@fieldwangai/agentflow 0.1.131 → 0.1.134
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/prd-workflow-collaboration.mjs +24 -3
- package/bin/lib/teams.mjs +160 -0
- package/bin/lib/ui-server.mjs +193 -3
- package/bin/lib/workspace-collaboration.mjs +52 -2
- package/builtin/web-ui/dist/assets/index-CqXKONpd.js +350 -0
- package/builtin/web-ui/dist/assets/{index-DQA8LAlU.css → index-QDDFbZ_T.css} +1 -1
- package/builtin/web-ui/dist/index.html +2 -2
- package/package.json +1 -1
- package/builtin/web-ui/dist/assets/index-C1QUYyi5.js +0 -350
|
@@ -1,350 +0,0 @@
|
|
|
1
|
-
var KL=Object.defineProperty;var qL=(e,t,n)=>t in e?KL(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Fn=(e,t,n)=>qL(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 gd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ia(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var nE={exports:{}},Am={},rE={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 nf=Symbol.for("react.element"),UL=Symbol.for("react.portal"),YL=Symbol.for("react.fragment"),GL=Symbol.for("react.strict_mode"),JL=Symbol.for("react.profiler"),XL=Symbol.for("react.provider"),QL=Symbol.for("react.context"),ZL=Symbol.for("react.forward_ref"),e2=Symbol.for("react.suspense"),t2=Symbol.for("react.memo"),n2=Symbol.for("react.lazy"),F0=Symbol.iterator;function r2(e){return e===null||typeof e!="object"?null:(e=F0&&e[F0]||e["@@iterator"],typeof e=="function"?e:null)}var sE={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},iE=Object.assign,oE={};function Dc(e,t,n){this.props=e,this.context=t,this.refs=oE,this.updater=n||sE}Dc.prototype.isReactComponent={};Dc.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")};Dc.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function aE(){}aE.prototype=Dc.prototype;function Pb(e,t,n){this.props=e,this.context=t,this.refs=oE,this.updater=n||sE}var Ib=Pb.prototype=new aE;Ib.constructor=Pb;iE(Ib,Dc.prototype);Ib.isPureReactComponent=!0;var z0=Array.isArray,lE=Object.prototype.hasOwnProperty,Rb={current:null},cE={key:!0,ref:!0,__self:!0,__source:!0};function uE(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)lE.call(t,r)&&!cE.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:nf,type:e,key:o,ref:a,props:s,_owner:Rb.current}}function s2(e,t){return{$$typeof:nf,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Tb(e){return typeof e=="object"&&e!==null&&e.$$typeof===nf}function i2(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var B0=/\/+/g;function sy(e,t){return typeof e=="object"&&e!==null&&e.key!=null?i2(""+e.key):t.toString(36)}function Gp(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 nf:case UL:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+sy(a,0):r,z0(s)?(n="",e!=null&&(n=e.replace(B0,"$&/")+"/"),Gp(s,t,n,"",function(u){return u})):s!=null&&(Tb(s)&&(s=s2(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(B0,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",z0(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+sy(o,l);a+=Gp(o,t,n,c,s)}else if(c=r2(e),typeof c=="function")for(e=c.call(e),l=0;!(o=e.next()).done;)o=o.value,c=r+sy(o,l++),a+=Gp(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 tp(e,t,n){if(e==null)return e;var r=[],s=0;return Gp(e,r,"","",function(o){return t.call(n,o,s++)}),r}function o2(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 Dr={current:null},Jp={transition:null},a2={ReactCurrentDispatcher:Dr,ReactCurrentBatchConfig:Jp,ReactCurrentOwner:Rb};function dE(){throw Error("act(...) is not supported in production builds of React.")}Rt.Children={map:tp,forEach:function(e,t,n){tp(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return tp(e,function(){t++}),t},toArray:function(e){return tp(e,function(t){return t})||[]},only:function(e){if(!Tb(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Rt.Component=Dc;Rt.Fragment=YL;Rt.Profiler=JL;Rt.PureComponent=Pb;Rt.StrictMode=GL;Rt.Suspense=e2;Rt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=a2;Rt.act=dE;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=iE({},e.props),s=e.key,o=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,a=Rb.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)lE.call(t,c)&&!cE.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:nf,type:e.type,key:s,ref:o,props:r,_owner:a}};Rt.createContext=function(e){return e={$$typeof:QL,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:XL,_context:e},e.Consumer=e};Rt.createElement=uE;Rt.createFactory=function(e){var t=uE.bind(null,e);return t.type=e,t};Rt.createRef=function(){return{current:null}};Rt.forwardRef=function(e){return{$$typeof:ZL,render:e}};Rt.isValidElement=Tb;Rt.lazy=function(e){return{$$typeof:n2,_payload:{_status:-1,_result:e},_init:o2}};Rt.memo=function(e,t){return{$$typeof:t2,type:e,compare:t===void 0?null:t}};Rt.startTransition=function(e){var t=Jp.transition;Jp.transition={};try{e()}finally{Jp.transition=t}};Rt.unstable_act=dE;Rt.useCallback=function(e,t){return Dr.current.useCallback(e,t)};Rt.useContext=function(e){return Dr.current.useContext(e)};Rt.useDebugValue=function(){};Rt.useDeferredValue=function(e){return Dr.current.useDeferredValue(e)};Rt.useEffect=function(e,t){return Dr.current.useEffect(e,t)};Rt.useId=function(){return Dr.current.useId()};Rt.useImperativeHandle=function(e,t,n){return Dr.current.useImperativeHandle(e,t,n)};Rt.useInsertionEffect=function(e,t){return Dr.current.useInsertionEffect(e,t)};Rt.useLayoutEffect=function(e,t){return Dr.current.useLayoutEffect(e,t)};Rt.useMemo=function(e,t){return Dr.current.useMemo(e,t)};Rt.useReducer=function(e,t,n){return Dr.current.useReducer(e,t,n)};Rt.useRef=function(e){return Dr.current.useRef(e)};Rt.useState=function(e){return Dr.current.useState(e)};Rt.useSyncExternalStore=function(e,t,n){return Dr.current.useSyncExternalStore(e,t,n)};Rt.useTransition=function(){return Dr.current.useTransition()};Rt.version="18.3.1";rE.exports=Rt;var m=rE.exports;const dt=ia(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 l2=m,c2=Symbol.for("react.element"),u2=Symbol.for("react.fragment"),d2=Object.prototype.hasOwnProperty,f2=l2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,p2={key:!0,ref:!0,__self:!0,__source:!0};function fE(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)d2.call(t,r)&&!p2.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:c2,type:e,key:o,ref:a,props:s,_owner:f2.current}}Am.Fragment=u2;Am.jsx=fE;Am.jsxs=fE;nE.exports=Am;var i=nE.exports,Ew={},pE={exports:{}},hs={},hE={exports:{}},mE={};/**
|
|
18
|
-
* @license React
|
|
19
|
-
* scheduler.production.min.js
|
|
20
|
-
*
|
|
21
|
-
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
22
|
-
*
|
|
23
|
-
* This source code is licensed under the MIT license found in the
|
|
24
|
-
* LICENSE file in the root directory of this source tree.
|
|
25
|
-
*/(function(e){function t($,W){var E=$.length;$.push(W);e:for(;0<E;){var Q=E-1>>>1,V=$[Q];if(0<s(V,W))$[Q]=W,$[E]=V,E=Q;else break e}}function n($){return $.length===0?null:$[0]}function r($){if($.length===0)return null;var W=$[0],E=$.pop();if(E!==W){$[0]=E;e:for(var Q=0,V=$.length,B=V>>>1;Q<B;){var se=2*(Q+1)-1,ue=$[se],G=se+1,ee=$[G];if(0>s(ue,E))G<V&&0>s(ee,ue)?($[Q]=ee,$[G]=E,Q=G):($[Q]=ue,$[se]=E,Q=se);else if(G<V&&0>s(ee,E))$[Q]=ee,$[G]=E,Q=G;else break e}}return W}function s($,W){var E=$.sortIndex-W.sortIndex;return E!==0?E:$.id-W.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var c=[],u=[],d=1,f=null,p=3,h=!1,y=!1,v=!1,w=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 b($){for(var W=n(u);W!==null;){if(W.callback===null)r(u);else if(W.startTime<=$)r(u),W.sortIndex=W.expirationTime,t(c,W);else break;W=n(u)}}function j($){if(v=!1,b($),!y)if(n(c)!==null)y=!0,z(N);else{var W=n(u);W!==null&&F(j,W.startTime-$)}}function N($,W){y=!1,v&&(v=!1,g(R),R=-1),h=!0;var E=p;try{for(b(W),f=n(c);f!==null&&(!(f.expirationTime>W)||$&&!L());){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),b(W)}else r(c);f=n(c)}if(f!==null)var B=!0;else{var se=n(u);se!==null&&F(j,se.startTime-W),B=!1}return B}finally{f=null,p=E,h=!1}}var C=!1,I=null,R=-1,H=5,A=-1;function L(){return!(e.unstable_now()-A<H)}function D(){if(I!==null){var $=e.unstable_now();A=$;var W=!0;try{W=I(!0,$)}finally{W?O():(C=!1,I=null)}}else C=!1}var O;if(typeof k=="function")O=function(){k(D)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,K=M.port2;M.port1.onmessage=D,O=function(){K.postMessage(null)}}else O=function(){w(D,0)};function z($){I=$,C||(C=!0,O())}function F($,W){R=w(function(){$(e.unstable_now())},W)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function($){$.callback=null},e.unstable_continueExecution=function(){y||h||(y=!0,z(N))},e.unstable_forceFrameRate=function($){0>$||125<$?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):H=0<$?Math.floor(1e3/$):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function($){switch(p){case 1:case 2:case 3:var W=3;break;default:W=p}var E=p;p=W;try{return $()}finally{p=E}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function($,W){switch($){case 1:case 2:case 3:case 4:case 5:break;default:$=3}var E=p;p=$;try{return W()}finally{p=E}},e.unstable_scheduleCallback=function($,W,E){var Q=e.unstable_now();switch(typeof E=="object"&&E!==null?(E=E.delay,E=typeof E=="number"&&0<E?Q+E:Q):E=Q,$){case 1:var 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,$={id:d++,callback:W,priorityLevel:$,startTime:E,expirationTime:V,sortIndex:-1},E>Q?($.sortIndex=E,t(u,$),n(c)===null&&$===n(u)&&(v?(g(R),R=-1):v=!0,F(j,E-Q))):($.sortIndex=V,t(c,$),y||h||(y=!0,z(N))),$},e.unstable_shouldYield=L,e.unstable_wrapCallback=function($){var W=p;return function(){var E=p;p=W;try{return $.apply(this,arguments)}finally{p=E}}}})(mE);hE.exports=mE;var h2=hE.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 m2=m,fs=h2;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 gE=new Set,yd={};function il(e,t){xc(e,t),xc(e+"Capture",t)}function xc(e,t){for(yd[e]=t,e=0;e<t.length;e++)gE.add(t[e])}var ro=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),Aw=Object.prototype.hasOwnProperty,g2=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,H0={},W0={};function y2(e){return Aw.call(W0,e)?!0:Aw.call(H0,e)?!1:g2.test(e)?W0[e]=!0:(H0[e]=!0,!1)}function w2(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function x2(e,t,n,r){if(t===null||typeof t>"u"||w2(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 Fr(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 wr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){wr[e]=new Fr(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];wr[t]=new Fr(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){wr[e]=new Fr(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){wr[e]=new Fr(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){wr[e]=new Fr(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){wr[e]=new Fr(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){wr[e]=new Fr(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){wr[e]=new Fr(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){wr[e]=new Fr(e,5,!1,e.toLowerCase(),null,!1,!1)});var Mb=/[\-:]([a-z])/g;function $b(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(Mb,$b);wr[t]=new Fr(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(Mb,$b);wr[t]=new Fr(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(Mb,$b);wr[t]=new Fr(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){wr[e]=new Fr(e,1,!1,e.toLowerCase(),null,!1,!1)});wr.xlinkHref=new Fr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){wr[e]=new Fr(e,1,!1,e.toLowerCase(),null,!0,!0)});function Lb(e,t,n,r){var s=wr.hasOwnProperty(t)?wr[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(x2(t,n,s,r)&&(n=null),r||s===null?y2(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):s.mustUseProperty?e[s.propertyName]=n===null?s.type===3?!1:"":n:(t=s.attributeName,r=s.attributeNamespace,n===null?e.removeAttribute(t):(s=s.type,n=s===3||s===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var fo=m2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,np=Symbol.for("react.element"),Bl=Symbol.for("react.portal"),Hl=Symbol.for("react.fragment"),Ob=Symbol.for("react.strict_mode"),Pw=Symbol.for("react.profiler"),yE=Symbol.for("react.provider"),wE=Symbol.for("react.context"),Db=Symbol.for("react.forward_ref"),Iw=Symbol.for("react.suspense"),Rw=Symbol.for("react.suspense_list"),Fb=Symbol.for("react.memo"),Po=Symbol.for("react.lazy"),xE=Symbol.for("react.offscreen"),V0=Symbol.iterator;function bu(e){return e===null||typeof e!="object"?null:(e=V0&&e[V0]||e["@@iterator"],typeof e=="function"?e:null)}var Ln=Object.assign,iy;function Fu(e){if(iy===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);iy=t&&t[1]||""}return`
|
|
34
|
-
`+iy+e}var oy=!1;function ay(e,t){if(!e||oy)return"";oy=!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{oy=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Fu(e):""}function b2(e){switch(e.tag){case 5:return Fu(e.type);case 16:return Fu("Lazy");case 13:return Fu("Suspense");case 19:return Fu("SuspenseList");case 0:case 2:case 15:return e=ay(e.type,!1),e;case 11:return e=ay(e.type.render,!1),e;case 1:return e=ay(e.type,!0),e;default:return""}}function Tw(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 Hl:return"Fragment";case Bl:return"Portal";case Pw:return"Profiler";case Ob:return"StrictMode";case Iw:return"Suspense";case Rw:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case wE:return(e.displayName||"Context")+".Consumer";case yE:return(e._context.displayName||"Context")+".Provider";case Db:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Fb:return t=e.displayName||null,t!==null?t:Tw(e.type)||"Memo";case Po:t=e._payload,e=e._init;try{return Tw(e(t))}catch{}}return null}function k2(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 Tw(t);case 8:return t===Ob?"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 Xo(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function bE(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function v2(e){var t=bE(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 rp(e){e._valueTracker||(e._valueTracker=v2(e))}function kE(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=bE(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function kh(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 Mw(e,t){var n=t.checked;return Ln({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function K0(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=Xo(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 vE(e,t){t=t.checked,t!=null&&Lb(e,"checked",t,!1)}function $w(e,t){vE(e,t);var n=Xo(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")?Lw(e,t.type,n):t.hasOwnProperty("defaultValue")&&Lw(e,t.type,Xo(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function q0(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 Lw(e,t,n){(t!=="number"||kh(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var zu=Array.isArray;function ic(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=""+Xo(n),t=null,s=0;s<e.length;s++){if(e[s].value===n){e[s].selected=!0,r&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function Ow(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Ae(91));return Ln({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function U0(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(zu(n)){if(1<n.length)throw Error(Ae(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:Xo(n)}}function SE(e,t){var n=Xo(t.value),r=Xo(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 Y0(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function jE(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 Dw(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?jE(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var sp,NE=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(sp=sp||document.createElement("div"),sp.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=sp.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function wd(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var Xu={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},S2=["Webkit","ms","Moz","O"];Object.keys(Xu).forEach(function(e){S2.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),Xu[t]=Xu[e]})});function CE(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||Xu.hasOwnProperty(e)&&Xu[e]?(""+t).trim():t+"px"}function _E(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=CE(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var j2=Ln({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 Fw(e,t){if(t){if(j2[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 zw(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 Bw=null;function zb(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var Hw=null,oc=null,ac=null;function G0(e){if(e=of(e)){if(typeof Hw!="function")throw Error(Ae(280));var t=e.stateNode;t&&(t=Mm(t),Hw(e.stateNode,e.type,t))}}function EE(e){oc?ac?ac.push(e):ac=[e]:oc=e}function AE(){if(oc){var e=oc,t=ac;if(ac=oc=null,G0(e),t)for(e=0;e<t.length;e++)G0(t[e])}}function PE(e,t){return e(t)}function IE(){}var ly=!1;function RE(e,t,n){if(ly)return e(t,n);ly=!0;try{return PE(e,t,n)}finally{ly=!1,(oc!==null||ac!==null)&&(IE(),AE())}}function xd(e,t){var n=e.stateNode;if(n===null)return null;var r=Mm(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 Ww=!1;if(ro)try{var ku={};Object.defineProperty(ku,"passive",{get:function(){Ww=!0}}),window.addEventListener("test",ku,ku),window.removeEventListener("test",ku,ku)}catch{Ww=!1}function N2(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 Qu=!1,vh=null,Sh=!1,Vw=null,C2={onError:function(e){Qu=!0,vh=e}};function _2(e,t,n,r,s,o,a,l,c){Qu=!1,vh=null,N2.apply(C2,arguments)}function E2(e,t,n,r,s,o,a,l,c){if(_2.apply(this,arguments),Qu){if(Qu){var u=vh;Qu=!1,vh=null}else throw Error(Ae(198));Sh||(Sh=!0,Vw=u)}}function ol(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 TE(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 J0(e){if(ol(e)!==e)throw Error(Ae(188))}function A2(e){var t=e.alternate;if(!t){if(t=ol(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 J0(s),e;if(o===r)return J0(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 ME(e){return e=A2(e),e!==null?$E(e):null}function $E(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=$E(e);if(t!==null)return t;e=e.sibling}return null}var LE=fs.unstable_scheduleCallback,X0=fs.unstable_cancelCallback,P2=fs.unstable_shouldYield,I2=fs.unstable_requestPaint,Vn=fs.unstable_now,R2=fs.unstable_getCurrentPriorityLevel,Bb=fs.unstable_ImmediatePriority,OE=fs.unstable_UserBlockingPriority,jh=fs.unstable_NormalPriority,T2=fs.unstable_LowPriority,DE=fs.unstable_IdlePriority,Pm=null,ji=null;function M2(e){if(ji&&typeof ji.onCommitFiberRoot=="function")try{ji.onCommitFiberRoot(Pm,e,void 0,(e.current.flags&128)===128)}catch{}}var Zs=Math.clz32?Math.clz32:O2,$2=Math.log,L2=Math.LN2;function O2(e){return e>>>=0,e===0?32:31-($2(e)/L2|0)|0}var ip=64,op=4194304;function Bu(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 Nh(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=Bu(l):(o&=a,o!==0&&(r=Bu(o)))}else a=n&~s,a!==0?r=Bu(a):o!==0&&(r=Bu(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-Zs(t),s=1<<n,r|=e[n],t&=~s;return r}function D2(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 F2(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,o=e.pendingLanes;0<o;){var a=31-Zs(o),l=1<<a,c=s[a];c===-1?(!(l&n)||l&r)&&(s[a]=D2(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function Kw(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function FE(){var e=ip;return ip<<=1,!(ip&4194240)&&(ip=64),e}function cy(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function rf(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Zs(t),e[t]=n}function z2(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-Zs(n),o=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~o}}function Hb(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Zs(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var an=0;function zE(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var BE,Wb,HE,WE,VE,qw=!1,ap=[],Bo=null,Ho=null,Wo=null,bd=new Map,kd=new Map,To=[],B2="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 Q0(e,t){switch(e){case"focusin":case"focusout":Bo=null;break;case"dragenter":case"dragleave":Ho=null;break;case"mouseover":case"mouseout":Wo=null;break;case"pointerover":case"pointerout":bd.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":kd.delete(t.pointerId)}}function vu(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=of(t),t!==null&&Wb(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function H2(e,t,n,r,s){switch(t){case"focusin":return Bo=vu(Bo,e,t,n,r,s),!0;case"dragenter":return Ho=vu(Ho,e,t,n,r,s),!0;case"mouseover":return Wo=vu(Wo,e,t,n,r,s),!0;case"pointerover":var o=s.pointerId;return bd.set(o,vu(bd.get(o)||null,e,t,n,r,s)),!0;case"gotpointercapture":return o=s.pointerId,kd.set(o,vu(kd.get(o)||null,e,t,n,r,s)),!0}return!1}function KE(e){var t=Pa(e.target);if(t!==null){var n=ol(t);if(n!==null){if(t=n.tag,t===13){if(t=TE(n),t!==null){e.blockedOn=t,VE(e.priority,function(){HE(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 Xp(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Uw(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);Bw=r,n.target.dispatchEvent(r),Bw=null}else return t=of(n),t!==null&&Wb(t),e.blockedOn=n,!1;t.shift()}return!0}function Z0(e,t,n){Xp(e)&&n.delete(t)}function W2(){qw=!1,Bo!==null&&Xp(Bo)&&(Bo=null),Ho!==null&&Xp(Ho)&&(Ho=null),Wo!==null&&Xp(Wo)&&(Wo=null),bd.forEach(Z0),kd.forEach(Z0)}function Su(e,t){e.blockedOn===t&&(e.blockedOn=null,qw||(qw=!0,fs.unstable_scheduleCallback(fs.unstable_NormalPriority,W2)))}function vd(e){function t(s){return Su(s,e)}if(0<ap.length){Su(ap[0],e);for(var n=1;n<ap.length;n++){var r=ap[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Bo!==null&&Su(Bo,e),Ho!==null&&Su(Ho,e),Wo!==null&&Su(Wo,e),bd.forEach(t),kd.forEach(t),n=0;n<To.length;n++)r=To[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<To.length&&(n=To[0],n.blockedOn===null);)KE(n),n.blockedOn===null&&To.shift()}var lc=fo.ReactCurrentBatchConfig,Ch=!0;function V2(e,t,n,r){var s=an,o=lc.transition;lc.transition=null;try{an=1,Vb(e,t,n,r)}finally{an=s,lc.transition=o}}function K2(e,t,n,r){var s=an,o=lc.transition;lc.transition=null;try{an=4,Vb(e,t,n,r)}finally{an=s,lc.transition=o}}function Vb(e,t,n,r){if(Ch){var s=Uw(e,t,n,r);if(s===null)xy(e,t,r,_h,n),Q0(e,r);else if(H2(s,e,t,n,r))r.stopPropagation();else if(Q0(e,r),t&4&&-1<B2.indexOf(e)){for(;s!==null;){var o=of(s);if(o!==null&&BE(o),o=Uw(e,t,n,r),o===null&&xy(e,t,r,_h,n),o===s)break;s=o}s!==null&&r.stopPropagation()}else xy(e,t,r,null,n)}}var _h=null;function Uw(e,t,n,r){if(_h=null,e=zb(r),e=Pa(e),e!==null)if(t=ol(e),t===null)e=null;else if(n=t.tag,n===13){if(e=TE(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null);return _h=e,null}function qE(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(R2()){case Bb:return 1;case OE:return 4;case jh:case T2:return 16;case DE:return 536870912;default:return 16}default:return 16}}var Oo=null,Kb=null,Qp=null;function UE(){if(Qp)return Qp;var e,t=Kb,n=t.length,r,s="value"in Oo?Oo.value:Oo.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 Qp=s.slice(e,1<r?1-r:void 0)}function Zp(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 lp(){return!0}function ej(){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)?lp:ej,this.isPropagationStopped=ej,this}return Ln(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=lp)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=lp)},persist:function(){},isPersistent:lp}),t}var Fc={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},qb=ms(Fc),sf=Ln({},Fc,{view:0,detail:0}),q2=ms(sf),uy,dy,ju,Im=Ln({},sf,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Ub,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!==ju&&(ju&&e.type==="mousemove"?(uy=e.screenX-ju.screenX,dy=e.screenY-ju.screenY):dy=uy=0,ju=e),uy)},movementY:function(e){return"movementY"in e?e.movementY:dy}}),tj=ms(Im),U2=Ln({},Im,{dataTransfer:0}),Y2=ms(U2),G2=Ln({},sf,{relatedTarget:0}),fy=ms(G2),J2=Ln({},Fc,{animationName:0,elapsedTime:0,pseudoElement:0}),X2=ms(J2),Q2=Ln({},Fc,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),Z2=ms(Q2),eO=Ln({},Fc,{data:0}),nj=ms(eO),tO={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},nO={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"},rO={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function sO(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=rO[e])?!!t[e]:!1}function Ub(){return sO}var iO=Ln({},sf,{key:function(e){if(e.key){var t=tO[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=Zp(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?nO[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Ub,charCode:function(e){return e.type==="keypress"?Zp(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?Zp(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),oO=ms(iO),aO=Ln({},Im,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),rj=ms(aO),lO=Ln({},sf,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Ub}),cO=ms(lO),uO=Ln({},Fc,{propertyName:0,elapsedTime:0,pseudoElement:0}),dO=ms(uO),fO=Ln({},Im,{deltaX:function(e){return"deltaX"in e?e.deltaX:"wheelDeltaX"in e?-e.wheelDeltaX:0},deltaY:function(e){return"deltaY"in e?e.deltaY:"wheelDeltaY"in e?-e.wheelDeltaY:"wheelDelta"in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0}),pO=ms(fO),hO=[9,13,27,32],Yb=ro&&"CompositionEvent"in window,Zu=null;ro&&"documentMode"in document&&(Zu=document.documentMode);var mO=ro&&"TextEvent"in window&&!Zu,YE=ro&&(!Yb||Zu&&8<Zu&&11>=Zu),sj=" ",ij=!1;function GE(e,t){switch(e){case"keyup":return hO.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function JE(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Wl=!1;function gO(e,t){switch(e){case"compositionend":return JE(t);case"keypress":return t.which!==32?null:(ij=!0,sj);case"textInput":return e=t.data,e===sj&&ij?null:e;default:return null}}function yO(e,t){if(Wl)return e==="compositionend"||!Yb&&GE(e,t)?(e=UE(),Qp=Kb=Oo=null,Wl=!1,e):null;switch(e){case"paste":return null;case"keypress":if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case"compositionend":return YE&&t.locale!=="ko"?null:t.data;default:return null}}var wO={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 oj(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!wO[e.type]:t==="textarea"}function XE(e,t,n,r){EE(r),t=Eh(t,"onChange"),0<t.length&&(n=new qb("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var ed=null,Sd=null;function xO(e){lA(e,0)}function Rm(e){var t=ql(e);if(kE(t))return e}function bO(e,t){if(e==="change")return t}var QE=!1;if(ro){var py;if(ro){var hy="oninput"in document;if(!hy){var aj=document.createElement("div");aj.setAttribute("oninput","return;"),hy=typeof aj.oninput=="function"}py=hy}else py=!1;QE=py&&(!document.documentMode||9<document.documentMode)}function lj(){ed&&(ed.detachEvent("onpropertychange",ZE),Sd=ed=null)}function ZE(e){if(e.propertyName==="value"&&Rm(Sd)){var t=[];XE(t,Sd,e,zb(e)),RE(xO,t)}}function kO(e,t,n){e==="focusin"?(lj(),ed=t,Sd=n,ed.attachEvent("onpropertychange",ZE)):e==="focusout"&&lj()}function vO(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Rm(Sd)}function SO(e,t){if(e==="click")return Rm(t)}function jO(e,t){if(e==="input"||e==="change")return Rm(t)}function NO(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var ni=typeof Object.is=="function"?Object.is:NO;function jd(e,t){if(ni(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(!Aw.call(t,s)||!ni(e[s],t[s]))return!1}return!0}function cj(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function uj(e,t){var n=cj(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=cj(n)}}function eA(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?eA(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function tA(){for(var e=window,t=kh();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=kh(e.document)}return t}function Gb(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 CO(e){var t=tA(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&eA(n.ownerDocument.documentElement,n)){if(r!==null&&Gb(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=uj(n,o);var a=uj(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 _O=ro&&"documentMode"in document&&11>=document.documentMode,Vl=null,Yw=null,td=null,Gw=!1;function dj(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Gw||Vl==null||Vl!==kh(r)||(r=Vl,"selectionStart"in r&&Gb(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}),td&&jd(td,r)||(td=r,r=Eh(Yw,"onSelect"),0<r.length&&(t=new qb("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Vl)))}function cp(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Kl={animationend:cp("Animation","AnimationEnd"),animationiteration:cp("Animation","AnimationIteration"),animationstart:cp("Animation","AnimationStart"),transitionend:cp("Transition","TransitionEnd")},my={},nA={};ro&&(nA=document.createElement("div").style,"AnimationEvent"in window||(delete Kl.animationend.animation,delete Kl.animationiteration.animation,delete Kl.animationstart.animation),"TransitionEvent"in window||delete Kl.transitionend.transition);function Tm(e){if(my[e])return my[e];if(!Kl[e])return e;var t=Kl[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in nA)return my[e]=t[n];return e}var rA=Tm("animationend"),sA=Tm("animationiteration"),iA=Tm("animationstart"),oA=Tm("transitionend"),aA=new Map,fj="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 oa(e,t){aA.set(e,t),il(t,[e])}for(var gy=0;gy<fj.length;gy++){var yy=fj[gy],EO=yy.toLowerCase(),AO=yy[0].toUpperCase()+yy.slice(1);oa(EO,"on"+AO)}oa(rA,"onAnimationEnd");oa(sA,"onAnimationIteration");oa(iA,"onAnimationStart");oa("dblclick","onDoubleClick");oa("focusin","onFocus");oa("focusout","onBlur");oa(oA,"onTransitionEnd");xc("onMouseEnter",["mouseout","mouseover"]);xc("onMouseLeave",["mouseout","mouseover"]);xc("onPointerEnter",["pointerout","pointerover"]);xc("onPointerLeave",["pointerout","pointerover"]);il("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));il("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));il("onBeforeInput",["compositionend","keypress","textInput","paste"]);il("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));il("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));il("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Hu="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(" "),PO=new Set("cancel close invalid load scroll toggle".split(" ").concat(Hu));function pj(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,E2(r,t,void 0,e),e.currentTarget=null}function lA(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;pj(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;pj(s,l,u),o=c}}}if(Sh)throw e=Vw,Sh=!1,Vw=null,e}function kn(e,t){var n=t[ex];n===void 0&&(n=t[ex]=new Set);var r=e+"__bubble";n.has(r)||(cA(t,e,2,!1),n.add(r))}function wy(e,t,n){var r=0;t&&(r|=4),cA(n,e,r,t)}var up="_reactListening"+Math.random().toString(36).slice(2);function Nd(e){if(!e[up]){e[up]=!0,gE.forEach(function(n){n!=="selectionchange"&&(PO.has(n)||wy(n,!1,e),wy(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[up]||(t[up]=!0,wy("selectionchange",!1,t))}}function cA(e,t,n,r){switch(qE(t)){case 1:var s=V2;break;case 4:s=K2;break;default:s=Vb}n=s.bind(null,t,n,e),s=void 0,!Ww||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 xy(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=Pa(l),a===null)return;if(c=a.tag,c===5||c===6){r=o=a;continue e}l=l.parentNode}}r=r.return}RE(function(){var u=o,d=zb(n),f=[];e:{var p=aA.get(e);if(p!==void 0){var h=qb,y=e;switch(e){case"keypress":if(Zp(n)===0)break e;case"keydown":case"keyup":h=oO;break;case"focusin":y="focus",h=fy;break;case"focusout":y="blur",h=fy;break;case"beforeblur":case"afterblur":h=fy;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=tj;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":h=Y2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":h=cO;break;case rA:case sA:case iA:h=X2;break;case oA:h=dO;break;case"scroll":h=q2;break;case"wheel":h=pO;break;case"copy":case"cut":case"paste":h=Z2;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":h=rj}var v=(t&4)!==0,w=!v&&e==="scroll",g=v?p!==null?p+"Capture":null:p;v=[];for(var k=u,b;k!==null;){b=k;var j=b.stateNode;if(b.tag===5&&j!==null&&(b=j,g!==null&&(j=xd(k,g),j!=null&&v.push(Cd(k,j,b)))),w)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!==Bw&&(y=n.relatedTarget||n.fromElement)&&(Pa(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?Pa(y):null,y!==null&&(w=ol(y),y!==w||y.tag!==5&&y.tag!==6)&&(y=null)):(h=null,y=u),h!==y)){if(v=tj,j="onMouseLeave",g="onMouseEnter",k="mouse",(e==="pointerout"||e==="pointerover")&&(v=rj,j="onPointerLeave",g="onPointerEnter",k="pointer"),w=h==null?p:ql(h),b=y==null?p:ql(y),p=new v(j,k+"leave",h,n,d),p.target=w,p.relatedTarget=b,j=null,Pa(d)===u&&(v=new v(g,k+"enter",y,n,d),v.target=b,v.relatedTarget=w,j=v),w=j,h&&y)t:{for(v=h,g=y,k=0,b=v;b;b=Al(b))k++;for(b=0,j=g;j;j=Al(j))b++;for(;0<k-b;)v=Al(v),k--;for(;0<b-k;)g=Al(g),b--;for(;k--;){if(v===g||g!==null&&v===g.alternate)break t;v=Al(v),g=Al(g)}v=null}else v=null;h!==null&&hj(f,p,h,v,!1),y!==null&&w!==null&&hj(f,w,y,v,!0)}}e:{if(p=u?ql(u):window,h=p.nodeName&&p.nodeName.toLowerCase(),h==="select"||h==="input"&&p.type==="file")var N=bO;else if(oj(p))if(QE)N=jO;else{N=vO;var C=kO}else(h=p.nodeName)&&h.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(N=SO);if(N&&(N=N(e,u))){XE(f,N,n,d);break e}C&&C(e,p,u),e==="focusout"&&(C=p._wrapperState)&&C.controlled&&p.type==="number"&&Lw(p,"number",p.value)}switch(C=u?ql(u):window,e){case"focusin":(oj(C)||C.contentEditable==="true")&&(Vl=C,Yw=u,td=null);break;case"focusout":td=Yw=Vl=null;break;case"mousedown":Gw=!0;break;case"contextmenu":case"mouseup":case"dragend":Gw=!1,dj(f,n,d);break;case"selectionchange":if(_O)break;case"keydown":case"keyup":dj(f,n,d)}var I;if(Yb)e:{switch(e){case"compositionstart":var R="onCompositionStart";break e;case"compositionend":R="onCompositionEnd";break e;case"compositionupdate":R="onCompositionUpdate";break e}R=void 0}else Wl?GE(e,n)&&(R="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(R="onCompositionStart");R&&(YE&&n.locale!=="ko"&&(Wl||R!=="onCompositionStart"?R==="onCompositionEnd"&&Wl&&(I=UE()):(Oo=d,Kb="value"in Oo?Oo.value:Oo.textContent,Wl=!0)),C=Eh(u,R),0<C.length&&(R=new nj(R,e,null,n,d),f.push({event:R,listeners:C}),I?R.data=I:(I=JE(n),I!==null&&(R.data=I)))),(I=mO?gO(e,n):yO(e,n))&&(u=Eh(u,"onBeforeInput"),0<u.length&&(d=new nj("onBeforeInput","beforeinput",null,n,d),f.push({event:d,listeners:u}),d.data=I))}lA(f,t)})}function Cd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function Eh(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,o=s.stateNode;s.tag===5&&o!==null&&(s=o,o=xd(e,n),o!=null&&r.unshift(Cd(e,o,s)),o=xd(e,t),o!=null&&r.push(Cd(e,o,s))),e=e.return}return r}function Al(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function hj(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=xd(n,o),c!=null&&a.unshift(Cd(n,c,l))):s||(c=xd(n,o),c!=null&&a.push(Cd(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var IO=/\r\n?/g,RO=/\u0000|\uFFFD/g;function mj(e){return(typeof e=="string"?e:""+e).replace(IO,`
|
|
38
|
-
`).replace(RO,"")}function dp(e,t,n){if(t=mj(t),mj(e)!==t&&n)throw Error(Ae(425))}function Ah(){}var Jw=null,Xw=null;function Qw(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 Zw=typeof setTimeout=="function"?setTimeout:void 0,TO=typeof clearTimeout=="function"?clearTimeout:void 0,gj=typeof Promise=="function"?Promise:void 0,MO=typeof queueMicrotask=="function"?queueMicrotask:typeof gj<"u"?function(e){return gj.resolve(null).then(e).catch($O)}:Zw;function $O(e){setTimeout(function(){throw e})}function by(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),vd(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);vd(t)}function Vo(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 yj(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 zc=Math.random().toString(36).slice(2),wi="__reactFiber$"+zc,_d="__reactProps$"+zc,so="__reactContainer$"+zc,ex="__reactEvents$"+zc,LO="__reactListeners$"+zc,OO="__reactHandles$"+zc;function Pa(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=yj(e);e!==null;){if(n=e[wi])return n;e=yj(e)}return t}e=n,n=e.parentNode}return null}function of(e){return e=e[wi]||e[so],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function ql(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Ae(33))}function Mm(e){return e[_d]||null}var tx=[],Ul=-1;function aa(e){return{current:e}}function Sn(e){0>Ul||(e.current=tx[Ul],tx[Ul]=null,Ul--)}function gn(e,t){Ul++,tx[Ul]=e.current,e.current=t}var Qo={},Er=aa(Qo),Jr=aa(!1),Wa=Qo;function bc(e,t){var n=e.type.contextTypes;if(!n)return Qo;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 Ph(){Sn(Jr),Sn(Er)}function wj(e,t,n){if(Er.current!==Qo)throw Error(Ae(168));gn(Er,t),gn(Jr,n)}function uA(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,k2(e)||"Unknown",s));return Ln({},n,r)}function Ih(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||Qo,Wa=Er.current,gn(Er,e),gn(Jr,Jr.current),!0}function xj(e,t,n){var r=e.stateNode;if(!r)throw Error(Ae(169));n?(e=uA(e,t,Wa),r.__reactInternalMemoizedMergedChildContext=e,Sn(Jr),Sn(Er),gn(Er,e)):Sn(Jr),gn(Jr,n)}var qi=null,$m=!1,ky=!1;function dA(e){qi===null?qi=[e]:qi.push(e)}function DO(e){$m=!0,dA(e)}function la(){if(!ky&&qi!==null){ky=!0;var e=0,t=an;try{var n=qi;for(an=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}qi=null,$m=!1}catch(s){throw qi!==null&&(qi=qi.slice(e+1)),LE(Bb,la),s}finally{an=t,ky=!1}}return null}var Yl=[],Gl=0,Rh=null,Th=0,Cs=[],_s=0,Va=null,Yi=1,Gi="";function Sa(e,t){Yl[Gl++]=Th,Yl[Gl++]=Rh,Rh=e,Th=t}function fA(e,t,n){Cs[_s++]=Yi,Cs[_s++]=Gi,Cs[_s++]=Va,Va=e;var r=Yi;e=Gi;var s=32-Zs(r)-1;r&=~(1<<s),n+=1;var o=32-Zs(t)+s;if(30<o){var a=s-s%5;o=(r&(1<<a)-1).toString(32),r>>=a,s-=a,Yi=1<<32-Zs(t)+s|n<<s|r,Gi=o+e}else Yi=1<<o|n<<s|r,Gi=e}function Jb(e){e.return!==null&&(Sa(e,1),fA(e,1,0))}function Xb(e){for(;e===Rh;)Rh=Yl[--Gl],Yl[Gl]=null,Th=Yl[--Gl],Yl[Gl]=null;for(;e===Va;)Va=Cs[--_s],Cs[_s]=null,Gi=Cs[--_s],Cs[_s]=null,Yi=Cs[--_s],Cs[_s]=null}var us=null,ls=null,_n=!1,Ys=null;function pA(e,t){var n=Ps(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 bj(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=Vo(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=Va!==null?{id:Yi,overflow:Gi}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Ps(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,us=e,ls=null,!0):!1;default:return!1}}function nx(e){return(e.mode&1)!==0&&(e.flags&128)===0}function rx(e){if(_n){var t=ls;if(t){var n=t;if(!bj(e,t)){if(nx(e))throw Error(Ae(418));t=Vo(n.nextSibling);var r=us;t&&bj(e,t)?pA(r,n):(e.flags=e.flags&-4097|2,_n=!1,us=e)}}else{if(nx(e))throw Error(Ae(418));e.flags=e.flags&-4097|2,_n=!1,us=e}}}function kj(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;us=e}function fp(e){if(e!==us)return!1;if(!_n)return kj(e),_n=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Qw(e.type,e.memoizedProps)),t&&(t=ls)){if(nx(e))throw hA(),Error(Ae(418));for(;t;)pA(e,t),t=Vo(t.nextSibling)}if(kj(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=Vo(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ls=null}}else ls=us?Vo(e.stateNode.nextSibling):null;return!0}function hA(){for(var e=ls;e;)e=Vo(e.nextSibling)}function kc(){ls=us=null,_n=!1}function Qb(e){Ys===null?Ys=[e]:Ys.push(e)}var FO=fo.ReactCurrentBatchConfig;function Nu(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 pp(e,t){throw e=Object.prototype.toString.call(t),Error(Ae(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function vj(e){var t=e._init;return t(e._payload)}function mA(e){function t(g,k){if(e){var b=g.deletions;b===null?(g.deletions=[k],g.flags|=16):b.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=Yo(g,k),g.index=0,g.sibling=null,g}function o(g,k,b){return g.index=b,e?(b=g.alternate,b!==null?(b=b.index,b<k?(g.flags|=2,k):b):(g.flags|=2,k)):(g.flags|=1048576,k)}function a(g){return e&&g.alternate===null&&(g.flags|=2),g}function l(g,k,b,j){return k===null||k.tag!==6?(k=Ey(b,g.mode,j),k.return=g,k):(k=s(k,b),k.return=g,k)}function c(g,k,b,j){var N=b.type;return N===Hl?d(g,k,b.props.children,j,b.key):k!==null&&(k.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===Po&&vj(N)===k.type)?(j=s(k,b.props),j.ref=Nu(g,k,b),j.return=g,j):(j=oh(b.type,b.key,b.props,null,g.mode,j),j.ref=Nu(g,k,b),j.return=g,j)}function u(g,k,b,j){return k===null||k.tag!==4||k.stateNode.containerInfo!==b.containerInfo||k.stateNode.implementation!==b.implementation?(k=Ay(b,g.mode,j),k.return=g,k):(k=s(k,b.children||[]),k.return=g,k)}function d(g,k,b,j,N){return k===null||k.tag!==7?(k=Oa(b,g.mode,j,N),k.return=g,k):(k=s(k,b),k.return=g,k)}function f(g,k,b){if(typeof k=="string"&&k!==""||typeof k=="number")return k=Ey(""+k,g.mode,b),k.return=g,k;if(typeof k=="object"&&k!==null){switch(k.$$typeof){case np:return b=oh(k.type,k.key,k.props,null,g.mode,b),b.ref=Nu(g,null,k),b.return=g,b;case Bl:return k=Ay(k,g.mode,b),k.return=g,k;case Po:var j=k._init;return f(g,j(k._payload),b)}if(zu(k)||bu(k))return k=Oa(k,g.mode,b,null),k.return=g,k;pp(g,k)}return null}function p(g,k,b,j){var N=k!==null?k.key:null;if(typeof b=="string"&&b!==""||typeof b=="number")return N!==null?null:l(g,k,""+b,j);if(typeof b=="object"&&b!==null){switch(b.$$typeof){case np:return b.key===N?c(g,k,b,j):null;case Bl:return b.key===N?u(g,k,b,j):null;case Po:return N=b._init,p(g,k,N(b._payload),j)}if(zu(b)||bu(b))return N!==null?null:d(g,k,b,j,null);pp(g,b)}return null}function h(g,k,b,j,N){if(typeof j=="string"&&j!==""||typeof j=="number")return g=g.get(b)||null,l(k,g,""+j,N);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case np:return g=g.get(j.key===null?b:j.key)||null,c(k,g,j,N);case Bl:return g=g.get(j.key===null?b:j.key)||null,u(k,g,j,N);case Po:var C=j._init;return h(g,k,b,C(j._payload),N)}if(zu(j)||bu(j))return g=g.get(b)||null,d(k,g,j,N,null);pp(k,j)}return null}function y(g,k,b,j){for(var N=null,C=null,I=k,R=k=0,H=null;I!==null&&R<b.length;R++){I.index>R?(H=I,I=null):H=I.sibling;var A=p(g,I,b[R],j);if(A===null){I===null&&(I=H);break}e&&I&&A.alternate===null&&t(g,I),k=o(A,k,R),C===null?N=A:C.sibling=A,C=A,I=H}if(R===b.length)return n(g,I),_n&&Sa(g,R),N;if(I===null){for(;R<b.length;R++)I=f(g,b[R],j),I!==null&&(k=o(I,k,R),C===null?N=I:C.sibling=I,C=I);return _n&&Sa(g,R),N}for(I=r(g,I);R<b.length;R++)H=h(I,g,R,b[R],j),H!==null&&(e&&H.alternate!==null&&I.delete(H.key===null?R:H.key),k=o(H,k,R),C===null?N=H:C.sibling=H,C=H);return e&&I.forEach(function(L){return t(g,L)}),_n&&Sa(g,R),N}function v(g,k,b,j){var N=bu(b);if(typeof N!="function")throw Error(Ae(150));if(b=N.call(b),b==null)throw Error(Ae(151));for(var C=N=null,I=k,R=k=0,H=null,A=b.next();I!==null&&!A.done;R++,A=b.next()){I.index>R?(H=I,I=null):H=I.sibling;var L=p(g,I,A.value,j);if(L===null){I===null&&(I=H);break}e&&I&&L.alternate===null&&t(g,I),k=o(L,k,R),C===null?N=L:C.sibling=L,C=L,I=H}if(A.done)return n(g,I),_n&&Sa(g,R),N;if(I===null){for(;!A.done;R++,A=b.next())A=f(g,A.value,j),A!==null&&(k=o(A,k,R),C===null?N=A:C.sibling=A,C=A);return _n&&Sa(g,R),N}for(I=r(g,I);!A.done;R++,A=b.next())A=h(I,g,R,A.value,j),A!==null&&(e&&A.alternate!==null&&I.delete(A.key===null?R:A.key),k=o(A,k,R),C===null?N=A:C.sibling=A,C=A);return e&&I.forEach(function(D){return t(g,D)}),_n&&Sa(g,R),N}function w(g,k,b,j){if(typeof b=="object"&&b!==null&&b.type===Hl&&b.key===null&&(b=b.props.children),typeof b=="object"&&b!==null){switch(b.$$typeof){case np:e:{for(var N=b.key,C=k;C!==null;){if(C.key===N){if(N=b.type,N===Hl){if(C.tag===7){n(g,C.sibling),k=s(C,b.props.children),k.return=g,g=k;break e}}else if(C.elementType===N||typeof N=="object"&&N!==null&&N.$$typeof===Po&&vj(N)===C.type){n(g,C.sibling),k=s(C,b.props),k.ref=Nu(g,C,b),k.return=g,g=k;break e}n(g,C);break}else t(g,C);C=C.sibling}b.type===Hl?(k=Oa(b.props.children,g.mode,j,b.key),k.return=g,g=k):(j=oh(b.type,b.key,b.props,null,g.mode,j),j.ref=Nu(g,k,b),j.return=g,g=j)}return a(g);case Bl:e:{for(C=b.key;k!==null;){if(k.key===C)if(k.tag===4&&k.stateNode.containerInfo===b.containerInfo&&k.stateNode.implementation===b.implementation){n(g,k.sibling),k=s(k,b.children||[]),k.return=g,g=k;break e}else{n(g,k);break}else t(g,k);k=k.sibling}k=Ay(b,g.mode,j),k.return=g,g=k}return a(g);case Po:return C=b._init,w(g,k,C(b._payload),j)}if(zu(b))return y(g,k,b,j);if(bu(b))return v(g,k,b,j);pp(g,b)}return typeof b=="string"&&b!==""||typeof b=="number"?(b=""+b,k!==null&&k.tag===6?(n(g,k.sibling),k=s(k,b),k.return=g,g=k):(n(g,k),k=Ey(b,g.mode,j),k.return=g,g=k),a(g)):n(g,k)}return w}var vc=mA(!0),gA=mA(!1),Mh=aa(null),$h=null,Jl=null,Zb=null;function ek(){Zb=Jl=$h=null}function tk(e){var t=Mh.current;Sn(Mh),e._currentValue=t}function sx(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 cc(e,t){$h=e,Zb=Jl=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Ur=!0),e.firstContext=null)}function Rs(e){var t=e._currentValue;if(Zb!==e)if(e={context:e,memoizedValue:t,next:null},Jl===null){if($h===null)throw Error(Ae(308));Jl=e,$h.dependencies={lanes:0,firstContext:e}}else Jl=Jl.next=e;return t}var Ia=null;function nk(e){Ia===null?Ia=[e]:Ia.push(e)}function yA(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,nk(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 Io=!1;function rk(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function wA(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 Ko(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Ut&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,nk(r)):(t.next=s.next,s.next=t),r.interleaved=t,io(e,n)}function eh(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,Hb(e,n)}}function Sj(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 Lh(e,t,n,r){var s=e.updateQueue;Io=!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=Ln({},f,p);break e;case 2:Io=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else h={eventTime:h,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},d===null?(u=d=h,c=f):d=d.next=h,a|=p;if(l=l.next,l===null){if(l=s.shared.pending,l===null)break;p=l,l=p.next,p.next=null,s.lastBaseUpdate=p,s.shared.pending=null}}while(!0);if(d===null&&(c=f),s.baseState=c,s.firstBaseUpdate=u,s.lastBaseUpdate=d,t=s.shared.interleaved,t!==null){s=t;do a|=s.lane,s=s.next;while(s!==t)}else o===null&&(s.shared.lanes=0);qa|=a,e.lanes=a,e.memoizedState=f}}function jj(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 af={},Ni=aa(af),Ed=aa(af),Ad=aa(af);function Ra(e){if(e===af)throw Error(Ae(174));return e}function sk(e,t){switch(gn(Ad,t),gn(Ed,e),gn(Ni,af),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:Dw(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=Dw(t,e)}Sn(Ni),gn(Ni,t)}function Sc(){Sn(Ni),Sn(Ed),Sn(Ad)}function xA(e){Ra(Ad.current);var t=Ra(Ni.current),n=Dw(t,e.type);t!==n&&(gn(Ed,e),gn(Ni,n))}function ik(e){Ed.current===e&&(Sn(Ni),Sn(Ed))}var Tn=aa(0);function Oh(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 vy=[];function ok(){for(var e=0;e<vy.length;e++)vy[e]._workInProgressVersionPrimary=null;vy.length=0}var th=fo.ReactCurrentDispatcher,Sy=fo.ReactCurrentBatchConfig,Ka=0,$n=null,nr=null,dr=null,Dh=!1,nd=!1,Pd=0,zO=0;function Sr(){throw Error(Ae(321))}function ak(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!ni(e[n],t[n]))return!1;return!0}function lk(e,t,n,r,s,o){if(Ka=o,$n=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,th.current=e===null||e.memoizedState===null?VO:KO,e=n(r,s),nd){o=0;do{if(nd=!1,Pd=0,25<=o)throw Error(Ae(301));o+=1,dr=nr=null,t.updateQueue=null,th.current=qO,e=n(r,s)}while(nd)}if(th.current=Fh,t=nr!==null&&nr.next!==null,Ka=0,dr=nr=$n=null,Dh=!1,t)throw Error(Ae(300));return e}function ck(){var e=Pd!==0;return Pd=0,e}function hi(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return dr===null?$n.memoizedState=dr=e:dr=dr.next=e,dr}function Ts(){if(nr===null){var e=$n.alternate;e=e!==null?e.memoizedState:null}else e=nr.next;var t=dr===null?$n.memoizedState:dr.next;if(t!==null)dr=t,nr=e;else{if(e===null)throw Error(Ae(310));nr=e,e={memoizedState:nr.memoizedState,baseState:nr.baseState,baseQueue:nr.baseQueue,queue:nr.queue,next:null},dr===null?$n.memoizedState=dr=e:dr=dr.next=e}return dr}function Id(e,t){return typeof t=="function"?t(e):t}function jy(e){var t=Ts(),n=t.queue;if(n===null)throw Error(Ae(311));n.lastRenderedReducer=e;var r=nr,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((Ka&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,$n.lanes|=d,qa|=d}u=u.next}while(u!==null&&u!==o);c===null?a=r:c.next=l,ni(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,$n.lanes|=o,qa|=o,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Ny(e){var t=Ts(),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);ni(o,t.memoizedState)||(Ur=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function bA(){}function kA(e,t){var n=$n,r=Ts(),s=t(),o=!ni(r.memoizedState,s);if(o&&(r.memoizedState=s,Ur=!0),r=r.queue,uk(jA.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||dr!==null&&dr.memoizedState.tag&1){if(n.flags|=2048,Rd(9,SA.bind(null,n,r,s,t),void 0,null),hr===null)throw Error(Ae(349));Ka&30||vA(n,t,s)}return s}function vA(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=$n.updateQueue,t===null?(t={lastEffect:null,stores:null},$n.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function SA(e,t,n,r){t.value=n,t.getSnapshot=r,NA(t)&&CA(e)}function jA(e,t,n){return n(function(){NA(t)&&CA(e)})}function NA(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!ni(e,n)}catch{return!0}}function CA(e){var t=io(e,1);t!==null&&ei(t,e,1,-1)}function Nj(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:Id,lastRenderedState:e},t.queue=e,e=e.dispatch=WO.bind(null,$n,e),[t.memoizedState,e]}function Rd(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=$n.updateQueue,t===null?(t={lastEffect:null,stores:null},$n.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 _A(){return Ts().memoizedState}function nh(e,t,n,r){var s=hi();$n.flags|=e,s.memoizedState=Rd(1|t,n,void 0,r===void 0?null:r)}function Lm(e,t,n,r){var s=Ts();r=r===void 0?null:r;var o=void 0;if(nr!==null){var a=nr.memoizedState;if(o=a.destroy,r!==null&&ak(r,a.deps)){s.memoizedState=Rd(t,n,o,r);return}}$n.flags|=e,s.memoizedState=Rd(1|t,n,o,r)}function Cj(e,t){return nh(8390656,8,e,t)}function uk(e,t){return Lm(2048,8,e,t)}function EA(e,t){return Lm(4,2,e,t)}function AA(e,t){return Lm(4,4,e,t)}function PA(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 IA(e,t,n){return n=n!=null?n.concat([e]):null,Lm(4,4,PA.bind(null,t,e),n)}function dk(){}function RA(e,t){var n=Ts();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&ak(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function TA(e,t){var n=Ts();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&ak(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function MA(e,t,n){return Ka&21?(ni(n,t)||(n=FE(),$n.lanes|=n,qa|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Ur=!0),e.memoizedState=n)}function BO(e,t){var n=an;an=n!==0&&4>n?n:4,e(!0);var r=Sy.transition;Sy.transition={};try{e(!1),t()}finally{an=n,Sy.transition=r}}function $A(){return Ts().memoizedState}function HO(e,t,n){var r=Uo(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},LA(e))OA(t,n);else if(n=yA(e,t,n,r),n!==null){var s=Or();ei(n,e,r,s),DA(n,t,r)}}function WO(e,t,n){var r=Uo(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(LA(e))OA(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,ni(l,a)){var c=t.interleaved;c===null?(s.next=s,nk(t)):(s.next=c.next,c.next=s),t.interleaved=s;return}}catch{}finally{}n=yA(e,t,s,r),n!==null&&(s=Or(),ei(n,e,r,s),DA(n,t,r))}}function LA(e){var t=e.alternate;return e===$n||t!==null&&t===$n}function OA(e,t){nd=Dh=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function DA(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,Hb(e,n)}}var Fh={readContext:Rs,useCallback:Sr,useContext:Sr,useEffect:Sr,useImperativeHandle:Sr,useInsertionEffect:Sr,useLayoutEffect:Sr,useMemo:Sr,useReducer:Sr,useRef:Sr,useState:Sr,useDebugValue:Sr,useDeferredValue:Sr,useTransition:Sr,useMutableSource:Sr,useSyncExternalStore:Sr,useId:Sr,unstable_isNewReconciler:!1},VO={readContext:Rs,useCallback:function(e,t){return hi().memoizedState=[e,t===void 0?null:t],e},useContext:Rs,useEffect:Cj,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,nh(4194308,4,PA.bind(null,t,e),n)},useLayoutEffect:function(e,t){return nh(4194308,4,e,t)},useInsertionEffect:function(e,t){return nh(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=HO.bind(null,$n,e),[r.memoizedState,e]},useRef:function(e){var t=hi();return e={current:e},t.memoizedState=e},useState:Nj,useDebugValue:dk,useDeferredValue:function(e){return hi().memoizedState=e},useTransition:function(){var e=Nj(!1),t=e[0];return e=BO.bind(null,e[1]),hi().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=$n,s=hi();if(_n){if(n===void 0)throw Error(Ae(407));n=n()}else{if(n=t(),hr===null)throw Error(Ae(349));Ka&30||vA(r,t,n)}s.memoizedState=n;var o={value:n,getSnapshot:t};return s.queue=o,Cj(jA.bind(null,r,o,e),[e]),r.flags|=2048,Rd(9,SA.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=hi(),t=hr.identifierPrefix;if(_n){var n=Gi,r=Yi;n=(r&~(1<<32-Zs(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Pd++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=zO++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},KO={readContext:Rs,useCallback:RA,useContext:Rs,useEffect:uk,useImperativeHandle:IA,useInsertionEffect:EA,useLayoutEffect:AA,useMemo:TA,useReducer:jy,useRef:_A,useState:function(){return jy(Id)},useDebugValue:dk,useDeferredValue:function(e){var t=Ts();return MA(t,nr.memoizedState,e)},useTransition:function(){var e=jy(Id)[0],t=Ts().memoizedState;return[e,t]},useMutableSource:bA,useSyncExternalStore:kA,useId:$A,unstable_isNewReconciler:!1},qO={readContext:Rs,useCallback:RA,useContext:Rs,useEffect:uk,useImperativeHandle:IA,useInsertionEffect:EA,useLayoutEffect:AA,useMemo:TA,useReducer:Ny,useRef:_A,useState:function(){return Ny(Id)},useDebugValue:dk,useDeferredValue:function(e){var t=Ts();return nr===null?t.memoizedState=e:MA(t,nr.memoizedState,e)},useTransition:function(){var e=Ny(Id)[0],t=Ts().memoizedState;return[e,t]},useMutableSource:bA,useSyncExternalStore:kA,useId:$A,unstable_isNewReconciler:!1};function Ks(e,t){if(e&&e.defaultProps){t=Ln({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function ix(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Ln({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Om={isMounted:function(e){return(e=e._reactInternals)?ol(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Or(),s=Uo(e),o=Zi(r,s);o.payload=t,n!=null&&(o.callback=n),t=Ko(e,o,s),t!==null&&(ei(t,e,s,r),eh(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Or(),s=Uo(e),o=Zi(r,s);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=Ko(e,o,s),t!==null&&(ei(t,e,s,r),eh(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Or(),r=Uo(e),s=Zi(n,r);s.tag=2,t!=null&&(s.callback=t),t=Ko(e,s,r),t!==null&&(ei(t,e,r,n),eh(t,e,r))}};function _j(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?!jd(n,r)||!jd(s,o):!0}function FA(e,t,n){var r=!1,s=Qo,o=t.contextType;return typeof o=="object"&&o!==null?o=Rs(o):(s=Xr(t)?Wa:Er.current,r=t.contextTypes,o=(r=r!=null)?bc(e,s):Qo),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Om,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=o),t}function Ej(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&&Om.enqueueReplaceState(t,t.state,null)}function ox(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},rk(e);var o=t.contextType;typeof o=="object"&&o!==null?s.context=Rs(o):(o=Xr(t)?Wa:Er.current,s.context=bc(e,o)),s.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(ix(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&&Om.enqueueReplaceState(s,s.state,null),Lh(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function jc(e,t){try{var n="",r=t;do n+=b2(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 Cy(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function ax(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var UO=typeof WeakMap=="function"?WeakMap:Map;function zA(e,t,n){n=Zi(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Bh||(Bh=!0,yx=r),ax(e,t)},n}function BA(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(){ax(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){ax(e,t),typeof r!="function"&&(qo===null?qo=new Set([this]):qo.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function Aj(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new UO;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=aD.bind(null,e,t,n),t.then(e,e))}function Pj(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 Ij(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,Ko(n,t,1))),n.lanes|=1),e)}var YO=fo.ReactCurrentOwner,Ur=!1;function Lr(e,t,n,r){t.child=e===null?gA(t,null,n,r):vc(t,e.child,n,r)}function Rj(e,t,n,r,s){n=n.render;var o=t.ref;return cc(t,s),r=lk(e,t,n,r,o,s),n=ck(),e!==null&&!Ur?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,oo(e,t,s)):(_n&&n&&Jb(t),t.flags|=1,Lr(e,t,r,s),t.child)}function Tj(e,t,n,r,s){if(e===null){var o=n.type;return typeof o=="function"&&!xk(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,HA(e,t,o,r,s)):(e=oh(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:jd,n(a,r)&&e.ref===t.ref)return oo(e,t,s)}return t.flags|=1,e=Yo(o,r),e.ref=t.ref,e.return=t,t.child=e}function HA(e,t,n,r,s){if(e!==null){var o=e.memoizedProps;if(jd(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 lx(e,t,n,r,s)}function WA(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},gn(Ql,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,gn(Ql,is),is|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,gn(Ql,is),is|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,gn(Ql,is),is|=r;return Lr(e,t,s,n),t.child}function VA(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function lx(e,t,n,r,s){var o=Xr(n)?Wa:Er.current;return o=bc(t,o),cc(t,s),n=lk(e,t,n,r,o,s),r=ck(),e!==null&&!Ur?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,oo(e,t,s)):(_n&&r&&Jb(t),t.flags|=1,Lr(e,t,n,s),t.child)}function Mj(e,t,n,r,s){if(Xr(n)){var o=!0;Ih(t)}else o=!1;if(cc(t,s),t.stateNode===null)rh(e,t),FA(t,n,r),ox(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=Rs(u):(u=Xr(n)?Wa:Er.current,u=bc(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)&&Ej(t,a,r,u),Io=!1;var p=t.memoizedState;a.state=p,Lh(t,r,a,s),c=t.memoizedState,l!==r||p!==c||Jr.current||Io?(typeof d=="function"&&(ix(t,n,d,r),c=t.memoizedState),(l=Io||_j(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,wA(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:Ks(t.type,l),a.props=u,f=t.pendingProps,p=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=Rs(c):(c=Xr(n)?Wa:Er.current,c=bc(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)&&Ej(t,a,r,c),Io=!1,p=t.memoizedState,a.state=p,Lh(t,r,a,s);var y=t.memoizedState;l!==f||p!==y||Jr.current||Io?(typeof h=="function"&&(ix(t,n,h,r),y=t.memoizedState),(u=Io||_j(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 cx(e,t,n,r,o,s)}function cx(e,t,n,r,s,o){VA(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&xj(t,n,!1),oo(e,t,o);r=t.stateNode,YO.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=vc(t,e.child,null,o),t.child=vc(t,null,l,o)):Lr(e,t,l,o),t.memoizedState=r.state,s&&xj(t,n,!0),t.child}function KA(e){var t=e.stateNode;t.pendingContext?wj(e,t.pendingContext,t.pendingContext!==t.context):t.context&&wj(e,t.context,!1),sk(e,t.containerInfo)}function $j(e,t,n,r,s){return kc(),Qb(s),t.flags|=256,Lr(e,t,n,r),t.child}var ux={dehydrated:null,treeContext:null,retryLane:0};function dx(e){return{baseLanes:e,cachePool:null,transitions:null}}function qA(e,t,n){var r=t.pendingProps,s=Tn.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),gn(Tn,s&1),e===null)return rx(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=zm(a,r,0,null),e=Oa(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=dx(n),t.memoizedState=ux,e):fk(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return GO(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=Yo(s,c),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?o=Yo(l,o):(o=Oa(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?dx(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},o.memoizedState=a,o.childLanes=e.childLanes&~n,t.memoizedState=ux,r}return o=e.child,e=o.sibling,r=Yo(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 fk(e,t){return t=zm({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function hp(e,t,n,r){return r!==null&&Qb(r),vc(t,e.child,null,n),e=fk(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function GO(e,t,n,r,s,o,a){if(n)return t.flags&256?(t.flags&=-257,r=Cy(Error(Ae(422))),hp(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,s=t.mode,r=zm({mode:"visible",children:r.children},s,0,null),o=Oa(o,s,a,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&vc(t,e.child,null,a),t.child.memoizedState=dx(a),t.memoizedState=ux,o);if(!(t.mode&1))return hp(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=Cy(o,r,void 0),hp(e,t,a,r)}if(l=(a&e.childLanes)!==0,Ur||l){if(r=hr,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),ei(r,e,s,-1))}return wk(),r=Cy(Error(Ae(421))),hp(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=lD.bind(null,e),s._reactRetry=t,null):(e=o.treeContext,ls=Vo(s.nextSibling),us=t,_n=!0,Ys=null,e!==null&&(Cs[_s++]=Yi,Cs[_s++]=Gi,Cs[_s++]=Va,Yi=e.id,Gi=e.overflow,Va=t),t=fk(t,r.children),t.flags|=4096,t)}function Lj(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),sx(e.return,t,n)}function _y(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 UA(e,t,n){var r=t.pendingProps,s=r.revealOrder,o=r.tail;if(Lr(e,t,r.children,n),r=Tn.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&&Lj(e,n,t);else if(e.tag===19)Lj(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(gn(Tn,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&&Oh(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),_y(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&&Oh(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}_y(t,!0,n,null,o);break;case"together":_y(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function rh(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),qa|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Ae(153));if(t.child!==null){for(e=t.child,n=Yo(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Yo(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function JO(e,t,n){switch(t.tag){case 3:KA(t),kc();break;case 5:xA(t);break;case 1:Xr(t.type)&&Ih(t);break;case 4:sk(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;gn(Mh,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(gn(Tn,Tn.current&1),t.flags|=128,null):n&t.child.childLanes?qA(e,t,n):(gn(Tn,Tn.current&1),e=oo(e,t,n),e!==null?e.sibling:null);gn(Tn,Tn.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return UA(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),gn(Tn,Tn.current),r)break;return null;case 22:case 23:return t.lanes=0,WA(e,t,n)}return oo(e,t,n)}var YA,fx,GA,JA;YA=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}};fx=function(){};GA=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Ra(Ni.current);var o=null;switch(n){case"input":s=Mw(e,s),r=Mw(e,r),o=[];break;case"select":s=Ln({},s,{value:void 0}),r=Ln({},r,{value:void 0}),o=[];break;case"textarea":s=Ow(e,s),r=Ow(e,r),o=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=Ah)}Fw(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"&&(yd.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"&&(yd.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&kn("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)}};JA=function(e,t,n,r){n!==r&&(t.flags|=4)};function Cu(e,t){if(!_n)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 jr(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 XO(e,t,n){var r=t.pendingProps;switch(Xb(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return jr(t),null;case 1:return Xr(t.type)&&Ph(),jr(t),null;case 3:return r=t.stateNode,Sc(),Sn(Jr),Sn(Er),ok(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(fp(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Ys!==null&&(bx(Ys),Ys=null))),fx(e,t),jr(t),null;case 5:ik(t);var s=Ra(Ad.current);if(n=t.type,e!==null&&t.stateNode!=null)GA(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 jr(t),null}if(e=Ra(Ni.current),fp(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[wi]=t,r[_d]=o,e=(t.mode&1)!==0,n){case"dialog":kn("cancel",r),kn("close",r);break;case"iframe":case"object":case"embed":kn("load",r);break;case"video":case"audio":for(s=0;s<Hu.length;s++)kn(Hu[s],r);break;case"source":kn("error",r);break;case"img":case"image":case"link":kn("error",r),kn("load",r);break;case"details":kn("toggle",r);break;case"input":K0(r,o),kn("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},kn("invalid",r);break;case"textarea":U0(r,o),kn("invalid",r)}Fw(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&&dp(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&dp(r.textContent,l,e),s=["children",""+l]):yd.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&kn("scroll",r)}switch(n){case"input":rp(r),q0(r,o,!0);break;case"textarea":rp(r),Y0(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=Ah)}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=jE(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[_d]=r,YA(e,t,!1,!1),t.stateNode=e;e:{switch(a=zw(n,r),n){case"dialog":kn("cancel",e),kn("close",e),s=r;break;case"iframe":case"object":case"embed":kn("load",e),s=r;break;case"video":case"audio":for(s=0;s<Hu.length;s++)kn(Hu[s],e);s=r;break;case"source":kn("error",e),s=r;break;case"img":case"image":case"link":kn("error",e),kn("load",e),s=r;break;case"details":kn("toggle",e),s=r;break;case"input":K0(e,r),s=Mw(e,r),kn("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=Ln({},r,{value:void 0}),kn("invalid",e);break;case"textarea":U0(e,r),s=Ow(e,r),kn("invalid",e);break;default:s=r}Fw(n,s),l=s;for(o in l)if(l.hasOwnProperty(o)){var c=l[o];o==="style"?_E(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&NE(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&wd(e,c):typeof c=="number"&&wd(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(yd.hasOwnProperty(o)?c!=null&&o==="onScroll"&&kn("scroll",e):c!=null&&Lb(e,o,c,a))}switch(n){case"input":rp(e),q0(e,r,!1);break;case"textarea":rp(e),Y0(e);break;case"option":r.value!=null&&e.setAttribute("value",""+Xo(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?ic(e,!!r.multiple,o,!1):r.defaultValue!=null&&ic(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=Ah)}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 jr(t),null;case 6:if(e&&t.stateNode!=null)JA(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Ae(166));if(n=Ra(Ad.current),Ra(Ni.current),fp(t)){if(r=t.stateNode,n=t.memoizedProps,r[wi]=t,(o=r.nodeValue!==n)&&(e=us,e!==null))switch(e.tag){case 3:dp(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&dp(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 jr(t),null;case 13:if(Sn(Tn),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(_n&&ls!==null&&t.mode&1&&!(t.flags&128))hA(),kc(),t.flags|=98560,o=!1;else if(o=fp(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 kc(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;jr(t),o=!1}else Ys!==null&&(bx(Ys),Ys=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||Tn.current&1?rr===0&&(rr=3):wk())),t.updateQueue!==null&&(t.flags|=4),jr(t),null);case 4:return Sc(),fx(e,t),e===null&&Nd(t.stateNode.containerInfo),jr(t),null;case 10:return tk(t.type._context),jr(t),null;case 17:return Xr(t.type)&&Ph(),jr(t),null;case 19:if(Sn(Tn),o=t.memoizedState,o===null)return jr(t),null;if(r=(t.flags&128)!==0,a=o.rendering,a===null)if(r)Cu(o,!1);else{if(rr!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Oh(e),a!==null){for(t.flags|=128,Cu(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 gn(Tn,Tn.current&1|2),t.child}e=e.sibling}o.tail!==null&&Vn()>Nc&&(t.flags|=128,r=!0,Cu(o,!1),t.lanes=4194304)}else{if(!r)if(e=Oh(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Cu(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!_n)return jr(t),null}else 2*Vn()-o.renderingStartTime>Nc&&n!==1073741824&&(t.flags|=128,r=!0,Cu(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=Vn(),t.sibling=null,n=Tn.current,gn(Tn,r?n&1|2:n&1),t):(jr(t),null);case 22:case 23:return yk(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?is&1073741824&&(jr(t),t.subtreeFlags&6&&(t.flags|=8192)):jr(t),null;case 24:return null;case 25:return null}throw Error(Ae(156,t.tag))}function QO(e,t){switch(Xb(t),t.tag){case 1:return Xr(t.type)&&Ph(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return Sc(),Sn(Jr),Sn(Er),ok(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return ik(t),null;case 13:if(Sn(Tn),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Ae(340));kc()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return Sn(Tn),null;case 4:return Sc(),null;case 10:return tk(t.type._context),null;case 22:case 23:return yk(),null;case 24:return null;default:return null}}var mp=!1,Nr=!1,ZO=typeof WeakSet=="function"?WeakSet:Set,Qe=null;function Xl(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){zn(e,t,r)}else n.current=null}function px(e,t,n){try{n()}catch(r){zn(e,t,r)}}var Oj=!1;function eD(e,t){if(Jw=Ch,e=tA(),Gb(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(Xw={focusedElem:e,selectionRange:n},Ch=!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,w=y.memoizedState,g=t.stateNode,k=g.getSnapshotBeforeUpdate(t.elementType===t.type?v:Ks(t.type,v),w);g.__reactInternalSnapshotBeforeUpdate=k}break;case 3:var b=t.stateNode.containerInfo;b.nodeType===1?b.textContent="":b.nodeType===9&&b.documentElement&&b.removeChild(b.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Ae(163))}}catch(j){zn(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,Qe=e;break}Qe=t.return}return y=Oj,Oj=!1,y}function rd(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&&px(t,n,o)}s=s.next}while(s!==r)}}function Dm(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 hx(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 XA(e){var t=e.alternate;t!==null&&(e.alternate=null,XA(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[wi],delete t[_d],delete t[ex],delete t[LO],delete t[OO])),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}function QA(e){return e.tag===5||e.tag===3||e.tag===4}function Dj(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||QA(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 mx(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=Ah));else if(r!==4&&(e=e.child,e!==null))for(mx(e,t,n),e=e.sibling;e!==null;)mx(e,t,n),e=e.sibling}function gx(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(gx(e,t,n),e=e.sibling;e!==null;)gx(e,t,n),e=e.sibling}var gr=null,qs=!1;function jo(e,t,n){for(n=n.child;n!==null;)ZA(e,t,n),n=n.sibling}function ZA(e,t,n){if(ji&&typeof ji.onCommitFiberUnmount=="function")try{ji.onCommitFiberUnmount(Pm,n)}catch{}switch(n.tag){case 5:Nr||Xl(n,t);case 6:var r=gr,s=qs;gr=null,jo(e,t,n),gr=r,qs=s,gr!==null&&(qs?(e=gr,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):gr.removeChild(n.stateNode));break;case 18:gr!==null&&(qs?(e=gr,n=n.stateNode,e.nodeType===8?by(e.parentNode,n):e.nodeType===1&&by(e,n),vd(e)):by(gr,n.stateNode));break;case 4:r=gr,s=qs,gr=n.stateNode.containerInfo,qs=!0,jo(e,t,n),gr=r,qs=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)&&px(n,t,a),s=s.next}while(s!==r)}jo(e,t,n);break;case 1:if(!Nr&&(Xl(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){zn(n,t,l)}jo(e,t,n);break;case 21:jo(e,t,n);break;case 22:n.mode&1?(Nr=(r=Nr)||n.memoizedState!==null,jo(e,t,n),Nr=r):jo(e,t,n);break;default:jo(e,t,n)}}function Fj(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new ZO),t.forEach(function(r){var s=cD.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Hs(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:gr=l.stateNode,qs=!1;break e;case 3:gr=l.stateNode.containerInfo,qs=!0;break e;case 4:gr=l.stateNode.containerInfo,qs=!0;break e}l=l.return}if(gr===null)throw Error(Ae(160));ZA(o,a,s),gr=null,qs=!1;var c=s.alternate;c!==null&&(c.return=null),s.return=null}catch(u){zn(s,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)eP(t,e),t=t.sibling}function eP(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Hs(t,e),di(e),r&4){try{rd(3,e,e.return),Dm(3,e)}catch(v){zn(e,e.return,v)}try{rd(5,e,e.return)}catch(v){zn(e,e.return,v)}}break;case 1:Hs(t,e),di(e),r&512&&n!==null&&Xl(n,n.return);break;case 5:if(Hs(t,e),di(e),r&512&&n!==null&&Xl(n,n.return),e.flags&32){var s=e.stateNode;try{wd(s,"")}catch(v){zn(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&&vE(s,o),zw(l,a);var u=zw(l,o);for(a=0;a<c.length;a+=2){var d=c[a],f=c[a+1];d==="style"?_E(s,f):d==="dangerouslySetInnerHTML"?NE(s,f):d==="children"?wd(s,f):Lb(s,d,f,u)}switch(l){case"input":$w(s,o);break;case"textarea":SE(s,o);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!o.multiple;var h=o.value;h!=null?ic(s,!!o.multiple,h,!1):p!==!!o.multiple&&(o.defaultValue!=null?ic(s,!!o.multiple,o.defaultValue,!0):ic(s,!!o.multiple,o.multiple?[]:"",!1))}s[_d]=o}catch(v){zn(e,e.return,v)}}break;case 6:if(Hs(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){zn(e,e.return,v)}}break;case 3:if(Hs(t,e),di(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{vd(t.containerInfo)}catch(v){zn(e,e.return,v)}break;case 4:Hs(t,e),di(e);break;case 13:Hs(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||(mk=Vn())),r&4&&Fj(e);break;case 22:if(d=n!==null&&n.memoizedState!==null,e.mode&1?(Nr=(u=Nr)||d,Hs(t,e),Nr=u):Hs(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:rd(4,p,p.return);break;case 1:Xl(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){zn(r,n,v)}}break;case 5:Xl(p,p.return);break;case 22:if(p.memoizedState!==null){Bj(f);continue}}h!==null?(h.return=p,Qe=h):Bj(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=CE("display",a))}catch(v){zn(e,e.return,v)}}}else if(f.tag===6){if(d===null)try{f.stateNode.nodeValue=u?"":f.memoizedProps}catch(v){zn(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:Hs(t,e),di(e),r&4&&Fj(e);break;case 21:break;default:Hs(t,e),di(e)}}function di(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(QA(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&&(wd(s,""),r.flags&=-33);var o=Dj(e);gx(e,o,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=Dj(e);mx(e,l,a);break;default:throw Error(Ae(161))}}catch(c){zn(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function tD(e,t,n){Qe=e,tP(e)}function tP(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||mp;if(!a){var l=s.alternate,c=l!==null&&l.memoizedState!==null||Nr;l=mp;var u=Nr;if(mp=a,(Nr=c)&&!u)for(Qe=s;Qe!==null;)a=Qe,c=a.child,a.tag===22&&a.memoizedState!==null?Hj(s):c!==null?(c.return=a,Qe=c):Hj(s);for(;o!==null;)Qe=o,tP(o),o=o.sibling;Qe=s,mp=l,Nr=u}zj(e)}else s.subtreeFlags&8772&&o!==null?(o.return=s,Qe=o):zj(e)}}function zj(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||Dm(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:Ks(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&jj(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}jj(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&&vd(f)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Ae(163))}Nr||t.flags&512&&hx(t)}catch(p){zn(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 Bj(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 Hj(e){for(;Qe!==null;){var t=Qe;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Dm(4,t)}catch(c){zn(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(c){zn(t,s,c)}}var o=t.return;try{hx(t)}catch(c){zn(t,o,c)}break;case 5:var a=t.return;try{hx(t)}catch(c){zn(t,a,c)}}}catch(c){zn(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 nD=Math.ceil,zh=fo.ReactCurrentDispatcher,pk=fo.ReactCurrentOwner,Is=fo.ReactCurrentBatchConfig,Ut=0,hr=null,Gn=null,yr=0,is=0,Ql=aa(0),rr=0,Td=null,qa=0,Fm=0,hk=0,sd=null,Kr=null,mk=0,Nc=1/0,Ki=null,Bh=!1,yx=null,qo=null,gp=!1,Do=null,Hh=0,id=0,wx=null,sh=-1,ih=0;function Or(){return Ut&6?Vn():sh!==-1?sh:sh=Vn()}function Uo(e){return e.mode&1?Ut&2&&yr!==0?yr&-yr:FO.transition!==null?(ih===0&&(ih=FE()),ih):(e=an,e!==0||(e=window.event,e=e===void 0?16:qE(e.type)),e):1}function ei(e,t,n,r){if(50<id)throw id=0,wx=null,Error(Ae(185));rf(e,n,r),(!(Ut&2)||e!==hr)&&(e===hr&&(!(Ut&2)&&(Fm|=n),rr===4&&Mo(e,yr)),Qr(e,r),n===1&&Ut===0&&!(t.mode&1)&&(Nc=Vn()+500,$m&&la()))}function Qr(e,t){var n=e.callbackNode;F2(e,t);var r=Nh(e,e===hr?yr:0);if(r===0)n!==null&&X0(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&X0(n),t===1)e.tag===0?DO(Wj.bind(null,e)):dA(Wj.bind(null,e)),MO(function(){!(Ut&6)&&la()}),n=null;else{switch(zE(r)){case 1:n=Bb;break;case 4:n=OE;break;case 16:n=jh;break;case 536870912:n=DE;break;default:n=jh}n=cP(n,nP.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function nP(e,t){if(sh=-1,ih=0,Ut&6)throw Error(Ae(327));var n=e.callbackNode;if(uc()&&e.callbackNode!==n)return null;var r=Nh(e,e===hr?yr:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Wh(e,r);else{t=r;var s=Ut;Ut|=2;var o=sP();(hr!==e||yr!==t)&&(Ki=null,Nc=Vn()+500,La(e,t));do try{iD();break}catch(l){rP(e,l)}while(!0);ek(),zh.current=o,Ut=s,Gn!==null?t=0:(hr=null,yr=0,t=rr)}if(t!==0){if(t===2&&(s=Kw(e),s!==0&&(r=s,t=xx(e,s))),t===1)throw n=Td,La(e,0),Mo(e,r),Qr(e,Vn()),n;if(t===6)Mo(e,r);else{if(s=e.current.alternate,!(r&30)&&!rD(s)&&(t=Wh(e,r),t===2&&(o=Kw(e),o!==0&&(r=o,t=xx(e,o))),t===1))throw n=Td,La(e,0),Mo(e,r),Qr(e,Vn()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(Ae(345));case 2:ja(e,Kr,Ki);break;case 3:if(Mo(e,r),(r&130023424)===r&&(t=mk+500-Vn(),10<t)){if(Nh(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){Or(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=Zw(ja.bind(null,e,Kr,Ki),t);break}ja(e,Kr,Ki);break;case 4:if(Mo(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-Zs(r);o=1<<a,a=t[a],a>s&&(s=a),r&=~o}if(r=s,r=Vn()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*nD(r/1960))-r,10<r){e.timeoutHandle=Zw(ja.bind(null,e,Kr,Ki),r);break}ja(e,Kr,Ki);break;case 5:ja(e,Kr,Ki);break;default:throw Error(Ae(329))}}}return Qr(e,Vn()),e.callbackNode===n?nP.bind(null,e):null}function xx(e,t){var n=sd;return e.current.memoizedState.isDehydrated&&(La(e,t).flags|=256),e=Wh(e,t),e!==2&&(t=Kr,Kr=n,t!==null&&bx(t)),e}function bx(e){Kr===null?Kr=e:Kr.push.apply(Kr,e)}function rD(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(!ni(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 Mo(e,t){for(t&=~hk,t&=~Fm,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Zs(t),r=1<<n;e[n]=-1,t&=~r}}function Wj(e){if(Ut&6)throw Error(Ae(327));uc();var t=Nh(e,0);if(!(t&1))return Qr(e,Vn()),null;var n=Wh(e,t);if(e.tag!==0&&n===2){var r=Kw(e);r!==0&&(t=r,n=xx(e,r))}if(n===1)throw n=Td,La(e,0),Mo(e,t),Qr(e,Vn()),n;if(n===6)throw Error(Ae(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,ja(e,Kr,Ki),Qr(e,Vn()),null}function gk(e,t){var n=Ut;Ut|=1;try{return e(t)}finally{Ut=n,Ut===0&&(Nc=Vn()+500,$m&&la())}}function Ua(e){Do!==null&&Do.tag===0&&!(Ut&6)&&uc();var t=Ut;Ut|=1;var n=Is.transition,r=an;try{if(Is.transition=null,an=1,e)return e()}finally{an=r,Is.transition=n,Ut=t,!(Ut&6)&&la()}}function yk(){is=Ql.current,Sn(Ql)}function La(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,TO(n)),Gn!==null)for(n=Gn.return;n!==null;){var r=n;switch(Xb(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Ph();break;case 3:Sc(),Sn(Jr),Sn(Er),ok();break;case 5:ik(r);break;case 4:Sc();break;case 13:Sn(Tn);break;case 19:Sn(Tn);break;case 10:tk(r.type._context);break;case 22:case 23:yk()}n=n.return}if(hr=e,Gn=e=Yo(e.current,null),yr=is=t,rr=0,Td=null,hk=Fm=qa=0,Kr=sd=null,Ia!==null){for(t=0;t<Ia.length;t++)if(n=Ia[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}Ia=null}return e}function rP(e,t){do{var n=Gn;try{if(ek(),th.current=Fh,Dh){for(var r=$n.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}Dh=!1}if(Ka=0,dr=nr=$n=null,nd=!1,Pd=0,pk.current=null,n===null||n.return===null){rr=1,Td=t,Gn=null;break}e:{var o=e,a=n.return,l=n,c=t;if(t=yr,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=Pj(a);if(h!==null){h.flags&=-257,Ij(h,a,l,o,t),h.mode&1&&Aj(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)){Aj(o,u,t),wk();break e}c=Error(Ae(426))}}else if(_n&&l.mode&1){var w=Pj(a);if(w!==null){!(w.flags&65536)&&(w.flags|=256),Ij(w,a,l,o,t),Qb(jc(c,l));break e}}o=c=jc(c,l),rr!==4&&(rr=2),sd===null?sd=[o]:sd.push(o),o=a;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var g=zA(o,c,t);Sj(o,g);break e;case 1:l=c;var k=o.type,b=o.stateNode;if(!(o.flags&128)&&(typeof k.getDerivedStateFromError=="function"||b!==null&&typeof b.componentDidCatch=="function"&&(qo===null||!qo.has(b)))){o.flags|=65536,t&=-t,o.lanes|=t;var j=BA(o,l,t);Sj(o,j);break e}}o=o.return}while(o!==null)}oP(n)}catch(N){t=N,Gn===n&&n!==null&&(Gn=n=n.return);continue}break}while(!0)}function sP(){var e=zh.current;return zh.current=Fh,e===null?Fh:e}function wk(){(rr===0||rr===3||rr===2)&&(rr=4),hr===null||!(qa&268435455)&&!(Fm&268435455)||Mo(hr,yr)}function Wh(e,t){var n=Ut;Ut|=2;var r=sP();(hr!==e||yr!==t)&&(Ki=null,La(e,t));do try{sD();break}catch(s){rP(e,s)}while(!0);if(ek(),Ut=n,zh.current=r,Gn!==null)throw Error(Ae(261));return hr=null,yr=0,rr}function sD(){for(;Gn!==null;)iP(Gn)}function iD(){for(;Gn!==null&&!P2();)iP(Gn)}function iP(e){var t=lP(e.alternate,e,is);e.memoizedProps=e.pendingProps,t===null?oP(e):Gn=t,pk.current=null}function oP(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=QO(n,t),n!==null){n.flags&=32767,Gn=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{rr=6,Gn=null;return}}else if(n=XO(n,t,is),n!==null){Gn=n;return}if(t=t.sibling,t!==null){Gn=t;return}Gn=t=e}while(t!==null);rr===0&&(rr=5)}function ja(e,t,n){var r=an,s=Is.transition;try{Is.transition=null,an=1,oD(e,t,n,r)}finally{Is.transition=s,an=r}return null}function oD(e,t,n,r){do uc();while(Do!==null);if(Ut&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(z2(e,o),e===hr&&(Gn=hr=null,yr=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||gp||(gp=!0,cP(jh,function(){return uc(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=Is.transition,Is.transition=null;var a=an;an=1;var l=Ut;Ut|=4,pk.current=null,eD(e,n),eP(n,e),CO(Xw),Ch=!!Jw,Xw=Jw=null,e.current=n,tD(n),I2(),Ut=l,an=a,Is.transition=o}else e.current=n;if(gp&&(gp=!1,Do=e,Hh=s),o=e.pendingLanes,o===0&&(qo=null),M2(n.stateNode),Qr(e,Vn()),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(Bh)throw Bh=!1,e=yx,yx=null,e;return Hh&1&&e.tag!==0&&uc(),o=e.pendingLanes,o&1?e===wx?id++:(id=0,wx=e):id=0,la(),null}function uc(){if(Do!==null){var e=zE(Hh),t=Is.transition,n=an;try{if(Is.transition=null,an=16>e?16:e,Do===null)var r=!1;else{if(e=Do,Do=null,Hh=0,Ut&6)throw Error(Ae(331));var s=Ut;for(Ut|=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:rd(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(XA(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 w=v.sibling;v.sibling=null,v=w}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:rd(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 b=a.child;if(a.subtreeFlags&2064&&b!==null)b.return=a,Qe=b;else e:for(a=k;Qe!==null;){if(l=Qe,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Dm(9,l)}}catch(N){zn(l,l.return,N)}if(l===a){Qe=null;break e}var j=l.sibling;if(j!==null){j.return=l.return,Qe=j;break e}Qe=l.return}}if(Ut=s,la(),ji&&typeof ji.onPostCommitFiberRoot=="function")try{ji.onPostCommitFiberRoot(Pm,e)}catch{}r=!0}return r}finally{an=n,Is.transition=t}}return!1}function Vj(e,t,n){t=jc(n,t),t=zA(e,t,1),e=Ko(e,t,1),t=Or(),e!==null&&(rf(e,1,t),Qr(e,t))}function zn(e,t,n){if(e.tag===3)Vj(e,e,n);else for(;t!==null;){if(t.tag===3){Vj(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(qo===null||!qo.has(r))){e=jc(n,e),e=BA(t,e,1),t=Ko(t,e,1),e=Or(),t!==null&&(rf(t,1,e),Qr(t,e));break}}t=t.return}}function aD(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Or(),e.pingedLanes|=e.suspendedLanes&n,hr===e&&(yr&n)===n&&(rr===4||rr===3&&(yr&130023424)===yr&&500>Vn()-mk?La(e,0):hk|=n),Qr(e,t)}function aP(e,t){t===0&&(e.mode&1?(t=op,op<<=1,!(op&130023424)&&(op=4194304)):t=1);var n=Or();e=io(e,t),e!==null&&(rf(e,t,n),Qr(e,n))}function lD(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),aP(e,n)}function cD(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,s=e.memoizedState;s!==null&&(n=s.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(Ae(314))}r!==null&&r.delete(t),aP(e,n)}var lP;lP=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,JO(e,t,n);Ur=!!(e.flags&131072)}else Ur=!1,_n&&t.flags&1048576&&fA(t,Th,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;rh(e,t),e=t.pendingProps;var s=bc(t,Er.current);cc(t,n),s=lk(null,t,r,e,s,n);var o=ck();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,Ih(t)):o=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,rk(t),s.updater=Om,t.stateNode=s,s._reactInternals=t,ox(t,r,e,n),t=cx(null,t,r,!0,o,n)):(t.tag=0,_n&&o&&Jb(t),Lr(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(rh(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=dD(r),e=Ks(r,e),s){case 0:t=lx(null,t,r,e,n);break e;case 1:t=Mj(null,t,r,e,n);break e;case 11:t=Rj(null,t,r,e,n);break e;case 14:t=Tj(null,t,r,Ks(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:Ks(r,s),lx(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ks(r,s),Mj(e,t,r,s,n);case 3:e:{if(KA(t),e===null)throw Error(Ae(387));r=t.pendingProps,o=t.memoizedState,s=o.element,wA(e,t),Lh(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=jc(Error(Ae(423)),t),t=$j(e,t,r,n,s);break e}else if(r!==s){s=jc(Error(Ae(424)),t),t=$j(e,t,r,n,s);break e}else for(ls=Vo(t.stateNode.containerInfo.firstChild),us=t,_n=!0,Ys=null,n=gA(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(kc(),r===s){t=oo(e,t,n);break e}Lr(e,t,r,n)}t=t.child}return t;case 5:return xA(t),e===null&&rx(t),r=t.type,s=t.pendingProps,o=e!==null?e.memoizedProps:null,a=s.children,Qw(r,s)?a=null:o!==null&&Qw(r,o)&&(t.flags|=32),VA(e,t),Lr(e,t,a,n),t.child;case 6:return e===null&&rx(t),null;case 13:return qA(e,t,n);case 4:return sk(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=vc(t,null,r,n):Lr(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ks(r,s),Rj(e,t,r,s,n);case 7:return Lr(e,t,t.pendingProps,n),t.child;case 8:return Lr(e,t,t.pendingProps.children,n),t.child;case 12:return Lr(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,gn(Mh,r._currentValue),r._currentValue=a,o!==null)if(ni(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),sx(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),sx(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}Lr(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,cc(t,n),s=Rs(s),r=r(s),t.flags|=1,Lr(e,t,r,n),t.child;case 14:return r=t.type,s=Ks(r,t.pendingProps),s=Ks(r.type,s),Tj(e,t,r,s,n);case 15:return HA(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Ks(r,s),rh(e,t),t.tag=1,Xr(r)?(e=!0,Ih(t)):e=!1,cc(t,n),FA(t,r,s),ox(t,r,s,n),cx(null,t,r,!0,e,n);case 19:return UA(e,t,n);case 22:return WA(e,t,n)}throw Error(Ae(156,t.tag))};function cP(e,t){return LE(e,t)}function uD(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 Ps(e,t,n,r){return new uD(e,t,n,r)}function xk(e){return e=e.prototype,!(!e||!e.isReactComponent)}function dD(e){if(typeof e=="function")return xk(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Db)return 11;if(e===Fb)return 14}return 2}function Yo(e,t){var n=e.alternate;return n===null?(n=Ps(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 oh(e,t,n,r,s,o){var a=2;if(r=e,typeof e=="function")xk(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Hl:return Oa(n.children,s,o,t);case Ob:a=8,s|=8;break;case Pw:return e=Ps(12,n,t,s|2),e.elementType=Pw,e.lanes=o,e;case Iw:return e=Ps(13,n,t,s),e.elementType=Iw,e.lanes=o,e;case Rw:return e=Ps(19,n,t,s),e.elementType=Rw,e.lanes=o,e;case xE:return zm(n,s,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case yE:a=10;break e;case wE:a=9;break e;case Db:a=11;break e;case Fb:a=14;break e;case Po:a=16,r=null;break e}throw Error(Ae(130,e==null?e:typeof e,""))}return t=Ps(a,n,t,s),t.elementType=e,t.type=r,t.lanes=o,t}function Oa(e,t,n,r){return e=Ps(7,e,r,t),e.lanes=n,e}function zm(e,t,n,r){return e=Ps(22,e,r,t),e.elementType=xE,e.lanes=n,e.stateNode={isHidden:!1},e}function Ey(e,t,n){return e=Ps(6,e,null,t),e.lanes=n,e}function Ay(e,t,n){return t=Ps(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function fD(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=cy(0),this.expirationTimes=cy(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=cy(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function bk(e,t,n,r,s,o,a,l,c){return e=new fD(e,t,n,l,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=Ps(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},rk(o),e}function pD(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Bl,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function uP(e){if(!e)return Qo;e=e._reactInternals;e:{if(ol(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 uA(e,n,t)}return t}function dP(e,t,n,r,s,o,a,l,c){return e=bk(n,r,!0,e,s,o,a,l,c),e.context=uP(null),n=e.current,r=Or(),s=Uo(n),o=Zi(r,s),o.callback=t??null,Ko(n,o,s),e.current.lanes=s,rf(e,s,r),Qr(e,r),e}function Bm(e,t,n,r){var s=t.current,o=Or(),a=Uo(s);return n=uP(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=Ko(s,t,a),e!==null&&(ei(e,s,a,o),eh(e,s,a)),a}function Vh(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 Kj(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function kk(e,t){Kj(e,t),(e=e.alternate)&&Kj(e,t)}function hD(){return null}var fP=typeof reportError=="function"?reportError:function(e){console.error(e)};function vk(e){this._internalRoot=e}Hm.prototype.render=vk.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Ae(409));Bm(e,t,null,null)};Hm.prototype.unmount=vk.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;Ua(function(){Bm(null,e,null,null)}),t[so]=null}};function Hm(e){this._internalRoot=e}Hm.prototype.unstable_scheduleHydration=function(e){if(e){var t=WE();e={blockedOn:null,target:e,priority:t};for(var n=0;n<To.length&&t!==0&&t<To[n].priority;n++);To.splice(n,0,e),n===0&&KE(e)}};function Sk(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function Wm(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function qj(){}function mD(e,t,n,r,s){if(s){if(typeof r=="function"){var o=r;r=function(){var u=Vh(a);o.call(u)}}var a=dP(t,r,e,0,null,!1,!1,"",qj);return e._reactRootContainer=a,e[so]=a.current,Nd(e.nodeType===8?e.parentNode:e),Ua(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var u=Vh(c);l.call(u)}}var c=bk(e,0,!1,null,null,!1,!1,"",qj);return e._reactRootContainer=c,e[so]=c.current,Nd(e.nodeType===8?e.parentNode:e),Ua(function(){Bm(t,c,n,r)}),c}function Vm(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=Vh(a);l.call(c)}}Bm(t,a,e,s)}else a=mD(n,t,e,s,r);return Vh(a)}BE=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Bu(t.pendingLanes);n!==0&&(Hb(t,n|1),Qr(t,Vn()),!(Ut&6)&&(Nc=Vn()+500,la()))}break;case 13:Ua(function(){var r=io(e,1);if(r!==null){var s=Or();ei(r,e,1,s)}}),kk(e,1)}};Wb=function(e){if(e.tag===13){var t=io(e,134217728);if(t!==null){var n=Or();ei(t,e,134217728,n)}kk(e,134217728)}};HE=function(e){if(e.tag===13){var t=Uo(e),n=io(e,t);if(n!==null){var r=Or();ei(n,e,t,r)}kk(e,t)}};WE=function(){return an};VE=function(e,t){var n=an;try{return an=e,t()}finally{an=n}};Hw=function(e,t,n){switch(t){case"input":if($w(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=Mm(r);if(!s)throw Error(Ae(90));kE(r),$w(r,s)}}}break;case"textarea":SE(e,n);break;case"select":t=n.value,t!=null&&ic(e,!!n.multiple,t,!1)}};PE=gk;IE=Ua;var gD={usingClientEntryPoint:!1,Events:[of,ql,Mm,EE,AE,gk]},_u={findFiberByHostInstance:Pa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},yD={bundleType:_u.bundleType,version:_u.version,rendererPackageName:_u.rendererPackageName,rendererConfig:_u.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:fo.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=ME(e),e===null?null:e.stateNode},findFiberByHostInstance:_u.findFiberByHostInstance||hD,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 yp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!yp.isDisabled&&yp.supportsFiber)try{Pm=yp.inject(yD),ji=yp}catch{}}hs.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=gD;hs.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Sk(t))throw Error(Ae(200));return pD(e,t,null,n)};hs.createRoot=function(e,t){if(!Sk(e))throw Error(Ae(299));var n=!1,r="",s=fP;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=bk(e,1,!1,null,null,n,!1,r,s),e[so]=t.current,Nd(e.nodeType===8?e.parentNode:e),new vk(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=ME(t),e=e===null?null:e.stateNode,e};hs.flushSync=function(e){return Ua(e)};hs.hydrate=function(e,t,n){if(!Wm(t))throw Error(Ae(200));return Vm(null,e,t,!0,n)};hs.hydrateRoot=function(e,t,n){if(!Sk(e))throw Error(Ae(405));var r=n!=null&&n.hydratedSources||null,s=!1,o="",a=fP;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=dP(t,null,e,1,n??null,s,!1,o,a),e[so]=t.current,Nd(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 Hm(t)};hs.render=function(e,t,n){if(!Wm(t))throw Error(Ae(200));return Vm(null,e,t,!1,n)};hs.unmountComponentAtNode=function(e){if(!Wm(e))throw Error(Ae(40));return e._reactRootContainer?(Ua(function(){Vm(null,null,e,!1,function(){e._reactRootContainer=null,e[so]=null})}),!0):!1};hs.unstable_batchedUpdates=gk;hs.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!Wm(n))throw Error(Ae(200));if(e==null||e._reactInternals===void 0)throw Error(Ae(38));return Vm(e,t,n,!1,r)};hs.version="18.3.1-next-f1338f8080-20240426";function pP(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(pP)}catch(e){console.error(e)}}pP(),pE.exports=hs;var ur=pE.exports,Uj=ur;Ew.createRoot=Uj.createRoot,Ew.hydrateRoot=Uj.hydrateRoot;const hP=m.createContext(null);function kx(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function wD(){const e=kx(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function xD({children:e}){const[t,n]=m.useState(wD);m.useEffect(()=>{const o=()=>n(kx(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=kx(l.pathname),u=l.search||"";window.history.pushState({},"",c+u),n(c)},[]),s=m.useMemo(()=>({path:t,navigate:r}),[t,r]);return i.jsx(hP.Provider,{value:s,children:e})}function gs(){const e=m.useContext(hP);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function bD(){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 Yj={};function vx(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&Yj[t[0]]||(typeof t[0]=="string"&&(Yj[t[0]]=new Date),bD(...t))}const mP=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function Gj(e,t,n){e.loadNamespaces(t,mP(e,n))}function Jj(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,mP(e,r))}function kD(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 vD(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(vx("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}}):kD(e,t,n)}const SD=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,jD={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},ND=e=>jD[e],CD=e=>e.replace(SD,ND);let Sx={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:CD};function _D(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Sx={...Sx,...e}}function ED(){return Sx}let gP;function AD(e){gP=e}function PD(){return gP}const ID={type:"3rdParty",init(e){_D(e.options.react),AD(e)}},RD=m.createContext();class TD{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const MD=(e,t)=>{const n=m.useRef();return m.useEffect(()=>{n.current=e},[e,t]),n.current};function zr(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=m.useContext(RD)||{},o=n||r||PD();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new TD),!o){vx("You will need to pass in an i18next instance by using initReactI18next");const b=(N,C)=>typeof C=="string"?C:C&&typeof C=="object"&&typeof C.defaultValue=="string"?C.defaultValue:Array.isArray(N)?N[N.length-1]:N,j=[b,{},!1];return j.t=b,j.i18n={},j.ready=!1,j}o.options.react&&o.options.react.wait!==void 0&&vx("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...ED(),...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(b=>vD(b,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=MD(y),w=m.useRef(!0);m.useEffect(()=>{const{bindI18n:b,bindI18nStore:j}=a;w.current=!0,!d&&!l&&(t.lng?Jj(o,t.lng,u,()=>{w.current&&h(f)}):Gj(o,u,()=>{w.current&&h(f)})),d&&v&&v!==y&&w.current&&h(f);function N(){w.current&&h(f)}return b&&o&&o.on(b,N),j&&o&&o.store.on(j,N),()=>{w.current=!1,b&&o&&b.split(" ").forEach(C=>o.off(C,N)),j&&o&&j.split(" ").forEach(C=>o.store.off(C,N))}},[o,y]);const g=m.useRef(!0);m.useEffect(()=>{w.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(b=>{t.lng?Jj(o,t.lng,u,()=>b()):Gj(o,u,()=>b())})}const yP="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:"/workflows",label:"迭代",icon:"timeline"},{to:"/workspaces",label:"知识库",icon:"folder_managed"},{to:"/nodes",labelKey:"common:nav.nodes",icon:"account_tree"},{to:"/my-flows",labelKey:"common:nav.myFlows",icon:"schema"},{to:"/skills",labelKey:"common:nav.skills",icon:"extension"},{to:"/mcps",labelKey:"common:nav.mcps",icon:"hub"},{to:"/node-studio",label:"节点编辑器",icon:"draw"},{to:"/schedules",label:"定时任务",icon:"event_busy"},{to:"/admin/usage",label:"管理看板",icon:"query_stats",adminOnly:!0},{to:"/feedback",labelKey:"common:nav.feedback",icon:"rate_review"},{to:"/settings",labelKey:"common:nav.settings",icon:"settings"}],LD=[{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 OD(e,t){return t==="/projects"?e==="/projects"||e==="/":t==="/nodes"?e==="/nodes"||e==="/my-nodes":e===t||e.startsWith(t+"/")}function DD({authUser:e,onLogout:t}){const{path:n,navigate:r}=gs(),{t:s}=zr(),[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:yP,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"+(OD(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&&LD.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 FD="agentflow.pipelineRecent",zD=15;function BD(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function HD(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(FD);return e?BD(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 WD(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 Xj(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 VD(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:WD(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,zD)}var os=Uint8Array,Zl=Uint16Array,KD=Int32Array,wP=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]),xP=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]),qD=new os([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),bP=function(e,t){for(var n=new Zl(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new KD(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}},kP=bP(wP,2),vP=kP.b,UD=kP.r;vP[28]=258,UD[258]=28;var YD=bP(xP,0),GD=YD.b,jx=new Zl(32768);for(var vn=0;vn<32768;++vn){var No=(vn&43690)>>1|(vn&21845)<<1;No=(No&52428)>>2|(No&13107)<<2,No=(No&61680)>>4|(No&3855)<<4,jx[vn]=((No&65280)>>8|(No&255)<<8)>>1}var od=function(e,t,n){for(var r=e.length,s=0,o=new Zl(t);s<r;++s)e[s]&&++o[e[s]-1];var a=new Zl(t);for(s=1;s<t;++s)a[s]=a[s-1]+o[s-1]<<1;var l;if(n){l=new Zl(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[jx[f]>>c]=u}else for(l=new Zl(r),s=0;s<r;++s)e[s]&&(l[s]=jx[a[e[s]-1]++]>>15-e[s]);return l},lf=new os(288);for(var vn=0;vn<144;++vn)lf[vn]=8;for(var vn=144;vn<256;++vn)lf[vn]=9;for(var vn=256;vn<280;++vn)lf[vn]=7;for(var vn=280;vn<288;++vn)lf[vn]=8;var SP=new os(32);for(var vn=0;vn<32;++vn)SP[vn]=5;var JD=od(lf,9,1),XD=od(SP,5,1),Py=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Ws=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Iy=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},QD=function(e){return(e+7)/8|0},jk=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))},ZD=["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||ZD[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,Ns),!n)throw r;return r},eF=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,w=t.n,g=s*8;do{if(!h){d=Ws(e,f,1);var k=Ws(e,f+1,3);if(f+=3,k)if(k==1)h=JD,y=XD,v=9,w=5;else if(k==2){var C=Ws(e,f,31)+257,I=Ws(e,f+10,15)+4,R=C+Ws(e,f+5,31)+1;f+=14;for(var H=new os(R),A=new os(19),L=0;L<I;++L)A[qD[L]]=Ws(e,f+L*3,7);f+=I*3;for(var D=Py(A),O=(1<<D)-1,M=od(A,D,1),L=0;L<R;){var K=M[Ws(e,f,O)];f+=K&15;var b=K>>4;if(b<16)H[L++]=b;else{var z=0,F=0;for(b==16?(F=3+Ws(e,f,3),f+=2,z=H[L-1]):b==17?(F=3+Ws(e,f,7),f+=3):b==18&&(F=11+Ws(e,f,127),f+=7);F--;)H[L++]=z}}var $=H.subarray(0,C),W=H.subarray(C);v=Py($),w=Py(W),h=od($,v,1),y=od(W,w,1)}else Ns(1);else{var b=QD(f)+4,j=e[b-4]|e[b-3]<<8,N=b+j;if(N>s){c&&Ns(0);break}l&&u(p+j),n.set(e.subarray(b,N),p),t.b=p+=j,t.p=f=N*8,t.f=d;continue}if(f>g){c&&Ns(0);break}}l&&u(p+131072);for(var E=(1<<v)-1,Q=(1<<w)-1,V=f;;V=f){var z=h[Iy(e,f)&E],B=z>>4;if(f+=z&15,f>g){c&&Ns(0);break}if(z||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 L=B-257,ue=wP[L];se=Ws(e,f,(1<<ue)-1)+vP[L],f+=ue}var G=y[Iy(e,f)&Q],ee=G>>4;G||Ns(3),f+=G&15;var W=GD[ee];if(ee>3){var ue=xP[ee];W+=Iy(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=w)}while(!d);return p!=n.length&&a?jk(n,0,p):n.subarray(0,p)},tF=new os(0),xi=function(e,t){return e[t]|e[t+1]<<8},Gs=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Ry=function(e,t){return Gs(e,t)+Gs(e,t+4)*4294967296};function nF(e,t){return eF(e,{i:2},t&&t.out,t&&t.dictionary)}var Nx=typeof TextDecoder<"u"&&new TextDecoder,rF=0;try{Nx.decode(tF,{stream:!0}),rF=1}catch{}var sF=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:jk(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 iF(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(Nx)return Nx.decode(e);var s=sF(e),o=s.s,n=s.r;return n.length&&Ns(8),o}}var oF=function(e,t){return t+30+xi(e,t+26)+xi(e,t+28)},aF=function(e,t,n){var r=xi(e,t+28),s=iF(e.subarray(t+46,t+46+r),!(xi(e,t+8)&2048)),o=t+46+r,a=Gs(e,t+20),l=n&&a==4294967295?lF(e,o):[a,Gs(e,t+24),Gs(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]},lF=function(e,t){for(;xi(e,t)!=1;t+=4+xi(e,t+2));return[Ry(e,t+12),Ry(e,t+4),Ry(e,t+20)]};function cF(e,t){for(var n={},r=e.length-22;Gs(e,r)!=101010256;--r)(!r||e.length-r>65558)&&Ns(13);var s=xi(e,r+8);if(!s)return{};var o=Gs(e,r+16),a=o==4294967295||s==65535;if(a){var l=Gs(e,r-12);a=Gs(e,l)==101075792,a&&(s=Gs(e,l+32),o=Gs(e,l+48))}for(var c=0;c<s;++c){var u=aF(e,o,a),d=u[0],f=u[1],p=u[2],h=u[3],y=u[4],v=u[5],w=oF(e,v);o=y,d?d==8?n[h]=nF(e.subarray(w,w+f),{out:new os(p)}):Ns(14,"unknown compression type "+d):n[h]=jk(e,w,w+f)}return n}const uF=8*1024*1024,dF=500;function fF(e){if(e==null||typeof e!="string")return null;let t=e.replace(/\\/g,"/").replace(/^\uFEFF/,"");for(;t.startsWith("/");)t=t.slice(1);if(!t||t.includes("\0")||/^[a-zA-Z]:/.test(t))return null;const n=t.split("/").filter(r=>r.length>0);for(const r of n)if(r==="."||r==="..")return null;return n.join("/")}function pF(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function hF(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 mF=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function gF(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=cF(t),r=new Map;let s=0,o=0;for(const[c,u]of Object.entries(n)){if(c.endsWith("/"))continue;const d=fF(c);if(!d||pF(d))continue;const f=(u==null?void 0:u.length)??0;if(s+=f,s>uF||(o+=1,o>dF))return null;r.set(d,f)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const u=hF(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 mF.test(l)?l:null}catch{return null}}const Ty=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function yF({file:e,onClose:t,onImported:n}){const{t:r}=zr(),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,w]=m.useState(null),g=v??e;m.useEffect(()=>{const N=requestAnimationFrame(()=>{var C;return(C=o.current)==null?void 0:C.focus()});return()=>cancelAnimationFrame(N)},[]),m.useEffect(()=>{let N=!1;return(async()=>{const C=g.name||"",I=C.toLowerCase();let R="";if(I.endsWith(".zip")){if(R=await gF(g)||"",!R){const H=C.replace(/\.zip$/i,"");Ty.test(H)&&(R=H)}}else if(I.endsWith(".yaml")||I.endsWith(".yml")){const H=C.replace(/\.ya?ml$/i,"");Ty.test(H)&&(R=H)}N||c(R)})(),()=>{N=!0}},[g]);const k=l.trim(),b=k.length>0&&Ty.test(k);async function j(N){if(N.preventDefault(),!(!b||f)){p(!0),y("");try{const C=new FormData;C.set("flowId",k),C.set("targetSpace",u),C.set("file",g,g.name);const I=await fetch("/api/flows/import",{method:"POST",body:C}),R=await I.json().catch(()=>({}));if(!I.ok){y(typeof R.error=="string"?R.error:r("project:importModal.importFailed"));return}n({id:R.flowId,source:R.flowSource??"user"})}catch(C){y(String((C==null?void 0:C.message)||C))}finally{p(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:N=>{N.target===N.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:N=>N.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:importModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":r("project:importModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:j,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:r("project:importModal.lead",{filename:g.name})}),i.jsx("input",{ref:a,type:"file",className:"af-import-file-input",accept:".yaml,.yml,.zip,application/zip","aria-hidden":!0,tabIndex:-1,onChange:N=>{var I;const C=(I=N.target.files)==null?void 0:I[0];C&&w(C),N.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:N=>c(N.target.value),"aria-invalid":k.length>0&&!b}),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 N;return(N=a.current)==null?void 0:N.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:!b||f,children:r(f?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const wF=/^[a-zA-Z][a-zA-Z0-9_-]*$/,Qj="af:newPipelineGuide";function xF({open:e,onClose:t,onCreated:n}){const{t:r}=zr(),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(""),[w,g]=m.useState(!1);m.useEffect(()=>{if(!e)return;l(""),u(""),f("user"),v(""),h(!1),localStorage.getItem(Qj)==="true"&&g(!0);const I=requestAnimationFrame(()=>{var R;return(R=o.current)==null?void 0:R.focus()});return()=>cancelAnimationFrame(I)},[e]);const k=()=>{localStorage.removeItem(Qj),g(!1)};if(!e)return null;const b=a.trim(),j=b.length>0&&wF.test(b);async function N(C){if(C.preventDefault(),!(!j||p)){h(!0),v(""),k();try{const I=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:b,description:c.trim(),targetSpace:d})}),R=await I.json().catch(()=>({}));if(!I.ok){v(typeof R.error=="string"?R.error:r("project:newPipelineModal.createFailed"));return}n({id:R.flowId,source:R.flowSource??"user"})}catch(I){v(String((I==null?void 0:I.message)||I))}finally{h(!1)}}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown: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"})})]}),w?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:N,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":b.length>0&&!j}),i.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r(w?"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(w?"onboarding:newPipeline.descPlaceholderGuide":"project:newPipelineModal.descPlaceholder"),value:c,onChange:C=>u(C.target.value)}),w?i.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-guide-hint",children:r("onboarding:newPipeline.descHintGuide")}):null]}),y?i.jsx("p",{className:"af-err af-new-pipeline-err",children:y}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:()=>{k(),t()},disabled:p,children:r("project:newPipelineModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!j||p,children:r(p?"project:newPipelineModal.creating":w?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const jP="agentflow.pipelineViewPreference";function NP(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function CP(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(jP)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function bF(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(jP,JSON.stringify(e))}catch{}}function Nk(e){return e==="display"?"display":"workspace"}function kF(e){const t=String(e||"").toLowerCase();return t==="builtin"||t==="admin"}function _P(e,t){const n=Nk(t);return n==="pipeline"&&kF(e==null?void 0:e.source)?"workspace":n}function vF(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function SF(e,t,n,r=!1){if(!e)return;const s=CP();s[NP(e,t,r)]={view:Nk(n),at:Date.now()},bF(s)}function jF(e,t="workspace"){if(!(e!=null&&e.id))return Nk(t);const r=CP()[NP(e.id,e.source??"user",!!e.archived)],s=_P(e,(r==null?void 0:r.view)||t);return s==="pipeline"&&!vF(e)?"workspace":s}function NF(e,t="workspace"){var s;const n=_P(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 wp(e,t="workspace"){return NF(e,jF(e,t))}function CF(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 Cx(e){return String((e==null?void 0:e.version)||"").trim()}function _F(e){const t=Cx(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 EF({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({}),[w,g]=m.useState(""),[k,b]=m.useState(""),[j,N]=m.useState(""),C=m.useCallback(async()=>{b("");try{const[D,O]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=agentflow&agent=codex")]),M=await D.json().catch(()=>({}));D.ok&&r({available:!!M.available,version:typeof M.version=="string"?M.version:"",loggedIn:!!M.loggedIn,user:typeof M.user=="string"?M.user:"",error:typeof M.error=="string"?M.error:""});const 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(D){b(String(D.message||D))}},[]);m.useEffect(()=>{C()},[C]);const I=m.useCallback(async()=>{const D=c.trim();if(D){g("search"),b(""),N("");try{const O=await fetch(`/api/skillhub/search?q=${encodeURIComponent(D)}&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){b(String(O.message||O))}finally{g("")}}},[c,d]),R=m.useCallback(async(D,O=!1)=>{if(!t)return;const M=D&&typeof D=="object"?D:null,K=String(M?M.slug||M.name||M.collection||M.skillId||M.id:D||"").trim();if(K){g(`install:${K}`),b(""),N("");try{const z=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},F=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z)}),$=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+F.status);N(O?`已更新 ${K}`:`已安装 ${K}`),await C(),typeof e=="function"&&await e()}catch(z){b(String(z.message||z))}finally{g("")}}},[t,C,e]),H=m.useCallback(async()=>{if(t&&s.length!==0){g("check-updates"),b(""),N("");try{const D=await Promise.all(s.map(async K=>{const z=String(K.name||"").trim();if(!z)return null;try{const F=await fetch(`/api/skillhub/search?q=${encodeURIComponent(z)}&mode=keyword`),$=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+F.status);const W=Array.isArray($.items)?$.items:[],E=W.find(se=>se.slug===z||se.name===z||se.id===z)||W[0],Q=Cx(K),V=String((E==null?void 0:E.version)||"").trim();let B="unknown";return E?Q&&V?B=CF(Q,V)<0?"update":"current":V&&(B="remote-only"):B="missing",[z,{state:B,latestVersion:V,installedVersion:Q,summary:(E==null?void 0:E.summary)||""}]}catch(F){return[z,{state:"error",error:String(F.message||F),installedVersion:Cx(K)}]}})),O={};for(const K of D)K&&(O[K[0]]=K[1]);v(O);const M=Object.values(O).filter(K=>K.state==="update").length;N(M>0?`发现 ${M} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{g("")}}},[t,s]),A=m.useCallback(async D=>{if(!t)return;const O=String(D||"").trim();if(O){g(`uninstall:${O}`),b(""),N("");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);N(`已卸载 ${O}`),await C(),typeof e=="function"&&await e()}catch(M){b(String(M.message||M))}finally{g("")}}},[t,C,e]),L=m.useCallback(async()=>{if(t){g("update-cli"),b(""),N("");try{const D=await fetch("/api/skillhub/update",{method:"POST"}),O=await D.json().catch(()=>({}));if(!D.ok)throw new Error(typeof O.error=="string"?O.error:"HTTP "+D.status);N("SkillHub CLI 已更新"),await C()}catch(D){b(String(D.message||D))}finally{g("")}}},[t,C]);return i.jsxs("section",{className:"af-set-card af-set-card--span-all af-set-skillhub",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"SkillHub"}),i.jsx("p",{className:"af-set-p af-set-p--tight",children:t?"搜索、安装、更新和卸载 AgentFlow 共享 skills。":"查看 AgentFlow 共享 skills;使用时在 Workspace 中通过 Load Skills 加载。"}),a?i.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:["Skills Root:",i.jsx("code",{children:a})]}):null]}),i.jsxs("div",{className:"af-set-skillhub-head-actions",children:[i.jsxs("div",{className:"af-set-skillhub-status",children:[i.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:"extension"}),i.jsx("span",{children:n.loggedIn?`已登录 ${n.user}`:"未登录 SkillHub"}),i.jsx("span",{className:"af-set-badge"+(n.available?" af-set-badge--ok":" af-set-badge--err"),children:n.available?`v${n.version}`:"not found"})]}),i.jsxs("div",{className:"af-set-skillhub-toolbar",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:C,disabled:!!w,children:"刷新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:H,disabled:!t||!!w||s.length===0,children:w==="check-updates"?"检查中…":"检查更新"}),i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:L,disabled:!t||!!w,children:w==="update-cli"?"更新中…":"更新 CLI"})]})]})]}),i.jsxs("div",{className:"af-set-skillhub-search",children:[i.jsxs("select",{className:"af-set-input af-set-input--sm af-set-skillhub-search-mode",value:d,onChange:D=>{f(D.target.value),h([])},children:[i.jsx("option",{value:"keyword",children:"关键词"}),i.jsx("option",{value:"skillId",children:"Skill ID"}),i.jsx("option",{value:"collectionId",children:"Collection ID"})]}),i.jsx("input",{className:"af-set-input af-set-input--sm",value:c,onChange:D=>u(D.target.value),onKeyDown:D=>{D.key==="Enter"&&I()},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:()=>I(),disabled:!c.trim()||w==="search",children:[i.jsx("span",{className:"material-symbols-outlined",children:"search"}),w==="search"?"搜索中…":"搜索"]})]}),k?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:k}):null,j?i.jsx("p",{className:"af-set-hint af-set-hint--inline",children:j}):null,i.jsxs("div",{className:"af-set-skillhub-grid",children:[i.jsxs("div",{className:"af-set-skillhub-pane",children:[i.jsxs("div",{className:"af-set-skillhub-pane-head",children:[i.jsx("h3",{children:"已安装"}),i.jsx("span",{children:s.length})]}),i.jsx("div",{className:"af-set-skillhub-list",children:s.length===0?i.jsx("div",{className:"af-set-skillhub-empty",children:"暂无 AgentFlow 共享 skills"}):s.map(D=>{const O=y[D.name],M=!O||O.state==="update"||O.state==="remote-only"||O.state==="unknown"||O.state==="error",K=w===`install:${D.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:D.displayName||D.name}),i.jsx("div",{className:"af-set-skillhub-meta",children:_F(D)}),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:()=>R(D.name,!0),disabled:!t||!!w||!M,children:K}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>A(D.name),disabled:!t||!!w,children:"卸载"})]})]},`${D.agent}:${D.path}:${D.name}`)})})]}),i.jsxs("div",{className:"af-set-skillhub-pane",children:[i.jsxs("div",{className:"af-set-skillhub-pane-head",children:[i.jsx("h3",{children:"搜索结果"}),i.jsx("span",{children:p.length})]}),i.jsx("div",{className:"af-set-skillhub-list",children:p.length===0?i.jsx("div",{className:"af-set-skillhub-empty",children:"输入关键词后搜索 SkillHub"}):p.map(D=>{const O=D.slug||D.name,M=D.kind==="collection"||D.collection,K=!M&&s.some(z=>z.name===O||z.name===D.name);return i.jsxs("div",{className:"af-set-skillhub-item",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-set-skillhub-title",children:D.name||O}),i.jsxs("div",{className:"af-set-skillhub-meta",children:[M?`collection:${D.collection}`:O,D.skillId?` · id:${D.skillId}`:"",D.version?` · ${D.version}`:""]}),D.summary?i.jsx("p",{className:"af-set-skillhub-summary",children:D.summary}):null]}),i.jsx("button",{type:"button",className:K?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>R(D,K),disabled:!t||!!w,children:K?"更新":M?"安装合集":"安装"})]},D.id||O)})})]})]})]})}function Da(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 AF(e){return{version:1,collections:Da({collections:e})}}function PF(e){const t=String(e||"").trim(),n=t.indexOf(":");return n>=0?t.slice(n+1).trim():t}function EP(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(PF(s)))||""}}function Zo(e,t){const n=EP(t);return Array.from(new Set((Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).map(r=>n(r)).filter(Boolean)))}function IF(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 RF(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function TF(e,t,n){const r=Zo(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 MF(e,t,n){const r=String(e).trim().toLowerCase(),s=Da({collections:n}).find(o=>o.id===r||o.name.toLowerCase()===r);return Zo(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=Da({collections:r}),l=MF(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=EP(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)),w=a.some(g=>{if(!g.builtin||g.id===o||g.name.toLowerCase()===o)return!1;const k=Zo(g,n);return k.length>0&&k.every(b=>h.has(b))});return l.length>0&&w&&!v?c:p}}}catch{}return c}function Pl(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 LF(e){const t=e??"user";return t==="builtin"||t==="admin"?"af-project-card af-project-card--builtin":"af-project-card"}function OF(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 _x(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 AP(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 DF="project:defaultCardDesc";function PP(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(DF)}function FF(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Hn({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(`(${FF(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 zF(e,t,n){const r=[String(e.id),PP(e,n),AP(e),_x(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
|
|
41
|
-
`).toLowerCase()}function BF(e,t,n){return t?zF(e,t,n).includes(t):!0}function HF(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 My(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
|
|
42
|
-
`).toLowerCase().includes(n):!0}function Zj(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 eN(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const WF=["all","agent","control","provide","marketplace"],VF=["all","agent","control","provide"],IP="agentflow.projects.activityPanelOpen",Ex="agentflow.projects.activitySelected";function KF(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(IP);return e!=="0"}function tN(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function qF(){return typeof localStorage>"u"?"":localStorage.getItem(Ex)||""}function xp(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function Wn(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 UF(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 Co(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function RP(e){var n;const t=(n=e==null?void 0:e.snippet)==null?void 0:n.instances;return Array.isArray(t)?t.filter(r=>r&&typeof r=="object"):t&&typeof t=="object"?Object.entries(t).map(([r,s])=>({...s&&typeof s=="object"?s:{},instanceId:(s==null?void 0:s.instanceId)||r})):[]}function TP(e){var n;const t=(n=e==null?void 0:e.snippet)==null?void 0:n.edges;return Array.isArray(t)?t.filter(r=>r&&typeof r=="object"):[]}function Ax(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 nN(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||Ax(e,t))}function YF(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function rN(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 GF(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 $y(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function JF(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 XF(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 QF(e){var v,w,g,k;const t=RP(e),n=TP(e),r=new Map(t.map((b,j)=>[Ax(b,j),nN(b,j)])),s=t.map((b,j)=>({id:Ax(b,j),title:nN(b,j),meta:YF(b)})),o=n.map((b,j)=>{const N=rN(b,"source"),C=rN(b,"target");return{key:(b==null?void 0:b.id)||`${N}-${C}-${j}`,sourceId:N,targetId:C,source:r.get(N)||N||"?",target:r.get(C)||C||"?",label:GF(b)}}),a=(w=(v=e==null?void 0:e.snippet)==null?void 0:v.ui)!=null&&w.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=XF(s,o),u=s.map(b=>{const j=JF(a[b.id])||c.get(b.id)||{x:0,y:0},N=l[b.id]&&typeof l[b.id]=="object"?l[b.id]:{},C=Number(N.width),I=Number(N.height),R=Math.max(132,Math.min(210,Number.isFinite(C)?C*.62:150)),H=Math.max(48,Math.min(76,Number.isFinite(I)?I*.46:54));return{...b,x:j.x,y:j.y,width:R,height:H}}),d=new Map(u.map(b=>[b.id,b])),f=o.map(b=>{const j=d.get(b.sourceId),N=d.get(b.targetId);if(!j||!N)return null;const C=j.x+j.width,I=j.y+j.height/2,R=N.x,H=N.y+N.height/2,A=Math.max(48,Math.abs(R-C)*.45);return{...b,path:`M ${C} ${I} C ${C+A} ${I}, ${R-A} ${H}, ${R} ${H}`,labelX:(C+R)/2,labelY:(I+H)/2}}).filter(Boolean),p=u.reduce((b,j)=>({minX:Math.min(b.minX,j.x),minY:Math.min(b.minY,j.y),maxX:Math.max(b.maxX,j.x+j.width),maxY:Math.max(b.maxY,j.y+j.height)}),{minX:0,minY:0,maxX:420,maxY:220}),h=36,y=`${p.minX-h} ${p.minY-h} ${Math.max(360,p.maxX-p.minX+h*2)} ${Math.max(180,p.maxY-p.minY+h*2)}`;return{nodes:s,edges:o,diagram:{nodes:u,edges:f,viewBox:y}}}function Il({resourceKind:e="",authUser:t=null}){var Pe,wt,Dt,Yt,Bn,Dn;const{t:n}=zr(),{navigate:r,path:s}=gs(),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([]),[w,g]=m.useState([]),[k,b]=m.useState(""),[j,N]=m.useState(!1),[C,I]=m.useState([]),[R,H]=m.useState(""),[A,L]=m.useState(""),[D,O]=m.useState(!1),[M,K]=m.useState(!1),[z,F]=m.useState(!1),[$,W]=m.useState(null),[E,Q]=m.useState(!1),[V,B]=m.useState(""),[se,ue]=m.useState(KF),[G,ee]=m.useState(qF),[te,ne]=m.useState("all"),[Z,ce]=m.useState(""),[de,me]=m.useState("overview"),[$e,Ce]=m.useState({}),[_e,Be]=m.useState(""),[ot,gt]=m.useState({}),[Te,st]=m.useState(""),[mt,Tt]=m.useState(""),[xe,Oe]=m.useState({}),[ie,ke]=m.useState(""),[Ke,Ue]=m.useState(""),[be,It]=m.useState(""),[nn,Vt]=m.useState(""),[Ot,ln]=m.useState(""),[re,Re]=m.useState(!1),[Je,Ze]=m.useState(""),[Mt,_t]=m.useState({hiddenBuiltins:[],promoted:[]}),Kn=m.useRef(0),jn=m.useRef(0),br=m.useRef(0),xn=m.useCallback(async()=>{var he,De;const q=++jn.current;H("");try{const Ee=await fetch("/api/flows");if(q!==jn.current)return;if(!Ee.ok)throw new Error("HTTP "+Ee.status);const et=await Ee.json();if(q!==jn.current)return;u(Array.isArray(et)?et:[])}catch(Ee){if(q!==jn.current)return;u([]),H(String(Ee.message||Ee))}try{const Ee=await fetch("/api/pipeline-recent-runs");if(q!==jn.current)return;if(Ee.ok){const et=await Ee.json();if(q!==jn.current)return;I(Array.isArray(et.runs)?et.runs:[])}else I([])}catch{if(q!==jn.current)return;I([])}if(t!=null&&t.isAdmin)try{const Ee=await fetch("/api/admin/builtin-flows");if(q!==jn.current)return;const et=await Ee.json().catch(()=>({}));Ee.ok&&_t({hiddenBuiltins:Array.isArray((he=et==null?void 0:et.config)==null?void 0:he.hiddenBuiltins)?et.config.hiddenBuiltins:[],promoted:Array.isArray((De=et==null?void 0:et.config)==null?void 0:De.promoted)?et.config.promoted:[]})}catch{if(q!==jn.current)return;_t({hiddenBuiltins:[],promoted:[]})}else _t({hiddenBuiltins:[],promoted:[]});O(!0)},[t==null?void 0:t.isAdmin]),Qn=m.useCallback(async(q,he)=>{if(!(t!=null&&t.isAdmin)||!(q!=null&&q.id))return;const De=`${he}:${q.source}:${q.id}`;Ze(De),H("");try{const Ee=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:he,flowId:q.id,ownerUserId:q.ownerUserId||t.userId})}),et=await Ee.json().catch(()=>({}));if(!Ee.ok)throw new Error(et.error||"更新内置配置失败");await xn()}catch(Ee){H(String(Ee.message||Ee))}finally{Ze("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,xn]),qn=m.useCallback(async()=>{const q=++br.current;L(""),K(!1);const he="/api/nodes",De=e==="my-flows"?"/api/marketplace/flow-snippets?scope=owned":"/api/marketplace/flow-snippets";f([]),v([]),ce("");try{const[Ee,et,Nn,bt]=await Promise.all([fetch(he),fetch("/api/skills"),fetch("/api/skill-collections"),fetch(De)]),Gt=await Ee.json().catch(()=>({})),Cn=await et.json().catch(()=>({})),yo=await Nn.json().catch(()=>({})),at=await bt.json().catch(()=>({}));if(!Ee.ok)throw new Error(Gt.error||"Nodes HTTP "+Ee.status);if(!et.ok)throw new Error(Cn.error||"Skills HTTP "+et.status);if(!Nn.ok)throw new Error(yo.error||"Collections HTTP "+Nn.status);if(!bt.ok)throw new Error(at.error||"Flow snippets HTTP "+bt.status);if(q!==br.current)return;f(Array.isArray(Gt.nodes)?Gt.nodes:Array.isArray(Gt)?Gt:[]),h(Array.isArray(Cn.skills)?Cn.skills:[]),g(Da(yo)),v(Array.isArray(at.snippets)?at.snippets:[])}catch(Ee){if(q!==br.current)return;f([]),h([]),v([]),g([]),L(String(Ee.message||Ee))}finally{if(q!==br.current)return;K(!0)}},[e]);m.useEffect(()=>{O(!1),xn(),qn()},[xn,qn]),m.useEffect(()=>{try{localStorage.setItem(IP,se?"1":"0")}catch{}},[se]),m.useEffect(()=>{try{G?localStorage.setItem(Ex,G):localStorage.removeItem(Ex)}catch{}},[G]),m.useEffect(()=>{let q=!1;return fetch("/api/ui-context").then(he=>he.json()).then(he=>{q||Re(!!he.hideCommunityLinks)}).catch(()=>{}),()=>{q=!0}},[]);const mr=m.useCallback(async q=>{if(!o)return;const he=Da({collections:q});N(!0),L("");try{const De=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(AF(he))}),Ee=await De.json().catch(()=>({}));if(!De.ok)throw new Error(Ee.error||"Collections HTTP "+De.status);g(Da(Ee))}catch(De){L(String(De.message||De))}finally{N(!1)}},[o]),ts=m.useCallback(()=>{if(!o)return;const q=k.trim();if(!q)return;const he=q.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",De=new Set(w.map(bt=>bt.id));let Ee=he,et=2;for(;De.has(Ee);)Ee=`${he}-${et++}`;const Nn=Date.now();mr([...w,{id:Ee,name:q,skillKeys:[],createdAt:Nn,updatedAt:Nn}]),b(""),ne(`collection:${Ee}`)},[o,k,mr,w]),Pr=m.useCallback(q=>{if(!o)return;const he=w.find(Ee=>Ee.id===q);if(he!=null&&he.builtin)return;const De=w.filter(Ee=>Ee.id!==q);te===`collection:${q}`&&ne("all"),mr(De)},[o,te,mr,w]),ys=m.useCallback((q,he,De)=>{if(!o)return;const Ee=String(he||"").trim();if(!Ee)return;const et=Date.now(),Nn=w.map(bt=>{if(bt.id!==q)return bt;const Gt=new Set(bt.skillKeys||[]);return De?Gt.add(Ee):Gt.delete(Ee),{...bt,skillKeys:Array.from(Gt),updatedAt:et}});mr(Nn)},[o,mr,w]),ws=m.useCallback(async q=>{const he=q==null?void 0:q.packageId,De=q==null?void 0:q.version;if(!he||!De||!window.confirm(n("project:deleteMyNodeConfirm",{id:he,version:De})))return;const Ee=Wn(q);Ue(Ee),It(""),L("");try{const et=new URLSearchParams({id:he,version:De}),Nn=await fetch(`/api/marketplace/node?${et.toString()}`,{method:"DELETE"}),bt=await Nn.json().catch(()=>({}));if(!Nn.ok||(bt==null?void 0:bt.ok)===!1){const Gt=Array.isArray(bt==null?void 0:bt.usage)&&bt.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:bt.usage.length})}`:"";throw new Error(((bt==null?void 0:bt.error)||"Delete failed")+Gt)}It(n("project:deleteMyNodeSuccess",{id:he,version:De})),gt(Gt=>{const Cn={...Gt};return delete Cn[Ee],Cn}),Oe(Gt=>{const Cn={};for(const[yo,at]of Object.entries(Gt))yo.startsWith(`${Ee}:`)||(Cn[yo]=at);return Cn}),ce(""),await qn()}catch(et){It(String(et.message||et))}finally{Ue("")}},[qn,n]),dn=m.useCallback(async q=>{const he=q==null?void 0:q.id,De=(q==null?void 0:q.version)||"1.0.0";if(!he||!De||!window.confirm(n("project:deleteMyFlowConfirm",{id:he,version:De})))return;const Ee=Co(q);Vt(Ee),ln(""),L("");try{const et=new URLSearchParams({id:he,version:De}),Nn=await fetch(`/api/marketplace/flow-snippet?${et.toString()}`,{method:"DELETE"}),bt=await Nn.json().catch(()=>({}));if(!Nn.ok||(bt==null?void 0:bt.ok)===!1)throw new Error((bt==null?void 0:bt.error)||"Delete failed");ln(n("project:deleteMyFlowSuccess",{id:he,version:De})),ce(""),await qn()}catch(et){ln(String(et.message||et))}finally{Vt("")}},[qn,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),he=q.get("tab");let De=!1;if(he==="nodes"){r("/nodes");return}if(he==="my-nodes"){r("/my-nodes");return}if(he==="my-flows"){r("/my-flows");return}if(he==="skills"){r("/skills");return}if(he==="archived"?(l("archived"),q.delete("tab"),De=!0):he&&(l("all"),q.delete("tab"),De=!0),q.get("new")==="1"&&(F(!0),q.delete("new"),De=!0),De){const Ee=q.toString();window.history.replaceState({},"",Ee?`/projects?${Ee}`:"/projects")}},[s,r]);const sr=m.useMemo(()=>VD(C,HD(),c),[C,c,s]),Ir=m.useMemo(()=>sr.filter(q=>HF(V,q)),[sr,V]),pn=V.trim().toLowerCase(),Zn=m.useMemo(()=>a==="archived"?c.filter(q=>q.archived):c.filter(q=>!q.archived),[c,a]),kr=m.useMemo(()=>Zn.filter(q=>BF(q,pn,n)),[Zn,pn,n]),ir=m.useMemo(()=>new Set((Mt.promoted||[]).map(q=>String((q==null?void 0:q.id)||"").trim()).filter(Boolean)),[Mt.promoted]),jt=m.useMemo(()=>(Mt.hiddenBuiltins||[]).map(q=>String(q||"").trim()).filter(Boolean),[Mt.hiddenBuiltins]),Xt=a==="nodes"||a==="my-nodes",Nt=a==="my-nodes",le=a==="my-flows",ve=m.useMemo(()=>d.filter(q=>Nt&&!UF(q,t)?!1:(te==="all"||(te==="marketplace"?q.source==="marketplace":q.type===te))&&My(V,[q.id,q.label,q.displayName,q.description,q.type,q.source,q.packageId,q.version])),[t,d,Nt,V,te]),it=m.useMemo(()=>{const q=new Map;for(const he of w)q.set(he.id,new Set(Zo(he,p)));return q},[p,w]),zt=m.useMemo(()=>[{id:"all",label:"全部"},...w.map(q=>{var he;return{id:`collection:${q.id}`,label:q.name,count:((he=it.get(q.id))==null?void 0:he.size)||0,collection:q}}),{id:"ungrouped",label:"未分组"}],[it,w]),Qt=m.useMemo(()=>p.filter(q=>{var Ee;const he=Wn(q);let De=te==="all";if(te.startsWith("collection:")){const et=te.slice(11);De=!!((Ee=it.get(et))!=null&&Ee.has(he))}else te==="ungrouped"&&(De=!Array.from(it.values()).some(et=>et.has(he)));return De&&My(V,[q.name,q.id,q.description,q.sourceLabel,q.source,q.path])}),[p,V,te,it]),rn=m.useMemo(()=>y.filter(q=>My(V,[q.id,q.name,q.displayName,q.description,q.version,q.packageDir,Array.isArray(q.tags)?q.tags.join(" "):""])),[y,V]),er=Xt||le||a==="skills",ht=m.useMemo(()=>ve.find(q=>Wn(q)===Z)||ve[0]||null,[ve,Z]),sn=m.useMemo(()=>Qt.find(q=>Wn(q)===Z)||Qt[0]||null,[Qt,Z]),Kt=m.useMemo(()=>rn.find(q=>Co(q)===Z)||rn[0]||null,[rn,Z]),vr=sn?$e[Wn(sn)]:null,tt=ht?ot[Wn(ht)]:null,On=ht&&mt?xe[`${Wn(ht)}:${mt}`]:null,$i=n(Xt?"project:searchNodes":le?"project:searchFlows":a==="skills"?"project:searchSkills":"project:searchPipelines");m.useEffect(()=>{if(a!=="skills"||!sn)return;const q=Wn(sn);if($e[q])return;let he=!1;return Be(q),fetch(`/api/skills/detail?key=${encodeURIComponent(q)}`).then(De=>De.json().then(Ee=>({ok:De.ok,json:Ee}))).then(({ok:De,json:Ee})=>{he||De&&Ee.skill&&Ce(et=>({...et,[q]:Ee.skill}))}).catch(()=>{}).finally(()=>{he||Be("")}),()=>{he=!0}},[a,sn,$e]),m.useEffect(()=>{if(!Xt||!ht)return;const q=Wn(ht);if(ot[q])return;let he=!1;return st(q),fetch(`/api/nodes/detail?id=${encodeURIComponent(ht.id)}`).then(De=>De.json().then(Ee=>({ok:De.ok,json:Ee}))).then(({ok:De,json:Ee})=>{he||De&>(et=>({...et,[q]:Ee}))}).catch(()=>{}).finally(()=>{he||st("")}),()=>{he=!0}},[Xt,ht,ot]),m.useEffect(()=>{if(!Xt)return;const q=Array.isArray(tt==null?void 0:tt.files)?tt.files:[];Tt(he=>{var De;return he&&q.some(Ee=>Ee.path===he)?he:((De=q[0])==null?void 0:De.path)||""})},[Xt,tt]),m.useEffect(()=>{if(!Xt||!ht||!mt)return;const q=`${Wn(ht)}:${mt}`;if(xe[q])return;let he=!1;return ke(q),fetch(`/api/nodes/file?id=${encodeURIComponent(ht.id)}&path=${encodeURIComponent(mt)}`).then(De=>De.json().then(Ee=>({ok:De.ok,json:Ee}))).then(({ok:De,json:Ee})=>{he||De&&Oe(et=>({...et,[q]:Ee}))}).catch(()=>{}).finally(()=>{he||ke("")}),()=>{he=!0}},[Xt,ht,mt,xe]),m.useEffect(()=>{It("")},[Z,a]);const Br=q=>{r(wp(q,"workspace"))},go=q=>{ee(tN(q)),r(wp({id:q.flowId,source:q.flowSource,archived:!!q.archived},"workspace"))},ai=m.useCallback(q=>{var he,De;q.preventDefault(),q.stopPropagation(),(De=(he=q.dataTransfer)==null?void 0:he.types)!=null&&De.includes("Files")&&(Kn.current+=1,Q(!0))},[]),Ms=m.useCallback(q=>{q.preventDefault(),q.stopPropagation(),Kn.current-=1,Kn.current<=0&&(Kn.current=0,Q(!1))},[]),oe=m.useCallback(q=>{q.preventDefault(),q.stopPropagation()},[]),Se=m.useCallback(q=>{var Ee,et;q.preventDefault(),q.stopPropagation(),Kn.current=0,Q(!1);const he=(et=(Ee=q.dataTransfer)==null?void 0:Ee.files)==null?void 0:et[0];if(!he)return;const De=he.name.toLowerCase();!De.endsWith(".yaml")&&!De.endsWith(".yml")&&!De.endsWith(".zip")||W(he)},[]);return i.jsxs("div",{className:"af-projects"+(E?" af-projects--drop-target":""),onDragEnter:ai,onDragLeave:Ms,onDragOver:oe,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]}),er?i.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>qn(),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:()=>F(!0),children:n("project:createNew")})]})]})]}),i.jsxs("div",{className:"af-projects-body",children:[i.jsxs("section",{className:"af-projects-main",children:[i.jsxs("header",{className:"af-projects-section-head",children:[i.jsx("h2",{className:"af-projects-h2",children:n(a==="my-nodes"?"project:myNodes":a==="my-flows"?"project:myFlows":a==="nodes"?"project:nodes":a==="skills"?"project:globalSkills":a==="archived"?"project:archivedPipelines":"project:activeProjects")}),i.jsx("p",{className:"af-projects-sub",children:pn?n("project:filterResult",{count:a==="nodes"||a==="my-nodes"?ve.length:a==="my-flows"?rn.length:a==="skills"?Qt.length:kr.length}):a==="my-nodes"?n("project:myNodesHint",{count:ve.length}):a==="my-flows"?n("project:myFlowsHint",{count:rn.length}):a==="nodes"?n("project:nodesHint",{count:d.length}):a==="skills"?n("project:skillsHint",{count:p.length}):n(a==="archived"?"project:archivedHint":"project:activeHint")}),R?i.jsx("p",{className:"af-err af-projects-api-hint",children:R}):null,A&&er?i.jsx("p",{className:"af-err af-projects-api-hint",children:A}):null]}),er?i.jsxs("div",{className:"af-resource-toolbar",children:[a==="skills"?i.jsx(EF,{onChanged:qn,canManage:!!(t!=null&&t.isAdmin)}):null,i.jsxs("div",{className:"af-resource-purpose",children:[i.jsx("span",{className:"material-symbols-outlined",children:le?"schema":Xt?Nt?"deployed_code":"account_tree":"extension"}),i.jsxs("div",{children:[i.jsx("h3",{children:n(le?"project:myFlowsPurposeTitle":Nt?"project:myNodesPurposeTitle":Xt?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),i.jsx("p",{children:n(le?"project:myFlowsPurposeDesc":Nt?"project:myNodesPurposeDesc":Xt?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),le?null:i.jsxs(i.Fragment,{children:[Xt?i.jsxs("div",{className:"af-resource-filter-row",children:[i.jsx("button",{type:"button",className:"af-resource-filter"+(Nt?"":" af-resource-filter--active"),onClick:()=>{l("nodes"),ne("all"),ce("")},children:n("project:nodeScopeAll")}),i.jsx("button",{type:"button",className:"af-resource-filter"+(Nt?" 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:(Xt?(Nt?VF:WF).map(q=>({id:q,label:n(`project:resourceFilter.${q}`)})):zt).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:j,"aria-label":`删除 ${q.collection.name}`,onClick:()=>Pr(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=>b(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()||j,onClick:()=>ts(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,Xt?i.jsx("div",{className:"af-resource-grid",children:ve.length>0?ve.map(q=>i.jsxs("button",{type:"button",className:"af-resource-card"+(ht&&Wn(q)===Wn(ht)?" af-resource-card--active":""),onClick:()=>ce(Wn(q)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Pl(q.type==="control"?"secondary":q.type==="provide"?"primary":"muted"),children:i.jsx(Hn,{query:V,children:q.type||"node"})}),i.jsx("span",{className:"af-resource-source",children:i.jsx(Hn,{query:V,children:Zj(q.source,n)})})]}),i.jsx("h3",{className:"af-project-title",children:i.jsx(Hn,{query:V,children:q.label||q.displayName||q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Hn,{query:V,children:q.description||n("project:noDescription")})}),i.jsxs("div",{className:"af-resource-meta-row",children:[i.jsx("span",{children:i.jsx(Hn,{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(Hn,{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:pn?n("project:noNodeMatch",{query:V.trim()}):n(Nt?"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:rn.length>0?rn.map(q=>{const he=RP(q),De=TP(q),Ee=Number.isFinite(Number(q.nodeCount))?Number(q.nodeCount):he.length,et=Number.isFinite(Number(q.edgeCount))?Number(q.edgeCount):De.length;return i.jsxs("button",{type:"button",className:"af-resource-card"+(Kt&&Co(q)===Co(Kt)?" af-resource-card--active":""),onClick:()=>ce(Co(q)),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Pl("primary"),children:i.jsx(Hn,{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(Hn,{query:V,children:q.displayName||q.name||q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Hn,{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(Hn,{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(Hn,{query:V,children:eN(q)})})]})]},Co(q))}):M?i.jsx("div",{className:"af-projects-empty-block",children:i.jsx("p",{className:"af-projects-empty",children:pn?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:Qt.length>0?Qt.map(q=>{const he=Wn(q),De=w.filter(Ee=>{var et;return(et=it.get(Ee.id))==null?void 0:et.has(he)});return i.jsxs("button",{type:"button",className:"af-resource-card"+(sn&&he===Wn(sn)?" af-resource-card--active":""),onClick:()=>ce(he),children:[i.jsxs("div",{className:"af-resource-card-head",children:[i.jsx("span",{className:Pl(q.source==="builtin"?"muted":"primary"),children:i.jsx(Hn,{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(Hn,{query:V,children:q.name||q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Hn,{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(Hn,{query:V,children:q.path||q.key||""})})]}),i.jsxs("div",{className:"af-skill-card-collections",children:[De.slice(0,3).map(Ee=>i.jsx("span",{children:Ee.name},Ee.id)),De.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:pn?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"&&jt.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:jt.map(q=>{const he=Je===`show-builtin:builtin:${q}`;return i.jsxs("button",{type:"button",disabled:he,onClick:()=>Qn({id:q,source:"builtin"},"show-builtin"),children:[i.jsx("span",{children:q}),i.jsx("em",{children:he?"恢复中":"恢复"})]},q)})})]}):null,i.jsxs("div",{className:"af-project-grid",children:[kr.length>0?kr.map(q=>{var Nn,bt;const he=(t==null?void 0:t.isAdmin)&&q.source==="user"&&!q.archived&&!ir.has(q.id),De=(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:LF(q.source),role:"button",tabIndex:0,onClick:()=>Br(q),onKeyDown:Gt=>{(Gt.key==="Enter"||Gt.key===" ")&&(Gt.preventDefault(),Br(q))},children:i.jsxs("div",{className:"af-project-card-body",children:[i.jsx("span",{className:Pl(_x(q.source,n).tone),children:i.jsx(Hn,{query:V,children:_x(q.source,n).label})}),q.source==="workspace"&&((Nn=q.collaboration)!=null&&Nn.role)?i.jsx("span",{className:Pl(q.collaboration.role==="owner"?"primary":"muted"),children:q.collaboration.role==="owner"?"我创建的":`${q.collaboration.ownerUsername||q.collaboration.ownerId} 分享`}):null,q.archived?i.jsx("span",{className:Pl("muted"),children:i.jsx(Hn,{query:V,children:n("project:archived")})}):null,i.jsx("h3",{className:"af-project-title",children:i.jsx(Hn,{query:V,children:q.id})}),i.jsx("p",{className:"af-project-desc",children:i.jsx(Hn,{query:V,children:PP(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(Hn,{query:V,children:AP(q)})})]}),t!=null&&t.isAdmin?i.jsxs("div",{className:"af-project-admin-actions",onClick:Gt=>Gt.stopPropagation(),onKeyDown:Gt=>Gt.stopPropagation(),children:[he?i.jsx("button",{type:"button",disabled:et,onClick:()=>Qn(q,"promote"),children:"设为内置"}):null,De?i.jsx("button",{type:"button",disabled:et,onClick:()=>Qn(q,"unpromote"),children:"取消内置"}):null,Ee?i.jsx("button",{type:"button",disabled:et,onClick:()=>Qn(q,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${q.id}:${q.source??"user"}:${q.archived?"a":""}:${((bt=q.collaboration)==null?void 0:bt.id)||"own"}`)}):D?Zn.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(R?"project:loadFailed":"project:noPipelines")}),!R&&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:()=>F(!0),children:[i.jsx("span",{className:"material-symbols-outlined af-project-add-icon",children:"add_circle"}),i.jsx("span",{className:"af-project-add-label",children:n("project:newPipeline")})]}),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")})]})]})]})]}),er?i.jsx("aside",{className:"af-resource-detail","aria-label":n(Xt?"project:nodeDetail":le?"project:flowDetail":"project:skillDetail"),children:Xt&&ht?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:ht.label||ht.displayName||ht.id}),i.jsx("p",{children:ht.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===Wn(ht)?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:ht.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:ht.type||((wt=tt==null?void 0:tt.node)==null?void 0:wt.type)||"node"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailSource")}),i.jsx("dd",{children:Zj(ht.source,n)})]}),ht.packageId?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPackage")}),i.jsx("dd",{children:ht.packageId})]}):null,ht.version?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailVersion")}),i.jsx("dd",{children:ht.version})]}):null,ht.packageDir||tt!=null&&tt.baseDir?i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:ht.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")})]})]}),Nt&&ht.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===Wn(ht),onClick:()=>ws(ht),children:[i.jsx("span",{className:"material-symbols-outlined",children:"delete"}),Ke===Wn(ht)?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")}),xp(((Dt=tt==null?void 0:tt.node)==null?void 0:Dt.inputs)||ht.inputs).length>0?xp(((Yt=tt==null?void 0:tt.node)==null?void 0:Yt.inputs)||ht.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")}),xp(((Bn=tt==null?void 0:tt.node)==null?void 0:Bn.outputs)||ht.outputs).length>0?xp(((Dn=tt==null?void 0:tt.node)==null?void 0:Dn.outputs)||ht.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"+(mt===q.path?" af-node-file-item--active":""),onClick:()=>Tt(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:[ie===`${Wn(ht)}:${mt}`?n("project:loadingResources"):On!=null&&On.binary?n("project:binaryFile"):(On==null?void 0:On.content)||n("project:selectNodeFile"),On!=null&&On.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(he=>he.label||he.instanceId).join(", ")})]},`${q.flowSource}:${q.flowId}:${q.archived?"a":""}`))}):i.jsx("p",{children:n("project:noNodeUsage")})]})]}):le&&Kt?(()=>{const q=QF(Kt);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:Kt.displayName||Kt.name||Kt.id}),i.jsx("p",{children:Kt.id})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:Kt.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:Kt.version||"1.0.0"})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:eN(Kt)})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:flowSnippetScale")}),i.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(Kt.nodeCount))?Number(Kt.nodeCount):q.nodes.length,edges:Number.isFinite(Number(Kt.edgeCount))?Number(Kt.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:nn===Co(Kt),onClick:()=>dn(Kt),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),nn===Co(Kt)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),Ot?i.jsx("p",{className:"af-resource-action-message",children:Ot}):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(he=>i.jsxs("g",{children:[i.jsx("path",{d:he.path}),he.label?i.jsx("text",{x:he.labelX,y:he.labelY-5,textAnchor:"middle",children:$y(he.label,18)}):null]},he.key))}),i.jsx("g",{className:"af-flow-snippet-map__nodes",children:q.diagram.nodes.map((he,De)=>i.jsxs("g",{transform:`translate(${he.x} ${he.y})`,children:[i.jsx("rect",{width:he.width,height:he.height,rx:"10"}),i.jsx("circle",{cx:"19",cy:he.height/2,r:"12"}),i.jsx("text",{className:"af-flow-snippet-map__node-index",x:"19",y:he.height/2+4,textAnchor:"middle",children:De+1}),i.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:he.height/2-3,children:$y(he.title)}),i.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:he.height/2+16,children:$y(he.meta||he.id,20)})]},he.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(Kt.snippet||{},null,2)})]})]})]})})():a==="skills"&&sn?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:sn.name||sn.id}),i.jsx("p",{children:sn.sourceLabel||sn.source})]})]}),i.jsx("p",{className:"af-resource-detail-desc",children:sn.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:sn.sourceLabel||sn.source})]}),i.jsxs("div",{children:[i.jsx("dt",{children:n("project:detailPath")}),i.jsx("dd",{children:sn.path||sn.key})]})]}),i.jsxs("div",{className:"af-resource-detail-section",children:[i.jsx("h4",{children:"Collections"}),w.length===0?i.jsx("p",{children:"暂无 collection。可在左侧新建后再添加。"}):i.jsx("div",{className:"af-skill-detail-collections",children:w.map(q=>{const he=Wn(sn),De=it.get(q.id)||new Set,Ee=De.has(he);return i.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[i.jsx("input",{type:"checkbox",checked:Ee,disabled:j||!o,onChange:et=>ys(q.id,he,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:[De.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===Wn(sn)?n("project:loadingResources"):(vr==null?void 0:vr.body)||(vr==null?void 0:vr.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:Ir.length===0?i.jsx("p",{className:"af-activity-empty",children:sr.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):Ir.map(q=>{const he=G===tN(q);return i.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action"+(he?" af-activity-row--active":""),"aria-current":he?"page":void 0,onClick:()=>go(q),children:[i.jsxs("div",{className:"af-activity-row-top",children:[i.jsx("h4",{className:"af-activity-name",children:i.jsx(Hn,{query:V,children:q.flowId})}),i.jsx("span",{className:"af-activity-time",children:Xj(q.at,n)})]}),i.jsxs("div",{className:"af-activity-meta",children:[i.jsx("span",{className:OF(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")," · ",Xj(q.at,n)]})]})]},`${q.kind}-${q.flowId}-${q.flowSource}-${q.at}`)})})]})]}),i.jsx(xF,{open:z,onClose:()=>F(!1),onCreated:async q=>{F(!1),await xn();const he=q.source??"user";r(wp({id:q.id,source:he},"workspace"))}}),$?i.jsx(yF,{file:$,onClose:()=>W(null),onImported:async q=>{W(null),await xn();const he=q.source??"user";r(wp({id:q.id,source:he},"workspace"))}},`${$.name}-${$.size}-${$.lastModified}`):null]})}function Xn(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=Xn(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var ZF={value:()=>{}};function Km(){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 ah(n)}function ah(e){this._=e}function ez(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}})}ah.prototype=Km.prototype={constructor:ah,on:function(e,t){var n=this._,r=ez(e+"",n),s,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((s=(e=r[o]).type)&&(s=tz(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]=sN(n[s],e.name,t);else if(t==null)for(s in n)n[s]=sN(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 ah(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 tz(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function sN(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=ZF,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Px="http://www.w3.org/1999/xhtml";const iN={svg:"http://www.w3.org/2000/svg",xhtml:Px,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function qm(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),iN.hasOwnProperty(t)?{space:iN[t],local:e}:e}function nz(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Px&&t.documentElement.namespaceURI===Px?t.createElement(e):t.createElementNS(n,e)}}function rz(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function MP(e){var t=qm(e);return(t.local?rz:nz)(t)}function sz(){}function Ck(e){return e==null?sz:function(){return this.querySelector(e)}}function iz(e){typeof e!="function"&&(e=Ck(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 oz(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function az(){return[]}function $P(e){return e==null?az:function(){return this.querySelectorAll(e)}}function lz(e){return function(){return oz(e.apply(this,arguments))}}function cz(e){typeof e=="function"?e=lz(e):e=$P(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 LP(e){return function(){return this.matches(e)}}function OP(e){return function(t){return t.matches(e)}}var uz=Array.prototype.find;function dz(e){return function(){return uz.call(this.children,e)}}function fz(){return this.firstElementChild}function pz(e){return this.select(e==null?fz:dz(typeof e=="function"?e:OP(e)))}var hz=Array.prototype.filter;function mz(){return Array.from(this.children)}function gz(e){return function(){return hz.call(this.children,e)}}function yz(e){return this.selectAll(e==null?mz:gz(typeof e=="function"?e:OP(e)))}function wz(e){typeof e!="function"&&(e=LP(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 DP(e){return new Array(e.length)}function xz(){return new ps(this._enter||this._groups.map(DP),this._parents)}function Kh(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Kh.prototype={constructor:Kh,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 bz(e){return function(){return e}}function kz(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 Kh(e,o[a]);for(;a<c;++a)(l=t[a])&&(s[a]=l)}function vz(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 Kh(e,o[l]);for(l=0;l<d;++l)(c=t[l])&&u.get(p[l])===c&&(s[l]=c)}function Sz(e){return e.__data__}function jz(e,t){if(!arguments.length)return Array.from(this,Sz);var n=t?vz:kz,r=this._parents,s=this._groups;typeof e!="function"&&(e=bz(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=Nz(e.call(d,d&&d.__data__,u,r)),y=h.length,v=l[u]=new Array(y),w=a[u]=new Array(y),g=c[u]=new Array(p);n(d,f,v,w,g,h,t);for(var k=0,b=0,j,N;k<y;++k)if(j=v[k]){for(k>=b&&(b=k+1);!(N=w[b])&&++b<y;);j._next=N||null}}return a=new ps(a,r),a._enter=l,a._exit=c,a}function Nz(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function Cz(){return new ps(this._exit||this._groups.map(DP),this._parents)}function _z(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 Ez(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 Az(){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 Pz(e){e||(e=Iz);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 Iz(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function Rz(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function Tz(){return Array.from(this)}function Mz(){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 Lz(){return!this.node()}function Oz(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 Dz(e){return function(){this.removeAttribute(e)}}function Fz(e){return function(){this.removeAttributeNS(e.space,e.local)}}function zz(e,t){return function(){this.setAttribute(e,t)}}function Bz(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Hz(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Wz(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 Vz(e,t){var n=qm(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?Fz:Dz:typeof t=="function"?n.local?Wz:Hz:n.local?Bz:zz)(n,t))}function FP(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Kz(e){return function(){this.style.removeProperty(e)}}function qz(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Uz(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function Yz(e,t,n){return arguments.length>1?this.each((t==null?Kz:typeof t=="function"?Uz:qz)(e,t,n??"")):Cc(this.node(),e)}function Cc(e,t){return e.style.getPropertyValue(t)||FP(e).getComputedStyle(e,null).getPropertyValue(t)}function Gz(e){return function(){delete this[e]}}function Jz(e,t){return function(){this[e]=t}}function Xz(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Qz(e,t){return arguments.length>1?this.each((t==null?Gz:typeof t=="function"?Xz:Jz)(e,t)):this.node()[e]}function zP(e){return e.trim().split(/^|\s+/)}function _k(e){return e.classList||new BP(e)}function BP(e){this._node=e,this._names=zP(e.getAttribute("class")||"")}BP.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 HP(e,t){for(var n=_k(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function WP(e,t){for(var n=_k(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function Zz(e){return function(){HP(this,e)}}function e3(e){return function(){WP(this,e)}}function t3(e,t){return function(){(t.apply(this,arguments)?HP:WP)(this,e)}}function n3(e,t){var n=zP(e+"");if(arguments.length<2){for(var r=_k(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?t3:t?Zz:e3)(n,t))}function r3(){this.textContent=""}function s3(e){return function(){this.textContent=e}}function i3(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function o3(e){return arguments.length?this.each(e==null?r3:(typeof e=="function"?i3:s3)(e)):this.node().textContent}function a3(){this.innerHTML=""}function l3(e){return function(){this.innerHTML=e}}function c3(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function u3(e){return arguments.length?this.each(e==null?a3:(typeof e=="function"?c3:l3)(e)):this.node().innerHTML}function d3(){this.nextSibling&&this.parentNode.appendChild(this)}function f3(){return this.each(d3)}function p3(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function h3(){return this.each(p3)}function m3(e){var t=typeof e=="function"?e:MP(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function g3(){return null}function y3(e,t){var n=typeof e=="function"?e:MP(e),r=t==null?g3:typeof t=="function"?t:Ck(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function w3(){var e=this.parentNode;e&&e.removeChild(this)}function x3(){return this.each(w3)}function b3(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function k3(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function v3(e){return this.select(e?k3:b3)}function S3(e){return arguments.length?this.property("__data__",e):this.node().__data__}function j3(e){return function(t){e.call(this,t,this.__data__)}}function N3(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 C3(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 _3(e,t,n){return function(){var r=this.__on,s,o=j3(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 E3(e,t,n){var r=N3(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?_3:C3,s=0;s<o;++s)this.each(l(r[s],t,n));return this}function VP(e,t,n){var r=FP(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 A3(e,t){return function(){return VP(this,e,t)}}function P3(e,t){return function(){return VP(this,e,t.apply(this,arguments))}}function I3(e,t){return this.each((typeof t=="function"?P3:A3)(e,t))}function*R3(){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 KP=[null];function ps(e,t){this._groups=e,this._parents=t}function cf(){return new ps([[document.documentElement]],KP)}function T3(){return this}ps.prototype=cf.prototype={constructor:ps,select:iz,selectAll:cz,selectChild:pz,selectChildren:yz,filter:wz,data:jz,enter:xz,exit:Cz,join:_z,merge:Ez,selection:T3,order:Az,sort:Pz,call:Rz,nodes:Tz,node:Mz,size:$z,empty:Lz,each:Oz,attr:Vz,style:Yz,property:Qz,classed:n3,text:o3,html:u3,raise:f3,lower:h3,append:m3,insert:y3,remove:x3,clone:v3,datum:S3,on:E3,dispatch:I3,[Symbol.iterator]:R3};function as(e){return typeof e=="string"?new ps([[document.querySelector(e)]],[document.documentElement]):new ps([[e]],KP)}function M3(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Us(e,t){if(e=M3(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},Md={capture:!0,passive:!1};function Ly(e){e.stopImmediatePropagation()}function dc(e){e.preventDefault(),e.stopImmediatePropagation()}function qP(e){var t=e.document.documentElement,n=as(e).on("dragstart.drag",dc,Md);"onselectstart"in t?n.on("selectstart.drag",dc,Md):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function UP(e,t){var n=e.document.documentElement,r=as(e).on("dragstart.drag",null);t&&(r.on("click.drag",dc,Md),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 bp=e=>()=>e;function Ix(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}})}Ix.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function L3(e){return!e.ctrlKey&&!e.button}function O3(){return this.parentNode}function D3(e,t){return t??{x:e.x,y:e.y}}function F3(){return navigator.maxTouchPoints||"ontouchstart"in this}function YP(){var e=L3,t=O3,n=D3,r=F3,s={},o=Km("start","drag","end"),a=0,l,c,u,d,f=0;function p(j){j.on("mousedown.drag",h).filter(r).on("touchstart.drag",w).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(j,N){if(!(d||!e.call(this,j,N))){var C=b(this,t.call(this,j,N),j,N,"mouse");C&&(as(j.view).on("mousemove.drag",y,Md).on("mouseup.drag",v,Md),qP(j.view),Ly(j),u=!1,l=j.clientX,c=j.clientY,C("start",j))}}function y(j){if(dc(j),!u){var N=j.clientX-l,C=j.clientY-c;u=N*N+C*C>f}s.mouse("drag",j)}function v(j){as(j.view).on("mousemove.drag mouseup.drag",null),UP(j.view,u),dc(j),s.mouse("end",j)}function w(j,N){if(e.call(this,j,N)){var C=j.changedTouches,I=t.call(this,j,N),R=C.length,H,A;for(H=0;H<R;++H)(A=b(this,I,j,N,C[H].identifier,C[H]))&&(Ly(j),A("start",j,C[H]))}}function g(j){var N=j.changedTouches,C=N.length,I,R;for(I=0;I<C;++I)(R=s[N[I].identifier])&&(dc(j),R("drag",j,N[I]))}function k(j){var N=j.changedTouches,C=N.length,I,R;for(d&&clearTimeout(d),d=setTimeout(function(){d=null},500),I=0;I<C;++I)(R=s[N[I].identifier])&&(Ly(j),R("end",j,N[I]))}function b(j,N,C,I,R,H){var A=o.copy(),L=Us(H||C,N),D,O,M;if((M=n.call(j,new Ix("beforestart",{sourceEvent:C,target:p,identifier:R,active:a,x:L[0],y:L[1],dx:0,dy:0,dispatch:A}),I))!=null)return D=M.x-L[0]||0,O=M.y-L[1]||0,function K(z,F,$){var W=L,E;switch(z){case"start":s[R]=K,E=a++;break;case"end":delete s[R],--a;case"drag":L=Us($||F,N),E=a;break}A.call(z,j,new Ix(z,{sourceEvent:F,subject:M,target:p,identifier:R,active:E,x:L[0]+D,y:L[1]+O,dx:L[0]-W[0],dy:L[1]-W[1],dispatch:A}),I)}}return p.filter=function(j){return arguments.length?(e=typeof j=="function"?j:bp(!!j),p):e},p.container=function(j){return arguments.length?(t=typeof j=="function"?j:bp(j),p):t},p.subject=function(j){return arguments.length?(n=typeof j=="function"?j:bp(j),p):n},p.touchable=function(j){return arguments.length?(r=typeof j=="function"?j:bp(!!j),p):r},p.on=function(){var j=o.on.apply(o,arguments);return j===o?p:j},p.clickDistance=function(j){return arguments.length?(f=(j=+j)*j,p):Math.sqrt(f)},p}function Ek(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function GP(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function uf(){}var $d=.7,qh=1/$d,fc="\\s*([+-]?\\d+)\\s*",Ld="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ci="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",z3=/^#([0-9a-f]{3,8})$/,B3=new RegExp(`^rgb\\(${fc},${fc},${fc}\\)$`),H3=new RegExp(`^rgb\\(${Ci},${Ci},${Ci}\\)$`),W3=new RegExp(`^rgba\\(${fc},${fc},${fc},${Ld}\\)$`),V3=new RegExp(`^rgba\\(${Ci},${Ci},${Ci},${Ld}\\)$`),K3=new RegExp(`^hsl\\(${Ld},${Ci},${Ci}\\)$`),q3=new RegExp(`^hsla\\(${Ld},${Ci},${Ci},${Ld}\\)$`),oN={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};Ek(uf,Ya,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:aN,formatHex:aN,formatHex8:U3,formatHsl:Y3,formatRgb:lN,toString:lN});function aN(){return this.rgb().formatHex()}function U3(){return this.rgb().formatHex8()}function Y3(){return JP(this).formatHsl()}function lN(){return this.rgb().formatRgb()}function Ya(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=z3.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?cN(t):n===3?new Yr(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?kp(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?kp(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=B3.exec(e))?new Yr(t[1],t[2],t[3],1):(t=H3.exec(e))?new Yr(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=W3.exec(e))?kp(t[1],t[2],t[3],t[4]):(t=V3.exec(e))?kp(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=K3.exec(e))?fN(t[1],t[2]/100,t[3]/100,1):(t=q3.exec(e))?fN(t[1],t[2]/100,t[3]/100,t[4]):oN.hasOwnProperty(e)?cN(oN[e]):e==="transparent"?new Yr(NaN,NaN,NaN,0):null}function cN(e){return new Yr(e>>16&255,e>>8&255,e&255,1)}function kp(e,t,n,r){return r<=0&&(e=t=n=NaN),new Yr(e,t,n,r)}function G3(e){return e instanceof uf||(e=Ya(e)),e?(e=e.rgb(),new Yr(e.r,e.g,e.b,e.opacity)):new Yr}function Rx(e,t,n,r){return arguments.length===1?G3(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}Ek(Yr,Rx,GP(uf,{brighter(e){return e=e==null?qh:Math.pow(qh,e),new Yr(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?$d:Math.pow($d,e),new Yr(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Yr(Fa(this.r),Fa(this.g),Fa(this.b),Uh(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:uN,formatHex:uN,formatHex8:J3,formatRgb:dN,toString:dN}));function uN(){return`#${Ta(this.r)}${Ta(this.g)}${Ta(this.b)}`}function J3(){return`#${Ta(this.r)}${Ta(this.g)}${Ta(this.b)}${Ta((isNaN(this.opacity)?1:this.opacity)*255)}`}function dN(){const e=Uh(this.opacity);return`${e===1?"rgb(":"rgba("}${Fa(this.r)}, ${Fa(this.g)}, ${Fa(this.b)}${e===1?")":`, ${e})`}`}function Uh(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Fa(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ta(e){return e=Fa(e),(e<16?"0":"")+e.toString(16)}function fN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Js(e,t,n,r)}function JP(e){if(e instanceof Js)return new Js(e.h,e.s,e.l,e.opacity);if(e instanceof uf||(e=Ya(e)),!e)return new Js;if(e instanceof Js)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 Js(a,l,c,e.opacity)}function X3(e,t,n,r){return arguments.length===1?JP(e):new Js(e,t,n,r??1)}function Js(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Ek(Js,X3,GP(uf,{brighter(e){return e=e==null?qh:Math.pow(qh,e),new Js(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?$d:Math.pow($d,e),new Js(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(Oy(e>=240?e-240:e+120,s,r),Oy(e,s,r),Oy(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Js(pN(this.h),vp(this.s),vp(this.l),Uh(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=Uh(this.opacity);return`${e===1?"hsl(":"hsla("}${pN(this.h)}, ${vp(this.s)*100}%, ${vp(this.l)*100}%${e===1?")":`, ${e})`}`}}));function pN(e){return e=(e||0)%360,e<0?e+360:e}function vp(e){return Math.max(0,Math.min(1,e||0))}function Oy(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 Ak=e=>()=>e;function Q3(e,t){return function(n){return e+n*t}}function Z3(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 eB(e){return(e=+e)==1?XP:function(t,n){return n-t?Z3(t,n,e):Ak(isNaN(t)?n:t)}}function XP(e,t){var n=t-e;return n?Q3(e,n):Ak(isNaN(e)?t:e)}const Yh=function e(t){var n=eB(t);function r(s,o){var a=n((s=Rx(s)).r,(o=Rx(o)).r),l=n(s.g,o.g),c=n(s.b,o.b),u=XP(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 tB(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 nB(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function rB(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]=ad(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 sB(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 iB(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]=ad(e[s],t[s]):r[s]=t[s];return function(o){for(s in n)r[s]=n[s](o);return r}}var Tx=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Dy=new RegExp(Tx.source,"g");function oB(e){return function(){return e}}function aB(e){return function(t){return e(t)+""}}function QP(e,t){var n=Tx.lastIndex=Dy.lastIndex=0,r,s,o,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=Tx.exec(e))&&(s=Dy.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=Dy.lastIndex;return n<t.length&&(o=t.slice(n),l[a]?l[a]+=o:l[++a]=o),l.length<2?c[0]?aB(c[0].x):oB(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 ad(e,t){var n=typeof t,r;return t==null||n==="boolean"?Ak(t):(n==="number"?gi:n==="string"?(r=Ya(t))?(t=r,Yh):QP:t instanceof Ya?Yh:t instanceof Date?sB:nB(t)?tB:Array.isArray(t)?rB:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?iB:gi)(e,t)}var hN=180/Math.PI,Mx={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ZP(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)*hN,skewX:Math.atan(c)*hN,scaleX:a,scaleY:l}}var Sp;function lB(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Mx:ZP(t.a,t.b,t.c,t.d,t.e,t.f)}function cB(e){return e==null||(Sp||(Sp=document.createElementNS("http://www.w3.org/2000/svg","g")),Sp.setAttribute("transform",e),!(e=Sp.transform.baseVal.consolidate()))?Mx:(e=e.matrix,ZP(e.a,e.b,e.c,e.d,e.e,e.f))}function eI(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,w;++y<v;)f[(w=p[y]).i]=w.x(h);return f.join("")}}}var uB=eI(lB,"px, ","px)","deg)"),dB=eI(cB,", ",")",")"),fB=1e-12;function mN(e){return((e=Math.exp(e))+1/e)/2}function pB(e){return((e=Math.exp(e))-1/e)/2}function hB(e){return((e=Math.exp(2*e))-1)/(e+1)}const lh=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,w,g;if(v<fB)g=Math.log(p/u)/t,w=function(I){return[l+I*h,c+I*y,u*Math.exp(t*I*g)]};else{var k=Math.sqrt(v),b=(p*p-u*u+r*v)/(2*u*n*k),j=(p*p-u*u-r*v)/(2*p*n*k),N=Math.log(Math.sqrt(b*b+1)-b),C=Math.log(Math.sqrt(j*j+1)-j);g=(C-N)/t,w=function(I){var R=I*g,H=mN(N),A=u/(n*k)*(H*hB(t*R+N)-pB(N));return[l+A*h,c+A*y,u*H/mN(t*R+N)]}}return w.duration=g*1e3*t/Math.SQRT2,w}return s.rho=function(o){var a=Math.max(.001,+o),l=a*a,c=l*l;return e(a,l,c)},s}(Math.SQRT2,2,4);var _c=0,Wu=0,Eu=0,tI=1e3,Gh,Vu,Jh=0,Ga=0,Um=0,Od=typeof performance=="object"&&performance.now?performance:Date,nI=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Pk(){return Ga||(nI(mB),Ga=Od.now()+Um)}function mB(){Ga=0}function Xh(){this._call=this._time=this._next=null}Xh.prototype=rI.prototype={constructor:Xh,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Pk():+n)+(t==null?0:+t),!this._next&&Vu!==this&&(Vu?Vu._next=this:Gh=this,Vu=this),this._call=e,this._time=n,$x()},stop:function(){this._call&&(this._call=null,this._time=1/0,$x())}};function rI(e,t,n){var r=new Xh;return r.restart(e,t,n),r}function gB(){Pk(),++_c;for(var e=Gh,t;e;)(t=Ga-e._time)>=0&&e._call.call(void 0,t),e=e._next;--_c}function gN(){Ga=(Jh=Od.now())+Um,_c=Wu=0;try{gB()}finally{_c=0,wB(),Ga=0}}function yB(){var e=Od.now(),t=e-Jh;t>tI&&(Um-=t,Jh=e)}function wB(){for(var e,t=Gh,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:Gh=n);Vu=e,$x(r)}function $x(e){if(!_c){Wu&&(Wu=clearTimeout(Wu));var t=e-Ga;t>24?(e<1/0&&(Wu=setTimeout(gN,e-Od.now()-Um)),Eu&&(Eu=clearInterval(Eu))):(Eu||(Jh=Od.now(),Eu=setInterval(yB,tI)),_c=1,nI(gN))}}function yN(e,t,n){var r=new Xh;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var xB=Km("start","end","cancel","interrupt"),bB=[],sI=0,wN=1,Lx=2,ch=3,xN=4,Ox=5,uh=6;function Ym(e,t,n,r,s,o){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;kB(e,n,{name:t,index:r,group:s,on:xB,tween:bB,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:sI})}function Ik(e,t){var n=ii(e,t);if(n.state>sI)throw new Error("too late; already scheduled");return n}function Ti(e,t){var n=ii(e,t);if(n.state>ch)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 kB(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=rI(o,0,n.time);function o(u){n.state=wN,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!==wN)return c();for(d in r)if(h=r[d],h.name===n.name){if(h.state===ch)return yN(a);h.state===xN?(h.state=uh,h.timer.stop(),h.on.call("interrupt",e,e.__data__,h.index,h.group),delete r[d]):+d<t&&(h.state=uh,h.timer.stop(),h.on.call("cancel",e,e.__data__,h.index,h.group),delete r[d])}if(yN(function(){n.state===ch&&(n.state=xN,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=Lx,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Lx){for(n.state=ch,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=Ox,1),f=-1,p=s.length;++f<p;)s[f].call(e,d);n.state===Ox&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=uh,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function dh(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>Lx&&r.state<Ox,r.state=uh,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}o&&delete e.__transition}}function vB(e){return this.each(function(){dh(this,e)})}function SB(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 jB(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 NB(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?SB:jB)(n,e,t))}function Rk(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 iI(e,t){var n;return(typeof t=="number"?gi:t instanceof Ya?Yh:(n=Ya(t))?(t=n,Yh):QP)(e,t)}function CB(e){return function(){this.removeAttribute(e)}}function _B(e){return function(){this.removeAttributeNS(e.space,e.local)}}function EB(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 AB(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 PB(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 IB(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 RB(e,t){var n=qm(e),r=n==="transform"?dB:iI;return this.attrTween(e,typeof t=="function"?(n.local?IB:PB)(n,r,Rk(this,"attr."+e,t)):t==null?(n.local?_B:CB)(n):(n.local?AB:EB)(n,r,t))}function TB(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function MB(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)&&MB(e,o)),n}return s._value=t,s}function LB(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&TB(e,o)),n}return s._value=t,s}function OB(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=qm(e);return this.tween(n,(r.local?$B:LB)(r,t))}function DB(e,t){return function(){Ik(this,e).delay=+t.apply(this,arguments)}}function FB(e,t){return t=+t,function(){Ik(this,e).delay=t}}function zB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?DB:FB)(t,e)):ii(this.node(),t).delay}function BB(e,t){return function(){Ti(this,e).duration=+t.apply(this,arguments)}}function HB(e,t){return t=+t,function(){Ti(this,e).duration=t}}function WB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?BB:HB)(t,e)):ii(this.node(),t).duration}function VB(e,t){if(typeof t!="function")throw new Error;return function(){Ti(this,e).ease=t}}function KB(e){var t=this._id;return arguments.length?this.each(VB(t,e)):ii(this.node(),t).ease}function qB(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Ti(this,e).ease=n}}function UB(e){if(typeof e!="function")throw new Error;return this.each(qB(this._id,e))}function YB(e){typeof e!="function"&&(e=LP(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 GB(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 JB(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 XB(e,t,n){var r,s,o=JB(t)?Ik:Ti;return function(){var a=o(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function QB(e,t){var n=this._id;return arguments.length<2?ii(this.node(),n).on.on(e):this.each(XB(n,e,t))}function ZB(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function eH(){return this.on("end.remove",ZB(this._id))}function tH(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Ck(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,Ym(u[p],t,n,p,u,ii(d,n)));return new ao(o,this._parents,t,n)}function nH(e){var t=this._name,n=this._id;typeof e!="function"&&(e=$P(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,w=p.length;v<w;++v)(h=p[v])&&Ym(h,t,n,v,p,y);o.push(p),a.push(d)}return new ao(o,a,t,n)}var rH=cf.prototype.constructor;function sH(){return new rH(this._groups,this._parents)}function iH(e,t){var n,r,s;return function(){var o=Cc(this,e),a=(this.style.removeProperty(e),Cc(this,e));return o===a?null:o===n&&a===r?s:s=t(n=o,r=a)}}function oI(e){return function(){this.style.removeProperty(e)}}function oH(e,t,n){var r,s=n+"",o;return function(){var a=Cc(this,e);return a===s?null:a===r?o:o=t(r=a,n)}}function aH(e,t,n){var r,s,o;return function(){var a=Cc(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),Cc(this,e))),a===c?null:a===r&&c===s?o:(s=c,o=t(r=a,l))}}function lH(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=oI(t)):void 0;(u!==n||s!==d)&&(r=(n=u).copy()).on(a,s=d),c.on=r}}function cH(e,t,n){var r=(e+="")=="transform"?uB:iI;return t==null?this.styleTween(e,iH(e,r)).on("end.style."+e,oI(e)):typeof t=="function"?this.styleTween(e,aH(e,r,Rk(this,"style."+e,t))).each(lH(this._id,e)):this.styleTween(e,oH(e,r,t),n).on("end.style."+e,null)}function uH(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function dH(e,t,n){var r,s;function o(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&uH(e,a,n)),r}return o._value=t,o}function fH(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,dH(e,t,n??""))}function pH(e){return function(){this.textContent=e}}function hH(e){return function(){var t=e(this);this.textContent=t??""}}function mH(e){return this.tween("text",typeof e=="function"?hH(Rk(this,"text",e)):pH(e==null?"":e+""))}function gH(e){return function(t){this.textContent=e.call(this,t)}}function yH(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&gH(s)),t}return r._value=e,r}function wH(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,yH(e))}function xH(){for(var e=this._name,t=this._id,n=aI(),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);Ym(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 bH(){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 kH=0;function ao(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function aI(){return++kH}var Hi=cf.prototype;ao.prototype={constructor:ao,select:tH,selectAll:nH,selectChild:Hi.selectChild,selectChildren:Hi.selectChildren,filter:YB,merge:GB,selection:sH,transition:xH,call:Hi.call,nodes:Hi.nodes,node:Hi.node,size:Hi.size,empty:Hi.empty,each:Hi.each,on:QB,attr:RB,attrTween:OB,style:cH,styleTween:fH,text:mH,textTween:wH,remove:eH,tween:NB,delay:zB,duration:WB,ease:KB,easeVarying:UB,end:bH,[Symbol.iterator]:Hi[Symbol.iterator]};function vH(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var SH={time:null,delay:0,duration:250,ease:vH};function jH(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 NH(e){var t,n;e instanceof ao?(t=e._id,e=e._name):(t=aI(),(n=SH).time=Pk(),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])&&Ym(c,e,t,u,a,n||jH(c,t));return new ao(r,this._parents,e,t)}cf.prototype.interrupt=vB;cf.prototype.transition=NH;const jp=e=>()=>e;function CH(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 Gm=new Ji(1,0,0);lI.prototype=Ji.prototype;function lI(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Gm;return e.__zoom}function Fy(e){e.stopImmediatePropagation()}function Au(e){e.preventDefault(),e.stopImmediatePropagation()}function _H(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function EH(){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 bN(){return this.__zoom||Gm}function AH(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function PH(){return navigator.maxTouchPoints||"ontouchstart"in this}function IH(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 cI(){var e=_H,t=EH,n=IH,r=AH,s=PH,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=lh,u=Km("start","zoom","end"),d,f,p,h=500,y=150,v=0,w=10;function g(M){M.property("__zoom",bN).on("wheel.zoom",R,{passive:!1}).on("mousedown.zoom",H).on("dblclick.zoom",A).filter(s).on("touchstart.zoom",L).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",O).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function(M,K,z,F){var $=M.selection?M.selection():M;$.property("__zoom",bN),M!==$?N(M,K,z,F):$.interrupt().each(function(){C(this,arguments).event(F).start().zoom(null,typeof K=="function"?K.apply(this,arguments):K).end()})},g.scaleBy=function(M,K,z,F){g.scaleTo(M,function(){var $=this.__zoom.k,W=typeof K=="function"?K.apply(this,arguments):K;return $*W},z,F)},g.scaleTo=function(M,K,z,F){g.transform(M,function(){var $=t.apply(this,arguments),W=this.__zoom,E=z==null?j($):typeof z=="function"?z.apply(this,arguments):z,Q=W.invert(E),V=typeof K=="function"?K.apply(this,arguments):K;return n(b(k(W,V),E,Q),$,a)},z,F)},g.translateBy=function(M,K,z,F){g.transform(M,function(){return n(this.__zoom.translate(typeof K=="function"?K.apply(this,arguments):K,typeof z=="function"?z.apply(this,arguments):z),t.apply(this,arguments),a)},null,F)},g.translateTo=function(M,K,z,F,$){g.transform(M,function(){var W=t.apply(this,arguments),E=this.__zoom,Q=F==null?j(W):typeof F=="function"?F.apply(this,arguments):F;return n(Gm.translate(Q[0],Q[1]).scale(E.k).translate(typeof K=="function"?-K.apply(this,arguments):-K,typeof z=="function"?-z.apply(this,arguments):-z),W,a)},F,$)};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 b(M,K,z){var F=K[0]-z[0]*M.k,$=K[1]-z[1]*M.k;return F===M.x&&$===M.y?M:new Ji(M.k,F,$)}function j(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function N(M,K,z,F){M.on("start.zoom",function(){C(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){C(this,arguments).event(F).end()}).tween("zoom",function(){var $=this,W=arguments,E=C($,W).event(F),Q=t.apply($,W),V=z==null?j(Q):typeof z=="function"?z.apply($,W):z,B=Math.max(Q[1][0]-Q[0][0],Q[1][1]-Q[0][1]),se=$.__zoom,ue=typeof K=="function"?K.apply($,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,z){return!z&&M.__zooming||new I(M,K)}function I(M,K){this.that=M,this.args=K,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,K),this.taps=0}I.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,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 CH(M,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:u}),K)}};function R(M,...K){if(!e.apply(this,arguments))return;var z=C(this,K).event(M),F=this.__zoom,$=Math.max(o[0],Math.min(o[1],F.k*Math.pow(2,r.apply(this,arguments)))),W=Us(M);if(z.wheel)(z.mouse[0][0]!==W[0]||z.mouse[0][1]!==W[1])&&(z.mouse[1]=F.invert(z.mouse[0]=W)),clearTimeout(z.wheel);else{if(F.k===$)return;z.mouse=[W,F.invert(W)],dh(this),z.start()}Au(M),z.wheel=setTimeout(E,y),z.zoom("mouse",n(b(k(F,$),z.mouse[0],z.mouse[1]),z.extent,a));function E(){z.wheel=null,z.end()}}function H(M,...K){if(p||!e.apply(this,arguments))return;var z=M.currentTarget,F=C(this,K,!0).event(M),$=as(M.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",B,!0),W=Us(M,z),E=M.clientX,Q=M.clientY;qP(M.view),Fy(M),F.mouse=[W,this.__zoom.invert(W)],dh(this),F.start();function V(se){if(Au(se),!F.moved){var ue=se.clientX-E,G=se.clientY-Q;F.moved=ue*ue+G*G>v}F.event(se).zoom("mouse",n(b(F.that.__zoom,F.mouse[0]=Us(se,z),F.mouse[1]),F.extent,a))}function B(se){$.on("mousemove.zoom mouseup.zoom",null),UP(se.view,F.moved),Au(se),F.event(se).end()}}function A(M,...K){if(e.apply(this,arguments)){var z=this.__zoom,F=Us(M.changedTouches?M.changedTouches[0]:M,this),$=z.invert(F),W=z.k*(M.shiftKey?.5:2),E=n(b(k(z,W),F,$),t.apply(this,K),a);Au(M),l>0?as(this).transition().duration(l).call(N,E,F,M):as(this).call(g.transform,E,F,M)}}function L(M,...K){if(e.apply(this,arguments)){var z=M.touches,F=z.length,$=C(this,K,M.changedTouches.length===F).event(M),W,E,Q,V;for(Fy(M),E=0;E<F;++E)Q=z[E],V=Us(Q,this),V=[V,this.__zoom.invert(V),Q.identifier],$.touch0?!$.touch1&&$.touch0[2]!==V[2]&&($.touch1=V,$.taps=0):($.touch0=V,W=!0,$.taps=1+!!d);d&&(d=clearTimeout(d)),W&&($.taps<2&&(f=V[0],d=setTimeout(function(){d=null},h)),dh(this),$.start())}}function D(M,...K){if(this.__zooming){var z=C(this,K).event(M),F=M.changedTouches,$=F.length,W,E,Q,V;for(Au(M),W=0;W<$;++W)E=F[W],Q=Us(E,this),z.touch0&&z.touch0[2]===E.identifier?z.touch0[0]=Q:z.touch1&&z.touch1[2]===E.identifier&&(z.touch1[0]=Q);if(E=z.that.__zoom,z.touch1){var B=z.touch0[0],se=z.touch0[1],ue=z.touch1[0],G=z.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(z.touch0)Q=z.touch0[0],V=z.touch0[1];else return;z.zoom("touch",n(b(E,Q,V),z.extent,a))}}function O(M,...K){if(this.__zooming){var z=C(this,K).event(M),F=M.changedTouches,$=F.length,W,E;for(Fy(M),p&&clearTimeout(p),p=setTimeout(function(){p=null},h),W=0;W<$;++W)E=F[W],z.touch0&&z.touch0[2]===E.identifier?delete z.touch0:z.touch1&&z.touch1[2]===E.identifier&&delete z.touch1;if(z.touch1&&!z.touch0&&(z.touch0=z.touch1,delete z.touch1),z.touch0)z.touch0[1]=this.__zoom.invert(z.touch0[0]);else if(z.end(),z.taps===2&&(E=Us(E,this),Math.hypot(f[0]-E[0],f[1]-E[1])<w)){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:jp(+M),g):r},g.filter=function(M){return arguments.length?(e=typeof M=="function"?M:jp(!!M),g):e},g.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:jp(!!M),g):s},g.extent=function(M){return arguments.length?(t=typeof M=="function"?M:jp([[+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?(w=+M,g):w},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."},Dd=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],uI=["Enter"," ","Escape"],dI={"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 Ec;(function(e){e.Strict="strict",e.Loose="loose"})(Ec||(Ec={}));var za;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(za||(za={}));var Fd;(function(e){e.Partial="partial",e.Full="full"})(Fd||(Fd={}));const fI={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var $o;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})($o||($o={}));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 kN={[qe.Left]:qe.Right,[qe.Right]:qe.Left,[qe.Top]:qe.Bottom,[qe.Bottom]:qe.Top};function pI(e){return e===null?null:e?"valid":"invalid"}const hI=e=>"id"in e&&"source"in e&&"target"in e,RH=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Tk=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),df=(e,t=[0,0])=>{const{width:n,height:r}=po(e),s=e.origin??t,o=n*s[0],a=r*s[1];return{x:e.position.x-o,y:e.position.y-a}},TH=(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):Tk(s)?s:t.nodeLookup.get(s.id));const l=a?Qh(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Jm(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Xm(n)},ff=(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=Jm(n,Qh(s)),r=!0)}),r?Xm(n):{x:0,y:0,width:0,height:0}},Mk=(e,t,[n,r,s]=[0,0,1],o=!1,a=!1)=>{const l={...hf(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=zd(l,Pc(u)),w=(h??0)*(y??0),g=o&&v>0;(!u.internals.handleBounds||g||v>=w||u.dragging)&&c.push(u)}return c},MH=(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 LH({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=ff(l),u=$k(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 mI({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&&Ic(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=Ic(f)?Ja(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 OH({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=MH(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 Ac=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Ja=(e={x:0,y:0},t,n)=>({x:Ac(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Ac(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function gI(e,t,n){const{width:r,height:s}=po(n),{x:o,y:a}=n.internals.positionAbsolute;return Ja(e,[[o,a],[o+r,a+s]],t)}const vN=(e,t,n)=>e<t?Ac(Math.abs(e-t),1,t)/t:e>n?-Ac(Math.abs(e-n),1,t)/t:0,yI=(e,t,n=15,r=40)=>{const s=vN(e.x,r,t.width-r)*n,o=vN(e.y,r,t.height-r)*n;return[s,o]},Jm=(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)}),Dx=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Xm=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Pc=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=Tk(e)?e.internals.positionAbsolute:df(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}},Qh=(e,t=[0,0])=>{var s,o;const{x:n,y:r}=Tk(e)?e.internals.positionAbsolute:df(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)}},wI=(e,t)=>Xm(Jm(Dx(e),Dx(t))),zd=(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)},SN=e=>Xs(e.width)&&Xs(e.height)&&Xs(e.x)&&Xs(e.y),Xs=e=>!isNaN(e)&&isFinite(e),DH=(e,t)=>{},pf=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),hf=({x:e,y:t},[n,r,s],o=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return o?pf(l,a):l},Zh=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function Rl(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 FH(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Rl(e,n),s=Rl(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=Rl(e.top??e.y??0,n),s=Rl(e.bottom??e.y??0,n),o=Rl(e.left??e.x??0,t),a=Rl(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 zH(e,t,n,r,s,o){const{x:a,y:l}=Zh(e,[t,n,r]),{x:c,y:u}=Zh({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 $k=(e,t,n,r,s,o)=>{const a=FH(o,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),d=Ac(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=zH(e,h,y,d,t,n),w={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-w.left+w.right,y:y-w.top+w.bottom,zoom:d}},Bd=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Ic(e){return e!=null&&e!=="parent"}function po(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 xI(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 bI(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 jN(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function BH(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function HH(e){return{...dI,...e||{}}}function ld(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:o,y:a}=Qs(e),l=hf({x:o-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:c,y:u}=n?pf(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const Lk=e=>({width:e.offsetWidth,height:e.offsetHeight}),kI=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},WH=["INPUT","SELECT","TEXTAREA"];function vI(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:WH.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const SI=e=>"clientX"in e,Qs=(e,t)=>{var o,a;const n=SI(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)}},NN=(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,...Lk(a)}})};function jI({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 Np(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function CN({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case qe.Left:return[t-Np(t-r,o),n];case qe.Right:return[t+Np(r-t,o),n];case qe.Top:return[t,n-Np(n-s,o)];case qe.Bottom:return[t,n+Np(s-n,o)]}}function NI({sourceX:e,sourceY:t,sourcePosition:n=qe.Bottom,targetX:r,targetY:s,targetPosition:o=qe.Top,curvature:a=.25}){const[l,c]=CN({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[u,d]=CN({pos:o,x1:r,y1:s,x2:e,y2:t,c:a}),[f,p,h,y]=jI({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 CI({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 VH({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 KH({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const o=Jm(Qh(e),Qh(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 zd(a,Xm(o))>0}const qH=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,UH=(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)),fh=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||qH;let s;return hI(e)?s={...e}:s={...e,id:r(e)},UH(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function _I({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,a,l]=CI({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,a,l]}const _N={[qe.Left]:{x:-1,y:0},[qe.Right]:{x:1,y:0},[qe.Top]:{x:0,y:-1},[qe.Bottom]:{x:0,y:1}},YH=({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},EN=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function GH({source:e,sourcePosition:t=qe.Bottom,target:n,targetPosition:r=qe.Top,center:s,offset:o,stepPosition:a}){const l=_N[t],c=_N[r],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=YH({source:u,sourcePosition:t,target:d}),p=f.x!==0?"x":"y",h=f[p];let y=[],v,w;const g={x:0,y:0},k={x:0,y:0},[,,b,j]=CI({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,w=s.y??(u.y+d.y)/2):(v=s.x??(u.x+d.x)/2,w=s.y??u.y+(d.y-u.y)*a);const R=[{x:v,y:u.y},{x:v,y:d.y}],H=[{x:u.x,y:w},{x:d.x,y:w}];l[p]===h?y=p==="x"?R:H:y=p==="x"?H:R}else{const R=[{x:u.x,y:d.y}],H=[{x:d.x,y:u.y}];if(p==="x"?y=l.x===h?H:R:y=l.y===h?R:H,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],z=u[M]>d[M],F=u[M]<d[M];(l[p]===1&&(!K&&z||K&&F)||l[p]!==1&&(!K&&F||K&&z))&&(y=p==="x"?R:H)}const A={x:u.x+g.x,y:u.y+g.y},L={x:d.x+k.x,y:d.y+k.y},D=Math.max(Math.abs(A.x-y[0].x),Math.abs(L.x-y[0].x)),O=Math.max(Math.abs(A.y-y[0].y),Math.abs(L.y-y[0].y));D>=O?(v=(A.x+L.x)/2,w=y[0].y):(v=y[0].x,w=(A.y+L.y)/2)}const N={x:u.x+g.x,y:u.y+g.y},C={x:d.x+k.x,y:d.y+k.y};return[[e,...N.x!==y[0].x||N.y!==y[0].y?[N]:[],...y,...C.x!==y[y.length-1].x||C.y!==y[y.length-1].y?[C]:[],n],v,w,b,j]}function JH(e,t,n,r){const s=Math.min(EN(e,t)/2,EN(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 Fx({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]=GH({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:l,y:c},offset:u,stepPosition:d});let w=`M${f[0].x} ${f[0].y}`;for(let g=1;g<f.length-1;g++)w+=JH(f[g-1],f[g],f[g+1],a);return w+=`L${f[f.length-1].x} ${f[f.length-1].y}`,[w,p,h,y,v]}function AN(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function XH(e){var f;const{sourceNode:t,targetNode:n}=e;if(!AN(t)||!AN(n))return null;const r=t.internals.handleBounds||PN(t.handles),s=n.internals.handleBounds||PN(n.handles),o=IN((r==null?void 0:r.source)??[],e.sourceHandle),a=IN(e.connectionMode===Ec.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=Xa(t,o,l),d=Xa(n,a,c);return{sourceX:u.x,sourceY:u.y,targetX:d.x,targetY:d.y,sourcePosition:l,targetPosition:c}}function PN(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 Xa(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??po(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 IN(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function zx(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function QH(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=zx(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 EI=1e3,ZH=10,Ok={nodeOrigin:[0,0],nodeExtent:Dd,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},e4={...Ok,checkEquality:!0};function Dk(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function t4(e,t,n){const r=Dk(Ok,n);for(const s of e.values())if(s.parentId)zk(s,e,t,r);else{const o=df(s,r.nodeOrigin),a=Ic(s.extent)?s.extent:r.nodeExtent,l=Ja(o,a,po(s));s.internals.positionAbsolute=l}}function n4(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 Fk(e){return e==="manual"}function Bx(e,t,n,r={}){var d,f;const s=Dk(e4,r),o={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!Fk(s.zIndexMode)?EI: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=df(p,s.nodeOrigin),v=Ic(p.extent)?p.extent:s.nodeExtent,w=Ja(y,v,po(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:w,handleBounds:n4(p,h),z:AI(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&&zk(h,t,n,r,o),u||(u=p.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function r4(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 zk(e,t,n,r,s){const{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=Dk(Ok,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}r4(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*ZH),s&&d.internals.rootParentIndex!==void 0&&(s.i=d.internals.rootParentIndex);const f=o&&!Fk(c)?EI:0,{x:p,y:h,z:y}=s4(e,d,a,l,f,c),{positionAbsolute:v}=e.internals,w=p!==v.x||h!==v.y;(w||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:w?{x:p,y:h}:v,z:y}})}function AI(e,t,n){const r=Xs(e.zIndex)?e.zIndex:0;return Fk(n)?r:r+(e.selected?t:0)}function s4(e,t,n,r,s,o){const{x:a,y:l}=t.internals.positionAbsolute,c=po(e),u=df(e,n),d=Ic(e.extent)?Ja(u,e.extent,c):u;let f=Ja({x:a+d.x,y:l+d.y},r,c);e.extent==="parent"&&(f=gI(f,c,t));const p=AI(e,s,o),h=t.internals.z??0;return{x:f.x,y:f.y,z:h>=p?h+1:p}}function Bk(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)??Pc(c),d=wI(u,l.rect);o.set(l.parentId,{expandedRect:d,parent:c})}return o.size>0&&o.forEach(({expandedRect:l,parent:c},u)=>{var b;const d=c.internals.positionAbsolute,f=po(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)),w=Math.max(f.height,Math.round(l.height)),g=(v-f.width)*p[0],k=(w-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}}),(b=n.get(u))==null||b.forEach(j=>{e.some(N=>N.id===j.id)||s.push({id:j.id,type:"position",position:{x:j.position.x+h,y:j.position.y+y}})})),(f.width<l.width||f.height<l.height||h||y)&&s.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:v+(h?p[0]*h-g:0),height:w+(y?p[1]*y-k:0)}})}),s}function i4(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=Lk(h.nodeElement),w=y.measured.width!==v.width||y.measured.height!==v.height;if(!!(v.width&&v.height&&(w||!y.internals.handleBounds||h.force))){const k=h.nodeElement.getBoundingClientRect(),b=Ic(y.extent)?y.extent:o;let{positionAbsolute:j}=y.internals;y.parentId&&y.extent==="parent"?j=gI(j,v,t.get(y.parentId)):b&&(j=Ja(j,b,v));const N={...y,measured:v,internals:{...y.internals,positionAbsolute:j,handleBounds:{source:NN("source",h.nodeElement,k,f,y.id),target:NN("target",h.nodeElement,k,f,y.id)}}};t.set(y.id,N),y.parentId&&zk(N,t,n,{nodeOrigin:s,zIndexMode:a}),c=!0,w&&(u.push({id:y.id,type:"dimensions",dimensions:v}),y.expandParent&&y.parentId&&p.push({id:y.id,parentId:y.parentId,rect:Pc(N,s)}))}}if(p.length>0){const h=Bk(p,t,n,s);u.push(...h)}return{changes:u,updatedInternals:c}}async function o4({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 RN(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 PI(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}`;RN("source",c,d,e,s,a),RN("target",c,u,e,o,l),t.set(r.id,r)}}function II(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:II(n,t):!1}function TN(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 a4(e,t,n,r){const s=new Map;for(const[o,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!II(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 zy({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 l4({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=pf(o,t);return{x:a.x-o.x,y:a.y-o.y}}function c4({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let o={x:null,y:null},a=0,l=new Map,c=!1,u={x:0,y:0},d=null,f=!1,p=null,h=!1,y=!1,v=null;function w({noDragClassName:k,handleSelector:b,domNode:j,isSelectable:N,nodeId:C,nodeClickDistance:I=0}){p=as(j);function R({x:D,y:O}){const{nodeLookup:M,nodeExtent:K,snapGrid:z,snapToGrid:F,nodeOrigin:$,onNodeDrag:W,onSelectionDrag:E,onError:Q,updateNodePositions:V}=t();o={x:D,y:O};let B=!1;const se=l.size>1,ue=se&&K?Dx(ff(l)):null,G=se&&F?l4({dragItems:l,snapGrid:z,x:D,y:O}):null;for(const[ee,te]of l){if(!M.has(ee))continue;let ne={x:D-te.distance.x,y:O-te.distance.y};F&&(ne=G?{x:Math.round(ne.x+G.x),y:Math.round(ne.y+G.y)}:pf(ne,z));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}=mI({nodeId:ee,nextPosition:ne,nodeLookup:M,nodeExtent:Z||K,nodeOrigin:$,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]=zy({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 H(){if(!d)return;const{transform:D,panBy:O,autoPanSpeed:M,autoPanOnNodeDrag:K}=t();if(!K){c=!1,cancelAnimationFrame(a);return}const[z,F]=yI(u,d,M);(z!==0||F!==0)&&(o.x=(o.x??0)-z/D[2],o.y=(o.y??0)-F/D[2],await O({x:z,y:F})&&R(o)),a=requestAnimationFrame(H)}function A(D){var se;const{nodeLookup:O,multiSelectionActive:M,nodesDraggable:K,transform:z,snapGrid:F,snapToGrid:$,selectNodesOnDrag:W,onNodeDragStart:E,onSelectionDragStart:Q,unselectNodesAndEdges:V}=t();f=!0,(!W||!N)&&!M&&C&&((se=O.get(C))!=null&&se.selected||V()),N&&W&&C&&(e==null||e(C));const B=ld(D.sourceEvent,{transform:z,snapGrid:F,snapToGrid:$,containerBounds:d});if(o=B,l=a4(O,K,B,C),l.size>0&&(n||E||!C&&Q)){const[ue,G]=zy({nodeId:C,dragItems:l,nodeLookup:O});n==null||n(D.sourceEvent,l,ue,G),E==null||E(D.sourceEvent,ue,G),C||Q==null||Q(D.sourceEvent,G)}}const L=YP().clickDistance(I).on("start",D=>{const{domNode:O,nodeDragThreshold:M,transform:K,snapGrid:z,snapToGrid:F}=t();d=(O==null?void 0:O.getBoundingClientRect())||null,h=!1,y=!1,v=D.sourceEvent,M===0&&A(D),o=ld(D.sourceEvent,{transform:K,snapGrid:z,snapToGrid:F,containerBounds:d}),u=Qs(D.sourceEvent,d)}).on("drag",D=>{const{autoPanOnNodeDrag:O,transform:M,snapGrid:K,snapToGrid:z,nodeDragThreshold:F,nodeLookup:$}=t(),W=ld(D.sourceEvent,{transform:M,snapGrid:K,snapToGrid:z,containerBounds:d});if(v=D.sourceEvent,(D.sourceEvent.type==="touchmove"&&D.sourceEvent.touches.length>1||C&&!$.has(C))&&(h=!0),!h){if(!c&&O&&f&&(c=!0,H()),!f){const E=Qs(D.sourceEvent,d),Q=E.x-u.x,V=E.y-u.y;Math.sqrt(Q*Q+V*V)>F&&A(D)}(o.x!==W.xSnapped||o.y!==W.ySnapped)&&l&&f&&(u=Qs(D.sourceEvent,d),R(W))}}).on("end",D=>{if(!(!f||h)&&(c=!1,f=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:O,updateNodePositions:M,onNodeDragStop:K,onSelectionDragStop:z}=t();if(y&&(M(l,!1),y=!1),s||K||!C&&z){const[F,$]=zy({nodeId:C,dragItems:l,nodeLookup:O,dragging:!1});s==null||s(D.sourceEvent,l,F,$),K==null||K(D.sourceEvent,F,$),C||z==null||z(D.sourceEvent,$)}}}).filter(D=>{const O=D.target;return!D.button&&(!k||!TN(O,`.${k}`,j))&&(!b||TN(O,b,j))});p.call(L)}function g(){p==null||p.on(".drag",null)}return{update:w,destroy:g}}function u4(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())zd(s,Pc(o))>0&&r.push(o);return r}const d4=250;function f4(e,t,n,r){var l,c;let s=[],o=1/0;const a=u4(e,n,t+d4);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}=Xa(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 RI(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,...Xa(a,c,c.position,!0)}:c}function TI(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function p4(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const MI=()=>!0;function h4(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:w,isValidConnection:g=MI,onReconnectEnd:k,updateConnection:b,getTransform:j,getFromHandle:N,autoPanSpeed:C,dragThreshold:I=1,handleDomNode:R}){const H=kI(e.target);let A=0,L;const{x:D,y:O}=Qs(e),M=TI(o,R),K=l==null?void 0:l.getBoundingClientRect();let z=!1;if(!K||!M)return;const F=RI(s,M,r,c,t);if(!F)return;let $=Qs(e,K),W=!1,E=null,Q=!1,V=null;function B(){if(!d||!K)return;const[ce,de]=yI($,K,C);p({x:ce,y:de}),A=requestAnimationFrame(B)}const se={...F,nodeId:s,type:M,position:F.position},ue=c.get(s);let ee={inProgress:!0,isValid:null,from:Xa(ue,se,qe.Left,!0),fromHandle:se,fromPosition:se.position,fromNode:ue,to:$,toHandle:null,toPosition:kN[se.position],toNode:null,pointer:$};function te(){z=!0,b(ee),y==null||y(e,{nodeId:s,handleId:r,handleType:M})}I===0&&te();function ne(ce){if(!z){const{x:Be,y:ot}=Qs(ce),gt=Be-D,Te=ot-O;if(!(gt*gt+Te*Te>I*I))return;te()}if(!N()||!se){Z(ce);return}const de=j();$=Qs(ce,K),L=f4(hf($,de,!1,[1,1]),n,c,se),W||(B(),W=!0);const me=$I(ce,{handle:L,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:g,doc:H,lib:u,flowId:f,nodeLookup:c});V=me.handleDomNode,E=me.connection,Q=p4(!!L,me.isValid);const $e=c.get(s),Ce=$e?Xa($e,se,qe.Left,!0):ee.from,_e={...ee,from:Ce,isValid:Q,to:me.toHandle&&Q?Zh({x:me.toHandle.x,y:me.toHandle.y},de):$,toHandle:me.toHandle,toPosition:Q&&me.toHandle?me.toHandle.position:kN[se.position],toNode:me.toHandle?c.get(me.toHandle.nodeId):null,pointer:$};b(_e),ee=_e}function Z(ce){if(!("touches"in ce&&ce.touches.length>0)){if(z){(L||V)&&E&&Q&&(v==null||v(E));const{inProgress:de,...me}=ee,$e={...me,toPosition:ee.toHandle?ee.toPosition:null};w==null||w(ce,$e),o&&(k==null||k(ce,$e))}h(),cancelAnimationFrame(A),W=!1,Q=!1,E=null,V=null,H.removeEventListener("mousemove",ne),H.removeEventListener("mouseup",Z),H.removeEventListener("touchmove",ne),H.removeEventListener("touchend",Z)}}H.addEventListener("mousemove",ne),H.addEventListener("mouseup",Z),H.addEventListener("touchmove",ne),H.addEventListener("touchend",Z)}function $I(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:o,doc:a,lib:l,flowId:c,isValidConnection:u=MI,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}=Qs(e),v=a.elementFromPoint(h,y),w=v!=null&&v.classList.contains(`${l}-flow__handle`)?v:p,g={handleDomNode:w,isValid:!1,connection:null,toHandle:null};if(w){const k=TI(void 0,w),b=w.getAttribute("data-nodeid"),j=w.getAttribute("data-handleid"),N=w.classList.contains("connectable"),C=w.classList.contains("connectableend");if(!b||!k)return g;const I={source:f?b:r,sourceHandle:f?j:s,target:f?r:b,targetHandle:f?s:j};g.connection=I;const H=N&&C&&(n===Ec.Strict?f&&k==="source"||!f&&k==="target":b!==r||j!==s);g.isValid=H&&u(I),g.toHandle=RI(b,k,j,d,n,!0)}return g}const Hx={onPointerDown:h4,isValid:$I};function m4({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=b=>{if(b.sourceEvent.type!=="wheel"||!t)return;const j=n(),N=b.sourceEvent.ctrlKey&&Bd()?10:1,C=-b.sourceEvent.deltaY*(b.sourceEvent.deltaMode===1?.05:b.sourceEvent.deltaMode?1:.002)*d,I=j[2]*Math.pow(2,C*N);t.scaleTo(I)};let v=[0,0];const w=b=>{(b.sourceEvent.type==="mousedown"||b.sourceEvent.type==="touchstart")&&(v=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY])},g=b=>{const j=n();if(b.sourceEvent.type!=="mousemove"&&b.sourceEvent.type!=="touchmove"||!t)return;const N=[b.sourceEvent.clientX??b.sourceEvent.touches[0].clientX,b.sourceEvent.clientY??b.sourceEvent.touches[0].clientY],C=[N[0]-v[0],N[1]-v[1]];v=N;const I=r()*Math.max(j[2],Math.log(j[2]))*(h?-1:1),R={x:j[0]-C[0]*I,y:j[1]-C[1]*I},H=[[0,0],[c,u]];t.setViewportConstrained({x:R.x,y:R.y,zoom:j[2]},H,l)},k=cI().on("start",w).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:Us}}const Qm=e=>({x:e.x,y:e.y,zoom:e.k}),By=({x:e,y:t,zoom:n})=>Gm.translate(e,t).scale(n),ec=(e,t)=>e.target.closest(`.${t}`),LI=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),g4=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,Hy=(e,t=0,n=g4,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},OI=e=>{const t=e.ctrlKey&&Bd()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function y4({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:o,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return d=>{if(ec(d,t))return d.ctrlKey&&d.preventDefault(),!1;d.preventDefault(),d.stopImmediatePropagation();const f=n.property("__zoom").k||1;if(d.ctrlKey&&a){const w=Us(d),g=OI(d),k=f*Math.pow(2,g);r.scaleTo(n,k,w,d);return}const p=d.deltaMode===1?20:1;let h=s===za.Vertical?0:d.deltaX*p,y=s===za.Horizontal?0:d.deltaY*p;!Bd()&&d.shiftKey&&s!==za.Vertical&&(h=d.deltaY*p,y=0),r.translateBy(n,-(h/f)*o,-(y/f)*o,{internal:!0});const v=Qm(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 w4({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const o=r.type==="wheel",a=!t&&o&&!r.ctrlKey,l=ec(r,e);if(r.ctrlKey&&o&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function x4({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,a,l;if((o=r.sourceEvent)!=null&&o.internal)return;const s=Qm(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 b4({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return o=>{var a,l;e.usedRightMouseButton=!!(n&&LI(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,Qm(o.transform)))}}function k4({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&&LI(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&o(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const c=Qm(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,c)},n?150:0)}}}function v4({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 w;const p=e||t,h=n&&f.ctrlKey,y=f.type==="wheel";if(f.button===1&&f.type==="mousedown"&&(ec(f,`${u}-flow__node`)||ec(f,`${u}-flow__edge`)))return!0;if(!r&&!p&&!s&&!o&&!n||a||d&&!y||ec(f,l)&&y||ec(f,c)&&(!y||s&&y&&!e)||!n&&f.ctrlKey&&y)return!1;if(!n&&f.type==="touchstart"&&((w=f.touches)==null?void 0:w.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 S4({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=cI().scaleExtent([t,n]).translateExtent(r),p=as(e).call(f);k({x:s.x,y:s.y,zoom:Ac(s.zoom,t,n)},[[0,0],[d.width,d.height]],r);const h=p.on("wheel.zoom"),y=p.on("dblclick.zoom");f.wheelDelta(OI);function v(L,D){return p?new Promise(O=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?ad:lh).transform(Hy(p,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>O(!0)),L)}):Promise.resolve(!1)}function w({noWheelClassName:L,noPanClassName:D,onPaneContextMenu:O,userSelectionActive:M,panOnScroll:K,panOnDrag:z,panOnScrollMode:F,panOnScrollSpeed:$,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:!Xs(ee)||ee<0?0:ee);const Z=ne?y4({zoomPanValues:u,noWheelClassName:L,d3Selection:p,d3Zoom:f,panOnScrollMode:F,panOnScrollSpeed:$,zoomOnPinch:E,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:l}):w4({noWheelClassName:L,preventScrolling:W,d3ZoomHandler:h});if(p.on("wheel.zoom",Z,{passive:!1}),!M){const de=x4({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});f.on("start",de);const me=b4({zoomPanValues:u,panOnDrag:z,onPaneContextMenu:!!O,onPanZoom:o,onTransformChange:ue});f.on("zoom",me);const $e=k4({zoomPanValues:u,panOnDrag:z,panOnScroll:K,onPaneContextMenu:O,onPanZoomEnd:l,onDraggingChange:c});f.on("end",$e)}const ce=v4({zoomActivationKeyPressed:B,panOnDrag:z,zoomOnScroll:Q,panOnScroll:K,zoomOnDoubleClick:V,zoomOnPinch:E,userSelectionActive:M,noPanClassName:D,noWheelClassName:L,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(L,D,O){const M=By(L),K=f==null?void 0:f.constrain()(M,D,O);return K&&await v(K),new Promise(z=>z(K))}async function b(L,D){const O=By(L);return await v(O,D),new Promise(M=>M(O))}function j(L){if(p){const D=By(L),O=p.property("__zoom");(O.k!==L.zoom||O.x!==L.x||O.y!==L.y)&&(f==null||f.transform(p,D,null,{sync:!0}))}}function N(){const L=p?lI(p.node()):{x:0,y:0,k:1};return{x:L.x,y:L.y,zoom:L.k}}function C(L,D){return p?new Promise(O=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?ad:lh).scaleTo(Hy(p,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>O(!0)),L)}):Promise.resolve(!1)}function I(L,D){return p?new Promise(O=>{f==null||f.interpolate((D==null?void 0:D.interpolate)==="linear"?ad:lh).scaleBy(Hy(p,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>O(!0)),L)}):Promise.resolve(!1)}function R(L){f==null||f.scaleExtent(L)}function H(L){f==null||f.translateExtent(L)}function A(L){const D=!Xs(L)||L<0?0:L;f==null||f.clickDistance(D)}return{update:w,destroy:g,setViewport:b,setViewportConstrained:k,getViewport:N,scaleTo:C,scaleBy:I,setScaleExtent:R,setTranslateExtent:H,syncViewport:j,setClickDistance:A}}var Rc;(function(e){e.Line="line",e.Handle="handle"})(Rc||(Rc={}));function j4({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 MN(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),s=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:s}}function _o(e,t){return Math.max(0,t-e)}function Eo(e,t){return Math.max(0,e-t)}function Cp(e,t,n){return Math.max(0,t-e,e-n)}function $N(e,t){return e?!t:t}function N4(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:w,minHeight:g,maxHeight:k}=r,{x:b,y:j,width:N,height:C,aspectRatio:I}=e;let R=Math.floor(d?h-e.pointerX:0),H=Math.floor(f?y-e.pointerY:0);const A=N+(c?-R:R),L=C+(u?-H:H),D=-o[0]*N,O=-o[1]*C;let M=Cp(A,v,w),K=Cp(L,g,k);if(a){let $=0,W=0;c&&R<0?$=_o(b+R+D,a[0][0]):!c&&R>0&&($=Eo(b+A+D,a[1][0])),u&&H<0?W=_o(j+H+O,a[0][1]):!u&&H>0&&(W=Eo(j+L+O,a[1][1])),M=Math.max(M,$),K=Math.max(K,W)}if(l){let $=0,W=0;c&&R>0?$=Eo(b+R,l[0][0]):!c&&R<0&&($=_o(b+A,l[1][0])),u&&H>0?W=Eo(j+H,l[0][1]):!u&&H<0&&(W=_o(j+L,l[1][1])),M=Math.max(M,$),K=Math.max(K,W)}if(s){if(d){const $=Cp(A/I,g,k)*I;if(M=Math.max(M,$),a){let W=0;!c&&!u||c&&!u&&p?W=Eo(j+O+A/I,a[1][1])*I:W=_o(j+O+(c?R:-R)/I,a[0][1])*I,M=Math.max(M,W)}if(l){let W=0;!c&&!u||c&&!u&&p?W=_o(j+A/I,l[1][1])*I:W=Eo(j+(c?R:-R)/I,l[0][1])*I,M=Math.max(M,W)}}if(f){const $=Cp(L*I,v,w)/I;if(K=Math.max(K,$),a){let W=0;!c&&!u||u&&!c&&p?W=Eo(b+L*I+D,a[1][0])/I:W=_o(b+(u?H:-H)*I+D,a[0][0])/I,K=Math.max(K,W)}if(l){let W=0;!c&&!u||u&&!c&&p?W=_o(b+L*I,l[1][0])/I:W=Eo(b+(u?H:-H)*I,l[0][0])/I,K=Math.max(K,W)}}}H=H+(H<0?K:-K),R=R+(R<0?M:-M),s&&(p?A>L*I?H=($N(c,u)?-R:R)/I:R=($N(c,u)?-H:H)*I:d?(H=R/I,u=c):(R=H*I,c=u));const z=c?b+R:b,F=u?j+H:j;return{width:N+(c?-R:R),height:C+(u?-H:H),x:o[0]*R*(c?-1:1)+z,y:o[1]*H*(u?-1:1)+F}}const DI={width:0,height:0,x:0,y:0},C4={...DI,pointerX:0,pointerY:0,aspectRatio:1};function _4(e){return[[0,0],[e.measured.width,e.measured.height]]}function E4(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 A4({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const o=as(e);let a={controlDirection:MN("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:w}){let g={...DI},k={...C4};a={boundaries:d,resizeDirection:p,keepAspectRatio:f,controlDirection:MN(u)};let b,j=null,N=[],C,I,R,H=!1;const A=YP().on("start",L=>{const{nodeLookup:D,transform:O,snapGrid:M,snapToGrid:K,nodeOrigin:z,paneDomNode:F}=n();if(b=D.get(t),!b)return;j=(F==null?void 0:F.getBoundingClientRect())??null;const{xSnapped:$,ySnapped:W}=ld(L.sourceEvent,{transform:O,snapGrid:M,snapToGrid:K,containerBounds:j});g={width:b.measured.width??0,height:b.measured.height??0,x:b.position.x??0,y:b.position.y??0},k={...g,pointerX:$,pointerY:W,aspectRatio:g.width/g.height},C=void 0,b.parentId&&(b.extent==="parent"||b.expandParent)&&(C=D.get(b.parentId),I=C&&b.extent==="parent"?_4(C):void 0),N=[],R=void 0;for(const[E,Q]of D)if(Q.parentId===t&&(N.push({id:E,position:{...Q.position},extent:Q.extent}),Q.extent==="parent"||Q.expandParent)){const V=E4(Q,b,Q.origin??z);R?R=[[Math.min(V[0][0],R[0][0]),Math.min(V[0][1],R[0][1])],[Math.max(V[1][0],R[1][0]),Math.max(V[1][1],R[1][1])]]:R=V}h==null||h(L,{...g})}).on("drag",L=>{const{transform:D,snapGrid:O,snapToGrid:M,nodeOrigin:K}=n(),z=ld(L.sourceEvent,{transform:D,snapGrid:O,snapToGrid:M,containerBounds:j}),F=[];if(!b)return;const{x:$,y:W,width:E,height:Q}=g,V={},B=b.origin??K,{width:se,height:ue,x:G,y:ee}=N4(k,a.controlDirection,z,a.boundaries,a.keepAspectRatio,B,I,R),te=se!==E,ne=ue!==Q,Z=G!==$&&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,N.length>0)){const Ce=G-$,_e=ee-W;for(const Be of N)Be.position={x:Be.position.x-Ce+B[0]*(se-E),y:Be.position.y-_e+B[1]*(ue-Q)},F.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&&b.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=j4({width:g.width,prevWidth:E,height:g.height,prevHeight:Q,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),me={...g,direction:de};(w==null?void 0:w(L,me))!==!1&&(H=!0,y==null||y(L,me),r(V,F))}).on("end",L=>{H&&(v==null||v(L,{...g}),s==null||s({...g}),H=!1)});o.call(A)}function c(){o.on(".drag",null)}return{update:l,destroy:c}}var FI={exports:{}},zI={},BI={exports:{}},HI={};/**
|
|
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 Tc=m;function P4(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var I4=typeof Object.is=="function"?Object.is:P4,R4=Tc.useState,T4=Tc.useEffect,M4=Tc.useLayoutEffect,$4=Tc.useDebugValue;function L4(e,t){var n=t(),r=R4({inst:{value:n,getSnapshot:t}}),s=r[0].inst,o=r[1];return M4(function(){s.value=n,s.getSnapshot=t,Wy(s)&&o({inst:s})},[e,n,t]),T4(function(){return Wy(s)&&o({inst:s}),e(function(){Wy(s)&&o({inst:s})})},[e]),$4(n),n}function Wy(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!I4(e,n)}catch{return!0}}function O4(e,t){return t()}var D4=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?O4:L4;HI.useSyncExternalStore=Tc.useSyncExternalStore!==void 0?Tc.useSyncExternalStore:D4;BI.exports=HI;var WI=BI.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 Zm=m,F4=WI;function z4(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var B4=typeof Object.is=="function"?Object.is:z4,H4=F4.useSyncExternalStore,W4=Zm.useRef,V4=Zm.useEffect,K4=Zm.useMemo,q4=Zm.useDebugValue;zI.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var o=W4(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=K4(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,B4(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=H4(e,o[0],o[1]);return V4(function(){a.hasValue=!0,a.value=l},[l]),q4(l),l};FI.exports=zI;var U4=FI.exports;const Y4=ia(U4),G4={},LN=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:()=>{(G4?"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},J4=e=>e?LN(e):LN,{useDebugValue:X4}=dt,{useSyncExternalStoreWithSelector:Q4}=Y4,Z4=e=>e;function VI(e,t=Z4,n){const r=Q4(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return X4(r),r}const ON=(e,t)=>{const n=J4(e),r=(s,o=t)=>VI(n,s,o);return Object.assign(r,n),r},eW=(e,t)=>e?ON(e,t):ON;function En(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 eg=m.createContext(null),tW=eg.Provider,KI=Ii.error001();function Wt(e,t){const n=m.useContext(eg);if(n===null)throw new Error(KI);return VI(n,e,t)}function wn(){const e=m.useContext(eg);if(e===null)throw new Error(KI);return m.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const DN={display:"none"},nW={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},qI="react-flow__node-desc",UI="react-flow__edge-desc",rW="react-flow__aria-live",sW=e=>e.ariaLiveMessage,iW=e=>e.ariaLabelConfig;function oW({rfId:e}){const t=Wt(sW);return i.jsx("div",{id:`${rW}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:nW,children:t})}function aW({rfId:e,disableKeyboardA11y:t}){const n=Wt(iW);return i.jsxs(i.Fragment,{children:[i.jsx("div",{id:`${qI}-${e}`,style:DN,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),i.jsx("div",{id:`${UI}-${e}`,style:DN,children:n["edge.a11yDescription.default"]}),!t&&i.jsx(oW,{rfId:e})]})}const tg=m.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},o)=>{const a=`${e}`.split("-");return i.jsx("div",{className:Xn(["react-flow__panel",n,...a]),style:r,ref:o,...s,children:t})});tg.displayName="Panel";function lW({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:i.jsx(tg,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://pro.reactflow.dev",children:i.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const cW=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},_p=e=>e.id;function uW(e,t){return En(e.selectedNodes.map(_p),t.selectedNodes.map(_p))&&En(e.selectedEdges.map(_p),t.selectedEdges.map(_p))}function dW({onSelectionChange:e}){const t=wn(),{selectedNodes:n,selectedEdges:r}=Wt(cW,uW);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 fW=e=>!!e.onSelectionChangeHandlers;function pW({onSelectionChange:e}){const t=Wt(fW);return e||t?i.jsx(dW,{onSelectionChange:e}):null}const Wx=typeof window<"u"?m.useLayoutEffect:m.useEffect,YI=[0,0],hW={x:0,y:0,zoom:1},mW=["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"],FN=[...mW,"rfId"],gW=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges}),zN={translateExtent:Dd,nodeOrigin:YI,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function yW(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:o,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Wt(gW,En),u=wn();Wx(()=>(c(e.defaultNodes,e.defaultEdges),()=>{d.current=zN,l()}),[]);const d=m.useRef(zN);return Wx(()=>{for(const f of FN){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:HH(p)}):f==="fitView"?u.setState({fitViewQueued:p}):f==="fitViewOptions"?u.setState({fitViewOptions:p}):u.setState({[f]:p})))}d.current=e},FN.map(f=>e[f])),null}function BN(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function wW(e){var r;const[t,n]=m.useState(e==="system"?null:e);return m.useEffect(()=>{if(e!=="system"){n(e);return}const s=BN(),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=BN())!=null&&r.matches?"dark":"light"}const HN=typeof document<"u"?document:null;function Hd(e=null,t={target:HN,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)??HN,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const d=h=>{var w,g;if(s.current=h.ctrlKey||h.metaKey||h.shiftKey||h.altKey,(!s.current||s.current&&!u)&&vI(h))return!1;const v=VN(h.code,l);if(o.current.add(h[v]),WN(a,o.current,!1)){const k=((g=(w=h.composedPath)==null?void 0:w.call(h))==null?void 0:g[0])||h.target,b=(k==null?void 0:k.nodeName)==="BUTTON"||(k==null?void 0:k.nodeName)==="A";t.preventDefault!==!1&&(s.current||!b)&&h.preventDefault(),r(!0)}},f=h=>{const y=VN(h.code,l);WN(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 WN(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function VN(e,t){return t.includes(e)?"code":"key"}const xW=()=>{const e=wn();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=$k(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 hf(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=Zh(t,n);return{x:a.x+s,y:a.y+o}}}),[])};function GI(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)bW(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 bW(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 cd(e,t){return GI(e,t)}function em(e,t){return GI(e,t)}function Na(e,t){return{id:e,type:"select",selected:t}}function tc(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 KN({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 qN(e){return{id:e.id,type:"remove"}}const UN=e=>RH(e),kW=e=>hI(e);function JI(e){return m.forwardRef(e)}function YN(e){const[t,n]=m.useState(BigInt(0)),[r]=m.useState(()=>vW(()=>n(s=>s+BigInt(1))));return Wx(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function vW(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const XI=m.createContext(null);function SW({children:e}){const t=wn(),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 w=KN({items:v,lookup:p});for(const g of y.values())w=g(w);d&&u(v),w.length>0?f==null||f(w):h&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:k,setNodes:b}=t.getState();g&&b(k)})},[]),r=YN(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(KN({items:h,lookup:p}))},[]),o=YN(s),a=m.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return i.jsx(XI.Provider,{value:a,children:e})}function jW(){const e=m.useContext(XI);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const NW=e=>!!e.panZoom;function Bc(){const e=xW(),t=wn(),n=jW(),r=Wt(NW),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=UN(f)?f:p.get(f.id),v=y.parentId?bI(y.position,y.measured,y.parentId,p,h):y.position,w={...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 Pc(w)},u=(f,p,h={replace:!1})=>{a(y=>y.map(v=>{if(v.id===f){const w=typeof p=="function"?p(v):p;return h.replace&&UN(w)?w:{...v,...w}}return v}))},d=(f,p,h={replace:!1})=>{l(y=>y.map(v=>{if(v.id===f){const w=typeof p=="function"?p(v):p;return h.replace&&kW(w)?w:{...v,...w}}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,w]=h;return{nodes:f.map(g=>({...g})),edges:p.map(g=>({...g})),viewport:{x:y,y:v,zoom:w}}},deleteElements:async({nodes:f=[],edges:p=[]})=>{const{nodes:h,edges:y,onNodesDelete:v,onEdgesDelete:w,triggerNodeChanges:g,triggerEdgeChanges:k,onDelete:b,onBeforeDelete:j}=t.getState(),{nodes:N,edges:C}=await OH({nodesToRemove:f,edgesToRemove:p,nodes:h,edges:y,onBeforeDelete:j}),I=C.length>0,R=N.length>0;if(I){const H=C.map(qN);w==null||w(C),k(H)}if(R){const H=N.map(qN);v==null||v(N),g(H)}return(R||I)&&(b==null||b({nodes:N,edges:C})),{deletedNodes:N,deletedEdges:C}},getIntersectingNodes:(f,p=!0,h)=>{const y=SN(f),v=y?f:c(f),w=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 b=Pc(w?g:k),j=zd(b,v);return p&&j>0||j>=b.width*b.height||j>=v.width*v.height}):[]},isNodeIntersecting:(f,p,h=!0)=>{const v=SN(f)?f:c(f);if(!v)return!1;const w=zd(v,p);return h&&w>0||w>=p.width*p.height||w>=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 TH(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??BH();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 GN=e=>e.selected,CW=typeof window<"u"?window:void 0;function _W({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=wn(),{deleteElements:r}=Bc(),s=Hd(e,{actInsideInputWithModifier:!1}),o=Hd(t,{target:CW});m.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(GN),edges:a.filter(GN)}),n.setState({nodesSelectionActive:!1})}},[s]),m.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function EW(e){const t=wn();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=Lk(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 ng={position:"absolute",width:"100%",height:"100%",top:0,left:0},AW=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function PW({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:o=za.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:w,onViewportChange:g,isControlledViewport:k,paneClickDistance:b,selectionOnDrag:j}){const N=wn(),C=m.useRef(null),{userSelectionActive:I,lib:R,connectionInProgress:H}=Wt(AW,En),A=Hd(p),L=m.useRef();EW(C);const D=m.useCallback(O=>{g==null||g({x:O[0],y:O[1],zoom:O[2]}),k||N.setState({transform:O})},[g,k]);return m.useEffect(()=>{if(C.current){L.current=S4({domNode:C.current,minZoom:d,maxZoom:f,translateExtent:u,viewport:c,onDraggingChange:z=>N.setState(F=>F.paneDragging===z?F:{paneDragging:z}),onPanZoomStart:(z,F)=>{const{onViewportChangeStart:$,onMoveStart:W}=N.getState();W==null||W(z,F),$==null||$(F)},onPanZoom:(z,F)=>{const{onViewportChange:$,onMove:W}=N.getState();W==null||W(z,F),$==null||$(F)},onPanZoomEnd:(z,F)=>{const{onViewportChangeEnd:$,onMoveEnd:W}=N.getState();W==null||W(z,F),$==null||$(F)}});const{x:O,y:M,zoom:K}=L.current.getViewport();return N.setState({panZoom:L.current,transform:[O,M,K],domNode:C.current.closest(".react-flow")}),()=>{var z;(z=L.current)==null||z.destroy()}}},[]),m.useEffect(()=>{var O;(O=L.current)==null||O.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:o,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:A,preventScrolling:h,noPanClassName:w,userSelectionActive:I,noWheelClassName:v,lib:R,onTransformChange:D,connectionInProgress:H,selectionOnDrag:j,paneClickDistance:b})},[e,t,n,r,s,o,a,l,A,h,w,I,v,R,D,H,j,b]),i.jsx("div",{className:"react-flow__renderer",ref:C,style:ng,children:y})}const IW=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function RW(){const{userSelectionActive:e,userSelectionRect:t}=Wt(IW,En);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 Vy=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},TW=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function MW({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Fd.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=wn(),{userSelectionActive:w,elementsSelectable:g,dragging:k,connectionInProgress:b}=Wt(TW,En),j=g&&(e||w),N=m.useRef(null),C=m.useRef(),I=m.useRef(new Set),R=m.useRef(new Set),H=m.useRef(!1),A=$=>{if(H.current||b){H.current=!1;return}c==null||c($),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},L=$=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){$.preventDefault();return}u==null||u($)},D=d?$=>d($):void 0,O=$=>{H.current&&($.stopPropagation(),H.current=!1)},M=$=>{var ue,G;const{domNode:W}=v.getState();if(C.current=W==null?void 0:W.getBoundingClientRect(),!C.current)return;const E=$.target===N.current;if(!E&&!!$.target.closest(".nokey")||!e||!(o&&E||t)||$.button!==0||!$.isPrimary)return;(G=(ue=$.target)==null?void 0:ue.setPointerCapture)==null||G.call(ue,$.pointerId),H.current=!1;const{x:B,y:se}=Qs($.nativeEvent,C.current);v.setState({userSelectionRect:{width:0,height:0,startX:B,startY:se,x:B,y:se}}),E||($.stopPropagation(),$.preventDefault())},K=$=>{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}=Qs($.nativeEvent,C.current),{startX:Z,startY:ce}=W;if(!H.current){const _e=t?0:s;if(Math.hypot(te-Z,ne-ce)<=_e)return;ee(),a==null||a($)}H.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=I.current,$e=R.current;I.current=new Set(Mk(Q,de,E,n===Fd.Partial,!0).map(_e=>_e.id)),R.current=new Set;const Ce=(G==null?void 0:G.selectable)??!0;for(const _e of I.current){const Be=B.get(_e);if(Be)for(const{edgeId:ot}of Be.values()){const gt=V.get(ot);gt&&(gt.selectable??Ce)&&R.current.add(ot)}}if(!jN(me,I.current)){const _e=tc(Q,I.current,!0);se(_e)}if(!jN($e,R.current)){const _e=tc(V,R.current);ue(_e)}v.setState({userSelectionRect:de,userSelectionActive:!0,nodesSelectionActive:!1})},z=$=>{var W,E;$.button===0&&((E=(W=$.target)==null?void 0:W.releasePointerCapture)==null||E.call(W,$.pointerId),!w&&$.target===N.current&&v.getState().userSelectionRect&&(A==null||A($)),v.setState({userSelectionActive:!1,userSelectionRect:null}),H.current&&(l==null||l($),v.setState({nodesSelectionActive:I.current.size>0})))},F=r===!0||Array.isArray(r)&&r.includes(0);return i.jsxs("div",{className:Xn(["react-flow__pane",{draggable:F,dragging:k,selection:e}]),onClick:j?void 0:Vy(A,N),onContextMenu:Vy(L,N),onWheel:Vy(D,N),onPointerEnter:j?void 0:f,onPointerMove:j?K:p,onPointerUp:j?z:void 0,onPointerDownCapture:j?M:void 0,onClickCapture:j?O:void 0,onPointerLeave:h,ref:N,style:ng,children:[y,i.jsx(RW,{})]})}function Vx({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 QI({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,nodeClickDistance:a}){const l=wn(),[c,u]=m.useState(!1),d=m.useRef();return m.useEffect(()=>{d.current=c4({getStoreItems:()=>l.getState(),onNodeMouseDown:f=>{Vx({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 $W=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function ZI(){const e=wn();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=$W(a),h=s?o[0]:5,y=s?o[1]:5,v=n.direction.x*h*n.factor,w=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+w};s&&(k=pf(k,o));const{position:b,positionAbsolute:j}=mI({nodeId:g.id,nextPosition:k,nodeLookup:u,nodeExtent:r,nodeOrigin:d,onError:l});g.position=b,g.internals.positionAbsolute=j,f.set(g.id,g)}c(f)},[])}const Hk=m.createContext(null),LW=Hk.Provider;Hk.Consumer;const eR=()=>m.useContext(Hk),OW=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),DW=(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===Ec.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 FW({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,z;const y=a||null,v=e==="target",w=wn(),g=eR(),{connectOnClick:k,noPanClassName:b,rfId:j}=Wt(OW,En),{connectingFrom:N,connectingTo:C,clickConnecting:I,isPossibleEndHandle:R,connectionInProcess:H,clickConnectionInProcess:A,valid:L}=Wt(DW(g,y,e),En);g||(z=(K=w.getState()).onError)==null||z.call(K,"010",Ii.error010());const D=F=>{const{defaultEdgeOptions:$,onConnect:W,hasDefaultEdges:E}=w.getState(),Q={...$,...F};if(E){const{edges:V,setEdges:B}=w.getState();B(fh(Q,V))}W==null||W(Q),l==null||l(Q)},O=F=>{if(!g)return;const $=SI(F.nativeEvent);if(s&&($&&F.button===0||!$)){const W=w.getState();Hx.onPointerDown(F.nativeEvent,{handleDomNode:F.currentTarget,autoPanOnConnect:W.autoPanOnConnect,connectionMode:W.connectionMode,connectionRadius:W.connectionRadius,domNode:W.domNode,nodeLookup:W.nodeLookup,lib:W.lib,isTarget:v,handleId:y,nodeId:g,flowId:W.rfId,panBy:W.panBy,cancelConnection:W.cancelConnection,onConnectStart:W.onConnectStart,onConnectEnd:(...E)=>{var Q,V;return(V=(Q=w.getState()).onConnectEnd)==null?void 0:V.call(Q,...E)},updateConnection:W.updateConnection,onConnect:D,isValidConnection:n||((...E)=>{var Q,V;return((V=(Q=w.getState()).isValidConnection)==null?void 0:V.call(Q,...E))??!0}),getTransform:()=>w.getState().transform,getFromHandle:()=>w.getState().connection.fromHandle,autoPanSpeed:W.autoPanSpeed,dragThreshold:W.connectionDragThreshold})}$?d==null||d(F):f==null||f(F)},M=F=>{const{onClickConnectStart:$,onClickConnectEnd:W,connectionClickStartHandle:E,connectionMode:Q,isValidConnection:V,lib:B,rfId:se,nodeLookup:ue,connection:G}=w.getState();if(!g||!E&&!s)return;if(!E){$==null||$(F.nativeEvent,{nodeId:g,handleId:y,handleType:e}),w.setState({connectionClickStartHandle:{nodeId:g,type:e,id:y}});return}const ee=kI(F.target),te=n||V,{connection:ne,isValid:Z}=Hx.isValid(F.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&&D(ne);const ce=structuredClone(G);delete ce.inProgress,ce.toPosition=ce.toHandle?ce.toHandle.position:null,W==null||W(F,ce),w.setState({connectionClickStartHandle:null})};return i.jsx("div",{"data-handleid":y,"data-nodeid":g,"data-handlepos":t,"data-id":`${j}-${g}-${y}-${e}`,className:Xn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",b,u,{source:!v,target:v,connectable:r,connectablestart:s,connectableend:o,clickconnecting:I,connectingfrom:N,connectingto:C,valid:L,connectionindicator:r&&(!H||R)&&(H||A?o:s)}]),onMouseDown:O,onTouchStart:O,onClick:k?M:void 0,ref:h,...p,children:c})}const Jn=m.memo(JI(FW));function zW({data:e,isConnectable:t,sourcePosition:n=qe.Bottom}){return i.jsxs(i.Fragment,{children:[e==null?void 0:e.label,i.jsx(Jn,{type:"source",position:n,isConnectable:t})]})}function BW({data:e,isConnectable:t,targetPosition:n=qe.Top,sourcePosition:r=qe.Bottom}){return i.jsxs(i.Fragment,{children:[i.jsx(Jn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,i.jsx(Jn,{type:"source",position:r,isConnectable:t})]})}function HW(){return null}function WW({data:e,isConnectable:t,targetPosition:n=qe.Top}){return i.jsxs(i.Fragment,{children:[i.jsx(Jn,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const tm={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},JN={input:zW,default:BW,output:WW,group:HW};function VW(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 KW=e=>{const{width:t,height:n,x:r,y:s}=ff(e.nodeLookup,{filter:o=>!!o.selected});return{width:Xs(t)?t:null,height:Xs(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 qW({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=wn(),{width:s,height:o,transformString:a,userSelectionActive:l}=Wt(KW,En),c=ZI(),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(QI({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(tm,h.key)&&(h.preventDefault(),c({direction:tm[h.key],factor:h.shiftKey?4:1}))};return i.jsx("div",{className:Xn(["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 XN=typeof window<"u"?window:void 0,UW=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function tR({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:w,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:b,panOnScroll:j,panOnScrollSpeed:N,panOnScrollMode:C,zoomOnDoubleClick:I,panOnDrag:R,defaultViewport:H,translateExtent:A,minZoom:L,maxZoom:D,preventScrolling:O,onSelectionContextMenu:M,noWheelClassName:K,noPanClassName:z,disableKeyboardA11y:F,onViewportChange:$,isControlledViewport:W}){const{nodesSelectionActive:E,userSelectionActive:Q}=Wt(UW,En),V=Hd(u,{target:XN}),B=Hd(v,{target:XN}),se=B||R,ue=B||j,G=d&&se!==!0,ee=V||Q||G;return _W({deleteKeyCode:c,multiSelectionKeyCode:y}),i.jsx(PW,{onPaneContextMenu:o,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:b,panOnScroll:ue,panOnScrollSpeed:N,panOnScrollMode:C,zoomOnDoubleClick:I,panOnDrag:!V&&se,defaultViewport:H,translateExtent:A,minZoom:L,maxZoom:D,zoomActivationKeyCode:w,preventScrolling:O,noWheelClassName:K,noPanClassName:z,onViewportChange:$,isControlledViewport:W,paneClickDistance:l,selectionOnDrag:G,children:i.jsxs(MW,{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(qW,{onSelectionContextMenu:M,noPanClassName:z,disableKeyboardA11y:F})]})})}tR.displayName="FlowRenderer";const YW=m.memo(tR),GW=e=>t=>e?Mk(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 JW(e){return Wt(m.useCallback(GW(e),[e]),En)}const XW=e=>e.updateNodeInternals;function QW(){const e=Wt(XW),[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 ZW({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=wn(),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 e5({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:w,nodeClickDistance:g,onError:k}){const{node:b,internals:j,isParent:N}=Wt(te=>{const ne=te.nodeLookup.get(e),Z=te.parentLookup.has(e);return{node:ne,internals:ne.internals,isParent:Z}},En);let C=b.type||"default",I=(w==null?void 0:w[C])||JN[C];I===void 0&&(k==null||k("003",Ii.error003(C)),C="default",I=(w==null?void 0:w.default)||JN.default);const R=!!(b.draggable||l&&typeof b.draggable>"u"),H=!!(b.selectable||c&&typeof b.selectable>"u"),A=!!(b.connectable||u&&typeof b.connectable>"u"),L=!!(b.focusable||d&&typeof b.focusable>"u"),D=wn(),O=xI(b),M=ZW({node:b,nodeType:C,hasDimensions:O,resizeObserver:f}),K=QI({nodeRef:M,disabled:b.hidden||!R,noDragClassName:p,handleSelector:b.dragHandle,nodeId:e,isSelectable:H,nodeClickDistance:g}),z=ZI();if(b.hidden)return null;const F=po(b),$=VW(b),W=H||R||t||n||r||s,E=n?te=>n(te,{...j.userNode}):void 0,Q=r?te=>r(te,{...j.userNode}):void 0,V=s?te=>s(te,{...j.userNode}):void 0,B=o?te=>o(te,{...j.userNode}):void 0,se=a?te=>a(te,{...j.userNode}):void 0,ue=te=>{const{selectNodesOnDrag:ne,nodeDragThreshold:Z}=D.getState();H&&(!ne||!R||Z>0)&&Vx({id:e,store:D,nodeRef:M}),t&&t(te,{...j.userNode})},G=te=>{if(!(vI(te.nativeEvent)||y)){if(uI.includes(te.key)&&H){const ne=te.key==="Escape";Vx({id:e,store:D,unselect:ne,nodeRef:M})}else if(R&&b.selected&&Object.prototype.hasOwnProperty.call(tm,te.key)){te.preventDefault();const{ariaLabelConfig:ne}=D.getState();D.setState({ariaLiveMessage:ne["node.a11yDescription.ariaLiveMessage"]({direction:te.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),z({direction:tm[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}=D.getState();if(!ce)return;Mk(new Map([[e,b]]),{x:0,y:0,width:ne,height:Z},te,!0).length>0||de(b.position.x+F.width/2,b.position.y+F.height/2,{zoom:te[2]})};return i.jsx("div",{className:Xn(["react-flow__node",`react-flow__node-${C}`,{[h]:R},b.className,{selected:b.selected,selectable:H,parent:N,draggable:R,dragging:K}]),ref:M,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:W?"all":"none",visibility:O?"visible":"hidden",...b.style,...$},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:E,onMouseMove:Q,onMouseLeave:V,onContextMenu:B,onClick:ue,onDoubleClick:se,onKeyDown:L?G:void 0,tabIndex:L?0:void 0,onFocus:L?ee:void 0,role:b.ariaRole??(L?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${qI}-${v}`,"aria-label":b.ariaLabel,...b.domAttributes,children:i.jsx(LW,{value:e,children:i.jsx(I,{id:e,data:b.data,type:C,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:b.selected??!1,selectable:H,draggable:R,deletable:b.deletable??!0,isConnectable:A,sourcePosition:b.sourcePosition,targetPosition:b.targetPosition,dragging:K,dragHandle:b.dragHandle,zIndex:j.z,parentId:b.parentId,...F})})})}var t5=m.memo(e5);const n5=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function nR(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:o}=Wt(n5,En),a=JW(e.onlyRenderVisibleElements),l=QW();return i.jsx("div",{className:"react-flow__nodes",style:ng,children:a.map(c=>i.jsx(t5,{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))})}nR.displayName="NodeRenderer";const r5=m.memo(nR);function s5(e){return Wt(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&&KH({sourceNode:o,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),En)}const i5=({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"})},o5=({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"})},QN={[bi.Arrow]:i5,[bi.ArrowClosed]:o5};function a5(e){const t=wn();return m.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(QN,e)?QN[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",Ii.error009(e)),null)},[e])}const l5=({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=a5(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},rR=({defaultColor:e,rfId:t})=>{const n=Wt(o=>o.edges),r=Wt(o=>o.defaultEdgeOptions),s=m.useMemo(()=>QH(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(l5,{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};rR.displayName="MarkerDefinitions";var c5=m.memo(rR);function sR({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=Xn(["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}sR.displayName="EdgeText";const u5=m.memo(sR);function rg({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:Xn(["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&&Xs(t)&&Xs(n)?i.jsx(u5,{x:t,y:n,label:r,labelStyle:s,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function ZN({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 iR({sourceX:e,sourceY:t,sourcePosition:n=qe.Bottom,targetX:r,targetY:s,targetPosition:o=qe.Top}){const[a,l]=ZN({pos:n,x1:e,y1:t,x2:r,y2:s}),[c,u]=ZN({pos:o,x1:r,y1:s,x2:e,y2:t}),[d,f,p,h]=jI({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 oR(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:w,interactionWidth:g})=>{const[k,b,j]=iR({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:o,targetPosition:l}),N=e.isInternal?void 0:t;return i.jsx(rg,{id:N,path:k,labelX:b,labelY:j,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:w,interactionWidth:g})})}const d5=oR({isInternal:!1}),aR=oR({isInternal:!0});d5.displayName="SimpleBezierEdge";aR.displayName="SimpleBezierEdgeInternal";function lR(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:w,pathOptions:g,interactionWidth:k})=>{const[b,j,N]=Fx({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(rg,{id:C,path:b,labelX:j,labelY:N,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:v,markerStart:w,interactionWidth:k})})}const cR=lR({isInternal:!1}),uR=lR({isInternal:!0});cR.displayName="SmoothStepEdge";uR.displayName="SmoothStepEdgeInternal";function dR(e){return m.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return i.jsx(cR,{...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 f5=dR({isInternal:!1}),fR=dR({isInternal:!0});f5.displayName="StepEdge";fR.displayName="StepEdgeInternal";function pR(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[w,g,k]=_I({sourceX:n,sourceY:r,targetX:s,targetY:o}),b=e.isInternal?void 0:t;return i.jsx(rg,{id:b,path:w,labelX:g,labelY:k,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:f,style:p,markerEnd:h,markerStart:y,interactionWidth:v})})}const p5=pR({isInternal:!1}),hR=pR({isInternal:!0});p5.displayName="StraightEdge";hR.displayName="StraightEdgeInternal";function mR(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:w,pathOptions:g,interactionWidth:k})=>{const[b,j,N]=NI({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(rg,{id:C,path:b,labelX:j,labelY:N,label:c,labelStyle:u,labelShowBg:d,labelBgStyle:f,labelBgPadding:p,labelBgBorderRadius:h,style:y,markerEnd:v,markerStart:w,interactionWidth:k})})}const h5=mR({isInternal:!1}),gR=mR({isInternal:!0});h5.displayName="BezierEdge";gR.displayName="BezierEdgeInternal";const e1={default:gR,straight:hR,step:fR,smoothstep:uR,simplebezier:aR},t1={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},m5=(e,t,n)=>n===qe.Left?e-t:n===qe.Right?e+t:e,g5=(e,t,n)=>n===qe.Top?e-t:n===qe.Bottom?e+t:e,n1="react-flow__edgeupdater";function r1({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:Xn([n1,`${n1}-${l}`]),cx:m5(t,r,e),cy:g5(n,r,e),r,stroke:"transparent",fill:"transparent"})}function y5({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=wn(),v=(j,N)=>{if(j.button!==0)return;const{autoPanOnConnect:C,domNode:I,connectionMode:R,connectionRadius:H,lib:A,onConnectStart:L,cancelConnection:D,nodeLookup:O,rfId:M,panBy:K,updateConnection:z}=y.getState(),F=N.type==="target",$=(Q,V)=>{p(!1),f==null||f(Q,n,N.type,V)},W=Q=>u==null?void 0:u(n,Q),E=(Q,V)=>{p(!0),d==null||d(j,n,N.type),L==null||L(Q,V)};Hx.onPointerDown(j.nativeEvent,{autoPanOnConnect:C,connectionMode:R,connectionRadius:H,domNode:I,handleId:N.id,nodeId:N.nodeId,nodeLookup:O,isTarget:F,edgeUpdaterType:N.type,lib:A,flowId:M,cancelConnection:D,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:$,updateConnection:z,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},w=j=>v(j,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=j=>v(j,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),k=()=>h(!0),b=()=>h(!1);return i.jsxs(i.Fragment,{children:[(e===!0||e==="source")&&i.jsx(r1,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:w,onMouseEnter:k,onMouseOut:b,type:"source"}),(e===!0||e==="target")&&i.jsx(r1,{position:c,centerX:o,centerY:a,radius:t,onMouseDown:g,onMouseEnter:k,onMouseOut:b,type:"target"})]})}function w5({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:w,onError:g,disableKeyboardA11y:k}){let b=Wt(de=>de.edgeLookup.get(e));const j=Wt(de=>de.defaultEdgeOptions);b=j?{...j,...b}:b;let N=b.type||"default",C=(v==null?void 0:v[N])||e1[N];C===void 0&&(g==null||g("011",Ii.error011(N)),N="default",C=(v==null?void 0:v.default)||e1.default);const I=!!(b.focusable||t&&typeof b.focusable>"u"),R=typeof f<"u"&&(b.reconnectable||n&&typeof b.reconnectable>"u"),H=!!(b.selectable||r&&typeof b.selectable>"u"),A=m.useRef(null),[L,D]=m.useState(!1),[O,M]=m.useState(!1),K=wn(),{zIndex:z,sourceX:F,sourceY:$,targetX:W,targetY:E,sourcePosition:Q,targetPosition:V}=Wt(m.useCallback(de=>{const me=de.nodeLookup.get(b.source),$e=de.nodeLookup.get(b.target);if(!me||!$e)return{zIndex:b.zIndex,...t1};const Ce=XH({id:e,sourceNode:me,targetNode:$e,sourceHandle:b.sourceHandle||null,targetHandle:b.targetHandle||null,connectionMode:de.connectionMode,onError:g});return{zIndex:VH({selected:b.selected,zIndex:b.zIndex,sourceNode:me,targetNode:$e,elevateOnSelect:de.elevateEdgesOnSelect,zIndexMode:de.zIndexMode}),...Ce||t1}},[b.source,b.target,b.sourceHandle,b.targetHandle,b.selected,b.zIndex]),En),B=m.useMemo(()=>b.markerStart?`url('#${zx(b.markerStart,y)}')`:void 0,[b.markerStart,y]),se=m.useMemo(()=>b.markerEnd?`url('#${zx(b.markerEnd,y)}')`:void 0,[b.markerEnd,y]);if(b.hidden||F===null||$===null||W===null||E===null)return null;const ue=de=>{var _e;const{addSelectedEdges:me,unselectNodesAndEdges:$e,multiSelectionActive:Ce}=K.getState();H&&(K.setState({nodesSelectionActive:!1}),b.selected&&Ce?($e({nodes:[],edges:[b]}),(_e=A.current)==null||_e.blur()):me([e])),s&&s(de,b)},G=o?de=>{o(de,{...b})}:void 0,ee=a?de=>{a(de,{...b})}:void 0,te=l?de=>{l(de,{...b})}:void 0,ne=c?de=>{c(de,{...b})}:void 0,Z=u?de=>{u(de,{...b})}:void 0,ce=de=>{var me;if(!k&&uI.includes(de.key)&&H){const{unselectNodesAndEdges:$e,addSelectedEdges:Ce}=K.getState();de.key==="Escape"?((me=A.current)==null||me.blur(),$e({edges:[b]})):Ce([e])}};return i.jsx("svg",{style:{zIndex:z},children:i.jsxs("g",{className:Xn(["react-flow__edge",`react-flow__edge-${N}`,b.className,w,{selected:b.selected,animated:b.animated,inactive:!H&&!s,updating:L,selectable:H}]),onClick:ue,onDoubleClick:G,onContextMenu:ee,onMouseEnter:te,onMouseMove:ne,onMouseLeave:Z,onKeyDown:I?ce:void 0,tabIndex:I?0:void 0,role:b.ariaRole??(I?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":b.ariaLabel===null?void 0:b.ariaLabel||`Edge from ${b.source} to ${b.target}`,"aria-describedby":I?`${UI}-${y}`:void 0,ref:A,...b.domAttributes,children:[!O&&i.jsx(C,{id:e,source:b.source,target:b.target,type:b.type,selected:b.selected,animated:b.animated,selectable:H,deletable:b.deletable??!0,label:b.label,labelStyle:b.labelStyle,labelShowBg:b.labelShowBg,labelBgStyle:b.labelBgStyle,labelBgPadding:b.labelBgPadding,labelBgBorderRadius:b.labelBgBorderRadius,sourceX:F,sourceY:$,targetX:W,targetY:E,sourcePosition:Q,targetPosition:V,data:b.data,style:b.style,sourceHandleId:b.sourceHandle,targetHandleId:b.targetHandle,markerStart:B,markerEnd:se,pathOptions:"pathOptions"in b?b.pathOptions:void 0,interactionWidth:b.interactionWidth}),R&&i.jsx(y5,{edge:b,isReconnectable:R,reconnectRadius:d,onReconnect:f,onReconnectStart:p,onReconnectEnd:h,sourceX:F,sourceY:$,targetX:W,targetY:E,sourcePosition:Q,targetPosition:V,setUpdateHover:D,setReconnecting:M})]})})}var x5=m.memo(w5);const b5=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function yR({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:w,edgesReconnectable:g,elementsSelectable:k,onError:b}=Wt(b5,En),j=s5(t);return i.jsxs("div",{className:"react-flow__edges",children:[i.jsx(c5,{defaultColor:e,rfId:n}),j.map(N=>i.jsx(x5,{id:N,edgesFocusable:w,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:b,edgeTypes:r,disableKeyboardA11y:v},N))]})}yR.displayName="EdgeRenderer";const k5=m.memo(yR),v5=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function S5({children:e}){const t=Wt(v5);return i.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function j5(e){const t=Bc(),n=m.useRef(!1);m.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const N5=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function C5(e){const t=Wt(N5),n=wn();return m.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function _5(e){return e.connection.inProgress?{...e.connection,to:hf(e.connection.to,e.transform)}:{...e.connection}}function E5(e){return _5}function A5(e){const t=E5();return Wt(t,En)}const P5=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function I5({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:o,height:a,isValid:l,inProgress:c}=Wt(P5,En);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:Xn(["react-flow__connection",pI(l)]),children:i.jsx(wR,{style:t,type:n,CustomComponent:r,isValid:l})})})}const wR=({style:e,type:t=$o.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}=A5();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:pI(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 $o.Bezier:[y]=NI(v);break;case $o.SimpleBezier:[y]=iR(v);break;case $o.Step:[y]=Fx({...v,borderRadius:0});break;case $o.SmoothStep:[y]=Fx(v);break;default:[y]=_I(v)}return i.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};wR.displayName="ConnectionLine";const R5={};function s1(e=R5){m.useRef(e),wn(),m.useEffect(()=>{},[e])}function T5(){wn(),m.useRef(!1),m.useEffect(()=>{},[])}function xR({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:w,connectionLineContainerStyle:g,selectionKeyCode:k,selectionOnDrag:b,selectionMode:j,multiSelectionKeyCode:N,panActivationKeyCode:C,zoomActivationKeyCode:I,deleteKeyCode:R,onlyRenderVisibleElements:H,elementsSelectable:A,defaultViewport:L,translateExtent:D,minZoom:O,maxZoom:M,preventScrolling:K,defaultMarkerColor:z,zoomOnScroll:F,zoomOnPinch:$,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:gt,noDragClassName:Te,noWheelClassName:st,noPanClassName:mt,disableKeyboardA11y:Tt,nodeExtent:xe,rfId:Oe,viewport:ie,onViewportChange:ke}){return s1(e),s1(t),T5(),j5(n),C5(ie),i.jsx(YW,{onPaneClick:se,onPaneMouseEnter:ue,onPaneMouseMove:G,onPaneMouseLeave:ee,onPaneContextMenu:ne,onPaneScroll:te,paneClickDistance:Z,deleteKeyCode:R,selectionKeyCode:k,selectionOnDrag:b,selectionMode:j,onSelectionStart:p,onSelectionEnd:h,multiSelectionKeyCode:N,panActivationKeyCode:C,zoomActivationKeyCode:I,elementsSelectable:A,zoomOnScroll:F,zoomOnPinch:$,zoomOnDoubleClick:V,panOnScroll:W,panOnScrollSpeed:E,panOnScrollMode:Q,panOnDrag:B,defaultViewport:L,translateExtent:D,minZoom:O,maxZoom:M,onSelectionContextMenu:f,preventScrolling:K,noDragClassName:Te,noWheelClassName:st,noPanClassName:mt,disableKeyboardA11y:Tt,onViewportChange:ke,isControlledViewport:!!ie,children:i.jsxs(S5,{children:[i.jsx(k5,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:Be,onReconnectStart:ot,onReconnectEnd:gt,onlyRenderVisibleElements:H,onEdgeContextMenu:de,onEdgeMouseEnter:me,onEdgeMouseMove:$e,onEdgeMouseLeave:Ce,reconnectRadius:_e,defaultMarkerColor:z,noPanClassName:mt,disableKeyboardA11y:Tt,rfId:Oe}),i.jsx(I5,{style:v,type:y,component:w,containerStyle:g}),i.jsx("div",{className:"react-flow__edgelabel-renderer"}),i.jsx(r5,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:d,nodeClickDistance:ce,onlyRenderVisibleElements:H,noPanClassName:mt,noDragClassName:Te,disableKeyboardA11y:Tt,nodeExtent:xe,rfId:Oe}),i.jsx("div",{className:"react-flow__viewport-portal"})]})})}xR.displayName="GraphView";const M5=m.memo(xR),i1=({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,w=new Map,g=r??t??[],k=n??e??[],b=d??[0,0],j=f??Dd;PI(v,w,g);const{nodesInitialized:N}=Bx(k,h,y,{nodeOrigin:b,nodeExtent:j,zIndexMode:p});let C=[0,0,1];if(a&&s&&o){const I=ff(h,{filter:L=>!!((L.width||L.initialWidth)&&(L.height||L.initialHeight))}),{x:R,y:H,zoom:A}=$k(I,s,o,c,u,(l==null?void 0:l.padding)??.1);C=[R,H,A]}return{rfId:"1",width:s??0,height:o??0,transform:C,nodes:k,nodesInitialized:N,nodeLookup:h,parentLookup:y,edges:g,edgeLookup:w,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:Dd,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ec.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:b,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:{...fI},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:DH,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:dI,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},$5=({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})=>eW((h,y)=>{async function v(){const{nodeLookup:w,panZoom:g,fitViewOptions:k,fitViewResolver:b,width:j,height:N,minZoom:C,maxZoom:I}=y();g&&(await LH({nodes:w,width:j,height:N,panZoom:g,minZoom:C,maxZoom:I},k),b==null||b.resolve(!0),h({fitViewResolver:null}))}return{...i1({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:w=>{const{nodeLookup:g,parentLookup:k,nodeOrigin:b,elevateNodesOnSelect:j,fitViewQueued:N,zIndexMode:C,nodesSelectionActive:I}=y(),{nodesInitialized:R,hasSelectedNodes:H}=Bx(w,g,k,{nodeOrigin:b,nodeExtent:f,elevateNodesOnSelect:j,checkEquality:!0,zIndexMode:C}),A=I&&H;N&&R?(v(),h({nodes:w,nodesInitialized:R,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:A})):h({nodes:w,nodesInitialized:R,nodesSelectionActive:A})},setEdges:w=>{const{connectionLookup:g,edgeLookup:k}=y();PI(g,k,w),h({edges:w})},setDefaultNodesAndEdges:(w,g)=>{if(w){const{setNodes:k}=y();k(w),h({hasDefaultNodes:!0})}if(g){const{setEdges:k}=y();k(g),h({hasDefaultEdges:!0})}},updateNodeInternals:w=>{const{triggerNodeChanges:g,nodeLookup:k,parentLookup:b,domNode:j,nodeOrigin:N,nodeExtent:C,debug:I,fitViewQueued:R,zIndexMode:H}=y(),{changes:A,updatedInternals:L}=i4(w,k,b,j,N,C,H);L&&(t4(k,b,{nodeOrigin:N,nodeExtent:C,zIndexMode:H}),R?(v(),h({fitViewQueued:!1,fitViewOptions:void 0})):h({}),(A==null?void 0:A.length)>0&&(I&&console.log("React Flow: trigger node changes",A),g==null||g(A)))},updateNodePositions:(w,g=!1)=>{const k=[];let b=[];const{nodeLookup:j,triggerNodeChanges:N,connection:C,updateConnection:I,onNodesChangeMiddlewareMap:R}=y();for(const[H,A]of w){const L=j.get(H),D=!!(L!=null&&L.expandParent&&(L!=null&&L.parentId)&&(A!=null&&A.position)),O={id:H,type:"position",position:D?{x:Math.max(0,A.position.x),y:Math.max(0,A.position.y)}:A.position,dragging:g};if(L&&C.inProgress&&C.fromNode.id===L.id){const M=Xa(L,C.fromHandle,qe.Left,!0);I({...C,from:M})}D&&L.parentId&&k.push({id:H,parentId:L.parentId,rect:{...A.internals.positionAbsolute,width:A.measured.width??0,height:A.measured.height??0}}),b.push(O)}if(k.length>0){const{parentLookup:H,nodeOrigin:A}=y(),L=Bk(k,j,H,A);b.push(...L)}for(const H of R.values())b=H(b);N(b)},triggerNodeChanges:w=>{const{onNodesChange:g,setNodes:k,nodes:b,hasDefaultNodes:j,debug:N}=y();if(w!=null&&w.length){if(j){const C=cd(w,b);k(C)}N&&console.log("React Flow: trigger node changes",w),g==null||g(w)}},triggerEdgeChanges:w=>{const{onEdgesChange:g,setEdges:k,edges:b,hasDefaultEdges:j,debug:N}=y();if(w!=null&&w.length){if(j){const C=em(w,b);k(C)}N&&console.log("React Flow: trigger edge changes",w),g==null||g(w)}},addSelectedNodes:w=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:b,triggerNodeChanges:j,triggerEdgeChanges:N}=y();if(g){const C=w.map(I=>Na(I,!0));j(C);return}j(tc(b,new Set([...w]),!0)),N(tc(k))},addSelectedEdges:w=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:b,triggerNodeChanges:j,triggerEdgeChanges:N}=y();if(g){const C=w.map(I=>Na(I,!0));N(C);return}N(tc(k,new Set([...w]))),j(tc(b,new Set,!0))},unselectNodesAndEdges:({nodes:w,edges:g}={})=>{const{edges:k,nodes:b,nodeLookup:j,triggerNodeChanges:N,triggerEdgeChanges:C}=y(),I=w||b,R=g||k,H=[];for(const L of I){if(!L.selected)continue;const D=j.get(L.id);D&&(D.selected=!1),H.push(Na(L.id,!1))}const A=[];for(const L of R)L.selected&&A.push(Na(L.id,!1));N(H),C(A)},setMinZoom:w=>{const{panZoom:g,maxZoom:k}=y();g==null||g.setScaleExtent([w,k]),h({minZoom:w})},setMaxZoom:w=>{const{panZoom:g,minZoom:k}=y();g==null||g.setScaleExtent([k,w]),h({maxZoom:w})},setTranslateExtent:w=>{var g;(g=y().panZoom)==null||g.setTranslateExtent(w),h({translateExtent:w})},resetSelectedElements:()=>{const{edges:w,nodes:g,triggerNodeChanges:k,triggerEdgeChanges:b,elementsSelectable:j}=y();if(!j)return;const N=g.reduce((I,R)=>R.selected?[...I,Na(R.id,!1)]:I,[]),C=w.reduce((I,R)=>R.selected?[...I,Na(R.id,!1)]:I,[]);k(N),b(C)},setNodeExtent:w=>{const{nodes:g,nodeLookup:k,parentLookup:b,nodeOrigin:j,elevateNodesOnSelect:N,nodeExtent:C,zIndexMode:I}=y();w[0][0]===C[0][0]&&w[0][1]===C[0][1]&&w[1][0]===C[1][0]&&w[1][1]===C[1][1]||(Bx(g,k,b,{nodeOrigin:j,nodeExtent:w,elevateNodesOnSelect:N,checkEquality:!1,zIndexMode:I}),h({nodeExtent:w}))},panBy:w=>{const{transform:g,width:k,height:b,panZoom:j,translateExtent:N}=y();return o4({delta:w,panZoom:j,transform:g,translateExtent:N,width:k,height:b})},setCenter:async(w,g,k)=>{const{width:b,height:j,maxZoom:N,panZoom:C}=y();if(!C)return Promise.resolve(!1);const I=typeof(k==null?void 0:k.zoom)<"u"?k.zoom:N;return await C.setViewport({x:b/2-w*I,y:j/2-g*I,zoom:I},{duration:k==null?void 0:k.duration,ease:k==null?void 0:k.ease,interpolate:k==null?void 0:k.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{h({connection:{...fI}})},updateConnection:w=>{h({connection:w})},reset:()=>h({...i1()})}},Object.is);function Wk({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(()=>$5({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(tW,{value:y,children:i.jsx(SW,{children:h})})}function L5({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(eg)?i.jsx(i.Fragment,{children:e}):i.jsx(Wk,{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 O5={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function D5({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:w,onClickConnectEnd:g,onNodeMouseEnter:k,onNodeMouseMove:b,onNodeMouseLeave:j,onNodeContextMenu:N,onNodeDoubleClick:C,onNodeDragStart:I,onNodeDrag:R,onNodeDragStop:H,onNodesDelete:A,onEdgesDelete:L,onDelete:D,onSelectionChange:O,onSelectionDragStart:M,onSelectionDrag:K,onSelectionDragStop:z,onSelectionContextMenu:F,onSelectionStart:$,onSelectionEnd:W,onBeforeDelete:E,connectionMode:Q,connectionLineType:V=$o.Bezier,connectionLineStyle:B,connectionLineComponent:se,connectionLineContainerStyle:ue,deleteKeyCode:G="Backspace",selectionKeyCode:ee="Shift",selectionOnDrag:te=!1,selectionMode:ne=Fd.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:ce=Bd()?"Meta":"Control",zoomActivationKeyCode:de=Bd()?"Meta":"Control",snapToGrid:me,snapGrid:$e,onlyRenderVisibleElements:Ce=!1,selectNodesOnDrag:_e,nodesDraggable:Be,autoPanOnNodeFocus:ot,nodesConnectable:gt,nodesFocusable:Te,nodeOrigin:st=YI,edgesFocusable:mt,edgesReconnectable:Tt,elementsSelectable:xe=!0,defaultViewport:Oe=hW,minZoom:ie=.5,maxZoom:ke=2,translateExtent:Ke=Dd,preventScrolling:Ue=!0,nodeExtent:be,defaultMarkerColor:It="#b1b1b7",zoomOnScroll:nn=!0,zoomOnPinch:Vt=!0,panOnScroll:Ot=!1,panOnScrollSpeed:ln=.5,panOnScrollMode:re=za.Free,zoomOnDoubleClick:Re=!0,panOnDrag:Je=!0,onPaneClick:Ze,onPaneMouseEnter:Mt,onPaneMouseMove:_t,onPaneMouseLeave:Kn,onPaneScroll:jn,onPaneContextMenu:br,paneClickDistance:xn=1,nodeClickDistance:Qn=0,children:qn,onReconnect:mr,onReconnectStart:ts,onReconnectEnd:Pr,onEdgeContextMenu:ys,onEdgeDoubleClick:ws,onEdgeMouseEnter:dn,onEdgeMouseMove:sr,onEdgeMouseLeave:Ir,reconnectRadius:pn=10,onNodesChange:Zn,onEdgesChange:kr,noDragClassName:ir="nodrag",noWheelClassName:jt="nowheel",noPanClassName:Xt="nopan",fitView:Nt,fitViewOptions:le,connectOnClick:ve,attributionPosition:it,proOptions:zt,defaultEdgeOptions:Qt,elevateNodesOnSelect:rn=!0,elevateEdgesOnSelect:er=!1,disableKeyboardA11y:ht=!1,autoPanOnConnect:sn,autoPanOnNodeDrag:Kt,autoPanSpeed:vr,connectionRadius:tt,isValidConnection:On,onError:$i,style:Br,id:go,nodeDragThreshold:ai,connectionDragThreshold:Ms,viewport:oe,onViewportChange:Se,width:Pe,height:wt,colorMode:Dt="light",debug:Yt,onScroll:Bn,ariaLabelConfig:Dn,zIndexMode:q="basic",...he},De){const Ee=go||"1",et=wW(Dt),Nn=m.useCallback(bt=>{bt.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),Bn==null||Bn(bt)},[Bn]);return i.jsx("div",{"data-testid":"rf__wrapper",...he,onScroll:Nn,style:{...Br,...O5},ref:De,className:Xn(["react-flow",s,et]),id:go,role:"application",children:i.jsxs(L5,{nodes:e,edges:t,width:Pe,height:wt,fitView:Nt,fitViewOptions:le,minZoom:ie,maxZoom:ke,nodeOrigin:st,nodeExtent:be,zIndexMode:q,children:[i.jsx(yW,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:h,onConnectStart:y,onConnectEnd:v,onClickConnectStart:w,onClickConnectEnd:g,nodesDraggable:Be,autoPanOnNodeFocus:ot,nodesConnectable:gt,nodesFocusable:Te,edgesFocusable:mt,edgesReconnectable:Tt,elementsSelectable:xe,elevateNodesOnSelect:rn,elevateEdgesOnSelect:er,minZoom:ie,maxZoom:ke,nodeExtent:be,onNodesChange:Zn,onEdgesChange:kr,snapToGrid:me,snapGrid:$e,connectionMode:Q,translateExtent:Ke,connectOnClick:ve,defaultEdgeOptions:Qt,fitView:Nt,fitViewOptions:le,onNodesDelete:A,onEdgesDelete:L,onDelete:D,onNodeDragStart:I,onNodeDrag:R,onNodeDragStop:H,onSelectionDrag:K,onSelectionDragStart:M,onSelectionDragStop:z,onMove:d,onMoveStart:f,onMoveEnd:p,noPanClassName:Xt,nodeOrigin:st,rfId:Ee,autoPanOnConnect:sn,autoPanOnNodeDrag:Kt,autoPanSpeed:vr,onError:$i,connectionRadius:tt,isValidConnection:On,selectNodesOnDrag:_e,nodeDragThreshold:ai,connectionDragThreshold:Ms,onBeforeDelete:E,debug:Yt,ariaLabelConfig:Dn,zIndexMode:q}),i.jsx(M5,{onInit:u,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:k,onNodeMouseMove:b,onNodeMouseLeave:j,onNodeContextMenu:N,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:Oe,translateExtent:Ke,minZoom:ie,maxZoom:ke,preventScrolling:Ue,zoomOnScroll:nn,zoomOnPinch:Vt,zoomOnDoubleClick:Re,panOnScroll:Ot,panOnScrollSpeed:ln,panOnScrollMode:re,panOnDrag:Je,onPaneClick:Ze,onPaneMouseEnter:Mt,onPaneMouseMove:_t,onPaneMouseLeave:Kn,onPaneScroll:jn,onPaneContextMenu:br,paneClickDistance:xn,nodeClickDistance:Qn,onSelectionContextMenu:F,onSelectionStart:$,onSelectionEnd:W,onReconnect:mr,onReconnectStart:ts,onReconnectEnd:Pr,onEdgeContextMenu:ys,onEdgeDoubleClick:ws,onEdgeMouseEnter:dn,onEdgeMouseMove:sr,onEdgeMouseLeave:Ir,reconnectRadius:pn,defaultMarkerColor:It,noDragClassName:ir,noWheelClassName:jt,noPanClassName:Xt,rfId:Ee,disableKeyboardA11y:ht,nodeExtent:be,viewport:oe,onViewportChange:Se}),i.jsx(pW,{onSelectionChange:O}),qn,i.jsx(lW,{proOptions:zt,position:it}),i.jsx(aW,{rfId:Ee,disableKeyboardA11y:ht})]})})}var bR=JI(D5);function F5(){const e=wn();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 z5(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(o=>cd(s,o)),[]);return[t,n,r]}function B5(e){const[t,n]=m.useState(e),r=m.useCallback(s=>n(o=>em(s,o)),[]);return[t,n,r]}function H5({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:Xn(["react-flow__background-pattern",n,r])})}function W5({radius:e,className:t}){return i.jsx("circle",{cx:e,cy:e,r:e,className:Xn(["react-flow__background-pattern","dots",t])})}var Go;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Go||(Go={}));const V5={[Go.Dots]:1,[Go.Lines]:1,[Go.Cross]:6},K5=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function kR({id:e,variant:t=Go.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}=Wt(K5,En),y=r||V5[t],v=t===Go.Dots,w=t===Go.Cross,g=Array.isArray(n)?n:[n,n],k=[g[0]*p[2]||1,g[1]*p[2]||1],b=y*p[2],j=Array.isArray(o)?o:[o,o],N=w?[b,b]:k,C=[j[0]*p[2]||1+N[0]/2,j[1]*p[2]||1+N[1]/2],I=`${h}${e||""}`;return i.jsxs("svg",{className:Xn(["react-flow__background",u]),style:{...c,...ng,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:f,"data-testid":"rf__background",children:[i.jsx("pattern",{id:I,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(W5,{radius:b/2,className:d}):i.jsx(H5,{dimensions:N,lineWidth:s,variant:t,className:d})}),i.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${I})`})]})}kR.displayName="Background";const vR=m.memo(kR);function q5(){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 U5(){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 Y5(){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 G5(){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 J5(){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 Ep({children:e,className:t,...n}){return i.jsx("button",{type:"button",className:Xn(["react-flow__controls-button",t]),...n,children:e})}const X5=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function SR({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=wn(),{isInteractive:v,minZoomReached:w,maxZoomReached:g,ariaLabelConfig:k}=Wt(X5,En),{zoomIn:b,zoomOut:j,fitView:N}=Bc(),C=()=>{b(),o==null||o()},I=()=>{j(),a==null||a()},R=()=>{N(s),l==null||l()},H=()=>{y.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},A=p==="horizontal"?"horizontal":"vertical";return i.jsxs(tg,{className:Xn(["react-flow__controls",A,u]),position:f,style:e,"data-testid":"rf__controls","aria-label":h??k["controls.ariaLabel"],children:[t&&i.jsxs(i.Fragment,{children:[i.jsx(Ep,{onClick:C,className:"react-flow__controls-zoomin",title:k["controls.zoomIn.ariaLabel"],"aria-label":k["controls.zoomIn.ariaLabel"],disabled:g,children:i.jsx(q5,{})}),i.jsx(Ep,{onClick:I,className:"react-flow__controls-zoomout",title:k["controls.zoomOut.ariaLabel"],"aria-label":k["controls.zoomOut.ariaLabel"],disabled:w,children:i.jsx(U5,{})})]}),n&&i.jsx(Ep,{className:"react-flow__controls-fitview",onClick:R,title:k["controls.fitView.ariaLabel"],"aria-label":k["controls.fitView.ariaLabel"],children:i.jsx(Y5,{})}),r&&i.jsx(Ep,{className:"react-flow__controls-interactive",onClick:H,title:k["controls.interactive.ariaLabel"],"aria-label":k["controls.interactive.ariaLabel"],children:v?i.jsx(J5,{}):i.jsx(G5,{})}),d]})}SR.displayName="Controls";m.memo(SR);function Q5({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||{},w=a||y||v;return i.jsx("rect",{className:Xn(["react-flow__minimap-node",{selected:p},u]),x:t,y:n,rx:d,ry:d,width:r,height:s,style:{fill:w,stroke:l,strokeWidth:c},shapeRendering:f,onClick:h?g=>h(g,e):void 0})}const Z5=m.memo(Q5),e6=e=>e.nodes.map(t=>t.id),Ky=e=>e instanceof Function?e:()=>e;function t6({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:o=Z5,onClick:a}){const l=Wt(e6,En),c=Ky(t),u=Ky(e),d=Ky(n),f=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return i.jsx(i.Fragment,{children:l.map(p=>i.jsx(r6,{id:p,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:d,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:o,onClick:a,shapeRendering:f},p))})}function n6({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}=Wt(y=>{const v=y.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const w=v.internals.userNode,{x:g,y:k}=v.internals.positionAbsolute,{width:b,height:j}=po(w);return{node:w,x:g,y:k,width:b,height:j}},En);return!u||u.hidden||!xI(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 r6=m.memo(n6);var s6=m.memo(t6);const i6=200,o6=150,a6=e=>!e.hidden,l6=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?wI(ff(e.nodeLookup,{filter:a6}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},c6="react-flow__minimap-desc";function jR({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:w=!1,ariaLabel:g,inversePan:k,zoomStep:b=1,offsetScale:j=5}){const N=wn(),C=m.useRef(null),{boundingRect:I,viewBB:R,rfId:H,panZoom:A,translateExtent:L,flowWidth:D,flowHeight:O,ariaLabelConfig:M}=Wt(l6,En),K=(e==null?void 0:e.width)??i6,z=(e==null?void 0:e.height)??o6,F=I.width/K,$=I.height/z,W=Math.max(F,$),E=W*K,Q=W*z,V=j*W,B=I.x-(E-I.width)/2-V,se=I.y-(Q-I.height)/2-V,ue=E+V*2,G=Q+V*2,ee=`${c6}-${H}`,te=m.useRef(0),ne=m.useRef();te.current=W,m.useEffect(()=>{if(C.current&&A)return ne.current=m4({domNode:C.current,panZoom:A,getTransform:()=>N.getState().transform,getViewScale:()=>te.current}),()=>{var me;(me=ne.current)==null||me.destroy()}},[A]),m.useEffect(()=>{var me;(me=ne.current)==null||me.update({translateExtent:L,width:D,height:O,inversePan:k,pannable:v,zoomStep:b,zoomable:w})},[v,w,k,b,L,D,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=N.getState().nodeLookup.get($e).internals.userNode;y(me,Ce)},[]):void 0,de=g??M["minimap.ariaLabel"];return i.jsx(tg,{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:Xn(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:i.jsxs("svg",{width:K,height:z,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(s6,{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${R.x},${R.y}h${R.width}v${R.height}h${-R.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}jR.displayName="MiniMap";m.memo(jR);const u6=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,d6={[Rc.Line]:"right",[Rc.Handle]:"bottom-right"};function f6({nodeId:e,position:t,variant:n=Rc.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:w,onResizeEnd:g}){const k=eR(),b=typeof e=="string"?e:k,j=wn(),N=m.useRef(null),C=n===Rc.Handle,I=Wt(m.useCallback(u6(C&&h),[C,h]),En),R=m.useRef(null),H=t??d6[n];m.useEffect(()=>{if(!(!N.current||!b))return R.current||(R.current=A4({domNode:N.current,nodeId:b,getStoreItems:()=>{const{nodeLookup:L,transform:D,snapGrid:O,snapToGrid:M,nodeOrigin:K,domNode:z}=j.getState();return{nodeLookup:L,transform:D,snapGrid:O,snapToGrid:M,nodeOrigin:K,paneDomNode:z}},onChange:(L,D)=>{const{triggerNodeChanges:O,nodeLookup:M,parentLookup:K,nodeOrigin:z}=j.getState(),F=[],$={x:L.x,y:L.y},W=M.get(b);if(W&&W.expandParent&&W.parentId){const E=W.origin??z,Q=L.width??W.measured.width??0,V=L.height??W.measured.height??0,B={id:W.id,parentId:W.parentId,rect:{width:Q,height:V,...bI({x:L.x??W.position.x,y:L.y??W.position.y},{width:Q,height:V},W.parentId,M,E)}},se=Bk([B],M,K,z);F.push(...se),$.x=L.x?Math.max(E[0]*Q,L.x):void 0,$.y=L.y?Math.max(E[1]*V,L.y):void 0}if($.x!==void 0&&$.y!==void 0){const E={id:b,type:"position",position:{...$}};F.push(E)}if(L.width!==void 0&&L.height!==void 0){const Q={id:b,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:L.width,height:L.height}};F.push(Q)}for(const E of D){const Q={...E,type:"position"};F.push(Q)}O(F)},onEnd:({width:L,height:D})=>{const O={id:b,type:"dimensions",resizing:!1,dimensions:{width:L,height:D}};j.getState().triggerNodeChanges([O])}})),R.current.update({controlPosition:H,boundaries:{minWidth:l,minHeight:c,maxWidth:u,maxHeight:d},keepAspectRatio:f,resizeDirection:p,onResizeStart:v,onResize:w,onResizeEnd:g,shouldResize:y}),()=>{var L;(L=R.current)==null||L.destroy()}},[H,l,c,u,d,f,v,w,g,y]);const A=H.split("-");return i.jsx("div",{className:Xn(["react-flow__resize-control","nodrag",...A,n,r]),ref:N,style:{...s,scale:I,...a&&{[C?"backgroundColor":"borderColor"]:a}},children:o})}const Vk=m.memo(f6),p6="modulepreload",h6=function(e){return"/"+e},o1={},m6=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=h6(c),c in o1)return;o1[c]=!0;const u=c.endsWith(".css"),d=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${d}`))return;const f=document.createElement("link");if(f.rel=u?"stylesheet":p6,u||(f.as="script"),f.crossOrigin="",f.href=c,l&&f.setAttribute("nonce",l),document.head.appendChild(f),u)return new Promise((p,h)=>{f.addEventListener("load",p),f.addEventListener("error",()=>h(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return s.then(a=>{for(const l of a||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};function g6(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const y6=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,w6=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,x6={};function a1(e,t){return(x6.jsx?w6:y6).test(e)}const b6=/[ \t\n\f\r]/g;function k6(e){return typeof e=="object"?e.type==="text"?l1(e.value):!1:l1(e)}function l1(e){return e.replace(b6,"")===""}class mf{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}mf.prototype.normal={};mf.prototype.property={};mf.prototype.space=void 0;function NR(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new mf(n,r,t)}function Kx(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 v6=0;const vt=al(),Yn=al(),qx=al(),Ie=al(),mn=al(),pc=al(),ss=al();function al(){return 2**++v6}const Ux=Object.freeze(Object.defineProperty({__proto__:null,boolean:vt,booleanish:Yn,commaOrSpaceSeparated:ss,commaSeparated:pc,number:Ie,overloadedBoolean:qx,spaceSeparated:mn},Symbol.toStringTag,{value:"Module"})),qy=Object.keys(Ux);class Kk extends es{constructor(t,n,r,s){let o=-1;if(super(t,n),c1(this,"space",s),typeof r=="number")for(;++o<qy.length;){const a=qy[o];c1(this,qy[o],(r&Ux[a])===Ux[a])}}}Kk.prototype.defined=!0;function c1(e,t,n){n&&(e[t]=n)}function Hc(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const o=new Kk(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[Kx(r)]=r,n[Kx(o.attribute)]=r}return new mf(t,n,e.space)}const CR=Hc({properties:{ariaActiveDescendant:null,ariaAtomic:Yn,ariaAutoComplete:null,ariaBusy:Yn,ariaChecked:Yn,ariaColCount:Ie,ariaColIndex:Ie,ariaColSpan:Ie,ariaControls:mn,ariaCurrent:null,ariaDescribedBy:mn,ariaDetails:null,ariaDisabled:Yn,ariaDropEffect:mn,ariaErrorMessage:null,ariaExpanded:Yn,ariaFlowTo:mn,ariaGrabbed:Yn,ariaHasPopup:null,ariaHidden:Yn,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:mn,ariaLevel:Ie,ariaLive:null,ariaModal:Yn,ariaMultiLine:Yn,ariaMultiSelectable:Yn,ariaOrientation:null,ariaOwns:mn,ariaPlaceholder:null,ariaPosInSet:Ie,ariaPressed:Yn,ariaReadOnly:Yn,ariaRelevant:null,ariaRequired:Yn,ariaRoleDescription:mn,ariaRowCount:Ie,ariaRowIndex:Ie,ariaRowSpan:Ie,ariaSelected:Yn,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 _R(e,t){return t in e?e[t]:t}function ER(e,t){return _R(e,t.toLowerCase())}const S6=Hc({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:pc,acceptCharset:mn,accessKey:mn,action:null,allow:null,allowFullScreen:vt,allowPaymentRequest:vt,allowUserMedia:vt,alt:null,as:null,async:vt,autoCapitalize:null,autoComplete:mn,autoFocus:vt,autoPlay:vt,blocking:mn,capture:null,charSet:null,checked:vt,cite:null,className:mn,cols:Ie,colSpan:null,content:null,contentEditable:Yn,controls:vt,controlsList:mn,coords:Ie|pc,crossOrigin:null,data:null,dateTime:null,decoding:null,default:vt,defer:vt,dir:null,dirName:null,disabled:vt,download:qx,draggable:Yn,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:vt,formTarget:null,headers:mn,height:Ie,hidden:qx,high:Ie,href:null,hrefLang:null,htmlFor:mn,httpEquiv:mn,id:null,imageSizes:null,imageSrcSet:null,inert:vt,inputMode:null,integrity:null,is:null,isMap:vt,itemId:null,itemProp:mn,itemRef:mn,itemScope:vt,itemType:mn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:vt,low:Ie,manifest:null,max:null,maxLength:Ie,media:null,method:null,min:null,minLength:Ie,multiple:vt,muted:vt,name:null,nonce:null,noModule:vt,noValidate:vt,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:vt,optimum:Ie,pattern:null,ping:mn,placeholder:null,playsInline:vt,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:vt,referrerPolicy:null,rel:mn,required:vt,reversed:vt,rows:Ie,rowSpan:Ie,sandbox:mn,scope:null,scoped:vt,seamless:vt,selected:vt,shadowRootClonable:vt,shadowRootDelegatesFocus:vt,shadowRootMode:null,shape:null,size:Ie,sizes:null,slot:null,span:Ie,spellCheck:Yn,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:vt,useMap:null,value:Yn,width:Ie,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:mn,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:vt,declare:vt,event:null,face:null,frame:null,frameBorder:null,hSpace:Ie,leftMargin:Ie,link:null,longDesc:null,lowSrc:null,marginHeight:Ie,marginWidth:Ie,noResize:vt,noHref:vt,noShade:vt,noWrap:vt,object:null,profile:null,prompt:null,rev:null,rightMargin:Ie,rules:null,scheme:null,scrolling:Yn,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:vt,disableRemotePlayback:vt,prefix:null,property:null,results:Ie,security:null,unselectable:null},space:"html",transform:ER}),j6=Hc({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:mn,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:vt,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:pc,g2:pc,glyphName:pc,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:mn,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:_R}),AR=Hc({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()}}),PR=Hc({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:ER}),IR=Hc({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),N6={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"},C6=/[A-Z]/g,u1=/-[a-z]/g,_6=/^data[-\w.:]+$/i;function E6(e,t){const n=Kx(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"&&_6.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(u1,P6);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!u1.test(o)){let a=o.replace(C6,A6);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=Kk}return new s(r,t)}function A6(e){return"-"+e.toLowerCase()}function P6(e){return e.charAt(1).toUpperCase()}const I6=NR([CR,S6,AR,PR,IR],"html"),qk=NR([CR,j6,AR,PR,IR],"svg");function R6(e){return e.join(" ").trim()}var Uk={},d1=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,T6=/\n/g,M6=/^\s*/,$6=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,L6=/^:\s*/,O6=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,D6=/^[;\s]*/,F6=/^\s+|\s+$/g,z6=`
|
|
67
|
-
`,f1="/",p1="*",_a="",B6="comment",H6="declaration";function W6(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(T6);v&&(n+=v.length);var w=y.lastIndexOf(z6);r=~w?y.length-w: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 w=v[0];return s(w),e=e.slice(w.length),v}}function u(){c(M6)}function d(y){var v;for(y=y||[];v=f();)v!==!1&&y.push(v);return y}function f(){var y=o();if(!(f1!=e.charAt(0)||p1!=e.charAt(1))){for(var v=2;_a!=e.charAt(v)&&(p1!=e.charAt(v)||f1!=e.charAt(v+1));)++v;if(v+=2,_a===e.charAt(v-1))return l("End of comment missing");var w=e.slice(2,v-2);return r+=2,s(w),e=e.slice(v),r+=2,y({type:B6,comment:w})}}function p(){var y=o(),v=c($6);if(v){if(f(),!c(L6))return l("property missing ':'");var w=c(O6),g=y({type:H6,property:h1(v[0].replace(d1,_a)),value:w?h1(w[0].replace(d1,_a)):_a});return c(D6),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 h1(e){return e?e.replace(F6,_a):_a}var V6=W6,K6=gd&&gd.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(Uk,"__esModule",{value:!0});Uk.default=U6;const q6=K6(V6);function U6(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,q6.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 sg={};Object.defineProperty(sg,"__esModule",{value:!0});sg.camelCase=void 0;var Y6=/^--[a-zA-Z0-9_-]+$/,G6=/-([a-z])/g,J6=/^[^-]+$/,X6=/^-(webkit|moz|ms|o|khtml)-/,Q6=/^-(ms)-/,Z6=function(e){return!e||J6.test(e)||Y6.test(e)},e8=function(e,t){return t.toUpperCase()},m1=function(e,t){return"".concat(t,"-")},t8=function(e,t){return t===void 0&&(t={}),Z6(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(Q6,m1):e=e.replace(X6,m1),e.replace(G6,e8))};sg.camelCase=t8;var n8=gd&&gd.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},r8=n8(Uk),s8=sg;function Yx(e,t){var n={};return!e||typeof e!="string"||(0,r8.default)(e,function(r,s){r&&s&&(n[(0,s8.camelCase)(r,t)]=s)}),n}Yx.default=Yx;var i8=Yx;const o8=ia(i8),RR=TR("end"),Yk=TR("start");function TR(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 a8(e){const t=Yk(e),n=RR(e);if(t&&n)return{start:t,end:n}}function ud(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?g1(e.position):"start"in e||"end"in e?g1(e):"line"in e||"column"in e?Gx(e):""}function Gx(e){return y1(e&&e.line)+":"+y1(e&&e.column)}function g1(e){return Gx(e&&e.start)+"-"+Gx(e&&e.end)}function y1(e){return e&&typeof e=="number"?e:1}class Ar 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=ud(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}}Ar.prototype.file="";Ar.prototype.name="";Ar.prototype.reason="";Ar.prototype.message="";Ar.prototype.stack="";Ar.prototype.column=void 0;Ar.prototype.line=void 0;Ar.prototype.ancestors=void 0;Ar.prototype.cause=void 0;Ar.prototype.fatal=void 0;Ar.prototype.place=void 0;Ar.prototype.ruleId=void 0;Ar.prototype.source=void 0;const Gk={}.hasOwnProperty,l8=new Map,c8=/[A-Z]/g,u8=new Set(["table","tbody","thead","tfoot","tr"]),d8=new Set(["td","th"]),MR="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function f8(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=b8(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=x8(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"?qk:I6,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=$R(s,e,void 0);return o&&typeof o!="string"?o:s.create(e,s.Fragment,{children:o||void 0},void 0)}function $R(e,t,n){if(t.type==="element")return p8(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return h8(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return g8(e,t,n);if(t.type==="mdxjsEsm")return m8(e,t);if(t.type==="root")return y8(e,t,n);if(t.type==="text")return w8(e,t)}function p8(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=qk,e.schema=s),e.ancestors.push(t);const o=OR(e,t.tagName,!1),a=k8(e,t);let l=Xk(e,t);return u8.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!k6(c):!0})),LR(e,a,o,t),Jk(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function h8(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)}Wd(e,t.position)}function m8(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Wd(e,t.position)}function g8(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=qk,e.schema=s),e.ancestors.push(t);const o=t.name===null?e.Fragment:OR(e,t.name,!0),a=v8(e,t),l=Xk(e,t);return LR(e,a,o,t),Jk(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function y8(e,t,n){const r={};return Jk(r,Xk(e,t)),e.create(t,e.Fragment,r,n)}function w8(e,t){return t.value}function LR(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Jk(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function x8(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 b8(e,t){return n;function n(r,s,o,a){const l=Array.isArray(o.children),c=Yk(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 k8(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&Gk.call(t.properties,s)){const o=S8(e,s,t.properties[s]);if(o){const[a,l]=o;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&d8.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 v8(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 Wd(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 Wd(e,t.position);else o=r.value===null?!0:r.value;n[s]=o}return n}function Xk(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:l8;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=$R(e,o,a);l!==void 0&&n.push(l)}return n}function S8(e,t,n){const r=E6(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?g6(n):R6(n)),r.property==="style"){let s=typeof n=="object"?n:j8(e,String(n));return e.stylePropertyNameCase==="css"&&(s=N8(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?N6[r.property]||r.property:r.attribute,n]}}function j8(e,t){try{return o8(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new Ar("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=MR+"#cannot-parse-style-attribute",s}}function OR(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=a1(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=a1(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return Gk.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Wd(e)}function Wd(e,t){const n=new Ar("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=MR+"#cannot-handle-mdx-estrees-without-createevaluater",n}function N8(e){const t={};let n;for(n in e)Gk.call(e,n)&&(t[C8(n)]=e[n]);return t}function C8(e){let t=e.replace(c8,_8);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function _8(e){return"-"+e.toLowerCase()}const Uy={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"]},E8={};function A8(e,t){const n=E8,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return DR(e,r,s)}function DR(e,t,n){if(P8(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 w1(e.children,t,n)}return Array.isArray(e)?w1(e,t,n):""}function w1(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=DR(e[s],t,n);return r.join("")}function P8(e){return!!(e&&typeof e=="object")}const x1=document.createElement("i");function Qk(e){const t="&"+e+";";x1.innerHTML=t;const n=x1.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 Es(e,t){return e.length>0?(Ri(e,e.length,0,t),e):t}const b1={}.hasOwnProperty;function I8(e){const t={};let n=-1;for(;++n<e.length;)R8(t,e[n]);return t}function R8(e,t){let n;for(n in t){const s=(b1.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){b1.call(s,a)||(s[a]=[]);const l=o[a];T8(s[a],Array.isArray(l)?l:l?[l]:[])}}}function T8(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 FR(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 hc(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const ki=ca(/[A-Za-z]/),cs=ca(/[\dA-Za-z]/),M8=ca(/[#-'*+\--9=?A-Z^-~]/);function Jx(e){return e!==null&&(e<32||e===127)}const Xx=ca(/\d/),$8=ca(/[\dA-Fa-f]/),L8=ca(/[!-/:-@[-`{-~]/);function yt(e){return e!==null&&e<-2}function Zr(e){return e!==null&&(e<0||e===32)}function Zt(e){return e===-2||e===-1||e===32}const O8=ca(new RegExp("\\p{P}|\\p{S}","u")),D8=ca(/\s/);function ca(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Wc(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 yn(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(c){return Zt(c)?(e.enter(n),l(c)):t(c)}function l(c){return Zt(c)&&o++<s?(e.consume(c),l):(e.exit(n),t(c))}}const F8={tokenize:z8};function z8(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"),yn(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 yt(l)?(e.consume(l),e.exit("chunkText"),o):(e.consume(l),a)}}const B8={tokenize:H8},k1={tokenize:W8};function H8(e){const t=this,n=[];let r=0,s,o,a;return l;function l(b){if(r<n.length){const j=n[r];return t.containerState=j[1],e.attempt(j[0].continuation,c,u)(b)}return u(b)}function c(b){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&k();const j=t.events.length;let N=j,C;for(;N--;)if(t.events[N][0]==="exit"&&t.events[N][1].type==="chunkFlow"){C=t.events[N][1].end;break}g(r);let I=j;for(;I<t.events.length;)t.events[I][1].end={...C},I++;return Ri(t.events,N+1,0,t.events.slice(j)),t.events.length=I,u(b)}return l(b)}function u(b){if(r===n.length){if(!s)return p(b);if(s.currentConstruct&&s.currentConstruct.concrete)return y(b);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(k1,d,f)(b)}function d(b){return s&&k(),g(r),p(b)}function f(b){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,y(b)}function p(b){return t.containerState={},e.attempt(k1,h,y)(b)}function h(b){return r++,n.push([t.currentConstruct,t.containerState]),p(b)}function y(b){if(b===null){s&&k(),g(0),e.consume(b);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:o}),v(b)}function v(b){if(b===null){w(e.exit("chunkFlow"),!0),g(0),e.consume(b);return}return yt(b)?(e.consume(b),w(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(b),v)}function w(b,j){const N=t.sliceStream(b);if(j&&N.push(null),b.previous=o,o&&(o.next=b),o=b,s.defineSkip(b.start),s.write(N),t.parser.lazy[b.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 I=t.events.length;let R=I,H,A;for(;R--;)if(t.events[R][0]==="exit"&&t.events[R][1].type==="chunkFlow"){if(H){A=t.events[R][1].end;break}H=!0}for(g(r),C=I;C<t.events.length;)t.events[C][1].end={...A},C++;Ri(t.events,R+1,0,t.events.slice(I)),t.events.length=C}}function g(b){let j=n.length;for(;j-- >b;){const N=n[j];t.containerState=N[1],N[0].exit.call(t,e)}n.length=b}function k(){s.write([null]),o=void 0,s=void 0,t.containerState._closeFlow=void 0}}function W8(e,t,n){return yn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function v1(e){if(e===null||Zr(e)||D8(e))return 1;if(O8(e))return 2}function Zk(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 Qx={name:"attention",resolveAll:V8,tokenize:K8};function V8(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};S1(f,-c),S1(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=Es(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Es(u,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",o,t]]),u=Es(u,Zk(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Es(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=Es(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 K8(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=v1(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=v1(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 S1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const q8={name:"autolink",tokenize:U8};function U8(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||Jx(h)?n(h):(e.consume(h),c)}function u(h){return h===64?(e.consume(h),d):M8(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 ig={partial:!0,tokenize:Y8};function Y8(e,t,n){return r;function r(o){return Zt(o)?yn(e,s,"linePrefix")(o):s(o)}function s(o){return o===null||yt(o)?t(o):n(o)}}const zR={continuation:{tokenize:J8},exit:X8,name:"blockQuote",tokenize:G8};function G8(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 Zt(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function J8(e,t,n){const r=this;return s;function s(a){return Zt(a)?yn(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(zR,t,n)(a)}}function X8(e){e.exit("blockQuote")}const BR={name:"characterEscape",tokenize:Q8};function Q8(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 L8(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const HR={name:"characterReference",tokenize:Z8};function Z8(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=Xx,d(f))}function d(f){if(f===59&&s){const p=e.exit("characterReferenceValue");return a===cs&&!Qk(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 j1={partial:!0,tokenize:t9},N1={concrete:!0,name:"codeFenced",tokenize:e9};function e9(e,t,n){const r=this,s={partial:!0,tokenize:N};let o=0,a=0,l;return c;function c(C){return u(C)}function u(C){const I=r.events[r.events.length-1];return o=I&&I[1].type==="linePrefix"?I[2].sliceSerialize(I[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"),Zt(C)?yn(e,f,"whitespace")(C):f(C))}function f(C){return C===null||yt(C)?(e.exit("codeFencedFence"),r.interrupt?t(C):e.check(j1,v,j)(C)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(C))}function p(C){return C===null||yt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),f(C)):Zt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),yn(e,h,"whitespace")(C)):C===96&&C===l?n(C):(e.consume(C),p)}function h(C){return C===null||yt(C)?f(C):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(C))}function y(C){return C===null||yt(C)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),f(C)):C===96&&C===l?n(C):(e.consume(C),y)}function v(C){return e.attempt(s,j,w)(C)}function w(C){return e.enter("lineEnding"),e.consume(C),e.exit("lineEnding"),g}function g(C){return o>0&&Zt(C)?yn(e,k,"linePrefix",o+1)(C):k(C)}function k(C){return C===null||yt(C)?e.check(j1,v,j)(C):(e.enter("codeFlowValue"),b(C))}function b(C){return C===null||yt(C)?(e.exit("codeFlowValue"),k(C)):(e.consume(C),b)}function j(C){return e.exit("codeFenced"),t(C)}function N(C,I,R){let H=0;return A;function A(K){return C.enter("lineEnding"),C.consume(K),C.exit("lineEnding"),L}function L(K){return C.enter("codeFencedFence"),Zt(K)?yn(C,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(K):D(K)}function D(K){return K===l?(C.enter("codeFencedFenceSequence"),O(K)):R(K)}function O(K){return K===l?(H++,C.consume(K),O):H>=a?(C.exit("codeFencedFenceSequence"),Zt(K)?yn(C,M,"whitespace")(K):M(K)):R(K)}function M(K){return K===null||yt(K)?(C.exit("codeFencedFence"),I(K)):R(K)}}}function t9(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 Yy={name:"codeIndented",tokenize:r9},n9={partial:!0,tokenize:s9};function r9(e,t,n){const r=this;return s;function s(u){return e.enter("codeIndented"),yn(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):yt(u)?e.attempt(n9,a,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||yt(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function s9(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):yt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):yn(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):yt(a)?s(a):n(a)}}const i9={name:"codeText",previous:a9,resolve:o9,tokenize:l9};function o9(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 a9(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function l9(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)):yt(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||yt(f)?(e.exit("codeTextData"),c(f)):(e.consume(f),u)}function d(f){return f===96?(e.consume(f),s++,d):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(f)):(o.type="codeTextData",u(f))}}class c9{constructor(t){this.left=t?[...t]:[],this.right=[]}get(t){if(t<0||t>=this.left.length+this.right.length)throw new RangeError("Cannot access index `"+t+"` in a splice buffer of size `"+(this.left.length+this.right.length)+"`");return t<this.left.length?this.left[t]:this.right[this.right.length-t+this.left.length-1]}get length(){return this.left.length+this.right.length}shift(){return this.setCursor(0),this.right.pop()}slice(t,n){const r=n??Number.POSITIVE_INFINITY;return r<this.left.length?this.left.slice(t,r):t>this.left.length?this.right.slice(this.right.length-r+this.left.length,this.right.length-t+this.left.length).reverse():this.left.slice(t).concat(this.right.slice(this.right.length-r+this.left.length).reverse())}splice(t,n,r){const s=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&Pu(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),Pu(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Pu(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);Pu(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Pu(this.left,n.reverse())}}}function Pu(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 WR(e){const t={};let n=-1,r,s,o,a,l,c,u;const d=new c9(e);for(;++n<d.length;){for(;n in t;)n=t[n];if(r=d.get(n),n&&r[1].type==="chunkFlow"&&d.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,o=0,o<c.length&&c[o][1].type==="lineEndingBlank"&&(o+=2),o<c.length&&c[o][1].type==="content"))for(;++o<c.length&&c[o][1].type!=="content";)c[o][1].type==="chunkText"&&(c[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,u9(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 u9(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 w=[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,w.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):w.pop(),p=w.length;p--;){const g=l.slice(w[p],w[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 d9={resolve:p9,tokenize:h9},f9={partial:!0,tokenize:m9};function p9(e){return WR(e),e}function h9(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):yt(l)?e.check(f9,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 m9(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),yn(e,o,"linePrefix")}function o(a){if(a===null||yt(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 VR(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||Jx(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||yt(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||Jx(g)?n(g):(e.consume(g),g===92?w:v)}function w(g){return g===40||g===41||g===92?(e.consume(g),v):v(g)}}function KR(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):yt(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||yt(h)||l++>999?(e.exit("chunkString"),d(h)):(e.consume(h),c||(c=!Zt(h)),h===92?p:f)}function p(h){return h===91||h===92||h===93?(e.consume(h),l++,f):f(h)}}function qR(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):yt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),yn(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),d(p))}function d(p){return p===a||p===null||yt(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 dd(e,t){let n;return r;function r(s){return yt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):Zt(s)?yn(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const g9={name:"definition",tokenize:w9},y9={partial:!0,tokenize:x9};function w9(e,t,n){const r=this;let s;return o;function o(h){return e.enter("definition"),a(h)}function a(h){return KR.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(h)}function l(h){return s=hc(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)?dd(e,u)(h):u(h)}function u(h){return VR(e,d,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(h)}function d(h){return e.attempt(y9,f,f)(h)}function f(h){return Zt(h)?yn(e,p,"whitespace")(h):p(h)}function p(h){return h===null||yt(h)?(e.exit("definition"),r.parser.defined.push(s),t(h)):n(h)}}function x9(e,t,n){return r;function r(l){return Zr(l)?dd(e,s)(l):n(l)}function s(l){return qR(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return Zt(l)?yn(e,a,"whitespace")(l):a(l)}function a(l){return l===null||yt(l)?t(l):n(l)}}const b9={name:"hardBreakEscape",tokenize:k9};function k9(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),s}function s(o){return yt(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const v9={name:"headingAtx",resolve:S9,tokenize:j9};function S9(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 j9(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||yt(d)?(e.exit("atxHeading"),t(d)):Zt(d)?yn(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 N9=["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"],C1=["pre","script","style","textarea"],C9={concrete:!0,name:"htmlFlow",resolveTo:A9,tokenize:P9},_9={partial:!0,tokenize:R9},E9={partial:!0,tokenize:I9};function A9(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 P9(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),w):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:D:y):n(B)}function v(B){return ki(B)?(e.consume(B),a=String.fromCharCode(B),w):n(B)}function w(B){if(B===null||B===47||B===62||Zr(B)){const se=B===47,ue=a.toLowerCase();return!se&&!o&&C1.includes(ue)?(s=1,r.interrupt?t(B):D(B)):N9.includes(a.toLowerCase())?(s=6,se?(e.consume(B),g):r.interrupt?t(B):D(B)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):o?k(B):b(B))}return B===45||cs(B)?(e.consume(B),a+=String.fromCharCode(B),w):n(B)}function g(B){return B===62?(e.consume(B),r.interrupt?t:D):n(B)}function k(B){return Zt(B)?(e.consume(B),k):A(B)}function b(B){return B===47?(e.consume(B),A):B===58||B===95||ki(B)?(e.consume(B),j):Zt(B)?(e.consume(B),b):A(B)}function j(B){return B===45||B===46||B===58||B===95||cs(B)?(e.consume(B),j):N(B)}function N(B){return B===61?(e.consume(B),C):Zt(B)?(e.consume(B),N):b(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,I):Zt(B)?(e.consume(B),C):R(B)}function I(B){return B===c?(e.consume(B),c=null,H):B===null||yt(B)?n(B):(e.consume(B),I)}function R(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||Zr(B)?N(B):(e.consume(B),R)}function H(B){return B===47||B===62||Zt(B)?b(B):n(B)}function A(B){return B===62?(e.consume(B),L):n(B)}function L(B){return B===null||yt(B)?D(B):Zt(B)?(e.consume(B),L):n(B)}function D(B){return B===45&&s===2?(e.consume(B),z):B===60&&s===1?(e.consume(B),F):B===62&&s===4?(e.consume(B),Q):B===63&&s===3?(e.consume(B),E):B===93&&s===5?(e.consume(B),W):yt(B)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(_9,V,O)(B)):B===null||yt(B)?(e.exit("htmlFlowData"),O(B)):(e.consume(B),D)}function O(B){return e.check(E9,M,V)(B)}function M(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),K}function K(B){return B===null||yt(B)?O(B):(e.enter("htmlFlowData"),D(B))}function z(B){return B===45?(e.consume(B),E):D(B)}function F(B){return B===47?(e.consume(B),a="",$):D(B)}function $(B){if(B===62){const se=a.toLowerCase();return C1.includes(se)?(e.consume(B),Q):D(B)}return ki(B)&&a.length<8?(e.consume(B),a+=String.fromCharCode(B),$):D(B)}function W(B){return B===93?(e.consume(B),E):D(B)}function E(B){return B===62?(e.consume(B),Q):B===45&&s===2?(e.consume(B),E):D(B)}function Q(B){return B===null||yt(B)?(e.exit("htmlFlowData"),V(B)):(e.consume(B),Q)}function V(B){return e.exit("htmlFlow"),t(B)}}function I9(e,t,n){const r=this;return s;function s(a){return yt(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 R9(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(ig,t,n)}}const T9={name:"htmlText",tokenize:M9};function M9(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),N):E===63?(e.consume(E),b):ki(E)?(e.consume(E),R):n(E)}function u(E){return E===45?(e.consume(E),d):E===91?(e.consume(E),o=0,y):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):yt(E)?(a=f,F(E)):(e.consume(E),f)}function p(E){return E===45?(e.consume(E),h):f(E)}function h(E){return E===62?z(E):E===45?p(E):f(E)}function y(E){const Q="CDATA[";return E===Q.charCodeAt(o++)?(e.consume(E),o===Q.length?v:y):n(E)}function v(E){return E===null?n(E):E===93?(e.consume(E),w):yt(E)?(a=v,F(E)):(e.consume(E),v)}function w(E){return E===93?(e.consume(E),g):v(E)}function g(E){return E===62?z(E):E===93?(e.consume(E),g):v(E)}function k(E){return E===null||E===62?z(E):yt(E)?(a=k,F(E)):(e.consume(E),k)}function b(E){return E===null?n(E):E===63?(e.consume(E),j):yt(E)?(a=b,F(E)):(e.consume(E),b)}function j(E){return E===62?z(E):b(E)}function N(E){return ki(E)?(e.consume(E),C):n(E)}function C(E){return E===45||cs(E)?(e.consume(E),C):I(E)}function I(E){return yt(E)?(a=I,F(E)):Zt(E)?(e.consume(E),I):z(E)}function R(E){return E===45||cs(E)?(e.consume(E),R):E===47||E===62||Zr(E)?H(E):n(E)}function H(E){return E===47?(e.consume(E),z):E===58||E===95||ki(E)?(e.consume(E),A):yt(E)?(a=H,F(E)):Zt(E)?(e.consume(E),H):z(E)}function A(E){return E===45||E===46||E===58||E===95||cs(E)?(e.consume(E),A):L(E)}function L(E){return E===61?(e.consume(E),D):yt(E)?(a=L,F(E)):Zt(E)?(e.consume(E),L):H(E)}function D(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),s=E,O):yt(E)?(a=D,F(E)):Zt(E)?(e.consume(E),D):(e.consume(E),M)}function O(E){return E===s?(e.consume(E),s=void 0,K):E===null?n(E):yt(E)?(a=O,F(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)?H(E):(e.consume(E),M)}function K(E){return E===47||E===62||Zr(E)?H(E):n(E)}function z(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function F(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),$}function $(E){return Zt(E)?yn(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 ev={name:"labelEnd",resolveAll:D9,resolveTo:F9,tokenize:z9},$9={tokenize:B9},L9={tokenize:H9},O9={tokenize:W9};function D9(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 F9(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=Es(l,e.slice(o+1,o+r+3)),l=Es(l,[["enter",d,t]]),l=Es(l,Zk(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),l=Es(l,[["exit",d,t],e[a-2],e[a-1],["exit",u,t]]),l=Es(l,e.slice(a+1)),l=Es(l,[["exit",c,t]]),Ri(e,o,e.length,l),e}function z9(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(hc(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(L9,d,a?u:f)(p):a?d(p):f(p)}function u(p){return e.attempt(O9,d,f)(p)}function d(p){return t(p)}function f(p){return o._balanced=!0,n(p)}}function B9(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)?dd(e,o)(f):o(f)}function o(f){return f===41?d(f):VR(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(f)}function a(f){return Zr(f)?dd(e,c)(f):d(f)}function l(f){return n(f)}function c(f){return f===34||f===39||f===40?qR(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(f):d(f)}function u(f){return Zr(f)?dd(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 H9(e,t,n){const r=this;return s;function s(l){return KR.call(r,e,o,a,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(hc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function W9(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 V9={name:"labelStartImage",resolveAll:ev.resolveAll,tokenize:K9};function K9(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 q9={name:"labelStartLink",resolveAll:ev.resolveAll,tokenize:U9};function U9(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 Gy={name:"lineEnding",tokenize:Y9};function Y9(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),yn(e,t,"linePrefix")}}const ph={name:"thematicBreak",tokenize:G9};function G9(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||yt(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===s?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),Zt(u)?yn(e,l,"whitespace")(u):l(u))}}const Vr={continuation:{tokenize:Z9},exit:tV,name:"list",tokenize:Q9},J9={partial:!0,tokenize:nV},X9={partial:!0,tokenize:eV};function Q9(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:Xx(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(ph,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 Xx(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(ig,r.interrupt?n:d,e.attempt(J9,p,f))}function d(h){return r.containerState.initialBlankLine=!0,o++,p(h)}function f(h){return Zt(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 Z9(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(ig,s,o);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,yn(e,t,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!Zt(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(X9,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,yn(e,e.attempt(Vr,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function eV(e,t,n){const r=this;return yn(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 tV(e){e.exit(this.containerState.type)}function nV(e,t,n){const r=this;return yn(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!Zt(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const _1={name:"setextUnderline",resolveTo:rV,tokenize:sV};function rV(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 sV(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"),Zt(u)?yn(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||yt(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const iV={tokenize:oV};function oV(e){const t=this,n=e.attempt(ig,r,e.attempt(this.parser.constructs.flowInitial,s,yn(e,e.attempt(this.parser.constructs.flow,s,e.attempt(d9,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 aV={resolveAll:YR()},lV=UR("string"),cV=UR("text");function UR(e){return{resolveAll:YR(e==="text"?uV: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 YR(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 uV(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 dV={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:zR},fV={91:g9},pV={[-2]:Yy,[-1]:Yy,32:Yy},hV={35:v9,42:ph,45:[_1,ph],60:C9,61:_1,95:ph,96:N1,126:N1},mV={38:HR,92:BR},gV={[-5]:Gy,[-4]:Gy,[-3]:Gy,33:V9,38:HR,42:Qx,60:[q8,T9],91:q9,92:[b9,BR],93:ev,95:Qx,96:i9},yV={null:[Qx,aV]},wV={null:[42,95]},xV={null:[]},bV=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:wV,contentInitial:fV,disable:xV,document:dV,flow:hV,flowInitial:pV,insideSpan:yV,string:mV,text:gV},Symbol.toStringTag,{value:"Module"}));function kV(e,t,n){let r={_bufferIndex:-1,_index:0,line:n&&n.line||1,column:n&&n.column||1,offset:n&&n.offset||0};const s={},o=[];let a=[],l=[];const c={attempt:I(N),check:I(C),consume:k,enter:b,exit:j,interrupt:I(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(L){return a=Es(a,L),w(),a[a.length-1]!==null?[]:(R(t,0),u.events=Zk(o,u.events,u),u.events)}function p(L,D){return SV(h(L),D)}function h(L){return vV(a,L)}function y(){const{_bufferIndex:L,_index:D,line:O,column:M,offset:K}=r;return{_bufferIndex:L,_index:D,line:O,column:M,offset:K}}function v(L){s[L.line]=L.column,A()}function w(){let L;for(;r._index<a.length;){const D=a[r._index];if(typeof D=="string")for(L=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===L&&r._bufferIndex<D.length;)g(D.charCodeAt(r._bufferIndex));else g(D)}}function g(L){d=d(L)}function k(L){yt(L)?(r.line++,r.column=1,r.offset+=L===-3?2:1,A()):L!==-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=L}function b(L,D){const O=D||{};return O.type=L,O.start=y(),u.events.push(["enter",O,u]),l.push(O),O}function j(L){const D=l.pop();return D.end=y(),u.events.push(["exit",D,u]),D}function N(L,D){R(L,D.from)}function C(L,D){D.restore()}function I(L,D){return O;function O(M,K,z){let F,$,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 F=G,$=0,G.length===0?z:B(G[$])}function B(G){return ee;function ee(te){return E=H(),W=G,G.partial||(u.currentConstruct=G),G.name&&u.parser.constructs.disable.null.includes(G.name)?ue():G.tokenize.call(D?Object.assign(Object.create(u),D):u,c,se,ue)(te)}}function se(G){return L(W,E),K}function ue(G){return E.restore(),++$<F.length?B(F[$]):z}}}function R(L,D){L.resolveAll&&!o.includes(L)&&o.push(L),L.resolve&&Ri(u.events,D,u.events.length-D,L.resolve(u.events.slice(D),u)),L.resolveTo&&(u.events=L.resolveTo(u.events,u))}function H(){const L=y(),D=u.previous,O=u.currentConstruct,M=u.events.length,K=Array.from(l);return{from:M,restore:z};function z(){r=L,u.previous=D,u.currentConstruct=O,u.events.length=M,l=K,A()}}function A(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function vV(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 SV(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 jV(e){const r={constructs:I8([bV,...(e||{}).extensions||[]]),content:s(F8),defined:[],document:s(B8),flow:s(iV),lazy:{},string:s(lV),text:s(cV)};return r;function s(o){return a;function a(l){return kV(r,o,l)}}}function NV(e){for(;!WR(e););return e}const E1=/[\0\t\n\r]/g;function CV(){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(E1.lastIndex=f,u=E1.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 _V=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function EV(e){return e.replace(_V,AV)}function AV(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),o=s===120||s===88;return FR(n.slice(o?2:1),o?16:10)}return Qk(n)||e}const GR={}.hasOwnProperty;function PV(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),IV(n)(NV(jV(n).document().write(CV()(e,t,!0))))}function IV(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(gt),autolinkProtocol:H,autolinkEmail:H,atxHeading:o(Ce),blockQuote:o(Z),characterEscape:H,characterReference:H,codeFenced:o(ce),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(ce,a),codeText:o(de,a),codeTextData:H,data:H,codeFlowValue:H,definition:o(me),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o($e),hardBreakEscape:o(_e),hardBreakTrailing:o(_e),htmlFlow:o(Be,a),htmlFlowData:H,htmlText:o(Be,a),htmlTextData:H,image:o(ot),label:a,link:o(gt),listItem:o(st),listItemValue:p,listOrdered:o(Te,f),listUnordered:o(Te),paragraph:o(mt),reference:B,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Ce),strong:o(Tt),thematicBreak:o(Oe)},exit:{atxHeading:c(),atxHeadingSequence:N,autolink:c(),autolinkEmail:ne,autolinkProtocol:te,blockQuote:c(),characterEscapeValue:A,characterReferenceMarkerHexadecimal:ue,characterReferenceMarkerNumeric:ue,characterReferenceValue:G,characterReference:ee,codeFenced:c(w),codeFencedFence:v,codeFencedFenceInfo:h,codeFencedFenceMeta:y,codeFlowValue:A,codeIndented:c(g),codeText:c(K),codeTextData:A,data:A,definition:c(),definitionDestinationString:j,definitionLabelString:k,definitionTitleString:b,emphasis:c(),hardBreakEscape:c(D),hardBreakTrailing:c(D),htmlFlow:c(O),htmlFlowData:A,htmlText:c(M),htmlTextData:A,image:c(F),label:W,labelText:$,lineEnding:L,link:c(z),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:se,resourceDestinationString:E,resourceTitleString:Q,resource:V,setextHeading:c(R),setextHeadingLineSequence:I,setextHeadingText:C,strong:c(),thematicBreak:c()}};JR(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ie){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<ie.length;)if(ie[be][1].type==="listOrdered"||ie[be][1].type==="listUnordered")if(ie[be][0]==="enter")Ue.push(be);else{const It=Ue.pop();be=s(ie,It,be)}for(be=-1;++be<ie.length;){const It=t[ie[be][0]];GR.call(It,ie[be][1].type)&&It[ie[be][1].type].call(Object.assign({sliceSerialize:ie[be][2].sliceSerialize},Ke),ie[be][1])}if(Ke.tokenStack.length>0){const It=Ke.tokenStack[Ke.tokenStack.length-1];(It[1]||A1).call(Ke,void 0,It[0])}for(ke.position={start:Ao(ie.length>0?ie[0][1].start:{line:1,column:1,offset:0}),end:Ao(ie.length>0?ie[ie.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(ie,ke,Ke){let Ue=ke-1,be=-1,It=!1,nn,Vt,Ot,ln;for(;++Ue<=Ke;){const re=ie[Ue];switch(re[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{re[0]==="enter"?be++:be--,ln=void 0;break}case"lineEndingBlank":{re[0]==="enter"&&(nn&&!ln&&!be&&!Ot&&(Ot=Ue),ln=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:ln=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(nn){let Re=Ue;for(Vt=void 0;Re--;){const Je=ie[Re];if(Je[1].type==="lineEnding"||Je[1].type==="lineEndingBlank"){if(Je[0]==="exit")continue;Vt&&(ie[Vt][1].type="lineEndingBlank",It=!0),Je[1].type="lineEnding",Vt=Re}else if(!(Je[1].type==="linePrefix"||Je[1].type==="blockQuotePrefix"||Je[1].type==="blockQuotePrefixWhitespace"||Je[1].type==="blockQuoteMarker"||Je[1].type==="listItemIndent"))break}Ot&&(!Vt||Ot<Vt)&&(nn._spread=!0),nn.end=Object.assign({},Vt?ie[Vt][1].start:re[1].end),ie.splice(Vt||Ue,0,["exit",nn,re[2]]),Ue++,Ke++}if(re[1].type==="listItemPrefix"){const Re={type:"listItem",_spread:!1,start:Object.assign({},re[1].start),end:void 0};nn=Re,ie.splice(Ue,0,["enter",Re,re[2]]),Ue++,Ke++,Ot=void 0,ln=!0}}}return ie[ke][1]._spread=It,Ke}function o(ie,ke){return Ke;function Ke(Ue){l.call(this,ie(Ue),Ue),ke&&ke.call(this,Ue)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(ie,ke,Ke){this.stack[this.stack.length-1].children.push(ie),this.stack.push(ie),this.tokenStack.push([ke,Ke||void 0]),ie.position={start:Ao(ke.start),end:void 0}}function c(ie){return ke;function ke(Ke){ie&&ie.call(this,Ke),u.call(this,Ke)}}function u(ie,ke){const Ke=this.stack.pop(),Ue=this.tokenStack.pop();if(Ue)Ue[0].type!==ie.type&&(ke?ke.call(this,ie,Ue[0]):(Ue[1]||A1).call(this,ie,Ue[0]));else throw new Error("Cannot close `"+ie.type+"` ("+ud({start:ie.start,end:ie.end})+"): it’s not open");Ke.position.end=Ao(ie.end)}function d(){return A8(this.stack.pop())}function f(){this.data.expectingFirstListItemValue=!0}function p(ie){if(this.data.expectingFirstListItemValue){const ke=this.stack[this.stack.length-2];ke.start=Number.parseInt(this.sliceSerialize(ie),10),this.data.expectingFirstListItemValue=void 0}}function h(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.lang=ie}function y(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.meta=ie}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function w(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ie.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ie.replace(/(\r?\n|\r)$/g,"")}function k(ie){const ke=this.resume(),Ke=this.stack[this.stack.length-1];Ke.label=ke,Ke.identifier=hc(this.sliceSerialize(ie)).toLowerCase()}function b(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.title=ie}function j(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.url=ie}function N(ie){const ke=this.stack[this.stack.length-1];if(!ke.depth){const Ke=this.sliceSerialize(ie).length;ke.depth=Ke}}function C(){this.data.setextHeadingSlurpLineEnding=!0}function I(ie){const ke=this.stack[this.stack.length-1];ke.depth=this.sliceSerialize(ie).codePointAt(0)===61?1:2}function R(){this.data.setextHeadingSlurpLineEnding=void 0}function H(ie){const Ke=this.stack[this.stack.length-1].children;let Ue=Ke[Ke.length-1];(!Ue||Ue.type!=="text")&&(Ue=xe(),Ue.position={start:Ao(ie.start),end:void 0},Ke.push(Ue)),this.stack.push(Ue)}function A(ie){const ke=this.stack.pop();ke.value+=this.sliceSerialize(ie),ke.position.end=Ao(ie.end)}function L(ie){const ke=this.stack[this.stack.length-1];if(this.data.atHardBreak){const Ke=ke.children[ke.children.length-1];Ke.position.end=Ao(ie.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ke.type)&&(H.call(this,ie),A.call(this,ie))}function D(){this.data.atHardBreak=!0}function O(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ie}function M(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ie}function K(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.value=ie}function z(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=ke,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function F(){const ie=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";ie.type+="Reference",ie.referenceType=ke,delete ie.url,delete ie.title}else delete ie.identifier,delete ie.label;this.data.referenceType=void 0}function $(ie){const ke=this.sliceSerialize(ie),Ke=this.stack[this.stack.length-2];Ke.label=EV(ke),Ke.identifier=hc(ke).toLowerCase()}function W(){const ie=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=ie.children;Ke.children=Ue}else Ke.alt=ke}function E(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.url=ie}function Q(){const ie=this.resume(),ke=this.stack[this.stack.length-1];ke.title=ie}function V(){this.data.inReference=void 0}function B(){this.data.referenceType="collapsed"}function se(ie){const ke=this.resume(),Ke=this.stack[this.stack.length-1];Ke.label=ke,Ke.identifier=hc(this.sliceSerialize(ie)).toLowerCase(),this.data.referenceType="full"}function ue(ie){this.data.characterReferenceType=ie.type}function G(ie){const ke=this.sliceSerialize(ie),Ke=this.data.characterReferenceType;let Ue;Ke?(Ue=FR(ke,Ke==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):Ue=Qk(ke);const be=this.stack[this.stack.length-1];be.value+=Ue}function ee(ie){const ke=this.stack.pop();ke.position.end=Ao(ie.end)}function te(ie){A.call(this,ie);const ke=this.stack[this.stack.length-1];ke.url=this.sliceSerialize(ie)}function ne(ie){A.call(this,ie);const ke=this.stack[this.stack.length-1];ke.url="mailto:"+this.sliceSerialize(ie)}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 gt(){return{type:"link",title:null,url:"",children:[]}}function Te(ie){return{type:"list",ordered:ie.type==="listOrdered",start:null,spread:ie._spread,children:[]}}function st(ie){return{type:"listItem",spread:ie._spread,checked:null,children:[]}}function mt(){return{type:"paragraph",children:[]}}function Tt(){return{type:"strong",children:[]}}function xe(){return{type:"text",value:""}}function Oe(){return{type:"thematicBreak"}}}function Ao(e){return{line:e.line,column:e.column,offset:e.offset}}function JR(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?JR(e,r):RV(e,r)}}function RV(e,t){let n;for(n in t)if(GR.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 A1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+ud({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+ud({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+ud({start:t.start,end:t.end})+") is still open")}function TV(e){const t=this;t.parser=n;function n(r){return PV(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function MV(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 LV(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 OV(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function DV(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function FV(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=Wc(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 zV(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 BV(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function XR(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 HV(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return XR(e,t);const s={src:Wc(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 WV(e,t){const n={src:Wc(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 VV(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 KV(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return XR(e,t);const s={href:Wc(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 qV(e,t){const n={href:Wc(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 UV(e,t,n){const r=e.all(t),s=n?YV(n):QR(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 YV(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=QR(n[r])}return t}function QR(e){const t=e.spread;return t??e.children.length>1}function GV(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 JV(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function XV(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function QV(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function ZV(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=Yk(t.children[1]),c=RR(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 eK(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 tK(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const P1=9,I1=32;function nK(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const o=[];for(;r;)o.push(R1(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return o.push(R1(t.slice(s),s>0,!1)),o.join("")}function R1(e,t,n){let r=0,s=e.length;if(t){let o=e.codePointAt(r);for(;o===P1||o===I1;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(s-1);for(;o===P1||o===I1;)s--,o=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function rK(e,t){const n={type:"text",value:nK(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function sK(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const iK={blockquote:MV,break:$V,code:LV,delete:OV,emphasis:DV,footnoteReference:FV,heading:zV,html:BV,imageReference:HV,image:WV,inlineCode:VV,linkReference:KV,link:qV,listItem:UV,list:GV,paragraph:JV,root:XV,strong:QV,table:ZV,tableCell:tK,tableRow:eK,text:rK,thematicBreak:sK,toml:Ap,yaml:Ap,definition:Ap,footnoteDefinition:Ap};function Ap(){}const ZR=-1,og=0,fd=1,nm=2,tv=3,nv=4,rv=5,sv=6,eT=7,tT=8,T1=typeof self=="object"?self:globalThis,oK=(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 og:case ZR:return n(a,s);case fd:{const l=n([],s);for(const c of a)l.push(r(c));return l}case nm:{const l=n({},s);for(const[c,u]of a)l[r(c)]=r(u);return l}case tv:return n(new Date(a),s);case nv:{const{source:l,flags:c}=a;return n(new RegExp(l,c),s)}case rv:{const l=n(new Map,s);for(const[c,u]of a)l.set(r(c),r(u));return l}case sv:{const l=n(new Set,s);for(const c of a)l.add(r(c));return l}case eT:{const{name:l,message:c}=a;return n(new T1[l](c),s)}case tT: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 T1[o](a),s)};return r},M1=e=>oK(new Map,e)(0),Tl="",{toString:aK}={},{keys:lK}=Object,Iu=e=>{const t=typeof e;if(t!=="object"||!e)return[og,t];const n=aK.call(e).slice(8,-1);switch(n){case"Array":return[fd,Tl];case"Object":return[nm,Tl];case"Date":return[tv,Tl];case"RegExp":return[nv,Tl];case"Map":return[rv,Tl];case"Set":return[sv,Tl];case"DataView":return[fd,n]}return n.includes("Array")?[fd,n]:n.includes("Error")?[eT,n]:[nm,n]},Pp=([e,t])=>e===og&&(t==="function"||t==="symbol"),cK=(e,t,n,r)=>{const s=(a,l)=>{const c=r.push(a)-1;return n.set(l,c),c},o=a=>{if(n.has(a))return n.get(a);let[l,c]=Iu(a);switch(l){case og:{let d=a;switch(c){case"bigint":l=tT,d=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);d=null;break;case"undefined":return s([ZR],a)}return s([l,d],a)}case fd:{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 nm:{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 lK(a))(e||!Pp(Iu(a[p])))&&d.push([o(p),o(a[p])]);return f}case tv:return s([l,a.toISOString()],a);case nv:{const{source:d,flags:f}=a;return s([l,{source:d,flags:f}],a)}case rv:{const d=[],f=s([l,d],a);for(const[p,h]of a)(e||!(Pp(Iu(p))||Pp(Iu(h))))&&d.push([o(p),o(h)]);return f}case sv:{const d=[],f=s([l,d],a);for(const p of a)(e||!Pp(Iu(p)))&&d.push(o(p));return f}}const{message:u}=a;return s([l,{name:c,message:u}],a)};return o},$1=(e,{json:t,lossy:n}={})=>{const r=[];return cK(!(t||n),!!t,new Map,r)(e),r},rm=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?M1($1(e,t)):structuredClone(e):(e,t)=>M1($1(e,t));function uK(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 dK(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function fK(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||uK,r=e.options.footnoteBackLabel||dK,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=Wc(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 w=d[d.length-1];if(w&&w.type==="element"&&w.tagName==="p"){const k=w.children[w.children.length-1];k&&k.type==="text"?k.value+=" ":w.children.push({type:"text",value:" "}),w.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:{...rm(a),id:"footnote-label"},children:[{type:"text",value:s}]},{type:"text",value:`
|
|
74
|
-
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
|
|
75
|
-
`}]}}const nT=function(e){if(e==null)return gK;if(typeof e=="function")return ag(e);if(typeof e=="object")return Array.isArray(e)?pK(e):hK(e);if(typeof e=="string")return mK(e);throw new Error("Expected function, string, or object as test")};function pK(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=nT(e[n]);return ag(r);function r(...s){let o=-1;for(;++o<t.length;)if(t[o].apply(this,s))return!0;return!1}}function hK(e){const t=e;return ag(n);function n(r){const s=r;let o;for(o in e)if(s[o]!==t[o])return!1;return!0}}function mK(e){return ag(t);function t(n){return n&&n.type===e}}function ag(e){return t;function t(n,r,s){return!!(yK(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function gK(){return!0}function yK(e){return e!==null&&typeof e=="object"&&"type"in e}const rT=[],wK=!0,L1=!1,xK="skip";function bK(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const o=nT(s),a=r?-1:1;l(e,void 0,[])();function l(c,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=rT,y,v,w;if((!t||o(c,u,d[d.length-1]||void 0))&&(h=kK(n(c,d)),h[0]===L1))return h;if("children"in c&&c.children){const g=c;if(g.children&&h[0]!==xK)for(v=(r?g.children.length:-1)+a,w=d.concat(g);v>-1&&v<g.children.length;){const k=g.children[v];if(y=l(k,v,w)(),y[0]===L1)return y;v=typeof y[1]=="number"?y[1]:v+a}}return h}}}function kK(e){return Array.isArray(e)?e:typeof e=="number"?[wK,e]:e==null?rT:[e]}function sT(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),bK(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 Zx={}.hasOwnProperty,vK={};function SK(e,t){const n=t||vK,r=new Map,s=new Map,o=new Map,a={...iK,...n.handlers},l={all:u,applyData:NK,definitionById:r,footnoteById:s,footnoteCounts:o,footnoteOrder:[],handlers:a,one:c,options:n,patch:jK,wrap:_K};return sT(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(Zx.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,...w}=d,g=rm(w);return g.children=l.all(d),g}return rm(d)}return(l.options.unknownHandler||CK)(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=O1(y.value)),!Array.isArray(y)&&y.type==="element")){const v=y.children[0];v&&v.type==="text"&&(v.value=O1(v.value))}Array.isArray(y)?f.push(...y):f.push(y)}}}return f}}function jK(e,t){e.position&&(t.position=a8(e))}function NK(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,rm(o)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function CK(e,t){const n=t.data||{},r="value"in t&&!(Zx.call(n,"hProperties")||Zx.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 _K(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 O1(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function D1(e,t){const n=SK(e,t),r=n.one(e,void 0),s=fK(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 EK(e,t){return e&&"run"in e?async function(n,r){const s=D1(n,{file:r,...t});await e.run(s,r)}:function(n,r){return D1(n,{file:r,...e||t})}}function F1(e){if(e)throw e}var hh=Object.prototype.hasOwnProperty,iT=Object.prototype.toString,z1=Object.defineProperty,B1=Object.getOwnPropertyDescriptor,H1=function(t){return typeof Array.isArray=="function"?Array.isArray(t):iT.call(t)==="[object Array]"},W1=function(t){if(!t||iT.call(t)!=="[object Object]")return!1;var n=hh.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&hh.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||hh.call(t,s)},V1=function(t,n){z1&&n.name==="__proto__"?z1(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},K1=function(t,n){if(n==="__proto__")if(hh.call(t,n)){if(B1)return B1(t,n).value}else return;return t[n]},AK=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=K1(l,n),s=K1(t,n),l!==s&&(d&&s&&(W1(s)||(o=H1(s)))?(o?(o=!1,a=r&&H1(r)?r:[]):a=r&&W1(r)?r:{},V1(l,{name:n,newValue:e(d,a,s)})):typeof s<"u"&&V1(l,{name:n,newValue:s}));return l};const Jy=ia(AK);function eb(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 PK(){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?IK(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 IK(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:RK,dirname:TK,extname:MK,join:$K,sep:"/"};function RK(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');gf(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 TK(e){if(gf(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 MK(e){gf(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;)gf(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":LK(n)}function LK(e){gf(e);const t=e.codePointAt(0)===47;let n=OK(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function OK(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 gf(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const DK={cwd:FK};function FK(){return"/"}function tb(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function zK(e){if(typeof e=="string")e=new URL(e);else if(!tb(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 BK(e)}function BK(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 Xy=["history","path","basename","stem","extname","dirname"];class oT{constructor(t){let n;t?tb(t)?n={path:t}:typeof t=="string"||HK(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":DK.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<Xy.length;){const o=Xy[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)Xy.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?mi.basename(this.path):void 0}set basename(t){Zy(t,"basename"),Qy(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){q1(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(Qy(t,"extname"),q1(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){tb(t)&&(t=zK(t)),Zy(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){Zy(t,"stem"),Qy(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 Ar(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 Qy(e,t){if(e&&e.includes(mi.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+mi.sep+"`")}function Zy(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function q1(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function HK(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const WK=function(e){const r=this.constructor.prototype,s=r[e],o=function(){return s.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},VK={}.hasOwnProperty;class iv extends WK{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=PK()}copy(){const t=new iv;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Jy(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(nw("data",this.frozen),this.namespace[t]=n,this):VK.call(this.namespace,t)&&this.namespace[t]||void 0:t?(nw("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=Ip(t),r=this.parser||this.Parser;return ew("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),ew("process",this.parser||this.Parser),tw("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(o,a){const l=Ip(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);UK(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(),ew("processSync",this.parser||this.Parser),tw("processSync",this.compiler||this.Compiler),this.process(t,s),Y1("processSync","process",n),r;function s(o,a){n=!0,F1(o),r=a}}run(t,n,r){U1(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=Ip(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),Y1("runSync","run",r),s;function o(a,l){F1(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=Ip(n),s=this.compiler||this.Compiler;return tw("stringify",s),U1(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(nw("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=Jy(!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];eb(v)&&eb(h)&&(h=Jy(!0,v,h)),r[p]=[u,h,...y]}}}}const KK=new iv().freeze();function ew(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function tw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function nw(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 U1(e){if(!eb(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function Y1(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function Ip(e){return qK(e)?e:new oT(e)}function qK(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function UK(e){return typeof e=="string"||YK(e)}function YK(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const GK="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",G1=[],J1={allowDangerousHtml:!0},JK=/^(https?|ircs?|mailto|xmpp)$/i,XK=[{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 aT(e){const t=QK(e),n=ZK(e);return e7(t.runSync(t.parse(n),n),e)}function QK(e){const t=e.rehypePlugins||G1,n=e.remarkPlugins||G1,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...J1}:J1;return KK().use(TV).use(n).use(EK,r).use(t)}function ZK(e){const t=e.children||"",n=new oT;return typeof t=="string"&&(n.value=t),n}function e7(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,o=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||t7;for(const d of XK)Object.hasOwn(t,d.from)&&(""+d.from+(d.to?"use `"+d.to+"` instead":"remove it")+GK+d.id,void 0);return sT(e,u),f8(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 Uy)if(Object.hasOwn(Uy,h)&&Object.hasOwn(d.properties,h)){const y=d.properties[h],v=Uy[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 t7(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||JK.test(e.slice(0,t))?e:""}const n7=new Set(["echarts"]),r7=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),s7=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),i7=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function Jo(e){return e&&typeof e=="object"&&!Array.isArray(e)}function Qa(e,t){if(!Jo(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:Jo(n[r])&&Jo(s)&&(n[r]=Qa(n[r],s));return n}function lg(e,t){return e==null?e:Array.isArray(e)?e.map(n=>Jo(n)?Qa(n,t):n):Jo(e)?Qa(e,t):e}function o7(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 nb(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)=>nb(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||s7.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);nb(r,`${t}.${n}`)}}}function a7(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(!r7.has(r))throw new Error(`series.type "${r||"(empty)"}" is not allowed`)}return t}function l7(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:Qa(e,t)}function c7(e,t){const n={left:"center",top:12,textStyle:{color:"rgba(255, 255, 255, 0.9)",fontSize:15,fontWeight:700},subtextStyle:{color:"rgba(255, 255, 255, 0.52)"}};return Array.isArray(e)?e.map((r,s)=>{if(!Jo(r))return r;const o=s===0&&t&&r.text==null?{...r,text:t}:r;return Qa(o,n)}):Jo(e)?Qa(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function u7(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:lg(e,n)}function X1(e,t="rgba(255, 255, 255, 0.62)"){return lg(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 d7(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:lg(e,n)}function f7(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:lg(e,t)}function p7(e,t,n){const r=c7(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>Jo(a)&&a.text),o=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??i7,textStyle:Qa(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:l7(e.tooltip),legend:u7(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?d7(e.grid,s||o):e.grid,xAxis:X1(e.xAxis),yAxis:X1(e.yAxis),radar:f7(e.radar),series:t}}function h7(e){const t=o7(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(!n7.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");nb(n);const r=a7(n.option.series),s=n.title==null?"":String(n.title),o=p7(n.option,r,s);return{ok:!0,spec:{...n,title:s,option:o}}}catch(n){return{ok:!1,error:String((n==null?void 0:n.message)||n)}}}function Rp(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function m7(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("|")&&!Rp(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==="`"&&!Rp(t,o)){const l=m7(t,o);r+=t.slice(o,o+l),s===0?s=l:s===l&&(s=0),o+=l-1;continue}if(s===0&&a==="|"&&!Rp(t,o)){n.push(r.trim()),r="";continue}if(s===0&&a==="\\"&&t[o+1]==="|"&&Rp(t,o+1)){r+="|",o+=1;continue}r+=a}return n.push(r.trim()),n}function lT(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 cT(e){const t=Xi(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function uT(e){return Xi(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function g7(e){return/^\s*(sequenceDiagram|flowchart\s+(?:TD|TB|BT|LR|RL)|graph\s+(?:TD|TB|BT|LR|RL))\b/i.test(String(e||""))}function y7(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 w7({code:e}){const t=m.useMemo(()=>y7(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 x7(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 b7({code:e}){const t=m.useMemo(()=>x7(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),w=(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:w,y:h-8,textAnchor:"middle",children:f.text.slice(0,72)})]},`msg-${p}`)})]})}function dT({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(b7,{code:t}):i.jsx(w7,{code:t})})}function k7(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&&g7(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&&cT(t[a+1])){o();const u=Xi(l),d=uT(t[a+1]),f=[];for(a+=2;a<t.length&&t[a].trim()&&Xi(t[a]).length>1;)f.push(lT(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 Q1(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 fT(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 pT(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=Q1(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(dT,{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(Q1(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 Z1({children:e,resolveSrc:t,basePath:n=""}){return i.jsx(aT,{components:pT(t,!0,n),children:fT(e)})}function ov({content:e,resolveSrc:t,basePath:n=""}){const r=m.useMemo(()=>k7(e),[e]),s=m.useMemo(()=>pT(t,!1,n),[n,t]);return i.jsx(i.Fragment,{children:r.map((o,a)=>o.type==="mermaid"?i.jsx(dT,{code:o.text},`mermaid-${a}`):o.type!=="table"?i.jsx(aT,{components:s,children:fT(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(Z1,{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(Z1,{resolveSrc:t,basePath:n,children:l[d]||""})},d))},c))})]})},`table-${a}`))})}function v7(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 S7(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 j7(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=S7(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&&cT(s[1])){const l=Xi(s[0]),c=uT(s[1]);return{columns:l.map((u,d)=>({key:String(d),label:u,align:c[d]||"left"})),rows:s.slice(2).map(u=>lT(Xi(u),l.length)),error:""}}const o=r.includes(" ")?" ":",",a=v7(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 av({content:e}){const t=m.useMemo(()=>j7(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 lv({content:e}){const t=m.useRef(null),n=m.useMemo(()=>h7(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:""}),m6(()=>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 hT(e){return typeof e>"u"||e===null}function N7(e){return typeof e=="object"&&e!==null}function C7(e){return Array.isArray(e)?e:hT(e)?[]:[e]}function _7(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 E7(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function A7(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var P7=hT,I7=N7,R7=C7,T7=E7,M7=A7,$7=_7,cv={isNothing:P7,isObject:I7,toArray:R7,repeat:T7,isNegativeZero:M7,extend:$7};function mT(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 Vd(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=mT(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Vd.prototype=Object.create(Error.prototype);Vd.prototype.constructor=Vd;Vd.prototype.toString=function(t){return this.name+": "+mT(this,t)};var Ea=Vd,L7=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],O7=["scalar","sequence","mapping"];function D7(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function F7(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(L7.indexOf(n)===-1)throw new Ea('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=D7(t.styleAliases||null),O7.indexOf(this.kind)===-1)throw new Ea('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Cr=F7;function eC(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 z7(){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 rb(e){return this.extend(e)}rb.prototype.extend=function(t){var n=[],r=[];if(t instanceof Cr)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 Ea("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(o){if(!(o instanceof Cr))throw new Ea("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(o.loadKind&&o.loadKind!=="scalar")throw new Ea("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 Ea("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 Cr))throw new Ea("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(rb.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=eC(s,"implicit"),s.compiledExplicit=eC(s,"explicit"),s.compiledTypeMap=z7(s.compiledImplicit,s.compiledExplicit),s};var B7=rb,H7=new Cr("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),W7=new Cr("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),V7=new Cr("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),K7=new B7({explicit:[H7,W7,V7]});function q7(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function U7(){return null}function Y7(e){return e===null}var G7=new Cr("tag:yaml.org,2002:null",{kind:"scalar",resolve:q7,construct:U7,predicate:Y7,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function J7(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 X7(e){return e==="true"||e==="True"||e==="TRUE"}function Q7(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Z7=new Cr("tag:yaml.org,2002:bool",{kind:"scalar",resolve:J7,construct:X7,predicate:Q7,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 eq(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function tq(e){return 48<=e&&e<=55}function nq(e){return 48<=e&&e<=57}function rq(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(!eq(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!tq(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!nq(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function sq(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 iq(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!cv.isNegativeZero(e)}var oq=new Cr("tag:yaml.org,2002:int",{kind:"scalar",resolve:rq,construct:sq,predicate:iq,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"]}}),aq=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function lq(e){return!(e===null||!aq.test(e)||e[e.length-1]==="_")}function cq(e){var t,n;return t=e.replace(/_/g,"").toLowerCase(),n=t[0]==="-"?-1:1,"+-".indexOf(t[0])>=0&&(t=t.slice(1)),t===".inf"?n===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:t===".nan"?NaN:n*parseFloat(t,10)}var uq=/^[-+]?[0-9]+e/;function dq(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(cv.isNegativeZero(e))return"-0.0";return n=e.toString(10),uq.test(n)?n.replace("e",".e"):n}function fq(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||cv.isNegativeZero(e))}var pq=new Cr("tag:yaml.org,2002:float",{kind:"scalar",resolve:lq,construct:cq,predicate:fq,represent:dq,defaultStyle:"lowercase"}),hq=K7.extend({implicit:[G7,Z7,oq,pq]}),mq=hq,gT=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),yT=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 gq(e){return e===null?!1:gT.exec(e)!==null||yT.exec(e)!==null}function yq(e){var t,n,r,s,o,a,l,c=0,u=null,d,f,p;if(t=gT.exec(e),t===null&&(t=yT.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 wq(e){return e.toISOString()}var xq=new Cr("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:gq,construct:yq,instanceOf:Date,represent:wq});function bq(e){return e==="<<"||e===null}var kq=new Cr("tag:yaml.org,2002:merge",{kind:"scalar",resolve:bq}),uv=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
94
|
-
\r`;function vq(e){if(e===null)return!1;var t,n,r=0,s=e.length,o=uv;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 Sq(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,o=uv,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 jq(e){var t="",n=0,r,s,o=e.length,a=uv;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 Nq(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var Cq=new Cr("tag:yaml.org,2002:binary",{kind:"scalar",resolve:vq,construct:Sq,predicate:Nq,represent:jq}),_q=Object.prototype.hasOwnProperty,Eq=Object.prototype.toString;function Aq(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,Eq.call(s)!=="[object Object]")return!1;for(o in s)if(_q.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 Pq(e){return e!==null?e:[]}var Iq=new Cr("tag:yaml.org,2002:omap",{kind:"sequence",resolve:Aq,construct:Pq}),Rq=Object.prototype.toString;function Tq(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],Rq.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;o[t]=[s[0],r[s[0]]]}return!0}function Mq(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 Cr("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:Tq,construct:Mq}),Lq=Object.prototype.hasOwnProperty;function Oq(e){if(e===null)return!0;var t,n=e;for(t in n)if(Lq.call(n,t)&&n[t]!==null)return!1;return!0}function Dq(e){return e!==null?e:{}}var Fq=new Cr("tag:yaml.org,2002:set",{kind:"mapping",resolve:Oq,construct:Dq});mq.extend({implicit:[xq,kq],explicit:[Cq,Iq,$q,Fq]});function tC(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 zq=new Array(256),Bq=new Array(256);for(var Ml=0;Ml<256;Ml++)zq[Ml]=tC(Ml)?1:0,Bq[Ml]=tC(Ml);const Kd=["requirement","planning","code","test","normal"],nC={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"};function dv(e,t){var s,o,a,l,c,u,d,f,p,h,y,v,w,g;const n=k=>{const b={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&&(b.required=!0),(k==null?void 0:k.description)!=null&&String(k.description).trim()&&(b.description=String(k.description)),(k==null?void 0:k.showOnNode)!=null&&(b.showOnNode=!!k.showOnNode),b},r={};for(const k of e){if((s=k==null?void 0:k.data)!=null&&s.isWorkspaceGroup)continue;const b=t[k.id]&&typeof t[k.id]=="object"?{...t[k.id]}:{},j=((o=k.data)==null?void 0:o.definitionId)||k.id,N=((a=k.data)==null?void 0:a.inputs)??[],C=((l=k.data)==null?void 0:l.outputs)??[],I=((c=k.data)==null?void 0:c.role)!=null?String(k.data.role).trim():"",R=b.role!=null?String(b.role).trim():"",H=nC[I]||I,A=nC[R]||R,L=Kd.includes(H)?H:Kd.includes(A)?A:"normal",D=Array.isArray(N)?N.map(n):Array.isArray(b.input)?b.input.map(ue=>n(ue)):[],O=Array.isArray(C)?C.map(n):Array.isArray(b.output)?b.output.map(ue=>n(ue)):[],M=((u=k.data)==null?void 0:u.label)!=null?String(k.data.label):b.label!=null?String(b.label):k.id,K=(d=k.data)==null?void 0:d.body,z=K!=null?String(K):b.body!=null?String(b.body):"";let F=((f=k.data)==null?void 0:f.model)!=null&&String(k.data.model).trim()!==""?String(k.data.model).trim():b.model!=null&&String(b.model).trim()!==""?String(b.model).trim():void 0;(F===""||F==="default")&&(F=void 0);const $={...b,definitionId:j,label:M,role:L,model:F,input:D,output:O},W=((p=k.data)==null?void 0:p.marketplaceRef)||b.marketplaceRef;W?$.marketplaceRef=String(W):delete $.marketplaceRef;const E=((h=k.data)==null?void 0:h.marketplacePackageId)||b.marketplacePackageId;E?$.marketplacePackageId=String(E):delete $.marketplacePackageId;const Q=((y=k.data)==null?void 0:y.marketplaceVersion)||b.marketplaceVersion;Q?$.marketplaceVersion=String(Q):delete $.marketplaceVersion,j.startsWith("provide_")||z.trim()===""?delete $.body:$.body=z;const V=Array.isArray((v=k.data)==null?void 0:v.images)?k.data.images:Array.isArray(b.images)?b.images:[];V.length>0?$.images=V:delete $.images;const B=(w=k.data)==null?void 0:w.script,se=B!=null?String(B):b.script!=null?String(b.script):"";se.trim()===""?delete $.script:$.script=se;for(const ue of["scriptRef","implementationRef","implementationMode"]){const G=(g=k.data)==null?void 0:g[ue],ee=G!=null?String(G):b[ue]!=null?String(b[ue]):"";ee.trim()===""?delete $[ue]:$[ue]=ee.trim()}delete $.temperature,delete $.maxTokens,delete $.description,r[k.id]=$}return r}function pd(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function Hq(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 Wq(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=>pd(a)),edges:o.map(a=>pd(a)),instances:dv(r,n||{})}}function Vq(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,Hq(p.id,a));const c=e.nodes.map(p=>{var y,v;const h=l.get(p.id);return{...pd(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{...pd(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]={...pd(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 Mn(e){switch(sm(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function sm(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 Kq(e,t){const n=sm(e),r=sm(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const qq=new Set(["knowledgeContext","workspaceContext","skillsContext","mcpContext"]);function sb(e){const t=sm(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&qq.has(n)?`${t}+${n}`:t}function Uq(e){return sb(e)}function qd(e,t){if(!e||!t||!Kq(e.type,t.type))return!1;const n=sb(e),r=sb(t),s=n.includes("+"),o=r.includes("+");return s||o?n===r:!0}function Yq(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 ib(e,t,n){var l;const r=n==="source"?"outputs":"inputs",o=Yq(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 im=/\[image\s+(\d+)\]/gi;function ho(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 Gq(e){return`image ${ho(e).length+1}`}function Jq(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function Xq(e,t){const n=ho(e),r=String(t||""),s=new Set;im.lastIndex=0;let o;for(;o=im.exec(r);)s.add(`image ${o[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function Qq(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 wT(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 hd(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 xT({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const o=ho(n);for(const a of r){const l=await Qq(a),c=Gq(o);o.push({id:`${Date.now().toString(36)}-${o.length+1}`,label:c,...l}),s=Jq(s,c)}return{body:s,images:o}}function Ss(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function Zq(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 eU(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function tn(e){e.stopPropagation()}function tU(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nU(e,t){const n=`\\[${tU(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
|
|
96
|
-
`).replace(/\n{3,}/g,`
|
|
97
|
-
|
|
98
|
-
`).trimEnd()}function rw(e){return String(e||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function rU(e){const t=String(e||"");let n="",r=0;im.lastIndex=0;let s;for(;s=im.exec(t);)n+=rw(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${rw(s[0])}</span>`,r=s.index+s[0].length;return n+=rw(t.slice(r)),n||" "}function sU(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 iU({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:o,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:u,deferTextCommit:d=!1}){var Xt,Nt;const{t:f}=zr(),p=(e==null?void 0:e.inputs)??[],h=(e==null?void 0:e.outputs)??[],y=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),v=Zq(e),w=(e==null?void 0:e.isRunMode)??!1,g=!!(e!=null&&e.readOnly),k=(e==null?void 0:e.isExecuting)??!1,b=(e==null?void 0:e.isDim)??!1,j=(e==null?void 0:e.nodeStatus)??null,N=(e==null?void 0:e.nodeElapsed)??null,C=(e==null?void 0:e.definitionId)||"",I=C.startsWith("provide_"),R=C==="provide_bool",H=C==="provide_str",A=C==="provide_file",L=C==="provide_password",D=C==="agent_subAgent",O=C==="control_agent_toBool",M=(D||O)&&!w,K=R?eU(h[0]):!1,z=I?String(((Xt=h[0])==null?void 0:Xt.value)??((Nt=h[0])==null?void 0:Nt.default)??(e==null?void 0:e.body)??""):"",F=String((e==null?void 0:e.body)||""),$=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||f("flow:node.fallbackLabel"),W=!I&&!M&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",E=ho(e==null?void 0:e.images),Q=R||H||A||L||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(z),[ce,de]=m.useState(!1),[me,$e]=m.useState(F),[Ce,_e]=m.useState(!1),[Be,ot]=m.useState({visible:!1,top:0,height:100}),[gt,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),zt=ve>it+1,Qt=zt?Math.max(12,it/ve*100):100,rn=Math.max(0,100-Qt),er=zt?Math.min(rn,le.scrollTop/Math.max(1,ve-it)*rn):0;ot({visible:zt,top:er,height:Qt})},[]);m.useEffect(()=>{V.current||Z(z)},[n,z]),m.useEffect(()=>{B.current||$e(F)},[n,F]),m.useEffect(()=>{const le=ue.current;if(!le)return;if(M){le.style.minHeight="",le.style.height="",G.current&&(G.current.style.minHeight="",G.current.style.height="");return}const ve=sU(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 zt=()=>{window.cancelAnimationFrame(it),it=window.requestAnimationFrame(()=>ve(n))},Qt=new ResizeObserver(zt);return Qt.observe(le),zt(),()=>{window.cancelAnimationFrame(it),Qt.disconnect()}},[e==null?void 0:e.onNodeContentResize,M,n]),m.useEffect(()=>{if(!gt)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)},[gt]);const mt=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],Tt=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],xe=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],Oe=Array.isArray(c==null?void 0:c.codex)?c.codex:[],ie=((e==null?void 0:e.model)??"").trim(),ke=y==="agent"&&!C.startsWith("tool_nodejs"),Ke=new Set(mt.map(Ss)),Ue=new Set(Tt.map(Ss)),be=new Set(xe.map(Ss)),It=new Set(Oe.map(Ss)),nn=ie?ie.startsWith("cursor:")||ie.startsWith("opencode:")||ie.startsWith("codex:")||ie.startsWith("claude-code:")?ie:be.has(ie)?`claude-code:${ie}`:It.has(ie)?`codex:${ie}`:Ue.has(ie)?`opencode:${ie}`:Ke.has(ie)?`cursor:${ie}`:ie:"",Vt=ie&&!nn.startsWith("cursor:")&&!nn.startsWith("opencode:")&&!nn.startsWith("codex:")&&!nn.startsWith("claude-code:")&&!Ke.has(ie)&&!Ue.has(ie)&&!be.has(ie)&&!It.has(ie),Ot=ie.startsWith("cursor:")?ie.slice(7):ie.startsWith("opencode:")?ie.slice(9):ie.startsWith("codex:")?ie.slice(6):ie.startsWith("claude-code:")?ie.slice(12):ie,ln=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))},Mt=le=>{le.stopPropagation(),V.current=!0},_t=le=>{if(le.stopPropagation(),g)return;V.current=!1;const ve=le.currentTarget.value;Z(ve),d||o==null||o(n,ve)},Kn=()=>{g||d&&ne===z||o==null||o(n,ne)},jn=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))},br=le=>{le.stopPropagation(),de(ve=>!ve)},xn=le=>{if($e(le),a==null||a(n,le),l){const ve=Xq(E,le);(ve.length!==E.length||ve.some((it,zt)=>{var Qt;return it.id!==((Qt=E[zt])==null?void 0:Qt.id)}))&&l(n,ve)}},Qn=le=>{if(le.stopPropagation(),g)return;const ve=le.target.value;d||B.current?$e(ve):xn(ve)},qn=le=>{le.stopPropagation(),!g&&(B.current=!0,_e(!0))},mr=le=>{if(le.stopPropagation(),g)return;B.current=!1,_e(!1);const ve=le.currentTarget.value;d?$e(ve):xn(ve)},ts=()=>{g||(B.current=!1,_e(!1),!(d&&me===F)&&xn(me))},Pr=le=>{le.stopPropagation(),le.preventDefault(),!g&&Te(!0)},ys=()=>{Te(!1),ts()},ws=le=>{le.stopPropagation(),le.key==="Escape"&&(le.preventDefault(),ys())},dn=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]),sr=m.useCallback((le,ve=0)=>{const it=ee.current;if(!it)return 0;const zt=it.getBoundingClientRect(),Qt=Be.height/100*zt.height,rn=Math.max(1,zt.height-Qt);return(le-zt.top-ve)/rn},[Be.height]),Ir=m.useCallback(le=>{var vr,tt;if(!Be.visible)return;le.preventDefault(),le.stopPropagation();const ve=ee.current;if(!ve)return;const it=ve.getBoundingClientRect(),zt=Be.top/100*it.height,Qt=Be.height/100*it.height,er=le.clientY>=it.top+zt&&le.clientY<=it.top+zt+Qt?le.clientY-it.top-zt:Qt/2;dn(sr(le.clientY,er));const ht=le.pointerId;(tt=(vr=le.currentTarget).setPointerCapture)==null||tt.call(vr,ht);const sn=On=>{On.preventDefault(),dn(sr(On.clientY,er))},Kt=()=>{window.removeEventListener("pointermove",sn),window.removeEventListener("pointerup",Kt),window.removeEventListener("pointercancel",Kt)};window.addEventListener("pointermove",sn),window.addEventListener("pointerup",Kt),window.addEventListener("pointercancel",Kt)},[sr,Be.height,Be.top,Be.visible,dn]),pn=async le=>{if(g)return;const ve=await xT({files:le,body:me,images:E});ve&&($e(ve.body),a==null||a(n,ve.body),l==null||l(n,ve.images))},Zn=(le,ve)=>{if(le.stopPropagation(),g)return;const it=E.filter(Qt=>Qt.id!==ve.id),zt=nU(me,ve.label);$e(zt),a==null||a(n,zt),l==null||l(n,it)},kr=le=>{if(g)return;const ve=wT(le);ve.length!==0&&(le.preventDefault(),le.stopPropagation(),pn(ve).catch(()=>{}))},ir=le=>{if(g)return;const ve=hd(le);ve.length!==0&&(le.preventDefault(),le.stopPropagation(),pn(ve).catch(()=>{}))},jt=()=>{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":"")+(j==="success"?" af-flow-node--done":"")+(j==="failed"?" af-flow-node--failed":"")+(j==="running"&&!k?" af-flow-node--running-disk":"")+(b?" af-flow-node--dim":"")+(M?" af-flow-node--inline-body-editor":"")+(H?" af-flow-node--provide-text":"")+(L?" af-flow-node--provide-password":"")+" af-flow-node--"+y.replace(/[^a-z0-9_-]/g,""),"data-schema":y,children:[i.jsxs("div",{className:"af-flow-node__chrome",children:[i.jsx("span",{className:"af-flow-node__title af-flow-node__title--chrome",title:`${$}${n?` (${n})`:""}${v?` · ${v}`:""}`,children:$}),!w&&ke&&i.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:tn,onMouseDown:tn,onClick:tn,children:[i.jsxs("select",{className:"af-flow-node__model nodrag",value:nn,onChange:ln,onPointerDown:tn,onMouseDown:tn,onClick:tn,"aria-label":f("flow:node.model"),title:Ot||f("flow:node.defaultModel"),disabled:g,children:[i.jsx("option",{value:"",children:f("flow:node.defaultModel")}),Vt&&i.jsx("option",{value:ie,children:ie}),mt.length>0&&i.jsx("optgroup",{label:"Cursor",children:mt.map(le=>i.jsx("option",{value:`cursor:${Ss(le)}`,children:Ss(le)},`c-${le}`))}),Tt.length>0&&i.jsx("optgroup",{label:"OpenCode",children:Tt.map(le=>i.jsx("option",{value:`opencode:${Ss(le)}`,children:Ss(le)},`o-${le}`))}),Oe.length>0&&i.jsx("optgroup",{label:"Codex",children:Oe.map(le=>i.jsx("option",{value:`codex:${Ss(le)}`,children:Ss(le)},`codex-${le}`))}),xe.length>0&&i.jsx("optgroup",{label:"Claude Code",children:xe.map(le=>i.jsx("option",{value:`claude-code:${Ss(le)}`,children:Ss(le)},`cc-${le}`))})]}),i.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),k&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),j==="running"&&!k&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:f("flow:node.diskRunning"),children:"RUNNING"}),j==="success"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:N!=null&&String(N).trim()!==""?N:"--"}),j==="failed"&&i.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!w&&I&&!R&&!H&&!A&&!L&&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"})}),!w&&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}):""),zt=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:[zt,le.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(Jn,{type:"target",position:qe.Left,id:`input-${ve}`,className:"af-flow-node__handle",style:{background:Mn(le.type)},title:it})]},`in-${ve}`)})}),i.jsxs("div",{className:"af-flow-node__title-wrap",children:[R?i.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(K?" af-flow-node__bool-select--true":""),value:K?"true":"false",onChange:Je,onPointerDown:tn,onMouseDown:tn,onClick:tn,"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"})]}):H?i.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:ne,onChange:Ze,onCompositionStart:Mt,onCompositionEnd:_t,onBlur:Kn,onPointerDown:tn,onMouseDown:tn,onClick:tn,placeholder:"输入文本",rows:2,readOnly:g}):A?i.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:tn,onMouseDown:tn,onClick:tn,children:[i.jsx("input",{className:"af-flow-node__file-input nodrag",value:ne,onChange:Ze,onCompositionStart:Mt,onCompositionEnd:_t,onBlur:Kn,placeholder:"选择或输入文件路径",title:ne||"选择或输入文件路径",readOnly:g}),i.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:g,onClick:jn,"aria-label":"选择文件",title:"选择文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):L?i.jsxs("div",{className:"af-flow-node__password-value nodrag",onPointerDown:tn,onMouseDown:tn,onClick:tn,children:[i.jsx("input",{className:"af-flow-node__password-input nodrag",type:ce?"text":"password",value:ne,onChange:Ze,onCompositionStart:Mt,onCompositionEnd:_t,onBlur:Kn,placeholder:"输入密码或密钥",title:ce?ne:"密码已隐藏",autoComplete:"off",readOnly:g}),i.jsx("button",{type:"button",className:"af-flow-node__password-toggle nodrag",disabled:g,onClick:br,"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:rU(me)+`
|
|
99
|
-
`}}),i.jsx("textarea",{ref:ue,className:"af-flow-node__prompt-editor nodrag",value:me,onChange:Qn,onCompositionStart:qn,onCompositionEnd:mr,onBlur:ts,onPaste:kr,onDrop:ir,onScroll:le=>{jt(),st()},onPointerDown:tn,onMouseDown:tn,onClick:tn,onKeyDown:tn,onDragOver:le=>{hd(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:tn,onMouseDown:tn,onClick:Pr,"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:Ir,"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=>Zn(it,le),onPointerDown:tn,onMouseDown:tn,"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:$,children:$})]}),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}):""),zt=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:[zt,le.required?i.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),i.jsx(Jn,{type:"source",position:qe.Right,id:`output-${ve}`,className:"af-flow-node__handle",style:{background:Mn(le.type)},title:it})]},`out-${ve}`)})})]}),gt?ur.createPortal(i.jsx("div",{className:"af-flow-node-full-editor nodrag",onPointerDown:tn,onMouseDown:tn,onClick:tn,onWheel:tn,children:i.jsxs("div",{className:"af-flow-node-full-editor__panel",children:[i.jsxs("div",{className:"af-flow-node-full-editor__header",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-flow-node-full-editor__title",children:$}),i.jsx("div",{className:"af-flow-node-full-editor__hint",children:"编辑 prompt,Esc 关闭"})]}),i.jsx("button",{type:"button",className:"af-flow-node-full-editor__close",onClick:ys,"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:Qn,onCompositionStart:qn,onCompositionEnd:mr,onPaste:kr,onDrop:ir,onKeyDown:ws,onDragOver:le=>{hd(le).length>0&&le.preventDefault()},placeholder:O?"输入判断条件 / prompt":"输入 prompt",readOnly:g})]})}),document.body):null]})}const mc="flowNode";function ob(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 oU={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 aU(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(oU[e]||[]).includes(s)?r:s}const lU={tool_git_checkout:new Set(["targetDir","pullIfExists","includeSubmodules","workspaceContext","commit","changed"]),control_load_skills:new Set(["mergeMode","workspaceContext","skillsContext","loadedCount","summary"]),control_load_mcp:new Set(["workspaceContext","mcpContext","loadedCount","summary"]),agent_subAgent:new Set(["workspaceContext","skillsContext","mcpContext"])},cU={control_cd_workspace:new Set(["mode","label","workspaceContext","cwd","previous"]),control_user_workspace:new Set(["cwd"]),display_markdown:new Set(["prev","next"]),display_mermaid:new Set(["prev","next"]),display_ascii:new Set(["prev","next"]),display_html:new Set(["prev","next"]),display_react_app:new Set(["prev","next"]),display_image:new Set(["prev","next"]),display_chart:new Set(["prev","next"]),display_table:new Set(["prev","next"]),tool_git_checkout:new Set(["branch","targetDir","pullIfExists","includeSubmodules","repoPath","commit","changed"]),tool_gitlab_create_mr:new Set(["repoPath","workspaceContext","sourceBranch","targetBranch","title","description","draft","labels","push","remote","tokenEnv","gitlabApiBase","removeSourceBranch","squash","created","mrIid","projectId","message"])},uU={agent_subAgent:new Set(["knowledgeContext","skillsContext"])},dU=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_react_app","display_image","display_chart","display_table"]);function fU(e,t){if(!dU.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function pU(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function hU(e,t){const n=String((e==null?void 0:e.baseDefinitionId)||"").trim();return n||t}function bT(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function mU(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 gU(e){const t=String(e??"").trim();return t?t.includes("${")?t:bT(t):""}function yU(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(gU).filter(Boolean):[];return[mU(t,n),bT(s),...o].join(" ")}return String(t.command||"").trim()}function rC(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=lU[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&&fU(e,r)?{showOnNode:!0}:{},...(d=uU[e])!=null&&d.has(r.name)?{showOnNode:!0}:{},...(f=cU[e])!=null&&f.has(r.name)?{showOnNode:!1}:{}}})}function wU(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=ob(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 ab(e,t,n,r,s){var $,W,E,Q,V,B,se,ue,G,ee,te,ne,Z,ce,de,me,$e,Ce,_e,Be,ot,gt;const o=(($=e.data)==null?void 0:$.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(Te=>Te.id===o),l=t[e.id];let c=[],u=[],d=((W=e.data)==null?void 0:W.label)??e.id,f,p,h,y,v;const w=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(ob)),Array.isArray(l.output)&&(u=l.output.map(ob)),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,b=(a==null?void 0:a.description)!=null?String(a.description).trim():"",j=b!==""?b:void 0,N=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:[],I=yU(a),R=v!==void 0?v:((se=e.data)==null?void 0:se.script)!=null?String(e.data.script):I,H=String(e.id),A=(ue=r==null?void 0:r[s])==null?void 0:ue[H],L=(G=A==null?void 0:A.label)==null?void 0:G.label,D=A==null?void 0:A.body,O=A==null?void 0:A.description;w||(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=hU(a,(a==null?void 0:a.id)??o),K=(l==null?void 0:l.marketplaceRef)||((ne=e.data)==null?void 0:ne.marketplaceRef)||pU(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=rC(M,c,a==null?void 0:a.inputs),u=rC(M,u,a==null?void 0:a.outputs),M.startsWith("provide_")&&u[0]&&String(u[0].default??u[0].value??"").trim()===""&&String(N).trim()!==""&&(u=u.map((Te,st)=>st===0?{...Te,default:N,value:N}:Te));const z=aU(M,d,a),F=M==="tool_nodejs"||String(R).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:L||d,displayLabel:z,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:((gt=e.data)==null?void 0:gt.schemaType)??e.type??"agent",role:g,model:k,body:D||N,images:C,script:R,inputs:c,outputs:u,description:O||j,originalLabel:d,originalBody:N,...F?{script:R}:{}}}}function xU(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 sC(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 iC(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function sw(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=sC(t==null?void 0:t.sourceHandle,"output"),o=sC(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=iC((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=iC((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 bU(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 oC(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function kU(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function vU({children:e}){return i.jsx("kbd",{className:"af-kbd",children:e})}function Vs({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(vU,{children:t})]},n))})}function SU({open:e,onClose:t}){const{t:n}=zr(),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=kU()?"⌘":"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(Vs,{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(Vs,{keys:["?"]})]}),i.jsxs("li",{className:"af-shortcuts-row",children:[i.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),i.jsx(Vs,{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(Vs,{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(Vs,{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(Vs,{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(Vs,{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(Vs,{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(Vs,{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(Vs,{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(Vs,{keys:[o,"Shift","Z"]})]})]})]})]})]})})}function jU(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 NU({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=zr(),[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,b,j;return{id:g.id,label:((k=g.data)==null?void 0:k.label)||"",definitionId:((b=g.data)==null?void 0:b.definitionId)||"",schemaType:((j=g.data)==null?void 0:j.schemaType)||""}}),v=o.trim(),w=y.map(g=>({e:g,s:jU(g,v)})).filter(g=>g.s>0);return w.sort((g,k)=>k.s-g.s||g.e.id.localeCompare(k.e.id)),w.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:w=>{w.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 aC(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 CU(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 lC(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 iw(e){return String((e==null?void 0:e.nodeId)||(e==null?void 0:e.runNodeId)||"")}function cC(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 _U({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),[w,g]=m.useState(""),[k,b]=m.useState(""),j=m.useCallback(async()=>{if(e!=null&&e.flowId){h(!0),g("");try{const R=new URLSearchParams;R.set("flowId",e.flowId),R.set("flowSource",e.flowSource||"user"),t?R.set("scheduleNodeId",t):n&&R.set("runNodeId",n),R.set("limit","80");const H=await fetch(`/api/workspace/run-logs?${R.toString()}`),A=await H.json().catch(()=>({}));if(!H.ok)throw new Error(A.error||"读取日志失败");const L=Array.isArray(A.runs)?A.runs:[];l(L),u(D=>{const O=L[0]||null;return O&&String(O.status||"")==="running"&&O.runId!==D?O.runId:D&&L.some(M=>M.runId===D)?D:r&&L.some(M=>M.runId===r)?r:(O==null?void 0:O.runId)||""})}catch(R){g(String(R.message||R)),l([])}finally{h(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,r,n,t]),N=m.useCallback(async R=>{if(!R){f(null);return}v(!0);try{const H=new URLSearchParams({flowId:(e==null?void 0:e.flowId)||"",flowSource:(e==null?void 0:e.flowSource)||"user"});e!=null&&e.archived&&H.set("archived","1");const A=await fetch(`/api/workspace/run-logs/${encodeURIComponent(R)}?${H.toString()}`),L=await A.json().catch(()=>({}));if(!A.ok)throw new Error(L.error||"读取日志详情失败");f(L)}catch(H){f({error:String(H.message||H),events:[]})}finally{v(!1)}},[e==null?void 0:e.archived,e==null?void 0:e.flowId,e==null?void 0:e.flowSource]);m.useEffect(()=>{j()},[j]),m.useEffect(()=>{N(c)},[N,c]),m.useEffect(()=>{const R=a.find(A=>A.runId===c),H=window.setInterval(()=>{j(),(!R||R.status==="running")&&c&&N(c)},2e3);return()=>window.clearInterval(H)},[N,j,a,c]);const C=m.useMemo(()=>{const R=Array.isArray(d==null?void 0:d.events)?d.events:[],H=k.trim().toLowerCase();return H?R.filter(A=>String(A.type||"").toLowerCase().includes(H)||iw(A).toLowerCase().includes(H)||lC(A).toLowerCase().includes(H)):R},[d==null?void 0:d.events,k]),I=(d==null?void 0:d.run)||a.find(R=>R.runId===c)||null;return i.jsxs("div",{className:"af-work-run-logs",children:[i.jsxs("div",{className:"af-pipeline-drawer-head",children:[i.jsx("h2",{className:"af-pipeline-drawer-title",children:"执行日志"}),i.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:o,"aria-label":"关闭日志侧栏",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-run-logs__meta",children:[i.jsx("span",{children:s||t||n||"Workspace Run"}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void j(),title:"刷新日志","aria-label":"刷新日志",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]}),w?i.jsx("div",{className:"af-work-run-logs__error",children:w}):null,i.jsxs("div",{className:"af-work-run-logs__body",children:[i.jsxs("div",{className:"af-work-run-logs__list",children:[i.jsx("div",{className:"af-work-run-logs__section-title",children:"最近执行"}),p?i.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,!p&&a.length===0?i.jsx("div",{className:"af-work-run-logs__empty",children:"暂无执行日志"}):null,a.map(R=>i.jsxs("button",{type:"button",className:"af-work-run-logs__run"+(R.runId===c?" af-work-run-logs__run--active":""),onClick:()=>u(R.runId),title:R.runId,children:[i.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${cC(R.status)}`,children:R.status||"unknown"}),i.jsx("span",{className:"af-work-run-logs__run-label",children:R.label||R.runNodeId||R.scheduleNodeId||"Workspace Run"}),i.jsx("span",{children:aC(R.startedAt)}),i.jsx("span",{children:CU(R.durationMs)})]},R.runId))]}),i.jsxs("div",{className:"af-work-run-logs__detail",children:[i.jsxs("div",{className:"af-work-run-logs__detail-head",children:[i.jsxs("div",{children:[i.jsx("div",{className:"af-work-run-logs__section-title",children:"详情"}),I!=null&&I.label?i.jsx("div",{className:"af-work-run-logs__detail-label",children:I.label}):null,i.jsx("div",{className:"af-work-run-logs__run-id",children:(I==null?void 0:I.runId)||"-"})]}),I?i.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${cC(I.status)}`,children:I.status}):null]}),i.jsxs("label",{className:"af-work-run-logs__search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{value:k,onChange:R=>b(R.target.value),placeholder:"搜索事件、节点、错误"})]}),y?i.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,d!=null&&d.error?i.jsx("div",{className:"af-work-run-logs__error",children:d.error}):null,!y&&!C.length?i.jsx("div",{className:"af-work-run-logs__empty",children:"暂无事件"}):null,i.jsx("div",{className:"af-work-run-logs__events",children:C.map((R,H)=>i.jsxs("div",{className:"af-work-run-logs__event",children:[i.jsx("span",{className:"af-work-run-logs__event-time",children:aC(R.ts)}),i.jsx("span",{className:"af-work-run-logs__event-type",children:R.type||"event"}),iw(R)?i.jsx("span",{className:"af-work-run-logs__event-node",children:iw(R)}):null,i.jsx("pre",{children:lC(R)})]},`${R.ts||H}-${H}`))})]})]})]})}function EU(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 kT(e){const t=EU(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 AU(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 PU(e){return String(e).replace(/<\/script/gi,"<\\/script")}function cg(e){const t=kT(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 fv(e,t=""){const n=kT(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=AU(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=PU(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 vT=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),IU=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function RU(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 TU(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 uC(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 ST(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(vT.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 jT(e){return{inputNames:uC(e==null?void 0:e.inputs),outputNames:uC(e==null?void 0:e.outputs)}}function MU(e,t,n){const r=jT(t),s=TU(e),o=[];for(const a of s)if(!ST(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=jT(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=ST(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 LU(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function OU(e){return e.map(t=>{const n=LU(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 DU(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 IU)vT.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function FU(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 zU(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 Tp({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}=zr(),f=m.useId(),p=m.useRef(null),h=m.useRef(null),[y,v]=m.useState(0),[w,g]=m.useState(0),[k,b]=m.useState(null),j=m.useMemo(()=>ho(c),[c]),N=m.useMemo(()=>MU(e,a,d),[e,a,d]),C=N.length>0,I=m.useMemo(()=>$U(e,a),[e,a]),R=m.useMemo(()=>OU(I),[I]),H=m.useMemo(()=>n?null:RU(e,y),[e,y,n]),A=m.useMemo(()=>{if(!H)return[];const z=DU(a,d);return FU(z,H.query)},[H,a,d]);m.useEffect(()=>{g(z=>{const F=Math.max(0,A.length-1);return Math.min(Math.max(0,z),F)})},[A.length]);const L=m.useCallback(()=>{const z=p.current;if(!z||!H||A.length===0){b(null);return}const F=zU(z,y);if(!F){b(null);return}const $=4,W=44,E=13.5*16,Q=Math.min(A.length*W+8,E);let V=F.bottom+$;V+Q>window.innerHeight-8&&(V=Math.max(8,F.top-Q-$));const B=288;let se=F.left;se=Math.max(8,Math.min(se,window.innerWidth-B-8)),b({top:V,left:se})},[H,A.length,y]);m.useLayoutEffect(()=>{if(!H||A.length===0){b(null);return}const z=requestAnimationFrame(()=>L());return()=>cancelAnimationFrame(z)},[H,A.length,y,e,L]),m.useEffect(()=>{if(!H||A.length===0)return;const z=()=>L();return window.addEventListener("scroll",z,!0),window.addEventListener("resize",z),()=>{window.removeEventListener("scroll",z,!0),window.removeEventListener("resize",z)}},[H,A.length,L]);const D=m.useCallback(z=>{if(!H)return;const{atIndex:F}=H,$=e.slice(0,F)+"${"+z+"}"+e.slice(y);t($);const W=F+z.length+3;queueMicrotask(()=>{const E=p.current;E&&(E.focus(),E.setSelectionRange(W,W)),v(W)})},[H,e,y,t]),O=m.useCallback(()=>{const z=p.current,F=h.current;!z||!F||(F.scrollTop=z.scrollTop,F.scrollLeft=z.scrollLeft,H&&A.length>0&&queueMicrotask(()=>L()))},[H,A.length,L]),M=m.useCallback(z=>{if(!n&&H&&A.length>0&&(z.key==="ArrowDown"||z.key==="ArrowUp"||z.key==="Enter")){if(z.key==="ArrowDown")z.preventDefault(),g(F=>(F+1)%A.length);else if(z.key==="ArrowUp")z.preventDefault(),g(F=>(F-1+A.length)%A.length);else if(z.key==="Enter"&&!z.shiftKey){z.preventDefault();const F=A[w];F&&D(F.insert)}}},[n,H,A,w,D]),K=m.useCallback(async z=>{if(n||typeof u!="function")return!1;const F=await xT({files:z,body:e,images:j});return F?(t(F.body),u(F.images),queueMicrotask(()=>{const $=p.current;if(!$)return;$.focus();const W=F.body.length;$.setSelectionRange(W,W),v(W)}),!0):!1},[n,j,t,u,e]);return i.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[j.length>0?i.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:j.map((z,F)=>i.jsxs("span",{className:"af-body-image-chip",title:z.name,children:[i.jsx("img",{src:z.dataUrl,alt:""}),i.jsxs("span",{children:["[",z.label||`image ${F+1}`,"]"]})]},z.id||F))}):null,i.jsxs("div",{className:"af-body-prompt-stack",children:[i.jsx("pre",{ref:h,className:"af-body-prompt-backdrop "+o,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:R+`
|
|
182
|
-
`}}),i.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+o,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":C,"aria-describedby":C?f:void 0,onChange:z=>{t(z.target.value),v(z.target.selectionStart??z.target.value.length)},onSelect:z=>{const F=z.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onClick:z=>{const F=z.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onKeyUp:z=>{const F=z.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??F.value.length)},onKeyDown:M,onPaste:z=>{const F=wT(z);F.length!==0&&(z.preventDefault(),K(F).catch(()=>{}))},onDragOver:z=>{hd(z).length>0&&z.preventDefault()},onDrop:z=>{const F=hd(z);F.length!==0&&(z.preventDefault(),K(F).catch(()=>{}))},onScroll:O})]}),H&&A.length>0&&k?ur.createPortal(i.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":d("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:k.top,left:k.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:A.map((z,F)=>i.jsx("li",{role:"option","aria-selected":F===w,children:i.jsxs("button",{type:"button",className:"af-composer-mention-item"+(F===w?" af-composer-mention-item--active":""),onMouseDown:$=>$.preventDefault(),onMouseEnter:()=>g(F),onClick:()=>D(z.insert),children:[i.jsx("span",{className:"af-composer-mention-id",children:`\${${z.insert}}`}),z.subtitle?i.jsx("span",{className:"af-composer-mention-sub",children:z.subtitle}):null]})},`${z.section}-${z.insert}`))}),document.body):null,C?i.jsx("p",{id:f,className:"af-body-ph-issues",role:"status",children:N.map(z=>z.message).join(" · ")}):null]})}const BU=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Ru(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function dC({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:o=!0}){const{t:a}=zr(),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,w)=>{if(w!==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 HU({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}=zr(),[h,y]=m.useState(!1),[v,w]=m.useState(!1),[g,k]=m.useState({status:"idle",message:""}),b=m.useCallback(O=>{t(M=>M&&{...M,...O})},[t]),{cursorList:j,opencodeList:N,claudeCodeList:C,codexList:I,currentNotInLists:R}=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:[],z=Array.isArray(s==null?void 0:s.codex)?s.codex:[],F=new Set([...O,...M,...K,...z].map(Ru)),$=((e==null?void 0:e.model)??"").trim(),W=$.startsWith("cursor:")?$.slice(7):$.startsWith("opencode:")?$.slice(9):$.startsWith("codex:")?$.slice(6):$.startsWith("claude-code:")?$.slice(12):$,E=$&&!F.has(W)?$:"";return{cursorList:O,opencodeList:M,claudeCodeList:K,codexList:z,currentNotInLists:E}},[s,e==null?void 0:e.model]);if(!e)return null;const H=String(e.script??""),A=n==="tool_nodejs"||H.trim()!=="",L=typeof c=="function"&&!o&&(e==null?void 0:e.newId),D=async()=>{if(L){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:D,disabled:!L||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=>b({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=>b({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:Kd.includes(e.role)?e.role:p("flow:roles.normal"),onChange:O=>b({role:O.target.value}),disabled:o,children:Kd.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?R||O:""})(),onChange:O=>b({model:O.target.value}),disabled:o,"aria-label":p("flow:nodeProps.modelAriaLabel"),children:[i.jsx("option",{value:"",children:p("flow:node.defaultModel")}),R?i.jsxs("option",{value:R,children:[R,p("flow:nodeProps.yamlValueNotInList")]}):null,j.length>0?i.jsx("optgroup",{label:"Cursor",children:j.map(O=>i.jsx("option",{value:Ru(O),children:O},`c-${O}`))}):null,N.length>0?i.jsx("optgroup",{label:"OpenCode",children:N.map(O=>i.jsx("option",{value:`opencode:${Ru(O)}`,children:O},`o-${O}`))}):null,I.length>0?i.jsx("optgroup",{label:"Codex",children:I.map(O=>i.jsx("option",{value:`codex:${Ru(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:${Ru(O)}`,children:O},`cc-${O}`))}):null]})]}),i.jsx(dC,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:O=>b({inputs:O}),disabled:o,requiredReadonly:!u}),i.jsx(dC,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:O=>b({outputs:O}),disabled:o,requiredReadonly:!u}),A?i.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[i.jsxs("div",{className:"af-node-props-prompt-head",children:[i.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.directCommand"),"(script)",i.jsx("span",{className:"af-node-props-hint",children:p("flow:node.scriptHint")})]}),i.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>w(!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(Tp,{value:H,onChange:O=>b({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=>b({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=>b({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=>b({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(Tp,{value:e.body,onChange:O=>b({body:O}),images:e.images,onImagesChange:O=>b({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&&w(!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:()=>w(!1),"aria-label":p("flow:nodeProps.collapse"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsx(Tp,{value:H,onChange:O=>b({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(Tp,{value:e.body,onChange:O=>b({body:O}),images:e.images,onImagesChange:O=>b({images:O}),disabled:o,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:f,variant:"expand"})]})}):null]})}function WU({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:o}=zr(),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 w(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})}),b=await k.json().catch(()=>({}));if(!k.ok){h(typeof b.error=="string"?b.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:w,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 VU({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,workspaceId:o="",leaveShared:a=!1,onDeleted:l}){const{t:c}=zr(),u=m.useId(),d=m.useRef(null),[f,p]=m.useState(""),[h,y]=m.useState(!1),[v,w]=m.useState("");if(m.useEffect(()=>{if(!e)return;p(""),w(""),y(!1);const j=requestAnimationFrame(()=>{var N;return(N=d.current)==null?void 0:N.focus()});return()=>cancelAnimationFrame(j)},[e,n]),!e)return null;const g=f.trim(),k=a||g===n;async function b(j){if(j.preventDefault(),!k||h)return;y(!0),w("");let N=null;try{const C=new AbortController;N=setTimeout(()=>C.abort(),15e3);const I=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:a?n:g,flowArchived:s,workspaceId:o}),signal:C.signal}),R=await I.json().catch(()=>({}));if(!I.ok){w(typeof R.error=="string"?R.error:c("project:deleteModal.deleteFailed"));return}try{for(let H=localStorage.length-1;H>=0;H--){const A=localStorage.key(H);A&&(A.startsWith(`af:composer-sessions:${n}:${r}`)||A.startsWith(`af:composer-active-session:${n}:${r}`)||A.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(A)}}catch{}await l()}catch(C){if((C==null?void 0:C.name)==="AbortError"){w(c("project:deleteModal.deleteTimeout"));return}w(String((C==null?void 0:C.message)||C))}finally{N&&clearTimeout(N),y(!1)}}return i.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:j=>{j.target===j.currentTarget&&t()},children:i.jsxs("div",{ref:d,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":u,tabIndex:-1,onMouseDown:j=>j.stopPropagation(),children:[i.jsxs("div",{className:"af-shortcuts-panel__head",children:[i.jsx("h2",{id:u,className:"af-shortcuts-panel__title",children:a?"退出共享 Workspace":c("project:deleteModal.title")}),i.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":c("project:deleteModal.close"),children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:b,children:[i.jsx("p",{className:"af-new-pipeline-lead",children:a?`退出后,${n} 将从你的项目列表移除;源项目和其他成员的数据不会被删除。`:c("project:deleteModal.lead",{flowId:n})}),a?null:i.jsxs("label",{className:"af-new-pipeline-field",children:[i.jsx("span",{className:"af-pipeline-drawer-label",children:c("project:deleteModal.confirmLabel")}),i.jsx("input",{type:"text",className:"af-new-pipeline-input",value:f,onChange:j=>p(j.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!k})]}),v?i.jsx("p",{className:"af-err af-new-pipeline-err",children:v}):null,i.jsxs("div",{className:"af-new-pipeline-actions",children:[i.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:h,children:c("project:deleteModal.cancel")}),i.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||h,children:h?a?"退出中...":c("project:deleteModal.deleting"):a?"确认退出":c("project:deleteModal.confirmDelete")})]})]})]})})}const fC=80,KU=220;function qU(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 UU(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Mp(e,t,n){const r={nodes:Array.isArray(e)?e.map(qU):[],edges:Array.isArray(t)?t.map(UU):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function ow(e,t){const n=[...e,t];return n.length>fC?n.slice(n.length-fC):n}function YU({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(N=>N+1),[]),v=m.useCallback(()=>{p.current&&(window.clearTimeout(p.current),p.current=null)},[]),w=m.useCallback(()=>{v();const N=d.current,C=f.current;return d.current=null,f.current=null,!N||!C||N.signature===C.signature?(C&&(u.current=C),!1):(l.current=ow(l.current,N),c.current=[],u.current=C,y(),!0)},[y,v]),g=m.useCallback((N=[],C=[],I={})=>{v(),l.current=[],c.current=[],d.current=null,f.current=null,u.current=Mp(N,C,I),h.current=!1,y()},[y,v]),k=m.useCallback(N=>{h.current=!0,u.current=N,d.current=null,f.current=null,v(),s==null||s(N.value),y()},[y,v,s]),b=m.useCallback(()=>{w();const N=u.current||Mp(e,t,n),C=l.current.pop();return C?(c.current=ow(c.current,N),k(C),!0):(y(),!1)},[y,t,n,w,e,k]),j=m.useCallback(()=>{w();const N=u.current||Mp(e,t,n),C=c.current.pop();return C?(l.current=ow(l.current,N),k(C),!0):(y(),!1)},[y,t,n,w,e,k]);return m.useEffect(()=>()=>v(),[v]),m.useEffect(()=>{if(!r)return;const N=Mp(e,t,n);if(!u.current){u.current=N;return}if(h.current){h.current=!1,u.current=N;return}N.signature!==u.current.signature&&(d.current||(d.current=u.current),f.current=N,v(),p.current=window.setTimeout(()=>{w()},KU))},[v,t,r,n,w,e]),{canUndo:l.current.length>0||!!d.current,canRedo:c.current.length>0,resetHistory:g,undo:b,redo:j,version:o}}function lo(e){return String(e??"").trim()}function pC(e){return e===!0?!0:["true","yes","done","waived","not_required"].includes(lo(e).toLowerCase())}function GU(e){return e===!1?!0:["false","no","not_required","waived"].includes(lo(e).toLowerCase())}function JU(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 NT(e){return lo((e==null?void 0:e.platform)||"all").toLowerCase()||"all"}function CT(e){return NT(e)==="all"}function XU(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=NT(e),s=JU(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 om(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 QU(e=[]){const t={issue:0,mr:1,other:2};return[...e].sort((n,r)=>t[om(n)]-t[om(r)])}function ZU(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 eY(e,t=[]){if(CT(e))return{kind:"aggregate",label:"双端汇总",detail:"由 Android / iOS 端侧 Issue 承接"};const n=t.map(om);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 pC(e==null?void 0:e.implementationNotRequired)||pC(e==null?void 0:e.implementation_not_required)||GU(r)?{kind:"not-required",label:ZU(e)||"无需实现 MR",detail:""}:n.includes("issue")?{kind:"pending",label:"MR 尚未记录",detail:""}:{kind:"missing-issue",label:"GitLab Issue 未绑定",detail:"端侧执行项应先创建或绑定 GitLab Issue"}}function lb(e=[]){return e.reduce((t,n)=>t+1+lb(Array.isArray(n==null?void 0:n.children)?n.children:[]),0)}function fr(e){return String(e||"").trim()}function Lo(e){return fr(e).toLowerCase()}function am(e){return typeof e=="string"?Lo(e):!e||typeof e!="object"||Array.isArray(e)?"":Lo(e.kind||e.type||e.persistence||e.durability)}function _T(e,t="http://localhost"){const n=fr(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 ET(e={}){const t=fr(e.href||e.url);if(!t)return!1;const n=Lo(e.kind||e.type),r=Lo(e.durability),s=Lo(e.persistence),o=Lo(e.truth||e.stateTruth||e.state_truth),a=Lo(e.authority),l=am(e.source)||am(e.sourceArtifact||e.source_artifact),c=[e.label,n].map(fr).join(" "),u=[e.label,e.title,n,s,a,l,t].map(fr).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 AT(e={}){const t=[e.label,e.kind,e.title,e.documentType].map(fr).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 tY(e={},{issueTitle:t="",requirementTitle:n=""}={}){const r=fr(e.articleTitle||e.article_title||e.documentTitle||e.document_title||e.docTitle||e.doc_title);return r||(fr(t)?fr(t):AT(e)==="tech-design"&&fr(n)?fr(n):fr(e.title||e.label))}function nY(e={},t="http://localhost"){const n=fr(e.issueKey||e.issue_key||e.issue),r=AT(e);if(n)return`issue:${n}:${r}`;if(r==="tech-design")return"requirement:tech-design";const s=fr(e.documentPath||e.document_path||e.path);return s?`path:${s.replace(/\\/g,"/").replace(/\/+/g,"/")}`:`url:${_T(e.href||e.url,t)}`}function hC(e={}){const t=fr(e.href||e.url),n=Lo(e.kind||e.type),r=am(e.source)||am(e.sourceArtifact||e.source_artifact),s=fr(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 rY(e,t){const n=hC(t)>hC(e)?t:e,r=n===t?e:t;return{...r,...n,title:mC(e.title)>=mC(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 mC(e){const t=fr(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 aw(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]=rY(r[a],s)}return r}function sY(e=[],t="http://localhost"){const n=(Array.isArray(e)?e:[]).filter(o=>ET(o)),r=aw(n,o=>_T(o.href||o.url,t)),s=aw(r,o=>fr(o.documentPath||o.document_path||o.path).replace(/\\/g,"/").replace(/\/+/g,"/"));return aw(s,o=>nY(o,t))}function Pt(e){return String(e||"").trim()}function co(e){return typeof e=="string"?Pt(e).toLowerCase():!e||typeof e!="object"||Array.isArray(e)?"":Pt(e.kind||e.type||e.persistence||e.durability).toLowerCase()}function nc(e){return Pt((e==null?void 0:e.key)||(e==null?void 0:e.artifactKey)||(e==null?void 0:e.artifact_key))}function PT(e){return Pt((e==null?void 0:e.canonicalUrl)||(e==null?void 0:e.canonical_url)||(e==null?void 0:e.reviewUrl)||(e==null?void 0:e.review_url)||(e==null?void 0:e.href)||(e==null?void 0:e.url))}function IT(e){const t=Pt(e);if(!t)return"";try{const n=new URL(t,"http://agentflow.local");return`${n.origin}${n.pathname}`}catch{return t.split(/[?#]/)[0]}}function iY(e){const t=Pt(e);if(!t)return"";try{const n=new URL(t,"http://agentflow.local");return n.hash="",n.searchParams.sort(),n.href}catch{return t.split("#")[0]}}function oY(e={}){if(!e||typeof e!="object"||Array.isArray(e))return"";const t=Pt(e.issueKey||e.issue_key||e.issue),n=Pt(e.action||e.actionId||e.action_id),r=Pt(e.stageKey||e.stage_key||e.stage||e.phase||e.code||n),s=r.toLowerCase(),o=[r,n,e.code,e.type].map(a=>Pt(a).toLowerCase()).filter(Boolean);return t?/^(?:issue-plan|issue-gitlab|implementation|bugfix|integration):/.test(s)?r:o.some(a=>/^code-review(?::|$)/.test(a)||a==="code_review_completed")?`implementation:${t}`:o.some(a=>/plan_draft_local|submit-plan|plan-doc/.test(a)||["plan_mr","plan_approved","issue-plan"].includes(a))?`issue-plan:${t}`:o.some(a=>/gitlab_issue_missing|ensure-gitlab-issue/.test(a)||a==="issue-gitlab")?`issue-gitlab:${t}`:o.some(a=>["fix_mr","bugfix"].includes(a))?`bugfix:${t}`:o.some(a=>["integration_mr","integrated","integration"].includes(a))?`integration:${t}`:o.some(a=>["implementation_mr","implementation_done","implementation_merged","impl_mr","impl_done","impl_merged","runtime_marker","status","implementation"].includes(a))?`implementation:${t}`:r||n:r||n}function aY(e={}){var o,a;if(!e||typeof e!="object"||Array.isArray(e)||Pt(e.type||e.kind).toLowerCase()!=="workflow-report")return!1;const n=!!Pt(e.action||e.actionId||e.action_id||((o=e.actionModel)==null?void 0:o.key)||((a=e.action_model)==null?void 0:a.key)),r=Pt(e.artifactScope||e.artifact_scope||e.scope).toLowerCase()==="global",s=e.aggregateByStage??e.aggregate_by_stage;return!n&&(r||s===!1)}function Mc(e){const t=nc(e);if(/^prd-review:/i.test(t)||Pt((e==null?void 0:e.reviewId)||(e==null?void 0:e.review_id))||/\/api\/prd-workflow\/review\//.test(PT(e)))return!0;const n=Pt((e==null?void 0:e.href)||(e==null?void 0:e.url)||(e==null?void 0:e.shortUrl)||(e==null?void 0:e.short_url)),r=Pt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),s=Pt(e==null?void 0:e.durability).toLowerCase(),o=co(e==null?void 0:e.source)||co((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact));return(r==="review"||r==="temporary-review"||s==="temporary"||s==="durable"||o==="local-draft"||o==="ai-doc")&&/\/r\/[A-Za-z0-9_-]{8,32}(?:[?#]|$)/.test(n)}function gC(e){const t=[e==null?void 0:e.label,e==null?void 0:e.kind,e==null?void 0:e.type,e==null?void 0:e.durability,co(e==null?void 0:e.source)].map(Pt).join(" ");return/方案文档/.test(t)?50:/临时/.test(t)?40:/Markdown Review/i.test(t)?20:/预览|review/i.test(t)?10:0}function yC(e){const t=[],n=nc(e);if(n&&t.push(`key:${n}`),Mc(e)){const s=IT(PT(e));s&&t.push(`review:${s}`)}const r=iY((e==null?void 0:e.href)||(e==null?void 0:e.url));return r&&t.push(`url:${r}`),t.length||t.push(`link:${Pt(e==null?void 0:e.label)}
|
|
183
|
-
${r}`),t}function lY(e){const t=[],n=new Map;for(const r of e){if(!r)continue;const s=yC(r),o=s.map(h=>n.get(h)).find(h=>h!=null);if(o==null){s.forEach(h=>n.set(h,t.length)),t.push(r);continue}const a=t[o],l=gC(r)>=gC(a)?Pt(r==null?void 0:r.label)||Pt(a==null?void 0:a.label):Pt(a==null?void 0:a.label)||Pt(r==null?void 0:r.label),c=!!nc(a),u=!!nc(r),d=c&&!u?a:r,f=d===a?r:a,p=nc(d)&&!nc(f)&&Pt(d==null?void 0:d.label)||l;t[o]={...f,...d,...p?{label:p}:{}},yC(t[o]).forEach(h=>n.set(h,o))}return t}function RT(e){const t=Pt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Pt(e==null?void 0:e.durability).toLowerCase(),r=Pt(e==null?void 0:e.persistence).toLowerCase(),s=co(e==null?void 0:e.source)||co((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,s].map(Pt).join(" ");return t==="temporary-review"||n==="temporary"||s==="local-draft"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(o)}function cY(e){if(!Mc(e)||RT(e))return!1;const t=Pt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Pt(e==null?void 0:e.durability).toLowerCase(),r=Pt(e==null?void 0:e.persistence).toLowerCase(),s=co(e==null?void 0:e.source)||co((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,s].map(Pt).join(" ");return t==="review"||n==="durable"||s==="ai-doc"||r==="ai-doc"||/方案文档预览|durable/i.test(o)}function uY(e){if(Mc(e))return!1;const t=Pt((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Pt(e==null?void 0:e.persistence).toLowerCase(),r=co(e==null?void 0:e.source)||co((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),s=[e==null?void 0:e.label,t].map(Pt).join(" ");return t==="ai-doc"||n==="ai-doc"||r==="ai-doc"||/方案文档|技术方案/.test(s)}function dY(e={}){const t=[e.stage,e.stageKey,e.stage_key,e.action,e.id,e.title].map(Pt).join(" ");return/(?:^|[:_-])issue[-_:]?plan(?:$|[:_-])|plan[-_:]?doc|submit[-_:]?plan/i.test(t)||/方案(?:文档)?(?:已确认|预览)/.test(t)}function fY(e=[],t={}){const n=lY(Array.isArray(e)?e:[]);if(!dY(t))return n;const r=n.filter(Mc);if(r.length===0)return n;const s=r.filter(cY),a=s.length>0||n.some(uY)?s.at(-1):r.filter(RT).at(-1);return n.filter(l=>!Mc(l)||l===a)}function vi(e,t){const n=[],r=new Map,s=a=>{if(typeof a=="string")return[`value:${a}`];if(!a||typeof a!="object")return[];const l=[],c=Pt(a.key||a.artifactKey||a.artifact_key);c&&l.push(`key:${c}`);const u=IT(a.canonicalUrl||a.canonical_url||a.reviewUrl||a.review_url||a.href||a.url);u&&l.push(`url:${u}`);const d=Pt(a.path);return d&&l.push(`path:${d}`),l.length||l.push(`value:${JSON.stringify(a)}`),l},o=a=>{if(!a)return;const l=s(a);if(!l.length)return;const c=l.map(u=>r.get(u)).find(u=>u!=null);if(c==null){const u=n.length;n.push(a),l.forEach(d=>r.set(d,u));return}n[c]=a,s(a).forEach(u=>r.set(u,c))};return(Array.isArray(e)?e:[]).forEach(o),(Array.isArray(t)?t:[]).forEach(o),n}function qr(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function lm(e){return Array.isArray(e)?e.map(lm):qr(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,lm(e[t])])):e}function eo(e,t){return JSON.stringify(lm(e))===JSON.stringify(lm(t))}function TT(e){return qr(e==null?void 0:e.instances)?e.instances:{}}function Ud(e){return qr(e==null?void 0:e.ui)?e.ui:{}}function $p(e,t){if(!qr(e))return{};const n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function pY(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=$p(e,["version","instances","edges","ui"]),r=$p(t,["version","instances","edges","ui"]);if(!eo(n,r))return!1;const s=["nodePositions","nodeSizes","groups","displayPage","viewport"];return eo($p(e.ui,s),$p(t.ui,s))}function MT(e){const t=Array.isArray(Ud(e).groups)?Ud(e).groups:[];return new Map(t.filter(n=>n==null?void 0:n.id).map(n=>[String(n.id),n]))}function wC(e){const t=new Set(Object.keys(TT(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 MT(e).keys())t.add(n);return t}function xC(e,t){const n=TT(e),r=Ud(e),s=MT(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 bC(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 hY(e,t){if(!pY(e,t))return{safe:!1,changedNodeIds:[],nodesChanged:!0,edgesChanged:!0,displayPageChanged:!0};const n=new Set([...wC(e),...wC(t)]),r=Array.from(n).filter(s=>!eo(xC(e,s),xC(t,s)));return{safe:!0,changedNodeIds:r,nodesChanged:r.length>0,edgesChanged:!eo(bC(e),bC(t)),displayPageChanged:!eo(Ud(e).displayPage||null,Ud(t).displayPage||null)}}function mY(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 kC(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 vC(e){if(!e||typeof e!="object")return e;const t={...e};return delete t.selected,t}function gY(e,t){const n=new Map((Array.isArray(e)?e:[]).map(r=>[kC(r),r]));return(Array.isArray(t)?t:[]).map(r=>{const s=n.get(kC(r));return s?eo(vC(s),vC(r))?s:{...r,selected:s.selected===!0}:r})}function yY(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 wY({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 xY({savedGraph:e,sentGraph:t,savedRevision:n="",currentRevision:r=""}={}){return{graph:e||t||null,revision:String(n||r||"")}}function $T(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 bY(e=[]){const t=$T(e);return t.mutated&&!t.active}function kY(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 vY(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 SY(e=[]){const t=[],n=[];let r=!1;for(const s of Array.isArray(e)?e:[]){if(kY(s)){t.push(s);continue}n.push(s),vY(s)&&(r=!0)}return{transient:t,committed:n,finishesInteraction:r}}function cb(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 jY(e=[]){return cb(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 SC(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 NY({background:e=!1}={}){return{graph:!0,nodes:!e,files:!e}}function CY({eventType:e="",revision:t="",currentRevision:n="",targetRevision:r="",refreshPending:s=!1}={}){return e!=="graph.committed"||!t?!1:t===n?!0:t===r&&s}const _Y="af:workspace-graph:v2",jC="agentflow.workspace.sidebarCollapsed",Dl=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],EY=new Set(["control_start","control_end","control_load_skills","control_load_mcp","control_cd_workspace","control_user_workspace"]),AY={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:""}]},PY={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:""}]},IY={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}]},RY={id:"control_load_mcp",displayName:"Load MCP",label:"Load MCP",description:"Load selected Cursor MCP server tool manifests for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"serverNames",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"mcpContext",default:"",showOnNode:!0}]},TY={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}]},MY={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}]},$Y=new Set(["png","jpg","jpeg","gif","webp","svg"]),LT=320,OT=180,DT=960,cm=96,FT=900,ub=520,db=320,Lp=52,Za=240,el=160,fb="display-ref:",Yd="0 9 * * *",LY="Asia/Shanghai",OY="0.1.131";function DY(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",workspaceId:e.get("workspaceId")||"",workflowShare:e.get("workflowShare")||"",adminOwnerId:e.get("adminOwnerId")||"",archived:e.get("archived")==="1"||e.get("flowArchived")==="1"}}function $r(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.workspaceId&&t.set("workspaceId",e.workspaceId),e.workflowShare&&t.set("workflowShare",e.workflowShare),e.adminOwnerId&&t.set("adminOwnerId",e.adminOwnerId),e.archived&&t.set("archived","1"),t}function pv(e,t=4e3){const n=String(e??"").trim();return n?n.length>t?`${n.slice(0,t)}
|
|
184
|
-
...[truncated ${n.length-t} chars]`:n:""}function FY(e){const t=pv(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 hv(e,t=80){return(Array.isArray(e)?e:[]).map(FY).filter(Boolean).slice(-t)}function zY(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=hv(s.messages,40),l=pv(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 BY(e){return(Array.isArray(e)?e:[]).map(t=>{const n=String((t==null?void 0:t.id)||"").trim();if(!n)return null;const r=hv(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:pv((t==null?void 0:t.label)||n,120),status:s==="failed"?"failed":"done",messages:r}}).filter(Boolean).slice(-20)}function NC(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:hv(n.messages,100),runSessions:BY(n.runSessions)},nodeChats:zY(t.nodeChats)}}function um(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 $Y.has(n)}function Gd(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=$r(t||{});return s.set("path",r),n.download&&s.set("download","1"),`/api/workspace/file/raw?${s.toString()}`}function HY(e){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=String((e==null?void 0:e.flowSource)||"user").trim()||"user",r=String((e==null?void 0:e.adminOwnerId)||"").trim();return`af:composer-skills:workspace:${t}:${n}${r?`:admin:${r}`:""}${e!=null&&e.archived?":archived":""}`}function WY(e){const t=String((e==null?void 0:e.username)||(e==null?void 0:e.userId)||"").trim();return t?`${jC}:${t}`:jC}function VY(e){try{const t=window.localStorage.getItem(e);if(t==="false")return!1;if(t==="true")return!0}catch{}return!0}function CC(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function KY(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 qY(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!KY(e)}function UY(e){const t=String(e||"").trim();if(!t||YY(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 YY(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 GY(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function lw(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 cw(e,t,n="Workspace Run"){const r=String(e||"").trim()||n,s=String(t||"").trim();return!s||r===s?r:`${r} (${s})`}function Aa(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 _C(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 JY(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 XY(e){const t=JY(e);return["方案确定","开发","Bug 修复","完成"].map((n,r)=>{let s="pending";return t>r?s="done":t===r&&(s=r===3?"done":"current"),{label:n,status:s}})}function zT(e){const t=String(e||"").trim();if(!/^https?:\/\//i.test(t))return t;try{const n=new URL(t);if(n.hostname==="0.0.0.0"||n.hostname==="::"||n.hostname==="[::]"){const s=window.location.hostname;n.hostname=s&&s!=="0.0.0.0"&&s!=="::"?s:"127.0.0.1"}const r=String(new URLSearchParams(window.location.search).get("workflowShare")||"").trim();return r&&n.pathname.startsWith("/api/prd-workflow/review/")&&!n.searchParams.has("workflowShare")&&n.searchParams.set("workflowShare",r),n.href}catch{return t}}function gc(e){const t=String((e==null?void 0:e.url)||(e==null?void 0:e.href)||"").trim();if(t)return zT(t);const n=String((e==null?void 0:e.path)||"").trim();return n?`file://${n}`:""}function ua(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 ea(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 mv(e){return ua(e==null?void 0:e.status)==="done"&&ea(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 mh(e){return!e||typeof e!="object"?"":String(e.detail||e.description||e.summary||e.message||e.reason||"")}function gv(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 QY(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 ZY(e,t){const n=to(e,t),r=ua(e==null?void 0:e.status),s=mv(e),a=`${tl(e)} ${gv(e)}`,l=QY(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"||ea(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"||ea(e)==="observation")return`${l} GitLab Issue 状态已观察`}return/implementation_in_progress|impl_in_progress/.test(a)?`正在实现 ${l}`:/implementation_ready/.test(a)?`可以开始实现 ${l}`:n}function eG(e){if(!e||typeof e!="object")return"";const t=ua(e.status),n=ea(e),r=mv(e),o=`${tl(e)} ${gv(e)}`,a=yv(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=mh(e);return d?d.length>180&&a.length?"相关结果和产物已更新;可从下方链接查看。":d:""}function dm(e){return!e||typeof e!="object"?"":String(e.stageEnteredAt||e.stage_entered_at||e.time||e.at||e.observedAt||e.observed_at||e.reportedAt||e.reported_at||e.startedAt||e.started_at||e.completedAt||e.completed_at||e.updatedAt||e.updated_at||e.createdAt||e.created_at||"")}const BT="Asia/Shanghai",tG=new Intl.DateTimeFormat("zh-CN",{timeZone:BT,year:"numeric",month:"2-digit",day:"2-digit"}),nG=new Intl.DateTimeFormat("zh-CN",{timeZone:BT,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function HT(e){const t=dm(e);if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Date(n):null}function rG(e){const t=HT(e);return t?tG.format(t).replace(/\//g,"-"):"无时间"}function sG(e){const t=HT(e);return t?nG.format(t):""}function iG(e=[]){const t=[];return(Array.isArray(e)?e:[]).forEach((n,r)=>{const s=rG(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 WT(e){const t=ua(e);return t==="done"?"完成":t==="current"?"当前":t==="observed"?"已观察":t==="superseded"?"已更新":t==="blocked"?"阻塞":"待处理"}function Ma(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 oG(e){const t=ua(e==null?void 0:e.status);return ea(e)==="observation"&&t==="done"?"已观察":WT(t)}function VT(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=ua(e.status),s=ea(e)==="observation"&&r==="done"?"observed":r;return n("status",WT(s),s),n("issue",e.issueKey||e.issue_key||e.issue,e.issueKey||e.issue_key||e.issue),n("platform",Ma(e.platform),e.platform),t}function aG(e=[]){const t=new Map;return(Array.isArray(e)?e:[]).forEach(n=>{VT(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 lG(e,t){const n=String(t||"all");return!n||n==="all"?!0:VT(e).some(r=>r.key===n)}function cG(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("平台",Ma(e.platform)),t}function yv(e){const t=[],n=(c,u,d={})=>{const f=zT(u);f&&t.push({...d,label:String(c||f).trim()||f,href:f})},r=(c,u="链接",d=0)=>{if(d>3||c==null)return;if(typeof c=="string"){(/^(https?:\/\/|file:\/\/)/i.test(c)||c.startsWith("/"))&&n(u,c);return}if(Array.isArray(c)){c.forEach((p,h)=>r(p,`${u} ${h+1}`,d+1));return}if(typeof c!="object")return;const f=c.label||c.title||c.name||c.kind||c.type||u;n(f,c.url||c.href||c.path||c.file||c.filePath||c.file_path,c);for(const p of["links","urls","artifacts","outputs","output","results","result","files"])c[p]!=null&&r(c[p],p,d+1)},s=Array.isArray(e==null?void 0:e.links)?e.links:[];for(const c of s)typeof c=="string"?n("链接",c):n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"链接",(c==null?void 0:c.url)||(c==null?void 0:c.href),c);for(const c of Array.isArray(e==null?void 0:e.artifacts)?e.artifacts:[])n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"Artifact",gc(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=Mc(c),d=String(c.key||c.artifactKey||c.artifact_key||"").trim(),f=d?`key:${d}`:u?`review:${o(c.canonicalUrl||c.canonical_url||c.href)}`:`${c.label}
|
|
185
|
-
${c.href}`,p=l.get(f);if(!p){l.set(f,c);continue}if(u){const h=a(p.label),y=a(c.label);(y>h||y===h&&String(c.label||"").length>String(p.label||"").length)&&l.set(f,c)}}return fY(Array.from(l.values()),e)}function uG(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 pb(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 w=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=tY({...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(w)||"",requirementTitle:s}),b={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:w,platform:f.platform||Ma(d.platform),durability:y.durability||d.durability||f.durability||"",persistence:y.persistence||d.persistence||f.persistence||"",truth:y.truth||y.stateTruth||y.state_truth||ea(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)||""};b.href&&n.push(b)};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:gc(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:gc(y)},{documentPath:y.path});const h=gc(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:Ma(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:Ma(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 pb(e))o(d,{issueKey:_i(d),platform:Ma(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 sY(n,window.location.origin)}function dG(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 fG(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 pG(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 hG(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 mG(e){const t=yv(e),n=(s,o)=>{if(Array.isArray(s)){for(const a of s)if(a)if(typeof a=="string")t.push({label:o,href:a});else{const l=a.url||a.href||a.webUrl||a.web_url||a.mrUrl||a.mr_url||a.issueUrl||a.issue_url;l&&t.push({label:a.label||a.title||a.platform||a.kind||o,href:l})}}};n(e==null?void 0:e.mrs,"MR"),n(e==null?void 0:e.mergeRequests,"MR"),n(e==null?void 0:e.merge_requests,"MR"),n(e==null?void 0:e.implMrs,"MR"),n(e==null?void 0:e.impl_mrs,"MR"),n(e==null?void 0:e.platformMrs,"MR"),n(e==null?void 0:e.platform_mrs,"MR");const r=new Set;return t.filter(s=>{const o=String(s.href||"").trim();if(!o)return!1;const a=`${s.label}
|
|
186
|
-
${o}`;return r.has(a)?!1:(r.add(a),!0)})}function gG(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(pG(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=hG(d)||XU(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 fm(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 tl(e){return oY(e)}function pm(e){const t=dm(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 pb(e){var s,o,a,l,c,u,d,f,p,h,y,v;const t=[],n=w=>{w&&typeof w=="object"&&!Array.isArray(w)&&t.push(w)},r=w=>{if(!w||typeof w!="object"||Array.isArray(w))return;const g=Array.isArray(w.issues)?w.issues:Array.isArray(w.children)?w.children:Array.isArray(w.items)?w.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(b=>n((b==null?void 0:b.issue)||b))):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(w=>{Array.isArray(w)&&w.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(w=>{Array.isArray(w)&&w.forEach(r)}),t}function yG(e,t){const n=String(t||"").trim();return n&&pb(e).find((r,s)=>_i(r,s)===n)||null}function wG(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 xG(e,t){if(!t||typeof t!="object")return t;const n=String(t.issueKey||t.issue_key||t.issue||"").trim(),r=yG(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=wG(e);if(!a&&!l)return o;const c=tl(o),u=`${c} ${gv(o)}`;if(!/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue|implementation|impl_|fix_|testing|submit-test|self-test/i.test(u))return o;const f=[];a&&f.push({key:`gitlab-issue:${n}:${(s||"all").toLowerCase()}`,label:"GitLab Issue",kind:"gitlab-issue",durability:"durable",url:a}),l&&f.push({key:"gitlab-epic:requirement",label:"GitLab Epic",kind:"gitlab-epic",durability:"durable",url:l});const p=ua(o.status),h=a&&p==="done"&&/^issue-gitlab:/.test(c)&&/需要.*GitLab Issue/.test(String(o.title||o.label||""));return{...o,...h?{title:String(o.title||o.label||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定"),label:String(o.label||o.title||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定")}:{},artifacts:vi(o.artifacts,f)}}function EC(e,t){const n=pm(t),r=pm(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:mh(s)||mh(t)||mh(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 bG(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||aY(f)||String(f.type||"")==="review-link"||String(f.type||"")==="action-preview"||f.preview===!0||String(f.type||"")==="same-platform-stage-conflict"&&/\/api\/prd-workflow\/review\//.test(String(((p=f.conflict)==null?void 0:p.previousArtifact)||((h=f.conflict)==null?void 0:h.incomingArtifact)||"")))},l=(f,p)=>({...f,links: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=tl(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,w=v?r.get(v)??s.get(y):null;v&&w!=null?(n[w]=u(h,EC(n[w],p)),h&&r.set(h,w),y&&s.set(y,w)):(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=fm(t),p=tl(t),h=p?r.get(p):f?s.get(f):null,y={...t,status:t.status||"next",kind:"next_action"};h!=null&&(n[h]=EC(n[h],y))}return n.map((f,p)=>({item:f,index:p,ts:pm(f)})).filter(f=>Number.isFinite(f.ts)).sort((f,p)=>p.ts-f.ts||f.index-p.index).map(f=>xG(e,f.item))}function kG(e){const t=Array.isArray(e==null?void 0:e.runtimeEvents)?e.runtimeEvents:Array.isArray(e==null?void 0:e.runtime_events)?e.runtime_events:[],n=Array.isArray(e==null?void 0:e.snapshotAudit)?e.snapshotAudit:Array.isArray(e==null?void 0:e.snapshot_audit)?e.snapshot_audit:[];return[...t,...n].filter(s=>s&&typeof s=="object").map((s,o)=>({item:s,index:o,ts:pm(s)})).sort((s,o)=>{const a=Number.isFinite(s.ts),l=Number.isFinite(o.ts);return a&&l?o.ts-s.ts||o.index-s.index:a?-1:l?1:o.index-s.index}).slice(0,8).map(s=>s.item)}function vG(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 SG(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)?`(+${Aa(r)} / 总 ${Aa(s)})`:"";return`${t+1}. ${n}${o}`}function KT(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 Fl(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return NaN}function jG(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 NG(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 CG(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 _G(e){var o,a,l;const t=KT(e);if(!t||typeof t!="object")return null;const n=String(t.type||""),r=String(t.subtype||""),s=Fl(t.timestamp_ms,t.completedAtMs,t.startedAtMs,e==null?void 0:e.ts,Date.now());if(n==="tool_call"&&r==="completed"){const c=NG(t),u=jG(t),d=Fl(t.startedAtMs,c==null?void 0:c.startedAtMs),f=Fl(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):Fl(p.executionTime,p.localExecutionTimeMs),y=String(((l=c==null?void 0:c.args)==null?void 0:l.command)||p.command||"").trim(),v=y?y.split(`
|
|
187
|
-
`).find(Boolean)||y:"";return{kind:"tool",label:CG(u,c),durationMs:Number.isFinite(h)?h:null,at:s,detail:v?v.slice(0,90):""}}if(n==="result"){const c=Fl(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 AC(e,t,n,r){const s=(Array.isArray(e)?e:[]).map(w=>typeof w=="string"?{text:w}:w).filter(w=>w&&String(w.text||"").trim()),o=Array.isArray(t)?t:[],a=[...o].reverse().find(w=>(w==null?void 0:w.kind)==="total"&&Number.isFinite(Number(w.durationMs))),l=[...s].reverse().find(w=>Number.isFinite(Number(w.totalMs))),c=Number.isFinite(Number(r))&&Number.isFinite(Number(n))?Math.max(0,Number(r)-Number(n)):NaN,u=Fl(a==null?void 0:a.durationMs,l==null?void 0:l.totalMs,c),d=s.filter(w=>w.kind==="model").reduce((w,g)=>w+(Number(g.stepMs)||0),0),f=o.filter(w=>(w==null?void 0:w.kind)==="tool"),p=f.reduce((w,g)=>w+(Number(g.durationMs)||0),0),h=o.filter(w=>(w==null?void 0:w.kind)==="network").length,y=[...s.filter(w=>Number(w.stepMs)>=1e3).map(w=>({label:w.text,durationMs:Number(w.stepMs),detail:"Activity 间隔"})),...f.filter(w=>Number(w.durationMs)>=1e3).map(w=>({label:w.label,durationMs:Number(w.durationMs),detail:w.detail||"工具实际执行"}))].sort((w,g)=>g.durationMs-w.durationMs).slice(0,6),v=["耗时概览"];return Number.isFinite(u)&&v.push(`- 当前总耗时:${Aa(u)}`),d>0&&v.push(`- 模型相关间隔:约 ${Aa(d)}(按 Activity 间隔估算)`),f.length>0&&v.push(`- 工具实际执行:${Aa(p)}(${f.length} 次完成事件)`),h>0&&v.push(`- 网络/会话恢复事件:${h} 次`),y.length>0&&(v.push(""),v.push("慢步骤"),y.forEach((w,g)=>{const k=w.detail?` · ${w.detail}`:"";v.push(`${g+1}. ${w.label}:${Aa(w.durationMs)}${k}`)})),s.length>0&&(v.push(""),v.push("最近 Activity"),s.slice(-10).forEach((w,g)=>{v.push(SG(w,g))})),f.length>0&&(v.push(""),v.push("最近工具完成"),f.slice(-8).forEach((w,g)=>{const k=Number.isFinite(Number(w.durationMs))?` ${Aa(w.durationMs)}`:"",b=w.detail?` · ${w.detail}`:"";v.push(`${g+1}. ${w.label}${k}${b}`)})),v.join(`
|
|
188
|
-
`)}function PC(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=KT(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 qT(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 UT(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function wv(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();return t||String(e.id||"").trim()}function YT(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function EG(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 AG(e){const t=String(e??"").trim();return t?t.includes("${")?t:YT(t):""}function GT(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(AG).filter(Boolean):[];return[EG(t,n),YT(o),...a].join(" ")}return String(t.command||"").trim()}function Ku(e){const t=String(wv(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 IC(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function hm(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function qu(e){return hm(e)}function hb(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Op(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 RC(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 TC(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 uw(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=ib(s.get(n),e.sourceHandle||"output-0","source"),a=ib(s.get(r),e.targetHandle||"input-0","target");return!!(o&&a&&qd(o,a))}function PG(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=ib(o,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:Uq(a)}:null}function IG(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"?qd(t.slot,a):qd(a,t.slot)))continue;const c=Ku(n);return{def:n,order:r,category:c,categoryRank:Dl.indexOf(c),slot:a,slotIndex:o,displayLabel:qu(n),description:hb(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 RG(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?qd(n.slot,p):qd(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(w=>w.target===y.target&&w.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,w,g,k,b,j,N,C;const f=Number(((w=(v=u.node)==null?void 0:v.position)==null?void 0:w.y)||0),p=Number(((k=(g=d.node)==null?void 0:g.position)==null?void 0:k.y)||0),h=Number(((j=(b=u.node)==null?void 0:b.position)==null?void 0:j.x)||0),y=Number(((C=(N=d.node)==null?void 0:N.position)==null?void 0:C.x)||0);return f-p||h-y||u.slotIndex-d.slotIndex||String(u.nodeId).localeCompare(String(d.nodeId))})}function rc(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 TG(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 MG(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function $G(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return Yd;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} * * *`:Yd}function Fo(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 xv(e){const t=String(e||"").trim().match(/^(\d{1,2}):(\d{1,2})$/);return t?`${Fo(t[1],9,0,23)}:${Fo(t[2],0,0,59)}`:"09:00"}function Uu(e,t,n,r,s){const o=xv(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()||Yd:`${l} ${a} * * *`}function LG(e){const n=String(e||Yd).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?`${Fo(u,9,0,23)}:${Fo(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 bv(e){let t={};const n=String(e||"").trim();if(n)try{t=JSON.parse(n)}catch{t={}}const r=Number(t.intervalMinutes),s=$G(r),o=typeof t.cron=="string"&&t.cron.trim()?t.cron.trim():s,a=LG(o),l=["daily","weekly","monthly","custom"].includes(t.scheduleType)?t.scheduleType:a.scheduleType,c=xv(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=Uu(l,c,u,d,o);return{enabled:t.enabled===!0,scheduleType:l,time:c,weekday:u,monthDay:d,cron:f,timezone:LY,targetRunNodeId:typeof t.targetRunNodeId=="string"?t.targetRunNodeId.trim():"",overlapPolicy:"skip"}}function OG(e){const t=bv(JSON.stringify(e||{}));return JSON.stringify(t)}function DG(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function FG(e){return e==="weekly"?"每周":e==="monthly"?"每月":e==="custom"?"高级 Cron":"每天"}function MC(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Date.parse(e);if(Number.isFinite(t))return t}return 0}function Dp(e){const t={};for(const n of Array.isArray(e)?e:[]){const r=String((n==null?void 0:n.scheduleNodeId)||(n==null?void 0:n.runNodeId)||"").trim();r&&(t[r]={nextAt:MC(n.nextRunAt),lastAt:MC(n.lastTriggeredAt),lastStatus:String(n.lastStatus||(n.enabled?"armed":"disabled")),lastError:String(n.lastError||""),lastRunId:String(n.lastRunId||""),targetRunNodeId:String(n.targetRunNodeId||n.runNodeId||""),cron:String(n.cron||""),timezone:String(n.timezone||"")})}return t}function mm(e){var t;return!!((t=e==null?void 0:e.data)!=null&&t.isWorkspaceGroup)}function gm(e){return e>0?`Group ${e+1}`:"Group"}function zG(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)||gm(r)).trim()||gm(r),color:String((n==null?void 0:n.color)||"purple").trim()||"purple",x:o,y:a,width:Math.max(Za,Math.round(l)),height:Math.max(el,Math.round(c))}}).filter(Boolean)}function BG(e){var n;return zG((n=e==null?void 0:e.ui)==null?void 0:n.groups).map(r=>({id:r.id,type:mc,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 mb(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(Za,Math.round(t)),height:Math.max(el,Math.round(n))}}function Yu(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:MG(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 JT(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 HG(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=ug(t);return[JT(e),Rn(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 $C(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 WG=new Map,VG=[];function Tu(e,t){var h,y;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=ZT(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 w=r[v]||{},g=w.definitionId||v,k=t.find(D=>D.id===g),b=wv(k)||g,j=t.find(D=>D.id===b)||k,N=w.marketplaceRef||UT(k),C=GT(k),I=o[v]&&typeof o[v].x=="number"&&typeof o[v].y=="number"?o[v]:{x:320+l.size*20,y:180+l.size*12},R=!!Rn({definitionId:b,inputs:w.input,outputs:w.output}),H=a[v]&&typeof a[v].width=="number"&&typeof a[v].height=="number"?{width:a[v].width,height:a[v].height}:null,A=Ba(H,{display:R}),L=A&&!ti(b);return{id:v,type:mc,position:I,...L?{width:A.width,height:A.height}:{},data:{label:w.label||hm(k)||hm(j)||v,definitionId:b,...N?{marketplaceRef:N}:{},...k!=null&&k.packageId?{marketplacePackageId:k.packageId}:{},...k!=null&&k.version?{marketplaceVersion:k.version}:{},schemaType:qT(b,j||k),role:w.role||"normal",model:w.model||void 0,body:w.body||"",script:w.script||C||"",scriptRef:w.scriptRef||"",implementationRef:w.implementationRef||"",implementationMode:w.implementationMode||"",displayReloadKey:w.displayReloadKey||"",...L?{nodeSize:A}:{},...R&&L?{displaySize:A}:{}}}}).map(v=>ab(v,r,t)),d=BG(e),f=s.filter(v=>(v==null?void 0:v.source)&&(v==null?void 0:v.target)).filter(v=>!d.some(w=>w.id===String(v.source)||w.id===String(v.target))).map((v,w)=>({id:v.id||`we-${v.source}-${v.target}-${w}`,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:xU(f,p),instances:r}}function LC(e){return`${fb}${e}`}function Fp(e){const t=String(e||"");return t.startsWith(fb)?t.slice(fb.length):t}function gb(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 gh(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(f=>{var p;return nl((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=Ba(u[f],{display:!0});p&&(c[f]=p)});const d=gb(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:c,...d?{viewport:d}:{}}}function OC(e,t=[]){return gh(e,t)}const dw=[{value:"1",label:"1 天"},{value:"7",label:"7 天"},{value:"30",label:"30 天"},{value:"90",label:"90 天"},{value:"365",label:"1 年"},{value:"permanent",label:"永久"}];function fw(e={}){return{title:"",layout:"gallery",nodeIds:[],expiresInDays:30,permanent:!1,...e}}function DC(e={}){return e.permanent?"permanent":String(e.expiresInDays||30)}function FC(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 KG(e={}){if(!e.expiresAt)return"永久有效";const t=Date.parse(String(e.expiresAt||""));return Number.isFinite(t)?`有效期至 ${new Date(t).toLocaleString()}`:"永久有效"}function zC(e={}){return new URL(e.url||`/display/${e.id||""}`,window.location.origin).href}const XT="af:workspace:canvas-clipboard",QT="agentflow.workspace.canvas-clipboard";function qG(e){return JSON.stringify({type:QT,version:1,clipboard:e})}function UG(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 YG(e){try{localStorage.setItem(XT,qG(e))}catch{}}function GG(){try{return UG(localStorage.getItem(XT))}catch{return null}}function JG(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function yb(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 BC(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function Ba(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:BC(n,OT,DT)||LT,height:BC(r,cm,FT)||cm}}function ym(e){const t=Ba(e,{display:!0});return t?{width:Math.max(320,Math.round(t.width)),height:Math.max(180,Math.round(t.height))}:null}function XG(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:ub,height:db}}function QG(e,t=""){const n=ym(e==null?void 0:e.displaySize);if(n)return n;const r=ym(e==null?void 0:e.nodeSize);if(r)return r;const s=nl(t)||yf(na((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown"));return XG(s)}function zl(e){var s,o,a,l,c,u,d,f,p,h,y;if(ti((s=e==null?void 0:e.data)==null?void 0:s.definitionId))return null;const t=!!Rn(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 Ba({width:n,height:r},{display:t})}function $l(e,t,n){var d,f,p,h,y,v,w,g,k,b,j,N,C;const r=(e||[]).filter(I=>!mm(I)),s=(e||[]).filter(mm),o=ZT(dv(r,n||{})),a=t.map(I=>({source:I.source,target:I.target,sourceHandle:I.sourceHandle??null,targetHandle:I.targetHandle??null})).filter(I=>!s.some(R=>R.id===I.source||R.id===I.target)),l={},c={},u=[];for(const I of r){l[I.id]={x:((d=I.position)==null?void 0:d.x)||0,y:((f=I.position)==null?void 0:f.y)||0};const R=zl(I);R&&(c[I.id]=R)}for(const I of s){const R=Number(((h=(p=I.data)==null?void 0:p.nodeSize)==null?void 0:h.width)||I.width||((y=I.measured)==null?void 0:y.width)||0),H=Number(((w=(v=I.data)==null?void 0:v.nodeSize)==null?void 0:w.height)||I.height||((g=I.measured)==null?void 0:g.height)||0);u.push({id:I.id,title:String(((k=I.data)==null?void 0:k.title)||((b=I.data)==null?void 0:b.label)||"Group"),color:String(((j=I.data)==null?void 0:j.color)||"purple"),x:Number(((N=I.position)==null?void 0:N.x)||0),y:Number(((C=I.position)==null?void 0:C.y)||0),width:Math.max(Za,Math.round(R||Za)),height:Math.max(el,Math.round(H||el))})}return{version:1,instances:o,edges:a,ui:{nodePositions:l,nodeSizes:c,groups:u}}}function ZT(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!nl(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 nl(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 Rn(e){const t=nl(e==null?void 0:e.definitionId);return t||(ti(e==null?void 0:e.definitionId)&&ug(e)?yf(na((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=Rn(e),r=ti(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 ta(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 ZG(e){let t=String(e||"").replace(/\r\n/g,`
|
|
189
|
-
`).trim();return t.includes(`
|
|
190
|
-
`)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
|
|
191
|
-
$1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
|
|
192
|
-
$2`)),t}function 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=ZG(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const d=String(c[1]||"").trim();return d==="|"||d===">"?a.slice((c.index||0)+c[0].length).split(`
|
|
193
|
-
`).filter(p=>/^\s+/.test(p)||!p.trim()).map(p=>p.replace(/^\s{2}/,"")).join(`
|
|
194
|
-
`).replace(/\s+$/g,""):d.replace(/^["']|["']$/g,"")}const u=t.replace(n[0],"").trim();if(u)return u}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),o=t.lastIndexOf("}");s>=0&&o>s&&r.unshift(t.slice(s,o+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}async function rl(e,t){const n=$r(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 wb(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 eJ(e,t=[],n=[]){const r=String(e||"");if(!r)return"";const s=new Map(t.map(o=>[o.id,o]));return(Array.isArray(n)?n:[]).filter(o=>String((o==null?void 0:o.target)||"")===r).slice(0,4).map(o=>{const a=s.get(String((o==null?void 0:o.source)||""));if(!a)return"";const l=a.data||{},c=String(l.body||"").trim(),u=[`- upstreamId: ${a.id}`,` label: ${String(l.label||a.id).trim()}`,` definitionId: ${String(l.definitionId||"").trim()}`];return c&&u.push(` task: ${c.slice(0,4e3)}`),u.join(`
|
|
195
|
-
`)}).filter(Boolean).join(`
|
|
196
|
-
|
|
197
|
-
`)}function Vc(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 tJ(e){const t=Vc(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function $a(e,t){return e==="html"?tJ(t):""}function eM(e,t=""){const n=Vc(e);if(!n.trim())return"";const s=`<base target="_blank"><script data-agentflow-display-link-guard="1">
|
|
198
|
-
(() => {
|
|
199
|
-
const frameId = ${JSON.stringify(String(t||""))};
|
|
200
|
-
const postSize = () => {
|
|
201
|
-
const doc = document.documentElement;
|
|
202
|
-
const body = document.body;
|
|
203
|
-
const height = Math.ceil(Math.max(
|
|
204
|
-
doc ? doc.scrollHeight : 0,
|
|
205
|
-
doc ? doc.offsetHeight : 0,
|
|
206
|
-
doc ? doc.clientHeight : 0,
|
|
207
|
-
body ? body.scrollHeight : 0,
|
|
208
|
-
body ? body.offsetHeight : 0,
|
|
209
|
-
body ? body.clientHeight : 0,
|
|
210
|
-
window.innerHeight || 0
|
|
211
|
-
));
|
|
212
|
-
window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
|
|
213
|
-
};
|
|
214
|
-
document.addEventListener("click", (event) => {
|
|
215
|
-
const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
|
|
216
|
-
if (!link) return;
|
|
217
|
-
const rawHref = String(link.getAttribute("href") || "").trim();
|
|
218
|
-
if (!rawHref || rawHref.startsWith("#")) return;
|
|
219
|
-
if (/^javascript:/i.test(rawHref)) {
|
|
220
|
-
event.preventDefault();
|
|
221
|
-
return;
|
|
222
|
-
}
|
|
223
|
-
event.preventDefault();
|
|
224
|
-
window.open(link.href, "_blank", "noopener,noreferrer");
|
|
225
|
-
}, true);
|
|
226
|
-
window.addEventListener("load", postSize);
|
|
227
|
-
window.addEventListener("resize", postSize);
|
|
228
|
-
requestAnimationFrame(postSize);
|
|
229
|
-
setTimeout(postSize, 60);
|
|
230
|
-
setTimeout(postSize, 300);
|
|
231
|
-
if (typeof ResizeObserver !== "undefined") {
|
|
232
|
-
const resizeObserver = new ResizeObserver(postSize);
|
|
233
|
-
resizeObserver.observe(document.documentElement);
|
|
234
|
-
if (document.body) resizeObserver.observe(document.body);
|
|
235
|
-
}
|
|
236
|
-
if (typeof MutationObserver !== "undefined") {
|
|
237
|
-
const mutationObserver = new MutationObserver(postSize);
|
|
238
|
-
mutationObserver.observe(document.documentElement, { childList: true, subtree: true, attributes: true, characterData: true });
|
|
239
|
-
}
|
|
240
|
-
})();
|
|
241
|
-
<\/script>`;return/data-agentflow-display-link-guard=["']1["']/i.test(n)?n:/<head\b[^>]*>/i.test(n)?n.replace(/<head\b([^>]*)>/i,`<head$1>${s}`):/<html\b[^>]*>/i.test(n)?n.replace(/<html\b([^>]*)>/i,`<html$1><head>${s}</head>`):`<!doctype html><html><head>${s}</head><body>${n}</body></html>`}function nJ(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 rJ(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function sJ(e,t){const n=URL.createObjectURL(e);try{rJ(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function tM(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 iJ(e){const t=tM(e);return t!=null&&t.documentElement?`${t.doctype?`<!DOCTYPE ${t.doctype.name}${t.doctype.publicId?` PUBLIC "${t.doctype.publicId}"`:""}${t.doctype.systemId?` "${t.doctype.systemId}"`:""}>`:"<!DOCTYPE html>"}
|
|
242
|
-
${t.documentElement.outerHTML}`:""}function pw(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 oJ(e,t,n,r={}){var w;const s=(w=e==null?void 0:e.getBoundingClientRect)==null?void 0:w.call(e),o=tM(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:pw(c),displayBody:pw(u),scroller:pw(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 aJ({flowParams:e,content:t,sourceFilePath:n,iframe:r,width:s,height:o,filename:a,snapshotElements:l,displaySize:c}){const u=oJ(r,s,o,{...l||{},displaySize:c}),d=iJ(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();sJ(p,a)}function lJ(e){const n=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]].find(r=>(r==null?void 0:r.name)==="alt");return String((n==null?void 0:n.value)||(n==null?void 0:n.default)||(e==null?void 0:e.label)||"Image preview")}function nM(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="react"?"deployed_code":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function cJ(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 rM({code:e}){const t=m.useMemo(()=>cJ(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),w=h?Math.min(v,d.scrollTop/Math.max(1,f-p)*v):0;o({visible:h,top:w,height:y})},[]);m.useEffect(()=>{const d=requestAnimationFrame(a),f=n.current;if(!f||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(d);const p=new ResizeObserver(a);p.observe(f);for(const h of Array.from(f.children))p.observe(h);return()=>{cancelAnimationFrame(d),p.disconnect()}},[t,a]);const l=m.useCallback(d=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,d))*p,a()},[a]),c=m.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(d-h.top-f)/v},[s.height]),u=m.useCallback(d=>{var j,N;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,w=d.clientY>=p.top+h&&d.clientY<=p.top+h+y?d.clientY-p.top-h:y/2;l(c(d.clientY,w));const g=d.pointerId;(N=(j=d.currentTarget).setPointerCapture)==null||N.call(j,g);const k=C=>{C.preventDefault(),l(c(C.clientY,w))},b=()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",b),window.removeEventListener("pointercancel",b)};window.addEventListener("pointermove",k),window.addEventListener("pointerup",b),window.addEventListener("pointercancel",b)},[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 sM({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const s=Rn(e),o=no(e),a=s==="image"?o:Ei(o),l=s==="image"?"":ta(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(""),rl(t,l).then(b=>{k||u(b)}).catch(b=>{k||f(String(b.message||b))}).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"?Vc(y):s==="react"?cg(y):Ei(y),w=m.useRef("");if(w.current||(w.current=`html-display-${Math.random().toString(36).slice(2,10)}`),!s)return null;const g=$a(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"?fv(v,w.current):eM(v,w.current)},r)});if(s==="image"){const k=Gd(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:lJ(e),loading:"lazy"})})}return s==="markdown"?i.jsx(fi,{className:"af-work-display-body af-work-display-body--markdown",children:i.jsx(ov,{content:v,basePath:l,resolveSrc:(k,b)=>Gd(k,t,b)})}):s==="chart"?i.jsx(fi,{className:"af-work-display-body af-work-display-body--chart",children:i.jsx(lv,{content:v})}):s==="table"?i.jsx(fi,{className:"af-work-display-body af-work-display-body--table",children:i.jsx(av,{content:v})}):s==="mermaid"?i.jsxs(fi,{className:"af-work-display-body",children:[i.jsx(rM,{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 uJ({node:e,onClose:t}){var k,b,j,N,C,I,R,H,A,L,D;const n=m.useRef(null),r=Rn(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=!!((b=e==null?void 0:e.data)!=null&&b.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):"",w=r==="markdown"?ta(v,"markdown"):"",g=r==="markdown"?w?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"||!w?(f(""),h(!1),()=>{O=!0}):(h(!0),rl(((M=e==null?void 0:e.data)==null?void 0:M.flowParams)||{},w).then(K=>{O||f(K)}).catch(K=>{var z,F;O||(f(""),(F=(z=e==null?void 0:e.data)==null?void 0:z.onStatus)==null||F.call(z,String(K.message||K)))}).finally(()=>{O||h(!1)}),()=>{O=!0})},[r,w,(N=(j=e==null?void 0:e.data)==null?void 0:j.flowParams)==null?void 0:N.flowId,(I=(C=e==null?void 0:e.data)==null?void 0:C.flowParams)==null?void 0:I.flowSource,(H=(R=e==null?void 0:e.data)==null?void 0:R.flowParams)==null?void 0:H.archived,(A=e==null?void 0:e.data)==null?void 0:A.displayReloadKey]),m.useEffect(()=>{a||u(String(g||""))},[g,a]),e?ur.createPortal(i.jsx("div",{className:"af-display-preview-overlay",role:"dialog","aria-modal":"true","aria-label":"全屏预览",children:i.jsxs("div",{className:"af-display-preview-shell",children:[i.jsxs("div",{className:"af-display-preview-head",children:[i.jsxs("div",{className:"af-display-preview-title",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:nM(r)}),i.jsx("strong",{children:s}),i.jsx("span",{children:e.id})]}),i.jsxs("div",{className:"af-display-preview-actions",children:[r==="markdown"?a?i.jsxs(i.Fragment,{children:[i.jsx("button",{type:"button",className:"af-display-preview-action",disabled:o||p,onClick:async()=>{var O,M;try{await oM({nodeId:e.id,data:e.data,filePath:w,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(iM,{value:c,onChange:u,onUploadImage:(L=e.data)==null?void 0:L.onUploadWorkspaceImage,readOnly:o}):i.jsx(sM,{data:e.data,flowParams:(D=e.data)==null?void 0:D.flowParams,htmlFrameRef:n})})]})}),document.body):null}function dJ({node:e}){var p,h,y,v,w,g,k,b,j,N;const t=Rn(e==null?void 0:e.data),n=no(e==null?void 0:e.data),r=t==="image"?n:Ei(n),s=t==="image"?"":ta(r,t),[o,a]=m.useState(""),[l,c]=m.useState(!1);m.useEffect(()=>{var I;let C=!1;return s?(c(!0),a(""),rl(((I=e==null?void 0:e.data)==null?void 0:I.flowParams)||{},s).then(R=>{C||a(R)}).catch(()=>{C||a("")}).finally(()=>{C||c(!1)}),()=>{C=!0}):(a(""),c(!1),()=>{C=!0})},[s,(h=(p=e==null?void 0:e.data)==null?void 0:p.flowParams)==null?void 0:h.flowId,(v=(y=e==null?void 0:e.data)==null?void 0:y.flowParams)==null?void 0:v.flowSource,(g=(w=e==null?void 0:e.data)==null?void 0:w.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"?Vc(u):t==="react"?cg(u):Ei(u),f=$a(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:((b=e==null?void 0:e.data)==null?void 0:b.label)||(e==null?void 0:e.id),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:t==="react"?fv(d):eM(d)}):t==="image"?i.jsx("img",{src:Gd(d,(j=e==null?void 0:e.data)==null?void 0:j.flowParams),alt:((N=e==null?void 0:e.data)==null?void 0:N.label)||(e==null?void 0:e.id),loading:"lazy"}):t==="markdown"?i.jsx("div",{className:"af-display-picker-preview__markdown",children:i.jsx(ov,{content:d,basePath:s,resolveSrc:(C,I)=>{var R;return Gd(C,(R=e==null?void 0:e.data)==null?void 0:R.flowParams,I)}})}):t==="chart"?i.jsx(lv,{content:d}):t==="table"?i.jsx(av,{content:d}):t==="mermaid"?i.jsxs("div",{className:"af-display-picker-preview__diagram",children:[i.jsx(rM,{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 iM({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),b=Math.max(1,g.clientHeight),j=k>b+1,N=j?Math.max(12,b/k*100):100,C=Math.max(0,100-N),I=j?Math.min(C,g.scrollTop/Math.max(1,k-b)*C):0;d({visible:j,top:I,height:N})},[]);m.useEffect(()=>{const g=requestAnimationFrame(f),k=s.current;if(!k||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(g);const b=new ResizeObserver(f);return b.observe(k),()=>{cancelAnimationFrame(g),b.disconnect()}},[f,e]);const p=m.useCallback(g=>{const k=s.current;if(!k)return;const b=Math.max(0,k.scrollHeight-k.clientHeight);k.scrollTop=Math.min(1,Math.max(0,g))*b,f()},[f]),h=m.useCallback((g,k=0)=>{const b=a.current;if(!b)return 0;const j=b.getBoundingClientRect(),N=u.height/100*j.height,C=Math.max(1,j.height-N);return(g-j.top-k)/C},[u.height]),y=m.useCallback(g=>{if(!u.visible)return;g.preventDefault(),g.stopPropagation();const k=a.current;if(!k)return;const b=k.getBoundingClientRect(),j=u.top/100*b.height,N=u.height/100*b.height,I=g.clientY>=b.top+j&&g.clientY<=b.top+j+N?g.clientY-b.top-j:N/2;p(h(g.clientY,I));const R=A=>{A.preventDefault(),p(h(A.clientY,I))},H=()=>{window.removeEventListener("pointermove",R),window.removeEventListener("pointerup",H),window.removeEventListener("pointercancel",H)};window.addEventListener("pointermove",R),window.addEventListener("pointerup",H),window.addEventListener("pointercancel",H)},[h,p,u.height,u.top,u.visible]),v=m.useCallback(g=>{const k=String(e||""),b=s.current,j=Number((b==null?void 0:b.selectionStart)??k.length),N=Number((b==null?void 0:b.selectionEnd)??j),C=k.slice(0,j),I=k.slice(N),R=C&&!C.endsWith(`
|
|
243
|
-
`)?`
|
|
244
|
-
`:"",H=I&&!I.startsWith(`
|
|
245
|
-
`)?`
|
|
246
|
-
`:"",A=`${C}${R}${g}${H}${I}`;t==null||t(A),window.requestAnimationFrame(()=>{var D,O;const L=C.length+R.length+g.length;(D=s.current)==null||D.focus(),(O=s.current)==null||O.setSelectionRange(L,L)})},[t,e]),w=m.useCallback(async g=>{if(!r&&!(!g||l)){c(!0);try{const k=await(n==null?void 0:n(g)),b=String(k||"").trim();if(b){const j=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 b;Array.from(((b=g.dataTransfer)==null?void 0:b.items)||[]).some(j=>String((j==null?void 0:j.type)||"").startsWith("image/"))&&(g.preventDefault(),g.dataTransfer.dropEffect="copy")},onDrop:g=>{var b;const k=Array.from(((b=g.dataTransfer)==null?void 0:b.files)||[]).find(um);k&&(g.preventDefault(),w(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 b;const k=(b=g.target.files)==null?void 0:b[0];g.target.value="",k&&w(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 fJ({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,w)=>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||w}-${w}`)),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 w=v.currentTarget.value;c(w),(g=t==null?void 0:t.onUpdateNodeChatDraft)==null||g.call(t,e,w)},onChange:v=>{var g;const w=v.target.value;c(w),u.current||(g=t==null?void 0:t.onUpdateNodeChatDraft)==null||g.call(t,e,w)},onKeyDown:v=>{var w,g;v.isComposing||(w=v.nativeEvent)!=null&&w.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 w;v.stopPropagation(),(w=t==null?void 0:t.onToggleNodeChat)==null||w.call(t,e)},title:"微调这个节点","aria-label":"微调这个节点",children:[i.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__plus","aria-hidden":!0,children:"add"}),i.jsx("span",{className:"af-work-node-chat-anchor__label",children:"继续微调这个展示"}),i.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__expand","aria-hidden":!0,children:"open_in_full"})]})}function pJ(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="react"?"json":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function hJ(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function mJ(e){return String(e||"node").trim().replace(/[^a-zA-Z0-9._-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,120)||"node"}function HC(e,t=""){const n=ta(e,t).replace(/^\/+/,"");return n.startsWith("outputs/")?n:""}function gJ(e,t){const n=mJ(e),r=new Set,s=Rn(t)||"";ti(t==null?void 0:t.definitionId)&&r.add(`outputs/${n}`);const o=HC(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=HC(u,s);return d&&r.add(d),u===`outputs/${n}`||u.startsWith(`outputs/${n}/`)})&&r.add(`outputs/${n}`),Array.from(r)}function WC(e,t){const n=Rn(t)||"markdown";return`outputs/${hJ((t==null?void 0:t.label)||e||n)}.${pJ(n)}`}async function oM({nodeId:e,data:t,filePath:n,content:r,setFileContent:s}){var o,a;if(n){const l=await wb((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 aM({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,gt;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(((gt=ce.slot)==null?void 0:gt.type)||"").trim();return $e==="node"&&Ce!=="node"?-1:Ce==="node"&&$e!=="node"?1:Z.idx-ce.idx}),l=Rn(t),c=m.useRef(null),u=m.useRef(null),[d,f]=m.useState(0),[p,h]=m.useState(!1),[y,v]=m.useState(!1),[w,g]=m.useState(!1),[k,b]=m.useState(""),[j,N]=m.useState(""),[C,I]=m.useState(!1),[R,H]=m.useState(!1),A=m.useRef(null),L=no(t),D=l==="markdown"?Ei(L):"",O=l==="markdown"?ta(D,"markdown"):"",M=l==="markdown"?O?j:D:"",K=!!(t!=null&&t.readOnly),z=!!(t!=null&&t.displayPageMode);m.useEffect(()=>{let Z=!1;return l!=="markdown"||!O?(N(""),I(!1),()=>{Z=!0}):(I(!0),rl((t==null?void 0:t.flowParams)||{},O).then(ce=>{Z||N(ce)}).catch(ce=>{var de;Z||(N(""),(de=t==null?void 0:t.onStatus)==null||de.call(t,String(ce.message||ce)))}).finally(()=>{Z||I(!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(()=>{w||b(String(M||""))},[M,w]);const F=(t==null?void 0:t.label)||(l==="mermaid"?"Mermaid":l==="ascii"?"ASCII":l==="html"?"HTML":l==="react"?"React App":l==="image"?"Image":l==="chart"?"Chart":l==="table"?"Table":"Markdown"),$=String((t==null?void 0:t.sourceNodeId)||e),W=(t==null?void 0:t.sharingDisplayNodeId)===$,E=t!=null&&t.displaySize&&Number(t.displaySize.width)>0&&Number(t.displaySize.height)>0?{width:Number(t.displaySize.width),height:Number(t.displaySize.height)}:null,Q=m.useCallback(async()=>{var Te,st,mt,Tt,xe,Oe,ie,ke,Ke,Ue;if(l!=="html"||p)return;const Z=no(t),ce=ta(Z,l);let de=Z;if(ce)try{de=await rl((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=Vc(de);if(!me.trim())return;const $e=$a(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=(Tt=(mt=c.current)==null?void 0:mt.querySelector)==null?void 0:Tt.call(mt,".af-work-display-body"),Be=(Oe=(xe=c.current)==null?void 0:xe.querySelector)==null?void 0:Oe.call(xe,".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(((ie=c.current)==null?void 0:ie.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))),gt=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 aJ({flowParams:(t==null?void 0:t.flowParams)||{},content:me,sourceFilePath:ce,iframe:u.current,width:ot,height:gt,filename:nJ((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 It=String((be==null?void 0:be.message)||be||"截图失败");(Ue=t==null?void 0:t.onStatus)==null||Ue.call(t,`HTML 截图失败:${It}`),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"&&(b(""),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(um)||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",H(!0))},[l,K]),ue=m.useCallback(Z=>{l==="image"&&(Z.currentTarget.contains(Z.relatedTarget)||H(!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(um);ce&&(Z.preventDefault(),Z.stopPropagation(),H(!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":"")+(R?" af-work-display-card--image-drop":"")+(z?" af-work-display-card--presentation":"")+(t!=null&&t.isExecuting?" af-work-display-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-display-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-display-card--failed":""),style:E?{width:E.width,height:E.height}:void 0,ref:c,onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,onDragOver:se,onDragLeave:ue,onDrop:G,children:[i.jsx(Vk,{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(Jn,{type:"target",position:qe.Left,id:`input-${ce}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:de,background:Mn(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(Jn,{type:"source",position:qe.Right,id:`output-${ce}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:me,background:Mn(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:nM(l)}),i.jsx("strong",{children:F}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"display"})]}),l==="html"?i.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick: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"?w?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 oM({nodeId:e,data:t,filePath:O,content:k,setFileContent:N}),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:()=>{b(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(),b(String(M||"")),g(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:i.jsx("span",{className:"material-symbols-outlined",children:"edit"})}):null,l==="image"?i.jsxs(i.Fragment,{children:[i.jsx("input",{ref:A,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:Z=>{var de;const ce=(de=Z.target.files)==null?void 0:de[0];Z.target.value="",ce&&V(ce)}}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:K,onClick:Z=>{var ce;Z.stopPropagation(),(ce=A.current)==null||ce.click()},"aria-label":"上传图片",title:"上传图片",children:i.jsx("span",{className:"material-symbols-outlined",children:"upload"})})]}):null,i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",onClick:Z=>{var ce;Z.stopPropagation(),(ce=t==null?void 0:t.onOpenDisplayPreview)==null||ce.call(t,$)},"aria-label":"全屏预览",title:"全屏预览",children:i.jsx("span",{className:"material-symbols-outlined",children:"fullscreen"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:W,onClick:Z=>{var ce;Z.stopPropagation(),(ce=t==null?void 0:t.onShareDisplayNode)==null||ce.call(t,$)},"aria-label":"分享展示",title:"分享展示",children:i.jsx("span",{className:"material-symbols-outlined",children:W?"hourglass_empty":"ios_share"})}),i.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled: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"&&w?i.jsx(iM,{value:k,onChange:b,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:K}):i.jsx(sM,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:u,htmlFrameVersion:d}),i.jsx(fJ,{nodeId:e,data:t})]})}function yJ({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`,w=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:w}),i.jsx(Jn,{type:"target",position:qe.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:v,background:Mn(h.type)},title:`${w} · ${h.type}`})]},`in-${y}`)}),o.map((h,y)=>{if(h.showOnNode===!1)return null;const v=`${2.25+y*1.75}rem`,w=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:w}),i.jsx(Jn,{type:"source",position:qe.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:v,background:Mn(h.type)},title:`${w} · ${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 wJ({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:o,workspaces:a}){var Ue,be,It,nn,Vt,Ot,ln;const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],u=MJ(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))||((It=t==null?void 0:t.runningRunNodeIds)==null?void 0:It[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",v=(t==null?void 0:t.nodeStatus)==="stopped",w=!!(t!=null&&t.readOnly),g=Array.isArray(s)?s:[],k=Array.isArray(o)?o:[],b=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]),[j,N]=m.useState(!1),[C,I]=m.useState(""),[R,H]=m.useState(()=>new Set),[A,L]=m.useState(!1),[D,O]=m.useState(""),[M,K]=m.useState("config"),z=ug(t),F=!!z,$=hM(u.displayType),W=m.useMemo(()=>QG(t,$),[t==null?void 0:t.displaySize,t==null?void 0:t.nodeSize,t==null?void 0:t.inputs,t==null?void 0:t.input,$]),E=m.useMemo(()=>({...t,sourceNodeId:e,label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务",definitionId:$,displaySize:W,nodeSize:W,body:z,inputs:[{type:"text",name:$==="display_image"?"src":"content",value:z,default:z}],outputs:c.length?c:[{type:"node",name:"next",default:""}]}),[t,$,e,z,c,W]),Q=Array.isArray((nn=t==null?void 0:t.modelLists)==null?void 0:nn.cursor)?t.modelLists.cursor:[],V=Array.isArray((Vt=t==null?void 0:t.modelLists)==null?void 0:Vt.opencode)?t.modelLists.opencode:[],B=Array.isArray((Ot=t==null?void 0:t.modelLists)==null?void 0:Ot.claudeCode)?t.modelLists.claudeCode:[],se=Array.isArray((ln=t==null?void 0:t.modelLists)==null?void 0:ln.codex)?t.modelLists.codex:[],ue=m.useMemo(()=>new Set(Q.map(js)),[Q]),G=m.useMemo(()=>new Set(V.map(js)),[V]),ee=m.useMemo(()=>new Set(B.map(js)),[B]),te=m.useMemo(()=>new Set(se.map(js)),[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 Mt=Zo(Ze,g).map(_t=>Ce.get(_t)).filter(Boolean);for(const _t of Mt)re.add(_t.key);return{...Ze,skills:Mt}}).filter(Ze=>Ze.skills.length>0),Je=g.filter(Ze=>!re.has(Ze.key));return{collectionGroups:Re,ungrouped:Je}},[k,Ce,g]);m.useEffect(()=>{H(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(Mt=>String(Mt||"").toLowerCase()).join(" ").includes(re);return{collectionGroups:_e.collectionGroups.map(Ze=>{const Mt=[Ze==null?void 0:Ze.id,Ze==null?void 0:Ze.name,Ze==null?void 0:Ze.description].map(_t=>String(_t||"").toLowerCase()).join(" ").includes(re);return{...Ze,skills:Mt?Ze.skills:Ze.skills.filter(Re)}}).filter(Ze=>Ze.skills.length>0),ungrouped:_e.ungrouped.filter(Re)}},[_e,C]),ot=xb(j,[Be.collectionGroups.length,Be.ungrouped.length,R.size,u.skillKeys.length,C]),gt=m.useMemo(()=>{const re=D.trim().toLowerCase();return re?b.filter(Re=>[Re.id,Re.label,Re.path,Re.repoUrl,Re.branch,Re.mountPath,Re.type].join(" ").toLowerCase().includes(re)):b},[b,D]),Te=m.useMemo(()=>wM(u.knowledgeContext),[u.knowledgeContext]),st=m.useMemo(()=>new Set(Te.map(re=>re.id||re.path||re.repoPath).filter(Boolean)),[Te]),mt=xb(A,[gt.length,Te.length,D]);m.useEffect(()=>{u.task!==h.current&&(h.current=u.task,p.current||f(u.task))},[u.task]),m.useEffect(()=>{if(!F){K("config");return}y||K("result")},[F,z,y]),m.useEffect(()=>{var Re,Je;if(!(M==="result"&&F))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,$,F,e,z,W,M]);const Tt=re=>{var Re;(Re=t==null?void 0:t.onChangeContextRunConfig)==null||Re.call(t,e,{...u,task:d,...re})},xe=(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}))},Oe=(re,Re)=>{const Je=new Set(u.skillKeys);for(const Ze of re){const Mt=String(Ze||"").trim();Mt&&(Re?Je.add(Mt):Je.delete(Mt))}Tt({skillKeys:Array.from(Je)})},ie=re=>{H(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=b.filter(Mt=>{const _t=Mt.id||Mt.path||"";return _t===Je?Re:st.has(_t)});Tt({knowledgeContext:dg(Ze)})},Ke=()=>{Tt({knowledgeContext:null})};return M==="result"&&F?i.jsx(aM,{id:e,data:{...E,selected:t==null?void 0:t.selected,onSelectNodePointerDown:t==null?void 0:t.onSelectNodePointerDown},selected:n,deleteNode:r}):i.jsxs("div",{className:"af-work-context-run-card"+(n?" af-work-context-run-card--selected":"")+(M==="result"&&F?" af-work-context-run-card--result":"")+(y?" af-work-context-run-card--running":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-context-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-context-run-card--failed":"")+(v?" af-work-context-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((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(Jn,{type:"target",position:qe.Left,id:`input-${Re}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:Je,background:Mn(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(Jn,{type:"source",position:qe.Right,id:`output-${Re}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:Je,background:Mn(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:w,"aria-label":"模型",title:ce||"默认模型",onChange:re=>Tt({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:${js(re)}`,children:js(re)},`context-cursor-${re}`))}):null,V.length?i.jsx("optgroup",{label:"OpenCode",children:V.map(re=>i.jsx("option",{value:`opencode:${js(re)}`,children:js(re)},`context-opencode-${re}`))}):null,se.length?i.jsx("optgroup",{label:"Codex",children:se.map(re=>i.jsx("option",{value:`codex:${js(re)}`,children:js(re)},`context-codex-${re}`))}):null,B.length?i.jsx("optgroup",{label:"Claude Code",children:B.map(re=>i.jsx("option",{value:`claude-code:${js(re)}`,children:js(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:ti(t==null?void 0:t.definitionId)?"workspace_one_click_task":(t==null?void 0:t.definitionId)||"workspace_one_click_task"}),F?i.jsxs("div",{className:"af-work-context-run-card__view-switch nodrag",onClick: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:w,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:w,placeholder:"输入任务,例如:基于选中的知识库总结需求并生成展示页",onCompositionStart:()=>{p.current=!0},onCompositionEnd:re=>{p.current=!1,f(re.currentTarget.value),xe(re.currentTarget.value)},onChange:re=>{f(re.target.value)},onBlur:re=>xe(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:w,className:"af-work-context-run-card__select",onClick:re=>{var Re;re.stopPropagation(),j||(Re=t==null?void 0:t.onRefreshSkills)==null||Re.call(t),N(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"})]}),j?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=>I(re.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),C?i.jsx("button",{type:"button",onClick:()=>I(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref: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(_t=>_t.key),Je=Re.filter(_t=>$e.has(_t)).length,Ze=Re.length>0&&Je===Re.length,Mt=R.has(re.id);return i.jsxs("section",{className:"af-work-load-skills-menu__group"+(Mt?" 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:w,onChange:_t=>Oe(Re,_t.target.checked),"aria-label":`选择 ${re.name}`}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>ie(re.id),"aria-expanded":!Mt,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:()=>ie(re.id),"aria-label":Mt?`展开 ${re.name}`:`收起 ${re.name}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Mt?"chevron_right":"expand_more"})})]}),Mt?null:i.jsx("div",{className:"af-work-load-skills-menu__options",children:re.skills.map(_t=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:$e.has(_t.key),disabled:w,onChange:Kn=>Oe([_t.key],Kn.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:_t.name}),_t.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:_t.description}):null]})]},`${re.id}:${_t.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:w,onChange:Re=>Oe([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:()=>Tt({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:w,className:"af-work-context-run-card__select",onClick:re=>{var Re;re.stopPropagation(),A||(Re=t==null?void 0:t.onRefreshWorkspaces)==null||Re.call(t),L(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"})]}),A?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:D,onChange:re=>O(re.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),D?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:mt.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:mt.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:gt.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:gt.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:w,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}`))})]}),gt.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:mt.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(mt.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:mt.handleScrollbarPointerDown,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${mt.scrollbar.height}%`,top:`${mt.scrollbar.top}%`}})})]}):null]}),i.jsxs("select",{value:u.displayType,disabled:w,onChange:re=>Tt({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"})]})]}),z?i.jsx("pre",{className:"af-work-context-run-card__preview",children:z.slice(0,520)}):null]}),i.jsxs("div",{className:"af-work-context-run-card__actions",children:[i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-context-run-card__run nodrag"+(y?" af-work-run-card__button--stop":""),disabled:w,onClick:re=>{var Re,Je;re.stopPropagation(),xe(),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 xJ({id:e,data:t,selected:n,deleteNode:r}){var I,R,H;const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=bv((t==null?void 0:t.body)||""),[l,c]=m.useState(a.cron),u=(t==null?void 0:t.scheduledRunState)||{},d=((R=(I=t==null?void 0:t.runningRunNodeIds)==null?void 0:I.has)==null?void 0:R.call(I,e))||((H=t==null?void 0:t.runningRunNodeIds)==null?void 0:H[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",f=(t==null?void 0:t.optimizingRun)===!0,p=(t==null?void 0:t.nodeStatus)==="stopped",h=!!(t!=null&&t.readOnly),y=A=>{var L;(L=t==null?void 0:t.onChangeScheduledRunConfig)==null||L.call(t,e,{...a,...A})},v=A=>{y({scheduleType:A,cron:Uu(A,a.time,a.weekday,a.monthDay,a.cron)})},w=A=>{y({time:A,cron:Uu(a.scheduleType,A,a.weekday,a.monthDay,a.cron)})},[g,k]=xv(a.time).split(":"),b=(A,L)=>{w(`${Fo(A,9,0,23)}:${Fo(L,0,0,59)}`)},j=A=>{y({weekday:A,cron:Uu(a.scheduleType,a.time,A,a.monthDay,a.cron)})},N=A=>{y({monthDay:A,cron:Uu(a.scheduleType,a.time,a.weekday,A,a.cron)})};m.useEffect(()=>{c(a.cron)},[a.cron,e]);const C=()=>{h||l===a.cron||y({cron:l})};return i.jsxs("div",{className:"af-work-run-card af-work-schedule-card"+(n?" af-work-run-card--selected":"")+(a.enabled?" af-work-schedule-card--enabled":"")+(d?" af-work-run-card--running":"")+(t!=null&&t.isExecuting?" af-work-run-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-run-card--failed":"")+(p?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[s.map((A,L)=>{if(A.showOnNode===!1)return null;const D=`${2.25+L*1.75}rem`,O=A.name||`#${L+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:D},children:O}),i.jsx(Jn,{type:"target",position:qe.Left,id:`input-${L}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:D,background:Mn(A.type)},title:`${O} · ${A.type}`})]},`in-${L}`)}),o.map((A,L)=>{if(A.showOnNode===!1)return null;const D=`${2.25+L*1.75}rem`,O=A.name||`#${L+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:D},children:O}),i.jsx(Jn,{type:"source",position:qe.Right,id:`output-${L}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:D,background:Mn(A.type)},title:`${O} · ${A.type}`})]},`out-${L}`)}),i.jsxs("div",{className:"af-work-run-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"event_repeat"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Scheduled Run"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_scheduled_run"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:h,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-schedule-card__body nodrag",children:[i.jsxs("label",{className:"af-work-schedule-card__toggle",children:[i.jsx("input",{type:"checkbox",checked:a.enabled,disabled:h,onChange:A=>y({enabled:A.target.checked})}),i.jsx("span",{children:a.enabled?"定时开启":"定时关闭"})]}),i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"频率"}),i.jsxs("select",{value:a.scheduleType,disabled:h,onChange:A=>v(A.target.value),children:[i.jsx("option",{value:"daily",children:"每天"}),i.jsx("option",{value:"weekly",children:"每周"}),i.jsx("option",{value:"monthly",children:"每月"}),i.jsx("option",{value:"custom",children:"高级 Cron"})]})]}),a.scheduleType!=="custom"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"时间"}),i.jsxs("div",{className:"af-work-schedule-time-selects",children:[i.jsx("select",{value:g,disabled:h,"aria-label":"小时",onChange:A=>b(A.target.value,k),children:Array.from({length:24},(A,L)=>Fo(L,0,0,23)).map(A=>i.jsxs("option",{value:A,children:[A," 时"]},A))}),i.jsx("select",{value:k,disabled:h,"aria-label":"分钟",onChange:A=>b(g,A.target.value),children:Array.from({length:12},(A,L)=>Fo(L*5,0,0,59)).map(A=>i.jsxs("option",{value:A,children:[A," 分"]},A))})]})]}):null,a.scheduleType==="weekly"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"星期"}),i.jsxs("select",{value:a.weekday,disabled:h,onChange:A=>j(A.target.value),children:[i.jsx("option",{value:1,children:"周一"}),i.jsx("option",{value:2,children:"周二"}),i.jsx("option",{value:3,children:"周三"}),i.jsx("option",{value:4,children:"周四"}),i.jsx("option",{value:5,children:"周五"}),i.jsx("option",{value:6,children:"周六"}),i.jsx("option",{value:0,children:"周日"})]})]}):null,a.scheduleType==="monthly"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"日期"}),i.jsx("select",{value:a.monthDay,disabled:h,onChange:A=>N(A.target.value),children:Array.from({length:31},(A,L)=>L+1).map(A=>i.jsxs("option",{value:A,children:[A," 日"]},A))})]}):null,a.scheduleType==="custom"?i.jsxs("label",{className:"af-work-schedule-card__field",children:[i.jsx("span",{children:"Cron"}),i.jsx("input",{type:"text",value:l,disabled:h,spellCheck:!1,placeholder:Yd,onChange:A=>c(A.target.value),onBlur:C,onKeyDown:A=>{A.key==="Enter"&&A.currentTarget.blur()}})]}):null,i.jsxs("div",{className:"af-work-schedule-card__meta",children:[i.jsxs("span",{children:[FG(a.scheduleType)," ",a.scheduleType==="custom"?"":a.time]}),i.jsxs("span",{children:["Next ",DG(u.nextAt)]}),i.jsx("span",{children:d?"running":u.lastStatus||"idle"})]}),u.lastError?i.jsx("div",{className:"af-work-schedule-card__error",children:u.lastError}):null,i.jsxs("div",{className:"af-work-schedule-card__actions",children:[i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__run-now nodrag"+(d?" af-work-run-card__button--stop":""),disabled:h||f,onClick:A=>{var L,D;A.stopPropagation(),d?(L=t==null?void 0:t.onStopWorkspaceNode)==null||L.call(t,e):(D=t==null?void 0:t.onRunWorkspaceNode)==null||D.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:d?"stop_circle":"play_arrow"}),i.jsx("span",{children:d?"停止":"立即运行"})]}),i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__optimize nodrag"+(f?" af-work-schedule-card__optimize--running":""),disabled:h||d||f,title:"为下游节点提前生成 implementation",onClick:A=>{var L;A.stopPropagation(),(L=t==null?void 0:t.onOptimizeWorkspaceSchedule)==null||L.call(t,e)},children:[i.jsx("span",{className:"material-symbols-outlined",children:f?"sync":"auto_fix_high"}),i.jsx("span",{children:f?"优化中":"优化"})]}),i.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__logs nodrag",onClick:A=>{var L;A.stopPropagation(),(L=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||L.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 bJ({id:e,data:t,selected:n,deleteNode:r}){const{setNodes:s}=Bc(),o=!!(t!=null&&t.readOnly),a=mb(t==null?void 0:t.nodeSize)||{width:Za,height:el},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=>uM(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(Vk,{className:"af-work-group-node__resize nodrag",minWidth:Za,minHeight:el,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 kJ(e){var y,v,w,g,k,b,j,N,C,I,R,H,A,L,D,O,M,K,z,F,$,W,E,Q,V,B,se,ue;const{setEdges:t,setNodes:n}=Bc(),r=(y=e.data)==null?void 0:y.onSyncNodePropDraft,s=!!((v=e.data)!=null&&v.readOnly),[o,a]=m.useState(!1),l=(w=e.data)!=null&&w.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=ti((ce=e.data)==null?void 0:ce.definitionId)?mM(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=>uM(ne,e.id)),t(ne=>NJ(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=ho(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(bJ,{...e,deleteNode:c}):nl((k=e.data)==null?void 0:k.definitionId)?i.jsx(aM,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((b=e.data)==null?void 0:b.definitionId)==="workspace_run"?i.jsx(yJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((j=e.data)==null?void 0:j.definitionId)==="workspace_scheduled_run"?i.jsx(xJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):ti((N=e.data)==null?void 0:N.definitionId)?i.jsx(wJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(C=e.data)==null?void 0:C.skills,skillCollections:(I=e.data)==null?void 0:I.skillCollections,workspaces:(R=e.data)==null?void 0:R.workspaceTargets}):((H=e.data)==null?void 0:H.definitionId)==="control_load_skills"?i.jsx(BJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(A=e.data)==null?void 0:A.skills,skillCollections:(L=e.data)==null?void 0:L.skillCollections,onChangeSkillKeys:(D=e.data)==null?void 0:D.onChangeLoadSkillKeys}):((O=e.data)==null?void 0:O.definitionId)==="control_load_mcp"?i.jsx(HJ,{...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}):((z=e.data)==null?void 0:z.definitionId)==="control_cd_workspace"?i.jsx(WJ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,workspaces:(F=e.data)==null?void 0:F.workspaceTargets,onChangeWorkspace:($=e.data)==null?void 0:$.onChangeLoadWorkspace,onRefreshWorkspaces:(W=e.data)==null?void 0:W.onRefreshWorkspaces}):i.jsxs("div",{className:"af-work-flow-node"+(e.selected?" af-work-flow-node--selected":"")+(o?" af-work-flow-node--resizing":"")+((E=e.data)!=null&&E.isExecuting||((Q=e.data)==null?void 0:Q.nodeStatus)==="running"?" af-work-flow-node--executing":"")+(((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(Vk,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:OT,minHeight:cm,maxWidth:DT,maxHeight:FT,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),i.jsx(iU,{...e,deleteNode:c,deferTextCommit:!0,modelLists:(ue=e.data)==null?void 0:ue.modelLists,onModelChange:d,onProvideValueChange:f,onNodeBodyChange:p,onNodeImagesChange:h})]})}const vJ={[mc]:m.memo(kJ)};function kv(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&kv(n.children,t);return t}function lM(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)?lM(r.children,n):null;if(s)return s}return null}function SJ(e){const t=String(e||"").replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!t||!t.includes("/")?"":t.split("/").slice(0,-1).join("/")}function cM(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&cM(n.children,t));return t}function zp(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 jJ(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 uM(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:jJ(e,n)}function NJ(e){let t=!1;const n=(e||[]).map(r=>r.selected?(t=!0,{...r,selected:!1}):r);return t?n:e}function CJ(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function _J(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:rc(c),size:n}:{...h,type:"directory",name:c,path:u,icon:rc(c,!0),children:s(h.children||[],a+1,u)}));return f||p.push(d?{type:"file",name:c,path:u,icon:rc(c),size:n}:{type:"directory",name:c,path:u,icon:rc(c,!0),children:s([],a+1,u)}),CJ(p)};return s(e||[],0,"")}function EJ(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 dM({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||rc(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(dM,{items:u.children,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:s,onSelect:o,onFileDragStart:a,onDelete:l,onDownload:c}):null]},u.path)})})}function AJ({files:e,query:t,onQueryChange:n,onSelect:r,onUpload:s,onClose:o}){const a=m.useMemo(()=>kv(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||rc(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:EJ(u.size)}):null]},u.path)),c.length===0?i.jsx("div",{className:"af-work-file-picker-modal__empty",children:"没有匹配文件,可先上传或调整搜索词。"}):null]})]})]})})}function VC({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 fM(e){const t=String((e==null?void 0:e.kind)||"");return["run-log","run-summary","activity","prompt","raw","thinking"].includes(t)}function PJ(e,t=!1){const n=Array.isArray(e)?e:[],r=n.filter(o=>!fM(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 IJ(e){return(Array.isArray(e)?e:[]).filter(fM)}function Jd(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 RJ(e){const t=Jd((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 Jd((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function TJ(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 Jd((n==null?void 0:n.default)||(n==null?void 0:n.value)||"")}function pM(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 KC(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function na(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 wm(e,t){const n=na(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 yf(e){const t=String(e||"").trim().toLowerCase();return["markdown","html","react","table","chart","ascii","mermaid"].includes(t)?t:"markdown"}function js(e){const t=String(e||""),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t.trim()}function hM(e){const t=yf(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 mM(e){return`${String(e||"context_run").trim()||"context_run"}__display`}function gM(e){return e==="display_image"?"src":"content"}function qC(e,t,n){const r=gM(t),s=Yu(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 UC(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 YC(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 ug(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 MJ(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=na(t,"includeWorkspaceContext","true").toLowerCase(),r=wm(t,"knowledgeContext"),s=wm(t,"workspaceContext");return{task:String((e==null?void 0:e.body)||""),skillKeys:TJ(e),includeWorkspaceContext:n!=="false"&&n!=="0"&&n!=="off",knowledgeContext:r||(s?dg([s]):null),workspaceContext:s,displayType:yf(na(t,"displayType","markdown")),model:String((e==null?void 0:e.model)||"").trim()}}function ti(e){const t=String(e||"");return t==="workspace_one_click_task"||t==="workspace_context_run"}function $J(e){const t=Jd((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 Jd((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function LJ(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function yM(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 dg(e=[]){const t=(Array.isArray(e)?e:[e]).map((n,r)=>yM(n,r===0?"primary":"context")).filter(Boolean);return t.length?{version:1,sources:t}:null}function wM(e){return(e&&typeof e=="object"&&Array.isArray(e.sources)?e.sources:[]).map(n=>yM(n,(n==null?void 0:n.role)||"context")).filter(Boolean)}function OJ(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=wm(t,"knowledgeContext"),r=wm(t,"workspaceContext");return{sources:wM(n||(r?dg([r]):null)),path:na(t,"path",""),label:na(t,"label","")}}function GC(e){var r,s,o,a,l,c,u,d,f;if(!e)return null;const{inputs:t,outputs:n}=wU(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:ho((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 JC(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 XC(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 DJ(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=Kd.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?[]:ho(t==null?void 0:t.images),inputs:XC(t==null?void 0:t.inputs),outputs:s&&Array.isArray((f=e.data)==null?void 0:f.outputs)?e.data.outputs:XC(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 QC({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(!BU.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=DJ(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(ho(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((w,g)=>({...w,source:w.source===a?c:w.source,target:w.target===a?c:w.target,id:`we-${w.source===a?c:w.source}-${w.target===a?c:w.target}-${g}`}))}return{ok:!0,changed:!0,nextId:c,nodes:p,edges:h,instances:y}}function FJ(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function zJ(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"])FJ(e[s],t[s])&&(r[s]=n[s]);return r}function xb(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),w=h?Math.min(v,d.scrollTop/Math.max(1,f-p)*v):0;o({visible:h,top:w,height:y})},[]);m.useEffect(()=>{if(!e)return;const d=requestAnimationFrame(a);return()=>cancelAnimationFrame(d)},[e,a,...t]);const l=m.useCallback(d=>{const f=n.current;if(!f)return;const p=Math.max(0,f.scrollHeight-f.clientHeight);f.scrollTop=Math.min(1,Math.max(0,d))*p,a()},[a]),c=m.useCallback((d,f=0)=>{const p=r.current;if(!p)return 0;const h=p.getBoundingClientRect(),y=s.height/100*h.height,v=Math.max(1,h.height-y);return(d-h.top-f)/v},[s.height]),u=m.useCallback(d=>{var j,N;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,w=d.clientY>=p.top+h&&d.clientY<=p.top+h+y?d.clientY-p.top-h:y/2;l(c(d.clientY,w));const g=d.pointerId;(N=(j=d.currentTarget).setPointerCapture)==null||N.call(j,g);const k=C=>{C.preventDefault(),l(c(C.clientY,w))},b=()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",b),window.removeEventListener("pointercancel",b)};window.addEventListener("pointermove",k),window.addEventListener("pointerup",b),window.addEventListener("pointercancel",b)},[c,l,s.height,s.top,s.visible]);return{menuRef:n,scrollbarTrackRef:r,scrollbar:s,updateMenuScrollbar:a,handleScrollbarPointerDown:u}}function BJ({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,w]=m.useState(()=>new Set),g=m.useRef(null),k=m.useRef(null),[b,j]=m.useState({visible:!1,top:0,height:100}),N=m.useMemo(()=>new Set(RJ(t)),[t]),C=m.useMemo(()=>new Map(u.map(F=>[F.key,F])),[u]),I=m.useMemo(()=>Array.from(N).map(F=>{var $;return(($=C.get(F))==null?void 0:$.name)||F}),[C,N]),R=m.useMemo(()=>pM(I,"选择 Skills"),[I]),H=m.useMemo(()=>{const F=new Set,$=d.map(E=>{const Q=Zo(E,u).map(V=>C.get(V)).filter(Boolean);for(const V of Q)F.add(V.key);return{...E,skills:Q}}).filter(E=>E.skills.length>0),W=u.filter(E=>!F.has(E.key));return{collectionGroups:$,ungrouped:W}},[C,d,u]);m.useEffect(()=>{w(F=>{let $=!1;const W=new Set(F);for(const E of H.collectionGroups)W.has(E.id)||(W.add(E.id),$=!0);return $?W:F})},[H.collectionGroups]);const A=m.useMemo(()=>{const F=h.trim().toLowerCase();if(!F)return H;const $=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(F);return{collectionGroups:H.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(F)?E.skills:E.skills.filter($);return{...E,skills:V}}).filter(E=>E.skills.length>0),ungrouped:H.ungrouped.filter($)}},[H,h]),L=m.useCallback((F,$)=>{const W=new Set(N);for(const E of F)$?W.add(E):W.delete(E);a==null||a(e,Array.from(W))},[e,N,a]),D=m.useCallback(F=>{w($=>{const W=new Set($);return W.has(F)?W.delete(F):W.add(F),W})},[]),O=m.useCallback(()=>{const F=g.current;if(!F)return;const $=Math.max(1,F.scrollHeight),W=Math.max(1,F.clientHeight),E=$>W+1,Q=E?Math.max(12,W/$*100):100,V=Math.max(0,100-Q),B=E?Math.min(V,F.scrollTop/Math.max(1,$-W)*V):0;j({visible:E,top:B,height:Q})},[]);m.useEffect(()=>{if(!f)return;const F=requestAnimationFrame(O);return()=>cancelAnimationFrame(F)},[v,A,N.size,f,O]);const M=m.useCallback(F=>{const $=g.current;if(!$)return;const W=Math.max(0,$.scrollHeight-$.clientHeight);$.scrollTop=Math.min(1,Math.max(0,F))*W,O()},[O]),K=m.useCallback((F,$=0)=>{const W=k.current;if(!W)return 0;const E=W.getBoundingClientRect(),Q=b.height/100*E.height,V=Math.max(1,E.height-Q);return(F-E.top-$)/V},[b.height]),z=m.useCallback(F=>{var ee,te;if(!b.visible)return;F.preventDefault(),F.stopPropagation();const $=k.current;if(!$)return;const W=$.getBoundingClientRect(),E=b.top/100*W.height,Q=b.height/100*W.height,B=F.clientY>=W.top+E&&F.clientY<=W.top+E+Q?F.clientY-W.top-E:Q/2;M(K(F.clientY,B));const se=F.pointerId;(te=(ee=F.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,b.height,b.top,b.visible]);return i.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":"")+(f?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((F,$)=>{if(F.showOnNode===!1)return null;const W=`${2.6+$*1.7}rem`,E=F.name||`#${$+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:W},children:E}),i.jsx(Jn,{type:"target",position:qe.Left,id:`input-${$}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:W,background:Mn(F.type)},title:`${E} · ${F.type}`})]},`in-${$}`)}),c.map((F,$)=>{if(F.showOnNode===!1)return null;const W=`${2.6+$*1.7}rem`,E=F.name||`#${$+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:W},children:E}),i.jsx(Jn,{type:"source",position:qe.Right,id:`output-${$}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:W,background:Mn(F.type)},title:`${E} · ${F.type}`})]},`out-${$}`)}),i.jsxs("div",{className:"af-work-load-skills-card__head",children:[i.jsx("span",{className:"material-symbols-outlined",children:"extension"}),i.jsx("strong",{children:(t==null?void 0:t.label)||"Load Skills"}),i.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_skills"}),i.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),i.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[i.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:F=>{var $;F.stopPropagation(),f||($=t==null?void 0:t.onRefreshSkills)==null||$.call(t),p(W=>!W)},children:[i.jsxs("span",{className:"af-work-load-skills-card__summary",title:R.title,children:[i.jsx("span",{className:"af-work-load-skills-card__summary-main",children:R.head}),R.extra?i.jsx("span",{className:"af-work-load-skills-card__summary-extra",children:R.extra}):null]}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:f?"expand_less":"expand_more"})]}),f?i.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:F=>F.stopPropagation(),children:[i.jsxs("div",{className:"af-work-load-skills-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{type:"search",value:h,onChange:F=>y(F.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),h?i.jsx("button",{type:"button",onClick:()=>y(""),"aria-label":"清空搜索",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),i.jsxs("div",{ref:g,className:"af-work-load-skills-menu",onScroll:O,children:[A.collectionGroups.map(F=>{const $=F.skills.map(V=>V.key),W=$.filter(V=>N.has(V)).length,E=$.length>0&&W===$.length,Q=v.has(F.id);return i.jsxs("section",{className:"af-work-load-skills-menu__group"+(Q?" af-work-load-skills-menu__group--collapsed":""),children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head",children:[i.jsx("input",{type:"checkbox",checked:E,onChange:V=>L($,V.target.checked),"aria-label":`选择 ${F.name}`}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>D(F.id),"aria-expanded":!Q,children:i.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[i.jsx("span",{children:F.name}),F.description?i.jsx("em",{children:F.description}):null]})}),i.jsxs("small",{children:[W,"/",$.length]}),i.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>D(F.id),"aria-label":Q?`展开 ${F.name}`:`收起 ${F.name}`,children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Q?"chevron_right":"expand_more"})})]}),Q?null:i.jsx("div",{className:"af-work-load-skills-menu__options",children:F.skills.map(V=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:N.has(V.key),onChange:B=>L([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]})]},`${F.id}:${V.key}`))})]},F.id)}),A.ungrouped.length>0?i.jsxs("section",{className:"af-work-load-skills-menu__group",children:[i.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[i.jsx("span",{children:"Ungrouped"}),i.jsx("small",{children:A.ungrouped.length})]}),i.jsx("div",{className:"af-work-load-skills-menu__options",children:A.ungrouped.map(F=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:N.has(F.key),onChange:$=>L([F.key],$.target.checked)}),i.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[i.jsx("span",{className:"af-work-load-skills-menu__option-title",children:F.name}),F.description?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:F.description}):null]})]},`ungrouped:${F.key}`))})]}):null,A.collectionGroups.length===0&&A.ungrouped.length===0?i.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Skills"}):null,i.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>a==null?void 0:a(e,[]),children:"清空"})]}),i.jsx("div",{ref:k,className:"af-work-load-skills-scrollbar"+(b.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:z,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${b.height}%`,top:`${b.top}%`}})})]}):null]})]})}function HJ({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($J(t)),[t]),h=m.useMemo(()=>(Array.isArray(s)?s:[]).map(w=>({name:String((w==null?void 0:w.name)||""),description:String((w==null?void 0:w.description)||""),detail:String((w==null?void 0:w.url)||[w==null?void 0:w.command,...Array.isArray(w==null?void 0:w.args)?w.args:[]].filter(Boolean).join(" ")||""),type:String((w==null?void 0:w.type)||"")})).filter(w=>w.name),[s]),y=m.useMemo(()=>{const w=d.trim().toLowerCase();return w?h.filter(g=>[g.name,g.description,g.detail,g.type].join(" ").toLowerCase().includes(w)):h},[d,h]),v=m.useCallback((w,g)=>{const k=new Set(p);for(const b of w)g?k.add(b):k.delete(b);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((w,g)=>{if(w.showOnNode===!1)return null;const k=`${2.6+g*1.7}rem`,b=w.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:b}),i.jsx(Jn,{type:"target",position:qe.Left,id:`input-${g}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:k,background:Mn(w.type)},title:`${b} · ${w.type}`})]},`in-${g}`)}),l.map((w,g)=>{if(w.showOnNode===!1)return null;const k=`${2.6+g*1.7}rem`,b=w.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:b}),i.jsx(Jn,{type:"source",position:qe.Right,id:`output-${g}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:k,background:Mn(w.type)},title:`${b} · ${w.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:w=>{var g;w.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:w=>w.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:w=>f(w.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(w=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:p.has(w.name),onChange:g=>v([w.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:w.name}),w.description||w.detail?i.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:w.description||w.detail}):null]})]},w.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 WJ({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=OJ(t),y=m.useMemo(()=>(Array.isArray(s)?s:[]).map(N=>({id:String((N==null?void 0:N.id)||""),label:String((N==null?void 0:N.label)||(N==null?void 0:N.name)||"知识库"),kind:(N==null?void 0:N.kind)==="git"?"git":"local",path:String((N==null?void 0:N.path)||""),repoUrl:String((N==null?void 0:N.repoUrl)||""),branch:String((N==null?void 0:N.branch)||""),mountPath:String((N==null?void 0:N.mountPath)||""),builtin:(N==null?void 0:N.builtin)===!0,exists:(N==null?void 0:N.exists)!==!1})).filter(N=>N.path),[s]),v=m.useMemo(()=>{const N=f.trim().toLowerCase();return N?y.filter(C=>[C.id,C.label,C.path,C.repoUrl,C.branch,C.mountPath].join(" ").toLowerCase().includes(N)):y},[f,y]),w=m.useMemo(()=>new Set((h.sources||[]).map(N=>N.id||N.path||N.repoPath).filter(Boolean)),[h.sources]),g=m.useMemo(()=>(h.sources||[]).map(N=>N.label||N.id||N.mountPath||N.path),[h.sources]),k=m.useMemo(()=>pM(g,"选择知识库"),[g]),b=xb(u,[v.length,g.length,f]),j=(N,C)=>{const I=(N==null?void 0:N.id)||(N==null?void 0:N.path)||"",R=y.filter(H=>{const A=H.id||H.path||"";return A===I?C:w.has(A)});o==null||o(e,R)};return i.jsxs("div",{className:"af-work-load-skills-card af-work-load-workspace-card"+(n?" af-work-load-skills-card--selected":"")+(u?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((N,C)=>{if(N.showOnNode===!1)return null;const I=`${2.6+C*1.7}rem`,R=N.name||`#${C+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:I},children:R}),i.jsx(Jn,{type:"target",position:qe.Left,id:`input-${C}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:I,background:Mn(N.type)},title:`${R} · ${N.type}`})]},`in-${C}`)}),c.map((N,C)=>{if(N.showOnNode===!1)return null;const I=`${2.6+C*1.7}rem`,R=N.name||`#${C+1}`;return i.jsxs(m.Fragment,{children:[i.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:I},children:R}),i.jsx(Jn,{type:"source",position:qe.Right,id:`output-${C}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:I,background:Mn(N.type)},title:`${R} · ${N.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:N=>{N.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:N=>N.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:N=>p(N.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:b.menuRef,className:"af-work-load-skills-menu",onScroll:b.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(N=>i.jsxs("label",{className:"af-work-load-skills-menu__option",children:[i.jsx("input",{type:"checkbox",checked:w.has(N.id||N.path),onChange:C=>j(N,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:N.label}),i.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[N.kind==="git"&&N.repoUrl?`${N.repoUrl}${N.branch?` · ${N.branch}`:""}${N.mountPath?` · ${N.mountPath}`:""}`:N.path,N.exists?"":" · 路径未就绪"]})]})]},`${N.id}:${N.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:b.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(b.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:b.handleScrollbarPointerDown,"aria-hidden":"true",children:i.jsx("span",{style:{height:`${b.scrollbar.height}%`,top:`${b.scrollbar.top}%`}})})]}):null]})]})}function xM({row:e,index:t=0,child:n=!1}){const r=(e==null?void 0:e.issue)||{},s=CT(r),o=QU(mG(r)),a=s?o.filter(p=>!["issue","mr"].includes(om(p))):o,l=eY(r,o),c=_i(r,t),u=s?"":Ma(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:fG(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(xM,{row:p,index:h,child:!0},_i((p==null?void 0:p.issue)||{},h)))}):null]})}function bM(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 kM(e){return(Array.isArray(e)?e:e==null||e===""?[]:[e]).map(n=>bM(n)).filter(Boolean)}function VJ({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=kM(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 KJ({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"&&kM(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(VJ,{fieldKey:o,field:a},o))})]})}function qJ({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=bM(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(KJ,{sectionKey:f,section:p},f))}):i.jsx("p",{className:"af-prd-workflow-muted",children:"暂无全局状态。各阶段可通过 Workflow 上报逐步补充负责人、配置、规则和其它上下文。"})]})}function UJ({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[w,g]=m.useState("all"),[k,b]=m.useState("all"),[j,N]=m.useState(!1),[C,I]=m.useState(!1),[R,H]=m.useState(!1),[A,L]=m.useState(""),[D,O]=m.useState(!1),[M,K]=m.useState(""),[z,F]=m.useState(null),$=String((r==null?void 0:r.phase)||(t?"unavailable":"unselected")),W=Array.isArray(r==null?void 0:r.issues)?r.issues:[],E=gG(r),Q=E.reduce((xe,Oe)=>xe+lb(Oe.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=bG(r,B),ue=uG(r,se),G=V.filter(xe=>!ET({...xe,href:gc(xe)})),ee=m.useMemo(()=>aG(se),[se]);m.useEffect(()=>{k!=="all"&&(ee.some(xe=>xe.key===k)||b("all"))},[k,ee]);const te=se.filter(xe=>lG(xe,k)),ne=iG(te),Z=kG(r),ce=Z.filter(xe=>vG(xe,w)),de=te.filter(xe=>mv(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=XY($),ot=m.useCallback(async()=>{const xe=String(t||"").trim();if(!xe){F(null);return}I(!0),L(""),K("");try{const Oe=new URLSearchParams({tapdId:xe});e.workflowShare&&Oe.set("workflowShare",e.workflowShare);const ie=await fetch(`/api/prd-workflow/share?${Oe.toString()}`),ke=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(ke.error||"读取 Workflow 分享状态失败");let Ke=ke.share||null;const Ue=ke.canCreate===!0&&!e.workflowShare;if(O(Ue),!Ke&&Ue){const be=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:xe})}),It=await be.json().catch(()=>({}));if(!be.ok)throw new Error(It.error||"生成 Workflow 分享链接失败");Ke=It.share||null}F(Ke)}catch(Oe){L(String(Oe.message||Oe))}finally{I(!1)}},[e,t]),gt=()=>{N(!0),ot()},Te=async()=>{if(!(!t||R||e.workflowShare)){H(!0),L(""),K("");try{const xe=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:t})}),Oe=await xe.json().catch(()=>({}));if(!xe.ok)throw new Error(Oe.error||"生成 Workflow 分享链接失败");F(Oe.share||null),O(!0)}catch(xe){L(String(xe.message||xe))}finally{H(!1)}}},st=async()=>{const xe=await yb((z==null?void 0:z.shortUrl)||(z==null?void 0:z.url)||"");K(xe?"已复制":"复制失败")},mt=async()=>{if(!(!t||R||!(z!=null&&z.canManage))){H(!0),L(""),K("");try{const xe=await fetch("/api/prd-workflow/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t})}),Oe=await xe.json().catch(()=>({}));if(!xe.ok)throw new Error(Oe.error||"取消 Workflow 分享链接失败");F(null),O(!0)}catch(xe){L(String(xe.message||xe))}finally{H(!1)}}},Tt=(z==null?void 0:z.shortUrl)||(z==null?void 0:z.url)||"";return i.jsxs("main",{className:"af-prd-workflow af-prd-workflow--timeline","aria-label":"PRD Workflow",children:[i.jsxs("section",{className:"af-prd-workflow__statusbar",children:[i.jsxs("div",{className:"af-prd-workflow__status-main",children:[i.jsx("span",{className:`af-prd-workflow-phase af-prd-workflow-phase--${$.toLowerCase().replace(/[^a-z0-9_-]+/gi,"_")}`,children:_C($)}),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:gt,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:[_C(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&&fm(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:()=>b("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:()=>b(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:Oe,index:ie})=>{const ke=ua(Oe.status),Ke=ea(Oe)==="observation"&&ke==="done"?"observed":ke,Ue=yv(Oe),be=sG(Oe),It=cG(Oe),nn=ZY(Oe,ie),Vt=eG(Oe);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:[be?i.jsx("time",{dateTime:dm(Oe),children:be}):null,i.jsx("strong",{children:nn})]}),Vt?i.jsx("p",{children:Vt}):null,It.length?i.jsx("div",{className:"af-prd-workflow-action__meta",children:It.map(Ot=>i.jsxs("span",{children:[i.jsx("b",{children:Ot.label}),Ot.value]},`${Ot.label}-${Ot.value}`))}):null]}),i.jsx("span",{className:"af-prd-workflow-action__status",children:oG(Oe)})]}),Ue.length?i.jsx("div",{className:"af-prd-workflow-action__links",children:Ue.map(Ot=>i.jsxs("a",{href:Ot.href,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:Ot.label}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]},`${Ot.label}-${Ot.href}`))}):null]})]},Oe.id||Oe.actionId||`${to(Oe,ie)}-${ie}`)})})]},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(qJ,{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,Oe)=>{const ie=gc(xe),ke=String(xe.label||xe.title||xe.kind||ie||`Artifact ${Oe+1}`);return ie?i.jsxs("a",{href:ie,target:"_blank",rel:"noreferrer",children:[i.jsx("span",{children:ke}),i.jsx("small",{children:xe.kind||ie})]},`${ie}-${Oe}`):i.jsxs("div",{children:[i.jsx("span",{children:ke}),i.jsx("small",{children:xe.kind||""})]},`${ke}-${Oe}`)})})]}):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 Oe=String(xe.title||xe.label||"ai-doc").trim(),ie=[xe.label&&xe.label!==Oe?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:Oe,children:[i.jsx("span",{className:"af-prd-ai-doc__title",children:Oe}),i.jsx("small",{className:"af-prd-ai-doc__meta",children:ie.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:lb(xe.issues)})]}),xe.issues.map((Oe,ie)=>i.jsx(xM,{row:Oe,index:ie},_i((Oe==null?void 0:Oe.issue)||{},ie)))]},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,Oe])=>i.jsx("button",{type:"button",className:w===xe?"is-active":"",onClick:()=>g(xe),children:Oe},xe))}),i.jsx("div",{className:"af-prd-workflow-audit",children:ce.length?ce.map((xe,Oe)=>i.jsxs("div",{children:[i.jsx("strong",{children:to(xe,Oe)}),i.jsx("small",{children:[xe.status,xe.type,dm(xe)].filter(Boolean).join(" · ")})]},xe.id||`${xe.type}-${Oe}`)):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]})]}),j?ur.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:()=>N(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("p",{className:"af-display-link-modal__empty",children:["通过只读链接分享 TAPD ",t," 的需求流程;不会分享当前 Project、画布或项目文件。"]}),C?i.jsx("div",{className:"af-display-link-modal__empty",children:"正在生成分享链接..."}):null,!C&&Tt?i.jsxs(i.Fragment,{children:[i.jsxs("div",{className:"af-display-link-modal__url",children:[i.jsx("input",{type:"text",value:Tt,readOnly:!0,onFocus:xe=>xe.currentTarget.select(),"aria-label":"Workflow 分享链接"}),i.jsxs("button",{type:"button",disabled:R,onClick:()=>void st(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),M||"复制链接"]}),z.canManage?i.jsx("button",{type:"button",disabled:R,onClick:()=>void mt(),children:R?"处理中...":"取消分享"}):null]}),i.jsx("div",{className:"af-prd-workflow-share-note",children:"获得链接的人无需登录即可只读查看同一份 Workflow;链接不会授予需求推进或项目编辑权限。"})]}):null,!C&&!Tt&&D?i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:R,onClick:()=>void Te(),children:R?"生成中...":"生成分享链接"}):null,A?i.jsx("div",{className:"af-flow-snippet-error",children:A}):null]}),i.jsx("div",{className:"af-flow-snippet-modal__foot",children:i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>N(!1),children:"完成"})})]})}),document.body):null]})}function ZC(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 Mu(e){if(!(e!=null&&e.hasIncoming))return"null";try{return JSON.stringify(e.incoming,null,2)}catch{return JSON.stringify(String(e.incoming))}}function YJ(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 GJ(){var v0,S0,j0;const{t:e,i18n:t}=zr(),{navigate:n}=gs(),r=Bc(),s=wn(),o=F5(),a=m.useMemo(DY,[]),l=!!a.workflowShare,c=m.useRef(new URLSearchParams(window.location.search).get("focusNodeId")||""),u=m.useMemo(()=>a.workspaceId?`agentflow.workspace.viewport:shared:${a.workspaceId}`:`agentflow.workspace.viewport:${a.flowSource||"user"}:${a.adminOwnerId||"self"}:${a.flowId||""}`,[a]),[d,f]=m.useState(()=>(()=>{if(a.workflowShare)return"workflow";const x=new URLSearchParams(window.location.search).get("view");return x==="display"||x==="workflow"?x:"workspace"})()),[p,h]=m.useState(!1),[y,v]=m.useState(!1),[w,g]=z5([]),[k,b]=B5([]),j=m.useRef([]),N=m.useRef([]),C=m.useRef(null),[I,R]=m.useState(()=>gh(null,[])),H=m.useRef(I),[A,L]=m.useState(null),D=m.useRef(null),O=m.useRef(!1),[M,K]=m.useState([]),z=m.useRef(new Map),F=m.useRef(new Map),$=m.useRef(new Set),W=m.useRef(new Set),E=m.useRef(null),Q=m.useRef(null),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),gt=m.useRef(0),Te=m.useRef(null),st=m.useRef(!1),mt=m.useRef(!1),Tt=m.useRef(""),xe=m.useRef(!1),Oe=m.useRef(!1),ie=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,It]=m.useState([]),nn=m.useRef([]),[Vt,Ot]=m.useState(""),[ln,re]=m.useState("nodes"),[Re,Je]=m.useState([]),[Ze,Mt]=m.useState(!1),[_t,Kn]=m.useState(""),[jn,br]=m.useState(!1),[xn,Qn]=m.useState({name:"",id:"",description:""}),[qn,mr]=m.useState(!1),[ts,Pr]=m.useState(""),[ys,ws]=m.useState(""),dn=m.useRef(null),[sr,Ir]=m.useState(!1),[pn,Zn]=m.useState(!1),[kr,ir]=m.useState(""),[jt,Xt]=m.useState(null),[Nt,le]=m.useState(()=>fw()),[ve,it]=m.useState(""),[zt,Qt]=m.useState(!1),[rn,er]=m.useState(""),[ht,sn]=m.useState(!1),[Kt,vr]=m.useState([]),[tt,On]=m.useState(!1),[$i,Br]=m.useState(""),[go,ai]=m.useState(""),[Ms,oe]=m.useState(""),[Se,Pe]=m.useState(!1),[wt,Dt]=m.useState(""),[Yt,Bn]=m.useState(""),[Dn,q]=m.useState(!1),[he,De]=m.useState("nodes"),[Ee,et]=m.useState(""),[Nn,bt]=m.useState(0),[Gt,Cn]=m.useState(""),yo=m.useRef(""),[at,xs]=m.useState(null),Lv=m.useRef(null),[m$,ll]=m.useState(""),[cl,Ov]=m.useState([]),[Dv,g$]=m.useState(""),[je,y$]=m.useState(!a.adminOwnerId),[Sf,w$]=m.useState(()=>a.adminOwnerId?{readonly:!0,ownerUserId:a.adminOwnerId,ownerUsername:a.adminOwnerId}:null),[cn,wg]=m.useState(null),[x$,xg]=m.useState(!1),[bg,Fv]=m.useState(!1),[zv,Jc]=m.useState(""),[Xc,Bv]=m.useState(""),[Hv,Wv]=m.useState(""),[An,ul]=m.useState(null),[b$,da]=m.useState(!1),[kg,dl]=m.useState({}),[jf,Vv]=m.useState(!1),[Kv,Qc]=m.useState(""),[vg,k$]=m.useState(""),[v$,fl]=m.useState(()=>new Set),[Sg,jg]=m.useState(""),[Zc,Ng]=m.useState({nodeId:"",query:""}),[qv,Uv]=m.useState(!1),Cg=m.useRef(null),Yv=m.useRef(null),Gv=m.useRef(""),[_g,Jv]=m.useState(()=>{try{const x=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(x)&&x>=160)return x}catch{}return 360}),[S$,Xv]=m.useState(!1),[fa,j$]=m.useState({cursor:[],opencode:[],claudeCode:[],codex:[]}),[Li,N$]=m.useState(""),[$s,C$]=m.useState([]),[Qv,Zv]=m.useState(!1),[Ls,eu]=m.useState([]),[pl,_$]=m.useState([]),[eS,E$]=m.useState(!1),[tS,nS]=m.useState([]),[rS,sS]=m.useState([]),[or,A$]=m.useState(()=>{try{const x=String(new URLSearchParams(window.location.search).get("tapdId")||"").trim();return x||String(window.localStorage.getItem(`agentflow.workflow.tapdId:${a.flowSource||"user"}:${a.flowId||""}`)||"").trim()}catch{return""}}),[un,Nf]=m.useState(null),[P$,iS]=m.useState(!1),[I$,hl]=m.useState(""),[Eg,oS]=m.useState(!1),[Ag,Cf]=m.useState(""),[bs,_f]=m.useState(null),[Pg,aS]=m.useState(!1),[tu,nu]=m.useState(null),lS=m.useCallback(x=>{dn.current&&window.clearTimeout(dn.current),ws(x),dn.current=window.setTimeout(()=>{ws(""),dn.current=null},3800)},[]),Hr=m.useCallback(x=>{const S=Array.isArray(x)||x instanceof Set?x:[x];for(const _ of S){const P=String(_||"").trim();P&&($.current.add(P),W.current.add(P))}$.current.size!==0&&(E.current==null&&(E.current=window.requestAnimationFrame(()=>{E.current=null;const _=Array.from($.current);$.current.clear(),_.forEach(P=>o(P))})),Q.current!=null&&window.clearTimeout(Q.current),Q.current=window.setTimeout(()=>{Q.current=null;const _=Array.from(W.current);W.current.clear(),_.forEach(P=>o(P))},80))},[o]);m.useEffect(()=>()=>{E.current!=null&&window.cancelAnimationFrame(E.current),Q.current!=null&&window.clearTimeout(Q.current),$.current.clear(),W.current.clear()},[]);const cS=m.useCallback((x,S)=>{const _=String(x||"").trim(),P=ym(S);!_||!P||(g(T=>T.map(U=>{var ae;if(U.id!==_)return U;const X=ym((ae=U.data)==null?void 0:ae.displaySize),J=X&&X.width===P.width&&X.height===P.height,Y=Math.round(Number(U.width||0))===P.width&&Math.round(Number(U.height||0))===P.height;return J&&Y?U:{...U,width:P.width,height:P.height,data:{...U.data,nodeSize:P,displaySize:P}}})),Hr(_))},[Hr,g]);m.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(_g)))}catch{}},[_g]);const Ig=m.useCallback(x=>{const S=Cg.current;if(!S)return null;const _=S.getBoundingClientRect(),P=16,T=150,U=230,X=_.top+P,J=_.bottom-P,Y=Math.max(T,J-X-U);return Math.min(Math.max(x-X,T),Y)},[]),R$=m.useCallback(x=>{x.preventDefault(),x.stopPropagation();const S=Cg.current;if(!S)return;let _=Ig(x.clientY);if(!Number.isFinite(_))return;Xv(!0),Jv(_);const P=U=>{U.preventDefault();const X=Ig(U.clientY);Number.isFinite(X)&&(_=X,S.style.setProperty("--af-work-files-pane-height",`${Math.round(X)}px`))},T=()=>{Jv(_),Xv(!1),window.removeEventListener("pointermove",P,!0),window.removeEventListener("pointerup",T,!0),window.removeEventListener("pointercancel",T,!0)};window.addEventListener("pointermove",P,!0),window.addEventListener("pointerup",T,!0),window.addEventListener("pointercancel",T,!0)},[Ig]);m.useEffect(()=>()=>{dn.current&&window.clearTimeout(dn.current),Ue.current&&window.clearTimeout(Ue.current)},[]);const[T$,uS]=m.useState(()=>new Set),[Ef,Rg]=m.useState(!1),Tg=m.useRef(null),dS=m.useRef(null),fS=m.useRef(null),[M$,$$]=m.useState({}),[pa,Mg]=m.useState(""),[ns,pS]=m.useState(!1),[ha,ml]=m.useState([]),[Os,Un]=m.useState([]),[Wr,ks]=m.useState("workspace"),[ru,gl]=m.useState(!1),hS=m.useRef(null),$g=m.useRef(null),[su,yl]=m.useState(null),[L$,Lg]=m.useState(!0),[mS,gS]=m.useState(""),[ma,wo]=m.useState({}),[Rr,Og]=m.useState(null),[yS,Dg]=m.useState(!1),wl=m.useMemo(()=>yS?WY(Rr):"",[yS,Rr]),[iu,Af]=m.useState(!0);m.useEffect(()=>{wl&&Af(VY(wl))},[wl]),m.useEffect(()=>{if(wl)try{window.localStorage.setItem(wl,iu?"true":"false")}catch{}},[iu,wl]);const[Fg,Pf]=m.useState(!1),[zg,wS]=m.useState(!1),[Bg,xS]=m.useState("pan"),[bS,O$]=m.useState({}),ou=m.useRef({}),[kS,ga]=m.useState({}),au=m.useRef(new Map),lu=m.useRef(new Set),[vS,xl]=m.useState(()=>new Set),[Hg,bl]=m.useState({}),[SS,jS]=m.useState(""),[Hce,ge]=m.useState(""),[NS,Ds]=m.useState("loading"),[CS,Fs]=m.useState("正在载入 Project"),Oi=m.useMemo(()=>HY(a),[a]),[_S,ES]=m.useState(""),cu=a.flowSource||"user",AS=m.useMemo(()=>new Set(Object.values(bS||{}).map(x=>String((x==null?void 0:x.runNodeId)||"").trim()).filter(Boolean)),[bS]),Di=m.useCallback(x=>{const S=ou.current||{},_=typeof x=="function"?x(S):x,P=_&&typeof _=="object"&&!Array.isArray(_)?_:{};return ou.current=P,O$(P),P},[]),PS=!!(a.flowId&&!a.adminOwnerId&&!a.archived&&(cn!=null&&cn.role?cn.role==="owner":cu==="user"||cu==="workspace")),uu=!!(!a.adminOwnerId&&cu==="workspace"&&(cn!=null&&cn.role)&&cn.role!=="owner"),IS={loading:"载入中",dirty:"有未同步修改",saving:"同步中",synced:"已同步",conflict:"同步冲突",error:"同步失败",readonly:"只读"}[NS]||"同步状态",li=m.useCallback(()=>{!ce.current||!je||(xe.current=!1,Be.current+=1,ot.current=!0,Ds("dirty"),Fs("本地修改等待同步"))},[je]);m.useEffect(()=>{a.flowId&&SF(a.flowId,a.flowSource||"user","workspace",!!a.archived)},[a]),m.useEffect(()=>{const x=()=>{f(new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace")};return window.addEventListener("popstate",x),()=>window.removeEventListener("popstate",x)},[]),m.useEffect(()=>{ml([]),Un([]),ks("workspace"),Lg(!0)},[a]);const Pn=m.useCallback(async()=>{const x=$r(a),S=await fetch(`/api/workspace/files?${x.toString()}`),_=await S.json();if(!S.ok)throw new Error(_.error||"读取 workspace 失败");const P=_.files||[];Ov(P),fl(new Set(cM(P))),g$(_.root||"")},[a]),If=m.useCallback(async()=>{Mt(!0),Kn("");try{const x=await fetch("/api/marketplace/flow-snippets"),S=await x.json().catch(()=>({}));if(!x.ok)throw new Error(S.error||"读取流程片段失败");Je(Array.isArray(S.snippets)?S.snippets:[])}catch(x){Kn(String(x.message||x)),Je([])}finally{Mt(!1)}},[]),RS=m.useCallback(async(x,S,_)=>{var Y,ae,pe;if(!ce.current)return;if(!je)throw ge("Readonly workspace"),Ds("readonly"),Fs("只读 Project"),new Error("Readonly workspace");Ds("saving"),Fs("正在同步修改");const P=$l(x,S,Z.current);P.ui={...P.ui||{},displayPage:OC(H.current,x)};const T=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:P,baseRevision:me.current,baseGraph:$e.current,clientId:ke.current})}),U=await T.json().catch(()=>({}));if(!T.ok){if(T.status===409||T.status===428){const Ne=Array.isArray(U.conflictItems)?U.conflictItems:[];ul({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}),dl(Object.fromEntries(Ne.map((He,Me)=>[String(Me),{mode:"local",manual:Mu(He)}]))),Qc(""),da(Ne.length>0),Ds("conflict"),Fs(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 Ds("error"),Fs(fe.message),fe}const X=Be.current!==_,J=xY({savedGraph:U.graph,sentGraph:P,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)||P.instances,ne(Z.current),U.merged&&U.graph){const fe=Tu(U.graph,be),Ne=gh((pe=(ae=U.graph)==null?void 0:ae.ui)==null?void 0:pe.displayPage,fe.nodes);Z.current=fe.instances,ne(fe.instances),g(fe.nodes),b(fe.edges),H.current=Ne,R(Ne)}ot.current=!1}return ga(Dp(U.workspaceSchedules||[])),ul(null),da(!1),Ds(X?"dirty":"synced"),Fs(X?"本地仍有修改等待同步":"所有修改已同步"),ge(X?"已保存上一版,本地新修改正在排队":U.merged?"Workspace graph merged and saved":"Workspace graph saved"),U},[a,be,b,g,je]),en=m.useCallback((x=w,S=k)=>{const _=_e.current,P={nextNodes:x,nextEdges:S,saveEditVersion:Be.current,waiters:[]},T=new Promise((J,Y)=>{P.waiters.push({resolve:J,reject:Y})});if(_.running)return _.pending=SC(_.pending,P),T;_.running=!0;const U=async()=>{let J=P;for(;J;){_.pending&&(J=SC(J,_.pending),_.pending=null);try{const Y=await RS(J.nextNodes,J.nextEdges,J.saveEditVersion);J.waiters.forEach(({resolve:ae})=>ae(Y))}catch(Y){(Y==null?void 0:Y.code)!=="WORKSPACE_REVISION_CONFLICT"&&(Ds("error"),Fs(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,T},[k,w,RS]),D$=m.useCallback(x=>{var _;const S=(_=x==null?void 0:x.extra)!=null&&_.instances&&typeof x.extra.instances=="object"?x.extra.instances:{};Z.current=S,ne(S),g(Array.isArray(x==null?void 0:x.nodes)?x.nodes:[]),b(Array.isArray(x==null?void 0:x.edges)?x.edges:[]),Cn(""),ee(null)},[b,g]),F$=m.useMemo(()=>({instances:te}),[te]),z$=YU({nodes:w,edges:k,extra:F$,enabled:ce.current,onRestore:D$}),{resetHistory:du,undo:TS,redo:MS}=z$,vs=m.useCallback(async(x={})=>{var Le,$t;const S=(x==null?void 0:x.background)===!0,_=gt.current+1;gt.current=_;const P=Be.current,T=me.current;S||(ce.current=!1);const U=NY({background:S}),X=$r(a);let J=null,Y;if(!U.nodes&&!U.files)Y=await fetch(`/api/workspace/graph?${X.toString()}`);else{const Fe=$r(a);Fe.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[ut,Et]=await Promise.all([fetch(`/api/nodes?${Fe.toString()}`),fetch(`/api/workspace/graph?${X.toString()}`),Pn()]);if(J=await ut.json(),!ut.ok)throw new Error(J.error||"读取节点定义失败");Y=Et}const ae=await Y.json();if(!Y.ok)throw new Error(ae.error||"读取 workspace graph 失败");const pe=wY({background:S,requestId:_,currentRequestId:gt.current,dirty:ot.current,startedEditVersion:P,currentEditVersion:Be.current,startedRevision:T,currentRevision:me.current});if(pe==="superseded")return{skipped:!0,reason:pe};if(pe==="local-edits")return ge("检测到远端更新;本地修改将在保存时自动合并"),{skipped:!0,reason:pe};const fe=S?nn.current:[...(Array.isArray(J)?J:J.nodes||[]).filter(Fe=>!EY.has(Fe.id)),MY,TY,IY,RY,AY,PY];S||(nn.current=fe,It(fe));const Ne=ae.graph||JSON.parse(localStorage.getItem(_Y)||"null")||{},We=Tu(Ne,fe),ze=gh((Le=Ne==null?void 0:Ne.ui)==null?void 0:Le.displayPage,We.nodes),Ve=!O.current;let He=D.current;if(Ve){let Fe=null;try{Fe=JSON.parse(window.localStorage.getItem(u)||"null")}catch{Fe=null}He=gb(Fe)||gb(($t=Ne==null?void 0:Ne.ui)==null?void 0:$t.viewport)}const Me=S?hY($e.current,Ne):null;if(S&&(Me!=null&&Me.safe)){const Fe=Me.nodesChanged?mY(j.current,We.nodes,Me.changedNodeIds):j.current,ut=Me.edgesChanged?gY(N.current,We.edges):N.current,Et=Me.displayPageChanged||!eo(H.current,ze),El=Me.nodesChanged||Me.edgesChanged||Et;if(El&&(xe.current=!0),Me.nodesChanged){const ci=yY(Z.current,We.instances,Me.changedNodeIds);Z.current=ci,j.current=Fe,ne(ci),g(Fe)}if(Me.edgesChanged&&(N.current=ut,b(ut)),Et&&(H.current=ze,R(ze)),El&&du(Fe,ut,{instances:Me.nodesChanged?Z.current:We.instances}),Me.nodesChanged||Et){const ci=new Set(ze.nodeIds);K(xa=>{const ba=xa.filter(Gf=>ci.has(Gf));return ba.length===xa.length?xa:ba})}}else Z.current=We.instances,j.current=We.nodes,N.current=We.edges,H.current=ze,xe.current=!0,ne(We.instances),g(We.nodes),b(We.edges),R(ze),K([]),du(We.nodes,We.edges,{instances:We.instances});const Bt=Dp(ae.workspaceSchedules||[]);ga(Fe=>eo(Fe,Bt)?Fe:Bt),me.current=String(ae.revision||""),$e.current=Ne,ot.current=!1;const rt=ae.collaboration||null;wg(Fe=>eo(Fe,rt)?Fe:rt),w$(ae.adminReview||null),ul(null),Ve&&(L(He),D.current=He,O.current=!0);const Ye=ae.writable!==!1;return y$(Ye),ge(Ye?"Workspace ready":"Readonly workspace"),Ds(Ye?"synced":"readonly"),Fs(Ye?"所有修改已同步":ae.adminReview?`管理员只读查看:${ae.adminReview.ownerUsername||ae.adminReview.ownerUserId||"其他用户"}`:"只读 Project"),ce.current=!0,{skipped:!1}},[a,t.language,Pn,du,b,g,u]),Rf=m.useCallback((x={})=>{if(!ce.current)return;const S=String(x.revision||""),_=x.type==="graph.committed",P=!!(Te.current||st.current||mt.current);if(CY({eventType:x.type,revision:S,currentRevision:me.current,targetRevision:Tt.current,refreshPending:P}))return;if(_&&S&&(Tt.current=S),ot.current){mt.current=!1,ge("检测到其他成员的更新;保存时将自动合并");return}if(mt.current=!0,Te.current||st.current)return;const T=async()=>{if(Te.current=null,Oe.current){mt.current=!0,Te.current=window.setTimeout(T,80);return}if(ot.current){mt.current=!1,ge("检测到其他成员的更新;保存时将自动合并");return}mt.current=!1,st.current=!0;try{await vs({background:!0}),Tt.current=me.current}catch(U){Tt.current="",ge(String(U.message||U))}finally{st.current=!1,mt.current&&!ot.current&&(Te.current=window.setTimeout(T,40))}};Te.current=window.setTimeout(T,40)},[vs]),fu=m.useCallback(async(x=or)=>{const S=String(x||"").trim();iS(!0),hl("");try{const _=$r(a);_.set("tapdId",S),_.set("runtimeOnly","1");const P=await fetch(`/api/prd-workflow/snapshot?${_.toString()}`),T=await P.json().catch(()=>({}));if(!P.ok)throw new Error(T.error||"读取 PRD Workflow 失败");Nf(T.snapshot||null),Cf(""),_f(null),nu(null);try{const U=`agentflow.workflow.tapdId:${a.flowSource||"user"}:${a.flowId||""}`;S?window.localStorage.setItem(U,S):window.localStorage.removeItem(U)}catch{}}catch(_){hl(String(_.message||_))}finally{iS(!1)}},[a,or]),kl=m.useCallback(async(x=null,S={})=>{const _=x&&typeof x=="object"?x:un==null?void 0:un.nextAction,P=fm(_);if(!P||Eg)return;const T=(S==null?void 0:S.confirm)===!0,U=String((S==null?void 0:S.expectedRevision)||(un==null?void 0:un.revision)||"");oS(!0),hl(""),T||(Cf(""),_f(null),nu(null));try{const X=await fetch("/api/prd-workflow/action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,tapdId:or,action:P,stage:tl(_),title:to(_,0),...dG(_),dryRun:!T,confirm:T,issueKey:_.issueKey||_.issue_key||"",expectedRevision:U,idempotencyKey:`workflow-${Date.now()}-${Math.random().toString(36).slice(2)}`})}),J=await X.json().catch(()=>({}));if(!X.ok||J.ok===!1)throw J.snapshot&&Nf(J.snapshot),J.conflict&&nu({...J.conflict,action:_}),new Error(J.error||"执行 PRD Workflow action 失败");Cf(J.rawOutput||(J.output?JSON.stringify(J.output,null,2):"")),Nf(J.snapshot||un),nu(null),_f(T?null:{action:_,output:J.output||null,expectedRevision:U,at:new Date().toISOString()})}catch(X){hl(String(X.message||X))}finally{oS(!1)}},[a,Eg,un,or]),B$=m.useCallback((x=null)=>kl(x,{confirm:!1}),[kl]),H$=m.useCallback(()=>{const x=(bs==null?void 0:bs.action)||(un==null?void 0:un.nextAction);return kl(x,{confirm:!0,expectedRevision:(bs==null?void 0:bs.expectedRevision)||""})},[kl,bs,un]),W$=m.useCallback(()=>{const x=(tu==null?void 0:tu.action)||(un==null?void 0:un.nextAction);return nu(null),kl(x,{confirm:!1})},[kl,tu,un]),V$=m.useCallback(async()=>{var U,X;const x=String(Ag||(un==null?void 0:un.rawOutput)||"").trim();if(!x||Pg)return;const S=(bs==null?void 0:bs.action)||(un==null?void 0:un.nextAction)||{},_=`Review: ${to(S,0)||(un==null?void 0:un.pointer)||or||"PRD Workflow"}`,P=/^[\[{]/.test(x),T=x.startsWith("#")?x:`# ${_}
|
|
247
|
-
|
|
248
|
-
${P?`\`\`\`json
|
|
249
|
-
${x}
|
|
250
|
-
\`\`\``:x}`;aS(!0),hl("");try{const J=await fetch("/api/prd-workflow/review-link",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,tapdId:or,title:_,markdown:T,action:fm(S),stage:tl(S),issueKey:S.issueKey||S.issue_key||"",artifactLabel:"临时 Review"})}),Y=await J.json().catch(()=>({}));if(!J.ok||Y.ok===!1)throw new Error(Y.error||"生成 Review 链接失败");Nf(Y.snapshot||un);const ae=((U=Y.review)==null?void 0:U.shortUrl)||((X=Y.review)==null?void 0:X.url)||"";ae&&Cf(pe=>`${pe||x}
|
|
251
|
-
|
|
252
|
-
Review link: ${ae}`)}catch(J){hl(String(J.message||J))}finally{aS(!1)}},[a,Ag,bs,Pg,un,or]),K$=m.useCallback(async(x,S)=>{const _={packageId:(x==null?void 0:x.newId)||(x==null?void 0:x.id)||(x==null?void 0:x.label),label:(x==null?void 0:x.label)||(x==null?void 0:x.newId)||(x==null?void 0:x.id),version:"1.0.0",definitionId:S,body:(x==null?void 0:x.body)||"",script:(x==null?void 0:x.script)||"",scriptRef:(x==null?void 0:x.scriptRef)||"",implementationRef:(x==null?void 0:x.implementationRef)||"",implementationMode:(x==null?void 0:x.implementationMode)||"",inputs:Array.isArray(x==null?void 0:x.inputs)?x.inputs:[],outputs:Array.isArray(x==null?void 0:x.outputs)?x.outputs:[],flowId:a.flowId,flowSource:a.flowSource||"user",archived:!!a.archived},P=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(_)}),T=await P.json().catch(()=>({}));if(!P.ok||(T==null?void 0:T.ok)===!1)throw new Error((T==null?void 0:T.error)||"Publish failed");return await vs(),ge(`Published node ${T.definitionId||T.id||_.packageId}`),T},[a,vs]),ya=m.useCallback((x=Os)=>{const S=Array.isArray(x)?x:[],P=[...S].reverse().find(T=>(T==null?void 0:T.status)==="running"||(T==null?void 0:T.status)==="stopping")||[...S].reverse().find(T=>T==null?void 0:T.id);return String((P==null?void 0:P.id)||"workspace")},[Os]),q$=m.useCallback(x=>{const S=String(x||"").trim();!S||S==="workspace"||Un(_=>{const P=(Array.isArray(_)?_:[]).filter(T=>T.id!==S);return ks(T=>T===S?ya(P):T),P})},[ya]);m.useCallback((x="")=>{gl(!0),yl(null),xs(null),ks(x||ya())},[ya]);const $S=m.useCallback((x={})=>{yl({scheduleNodeId:String(x.scheduleNodeId||""),runNodeId:String(x.runNodeId||x.nodeId||""),lastRunId:String(x.lastRunId||""),label:String(x.label||"")}),gl(!1),xs(null),Cn("")},[]),Wg=m.useCallback(async(x="")=>{const S=String(x||"").trim();if(!(!S||!je)){jS(S),ge(`Optimizing run: ${S}`);try{await en(j.current,N.current);const _=$l(j.current,N.current,Z.current),P=JC(j.current,Z.current,S,Li),T=await fetch("/api/workspace/run/optimize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runNodeId:S,graph:_,model:P})}),U=await T.json().catch(()=>({}));if(!T.ok||U.ok===!1)throw new Error(U.error||"优化失败");const X=U.graph||_,J=Tu(X,be);Z.current=J.instances,ne(J.instances),g(J.nodes),b(J.edges),ga(Dp(U.workspaceSchedules||[])),du(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{jS("")}}},[Li,N,a,j,be,du,en,b,g,je]),LS=m.useCallback(async(x="")=>{const S=String(x||"").trim(),_=ou.current||{},P=Object.entries(_).find(([Y,ae])=>Y===S||String((ae==null?void 0:ae.runNodeId)||"")===S)||Object.entries(_)[0]||null,T=(P==null?void 0:P[0])||"",U=(P==null?void 0:P[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));T&&Di(Y=>{const ae={...Y};return ae[T]&&(ae[T]={...ae[T],status:"stopping"}),ae}),ge(X?`Stopping Workspace run: ${X}...`:"Stopping Workspace run..."),Un(Y=>Y.map(ae=>(T?ae.id===T:!X||ae.runNodeId===X)&&ae.status==="running"?{...ae,status:"stopping"}:ae));try{const Y=await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runId:T,runNodeId:X})}),ae=await Y.json().catch(()=>({}));if(!Y.ok||(ae==null?void 0:ae.stopped)!==!0)throw new Error(ae.error||"Workspace run stop failed");const pe=T?au.current.get(T):null;pe&&(pe.abort(),au.current.delete(T)),T&&Di(fe=>{const Ne={...fe};return delete Ne[T],Ne}),xl(fe=>{const Ne=new Set(fe);for(const We of J)Ne.delete(We);return Ne}),bl(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"),Un(fe=>fe.map(Ne=>(T?Ne.id===T:!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){T&&Di(pe=>{const fe={...pe};return fe[T]&&(fe[T]={...fe[T],status:"running"}),fe});const ae=String((Y==null?void 0:Y.message)||Y||"Workspace run stop failed");ge(`停止失败:${ae}`),Un(pe=>pe.map(fe=>(T?fe.id===T:!X||fe.runNodeId===X)?{...fe,status:"running",messages:[...Array.isArray(fe.messages)?fe.messages:[],{role:"assistant",kind:"error",error:!0,text:`停止失败:${ae}`,at:Date.now()}].slice(-160)}:fe))}},[a,Di]),Tf=m.useCallback(async()=>{if(a.flowId)try{const x=$r(a),S=await fetch(`/api/workspace/run/status?${x.toString()}`),_=await S.json().catch(()=>({}));if(!S.ok||!_.running)return;const P=Array.isArray(_.runs)&&_.runs.length?_.runs:[{runId:`run-restored-${_.startedAt||Date.now()}`,runNodeId:_.runNodeId||"",startedAt:_.startedAt||Date.now(),plannedNodeIds:[]}],T={},U=[];for(const X of P){const J=String((X==null?void 0:X.runNodeId)||"").trim(),Y=String((X==null?void 0:X.runId)||`run-restored-${(X==null?void 0:X.startedAt)||Date.now()}-${J}`).trim();if(!Y)continue;const ae=String((X==null?void 0:X.label)||"").trim()||lw(j.current,Z.current,J,"Workspace Run");T[Y]={id:Y,runNodeId:J,label:ae,status:(X==null?void 0:X.state)==="stopping"?"stopping":"running",plannedNodeIds:Array.isArray(X==null?void 0:X.plannedNodeIds)?X.plannedNodeIds:[],startedAt:(X==null?void 0:X.startedAt)||Date.now()},J&&U.push(J)}if(!Object.keys(T).length)return;Di(X=>({...X,...T})),xl(X=>{const J=new Set(X);for(const Y of U)J.add(Y);return J}),bl(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"),Un(X=>{const J=[...X];for(const[Y,ae]of Object.entries(T)){if(J.some(Ne=>Ne.id===Y||["running","stopping"].includes(Ne.status)&&Ne.runNodeId===ae.runNodeId))continue;const pe=String(ae.runNodeId||""),fe=String(ae.label||"").trim()||lw(j.current,Z.current,pe,"Workspace Run");J.push({id:Y,label:cw(fe,pe,"Workspace Run"),alias:fe,runNodeId:pe,status:ae.status,startedAt:ae.startedAt||Date.now(),steps:pe?[{id:pe,label:cw(fe,pe,"Workspace Run"),status:"running"}]:[],messages:[{role:"assistant",kind:"run-summary",text:ae.status==="stopping"?"Workspace run is stopping in the background.":"Workspace run is still running in the background.",at:Date.now()}]})}return[...J.slice(-8)]})}catch{}},[a,j,Di]),OS=m.useCallback(async x=>{if(!je){ge("Readonly workspace");return}if(!x)return;if(Object.values(ou.current||{}).find(rt=>String((rt==null?void 0:rt.runNodeId)||"")===String(x||""))){ge(`Workspace run already running: ${x}`);return}let _=j.current,P=N.current,T=Z.current;const U=Lv.current;if(U!=null&&U.id){const rt=_.find(Le=>Le.id===U.id),Ye=QC({nodes:_,edges:P,instances:T,selectedNode:rt,draft:U,allowRename:!1});if(Ye!=null&&Ye.error){ll(Ye.error),ge(Ye.error);return}Ye!=null&&Ye.ok&&Ye.changed&&(_=Ye.nodes,P=Ye.edges,T=Ye.instances,Z.current=T,j.current=_,N.current=P,ne(T),g(_),b(P),Hr(Ye.nextId||U.id))}const X=$l(_,P,T),J=`run-${Date.now()}-${String(x).replace(/[^a-z0-9_-]+/gi,"_")}`,Y=lw(_,T,x,"Workspace Run"),ae=cw(Y,x,"Workspace Run");let pe=[x];try{const rt=await fetch("/api/workspace/run/plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:X,runNodeId:x})}),Ye=await rt.json().catch(()=>({}));if(!rt.ok||(Ye==null?void 0:Ye.ok)===!1)throw new Error(Ye.error||"Workspace run plan failed");pe=Array.isArray(Ye.plannedNodeIds)&&Ye.plannedNodeIds.length?Ye.plannedNodeIds.map($t=>String($t||"").trim()).filter(Boolean):[x],pe=Array.from(new Set([x,...pe].filter(Boolean)));const Le=Ye.conflict||null;if(Le!=null&&Le.runNodeId||Le!=null&&Le.runId){const $t=Array.isArray(Le.conflictNodeIds)&&Le.conflictNodeIds.length?`: ${Le.conflictNodeIds.join(", ")}`:"";ge(`Run ${x} conflicts with running ${Le.runNodeId||Le.runId}${$t}`);return}}catch(rt){ge(String(rt.message||rt));return}const fe=new Set(pe),Ne=Object.values(ou.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 ${x} conflicts with running ${Ne.runNodeId||"workspace run"}${rt.length?`: ${rt.join(", ")}`:""}`);return}const We=new AbortController;au.current.set(J,We),lu.current.delete(J),Di(rt=>({...rt,[J]:{id:J,runNodeId:x,label:Y,plannedNodeIds:pe,startedAt:Date.now()}})),xl(rt=>new Set([...rt,x])),bl(rt=>({...rt,[x]:{status:"running"}})),ge(`Running ${ae}...`),ks(J),Un(rt=>[...rt.slice(-7),{id:J,label:ae,alias:Y,runNodeId:x,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);let ze=x;const Ve=new Map,He=()=>lu.current.has(J),Me=rt=>{const Ye=new Set((rt||[]).map(Le=>String(Le||"").trim()).filter(Boolean));Ye.size||Ye.add(String(x||"")),xl(Le=>{const $t=new Set(Le);for(const Fe of Ye)$t.delete(Fe);return $t})},Bt=(rt,Ye)=>{const Le=new Set((rt||[]).map($t=>String($t||"").trim()).filter(Boolean));Le.size||Le.add(String(x||"")),bl($t=>{var ut;const Fe={...$t};for(const Et of Le)Et&&(!Fe[Et]||((ut=Fe[Et])==null?void 0:ut.status)==="running")&&(Fe[Et]={status:Ye});return Fe})};try{await en(_,P);const rt=JC(_,T,x,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:x,runAlias:Y,runSessionId:J,expectedRevision:me.current,clientId:ke.current,model:rt,selectedSkills:Ls,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(),$t=new TextDecoder;let Fe="",ut=[],Et=[];const El=(ye,nt)=>{var lt,Ct;const Ge=w.find(Ft=>Ft.id===ye),ft=String(((lt=Ge==null?void 0:Ge.data)==null?void 0:lt.label)||ye||"").trim(),we=String(nt||((Ct=Ge==null?void 0:Ge.data)==null?void 0:Ct.definitionId)||"").trim();return we&&we!==ft?`${ft} (${we})`:ft},ci=(ye,nt,Ge)=>{const ft=String(ye||"").trim();ft&&Un(we=>we.map(lt=>{if(lt.id!==J)return lt;const Ft=[...Array.isArray(lt.steps)?lt.steps:[]],pt=Ft.findIndex(hn=>hn.id===ft),kt={id:ft,label:El(ft,nt),status:Ge};pt>=0?Ft[pt]={...Ft[pt],...kt}:Ft.push(kt);const fn=Ft.map((hn,ko)=>{const Bi=hn.status==="done"?"[done]":hn.status==="failed"?"[failed]":"[running]";return`${ko+1}. ${Bi} ${hn.label}`}).join(`
|
|
253
|
-
`),Jt=Array.isArray(lt.messages)?lt.messages:[],on=Jt.findIndex(hn=>hn.kind==="run-summary"),bn={role:"assistant",kind:"run-summary",text:fn||"准备运行...",at:Date.now()},Ht=[...Jt];return on>=0?Ht[on]=bn:Ht.unshift(bn),{...lt,steps:Ft,messages:Ht.slice(-160)}}))},xa=(ye,nt)=>{var A0,P0,I0,R0,T0,M0,$0,L0,O0,D0;const Ge=String(ye||"").trim(),ft=String(nt||"").trim();if(!Ge||!ft)return;const we=(A0=Z.current)==null?void 0:A0[Ge];if(!ti(we==null?void 0:we.definitionId))return;const lt=na(we==null?void 0:we.input,"displayType","markdown"),Ct=hM(lt),Ft=mM(Ge),pt=be.find(Tr=>Tr.id===Ct),kt=qC(pt==null?void 0:pt.inputs,Ct,ft),fn=qC(pt==null?void 0:pt.outputs,Ct,ft),Jt=String((we==null?void 0:we.label)||Ge||"一键任务").trim(),on={...Z.current||{},[Ge]:{...we||{},output:YC(we==null?void 0:we.output)},[Ft]:{...((P0=Z.current)==null?void 0:P0[Ft])||{},definitionId:Ct,label:Jt,role:"normal",body:ft,input:kt,output:fn,sourceContextRunNodeId:Ge,displayReloadKey:String(Date.now())}};Z.current=on,ne(on);const bn=j.current||[],Ht=bn.find(Tr=>Tr.id===Ge),hn=bn.find(Tr=>Tr.id===Ft),ko=Number(((I0=Ht==null?void 0:Ht.measured)==null?void 0:I0.width)||(Ht==null?void 0:Ht.width)||((T0=(R0=Ht==null?void 0:Ht.data)==null?void 0:R0.nodeSize)==null?void 0:T0.width)||520),Bi=(hn==null?void 0:hn.position)||{x:Number(((M0=Ht==null?void 0:Ht.position)==null?void 0:M0.x)||0)+ko+120,y:Number((($0=Ht==null?void 0:Ht.position)==null?void 0:$0.y)||0)},lr=((L0=hn==null?void 0:hn.data)==null?void 0:L0.displaySize)||((O0=hn==null?void 0:hn.data)==null?void 0:O0.nodeSize)||{width:ub,height:db},ui=ab({id:Ft,type:mc,position:Bi,width:Number(lr.width)||ub,height:Number(lr.height)||db,data:{label:Jt,definitionId:Ct,role:"normal",body:ft,inputs:kt,outputs:fn,sourceContextRunNodeId:Ge,displayReloadKey:on[Ft].displayReloadKey,nodeSize:lr,displaySize:lr}},on,be),vo=bn.map(Tr=>{if(Tr.id===Ge){const{width:Wce,height:Vce,measured:Kce,...VL}=Tr,{nodeSize:qce,displaySize:Uce,...ep}=Tr.data||{};return{...VL,data:{...ep,outputs:YC(ep==null?void 0:ep.outputs),contextRunResultNonce:Date.now()}}}return Tr.id===Ft?{...ui,selected:Tr.selected}:Tr});hn||vo.push(ui),j.current=vo,g(vo);const So=N.current||[],Zf=gM(Ct),ry=UC((we==null?void 0:we.output)||((D0=Ht==null?void 0:Ht.data)==null?void 0:D0.outputs),"output",["content","result"],["text"]),HL=UC(kt,"input",[Zf,"content"],["text"]),WL={id:`we-${Ge}-${Ft}`,source:Ge,target:Ft,sourceHandle:ry,targetHandle:HL,markerEnd:{type:bi.ArrowClosed}},E0=[...So.filter(Tr=>!(Tr.source===Ge&&Tr.target===Ft)),WL];N.current=E0,b(E0),window.requestAnimationFrame(()=>{o(Ge),o(Ft)})},ba=(ye,nt=null)=>{const Ge=ye!=null&&ye.instances&&typeof ye.instances=="object"?ye.instances:{},ft=nt instanceof Set?nt:null;for(const[we,lt]of Object.entries(Ge)){if(ft&&!ft.has(we)||!ti(lt==null?void 0:lt.definitionId))continue;const Ct=ug({outputs:lt.output});Ct&&xa(we,Ct)}},Gf=ye=>{const nt=String(ye||"").trim();if(!nt)return;const Ge=ze;ze=nt,xl(ft=>{const we=new Set(ft);return Ge&&Ge!==nt&&Ge!==x&&we.delete(Ge),x&&we.add(x),we.add(nt),we}),bl(ft=>{var we;return{...ft,...Ge&&Ge!==nt&&Ge!==x&&((we=ft[Ge])==null?void 0:we.status)==="running"?{[Ge]:{status:"success"}}:{},...x?{[x]:{status:"running"}}:{},[nt]:{status:"running"}}})},N0=ye=>{const nt=String(ye||"").trim();nt&&(xl(Ge=>{const ft=new Set(Ge);return ft.delete(nt),ft}),bl(Ge=>({...Ge,[nt]:{status:"success"}})))},C0=(ye,nt)=>{const Ge=String(nt||"");if(!Ge.trim())return;const ft=["assistant","thinking","result","error","prompt"].includes(ye)?ye:"assistant";Un(we=>we.map(lt=>{if(lt.id!==J)return lt;let Ct=Array.isArray(lt.messages)?lt.messages:[];if(ft==="result"){const kt=[...Ct].reverse().find(fn=>fn.kind==="assistant");if(String((kt==null?void 0:kt.text)||"").trim()===Ge.trim())return lt}if(ft==="assistant"){const kt=Ct.findIndex(fn=>fn.kind==="result"&&String(fn.text||"").trim()===Ge.trim());kt>=0&&(Ct=Ct.filter((fn,Jt)=>Jt!==kt))}const Ft=[...Ct],pt=Ft[Ft.length-1];return pt&&pt.kind===ft&&!pt.error?Ft[Ft.length-1]={...pt,text:`${pt.text||""}${pt.text?`
|
|
254
|
-
`:""}${Ge}`}:Ft.push({role:"assistant",kind:ft,text:Ge,...ft==="error"?{error:!0}:{},at:Date.now()}),{...lt,messages:Ft.slice(-160)}}))},Jf=ye=>{const nt=String(ye||"");nt.trim()&&Un(Ge=>Ge.map(ft=>{var Ft;if(ft.id!==J)return ft;const we=Array.isArray(ft.messages)?ft.messages:[],lt=we.findIndex(pt=>pt.kind==="thinking"),Ct=[...we];if(lt>=0){const pt=String(((Ft=Ct[lt])==null?void 0:Ft.text)||"");Ct[lt]={...Ct[lt],text:`${pt}${pt&&!pt.endsWith(`
|
|
255
|
-
`),""}${nt}`,at:Date.now()}}else{const pt=Ct.findIndex(kt=>kt.kind==="activity");Ct.splice(pt>=0?pt+1:Ct.length,0,{role:"assistant",kind:"thinking",text:nt,at:Date.now()})}return{...ft,messages:Ct.slice(-160)}}))},bo=(ye,nt=null)=>{const Ge=UY(ye);Ge&&Un(ft=>ft.map(we=>{if(we.id!==J)return we;const lt=Number(nt==null?void 0:nt.ts)||Date.now(),Ct=Number(we.startedAt)||lt,Ft=Number(we.lastActivityAt)||Ct,pt=Math.max(0,lt-Ft),kt=Number.isFinite(Number(nt==null?void 0:nt.runElapsedMs))?Math.max(0,Number(nt.runElapsedMs)):Math.max(0,lt-Ct),fn=Array.isArray(we.activities)?we.activities:[],Jt=fn[fn.length-1],bn=(typeof Jt=="string"?Jt:String((Jt==null?void 0:Jt.text)||""))===Ge?fn:[...fn,{text:Ge,kind:GY(Ge),stepMs:pt,totalMs:kt,at:lt}].slice(-30),Ht=Array.isArray(we.timingEntries)?we.timingEntries:[],hn=Array.isArray(we.messages)?we.messages:[],ko=hn.findIndex(ui=>ui.kind==="activity"),Bi={role:"assistant",kind:"activity",text:AC(bn,Ht,Ct,lt),at:Date.now()},lr=[...hn];if(ko>=0)lr[ko]=Bi;else{const ui=lr.findIndex(vo=>vo.kind==="run-summary");lr.splice(ui>=0?ui+1:0,0,Bi)}return{...we,activities:bn,lastActivityAt:lt,messages:lr.slice(-160)}}))},_0=ye=>{const nt=String((ye==null?void 0:ye.source)||"runner"),Ge=String((ye==null?void 0:ye.stream)||""),ft=String((ye==null?void 0:ye.eventType)||"event"),we=String((ye==null?void 0:ye.text)||"").trim();if(!we)return;const lt=`[${nt}${Ge?`:${Ge}`:""}] ${ft}
|
|
256
|
-
${we}`,Ct=_G(ye);Un(Ft=>Ft.map(pt=>{if(pt.id!==J)return pt;const fn=[...Array.isArray(pt.rawTrace)?pt.rawTrace:[],lt].slice(-80),Jt=Array.isArray(pt.timingEntries)?pt.timingEntries:[],on=Ct?[...Jt,Ct].slice(-80):Jt,bn=Array.isArray(pt.activities)?pt.activities:[],Ht=Number(pt.startedAt)||Number(ye==null?void 0:ye.ts)||Date.now(),hn=Number(Ct==null?void 0:Ct.at)||Number(ye==null?void 0:ye.ts)||Date.now(),ko=Array.isArray(pt.messages)?pt.messages:[],Bi={role:"assistant",kind:"raw",text:fn.join(`
|
|
257
|
-
|
|
258
|
-
---
|
|
259
|
-
|
|
260
|
-
`),at:Date.now()},lr=[...ko],ui=lr.findIndex(So=>So.kind==="activity");if(Ct){const So={role:"assistant",kind:"activity",text:AC(bn,on,Ht,hn),at:Date.now()};if(ui>=0)lr[ui]=So;else{const Zf=lr.findIndex(ry=>ry.kind==="run-summary");lr.splice(Zf>=0?Zf+1:0,0,So)}}const vo=lr.findIndex(So=>So.kind==="raw");return vo>=0?lr[vo]=Bi:lr.push(Bi),{...pt,rawTrace:fn,timingEntries:on,messages:lr.slice(-160)}}))},BL=ye=>{Un(nt=>nt.map(Ge=>Ge.id===J?{...Ge,status:ye,endedAt:Date.now()}:Ge))},Xf=ye=>{const nt=new Set,Ge=String((ye==null?void 0:ye.nodeId)||"").trim();Ge&&nt.add(Ge);for(const ft of Array.isArray(ye==null?void 0:ye.displayNodeIds)?ye.displayNodeIds:[]){const we=String(ft||"").trim();we&&nt.add(we)}for(const ft of Array.isArray(ye==null?void 0:ye.touchedNodeIds)?ye.touchedNodeIds:[]){const we=String(ft||"").trim();we&&nt.add(we)}if(nt.size===0)for(const ft of Array.isArray(ye==null?void 0:ye.order)?ye.order:[]){const we=String(ft||"").trim();we&&nt.add(we)}return nt},Qf=(ye,nt=null)=>{const Ge=Tu(ye||X,be),ft=new Map(Ge.nodes.map(pt=>[pt.id,pt])),we=Ge.instances||{},lt=nt instanceof Set?nt:null,Ct=(pt,kt)=>{const fn={...pt||kt};Array.isArray(kt==null?void 0:kt.output)&&(fn.output=kt.output);for(const Jt of["scriptRef","implementationRef","implementationMode"])(kt==null?void 0:kt[Jt])!=null&&String(kt[Jt]).trim()!==""&&(fn[Jt]=kt[Jt]);return fn},Ft=(pt,kt)=>{const fn={...pt||{}};Array.isArray(kt==null?void 0:kt.outputs)&&(fn.outputs=kt.outputs);for(const Jt of["scriptRef","implementationRef","implementationMode"])(kt==null?void 0:kt[Jt])!=null&&String(kt[Jt]).trim()!==""&&(fn[Jt]=kt[Jt]);return fn};g(pt=>{const kt=new Set(pt.map(on=>on.id)),Jt={...$l(pt,N.current,Z.current).instances||{}};for(const[on,bn]of Object.entries(we)){if(lt&&!lt.has(on)||!kt.has(on))continue;const Ht=Jt[on];nl((bn==null?void 0:bn.definitionId)||(Ht==null?void 0:Ht.definitionId))?Jt[on]=bn:Array.isArray(bn==null?void 0:bn.output)&&(Jt[on]=Ct(Ht,bn))}return Z.current=Jt,ne(Jt),pt.map(on=>{var Ht,hn;if(lt&&!lt.has(on.id))return on;const bn=ft.get(on.id);return bn?nl(((Ht=bn.data)==null?void 0:Ht.definitionId)||((hn=on.data)==null?void 0:hn.definitionId))?{...on,data:{...on.data,...bn.data}}:{...on,data:Ft(on.data,bn.data)}:on})})};for(;;){const{value:ye,done:nt}=await Le.read();if(nt)break;Fe+=$t.decode(ye,{stream:!0});const Ge=Fe.split(`
|
|
261
|
-
`);Fe=Ge.pop()||"";for(const ft of Ge){if(!ft.trim())continue;const we=JSON.parse(ft);if(we.type==="error")throw new Error(we.error||"Workspace run failed");if(we.type==="stopped"){lu.current.add(J),ut=Array.isArray(we.order)?we.order:ut,bo("运行停止",we);continue}if(we.type==="node-start"&&(ge(`Running ${we.nodeId}...`),Gf(we.nodeId),ci(we.nodeId,we.definitionId,"running")),we.type==="node-done"){const lt=Ve.get(String(we.nodeId||"").trim());lt&&xa(we.nodeId,lt),N0(we.nodeId),ci(we.nodeId,we.definitionId,"done")}if(we.type==="status"&&bo(we.line||we.message||"",we),we.type==="paused"&&(Et=Array.isArray(we.nodeIds)?we.nodeIds:[],bo("运行暂停",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"?Jf(we.text||""):C0(we.kind,we.text||"")),we.type==="raw"){const lt=PC(we);lt&&Jf(lt),_0(we)}if(we.type==="graph"&&we.graph){const lt=Xf(we);Qf(we.graph,lt),ba(we.graph,lt)}if(we.type==="done"){if(we.revision&&(me.current=String(we.revision)),we.graph){$e.current=we.graph;const lt=Xf(we);Qf(we.graph,lt),ba(we.graph,lt)}ut=Array.isArray(we.order)?we.order:[],Et=Array.isArray(we.pauseNodeIds)?we.pauseNodeIds:Et,bo(Et.length?"运行暂停":"运行完成",we)}}}if(Fe.trim()){const ye=JSON.parse(Fe);if(ye.type==="error")throw new Error(ye.error||"Workspace run failed");if(ye.type==="stopped"&&(lu.current.add(J),bo("运行停止",ye)),ye.type==="node-start"&&(ge(`Running ${ye.nodeId}...`),Gf(ye.nodeId),ci(ye.nodeId,ye.definitionId,"running")),ye.type==="node-done"){const nt=Ve.get(String(ye.nodeId||"").trim());nt&&xa(ye.nodeId,nt),N0(ye.nodeId),ci(ye.nodeId,ye.definitionId,"done")}if(ye.type==="status"&&bo(ye.line||ye.message||"",ye),ye.type==="paused"&&(Et=Array.isArray(ye.nodeIds)?ye.nodeIds:[],bo("运行暂停",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"?Jf(ye.text||""):C0(ye.kind,ye.text||"")),ye.type==="raw"){const nt=PC(ye);nt&&Jf(nt),_0(ye)}if(ye.type==="graph"&&ye.graph){const nt=Xf(ye);Qf(ye.graph,nt),ba(ye.graph,nt)}if(ye.type==="done"){if(ye.revision&&(me.current=String(ye.revision)),ye.graph){$e.current=ye.graph;const nt=Xf(ye);Qf(ye.graph,nt),ba(ye.graph,nt)}ut=Array.isArray(ye.order)?ye.order:[],Et=Array.isArray(ye.pauseNodeIds)?ye.pauseNodeIds:Et,bo(Et.length?"运行暂停":"运行完成",ye)}}He()&&(Me(pe),Bt(pe,"stopped"));const ny=He()?`Workspace run stopped: ${x}`:Et.length?`Workspace run paused at ${Et.join(", ")}`:`Workspace run done: ${ut.length?ut.join(" -> "):x}`;if(ge(ny),He()||Bt(pe,Et.length?"paused":"success"),BL(He()?"stopped":Et.length?"paused":"done"),!He()){try{await en(j.current,N.current),ge(ny)}catch(ye){ge(`${ny},但保存结果失败:${String(ye.message||ye)}`)}await Pn()}}catch(rt){if(He()||(rt==null?void 0:rt.name)==="AbortError"){Me(pe),Bt(pe,"stopped"),ge(`Workspace run stopped: ${x}`),Un(Ye=>Ye.map(Le=>Le.id===J?{...Le,status:"stopped",endedAt:Date.now()}:Le));return}Me(pe),Bt([x,ze].filter(Boolean),"failed"),ge(String(rt.message||rt)),Un(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{au.current.get(J)===We&&au.current.delete(J),Di(rt=>{const Ye={...rt};return delete Ye[J],Ye}),lu.current.delete(J),Me(pe)}},[Li,k,a,Pn,w,be,Hr,en,Ls,b,g,Di,o,je]),Mf=m.useCallback(async()=>{try{const S=await(await fetch("/api/skills")).json().catch(()=>({})),_=Array.isArray(S.skills)?S.skills.map(P=>({key:String(P.key),name:String(P.name||P.id||P.key),description:P.description?String(P.description):"",sourceLabel:P.sourceLabel?String(P.sourceLabel):""})):[];C$(_),Zv(!0)}catch{Zv(!0)}},[]),$f=m.useCallback(async()=>{try{const S=await(await fetch("/api/mcps")).json().catch(()=>({})),_=Array.isArray(S.servers)?S.servers.map(P=>({name:String((P==null?void 0:P.name)||""),type:String((P==null?void 0:P.type)||""),url:String((P==null?void 0:P.url)||""),command:String((P==null?void 0:P.command)||""),args:Array.isArray(P==null?void 0:P.args)?P.args.map(String):[],description:String((P==null?void 0:P.description)||"")})).filter(P=>P.name):[];nS(_)}catch{nS([])}},[]),Lf=m.useCallback(async()=>{try{const x=$r(a),_=await(await fetch(`/api/workspaces?${x.toString()}`)).json().catch(()=>({})),P=Array.isArray(_.workspaces)?_.workspaces.map(T=>({id:String((T==null?void 0:T.id)||""),label:String((T==null?void 0:T.label)||(T==null?void 0:T.name)||"知识库"),path:String((T==null?void 0:T.path)||""),kind:(T==null?void 0:T.kind)==="git"?"git":"local",repoUrl:String((T==null?void 0:T.repoUrl)||""),branch:String((T==null?void 0:T.branch)||""),mountPath:String((T==null?void 0:T.mountPath)||""),type:String((T==null?void 0:T.type)||""),builtin:(T==null?void 0:T.builtin)===!0,exists:(T==null?void 0:T.exists)!==!1})).filter(T=>T.path):[];sS(P)}catch{sS([])}},[a]),DS=m.useCallback(async()=>{Ke.current=!1;try{const x=$r(a),S=await fetch(`/api/workspace/conversations?${x.toString()}`),_=await S.json().catch(()=>({}));if(!S.ok)throw new Error(_.error||`HTTP ${S.status}`);const P=NC(_.conversations||{});ml(P.composer.messages),Un(P.composer.runSessions),ks(P.composer.activeSessionId||"workspace"),wo(P.nodeChats)}catch{ml([]),Un([]),ks("workspace"),wo({})}finally{Ke.current=!0}},[a]),FS=m.useCallback(async()=>{if(!je||a.archived)return;const x=NC({composer:{activeSessionId:Wr,messages:ha,runSessions:Os},nodeChats:ma});await fetch("/api/workspace/conversations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,conversations:x})}).then(async S=>{if(!S.ok){const _=await S.json().catch(()=>({}));throw new Error(_.error||`HTTP ${S.status}`)}})},[Wr,ha,Os,a,ma,je]);m.useEffect(()=>{let x=!1;return l?(Og(null),Dg(!0),()=>{x=!0}):((async()=>{const _=new URL(window.location.href),P=String(_.searchParams.get("invite")||"").trim();if(P){ge("正在加入共享 Workspace...");const T=await fetch("/api/workspace/collaboration/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:P})}),U=await T.json().catch(()=>({}));if(!T.ok)throw new Error(U.error||"加入共享 Workspace 失败");_.searchParams.delete("invite"),window.history.replaceState({},"",`${_.pathname}${_.search}${_.hash}`)}x||(await vs(),x||await DS())})().catch(_=>{const P=String(_.message||_);ge(P),Ds("error"),Fs(P)}),If(),fetch("/api/model-lists").then(_=>_.json()).then(_=>j$({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(()=>{}),Mf(),$f(),Lf(),Tf(),fetch("/api/skill-collections").then(_=>_.json()).then(_=>{_$(Da(_)),E$(!0)}).catch(()=>{}),fetch("/api/auth/me").then(_=>_.json()).then(_=>{Og(_.user||null),Dg(!0)}).catch(()=>{Og(null),Dg(!0)}),()=>{x=!0})},[l,vs,DS,If,$f,Mf,Tf,Lf,Oi]),m.useEffect(()=>{if(ES(""),!(!Qv||!eS)){if(!Oi){eu([]);return}eu($F(Oi,"workspace",$s,pl)),ES(Oi)}},[pl,eS,$s,Qv,Oi]),m.useEffect(()=>{if(!(_S!==Oi||!Oi))try{localStorage.setItem(Oi,JSON.stringify(Ls))}catch{}},[Ls,Oi,_S]),m.useEffect(()=>{Z.current=te},[te]),m.useEffect(()=>{j.current=w},[w]),m.useEffect(()=>{if(Oe.current)return;const x=z.current,S=new Map,_=[];for(const P of w){const T=JT(P);S.set(P.id,T),x.get(P.id)!==T&&_.push(P.id)}z.current=S,_.length!==0&&Hr(_)},[w,Hr]),m.useEffect(()=>{N.current=k},[k]),m.useEffect(()=>{H.current=I},[I]),m.useEffect(()=>{D.current=A},[A]),m.useEffect(()=>{Lv.current=at},[at]),m.useEffect(()=>{yo.current=Gt},[Gt]),m.useEffect(()=>{ue.current=G},[G]),m.useEffect(()=>{if(!G)return;const x=_=>{_.key==="Escape"&&ee(null)},S=_=>{var P,T;(T=(P=_.target)==null?void 0:P.closest)!=null&&T.call(P,".af-connect-node-menu")||ee(null)};return document.addEventListener("keydown",x),document.addEventListener("pointerdown",S),()=>{document.removeEventListener("keydown",x),document.removeEventListener("pointerdown",S)}},[G]),m.useEffect(()=>{if(!ce.current||!je)return;if(Oe.current){de.current&&window.clearTimeout(de.current);return}if(xe.current){xe.current=!1;return}li(),de.current&&window.clearTimeout(de.current);const x=ie.current?0:650;return ie.current=!1,de.current=window.setTimeout(()=>{en().catch(S=>ge(String(S.message||S)))},x),()=>{de.current&&window.clearTimeout(de.current)}},[w,k,I,li,en,je]),m.useEffect(()=>{if(Ke.current&&!(!je||a.archived))return Ue.current&&window.clearTimeout(Ue.current),Ue.current=window.setTimeout(()=>{FS().catch(x=>ge(String(x.message||x)))},900),()=>{Ue.current&&window.clearTimeout(Ue.current)}},[Wr,ha,Os,a.archived,ma,FS,je]);const pu=m.useMemo(()=>w.filter(x=>{var S;return((S=x==null?void 0:x.data)==null?void 0:S.definitionId)==="workspace_scheduled_run"}).map(x=>{var S;return{id:x.id,config:bv(((S=x.data)==null?void 0:S.body)||"")}}),[w]),U$=m.useMemo(()=>pu.map(x=>`${x.id}:${x.config.enabled?"1":"0"}:${x.config.cron}:${x.config.timezone}`).join("|"),[pu]);m.useEffect(()=>{if(!ce.current||d!=="workspace"||!a.flowId){ga({});return}if(!pu.length){ga({});return}let x=!1;const S=async()=>{try{const P=$r(a),T=await fetch(`/api/workspace/schedules?${P.toString()}`),U=await T.json().catch(()=>({}));if(!T.ok)throw new Error(U.error||"读取 Workspace 定时状态失败");x||ga(Dp(U.schedules||[]))}catch{x||ga(P=>{var U;const T={};for(const X of pu)T[X.id]={...P[X.id]||{},lastStatus:((U=P[X.id])==null?void 0:U.lastStatus)||"unknown"};return T})}};S();const _=window.setInterval(S,5e3);return()=>{x=!0,window.clearInterval(_)}},[a,pu,U$,d]);const zS=m.useCallback((x,S)=>{if(!je){ge("Readonly workspace");return}const _=KC(S),P=Y=>Array.isArray(Y)?Y.map(ae=>(ae==null?void 0:ae.name)!=="skillKeys"&&(ae==null?void 0:ae.name)!=="skillsContext"&&(ae==null?void 0:ae.type)!=="text"?ae:{...ae,default:_,value:_}):[],T=w.map(Y=>{var ae;return Y.id!==x?Y:{...Y,data:{...Y.data,body:_,inputs:P((ae=Y.data)==null?void 0:ae.inputs)}}}),U=Z.current||{},X=U[x]&&typeof U[x]=="object"?U[x]:{},J={...U,[x]:{...X,body:_,input:P(X.input)}};Z.current=J,g(T),ne(J),xs(Y=>!Y||Y.id!==x?Y:{...Y,body:_,inputs:P(Y.inputs)}),en(T,k).catch(Y=>ge(String(Y.message||Y)))},[k,w,en,g,je]),BS=m.useCallback((x,S)=>{if(!je){ge("Readonly workspace");return}const _=LJ(S),P=Y=>Array.isArray(Y)?Y.map(ae=>(ae==null?void 0:ae.name)!=="serverNames"&&(ae==null?void 0:ae.name)!=="mcpContext"&&(ae==null?void 0:ae.type)!=="text"?ae:{...ae,default:_,value:_}):[],T=w.map(Y=>{var ae;return Y.id!==x?Y:{...Y,data:{...Y.data,body:_,inputs:P((ae=Y.data)==null?void 0:ae.inputs)}}}),U=Z.current||{},X=U[x]&&typeof U[x]=="object"?U[x]:{},J={...U,[x]:{...X,body:_,input:P(X.input)}};Z.current=J,g(T),ne(J),xs(Y=>!Y||Y.id!==x?Y:{...Y,body:_,inputs:P(Y.inputs)}),en(T,k).catch(Y=>ge(String(Y.message||Y)))},[k,w,en,g,je]),HS=m.useCallback((x,S)=>{if(!je){ge("Readonly workspace");return}const _=(Array.isArray(S)?S:S?[S]:[]).filter(ze=>String((ze==null?void 0:ze.path)||"").trim()),P=_[0]||null,T=String((P==null?void 0:P.path)||"").trim(),U=_.length===1?String((P==null?void 0:P.label)||(P==null?void 0:P.id)||"知识库").trim():_.length?`${_.length} 个知识库`:"",X=_.length?JSON.stringify(dg(_)):"",J=P?JSON.stringify({version:1,id:(P==null?void 0:P.id)||"",label:String((P==null?void 0:P.label)||(P==null?void 0:P.id)||"知识库").trim(),kind:(P==null?void 0:P.kind)||"local",cwd:T,workspaceRoot:T,repoUrl:(P==null?void 0:P.repoUrl)||"",branch:(P==null?void 0:P.branch)||"",mountPath:(P==null?void 0:P.mountPath)||"",type:(P==null?void 0:P.type)||""}):"",Y=ze=>Array.isArray(ze)?ze.map(Ve=>(Ve==null?void 0:Ve.name)==="path"?{...Ve,default:T,value:T}:(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:T,value:T,showOnNode:!1}:Ve):[],pe=w.map(ze=>{var Ve,He,Me;return ze.id===x?{...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[x]&&typeof fe[x]=="object"?fe[x]:{},We={...fe,[x]:{...Ne,label:Ne.label||"加载知识库",input:Y(Ne.input),output:ae(Ne.output)}};Z.current=We,g(pe),ne(We),xs(ze=>(ze==null?void 0:ze.id)===x?{...ze,inputs:Y(ze.inputs),outputs:ae(ze.outputs)}:ze),en(pe,k).catch(ze=>ge(String(ze.message||ze)))},[k,w,en,g,je]),WS=m.useCallback((x,S)=>{if(!je){ge("Readonly workspace");return}const _=String(x||"");if(!_)return;const P=KC((S==null?void 0:S.skillKeys)||[]),T=yf((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:P,value:P}:(Me==null?void 0:Me.name)==="displayType"?{...Me,default:T,value:T}:(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):[],pe=He=>Array.isArray(He)?He.map(Me=>(Me==null?void 0:Me.name)==="displayType"?{...Me,default:T,value:T}:Me):[],fe=String((S==null?void 0:S.task)??""),Ne=w.map(He=>{var Me,Bt;return He.id===_?{...He,data:{...He.data,body:fe,model:U,inputs:ae((Me=He.data)==null?void 0:Me.inputs),outputs:pe((Bt=He.data)==null?void 0:Bt.outputs)}}:He}),We=Z.current||{},ze=We[_]&&typeof We[_]=="object"?We[_]:{},Ve={...We,[_]:{...ze,body:fe,model:U,input:ae(ze.input),output:pe(ze.output)}};Z.current=Ve,g(Ne),ne(Ve),xs(He=>(He==null?void 0:He.id)===_?{...He,body:fe,model:U,inputs:ae(He.inputs),outputs:pe(He.outputs)}:He),en(Ne,k).catch(He=>ge(String(He.message||He)))},[k,w,en,g,je]),VS=m.useCallback((x,S)=>{if(!je){ge("Readonly workspace");return}const _=OG(S),P=w.map(J=>J.id===x?{...J,data:{...J.data,body:_}}:J),T=Z.current||{},U=T[x]&&typeof T[x]=="object"?T[x]:{},X={...T,[x]:{...U,body:_}};Z.current=X,xe.current=!0,g(P),ne(X),xs(J=>(J==null?void 0:J.id)===x?{...J,body:_}:J),en(P,k).catch(J=>ge(String(J.message||J)))},[k,w,en,g,je]),KS=m.useCallback(x=>{const S=String(x||"").trim();S&&(gS(_=>_===S?"":S),wo(_=>({..._,[S]:_[S]||{sessionId:`nodechat_${Date.now()}_${S.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),qS=m.useCallback(()=>gS(""),[]),US=m.useCallback((x,S)=>{const _=String(x||"").trim();_&&wo(P=>({...P,[_]:{...P[_]||{sessionId:`nodechat_${Date.now()}_${_.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(S||""),error:""}}))},[]),zs=m.useCallback((x,S,_="replace",P={})=>{var rt,Ye;if(!je){ge("Readonly workspace");return}const T=String(x||"").trim();if(!T)return;const U=j.current.find(Le=>Le.id===T),X=Rn(U==null?void 0:U.data),J=ti((rt=U==null?void 0:U.data)==null?void 0:rt.definitionId),Y=Ei(S),ae=X==="html"?Vc(Y):X==="react"?cg(Y):String(Y||""),pe=U?no(U.data):"",fe=_==="append"&&String(pe||"").trim()?`${String(pe).replace(/\s+$/g,"")}
|
|
262
|
-
|
|
263
|
-
${ae.trim()}`:ae,Ne=X==="image"?"src":"content",We=P!=null&&P.reloadDisplay?Date.now():(Ye=U==null?void 0:U.data)==null?void 0:Ye.displayReloadKey,ze=Le=>{let $t=!1;return(Array.isArray(Le)?Le:[]).map(ut=>{const Et=String((ut==null?void 0:ut.name)||""),El=String((ut==null?void 0:ut.type)||"");return(J?Et===Ne||Et==="result"||Et==="filePath":Et===Ne||Et==="filePath"||El==="text")?$t?{...ut,default:"",value:""}:($t=!0,{...ut,default:fe,value:fe}):ut})},Ve=j.current.map(Le=>{var $t,Fe;return Le.id!==T?Le:{...Le,data:{...Le.data,body:J?Le.data.body:fe,...We?{displayReloadKey:We}:{},inputs:ze(($t=Le.data)==null?void 0:$t.inputs),outputs:ze((Fe=Le.data)==null?void 0:Fe.outputs)}}}),He=Z.current||{},Me=He[T]&&typeof He[T]=="object"?He[T]:{},Bt={...He,[T]:{...Me,body:J?Me.body:fe,input:ze(Me.input),output:ze(Me.output)}};Z.current=Bt,g(Ve),ne(Bt),xs(Le=>(Le==null?void 0:Le.id)===T?{...Le,...J?{}:{body:fe}}:Le),(P==null?void 0:P.logChat)!==!1&&wo(Le=>{var $t;return{...Le,[T]:{...Le[T]||{},candidateContent:"",messages:[...($t=Le[T])!=null&&$t.messages&&Array.isArray(Le[T].messages)?Le[T].messages:[],{role:"assistant",text:_==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),en(Ve,N.current).catch(Le=>ge(String(Le.message||Le))),ge(String((P==null?void 0:P.statusMessage)||"")||(_==="append"?"已追加节点内容":"已替换节点内容"))},[en,g,je]),Of=m.useCallback(async(x,S="")=>{if(!je)return ge("Readonly workspace"),"";if(!x)return"";try{const _=new FormData;_.set("file",x),_.set("dir",String(S||"")),a.flowId&&_.set("flowId",a.flowId),a.flowSource&&_.set("flowSource",a.flowSource),a.adminOwnerId&&_.set("adminOwnerId",a.adminOwnerId),a.archived&&_.set("archived","1");const P=await fetch("/api/workspace/upload",{method:"POST",body:_}),T=await P.json().catch(()=>({}));if(!P.ok)throw new Error(T.error||"上传文件失败");const U=String(T.path||"").trim();if(!U)throw new Error("上传文件失败:未返回路径");return await Pn(),fl(X=>{const J=new Set(X);for(const Y of zp(U))J.delete(Y);return J}),ge(`已上传 ${U}`),U}catch(_){return ge(String(_.message||_)),""}},[a,Pn,je]),Df=m.useCallback(async x=>um(x)?Of(x,"img"):(ge("请选择图片文件"),""),[Of]),YS=m.useCallback((x="")=>{var S;if(!je){ge("Readonly workspace");return}Gv.current=String(x||""),(S=Yv.current)==null||S.click()},[je]),Y$=m.useCallback(async x=>{const S=Array.from(x.target.files||[]);if(x.target.value="",!S.length)return;const _=Gv.current||"";Uv(!0);try{let P="";for(const T of S){const U=await Of(T,_);U&&(P=U)}S.length>1&&ge(`已上传 ${S.length} 个文件${P?`,最后一个:${P}`:""}`)}catch(P){ge(String(P.message||P))}finally{Uv(!1)}},[Of]),GS=m.useCallback(async(x,S)=>{const _=String(x||"").trim();if(!_)return;const P=await Df(S);P&&zs(_,P,"replace",{logChat:!1,statusMessage:`已上传图片 ${P}`})},[zs,Df]),JS=m.useCallback(async(x,S=void 0)=>{var ze,Ve;if(!je){ge("Readonly workspace");return}const _=String(x||"").trim();if(!_)return;const P=ma[_]||{},T=String(S!==void 0?S:P.draft||"").trim();if(!T||P.running)return;const U=j.current.find(He=>He.id===_);if(!U)return;const X=Rn(U.data)||"markdown",J=no(U.data);let Y=ta(J,X),ae=Ei(J);if(Y)try{ae=await rl(a,Y)}catch(He){ge(String(He.message||He))}else if(X!=="image"&&String(ae||"").trim()){const He=$a(X,ae);if(He){ge(`${He} 未进入微调。`);return}try{const Me=await wb(a,WC(_,U.data),ae);await Pn(),zs(_,Me,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已将展示保存为 ${Me}`}),Y=Me,ae=""}catch(Me){ge(String(Me.message||Me));return}}const pe=eJ(_,j.current,N.current),fe={role:"user",text:T,at:Date.now()},Ne=Array.isArray(P.messages)?P.messages:[],We=P.sessionId||`nodechat_${Date.now()}_${_.replace(/[^a-z0-9_-]+/gi,"_")}`;wo(He=>({...He,[_]:{...P,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:pe,targetFilePath:Y,messages:Ne,message:T,model:Li})}),Me=await He.json().catch(()=>({}));if(!He.ok)throw new Error(Me.error||"节点微调失败");const Bt=String(Me.candidateContent||Me.reply||"").trim(),rt=!!Me.directFileEdit,Ye=String(Me.artifactPath||Y||"").trim();if(rt&&Ye){const Le=$a(X,Bt);if(Le)throw new Error(`${Le} 文件已由 agent 修改,请检查 ${Ye}。`);await Pn(),zs(_,Ye,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已按微调描述更新 ${Ye}`})}else if(Bt){const Le=$a(X,Bt);if(Le)throw new Error(`${Le} 已取消写入,避免覆盖当前展示文件。`);if(Y){const $t=await wb(a,Y,Bt);await Pn(),zs(_,$t,"replace",{logChat:!1,statusMessage:`已按微调描述更新 ${$t}`})}else zs(_,Bt,"replace",{logChat:!1,statusMessage:"已按微调描述更新展示内容"})}wo(Le=>{var $t;return{...Le,[_]:{...Le[_]||{},sessionId:String(Me.sessionId||We),running:!1,candidateContent:"",messages:[...($t=Le[_])!=null&&$t.messages&&Array.isArray(Le[_].messages)?Le[_].messages:[...Ne,fe],{role:"assistant",text:Bt||rt?Ye?`已更新文件 ${Ye}。`:"已按你的描述更新当前展示。":"没有生成可更新的内容。",at:Date.now()}]}}})}catch(He){const Me=String(He.message||He);wo(Bt=>({...Bt,[_]:{...Bt[_]||{},running:!1,error:Me}})),ge(Me)}},[Li,a,Pn,ma,zs,je]),XS=m.useCallback(async(x,S)=>{if(!je){ge("Readonly workspace");return}const _=Rn(S)||"markdown",P=no(S),T=ta(P,_);let U=Ei(P);if(T)try{U=await rl(a,T)}catch(ae){ge(String(ae.message||ae));return}if(!String(U||"").trim()){ge("展示节点没有可保存内容");return}const X=$a(_,U);if(X){ge(`${X} 未保存文件。`);return}const J=WC(x,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})}),pe=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(pe.error||"保存文件失败");const fe=pe.path||Y,Ne=$r(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 Pn(),Ov(ze=>_J(ze,fe,String(U||"").length)),fl(ze=>{const Ve=new Set(ze);for(const He of zp(fe))Ve.delete(He);return Ve}),zs(x,fe,"replace",{logChat:!1,statusMessage:`已保存并引用 ${fe}`}),ge(`已保存 ${fe}`)}catch(ae){ge(String(ae.message||ae))}},[a,Pn,zs,je]),QS=m.useCallback(x=>{var T,U;const S=String(x||"").trim();if(!S||ve)return;const _=j.current.find(X=>X.id===S);if(!_||!Rn(_==null?void 0:_.data)){ge("展示节点不可用");return}const P=String(((T=_.data)==null?void 0:T.label)||((U=_.data)==null?void 0:U.displayName)||S).trim()||"AgentFlow Display";le(fw({title:P,layout:"single",nodeIds:[S],mode:"single-node",sourceNodeId:S})),ir(""),Xt(null),Ir(!0)},[ve]),Ff=m.useCallback((x,S)=>{const _=String(x||"");_&&xs(P=>{if(!P||P.id!==_)return P;const T=typeof S=="function"?S(P):S;return!T||typeof T!="object"?P:{...P,...T}})},[]),ZS=m.useCallback((x,S)=>{const _=String(x||"");!_||!je||(g(P=>P.map(T=>{var X;if(T.id!==_)return T;const U=Array.isArray((X=T.data)==null?void 0:X.outputs)&&T.data.outputs.length?T.data.outputs.map((J,Y)=>Y===0?{...J,default:S,value:S}:J):[{type:"file",name:"value",default:S,value:S}];return{...T,data:{...T.data,body:"",outputs:U}}})),Ff(_,P=>({body:"",outputs:Array.isArray(P==null?void 0:P.outputs)&&P.outputs.length?P.outputs.map((U,X)=>X===0?{...U,default:S,value:S}:U):[{type:"file",name:"value",default:S,value:S}]})),ge(`已选择文件 ${S}`))},[g,Ff,je]),e0=m.useCallback(x=>{Ng({nodeId:String(x||""),query:""})},[]),Vg=m.useCallback(()=>{Ng({nodeId:"",query:""})},[]),G$=m.useCallback(x=>{const S=String((x==null?void 0:x.path)||"").trim();!S||!Zc.nodeId||(ZS(Zc.nodeId,S),Vg())},[Vg,Zc.nodeId,ZS]),t0=m.useCallback(async(x,S)=>{if(!je)return;const _=gJ(x,S);if(_.length===0)return;const P=[];try{for(const T of _){const U=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:T})});if(U.status===404)continue;const X=await U.json().catch(()=>({}));if(!U.ok)throw new Error(X.error||"清理节点输出失败");P.push(X.path||T)}if(P.length===0)return;ge(`已清理 ${P.join(", ")}`),await Pn(),jg(T=>_.some(U=>T===U||T.startsWith(`${U}/`))?"":T)}catch(T){ge(String(T.message||T))}},[a,Pn,je]),hu=m.useMemo(()=>({modelLists:fa,showBodyPreview:!0,flowParams:a,readOnly:!je,onRunWorkspaceNode:OS,onStopWorkspaceNode:LS,onOpenWorkspaceRunLogs:$S,onOptimizeWorkspaceRun:Wg,onOptimizeWorkspaceSchedule:Wg,runningRunNodeIds:AS,onChangeScheduledRunConfig:VS,onChangeContextRunConfig:WS,skills:$s,skillCollections:pl,onChangeLoadSkillKeys:zS,onRefreshSkills:Mf,mcpServers:tS,onChangeLoadMcpNames:BS,onRefreshMcps:$f,workspaceTargets:rS,onChangeLoadWorkspace:HS,onRefreshWorkspaces:Lf,onSaveDisplayNodeToFile:XS,onShareDisplayNode:QS,onOpenDisplayPreview:Bn,onRefreshNodeInternals:Hr,onEnsureWorkspaceNodeDisplaySize:cS,sharingDisplayNodeId:ve,onUploadWorkspaceImage:Df,onUploadImageToDisplayNode:GS,onOpenProvideFilePicker:e0,onStatus:ge,onSetDisplayNodeContent:zs,onToggleNodeChat:KS,onCloseNodeChat:qS,onUpdateNodeChatDraft:US,onSendNodeChat:JS,onSyncNodePropDraft:Ff,onCleanupWorkspaceNodeOutputs:t0}),[WS,BS,zS,HS,VS,t0,qS,cS,a,tS,fa,e0,$S,Wg,$f,Hr,Mf,Lf,OS,AS,XS,JS,zs,QS,ve,pl,$s,LS,Ff,KS,US,GS,Df,rS,je]),J$=m.useRef(new Map),rs=m.useMemo(()=>{const x=J$.current,S=new Set,_=w.map(P=>{var Y,ae,pe;const T={selected:P.selected===!0,isExecuting:vS.has(P.id),nodeStatus:((Y=Hg[P.id])==null?void 0:Y.status)??null,nodeElapsed:((ae=Hg[P.id])==null?void 0:ae.elapsed)??null,optimizingRun:SS===P.id,scheduledRunState:kS[P.id]||null,nodeChatActive:mS===P.id,nodeChat:ma[P.id]||null},U=x.get(P.id);if(U&&U.source===P&&U.commonData===hu&&$C(U.runtime,T))return S.add(P.id),U.node;const X=!!(U&&((pe=U.source)==null?void 0:pe.data)===P.data&&U.commonData===hu&&$C(U.runtime,T)),J={...P,data:X?U.node.data:{...P.data,...hu,...T}};return x.set(P.id,{source:P,commonData:hu,runtime:T,node:J}),S.add(P.id),J});for(const P of x.keys())S.has(P)||x.delete(P);return _},[mS,hu,ma,w,SS,kS,vS,Hg]),ct=d==="display",In=d==="workflow",n0=m.useMemo(()=>ct?new Map(rs.map(x=>[x.id,x])):WG,[rs,ct]),r0=m.useMemo(()=>Yt&&rs.find(x=>x.id===Yt)||null,[Yt,rs]),s0=m.useRef(new Map),mu=m.useMemo(()=>{if(!ct)return s0.current.clear(),VG;const x=new Set(M),S=s0.current,_=new Set,P=I.nodeIds.map((T,U)=>{var We,ze,Ve,He;const X=n0.get(T);if(!X||!Rn(X.data))return null;const J=zl(X)||{width:520,height:320},Y=Ba(I.nodeSizes[T]||J,{display:!0})||J,ae=I.nodePositions[T]||{x:180+U*36,y:120+U*28},pe=x.has(T),fe=S.get(T);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===pe)return _.add(T),fe.node;const Ne={...X,id:LC(T),position:ae,selected:pe,width:Y.width,height:Y.height,data:{...X.data,sourceNodeId:T,displayPageMode:!0,readOnly:!0,selected:pe,displaySize:Y,nodeSize:Y}};return S.set(T,{source:X,position:ae,size:Y,selected:pe,node:Ne}),_.add(T),Ne}).filter(Boolean);for(const T of S.keys())_.has(T)||S.delete(T);return P},[I,n0,ct,M]),vl=m.useMemo(()=>rs.filter(x=>Rn(x==null?void 0:x.data)),[rs]);m.useEffect(()=>{if(!ct||!I.viewport)return;const x=I.viewport,S=()=>{try{r.setViewport(x,{duration:0})}catch{}},_=window.requestAnimationFrame(()=>window.requestAnimationFrame(S));return()=>window.cancelAnimationFrame(_)},[I.viewport,ct,r]),m.useEffect(()=>{if(ct||In||!A)return;const x=A,S=()=>{try{r.setViewport(x,{duration:0})}catch{}},_=window.requestAnimationFrame(()=>window.requestAnimationFrame(S));return()=>window.cancelAnimationFrame(_)},[ct,In,r,A]),m.useEffect(()=>{In&&fu(or)},[In]),m.useEffect(()=>{if(!In||!or)return;const x=$r(a);x.set("tapdId",or);let S=null,_=null,P=!1;const T=()=>{_&&(window.clearTimeout(_),_=null),S&&(S.onmessage=null,S.onerror=null,S.close(),S=null)},U=()=>{P||document.hidden||S||(S=new EventSource(`/api/prd-workflow/events?${x.toString()}`),S.onmessage=()=>{fu(or)},S.onerror=()=>{T(),!P&&!document.hidden&&(_=window.setTimeout(U,5e3))})},X=()=>{if(document.hidden){T();return}fu(or),U()};return U(),document.addEventListener("visibilitychange",X),()=>{P=!0,document.removeEventListener("visibilitychange",X),T()}},[a,In,fu,or]),m.useEffect(()=>{if(!a.flowId||In)return;const x=$r(a);x.set("clientId",ke.current);let S=null,_=null,P=!1;const T=()=>{_&&(window.clearTimeout(_),_=null),S&&(S.onmessage=null,S.onerror=null,S.close(),S=null)},U=()=>{P||document.hidden||S||(S=new EventSource(`/api/workspace/events?${x.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"){Rf(Y);return}if(Y.type==="runtime.committed"){Rf(Y);return}if(String(Y.type||"").startsWith("file.")){Pn();return}String(Y.type||"").startsWith("run.")&&Tf()}},S.onerror=()=>{T(),!P&&!document.hidden&&(_=window.setTimeout(U,5e3))})},X=()=>{if(document.hidden){T();return}Rf({type:"visibility.resume"}),U()};return U(),document.addEventListener("visibilitychange",X),()=>{P=!0,document.removeEventListener("visibilitychange",X),T(),Te.current&&(window.clearTimeout(Te.current),Te.current=null),mt.current=!1}},[a,In,Pn,Tf,Rf]),m.useEffect(()=>{if(Oe.current)return;const x=F.current,S=new Map,_=[];for(const P of[...rs,...mu]){const T=HG(P);S.set(P.id,T),x.get(P.id)!==T&&_.push(P.id)}F.current=S,_.length!==0&&Hr(_)},[mu,rs,Hr]);const qt=m.useMemo(()=>w.find(x=>x.id===Gt)||null,[w,Gt]),Kg=m.useRef({id:"",draft:null}),X$=m.useMemo(()=>{const x=GC(qt);return x?JSON.stringify(x):""},[qt==null?void 0:qt.data,qt==null?void 0:qt.id]);m.useEffect(()=>{if(!qt){Kg.current={id:"",draft:null},xs(null),ll("");return}const x=GC(qt),S=Kg.current;Kg.current={id:qt.id,draft:x},xs(_=>!_||_.id!==qt.id||S.id!==qt.id||!S.draft?x:zJ(_,S.draft,x)),ll("")},[qt==null?void 0:qt.id,X$]);const qg=m.useCallback((x=!1)=>{if(!at||!qt)return!1;if(!je)return ll("Readonly workspace"),ge("Readonly workspace"),!1;ll("");const S=QC({nodes:w,edges:k,instances:Z.current,selectedNode:qt,draft:at,allowRename:x});return S!=null&&S.error?(ll(S.error),!1):(!(S!=null&&S.ok)||!S.changed||(Z.current=S.instances,ne(S.instances),g(S.nodes),b(S.edges),S.nextId!==qt.id&&Cn(S.nextId),Hr(S.nextId)),!0)},[k,at,w,qt,b,g,Hr,je]);m.useEffect(()=>{if(!je||!at||!qt)return;const x=window.setTimeout(()=>{qg(!1)},350);return()=>window.clearTimeout(x)},[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)||[]),qg,qt==null?void 0:qt.id,je]);const i0=m.useRef({refs:new Map,nodeDataById:new Map}),Ug=m.useMemo(()=>{const x=i0.current;let S=x.refs.size!==w.length;const _=new Map;for(const T of w)_.set(T.id,T.data),(!x.refs.has(T.id)||x.refs.get(T.id)!==T.data)&&(S=!0);if(!S)return x.nodeDataById;const P=new Map(w.map(T=>[T.id,T.data]));return i0.current={refs:_,nodeDataById:P},P},[w]),Q$=m.useMemo(()=>k.map(x=>{var Y,ae;const S=Ug.get(x.source),_=Ug.get(x.target),P=/^output-(\d+)$/.exec(x.sourceHandle||""),T=/^input-(\d+)$/.exec(x.targetHandle||""),U=S&&P?(Y=S.outputs)==null?void 0:Y[parseInt(P[1],10)]:null,X=_&&T?(ae=_.inputs)==null?void 0:ae[parseInt(T[1],10)]:null,J=U!=null&&U.type?Mn(U.type):X!=null&&X.type?Mn(X.type):"";return J?{...x,style:{...x.style||{},stroke:J,strokeWidth:2},markerEnd:{type:bi.ArrowClosed,color:J}}:x}),[Ug,k]),zf=ct?mu:rs,Z$=ct?[]:Q$,o0=m.useRef(zf),Sl=m.useRef([]);Oe.current||(o0.current=zf);const eL=m.useMemo(()=>ct?mu.map(x=>({...x,id:Fp(x.id)})):rs,[mu,rs,ct]),Yg=m.useCallback(x=>{const S=String(x||"").trim();if(!S)return;const _=ct?LC(S):S;ct?K([S]):(g(T=>T.map(U=>({...U,selected:U.id===_}))),b(T=>T.map(U=>({...U,selected:!1}))),Cn(_));const P=()=>{var ae,pe,fe;const T=r.getNode(_);if(!T)return;const U=(ae=r.getInternalNode)==null?void 0:ae.call(r,_),X=((pe=U==null?void 0:U.measured)==null?void 0:pe.width)??(U==null?void 0:U.width)??T.width??260,J=((fe=U==null?void 0:U.measured)==null?void 0:fe.height)??(U==null?void 0:U.height)??T.height??120,{zoom:Y}=r.getViewport();r.setCenter(T.position.x+X/2,T.position.y+J/2,{zoom:JG(Y),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(P))},[ct,r,b,g]);m.useEffect(()=>{const x=String(c.current||"").trim();!x||!ce.current||d!=="workspace"||rs.some(S=>S.id===x)&&(c.current="",xe.current=!0,Yg(x))},[rs,Yg,d]);const a0=m.useCallback(()=>{const x=r.getViewport(),S={x:Number(x.x)||0,y:Number(x.y)||0,zoom:Math.min(Math.max(Number(x.zoom)||1,.1),4)};if(ct){const _={...H.current,viewport:S};H.current=_,R(_),ge("已固定 Display 进入视角")}else{D.current=S,L(S);try{window.localStorage.setItem(u,JSON.stringify(S))}catch{}ge("已固定 Workspace 进入视角");return}en(j.current,N.current).catch(_=>ge(String(_.message||_)))},[ct,r,en,u]),Gg=m.useMemo(()=>{const x=Vt.trim().toLowerCase(),S={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const _ of be)x&&![_.id,_.label,_.displayName,_.description].some(P=>String(P||"").toLowerCase().includes(x))||S[Ku(_)].push(_);for(const _ of Dl)S[_].sort((P,T)=>P.id.localeCompare(T.id));return S},[be,Vt]),gu=m.useMemo(()=>{const x=Ee.trim().toLowerCase();return be.filter(S=>!x||[S.id,S.label,S.displayName,S.description].some(_=>String(_||"").toLowerCase().includes(x))).sort((S,_)=>{const P=Dl.indexOf(Ku(S)),T=Dl.indexOf(Ku(_));return P!==T?P-T:qu(S).localeCompare(qu(_))}).slice(0,30)},[be,Ee]),yu=m.useMemo(()=>{const x=Ee.trim().toLowerCase();return Re.filter(S=>!x||[S.id,S.version,S.displayName,S.name,S.description,...Array.isArray(S.tags)?S.tags:[]].some(_=>String(_||"").toLowerCase().includes(x))).sort((S,_)=>String(S.displayName||S.name||S.id).localeCompare(String(_.displayName||_.name||_.id))).slice(0,30)},[Re,Ee]);m.useEffect(()=>{bt(0)},[Ee,Dn,he]),m.useEffect(()=>{if(!Dn)return;const x=window.setTimeout(()=>{var S;return(S=fS.current)==null?void 0:S.focus()},0);return()=>window.clearTimeout(x)},[Dn]);const tL=m.useMemo(()=>{const x=vg.trim().toLowerCase();return x?kv(cl).filter(S=>S.path.toLowerCase().includes(x)):cl},[vg,cl]),wa=m.useMemo(()=>lM(cl,Sg),[cl,Sg]),Fi=(wa==null?void 0:wa.type)==="directory"?wa.path:SJ((wa==null?void 0:wa.path)||""),nL=m.useCallback(x=>{var S,_;(_=(S=x.target)==null?void 0:S.closest)!=null&&_.call(S,".af-work-file")||jg("")},[]),rL=[...(fa.cursor||[]).map(x=>({label:`Cursor · ${x.split(" - ")[0]}`,value:`cursor:${x.split(" - ")[0]}`})),...(fa.opencode||[]).map(x=>({label:`OpenCode · ${x.split(" - ")[0]}`,value:`opencode:${x.split(" - ")[0]}`})),...(fa.claudeCode||[]).map(x=>({label:`Claude · ${x.split(" - ")[0]}`,value:`claude-code:${x.split(" - ")[0]}`})),...(fa.codex||[]).map(x=>({label:`Codex · ${x.split(" - ")[0]}`,value:`codex:${x.split(" - ")[0]}`}))],Jg=m.useMemo(()=>new Set(Ls),[Ls]),jl=m.useMemo(()=>{const x=new Map($s.map(U=>[U.key,U])),S=new Set,_=new Set,P=pl.map(U=>{const X=Zo(U,$s).map(J=>x.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),T=$s.filter(U=>{const X=String(U.name||U.id||U.key||"").trim();return!S.has(U.key)&&!_.has(X)});return{groups:P,ungrouped:T}},[pl,$s]);m.useEffect(()=>{uS(x=>{let S=!1;const _=new Set(x);for(const P of jl.groups)_.has(P.id)||(_.add(P.id),S=!0);return S?_:x})},[jl.groups]);const tr=m.useMemo(()=>{const x=w.filter(S=>S.selected);return x.length>0?x:Gt?w.filter(S=>S.id===Gt):[]},[w,Gt]),Bf=m.useMemo(()=>tr.map(x=>x.id),[tr]),l0=m.useCallback(()=>{if(ct)return;if(!je){ge("Readonly workspace");return}const x=(j.current||[]).filter(J=>(J==null?void 0:J.selected)&&!mm(J));if(x.length<2){ge("选择至少两个节点后按 G 创建 Group");return}const S=x.reduce((J,Y)=>{var We,ze,Ve,He,Me,Bt,rt,Ye,Le,$t,Fe,ut;const ae=Number(((We=Y.position)==null?void 0:We.x)||0),pe=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=(Bt=Y.data)==null?void 0:Bt.displaySize)==null?void 0:rt.width)||LT),Ne=Number(((Ye=Y.measured)==null?void 0:Ye.height)||Y.height||(($t=(Le=Y.data)==null?void 0:Le.nodeSize)==null?void 0:$t.height)||((ut=(Fe=Y.data)==null?void 0:Fe.displaySize)==null?void 0:ut.height)||cm);return{minX:Math.min(J.minX,ae),minY:Math.min(J.minY,pe),maxX:Math.max(J.maxX,ae+fe),maxY:Math.max(J.maxY,pe+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((j.current||[]).map(J=>J.id));let P=1,T=`group_${P}`;for(;_.has(T);)P+=1,T=`group_${P}`;const U=mb({width:S.maxX-S.minX+Lp*2,height:S.maxY-S.minY+Lp*2})||{width:Za,height:el},X={id:T,type:mc,position:{x:S.minX-Lp,y:S.minY-Lp},width:U.width,height:U.height,selected:!0,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:gm(P-1),title:gm(P-1),color:"purple",nodeSize:U}};g(J=>[X,...J.map(Y=>({...Y,selected:!1}))]),b(J=>J.map(Y=>({...Y,selected:!1}))),Cn(""),ge(`Created group for ${x.length} nodes`)},[ct,b,g,je]),wu=m.useMemo(()=>w.filter(x=>Rn(x==null?void 0:x.data)),[w]),Xg=m.useMemo(()=>tr.filter(x=>Rn(x==null?void 0:x.data)).map(x=>x.id),[tr]),sL=m.useMemo(()=>{const x=String((Rr==null?void 0:Rr.username)||(Rr==null?void 0:Rr.userId)||"").trim();return x?x.slice(0,1).toUpperCase():"?"},[Rr]),Qg=m.useMemo(()=>new Set(Bf),[Bf]),Hf=m.useMemo(()=>k.filter(x=>Qg.has(x.source)&&Qg.has(x.target)),[k,Qg]),Zg=m.useCallback(x=>{const S=x==="display"?"display":x==="workflow"?"workflow":"workspace";f(S),Cn(""),K([]),ee(null),q(!1),Pe(!1);const _=$r(a);S==="display"&&_.set("view","display"),S==="workflow"&&(_.set("view","workflow"),or.trim()&&_.set("tapdId",or.trim()));const P=`/workspace${_.toString()?`?${_.toString()}`:""}`;window.history.pushState({},"",P)},[a,or]),c0=m.useCallback(x=>{const S=String(x||"").trim();if(!S)return;const _=j.current.find(P=>P.id===S);if(!_||!Rn(_.data)){ge("展示节点不可用");return}R(P=>{if(P.nodeIds.includes(S))return P;const T=P.nodeIds.length,U=zl(_);return{nodeIds:[...P.nodeIds,S],nodePositions:{...P.nodePositions,[S]:{x:180+T*36,y:120+T*28}},nodeSizes:{...P.nodeSizes,...U?{[S]:U}:{}}}}),K([S])},[]),u0=m.useCallback(x=>{const S=String(x||"").trim();S&&(R(_=>{const P=_.nodeIds.filter(X=>X!==S),T={..._.nodePositions},U={..._.nodeSizes};return delete T[S],delete U[S],{nodeIds:P,nodePositions:T,nodeSizes:U}}),K(_=>_.filter(P=>P!==S)))},[]),d0=m.useCallback(x=>{const S=String(x||"").trim();S&&(H.current.nodeIds.includes(S)?u0(S):c0(S))},[c0,u0]),Wf=m.useMemo(()=>{const x=wt.trim().toLowerCase();return x?vl.filter(S=>{var _,P;return[S.id,(_=S.data)==null?void 0:_.label,(P=S.data)==null?void 0:P.definitionId].filter(Boolean).some(T=>String(T).toLowerCase().includes(x))}):vl},[vl,wt]),f0=m.useMemo(()=>{const x=Wf.length,S=x<=1?1:x<=4?2:3,_=Array.from({length:S},()=>({height:0,nodes:[]}));for(const P of Wf){const T=zl(P)||{width:420,height:260},U=Math.max(1,Number(T.width)||420),X=Math.max(1,Number(T.height)||260),J=Math.min(26,Math.max(5.5,X/U*16))+3.2;let Y=_[0];for(const ae of _)ae.height<Y.height&&(Y=ae);Y.nodes.push(P),Y.height+=J}return _.map(P=>P.nodes)},[Wf]),iL=m.useCallback(x=>{var U;const S=I.nodeIds.includes(x.id),_=zl(x)||{width:420,height:260},P=Math.max(1,Math.round(Number(_.width)||420)),T=Math.max(1,Math.round(Number(_.height)||260));return i.jsxs("button",{type:"button",className:"af-display-picker-card"+(S?" af-display-picker-card--selected":""),style:{"--af-display-picker-card-ratio":`${P} / ${T}`},onClick:()=>d0(x.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(dJ,{node:x})}),i.jsxs("span",{className:"af-display-picker-card__meta",children:[i.jsx("strong",{children:((U=x.data)==null?void 0:U.label)||x.id}),i.jsxs("small",{children:[Rn(x.data)," · ",x.id]})]})]},x.id)},[I.nodeIds,d0]),p0=m.useMemo(()=>{const x=Vt.trim().toLowerCase();return x?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(x))):Re},[Re,Vt]),h0=m.useCallback((x,S)=>{const _=String(x||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let P=`${_}_${Date.now().toString(36)}`,T=2;for(;S.has(P);)P=`${_}_${Date.now().toString(36)}_${T}`,T+=1;return S.add(P),P},[]),xu=m.useCallback((x,S)=>{var Le,$t;if(!je){ge("Readonly workspace");return}const _=x!=null&&x.snippet&&typeof x.snippet=="object"?x.snippet:{},P=_.instances&&typeof _.instances=="object"?_.instances:{},T=Object.keys(P);if(T.length===0)return;const U=new Set(j.current.map(Fe=>Fe.id)),X={};for(const Fe of T)X[Fe]=h0(Fe,U);const J=(Le=_.ui)!=null&&Le.nodePositions&&typeof _.ui.nodePositions=="object"?_.ui.nodePositions:{},Y=($t=_.ui)!=null&&$t.nodeSizes&&typeof _.ui.nodeSizes=="object"?_.ui.nodeSizes:{},ae=T.map(Fe=>{const ut=J[Fe];return{id:Fe,x:typeof(ut==null?void 0:ut.x)=="number"?ut.x:0,y:typeof(ut==null?void 0:ut.y)=="number"?ut.y:0}}),pe=Math.min(...ae.map(Fe=>Fe.x)),fe=Math.min(...ae.map(Fe=>Fe.y));let Ne=S||{x:360+j.current.length*24,y:180+j.current.length*18};if(!S){const Fe=document.querySelector(".af-workspace-canvas .react-flow");if(Fe){const ut=Fe.getBoundingClientRect();Ne=r.screenToFlowPosition({x:ut.left+ut.width*.48,y:ut.top+ut.height*.32})}}const We={},ze={},Ve={};for(const Fe of ae){const ut=X[Fe.id];We[ut]={...P[Fe.id]||{}},ze[ut]={x:Ne.x+(Fe.x-pe),y:Ne.y+(Fe.y-fe)};const Et=Y[Fe.id];typeof(Et==null?void 0:Et.width)=="number"&&typeof(Et==null?void 0:Et.height)=="number"&&(Ve[ut]={width:Et.width,height:Et.height})}const He=new Set(T),Me=(Array.isArray(_.edges)?_.edges:[]).filter(Fe=>He.has(Fe==null?void 0:Fe.source)&&He.has(Fe==null?void 0:Fe.target)).map(Fe=>({source:X[Fe.source],target:X[Fe.target],sourceHandle:Fe.sourceHandle??null,targetHandle:Fe.targetHandle??null})),Bt=Tu({instances:We,edges:Me,ui:{nodePositions:ze,nodeSizes:Ve}},be),rt=Bt.nodes.map(Fe=>Fe.id),Ye=Bt.nodes.map(Fe=>({...Fe,selected:!0}));Z.current={...Z.current,...Bt.instances},ne(Z.current),g(Fe=>[...Fe.map(ut=>({...ut,selected:!1})),...Ye]),b(Fe=>[...Fe.map(ut=>({...ut,selected:!1})),...Bt.edges.map(ut=>({...ut,selected:!1}))]),Cn(""),K([]),ge(`已添加流程片段:${x.displayName||x.id}(已选中 ${rt.length} 个节点)`)},[h0,be,r,b,g,je]),oL=m.useCallback(()=>{var _,P;if(tr.length<2){Kn("请先在 workspace 画布上选择至少两个节点。"),re("flows");return}const x=tr[0],S=tr.length===2?`${((_=x.data)==null?void 0:_.label)||x.id} 片段`:`${((P=x.data)==null?void 0:P.label)||x.id} 等 ${tr.length} 个节点`;Qn({name:S,id:S.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),Pr(""),br(!0),re("flows")},[tr]),aL=m.useCallback(async()=>{var T,U;if(tr.length<2)return;const x=xn.name.trim();if(!x){Pr("请填写片段名称。");return}const S={},_={};for(const X of tr){S[X.id]={x:((T=X.position)==null?void 0:T.x)||0,y:((U=X.position)==null?void 0:U.y)||0};const J=zl(X);J&&(_[X.id]=J)}const P=Hf.map(X=>({source:X.source,target:X.target,sourceHandle:X.sourceHandle??null,targetHandle:X.targetHandle??null}));mr(!0),Pr("");try{const X=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:xn.id,name:x,displayName:x,version:"1.0.0",description:xn.description,snippet:{instances:dv(tr,Z.current),edges:P,ui:{nodePositions:S,nodeSizes:_}}})}),J=await X.json().catch(()=>({}));if(!X.ok||J.ok===!1)throw new Error(J.error||"发布流程片段失败");br(!1),ge(`流程片段已发布:${J.id||x}`),lS(`流程片段已发布:${J.id||x}`),await If(),re("flows")}catch(X){Pr(String(X.message||X))}finally{mr(!1)}},[If,xn,Hf,tr,lS]),m0=m.useCallback(async()=>{var S;const x=Xc.trim();if(x){Fv(!0),Jc("");try{const _=await fetch("/api/workspace/collaboration/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,username:x,role:"editor"})}),P=await _.json().catch(()=>({}));if(!_.ok)throw new Error(P.error||"添加协作成员失败");wg(P.workspace||null),Bv(""),ge(`已将 Workspace 分享给 ${((S=P.member)==null?void 0:S.username)||x}`)}catch(_){Jc(String(_.message||_))}finally{Fv(!1)}}},[a,Xc]),lL=m.useCallback(()=>{Jc(""),xg(!0)},[]),cL=m.useCallback(async x=>{const S=String((x==null?void 0:x.userId)||"").trim();if(!(!S||S===(cn==null?void 0:cn.ownerId))){Wv(S),Jc("");try{const _=await fetch("/api/workspace/collaboration/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,memberUserId:S})}),P=await _.json().catch(()=>({}));if(!_.ok)throw new Error(P.error||"取消成员分享失败");wg(P.workspace||null),ge(`已取消对 ${(x==null?void 0:x.username)||S} 的分享`)}catch(_){Jc(String(_.message||_))}finally{Wv("")}}},[a,cn==null?void 0:cn.ownerId]),g0=m.useCallback(async()=>{const x=$l(j.current,N.current,Z.current);x.ui={...x.ui||{},...D.current?{viewport:D.current}:{},displayPage:OC(H.current,j.current)};const S=new Blob([`${JSON.stringify(x,null,2)}
|
|
264
|
-
`],{type:"application/json"}),_=URL.createObjectURL(S),P=document.createElement("a");P.href=_,P.download=`${a.flowId||"workspace"}-conflict-draft-${Date.now()}.json`,document.body.appendChild(P),P.click(),P.remove(),URL.revokeObjectURL(_),await vs(),ul(null),da(!1),ge("已备份本地草稿并载入远端最新版本")},[N,a.flowId,vs,j]),uL=m.useCallback(async()=>{const x=Array.isArray(An==null?void 0:An.conflictItems)?An.conflictItems:[];if(!x.length||!(An!=null&&An.mergeGraph)||!(An!=null&&An.currentGraph)){Qc("当前冲突缺少字段合并数据,请改用“备份并载入远端”。");return}let S=An.mergeGraph;try{x.forEach((P,T)=>{const U=kg[String(T)]||{mode:"local"};let X,J=!0;U.mode==="remote"?(X=P.current,J=P.hasCurrent!==!1):U.mode==="manual"?X=JSON.parse(String(U.manual||"")):(X=P.incoming,J=P.hasIncoming!==!1),S=YJ(S,P.pathParts,X,J)})}catch(P){Qc(`手动值不是有效 JSON:${String(P.message||P)}`);return}Vv(!0),Qc(""),Ds("saving"),Fs("正在提交冲突解决结果");const _=Ce.current.catch(()=>{}).then(async()=>{const P=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:S,baseRevision:An.currentRevision,baseGraph:An.currentGraph,clientId:ke.current})}),T=await P.json().catch(()=>({}));if(!P.ok){if(P.status===409&&Array.isArray(T.conflictItems)){const U=T.conflictItems;ul({currentRevision:String(T.currentRevision||""),message:T.error||"Workspace 再次出现冲突",conflictPaths:Array.isArray(T.conflictPaths)?T.conflictPaths:[],conflictItems:U,mergeGraph:T.mergeGraph||null,currentGraph:T.currentGraph||null}),dl(Object.fromEntries(U.map((X,J)=>[String(J),{mode:"local",manual:Mu(X)}])))}throw new Error(T.error||"提交冲突解决结果失败")}await vs(),ul(null),da(!1),ge("冲突已解决并保存")});Ce.current=_;try{await _}catch(P){Qc(String(P.message||P)),Ds("error"),Fs(String(P.message||P))}finally{Vv(!1)}},[a,vs,An,kg]);m.useCallback(()=>{if(wu.length===0){ge("当前 workspace 没有 display 节点");return}const x=Xg.length>0?Xg:wu.map(_=>_.id),S=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display";le(fw({title:S,layout:"gallery",nodeIds:x,mode:"multi-node"})),ir(""),Xt(null),Ir(!0)},[a.flowId,Xg,wu]);const dL=m.useCallback(x=>{le(S=>{const _=Array.isArray(S.nodeIds)?S.nodeIds:[];return _.includes(x)?{...S,nodeIds:_.filter(P=>P!==x)}:{...S,nodeIds:[..._,x]}})},[]),Bs=m.useCallback(async()=>{On(!0),Br("");try{const x=await fetch("/api/display/shares"),S=await x.json().catch(()=>({}));if(!x.ok)throw new Error(S.error||"读取分享列表失败");vr(Array.isArray(S.shares)?S.shares:[])}catch(x){Br(String(x.message||x)),vr([])}finally{On(!1)}},[]),fL=m.useCallback(()=>{sn(!0),oe(""),Bs()},[Bs]),pL=m.useCallback(async()=>{var _,P;const x=Nt.title.trim(),S=Array.isArray(Nt.nodeIds)?Nt.nodeIds:[];if(S.length===0){ir("请选择至少一个 display 节点。");return}Zn(!0),ir(""),Xt(null);try{await en(w,k);const T=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:x,layout:Nt.layout,nodeIds:S,...FC(Nt)})}),U=await T.json().catch(()=>({}));if(!T.ok||U.ok===!1)throw new Error(U.error||"发布展示页失败");const X=new URL(U.url||`/display/${((_=U.share)==null?void 0:_.id)||""}`,window.location.origin).href;Xt({...U,absoluteUrl:X}),ge((P=U.share)!=null&&P.expiresAt?"展示页已生成":"展示页已生成:永久有效"),ht&&Bs()}catch(T){ir(String(T.message||T))}finally{Zn(!1)}},[Nt,ht,k,a,Bs,w,en]),hL=m.useCallback(async()=>{var S,_;const x=Array.isArray(I.nodeIds)?I.nodeIds:[];if(x.length===0){ir("请先添加至少一个展示节点。"),ge("请先添加至少一个展示节点"),Pe(!0);return}Zn(!0),ir("");try{await en(w,k);const P=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display",T=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:P,layout:"canvas",nodeIds:x,...FC(Nt)})}),U=await T.json().catch(()=>({}));if(!T.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;Xt({...U,absoluteUrl:X}),Qt(!0),ge((_=U.share)!=null&&_.expiresAt?"展示链接已生成":"展示链接已生成:永久有效"),ht&&Bs()}catch(P){const T=String(P.message||P);ir(T),ge(T)}finally{Zn(!1)}},[I.nodeIds,Nt,ht,k,a,Bs,w,en]),y0=m.useCallback(async()=>{const x=jt==null?void 0:jt.absoluteUrl;if(!x)return;const S=await yb(x);er(S?"copied":"failed"),window.setTimeout(()=>er(""),1600)},[jt==null?void 0:jt.absoluteUrl]),mL=m.useCallback(async x=>{const S=zC(x),_=await yb(S);oe(_?String((x==null?void 0:x.id)||""):"failed"),window.setTimeout(()=>oe(""),1600)},[]),gL=m.useCallback(async(x,S)=>{const _=String((x==null?void 0:x.id)||"");if(_){ai(_),Br("");try{const P=S==="permanent"?{id:_,expiresMode:"permanent",permanent:!0}:{id:_,expiresMode:"days",expiresInDays:Number(S||30)},T=await fetch("/api/display/share",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(P)}),U=await T.json().catch(()=>({}));if(!T.ok||U.ok===!1)throw new Error(U.error||"更新分享有效期失败");await Bs(),ge("分享有效期已更新")}catch(P){Br(String(P.message||P))}finally{ai("")}}},[Bs]),yL=m.useCallback(async x=>{const S=String((x==null?void 0:x.id)||"");if(S){ai(S),Br("");try{const _=await fetch(`/api/display/share?id=${encodeURIComponent(S)}`,{method:"DELETE"}),P=await _.json().catch(()=>({}));if(!_.ok||P.ok===!1)throw new Error(P.error||"撤销分享失败");await Bs(),ge("分享已撤销")}catch(_){Br(String(_.message||_))}finally{ai("")}}},[Bs]),wL=m.useCallback(x=>{g(S=>S.map(_=>_.id===x?{..._,selected:!1}:_)),Cn(S=>S===x?"":S)},[g]),Nl=m.useCallback(()=>{const x=Tg.current;if(!x)return;const S=x.getBoundingClientRect(),_=Math.min(420,Math.max(320,S.width+160)),P=12,T=Math.max(180,S.top-P*2),U=Math.min(560,T);$$({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-_-12,S.left)),top:Math.max(P,S.top-U-P),width:_,maxHeight:U,zIndex:1e4})},[]);m.useEffect(()=>{if(!Ef)return;Nl();const x=_=>{var T,U;const P=_.target;(T=Tg.current)!=null&&T.contains(P)||(U=dS.current)!=null&&U.contains(P)||Rg(!1)},S=_=>{_.key==="Escape"&&Rg(!1)};return window.addEventListener("pointerdown",x),window.addEventListener("keydown",S),window.addEventListener("resize",Nl),window.addEventListener("scroll",Nl,!0),()=>{window.removeEventListener("pointerdown",x),window.removeEventListener("keydown",S),window.removeEventListener("resize",Nl),window.removeEventListener("scroll",Nl,!0)}},[Ef,Nl]);const Vf=m.useCallback(x=>{const S=$T(x);if(S.active&&(Oe.current=!0),S.finished&&(Oe.current=!1,ie.current=!0),bY(x)&&li(),d==="display"){R(T=>{var Y,ae;let U=T.nodePositions,X=T.nodeSizes;for(const pe of x||[]){const fe=Fp(pe==null?void 0:pe.id);if(!(!fe||!T.nodeIds.includes(fe))&&pe.type!=="select"){if(pe.type==="position"&&pe.position){const Ne=U[fe];if((Ne==null?void 0:Ne.x)===pe.position.x&&(Ne==null?void 0:Ne.y)===pe.position.y)continue;U===T.nodePositions&&(U={...T.nodePositions}),U[fe]={x:pe.position.x,y:pe.position.y};continue}if(pe.type==="dimensions"&&((Y=pe.dimensions)!=null&&Y.width)&&((ae=pe.dimensions)!=null&&ae.height)){const Ne=Ba({width:Math.round(Number(pe.dimensions.width)),height:Math.round(Number(pe.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===T.nodeSizes&&(X={...T.nodeSizes}),X[fe]=Ne}}}}if(U===T.nodePositions&&X===T.nodeSizes)return T;const J={...T,nodePositions:U,nodeSizes:X};return H.current=J,J});const P=(x||[]).filter(T=>(T==null?void 0:T.type)==="select");P.length>0&&K(T=>{const U=new Set(T);for(const J of P){const Y=Fp(J==null?void 0:J.id);Y&&(J.selected?U.add(Y):U.delete(Y))}const X=Array.from(U);return X.length===T.length&&X.every((J,Y)=>J===T[Y])?T:X});return}if(!je){const P=(x||[]).filter(T=>(T==null?void 0:T.type)==="select");P.length>0&&g(T=>cd(P,T));return}const _=(x||[]).filter(P=>{var T,U;return(P==null?void 0:P.type)==="dimensions"&&((T=P.dimensions)==null?void 0:T.width)&&((U=P.dimensions)==null?void 0:U.height)});g(P=>{const T=new Map;if(_.length>0){const J=new Map(P.map(Y=>[Y.id,Y]));for(const Y of _){const ae=J.get(Y.id),pe={width:Math.round(Number(Y.dimensions.width)),height:Math.round(Number(Y.dimensions.height))},fe=mm(ae)?mb(pe):Ba(pe,{display:!!Rn(ae==null?void 0:ae.data)});fe&&T.set(Y.id,fe)}}const U=cd(x,P),X=T.size===0?U:U.map(J=>{const Y=T.get(J.id);if(!Y)return J;const ae={...J.data,nodeSize:Y};return Rn(J.data)&&(ae.displaySize=Y),{...J,width:Y.width,height:Y.height,data:ae}});return j.current=X,X}),_.length>0&&Hr(_.map(P=>P.id))},[li,Hr,g,d,je]),Kf=m.useCallback((x=[],{finish:S=!1}={})=>{const _=S?jY([...V.current,...x]):cb(x);S&&(V.current=[]),_.length>0&&Vf(_)},[Vf]),xL=m.useCallback(x=>{const{transient:S,committed:_,finishesInteraction:P}=SY(x);if(S.length>0){Oe.current||(Oe.current=!0,Sl.current=o0.current),V.current=cb([...V.current,...S]);const T=cd(S,Sl.current);Sl.current=T,s.getState().setNodes(T)}if(P){Sl.current=[],Kf(_,{finish:!0});return}_.length>0&&Vf(_)},[Vf,Kf,s]);m.useEffect(()=>{const x=()=>{!Oe.current&&V.current.length===0||(Kf([],{finish:!0}),Sl.current=[])},S=()=>{document.visibilityState==="hidden"&&x()};return window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x),window.addEventListener("blur",x),document.addEventListener("visibilitychange",S),()=>{window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x),window.removeEventListener("blur",x),document.removeEventListener("visibilitychange",S),V.current=[],Sl.current=[]}},[Kf]);const bL=m.useCallback(x=>{if(d!=="display"){if(!je){const S=(x||[]).filter(_=>(_==null?void 0:_.type)==="select");S.length>0&&b(_=>{const P=em(S,_);return N.current=P,P});return}(x||[]).some(S=>(S==null?void 0:S.type)!=="select")&&li(),b(S=>{const _=em(x,S);return N.current=_,_})}},[li,b,d,je]),Cl=m.useCallback(()=>{const x=document.querySelector(".af-workspace-canvas .react-flow");if(x){const S=x.getBoundingClientRect();return r.screenToFlowPosition({x:S.left+S.width*.48,y:S.top+S.height*.32})}return{x:360+w.length*36,y:180+w.length*28}},[w.length,r]),qf=m.useCallback(()=>{var x,S,_;if(qt){const P=Number(((x=qt.measured)==null?void 0:x.width)||qt.width||260);return{x:Number(((S=qt.position)==null?void 0:S.x)||0)+P+140,y:Number(((_=qt.position)==null?void 0:_.y)||0)}}return Cl()},[Cl,qt]),zi=m.useCallback((x,S={})=>{if(!je)return ge("Readonly workspace"),null;if(!x)return null;const _=wv(x)||x.id,P=UT(x),T=GT(x),U=S.id||TG(_,w),X=Yu(x.inputs),J=Yu(x.outputs),Y={definitionId:_,...P?{marketplaceRef:P}:{},...x.packageId?{marketplacePackageId:x.packageId}:{},...x.version?{marketplaceVersion:x.version}:{},label:S.label||hm(x),role:"normal",body:S.body||"",...S.script||T?{script:S.script||T}:{},...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:mc,position:S.position||Cl(),data:{label:Y.label,definitionId:_,...P?{marketplaceRef:P}:{},...x.packageId?{marketplacePackageId:x.packageId}:{},...x.version?{marketplaceVersion:x.version}:{},schemaType:qT(_,x),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}},pe={...ab(ae,{...Z.current,[U]:Y},be),selected:!0};return li(),g(fe=>[...fe.map(Ne=>({...Ne,selected:!1})),pe]),S.openProperties&&Cn(U),U},[Cl,li,w,be,g,je]),kL=m.useCallback(x=>uw(x,j.current),[]),vL=m.useCallback(x=>{if(!je){ge("Readonly workspace");return}if(!uw(x,j.current)){ge("端口类型不匹配,已取消连线");return}ee(null),li(),g(S=>sw(S,x)),b(S=>{const _=S.filter(T=>!(T.target===x.target&&T.targetHandle===x.targetHandle)),P=fh({...x,markerEnd:{type:bi.ArrowClosed}},_);return N.current=P,P})},[li,b,g,je]),SL=m.useCallback((x,S)=>{if(!je)return;const _=PG(S,j.current);se.current=_?{..._,preferExisting:!!(x!=null&&x.shiftKey)}:null,ee(null)},[je]),jL=m.useCallback((x,S)=>{var He,Me,Bt,rt;if(!je)return;const _=se.current;if(se.current=null,!_||S!=null&&S.toNode)return;const P=IG(be,_),T=RG(j.current,N.current,_);if(P.length===0&&T.length===0){ge(`没有匹配 ${_.slotType} 端口的节点`);return}const X=!!(x!=null&&x.shiftKey||_.preferExisting)?T.length>0?"existing":"create":P.length>0?"create":"existing",J=((Me=(He=x==null?void 0:x.changedTouches)==null?void 0:He[0])==null?void 0:Me.clientX)??(x==null?void 0:x.clientX),Y=((rt=(Bt=x==null?void 0:x.changedTouches)==null?void 0:Bt[0])==null?void 0:rt.clientY)??(x==null?void 0:x.clientY);if(!Number.isFinite(J)||!Number.isFinite(Y))return;const ae=document.querySelector(".af-workspace-canvas .react-flow");if(!ae)return;const pe=ae.getBoundingClientRect(),fe=320,Ne=Math.max(P.length,T.length),We=Math.min(480,150+Ne*58),ze=Math.max(12,Math.min(J-pe.left,pe.width-fe-12)),Ve=Math.max(12,Math.min(Y-pe.top,pe.height-We-12));ee({left:ze,top:Ve,flowPosition:r.screenToFlowPosition({x:J,y:Y}),draft:_,candidates:P,existingCandidates:T,mode:X,query:""})},[be,r,je]),NL=m.useCallback(x=>{if(!je){ge("Readonly workspace"),ee(null);return}const S=ue.current;if(!S||!(x!=null&&x.def))return;const _=zi(x.def,{position:S.flowPosition});if(!_)return;const P=S.draft.handleType==="source"?{source:S.draft.nodeId,sourceHandle:S.draft.handleId,target:_,targetHandle:`input-${x.slotIndex}`}:{source:_,sourceHandle:`output-${x.slotIndex}`,target:S.draft.nodeId,targetHandle:S.draft.handleId};g(T=>sw(T,P)),b(T=>{const U=T.filter(J=>!(J.target===P.target&&J.targetHandle===P.targetHandle)),X=fh({...P,markerEnd:{type:bi.ArrowClosed}},U);return N.current=X,X}),ee(null)},[zi,b,je]),CL=m.useCallback(x=>{if(!je){ge("Readonly workspace"),ee(null);return}const S=x==null?void 0:x.connection;if(!S||!uw(S,j.current)){ge("端口类型不匹配,已取消连线"),ee(null);return}g(_=>sw(_,S)),b(_=>{const P=_.filter(U=>!(U.target===S.target&&U.targetHandle===S.targetHandle)),T=fh({...S,markerEnd:{type:bi.ArrowClosed}},P);return N.current=T,T}),ee(null)},[b,g,je]),w0=m.useCallback(x=>{x&&(zi(x,{position:qf()}),q(!1),et(""))},[zi,qf]),x0=m.useCallback(x=>{x&&(xu(x,qf()),q(!1),et(""))},[xu,qf]),_L=m.useCallback(x=>{var _,P,T;if(ct||In)return;const S=x==null?void 0:x.target;CC(S)||(_=S==null?void 0:S.closest)!=null&&_.call(S,"button, a, [role='button'], .react-flow__handle")||(T=(P=C.current)==null?void 0:P.focus)==null||T.call(P,{preventScroll:!0})},[ct,In]);m.useEffect(()=>{const x=S=>{var ae;if(S.defaultPrevented)return;const _=bU(S.target)||CC(S.target);if((S.metaKey||S.ctrlKey)&&S.key.toLowerCase()==="s"){S.preventDefault(),en().catch(pe=>ge(String(pe.message||pe)));return}if((S.metaKey||S.ctrlKey)&&S.key.toLowerCase()==="k"){S.preventDefault(),S.stopPropagation(),wS(pe=>!pe);return}if(zg)return;if(Fg){(S.key==="Escape"||oC(S))&&(S.preventDefault(),Pf(!1));return}const P=S.key.toLowerCase(),T=(S.metaKey||S.ctrlKey)&&P==="c",U=(S.metaKey||S.ctrlKey)&&P==="v",X=_&&T&&qY(S.target);if(_&&!X)return;const J=(S.metaKey||S.ctrlKey)&&!S.shiftKey&&P==="z",Y=(S.metaKey||S.ctrlKey)&&(S.shiftKey&&P==="z"||P==="y");if(J||Y){if(ct){S.preventDefault(),S.stopPropagation(),ge("展示页布局会自动保存");return}if(!je){S.preventDefault(),ge("Readonly workspace");return}S.preventDefault(),S.stopPropagation();const pe=J?TS():MS();ge(pe?J?"Undo canvas change":"Redo canvas change":J?"Nothing to undo":"Nothing to redo");return}if(T){if(ct)return;const pe=yo.current,fe=(j.current||[]).some(We=>We==null?void 0:We.selected)?j.current:(j.current||[]).map(We=>pe&&We.id===pe?{...We,selected:!0}:We),Ne=Wq(fe,N.current,Z.current);Ne&&(S.preventDefault(),S.stopPropagation(),B.current=Ne,YG(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(ct){S.preventDefault(),S.stopPropagation();return}if(!je){S.preventDefault(),ge("Readonly workspace");return}const pe=B.current||GG();pe&&!B.current&&(B.current=pe);const fe=Vq(pe,j.current,N.current,Z.current);fe&&(S.preventDefault(),S.stopPropagation(),Z.current=fe.instances,ne(fe.instances),g(fe.nodes),b(fe.edges),ge(`Pasted ${fe.pastedNodeIds.length} node${fe.pastedNodeIds.length>1?"s":""}`));return}if(oC(S)&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),Pf(!0);return}if(P==="g"&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),l0();return}if(S.key==="a"||S.key==="A"){if(S.metaKey||S.ctrlKey){S.preventDefault(),ct?K(H.current.nodeIds):(g(pe=>pe.map(fe=>({...fe,selected:!0}))),b(pe=>pe.map(fe=>({...fe,selected:!1}))));return}if(S.altKey)return;if(ct){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(),xS("select");return}if((S.key==="h"||S.key==="H")&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),xS("pan");return}(S.key==="f"||S.key==="F")&&!S.metaKey&&!S.ctrlKey&&!S.altKey&&(S.preventDefault(),a0())};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[l0,ct,zg,a0,MS,en,Fg,b,g,TS,je]);const EL=m.useCallback(x=>{fl(S=>{const _=new Set(S);return _.has(x)?_.delete(x):_.add(x),_})},[]),AL=m.useCallback((x,S)=>{x.dataTransfer.effectAllowed="copy",x.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:S.path,name:S.name,type:S.type})),x.dataTransfer.setData("text/plain",S.path)},[]),PL=m.useCallback((x,S)=>{x.dataTransfer.effectAllowed="move",x.dataTransfer.setData("application/agentflow-node",S.id),x.dataTransfer.setData("text/plain",S.id)},[]),Uf=m.useCallback(async(x,S)=>{const _=String((x==null?void 0:x.name)||(x==null?void 0:x.path)||"").toLowerCase(),P=_.split(".").pop(),T=["jsx","tsx","js"].includes(P)?"display_react_app":P==="html"?"display_html":P==="csv"||P==="tsv"||P==="json"&&/\b(table|data|rows|report)\b/i.test(_)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(P)?"display_image":"display_markdown",U=be.find(fe=>fe.id===T);if(!U){ge("展示节点不可用");return}const X=T==="display_image";let J=String(x.path||"");if(!X){const fe=$r(a);fe.set("path",x.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=T==="display_image"?"src":"content",ae=Yu(U.inputs).map(fe=>fe.name===Y?{...fe,default:J,value:J}:fe),pe=Yu(U.outputs).map(fe=>fe.name===Y?{...fe,default:J,value:J}:fe);zi(U,{label:x.name||"Display",body:J,inputs:ae,outputs:pe,position:S}),ge(`已创建展示:${x.path}`)},[zi,a,be]),IL=m.useCallback(x=>{if(!je){ge("Readonly workspace");return}Uf(x,Cl()).catch(S=>ge(String(S.message||S)))},[Uf,Cl,je]),RL=m.useCallback(x=>{if(!je){x.preventDefault(),ge("Readonly workspace");return}const S=x.dataTransfer.getData("application/x-agentflow-workspace-file");if(S){x.preventDefault();let X;try{X=JSON.parse(S)}catch{return}if(!(X!=null&&X.path))return;const J=r.screenToFlowPosition({x:x.clientX,y:x.clientY});Uf(X,J).catch(Y=>ge(String(Y.message||Y)));return}const _=x.dataTransfer.getData("application/agentflow-snippet");if(_){const X=Re.find(Y=>`${Y.id}@${Y.version}`===_);if(!X)return;x.preventDefault();const J=r.screenToFlowPosition({x:x.clientX,y:x.clientY});xu(X,J);return}const P=x.dataTransfer.getData("application/agentflow-node");if(!P)return;const T=be.find(X=>X.id===P);if(!T)return;x.preventDefault();const U=r.screenToFlowPosition({x:x.clientX,y:x.clientY});zi(T,{position:U})},[Uf,zi,Re,xu,be,r,je]),TL=m.useCallback(x=>{if(!je)return;const S=Array.from(x.dataTransfer.types||[]);!S.includes("application/x-agentflow-workspace-file")&&!S.includes("application/agentflow-node")&&!S.includes("application/agentflow-snippet")||(x.preventDefault(),x.dataTransfer.dropEffect=S.includes("application/agentflow-node")||S.includes("application/agentflow-snippet")?"move":"copy")},[je]),ML=m.useCallback(async(x="")=>{if(!je){ge("Readonly workspace");return}const S=window.prompt("新文件名",x?`${x}/notes.md`:"notes.md");if(!S)return;const _=x&&!S.includes("/")?`${x}/${S}`:S;try{const P=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:_,content:""})}),T=await P.json();if(!P.ok)throw new Error(T.error||"创建文件失败");await Pn(),fl(U=>{const X=new Set(U);for(const J of zp(T.path||_))X.delete(J);return X}),ge(`已创建 ${T.path}`)}catch(P){ge(String(P.message||P))}},[a,Pn,je]),$L=m.useCallback(async(x="")=>{if(!je){ge("Readonly workspace");return}const S=window.prompt("新文件夹名",x?`${x}/docs`:"docs");if(!S)return;const _=x&&!S.includes("/")?`${x}/${S}`:S;try{const P=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:_})}),T=await P.json();if(!P.ok)throw new Error(T.error||"创建文件夹失败");await Pn(),fl(U=>{const X=new Set(U);for(const J of zp(T.path||_))X.delete(J);return T.path&&X.delete(T.path),X}),ge(`已创建 ${T.path}`)}catch(P){ge(String(P.message||P))}},[a,Pn,je]),LL=m.useCallback(async x=>{if(!je){ge("Readonly workspace");return}if(!(!(x!=null&&x.path)||!window.confirm(`删除 ${x.path}?`)))try{const S=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:x.path})}),_=await S.json();if(!S.ok)throw new Error(_.error||"删除失败");ge(`已删除 ${_.path}`),await Pn()}catch(S){ge(String(S.message||S))}},[a,Pn,je]),OL=m.useCallback(x=>{if(!(x!=null&&x.path)||x.type==="directory")return;const S=Gd(x.path,a,{download:!0});if(!S)return;const _=document.createElement("a");_.href=S,_.download=x.name||x.path.split("/").pop()||"download",_.rel="noopener",document.body.appendChild(_),_.click(),_.remove()},[a]),Yf=m.useCallback(async()=>{if(!je){ge("Readonly workspace");return}const x=pa.trim(),S=Wr,_=Os.find(X=>X.id===S)||null;if(!x||ns||(_==null?void 0:_.status)==="running"||(_==null?void 0:_.status)==="stopping")return;const P=_?Array.isArray(_.messages)?_.messages:[]:ha,T=$l(w,k,Z.current);Mg(""),pS(!0),gl(!0),yl(null);const U={role:"user",text:x,at:Date.now()};_?Un(X=>X.map(J=>J.id===S?{...J,status:"running",messages:[...Array.isArray(J.messages)?J.messages:[],U].slice(-180)}:J)):(ks("workspace"),ml(X=>[...X,U]));try{await en(w,k);const X=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,prompt:x,outputKind:"markdown",workspaceGraph:T,allowFlowYaml:!1,model:Li,selectedSkills:Ls,selectedNodeIds:Bf,messages:P})}),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()};_?Un(pe=>pe.map(fe=>fe.id===S?{...fe,status:"done",messages:[...Array.isArray(fe.messages)?fe.messages:[],ae].slice(-180)}:fe)):ml(pe=>[...pe,ae]),await vs(),ge("AI 生成完成")}catch(X){const J=String(X.message||X),Y={role:"assistant",text:J,error:!0,at:Date.now()};_?Un(ae=>ae.map(pe=>pe.id===S?{...pe,status:"failed",messages:[...Array.isArray(pe.messages)?pe.messages:[],Y].slice(-180)}:pe)):ml(ae=>[...ae,Y]),ge(J)}finally{pS(!1)}},[Wr,ha,Li,Os,ns,pa,k,a,vs,w,en,Bf,Ls,je]),ar=Os.find(x=>x.id===Wr)||null,ey=ar?Array.isArray(ar.messages)?ar.messages:[]:ha,_l=ar&&(ar.status==="running"||ar.status==="stopping")||ns,DL=PJ(ey,_l),ty=IJ(ey),b0=ar?ar.status==="stopping"?`${ar.label} stopping`:ar.status==="running"?`${ar.label} running`:ar.status==="paused"?`${ar.label} paused`:ar.status==="failed"?`${ar.label} failed`:`${ar.label} done`:ns?"Workspace agent running":ha.length>0?"Workspace conversation":"Ready";m.useEffect(()=>{Wr!=="workspace"&&(Os.some(x=>x.id===Wr)||ks(ya()))},[Wr,Os,ya]),m.useEffect(()=>{if(!ru)return;const x=window.requestAnimationFrame(()=>{var _,P;const S=hS.current;S&&(S.scrollTop=S.scrollHeight),(P=(_=$g.current)==null?void 0:_.scrollIntoView)==null||P.call(_,{block:"nearest",inline:"nearest"})});return()=>window.cancelAnimationFrame(x)},[ey.length,Wr,b0,ty.length,ru]);const FL=String(a.flowId||"").trim()||"Workspace",xo=(Nt==null?void 0:Nt.mode)==="single-node",k0=xo&&wu.find(x=>{var S;return x.id===Nt.sourceNodeId||((S=Nt.nodeIds)==null?void 0:S.includes(x.id))})||null,zL=xo&&k0?[k0]:wu;return i.jsxs("div",{className:"af-workspace-page",children:[l?null:i.jsxs("header",{className:"af-pipeline-top af-workspace-top",children:[i.jsxs("div",{className:"af-pipeline-top-left",children:[i.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>n(a.adminOwnerId?"/admin/usage":"/projects"),"aria-label":"返回",children:i.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),i.jsxs("div",{className:"af-pipeline-brand",title:a.flowId?`${a.flowId} · ${Dv}`:Dv||"PROJECT",children:[i.jsx("span",{className:"af-pipeline-brand-name",children:FL}),i.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",OY,"-STABLE"]})]}),Sf?i.jsxs("span",{className:"af-workspace-admin-review-badge",title:"管理员审阅模式不会修改、运行或加入该 Workspace",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),"只读查看 · ",Sf.ownerUsername||Sf.ownerUserId]}):null,i.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[i.jsx("button",{type:"button",className:d==="workspace"?"af-view-switch__active":"",onClick:()=>Zg("workspace"),children:"Workspace"}),i.jsx("button",{type:"button",className:d==="display"?"af-view-switch__active":"",onClick:()=>Zg("display"),children:"Display"}),i.jsx("button",{type:"button",className:d==="workflow"?"af-view-switch__active":"",onClick:()=>Zg("workflow"),children:"Workflow"})]})]}),i.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[i.jsx("span",{className:`af-workspace-sync-light is-${NS}`,title:`${IS} · ${CS}`,role:"status","aria-label":`${IS}:${CS}`,children:i.jsx("span",{className:"af-workspace-sync-light__dot","aria-hidden":!0})}),An?i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:()=>{var x;(x=An.conflictItems)!=null&&x.length?da(!0):g0()},title:["先下载当前本地草稿,再载入远端最新版本",...An.conflictPaths||[]].join(`
|
|
265
|
-
`),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"difference"}),"处理冲突"]}):null,ct?i.jsxs(i.Fragment,{children:[i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!je||pn||!(jt!=null&&jt.absoluteUrl)&&I.nodeIds.length===0,onClick:()=>{er(""),Qt(!0)},title:jt!=null&&jt.absoluteUrl?"查看展示链接":I.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:pn?"hourglass_empty":"ios_share"}),pn?"生成中":jt!=null&&jt.absoluteUrl?"展示链接":"生成链接"]}),i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!je||vl.length===0,onClick:()=>Pe(!0),title:vl.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:!je||!!(cn!=null&&cn.role&&cn.role!=="owner"),onClick:lL,title:cn!=null&&cn.role&&cn.role!=="owner"?"仅 Workspace 所有者可以创建邀请":"邀请其他成员协作编辑",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"协作分享"]}),Sf?null:i.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:fL,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:!PS,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:!PS&&!uu,onClick:()=>v(!0),"aria-label":uu?"退出共享 Workspace":e("flow:topbar.deletePipeline"),title:uu?"退出共享 Workspace":e("flow:topbar.deletePipeline"),children:i.jsx("span",{className:"material-symbols-outlined",children:uu?"logout":"delete_forever"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Pf(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:i.jsx("span",{className:"material-symbols-outlined",children:"help"})}),i.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(ru?" af-composer-topbar-btn--active":"")+(ns?" af-composer-topbar-btn--running":""),disabled:!je||ct||In,onClick:()=>{yl(null),gl(x=>(x||ks(ya()),!x))},children:"AI"}),i.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!je,onClick:()=>en().catch(x=>ge(String(x.message||x))),children:"Save"})]})]}),ys?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:ys}),i.jsx("button",{type:"button",onClick:()=>ws(""),"aria-label":"关闭发布提示",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,i.jsxs("div",{className:"af-workspace-body"+(!ct&&!In&&(ru||at)?" af-workspace-body--drawer":"")+(!ct&&!In&&iu?" af-workspace-body--sidebar-collapsed":"")+(ct?" af-workspace-body--display-mode":"")+(In?" af-workspace-body--workflow-mode":""),children:[!ct&&!In&&iu?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:()=>Af(!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:()=>Af(!1),"aria-label":"展开侧边栏",title:(Rr==null?void 0:Rr.username)||(Rr==null?void 0:Rr.userId)||"展开侧边栏",children:sL})]})}):null,!ct&&!In?i.jsxs("aside",{ref:Cg,className:"af-workspace-sidebar"+(S$?" af-workspace-sidebar--resizing":""),"aria-hidden":iu,style:{"--af-work-files-pane-height":`${Math.round(_g)}px`},children:[i.jsxs("section",{className:"af-workspace-files-section",children:[i.jsxs("div",{className:"af-workspace-sidebar-head",children:[i.jsx("h2",{children:"Files"}),i.jsxs("div",{className:"af-workspace-sidebar-actions",children:[i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Af(!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:()=>ML(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||qv,onClick:()=>YS(Fi),"aria-label":"上传文件",title:Fi?`上传到 ${Fi}`:"上传文件",children:i.jsx("span",{className:"material-symbols-outlined",children:qv?"hourglass_top":"upload_file"})}),i.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void Pn(),"aria-label":"刷新文件",title:"刷新文件",children:i.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),i.jsx("input",{ref:Yv,type:"file",multiple:!0,className:"af-visually-hidden",onChange:Y$})]})]}),i.jsx("input",{className:"af-workspace-search",value:vg,onChange:x=>k$(x.target.value),placeholder:"搜索文件..."}),i.jsx("div",{className:"af-workspace-files-scroll",onClick:nL,children:i.jsx(dM,{items:tL,onOpen:IL,selectedPath:Sg,collapsedDirs:v$,onToggleDir:EL,onSelect:x=>jg(x.path||""),onFileDragStart:AL,onDelete:LL,onDownload:OL})})]}),i.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:R$,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:ln==="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:Vt,onChange:x=>Ot(x.target.value),placeholder:ln==="flows"?"搜索流程片段...":"搜索节点...","aria-label":ln==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[i.jsxs("button",{type:"button",role:"tab","aria-selected":ln==="nodes",className:"af-palette-tab"+(ln==="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":ln==="flows",className:"af-palette-tab"+(ln==="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:ln==="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:oL,disabled:tr.length<2,title:tr.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:["已选 ",tr.length," 节点 / ",Hf.length," 连线"]})]})}),_t?i.jsx("p",{className:"af-err af-palette-list-err",children:_t}):null,Ze?i.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):p0.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:p0.map(x=>{const S=`${x.id}@${x.version}`,_=x.displayName||x.name||x.id,P=x.description||`${x.nodeCount||0} 个节点,${x.edgeCount||0} 条连线`;return i.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",draggable:!0,onDragStart:T=>{T.dataTransfer.effectAllowed="move",T.dataTransfer.setData("application/agentflow-snippet",S),T.dataTransfer.setData("text/plain",S)},onClick:()=>xu(x),title:P,children:[i.jsxs("span",{className:"af-palette-card-head",children:[i.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),i.jsxs("span",{className:"af-palette-card-main",children:[i.jsx("span",{className:"af-palette-card-label",children:_}),i.jsxs("span",{className:"af-palette-card-id",children:[x.id,"@",x.version]})]})]}),P?i.jsx("span",{className:"af-palette-card-desc",children:P}):null,i.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[i.jsxs("span",{children:[x.nodeCount||0," nodes"]}),i.jsxs("span",{children:[x.edgeCount||0," edges"]})]})]},S)})})]}):i.jsx("p",{className:"af-palette-empty",children:Vt.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):i.jsxs(i.Fragment,{children:[Dl.map(x=>{var S;return(S=Gg[x])!=null&&S.length?i.jsxs("section",{className:`af-palette-section af-flow-palette-section--${x}`,children:[i.jsx("h3",{className:"af-palette-cat",children:x}),i.jsx("div",{className:"af-palette-cards",children:Gg[x].map(_=>{const P=TC(_.inputs,"input"),T=TC(_.outputs,"output"),U=hb(_),X=qu(_);return i.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:J=>PL(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:IC(x)})}),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:[P.list.length," IN"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[P.shown.map((J,Y)=>i.jsxs("span",{className:"af-palette-card-port",title:RC("input",J,Y),children:[i.jsx("span",{className:"af-palette-card-port-dot",style:{background:Mn(J==null?void 0:J.type)}}),i.jsx("span",{className:"af-palette-card-port-name",children:Op(J,Y)})]},`in-${Y}`)),P.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",P.hidden]}):null]})]}),i.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[i.jsxs("span",{className:"af-palette-card-port-count",children:[T.list.length," OUT"]}),i.jsxs("span",{className:"af-palette-card-port-list",children:[T.shown.map((J,Y)=>i.jsxs("span",{className:"af-palette-card-port",title:RC("output",J,Y),children:[i.jsx("span",{className:"af-palette-card-port-name",children:Op(J,Y)}),i.jsx("span",{className:"af-palette-card-port-dot",style:{background:Mn(J==null?void 0:J.type)}})]},`out-${Y}`)),T.hidden>0?i.jsxs("span",{className:"af-palette-card-port-more",children:["+",T.hidden]}):null]})]})]})]},_.id)})})]},x):null}),be.length>0&&Vt.trim()&&Dl.every(x=>{var S;return!((S=Gg[x])!=null&&S.length)})?i.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}):null,In?i.jsx(UJ,{flowParams:a,tapdId:or,setTapdId:A$,snapshot:un,loading:P$,error:I$,actionRunning:Eg,actionOutput:Ag,pendingConfirm:bs,conflict:tu,reviewPublishing:Pg,onRefresh:()=>fu(or),onRunDryRun:B$,onConfirmAction:H$,onRetryConflict:W$,onPublishReview:V$}):i.jsxs("main",{ref:C,className:"af-workspace-canvas",tabIndex:-1,onPointerDownCapture:_L,children:[i.jsx(bR,{className:"af-flow-canvas af-workspace-flow"+(Bg==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(ct?" af-workspace-flow--display-mode":""),nodes:zf,edges:Z$,nodeTypes:vJ,onNodesChange:xL,onEdgesChange:bL,onConnect:ct?void 0:vL,onConnectStart:ct?void 0:SL,onConnectEnd:ct?void 0:jL,isValidConnection:ct?void 0:kL,onNodeClick:(x,S)=>{var _;if(ct){K([Fp(S.id)]);return}if((_=S==null?void 0:S.data)!=null&&_.isWorkspaceGroup){Cn("");return}if(x.detail>=3){gl(!1),g(P=>P.map(T=>({...T,selected:T.id===S.id}))),b(P=>P.map(T=>({...T,selected:!1}))),Cn(S.id);return}Gt&&Cn(S.id)},onNodeDoubleClick:x=>{x.preventDefault()},onPaneClick:()=>{ct?K([]):Cn("")},onDrop:ct?void 0:RL,onDragOver:ct?void 0:TL,nodesDraggable:je,nodesConnectable:ct?!1:je,edgesReconnectable:ct?!1:je,onlyRenderVisibleElements:zf.length>=80,deleteKeyCode:ct?null:je?["Backspace","Delete"]:null,selectionOnDrag:Bg==="select",panOnDrag:Bg==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:i.jsx(vR,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!ct&&G?(()=>{var J;const x=String(G.query||"").trim().toLowerCase(),S=G.mode==="create"?"create":"existing",_=Array.isArray(G.candidates)?G.candidates:[],P=Array.isArray(G.existingCandidates)?G.existingCandidates:[],T=x?_.filter(Y=>{var ae,pe,fe;return[(ae=Y.def)==null?void 0:ae.id,Y.displayLabel,Y.description,(pe=Y.slot)==null?void 0:pe.name,(fe=Y.slot)==null?void 0:fe.type].filter(Boolean).some(Ne=>String(Ne).toLowerCase().includes(x))}):_,U=x?P.filter(Y=>{var ae,pe;return[Y.nodeId,Y.nodeLabel,Y.definitionId,(ae=Y.slot)==null?void 0:ae.name,(pe=Y.slot)==null?void 0:pe.type].filter(Boolean).some(fe=>String(fe).toLowerCase().includes(x))}):P,X=G.draft.handleType==="source"?"IN":"OUT";return i.jsxs("div",{className:"af-connect-node-menu",style:{left:G.left,top:G.top},role:"dialog","aria-label":"选择匹配节点",children:[i.jsxs("div",{className:"af-connect-node-menu__head",children:[i.jsxs("div",{className:"af-connect-node-menu__title",children:[i.jsx("span",{className:"af-connect-node-menu__dot",style:{background:Mn((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:P.length===0,onClick:()=>ee(Y=>Y&&{...Y,mode:"existing",query:""}),children:["连接已有 ",i.jsx("span",{children:P.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"?T.map(Y=>{var fe,Ne;const ae=Y.displayLabel||((fe=Y.def)==null?void 0:fe.id),pe=Op(Y.slot,Y.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>NL(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:Mn((Ne=Y.slot)==null?void 0:Ne.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:pe})]})]},`${Y.def.id}-${Y.slotIndex}`)}):U.map(Y=>{var fe;const ae=Y.nodeLabel||Y.nodeId,pe=Op(Y.slot,Y.slotIndex);return i.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>CL(Y),title:`${Y.definitionId||Y.nodeId} · ${pe}`,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:Mn((fe=Y.slot)==null?void 0:fe.type)},"aria-hidden":!0}),i.jsx("span",{className:"af-connect-node-menu__port-name",children:pe}),Y.occupied?i.jsx("span",{className:"af-connect-node-menu__port-badge",children:"替换"}):null]})]},`${Y.nodeId}-${Y.handleId}`)}),(S==="create"?T.length:U.length)===0?i.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!ct&&!In&&!L$?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:()=>Lg(!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:tr.length===0?i.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):tr.map(x=>{var T,U;const S=String(((T=x.data)==null?void 0:T.label)??x.id),_=(U=x.data)!=null&&U.definitionId?String(x.data.definitionId):"",P=_&&_!==S?`${S} · ${x.id} · ${_}`:`${S} · ${x.id}`;return i.jsxs("div",{className:"af-composer-node-chip",title:P,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:()=>wL(x.id),"aria-label":`取消选择 ${x.id}`,children:i.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},x.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:pa,rows:2,onChange:x=>Mg(x.target.value),onKeyDown:x=>{(x.metaKey||x.ctrlKey)&&x.key==="Enter"&&(x.preventDefault(),Yf())},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:Tg,type:"button",className:"af-composer-skills-button"+(Ls.length>0?" af-composer-skills-button--active":""),disabled:ns||!je,"aria-haspopup":"listbox","aria-expanded":Ef,onClick:()=>Rg(x=>!x),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),i.jsx("span",{children:Ls.length>0?`Skills ${Ls.length}`:"Skills"})]}),Ef&&!ns?ur.createPortal(i.jsx("div",{ref:dS,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:M$,children:$s.length===0?i.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):i.jsxs(i.Fragment,{children:[jl.groups.map(x=>{const S=Zo(x,$s),_=TF(x,Jg,$s),P=T$.has(x.id);return i.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(P?" af-composer-skill-group--collapsed":""),children:[i.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[i.jsxs("label",{className:"af-composer-skill-group-check",children:[i.jsx("input",{type:"checkbox",checked:_==="all",disabled:S.length===0,onChange:T=>{const U=T.target.checked;eu(X=>U?IF(X,S):RF(X,S))}}),i.jsxs("span",{className:"af-composer-skill-group-title-main",children:[i.jsx("span",{children:x.name}),x.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":P?`展开 ${x.name}`:`收起 ${x.name}`,onClick:()=>{uS(T=>{const U=new Set(T);return U.has(x.id)?U.delete(x.id):U.add(x.id),U})},children:[i.jsx("span",{children:x.skills.length}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:P?"expand_more":"expand_less"})]})]}),P?null:i.jsx("div",{className:"af-composer-skill-group-items",children:x.skills.map(T=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:Jg.has(T.key),onChange:U=>{const X=U.target.checked;eu(J=>X?J.includes(T.key)?J:[...J,T.key]:J.filter(Y=>Y!==T.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:T.name}),T.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:T.description}):null]})]},`${x.id}:${T.key}`))})]},x.id)}),jl.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:jl.ungrouped.length})]}),jl.ungrouped.map(x=>i.jsxs("label",{className:"af-composer-skill-option",children:[i.jsx("input",{type:"checkbox",checked:Jg.has(x.key),onChange:S=>{const _=S.target.checked;eu(P=>_?P.includes(x.key)?P:[...P,x.key]:P.filter(T=>T!==x.key))}}),i.jsxs("span",{className:"af-composer-skill-option-main",children:[i.jsx("span",{className:"af-composer-skill-option-title",children:x.name}),x.description?i.jsx("span",{className:"af-composer-skill-option-desc",children:x.description}):null]})]},`ungrouped:${x.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:x=>N$(x.target.value),"aria-label":"模型",children:[i.jsx("option",{value:"",children:"默认模型"}),rL.map(x=>i.jsx("option",{value:x.value,children:x.label},x.value))]})}),i.jsx("button",{type:"button",className:"af-composer-send"+(pa.trim()&&!ns?" af-composer-send--active":"")+(ns?" af-composer-send--stop":""),disabled:ns||!pa.trim()||!je,"aria-label":ns?"Running":"Send",onClick:()=>void Yf(),children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ns?"sync":"arrow_upward"})})]})]})]})}):!ct&&!In?i.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>Lg(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})}):null]}),!ct&&!In&&ru?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:()=>gl(!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"+(Wr==="workspace"?" af-composer-session-tab--active":""),ref:Wr==="workspace"?$g:null,onClick:()=>ks("workspace"),children:i.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),Os.map(x=>i.jsxs("div",{role:"tab",tabIndex:0,ref:Wr===x.id?$g:null,className:"af-composer-session-tab"+(Wr===x.id?" af-composer-session-tab--active":"")+(x.status==="running"||x.status==="stopping"?" af-composer-session-tab--running":""),onClick:()=>ks(x.id),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),ks(x.id))},title:x.runNodeId||x.label,children:[i.jsx("span",{className:"af-composer-session-label",children:x.label}),i.jsx("button",{type:"button",className:"af-composer-session-close",onClick:S=>{S.preventDefault(),S.stopPropagation(),q$(x.id)},"aria-label":`关闭 ${x.label}`,title:"关闭 tab",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]},x.id))]}),i.jsx("div",{className:"af-composer-sidebar-status"+(_l?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:b0}),i.jsxs("div",{className:"af-composer-sidebar-thread",ref:hS,children:[i.jsx(VC,{messages:DL,running:_l,showRunningIndicator:!ar}),ty.length>0?i.jsxs("details",{className:"af-composer-sidebar-log-details",..._l?{open:!0}:{},children:[i.jsx("summary",{children:"执行日志"}),i.jsx(VC,{messages:ty,running:!1,showRunningIndicator:!1})]}):null]}),i.jsxs("div",{className:"af-composer-sidebar-input",children:[i.jsx("textarea",{className:"af-composer-sidebar-textarea",value:pa,rows:3,onChange:x=>Mg(x.target.value),onKeyDown:x=>{(x.metaKey||x.ctrlKey)&&x.key==="Enter"&&(x.preventDefault(),Yf())},placeholder:ar?"继续追问、总结或要求调整这次结果":"继续描述你想让 AI 在 workspace 中做什么",disabled:!je||_l}),i.jsx("button",{type:"button",className:"af-composer-sidebar-send",disabled:!je||_l||!pa.trim(),onClick:()=>void Yf(),"aria-label":"发送 AI 对话",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]})]})}):!ct&&!In&&at&&qt?i.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:i.jsx(HU,{draft:at,setDraft:xs,definitionId:String(((v0=qt.data)==null?void 0:v0.definitionId)||qt.id),systemPromptReadonly:String(((S0=qt.data)==null?void 0:S0.description)||""),modelLists:fa,disabled:!je,onIdBlur:()=>qg(!0),onClose:()=>Cn(""),onPublishToMarketplace:K$,error:m$,ioSlots:{inputs:Array.isArray(at==null?void 0:at.inputs)?at.inputs:[],outputs:Array.isArray(at==null?void 0:at.outputs)?at.outputs:[]}})}):null,!ct&&!In&&su?ur.createPortal(i.jsx("div",{className:"af-workspace-run-logs-overlay",role:"presentation",onMouseDown:()=>yl(null),children:i.jsx("aside",{className:"af-workspace-run-logs-drawer","aria-label":"Workspace Run Logs",onMouseDown:x=>x.stopPropagation(),children:i.jsx(_U,{flowParams:a,scheduleNodeId:su.scheduleNodeId,runNodeId:su.runNodeId,lastRunId:su.lastRunId,label:su.label,onClose:()=>yl(null)})})}),document.body):null,i.jsx(SU,{open:Fg,onClose:()=>Pf(!1)}),i.jsx(NU,{open:zg,onClose:()=>wS(!1),onJump:Yg,nodes:eL}),i.jsx(WU,{open:p,onClose:()=>h(!1),flowId:a.flowId||"",flowSource:cu,onArchived:()=>{h(!1),n("/projects?tab=archived")}}),i.jsx(VU,{open:y&&!!a.flowId,onClose:()=>v(!1),flowId:a.flowId||"",flowSource:cu,flowArchived:!!a.archived,workspaceId:a.workspaceId||"",leaveShared:uu,onDeleted:async()=>{v(!1),n("/projects")}}),b$&&An?ur.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"}),"解决 ",((j0=An.conflictItems)==null?void 0:j0.length)||0," 处字段冲突"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>da(!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:()=>dl(Object.fromEntries((An.conflictItems||[]).map((x,S)=>[String(S),{mode:"local",manual:Mu(x)}]))),children:"全部保留我的"}),i.jsx("button",{type:"button",onClick:()=>dl(Object.fromEntries((An.conflictItems||[]).map((x,S)=>[String(S),{mode:"remote",manual:Mu(x)}]))),children:"全部使用远端"})]})]}),(An.conflictItems||[]).map((x,S)=>{const _=kg[String(S)]||{mode:"local",manual:Mu(x)};return i.jsxs("section",{className:"af-workspace-conflict-item",children:[i.jsx("code",{className:"af-workspace-conflict-path",children:x.path}),i.jsx("div",{className:"af-workspace-conflict-options",children:[["local","保留我的"],["remote","使用远端"],["manual","手动编辑"]].map(([P,T])=>i.jsx("button",{type:"button",className:_.mode===P?"is-active":"",onClick:()=>dl(U=>({...U,[String(S)]:{..._,mode:P}})),children:T},P))}),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:ZC(x,"incoming")})]}),i.jsxs("div",{className:_.mode==="remote"?"is-selected":"",children:[i.jsx("span",{children:"远端修改"}),i.jsx("pre",{children:ZC(x,"current")})]})]}),_.mode==="manual"?i.jsxs("label",{className:"af-workspace-conflict-manual",children:[i.jsx("span",{children:"最终值(JSON)"}),i.jsx("textarea",{value:_.manual,onChange:P=>dl(T=>({...T,[String(S)]:{..._,manual:P.target.value}})),rows:5})]}):null]},`${x.path||"conflict"}-${S}`)}),Kv?i.jsx("div",{className:"af-flow-snippet-error",children:Kv}):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:jf,onClick:()=>void g0(),children:"备份并载入远端"}),i.jsx("span",{className:"af-workspace-conflict-foot__spacer"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:jf,onClick:()=>da(!1),children:"稍后处理"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:jf||!(An.conflictItems||[]).length,onClick:()=>void uL(),children:jf?"保存中...":"应用选择并保存"})]})]})}),document.body):null,jn?ur.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:()=>br(!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:xn.name,onChange:x=>{const S=x.target.value;Qn(_=>({..._,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:xn.id,onChange:x=>Qn(S=>({...S,id:x.target.value})),placeholder:"content-cleanup-snippet"})]}),i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"说明"}),i.jsx("textarea",{value:xn.description,onChange:x=>Qn(S=>({...S,description:x.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),i.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",tr.length," 个节点和 ",Hf.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:()=>br(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:qn||!xn.name.trim(),onClick:()=>void aL(),children:qn?"发布中...":"发布"})]})]})}),document.body):null,r0?i.jsx(uJ,{node:r0,onClose:()=>Bn("")}):null,sr?ur.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":xo?"新建分享":"发布展示页",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"}),xo?"新建分享":"发布展示页"]}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Ir(!1),"aria-label":"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.jsxs("div",{className:"af-flow-snippet-modal__body",children:[i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"标题"}),i.jsx("input",{type:"text",value:Nt.title,onChange:x=>le(S=>({...S,title:x.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),xo?null:i.jsxs("label",{className:"af-flow-snippet-field",children:[i.jsx("span",{children:"布局"}),i.jsxs("select",{className:"af-display-share-select",value:Nt.layout,onChange:x=>le(S=>({...S,layout:x.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:DC(Nt),onChange:x=>{const S=x.target.value;le(_=>({..._,permanent:S==="permanent",expiresInDays:S==="permanent"?_.expiresInDays||30:Number(S)}))},children:dw.map(x=>i.jsx("option",{value:x.value,children:x.label},x.value))})]}),i.jsxs("div",{className:"af-display-share-node-list",role:"group","aria-label":xo?"分享内容":"选择展示节点",children:[xo?i.jsx("span",{className:"af-display-share-node-list__label",children:"分享内容"}):null,zL.map(x=>{var _;const S=Array.isArray(Nt.nodeIds)&&Nt.nodeIds.includes(x.id);return i.jsxs("label",{className:"af-display-share-node-row",children:[i.jsx("input",{type:"checkbox",checked:S,disabled:xo,onChange:()=>dL(x.id)}),i.jsxs("span",{className:"af-display-share-node-row__main",children:[i.jsx("strong",{children:((_=x.data)==null?void 0:_.label)||x.id}),i.jsxs("small",{children:[Rn(x.data)," · ",x.id]})]})]},x.id)})]}),jt!=null&&jt.absoluteUrl?i.jsxs("div",{className:"af-display-share-result",children:[i.jsx("input",{type:"text",readOnly:!0,value:jt.absoluteUrl,onFocus:x=>x.target.select()}),i.jsx("button",{type:"button",onClick:()=>window.open(jt.absoluteUrl,"_blank","noopener,noreferrer"),children:"打开"}),i.jsx("button",{type:"button",onClick:()=>void y0(),children:rn==="copied"?"已复制":rn==="failed"?"复制失败":"复制"})]}):null,kr?i.jsx("div",{className:"af-flow-snippet-error",children:kr}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Ir(!1),children:"取消"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:pn||!Array.isArray(Nt.nodeIds)||Nt.nodeIds.length===0,onClick:()=>void pL(),children:pn?"生成中...":"生成链接"})]})]})}),document.body):null,zt?ur.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:()=>{er(""),Qt(!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:[jt!=null&&jt.absoluteUrl?i.jsxs("div",{className:"af-display-link-modal__url",children:[i.jsx("input",{type:"text",readOnly:!0,value:jt.absoluteUrl,onFocus:x=>x.target.select(),autoFocus:!0}),i.jsxs("button",{type:"button",onClick:()=>window.open(jt.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 y0(),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:rn==="copied"?"check":"content_copy"}),rn==="copied"?"已复制":rn==="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:DC(Nt),onChange:x=>{const S=x.target.value;le(_=>({..._,permanent:S==="permanent",expiresInDays:S==="permanent"?_.expiresInDays||30:Number(S)}))},children:dw.map(x=>i.jsx("option",{value:x.value,children:x.label},x.value))})]}),kr?i.jsx("div",{className:"af-flow-snippet-error",children:kr}):null]}),i.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>{er(""),Qt(!1)},children:"关闭"}),i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:pn||I.nodeIds.length===0,onClick:()=>void hL(),children:pn?"生成中...":jt!=null&&jt.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,x$?ur.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:()=>xg(!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:Xc,onChange:x=>Bv(x.target.value),onKeyDown:x=>{x.key==="Enter"&&Xc.trim()&&!bg&&(x.preventDefault(),m0())},placeholder:"输入用户名",autoFocus:!0}),i.jsx("button",{type:"button",disabled:bg||!Xc.trim(),onClick:()=>void m0(),children:bg?"添加中...":"添加成员"})]}),zv?i.jsx("div",{className:"af-flow-snippet-error",children:zv}):null,i.jsx("div",{className:"af-workspace-member-list",children:((cn==null?void 0:cn.members)||[]).map(x=>{const S=x.userId===(cn==null?void 0:cn.ownerId)||x.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:x.username||x.userId}),i.jsx("small",{children:S?"所有者":x.role==="viewer"?"只读成员":"编辑成员"})]}),S?null:i.jsx("button",{type:"button",disabled:Hv===x.userId,onClick:()=>void cL(x),children:Hv===x.userId?"移除中...":"取消分享"})]},x.userId)})})]}),i.jsx("div",{className:"af-flow-snippet-modal__foot",children:i.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>xg(!1),children:"完成"})})]})}),document.body):null,ht?ur.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:()=>sn(!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:Kt.length?`${Kt.length} 个分享`:"暂无分享"}),i.jsxs("button",{type:"button",onClick:()=>void Bs(),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&&Kt.length===0?i.jsx("div",{className:"af-display-link-modal__empty",children:"还没有创建过展示分享"}):null,i.jsx("div",{className:"af-display-shares-list",children:Kt.map(x=>{const S=zC(x),_=go===x.id,P=x.expiresAt?String(x.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:x.title||"AgentFlow Display"}),i.jsxs("span",{children:[x.flowId||"-"," · ",x.layout||"gallery"," · ",Array.isArray(x.nodeIds)?x.nodeIds.length:0," nodes"]}),i.jsx("small",{children:KG(x)})]}),i.jsx("input",{className:"af-display-share-item__url",type:"text",readOnly:!0,value:S,onFocus:T=>T.target.select()}),i.jsx("select",{className:"af-display-share-select",value:P,disabled:_,onChange:T=>void gL(x,T.target.value),"aria-label":"修改分享有效期",children:dw.map(T=>i.jsx("option",{value:T.value,children:T.label},T.value))}),i.jsxs("div",{className:"af-display-share-item__actions",children:[i.jsxs("button",{type:"button",onClick:()=>window.open(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 mL(x),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Ms===x.id?"check":"content_copy"}),Ms===x.id?"已复制":"复制"]}),i.jsxs("button",{type:"button",className:"af-display-share-item__danger",disabled:_,onClick:()=>void yL(x),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:_?"hourglass_empty":"link_off"}),"撤销"]})]})]},x.id)})})]})]})}),document.body):null,Se?ur.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:wt,onChange:x=>Dt(x.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),i.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":f0.length||1},children:Wf.length>0?f0.map((x,S)=>i.jsx("div",{className:"af-display-picker-column",children:x.map(iL)},`display-picker-column-${S}`)):i.jsx("div",{className:"af-display-picker-empty",children:vl.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,Zc.nodeId?ur.createPortal(i.jsx(AJ,{files:cl,query:Zc.query,onQueryChange:x=>Ng(S=>({...S,query:x})),onSelect:G$,onUpload:YS,onClose:Vg}),document.body):null,!ct&&!In&&Dn?ur.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:x=>x.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":he==="nodes",className:"af-workspace-quick-add__tab"+(he==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>De("nodes"),children:"节点"}),i.jsx("button",{type:"button",role:"tab","aria-selected":he==="flows",className:"af-workspace-quick-add__tab"+(he==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>De("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:fS,value:Ee,onChange:x=>et(x.target.value),onKeyDown:x=>{if(x.key==="Escape")x.preventDefault(),q(!1);else if(x.key==="ArrowDown"){x.preventDefault();const S=he==="flows"?yu.length:gu.length;bt(_=>Math.min(Math.max(0,S-1),_+1))}else x.key==="ArrowUp"?(x.preventDefault(),bt(S=>Math.max(0,S-1))):x.key==="Tab"?(x.preventDefault(),De(S=>S==="nodes"?"flows":"nodes")):x.key==="Enter"&&(x.preventDefault(),he==="flows"?x0(yu[Nn]||yu[0]):w0(gu[Nn]||gu[0]))},placeholder:he==="flows"?"搜索流程片段...":"搜索节点...","aria-label":he==="flows"?"搜索流程片段":"搜索节点"})]}),i.jsx("div",{className:"af-workspace-quick-add__list",children:he==="flows"?yu.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:Ze?"正在加载流程片段...":_t||"没有匹配的流程片段"}):yu.map((x,S)=>{const _=x.displayName||x.name||x.id,P=x.snippet&&typeof x.snippet=="object"?x.snippet.instances:null,T=x.snippet&&typeof x.snippet=="object"?x.snippet.edges:null,U=Number.isFinite(Number(x.nodeCount))?Number(x.nodeCount):Object.keys(P||{}).length,X=Number.isFinite(Number(x.edgeCount))?Number(x.edgeCount):Array.isArray(T)?T.length:0;return i.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(S===Nn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>bt(S),onClick:()=>x0(x),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:[x.id,x.version?` · v${x.version}`:""]}),i.jsx("span",{className:"af-workspace-quick-add__desc",children:x.description||`${U} 节点 / ${X} 连线`})]}),i.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${x.id}@${x.version}`)}):gu.length===0?i.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):gu.map((x,S)=>{const _=Ku(x),P=qu(x),T=hb(x);return i.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(S===Nn?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>bt(S),onClick:()=>w0(x),children:[i.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:IC(_)}),i.jsxs("span",{className:"af-workspace-quick-add__main",children:[i.jsx("span",{className:"af-workspace-quick-add__label",children:P}),i.jsx("span",{className:"af-workspace-quick-add__meta",children:x.id}),T?i.jsx("span",{className:"af-workspace-quick-add__desc",children:T}):null]}),i.jsx("span",{className:"af-workspace-quick-add__cat",children:_})]},x.id)})})]})}),document.body):null]})]})}function vM(){return i.jsx(Wk,{children:i.jsx(GJ,{})})}function JJ(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 XJ(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 QJ(e){let t=String(e||"").replace(/\r\n/g,`
|
|
266
|
-
`).trim();return t.includes(`
|
|
267
|
-
`)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
|
|
268
|
-
$1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
|
|
269
|
-
$2`)),t}function SM(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=QJ(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const d=String(c[1]||"").trim();return d==="|"||d===">"?a.slice((c.index||0)+c[0].length).split(`
|
|
270
|
-
`).filter(p=>/^\s+/.test(p)||!p.trim()).map(p=>p.replace(/^\s{2}/,"")).join(`
|
|
271
|
-
`).replace(/\s+$/g,""):d.replace(/^["']|["']$/g,"")}const u=t.replace(n[0],"").trim();if(u)return u}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],s=t.indexOf("{"),o=t.lastIndexOf("}");s>=0&&o>s&&r.unshift(t.slice(s,o+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}function vv(e){let t=SM(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 ZJ(e){const t=vv(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function eX(e){const t=vv(e);if(!t.trim())return"";const n=`<base target="_blank"><script data-agentflow-display-link-guard="1">
|
|
272
|
-
(() => {
|
|
273
|
-
document.addEventListener("click", (event) => {
|
|
274
|
-
const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
|
|
275
|
-
if (!link) return;
|
|
276
|
-
const rawHref = String(link.getAttribute("href") || "").trim();
|
|
277
|
-
if (!rawHref || rawHref.startsWith("#")) return;
|
|
278
|
-
if (/^javascript:/i.test(rawHref)) {
|
|
279
|
-
event.preventDefault();
|
|
280
|
-
return;
|
|
281
|
-
}
|
|
282
|
-
event.preventDefault();
|
|
283
|
-
window.open(link.href, "_blank", "noopener,noreferrer");
|
|
284
|
-
}, true);
|
|
285
|
-
})();
|
|
286
|
-
<\/script>`;return/data-agentflow-display-link-guard=["']1["']/i.test(t)?t:/<head\b[^>]*>/i.test(t)?t.replace(/<head\b([^>]*)>/i,`<head$1>${n}`):/<html\b[^>]*>/i.test(t)?t.replace(/<html\b([^>]*)>/i,`<html$1><head>${n}</head>`):`<!doctype html><html><head>${n}</head><body>${t}</body></html>`}function jM(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 tX(e,t,n={}){const r=String(e||"").trim();return r?jM(r,t,n):""}function nX({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),w=h?Math.min(v,d.scrollTop/Math.max(1,f-p)*v):0;o({visible:h,top:w,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,w=d.clientY>=p.top+h&&d.clientY<=p.top+h+y?d.clientY-p.top-h:y/2;l(c(d.clientY,w));const g=b=>{b.preventDefault(),l(c(b.clientY,w))},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 bb({node:e,shareId:t,style:n,bare:r=!1}){const s=JJ(e),o=e.kind==="html"?vv(s):e.kind==="react"?cg(s):SM(s),a=e.kind==="html"?ZJ(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:XJ(e.kind)}),i.jsx("strong",{children:e.label||e.id}),i.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),i.jsx(nX,{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:eX(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:fv(o)}):null,e.kind==="image"?i.jsx("img",{src:jM(o,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?i.jsx("div",{className:"af-public-display-markdown",children:i.jsx(ov,{content:o,resolveSrc:(c,u)=>tX(c,t,u)})}):null,e.kind==="chart"?i.jsx(lv,{content:o}):null,e.kind==="table"?i.jsx(av,{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 rX({data:e}){return i.jsx(bb,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const sX={publicDisplay:rX};function iX(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 NM(){var l,c,u,d;const{path:e}=gs(),t=m.useMemo(()=>iX(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(bb,{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(bb,{node:p,shareId:t},p.id))})]})}return i.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:i.jsx(Wk,{children:i.jsx(bR,{className:"af-public-display-flow",nodes:s,edges:[],nodeTypes:sX,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(vR,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const xt=e=>typeof e=="string",$u=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},e_=e=>e==null?"":""+e,oX=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},aX=/###/g,t_=e=>e&&e.indexOf("###")>-1?e.replace(aX,"."):e,n_=e=>!e||xt(e),md=(e,t,n)=>{const r=xt(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(n_(e))return{};const o=t_(r[s]);!e[o]&&n&&(e[o]=new n),Object.prototype.hasOwnProperty.call(e,o)?e=e[o]:e={},++s}return n_(e)?{}:{obj:e,k:t_(r[s])}},r_=(e,t,n)=>{const{obj:r,k:s}=md(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=md(e,a,Object);for(;l.obj===void 0&&a.length;)o=`${a[a.length-1]}.${o}`,a=a.slice(0,a.length-1),l=md(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${o}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${o}`]=n},lX=(e,t,n,r)=>{const{obj:s,k:o}=md(e,t,Object);s[o]=s[o]||[],s[o].push(n)},xm=(e,t)=>{const{obj:n,k:r}=md(e,t);if(n)return n[r]},cX=(e,t,n)=>{const r=xm(e,n);return r!==void 0?r:xm(t,n)},CM=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?xt(e[r])||e[r]instanceof String||xt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):CM(e[r],t[r],n):e[r]=t[r]);return e},Ll=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var uX={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const dX=e=>xt(e)?e.replace(/[&<>"'\/]/g,t=>uX[t]):e;class fX{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 pX=[" ",",","?","!",";"],hX=new fX(20),mX=(e,t,n)=>{t=t||"",n=n||"";const r=pX.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=hX.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},kb=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},bm=e=>e&&e.replace("_","-"),gX={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 km{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||gX,this.options=n,this.debug=n.debug}log(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,r,s){return s&&!this.debug?null:(xt(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new km(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new km(this.logger,t)}}var Si=new km;class fg{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 s_ extends fg{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,a=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.indexOf(".")>-1?l=t.split("."):(l=[t,n],r&&(Array.isArray(r)?l.push(...r):xt(r)&&o?l.push(...r.split(o)):l.push(r)));const c=xm(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!a||!xt(r)?c:kb(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),r_(this.data,l,s),o.silent||this.emit("added",t,n,r,s)}addResources(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const o in r)(xt(r[o])||Array.isArray(r[o]))&&this.addResource(t,n,o,r[o],{silent:!0});s.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,s,o){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),s=r,r=n,n=l[1]),this.addNamespaces(n);let c=xm(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?CM(c,r,o):c={...c,...r},r_(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 _M={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 i_={};class vm extends fg{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),oX(["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&&!mX(t,r,s);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:xt(o)?[o]:o};const u=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(u[0])>-1)&&(o=u.shift()),t=u.join(s)}return{key:t,namespaces:xt(o)?[o]:o}}translate(t,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const s=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(t[t.length-1],n),c=l[l.length-1],u=n.lng||this.language,d=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&u.toLowerCase()==="cimode"){if(d){const j=n.nsSeparator||this.options.nsSeparator;return s?{res:`${c}${j}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${j}${a}`}return s?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:a}const f=this.resolve(t,n);let p=f&&f.res;const h=f&&f.usedKey||a,y=f&&f.exactUsedKey||a,v=Object.prototype.toString.apply(p),w=["[object Number]","[object Function]","[object RegExp]"],g=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,k=!this.i18nFormat||this.i18nFormat.handleAsObject,b=!xt(p)&&typeof p!="boolean"&&typeof p!="number";if(k&&p&&b&&w.indexOf(v)<0&&!(xt(g)&&Array.isArray(p))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const j=this.options.returnedObjectHandler?this.options.returnedObjectHandler(h,p,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(f.res=j,f.usedParams=this.getUsedParamsDetails(n),f):j}if(o){const j=Array.isArray(p),N=j?[]:{},C=j?y:h;for(const I in p)if(Object.prototype.hasOwnProperty.call(p,I)){const R=`${C}${o}${I}`;N[I]=this.translate(R,{...n,joinArrays:!1,ns:l}),N[I]===R&&(N[I]=p[I])}p=N}}else if(k&&xt(g)&&Array.isArray(p))p=p.join(g),p&&(p=this.extendTranslation(p,t,n,r));else{let j=!1,N=!1;const C=n.count!==void 0&&!xt(n.count),I=vm.hasDefaultValue(n),R=C?this.pluralResolver.getSuffix(u,n.count,n):"",H=n.ordinal&&C?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",A=C&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),L=A&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${R}`]||n[`defaultValue${H}`]||n.defaultValue;!this.isValidLookup(p)&&I&&(j=!0,p=L),this.isValidLookup(p)||(N=!0,p=a);const O=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&N?void 0:p,M=I&&L!==p&&this.options.updateMissing;if(N||j||M){if(this.logger.log(M?"updateKey":"missingKey",u,c,a,M?L:p),o){const $=this.resolve(a,{...n,keySeparator:!1});$&&$.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let K=[];const z=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&z&&z[0])for(let $=0;$<z.length;$++)K.push(z[$]);else this.options.saveMissingTo==="all"?K=this.languageUtils.toResolveHierarchy(n.lng||this.language):K.push(n.lng||this.language);const F=($,W,E)=>{const Q=I&&E!==p?E:O;this.options.missingKeyHandler?this.options.missingKeyHandler($,c,W,Q,M,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing($,c,W,Q,M,n),this.emit("missingKey",$,c,W,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&C?K.forEach($=>{const W=this.pluralResolver.getSuffixes($,n);A&&n[`defaultValue${this.options.pluralSeparator}zero`]&&W.indexOf(`${this.options.pluralSeparator}zero`)<0&&W.push(`${this.options.pluralSeparator}zero`),W.forEach(E=>{F([$],a+E,n[`defaultValue${E}`]||L)})}):F(K,a,L))}p=this.extendTranslation(p,t,n,f,r),N&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${c}:${a}`),(N||j)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${a}`:a,j?p:void 0):p=this.options.parseMissingKeyHandler(p))}return s?(f.res=p,f.usedParams=this.getUsedParamsDetails(n),f):p}extendTranslation(t,n,r,s,o){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const u=xt(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let d;if(u){const p=t.match(this.interpolator.nestingRegexp);d=p&&p.length}let f=r.replace&&!xt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(f={...this.options.interpolation.defaultVariables,...f}),t=this.interpolator.interpolate(t,f,r.lng||this.language||s.usedLng,r),u){const p=t.match(this.interpolator.nestingRegexp),h=p&&p.length;d<h&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,h=new Array(p),y=0;y<p;y++)h[y]=arguments[y];return o&&o[0]===h[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${h[0]} in key: ${n[0]}`),null):a.translate(...h,n)},r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,c=xt(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=_M.handle(c,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...s,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,s,o,a,l;return xt(t)&&(t=[t]),t.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),d=u.key;s=d;let f=u.namespaces;this.options.fallbackNS&&(f=f.concat(this.options.fallbackNS));const p=n.count!==void 0&&!xt(n.count),h=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),y=n.context!==void 0&&(xt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);f.forEach(w=>{this.isValidLookup(r)||(l=w,!i_[`${v[0]}-${w}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(i_[`${v[0]}-${w}`]=!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,w,n);else{let j;p&&(j=this.pluralResolver.getSuffix(g,n.count,n));const N=`${this.options.pluralSeparator}zero`,C=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(k.push(d+j),n.ordinal&&j.indexOf(C)===0&&k.push(d+j.replace(C,this.options.pluralSeparator)),h&&k.push(d+N)),y){const I=`${d}${this.options.contextSeparator}${n.context}`;k.push(I),p&&(k.push(I+j),n.ordinal&&j.indexOf(C)===0&&k.push(I+j.replace(C,this.options.pluralSeparator)),h&&k.push(I+N))}}let b;for(;b=k.pop();)this.isValidLookup(r)||(o=b,r=this.getResource(g,w,b,n))}))})}),{res:r,usedKey:s,exactUsedKey:o,usedLng:a,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,n,r,s):this.resourceStore.getResource(t,n,r,s)}getUsedParamsDetails(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&!xt(t.replace);let s=r?t.replace:t;if(r&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!r){s={...s};for(const o of n)delete s[o]}return s}static hasDefaultValue(t){const n="defaultValue";for(const r in t)if(Object.prototype.hasOwnProperty.call(t,r)&&n===r.substring(0,n.length)&&t[r]!==void 0)return!0;return!1}}const hw=e=>e.charAt(0).toUpperCase()+e.slice(1);class o_{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Si.create("languageUtils")}getScriptPartFromCode(t){if(t=bm(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=bm(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(xt(t)&&t.indexOf("-")>-1){if(typeof Intl<"u"&&typeof Intl.getCanonicalLocales<"u")try{let s=Intl.getCanonicalLocales(t)[0];if(s&&this.options.lowerCaseLng&&(s=s.toLowerCase()),s)return s}catch{}const n=["hans","hant","latn","cyrl","cans","mong","arab"];let r=t.split("-");return this.options.lowerCaseLng?r=r.map(s=>s.toLowerCase()):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=hw(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]=hw(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=hw(r[2].toLowerCase()))),r.join("-")}return this.options.cleanCode||this.options.lowerCaseLng?t.toLowerCase():t}isSupportedCode(t){return(this.options.load==="languageOnly"||this.options.nonExplicitSupportedLngs)&&(t=this.getLanguagePartFromCode(t)),!this.supportedLngs||!this.supportedLngs.length||this.supportedLngs.indexOf(t)>-1}getBestMatchFromCodes(t){if(!t)return null;let n;return t.forEach(r=>{if(n)return;const s=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(s))&&(n=s)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const s=this.getLanguagePartFromCode(r);if(this.isSupportedCode(s))return n=s;n=this.options.supportedLngs.find(o=>{if(o===s)return o;if(!(o.indexOf("-")<0&&s.indexOf("-")<0)&&(o.indexOf("-")>0&&s.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===s||o.indexOf(s)===0&&s.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),xt(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],t),s=[],o=a=>{a&&(this.isSupportedCode(a)?s.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return xt(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&o(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&o(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&o(this.getLanguagePartFromCode(t))):xt(t)&&o(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&o(this.formatLanguageCode(a))}),s}}let yX=[{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}],wX={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 xX=["v1","v2","v3"],bX=["v4"],a_={zero:0,one:1,two:2,few:3,many:4,other:5},kX=()=>{const e={};return yX.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:wX[t.fc]}})}),e};class vX{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||bX.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=kX(),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=bm(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)=>a_[s]-a_[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!xX.includes(this.options.compatibilityJSON)}}const l_=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=cX(e,t,n);return!o&&s&&xt(n)&&(o=kb(e,n,r),o===void 0&&(o=kb(t,n,r))),o},mw=e=>e.replace(/\$/g,"$$$$");class SX{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:w,maxReplaces:g,alwaysFormat:k}=t.interpolation;this.escape=n!==void 0?n:dX,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=o?Ll(o):a||"{{",this.suffix=l?Ll(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=d?"":f||"-",this.unescapeSuffix=this.unescapePrefix?"":d||"",this.nestingPrefix=p?Ll(p):h||Ll("$t("),this.nestingSuffix=y?Ll(y):v||Ll(")"),this.nestingOptionsSeparator=w||",",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=l_(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(),w=y.join(this.formatSeparator).trim();return this.format(l_(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),w,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=>mw(h)},{regex:this.regexp,safeValue:h=>this.escapeValue?mw(this.escape(h)):mw(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 w=d(t,o,s);a=xt(w)?w:""}else if(s&&Object.prototype.hasOwnProperty.call(s,y))a="";else if(f){a=o[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${t}`),a="";else!xt(a)&&!this.useRawValueToEscape&&(a=e_(a));const v=h.safeValue(a);if(t=t.replace(o[0],v),f?(h.regex.lastIndex+=a.length,h.regex.lastIndex-=o[0].length):h.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s,o,a;const l=(c,u)=>{const d=this.nestingOptionsSeparator;if(c.indexOf(d)<0)return c;const f=c.split(new RegExp(`${d}[ ]*{`));let p=`{${f[1]}`;c=f[0],p=this.interpolate(p,a);const h=p.match(/'/g),y=p.match(/"/g);(h&&h.length%2===0&&!y||y.length%2!==0)&&(p=p.replace(/'/g,'"'));try{a=JSON.parse(p),u&&(a={...u,...a})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${d}${p}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,c};for(;s=this.nestingRegexp.exec(t);){let c=[];a={...r},a=a.replace&&!xt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let u=!1;if(s[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(s[1])){const d=s[1].split(this.formatSeparator).map(f=>f.trim());s[1]=d.shift(),c=d,u=!0}if(o=n(l.call(this,s[1].trim(),a),a),o&&s[0]===t&&!xt(o))return o;xt(o)||(o=e_(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 jX=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}},Ol=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(bm(r),s),t[a]=l),l(n)}};class NX{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Si.create("formatter"),this.options=t,this.formats={number:Ol((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return o=>s.format(o)}),currency:Ol((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return o=>s.format(o)}),datetime:Ol((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return o=>s.format(o)}),relativetime:Ol((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return o=>s.format(o,r.range||"day")}),list:Ol((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()]=Ol(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}=jX(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 CX=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class _X extends fg{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=>{lX(c.loaded,[o],a),CX(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const d=c.loaded[u];d.length&&d.forEach(f=>{l[u][f]===void 0&&(l[u][f]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!t.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:r,tried:s,wait:o,callback:a});return}this.readingCalls++;const l=(u,d)=>{if(this.readingCalls--,this.waitingReads.length>0){const f=this.waitingReads.shift();this.read(f.lng,f.ns,f.fcName,f.tried,f.wait,f.callback)}if(u&&d&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,o*2,a)},o);return}a(u,d)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(t,n);u&&typeof u.then=="function"?u.then(d=>l(null,d)).catch(l):l(null,u)}catch(u){l(u)}return}return c(t,n,l)}prepareLoading(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();xt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),xt(n)&&(n=[n]);const o=this.queueLoad(t,n,r,s);if(!o.toLoad.length)return o.pending.length||s(),null;o.toLoad.forEach(a=>{this.loadOne(a)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t.split("|"),s=r[0],o=r[1];this.read(s,o,"read",void 0,void 0,(a,l)=>{a&&this.logger.warn(`${n}loading namespace ${o} for language ${s} failed`,a),!a&&l&&this.logger.log(`${n}loaded namespace ${o} for language ${s}`,l),this.loaded(t,a,l)})}saveMissing(t,n,r,s,o){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},l=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend&&this.backend.create){const c={...a,isUpdate:o},u=this.backend.create.bind(this.backend);if(u.length<6)try{let d;u.length===5?d=u(t,n,r,s,c):d=u(t,n,r,s),d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}else u(t,n,r,s,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const c_=()=>({debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),xt(e[1])&&(t.defaultValue=e[1]),xt(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(r=>{t[r]=n[r]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),u_=e=>(xt(e.ns)&&(e.ns=[e.ns]),xt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),xt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Bp=()=>{},EX=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class Xd extends fg{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=u_(t),this.services={},this.logger=Si,this.modules={external:[]},EX(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(){var t=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(xt(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=c_();this.options={...s,...this.options,...u_(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=NX);const f=new o_(this.options);this.store=new s_(this.options.resources,this.options);const p=this.services;p.logger=Si,p.resourceStore=this.store,p.languageUtils=f,p.pluralResolver=new vX(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 SX(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new _X(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),w=1;w<y;w++)v[w-1]=arguments[w];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 vm(this.services,this.options),this.translator.on("*",function(h){for(var y=arguments.length,v=new Array(y>1?y-1:0),w=1;w<y;w++)v[w-1]=arguments[w];t.emit(h,...v)}),this.modules.external.forEach(h=>{h.init&&h.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Bp),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=$u(),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]:Bp;const s=xt(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(s&&s.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const o=[],a=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&o.indexOf(u)<0&&o.push(u)})};s?a(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>a(c)),this.options.preload&&this.options.preload.forEach(l=>a(l)),this.services.backendConnector.load(o,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(t,n,r){const s=$u();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=Bp),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"&&_M.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=$u();this.emit("languageChanging",t);const o=c=>{this.language=c,this.languages=this.services.languageUtils.toResolveHierarchy(c),this.resolvedLanguage=void 0,this.setResolvedLanguage(c)},a=(c,u)=>{u?(o(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,s.resolve(function(){return r.t(...arguments)}),n&&n(c,function(){return r.t(...arguments)})},l=c=>{!t&&!c&&this.services.languageDetector&&(c=[]);const u=xt(c)?c:this.services.languageUtils.getBestMatchFromCodes(c);u&&(this.language||o(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(u)),this.loadResources(u,d=>{a(d,u)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),s}getFixedT(t,n,r){var s=this;const o=function(a,l){let c;if(typeof l!="object"){for(var u=arguments.length,d=new Array(u>2?u-2:0),f=2;f<u;f++)d[f-2]=arguments[f];c=s.options.overloadTranslationOptionHandler([a,l].concat(d))}else c={...l};c.lng=c.lng||o.lng,c.lngs=c.lngs||o.lngs,c.ns=c.ns||o.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||o.keyPrefix);const p=s.options.keySeparator||".";let h;return c.keyPrefix&&Array.isArray(a)?h=a.map(y=>`${c.keyPrefix}${p}${y}`):h=c.keyPrefix?`${c.keyPrefix}${p}${a}`:a,s.t(h,c)};return xt(t)?o.lng=t:o.lngs=t,o.ns=n,o.keyPrefix=r,o}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],s=this.options?this.options.fallbackLng:!1,o=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,a);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,t)&&(!s||a(o,t)))}loadNamespaces(t,n){const r=$u();return this.options.ns?(xt(t)&&(t=[t]),t.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{r.resolve(),n&&n(s)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=$u();xt(t)&&(t=[t]);const s=this.options.preload||[],o=t.filter(a=>s.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return o.length?(this.options.preload=s.concat(o),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services&&this.services.languageUtils||new o_(c_());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 Xd(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Bp;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},o=new Xd(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 s_(this.store.data,s),o.services.resourceStore=o.store),o.translator=new vm(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 xr=Xd.createInstance();xr.createInstance=Xd.createInstance;xr.createInstance;xr.dir;xr.init;xr.loadResources;xr.reloadResources;xr.use;xr.changeLanguage;xr.getFixedT;xr.t;xr.exists;xr.setDefaultNamespace;xr.hasLoadedNamespace;xr.loadNamespaces;xr.loadLanguages;function AX(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Qd(e){"@babel/helpers - typeof";return Qd=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},Qd(e)}function PX(e,t){if(Qd(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Qd(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function IX(e){var t=PX(e,"string");return Qd(t)=="symbol"?t:t+""}function RX(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,IX(r.key),r)}}function TX(e,t,n){return t&&RX(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var EM=[],MX=EM.forEach,$X=EM.slice;function LX(e){return MX.call($X.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var d_=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,OX=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(!d_.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!d_.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},f_={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=OX(t,encodeURIComponent(n),o)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),s=0;s<r.length;s++){for(var o=r[s];o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(n)===0)return o.substring(n.length,o.length)}return null},remove:function(t){this.create(t,"",-1)}},DX={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=f_.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&f_.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},FX={name:"querystring",lookup:function(t){var n;if(typeof window<"u"){var r=window.location.search;!window.location.search&&window.location.hash&&window.location.hash.indexOf("?")>-1&&(r=window.location.hash.substring(window.location.hash.indexOf("?")));for(var s=r.substring(1),o=s.split("&"),a=0;a<o.length;a++){var l=o[a].indexOf("=");if(l>0){var c=o[a].substring(0,l);c===t.lookupQuerystring&&(n=o[a].substring(l+1))}}}return n}},Lu=null,p_=function(){if(Lu!==null)return Lu;try{Lu=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Lu=!1}return Lu},zX={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&p_()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&p_()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Ou=null,h_=function(){if(Ou!==null)return Ou;try{Ou=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Ou=!1}return Ou},BX={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&h_()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&h_()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},HX={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}},WX={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}},VX={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}},KX={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]}},AM=!1;try{document.cookie,AM=!0}catch{}var PM=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];AM||PM.splice(1,1);function qX(){return{order:PM,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var IM=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};AX(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return TX(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=LX(r,this.options||{},qX()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(o){return o.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=s,this.addDetector(DX),this.addDetector(FX),this.addDetector(zX),this.addDetector(BX),this.addDetector(HX),this.addDetector(WX),this.addDetector(VX),this.addDetector(KX)}},{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)}))}}])}();IM.type="languageDetector";const UX={name:"AgentFlow",tagline:"AI Workflow Orchestration"},YX={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},GX={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"},JX={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},XX={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},QX={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},ZX={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},eQ={app:UX,nav:YX,common:GX,status:JX,nodeTypes:XX,engine:QX,links:ZX},tQ="Flow Editor",nQ="Nodes",rQ="Edges",sQ="Properties",iQ={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"},oQ={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}}"},aQ={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},lQ={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},cQ={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"},uQ={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)"},dQ={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},fQ={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},pQ={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},hQ={node:"Node",text:"Text",file:"File",bool:"Boolean"},mQ={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"},gQ={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"},yQ={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},wQ={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."},xQ={mainNav:"Main Navigation"},bQ={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'},kQ={title:"AI Assistant",placeholder:"Ask AI to help with this node...",thinking:"Thinking",reply:"Reply",result:"Result",error:"Error",waiting:"Waiting for response...",yourQuestion:"Your question",send:"Send",expand:"Expand conversation",collapse:"Collapse",connecting:"Connecting…",requestFailed:"Request failed",cannotReadStream:"Cannot read response stream",connectTimeout:"Connection timeout (120s), please confirm UI service is running and retry. [CONNECT_TIMEOUT]",aborted:"Aborted",executing:"Executing…",ready:"Ready",done:"Done",inputPlaceholder:"Type your question (⌘/Ctrl+Enter to send)",inputAriaLabel:"Question input",mentionAriaLabel:"Mention: instances and node types",modelLabel:"Model",modelAriaLabel:"Conversation model",modelDefault:"Default",modelNotInList:"(not in current list)",stopGeneration:"Stop generation",conversationOutput:"Conversation & Output",collapseAriaLabel:"Collapse",closeSidebar:"Close sidebar",endConversation:"End conversation (will stop generation)",closeConversation:"Close conversation",newConversation:"New conversation",switchConversation:"Switch conversation",selectedNodesAriaLabel:"Selected nodes list",selectedNodesEmpty:"Select nodes on canvas, or use @ in the input to pick Instances or Node types",removeFromInput:"Remove @{{id}} from input",deselectNode:"Deselect {{id}}",taskPlan:`📋 Task Plan ({{count}} steps):
|
|
287
|
-
{{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
|
|
288
|
-
Current: {{current}}`,phaseComplete:"{{phaseName}} completed. Next phase: {{nextPhase}}",nextPhase:"Next phase",continuePhase:"Continue {{label}}",skipRemainingPhases:"Please complete all remaining steps at once (skip phased confirmation)",phaseProgress:"Phase progress",phaseReviewLabel:"Phase options",phaseReviewHint:'This phase is complete. Review the canvas, then continue to "{{nextPhase}}".',phaseReviewContinue:"Continue: {{label}}",phaseReviewSkip:"Skip — finish remaining in one pass",stepsAriaLabel:"Task steps progress",phasesAriaLabel:"Generation phases progress",phaseNumber:"Phase {{index}}",stepRoleLabel:"Role: {{role}}",stepInstanceLabel:"Instance: {{instanceId}}",pageRefreshReset:"Reset after page refresh",conversationLabel:"Conversation {{n}}"},vQ={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"},SQ={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},jQ={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}}"},NQ={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"},CQ={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"},_Q={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"},EQ={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"},AQ={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"},PQ={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},IQ={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},RQ={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"},TQ={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."},MQ={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},$Q={save:"Save",cancel:"Cancel"},LQ={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},OQ={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},DQ={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"},FQ={title:tQ,nodes:nQ,edges:rQ,properties:sQ,node:iQ,nodeProps:oQ,actions:aQ,panel:lQ,palette:cQ,pipeline:uQ,status:dQ,roles:fQ,phases:pQ,types:hQ,runContext:mQ,shortcuts:gQ,jumpPalette:yQ,emptyCanvas:wQ,sidebar:xQ,validation:bQ,composer:kQ,topbar:vQ,palette2:SQ,run:jQ,fileEdit:NQ,settings:CQ,schedule:_Q,history:EQ,nodePropsError:AQ,placeholder:PQ,time:IQ,userCheck:RQ,userAsk:TQ,toolPrint:MQ,provideEdit:$Q,runParams:LQ,runPreset:OQ,runConfig:DQ},zQ="Settings",BQ={engine:"Engine Settings",preferences:"Global Preferences"},HQ={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)."},WQ={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..."}},VQ={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."},KQ={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."},qQ={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."},UQ={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)"},YQ={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"},GQ={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models",codexModels:"Codex Models"},JQ={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},XQ={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},QQ={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."},ZQ={title:zQ,crumb:BQ,workspace:HQ,cursor:WQ,opencode:VQ,claudeCode:KQ,codex:qQ,env:UQ,allowlist:YQ,system:GQ,shortcuts:JQ,language:XQ,onboarding:QQ},eZ={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},tZ={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)"},nZ={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},rZ={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},sZ={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},iZ={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},oZ={aiLabels:eZ,placeholders:tZ,actions:nZ,labels:rZ,tooltips:sZ,rightPanel:iZ},aZ="Projects",lZ="All",cZ="Archived",uZ="Nodes",dZ="My Nodes",fZ="My Flows",pZ="Skills",hZ="Active Projects",mZ="Archived Pipelines",gZ="Global Nodes",yZ="All Nodes",wZ="My Nodes",xZ="Manage node versions published to the current workspace marketplace, {{count}} total.",bZ="Manage flow snippets published to the current workspace marketplace, {{count}} total.",kZ="Global Skills",vZ="Create New Project",SZ="New Pipeline",jZ="SEARCH PIPELINES...",NZ="SEARCH NODES...",CZ="SEARCH FLOW SNIPPETS...",_Z="SEARCH SKILLS...",EZ="Refresh Resources",AZ="Loading pipelines...",PZ="Loading global resources...",IZ="Filter result: {{count}} items (matching title, description, path and tags)",RZ="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",TZ="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",MZ="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",$Z="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",LZ="Executable building blocks for pipeline runtime",OZ="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.",DZ="Published local node packages",FZ="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",zZ="Published flow snippets",BZ="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",HZ="Operating guides for Composer and agents",WZ="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",VZ="No archived projects.",KZ="No active pipelines; archived items are in the Archived tab.",qZ="No global nodes available.",UZ="No marketplace nodes have been published.",YZ="No flow snippets have been published. Select multiple canvas nodes and publish them first.",GZ="No skills available.",JZ="No description.",XZ='No node matches "{{query}}".',QZ='No flow snippet matches "{{query}}".',ZZ='No skill matches "{{query}}".',eee="{{inputs}} in / {{outputs}} out",tee="Flow Snippet",nee="{{nodes}} nodes / {{edges}} edges",ree="Skill",see="Node detail",iee="Flow snippet detail",oee="Skill detail",aee="Type",lee="Source",cee="Package",uee="Version",dee="Path",fee="Editable",pee="Read only",hee="Editable",mee="Schema",gee="Inputs",yee="Outputs",wee="Runtime",xee="Node Body",bee="Files",kee="Usage",vee="No runtime manifest.",See="No node body or README.",jee="No previewable files.",Nee="Select a file to preview.",Cee="Binary file preview is not supported.",_ee="Large file; showing the first 256KB only.",Eee="No pipelines using this node were found.",Aee="Node Management",Pee="Delete Node Version",Iee="Deleting...",Ree="AgentFlow checks all flow references before deleting; installed or used versions are kept.",Tee="Delete {{id}}@{{version}}? This cannot be undone.",Mee="Deleted {{id}}@{{version}}.",$ee="{{count}} flow(s) still use it.",Lee="Flow Snippet Management",Oee="Delete Flow Snippet",Dee="Deleting...",Fee="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",zee="Delete {{id}}@{{version}}? This cannot be undone.",Bee="Deleted {{id}}@{{version}}.",Hee="No slots",Wee="Purpose",Vee="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",Kee="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.",qee="Scale",Uee="Flow Preview",Yee="Edges",Gee="Snippet JSON",Jee="{{count}} more edge(s)",Xee="No previewable nodes.",Qee="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",Zee="SKILL.md Preview",ete="No preview content available.",tte="Select a resource to inspect details.",nte="Failed to load pipeline list.",rte="No pipelines in current workspace.",ste="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.",ite='No pipelines found matching "{{query}}". Try different keywords or clear the search.',ote="Recent Activity",ate="No recent activity",lte="No recent activity matching the keyword",cte="Recent Run",ute="Recent Open",dte={builtin:"Built-in",workspace:"Workspace",user:"User"},fte={flow:"Flow",global:"Global",marketplace:"Marketplace"},pte={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},hte={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},mte="Open to edit this pipeline in the node canvas.",gte={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>"},yte={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"},wte={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"},xte={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"},bte={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"},kte={title:aZ,all:lZ,archived:cZ,nodes:uZ,myNodes:dZ,myFlows:fZ,skills:pZ,activeProjects:hZ,archivedPipelines:mZ,globalNodes:gZ,nodeScopeAll:yZ,nodeScopeMine:wZ,myNodesHint:xZ,myFlowsHint:bZ,globalSkills:kZ,createNew:vZ,newPipeline:SZ,searchPipelines:jZ,searchNodes:NZ,searchFlows:CZ,searchSkills:_Z,refreshResources:EZ,loadingPipelines:AZ,loadingResources:PZ,filterResult:IZ,archivedHint:RZ,activeHint:TZ,nodesHint:MZ,skillsHint:$Z,nodesPurposeTitle:LZ,nodesPurposeDesc:OZ,myNodesPurposeTitle:DZ,myNodesPurposeDesc:FZ,myFlowsPurposeTitle:zZ,myFlowsPurposeDesc:BZ,skillsPurposeTitle:HZ,skillsPurposeDesc:WZ,noArchived:VZ,noActive:KZ,noNodes:qZ,noMyNodes:UZ,noMyFlows:YZ,noSkills:GZ,noDescription:JZ,noNodeMatch:XZ,noFlowSnippetMatch:QZ,noSkillMatch:ZZ,nodeSlots:eee,flowSnippet:tee,flowSnippetNodes:nee,skill:ree,nodeDetail:see,flowDetail:iee,skillDetail:oee,detailType:aee,detailSource:lee,detailPackage:cee,detailVersion:uee,detailPath:dee,detailEditable:fee,readOnly:pee,editable:hee,nodeSchema:mee,nodeInputs:gee,nodeOutputs:yee,nodeRuntime:wee,nodeBody:xee,nodeFiles:bee,nodeUsage:kee,noRuntimeManifest:vee,noNodeBody:See,noNodeFiles:jee,selectNodeFile:Nee,binaryFile:Cee,fileTruncated:_ee,noNodeUsage:Eee,myNodeManagement:Aee,deleteMyNode:Pee,deletingMyNode:Iee,deleteMyNodeHint:Ree,deleteMyNodeConfirm:Tee,deleteMyNodeSuccess:Mee,deleteMyNodeUsedBy:$ee,myFlowManagement:Lee,deleteMyFlow:Oee,deletingMyFlow:Dee,deleteMyFlowHint:Fee,deleteMyFlowConfirm:zee,deleteMyFlowSuccess:Bee,noSlots:Hee,resourceMeaning:Wee,nodesMeaning:Vee,myFlowsMeaning:Kee,flowSnippetScale:qee,flowSnippetPreview:Uee,flowSnippetEdges:Yee,flowSnippetJson:Gee,flowSnippetMoreEdges:Jee,noFlowSnippetPreview:Xee,skillsMeaning:Qee,skillPreview:Zee,skillPreviewEmpty:ete,selectResource:tte,loadFailed:nte,noPipelines:rte,emptyHint:ste,noMatch:ite,recentActivity:ote,noRecentActivity:ate,noMatchRecent:lte,recentRun:cte,recentOpen:ute,sourceBadge:dte,resourceSource:fte,resourceFilter:pte,nodeDetailTabs:hte,defaultCardDesc:mte,hubCard:gte,newPipelineModal:yte,importModal:wte,deleteModal:xte,archiveModal:bte},vte="Back",Ste="Next",jte="Skip",Nte="Done",Cte="Start Creating",_te={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
|
|
289
|
-
|
|
290
|
-
Click the button below to create your first pipeline.`,hubIntro:`Don't want to start from scratch?
|
|
291
|
-
|
|
292
|
-
Browse ready-made pipelines on AgentFlow Hub — community-shared flows you can install and run in one click.`},Ete={intro:`Now you're in the flow editor.
|
|
293
|
-
|
|
294
|
-
Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
|
|
295
|
-
|
|
296
|
-
The left node panel allows you to freely drag, delete, and adjust connections.`,introEmpty:`The canvas is empty. Start creating your flow!
|
|
297
|
-
|
|
298
|
-
Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
|
|
299
|
-
|
|
300
|
-
The left node panel allows you to freely drag, delete, and adjust connections.`},Ate={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"},Pte={back:vte,next:Ste,skip:jte,done:Nte,startCreate:Cte,projects:_te,flow:Ete,newPipeline:Ate},Ite={name:"AgentFlow",tagline:"AI 工作流编排"},Rte={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},Tte={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},Mte={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},$te={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},Lte={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},Ote={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},Dte={app:Ite,nav:Rte,common:Tte,status:Mte,nodeTypes:$te,engine:Lte,links:Ote},Fte="流程编辑器",zte="节点",Bte="连线",Hte="属性",Wte={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:"编辑内容"},Vte={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}}"},Kte={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},qte={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},Ute={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},Yte={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},Gte={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},Jte={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},Xte={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},Qte={node:"节点",text:"文本",file:"文件",bool:"布尔"},Zte={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:"等待"},ene={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},tne={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},nne={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},rne={mainNav:"主导航"},sne={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},ine={title:"AI 助手",placeholder:"让 AI 协助编辑此节点…",thinking:"思考",reply:"回复",result:"结果",error:"错误",waiting:"等待响应…",yourQuestion:"您的问题",send:"发送",expand:"展开对话",collapse:"收起",connecting:"连接中…",requestFailed:"请求失败",cannotReadStream:"无法读取响应流",connectTimeout:"连接超时(120s),请确认 UI 服务正在运行并重试。[CONNECT_TIMEOUT]",aborted:"已中止",executing:"执行中…",ready:"就绪",done:"完成",inputPlaceholder:"在此输入问题(⌘/Ctrl+Enter 发送)",inputAriaLabel:"问题输入",mentionAriaLabel:"提及:实例与节点类型",modelLabel:"模型",modelAriaLabel:"对话模型",modelDefault:"默认",modelNotInList:"(不在当前列表)",stopGeneration:"停止生成",conversationOutput:"对话与输出",collapseAriaLabel:"收起",closeSidebar:"关闭侧栏",endConversation:"结束对话(将停止生成)",closeConversation:"关闭对话",newConversation:"新建对话",switchConversation:"切换对话",selectedNodesAriaLabel:"已选节点列表",selectedNodesEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",removeFromInput:"从输入中移除 @{{id}}",deselectNode:"取消选中 {{id}}",taskPlan:`📋 任务规划({{count}} 步):
|
|
301
|
-
{{summary}}`,step:"步骤 {{current}}/{{total}}: {{description}}",phaseGeneration:`分阶段生成({{count}} 阶段):{{labels}}
|
|
302
|
-
当前:{{current}}`,phaseComplete:"{{phaseName}}已完成。下一阶段:{{nextPhase}}",nextPhase:"下一阶段",continuePhase:"继续{{label}}",skipRemainingPhases:"请一次性完成剩余所有步骤(跳过分阶段确认)",phaseProgress:"分阶段进度",phaseReviewLabel:"分阶段选项",phaseReviewHint:"当前阶段完成,请在画布上检查结果,确认无误后进入「{{nextPhase}}」",phaseReviewContinue:"继续:{{label}}",phaseReviewSkip:"跳过,一次性完成剩余",stepsAriaLabel:"任务步骤进度",phasesAriaLabel:"生成阶段进度",phaseNumber:"第 {{index}} 阶段",stepRoleLabel:"角色:{{role}}",stepInstanceLabel:"实例:{{instanceId}}",pageRefreshReset:"页面刷新后重置",conversationLabel:"对话 {{n}}"},one={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},ane={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},lne={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}} 的分支"},cne={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},une={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:"已复制"},dne={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:"定时配置已保存"},fne={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},pne={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},hne={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},mne={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},gne={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},yne={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},wne={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},xne={save:"保存",cancel:"取消"},bne={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},kne={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},vne={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},Sne={title:Fte,nodes:zte,edges:Bte,properties:Hte,node:Wte,nodeProps:Vte,actions:Kte,panel:qte,palette:Ute,pipeline:Yte,status:Gte,roles:Jte,phases:Xte,types:Qte,runContext:Zte,shortcuts:ene,jumpPalette:tne,emptyCanvas:nne,sidebar:rne,validation:sne,composer:ine,topbar:one,palette2:ane,run:lne,fileEdit:cne,settings:une,schedule:dne,history:fne,nodePropsError:pne,placeholder:hne,time:mne,userCheck:gne,userAsk:yne,toolPrint:wne,provideEdit:xne,runParams:bne,runPreset:kne,runConfig:vne},jne="设置",Nne={engine:"引擎设置",preferences:"全局首选项"},Cne={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},_ne={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},Ene={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},Ane={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},Pne={title:"Codex CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Codex 模型名称列表",description:"模型列表来自 codex debug models --bundled;首次使用请先执行 codex login。"},Ine={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},Rne={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:"添加"},Tne={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型",codexModels:"Codex 模型"},Mne={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},$ne={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},Lne={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},One={title:jne,crumb:Nne,workspace:Cne,cursor:_ne,opencode:Ene,claudeCode:Ane,codex:Pne,env:Ine,allowlist:Rne,system:Tne,shortcuts:Mne,language:$ne,onboarding:Lne},Dne={thinking:"思考",result:"结果",reply:"回复",error:"错误"},Fne={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},zne={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},Bne={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},Hne={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},Wne={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},Vne={aiLabels:Dne,placeholders:Fne,actions:zne,labels:Bne,tooltips:Hne,rightPanel:Wne},Kne="项目",qne="全部",Une="已归档",Yne="Nodes",Gne="我的 Nodes",Jne="我的流程",Xne="Skills",Qne="活跃项目",Zne="已归档流水线",ere="全局 Nodes",tre="全部 Nodes",nre="我的 Nodes",rre="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",sre="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",ire="全局 Skills",ore="创建新项目",are="新建流水线",lre="搜索流水线…",cre="搜索 nodes…",ure="搜索流程片段…",dre="搜索 skills…",fre="刷新资源",pre="加载流水线列表…",hre="加载全局资源…",mre="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",gre="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",yre="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",wre="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",xre="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",bre="流程运行时的可执行积木",kre="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",vre="已发布的本地节点包",Sre="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",jre="已发布的流程片段",Nre="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",Cre="Composer/Agent 的操作指南",_re="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",Ere="暂无归档项目。",Are="暂无未归档流水线;已归档项在 Archived 标签中查看。",Pre="暂无可用全局 nodes。",Ire="暂无已发布的 marketplace nodes。",Rre="暂无已发布的流程片段。可在画布中选中多个节点后发布。",Tre="暂无可用 skills。",Mre="暂无描述。",$re="未找到与「{{query}}」匹配的 node。",Lre="未找到与「{{query}}」匹配的流程片段。",Ore="未找到与「{{query}}」匹配的 skill。",Dre="{{inputs}} in / {{outputs}} out",Fre="流程片段",zre="{{nodes}} 节点 / {{edges}} 连线",Bre="Skill",Hre="Node 详情",Wre="流程片段详情",Vre="Skill 详情",Kre="类型",qre="来源",Ure="包",Yre="版本",Gre="路径",Jre="可编辑",Xre="只读",Qre="可编辑",Zre="Schema",ese="输入",tse="输出",nse="Runtime",rse="节点内容",sse="Files",ise="Usage",ose="暂无 runtime manifest。",ase="暂无节点正文或 README。",lse="暂无可预览文件。",cse="请选择文件查看内容。",use="二进制文件暂不支持预览。",dse="文件较大,仅显示前 256KB。",fse="暂未发现使用此 node 的流水线。",pse="节点管理",hse="删除节点版本",mse="删除中…",gse="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",yse="确定删除 {{id}}@{{version}}?此操作不可撤销。",wse="已删除 {{id}}@{{version}}。",xse="仍有 {{count}} 个 Flow 使用它。",bse="流程片段管理",kse="删除流程片段",vse="删除中…",Sse="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",jse="确定删除 {{id}}@{{version}}?此操作不可撤销。",Nse="已删除 {{id}}@{{version}}。",Cse="无槽位",_se="作用",Ese="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",Ase="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",Pse="规模",Ise="流程预览",Rse="连线",Tse="片段 JSON",Mse="还有 {{count}} 条连线",$se="暂无可预览节点。",Lse="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",Ose="SKILL.md 预览",Dse="暂无可预览内容。",Fse="请选择一个资源查看详情。",zse="未能加载流水线列表。",Bse="当前工作区暂无流水线。",Hse="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",Wse="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",Vse="最近打开或最近运行",Kse="暂无打开或运行记录",qse="暂无与关键词匹配的最近记录",Use="最近运行",Yse="最近打开",Gse={builtin:"内置",workspace:"工作区",user:"用户"},Jse={flow:"Flow",global:"Global",marketplace:"Marketplace"},Xse={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Qse={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Zse="打开以在节点画布中编辑此流水线。",eie={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},tie={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:"关闭"},nie={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},rie={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},sie={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},iie={title:Kne,all:qne,archived:Une,nodes:Yne,myNodes:Gne,myFlows:Jne,skills:Xne,activeProjects:Qne,archivedPipelines:Zne,globalNodes:ere,nodeScopeAll:tre,nodeScopeMine:nre,myNodesHint:rre,myFlowsHint:sre,globalSkills:ire,createNew:ore,newPipeline:are,searchPipelines:lre,searchNodes:cre,searchFlows:ure,searchSkills:dre,refreshResources:fre,loadingPipelines:pre,loadingResources:hre,filterResult:mre,archivedHint:gre,activeHint:yre,nodesHint:wre,skillsHint:xre,nodesPurposeTitle:bre,nodesPurposeDesc:kre,myNodesPurposeTitle:vre,myNodesPurposeDesc:Sre,myFlowsPurposeTitle:jre,myFlowsPurposeDesc:Nre,skillsPurposeTitle:Cre,skillsPurposeDesc:_re,noArchived:Ere,noActive:Are,noNodes:Pre,noMyNodes:Ire,noMyFlows:Rre,noSkills:Tre,noDescription:Mre,noNodeMatch:$re,noFlowSnippetMatch:Lre,noSkillMatch:Ore,nodeSlots:Dre,flowSnippet:Fre,flowSnippetNodes:zre,skill:Bre,nodeDetail:Hre,flowDetail:Wre,skillDetail:Vre,detailType:Kre,detailSource:qre,detailPackage:Ure,detailVersion:Yre,detailPath:Gre,detailEditable:Jre,readOnly:Xre,editable:Qre,nodeSchema:Zre,nodeInputs:ese,nodeOutputs:tse,nodeRuntime:nse,nodeBody:rse,nodeFiles:sse,nodeUsage:ise,noRuntimeManifest:ose,noNodeBody:ase,noNodeFiles:lse,selectNodeFile:cse,binaryFile:use,fileTruncated:dse,noNodeUsage:fse,myNodeManagement:pse,deleteMyNode:hse,deletingMyNode:mse,deleteMyNodeHint:gse,deleteMyNodeConfirm:yse,deleteMyNodeSuccess:wse,deleteMyNodeUsedBy:xse,myFlowManagement:bse,deleteMyFlow:kse,deletingMyFlow:vse,deleteMyFlowHint:Sse,deleteMyFlowConfirm:jse,deleteMyFlowSuccess:Nse,noSlots:Cse,resourceMeaning:_se,nodesMeaning:Ese,myFlowsMeaning:Ase,flowSnippetScale:Pse,flowSnippetPreview:Ise,flowSnippetEdges:Rse,flowSnippetJson:Tse,flowSnippetMoreEdges:Mse,noFlowSnippetPreview:$se,skillsMeaning:Lse,skillPreview:Ose,skillPreviewEmpty:Dse,selectResource:Fse,loadFailed:zse,noPipelines:Bse,emptyHint:Hse,noMatch:Wse,recentActivity:Vse,noRecentActivity:Kse,noMatchRecent:qse,recentRun:Use,recentOpen:Yse,sourceBadge:Gse,resourceSource:Jse,resourceFilter:Xse,nodeDetailTabs:Qse,defaultCardDesc:Zse,hubCard:eie,newPipelineModal:tie,importModal:nie,deleteModal:rie,archiveModal:sie},oie="返回",aie="下一步",lie="跳过",cie="完成",uie="开始创建",die={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
|
|
303
|
-
|
|
304
|
-
点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
|
|
305
|
-
|
|
306
|
-
在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},fie={intro:`现在进入流程编辑器。
|
|
307
|
-
|
|
308
|
-
在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
|
|
309
|
-
|
|
310
|
-
左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
|
|
311
|
-
|
|
312
|
-
在下方输入框用自然语言描述需求,AI 会自动生成流程图。
|
|
313
|
-
|
|
314
|
-
左侧节点面板可以自由拖拽、删除和调整连接。`},pie={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},hie={back:oie,next:aie,skip:lie,done:cie,startCreate:uie,projects:die,flow:fie,newPipeline:pie},mie={en:{common:eQ,flow:FQ,settings:ZQ,composer:oZ,project:kte,onboarding:Pte},zh:{common:Dte,flow:Sne,settings:One,composer:Vne,project:iie,onboarding:hie}};xr.use(IM).use(ID).init({resources:mie,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 gie=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function yie(e){return xr.changeLanguage(e)}const vb="agentflow-settings-opencode-plan-v1",Gu="CURSOR_API_KEYS",Ju="AGENTFLOW_CURSOR_API_KEY_COOLDOWN_MINUTES",gw=new Set([Gu,Ju,"CURSOR_API_KEY_COOLDOWN_MINUTES"]),RM=["cursor","opencode","claudeCode","codex"];function TM(){return{cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}}function Sb(e){const t=String(e||"").trim(),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t}function ka(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const r of RM)n[r]=Array.isArray(t[r])?[...new Set(t[r].map(Sb).filter(Boolean))]:[];return n}function Wi(e){if(!e||typeof e!="object")return TM();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 yc(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function wie(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Ca(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()||yc(),c=String(r.scope??t).trim()==="global"?"global":"user";!s&&!o||n.push({id:a,key:s,value:o,scope:c})}return n}function m_(e){return Ca(e).map(({key:t,value:n})=>({key:t,value:n}))}function g_(){try{return localStorage.getItem(vb)??""}catch{return""}}function MM(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function xie(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()||yc(),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 y_(e){const t=Array.isArray(e)?e.map((n,r)=>({id:String((n==null?void 0:n.id)||"").trim()||yc(),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 bie(e){const t=String(e||"").trim();return t?t.length<=10?MM(t):`${t.slice(0,4)}${"•".repeat(Math.min(18,t.length-8))}${t.slice(-4)}`:""}function kie(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 vie({authUser:e}){const{t,i18n:n}=zr(["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(TM()),[p,h]=m.useState(()=>ka({})),[y,v]=m.useState(!1),[w,g]=m.useState(""),[k,b]=m.useState(""),[j,N]=m.useState(!1),[C,I]=m.useState(!1),[R,H]=m.useState(""),[A,L]=m.useState([]),[D,O]=m.useState(""),[M,K]=m.useState(!1),[z,F]=m.useState(""),[$,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,gt]=m.useState(""),[Te,st]=m.useState(!1),[mt,Tt]=m.useState(!1),[xe,Oe]=m.useState(""),[ie,ke]=m.useState(""),[Ke,Ue]=m.useState(""),[be,It]=m.useState(null),[nn,Vt]=m.useState(!1),[Ot,ln]=m.useState(!1),[re,Re]=m.useState(""),Je=m.useRef(null),Ze=m.useRef(!1),Mt=m.useRef(!1),_t=m.useRef(""),Kn=m.useCallback(async()=>{l("");try{const oe=await fetch("/api/ui-context");if(!oe.ok)throw new Error("HTTP "+oe.status);const Se=await oe.json();o(typeof Se.workspaceRoot=="string"?Se.workspaceRoot:"")}catch(oe){l(String(oe.message||oe)),o("")}},[]),jn=m.useCallback(async()=>{b(""),N(!0),g("");try{const oe=await fetch(e!=null&&e.isAdmin?"/api/model-visibility":"/api/model-lists");if(!oe.ok)throw new Error("HTTP "+oe.status);const Se=await oe.json();if(e!=null&&e.isAdmin)u(Wi(Se.modelLists)),f(Wi(Se.allModelLists)),h(ka(Se.hiddenModels));else{const Pe=Wi(Se);u(Pe),f(Pe),h(ka({}))}}catch(oe){b(String(oe.message||oe))}finally{N(!1)}},[e==null?void 0:e.isAdmin]),br=m.useCallback(async()=>{O("");try{const oe=await fetch("/api/user-env"),Se=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+oe.status);const Pe=Ca(Array.isArray(Se.env)?Se.env:[],"user").map(Yt=>({...Yt,scope:"user"})),Dt=[...e!=null&&e.isAdmin?Ca(Array.isArray(Se.globalEnv)?Se.globalEnv:[],"global").map(Yt=>({...Yt,scope:"global"})):[],...Pe];_t.current=JSON.stringify(Dt),L(Dt)}catch(oe){L([]),O(String(oe.message||oe))}finally{Mt.current=!0}},[e==null?void 0:e.isAdmin]),xn=m.useCallback(async()=>{if(e!=null&&e.isAdmin){st(!0),Oe("");try{const oe=await fetch("/api/admin/user-allowlist"),Se=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+oe.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(oe){Oe(String(oe.message||oe))}finally{st(!1)}}},[e==null?void 0:e.isAdmin]),Qn=m.useCallback(async oe=>{if(e!=null&&e.isAdmin){Tt(!0),Oe("");try{const Se=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:oe})}),Pe=await Se.json().catch(()=>({}));if(!Se.ok)throw new Error(typeof Pe.error=="string"?Pe.error:"HTTP "+Se.status);const wt=Pe.allowlist&&typeof Pe.allowlist=="object"?Pe.allowlist:{};me(Array.isArray(wt.fileUsers)?wt.fileUsers.map(String):[]),Ce(Array.isArray(wt.envUsers)?wt.envUsers.map(String):[]),Be(typeof wt.path=="string"?wt.path:"")}catch(Se){Oe(String(Se.message||Se))}finally{Tt(!1)}}},[e==null?void 0:e.isAdmin]),qn=m.useCallback(async()=>{if(e!=null&&e.isAdmin){Vt(!0),Re("");try{const oe=await fetch("/api/admin/storage-config"),Se=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+oe.status);const Pe=Se.config&&typeof Se.config=="object"?Se.config:{};It(Pe),ke(typeof Pe.dataRoot=="string"?Pe.dataRoot:""),Ue(typeof Pe.skillsRoot=="string"?Pe.skillsRoot:"")}catch(oe){Re(String(oe.message||oe))}finally{Vt(!1)}}},[e==null?void 0:e.isAdmin]),mr=m.useCallback(async()=>{if(e!=null&&e.isAdmin){ln(!0),Re("");try{const oe=await fetch("/api/admin/storage-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataRoot:ie.trim(),skillsRoot:Ke.trim(),migrateLegacySkills:!0})}),Se=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+oe.status);const Pe=Se.config&&typeof Se.config=="object"?Se.config:{};It(Pe),ke(typeof Pe.dataRoot=="string"?Pe.dataRoot:""),Ue(typeof Pe.skillsRoot=="string"?Pe.skillsRoot:"")}catch(oe){Re(String(oe.message||oe))}finally{ln(!1)}}},[e==null?void 0:e.isAdmin,ie,Ke]),ts=m.useCallback(async oe=>{const Se=Ca(oe),Pe=Se.filter(Dt=>Dt.scope!=="global"),wt=Se.filter(Dt=>Dt.scope==="global");K(!0),O("");try{const Dt=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:m_(Pe),...e!=null&&e.isAdmin?{globalEnv:m_(wt)}:{}})}),Yt=await Dt.json().catch(()=>({}));if(!Dt.ok)throw new Error(typeof Yt.error=="string"?Yt.error:"HTTP "+Dt.status);const Bn=Ca(Array.isArray(Yt.env)?Yt.env:[],"user").map(he=>({...he,scope:"user"})),q=[...e!=null&&e.isAdmin?Ca(Array.isArray(Yt.globalEnv)?Yt.globalEnv:[],"global").map(he=>({...he,scope:"global"})):[],...Bn];_t.current=JSON.stringify(q),L(q)}catch(Dt){O(String(Dt.message||Dt))}finally{K(!1)}},[e==null?void 0:e.isAdmin]),Pr=m.useCallback(async()=>{b(""),N(!0);try{const oe=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:Z.trim()})}),Se=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof Se.error=="string"?Se.error:"HTTP "+oe.status);u(Wi(Se.modelLists)),e!=null&&e.isAdmin?await jn():f(Wi(Se.modelLists))}catch(oe){b(String(oe.message||oe))}finally{N(!1)}},[e==null?void 0:e.isAdmin,jn,Z]),ys=m.useCallback(async oe=>{if(!(e!=null&&e.isAdmin))return;const Se=ka(oe);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})}),wt=await Pe.json().catch(()=>({}));if(!Pe.ok)throw new Error(typeof wt.error=="string"?wt.error:"HTTP "+Pe.status);u(Wi(wt.modelLists)),f(Wi(wt.allModelLists)),h(ka(wt.hiddenModels))}catch(Pe){g(String(Pe.message||Pe)),jn()}finally{v(!1)}},[e==null?void 0:e.isAdmin,jn]),ws=m.useCallback((oe,Se,Pe)=>{const wt=RM.includes(oe)?oe:"cursor",Dt=Sb(Se);if(!Dt)return;const Yt=ka(p),Bn=new Set(Yt[wt]);Pe?Bn.delete(Dt):Bn.add(Dt),ys({...Yt,[wt]:Array.from(Bn)})},[p,ys]);m.useEffect(()=>{br(),e!=null&&e.isAdmin?(Kn(),jn(),xn(),qn(),(async()=>{try{const oe=await fetch("/api/agentflow-config");if(oe.ok){const Se=await oe.json(),Pe=typeof Se.opencodeProvider=="string"?Se.opencodeProvider:"";ce(Pe),Je.current=Pe;try{localStorage.setItem(vb,Pe)}catch{}}else{const Se=g_();ce(Se),Je.current=Se}}catch{const oe=g_();ce(oe),Je.current=oe}finally{Ze.current=!0}})()):(o(""),Ze.current=!1)},[e==null?void 0:e.isAdmin,Kn,jn,qn,xn,br]),m.useEffect(()=>{if(!Mt.current||JSON.stringify(Ca(A))===_t.current)return;const Se=setTimeout(()=>{ts(A)},350);return()=>clearTimeout(Se)},[A,ts]),m.useEffect(()=>{if(!(e!=null&&e.isAdmin)||!Ze.current)return;const oe=Z.trim();if(oe===Je.current)return;const Se=setTimeout(()=>{(async()=>{I(!0),H("");try{const Pe=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:oe})}),wt=await Pe.json().catch(()=>({}));if(!Pe.ok)throw new Error(typeof wt.error=="string"?wt.error:"HTTP "+Pe.status);Je.current=oe;try{localStorage.setItem(vb,oe)}catch{}wt.modelLists&&(u(Wi(wt.modelLists)),e!=null&&e.isAdmin?jn():f(Wi(wt.modelLists)))}catch(Pe){H(String(Pe.message||Pe))}finally{I(!1)}})()},450);return()=>clearTimeout(Se)},[e==null?void 0:e.isAdmin,jn,Z]);const dn=e!=null&&e.isAdmin?d:c,sr=dn.cursor.length>0,Ir=dn.opencode.length>0,pn=dn.claudeCode.length>0,Zn=dn.codex.length>0,kr=ka(p),ir={cursor:c.cursor.length,opencode:c.opencode.length,claudeCode:c.claudeCode.length,codex:c.codex.length},jt=m.useCallback((oe,Se,Pe)=>{const wt=Array.isArray(Se)?Se:[];if(!(e!=null&&e.isAdmin))return i.jsx("pre",{className:"af-set-model-preview","aria-label":Pe,children:wt.join(`
|
|
315
|
-
`)});const Dt=new Set(kr[oe]||[]);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:["展示 ",ir[oe]||0," / ",wt.length]}),i.jsx("span",{children:y?"保存中":"取消勾选后从模型下拉隐藏"})]}),i.jsx("div",{className:"af-set-model-visibility-list",children:wt.map(Yt=>{const Bn=Sb(Yt),Dn=!Dt.has(Bn);return i.jsxs("label",{className:"af-set-model-visibility-row",children:[i.jsx("input",{type:"checkbox",checked:Dn,disabled:y,onChange:q=>ws(oe,Yt,q.target.checked)}),i.jsx("span",{children:Yt})]},`${oe}-${Yt}`)})})]})},[e==null?void 0:e.isAdmin,kr,y,ir,ws]),Xt=de.length>0||$e.length>0,Nt=e!=null&&e.isAdmin?A:A.filter(oe=>!gw.has(String((oe==null?void 0:oe.key)||"").trim())),le=e!=null&&e.isAdmin&&te?"global":"user",ve=m.useMemo(()=>A.find(oe=>oe.key===Gu&&(oe.scope||"user")===le)||null,[le,A]),it=m.useMemo(()=>xie((ve==null?void 0:ve.value)||""),[ve==null?void 0:ve.value]),zt=m.useMemo(()=>A.find(oe=>oe.key===Ju&&(oe.scope||"user")===le)||null,[le,A]),Qt=zt!=null&&zt.value?String(zt.value):"30",rn=m.useCallback((oe,Se,Pe)=>{const wt=String(oe||"").trim();if(!wt)return;const Dt=String(Se??"");L(Yt=>{const Bn=Yt.find(Dn=>Dn.key===wt&&(Dn.scope||"user")===Pe);return Dt?Bn?Yt.map(Dn=>Dn.id===Bn.id?{...Dn,value:Dt,scope:Pe}:Dn):[{id:yc(),key:wt,value:Dt,scope:Pe},...Yt]:Yt.filter(Dn=>!(Dn.key===wt&&(Dn.scope||"user")===Pe))})},[]),er=m.useCallback(()=>{const oe=G.trim();if(!oe)return;const Se=[...it,{id:yc(),name:se.trim()||`Key ${it.length+1}`,key:oe,createdAt:new Date().toISOString()}];rn(Gu,y_(Se),le),ue(""),ee("")},[se,it,le,G,rn]),ht=m.useCallback(oe=>{const Se=it.filter(Pe=>Pe.id!==oe);rn(Gu,Se.length?y_(Se):"",le)},[it,le,rn]),sn=m.useCallback(oe=>{const Se=String(oe||"").replace(/[^\d]/g,"");if(!Se){rn(Ju,"",le);return}const Pe=Math.min(1440,Math.max(1,Number(Se)||30));rn(Ju,String(Pe),le)},[le,rn]),Kt=m.useCallback(()=>{var oe;s&&((oe=navigator.clipboard)==null||oe.writeText(s))},[s]),vr=m.useCallback(()=>{const oe=z.trim(),Se=$;if(oe){if(!wie(oe)){O(t("settings:env.invalidKey"));return}if(!(e!=null&&e.isAdmin)&&gw.has(oe)){O("该运行基础设施变量仅管理员可配置。");return}L(Pe=>[{id:yc(),key:oe,value:Se,scope:e!=null&&e.isAdmin&&E?"global":"user"},...Pe]),F(""),W("")}},[e==null?void 0:e.isAdmin,E,z,$,t]),tt=m.useCallback(oe=>{L(Se=>Se.filter(Pe=>Pe.id!==oe))},[]),On=m.useCallback((oe,Se)=>{const Pe=String((Se==null?void 0:Se.key)||"").trim();if(!(e!=null&&e.isAdmin)&&Pe&&gw.has(Pe)){O("该运行基础设施变量仅管理员可配置。");return}L(wt=>wt.map(Dt=>Dt.id===oe?{...Dt,...Se}:Dt))},[e==null?void 0:e.isAdmin]),$i=m.useCallback(oe=>{B(Se=>{const Pe=new Set(Se);return Pe.has(oe)?Pe.delete(oe):Pe.add(oe),Pe})},[]),Br=m.useCallback(()=>{const oe=ot.trim();if(!oe)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(oe)){Oe("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(de.map(Pe=>String(Pe||"").trim().toLowerCase())).has(oe.toLowerCase())){gt("");return}gt(""),Qn([...de,oe])},[ot,de,Qn]),go=m.useCallback(oe=>{const Se=String(oe||"").trim().toLowerCase();Se&&Qn(de.filter(Pe=>String(Pe||"").trim().toLowerCase()!==Se))},[de,Qn]),ai=m.useCallback(oe=>{const Se=oe.target.value;yie(Se)},[]),Ms=oe=>{const Se=kie(oe,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,D?i.jsx("p",{className:"af-err af-settings-api-hint",children:D}):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:Kt,"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"+(sr?" af-set-badge--ok":" af-set-badge--muted"),children:t(sr?"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:sr?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(sr?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:sr?t("settings:cursor.modelList.count",{count:c.cursor.length})+(e!=null&&e.isAdmin?` / ${dn.cursor.length}`:"")+" · "+Ms(c.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),sr?jt("cursor",dn.cursor,t("settings:cursor.modelPreviewLabel")):null,w?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:w}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Pr(),disabled:j,children:t(j?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-cursor-pool",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"key"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"Cursor API Key 池"}),i.jsx("p",{className:"af-set-card-subtitle",children:"按请求轮换,遇到 usage limit 或 resource_exhausted 会自动尝试下一个 Key。"})]})]}),i.jsxs("span",{className:"af-set-badge"+(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:Qt,onChange:oe=>sn(oe.target.value)}),i.jsx("span",{children:"分钟"})]}),i.jsx("span",{className:"af-set-env-note",children:M?"保存中":le==="global"?"全局配置":"个人配置"})]}),i.jsx("div",{className:"af-set-cursor-key-list",children:it.length?it.map(oe=>i.jsxs("div",{className:"af-set-cursor-key-row",children:[i.jsxs("div",{className:"af-set-cursor-key-main",children:[i.jsx("strong",{children:oe.name}),i.jsx("code",{children:bie(oe.key)})]}),i.jsx("span",{className:"af-set-cursor-key-meta",children:oe.createdAt?new Date(oe.createdAt).toLocaleString():"历史 Key"}),i.jsx("button",{type:"button",className:"af-set-env-del af-set-cursor-key-delete","aria-label":`删除 ${oe.name}`,onClick:()=>ht(oe.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},oe.id)):i.jsx("div",{className:"af-set-cursor-key-empty",children:"还没有配置 Key。配置后 Cursor CLI runner 会自动轮换使用。"})}),i.jsxs("div",{className:"af-set-cursor-key-add",children:[i.jsx("input",{className:"af-set-input",value:se,onChange:oe=>ue(oe.target.value),placeholder:"名称,例如 Team Key 1"}),i.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:G,onChange:oe=>ee(oe.target.value),placeholder:"Cursor API Key"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:er,disabled:!G.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"添加 Key"]})]}),i.jsxs("p",{className:"af-set-hint",children:["保存到 ",Gu,";冷却时间保存到 ",Ju,"。个人配置会覆盖全局配置。"]})]}),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"+(Ir?" af-set-badge--ok":" af-set-badge--err"),children:t(Ir?"settings:opencode.status.ready":"settings:opencode.status.notFound")})]}),i.jsx("p",{className:"af-set-p",children:t("settings:opencode.description")}),i.jsxs("div",{children:[i.jsx("label",{className:"af-set-label-sm",htmlFor:"af-opencode-plan",children:t("settings:opencode.provider")}),i.jsx("input",{id:"af-opencode-plan",className:"af-set-input af-set-input--sm af-set-input--mono",type:"text",value:Z,onChange:oe=>ce(oe.target.value),placeholder:t("settings:opencode.providerPlaceholder"),autoComplete:"off"}),C?i.jsx("p",{className:"af-set-hint af-set-hint--inline","aria-live":"polite",children:t("settings:opencode.saving")}):null,R?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:R}):null]}),Ir?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?` / ${dn.opencode.length}`:"")+" · "+Ms(c.opencodeFetchedAt)}),jt("opencode",dn.opencode,t("settings:opencode.modelPreviewLabel"))]}):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Pr(),disabled:j,children:t(j?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),i.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:claudeCode.title")}),i.jsx("span",{className:"af-set-badge"+(pn?" af-set-badge--ok":" af-set-badge--err"),children:t(pn?"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:pn?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(pn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:pn?t("settings:cursor.modelList.count",{count:c.claudeCode.length})+(e!=null&&e.isAdmin?` / ${dn.claudeCode.length}`:"")+" · "+Ms(c.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),i.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),pn?jt("claudeCode",dn.claudeCode,t("settings:claudeCode.modelPreviewLabel")):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Pr(),disabled:j,children:t(j?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),i.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:codex.title")}),i.jsx("span",{className:"af-set-badge"+(Zn?" af-set-badge--ok":" af-set-badge--err"),children:t(Zn?"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:Zn?"check_circle":"hourglass_empty"})}),i.jsxs("div",{children:[i.jsx("p",{className:"af-set-cli-title",children:t(Zn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),i.jsx("p",{className:"af-set-cli-mono",children:Zn?t("settings:cursor.modelList.count",{count:c.codex.length})+(e!=null&&e.isAdmin?` / ${dn.codex.length}`:"")+" · "+Ms(c.codexFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),i.jsx("p",{className:"af-set-p",children:t("settings:codex.description")}),Zn?jt("codex",dn.codex,t("settings:codex.modelPreviewLabel")):null,i.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Pr(),disabled:j,children:t(j?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]})]}):null,i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-env",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"variables"})}),i.jsx("h2",{className:"af-set-h2",children:t("settings:env.title")})]}),i.jsx("span",{className:"af-set-env-note",children:M?t("settings:env.saving"):e!=null&&e.isAdmin?t("settings:env.noteAdmin"):t("settings:env.note")})]}),i.jsxs("div",{className:"af-set-env-rows"+(e!=null&&e.isAdmin?" af-set-env-rows--admin":""),children:[i.jsxs("div",{className:"af-set-env-row af-set-env-row--header","aria-hidden":!0,children:[i.jsx("span",{children:t("settings:env.key")}),e!=null&&e.isAdmin?i.jsx("span",{children:t("settings:env.scope")}):null,i.jsx("span",{children:t("settings:env.value")}),i.jsx("span",{})]}),i.jsxs("div",{className:"af-set-env-row af-set-env-row--draft"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[i.jsx("div",{className:"af-set-env-cell",children:i.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",placeholder:"KEY_NAME",value:z,onChange:oe=>F(oe.target.value),"aria-label":t("settings:env.newKey")})}),e!=null&&e.isAdmin?i.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:i.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[i.jsx("button",{type:"button",className:E?"":"is-active",onClick:()=>Q(!1),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:E?"is-active":"",onClick:()=>Q(!0),children:t("settings:env.global")})]})}):null,i.jsx("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:i.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:"password",placeholder:t("settings:env.newValue"),value:$,onChange:oe=>W(oe.target.value),"aria-label":t("settings:env.newValue")})}),i.jsx("div",{className:"af-set-env-actions",children:i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:vr,disabled:!z.trim(),children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]}),Nt.map(oe=>i.jsxs("div",{className:"af-set-env-row"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[i.jsx("div",{className:"af-set-env-cell",children:i.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",value:oe.key,onChange:Se=>On(oe.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:oe.scope!=="global"?"is-active":"",onClick:()=>On(oe.id,{scope:"user"}),children:t("settings:env.personal")}),i.jsx("button",{type:"button",className:oe.scope==="global"?"is-active":"",onClick:()=>On(oe.id,{scope:"global"}),children:t("settings:env.global")})]})}):null,i.jsxs("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:[i.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:V.has(oe.id)?"text":"password",value:oe.value,onChange:Se=>On(oe.id,{value:Se.target.value}),placeholder:MM(oe.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),i.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>$i(oe.id),"aria-label":V.has(oe.id)?"Hide value":"Show value",children:i.jsx("span",{className:"material-symbols-outlined",children:V.has(oe.id)?"visibility_off":"visibility"})})]}),i.jsx("div",{className:"af-set-env-actions",children:i.jsx("button",{type:"button",className:"af-set-env-del","aria-label":t("settings:env.delete",{key:oe.key}),onClick:()=>tt(oe.id),children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},oe.id))]})]}),e!=null&&e.isAdmin?i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"hard_drive_2"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"AgentFlow Data Root"}),i.jsx("p",{className:"af-set-card-subtitle",children:"配置整个 AgentFlow 数据目录的位置,保存时会迁移当前数据。"})]})]}),i.jsx("span",{className:"af-set-badge"+(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 qn(),disabled:nn||Ot,children:nn?"刷新中...":"刷新"})]}),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:ie,onChange:oe=>ke(oe.target.value),placeholder:"/data1/services/mengmai/agentflow",autoComplete:"off",disabled:!!(be!=null&&be.envLocked)||Ot}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void mr(),"aria-label":"保存 AgentFlow Data Root",disabled:Ot||!!(be!=null&&be.envLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:Ot?"hourglass_empty":"save"})})]}),i.jsxs("p",{className:"af-set-hint",children:["当前目录:",i.jsx("code",{children:(be==null?void 0:be.dataRoot)||ie||"-"}),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:oe=>Ue(oe.target.value),placeholder:"/data1/services/mengmai/agentflow/skills",autoComplete:"off",disabled:!!(be!=null&&be.skillsEnvLocked)||Ot}),i.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void mr(),"aria-label":"保存 AgentFlow Skills Root",disabled:Ot||!!(be!=null&&be.skillsEnvLocked),children:i.jsx("span",{className:"material-symbols-outlined",children:Ot?"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"+(Xt?" af-set-badge--ok":" af-set-badge--muted"),children:t(Xt?"settings:allowlist.enabled":"settings:allowlist.open")}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void xn(),disabled:Te,children:t(Te?"settings:allowlist.refreshing":"common:common.refresh")})]}),xe?i.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:xe}):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:mt?t("settings:allowlist.saving"):t("settings:allowlist.userCount",{count:de.length})})]}),i.jsx("div",{className:"af-allowlist-list",children:de.length>0?de.map(oe=>i.jsxs("div",{className:"af-allowlist-row",children:[i.jsx("span",{className:"af-allowlist-name",children:oe}),i.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>go(oe),"aria-label":t("settings:allowlist.remove",{username:oe}),disabled:mt,children:i.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},oe)):i.jsx("div",{className:"af-allowlist-empty",children:t("settings:allowlist.emptyFile")})}),i.jsxs("div",{className:"af-allowlist-add",children:[i.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",value:ot,onChange:oe=>gt(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&Br()},placeholder:"username",autoComplete:"off"}),i.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:Br,disabled:mt||!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(oe=>i.jsx("code",{children:oe},oe)):i.jsx("span",{children:t("settings:allowlist.emptyEnv")})}),i.jsx("p",{className:"af-set-hint af-set-hint--inline",children:t("settings:allowlist.unionHint")})]})]})]}):null,i.jsxs("section",{className:"af-settings-rail","aria-label":t("settings:title"),children:[e!=null&&e.isAdmin?i.jsxs("div",{className:"af-set-rail-card af-set-rail-card--accent",children:[i.jsxs("div",{className:"af-set-rail-inner",children:[i.jsx("h3",{className:"af-set-rail-h3",children:t("settings:system.title")}),i.jsxs("div",{className:"af-set-health-line",children:[i.jsx("span",{className:"af-set-pulse-dot","aria-hidden":!0}),i.jsx("span",{className:"af-set-health-label",children:t(!a&&!k?"settings:system.normal":"settings:system.abnormal")})]}),i.jsxs("div",{className:"af-set-meter",children:[i.jsxs("div",{className:"af-set-meter-row",children:[i.jsx("span",{children:t("settings:system.cursorModels")}),i.jsx("span",{children:c.cursor.length})]}),i.jsx("div",{className:"af-set-meter-bar",children:i.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.cursor.length>0?12+c.cursor.length*3:4)}%`}})})]}),i.jsxs("div",{className:"af-set-meter",children:[i.jsxs("div",{className:"af-set-meter-row",children:[i.jsx("span",{children:t("settings:system.opencodeModels")}),i.jsx("span",{children:c.opencode.length})]}),i.jsx("div",{className:"af-set-meter-bar",children:i.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.opencode.length>0?12+c.opencode.length*3:4)}%`}})})]}),i.jsxs("div",{className:"af-set-meter",children:[i.jsxs("div",{className:"af-set-meter-row",children:[i.jsx("span",{children:t("settings:system.claudeCodeModels")}),i.jsx("span",{children:c.claudeCode.length})]}),i.jsx("div",{className:"af-set-meter-bar",children:i.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.claudeCode.length>0?12+c.claudeCode.length*3:4)}%`}})})]}),i.jsxs("div",{className:"af-set-meter",children:[i.jsxs("div",{className:"af-set-meter-row",children:[i.jsx("span",{children:t("settings:system.codexModels")}),i.jsx("span",{children:c.codex.length})]}),i.jsx("div",{className:"af-set-meter-bar",children:i.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.codex.length>0?12+c.codex.length*3:4)}%`}})})]})]}),i.jsx("div",{className:"af-set-rail-watermark","aria-hidden":!0,children:i.jsx("span",{className:"material-symbols-outlined",children:"vital_signs"})})]}):null,i.jsxs("div",{className:"af-set-rail-card",children:[i.jsx("h3",{className:"af-set-rail-h3 af-set-rail-h3--sm",children:t("settings:language.title")}),i.jsxs("div",{className:"af-set-language-selector",children:[i.jsx("select",{className:"af-set-input af-set-input--sm",value:r,onChange:ai,"aria-label":t("settings:language.description"),children:gie.map(oe=>i.jsxs("option",{value:oe.code,children:[oe.flag," ",oe.name]},oe.code))}),i.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})})]})})]})}function Sie(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(t))}function jie(e){return e==="thinking"?"Thinking":e==="tool"?"工具":e==="error"?"错误":e==="result"?"结果":"过程"}function Nie(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":t}function Cie({run:e,onClose:t}){const[n,r]=m.useState(null),[s,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState("timeline"),d=m.useCallback(async({quiet:v=!1}={})=>{if(e!=null&&e.runId){v||o(!0),l("");try{const w=new URLSearchParams({runType:e.runType||"pipeline",userId:e.userId||"",flowId:e.flowId||"",flowSource:e.flowSource||"user",runId:e.runId}),g=await fetch(`/api/admin/run-detail?${w.toString()}`),k=await g.json().catch(()=>({}));if(!g.ok)throw new Error(k.error||`HTTP ${g.status}`);r(k)}catch(w){l(String((w==null?void 0:w.message)||w))}finally{v||o(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,e==null?void 0:e.runId,e==null?void 0:e.runType,e==null?void 0:e.userId]);m.useEffect(()=>{r(null),u("timeline"),d()},[d]),m.useEffect(()=>{if((e==null?void 0:e.status)!=="running")return;const v=window.setInterval(()=>{document.hidden||d({quiet:!0})},5e3);return()=>window.clearInterval(v)},[d,e==null?void 0:e.status]);const f=Array.isArray(n==null?void 0:n.events)?n.events:[],p=m.useMemo(()=>f.filter(v=>(v==null?void 0:v.kind)==="thinking"),[f]),h=Array.isArray(n==null?void 0:n.rawLines)?n.rawLines:[],y=c==="thinking"?p:f;return i.jsx("div",{className:"af-admin-run-detail-overlay",role:"presentation",onMouseDown:t,children:i.jsxs("aside",{className:"af-admin-run-detail",role:"dialog","aria-modal":"true","aria-label":"Run 详情",onMouseDown:v=>v.stopPropagation(),children:[i.jsxs("header",{className:"af-admin-run-detail__head",children:[i.jsxs("div",{children:[i.jsxs("span",{className:"af-admin-run-detail__eyebrow",children:[e.runType==="workspace"?"Workspace Run":"Pipeline Run"," · ",Nie(e.status)]}),i.jsx("h2",{children:e.flowId||"Run 详情"}),i.jsxs("p",{children:[e.username||e.userId," · ",i.jsx("code",{children:e.runId})]})]}),i.jsxs("div",{className:"af-admin-run-detail__actions",children:[i.jsx("button",{type:"button",onClick:()=>void d(),disabled:s,title:"刷新详情",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"})}),i.jsx("button",{type:"button",onClick:t,title:"关闭",children:i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),i.jsxs("div",{className:"af-admin-run-detail__tabs",role:"tablist","aria-label":"Run 详情分类",children:[i.jsxs("button",{type:"button",className:c==="timeline"?"is-active":"",onClick:()=>u("timeline"),children:["过程 ",i.jsx("span",{children:f.length})]}),i.jsxs("button",{type:"button",className:c==="thinking"?"is-active":"",onClick:()=>u("thinking"),children:["Thinking ",i.jsx("span",{children:p.length})]}),i.jsxs("button",{type:"button",className:c==="raw"?"is-active":"",onClick:()=>u("raw"),children:["原始日志 ",i.jsx("span",{children:h.length})]})]}),n!=null&&n.truncated?i.jsx("div",{className:"af-admin-run-detail__notice",children:"日志较大,当前展示最新的 512 KB / 2000 条记录。"}):null,a?i.jsx("div",{className:"af-admin-run-detail__error",children:a}):null,s&&!n?i.jsx("div",{className:"af-admin-run-detail__empty",children:"正在读取 Run 详情..."}):null,i.jsx("div",{className:"af-admin-run-detail__body",children:c==="raw"?h.length>0?i.jsx("pre",{className:"af-admin-run-detail__raw",children:h.join(`
|
|
316
|
-
`)}):i.jsx("div",{className:"af-admin-run-detail__empty",children:"这个 Run 没有原始日志。"}):y.length>0?i.jsx("div",{className:"af-admin-run-detail__timeline",children:y.map((v,w)=>i.jsxs("article",{className:`af-admin-run-detail__event is-${v.kind||"process"}`,children:[i.jsxs("div",{className:"af-admin-run-detail__event-meta",children:[i.jsx("time",{children:Sie(v.ts)}),i.jsx("span",{className:`af-admin-run-detail__kind is-${v.kind||"process"}`,children:jie(v.kind)}),i.jsx("span",{children:v.type||"event"}),v.nodeId?i.jsx("code",{children:v.nodeId}):null]}),i.jsx("pre",{children:v.text||"-"})]},v.id||`${v.ts||0}-${w}`))}):i.jsx("div",{className:"af-admin-run-detail__empty",children:c==="thinking"?"该模型或 CLI 没有为这个 Run 输出可记录的 Thinking。":"这个 Run 暂无过程事件。"})})]})})}function Mr(e){return new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Math.max(0,Number(e||0)))}function Hp(e){return`${Math.round(Math.max(0,Math.min(1,Number(e||0)))*100)}%`}function yw(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 _ie(e){const t=String(e||"");return t.includes("-")?t.slice(5):t}function ww(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 Eie(e){const t=String(e||"").trim();return t?t.length>18?t.slice(0,8)+"..."+t.slice(-6):t:"-"}function Aie(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":"未知"}function Pie({authUser:e}){const{navigate:t}=gs(),[n,r]=m.useState(null),[s,o]=m.useState(!1),[a,l]=m.useState(""),[c,u]=m.useState(null),[d,f]=m.useState(null),[p,h]=m.useState([]),[y,v]=m.useState(!1),[w,g]=m.useState(""),k=m.useCallback(async()=>{if(e!=null&&e.isAdmin){o(!0),l("");try{const A=await fetch("/api/admin/usage-dashboard"),L=await A.json().catch(()=>({}));if(!A.ok)throw new Error(typeof L.error=="string"?L.error:"HTTP "+A.status);r(L)}catch(A){r(null),l(String((A==null?void 0:A.message)||A))}finally{o(!1)}}},[e==null?void 0:e.isAdmin]),b=m.useCallback(async A=>{const L=String((A==null?void 0:A.userId)||"").trim();if(!(!(e!=null&&e.isAdmin)||!L)){f({userId:L,username:String((A==null?void 0:A.username)||L)}),h([]),g(""),v(!0);try{const D=new URLSearchParams({userId:L}),O=await fetch(`/api/admin/user-workspaces?${D.toString()}`),M=await O.json().catch(()=>({}));if(!O.ok)throw new Error(M.error||"读取用户 Workspace 失败");f(M.owner||{userId:L,username:String((A==null?void 0:A.username)||L)}),h(Array.isArray(M.workspaces)?M.workspaces:[])}catch(D){g(String(D.message||D))}finally{v(!1)}}},[e==null?void 0:e.isAdmin]),j=m.useCallback(A=>{const L=String((A==null?void 0:A.ownerUserId)||(d==null?void 0:d.userId)||"").trim(),D=String((A==null?void 0:A.id)||"").trim();if(!L||!D)return;const O=new URLSearchParams({flowId:D,flowSource:"user",adminOwnerId:L});A!=null&&A.archived&&O.set("archived","1"),t(`/workspace?${O.toString()}`)},[t,d==null?void 0:d.userId]);m.useEffect(()=>{k()},[k]);const N=Array.isArray(n==null?void 0:n.dailyTrend)?n.dailyTrend:[],C=m.useMemo(()=>{const D={top:20,right:24,bottom:42,left:42},O=980-D.left-D.right,M=250-D.top-D.bottom,K=N.length>0?N:[],z=Math.max(1,...K.map(V=>Number(V.runs||0))),F=Math.max(1,...K.flatMap(V=>[Number(V.users||0),Number(V.pipelines||0)])),$=V=>D.left+(K.length<=1?O/2:V*O/(K.length-1)),W=V=>D.top+M-Math.max(0,Number(V||0))/z*M,E=V=>D.top+M-Math.max(0,Number(V||0))/F*M,Q=V=>K.map((B,se)=>`${se===0?"M":"L"} ${$(se)} ${E(B[V])}`).join(" ");return{width:980,height:250,margin:D,innerHeight:M,rows:K,x:$,yRuns:W,yLine:E,lineUsers:Q("users"),linePipelines:Q("pipelines"),barWidth:Math.min(34,Math.max(12,O/Math.max(1,K.length)*.44))}},[N]),I=(n==null?void 0:n.usage)||{},R=(n==null?void 0:n.totals)||{},H=Array.isArray(n==null?void 0:n.recentRuns)?n.recentRuns:[];return e!=null&&e.isAdmin?i.jsxs("main",{className:"af-admin-usage-page",children:[i.jsxs("section",{className:"af-admin-usage-hero",children:[i.jsxs("div",{children:[i.jsx("p",{className:"af-admin-usage-eyebrow",children:"Admin / Usage"}),i.jsx("h1",{children:"管理看板"}),i.jsx("p",{children:"重点观察使用率、每日趋势、成功率与各用户流水线活跃度。"})]}),i.jsxs("button",{type:"button",onClick:()=>void k(),disabled:s,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),s?"刷新中":"刷新"]})]}),a?i.jsx("div",{className:"af-project-admin-usage__error",children:a}):null,i.jsxs("section",{className:"af-admin-usage-rate-grid","aria-label":"使用率",children:[i.jsxs("div",{children:[i.jsx("span",{children:"7日活跃用户率"}),i.jsx("strong",{children:Hp(I.activeUserRate)}),i.jsxs("em",{children:[Mr(I.activeUsers)," / ",Mr(R.users)," users"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日流水线使用率"}),i.jsx("strong",{children:Hp(I.activePipelineRate)}),i.jsxs("em",{children:[Mr(I.activePipelines)," / ",Mr(R.activePipelines)," active"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日 Run"}),i.jsx("strong",{children:Mr(I.runs)}),i.jsxs("em",{children:[Mr(I.avgRunsPerDay)," / day"]})]}),i.jsxs("div",{children:[i.jsx("span",{children:"7日成功率"}),i.jsx("strong",{children:Hp(I.successRate)}),i.jsxs("em",{children:["失败率 ",Hp(I.failureRate)," · avg ",yw(I.avgDurationMs)]})]})]}),i.jsxs("section",{className:"af-project-admin-usage af-admin-usage-trend",children:[i.jsx("div",{className:"af-project-admin-usage__head",children:i.jsxs("div",{children:[i.jsx("strong",{children:"每日趋势"}),i.jsx("span",{children:"上方看趋势,下方看最近 50 次具体运行。"})]})}),i.jsxs("div",{className:"af-admin-usage-chart",role:"img","aria-label":"最近 14 天运行趋势",children:[i.jsxs("div",{className:"af-admin-usage-chart__legend",children:[i.jsxs("span",{children:[i.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--runs"}),"Runs"]}),i.jsxs("span",{children:[i.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--users"}),"活跃用户"]}),i.jsxs("span",{children:[i.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--pipelines"}),"活跃流水线"]})]}),i.jsx("div",{className:"af-admin-usage-chart__canvas",children:i.jsxs("svg",{viewBox:`0 0 ${C.width} ${C.height}`,preserveAspectRatio:"xMidYMid meet",children:[i.jsx("line",{className:"af-admin-usage-chart__axis",x1:C.margin.left,y1:C.margin.top+C.innerHeight,x2:C.width-C.margin.right,y2:C.margin.top+C.innerHeight}),[.25,.5,.75,1].map(A=>i.jsx("line",{className:"af-admin-usage-chart__grid",x1:C.margin.left,y1:C.margin.top+C.innerHeight-C.innerHeight*A,x2:C.width-C.margin.right,y2:C.margin.top+C.innerHeight-C.innerHeight*A},A)),C.rows.map((A,L)=>{const D=C.x(L),O=C.yRuns(A.runs),M=C.margin.top+C.innerHeight,K=Math.max(2,M-O);return i.jsxs("g",{children:[i.jsx("rect",{className:"af-admin-usage-chart__run-bar",x:D-C.barWidth/2,y:M-K,width:C.barWidth,height:K,rx:"5",children:i.jsx("title",{children:`${A.date}: ${A.runs} runs`})}),i.jsx("text",{className:"af-admin-usage-chart__value",x:D,y:M+22,children:Mr(A.runs)}),i.jsx("text",{className:"af-admin-usage-chart__date",x:D,y:M+42,children:_ie(A.date)})]},A.date)}),C.rows.length>0?i.jsxs(i.Fragment,{children:[i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--users",d:C.lineUsers}),i.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--pipelines",d:C.linePipelines}),C.rows.map((A,L)=>{const D=C.x(L);return i.jsxs("g",{children:[i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--users",cx:D,cy:C.yLine(A.users),r:"3.5"}),i.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--pipelines",cx:D,cy:C.yLine(A.pipelines),r:"3.5"})]},`${A.date}-points`)})]}):null]})})]}),i.jsx("div",{className:"af-project-admin-usage__table-wrap",children:i.jsxs("table",{className:"af-project-admin-usage__table af-admin-usage-table--recent",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"用户"}),i.jsx("th",{children:"流水线"}),i.jsx("th",{children:"运行时间"}),i.jsx("th",{children:"状态"}),i.jsx("th",{children:"耗时"}),i.jsx("th",{children:"Run ID"})]})}),i.jsx("tbody",{children:H.length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:6,children:"暂无运行明细"})}):H.map(A=>i.jsxs("tr",{className:"af-admin-usage-run-row",role:"button",tabIndex:0,title:"查看 Run 过程与 Thinking",onClick:()=>u(A),onKeyDown:L=>{(L.key==="Enter"||L.key===" ")&&(L.preventDefault(),u(A))},children:[i.jsxs("td",{children:[i.jsx("strong",{children:A.username||A.userId||"-"}),i.jsx("span",{children:A.userId||"-"})]}),i.jsxs("td",{children:[i.jsx("strong",{children:A.flowId||"-"}),i.jsxs("span",{children:[A.runType==="workspace"?"Workspace Run":"Pipeline"," · ",A.flowSource||"user"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:ww(A.at)}),A.endedAt?i.jsxs("span",{children:["结束 ",ww(A.endedAt)]}):i.jsx("span",{children:"未结束"})]}),i.jsx("td",{children:i.jsx("span",{className:"af-project-admin-usage__chips",children:i.jsx("em",{children:Aie(A.status)})})}),i.jsx("td",{children:yw(A.durationMs)}),i.jsx("td",{children:i.jsxs("span",{className:"af-admin-usage-run-link",children:[i.jsx("code",{className:"af-admin-usage-run-id",title:A.runId,children:Eie(A.runId)}),i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})})]},`${A.userId}:${A.flowSource}:${A.flowId}:${A.runId}:${A.at}`))})]})})]}),i.jsxs("section",{className:"af-project-admin-usage",children:[i.jsx("div",{className:"af-project-admin-usage__head",children:i.jsxs("div",{children:[i.jsx("strong",{children:"用户使用明细"}),i.jsx("span",{children:"按用户汇总 Pipeline 数、Run 次数和最近运行。"})]})}),i.jsx("div",{className:"af-project-admin-usage__table-wrap",children:i.jsxs("table",{className:"af-project-admin-usage__table",children:[i.jsx("thead",{children:i.jsxs("tr",{children:[i.jsx("th",{children:"User"}),i.jsx("th",{children:"Pipeline"}),i.jsx("th",{children:"Runs"}),i.jsx("th",{children:"状态"}),i.jsx("th",{children:"最近运行"}),i.jsx("th",{children:"Workspace"})]})}),i.jsx("tbody",{children:s&&!n?i.jsx("tr",{children:i.jsx("td",{colSpan:6,children:"正在加载..."})}):((n==null?void 0:n.users)||[]).length===0?i.jsx("tr",{children:i.jsx("td",{colSpan:6,children:"暂无用户数据"})}):((n==null?void 0:n.users)||[]).map(A=>{var L,D,O,M,K,z,F,$,W,E,Q,V,B;return i.jsxs("tr",{children:[i.jsxs("td",{children:[i.jsx("strong",{children:A.username||A.userId}),i.jsxs("span",{children:[A.userId,A.isAdmin?" · admin":""]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Mr((L=A.pipelines)==null?void 0:L.total)}),i.jsxs("span",{children:[Mr((D=A.pipelines)==null?void 0:D.active)," active / ",Mr((O=A.pipelines)==null?void 0:O.archived)," archived"]})]}),i.jsxs("td",{children:[i.jsx("strong",{children:Mr((M=A.runs)==null?void 0:M.total)}),i.jsxs("span",{children:["avg ",yw((K=A.runs)==null?void 0:K.avgDurationMs)]})]}),i.jsx("td",{children:i.jsxs("span",{className:"af-project-admin-usage__chips",children:[i.jsxs("em",{children:["成功 ",Mr((z=A.runs)==null?void 0:z.success)]}),i.jsxs("em",{children:["失败 ",Mr((F=A.runs)==null?void 0:F.failed)]}),i.jsxs("em",{children:["运行中 ",Mr(($=A.runs)==null?void 0:$.running)]})]})}),i.jsx("td",{children:(W=A.runs)!=null&&W.lastRunAt?i.jsxs(i.Fragment,{children:[i.jsx("strong",{children:((E=A.runs)==null?void 0:E.lastRunFlowId)||"-"}),i.jsxs("span",{children:[((Q=A.runs)==null?void 0:Q.lastRunStatus)||"unknown"," · ",ww(A.runs.lastRunAt)]})]}):i.jsx("span",{children:"无运行记录"})}),i.jsx("td",{children:i.jsxs("button",{type:"button",className:"af-admin-workspace-review-button",disabled:!((V=A.pipelines)!=null&&V.total)||y&&(d==null?void 0:d.userId)===A.userId,onClick:()=>void b(A),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),y&&(d==null?void 0:d.userId)===A.userId?"读取中":`查看 ${Mr((B=A.pipelines)==null?void 0:B.total)}`]})})]},A.userId)})})]})})]}),d?i.jsxs("section",{className:"af-project-admin-usage af-admin-user-workspaces",children:[i.jsxs("div",{className:"af-project-admin-usage__head",children:[i.jsxs("div",{children:[i.jsxs("strong",{children:[d.username||d.userId," 的 Workspace"]}),i.jsx("span",{children:"管理员审阅模式:只读查看,不会加入协作成员,也不能保存或运行。"})]}),i.jsx("button",{type:"button",onClick:()=>{f(null),h([]),g("")},children:"关闭"})]}),w?i.jsx("div",{className:"af-project-admin-usage__error",children:w}):null,i.jsx("div",{className:"af-admin-user-workspaces__grid",children:y?i.jsx("p",{children:"正在读取 Workspace..."}):p.length===0?i.jsx("p",{children:"该用户暂无 Workspace。"}):p.map(A=>i.jsxs("button",{type:"button",className:"af-admin-user-workspace-card",onClick:()=>j(A),children:[i.jsx("span",{className:"af-admin-user-workspace-card__icon material-symbols-outlined","aria-hidden":!0,children:A.archived?"inventory_2":"account_tree"}),i.jsxs("span",{className:"af-admin-user-workspace-card__content",children:[i.jsx("strong",{children:A.id}),i.jsx("small",{children:A.description||(A.archived?"已归档 Workspace":"用户 Workspace")})]}),i.jsx("span",{className:"af-admin-user-workspace-card__status",children:A.archived?"已归档":"只读打开"})]},`${A.id}:${A.archived?"archived":"active"}`))})]}):null,c?i.jsx(Cie,{run:c,onClose:()=>u(null)}):null]}):i.jsx("main",{className:"af-admin-usage-page",children:i.jsx("section",{className:"af-project-admin-usage",children:i.jsx("div",{className:"af-project-admin-usage__head",children:i.jsxs("div",{children:[i.jsx("strong",{children:"管理看板"}),i.jsx("span",{children:"需要管理员权限。"})]})})})})}function Iie(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 Rie({authUser:e}){const{navigate:t}=gs(),[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),[w,g]=m.useState(""),k=!!(e!=null&&e.isAdmin),b=m.useCallback(async()=>{if(k){v(!0),g("");try{const N=await fetch("/api/feedback"),C=await N.json().catch(()=>({}));if(!N.ok)throw new Error(C.error||"加载失败");h(Array.isArray(C.feedback)?C.feedback:[])}catch(N){g(String(N.message||N)),h([])}finally{v(!1)}}},[k]);m.useEffect(()=>{b()},[b]);const j=async N=>{if(N.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})}),I=await C.json().catch(()=>({}));if(!C.ok)throw new Error(I.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 b(),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"}),"返回"]})]})]}),w?i.jsx("p",{className:"af-err af-feedback-error",children:w}):null,i.jsx("div",{className:"af-feedback-list af-feedback-list--page",children:p.length>0?p.map(N=>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:N.title||"未命名反馈"}),i.jsxs("p",{children:[i.jsx("span",{children:N.username||N.userId||"unknown"}),i.jsx("span",{children:Iie(N.createdAt)})]})]}),N.contact?i.jsx("span",{className:"af-feedback-item__contact",children:N.contact}):null]}),i.jsx("p",{className:"af-feedback-item__content",children:N.content}),N.pageUrl?i.jsx("code",{className:"af-feedback-item__url",children:N.pageUrl}):null]},N.id)):i.jsx("div",{className:"af-feedback-empty",children:y?"正在加载反馈...":"暂无反馈"})})]})}):i.jsx("main",{className:"af-feedback-page",children:i.jsxs("section",{className:"af-feedback-panel",children:[i.jsxs("div",{className:"af-feedback-head",children:[i.jsxs("div",{children:[i.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),i.jsx("h1",{children:"意见反馈"}),i.jsx("p",{children:"提交使用中遇到的问题、改进建议或功能需求,管理员会在这里统一查看。"})]}),i.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>t("/projects"),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]}),d?i.jsxs("div",{className:"af-feedback-success",role:"status",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),i.jsxs("div",{children:[i.jsx("strong",{children:"已提交"}),i.jsx("span",{children:"感谢反馈,管理员可以在意见反馈页查看这条记录。"})]})]}):null,i.jsxs("form",{className:"af-feedback-form",onSubmit:j,children:[i.jsxs("label",{className:"af-feedback-field",children:[i.jsx("span",{children:"标题"}),i.jsx("input",{value:n,onChange:N=>r(N.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:N=>o(N.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 $M(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function w_(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:$M(),key:r,value:String(s??""),private:n.has(r)}))}function x_(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 yh(e=null){const t=e!=null&&e.raw&&typeof e.raw=="object"?e.raw:{},n=Array.isArray(t.args)?t.args:Array.isArray(e==null?void 0:e.args)?e.args:[];return{originalName:String((e==null?void 0:e.name)||""),name:String((e==null?void 0:e.name)||""),type:e!=null&&e.url||t.url?"url":"command",url:String((e==null?void 0:e.url)||t.url||""),command:String((e==null?void 0:e.command)||t.command||""),argsText:n.map(String).join(`
|
|
317
|
-
`),description:String((e==null?void 0:e.description)||t.description||""),envRows:w_(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:w_(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 xw(){return yh({name:"",raw:{command:""}})}function Tie(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=x_(e.envRows),s=x_(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 b_(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function k_(e){return e?e.ok?"ok":"error":"unknown"}function jb(e){return e==="ok"?"ok":e==="partial"?"partial":e==="unsupported"?"error":"unknown"}function Mie(e,t){return e&&e.label||t}async function bw(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 Sv(e){return String(e||"").trim()||"<AGENTFLOW_TOKEN>"}function LM({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:Sv(t)}}}},null,2)}function OM({baseUrl:e="",token:t=""}){const n=JSON.stringify(String(e||"http://127.0.0.1:8875")),r=JSON.stringify(Sv(t));return["[mcp_servers.agentflow]",'command = "agentflow"','args = ["mcp"]',"","[mcp_servers.agentflow.env]",`AGENTFLOW_BASE_URL = ${n}`,`AGENTFLOW_TOKEN = ${r}`].join(`
|
|
318
|
-
`)}function $ie({baseUrl:e="",token:t=""}){const n=String(e||"http://127.0.0.1:8875"),r=LM({baseUrl:n,token:t}),s=OM({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: ${Sv(t)}`,"","Cursor 配置片段(合并到 .cursor/mcp.json 或 ~/.cursor/mcp.json):","```json",r,"```","","Codex 配置片段(合并到 ~/.codex/config.toml 的 mcp_servers 配置):","```toml",s,"```","","配置要求:","1. 先判断当前仓库主要使用 Cursor、Codex,还是两者都需要配置。","2. 不要覆盖已有 MCP server;只新增或更新名为 `agentflow` 的 server。","3. 保留已有配置文件里的其他字段、注释和 server。","4. 如果配置文件不存在,请创建父目录和配置文件。","5. 不要把 token 打印到最终回复里;如果需要说明,只写 `AGENTFLOW_TOKEN 已写入配置`。","6. 如果 token 仍是 `<AGENTFLOW_TOKEN>` 占位符,请提醒用户需要在配置文件中替换成真实 token,或回到 AgentFlow 的 MCP 页面点击“使用当前登录 Token”后重新复制。","7. 如果外部 Agent 启动 MCP 时找不到 `agentflow` 命令,请把 command 改成本机 agentflow 可执行文件的绝对路径,或先把 agentflow 安装/软链到 PATH。","","配置后验证:","- 如果配置使用 `command: agentflow`,确认外部 Agent 所在环境可以执行这个命令;如果使用绝对路径,则确认路径存在且可执行。","- 通过 MCP 客户端刷新或重启后,确认 `agentflow` server 出现在 MCP server 列表。","- 如果可以做工具探测,只验证 `tools/list` 能看到 `agentflow_list_flows`、`agentflow_run_flow`、`agentflow_get_display_outputs`。","","最终回复只需要说明:配置了哪些文件、是否验证成功、如果失败下一步该检查什么。"].join(`
|
|
319
|
-
`)}function Lie({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--${jb(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:Mie(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 v_({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:$M(),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 Oie(){var ue;const[e,t]=m.useState(""),[n,r]=m.useState([]),[s,o]=m.useState(xw),[a,l]=m.useState(""),[c,u]=m.useState(!1),[d,f]=m.useState(!1),[p,h]=m.useState(!1),[y,v]=m.useState({}),[w,g]=m.useState(""),[k,b]=m.useState(""),[j,N]=m.useState(()=>{var G;return typeof window<"u"&&((G=window.location)!=null&&G.origin)?window.location.origin:"http://127.0.0.1:8875"}),[C,I]=m.useState(""),[R,H]=m.useState(""),A=m.useMemo(()=>n.find(G=>G.name===a)||null,[a,n]),L=A&&y[A.name]||null,D=m.useMemo(()=>LM({baseUrl:j,token:C}),[j,C]),O=m.useMemo(()=>OM({baseUrl:j,token:C}),[j,C]),M=m.useMemo(()=>$ie({baseUrl:j,token:C}),[j,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(yh(te.find(ne=>ne.name===a)))}catch(G){g(String(G.message||G))}finally{u(!1)}},[a]);m.useEffect(()=>{K()},[K]);const z=()=>{l(""),o(xw()),b(""),g("")},F=G=>{l(G.name),o(yh(G)),b(""),g("")},$=m.useCallback(async()=>{if(!M)return;const G=await bw(M);H(G?"prompt":"copy-failed"),window.setTimeout(()=>H(""),1200)},[M]),W=m.useCallback(async()=>{const G=await bw(D);H(G?"cursor":"copy-failed"),window.setTimeout(()=>H(""),1200)},[D]),E=m.useCallback(async()=>{const G=await bw(O);H(G?"codex":"copy-failed"),window.setTimeout(()=>H(""),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);I(String(ee.token||"")),H("token"),window.setTimeout(()=>H(""),1200)}catch(G){H(""),g(String(G.message||G))}},[]),V=async(G="")=>{h(!0),g(""),b("");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}),b(G?`已检测 ${G}。`:"已检测所有 MCP。")}catch(ee){g(String(ee.message||ee))}finally{h(!1)}},B=async()=>{f(!0),g(""),b("");try{const G=Tie(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(yh(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}),b("已保存。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(""),b("");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(xw()),v(ne=>{const Z={...ne};return delete Z[G.name],Z}),b("已删除。")}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:z,disabled:d,children:"新增 MCP"})]})]}),i.jsx("div",{className:"af-settings-body",children:i.jsxs("div",{className:"af-settings-inner",children:[i.jsxs("section",{className:"af-settings-hero",children:[i.jsx("h1",{className:"af-settings-h1",children:"MCP 管理"}),i.jsx("p",{className:"af-settings-lead",children:"管理 AgentFlow 暴露给外部 Agent 的 MCP 接入方式,以及 AgentFlow 自身可调用的外部 MCP server。"})]}),i.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-mcp-personal",children:[i.jsxs("div",{className:"af-set-env-head",children:[i.jsxs("div",{className:"af-set-card-head",children:[i.jsx("div",{className:"af-set-env-icon-wrap",children:i.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"lan"})}),i.jsxs("div",{children:[i.jsx("h2",{className:"af-set-h2",children:"我的 MCP"}),i.jsx("p",{className:"af-set-card-subtitle",children:"给 Cursor、Codex 等外部 Agent 配置 AgentFlow MCP,用来运行流程并读取 display 结果。"})]})]}),i.jsx("span",{className:"af-set-badge af-set-badge--ok",children:"AgentFlow as MCP"})]}),i.jsx("p",{className:"af-set-hint",children:"这里生成的是让其他 Agent 连接本平台的配置;下方“外部 MCP Servers”管理的是 AgentFlow 运行时可调用的外部工具。"}),i.jsxs("div",{className:"af-set-mcp-connect-grid",children:[i.jsxs("label",{className:"af-set-mcp-field",children:[i.jsx("span",{children:"Base URL"}),i.jsx("input",{className:"af-set-input af-set-input--mono",value:j,onChange:G=>N(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=>I(G.target.value),placeholder:"<AGENTFLOW_TOKEN>"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:Q,children:R==="token"?"已填入":"使用当前登录 Token"})]})]})]}),i.jsxs("div",{className:"af-set-mcp-snippet-grid",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"af-set-mcp-snippet-head",children:[i.jsx("span",{children:"Cursor mcp.json"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:W,children:R==="cursor"?"已复制":R==="copy-failed"?"复制失败":"复制"})]}),i.jsx("pre",{className:"af-set-mcp-code",children:D})]}),i.jsxs("div",{children:[i.jsxs("div",{className:"af-set-mcp-snippet-head",children:[i.jsx("span",{children:"Codex config.toml"}),i.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:E,children:R==="codex"?"已复制":R==="copy-failed"?"复制失败":"复制"})]}),i.jsx("pre",{className:"af-set-mcp-code",children:O})]})]}),i.jsx("div",{className:"af-set-mcp-copy-row",children:i.jsxs("button",{type:"button",className:"af-set-footer-primary",onClick:$,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),R==="prompt"?"已复制 Prompt":R==="copy-failed"?"复制失败":"复制 AI 配置 Prompt"]})}),R==="copy-failed"?i.jsx("p",{className:"af-mcp-error",children:"浏览器禁止访问剪贴板,请手动选中下面的 Prompt 复制。"}):null,i.jsx("label",{className:"af-set-label-sm",htmlFor:"af-mcp-ai-prompt",children:"AI 配置 Prompt"}),i.jsx("textarea",{id:"af-mcp-ai-prompt",className:"af-set-input af-set-input--mono af-set-mcp-prompt",rows:12,readOnly:!0,value:M})]}),i.jsxs("section",{className:"af-settings-hero af-settings-hero--compact",children:[i.jsx("h2",{className:"af-settings-h2",children:"外部 MCP Servers"}),i.jsxs("p",{className:"af-settings-lead",children:["新增、编辑和删除 AgentFlow 可调用的外部 MCP server。当前配置文件:",i.jsx("span",{className:"af-settings-code",children:e||"~/.cursor/mcp.json"})]})]}),i.jsxs("div",{className:"af-mcp-layout",children:[i.jsxs("section",{className:"af-set-card af-mcp-list-card",children:[i.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[i.jsx("h2",{className:"af-set-h2",children:"Servers"}),i.jsxs("div",{className:"af-mcp-list-head-actions",children:[i.jsx("span",{className:"af-set-badge af-set-badge--muted",children:n.length}),i.jsxs("button",{type:"button",className:"af-set-btn-mini",onClick:z,disabled:d,children:[i.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]})]}),c?i.jsx("p",{className:"af-set-p",children:"加载中..."}):null,n.length===0&&!c?i.jsxs("div",{className:"af-mcp-empty",children:[i.jsx("p",{className:"af-set-p",children:"暂无 MCP server。"}),i.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:z,disabled:d,children:"新增 MCP Server"})]}):null,i.jsx("div",{className:"af-mcp-server-list",children:n.map(G=>{var ee,te,ne,Z;return i.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===G.name?" af-mcp-server-item--active":""),onClick:()=>F(G),children:[i.jsx("span",{className:"material-symbols-outlined",children:G.type==="url"?"cloud":"terminal"}),i.jsxs("span",{children:[i.jsxs("span",{className:"af-mcp-server-title",children:[i.jsx("strong",{children:G.name}),i.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${k_(y[G.name])}`,children:b_(y[G.name])})]}),i.jsxs("span",{className:"af-mcp-server-backends",children:[i.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${jb((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--${jb((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:A?"编辑 MCP":"新增 MCP"}),i.jsx("p",{className:"af-set-p af-set-p--tight",children:"保存后会写入 Cursor MCP 配置。已运行的 agent 进程不会热更新,下一次启动会读取新配置。"})]}),A?i.jsxs("div",{className:"af-mcp-editor-actions",children:[i.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>V(A.name),disabled:p||d,children:p?"检测中...":"检测"}),i.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>se(A),disabled:d,children:"删除"})]}):null]}),w?i.jsx("p",{className:"af-mcp-error",children:w}):null,k?i.jsx("p",{className:"af-mcp-status",children:k}):null,A?i.jsx(Lie,{server:A}):null,L?i.jsxs("div",{className:`af-mcp-check af-mcp-check--${k_(L)}`,children:[i.jsxs("div",{className:"af-mcp-check-head",children:[i.jsx("strong",{children:b_(L)}),i.jsxs("span",{children:[L.elapsedMs||0,"ms"]})]}),L.error?i.jsx("p",{children:L.error}):null,(ue=L.tools)!=null&&ue.length?i.jsx("div",{className:"af-mcp-tools-list",children:L.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
|
|
320
|
-
--flag`})]})]}),i.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["描述",i.jsx("input",{className:"af-set-input",value:s.description,onChange:G=>o(ee=>({...ee,description:G.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),i.jsx(v_,{title:"Headers",rows:s.headerRows,onChange:G=>o(ee=>({...ee,headerRows:G})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),i.jsx(v_,{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:z,disabled:d,children:"清空"}),i.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:B,disabled:d,children:d?"保存中...":"保存 MCP"})]})]})]})]})})]})}function Die(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 S_(e={}){return(e==null?void 0:e.kind)==="workspace"&&String((e==null?void 0:e.scheduleNodeId)||"").trim()?"打开节点":"打开项目"}function j_(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 Fie(e){return(e==null?void 0:e.kind)==="workspace"?"Workspace":"Pipeline"}function zie(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 Bie(){const{navigate:e}=gs(),[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=Die(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:Fie(p)}),i.jsx("span",{className:`af-schedule-state ${p.enabled?"af-schedule-state--on":"af-schedule-state--off"}`,children:zie(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:j_(p.nextRunAt)})]}),i.jsxs("div",{children:[i.jsx("span",{children:"最近执行"}),i.jsx("strong",{children:j_(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:S_(p),onClick:()=>e(v),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),S_(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 N_={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 C_(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 Hie(e){var c,u,d,f,p,h,y,v,w,g,k,b;const t=(e==null?void 0:e.manifest)||{},n=(e==null?void 0:e.files)||{},r=Array.isArray(t.inputs)?t.inputs:[],s=Array.isArray(t.outputs)?t.outputs:[],o=Array.isArray((c=t.configSchema)==null?void 0:c.fields)?t.configSchema.fields:[],a=Array.isArray((d=(u=t.ui)==null?void 0:u.card)==null?void 0:d.actions)?t.ui.card.actions:[],l=(f=e==null?void 0:e.test)!=null&&f.inputs&&typeof e.test.inputs=="object"?e.test.inputs:{};return[{id:"contract",label:"Contract",icon:"account_tree",rows:[...r.map(j=>[`input.${j.name||"-"}`,`${j.type||"text"}${j.required?" · required":""}${j.default?` · default: ${j.default}`:""}`]),...s.map(j=>[`output.${j.name||"-"}`,j.type||"text"]),...o.map(j=>[`config.${j.key||"-"}`,j.type||"text"])]},{id:"runtime",label:"Runtime",icon:"terminal",rows:[["runtime.type",((p=t.runtime)==null?void 0:p.type)||t.baseDefinitionId||"tool_nodejs"],["runtime.entry",((h=t.runtime)==null?void 0:h.entry)||"scripts/run.mjs"],["prompt.md",n["prompt.md"]||"-"],["implementation.md",n["implementation.md"]||"-"]]},{id:"ui",label:"UI",icon:"dashboard_customize",rows:[["card.variant",((v=(y=t.ui)==null?void 0:y.card)==null?void 0:v.variant)||"default"],["card.icon",((g=(w=t.ui)==null?void 0:w.card)==null?void 0:g.icon)||"extension"],...a.map(j=>[`action.${j.id||j.label||"-"}`,j.variant||j.label||"secondary"])]},{id:"tests",label:"Tests",icon:"science",rows:[...Object.entries(l).map(([j,N])=>[`sample.${j}`,String(N)]),["last run",`${((k=e==null?void 0:e.test)==null?void 0:k.status)||"not run"}${(b=e==null?void 0:e.test)!=null&&b.durationMs?` · ${e.test.durationMs}ms`:""}`]]}]}function Wie(){var O,M,K,z,F,$,W;const[e,t]=m.useState(null),[n,r]=m.useState("runtime"),[s,o]=m.useState(!1),[a,l]=m.useState(!0),[c,u]=m.useState(""),[d,f]=m.useState(!1),[p,h]=m.useState(""),y=e||N_,v=m.useMemo(()=>Hie(y),[y]),w=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)||{},b=((O=y==null?void 0:y.test)==null?void 0:O.inputs)||{},j=Array.isArray((M=y==null?void 0:y.test)==null?void 0:M.log)?y.test.log:[],N=((z=(K=g.ui)==null?void 0:K.card)==null?void 0:z.icon)||"event_repeat",C=(($=(F=g.ui)==null?void 0:F.card)==null?void 0:$.variant)||"default",I=k.enabled===!0,R=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(()=>{R()},[R]);const H=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]),A=()=>{o(!0),window.setTimeout(()=>o(!1),900)},L=E=>{const Q={...k,enabled:E};t(V=>({...V||N_,config:Q})),H({config:{enabled:E}})},D=()=>{H({promptDraft:p,appendUserMessage:!0})};return i.jsxs("div",{className:"af-node-studio-page",children:[i.jsxs("header",{className:"af-node-studio-top",children:[i.jsxs("div",{children:[i.jsxs("div",{className:"af-settings-crumb",children:[i.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),i.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:"Node Studio"})]}),i.jsx("h1",{children:"节点编辑器"})]}),i.jsxs("div",{className:"af-node-studio-actions",children:[i.jsxs("button",{type:"button",onClick:()=>void R(),disabled:a,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),a?"Loading":"Preview"]}),i.jsxs("button",{type:"button",onClick:A,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:s?"sync":"science"}),"Test"]}),i.jsxs("button",{type:"button",className:"af-node-studio-actions__primary",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"publish"}),"Publish"]})]})]}),i.jsxs("main",{className:"af-node-studio-shell",children:[i.jsxs("aside",{className:"af-node-studio-agent","aria-label":"AI Agent",children:[i.jsxs("div",{className:"af-node-studio-panel-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"}),i.jsx("strong",{children:"AI Agent"})]}),c?i.jsx("div",{className:"af-node-studio-error",children:c}):null,i.jsxs("div",{className:"af-node-studio-thread",children:[e?null:i.jsx("div",{className:"af-node-studio-empty",children:"还没有节点草稿。描述你要创建的节点,发送后会创建一个新的 draft。"}),(Array.isArray(y==null?void 0:y.agentMessages)?y.agentMessages:[]).map((E,Q)=>i.jsx("div",{className:E.role==="user"?"af-node-studio-message af-node-studio-message--user":"af-node-studio-message",children:E.text||""},`${E.role||"message"}-${Q}`)),i.jsxs("div",{className:"af-node-studio-agent-tools",children:[i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"edit"}),"修改 UI"]}),i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"code"}),"改脚本"]}),i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"bug_report"}),"修复报错"]})]})]}),i.jsxs("label",{className:"af-node-studio-prompt",children:[i.jsx("span",{children:"需求"}),i.jsx("textarea",{value:p,onChange:E=>h(E.target.value)})]}),i.jsxs("button",{type:"button",className:"af-node-studio-send",onClick:D,disabled:d,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:d?"sync":"send"}),d?"Saving":"Send"]})]}),i.jsxs("section",{className:"af-node-studio-preview","aria-label":"Preview and Test",children:[i.jsxs("div",{className:"af-node-studio-panel-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"view_in_ar"}),i.jsx("strong",{children:"Preview / Test"})]}),i.jsxs("div",{className:"af-node-studio-preview-grid",children:[i.jsx("div",{className:"af-node-studio-preview-stage",children:e?C==="schedule"?i.jsxs("div",{className:"af-node-preview-card",children:[i.jsxs("div",{className:"af-node-preview-card__head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:N}),i.jsx("strong",{children:y.title||g.name||"Untitled Node"}),i.jsx("code",{children:C_(y)})]}),i.jsxs("label",{className:"af-node-preview-toggle",children:[i.jsx("input",{type:"checkbox",checked:I,onChange:E=>L(E.target.checked)}),i.jsx("span",{children:I?"定时开启":"定时关闭"})]}),i.jsxs("div",{className:"af-node-preview-fields",children:[i.jsxs("label",{children:[i.jsx("span",{children:"频率"}),i.jsxs("select",{value:k.scheduleType||"daily",onChange:E=>H({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=>H({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=>H({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:I?"enabled":"disabled"})]}),i.jsxs("div",{className:"af-node-preview-actions",children:[i.jsxs("button",{type:"button",className:"af-node-preview-run",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"play_arrow"}),"立即运行"]}),i.jsxs("button",{type:"button",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"article"}),"日志"]})]})]}):i.jsxs("div",{className:"af-node-preview-card af-node-preview-card--default",children:[i.jsxs("div",{className:"af-node-preview-card__head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:N}),i.jsx("strong",{children:y.title||g.name||"Untitled Node"}),i.jsx("code",{children:C_(y)})]}),i.jsxs("div",{className:"af-node-preview-default-body",children:[i.jsx("p",{children:g.description||"这个节点还没有描述。AI 生成 runtime、prompt 或 script 后,内部信息会显示在右侧。"}),i.jsxs("div",{children:[i.jsxs("span",{children:[Array.isArray(g.inputs)?g.inputs.length:0," inputs"]}),i.jsxs("span",{children:[Array.isArray(g.outputs)?g.outputs.length:0," outputs"]}),i.jsx("span",{children:((W=g.runtime)==null?void 0:W.type)||g.baseDefinitionId||"agent_subAgent"})]})]})]}):i.jsxs("div",{className:"af-node-preview-empty",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_box"}),i.jsx("strong",{children:"暂无预览"}),i.jsx("p",{children:"先在左侧描述你要创建的节点,AI 生成 draft 后这里会展示节点卡片。"})]})}),i.jsxs("div",{className:"af-node-studio-test",children:[i.jsxs("div",{className:"af-node-studio-subhead",children:[i.jsx("strong",{children:"Test Inputs"}),i.jsxs("button",{type:"button",onClick:A,children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:s?"sync":"play_arrow"}),"Run"]})]}),i.jsxs("div",{className:"af-node-studio-inputs",children:[i.jsxs("label",{children:[i.jsx("span",{children:"project"}),i.jsx("input",{value:b.project||"",readOnly:!0,placeholder:"-"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"date"}),i.jsx("input",{value:b.date||"",readOnly:!0,placeholder:"-"})]})]}),i.jsx("div",{className:"af-node-studio-log",children:(s?["running..."]:j.length?j:["No test run yet."]).map((E,Q)=>i.jsx("span",{children:E},`${E}-${Q}`))})]})]})]}),i.jsxs("aside",{className:"af-node-studio-internals","aria-label":"Internals",children:[i.jsxs("div",{className:"af-node-studio-panel-head",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),i.jsx("strong",{children:"Internals"})]}),i.jsx("div",{className:"af-node-studio-tabs",role:"tablist","aria-label":"Internals sections",children:v.map(E=>i.jsxs("button",{type:"button",className:E.id===n?"af-node-studio-tab af-node-studio-tab--active":"af-node-studio-tab",onClick:()=>r(E.id),children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:E.icon}),E.label]},E.id))}),i.jsx("div",{className:"af-node-studio-internal-list",children:w.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:w.id==="ui"?JSON.stringify(g.ui||{},null,2):w.id==="contract"?JSON.stringify({inputs:g.inputs||[],outputs:g.outputs||[],configSchema:g.configSchema||{}},null,2):w.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 Vie(){return`ws_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function Kie(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function wh(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 qie(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 kw(){return{id:"",label:"",kind:"git",path:"",repoUrl:"",branch:"master",mountPath:"",credentialRef:"",type:"code",description:"",enabled:!0}}function Wp(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 Uie(e){const t=e.kind==="local"?"local":"git",n=t==="git"?String(e.repoUrl||"").trim():"",r=t==="git"?String(e.mountPath||wh(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 Yie({ok:e}){return i.jsx("span",{className:"af-workspaces-dot"+(e?" af-workspaces-dot--ok":""),"aria-hidden":!0})}function __({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(Yie,{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 Gie(){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([]),[w,g]=m.useState(kw),[k,b]=m.useState(""),[j,N]=m.useState([]),[C,I]=m.useState(""),R=m.useMemo(()=>y.findIndex((V,B)=>Vi(V,B)===C),[y,C]),A=!!m.useMemo(()=>p.find((V,B)=>Vi(V,B)===C)||null,[p,C]),L=m.useMemo(()=>{const V=String(w.credentialRef||"").trim();return V?j.some(B=>String((B==null?void 0:B.key)||"").trim()===V&&String((B==null?void 0:B.value)??"")!==""):!1},[w.credentialRef,j]),D=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),N(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(()=>{D()},[D]);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&&I(B),u("已保存")}catch(se){l(String(se.message||se))}finally{r(!1)}},[d]),M=m.useCallback(()=>{I(""),g(kw()),b(""),u(""),l("")},[]),K=m.useCallback((V,B)=>{I(Vi(V,B)),g(Wp(V)),b(""),u("")},[]),z=m.useCallback((V,B)=>{I(Vi(V,B)),g(Wp(V)),b(""),u("")},[]),F=m.useCallback(async(V,B)=>{const se=String(V||"").trim(),ue=String(B??"");if(!se||!ue)return;const G=j.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);N(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)},[j]),$=m.useCallback(()=>{const V=Uie({...w,id:w.id||Vie()}),B=k.trim();if(V.kind==="git"&&B&&!V.credentialRef&&(V.credentialRef=qie(w,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&&!Kie(V.credentialRef)){l("凭证环境变量只能使用字母、数字和下划线,且不能以数字开头");return}const se=R>=0?y.map((ue,G)=>G===R?V:ue):[V,...y];g(Wp(V)),(async()=>{r(!0);try{B&&await F(V.credentialRef,B),b(""),await O(se,Vi(V))}catch(ue){l(String(ue.message||ue)),r(!1)}})()},[y,w,O,F,R,k]),W=m.useCallback(()=>{if(R<0)return;const V=y.filter((B,se)=>se!==R);g(kw()),I(""),O(V)},[y,O,R]),E=m.useCallback(async()=>{if(!A){if(R<0||!w.id){l("请先保存知识库配置,再拉取更新");return}if(w.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:w.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(w.id||""));ue&&g(Wp(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,w,A,R]),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:D,disabled:e,children:[i.jsx("span",{className:"material-symbols-outlined",children:"refresh"}),"刷新"]})]}),i.jsx("main",{className:"af-settings-body",children:i.jsxs("div",{className:"af-workspaces-inner",children:[i.jsxs("header",{className:"af-settings-hero",children:[i.jsx("h1",{className:"af-settings-h1",children:"知识库"}),i.jsx("p",{className:"af-settings-lead",children:"维护可被加载知识库、一键任务和后续 Agent 使用的只读上下文源。Git 字段与 mengmai 的资源配置保持一致。"}),d?i.jsxs("p",{className:"af-workspaces-config",children:["配置文件:",d]}):null,a?i.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,c?i.jsx("p",{className:"af-workspaces-status",children:c}):null]}),i.jsxs("section",{className:"af-workspaces-summary",children:[i.jsxs("div",{children:[i.jsx("span",{children:"内置"}),i.jsx("strong",{children:p.length})]}),i.jsxs("div",{children:[i.jsx("span",{children:"自定义"}),i.jsx("strong",{children:y.length})]}),i.jsxs("div",{children:[i.jsx("span",{children:"Git"}),i.jsx("strong",{children:y.filter(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(__,{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(__,{item:V,selected:Vi(V,B)===C,onClick:()=>z(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:A?"查看内置知识库":R>=0?"编辑知识库":"新增知识库"}),i.jsx("p",{children:A?"内置项由当前运行环境提供,不能在这里修改。":"本地路径用于读取上下文,Git 字段用于后续同步和上下文挂载。"})]}),i.jsxs("label",{className:"af-workspaces-switch",children:[i.jsx("input",{type:"checkbox",checked:w.enabled!==!1,disabled:A,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:w.kind==="git"?"active":"",disabled:A,onClick:()=>Q({kind:"git",type:w.type==="local"?"code":w.type}),children:[i.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),"Git"]}),i.jsxs("button",{type:"button",className:w.kind==="local"?"active":"",disabled:A,onClick:()=>Q({kind:"local",type:"local"}),children:[i.jsx("span",{className:"material-symbols-outlined",children:"folder_open"}),"本地目录"]})]}),i.jsxs("div",{className:"af-workspaces-form",children:[i.jsxs("label",{children:[i.jsx("span",{children:"名称"}),i.jsx("input",{value:w.label,disabled:A,onChange:V=>Q({label:V.target.value}),placeholder:"Likee Android"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"类型"}),i.jsxs("select",{value:w.type,disabled:A,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:w.path,disabled:A,onChange:V=>Q({path:V.target.value}),placeholder:w.kind==="git"?"可空,默认保存到全局资源目录/repos/<仓库名>":"/Users/.../project"})]}),w.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:w.repoUrl,disabled:A,onChange:V=>{const B=V.target.value,se=wh(w.repoUrl),ue=String(w.mountPath||"").trim();Q({repoUrl:B,...!ue||ue===se?{mountPath:wh(B)}:{}})},placeholder:"https://git.example.com/group/repo.git"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"分支"}),i.jsx("input",{value:w.branch,disabled:A,onChange:V=>Q({branch:V.target.value}),placeholder:"master"})]}),i.jsxs("label",{children:[i.jsx("span",{children:"挂载目录"}),i.jsx("input",{value:w.mountPath,disabled:A,onChange:V=>Q({mountPath:V.target.value}),placeholder:wh(w.repoUrl)||"repo_name"})]}),i.jsxs("label",{className:"af-workspaces-form__wide",children:[i.jsx("span",{children:"凭证环境变量"}),i.jsx("input",{value:w.credentialRef,disabled:A,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:A,onChange:V=>b(V.target.value),placeholder:L?"已在个人环境变量中配置;留空则不修改":"保存到个人环境变量,不写入 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:w.description,disabled:A,onChange:V=>Q({description:V.target.value}),placeholder:"这个知识库包含哪些代码、文档或需求上下文"})]})]}),i.jsxs("div",{className:"af-workspaces-actions",children:[!A&&R>=0?i.jsxs("button",{type:"button",className:"af-workspaces-danger",onClick:W,disabled:n||s,children:[i.jsx("span",{className:"material-symbols-outlined",children:"delete"}),"删除"]}):i.jsx("span",{}),i.jsxs("div",{children:[w.kind==="git"&&R>=0?i.jsxs("button",{type:"button",onClick:E,disabled:A||n||s,children:[i.jsx("span",{className:"material-symbols-outlined",children:s?"sync":"download"}),s?"拉取中":"拉取更新"]}):null,i.jsx("button",{type:"button",onClick:M,disabled:n||s,children:"重置"}),i.jsxs("button",{type:"button",className:"af-workspaces-primary",onClick:$,disabled:A||n||s,children:[i.jsx("span",{className:"material-symbols-outlined",children:"save"}),n?"保存中":"保存"]})]})]})]})]})]})})]})}function Jie(e){const t=Date.parse(String(e||""));return Number.isFinite(t)?new Date(t).toLocaleString([],{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-"}function Xie(e){return e==="owner"?"我创建的":e==="editor"?"协作编辑":e==="viewer"?"只读协作":"可访问"}function Qie(e){return e==="completed"?"已完成":e==="blocked"?"需关注":"进行中"}function Zie(e){const t=String(e||"").toLowerCase();return t==="android"?"Android":t==="ios"?"iOS":["all","both","cross-platform","cross_platform"].includes(t)?"双端":e||""}function eoe(e){return`/workspace?${new URLSearchParams({view:"workflow",tapdId:String((e==null?void 0:e.tapdId)||"")}).toString()}`}function toe(){const{navigate:e}=gs(),[t,n]=m.useState([]),[r,s]=m.useState(!1),[o,a]=m.useState(""),[l,c]=m.useState(""),[u,d]=m.useState("all"),[f,p]=m.useState("all"),h=m.useCallback(async()=>{s(!0),a("");try{const w=await fetch("/api/prd-workflows"),g=await w.json().catch(()=>({}));if(!w.ok)throw new Error(g.error||"读取迭代列表失败");n(Array.isArray(g.workflows)?g.workflows:[])}catch(w){a(String(w.message||w)),n([])}finally{s(!1)}},[]);m.useEffect(()=>{h()},[h]);const y=m.useMemo(()=>({total:t.length,owned:t.filter(w=>w.role==="owner").length,collaborating:t.filter(w=>w.role!=="owner").length,attention:t.filter(w=>w.state==="blocked").length}),[t]),v=m.useMemo(()=>{const w=l.trim().toLowerCase();return t.filter(g=>{var k;return u==="owned"&&g.role!=="owner"||u==="collaborating"&&g.role==="owner"||f!=="all"&&g.state!==f?!1:w?[g.tapdId,g.title,g.pointer,g.phase,g.ownerUsername,(k=g.latestAction)==null?void 0:k.title].some(b=>String(b||"").toLowerCase().includes(w)):!0})},[l,u,f,t]);return i.jsxs("div",{className:"af-settings-page af-workflows-page",children:[i.jsxs("div",{className:"af-settings-top",children:[i.jsxs("div",{className:"af-settings-crumb",children:[i.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),i.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),i.jsx("span",{className:"af-settings-crumb-active",children:"迭代"})]}),i.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:()=>void h(),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 af-workflows-inner",children:[i.jsx("section",{className:"af-settings-hero af-workflows-hero",children:i.jsxs("div",{children:[i.jsx("span",{className:"af-workflows-eyebrow",children:"Workflow Dashboard"}),i.jsx("h1",{className:"af-settings-h1",children:"迭代"}),i.jsx("p",{className:"af-settings-lead",children:"集中查看我创建和参与的需求 Workflow,追踪阶段、Action 进度与最新动态。"})]})}),i.jsxs("div",{className:"af-workflows-summary","aria-label":"迭代汇总",children:[i.jsxs("div",{children:[i.jsx("span",{children:"全部迭代"}),i.jsx("strong",{children:y.total})]}),i.jsxs("div",{children:[i.jsx("span",{children:"我创建的"}),i.jsx("strong",{children:y.owned})]}),i.jsxs("div",{children:[i.jsx("span",{children:"参与协作"}),i.jsx("strong",{children:y.collaborating})]}),i.jsxs("div",{className:y.attention?"is-attention":"",children:[i.jsx("span",{children:"需关注"}),i.jsx("strong",{children:y.attention})]})]}),i.jsxs("section",{className:"af-workflows-toolbar","aria-label":"迭代筛选",children:[i.jsxs("label",{className:"af-workflows-search",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),i.jsx("input",{value:l,onChange:w=>c(w.target.value),placeholder:"搜索 TAPD、需求、阶段或成员","aria-label":"搜索迭代"})]}),i.jsx("div",{className:"af-workflows-segments","aria-label":"协作范围",children:[["all","全部"],["owned","我创建的"],["collaborating","与我协作"]].map(([w,g])=>i.jsx("button",{type:"button",className:u===w?"is-active":"","aria-pressed":u===w,onClick:()=>d(w),children:g},w))}),i.jsxs("select",{value:f,onChange:w=>p(w.target.value),"aria-label":"迭代状态",children:[i.jsx("option",{value:"all",children:"全部状态"}),i.jsx("option",{value:"active",children:"进行中"}),i.jsx("option",{value:"completed",children:"已完成"}),i.jsx("option",{value:"blocked",children:"需关注"})]})]}),o?i.jsx("div",{className:"af-workflows-message af-workflows-message--error",children:o}):null,r?i.jsx("div",{className:"af-workflows-message",children:"正在读取迭代..."}):null,!r&&!o&&t.length===0?i.jsxs("div",{className:"af-workflows-empty",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timeline"}),i.jsx("strong",{children:"暂无迭代"}),i.jsx("p",{children:"当 prd-flow 上报 Workflow 后,它会出现在这里。"})]}):null,!r&&t.length>0&&v.length===0?i.jsx("div",{className:"af-workflows-message",children:"没有符合当前筛选条件的迭代。"}):null,i.jsx("div",{className:"af-workflows-list",children:v.map(w=>{var k,b;const g=w.actionCount>0?Math.round(w.completedActionCount/w.actionCount*100):0;return i.jsxs("article",{className:"af-workflow-card",children:[i.jsxs("div",{className:"af-workflow-card__identity",children:[i.jsxs("div",{className:"af-workflow-card__title-row",children:[i.jsxs("span",{className:"af-workflow-tapd",children:["TAPD ",w.tapdId]}),i.jsx("span",{className:`af-workflow-state af-workflow-state--${w.state||"active"}`,children:Qie(w.state)}),i.jsx("span",{className:"af-workflow-role",children:Xie(w.role)}),w.shareActive?i.jsxs("span",{className:"af-workflow-shared",children:[i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"link"}),"已分享"]}):null]}),i.jsx("h2",{children:w.title||w.pointer||`需求 ${w.tapdId}`}),i.jsx("p",{children:w.pointer||"等待 Workflow 上报当前状态"}),i.jsxs("div",{className:"af-workflow-card__meta",children:[i.jsx("span",{children:w.phase||"未识别阶段"}),i.jsxs("span",{children:[w.issueCount||0," Issues"]}),(w.platforms||[]).map(j=>i.jsx("span",{children:Zie(j)},j)),i.jsxs("span",{children:["Owner · ",w.ownerUsername||w.ownerId||"-"]})]})]}),i.jsxs("div",{className:"af-workflow-card__progress",children:[i.jsxs("div",{children:[i.jsx("span",{children:"Action 进度"}),i.jsxs("strong",{children:[w.completedActionCount||0,"/",w.actionCount||0]})]}),i.jsx("div",{className:"af-workflow-progress","aria-label":`Action 完成度 ${g}%`,children:i.jsx("span",{style:{width:`${g}%`}})}),i.jsxs("small",{children:[g,"%"]})]}),i.jsxs("div",{className:"af-workflow-card__latest",children:[i.jsx("span",{children:"最新动态"}),i.jsx("strong",{children:((k=w.latestAction)==null?void 0:k.title)||"暂无 Action 记录"}),i.jsx("small",{children:Jie(((b=w.latestAction)==null?void 0:b.at)||w.updatedAt)})]}),i.jsxs("button",{type:"button",className:"af-workflow-open",onClick:()=>e(eoe(w)),children:["打开 Workflow",i.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_forward"})]})]},w.id||w.tapdId)})})]})})]})}const noe=[{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"}],roe=[{label:"Use Case 01",title:"Likee 客户端知识库查询(如广告占位)",images:["/likee-context/usecase-ad-query.png"],trigger:"产品或运营想确认客户端已有逻辑,例如 Likee Android 里有哪些广告占位,以及相关常量和代码位置。",steps:["在「我的流程」加载 Likee Android 流程片段","在子 Agent 节点输入客户端逻辑问题","点击 Run Line,只执行当前链路","在右侧 Markdown Display 查看知识库查询结果"],outputs:["SETTING_ID / PAGE_ID 表格","客户端代码路径与口径说明","可继续用于 PRD 的背景材料"]},{label:"Use Case 02",title:"客户端原型设计",images:["/likee-context/usecase-prototype.png"],trigger:"业务已经明确要在 Likee 首页加入广告引导,需要先把弹框体验画出来给产品、设计、研发评审。",steps:["在 Workspace 打开原型生成流程","加载客户端原型 Skill","在子 Agent 中说明生成一个首页 dialog 弹框","查看 HTML Display 中的手机预览稿"],outputs:["Likee 风格手机原型","弹框文案与按钮状态","可直接用于评审的 Display 面板"]},{label:"Use Case 03",title:"前端 H5 原型设计",images:["/likee-context/usecase-h5-prototype.png"],trigger:"运营活动需要快速产出 Likee 风格 H5 页面,例如幸运转盘、积分排行榜、活动首页或结果页。",steps:["在 Workspace 打开 H5 原型生成流程","加载前端 H5 原型相关 Skill","在子 Agent 中说明活动结构、页面模块和运营规则","查看 HTML Display 中的可交互 H5 原型"],outputs:["Likee 风格 H5 页面","抽奖转盘与排行榜布局","活动规则和状态页","可用于评审的 HTML Display"]},{label:"Use Case 04",title:"CK / Hive 查数与 SQL 生成",images:["/likee-context/usecase-data-query.png"],trigger:"运营或产品需要快速验证一个数据问题,例如找出典型 UID、对比不同日期的视频上传分辨率占比,并保留可复用 SQL。",steps:["在 Workspace 打开查数流程","加载查数相关 Skill","在子 Agent 中说明数据口径、日期和筛选条件","查看 Markdown Display 中的数据结果和查询 SQL"],outputs:["查询结果表格","SQL 语句","口径说明","可继续接入 PRD 或复盘面板的数据结论"]},{label:"Use Case 05",title:"需求文档生成、数据补齐与同步",images:["/likee-context/usecase-prd.png","/likee-context/usecase-sync.png"],trigger:"需求进入评审和落库阶段,需要把 TAPD 信息、Hive 数据、原型内容组织成 PRD,并同步到 TAPD 和 Git 仓库。",steps:["先运行 TAPD / 数据查询节点,拿到迭代、页面 PV 和业务背景","把查询结果和原型 Display 内容接入 PRD 生成子 Agent","在 Markdown Display 查看完整需求文档","把 PRD content 接入 TAPD 更新节点和 Git 仓库提交节点"],outputs:["完整 PRD 文档","项目背景与 Top 页面数据","TAPD 需求更新成功","Git MR 链接"]},{label:"Use Case 06",title:"Display 模式做需求评审面板",images:["/likee-context/usecase-display.png"],trigger:"流程跑完后,需要把 PRD、原型、数据图表、展示位表格放在一个页面里给产品、运营、研发一起看。",steps:["在 Workspace 中完成查数、原型、PRD、同步节点执行","确认 Markdown / HTML / 图表 / 表格展示节点都有结果","切换顶部 DISPLAY 模式","使用生成链接把评审面板发给相关同学"],outputs:["PRD 长文档","客户端原型预览","图表与表格","统一展示链接"]}],soe=[{name:"likee-client-ui",namespace:"智能助手 / 客户端原型",icon:"phone_iphone",mode:"客户端原型设计",usage:"生成 Likee 客户端风格页面、弹框、Feed 引导、个人页、活动入口等原型,适合产品评审前快速对齐体验。",examples:["首页 dialog 弹框","Feed 内引导","客户端红色主品牌视觉","移动端交互态"],tone:"pink"},{name:"tapd-likee",namespace:"智能助手 / TAPD",icon:"sync",mode:"需求系统交互",usage:"和 TAPD 交互,支持创建、同步、更新需求,把工作区生成的 PRD 或 Markdown 内容回写到需求系统。",examples:["创建 TAPD 需求","更新需求正文","同步处理人和链接","把结果回显到 Display"],tone:"green"},{name:"plain-language-response",namespace:"智能助手 / 回答风格",icon:"record_voice_over",mode:"业务化回答",usage:"用于把回答收敛成产品、运营更容易阅读的解释,避免直接把客户端代码库细节、函数调用链和实现细节暴露太多。",examples:["需求背景解释","代码结论转业务语言","评审材料摘要","减少实现细节噪音"],tone:"cyan"},{name:"create-likee-h5-style-html",namespace:"智能助手 / 前端 H5",icon:"language",mode:"H5 原型设计",usage:"创建 Likee H5 风格原型,适合运营活动、抽奖、排行榜、报告页、反馈表单、创作者认证页、订单列表等页面。",examples:["幸运转盘活动","积分排行榜","活动规则页","结果页和空状态"],tone:"amber"},{name:"analytics",namespace:"数据 / CK & Hive",icon:"query_stats",mode:"查数和 SQL 生成",usage:"面向 CK、Hive 的指标查询和 SQL 生成,适合 PV、UV、转化、分国家、分实验组、典型 UID 等数据问题。",examples:["自动生成 SQL","输出查询结果表","解释指标口径","沉淀复盘数据"],tone:"green"}],ioe=[["知识库","查客户端、后台、前端逻辑","广告、Feed、会员、增长、配置、接口调用链"],["数据","查 CK / Hive 并输出 SQL","PV、UV、转化、分页面、分国家、分实验组"],["产物","生成原型、PRD、Display 面板","Markdown、HTML 原型、图表、表格、交互预览"],["协作","同步 TAPD 与 Git 仓库","需求正文、变更记录、MR 链接、评审材料"]];function Vp({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 ooe(){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(Vp,{icon:"travel_explore",title:"全局上下文",label:"Likee 业务、代码、数据",tone:"pink"})}),i.jsx("div",{className:"likee-node-pos likee-node-b",children:i.jsx(Vp,{icon:"database",title:"CK / Hive",label:"自动 SQL 与指标口径",tone:"cyan"})}),i.jsx("div",{className:"likee-node-pos likee-node-c",children:i.jsx(Vp,{icon:"article",title:"需求文档",label:"PRD、变更说明、评审稿",tone:"amber"})}),i.jsx("div",{className:"likee-node-pos likee-node-d",children:i.jsx(Vp,{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 xh({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 aoe(){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(xh,{kicker:"SKILLS",title:"用 Skills 把 Likee 上下文变成可复用能力",children:"Skills 是工作区里可加载的能力包。手动搭建工作区时,只需要按场景加载对应 Skill。"}),i.jsx("div",{className:"likee-skill-grid",children:soe.map(e=>i.jsxs("article",{className:`likee-skill-card likee-skill-${e.tone}`,children:[i.jsxs("div",{className:"likee-skill-head",children:[i.jsx("div",{className:"likee-skill-icon",children:i.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),i.jsxs("div",{children:[i.jsx("h3",{children:e.name}),i.jsx("span",{children:e.namespace})]})]}),i.jsx("div",{className:"likee-skill-mode",children:e.mode}),i.jsx("p",{children:e.usage}),i.jsx("div",{className:"likee-skill-examples",children:e.examples.map(t=>i.jsx("strong",{children:t},t))})]},e.name))})]})})}function DM(){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(ooe,{}),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(xh,{kicker:"SCENARIO TRIGGERS",title:"打造 Likee 团队全景上下文",children:"不要求先会写 Prompt,也不要求知道该找哪个系统。选择一个业务场景,工作台会把需要的 Likee 上下文、数据查询和最终产物组织起来。"}),i.jsx("div",{className:"likee-scenario-grid",children:noe.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(xh,{kicker:"USE CASES",title:"沉淀 Likee 业务流水线",children:"这里展示的是平台里实际可跑的工作流:加载流程片段,在子 Agent 或 Run 节点输入业务问题,执行当前 line,最终在 Display、TAPD 和 Git 中拿到结果。"}),i.jsx("div",{className:"likee-usecase-stack",children:roe.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(aoe,{}),i.jsx("section",{className:"likee-section",children:i.jsxs("div",{className:"likee-section-inner likee-two-column likee-capability-layout",children:[i.jsx(xh,{kicker:"CAPABILITY MAP",title:"每个场景背后,都连接同一套 Likee 上下文能力",children:"工作台把知识库、CK / Hive、原型、PRD、TAPD 和 Git 放到同一条链路里。用户看到的是业务场景,系统处理的是上下文、产物和同步。"}),i.jsx("div",{className:"likee-capability-table",children:ioe.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 FM(e){return t=>typeof t===e}var loe=FM("function"),coe=e=>e===null,E_=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",A_=e=>!uoe(e)&&!coe(e)&&(loe(e)||typeof e=="object"),uoe=FM("undefined");function doe(e,t,n){return woe(n,e,t)?!0:(xoe(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?foe(e,t,n):e instanceof Map&&t instanceof Map?moe(e,t,n):e instanceof Set&&t instanceof Set?yoe(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?poe(e,t):E_(e)&&E_(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?hoe(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():goe(e,t,n))}function wf(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!A_(e)||!t||!A_(t)?!1:doe(e,t,n)}function foe(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!wf(e[s],t[s],n))return!1;return!0}function poe(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 hoe(e,t,n){return e.message===t.message&&e.name===t.name&&wf(e.cause,t.cause,n)}function moe(e,t,n){if(e.size!==t.size)return!1;for(const r of e.entries())if(!t.has(r[0]))return!1;for(const r of e.entries())if(!wf(r[1],t.get(r[0]),n))return!1;return!0}function goe(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)&&!wf(e[o],t[o],n))return!1}return!0}function yoe(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 woe(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function xoe(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function jv(e,t){return wf(e,t,new WeakMap)}function vw(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function boe(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function koe(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function voe(){const e=m.useRef(!0);return e.current?(e.current=!1,!0):e.current}function Soe(e,t){const n=voe();m.useEffect(()=>{if(!n)return e()},t)}function zM(e){const t=m.useRef(void 0);return m.useEffect(()=>{t.current=e}),t.current}function joe(e,t){const n=m.useRef(t);return jv(t,n.current)||(n.current=t),m.useMemo(e,n.current)}function Noe(e){m.useEffect(()=>{e()},[])}function Coe(e=0){const[t,n]=m.useState({height:vw()?window.innerHeight:0,width:vw()?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(!vw())return()=>{};const o=s.current;return n({height:window.innerHeight,width:window.innerWidth}),koe(window,"resize",o),()=>{boe(window,"resize",o)}},[]),t}var _oe=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],Eoe=["bigint","boolean","null","number","string","symbol","undefined"];function xf(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(Aoe(t))return t}function oi(e){return t=>xf(t)===e}function Aoe(e){return _oe.includes(e)}function Kc(e){return t=>typeof t===e}function Poe(e){return Eoe.includes(e)}var Ioe=["innerHTML","ownerDocument","style","attributes","nodeValue"],bf=e=>Array.isArray(e),Roe=e=>xf(e)==="AsyncGeneratorFunction",Toe=oi("AsyncFunction"),Moe=Kc("bigint"),$oe=e=>e===!0||e===!1,Loe=oi("Date"),Ooe=oi("Error"),ra=Kc("function"),Doe=oi("GeneratorFunction"),Foe=e=>typeof e=="number"&&Number.isInteger(e),Nb=oi("Map"),BM=e=>Number.isNaN(e),Nv=e=>e===null,HM=oi("Function"),zoe=oi("Promise"),Boe=oi("RegExp"),Cb=oi("Set"),kf=Kc("string"),Hoe=Kc("symbol"),Cv=Kc("undefined"),Woe=oi("WeakMap"),Voe=oi("WeakSet"),_v=e=>Nv(e)||Cv(e),WM=e=>!Cv(e),Koe=e=>Kc("number")(e)&&!BM(e),qoe=e=>kf(e)&&e.trim().length>0,Uoe=e=>{if(!kf(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},pg=e=>!_v(e)&&(ra(e)||typeof e=="object"),VM=e=>{if(xf(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},Yoe=e=>Nv(e)||Poe(typeof e),Goe=e=>xf(e)==="URL",KM=e=>!_v(e)&&ra(e[Symbol.iterator]),Joe=e=>KM(e)&&ra(e.next)&&ra(e.throw),Xoe=e=>ra(e)&&/^class\s/.test(e.toString()),Qoe=(e,t)=>!bf(e)||!ra(t)?!1:e.every(n=>t(n)),Zoe=e=>pg(e)&&!VM(e)&&e.nodeType===1&&kf(e.nodeName)&&Ioe.every(t=>t in e),eae=e=>kf(e)&&e.length===0||bf(e)&&e.length===0||pg(e)&&!Nb(e)&&!Cb(e)&&Object.keys(e).length===0||Cb(e)&&e.size===0||Nb(e)&&e.size===0,tae=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,nae=(e,t)=>bf(e)?e.indexOf(t)>-1:!1,rae=(e,t,n)=>{if(!pg(e)||!t)return!1;const r=e[t];return ra(n)?n(r):WM(r)};function St(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(bf(e))return"Array";if(HM(e))return"Function";const t=xf(e);return t||"Object"}St.array=bf;St.arrayOf=Qoe;St.asyncGeneratorFunction=Roe;St.asyncFunction=Toe;St.bigint=Moe;St.boolean=$oe;St.class=Xoe;St.date=Loe;St.defined=WM;St.domElement=Zoe;St.empty=eae;St.error=Ooe;St.function=ra;St.generator=Joe;St.generatorFunction=Doe;St.instanceOf=tae;St.integer=Foe;St.iterable=KM;St.map=Nb;St.nan=BM;St.null=Nv;St.nullOrUndefined=_v;St.nonEmptyString=qoe;St.number=Koe;St.numericString=Uoe;St.object=pg;St.oneOf=nae;St.plainFunction=HM;St.plainObject=VM;St.primitive=Yoe;St.promise=zoe;St.propertyOf=rae;St.regexp=Boe;St.set=Cb;St.string=kf;St.symbol=Hoe;St.undefined=Cv;St.url=Goe;St.weakMap=Woe;St.weakSet=Voe;var _r=St;/* v8 ignore next -- @preserve */var sae=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},iae=function(e,t){return e+Zd(t)},Zd=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(iae,""):sae(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?Zd(e.props.children):""};Zd.default=Zd;var oae=Zd;const Sw=ia(oae);var qM={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(N){return N!=="constructor"&&N!=="prototype"&&N!=="__proto__"}function a(N){let C=0;const I=N.length,R=new Array(I);for(C;C<I;++C)R[C]=g(N[C]);return R}function l(N){const C={};if(p&&Object.getPrototypeOf(N)!==t)return p(N);const I=f(N);let R,H,A;for(R=0,H=I.length;R<H;++R)o(A=I[R])&&(C[A]=g(N[A]));return C}function c(N,C){const I=N.length,R=C.length;let H=0;const A=new Array(I+R);for(H;H<I;++H)A[H]=g(N[H]);for(H=0;H<R;++H)A[H+I]=g(C[H]);return A}const u=Object.prototype.propertyIsEnumerable;function d(N){const C=Object.keys(N),I=Object.getOwnPropertySymbols(N);for(let R=0,H=I.length;R<H;++R)u.call(N,I[R])&&C.push(I[R]);return C}const f=s!=null&&s.symbols?d:Object.keys,p=typeof(s==null?void 0:s.cloneProtoObject)=="function"?s.cloneProtoObject:void 0,h=typeof(s==null?void 0:s.isMergeableObject)=="function"?s.isMergeableObject:n(),y=(s==null?void 0:s.onlyDefinedProperties)===!0;function v(N){return typeof N!="object"||N===null}const w=s&&typeof s.mergeArray=="function"?s.mergeArray({clone:g,deepmerge:b,getKeys:f,isMergeableObject:h}):c;function g(N){return h(N)?Array.isArray(N)?a(N):l(N):N}function k(N,C){const I={},R=f(N),H=f(C);let A,L,D;for(A=0,L=R.length;A<L;++A)o(D=R[A])&&H.indexOf(D)===-1&&(I[D]=g(N[D]));for(A=0,L=H.length;A<L;++A)if(o(D=H[A]))if(D in N)R.indexOf(D)!==-1&&(p&&h(C[D])&&Object.getPrototypeOf(C[D])!==t?I[D]=p(C[D]):I[D]=b(N[D],C[D]));else{if(y&&typeof C[D]>"u")continue;I[D]=g(C[D])}return I}function b(N,C){if(y&&typeof C>"u")return g(N);const I=Array.isArray(C),R=Array.isArray(N);return v(C)?C:h(N)?I&&R?w(N,C):I!==R?g(C):k(N,C):g(C)}function j(){switch(arguments.length){case 0:return{};case 1:return g(arguments[0]);case 2:return b(arguments[0],arguments[1])}let N;for(let C=0,I=arguments.length;C<I;++C)N=b(N,arguments[C]);return N}return s!=null&&s.all?j:b}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(qM);var aae=qM.exports;const lae=ia(aae);var cae=new Error("Element already at target scroll position"),uae=new Error("Scroll cancelled"),dae=Math.min,P_=Date.now,fae={left:I_("scrollLeft"),top:I_("scrollTop")};function I_(e){return function(n,r,s,o){s=s||{},typeof s=="function"&&(o=s,s={}),typeof o!="function"&&(o=hae);var a=P_(),l=n[e],c=s.ease||pae,u=isNaN(s.duration)?350:+s.duration,d=!1;return l===r?o(cae,n[e]):requestAnimationFrame(p),f;function f(){d=!0}function p(h){if(d)return o(uae,n[e]);var y=P_(),v=dae(1,(y-a)/u),w=c(v);n[e]=w*(r-l)+l,v<1?requestAnimationFrame(p):requestAnimationFrame(function(){o(null,n[e])})}}}function pae(e){return .5*(1-Math.cos(Math.PI*e))}function hae(){}const mae=ia(fae);var UM={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(gd,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})})(UM);var gae=UM.exports;const YM=ia(gae),yae=["top","right","bottom","left"],R_=["start","end"],T_=yae.reduce((e,t)=>e.concat(t,t+"-"+R_[0],t+"-"+R_[1]),[]),$c=Math.min,Ha=Math.max,Sm=Math.round,Kp=Math.floor,Ai=e=>({x:e,y:e}),wae={left:"right",right:"left",bottom:"top",top:"bottom"};function _b(e,t,n){return Ha(e,$c(t,n))}function qc(e,t){return typeof e=="function"?e(t):e}function uo(e){return e.split("-")[0]}function Pi(e){return e.split("-")[1]}function GM(e){return e==="x"?"y":"x"}function Ev(e){return e==="y"?"height":"width"}function zo(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function Av(e){return GM(zo(e))}function JM(e,t,n){n===void 0&&(n=!1);const r=Pi(e),s=Av(e),o=Ev(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=Nm(a)),[a,Nm(a)]}function xae(e){const t=Nm(e);return[jm(e),t,jm(t)]}function jm(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const M_=["left","right"],$_=["right","left"],bae=["top","bottom"],kae=["bottom","top"];function vae(e,t,n){switch(e){case"top":case"bottom":return n?t?$_:M_:t?M_:$_;case"left":case"right":return t?bae:kae;default:return[]}}function Sae(e,t,n,r){const s=Pi(e);let o=vae(uo(e),n==="start",r);return s&&(o=o.map(a=>a+"-"+s),t&&(o=o.concat(o.map(jm)))),o}function Nm(e){const t=uo(e);return wae[t]+e.slice(t.length)}function jae(e){return{top:0,right:0,bottom:0,left:0,...e}}function XM(e){return typeof e!="number"?jae(e):{top:e,right:e,bottom:e,left:e}}function Cm(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 L_(e,t,n){let{reference:r,floating:s}=e;const o=zo(t),a=Av(t),l=Ev(a),c=uo(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 Nae(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}=qc(t,e),y=XM(h),w=l[p?f==="floating"?"reference":"floating":f],g=Cm(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(w)))==null||n?w:w.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,b=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),j=await(o.isElement==null?void 0:o.isElement(b))?await(o.getScale==null?void 0:o.getScale(b))||{x:1,y:1}:{x:1,y:1},N=Cm(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:b,strategy:c}):k);return{top:(g.top-N.top+y.top)/j.y,bottom:(N.bottom-g.bottom+y.bottom)/j.y,left:(g.left-N.left+y.left)/j.x,right:(N.right-g.right+y.right)/j.x}}const Cae=50,_ae=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:Nae},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}=L_(u,r,c),p=r,h=0;const y={};for(let v=0;v<o.length;v++){const w=o[v];if(!w)continue;const{name:g,fn:k}=w,{x:b,y:j,data:N,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=b??d,f=j??f,y[g]={...y[g],...N},C&&h<Cae&&(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}=L_(u,p,c)),v=-1)}return{x:d,y:f,placement:p,strategy:s,middlewareData:y}},Eae=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}=qc(e,t)||{};if(u==null)return{};const f=XM(d),p={x:n,y:r},h=Av(s),y=Ev(h),v=await a.getDimensions(u),w=h==="y",g=w?"top":"left",k=w?"bottom":"right",b=w?"clientHeight":"clientWidth",j=o.reference[y]+o.reference[h]-p[h]-o.floating[y],N=p[h]-o.reference[h],C=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let I=C?C[b]:0;(!I||!await(a.isElement==null?void 0:a.isElement(C)))&&(I=l.floating[b]||o.floating[y]);const R=j/2-N/2,H=I/2-v[y]/2-1,A=$c(f[g],H),L=$c(f[k],H),D=A,O=I-v[y]-L,M=I/2-v[y]/2+R,K=_b(D,M,O),z=!c.arrow&&Pi(s)!=null&&M!==K&&o.reference[y]/2-(M<D?A:L)-v[y]/2<0,F=z?M<D?M-D:M-O:0;return{[h]:p[h]+F,data:{[h]:K,centerOffset:M-K-F,...z&&{alignmentOffset:F}},reset:z}}});function Aae(e,t,n){return(e?[...n.filter(s=>Pi(s)===e),...n.filter(s=>Pi(s)!==e)]:n.filter(s=>uo(s)===s)).filter(s=>e?Pi(s)===e||(t?jm(s)!==s:!1):!0)}const Pae=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=T_,autoAlignment:h=!0,...y}=qc(e,t),v=f!==void 0||p===T_?Aae(f||null,h,p):p,w=await c.detectOverflow(t,y),g=((n=a.autoPlacement)==null?void 0:n.index)||0,k=v[g];if(k==null)return{};const b=JM(k,o,await(c.isRTL==null?void 0:c.isRTL(u.floating)));if(l!==k)return{reset:{placement:v[0]}};const j=[w[uo(k)],w[b[0]],w[b[1]]],N=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:k,overflows:j}],C=v[g+1];if(C)return{data:{index:g+1,overflows:N},reset:{placement:C}};const I=N.map(A=>{const L=Pi(A.placement);return[A.placement,L&&d?A.overflows.slice(0,2).reduce((D,O)=>D+O,0):A.overflows[0],A.overflows]}).sort((A,L)=>A[1]-L[1]),H=((s=I.filter(A=>A[2].slice(0,Pi(A[0])?2:3).every(L=>L<=0))[0])==null?void 0:s[0])||I[0][0];return H!==l?{data:{index:g+1,overflows:N},reset:{placement:H}}:{}}}},Iae=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,...w}=qc(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const g=uo(s),k=zo(l),b=uo(l)===l,j=await(c.isRTL==null?void 0:c.isRTL(u.floating)),N=p||(b||!v?[Nm(l)]:xae(l)),C=y!=="none";!p&&C&&N.push(...Sae(l,v,y,j));const I=[l,...N],R=await c.detectOverflow(t,w),H=[];let A=((r=o.flip)==null?void 0:r.overflows)||[];if(d&&H.push(R[g]),f){const M=JM(s,a,j);H.push(R[M[0]],R[M[1]])}if(A=[...A,{placement:s,overflows:H}],!H.every(M=>M<=0)){var L,D;const M=(((L=o.flip)==null?void 0:L.index)||0)+1,K=I[M];if(K&&(!(f==="alignment"?k!==zo(K):!1)||A.every($=>zo($.placement)===k?$.overflows[0]>0:!0)))return{data:{index:M,overflows:A},reset:{placement:K}};let z=(D=A.filter(F=>F.overflows[0]<=0).sort((F,$)=>F.overflows[1]-$.overflows[1])[0])==null?void 0:D.placement;if(!z)switch(h){case"bestFit":{var O;const F=(O=A.filter($=>{if(C){const W=zo($.placement);return W===k||W==="y"}return!0}).map($=>[$.placement,$.overflows.filter(W=>W>0).reduce((W,E)=>W+E,0)]).sort(($,W)=>$[1]-W[1])[0])==null?void 0:O[0];F&&(z=F);break}case"initialPlacement":z=l;break}if(s!==z)return{reset:{placement:z}}}return{}}}},Rae=new Set(["left","top"]);async function Tae(e,t){const{placement:n,platform:r,elements:s}=e,o=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=uo(n),l=Pi(n),c=zo(n)==="y",u=Rae.has(a)?-1:1,d=o&&c?-1:1,f=qc(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 Mae=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 Tae(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}}}}},$ae=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:b}=g;return{x:k,y:b}}},...u}=qc(e,t),d={x:n,y:r},f=await o.detectOverflow(t,u),p=zo(uo(s)),h=GM(p);let y=d[h],v=d[p];if(a){const g=h==="y"?"top":"left",k=h==="y"?"bottom":"right",b=y+f[g],j=y-f[k];y=_b(b,y,j)}if(l){const g=p==="y"?"top":"left",k=p==="y"?"bottom":"right",b=v+f[g],j=v-f[k];v=_b(b,v,j)}const w=c.fn({...t,[h]:y,[p]:v});return{...w,data:{x:w.x-n,y:w.y-r,enabled:{[h]:a,[p]:l}}}}}};function hg(){return typeof window<"u"}function Uc(e){return QM(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=(QM(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function QM(e){return hg()?e instanceof Node||e instanceof ds(e).Node:!1}function ri(e){return hg()?e instanceof Element||e instanceof ds(e).Element:!1}function mo(e){return hg()?e instanceof HTMLElement||e instanceof ds(e).HTMLElement:!1}function O_(e){return!hg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ds(e).ShadowRoot}function vf(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=si(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function Lae(e){return/^(table|td|th)$/.test(Uc(e))}function mg(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Oae=/transform|translate|scale|rotate|perspective|filter/,Dae=/paint|layout|strict|content/,va=e=>!!e&&e!=="none";let jw;function Pv(e){const t=ri(e)?si(e):e;return va(t.transform)||va(t.translate)||va(t.scale)||va(t.rotate)||va(t.perspective)||!Iv()&&(va(t.backdropFilter)||va(t.filter))||Oae.test(t.willChange||"")||Dae.test(t.contain||"")}function Fae(e){let t=sa(e);for(;mo(t)&&!Lc(t);){if(Pv(t))return t;if(mg(t))return null;t=sa(t)}return null}function Iv(){return jw==null&&(jw=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),jw}function Lc(e){return/^(html|body|#document)$/.test(Uc(e))}function si(e){return ds(e).getComputedStyle(e)}function gg(e){return ri(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function sa(e){if(Uc(e)==="html")return e;const t=e.assignedSlot||e.parentNode||O_(e)&&e.host||Mi(e);return O_(t)?t.host:t}function ZM(e){const t=sa(e);return Lc(t)?e.ownerDocument?e.ownerDocument.body:e.body:mo(t)&&vf(t)?t:ZM(t)}function ef(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=ZM(e),o=s===((r=e.ownerDocument)==null?void 0:r.body),a=ds(s);if(o){const l=Eb(a);return t.concat(a,a.visualViewport||[],vf(s)?s:[],l&&n?ef(l):[])}else return t.concat(s,ef(s,[],n))}function Eb(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function e$(e){const t=si(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=mo(e),o=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=Sm(n)!==o||Sm(r)!==a;return l&&(n=o,r=a),{width:n,height:r,$:l}}function Rv(e){return ri(e)?e:e.contextElement}function wc(e){const t=Rv(e);if(!mo(t))return Ai(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:o}=e$(t);let a=(o?Sm(n.width):n.width)/r,l=(o?Sm(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const zae=Ai(0);function t$(e){const t=ds(e);return!Iv()||!t.visualViewport?zae:{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 sl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),o=Rv(e);let a=Ai(1);t&&(r?ri(r)&&(a=wc(r)):a=wc(e));const l=Bae(o,n,r)?t$(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&&ri(r)?ds(r):r;let y=p,v=Eb(y);for(;v&&r&&h!==y;){const w=wc(v),g=v.getBoundingClientRect(),k=si(v),b=g.left+(v.clientLeft+parseFloat(k.paddingLeft))*w.x,j=g.top+(v.clientTop+parseFloat(k.paddingTop))*w.y;c*=w.x,u*=w.y,d*=w.x,f*=w.y,c+=b,u+=j,y=ds(v),v=Eb(y)}}return Cm({width:d,height:f,x:c,y:u})}function yg(e,t){const n=gg(e).scrollLeft;return t?t.left+n:sl(Mi(e)).left+n}function n$(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-yg(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function Hae(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const o=s==="fixed",a=Mi(r),l=t?mg(t.floating):!1;if(r===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},u=Ai(1);const d=Ai(0),f=mo(r);if((f||!f&&!o)&&((Uc(r)!=="body"||vf(a))&&(c=gg(r)),f)){const h=sl(r);u=wc(r),d.x=h.x+r.clientLeft,d.y=h.y+r.clientTop}const p=a&&!f&&!o?n$(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 Wae(e){return Array.from(e.getClientRects())}function Vae(e){const t=Mi(e),n=gg(e),r=e.ownerDocument.body,s=Ha(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=Ha(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+yg(e);const l=-n.scrollTop;return si(r).direction==="rtl"&&(a+=Ha(t.clientWidth,r.clientWidth)-s),{width:s,height:o,x:a,y:l}}const D_=25;function Kae(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=Iv();(!d||d&&t==="fixed")&&(l=s.offsetLeft,c=s.offsetTop)}const u=yg(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<=D_&&(o-=y)}else u<=D_&&(o+=u);return{width:o,height:a,x:l,y:c}}function qae(e,t){const n=sl(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,o=mo(e)?wc(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 F_(e,t,n){let r;if(t==="viewport")r=Kae(e,n);else if(t==="document")r=Vae(Mi(e));else if(ri(t))r=qae(t,n);else{const s=t$(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return Cm(r)}function r$(e,t){const n=sa(e);return n===t||!ri(n)||Lc(n)?!1:si(n).position==="fixed"||r$(n,t)}function Uae(e,t){const n=t.get(e);if(n)return n;let r=ef(e,[],!1).filter(l=>ri(l)&&Uc(l)!=="body"),s=null;const o=si(e).position==="fixed";let a=o?sa(e):e;for(;ri(a)&&!Lc(a);){const l=si(a),c=Pv(a);!c&&l.position==="fixed"&&(s=null),(o?!c&&!s:!c&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||vf(a)&&!c&&r$(e,a))?r=r.filter(d=>d!==a):s=l,a=sa(a)}return t.set(e,r),r}function Yae(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?mg(t)?[]:Uae(t,this._c):[].concat(n),r],l=F_(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=F_(t,a[p],s);c=Ha(h.top,c),u=$c(h.right,u),d=$c(h.bottom,d),f=Ha(h.left,f)}return{width:u-f,height:d-c,x:f,y:c}}function Gae(e){const{width:t,height:n}=e$(e);return{width:t,height:n}}function Jae(e,t,n){const r=mo(t),s=Mi(t),o=n==="fixed",a=sl(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const c=Ai(0);function u(){c.x=yg(s)}if(r||!r&&!o)if((Uc(t)!=="body"||vf(s))&&(l=gg(t)),r){const h=sl(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?n$(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 Nw(e){return si(e).position==="static"}function z_(e,t){if(!mo(e)||si(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Mi(e)===n&&(n=n.ownerDocument.body),n}function s$(e,t){const n=ds(e);if(mg(e))return n;if(!mo(e)){let s=sa(e);for(;s&&!Lc(s);){if(ri(s)&&!Nw(s))return s;s=sa(s)}return n}let r=z_(e,t);for(;r&&Lae(r)&&Nw(r);)r=z_(r,t);return r&&Lc(r)&&Nw(r)&&!Pv(r)?n:r||Fae(e)||n}const Xae=async function(e){const t=this.getOffsetParent||s$,n=this.getDimensions,r=await n(e.floating);return{reference:Jae(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Qae(e){return si(e).direction==="rtl"}const Zae={convertOffsetParentRelativeRectToViewportRelativeRect:Hae,getDocumentElement:Mi,getClippingRect:Yae,getOffsetParent:s$,getElementRects:Xae,getClientRects:Wae,getDimensions:Gae,getScale:wc,isElement:ri,isRTL:Qae};function i$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function ele(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=Kp(f),v=Kp(s.clientWidth-(d+p)),w=Kp(s.clientHeight-(f+h)),g=Kp(d),b={rootMargin:-y+"px "+-v+"px "+-w+"px "+-g+"px",threshold:Ha(0,$c(1,c))||1};let j=!0;function N(C){const I=C[0].intersectionRatio;if(I!==c){if(!j)return a();I?a(!1,I):r=setTimeout(()=>{a(!1,1e-7)},1e3)}I===1&&!i$(u,e.getBoundingClientRect())&&a(),j=!1}try{n=new IntersectionObserver(N,{...b,root:s.ownerDocument})}catch{n=new IntersectionObserver(N,b)}n.observe(e)}return a(!0),o}function B_(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=Rv(e),d=s||o?[...u?ef(u):[],...t?ef(t):[]]:[];d.forEach(g=>{s&&g.addEventListener("scroll",n,{passive:!0}),o&&g.addEventListener("resize",n)});const f=u&&l?ele(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 b;(b=h)==null||b.observe(t)})),n()}),u&&!c&&h.observe(u),t&&h.observe(t));let y,v=c?sl(e):null;c&&w();function w(){const g=sl(e);v&&!i$(v,g)&&n(),v=g,y=requestAnimationFrame(w)}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 tle=Mae,nle=Pae,rle=$ae,sle=Iae,H_=Eae,ile=(e,t,n)=>{const r=new Map,s={platform:Zae,...n},o={...s.platform,_c:r};return _ae(e,t,{...s,platform:o})};var ole=typeof document<"u",ale=function(){},bh=ole?m.useLayoutEffect:ale;function _m(e,t){if(e===t)return!0;if(typeof e!=typeof t)return!1;if(typeof e=="function"&&e.toString()===t.toString())return!0;let n,r,s;if(e&&t&&typeof e=="object"){if(Array.isArray(e)){if(n=e.length,n!==t.length)return!1;for(r=n;r--!==0;)if(!_m(e[r],t[r]))return!1;return!0}if(s=Object.keys(e),n=s.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,s[r]))return!1;for(r=n;r--!==0;){const o=s[r];if(!(o==="_owner"&&e.$$typeof)&&!_m(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function o$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function W_(e,t){const n=o$(e);return Math.round(t*n)/n}function Cw(e){const t=m.useRef(e);return bh(()=>{t.current=e}),t}function V_(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:o,floating:a}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[d,f]=m.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,h]=m.useState(r);_m(p,r)||h(r);const[y,v]=m.useState(null),[w,g]=m.useState(null),k=m.useCallback($=>{$!==C.current&&(C.current=$,v($))},[]),b=m.useCallback($=>{$!==I.current&&(I.current=$,g($))},[]),j=o||y,N=a||w,C=m.useRef(null),I=m.useRef(null),R=m.useRef(d),H=c!=null,A=Cw(c),L=Cw(s),D=Cw(u),O=m.useCallback(()=>{if(!C.current||!I.current)return;const $={placement:t,strategy:n,middleware:p};L.current&&($.platform=L.current),ile(C.current,I.current,$).then(W=>{const E={...W,isPositioned:D.current!==!1};M.current&&!_m(R.current,E)&&(R.current=E,ur.flushSync(()=>{f(E)}))})},[p,t,n,L,D]);bh(()=>{u===!1&&R.current.isPositioned&&(R.current.isPositioned=!1,f($=>({...$,isPositioned:!1})))},[u]);const M=m.useRef(!1);bh(()=>(M.current=!0,()=>{M.current=!1}),[]),bh(()=>{if(j&&(C.current=j),N&&(I.current=N),j&&N){if(A.current)return A.current(j,N,O);O()}},[j,N,O,A,H]);const K=m.useMemo(()=>({reference:C,floating:I,setReference:k,setFloating:b}),[k,b]),z=m.useMemo(()=>({reference:j,floating:N}),[j,N]),F=m.useMemo(()=>{const $={position:n,left:0,top:0};if(!z.floating)return $;const W=W_(z.floating,d.x),E=W_(z.floating,d.y);return l?{...$,transform:"translate("+W+"px, "+E+"px)",...o$(z.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:W,top:E}},[n,l,z.floating,d.x,d.y]);return m.useMemo(()=>({...d,update:O,refs:K,elements:z,floatingStyles:F}),[d,O,K,z,F])}const lle=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?H_({element:r.current,padding:s}).fn(n):{}:r?H_({element:r,padding:s}).fn(n):{}}}},K_=(e,t)=>{const n=tle(e);return{name:n.name,fn:n.fn,options:[e,t]}},cle=(e,t)=>{const n=rle(e);return{name:n.name,fn:n.fn,options:[e,t]}},ule=(e,t)=>{const n=sle(e);return{name:n.name,fn:n.fn,options:[e,t]}},dle=(e,t)=>{const n=nle(e);return{name:n.name,fn:n.fn,options:[e,t]}},fle=(e,t)=>{const n=lle(e);return{name:n.name,fn:n.fn,options:[e,t]}},ple={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},hle={beaconOptions:{offset:-18}},a$={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},mle={isFixed:!1,locale:a$,placement:"bottom"},gle={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},Lt={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},cr={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"},At={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},yle="react-joyride-portal";function wle(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function sc(...e){return lae({all:!0,isMergeableObject:t=>!(!_r.plainObject(t)||m.isValidElement(t))})(...e)}function l$(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=Sw(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&&l$(e.type)==="function")try{o=Ui(e.type({}),t)}catch{o=Sw(n)}else o=Sw(n);return o}function pr(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 xle(e,t){const n=wle(t);return{...e,...n}}function tf(){}function ble(e){return Object.keys(e)}function Em(e,...t){if(!_r.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 q_(e,...t){if(!_r.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 Ab(e,t,n){const r=o=>o.replace("{current}",String(t)).replace("{total}",String(n));if(l$(e)==="string")return r(e);if(!m.isValidElement(e))return e;const{children:s}=e.props;if(_r.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):Ab(o,t,n))});if(_r.function(e.type)&&!Object.values(e.props).length)try{return Ab(e.type({}),t,n)}catch{return e}return e}function U_(e){return ble(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function Tv(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function Y_(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 Mv(e){return e?e.getBoundingClientRect():null}function kle(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 As(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 vle(e,t,n){const r=Mv(e),s=Yc(e),o=s?!s.isSameNode(Gr()):!1,a=n??Gc(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 Yc(e,t){if(!e)return Gr();const n=YM(e);if(n){if(n.isSameNode(Gr()))return t?document:Gr();if(!(n.scrollHeight>n.offsetHeight))return Gr()}return n}function Sle(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 jle(e,t){if(!e)return 0;const n=YM(e)??Gr(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=Mv(n),o=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&(c$(e)||Nle(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 Nle(e){return e.offsetParent!==document.body}function c$(e){if(!e)return!1;const t=Yc(e);return t?!t.isSameNode(Gr()):!1}function Gc(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?Gc(e.parentNode,t):!1}function qp(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 G_(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?Yc(s):Gr(),l=a?!a.isSameNode(Gr()):!1;return(r.isFixed||Gc(s))&&!l?!1:a.scrollHeight>a.clientHeight}function Gr(){return document.scrollingElement??document.documentElement}function J_(e,t){const{duration:n,element:r}=t;let s=()=>{};const o=new Promise(a=>{const{scrollTop:l}=r,c=e>l?e-l:l-e;s=mae.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:s,promise:o}}function Cle(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 u$={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},Up={...u$,borderRadius:4,padding:8};function _le(e,t){const{styles:n}=e,r=sc(n??{},t.styles??{});let{width:s}=t;Tv()&&(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 sc({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...u$,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(${Cle(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:{...Up,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...Up,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...Up,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...Up,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 Ele=["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 $v(e,t){if(!t)return null;const n=sc(mle,q_(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=sc(ple,e.options??{},q_(t,...Ele)),s=_le(e,{...n,...r}),o=sc(hle,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:sc(a$,e.locale??{},n.locale||{}),floatingOptions:o,spotlightPadding:Ale(r.spotlightPadding),styles:s}}function Ale(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 Ple(e,t,n){const{action:r}=t,s=n&&[Lt.PREV,Lt.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function d$(e,t=!1){return _r.plainObject(e)?e.target?!0:(pr(t,"tour","target is missing from the step"),!1):(pr(t,"tour","step must be an object"),!1)}function f$(e,t=!1){return _r.array(e)?e.every(n=>d$(n,t)):(pr(t,"tour","steps must be an array"),!1)}var Ile=class{constructor(e){Fn(this,"beaconPosition",null);Fn(this,"debug");Fn(this,"eventListeners",new Map);Fn(this,"listeners",new Set);Fn(this,"props");Fn(this,"snapshot");Fn(this,"state");Fn(this,"steps");Fn(this,"tooltipPosition",null);Fn(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});Fn(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);Fn(this,"getServerSnapshot",()=>this.snapshot);Fn(this,"getSnapshot",()=>this.snapshot);Fn(this,"getEventState",()=>Em(this.snapshot,"positioned"));Fn(this,"getState",()=>Em(this.snapshot,"positioned"));Fn(this,"setPositionData",(e,t)=>{var r,s,o;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&pr(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)});Fn(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});Fn(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});Fn(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)}});Fn(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));Fn(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,!jv(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=_r.number(n);let o=0;this.debug=(e==null?void 0:e.debug)??!1,s?(o=n,_r.number(t)&&pr(this.debug,"tour","initialStepIndex is ignored in controlled mode")):_r.number(t)&&(t>=0&&t<r.length?o=t:r.length>0&&pr(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:Lt.INIT,controlled:s,index:o,lifecycle:Xe.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?At.READY:At.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===At.WAITING&&e.size>0?{...e,status:At.RUNNING}:e}getStep(e){return $v(this.props,this.steps[e??this.state.index])}};function Rle(e){return new Ile(e)}function X_(e,t){return Math.min(Math.max(e,0),t)}function Tle(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:(w=null)=>{const{index:g,status:k}=o();k===At.RUNNING&&e.current.updateState({action:Lt.CLOSE,index:g+1,origin:w,lifecycle:Xe.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:w=>{const{controlled:g,size:k,status:b}=o();if(g){pr(r.current,"tour","go() is not supported in controlled mode");return}b===At.RUNNING&&e.current.updateState({action:Lt.GO,index:w,lifecycle:Xe.COMPLETE,positioned:!1,scrolling:!1,status:w<k?b:At.FINISHED,waiting:!1})},info:()=>Em(e.current.getSnapshot(),"positioned"),next:w=>{const{index:g,size:k,status:b}=o();b===At.RUNNING&&e.current.updateState({action:Lt.NEXT,index:X_(g+1,k),lifecycle:Xe.COMPLETE,origin:w,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:w}=o();w===At.RUNNING&&e.current.updateState({action:Lt.UPDATE,lifecycle:Xe.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:w=>{const{index:g,size:k,status:b}=o();b===At.RUNNING&&e.current.updateState({action:Lt.PREV,index:X_(g-1,k),lifecycle:Xe.COMPLETE,origin:w,positioned:!1,scrolling:!1,waiting:!1})},reset:(w=!1)=>{const{controlled:g}=o();if(g){pr(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:Lt.RESET,index:0,lifecycle:Xe.INIT,positioned:!1,scrolling:!1,status:w?At.RUNNING:At.READY,waiting:!1})},skip:w=>{const{status:g}=o();g===At.RUNNING&&e.current.updateState({action:Lt.SKIP,lifecycle:Xe.COMPLETE,origin:w,positioned:!1,scrolling:!1,status:At.SKIPPED,waiting:!1})},start:w=>{const{index:g,size:k}=o();s.current(),e.current.updateState({action:Lt.START,index:_r.number(w)?w:g,lifecycle:Xe.INIT,positioned:!1,scrolling:!1,status:k?At.RUNNING:At.WAITING,waiting:!1},!0)},stop:(w=!1)=>{const{index:g,status:k}=o();[At.FINISHED,At.SKIPPED].includes(k)||e.current.updateState({action:Lt.STOP,index:g+(w?1:0),lifecycle:Xe.COMPLETE,positioned:!1,scrolling:!1,status:At.PAUSED,waiting:!1})}}},[e])}const Mle=new Set(["origin","positioned"]);function $le(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return pr(!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]&&!Mle.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||pr(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function Lle(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 Ro(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 Ole(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,w=zM(l)??null,g=m.useRef(null),k=m.useRef(o),b=m.useRef(a),j=m.useRef(s),N=m.useRef(l),C=m.useRef(w),I=m.useRef(n),R=m.useRef(null),H=m.useRef(null),A=m.useRef(null);k.current=o,b.current=a,j.current=s,N.current=l,C.current=w,I.current=n;const L=()=>{R.current&&(clearInterval(R.current),R.current=null),H.current=null,A.current&&(A.current.cancel(),A.current=null)};m.useEffect(()=>{if(!j.current)return;const{hasChangedTo:D}=Ro(b.current,j.current);(D("action",[Lt.NEXT,Lt.PREV,Lt.SKIP,Lt.CLOSE])||g.current===Lt.CLOSE&&u===Lt.START)&&(g.current=u)},[u]),m.useEffect(()=>{if(!j.current)return()=>{L()};const{hasChanged:D}=Ro(b.current,j.current),O=N.current;if(D("index")&&L(),v!==At.RUNNING||!O||f!==Xe.INIT)return()=>{L()};const{hasChangedTo:M}=Ro(b.current,j.current);M("status",At.RUNNING)&&[At.IDLE,At.READY,At.PAUSED].includes(j.current.status)&&r(cr.TOUR_START,O),c.current.cleanupPositionData();const{debug:K}=k.current;if(O.before&&!A.current){pr(K,`step:${d}`,"before()",O),A.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(cr.STEP_BEFORE_HOOK,O,{action:g.current??b.current.action});const z=()=>{A.current=null,c.current.updateState({action:g.current??b.current.action,waiting:!1,lifecycle:Xe.READY})},F=new AbortController,$=O.beforeTimeout;A.current={cancel:()=>F.abort()};const W=$?setTimeout(()=>{F.signal.aborted||(pr(K,`step:${d}`,"before()","timed out",`${$}ms`),F.abort(),t(O,"before_hook"),r(cr.ERROR,O,{error:new Error("Step before hook timed out")}),z())},$):null;O.before({...c.current.getState(),action:g.current??c.current.getState().action,step:O}).then(()=>{F.signal.aborted||(W&&clearTimeout(W),z())}).catch(E=>{F.signal.aborted||(W&&clearTimeout(W),t(O,"before_hook"),r(cr.ERROR,O,{error:E instanceof Error?E:new Error(String(E))}),z())})}else if(!A.current){R.current&&H.current!==O.target&&L();const z=As(O.target);if(z&&qp(z))L(),c.current.updateState({action:g.current??Lt.UPDATE,lifecycle:Xe.READY,waiting:!1});else if(O.targetWaitTimeout===0)c.current.updateState({action:g.current??Lt.UPDATE,lifecycle:Xe.READY,waiting:!1});else if(!R.current){const{targetWaitTimeout:F}=O,$=Date.now();H.current=O.target,pr(K,`step:${d}`,"polling","started",`${F}ms`),c.current.updateState({waiting:!0}),R.current=setInterval(()=>{const W=As(O.target),E=Date.now()-$,Q=E>=F;(W&&qp(W)||Q)&&(pr(K,`step:${d}`,"polling",W&&qp(W)?"found":"timed out",`${E}ms`),L(),c.current.updateState({action:g.current??Lt.UPDATE,lifecycle:Xe.READY,waiting:!1}))},100)}}return()=>{L()}},[t,r,d,f,v,c]),m.useEffect(()=>{if(!j.current)return;const{hasChanged:D,hasChangedTo:O,previous:M}=Ro(b.current,j.current),K=N.current;if(!K)return;const z=As(K.target),F=!!z;if(F&&qp(z)){if(O("lifecycle",Xe.READY)&&M.lifecycle===Xe.INIT&&r(cr.STEP_BEFORE,K,{action:g.current??b.current.action}),O("lifecycle",Xe.READY)){const $=b.current,W=Ple(K,$,k.current.continuous)?Xe.TOOLTIP:Xe.BEACON,E=As(K.scrollTarget??K.spotlightTarget??K.target),Q=G_({isFirstStep:$.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:K,target:E,targetLifecycle:W}),V=W===Xe.TOOLTIP?Xe.TOOLTIP_BEFORE:Xe.BEACON_BEFORE;pr(k.current.debug,`step:${d}`,"scroll",Q?"needed":"skipped"),c.current.updateState({action:Lt.UPDATE,lifecycle:V,scrolling:Q})}}else if(b.current.status===At.RUNNING&&f!==Xe.INIT&&f!==Xe.COMPLETE&&D("lifecycle")){pr(k.current.debug,`step:${d}`,F?"Target not visible":"Target not mounted",K),t(K,"target_not_found"),r(cr.TARGET_NOT_FOUND,K);const $=b.current;$.controlled||c.current.updateState({action:Lt.UPDATE,index:$.index+($.action===Lt.PREV?-1:1),lifecycle:Xe.INIT})}},[t,r,d,f,c]),m.useEffect(()=>{if(!j.current)return;const{hasChangedTo:D,previous:O}=Ro(b.current,j.current),M=N.current,K=C.current;if(M&&D("lifecycle",Xe.TOOLTIP_BEFORE)&&O.lifecycle===Xe.BEACON){const $=As(M.scrollTarget??M.spotlightTarget??M.target);if(G_({isFirstStep:b.current.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:M,target:$,targetLifecycle:Xe.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const z=f===Xe.BEACON_BEFORE||f===Xe.TOOLTIP_BEFORE;if(M&&z&&!h){const $=f===Xe.TOOLTIP_BEFORE?Xe.TOOLTIP:Xe.BEACON;c.current.updateState({action:Lt.UPDATE,lifecycle:$})}M&&D("lifecycle",Xe.BEACON)&&r(cr.BEACON,M),M&&D("lifecycle",Xe.TOOLTIP)&&r(cr.TOOLTIP,M);const F=b.current;if((F.status===At.RUNNING||F.controlled&&F.status===At.PAUSED&&M)&&K&&D("lifecycle",Xe.COMPLETE)&&O.lifecycle===Xe.TOOLTIP&&(r(cr.STEP_AFTER,K,{action:g.current??Lt.UPDATE,index:O.index??F.index,lifecycle:F.lifecycle}),K.after)){r(cr.STEP_AFTER_HOOK,K,{action:g.current??Lt.UPDATE,index:O.index??F.index,lifecycle:F.lifecycle});try{K.after({...c.current.getState(),action:g.current??Lt.UPDATE,index:O.index??F.index,lifecycle:F.lifecycle,step:K})}catch{}}},[r,f,p,h,c]),m.useEffect(()=>{if(!j.current)return;const{hasChangedTo:D,previous:O}=Ro(b.current,j.current),M=N.current,K=C.current;y&&!M&&f===Xe.INIT&&c.current.updateState({action:Lt.UPDATE,lifecycle:Xe.COMPLETE,status:At.FINISHED}),!b.current.controlled&&v===At.RUNNING&&D("lifecycle",Xe.COMPLETE)&&d<y&&c.current.updateState({action:Lt.UPDATE,lifecycle:Xe.INIT}),D("lifecycle",Xe.COMPLETE)&&d>=y&&c.current.updateState({action:Lt.UPDATE,lifecycle:Xe.COMPLETE,status:At.FINISHED});const z=M??K??$v(k.current,k.current.steps[d-1]);if(z&&D("status",[At.FINISHED,At.SKIPPED])){let F;M?F=d:K?F=O.index??d:F=d-1,r(cr.TOUR_END,z,{index:F}),b.current.controlled||I.current.reset(),g.current=null}M&&D("action",Lt.STOP)&&(g.current=null,r(cr.TOUR_STATUS,M)),M&&D("action",Lt.RESET)&&(r(cr.TOUR_STATUS,M),g.current=null)},[u,r,d,f,y,v,c])}function Dle({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}=Ro(n,h);if(jv(h.steps,u)||(f$(u,o)?s.current.setSteps(u):(pr(o,"tour","Steps are not valid",u),t(cr.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(_r.number(c)&&y("stepIndex")){const v=_r.number(h.stepIndex)&&h.stepIndex<c?Lt.NEXT:Lt.PREV;[At.FINISHED,At.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 Fle(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=zle(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=As(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 zle(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 w;(w=f.current)==null||w.call(f)},[]),m.useEffect(()=>{var N;if(!h.current||!v.current)return;const{hasChangedTo:w}=Ro(p.current,h.current),g=v.current,{debug:k}=y.current,{scrollDuration:b}=g,j=l===Xe.BEACON_BEFORE||l===Xe.TOOLTIP_BEFORE;if(d===At.RUNNING&&j&&u&&w("positioned",!0)){const C=As(g.scrollTarget??g.spotlightTarget??g.target),I=o.current.getPositionData("beacon"),R=Yc(C),H=R?!R.isSameNode(Gr()):!1;(N=f.current)==null||N.call(f),(async()=>{if(H&&!Gc(R)){const F=Gr(),$=Sle(R),W={initial:F.scrollTop,target:$,element:F,duration:b};e(cr.SCROLL_START,g,{scroll:W});const{cancel:E,promise:Q}=J_($,{element:F,duration:b});f.current=E,await Q,e(cr.SCROLL_END,g,{scroll:W})}const L=Math.floor(jle(C,g.scrollOffset))||0,D=H?L:Fle(L,{beaconPosition:I,lifecycle:l,scrollOffset:g.scrollOffset,step:g});pr(k,`step:${a}`,"scroll",H?"custom":"document",`${L} → ${D}`);const O=R,M={initial:O.scrollTop,target:D,element:O,duration:b};e(cr.SCROLL_START,g,{scroll:M});const{cancel:K,promise:z}=J_(D,{element:O,duration:b});f.current=K,await z,e(cr.SCROLL_END,g,{scroll:M}),o.current.updateState({scrolling:!1})})().catch(()=>{o.current.updateState({scrolling:!1})})}},[e,a,l,c,u,d,o])}function Hle(e){const t=joe(()=>xle(gle,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:o,stepIndex:a,steps:l}=t,c=m.useRef(Rle(t)),u=WI.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[d,f]=m.useState([]),p=m.useCallback((N,C)=>{f(I=>[...I,{reason:C,step:N}])},[]),h=m.useCallback(()=>{f([])},[]);$le(c,n);const y=Tle(c,n,h),v=Lle(s,y,c),{index:w,size:g,status:k}=u,b=zM(u),j=m.useMemo(()=>$v(t,l[w]),[w,t,l]);return Noe(()=>{o&&g&&f$(l,n)&&y.start(a??r)}),Soe(()=>{o&&g&&k===At.IDLE&&c.current.updateState({status:At.READY})},[o,g,k]),Dle({controls:y,emitEvent:v,props:t,state:u,store:c}),Ole({addFailure:p,controls:y,emitEvent:v,previousState:b,props:t,state:u,step:j,store:c}),Ble({emitEvent:v,previousState:b,props:t,state:u,step:j,store:c}),{controls:y,failures:d,mergedProps:t,state:u,step:j,store:c}}function Wle(e){const[t,n]=m.useState(null);return m.useEffect(()=>{let r=null,s=!1;if(e)if(_r.domElement(e))r=e,s=!0;else{const o=document.querySelector(e);o&&(r=o)}else{const o=document.createElement("div");o.id=yle,document.body.appendChild(o),r=o}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const Vle={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function Kle({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(m.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return tf;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
|
|
321
|
-
@keyframes joyride-loader-spin {
|
|
322
|
-
to { transform: rotate(360deg); }
|
|
323
|
-
}
|
|
324
|
-
`)),document.head.appendChild(c),()=>{const u=document.getElementById("joyride-loader-animation");u!=null&&u.parentNode&&u.parentNode.removeChild(u)}},[r,e]),n===null)return null;const{height:s,width:o,...a}=t.styles.loader;let l;if(n){const c=n;l=dt.createElement(c,{step:t})}else l=dt.createElement("div",{style:{...Vle,height:s,width:o,borderTopColor:t.primaryColor}});return dt.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const qle={height:0,isFixed:!1,left:0,top:0,width:0};function Du(e,t){const n=As(e);if(!n)return qle;const r=Mv(n),s=Gc(n),o=vle(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 Ule(e,t,n){const[r,s]=m.useState(()=>Du(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=Du(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=Yc(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(Du(e,t))},h=As(e);return h?p(h):(f=new MutationObserver(()=>{const y=As(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(Du(e,t)),l.current=n},[n,e,t]);let d=r;return l.current&&!n&&(d=Du(e,t)),d}function Yle(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function Q_(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 Gle=[Xe.BEACON_BEFORE,Xe.BEACON];function Jle(e){var z,F;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:s,onClickOverlay:o,overlayClickAction:a,placement:l,portalElement:c,scrolling:u,spotlightPadding:d,spotlightRadius:f,spotlightTarget:p,styles:h,target:y,waiting:v}=e,w=Coe(),g=Ule(p??y,d,u||v),k=m.useRef(null),b=(s===Xe.TOOLTIP||s===Xe.TOOLTIP_BEFORE)&&l!=="center",[j,N]=m.useState(!1),C=c?(z=k.current)==null?void 0:z.offsetParent:null,I=(C==null?void 0:C.clientWidth)??w.width,R=(C==null?void 0:C.clientHeight)??kle()??w.height,H=((F=h.overlay)==null?void 0:F.backgroundColor)??"rgba(0, 0, 0, 0.5)",A=m.useMemo(()=>{const{backgroundColor:$,mixBlendMode:W,...E}=h.overlay;return{height:R,pointerEvents:"none",...E}},[R,h.overlay]),L=b&&!u&&!v;m.useEffect(()=>{L?requestAnimationFrame(()=>N(!0)):N(!1)},[L]);const D=n&&Gle.includes(s),O=!n&&s!==Xe.TOOLTIP;if(r||!v&&(D||O))return null;let M="";if(L)if(c&&C){const $=As(p??y);if($){const W=Y_($),E=Y_(C);M=Q_(W.left-E.left-d.left,W.top-E.top-d.top,$.offsetWidth+d.left+d.right,$.offsetHeight+d.top+d.bottom,f)}}else M=Q_(g.left,g.top,g.width,g.height,f);const K=Yle(I,R,M);return dt.createElement("div",{ref:k,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:A},dt.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:R,left:0,position:g.isFixed?"fixed":"absolute",top:0,width:I}},dt.createElement("path",{d:K,fill:H,fillRule:"evenodd",onClick:o,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),M&&dt.createElement("path",{d:M,fill:H,style:{opacity:j?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),M&&Object.keys(h.spotlight).length>0&&dt.createElement("path",{d:M,fill:"none",style:{pointerEvents:"none"},...h.spotlight})))}function p$(e){const{children:t,element:n}=e;return n?ur.createPortal(t,n):null}const Xle='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function Qle(e,t){const n=m.useRef(null);m.useEffect(()=>{if(!e)return tf;n.current=document.activeElement;const r=o=>{if(o.key!=="Tab")return;const a=[...e.querySelectorAll(Xle)],{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 Zle(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 ece(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 tce({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=dt.createElement("span",{style:{flexShrink:0}},dt.createElement(l,{base:n,placement:r,size:o}))}else{const u=Zle(r,n,o);if(!u)return null;c=dt.createElement("svg",{height:u.height,width:u.width,xmlns:"http://www.w3.org/2000/svg"},dt.createElement("polygon",{fill:"currentColor",points:u.points}))}return dt.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,...ece(r,s,o,n),...s?{}:{visibility:"hidden"}}},c)}function nce(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 tf;const w=document.createElement("style");w.id="joyride-beacon-animation",a&&w.setAttribute("nonce",a),w.appendChild(document.createTextNode(`
|
|
325
|
-
@keyframes joyride-beacon-inner {
|
|
326
|
-
20% {
|
|
327
|
-
opacity: 0.9;
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
90% {
|
|
331
|
-
opacity: 0.7;
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
|
|
335
|
-
@keyframes joyride-beacon-outer {
|
|
336
|
-
0% {
|
|
337
|
-
transform: scale(1);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
45% {
|
|
341
|
-
opacity: 0.7;
|
|
342
|
-
transform: scale(0.75);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
100% {
|
|
346
|
-
opacity: 0.9;
|
|
347
|
-
transform: scale(1);
|
|
348
|
-
}
|
|
349
|
-
}
|
|
350
|
-
`)),document.head.appendChild(w);const g=setTimeout(()=>{_r.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 w=t;v=dt.createElement(w,{continuous:n,index:r,isLastStep:s,size:u,step:d})}else v=dt.createElement("span",{style:f.beacon},dt.createElement("span",{style:f.beaconOuter}),dt.createElement("span",{style:f.beaconInner}));return dt.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 rce({styles:e,...t}){const{color:n,height:r,width:s,...o}=e;return dt.createElement("button",{style:o,type:"button",...t},dt.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"},dt.createElement("g",null,dt.createElement("path",{d:"M8.13911129,9.00268191 L0.171521827,17.0258467 C-0.0498027049,17.248715 -0.0498027049,17.6098394 0.171521827,17.8327545 C0.28204354,17.9443526 0.427188206,17.9998706 0.572051765,17.9998706 C0.71714958,17.9998706 0.862013139,17.9443526 0.972581703,17.8327545 L9.0000937,9.74924618 L17.0276057,17.8327545 C17.1384085,17.9443526 17.2832721,17.9998706 17.4281356,17.9998706 C17.5729992,17.9998706 17.718097,17.9443526 17.8286656,17.8327545 C18.0499901,17.6098862 18.0499901,17.2487618 17.8286656,17.0258467 L9.86135722,9.00268191 L17.8340066,0.973848225 C18.0553311,0.750979934 18.0553311,0.389855532 17.8340066,0.16694039 C17.6126821,-0.0556467968 17.254037,-0.0556467968 17.0329467,0.16694039 L9.00042166,8.25611765 L0.967006424,0.167268345 C0.745681892,-0.0553188426 0.387317931,-0.0553188426 0.165993399,0.167268345 C-0.0553311331,0.390136635 -0.0553311331,0.751261038 0.165993399,0.974176179 L8.13920499,9.00268191 L8.13911129,9.00268191 Z",fill:n}))))}function sce(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:o,skipProps:a,step:l,tooltipProps:c}=e,{buttons:u,content:d,styles:f,title:p}=l,h={};u.includes("primary")&&(h.primary=dt.createElement("button",{"data-testid":"button-primary",style:f.buttonPrimary,type:"button",...o})),u.includes("skip")&&!s&&(h.skip=dt.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:f.buttonSkip,type:"button",...a})),u.includes("back")&&r>0&&(h.back=dt.createElement("button",{"data-testid":"button-back",style:f.buttonBack,type:"button",...t})),h.close=u.includes("close")&&dt.createElement(rce,{"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 dt.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:f.tooltip,...c,...y},dt.createElement("div",{style:f.tooltipContainer},p&&dt.createElement("h4",{id:"joyride-tooltip-title",style:f.tooltipTitle},p),dt.createElement("div",{id:"joyride-tooltip-content",style:f.tooltipContent},d)),u.some(v=>v==="back"||v==="primary"||v==="skip")&&dt.createElement("div",{style:f.tooltipFooter},dt.createElement("div",{style:f.tooltipFooterSpacer},h.skip),h.back,h.primary),h.close)}function ice(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:b,next:j,nextWithProgress:N,skip:C}=a.locale,I=Ui(g),R=Ui(k),H=Ui(b),A=Ui(j),L=Ui(C);let D=k,O=R;if(t){if(D=j,O=A,a.showProgress&&!s){const M=Ui(N,{step:r+1,steps:o});D=Ab(N,r+1,o),O=M}s&&(D=b,O=H)}return{backProps:{"aria-label":I,children:g,"data-action":"back",onClick:l,role:"button",title:I},closeProps:{"aria-label":R,children:k,"data-action":"close",onClick:c,role:"button",title:R},primaryProps:{"aria-label":O,children:D,"data-action":"primary",onClick:u,role:"button",title:O},skipProps:{"aria-label":L,children:C,"data-action":"skip",onClick:d,role:"button",title:L},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:p,beaconComponent:h,tooltipComponent:y,...v}=a;let w;if(y){const g=y;w=dt.createElement(g,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v})}else w=dt.createElement(sce,{...f(),continuous:t,controls:n,index:r,isLastStep:s,size:o,step:v});return w}function oce(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function ace(e,t,n){var r,s;return e?[dle()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[ule({crossAxis:!1,fallbackPlacements:oce(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function lce(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),w=m.useRef({}),g=m.useRef({}),k=p.placement==="center",b=p.placement==="auto",j=m.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),N=m.useMemo(()=>c$(h)?Yc(h):void 0,[h]),C=m.useMemo(()=>Gc(h),[h]),I=m.useMemo(()=>N?{boundary:N,rootBoundary:"viewport"}:{},[N]),R=k||b?"bottom":p.placement,H=k?"fixed":((W=p.floatingOptions)==null?void 0:W.strategy)??(p.isFixed||C?"fixed":"absolute"),A=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})}]:[K_(({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]),...ace(b,p,R),cle({padding:10,...I,...(ue=p.floatingOptions)==null?void 0:ue.shiftOptions}),...(G=p.floatingOptions)!=null&&G.hideArrow?[]:[fle({element:v,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((ee=p.floatingOptions)==null?void 0:ee.middleware)??[]]},[k,p,b,R,I]),L=V_({...k?{elements:{reference:j}}:{},placement:R,strategy:H,middleware:A}),D=V_({strategy:H,placement:p.beaconPlacement??(b||k?"bottom":p.placement),middleware:m.useMemo(()=>{var se,ue;return[K_(((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:B_});g.current=L.middlewareData,w.current=D.middlewareData,m.useEffect(()=>{var G;const{floating:se,reference:ue}=L.elements;if(!(!ue||!se||s!==Xe.TOOLTIP))return B_(ue,se,L.update,(G=p.floatingOptions)==null?void 0:G.autoUpdate)},[s,L.update,(V=p.floatingOptions)==null?void 0:V.autoUpdate,p.target,L.elements]),m.useEffect(()=>{!k&&h&&L.refs.setReference(h),h&&D.refs.setReference(h)},[D.refs,k,h,L.refs]),m.useEffect(()=>{L.isPositioned&&c("tooltip",{placement:L.placement,x:L.x??0,y:L.y??0,middlewareData:g.current})},[c,L.isPositioned,L.placement,L.x,L.y]),m.useEffect(()=>{D.isPositioned&&c("beacon",{placement:D.placement,x:D.x??0,y:D.y??0,middlewareData:w.current})},[c,D.isPositioned,D.placement,D.x,D.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&&(L.refs.setFloating(se),u(se))},[L.refs,u]),{arrow:z,floater:F}=p.styles;let $=null;if(s===Xe.TOOLTIP||s===Xe.TOOLTIP_BEFORE){const se=U_({...F,...L.floatingStyles,zIndex:O,opacity:a&&L.isPositioned?1:0,...!a&&{transition:"none"}});$=dt.createElement("div",{ref:K,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:se},dt.createElement(ice,{continuous:t,controls:n,index:r,isLastStep:r+1===f,size:f,step:p}),!k&&!((B=p.floatingOptions)!=null&&B.hideArrow)&&dt.createElement(tce,{arrowComponent:p.arrowComponent,arrowRef:v,base:p.arrowBase,placement:L.placement,position:L.middlewareData.arrow,size:p.arrowSize,styles:z}))}else(s===Xe.BEACON||s===Xe.BEACON_BEFORE)&&($=dt.createElement("div",{ref:D.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:U_({...D.floatingStyles,zIndex:O})},dt.createElement(nce,{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 dt.createElement(p$,{element:l},$)}function cce(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);Qle(d.disableFocusTrap?null:p,"[data-action=primary]");const y=As(d.target),v=s===Xe.TOOLTIP;return!d$(d)||!_r.domElement(y)?null:dt.createElement(lce,{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 uce({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:o,debug:a,nonce:l,portalElement:c,scrollToFirstStep:u}=t,d=Wle(c),{index:f,lifecycle:p,status:h}=n,y=h===At.RUNNING,[v,w]=m.useState(!1),g=m.useRef(null),k=(r==null?void 0:r.loaderDelay)??0;m.useEffect(()=>(n.waiting?k===0?w(!0):g.current=setTimeout(()=>{w(!0)},k):w(!1),()=>{g.current&&(clearTimeout(g.current),g.current=null)}),[k,n.waiting]),m.useEffect(()=>{if(!y)return;const N=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",N,{passive:!0}),()=>{document.body.removeEventListener("keydown",N)}},[e,y,p,r]);const b=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 j=n.action===Lt.START&&!r.skipBeacon&&r.placement!=="center";return dt.createElement(dt.Fragment,null,p!==Xe.INIT&&dt.createElement(cce,{...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}),dt.createElement(p$,{element:d},dt.createElement(dt.Fragment,null,v&&dt.createElement(Kle,{nonce:l,step:r}),!j&&dt.createElement(Jle,{...r,continuous:o,lifecycle:p,onClickOverlay:b,portalElement:c?d:null,scrolling:n.scrolling,waiting:n.waiting}))))}function dce(e){const{controls:t,failures:n,mergedProps:r,state:s,step:o,store:a}=Hle(e);return{controls:t,failures:n,on:m.useCallback((l,c)=>a.current.on(l,c),[a]),state:m.useMemo(()=>Em(s,"positioned"),[s]),step:o,Tour:Tv()?dt.createElement(uce,{controls:t,mergedProps:r,state:s,step:o,store:a}):null}}function fce(e){const{Tour:t}=dce(e);return t}function pce(e){return Tv()?dt.createElement(fce,e):null}function hce(e){return[{target:"body",content:e("onboarding:projects.intro"),disableBeacon:!0,placement:"center"},{target:".af-hub-card",content:e("onboarding:projects.hubIntro"),disableBeacon:!0,placement:"left"}]}function mce(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function gce(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const Yp="af:onboarding";function yce({page:e,hasNodes:t=!1}){const{t:n}=zr(),[r,s]=m.useState(!1),[o,a]=m.useState([]),l=m.useRef(null),c=m.useMemo(()=>e==="projects"?hce(n):t?mce(n):gce(n),[e,t,n]);return m.useEffect(()=>{const u=localStorage.getItem(Yp),d=u?JSON.parse(u):{};if(d.completed||d[e]){s(!1),a([]);return}localStorage.setItem(Yp,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(Yp)||"{}",w=JSON.parse(v);h===n("onboarding:skip")?(w.projects=!0,w.flow=!0,w.completed=!0):w[e]=!0,localStorage.setItem(Yp,JSON.stringify(w)),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(pce,{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 wce="agentflow:recent-runs:v1",xce="agentflow:recent-runs:poller",bce=3e3,kce=8e3,vce=2e3,Z_=5e3,Sce=16e3,eE=[1e4,3e4,6e4];function jce(e){return eE[Math.min(Math.max(e-1,0),eE.length-1)]}function Nce(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Cce(e){if(!e)return"暂无成功记录";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"暂无成功记录"}}function _ce(){const{navigate:e,path:t}=gs(),[n,r]=m.useState([]),[s,o]=m.useState(!1),[a,l]=m.useState(1),[c,u]=m.useState({status:"idle",failureCount:0,lastSuccessAt:0,message:""}),d=m.useRef(()=>{});m.useEffect(()=>{let j=!1,N=!1,C=!1,I=null,R=0,H=0,A=0,L=0,D=null,O=0,M=0;const K=Nce(),z=new Map,F=typeof BroadcastChannel=="function"?new BroadcastChannel(wce):null,$=Ce=>{try{F==null||F.postMessage({...Ce,tabId:K,sentAt:Date.now()})}catch{}},W=()=>{const Ce=Date.now()-Sce;for(const[_e,Be]of z)Be<Ce&&z.delete(_e);l(1+z.size)},E=(Ce="presence")=>{$({type:Ce,visible:!document.hidden})},Q=Ce=>{if(!j&&(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),$({type:"state",...Ce})},B=()=>{R&&(window.clearTimeout(R),R=0)},se=Ce=>{B(),!(j||!N||document.hidden)&&(R=window.setTimeout(()=>{R=0,ue()},Math.max(0,Ce)))},ue=async()=>{if(j||!N||document.hidden||D)return;const Ce=new AbortController;D=Ce;let _e=!1;const Be=window.setTimeout(()=>{_e=!0,Ce.abort()},kce);try{const ot=await fetch("/api/pipeline-recent-runs",{signal:Ce.signal});if(!ot.ok)throw new Error(`HTTP ${ot.status}`);const gt=await ot.json();if(j||!N||document.hidden)return;O=0,M=Date.now();const Te=Array.isArray(gt.runs)?gt.runs:[];V({runs:Te.filter(st=>st&&st.status==="running"),syncHealth:{status:"ok",failureCount:0,lastSuccessAt:M,message:""}}),se(bce)}catch(ot){const gt=Ce.signal.aborted&&!_e;if(j||!N||document.hidden||gt)return;O+=1,V({syncHealth:{status:"delayed",failureCount:O,lastSuccessAt:M,message:_e?"运行状态同步超过 8 秒未响应":`运行状态同步失败:${String((ot==null?void 0:ot.message)||ot)}`}}),se(jce(O))}finally{window.clearTimeout(Be),D===Ce&&(D=null)}},G=()=>{B(),D&&(D.abort(),D=null)},ee=()=>{if(G(),I){const Ce=I;I=null,Ce()}N=!1},te=(Ce=vce)=>{H&&window.clearTimeout(H),!(j||document.hidden||N||C)&&(H=window.setTimeout(()=>{H=0,Z()},Ce))},ne=()=>{j||document.hidden||N||(N=!0,se(0))},Z=async()=>{var Ce;if(!(j||document.hidden||N||C)){if(!((Ce=navigator.locks)!=null&&Ce.request)){ne();return}C=!0;try{await navigator.locks.request(xce,{mode:"exclusive",ifAvailable:!0},async _e=>{if(C=!1,!_e||j||document.hidden){te();return}N=!0,se(0),await new Promise(Be=>{I=Be}),I=null,N=!1})}catch{C=!1}finally{te()}}},ce=()=>{if(!j){if(N){O=0,se(0);return}$({type:"retry"}),te(0)}};d.current=ce,F&&(F.onmessage=Ce=>{const _e=Ce.data;if(!(!_e||_e.tabId===K)){if(_e.type==="hello"||_e.type==="presence"){z.set(_e.tabId,Date.now()),W(),_e.type==="hello"&&E();return}if(_e.type==="bye"){z.delete(_e.tabId),W(),te(0);return}if(_e.type==="state"){z.set(_e.tabId,Date.now()),W(),Q(_e);return}_e.type==="retry"&&N&&(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"),A=window.setInterval(E,Z_),L=window.setInterval(W,Z_),te(0),()=>{j=!0,d.current=()=>{},E("bye"),ee(),H&&window.clearTimeout(H),A&&window.clearInterval(A),L&&window.clearInterval(L),document.removeEventListener("visibilitychange",de),window.removeEventListener("pagehide",me),window.removeEventListener("pageshow",$e),F==null||F.close()}},[]);const f=j=>{const N=new URLSearchParams({flowId:j.flowId,flowSource:j.flowSource||"workspace"});e(`/flow?${N.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,w=n.length===1;if(n.length===0&&!y)return null;const g=y?"状态同步延迟":n.length>0?w?n[0].flowId:`${n.length} running`:"",k=y?`${c.message}${v?`;检测到 ${a} 个 AgentFlow 标签页`:""}`:v?`已合并 ${a} 个 AgentFlow 标签页的运行状态同步`:w?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,b=()=>{if(!y&&!v&&w){f(n[0]);return}o(j=>!j)};return i.jsxs("div",{className:"af-run-indicator"+(y?" af-run-indicator--delayed":"")+(v?" af-run-indicator--coordinated":""),role:"status","aria-live":"polite",children:[s&&i.jsxs("div",{className:"af-run-indicator__menu",onMouseLeave:()=>o(!1),children:[(y||v)&&i.jsxs("div",{className:"af-run-indicator__sync",children:[i.jsx("div",{className:"af-run-indicator__sync-title",children:y?"运行状态同步延迟":"多标签页同步已合并"}),i.jsx("div",{className:"af-run-indicator__sync-copy",children:v?`检测到 ${a} 个 AgentFlow 标签页。当前只由一个可见标签页请求运行状态,后台页面不会重复建立连接。`:"运行状态接口暂未及时返回,已停止重复请求并自动降低刷新频率。"}),y&&i.jsxs("div",{className:"af-run-indicator__sync-meta",children:["最近成功:",Cce(c.lastSuccessAt)]}),y&&i.jsx("button",{type:"button",className:"af-run-indicator__retry",onClick:j=>{j.stopPropagation(),d.current()},children:"立即重试"})]}),n.map(j=>i.jsxs("button",{type:"button",className:"af-run-indicator__item"+(j.flowId===h?" af-run-indicator__item--current":""),onClick:()=>f(j),title:`${j.flowId} · ${j.runId}`,children:[i.jsx("span",{className:"af-run-indicator__dot"}),i.jsx("span",{className:"af-run-indicator__flow",children:j.flowId}),i.jsx("span",{className:"af-run-indicator__run",children:j.runId.slice(0,12)})]},`${j.flowId}:${j.runId}`))]}),i.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:b,title:k,children:[i.jsx("span",{className:"af-run-indicator__pulse"}),i.jsx("span",{className:"af-run-indicator__label",children:g})]})]})}const _w="0.1.131",Ece=6e4,Ace=30*6e4;function Oc(e){return String(e||"").trim().replace(/^v/i,"")}function Pce(e,t){const n=Oc(e),r=Oc(t);return!!(n&&r&&n!==r)}function Ice(e,t){return`agentflow.app-version.snooze:${Oc(e)}:${Oc(t)}`}function Rce(e){if(!e)return 0;try{const t=Number(window.sessionStorage.getItem(e));return Number.isFinite(t)?t:0}catch{return 0}}function Tce(){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=Oc(u.version);if(!Pce(_w,d)){t(null);return}const f=Ice(_w,d);if(Rce(f)>Date.now())return;t({clientVersion:Oc(_w),serverVersion:d,startedAt:String(u.startedAt||""),snoozeKey:f})}catch{}finally{s=!1}}},a=()=>{document.visibilityState==="visible"&&o()},l=window.setInterval(()=>void o(),Ece);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()+Ace))}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 h$(e){return e==="/likee-context"||e==="/likee_context"}function Mce(e){if(e!=="/workspace")return!1;const t=new URLSearchParams(window.location.search);return!!String(t.get("workflowShare")||"").trim()}function $ce(){const{navigate:e}=gs();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 Lce 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 Oce({authUser:e}){const{path:t}=gs();return t==="/projects"||t==="/"?i.jsx(Il,{authUser:e}):t==="/nodes"?i.jsx(Il,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?i.jsx(Il,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?i.jsx(Il,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?i.jsx(Il,{authUser:e,resourceKind:"skills"}):t==="/workspaces"?i.jsx(Gie,{authUser:e}):t==="/workflows"?i.jsx(toe,{}):t==="/mcps"?i.jsx(Oie,{}):t==="/schedules"?i.jsx(Bie,{}):t==="/node-studio"?i.jsx(Wie,{}):t==="/flow"?i.jsx($ce,{}):t==="/workspace"?i.jsx(vM,{}):t.startsWith("/display")?i.jsx(NM,{}):t==="/settings"?i.jsx(vie,{authUser:e}):t==="/admin/usage"?i.jsx(Pie,{authUser:e}):t==="/feedback"?i.jsx(Rie,{authUser:e}):h$(t)?i.jsx(DM,{}):i.jsx(Il,{})}function Dce({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 Fce({authUser:e,onLogout:t}){const{path:n}=gs(),r=n==="/flow"||n==="/workspace";return i.jsxs("div",{className:"af-app",children:[n!=="/settings"?i.jsx(yce,{page:r?"flow":"projects"}):null,r?null:i.jsx(DD,{authUser:e,onLogout:t}),i.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:i.jsx(Oce,{authUser:e})}),i.jsx(_ce,{})]})}function zce(){return i.jsx(Lce,{children:i.jsxs(xD,{children:[i.jsx(Bce,{}),i.jsx(Tce,{})]})})}function Bce(){const{path:e}=gs();return e.startsWith("/display")?i.jsx(NM,{}):h$(e)?i.jsx(DM,{}):Mce(e)?i.jsx(vM,{}):i.jsx(Dce,{children:({user:t,onLogout:n})=>i.jsx(Fce,{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 tE=document.querySelector('link[rel="icon"]');tE&&(tE.href=yP);Ew.createRoot(document.getElementById("root")).render(i.jsx(dt.StrictMode,{children:i.jsx(zce,{})}));
|