@fieldwangai/agentflow 0.1.61 → 0.1.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,238 +0,0 @@
1
- var N2=Object.defineProperty;var j2=(e,t,n)=>t in e?N2(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var er=(e,t,n)=>j2(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const a of i.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function r(s){if(s.ep)return;s.ep=!0;const i=n(s);fetch(s.href,i)}})();var ff=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function ul(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var kC={exports:{}},Sg={},SC={exports:{}},Mt={};/**
2
- * @license React
3
- * react.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var Zf=Symbol.for("react.element"),C2=Symbol.for("react.portal"),E2=Symbol.for("react.fragment"),_2=Symbol.for("react.strict_mode"),P2=Symbol.for("react.profiler"),A2=Symbol.for("react.provider"),I2=Symbol.for("react.context"),T2=Symbol.for("react.forward_ref"),R2=Symbol.for("react.suspense"),L2=Symbol.for("react.memo"),O2=Symbol.for("react.lazy"),sk=Symbol.iterator;function M2(e){return e===null||typeof e!="object"?null:(e=sk&&e[sk]||e["@@iterator"],typeof e=="function"?e:null)}var NC={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},jC=Object.assign,CC={};function Du(e,t,n){this.props=e,this.context=t,this.refs=CC,this.updater=n||NC}Du.prototype.isReactComponent={};Du.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")};Du.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function EC(){}EC.prototype=Du.prototype;function Hb(e,t,n){this.props=e,this.context=t,this.refs=CC,this.updater=n||NC}var Wb=Hb.prototype=new EC;Wb.constructor=Hb;jC(Wb,Du.prototype);Wb.isPureReactComponent=!0;var ik=Array.isArray,_C=Object.prototype.hasOwnProperty,Vb={current:null},PC={key:!0,ref:!0,__self:!0,__source:!0};function AC(e,t,n){var r,s={},i=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(i=""+t.key),t)_C.call(t,r)&&!PC.hasOwnProperty(r)&&(s[r]=t[r]);var l=arguments.length-2;if(l===1)s.children=n;else if(1<l){for(var u=Array(l),d=0;d<l;d++)u[d]=arguments[d+2];s.children=u}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)s[r]===void 0&&(s[r]=l[r]);return{$$typeof:Zf,type:e,key:i,ref:a,props:s,_owner:Vb.current}}function $2(e,t){return{$$typeof:Zf,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function Ub(e){return typeof e=="object"&&e!==null&&e.$$typeof===Zf}function D2(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var ok=/\/+/g;function jy(e,t){return typeof e=="object"&&e!==null&&e.key!=null?D2(""+e.key):t.toString(36)}function Wh(e,t,n,r,s){var i=typeof e;(i==="undefined"||i==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(i){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case Zf:case C2:a=!0}}if(a)return a=e,s=s(a),e=r===""?"."+jy(a,0):r,ik(s)?(n="",e!=null&&(n=e.replace(ok,"$&/")+"/"),Wh(s,t,n,"",function(d){return d})):s!=null&&(Ub(s)&&(s=$2(s,n+(!s.key||a&&a.key===s.key?"":(""+s.key).replace(ok,"$&/")+"/")+e)),t.push(s)),1;if(a=0,r=r===""?".":r+":",ik(e))for(var l=0;l<e.length;l++){i=e[l];var u=r+jy(i,l);a+=Wh(i,t,n,u,s)}else if(u=M2(e),typeof u=="function")for(e=u.call(e),l=0;!(i=e.next()).done;)i=i.value,u=r+jy(i,l++),a+=Wh(i,t,n,u,s);else if(i==="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 Jp(e,t,n){if(e==null)return e;var r=[],s=0;return Wh(e,r,"","",function(i){return t.call(n,i,s++)}),r}function F2(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 fs={current:null},Vh={transition:null},z2={ReactCurrentDispatcher:fs,ReactCurrentBatchConfig:Vh,ReactCurrentOwner:Vb};function IC(){throw Error("act(...) is not supported in production builds of React.")}Mt.Children={map:Jp,forEach:function(e,t,n){Jp(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Jp(e,function(){t++}),t},toArray:function(e){return Jp(e,function(t){return t})||[]},only:function(e){if(!Ub(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};Mt.Component=Du;Mt.Fragment=E2;Mt.Profiler=P2;Mt.PureComponent=Hb;Mt.StrictMode=_2;Mt.Suspense=R2;Mt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=z2;Mt.act=IC;Mt.cloneElement=function(e,t,n){if(e==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+e+".");var r=jC({},e.props),s=e.key,i=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(i=t.ref,a=Vb.current),t.key!==void 0&&(s=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(u in t)_C.call(t,u)&&!PC.hasOwnProperty(u)&&(r[u]=t[u]===void 0&&l!==void 0?l[u]:t[u])}var u=arguments.length-2;if(u===1)r.children=n;else if(1<u){l=Array(u);for(var d=0;d<u;d++)l[d]=arguments[d+2];r.children=l}return{$$typeof:Zf,type:e.type,key:s,ref:i,props:r,_owner:a}};Mt.createContext=function(e){return e={$$typeof:I2,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:A2,_context:e},e.Consumer=e};Mt.createElement=AC;Mt.createFactory=function(e){var t=AC.bind(null,e);return t.type=e,t};Mt.createRef=function(){return{current:null}};Mt.forwardRef=function(e){return{$$typeof:T2,render:e}};Mt.isValidElement=Ub;Mt.lazy=function(e){return{$$typeof:O2,_payload:{_status:-1,_result:e},_init:F2}};Mt.memo=function(e,t){return{$$typeof:L2,type:e,compare:t===void 0?null:t}};Mt.startTransition=function(e){var t=Vh.transition;Vh.transition={};try{e()}finally{Vh.transition=t}};Mt.unstable_act=IC;Mt.useCallback=function(e,t){return fs.current.useCallback(e,t)};Mt.useContext=function(e){return fs.current.useContext(e)};Mt.useDebugValue=function(){};Mt.useDeferredValue=function(e){return fs.current.useDeferredValue(e)};Mt.useEffect=function(e,t){return fs.current.useEffect(e,t)};Mt.useId=function(){return fs.current.useId()};Mt.useImperativeHandle=function(e,t,n){return fs.current.useImperativeHandle(e,t,n)};Mt.useInsertionEffect=function(e,t){return fs.current.useInsertionEffect(e,t)};Mt.useLayoutEffect=function(e,t){return fs.current.useLayoutEffect(e,t)};Mt.useMemo=function(e,t){return fs.current.useMemo(e,t)};Mt.useReducer=function(e,t,n){return fs.current.useReducer(e,t,n)};Mt.useRef=function(e){return fs.current.useRef(e)};Mt.useState=function(e){return fs.current.useState(e)};Mt.useSyncExternalStore=function(e,t,n){return fs.current.useSyncExternalStore(e,t,n)};Mt.useTransition=function(){return fs.current.useTransition()};Mt.version="18.3.1";SC.exports=Mt;var h=SC.exports;const lt=ul(h);/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var B2=h,H2=Symbol.for("react.element"),W2=Symbol.for("react.fragment"),V2=Object.prototype.hasOwnProperty,U2=B2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,K2={key:!0,ref:!0,__self:!0,__source:!0};function TC(e,t,n){var r,s={},i=null,a=null;n!==void 0&&(i=""+n),t.key!==void 0&&(i=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)V2.call(t,r)&&!K2.hasOwnProperty(r)&&(s[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)s[r]===void 0&&(s[r]=t[r]);return{$$typeof:H2,type:e,key:i,ref:a,props:s,_owner:U2.current}}Sg.Fragment=W2;Sg.jsx=TC;Sg.jsxs=TC;kC.exports=Sg;var o=kC.exports,Kx={},RC={exports:{}},ri={},LC={exports:{}},OC={};/**
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(C,T){var E=C.length;C.push(T);e:for(;0<E;){var G=E-1>>>1,Z=C[G];if(0<s(Z,T))C[G]=T,C[E]=Z,E=G;else break e}}function n(C){return C.length===0?null:C[0]}function r(C){if(C.length===0)return null;var T=C[0],E=C.pop();if(E!==T){C[0]=E;e:for(var G=0,Z=C.length,V=Z>>>1;G<V;){var se=2*(G+1)-1,de=C[se],fe=se+1,pe=C[fe];if(0>s(de,E))fe<Z&&0>s(pe,de)?(C[G]=pe,C[fe]=E,G=fe):(C[G]=de,C[se]=E,G=se);else if(fe<Z&&0>s(pe,E))C[G]=pe,C[fe]=E,G=fe;else break e}}return T}function s(C,T){var E=C.sortIndex-T.sortIndex;return E!==0?E:C.id-T.id}if(typeof performance=="object"&&typeof performance.now=="function"){var i=performance;e.unstable_now=function(){return i.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var u=[],d=[],f=1,c=null,p=3,m=!1,g=!1,b=!1,k=typeof setTimeout=="function"?setTimeout:null,y=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function w(C){for(var T=n(d);T!==null;){if(T.callback===null)r(d);else if(T.startTime<=C)r(d),T.sortIndex=T.expirationTime,t(u,T);else break;T=n(d)}}function j(C){if(b=!1,w(C),!g)if(n(u)!==null)g=!0,I(P);else{var T=n(d);T!==null&&z(j,T.startTime-C)}}function P(C,T){g=!1,b&&(b=!1,y(B),B=-1),m=!0;var E=p;try{for(w(T),c=n(u);c!==null&&(!(c.expirationTime>T)||C&&!R());){var G=c.callback;if(typeof G=="function"){c.callback=null,p=c.priorityLevel;var Z=G(c.expirationTime<=T);T=e.unstable_now(),typeof Z=="function"?c.callback=Z:c===n(u)&&r(u),w(T)}else r(u);c=n(u)}if(c!==null)var V=!0;else{var se=n(d);se!==null&&z(j,se.startTime-T),V=!1}return V}finally{c=null,p=E,m=!1}}var _=!1,L=null,B=-1,D=5,F=-1;function R(){return!(e.unstable_now()-F<D)}function M(){if(L!==null){var C=e.unstable_now();F=C;var T=!0;try{T=L(!0,C)}finally{T?W():(_=!1,L=null)}}else _=!1}var W;if(typeof v=="function")W=function(){v(M)};else if(typeof MessageChannel<"u"){var O=new MessageChannel,$=O.port2;O.port1.onmessage=M,W=function(){$.postMessage(null)}}else W=function(){k(M,0)};function I(C){L=C,_||(_=!0,W())}function z(C,T){B=k(function(){C(e.unstable_now())},T)}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(C){C.callback=null},e.unstable_continueExecution=function(){g||m||(g=!0,I(P))},e.unstable_forceFrameRate=function(C){0>C||125<C?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):D=0<C?Math.floor(1e3/C):5},e.unstable_getCurrentPriorityLevel=function(){return p},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(C){switch(p){case 1:case 2:case 3:var T=3;break;default:T=p}var E=p;p=T;try{return C()}finally{p=E}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(C,T){switch(C){case 1:case 2:case 3:case 4:case 5:break;default:C=3}var E=p;p=C;try{return T()}finally{p=E}},e.unstable_scheduleCallback=function(C,T,E){var G=e.unstable_now();switch(typeof E=="object"&&E!==null?(E=E.delay,E=typeof E=="number"&&0<E?G+E:G):E=G,C){case 1:var Z=-1;break;case 2:Z=250;break;case 5:Z=1073741823;break;case 4:Z=1e4;break;default:Z=5e3}return Z=E+Z,C={id:f++,callback:T,priorityLevel:C,startTime:E,expirationTime:Z,sortIndex:-1},E>G?(C.sortIndex=E,t(d,C),n(u)===null&&C===n(d)&&(b?(y(B),B=-1):b=!0,z(j,E-G))):(C.sortIndex=Z,t(u,C),g||m||(g=!0,I(P))),C},e.unstable_shouldYield=R,e.unstable_wrapCallback=function(C){var T=p;return function(){var E=p;p=T;try{return C.apply(this,arguments)}finally{p=E}}}})(OC);LC.exports=OC;var q2=LC.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 Y2=h,ti=q2;function je(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 MC=new Set,pf={};function uc(e,t){yu(e,t),yu(e+"Capture",t)}function yu(e,t){for(pf[e]=t,e=0;e<t.length;e++)MC.add(t[e])}var oa=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),qx=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]*$/,ak={},lk={};function X2(e){return qx.call(lk,e)?!0:qx.call(ak,e)?!1:G2.test(e)?lk[e]=!0:(ak[e]=!0,!1)}function J2(e,t,n,r){if(n!==null&&n.type===0)return!1;switch(typeof t){case"function":case"symbol":return!0;case"boolean":return r?!1:n!==null?!n.acceptsBooleans:(e=e.toLowerCase().slice(0,5),e!=="data-"&&e!=="aria-");default:return!1}}function Q2(e,t,n,r){if(t===null||typeof t>"u"||J2(e,t,n,r))return!0;if(r)return!1;if(n!==null)switch(n.type){case 3:return!t;case 4:return t===!1;case 5:return isNaN(t);case 6:return isNaN(t)||1>t}return!1}function ps(e,t,n,r,s,i,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=i,this.removeEmptyString=a}var Dr={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Dr[e]=new ps(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Dr[t]=new ps(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Dr[e]=new ps(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Dr[e]=new ps(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){Dr[e]=new ps(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Dr[e]=new ps(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Dr[e]=new ps(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Dr[e]=new ps(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Dr[e]=new ps(e,5,!1,e.toLowerCase(),null,!1,!1)});var Kb=/[\-:]([a-z])/g;function qb(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(Kb,qb);Dr[t]=new ps(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(Kb,qb);Dr[t]=new ps(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(Kb,qb);Dr[t]=new ps(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Dr[e]=new ps(e,1,!1,e.toLowerCase(),null,!1,!1)});Dr.xlinkHref=new ps("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Dr[e]=new ps(e,1,!1,e.toLowerCase(),null,!0,!0)});function Yb(e,t,n,r){var s=Dr.hasOwnProperty(t)?Dr[t]:null;(s!==null?s.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(Q2(t,n,s,r)&&(n=null),r||s===null?X2(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 pa=Y2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Qp=Symbol.for("react.element"),Bc=Symbol.for("react.portal"),Hc=Symbol.for("react.fragment"),Gb=Symbol.for("react.strict_mode"),Yx=Symbol.for("react.profiler"),$C=Symbol.for("react.provider"),DC=Symbol.for("react.context"),Xb=Symbol.for("react.forward_ref"),Gx=Symbol.for("react.suspense"),Xx=Symbol.for("react.suspense_list"),Jb=Symbol.for("react.memo"),Oa=Symbol.for("react.lazy"),FC=Symbol.for("react.offscreen"),ck=Symbol.iterator;function xd(e){return e===null||typeof e!="object"?null:(e=ck&&e[ck]||e["@@iterator"],typeof e=="function"?e:null)}var Gn=Object.assign,Cy;function Md(e){if(Cy===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);Cy=t&&t[1]||""}return`
34
- `+Cy+e}var Ey=!1;function _y(e,t){if(!e||Ey)return"";Ey=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(d){var r=d}Reflect.construct(e,[],t)}else{try{t.call()}catch(d){r=d}e.call(t.prototype)}else{try{throw Error()}catch(d){r=d}e()}}catch(d){if(d&&r&&typeof d.stack=="string"){for(var s=d.stack.split(`
35
- `),i=r.stack.split(`
36
- `),a=s.length-1,l=i.length-1;1<=a&&0<=l&&s[a]!==i[l];)l--;for(;1<=a&&0<=l;a--,l--)if(s[a]!==i[l]){if(a!==1||l!==1)do if(a--,l--,0>l||s[a]!==i[l]){var u=`
37
- `+s[a].replace(" at new "," at ");return e.displayName&&u.includes("<anonymous>")&&(u=u.replace("<anonymous>",e.displayName)),u}while(1<=a&&0<=l);break}}}finally{Ey=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?Md(e):""}function Z2(e){switch(e.tag){case 5:return Md(e.type);case 16:return Md("Lazy");case 13:return Md("Suspense");case 19:return Md("SuspenseList");case 0:case 2:case 15:return e=_y(e.type,!1),e;case 11:return e=_y(e.type.render,!1),e;case 1:return e=_y(e.type,!0),e;default:return""}}function Jx(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 Hc:return"Fragment";case Bc:return"Portal";case Yx:return"Profiler";case Gb:return"StrictMode";case Gx:return"Suspense";case Xx:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case DC:return(e.displayName||"Context")+".Consumer";case $C:return(e._context.displayName||"Context")+".Provider";case Xb:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case Jb:return t=e.displayName||null,t!==null?t:Jx(e.type)||"Memo";case Oa:t=e._payload,e=e._init;try{return Jx(e(t))}catch{}}return null}function eL(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 Jx(t);case 8:return t===Gb?"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 rl(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function zC(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function tL(e){var t=zC(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,i=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return s.call(this)},set:function(a){r=""+a,i.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 Zp(e){e._valueTracker||(e._valueTracker=tL(e))}function BC(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=zC(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function hm(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 Qx(e,t){var n=t.checked;return Gn({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function uk(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=rl(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 HC(e,t){t=t.checked,t!=null&&Yb(e,"checked",t,!1)}function Zx(e,t){HC(e,t);var n=rl(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")?ew(e,t.type,n):t.hasOwnProperty("defaultValue")&&ew(e,t.type,rl(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function dk(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 ew(e,t,n){(t!=="number"||hm(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var $d=Array.isArray;function iu(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=""+rl(n),t=null,s=0;s<e.length;s++){if(e[s].value===n){e[s].selected=!0,r&&(e[s].defaultSelected=!0);return}t!==null||e[s].disabled||(t=e[s])}t!==null&&(t.selected=!0)}}function tw(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(je(91));return Gn({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function fk(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(je(92));if($d(n)){if(1<n.length)throw Error(je(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:rl(n)}}function WC(e,t){var n=rl(t.value),r=rl(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 pk(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function VC(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 nw(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?VC(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var eh,UC=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(eh=eh||document.createElement("div"),eh.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=eh.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function hf(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var qd={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},nL=["Webkit","ms","Moz","O"];Object.keys(qd).forEach(function(e){nL.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),qd[t]=qd[e]})});function KC(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||qd.hasOwnProperty(e)&&qd[e]?(""+t).trim():t+"px"}function qC(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,s=KC(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,s):e[n]=s}}var rL=Gn({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 rw(e,t){if(t){if(rL[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(je(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(je(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(je(61))}if(t.style!=null&&typeof t.style!="object")throw Error(je(62))}}function sw(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 iw=null;function Qb(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var ow=null,ou=null,au=null;function hk(e){if(e=np(e)){if(typeof ow!="function")throw Error(je(280));var t=e.stateNode;t&&(t=_g(t),ow(e.stateNode,e.type,t))}}function YC(e){ou?au?au.push(e):au=[e]:ou=e}function GC(){if(ou){var e=ou,t=au;if(au=ou=null,hk(e),t)for(e=0;e<t.length;e++)hk(t[e])}}function XC(e,t){return e(t)}function JC(){}var Py=!1;function QC(e,t,n){if(Py)return e(t,n);Py=!0;try{return XC(e,t,n)}finally{Py=!1,(ou!==null||au!==null)&&(JC(),GC())}}function mf(e,t){var n=e.stateNode;if(n===null)return null;var r=_g(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(je(231,t,typeof n));return n}var aw=!1;if(oa)try{var wd={};Object.defineProperty(wd,"passive",{get:function(){aw=!0}}),window.addEventListener("test",wd,wd),window.removeEventListener("test",wd,wd)}catch{aw=!1}function sL(e,t,n,r,s,i,a,l,u){var d=Array.prototype.slice.call(arguments,3);try{t.apply(n,d)}catch(f){this.onError(f)}}var Yd=!1,mm=null,gm=!1,lw=null,iL={onError:function(e){Yd=!0,mm=e}};function oL(e,t,n,r,s,i,a,l,u){Yd=!1,mm=null,sL.apply(iL,arguments)}function aL(e,t,n,r,s,i,a,l,u){if(oL.apply(this,arguments),Yd){if(Yd){var d=mm;Yd=!1,mm=null}else throw Error(je(198));gm||(gm=!0,lw=d)}}function dc(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 ZC(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 mk(e){if(dc(e)!==e)throw Error(je(188))}function lL(e){var t=e.alternate;if(!t){if(t=dc(e),t===null)throw Error(je(188));return t!==e?null:e}for(var n=e,r=t;;){var s=n.return;if(s===null)break;var i=s.alternate;if(i===null){if(r=s.return,r!==null){n=r;continue}break}if(s.child===i.child){for(i=s.child;i;){if(i===n)return mk(s),e;if(i===r)return mk(s),t;i=i.sibling}throw Error(je(188))}if(n.return!==r.return)n=s,r=i;else{for(var a=!1,l=s.child;l;){if(l===n){a=!0,n=s,r=i;break}if(l===r){a=!0,r=s,n=i;break}l=l.sibling}if(!a){for(l=i.child;l;){if(l===n){a=!0,n=i,r=s;break}if(l===r){a=!0,r=i,n=s;break}l=l.sibling}if(!a)throw Error(je(189))}}if(n.alternate!==r)throw Error(je(190))}if(n.tag!==3)throw Error(je(188));return n.stateNode.current===n?e:t}function eE(e){return e=lL(e),e!==null?tE(e):null}function tE(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=tE(e);if(t!==null)return t;e=e.sibling}return null}var nE=ti.unstable_scheduleCallback,gk=ti.unstable_cancelCallback,cL=ti.unstable_shouldYield,uL=ti.unstable_requestPaint,lr=ti.unstable_now,dL=ti.unstable_getCurrentPriorityLevel,Zb=ti.unstable_ImmediatePriority,rE=ti.unstable_UserBlockingPriority,ym=ti.unstable_NormalPriority,fL=ti.unstable_LowPriority,sE=ti.unstable_IdlePriority,Ng=null,So=null;function pL(e){if(So&&typeof So.onCommitFiberRoot=="function")try{So.onCommitFiberRoot(Ng,e,void 0,(e.current.flags&128)===128)}catch{}}var Gi=Math.clz32?Math.clz32:gL,hL=Math.log,mL=Math.LN2;function gL(e){return e>>>=0,e===0?32:31-(hL(e)/mL|0)|0}var th=64,nh=4194304;function Dd(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 xm(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,s=e.suspendedLanes,i=e.pingedLanes,a=n&268435455;if(a!==0){var l=a&~s;l!==0?r=Dd(l):(i&=a,i!==0&&(r=Dd(i)))}else a=n&~s,a!==0?r=Dd(a):i!==0&&(r=Dd(i));if(r===0)return 0;if(t!==0&&t!==r&&!(t&s)&&(s=r&-r,i=t&-t,s>=i||s===16&&(i&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-Gi(t),s=1<<n,r|=e[n],t&=~s;return r}function yL(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 xL(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,s=e.expirationTimes,i=e.pendingLanes;0<i;){var a=31-Gi(i),l=1<<a,u=s[a];u===-1?(!(l&n)||l&r)&&(s[a]=yL(l,t)):u<=t&&(e.expiredLanes|=l),i&=~l}}function cw(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function iE(){var e=th;return th<<=1,!(th&4194240)&&(th=64),e}function Ay(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function ep(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-Gi(t),e[t]=n}function wL(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-Gi(n),i=1<<s;t[s]=0,r[s]=-1,e[s]=-1,n&=~i}}function ev(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Gi(n),s=1<<r;s&t|e[r]&t&&(e[r]|=t),n&=~s}}var on=0;function oE(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var aE,tv,lE,cE,uE,uw=!1,rh=[],Ua=null,Ka=null,qa=null,gf=new Map,yf=new Map,Da=[],bL="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 yk(e,t){switch(e){case"focusin":case"focusout":Ua=null;break;case"dragenter":case"dragleave":Ka=null;break;case"mouseover":case"mouseout":qa=null;break;case"pointerover":case"pointerout":gf.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":yf.delete(t.pointerId)}}function bd(e,t,n,r,s,i){return e===null||e.nativeEvent!==i?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:i,targetContainers:[s]},t!==null&&(t=np(t),t!==null&&tv(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,s!==null&&t.indexOf(s)===-1&&t.push(s),e)}function vL(e,t,n,r,s){switch(t){case"focusin":return Ua=bd(Ua,e,t,n,r,s),!0;case"dragenter":return Ka=bd(Ka,e,t,n,r,s),!0;case"mouseover":return qa=bd(qa,e,t,n,r,s),!0;case"pointerover":var i=s.pointerId;return gf.set(i,bd(gf.get(i)||null,e,t,n,r,s)),!0;case"gotpointercapture":return i=s.pointerId,yf.set(i,bd(yf.get(i)||null,e,t,n,r,s)),!0}return!1}function dE(e){var t=Hl(e.target);if(t!==null){var n=dc(t);if(n!==null){if(t=n.tag,t===13){if(t=ZC(n),t!==null){e.blockedOn=t,uE(e.priority,function(){lE(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 Uh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=dw(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);iw=r,n.target.dispatchEvent(r),iw=null}else return t=np(n),t!==null&&tv(t),e.blockedOn=n,!1;t.shift()}return!0}function xk(e,t,n){Uh(e)&&n.delete(t)}function kL(){uw=!1,Ua!==null&&Uh(Ua)&&(Ua=null),Ka!==null&&Uh(Ka)&&(Ka=null),qa!==null&&Uh(qa)&&(qa=null),gf.forEach(xk),yf.forEach(xk)}function vd(e,t){e.blockedOn===t&&(e.blockedOn=null,uw||(uw=!0,ti.unstable_scheduleCallback(ti.unstable_NormalPriority,kL)))}function xf(e){function t(s){return vd(s,e)}if(0<rh.length){vd(rh[0],e);for(var n=1;n<rh.length;n++){var r=rh[n];r.blockedOn===e&&(r.blockedOn=null)}}for(Ua!==null&&vd(Ua,e),Ka!==null&&vd(Ka,e),qa!==null&&vd(qa,e),gf.forEach(t),yf.forEach(t),n=0;n<Da.length;n++)r=Da[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<Da.length&&(n=Da[0],n.blockedOn===null);)dE(n),n.blockedOn===null&&Da.shift()}var lu=pa.ReactCurrentBatchConfig,wm=!0;function SL(e,t,n,r){var s=on,i=lu.transition;lu.transition=null;try{on=1,nv(e,t,n,r)}finally{on=s,lu.transition=i}}function NL(e,t,n,r){var s=on,i=lu.transition;lu.transition=null;try{on=4,nv(e,t,n,r)}finally{on=s,lu.transition=i}}function nv(e,t,n,r){if(wm){var s=dw(e,t,n,r);if(s===null)zy(e,t,r,bm,n),yk(e,r);else if(vL(s,e,t,n,r))r.stopPropagation();else if(yk(e,r),t&4&&-1<bL.indexOf(e)){for(;s!==null;){var i=np(s);if(i!==null&&aE(i),i=dw(e,t,n,r),i===null&&zy(e,t,r,bm,n),i===s)break;s=i}s!==null&&r.stopPropagation()}else zy(e,t,r,null,n)}}var bm=null;function dw(e,t,n,r){if(bm=null,e=Qb(r),e=Hl(e),e!==null)if(t=dc(e),t===null)e=null;else if(n=t.tag,n===13){if(e=ZC(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 bm=e,null}function fE(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(dL()){case Zb:return 1;case rE:return 4;case ym:case fL:return 16;case sE:return 536870912;default:return 16}default:return 16}}var Ba=null,rv=null,Kh=null;function pE(){if(Kh)return Kh;var e,t=rv,n=t.length,r,s="value"in Ba?Ba.value:Ba.textContent,i=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[i-r];r++);return Kh=s.slice(e,1<r?1-r:void 0)}function qh(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 sh(){return!0}function wk(){return!1}function si(e){function t(n,r,s,i,a){this._reactName=n,this._targetInst=s,this.type=r,this.nativeEvent=i,this.target=a,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(i):i[l]);return this.isDefaultPrevented=(i.defaultPrevented!=null?i.defaultPrevented:i.returnValue===!1)?sh:wk,this.isPropagationStopped=wk,this}return Gn(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=sh)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=sh)},persist:function(){},isPersistent:sh}),t}var Fu={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},sv=si(Fu),tp=Gn({},Fu,{view:0,detail:0}),jL=si(tp),Iy,Ty,kd,jg=Gn({},tp,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:iv,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!==kd&&(kd&&e.type==="mousemove"?(Iy=e.screenX-kd.screenX,Ty=e.screenY-kd.screenY):Ty=Iy=0,kd=e),Iy)},movementY:function(e){return"movementY"in e?e.movementY:Ty}}),bk=si(jg),CL=Gn({},jg,{dataTransfer:0}),EL=si(CL),_L=Gn({},tp,{relatedTarget:0}),Ry=si(_L),PL=Gn({},Fu,{animationName:0,elapsedTime:0,pseudoElement:0}),AL=si(PL),IL=Gn({},Fu,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),TL=si(IL),RL=Gn({},Fu,{data:0}),vk=si(RL),LL={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},OL={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"},ML={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function $L(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=ML[e])?!!t[e]:!1}function iv(){return $L}var DL=Gn({},tp,{key:function(e){if(e.key){var t=LL[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=qh(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?OL[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:iv,charCode:function(e){return e.type==="keypress"?qh(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?qh(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),FL=si(DL),zL=Gn({},jg,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),kk=si(zL),BL=Gn({},tp,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:iv}),HL=si(BL),WL=Gn({},Fu,{propertyName:0,elapsedTime:0,pseudoElement:0}),VL=si(WL),UL=Gn({},jg,{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}),KL=si(UL),qL=[9,13,27,32],ov=oa&&"CompositionEvent"in window,Gd=null;oa&&"documentMode"in document&&(Gd=document.documentMode);var YL=oa&&"TextEvent"in window&&!Gd,hE=oa&&(!ov||Gd&&8<Gd&&11>=Gd),Sk=" ",Nk=!1;function mE(e,t){switch(e){case"keyup":return qL.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function gE(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var Wc=!1;function GL(e,t){switch(e){case"compositionend":return gE(t);case"keypress":return t.which!==32?null:(Nk=!0,Sk);case"textInput":return e=t.data,e===Sk&&Nk?null:e;default:return null}}function XL(e,t){if(Wc)return e==="compositionend"||!ov&&mE(e,t)?(e=pE(),Kh=rv=Ba=null,Wc=!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 hE&&t.locale!=="ko"?null:t.data;default:return null}}var JL={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 jk(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!JL[e.type]:t==="textarea"}function yE(e,t,n,r){YC(r),t=vm(t,"onChange"),0<t.length&&(n=new sv("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Xd=null,wf=null;function QL(e){_E(e,0)}function Cg(e){var t=Kc(e);if(BC(t))return e}function ZL(e,t){if(e==="change")return t}var xE=!1;if(oa){var Ly;if(oa){var Oy="oninput"in document;if(!Oy){var Ck=document.createElement("div");Ck.setAttribute("oninput","return;"),Oy=typeof Ck.oninput=="function"}Ly=Oy}else Ly=!1;xE=Ly&&(!document.documentMode||9<document.documentMode)}function Ek(){Xd&&(Xd.detachEvent("onpropertychange",wE),wf=Xd=null)}function wE(e){if(e.propertyName==="value"&&Cg(wf)){var t=[];yE(t,wf,e,Qb(e)),QC(QL,t)}}function eO(e,t,n){e==="focusin"?(Ek(),Xd=t,wf=n,Xd.attachEvent("onpropertychange",wE)):e==="focusout"&&Ek()}function tO(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return Cg(wf)}function nO(e,t){if(e==="click")return Cg(t)}function rO(e,t){if(e==="input"||e==="change")return Cg(t)}function sO(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var Ji=typeof Object.is=="function"?Object.is:sO;function bf(e,t){if(Ji(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(!qx.call(t,s)||!Ji(e[s],t[s]))return!1}return!0}function _k(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Pk(e,t){var n=_k(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=_k(n)}}function bE(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?bE(e,t.parentNode):"contains"in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function vE(){for(var e=window,t=hm();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=hm(e.document)}return t}function av(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 iO(e){var t=vE(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&bE(n.ownerDocument.documentElement,n)){if(r!==null&&av(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,i=Math.min(r.start,s);r=r.end===void 0?i:Math.min(r.end,s),!e.extend&&i>r&&(s=r,r=i,i=s),s=Pk(n,i);var a=Pk(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(),i>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 oO=oa&&"documentMode"in document&&11>=document.documentMode,Vc=null,fw=null,Jd=null,pw=!1;function Ak(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;pw||Vc==null||Vc!==hm(r)||(r=Vc,"selectionStart"in r&&av(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}),Jd&&bf(Jd,r)||(Jd=r,r=vm(fw,"onSelect"),0<r.length&&(t=new sv("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=Vc)))}function ih(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var Uc={animationend:ih("Animation","AnimationEnd"),animationiteration:ih("Animation","AnimationIteration"),animationstart:ih("Animation","AnimationStart"),transitionend:ih("Transition","TransitionEnd")},My={},kE={};oa&&(kE=document.createElement("div").style,"AnimationEvent"in window||(delete Uc.animationend.animation,delete Uc.animationiteration.animation,delete Uc.animationstart.animation),"TransitionEvent"in window||delete Uc.transitionend.transition);function Eg(e){if(My[e])return My[e];if(!Uc[e])return e;var t=Uc[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in kE)return My[e]=t[n];return e}var SE=Eg("animationend"),NE=Eg("animationiteration"),jE=Eg("animationstart"),CE=Eg("transitionend"),EE=new Map,Ik="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function dl(e,t){EE.set(e,t),uc(t,[e])}for(var $y=0;$y<Ik.length;$y++){var Dy=Ik[$y],aO=Dy.toLowerCase(),lO=Dy[0].toUpperCase()+Dy.slice(1);dl(aO,"on"+lO)}dl(SE,"onAnimationEnd");dl(NE,"onAnimationIteration");dl(jE,"onAnimationStart");dl("dblclick","onDoubleClick");dl("focusin","onFocus");dl("focusout","onBlur");dl(CE,"onTransitionEnd");yu("onMouseEnter",["mouseout","mouseover"]);yu("onMouseLeave",["mouseout","mouseover"]);yu("onPointerEnter",["pointerout","pointerover"]);yu("onPointerLeave",["pointerout","pointerover"]);uc("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));uc("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));uc("onBeforeInput",["compositionend","keypress","textInput","paste"]);uc("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));uc("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));uc("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Fd="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(" "),cO=new Set("cancel close invalid load scroll toggle".split(" ").concat(Fd));function Tk(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,aL(r,t,void 0,e),e.currentTarget=null}function _E(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 i=void 0;if(t)for(var a=r.length-1;0<=a;a--){var l=r[a],u=l.instance,d=l.currentTarget;if(l=l.listener,u!==i&&s.isPropagationStopped())break e;Tk(s,l,d),i=u}else for(a=0;a<r.length;a++){if(l=r[a],u=l.instance,d=l.currentTarget,l=l.listener,u!==i&&s.isPropagationStopped())break e;Tk(s,l,d),i=u}}}if(gm)throw e=lw,gm=!1,lw=null,e}function On(e,t){var n=t[xw];n===void 0&&(n=t[xw]=new Set);var r=e+"__bubble";n.has(r)||(PE(t,e,2,!1),n.add(r))}function Fy(e,t,n){var r=0;t&&(r|=4),PE(n,e,r,t)}var oh="_reactListening"+Math.random().toString(36).slice(2);function vf(e){if(!e[oh]){e[oh]=!0,MC.forEach(function(n){n!=="selectionchange"&&(cO.has(n)||Fy(n,!1,e),Fy(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[oh]||(t[oh]=!0,Fy("selectionchange",!1,t))}}function PE(e,t,n,r){switch(fE(t)){case 1:var s=SL;break;case 4:s=NL;break;default:s=nv}n=s.bind(null,t,n,e),s=void 0,!aw||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 zy(e,t,n,r,s){var i=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 u=a.tag;if((u===3||u===4)&&(u=a.stateNode.containerInfo,u===s||u.nodeType===8&&u.parentNode===s))return;a=a.return}for(;l!==null;){if(a=Hl(l),a===null)return;if(u=a.tag,u===5||u===6){r=i=a;continue e}l=l.parentNode}}r=r.return}QC(function(){var d=i,f=Qb(n),c=[];e:{var p=EE.get(e);if(p!==void 0){var m=sv,g=e;switch(e){case"keypress":if(qh(n)===0)break e;case"keydown":case"keyup":m=FL;break;case"focusin":g="focus",m=Ry;break;case"focusout":g="blur",m=Ry;break;case"beforeblur":case"afterblur":m=Ry;break;case"click":if(n.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":m=bk;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=EL;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=HL;break;case SE:case NE:case jE:m=AL;break;case CE:m=VL;break;case"scroll":m=jL;break;case"wheel":m=KL;break;case"copy":case"cut":case"paste":m=TL;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=kk}var b=(t&4)!==0,k=!b&&e==="scroll",y=b?p!==null?p+"Capture":null:p;b=[];for(var v=d,w;v!==null;){w=v;var j=w.stateNode;if(w.tag===5&&j!==null&&(w=j,y!==null&&(j=mf(v,y),j!=null&&b.push(kf(v,j,w)))),k)break;v=v.return}0<b.length&&(p=new m(p,g,null,n,f),c.push({event:p,listeners:b}))}}if(!(t&7)){e:{if(p=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",p&&n!==iw&&(g=n.relatedTarget||n.fromElement)&&(Hl(g)||g[aa]))break e;if((m||p)&&(p=f.window===f?f:(p=f.ownerDocument)?p.defaultView||p.parentWindow:window,m?(g=n.relatedTarget||n.toElement,m=d,g=g?Hl(g):null,g!==null&&(k=dc(g),g!==k||g.tag!==5&&g.tag!==6)&&(g=null)):(m=null,g=d),m!==g)){if(b=bk,j="onMouseLeave",y="onMouseEnter",v="mouse",(e==="pointerout"||e==="pointerover")&&(b=kk,j="onPointerLeave",y="onPointerEnter",v="pointer"),k=m==null?p:Kc(m),w=g==null?p:Kc(g),p=new b(j,v+"leave",m,n,f),p.target=k,p.relatedTarget=w,j=null,Hl(f)===d&&(b=new b(y,v+"enter",g,n,f),b.target=w,b.relatedTarget=k,j=b),k=j,m&&g)t:{for(b=m,y=g,v=0,w=b;w;w=Ac(w))v++;for(w=0,j=y;j;j=Ac(j))w++;for(;0<v-w;)b=Ac(b),v--;for(;0<w-v;)y=Ac(y),w--;for(;v--;){if(b===y||y!==null&&b===y.alternate)break t;b=Ac(b),y=Ac(y)}b=null}else b=null;m!==null&&Rk(c,p,m,b,!1),g!==null&&k!==null&&Rk(c,k,g,b,!0)}}e:{if(p=d?Kc(d):window,m=p.nodeName&&p.nodeName.toLowerCase(),m==="select"||m==="input"&&p.type==="file")var P=ZL;else if(jk(p))if(xE)P=rO;else{P=tO;var _=eO}else(m=p.nodeName)&&m.toLowerCase()==="input"&&(p.type==="checkbox"||p.type==="radio")&&(P=nO);if(P&&(P=P(e,d))){yE(c,P,n,f);break e}_&&_(e,p,d),e==="focusout"&&(_=p._wrapperState)&&_.controlled&&p.type==="number"&&ew(p,"number",p.value)}switch(_=d?Kc(d):window,e){case"focusin":(jk(_)||_.contentEditable==="true")&&(Vc=_,fw=d,Jd=null);break;case"focusout":Jd=fw=Vc=null;break;case"mousedown":pw=!0;break;case"contextmenu":case"mouseup":case"dragend":pw=!1,Ak(c,n,f);break;case"selectionchange":if(oO)break;case"keydown":case"keyup":Ak(c,n,f)}var L;if(ov)e:{switch(e){case"compositionstart":var B="onCompositionStart";break e;case"compositionend":B="onCompositionEnd";break e;case"compositionupdate":B="onCompositionUpdate";break e}B=void 0}else Wc?mE(e,n)&&(B="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(B="onCompositionStart");B&&(hE&&n.locale!=="ko"&&(Wc||B!=="onCompositionStart"?B==="onCompositionEnd"&&Wc&&(L=pE()):(Ba=f,rv="value"in Ba?Ba.value:Ba.textContent,Wc=!0)),_=vm(d,B),0<_.length&&(B=new vk(B,e,null,n,f),c.push({event:B,listeners:_}),L?B.data=L:(L=gE(n),L!==null&&(B.data=L)))),(L=YL?GL(e,n):XL(e,n))&&(d=vm(d,"onBeforeInput"),0<d.length&&(f=new vk("onBeforeInput","beforeinput",null,n,f),c.push({event:f,listeners:d}),f.data=L))}_E(c,t)})}function kf(e,t,n){return{instance:e,listener:t,currentTarget:n}}function vm(e,t){for(var n=t+"Capture",r=[];e!==null;){var s=e,i=s.stateNode;s.tag===5&&i!==null&&(s=i,i=mf(e,n),i!=null&&r.unshift(kf(e,i,s)),i=mf(e,t),i!=null&&r.push(kf(e,i,s))),e=e.return}return r}function Ac(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Rk(e,t,n,r,s){for(var i=t._reactName,a=[];n!==null&&n!==r;){var l=n,u=l.alternate,d=l.stateNode;if(u!==null&&u===r)break;l.tag===5&&d!==null&&(l=d,s?(u=mf(n,i),u!=null&&a.unshift(kf(n,u,l))):s||(u=mf(n,i),u!=null&&a.push(kf(n,u,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var uO=/\r\n?/g,dO=/\u0000|\uFFFD/g;function Lk(e){return(typeof e=="string"?e:""+e).replace(uO,`
38
- `).replace(dO,"")}function ah(e,t,n){if(t=Lk(t),Lk(e)!==t&&n)throw Error(je(425))}function km(){}var hw=null,mw=null;function gw(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 yw=typeof setTimeout=="function"?setTimeout:void 0,fO=typeof clearTimeout=="function"?clearTimeout:void 0,Ok=typeof Promise=="function"?Promise:void 0,pO=typeof queueMicrotask=="function"?queueMicrotask:typeof Ok<"u"?function(e){return Ok.resolve(null).then(e).catch(hO)}:yw;function hO(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),xf(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=s}while(n);xf(t)}function Ya(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 Mk(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 zu=Math.random().toString(36).slice(2),wo="__reactFiber$"+zu,Sf="__reactProps$"+zu,aa="__reactContainer$"+zu,xw="__reactEvents$"+zu,mO="__reactListeners$"+zu,gO="__reactHandles$"+zu;function Hl(e){var t=e[wo];if(t)return t;for(var n=e.parentNode;n;){if(t=n[aa]||n[wo]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Mk(e);e!==null;){if(n=e[wo])return n;e=Mk(e)}return t}e=n,n=e.parentNode}return null}function np(e){return e=e[wo]||e[aa],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function Kc(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(je(33))}function _g(e){return e[Sf]||null}var ww=[],qc=-1;function fl(e){return{current:e}}function $n(e){0>qc||(e.current=ww[qc],ww[qc]=null,qc--)}function En(e,t){qc++,ww[qc]=e.current,e.current=t}var sl={},Zr=fl(sl),Is=fl(!1),Zl=sl;function xu(e,t){var n=e.type.contextTypes;if(!n)return sl;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var s={},i;for(i in n)s[i]=t[i];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=s),s}function Ts(e){return e=e.childContextTypes,e!=null}function Sm(){$n(Is),$n(Zr)}function $k(e,t,n){if(Zr.current!==sl)throw Error(je(168));En(Zr,t),En(Is,n)}function AE(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(je(108,eL(e)||"Unknown",s));return Gn({},n,r)}function Nm(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||sl,Zl=Zr.current,En(Zr,e),En(Is,Is.current),!0}function Dk(e,t,n){var r=e.stateNode;if(!r)throw Error(je(169));n?(e=AE(e,t,Zl),r.__reactInternalMemoizedMergedChildContext=e,$n(Is),$n(Zr),En(Zr,e)):$n(Is),En(Is,n)}var Jo=null,Pg=!1,Hy=!1;function IE(e){Jo===null?Jo=[e]:Jo.push(e)}function yO(e){Pg=!0,IE(e)}function pl(){if(!Hy&&Jo!==null){Hy=!0;var e=0,t=on;try{var n=Jo;for(on=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}Jo=null,Pg=!1}catch(s){throw Jo!==null&&(Jo=Jo.slice(e+1)),nE(Zb,pl),s}finally{on=t,Hy=!1}}return null}var Yc=[],Gc=0,jm=null,Cm=0,bi=[],vi=0,ec=null,ea=1,ta="";function $l(e,t){Yc[Gc++]=Cm,Yc[Gc++]=jm,jm=e,Cm=t}function TE(e,t,n){bi[vi++]=ea,bi[vi++]=ta,bi[vi++]=ec,ec=e;var r=ea;e=ta;var s=32-Gi(r)-1;r&=~(1<<s),n+=1;var i=32-Gi(t)+s;if(30<i){var a=s-s%5;i=(r&(1<<a)-1).toString(32),r>>=a,s-=a,ea=1<<32-Gi(t)+s|n<<s|r,ta=i+e}else ea=1<<i|n<<s|r,ta=e}function lv(e){e.return!==null&&($l(e,1),TE(e,1,0))}function cv(e){for(;e===jm;)jm=Yc[--Gc],Yc[Gc]=null,Cm=Yc[--Gc],Yc[Gc]=null;for(;e===ec;)ec=bi[--vi],bi[vi]=null,ta=bi[--vi],bi[vi]=null,ea=bi[--vi],bi[vi]=null}var Zs=null,Js=null,Bn=!1,Vi=null;function RE(e,t){var n=Ni(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 Fk(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,Zs=e,Js=Ya(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,Zs=e,Js=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=ec!==null?{id:ea,overflow:ta}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=Ni(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,Zs=e,Js=null,!0):!1;default:return!1}}function bw(e){return(e.mode&1)!==0&&(e.flags&128)===0}function vw(e){if(Bn){var t=Js;if(t){var n=t;if(!Fk(e,t)){if(bw(e))throw Error(je(418));t=Ya(n.nextSibling);var r=Zs;t&&Fk(e,t)?RE(r,n):(e.flags=e.flags&-4097|2,Bn=!1,Zs=e)}}else{if(bw(e))throw Error(je(418));e.flags=e.flags&-4097|2,Bn=!1,Zs=e}}}function zk(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;Zs=e}function lh(e){if(e!==Zs)return!1;if(!Bn)return zk(e),Bn=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!gw(e.type,e.memoizedProps)),t&&(t=Js)){if(bw(e))throw LE(),Error(je(418));for(;t;)RE(e,t),t=Ya(t.nextSibling)}if(zk(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(je(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){Js=Ya(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}Js=null}}else Js=Zs?Ya(e.stateNode.nextSibling):null;return!0}function LE(){for(var e=Js;e;)e=Ya(e.nextSibling)}function wu(){Js=Zs=null,Bn=!1}function uv(e){Vi===null?Vi=[e]:Vi.push(e)}var xO=pa.ReactCurrentBatchConfig;function Sd(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(je(309));var r=n.stateNode}if(!r)throw Error(je(147,e));var s=r,i=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===i?t.ref:(t=function(a){var l=s.refs;a===null?delete l[i]:l[i]=a},t._stringRef=i,t)}if(typeof e!="string")throw Error(je(284));if(!n._owner)throw Error(je(290,e))}return e}function ch(e,t){throw e=Object.prototype.toString.call(t),Error(je(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function Bk(e){var t=e._init;return t(e._payload)}function OE(e){function t(y,v){if(e){var w=y.deletions;w===null?(y.deletions=[v],y.flags|=16):w.push(v)}}function n(y,v){if(!e)return null;for(;v!==null;)t(y,v),v=v.sibling;return null}function r(y,v){for(y=new Map;v!==null;)v.key!==null?y.set(v.key,v):y.set(v.index,v),v=v.sibling;return y}function s(y,v){return y=Qa(y,v),y.index=0,y.sibling=null,y}function i(y,v,w){return y.index=w,e?(w=y.alternate,w!==null?(w=w.index,w<v?(y.flags|=2,v):w):(y.flags|=2,v)):(y.flags|=1048576,v)}function a(y){return e&&y.alternate===null&&(y.flags|=2),y}function l(y,v,w,j){return v===null||v.tag!==6?(v=Gy(w,y.mode,j),v.return=y,v):(v=s(v,w),v.return=y,v)}function u(y,v,w,j){var P=w.type;return P===Hc?f(y,v,w.props.children,j,w.key):v!==null&&(v.elementType===P||typeof P=="object"&&P!==null&&P.$$typeof===Oa&&Bk(P)===v.type)?(j=s(v,w.props),j.ref=Sd(y,v,w),j.return=y,j):(j=em(w.type,w.key,w.props,null,y.mode,j),j.ref=Sd(y,v,w),j.return=y,j)}function d(y,v,w,j){return v===null||v.tag!==4||v.stateNode.containerInfo!==w.containerInfo||v.stateNode.implementation!==w.implementation?(v=Xy(w,y.mode,j),v.return=y,v):(v=s(v,w.children||[]),v.return=y,v)}function f(y,v,w,j,P){return v===null||v.tag!==7?(v=ql(w,y.mode,j,P),v.return=y,v):(v=s(v,w),v.return=y,v)}function c(y,v,w){if(typeof v=="string"&&v!==""||typeof v=="number")return v=Gy(""+v,y.mode,w),v.return=y,v;if(typeof v=="object"&&v!==null){switch(v.$$typeof){case Qp:return w=em(v.type,v.key,v.props,null,y.mode,w),w.ref=Sd(y,null,v),w.return=y,w;case Bc:return v=Xy(v,y.mode,w),v.return=y,v;case Oa:var j=v._init;return c(y,j(v._payload),w)}if($d(v)||xd(v))return v=ql(v,y.mode,w,null),v.return=y,v;ch(y,v)}return null}function p(y,v,w,j){var P=v!==null?v.key:null;if(typeof w=="string"&&w!==""||typeof w=="number")return P!==null?null:l(y,v,""+w,j);if(typeof w=="object"&&w!==null){switch(w.$$typeof){case Qp:return w.key===P?u(y,v,w,j):null;case Bc:return w.key===P?d(y,v,w,j):null;case Oa:return P=w._init,p(y,v,P(w._payload),j)}if($d(w)||xd(w))return P!==null?null:f(y,v,w,j,null);ch(y,w)}return null}function m(y,v,w,j,P){if(typeof j=="string"&&j!==""||typeof j=="number")return y=y.get(w)||null,l(v,y,""+j,P);if(typeof j=="object"&&j!==null){switch(j.$$typeof){case Qp:return y=y.get(j.key===null?w:j.key)||null,u(v,y,j,P);case Bc:return y=y.get(j.key===null?w:j.key)||null,d(v,y,j,P);case Oa:var _=j._init;return m(y,v,w,_(j._payload),P)}if($d(j)||xd(j))return y=y.get(w)||null,f(v,y,j,P,null);ch(v,j)}return null}function g(y,v,w,j){for(var P=null,_=null,L=v,B=v=0,D=null;L!==null&&B<w.length;B++){L.index>B?(D=L,L=null):D=L.sibling;var F=p(y,L,w[B],j);if(F===null){L===null&&(L=D);break}e&&L&&F.alternate===null&&t(y,L),v=i(F,v,B),_===null?P=F:_.sibling=F,_=F,L=D}if(B===w.length)return n(y,L),Bn&&$l(y,B),P;if(L===null){for(;B<w.length;B++)L=c(y,w[B],j),L!==null&&(v=i(L,v,B),_===null?P=L:_.sibling=L,_=L);return Bn&&$l(y,B),P}for(L=r(y,L);B<w.length;B++)D=m(L,y,B,w[B],j),D!==null&&(e&&D.alternate!==null&&L.delete(D.key===null?B:D.key),v=i(D,v,B),_===null?P=D:_.sibling=D,_=D);return e&&L.forEach(function(R){return t(y,R)}),Bn&&$l(y,B),P}function b(y,v,w,j){var P=xd(w);if(typeof P!="function")throw Error(je(150));if(w=P.call(w),w==null)throw Error(je(151));for(var _=P=null,L=v,B=v=0,D=null,F=w.next();L!==null&&!F.done;B++,F=w.next()){L.index>B?(D=L,L=null):D=L.sibling;var R=p(y,L,F.value,j);if(R===null){L===null&&(L=D);break}e&&L&&R.alternate===null&&t(y,L),v=i(R,v,B),_===null?P=R:_.sibling=R,_=R,L=D}if(F.done)return n(y,L),Bn&&$l(y,B),P;if(L===null){for(;!F.done;B++,F=w.next())F=c(y,F.value,j),F!==null&&(v=i(F,v,B),_===null?P=F:_.sibling=F,_=F);return Bn&&$l(y,B),P}for(L=r(y,L);!F.done;B++,F=w.next())F=m(L,y,B,F.value,j),F!==null&&(e&&F.alternate!==null&&L.delete(F.key===null?B:F.key),v=i(F,v,B),_===null?P=F:_.sibling=F,_=F);return e&&L.forEach(function(M){return t(y,M)}),Bn&&$l(y,B),P}function k(y,v,w,j){if(typeof w=="object"&&w!==null&&w.type===Hc&&w.key===null&&(w=w.props.children),typeof w=="object"&&w!==null){switch(w.$$typeof){case Qp:e:{for(var P=w.key,_=v;_!==null;){if(_.key===P){if(P=w.type,P===Hc){if(_.tag===7){n(y,_.sibling),v=s(_,w.props.children),v.return=y,y=v;break e}}else if(_.elementType===P||typeof P=="object"&&P!==null&&P.$$typeof===Oa&&Bk(P)===_.type){n(y,_.sibling),v=s(_,w.props),v.ref=Sd(y,_,w),v.return=y,y=v;break e}n(y,_);break}else t(y,_);_=_.sibling}w.type===Hc?(v=ql(w.props.children,y.mode,j,w.key),v.return=y,y=v):(j=em(w.type,w.key,w.props,null,y.mode,j),j.ref=Sd(y,v,w),j.return=y,y=j)}return a(y);case Bc:e:{for(_=w.key;v!==null;){if(v.key===_)if(v.tag===4&&v.stateNode.containerInfo===w.containerInfo&&v.stateNode.implementation===w.implementation){n(y,v.sibling),v=s(v,w.children||[]),v.return=y,y=v;break e}else{n(y,v);break}else t(y,v);v=v.sibling}v=Xy(w,y.mode,j),v.return=y,y=v}return a(y);case Oa:return _=w._init,k(y,v,_(w._payload),j)}if($d(w))return g(y,v,w,j);if(xd(w))return b(y,v,w,j);ch(y,w)}return typeof w=="string"&&w!==""||typeof w=="number"?(w=""+w,v!==null&&v.tag===6?(n(y,v.sibling),v=s(v,w),v.return=y,y=v):(n(y,v),v=Gy(w,y.mode,j),v.return=y,y=v),a(y)):n(y,v)}return k}var bu=OE(!0),ME=OE(!1),Em=fl(null),_m=null,Xc=null,dv=null;function fv(){dv=Xc=_m=null}function pv(e){var t=Em.current;$n(Em),e._currentValue=t}function kw(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 cu(e,t){_m=e,dv=Xc=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(Cs=!0),e.firstContext=null)}function Ci(e){var t=e._currentValue;if(dv!==e)if(e={context:e,memoizedValue:t,next:null},Xc===null){if(_m===null)throw Error(je(308));Xc=e,_m.dependencies={lanes:0,firstContext:e}}else Xc=Xc.next=e;return t}var Wl=null;function hv(e){Wl===null?Wl=[e]:Wl.push(e)}function $E(e,t,n,r){var s=t.interleaved;return s===null?(n.next=n,hv(t)):(n.next=s.next,s.next=n),t.interleaved=n,la(e,r)}function la(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 Ma=!1;function mv(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function DE(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 ia(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function Ga(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Kt&2){var s=r.pending;return s===null?t.next=t:(t.next=s.next,s.next=t),r.pending=t,la(e,n)}return s=r.interleaved,s===null?(t.next=t,hv(r)):(t.next=s.next,s.next=t),r.interleaved=t,la(e,n)}function Yh(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,ev(e,n)}}function Hk(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var s=null,i=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};i===null?s=i=a:i=i.next=a,n=n.next}while(n!==null);i===null?s=i=t:i=i.next=t}else s=i=t;n={baseState:r.baseState,firstBaseUpdate:s,lastBaseUpdate:i,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 Pm(e,t,n,r){var s=e.updateQueue;Ma=!1;var i=s.firstBaseUpdate,a=s.lastBaseUpdate,l=s.shared.pending;if(l!==null){s.shared.pending=null;var u=l,d=u.next;u.next=null,a===null?i=d:a.next=d,a=u;var f=e.alternate;f!==null&&(f=f.updateQueue,l=f.lastBaseUpdate,l!==a&&(l===null?f.firstBaseUpdate=d:l.next=d,f.lastBaseUpdate=u))}if(i!==null){var c=s.baseState;a=0,f=d=u=null,l=i;do{var p=l.lane,m=l.eventTime;if((r&p)===p){f!==null&&(f=f.next={eventTime:m,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var g=e,b=l;switch(p=t,m=n,b.tag){case 1:if(g=b.payload,typeof g=="function"){c=g.call(m,c,p);break e}c=g;break e;case 3:g.flags=g.flags&-65537|128;case 0:if(g=b.payload,p=typeof g=="function"?g.call(m,c,p):g,p==null)break e;c=Gn({},c,p);break e;case 2:Ma=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,p=s.effects,p===null?s.effects=[l]:p.push(l))}else m={eventTime:m,lane:p,tag:l.tag,payload:l.payload,callback:l.callback,next:null},f===null?(d=f=m,u=c):f=f.next=m,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(f===null&&(u=c),s.baseState=u,s.firstBaseUpdate=d,s.lastBaseUpdate=f,t=s.shared.interleaved,t!==null){s=t;do a|=s.lane,s=s.next;while(s!==t)}else i===null&&(s.shared.lanes=0);nc|=a,e.lanes=a,e.memoizedState=c}}function Wk(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(je(191,s));s.call(r)}}}var rp={},No=fl(rp),Nf=fl(rp),jf=fl(rp);function Vl(e){if(e===rp)throw Error(je(174));return e}function gv(e,t){switch(En(jf,t),En(Nf,e),En(No,rp),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:nw(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=nw(t,e)}$n(No),En(No,t)}function vu(){$n(No),$n(Nf),$n(jf)}function FE(e){Vl(jf.current);var t=Vl(No.current),n=nw(t,e.type);t!==n&&(En(Nf,e),En(No,n))}function yv(e){Nf.current===e&&($n(No),$n(Nf))}var qn=fl(0);function Am(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||n.data==="$?"||n.data==="$!"))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==void 0){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Wy=[];function xv(){for(var e=0;e<Wy.length;e++)Wy[e]._workInProgressVersionPrimary=null;Wy.length=0}var Gh=pa.ReactCurrentDispatcher,Vy=pa.ReactCurrentBatchConfig,tc=0,Yn=null,wr=null,Er=null,Im=!1,Qd=!1,Cf=0,wO=0;function Gr(){throw Error(je(321))}function wv(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!Ji(e[n],t[n]))return!1;return!0}function bv(e,t,n,r,s,i){if(tc=i,Yn=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Gh.current=e===null||e.memoizedState===null?SO:NO,e=n(r,s),Qd){i=0;do{if(Qd=!1,Cf=0,25<=i)throw Error(je(301));i+=1,Er=wr=null,t.updateQueue=null,Gh.current=jO,e=n(r,s)}while(Qd)}if(Gh.current=Tm,t=wr!==null&&wr.next!==null,tc=0,Er=wr=Yn=null,Im=!1,t)throw Error(je(300));return e}function vv(){var e=Cf!==0;return Cf=0,e}function mo(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Er===null?Yn.memoizedState=Er=e:Er=Er.next=e,Er}function Ei(){if(wr===null){var e=Yn.alternate;e=e!==null?e.memoizedState:null}else e=wr.next;var t=Er===null?Yn.memoizedState:Er.next;if(t!==null)Er=t,wr=e;else{if(e===null)throw Error(je(310));wr=e,e={memoizedState:wr.memoizedState,baseState:wr.baseState,baseQueue:wr.baseQueue,queue:wr.queue,next:null},Er===null?Yn.memoizedState=Er=e:Er=Er.next=e}return Er}function Ef(e,t){return typeof t=="function"?t(e):t}function Uy(e){var t=Ei(),n=t.queue;if(n===null)throw Error(je(311));n.lastRenderedReducer=e;var r=wr,s=r.baseQueue,i=n.pending;if(i!==null){if(s!==null){var a=s.next;s.next=i.next,i.next=a}r.baseQueue=s=i,n.pending=null}if(s!==null){i=s.next,r=r.baseState;var l=a=null,u=null,d=i;do{var f=d.lane;if((tc&f)===f)u!==null&&(u=u.next={lane:0,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null}),r=d.hasEagerState?d.eagerState:e(r,d.action);else{var c={lane:f,action:d.action,hasEagerState:d.hasEagerState,eagerState:d.eagerState,next:null};u===null?(l=u=c,a=r):u=u.next=c,Yn.lanes|=f,nc|=f}d=d.next}while(d!==null&&d!==i);u===null?a=r:u.next=l,Ji(r,t.memoizedState)||(Cs=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=u,n.lastRenderedState=r}if(e=n.interleaved,e!==null){s=e;do i=s.lane,Yn.lanes|=i,nc|=i,s=s.next;while(s!==e)}else s===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function Ky(e){var t=Ei(),n=t.queue;if(n===null)throw Error(je(311));n.lastRenderedReducer=e;var r=n.dispatch,s=n.pending,i=t.memoizedState;if(s!==null){n.pending=null;var a=s=s.next;do i=e(i,a.action),a=a.next;while(a!==s);Ji(i,t.memoizedState)||(Cs=!0),t.memoizedState=i,t.baseQueue===null&&(t.baseState=i),n.lastRenderedState=i}return[i,r]}function zE(){}function BE(e,t){var n=Yn,r=Ei(),s=t(),i=!Ji(r.memoizedState,s);if(i&&(r.memoizedState=s,Cs=!0),r=r.queue,kv(VE.bind(null,n,r,e),[e]),r.getSnapshot!==t||i||Er!==null&&Er.memoizedState.tag&1){if(n.flags|=2048,_f(9,WE.bind(null,n,r,s,t),void 0,null),Pr===null)throw Error(je(349));tc&30||HE(n,t,s)}return s}function HE(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Yn.updateQueue,t===null?(t={lastEffect:null,stores:null},Yn.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function WE(e,t,n,r){t.value=n,t.getSnapshot=r,UE(t)&&KE(e)}function VE(e,t,n){return n(function(){UE(t)&&KE(e)})}function UE(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!Ji(e,n)}catch{return!0}}function KE(e){var t=la(e,1);t!==null&&Xi(t,e,1,-1)}function Vk(e){var t=mo();return typeof e=="function"&&(e=e()),t.memoizedState=t.baseState=e,e={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Ef,lastRenderedState:e},t.queue=e,e=e.dispatch=kO.bind(null,Yn,e),[t.memoizedState,e]}function _f(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Yn.updateQueue,t===null?(t={lastEffect:null,stores:null},Yn.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 qE(){return Ei().memoizedState}function Xh(e,t,n,r){var s=mo();Yn.flags|=e,s.memoizedState=_f(1|t,n,void 0,r===void 0?null:r)}function Ag(e,t,n,r){var s=Ei();r=r===void 0?null:r;var i=void 0;if(wr!==null){var a=wr.memoizedState;if(i=a.destroy,r!==null&&wv(r,a.deps)){s.memoizedState=_f(t,n,i,r);return}}Yn.flags|=e,s.memoizedState=_f(1|t,n,i,r)}function Uk(e,t){return Xh(8390656,8,e,t)}function kv(e,t){return Ag(2048,8,e,t)}function YE(e,t){return Ag(4,2,e,t)}function GE(e,t){return Ag(4,4,e,t)}function XE(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 JE(e,t,n){return n=n!=null?n.concat([e]):null,Ag(4,4,XE.bind(null,t,e),n)}function Sv(){}function QE(e,t){var n=Ei();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&wv(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function ZE(e,t){var n=Ei();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&wv(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function e_(e,t,n){return tc&21?(Ji(n,t)||(n=iE(),Yn.lanes|=n,nc|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,Cs=!0),e.memoizedState=n)}function bO(e,t){var n=on;on=n!==0&&4>n?n:4,e(!0);var r=Vy.transition;Vy.transition={};try{e(!1),t()}finally{on=n,Vy.transition=r}}function t_(){return Ei().memoizedState}function vO(e,t,n){var r=Ja(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},n_(e))r_(t,n);else if(n=$E(e,t,n,r),n!==null){var s=ds();Xi(n,e,r,s),s_(n,t,r)}}function kO(e,t,n){var r=Ja(e),s={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(n_(e))r_(t,s);else{var i=e.alternate;if(e.lanes===0&&(i===null||i.lanes===0)&&(i=t.lastRenderedReducer,i!==null))try{var a=t.lastRenderedState,l=i(a,n);if(s.hasEagerState=!0,s.eagerState=l,Ji(l,a)){var u=t.interleaved;u===null?(s.next=s,hv(t)):(s.next=u.next,u.next=s),t.interleaved=s;return}}catch{}finally{}n=$E(e,t,s,r),n!==null&&(s=ds(),Xi(n,e,r,s),s_(n,t,r))}}function n_(e){var t=e.alternate;return e===Yn||t!==null&&t===Yn}function r_(e,t){Qd=Im=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function s_(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ev(e,n)}}var Tm={readContext:Ci,useCallback:Gr,useContext:Gr,useEffect:Gr,useImperativeHandle:Gr,useInsertionEffect:Gr,useLayoutEffect:Gr,useMemo:Gr,useReducer:Gr,useRef:Gr,useState:Gr,useDebugValue:Gr,useDeferredValue:Gr,useTransition:Gr,useMutableSource:Gr,useSyncExternalStore:Gr,useId:Gr,unstable_isNewReconciler:!1},SO={readContext:Ci,useCallback:function(e,t){return mo().memoizedState=[e,t===void 0?null:t],e},useContext:Ci,useEffect:Uk,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Xh(4194308,4,XE.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Xh(4194308,4,e,t)},useInsertionEffect:function(e,t){return Xh(4,2,e,t)},useMemo:function(e,t){var n=mo();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=mo();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=vO.bind(null,Yn,e),[r.memoizedState,e]},useRef:function(e){var t=mo();return e={current:e},t.memoizedState=e},useState:Vk,useDebugValue:Sv,useDeferredValue:function(e){return mo().memoizedState=e},useTransition:function(){var e=Vk(!1),t=e[0];return e=bO.bind(null,e[1]),mo().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Yn,s=mo();if(Bn){if(n===void 0)throw Error(je(407));n=n()}else{if(n=t(),Pr===null)throw Error(je(349));tc&30||HE(r,t,n)}s.memoizedState=n;var i={value:n,getSnapshot:t};return s.queue=i,Uk(VE.bind(null,r,i,e),[e]),r.flags|=2048,_f(9,WE.bind(null,r,i,n,t),void 0,null),n},useId:function(){var e=mo(),t=Pr.identifierPrefix;if(Bn){var n=ta,r=ea;n=(r&~(1<<32-Gi(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Cf++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=wO++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},NO={readContext:Ci,useCallback:QE,useContext:Ci,useEffect:kv,useImperativeHandle:JE,useInsertionEffect:YE,useLayoutEffect:GE,useMemo:ZE,useReducer:Uy,useRef:qE,useState:function(){return Uy(Ef)},useDebugValue:Sv,useDeferredValue:function(e){var t=Ei();return e_(t,wr.memoizedState,e)},useTransition:function(){var e=Uy(Ef)[0],t=Ei().memoizedState;return[e,t]},useMutableSource:zE,useSyncExternalStore:BE,useId:t_,unstable_isNewReconciler:!1},jO={readContext:Ci,useCallback:QE,useContext:Ci,useEffect:kv,useImperativeHandle:JE,useInsertionEffect:YE,useLayoutEffect:GE,useMemo:ZE,useReducer:Ky,useRef:qE,useState:function(){return Ky(Ef)},useDebugValue:Sv,useDeferredValue:function(e){var t=Ei();return wr===null?t.memoizedState=e:e_(t,wr.memoizedState,e)},useTransition:function(){var e=Ky(Ef)[0],t=Ei().memoizedState;return[e,t]},useMutableSource:zE,useSyncExternalStore:BE,useId:t_,unstable_isNewReconciler:!1};function Bi(e,t){if(e&&e.defaultProps){t=Gn({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Sw(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Gn({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var Ig={isMounted:function(e){return(e=e._reactInternals)?dc(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=ds(),s=Ja(e),i=ia(r,s);i.payload=t,n!=null&&(i.callback=n),t=Ga(e,i,s),t!==null&&(Xi(t,e,s,r),Yh(t,e,s))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=ds(),s=Ja(e),i=ia(r,s);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=Ga(e,i,s),t!==null&&(Xi(t,e,s,r),Yh(t,e,s))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=ds(),r=Ja(e),s=ia(n,r);s.tag=2,t!=null&&(s.callback=t),t=Ga(e,s,r),t!==null&&(Xi(t,e,r,n),Yh(t,e,r))}};function Kk(e,t,n,r,s,i,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,i,a):t.prototype&&t.prototype.isPureReactComponent?!bf(n,r)||!bf(s,i):!0}function i_(e,t,n){var r=!1,s=sl,i=t.contextType;return typeof i=="object"&&i!==null?i=Ci(i):(s=Ts(t)?Zl:Zr.current,r=t.contextTypes,i=(r=r!=null)?xu(e,s):sl),t=new t(n,i),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=Ig,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=s,e.__reactInternalMemoizedMaskedChildContext=i),t}function qk(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&&Ig.enqueueReplaceState(t,t.state,null)}function Nw(e,t,n,r){var s=e.stateNode;s.props=n,s.state=e.memoizedState,s.refs={},mv(e);var i=t.contextType;typeof i=="object"&&i!==null?s.context=Ci(i):(i=Ts(t)?Zl:Zr.current,s.context=xu(e,i)),s.state=e.memoizedState,i=t.getDerivedStateFromProps,typeof i=="function"&&(Sw(e,t,i,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&&Ig.enqueueReplaceState(s,s.state,null),Pm(e,n,s,r),s.state=e.memoizedState),typeof s.componentDidMount=="function"&&(e.flags|=4194308)}function ku(e,t){try{var n="",r=t;do n+=Z2(r),r=r.return;while(r);var s=n}catch(i){s=`
39
- Error generating stack: `+i.message+`
40
- `+i.stack}return{value:e,source:t,stack:s,digest:null}}function qy(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function jw(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var CO=typeof WeakMap=="function"?WeakMap:Map;function o_(e,t,n){n=ia(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){Lm||(Lm=!0,Ow=r),jw(e,t)},n}function a_(e,t,n){n=ia(-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(){jw(e,t)}}var i=e.stateNode;return i!==null&&typeof i.componentDidCatch=="function"&&(n.callback=function(){jw(e,t),typeof r!="function"&&(Xa===null?Xa=new Set([this]):Xa.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function Yk(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new CO;var s=new Set;r.set(t,s)}else s=r.get(t),s===void 0&&(s=new Set,r.set(t,s));s.has(n)||(s.add(n),e=zO.bind(null,e,t,n),t.then(e,e))}function Gk(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 Xk(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=ia(-1,1),t.tag=2,Ga(n,t,1))),n.lanes|=1),e)}var EO=pa.ReactCurrentOwner,Cs=!1;function cs(e,t,n,r){t.child=e===null?ME(t,null,n,r):bu(t,e.child,n,r)}function Jk(e,t,n,r,s){n=n.render;var i=t.ref;return cu(t,s),r=bv(e,t,n,r,i,s),n=vv(),e!==null&&!Cs?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,ca(e,t,s)):(Bn&&n&&lv(t),t.flags|=1,cs(e,t,r,s),t.child)}function Qk(e,t,n,r,s){if(e===null){var i=n.type;return typeof i=="function"&&!Iv(i)&&i.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=i,l_(e,t,i,r,s)):(e=em(n.type,null,r,t,t.mode,s),e.ref=t.ref,e.return=t,t.child=e)}if(i=e.child,!(e.lanes&s)){var a=i.memoizedProps;if(n=n.compare,n=n!==null?n:bf,n(a,r)&&e.ref===t.ref)return ca(e,t,s)}return t.flags|=1,e=Qa(i,r),e.ref=t.ref,e.return=t,t.child=e}function l_(e,t,n,r,s){if(e!==null){var i=e.memoizedProps;if(bf(i,r)&&e.ref===t.ref)if(Cs=!1,t.pendingProps=r=i,(e.lanes&s)!==0)e.flags&131072&&(Cs=!0);else return t.lanes=e.lanes,ca(e,t,s)}return Cw(e,t,n,r,s)}function c_(e,t,n){var r=t.pendingProps,s=r.children,i=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},En(Qc,Ys),Ys|=n;else{if(!(n&1073741824))return e=i!==null?i.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,En(Qc,Ys),Ys|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=i!==null?i.baseLanes:n,En(Qc,Ys),Ys|=r}else i!==null?(r=i.baseLanes|n,t.memoizedState=null):r=n,En(Qc,Ys),Ys|=r;return cs(e,t,s,n),t.child}function u_(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Cw(e,t,n,r,s){var i=Ts(n)?Zl:Zr.current;return i=xu(t,i),cu(t,s),n=bv(e,t,n,r,i,s),r=vv(),e!==null&&!Cs?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~s,ca(e,t,s)):(Bn&&r&&lv(t),t.flags|=1,cs(e,t,n,s),t.child)}function Zk(e,t,n,r,s){if(Ts(n)){var i=!0;Nm(t)}else i=!1;if(cu(t,s),t.stateNode===null)Jh(e,t),i_(t,n,r),Nw(t,n,r,s),r=!0;else if(e===null){var a=t.stateNode,l=t.memoizedProps;a.props=l;var u=a.context,d=n.contextType;typeof d=="object"&&d!==null?d=Ci(d):(d=Ts(n)?Zl:Zr.current,d=xu(t,d));var f=n.getDerivedStateFromProps,c=typeof f=="function"||typeof a.getSnapshotBeforeUpdate=="function";c||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||u!==d)&&qk(t,a,r,d),Ma=!1;var p=t.memoizedState;a.state=p,Pm(t,r,a,s),u=t.memoizedState,l!==r||p!==u||Is.current||Ma?(typeof f=="function"&&(Sw(t,n,f,r),u=t.memoizedState),(l=Ma||Kk(t,n,l,r,p,u,d))?(c||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=u),a.props=r,a.state=u,a.context=d,r=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,DE(e,t),l=t.memoizedProps,d=t.type===t.elementType?l:Bi(t.type,l),a.props=d,c=t.pendingProps,p=a.context,u=n.contextType,typeof u=="object"&&u!==null?u=Ci(u):(u=Ts(n)?Zl:Zr.current,u=xu(t,u));var m=n.getDerivedStateFromProps;(f=typeof m=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==c||p!==u)&&qk(t,a,r,u),Ma=!1,p=t.memoizedState,a.state=p,Pm(t,r,a,s);var g=t.memoizedState;l!==c||p!==g||Is.current||Ma?(typeof m=="function"&&(Sw(t,n,m,r),g=t.memoizedState),(d=Ma||Kk(t,n,d,r,p,g,u)||!1)?(f||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,g,u),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,g,u)),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=g),a.props=r,a.state=g,a.context=u,r=d):(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 Ew(e,t,n,r,i,s)}function Ew(e,t,n,r,s,i){u_(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return s&&Dk(t,n,!1),ca(e,t,i);r=t.stateNode,EO.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=bu(t,e.child,null,i),t.child=bu(t,null,l,i)):cs(e,t,l,i),t.memoizedState=r.state,s&&Dk(t,n,!0),t.child}function d_(e){var t=e.stateNode;t.pendingContext?$k(e,t.pendingContext,t.pendingContext!==t.context):t.context&&$k(e,t.context,!1),gv(e,t.containerInfo)}function eS(e,t,n,r,s){return wu(),uv(s),t.flags|=256,cs(e,t,n,r),t.child}var _w={dehydrated:null,treeContext:null,retryLane:0};function Pw(e){return{baseLanes:e,cachePool:null,transitions:null}}function f_(e,t,n){var r=t.pendingProps,s=qn.current,i=!1,a=(t.flags&128)!==0,l;if((l=a)||(l=e!==null&&e.memoizedState===null?!1:(s&2)!==0),l?(i=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(s|=1),En(qn,s&1),e===null)return vw(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,i?(r=t.mode,i=t.child,a={mode:"hidden",children:a},!(r&1)&&i!==null?(i.childLanes=0,i.pendingProps=a):i=Lg(a,r,0,null),e=ql(e,r,n,null),i.return=t,e.return=t,i.sibling=e,t.child=i,t.child.memoizedState=Pw(n),t.memoizedState=_w,e):Nv(t,a));if(s=e.memoizedState,s!==null&&(l=s.dehydrated,l!==null))return _O(e,t,a,r,l,s,n);if(i){i=r.fallback,a=t.mode,s=e.child,l=s.sibling;var u={mode:"hidden",children:r.children};return!(a&1)&&t.child!==s?(r=t.child,r.childLanes=0,r.pendingProps=u,t.deletions=null):(r=Qa(s,u),r.subtreeFlags=s.subtreeFlags&14680064),l!==null?i=Qa(l,i):(i=ql(i,a,n,null),i.flags|=2),i.return=t,r.return=t,r.sibling=i,t.child=r,r=i,i=t.child,a=e.child.memoizedState,a=a===null?Pw(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},i.memoizedState=a,i.childLanes=e.childLanes&~n,t.memoizedState=_w,r}return i=e.child,e=i.sibling,r=Qa(i,{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 Nv(e,t){return t=Lg({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function uh(e,t,n,r){return r!==null&&uv(r),bu(t,e.child,null,n),e=Nv(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function _O(e,t,n,r,s,i,a){if(n)return t.flags&256?(t.flags&=-257,r=qy(Error(je(422))),uh(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(i=r.fallback,s=t.mode,r=Lg({mode:"visible",children:r.children},s,0,null),i=ql(i,s,a,null),i.flags|=2,r.return=t,i.return=t,r.sibling=i,t.child=r,t.mode&1&&bu(t,e.child,null,a),t.child.memoizedState=Pw(a),t.memoizedState=_w,i);if(!(t.mode&1))return uh(e,t,a,null);if(s.data==="$!"){if(r=s.nextSibling&&s.nextSibling.dataset,r)var l=r.dgst;return r=l,i=Error(je(419)),r=qy(i,r,void 0),uh(e,t,a,r)}if(l=(a&e.childLanes)!==0,Cs||l){if(r=Pr,r!==null){switch(a&-a){case 4:s=2;break;case 16:s=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:s=32;break;case 536870912:s=268435456;break;default:s=0}s=s&(r.suspendedLanes|a)?0:s,s!==0&&s!==i.retryLane&&(i.retryLane=s,la(e,s),Xi(r,e,s,-1))}return Av(),r=qy(Error(je(421))),uh(e,t,a,r)}return s.data==="$?"?(t.flags|=128,t.child=e.child,t=BO.bind(null,e),s._reactRetry=t,null):(e=i.treeContext,Js=Ya(s.nextSibling),Zs=t,Bn=!0,Vi=null,e!==null&&(bi[vi++]=ea,bi[vi++]=ta,bi[vi++]=ec,ea=e.id,ta=e.overflow,ec=t),t=Nv(t,r.children),t.flags|=4096,t)}function tS(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),kw(e.return,t,n)}function Yy(e,t,n,r,s){var i=e.memoizedState;i===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:s}:(i.isBackwards=t,i.rendering=null,i.renderingStartTime=0,i.last=r,i.tail=n,i.tailMode=s)}function p_(e,t,n){var r=t.pendingProps,s=r.revealOrder,i=r.tail;if(cs(e,t,r.children,n),r=qn.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&&tS(e,n,t);else if(e.tag===19)tS(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(En(qn,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&&Am(e)===null&&(s=n),n=n.sibling;n=s,n===null?(s=t.child,t.child=null):(s=n.sibling,n.sibling=null),Yy(t,!1,s,n,i);break;case"backwards":for(n=null,s=t.child,t.child=null;s!==null;){if(e=s.alternate,e!==null&&Am(e)===null){t.child=s;break}e=s.sibling,s.sibling=n,n=s,s=e}Yy(t,!0,n,null,i);break;case"together":Yy(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Jh(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function ca(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),nc|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(je(153));if(t.child!==null){for(e=t.child,n=Qa(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Qa(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function PO(e,t,n){switch(t.tag){case 3:d_(t),wu();break;case 5:FE(t);break;case 1:Ts(t.type)&&Nm(t);break;case 4:gv(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,s=t.memoizedProps.value;En(Em,r._currentValue),r._currentValue=s;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(En(qn,qn.current&1),t.flags|=128,null):n&t.child.childLanes?f_(e,t,n):(En(qn,qn.current&1),e=ca(e,t,n),e!==null?e.sibling:null);En(qn,qn.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return p_(e,t,n);t.flags|=128}if(s=t.memoizedState,s!==null&&(s.rendering=null,s.tail=null,s.lastEffect=null),En(qn,qn.current),r)break;return null;case 22:case 23:return t.lanes=0,c_(e,t,n)}return ca(e,t,n)}var h_,Aw,m_,g_;h_=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}};Aw=function(){};m_=function(e,t,n,r){var s=e.memoizedProps;if(s!==r){e=t.stateNode,Vl(No.current);var i=null;switch(n){case"input":s=Qx(e,s),r=Qx(e,r),i=[];break;case"select":s=Gn({},s,{value:void 0}),r=Gn({},r,{value:void 0}),i=[];break;case"textarea":s=tw(e,s),r=tw(e,r),i=[];break;default:typeof s.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=km)}rw(n,r);var a;n=null;for(d in s)if(!r.hasOwnProperty(d)&&s.hasOwnProperty(d)&&s[d]!=null)if(d==="style"){var l=s[d];for(a in l)l.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else d!=="dangerouslySetInnerHTML"&&d!=="children"&&d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&d!=="autoFocus"&&(pf.hasOwnProperty(d)?i||(i=[]):(i=i||[]).push(d,null));for(d in r){var u=r[d];if(l=s!=null?s[d]:void 0,r.hasOwnProperty(d)&&u!==l&&(u!=null||l!=null))if(d==="style")if(l){for(a in l)!l.hasOwnProperty(a)||u&&u.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in u)u.hasOwnProperty(a)&&l[a]!==u[a]&&(n||(n={}),n[a]=u[a])}else n||(i||(i=[]),i.push(d,n)),n=u;else d==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,l=l?l.__html:void 0,u!=null&&l!==u&&(i=i||[]).push(d,u)):d==="children"?typeof u!="string"&&typeof u!="number"||(i=i||[]).push(d,""+u):d!=="suppressContentEditableWarning"&&d!=="suppressHydrationWarning"&&(pf.hasOwnProperty(d)?(u!=null&&d==="onScroll"&&On("scroll",e),i||l===u||(i=[])):(i=i||[]).push(d,u))}n&&(i=i||[]).push("style",n);var d=i;(t.updateQueue=d)&&(t.flags|=4)}};g_=function(e,t,n,r){n!==r&&(t.flags|=4)};function Nd(e,t){if(!Bn)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 Xr(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 AO(e,t,n){var r=t.pendingProps;switch(cv(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Xr(t),null;case 1:return Ts(t.type)&&Sm(),Xr(t),null;case 3:return r=t.stateNode,vu(),$n(Is),$n(Zr),xv(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(lh(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,Vi!==null&&(Dw(Vi),Vi=null))),Aw(e,t),Xr(t),null;case 5:yv(t);var s=Vl(jf.current);if(n=t.type,e!==null&&t.stateNode!=null)m_(e,t,n,r,s),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(je(166));return Xr(t),null}if(e=Vl(No.current),lh(t)){r=t.stateNode,n=t.type;var i=t.memoizedProps;switch(r[wo]=t,r[Sf]=i,e=(t.mode&1)!==0,n){case"dialog":On("cancel",r),On("close",r);break;case"iframe":case"object":case"embed":On("load",r);break;case"video":case"audio":for(s=0;s<Fd.length;s++)On(Fd[s],r);break;case"source":On("error",r);break;case"img":case"image":case"link":On("error",r),On("load",r);break;case"details":On("toggle",r);break;case"input":uk(r,i),On("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!i.multiple},On("invalid",r);break;case"textarea":fk(r,i),On("invalid",r)}rw(n,i),s=null;for(var a in i)if(i.hasOwnProperty(a)){var l=i[a];a==="children"?typeof l=="string"?r.textContent!==l&&(i.suppressHydrationWarning!==!0&&ah(r.textContent,l,e),s=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(i.suppressHydrationWarning!==!0&&ah(r.textContent,l,e),s=["children",""+l]):pf.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&On("scroll",r)}switch(n){case"input":Zp(r),dk(r,i,!0);break;case"textarea":Zp(r),pk(r);break;case"select":case"option":break;default:typeof i.onClick=="function"&&(r.onclick=km)}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=VC(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[wo]=t,e[Sf]=r,h_(e,t,!1,!1),t.stateNode=e;e:{switch(a=sw(n,r),n){case"dialog":On("cancel",e),On("close",e),s=r;break;case"iframe":case"object":case"embed":On("load",e),s=r;break;case"video":case"audio":for(s=0;s<Fd.length;s++)On(Fd[s],e);s=r;break;case"source":On("error",e),s=r;break;case"img":case"image":case"link":On("error",e),On("load",e),s=r;break;case"details":On("toggle",e),s=r;break;case"input":uk(e,r),s=Qx(e,r),On("invalid",e);break;case"option":s=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},s=Gn({},r,{value:void 0}),On("invalid",e);break;case"textarea":fk(e,r),s=tw(e,r),On("invalid",e);break;default:s=r}rw(n,s),l=s;for(i in l)if(l.hasOwnProperty(i)){var u=l[i];i==="style"?qC(e,u):i==="dangerouslySetInnerHTML"?(u=u?u.__html:void 0,u!=null&&UC(e,u)):i==="children"?typeof u=="string"?(n!=="textarea"||u!=="")&&hf(e,u):typeof u=="number"&&hf(e,""+u):i!=="suppressContentEditableWarning"&&i!=="suppressHydrationWarning"&&i!=="autoFocus"&&(pf.hasOwnProperty(i)?u!=null&&i==="onScroll"&&On("scroll",e):u!=null&&Yb(e,i,u,a))}switch(n){case"input":Zp(e),dk(e,r,!1);break;case"textarea":Zp(e),pk(e);break;case"option":r.value!=null&&e.setAttribute("value",""+rl(r.value));break;case"select":e.multiple=!!r.multiple,i=r.value,i!=null?iu(e,!!r.multiple,i,!1):r.defaultValue!=null&&iu(e,!!r.multiple,r.defaultValue,!0);break;default:typeof s.onClick=="function"&&(e.onclick=km)}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 Xr(t),null;case 6:if(e&&t.stateNode!=null)g_(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(je(166));if(n=Vl(jf.current),Vl(No.current),lh(t)){if(r=t.stateNode,n=t.memoizedProps,r[wo]=t,(i=r.nodeValue!==n)&&(e=Zs,e!==null))switch(e.tag){case 3:ah(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&ah(r.nodeValue,n,(e.mode&1)!==0)}i&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[wo]=t,t.stateNode=r}return Xr(t),null;case 13:if($n(qn),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Bn&&Js!==null&&t.mode&1&&!(t.flags&128))LE(),wu(),t.flags|=98560,i=!1;else if(i=lh(t),r!==null&&r.dehydrated!==null){if(e===null){if(!i)throw Error(je(318));if(i=t.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(je(317));i[wo]=t}else wu(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Xr(t),i=!1}else Vi!==null&&(Dw(Vi),Vi=null),i=!0;if(!i)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||qn.current&1?vr===0&&(vr=3):Av())),t.updateQueue!==null&&(t.flags|=4),Xr(t),null);case 4:return vu(),Aw(e,t),e===null&&vf(t.stateNode.containerInfo),Xr(t),null;case 10:return pv(t.type._context),Xr(t),null;case 17:return Ts(t.type)&&Sm(),Xr(t),null;case 19:if($n(qn),i=t.memoizedState,i===null)return Xr(t),null;if(r=(t.flags&128)!==0,a=i.rendering,a===null)if(r)Nd(i,!1);else{if(vr!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=Am(e),a!==null){for(t.flags|=128,Nd(i,!1),r=a.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)i=n,e=r,i.flags&=14680066,a=i.alternate,a===null?(i.childLanes=0,i.lanes=e,i.child=null,i.subtreeFlags=0,i.memoizedProps=null,i.memoizedState=null,i.updateQueue=null,i.dependencies=null,i.stateNode=null):(i.childLanes=a.childLanes,i.lanes=a.lanes,i.child=a.child,i.subtreeFlags=0,i.deletions=null,i.memoizedProps=a.memoizedProps,i.memoizedState=a.memoizedState,i.updateQueue=a.updateQueue,i.type=a.type,e=a.dependencies,i.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return En(qn,qn.current&1|2),t.child}e=e.sibling}i.tail!==null&&lr()>Su&&(t.flags|=128,r=!0,Nd(i,!1),t.lanes=4194304)}else{if(!r)if(e=Am(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Nd(i,!0),i.tail===null&&i.tailMode==="hidden"&&!a.alternate&&!Bn)return Xr(t),null}else 2*lr()-i.renderingStartTime>Su&&n!==1073741824&&(t.flags|=128,r=!0,Nd(i,!1),t.lanes=4194304);i.isBackwards?(a.sibling=t.child,t.child=a):(n=i.last,n!==null?n.sibling=a:t.child=a,i.last=a)}return i.tail!==null?(t=i.tail,i.rendering=t,i.tail=t.sibling,i.renderingStartTime=lr(),t.sibling=null,n=qn.current,En(qn,r?n&1|2:n&1),t):(Xr(t),null);case 22:case 23:return Pv(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?Ys&1073741824&&(Xr(t),t.subtreeFlags&6&&(t.flags|=8192)):Xr(t),null;case 24:return null;case 25:return null}throw Error(je(156,t.tag))}function IO(e,t){switch(cv(t),t.tag){case 1:return Ts(t.type)&&Sm(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return vu(),$n(Is),$n(Zr),xv(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return yv(t),null;case 13:if($n(qn),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(je(340));wu()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return $n(qn),null;case 4:return vu(),null;case 10:return pv(t.type._context),null;case 22:case 23:return Pv(),null;case 24:return null;default:return null}}var dh=!1,Jr=!1,TO=typeof WeakSet=="function"?WeakSet:Set,qe=null;function Jc(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){tr(e,t,r)}else n.current=null}function Iw(e,t,n){try{n()}catch(r){tr(e,t,r)}}var nS=!1;function RO(e,t){if(hw=wm,e=vE(),av(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,i=r.focusNode;r=r.focusOffset;try{n.nodeType,i.nodeType}catch{n=null;break e}var a=0,l=-1,u=-1,d=0,f=0,c=e,p=null;t:for(;;){for(var m;c!==n||s!==0&&c.nodeType!==3||(l=a+s),c!==i||r!==0&&c.nodeType!==3||(u=a+r),c.nodeType===3&&(a+=c.nodeValue.length),(m=c.firstChild)!==null;)p=c,c=m;for(;;){if(c===e)break t;if(p===n&&++d===s&&(l=a),p===i&&++f===r&&(u=a),(m=c.nextSibling)!==null)break;c=p,p=c.parentNode}c=m}n=l===-1||u===-1?null:{start:l,end:u}}else n=null}n=n||{start:0,end:0}}else n=null;for(mw={focusedElem:e,selectionRange:n},wm=!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 g=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(g!==null){var b=g.memoizedProps,k=g.memoizedState,y=t.stateNode,v=y.getSnapshotBeforeUpdate(t.elementType===t.type?b:Bi(t.type,b),k);y.__reactInternalSnapshotBeforeUpdate=v}break;case 3:var w=t.stateNode.containerInfo;w.nodeType===1?w.textContent="":w.nodeType===9&&w.documentElement&&w.removeChild(w.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(je(163))}}catch(j){tr(t,t.return,j)}if(e=t.sibling,e!==null){e.return=t.return,qe=e;break}qe=t.return}return g=nS,nS=!1,g}function Zd(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 i=s.destroy;s.destroy=void 0,i!==void 0&&Iw(t,n,i)}s=s.next}while(s!==r)}}function Tg(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 Tw(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 y_(e){var t=e.alternate;t!==null&&(e.alternate=null,y_(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[wo],delete t[Sf],delete t[xw],delete t[mO],delete t[gO])),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 x_(e){return e.tag===5||e.tag===3||e.tag===4}function rS(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||x_(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 Rw(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=km));else if(r!==4&&(e=e.child,e!==null))for(Rw(e,t,n),e=e.sibling;e!==null;)Rw(e,t,n),e=e.sibling}function Lw(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(Lw(e,t,n),e=e.sibling;e!==null;)Lw(e,t,n),e=e.sibling}var Lr=null,Hi=!1;function _a(e,t,n){for(n=n.child;n!==null;)w_(e,t,n),n=n.sibling}function w_(e,t,n){if(So&&typeof So.onCommitFiberUnmount=="function")try{So.onCommitFiberUnmount(Ng,n)}catch{}switch(n.tag){case 5:Jr||Jc(n,t);case 6:var r=Lr,s=Hi;Lr=null,_a(e,t,n),Lr=r,Hi=s,Lr!==null&&(Hi?(e=Lr,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Lr.removeChild(n.stateNode));break;case 18:Lr!==null&&(Hi?(e=Lr,n=n.stateNode,e.nodeType===8?By(e.parentNode,n):e.nodeType===1&&By(e,n),xf(e)):By(Lr,n.stateNode));break;case 4:r=Lr,s=Hi,Lr=n.stateNode.containerInfo,Hi=!0,_a(e,t,n),Lr=r,Hi=s;break;case 0:case 11:case 14:case 15:if(!Jr&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){s=r=r.next;do{var i=s,a=i.destroy;i=i.tag,a!==void 0&&(i&2||i&4)&&Iw(n,t,a),s=s.next}while(s!==r)}_a(e,t,n);break;case 1:if(!Jr&&(Jc(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){tr(n,t,l)}_a(e,t,n);break;case 21:_a(e,t,n);break;case 22:n.mode&1?(Jr=(r=Jr)||n.memoizedState!==null,_a(e,t,n),Jr=r):_a(e,t,n);break;default:_a(e,t,n)}}function sS(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new TO),t.forEach(function(r){var s=HO.bind(null,e,r);n.has(r)||(n.add(r),r.then(s,s))})}}function Di(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var s=n[r];try{var i=e,a=t,l=a;e:for(;l!==null;){switch(l.tag){case 5:Lr=l.stateNode,Hi=!1;break e;case 3:Lr=l.stateNode.containerInfo,Hi=!0;break e;case 4:Lr=l.stateNode.containerInfo,Hi=!0;break e}l=l.return}if(Lr===null)throw Error(je(160));w_(i,a,s),Lr=null,Hi=!1;var u=s.alternate;u!==null&&(u.return=null),s.return=null}catch(d){tr(s,t,d)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)b_(t,e),t=t.sibling}function b_(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Di(t,e),po(e),r&4){try{Zd(3,e,e.return),Tg(3,e)}catch(b){tr(e,e.return,b)}try{Zd(5,e,e.return)}catch(b){tr(e,e.return,b)}}break;case 1:Di(t,e),po(e),r&512&&n!==null&&Jc(n,n.return);break;case 5:if(Di(t,e),po(e),r&512&&n!==null&&Jc(n,n.return),e.flags&32){var s=e.stateNode;try{hf(s,"")}catch(b){tr(e,e.return,b)}}if(r&4&&(s=e.stateNode,s!=null)){var i=e.memoizedProps,a=n!==null?n.memoizedProps:i,l=e.type,u=e.updateQueue;if(e.updateQueue=null,u!==null)try{l==="input"&&i.type==="radio"&&i.name!=null&&HC(s,i),sw(l,a);var d=sw(l,i);for(a=0;a<u.length;a+=2){var f=u[a],c=u[a+1];f==="style"?qC(s,c):f==="dangerouslySetInnerHTML"?UC(s,c):f==="children"?hf(s,c):Yb(s,f,c,d)}switch(l){case"input":Zx(s,i);break;case"textarea":WC(s,i);break;case"select":var p=s._wrapperState.wasMultiple;s._wrapperState.wasMultiple=!!i.multiple;var m=i.value;m!=null?iu(s,!!i.multiple,m,!1):p!==!!i.multiple&&(i.defaultValue!=null?iu(s,!!i.multiple,i.defaultValue,!0):iu(s,!!i.multiple,i.multiple?[]:"",!1))}s[Sf]=i}catch(b){tr(e,e.return,b)}}break;case 6:if(Di(t,e),po(e),r&4){if(e.stateNode===null)throw Error(je(162));s=e.stateNode,i=e.memoizedProps;try{s.nodeValue=i}catch(b){tr(e,e.return,b)}}break;case 3:if(Di(t,e),po(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{xf(t.containerInfo)}catch(b){tr(e,e.return,b)}break;case 4:Di(t,e),po(e);break;case 13:Di(t,e),po(e),s=e.child,s.flags&8192&&(i=s.memoizedState!==null,s.stateNode.isHidden=i,!i||s.alternate!==null&&s.alternate.memoizedState!==null||(Ev=lr())),r&4&&sS(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Jr=(d=Jr)||f,Di(t,e),Jr=d):Di(t,e),po(e),r&8192){if(d=e.memoizedState!==null,(e.stateNode.isHidden=d)&&!f&&e.mode&1)for(qe=e,f=e.child;f!==null;){for(c=qe=f;qe!==null;){switch(p=qe,m=p.child,p.tag){case 0:case 11:case 14:case 15:Zd(4,p,p.return);break;case 1:Jc(p,p.return);var g=p.stateNode;if(typeof g.componentWillUnmount=="function"){r=p,n=p.return;try{t=r,g.props=t.memoizedProps,g.state=t.memoizedState,g.componentWillUnmount()}catch(b){tr(r,n,b)}}break;case 5:Jc(p,p.return);break;case 22:if(p.memoizedState!==null){oS(c);continue}}m!==null?(m.return=p,qe=m):oS(c)}f=f.sibling}e:for(f=null,c=e;;){if(c.tag===5){if(f===null){f=c;try{s=c.stateNode,d?(i=s.style,typeof i.setProperty=="function"?i.setProperty("display","none","important"):i.display="none"):(l=c.stateNode,u=c.memoizedProps.style,a=u!=null&&u.hasOwnProperty("display")?u.display:null,l.style.display=KC("display",a))}catch(b){tr(e,e.return,b)}}}else if(c.tag===6){if(f===null)try{c.stateNode.nodeValue=d?"":c.memoizedProps}catch(b){tr(e,e.return,b)}}else if((c.tag!==22&&c.tag!==23||c.memoizedState===null||c===e)&&c.child!==null){c.child.return=c,c=c.child;continue}if(c===e)break e;for(;c.sibling===null;){if(c.return===null||c.return===e)break e;f===c&&(f=null),c=c.return}f===c&&(f=null),c.sibling.return=c.return,c=c.sibling}}break;case 19:Di(t,e),po(e),r&4&&sS(e);break;case 21:break;default:Di(t,e),po(e)}}function po(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(x_(n)){var r=n;break e}n=n.return}throw Error(je(160))}switch(r.tag){case 5:var s=r.stateNode;r.flags&32&&(hf(s,""),r.flags&=-33);var i=rS(e);Lw(e,i,s);break;case 3:case 4:var a=r.stateNode.containerInfo,l=rS(e);Rw(e,l,a);break;default:throw Error(je(161))}}catch(u){tr(e,e.return,u)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function LO(e,t,n){qe=e,v_(e)}function v_(e,t,n){for(var r=(e.mode&1)!==0;qe!==null;){var s=qe,i=s.child;if(s.tag===22&&r){var a=s.memoizedState!==null||dh;if(!a){var l=s.alternate,u=l!==null&&l.memoizedState!==null||Jr;l=dh;var d=Jr;if(dh=a,(Jr=u)&&!d)for(qe=s;qe!==null;)a=qe,u=a.child,a.tag===22&&a.memoizedState!==null?aS(s):u!==null?(u.return=a,qe=u):aS(s);for(;i!==null;)qe=i,v_(i),i=i.sibling;qe=s,dh=l,Jr=d}iS(e)}else s.subtreeFlags&8772&&i!==null?(i.return=s,qe=i):iS(e)}}function iS(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:Jr||Tg(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Jr)if(n===null)r.componentDidMount();else{var s=t.elementType===t.type?n.memoizedProps:Bi(t.type,n.memoizedProps);r.componentDidUpdate(s,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var i=t.updateQueue;i!==null&&Wk(t,i,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}Wk(t,a,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var u=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":u.autoFocus&&n.focus();break;case"img":u.src&&(n.src=u.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var d=t.alternate;if(d!==null){var f=d.memoizedState;if(f!==null){var c=f.dehydrated;c!==null&&xf(c)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(je(163))}Jr||t.flags&512&&Tw(t)}catch(p){tr(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 oS(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 aS(e){for(;qe!==null;){var t=qe;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{Tg(4,t)}catch(u){tr(t,n,u)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var s=t.return;try{r.componentDidMount()}catch(u){tr(t,s,u)}}var i=t.return;try{Tw(t)}catch(u){tr(t,i,u)}break;case 5:var a=t.return;try{Tw(t)}catch(u){tr(t,a,u)}}}catch(u){tr(t,t.return,u)}if(t===e){qe=null;break}var l=t.sibling;if(l!==null){l.return=t.return,qe=l;break}qe=t.return}}var OO=Math.ceil,Rm=pa.ReactCurrentDispatcher,jv=pa.ReactCurrentOwner,ji=pa.ReactCurrentBatchConfig,Kt=0,Pr=null,hr=null,Mr=0,Ys=0,Qc=fl(0),vr=0,Pf=null,nc=0,Rg=0,Cv=0,ef=null,js=null,Ev=0,Su=1/0,Go=null,Lm=!1,Ow=null,Xa=null,fh=!1,Ha=null,Om=0,tf=0,Mw=null,Qh=-1,Zh=0;function ds(){return Kt&6?lr():Qh!==-1?Qh:Qh=lr()}function Ja(e){return e.mode&1?Kt&2&&Mr!==0?Mr&-Mr:xO.transition!==null?(Zh===0&&(Zh=iE()),Zh):(e=on,e!==0||(e=window.event,e=e===void 0?16:fE(e.type)),e):1}function Xi(e,t,n,r){if(50<tf)throw tf=0,Mw=null,Error(je(185));ep(e,n,r),(!(Kt&2)||e!==Pr)&&(e===Pr&&(!(Kt&2)&&(Rg|=n),vr===4&&Fa(e,Mr)),Rs(e,r),n===1&&Kt===0&&!(t.mode&1)&&(Su=lr()+500,Pg&&pl()))}function Rs(e,t){var n=e.callbackNode;xL(e,t);var r=xm(e,e===Pr?Mr:0);if(r===0)n!==null&&gk(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&gk(n),t===1)e.tag===0?yO(lS.bind(null,e)):IE(lS.bind(null,e)),pO(function(){!(Kt&6)&&pl()}),n=null;else{switch(oE(r)){case 1:n=Zb;break;case 4:n=rE;break;case 16:n=ym;break;case 536870912:n=sE;break;default:n=ym}n=P_(n,k_.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function k_(e,t){if(Qh=-1,Zh=0,Kt&6)throw Error(je(327));var n=e.callbackNode;if(uu()&&e.callbackNode!==n)return null;var r=xm(e,e===Pr?Mr:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=Mm(e,r);else{t=r;var s=Kt;Kt|=2;var i=N_();(Pr!==e||Mr!==t)&&(Go=null,Su=lr()+500,Kl(e,t));do try{DO();break}catch(l){S_(e,l)}while(!0);fv(),Rm.current=i,Kt=s,hr!==null?t=0:(Pr=null,Mr=0,t=vr)}if(t!==0){if(t===2&&(s=cw(e),s!==0&&(r=s,t=$w(e,s))),t===1)throw n=Pf,Kl(e,0),Fa(e,r),Rs(e,lr()),n;if(t===6)Fa(e,r);else{if(s=e.current.alternate,!(r&30)&&!MO(s)&&(t=Mm(e,r),t===2&&(i=cw(e),i!==0&&(r=i,t=$w(e,i))),t===1))throw n=Pf,Kl(e,0),Fa(e,r),Rs(e,lr()),n;switch(e.finishedWork=s,e.finishedLanes=r,t){case 0:case 1:throw Error(je(345));case 2:Dl(e,js,Go);break;case 3:if(Fa(e,r),(r&130023424)===r&&(t=Ev+500-lr(),10<t)){if(xm(e,0)!==0)break;if(s=e.suspendedLanes,(s&r)!==r){ds(),e.pingedLanes|=e.suspendedLanes&s;break}e.timeoutHandle=yw(Dl.bind(null,e,js,Go),t);break}Dl(e,js,Go);break;case 4:if(Fa(e,r),(r&4194240)===r)break;for(t=e.eventTimes,s=-1;0<r;){var a=31-Gi(r);i=1<<a,a=t[a],a>s&&(s=a),r&=~i}if(r=s,r=lr()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*OO(r/1960))-r,10<r){e.timeoutHandle=yw(Dl.bind(null,e,js,Go),r);break}Dl(e,js,Go);break;case 5:Dl(e,js,Go);break;default:throw Error(je(329))}}}return Rs(e,lr()),e.callbackNode===n?k_.bind(null,e):null}function $w(e,t){var n=ef;return e.current.memoizedState.isDehydrated&&(Kl(e,t).flags|=256),e=Mm(e,t),e!==2&&(t=js,js=n,t!==null&&Dw(t)),e}function Dw(e){js===null?js=e:js.push.apply(js,e)}function MO(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],i=s.getSnapshot;s=s.value;try{if(!Ji(i(),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 Fa(e,t){for(t&=~Cv,t&=~Rg,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-Gi(t),r=1<<n;e[n]=-1,t&=~r}}function lS(e){if(Kt&6)throw Error(je(327));uu();var t=xm(e,0);if(!(t&1))return Rs(e,lr()),null;var n=Mm(e,t);if(e.tag!==0&&n===2){var r=cw(e);r!==0&&(t=r,n=$w(e,r))}if(n===1)throw n=Pf,Kl(e,0),Fa(e,t),Rs(e,lr()),n;if(n===6)throw Error(je(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Dl(e,js,Go),Rs(e,lr()),null}function _v(e,t){var n=Kt;Kt|=1;try{return e(t)}finally{Kt=n,Kt===0&&(Su=lr()+500,Pg&&pl())}}function rc(e){Ha!==null&&Ha.tag===0&&!(Kt&6)&&uu();var t=Kt;Kt|=1;var n=ji.transition,r=on;try{if(ji.transition=null,on=1,e)return e()}finally{on=r,ji.transition=n,Kt=t,!(Kt&6)&&pl()}}function Pv(){Ys=Qc.current,$n(Qc)}function Kl(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,fO(n)),hr!==null)for(n=hr.return;n!==null;){var r=n;switch(cv(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&Sm();break;case 3:vu(),$n(Is),$n(Zr),xv();break;case 5:yv(r);break;case 4:vu();break;case 13:$n(qn);break;case 19:$n(qn);break;case 10:pv(r.type._context);break;case 22:case 23:Pv()}n=n.return}if(Pr=e,hr=e=Qa(e.current,null),Mr=Ys=t,vr=0,Pf=null,Cv=Rg=nc=0,js=ef=null,Wl!==null){for(t=0;t<Wl.length;t++)if(n=Wl[t],r=n.interleaved,r!==null){n.interleaved=null;var s=r.next,i=n.pending;if(i!==null){var a=i.next;i.next=s,r.next=a}n.pending=r}Wl=null}return e}function S_(e,t){do{var n=hr;try{if(fv(),Gh.current=Tm,Im){for(var r=Yn.memoizedState;r!==null;){var s=r.queue;s!==null&&(s.pending=null),r=r.next}Im=!1}if(tc=0,Er=wr=Yn=null,Qd=!1,Cf=0,jv.current=null,n===null||n.return===null){vr=1,Pf=t,hr=null;break}e:{var i=e,a=n.return,l=n,u=t;if(t=Mr,l.flags|=32768,u!==null&&typeof u=="object"&&typeof u.then=="function"){var d=u,f=l,c=f.tag;if(!(f.mode&1)&&(c===0||c===11||c===15)){var p=f.alternate;p?(f.updateQueue=p.updateQueue,f.memoizedState=p.memoizedState,f.lanes=p.lanes):(f.updateQueue=null,f.memoizedState=null)}var m=Gk(a);if(m!==null){m.flags&=-257,Xk(m,a,l,i,t),m.mode&1&&Yk(i,d,t),t=m,u=d;var g=t.updateQueue;if(g===null){var b=new Set;b.add(u),t.updateQueue=b}else g.add(u);break e}else{if(!(t&1)){Yk(i,d,t),Av();break e}u=Error(je(426))}}else if(Bn&&l.mode&1){var k=Gk(a);if(k!==null){!(k.flags&65536)&&(k.flags|=256),Xk(k,a,l,i,t),uv(ku(u,l));break e}}i=u=ku(u,l),vr!==4&&(vr=2),ef===null?ef=[i]:ef.push(i),i=a;do{switch(i.tag){case 3:i.flags|=65536,t&=-t,i.lanes|=t;var y=o_(i,u,t);Hk(i,y);break e;case 1:l=u;var v=i.type,w=i.stateNode;if(!(i.flags&128)&&(typeof v.getDerivedStateFromError=="function"||w!==null&&typeof w.componentDidCatch=="function"&&(Xa===null||!Xa.has(w)))){i.flags|=65536,t&=-t,i.lanes|=t;var j=a_(i,l,t);Hk(i,j);break e}}i=i.return}while(i!==null)}C_(n)}catch(P){t=P,hr===n&&n!==null&&(hr=n=n.return);continue}break}while(!0)}function N_(){var e=Rm.current;return Rm.current=Tm,e===null?Tm:e}function Av(){(vr===0||vr===3||vr===2)&&(vr=4),Pr===null||!(nc&268435455)&&!(Rg&268435455)||Fa(Pr,Mr)}function Mm(e,t){var n=Kt;Kt|=2;var r=N_();(Pr!==e||Mr!==t)&&(Go=null,Kl(e,t));do try{$O();break}catch(s){S_(e,s)}while(!0);if(fv(),Kt=n,Rm.current=r,hr!==null)throw Error(je(261));return Pr=null,Mr=0,vr}function $O(){for(;hr!==null;)j_(hr)}function DO(){for(;hr!==null&&!cL();)j_(hr)}function j_(e){var t=__(e.alternate,e,Ys);e.memoizedProps=e.pendingProps,t===null?C_(e):hr=t,jv.current=null}function C_(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=IO(n,t),n!==null){n.flags&=32767,hr=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{vr=6,hr=null;return}}else if(n=AO(n,t,Ys),n!==null){hr=n;return}if(t=t.sibling,t!==null){hr=t;return}hr=t=e}while(t!==null);vr===0&&(vr=5)}function Dl(e,t,n){var r=on,s=ji.transition;try{ji.transition=null,on=1,FO(e,t,n,r)}finally{ji.transition=s,on=r}return null}function FO(e,t,n,r){do uu();while(Ha!==null);if(Kt&6)throw Error(je(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(je(177));e.callbackNode=null,e.callbackPriority=0;var i=n.lanes|n.childLanes;if(wL(e,i),e===Pr&&(hr=Pr=null,Mr=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||fh||(fh=!0,P_(ym,function(){return uu(),null})),i=(n.flags&15990)!==0,n.subtreeFlags&15990||i){i=ji.transition,ji.transition=null;var a=on;on=1;var l=Kt;Kt|=4,jv.current=null,RO(e,n),b_(n,e),iO(mw),wm=!!hw,mw=hw=null,e.current=n,LO(n),uL(),Kt=l,on=a,ji.transition=i}else e.current=n;if(fh&&(fh=!1,Ha=e,Om=s),i=e.pendingLanes,i===0&&(Xa=null),pL(n.stateNode),Rs(e,lr()),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(Lm)throw Lm=!1,e=Ow,Ow=null,e;return Om&1&&e.tag!==0&&uu(),i=e.pendingLanes,i&1?e===Mw?tf++:(tf=0,Mw=e):tf=0,pl(),null}function uu(){if(Ha!==null){var e=oE(Om),t=ji.transition,n=on;try{if(ji.transition=null,on=16>e?16:e,Ha===null)var r=!1;else{if(e=Ha,Ha=null,Om=0,Kt&6)throw Error(je(331));var s=Kt;for(Kt|=4,qe=e.current;qe!==null;){var i=qe,a=i.child;if(qe.flags&16){var l=i.deletions;if(l!==null){for(var u=0;u<l.length;u++){var d=l[u];for(qe=d;qe!==null;){var f=qe;switch(f.tag){case 0:case 11:case 15:Zd(8,f,i)}var c=f.child;if(c!==null)c.return=f,qe=c;else for(;qe!==null;){f=qe;var p=f.sibling,m=f.return;if(y_(f),f===d){qe=null;break}if(p!==null){p.return=m,qe=p;break}qe=m}}}var g=i.alternate;if(g!==null){var b=g.child;if(b!==null){g.child=null;do{var k=b.sibling;b.sibling=null,b=k}while(b!==null)}}qe=i}}if(i.subtreeFlags&2064&&a!==null)a.return=i,qe=a;else e:for(;qe!==null;){if(i=qe,i.flags&2048)switch(i.tag){case 0:case 11:case 15:Zd(9,i,i.return)}var y=i.sibling;if(y!==null){y.return=i.return,qe=y;break e}qe=i.return}}var v=e.current;for(qe=v;qe!==null;){a=qe;var w=a.child;if(a.subtreeFlags&2064&&w!==null)w.return=a,qe=w;else e:for(a=v;qe!==null;){if(l=qe,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:Tg(9,l)}}catch(P){tr(l,l.return,P)}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(Kt=s,pl(),So&&typeof So.onPostCommitFiberRoot=="function")try{So.onPostCommitFiberRoot(Ng,e)}catch{}r=!0}return r}finally{on=n,ji.transition=t}}return!1}function cS(e,t,n){t=ku(n,t),t=o_(e,t,1),e=Ga(e,t,1),t=ds(),e!==null&&(ep(e,1,t),Rs(e,t))}function tr(e,t,n){if(e.tag===3)cS(e,e,n);else for(;t!==null;){if(t.tag===3){cS(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(Xa===null||!Xa.has(r))){e=ku(n,e),e=a_(t,e,1),t=Ga(t,e,1),e=ds(),t!==null&&(ep(t,1,e),Rs(t,e));break}}t=t.return}}function zO(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=ds(),e.pingedLanes|=e.suspendedLanes&n,Pr===e&&(Mr&n)===n&&(vr===4||vr===3&&(Mr&130023424)===Mr&&500>lr()-Ev?Kl(e,0):Cv|=n),Rs(e,t)}function E_(e,t){t===0&&(e.mode&1?(t=nh,nh<<=1,!(nh&130023424)&&(nh=4194304)):t=1);var n=ds();e=la(e,t),e!==null&&(ep(e,t,n),Rs(e,n))}function BO(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),E_(e,n)}function HO(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(je(314))}r!==null&&r.delete(t),E_(e,n)}var __;__=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||Is.current)Cs=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return Cs=!1,PO(e,t,n);Cs=!!(e.flags&131072)}else Cs=!1,Bn&&t.flags&1048576&&TE(t,Cm,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Jh(e,t),e=t.pendingProps;var s=xu(t,Zr.current);cu(t,n),s=bv(null,t,r,e,s,n);var i=vv();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,Ts(r)?(i=!0,Nm(t)):i=!1,t.memoizedState=s.state!==null&&s.state!==void 0?s.state:null,mv(t),s.updater=Ig,t.stateNode=s,s._reactInternals=t,Nw(t,r,e,n),t=Ew(null,t,r,!0,i,n)):(t.tag=0,Bn&&i&&lv(t),cs(null,t,s,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Jh(e,t),e=t.pendingProps,s=r._init,r=s(r._payload),t.type=r,s=t.tag=VO(r),e=Bi(r,e),s){case 0:t=Cw(null,t,r,e,n);break e;case 1:t=Zk(null,t,r,e,n);break e;case 11:t=Jk(null,t,r,e,n);break e;case 14:t=Qk(null,t,r,Bi(r.type,e),n);break e}throw Error(je(306,r,""))}return t;case 0:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Bi(r,s),Cw(e,t,r,s,n);case 1:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Bi(r,s),Zk(e,t,r,s,n);case 3:e:{if(d_(t),e===null)throw Error(je(387));r=t.pendingProps,i=t.memoizedState,s=i.element,DE(e,t),Pm(t,r,null,n);var a=t.memoizedState;if(r=a.element,i.isDehydrated)if(i={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=i,t.memoizedState=i,t.flags&256){s=ku(Error(je(423)),t),t=eS(e,t,r,n,s);break e}else if(r!==s){s=ku(Error(je(424)),t),t=eS(e,t,r,n,s);break e}else for(Js=Ya(t.stateNode.containerInfo.firstChild),Zs=t,Bn=!0,Vi=null,n=ME(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(wu(),r===s){t=ca(e,t,n);break e}cs(e,t,r,n)}t=t.child}return t;case 5:return FE(t),e===null&&vw(t),r=t.type,s=t.pendingProps,i=e!==null?e.memoizedProps:null,a=s.children,gw(r,s)?a=null:i!==null&&gw(r,i)&&(t.flags|=32),u_(e,t),cs(e,t,a,n),t.child;case 6:return e===null&&vw(t),null;case 13:return f_(e,t,n);case 4:return gv(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=bu(t,null,r,n):cs(e,t,r,n),t.child;case 11:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Bi(r,s),Jk(e,t,r,s,n);case 7:return cs(e,t,t.pendingProps,n),t.child;case 8:return cs(e,t,t.pendingProps.children,n),t.child;case 12:return cs(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,s=t.pendingProps,i=t.memoizedProps,a=s.value,En(Em,r._currentValue),r._currentValue=a,i!==null)if(Ji(i.value,a)){if(i.children===s.children&&!Is.current){t=ca(e,t,n);break e}}else for(i=t.child,i!==null&&(i.return=t);i!==null;){var l=i.dependencies;if(l!==null){a=i.child;for(var u=l.firstContext;u!==null;){if(u.context===r){if(i.tag===1){u=ia(-1,n&-n),u.tag=2;var d=i.updateQueue;if(d!==null){d=d.shared;var f=d.pending;f===null?u.next=u:(u.next=f.next,f.next=u),d.pending=u}}i.lanes|=n,u=i.alternate,u!==null&&(u.lanes|=n),kw(i.return,n,t),l.lanes|=n;break}u=u.next}}else if(i.tag===10)a=i.type===t.type?null:i.child;else if(i.tag===18){if(a=i.return,a===null)throw Error(je(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),kw(a,n,t),a=i.sibling}else a=i.child;if(a!==null)a.return=i;else for(a=i;a!==null;){if(a===t){a=null;break}if(i=a.sibling,i!==null){i.return=a.return,a=i;break}a=a.return}i=a}cs(e,t,s.children,n),t=t.child}return t;case 9:return s=t.type,r=t.pendingProps.children,cu(t,n),s=Ci(s),r=r(s),t.flags|=1,cs(e,t,r,n),t.child;case 14:return r=t.type,s=Bi(r,t.pendingProps),s=Bi(r.type,s),Qk(e,t,r,s,n);case 15:return l_(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,s=t.pendingProps,s=t.elementType===r?s:Bi(r,s),Jh(e,t),t.tag=1,Ts(r)?(e=!0,Nm(t)):e=!1,cu(t,n),i_(t,r,s),Nw(t,r,s,n),Ew(null,t,r,!0,e,n);case 19:return p_(e,t,n);case 22:return c_(e,t,n)}throw Error(je(156,t.tag))};function P_(e,t){return nE(e,t)}function WO(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 Ni(e,t,n,r){return new WO(e,t,n,r)}function Iv(e){return e=e.prototype,!(!e||!e.isReactComponent)}function VO(e){if(typeof e=="function")return Iv(e)?1:0;if(e!=null){if(e=e.$$typeof,e===Xb)return 11;if(e===Jb)return 14}return 2}function Qa(e,t){var n=e.alternate;return n===null?(n=Ni(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 em(e,t,n,r,s,i){var a=2;if(r=e,typeof e=="function")Iv(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case Hc:return ql(n.children,s,i,t);case Gb:a=8,s|=8;break;case Yx:return e=Ni(12,n,t,s|2),e.elementType=Yx,e.lanes=i,e;case Gx:return e=Ni(13,n,t,s),e.elementType=Gx,e.lanes=i,e;case Xx:return e=Ni(19,n,t,s),e.elementType=Xx,e.lanes=i,e;case FC:return Lg(n,s,i,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case $C:a=10;break e;case DC:a=9;break e;case Xb:a=11;break e;case Jb:a=14;break e;case Oa:a=16,r=null;break e}throw Error(je(130,e==null?e:typeof e,""))}return t=Ni(a,n,t,s),t.elementType=e,t.type=r,t.lanes=i,t}function ql(e,t,n,r){return e=Ni(7,e,r,t),e.lanes=n,e}function Lg(e,t,n,r){return e=Ni(22,e,r,t),e.elementType=FC,e.lanes=n,e.stateNode={isHidden:!1},e}function Gy(e,t,n){return e=Ni(6,e,null,t),e.lanes=n,e}function Xy(e,t,n){return t=Ni(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function UO(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=Ay(0),this.expirationTimes=Ay(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Ay(0),this.identifierPrefix=r,this.onRecoverableError=s,this.mutableSourceEagerHydrationData=null}function Tv(e,t,n,r,s,i,a,l,u){return e=new UO(e,t,n,l,u),t===1?(t=1,i===!0&&(t|=8)):t=0,i=Ni(3,null,null,t),e.current=i,i.stateNode=e,i.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},mv(i),e}function KO(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:Bc,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function A_(e){if(!e)return sl;e=e._reactInternals;e:{if(dc(e)!==e||e.tag!==1)throw Error(je(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(Ts(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(je(171))}if(e.tag===1){var n=e.type;if(Ts(n))return AE(e,n,t)}return t}function I_(e,t,n,r,s,i,a,l,u){return e=Tv(n,r,!0,e,s,i,a,l,u),e.context=A_(null),n=e.current,r=ds(),s=Ja(n),i=ia(r,s),i.callback=t??null,Ga(n,i,s),e.current.lanes=s,ep(e,s,r),Rs(e,r),e}function Og(e,t,n,r){var s=t.current,i=ds(),a=Ja(s);return n=A_(n),t.context===null?t.context=n:t.pendingContext=n,t=ia(i,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=Ga(s,t,a),e!==null&&(Xi(e,s,a,i),Yh(e,s,a)),a}function $m(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 uS(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Rv(e,t){uS(e,t),(e=e.alternate)&&uS(e,t)}function qO(){return null}var T_=typeof reportError=="function"?reportError:function(e){console.error(e)};function Lv(e){this._internalRoot=e}Mg.prototype.render=Lv.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(je(409));Og(e,t,null,null)};Mg.prototype.unmount=Lv.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;rc(function(){Og(null,e,null,null)}),t[aa]=null}};function Mg(e){this._internalRoot=e}Mg.prototype.unstable_scheduleHydration=function(e){if(e){var t=cE();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Da.length&&t!==0&&t<Da[n].priority;n++);Da.splice(n,0,e),n===0&&dE(e)}};function Ov(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function $g(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function dS(){}function YO(e,t,n,r,s){if(s){if(typeof r=="function"){var i=r;r=function(){var d=$m(a);i.call(d)}}var a=I_(t,r,e,0,null,!1,!1,"",dS);return e._reactRootContainer=a,e[aa]=a.current,vf(e.nodeType===8?e.parentNode:e),rc(),a}for(;s=e.lastChild;)e.removeChild(s);if(typeof r=="function"){var l=r;r=function(){var d=$m(u);l.call(d)}}var u=Tv(e,0,!1,null,null,!1,!1,"",dS);return e._reactRootContainer=u,e[aa]=u.current,vf(e.nodeType===8?e.parentNode:e),rc(function(){Og(t,u,n,r)}),u}function Dg(e,t,n,r,s){var i=n._reactRootContainer;if(i){var a=i;if(typeof s=="function"){var l=s;s=function(){var u=$m(a);l.call(u)}}Og(t,a,e,s)}else a=YO(n,t,e,s,r);return $m(a)}aE=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=Dd(t.pendingLanes);n!==0&&(ev(t,n|1),Rs(t,lr()),!(Kt&6)&&(Su=lr()+500,pl()))}break;case 13:rc(function(){var r=la(e,1);if(r!==null){var s=ds();Xi(r,e,1,s)}}),Rv(e,1)}};tv=function(e){if(e.tag===13){var t=la(e,134217728);if(t!==null){var n=ds();Xi(t,e,134217728,n)}Rv(e,134217728)}};lE=function(e){if(e.tag===13){var t=Ja(e),n=la(e,t);if(n!==null){var r=ds();Xi(n,e,t,r)}Rv(e,t)}};cE=function(){return on};uE=function(e,t){var n=on;try{return on=e,t()}finally{on=n}};ow=function(e,t,n){switch(t){case"input":if(Zx(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=_g(r);if(!s)throw Error(je(90));BC(r),Zx(r,s)}}}break;case"textarea":WC(e,n);break;case"select":t=n.value,t!=null&&iu(e,!!n.multiple,t,!1)}};XC=_v;JC=rc;var GO={usingClientEntryPoint:!1,Events:[np,Kc,_g,YC,GC,_v]},jd={findFiberByHostInstance:Hl,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},XO={bundleType:jd.bundleType,version:jd.version,rendererPackageName:jd.rendererPackageName,rendererConfig:jd.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:pa.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=eE(e),e===null?null:e.stateNode},findFiberByHostInstance:jd.findFiberByHostInstance||qO,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 ph=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ph.isDisabled&&ph.supportsFiber)try{Ng=ph.inject(XO),So=ph}catch{}}ri.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=GO;ri.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ov(t))throw Error(je(200));return KO(e,t,null,n)};ri.createRoot=function(e,t){if(!Ov(e))throw Error(je(299));var n=!1,r="",s=T_;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(s=t.onRecoverableError)),t=Tv(e,1,!1,null,null,n,!1,r,s),e[aa]=t.current,vf(e.nodeType===8?e.parentNode:e),new Lv(t)};ri.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(je(188)):(e=Object.keys(e).join(","),Error(je(268,e)));return e=eE(t),e=e===null?null:e.stateNode,e};ri.flushSync=function(e){return rc(e)};ri.hydrate=function(e,t,n){if(!$g(t))throw Error(je(200));return Dg(null,e,t,!0,n)};ri.hydrateRoot=function(e,t,n){if(!Ov(e))throw Error(je(405));var r=n!=null&&n.hydratedSources||null,s=!1,i="",a=T_;if(n!=null&&(n.unstable_strictMode===!0&&(s=!0),n.identifierPrefix!==void 0&&(i=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=I_(t,null,e,1,n??null,s,!1,i,a),e[aa]=t.current,vf(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 Mg(t)};ri.render=function(e,t,n){if(!$g(t))throw Error(je(200));return Dg(null,e,t,!1,n)};ri.unmountComponentAtNode=function(e){if(!$g(e))throw Error(je(40));return e._reactRootContainer?(rc(function(){Dg(null,null,e,!1,function(){e._reactRootContainer=null,e[aa]=null})}),!0):!1};ri.unstable_batchedUpdates=_v;ri.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!$g(n))throw Error(je(200));if(e==null||e._reactInternals===void 0)throw Error(je(38));return Dg(e,t,n,!1,r)};ri.version="18.3.1-next-f1338f8080-20240426";function R_(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(R_)}catch(e){console.error(e)}}R_(),RC.exports=ri;var Or=RC.exports,fS=Or;Kx.createRoot=fS.createRoot,Kx.hydrateRoot=fS.hydrateRoot;const L_=h.createContext(null);function Fw(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function JO(){const e=Fw(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function QO({children:e}){const[t,n]=h.useState(JO);h.useEffect(()=>{const i=()=>n(Fw(window.location.pathname));return window.addEventListener("popstate",i),()=>window.removeEventListener("popstate",i)},[]);const r=h.useCallback(i=>{const a=i.startsWith("/")?i:`/${i}`;let l;try{l=new URL(a,window.location.origin)}catch{l=new URL("/",window.location.origin)}const u=Fw(l.pathname),d=l.search||"";window.history.pushState({},"",u+d),n(u)},[]),s=h.useMemo(()=>({path:t,navigate:r}),[t,r]);return o.jsx(L_.Provider,{value:s,children:e})}function Io(){const e=h.useContext(L_);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function ZO(){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 pS={};function zw(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&pS[t[0]]||(typeof t[0]=="string"&&(pS[t[0]]=new Date),ZO(...t))}const O_=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function hS(e,t,n){e.loadNamespaces(t,O_(e,n))}function mS(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,O_(e,r))}function eM(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,i=t.languages[t.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,u)=>{const d=t.services.backendConnector.state[`${l}|${u}`];return d===-1||d===2};return n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!a(t.isLanguageChangingTo,e)?!1:!!(t.hasResourceBundle(r,e)||!t.services.backendConnector.backend||t.options.resources&&!t.options.partialBundledLanguages||a(r,e)&&(!s||a(i,e)))}function tM(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(zw("i18n.languages were undefined or empty",t.languages),!0):t.options.ignoreJSONStructure!==void 0?t.hasLoadedNamespace(e,{lng:n.lng,precheck:(s,i)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&s.services.backendConnector.backend&&s.isLanguageChangingTo&&!i(s.isLanguageChangingTo,e))return!1}}):eM(e,t,n)}const nM=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,rM={"&amp;":"&","&#38;":"&","&lt;":"<","&#60;":"<","&gt;":">","&#62;":">","&apos;":"'","&#39;":"'","&quot;":'"',"&#34;":'"',"&nbsp;":" ","&#160;":" ","&copy;":"©","&#169;":"©","&reg;":"®","&#174;":"®","&hellip;":"…","&#8230;":"…","&#x2F;":"/","&#47;":"/"},sM=e=>rM[e],iM=e=>e.replace(nM,sM);let Bw={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:iM};function oM(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};Bw={...Bw,...e}}function aM(){return Bw}let M_;function lM(e){M_=e}function cM(){return M_}const uM={type:"3rdParty",init(e){oM(e.options.react),lM(e)}},dM=h.createContext();class fM{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const pM=(e,t)=>{const n=h.useRef();return h.useEffect(()=>{n.current=e},[e,t]),n.current};function Pn(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:s}=h.useContext(dM)||{},i=n||r||cM();if(i&&!i.reportNamespaces&&(i.reportNamespaces=new fM),!i){zw("You will need to pass in an i18next instance by using initReactI18next");const w=(P,_)=>typeof _=="string"?_:_&&typeof _=="object"&&typeof _.defaultValue=="string"?_.defaultValue:Array.isArray(P)?P[P.length-1]:P,j=[w,{},!1];return j.t=w,j.i18n={},j.ready=!1,j}i.options.react&&i.options.react.wait!==void 0&&zw("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...aM(),...i.options.react,...t},{useSuspense:l,keyPrefix:u}=a;let d=e||s||i.options&&i.options.defaultNS;d=typeof d=="string"?[d]:d||["translation"],i.reportNamespaces.addUsedNamespaces&&i.reportNamespaces.addUsedNamespaces(d);const f=(i.isInitialized||i.initializedStoreOnce)&&d.every(w=>tM(w,i,a));function c(){return i.getFixedT(t.lng||null,a.nsMode==="fallback"?d:d[0],u)}const[p,m]=h.useState(c);let g=d.join();t.lng&&(g=`${t.lng}${g}`);const b=pM(g),k=h.useRef(!0);h.useEffect(()=>{const{bindI18n:w,bindI18nStore:j}=a;k.current=!0,!f&&!l&&(t.lng?mS(i,t.lng,d,()=>{k.current&&m(c)}):hS(i,d,()=>{k.current&&m(c)})),f&&b&&b!==g&&k.current&&m(c);function P(){k.current&&m(c)}return w&&i&&i.on(w,P),j&&i&&i.store.on(j,P),()=>{k.current=!1,w&&i&&w.split(" ").forEach(_=>i.off(_,P)),j&&i&&j.split(" ").forEach(_=>i.store.off(_,P))}},[i,g]);const y=h.useRef(!0);h.useEffect(()=>{k.current&&!y.current&&m(c),y.current=!1},[i,u]);const v=[p,i,f];if(v.t=p,v.i18n=i,v.ready=f,f||!f&&!l)return v;throw new Promise(w=>{t.lng?mS(i,t.lng,d,()=>w()):hS(i,d,()=>w())})}const $_="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",hM=[{to:"/projects",labelKey:"common:nav.projects",icon:"folder_open"},{to:"/nodes",labelKey:"common:nav.nodes",icon:"account_tree"},{to:"/my-nodes",labelKey:"common:nav.myNodes",icon:"deployed_code"},{to:"/my-flows",labelKey:"common:nav.myFlows",icon:"schema"},{to:"/skills",labelKey:"common:nav.skills",icon:"extension"},{to:"/mcps",labelKey:"common:nav.mcps",icon:"hub"},{to:"/feedback",labelKey:"common:nav.feedback",icon:"rate_review"},{to:"/settings",labelKey:"common:nav.settings",icon:"settings"}],mM=[{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 gM(e,t){return t==="/projects"?e==="/projects"||e==="/":e===t||e.startsWith(t+"/")}function yM({authUser:e,onLogout:t}){const{path:n,navigate:r}=Io(),{t:s}=Pn(),[i,a]=h.useState(!1);return h.useEffect(()=>{let l=!1;return fetch("/api/ui-context").then(u=>u.json()).then(u=>{l||a(!!u.hideCommunityLinks)}).catch(()=>{}),()=>{l=!0}},[]),o.jsxs("aside",{className:"af-sidebar","aria-label":s("flow:sidebar.mainNav"),children:[o.jsxs("div",{className:"af-brand",children:[o.jsx("div",{className:"af-brand-mark","aria-hidden":!0,children:o.jsx("img",{src:$_,alt:"",width:"36",height:"36",decoding:"async"})}),o.jsxs("div",{children:[o.jsx("h1",{className:"af-brand-title",children:"Agentflow"}),o.jsx("p",{className:"af-brand-tag",children:"Orchestration Engine"})]})]}),o.jsx("nav",{className:"af-nav",children:hM.map(l=>o.jsxs("button",{type:"button",className:"af-nav-link"+(gM(n,l.to)?" af-nav-link--active":""),onClick:()=>r(l.to),children:[o.jsx("span",{className:"material-symbols-outlined",children:l.icon}),o.jsx("span",{children:s(l.labelKey)})]},l.to))}),o.jsxs("div",{className:"af-sidebar-footer",children:[o.jsxs("div",{className:"af-sidebar-user",title:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||"",children:[o.jsx("span",{className:"material-symbols-outlined",children:"person"}),o.jsx("span",{children:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||""}),e!=null&&e.isAdmin?o.jsx("span",{className:"af-sidebar-admin-badge",children:"Admin"}):null,o.jsx("button",{type:"button",className:"af-sidebar-logout",onClick:t,"aria-label":"Logout",title:"Logout",children:o.jsx("span",{className:"material-symbols-outlined",children:"logout"})})]}),!i&&mM.map(l=>{const u=s(l.labelKey);return o.jsx("a",{className:"af-sidebar-ext",href:l.href,target:"_blank",rel:"noopener noreferrer","aria-label":u,title:u,children:o.jsx("span",{className:"material-symbols-outlined",children:l.icon})},l.href)})]})]})}const D_="agentflow.pipelineRecent",xM=50,wM=15;function bM(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function F_(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(D_);return e?bM(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 hh(e,t){if(typeof localStorage>"u")return;const n=Date.now(),r=F_(),i=[{flowId:e,flowSource:t,kind:"opened",at:n},...r.filter(a=>!(a.flowId===e&&a.flowSource===t))].slice(0,xM);try{localStorage.setItem(D_,JSON.stringify(i))}catch{}}function vM(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 Hw(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 i=Math.floor(s/60);if(i<60)return t("flow:time.minutesAgo",{n:i});const a=Math.floor(i/60);if(a<24)return t("flow:time.hoursAgo",{n:a});const l=new Date(e),u=new Date,d=new Date(u);if(d.setDate(d.getDate()-1),l.toDateString()===d.toDateString())return t("flow:time.yesterday");const f=Math.floor(a/24);return f<7?t("flow:time.daysAgo",{n:f}):`${l.getMonth()+1}/${l.getDate()}`}function kM(e,t){if(e==null||!Number.isFinite(e)||e<=0)return"--";if(e<1e3)return t("flow:time.milliseconds",{n:Math.max(1,Math.round(e))});const n=e/1e3;return t("flow:time.seconds",{n:n>=10?Math.round(n):n.toFixed(1)})}function SM(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:vM(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,i)=>i.at-s.at),r.slice(0,wM)}var Gs=Uint8Array,Zc=Uint16Array,NM=Int32Array,z_=new Gs([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]),B_=new Gs([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]),jM=new Gs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),H_=function(e,t){for(var n=new Zc(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var s=new NM(n[30]),r=1;r<30;++r)for(var i=n[r];i<n[r+1];++i)s[i]=i-n[r]<<5|r;return{b:n,r:s}},W_=H_(z_,2),V_=W_.b,CM=W_.r;V_[28]=258,CM[258]=28;var EM=H_(B_,0),_M=EM.b,Ww=new Zc(32768);for(var Mn=0;Mn<32768;++Mn){var Pa=(Mn&43690)>>1|(Mn&21845)<<1;Pa=(Pa&52428)>>2|(Pa&13107)<<2,Pa=(Pa&61680)>>4|(Pa&3855)<<4,Ww[Mn]=((Pa&65280)>>8|(Pa&255)<<8)>>1}var nf=function(e,t,n){for(var r=e.length,s=0,i=new Zc(t);s<r;++s)e[s]&&++i[e[s]-1];var a=new Zc(t);for(s=1;s<t;++s)a[s]=a[s-1]+i[s-1]<<1;var l;if(n){l=new Zc(1<<t);var u=15-t;for(s=0;s<r;++s)if(e[s])for(var d=s<<4|e[s],f=t-e[s],c=a[e[s]-1]++<<f,p=c|(1<<f)-1;c<=p;++c)l[Ww[c]>>u]=d}else for(l=new Zc(r),s=0;s<r;++s)e[s]&&(l[s]=Ww[a[e[s]-1]++]>>15-e[s]);return l},sp=new Gs(288);for(var Mn=0;Mn<144;++Mn)sp[Mn]=8;for(var Mn=144;Mn<256;++Mn)sp[Mn]=9;for(var Mn=256;Mn<280;++Mn)sp[Mn]=7;for(var Mn=280;Mn<288;++Mn)sp[Mn]=8;var U_=new Gs(32);for(var Mn=0;Mn<32;++Mn)U_[Mn]=5;var PM=nf(sp,9,1),AM=nf(U_,5,1),Jy=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Fi=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},Qy=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},IM=function(e){return(e+7)/8|0},Mv=function(e,t,n){return(t==null||t<0)&&(t=0),(n==null||n>e.length)&&(n=e.length),new Gs(e.subarray(t,n))},TM=["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"],wi=function(e,t,n){var r=new Error(t||TM[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,wi),!n)throw r;return r},RM=function(e,t,n,r){var s=e.length,i=r?r.length:0;if(!s||t.f&&!t.l)return n||new Gs(0);var a=!n,l=a||t.i!=2,u=t.i;a&&(n=new Gs(s*3));var d=function(we){var Oe=n.length;if(we>Oe){var Ie=new Gs(Math.max(Oe*2,we));Ie.set(n),n=Ie}},f=t.f||0,c=t.p||0,p=t.b||0,m=t.l,g=t.d,b=t.m,k=t.n,y=s*8;do{if(!m){f=Fi(e,c,1);var v=Fi(e,c+1,3);if(c+=3,v)if(v==1)m=PM,g=AM,b=9,k=5;else if(v==2){var _=Fi(e,c,31)+257,L=Fi(e,c+10,15)+4,B=_+Fi(e,c+5,31)+1;c+=14;for(var D=new Gs(B),F=new Gs(19),R=0;R<L;++R)F[jM[R]]=Fi(e,c+R*3,7);c+=L*3;for(var M=Jy(F),W=(1<<M)-1,O=nf(F,M,1),R=0;R<B;){var $=O[Fi(e,c,W)];c+=$&15;var w=$>>4;if(w<16)D[R++]=w;else{var I=0,z=0;for(w==16?(z=3+Fi(e,c,3),c+=2,I=D[R-1]):w==17?(z=3+Fi(e,c,7),c+=3):w==18&&(z=11+Fi(e,c,127),c+=7);z--;)D[R++]=I}}var C=D.subarray(0,_),T=D.subarray(_);b=Jy(C),k=Jy(T),m=nf(C,b,1),g=nf(T,k,1)}else wi(1);else{var w=IM(c)+4,j=e[w-4]|e[w-3]<<8,P=w+j;if(P>s){u&&wi(0);break}l&&d(p+j),n.set(e.subarray(w,P),p),t.b=p+=j,t.p=c=P*8,t.f=f;continue}if(c>y){u&&wi(0);break}}l&&d(p+131072);for(var E=(1<<b)-1,G=(1<<k)-1,Z=c;;Z=c){var I=m[Qy(e,c)&E],V=I>>4;if(c+=I&15,c>y){u&&wi(0);break}if(I||wi(2),V<256)n[p++]=V;else if(V==256){Z=c,m=null;break}else{var se=V-254;if(V>264){var R=V-257,de=z_[R];se=Fi(e,c,(1<<de)-1)+V_[R],c+=de}var fe=g[Qy(e,c)&G],pe=fe>>4;fe||wi(3),c+=fe&15;var T=_M[pe];if(pe>3){var de=B_[pe];T+=Qy(e,c)&(1<<de)-1,c+=de}if(c>y){u&&wi(0);break}l&&d(p+131072);var ae=p+se;if(p<T){var be=i-T,_e=Math.min(T,ae);for(be+p<0&&wi(3);p<_e;++p)n[p]=r[be+p]}for(;p<ae;++p)n[p]=n[p-T]}}t.l=m,t.p=Z,t.b=p,t.f=f,m&&(f=1,t.m=b,t.d=g,t.n=k)}while(!f);return p!=n.length&&a?Mv(n,0,p):n.subarray(0,p)},LM=new Gs(0),bo=function(e,t){return e[t]|e[t+1]<<8},Ui=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},Zy=function(e,t){return Ui(e,t)+Ui(e,t+4)*4294967296};function OM(e,t){return RM(e,{i:2},t&&t.out,t&&t.dictionary)}var Vw=typeof TextDecoder<"u"&&new TextDecoder,MM=0;try{Vw.decode(LM,{stream:!0}),MM=1}catch{}var $M=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:Mv(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 DM(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(Vw)return Vw.decode(e);var s=$M(e),i=s.s,n=s.r;return n.length&&wi(8),i}}var FM=function(e,t){return t+30+bo(e,t+26)+bo(e,t+28)},zM=function(e,t,n){var r=bo(e,t+28),s=DM(e.subarray(t+46,t+46+r),!(bo(e,t+8)&2048)),i=t+46+r,a=Ui(e,t+20),l=n&&a==4294967295?BM(e,i):[a,Ui(e,t+24),Ui(e,t+42)],u=l[0],d=l[1],f=l[2];return[bo(e,t+10),u,d,s,i+bo(e,t+30)+bo(e,t+32),f]},BM=function(e,t){for(;bo(e,t)!=1;t+=4+bo(e,t+2));return[Zy(e,t+12),Zy(e,t+4),Zy(e,t+20)]};function HM(e,t){for(var n={},r=e.length-22;Ui(e,r)!=101010256;--r)(!r||e.length-r>65558)&&wi(13);var s=bo(e,r+8);if(!s)return{};var i=Ui(e,r+16),a=i==4294967295||s==65535;if(a){var l=Ui(e,r-12);a=Ui(e,l)==101075792,a&&(s=Ui(e,l+32),i=Ui(e,l+48))}for(var u=0;u<s;++u){var d=zM(e,i,a),f=d[0],c=d[1],p=d[2],m=d[3],g=d[4],b=d[5],k=FM(e,b);i=g,f?f==8?n[m]=OM(e.subarray(k,k+c),{out:new Gs(p)}):wi(14,"unknown compression type "+f):n[m]=Mv(e,k,k+c)}return n}const WM=8*1024*1024,VM=500;function UM(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 KM(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function qM(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 YM=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function GM(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=HM(t),r=new Map;let s=0,i=0;for(const[u,d]of Object.entries(n)){if(u.endsWith("/"))continue;const f=UM(u);if(!f||KM(f))continue;const c=(d==null?void 0:d.length)??0;if(s+=c,s>WM||(i+=1,i>VM))return null;r.set(f,c)}if(r.size===0)return null;const a=new Set;for(const u of r.keys()){const d=qM(u);d!==null&&a.add(d)}if(a.size!==1)return null;const[l]=[...a];if(l==="")return null;for(const u of r.keys())if(!(u===l||u.startsWith(`${l}/`)))return null;return YM.test(l)?l:null}catch{return null}}const ex=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function XM({file:e,onClose:t,onImported:n}){const{t:r}=Pn(),s=h.useId(),i=h.useRef(null),a=h.useRef(null),[l,u]=h.useState(""),[d,f]=h.useState("user"),[c,p]=h.useState(!1),[m,g]=h.useState(""),[b,k]=h.useState(null),y=b??e;h.useEffect(()=>{const P=requestAnimationFrame(()=>{var _;return(_=i.current)==null?void 0:_.focus()});return()=>cancelAnimationFrame(P)},[]),h.useEffect(()=>{let P=!1;return(async()=>{const _=y.name||"",L=_.toLowerCase();let B="";if(L.endsWith(".zip")){if(B=await GM(y)||"",!B){const D=_.replace(/\.zip$/i,"");ex.test(D)&&(B=D)}}else if(L.endsWith(".yaml")||L.endsWith(".yml")){const D=_.replace(/\.ya?ml$/i,"");ex.test(D)&&(B=D)}P||u(B)})(),()=>{P=!0}},[y]);const v=l.trim(),w=v.length>0&&ex.test(v);async function j(P){if(P.preventDefault(),!(!w||c)){p(!0),g("");try{const _=new FormData;_.set("flowId",v),_.set("targetSpace",d),_.set("file",y,y.name);const L=await fetch("/api/flows/import",{method:"POST",body:_}),B=await L.json().catch(()=>({}));if(!L.ok){g(typeof B.error=="string"?B.error:r("project:importModal.importFailed"));return}n({id:B.flowId,source:B.flowSource??"user"})}catch(_){g(String((_==null?void 0:_.message)||_))}finally{p(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:P=>{P.target===P.currentTarget&&t()},children:o.jsxs("div",{ref:i,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:P=>P.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:importModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":r("project:importModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:j,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:r("project:importModal.lead",{filename:y.name})}),o.jsx("input",{ref:a,type:"file",className:"af-import-file-input",accept:".yaml,.yml,.zip,application/zip","aria-hidden":!0,tabIndex:-1,onChange:P=>{var L;const _=(L=P.target.files)==null?void 0:L[0];_&&k(_),P.target.value=""}}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:importModal.nameLabel")}),o.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"importFlowId",autoComplete:"off",spellCheck:!1,placeholder:r("project:importModal.namePlaceholder"),value:l,onChange:P=>u(P.target.value),"aria-invalid":v.length>0&&!w}),o.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r("project:importModal.nameHint")})]}),o.jsx("div",{className:"af-import-repick",children:o.jsx("button",{type:"button",className:"af-btn-secondary af-import-repick-btn",onClick:()=>{var P;return(P=a.current)==null?void 0:P.click()},children:r("project:importModal.changeFile")})}),m?o.jsx("p",{className:"af-err af-new-pipeline-err",children:m}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:c,children:r("project:importModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!w||c,children:r(c?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const JM=/^[a-zA-Z][a-zA-Z0-9_-]*$/,gS="af:newPipelineGuide";function QM({open:e,onClose:t,onCreated:n}){const{t:r}=Pn(),s=h.useId(),i=h.useRef(null),[a,l]=h.useState(""),[u,d]=h.useState(""),[f,c]=h.useState("user"),[p,m]=h.useState(!1),[g,b]=h.useState(""),[k,y]=h.useState(!1);h.useEffect(()=>{if(!e)return;l(""),d(""),c("user"),b(""),m(!1),localStorage.getItem(gS)==="true"&&y(!0);const L=requestAnimationFrame(()=>{var B;return(B=i.current)==null?void 0:B.focus()});return()=>cancelAnimationFrame(L)},[e]);const v=()=>{localStorage.removeItem(gS),y(!1)};if(!e)return null;const w=a.trim(),j=w.length>0&&JM.test(w);async function P(_){if(_.preventDefault(),!(!j||p)){m(!0),b(""),v();try{const L=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:w,description:u.trim(),targetSpace:f})}),B=await L.json().catch(()=>({}));if(!L.ok){b(typeof B.error=="string"?B.error:r("project:newPipelineModal.createFailed"));return}n({id:B.flowId,source:B.flowSource??"user"})}catch(L){b(String((L==null?void 0:L.message)||L))}finally{m(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:_=>{_.target===_.currentTarget&&(v(),t())},children:o.jsxs("div",{ref:i,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":s,tabIndex:-1,onMouseDown:_=>_.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:s,className:"af-shortcuts-panel__title",children:r("project:newPipelineModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:()=>{v(),t()},"aria-label":r("project:newPipelineModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),k?o.jsx("div",{className:"af-new-pipeline-guide",children:o.jsxs("div",{className:"af-new-pipeline-guide-content",children:[o.jsx("span",{className:"material-symbols-outlined af-new-pipeline-guide-icon",children:"lightbulb"}),o.jsxs("div",{className:"af-new-pipeline-guide-text",children:[o.jsx("p",{children:o.jsx("strong",{children:r("onboarding:newPipeline.guideTitle")})}),o.jsx("p",{children:r("onboarding:newPipeline.guideDesc")})]}),o.jsx("button",{type:"button",className:"af-new-pipeline-guide-close",onClick:v,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})}):null,o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:P,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:r("project:newPipelineModal.lead")}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.nameLabel")}),o.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"pipelineName",autoComplete:"off",spellCheck:!1,placeholder:r("project:newPipelineModal.namePlaceholder"),value:a,onChange:_=>l(_.target.value),"aria-invalid":w.length>0&&!j}),o.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r(k?"onboarding:newPipeline.nameHintGuide":"project:newPipelineModal.nameHint")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.descLabel")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-new-pipeline-textarea",name:"pipelineDescription",rows:3,placeholder:r(k?"onboarding:newPipeline.descPlaceholderGuide":"project:newPipelineModal.descPlaceholder"),value:u,onChange:_=>d(_.target.value)}),k?o.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-guide-hint",children:r("onboarding:newPipeline.descHintGuide")}):null]}),g?o.jsx("p",{className:"af-err af-new-pipeline-err",children:g}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:()=>{v(),t()},disabled:p,children:r("project:newPipelineModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!j||p,children:r(p?"project:newPipelineModal.creating":k?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const K_="agentflow.pipelineViewPreference";function q_(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function Y_(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(K_)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function ZM(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(K_,JSON.stringify(e))}catch{}}function Dm(e){return e==="display"?"display":e==="pipeline"?"pipeline":"workspace"}function e$(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function G_(e,t,n,r=!1){if(!e)return;const s=Y_();s[q_(e,t,r)]={view:Dm(n),at:Date.now()},ZM(s)}function t$(e,t="workspace"){if(!(e!=null&&e.id))return Dm(t);const r=Y_()[q_(e.id,e.source??"user",!!e.archived)],s=Dm((r==null?void 0:r.view)||t);return s==="pipeline"&&!e$(e)?"workspace":s}function Af(e,t="workspace"){const n=Dm(t);if(!(e!=null&&e.id))return n==="pipeline"?"/flow":n==="display"?"/workspace?view=display":"/workspace";const r=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});return e.archived&&r.set(n==="pipeline"?"flowArchived":"archived","1"),n==="display"&&r.set("view","display"),`/${n==="pipeline"?"flow":"workspace"}?${r.toString()}`}function mh(e,t="workspace"){return Af(e,t$(e,t))}function n$(e,t){const n=String(e||"").split(/[.-]/).map(i=>Number.parseInt(i,10)),r=String(t||"").split(/[.-]/).map(i=>Number.parseInt(i,10)),s=Math.max(n.length,r.length);for(let i=0;i<s;i+=1){const a=Number.isFinite(n[i])?n[i]:0,l=Number.isFinite(r[i])?r[i]:0;if(a!==l)return a>l?1:-1}return 0}function Uw(e){return String((e==null?void 0:e.version)||"").trim()}function r$(e){const t=Uw(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 s$({onChanged:e}){const[t,n]=h.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[r,s]=h.useState([]),[i,a]=h.useState(""),[l,u]=h.useState("keyword"),[d,f]=h.useState([]),[c,p]=h.useState({}),[m,g]=h.useState(""),[b,k]=h.useState(""),[y,v]=h.useState(""),w=h.useCallback(async()=>{k("");try{const[D,F]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=global&agent=codex")]),R=await D.json().catch(()=>({}));D.ok&&n({available:!!R.available,version:typeof R.version=="string"?R.version:"",loggedIn:!!R.loggedIn,user:typeof R.user=="string"?R.user:"",error:typeof R.error=="string"?R.error:""});const M=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof M.error=="string"?M.error:"HTTP "+F.status);s(Array.isArray(M.skills)?M.skills:[]),p({})}catch(D){k(String(D.message||D))}},[]);h.useEffect(()=>{w()},[w]);const j=h.useCallback(async()=>{const D=i.trim();if(D){g("search"),k(""),v("");try{const F=await fetch(`/api/skillhub/search?q=${encodeURIComponent(D)}&mode=${encodeURIComponent(l)}`),R=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof R.error=="string"?R.error:"HTTP "+F.status);f(Array.isArray(R.items)?R.items:[])}catch(F){k(String(F.message||F))}finally{g("")}}},[i,l]),P=h.useCallback(async(D,F=!1)=>{const R=D&&typeof D=="object"?D:null,M=String(R?R.slug||R.name||R.collection||R.skillId||R.id:D||"").trim();if(M){g(`install:${M}`),k(""),v("");try{const W=R?{slug:R.slug||"",skillId:R.skillId||"",collection:R.collection||"",collectionName:R.collection&&R.name||"",target:"global",agent:"codex",force:F}:{slug:M,target:"global",agent:"codex",force:F},O=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W)}),$=await O.json().catch(()=>({}));if(!O.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+O.status);v(F?`已更新 ${M}`:`已安装 ${M}`),await w(),typeof e=="function"&&await e()}catch(W){k(String(W.message||W))}finally{g("")}}},[w,e]),_=h.useCallback(async()=>{if(r.length!==0){g("check-updates"),k(""),v("");try{const D=await Promise.all(r.map(async M=>{const W=String(M.name||"").trim();if(!W)return null;try{const O=await fetch(`/api/skillhub/search?q=${encodeURIComponent(W)}&mode=keyword`),$=await O.json().catch(()=>({}));if(!O.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+O.status);const I=Array.isArray($.items)?$.items:[],z=I.find(G=>G.slug===W||G.name===W||G.id===W)||I[0],C=Uw(M),T=String((z==null?void 0:z.version)||"").trim();let E="unknown";return z?C&&T?E=n$(C,T)<0?"update":"current":T&&(E="remote-only"):E="missing",[W,{state:E,latestVersion:T,installedVersion:C,summary:(z==null?void 0:z.summary)||""}]}catch(O){return[W,{state:"error",error:String(O.message||O),installedVersion:Uw(M)}]}})),F={};for(const M of D)M&&(F[M[0]]=M[1]);p(F);const R=Object.values(F).filter(M=>M.state==="update").length;v(R>0?`发现 ${R} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{g("")}}},[r]),L=h.useCallback(async D=>{const F=String(D||"").trim();if(F){g(`uninstall:${F}`),k(""),v("");try{const R=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:F,target:"global",agent:"codex"})}),M=await R.json().catch(()=>({}));if(!R.ok)throw new Error(typeof M.error=="string"?M.error:"HTTP "+R.status);v(`已卸载 ${F}`),await w(),typeof e=="function"&&await e()}catch(R){k(String(R.message||R))}finally{g("")}}},[w,e]),B=h.useCallback(async()=>{g("update-cli"),k(""),v("");try{const D=await fetch("/api/skillhub/update",{method:"POST"}),F=await D.json().catch(()=>({}));if(!D.ok)throw new Error(typeof F.error=="string"?F.error:"HTTP "+D.status);v("SkillHub CLI 已更新"),await w()}catch(D){k(String(D.message||D))}finally{g("")}},[w]);return o.jsxs("section",{className:"af-set-card af-set-card--span-all af-set-skillhub",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:"SkillHub"}),o.jsx("p",{className:"af-set-p af-set-p--tight",children:"搜索、安装、更新和卸载 Codex 全局 skills。"})]}),o.jsxs("div",{className:"af-set-skillhub-head-actions",children:[o.jsxs("div",{className:"af-set-skillhub-status",children:[o.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:"extension"}),o.jsx("span",{children:t.loggedIn?`已登录 ${t.user}`:"未登录 SkillHub"}),o.jsx("span",{className:"af-set-badge"+(t.available?" af-set-badge--ok":" af-set-badge--err"),children:t.available?`v${t.version}`:"not found"})]}),o.jsxs("div",{className:"af-set-skillhub-toolbar",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:w,disabled:!!m,children:"刷新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:_,disabled:!!m||r.length===0,children:m==="check-updates"?"检查中…":"检查更新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:B,disabled:!!m,children:m==="update-cli"?"更新中…":"更新 CLI"})]})]})]}),o.jsxs("div",{className:"af-set-skillhub-search",children:[o.jsxs("select",{className:"af-set-input af-set-input--sm af-set-skillhub-search-mode",value:l,onChange:D=>{u(D.target.value),f([])},children:[o.jsx("option",{value:"keyword",children:"关键词"}),o.jsx("option",{value:"skillId",children:"Skill ID"}),o.jsx("option",{value:"collectionId",children:"Collection ID"})]}),o.jsx("input",{className:"af-set-input af-set-input--sm",value:i,onChange:D=>a(D.target.value),onKeyDown:D=>{D.key==="Enter"&&j()},placeholder:l==="collectionId"?"输入 collection id,例如 1":l==="skillId"?"输入 skill id":"搜索 skill slug / 关键词,例如 android、issue-tracker"}),o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:()=>j(),disabled:!i.trim()||m==="search",children:[o.jsx("span",{className:"material-symbols-outlined",children:"search"}),m==="search"?"搜索中…":"搜索"]})]}),b?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:b}):null,y?o.jsx("p",{className:"af-set-hint af-set-hint--inline",children:y}):null,o.jsxs("div",{className:"af-set-skillhub-grid",children:[o.jsxs("div",{className:"af-set-skillhub-pane",children:[o.jsxs("div",{className:"af-set-skillhub-pane-head",children:[o.jsx("h3",{children:"已安装"}),o.jsx("span",{children:r.length})]}),o.jsx("div",{className:"af-set-skillhub-list",children:r.length===0?o.jsx("div",{className:"af-set-skillhub-empty",children:"暂无 Codex 全局 skills"}):r.map(D=>{const F=c[D.name],R=!F||F.state==="update"||F.state==="remote-only"||F.state==="unknown"||F.state==="error",M=m===`install:${D.name}`?"更新中…":(F==null?void 0:F.state)==="current"?"已最新":(F==null?void 0:F.state)==="update"&&F.latestVersion?`更新到 v${F.latestVersion}`:(F==null?void 0:F.state)==="remote-only"&&F.latestVersion?`安装 v${F.latestVersion}`:"重装";return o.jsxs("div",{className:"af-set-skillhub-item",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-set-skillhub-title",children:D.displayName||D.name}),o.jsx("div",{className:"af-set-skillhub-meta",children:r$(D)}),o.jsx("div",{className:"af-set-skillhub-version-row",children:F?F.state==="update"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--warn",children:["可更新 ",F.installedVersion?`v${F.installedVersion} -> `:"","v",F.latestVersion]}):F.state==="current"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--ok",children:["已最新 v",F.latestVersion||F.installedVersion]}):F.state==="remote-only"?o.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:["远端 v",F.latestVersion,",本地版本未知"]}):F.state==="missing"?o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未找到远端匹配项"}):F.state==="error"?o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--err",children:"检查失败"}):o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"状态未知"}):o.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未检查远端版本"})})]}),o.jsxs("div",{className:"af-set-skillhub-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>P(D.name,!0),disabled:!!m||!R,children:M}),o.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>L(D.name),disabled:!!m,children:"卸载"})]})]},`${D.agent}:${D.path}:${D.name}`)})})]}),o.jsxs("div",{className:"af-set-skillhub-pane",children:[o.jsxs("div",{className:"af-set-skillhub-pane-head",children:[o.jsx("h3",{children:"搜索结果"}),o.jsx("span",{children:d.length})]}),o.jsx("div",{className:"af-set-skillhub-list",children:d.length===0?o.jsx("div",{className:"af-set-skillhub-empty",children:"输入关键词后搜索 SkillHub"}):d.map(D=>{const F=D.slug||D.name,R=D.kind==="collection"||D.collection,M=!R&&r.some(W=>W.name===F||W.name===D.name);return o.jsxs("div",{className:"af-set-skillhub-item",children:[o.jsxs("div",{children:[o.jsx("div",{className:"af-set-skillhub-title",children:D.name||F}),o.jsxs("div",{className:"af-set-skillhub-meta",children:[R?`collection:${D.collection}`:F,D.skillId?` · id:${D.skillId}`:"",D.version?` · ${D.version}`:""]}),D.summary?o.jsx("p",{className:"af-set-skillhub-summary",children:D.summary}):null]}),o.jsx("button",{type:"button",className:M?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>P(D,M),disabled:!!m,children:M?"更新":R?"安装合集":"安装"})]},D.id||F)})})]})]})]})}function Za(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 i$(e){return{version:1,collections:Za({collections:e})}}function il(e,t){const n=new Set((Array.isArray(t)?t:[]).map(r=>r.key).filter(Boolean));return(Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).filter(r=>n.has(r))}function X_(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 J_(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function Q_(e,t,n){const r=il(e,n);if(r.length===0)return"empty";const s=r.filter(i=>t.has(i)).length;return s===0?"none":s===r.length?"all":"partial"}function o$(e,t,n){const r=String(e||"").trim().toLowerCase(),s=Za({collections:n}).find(i=>i.id===r||i.name.toLowerCase()===r);return il(s,t)}function Z_(e,t,n,r){const s=(Array.isArray(n)?n:[]).map(d=>d.key).filter(Boolean),i=String(t||"").trim().toLowerCase(),a=Za({collections:r}),l=o$(t,n,r),u=l.length>0?l:s;if(!e)return u;try{const d=localStorage.getItem(e);if(d!==null){const f=JSON.parse(d);if(Array.isArray(f)){const c=new Set(s),p=f.map(String).filter(y=>c.has(y));if(s.length>0&&p.length===s.length)return u;const m=new Set(p),g=new Set(l),b=l.length>0&&l.every(y=>m.has(y)),k=a.some(y=>{if(!y.builtin||y.id===i||y.name.toLowerCase()===i)return!1;const v=il(y,n);return v.length>0&&v.every(w=>m.has(w))});return l.length>0&&k&&!b?u:p}}}catch{}return u}function Cd(e){return 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 a$(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 Kw(e,t){return e==="builtin"?{label:t("project:sourceBadge.builtin"),tone:"muted"}:e==="admin"?{label:t("project:sourceBadge.builtin"),tone:"muted"}:e==="workspace"?{label:t("project:sourceBadge.workspace"),tone:"secondary"}:{label:t("project:sourceBadge.user"),tone:"primary"}}function eP(e){const t=e.source??"user";return t==="builtin"?`builtin/pipelines / ${e.id}`:t==="admin"?`admin builtin / ${e.ownerUserId||"-"} / ${e.id}`:t==="workspace"?e.archived?`.workspace/agentflow/pipelines/_archived / ${e.id}`:`.workspace/agentflow/pipelines / ${e.id}`:e.archived?`~/agentflow/pipelines/_archived / ${e.id}`:`~/agentflow/pipelines / ${e.id}`}const l$="project:defaultCardDesc";function tP(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(l$)}function c$(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function ar({children:e,className:t="",query:n}){const r=n.trim(),s=String(e);if(!r)return o.jsx("span",{className:t,children:s});const i=new RegExp(`(${c$(r)})`,"gi"),a=s.split(i);return o.jsx("span",{className:t,children:a.map((l,u)=>u%2===1?o.jsx("mark",{className:"af-search-hit",children:l},u):o.jsx("span",{children:l},u))})}function u$(e,t,n){const r=[String(e.id),tP(e,n),eP(e),Kw(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
41
- `).toLowerCase()}function d$(e,t,n){return t?u$(e,t,n).includes(t):!0}function f$(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 tx(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
42
- `).toLowerCase().includes(n):!0}function yS(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 xS(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const p$=["all","agent","control","provide","marketplace"],h$=["all","agent","control","provide"],nP="agentflow.projects.activityPanelOpen",qw="agentflow.projects.activitySelected";function m$(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(nP);return e!=="0"}function wS(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function g$(){return typeof localStorage>"u"?"":localStorage.getItem(qw)||""}function gh(e){return!e||typeof e!="object"?[]:Object.entries(e).map(([t,n])=>({key:t,...n&&typeof n=="object"?n:{}}))}function zn(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 Aa(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 sP(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 Yw(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 bS(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||Yw(e,t))}function y$(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function vS(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 x$(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 nx(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function w$(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 b$(e,t){const n=e.map(f=>f.id),r=new Set(n),s=new Map(n.map(f=>[f,0])),i=new Map(n.map(f=>[f,[]]));t.forEach(f=>{var c;!r.has(f.sourceId)||!r.has(f.targetId)||(s.set(f.targetId,(s.get(f.targetId)||0)+1),(c=i.get(f.sourceId))==null||c.push(f.targetId))});const a=new Map,l=n.filter(f=>(s.get(f)||0)===0);l.length===0&&n[0]&&l.push(n[0]),l.forEach(f=>a.set(f,0));for(let f=0;f<l.length;f+=1){const c=l[f],p=(a.get(c)||0)+1;for(const m of i.get(c)||[])(!a.has(m)||p>a.get(m))&&(a.set(m,p),l.push(m))}n.forEach((f,c)=>{a.has(f)||a.set(f,c%3)});const u=new Map,d=new Map;return n.forEach(f=>{const c=a.get(f)||0,p=u.get(c)||0;u.set(c,p+1),d.set(f,{x:c*190,y:p*86})}),d}function v$(e){var b,k,y,v;const t=rP(e),n=sP(e),r=new Map(t.map((w,j)=>[Yw(w,j),bS(w,j)])),s=t.map((w,j)=>({id:Yw(w,j),title:bS(w,j),meta:y$(w)})),i=n.map((w,j)=>{const P=vS(w,"source"),_=vS(w,"target");return{key:(w==null?void 0:w.id)||`${P}-${_}-${j}`,sourceId:P,targetId:_,source:r.get(P)||P||"?",target:r.get(_)||_||"?",label:x$(w)}}),a=(k=(b=e==null?void 0:e.snippet)==null?void 0:b.ui)!=null&&k.nodePositions&&typeof e.snippet.ui.nodePositions=="object"?e.snippet.ui.nodePositions:{},l=(v=(y=e==null?void 0:e.snippet)==null?void 0:y.ui)!=null&&v.nodeSizes&&typeof e.snippet.ui.nodeSizes=="object"?e.snippet.ui.nodeSizes:{},u=b$(s,i),d=s.map(w=>{const j=w$(a[w.id])||u.get(w.id)||{x:0,y:0},P=l[w.id]&&typeof l[w.id]=="object"?l[w.id]:{},_=Number(P.width),L=Number(P.height),B=Math.max(132,Math.min(210,Number.isFinite(_)?_*.62:150)),D=Math.max(48,Math.min(76,Number.isFinite(L)?L*.46:54));return{...w,x:j.x,y:j.y,width:B,height:D}}),f=new Map(d.map(w=>[w.id,w])),c=i.map(w=>{const j=f.get(w.sourceId),P=f.get(w.targetId);if(!j||!P)return null;const _=j.x+j.width,L=j.y+j.height/2,B=P.x,D=P.y+P.height/2,F=Math.max(48,Math.abs(B-_)*.45);return{...w,path:`M ${_} ${L} C ${_+F} ${L}, ${B-F} ${D}, ${B} ${D}`,labelX:(_+B)/2,labelY:(L+D)/2}}).filter(Boolean),p=d.reduce((w,j)=>({minX:Math.min(w.minX,j.x),minY:Math.min(w.minY,j.y),maxX:Math.max(w.maxX,j.x+j.width),maxY:Math.max(w.maxY,j.y+j.height)}),{minX:0,minY:0,maxX:420,maxY:220}),m=36,g=`${p.minX-m} ${p.minY-m} ${Math.max(360,p.maxX-p.minX+m*2)} ${Math.max(180,p.maxY-p.minY+m*2)}`;return{nodes:s,edges:i,diagram:{nodes:d,edges:c,viewBox:g}}}function Ic({resourceKind:e="",authUser:t=null}){var un,Jn,gs,Vr,ii,zs;const{t:n}=Pn(),{navigate:r,path:s}=Io(),[i,a]=h.useState(e||"all"),[l,u]=h.useState([]),[d,f]=h.useState([]),[c,p]=h.useState([]),[m,g]=h.useState([]),[b,k]=h.useState([]),[y,v]=h.useState(""),[w,j]=h.useState(!1),[P,_]=h.useState([]),[L,B]=h.useState(""),[D,F]=h.useState(""),[R,M]=h.useState(!1),[W,O]=h.useState(!1),[$,I]=h.useState(!1),[z,C]=h.useState(null),[T,E]=h.useState(!1),[G,Z]=h.useState(""),[V,se]=h.useState(m$),[de,fe]=h.useState(g$),[pe,ae]=h.useState("all"),[be,_e]=h.useState(""),[we,Oe]=h.useState("overview"),[Ie,et]=h.useState({}),[ft,Je]=h.useState(""),[bt,Ve]=h.useState({}),[jt,An]=h.useState(""),[pn,In]=h.useState(""),[en,Wn]=h.useState({}),[Tn,ce]=h.useState(""),[ve,ze]=h.useState(""),[it,ot]=h.useState(""),[Tt,tt]=h.useState(""),[an,Xt]=h.useState(""),[rr,vn]=h.useState(!1),[ln,hn]=h.useState(""),[sr,xe]=h.useState({hiddenBuiltins:[],promoted:[]}),Me=h.useRef(0),Ze=h.useRef(0),Dt=h.useRef(0),ie=h.useCallback(async()=>{var ge,Te;const K=++Ze.current;B("");try{const Re=await fetch("/api/flows");if(K!==Ze.current)return;if(!Re.ok)throw new Error("HTTP "+Re.status);const We=await Re.json();if(K!==Ze.current)return;u(Array.isArray(We)?We:[])}catch(Re){if(K!==Ze.current)return;u([]),B(String(Re.message||Re))}try{const Re=await fetch("/api/pipeline-recent-runs");if(K!==Ze.current)return;if(Re.ok){const We=await Re.json();if(K!==Ze.current)return;_(Array.isArray(We.runs)?We.runs:[])}else _([])}catch{if(K!==Ze.current)return;_([])}if(t!=null&&t.isAdmin)try{const Re=await fetch("/api/admin/builtin-flows");if(K!==Ze.current)return;const We=await Re.json().catch(()=>({}));Re.ok&&xe({hiddenBuiltins:Array.isArray((ge=We==null?void 0:We.config)==null?void 0:ge.hiddenBuiltins)?We.config.hiddenBuiltins:[],promoted:Array.isArray((Te=We==null?void 0:We.config)==null?void 0:Te.promoted)?We.config.promoted:[]})}catch{if(K!==Ze.current)return;xe({hiddenBuiltins:[],promoted:[]})}else xe({hiddenBuiltins:[],promoted:[]});M(!0)},[t==null?void 0:t.isAdmin]),Pe=h.useCallback(async(K,ge)=>{if(!(t!=null&&t.isAdmin)||!(K!=null&&K.id))return;const Te=`${ge}:${K.source}:${K.id}`;hn(Te),B("");try{const Re=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:ge,flowId:K.id,ownerUserId:K.ownerUserId||t.userId})}),We=await Re.json().catch(()=>({}));if(!Re.ok)throw new Error(We.error||"更新内置配置失败");await ie()}catch(Re){B(String(Re.message||Re))}finally{hn("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,ie]),He=h.useCallback(async()=>{const K=++Dt.current;F(""),O(!1);const ge=e==="my-nodes"?"/api/nodes?scope=owned":"/api/nodes",Te=e==="my-flows"?"/api/marketplace/flow-snippets?scope=owned":"/api/marketplace/flow-snippets";f([]),g([]),_e("");try{const[Re,We,Jt,Rt]=await Promise.all([fetch(ge),fetch("/api/skills"),fetch("/api/skill-collections"),fetch(Te)]),dn=await Re.json().catch(()=>({})),Ur=await We.json().catch(()=>({})),rs=await Jt.json().catch(()=>({})),Bs=await Rt.json().catch(()=>({}));if(!Re.ok)throw new Error(dn.error||"Nodes HTTP "+Re.status);if(!We.ok)throw new Error(Ur.error||"Skills HTTP "+We.status);if(!Jt.ok)throw new Error(rs.error||"Collections HTTP "+Jt.status);if(!Rt.ok)throw new Error(Bs.error||"Flow snippets HTTP "+Rt.status);if(K!==Dt.current)return;f(Array.isArray(dn.nodes)?dn.nodes:Array.isArray(dn)?dn:[]),p(Array.isArray(Ur.skills)?Ur.skills:[]),k(Za(rs)),g(Array.isArray(Bs.snippets)?Bs.snippets:[])}catch(Re){if(K!==Dt.current)return;f([]),p([]),g([]),k([]),F(String(Re.message||Re))}finally{if(K!==Dt.current)return;O(!0)}},[e]);h.useEffect(()=>{M(!1),ie(),He()},[ie,He]),h.useEffect(()=>{try{localStorage.setItem(nP,V?"1":"0")}catch{}},[V]),h.useEffect(()=>{try{de?localStorage.setItem(qw,de):localStorage.removeItem(qw)}catch{}},[de]),h.useEffect(()=>{let K=!1;return fetch("/api/ui-context").then(ge=>ge.json()).then(ge=>{K||vn(!!ge.hideCommunityLinks)}).catch(()=>{}),()=>{K=!0}},[]);const Ft=h.useCallback(async K=>{const ge=Za({collections:K});j(!0),F("");try{const Te=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i$(ge))}),Re=await Te.json().catch(()=>({}));if(!Te.ok)throw new Error(Re.error||"Collections HTTP "+Te.status);k(Za(Re))}catch(Te){F(String(Te.message||Te))}finally{j(!1)}},[]),cn=h.useCallback(()=>{const K=y.trim();if(!K)return;const ge=K.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",Te=new Set(b.map(Rt=>Rt.id));let Re=ge,We=2;for(;Te.has(Re);)Re=`${ge}-${We++}`;const Jt=Date.now();Ft([...b,{id:Re,name:K,skillKeys:[],createdAt:Jt,updatedAt:Jt}]),v(""),ae(`collection:${Re}`)},[y,Ft,b]),ir=h.useCallback(K=>{const ge=b.find(Re=>Re.id===K);if(ge!=null&&ge.builtin)return;const Te=b.filter(Re=>Re.id!==K);pe===`collection:${K}`&&ae("all"),Ft(Te)},[pe,Ft,b]),Ds=h.useCallback((K,ge,Te)=>{const Re=String(ge||"").trim();if(!Re)return;const We=Date.now(),Jt=b.map(Rt=>{if(Rt.id!==K)return Rt;const dn=new Set(Rt.skillKeys||[]);return Te?dn.add(Re):dn.delete(Re),{...Rt,skillKeys:Array.from(dn),updatedAt:We}});Ft(Jt)},[Ft,b]),ns=h.useCallback(async K=>{const ge=K==null?void 0:K.packageId,Te=K==null?void 0:K.version;if(!ge||!Te||!window.confirm(n("project:deleteMyNodeConfirm",{id:ge,version:Te})))return;const Re=zn(K);ze(Re),ot(""),F("");try{const We=new URLSearchParams({id:ge,version:Te}),Jt=await fetch(`/api/marketplace/node?${We.toString()}`,{method:"DELETE"}),Rt=await Jt.json().catch(()=>({}));if(!Jt.ok||(Rt==null?void 0:Rt.ok)===!1){const dn=Array.isArray(Rt==null?void 0:Rt.usage)&&Rt.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:Rt.usage.length})}`:"";throw new Error(((Rt==null?void 0:Rt.error)||"Delete failed")+dn)}ot(n("project:deleteMyNodeSuccess",{id:ge,version:Te})),Ve(dn=>{const Ur={...dn};return delete Ur[Re],Ur}),Wn(dn=>{const Ur={};for(const[rs,Bs]of Object.entries(dn))rs.startsWith(`${Re}:`)||(Ur[rs]=Bs);return Ur}),_e(""),await He()}catch(We){ot(String(We.message||We))}finally{ze("")}},[He,n]),cr=h.useCallback(async K=>{const ge=K==null?void 0:K.id,Te=(K==null?void 0:K.version)||"1.0.0";if(!ge||!Te||!window.confirm(n("project:deleteMyFlowConfirm",{id:ge,version:Te})))return;const Re=Aa(K);tt(Re),Xt(""),F("");try{const We=new URLSearchParams({id:ge,version:Te}),Jt=await fetch(`/api/marketplace/flow-snippet?${We.toString()}`,{method:"DELETE"}),Rt=await Jt.json().catch(()=>({}));if(!Jt.ok||(Rt==null?void 0:Rt.ok)===!1)throw new Error((Rt==null?void 0:Rt.error)||"Delete failed");Xt(n("project:deleteMyFlowSuccess",{id:ge,version:Te})),_e(""),await He()}catch(We){Xt(String(We.message||We))}finally{tt("")}},[He,n]);h.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){a(e),ae("all"),_e(""),Oe("overview");return}a(K=>K==="archived"?"archived":"all")},[e]),h.useEffect(()=>{if(s!=="/projects"&&s!=="/")return;const K=new URLSearchParams(window.location.search);let ge=!1;if(K.get("tab")==="nodes"){r("/nodes");return}if(K.get("tab")==="my-nodes"){r("/my-nodes");return}if(K.get("tab")==="my-flows"){r("/my-flows");return}if(K.get("tab")==="skills"){r("/skills");return}if(K.get("tab")==="archived"&&(a("archived"),K.delete("tab"),ge=!0),K.get("new")==="1"&&(I(!0),K.delete("new"),ge=!0),ge){const Te=K.toString();window.history.replaceState({},"",Te?`/projects?${Te}`:"/projects")}},[s,r]);const Xn=h.useMemo(()=>SM(P,F_(),l),[P,l,s]),zr=h.useMemo(()=>Xn.filter(K=>f$(G,K)),[Xn,G]),st=G.trim().toLowerCase(),Br=h.useMemo(()=>i==="archived"?l.filter(K=>K.archived):l.filter(K=>!K.archived),[l,i]),_i=h.useMemo(()=>Br.filter(K=>d$(K,st,n)),[Br,st,n]),ga=h.useMemo(()=>new Set((sr.promoted||[]).map(K=>String((K==null?void 0:K.id)||"").trim()).filter(Boolean)),[sr.promoted]),hs=h.useMemo(()=>(sr.hiddenBuiltins||[]).map(K=>String(K||"").trim()).filter(Boolean),[sr.hiddenBuiltins]),Ee=i==="nodes"||i==="my-nodes",tn=i==="my-nodes",ur=i==="my-flows",pt=h.useMemo(()=>d.filter(K=>tn&&K.source!=="marketplace"?!1:(pe==="all"||(pe==="marketplace"?K.source==="marketplace":K.type===pe))&&tx(G,[K.id,K.label,K.displayName,K.description,K.type,K.source,K.packageId,K.version])),[d,tn,G,pe]),Le=h.useMemo(()=>{const K=new Map;for(const ge of b)K.set(ge.id,new Set(ge.skillKeys||[]));return K},[b]),Hr=h.useMemo(()=>[{id:"all",label:"全部"},...b.map(K=>({id:`collection:${K.id}`,label:K.name,count:K.skillKeys.length,collection:K})),{id:"ungrouped",label:"未分组"}],[b]),Vn=h.useMemo(()=>c.filter(K=>{var Re;const ge=zn(K);let Te=pe==="all";if(pe.startsWith("collection:")){const We=pe.slice(11);Te=!!((Re=Le.get(We))!=null&&Re.has(ge))}else pe==="ungrouped"&&(Te=!Array.from(Le.values()).some(We=>We.has(ge)));return Te&&tx(G,[K.name,K.id,K.description,K.sourceLabel,K.source,K.path])}),[c,G,pe,Le]),Wr=h.useMemo(()=>m.filter(K=>tx(G,[K.id,K.name,K.displayName,K.description,K.version,K.packageDir,Array.isArray(K.tags)?K.tags.join(" "):""])),[m,G]),kr=Ee||ur||i==="skills",ct=h.useMemo(()=>pt.find(K=>zn(K)===be)||pt[0]||null,[pt,be]),Wt=h.useMemo(()=>Vn.find(K=>zn(K)===be)||Vn[0]||null,[Vn,be]),nn=h.useMemo(()=>Wr.find(K=>Aa(K)===be)||Wr[0]||null,[Wr,be]),Sr=Wt?Ie[zn(Wt)]:null,Qe=ct?bt[zn(ct)]:null,dr=ct&&pn?en[`${zn(ct)}:${pn}`]:null,Fs=n(Ee?"project:searchNodes":ur?"project:searchFlows":i==="skills"?"project:searchSkills":"project:searchPipelines");h.useEffect(()=>{if(i!=="skills"||!Wt)return;const K=zn(Wt);if(Ie[K])return;let ge=!1;return Je(K),fetch(`/api/skills/detail?key=${encodeURIComponent(K)}`).then(Te=>Te.json().then(Re=>({ok:Te.ok,json:Re}))).then(({ok:Te,json:Re})=>{ge||Te&&Re.skill&&et(We=>({...We,[K]:Re.skill}))}).catch(()=>{}).finally(()=>{ge||Je("")}),()=>{ge=!0}},[i,Wt,Ie]),h.useEffect(()=>{if(!Ee||!ct)return;const K=zn(ct);if(bt[K])return;let ge=!1;return An(K),fetch(`/api/nodes/detail?id=${encodeURIComponent(ct.id)}`).then(Te=>Te.json().then(Re=>({ok:Te.ok,json:Re}))).then(({ok:Te,json:Re})=>{ge||Te&&Ve(We=>({...We,[K]:Re}))}).catch(()=>{}).finally(()=>{ge||An("")}),()=>{ge=!0}},[Ee,ct,bt]),h.useEffect(()=>{if(!Ee)return;const K=Array.isArray(Qe==null?void 0:Qe.files)?Qe.files:[];In(ge=>{var Te;return ge&&K.some(Re=>Re.path===ge)?ge:((Te=K[0])==null?void 0:Te.path)||""})},[Ee,Qe]),h.useEffect(()=>{if(!Ee||!ct||!pn)return;const K=`${zn(ct)}:${pn}`;if(en[K])return;let ge=!1;return ce(K),fetch(`/api/nodes/file?id=${encodeURIComponent(ct.id)}&path=${encodeURIComponent(pn)}`).then(Te=>Te.json().then(Re=>({ok:Te.ok,json:Re}))).then(({ok:Te,json:Re})=>{ge||Te&&Wn(We=>({...We,[K]:Re}))}).catch(()=>{}).finally(()=>{ge||ce("")}),()=>{ge=!0}},[Ee,ct,pn,en]),h.useEffect(()=>{ot("")},[be,i]);const ya=K=>{r(mh(K,"workspace"))},ms=K=>{fe(wS(K)),r(mh({id:K.flowId,source:K.flowSource,archived:!!K.archived},"workspace"))},Lo=h.useCallback(K=>{var ge,Te;K.preventDefault(),K.stopPropagation(),(Te=(ge=K.dataTransfer)==null?void 0:ge.types)!=null&&Te.includes("Files")&&(Me.current+=1,E(!0))},[]),yr=h.useCallback(K=>{K.preventDefault(),K.stopPropagation(),Me.current-=1,Me.current<=0&&(Me.current=0,E(!1))},[]),Oo=h.useCallback(K=>{K.preventDefault(),K.stopPropagation()},[]),Pi=h.useCallback(K=>{var Re,We;K.preventDefault(),K.stopPropagation(),Me.current=0,E(!1);const ge=(We=(Re=K.dataTransfer)==null?void 0:Re.files)==null?void 0:We[0];if(!ge)return;const Te=ge.name.toLowerCase();!Te.endsWith(".yaml")&&!Te.endsWith(".yml")&&!Te.endsWith(".zip")||C(ge)},[]);return o.jsxs("div",{className:"af-projects"+(T?" af-projects--drop-target":""),onDragEnter:Lo,onDragLeave:yr,onDragOver:Oo,onDrop:Pi,children:[o.jsxs("header",{className:"af-projects-top",children:[e?o.jsx("div",{className:"af-projects-tabs af-projects-tabs--empty","aria-hidden":!0}):o.jsxs("div",{className:"af-projects-tabs",children:[o.jsx("button",{type:"button",className:i==="all"?"af-tab af-tab--active":"af-tab",onClick:()=>a("all"),children:n("project:all")}),o.jsx("button",{type:"button",className:i==="archived"?"af-tab af-tab--active":"af-tab",onClick:()=>a("archived"),children:n("project:archived")})]}),o.jsxs("div",{className:"af-projects-top-right",children:[o.jsxs("div",{className:"af-search-wrap",children:[o.jsx("span",{className:"material-symbols-outlined af-search-icon",children:"search"}),o.jsx("input",{className:"af-search"+(G.trim()?" af-search--has-clear":""),type:"search",placeholder:Fs,"aria-label":Fs,autoComplete:"off",value:G,onChange:K=>Z(K.target.value),onKeyDown:K=>{K.key==="Escape"&&(Z(""),K.currentTarget.blur())}}),G.trim()?o.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>Z(""),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),kr?o.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>He(),children:n("project:refreshResources")}):o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-icon-btn"+(V?" af-icon-btn--active":""),"aria-label":n("flow:palette.toggleRecentActivity"),"aria-expanded":V,"aria-controls":"af-recent-activity-panel",onClick:()=>se(K=>!K),children:o.jsx("span",{className:"material-symbols-outlined",children:"notifications"})}),o.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>I(!0),children:n("project:createNew")})]})]})]}),o.jsxs("div",{className:"af-projects-body",children:[o.jsxs("section",{className:"af-projects-main",children:[o.jsxs("header",{className:"af-projects-section-head",children:[o.jsx("h2",{className:"af-projects-h2",children:n(i==="my-nodes"?"project:myNodes":i==="my-flows"?"project:myFlows":i==="nodes"?"project:globalNodes":i==="skills"?"project:globalSkills":i==="archived"?"project:archivedPipelines":"project:activeProjects")}),o.jsx("p",{className:"af-projects-sub",children:st?n("project:filterResult",{count:i==="nodes"||i==="my-nodes"?pt.length:i==="my-flows"?Wr.length:i==="skills"?Vn.length:_i.length}):i==="my-nodes"?n("project:myNodesHint",{count:pt.length}):i==="my-flows"?n("project:myFlowsHint",{count:Wr.length}):i==="nodes"?n("project:nodesHint",{count:d.length}):i==="skills"?n("project:skillsHint",{count:c.length}):n(i==="archived"?"project:archivedHint":"project:activeHint")}),L?o.jsx("p",{className:"af-err af-projects-api-hint",children:L}):null,D&&kr?o.jsx("p",{className:"af-err af-projects-api-hint",children:D}):null]}),kr?o.jsxs("div",{className:"af-resource-toolbar",children:[i==="skills"?o.jsx(s$,{onChanged:He}):null,o.jsxs("div",{className:"af-resource-purpose",children:[o.jsx("span",{className:"material-symbols-outlined",children:ur?"schema":Ee?tn?"deployed_code":"account_tree":"extension"}),o.jsxs("div",{children:[o.jsx("h3",{children:n(ur?"project:myFlowsPurposeTitle":tn?"project:myNodesPurposeTitle":Ee?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),o.jsx("p",{children:n(ur?"project:myFlowsPurposeDesc":tn?"project:myNodesPurposeDesc":Ee?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),ur?null:o.jsx("div",{className:"af-resource-filter-row",children:(Ee?(tn?h$:p$).map(K=>({id:K,label:n(`project:resourceFilter.${K}`)})):Hr).map(K=>K.collection?o.jsxs("span",{className:"af-resource-filter-chip"+(pe===K.id?" af-resource-filter-chip--active":""),children:[o.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{ae(K.id),_e("")},children:[K.label,o.jsx("em",{children:K.count}),K.collection.builtin?o.jsx("strong",{children:"built-in"}):null]}),K.collection.builtin?null:o.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:w,"aria-label":`删除 ${K.collection.name}`,onClick:()=>ir(K.collection.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},K.id):o.jsx("button",{type:"button",className:"af-resource-filter"+(pe===K.id?" af-resource-filter--active":""),onClick:()=>{ae(K.id),_e("")},children:K.label},K.id))}),i==="skills"?o.jsx("div",{className:"af-skill-collections-manager",children:o.jsxs("div",{className:"af-skill-collections-create",children:[o.jsx("input",{className:"af-set-input af-set-input--sm",value:y,onChange:K=>v(K.target.value),onKeyDown:K=>{K.key==="Enter"&&cn()},placeholder:"新建 skill collection"}),o.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!y.trim()||w,onClick:()=>cn(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,Ee?o.jsx("div",{className:"af-resource-grid",children:pt.length>0?pt.map(K=>o.jsxs("button",{type:"button",className:"af-resource-card"+(ct&&zn(K)===zn(ct)?" af-resource-card--active":""),onClick:()=>_e(zn(K)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:Cd(K.type==="control"?"secondary":K.type==="provide"?"primary":"muted"),children:o.jsx(ar,{query:G,children:K.type||"node"})}),o.jsx("span",{className:"af-resource-source",children:o.jsx(ar,{query:G,children:yS(K.source,n)})})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(ar,{query:G,children:K.label||K.displayName||K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(ar,{query:G,children:K.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:o.jsx(ar,{query:G,children:K.id})}),o.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(K.inputs||{}).length,outputs:Object.keys(K.outputs||{}).length})})]}),K.packageId?o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"deployed_code"}),o.jsx("span",{className:"af-path-text",children:o.jsx(ar,{query:G,children:`${K.packageId}${K.version?` / ${K.version}`:""}`})})]}):null]},`${K.id}:${K.source||""}:${K.packageId||""}`)):W?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:st?n("project:noNodeMatch",{query:G.trim()}):n(tn?"project:noMyNodes":"project:noNodes")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):ur?o.jsx("div",{className:"af-resource-grid",children:Wr.length>0?Wr.map(K=>{const ge=rP(K),Te=sP(K),Re=Number.isFinite(Number(K.nodeCount))?Number(K.nodeCount):ge.length,We=Number.isFinite(Number(K.edgeCount))?Number(K.edgeCount):Te.length;return o.jsxs("button",{type:"button",className:"af-resource-card"+(nn&&Aa(K)===Aa(nn)?" af-resource-card--active":""),onClick:()=>_e(Aa(K)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:Cd("primary"),children:o.jsx(ar,{query:G,children:K.version?`v${K.version}`:"flow"})}),o.jsx("span",{className:"af-resource-source",children:n("project:flowSnippet")})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(ar,{query:G,children:K.displayName||K.name||K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(ar,{query:G,children:K.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-resource-meta-row",children:[o.jsx("span",{children:n("project:flowSnippetNodes",{nodes:Re,edges:We})}),o.jsx("span",{children:o.jsx(ar,{query:G,children:K.id})})]}),o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"schema"}),o.jsx("span",{className:"af-path-text",children:o.jsx(ar,{query:G,children:xS(K)})})]})]},Aa(K))}):W?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:st?n("project:noFlowSnippetMatch",{query:G.trim()}):n("project:noMyFlows")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):i==="skills"?o.jsx("div",{className:"af-resource-grid",children:Vn.length>0?Vn.map(K=>o.jsxs("button",{type:"button",className:"af-resource-card"+(Wt&&zn(K)===zn(Wt)?" af-resource-card--active":""),onClick:()=>_e(zn(K)),children:[o.jsxs("div",{className:"af-resource-card-head",children:[o.jsx("span",{className:Cd(K.source==="builtin"?"muted":"primary"),children:o.jsx(ar,{query:G,children:K.sourceLabel||K.source||"skill"})}),o.jsx("span",{className:"af-resource-source",children:n("project:skill")})]}),o.jsx("h3",{className:"af-project-title",children:o.jsx(ar,{query:G,children:K.name||K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(ar,{query:G,children:K.description||n("project:noDescription")})}),o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"extension"}),o.jsx("span",{className:"af-path-text",children:o.jsx(ar,{query:G,children:K.path||K.key||""})})]}),o.jsxs("div",{className:"af-skill-card-collections",children:[b.filter(ge=>ge.skillKeys.includes(zn(K))).slice(0,3).map(ge=>o.jsx("span",{children:ge.name},ge.id)),b.filter(ge=>ge.skillKeys.includes(zn(K))).length===0?o.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},K.key||`${K.source}:${K.name}`)):W?o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:st?n("project:noSkillMatch",{query:G.trim()}):n("project:noSkills")})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):o.jsxs(o.Fragment,{children:[t!=null&&t.isAdmin&&i==="all"&&hs.length>0?o.jsxs("div",{className:"af-project-admin-panel",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"已隐藏内置"}),o.jsx("span",{children:"这些包内置流水线不会出现在普通项目列表中。"})]}),o.jsx("div",{className:"af-project-admin-hidden-list",children:hs.map(K=>{const ge=ln===`show-builtin:builtin:${K}`;return o.jsxs("button",{type:"button",disabled:ge,onClick:()=>Pe({id:K,source:"builtin"},"show-builtin"),children:[o.jsx("span",{children:K}),o.jsx("em",{children:ge?"恢复中":"恢复"})]},K)})})]}):null,o.jsxs("div",{className:"af-project-grid",children:[_i.length>0?_i.map(K=>{const ge=(t==null?void 0:t.isAdmin)&&K.source==="user"&&!K.archived&&!ga.has(K.id),Te=(t==null?void 0:t.isAdmin)&&K.source==="admin",Re=(t==null?void 0:t.isAdmin)&&K.source==="builtin",We=ln.endsWith(`:${K.source}:${K.id}`);return o.jsx("div",{className:"af-project-card",role:"button",tabIndex:0,onClick:()=>ya(K),onKeyDown:Jt=>{(Jt.key==="Enter"||Jt.key===" ")&&(Jt.preventDefault(),ya(K))},children:o.jsxs("div",{className:"af-project-card-body",children:[o.jsx("span",{className:Cd(Kw(K.source,n).tone),children:o.jsx(ar,{query:G,children:Kw(K.source,n).label})}),K.archived?o.jsx("span",{className:Cd("muted"),children:o.jsx(ar,{query:G,children:n("project:archived")})}):null,o.jsx("h3",{className:"af-project-title",children:o.jsx(ar,{query:G,children:K.id})}),o.jsx("p",{className:"af-project-desc",children:o.jsx(ar,{query:G,children:tP(K,n)})}),o.jsxs("div",{className:"af-project-path",children:[o.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"database"}),o.jsx("span",{className:"af-path-text",children:o.jsx(ar,{query:G,children:eP(K)})})]}),t!=null&&t.isAdmin?o.jsxs("div",{className:"af-project-admin-actions",onClick:Jt=>Jt.stopPropagation(),onKeyDown:Jt=>Jt.stopPropagation(),children:[ge?o.jsx("button",{type:"button",disabled:We,onClick:()=>Pe(K,"promote"),children:"设为内置"}):null,Te?o.jsx("button",{type:"button",disabled:We,onClick:()=>Pe(K,"unpromote"),children:"取消内置"}):null,Re?o.jsx("button",{type:"button",disabled:We,onClick:()=>Pe(K,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${K.id}:${K.source??"user"}:${K.archived?"a":""}`)}):R?Br.length===0?o.jsxs("div",{className:"af-projects-empty-block",children:[o.jsx("p",{className:"af-projects-empty",children:i==="archived"?n("project:noArchived"):l.length>0?n("project:noActive"):n(L?"project:loadFailed":"project:noPipelines")}),!L&&l.length===0&&i==="all"?o.jsx("p",{className:"af-projects-empty-hint",children:n("project:emptyHint",{code1:"agentflow ui",code2:".agentflow/pipelines"})}):null]}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:noMatch",{query:G.trim()})})}):o.jsx("div",{className:"af-projects-empty-block",children:o.jsx("p",{className:"af-projects-empty",children:n("project:loadingPipelines")})}),o.jsxs("button",{type:"button",className:"af-project-add",onClick:()=>I(!0),children:[o.jsx("span",{className:"material-symbols-outlined af-project-add-icon",children:"add_circle"}),o.jsx("span",{className:"af-project-add-label",children:n("project:newPipeline")})]}),rr?null:o.jsxs("a",{className:"af-hub-card",href:"https://agentflow-hub.com",target:"_blank",rel:"noopener noreferrer",children:[o.jsx("div",{className:"af-hub-card__glow","aria-hidden":!0}),o.jsxs("span",{className:"af-hub-card__eyebrow",children:[o.jsx("span",{className:"material-symbols-outlined af-hub-card__eyebrow-icon",children:"hub"}),n("project:hubCard.eyebrow")]}),o.jsx("h3",{className:"af-hub-card__title",children:n("project:hubCard.title")}),o.jsx("p",{className:"af-hub-card__desc",children:n("project:hubCard.desc")}),o.jsxs("span",{className:"af-hub-card__cta",children:[n("project:hubCard.cta"),o.jsx("span",{className:"material-symbols-outlined af-hub-card__cta-icon",children:"arrow_outward"})]}),o.jsx("code",{className:"af-hub-card__cli",children:n("project:hubCard.cliHint")})]})]})]})]}),kr?o.jsx("aside",{className:"af-resource-detail","aria-label":n(Ee?"project:nodeDetail":ur?"project:flowDetail":"project:skillDetail"),children:Ee&&ct?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-resource-detail-head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),o.jsxs("div",{children:[o.jsx("h3",{children:ct.label||ct.displayName||ct.id}),o.jsx("p",{children:ct.id})]})]}),o.jsx("div",{className:"af-resource-detail-tabs",children:["overview","schema","runtime","files","usage"].map(K=>o.jsx("button",{type:"button",className:"af-resource-detail-tab"+(we===K?" af-resource-detail-tab--active":""),onClick:()=>Oe(K),children:n(`project:nodeDetailTabs.${K}`)},K))}),jt===zn(ct)?o.jsx("p",{className:"af-resource-detail-desc",children:n("project:loadingResources")}):we==="overview"?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"af-resource-detail-desc",children:ct.description||((un=Qe==null?void 0:Qe.node)==null?void 0:un.description)||n("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailType")}),o.jsx("dd",{children:ct.type||((Jn=Qe==null?void 0:Qe.node)==null?void 0:Jn.type)||"node"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailSource")}),o.jsx("dd",{children:yS(ct.source,n)})]}),ct.packageId?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPackage")}),o.jsx("dd",{children:ct.packageId})]}):null,ct.version?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailVersion")}),o.jsx("dd",{children:ct.version})]}):null,ct.packageDir||Qe!=null&&Qe.baseDir?o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:ct.packageDir||(Qe==null?void 0:Qe.baseDir)})]}):null,o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailEditable")}),o.jsx("dd",{children:(Qe==null?void 0:Qe.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),tn&&ct.source==="marketplace"?o.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[o.jsx("h4",{children:n("project:myNodeManagement")}),o.jsx("p",{children:n("project:deleteMyNodeHint")}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:ve===zn(ct),onClick:()=>ns(ct),children:[o.jsx("span",{className:"material-symbols-outlined",children:"delete"}),ve===zn(ct)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),it?o.jsx("p",{className:"af-resource-action-message",children:it}):null]}):null,o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:resourceMeaning")}),o.jsx("p",{children:n("project:nodesMeaning")})]})]}):we==="schema"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeSchema")}),o.jsxs("div",{className:"af-resource-slot-group",children:[o.jsx("span",{children:n("project:nodeInputs")}),gh(((gs=Qe==null?void 0:Qe.node)==null?void 0:gs.inputs)||ct.inputs).length>0?gh(((Vr=Qe==null?void 0:Qe.node)==null?void 0:Vr.inputs)||ct.inputs).map(K=>o.jsxs("code",{children:[K.name||K.key,K.type?`: ${K.type}`:""]},K.key)):o.jsx("em",{children:n("project:noSlots")})]}),o.jsxs("div",{className:"af-resource-slot-group",children:[o.jsx("span",{children:n("project:nodeOutputs")}),gh(((ii=Qe==null?void 0:Qe.node)==null?void 0:ii.outputs)||ct.outputs).length>0?gh(((zs=Qe==null?void 0:Qe.node)==null?void 0:zs.outputs)||ct.outputs).map(K=>o.jsxs("code",{children:[K.name||K.key,K.type?`: ${K.type}`:""]},K.key)):o.jsx("em",{children:n("project:noSlots")})]})]}):we==="runtime"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeRuntime")}),Qe!=null&&Qe.runtime?o.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(Qe.runtime,null,2)}):o.jsx("p",{children:n("project:noRuntimeManifest")}),Qe!=null&&Qe.body?o.jsxs(o.Fragment,{children:[o.jsx("h4",{className:"af-resource-detail-subtitle",children:n("project:nodeBody")}),o.jsx("pre",{className:"af-resource-skill-preview",children:Qe.body})]}):o.jsx("p",{children:n("project:noNodeBody")})]}):we==="files"?o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeFiles")}),Array.isArray(Qe==null?void 0:Qe.files)&&Qe.files.length>0?o.jsxs("div",{className:"af-node-file-browser",children:[o.jsx("div",{className:"af-node-file-list",children:Qe.files.map(K=>o.jsxs("button",{type:"button",className:"af-node-file-item"+(pn===K.path?" af-node-file-item--active":""),onClick:()=>In(K.path),children:[o.jsx("span",{className:"material-symbols-outlined",children:"description"}),o.jsx("span",{children:K.path})]},K.path))}),o.jsxs("pre",{className:"af-resource-skill-preview",children:[Tn===`${zn(ct)}:${pn}`?n("project:loadingResources"):dr!=null&&dr.binary?n("project:binaryFile"):(dr==null?void 0:dr.content)||n("project:selectNodeFile"),dr!=null&&dr.truncated?`
43
-
44
- ${n("project:fileTruncated")}`:""]})]}):o.jsx("p",{children:n("project:noNodeFiles")})]}):o.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[o.jsx("h4",{children:n("project:nodeUsage")}),Array.isArray(Qe==null?void 0:Qe.usage)&&Qe.usage.length>0?o.jsx("div",{className:"af-node-usage-list",children:Qe.usage.map(K=>o.jsxs("div",{className:"af-node-usage-item",children:[o.jsx("strong",{children:K.flowId}),o.jsxs("span",{children:[K.flowSource,K.archived?` · ${n("project:archived")}`:""]}),o.jsx("em",{children:K.instances.map(ge=>ge.label||ge.instanceId).join(", ")})]},`${K.flowSource}:${K.flowId}:${K.archived?"a":""}`))}):o.jsx("p",{children:n("project:noNodeUsage")})]})]}):ur&&nn?(()=>{const K=v$(nn);return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-resource-detail-head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"schema"}),o.jsxs("div",{children:[o.jsx("h3",{children:nn.displayName||nn.name||nn.id}),o.jsx("p",{children:nn.id})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:nn.description||n("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailVersion")}),o.jsx("dd",{children:nn.version||"1.0.0"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:xS(nn)})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:flowSnippetScale")}),o.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(nn.nodeCount))?Number(nn.nodeCount):K.nodes.length,edges:Number.isFinite(Number(nn.edgeCount))?Number(nn.edgeCount):K.edges.length})})]})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:resourceMeaning")}),o.jsx("p",{children:n("project:myFlowsMeaning")})]}),o.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[o.jsx("h4",{children:n("project:myFlowManagement")}),o.jsx("p",{children:n("project:deleteMyFlowHint")}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:Tt===Aa(nn),onClick:()=>cr(nn),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),Tt===Aa(nn)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),an?o.jsx("p",{className:"af-resource-action-message",children:an}):null]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:flowSnippetPreview")}),K.diagram.nodes.length>0?o.jsx("div",{className:"af-flow-snippet-map",children:o.jsxs("svg",{viewBox:K.diagram.viewBox,role:"img","aria-label":n("project:flowSnippetPreview"),children:[o.jsx("defs",{children:o.jsx("marker",{id:"af-flow-snippet-arrow",markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:o.jsx("path",{d:"M 0 0 L 8 4 L 0 8 z"})})}),o.jsx("g",{className:"af-flow-snippet-map__edges",children:K.diagram.edges.map(ge=>o.jsxs("g",{children:[o.jsx("path",{d:ge.path}),ge.label?o.jsx("text",{x:ge.labelX,y:ge.labelY-5,textAnchor:"middle",children:nx(ge.label,18)}):null]},ge.key))}),o.jsx("g",{className:"af-flow-snippet-map__nodes",children:K.diagram.nodes.map((ge,Te)=>o.jsxs("g",{transform:`translate(${ge.x} ${ge.y})`,children:[o.jsx("rect",{width:ge.width,height:ge.height,rx:"10"}),o.jsx("circle",{cx:"19",cy:ge.height/2,r:"12"}),o.jsx("text",{className:"af-flow-snippet-map__node-index",x:"19",y:ge.height/2+4,textAnchor:"middle",children:Te+1}),o.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:ge.height/2-3,children:nx(ge.title)}),o.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:ge.height/2+16,children:nx(ge.meta||ge.id,20)})]},ge.id))})]})}):o.jsx("p",{className:"af-resource-detail-desc",children:n("project:noFlowSnippetPreview")}),o.jsxs("details",{className:"af-flow-snippet-json",children:[o.jsx("summary",{children:n("project:flowSnippetJson")}),o.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(nn.snippet||{},null,2)})]})]})]})})():i==="skills"&&Wt?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-resource-detail-head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"extension"}),o.jsxs("div",{children:[o.jsx("h3",{children:Wt.name||Wt.id}),o.jsx("p",{children:Wt.sourceLabel||Wt.source})]})]}),o.jsx("p",{className:"af-resource-detail-desc",children:Wt.description||n("project:noDescription")}),o.jsxs("dl",{className:"af-resource-detail-kv",children:[o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailSource")}),o.jsx("dd",{children:Wt.sourceLabel||Wt.source})]}),o.jsxs("div",{children:[o.jsx("dt",{children:n("project:detailPath")}),o.jsx("dd",{children:Wt.path||Wt.key})]})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:"Collections"}),b.length===0?o.jsx("p",{children:"暂无 collection。可在左侧新建后再添加。"}):o.jsx("div",{className:"af-skill-detail-collections",children:b.map(K=>{const ge=zn(Wt),Te=K.skillKeys.includes(ge);return o.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[o.jsx("input",{type:"checkbox",checked:Te,disabled:w,onChange:Re=>Ds(K.id,ge,Re.target.checked)}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:K.name}),o.jsxs("span",{className:"af-composer-skill-option-desc",children:[K.skillKeys.length," skills"]})]})]},K.id)})})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:resourceMeaning")}),o.jsx("p",{children:n("project:skillsMeaning")})]}),o.jsxs("div",{className:"af-resource-detail-section",children:[o.jsx("h4",{children:n("project:skillPreview")}),o.jsx("pre",{className:"af-resource-skill-preview",children:ft===zn(Wt)?n("project:loadingResources"):(Sr==null?void 0:Sr.body)||(Sr==null?void 0:Sr.content)||n("project:skillPreviewEmpty")})]})]}):o.jsx("p",{className:"af-activity-empty",children:n("project:selectResource")})}):o.jsxs("aside",{id:"af-recent-activity-panel",className:"af-activity"+(V?"":" af-activity--hidden"),"aria-hidden":!V,"aria-label":n("project:recentActivity"),children:[o.jsxs("h2",{className:"af-activity-title",children:[o.jsx("span",{className:"af-activity-bullet"}),n("project:recentActivity")]}),o.jsx("div",{className:"af-activity-list",children:zr.length===0?o.jsx("p",{className:"af-activity-empty",children:Xn.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):zr.map(K=>{const ge=de===wS(K);return o.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action"+(ge?" af-activity-row--active":""),"aria-current":ge?"page":void 0,onClick:()=>ms(K),children:[o.jsxs("div",{className:"af-activity-row-top",children:[o.jsx("h4",{className:"af-activity-name",children:o.jsx(ar,{query:G,children:K.flowId})}),o.jsx("span",{className:"af-activity-time",children:Hw(K.at,n)})]}),o.jsxs("div",{className:"af-activity-meta",children:[o.jsx("span",{className:a$(K.kind),children:K.kind==="executed"?"play_arrow":"visibility"}),o.jsxs("p",{className:"af-activity-text",children:[K.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",Hw(K.at,n)]})]})]},`${K.kind}-${K.flowId}-${K.flowSource}-${K.at}`)})})]})]}),o.jsx(QM,{open:$,onClose:()=>I(!1),onCreated:async K=>{I(!1),await ie();const ge=K.source??"user";r(mh({id:K.id,source:ge},"workspace"))}}),z?o.jsx(XM,{file:z,onClose:()=>C(null),onImported:async K=>{C(null),await ie();const ge=K.source??"user";r(mh({id:K.id,source:ge},"workspace"))}},`${z.name}-${z.size}-${z.lastModified}`):null]})}function gr(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=gr(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var k$={value:()=>{}};function Fg(){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 tm(n)}function tm(e){this._=e}function S$(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}})}tm.prototype=Fg.prototype={constructor:tm,on:function(e,t){var n=this._,r=S$(e+"",n),s,i=-1,a=r.length;if(arguments.length<2){for(;++i<a;)if((s=(e=r[i]).type)&&(s=N$(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++i<a;)if(s=(e=r[i]).type)n[s]=kS(n[s],e.name,t);else if(t==null)for(s in n)n[s]=kS(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 tm(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,i;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(i=this._[e],r=0,s=i.length;r<s;++r)i[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,i=r.length;s<i;++s)r[s].value.apply(t,n)}};function N$(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function kS(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=k$,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Gw="http://www.w3.org/1999/xhtml";const SS={svg:"http://www.w3.org/2000/svg",xhtml:Gw,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function zg(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),SS.hasOwnProperty(t)?{space:SS[t],local:e}:e}function j$(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Gw&&t.documentElement.namespaceURI===Gw?t.createElement(e):t.createElementNS(n,e)}}function C$(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function iP(e){var t=zg(e);return(t.local?C$:j$)(t)}function E$(){}function $v(e){return e==null?E$:function(){return this.querySelector(e)}}function _$(e){typeof e!="function"&&(e=$v(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],a=i.length,l=r[s]=new Array(a),u,d,f=0;f<a;++f)(u=i[f])&&(d=e.call(u,u.__data__,f,i))&&("__data__"in u&&(d.__data__=u.__data__),l[f]=d);return new ni(r,this._parents)}function P$(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function A$(){return[]}function oP(e){return e==null?A$:function(){return this.querySelectorAll(e)}}function I$(e){return function(){return P$(e.apply(this,arguments))}}function T$(e){typeof e=="function"?e=I$(e):e=oP(e);for(var t=this._groups,n=t.length,r=[],s=[],i=0;i<n;++i)for(var a=t[i],l=a.length,u,d=0;d<l;++d)(u=a[d])&&(r.push(e.call(u,u.__data__,d,a)),s.push(u));return new ni(r,s)}function aP(e){return function(){return this.matches(e)}}function lP(e){return function(t){return t.matches(e)}}var R$=Array.prototype.find;function L$(e){return function(){return R$.call(this.children,e)}}function O$(){return this.firstElementChild}function M$(e){return this.select(e==null?O$:L$(typeof e=="function"?e:lP(e)))}var $$=Array.prototype.filter;function D$(){return Array.from(this.children)}function F$(e){return function(){return $$.call(this.children,e)}}function z$(e){return this.selectAll(e==null?D$:F$(typeof e=="function"?e:lP(e)))}function B$(e){typeof e!="function"&&(e=aP(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],a=i.length,l=r[s]=[],u,d=0;d<a;++d)(u=i[d])&&e.call(u,u.__data__,d,i)&&l.push(u);return new ni(r,this._parents)}function cP(e){return new Array(e.length)}function H$(){return new ni(this._enter||this._groups.map(cP),this._parents)}function Fm(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Fm.prototype={constructor:Fm,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 W$(e){return function(){return e}}function V$(e,t,n,r,s,i){for(var a=0,l,u=t.length,d=i.length;a<d;++a)(l=t[a])?(l.__data__=i[a],r[a]=l):n[a]=new Fm(e,i[a]);for(;a<u;++a)(l=t[a])&&(s[a]=l)}function U$(e,t,n,r,s,i,a){var l,u,d=new Map,f=t.length,c=i.length,p=new Array(f),m;for(l=0;l<f;++l)(u=t[l])&&(p[l]=m=a.call(u,u.__data__,l,t)+"",d.has(m)?s[l]=u:d.set(m,u));for(l=0;l<c;++l)m=a.call(e,i[l],l,i)+"",(u=d.get(m))?(r[l]=u,u.__data__=i[l],d.delete(m)):n[l]=new Fm(e,i[l]);for(l=0;l<f;++l)(u=t[l])&&d.get(p[l])===u&&(s[l]=u)}function K$(e){return e.__data__}function q$(e,t){if(!arguments.length)return Array.from(this,K$);var n=t?U$:V$,r=this._parents,s=this._groups;typeof e!="function"&&(e=W$(e));for(var i=s.length,a=new Array(i),l=new Array(i),u=new Array(i),d=0;d<i;++d){var f=r[d],c=s[d],p=c.length,m=Y$(e.call(f,f&&f.__data__,d,r)),g=m.length,b=l[d]=new Array(g),k=a[d]=new Array(g),y=u[d]=new Array(p);n(f,c,b,k,y,m,t);for(var v=0,w=0,j,P;v<g;++v)if(j=b[v]){for(v>=w&&(w=v+1);!(P=k[w])&&++w<g;);j._next=P||null}}return a=new ni(a,r),a._enter=l,a._exit=u,a}function Y$(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function G$(){return new ni(this._exit||this._groups.map(cP),this._parents)}function X$(e,t,n){var r=this.enter(),s=this,i=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?i.remove():n(i),r&&s?r.merge(s).order():s}function J$(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,i=r.length,a=Math.min(s,i),l=new Array(s),u=0;u<a;++u)for(var d=n[u],f=r[u],c=d.length,p=l[u]=new Array(c),m,g=0;g<c;++g)(m=d[g]||f[g])&&(p[g]=m);for(;u<s;++u)l[u]=n[u];return new ni(l,this._parents)}function Q$(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,i=r[s],a;--s>=0;)(a=r[s])&&(i&&a.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(a,i),i=a);return this}function Z$(e){e||(e=eD);function t(c,p){return c&&p?e(c.__data__,p.__data__):!c-!p}for(var n=this._groups,r=n.length,s=new Array(r),i=0;i<r;++i){for(var a=n[i],l=a.length,u=s[i]=new Array(l),d,f=0;f<l;++f)(d=a[f])&&(u[f]=d);u.sort(t)}return new ni(s,this._parents).order()}function eD(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function tD(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function nD(){return Array.from(this)}function rD(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,i=r.length;s<i;++s){var a=r[s];if(a)return a}return null}function sD(){let e=0;for(const t of this)++e;return e}function iD(){return!this.node()}function oD(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],i=0,a=s.length,l;i<a;++i)(l=s[i])&&e.call(l,l.__data__,i,s);return this}function aD(e){return function(){this.removeAttribute(e)}}function lD(e){return function(){this.removeAttributeNS(e.space,e.local)}}function cD(e,t){return function(){this.setAttribute(e,t)}}function uD(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function dD(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function fD(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 pD(e,t){var n=zg(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?lD:aD:typeof t=="function"?n.local?fD:dD:n.local?uD:cD)(n,t))}function uP(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function hD(e){return function(){this.style.removeProperty(e)}}function mD(e,t,n){return function(){this.style.setProperty(e,t,n)}}function gD(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function yD(e,t,n){return arguments.length>1?this.each((t==null?hD:typeof t=="function"?gD:mD)(e,t,n??"")):Nu(this.node(),e)}function Nu(e,t){return e.style.getPropertyValue(t)||uP(e).getComputedStyle(e,null).getPropertyValue(t)}function xD(e){return function(){delete this[e]}}function wD(e,t){return function(){this[e]=t}}function bD(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function vD(e,t){return arguments.length>1?this.each((t==null?xD:typeof t=="function"?bD:wD)(e,t)):this.node()[e]}function dP(e){return e.trim().split(/^|\s+/)}function Dv(e){return e.classList||new fP(e)}function fP(e){this._node=e,this._names=dP(e.getAttribute("class")||"")}fP.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 pP(e,t){for(var n=Dv(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function hP(e,t){for(var n=Dv(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function kD(e){return function(){pP(this,e)}}function SD(e){return function(){hP(this,e)}}function ND(e,t){return function(){(t.apply(this,arguments)?pP:hP)(this,e)}}function jD(e,t){var n=dP(e+"");if(arguments.length<2){for(var r=Dv(this.node()),s=-1,i=n.length;++s<i;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?ND:t?kD:SD)(n,t))}function CD(){this.textContent=""}function ED(e){return function(){this.textContent=e}}function _D(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function PD(e){return arguments.length?this.each(e==null?CD:(typeof e=="function"?_D:ED)(e)):this.node().textContent}function AD(){this.innerHTML=""}function ID(e){return function(){this.innerHTML=e}}function TD(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function RD(e){return arguments.length?this.each(e==null?AD:(typeof e=="function"?TD:ID)(e)):this.node().innerHTML}function LD(){this.nextSibling&&this.parentNode.appendChild(this)}function OD(){return this.each(LD)}function MD(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function $D(){return this.each(MD)}function DD(e){var t=typeof e=="function"?e:iP(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function FD(){return null}function zD(e,t){var n=typeof e=="function"?e:iP(e),r=t==null?FD:typeof t=="function"?t:$v(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function BD(){var e=this.parentNode;e&&e.removeChild(this)}function HD(){return this.each(BD)}function WD(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function VD(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function UD(e){return this.select(e?VD:WD)}function KD(e){return arguments.length?this.property("__data__",e):this.node().__data__}function qD(e){return function(t){e.call(this,t,this.__data__)}}function YD(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 GD(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,i;n<s;++n)i=t[n],(!e.type||i.type===e.type)&&i.name===e.name?this.removeEventListener(i.type,i.listener,i.options):t[++r]=i;++r?t.length=r:delete this.__on}}}function XD(e,t,n){return function(){var r=this.__on,s,i=qD(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=i,s.options=n),s.value=t;return}}this.addEventListener(e.type,i,n),s={type:e.type,name:e.name,value:t,listener:i,options:n},r?r.push(s):this.__on=[s]}}function JD(e,t,n){var r=YD(e+""),s,i=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var u=0,d=l.length,f;u<d;++u)for(s=0,f=l[u];s<i;++s)if((a=r[s]).type===f.type&&a.name===f.name)return f.value}return}for(l=t?XD:GD,s=0;s<i;++s)this.each(l(r[s],t,n));return this}function mP(e,t,n){var r=uP(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 QD(e,t){return function(){return mP(this,e,t)}}function ZD(e,t){return function(){return mP(this,e,t.apply(this,arguments))}}function eF(e,t){return this.each((typeof t=="function"?ZD:QD)(e,t))}function*tF(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,i=r.length,a;s<i;++s)(a=r[s])&&(yield a)}var gP=[null];function ni(e,t){this._groups=e,this._parents=t}function ip(){return new ni([[document.documentElement]],gP)}function nF(){return this}ni.prototype=ip.prototype={constructor:ni,select:_$,selectAll:T$,selectChild:M$,selectChildren:z$,filter:B$,data:q$,enter:H$,exit:G$,join:X$,merge:J$,selection:nF,order:Q$,sort:Z$,call:tD,nodes:nD,node:rD,size:sD,empty:iD,each:oD,attr:pD,style:yD,property:vD,classed:jD,text:PD,html:RD,raise:OD,lower:$D,append:DD,insert:zD,remove:HD,clone:UD,datum:KD,on:JD,dispatch:eF,[Symbol.iterator]:tF};function Xs(e){return typeof e=="string"?new ni([[document.querySelector(e)]],[document.documentElement]):new ni([[e]],gP)}function rF(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Wi(e,t){if(e=rF(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 sF={passive:!1},If={capture:!0,passive:!1};function rx(e){e.stopImmediatePropagation()}function du(e){e.preventDefault(),e.stopImmediatePropagation()}function yP(e){var t=e.document.documentElement,n=Xs(e).on("dragstart.drag",du,If);"onselectstart"in t?n.on("selectstart.drag",du,If):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function xP(e,t){var n=e.document.documentElement,r=Xs(e).on("dragstart.drag",null);t&&(r.on("click.drag",du,If),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 yh=e=>()=>e;function Xw(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:i,x:a,y:l,dx:u,dy:d,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:i,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:d,enumerable:!0,configurable:!0},_:{value:f}})}Xw.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function iF(e){return!e.ctrlKey&&!e.button}function oF(){return this.parentNode}function aF(e,t){return t??{x:e.x,y:e.y}}function lF(){return navigator.maxTouchPoints||"ontouchstart"in this}function wP(){var e=iF,t=oF,n=aF,r=lF,s={},i=Fg("start","drag","end"),a=0,l,u,d,f,c=0;function p(j){j.on("mousedown.drag",m).filter(r).on("touchstart.drag",k).on("touchmove.drag",y,sF).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(j,P){if(!(f||!e.call(this,j,P))){var _=w(this,t.call(this,j,P),j,P,"mouse");_&&(Xs(j.view).on("mousemove.drag",g,If).on("mouseup.drag",b,If),yP(j.view),rx(j),d=!1,l=j.clientX,u=j.clientY,_("start",j))}}function g(j){if(du(j),!d){var P=j.clientX-l,_=j.clientY-u;d=P*P+_*_>c}s.mouse("drag",j)}function b(j){Xs(j.view).on("mousemove.drag mouseup.drag",null),xP(j.view,d),du(j),s.mouse("end",j)}function k(j,P){if(e.call(this,j,P)){var _=j.changedTouches,L=t.call(this,j,P),B=_.length,D,F;for(D=0;D<B;++D)(F=w(this,L,j,P,_[D].identifier,_[D]))&&(rx(j),F("start",j,_[D]))}}function y(j){var P=j.changedTouches,_=P.length,L,B;for(L=0;L<_;++L)(B=s[P[L].identifier])&&(du(j),B("drag",j,P[L]))}function v(j){var P=j.changedTouches,_=P.length,L,B;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),L=0;L<_;++L)(B=s[P[L].identifier])&&(rx(j),B("end",j,P[L]))}function w(j,P,_,L,B,D){var F=i.copy(),R=Wi(D||_,P),M,W,O;if((O=n.call(j,new Xw("beforestart",{sourceEvent:_,target:p,identifier:B,active:a,x:R[0],y:R[1],dx:0,dy:0,dispatch:F}),L))!=null)return M=O.x-R[0]||0,W=O.y-R[1]||0,function $(I,z,C){var T=R,E;switch(I){case"start":s[B]=$,E=a++;break;case"end":delete s[B],--a;case"drag":R=Wi(C||z,P),E=a;break}F.call(I,j,new Xw(I,{sourceEvent:z,subject:O,target:p,identifier:B,active:E,x:R[0]+M,y:R[1]+W,dx:R[0]-T[0],dy:R[1]-T[1],dispatch:F}),L)}}return p.filter=function(j){return arguments.length?(e=typeof j=="function"?j:yh(!!j),p):e},p.container=function(j){return arguments.length?(t=typeof j=="function"?j:yh(j),p):t},p.subject=function(j){return arguments.length?(n=typeof j=="function"?j:yh(j),p):n},p.touchable=function(j){return arguments.length?(r=typeof j=="function"?j:yh(!!j),p):r},p.on=function(){var j=i.on.apply(i,arguments);return j===i?p:j},p.clickDistance=function(j){return arguments.length?(c=(j=+j)*j,p):Math.sqrt(c)},p}function Fv(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function bP(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function op(){}var Tf=.7,zm=1/Tf,fu="\\s*([+-]?\\d+)\\s*",Rf="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",jo="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",cF=/^#([0-9a-f]{3,8})$/,uF=new RegExp(`^rgb\\(${fu},${fu},${fu}\\)$`),dF=new RegExp(`^rgb\\(${jo},${jo},${jo}\\)$`),fF=new RegExp(`^rgba\\(${fu},${fu},${fu},${Rf}\\)$`),pF=new RegExp(`^rgba\\(${jo},${jo},${jo},${Rf}\\)$`),hF=new RegExp(`^hsl\\(${Rf},${jo},${jo}\\)$`),mF=new RegExp(`^hsla\\(${Rf},${jo},${jo},${Rf}\\)$`),NS={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};Fv(op,sc,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:jS,formatHex:jS,formatHex8:gF,formatHsl:yF,formatRgb:CS,toString:CS});function jS(){return this.rgb().formatHex()}function gF(){return this.rgb().formatHex8()}function yF(){return vP(this).formatHsl()}function CS(){return this.rgb().formatRgb()}function sc(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=cF.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?ES(t):n===3?new Es(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?xh(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?xh(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=uF.exec(e))?new Es(t[1],t[2],t[3],1):(t=dF.exec(e))?new Es(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=fF.exec(e))?xh(t[1],t[2],t[3],t[4]):(t=pF.exec(e))?xh(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=hF.exec(e))?AS(t[1],t[2]/100,t[3]/100,1):(t=mF.exec(e))?AS(t[1],t[2]/100,t[3]/100,t[4]):NS.hasOwnProperty(e)?ES(NS[e]):e==="transparent"?new Es(NaN,NaN,NaN,0):null}function ES(e){return new Es(e>>16&255,e>>8&255,e&255,1)}function xh(e,t,n,r){return r<=0&&(e=t=n=NaN),new Es(e,t,n,r)}function xF(e){return e instanceof op||(e=sc(e)),e?(e=e.rgb(),new Es(e.r,e.g,e.b,e.opacity)):new Es}function Jw(e,t,n,r){return arguments.length===1?xF(e):new Es(e,t,n,r??1)}function Es(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Fv(Es,Jw,bP(op,{brighter(e){return e=e==null?zm:Math.pow(zm,e),new Es(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Tf:Math.pow(Tf,e),new Es(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Es(Yl(this.r),Yl(this.g),Yl(this.b),Bm(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:_S,formatHex:_S,formatHex8:wF,formatRgb:PS,toString:PS}));function _S(){return`#${Ul(this.r)}${Ul(this.g)}${Ul(this.b)}`}function wF(){return`#${Ul(this.r)}${Ul(this.g)}${Ul(this.b)}${Ul((isNaN(this.opacity)?1:this.opacity)*255)}`}function PS(){const e=Bm(this.opacity);return`${e===1?"rgb(":"rgba("}${Yl(this.r)}, ${Yl(this.g)}, ${Yl(this.b)}${e===1?")":`, ${e})`}`}function Bm(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Yl(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Ul(e){return e=Yl(e),(e<16?"0":"")+e.toString(16)}function AS(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ki(e,t,n,r)}function vP(e){if(e instanceof Ki)return new Ki(e.h,e.s,e.l,e.opacity);if(e instanceof op||(e=sc(e)),!e)return new Ki;if(e instanceof Ki)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),i=Math.max(t,n,r),a=NaN,l=i-s,u=(i+s)/2;return l?(t===i?a=(n-r)/l+(n<r)*6:n===i?a=(r-t)/l+2:a=(t-n)/l+4,l/=u<.5?i+s:2-i-s,a*=60):l=u>0&&u<1?0:a,new Ki(a,l,u,e.opacity)}function bF(e,t,n,r){return arguments.length===1?vP(e):new Ki(e,t,n,r??1)}function Ki(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Fv(Ki,bF,bP(op,{brighter(e){return e=e==null?zm:Math.pow(zm,e),new Ki(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Tf:Math.pow(Tf,e),new Ki(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new Es(sx(e>=240?e-240:e+120,s,r),sx(e,s,r),sx(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Ki(IS(this.h),wh(this.s),wh(this.l),Bm(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=Bm(this.opacity);return`${e===1?"hsl(":"hsla("}${IS(this.h)}, ${wh(this.s)*100}%, ${wh(this.l)*100}%${e===1?")":`, ${e})`}`}}));function IS(e){return e=(e||0)%360,e<0?e+360:e}function wh(e){return Math.max(0,Math.min(1,e||0))}function sx(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 zv=e=>()=>e;function vF(e,t){return function(n){return e+n*t}}function kF(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 SF(e){return(e=+e)==1?kP:function(t,n){return n-t?kF(t,n,e):zv(isNaN(t)?n:t)}}function kP(e,t){var n=t-e;return n?vF(e,n):zv(isNaN(e)?t:e)}const Hm=function e(t){var n=SF(t);function r(s,i){var a=n((s=Jw(s)).r,(i=Jw(i)).r),l=n(s.g,i.g),u=n(s.b,i.b),d=kP(s.opacity,i.opacity);return function(f){return s.r=a(f),s.g=l(f),s.b=u(f),s.opacity=d(f),s+""}}return r.gamma=e,r}(1);function NF(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),s;return function(i){for(s=0;s<n;++s)r[s]=e[s]*(1-i)+t[s]*i;return r}}function jF(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function CF(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,s=new Array(r),i=new Array(n),a;for(a=0;a<r;++a)s[a]=rf(e[a],t[a]);for(;a<n;++a)i[a]=t[a];return function(l){for(a=0;a<r;++a)i[a]=s[a](l);return i}}function EF(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function yo(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function _F(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]=rf(e[s],t[s]):r[s]=t[s];return function(i){for(s in n)r[s]=n[s](i);return r}}var Qw=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ix=new RegExp(Qw.source,"g");function PF(e){return function(){return e}}function AF(e){return function(t){return e(t)+""}}function SP(e,t){var n=Qw.lastIndex=ix.lastIndex=0,r,s,i,a=-1,l=[],u=[];for(e=e+"",t=t+"";(r=Qw.exec(e))&&(s=ix.exec(t));)(i=s.index)>n&&(i=t.slice(n,i),l[a]?l[a]+=i:l[++a]=i),(r=r[0])===(s=s[0])?l[a]?l[a]+=s:l[++a]=s:(l[++a]=null,u.push({i:a,x:yo(r,s)})),n=ix.lastIndex;return n<t.length&&(i=t.slice(n),l[a]?l[a]+=i:l[++a]=i),l.length<2?u[0]?AF(u[0].x):PF(t):(t=u.length,function(d){for(var f=0,c;f<t;++f)l[(c=u[f]).i]=c.x(d);return l.join("")})}function rf(e,t){var n=typeof t,r;return t==null||n==="boolean"?zv(t):(n==="number"?yo:n==="string"?(r=sc(t))?(t=r,Hm):SP:t instanceof sc?Hm:t instanceof Date?EF:jF(t)?NF:Array.isArray(t)?CF:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?_F:yo)(e,t)}var TS=180/Math.PI,Zw={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function NP(e,t,n,r,s,i){var a,l,u;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(u=e*n+t*r)&&(n-=e*u,r-=t*u),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,u/=l),e*r<t*n&&(e=-e,t=-t,u=-u,a=-a),{translateX:s,translateY:i,rotate:Math.atan2(t,e)*TS,skewX:Math.atan(u)*TS,scaleX:a,scaleY:l}}var bh;function IF(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Zw:NP(t.a,t.b,t.c,t.d,t.e,t.f)}function TF(e){return e==null||(bh||(bh=document.createElementNS("http://www.w3.org/2000/svg","g")),bh.setAttribute("transform",e),!(e=bh.transform.baseVal.consolidate()))?Zw:(e=e.matrix,NP(e.a,e.b,e.c,e.d,e.e,e.f))}function jP(e,t,n,r){function s(d){return d.length?d.pop()+" ":""}function i(d,f,c,p,m,g){if(d!==c||f!==p){var b=m.push("translate(",null,t,null,n);g.push({i:b-4,x:yo(d,c)},{i:b-2,x:yo(f,p)})}else(c||p)&&m.push("translate("+c+t+p+n)}function a(d,f,c,p){d!==f?(d-f>180?f+=360:f-d>180&&(d+=360),p.push({i:c.push(s(c)+"rotate(",null,r)-2,x:yo(d,f)})):f&&c.push(s(c)+"rotate("+f+r)}function l(d,f,c,p){d!==f?p.push({i:c.push(s(c)+"skewX(",null,r)-2,x:yo(d,f)}):f&&c.push(s(c)+"skewX("+f+r)}function u(d,f,c,p,m,g){if(d!==c||f!==p){var b=m.push(s(m)+"scale(",null,",",null,")");g.push({i:b-4,x:yo(d,c)},{i:b-2,x:yo(f,p)})}else(c!==1||p!==1)&&m.push(s(m)+"scale("+c+","+p+")")}return function(d,f){var c=[],p=[];return d=e(d),f=e(f),i(d.translateX,d.translateY,f.translateX,f.translateY,c,p),a(d.rotate,f.rotate,c,p),l(d.skewX,f.skewX,c,p),u(d.scaleX,d.scaleY,f.scaleX,f.scaleY,c,p),d=f=null,function(m){for(var g=-1,b=p.length,k;++g<b;)c[(k=p[g]).i]=k.x(m);return c.join("")}}}var RF=jP(IF,"px, ","px)","deg)"),LF=jP(TF,", ",")",")"),OF=1e-12;function RS(e){return((e=Math.exp(e))+1/e)/2}function MF(e){return((e=Math.exp(e))-1/e)/2}function $F(e){return((e=Math.exp(2*e))-1)/(e+1)}const nm=function e(t,n,r){function s(i,a){var l=i[0],u=i[1],d=i[2],f=a[0],c=a[1],p=a[2],m=f-l,g=c-u,b=m*m+g*g,k,y;if(b<OF)y=Math.log(p/d)/t,k=function(L){return[l+L*m,u+L*g,d*Math.exp(t*L*y)]};else{var v=Math.sqrt(b),w=(p*p-d*d+r*b)/(2*d*n*v),j=(p*p-d*d-r*b)/(2*p*n*v),P=Math.log(Math.sqrt(w*w+1)-w),_=Math.log(Math.sqrt(j*j+1)-j);y=(_-P)/t,k=function(L){var B=L*y,D=RS(P),F=d/(n*v)*(D*$F(t*B+P)-MF(P));return[l+F*m,u+F*g,d*D/RS(t*B+P)]}}return k.duration=y*1e3*t/Math.SQRT2,k}return s.rho=function(i){var a=Math.max(.001,+i),l=a*a,u=l*l;return e(a,l,u)},s}(Math.SQRT2,2,4);var ju=0,zd=0,Ed=0,CP=1e3,Wm,Bd,Vm=0,ic=0,Bg=0,Lf=typeof performance=="object"&&performance.now?performance:Date,EP=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Bv(){return ic||(EP(DF),ic=Lf.now()+Bg)}function DF(){ic=0}function Um(){this._call=this._time=this._next=null}Um.prototype=_P.prototype={constructor:Um,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Bv():+n)+(t==null?0:+t),!this._next&&Bd!==this&&(Bd?Bd._next=this:Wm=this,Bd=this),this._call=e,this._time=n,eb()},stop:function(){this._call&&(this._call=null,this._time=1/0,eb())}};function _P(e,t,n){var r=new Um;return r.restart(e,t,n),r}function FF(){Bv(),++ju;for(var e=Wm,t;e;)(t=ic-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ju}function LS(){ic=(Vm=Lf.now())+Bg,ju=zd=0;try{FF()}finally{ju=0,BF(),ic=0}}function zF(){var e=Lf.now(),t=e-Vm;t>CP&&(Bg-=t,Vm=e)}function BF(){for(var e,t=Wm,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:Wm=n);Bd=e,eb(r)}function eb(e){if(!ju){zd&&(zd=clearTimeout(zd));var t=e-ic;t>24?(e<1/0&&(zd=setTimeout(LS,e-Lf.now()-Bg)),Ed&&(Ed=clearInterval(Ed))):(Ed||(Vm=Lf.now(),Ed=setInterval(zF,CP)),ju=1,EP(LS))}}function OS(e,t,n){var r=new Um;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var HF=Fg("start","end","cancel","interrupt"),WF=[],PP=0,MS=1,tb=2,rm=3,$S=4,nb=5,sm=6;function Hg(e,t,n,r,s,i){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;VF(e,n,{name:t,index:r,group:s,on:HF,tween:WF,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:PP})}function Hv(e,t){var n=eo(e,t);if(n.state>PP)throw new Error("too late; already scheduled");return n}function To(e,t){var n=eo(e,t);if(n.state>rm)throw new Error("too late; already running");return n}function eo(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function VF(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=_P(i,0,n.time);function i(d){n.state=MS,n.timer.restart(a,n.delay,n.time),n.delay<=d&&a(d-n.delay)}function a(d){var f,c,p,m;if(n.state!==MS)return u();for(f in r)if(m=r[f],m.name===n.name){if(m.state===rm)return OS(a);m.state===$S?(m.state=sm,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[f]):+f<t&&(m.state=sm,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[f])}if(OS(function(){n.state===rm&&(n.state=$S,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=tb,n.on.call("start",e,e.__data__,n.index,n.group),n.state===tb){for(n.state=rm,s=new Array(p=n.tween.length),f=0,c=-1;f<p;++f)(m=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(s[++c]=m);s.length=c+1}}function l(d){for(var f=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(u),n.state=nb,1),c=-1,p=s.length;++c<p;)s[c].call(e,f);n.state===nb&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){n.state=sm,n.timer.stop(),delete r[t];for(var d in r)return;delete e.__transition}}function im(e,t){var n=e.__transition,r,s,i=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){i=!1;continue}s=r.state>tb&&r.state<nb,r.state=sm,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}i&&delete e.__transition}}function UF(e){return this.each(function(){im(this,e)})}function KF(e,t){var n,r;return function(){var s=To(this,e),i=s.tween;if(i!==n){r=n=i;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 qF(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var i=To(this,e),a=i.tween;if(a!==r){s=(r=a).slice();for(var l={name:t,value:n},u=0,d=s.length;u<d;++u)if(s[u].name===t){s[u]=l;break}u===d&&s.push(l)}i.tween=s}}function YF(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=eo(this.node(),n).tween,s=0,i=r.length,a;s<i;++s)if((a=r[s]).name===e)return a.value;return null}return this.each((t==null?KF:qF)(n,e,t))}function Wv(e,t,n){var r=e._id;return e.each(function(){var s=To(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return eo(s,r).value[t]}}function AP(e,t){var n;return(typeof t=="number"?yo:t instanceof sc?Hm:(n=sc(t))?(t=n,Hm):SP)(e,t)}function GF(e){return function(){this.removeAttribute(e)}}function XF(e){return function(){this.removeAttributeNS(e.space,e.local)}}function JF(e,t,n){var r,s=n+"",i;return function(){var a=this.getAttribute(e);return a===s?null:a===r?i:i=t(r=a,n)}}function QF(e,t,n){var r,s=n+"",i;return function(){var a=this.getAttributeNS(e.space,e.local);return a===s?null:a===r?i:i=t(r=a,n)}}function ZF(e,t,n){var r,s,i;return function(){var a,l=n(this),u;return l==null?void this.removeAttribute(e):(a=this.getAttribute(e),u=l+"",a===u?null:a===r&&u===s?i:(s=u,i=t(r=a,l)))}}function ez(e,t,n){var r,s,i;return function(){var a,l=n(this),u;return l==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),u=l+"",a===u?null:a===r&&u===s?i:(s=u,i=t(r=a,l)))}}function tz(e,t){var n=zg(e),r=n==="transform"?LF:AP;return this.attrTween(e,typeof t=="function"?(n.local?ez:ZF)(n,r,Wv(this,"attr."+e,t)):t==null?(n.local?XF:GF)(n):(n.local?QF:JF)(n,r,t))}function nz(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function rz(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function sz(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&rz(e,i)),n}return s._value=t,s}function iz(e,t){var n,r;function s(){var i=t.apply(this,arguments);return i!==r&&(n=(r=i)&&nz(e,i)),n}return s._value=t,s}function oz(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=zg(e);return this.tween(n,(r.local?sz:iz)(r,t))}function az(e,t){return function(){Hv(this,e).delay=+t.apply(this,arguments)}}function lz(e,t){return t=+t,function(){Hv(this,e).delay=t}}function cz(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?az:lz)(t,e)):eo(this.node(),t).delay}function uz(e,t){return function(){To(this,e).duration=+t.apply(this,arguments)}}function dz(e,t){return t=+t,function(){To(this,e).duration=t}}function fz(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?uz:dz)(t,e)):eo(this.node(),t).duration}function pz(e,t){if(typeof t!="function")throw new Error;return function(){To(this,e).ease=t}}function hz(e){var t=this._id;return arguments.length?this.each(pz(t,e)):eo(this.node(),t).ease}function mz(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;To(this,e).ease=n}}function gz(e){if(typeof e!="function")throw new Error;return this.each(mz(this._id,e))}function yz(e){typeof e!="function"&&(e=aP(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var i=t[s],a=i.length,l=r[s]=[],u,d=0;d<a;++d)(u=i[d])&&e.call(u,u.__data__,d,i)&&l.push(u);return new ua(r,this._parents,this._name,this._id)}function xz(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,i=Math.min(r,s),a=new Array(r),l=0;l<i;++l)for(var u=t[l],d=n[l],f=u.length,c=a[l]=new Array(f),p,m=0;m<f;++m)(p=u[m]||d[m])&&(c[m]=p);for(;l<r;++l)a[l]=t[l];return new ua(a,this._parents,this._name,this._id)}function wz(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 bz(e,t,n){var r,s,i=wz(t)?Hv:To;return function(){var a=i(this,e),l=a.on;l!==r&&(s=(r=l).copy()).on(t,n),a.on=s}}function vz(e,t){var n=this._id;return arguments.length<2?eo(this.node(),n).on.on(e):this.each(bz(n,e,t))}function kz(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function Sz(){return this.on("end.remove",kz(this._id))}function Nz(e){var t=this._name,n=this._id;typeof e!="function"&&(e=$v(e));for(var r=this._groups,s=r.length,i=new Array(s),a=0;a<s;++a)for(var l=r[a],u=l.length,d=i[a]=new Array(u),f,c,p=0;p<u;++p)(f=l[p])&&(c=e.call(f,f.__data__,p,l))&&("__data__"in f&&(c.__data__=f.__data__),d[p]=c,Hg(d[p],t,n,p,d,eo(f,n)));return new ua(i,this._parents,t,n)}function jz(e){var t=this._name,n=this._id;typeof e!="function"&&(e=oP(e));for(var r=this._groups,s=r.length,i=[],a=[],l=0;l<s;++l)for(var u=r[l],d=u.length,f,c=0;c<d;++c)if(f=u[c]){for(var p=e.call(f,f.__data__,c,u),m,g=eo(f,n),b=0,k=p.length;b<k;++b)(m=p[b])&&Hg(m,t,n,b,p,g);i.push(p),a.push(f)}return new ua(i,a,t,n)}var Cz=ip.prototype.constructor;function Ez(){return new Cz(this._groups,this._parents)}function _z(e,t){var n,r,s;return function(){var i=Nu(this,e),a=(this.style.removeProperty(e),Nu(this,e));return i===a?null:i===n&&a===r?s:s=t(n=i,r=a)}}function IP(e){return function(){this.style.removeProperty(e)}}function Pz(e,t,n){var r,s=n+"",i;return function(){var a=Nu(this,e);return a===s?null:a===r?i:i=t(r=a,n)}}function Az(e,t,n){var r,s,i;return function(){var a=Nu(this,e),l=n(this),u=l+"";return l==null&&(u=l=(this.style.removeProperty(e),Nu(this,e))),a===u?null:a===r&&u===s?i:(s=u,i=t(r=a,l))}}function Iz(e,t){var n,r,s,i="style."+t,a="end."+i,l;return function(){var u=To(this,e),d=u.on,f=u.value[i]==null?l||(l=IP(t)):void 0;(d!==n||s!==f)&&(r=(n=d).copy()).on(a,s=f),u.on=r}}function Tz(e,t,n){var r=(e+="")=="transform"?RF:AP;return t==null?this.styleTween(e,_z(e,r)).on("end.style."+e,IP(e)):typeof t=="function"?this.styleTween(e,Az(e,r,Wv(this,"style."+e,t))).each(Iz(this._id,e)):this.styleTween(e,Pz(e,r,t),n).on("end.style."+e,null)}function Rz(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function Lz(e,t,n){var r,s;function i(){var a=t.apply(this,arguments);return a!==s&&(r=(s=a)&&Rz(e,a,n)),r}return i._value=t,i}function Oz(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,Lz(e,t,n??""))}function Mz(e){return function(){this.textContent=e}}function $z(e){return function(){var t=e(this);this.textContent=t??""}}function Dz(e){return this.tween("text",typeof e=="function"?$z(Wv(this,"text",e)):Mz(e==null?"":e+""))}function Fz(e){return function(t){this.textContent=e.call(this,t)}}function zz(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&Fz(s)),t}return r._value=e,r}function Bz(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,zz(e))}function Hz(){for(var e=this._name,t=this._id,n=TP(),r=this._groups,s=r.length,i=0;i<s;++i)for(var a=r[i],l=a.length,u,d=0;d<l;++d)if(u=a[d]){var f=eo(u,t);Hg(u,e,n,d,a,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new ua(r,this._parents,e,n)}function Wz(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(i,a){var l={value:a},u={value:function(){--s===0&&i()}};n.each(function(){var d=To(this,r),f=d.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(u)),d.on=t}),s===0&&i()})}var Vz=0;function ua(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function TP(){return++Vz}var qo=ip.prototype;ua.prototype={constructor:ua,select:Nz,selectAll:jz,selectChild:qo.selectChild,selectChildren:qo.selectChildren,filter:yz,merge:xz,selection:Ez,transition:Hz,call:qo.call,nodes:qo.nodes,node:qo.node,size:qo.size,empty:qo.empty,each:qo.each,on:vz,attr:tz,attrTween:oz,style:Tz,styleTween:Oz,text:Dz,textTween:Bz,remove:Sz,tween:YF,delay:cz,duration:fz,ease:hz,easeVarying:gz,end:Wz,[Symbol.iterator]:qo[Symbol.iterator]};function Uz(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var Kz={time:null,delay:0,duration:250,ease:Uz};function qz(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 Yz(e){var t,n;e instanceof ua?(t=e._id,e=e._name):(t=TP(),(n=Kz).time=Bv(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,i=0;i<s;++i)for(var a=r[i],l=a.length,u,d=0;d<l;++d)(u=a[d])&&Hg(u,e,t,d,a,n||qz(u,t));return new ua(r,this._parents,e,t)}ip.prototype.interrupt=UF;ip.prototype.transition=Yz;const vh=e=>()=>e;function Gz(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 na(e,t,n){this.k=e,this.x=t,this.y=n}na.prototype={constructor:na,scale:function(e){return e===1?this:new na(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new na(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 Wg=new na(1,0,0);RP.prototype=na.prototype;function RP(e){for(;!e.__zoom;)if(!(e=e.parentNode))return Wg;return e.__zoom}function ox(e){e.stopImmediatePropagation()}function _d(e){e.preventDefault(),e.stopImmediatePropagation()}function Xz(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function Jz(){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 DS(){return this.__zoom||Wg}function Qz(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function Zz(){return navigator.maxTouchPoints||"ontouchstart"in this}function e3(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],i=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>i?(i+a)/2:Math.min(0,i)||Math.max(0,a))}function LP(){var e=Xz,t=Jz,n=e3,r=Qz,s=Zz,i=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,u=nm,d=Fg("start","zoom","end"),f,c,p,m=500,g=150,b=0,k=10;function y(O){O.property("__zoom",DS).on("wheel.zoom",B,{passive:!1}).on("mousedown.zoom",D).on("dblclick.zoom",F).filter(s).on("touchstart.zoom",R).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",W).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}y.transform=function(O,$,I,z){var C=O.selection?O.selection():O;C.property("__zoom",DS),O!==C?P(O,$,I,z):C.interrupt().each(function(){_(this,arguments).event(z).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},y.scaleBy=function(O,$,I,z){y.scaleTo(O,function(){var C=this.__zoom.k,T=typeof $=="function"?$.apply(this,arguments):$;return C*T},I,z)},y.scaleTo=function(O,$,I,z){y.transform(O,function(){var C=t.apply(this,arguments),T=this.__zoom,E=I==null?j(C):typeof I=="function"?I.apply(this,arguments):I,G=T.invert(E),Z=typeof $=="function"?$.apply(this,arguments):$;return n(w(v(T,Z),E,G),C,a)},I,z)},y.translateBy=function(O,$,I,z){y.transform(O,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof I=="function"?I.apply(this,arguments):I),t.apply(this,arguments),a)},null,z)},y.translateTo=function(O,$,I,z,C){y.transform(O,function(){var T=t.apply(this,arguments),E=this.__zoom,G=z==null?j(T):typeof z=="function"?z.apply(this,arguments):z;return n(Wg.translate(G[0],G[1]).scale(E.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof I=="function"?-I.apply(this,arguments):-I),T,a)},z,C)};function v(O,$){return $=Math.max(i[0],Math.min(i[1],$)),$===O.k?O:new na($,O.x,O.y)}function w(O,$,I){var z=$[0]-I[0]*O.k,C=$[1]-I[1]*O.k;return z===O.x&&C===O.y?O:new na(O.k,z,C)}function j(O){return[(+O[0][0]+ +O[1][0])/2,(+O[0][1]+ +O[1][1])/2]}function P(O,$,I,z){O.on("start.zoom",function(){_(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){_(this,arguments).event(z).end()}).tween("zoom",function(){var C=this,T=arguments,E=_(C,T).event(z),G=t.apply(C,T),Z=I==null?j(G):typeof I=="function"?I.apply(C,T):I,V=Math.max(G[1][0]-G[0][0],G[1][1]-G[0][1]),se=C.__zoom,de=typeof $=="function"?$.apply(C,T):$,fe=u(se.invert(Z).concat(V/se.k),de.invert(Z).concat(V/de.k));return function(pe){if(pe===1)pe=de;else{var ae=fe(pe),be=V/ae[2];pe=new na(be,Z[0]-ae[0]*be,Z[1]-ae[1]*be)}E.zoom(null,pe)}})}function _(O,$,I){return!I&&O.__zooming||new L(O,$)}function L(O,$){this.that=O,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(O,$),this.taps=0}L.prototype={event:function(O){return O&&(this.sourceEvent=O),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(O,$){return this.mouse&&O!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&O!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&O!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(O){var $=Xs(this.that).datum();d.call(O,this.that,new Gz(O,{sourceEvent:this.sourceEvent,target:y,transform:this.that.__zoom,dispatch:d}),$)}};function B(O,...$){if(!e.apply(this,arguments))return;var I=_(this,$).event(O),z=this.__zoom,C=Math.max(i[0],Math.min(i[1],z.k*Math.pow(2,r.apply(this,arguments)))),T=Wi(O);if(I.wheel)(I.mouse[0][0]!==T[0]||I.mouse[0][1]!==T[1])&&(I.mouse[1]=z.invert(I.mouse[0]=T)),clearTimeout(I.wheel);else{if(z.k===C)return;I.mouse=[T,z.invert(T)],im(this),I.start()}_d(O),I.wheel=setTimeout(E,g),I.zoom("mouse",n(w(v(z,C),I.mouse[0],I.mouse[1]),I.extent,a));function E(){I.wheel=null,I.end()}}function D(O,...$){if(p||!e.apply(this,arguments))return;var I=O.currentTarget,z=_(this,$,!0).event(O),C=Xs(O.view).on("mousemove.zoom",Z,!0).on("mouseup.zoom",V,!0),T=Wi(O,I),E=O.clientX,G=O.clientY;yP(O.view),ox(O),z.mouse=[T,this.__zoom.invert(T)],im(this),z.start();function Z(se){if(_d(se),!z.moved){var de=se.clientX-E,fe=se.clientY-G;z.moved=de*de+fe*fe>b}z.event(se).zoom("mouse",n(w(z.that.__zoom,z.mouse[0]=Wi(se,I),z.mouse[1]),z.extent,a))}function V(se){C.on("mousemove.zoom mouseup.zoom",null),xP(se.view,z.moved),_d(se),z.event(se).end()}}function F(O,...$){if(e.apply(this,arguments)){var I=this.__zoom,z=Wi(O.changedTouches?O.changedTouches[0]:O,this),C=I.invert(z),T=I.k*(O.shiftKey?.5:2),E=n(w(v(I,T),z,C),t.apply(this,$),a);_d(O),l>0?Xs(this).transition().duration(l).call(P,E,z,O):Xs(this).call(y.transform,E,z,O)}}function R(O,...$){if(e.apply(this,arguments)){var I=O.touches,z=I.length,C=_(this,$,O.changedTouches.length===z).event(O),T,E,G,Z;for(ox(O),E=0;E<z;++E)G=I[E],Z=Wi(G,this),Z=[Z,this.__zoom.invert(Z),G.identifier],C.touch0?!C.touch1&&C.touch0[2]!==Z[2]&&(C.touch1=Z,C.taps=0):(C.touch0=Z,T=!0,C.taps=1+!!f);f&&(f=clearTimeout(f)),T&&(C.taps<2&&(c=Z[0],f=setTimeout(function(){f=null},m)),im(this),C.start())}}function M(O,...$){if(this.__zooming){var I=_(this,$).event(O),z=O.changedTouches,C=z.length,T,E,G,Z;for(_d(O),T=0;T<C;++T)E=z[T],G=Wi(E,this),I.touch0&&I.touch0[2]===E.identifier?I.touch0[0]=G:I.touch1&&I.touch1[2]===E.identifier&&(I.touch1[0]=G);if(E=I.that.__zoom,I.touch1){var V=I.touch0[0],se=I.touch0[1],de=I.touch1[0],fe=I.touch1[1],pe=(pe=de[0]-V[0])*pe+(pe=de[1]-V[1])*pe,ae=(ae=fe[0]-se[0])*ae+(ae=fe[1]-se[1])*ae;E=v(E,Math.sqrt(pe/ae)),G=[(V[0]+de[0])/2,(V[1]+de[1])/2],Z=[(se[0]+fe[0])/2,(se[1]+fe[1])/2]}else if(I.touch0)G=I.touch0[0],Z=I.touch0[1];else return;I.zoom("touch",n(w(E,G,Z),I.extent,a))}}function W(O,...$){if(this.__zooming){var I=_(this,$).event(O),z=O.changedTouches,C=z.length,T,E;for(ox(O),p&&clearTimeout(p),p=setTimeout(function(){p=null},m),T=0;T<C;++T)E=z[T],I.touch0&&I.touch0[2]===E.identifier?delete I.touch0:I.touch1&&I.touch1[2]===E.identifier&&delete I.touch1;if(I.touch1&&!I.touch0&&(I.touch0=I.touch1,delete I.touch1),I.touch0)I.touch0[1]=this.__zoom.invert(I.touch0[0]);else if(I.end(),I.taps===2&&(E=Wi(E,this),Math.hypot(c[0]-E[0],c[1]-E[1])<k)){var G=Xs(this).on("dblclick.zoom");G&&G.apply(this,arguments)}}}return y.wheelDelta=function(O){return arguments.length?(r=typeof O=="function"?O:vh(+O),y):r},y.filter=function(O){return arguments.length?(e=typeof O=="function"?O:vh(!!O),y):e},y.touchable=function(O){return arguments.length?(s=typeof O=="function"?O:vh(!!O),y):s},y.extent=function(O){return arguments.length?(t=typeof O=="function"?O:vh([[+O[0][0],+O[0][1]],[+O[1][0],+O[1][1]]]),y):t},y.scaleExtent=function(O){return arguments.length?(i[0]=+O[0],i[1]=+O[1],y):[i[0],i[1]]},y.translateExtent=function(O){return arguments.length?(a[0][0]=+O[0][0],a[1][0]=+O[1][0],a[0][1]=+O[0][1],a[1][1]=+O[1][1],y):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},y.constrain=function(O){return arguments.length?(n=O,y):n},y.duration=function(O){return arguments.length?(l=+O,y):l},y.interpolate=function(O){return arguments.length?(u=O,y):u},y.on=function(){var O=d.on.apply(d,arguments);return O===d?y:O},y.clickDistance=function(O){return arguments.length?(b=(O=+O)*O,y):Math.sqrt(b)},y.tapDistance=function(O){return arguments.length?(k=+O,y):k},y}const Po={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."},Of=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],OP=["Enter"," ","Escape"],MP={"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 Cu;(function(e){e.Strict="strict",e.Loose="loose"})(Cu||(Cu={}));var Gl;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Gl||(Gl={}));var Mf;(function(e){e.Partial="partial",e.Full="full"})(Mf||(Mf={}));const $P={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var za;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(za||(za={}));var Ls;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ls||(Ls={}));var Xe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Xe||(Xe={}));const FS={[Xe.Left]:Xe.Right,[Xe.Right]:Xe.Left,[Xe.Top]:Xe.Bottom,[Xe.Bottom]:Xe.Top};function DP(e){return e===null?null:e?"valid":"invalid"}const FP=e=>"id"in e&&"source"in e&&"target"in e,t3=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),Vv=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),ap=(e,t=[0,0])=>{const{width:n,height:r}=ha(e),s=e.origin??t,i=n*s[0],a=r*s[1];return{x:e.position.x-i,y:e.position.y-a}},n3=(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 i=typeof s=="string";let a=!t.nodeLookup&&!i?s:void 0;t.nodeLookup&&(a=i?t.nodeLookup.get(s):Vv(s)?s:t.nodeLookup.get(s.id));const l=a?Km(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Vg(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return Ug(n)},lp=(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=Vg(n,Km(s)),r=!0)}),r?Ug(n):{x:0,y:0,width:0,height:0}},Uv=(e,t,[n,r,s]=[0,0,1],i=!1,a=!1)=>{const l={...up(t,[n,r,s]),width:t.width/s,height:t.height/s},u=[];for(const d of e.values()){const{measured:f,selectable:c=!0,hidden:p=!1}=d;if(a&&!c||p)continue;const m=f.width??d.width??d.initialWidth??null,g=f.height??d.height??d.initialHeight??null,b=$f(l,_u(d)),k=(m??0)*(g??0),y=i&&b>0;(!d.internals.handleBounds||y||b>=k||d.dragging)&&u.push(d)}return u},r3=(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 s3(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 i3({nodes:e,width:t,height:n,panZoom:r,minZoom:s,maxZoom:i},a){if(e.size===0)return Promise.resolve(!0);const l=s3(e,a),u=lp(l),d=Kv(u,t,n,(a==null?void 0:a.minZoom)??s,(a==null?void 0:a.maxZoom)??i,(a==null?void 0:a.padding)??.1);return await r.setViewport(d,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),Promise.resolve(!0)}function zP({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:s,onError:i}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:u,y:d}=l?l.internals.positionAbsolute:{x:0,y:0},f=a.origin??r;let c=a.extent||s;if(a.extent==="parent"&&!a.expandParent)if(!l)i==null||i("005",Po.error005());else{const m=l.measured.width,g=l.measured.height;m&&g&&(c=[[u,d],[u+m,d+g]])}else l&&Pu(a.extent)&&(c=[[a.extent[0][0]+u,a.extent[0][1]+d],[a.extent[1][0]+u,a.extent[1][1]+d]]);const p=Pu(c)?oc(t,c,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(i==null||i("015",Po.error015())),{position:{x:p.x-u+(a.measured.width??0)*f[0],y:p.y-d+(a.measured.height??0)*f[1]},positionAbsolute:p}}async function o3({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:s}){const i=new Set(e.map(p=>p.id)),a=[];for(const p of n){if(p.deletable===!1)continue;const m=i.has(p.id),g=!m&&p.parentId&&a.find(b=>b.id===p.parentId);(m||g)&&a.push(p)}const l=new Set(t.map(p=>p.id)),u=r.filter(p=>p.deletable!==!1),f=r3(a,u);for(const p of u)l.has(p.id)&&!f.find(g=>g.id===p.id)&&f.push(p);if(!s)return{edges:f,nodes:a};const c=await s({nodes:a,edges:f});return typeof c=="boolean"?c?{edges:f,nodes:a}:{edges:[],nodes:[]}:c}const Eu=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),oc=(e={x:0,y:0},t,n)=>({x:Eu(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:Eu(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function BP(e,t,n){const{width:r,height:s}=ha(n),{x:i,y:a}=n.internals.positionAbsolute;return oc(e,[[i,a],[i+r,a+s]],t)}const zS=(e,t,n)=>e<t?Eu(Math.abs(e-t),1,t)/t:e>n?-Eu(Math.abs(e-n),1,t)/t:0,HP=(e,t,n=15,r=40)=>{const s=zS(e.x,r,t.width-r)*n,i=zS(e.y,r,t.height-r)*n;return[s,i]},Vg=(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)}),rb=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),Ug=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),_u=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=Vv(e)?e.internals.positionAbsolute:ap(e,t);return{x:n,y:r,width:((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0,height:((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0}},Km=(e,t=[0,0])=>{var s,i;const{x:n,y:r}=Vv(e)?e.internals.positionAbsolute:ap(e,t);return{x:n,y:r,x2:n+(((s=e.measured)==null?void 0:s.width)??e.width??e.initialWidth??0),y2:r+(((i=e.measured)==null?void 0:i.height)??e.height??e.initialHeight??0)}},WP=(e,t)=>Ug(Vg(rb(e),rb(t))),$f=(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)},BS=e=>qi(e.width)&&qi(e.height)&&qi(e.x)&&qi(e.y),qi=e=>!isNaN(e)&&isFinite(e),a3=(e,t)=>{},cp=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),up=({x:e,y:t},[n,r,s],i=!1,a=[1,1])=>{const l={x:(e-n)/s,y:(t-r)/s};return i?cp(l,a):l},qm=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r});function Tc(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 l3(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Tc(e,n),s=Tc(e,t);return{top:r,right:s,bottom:r,left:s,x:s*2,y:r*2}}if(typeof e=="object"){const r=Tc(e.top??e.y??0,n),s=Tc(e.bottom??e.y??0,n),i=Tc(e.left??e.x??0,t),a=Tc(e.right??e.x??0,t);return{top:r,right:a,bottom:s,left:i,x:i+a,y:r+s}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function c3(e,t,n,r,s,i){const{x:a,y:l}=qm(e,[t,n,r]),{x:u,y:d}=qm({x:e.x+e.width,y:e.y+e.height},[t,n,r]),f=s-u,c=i-d;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(f),bottom:Math.floor(c)}}const Kv=(e,t,n,r,s,i)=>{const a=l3(i,t,n),l=(t-a.x)/e.width,u=(n-a.y)/e.height,d=Math.min(l,u),f=Eu(d,r,s),c=e.x+e.width/2,p=e.y+e.height/2,m=t/2-c*f,g=n/2-p*f,b=c3(e,m,g,f,t,n),k={left:Math.min(b.left-a.left,0),top:Math.min(b.top-a.top,0),right:Math.min(b.right-a.right,0),bottom:Math.min(b.bottom-a.bottom,0)};return{x:m-k.left+k.right,y:g-k.top+k.bottom,zoom:f}},Df=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0};function Pu(e){return e!=null&&e!=="parent"}function ha(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 VP(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 UP(e,t={width:0,height:0},n,r,s){const i={...e},a=r.get(n);if(a){const l=a.origin||s;i.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],i.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return i}function HS(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function u3(){let e,t;return{promise:new Promise((r,s)=>{e=r,t=s}),resolve:e,reject:t}}function d3(e){return{...MP,...e||{}}}function sf(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:s}){const{x:i,y:a}=Yi(e),l=up({x:i-((s==null?void 0:s.left)??0),y:a-((s==null?void 0:s.top)??0)},r),{x:u,y:d}=n?cp(l,t):l;return{xSnapped:u,ySnapped:d,...l}}const qv=e=>({width:e.offsetWidth,height:e.offsetHeight}),KP=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},f3=["INPUT","SELECT","TEXTAREA"];function qP(e){var r,s;const t=((s=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:s[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:f3.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const YP=e=>"clientX"in e,Yi=(e,t)=>{var i,a;const n=YP(e),r=n?e.clientX:(i=e.touches)==null?void 0:i[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)}},WS=(e,t,n,r,s)=>{const i=t.querySelectorAll(`.${e}`);return!i||!i.length?null:Array.from(i).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,...qv(a)}})};function GP({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:i,targetControlX:a,targetControlY:l}){const u=e*.125+s*.375+a*.375+n*.125,d=t*.125+i*.375+l*.375+r*.125,f=Math.abs(u-e),c=Math.abs(d-t);return[u,d,f,c]}function kh(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function VS({pos:e,x1:t,y1:n,x2:r,y2:s,c:i}){switch(e){case Xe.Left:return[t-kh(t-r,i),n];case Xe.Right:return[t+kh(r-t,i),n];case Xe.Top:return[t,n-kh(n-s,i)];case Xe.Bottom:return[t,n+kh(s-n,i)]}}function XP({sourceX:e,sourceY:t,sourcePosition:n=Xe.Bottom,targetX:r,targetY:s,targetPosition:i=Xe.Top,curvature:a=.25}){const[l,u]=VS({pos:n,x1:e,y1:t,x2:r,y2:s,c:a}),[d,f]=VS({pos:i,x1:r,y1:s,x2:e,y2:t,c:a}),[c,p,m,g]=GP({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:u,targetControlX:d,targetControlY:f});return[`M${e},${t} C${l},${u} ${d},${f} ${r},${s}`,c,p,m,g]}function JP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,i=n<e?n+s:n-s,a=Math.abs(r-t)/2,l=r<t?r+a:r-a;return[i,l,s,a]}function p3({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:s=!1,zIndexMode:i="basic"}){if(i==="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 h3({sourceNode:e,targetNode:t,width:n,height:r,transform:s}){const i=Vg(Km(e),Km(t));i.x===i.x2&&(i.x2+=1),i.y===i.y2&&(i.y2+=1);const a={x:-s[0]/s[2],y:-s[1]/s[2],width:n/s[2],height:r/s[2]};return $f(a,Ug(i))>0}const m3=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,g3=(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)),Ff=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||m3;let s;return FP(e)?s={...e}:s={...e,id:r(e)},g3(s,t)?t:(s.sourceHandle===null&&delete s.sourceHandle,s.targetHandle===null&&delete s.targetHandle,t.concat(s))};function QP({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,i,a,l]=JP({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,i,a,l]}const US={[Xe.Left]:{x:-1,y:0},[Xe.Right]:{x:1,y:0},[Xe.Top]:{x:0,y:-1},[Xe.Bottom]:{x:0,y:1}},y3=({source:e,sourcePosition:t=Xe.Bottom,target:n})=>t===Xe.Left||t===Xe.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},KS=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function x3({source:e,sourcePosition:t=Xe.Bottom,target:n,targetPosition:r=Xe.Top,center:s,offset:i,stepPosition:a}){const l=US[t],u=US[r],d={x:e.x+l.x*i,y:e.y+l.y*i},f={x:n.x+u.x*i,y:n.y+u.y*i},c=y3({source:d,sourcePosition:t,target:f}),p=c.x!==0?"x":"y",m=c[p];let g=[],b,k;const y={x:0,y:0},v={x:0,y:0},[,,w,j]=JP({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*u[p]===-1){p==="x"?(b=s.x??d.x+(f.x-d.x)*a,k=s.y??(d.y+f.y)/2):(b=s.x??(d.x+f.x)/2,k=s.y??d.y+(f.y-d.y)*a);const B=[{x:b,y:d.y},{x:b,y:f.y}],D=[{x:d.x,y:k},{x:f.x,y:k}];l[p]===m?g=p==="x"?B:D:g=p==="x"?D:B}else{const B=[{x:d.x,y:f.y}],D=[{x:f.x,y:d.y}];if(p==="x"?g=l.x===m?D:B:g=l.y===m?B:D,t===r){const O=Math.abs(e[p]-n[p]);if(O<=i){const $=Math.min(i-1,i-O);l[p]===m?y[p]=(d[p]>e[p]?-1:1)*$:v[p]=(f[p]>n[p]?-1:1)*$}}if(t!==r){const O=p==="x"?"y":"x",$=l[p]===u[O],I=d[O]>f[O],z=d[O]<f[O];(l[p]===1&&(!$&&I||$&&z)||l[p]!==1&&(!$&&z||$&&I))&&(g=p==="x"?B:D)}const F={x:d.x+y.x,y:d.y+y.y},R={x:f.x+v.x,y:f.y+v.y},M=Math.max(Math.abs(F.x-g[0].x),Math.abs(R.x-g[0].x)),W=Math.max(Math.abs(F.y-g[0].y),Math.abs(R.y-g[0].y));M>=W?(b=(F.x+R.x)/2,k=g[0].y):(b=g[0].x,k=(F.y+R.y)/2)}const P={x:d.x+y.x,y:d.y+y.y},_={x:f.x+v.x,y:f.y+v.y};return[[e,...P.x!==g[0].x||P.y!==g[0].y?[P]:[],...g,..._.x!==g[g.length-1].x||_.y!==g[g.length-1].y?[_]:[],n],b,k,w,j]}function w3(e,t,n,r){const s=Math.min(KS(e,t)/2,KS(t,n)/2,r),{x:i,y:a}=t;if(e.x===i&&i===n.x||e.y===a&&a===n.y)return`L${i} ${a}`;if(e.y===a){const d=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${i+s*d},${a}Q ${i},${a} ${i},${a+s*f}`}const l=e.x<n.x?1:-1,u=e.y<n.y?-1:1;return`L ${i},${a+s*u}Q ${i},${a} ${i+s*l},${a}`}function sb({sourceX:e,sourceY:t,sourcePosition:n=Xe.Bottom,targetX:r,targetY:s,targetPosition:i=Xe.Top,borderRadius:a=5,centerX:l,centerY:u,offset:d=20,stepPosition:f=.5}){const[c,p,m,g,b]=x3({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:i,center:{x:l,y:u},offset:d,stepPosition:f});let k=`M${c[0].x} ${c[0].y}`;for(let y=1;y<c.length-1;y++)k+=w3(c[y-1],c[y],c[y+1],a);return k+=`L${c[c.length-1].x} ${c[c.length-1].y}`,[k,p,m,g,b]}function qS(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function b3(e){var c;const{sourceNode:t,targetNode:n}=e;if(!qS(t)||!qS(n))return null;const r=t.internals.handleBounds||YS(t.handles),s=n.internals.handleBounds||YS(n.handles),i=GS((r==null?void 0:r.source)??[],e.sourceHandle),a=GS(e.connectionMode===Cu.Strict?(s==null?void 0:s.target)??[]:((s==null?void 0:s.target)??[]).concat((s==null?void 0:s.source)??[]),e.targetHandle);if(!i||!a)return(c=e.onError)==null||c.call(e,"008",Po.error008(i?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(i==null?void 0:i.position)||Xe.Bottom,u=(a==null?void 0:a.position)||Xe.Top,d=ac(t,i,l),f=ac(n,a,u);return{sourceX:d.x,sourceY:d.y,targetX:f.x,targetY:f.y,sourcePosition:l,targetPosition:u}}function YS(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 ac(e,t,n=Xe.Left,r=!1){const s=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,i=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??ha(e);if(r)return{x:s+a/2,y:i+l/2};switch((t==null?void 0:t.position)??n){case Xe.Top:return{x:s+a/2,y:i};case Xe.Right:return{x:s+a,y:i+l/2};case Xe.Bottom:return{x:s+a/2,y:i+l};case Xe.Left:return{x:s,y:i+l/2}}}function GS(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function ib(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function v3(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:s}){const i=new Set;return e.reduce((a,l)=>([l.markerStart||r,l.markerEnd||s].forEach(u=>{if(u&&typeof u=="object"){const d=ib(u,t);i.has(d)||(a.push({id:d,color:u.color||n,...u}),i.add(d))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const ZP=1e3,k3=10,Yv={nodeOrigin:[0,0],nodeExtent:Of,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},S3={...Yv,checkEquality:!0};function Gv(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function N3(e,t,n){const r=Gv(Yv,n);for(const s of e.values())if(s.parentId)Jv(s,e,t,r);else{const i=ap(s,r.nodeOrigin),a=Pu(s.extent)?s.extent:r.nodeExtent,l=oc(i,a,ha(s));s.internals.positionAbsolute=l}}function j3(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 i={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(i):s.type==="target"&&r.push(i)}return{source:n,target:r}}function Xv(e){return e==="manual"}function ob(e,t,n,r={}){var f,c;const s=Gv(S3,r),i={i:0},a=new Map(t),l=s!=null&&s.elevateNodesOnSelect&&!Xv(s.zIndexMode)?ZP:0;let u=e.length>0,d=!1;t.clear(),n.clear();for(const p of e){let m=a.get(p.id);if(s.checkEquality&&p===(m==null?void 0:m.internals.userNode))t.set(p.id,m);else{const g=ap(p,s.nodeOrigin),b=Pu(p.extent)?p.extent:s.nodeExtent,k=oc(g,b,ha(p));m={...s.defaults,...p,measured:{width:(f=p.measured)==null?void 0:f.width,height:(c=p.measured)==null?void 0:c.height},internals:{positionAbsolute:k,handleBounds:j3(p,m),z:eA(p,l,s.zIndexMode),userNode:p}},t.set(p.id,m)}(m.measured===void 0||m.measured.width===void 0||m.measured.height===void 0)&&!m.hidden&&(u=!1),p.parentId&&Jv(m,t,n,r,i),d||(d=p.selected??!1)}return{nodesInitialized:u,hasSelectedNodes:d}}function C3(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 Jv(e,t,n,r,s){const{elevateNodesOnSelect:i,nodeOrigin:a,nodeExtent:l,zIndexMode:u}=Gv(Yv,r),d=e.parentId,f=t.get(d);if(!f){console.warn(`Parent node ${d} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}C3(e,n),s&&!f.parentId&&f.internals.rootParentIndex===void 0&&u==="auto"&&(f.internals.rootParentIndex=++s.i,f.internals.z=f.internals.z+s.i*k3),s&&f.internals.rootParentIndex!==void 0&&(s.i=f.internals.rootParentIndex);const c=i&&!Xv(u)?ZP:0,{x:p,y:m,z:g}=E3(e,f,a,l,c,u),{positionAbsolute:b}=e.internals,k=p!==b.x||m!==b.y;(k||g!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:k?{x:p,y:m}:b,z:g}})}function eA(e,t,n){const r=qi(e.zIndex)?e.zIndex:0;return Xv(n)?r:r+(e.selected?t:0)}function E3(e,t,n,r,s,i){const{x:a,y:l}=t.internals.positionAbsolute,u=ha(e),d=ap(e,n),f=Pu(e.extent)?oc(d,e.extent,u):d;let c=oc({x:a+f.x,y:l+f.y},r,u);e.extent==="parent"&&(c=BP(c,u,t));const p=eA(e,s,i),m=t.internals.z??0;return{x:c.x,y:c.y,z:m>=p?m+1:p}}function Qv(e,t,n,r=[0,0]){var a;const s=[],i=new Map;for(const l of e){const u=t.get(l.parentId);if(!u)continue;const d=((a=i.get(l.parentId))==null?void 0:a.expandedRect)??_u(u),f=WP(d,l.rect);i.set(l.parentId,{expandedRect:f,parent:u})}return i.size>0&&i.forEach(({expandedRect:l,parent:u},d)=>{var w;const f=u.internals.positionAbsolute,c=ha(u),p=u.origin??r,m=l.x<f.x?Math.round(Math.abs(f.x-l.x)):0,g=l.y<f.y?Math.round(Math.abs(f.y-l.y)):0,b=Math.max(c.width,Math.round(l.width)),k=Math.max(c.height,Math.round(l.height)),y=(b-c.width)*p[0],v=(k-c.height)*p[1];(m>0||g>0||y||v)&&(s.push({id:d,type:"position",position:{x:u.position.x-m+y,y:u.position.y-g+v}}),(w=n.get(d))==null||w.forEach(j=>{e.some(P=>P.id===j.id)||s.push({id:j.id,type:"position",position:{x:j.position.x+m,y:j.position.y+g}})})),(c.width<l.width||c.height<l.height||m||g)&&s.push({id:d,type:"dimensions",setAttributes:!0,dimensions:{width:b+(m?p[0]*m-y:0),height:k+(g?p[1]*g-v:0)}})}),s}function _3(e,t,n,r,s,i,a){const l=r==null?void 0:r.querySelector(".xyflow__viewport");let u=!1;if(!l)return{changes:[],updatedInternals:u};const d=[],f=window.getComputedStyle(l),{m22:c}=new window.DOMMatrixReadOnly(f.transform),p=[];for(const m of e.values()){const g=t.get(m.id);if(!g)continue;if(g.hidden){t.set(g.id,{...g,internals:{...g.internals,handleBounds:void 0}}),u=!0;continue}const b=qv(m.nodeElement),k=g.measured.width!==b.width||g.measured.height!==b.height;if(!!(b.width&&b.height&&(k||!g.internals.handleBounds||m.force))){const v=m.nodeElement.getBoundingClientRect(),w=Pu(g.extent)?g.extent:i;let{positionAbsolute:j}=g.internals;g.parentId&&g.extent==="parent"?j=BP(j,b,t.get(g.parentId)):w&&(j=oc(j,w,b));const P={...g,measured:b,internals:{...g.internals,positionAbsolute:j,handleBounds:{source:WS("source",m.nodeElement,v,c,g.id),target:WS("target",m.nodeElement,v,c,g.id)}}};t.set(g.id,P),g.parentId&&Jv(P,t,n,{nodeOrigin:s,zIndexMode:a}),u=!0,k&&(d.push({id:g.id,type:"dimensions",dimensions:b}),g.expandParent&&g.parentId&&p.push({id:g.id,parentId:g.parentId,rect:_u(P,s)}))}}if(p.length>0){const m=Qv(p,t,n,s);d.push(...m)}return{changes:d,updatedInternals:u}}async function P3({delta:e,panZoom:t,transform:n,translateExtent:r,width:s,height:i}){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,i]],r),l=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(l)}function XS(e,t,n,r,s,i){let a=s;const l=r.get(a)||new Map;r.set(a,l.set(n,t)),a=`${s}-${e}`;const u=r.get(a)||new Map;if(r.set(a,u.set(n,t)),i){a=`${s}-${e}-${i}`;const d=r.get(a)||new Map;r.set(a,d.set(n,t))}}function tA(e,t,n){e.clear(),t.clear();for(const r of n){const{source:s,target:i,sourceHandle:a=null,targetHandle:l=null}=r,u={edgeId:r.id,source:s,target:i,sourceHandle:a,targetHandle:l},d=`${s}-${a}--${i}-${l}`,f=`${i}-${l}--${s}-${a}`;XS("source",u,f,e,s,a),XS("target",u,d,e,i,l),t.set(r.id,r)}}function nA(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:nA(n,t):!1}function JS(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 A3(e,t,n,r){const s=new Map;for(const[i,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!nA(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(i);l&&s.set(i,{id:i,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 ax({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,u;const s=[];for(const[d,f]of t){const c=(a=n.get(d))==null?void 0:a.internals.userNode;c&&s.push({...c,position:f.position,dragging:r})}if(!e)return[s[0],s];const i=(l=n.get(e))==null?void 0:l.internals.userNode;return[i?{...i,position:((u=t.get(e))==null?void 0:u.position)||i.position,dragging:r}:s[0],s]}function I3({dragItems:e,snapGrid:t,x:n,y:r}){const s=e.values().next().value;if(!s)return null;const i={x:n-s.distance.x,y:r-s.distance.y},a=cp(i,t);return{x:a.x-i.x,y:a.y-i.y}}function T3({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:s}){let i={x:null,y:null},a=0,l=new Map,u=!1,d={x:0,y:0},f=null,c=!1,p=null,m=!1,g=!1,b=null;function k({noDragClassName:v,handleSelector:w,domNode:j,isSelectable:P,nodeId:_,nodeClickDistance:L=0}){p=Xs(j);function B({x:M,y:W}){const{nodeLookup:O,nodeExtent:$,snapGrid:I,snapToGrid:z,nodeOrigin:C,onNodeDrag:T,onSelectionDrag:E,onError:G,updateNodePositions:Z}=t();i={x:M,y:W};let V=!1;const se=l.size>1,de=se&&$?rb(lp(l)):null,fe=se&&z?I3({dragItems:l,snapGrid:I,x:M,y:W}):null;for(const[pe,ae]of l){if(!O.has(pe))continue;let be={x:M-ae.distance.x,y:W-ae.distance.y};z&&(be=fe?{x:Math.round(be.x+fe.x),y:Math.round(be.y+fe.y)}:cp(be,I));let _e=null;if(se&&$&&!ae.extent&&de){const{positionAbsolute:Ie}=ae.internals,et=Ie.x-de.x+$[0][0],ft=Ie.x+ae.measured.width-de.x2+$[1][0],Je=Ie.y-de.y+$[0][1],bt=Ie.y+ae.measured.height-de.y2+$[1][1];_e=[[et,Je],[ft,bt]]}const{position:we,positionAbsolute:Oe}=zP({nodeId:pe,nextPosition:be,nodeLookup:O,nodeExtent:_e||$,nodeOrigin:C,onError:G});V=V||ae.position.x!==we.x||ae.position.y!==we.y,ae.position=we,ae.internals.positionAbsolute=Oe}if(g=g||V,!!V&&(Z(l,!0),b&&(r||T||!_&&E))){const[pe,ae]=ax({nodeId:_,dragItems:l,nodeLookup:O});r==null||r(b,l,pe,ae),T==null||T(b,pe,ae),_||E==null||E(b,ae)}}async function D(){if(!f)return;const{transform:M,panBy:W,autoPanSpeed:O,autoPanOnNodeDrag:$}=t();if(!$){u=!1,cancelAnimationFrame(a);return}const[I,z]=HP(d,f,O);(I!==0||z!==0)&&(i.x=(i.x??0)-I/M[2],i.y=(i.y??0)-z/M[2],await W({x:I,y:z})&&B(i)),a=requestAnimationFrame(D)}function F(M){var se;const{nodeLookup:W,multiSelectionActive:O,nodesDraggable:$,transform:I,snapGrid:z,snapToGrid:C,selectNodesOnDrag:T,onNodeDragStart:E,onSelectionDragStart:G,unselectNodesAndEdges:Z}=t();c=!0,(!T||!P)&&!O&&_&&((se=W.get(_))!=null&&se.selected||Z()),P&&T&&_&&(e==null||e(_));const V=sf(M.sourceEvent,{transform:I,snapGrid:z,snapToGrid:C,containerBounds:f});if(i=V,l=A3(W,$,V,_),l.size>0&&(n||E||!_&&G)){const[de,fe]=ax({nodeId:_,dragItems:l,nodeLookup:W});n==null||n(M.sourceEvent,l,de,fe),E==null||E(M.sourceEvent,de,fe),_||G==null||G(M.sourceEvent,fe)}}const R=wP().clickDistance(L).on("start",M=>{const{domNode:W,nodeDragThreshold:O,transform:$,snapGrid:I,snapToGrid:z}=t();f=(W==null?void 0:W.getBoundingClientRect())||null,m=!1,g=!1,b=M.sourceEvent,O===0&&F(M),i=sf(M.sourceEvent,{transform:$,snapGrid:I,snapToGrid:z,containerBounds:f}),d=Yi(M.sourceEvent,f)}).on("drag",M=>{const{autoPanOnNodeDrag:W,transform:O,snapGrid:$,snapToGrid:I,nodeDragThreshold:z,nodeLookup:C}=t(),T=sf(M.sourceEvent,{transform:O,snapGrid:$,snapToGrid:I,containerBounds:f});if(b=M.sourceEvent,(M.sourceEvent.type==="touchmove"&&M.sourceEvent.touches.length>1||_&&!C.has(_))&&(m=!0),!m){if(!u&&W&&c&&(u=!0,D()),!c){const E=Yi(M.sourceEvent,f),G=E.x-d.x,Z=E.y-d.y;Math.sqrt(G*G+Z*Z)>z&&F(M)}(i.x!==T.xSnapped||i.y!==T.ySnapped)&&l&&c&&(d=Yi(M.sourceEvent,f),B(T))}}).on("end",M=>{if(!(!c||m)&&(u=!1,c=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:W,updateNodePositions:O,onNodeDragStop:$,onSelectionDragStop:I}=t();if(g&&(O(l,!1),g=!1),s||$||!_&&I){const[z,C]=ax({nodeId:_,dragItems:l,nodeLookup:W,dragging:!1});s==null||s(M.sourceEvent,l,z,C),$==null||$(M.sourceEvent,z,C),_||I==null||I(M.sourceEvent,C)}}}).filter(M=>{const W=M.target;return!M.button&&(!v||!JS(W,`.${v}`,j))&&(!w||JS(W,w,j))});p.call(R)}function y(){p==null||p.on(".drag",null)}return{update:k,destroy:y}}function R3(e,t,n){const r=[],s={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const i of t.values())$f(s,_u(i))>0&&r.push(i);return r}const L3=250;function O3(e,t,n,r){var l,u;let s=[],i=1/0;const a=R3(e,n,t+L3);for(const d of a){const f=[...((l=d.internals.handleBounds)==null?void 0:l.source)??[],...((u=d.internals.handleBounds)==null?void 0:u.target)??[]];for(const c of f){if(r.nodeId===c.nodeId&&r.type===c.type&&r.id===c.id)continue;const{x:p,y:m}=ac(d,c,c.position,!0),g=Math.sqrt(Math.pow(p-e.x,2)+Math.pow(m-e.y,2));g>t||(g<i?(s=[{...c,x:p,y:m}],i=g):g===i&&s.push({...c,x:p,y:m}))}}if(!s.length)return null;if(s.length>1){const d=r.type==="source"?"target":"source";return s.find(f=>f.type===d)??s[0]}return s[0]}function rA(e,t,n,r,s,i=!1){var d,f,c;const a=r.get(e);if(!a)return null;const l=s==="strict"?(d=a.internals.handleBounds)==null?void 0:d[t]:[...((f=a.internals.handleBounds)==null?void 0:f.source)??[],...((c=a.internals.handleBounds)==null?void 0:c.target)??[]],u=(n?l==null?void 0:l.find(p=>p.id===n):l==null?void 0:l[0])??null;return u&&i?{...u,...ac(a,u,u.position,!0)}:u}function sA(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function M3(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const iA=()=>!0;function $3(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:s,edgeUpdaterType:i,isTarget:a,domNode:l,nodeLookup:u,lib:d,autoPanOnConnect:f,flowId:c,panBy:p,cancelConnection:m,onConnectStart:g,onConnect:b,onConnectEnd:k,isValidConnection:y=iA,onReconnectEnd:v,updateConnection:w,getTransform:j,getFromHandle:P,autoPanSpeed:_,dragThreshold:L=1,handleDomNode:B}){const D=KP(e.target);let F=0,R;const{x:M,y:W}=Yi(e),O=sA(i,B),$=l==null?void 0:l.getBoundingClientRect();let I=!1;if(!$||!O)return;const z=rA(s,O,r,u,t);if(!z)return;let C=Yi(e,$),T=!1,E=null,G=!1,Z=null;function V(){if(!f||!$)return;const[we,Oe]=HP(C,$,_);p({x:we,y:Oe}),F=requestAnimationFrame(V)}const se={...z,nodeId:s,type:O,position:z.position},de=u.get(s);let pe={inProgress:!0,isValid:null,from:ac(de,se,Xe.Left,!0),fromHandle:se,fromPosition:se.position,fromNode:de,to:C,toHandle:null,toPosition:FS[se.position],toNode:null,pointer:C};function ae(){I=!0,w(pe),g==null||g(e,{nodeId:s,handleId:r,handleType:O})}L===0&&ae();function be(we){if(!I){const{x:bt,y:Ve}=Yi(we),jt=bt-M,An=Ve-W;if(!(jt*jt+An*An>L*L))return;ae()}if(!P()||!se){_e(we);return}const Oe=j();C=Yi(we,$),R=O3(up(C,Oe,!1,[1,1]),n,u,se),T||(V(),T=!0);const Ie=oA(we,{handle:R,connectionMode:t,fromNodeId:s,fromHandleId:r,fromType:a?"target":"source",isValidConnection:y,doc:D,lib:d,flowId:c,nodeLookup:u});Z=Ie.handleDomNode,E=Ie.connection,G=M3(!!R,Ie.isValid);const et=u.get(s),ft=et?ac(et,se,Xe.Left,!0):pe.from,Je={...pe,from:ft,isValid:G,to:Ie.toHandle&&G?qm({x:Ie.toHandle.x,y:Ie.toHandle.y},Oe):C,toHandle:Ie.toHandle,toPosition:G&&Ie.toHandle?Ie.toHandle.position:FS[se.position],toNode:Ie.toHandle?u.get(Ie.toHandle.nodeId):null,pointer:C};w(Je),pe=Je}function _e(we){if(!("touches"in we&&we.touches.length>0)){if(I){(R||Z)&&E&&G&&(b==null||b(E));const{inProgress:Oe,...Ie}=pe,et={...Ie,toPosition:pe.toHandle?pe.toPosition:null};k==null||k(we,et),i&&(v==null||v(we,et))}m(),cancelAnimationFrame(F),T=!1,G=!1,E=null,Z=null,D.removeEventListener("mousemove",be),D.removeEventListener("mouseup",_e),D.removeEventListener("touchmove",be),D.removeEventListener("touchend",_e)}}D.addEventListener("mousemove",be),D.addEventListener("mouseup",_e),D.addEventListener("touchmove",be),D.addEventListener("touchend",_e)}function oA(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:s,fromType:i,doc:a,lib:l,flowId:u,isValidConnection:d=iA,nodeLookup:f}){const c=i==="target",p=t?a.querySelector(`.${l}-flow__handle[data-id="${u}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:m,y:g}=Yi(e),b=a.elementFromPoint(m,g),k=b!=null&&b.classList.contains(`${l}-flow__handle`)?b:p,y={handleDomNode:k,isValid:!1,connection:null,toHandle:null};if(k){const v=sA(void 0,k),w=k.getAttribute("data-nodeid"),j=k.getAttribute("data-handleid"),P=k.classList.contains("connectable"),_=k.classList.contains("connectableend");if(!w||!v)return y;const L={source:c?w:r,sourceHandle:c?j:s,target:c?r:w,targetHandle:c?s:j};y.connection=L;const D=P&&_&&(n===Cu.Strict?c&&v==="source"||!c&&v==="target":w!==r||j!==s);y.isValid=D&&d(L),y.toHandle=rA(w,v,j,f,n,!0)}return y}const ab={onPointerDown:$3,isValid:oA};function D3({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const s=Xs(e);function i({translateExtent:l,width:u,height:d,zoomStep:f=1,pannable:c=!0,zoomable:p=!0,inversePan:m=!1}){const g=w=>{if(w.sourceEvent.type!=="wheel"||!t)return;const j=n(),P=w.sourceEvent.ctrlKey&&Df()?10:1,_=-w.sourceEvent.deltaY*(w.sourceEvent.deltaMode===1?.05:w.sourceEvent.deltaMode?1:.002)*f,L=j[2]*Math.pow(2,_*P);t.scaleTo(L)};let b=[0,0];const k=w=>{(w.sourceEvent.type==="mousedown"||w.sourceEvent.type==="touchstart")&&(b=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY])},y=w=>{const j=n();if(w.sourceEvent.type!=="mousemove"&&w.sourceEvent.type!=="touchmove"||!t)return;const P=[w.sourceEvent.clientX??w.sourceEvent.touches[0].clientX,w.sourceEvent.clientY??w.sourceEvent.touches[0].clientY],_=[P[0]-b[0],P[1]-b[1]];b=P;const L=r()*Math.max(j[2],Math.log(j[2]))*(m?-1:1),B={x:j[0]-_[0]*L,y:j[1]-_[1]*L},D=[[0,0],[u,d]];t.setViewportConstrained({x:B.x,y:B.y,zoom:j[2]},D,l)},v=LP().on("start",k).on("zoom",c?y:null).on("zoom.wheel",p?g:null);s.call(v,{})}function a(){s.on("zoom",null)}return{update:i,destroy:a,pointer:Wi}}const Kg=e=>({x:e.x,y:e.y,zoom:e.k}),lx=({x:e,y:t,zoom:n})=>Wg.translate(e,t).scale(n),eu=(e,t)=>e.target.closest(`.${t}`),aA=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),F3=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,cx=(e,t=0,n=F3,r=()=>{})=>{const s=typeof t=="number"&&t>0;return s||r(),s?e.transition().duration(t).ease(n).on("end",r):e},lA=e=>{const t=e.ctrlKey&&Df()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function z3({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:s,panOnScrollSpeed:i,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:u,onPanZoomEnd:d}){return f=>{if(eu(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const c=n.property("__zoom").k||1;if(f.ctrlKey&&a){const k=Wi(f),y=lA(f),v=c*Math.pow(2,y);r.scaleTo(n,v,k,f);return}const p=f.deltaMode===1?20:1;let m=s===Gl.Vertical?0:f.deltaX*p,g=s===Gl.Horizontal?0:f.deltaY*p;!Df()&&f.shiftKey&&s!==Gl.Vertical&&(m=f.deltaY*p,g=0),r.translateBy(n,-(m/c)*i,-(g/c)*i,{internal:!0});const b=Kg(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(u==null||u(f,b),e.panScrollTimeout=setTimeout(()=>{d==null||d(f,b),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(f,b))}}function B3({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,s){const i=r.type==="wheel",a=!t&&i&&!r.ctrlKey,l=eu(r,e);if(r.ctrlKey&&i&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,s)}}function H3({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var i,a,l;if((i=r.sourceEvent)!=null&&i.internal)return;const s=Kg(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 W3({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:s}){return i=>{var a,l;e.usedRightMouseButton=!!(n&&aA(t,e.mouseButton??0)),(a=i.sourceEvent)!=null&&a.sync||r([i.transform.x,i.transform.y,i.transform.k]),s&&!((l=i.sourceEvent)!=null&&l.internal)&&(s==null||s(i.sourceEvent,Kg(i.transform)))}}function V3({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:s,onPaneContextMenu:i}){return a=>{var l;if(!((l=a.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,i&&aA(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&i(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),s)){const u=Kg(a.transform);e.prevViewport=u,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{s==null||s(a.sourceEvent,u)},n?150:0)}}}function U3({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:s,zoomOnDoubleClick:i,userSelectionActive:a,noWheelClassName:l,noPanClassName:u,lib:d,connectionInProgress:f}){return c=>{var k;const p=e||t,m=n&&c.ctrlKey,g=c.type==="wheel";if(c.button===1&&c.type==="mousedown"&&(eu(c,`${d}-flow__node`)||eu(c,`${d}-flow__edge`)))return!0;if(!r&&!p&&!s&&!i&&!n||a||f&&!g||eu(c,l)&&g||eu(c,u)&&(!g||s&&g&&!e)||!n&&c.ctrlKey&&g)return!1;if(!n&&c.type==="touchstart"&&((k=c.touches)==null?void 0:k.length)>1)return c.preventDefault(),!1;if(!p&&!s&&!m&&g||!r&&(c.type==="mousedown"||c.type==="touchstart")||Array.isArray(r)&&!r.includes(c.button)&&c.type==="mousedown")return!1;const b=Array.isArray(r)&&r.includes(c.button)||!c.button||c.button<=1;return(!c.ctrlKey||g)&&b}}function K3({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:s,onPanZoom:i,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:u}){const d={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),c=LP().scaleExtent([t,n]).translateExtent(r),p=Xs(e).call(c);v({x:s.x,y:s.y,zoom:Eu(s.zoom,t,n)},[[0,0],[f.width,f.height]],r);const m=p.on("wheel.zoom"),g=p.on("dblclick.zoom");c.wheelDelta(lA);function b(R,M){return p?new Promise(W=>{c==null||c.interpolate((M==null?void 0:M.interpolate)==="linear"?rf:nm).transform(cx(p,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>W(!0)),R)}):Promise.resolve(!1)}function k({noWheelClassName:R,noPanClassName:M,onPaneContextMenu:W,userSelectionActive:O,panOnScroll:$,panOnDrag:I,panOnScrollMode:z,panOnScrollSpeed:C,preventScrolling:T,zoomOnPinch:E,zoomOnScroll:G,zoomOnDoubleClick:Z,zoomActivationKeyPressed:V,lib:se,onTransformChange:de,connectionInProgress:fe,paneClickDistance:pe,selectionOnDrag:ae}){O&&!d.isZoomingOrPanning&&y();const be=$&&!V&&!O;c.clickDistance(ae?1/0:!qi(pe)||pe<0?0:pe);const _e=be?z3({zoomPanValues:d,noWheelClassName:R,d3Selection:p,d3Zoom:c,panOnScrollMode:z,panOnScrollSpeed:C,zoomOnPinch:E,onPanZoomStart:a,onPanZoom:i,onPanZoomEnd:l}):B3({noWheelClassName:R,preventScrolling:T,d3ZoomHandler:m});if(p.on("wheel.zoom",_e,{passive:!1}),!O){const Oe=H3({zoomPanValues:d,onDraggingChange:u,onPanZoomStart:a});c.on("start",Oe);const Ie=W3({zoomPanValues:d,panOnDrag:I,onPaneContextMenu:!!W,onPanZoom:i,onTransformChange:de});c.on("zoom",Ie);const et=V3({zoomPanValues:d,panOnDrag:I,panOnScroll:$,onPaneContextMenu:W,onPanZoomEnd:l,onDraggingChange:u});c.on("end",et)}const we=U3({zoomActivationKeyPressed:V,panOnDrag:I,zoomOnScroll:G,panOnScroll:$,zoomOnDoubleClick:Z,zoomOnPinch:E,userSelectionActive:O,noPanClassName:M,noWheelClassName:R,lib:se,connectionInProgress:fe});c.filter(we),Z?p.on("dblclick.zoom",g):p.on("dblclick.zoom",null)}function y(){c.on("zoom",null)}async function v(R,M,W){const O=lx(R),$=c==null?void 0:c.constrain()(O,M,W);return $&&await b($),new Promise(I=>I($))}async function w(R,M){const W=lx(R);return await b(W,M),new Promise(O=>O(W))}function j(R){if(p){const M=lx(R),W=p.property("__zoom");(W.k!==R.zoom||W.x!==R.x||W.y!==R.y)&&(c==null||c.transform(p,M,null,{sync:!0}))}}function P(){const R=p?RP(p.node()):{x:0,y:0,k:1};return{x:R.x,y:R.y,zoom:R.k}}function _(R,M){return p?new Promise(W=>{c==null||c.interpolate((M==null?void 0:M.interpolate)==="linear"?rf:nm).scaleTo(cx(p,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>W(!0)),R)}):Promise.resolve(!1)}function L(R,M){return p?new Promise(W=>{c==null||c.interpolate((M==null?void 0:M.interpolate)==="linear"?rf:nm).scaleBy(cx(p,M==null?void 0:M.duration,M==null?void 0:M.ease,()=>W(!0)),R)}):Promise.resolve(!1)}function B(R){c==null||c.scaleExtent(R)}function D(R){c==null||c.translateExtent(R)}function F(R){const M=!qi(R)||R<0?0:R;c==null||c.clickDistance(M)}return{update:k,destroy:y,setViewport:w,setViewportConstrained:v,getViewport:P,scaleTo:_,scaleBy:L,setScaleExtent:B,setTranslateExtent:D,syncViewport:j,setClickDistance:F}}var Au;(function(e){e.Line="line",e.Handle="handle"})(Au||(Au={}));function q3({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:s,affectsY:i}){const a=e-t,l=n-r,u=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&s&&(u[0]=u[0]*-1),l&&i&&(u[1]=u[1]*-1),u}function QS(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 Ia(e,t){return Math.max(0,t-e)}function Ta(e,t){return Math.max(0,e-t)}function Sh(e,t,n){return Math.max(0,t-e,e-n)}function ZS(e,t){return e?!t:t}function Y3(e,t,n,r,s,i,a,l){let{affectsX:u,affectsY:d}=t;const{isHorizontal:f,isVertical:c}=t,p=f&&c,{xSnapped:m,ySnapped:g}=n,{minWidth:b,maxWidth:k,minHeight:y,maxHeight:v}=r,{x:w,y:j,width:P,height:_,aspectRatio:L}=e;let B=Math.floor(f?m-e.pointerX:0),D=Math.floor(c?g-e.pointerY:0);const F=P+(u?-B:B),R=_+(d?-D:D),M=-i[0]*P,W=-i[1]*_;let O=Sh(F,b,k),$=Sh(R,y,v);if(a){let C=0,T=0;u&&B<0?C=Ia(w+B+M,a[0][0]):!u&&B>0&&(C=Ta(w+F+M,a[1][0])),d&&D<0?T=Ia(j+D+W,a[0][1]):!d&&D>0&&(T=Ta(j+R+W,a[1][1])),O=Math.max(O,C),$=Math.max($,T)}if(l){let C=0,T=0;u&&B>0?C=Ta(w+B,l[0][0]):!u&&B<0&&(C=Ia(w+F,l[1][0])),d&&D>0?T=Ta(j+D,l[0][1]):!d&&D<0&&(T=Ia(j+R,l[1][1])),O=Math.max(O,C),$=Math.max($,T)}if(s){if(f){const C=Sh(F/L,y,v)*L;if(O=Math.max(O,C),a){let T=0;!u&&!d||u&&!d&&p?T=Ta(j+W+F/L,a[1][1])*L:T=Ia(j+W+(u?B:-B)/L,a[0][1])*L,O=Math.max(O,T)}if(l){let T=0;!u&&!d||u&&!d&&p?T=Ia(j+F/L,l[1][1])*L:T=Ta(j+(u?B:-B)/L,l[0][1])*L,O=Math.max(O,T)}}if(c){const C=Sh(R*L,b,k)/L;if($=Math.max($,C),a){let T=0;!u&&!d||d&&!u&&p?T=Ta(w+R*L+M,a[1][0])/L:T=Ia(w+(d?D:-D)*L+M,a[0][0])/L,$=Math.max($,T)}if(l){let T=0;!u&&!d||d&&!u&&p?T=Ia(w+R*L,l[1][0])/L:T=Ta(w+(d?D:-D)*L,l[0][0])/L,$=Math.max($,T)}}}D=D+(D<0?$:-$),B=B+(B<0?O:-O),s&&(p?F>R*L?D=(ZS(u,d)?-B:B)/L:B=(ZS(u,d)?-D:D)*L:f?(D=B/L,d=u):(B=D*L,u=d));const I=u?w+B:w,z=d?j+D:j;return{width:P+(u?-B:B),height:_+(d?-D:D),x:i[0]*B*(u?-1:1)+I,y:i[1]*D*(d?-1:1)+z}}const cA={width:0,height:0,x:0,y:0},G3={...cA,pointerX:0,pointerY:0,aspectRatio:1};function X3(e){return[[0,0],[e.measured.width,e.measured.height]]}function J3(e,t,n){const r=t.position.x+e.position.x,s=t.position.y+e.position.y,i=e.measured.width??0,a=e.measured.height??0,l=n[0]*i,u=n[1]*a;return[[r-l,s-u],[r+i-l,s+a-u]]}function Q3({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:s}){const i=Xs(e);let a={controlDirection:QS("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:d,boundaries:f,keepAspectRatio:c,resizeDirection:p,onResizeStart:m,onResize:g,onResizeEnd:b,shouldResize:k}){let y={...cA},v={...G3};a={boundaries:f,resizeDirection:p,keepAspectRatio:c,controlDirection:QS(d)};let w,j=null,P=[],_,L,B,D=!1;const F=wP().on("start",R=>{const{nodeLookup:M,transform:W,snapGrid:O,snapToGrid:$,nodeOrigin:I,paneDomNode:z}=n();if(w=M.get(t),!w)return;j=(z==null?void 0:z.getBoundingClientRect())??null;const{xSnapped:C,ySnapped:T}=sf(R.sourceEvent,{transform:W,snapGrid:O,snapToGrid:$,containerBounds:j});y={width:w.measured.width??0,height:w.measured.height??0,x:w.position.x??0,y:w.position.y??0},v={...y,pointerX:C,pointerY:T,aspectRatio:y.width/y.height},_=void 0,w.parentId&&(w.extent==="parent"||w.expandParent)&&(_=M.get(w.parentId),L=_&&w.extent==="parent"?X3(_):void 0),P=[],B=void 0;for(const[E,G]of M)if(G.parentId===t&&(P.push({id:E,position:{...G.position},extent:G.extent}),G.extent==="parent"||G.expandParent)){const Z=J3(G,w,G.origin??I);B?B=[[Math.min(Z[0][0],B[0][0]),Math.min(Z[0][1],B[0][1])],[Math.max(Z[1][0],B[1][0]),Math.max(Z[1][1],B[1][1])]]:B=Z}m==null||m(R,{...y})}).on("drag",R=>{const{transform:M,snapGrid:W,snapToGrid:O,nodeOrigin:$}=n(),I=sf(R.sourceEvent,{transform:M,snapGrid:W,snapToGrid:O,containerBounds:j}),z=[];if(!w)return;const{x:C,y:T,width:E,height:G}=y,Z={},V=w.origin??$,{width:se,height:de,x:fe,y:pe}=Y3(v,a.controlDirection,I,a.boundaries,a.keepAspectRatio,V,L,B),ae=se!==E,be=de!==G,_e=fe!==C&&ae,we=pe!==T&&be;if(!_e&&!we&&!ae&&!be)return;if((_e||we||V[0]===1||V[1]===1)&&(Z.x=_e?fe:y.x,Z.y=we?pe:y.y,y.x=Z.x,y.y=Z.y,P.length>0)){const ft=fe-C,Je=pe-T;for(const bt of P)bt.position={x:bt.position.x-ft+V[0]*(se-E),y:bt.position.y-Je+V[1]*(de-G)},z.push(bt)}if((ae||be)&&(Z.width=ae&&(!a.resizeDirection||a.resizeDirection==="horizontal")?se:y.width,Z.height=be&&(!a.resizeDirection||a.resizeDirection==="vertical")?de:y.height,y.width=Z.width,y.height=Z.height),_&&w.expandParent){const ft=V[0]*(Z.width??0);Z.x&&Z.x<ft&&(y.x=ft,v.x=v.x-(Z.x-ft));const Je=V[1]*(Z.height??0);Z.y&&Z.y<Je&&(y.y=Je,v.y=v.y-(Z.y-Je))}const Oe=q3({width:y.width,prevWidth:E,height:y.height,prevHeight:G,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),Ie={...y,direction:Oe};(k==null?void 0:k(R,Ie))!==!1&&(D=!0,g==null||g(R,Ie),r(Z,z))}).on("end",R=>{D&&(b==null||b(R,{...y}),s==null||s({...y}),D=!1)});i.call(F)}function u(){i.on(".drag",null)}return{update:l,destroy:u}}var uA={exports:{}},dA={},fA={exports:{}},pA={};/**
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 Iu=h;function Z3(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var e5=typeof Object.is=="function"?Object.is:Z3,t5=Iu.useState,n5=Iu.useEffect,r5=Iu.useLayoutEffect,s5=Iu.useDebugValue;function i5(e,t){var n=t(),r=t5({inst:{value:n,getSnapshot:t}}),s=r[0].inst,i=r[1];return r5(function(){s.value=n,s.getSnapshot=t,ux(s)&&i({inst:s})},[e,n,t]),n5(function(){return ux(s)&&i({inst:s}),e(function(){ux(s)&&i({inst:s})})},[e]),s5(n),n}function ux(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!e5(e,n)}catch{return!0}}function o5(e,t){return t()}var a5=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?o5:i5;pA.useSyncExternalStore=Iu.useSyncExternalStore!==void 0?Iu.useSyncExternalStore:a5;fA.exports=pA;var hA=fA.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 qg=h,l5=hA;function c5(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var u5=typeof Object.is=="function"?Object.is:c5,d5=l5.useSyncExternalStore,f5=qg.useRef,p5=qg.useEffect,h5=qg.useMemo,m5=qg.useDebugValue;dA.useSyncExternalStoreWithSelector=function(e,t,n,r,s){var i=f5(null);if(i.current===null){var a={hasValue:!1,value:null};i.current=a}else a=i.current;i=h5(function(){function u(m){if(!d){if(d=!0,f=m,m=r(m),s!==void 0&&a.hasValue){var g=a.value;if(s(g,m))return c=g}return c=m}if(g=c,u5(f,m))return g;var b=r(m);return s!==void 0&&s(g,b)?(f=m,g):(f=m,c=b)}var d=!1,f,c,p=n===void 0?null:n;return[function(){return u(t())},p===null?void 0:function(){return u(p())}]},[t,n,r,s]);var l=d5(e,i[0],i[1]);return p5(function(){a.hasValue=!0,a.value=l},[l]),m5(l),l};uA.exports=dA;var g5=uA.exports;const y5=ul(g5),x5={},eN=e=>{let t;const n=new Set,r=(f,c)=>{const p=typeof f=="function"?f(t):f;if(!Object.is(p,t)){const m=t;t=c??(typeof p!="object"||p===null)?p:Object.assign({},t,p),n.forEach(g=>g(t,m))}},s=()=>t,u={setState:r,getState:s,getInitialState:()=>d,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(x5?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},d=t=e(r,s,u);return u},w5=e=>e?eN(e):eN,{useDebugValue:b5}=lt,{useSyncExternalStoreWithSelector:v5}=y5,k5=e=>e;function mA(e,t=k5,n){const r=v5(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return b5(r),r}const tN=(e,t)=>{const n=w5(e),r=(s,i=t)=>mA(n,s,i);return Object.assign(r,n),r},S5=(e,t)=>e?tN(e,t):tN;function Hn(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 Yg=h.createContext(null),N5=Yg.Provider,gA=Po.error001();function Ht(e,t){const n=h.useContext(Yg);if(n===null)throw new Error(gA);return mA(n,e,t)}function Dn(){const e=h.useContext(Yg);if(e===null)throw new Error(gA);return h.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const nN={display:"none"},j5={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},yA="react-flow__node-desc",xA="react-flow__edge-desc",C5="react-flow__aria-live",E5=e=>e.ariaLiveMessage,_5=e=>e.ariaLabelConfig;function P5({rfId:e}){const t=Ht(E5);return o.jsx("div",{id:`${C5}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:j5,children:t})}function A5({rfId:e,disableKeyboardA11y:t}){const n=Ht(_5);return o.jsxs(o.Fragment,{children:[o.jsx("div",{id:`${yA}-${e}`,style:nN,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),o.jsx("div",{id:`${xA}-${e}`,style:nN,children:n["edge.a11yDescription.default"]}),!t&&o.jsx(P5,{rfId:e})]})}const Tu=h.forwardRef(({position:e="top-left",children:t,className:n,style:r,...s},i)=>{const a=`${e}`.split("-");return o.jsx("div",{className:gr(["react-flow__panel",n,...a]),style:r,ref:i,...s,children:t})});Tu.displayName="Panel";function I5({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:o.jsx(Tu,{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:o.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const T5=e=>{const t=[],n=[];for(const[,r]of e.nodeLookup)r.selected&&t.push(r.internals.userNode);for(const[,r]of e.edgeLookup)r.selected&&n.push(r);return{selectedNodes:t,selectedEdges:n}},Nh=e=>e.id;function R5(e,t){return Hn(e.selectedNodes.map(Nh),t.selectedNodes.map(Nh))&&Hn(e.selectedEdges.map(Nh),t.selectedEdges.map(Nh))}function L5({onSelectionChange:e}){const t=Dn(),{selectedNodes:n,selectedEdges:r}=Ht(T5,R5);return h.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChangeHandlers.forEach(i=>i(s))},[n,r,e]),null}const O5=e=>!!e.onSelectionChangeHandlers;function M5({onSelectionChange:e}){const t=Ht(O5);return e||t?o.jsx(L5,{onSelectionChange:e}):null}const lb=typeof window<"u"?h.useLayoutEffect:h.useEffect,wA=[0,0],$5={x:0,y:0,zoom:1},D5=["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"],rN=[...D5,"rfId"],F5=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}),sN={translateExtent:Of,nodeOrigin:wA,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function z5(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:s,setTranslateExtent:i,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:u}=Ht(F5,Hn),d=Dn();lb(()=>(u(e.defaultNodes,e.defaultEdges),()=>{f.current=sN,l()}),[]);const f=h.useRef(sN);return lb(()=>{for(const c of rN){const p=e[c],m=f.current[c];p!==m&&(typeof e[c]>"u"||(c==="nodes"?t(p):c==="edges"?n(p):c==="minZoom"?r(p):c==="maxZoom"?s(p):c==="translateExtent"?i(p):c==="nodeExtent"?a(p):c==="ariaLabelConfig"?d.setState({ariaLabelConfig:d3(p)}):c==="fitView"?d.setState({fitViewQueued:p}):c==="fitViewOptions"?d.setState({fitViewOptions:p}):d.setState({[c]:p})))}f.current=e},rN.map(c=>e[c])),null}function iN(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function B5(e){var r;const[t,n]=h.useState(e==="system"?null:e);return h.useEffect(()=>{if(e!=="system"){n(e);return}const s=iN(),i=()=>n(s!=null&&s.matches?"dark":"light");return i(),s==null||s.addEventListener("change",i),()=>{s==null||s.removeEventListener("change",i)}},[e]),t!==null?t:(r=iN())!=null&&r.matches?"dark":"light"}const oN=typeof document<"u"?document:null;function zf(e=null,t={target:oN,actInsideInputWithModifier:!0}){const[n,r]=h.useState(!1),s=h.useRef(!1),i=h.useRef(new Set([])),[a,l]=h.useMemo(()=>{if(e!==null){const d=(Array.isArray(e)?e:[e]).filter(c=>typeof c=="string").map(c=>c.replace("+",`
61
- `).replace(`
62
-
63
- `,`
64
- +`).split(`
65
- `)),f=d.reduce((c,p)=>c.concat(...p),[]);return[d,f]}return[[],[]]},[e]);return h.useEffect(()=>{const u=(t==null?void 0:t.target)??oN,d=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const f=m=>{var k,y;if(s.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!s.current||s.current&&!d)&&qP(m))return!1;const b=lN(m.code,l);if(i.current.add(m[b]),aN(a,i.current,!1)){const v=((y=(k=m.composedPath)==null?void 0:k.call(m))==null?void 0:y[0])||m.target,w=(v==null?void 0:v.nodeName)==="BUTTON"||(v==null?void 0:v.nodeName)==="A";t.preventDefault!==!1&&(s.current||!w)&&m.preventDefault(),r(!0)}},c=m=>{const g=lN(m.code,l);aN(a,i.current,!0)?(r(!1),i.current.clear()):i.current.delete(m[g]),m.key==="Meta"&&i.current.clear(),s.current=!1},p=()=>{i.current.clear(),r(!1)};return u==null||u.addEventListener("keydown",f),u==null||u.addEventListener("keyup",c),window.addEventListener("blur",p),window.addEventListener("contextmenu",p),()=>{u==null||u.removeEventListener("keydown",f),u==null||u.removeEventListener("keyup",c),window.removeEventListener("blur",p),window.removeEventListener("contextmenu",p)}}},[e,r]),n}function aN(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function lN(e,t){return t.includes(e)?"code":"key"}const H5=()=>{const e=Dn();return h.useMemo(()=>({zoomIn:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):Promise.resolve(!1)},zoomOut:t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):Promise.resolve(!1)},zoomTo:(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,s,i],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??s,zoom:t.zoom??i},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:i,maxZoom:a,panZoom:l}=e.getState(),u=Kv(t,r,s,i,a,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(u,{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:i,domNode:a}=e.getState();if(!a)return t;const{x:l,y:u}=a.getBoundingClientRect(),d={x:t.x-l,y:t.y-u},f=n.snapGrid??s,c=n.snapToGrid??i;return up(d,r,c,f)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:s,y:i}=r.getBoundingClientRect(),a=qm(t,n);return{x:a.x+s,y:a.y+i}}}),[])};function bA(e,t){const n=[],r=new Map,s=[];for(const i of e)if(i.type==="add"){s.push(i);continue}else if(i.type==="remove"||i.type==="replace")r.set(i.id,[i]);else{const a=r.get(i.id);a?a.push(i):r.set(i.id,[i])}for(const i of t){const a=r.get(i.id);if(!a){n.push(i);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const l={...i};for(const u of a)W5(u,l);n.push(l)}return s.length&&s.forEach(i=>{i.index!==void 0?n.splice(i.index,0,{...i.item}):n.push({...i.item})}),n}function W5(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 Ym(e,t){return bA(e,t)}function Zv(e,t){return bA(e,t)}function Fl(e,t){return{id:e,type:"select",selected:t}}function tu(e,t=new Set,n=!1){const r=[];for(const[s,i]of e){const a=t.has(s);!(i.selected===void 0&&!a)&&i.selected!==a&&(n&&(i.selected=a),r.push(Fl(i.id,a)))}return r}function cN({items:e=[],lookup:t}){var s;const n=[],r=new Map(e.map(i=>[i.id,i]));for(const[i,a]of e.entries()){const l=t.get(a.id),u=((s=l==null?void 0:l.internals)==null?void 0:s.userNode)??l;u!==void 0&&u!==a&&n.push({id:a.id,item:a,type:"replace"}),u===void 0&&n.push({item:a,type:"add",index:i})}for(const[i]of t)r.get(i)===void 0&&n.push({id:i,type:"remove"});return n}function uN(e){return{id:e.id,type:"remove"}}const dN=e=>t3(e),V5=e=>FP(e);function vA(e){return h.forwardRef(e)}function fN(e){const[t,n]=h.useState(BigInt(0)),[r]=h.useState(()=>U5(()=>n(s=>s+BigInt(1))));return lb(()=>{const s=r.get();s.length&&(e(s),r.reset())},[t]),r}function U5(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const kA=h.createContext(null);function K5({children:e}){const t=Dn(),n=h.useCallback(l=>{const{nodes:u=[],setNodes:d,hasDefaultNodes:f,onNodesChange:c,nodeLookup:p,fitViewQueued:m,onNodesChangeMiddlewareMap:g}=t.getState();let b=u;for(const y of l)b=typeof y=="function"?y(b):y;let k=cN({items:b,lookup:p});for(const y of g.values())k=y(k);f&&d(b),k.length>0?c==null||c(k):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:v,setNodes:w}=t.getState();y&&w(v)})},[]),r=fN(n),s=h.useCallback(l=>{const{edges:u=[],setEdges:d,hasDefaultEdges:f,onEdgesChange:c,edgeLookup:p}=t.getState();let m=u;for(const g of l)m=typeof g=="function"?g(m):g;f?d(m):c&&c(cN({items:m,lookup:p}))},[]),i=fN(s),a=h.useMemo(()=>({nodeQueue:r,edgeQueue:i}),[]);return o.jsx(kA.Provider,{value:a,children:e})}function q5(){const e=h.useContext(kA);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const Y5=e=>!!e.panZoom;function fc(){const e=H5(),t=Dn(),n=q5(),r=Ht(Y5),s=h.useMemo(()=>{const i=c=>t.getState().nodeLookup.get(c),a=c=>{n.nodeQueue.push(c)},l=c=>{n.edgeQueue.push(c)},u=c=>{var y,v;const{nodeLookup:p,nodeOrigin:m}=t.getState(),g=dN(c)?c:p.get(c.id),b=g.parentId?UP(g.position,g.measured,g.parentId,p,m):g.position,k={...g,position:b,width:((y=g.measured)==null?void 0:y.width)??g.width,height:((v=g.measured)==null?void 0:v.height)??g.height};return _u(k)},d=(c,p,m={replace:!1})=>{a(g=>g.map(b=>{if(b.id===c){const k=typeof p=="function"?p(b):p;return m.replace&&dN(k)?k:{...b,...k}}return b}))},f=(c,p,m={replace:!1})=>{l(g=>g.map(b=>{if(b.id===c){const k=typeof p=="function"?p(b):p;return m.replace&&V5(k)?k:{...b,...k}}return b}))};return{getNodes:()=>t.getState().nodes.map(c=>({...c})),getNode:c=>{var p;return(p=i(c))==null?void 0:p.internals.userNode},getInternalNode:i,getEdges:()=>{const{edges:c=[]}=t.getState();return c.map(p=>({...p}))},getEdge:c=>t.getState().edgeLookup.get(c),setNodes:a,setEdges:l,addNodes:c=>{const p=Array.isArray(c)?c:[c];n.nodeQueue.push(m=>[...m,...p])},addEdges:c=>{const p=Array.isArray(c)?c:[c];n.edgeQueue.push(m=>[...m,...p])},toObject:()=>{const{nodes:c=[],edges:p=[],transform:m}=t.getState(),[g,b,k]=m;return{nodes:c.map(y=>({...y})),edges:p.map(y=>({...y})),viewport:{x:g,y:b,zoom:k}}},deleteElements:async({nodes:c=[],edges:p=[]})=>{const{nodes:m,edges:g,onNodesDelete:b,onEdgesDelete:k,triggerNodeChanges:y,triggerEdgeChanges:v,onDelete:w,onBeforeDelete:j}=t.getState(),{nodes:P,edges:_}=await o3({nodesToRemove:c,edgesToRemove:p,nodes:m,edges:g,onBeforeDelete:j}),L=_.length>0,B=P.length>0;if(L){const D=_.map(uN);k==null||k(_),v(D)}if(B){const D=P.map(uN);b==null||b(P),y(D)}return(B||L)&&(w==null||w({nodes:P,edges:_})),{deletedNodes:P,deletedEdges:_}},getIntersectingNodes:(c,p=!0,m)=>{const g=BS(c),b=g?c:u(c),k=m!==void 0;return b?(m||t.getState().nodes).filter(y=>{const v=t.getState().nodeLookup.get(y.id);if(v&&!g&&(y.id===c.id||!v.internals.positionAbsolute))return!1;const w=_u(k?y:v),j=$f(w,b);return p&&j>0||j>=w.width*w.height||j>=b.width*b.height}):[]},isNodeIntersecting:(c,p,m=!0)=>{const b=BS(c)?c:u(c);if(!b)return!1;const k=$f(b,p);return m&&k>0||k>=p.width*p.height||k>=b.width*b.height},updateNode:d,updateNodeData:(c,p,m={replace:!1})=>{d(c,g=>{const b=typeof p=="function"?p(g):p;return m.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},m)},updateEdge:f,updateEdgeData:(c,p,m={replace:!1})=>{f(c,g=>{const b=typeof p=="function"?p(g):p;return m.replace?{...g,data:b}:{...g,data:{...g.data,...b}}},m)},getNodesBounds:c=>{const{nodeLookup:p,nodeOrigin:m}=t.getState();return n3(c,{nodeLookup:p,nodeOrigin:m})},getHandleConnections:({type:c,id:p,nodeId:m})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${m}-${c}${p?`-${p}`:""}`))==null?void 0:g.values())??[])},getNodeConnections:({type:c,handleId:p,nodeId:m})=>{var g;return Array.from(((g=t.getState().connectionLookup.get(`${m}${c?p?`-${c}-${p}`:`-${c}`:""}`))==null?void 0:g.values())??[])},fitView:async c=>{const p=t.getState().fitViewResolver??u3();return t.setState({fitViewQueued:!0,fitViewOptions:c,fitViewResolver:p}),n.nodeQueue.push(m=>[...m]),p.promise}}},[]);return h.useMemo(()=>({...s,...e,viewportInitialized:r}),[r])}const pN=e=>e.selected,G5=typeof window<"u"?window:void 0;function X5({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Dn(),{deleteElements:r}=fc(),s=zf(e,{actInsideInputWithModifier:!1}),i=zf(t,{target:G5});h.useEffect(()=>{if(s){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(pN),edges:a.filter(pN)}),n.setState({nodesSelectionActive:!1})}},[s]),h.useEffect(()=>{n.setState({multiSelectionActive:i})},[i])}function J5(e){const t=Dn();h.useEffect(()=>{const n=()=>{var s,i,a,l;if(!e.current||!(((i=(s=e.current).checkVisibility)==null?void 0:i.call(s))??!0))return!1;const r=qv(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Po.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 Gg={position:"absolute",width:"100%",height:"100%",top:0,left:0},Q5=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Z5({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:s=.5,panOnScrollMode:i=Gl.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:u,translateExtent:d,minZoom:f,maxZoom:c,zoomActivationKeyCode:p,preventScrolling:m=!0,children:g,noWheelClassName:b,noPanClassName:k,onViewportChange:y,isControlledViewport:v,paneClickDistance:w,selectionOnDrag:j}){const P=Dn(),_=h.useRef(null),{userSelectionActive:L,lib:B,connectionInProgress:D}=Ht(Q5,Hn),F=zf(p),R=h.useRef();J5(_);const M=h.useCallback(W=>{y==null||y({x:W[0],y:W[1],zoom:W[2]}),v||P.setState({transform:W})},[y,v]);return h.useEffect(()=>{if(_.current){R.current=K3({domNode:_.current,minZoom:f,maxZoom:c,translateExtent:d,viewport:u,onDraggingChange:I=>P.setState(z=>z.paneDragging===I?z:{paneDragging:I}),onPanZoomStart:(I,z)=>{const{onViewportChangeStart:C,onMoveStart:T}=P.getState();T==null||T(I,z),C==null||C(z)},onPanZoom:(I,z)=>{const{onViewportChange:C,onMove:T}=P.getState();T==null||T(I,z),C==null||C(z)},onPanZoomEnd:(I,z)=>{const{onViewportChangeEnd:C,onMoveEnd:T}=P.getState();T==null||T(I,z),C==null||C(z)}});const{x:W,y:O,zoom:$}=R.current.getViewport();return P.setState({panZoom:R.current,transform:[W,O,$],domNode:_.current.closest(".react-flow")}),()=>{var I;(I=R.current)==null||I.destroy()}}},[]),h.useEffect(()=>{var W;(W=R.current)==null||W.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:F,preventScrolling:m,noPanClassName:k,userSelectionActive:L,noWheelClassName:b,lib:B,onTransformChange:M,connectionInProgress:D,selectionOnDrag:j,paneClickDistance:w})},[e,t,n,r,s,i,a,l,F,m,k,L,b,B,M,D,j,w]),o.jsx("div",{className:"react-flow__renderer",ref:_,style:Gg,children:g})}const e4=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function t4(){const{userSelectionActive:e,userSelectionRect:t}=Ht(e4,Hn);return e&&t?o.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 dx=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},n4=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function r4({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Mf.Full,panOnDrag:r,paneClickDistance:s,selectionOnDrag:i,onSelectionStart:a,onSelectionEnd:l,onPaneClick:u,onPaneContextMenu:d,onPaneScroll:f,onPaneMouseEnter:c,onPaneMouseMove:p,onPaneMouseLeave:m,children:g}){const b=Dn(),{userSelectionActive:k,elementsSelectable:y,dragging:v,connectionInProgress:w}=Ht(n4,Hn),j=y&&(e||k),P=h.useRef(null),_=h.useRef(),L=h.useRef(new Set),B=h.useRef(new Set),D=h.useRef(!1),F=C=>{if(D.current||w){D.current=!1;return}u==null||u(C),b.getState().resetSelectedElements(),b.setState({nodesSelectionActive:!1})},R=C=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){C.preventDefault();return}d==null||d(C)},M=f?C=>f(C):void 0,W=C=>{D.current&&(C.stopPropagation(),D.current=!1)},O=C=>{var de,fe;const{domNode:T}=b.getState();if(_.current=T==null?void 0:T.getBoundingClientRect(),!_.current)return;const E=C.target===P.current;if(!E&&!!C.target.closest(".nokey")||!e||!(i&&E||t)||C.button!==0||!C.isPrimary)return;(fe=(de=C.target)==null?void 0:de.setPointerCapture)==null||fe.call(de,C.pointerId),D.current=!1;const{x:V,y:se}=Yi(C.nativeEvent,_.current);b.setState({userSelectionRect:{width:0,height:0,startX:V,startY:se,x:V,y:se}}),E||(C.stopPropagation(),C.preventDefault())},$=C=>{const{userSelectionRect:T,transform:E,nodeLookup:G,edgeLookup:Z,connectionLookup:V,triggerNodeChanges:se,triggerEdgeChanges:de,defaultEdgeOptions:fe,resetSelectedElements:pe}=b.getState();if(!_.current||!T)return;const{x:ae,y:be}=Yi(C.nativeEvent,_.current),{startX:_e,startY:we}=T;if(!D.current){const Je=t?0:s;if(Math.hypot(ae-_e,be-we)<=Je)return;pe(),a==null||a(C)}D.current=!0;const Oe={startX:_e,startY:we,x:ae<_e?ae:_e,y:be<we?be:we,width:Math.abs(ae-_e),height:Math.abs(be-we)},Ie=L.current,et=B.current;L.current=new Set(Uv(G,Oe,E,n===Mf.Partial,!0).map(Je=>Je.id)),B.current=new Set;const ft=(fe==null?void 0:fe.selectable)??!0;for(const Je of L.current){const bt=V.get(Je);if(bt)for(const{edgeId:Ve}of bt.values()){const jt=Z.get(Ve);jt&&(jt.selectable??ft)&&B.current.add(Ve)}}if(!HS(Ie,L.current)){const Je=tu(G,L.current,!0);se(Je)}if(!HS(et,B.current)){const Je=tu(Z,B.current);de(Je)}b.setState({userSelectionRect:Oe,userSelectionActive:!0,nodesSelectionActive:!1})},I=C=>{var T,E;C.button===0&&((E=(T=C.target)==null?void 0:T.releasePointerCapture)==null||E.call(T,C.pointerId),!k&&C.target===P.current&&b.getState().userSelectionRect&&(F==null||F(C)),b.setState({userSelectionActive:!1,userSelectionRect:null}),D.current&&(l==null||l(C),b.setState({nodesSelectionActive:L.current.size>0})))},z=r===!0||Array.isArray(r)&&r.includes(0);return o.jsxs("div",{className:gr(["react-flow__pane",{draggable:z,dragging:v,selection:e}]),onClick:j?void 0:dx(F,P),onContextMenu:dx(R,P),onWheel:dx(M,P),onPointerEnter:j?void 0:c,onPointerMove:j?$:p,onPointerUp:j?I:void 0,onPointerDownCapture:j?O:void 0,onClickCapture:j?W:void 0,onPointerLeave:m,ref:P,style:Gg,children:[g,o.jsx(t4,{})]})}function cb({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:i,multiSelectionActive:a,nodeLookup:l,onError:u}=t.getState(),d=l.get(e);if(!d){u==null||u("012",Po.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&a)&&(i({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):s([e])}function SA({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:i,nodeClickDistance:a}){const l=Dn(),[u,d]=h.useState(!1),f=h.useRef();return h.useEffect(()=>{f.current=T3({getStoreItems:()=>l.getState(),onNodeMouseDown:c=>{cb({id:c,store:l,nodeRef:e})},onDragStart:()=>{d(!0)},onDragStop:()=>{d(!1)}})},[]),h.useEffect(()=>{if(!(t||!e.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:i,nodeId:s,nodeClickDistance:a}),()=>{var c;(c=f.current)==null||c.destroy()}},[n,r,t,i,e,s,a]),u}const s4=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function NA(){const e=Dn();return h.useCallback(n=>{const{nodeExtent:r,snapToGrid:s,snapGrid:i,nodesDraggable:a,onError:l,updateNodePositions:u,nodeLookup:d,nodeOrigin:f}=e.getState(),c=new Map,p=s4(a),m=s?i[0]:5,g=s?i[1]:5,b=n.direction.x*m*n.factor,k=n.direction.y*g*n.factor;for(const[,y]of d){if(!p(y))continue;let v={x:y.internals.positionAbsolute.x+b,y:y.internals.positionAbsolute.y+k};s&&(v=cp(v,i));const{position:w,positionAbsolute:j}=zP({nodeId:y.id,nextPosition:v,nodeLookup:d,nodeExtent:r,nodeOrigin:f,onError:l});y.position=w,y.internals.positionAbsolute=j,c.set(y.id,y)}u(c)},[])}const e0=h.createContext(null),i4=e0.Provider;e0.Consumer;const jA=()=>h.useContext(e0),o4=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),a4=(e,t,n)=>r=>{const{connectionClickStartHandle:s,connectionMode:i,connection:a}=r,{fromHandle:l,toHandle:u,isValid:d}=a,f=(u==null?void 0:u.nodeId)===e&&(u==null?void 0:u.id)===t&&(u==null?void 0:u.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:f,clickConnecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.id)===t&&(s==null?void 0:s.type)===n,isPossibleEndHandle:i===Cu.Strict?(l==null?void 0:l.type)!==n:e!==(l==null?void 0:l.nodeId)||t!==(l==null?void 0:l.id),connectionInProcess:!!l,clickConnectionInProcess:!!s,valid:f&&d}};function l4({type:e="source",position:t=Xe.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:i=!0,id:a,onConnect:l,children:u,className:d,onMouseDown:f,onTouchStart:c,...p},m){var $,I;const g=a||null,b=e==="target",k=Dn(),y=jA(),{connectOnClick:v,noPanClassName:w,rfId:j}=Ht(o4,Hn),{connectingFrom:P,connectingTo:_,clickConnecting:L,isPossibleEndHandle:B,connectionInProcess:D,clickConnectionInProcess:F,valid:R}=Ht(a4(y,g,e),Hn);y||(I=($=k.getState()).onError)==null||I.call($,"010",Po.error010());const M=z=>{const{defaultEdgeOptions:C,onConnect:T,hasDefaultEdges:E}=k.getState(),G={...C,...z};if(E){const{edges:Z,setEdges:V}=k.getState();V(Ff(G,Z))}T==null||T(G),l==null||l(G)},W=z=>{if(!y)return;const C=YP(z.nativeEvent);if(s&&(C&&z.button===0||!C)){const T=k.getState();ab.onPointerDown(z.nativeEvent,{handleDomNode:z.currentTarget,autoPanOnConnect:T.autoPanOnConnect,connectionMode:T.connectionMode,connectionRadius:T.connectionRadius,domNode:T.domNode,nodeLookup:T.nodeLookup,lib:T.lib,isTarget:b,handleId:g,nodeId:y,flowId:T.rfId,panBy:T.panBy,cancelConnection:T.cancelConnection,onConnectStart:T.onConnectStart,onConnectEnd:(...E)=>{var G,Z;return(Z=(G=k.getState()).onConnectEnd)==null?void 0:Z.call(G,...E)},updateConnection:T.updateConnection,onConnect:M,isValidConnection:n||((...E)=>{var G,Z;return((Z=(G=k.getState()).isValidConnection)==null?void 0:Z.call(G,...E))??!0}),getTransform:()=>k.getState().transform,getFromHandle:()=>k.getState().connection.fromHandle,autoPanSpeed:T.autoPanSpeed,dragThreshold:T.connectionDragThreshold})}C?f==null||f(z):c==null||c(z)},O=z=>{const{onClickConnectStart:C,onClickConnectEnd:T,connectionClickStartHandle:E,connectionMode:G,isValidConnection:Z,lib:V,rfId:se,nodeLookup:de,connection:fe}=k.getState();if(!y||!E&&!s)return;if(!E){C==null||C(z.nativeEvent,{nodeId:y,handleId:g,handleType:e}),k.setState({connectionClickStartHandle:{nodeId:y,type:e,id:g}});return}const pe=KP(z.target),ae=n||Z,{connection:be,isValid:_e}=ab.isValid(z.nativeEvent,{handle:{nodeId:y,id:g,type:e},connectionMode:G,fromNodeId:E.nodeId,fromHandleId:E.id||null,fromType:E.type,isValidConnection:ae,flowId:se,doc:pe,lib:V,nodeLookup:de});_e&&be&&M(be);const we=structuredClone(fe);delete we.inProgress,we.toPosition=we.toHandle?we.toHandle.position:null,T==null||T(z,we),k.setState({connectionClickStartHandle:null})};return o.jsx("div",{"data-handleid":g,"data-nodeid":y,"data-handlepos":t,"data-id":`${j}-${y}-${g}-${e}`,className:gr(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",w,d,{source:!b,target:b,connectable:r,connectablestart:s,connectableend:i,clickconnecting:L,connectingfrom:P,connectingto:_,valid:R,connectionindicator:r&&(!D||B)&&(D||F?i:s)}]),onMouseDown:W,onTouchStart:W,onClick:v?O:void 0,ref:m,...p,children:u})}const Ms=h.memo(vA(l4));function c4({data:e,isConnectable:t,sourcePosition:n=Xe.Bottom}){return o.jsxs(o.Fragment,{children:[e==null?void 0:e.label,o.jsx(Ms,{type:"source",position:n,isConnectable:t})]})}function u4({data:e,isConnectable:t,targetPosition:n=Xe.Top,sourcePosition:r=Xe.Bottom}){return o.jsxs(o.Fragment,{children:[o.jsx(Ms,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,o.jsx(Ms,{type:"source",position:r,isConnectable:t})]})}function d4(){return null}function f4({data:e,isConnectable:t,targetPosition:n=Xe.Top}){return o.jsxs(o.Fragment,{children:[o.jsx(Ms,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Gm={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},hN={input:c4,default:u4,output:f4,group:d4};function p4(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 h4=e=>{const{width:t,height:n,x:r,y:s}=lp(e.nodeLookup,{filter:i=>!!i.selected});return{width:qi(t)?t:null,height:qi(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 m4({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Dn(),{width:s,height:i,transformString:a,userSelectionActive:l}=Ht(h4,Hn),u=NA(),d=h.useRef(null);h.useEffect(()=>{var m;n||(m=d.current)==null||m.focus({preventScroll:!0})},[n]);const f=!l&&s!==null&&i!==null;if(SA({nodeRef:d,disabled:!f}),!f)return null;const c=e?m=>{const g=r.getState().nodes.filter(b=>b.selected);e(m,g)}:void 0,p=m=>{Object.prototype.hasOwnProperty.call(Gm,m.key)&&(m.preventDefault(),u({direction:Gm[m.key],factor:m.shiftKey?4:1}))};return o.jsx("div",{className:gr(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:o.jsx("div",{ref:d,className:"react-flow__nodesselection-rect",onContextMenu:c,tabIndex:n?void 0:-1,onKeyDown:n?void 0:p,style:{width:s,height:i}})})}const mN=typeof window<"u"?window:void 0,g4=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function CA({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:u,selectionKeyCode:d,selectionOnDrag:f,selectionMode:c,onSelectionStart:p,onSelectionEnd:m,multiSelectionKeyCode:g,panActivationKeyCode:b,zoomActivationKeyCode:k,elementsSelectable:y,zoomOnScroll:v,zoomOnPinch:w,panOnScroll:j,panOnScrollSpeed:P,panOnScrollMode:_,zoomOnDoubleClick:L,panOnDrag:B,defaultViewport:D,translateExtent:F,minZoom:R,maxZoom:M,preventScrolling:W,onSelectionContextMenu:O,noWheelClassName:$,noPanClassName:I,disableKeyboardA11y:z,onViewportChange:C,isControlledViewport:T}){const{nodesSelectionActive:E,userSelectionActive:G}=Ht(g4,Hn),Z=zf(d,{target:mN}),V=zf(b,{target:mN}),se=V||B,de=V||j,fe=f&&se!==!0,pe=Z||G||fe;return X5({deleteKeyCode:u,multiSelectionKeyCode:g}),o.jsx(Z5,{onPaneContextMenu:i,elementsSelectable:y,zoomOnScroll:v,zoomOnPinch:w,panOnScroll:de,panOnScrollSpeed:P,panOnScrollMode:_,zoomOnDoubleClick:L,panOnDrag:!Z&&se,defaultViewport:D,translateExtent:F,minZoom:R,maxZoom:M,zoomActivationKeyCode:k,preventScrolling:W,noWheelClassName:$,noPanClassName:I,onViewportChange:C,isControlledViewport:T,paneClickDistance:l,selectionOnDrag:fe,children:o.jsxs(r4,{onSelectionStart:p,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:i,onPaneScroll:a,panOnDrag:se,isSelecting:!!pe,selectionMode:c,selectionKeyPressed:Z,paneClickDistance:l,selectionOnDrag:fe,children:[e,E&&o.jsx(m4,{onSelectionContextMenu:O,noPanClassName:I,disableKeyboardA11y:z})]})})}CA.displayName="FlowRenderer";const y4=h.memo(CA),x4=e=>t=>e?Uv(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 w4(e){return Ht(h.useCallback(x4(e),[e]),Hn)}const b4=e=>e.updateNodeInternals;function v4(){const e=Ht(b4),[t]=h.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(s=>{const i=s.target.getAttribute("data-id");r.set(i,{id:i,nodeElement:s.target,force:!0})}),e(r)}));return h.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function k4({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const s=Dn(),i=h.useRef(null),a=h.useRef(null),l=h.useRef(e.sourcePosition),u=h.useRef(e.targetPosition),d=h.useRef(t),f=n&&!!e.internals.handleBounds;return h.useEffect(()=>{i.current&&!e.hidden&&(!f||a.current!==i.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(i.current),a.current=i.current)},[f,e.hidden]),h.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),h.useEffect(()=>{if(i.current){const c=d.current!==t,p=l.current!==e.sourcePosition,m=u.current!==e.targetPosition;(c||p||m)&&(d.current=t,l.current=e.sourcePosition,u.current=e.targetPosition,s.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:i.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),i}function S4({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:s,onContextMenu:i,onDoubleClick:a,nodesDraggable:l,elementsSelectable:u,nodesConnectable:d,nodesFocusable:f,resizeObserver:c,noDragClassName:p,noPanClassName:m,disableKeyboardA11y:g,rfId:b,nodeTypes:k,nodeClickDistance:y,onError:v}){const{node:w,internals:j,isParent:P}=Ht(ae=>{const be=ae.nodeLookup.get(e),_e=ae.parentLookup.has(e);return{node:be,internals:be.internals,isParent:_e}},Hn);let _=w.type||"default",L=(k==null?void 0:k[_])||hN[_];L===void 0&&(v==null||v("003",Po.error003(_)),_="default",L=(k==null?void 0:k.default)||hN.default);const B=!!(w.draggable||l&&typeof w.draggable>"u"),D=!!(w.selectable||u&&typeof w.selectable>"u"),F=!!(w.connectable||d&&typeof w.connectable>"u"),R=!!(w.focusable||f&&typeof w.focusable>"u"),M=Dn(),W=VP(w),O=k4({node:w,nodeType:_,hasDimensions:W,resizeObserver:c}),$=SA({nodeRef:O,disabled:w.hidden||!B,noDragClassName:p,handleSelector:w.dragHandle,nodeId:e,isSelectable:D,nodeClickDistance:y}),I=NA();if(w.hidden)return null;const z=ha(w),C=p4(w),T=D||B||t||n||r||s,E=n?ae=>n(ae,{...j.userNode}):void 0,G=r?ae=>r(ae,{...j.userNode}):void 0,Z=s?ae=>s(ae,{...j.userNode}):void 0,V=i?ae=>i(ae,{...j.userNode}):void 0,se=a?ae=>a(ae,{...j.userNode}):void 0,de=ae=>{const{selectNodesOnDrag:be,nodeDragThreshold:_e}=M.getState();D&&(!be||!B||_e>0)&&cb({id:e,store:M,nodeRef:O}),t&&t(ae,{...j.userNode})},fe=ae=>{if(!(qP(ae.nativeEvent)||g)){if(OP.includes(ae.key)&&D){const be=ae.key==="Escape";cb({id:e,store:M,unselect:be,nodeRef:O})}else if(B&&w.selected&&Object.prototype.hasOwnProperty.call(Gm,ae.key)){ae.preventDefault();const{ariaLabelConfig:be}=M.getState();M.setState({ariaLiveMessage:be["node.a11yDescription.ariaLiveMessage"]({direction:ae.key.replace("Arrow","").toLowerCase(),x:~~j.positionAbsolute.x,y:~~j.positionAbsolute.y})}),I({direction:Gm[ae.key],factor:ae.shiftKey?4:1})}}},pe=()=>{var et;if(g||!((et=O.current)!=null&&et.matches(":focus-visible")))return;const{transform:ae,width:be,height:_e,autoPanOnNodeFocus:we,setCenter:Oe}=M.getState();if(!we)return;Uv(new Map([[e,w]]),{x:0,y:0,width:be,height:_e},ae,!0).length>0||Oe(w.position.x+z.width/2,w.position.y+z.height/2,{zoom:ae[2]})};return o.jsx("div",{className:gr(["react-flow__node",`react-flow__node-${_}`,{[m]:B},w.className,{selected:w.selected,selectable:D,parent:P,draggable:B,dragging:$}]),ref:O,style:{zIndex:j.z,transform:`translate(${j.positionAbsolute.x}px,${j.positionAbsolute.y}px)`,pointerEvents:T?"all":"none",visibility:W?"visible":"hidden",...w.style,...C},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:E,onMouseMove:G,onMouseLeave:Z,onContextMenu:V,onClick:de,onDoubleClick:se,onKeyDown:R?fe:void 0,tabIndex:R?0:void 0,onFocus:R?pe:void 0,role:w.ariaRole??(R?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${yA}-${b}`,"aria-label":w.ariaLabel,...w.domAttributes,children:o.jsx(i4,{value:e,children:o.jsx(L,{id:e,data:w.data,type:_,positionAbsoluteX:j.positionAbsolute.x,positionAbsoluteY:j.positionAbsolute.y,selected:w.selected??!1,selectable:D,draggable:B,deletable:w.deletable??!0,isConnectable:F,sourcePosition:w.sourcePosition,targetPosition:w.targetPosition,dragging:$,dragHandle:w.dragHandle,zIndex:j.z,parentId:w.parentId,...z})})})}var N4=h.memo(S4);const j4=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function EA(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,onError:i}=Ht(j4,Hn),a=w4(e.onlyRenderVisibleElements),l=v4();return o.jsx("div",{className:"react-flow__nodes",style:Gg,children:a.map(u=>o.jsx(N4,{id:u,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:i},u))})}EA.displayName="NodeRenderer";const C4=h.memo(EA);function E4(e){return Ht(h.useCallback(n=>{if(!e)return n.edges.map(s=>s.id);const r=[];if(n.width&&n.height)for(const s of n.edges){const i=n.nodeLookup.get(s.source),a=n.nodeLookup.get(s.target);i&&a&&h3({sourceNode:i,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(s.id)}return r},[e]),Hn)}const _4=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return o.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},P4=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return o.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},gN={[Ls.Arrow]:_4,[Ls.ArrowClosed]:P4};function A4(e){const t=Dn();return h.useMemo(()=>{var s,i;return Object.prototype.hasOwnProperty.call(gN,e)?gN[e]:((i=(s=t.getState()).onError)==null||i.call(s,"009",Po.error009(e)),null)},[e])}const I4=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:i="strokeWidth",strokeWidth:a,orient:l="auto-start-reverse"})=>{const u=A4(t);return u?o.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:i,orient:l,refX:"0",refY:"0",children:o.jsx(u,{color:n,strokeWidth:a})}):null},_A=({defaultColor:e,rfId:t})=>{const n=Ht(i=>i.edges),r=Ht(i=>i.defaultEdgeOptions),s=h.useMemo(()=>v3(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?o.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:o.jsx("defs",{children:s.map(i=>o.jsx(I4,{id:i.id,type:i.type,color:i.color,width:i.width,height:i.height,markerUnits:i.markerUnits,strokeWidth:i.strokeWidth,orient:i.orient},i.id))})}):null};_A.displayName="MarkerDefinitions";var T4=h.memo(_A);function PA({x:e,y:t,label:n,labelStyle:r,labelShowBg:s=!0,labelBgStyle:i,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:u,className:d,...f}){const[c,p]=h.useState({x:1,y:0,width:0,height:0}),m=gr(["react-flow__edge-textwrapper",d]),g=h.useRef(null);return h.useEffect(()=>{if(g.current){const b=g.current.getBBox();p({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),n?o.jsxs("g",{transform:`translate(${e-c.width/2} ${t-c.height/2})`,className:m,visibility:c.width?"visible":"hidden",...f,children:[s&&o.jsx("rect",{width:c.width+2*a[0],x:-a[0],y:-a[1],height:c.height+2*a[1],className:"react-flow__edge-textbg",style:i,rx:l,ry:l}),o.jsx("text",{className:"react-flow__edge-text",y:c.height/2,dy:"0.3em",ref:g,style:r,children:n}),u]}):null}PA.displayName="EdgeText";const R4=h.memo(PA);function Xg({path:e,labelX:t,labelY:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:u,interactionWidth:d=20,...f}){return o.jsxs(o.Fragment,{children:[o.jsx("path",{...f,d:e,fill:"none",className:gr(["react-flow__edge-path",f.className])}),d?o.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:d,className:"react-flow__edge-interaction"}):null,r&&qi(t)&&qi(n)?o.jsx(R4,{x:t,y:n,label:r,labelStyle:s,labelShowBg:i,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:u}):null]})}function yN({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Xe.Left||e===Xe.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function AA({sourceX:e,sourceY:t,sourcePosition:n=Xe.Bottom,targetX:r,targetY:s,targetPosition:i=Xe.Top}){const[a,l]=yN({pos:n,x1:e,y1:t,x2:r,y2:s}),[u,d]=yN({pos:i,x1:r,y1:s,x2:e,y2:t}),[f,c,p,m]=GP({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:a,sourceControlY:l,targetControlX:u,targetControlY:d});return[`M${e},${t} C${a},${l} ${u},${d} ${r},${s}`,f,c,p,m]}function IA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a,targetPosition:l,label:u,labelStyle:d,labelShowBg:f,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:k,interactionWidth:y})=>{const[v,w,j]=AA({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l}),P=e.isInternal?void 0:t;return o.jsx(Xg,{id:P,path:v,labelX:w,labelY:j,label:u,labelStyle:d,labelShowBg:f,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:k,interactionWidth:y})})}const L4=IA({isInternal:!1}),TA=IA({isInternal:!0});L4.displayName="SimpleBezierEdge";TA.displayName="SimpleBezierEdgeInternal";function RA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:c,style:p,sourcePosition:m=Xe.Bottom,targetPosition:g=Xe.Top,markerEnd:b,markerStart:k,pathOptions:y,interactionWidth:v})=>{const[w,j,P]=sb({sourceX:n,sourceY:r,sourcePosition:m,targetX:s,targetY:i,targetPosition:g,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset,stepPosition:y==null?void 0:y.stepPosition}),_=e.isInternal?void 0:t;return o.jsx(Xg,{id:_,path:w,labelX:j,labelY:P,label:a,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:c,style:p,markerEnd:b,markerStart:k,interactionWidth:v})})}const LA=RA({isInternal:!1}),OA=RA({isInternal:!0});LA.displayName="SmoothStepEdge";OA.displayName="SmoothStepEdgeInternal";function MA(e){return h.memo(({id:t,...n})=>{var s;const r=e.isInternal?void 0:t;return o.jsx(LA,{...n,id:r,pathOptions:h.useMemo(()=>{var i;return{borderRadius:0,offset:(i=n.pathOptions)==null?void 0:i.offset}},[(s=n.pathOptions)==null?void 0:s.offset])})})}const O4=MA({isInternal:!1}),$A=MA({isInternal:!0});O4.displayName="StepEdge";$A.displayName="StepEdgeInternal";function DA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,label:a,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:c,style:p,markerEnd:m,markerStart:g,interactionWidth:b})=>{const[k,y,v]=QP({sourceX:n,sourceY:r,targetX:s,targetY:i}),w=e.isInternal?void 0:t;return o.jsx(Xg,{id:w,path:k,labelX:y,labelY:v,label:a,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:c,style:p,markerEnd:m,markerStart:g,interactionWidth:b})})}const M4=DA({isInternal:!1}),FA=DA({isInternal:!0});M4.displayName="StraightEdge";FA.displayName="StraightEdgeInternal";function zA(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:s,targetY:i,sourcePosition:a=Xe.Bottom,targetPosition:l=Xe.Top,label:u,labelStyle:d,labelShowBg:f,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:k,pathOptions:y,interactionWidth:v})=>{const[w,j,P]=XP({sourceX:n,sourceY:r,sourcePosition:a,targetX:s,targetY:i,targetPosition:l,curvature:y==null?void 0:y.curvature}),_=e.isInternal?void 0:t;return o.jsx(Xg,{id:_,path:w,labelX:j,labelY:P,label:u,labelStyle:d,labelShowBg:f,labelBgStyle:c,labelBgPadding:p,labelBgBorderRadius:m,style:g,markerEnd:b,markerStart:k,interactionWidth:v})})}const $4=zA({isInternal:!1}),BA=zA({isInternal:!0});$4.displayName="BezierEdge";BA.displayName="BezierEdgeInternal";const xN={default:BA,straight:FA,step:$A,smoothstep:OA,simplebezier:TA},wN={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},D4=(e,t,n)=>n===Xe.Left?e-t:n===Xe.Right?e+t:e,F4=(e,t,n)=>n===Xe.Top?e-t:n===Xe.Bottom?e+t:e,bN="react-flow__edgeupdater";function vN({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:i,onMouseOut:a,type:l}){return o.jsx("circle",{onMouseDown:s,onMouseEnter:i,onMouseOut:a,className:gr([bN,`${bN}-${l}`]),cx:D4(t,r,e),cy:F4(n,r,e),r,stroke:"transparent",fill:"transparent"})}function z4({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:s,targetX:i,targetY:a,sourcePosition:l,targetPosition:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:c,setReconnecting:p,setUpdateHover:m}){const g=Dn(),b=(j,P)=>{if(j.button!==0)return;const{autoPanOnConnect:_,domNode:L,connectionMode:B,connectionRadius:D,lib:F,onConnectStart:R,cancelConnection:M,nodeLookup:W,rfId:O,panBy:$,updateConnection:I}=g.getState(),z=P.type==="target",C=(G,Z)=>{p(!1),c==null||c(G,n,P.type,Z)},T=G=>d==null?void 0:d(n,G),E=(G,Z)=>{p(!0),f==null||f(j,n,P.type),R==null||R(G,Z)};ab.onPointerDown(j.nativeEvent,{autoPanOnConnect:_,connectionMode:B,connectionRadius:D,domNode:L,handleId:P.id,nodeId:P.nodeId,nodeLookup:W,isTarget:z,edgeUpdaterType:P.type,lib:F,flowId:O,cancelConnection:M,panBy:$,isValidConnection:(...G)=>{var Z,V;return((V=(Z=g.getState()).isValidConnection)==null?void 0:V.call(Z,...G))??!0},onConnect:T,onConnectStart:E,onConnectEnd:(...G)=>{var Z,V;return(V=(Z=g.getState()).onConnectEnd)==null?void 0:V.call(Z,...G)},onReconnectEnd:C,updateConnection:I,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:j.currentTarget})},k=j=>b(j,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=j=>b(j,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),v=()=>m(!0),w=()=>m(!1);return o.jsxs(o.Fragment,{children:[(e===!0||e==="source")&&o.jsx(vN,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:k,onMouseEnter:v,onMouseOut:w,type:"source"}),(e===!0||e==="target")&&o.jsx(vN,{position:u,centerX:i,centerY:a,radius:t,onMouseDown:y,onMouseEnter:v,onMouseOut:w,type:"target"})]})}function B4({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:s,onDoubleClick:i,onContextMenu:a,onMouseEnter:l,onMouseMove:u,onMouseLeave:d,reconnectRadius:f,onReconnect:c,onReconnectStart:p,onReconnectEnd:m,rfId:g,edgeTypes:b,noPanClassName:k,onError:y,disableKeyboardA11y:v}){let w=Ht(Oe=>Oe.edgeLookup.get(e));const j=Ht(Oe=>Oe.defaultEdgeOptions);w=j?{...j,...w}:w;let P=w.type||"default",_=(b==null?void 0:b[P])||xN[P];_===void 0&&(y==null||y("011",Po.error011(P)),P="default",_=(b==null?void 0:b.default)||xN.default);const L=!!(w.focusable||t&&typeof w.focusable>"u"),B=typeof c<"u"&&(w.reconnectable||n&&typeof w.reconnectable>"u"),D=!!(w.selectable||r&&typeof w.selectable>"u"),F=h.useRef(null),[R,M]=h.useState(!1),[W,O]=h.useState(!1),$=Dn(),{zIndex:I,sourceX:z,sourceY:C,targetX:T,targetY:E,sourcePosition:G,targetPosition:Z}=Ht(h.useCallback(Oe=>{const Ie=Oe.nodeLookup.get(w.source),et=Oe.nodeLookup.get(w.target);if(!Ie||!et)return{zIndex:w.zIndex,...wN};const ft=b3({id:e,sourceNode:Ie,targetNode:et,sourceHandle:w.sourceHandle||null,targetHandle:w.targetHandle||null,connectionMode:Oe.connectionMode,onError:y});return{zIndex:p3({selected:w.selected,zIndex:w.zIndex,sourceNode:Ie,targetNode:et,elevateOnSelect:Oe.elevateEdgesOnSelect,zIndexMode:Oe.zIndexMode}),...ft||wN}},[w.source,w.target,w.sourceHandle,w.targetHandle,w.selected,w.zIndex]),Hn),V=h.useMemo(()=>w.markerStart?`url('#${ib(w.markerStart,g)}')`:void 0,[w.markerStart,g]),se=h.useMemo(()=>w.markerEnd?`url('#${ib(w.markerEnd,g)}')`:void 0,[w.markerEnd,g]);if(w.hidden||z===null||C===null||T===null||E===null)return null;const de=Oe=>{var Je;const{addSelectedEdges:Ie,unselectNodesAndEdges:et,multiSelectionActive:ft}=$.getState();D&&($.setState({nodesSelectionActive:!1}),w.selected&&ft?(et({nodes:[],edges:[w]}),(Je=F.current)==null||Je.blur()):Ie([e])),s&&s(Oe,w)},fe=i?Oe=>{i(Oe,{...w})}:void 0,pe=a?Oe=>{a(Oe,{...w})}:void 0,ae=l?Oe=>{l(Oe,{...w})}:void 0,be=u?Oe=>{u(Oe,{...w})}:void 0,_e=d?Oe=>{d(Oe,{...w})}:void 0,we=Oe=>{var Ie;if(!v&&OP.includes(Oe.key)&&D){const{unselectNodesAndEdges:et,addSelectedEdges:ft}=$.getState();Oe.key==="Escape"?((Ie=F.current)==null||Ie.blur(),et({edges:[w]})):ft([e])}};return o.jsx("svg",{style:{zIndex:I},children:o.jsxs("g",{className:gr(["react-flow__edge",`react-flow__edge-${P}`,w.className,k,{selected:w.selected,animated:w.animated,inactive:!D&&!s,updating:R,selectable:D}]),onClick:de,onDoubleClick:fe,onContextMenu:pe,onMouseEnter:ae,onMouseMove:be,onMouseLeave:_e,onKeyDown:L?we:void 0,tabIndex:L?0:void 0,role:w.ariaRole??(L?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":w.ariaLabel===null?void 0:w.ariaLabel||`Edge from ${w.source} to ${w.target}`,"aria-describedby":L?`${xA}-${g}`:void 0,ref:F,...w.domAttributes,children:[!W&&o.jsx(_,{id:e,source:w.source,target:w.target,type:w.type,selected:w.selected,animated:w.animated,selectable:D,deletable:w.deletable??!0,label:w.label,labelStyle:w.labelStyle,labelShowBg:w.labelShowBg,labelBgStyle:w.labelBgStyle,labelBgPadding:w.labelBgPadding,labelBgBorderRadius:w.labelBgBorderRadius,sourceX:z,sourceY:C,targetX:T,targetY:E,sourcePosition:G,targetPosition:Z,data:w.data,style:w.style,sourceHandleId:w.sourceHandle,targetHandleId:w.targetHandle,markerStart:V,markerEnd:se,pathOptions:"pathOptions"in w?w.pathOptions:void 0,interactionWidth:w.interactionWidth}),B&&o.jsx(z4,{edge:w,isReconnectable:B,reconnectRadius:f,onReconnect:c,onReconnectStart:p,onReconnectEnd:m,sourceX:z,sourceY:C,targetX:T,targetY:E,sourcePosition:G,targetPosition:Z,setUpdateHover:M,setReconnecting:O})]})})}var H4=h.memo(B4);const W4=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function HA({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:s,onReconnect:i,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:u,onEdgeMouseLeave:d,onEdgeClick:f,reconnectRadius:c,onEdgeDoubleClick:p,onReconnectStart:m,onReconnectEnd:g,disableKeyboardA11y:b}){const{edgesFocusable:k,edgesReconnectable:y,elementsSelectable:v,onError:w}=Ht(W4,Hn),j=E4(t);return o.jsxs("div",{className:"react-flow__edges",children:[o.jsx(T4,{defaultColor:e,rfId:n}),j.map(P=>o.jsx(H4,{id:P,edgesFocusable:k,edgesReconnectable:y,elementsSelectable:v,noPanClassName:s,onReconnect:i,onContextMenu:a,onMouseEnter:l,onMouseMove:u,onMouseLeave:d,onClick:f,reconnectRadius:c,onDoubleClick:p,onReconnectStart:m,onReconnectEnd:g,rfId:n,onError:w,edgeTypes:r,disableKeyboardA11y:b},P))]})}HA.displayName="EdgeRenderer";const V4=h.memo(HA),U4=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function K4({children:e}){const t=Ht(U4);return o.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function q4(e){const t=fc(),n=h.useRef(!1);h.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Y4=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function G4(e){const t=Ht(Y4),n=Dn();return h.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function X4(e){return e.connection.inProgress?{...e.connection,to:up(e.connection.to,e.transform)}:{...e.connection}}function J4(e){return X4}function Q4(e){const t=J4();return Ht(t,Hn)}const Z4=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function eB({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:s,width:i,height:a,isValid:l,inProgress:u}=Ht(Z4,Hn);return!(i&&s&&u)?null:o.jsx("svg",{style:e,width:i,height:a,className:"react-flow__connectionline react-flow__container",children:o.jsx("g",{className:gr(["react-flow__connection",DP(l)]),children:o.jsx(WA,{style:t,type:n,CustomComponent:r,isValid:l})})})}const WA=({style:e,type:t=za.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:s,from:i,fromNode:a,fromHandle:l,fromPosition:u,to:d,toNode:f,toHandle:c,toPosition:p,pointer:m}=Q4();if(!s)return;if(n)return o.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:i.x,fromY:i.y,toX:d.x,toY:d.y,fromPosition:u,toPosition:p,connectionStatus:DP(r),toNode:f,toHandle:c,pointer:m});let g="";const b={sourceX:i.x,sourceY:i.y,sourcePosition:u,targetX:d.x,targetY:d.y,targetPosition:p};switch(t){case za.Bezier:[g]=XP(b);break;case za.SimpleBezier:[g]=AA(b);break;case za.Step:[g]=sb({...b,borderRadius:0});break;case za.SmoothStep:[g]=sb(b);break;default:[g]=QP(b)}return o.jsx("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};WA.displayName="ConnectionLine";const tB={};function kN(e=tB){h.useRef(e),Dn(),h.useEffect(()=>{},[e])}function nB(){Dn(),h.useRef(!1),h.useEffect(()=>{},[])}function VA({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:s,onNodeDoubleClick:i,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:u,onNodeMouseLeave:d,onNodeContextMenu:f,onSelectionContextMenu:c,onSelectionStart:p,onSelectionEnd:m,connectionLineType:g,connectionLineStyle:b,connectionLineComponent:k,connectionLineContainerStyle:y,selectionKeyCode:v,selectionOnDrag:w,selectionMode:j,multiSelectionKeyCode:P,panActivationKeyCode:_,zoomActivationKeyCode:L,deleteKeyCode:B,onlyRenderVisibleElements:D,elementsSelectable:F,defaultViewport:R,translateExtent:M,minZoom:W,maxZoom:O,preventScrolling:$,defaultMarkerColor:I,zoomOnScroll:z,zoomOnPinch:C,panOnScroll:T,panOnScrollSpeed:E,panOnScrollMode:G,zoomOnDoubleClick:Z,panOnDrag:V,onPaneClick:se,onPaneMouseEnter:de,onPaneMouseMove:fe,onPaneMouseLeave:pe,onPaneScroll:ae,onPaneContextMenu:be,paneClickDistance:_e,nodeClickDistance:we,onEdgeContextMenu:Oe,onEdgeMouseEnter:Ie,onEdgeMouseMove:et,onEdgeMouseLeave:ft,reconnectRadius:Je,onReconnect:bt,onReconnectStart:Ve,onReconnectEnd:jt,noDragClassName:An,noWheelClassName:pn,noPanClassName:In,disableKeyboardA11y:en,nodeExtent:Wn,rfId:Tn,viewport:ce,onViewportChange:ve}){return kN(e),kN(t),nB(),q4(n),G4(ce),o.jsx(y4,{onPaneClick:se,onPaneMouseEnter:de,onPaneMouseMove:fe,onPaneMouseLeave:pe,onPaneContextMenu:be,onPaneScroll:ae,paneClickDistance:_e,deleteKeyCode:B,selectionKeyCode:v,selectionOnDrag:w,selectionMode:j,onSelectionStart:p,onSelectionEnd:m,multiSelectionKeyCode:P,panActivationKeyCode:_,zoomActivationKeyCode:L,elementsSelectable:F,zoomOnScroll:z,zoomOnPinch:C,zoomOnDoubleClick:Z,panOnScroll:T,panOnScrollSpeed:E,panOnScrollMode:G,panOnDrag:V,defaultViewport:R,translateExtent:M,minZoom:W,maxZoom:O,onSelectionContextMenu:c,preventScrolling:$,noDragClassName:An,noWheelClassName:pn,noPanClassName:In,disableKeyboardA11y:en,onViewportChange:ve,isControlledViewport:!!ce,children:o.jsxs(K4,{children:[o.jsx(V4,{edgeTypes:t,onEdgeClick:s,onEdgeDoubleClick:a,onReconnect:bt,onReconnectStart:Ve,onReconnectEnd:jt,onlyRenderVisibleElements:D,onEdgeContextMenu:Oe,onEdgeMouseEnter:Ie,onEdgeMouseMove:et,onEdgeMouseLeave:ft,reconnectRadius:Je,defaultMarkerColor:I,noPanClassName:In,disableKeyboardA11y:en,rfId:Tn}),o.jsx(eB,{style:b,type:g,component:k,containerStyle:y}),o.jsx("div",{className:"react-flow__edgelabel-renderer"}),o.jsx(C4,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:i,onNodeMouseEnter:l,onNodeMouseMove:u,onNodeMouseLeave:d,onNodeContextMenu:f,nodeClickDistance:we,onlyRenderVisibleElements:D,noPanClassName:In,noDragClassName:An,disableKeyboardA11y:en,nodeExtent:Wn,rfId:Tn}),o.jsx("div",{className:"react-flow__viewport-portal"})]})})}VA.displayName="GraphView";const rB=h.memo(VA),SN=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:u=.5,maxZoom:d=2,nodeOrigin:f,nodeExtent:c,zIndexMode:p="basic"}={})=>{const m=new Map,g=new Map,b=new Map,k=new Map,y=r??t??[],v=n??e??[],w=f??[0,0],j=c??Of;tA(b,k,y);const{nodesInitialized:P}=ob(v,m,g,{nodeOrigin:w,nodeExtent:j,zIndexMode:p});let _=[0,0,1];if(a&&s&&i){const L=lp(m,{filter:R=>!!((R.width||R.initialWidth)&&(R.height||R.initialHeight))}),{x:B,y:D,zoom:F}=Kv(L,s,i,u,d,(l==null?void 0:l.padding)??.1);_=[B,D,F]}return{rfId:"1",width:s??0,height:i??0,transform:_,nodes:v,nodesInitialized:P,nodeLookup:m,parentLookup:g,edges:y,edgeLookup:k,connectionLookup:b,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:u,maxZoom:d,translateExtent:Of,nodeExtent:j,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Cu.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:w,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:{...$P},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:a3,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:MP,zIndexMode:p,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},sB=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:u,maxZoom:d,nodeOrigin:f,nodeExtent:c,zIndexMode:p})=>S5((m,g)=>{async function b(){const{nodeLookup:k,panZoom:y,fitViewOptions:v,fitViewResolver:w,width:j,height:P,minZoom:_,maxZoom:L}=g();y&&(await i3({nodes:k,width:j,height:P,panZoom:y,minZoom:_,maxZoom:L},v),w==null||w.resolve(!0),m({fitViewResolver:null}))}return{...SN({nodes:e,edges:t,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:u,maxZoom:d,nodeOrigin:f,nodeExtent:c,defaultNodes:n,defaultEdges:r,zIndexMode:p}),setNodes:k=>{const{nodeLookup:y,parentLookup:v,nodeOrigin:w,elevateNodesOnSelect:j,fitViewQueued:P,zIndexMode:_,nodesSelectionActive:L}=g(),{nodesInitialized:B,hasSelectedNodes:D}=ob(k,y,v,{nodeOrigin:w,nodeExtent:c,elevateNodesOnSelect:j,checkEquality:!0,zIndexMode:_}),F=L&&D;P&&B?(b(),m({nodes:k,nodesInitialized:B,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:F})):m({nodes:k,nodesInitialized:B,nodesSelectionActive:F})},setEdges:k=>{const{connectionLookup:y,edgeLookup:v}=g();tA(y,v,k),m({edges:k})},setDefaultNodesAndEdges:(k,y)=>{if(k){const{setNodes:v}=g();v(k),m({hasDefaultNodes:!0})}if(y){const{setEdges:v}=g();v(y),m({hasDefaultEdges:!0})}},updateNodeInternals:k=>{const{triggerNodeChanges:y,nodeLookup:v,parentLookup:w,domNode:j,nodeOrigin:P,nodeExtent:_,debug:L,fitViewQueued:B,zIndexMode:D}=g(),{changes:F,updatedInternals:R}=_3(k,v,w,j,P,_,D);R&&(N3(v,w,{nodeOrigin:P,nodeExtent:_,zIndexMode:D}),B?(b(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),(F==null?void 0:F.length)>0&&(L&&console.log("React Flow: trigger node changes",F),y==null||y(F)))},updateNodePositions:(k,y=!1)=>{const v=[];let w=[];const{nodeLookup:j,triggerNodeChanges:P,connection:_,updateConnection:L,onNodesChangeMiddlewareMap:B}=g();for(const[D,F]of k){const R=j.get(D),M=!!(R!=null&&R.expandParent&&(R!=null&&R.parentId)&&(F!=null&&F.position)),W={id:D,type:"position",position:M?{x:Math.max(0,F.position.x),y:Math.max(0,F.position.y)}:F.position,dragging:y};if(R&&_.inProgress&&_.fromNode.id===R.id){const O=ac(R,_.fromHandle,Xe.Left,!0);L({..._,from:O})}M&&R.parentId&&v.push({id:D,parentId:R.parentId,rect:{...F.internals.positionAbsolute,width:F.measured.width??0,height:F.measured.height??0}}),w.push(W)}if(v.length>0){const{parentLookup:D,nodeOrigin:F}=g(),R=Qv(v,j,D,F);w.push(...R)}for(const D of B.values())w=D(w);P(w)},triggerNodeChanges:k=>{const{onNodesChange:y,setNodes:v,nodes:w,hasDefaultNodes:j,debug:P}=g();if(k!=null&&k.length){if(j){const _=Ym(k,w);v(_)}P&&console.log("React Flow: trigger node changes",k),y==null||y(k)}},triggerEdgeChanges:k=>{const{onEdgesChange:y,setEdges:v,edges:w,hasDefaultEdges:j,debug:P}=g();if(k!=null&&k.length){if(j){const _=Zv(k,w);v(_)}P&&console.log("React Flow: trigger edge changes",k),y==null||y(k)}},addSelectedNodes:k=>{const{multiSelectionActive:y,edgeLookup:v,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:P}=g();if(y){const _=k.map(L=>Fl(L,!0));j(_);return}j(tu(w,new Set([...k]),!0)),P(tu(v))},addSelectedEdges:k=>{const{multiSelectionActive:y,edgeLookup:v,nodeLookup:w,triggerNodeChanges:j,triggerEdgeChanges:P}=g();if(y){const _=k.map(L=>Fl(L,!0));P(_);return}P(tu(v,new Set([...k]))),j(tu(w,new Set,!0))},unselectNodesAndEdges:({nodes:k,edges:y}={})=>{const{edges:v,nodes:w,nodeLookup:j,triggerNodeChanges:P,triggerEdgeChanges:_}=g(),L=k||w,B=y||v,D=[];for(const R of L){if(!R.selected)continue;const M=j.get(R.id);M&&(M.selected=!1),D.push(Fl(R.id,!1))}const F=[];for(const R of B)R.selected&&F.push(Fl(R.id,!1));P(D),_(F)},setMinZoom:k=>{const{panZoom:y,maxZoom:v}=g();y==null||y.setScaleExtent([k,v]),m({minZoom:k})},setMaxZoom:k=>{const{panZoom:y,minZoom:v}=g();y==null||y.setScaleExtent([v,k]),m({maxZoom:k})},setTranslateExtent:k=>{var y;(y=g().panZoom)==null||y.setTranslateExtent(k),m({translateExtent:k})},resetSelectedElements:()=>{const{edges:k,nodes:y,triggerNodeChanges:v,triggerEdgeChanges:w,elementsSelectable:j}=g();if(!j)return;const P=y.reduce((L,B)=>B.selected?[...L,Fl(B.id,!1)]:L,[]),_=k.reduce((L,B)=>B.selected?[...L,Fl(B.id,!1)]:L,[]);v(P),w(_)},setNodeExtent:k=>{const{nodes:y,nodeLookup:v,parentLookup:w,nodeOrigin:j,elevateNodesOnSelect:P,nodeExtent:_,zIndexMode:L}=g();k[0][0]===_[0][0]&&k[0][1]===_[0][1]&&k[1][0]===_[1][0]&&k[1][1]===_[1][1]||(ob(y,v,w,{nodeOrigin:j,nodeExtent:k,elevateNodesOnSelect:P,checkEquality:!1,zIndexMode:L}),m({nodeExtent:k}))},panBy:k=>{const{transform:y,width:v,height:w,panZoom:j,translateExtent:P}=g();return P3({delta:k,panZoom:j,transform:y,translateExtent:P,width:v,height:w})},setCenter:async(k,y,v)=>{const{width:w,height:j,maxZoom:P,panZoom:_}=g();if(!_)return Promise.resolve(!1);const L=typeof(v==null?void 0:v.zoom)<"u"?v.zoom:P;return await _.setViewport({x:w/2-k*L,y:j/2-y*L,zoom:L},{duration:v==null?void 0:v.duration,ease:v==null?void 0:v.ease,interpolate:v==null?void 0:v.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{m({connection:{...$P}})},updateConnection:k=>{m({connection:k})},reset:()=>m({...SN()})}},Object.is);function Jg({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:s,initialHeight:i,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:u,fitView:d,nodeOrigin:f,nodeExtent:c,zIndexMode:p,children:m}){const[g]=h.useState(()=>sB({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:s,height:i,fitView:d,minZoom:a,maxZoom:l,fitViewOptions:u,nodeOrigin:f,nodeExtent:c,zIndexMode:p}));return o.jsx(N5,{value:g,children:o.jsx(K5,{children:m})})}function iB({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:s,width:i,height:a,fitView:l,fitViewOptions:u,minZoom:d,maxZoom:f,nodeOrigin:c,nodeExtent:p,zIndexMode:m}){return h.useContext(Yg)?o.jsx(o.Fragment,{children:e}):o.jsx(Jg,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:s,initialWidth:i,initialHeight:a,fitView:l,initialFitViewOptions:u,initialMinZoom:d,initialMaxZoom:f,nodeOrigin:c,nodeExtent:p,zIndexMode:m,children:e})}const oB={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function aB({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:i,edgeTypes:a,onNodeClick:l,onEdgeClick:u,onInit:d,onMove:f,onMoveStart:c,onMoveEnd:p,onConnect:m,onConnectStart:g,onConnectEnd:b,onClickConnectStart:k,onClickConnectEnd:y,onNodeMouseEnter:v,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:P,onNodeDoubleClick:_,onNodeDragStart:L,onNodeDrag:B,onNodeDragStop:D,onNodesDelete:F,onEdgesDelete:R,onDelete:M,onSelectionChange:W,onSelectionDragStart:O,onSelectionDrag:$,onSelectionDragStop:I,onSelectionContextMenu:z,onSelectionStart:C,onSelectionEnd:T,onBeforeDelete:E,connectionMode:G,connectionLineType:Z=za.Bezier,connectionLineStyle:V,connectionLineComponent:se,connectionLineContainerStyle:de,deleteKeyCode:fe="Backspace",selectionKeyCode:pe="Shift",selectionOnDrag:ae=!1,selectionMode:be=Mf.Full,panActivationKeyCode:_e="Space",multiSelectionKeyCode:we=Df()?"Meta":"Control",zoomActivationKeyCode:Oe=Df()?"Meta":"Control",snapToGrid:Ie,snapGrid:et,onlyRenderVisibleElements:ft=!1,selectNodesOnDrag:Je,nodesDraggable:bt,autoPanOnNodeFocus:Ve,nodesConnectable:jt,nodesFocusable:An,nodeOrigin:pn=wA,edgesFocusable:In,edgesReconnectable:en,elementsSelectable:Wn=!0,defaultViewport:Tn=$5,minZoom:ce=.5,maxZoom:ve=2,translateExtent:ze=Of,preventScrolling:it=!0,nodeExtent:ot,defaultMarkerColor:Tt="#b1b1b7",zoomOnScroll:tt=!0,zoomOnPinch:an=!0,panOnScroll:Xt=!1,panOnScrollSpeed:rr=.5,panOnScrollMode:vn=Gl.Free,zoomOnDoubleClick:ln=!0,panOnDrag:hn=!0,onPaneClick:sr,onPaneMouseEnter:xe,onPaneMouseMove:Me,onPaneMouseLeave:Ze,onPaneScroll:Dt,onPaneContextMenu:ie,paneClickDistance:Pe=1,nodeClickDistance:He=0,children:Ft,onReconnect:cn,onReconnectStart:ir,onReconnectEnd:Ds,onEdgeContextMenu:ns,onEdgeDoubleClick:cr,onEdgeMouseEnter:Xn,onEdgeMouseMove:zr,onEdgeMouseLeave:st,reconnectRadius:Br=10,onNodesChange:_i,onEdgesChange:ga,noDragClassName:hs="nodrag",noWheelClassName:Ee="nowheel",noPanClassName:tn="nopan",fitView:ur,fitViewOptions:pt,connectOnClick:Le,attributionPosition:Hr,proOptions:Vn,defaultEdgeOptions:Wr,elevateNodesOnSelect:kr=!0,elevateEdgesOnSelect:ct=!1,disableKeyboardA11y:Wt=!1,autoPanOnConnect:nn,autoPanOnNodeDrag:Sr,autoPanSpeed:Qe,connectionRadius:dr,isValidConnection:Fs,onError:ya,style:ms,id:Lo,nodeDragThreshold:yr,connectionDragThreshold:Oo,viewport:Pi,onViewportChange:un,width:Jn,height:gs,colorMode:Vr="light",debug:ii,onScroll:zs,ariaLabelConfig:K,zIndexMode:ge="basic",...Te},Re){const We=Lo||"1",Jt=B5(Vr),Rt=h.useCallback(dn=>{dn.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),zs==null||zs(dn)},[zs]);return o.jsx("div",{"data-testid":"rf__wrapper",...Te,onScroll:Rt,style:{...ms,...oB},ref:Re,className:gr(["react-flow",s,Jt]),id:Lo,role:"application",children:o.jsxs(iB,{nodes:e,edges:t,width:Jn,height:gs,fitView:ur,fitViewOptions:pt,minZoom:ce,maxZoom:ve,nodeOrigin:pn,nodeExtent:ot,zIndexMode:ge,children:[o.jsx(z5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:g,onConnectEnd:b,onClickConnectStart:k,onClickConnectEnd:y,nodesDraggable:bt,autoPanOnNodeFocus:Ve,nodesConnectable:jt,nodesFocusable:An,edgesFocusable:In,edgesReconnectable:en,elementsSelectable:Wn,elevateNodesOnSelect:kr,elevateEdgesOnSelect:ct,minZoom:ce,maxZoom:ve,nodeExtent:ot,onNodesChange:_i,onEdgesChange:ga,snapToGrid:Ie,snapGrid:et,connectionMode:G,translateExtent:ze,connectOnClick:Le,defaultEdgeOptions:Wr,fitView:ur,fitViewOptions:pt,onNodesDelete:F,onEdgesDelete:R,onDelete:M,onNodeDragStart:L,onNodeDrag:B,onNodeDragStop:D,onSelectionDrag:$,onSelectionDragStart:O,onSelectionDragStop:I,onMove:f,onMoveStart:c,onMoveEnd:p,noPanClassName:tn,nodeOrigin:pn,rfId:We,autoPanOnConnect:nn,autoPanOnNodeDrag:Sr,autoPanSpeed:Qe,onError:ya,connectionRadius:dr,isValidConnection:Fs,selectNodesOnDrag:Je,nodeDragThreshold:yr,connectionDragThreshold:Oo,onBeforeDelete:E,debug:ii,ariaLabelConfig:K,zIndexMode:ge}),o.jsx(rB,{onInit:d,onNodeClick:l,onEdgeClick:u,onNodeMouseEnter:v,onNodeMouseMove:w,onNodeMouseLeave:j,onNodeContextMenu:P,onNodeDoubleClick:_,nodeTypes:i,edgeTypes:a,connectionLineType:Z,connectionLineStyle:V,connectionLineComponent:se,connectionLineContainerStyle:de,selectionKeyCode:pe,selectionOnDrag:ae,selectionMode:be,deleteKeyCode:fe,multiSelectionKeyCode:we,panActivationKeyCode:_e,zoomActivationKeyCode:Oe,onlyRenderVisibleElements:ft,defaultViewport:Tn,translateExtent:ze,minZoom:ce,maxZoom:ve,preventScrolling:it,zoomOnScroll:tt,zoomOnPinch:an,zoomOnDoubleClick:ln,panOnScroll:Xt,panOnScrollSpeed:rr,panOnScrollMode:vn,panOnDrag:hn,onPaneClick:sr,onPaneMouseEnter:xe,onPaneMouseMove:Me,onPaneMouseLeave:Ze,onPaneScroll:Dt,onPaneContextMenu:ie,paneClickDistance:Pe,nodeClickDistance:He,onSelectionContextMenu:z,onSelectionStart:C,onSelectionEnd:T,onReconnect:cn,onReconnectStart:ir,onReconnectEnd:Ds,onEdgeContextMenu:ns,onEdgeDoubleClick:cr,onEdgeMouseEnter:Xn,onEdgeMouseMove:zr,onEdgeMouseLeave:st,reconnectRadius:Br,defaultMarkerColor:Tt,noDragClassName:hs,noWheelClassName:Ee,noPanClassName:tn,rfId:We,disableKeyboardA11y:Wt,nodeExtent:ot,viewport:Pi,onViewportChange:un}),o.jsx(M5,{onSelectionChange:W}),Ft,o.jsx(I5,{proOptions:Vn,position:Hr}),o.jsx(A5,{rfId:We,disableKeyboardA11y:Wt})]})})}var t0=vA(aB);function n0(){const e=Dn();return h.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),s=Array.isArray(t)?t:[t],i=new Map;s.forEach(a=>{const l=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);l&&i.set(a,{id:a,nodeElement:l,force:!0})}),requestAnimationFrame(()=>r(i,{triggerFitView:!1}))},[])}function UA(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(i=>Ym(s,i)),[]);return[t,n,r]}function KA(e){const[t,n]=h.useState(e),r=h.useCallback(s=>n(i=>Zv(s,i)),[]);return[t,n,r]}function lB({dimensions:e,lineWidth:t,variant:n,className:r}){return o.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:gr(["react-flow__background-pattern",n,r])})}function cB({radius:e,className:t}){return o.jsx("circle",{cx:e,cy:e,r:e,className:gr(["react-flow__background-pattern","dots",t])})}var el;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(el||(el={}));const uB={[el.Dots]:1,[el.Lines]:1,[el.Cross]:6},dB=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function qA({id:e,variant:t=el.Dots,gap:n=20,size:r,lineWidth:s=1,offset:i=0,color:a,bgColor:l,style:u,className:d,patternClassName:f}){const c=h.useRef(null),{transform:p,patternId:m}=Ht(dB,Hn),g=r||uB[t],b=t===el.Dots,k=t===el.Cross,y=Array.isArray(n)?n:[n,n],v=[y[0]*p[2]||1,y[1]*p[2]||1],w=g*p[2],j=Array.isArray(i)?i:[i,i],P=k?[w,w]:v,_=[j[0]*p[2]||1+P[0]/2,j[1]*p[2]||1+P[1]/2],L=`${m}${e||""}`;return o.jsxs("svg",{className:gr(["react-flow__background",d]),style:{...u,...Gg,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:c,"data-testid":"rf__background",children:[o.jsx("pattern",{id:L,x:p[0]%v[0],y:p[1]%v[1],width:v[0],height:v[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`,children:b?o.jsx(cB,{radius:w/2,className:f}):o.jsx(lB,{dimensions:P,lineWidth:s,variant:t,className:f})}),o.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${L})`})]})}qA.displayName="Background";const r0=h.memo(qA);function fB(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:o.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function pB(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:o.jsx("path",{d:"M0 0h32v4.2H0z"})})}function hB(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:o.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 mB(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o.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 gB(){return o.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:o.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 jh({children:e,className:t,...n}){return o.jsx("button",{type:"button",className:gr(["react-flow__controls-button",t]),...n,children:e})}const yB=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function YA({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:i,onZoomOut:a,onFitView:l,onInteractiveChange:u,className:d,children:f,position:c="bottom-left",orientation:p="vertical","aria-label":m}){const g=Dn(),{isInteractive:b,minZoomReached:k,maxZoomReached:y,ariaLabelConfig:v}=Ht(yB,Hn),{zoomIn:w,zoomOut:j,fitView:P}=fc(),_=()=>{w(),i==null||i()},L=()=>{j(),a==null||a()},B=()=>{P(s),l==null||l()},D=()=>{g.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),u==null||u(!b)},F=p==="horizontal"?"horizontal":"vertical";return o.jsxs(Tu,{className:gr(["react-flow__controls",F,d]),position:c,style:e,"data-testid":"rf__controls","aria-label":m??v["controls.ariaLabel"],children:[t&&o.jsxs(o.Fragment,{children:[o.jsx(jh,{onClick:_,className:"react-flow__controls-zoomin",title:v["controls.zoomIn.ariaLabel"],"aria-label":v["controls.zoomIn.ariaLabel"],disabled:y,children:o.jsx(fB,{})}),o.jsx(jh,{onClick:L,className:"react-flow__controls-zoomout",title:v["controls.zoomOut.ariaLabel"],"aria-label":v["controls.zoomOut.ariaLabel"],disabled:k,children:o.jsx(pB,{})})]}),n&&o.jsx(jh,{className:"react-flow__controls-fitview",onClick:B,title:v["controls.fitView.ariaLabel"],"aria-label":v["controls.fitView.ariaLabel"],children:o.jsx(hB,{})}),r&&o.jsx(jh,{className:"react-flow__controls-interactive",onClick:D,title:v["controls.interactive.ariaLabel"],"aria-label":v["controls.interactive.ariaLabel"],children:b?o.jsx(gB,{}):o.jsx(mB,{})}),f]})}YA.displayName="Controls";const xB=h.memo(YA);function wB({id:e,x:t,y:n,width:r,height:s,style:i,color:a,strokeColor:l,strokeWidth:u,className:d,borderRadius:f,shapeRendering:c,selected:p,onClick:m}){const{background:g,backgroundColor:b}=i||{},k=a||g||b;return o.jsx("rect",{className:gr(["react-flow__minimap-node",{selected:p},d]),x:t,y:n,rx:f,ry:f,width:r,height:s,style:{fill:k,stroke:l,strokeWidth:u},shapeRendering:c,onClick:m?y=>m(y,e):void 0})}const bB=h.memo(wB),vB=e=>e.nodes.map(t=>t.id),fx=e=>e instanceof Function?e:()=>e;function kB({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i=bB,onClick:a}){const l=Ht(vB,Hn),u=fx(t),d=fx(e),f=fx(n),c=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return o.jsx(o.Fragment,{children:l.map(p=>o.jsx(NB,{id:p,nodeColorFunc:u,nodeStrokeColorFunc:d,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:s,NodeComponent:i,onClick:a,shapeRendering:c},p))})}function SB({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:s,nodeStrokeWidth:i,shapeRendering:a,NodeComponent:l,onClick:u}){const{node:d,x:f,y:c,width:p,height:m}=Ht(g=>{const b=g.nodeLookup.get(e);if(!b)return{node:void 0,x:0,y:0,width:0,height:0};const k=b.internals.userNode,{x:y,y:v}=b.internals.positionAbsolute,{width:w,height:j}=ha(k);return{node:k,x:y,y:v,width:w,height:j}},Hn);return!d||d.hidden||!VP(d)?null:o.jsx(l,{x:f,y:c,width:p,height:m,style:d.style,selected:!!d.selected,className:r(d),color:t(d),borderRadius:s,strokeColor:n(d),strokeWidth:i,shapeRendering:a,onClick:u,id:d.id})}const NB=h.memo(SB);var jB=h.memo(kB);const CB=200,EB=150,_B=e=>!e.hidden,PB=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?WP(lp(e.nodeLookup,{filter:_B}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},AB="react-flow__minimap-desc";function GA({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:s="",nodeBorderRadius:i=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:u,maskColor:d,maskStrokeColor:f,maskStrokeWidth:c,position:p="bottom-right",onClick:m,onNodeClick:g,pannable:b=!1,zoomable:k=!1,ariaLabel:y,inversePan:v,zoomStep:w=1,offsetScale:j=5}){const P=Dn(),_=h.useRef(null),{boundingRect:L,viewBB:B,rfId:D,panZoom:F,translateExtent:R,flowWidth:M,flowHeight:W,ariaLabelConfig:O}=Ht(PB,Hn),$=(e==null?void 0:e.width)??CB,I=(e==null?void 0:e.height)??EB,z=L.width/$,C=L.height/I,T=Math.max(z,C),E=T*$,G=T*I,Z=j*T,V=L.x-(E-L.width)/2-Z,se=L.y-(G-L.height)/2-Z,de=E+Z*2,fe=G+Z*2,pe=`${AB}-${D}`,ae=h.useRef(0),be=h.useRef();ae.current=T,h.useEffect(()=>{if(_.current&&F)return be.current=D3({domNode:_.current,panZoom:F,getTransform:()=>P.getState().transform,getViewScale:()=>ae.current}),()=>{var Ie;(Ie=be.current)==null||Ie.destroy()}},[F]),h.useEffect(()=>{var Ie;(Ie=be.current)==null||Ie.update({translateExtent:R,width:M,height:W,inversePan:v,pannable:b,zoomStep:w,zoomable:k})},[b,k,v,w,R,M,W]);const _e=m?Ie=>{var Je;const[et,ft]=((Je=be.current)==null?void 0:Je.pointer(Ie))||[0,0];m(Ie,{x:et,y:ft})}:void 0,we=g?h.useCallback((Ie,et)=>{const ft=P.getState().nodeLookup.get(et).internals.userNode;g(Ie,ft)},[]):void 0,Oe=y??O["minimap.ariaLabel"];return o.jsx(Tu,{position:p,style:{...e,"--xy-minimap-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-background-color-props":typeof d=="string"?d:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof c=="number"?c*T: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:gr(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:o.jsxs("svg",{width:$,height:I,viewBox:`${V} ${se} ${de} ${fe}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":pe,ref:_,onClick:_e,children:[Oe&&o.jsx("title",{id:pe,children:Oe}),o.jsx(jB,{onClick:we,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:i,nodeClassName:s,nodeStrokeWidth:a,nodeComponent:l}),o.jsx("path",{className:"react-flow__minimap-mask",d:`M${V-Z},${se-Z}h${de+Z*2}v${fe+Z*2}h${-de-Z*2}z
66
- M${B.x},${B.y}h${B.width}v${B.height}h${-B.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}GA.displayName="MiniMap";const IB=h.memo(GA),TB=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,RB={[Au.Line]:"right",[Au.Handle]:"bottom-right"};function LB({nodeId:e,position:t,variant:n=Au.Handle,className:r,style:s=void 0,children:i,color:a,minWidth:l=10,minHeight:u=10,maxWidth:d=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:c=!1,resizeDirection:p,autoScale:m=!0,shouldResize:g,onResizeStart:b,onResize:k,onResizeEnd:y}){const v=jA(),w=typeof e=="string"?e:v,j=Dn(),P=h.useRef(null),_=n===Au.Handle,L=Ht(h.useCallback(TB(_&&m),[_,m]),Hn),B=h.useRef(null),D=t??RB[n];h.useEffect(()=>{if(!(!P.current||!w))return B.current||(B.current=Q3({domNode:P.current,nodeId:w,getStoreItems:()=>{const{nodeLookup:R,transform:M,snapGrid:W,snapToGrid:O,nodeOrigin:$,domNode:I}=j.getState();return{nodeLookup:R,transform:M,snapGrid:W,snapToGrid:O,nodeOrigin:$,paneDomNode:I}},onChange:(R,M)=>{const{triggerNodeChanges:W,nodeLookup:O,parentLookup:$,nodeOrigin:I}=j.getState(),z=[],C={x:R.x,y:R.y},T=O.get(w);if(T&&T.expandParent&&T.parentId){const E=T.origin??I,G=R.width??T.measured.width??0,Z=R.height??T.measured.height??0,V={id:T.id,parentId:T.parentId,rect:{width:G,height:Z,...UP({x:R.x??T.position.x,y:R.y??T.position.y},{width:G,height:Z},T.parentId,O,E)}},se=Qv([V],O,$,I);z.push(...se),C.x=R.x?Math.max(E[0]*G,R.x):void 0,C.y=R.y?Math.max(E[1]*Z,R.y):void 0}if(C.x!==void 0&&C.y!==void 0){const E={id:w,type:"position",position:{...C}};z.push(E)}if(R.width!==void 0&&R.height!==void 0){const G={id:w,type:"dimensions",resizing:!0,setAttributes:p?p==="horizontal"?"width":"height":!0,dimensions:{width:R.width,height:R.height}};z.push(G)}for(const E of M){const G={...E,type:"position"};z.push(G)}W(z)},onEnd:({width:R,height:M})=>{const W={id:w,type:"dimensions",resizing:!1,dimensions:{width:R,height:M}};j.getState().triggerNodeChanges([W])}})),B.current.update({controlPosition:D,boundaries:{minWidth:l,minHeight:u,maxWidth:d,maxHeight:f},keepAspectRatio:c,resizeDirection:p,onResizeStart:b,onResize:k,onResizeEnd:y,shouldResize:g}),()=>{var R;(R=B.current)==null||R.destroy()}},[D,l,u,d,f,c,b,k,y,g]);const F=D.split("-");return o.jsx("div",{className:gr(["react-flow__resize-control","nodrag",...F,n,r]),ref:P,style:{...s,scale:L,...a&&{[_?"backgroundColor":"borderColor"]:a}},children:i})}const XA=h.memo(LB);function OB(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const MB=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,$B=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,DB={};function NN(e,t){return(DB.jsx?$B:MB).test(e)}const FB=/[ \t\n\f\r]/g;function zB(e){return typeof e=="object"?e.type==="text"?jN(e.value):!1:jN(e)}function jN(e){return e.replace(FB,"")===""}let dp=class{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}};dp.prototype.normal={};dp.prototype.property={};dp.prototype.space=void 0;function JA(e,t){const n={},r={};for(const s of e)Object.assign(n,s.property),Object.assign(r,s.normal);return new dp(n,r,t)}function ub(e){return e.toLowerCase()}class $s{constructor(t,n){this.attribute=n,this.property=t}}$s.prototype.attribute="";$s.prototype.booleanish=!1;$s.prototype.boolean=!1;$s.prototype.commaOrSpaceSeparated=!1;$s.prototype.commaSeparated=!1;$s.prototype.defined=!1;$s.prototype.mustUseProperty=!1;$s.prototype.number=!1;$s.prototype.overloadedBoolean=!1;$s.prototype.property="";$s.prototype.spaceSeparated=!1;$s.prototype.space=void 0;let BB=0;const Et=pc(),pr=pc(),db=pc(),Ce=pc(),Cn=pc(),pu=pc(),qs=pc();function pc(){return 2**++BB}const fb=Object.freeze(Object.defineProperty({__proto__:null,boolean:Et,booleanish:pr,commaOrSpaceSeparated:qs,commaSeparated:pu,number:Ce,overloadedBoolean:db,spaceSeparated:Cn},Symbol.toStringTag,{value:"Module"})),px=Object.keys(fb);class s0 extends $s{constructor(t,n,r,s){let i=-1;if(super(t,n),CN(this,"space",s),typeof r=="number")for(;++i<px.length;){const a=px[i];CN(this,px[i],(r&fb[a])===fb[a])}}}s0.prototype.defined=!0;function CN(e,t,n){n&&(e[t]=n)}function Bu(e){const t={},n={};for(const[r,s]of Object.entries(e.properties)){const i=new s0(r,e.transform(e.attributes||{},r),s,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(i.mustUseProperty=!0),t[r]=i,n[ub(r)]=r,n[ub(i.attribute)]=r}return new dp(t,n,e.space)}const QA=Bu({properties:{ariaActiveDescendant:null,ariaAtomic:pr,ariaAutoComplete:null,ariaBusy:pr,ariaChecked:pr,ariaColCount:Ce,ariaColIndex:Ce,ariaColSpan:Ce,ariaControls:Cn,ariaCurrent:null,ariaDescribedBy:Cn,ariaDetails:null,ariaDisabled:pr,ariaDropEffect:Cn,ariaErrorMessage:null,ariaExpanded:pr,ariaFlowTo:Cn,ariaGrabbed:pr,ariaHasPopup:null,ariaHidden:pr,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:Cn,ariaLevel:Ce,ariaLive:null,ariaModal:pr,ariaMultiLine:pr,ariaMultiSelectable:pr,ariaOrientation:null,ariaOwns:Cn,ariaPlaceholder:null,ariaPosInSet:Ce,ariaPressed:pr,ariaReadOnly:pr,ariaRelevant:null,ariaRequired:pr,ariaRoleDescription:Cn,ariaRowCount:Ce,ariaRowIndex:Ce,ariaRowSpan:Ce,ariaSelected:pr,ariaSetSize:Ce,ariaSort:null,ariaValueMax:Ce,ariaValueMin:Ce,ariaValueNow:Ce,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function ZA(e,t){return t in e?e[t]:t}function eI(e,t){return ZA(e,t.toLowerCase())}const HB=Bu({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:pu,acceptCharset:Cn,accessKey:Cn,action:null,allow:null,allowFullScreen:Et,allowPaymentRequest:Et,allowUserMedia:Et,alt:null,as:null,async:Et,autoCapitalize:null,autoComplete:Cn,autoFocus:Et,autoPlay:Et,blocking:Cn,capture:null,charSet:null,checked:Et,cite:null,className:Cn,cols:Ce,colSpan:null,content:null,contentEditable:pr,controls:Et,controlsList:Cn,coords:Ce|pu,crossOrigin:null,data:null,dateTime:null,decoding:null,default:Et,defer:Et,dir:null,dirName:null,disabled:Et,download:db,draggable:pr,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:Et,formTarget:null,headers:Cn,height:Ce,hidden:db,high:Ce,href:null,hrefLang:null,htmlFor:Cn,httpEquiv:Cn,id:null,imageSizes:null,imageSrcSet:null,inert:Et,inputMode:null,integrity:null,is:null,isMap:Et,itemId:null,itemProp:Cn,itemRef:Cn,itemScope:Et,itemType:Cn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:Et,low:Ce,manifest:null,max:null,maxLength:Ce,media:null,method:null,min:null,minLength:Ce,multiple:Et,muted:Et,name:null,nonce:null,noModule:Et,noValidate:Et,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:Et,optimum:Ce,pattern:null,ping:Cn,placeholder:null,playsInline:Et,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:Et,referrerPolicy:null,rel:Cn,required:Et,reversed:Et,rows:Ce,rowSpan:Ce,sandbox:Cn,scope:null,scoped:Et,seamless:Et,selected:Et,shadowRootClonable:Et,shadowRootDelegatesFocus:Et,shadowRootMode:null,shape:null,size:Ce,sizes:null,slot:null,span:Ce,spellCheck:pr,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Ce,step:null,style:null,tabIndex:Ce,target:null,title:null,translate:null,type:null,typeMustMatch:Et,useMap:null,value:pr,width:Ce,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:Cn,axis:null,background:null,bgColor:null,border:Ce,borderColor:null,bottomMargin:Ce,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:Et,declare:Et,event:null,face:null,frame:null,frameBorder:null,hSpace:Ce,leftMargin:Ce,link:null,longDesc:null,lowSrc:null,marginHeight:Ce,marginWidth:Ce,noResize:Et,noHref:Et,noShade:Et,noWrap:Et,object:null,profile:null,prompt:null,rev:null,rightMargin:Ce,rules:null,scheme:null,scrolling:pr,standby:null,summary:null,text:null,topMargin:Ce,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Ce,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:Et,disableRemotePlayback:Et,prefix:null,property:null,results:Ce,security:null,unselectable:null},space:"html",transform:eI}),WB=Bu({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:qs,accentHeight:Ce,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Ce,amplitude:Ce,arabicForm:null,ascent:Ce,attributeName:null,attributeType:null,azimuth:Ce,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Ce,by:null,calcMode:null,capHeight:Ce,className:Cn,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:Ce,diffuseConstant:Ce,direction:null,display:null,dur:null,divisor:Ce,dominantBaseline:null,download:Et,dx:null,dy:null,edgeMode:null,editable:null,elevation:Ce,enableBackground:null,end:null,event:null,exponent:Ce,externalResourcesRequired:null,fill:null,fillOpacity:Ce,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:pu,g2:pu,glyphName:pu,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Ce,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Ce,horizOriginX:Ce,horizOriginY:Ce,id:null,ideographic:Ce,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Ce,k:Ce,k1:Ce,k2:Ce,k3:Ce,k4:Ce,kernelMatrix:qs,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Ce,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:Ce,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:Ce,overlineThickness:Ce,paintOrder:null,panose1:null,path:null,pathLength:Ce,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:Cn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Ce,pointsAtY:Ce,pointsAtZ:Ce,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:qs,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:qs,rev:qs,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:qs,requiredFeatures:qs,requiredFonts:qs,requiredFormats:qs,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:Ce,specularExponent:Ce,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Ce,strikethroughThickness:Ce,string:null,stroke:null,strokeDashArray:qs,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Ce,strokeOpacity:Ce,strokeWidth:null,style:null,surfaceScale:Ce,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:qs,tabIndex:Ce,tableValues:null,target:null,targetX:Ce,targetY:Ce,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:qs,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Ce,underlineThickness:Ce,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Ce,values:null,vAlphabetic:Ce,vMathematical:Ce,vectorEffect:null,vHanging:Ce,vIdeographic:Ce,version:null,vertAdvY:Ce,vertOriginX:Ce,vertOriginY:Ce,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Ce,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:ZA}),tI=Bu({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()}}),nI=Bu({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:eI}),rI=Bu({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),VB={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"},UB=/[A-Z]/g,EN=/-[a-z]/g,KB=/^data[-\w.:]+$/i;function qB(e,t){const n=ub(t);let r=t,s=$s;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&KB.test(t)){if(t.charAt(4)==="-"){const i=t.slice(5).replace(EN,GB);r="data"+i.charAt(0).toUpperCase()+i.slice(1)}else{const i=t.slice(4);if(!EN.test(i)){let a=i.replace(UB,YB);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}s=s0}return new s(r,t)}function YB(e){return"-"+e.toLowerCase()}function GB(e){return e.charAt(1).toUpperCase()}const XB=JA([QA,HB,tI,nI,rI],"html"),i0=JA([QA,WB,tI,nI,rI],"svg");function JB(e){return e.join(" ").trim()}var o0={},_N=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,QB=/\n/g,ZB=/^\s*/,eH=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,tH=/^:\s*/,nH=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,rH=/^[;\s]*/,sH=/^\s+|\s+$/g,iH=`
67
- `,PN="/",AN="*",Bl="",oH="comment",aH="declaration";function lH(e,t){if(typeof e!="string")throw new TypeError("First argument must be a string");if(!e)return[];t=t||{};var n=1,r=1;function s(g){var b=g.match(QB);b&&(n+=b.length);var k=g.lastIndexOf(iH);r=~k?g.length-k:r+g.length}function i(){var g={line:n,column:r};return function(b){return b.position=new a(g),d(),b}}function a(g){this.start=g,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function l(g){var b=new Error(t.source+":"+n+":"+r+": "+g);if(b.reason=g,b.filename=t.source,b.line=n,b.column=r,b.source=e,!t.silent)throw b}function u(g){var b=g.exec(e);if(b){var k=b[0];return s(k),e=e.slice(k.length),b}}function d(){u(ZB)}function f(g){var b;for(g=g||[];b=c();)b!==!1&&g.push(b);return g}function c(){var g=i();if(!(PN!=e.charAt(0)||AN!=e.charAt(1))){for(var b=2;Bl!=e.charAt(b)&&(AN!=e.charAt(b)||PN!=e.charAt(b+1));)++b;if(b+=2,Bl===e.charAt(b-1))return l("End of comment missing");var k=e.slice(2,b-2);return r+=2,s(k),e=e.slice(b),r+=2,g({type:oH,comment:k})}}function p(){var g=i(),b=u(eH);if(b){if(c(),!u(tH))return l("property missing ':'");var k=u(nH),y=g({type:aH,property:IN(b[0].replace(_N,Bl)),value:k?IN(k[0].replace(_N,Bl)):Bl});return u(rH),y}}function m(){var g=[];f(g);for(var b;b=p();)b!==!1&&(g.push(b),f(g));return g}return d(),m()}function IN(e){return e?e.replace(sH,Bl):Bl}var cH=lH,uH=ff&&ff.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(o0,"__esModule",{value:!0});o0.default=fH;const dH=uH(cH);function fH(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,dH.default)(e),s=typeof t=="function";return r.forEach(i=>{if(i.type!=="declaration")return;const{property:a,value:l}=i;s?t(a,l,i):l&&(n=n||{},n[a]=l)}),n}var Qg={};Object.defineProperty(Qg,"__esModule",{value:!0});Qg.camelCase=void 0;var pH=/^--[a-zA-Z0-9_-]+$/,hH=/-([a-z])/g,mH=/^[^-]+$/,gH=/^-(webkit|moz|ms|o|khtml)-/,yH=/^-(ms)-/,xH=function(e){return!e||mH.test(e)||pH.test(e)},wH=function(e,t){return t.toUpperCase()},TN=function(e,t){return"".concat(t,"-")},bH=function(e,t){return t===void 0&&(t={}),xH(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(yH,TN):e=e.replace(gH,TN),e.replace(hH,wH))};Qg.camelCase=bH;var vH=ff&&ff.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},kH=vH(o0),SH=Qg;function pb(e,t){var n={};return!e||typeof e!="string"||(0,kH.default)(e,function(r,s){r&&s&&(n[(0,SH.camelCase)(r,t)]=s)}),n}pb.default=pb;var NH=pb;const jH=ul(NH),sI=iI("end"),a0=iI("start");function iI(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 CH(e){const t=a0(e),n=sI(e);if(t&&n)return{start:t,end:n}}function of(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?RN(e.position):"start"in e||"end"in e?RN(e):"line"in e||"column"in e?hb(e):""}function hb(e){return LN(e&&e.line)+":"+LN(e&&e.column)}function RN(e){return hb(e&&e.start)+"-"+hb(e&&e.end)}function LN(e){return e&&typeof e=="number"?e:1}class es extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let s="",i={},a=!1;if(n&&("line"in n&&"column"in n?i={place:n}:"start"in n&&"end"in n?i={place:n}:"type"in n?i={ancestors:[n],place:n.position}:i={...n}),typeof t=="string"?s=t:!i.cause&&t&&(a=!0,s=t.message,i.cause=t),!i.ruleId&&!i.source&&typeof r=="string"){const u=r.indexOf(":");u===-1?i.ruleId=r:(i.source=r.slice(0,u),i.ruleId=r.slice(u+1))}if(!i.place&&i.ancestors&&i.ancestors){const u=i.ancestors[i.ancestors.length-1];u&&(i.place=u.position)}const l=i.place&&"start"in i.place?i.place.start:i.place;this.ancestors=i.ancestors||void 0,this.cause=i.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=of(i.place)||"1:1",this.place=i.place||void 0,this.reason=this.message,this.ruleId=i.ruleId||void 0,this.source=i.source||void 0,this.stack=a&&i.cause&&typeof i.cause.stack=="string"?i.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}es.prototype.file="";es.prototype.name="";es.prototype.reason="";es.prototype.message="";es.prototype.stack="";es.prototype.column=void 0;es.prototype.line=void 0;es.prototype.ancestors=void 0;es.prototype.cause=void 0;es.prototype.fatal=void 0;es.prototype.place=void 0;es.prototype.ruleId=void 0;es.prototype.source=void 0;const l0={}.hasOwnProperty,EH=new Map,_H=/[A-Z]/g,PH=new Set(["table","tbody","thead","tfoot","tr"]),AH=new Set(["td","th"]),oI="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function IH(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=FH(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=DH(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"?i0:XB,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},i=aI(s,e,void 0);return i&&typeof i!="string"?i:s.create(e,s.Fragment,{children:i||void 0},void 0)}function aI(e,t,n){if(t.type==="element")return TH(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return RH(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return OH(e,t,n);if(t.type==="mdxjsEsm")return LH(e,t);if(t.type==="root")return MH(e,t,n);if(t.type==="text")return $H(e,t)}function TH(e,t,n){const r=e.schema;let s=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(s=i0,e.schema=s),e.ancestors.push(t);const i=cI(e,t.tagName,!1),a=zH(e,t);let l=u0(e,t);return PH.has(t.tagName)&&(l=l.filter(function(u){return typeof u=="string"?!zB(u):!0})),lI(e,a,i,t),c0(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function RH(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)}Bf(e,t.position)}function LH(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);Bf(e,t.position)}function OH(e,t,n){const r=e.schema;let s=r;t.name==="svg"&&r.space==="html"&&(s=i0,e.schema=s),e.ancestors.push(t);const i=t.name===null?e.Fragment:cI(e,t.name,!0),a=BH(e,t),l=u0(e,t);return lI(e,a,i,t),c0(a,l),e.ancestors.pop(),e.schema=r,e.create(t,i,a,n)}function MH(e,t,n){const r={};return c0(r,u0(e,t)),e.create(t,e.Fragment,r,n)}function $H(e,t){return t.value}function lI(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function c0(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function DH(e,t,n){return r;function r(s,i,a,l){const d=Array.isArray(a.children)?n:t;return l?d(i,a,l):d(i,a)}}function FH(e,t){return n;function n(r,s,i,a){const l=Array.isArray(i.children),u=a0(r);return t(s,i,a,l,{columnNumber:u?u.column-1:void 0,fileName:e,lineNumber:u?u.line:void 0},void 0)}}function zH(e,t){const n={};let r,s;for(s in t.properties)if(s!=="children"&&l0.call(t.properties,s)){const i=HH(e,s,t.properties[s]);if(i){const[a,l]=i;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&AH.has(t.tagName)?r=l:n[a]=l}}if(r){const i=n.style||(n.style={});i[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function BH(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const i=r.data.estree.body[0];i.type;const a=i.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else Bf(e,t.position);else{const s=r.name;let i;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,i=e.evaluater.evaluateExpression(l.expression)}else Bf(e,t.position);else i=r.value===null?!0:r.value;n[s]=i}return n}function u0(e,t){const n=[];let r=-1;const s=e.passKeys?new Map:EH;for(;++r<t.children.length;){const i=t.children[r];let a;if(e.passKeys){const u=i.type==="element"?i.tagName:i.type==="mdxJsxFlowElement"||i.type==="mdxJsxTextElement"?i.name:void 0;if(u){const d=s.get(u)||0;a=u+"-"+d,s.set(u,d+1)}}const l=aI(e,i,a);l!==void 0&&n.push(l)}return n}function HH(e,t,n){const r=qB(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?OB(n):JB(n)),r.property==="style"){let s=typeof n=="object"?n:WH(e,String(n));return e.stylePropertyNameCase==="css"&&(s=VH(s)),["style",s]}return[e.elementAttributeNameCase==="react"&&r.space?VB[r.property]||r.property:r.attribute,n]}}function WH(e,t){try{return jH(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,s=new es("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=oI+"#cannot-parse-style-attribute",s}}function cI(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const s=t.split(".");let i=-1,a;for(;++i<s.length;){const l=NN(s[i])?{type:"Identifier",name:s[i]}:{type:"Literal",value:s[i]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(i&&l.type==="Literal"),optional:!1}:l}r=a}else r=NN(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const s=r.value;return l0.call(e.components,s)?e.components[s]:s}if(e.evaluater)return e.evaluater.evaluateExpression(r);Bf(e)}function Bf(e,t){const n=new es("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=oI+"#cannot-handle-mdx-estrees-without-createevaluater",n}function VH(e){const t={};let n;for(n in e)l0.call(e,n)&&(t[UH(n)]=e[n]);return t}function UH(e){let t=e.replace(_H,KH);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function KH(e){return"-"+e.toLowerCase()}const hx={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"]},qH={};function YH(e,t){const n=qH,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,s=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return uI(e,r,s)}function uI(e,t,n){if(GH(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 ON(e.children,t,n)}return Array.isArray(e)?ON(e,t,n):""}function ON(e,t,n){const r=[];let s=-1;for(;++s<e.length;)r[s]=uI(e[s],t,n);return r.join("")}function GH(e){return!!(e&&typeof e=="object")}const MN=document.createElement("i");function d0(e){const t="&"+e+";";MN.innerHTML=t;const n=MN.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Ao(e,t,n,r){const s=e.length;let i=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);i<r.length;)a=r.slice(i,i+1e4),a.unshift(t,0),e.splice(...a),i+=1e4,t+=1e4}function ki(e,t){return e.length>0?(Ao(e,e.length,0,t),e):t}const $N={}.hasOwnProperty;function XH(e){const t={};let n=-1;for(;++n<e.length;)JH(t,e[n]);return t}function JH(e,t){let n;for(n in t){const s=($N.call(e,n)?e[n]:void 0)||(e[n]={}),i=t[n];let a;if(i)for(a in i){$N.call(s,a)||(s[a]=[]);const l=i[a];QH(s[a],Array.isArray(l)?l:l?[l]:[])}}}function QH(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Ao(e,0,0,r)}function dI(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 hu(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const vo=hl(/[A-Za-z]/),Qs=hl(/[\dA-Za-z]/),ZH=hl(/[#-'*+\--9=?A-Z^-~]/);function mb(e){return e!==null&&(e<32||e===127)}const gb=hl(/\d/),e6=hl(/[\dA-Fa-f]/),t6=hl(/[!-/:-@[-`{-~]/);function xt(e){return e!==null&&e<-2}function Os(e){return e!==null&&(e<0||e===32)}function Zt(e){return e===-2||e===-1||e===32}const n6=hl(new RegExp("\\p{P}|\\p{S}","u")),r6=hl(/\s/);function hl(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function Hu(e){const t=[];let n=-1,r=0,s=0;for(;++n<e.length;){const i=e.charCodeAt(n);let a="";if(i===37&&Qs(e.charCodeAt(n+1))&&Qs(e.charCodeAt(n+2)))s=2;else if(i<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(i))||(a=String.fromCharCode(i));else if(i>55295&&i<57344){const l=e.charCodeAt(n+1);i<56320&&l>56319&&l<57344?(a=String.fromCharCode(i,l),s=1):a="�"}else a=String.fromCharCode(i);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 _n(e,t,n,r){const s=r?r-1:Number.POSITIVE_INFINITY;let i=0;return a;function a(u){return Zt(u)?(e.enter(n),l(u)):t(u)}function l(u){return Zt(u)&&i++<s?(e.consume(u),l):(e.exit(n),t(u))}}const s6={tokenize:i6};function i6(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"),_n(e,t,"linePrefix")}function s(l){return e.enter("paragraph"),i(l)}function i(l){const u=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=u),n=u,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return xt(l)?(e.consume(l),e.exit("chunkText"),i):(e.consume(l),a)}}const o6={tokenize:a6},DN={tokenize:l6};function a6(e){const t=this,n=[];let r=0,s,i,a;return l;function l(w){if(r<n.length){const j=n[r];return t.containerState=j[1],e.attempt(j[0].continuation,u,d)(w)}return d(w)}function u(w){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,s&&v();const j=t.events.length;let P=j,_;for(;P--;)if(t.events[P][0]==="exit"&&t.events[P][1].type==="chunkFlow"){_=t.events[P][1].end;break}y(r);let L=j;for(;L<t.events.length;)t.events[L][1].end={..._},L++;return Ao(t.events,P+1,0,t.events.slice(j)),t.events.length=L,d(w)}return l(w)}function d(w){if(r===n.length){if(!s)return p(w);if(s.currentConstruct&&s.currentConstruct.concrete)return g(w);t.interrupt=!!(s.currentConstruct&&!s._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(DN,f,c)(w)}function f(w){return s&&v(),y(r),p(w)}function c(w){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,g(w)}function p(w){return t.containerState={},e.attempt(DN,m,g)(w)}function m(w){return r++,n.push([t.currentConstruct,t.containerState]),p(w)}function g(w){if(w===null){s&&v(),y(0),e.consume(w);return}return s=s||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:s,contentType:"flow",previous:i}),b(w)}function b(w){if(w===null){k(e.exit("chunkFlow"),!0),y(0),e.consume(w);return}return xt(w)?(e.consume(w),k(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(w),b)}function k(w,j){const P=t.sliceStream(w);if(j&&P.push(null),w.previous=i,i&&(i.next=w),i=w,s.defineSkip(w.start),s.write(P),t.parser.lazy[w.start.line]){let _=s.events.length;for(;_--;)if(s.events[_][1].start.offset<a&&(!s.events[_][1].end||s.events[_][1].end.offset>a))return;const L=t.events.length;let B=L,D,F;for(;B--;)if(t.events[B][0]==="exit"&&t.events[B][1].type==="chunkFlow"){if(D){F=t.events[B][1].end;break}D=!0}for(y(r),_=L;_<t.events.length;)t.events[_][1].end={...F},_++;Ao(t.events,B+1,0,t.events.slice(L)),t.events.length=_}}function y(w){let j=n.length;for(;j-- >w;){const P=n[j];t.containerState=P[1],P[0].exit.call(t,e)}n.length=w}function v(){s.write([null]),i=void 0,s=void 0,t.containerState._closeFlow=void 0}}function l6(e,t,n){return _n(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function FN(e){if(e===null||Os(e)||r6(e))return 1;if(n6(e))return 2}function f0(e,t,n){const r=[];let s=-1;for(;++s<e.length;){const i=e[s].resolveAll;i&&!r.includes(i)&&(t=i(t,n),r.push(i))}return t}const yb={name:"attention",resolveAll:c6,tokenize:u6};function c6(e,t){let n=-1,r,s,i,a,l,u,d,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;u=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 c={...e[r][1].end},p={...e[n][1].start};zN(c,-u),zN(p,u),a={type:u>1?"strongSequence":"emphasisSequence",start:c,end:{...e[r][1].end}},l={type:u>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:p},i={type:u>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},s={type:u>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},d=[],e[r][1].end.offset-e[r][1].start.offset&&(d=ki(d,[["enter",e[r][1],t],["exit",e[r][1],t]])),d=ki(d,[["enter",s,t],["enter",a,t],["exit",a,t],["enter",i,t]]),d=ki(d,f0(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),d=ki(d,[["exit",i,t],["enter",l,t],["exit",l,t],["exit",s,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,d=ki(d,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,Ao(e,r-1,n-r+3,d),n=r+d.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function u6(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,s=FN(r);let i;return a;function a(u){return i=u,e.enter("attentionSequence"),l(u)}function l(u){if(u===i)return e.consume(u),l;const d=e.exit("attentionSequence"),f=FN(u),c=!f||f===2&&s||n.includes(u),p=!s||s===2&&f||n.includes(r);return d._open=!!(i===42?c:c&&(s||!p)),d._close=!!(i===42?p:p&&(f||!c)),t(u)}}function zN(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const d6={name:"autolink",tokenize:f6};function f6(e,t,n){let r=0;return s;function s(m){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),i}function i(m){return vo(m)?(e.consume(m),a):m===64?n(m):d(m)}function a(m){return m===43||m===45||m===46||Qs(m)?(r=1,l(m)):d(m)}function l(m){return m===58?(e.consume(m),r=0,u):(m===43||m===45||m===46||Qs(m))&&r++<32?(e.consume(m),l):(r=0,d(m))}function u(m){return m===62?(e.exit("autolinkProtocol"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):m===null||m===32||m===60||mb(m)?n(m):(e.consume(m),u)}function d(m){return m===64?(e.consume(m),f):ZH(m)?(e.consume(m),d):n(m)}function f(m){return Qs(m)?c(m):n(m)}function c(m){return m===46?(e.consume(m),r=0,f):m===62?(e.exit("autolinkProtocol").type="autolinkEmail",e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.exit("autolink"),t):p(m)}function p(m){if((m===45||Qs(m))&&r++<63){const g=m===45?p:c;return e.consume(m),g}return n(m)}}const Zg={partial:!0,tokenize:p6};function p6(e,t,n){return r;function r(i){return Zt(i)?_n(e,s,"linePrefix")(i):s(i)}function s(i){return i===null||xt(i)?t(i):n(i)}}const fI={continuation:{tokenize:m6},exit:g6,name:"blockQuote",tokenize:h6};function h6(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"),i}return n(a)}function i(a){return Zt(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function m6(e,t,n){const r=this;return s;function s(a){return Zt(a)?_n(e,i,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):i(a)}function i(a){return e.attempt(fI,t,n)(a)}}function g6(e){e.exit("blockQuote")}const pI={name:"characterEscape",tokenize:y6};function y6(e,t,n){return r;function r(i){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(i),e.exit("escapeMarker"),s}function s(i){return t6(i)?(e.enter("characterEscapeValue"),e.consume(i),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(i)}}const hI={name:"characterReference",tokenize:x6};function x6(e,t,n){const r=this;let s=0,i,a;return l;function l(c){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),u}function u(c){return c===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(c),e.exit("characterReferenceMarkerNumeric"),d):(e.enter("characterReferenceValue"),i=31,a=Qs,f(c))}function d(c){return c===88||c===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(c),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),i=6,a=e6,f):(e.enter("characterReferenceValue"),i=7,a=gb,f(c))}function f(c){if(c===59&&s){const p=e.exit("characterReferenceValue");return a===Qs&&!d0(r.sliceSerialize(p))?n(c):(e.enter("characterReferenceMarker"),e.consume(c),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(c)&&s++<i?(e.consume(c),f):n(c)}}const BN={partial:!0,tokenize:b6},HN={concrete:!0,name:"codeFenced",tokenize:w6};function w6(e,t,n){const r=this,s={partial:!0,tokenize:P};let i=0,a=0,l;return u;function u(_){return d(_)}function d(_){const L=r.events[r.events.length-1];return i=L&&L[1].type==="linePrefix"?L[2].sliceSerialize(L[1],!0).length:0,l=_,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(_)}function f(_){return _===l?(a++,e.consume(_),f):a<3?n(_):(e.exit("codeFencedFenceSequence"),Zt(_)?_n(e,c,"whitespace")(_):c(_))}function c(_){return _===null||xt(_)?(e.exit("codeFencedFence"),r.interrupt?t(_):e.check(BN,b,j)(_)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),p(_))}function p(_){return _===null||xt(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),c(_)):Zt(_)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),_n(e,m,"whitespace")(_)):_===96&&_===l?n(_):(e.consume(_),p)}function m(_){return _===null||xt(_)?c(_):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),g(_))}function g(_){return _===null||xt(_)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),c(_)):_===96&&_===l?n(_):(e.consume(_),g)}function b(_){return e.attempt(s,j,k)(_)}function k(_){return e.enter("lineEnding"),e.consume(_),e.exit("lineEnding"),y}function y(_){return i>0&&Zt(_)?_n(e,v,"linePrefix",i+1)(_):v(_)}function v(_){return _===null||xt(_)?e.check(BN,b,j)(_):(e.enter("codeFlowValue"),w(_))}function w(_){return _===null||xt(_)?(e.exit("codeFlowValue"),v(_)):(e.consume(_),w)}function j(_){return e.exit("codeFenced"),t(_)}function P(_,L,B){let D=0;return F;function F($){return _.enter("lineEnding"),_.consume($),_.exit("lineEnding"),R}function R($){return _.enter("codeFencedFence"),Zt($)?_n(_,M,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)($):M($)}function M($){return $===l?(_.enter("codeFencedFenceSequence"),W($)):B($)}function W($){return $===l?(D++,_.consume($),W):D>=a?(_.exit("codeFencedFenceSequence"),Zt($)?_n(_,O,"whitespace")($):O($)):B($)}function O($){return $===null||xt($)?(_.exit("codeFencedFence"),L($)):B($)}}}function b6(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"),i)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const mx={name:"codeIndented",tokenize:k6},v6={partial:!0,tokenize:S6};function k6(e,t,n){const r=this;return s;function s(d){return e.enter("codeIndented"),_n(e,i,"linePrefix",5)(d)}function i(d){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(d):n(d)}function a(d){return d===null?u(d):xt(d)?e.attempt(v6,a,u)(d):(e.enter("codeFlowValue"),l(d))}function l(d){return d===null||xt(d)?(e.exit("codeFlowValue"),a(d)):(e.consume(d),l)}function u(d){return e.exit("codeIndented"),t(d)}}function S6(e,t,n){const r=this;return s;function s(a){return r.parser.lazy[r.now().line]?n(a):xt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),s):_n(e,i,"linePrefix",5)(a)}function i(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):xt(a)?s(a):n(a)}}const N6={name:"codeText",previous:C6,resolve:j6,tokenize:E6};function j6(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 C6(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function E6(e,t,n){let r=0,s,i;return a;function a(c){return e.enter("codeText"),e.enter("codeTextSequence"),l(c)}function l(c){return c===96?(e.consume(c),r++,l):(e.exit("codeTextSequence"),u(c))}function u(c){return c===null?n(c):c===32?(e.enter("space"),e.consume(c),e.exit("space"),u):c===96?(i=e.enter("codeTextSequence"),s=0,f(c)):xt(c)?(e.enter("lineEnding"),e.consume(c),e.exit("lineEnding"),u):(e.enter("codeTextData"),d(c))}function d(c){return c===null||c===32||c===96||xt(c)?(e.exit("codeTextData"),u(c)):(e.consume(c),d)}function f(c){return c===96?(e.consume(c),s++,f):s===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(c)):(i.type="codeTextData",d(c))}}class _6{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 i=this.right.splice(this.right.length-s,Number.POSITIVE_INFINITY);return r&&Pd(this.left,r),i.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),Pd(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Pd(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);Pd(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Pd(this.left,n.reverse())}}}function Pd(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 mI(e){const t={};let n=-1,r,s,i,a,l,u,d;const f=new _6(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(u=r[1]._tokenizer.events,i=0,i<u.length&&u[i][1].type==="lineEndingBlank"&&(i+=2),i<u.length&&u[i][1].type==="content"))for(;++i<u.length&&u[i][1].type!=="content";)u[i][1].type==="chunkText"&&(u[i][1]._isInFirstContentOfListItem=!0,i++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,P6(f,n)),n=t[n],d=!0);else if(r[1]._container){for(i=n,s=void 0;i--;)if(a=f.get(i),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(s&&(f.get(s)[1].type="lineEndingBlank"),a[1].type="lineEnding",s=i);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;s&&(r[1].end={...f.get(s)[1].start},l=f.slice(s,n),l.unshift(r),f.splice(s,n-s+1,l))}}return Ao(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!d}function P6(e,t){const n=e.get(t)[1],r=e.get(t)[2];let s=t-1;const i=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,u=[],d={};let f,c,p=-1,m=n,g=0,b=0;const k=[b];for(;m;){for(;e.get(++s)[1]!==m;);i.push(s),m._tokenizer||(f=r.sliceStream(m),m.next||f.push(null),c&&a.defineSkip(m.start),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),c=m,m=m.next}for(m=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&&(b=p+1,k.push(b),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(a.events=[],m?(m._tokenizer=void 0,m.previous=void 0):k.pop(),p=k.length;p--;){const y=l.slice(k[p],k[p+1]),v=i.pop();u.push([v,v+y.length-1]),e.splice(v,2,y)}for(u.reverse(),p=-1;++p<u.length;)d[g+u[p][0]]=g+u[p][1],g+=u[p][1]-u[p][0]-1;return d}const A6={resolve:T6,tokenize:R6},I6={partial:!0,tokenize:L6};function T6(e){return mI(e),e}function R6(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?i(l):xt(l)?e.check(I6,a,i)(l):(e.consume(l),s)}function i(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 L6(e,t,n){const r=this;return s;function s(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),_n(e,i,"linePrefix")}function i(a){if(a===null||xt(a))return n(a);const l=r.events[r.events.length-1];return!r.parser.constructs.disable.null.includes("codeIndented")&&l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):e.interrupt(r.parser.constructs.flow,n,t)(a)}}function gI(e,t,n,r,s,i,a,l,u){const d=u||Number.POSITIVE_INFINITY;let f=0;return c;function c(y){return y===60?(e.enter(r),e.enter(s),e.enter(i),e.consume(y),e.exit(i),p):y===null||y===32||y===41||mb(y)?n(y):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),b(y))}function p(y){return y===62?(e.enter(i),e.consume(y),e.exit(i),e.exit(s),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),m(y))}function m(y){return y===62?(e.exit("chunkString"),e.exit(l),p(y)):y===null||y===60||xt(y)?n(y):(e.consume(y),y===92?g:m)}function g(y){return y===60||y===62||y===92?(e.consume(y),m):m(y)}function b(y){return!f&&(y===null||y===41||Os(y))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(y)):f<d&&y===40?(e.consume(y),f++,b):y===41?(e.consume(y),f--,b):y===null||y===32||y===40||mb(y)?n(y):(e.consume(y),y===92?k:b)}function k(y){return y===40||y===41||y===92?(e.consume(y),b):b(y)}}function yI(e,t,n,r,s,i){const a=this;let l=0,u;return d;function d(m){return e.enter(r),e.enter(s),e.consume(m),e.exit(s),e.enter(i),f}function f(m){return l>999||m===null||m===91||m===93&&!u||m===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(m):m===93?(e.exit(i),e.enter(s),e.consume(m),e.exit(s),e.exit(r),t):xt(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),c(m))}function c(m){return m===null||m===91||m===93||xt(m)||l++>999?(e.exit("chunkString"),f(m)):(e.consume(m),u||(u=!Zt(m)),m===92?p:c)}function p(m){return m===91||m===92||m===93?(e.consume(m),l++,c):c(m)}}function xI(e,t,n,r,s,i){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,u):n(p)}function u(p){return p===a?(e.enter(s),e.consume(p),e.exit(s),e.exit(r),t):(e.enter(i),d(p))}function d(p){return p===a?(e.exit(i),u(a)):p===null?n(p):xt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),_n(e,d,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(p))}function f(p){return p===a||p===null||xt(p)?(e.exit("chunkString"),d(p)):(e.consume(p),p===92?c:f)}function c(p){return p===a||p===92?(e.consume(p),f):f(p)}}function af(e,t){let n;return r;function r(s){return xt(s)?(e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),n=!0,r):Zt(s)?_n(e,r,n?"linePrefix":"lineSuffix")(s):t(s)}}const O6={name:"definition",tokenize:$6},M6={partial:!0,tokenize:D6};function $6(e,t,n){const r=this;let s;return i;function i(m){return e.enter("definition"),a(m)}function a(m){return yI.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function l(m){return s=hu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),u):n(m)}function u(m){return Os(m)?af(e,d)(m):d(m)}function d(m){return gI(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function f(m){return e.attempt(M6,c,c)(m)}function c(m){return Zt(m)?_n(e,p,"whitespace")(m):p(m)}function p(m){return m===null||xt(m)?(e.exit("definition"),r.parser.defined.push(s),t(m)):n(m)}}function D6(e,t,n){return r;function r(l){return Os(l)?af(e,s)(l):n(l)}function s(l){return xI(e,i,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function i(l){return Zt(l)?_n(e,a,"whitespace")(l):a(l)}function a(l){return l===null||xt(l)?t(l):n(l)}}const F6={name:"hardBreakEscape",tokenize:z6};function z6(e,t,n){return r;function r(i){return e.enter("hardBreakEscape"),e.consume(i),s}function s(i){return xt(i)?(e.exit("hardBreakEscape"),t(i)):n(i)}}const B6={name:"headingAtx",resolve:H6,tokenize:W6};function H6(e,t){let n=e.length-2,r=3,s,i;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},i={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Ao(e,r,n-r+1,[["enter",s,t],["enter",i,t],["exit",i,t],["exit",s,t]])),e}function W6(e,t,n){let r=0;return s;function s(f){return e.enter("atxHeading"),i(f)}function i(f){return e.enter("atxHeadingSequence"),a(f)}function a(f){return f===35&&r++<6?(e.consume(f),a):f===null||Os(f)?(e.exit("atxHeadingSequence"),l(f)):n(f)}function l(f){return f===35?(e.enter("atxHeadingSequence"),u(f)):f===null||xt(f)?(e.exit("atxHeading"),t(f)):Zt(f)?_n(e,l,"whitespace")(f):(e.enter("atxHeadingText"),d(f))}function u(f){return f===35?(e.consume(f),u):(e.exit("atxHeadingSequence"),l(f))}function d(f){return f===null||f===35||Os(f)?(e.exit("atxHeadingText"),l(f)):(e.consume(f),d)}}const V6=["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"],WN=["pre","script","style","textarea"],U6={concrete:!0,name:"htmlFlow",resolveTo:Y6,tokenize:G6},K6={partial:!0,tokenize:J6},q6={partial:!0,tokenize:X6};function Y6(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 G6(e,t,n){const r=this;let s,i,a,l,u;return d;function d(V){return f(V)}function f(V){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(V),c}function c(V){return V===33?(e.consume(V),p):V===47?(e.consume(V),i=!0,b):V===63?(e.consume(V),s=3,r.interrupt?t:E):vo(V)?(e.consume(V),a=String.fromCharCode(V),k):n(V)}function p(V){return V===45?(e.consume(V),s=2,m):V===91?(e.consume(V),s=5,l=0,g):vo(V)?(e.consume(V),s=4,r.interrupt?t:E):n(V)}function m(V){return V===45?(e.consume(V),r.interrupt?t:E):n(V)}function g(V){const se="CDATA[";return V===se.charCodeAt(l++)?(e.consume(V),l===se.length?r.interrupt?t:M:g):n(V)}function b(V){return vo(V)?(e.consume(V),a=String.fromCharCode(V),k):n(V)}function k(V){if(V===null||V===47||V===62||Os(V)){const se=V===47,de=a.toLowerCase();return!se&&!i&&WN.includes(de)?(s=1,r.interrupt?t(V):M(V)):V6.includes(a.toLowerCase())?(s=6,se?(e.consume(V),y):r.interrupt?t(V):M(V)):(s=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(V):i?v(V):w(V))}return V===45||Qs(V)?(e.consume(V),a+=String.fromCharCode(V),k):n(V)}function y(V){return V===62?(e.consume(V),r.interrupt?t:M):n(V)}function v(V){return Zt(V)?(e.consume(V),v):F(V)}function w(V){return V===47?(e.consume(V),F):V===58||V===95||vo(V)?(e.consume(V),j):Zt(V)?(e.consume(V),w):F(V)}function j(V){return V===45||V===46||V===58||V===95||Qs(V)?(e.consume(V),j):P(V)}function P(V){return V===61?(e.consume(V),_):Zt(V)?(e.consume(V),P):w(V)}function _(V){return V===null||V===60||V===61||V===62||V===96?n(V):V===34||V===39?(e.consume(V),u=V,L):Zt(V)?(e.consume(V),_):B(V)}function L(V){return V===u?(e.consume(V),u=null,D):V===null||xt(V)?n(V):(e.consume(V),L)}function B(V){return V===null||V===34||V===39||V===47||V===60||V===61||V===62||V===96||Os(V)?P(V):(e.consume(V),B)}function D(V){return V===47||V===62||Zt(V)?w(V):n(V)}function F(V){return V===62?(e.consume(V),R):n(V)}function R(V){return V===null||xt(V)?M(V):Zt(V)?(e.consume(V),R):n(V)}function M(V){return V===45&&s===2?(e.consume(V),I):V===60&&s===1?(e.consume(V),z):V===62&&s===4?(e.consume(V),G):V===63&&s===3?(e.consume(V),E):V===93&&s===5?(e.consume(V),T):xt(V)&&(s===6||s===7)?(e.exit("htmlFlowData"),e.check(K6,Z,W)(V)):V===null||xt(V)?(e.exit("htmlFlowData"),W(V)):(e.consume(V),M)}function W(V){return e.check(q6,O,Z)(V)}function O(V){return e.enter("lineEnding"),e.consume(V),e.exit("lineEnding"),$}function $(V){return V===null||xt(V)?W(V):(e.enter("htmlFlowData"),M(V))}function I(V){return V===45?(e.consume(V),E):M(V)}function z(V){return V===47?(e.consume(V),a="",C):M(V)}function C(V){if(V===62){const se=a.toLowerCase();return WN.includes(se)?(e.consume(V),G):M(V)}return vo(V)&&a.length<8?(e.consume(V),a+=String.fromCharCode(V),C):M(V)}function T(V){return V===93?(e.consume(V),E):M(V)}function E(V){return V===62?(e.consume(V),G):V===45&&s===2?(e.consume(V),E):M(V)}function G(V){return V===null||xt(V)?(e.exit("htmlFlowData"),Z(V)):(e.consume(V),G)}function Z(V){return e.exit("htmlFlow"),t(V)}}function X6(e,t,n){const r=this;return s;function s(a){return xt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):n(a)}function i(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function J6(e,t,n){return r;function r(s){return e.enter("lineEnding"),e.consume(s),e.exit("lineEnding"),e.attempt(Zg,t,n)}}const Q6={name:"htmlText",tokenize:Z6};function Z6(e,t,n){const r=this;let s,i,a;return l;function l(E){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(E),u}function u(E){return E===33?(e.consume(E),d):E===47?(e.consume(E),P):E===63?(e.consume(E),w):vo(E)?(e.consume(E),B):n(E)}function d(E){return E===45?(e.consume(E),f):E===91?(e.consume(E),i=0,g):vo(E)?(e.consume(E),v):n(E)}function f(E){return E===45?(e.consume(E),m):n(E)}function c(E){return E===null?n(E):E===45?(e.consume(E),p):xt(E)?(a=c,z(E)):(e.consume(E),c)}function p(E){return E===45?(e.consume(E),m):c(E)}function m(E){return E===62?I(E):E===45?p(E):c(E)}function g(E){const G="CDATA[";return E===G.charCodeAt(i++)?(e.consume(E),i===G.length?b:g):n(E)}function b(E){return E===null?n(E):E===93?(e.consume(E),k):xt(E)?(a=b,z(E)):(e.consume(E),b)}function k(E){return E===93?(e.consume(E),y):b(E)}function y(E){return E===62?I(E):E===93?(e.consume(E),y):b(E)}function v(E){return E===null||E===62?I(E):xt(E)?(a=v,z(E)):(e.consume(E),v)}function w(E){return E===null?n(E):E===63?(e.consume(E),j):xt(E)?(a=w,z(E)):(e.consume(E),w)}function j(E){return E===62?I(E):w(E)}function P(E){return vo(E)?(e.consume(E),_):n(E)}function _(E){return E===45||Qs(E)?(e.consume(E),_):L(E)}function L(E){return xt(E)?(a=L,z(E)):Zt(E)?(e.consume(E),L):I(E)}function B(E){return E===45||Qs(E)?(e.consume(E),B):E===47||E===62||Os(E)?D(E):n(E)}function D(E){return E===47?(e.consume(E),I):E===58||E===95||vo(E)?(e.consume(E),F):xt(E)?(a=D,z(E)):Zt(E)?(e.consume(E),D):I(E)}function F(E){return E===45||E===46||E===58||E===95||Qs(E)?(e.consume(E),F):R(E)}function R(E){return E===61?(e.consume(E),M):xt(E)?(a=R,z(E)):Zt(E)?(e.consume(E),R):D(E)}function M(E){return E===null||E===60||E===61||E===62||E===96?n(E):E===34||E===39?(e.consume(E),s=E,W):xt(E)?(a=M,z(E)):Zt(E)?(e.consume(E),M):(e.consume(E),O)}function W(E){return E===s?(e.consume(E),s=void 0,$):E===null?n(E):xt(E)?(a=W,z(E)):(e.consume(E),W)}function O(E){return E===null||E===34||E===39||E===60||E===61||E===96?n(E):E===47||E===62||Os(E)?D(E):(e.consume(E),O)}function $(E){return E===47||E===62||Os(E)?D(E):n(E)}function I(E){return E===62?(e.consume(E),e.exit("htmlTextData"),e.exit("htmlText"),t):n(E)}function z(E){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(E),e.exit("lineEnding"),C}function C(E){return Zt(E)?_n(e,T,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(E):T(E)}function T(E){return e.enter("htmlTextData"),a(E)}}const p0={name:"labelEnd",resolveAll:r8,resolveTo:s8,tokenize:i8},e8={tokenize:o8},t8={tokenize:a8},n8={tokenize:l8};function r8(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&&Ao(e,0,e.length,n),e}function s8(e,t){let n=e.length,r=0,s,i,a,l;for(;n--;)if(s=e[n][1],i){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&&(i=n,s.type!=="labelLink")){r=2;break}}else s.type==="labelEnd"&&(a=n);const u={type:e[i][1].type==="labelLink"?"link":"image",start:{...e[i][1].start},end:{...e[e.length-1][1].end}},d={type:"label",start:{...e[i][1].start},end:{...e[a][1].end}},f={type:"labelText",start:{...e[i+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",u,t],["enter",d,t]],l=ki(l,e.slice(i+1,i+r+3)),l=ki(l,[["enter",f,t]]),l=ki(l,f0(t.parser.constructs.insideSpan.null,e.slice(i+r+4,a-3),t)),l=ki(l,[["exit",f,t],e[a-2],e[a-1],["exit",d,t]]),l=ki(l,e.slice(a+1)),l=ki(l,[["exit",u,t]]),Ao(e,i,e.length,l),e}function i8(e,t,n){const r=this;let s=r.events.length,i,a;for(;s--;)if((r.events[s][1].type==="labelImage"||r.events[s][1].type==="labelLink")&&!r.events[s][1]._balanced){i=r.events[s][1];break}return l;function l(p){return i?i._inactive?c(p):(a=r.parser.defined.includes(hu(r.sliceSerialize({start:i.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(p),e.exit("labelMarker"),e.exit("labelEnd"),u):n(p)}function u(p){return p===40?e.attempt(e8,f,a?f:c)(p):p===91?e.attempt(t8,f,a?d:c)(p):a?f(p):c(p)}function d(p){return e.attempt(n8,f,c)(p)}function f(p){return t(p)}function c(p){return i._balanced=!0,n(p)}}function o8(e,t,n){return r;function r(c){return e.enter("resource"),e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),s}function s(c){return Os(c)?af(e,i)(c):i(c)}function i(c){return c===41?f(c):gI(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(c)}function a(c){return Os(c)?af(e,u)(c):f(c)}function l(c){return n(c)}function u(c){return c===34||c===39||c===40?xI(e,d,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(c):f(c)}function d(c){return Os(c)?af(e,f)(c):f(c)}function f(c){return c===41?(e.enter("resourceMarker"),e.consume(c),e.exit("resourceMarker"),e.exit("resource"),t):n(c)}}function a8(e,t,n){const r=this;return s;function s(l){return yI.call(r,e,i,a,"reference","referenceMarker","referenceString")(l)}function i(l){return r.parser.defined.includes(hu(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function l8(e,t,n){return r;function r(i){return e.enter("reference"),e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),s}function s(i){return i===93?(e.enter("referenceMarker"),e.consume(i),e.exit("referenceMarker"),e.exit("reference"),t):n(i)}}const c8={name:"labelStartImage",resolveAll:p0.resolveAll,tokenize:u8};function u8(e,t,n){const r=this;return s;function s(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),i}function i(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 d8={name:"labelStartLink",resolveAll:p0.resolveAll,tokenize:f8};function f8(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"),i}function i(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const gx={name:"lineEnding",tokenize:p8};function p8(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),_n(e,t,"linePrefix")}}const om={name:"thematicBreak",tokenize:h8};function h8(e,t,n){let r=0,s;return i;function i(d){return e.enter("thematicBreak"),a(d)}function a(d){return s=d,l(d)}function l(d){return d===s?(e.enter("thematicBreakSequence"),u(d)):r>=3&&(d===null||xt(d))?(e.exit("thematicBreak"),t(d)):n(d)}function u(d){return d===s?(e.consume(d),r++,u):(e.exit("thematicBreakSequence"),Zt(d)?_n(e,l,"whitespace")(d):l(d))}}const Ns={continuation:{tokenize:x8},exit:b8,name:"list",tokenize:y8},m8={partial:!0,tokenize:v8},g8={partial:!0,tokenize:w8};function y8(e,t,n){const r=this,s=r.events[r.events.length-1];let i=s&&s[1].type==="linePrefix"?s[2].sliceSerialize(s[1],!0).length:0,a=0;return l;function l(m){const g=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(g==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:gb(m)){if(r.containerState.type||(r.containerState.type=g,e.enter(g,{_container:!0})),g==="listUnordered")return e.enter("listItemPrefix"),m===42||m===45?e.check(om,n,d)(m):d(m);if(!r.interrupt||m===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),u(m)}return n(m)}function u(m){return gb(m)&&++a<10?(e.consume(m),u):(!r.interrupt||a<2)&&(r.containerState.marker?m===r.containerState.marker:m===41||m===46)?(e.exit("listItemValue"),d(m)):n(m)}function d(m){return e.enter("listItemMarker"),e.consume(m),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||m,e.check(Zg,r.interrupt?n:f,e.attempt(m8,p,c))}function f(m){return r.containerState.initialBlankLine=!0,i++,p(m)}function c(m){return Zt(m)?(e.enter("listItemPrefixWhitespace"),e.consume(m),e.exit("listItemPrefixWhitespace"),p):n(m)}function p(m){return r.containerState.size=i+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(m)}}function x8(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Zg,s,i);function s(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,_n(e,t,"listItemIndent",r.containerState.size+1)(l)}function i(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(g8,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,_n(e,e.attempt(Ns,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function w8(e,t,n){const r=this;return _n(e,s,"listItemIndent",r.containerState.size+1);function s(i){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(i):n(i)}}function b8(e){e.exit(this.containerState.type)}function v8(e,t,n){const r=this;return _n(e,s,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function s(i){const a=r.events[r.events.length-1];return!Zt(i)&&a&&a[1].type==="listItemPrefixWhitespace"?t(i):n(i)}}const VN={name:"setextUnderline",resolveTo:k8,tokenize:S8};function k8(e,t){let n=e.length,r,s,i;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),!i&&e[n][1].type==="definition"&&(i=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[s][1].type="setextHeadingText",i?(e.splice(s,0,["enter",a,t]),e.splice(i+1,0,["exit",e[r][1],t]),e[r][1].end={...e[i][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function S8(e,t,n){const r=this;let s;return i;function i(d){let f=r.events.length,c;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){c=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||c)?(e.enter("setextHeadingLine"),s=d,a(d)):n(d)}function a(d){return e.enter("setextHeadingLineSequence"),l(d)}function l(d){return d===s?(e.consume(d),l):(e.exit("setextHeadingLineSequence"),Zt(d)?_n(e,u,"lineSuffix")(d):u(d))}function u(d){return d===null||xt(d)?(e.exit("setextHeadingLine"),t(d)):n(d)}}const N8={tokenize:j8};function j8(e){const t=this,n=e.attempt(Zg,r,e.attempt(this.parser.constructs.flowInitial,s,_n(e,e.attempt(this.parser.constructs.flow,s,e.attempt(A6,s)),"linePrefix")));return n;function r(i){if(i===null){e.consume(i);return}return e.enter("lineEndingBlank"),e.consume(i),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function s(i){if(i===null){e.consume(i);return}return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const C8={resolveAll:bI()},E8=wI("string"),_8=wI("text");function wI(e){return{resolveAll:bI(e==="text"?P8:void 0),tokenize:t};function t(n){const r=this,s=this.parser.constructs[e],i=n.attempt(s,a,l);return a;function a(f){return d(f)?i(f):l(f)}function l(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),u}function u(f){return d(f)?(n.exit("data"),i(f)):(n.consume(f),u)}function d(f){if(f===null)return!0;const c=s[f];let p=-1;if(c)for(;++p<c.length;){const m=c[p];if(!m.previous||m.previous.call(r,r.previous))return!0}return!1}}}function bI(e){return t;function t(n,r){let s=-1,i;for(;++s<=n.length;)i===void 0?n[s]&&n[s][1].type==="data"&&(i=s,s++):(!n[s]||n[s][1].type!=="data")&&(s!==i+2&&(n[i][1].end=n[s-1][1].end,n.splice(i+2,s-i-2),s=i+2),i=void 0);return e?e(n,r):n}}function P8(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 i=s.length,a=-1,l=0,u;for(;i--;){const d=s[i];if(typeof d=="string"){for(a=d.length;d.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(d===-2)u=!0,l++;else if(d!==-1){i++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const d={type:n===e.length||u||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:i?a:r.start._bufferIndex+a,_index:r.start._index+i,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...d.start},r.start.offset===r.end.offset?Object.assign(r,d):(e.splice(n,0,["enter",d,t],["exit",d,t]),n+=2)}n++}return e}const A8={42:Ns,43:Ns,45:Ns,48:Ns,49:Ns,50:Ns,51:Ns,52:Ns,53:Ns,54:Ns,55:Ns,56:Ns,57:Ns,62:fI},I8={91:O6},T8={[-2]:mx,[-1]:mx,32:mx},R8={35:B6,42:om,45:[VN,om],60:U6,61:VN,95:om,96:HN,126:HN},L8={38:hI,92:pI},O8={[-5]:gx,[-4]:gx,[-3]:gx,33:c8,38:hI,42:yb,60:[d6,Q6],91:d8,92:[F6,pI],93:p0,95:yb,96:N6},M8={null:[yb,C8]},$8={null:[42,95]},D8={null:[]},F8=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:$8,contentInitial:I8,disable:D8,document:A8,flow:R8,flowInitial:T8,insideSpan:M8,string:L8,text:O8},Symbol.toStringTag,{value:"Module"}));function z8(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={},i=[];let a=[],l=[];const u={attempt:L(P),check:L(_),consume:v,enter:w,exit:j,interrupt:L(_,{interrupt:!0})},d={code:null,containerState:{},defineSkip:b,events:[],now:g,parser:e,previous:null,sliceSerialize:p,sliceStream:m,write:c};let f=t.tokenize.call(d,u);return t.resolveAll&&i.push(t),d;function c(R){return a=ki(a,R),k(),a[a.length-1]!==null?[]:(B(t,0),d.events=f0(i,d.events,d),d.events)}function p(R,M){return H8(m(R),M)}function m(R){return B8(a,R)}function g(){const{_bufferIndex:R,_index:M,line:W,column:O,offset:$}=r;return{_bufferIndex:R,_index:M,line:W,column:O,offset:$}}function b(R){s[R.line]=R.column,F()}function k(){let R;for(;r._index<a.length;){const M=a[r._index];if(typeof M=="string")for(R=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===R&&r._bufferIndex<M.length;)y(M.charCodeAt(r._bufferIndex));else y(M)}}function y(R){f=f(R)}function v(R){xt(R)?(r.line++,r.column=1,r.offset+=R===-3?2:1,F()):R!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),d.previous=R}function w(R,M){const W=M||{};return W.type=R,W.start=g(),d.events.push(["enter",W,d]),l.push(W),W}function j(R){const M=l.pop();return M.end=g(),d.events.push(["exit",M,d]),M}function P(R,M){B(R,M.from)}function _(R,M){M.restore()}function L(R,M){return W;function W(O,$,I){let z,C,T,E;return Array.isArray(O)?Z(O):"tokenize"in O?Z([O]):G(O);function G(fe){return pe;function pe(ae){const be=ae!==null&&fe[ae],_e=ae!==null&&fe.null,we=[...Array.isArray(be)?be:be?[be]:[],...Array.isArray(_e)?_e:_e?[_e]:[]];return Z(we)(ae)}}function Z(fe){return z=fe,C=0,fe.length===0?I:V(fe[C])}function V(fe){return pe;function pe(ae){return E=D(),T=fe,fe.partial||(d.currentConstruct=fe),fe.name&&d.parser.constructs.disable.null.includes(fe.name)?de():fe.tokenize.call(M?Object.assign(Object.create(d),M):d,u,se,de)(ae)}}function se(fe){return R(T,E),$}function de(fe){return E.restore(),++C<z.length?V(z[C]):I}}}function B(R,M){R.resolveAll&&!i.includes(R)&&i.push(R),R.resolve&&Ao(d.events,M,d.events.length-M,R.resolve(d.events.slice(M),d)),R.resolveTo&&(d.events=R.resolveTo(d.events,d))}function D(){const R=g(),M=d.previous,W=d.currentConstruct,O=d.events.length,$=Array.from(l);return{from:O,restore:I};function I(){r=R,d.previous=M,d.currentConstruct=W,d.events.length=O,l=$,F()}}function F(){r.line in s&&r.column<2&&(r.column=s[r.line],r.offset+=s[r.line]-1)}}function B8(e,t){const n=t.start._index,r=t.start._bufferIndex,s=t.end._index,i=t.end._bufferIndex;let a;if(n===s)a=[e[n].slice(r,i)];else{if(a=e.slice(n,s),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}i>0&&a.push(e[s].slice(0,i))}return a}function H8(e,t){let n=-1;const r=[];let s;for(;++n<e.length;){const i=e[n];let a;if(typeof i=="string")a=i;else switch(i){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(i)}s=i===-2,r.push(a)}return r.join("")}function W8(e){const r={constructs:XH([F8,...(e||{}).extensions||[]]),content:s(s6),defined:[],document:s(o6),flow:s(N8),lazy:{},string:s(E8),text:s(_8)};return r;function s(i){return a;function a(l){return z8(r,i,l)}}}function V8(e){for(;!mI(e););return e}const UN=/[\0\t\n\r]/g;function U8(){let e=1,t="",n=!0,r;return s;function s(i,a,l){const u=[];let d,f,c,p,m;for(i=t+(typeof i=="string"?i.toString():new TextDecoder(a||void 0).decode(i)),c=0,t="",n&&(i.charCodeAt(0)===65279&&c++,n=void 0);c<i.length;){if(UN.lastIndex=c,d=UN.exec(i),p=d&&d.index!==void 0?d.index:i.length,m=i.charCodeAt(p),!d){t=i.slice(c);break}if(m===10&&c===p&&r)u.push(-3),r=void 0;else switch(r&&(u.push(-5),r=void 0),c<p&&(u.push(i.slice(c,p)),e+=p-c),m){case 0:{u.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,u.push(-2);e++<f;)u.push(-1);break}case 10:{u.push(-4),e=1;break}default:r=!0,e=1}c=p+1}return l&&(r&&u.push(-5),t&&u.push(t),u.push(null)),u}}const K8=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function q8(e){return e.replace(K8,Y8)}function Y8(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const s=n.charCodeAt(1),i=s===120||s===88;return dI(n.slice(i?2:1),i?16:10)}return d0(n)||e}const vI={}.hasOwnProperty;function G8(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),X8(n)(V8(W8(n).document().write(U8()(e,t,!0))))}function X8(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:i(jt),autolinkProtocol:D,autolinkEmail:D,atxHeading:i(ft),blockQuote:i(_e),characterEscape:D,characterReference:D,codeFenced:i(we),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:i(we,a),codeText:i(Oe,a),codeTextData:D,data:D,codeFlowValue:D,definition:i(Ie),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:i(et),hardBreakEscape:i(Je),hardBreakTrailing:i(Je),htmlFlow:i(bt,a),htmlFlowData:D,htmlText:i(bt,a),htmlTextData:D,image:i(Ve),label:a,link:i(jt),listItem:i(pn),listItemValue:p,listOrdered:i(An,c),listUnordered:i(An),paragraph:i(In),reference:V,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:i(ft),strong:i(en),thematicBreak:i(Tn)},exit:{atxHeading:u(),atxHeadingSequence:P,autolink:u(),autolinkEmail:be,autolinkProtocol:ae,blockQuote:u(),characterEscapeValue:F,characterReferenceMarkerHexadecimal:de,characterReferenceMarkerNumeric:de,characterReferenceValue:fe,characterReference:pe,codeFenced:u(k),codeFencedFence:b,codeFencedFenceInfo:m,codeFencedFenceMeta:g,codeFlowValue:F,codeIndented:u(y),codeText:u($),codeTextData:F,data:F,definition:u(),definitionDestinationString:j,definitionLabelString:v,definitionTitleString:w,emphasis:u(),hardBreakEscape:u(M),hardBreakTrailing:u(M),htmlFlow:u(W),htmlFlowData:F,htmlText:u(O),htmlTextData:F,image:u(z),label:T,labelText:C,lineEnding:R,link:u(I),listItem:u(),listOrdered:u(),listUnordered:u(),paragraph:u(),referenceString:se,resourceDestinationString:E,resourceTitleString:G,resource:Z,setextHeading:u(B),setextHeadingLineSequence:L,setextHeadingText:_,strong:u(),thematicBreak:u()}};kI(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(ce){let ve={type:"root",children:[]};const ze={stack:[ve],tokenStack:[],config:t,enter:l,exit:d,buffer:a,resume:f,data:n},it=[];let ot=-1;for(;++ot<ce.length;)if(ce[ot][1].type==="listOrdered"||ce[ot][1].type==="listUnordered")if(ce[ot][0]==="enter")it.push(ot);else{const Tt=it.pop();ot=s(ce,Tt,ot)}for(ot=-1;++ot<ce.length;){const Tt=t[ce[ot][0]];vI.call(Tt,ce[ot][1].type)&&Tt[ce[ot][1].type].call(Object.assign({sliceSerialize:ce[ot][2].sliceSerialize},ze),ce[ot][1])}if(ze.tokenStack.length>0){const Tt=ze.tokenStack[ze.tokenStack.length-1];(Tt[1]||KN).call(ze,void 0,Tt[0])}for(ve.position={start:Ra(ce.length>0?ce[0][1].start:{line:1,column:1,offset:0}),end:Ra(ce.length>0?ce[ce.length-2][1].end:{line:1,column:1,offset:0})},ot=-1;++ot<t.transforms.length;)ve=t.transforms[ot](ve)||ve;return ve}function s(ce,ve,ze){let it=ve-1,ot=-1,Tt=!1,tt,an,Xt,rr;for(;++it<=ze;){const vn=ce[it];switch(vn[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{vn[0]==="enter"?ot++:ot--,rr=void 0;break}case"lineEndingBlank":{vn[0]==="enter"&&(tt&&!rr&&!ot&&!Xt&&(Xt=it),rr=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:rr=void 0}if(!ot&&vn[0]==="enter"&&vn[1].type==="listItemPrefix"||ot===-1&&vn[0]==="exit"&&(vn[1].type==="listUnordered"||vn[1].type==="listOrdered")){if(tt){let ln=it;for(an=void 0;ln--;){const hn=ce[ln];if(hn[1].type==="lineEnding"||hn[1].type==="lineEndingBlank"){if(hn[0]==="exit")continue;an&&(ce[an][1].type="lineEndingBlank",Tt=!0),hn[1].type="lineEnding",an=ln}else if(!(hn[1].type==="linePrefix"||hn[1].type==="blockQuotePrefix"||hn[1].type==="blockQuotePrefixWhitespace"||hn[1].type==="blockQuoteMarker"||hn[1].type==="listItemIndent"))break}Xt&&(!an||Xt<an)&&(tt._spread=!0),tt.end=Object.assign({},an?ce[an][1].start:vn[1].end),ce.splice(an||it,0,["exit",tt,vn[2]]),it++,ze++}if(vn[1].type==="listItemPrefix"){const ln={type:"listItem",_spread:!1,start:Object.assign({},vn[1].start),end:void 0};tt=ln,ce.splice(it,0,["enter",ln,vn[2]]),it++,ze++,Xt=void 0,rr=!0}}}return ce[ve][1]._spread=Tt,ze}function i(ce,ve){return ze;function ze(it){l.call(this,ce(it),it),ve&&ve.call(this,it)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(ce,ve,ze){this.stack[this.stack.length-1].children.push(ce),this.stack.push(ce),this.tokenStack.push([ve,ze||void 0]),ce.position={start:Ra(ve.start),end:void 0}}function u(ce){return ve;function ve(ze){ce&&ce.call(this,ze),d.call(this,ze)}}function d(ce,ve){const ze=this.stack.pop(),it=this.tokenStack.pop();if(it)it[0].type!==ce.type&&(ve?ve.call(this,ce,it[0]):(it[1]||KN).call(this,ce,it[0]));else throw new Error("Cannot close `"+ce.type+"` ("+of({start:ce.start,end:ce.end})+"): it’s not open");ze.position.end=Ra(ce.end)}function f(){return YH(this.stack.pop())}function c(){this.data.expectingFirstListItemValue=!0}function p(ce){if(this.data.expectingFirstListItemValue){const ve=this.stack[this.stack.length-2];ve.start=Number.parseInt(this.sliceSerialize(ce),10),this.data.expectingFirstListItemValue=void 0}}function m(){const ce=this.resume(),ve=this.stack[this.stack.length-1];ve.lang=ce}function g(){const ce=this.resume(),ve=this.stack[this.stack.length-1];ve.meta=ce}function b(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function k(){const ce=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ce.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function y(){const ce=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ce.replace(/(\r?\n|\r)$/g,"")}function v(ce){const ve=this.resume(),ze=this.stack[this.stack.length-1];ze.label=ve,ze.identifier=hu(this.sliceSerialize(ce)).toLowerCase()}function w(){const ce=this.resume(),ve=this.stack[this.stack.length-1];ve.title=ce}function j(){const ce=this.resume(),ve=this.stack[this.stack.length-1];ve.url=ce}function P(ce){const ve=this.stack[this.stack.length-1];if(!ve.depth){const ze=this.sliceSerialize(ce).length;ve.depth=ze}}function _(){this.data.setextHeadingSlurpLineEnding=!0}function L(ce){const ve=this.stack[this.stack.length-1];ve.depth=this.sliceSerialize(ce).codePointAt(0)===61?1:2}function B(){this.data.setextHeadingSlurpLineEnding=void 0}function D(ce){const ze=this.stack[this.stack.length-1].children;let it=ze[ze.length-1];(!it||it.type!=="text")&&(it=Wn(),it.position={start:Ra(ce.start),end:void 0},ze.push(it)),this.stack.push(it)}function F(ce){const ve=this.stack.pop();ve.value+=this.sliceSerialize(ce),ve.position.end=Ra(ce.end)}function R(ce){const ve=this.stack[this.stack.length-1];if(this.data.atHardBreak){const ze=ve.children[ve.children.length-1];ze.position.end=Ra(ce.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ve.type)&&(D.call(this,ce),F.call(this,ce))}function M(){this.data.atHardBreak=!0}function W(){const ce=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ce}function O(){const ce=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ce}function $(){const ce=this.resume(),ve=this.stack[this.stack.length-1];ve.value=ce}function I(){const ce=this.stack[this.stack.length-1];if(this.data.inReference){const ve=this.data.referenceType||"shortcut";ce.type+="Reference",ce.referenceType=ve,delete ce.url,delete ce.title}else delete ce.identifier,delete ce.label;this.data.referenceType=void 0}function z(){const ce=this.stack[this.stack.length-1];if(this.data.inReference){const ve=this.data.referenceType||"shortcut";ce.type+="Reference",ce.referenceType=ve,delete ce.url,delete ce.title}else delete ce.identifier,delete ce.label;this.data.referenceType=void 0}function C(ce){const ve=this.sliceSerialize(ce),ze=this.stack[this.stack.length-2];ze.label=q8(ve),ze.identifier=hu(ve).toLowerCase()}function T(){const ce=this.stack[this.stack.length-1],ve=this.resume(),ze=this.stack[this.stack.length-1];if(this.data.inReference=!0,ze.type==="link"){const it=ce.children;ze.children=it}else ze.alt=ve}function E(){const ce=this.resume(),ve=this.stack[this.stack.length-1];ve.url=ce}function G(){const ce=this.resume(),ve=this.stack[this.stack.length-1];ve.title=ce}function Z(){this.data.inReference=void 0}function V(){this.data.referenceType="collapsed"}function se(ce){const ve=this.resume(),ze=this.stack[this.stack.length-1];ze.label=ve,ze.identifier=hu(this.sliceSerialize(ce)).toLowerCase(),this.data.referenceType="full"}function de(ce){this.data.characterReferenceType=ce.type}function fe(ce){const ve=this.sliceSerialize(ce),ze=this.data.characterReferenceType;let it;ze?(it=dI(ve,ze==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):it=d0(ve);const ot=this.stack[this.stack.length-1];ot.value+=it}function pe(ce){const ve=this.stack.pop();ve.position.end=Ra(ce.end)}function ae(ce){F.call(this,ce);const ve=this.stack[this.stack.length-1];ve.url=this.sliceSerialize(ce)}function be(ce){F.call(this,ce);const ve=this.stack[this.stack.length-1];ve.url="mailto:"+this.sliceSerialize(ce)}function _e(){return{type:"blockquote",children:[]}}function we(){return{type:"code",lang:null,meta:null,value:""}}function Oe(){return{type:"inlineCode",value:""}}function Ie(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function et(){return{type:"emphasis",children:[]}}function ft(){return{type:"heading",depth:0,children:[]}}function Je(){return{type:"break"}}function bt(){return{type:"html",value:""}}function Ve(){return{type:"image",title:null,url:"",alt:null}}function jt(){return{type:"link",title:null,url:"",children:[]}}function An(ce){return{type:"list",ordered:ce.type==="listOrdered",start:null,spread:ce._spread,children:[]}}function pn(ce){return{type:"listItem",spread:ce._spread,checked:null,children:[]}}function In(){return{type:"paragraph",children:[]}}function en(){return{type:"strong",children:[]}}function Wn(){return{type:"text",value:""}}function Tn(){return{type:"thematicBreak"}}}function Ra(e){return{line:e.line,column:e.column,offset:e.offset}}function kI(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?kI(e,r):J8(e,r)}}function J8(e,t){let n;for(n in t)if(vI.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 KN(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+of({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+of({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+of({start:t.start,end:t.end})+") is still open")}function Q8(e){const t=this;t.parser=n;function n(r){return G8(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function Z8(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 e9(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
70
- `}]}function t9(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 i={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(i.data={meta:t.meta}),e.patch(t,i),i=e.applyData(t,i),i={type:"element",tagName:"pre",properties:{},children:[i]},e.patch(t,i),i}function n9(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function r9(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function s9(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),s=Hu(r.toLowerCase()),i=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=i+1,l+=1,e.footnoteCounts.set(r,l);const u={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,u);const d={type:"element",tagName:"sup",properties:{},children:[u]};return e.patch(t,d),e.applyData(t,d)}function i9(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 o9(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function SI(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),i=s[0];i&&i.type==="text"?i.value="["+i.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 a9(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return SI(e,t);const s={src:Hu(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"img",properties:s,children:[]};return e.patch(t,i),e.applyData(t,i)}function l9(e,t){const n={src:Hu(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 c9(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 u9(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return SI(e,t);const s={href:Hu(r.url||"")};r.title!==null&&r.title!==void 0&&(s.title=r.title);const i={type:"element",tagName:"a",properties:s,children:e.all(t)};return e.patch(t,i),e.applyData(t,i)}function d9(e,t){const n={href:Hu(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 f9(e,t,n){const r=e.all(t),s=n?p9(n):NI(t),i={},a=[];if(typeof t.checked=="boolean"){const f=r[0];let c;f&&f.type==="element"&&f.tagName==="p"?c=f:(c={type:"element",tagName:"p",properties:{},children:[]},r.unshift(c)),c.children.length>0&&c.children.unshift({type:"text",value:" "}),c.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),i.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const f=r[l];(s||l!==0||f.type!=="element"||f.tagName!=="p")&&a.push({type:"text",value:`
72
- `}),f.type==="element"&&f.tagName==="p"&&!s?a.push(...f.children):a.push(f)}const u=r[r.length-1];u&&(s||u.type!=="element"||u.tagName!=="p")&&a.push({type:"text",value:`
73
- `});const d={type:"element",tagName:"li",properties:i,children:a};return e.patch(t,d),e.applyData(t,d)}function p9(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=NI(n[r])}return t}function NI(e){const t=e.spread;return t??e.children.length>1}function h9(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 i={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,i),e.applyData(t,i)}function m9(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function g9(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function y9(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function x9(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=a0(t.children[1]),u=sI(t.children[t.children.length-1]);l&&u&&(a.position={start:l,end:u}),s.push(a)}const i={type:"element",tagName:"table",properties:{},children:e.wrap(s,!0)};return e.patch(t,i),e.applyData(t,i)}function w9(e,t,n){const r=n?n.children:void 0,i=(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 u=-1;const d=[];for(;++u<l;){const c=t.children[u],p={},m=a?a[u]:void 0;m&&(p.align=m);let g={type:"element",tagName:i,properties:p,children:[]};c&&(g.children=e.all(c),e.patch(c,g),g=e.applyData(c,g)),d.push(g)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(d,!0)};return e.patch(t,f),e.applyData(t,f)}function b9(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const qN=9,YN=32;function v9(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),s=0;const i=[];for(;r;)i.push(GN(t.slice(s,r.index),s>0,!0),r[0]),s=r.index+r[0].length,r=n.exec(t);return i.push(GN(t.slice(s),s>0,!1)),i.join("")}function GN(e,t,n){let r=0,s=e.length;if(t){let i=e.codePointAt(r);for(;i===qN||i===YN;)r++,i=e.codePointAt(r)}if(n){let i=e.codePointAt(s-1);for(;i===qN||i===YN;)s--,i=e.codePointAt(s-1)}return s>r?e.slice(r,s):""}function k9(e,t){const n={type:"text",value:v9(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function S9(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const N9={blockquote:Z8,break:e9,code:t9,delete:n9,emphasis:r9,footnoteReference:s9,heading:i9,html:o9,imageReference:a9,image:l9,inlineCode:c9,linkReference:u9,link:d9,listItem:f9,list:h9,paragraph:m9,root:g9,strong:y9,table:x9,tableCell:b9,tableRow:w9,text:k9,thematicBreak:S9,toml:Ch,yaml:Ch,definition:Ch,footnoteDefinition:Ch};function Ch(){}const jI=-1,ey=0,lf=1,Xm=2,h0=3,m0=4,g0=5,y0=6,CI=7,EI=8,XN=typeof self=="object"?self:globalThis,j9=(e,t)=>{const n=(s,i)=>(e.set(i,s),s),r=s=>{if(e.has(s))return e.get(s);const[i,a]=t[s];switch(i){case ey:case jI:return n(a,s);case lf:{const l=n([],s);for(const u of a)l.push(r(u));return l}case Xm:{const l=n({},s);for(const[u,d]of a)l[r(u)]=r(d);return l}case h0:return n(new Date(a),s);case m0:{const{source:l,flags:u}=a;return n(new RegExp(l,u),s)}case g0:{const l=n(new Map,s);for(const[u,d]of a)l.set(r(u),r(d));return l}case y0:{const l=n(new Set,s);for(const u of a)l.add(r(u));return l}case CI:{const{name:l,message:u}=a;return n(new XN[l](u),s)}case EI: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 XN[i](a),s)};return r},JN=e=>j9(new Map,e)(0),Rc="",{toString:C9}={},{keys:E9}=Object,Ad=e=>{const t=typeof e;if(t!=="object"||!e)return[ey,t];const n=C9.call(e).slice(8,-1);switch(n){case"Array":return[lf,Rc];case"Object":return[Xm,Rc];case"Date":return[h0,Rc];case"RegExp":return[m0,Rc];case"Map":return[g0,Rc];case"Set":return[y0,Rc];case"DataView":return[lf,n]}return n.includes("Array")?[lf,n]:n.includes("Error")?[CI,n]:[Xm,n]},Eh=([e,t])=>e===ey&&(t==="function"||t==="symbol"),_9=(e,t,n,r)=>{const s=(a,l)=>{const u=r.push(a)-1;return n.set(l,u),u},i=a=>{if(n.has(a))return n.get(a);let[l,u]=Ad(a);switch(l){case ey:{let f=a;switch(u){case"bigint":l=EI,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+u);f=null;break;case"undefined":return s([jI],a)}return s([l,f],a)}case lf:{if(u){let p=a;return u==="DataView"?p=new Uint8Array(a.buffer):u==="ArrayBuffer"&&(p=new Uint8Array(a)),s([u,[...p]],a)}const f=[],c=s([l,f],a);for(const p of a)f.push(i(p));return c}case Xm:{if(u)switch(u){case"BigInt":return s([u,a.toString()],a);case"Boolean":case"Number":case"String":return s([u,a.valueOf()],a)}if(t&&"toJSON"in a)return i(a.toJSON());const f=[],c=s([l,f],a);for(const p of E9(a))(e||!Eh(Ad(a[p])))&&f.push([i(p),i(a[p])]);return c}case h0:return s([l,a.toISOString()],a);case m0:{const{source:f,flags:c}=a;return s([l,{source:f,flags:c}],a)}case g0:{const f=[],c=s([l,f],a);for(const[p,m]of a)(e||!(Eh(Ad(p))||Eh(Ad(m))))&&f.push([i(p),i(m)]);return c}case y0:{const f=[],c=s([l,f],a);for(const p of a)(e||!Eh(Ad(p)))&&f.push(i(p));return c}}const{message:d}=a;return s([l,{name:u,message:d}],a)};return i},QN=(e,{json:t,lossy:n}={})=>{const r=[];return _9(!(t||n),!!t,new Map,r)(e),r},Jm=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?JN(QN(e,t)):structuredClone(e):(e,t)=>JN(QN(e,t));function P9(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 A9(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function I9(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||P9,r=e.options.footnoteBackLabel||A9,s=e.options.footnoteLabel||"Footnotes",i=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let u=-1;for(;++u<e.footnoteOrder.length;){const d=e.footnoteById.get(e.footnoteOrder[u]);if(!d)continue;const f=e.all(d),c=String(d.identifier).toUpperCase(),p=Hu(c.toLowerCase());let m=0;const g=[],b=e.footnoteCounts.get(c);for(;b!==void 0&&++m<=b;){g.length>0&&g.push({type:"text",value:" "});let v=typeof n=="string"?n:n(u,m);typeof v=="string"&&(v={type:"text",value:v}),g.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+p+(m>1?"-"+m:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(u,m),className:["data-footnote-backref"]},children:Array.isArray(v)?v:[v]})}const k=f[f.length-1];if(k&&k.type==="element"&&k.tagName==="p"){const v=k.children[k.children.length-1];v&&v.type==="text"?v.value+=" ":k.children.push({type:"text",value:" "}),k.children.push(...g)}else f.push(...g);const y={type:"element",tagName:"li",properties:{id:t+"fn-"+p},children:e.wrap(f,!0)};e.patch(d,y),l.push(y)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:i,properties:{...Jm(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 _I=function(e){if(e==null)return O9;if(typeof e=="function")return ty(e);if(typeof e=="object")return Array.isArray(e)?T9(e):R9(e);if(typeof e=="string")return L9(e);throw new Error("Expected function, string, or object as test")};function T9(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=_I(e[n]);return ty(r);function r(...s){let i=-1;for(;++i<t.length;)if(t[i].apply(this,s))return!0;return!1}}function R9(e){const t=e;return ty(n);function n(r){const s=r;let i;for(i in e)if(s[i]!==t[i])return!1;return!0}}function L9(e){return ty(t);function t(n){return n&&n.type===e}}function ty(e){return t;function t(n,r,s){return!!(M9(n)&&e.call(this,n,typeof r=="number"?r:void 0,s||void 0))}}function O9(){return!0}function M9(e){return e!==null&&typeof e=="object"&&"type"in e}const PI=[],$9=!0,ZN=!1,D9="skip";function F9(e,t,n,r){let s;typeof t=="function"&&typeof n!="function"?(r=n,n=t):s=t;const i=_I(s),a=r?-1:1;l(e,void 0,[])();function l(u,d,f){const c=u&&typeof u=="object"?u:{};if(typeof c.type=="string"){const m=typeof c.tagName=="string"?c.tagName:typeof c.name=="string"?c.name:void 0;Object.defineProperty(p,"name",{value:"node ("+(u.type+(m?"<"+m+">":""))+")"})}return p;function p(){let m=PI,g,b,k;if((!t||i(u,d,f[f.length-1]||void 0))&&(m=z9(n(u,f)),m[0]===ZN))return m;if("children"in u&&u.children){const y=u;if(y.children&&m[0]!==D9)for(b=(r?y.children.length:-1)+a,k=f.concat(y);b>-1&&b<y.children.length;){const v=y.children[b];if(g=l(v,b,k)(),g[0]===ZN)return g;b=typeof g[1]=="number"?g[1]:b+a}}return m}}}function z9(e){return Array.isArray(e)?e:typeof e=="number"?[$9,e]:e==null?PI:[e]}function AI(e,t,n,r){let s,i,a;typeof t=="function"&&typeof n!="function"?(i=void 0,a=t,s=n):(i=t,a=n,s=r),F9(e,i,l,s);function l(u,d){const f=d[d.length-1],c=f?f.children.indexOf(u):void 0;return a(u,c,f)}}const xb={}.hasOwnProperty,B9={};function H9(e,t){const n=t||B9,r=new Map,s=new Map,i=new Map,a={...N9,...n.handlers},l={all:d,applyData:V9,definitionById:r,footnoteById:s,footnoteCounts:i,footnoteOrder:[],handlers:a,one:u,options:n,patch:W9,wrap:K9};return AI(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const c=f.type==="definition"?r:s,p=String(f.identifier).toUpperCase();c.has(p)||c.set(p,f)}}),l;function u(f,c){const p=f.type,m=l.handlers[p];if(xb.call(l.handlers,p)&&m)return m(l,f,c);if(l.options.passThrough&&l.options.passThrough.includes(p)){if("children"in f){const{children:b,...k}=f,y=Jm(k);return y.children=l.all(f),y}return Jm(f)}return(l.options.unknownHandler||U9)(l,f,c)}function d(f){const c=[];if("children"in f){const p=f.children;let m=-1;for(;++m<p.length;){const g=l.one(p[m],f);if(g){if(m&&p[m-1].type==="break"&&(!Array.isArray(g)&&g.type==="text"&&(g.value=ej(g.value)),!Array.isArray(g)&&g.type==="element")){const b=g.children[0];b&&b.type==="text"&&(b.value=ej(b.value))}Array.isArray(g)?c.push(...g):c.push(g)}}}return c}}function W9(e,t){e.position&&(t.position=CH(e))}function V9(e,t){let n=t;if(e&&e.data){const r=e.data.hName,s=e.data.hChildren,i=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"&&i&&Object.assign(n.properties,Jm(i)),"children"in n&&n.children&&s!==null&&s!==void 0&&(n.children=s)}return n}function U9(e,t){const n=t.data||{},r="value"in t&&!(xb.call(n,"hProperties")||xb.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 K9(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 ej(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function tj(e,t){const n=H9(e,t),r=n.one(e,void 0),s=I9(n),i=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return s&&i.children.push({type:"text",value:`
79
- `},s),i}function q9(e,t){return e&&"run"in e?async function(n,r){const s=tj(n,{file:r,...t});await e.run(s,r)}:function(n,r){return tj(n,{file:r,...e||t})}}function nj(e){if(e)throw e}var am=Object.prototype.hasOwnProperty,II=Object.prototype.toString,rj=Object.defineProperty,sj=Object.getOwnPropertyDescriptor,ij=function(t){return typeof Array.isArray=="function"?Array.isArray(t):II.call(t)==="[object Array]"},oj=function(t){if(!t||II.call(t)!=="[object Object]")return!1;var n=am.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&am.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var s;for(s in t);return typeof s>"u"||am.call(t,s)},aj=function(t,n){rj&&n.name==="__proto__"?rj(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},lj=function(t,n){if(n==="__proto__")if(am.call(t,n)){if(sj)return sj(t,n).value}else return;return t[n]},Y9=function e(){var t,n,r,s,i,a,l=arguments[0],u=1,d=arguments.length,f=!1;for(typeof l=="boolean"&&(f=l,l=arguments[1]||{},u=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});u<d;++u)if(t=arguments[u],t!=null)for(n in t)r=lj(l,n),s=lj(t,n),l!==s&&(f&&s&&(oj(s)||(i=ij(s)))?(i?(i=!1,a=r&&ij(r)?r:[]):a=r&&oj(r)?r:{},aj(l,{name:n,newValue:e(f,a,s)})):typeof s<"u"&&aj(l,{name:n,newValue:s}));return l};const yx=ul(Y9);function wb(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 G9(){const e=[],t={run:n,use:r};return t;function n(...s){let i=-1;const a=s.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...s);function l(u,...d){const f=e[++i];let c=-1;if(u){a(u);return}for(;++c<s.length;)(d[c]===null||d[c]===void 0)&&(d[c]=s[c]);s=d,f?X9(f,l)(...d):a(null,...d)}}function r(s){if(typeof s!="function")throw new TypeError("Expected `middelware` to be a function, not "+s);return e.push(s),t}}function X9(e,t){let n;return r;function r(...a){const l=e.length>a.length;let u;l&&a.push(s);try{u=e.apply(this,a)}catch(d){const f=d;if(l&&n)throw f;return s(f)}l||(u&&u.then&&typeof u.then=="function"?u.then(i,s):u instanceof Error?s(u):i(u))}function s(a,...l){n||(n=!0,t(a,...l))}function i(a){s(null,a)}}const go={basename:J9,dirname:Q9,extname:Z9,join:eW,sep:"/"};function J9(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');fp(e);let n=0,r=-1,s=e.length,i;if(t===void 0||t.length===0||t.length>e.length){for(;s--;)if(e.codePointAt(s)===47){if(i){n=s+1;break}}else r<0&&(i=!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(i){n=s+1;break}}else a<0&&(i=!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 Q9(e){if(fp(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 Z9(e){fp(e);let t=e.length,n=-1,r=0,s=-1,i=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:i!==1&&(i=1):s>-1&&(i=-1)}return s<0||n<0||i===0||i===1&&s===n-1&&s===r+1?"":e.slice(s,n)}function eW(...e){let t=-1,n;for(;++t<e.length;)fp(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":tW(n)}function tW(e){fp(e);const t=e.codePointAt(0)===47;let n=nW(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function nW(e,t){let n="",r=0,s=-1,i=0,a=-1,l,u;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||i===1))if(s!==a-1&&i===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(u=n.lastIndexOf("/"),u!==n.length-1){u<0?(n="",r=0):(n=n.slice(0,u),r=n.length-1-n.lastIndexOf("/")),s=a,i=0;continue}}else if(n.length>0){n="",r=0,s=a,i=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,i=0}else l===46&&i>-1?i++:i=-1}return n}function fp(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const rW={cwd:sW};function sW(){return"/"}function bb(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function iW(e){if(typeof e=="string")e=new URL(e);else if(!bb(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 oW(e)}function oW(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 xx=["history","path","basename","stem","extname","dirname"];class TI{constructor(t){let n;t?bb(t)?n={path:t}:typeof t=="string"||aW(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":rW.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<xx.length;){const i=xx[r];i in n&&n[i]!==void 0&&n[i]!==null&&(this[i]=i==="history"?[...n[i]]:n[i])}let s;for(s in n)xx.includes(s)||(this[s]=n[s])}get basename(){return typeof this.path=="string"?go.basename(this.path):void 0}set basename(t){bx(t,"basename"),wx(t,"basename"),this.path=go.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?go.dirname(this.path):void 0}set dirname(t){cj(this.basename,"dirname"),this.path=go.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?go.extname(this.path):void 0}set extname(t){if(wx(t,"extname"),cj(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=go.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){bb(t)&&(t=iW(t)),bx(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?go.basename(this.path,this.extname):void 0}set stem(t){bx(t,"stem"),wx(t,"stem"),this.path=go.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 es(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 wx(e,t){if(e&&e.includes(go.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+go.sep+"`")}function bx(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function cj(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function aW(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const lW=function(e){const r=this.constructor.prototype,s=r[e],i=function(){return s.apply(i,arguments)};return Object.setPrototypeOf(i,r),i},cW={}.hasOwnProperty;class x0 extends lW{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=G9()}copy(){const t=new x0;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(yx(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Sx("data",this.frozen),this.namespace[t]=n,this):cW.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Sx("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=_h(t),r=this.parser||this.Parser;return vx("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),vx("process",this.parser||this.Parser),kx("process",this.compiler||this.Compiler),n?s(void 0,n):new Promise(s);function s(i,a){const l=_h(t),u=r.parse(l);r.run(u,l,function(f,c,p){if(f||!c||!p)return d(f);const m=c,g=r.stringify(m,p);fW(g)?p.value=g:p.result=g,d(f,p)});function d(f,c){f||!c?a(f):i?i(c):n(void 0,c)}}}processSync(t){let n=!1,r;return this.freeze(),vx("processSync",this.parser||this.Parser),kx("processSync",this.compiler||this.Compiler),this.process(t,s),dj("processSync","process",n),r;function s(i,a){n=!0,nj(i),r=a}}run(t,n,r){uj(t),this.freeze();const s=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?i(void 0,r):new Promise(i);function i(a,l){const u=_h(n);s.run(t,u,d);function d(f,c,p){const m=c||t;f?l(f):a?a(m):r(void 0,m,p)}}}runSync(t,n){let r=!1,s;return this.run(t,n,i),dj("runSync","run",r),s;function i(a,l){nj(a),s=l,r=!0}}stringify(t,n){this.freeze();const r=_h(n),s=this.compiler||this.Compiler;return kx("stringify",s),uj(t),s(t,r)}use(t,...n){const r=this.attachers,s=this.namespace;if(Sx("use",this.frozen),t!=null)if(typeof t=="function")u(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 i(d){if(typeof d=="function")u(d,[]);else if(typeof d=="object")if(Array.isArray(d)){const[f,...c]=d;u(f,c)}else a(d);else throw new TypeError("Expected usable value, not `"+d+"`")}function a(d){if(!("plugins"in d)&&!("settings"in d))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(d.plugins),d.settings&&(s.settings=yx(!0,s.settings,d.settings))}function l(d){let f=-1;if(d!=null)if(Array.isArray(d))for(;++f<d.length;){const c=d[f];i(c)}else throw new TypeError("Expected a list of plugins, not `"+d+"`")}function u(d,f){let c=-1,p=-1;for(;++c<r.length;)if(r[c][0]===d){p=c;break}if(p===-1)r.push([d,...f]);else if(f.length>0){let[m,...g]=f;const b=r[p][1];wb(b)&&wb(m)&&(m=yx(!0,b,m)),r[p]=[d,m,...g]}}}}const uW=new x0().freeze();function vx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function kx(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Sx(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 uj(e){if(!wb(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function dj(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function _h(e){return dW(e)?e:new TI(e)}function dW(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function fW(e){return typeof e=="string"||pW(e)}function pW(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const hW="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",fj=[],pj={allowDangerousHtml:!0},mW=/^(https?|ircs?|mailto|xmpp)$/i,gW=[{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 pp(e){const t=yW(e),n=xW(e);return wW(t.runSync(t.parse(n),n),e)}function yW(e){const t=e.rehypePlugins||fj,n=e.remarkPlugins||fj,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...pj}:pj;return uW().use(Q8).use(n).use(q9,r).use(t)}function xW(e){const t=e.children||"",n=new TI;return typeof t=="string"&&(n.value=t),n}function wW(e,t){const n=t.allowedElements,r=t.allowElement,s=t.components,i=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,u=t.urlTransform||bW;for(const f of gW)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+hW+f.id,void 0);return AI(e,d),IH(e,{Fragment:o.Fragment,components:s,ignoreInvalidStyle:!0,jsx:o.jsx,jsxs:o.jsxs,passKeys:!0,passNode:!0});function d(f,c,p){if(f.type==="raw"&&p&&typeof c=="number")return a?p.children.splice(c,1):p.children[c]={type:"text",value:f.value},c;if(f.type==="element"){let m;for(m in hx)if(Object.hasOwn(hx,m)&&Object.hasOwn(f.properties,m)){const g=f.properties[m],b=hx[m];(b===null||b.includes(f.tagName))&&(f.properties[m]=u(String(g||""),m,f))}}if(f.type==="element"){let m=n?!n.includes(f.tagName):i?i.includes(f.tagName):!1;if(!m&&r&&typeof c=="number"&&(m=!r(f,c,p)),m&&p&&typeof c=="number")return l&&f.children?p.children.splice(c,1,...f.children):p.children.splice(c,1),c}}}function bW(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||mW.test(e.slice(0,t))?e:""}function vW(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)}function Qm(e){if(e==null)return"null";if(typeof e!="object")return JSON.stringify(e);if(Array.isArray(e))return`[${e.map(r=>Qm(r)).join(",")}]`;const t=e;return`{${Object.keys(t).sort().map(r=>`${JSON.stringify(r)}:${Qm(t[r])}`).join(",")}}`}function hj(e){return Qm({id:e.id,type:e.type,position:e.position,data:e.data,parentId:e.parentId,extent:e.extent,sourcePosition:e.sourcePosition,targetPosition:e.targetPosition,hidden:e.hidden})}function Hf(e){const t=e.sourceHandle??"",n=e.targetHandle??"";return`${e.source}|${t}|${e.target}|${n}`}function mj(e){return Qm({source:e.source,target:e.target,sourceHandle:e.sourceHandle??null,targetHandle:e.targetHandle??null,type:e.type,label:e.label,data:e.data,markerStart:e.markerStart,markerEnd:e.markerEnd,animated:e.animated,hidden:e.hidden,style:e.style})}function gj(e,t){return!vW(t)||!("selected"in t)||t.selected===e.selected?e:{...e,selected:!!t.selected}}function yj(e,t=!1){const n=new Map;for(const r of e){const s=Hf(r);if(t&&n.has(s))throw new Error(`存在重复连线键: ${s}`);n.set(s,r)}return n}function kW(e,t,n,r){const s=new Map(e.map(v=>[v.id,v])),i=new Set(n.map(v=>v.id)),a=new Set,l=[],u=[],d=n.map(v=>{const w=s.get(v.id);return w?hj(w)===hj(v)?(a.add(v.id),w):(u.push(v.id),gj(v,w)):(l.push(v.id),v)}),f=yj(t),c=yj(r,!0),p=new Set,m=[],g=[],b=r.map(v=>{const w=Hf(v),j=f.get(w);return j?mj(j)===mj(v)?(p.add(w),j):(g.push(w),gj(v,j)):(m.push(w),v)}),k=e.filter(v=>!i.has(v.id)).map(v=>v.id),y=t.map(v=>Hf(v)).filter(v=>!c.has(v));return{nodes:d,edges:b,changes:{addedNodeIds:l,updatedNodeIds:u,removedNodeIds:k,addedEdgeKeys:m,updatedEdgeKeys:g,removedEdgeKeys:y},stats:{nodeAdded:l.length,nodeRemoved:k.length,nodeReused:a.size,edgeAdded:m.length,edgeRemoved:y.length,edgeReused:p.size,nextEdgeCount:c.size}}}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function RI(e){return typeof e>"u"||e===null}function SW(e){return typeof e=="object"&&e!==null}function NW(e){return Array.isArray(e)?e:RI(e)?[]:[e]}function jW(e,t){var n,r,s,i;if(t)for(i=Object.keys(t),n=0,r=i.length;n<r;n+=1)s=i[n],e[s]=t[s];return e}function CW(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function EW(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var _W=RI,PW=SW,AW=NW,IW=CW,TW=EW,RW=jW,br={isNothing:_W,isObject:PW,toArray:AW,repeat:IW,isNegativeZero:TW,extend:RW};function LI(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
80
-
81
- `+e.mark.snippet),r+" "+n):r}function Wf(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=LI(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}Wf.prototype=Object.create(Error.prototype);Wf.prototype.constructor=Wf;Wf.prototype.toString=function(t){return this.name+": "+LI(this,t)};var us=Wf;function Nx(e,t,n,r,s){var i="",a="",l=Math.floor(s/2)-1;return r-t>l&&(i=" ... ",t=r-l+i.length),n-r>l&&(a=" ...",n=r+l-a.length),{str:i+e.slice(t,n).replace(/\t/g,"→")+a,pos:r-t+i.length}}function jx(e,t){return br.repeat(" ",t-e.length)+e}function LW(e,t){if(t=Object.create(t||null),!e.buffer)return null;t.maxLength||(t.maxLength=79),typeof t.indent!="number"&&(t.indent=1),typeof t.linesBefore!="number"&&(t.linesBefore=3),typeof t.linesAfter!="number"&&(t.linesAfter=2);for(var n=/\r?\n|\r|\0/g,r=[0],s=[],i,a=-1;i=n.exec(e.buffer);)s.push(i.index),r.push(i.index+i[0].length),e.position<=i.index&&a<0&&(a=r.length-2);a<0&&(a=r.length-1);var l="",u,d,f=Math.min(e.line+t.linesAfter,s.length).toString().length,c=t.maxLength-(t.indent+f+3);for(u=1;u<=t.linesBefore&&!(a-u<0);u++)d=Nx(e.buffer,r[a-u],s[a-u],e.position-(r[a]-r[a-u]),c),l=br.repeat(" ",t.indent)+jx((e.line-u+1).toString(),f)+" | "+d.str+`
82
- `+l;for(d=Nx(e.buffer,r[a],s[a],e.position,c),l+=br.repeat(" ",t.indent)+jx((e.line+1).toString(),f)+" | "+d.str+`
83
- `,l+=br.repeat("-",t.indent+f+3+d.pos)+`^
84
- `,u=1;u<=t.linesAfter&&!(a+u>=s.length);u++)d=Nx(e.buffer,r[a+u],s[a+u],e.position-(r[a]-r[a+u]),c),l+=br.repeat(" ",t.indent)+jx((e.line+u+1).toString(),f)+" | "+d.str+`
85
- `;return l.replace(/\n$/,"")}var OW=LW,MW=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],$W=["scalar","sequence","mapping"];function DW(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function FW(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(MW.indexOf(n)===-1)throw new us('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=DW(t.styleAliases||null),$W.indexOf(this.kind)===-1)throw new us('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var $r=FW;function xj(e,t){var n=[];return e[t].forEach(function(r){var s=n.length;n.forEach(function(i,a){i.tag===r.tag&&i.kind===r.kind&&i.multi===r.multi&&(s=a)}),n[s]=r}),n}function zW(){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 vb(e){return this.extend(e)}vb.prototype.extend=function(t){var n=[],r=[];if(t instanceof $r)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 us("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(i){if(!(i instanceof $r))throw new us("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(i.loadKind&&i.loadKind!=="scalar")throw new us("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(i.multi)throw new us("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(i){if(!(i instanceof $r))throw new us("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var s=Object.create(vb.prototype);return s.implicit=(this.implicit||[]).concat(n),s.explicit=(this.explicit||[]).concat(r),s.compiledImplicit=xj(s,"implicit"),s.compiledExplicit=xj(s,"explicit"),s.compiledTypeMap=zW(s.compiledImplicit,s.compiledExplicit),s};var OI=vb,MI=new $r("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),$I=new $r("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),DI=new $r("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),FI=new OI({explicit:[MI,$I,DI]});function BW(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function HW(){return null}function WW(e){return e===null}var zI=new $r("tag:yaml.org,2002:null",{kind:"scalar",resolve:BW,construct:HW,predicate:WW,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function VW(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 UW(e){return e==="true"||e==="True"||e==="TRUE"}function KW(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var BI=new $r("tag:yaml.org,2002:bool",{kind:"scalar",resolve:VW,construct:UW,predicate:KW,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 qW(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function YW(e){return 48<=e&&e<=55}function GW(e){return 48<=e&&e<=57}function XW(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(!qW(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}if(s==="o"){for(n++;n<t;n++)if(s=e[n],s!=="_"){if(!YW(e.charCodeAt(n)))return!1;r=!0}return r&&s!=="_"}}if(s==="_")return!1;for(;n<t;n++)if(s=e[n],s!=="_"){if(!GW(e.charCodeAt(n)))return!1;r=!0}return!(!r||s==="_")}function JW(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 QW(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!br.isNegativeZero(e)}var HI=new $r("tag:yaml.org,2002:int",{kind:"scalar",resolve:XW,construct:JW,predicate:QW,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"]}}),ZW=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function eV(e){return!(e===null||!ZW.test(e)||e[e.length-1]==="_")}function tV(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 nV=/^[-+]?[0-9]+e/;function rV(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(br.isNegativeZero(e))return"-0.0";return n=e.toString(10),nV.test(n)?n.replace("e",".e"):n}function sV(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||br.isNegativeZero(e))}var WI=new $r("tag:yaml.org,2002:float",{kind:"scalar",resolve:eV,construct:tV,predicate:sV,represent:rV,defaultStyle:"lowercase"}),VI=FI.extend({implicit:[zI,BI,HI,WI]}),UI=VI,KI=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),qI=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 iV(e){return e===null?!1:KI.exec(e)!==null||qI.exec(e)!==null}function oV(e){var t,n,r,s,i,a,l,u=0,d=null,f,c,p;if(t=KI.exec(e),t===null&&(t=qI.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(i=+t[4],a=+t[5],l=+t[6],t[7]){for(u=t[7].slice(0,3);u.length<3;)u+="0";u=+u}return t[9]&&(f=+t[10],c=+(t[11]||0),d=(f*60+c)*6e4,t[9]==="-"&&(d=-d)),p=new Date(Date.UTC(n,r,s,i,a,l,u)),d&&p.setTime(p.getTime()-d),p}function aV(e){return e.toISOString()}var YI=new $r("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:iV,construct:oV,instanceOf:Date,represent:aV});function lV(e){return e==="<<"||e===null}var GI=new $r("tag:yaml.org,2002:merge",{kind:"scalar",resolve:lV}),w0=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
86
- \r`;function cV(e){if(e===null)return!1;var t,n,r=0,s=e.length,i=w0;for(n=0;n<s;n++)if(t=i.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8===0}function uV(e){var t,n,r=e.replace(/[\r\n=]/g,""),s=r.length,i=w0,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|i.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 dV(e){var t="",n=0,r,s,i=e.length,a=w0;for(r=0;r<i;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=i%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 fV(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var XI=new $r("tag:yaml.org,2002:binary",{kind:"scalar",resolve:cV,construct:uV,predicate:fV,represent:dV}),pV=Object.prototype.hasOwnProperty,hV=Object.prototype.toString;function mV(e){if(e===null)return!0;var t=[],n,r,s,i,a,l=e;for(n=0,r=l.length;n<r;n+=1){if(s=l[n],a=!1,hV.call(s)!=="[object Object]")return!1;for(i in s)if(pV.call(s,i))if(!a)a=!0;else return!1;if(!a)return!1;if(t.indexOf(i)===-1)t.push(i);else return!1}return!0}function gV(e){return e!==null?e:[]}var JI=new $r("tag:yaml.org,2002:omap",{kind:"sequence",resolve:mV,construct:gV}),yV=Object.prototype.toString;function xV(e){if(e===null)return!0;var t,n,r,s,i,a=e;for(i=new Array(a.length),t=0,n=a.length;t<n;t+=1){if(r=a[t],yV.call(r)!=="[object Object]"||(s=Object.keys(r),s.length!==1))return!1;i[t]=[s[0],r[s[0]]]}return!0}function wV(e){if(e===null)return[];var t,n,r,s,i,a=e;for(i=new Array(a.length),t=0,n=a.length;t<n;t+=1)r=a[t],s=Object.keys(r),i[t]=[s[0],r[s[0]]];return i}var QI=new $r("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:xV,construct:wV}),bV=Object.prototype.hasOwnProperty;function vV(e){if(e===null)return!0;var t,n=e;for(t in n)if(bV.call(n,t)&&n[t]!==null)return!1;return!0}function kV(e){return e!==null?e:{}}var ZI=new $r("tag:yaml.org,2002:set",{kind:"mapping",resolve:vV,construct:kV}),b0=UI.extend({implicit:[YI,GI],explicit:[XI,JI,QI,ZI]}),ol=Object.prototype.hasOwnProperty,Zm=1,eT=2,tT=3,eg=4,Cx=1,SV=2,wj=3,NV=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,jV=/[\x85\u2028\u2029]/,CV=/[,\[\]\{\}]/,nT=/^(?:!|!!|![a-z\-]+!)$/i,rT=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function bj(e){return Object.prototype.toString.call(e)}function Co(e){return e===10||e===13}function Xl(e){return e===9||e===32}function _s(e){return e===9||e===32||e===10||e===13}function nu(e){return e===44||e===91||e===93||e===123||e===125}function EV(e){var t;return 48<=e&&e<=57?e-48:(t=e|32,97<=t&&t<=102?t-97+10:-1)}function _V(e){return e===120?2:e===117?4:e===85?8:0}function PV(e){return 48<=e&&e<=57?e-48:-1}function vj(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
87
- `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"…":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}function AV(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function sT(e,t,n){t==="__proto__"?Object.defineProperty(e,t,{configurable:!0,enumerable:!0,writable:!0,value:n}):e[t]=n}var iT=new Array(256),oT=new Array(256);for(var Lc=0;Lc<256;Lc++)iT[Lc]=vj(Lc)?1:0,oT[Lc]=vj(Lc);function IV(e,t){this.input=e,this.filename=t.filename||null,this.schema=t.schema||b0,this.onWarning=t.onWarning||null,this.legacy=t.legacy||!1,this.json=t.json||!1,this.listener=t.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function aT(e,t){var n={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return n.snippet=OW(n),new us(t,n)}function rt(e,t){throw aT(e,t)}function tg(e,t){e.onWarning&&e.onWarning.call(null,aT(e,t))}var kj={YAML:function(t,n,r){var s,i,a;t.version!==null&&rt(t,"duplication of %YAML directive"),r.length!==1&&rt(t,"YAML directive accepts exactly one argument"),s=/^([0-9]+)\.([0-9]+)$/.exec(r[0]),s===null&&rt(t,"ill-formed argument of the YAML directive"),i=parseInt(s[1],10),a=parseInt(s[2],10),i!==1&&rt(t,"unacceptable YAML version of the document"),t.version=r[0],t.checkLineBreaks=a<2,a!==1&&a!==2&&tg(t,"unsupported YAML version of the document")},TAG:function(t,n,r){var s,i;r.length!==2&&rt(t,"TAG directive accepts exactly two arguments"),s=r[0],i=r[1],nT.test(s)||rt(t,"ill-formed tag handle (first argument) of the TAG directive"),ol.call(t.tagMap,s)&&rt(t,'there is a previously declared suffix for "'+s+'" tag handle'),rT.test(i)||rt(t,"ill-formed tag prefix (second argument) of the TAG directive");try{i=decodeURIComponent(i)}catch{rt(t,"tag prefix is malformed: "+i)}t.tagMap[s]=i}};function tl(e,t,n,r){var s,i,a,l;if(t<n){if(l=e.input.slice(t,n),r)for(s=0,i=l.length;s<i;s+=1)a=l.charCodeAt(s),a===9||32<=a&&a<=1114111||rt(e,"expected valid JSON character");else NV.test(l)&&rt(e,"the stream contains non-printable characters");e.result+=l}}function Sj(e,t,n,r){var s,i,a,l;for(br.isObject(n)||rt(e,"cannot merge mappings; the provided source object is unacceptable"),s=Object.keys(n),a=0,l=s.length;a<l;a+=1)i=s[a],ol.call(t,i)||(sT(t,i,n[i]),r[i]=!0)}function ru(e,t,n,r,s,i,a,l,u){var d,f;if(Array.isArray(s))for(s=Array.prototype.slice.call(s),d=0,f=s.length;d<f;d+=1)Array.isArray(s[d])&&rt(e,"nested arrays are not supported inside keys"),typeof s=="object"&&bj(s[d])==="[object Object]"&&(s[d]="[object Object]");if(typeof s=="object"&&bj(s)==="[object Object]"&&(s="[object Object]"),s=String(s),t===null&&(t={}),r==="tag:yaml.org,2002:merge")if(Array.isArray(i))for(d=0,f=i.length;d<f;d+=1)Sj(e,t,i[d],n);else Sj(e,t,i,n);else!e.json&&!ol.call(n,s)&&ol.call(t,s)&&(e.line=a||e.line,e.lineStart=l||e.lineStart,e.position=u||e.position,rt(e,"duplicated mapping key")),sT(t,s,i),delete n[s];return t}function v0(e){var t;t=e.input.charCodeAt(e.position),t===10?e.position++:t===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):rt(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function mr(e,t,n){for(var r=0,s=e.input.charCodeAt(e.position);s!==0;){for(;Xl(s);)s===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),s=e.input.charCodeAt(++e.position);if(t&&s===35)do s=e.input.charCodeAt(++e.position);while(s!==10&&s!==13&&s!==0);if(Co(s))for(v0(e),s=e.input.charCodeAt(e.position),r++,e.lineIndent=0;s===32;)e.lineIndent++,s=e.input.charCodeAt(++e.position);else break}return n!==-1&&r!==0&&e.lineIndent<n&&tg(e,"deficient indentation"),r}function ny(e){var t=e.position,n;return n=e.input.charCodeAt(t),!!((n===45||n===46)&&n===e.input.charCodeAt(t+1)&&n===e.input.charCodeAt(t+2)&&(t+=3,n=e.input.charCodeAt(t),n===0||_s(n)))}function k0(e,t){t===1?e.result+=" ":t>1&&(e.result+=br.repeat(`
88
- `,t-1))}function TV(e,t,n){var r,s,i,a,l,u,d,f,c=e.kind,p=e.result,m;if(m=e.input.charCodeAt(e.position),_s(m)||nu(m)||m===35||m===38||m===42||m===33||m===124||m===62||m===39||m===34||m===37||m===64||m===96||(m===63||m===45)&&(s=e.input.charCodeAt(e.position+1),_s(s)||n&&nu(s)))return!1;for(e.kind="scalar",e.result="",i=a=e.position,l=!1;m!==0;){if(m===58){if(s=e.input.charCodeAt(e.position+1),_s(s)||n&&nu(s))break}else if(m===35){if(r=e.input.charCodeAt(e.position-1),_s(r))break}else{if(e.position===e.lineStart&&ny(e)||n&&nu(m))break;if(Co(m))if(u=e.line,d=e.lineStart,f=e.lineIndent,mr(e,!1,-1),e.lineIndent>=t){l=!0,m=e.input.charCodeAt(e.position);continue}else{e.position=a,e.line=u,e.lineStart=d,e.lineIndent=f;break}}l&&(tl(e,i,a,!1),k0(e,e.line-u),i=a=e.position,l=!1),Xl(m)||(a=e.position+1),m=e.input.charCodeAt(++e.position)}return tl(e,i,a,!1),e.result?!0:(e.kind=c,e.result=p,!1)}function RV(e,t){var n,r,s;if(n=e.input.charCodeAt(e.position),n!==39)return!1;for(e.kind="scalar",e.result="",e.position++,r=s=e.position;(n=e.input.charCodeAt(e.position))!==0;)if(n===39)if(tl(e,r,e.position,!0),n=e.input.charCodeAt(++e.position),n===39)r=e.position,e.position++,s=e.position;else return!0;else Co(n)?(tl(e,r,s,!0),k0(e,mr(e,!1,t)),r=s=e.position):e.position===e.lineStart&&ny(e)?rt(e,"unexpected end of the document within a single quoted scalar"):(e.position++,s=e.position);rt(e,"unexpected end of the stream within a single quoted scalar")}function LV(e,t){var n,r,s,i,a,l;if(l=e.input.charCodeAt(e.position),l!==34)return!1;for(e.kind="scalar",e.result="",e.position++,n=r=e.position;(l=e.input.charCodeAt(e.position))!==0;){if(l===34)return tl(e,n,e.position,!0),e.position++,!0;if(l===92){if(tl(e,n,e.position,!0),l=e.input.charCodeAt(++e.position),Co(l))mr(e,!1,t);else if(l<256&&iT[l])e.result+=oT[l],e.position++;else if((a=_V(l))>0){for(s=a,i=0;s>0;s--)l=e.input.charCodeAt(++e.position),(a=EV(l))>=0?i=(i<<4)+a:rt(e,"expected hexadecimal character");e.result+=AV(i),e.position++}else rt(e,"unknown escape sequence");n=r=e.position}else Co(l)?(tl(e,n,r,!0),k0(e,mr(e,!1,t)),n=r=e.position):e.position===e.lineStart&&ny(e)?rt(e,"unexpected end of the document within a double quoted scalar"):(e.position++,r=e.position)}rt(e,"unexpected end of the stream within a double quoted scalar")}function OV(e,t){var n=!0,r,s,i,a=e.tag,l,u=e.anchor,d,f,c,p,m,g=Object.create(null),b,k,y,v;if(v=e.input.charCodeAt(e.position),v===91)f=93,m=!1,l=[];else if(v===123)f=125,m=!0,l={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),v=e.input.charCodeAt(++e.position);v!==0;){if(mr(e,!0,t),v=e.input.charCodeAt(e.position),v===f)return e.position++,e.tag=a,e.anchor=u,e.kind=m?"mapping":"sequence",e.result=l,!0;n?v===44&&rt(e,"expected the node content, but found ','"):rt(e,"missed comma between flow collection entries"),k=b=y=null,c=p=!1,v===63&&(d=e.input.charCodeAt(e.position+1),_s(d)&&(c=p=!0,e.position++,mr(e,!0,t))),r=e.line,s=e.lineStart,i=e.position,Ru(e,t,Zm,!1,!0),k=e.tag,b=e.result,mr(e,!0,t),v=e.input.charCodeAt(e.position),(p||e.line===r)&&v===58&&(c=!0,v=e.input.charCodeAt(++e.position),mr(e,!0,t),Ru(e,t,Zm,!1,!0),y=e.result),m?ru(e,l,g,k,b,y,r,s,i):c?l.push(ru(e,null,g,k,b,y,r,s,i)):l.push(b),mr(e,!0,t),v=e.input.charCodeAt(e.position),v===44?(n=!0,v=e.input.charCodeAt(++e.position)):n=!1}rt(e,"unexpected end of the stream within a flow collection")}function MV(e,t){var n,r,s=Cx,i=!1,a=!1,l=t,u=0,d=!1,f,c;if(c=e.input.charCodeAt(e.position),c===124)r=!1;else if(c===62)r=!0;else return!1;for(e.kind="scalar",e.result="";c!==0;)if(c=e.input.charCodeAt(++e.position),c===43||c===45)Cx===s?s=c===43?wj:SV:rt(e,"repeat of a chomping mode identifier");else if((f=PV(c))>=0)f===0?rt(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):a?rt(e,"repeat of an indentation width identifier"):(l=t+f-1,a=!0);else break;if(Xl(c)){do c=e.input.charCodeAt(++e.position);while(Xl(c));if(c===35)do c=e.input.charCodeAt(++e.position);while(!Co(c)&&c!==0)}for(;c!==0;){for(v0(e),e.lineIndent=0,c=e.input.charCodeAt(e.position);(!a||e.lineIndent<l)&&c===32;)e.lineIndent++,c=e.input.charCodeAt(++e.position);if(!a&&e.lineIndent>l&&(l=e.lineIndent),Co(c)){u++;continue}if(e.lineIndent<l){s===wj?e.result+=br.repeat(`
89
- `,i?1+u:u):s===Cx&&i&&(e.result+=`
90
- `);break}for(r?Xl(c)?(d=!0,e.result+=br.repeat(`
91
- `,i?1+u:u)):d?(d=!1,e.result+=br.repeat(`
92
- `,u+1)):u===0?i&&(e.result+=" "):e.result+=br.repeat(`
93
- `,u):e.result+=br.repeat(`
94
- `,i?1+u:u),i=!0,a=!0,u=0,n=e.position;!Co(c)&&c!==0;)c=e.input.charCodeAt(++e.position);tl(e,n,e.position,!1)}return!0}function Nj(e,t){var n,r=e.tag,s=e.anchor,i=[],a,l=!1,u;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=i),u=e.input.charCodeAt(e.position);u!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,rt(e,"tab characters must not be used in indentation")),!(u!==45||(a=e.input.charCodeAt(e.position+1),!_s(a))));){if(l=!0,e.position++,mr(e,!0,-1)&&e.lineIndent<=t){i.push(null),u=e.input.charCodeAt(e.position);continue}if(n=e.line,Ru(e,t,tT,!1,!0),i.push(e.result),mr(e,!0,-1),u=e.input.charCodeAt(e.position),(e.line===n||e.lineIndent>t)&&u!==0)rt(e,"bad indentation of a sequence entry");else if(e.lineIndent<t)break}return l?(e.tag=r,e.anchor=s,e.kind="sequence",e.result=i,!0):!1}function $V(e,t,n){var r,s,i,a,l,u,d=e.tag,f=e.anchor,c={},p=Object.create(null),m=null,g=null,b=null,k=!1,y=!1,v;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=c),v=e.input.charCodeAt(e.position);v!==0;){if(!k&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,rt(e,"tab characters must not be used in indentation")),r=e.input.charCodeAt(e.position+1),i=e.line,(v===63||v===58)&&_s(r))v===63?(k&&(ru(e,c,p,m,g,null,a,l,u),m=g=b=null),y=!0,k=!0,s=!0):k?(k=!1,s=!0):rt(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,v=r;else{if(a=e.line,l=e.lineStart,u=e.position,!Ru(e,n,eT,!1,!0))break;if(e.line===i){for(v=e.input.charCodeAt(e.position);Xl(v);)v=e.input.charCodeAt(++e.position);if(v===58)v=e.input.charCodeAt(++e.position),_s(v)||rt(e,"a whitespace character is expected after the key-value separator within a block mapping"),k&&(ru(e,c,p,m,g,null,a,l,u),m=g=b=null),y=!0,k=!1,s=!1,m=e.tag,g=e.result;else if(y)rt(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=d,e.anchor=f,!0}else if(y)rt(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=d,e.anchor=f,!0}if((e.line===i||e.lineIndent>t)&&(k&&(a=e.line,l=e.lineStart,u=e.position),Ru(e,t,eg,!0,s)&&(k?g=e.result:b=e.result),k||(ru(e,c,p,m,g,b,a,l,u),m=g=b=null),mr(e,!0,-1),v=e.input.charCodeAt(e.position)),(e.line===i||e.lineIndent>t)&&v!==0)rt(e,"bad indentation of a mapping entry");else if(e.lineIndent<t)break}return k&&ru(e,c,p,m,g,null,a,l,u),y&&(e.tag=d,e.anchor=f,e.kind="mapping",e.result=c),y}function DV(e){var t,n=!1,r=!1,s,i,a;if(a=e.input.charCodeAt(e.position),a!==33)return!1;if(e.tag!==null&&rt(e,"duplication of a tag property"),a=e.input.charCodeAt(++e.position),a===60?(n=!0,a=e.input.charCodeAt(++e.position)):a===33?(r=!0,s="!!",a=e.input.charCodeAt(++e.position)):s="!",t=e.position,n){do a=e.input.charCodeAt(++e.position);while(a!==0&&a!==62);e.position<e.length?(i=e.input.slice(t,e.position),a=e.input.charCodeAt(++e.position)):rt(e,"unexpected end of the stream within a verbatim tag")}else{for(;a!==0&&!_s(a);)a===33&&(r?rt(e,"tag suffix cannot contain exclamation marks"):(s=e.input.slice(t-1,e.position+1),nT.test(s)||rt(e,"named tag handle cannot contain such characters"),r=!0,t=e.position+1)),a=e.input.charCodeAt(++e.position);i=e.input.slice(t,e.position),CV.test(i)&&rt(e,"tag suffix cannot contain flow indicator characters")}i&&!rT.test(i)&&rt(e,"tag name cannot contain such characters: "+i);try{i=decodeURIComponent(i)}catch{rt(e,"tag name is malformed: "+i)}return n?e.tag=i:ol.call(e.tagMap,s)?e.tag=e.tagMap[s]+i:s==="!"?e.tag="!"+i:s==="!!"?e.tag="tag:yaml.org,2002:"+i:rt(e,'undeclared tag handle "'+s+'"'),!0}function FV(e){var t,n;if(n=e.input.charCodeAt(e.position),n!==38)return!1;for(e.anchor!==null&&rt(e,"duplication of an anchor property"),n=e.input.charCodeAt(++e.position),t=e.position;n!==0&&!_s(n)&&!nu(n);)n=e.input.charCodeAt(++e.position);return e.position===t&&rt(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(t,e.position),!0}function zV(e){var t,n,r;if(r=e.input.charCodeAt(e.position),r!==42)return!1;for(r=e.input.charCodeAt(++e.position),t=e.position;r!==0&&!_s(r)&&!nu(r);)r=e.input.charCodeAt(++e.position);return e.position===t&&rt(e,"name of an alias node must contain at least one character"),n=e.input.slice(t,e.position),ol.call(e.anchorMap,n)||rt(e,'unidentified alias "'+n+'"'),e.result=e.anchorMap[n],mr(e,!0,-1),!0}function Ru(e,t,n,r,s){var i,a,l,u=1,d=!1,f=!1,c,p,m,g,b,k;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,i=a=l=eg===n||tT===n,r&&mr(e,!0,-1)&&(d=!0,e.lineIndent>t?u=1:e.lineIndent===t?u=0:e.lineIndent<t&&(u=-1)),u===1)for(;DV(e)||FV(e);)mr(e,!0,-1)?(d=!0,l=i,e.lineIndent>t?u=1:e.lineIndent===t?u=0:e.lineIndent<t&&(u=-1)):l=!1;if(l&&(l=d||s),(u===1||eg===n)&&(Zm===n||eT===n?b=t:b=t+1,k=e.position-e.lineStart,u===1?l&&(Nj(e,k)||$V(e,k,b))||OV(e,b)?f=!0:(a&&MV(e,b)||RV(e,b)||LV(e,b)?f=!0:zV(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&rt(e,"alias node should not have any properties")):TV(e,b,Zm===n)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):u===0&&(f=l&&Nj(e,k))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&rt(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),c=0,p=e.implicitTypes.length;c<p;c+=1)if(g=e.implicitTypes[c],g.resolve(e.result)){e.result=g.construct(e.result),e.tag=g.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(ol.call(e.typeMap[e.kind||"fallback"],e.tag))g=e.typeMap[e.kind||"fallback"][e.tag];else for(g=null,m=e.typeMap.multi[e.kind||"fallback"],c=0,p=m.length;c<p;c+=1)if(e.tag.slice(0,m[c].tag.length)===m[c].tag){g=m[c];break}g||rt(e,"unknown tag !<"+e.tag+">"),e.result!==null&&g.kind!==e.kind&&rt(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+g.kind+'", not "'+e.kind+'"'),g.resolve(e.result,e.tag)?(e.result=g.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):rt(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||f}function BV(e){var t=e.position,n,r,s,i=!1,a;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(a=e.input.charCodeAt(e.position))!==0&&(mr(e,!0,-1),a=e.input.charCodeAt(e.position),!(e.lineIndent>0||a!==37));){for(i=!0,a=e.input.charCodeAt(++e.position),n=e.position;a!==0&&!_s(a);)a=e.input.charCodeAt(++e.position);for(r=e.input.slice(n,e.position),s=[],r.length<1&&rt(e,"directive name must not be less than one character in length");a!==0;){for(;Xl(a);)a=e.input.charCodeAt(++e.position);if(a===35){do a=e.input.charCodeAt(++e.position);while(a!==0&&!Co(a));break}if(Co(a))break;for(n=e.position;a!==0&&!_s(a);)a=e.input.charCodeAt(++e.position);s.push(e.input.slice(n,e.position))}a!==0&&v0(e),ol.call(kj,r)?kj[r](e,r,s):tg(e,'unknown document directive "'+r+'"')}if(mr(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,mr(e,!0,-1)):i&&rt(e,"directives end mark is expected"),Ru(e,e.lineIndent-1,eg,!1,!0),mr(e,!0,-1),e.checkLineBreaks&&jV.test(e.input.slice(t,e.position))&&tg(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&ny(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,mr(e,!0,-1));return}if(e.position<e.length-1)rt(e,"end of the stream or a document separator is expected");else return}function lT(e,t){e=String(e),t=t||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
95
- `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var n=new IV(e,t),r=e.indexOf("\0");for(r!==-1&&(n.position=r,rt(n,"null byte is not allowed in input")),n.input+="\0";n.input.charCodeAt(n.position)===32;)n.lineIndent+=1,n.position+=1;for(;n.position<n.length-1;)BV(n);return n.documents}function HV(e,t,n){t!==null&&typeof t=="object"&&typeof n>"u"&&(n=t,t=null);var r=lT(e,n);if(typeof t!="function")return r;for(var s=0,i=r.length;s<i;s+=1)t(r[s])}function WV(e,t){var n=lT(e,t);if(n.length!==0){if(n.length===1)return n[0];throw new us("expected a single document in the stream, but found more")}}var VV=HV,UV=WV,cT={loadAll:VV,load:UV},uT=Object.prototype.toString,dT=Object.prototype.hasOwnProperty,S0=65279,KV=9,Vf=10,qV=13,YV=32,GV=33,XV=34,kb=35,JV=37,QV=38,ZV=39,eU=42,fT=44,tU=45,ng=58,nU=61,rU=62,sU=63,iU=64,pT=91,hT=93,oU=96,mT=123,aU=124,gT=125,ts={};ts[0]="\\0";ts[7]="\\a";ts[8]="\\b";ts[9]="\\t";ts[10]="\\n";ts[11]="\\v";ts[12]="\\f";ts[13]="\\r";ts[27]="\\e";ts[34]='\\"';ts[92]="\\\\";ts[133]="\\N";ts[160]="\\_";ts[8232]="\\L";ts[8233]="\\P";var lU=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],cU=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function uU(e,t){var n,r,s,i,a,l,u;if(t===null)return{};for(n={},r=Object.keys(t),s=0,i=r.length;s<i;s+=1)a=r[s],l=String(t[a]),a.slice(0,2)==="!!"&&(a="tag:yaml.org,2002:"+a.slice(2)),u=e.compiledTypeMap.fallback[a],u&&dT.call(u.styleAliases,l)&&(l=u.styleAliases[l]),n[a]=l;return n}function dU(e){var t,n,r;if(t=e.toString(16).toUpperCase(),e<=255)n="x",r=2;else if(e<=65535)n="u",r=4;else if(e<=4294967295)n="U",r=8;else throw new us("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+n+br.repeat("0",r-t.length)+t}var fU=1,Uf=2;function pU(e){this.schema=e.schema||b0,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=br.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=uU(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?Uf:fU,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function jj(e,t){for(var n=br.repeat(" ",t),r=0,s=-1,i="",a,l=e.length;r<l;)s=e.indexOf(`
96
- `,r),s===-1?(a=e.slice(r),r=l):(a=e.slice(r,s+1),r=s+1),a.length&&a!==`
97
- `&&(i+=n),i+=a;return i}function Sb(e,t){return`
98
- `+br.repeat(" ",e.indent*t)}function hU(e,t){var n,r,s;for(n=0,r=e.implicitTypes.length;n<r;n+=1)if(s=e.implicitTypes[n],s.resolve(t))return!0;return!1}function rg(e){return e===YV||e===KV}function Kf(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==S0||65536<=e&&e<=1114111}function Cj(e){return Kf(e)&&e!==S0&&e!==qV&&e!==Vf}function Ej(e,t,n){var r=Cj(e),s=r&&!rg(e);return(n?r:r&&e!==fT&&e!==pT&&e!==hT&&e!==mT&&e!==gT)&&e!==kb&&!(t===ng&&!s)||Cj(t)&&!rg(t)&&e===kb||t===ng&&s}function mU(e){return Kf(e)&&e!==S0&&!rg(e)&&e!==tU&&e!==sU&&e!==ng&&e!==fT&&e!==pT&&e!==hT&&e!==mT&&e!==gT&&e!==kb&&e!==QV&&e!==eU&&e!==GV&&e!==aU&&e!==nU&&e!==rU&&e!==ZV&&e!==XV&&e!==JV&&e!==iU&&e!==oU}function gU(e){return!rg(e)&&e!==ng}function Hd(e,t){var n=e.charCodeAt(t),r;return n>=55296&&n<=56319&&t+1<e.length&&(r=e.charCodeAt(t+1),r>=56320&&r<=57343)?(n-55296)*1024+r-56320+65536:n}function yT(e){var t=/^\n* /;return t.test(e)}var xT=1,Nb=2,wT=3,bT=4,Dc=5;function yU(e,t,n,r,s,i,a,l){var u,d=0,f=null,c=!1,p=!1,m=r!==-1,g=-1,b=mU(Hd(e,0))&&gU(Hd(e,e.length-1));if(t||a)for(u=0;u<e.length;d>=65536?u+=2:u++){if(d=Hd(e,u),!Kf(d))return Dc;b=b&&Ej(d,f,l),f=d}else{for(u=0;u<e.length;d>=65536?u+=2:u++){if(d=Hd(e,u),d===Vf)c=!0,m&&(p=p||u-g-1>r&&e[g+1]!==" ",g=u);else if(!Kf(d))return Dc;b=b&&Ej(d,f,l),f=d}p=p||m&&u-g-1>r&&e[g+1]!==" "}return!c&&!p?b&&!a&&!s(e)?xT:i===Uf?Dc:Nb:n>9&&yT(e)?Dc:a?i===Uf?Dc:Nb:p?bT:wT}function xU(e,t,n,r,s){e.dump=function(){if(t.length===0)return e.quotingType===Uf?'""':"''";if(!e.noCompatMode&&(lU.indexOf(t)!==-1||cU.test(t)))return e.quotingType===Uf?'"'+t+'"':"'"+t+"'";var i=e.indent*Math.max(1,n),a=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-i),l=r||e.flowLevel>-1&&n>=e.flowLevel;function u(d){return hU(e,d)}switch(yU(t,l,e.indent,a,u,e.quotingType,e.forceQuotes&&!r,s)){case xT:return t;case Nb:return"'"+t.replace(/'/g,"''")+"'";case wT:return"|"+_j(t,e.indent)+Pj(jj(t,i));case bT:return">"+_j(t,e.indent)+Pj(jj(wU(t,a),i));case Dc:return'"'+bU(t)+'"';default:throw new us("impossible error: invalid scalar style")}}()}function _j(e,t){var n=yT(e)?String(t):"",r=e[e.length-1]===`
99
- `,s=r&&(e[e.length-2]===`
100
- `||e===`
101
- `),i=s?"+":r?"":"-";return n+i+`
102
- `}function Pj(e){return e[e.length-1]===`
103
- `?e.slice(0,-1):e}function wU(e,t){for(var n=/(\n+)([^\n]*)/g,r=function(){var d=e.indexOf(`
104
- `);return d=d!==-1?d:e.length,n.lastIndex=d,Aj(e.slice(0,d),t)}(),s=e[0]===`
105
- `||e[0]===" ",i,a;a=n.exec(e);){var l=a[1],u=a[2];i=u[0]===" ",r+=l+(!s&&!i&&u!==""?`
106
- `:"")+Aj(u,t),s=i}return r}function Aj(e,t){if(e===""||e[0]===" ")return e;for(var n=/ [^ ]/g,r,s=0,i,a=0,l=0,u="";r=n.exec(e);)l=r.index,l-s>t&&(i=a>s?a:l,u+=`
107
- `+e.slice(s,i),s=i+1),a=l;return u+=`
108
- `,e.length-s>t&&a>s?u+=e.slice(s,a)+`
109
- `+e.slice(a+1):u+=e.slice(s),u.slice(1)}function bU(e){for(var t="",n=0,r,s=0;s<e.length;n>=65536?s+=2:s++)n=Hd(e,s),r=ts[n],!r&&Kf(n)?(t+=e[s],n>=65536&&(t+=e[s+1])):t+=r||dU(n);return t}function vU(e,t,n){var r="",s=e.tag,i,a,l;for(i=0,a=n.length;i<a;i+=1)l=n[i],e.replacer&&(l=e.replacer.call(n,String(i),l)),(da(e,t,l,!1,!1)||typeof l>"u"&&da(e,t,null,!1,!1))&&(r!==""&&(r+=","+(e.condenseFlow?"":" ")),r+=e.dump);e.tag=s,e.dump="["+r+"]"}function Ij(e,t,n,r){var s="",i=e.tag,a,l,u;for(a=0,l=n.length;a<l;a+=1)u=n[a],e.replacer&&(u=e.replacer.call(n,String(a),u)),(da(e,t+1,u,!0,!0,!1,!0)||typeof u>"u"&&da(e,t+1,null,!0,!0,!1,!0))&&((!r||s!=="")&&(s+=Sb(e,t)),e.dump&&Vf===e.dump.charCodeAt(0)?s+="-":s+="- ",s+=e.dump);e.tag=i,e.dump=s||"[]"}function kU(e,t,n){var r="",s=e.tag,i=Object.keys(n),a,l,u,d,f;for(a=0,l=i.length;a<l;a+=1)f="",r!==""&&(f+=", "),e.condenseFlow&&(f+='"'),u=i[a],d=n[u],e.replacer&&(d=e.replacer.call(n,u,d)),da(e,t,u,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),da(e,t,d,!1,!1)&&(f+=e.dump,r+=f));e.tag=s,e.dump="{"+r+"}"}function SU(e,t,n,r){var s="",i=e.tag,a=Object.keys(n),l,u,d,f,c,p;if(e.sortKeys===!0)a.sort();else if(typeof e.sortKeys=="function")a.sort(e.sortKeys);else if(e.sortKeys)throw new us("sortKeys must be a boolean or a function");for(l=0,u=a.length;l<u;l+=1)p="",(!r||s!=="")&&(p+=Sb(e,t)),d=a[l],f=n[d],e.replacer&&(f=e.replacer.call(n,d,f)),da(e,t+1,d,!0,!0,!0)&&(c=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,c&&(e.dump&&Vf===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,c&&(p+=Sb(e,t)),da(e,t+1,f,!0,c)&&(e.dump&&Vf===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,s+=p));e.tag=i,e.dump=s||"{}"}function Tj(e,t,n){var r,s,i,a,l,u;for(s=n?e.explicitTypes:e.implicitTypes,i=0,a=s.length;i<a;i+=1)if(l=s[i],(l.instanceOf||l.predicate)&&(!l.instanceOf||typeof t=="object"&&t instanceof l.instanceOf)&&(!l.predicate||l.predicate(t))){if(n?l.multi&&l.representName?e.tag=l.representName(t):e.tag=l.tag:e.tag="?",l.represent){if(u=e.styleMap[l.tag]||l.defaultStyle,uT.call(l.represent)==="[object Function]")r=l.represent(t,u);else if(dT.call(l.represent,u))r=l.represent[u](t,u);else throw new us("!<"+l.tag+'> tag resolver accepts not "'+u+'" style');e.dump=r}return!0}return!1}function da(e,t,n,r,s,i,a){e.tag=null,e.dump=n,Tj(e,n,!1)||Tj(e,n,!0);var l=uT.call(e.dump),u=r,d;r&&(r=e.flowLevel<0||e.flowLevel>t);var f=l==="[object Object]"||l==="[object Array]",c,p;if(f&&(c=e.duplicates.indexOf(n),p=c!==-1),(e.tag!==null&&e.tag!=="?"||p||e.indent!==2&&t>0)&&(s=!1),p&&e.usedDuplicates[c])e.dump="*ref_"+c;else{if(f&&p&&!e.usedDuplicates[c]&&(e.usedDuplicates[c]=!0),l==="[object Object]")r&&Object.keys(e.dump).length!==0?(SU(e,t,e.dump,s),p&&(e.dump="&ref_"+c+e.dump)):(kU(e,t,e.dump),p&&(e.dump="&ref_"+c+" "+e.dump));else if(l==="[object Array]")r&&e.dump.length!==0?(e.noArrayIndent&&!a&&t>0?Ij(e,t-1,e.dump,s):Ij(e,t,e.dump,s),p&&(e.dump="&ref_"+c+e.dump)):(vU(e,t,e.dump),p&&(e.dump="&ref_"+c+" "+e.dump));else if(l==="[object String]")e.tag!=="?"&&xU(e,e.dump,t,i,u);else{if(l==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new us("unacceptable kind of an object to dump "+l)}e.tag!==null&&e.tag!=="?"&&(d=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?d="!"+d:d.slice(0,18)==="tag:yaml.org,2002:"?d="!!"+d.slice(18):d="!<"+d+">",e.dump=d+" "+e.dump)}return!0}function NU(e,t){var n=[],r=[],s,i;for(jb(e,n,r),s=0,i=r.length;s<i;s+=1)t.duplicates.push(n[r[s]]);t.usedDuplicates=new Array(i)}function jb(e,t,n){var r,s,i;if(e!==null&&typeof e=="object")if(s=t.indexOf(e),s!==-1)n.indexOf(s)===-1&&n.push(s);else if(t.push(e),Array.isArray(e))for(s=0,i=e.length;s<i;s+=1)jb(e[s],t,n);else for(r=Object.keys(e),s=0,i=r.length;s<i;s+=1)jb(e[r[s]],t,n)}function jU(e,t){t=t||{};var n=new pU(t);n.noRefs||NU(e,n);var r=e;return n.replacer&&(r=n.replacer.call({"":r},"",r)),da(n,0,r,!0,!0)?n.dump+`
110
- `:""}var CU=jU,EU={dump:CU};function N0(e,t){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+t+" instead, which is now safe by default.")}}var _U=$r,PU=OI,AU=FI,IU=VI,TU=UI,RU=b0,LU=cT.load,OU=cT.loadAll,MU=EU.dump,$U=us,DU={binary:XI,float:WI,map:DI,null:zI,pairs:QI,set:ZI,timestamp:YI,bool:BI,int:HI,merge:GI,omap:JI,seq:$I,str:MI},FU=N0("safeLoad","load"),zU=N0("safeLoadAll","loadAll"),BU=N0("safeDump","dump"),vT={Type:_U,Schema:PU,FAILSAFE_SCHEMA:AU,JSON_SCHEMA:IU,CORE_SCHEMA:TU,DEFAULT_SCHEMA:RU,load:LU,loadAll:OU,dump:MU,YAMLException:$U,types:DU,safeLoad:FU,safeLoadAll:zU,safeDump:BU};const al=["requirement","planning","code","test","normal"],Cb={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"},HU=["agent","control","provide","condition","jump","condition_jump","start","end"];function WU(e){return HU.includes(e)?e:"agent"}function VU(e){const t=(e||"").toLowerCase();return t.startsWith("control_")?"control":t.startsWith("agent_")?"agent":t.startsWith("provide_")?"provide":(t.startsWith("tool_"),"agent")}function UU(e){var t;if(!(e!=null&&e.trim()))return{nodes:[],edges:[],instances:{}};try{const n=vT.load(e);if(!n||typeof n!="object")return{error:"flow.yaml 格式无效:根内容不是对象"};const r=n,s=r.instances&&typeof r.instances=="object"?r.instances:{},i=Array.isArray(r.edges)?r.edges:Array.isArray((t=r.flow)==null?void 0:t.edges)?r.flow.edges:[],a=r.ui&&typeof r.ui=="object"?r.ui:{},l=a.nodePositions&&typeof a.nodePositions=="object"?a.nodePositions:{},u=a.nodeSizes&&typeof a.nodeSizes=="object"?a.nodeSizes:{},d=a.viewport&&typeof a.viewport=="object"?a.viewport:null,f=d&&Number.isFinite(Number(d.x))&&Number.isFinite(Number(d.y))&&Number.isFinite(Number(d.zoom))?{x:Number(d.x),y:Number(d.y),zoom:Math.min(Math.max(Number(d.zoom),.1),4)}:void 0,c=typeof a.description=="string"&&a.description.trim()?a.description.trim():void 0,p=new Set(Object.keys(s));for(const b of i)b!=null&&b.source&&p.add(String(b.source)),b!=null&&b.target&&p.add(String(b.target));const m=Array.from(p).map(b=>{const k=s[b],y=l[b]&&typeof l[b].x=="number"&&typeof l[b].y=="number"?{x:l[b].x,y:l[b].y}:{x:0,y:0},v=u[b]&&typeof u[b].width=="number"&&typeof u[b].height=="number"?{width:u[b].width,height:u[b].height}:null,w=(k==null?void 0:k.definitionId)??b,j=VU(w),P=(k==null?void 0:k.label)!=null?String(k.label):b,_=(k==null?void 0:k.role)!=null?String(k.role).trim():"",L=Cb[_]||_,B=al.includes(L)?L:"normal",D=(k==null?void 0:k.model)!=null?String(k.model).trim():void 0,F=(k==null?void 0:k.body)!=null?String(k.body):"",R=(k==null?void 0:k.script)!=null?String(k.script):"",M=Array.isArray(k==null?void 0:k.images)?k.images:[];return{id:b,type:WU(j),position:y,...v?{width:v.width,height:v.height}:{},data:{label:P,definitionId:w,schemaType:j,role:B,model:D||void 0,body:F,images:M,...v?{displaySize:v}:{},...R.trim()!==""?{script:R}:{}}}}),g=i.filter(b=>(b==null?void 0:b.source)&&(b==null?void 0:b.target)).map((b,k)=>({id:`e-${b.source}-${b.target}-${k}`,source:String(b.source),target:String(b.target),sourceHandle:b.sourceHandle??void 0,targetHandle:b.targetHandle??void 0,markerEnd:{type:Ls.ArrowClosed}}));return{nodes:m,edges:g,instances:s,description:c,...f?{viewport:f}:{}}}catch(n){const r=n instanceof Error?n.message:String(n);let s="";if(/bad indentation of a mapping entry|expected.*scalar|mapping values are not allowed/i.test(r)){const i=r.match(/\((\d+):/);s=`
111
-
112
- 💡 提示:通常由 ${i?`第 ${i[1]} 行附近`:""}的 \`script\` / \`body\` / \`value\` 字段裸写命令字符串引起。
113
- YAML 中含 \`: \`、\`"\`、\`'\` 等特殊字符的多行字符串必须使用 \`|\` 块标量。
114
-
115
- ✅ 正确写法:
116
- \`\`\`yaml
117
- script: |
118
- node -e "console.log('TODO: scripts/x.mjs')"
119
- \`\`\`
120
- ❌ 错误写法(当前文件):
121
- \`\`\`yaml
122
- script: node -e "console.log('TODO: scripts/x.mjs')"
123
- \`\`\``}return{error:`flow.yaml 解析失败:${r}${s}`}}}function hp(e,t){var s,i,a,l,u,d,f,c,p,m,g,b;const n=k=>{const y={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&&(y.required=!0),(k==null?void 0:k.showOnNode)!=null&&(y.showOnNode=!!k.showOnNode),y},r={};for(const k of e){const y=t[k.id]&&typeof t[k.id]=="object"?{...t[k.id]}:{},v=((s=k.data)==null?void 0:s.definitionId)||k.id,w=((i=k.data)==null?void 0:i.inputs)??[],j=((a=k.data)==null?void 0:a.outputs)??[],P=((l=k.data)==null?void 0:l.role)!=null?String(k.data.role).trim():"",_=y.role!=null?String(y.role).trim():"",L=Cb[P]||P,B=Cb[_]||_,D=al.includes(L)?L:al.includes(B)?B:"normal",F=Array.isArray(w)?w.map(n):Array.isArray(y.input)?y.input.map(V=>n(V)):[],R=Array.isArray(j)?j.map(n):Array.isArray(y.output)?y.output.map(V=>n(V)):[],M=((u=k.data)==null?void 0:u.label)!=null?String(k.data.label):y.label!=null?String(y.label):k.id,W=(d=k.data)==null?void 0:d.body,O=W!=null?String(W):y.body!=null?String(y.body):"";let $=((f=k.data)==null?void 0:f.model)!=null&&String(k.data.model).trim()!==""?String(k.data.model).trim():y.model!=null&&String(y.model).trim()!==""?String(y.model).trim():void 0;($===""||$==="default")&&($=void 0);const I={...y,definitionId:v,label:M,role:D,model:$,input:F,output:R},z=((c=k.data)==null?void 0:c.marketplaceRef)||y.marketplaceRef;z?I.marketplaceRef=String(z):delete I.marketplaceRef;const C=((p=k.data)==null?void 0:p.marketplacePackageId)||y.marketplacePackageId;C?I.marketplacePackageId=String(C):delete I.marketplacePackageId;const T=((m=k.data)==null?void 0:m.marketplaceVersion)||y.marketplaceVersion;T?I.marketplaceVersion=String(T):delete I.marketplaceVersion,v.startsWith("provide_")||O.trim()===""?delete I.body:I.body=O;const E=Array.isArray((g=k.data)==null?void 0:g.images)?k.data.images:Array.isArray(y.images)?y.images:[];E.length>0?I.images=E:delete I.images;const G=(b=k.data)==null?void 0:b.script,Z=G!=null?String(G):y.script!=null?String(y.script):"";Z.trim()===""?delete I.script:I.script=Z,delete I.temperature,delete I.maxTokens,delete I.description,r[k.id]=I}return r}function cf(e){return typeof structuredClone=="function"?structuredClone(e):JSON.parse(JSON.stringify(e))}function KU(e,t){const n=String(e||"node").replace(/_copy(?:_\d+)?$/i,"");let r=`${n}_copy`,s=2;for(;t.has(r);)r=`${n}_copy_${s}`,s+=1;return t.add(r),r}function kT(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)),i=(t||[]).filter(a=>s.has(a.source)&&s.has(a.target));return{version:1,nodes:r.map(a=>cf(a)),edges:i.map(a=>cf(a)),instances:hp(r,n||{})}}function ST(e,t,n,r,s={}){var c;if(!e||!Array.isArray(e.nodes)||e.nodes.length===0)return null;const i=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,KU(p.id,a));const u=e.nodes.map(p=>{var g,b;const m=l.get(p.id);return{...cf(p),id:m,selected:!0,dragging:!1,position:{x:Number(((g=p.position)==null?void 0:g.x)||0)+i.x,y:Number(((b=p.position)==null?void 0:b.y)||0)+i.y}}}),d=(e.edges||[]).filter(p=>l.has(p.source)&&l.has(p.target)).map((p,m)=>{const g=l.get(p.source),b=l.get(p.target);return{...cf(p),id:`e-${g}-${b}-${Date.now()}-${m}`,source:g,target:b,selected:!1}}),f={...r||{}};for(const[p,m]of l.entries()){const g=(c=e.instances)==null?void 0:c[p];g&&(f[m]={...cf(g),label:g.label!=null?String(g.label):m})}return{nodes:[...(t||[]).map(p=>({...p,selected:!1})),...u],edges:[...(n||[]).map(p=>({...p,selected:!1})),...d],instances:f,pastedNodeIds:u.map(p=>p.id)}}function Rj(e,t,n,r){var f,c,p,m;const s=hp(e,n),i=t.map(g=>({source:g.source,target:g.target,sourceHandle:g.sourceHandle??null,targetHandle:g.targetHandle??null})),a={},l={};for(const g of e){const b=g.position??{x:0,y:0};a[g.id]={x:b.x,y:b.y};const k=Number(((c=(f=g.data)==null?void 0:f.displaySize)==null?void 0:c.width)||g.width||0),y=Number(((m=(p=g.data)==null?void 0:p.displaySize)==null?void 0:m.height)||g.height||0);k>0&&y>0&&(l[g.id]={width:Math.round(k),height:Math.round(y)})}const u={nodePositions:a};Object.keys(l).length>0&&(u.nodeSizes=l),r!=null&&r.viewport&&Number.isFinite(Number(r.viewport.x))&&Number.isFinite(Number(r.viewport.y))&&Number.isFinite(Number(r.viewport.zoom))&&(u.viewport={x:Number(r.viewport.x),y:Number(r.viewport.y),zoom:Math.min(Math.max(Number(r.viewport.zoom),.1),4)}),(r==null?void 0:r.description)!=null&&String(r.description).trim()!==""&&(u.description=String(r.description).trim());const d={instances:s,edges:i,ui:u};return vT.dump(d,{lineWidth:-1})}function qU(e){var s,i;const t={inputNames:[],outputNames:[]},n=Array.isArray((s=e.data)==null?void 0:s.inputs)?e.data.inputs:[],r=Array.isArray((i=e.data)==null?void 0:i.outputs)?e.data.outputs:[];for(let a=0;a<n.length;a++){const l=n[a],u=(l&&l.name!=null?String(l.name).trim():"")||`input-${a}`;t.inputNames.push(u)}for(let a=0;a<r.length;a++){const l=r[a],u=(l&&l.name!=null?String(l.name).trim():"")||`output-${a}`;t.outputNames.push(u)}return t}function YU(e,t,n){var u,d,f;const r=new Set(e.map(c=>c.id)),s={};for(const c of e)s[c.id]=qU(c);const i=new Map,a=new Map;for(const c of t)c.target&&r.has(c.target)&&(i.has(c.target)||i.set(c.target,new Set),c.targetHandle&&i.get(c.target).add(c.targetHandle)),c.source&&r.has(c.source)&&(a.has(c.source)||a.set(c.source,new Set),c.sourceHandle&&a.get(c.source).add(c.sourceHandle));const l=[];for(const c of e){const p=((u=c.data)==null?void 0:u.definitionId)!=null?String(c.data.definitionId):"",m=s[c.id]||{inputNames:[],outputNames:[]},g=m.inputNames.length,b=m.outputNames.length;if(!(p==="control_start"||p.startsWith("provide_"))&&g>0)for(let v=0;v<g;v++){const w=`input-${v}`;if(!((d=i.get(c.id))==null?void 0:d.has(w))){const P=m.inputNames[v]||w;l.push({nodeId:c.id,suffix:n("flow:validation.inputSlotNoEdge",{slotName:P,handle:w}),key:`${c.id}-${w}-in`})}}if(!(p==="control_end")&&b>0)for(let v=0;v<b;v++){const w=`output-${v}`;if(!((f=a.get(c.id))==null?void 0:f.has(w))){const P=m.outputNames[v]||w;l.push({nodeId:c.id,suffix:n("flow:validation.outputSlotNoEdge",{slotName:P,handle:w}),key:`${c.id}-${w}-out`})}}}return l}const sg=/\[image\s+(\d+)\]/gi;function Ps(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 GU(e){return`image ${Ps(e).length+1}`}function XU(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function JU(e,t){const n=Ps(e),r=String(t||""),s=new Set;sg.lastIndex=0;let i;for(;i=sg.exec(r);)s.add(`image ${i[1]}`.toLowerCase());return s.size===0?[]:n.filter(a=>s.has(String(a.label||"").toLowerCase()))}function QU(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 NT(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 ig(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 jT({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let s=String(t||"");const i=Ps(n);for(const a of r){const l=await QU(a),u=GU(i);i.push({id:`${Date.now().toString(36)}-${i.length+1}`,label:u,...l}),s=XU(s,u)}return{body:s,images:i}}function Eb(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),r.showOnNode=n?!!e.showOnNode:!!r.required||String(t).trim().toLowerCase()==="node",r._showOnNodeExplicit=n,r}const ZU={agent_subAgent:["SubAgent"],control_start:["Start"],control_end:["End"],control_agent_toBool:["Agent ToBool"],control_anyOne:["Any One"],control_cancelled:["Cancelled","Cancel Check"],control_cd_workspace:["CD Workspace"],control_delay:["Delay"],control_if:["If Branch"],control_interval_loop:["Interval Loop"],control_load_skills:["Load Skills"],control_load_mcp:["Load MCP"],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_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_bool:["Boolean"],provide_text:["Text"],provide_str:["Text"],display_markdown:["Markdown Display"],display_mermaid:["Mermaid Display"],display_ascii:["ASCII Display"],display_chart:["Chart Display"],display_table:["Table Display"]};function eK(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),s=String(t||"").trim();return!r||!s||r===s?s:(ZU[e]||[]).includes(s)?r:s}const tK={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"])},nK={control_cd_workspace:new Set(["mode","label","cwd","previous"]),control_user_workspace:new Set(["cwd"]),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"])},rK=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_image","display_chart","display_table"]);function sK(e,t){if(!rK.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function iK(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function oK(e,t){const n=String((e==null?void 0:e.baseDefinitionId)||"").trim();if(!n)return t;const r=e!=null&&e.runtime&&typeof e.runtime=="object"?e.runtime:{};return!!(r.entry||r.command)&&n==="tool_nodejs"?t:n}function Lj(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,s)=>{var d,f;const i=n[s],l=n.find(c=>(c==null?void 0:c.name)&&c.name===r.name)||i;if(!l)return r;const u=r.showOnNode===!1&&l.showOnNode==null&&((d=tK[e])==null?void 0:d.has(r.name));return{...r,...r.required==null&&l.required!=null?{required:!!l.required}:{},...u?{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&&sK(e,r)?{showOnNode:!0}:{},...(f=nK[e])!=null&&f.has(r.name)?{showOnNode:!1}:{}}})}function CT(e){var s,i;const t=Array.isArray((s=e==null?void 0:e.data)==null?void 0:s.inputs)?e.data.inputs:[],n=Array.isArray((i=e==null?void 0:e.data)==null?void 0:i.outputs)?e.data.outputs:[],r=a=>a.map(l=>{const u=Eb(l);return{type:String(u.type||"node"),name:String(u.name??""),default:String(u.default??""),required:!!u.required,showOnNode:u.showOnNode!=null?u.showOnNode!==!1:!!u.required||String(u.type||"").trim().toLowerCase()==="node"}});return{inputs:r(t),outputs:r(n)}}function qf(e,t,n,r,s){var z,C,T,E,G,Z,V,se,de,fe,pe,ae,be,_e,we,Oe,Ie,et,ft,Je,bt;const i=((z=e.data)==null?void 0:z.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(Ve=>Ve.id===i),l=t[e.id];let u=[],d=[],f=((C=e.data)==null?void 0:C.label)??e.id,c,p,m,g,b;const k=!!l;l&&(Array.isArray(l.input)&&(u=l.input.map(Eb)),Array.isArray(l.output)&&(d=l.output.map(Eb)),l.label&&(f=String(l.label)),l.role&&typeof l.role=="string"&&(c=l.role),l.model!=null&&(p=String(l.model).trim()),l.body!=null&&(m=String(l.body)),Array.isArray(l.images)&&(g=l.images),l.script!=null&&(b=String(l.script)));const y=c??(typeof((T=e.data)==null?void 0:T.role)=="string"?e.data.role:"普通"),v=p??((E=e.data)==null?void 0:E.model)??void 0,w=(a==null?void 0:a.description)!=null?String(a.description).trim():"",j=w!==""?w:void 0,P=m??((G=e.data)==null?void 0:G.body)??"",_=Array.isArray(g)?g:Array.isArray((Z=e.data)==null?void 0:Z.images)?e.data.images:[],L=b!==void 0?b:((V=e.data)==null?void 0:V.script)!=null?String(e.data.script):"",B=String(e.id),D=(se=r==null?void 0:r[s])==null?void 0:se[B],F=(de=D==null?void 0:D.label)==null?void 0:de.label,R=D==null?void 0:D.body,M=D==null?void 0:D.description;k||(u.length===0&&((fe=a==null?void 0:a.inputs)!=null&&fe.length)&&(u=a.inputs.map(Ve=>({...Ve}))),d.length===0&&((pe=a==null?void 0:a.outputs)!=null&&pe.length)&&(d=a.outputs.map(Ve=>({...Ve}))));const W=oK(a,(a==null?void 0:a.id)??i),O=(l==null?void 0:l.marketplaceRef)||((ae=e.data)==null?void 0:ae.marketplaceRef)||iK(a);if(W==="agent_subAgent"&&!d.some(Ve=>(Ve==null?void 0:Ve.name)==="result")){const Ve=(be=a==null?void 0:a.outputs)==null?void 0:be.find(jt=>(jt==null?void 0:jt.name)==="result");d=[...d,Ve?{...Ve}:{type:"text",name:"result",default:""}]}if((W==="display_markdown"||W==="display_mermaid"||W==="display_ascii"||W==="display_chart"||W==="display_table")&&!d.some(Ve=>(Ve==null?void 0:Ve.name)==="next")){const Ve=(_e=a==null?void 0:a.outputs)==null?void 0:_e.find(jt=>(jt==null?void 0:jt.name)==="next");d=[...d,Ve?{...Ve}:{type:"node",name:"next",default:""}]}if(W==="workspace_run"){if(!u.some(Ve=>(Ve==null?void 0:Ve.name)==="prev")){const Ve=(we=a==null?void 0:a.inputs)==null?void 0:we.find(jt=>(jt==null?void 0:jt.name)==="prev");u=[Ve?{...Ve}:{type:"node",name:"prev",default:""},...u]}if(!d.some(Ve=>(Ve==null?void 0:Ve.name)==="next")){const Ve=(Oe=a==null?void 0:a.outputs)==null?void 0:Oe.find(jt=>(jt==null?void 0:jt.name)==="next");d=[...d,Ve?{...Ve}:{type:"node",name:"next",default:""}]}}u=Lj(W,u,a==null?void 0:a.inputs),d=Lj(W,d,a==null?void 0:a.outputs),W.startsWith("provide_")&&d[0]&&String(d[0].default??d[0].value??"").trim()===""&&String(P).trim()!==""&&(d=d.map((Ve,jt)=>jt===0?{...Ve,default:P,value:P}:Ve));const $=eK(W,F||f,a),I=W==="tool_nodejs"||String(L).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:F||f,displayLabel:$,definitionDisplayName:a==null?void 0:a.displayName,definitionId:W,...O?{marketplaceRef:O}:{},...l!=null&&l.marketplacePackageId||(Ie=e.data)!=null&&Ie.marketplacePackageId||a!=null&&a.packageId?{marketplacePackageId:(l==null?void 0:l.marketplacePackageId)||((et=e.data)==null?void 0:et.marketplacePackageId)||(a==null?void 0:a.packageId)}:{},...l!=null&&l.marketplaceVersion||(ft=e.data)!=null&&ft.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((Je=e.data)==null?void 0:Je.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((bt=e.data)==null?void 0:bt.schemaType)??e.type??"agent",role:y,model:v,body:R||P,images:_,script:L,inputs:u,outputs:d,description:M||j,originalLabel:f,originalBody:P,...I?{script:L}:{}}}}function ET(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var f,c,p,m;const s=n.get(r.source),i=n.get(r.target),a=((c=(f=s==null?void 0:s.data)==null?void 0:f.outputs)==null?void 0:c.length)??0,l=((m=(p=i==null?void 0:i.data)==null?void 0:p.inputs)==null?void 0:m.length)??0,u=r.sourceHandle?parseInt(String(r.sourceHandle).replace("output-",""),10):0,d=r.targetHandle?parseInt(String(r.targetHandle).replace("input-",""),10):0;return s&&i&&u>=0&&u<a&&d>=0&&d<l})}function Oj(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 Mj(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function og(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=Oj(t==null?void 0:t.sourceHandle,"output"),i=Oj(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(u=>{var d,f,c,p;if(u.id===n){const m=Mj((d=u.data)==null?void 0:d.outputs,s);if(m!==((f=u.data)==null?void 0:f.outputs))return a=!0,{...u,data:{...u.data,outputs:m}}}if(u.id===r){const m=Mj((c=u.data)==null?void 0:c.inputs,i);if(m!==((p=u.data)==null?void 0:p.inputs))return a=!0,{...u,data:{...u.data,inputs:m}}}return u});return a?l:e}const $j=80,aK=220;function lK(e){if(!e||typeof e!="object")return e;const{selected:t,dragging:n,resizing:r,className:s,positionAbsolute:i,measured:a,internals:l,...u}=e;return u}function cK(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function Ph(e,t,n){const r={nodes:Array.isArray(e)?e.map(lK):[],edges:Array.isArray(t)?t.map(cK):[],extra:n&&typeof n=="object"?n:{}},s=JSON.stringify(r);return{value:JSON.parse(s),signature:s}}function Ex(e,t){const n=[...e,t];return n.length>$j?n.slice(n.length-$j):n}function _T({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:s}){const[i,a]=h.useState(0),l=h.useRef([]),u=h.useRef([]),d=h.useRef(null),f=h.useRef(null),c=h.useRef(null),p=h.useRef(null),m=h.useRef(!1),g=h.useCallback(()=>a(P=>P+1),[]),b=h.useCallback(()=>{p.current&&(window.clearTimeout(p.current),p.current=null)},[]),k=h.useCallback(()=>{b();const P=f.current,_=c.current;return f.current=null,c.current=null,!P||!_||P.signature===_.signature?(_&&(d.current=_),!1):(l.current=Ex(l.current,P),u.current=[],d.current=_,g(),!0)},[g,b]),y=h.useCallback((P=[],_=[],L={})=>{b(),l.current=[],u.current=[],f.current=null,c.current=null,d.current=Ph(P,_,L),m.current=!1,g()},[g,b]),v=h.useCallback(P=>{m.current=!0,d.current=P,f.current=null,c.current=null,b(),s==null||s(P.value),g()},[g,b,s]),w=h.useCallback(()=>{k();const P=d.current||Ph(e,t,n),_=l.current.pop();return _?(u.current=Ex(u.current,P),v(_),!0):(g(),!1)},[g,t,n,k,e,v]),j=h.useCallback(()=>{k();const P=d.current||Ph(e,t,n),_=u.current.pop();return _?(l.current=Ex(l.current,P),v(_),!0):(g(),!1)},[g,t,n,k,e,v]);return h.useEffect(()=>()=>b(),[b]),h.useEffect(()=>{if(!r)return;const P=Ph(e,t,n);if(!d.current){d.current=P;return}if(m.current){m.current=!1,d.current=P;return}P.signature!==d.current.signature&&(f.current||(f.current=d.current),c.current=P,b(),p.current=window.setTimeout(()=>{k()},aK))},[b,t,r,n,k,e]),{canUndo:l.current.length>0||!!f.current,canRedo:u.current.length>0,resetHistory:y,undo:w,redo:j,version:i}}function nr(e){switch(ag(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function ag(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 uK(e,t){const n=ag(e),r=ag(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const dK=new Set(["workspaceContext","skillsContext","mcpContext"]);function _b(e){const t=ag(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&dK.has(n)?`${t}+${n}`:t}function PT(e){return _b(e)}function Lu(e,t){if(!e||!t||!uK(e.type,t.type))return!1;const n=_b(e),r=_b(t),s=n.includes("+"),i=r.includes("+");return s||i?n===r:!0}function fK(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 Ou(e,t,n){var l;const r=n==="source"?"outputs":"inputs",i=fK(t,n==="source"?"output":"input");return i<0?null:(Array.isArray((l=e==null?void 0:e.data)==null?void 0:l[r])?e.data[r]:[])[i]||null}function Yo(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function pK(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 hK(e){const t=String(e||"").trim();return t?t.match(/^marketplace:/i)?"MARKETPLACE":t:""}function mK(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function Rr(e){e.stopPropagation()}function gK(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function yK(e,t){const n=`\\[${gK(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
124
- `).replace(/\n{3,}/g,`
125
-
126
- `).trimEnd()}function _x(e){return String(e||"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function xK(e){const t=String(e||"");let n="",r=0;sg.lastIndex=0;let s;for(;s=sg.exec(t);)n+=_x(t.slice(r,s.index)),n+=`<span class="af-flow-node__image-token">${_x(s[0])}</span>`,r=s.index+s[0].length;return n+=_x(t.slice(r)),n||" "}function wK(e,t){const n=window.getComputedStyle(e),r=Number.parseFloat(n.lineHeight)||18,s=Number.parseFloat(n.paddingTop)||0,i=Number.parseFloat(n.paddingBottom)||0,a=Number.parseFloat(n.borderTopWidth)||0,l=Number.parseFloat(n.borderBottomWidth)||0,u=String(t||"").split(/\r\n|\r|\n/).length,d=Math.min(Math.max(u,2),8);return Math.ceil(d*r+s+i+a+l)}function AT({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:s,onProvideValueChange:i,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:u,onModelChange:d}){var hn,sr;const{t:f}=Pn(),c=(e==null?void 0:e.inputs)??[],p=(e==null?void 0:e.outputs)??[],m=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),g=pK(e),b=hK(g),k=(e==null?void 0:e.isRunMode)??!1,y=!!(e!=null&&e.readOnly),v=(e==null?void 0:e.isExecuting)??!1,w=(e==null?void 0:e.isDim)??!1,j=(e==null?void 0:e.nodeStatus)??null,P=(e==null?void 0:e.nodeElapsed)??null,_=(e==null?void 0:e.definitionId)||"",L=_.startsWith("provide_"),B=_==="provide_bool",D=_==="provide_str",F=_==="provide_file",R=_==="agent_subAgent",M=R&&!k,W=B?mK(p[0]):!1,O=L?String(((hn=p[0])==null?void 0:hn.value)??((sr=p[0])==null?void 0:sr.default)??(e==null?void 0:e.body)??""):"",$=String((e==null?void 0:e.body)||""),I=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||f("flow:node.fallbackLabel"),z=!L&&!M&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",C=Ps(e==null?void 0:e.images),T=h.useRef(!1),E=h.useRef(!1),G=h.useRef(null),Z=h.useRef(null),V=h.useRef(null),[se,de]=h.useState(O),[fe,pe]=h.useState($);h.useEffect(()=>{T.current||de(O)},[n,O]),h.useEffect(()=>{E.current||pe($)},[n,$]),h.useEffect(()=>{const xe=Z.current;if(!xe)return;const Me=wK(xe,fe);xe.style.minHeight=`${Me}px`,xe.style.height="",V.current&&(V.current.style.minHeight=`${Me}px`,V.current.style.height="")},[fe]),h.useEffect(()=>{const xe=G.current,Me=e==null?void 0:e.onNodeContentResize;if(!M||!xe||!Me||typeof ResizeObserver>"u")return;let Ze=0;const Dt=()=>{window.cancelAnimationFrame(Ze),Ze=window.requestAnimationFrame(()=>Me(n))},ie=new ResizeObserver(Dt);return ie.observe(xe),Dt(),()=>{window.cancelAnimationFrame(Ze),ie.disconnect()}},[e==null?void 0:e.onNodeContentResize,M,n]);const ae=Array.isArray(u==null?void 0:u.cursor)?u.cursor:[],be=Array.isArray(u==null?void 0:u.opencode)?u.opencode:[],_e=Array.isArray(u==null?void 0:u.claudeCode)?u.claudeCode:[],we=((e==null?void 0:e.model)??"").trim(),Oe=m==="agent"&&!_.startsWith("tool_nodejs"),Ie=new Set(ae.map(Yo)),et=new Set(be.map(Yo)),ft=new Set(_e.map(Yo)),Je=we?we.startsWith("cursor:")||we.startsWith("opencode:")||we.startsWith("claude-code:")?we:ft.has(we)?`claude-code:${we}`:et.has(we)?`opencode:${we}`:Ie.has(we)?`cursor:${we}`:we:"",bt=we&&!Je.startsWith("cursor:")&&!Je.startsWith("opencode:")&&!Je.startsWith("claude-code:")&&!Ie.has(we)&&!et.has(we)&&!ft.has(we),Ve=we.startsWith("cursor:")?we.slice(7):we.startsWith("opencode:")?we.slice(9):we.startsWith("claude-code:")?we.slice(12):we,jt=xe=>{if(y)return;const Me=xe.target.value;d&&d(n,Me)},An=xe=>{xe.stopPropagation(),!y&&r&&r(n)},pn=xe=>{xe.stopPropagation(),s&&s()},In=xe=>{xe.stopPropagation(),!y&&(i==null||i(n,xe.target.value==="true"?"true":"false"))},en=xe=>{if(xe.stopPropagation(),y)return;const Me=xe.target.value;de(Me),T.current||i==null||i(n,Me)},Wn=xe=>{xe.stopPropagation(),T.current=!0},Tn=xe=>{if(xe.stopPropagation(),y)return;T.current=!1;const Me=xe.currentTarget.value;de(Me),i==null||i(n,Me)},ce=()=>{y||i==null||i(n,se)},ve=xe=>{if(xe.stopPropagation(),y)return;const Me=window.prompt("文件路径",se);Me!=null&&(de(Me),i==null||i(n,Me))},ze=xe=>{if(pe(xe),a==null||a(n,xe),l){const Me=JU(C,xe);(Me.length!==C.length||Me.some((Ze,Dt)=>{var ie;return Ze.id!==((ie=C[Dt])==null?void 0:ie.id)}))&&l(n,Me)}},it=xe=>{if(xe.stopPropagation(),y)return;const Me=xe.target.value;E.current?pe(Me):ze(Me)},ot=xe=>{xe.stopPropagation(),!y&&(E.current=!0)},Tt=xe=>{if(xe.stopPropagation(),y)return;E.current=!1;const Me=xe.currentTarget.value;ze(Me)},tt=()=>{y||ze(fe)},an=async xe=>{if(y)return;const Me=await jT({files:xe,body:fe,images:C});Me&&(pe(Me.body),a==null||a(n,Me.body),l==null||l(n,Me.images))},Xt=(xe,Me)=>{if(xe.stopPropagation(),y)return;const Ze=C.filter(ie=>ie.id!==Me.id),Dt=yK(fe,Me.label);pe(Dt),a==null||a(n,Dt),l==null||l(n,Ze)},rr=xe=>{if(y)return;const Me=NT(xe);Me.length!==0&&(xe.preventDefault(),xe.stopPropagation(),an(Me).catch(()=>{}))},vn=xe=>{if(y)return;const Me=ig(xe);Me.length!==0&&(xe.preventDefault(),xe.stopPropagation(),an(Me).catch(()=>{}))},ln=()=>{const xe=Z.current,Me=V.current;!xe||!Me||(Me.scrollTop=xe.scrollTop,Me.scrollLeft=xe.scrollLeft)};return o.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(v?" af-flow-node--executing":"")+(j==="success"?" af-flow-node--done":"")+(j==="failed"?" af-flow-node--failed":"")+(j==="running"&&!v?" af-flow-node--running-disk":"")+(w?" af-flow-node--dim":"")+(M?" af-flow-node--inline-body-editor":"")+" af-flow-node--"+m.replace(/[^a-z0-9_-]/g,""),"data-schema":m,children:[o.jsxs("div",{className:"af-flow-node__chrome",children:[o.jsx("span",{className:"af-flow-node__type",title:g,children:b}),!k&&Oe&&o.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:Rr,onMouseDown:Rr,onClick:Rr,children:[o.jsxs("select",{className:"af-flow-node__model nodrag",value:Je,onChange:jt,onPointerDown:Rr,onMouseDown:Rr,onClick:Rr,"aria-label":f("flow:node.model"),title:Ve||f("flow:node.defaultModel"),disabled:y,children:[o.jsx("option",{value:"",children:f("flow:node.defaultModel")}),bt&&o.jsx("option",{value:we,children:we}),ae.length>0&&o.jsx("optgroup",{label:"Cursor",children:ae.map(xe=>o.jsx("option",{value:`cursor:${Yo(xe)}`,children:Yo(xe)},`c-${xe}`))}),be.length>0&&o.jsx("optgroup",{label:"OpenCode",children:be.map(xe=>o.jsx("option",{value:`opencode:${Yo(xe)}`,children:Yo(xe)},`o-${xe}`))}),_e.length>0&&o.jsx("optgroup",{label:"Claude Code",children:_e.map(xe=>o.jsx("option",{value:`claude-code:${Yo(xe)}`,children:Yo(xe)},`cc-${xe}`))})]}),o.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),v&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),j==="running"&&!v&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:f("flow:node.diskRunning"),children:"RUNNING"}),j==="success"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:P!=null&&String(P).trim()!==""?P:"--"}),j==="failed"&&o.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),!k&&L&&!B&&!D&&!F&&o.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:pn,"aria-label":f("flow:node.expandProvide"),title:f("flow:node.expandProvide"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!k&&o.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:y,onClick:An,"aria-label":f("flow:node.deleteNode"),title:f("flow:node.deleteNode"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-flow-node__body",children:[o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--in",children:c.map((xe,Me)=>{if(xe.showOnNode===!1)return null;const Ze=f("flow:node.inputTooltip",{name:xe.name||`#${Me}`,type:xe.type})+(xe.default!=null&&xe.default!==""?f("flow:node.defaultSuffix",{value:xe.default}):""),Dt=xe.name||`#${Me+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:Ze,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[Dt,xe.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Ms,{type:"target",position:Xe.Left,id:`input-${Me}`,className:"af-flow-node__handle",style:{background:nr(xe.type)},title:Ze})]},`in-${Me}`)})}),o.jsxs("div",{className:"af-flow-node__title-wrap",children:[o.jsx("span",{className:"af-flow-node__title",children:I}),n?o.jsx("span",{className:"af-flow-node__subtitle",title:n,children:n}):null,B?o.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(W?" af-flow-node__bool-select--true":""),value:W?"true":"false",onChange:In,onPointerDown:Rr,onMouseDown:Rr,onClick:Rr,"aria-label":"Boolean value",title:W?"true":"false",disabled:y,children:[o.jsx("option",{value:"false",children:"false"}),o.jsx("option",{value:"true",children:"true"})]}):D?o.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:se,onChange:en,onCompositionStart:Wn,onCompositionEnd:Tn,onBlur:ce,onPointerDown:Rr,onMouseDown:Rr,onClick:Rr,placeholder:"输入文本",rows:2,readOnly:y}):F?o.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:Rr,onMouseDown:Rr,onClick:Rr,children:[o.jsx("input",{className:"af-flow-node__file-input nodrag",value:se,onChange:en,onCompositionStart:Wn,onCompositionEnd:Tn,onBlur:ce,placeholder:"选择或输入文件路径",title:se||"选择或输入文件路径",readOnly:y}),o.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:y,onClick:ve,"aria-label":"选择文件",title:"选择文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):R&&!k?o.jsxs("div",{ref:G,className:"af-flow-node__prompt-stack nodrag",children:[o.jsx("pre",{ref:V,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:xK(fe)+`
127
- `}}),o.jsx("textarea",{ref:Z,className:"af-flow-node__prompt-editor nodrag",value:fe,onChange:it,onCompositionStart:ot,onCompositionEnd:Tt,onBlur:tt,onPaste:rr,onDrop:vn,onScroll:ln,onDragOver:xe=>{ig(xe).length>0&&xe.preventDefault()},placeholder:"输入 prompt",rows:2,readOnly:y})]}):null,R&&C.length>0?o.jsx("div",{className:"af-flow-node__image-chips",children:C.map((xe,Me)=>o.jsxs("span",{className:"af-flow-node__image-chip",title:xe.name,children:[o.jsx("img",{src:xe.dataUrl,alt:""}),o.jsxs("span",{children:["[",xe.label||`image ${Me+1}`,"]"]}),o.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:y,onClick:Ze=>Xt(Ze,xe),onPointerDown:Rr,onMouseDown:Rr,"aria-label":`删除 ${xe.label||`image ${Me+1}`}`,title:"删除图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},xe.id||Me))}):null,z?o.jsx("span",{className:"af-flow-node__prompt-preview",title:z,children:z}):null]}),o.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:p.map((xe,Me)=>{if(xe.showOnNode===!1)return null;const Ze=f("flow:node.outputTooltip",{name:xe.name||`#${Me}`,type:xe.type})+(xe.default!=null&&xe.default!==""?f("flow:node.defaultSuffix",{value:xe.default}):""),Dt=xe.name||`#${Me+1}`;return o.jsxs("div",{className:"af-flow-node__port-row",title:Ze,children:[o.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[Dt,xe.required?o.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),o.jsx(Ms,{type:"source",position:Xe.Right,id:`output-${Me}`,className:"af-flow-node__handle",style:{background:nr(xe.type)},title:Ze})]},`out-${Me}`)})})]})]})}const mp="flowNode";function IT(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 lg(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function bK(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function TT({open:e,onClose:t,flowId:n,flowSource:r,onArchived:s}){const{t:i}=Pn(),a=h.useId(),l=h.useRef(null),[u,d]=h.useState(""),[f,c]=h.useState(!1),[p,m]=h.useState("");if(h.useEffect(()=>{if(!e)return;d(""),m(""),c(!1);const y=requestAnimationFrame(()=>{var v;return(v=l.current)==null?void 0:v.focus()});return()=>cancelAnimationFrame(y)},[e,n]),!e)return null;const g=u.trim(),b=g===n;async function k(y){if(y.preventDefault(),!(!b||f)){c(!0),m("");try{const v=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:g})}),w=await v.json().catch(()=>({}));if(!v.ok){m(typeof w.error=="string"?w.error:i("project:archiveModal.archiveFailed"));return}s()}catch(v){m(String((v==null?void 0:v.message)||v))}finally{c(!1)}}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:o.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:i("project:archiveModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":i("project:archiveModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:k,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:i("project:archiveModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:i("project:archiveModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:u,onChange:y=>d(y.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!b})]}),p?o.jsx("p",{className:"af-err af-new-pipeline-err",children:p}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:i("project:archiveModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!b||f,children:i(f?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function Dj({open:e,title:t,message:n,confirmLabel:r,cancelLabel:s,destructive:i=!1,secondaryLabel:a,secondaryDestructive:l=!1,onSecondary:u,onConfirm:d,onCancel:f}){const{t:c}=Pn(),p=h.useId(),m=h.useRef(null);if(h.useEffect(()=>{if(!e)return;const y=requestAnimationFrame(()=>{var w;return(w=m.current)==null?void 0:w.focus()});function v(w){w.key==="Escape"&&f(),w.key==="Enter"&&d()}return window.addEventListener("keydown",v),()=>{cancelAnimationFrame(y),window.removeEventListener("keydown",v)}},[e,f,d]),!e)return null;const g=r??c("common:common.confirm","确定"),b=s??c("common:common.cancel","取消"),k=t??c("common:common.confirmTitle","请确认");return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&f()},children:o.jsxs("div",{ref:m,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":p,tabIndex:-1,onMouseDown:y=>y.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:p,className:"af-shortcuts-panel__title",children:k}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:f,"aria-label":b,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-shortcuts-panel__body af-new-pipeline-form",children:[o.jsx("p",{className:"af-new-pipeline-lead",children:n}),o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:f,children:b}),a&&u?o.jsx("button",{type:"button",className:l?"af-btn-secondary af-btn-destructive":"af-btn-secondary",onClick:u,children:a}):null,o.jsx("button",{type:"button",className:i?"af-btn-primary af-btn-destructive":"af-btn-primary",onClick:d,autoFocus:!0,children:g})]})]})]})})}function RT({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,onDeleted:i}){const{t:a}=Pn(),l=h.useId(),u=h.useRef(null),[d,f]=h.useState(""),[c,p]=h.useState(!1),[m,g]=h.useState("");if(h.useEffect(()=>{if(!e)return;f(""),g(""),p(!1);const v=requestAnimationFrame(()=>{var w;return(w=u.current)==null?void 0:w.focus()});return()=>cancelAnimationFrame(v)},[e,n]),!e)return null;const b=d.trim(),k=b===n;async function y(v){if(v.preventDefault(),!k||c)return;p(!0),g("");let w=null;try{const j=new AbortController;w=setTimeout(()=>j.abort(),15e3);const P=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:b,flowArchived:s}),signal:j.signal}),_=await P.json().catch(()=>({}));if(!P.ok){g(typeof _.error=="string"?_.error:a("project:deleteModal.deleteFailed"));return}try{for(let L=localStorage.length-1;L>=0;L--){const B=localStorage.key(L);B&&(B.startsWith(`af:composer-sessions:${n}:${r}`)||B.startsWith(`af:composer-active-session:${n}:${r}`)||B.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(B)}}catch{}await i()}catch(j){if((j==null?void 0:j.name)==="AbortError"){g(a("project:deleteModal.deleteTimeout"));return}g(String((j==null?void 0:j.message)||j))}finally{w&&clearTimeout(w),p(!1)}}return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:v=>{v.target===v.currentTarget&&t()},children:o.jsxs("div",{ref:u,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":l,tabIndex:-1,onMouseDown:v=>v.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:l,className:"af-shortcuts-panel__title",children:a("project:deleteModal.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":a("project:deleteModal.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:y,children:[o.jsx("p",{className:"af-new-pipeline-lead",children:a("project:deleteModal.lead",{flowId:n})}),o.jsxs("label",{className:"af-new-pipeline-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:a("project:deleteModal.confirmLabel")}),o.jsx("input",{type:"text",className:"af-new-pipeline-input",value:d,onChange:v=>f(v.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":b.length>0&&!k})]}),m?o.jsx("p",{className:"af-err af-new-pipeline-err",children:m}):null,o.jsxs("div",{className:"af-new-pipeline-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:c,children:a("project:deleteModal.cancel")}),o.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||c,children:a(c?"project:deleteModal.deleting":"project:deleteModal.confirmDelete")})]})]})]})})}function vK({children:e}){return o.jsx("kbd",{className:"af-kbd",children:e})}function zi({keys:e}){return o.jsx("span",{className:"af-shortcuts-keys",children:e.map((t,n)=>o.jsxs("span",{children:[n>0?o.jsx("span",{className:"af-shortcuts-keys__plus",children:"+"}):null,o.jsx(vK,{children:t})]},n))})}function LT({open:e,onClose:t}){const{t:n}=Pn(),r=h.useRef(null);if(h.useEffect(()=>{if(!e)return;const a=requestAnimationFrame(()=>{var l;return(l=r.current)==null?void 0:l.focus()});return()=>cancelAnimationFrame(a)},[e]),!e)return null;const i=bK()?"⌘":"Ctrl";return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:a=>{a.target===a.currentTarget&&t()},children:o.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:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:"af-shortcuts-title",className:"af-shortcuts-panel__title",children:n("flow:shortcuts.title")}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":n("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-shortcuts-panel__body",children:[o.jsxs("section",{className:"af-shortcuts-section",children:[o.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.general")}),o.jsxs("ul",{className:"af-shortcuts-list",children:[o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveDesc")}),o.jsx(zi,{keys:[i,"S"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.shortcutsLabel")}),o.jsx(zi,{keys:["?"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),o.jsx(zi,{keys:[i,"K"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.openNodePalette")}),o.jsx(zi,{keys:["A"]})]})]})]}),o.jsxs("section",{className:"af-shortcuts-section",children:[o.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.canvas")}),o.jsxs("ul",{className:"af-shortcuts-list",children:[o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectTool")}),o.jsx(zi,{keys:["V"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.panTool")}),o.jsx(zi,{keys:["H"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.holdSpacePan")}),o.jsx(zi,{keys:["Space"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveViewport")}),o.jsx(zi,{keys:["F"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),o.jsx(zi,{keys:[i,"A"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.undo")}),o.jsx(zi,{keys:[i,"Z"]})]}),o.jsxs("li",{className:"af-shortcuts-row",children:[o.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.redo")}),o.jsx(zi,{keys:[i,"Shift","Z"]})]})]})]})]})]})})}function kK(e,t){if(!t)return 1;const n=t.toLowerCase(),r=(e.id||"").toLowerCase(),s=(e.label||"").toLowerCase(),i=(e.definitionId||"").toLowerCase();return r===n?100:r.startsWith(n)?80:r.includes(n)?60:s.startsWith(n)?40:s.includes(n)?30:i.includes(n)?15:0}function OT({open:e,onClose:t,onJump:n,nodes:r}){const{t:s}=Pn(),[i,a]=h.useState(""),[l,u]=h.useState(0),d=h.useRef(null),f=h.useRef(null);h.useEffect(()=>{if(!e)return;a(""),u(0);const g=requestAnimationFrame(()=>{var b;return(b=d.current)==null?void 0:b.focus()});return()=>cancelAnimationFrame(g)},[e]);const c=h.useMemo(()=>{const g=(r||[]).map(y=>{var v,w,j;return{id:y.id,label:((v=y.data)==null?void 0:v.label)||"",definitionId:((w=y.data)==null?void 0:w.definitionId)||"",schemaType:((j=y.data)==null?void 0:j.schemaType)||""}}),b=i.trim(),k=g.map(y=>({e:y,s:kK(y,b)})).filter(y=>y.s>0);return k.sort((y,v)=>v.s-y.s||y.e.id.localeCompare(v.e.id)),k.slice(0,50).map(y=>y.e)},[r,i]);if(h.useEffect(()=>{l>=c.length&&u(0)},[c.length,l]),h.useEffect(()=>{var b;const g=(b=f.current)==null?void 0:b.querySelector(`[data-idx="${l}"]`);g&&g.scrollIntoView({block:"nearest"})},[l]),!e)return null;const p=g=>{const b=c[g];b&&(n(b.id),t())},m=g=>{if(g.key==="Escape"){g.preventDefault(),t();return}if(g.key==="ArrowDown"){g.preventDefault(),u(b=>Math.min(c.length-1,b+1));return}if(g.key==="ArrowUp"){g.preventDefault(),u(b=>Math.max(0,b-1));return}g.key==="Enter"&&(g.preventDefault(),p(l))};return o.jsx("div",{className:"af-jump-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:o.jsxs("div",{className:"af-jump-panel",role:"dialog","aria-modal":"true","aria-label":s("flow:jumpPalette.title"),onMouseDown:g=>g.stopPropagation(),children:[o.jsxs("div",{className:"af-jump-panel__input-wrap",children:[o.jsx("span",{className:"af-jump-panel__icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:d,type:"text",className:"af-jump-panel__input",placeholder:s("flow:jumpPalette.placeholder"),value:i,onChange:g=>{a(g.target.value),u(0)},onKeyDown:m,spellCheck:!1,autoComplete:"off"}),o.jsx("span",{className:"af-jump-panel__count",children:c.length})]}),c.length===0?o.jsx("div",{className:"af-jump-panel__empty",children:s("flow:jumpPalette.empty")}):o.jsx("ul",{ref:f,className:"af-jump-panel__list",role:"listbox",children:c.map((g,b)=>o.jsxs("li",{"data-idx":b,role:"option","aria-selected":b===l,className:"af-jump-panel__item"+(b===l?" af-jump-panel__item--active":""),onMouseEnter:()=>u(b),onMouseDown:k=>{k.preventDefault(),p(b)},children:[o.jsx("span",{className:"af-jump-panel__id",children:g.id}),g.label&&g.label!==g.id&&o.jsx("span",{className:"af-jump-panel__label",children:g.label}),g.definitionId&&o.jsx("span",{className:"af-jump-panel__tag",children:g.definitionId})]},g.id))}),o.jsxs("div",{className:"af-jump-panel__hint",children:[o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"↑"}),o.jsx("kbd",{className:"af-kbd",children:"↓"})," ",s("flow:jumpPalette.hintNavigate")]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"Enter"})," ",s("flow:jumpPalette.hintJump")]}),o.jsxs("span",{children:[o.jsx("kbd",{className:"af-kbd",children:"Esc"})," ",s("flow:jumpPalette.hintClose")]})]})]})})}function SK({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:s=!1,filePath:i,fileName:a,onSaved:l,onAiEdit:u}){const{t:d}=Pn(),f=h.useId(),c=h.useRef(null),p=h.useRef(null),[m,g]=h.useState(""),[b,k]=h.useState(""),[y,v]=h.useState(!1),[w,j]=h.useState(!1),[P,_]=h.useState(!1),[L,B]=h.useState(""),[D,F]=h.useState("");if(h.useEffect(()=>{if(!e||!i)return;g(""),k(""),B(""),F(""),v(!0),j(!1),_(!1);const I=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i});(async()=>{try{const C=await fetch(`/api/pipeline-file-content?${I}`),T=await C.json();if(!C.ok)throw new Error(T.error||"HTTP "+C.status);g(T.content||""),k(T.content||"")}catch(C){B(C.message||String(C))}finally{v(!1)}})();const z=requestAnimationFrame(()=>{var C;return(C=c.current)==null?void 0:C.focus()});return()=>cancelAnimationFrame(z)},[e,i,n,r,s]),!e)return null;const R=m!==b;async function M(I){if(I.preventDefault(),!w){j(!0),B(""),F("");try{const z=new URLSearchParams({flowId:n,flowSource:r,archived:s?"1":"0",path:i}),C=await fetch(`/api/pipeline-file-save?${z}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({content:m})}),T=await C.json();if(!C.ok)throw new Error(T.error||"HTTP "+C.status);k(m),F(d("flow:fileEdit.saved")),l&&l()}catch(z){B(z.message||String(z))}finally{j(!1)}}}async function W(){if(!(!u||P||!m)){_(!0),B("");try{const I=await u(m);typeof I=="string"&&I&&g(I)}catch(I){B(I.message||String(I))}finally{_(!1)}}}function O(){g(b),B(""),F("")}const $=m.length>1e5;return o.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:I=>{I.target===I.currentTarget&&t()},children:o.jsxs("div",{ref:c,className:"af-shortcuts-panel af-file-edit-panel",role:"dialog","aria-modal":"true","aria-labelledby":f,tabIndex:-1,onMouseDown:I=>I.stopPropagation(),children:[o.jsxs("div",{className:"af-shortcuts-panel__head",children:[o.jsx("h2",{id:f,className:"af-shortcuts-panel__title",children:a||i}),o.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":d("flow:fileEdit.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-file-edit-body",children:y?o.jsx("div",{className:"af-file-edit-loading",children:d("flow:fileEdit.loading")}):L&&!m?o.jsx("div",{className:"af-file-edit-error",children:L}):o.jsxs(o.Fragment,{children:[$&&o.jsx("div",{className:"af-file-edit-warning",children:d("flow:fileEdit.largeFileWarning")}),o.jsx("textarea",{ref:p,className:"af-file-edit-textarea",value:m,onChange:I=>g(I.target.value),spellCheck:!1,placeholder:d("flow:fileEdit.placeholder")})]})}),(L||D)&&!y&&o.jsx("div",{className:`af-file-edit-status${D?" af-file-edit-status--success":""}`,children:D||L}),o.jsxs("div",{className:"af-file-edit-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary",onClick:O,disabled:!R||w||P,children:d("flow:fileEdit.reset")}),u&&o.jsx("button",{type:"button",className:"af-btn-secondary af-btn-ai",onClick:W,disabled:P||w||!m,children:d(P?"flow:fileEdit.aiRunning":"flow:fileEdit.aiEdit")}),o.jsx("button",{type:"button",className:"af-btn-primary",onClick:M,disabled:!R||w||P,children:d(w?"flow:fileEdit.saving":"flow:fileEdit.save")})]})]})})}const MT=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),NK=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function jK(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 CK(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 Fj(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 $T(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(MT.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 DT(e){return{inputNames:Fj(e==null?void 0:e.inputs),outputNames:Fj(e==null?void 0:e.outputs)}}function EK(e,t,n){const r=DT(t),s=CK(e),i=[];for(const a of s)if(!$T(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();i.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return i}function _K(e,t){const n=DT(t),r=/\$\{([^}]*)\}/g,s=[];let i=0,a;for(;(a=r.exec(e))!==null;){a.index>i&&s.push({kind:"plain",text:e.slice(i,a.index)});const l=a[0],u=$T(a[1],n);s.push({kind:u?"ph-valid":"ph-invalid",text:l}),i=a.index+l.length}return i<e.length&&s.push({kind:"plain",text:e.slice(i)}),s}function PK(e){return e.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function AK(e){return e.map(t=>{const n=PK(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 IK(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 i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${s}`,label:s,subtitle:i?t("flow:placeholder.inputSubtitle",{type:i}):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 i=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${s}`,label:s,subtitle:i?t("flow:placeholder.outputSubtitle",{type:i}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of NK)MT.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function TK(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(i=>String(i).toLowerCase()).some(i=>i.includes(n))):e}function RK(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 i=e.clientWidth;if(i<=0)return null;s.style.width=`${i}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(),u=parseFloat(r.lineHeight),d=Number.isFinite(u)&&u>0?u:l.height||16;return document.body.removeChild(s),{top:l.top,left:l.left,bottom:l.bottom,height:d}}function Ah({value:e,onChange:t,disabled:n,placeholder:r,rows:s=8,textareaClassName:i,ioSlots:a,variant:l="drawer",images:u,onImagesChange:d}){const{t:f}=Pn(),c=h.useId(),p=h.useRef(null),m=h.useRef(null),[g,b]=h.useState(0),[k,y]=h.useState(0),[v,w]=h.useState(null),j=h.useMemo(()=>Ps(u),[u]),P=h.useMemo(()=>EK(e,a,f),[e,a,f]),_=P.length>0,L=h.useMemo(()=>_K(e,a),[e,a]),B=h.useMemo(()=>AK(L),[L]),D=h.useMemo(()=>n?null:jK(e,g),[e,g,n]),F=h.useMemo(()=>{if(!D)return[];const I=IK(a,f);return TK(I,D.query)},[D,a,f]);h.useEffect(()=>{y(I=>{const z=Math.max(0,F.length-1);return Math.min(Math.max(0,I),z)})},[F.length]);const R=h.useCallback(()=>{const I=p.current;if(!I||!D||F.length===0){w(null);return}const z=RK(I,g);if(!z){w(null);return}const C=4,T=44,E=13.5*16,G=Math.min(F.length*T+8,E);let Z=z.bottom+C;Z+G>window.innerHeight-8&&(Z=Math.max(8,z.top-G-C));const V=288;let se=z.left;se=Math.max(8,Math.min(se,window.innerWidth-V-8)),w({top:Z,left:se})},[D,F.length,g]);h.useLayoutEffect(()=>{if(!D||F.length===0){w(null);return}const I=requestAnimationFrame(()=>R());return()=>cancelAnimationFrame(I)},[D,F.length,g,e,R]),h.useEffect(()=>{if(!D||F.length===0)return;const I=()=>R();return window.addEventListener("scroll",I,!0),window.addEventListener("resize",I),()=>{window.removeEventListener("scroll",I,!0),window.removeEventListener("resize",I)}},[D,F.length,R]);const M=h.useCallback(I=>{if(!D)return;const{atIndex:z}=D,C=e.slice(0,z)+"${"+I+"}"+e.slice(g);t(C);const T=z+I.length+3;queueMicrotask(()=>{const E=p.current;E&&(E.focus(),E.setSelectionRange(T,T)),b(T)})},[D,e,g,t]),W=h.useCallback(()=>{const I=p.current,z=m.current;!I||!z||(z.scrollTop=I.scrollTop,z.scrollLeft=I.scrollLeft,D&&F.length>0&&queueMicrotask(()=>R()))},[D,F.length,R]),O=h.useCallback(I=>{if(!n&&D&&F.length>0&&(I.key==="ArrowDown"||I.key==="ArrowUp"||I.key==="Enter")){if(I.key==="ArrowDown")I.preventDefault(),y(z=>(z+1)%F.length);else if(I.key==="ArrowUp")I.preventDefault(),y(z=>(z-1+F.length)%F.length);else if(I.key==="Enter"&&!I.shiftKey){I.preventDefault();const z=F[k];z&&M(z.insert)}}},[n,D,F,k,M]),$=h.useCallback(async I=>{if(n||typeof d!="function")return!1;const z=await jT({files:I,body:e,images:j});return z?(t(z.body),d(z.images),queueMicrotask(()=>{const C=p.current;if(!C)return;C.focus();const T=z.body.length;C.setSelectionRange(T,T),b(T)}),!0):!1},[n,j,t,d,e]);return o.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[j.length>0?o.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:j.map((I,z)=>o.jsxs("span",{className:"af-body-image-chip",title:I.name,children:[o.jsx("img",{src:I.dataUrl,alt:""}),o.jsxs("span",{children:["[",I.label||`image ${z+1}`,"]"]})]},I.id||z))}):null,o.jsxs("div",{className:"af-body-prompt-stack",children:[o.jsx("pre",{ref:m,className:"af-body-prompt-backdrop "+i,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:B+`
128
- `}}),o.jsx("textarea",{ref:p,className:"af-body-prompt-textarea "+i,rows:s,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":_,"aria-describedby":_?c:void 0,onChange:I=>{t(I.target.value),b(I.target.selectionStart??I.target.value.length)},onSelect:I=>{const z=I.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??0)},onClick:I=>{const z=I.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??0)},onKeyUp:I=>{const z=I.target;z instanceof HTMLTextAreaElement&&b(z.selectionStart??z.value.length)},onKeyDown:O,onPaste:I=>{const z=NT(I);z.length!==0&&(I.preventDefault(),$(z).catch(()=>{}))},onDragOver:I=>{ig(I).length>0&&I.preventDefault()},onDrop:I=>{const z=ig(I);z.length!==0&&(I.preventDefault(),$(z).catch(()=>{}))},onScroll:W})]}),D&&F.length>0&&v?Or.createPortal(o.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":f("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:v.top,left:v.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:F.map((I,z)=>o.jsx("li",{role:"option","aria-selected":z===k,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(z===k?" af-composer-mention-item--active":""),onMouseDown:C=>C.preventDefault(),onMouseEnter:()=>y(z),onClick:()=>M(I.insert),children:[o.jsx("span",{className:"af-composer-mention-id",children:`\${${I.insert}}`}),I.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:I.subtitle}):null]})},`${I.section}-${I.insert}`))}),document.body):null,_?o.jsx("p",{id:c,className:"af-body-ph-issues",role:"status",children:P.map(I=>I.message).join(" · ")}):null]})}const FT=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function Ih(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function zj({kind:e,label:t,slots:n,onSlotsChange:r,disabled:s,requiredReadonly:i=!0}){const{t:a}=Pn(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),u=c=>r(n.filter((p,m)=>m!==c)),d=(c,p,m)=>{const g=n.map((b,k)=>{if(k!==c)return b;const y={...b,[p]:m};return p==="required"&&m===!0&&(y.showOnNode=!0),y});r(g)},f=e==="input"?"input":"output";return o.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[o.jsxs("div",{className:"af-node-props-io-head",children:[o.jsx("span",{className:"af-node-props-label",children:t}),o.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")})]}),o.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:f})}),n.length===0?o.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?o.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[o.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[o.jsx("span",{children:a("flow:nodeProps.handle")}),o.jsx("span",{children:a("flow:nodeProps.type")}),o.jsx("span",{children:a("flow:nodeProps.name")}),o.jsx("span",{children:a("flow:nodeProps.defaultValue")}),o.jsx("span",{children:a("flow:nodeProps.required")}),o.jsx("span",{children:a("flow:nodeProps.showOnNode")}),o.jsx("span",{})]}),n.map((c,p)=>o.jsxs("div",{className:"af-node-props-io-row",children:[o.jsxs("span",{className:"af-node-props-io-handle",title:`${f}-${p}`,children:[f,"-",p]}),o.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:c.type,onChange:m=>d(p,"type",m.target.value),disabled:s,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:p}),children:["node","text","file","bool"].map(m=>o.jsx("option",{value:m,children:m},m))}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:c.name,onChange:m=>d(p,"name",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:p})}),o.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:c.default,onChange:m=>d(p,"default",m.target.value),disabled:s,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:p})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:o.jsx("input",{type:"checkbox",checked:!!c.required,onChange:m=>{i||d(p,"required",m.target.checked)},disabled:s||i,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:p})})}),o.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:o.jsx("input",{type:"checkbox",checked:c.showOnNode!==!1,onChange:m=>d(p,"showOnNode",m.target.checked),disabled:s,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:p})})}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>u(p),disabled:s,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:p}),title:a("flow:nodeProps.deletePin"),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${f}-${p}`))]}):null]})}function zT({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:s,disabled:i,onIdBlur:a,onClose:l,onPublishToMarketplace:u,allowEditRequiredPins:d=!1,error:f,ioSlots:c}){const{t:p}=Pn(),[m,g]=h.useState(!1),[b,k]=h.useState(!1),[y,v]=h.useState({status:"idle",message:""}),w=h.useCallback(M=>{t(W=>W&&{...W,...M})},[t]),{cursorList:j,opencodeList:P,claudeCodeList:_,currentNotInLists:L}=h.useMemo(()=>{const M=Array.isArray(s==null?void 0:s.cursor)?s.cursor:[],W=Array.isArray(s==null?void 0:s.opencode)?s.opencode:[],O=Array.isArray(s==null?void 0:s.claudeCode)?s.claudeCode:[],$=new Set([...M,...W,...O].map(Ih)),I=((e==null?void 0:e.model)??"").trim(),z=I.startsWith("cursor:")?I.slice(7):I.startsWith("opencode:")?I.slice(9):I.startsWith("claude-code:")?I.slice(12):I,C=I&&!$.has(z)?I:"";return{cursorList:M,opencodeList:W,claudeCodeList:O,currentNotInLists:C}},[s,e==null?void 0:e.model]);if(!e)return null;const B=String(e.script??""),D=n==="tool_nodejs"||B.trim()!=="",F=typeof u=="function"&&!i&&(e==null?void 0:e.newId),R=async()=>{if(F){v({status:"running",message:p("flow:nodeProps.publishRunning")});try{const M=await u(e,n);v({status:"success",message:M!=null&&M.definitionId?p("flow:nodeProps.publishSuccessWithId",{id:M.definitionId}):p("flow:nodeProps.publishSuccess")})}catch(M){v({status:"error",message:String((M==null?void 0:M.message)||M)})}}};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:p("flow:nodeProps.title")}),o.jsxs("div",{className:"af-node-props-head-actions",children:[o.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:R,disabled:!F||y.status==="running",title:p("flow:nodeProps.publishToMarketplaceHint"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),y.status==="running"?p("flow:nodeProps.publishing"):p("flow:nodeProps.publishToMarketplace")]}),o.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:p("common:common.close")})]})]}),o.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[f?o.jsx("p",{className:"af-err af-node-props-err",children:f}):null,y.message?o.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${y.status}`,children:y.message}):null,o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.nodeType")}),o.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:nodeProps.instanceId"),o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.displayNameHint")})]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:M=>w({newId:M.target.value}),onBlur:a,disabled:i,spellCheck:!1,autoComplete:"off","aria-label":p("flow:nodeProps.instanceId")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.displayName"),"(LABEL)"]}),o.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:M=>w({label:M.target.value}),disabled:i,spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.role"),"(ROLE)"]}),o.jsx("select",{className:"af-node-props-select",value:al.includes(e.role)?e.role:p("flow:roles.normal"),onChange:M=>w({role:M.target.value}),disabled:i,children:al.map(M=>o.jsx("option",{value:M,children:M},M))})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.model"),"(MODEL)"]}),o.jsx("span",{className:"af-node-props-sublabel",children:p("flow:node.modelHint")}),o.jsxs("select",{className:"af-node-props-select",value:(()=>{const M=(e.model||"").trim();return M?L||M:""})(),onChange:M=>w({model:M.target.value}),disabled:i,"aria-label":p("flow:nodeProps.modelAriaLabel"),children:[o.jsx("option",{value:"",children:p("flow:node.defaultModel")}),L?o.jsxs("option",{value:L,children:[L,p("flow:nodeProps.yamlValueNotInList")]}):null,j.length>0?o.jsx("optgroup",{label:"Cursor",children:j.map(M=>o.jsx("option",{value:Ih(M),children:M},`c-${M}`))}):null,P.length>0?o.jsx("optgroup",{label:"OpenCode",children:P.map(M=>o.jsx("option",{value:Ih(M),children:M},`o-${M}`))}):null,_.length>0?o.jsx("optgroup",{label:"Claude Code",children:_.map(M=>o.jsx("option",{value:`claude-code:${Ih(M)}`,children:M},`cc-${M}`))}):null]})]}),o.jsx(zj,{kind:"input",label:p("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:M=>w({inputs:M}),disabled:i,requiredReadonly:!d}),o.jsx(zj,{kind:"output",label:p("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:M=>w({outputs:M}),disabled:i,requiredReadonly:!d}),D?o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsxs("span",{className:"af-node-props-label",children:[p("flow:node.directCommand"),"(script)",o.jsx("span",{className:"af-node-props-hint",children:p("flow:node.scriptHint")})]}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>k(!0),"aria-label":p("flow:nodeProps.expandEditScript"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Ah,{value:B,onChange:M=>w({script:M}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:c,variant:"drawer"})]}):null,o.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[o.jsxs("div",{className:"af-node-props-prompt-head",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.userPrompt")}),o.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>g(!0),"aria-label":p("flow:nodeProps.expandEdit"),title:p("flow:nodeProps.expand"),disabled:i,children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Ah,{value:e.body,onChange:M=>w({body:M}),images:e.images,onImagesChange:M=>w({images:M}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:c,variant:"drawer"})]}),o.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[o.jsx("span",{className:"af-node-props-label",children:p("flow:node.systemDescription")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||p("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),b?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editScript"),onMouseDown:M=>{M.target===M.currentTarget&&k(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.directCommand")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>k(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(Ah,{value:B,onChange:M=>w({script:M}),disabled:i,placeholder:p("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:c,variant:"expand"})]})}):null,m?o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":p("flow:nodeProps.editUserPrompt"),onMouseDown:M=>{M.target===M.currentTarget&&g(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:p("flow:node.body")}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>g(!1),"aria-label":p("flow:nodeProps.collapse"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx(Ah,{value:e.body,onChange:M=>w({body:M}),images:e.images,onImagesChange:M=>w({images:M}),disabled:i,placeholder:p("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:c,variant:"expand"})]})}):null]})}function j0(e){var n;if(e.displayKind==="image"||e.encoding==="base64"&&((n=e.mimeType)!=null&&n.startsWith("image/")))return"image";if(e.displayKind==="json"||e.mimeType==="application/json")return"json";if(e.displayKind==="markdown"||e.mimeType==="text/markdown")return"markdown";if(e.displayKind==="text")return"text";const t=(e.content||"").trim();if(t&&(t.startsWith("{")||t.startsWith("[")))try{return JSON.parse(t),"json"}catch{}return"text"}function LK(e){const t=j0(e);if(t==="image"){const n=(e.mimeType||"image/png").split("/")[1];return n?n.toUpperCase():"IMAGE"}return t==="json"?"JSON":t==="markdown"?"MD":null}function BT(e){try{return JSON.stringify(JSON.parse(e.trim()),null,2)}catch{return e}}function Bj({text:e}){const{t}=Pn(),n=e||"";return n.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(pp,{children:n})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}function Hj({o:e}){var r;const{t}=Pn(),n=j0(e);if(n==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/"))){const i=`data:${e.mimeType||"image/png"};base64,${e.content||""}`;return o.jsxs("div",{className:"af-run-ctx-media",children:[o.jsx("img",{className:"af-run-ctx-img",src:i,alt:e.slot||"output",loading:"lazy"}),e.truncated?o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.imageTruncated")}):null]})}if(n==="json")return o.jsx("pre",{className:"af-run-ctx-pre",children:BT(e.content||"")});if(n==="markdown"){const s=e.content||"";return s.trim()?o.jsx("div",{className:"af-run-ctx-md",children:o.jsx(pp,{children:s})}):o.jsx("div",{className:"af-run-ctx-hint",children:t("flow:runContext.empty")})}return o.jsx("pre",{className:"af-run-ctx-pre",children:e.content!=null&&e.content!==""?e.content:t("flow:runContext.empty")})}function Wj(e){return LK(e)}function Vj(e){var r;if(!e)return null;const t=j0(e);if(t==="image"||e.encoding==="base64"&&((r=e.mimeType)!=null&&r.startsWith("image/")))return null;const n=e.content;return n==null||n===""?null:t==="json"?BT(String(n)):String(n)}function Uj({text:e,title:t,copiedLabel:n}){const[r,s]=h.useState(!1);if(!e)return null;const i=async()=>{try{await navigator.clipboard.writeText(e),s(!0),window.setTimeout(()=>s(!1),1400)}catch{}};return o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-copy-btn",onClick:i,title:r?n:t,"aria-label":r?n:t,children:o.jsx("span",{className:"material-symbols-outlined",children:r?"check":"content_copy"})})}const Kj=2e4,HT="af:run-node-ctx-width";function lm(){return typeof window>"u"?416:Math.min(26*16,window.innerWidth-32)}function Wa(e){const n=Math.max(280,Math.min(Math.floor(window.innerWidth*.92),1200));return Number.isFinite(e)?Math.min(Math.max(Math.round(e),200),n):Wa(lm())}function OK(){try{const e=localStorage.getItem(HT);if(e==null)return Wa(lm());const t=parseInt(e,10);return Number.isFinite(t)?Wa(t):Wa(lm())}catch{return Wa(lm())}}async function qj(e,t,n,r){const s=new URLSearchParams({flowId:e,instanceId:t});n&&String(n).trim()&&s.set("runId",String(n).trim());const i=await fetch(`/api/node-exec-context?${s.toString()}`,{signal:r}),a=await i.text();let l;try{l=JSON.parse(a)}catch{throw new Error(a.startsWith("<!")||a.startsWith("<html")?"apiConnectError":"invalidJson")}if(!i.ok)throw new Error(l.error||"HTTP "+i.status);return l}function MK(e,t){const n=`flow:runContext.${t}`,r=e(n);return r!==n?r:t}function $K({instanceId:e,flowId:t,runId:n,nodeStatus:r,onClose:s}){const{t:i}=Pn(),[a,l]=h.useState(()=>typeof window<"u"&&window.matchMedia("(max-width: 960px)").matches),[u,d]=h.useState(OK),f=h.useRef({active:!1,pointerId:-1,startX:0,startW:416}),[c,p]=h.useState(!0),[m,g]=h.useState(""),[b,k]=h.useState([]),[y,v]=h.useState(null),[w,j]=h.useState(null),P=h.useRef(null),_=h.useRef(null),L=h.useRef(0),B=h.useRef(0);h.useLayoutEffect(()=>{const C=window.matchMedia("(max-width: 960px)"),T=()=>l(C.matches);return C.addEventListener("change",T),()=>C.removeEventListener("change",T)},[]),h.useEffect(()=>{function C(){d(T=>Wa(T))}return window.addEventListener("resize",C),()=>window.removeEventListener("resize",C)},[]);const D=h.useCallback(()=>{d(C=>{const T=Wa(C);try{localStorage.setItem(HT,String(T))}catch{}return T})},[]),F=h.useCallback(C=>{if(a||C.button!==0)return;C.preventDefault();const T=C.currentTarget;f.current={active:!0,pointerId:C.pointerId,startX:C.clientX,startW:u},T.setPointerCapture(C.pointerId)},[a,u]),R=h.useCallback(C=>{const T=f.current;if(!T.active||C.pointerId!==T.pointerId)return;const E=T.startX-C.clientX;d(Wa(T.startW+E))},[]),M=h.useCallback(C=>{const T=f.current;if(!(!T.active||C.pointerId!==T.pointerId)){T.active=!1;try{C.currentTarget.releasePointerCapture(C.pointerId)}catch{}D()}},[D]),W=h.useCallback(()=>{const C=f.current;C.active&&(C.active=!1,D())},[D]),O=h.useCallback(C=>{const T=Array.isArray(C)?C:[];k(T),v(E=>E&&T.some(G=>G.execId===E)?E:T.length>0?T[T.length-1].execId:null)},[]),$=h.useCallback(()=>{if(!e||!t)return;const C=++L.current,T=new AbortController,E=window.setTimeout(()=>T.abort(),Kj);(async()=>{try{const G=await qj(t,e,n,T.signal);if(C!==L.current)return;O(Array.isArray(G.rounds)?G.rounds:[])}catch{}finally{window.clearTimeout(E)}})()},[e,t,n,O]);h.useEffect(()=>{if(!e||!t){p(!1),g(""),k([]);return}const C=++B.current;p(!0),g(""),k([]),v(null);const T=new AbortController,E=window.setTimeout(()=>T.abort(),Kj);return(async()=>{try{const G=await qj(t,e,n,T.signal);if(C!==B.current)return;O(Array.isArray(G.rounds)?G.rounds:[])}catch(G){if(C!==B.current)return;const Z=(G==null?void 0:G.name)==="AbortError"?"requestTimeout":G.message||String(G);g(Z)}finally{window.clearTimeout(E),C===B.current&&p(!1)}})(),()=>{T.abort(),B.current++,L.current++}},[e,t,n,O]),h.useEffect(()=>{r&&$()},[r,$]),h.useEffect(()=>{clearInterval(_.current);const C=b.length>0?b[b.length-1]:null;return(r==="running"&&b.length===0||!!(C&&C.status==="running"))&&e&&t&&(_.current=setInterval(()=>$(),2e3)),()=>clearInterval(_.current)},[b,e,t,n,r,$]),h.useEffect(()=>{P.current&&(P.current.scrollTop=0)},[y]);const I=b.find(C=>C.execId===y),z=a?void 0:{width:`${u}px`};return o.jsxs("aside",{className:"af-run-ctx-panel",style:z,"aria-label":i("flow:runContext.title"),children:[a?null:o.jsx("div",{className:"af-run-ctx-resize",role:"separator","aria-orientation":"vertical","aria-label":i("flow:runContext.resizeHandle"),onPointerDown:F,onPointerMove:R,onPointerUp:M,onPointerCancel:M,onLostPointerCapture:W}),o.jsxs("div",{className:"af-run-ctx-panel__main",children:[o.jsxs("div",{className:"af-run-ctx-head",children:[o.jsx("h2",{className:"af-run-ctx-title",title:e,children:e}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:s,"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),c&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("common:common.loading")}),m&&o.jsx("div",{className:"af-run-ctx-error",children:MK(i,m)}),!c&&!m&&b.length===0&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i(r==="running"?"flow:runContext.executingNoArtifacts":"flow:runContext.noData")}),b.length>0&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-run-ctx-rounds af-run-ctx-rounds--select af-run-ctx-round--"+FK((I==null?void 0:I.status)||""),children:[o.jsx("span",{className:"af-run-ctx-round-dot","aria-hidden":!0}),o.jsx("select",{className:"af-run-ctx-round-select",value:String(y??""),onChange:C=>{const T=C.target.value;v(T==="latest"?"latest":Number(T))},children:[...b].reverse().map(C=>{const T=C.execId==="latest"?i("flow:runContext.latest"):`#${C.execId}`,E=zK(i,C.status),G=C.finishedAt?` · ${DK(C.finishedAt)}`:"";return o.jsx("option",{value:String(C.execId),children:`${T} · ${E}${G}`},C.execId)})})]}),I&&o.jsxs("div",{className:"af-run-ctx-body",ref:P,children:[I.inputs&&I.inputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"input"}),"Inputs"]}),I.inputs.map((C,T)=>o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsx("div",{className:"af-run-ctx-slot-head",children:o.jsx("div",{className:"af-run-ctx-slot-name",children:C.slot})}),o.jsx("pre",{className:"af-run-ctx-slot-text",children:C.value})]},`${C.slot}-${T}`))]}),I.prompt!=null&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"description"}),"Prompt",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("prompt"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx(Bj,{text:I.prompt})]}),I.outputs&&I.outputs.length>0&&o.jsxs("section",{className:"af-run-ctx-section",children:[o.jsxs("h3",{className:"af-run-ctx-section-title",children:[o.jsx("span",{className:"material-symbols-outlined af-run-ctx-section-icon","aria-hidden":!0,children:"output"}),"Outputs",o.jsx("button",{type:"button",className:"af-icon-btn af-run-ctx-section-expand",onClick:()=>j("output"),title:i("flow:nodeProps.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),I.outputs.map((C,T)=>{const E=Wj(C),G=Vj(C);return o.jsxs("div",{className:"af-run-ctx-output-slot",children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:C.slot}),E?o.jsx("span",{className:"af-run-ctx-format-badge",title:i("flow:runContext.detectedContentType"),children:E}):null,o.jsx(Uj,{text:G,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(Hj,{o:C})]},`${C.slot}-${T}`)})]}),!I.prompt&&(!I.outputs||I.outputs.length===0)&&o.jsx("div",{className:"af-run-ctx-placeholder",children:i("flow:runContext.roundNoContent")})]})]})]}),w&&I&&o.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true",onClick:C=>{C.target===C.currentTarget&&j(null)},children:o.jsxs("div",{className:"af-node-props-expand-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head",children:[o.jsx("span",{className:"af-node-props-expand-title",children:w==="prompt"?"Prompt":"Outputs"}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>j(null),"aria-label":i("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-node-props-expand-body af-run-ctx-expand-body",children:[w==="prompt"&&I.prompt!=null&&o.jsx(Bj,{text:I.prompt}),w==="output"&&I.outputs&&I.outputs.map((C,T)=>{const E=Wj(C),G=Vj(C);return o.jsxs("div",{className:"af-run-ctx-output-slot",style:{marginBottom:"1rem"},children:[o.jsxs("div",{className:"af-run-ctx-slot-head",children:[o.jsx("div",{className:"af-run-ctx-slot-name",children:C.slot}),E?o.jsx("span",{className:"af-run-ctx-format-badge",children:E}):null,o.jsx(Uj,{text:G,title:i("common:common.copy"),copiedLabel:i("common:common.copied")})]}),o.jsx(Hj,{o:C})]},`${C.slot}-${T}`)})]})]})})]})}function DK(e){try{const t=new Date(e);if(isNaN(t.getTime()))return e;const n=r=>String(r).padStart(2,"0");return`${n(t.getMonth()+1)}-${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`}catch{return e}}function FK(e){const t=String(e||"").toLowerCase();return t==="success"||t==="completed"||t==="done"?"success":t==="failed"||t==="error"?"failed":t==="running"||t==="executing"?"running":t==="cache_not_met"?"cache":t?"unknown":"pending"}function zK(e,t){const n=String(t||"").toLowerCase();return n?n==="success"||n==="completed"||n==="done"?e("flow:runContext.statusSuccess",{defaultValue:"成功"}):n==="failed"||n==="error"?e("flow:runContext.statusFailed",{defaultValue:"失败"}):n==="running"||n==="executing"?e("flow:runContext.statusRunning",{defaultValue:"运行中"}):n==="cache_not_met"?e("flow:runContext.statusCacheMiss",{defaultValue:"缓存失效"}):t:e("flow:runContext.statusPending",{defaultValue:"等待"})}function BK({flowId:e,flowSource:t,flowArchived:n,provideNodes:r,edges:s,nodes:i,onCliInputsChange:a,onBackToEdit:l}){const{t:u}=Pn(),[d,f]=h.useState({}),[c,p]=h.useState(null),[m,g]=h.useState({}),[b,k]=h.useState(!0),[y,v]=h.useState(!1),[w,j]=h.useState(""),[P,_]=h.useState(!1),[L,B]=h.useState(null),D=h.useRef(null),F=h.useRef(!0),R=h.useRef({});h.useMemo(()=>{var E,G,Z;const T={};for(const V of r){const se=(Z=(G=(E=V.data)==null?void 0:E.outputs)==null?void 0:G[0])==null?void 0:Z.default;se!=null&&se!==""&&(T[V.id]=String(se))}return R.current=T,T},[r]);const M=h.useMemo(()=>{var E;const T={};for(const G of i){if(!((E=G.data)!=null&&E.inputs))continue;const Z=G.data.inputs;for(let V=0;V<Z.length;V++){const se=Z[V];if(!(se!=null&&se.name))continue;const de=s.find(pe=>pe.target===G.id&&pe.targetHandle===`input-${V}`);if(!(de!=null&&de.source))continue;r.find(pe=>pe.id===de.source)&&(T[de.source]=se.name)}}return T},[i,s,r]);h.useEffect(()=>(F.current=!0,()=>{F.current=!1}),[]),h.useEffect(()=>{if(!e){k(!1);return}k(!0);const T=new URLSearchParams({flowId:e,flowSource:t||"user"});n&&T.set("archived","1"),fetch(`/api/flow/run-config?${T.toString()}`).then(E=>{if(!E.ok)throw new Error(`HTTP ${E.status}`);return E.json()}).then(E=>{var Z;if(!F.current)return;f(E.presets||{}),p(E.activePreset||null);const G=E.activePreset&&((Z=E.presets)!=null&&Z[E.activePreset])?E.presets[E.activePreset]:{};g({...R.current,...G}),k(!1)}).catch(()=>{F.current&&(g(R.current),k(!1))})},[e,t,n]),h.useEffect(()=>{var E;if(!a)return;const T={};for(const[G,Z]of Object.entries(m)){const V=M[G];if(!V)continue;const se=r.find(fe=>fe.id===G);if(!se)continue;(((E=se.data)==null?void 0:E.definitionId)||"").startsWith("provide_file")?T[V]={type:"file",path:Z}:T[V]={type:"str",value:Z}}a(T)},[m,M,r,a]);const W=h.useCallback((T,E)=>{g(G=>({...G,[T]:E}))},[]),O=h.useCallback(T=>{T!==c&&(p(T),T&&d[T]?g({...R.current,...d[T]}):g(R.current))},[c,d]),$=h.useCallback(async()=>{if(w.trim()){v(!0);try{const T={...d,[w.trim()]:m},E={flowId:e,flowSource:t,archived:n,presets:T,activePreset:w.trim()};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(E)})).ok&&(f(T),p(w.trim()),j(""),_(!1))}finally{v(!1)}}},[e,t,n,d,m,w]),I=h.useCallback(async()=>{if(c){v(!0);try{const T={...d};delete T[c];const E=Object.keys(T)[0]||null;(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:T,activePreset:E})})).ok&&(f(T),p(E),E&&T[E]?g({...R.current,...T[E]}):g(R.current))}finally{v(!1)}}},[e,t,n,d,c]),z=h.useCallback(async()=>{if(c){v(!0);try{const T={...d,[c]:m};(await fetch("/api/flow/run-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:e,flowSource:t,archived:n,presets:T,activePreset:c})})).ok&&f(T)}finally{v(!1)}}},[e,t,n,d,c,m]),C=Object.keys(d);return C.length>0,b?o.jsx("aside",{className:"af-run-config-panel",children:o.jsx("div",{className:"af-run-config-loading",children:u("common.loading")})}):o.jsxs("aside",{className:"af-run-config-panel",children:[o.jsxs("div",{className:"af-run-config-preset",children:[o.jsx("label",{className:"af-run-config-preset-label",children:u("flow:runConfig.preset")}),o.jsxs("div",{className:"af-run-config-preset-row",children:[o.jsxs("select",{className:"af-run-config-preset-select",value:c||"",onChange:T=>O(T.target.value||null),disabled:y,children:[o.jsx("option",{value:"",children:u("flow:runConfig.default")}),C.map(T=>o.jsx("option",{value:T,children:T},T))]}),o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--new",onClick:()=>_(!0),disabled:y,title:u("flow:runConfig.newPreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),c&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--save",onClick:z,disabled:y,title:u("flow:runConfig.savePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"})}),c&&o.jsx("button",{type:"button",className:"af-run-config-preset-btn af-run-config-preset-btn--delete",onClick:I,disabled:y,title:u("flow:runConfig.deletePreset"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]})]}),P&&o.jsxs("div",{className:"af-run-config-save-dialog",children:[o.jsx("input",{type:"text",className:"af-run-config-save-input",placeholder:u("flow:runConfig.presetNamePlaceholder"),value:w,onChange:T=>j(T.target.value),disabled:y}),o.jsxs("div",{className:"af-run-config-save-actions",children:[o.jsx("button",{type:"button",className:"af-btn-primary",onClick:$,disabled:y||!w.trim(),children:u(y?"common.saving":"common.save")}),o.jsx("button",{type:"button",className:"af-btn-outline",onClick:()=>{_(!1),j("")},disabled:y,children:u("common.cancel")})]})]}),o.jsxs("div",{className:"af-run-config-inputs",children:[o.jsx("div",{className:"af-run-config-inputs-header",children:u("flow:runConfig.inputParams")}),r.length===0?o.jsx("div",{className:"af-run-config-empty",children:u("flow:runConfig.noProvideNodes")}):o.jsx("div",{className:"af-run-config-input-list",children:r.map(T=>{var pe,ae;const E=((pe=T.data)==null?void 0:pe.definitionId)||"",G=E.startsWith("provide_file"),Z=E==="provide_bool",V=((ae=T.data)==null?void 0:ae.label)||T.id,se=T.id,de=m[se]||"",fe=["true","1","yes","on"].includes(String(de).trim().toLowerCase());return o.jsxs("div",{className:"af-run-config-input-item",children:[o.jsxs("div",{className:"af-run-config-input-head",children:[o.jsx("span",{className:"af-run-config-input-icon material-symbols-outlined"+(G?" af-run-config-input-icon--file":""),"aria-hidden":!0,children:G?"description":Z?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-config-input-label",children:V}),Z?null:o.jsx("button",{type:"button",className:"af-run-config-input-expand",onClick:()=>B({instanceId:se,label:V,content:de}),"aria-label":u("flow:runConfig.expandInput"),title:u("flow:runConfig.expandInput"),children:o.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),o.jsx("div",{className:"af-run-config-input-id",children:se}),Z?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(fe?" af-run-config-bool-toggle--true":""),onClick:()=>W(se,fe?"false":"true"),"aria-pressed":fe,children:fe?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-config-input-field",value:de,onChange:be=>W(se,be.target.value),placeholder:u(G?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},se)})})]}),L&&Or.createPortal(o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:L.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>B(null),"aria-label":u("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:D,className:"af-provide-edit-modal__textarea",defaultValue:L.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:()=>{!L||!D.current||(W(L.instanceId,D.current.value),B(null))},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),u("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>B(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),u("flow:provideEdit.cancel")]})]})]})}),document.body)]})}const WT={ai:["planner-system","planner-user","planner-response","agent-step-prompt","repair-prompt","ai-thinking","ai-assistant","ai-result","ai-tool"],flow:["composer-start","classify","plan","phase-plan","phase-complete","phase-auto-continue","composer-done"],step:["step-start","step-progress","step-done","validation"],output:["natural","status"],error:["error"]},HK={"planner-system":"#9ecaff","planner-user":"#9ecaff","planner-response":"#7c4dff","agent-step-prompt":"#7c4dff","repair-prompt":"#ff6b6b","ai-thinking":"#a8b9d4","ai-assistant":"#e8deff","ai-result":"#00e475","ai-tool":"#9ecaff","composer-start":"#00e475","composer-done":"#00e475","step-start":"#e8deff","step-done":"#e8deff","step-progress":"#e8deff",natural:"#a8a8a8",status:"#a8a8a8",error:"#ff6b6b","phase-plan":"#00e475","phase-complete":"#00e475"};function WK(e){return!e||e<1024?`${e||0} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}function VK(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}:${t.getSeconds().toString().padStart(2,"0")}.${t.getMilliseconds().toString().padStart(3,"0")}`}function UK(e){if(!e)return"";const t=new Date(e);return isNaN(t.getTime())?e:`${t.getMonth()+1}/${t.getDate()} ${t.getHours().toString().padStart(2,"0")}:${t.getMinutes().toString().padStart(2,"0")}`}function Yj(e,t){if(e==="natural"&&t&&typeof t=="object"){const n=t.kind;if(n==="thinking"||n==="assistant"||n==="result"||n==="tool")return"ai";if(n==="error")return"error"}for(const[n,r]of Object.entries(WT))if(r.includes(e))return n;return"other"}function KK({event:e,defaultExpanded:t}){const[n,r]=h.useState(!!t),s=HK[e.tag]||"#a8a8a8",i=e.payload,a=i&&typeof i=="object",l=a?typeof i.text=="string"?i.text:"":String(i||""),u=a?i.meta:null,d=h.useMemo(()=>l?l.slice(0,140).replace(/\s+/g," "):a?Object.keys(i).filter(m=>m!=="text"&&m!=="meta").slice(0,3).map(m=>{const g=i[m];return g==null?`${m}:null`:typeof g=="object"?`${m}:{…}`:`${m}:${String(g).slice(0,30)}`}).join(" "):"",[i,l,a]),f=h.useCallback(c=>{c.stopPropagation();const p=a?JSON.stringify(i,null,2):String(i);try{navigator.clipboard.writeText(p)}catch{}},[i,a]);return o.jsxs("div",{style:{borderLeft:`3px solid ${s}`,background:n?"#1c1b1b":"#131313",marginBottom:4,borderRadius:4,cursor:"pointer",transition:"background 120ms"},onClick:()=>r(c=>!c),children:[o.jsxs("div",{style:{padding:"6px 10px",display:"flex",alignItems:"center",gap:10,fontSize:12},children:[o.jsx("span",{style:{color:"#9a9a9a",fontFamily:"monospace",flexShrink:0},children:VK(e.ts)}),o.jsx("span",{style:{color:s,fontWeight:600,fontFamily:"monospace",flexShrink:0,padding:"1px 6px",background:"rgba(255,255,255,0.04)",borderRadius:3},children:e.tag}),o.jsx("span",{style:{color:"#c5c2c1",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontFamily:"monospace"},children:d}),n&&o.jsx("button",{type:"button",onClick:f,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:3,padding:"2px 8px",fontSize:11,cursor:"pointer"},children:"Copy"})]}),n&&o.jsxs("div",{style:{padding:"0 10px 10px 10px",borderTop:"1px solid rgba(255,255,255,0.04)"},children:[u&&Object.keys(u).length>0&&o.jsx("div",{style:{marginTop:8,padding:8,background:"#0e0e0e",borderRadius:4,fontSize:11,fontFamily:"monospace",color:"#9ecaff",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(u,null,2)}),l?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-word",maxHeight:600,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:l}):a?o.jsx("pre",{style:{marginTop:8,padding:10,background:"#0e0e0e",borderRadius:4,fontSize:12,color:"#e5e2e1",whiteSpace:"pre-wrap",wordBreak:"break-all",maxHeight:400,overflowY:"auto",margin:"8px 0 0 0",fontFamily:"ui-monospace, SF Mono, Menlo, monospace"},children:JSON.stringify(i,null,2)}):null]})]})}function qK({open:e,onClose:t,flowId:n}){var B;const[r,s]=h.useState([]),[i,a]=h.useState(!1),[l,u]=h.useState(null),[d,f]=h.useState(null),[c,p]=h.useState(!1),[m,g]=h.useState(!0),[b,k]=h.useState({ai:!0,flow:!0,step:!0,output:!0,error:!0}),[y,v]=h.useState(""),w=h.useRef(null),j=h.useCallback(async()=>{a(!0);try{const D=m&&n?`?flowId=${encodeURIComponent(n)}`:"",R=await(await fetch(`/api/composer-logs${D}`)).json();s(Array.isArray(R.sessions)?R.sessions:[])}catch{s([])}finally{a(!1)}},[n,m]),P=h.useCallback(async D=>{if(!D){f(null);return}p(!0);try{const R=await(await fetch(`/api/composer-logs/${encodeURIComponent(D)}`)).json();f(R)}catch{f(null)}finally{p(!1)}},[]);h.useEffect(()=>{e&&j()},[e,j]),h.useEffect(()=>{if(!(!e||!l))return P(l),w.current=setInterval(()=>P(l),2e3),()=>{w.current&&clearInterval(w.current),w.current=null}},[e,l,P]);const _=h.useMemo(()=>{const D=(d==null?void 0:d.events)||[],F=y.trim().toLowerCase();return D.filter(R=>{const M=Yj(R.tag,R.payload);return!b[M]&&M!=="other"?!1:F?[R.tag,JSON.stringify(R.payload||"")].join(" ").toLowerCase().includes(F):!0})},[d,b,y]),L=h.useMemo(()=>{const D=(d==null?void 0:d.events)||[],F={};for(const R of D){const M=Yj(R.tag,R.payload);F[M]=(F[M]||0)+1}return F},[d]);return e?o.jsxs("div",{style:{position:"fixed",top:0,right:0,bottom:0,width:"min(1100px, 80vw)",background:"#131313",borderLeft:"1px solid rgba(255,255,255,0.08)",display:"flex",flexDirection:"column",zIndex:9999,boxShadow:"-8px 0 32px rgba(0,0,0,0.5)",color:"#e5e2e1",fontFamily:"Inter, system-ui, sans-serif"},children:[o.jsxs("div",{style:{padding:"12px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:12,flexShrink:0,background:"#1c1b1b"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:14},children:"Composer Logs"}),o.jsx("span",{style:{fontSize:11,color:"#9a9a9a"},children:n?`flowId: ${n}`:"no flow selected"}),o.jsxs("label",{style:{fontSize:11,color:"#9a9a9a",display:"flex",alignItems:"center",gap:4,cursor:"pointer"},children:[o.jsx("input",{type:"checkbox",checked:m,onChange:D=>g(D.target.checked),disabled:!n}),"仅显示当前 flow"]}),o.jsx("button",{type:"button",onClick:j,style:{background:"rgba(124,77,255,0.15)",color:"#e8deff",border:"none",borderRadius:4,padding:"4px 10px",fontSize:12,cursor:"pointer"},children:"Refresh"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{type:"button",onClick:t,style:{background:"transparent",color:"#e5e2e1",border:"1px solid rgba(255,255,255,0.12)",borderRadius:4,padding:"4px 12px",fontSize:12,cursor:"pointer"},children:"Close"})]}),o.jsxs("div",{style:{flex:1,display:"flex",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{width:280,borderRight:"1px solid rgba(255,255,255,0.06)",overflowY:"auto",background:"#0e0e0e",flexShrink:0},children:[i&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:"Loading…"}),!i&&r.length===0&&o.jsx("div",{style:{padding:12,fontSize:12,color:"#9a9a9a"},children:m&&n?"no sessions for this flow":"no sessions"}),r.map(D=>{const F=l===D.sessionId;return o.jsxs("div",{onClick:()=>u(D.sessionId),style:{padding:"10px 12px",borderBottom:"1px solid rgba(255,255,255,0.04)",cursor:"pointer",background:F?"rgba(124,77,255,0.18)":"transparent",borderLeft:F?"3px solid #7c4dff":"3px solid transparent"},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"#e5e2e1"},children:UK(D.mtime)}),o.jsx("div",{style:{fontSize:11,color:"#9ecaff",marginTop:2,fontFamily:"monospace"},children:D.flowId||"(no flow)"}),D.promptPreview&&o.jsx("div",{style:{fontSize:11,color:"#9a9a9a",marginTop:4,overflow:"hidden",textOverflow:"ellipsis",display:"-webkit-box",WebkitLineClamp:2,WebkitBoxOrient:"vertical"},children:D.promptPreview}),o.jsxs("div",{style:{fontSize:10,color:"#6a6a6a",marginTop:4},children:[WK(D.size)," · ",D.model||"default"]})]},D.sessionId)})]}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",overflow:"hidden",minHeight:0},children:[o.jsxs("div",{style:{padding:"10px 16px",borderBottom:"1px solid rgba(255,255,255,0.06)",display:"flex",alignItems:"center",gap:8,flexWrap:"wrap",flexShrink:0,background:"#1c1b1b"},children:[Object.keys(WT).map(D=>o.jsxs("button",{type:"button",onClick:()=>k(F=>({...F,[D]:!F[D]})),style:{background:b[D]?"rgba(124,77,255,0.25)":"transparent",color:b[D]?"#e8deff":"#6a6a6a",border:`1px solid ${b[D]?"rgba(124,77,255,0.4)":"rgba(255,255,255,0.08)"}`,borderRadius:999,padding:"3px 12px",fontSize:11,cursor:"pointer",fontFamily:"monospace",textTransform:"uppercase"},children:[D," ",L[D]!=null?`(${L[D]})`:""]},D)),o.jsx("input",{type:"text",placeholder:"search…",value:y,onChange:D=>v(D.target.value),style:{marginLeft:8,flex:1,minWidth:120,background:"#0e0e0e",border:"1px solid rgba(255,255,255,0.08)",borderRadius:4,color:"#e5e2e1",padding:"4px 8px",fontSize:12}})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:12,minHeight:0},children:[!l&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20,textAlign:"center"},children:"Select a session on the left to view events"}),c&&!d&&o.jsx("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:"Loading…"}),d&&_.length===0&&o.jsxs("div",{style:{color:"#9a9a9a",fontSize:12,padding:20},children:["No events match current filter (",((B=d.events)==null?void 0:B.length)||0," total)"]}),_.map((D,F)=>o.jsx(KK,{event:D,defaultExpanded:D.tag==="error"},`${D.ts}_${F}`))]})]})]})]}):null}const YK="0.1.61";function Gj(e){const t=Math.max(0,Number(e)||0),n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4),s=Math.floor(t%6e4/1e3);return`${String(n).padStart(2,"0")}:${String(r).padStart(2,"0")}:${String(s).padStart(2,"0")}`}function Px(e,t){return t==="running"?Gj(e):e==null||!Number.isFinite(e)||e<=0?"--":Gj(e)}const VT=h.createContext({modelLists:{cursor:[],opencode:[]},onModelChange:()=>{}});function GK(e){var v,w,j,P,_,L,B,D,F,R,M;const{setNodes:t}=fc(),n=n0(),{modelLists:r,onModelChange:s}=h.useContext(VT),i=h.useRef(null),a=!!((v=e.data)!=null&&v.readOnly),l=(w=e.data)!=null&&w.displaySize&&Number(e.data.displaySize.width)>0&&Number(e.data.displaySize.height)>0?{width:Number(e.data.displaySize.width),height:Number(e.data.displaySize.height)}:null,u=((j=e.data)==null?void 0:j.definitionId)==="agent_subAgent"&&!((P=e.data)!=null&&P.isRunMode)&&!a,d=h.useCallback(W=>{const O=()=>n(W);window.requestAnimationFrame(O),window.setTimeout(O,80)},[n]),f=h.useCallback((W,O)=>{const $=r1(O);$&&(t(I=>I.map(z=>{var E,G,Z,V,se,de;if(z.id!==W)return z;const C=Number(((G=(E=z.data)==null?void 0:E.displaySize)==null?void 0:G.width)||z.width||((Z=z.measured)==null?void 0:Z.width)||0),T=Number(((se=(V=z.data)==null?void 0:V.displaySize)==null?void 0:se.height)||z.height||((de=z.measured)==null?void 0:de.height)||0);return Math.abs(C-$.width)<2&&Math.abs(T-$.height)<2?z:{...z,width:$.width,height:$.height,data:{...z.data,displaySize:$}}})),d(W))},[d,t]),c=h.useCallback(W=>{if(a)return;const O=i.current;if(!O)return;const $=O.getBoundingClientRect();f(W,{width:Math.max($.width,O.scrollWidth),height:Math.max($.height,O.scrollHeight)})},[f,a]),p=h.useCallback(W=>{var se,de,fe,pe,ae,be;if(!u)return;W.preventDefault(),W.stopPropagation();const O=i.current,$=O==null?void 0:O.getBoundingClientRect(),I=Number(((de=(se=e.data)==null?void 0:se.displaySize)==null?void 0:de.width)||e.width||((fe=e.measured)==null?void 0:fe.width)||($==null?void 0:$.width)||YT),z=Number(((ae=(pe=e.data)==null?void 0:pe.displaySize)==null?void 0:ae.height)||e.height||((be=e.measured)==null?void 0:be.height)||($==null?void 0:$.height)||Pb),C=W.clientX,T=W.clientY,E=e.id;let G=0;const Z=_e=>{const we=r1({width:I+_e.clientX-C,height:z+_e.clientY-T});we&&(window.cancelAnimationFrame(G),G=window.requestAnimationFrame(()=>f(E,we)))},V=()=>{window.cancelAnimationFrame(G),window.removeEventListener("pointermove",Z),window.removeEventListener("pointerup",V),window.removeEventListener("pointercancel",V),d(E)};window.addEventListener("pointermove",Z),window.addEventListener("pointerup",V,{once:!0}),window.addEventListener("pointercancel",V,{once:!0})},[f,(L=(_=e.data)==null?void 0:_.displaySize)==null?void 0:L.height,(D=(B=e.data)==null?void 0:B.displaySize)==null?void 0:D.width,e.height,e.id,(F=e.measured)==null?void 0:F.height,(R=e.measured)==null?void 0:R.width,e.width,d,u]),m=h.useCallback(W=>{t(O=>O.filter($=>$.id!==W))},[t]),g=h.useCallback(()=>{var I,z,C,T,E,G,Z,V;const W=((I=e.data)==null?void 0:I.definitionId)||"",O=((z=e.data)==null?void 0:z.label)||e.id,$=((E=(T=(C=e.data)==null?void 0:C.outputs)==null?void 0:T[0])==null?void 0:E.value)||((V=(Z=(G=e.data)==null?void 0:G.outputs)==null?void 0:Z[0])==null?void 0:V.default)||"";window.__provideEditContent={instanceId:e.id,label:O,definitionId:W,content:$},window.dispatchEvent(new CustomEvent("provide-expand"))},[e.id,e.data]),b=h.useCallback((W,O)=>{t($=>$.map(I=>{var C;if(I.id!==W)return I;const z=Array.isArray((C=I.data)==null?void 0:C.outputs)&&I.data.outputs.length?I.data.outputs.map((T,E)=>E===0?{...T,default:O,value:O}:T):[{type:"bool",name:"value",default:O,value:O}];return{...I,data:{...I.data,body:"",outputs:z}}}))},[t]),k=h.useCallback((W,O)=>{t($=>$.map(I=>I.id===W?{...I,data:{...I.data,body:O}}:I))},[t]),y=h.useCallback((W,O)=>{t($=>$.map(I=>I.id===W?{...I,data:{...I.data,images:Ps(O)}}:I))},[t]);return o.jsxs("div",{ref:i,className:"af-flow-node-shell"+(u?" af-flow-node-shell--resizable":""),style:l?{width:l.width,height:l.height}:void 0,children:[o.jsx(AT,{...e,data:{...e.data,onNodeContentResize:c},deleteNode:m,onProvideExpand:g,onProvideValueChange:b,onNodeBodyChange:k,onNodeImagesChange:y,modelLists:r,onModelChange:s}),u?o.jsx("span",{className:"af-flow-node-shell__resize-grip nodrag","aria-label":((M=e.data)==null?void 0:M.resizeLabel)||"Resize node",role:"separator",onPointerDown:p}):null]})}const XK={[mp]:GK},Wd=["CONTROL","TOOL","PROVIDE","AGENT"],JK=1200,Xj="af-flow-node--sync-flash",Jj="af-flow-edge--sync-flash";function Qj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).includes(t)?n:`${n} ${t}`:t}function Zj(e,t){const n=String(e||"").trim();return n?n.split(/\s+/).filter(r=>r&&r!==t).join(" "):""}function C0(e){const t=((e==null?void 0:e.id)??"").trim();return/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function QK(e){const t=C0(e);return t==="CONTROL"?"control":t==="PROVIDE"?"provide":t==="TOOL"?"tool":"agent"}function Th(e){return(Array.isArray(e)?e:[]).map(n=>{const r=String((n==null?void 0:n.name)||(n==null?void 0:n.id)||"").trim(),s=String((n==null?void 0:n.type)||"").trim();return!r&&!s?"":s?`${r||"-"}: ${s}`:r}).filter(Boolean)}function UT(e){return String((e==null?void 0:e.label)||"").trim()||String((e==null?void 0:e.id)||"").trim()}function KT(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Ax(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 e1(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(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function t1(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 ZK(e){return e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function e7(e,t){return t?[e==null?void 0:e.id,e==null?void 0:e.label,e==null?void 0:e.description].filter(Boolean).some(r=>String(r).toLowerCase().includes(t)):!0}function qT(e,t,n,r,s){const i=QK(e),a={id:t,type:mp,position:n,data:{label:e.label??e.id,definitionId:e.id,schemaType:i,inputs:Array.isArray(e.inputs)?e.inputs.map(l=>({...l})):[],outputs:Array.isArray(e.outputs)?e.outputs.map(l=>({...l})):[]}};return qf(a,r,s)}const YT=320,t7=220,n7=1600,Pb=104,r7=900;function n1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function r1(e){if(!e||typeof e!="object")return null;const t=Number(e.width),n=Number(e.height);return!Number.isFinite(t)||!Number.isFinite(n)||t<=0||n<=0?null:{width:n1(t,t7,n7)||YT,height:n1(n,Pb,r7)||Pb}}function s7(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,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 s1(e,t){const n=String((e==null?void 0:e.source)||""),r=String((e==null?void 0:e.target)||"");if(!n||!r)return!1;const s=new Map(t.map(d=>[d.id,d])),i=s.get(n),a=s.get(r),l=Ou(i,e.sourceHandle||"output-0","source"),u=Ou(a,e.targetHandle||"input-0","target");return!l||!u?!1:Lu(l,u)}function i7(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 i=t.find(l=>l.id===n),a=Ou(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:PT(a)}:null}function o7(e,t,n){var a;const r=qT(e,`__candidate_${e.id}`,{x:0,y:0},{},t),s=n.handleType==="source"?"inputs":"outputs",i=Array.isArray((a=r.data)==null?void 0:a[s])?r.data[s]:[];for(let l=0;l<i.length;l+=1){const u=i[l];if(n.handleType==="source"?Lu(n.slot,u):Lu(u,n.slot))return{slot:u,slotIndex:l,hydrated:r}}return null}function a7(e,t){return t?e.map((n,r)=>{const s=o7(n,e,t);if(!s)return null;const i=C0(n);return{def:n,order:r,category:i,categoryRank:Wd.indexOf(i),slot:s.slot,slotIndex:s.slotIndex,displayLabel:UT(s.hydrated.data||n),description:KT(n)}}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}const l7=/@([a-zA-Z_][a-zA-Z0-9_]*)/g;function c7(e){const t=new Set,n=[];let r;const s=new RegExp(l7.source,"g");for(;(r=s.exec(e))!==null;){const i=r[1];t.has(i)||(t.add(i),n.push(i))}return n}function i1(e,t){const n=e.slice(0,t),r=n.lastIndexOf("@");if(r<0)return null;const s=n.slice(r+1);return/[\s\n]/.test(s)?null:{atIndex:r,query:s}}function Qo(e){const t=String(e||"").indexOf(" - ");return t>=0?e.slice(0,t).trim():String(e||"").trim()}function Rh(e,t,n,r){const s=(e||"").trim();if(!s)return"";if(s.startsWith("opencode:")||s.startsWith("claude-code:"))return s;const i=Array.isArray(t)?t:[],a=Array.isArray(n)?n:[],l=Array.isArray(r)?r:[],u=i.map(Qo),d=a.map(Qo);return l.map(Qo).includes(s)&&!u.includes(s)&&!d.includes(s)?`claude-code:${s}`:d.includes(s)&&!u.includes(s)?`opencode:${s}`:s}function u7(e){if(e==null)return"";const t=String(e).trim();return t?t.length<=26?t:`${t.slice(0,12)}…${t.slice(-10)}`:""}function Ix(e){if(!Array.isArray(e)||e.length===0)return 0;let t=0;for(const n of e){const r=/^(?:对话|Conversation|Chat)\s*(\d+)\s*$/.exec(String((n==null?void 0:n.label)??"").trim());r&&(t=Math.max(t,parseInt(r[1],10)))}return t}function d7({steps:e}){const{t}=Pn();return!e||e.length===0?null:o.jsx("div",{className:"af-composer-steps-track",role:"list","aria-label":t("flow:composer.stepsAriaLabel"),children:e.map(n=>{const r=String(n.description||n.type||"").trim(),s=n.model||n.executorModel,i=[`${n.index+1}. ${r||"—"}`,n.nodeRole?t("flow:composer.stepRoleLabel",{role:n.nodeRole}):"",n.instanceId?t("flow:composer.stepInstanceLabel",{instanceId:n.instanceId}):"",s?`${t("flow:palette.model")}:${s}`:""].filter(Boolean).join(`
129
- `),a=n.status||"pending";return o.jsxs("div",{className:"af-composer-step-chip"+(a==="done"?" af-composer-step-chip--done":"")+(a==="running"?" af-composer-step-chip--running":"")+(a==="error"?" af-composer-step-chip--error":"")+(a==="pending"?" af-composer-step-chip--pending":""),role:"listitem",title:i,children:[o.jsx("span",{className:"af-composer-step-chip-idx",children:n.index+1}),o.jsx("span",{className:"af-composer-step-chip-main",children:n.nodeRole||s?o.jsxs("span",{className:"af-composer-step-chip-meta",children:[n.nodeRole?o.jsx("span",{className:"af-composer-step-chip-role",children:n.nodeRole}):null,s?o.jsx("span",{className:"af-composer-step-chip-model",children:u7(s)}):null]}):null})]},n.index)})})}function f7(e,t){const n=e.trim(),r=t.trim();return r?n?!!(n===r||n.endsWith(r)||r.length>=8&&n.includes(r)):!1:!0}function p7(e){const t=[];for(const n of e){if(!n||typeof n.text!="string"||!n.text.trim())continue;const s=typeof n.kind=="string"&&n.kind?n.kind:"assistant",i=t[t.length-1];i&&i.kind===s?i.text+=s==="error"||s==="result"?`
130
- ${n.text}`:n.text:t.push({kind:s,text:n.text})}return t}function h7(e,t){return e==="thinking"?t("flow:composer.thinking"):e==="result"?t("flow:composer.result"):e==="assistant"?t("flow:composer.reply"):e==="error"?t("flow:composer.error"):String(e)}function m7(e){return e==="thinking"?"af-composer-ai-block af-composer-ai-block--thinking":e==="result"?"af-composer-ai-block af-composer-ai-block--result":e==="assistant"?"af-composer-ai-block af-composer-ai-block--reply":e==="error"?"af-composer-ai-block af-composer-ai-block--error":"af-composer-ai-block af-composer-ai-block--reply"}function o1({thread:e,liveSegments:t,running:n,className:r="",autoScroll:s=!0}){const{t:i}=Pn(),a=h.useRef(null),l=["af-composer-ai-stack","af-composer-ai-stack--in-panel","af-composer-thread-stack",r].filter(Boolean).join(" ");return h.useEffect(()=>{if(!s||!a.current)return;const u=a.current;requestAnimationFrame(()=>{u.scrollTop=u.scrollHeight})},[e,t,s]),o.jsxs("div",{ref:a,className:l,children:[e.map((u,d)=>u.type==="user"?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--user-msg",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:i("flow:composer.yourQuestion")}),o.jsx("div",{className:"af-composer-ai-block-body",children:u.text})]},`composer-u-${d}-${u.text.slice(0,48)}`):o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(a1,{segments:u.segments,running:!1})},`composer-a-${d}`)),o.jsx("div",{className:"af-composer-thread-assistant",children:o.jsx(a1,{segments:t,running:n})})]})}function a1({segments:e,running:t=!1}){const{t:n}=Pn(),r=e.filter(c=>c.kind==="assistant").map(c=>c.text).join(""),s=e.filter(c=>c.kind==="result").map(c=>c.text).join(""),i=f7(r,s),a=e.filter(c=>c.kind==="error").map(c=>c.text).join(`
131
- `),l=e.filter(c=>c.kind!=="error"),u=i?l.filter(c=>c.kind!=="result"):l,d=p7(u),f=!!(d.length>0||a);return o.jsxs(o.Fragment,{children:[d.map((c,p)=>o.jsxs("section",{className:m7(c.kind),children:[o.jsx("div",{className:"af-composer-ai-block-label",children:h7(c.kind,n)}),o.jsx("div",{className:"af-composer-ai-block-body",children:c.text})]},`${c.kind}-${p}`)),t&&!f?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.reply")}),o.jsx("div",{className:"af-composer-ai-block-body",children:n("flow:composer.waiting")})]}):null,a?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--error",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:n("flow:composer.error")}),o.jsx("div",{className:"af-composer-ai-block-body",children:a})]}):null]})}function g7({fitViewEpoch:e}){const{fitView:t}=fc(),n=h.useRef(t);return n.current=t,h.useEffect(()=>{if(e>0){const r=requestAnimationFrame(()=>n.current({padding:.2,duration:200,maxZoom:1}));return()=>cancelAnimationFrame(r)}},[e]),null}function y7({onReady:e}){const t=n0();return h.useEffect(()=>(e(t),()=>e(null)),[e,t]),null}function l1(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}function c1(e){if(!e||typeof e!="object")return null;const t=Number(e.x),n=Number(e.y),r=Number(e.zoom);return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)?null:{x:t,y:n,zoom:Math.min(Math.max(r,.1),4)}}const cm=1500,u1=500,x7=262144,w7=2e3;function Tx(e){return typeof e!="string"?"":e.length<=w7?e:`[log line truncated, ${e.length} chars]`}const b7=cm;function v7(e){const t=e.match(/^\[([^\]]+)\]\s+\[([^\]]+)\]\s+([\s\S]*)$/);if(!t)return null;const[,n,r,s]=t;if(r==="cli")try{const i=JSON.parse(s);return i&&i.event==="node-start"?{ts:n,type:"node-start",text:`节点 ${i.instanceId||""}${i.label?` · ${i.label}`:""} 开始`}:i&&i.event==="node-done"?{ts:n,type:"node-done",text:`节点 ${i.instanceId||""} 完成${i.elapsed?` (${i.elapsed})`:""}`}:i&&i.event==="node-failed"?{ts:n,type:"node-failed",text:`节点 ${i.instanceId||""} 失败${i.error?`: ${i.error}`:""}`}:i&&i.event==="apply-start"?{ts:n,type:"info",text:`[apply-start] uuid=${i.uuid||""}`}:{ts:n,type:"info",text:Tx(s)}}catch{return{ts:n,type:"info",text:Tx(s)}}return{ts:n,type:"log",text:Tx(`[${r}] ${s}`)}}function d1(e){if(!e)return[];const t=[],n=e.split(`
132
- `);for(let r=n.length-1;r>=0&&t.length<b7;r--){const s=n[r];if(!s)continue;const i=v7(s);i&&t.push(i)}return t.reverse(),t}function k7(e,t){if(e===t)return!0;if(!e||!t)return!1;const n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(const s of n){const i=e[s],a=t[s];if(!a)return!1;if(i!==a&&(i.status!==a.status||(i.elapsed??null)!==(a.elapsed??null)))return!1}return!0}function S7(e,t){if(e===t)return!0;if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function N7({fitViewEpoch:e,canvasTool:t,nodes:n,edges:r,onNodesChange:s,onEdgesChange:i,onConnect:a,onConnectStart:l,onConnectEnd:u,isValidConnection:d,onNodesDelete:f,onNodeClick:c,onNodeDoubleClick:p,onEdgeClick:m,onFlowInit:g,onDrop:b,onDragOver:k,hideMinimapAndControls:y,bottomSlot:v}){const{t:w}=Pn(),j=!s,P=j||t==="pan"?!0:[1,2],_=j?!1:t==="select",L="af-flow-canvas"+(j?" af-flow-canvas--run-mode":"")+(t==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select"),B=h.useCallback(()=>{},[]),D=h.useMemo(()=>{const F=new Map(n.map($=>[$.id,$])),R=new Set(n.filter($=>$.selected).map($=>$.id)),M=R.size>0,W=($,I)=>{const z=/^#([0-9a-f]{6})$/i.exec($);if(!z)return $;const C=parseInt(z[1],16);return`rgba(${C>>16&255}, ${C>>8&255}, ${C&255}, ${I})`},O="#ff5169";return r.map($=>{var we,Oe,Ie,et;const I=F.get($.source),z=F.get($.target),C=/^output-(\d+)$/.exec($.sourceHandle||""),T=/^input-(\d+)$/.exec($.targetHandle||""),E=I&&C?(Oe=(we=I.data)==null?void 0:we.outputs)==null?void 0:Oe[parseInt(C[1],10)]:null,G=z&&T?(et=(Ie=z.data)==null?void 0:Ie.inputs)==null?void 0:et[parseInt(T[1],10)]:null,Z=E!=null&&E.type?nr(E.type):null,V=G!=null&&G.type?nr(G.type):null,se=Z&&V&&Z!==V,de=M&&(R.has($.source)||R.has($.target)),fe=$.style||{};if(se){const ft=$.selected?.95:de?.85:.78,Je=W(O,ft);return{...$,className:(($.className||"")+" af-flow-edge--type-mismatch"+(de?" af-flow-edge--adjacent":"")).trim(),style:{...fe,stroke:Je,strokeWidth:de?2.75:2.5,strokeDasharray:"6 4"},markerEnd:$.markerEnd&&typeof $.markerEnd=="object"?{...$.markerEnd,color:Je}:{type:Ls.ArrowClosed,color:Je}}}const pe=Z||V;if(!pe)return de?{...$,className:(($.className||"")+" af-flow-edge--adjacent").trim(),style:{...fe,strokeWidth:2.5}}:$;const ae=de||$.selected?.7:.38,be=W(pe,ae),_e=de?2.5:fe.strokeWidth??2;return{...$,className:(($.className||"")+(de?" af-flow-edge--adjacent":"")).trim(),style:{...fe,stroke:be,strokeWidth:_e},markerEnd:$.markerEnd&&typeof $.markerEnd=="object"?{...$.markerEnd,color:be}:{type:Ls.ArrowClosed,color:be}}})},[n,r]);return o.jsxs(t0,{className:L,nodes:n,edges:D,onNodesChange:s||B,onEdgesChange:i||B,onConnect:j?void 0:a,onConnectStart:j?void 0:l,onConnectEnd:j?void 0:u,isValidConnection:j?void 0:d,onNodesDelete:j?void 0:f,onNodeClick:c,onNodeDoubleClick:j?void 0:p,onEdgeClick:j?void 0:m,onInit:g,onDrop:j?void 0:b,onDragOver:j?void 0:k,nodeTypes:XK,selectionOnDrag:_,panOnDrag:P,nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j,edgesFocusable:!j,panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,defaultEdgeOptions:{style:{stroke:"rgba(205, 189, 255, 0.45)",strokeWidth:2}},connectionLineStyle:{stroke:"rgba(205, 189, 255, 0.65)",strokeWidth:2},children:[o.jsx(r0,{gap:20,size:1,color:"rgba(28, 27, 27, 0.9)"}),o.jsx(Tu,{position:"bottom-center",className:"af-flow-bottom-unified-panel"+(y?" af-flow-bottom-unified-panel--solo":""),children:o.jsxs("div",{className:"af-flow-bottom-unified-row"+(y?" af-flow-bottom-unified-row--solo":""),children:[y?null:o.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--minimap",children:o.jsx(IB,{zoomable:!0,pannable:!0,position:"bottom-left",className:"af-flow-bottom-minimap",style:{width:152,height:104},maskColor:"rgba(14, 14, 14, 0.85)",nodeColor:F=>{var M;const R=(((M=F.data)==null?void 0:M.schemaType)??"agent").toLowerCase();return R==="control"?"rgba(237, 108, 2, 0.85)":R==="provide"?"rgba(0, 228, 117, 0.35)":R==="tool"?"rgba(124, 77, 255, 0.75)":"rgba(158, 202, 255, 0.5)"}})}),o.jsx("div",{className:"af-flow-bottom-unified__center",children:v}),y?null:o.jsx("div",{className:"af-flow-bottom-unified__side af-flow-bottom-unified__side--zoom",children:o.jsx(xB,{position:"bottom-right",showInteractive:!1,className:"af-flow-bottom-controls"})})]})}),!y&&o.jsx(Tu,{position:"bottom-left",className:"af-pin-legend",children:[{type:"node",color:"#ff9800"},{type:"text",color:"#2196f3"},{type:"file",color:"#4caf50"},{type:"bool",color:"#9c27b0"}].map(({type:F,color:R})=>o.jsxs("span",{className:"af-pin-legend__item",children:[o.jsx("span",{className:"af-pin-legend__dot",style:{background:R}}),o.jsx("span",{className:"af-pin-legend__label",children:F})]},F))}),o.jsx(g7,{fitViewEpoch:e}),!j&&n.length===0?o.jsxs("div",{className:"af-flow-empty-hint",children:[o.jsx("span",{className:"af-flow-empty-hint-icon material-symbols-outlined",children:"account_tree"}),o.jsx("p",{className:"af-flow-empty-hint-text",children:w("flow:emptyCanvas.composerHint")}),o.jsx("p",{className:"af-flow-empty-hint-sub",dangerouslySetInnerHTML:{__html:w("flow:emptyCanvas.composerSub")}})]}):null]})}function f1(e){if(!window.location.pathname.startsWith("/flow"))return;if(!e){window.history.replaceState({},"","/flow");return}const t=new URLSearchParams(window.location.search),n=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});e.archived&&n.set("flowArchived","1"),t.get("panel")==="settings"&&n.set("panel","settings"),window.history.replaceState({},"","/flow?"+n.toString())}function j7(e){return e==="builtin"||e==="admin"?"workspace":e??"user"}function xi(e){return e==="builtin"||e==="admin"}function Oc(e,t){return t(e==="builtin"||e==="admin"?"flow:settings.builtin":e==="workspace"?"flow:palette.workspace":"flow:palette.userDir")}function C7(e){var r,s,i,a;const t=Number(((s=(r=e==null?void 0:e.data)==null?void 0:r.displaySize)==null?void 0:s.width)||(e==null?void 0:e.width)||0),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.height)||(e==null?void 0:e.height)||0);return t>0&&n>0?{width:Math.round(t),height:Math.round(n)}:null}const GT="af:run-console-height",uf=230,Id={enabled:!1,cron:"",timezone:"Asia/Shanghai",preset:"",overlapPolicy:"skip",misfirePolicy:"skip",nextRunAt:null},Lh={};function um(e){if(!Number.isFinite(e))return uf;const t=Math.max(240,Math.floor(window.innerHeight*.88));return Math.min(Math.max(Math.round(e),96),t)}function E7(){try{const e=localStorage.getItem(GT);if(e==null)return uf;const t=parseInt(e,10);return Number.isFinite(t)?um(t):uf}catch{return uf}}function _7(){var tk,nk;const{t:e,i18n:t}=Pn(),{navigate:n,path:r}=Io(),s=h.useRef(null),i=h.useRef(new Map),a=h.useCallback(x=>{s.current=typeof x=="function"?x:null},[]),[l,u]=h.useState([]),[d,f]=h.useState(""),[c,p]=h.useState(null),[m,g]=h.useState(0),[b,k]=h.useState(""),[y,v]=h.useState(""),[w,j]=h.useState(""),[P,_]=h.useState(""),[L,B]=h.useState(!1),[D,F]=h.useState(""),[R,M]=h.useState(!1),[W,O]=h.useState(""),[$,I]=h.useState(!1),[z,C]=h.useState(!1),[T,E]=h.useState(!1),[G,Z]=h.useState(null),[V,se]=h.useState(!1),[de,fe]=h.useState(!1),pe=h.useRef(!1),[ae,be]=h.useState([]),[_e,we]=h.useState(""),[Oe,Ie]=h.useState("nodes"),et=h.useRef(null),[ft,Je]=h.useState([]),[bt,Ve]=h.useState(!1),[jt,An]=h.useState(""),[pn,In]=h.useState(!1),[en,Wn]=h.useState({name:"",id:"",description:""}),[Tn,ce]=h.useState(!1),[ve,ze]=h.useState(""),[it,ot]=h.useState(""),Tt=h.useRef(null),[tt,an]=h.useState([]),[Xt,rr]=h.useState(!1),[vn,ln]=h.useState(""),[hn,sr]=h.useState(""),[xe,Me]=h.useState(null),[Ze,Dt]=h.useState(null),[ie,Pe]=h.useState([]),[He,Ft]=h.useState(""),[cn,ir]=h.useState(!1),Ds=h.useCallback(x=>{Tt.current&&window.clearTimeout(Tt.current),ot(x),Tt.current=window.setTimeout(()=>{ot(""),Tt.current=null},3800)},[]),ns=h.useCallback(x=>{const N=String(x||"").trim();if(!N)return;const H=()=>{var q;return(q=s.current)==null?void 0:q.call(s,N)};window.requestAnimationFrame(H),window.setTimeout(H,80)},[]);h.useEffect(()=>()=>{Tt.current&&window.clearTimeout(Tt.current)},[]);const[cr,Xn]=h.useState(!1),[zr,st]=h.useState({files:[]}),[Br,_i]=h.useState(!1),[ga,hs]=h.useState(!0);h.useEffect(()=>{let x=!1;const N=()=>{fetch("/api/flows",{method:"HEAD"}).then(q=>{x||hs(q.ok)}).catch(()=>{x||hs(!1)})};N();const H=window.setInterval(N,5e3);return()=>{x=!0,window.clearInterval(H)}},[]),h.useEffect(()=>{let x=!1;return fetch("/api/dev-info").then(N=>N.json()).then(N=>{x||ya(!!(N!=null&&N.isDev))}).catch(()=>{}),()=>{x=!0}},[]),h.useEffect(()=>{c!=null&&c.id&&G_(c.id,c.source??"user","pipeline",!!c.archived)},[c==null?void 0:c.id,c==null?void 0:c.source,c==null?void 0:c.archived]);const[Ee,tn]=h.useState("edit"),[ur,pt]=h.useState([]),Le=h.useRef(0),[Hr,Vn]=h.useState(new Set),[Wr,kr]=h.useState({}),[ct,Wt]=h.useState(null),[nn,Sr]=h.useState(0),[Qe,dr]=h.useState(!1),[Fs,ya]=h.useState(!1),[ms,Lo]=h.useState(!1),[yr,Oo]=h.useState(E7),Pi=h.useRef({active:!1,pointerId:-1,startY:0,startH:uf}),[un,Jn]=h.useState(null),[gs,Vr]=h.useState(null),[ii,zs]=h.useState({}),K=h.useRef(ii);h.useEffect(()=>{K.current=ii},[ii]);const[ge,Te]=h.useState(!1),[Re,We]=h.useState(!1),[Jt,Rt]=h.useState({}),[dn,Ur]=h.useState({}),[rs,Bs]=h.useState(null),[or,xa]=h.useState(Id),[Gu,vp]=h.useState(!1),[Ai,wa]=h.useState(!1),[ml,Nr]=h.useState(""),[gl,yl]=h.useState(""),[Vt,hc]=h.useState(Lh),[zt,xl]=h.useState(null),no=h.useRef(0),oi=h.useRef(null),Mo=h.useRef(null),Xu=h.useRef(!0),$o=h.useRef(!1),[xr,wl]=h.useState(null),[ai,Ii]=h.useState(null),[mc,Do]=h.useState(!1),[ba,Fo]=h.useState(""),[bl,vl]=h.useState(!1),Ju=h.useRef(null),[li,Ar]=h.useState(null),[Qu,ci]=h.useState(!1),[va,zo]=h.useState(null),[ys,Zu]=h.useState(!1),[Kr,ka]=h.useState(null),ui=h.useRef(null),[xs,Ae]=h.useState(""),[ws,Sa]=h.useState(0),[Na,di]=h.useState(0),[kp,ed]=h.useState("pan"),[fr,ro]=h.useState(!1),[Rn,Sp]=h.useState(!1),td=h.useRef(null),nd=h.useRef(null),ja=h.useRef(null),[Np,jp]=h.useState(0),[yt,rd]=h.useState(null),[Cp,kl]=h.useState(""),[wt,Ep]=h.useState({cursor:[],opencode:[],claudeCode:[]}),[fi,Sl]=h.useState(""),[gc,uy]=h.useState(""),[pi,_p]=h.useState([]),[bs,so]=h.useState([]),[sd,Pp]=h.useState(!1),[Nl,Ap]=h.useState([]),[id,Hs]=h.useState(!1),[Ip,jl]=h.useState(()=>new Set),[Ti,ut]=h.useState(!1),qt=h.useRef(null),yc=h.useRef(null),[dy,od]=h.useState({}),xc=h.useCallback(x=>{if(!x)return null;const N=x.id,H=x.source??"user",q=x.archived?"archived":"";return{sessionsKey:`af:composer-sessions:${N}:${H}${q?":"+q:""}`,activeKey:`af:composer-active-session:${N}:${H}${q?":"+q:""}`}},[]),Tp=h.useCallback(x=>{if(!x)return"";const N=x.id,H=x.source??"user",q=x.archived?"archived":"";return`af:composer-skills:pipeline:${N}:${H}${q?":"+q:""}`},[]),Rp=h.useCallback(x=>{const N=xc(x);if(!N)return{sessions:[],activeSessionId:null};try{const H=localStorage.getItem(N.sessionsKey);if(!H)return{sessions:[],activeSessionId:null};const q=JSON.parse(H);if(!Array.isArray(q))return{sessions:[],activeSessionId:null};const Y=q.filter(ee=>ee&&typeof ee.id=="string").map(ee=>({...ee,running:!1,statusLine:ee.running?e("flow:composer.pageRefreshReset"):ee.statusLine,steps:[]}));let J=null;try{J=localStorage.getItem(N.activeKey),J&&!Y.some(ee=>ee.id===J)&&(J=null)}catch{J=null}return{sessions:Y,activeSessionId:J}}catch{return{sessions:[],activeSessionId:null}}},[xc]),wc=h.useCallback((x,N,H)=>{const q=xc(x);if(q)try{localStorage.setItem(q.sessionsKey,JSON.stringify(N)),H?localStorage.setItem(q.activeKey,H):localStorage.removeItem(q.activeKey)}catch{}},[xc]),Bo=h.useRef(0),Cl=h.useRef({sessions:[],activeSessionId:null,flowKey:null}),[ss,qr]=h.useState([]),[Qn,io]=h.useState(null),oo=h.useMemo(()=>Tp(c),[Tp,c]),[bc,Ho]=h.useState(""),Fn=h.useMemo(()=>{if(!c)return null;const x=c.id,N=c.source??"user",H=c.archived?"archived":"";return`${x}:${N}${H?":"+H:""}`},[c]),Ca=h.useRef(!1);h.useEffect(()=>{if(!Fn){qr([]),io(null),Cl.current={sessions:[],activeSessionId:null,flowKey:null};return}const x=Cl.current;if(x.flowKey===Fn)return;x.flowKey=Fn,Ca.current&&x.sessions.length>0&&wc(c,x.sessions,x.activeSessionId);const{sessions:N,activeSessionId:H}=Rp(c);if(N.length===0){const q=`session-1-${Date.now()}`,Y={id:q,label:e("flow:composer.conversationLabel",{n:1}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};x.sessions=[Y],x.activeSessionId=q,qr([Y]),io(q)}else{const q=N[N.length-1];if(q&&(!q.thread||q.thread.length===0))Bo.current=Ix(N),x.sessions=N,x.activeSessionId=q.id,qr(N),io(q.id);else{const J=Ix(N)+1;Bo.current=J;const ee=`session-${J}-${Date.now()}`,te={id:ee,label:e("flow:composer.conversationLabel",{n:J}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null},me=[...N,te];x.sessions=me,x.activeSessionId=ee,qr(me),io(ee)}}Ca.current=!0},[Fn,c,Rp,wc]);const kn=h.useMemo(()=>ss.find(x=>x.id===Qn)||null,[ss,Qn]),Sn=(kn==null?void 0:kn.running)??!1,El=(kn==null?void 0:kn.statusLine)??"",Wo=(kn==null?void 0:kn.segments)??[],ao=(kn==null?void 0:kn.thread)??[],ad=(kn==null?void 0:kn.steps)??[];kn==null||kn.outputDismissed;const Nt=(kn==null?void 0:kn.phaseContext)??null,ld=h.useRef([]),[vc,Vo]=h.useState(!1),_l=h.useRef(null),Lp=h.useRef(null);h.useEffect(()=>{const x=Lp.current;x&&requestAnimationFrame(()=>{x.scrollTop=x.scrollHeight})},[ao,Wo]);const kc=h.useRef(null),Sc=h.useRef(!1),Pl=h.useRef(null),Op=h.useCallback(x=>{const N=++Bo.current,H=`session-${N}-${Date.now()}`,q={id:H,label:x||e("flow:composer.conversationLabel",{n:N}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};return qr(Y=>[...Y,q]),io(H),H},[]);h.useEffect(()=>{!c||!Ca.current||(Cl.current.sessions=ss,Cl.current.activeSessionId=Qn,wc(c,ss,Qn))},[ss,Qn,c,wc]),h.useEffect(()=>{Bo.current=Math.max(Bo.current,Ix(ss))},[ss]);const Mp=h.useCallback(x=>{var N;kc.current===x&&((N=_l.current)==null||N.abort()),qr(H=>{const q=H.filter(J=>J.id!==x);if(H.some((J,ee)=>J.id===x&&H.findIndex(te=>te.id===Qn)===ee)||Qn===x){const J=q;J.length>0?io(J[J.length-1].id):setTimeout(()=>{Bo.current=0;const ee=++Bo.current,te=`session-${ee}-${Date.now()}`,me={id:te,label:e("flow:composer.conversationLabel",{n:ee}),thread:[],segments:[],running:!1,statusLine:"",steps:[],outputDismissed:!1,createdAt:Date.now(),phaseContext:null};qr(ye=>[...ye,me]),io(te)},0)}return q})},[Qn]),Yr=h.useCallback(x=>{qr(N=>{const H=N.findIndex(J=>J.id===Qn);if(H<0)return N;const q={...N[H]};x(q);const Y=[...N];return Y[H]=q,Y})},[Qn]),$p=h.useCallback(x=>{Yr(N=>{N.running=x})},[Yr]),Ws=h.useCallback(x=>{Yr(N=>{N.statusLine=x})},[Yr]),Vs=h.useCallback(x=>{Yr(N=>{typeof x=="function"?N.segments=x(N.segments):N.segments=x})},[Yr]),Dp=h.useCallback(x=>{Yr(N=>{typeof x=="function"?N.thread=x(N.thread):N.thread=x})},[Yr]),hi=h.useCallback(x=>{Yr(N=>{typeof x=="function"?N.steps=x(N.steps):N.steps=x})},[Yr]),Fp=h.useCallback(x=>{Yr(N=>{N.outputDismissed=x})},[Yr]),Al=h.useCallback(x=>{Yr(N=>{N.phaseContext=typeof x=="function"?x(N.phaseContext):x})},[Yr]),Uo=h.useCallback(x=>{io(x),qr(N=>{const H=N.findIndex(Y=>Y.id===x);if(H<0||!N[H].outputDismissed)return N;const q=[...N];return q[H]={...N[H],outputDismissed:!1},q})},[]);h.useEffect(()=>{ld.current=Wo},[Wo]);const Zn=h.useRef({}),mi=h.useRef(!1),Ri=h.useRef(null),Nc=h.useRef(null),lo=h.useRef(null),Ea=h.useRef(!1),cd=h.useRef(0),Il=h.useRef(""),[Ct,vt,fy]=UA([]),[mn,Yt,py]=KA([]),Us=h.useRef(Ct),Ko=h.useRef(mn),ud=h.useRef(null),jc=h.useRef(null),zp=h.useRef(null),Tl=h.useRef(null),[rn,Li]=h.useState(null),Bp=h.useCallback(x=>{var N;Zn.current=(N=x==null?void 0:x.extra)!=null&&N.instances&&typeof x.extra.instances=="object"?x.extra.instances:{},vt(Array.isArray(x==null?void 0:x.nodes)?x.nodes:[]),Yt(Array.isArray(x==null?void 0:x.edges)?x.edges:[]),Li(null)},[Yt,vt]),hy=h.useMemo(()=>({instances:Zn.current}),[mn,Ct]),{resetHistory:dd,undo:fd,redo:S}=_T({nodes:Ct,edges:mn,extra:hy,enabled:!!c&&Ea.current&&Ee==="edit",onRestore:Bp}),A=h.useMemo(()=>Ct.filter(x=>{var N;return(((N=x.data)==null?void 0:N.definitionId)||"").startsWith("provide_")}),[Ct]),U=h.useMemo(()=>{var N;const x={};for(const H of Ct){if(!((N=H.data)!=null&&N.inputs))continue;const q=H.data.inputs;for(let Y=0;Y<q.length;Y++){const J=q[Y];if(!(J!=null&&J.name))continue;const ee=mn.find(me=>me.target===H.id&&me.targetHandle===`input-${Y}`);if(!(ee!=null&&ee.source))continue;A.find(me=>me.id===ee.source)&&(x[ee.source]=J.name)}}return x},[Ct,mn,A]),X=h.useMemo(()=>{if(Ee==="edit"||Hr.size===0)return null;const x=new Set(Hr);for(const N of mn)Hr.has(N.source)&&x.add(N.target),Hr.has(N.target)&&x.add(N.source);return x},[Ee,Hr,mn]),Q=h.useMemo(()=>Ee==="edit"?Ct:Ct.map(x=>{var N,H;return{...x,draggable:!1,connectable:!1,data:{...x.data,isRunMode:!0,isExecuting:Hr.has(x.id),nodeStatus:((N=Wr[x.id])==null?void 0:N.status)??null,nodeElapsed:((H=Wr[x.id])==null?void 0:H.elapsed)??null,isDim:X?!X.has(x.id):!1}}}),[Ee,Ct,Hr,Wr,X]),re=h.useMemo(()=>X?mn.map(x=>{const N=Hr.has(x.source)||Hr.has(x.target),H=x.className?x.className.replace(/\s?af-flow-edge--(dim|focus)\b/g,""):"",q=N?"af-flow-edge--focus":"af-flow-edge--dim";return{...x,className:(H?H+" ":"")+q}}):mn,[mn,Hr,X]);h.useEffect(()=>{if(!c){Ur({}),Bs(null),xa(Id),hc(Lh),xl(null),Nr(""),yl("");return}const x=new URLSearchParams({flowId:c.id,flowSource:c.source||"user"});c.archived&&x.set("archived","1"),fetch(`/api/flow/run-config?${x.toString()}`).then(N=>N.json()).then(N=>{Ur(N.presets||{}),Bs(N.activePreset||null)}).catch(()=>{Ur({}),Bs(null)})},[c==null?void 0:c.id,c==null?void 0:c.source,c==null?void 0:c.archived]);const ne=h.useCallback(x=>{no.current+=1,xa(x)},[]),oe=h.useCallback(async(x,N={})=>{if(!x)return;const H=!!N.quiet,q=!!N.force,Y=no.current;H||(vp(!0),Nr(""),yl(""));const J=new URLSearchParams({flowId:x.id,flowSource:x.source||"user"});x.archived&&J.set("archived","1");try{const ee=await fetch(`/api/flow/schedule?${J.toString()}`),te=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(te.error||`HTTP ${ee.status}`);if(!q&&no.current!==Y)return;xa({...Id,...te.schedule||{}}),hc(te.state&&typeof te.state=="object"?te.state:Lh),xl(te.status||null)}catch(ee){if(!q&&no.current!==Y)return;xa(Id),hc(Lh),xl(null),Nr(String(ee.message||ee))}finally{vp(!1)}},[]);h.useEffect(()=>{if(!c)return;let x=!1;return(async()=>{await oe(c)})(),()=>{x=!0}},[c==null?void 0:c.id,c==null?void 0:c.source,c==null?void 0:c.archived,oe]),h.useEffect(()=>{var H,q,Y,J;if(!rs||!dn[rs]||A.length===0)return;const x=dn[rs],N={};for(const ee of A){const te=U[ee.id];if(!te)continue;const me=((H=ee.data)==null?void 0:H.definitionId)||"",ye=x[ee.id]??((J=(Y=(q=ee.data)==null?void 0:q.outputs)==null?void 0:Y[0])==null?void 0:J.default)??"";me.startsWith("provide_file")?N[te]={type:"file",path:ye}:N[te]={type:"str",value:ye}}Object.keys(N).length>0&&zs(N)},[rs,dn,A,U]);const he=h.useCallback(()=>{if(!Kr||!ui.current)return;const x=ui.current.value;vt(N=>N.map(H=>{var q,Y;return H.id!==Kr.instanceId?H:{...H,data:{...H.data,outputs:((Y=(q=H.data)==null?void 0:q.outputs)==null?void 0:Y.map((J,ee)=>ee===0?{...J,default:x}:J))||[{type:"text",name:"value",default:x}]}}})),ka(null)},[Kr,vt]),le=h.useMemo(()=>{const x=Ct.filter(N=>N.selected);return x.length===1?x[0]:null},[Ct]),Ne=h.useMemo(()=>c?YU(Ct,mn,e):[],[c,Ct,mn,e]),Be=h.useMemo(()=>Ne.map(x=>x.key).join("|"),[Ne]),at=h.useMemo(()=>Ne.some(x=>String((x==null?void 0:x.level)||"warning").toLowerCase()==="error"),[Ne]);h.useLayoutEffect(()=>{se(Ne.length>0&&!at)},[Be,c==null?void 0:c.id,c==null?void 0:c.source,Ne.length,at]),ja.current=le,h.useEffect(()=>{Us.current=Ct},[Ct]),h.useEffect(()=>{const x=i.current,N=new Map,H=[];for(const ee of Ct){const te=s7(ee);N.set(ee.id,te),x.get(ee.id)!==te&&H.push(ee.id)}if(i.current=N,H.length===0)return;const q=()=>H.forEach(ee=>{var te;return(te=s.current)==null?void 0:te.call(s,ee)}),Y=window.requestAnimationFrame(q),J=window.setTimeout(q,80);return()=>{window.cancelAnimationFrame(Y),window.clearTimeout(J)}},[Ct]),h.useEffect(()=>{Ko.current=mn},[mn]),h.useEffect(()=>{zp.current=rn},[rn]),h.useEffect(()=>{if(!rn)return;const x=H=>{H.key==="Escape"&&Li(null)},N=H=>{var q,Y;(Y=(q=H.target)==null?void 0:q.closest)!=null&&Y.call(q,".af-connect-node-menu")||Li(null)};return document.addEventListener("keydown",x),document.addEventListener("pointerdown",N),()=>{document.removeEventListener("keydown",x),document.removeEventListener("pointerdown",N)}},[rn]),h.useEffect(()=>()=>{lo.current!=null&&(clearTimeout(lo.current),lo.current=null)},[]);const Ue=h.useMemo(()=>{var N;if(!le)return null;const x=(N=le.data)==null?void 0:N.definitionId;return ae.find(H=>H.id===x)??null},[le,ae]),Lt=h.useMemo(()=>{const x={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const N of ae){const H=C0(N);x[H].push(N)}for(const N of Wd)x[N].sort((H,q)=>H.id.localeCompare(q.id));return x},[ae]),Ln=h.useMemo(()=>{const x=_e.trim().toLowerCase();if(!x)return Lt;const N={CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const H of Wd)N[H]=Lt[H].filter(q=>e7(q,x));return N},[Lt,_e]),gi=h.useMemo(()=>Wd.reduce((x,N)=>x+Ln[N].length,0),[Ln]),Pt=h.useMemo(()=>ae.filter(x=>{const N=String(x.id??""),H=String(x.source??"");return N.startsWith("marketplace:")||H==="marketplace"||H==="collection"}),[ae]),jr=h.useMemo(()=>{const x=new Set;for(const N of Pt){const H=String(N.id??"");if(H&&(x.add(H),H.startsWith("marketplace:"))){const q=H.slice(12),[Y]=q.split("@");Y&&x.add(`marketplace:${Y}`)}}return x},[Pt]),Ks=h.useCallback(async()=>{f("");try{const x=await fetch("/api/flows");if(!x.ok)throw new Error("HTTP "+x.status);u(await x.json())}catch(x){f(String(x.message||x))}},[]);h.useEffect(()=>{Ks()},[Ks]),h.useEffect(()=>{if(r!=="/flow")return;const x=new URLSearchParams(window.location.search);x.get("new")==="1"&&!x.get("flowId")&&n("/projects?new=1")},[r,n]),h.useEffect(()=>{if(r!=="/flow"||!c)return;new URLSearchParams(window.location.search).get("panel")==="settings"&&Dt("settings")},[r,c==null?void 0:c.id,c==null?void 0:c.source]),h.useEffect(()=>{let x=!1;const N=()=>{fetch("/api/model-lists").then(q=>q.json()).then(q=>{x||Ep({cursor:Array.isArray(q.cursor)?q.cursor.map(String):[],opencode:Array.isArray(q.opencode)?q.opencode.map(String):[],claudeCode:Array.isArray(q.claudeCode)?q.claudeCode.map(String):[]})}).catch(()=>{})};N();const H=setTimeout(N,4e3);return()=>{x=!0,clearTimeout(H)}},[]),h.useEffect(()=>{let x=!1;return fetch("/api/skills").then(N=>N.json()).then(N=>{if(x)return;const H=Array.isArray(N.skills)?N.skills.filter(q=>q&&typeof q.key=="string"&&q.key.trim()).map(q=>({key:String(q.key),name:String(q.name||q.id||q.key),description:q.description?String(q.description):"",sourceLabel:q.sourceLabel?String(q.sourceLabel):""})):[];_p(H),Pp(!0)}).catch(()=>{}),()=>{x=!0}},[]),h.useEffect(()=>{let x=!1;return fetch("/api/skill-collections").then(N=>N.json()).then(N=>{x||(Ap(Za(N)),Hs(!0))}).catch(()=>{}),()=>{x=!0}},[]),h.useEffect(()=>{if(Ho(""),!(!sd||!id)){if(!oo){so([]);return}so(Z_(oo,"pipeline",pi,Nl)),Ho(oo)}},[Nl,id,pi,sd,oo]),h.useEffect(()=>{if(!(bc!==oo||!oo))try{localStorage.setItem(oo,JSON.stringify(bs))}catch{}},[bs,oo,bc]);const Ir=h.useCallback(async x=>{const N=x.source??"user",H=!!x.archived,q=new URLSearchParams({flowId:x.id,flowSource:N});H&&q.set("archived","1");const Y=new URLSearchParams({flowId:x.id,flowSource:N});H&&Y.set("archived","1"),Y.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[J,ee]=await Promise.all([fetch("/api/flow?"+q.toString()),fetch("/api/nodes?"+Y.toString())]),te=await J.json();if(!J.ok||te.error)throw new Error(te.error||e("flow:nodePropsError.loadFlowFailed"));const me=await ee.json();if(!ee.ok)throw new Error(e("flow:nodePropsError.loadNodesFailed"));const ye=Array.isArray(me)?me:Array.isArray(me==null?void 0:me.nodes)?me.nodes:[],Fe=!Array.isArray(me)&&(me==null?void 0:me.pipelineTranslations)||{},ue=UU(te.flowYaml||"");if(ue.error)throw new Error(ue.error);const $e={...ue.instances||{}},Se=ue.nodes.map(yn=>qf(yn,$e,ye,Fe,x.id)),gt=ET(ue.edges,Se);return{flowSource:N,paletteList:ye,instances:$e,flowDescriptionText:ue.description??"",viewport:c1(ue.viewport),nodes:Se,edges:gt}},[t.language,e]),Un=h.useCallback(async(x,N={})=>{const H=!!N.preserveComposer,q=H&&!!N.incrementalSync;Ea.current=!1,cd.current+=1,p(x),v(""),H||(j(""),we(""),Dt(null),k(""),F(""),O(""),Ae(""),Dp([]),Vs([]),hi([]),Fp(!1),Al(null),ed("pan")),q||(Zn.current={},vt([]),Yt([])),f1(x);try{const Y=await Ir(x);if(be(Y.paletteList),Zn.current=Y.instances,k(Y.flowDescriptionText),F(x.id||""),q){const J=Us.current,ee=Ko.current;try{const te=kW(J,ee,Y.nodes,Y.edges),me=new Set([...te.changes.addedNodeIds,...te.changes.updatedNodeIds]),ye=new Set([...te.changes.addedEdgeKeys,...te.changes.updatedEdgeKeys]),Fe=me.size>0?te.nodes.map($e=>me.has($e.id)?{...$e,className:Qj($e.className,Xj)}:$e):te.nodes,ue=ye.size>0?te.edges.map($e=>ye.has(Hf($e))?{...$e,className:Qj($e.className,Jj)}:$e):te.edges;vt(Fe),Yt(ue),lo.current!=null&&(clearTimeout(lo.current),lo.current=null),(me.size>0||ye.size>0)&&(lo.current=window.setTimeout(()=>{lo.current=null,me.size>0&&vt($e=>$e.map(Se=>{if(!me.has(Se.id))return Se;const gt=Zj(Se.className,Xj);return gt===String(Se.className||"")?Se:{...Se,className:gt}})),ye.size>0&&Yt($e=>$e.map(Se=>{if(!ye.has(Hf(Se)))return Se;const gt=Zj(Se.className,Jj);return gt===String(Se.className||"")?Se:{...Se,className:gt}}))},JK))}catch{vt(Y.nodes),Yt(Y.edges)}}else if(vt(Y.nodes),Yt(Y.edges),Nc.current=Y.viewport||null,Y.viewport){const J=()=>{var ee;try{(ee=Ri.current)==null||ee.setViewport(Y.viewport,{duration:0})}catch{}};requestAnimationFrame(()=>requestAnimationFrame(J))}else g(J=>J+1);hh(x.id,Y.flowSource),jp(J=>J+1),dd(Y.nodes,Y.edges,{instances:Y.instances});try{Il.current=Rj(Y.nodes,Y.edges,Y.instances,{description:Y.flowDescriptionText,viewport:Nc.current})}catch{Il.current=""}Ea.current=!0}catch(Y){v(String(Y.message||Y))}},[Ir,dd,vt,Yt]),ht=h.useCallback(async()=>{if(!(c!=null&&c.id))return;const x=c.source??"user",N=new URLSearchParams({flowId:c.id,flowSource:x});c.archived&&N.set("archived","1"),N.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const H=await fetch("/api/nodes?"+N.toString()),q=await H.json();if(!H.ok)throw new Error((q==null?void 0:q.error)||e("flow:nodePropsError.loadNodesFailed"));const Y=Array.isArray(q)?q:Array.isArray(q==null?void 0:q.nodes)?q.nodes:[];be(Y)},[c,e,t.language]),fn=h.useCallback(async()=>{rr(!0),ln("");try{const x=await fetch("/api/marketplace/nodes"),N=await x.json().catch(()=>({}));if(!x.ok)throw new Error((N==null?void 0:N.error)||"Failed to load marketplace nodes");an(Array.isArray(N==null?void 0:N.nodes)?N.nodes:[])}catch(x){ln(String(x.message||x)),an([])}finally{rr(!1)}},[]),is=h.useCallback(async()=>{Ve(!0),An("");try{const x=await fetch("/api/marketplace/flow-snippets"),N=await x.json().catch(()=>({}));if(!x.ok)throw new Error((N==null?void 0:N.error)||"Failed to load flow snippets");Je(Array.isArray(N==null?void 0:N.snippets)?N.snippets:[])}catch(x){An(String(x.message||x)),Je([])}finally{Ve(!1)}},[]);h.useEffect(()=>{c&&(fn(),is())},[c==null?void 0:c.id,c==null?void 0:c.source,c==null?void 0:c.archived,fn,is]);const Cc=h.useCallback(async x=>{if(!c||!x)return;const N=x.definitionId||`marketplace:${x.id}${x.version?`@${x.version}`:""}`;if(N){sr(N),ln("");try{const H=await fetch("/api/marketplace/install-node",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source||"user",archived:!!c.archived,nodeSpec:N})}),q=await H.json().catch(()=>({}));if(!H.ok||(q==null?void 0:q.ok)===!1)throw new Error((q==null?void 0:q.error)||"Failed to install marketplace node");await ht()}catch(H){ln(String(H.message||H))}finally{sr("")}}},[c,ht]),Ec=h.useCallback(async(x,N)=>{const H={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:N,body:(x==null?void 0:x.body)||"",script:(x==null?void 0:x.script)||"",inputs:Array.isArray(x==null?void 0:x.inputs)?x.inputs:[],outputs:Array.isArray(x==null?void 0:x.outputs)?x.outputs:[],flowId:c==null?void 0:c.id,flowSource:(c==null?void 0:c.source)||"user"},q=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(H)}),Y=await q.json();if(!q.ok||(Y==null?void 0:Y.ok)===!1)throw new Error((Y==null?void 0:Y.error)||"Publish failed");return await ht(),Y},[ht,c]),ke=h.useCallback(async()=>{var q;if(!c||pe.current)return;const x=c.id,N=c.source??"user",H=((q=ja.current)==null?void 0:q.id)??null;pe.current=!0,fe(!0);try{await Un({id:x,source:N,archived:c.archived},{preserveComposer:!0,incrementalSync:!0}),H&&vt(Y=>Y.map(J=>({...J,selected:J.id===H})))}finally{pe.current=!1,fe(!1)}},[c,c==null?void 0:c.archived,Un,vt]);h.useEffect(()=>{if(mi.current||l.length===0)return;const x=new URLSearchParams(window.location.search),N=x.get("flowId");if(!N)return;const H=x.get("flowSource")??"user",q=x.get("flowArchived")==="1",Y=l.find(J=>J.id===N&&(J.source??"user")===H&&!!J.archived===q);Y&&(mi.current=!0,Un(Y))},[l,Un]);const dt=h.useRef(0);h.useEffect(()=>{if(!c)return;const x=c.id,N=c.source??"user",H=!!c.archived;dt.current=0;let q=!1;const Y=async()=>{var te;if(q)return;const ee=new URLSearchParams({flowId:x,flowSource:N,v:String(dt.current)});H&&ee.set("archived","1");try{const me=await fetch("/api/flow-editor-sync-poll?"+ee.toString());if(!me.ok||q)return;const ye=await me.json();if(q)return;if(ye.changed){dt.current=ye.version;const Fe=((te=ja.current)==null?void 0:te.id)??null;await Un({id:x,source:N,archived:H},{preserveComposer:!0,incrementalSync:!0}),await oe({id:x,source:N,archived:H},{quiet:!0,force:!0}),Fe&&vt(ue=>ue.map($e=>({...$e,selected:$e.id===Fe})))}else dt.current=ye.version}catch{}},J=window.setInterval(Y,2e3);return Y(),()=>{q=!0,window.clearInterval(J)}},[c==null?void 0:c.id,c==null?void 0:c.source,c==null?void 0:c.archived,Un,oe,vt]);const mt=h.useMemo(()=>w?w.startsWith(e("flow:status.saveFailed"))?" af-palette-tip--error":w===e("flow:status.saved")?" af-palette-tip--success":" af-palette-tip--info":"",[w]);h.useEffect(()=>{if(!w)return;w===e("flow:status.saved")||w.startsWith(e("flow:status.runInTerminal"));const x=w.startsWith(e("flow:status.runInTerminal"))?5200:2800,N=window.setTimeout(()=>j(""),x);return()=>clearTimeout(N)},[w,e]),h.useEffect(()=>{_("")},[c==null?void 0:c.id,c==null?void 0:c.source]),h.useEffect(()=>{const x=()=>{window.__provideEditContent&&(ka(window.__provideEditContent),window.__provideEditContent=null)};return window.addEventListener("provide-expand",x),()=>window.removeEventListener("provide-expand",x)},[]),h.useEffect(()=>{var te,me,ye,Fe,ue,$e,Se;if(!le){rd(null);return}const x=Zn.current[le.id]||{},{inputs:N,outputs:H}=CT(le),q=String(((te=le.data)==null?void 0:te.definitionId)??le.id??""),Y=((me=le.data)==null?void 0:me.script)!=null?String(le.data.script):void 0,J=x.script!=null?String(x.script):void 0,ee=q==="tool_nodejs"||Y&&Y.trim()!==""||J&&J.trim()!==""?String(Y??J??""):"";rd({id:le.id,newId:le.id,label:String(((ye=le.data)==null?void 0:ye.label)??le.id),role:((Fe=le.data)==null?void 0:Fe.role)??"普通",model:String(((ue=le.data)==null?void 0:ue.model)??x.model??""),body:String((($e=le.data)==null?void 0:$e.body)??x.body??""),images:Ps(((Se=le.data)==null?void 0:Se.images)??x.images),script:ee,inputs:N,outputs:H})},[le==null?void 0:le.id,Np]),h.useEffect(()=>{c&&(le||(nd.current=null,Dt(x=>x==="node"?null:x)))},[c,le==null?void 0:le.id]);const nt=h.useCallback(()=>{nd.current=null,Dt(x=>x==="settings"||x==="history"?x:"node")},[]),De=h.useCallback((x,N)=>{x.metaKey||x.ctrlKey||x.shiftKey||Ee!=="edit"&&Vr((N==null?void 0:N.id)??null)},[Ee]),Ot=h.useCallback((x,N)=>{Ee==="edit"&&(x.preventDefault(),vt(H=>H.map(q=>({...q,selected:q.id===N.id}))),Yt(H=>H.map(q=>({...q,selected:!1}))),nt())},[nt,Ee,Yt,vt]),Qt=h.useCallback((x,N)=>{if(Ee!=="edit")return;const H=x.metaKey||x.ctrlKey||x.shiftKey;Yt(q=>q.map(Y=>Y.id===N.id?{...Y,selected:!Y.selected||!H}:H?Y:{...Y,selected:!1})),H||vt(q=>q.map(Y=>({...Y,selected:!1})))},[Ee,Yt,vt]),Ut=h.useCallback(x=>s1(x,Us.current),[]),Nn=h.useCallback(x=>{if(!s1(x,Us.current)){j("端口类型不匹配,已取消连线");return}Li(null),vt(N=>og(N,x)),Yt(N=>{const H=N.filter(q=>!(q.target===x.target&&q.targetHandle===x.targetHandle));return Ff({...x,markerEnd:{type:Ls.ArrowClosed}},H)})},[Yt,vt]),gn=h.useCallback((x,N)=>{jc.current=i7(N,Us.current),Li(null)},[]),At=h.useCallback((x,N)=>{var Se,gt,yn,xn;const H=jc.current;if(jc.current=null,!c||!H||N!=null&&N.toNode)return;const q=a7(ae,H);if(q.length===0){j(`没有匹配 ${H.slotType} 端口的节点`);return}const Y=((gt=(Se=x==null?void 0:x.changedTouches)==null?void 0:Se[0])==null?void 0:gt.clientX)??(x==null?void 0:x.clientX),J=((xn=(yn=x==null?void 0:x.changedTouches)==null?void 0:yn[0])==null?void 0:xn.clientY)??(x==null?void 0:x.clientY);if(!Number.isFinite(Y)||!Number.isFinite(J))return;const ee=Ri.current,te=document.querySelector(".af-pipeline-flow .react-flow");if(!ee||!te)return;const me=te.getBoundingClientRect(),ye=320,Fe=Math.min(440,104+q.length*58),ue=Math.max(12,Math.min(Y-me.left,me.width-ye-12)),$e=Math.max(12,Math.min(J-me.top,me.height-Fe-12));Li({left:ue,top:$e,flowPosition:ee.screenToFlowPosition({x:Y,y:J}),draft:H,candidates:q,query:""})},[ae,c]),sn=h.useCallback(x=>{for(const N of x)delete Zn.current[N.id]},[]),os=h.useCallback(x=>{Ri.current=x},[]),Oi=h.useCallback(x=>{vt(H=>H.map(q=>({...q,selected:q.id===x}))),Yt(H=>H.map(q=>({...q,selected:!1}))),nt();const N=()=>{var me,ye,Fe;const H=Ri.current;if(!(H!=null&&H.getNode))return;const q=H.getNode(x);if(!q)return;const Y=(me=H.getInternalNode)==null?void 0:me.call(H,x),J=((ye=Y==null?void 0:Y.measured)==null?void 0:ye.width)??(Y==null?void 0:Y.width)??q.width??200,ee=((Fe=Y==null?void 0:Y.measured)==null?void 0:Fe.height)??(Y==null?void 0:Y.height)??q.height??88,{zoom:te}=H.getViewport();H.setCenter(q.position.x+J/2,q.position.y+ee/2,{zoom:l1(te),duration:220})};requestAnimationFrame(()=>requestAnimationFrame(N))},[vt,Yt,nt]),co=h.useCallback(x=>{vt(H=>H.map(q=>({...q,selected:q.id===x}))),Yt(H=>H.map(q=>({...q,selected:!1})));const N=()=>{var ye,Fe,ue;const H=Ri.current;if(!(H!=null&&H.getNode))return;const q=H.getNode(x);if(!q)return;const Y=(ye=H.getInternalNode)==null?void 0:ye.call(H,x),J=((Fe=Y==null?void 0:Y.measured)==null?void 0:Fe.width)??(Y==null?void 0:Y.width)??q.width??200,ee=((ue=Y==null?void 0:Y.measured)==null?void 0:ue.height)??(Y==null?void 0:Y.height)??q.height??88,{zoom:te}=H.getViewport(),me=l1(te);H.setCenter(q.position.x+J/2,q.position.y+ee/2,{zoom:me,duration:260})};requestAnimationFrame(()=>requestAnimationFrame(N))},[vt,Yt]),vs=h.useCallback((x,N)=>{const H=`node-${Date.now()}`;return qT(x,H,N,Zn.current,ae)},[ae]),Hp=h.useCallback(x=>{if(!c||!x)return;let N={x:180,y:160};const H=Ri.current,q=document.querySelector(".af-pipeline-flow .react-flow");if(H&&q){const Y=q.getBoundingClientRect();N=H.screenToFlowPosition({x:Y.left+Y.width*.45,y:Y.top+Y.height*.38})}vt(Y=>[...Y,vs(x,N)])},[c,vt,vs]),my=h.useCallback(x=>{const N=zp.current;if(!c||!N||!(x!=null&&x.def))return;const H=vs(x.def,N.flowPosition),q=N.draft.handleType==="source"?{source:N.draft.nodeId,sourceHandle:N.draft.handleId,target:H.id,targetHandle:`input-${x.slotIndex}`}:{source:H.id,sourceHandle:`output-${x.slotIndex}`,target:N.draft.nodeId,targetHandle:N.draft.handleId};vt(Y=>og([...Y,H],q)),Yt(Y=>{const J=Y.filter(ee=>!(ee.target===q.target&&ee.targetHandle===q.targetHandle));return Ff({...q,markerEnd:{type:Ls.ArrowClosed}},J)}),Li(null)},[c,vs,vt,Yt]),e2=h.useCallback(x=>{x.preventDefault(),x.dataTransfer.dropEffect="move"},[]),t2=h.useCallback(x=>{var ee;if(x.preventDefault(),!c)return;const N=Ri.current;if(!N)return;const H=N.screenToFlowPosition({x:x.clientX,y:x.clientY}),q=x.dataTransfer.getData("application/agentflow-snippet");if(q){const te=ft.find(me=>`${me.id}@${me.version}`===q);te&&((ee=Tl.current)==null||ee.call(Tl,te,H));return}const Y=x.dataTransfer.getData("application/agentflow-node");if(!Y)return;const J=ae.find(te=>te.id===Y);J&&vt(te=>[...te,vs(J,H)])},[c,ae,ft,vt,vs]),yi=h.useCallback(async(x,N)=>{if(!c)return;const H=Rj(x,N,Zn.current,{description:b,viewport:Nc.current});if(H!==Il.current){j(e("flow:status.saving"));try{const q=j7(c.source),Y=await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:q,flowYaml:H,...c.archived?{flowArchived:!0}:{}})}),J=await Y.json();if(!Y.ok||!J.success)throw new Error(J.error||e("flow:status.saveFailed"));if(Il.current=H,j(e("flow:status.saved")),xi(c.source)&&q==="workspace"){const ee={id:c.id,source:"workspace",path:void 0};p(ee),f1(ee),hh(c.id,"workspace")}}catch(q){j(e("flow:status.saveFailed")+": "+(q.message||q))}}},[c,b]);h.useEffect(()=>{if(!c||!Ea.current||Ee!=="edit"||c.archived)return;const x=cd.current,N=setTimeout(()=>{x===cd.current&&Ea.current&&yi(Us.current,Ko.current)},400);return()=>clearTimeout(N)},[Ct,mn,b,Ee,c,yi]);const Wp=h.useCallback(async x=>{if(!c||c.archived)return;const N=c.source??"user";if(!(N!=="user"&&N!=="workspace")&&N!==x){B(!0),_("");try{const H=await fetch("/api/flow/move",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,fromSource:N,toSource:x})}),q=await H.json().catch(()=>({}));if(!H.ok)throw new Error(typeof q.error=="string"?q.error:e("flow:composer.requestFailed"));const Y=q.flowSource==="workspace"||q.flowSource==="user"?q.flowSource:x;let J={id:c.id,source:Y,archived:c.archived};try{const ee=await fetch("/api/flows");if(ee.ok){const te=await ee.json(),me=Array.isArray(te)?te.find(ye=>ye.id===c.id&&(ye.source??"user")===Y&&!!ye.archived==!!c.archived):null;me&&(J=me)}}catch{}await Un(J,{preserveComposer:!0}),hh(c.id,Y)}catch(H){_(String(H.message||H))}finally{B(!1)}}},[c,Un]),gy=h.useCallback(async()=>{if(c){wa(!0),Nr(""),yl("");try{const x=await fetch("/api/flow/schedule",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source||"user",archived:!!c.archived,schedule:or})}),N=await x.json().catch(()=>({}));if(!x.ok||!N.success)throw new Error(N.error||"Failed to save schedule");xa({...Id,...N.schedule||{}}),yl(e("flow:schedule.saved")),await oe(c,{quiet:!0,force:!0})}catch(x){Nr(String(x.message||x))}finally{wa(!1)}}},[c,or,oe,e]),n2=h.useCallback(async()=>{c&&(await yi(Us.current,Ko.current),!c.archived&&c.source!=="builtin"&&await gy())},[c,yi,gy]),Vp=h.useCallback(async()=>{if(!c||!D.trim())return;const x=D.trim();if(x===c.id){O("");return}M(!0),O("");try{const N=await fetch("/api/flow/rename",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",newFlowId:x})}),H=await N.json().catch(()=>({}));if(!N.ok)throw new Error(typeof H.error=="string"?H.error:e("flow:composer.requestFailed"));let q={id:H.flowId,source:H.flowSource??c.source,archived:c.archived};try{const Y=await fetch("/api/flows");if(Y.ok){const J=await Y.json(),ee=Array.isArray(J)?J.find(te=>te.id===H.flowId&&(te.source??"user")===(H.flowSource??c.source)):null;ee&&(q=ee)}}catch{}await Un(q,{preserveComposer:!0}),hh(H.flowId,H.flowSource??c.source)}catch(N){O(String(N.message||N))}finally{M(!1)}},[c,D,Un]),W0=h.useCallback(x=>{navigator.clipboard.writeText(x).then(()=>{I(!0),setTimeout(()=>I(!1),2e3)}).catch(()=>{})},[]),yy=h.useCallback(()=>{yi(Ct,mn)},[yi,Ct,mn]),V0=h.useCallback(()=>{var N,H;if(!c)return;const x=c1((H=(N=Ri.current)==null?void 0:N.getViewport)==null?void 0:H.call(N));x&&(Nc.current=x,j("已固定 Pipeline 进入视角"),yi(Us.current,Ko.current))},[yi,c]),r2=h.useCallback((x,N)=>{const H=N.trim()===""||N==="default"?void 0:N.trim(),q=Ct.map(Y=>Y.id===x?{...Y,data:{...Y.data,model:H}}:Y);vt(q),yi(q,mn)},[Ct,mn,vt,yi]),Up=h.useCallback(()=>{var gt,yn;if(!yt||!c||!le)return!1;const x=le.id,N=yt.newId.trim();if(kl(""),!FT.test(N))return kl(e("flow:nodePropsError.invalidInstanceId")),!1;if(Ct.some(xn=>xn.id===N&&xn.id!==x))return kl(e("flow:nodePropsError.duplicateInstanceId")),!1;const H=yt.role.trim(),q=al.includes(H)?H:"普通",Y=yt.model.trim(),J=xn=>(Array.isArray(xn)?xn:[]).map(Bt=>({type:String((Bt==null?void 0:Bt.type)??"节点").trim()||"节点",name:String((Bt==null?void 0:Bt.name)??""),default:String((Bt==null?void 0:Bt.default)??""),required:!!(Bt!=null&&Bt.required),showOnNode:(Bt==null?void 0:Bt.showOnNode)!=null?Bt.showOnNode!==!1:!!(Bt!=null&&Bt.required)||String((Bt==null?void 0:Bt.type)??"节点").trim().toLowerCase()==="node"})),ee=J(yt.inputs),te=J(yt.outputs),me=String(((gt=le.data)==null?void 0:gt.definitionId)??N),ye=me.startsWith("provide_"),Fe={...le.data,label:yt.label.trim()||N,role:q,model:Y===""||Y==="default"?void 0:Y,body:ye?"":yt.body,images:ye?[]:Ps(yt.images),inputs:ee,outputs:ye&&Array.isArray((yn=le.data)==null?void 0:yn.outputs)?le.data.outputs:te},ue=String(yt.script??"").trim();me==="tool_nodejs"||ue!==""?Fe.script=String(yt.script??""):delete Fe.script;let $e,Se=mn;if(N!==x){const xn={...Zn.current},Bt={...xn[x]||{}};delete xn[x],xn[N]=Bt,Zn.current=xn,$e=Ct.map(kt=>kt.id!==x?kt:{...kt,id:N,selected:!0,data:Fe}),Se=mn.map((kt,Gt)=>({...kt,source:kt.source===x?N:kt.source,target:kt.target===x?N:kt.target,id:`e-${kt.source===x?N:kt.source}-${kt.target===x?N:kt.target}-${Gt}`}))}else $e=Ct.map(xn=>xn.id===x?{...xn,data:Fe}:xn);return vt($e),Yt(Se),ns(N),yi($e,Se),!0},[yt,c,le,Ct,mn,vt,Yt,ns,yi]),xy=h.useCallback(()=>{var yn,xn;if(!yt||!c||!le)return!1;const x=le.id,N=yt.role.trim(),H=al.includes(N)?N:"普通",q=yt.model.trim(),Y=Bt=>(Array.isArray(Bt)?Bt:[]).map(kt=>({type:String((kt==null?void 0:kt.type)??"节点").trim()||"节点",name:String((kt==null?void 0:kt.name)??""),default:String((kt==null?void 0:kt.default)??""),required:!!(kt!=null&&kt.required),showOnNode:(kt==null?void 0:kt.showOnNode)!=null?kt.showOnNode!==!1:!!(kt!=null&&kt.required)||String((kt==null?void 0:kt.type)??"节点").trim().toLowerCase()==="node"})),J=Y(yt.inputs),ee=Y(yt.outputs),te=String(((yn=le.data)==null?void 0:yn.definitionId)??x),me=te.startsWith("provide_"),ye=yt.label.trim()||x,Fe=q===""||q==="default"?void 0:q,ue={...le.data,label:ye,role:H,model:Fe,body:me?"":yt.body,images:me?[]:Ps(yt.images),inputs:J,outputs:me&&Array.isArray((xn=le.data)==null?void 0:xn.outputs)?le.data.outputs:ee},$e=String(yt.script??"").trim();te==="tool_nodejs"||$e!==""?ue.script=String(yt.script??""):delete ue.script;const Se=le.data||{};return(Se.label!==ue.label||Se.role!==ue.role||Se.model!==ue.model||Se.body!==ue.body||JSON.stringify(Ps(Se.images))!==JSON.stringify(ue.images)||(Se.script??void 0)!==(ue.script??void 0)||JSON.stringify(Se.inputs||[])!==JSON.stringify(J)||JSON.stringify(Se.outputs||[])!==JSON.stringify(ee))&&(vt(Bt=>Bt.map(kt=>kt.id===x?{...kt,data:ue}:kt)),ns(x)),!0},[yt,c,le,vt,ns]),U0=h.useRef(xy);h.useEffect(()=>{U0.current=xy},[xy]),h.useEffect(()=>{if(!yt||!c||!Ea.current||Ee!=="edit")return;const x=setTimeout(()=>{U0.current()},400);return()=>clearTimeout(x)},[yt,c,Ee]);const s2=h.useCallback(()=>{if(!(!yt||!le)){if(yt.newId.trim()===le.id){kl("");return}Up()}},[yt,le,Up]);h.useEffect(()=>{const x=N=>{var ee,te,me;if(Ee!=="edit")return;const H=IT(N.target);if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="s"){if(Ze==="node"&&le&&yt){N.preventDefault(),N.stopPropagation(),Up()||yy();return}if(H)return;N.preventDefault(),N.stopPropagation(),yy();return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="k"){N.preventDefault(),N.stopPropagation(),Sp(ye=>!ye);return}if(Rn)return;if(fr){if(N.key==="Escape"){N.preventDefault(),ro(!1);return}if(lg(N)&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),ro(!1);return}(N.key==="v"||N.key==="V"||N.key==="h"||N.key==="H")&&!N.metaKey&&!N.ctrlKey&&!N.altKey&&N.preventDefault();return}if(H)return;const q=N.key.toLowerCase(),Y=(N.metaKey||N.ctrlKey)&&!N.shiftKey&&q==="z",J=(N.metaKey||N.ctrlKey)&&(N.shiftKey&&q==="z"||q==="y");if(Y||J){N.preventDefault(),N.stopPropagation();const ye=Y?fd():S();j(ye?Y?"Undo canvas change":"Redo canvas change":Y?"Nothing to undo":"Nothing to redo");return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="c"){const ye=kT(Us.current,Ko.current,Zn.current);ye&&(N.preventDefault(),N.stopPropagation(),ud.current=ye,j(`Copied ${ye.nodes.length} node${ye.nodes.length>1?"s":""}`));return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="v"){const ye=ST(ud.current,Us.current,Ko.current,Zn.current);ye&&(N.preventDefault(),N.stopPropagation(),Zn.current=ye.instances,vt(ye.nodes),Yt(ye.edges),j(`Pasted ${ye.pastedNodeIds.length} node${ye.pastedNodeIds.length>1?"s":""}`));return}if((N.key==="a"||N.key==="A")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),N.stopPropagation(),(ee=et.current)==null||ee.focus(),(me=(te=et.current)==null?void 0:te.select)==null||me.call(te);return}if((N.metaKey||N.ctrlKey)&&N.key.toLowerCase()==="a"){N.preventDefault(),N.stopPropagation(),vt(ye=>ye.map(Fe=>({...Fe,selected:!0}))),Yt(ye=>ye.map(Fe=>({...Fe,selected:!1})));return}if(lg(N)&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),ro(ye=>!ye);return}if((N.key==="v"||N.key==="V")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),ed("select");return}if((N.key==="h"||N.key==="H")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),ed("pan");return}if((N.key==="f"||N.key==="F")&&!N.metaKey&&!N.ctrlKey&&!N.altKey){N.preventDefault(),V0();return}};return window.addEventListener("keydown",x,!0),()=>window.removeEventListener("keydown",x,!0)},[yy,V0,fr,Rn,Ze,le,yt,Up,Ee,fd,S]),h.useEffect(()=>{if(Ee!=="running"||ct==null)return;let x=Math.floor((Date.now()-ct)/1e3);const N=setInterval(()=>{const H=Date.now()-ct,q=Math.floor(H/1e3);q!==x&&(x=q,Sr(H))},500);return()=>clearInterval(N)},[Ee,ct]),h.useEffect(()=>{const x=Mo.current;!x||!x.parentElement||Xu.current&&($o.current=!0,x.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{$o.current=!1}))},[ur]),h.useEffect(()=>{const x=Mo.current;if(!x)return;const N=x.parentElement;if(!N)return;const H=()=>{if($o.current)return;const q=N.scrollHeight-N.scrollTop-N.clientHeight;Xu.current=q<40};return N.addEventListener("scroll",H,{passive:!0}),()=>N.removeEventListener("scroll",H)},[Qe,Ee]),h.useEffect(()=>{if(Ee==="edit"||!Qe)return;Xu.current=!0;const x=Mo.current;x&&($o.current=!0,x.scrollIntoView({behavior:"auto",block:"end"}),requestAnimationFrame(()=>{$o.current=!1}))},[Ee,Qe]),h.useEffect(()=>{ur.length>cm+u1&&pt(x=>x.length>cm+u1?x.slice(-cm):x)},[ur]);const i2=h.useCallback(x=>{if(x.button!==0)return;x.preventDefault();const N=x.currentTarget;Pi.current={active:!0,pointerId:x.pointerId,startY:x.clientY,startH:yr},N.setPointerCapture(x.pointerId)},[yr]),o2=h.useCallback(x=>{const N=Pi.current;if(!N.active||x.pointerId!==N.pointerId)return;const H=N.startY-x.clientY;Oo(um(N.startH+H))},[]),Kp=h.useCallback(()=>{Oo(x=>{const N=um(x);try{localStorage.setItem(GT,String(N))}catch{}return N})},[]),K0=h.useCallback(x=>{const N=Pi.current;if(!(!N.active||x.pointerId!==N.pointerId)){N.active=!1;try{x.currentTarget.releasePointerCapture(x.pointerId)}catch{}Kp()}},[Kp]),a2=h.useCallback(()=>{const x=Pi.current;x.active&&(x.active=!1,Kp())},[Kp]);h.useEffect(()=>{function x(){Oo(N=>um(N))}return window.addEventListener("resize",x),()=>window.removeEventListener("resize",x)},[]);const uo=h.useCallback(async(x={})=>{if(!c)return;const N=x.runUuid!=null&&String(x.runUuid).trim()?String(x.runUuid).trim():null,H=x.cliInputsOverride??K.current,q=!!x.prepareOnly;if(tn(q?"ready":"running"),pt(q?[]:[{ts:new Date().toISOString(),type:"info",text:N?e("flow:run.connectingApiResume",{uuid:N}):e("flow:run.connectingApi")}]),Vn(new Set),kr({}),dr(!q),Dt(null),N||Jn(null),q)return;if(!N){const J=Date.now();Wt(J),Sr(0)}const Y=new AbortController;oi.current=Y;try{const J=await fetch("/api/flow/run",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source||"user",...N?{uuid:N}:{},cliInputs:H}),signal:Y.signal});if(!J.ok){const ue=await J.json().catch(()=>({error:e("flow:composer.requestFailed")}));pt($e=>[...$e,{ts:new Date().toISOString(),type:"error",text:ue.error||e("flow:composer.requestFailed")}]),tn("error");return}if(pt(ue=>[...ue,{ts:new Date().toISOString(),type:"info",text:e("flow:run.connectedReceiving")}]),!J.body){pt(ue=>[...ue,{ts:new Date().toISOString(),type:"error",text:e("flow:run.noBody")}]),tn("error");return}const ee=J.body.getReader(),te=new TextDecoder;let me="";const ye=ue=>{const $e=ue.ts||new Date().toISOString();if(ue.type==="event")if(ue.event==="node-start")Vn(Se=>new Set(Se).add(ue.instanceId)),kr(Se=>({...Se,[ue.instanceId]:{status:"running",startMs:Date.now()}})),pt(Se=>[...Se,{ts:$e,type:"node-start",text:ue.label?e("flow:run.nodeStartWithLabel",{instanceId:ue.instanceId,label:ue.label}):e("flow:run.nodeStart",{instanceId:ue.instanceId})}]);else if(ue.event==="node-done"){Vn(gt=>{const yn=new Set(gt);return yn.delete(ue.instanceId),yn});const Se=ue.elapsed??null;kr(gt=>({...gt,[ue.instanceId]:{status:"success",elapsed:Se}})),pt(gt=>[...gt,{ts:$e,type:"node-done",text:Se?e("flow:run.nodeDoneWithElapsed",{instanceId:ue.instanceId,elapsed:Se}):e("flow:run.nodeDone",{instanceId:ue.instanceId})}])}else if(ue.event==="node-failed")Vn(Se=>{const gt=new Set(Se);return gt.delete(ue.instanceId),gt}),kr(Se=>({...Se,[ue.instanceId]:{status:"failed",elapsed:ue.elapsed??null}})),pt(Se=>[...Se,{ts:$e,type:"node-failed",text:e("flow:run.nodeFailed",{instanceId:ue.instanceId})}]);else if(ue.event==="apply-start"){if(ue.uuid&&Jn(String(ue.uuid)),typeof ue.runStartTime=="number"&&ue.runStartTime>0)Wt(ue.runStartTime),Sr(Math.max(0,Date.now()-ue.runStartTime));else if(typeof ue.totalExecutedMs=="number"&&ue.totalExecutedMs>0){const Se=Date.now()-ue.totalExecutedMs;Wt(Se),Sr(ue.totalExecutedMs)}pt(Se=>[...Se,{ts:$e,type:"info",text:e("flow:run.pipelineStart",{uuid:ue.uuid||"?"})}])}else ue.event==="apply-done"?pt(Se=>[...Se,{ts:$e,type:"info",text:ue.totalElapsed?e("flow:run.pipelineDoneWithElapsed",{elapsed:ue.totalElapsed}):e("flow:run.pipelineDone")}]):ue.event==="apply-paused"?pt(Se=>[...Se,{ts:$e,type:"warn",text:e("flow:run.pipelinePaused",{nodes:(ue.pendingNodes||[]).join(", ")})}]):pt(Se=>[...Se,{ts:$e,type:"event",text:`[${ue.event}] ${JSON.stringify(ue)}`}]);else ue.type==="user-check-content"?(wl({instanceId:ue.instanceId,execId:ue.execId??1,inputPath:ue.inputPath,outputPath:ue.outputPath,content:ue.content||""}),Ii(ue.content||""),Do(!1),Fo(""),vl(!1),pt(Se=>[...Se,{ts:$e,type:"user-check",text:e("flow:run.userCheckContent",{instanceId:ue.instanceId})}])):ue.type==="user-ask-prompt"?(Ar({instanceId:ue.instanceId,execId:ue.execId??1,question:ue.question||"",options:Array.isArray(ue.options)?ue.options:[]}),ci(!1),pt(Se=>[...Se,{ts:$e,type:"user-ask",text:e("flow:run.userAskPrompt",{instanceId:ue.instanceId,defaultValue:`等待用户选择 (${ue.instanceId})`})}])):ue.type==="tool-print-content"?(zo({instanceId:ue.instanceId,execId:ue.execId??1,content:ue.content||"",createdAt:Date.now()}),Zu(!1)):ue.type==="log"?pt(Se=>[...Se,{ts:$e,type:"log",text:ue.text!=null?String(ue.text):""}]):ue.type==="error"?pt(Se=>[...Se,{ts:$e,type:"error",text:ue.message||e("flow:run.unknownError")}]):ue.type==="done"?pt(Se=>[...Se,{ts:$e,type:"done",text:e("flow:run.executionEnd",{exitCode:ue.exitCode??"?"})}]):pt(Se=>[...Se,{ts:$e,type:"log",text:JSON.stringify(ue)}])},Fe=ue=>{if(ue.trim())try{ye(JSON.parse(ue))}catch{pt($e=>[...$e,{ts:new Date().toISOString(),type:"log",text:ue}])}};for(;;){const{done:ue,value:$e}=await ee.read();me+=te.decode($e??new Uint8Array,{stream:!ue});const Se=me.split(`
133
- `);me=Se.pop()??"";for(const gt of Se)Fe(gt);if(ue)break}me.trim()&&Fe(me),tn("done")}catch(J){J.name==="AbortError"?(pt(ee=>[...ee,{ts:new Date().toISOString(),type:"warn",text:e("flow:run.executionStopped")}]),tn("stopped")):(pt(ee=>[...ee,{ts:new Date().toISOString(),type:"error",text:J.message||e("flow:run.unknownError")}]),tn("error"))}finally{oi.current=null,Vn(new Set)}},[c]),[l2,wy]=h.useState(!1),c2=h.useCallback(()=>{wy(!0)},[]),u2=h.useCallback(async()=>{if(wy(!1),oi.current&&(oi.current.abort(),oi.current=null),c)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source||"user"})})}catch{}tn("stopped"),Vn(new Set)},[c]),Rl=h.useCallback(()=>{tn("edit"),Vn(new Set),kr({}),Vr(null),Jn(null)},[]),[d2,qp]=h.useState(!1),f2=h.useCallback(async()=>{if(qp(!1),oi.current&&(oi.current.abort(),oi.current=null),c)try{await fetch("/api/flow/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source||"user"})})}catch{}Rl()},[c,Rl]),p2=h.useCallback(()=>{qp(!1),n("/projects")},[n]),h2=h.useCallback(x=>{const N=x.runId!=null&&String(x.runId).trim()?String(x.runId).trim():null,H=x.flowId!=null&&String(x.flowId).trim()?String(x.flowId).trim():(c==null?void 0:c.id)!=null?String(c.id):null;Jn(N);const q=x.status||"unknown";let Y="stopped";q==="success"?Y="done":q==="failed"?Y="error":q==="running"?Y="running":Y="stopped",tn(Y);const J=typeof x.at=="number"?x.at:null;if(Y==="running"&&J!=null?(Wt(J),Sr(Math.max(0,Date.now()-J))):J!=null&&typeof x.endedAt=="number"&&x.endedAt>J?(Wt(null),Sr(x.endedAt-J)):(Wt(null),Sr(Math.max(0,x.durationMs??0))),pt([]),Vn(new Set),kr({}),Vr(null),Dt(null),dr(!1),N&&H){const ee=new URLSearchParams({flowId:H,runId:N});fetch(`/api/run-node-statuses?${ee}`).then(te=>te.json()).then(te=>{const me=te.statuses&&typeof te.statuses=="object"?te.statuses:{},ye={};for(const[Fe,ue]of Object.entries(me))ue&&typeof ue=="object"&&typeof ue.status=="string"&&(ye[Fe]={status:ue.status,...ue.elapsed!=null&&String(ue.elapsed).trim()!==""?{elapsed:String(ue.elapsed)}:{}});kr(ye)}).catch(()=>{})}},[c==null?void 0:c.id]);h.useEffect(()=>{if(!(c!=null&&c.id)||Ee!=="edit")return;let x=!1;return(async()=>{try{const N=await fetch("/api/pipeline-recent-runs"),H=await N.json();if(x||!N.ok)return;const Y=(Array.isArray(H.runs)?H.runs:[]).find(te=>te.flowId===c.id&&te.status==="running");if(!Y||x)return;const J=Y.runId||null;Jn(J),tn("running"),dr(!0),Wt(Y.at||Date.now()),Le.current=0;const ee=[{ts:new Date().toISOString(),type:"info",text:`[resume] 检测到活跃 run ${J},已恢复运行视图`}];if(J){const te=new URLSearchParams({flowId:c.id,runId:J}),ye=await(await fetch(`/api/run-node-statuses?${te}`)).json();if(x)return;const Fe=ye.statuses&&typeof ye.statuses=="object"?ye.statuses:{},ue={},$e=new Set;for(const[Se,gt]of Object.entries(Fe))gt&&typeof gt=="object"&&typeof gt.status=="string"&&(ue[Se]={status:gt.status,...gt.elapsed!=null&&String(gt.elapsed).trim()!==""?{elapsed:String(gt.elapsed)}:{}},gt.status==="running"&&$e.add(Se));kr(ue),Vn($e);try{const Se=new URLSearchParams({flowId:c.id,runId:J,sinceBytes:"0",tailBytes:"262144"}),gt=await fetch(`/api/run-log?${Se}`);if(gt.ok){const yn=await gt.json();if(!x){Le.current=Number(yn.bytes||0);const xn=d1(typeof yn.text=="string"?yn.text:"");pt([...xn,...ee]);return}}}catch{}}pt(ee)}catch{}})(),()=>{x=!0}},[c==null?void 0:c.id]),h.useEffect(()=>{if(Ee==="edit"||!(c!=null&&c.id)||!un)return;let x=!1,N=null;const H=async()=>{try{const q=new URLSearchParams({flowId:c.id,runId:un}),Y=await fetch(`/api/run-node-statuses?${q}`);if(!Y.ok)return;const J=await Y.json();if(x)return;const ee=J.statuses&&typeof J.statuses=="object"?J.statuses:{},te={},me=new Set;for(const[ye,Fe]of Object.entries(ee))Fe&&typeof Fe=="object"&&typeof Fe.status=="string"&&(te[ye]={status:Fe.status,...Fe.elapsed!=null&&String(Fe.elapsed).trim()!==""?{elapsed:String(Fe.elapsed)}:{}},Fe.status==="running"&&me.add(ye));kr(ye=>k7(ye,te)?ye:te),Vn(ye=>S7(ye,me)?ye:me);try{const ye=new URLSearchParams({flowId:c.id,runId:un,sinceBytes:String(Le.current||0),tailBytes:String(x7)}),Fe=await fetch(`/api/run-log?${ye}`);if(Fe.ok){const ue=await Fe.json();if(x)return;const $e=Number(ue.bytes||0),Se=typeof ue.text=="string"?ue.text:"";if(Se){const gt=d1(Se);gt.length>0&&pt(yn=>[...yn,...gt])}Le.current=$e}}catch{}try{const ye=await fetch("/api/pipeline-recent-runs");if(!ye.ok)return;const Fe=await ye.json();if(x)return;const $e=(Array.isArray(Fe.runs)?Fe.runs:[]).find(Se=>Se.flowId===c.id&&Se.runId===un);if($e&&$e.status){const Se=$e.status;Se==="running"?tn(gt=>gt==="running"?gt:"running"):Se==="success"?tn("done"):Se==="failed"?tn("error"):(Se==="stopped"||Se==="interrupted")&&tn("stopped")}}catch{}}catch{}};return H(),N=window.setInterval(H,2500),()=>{x=!0,N&&window.clearInterval(N)}},[Ee,c==null?void 0:c.id,un]),h.useEffect(()=>{if(Ze!=="history"||!c)return;let x=!1;return(async()=>{ir(!0),Ft("");try{const N=await fetch("/api/pipeline-recent-runs"),H=await N.json();if(!N.ok)throw new Error(H.error||"HTTP "+N.status);x||Pe(Array.isArray(H.runs)?H.runs:[])}catch(N){x||(Ft(String(N.message||N)),Pe([]))}finally{x||ir(!1)}})(),()=>{x=!0}},[Ze,c]),h.useEffect(()=>{if(!c){st({files:[]});return}let x=!1;return(async()=>{_i(!0);try{const N=new URLSearchParams({flowId:c.id,flowSource:c.source||"user",archived:c.archived?"1":"0"}),H=await fetch(`/api/pipeline-files?${N}`),q=await H.json();if(!H.ok)throw new Error(q.error||"HTTP "+H.status);x||st({files:Array.isArray(q.files)?q.files:[],path:q.path,error:q.error})}catch(N){x||st({files:[],error:N.message||String(N)})}finally{x||_i(!1)}})(),()=>{x=!0}},[c]);const pd=h.useMemo(()=>c?ie.filter(x=>x&&x.flowId===c.id).sort((x,N)=>N.at-x.at):[],[ie,c]),as=h.useMemo(()=>{let x=0,N=0,H=0,q=0,Y=0;for(const J of pd){const ee=J.status||"unknown";ee==="success"?x+=1:ee==="failed"?N+=1:ee==="running"?H+=1:ee==="stopped"?q+=1:ee==="interrupted"&&(Y+=1)}return{success:x,failed:N,running:H,stopped:q,interrupted:Y}},[pd]),hd=h.useMemo(()=>c?i1(xs,ws):null,[c,xs,ws]),Mi=h.useMemo(()=>{if(!hd||!c)return[];const x=hd.query.toLowerCase(),N=Y=>x?Y.some(J=>J&&String(J).toLowerCase().includes(x)):!0,H=Ct.map(Y=>{var ye,Fe;const J=Y.id,ee=String(((ye=Y.data)==null?void 0:ye.label)??J),te=(Fe=Y.data)!=null&&Fe.definitionId?String(Y.data.definitionId):"",me=[ee!==J?ee:"",te&&te!==J?te:""].filter(Boolean);return{id:J,label:ee,defId:te,subs:me}}).filter(({id:Y,label:J,defId:ee})=>N([Y,J,ee])).sort((Y,J)=>Y.id.localeCompare(J.id)).slice(0,18).map(({id:Y,label:J,defId:ee})=>{const te=[J!==Y?J:null,ee||null].filter(Boolean).join(" · ")||void 0;return{kind:"instance",id:Y,title:Y,subtitle:te}}),q=ae.filter(Y=>Y&&Y.id&&N([Y.id,Y.label,Y.description])).sort((Y,J)=>Y.id.localeCompare(J.id)).slice(0,22).map(Y=>({kind:"definition",id:Y.id,title:Y.id,subtitle:Y.label&&Y.label!==Y.id?String(Y.label):String(Y.type||"")}));return[...H,...q]},[hd,Ct,ae,c]),md=h.useMemo(()=>{const x=Mi.filter(H=>H.kind==="instance"),N=Mi.filter(H=>H.kind==="definition");return{instances:x,definitions:N}},[Mi]);h.useEffect(()=>{di(x=>{const N=Math.max(0,Mi.length-1);return Math.min(Math.max(0,x),N)})},[Mi]);const q0=h.useMemo(()=>c7(xs),[xs]),Tr=h.useMemo(()=>Ct.filter(x=>x.selected),[Ct]),by=h.useMemo(()=>new Set(Tr.map(x=>x.id)),[Tr]),Yp=h.useMemo(()=>mn.filter(x=>by.has(x.source)&&by.has(x.target)),[mn,by]),Y0=h.useMemo(()=>{const x=_e.trim().toLowerCase();return x?ft.filter(N=>[N.id,N.version,N.displayName,N.name,N.description,...Array.isArray(N.tags)?N.tags:[]].filter(Boolean).some(H=>String(H).toLowerCase().includes(x))):ft},[ft,_e]),G0=h.useCallback((x,N)=>{const H=String(x||"snippet-node").trim().replace(/[^a-zA-Z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")||"snippet-node",q=Date.now().toString(36);let Y=`${H}-${q}`,J=2;for(;N.has(Y);)Y=`${H}-${q}-${J}`,J+=1;return N.add(Y),Y},[]),X0=h.useCallback((x,N)=>{var Gt,ls;if(!c||!x)return;const H=x.snippet&&typeof x.snippet=="object"?x.snippet:{},q=H.instances&&typeof H.instances=="object"?H.instances:{},Y=Object.keys(q);if(Y.length===0)return;const J=new Set(Us.current.map(Ye=>Ye.id)),ee={};for(const Ye of Y)ee[Ye]=G0(Ye,J);const te=(Gt=H.ui)!=null&&Gt.nodePositions&&typeof H.ui.nodePositions=="object"?H.ui.nodePositions:{},me=(ls=H.ui)!=null&&ls.nodeSizes&&typeof H.ui.nodeSizes=="object"?H.ui.nodeSizes:{},ye=Y.map(Ye=>{const wn=te[Ye];return{id:Ye,x:typeof(wn==null?void 0:wn.x)=="number"?wn.x:0,y:typeof(wn==null?void 0:wn.y)=="number"?wn.y:0}}),Fe=Math.min(...ye.map(Ye=>Ye.x)),ue=Math.min(...ye.map(Ye=>Ye.y));let $e=N||{x:180,y:160};const Se=Ri.current,gt=document.querySelector(".af-pipeline-flow .react-flow");if(!N&&Se&&gt){const Ye=gt.getBoundingClientRect();$e=Se.screenToFlowPosition({x:Ye.left+Ye.width*.48,y:Ye.top+Ye.height*.32})}const yn={};for(const Ye of Y)yn[ee[Ye]]={...q[Ye]||{}};Zn.current={...Zn.current,...yn};const xn=Y.map(Ye=>{const wn=q[Ye]||{},fo=ye.find(yd=>yd.id===Ye)||{x:0,y:0},$i=me[Ye]&&typeof me[Ye].width=="number"&&typeof me[Ye].height=="number"?{width:me[Ye].width,height:me[Ye].height}:null,Ol={id:ee[Ye],type:"flowNode",selected:!0,position:{x:$e.x+(fo.x-Fe),y:$e.y+(fo.y-ue)},...$i?{width:$i.width,height:$i.height}:{},data:{label:wn.label||ee[Ye],definitionId:wn.definitionId||Ye,role:wn.role||"normal",body:wn.body||"",script:wn.script||"",...$i?{displaySize:$i}:{}}};return qf(Ol,Zn.current,ae,{},c.id)}),Bt=new Set(Y),kt=(Array.isArray(H.edges)?H.edges:[]).filter(Ye=>Bt.has(Ye==null?void 0:Ye.source)&&Bt.has(Ye==null?void 0:Ye.target)).map((Ye,wn)=>({id:`e-${ee[Ye.source]}-${ee[Ye.target]}-${Date.now()}-${wn}`,source:ee[Ye.source],target:ee[Ye.target],sourceHandle:Ye.sourceHandle??void 0,targetHandle:Ye.targetHandle??void 0,markerEnd:{type:Ls.ArrowClosed}}));vt(Ye=>[...Ye.map(wn=>({...wn,selected:!1})),...xn]),Yt(Ye=>[...Ye.map(wn=>({...wn,selected:!1})),...kt]),j(`已添加流程片段:${x.displayName||x.id}`)},[G0,ae,c,Yt,vt]);Tl.current=X0;const m2=h.useCallback(()=>{var H,q;if(Tr.length<2){An("请先在画布上选择至少两个节点。"),Ie("flows");return}const x=Tr[0],N=Tr.length===2?`${((H=x.data)==null?void 0:H.label)||x.id} 片段`:`${((q=x.data)==null?void 0:q.label)||x.id} 等 ${Tr.length} 个节点`;Wn({name:N,id:N.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),ze(""),In(!0),Ie("flows")},[Tr]),g2=h.useCallback(async()=>{var J,ee;if(!c||Tr.length<2)return;const x=en.name.trim();if(!x){ze("请填写片段名称。");return}const N=hp(Tr,Zn.current),H={},q={};for(const te of Tr){H[te.id]={x:((J=te.position)==null?void 0:J.x)||0,y:((ee=te.position)==null?void 0:ee.y)||0};const me=C7(te);me&&(q[te.id]=me)}const Y=Yp.map(te=>({source:te.source,target:te.target,sourceHandle:te.sourceHandle??null,targetHandle:te.targetHandle??null}));ce(!0),ze("");try{const te=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:en.id,name:x,displayName:x,version:"1.0.0",description:en.description,snippet:{instances:N,edges:Y,ui:{nodePositions:H,nodeSizes:q}}})}),me=await te.json().catch(()=>({}));if(!te.ok||(me==null?void 0:me.ok)===!1)throw new Error((me==null?void 0:me.error)||"Publish failed");In(!1),j(`流程片段已发布:${me.id||x}`),Ds(`流程片段已发布:${me.id||x}`),await is(),Ie("flows")}catch(te){ze(String(te.message||te))}finally{ce(!1)}},[c,Tr,Yp,en,is,Ds]),Gp=h.useMemo(()=>{const x=[],N=new Set;for(const Y of Tr)N.add(Y.id),x.push({node:Y,kind:"canvas"});const H=new Map(Ct.map(Y=>[Y.id,Y])),q=new Map(ae.map(Y=>[Y.id,Y]));for(const Y of q0){if(N.has(Y))continue;const J=H.get(Y);if(J){N.add(Y),x.push({node:J,kind:"mention"});continue}const ee=q.get(Y);ee&&(N.add(Y),x.push({definition:ee,kind:"definition"}))}return x},[Tr,q0,Ct,ae]),ks=h.useMemo(()=>{const x=Array.isArray(wt==null?void 0:wt.cursor)?wt.cursor:[],N=Array.isArray(wt==null?void 0:wt.opencode)?wt.opencode:[],H=Array.isArray(wt==null?void 0:wt.claudeCode)?wt.claudeCode:[],q=N.map(ye=>`opencode:${Qo(ye)}`),Y=H.map(ye=>`claude-code:${Qo(ye)}`),J=new Set([...x,...N,...H].map(Qo).concat(q).concat(Y)),ee=(fi||"").trim(),te=Rh(fi,x,N,H),me=te&&!J.has(te)&&!J.has(ee)?ee:"";return{cursorList:x,opencodeList:N,claudeCodeList:H,currentNotInLists:me}},[wt,fi]),vy=h.useMemo(()=>new Set(bs),[bs]),ky=bs.length,Xp=h.useMemo(()=>{const x=new Map(pi.map(J=>[J.key,J])),N=new Set,H=new Set,q=Nl.map(J=>{const ee=il(J,pi).map(te=>x.get(te)).filter(Boolean);for(const te of ee)N.add(te.key),H.add(String(te.name||te.id||te.key||"").trim());return{...J,skills:ee}}).filter(J=>J.skills.length>0),Y=pi.filter(J=>{const ee=String(J.name||J.id||J.key||"").trim();return!N.has(J.key)&&!H.has(ee)});return{groups:q,ungrouped:Y}},[Nl,pi]),_c=h.useCallback(()=>{const x=qt.current;if(!x)return;const N=x.getBoundingClientRect(),H=Math.min(400,Math.max(300,window.innerWidth-24)),q=Math.min(Math.max(12,N.right-H),window.innerWidth-H-12),Y=Math.max(140,N.top-22),J=Math.min(360,Y);od({position:"fixed",left:`${q}px`,top:`${Math.max(12,N.top-J-10)}px`,width:`${H}px`,maxHeight:`${J}px`})},[]);h.useEffect(()=>{const x=Array.isArray(wt==null?void 0:wt.cursor)?wt.cursor:[],N=Array.isArray(wt==null?void 0:wt.opencode)?wt.opencode:[],H=Array.isArray(wt==null?void 0:wt.claudeCode)?wt.claudeCode:[];Sl(q=>{const Y=Rh(q,x,N,H);return Y===q?q:Y})},[wt.cursor,wt.opencode,wt.claudeCode]),h.useEffect(()=>{if(!Ti)return;_c();const x=H=>{var Y,J;const q=H.target;(Y=qt.current)!=null&&Y.contains(q)||(J=yc.current)!=null&&J.contains(q)||ut(!1)},N=H=>{H.key==="Escape"&&ut(!1)};return window.addEventListener("resize",_c),window.addEventListener("scroll",_c,!0),document.addEventListener("pointerdown",x),document.addEventListener("keydown",N),()=>{window.removeEventListener("resize",_c),window.removeEventListener("scroll",_c,!0),document.removeEventListener("pointerdown",x),document.removeEventListener("keydown",N)}},[Ti,_c]);const Ll=h.useCallback(async(x,N={})=>{var kt;if(!c||Sc.current)return;const H=N.phaseContextSnapshot,q=(typeof x=="string"?x:xs).trim();if(!q)return;const Y=ld.current;Sc.current=!0,$p(!0),Ws(e("flow:composer.connecting")),Dt(Gt=>Gt!=="composer"?"composer":Gt);const J=[...ao];if(Y.length>0&&J.push({type:"assistant",segments:[...Y]}),Dp([...J,{type:"user",text:q}]),J.filter(Gt=>Gt.type==="user").length===0){const Gt=q.replace(/\s+/g," ").slice(0,30)+(q.length>30?"…":"");qr(ls=>ls.map(Ye=>Ye.id===Qn?{...Ye,label:Gt}:Ye))}const ee=J.map(Gt=>Gt.type==="user"?{role:"user",text:Gt.text}:{role:"assistant",text:(Gt.segments||[]).filter(Ye=>Ye.kind==="assistant"||Ye.kind==="result").map(Ye=>Ye.text).join(`
134
- `)}).filter(Gt=>Gt.text),te=H??Nt;Ae(""),Vs([]),hi([]),Fp(!1);const me=new AbortController;_l.current=me,kc.current=Qn;let ye=null;const Fe=Array.isArray(wt==null?void 0:wt.cursor)?wt.cursor:[],ue=Array.isArray(wt==null?void 0:wt.opencode)?wt.opencode:[],$e=Array.isArray(wt==null?void 0:wt.claudeCode)?wt.claudeCode:[],Se=Rh(fi,Fe,ue,$e),gt=Gp.filter(Gt=>Gt.kind!=="definition"&&Gt.node).map(Gt=>Gt.node.id),yn=c;let xn=!1,Bt=!1;try{ye=setTimeout(()=>me.abort(),12e4);const Gt={prompt:q,model:Se,flowId:c.id,flowSource:c.source??"user",...c.archived?{flowArchived:!0}:{},contextInstanceIds:gt,thread:ee,selectedSkills:bs};te&&te.nextPhase&&!te.isLastPhase&&(Gt.phaseContext={phaseIndex:te.nextPhase.index,phases:te.phases,userPromptOriginal:te.userPromptOriginal||q}),gc&&(Gt.phaseRole=gc);const ls=await fetch("/api/composer-agent",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Gt),signal:me.signal});if(ye&&(clearTimeout(ye),ye=null),!ls.ok){let $i=ls.statusText||e("flow:composer.requestFailed");try{const Ol=await ls.json();Ol&&Ol.error&&($i=String(Ol.error))}catch{}Ws($i),Vs([{kind:"error",text:$i}]);return}const Ye=(kt=ls.body)==null?void 0:kt.getReader();if(!Ye){Ws(e("flow:composer.cannotReadStream"));return}const wn=new TextDecoder;let fo="";for(;;){const{done:$i,value:Ol}=await Ye.read();if($i)break;for(fo+=wn.decode(Ol,{stream:!0});;){const yd=fo.indexOf(`
135
- `);if(yd<0)break;const rk=fo.slice(0,yd).trim();if(fo=fo.slice(yd+1),!rk)continue;let Ge;try{Ge=JSON.parse(rk)}catch{continue}if(Ge.type==="status"&&typeof Ge.line=="string"&&Ws(Ge.line),Ge.type==="natural"&&typeof Ge.text=="string"&&Ge.text){const jn=typeof Ge.kind=="string"&&Ge.kind?Ge.kind:"assistant";Vs(bn=>[...bn,{kind:jn,text:Ge.text}])}if(Ge.type==="error"&&Ge.message){Bt=!0;const jn=Ge.code?` [${Ge.code}]`:"",bn=String(Ge.message)+jn;Ws(bn),Vs(Ss=>[...Ss,{kind:"error",text:bn}])}if(Ge.type==="plan"&&Array.isArray(Ge.steps)){hi(Ge.steps.map(bn=>({...bn,status:"pending"})));const jn=Ge.steps.map((bn,Ss)=>`${Ss+1}. ${bn.description||bn.type}`).join(`
136
- `);Vs(bn=>[...bn,{kind:"assistant",text:e("flow:composer.taskPlan",{count:Ge.steps.length,summary:jn})}])}if(Ge.type==="step-start"){const jn=Ge.index??0,bn=Ge.total??0,Ss=Ge.tier?` [${Ge.tier}]`:"",k2=Ge.model?` (${Ge.model})`:"";Ws(e("flow:composer.step",{current:jn+1,total:bn,description:(Ge.description||"")+Ss+k2})),hi(S2=>S2.map(Pc=>Pc.index===jn?{...Pc,status:"running",model:Ge.model,tier:Ge.tier,nodeRole:Ge.nodeRole??Pc.nodeRole,instanceId:Ge.instanceId??Pc.instanceId,instanceLabel:Ge.instanceLabel??Pc.instanceLabel}:Pc))}if(Ge.type==="step-progress"){const jn=Ge.index??0,bn=Ge.total??0;Ws(e("flow:composer.step",{current:jn+1,total:bn,description:Ge.description||""}))}if(Ge.type==="step-done"){const jn=Ge.index??0;hi(bn=>bn.map(Ss=>Ss.index===jn?{...Ss,status:Ge.success?"done":"error"}:Ss))}if(Ge.type==="phase-plan"&&Array.isArray(Ge.phases)){Al(bn=>({...bn||{},phases:Ge.phases,currentPhase:Ge.currentPhase??0,phaseTotal:Ge.phaseTotal??Ge.phases.length,phaseName:Ge.phaseName||"",isLastPhase:!1,nextPhase:null,userPromptOriginal:(bn==null?void 0:bn.userPromptOriginal)||q}));const jn=Ge.phases.map((bn,Ss)=>`${Ss+1}. ${bn.label}`).join(" → ");Vs(bn=>[...bn,{kind:"assistant",text:e("flow:composer.phaseGeneration",{count:Ge.phases.length,labels:jn,current:Ge.phaseName||""})}])}Ge.type==="phase-complete"&&(Al(jn=>{var Ss;return{...jn||{},phases:Ge.phases||(jn==null?void 0:jn.phases)||[],currentPhase:Ge.phaseIndex??0,phaseTotal:Ge.phaseTotal??((Ss=Ge.phases)==null?void 0:Ss.length)??0,phaseName:Ge.phaseName||"",isLastPhase:!!Ge.isLastPhase,nextPhase:Ge.nextPhase||null,userPromptOriginal:Ge.userPromptOriginal||(jn==null?void 0:jn.userPromptOriginal)||q}}),!Ge.isLastPhase&&Ge.nextPhase&&Vs(jn=>[...jn,{kind:"assistant",text:e("flow:composer.phaseComplete",{phaseName:Ge.phaseName||e("flow:composer.nextPhase"),nextPhase:Ge.nextPhase.label})}])),Ge.type==="done"&&(xn=!0,Ws(jn=>jn||e("flow:composer.done")))}}}catch(Gt){const ls=Gt;if(ls.name==="AbortError"){const Ye=e(ye?"flow:composer.connectTimeout":"flow:composer.aborted");Ws(Ye),Vs(wn=>[...wn,{kind:"error",text:Ye}])}else{const Ye=ls.code||ls.name||"UNKNOWN",wn=`${ls.message||String(Gt)} [${Ye}]`;Ws(wn),Vs(fo=>[...fo,{kind:"error",text:wn}])}}finally{if(Sc.current=!1,$p(!1),_l.current=null,kc.current=null,ye&&clearTimeout(ye),xn&&yn){const Gt={id:yn.id,source:yn.source??"user",archived:yn.archived};(async()=>(await Un(Gt,{preserveComposer:!0,incrementalSync:!0}),await oe(Gt,{quiet:!0,force:!0})))()}}},[c,xs,fi,wt,Gp,Un,oe,ao,Qn,Nt,gc,bs]);Pl.current=Ll;const J0=h.useCallback(()=>{!Nt||Nt.isLastPhase||(Al(null),Ll(e("flow:composer.skipRemainingPhases")))},[Nt,Ll]),Q0=h.useCallback(()=>{if(!Nt||Nt.isLastPhase||!Nt.nextPhase)return;const x=String(Nt.nextPhase.label||"").trim()||e("flow:composer.nextPhase");Ll(e("flow:composer.continuePhase",{label:x}),{phaseContextSnapshot:Nt})},[Nt,Ll]);h.useEffect(()=>{if(!vc)return;const x=N=>{N.key==="Escape"&&Vo(!1)};return window.addEventListener("keydown",x),()=>window.removeEventListener("keydown",x)},[vc]),h.useEffect(()=>{Ee!=="edit"&&Vo(!1)},[Ee]),h.useLayoutEffect(()=>{const x=td.current;if(!x)return;if(!c){x.style.height="";return}x.style.height="0px";const N=getComputedStyle(x),H=parseFloat(N.lineHeight),q=(parseFloat(N.paddingTop)||0)+(parseFloat(N.paddingBottom)||0),Y=Number.isFinite(H)&&H>0?H:13*1.45,J=q+Y*2,ee=q+Y*10,te=Math.min(Math.max(x.scrollHeight,J),ee);x.style.height=`${te}px`},[xs,c]);const Sy=h.useCallback(x=>{const N=xs,H=ws,q=i1(N,H);if(!q)return;const Y=N.slice(0,q.atIndex)+`@${x} `+N.slice(H);Ae(Y);const J=q.atIndex+x.length+2;queueMicrotask(()=>{const ee=td.current;ee&&(ee.focus(),ee.setSelectionRange(J,J)),Sa(J)})},[xs,ws]),Ny=h.useCallback(x=>{Ae(N=>{const H=`@${x}`,q=N.indexOf(H);return q<0?N:N.slice(0,q)+N.slice(q+H.length)})},[]),Z0=h.useCallback(x=>{x.kind==="canvas"?vt(N=>N.map(H=>H.id===x.node.id?{...H,selected:!1}:H)):x.kind==="mention"?Ny(x.node.id):Ny(x.definition.id)},[vt,Ny]),y2=h.useCallback(()=>{Dt(x=>x==="history"?null:"history")},[]),x2=h.useCallback(()=>{Dt(x=>x==="settings"?null:"settings")},[]),w2=h.useCallback(()=>{Dt(x=>x==="composer"?null:"composer")},[]),gd=h.useCallback(()=>{Dt(x=>(x==="node"&&ja.current&&(nd.current=ja.current.id),null))},[]),ek=h.useCallback(()=>{ro(x=>!x)},[]),b2=()=>{if(!c)return null;const x=Ai||c.archived||xi(c.source),N=zt!=null&&zt.running?e("flow:schedule.running"):or.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled"),H=zt!=null&&zt.running?"running":or.enabled?"waiting":"disabled",q=tt.slice(0,12),Y=c.archived||xi(c.source);return o.jsxs("section",{className:"af-pipeline-settings-page","aria-label":e("flow:settings.title"),children:[o.jsxs("aside",{className:"af-pipeline-settings-nav","aria-label":e("flow:settings.sectionNav"),children:[o.jsx("div",{className:"af-pipeline-settings-nav-title",children:e("flow:settings.title")}),o.jsxs("a",{href:"#pipeline-basic",className:"af-pipeline-settings-nav-item af-pipeline-settings-nav-item--active",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"badge"}),e("flow:settings.basicInfo")]}),o.jsxs("a",{href:"#pipeline-storage",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),e("flow:settings.storageAndPath")]}),o.jsxs("a",{href:"#pipeline-marketplace",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"deployed_code"}),e("flow:settings.nodeMarketplace")]}),o.jsxs("a",{href:"#pipeline-schedule",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"schedule"}),e("flow:schedule.title")]}),o.jsxs("a",{href:"#pipeline-metadata",className:"af-pipeline-settings-nav-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"dataset"}),e("flow:pipeline.metadata")]}),o.jsxs("button",{type:"button",className:"af-pipeline-settings-nav-link",onClick:()=>n("/settings"),children:[e("flow:settings.globalSettings"),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})]}),o.jsxs("main",{className:"af-pipeline-settings-main",children:[o.jsxs("div",{className:"af-pipeline-settings-main-head",children:[o.jsxs("div",{children:[o.jsx("h1",{className:"af-pipeline-settings-title",children:e("flow:settings.title")}),o.jsx("p",{className:"af-pipeline-settings-subtitle",children:e("flow:settings.subtitle")})]}),o.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:gd,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),o.jsxs("section",{id:"pipeline-basic",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"1."}),o.jsx("h2",{children:e("flow:settings.basicInfo")})]}),o.jsxs("div",{className:"af-pipeline-settings-grid af-pipeline-settings-grid--two",children:[o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(c.source==="user"||c.source==="workspace")&&!c.archived?o.jsxs("div",{className:"af-pipeline-rename-row",children:[o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:D,onChange:J=>{F(J.target.value),O("")},onKeyDown:J=>{J.key==="Enter"&&(J.preventDefault(),Vp())},onBlur:()=>{D.trim()&&D.trim()!==c.id&&Vp()},placeholder:c.id,disabled:R,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:Oc(c.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[c.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:Oc(c.source??"user",e)}),c.archived?o.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),W?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:W}):null]}),o.jsxs("div",{className:"af-pipeline-settings-kv-block",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.owner")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"person"}),c.owner||"bigo"]})]})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea af-pipeline-settings-textarea",value:b,onChange:J=>k(J.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:4,spellCheck:!1})]})]}),o.jsxs("section",{id:"pipeline-storage",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"2."}),o.jsx("h2",{children:e("flow:settings.storageAndPath")})]}),typeof c.path=="string"&&c.path?o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[o.jsx("span",{className:"af-pipeline-path-text",children:c.path}),o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>W0(c.path),title:e("flow:settings.copyPath"),children:o.jsx("span",{className:"material-symbols-outlined",children:$?"check":"content_copy"})})]})]}):null,c.source==="user"||c.source==="workspace"?c.archived?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),o.jsx("div",{className:"af-pipeline-move-actions",children:c.source==="user"?o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:L,onClick:()=>Wp("workspace"),children:e(L?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:L,onClick:()=>Wp("user"),children:e(L?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),P?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:P}):null]}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")})]}),o.jsxs("section",{id:"pipeline-marketplace",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"3."}),o.jsx("h2",{children:e("flow:settings.nodeMarketplace")})]}),o.jsxs("div",{className:"af-pipeline-market-row",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"af-pipeline-market-count",children:[tt.length," ",e("flow:settings.marketNodesUnit")]}),o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.marketplaceHint")})]}),o.jsxs("button",{type:"button",className:"af-btn-secondary",onClick:fn,disabled:Xt,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),e(Xt?"common:common.loading":"common:common.refresh")]})]}),vn?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:vn}):null,Xt?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):q.length>0?o.jsx("div",{className:"af-pipeline-market-list",children:q.map(J=>{const ee=J.definitionId||`marketplace:${J.id}${J.version?`@${J.version}`:""}`,te=jr.has(ee)||jr.has(`marketplace:${J.id}`),me=Pt.find($e=>String($e.id)===ee||String($e.id)===`marketplace:${J.id}`),ye=hn===ee,Fe=Th(J.inputs||J.input),ue=Th(J.outputs||J.output);return o.jsxs("div",{className:"af-pipeline-market-item",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:te?"check_circle":"extension"}),o.jsxs("div",{className:"af-pipeline-market-main",children:[o.jsxs("div",{className:"af-pipeline-market-title-row",children:[o.jsx("strong",{children:J.displayName||J.label||J.id}),o.jsx("span",{children:J.version?`v${J.version}`:ee})]}),o.jsx("p",{className:"af-pipeline-market-purpose",children:J.description||e("flow:settings.marketplaceNoDescription")}),o.jsxs("div",{className:"af-pipeline-market-io",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-market-io-label",children:"Inputs"}),o.jsx("div",{className:"af-pipeline-market-chips",children:Fe.length>0?Fe.map($e=>o.jsx("span",{className:"af-pipeline-market-chip",children:$e},`in-${ee}-${$e}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-market-io-label",children:"Outputs"}),o.jsx("div",{className:"af-pipeline-market-chips",children:ue.length>0?ue.map($e=>o.jsx("span",{className:"af-pipeline-market-chip",children:$e},`out-${ee}-${$e}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]})]}),o.jsxs("div",{className:"af-pipeline-market-actions",children:[o.jsx("button",{type:"button",className:"af-btn-secondary af-pipeline-market-action",onClick:()=>Me(J),children:e("flow:settings.previewNode")}),o.jsx("button",{type:"button",className:te?"af-btn-secondary af-pipeline-market-action":"af-btn-primary af-pipeline-market-action",disabled:Y||ye,onClick:()=>{te&&me?(Hp(me),Dt(null)):Cc(J)},children:e(ye?"flow:settings.installingNode":te?"flow:settings.addInstalledNode":"flow:settings.installNode")})]})]},ee)})}):o.jsx("div",{className:"af-pipeline-settings-empty",children:e("flow:settings.marketplaceEmpty")})]}),o.jsxs("section",{id:"pipeline-schedule",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"4."}),o.jsx("h2",{children:e("flow:schedule.title")})]}),Gu?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-settings-schedule-grid",children:[o.jsxs("label",{className:"af-new-pipeline-radio af-pipeline-settings-checkbox",children:[o.jsx("input",{type:"checkbox",checked:!!or.enabled,disabled:x,onChange:J=>ne(ee=>({...ee,enabled:J.target.checked}))}),o.jsx("span",{children:e("flow:schedule.enabled")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:or.cron||"",disabled:x,onChange:J=>ne(ee=>({...ee,cron:J.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:or.timezone||"",disabled:x,onChange:J=>ne(ee=>({...ee,timezone:J.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),o.jsxs("select",{className:"af-pipeline-flow-select",value:or.preset||"",disabled:x,onChange:J=>ne(ee=>({...ee,preset:J.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(dn).map(J=>o.jsx("option",{value:J,children:J},J))]})]})]}),o.jsxs("div",{className:"af-pipeline-settings-schedule-status",children:[o.jsx("span",{className:`af-pipeline-settings-status-dot af-pipeline-settings-status-dot--${H}`}),o.jsx("span",{children:or.nextRunAt?e("flow:schedule.nextRun",{time:new Date(or.nextRunAt).toLocaleString()}):e("flow:schedule.noNextRun")}),o.jsxs("span",{children:[e("flow:schedule.runtime"),":",N]})]}),o.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[Vt.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Vt.lastTriggeredAt).toLocaleString()})]}):null,Vt.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Vt.lastSkippedAt).toLocaleString(),Vt.lastSkipReason?` · ${Vt.lastSkipReason}`:""]})]}):null,Vt.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Vt.lastRunUuid})]}):null,Vt.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Vt.lastExitCode)})]}):null,Vt.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Vt.lastFinishedAt).toLocaleString()})]}):null]}),zt!=null&&zt.lastError||Vt.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(zt==null?void 0:zt.lastError)||Vt.lastError}):null,c.archived||xi(c.source)?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,ml?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:ml}):null,gl?o.jsx("p",{className:"af-pipeline-drawer-muted",children:gl}):null]})]}),o.jsxs("section",{id:"pipeline-metadata",className:"af-pipeline-settings-section",children:[o.jsxs("div",{className:"af-pipeline-settings-section-head",children:[o.jsx("span",{className:"af-pipeline-settings-section-index",children:"5."}),o.jsx("h2",{children:e("flow:pipeline.metadata")})]}),o.jsxs("dl",{className:"af-pipeline-meta-dl af-pipeline-settings-dl",children:[o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsxs("dd",{children:[Ct.length," ",e("flow:pipeline.nodesUnit")]})]}),o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:settings.marketplaceNodes")}),o.jsx("dd",{children:Pt.length})]}),o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:settings.source")}),o.jsx("dd",{children:Oc(c.source??"user",e)})]})]})]})]}),o.jsxs("aside",{className:"af-pipeline-settings-side","aria-label":e("flow:settings.overview"),children:[o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsxs("div",{className:"af-pipeline-settings-overview-head",children:[o.jsx("span",{className:"af-pipeline-settings-overview-icon material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),o.jsxs("div",{children:[o.jsx("h2",{children:c.id}),o.jsx("span",{className:`af-pipeline-settings-status af-pipeline-settings-status--${H}`,children:N})]})]}),o.jsxs("dl",{className:"af-pipeline-settings-side-dl",children:[o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsx("dd",{children:Ct.length})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.owner")}),o.jsx("dd",{children:c.owner||"bigo"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.source")}),o.jsx("dd",{children:Oc(c.source??"user",e)})]})]})]}),o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsx("h2",{children:e("flow:settings.quickActions")}),o.jsxs("button",{type:"button",className:"af-btn-primary af-pipeline-settings-side-action",onClick:()=>void n2(),disabled:Ai,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"save"}),e(Ai?"flow:settings.savingChanges":"flow:settings.saveChanges")]}),o.jsxs("button",{type:"button",className:"af-btn-secondary af-pipeline-settings-side-action",onClick:gd,children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),e("flow:settings.backToCanvas")]})]}),o.jsxs("section",{className:"af-pipeline-settings-side-card",children:[o.jsx("h2",{children:e("flow:settings.help")}),o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.helpText")}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]})]})]})},v2=()=>{const x=xe;if(!x)return null;const N=x.definitionId||`marketplace:${x.id}${x.version?`@${x.version}`:""}`,H=x.displayName||x.label||x.id,q=Th(x.inputs||x.input),Y=Th(x.outputs||x.output);return Or.createPortal(o.jsx("div",{className:"af-market-preview-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:settings.nodePreviewTitle"),onMouseDown:J=>{J.target===J.currentTarget&&Me(null)},children:o.jsxs("div",{className:"af-market-preview-dialog",children:[o.jsxs("div",{className:"af-market-preview-head",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:settings.nodePreviewTitle")}),o.jsx("h2",{children:H})]}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Me(null),"aria-label":e("flow:settings.closePreview"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-market-preview-body",children:[o.jsx("section",{className:"af-market-preview-visual","aria-label":e("flow:settings.nodeStylePreview"),children:o.jsxs("div",{className:"af-market-preview-node",children:[o.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--left",children:(q.length>0?q:[""]).slice(0,4).map((J,ee)=>o.jsx("span",{title:J},`preview-in-${ee}`))}),o.jsxs("div",{className:"af-market-preview-node-main",children:[o.jsx("span",{className:"af-market-preview-node-icon material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("strong",{children:H}),o.jsx("span",{children:N})]}),o.jsx("div",{className:"af-market-preview-node-ports af-market-preview-node-ports--right",children:(Y.length>0?Y:[""]).slice(0,4).map((J,ee)=>o.jsx("span",{title:J},`preview-out-${ee}`))})]})}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:e("flow:settings.nodeFunction")}),o.jsx("p",{children:x.description||e("flow:settings.marketplaceNoDescription")})]}),o.jsxs("div",{className:"af-market-preview-io-grid",children:[o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:"Inputs"}),o.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:q.length>0?q.map(J=>o.jsx("span",{className:"af-pipeline-market-chip",children:J},`preview-input-${J}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noInputs")})})]}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:"Outputs"}),o.jsx("div",{className:"af-pipeline-market-chips af-market-preview-chips",children:Y.length>0?Y.map(J=>o.jsx("span",{className:"af-pipeline-market-chip",children:J},`preview-output-${J}`)):o.jsx("span",{className:"af-pipeline-market-chip af-pipeline-market-chip--muted",children:e("flow:settings.noOutputs")})})]})]}),o.jsxs("section",{className:"af-market-preview-section",children:[o.jsx("h3",{children:e("flow:settings.nodePackageInfo")}),o.jsxs("dl",{className:"af-market-preview-dl",children:[o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.definitionId")}),o.jsx("dd",{children:N})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.version")}),o.jsx("dd",{children:x.version||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.packagePath")}),o.jsx("dd",{children:x.packageDir||"-"})]}),o.jsxs("div",{children:[o.jsx("dt",{children:e("flow:settings.packagedFiles")}),o.jsx("dd",{children:Array.isArray(x.packagedFiles)&&x.packagedFiles.length>0?x.packagedFiles.map(J=>J.to||J).join(", "):"-"})]})]})]})]})]})}),document.body)};return o.jsxs(Jg,{children:[o.jsx(y7,{onReady:a}),o.jsxs(VT.Provider,{value:{modelLists:wt,onModelChange:r2},children:[o.jsxs("div",{className:"af-pipeline-page"+(Ee!=="edit"?" af-pipeline-page--run-mode":""),children:[o.jsxs("header",{className:"af-pipeline-top",children:[o.jsxs("div",{className:"af-pipeline-top-left",children:[o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>{Ee==="running"?qp(!0):Ee!=="edit"?Rl():n("/projects")},"aria-label":e(Ee!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),title:e(Ee!=="edit"?"flow:topbar.backToEdit":"flow:topbar.backToProjects"),children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsxs("div",{className:"af-pipeline-brand",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:"PIPELINE"}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",YK,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",className:"af-view-switch__active",children:"Pipeline"}),o.jsx("button",{type:"button",onClick:()=>n(Af(c,"workspace")),children:"Workspace"}),o.jsx("button",{type:"button",onClick:()=>n(Af(c,"display")),children:"Display"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-flow-toolbar-actions",children:[Fs&&o.jsx("button",{type:"button",className:"af-icon-btn"+(ms?" af-icon-btn--active":""),"aria-label":"Composer Logs (dev)",title:"Composer Logs (dev)",onClick:()=>Lo(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"description"})}),Ee==="running"&&o.jsxs("div",{className:"af-run-timer",children:[o.jsx("span",{className:"af-run-timer__dot"}),o.jsx("span",{className:"af-run-timer__label",children:"RUNTIME"}),o.jsx("span",{className:"af-run-timer__value",children:Px(nn,"running")})]}),Ee==="stopped"&&o.jsxs("div",{className:"af-run-timer af-run-timer--stopped",children:[o.jsx("span",{className:"af-run-timer__label",children:"PAUSED"}),o.jsx("span",{className:"af-run-timer__value",children:Px(nn,"stopped")})]}),(Ee==="done"||Ee==="error")&&o.jsxs("div",{className:"af-run-timer"+(Ee==="error"?" af-run-timer--error":" af-run-timer--done"),children:[o.jsx("span",{className:"af-run-timer__label",children:Ee==="error"?"FAILED":"COMPLETED"}),o.jsx("span",{className:"af-run-timer__value",children:Px(nn,Ee)})]}),Ee!=="edit"&&o.jsx("button",{type:"button",className:"af-icon-btn"+(Qe?" af-icon-btn--active":""),"aria-label":e("flow:topbar.executionLog"),title:e("flow:topbar.executionLog"),onClick:()=>dr(x=>!x),children:o.jsx("span",{className:"material-symbols-outlined",children:"terminal"})}),Ee==="edit"&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-icon-btn"+(Ze==="history"?" af-icon-btn--active":""),"aria-label":e("flow:topbar.history"),title:e("flow:topbar.history"),disabled:!c,onClick:y2,children:o.jsx("span",{className:"material-symbols-outlined",children:"history"})}),o.jsx("button",{type:"button",className:"af-icon-btn"+(Ze==="settings"?" af-icon-btn--active":""),onClick:x2,"aria-label":e("flow:topbar.pipelineSettings"),title:e("flow:topbar.pipelineSettings"),disabled:!c,children:o.jsx("span",{className:"material-symbols-outlined",children:"settings"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(Ze==="composer"?" af-composer-topbar-btn--active":"")+(Sn?" af-composer-topbar-btn--running":""),onClick:w2,"aria-label":"AI Composer",title:"AI Composer",disabled:!c,children:"AI"}),o.jsx("button",{type:"button",className:"af-icon-btn af-shortcuts-trigger"+(fr?" af-icon-btn--active":""),onClick:ek,"aria-label":e("flow:topbar.shortcutsLabel"),title:e("flow:topbar.shortcutsTitle"),disabled:!c,children:o.jsx("span",{className:"af-shortcuts-trigger__mark","aria-hidden":!0,children:"?"})}),o.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger","aria-label":e("flow:topbar.deletePipeline"),title:e("flow:topbar.deletePipeline"),disabled:!c||xi(c.source)||c.source!=="user"&&c.source!=="workspace",onClick:()=>E(!0),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),o.jsx("button",{type:"button",className:"af-btn-pipeline-archive",disabled:!c||xi(c.source)||c.archived||c.source!=="user"&&c.source!=="workspace",onClick:()=>C(!0),children:"Archive"})]}),Ee==="running"?o.jsxs("button",{type:"button",className:"af-btn-run-stop",onClick:c2,title:e("flow:run.pauseRun"),children:[o.jsx("span",{className:"material-symbols-outlined",children:"pause"}),"Pause"]}):Ee==="ready"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!c,onClick:()=>void uo(),title:e("flow:topbar.startRun"),children:e("flow:topbar.startRun")}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Rl,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Ee==="stopped"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!c,onClick:()=>void uo({runUuid:un}),title:un?e("flow:topbar.resumeTitle",{uuid:un}):e("flow:topbar.resumeTitleNoUuid"),children:"Resume"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Rl,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):Ee==="done"||Ee==="error"?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!c,onClick:()=>void uo(),title:e("flow:topbar.rerunTitle"),children:"Run"}),o.jsxs("button",{type:"button",className:"af-btn-pipeline-save",onClick:Rl,children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),"Edit"]})]}):o.jsxs("div",{className:"af-run-btn-group",children:[o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg af-run-btn-main",disabled:!c,onClick:()=>void uo(),children:"Run"}),o.jsx("button",{type:"button",className:"af-run-btn-dropdown",disabled:!c,onClick:()=>Te(x=>!x),"aria-label":e("flow:topbar.runOptions"),"aria-expanded":ge,children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_drop_down"})}),ge&&c&&o.jsxs("div",{className:"af-run-dropdown-menu",children:[o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var N,H,q,Y,J;Te(!1);const x={};for(const ee of A){const te=U[ee.id];te&&(x[te]=((N=ii[te])==null?void 0:N.value)??((H=ii[te])==null?void 0:H.path)??((J=(Y=(q=ee.data)==null?void 0:q.outputs)==null?void 0:Y[0])==null?void 0:J.default)??"")}Rt(x),We(!0)},children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),e("flow:topbar.runWithParams")]}),o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{Te(!1),uo({prepareOnly:!0})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"tune"}),e("flow:topbar.editRun")]}),o.jsx("div",{className:"af-run-dropdown-divider"}),o.jsxs("div",{className:"af-run-dropdown-section",children:[o.jsx("span",{className:"af-run-dropdown-section-label",children:e("flow:topbar.runWithPreset")}),o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{Te(!1),uo()},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runPreset.default")]}),Object.keys(dn).map(x=>o.jsxs("button",{type:"button",className:"af-run-dropdown-item",onClick:()=>{var q;Te(!1);const N=dn[x]||{},H={};for(const Y of A){const J=U[Y.id];if(!J)continue;const ee=((q=Y.data)==null?void 0:q.definitionId)||"",te=N[Y.id]??"";ee.startsWith("provide_file")?H[J]={type:"file",path:te}:H[J]={type:"str",value:te}}uo({cliInputsOverride:H})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"bookmark"}),x]},x))]})]})]})]})]}),it?o.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsx("span",{children:it}),o.jsx("button",{type:"button",onClick:()=>ot(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-pipeline-body"+(Ee!=="edit"?" af-pipeline-body--run-mode":""),children:[Ee==="edit"&&Ze!=="settings"?o.jsxs("aside",{className:"af-node-palette af-flow-left-panel",id:"af-node-palette","aria-label":e("flow:palette2.nodePalette"),children:[o.jsxs("div",{className:`af-palette-workspace${cr?" af-palette-workspace--expanded":""}`,children:[o.jsxs("button",{type:"button",className:"af-palette-workspace-head",onClick:()=>Xn(x=>!x),"aria-expanded":cr,children:[o.jsx("span",{className:"af-palette-workspace-icon material-symbols-outlined","aria-hidden":!0,children:"folder_open"}),o.jsx("span",{className:"af-palette-workspace-label",children:e("flow:palette.workspace")}),o.jsx("span",{className:"af-palette-workspace-chevron material-symbols-outlined","aria-hidden":!0,children:cr?"expand_less":"expand_more"})]}),o.jsx("div",{className:"af-palette-workspace-path",title:c&&(c.path||zr.path)||"",children:c?c.id:e("flow:palette2.noPipelineSelected")}),cr&&o.jsx("div",{className:"af-palette-workspace-tree",children:Br?o.jsx("div",{className:"af-palette-workspace-loading",children:e("flow:palette.loading")}):zr.error?o.jsx("div",{className:"af-palette-workspace-empty",children:zr.error}):c?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-palette-workspace-group",children:[o.jsxs("div",{className:"af-palette-workspace-group-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"}),o.jsx("span",{children:c.id}),o.jsxs("span",{className:"af-palette-workspace-count",children:["(",zr.files.length,")"]})]}),zr.files.length>0?o.jsx("ul",{className:"af-palette-workspace-list",children:zr.files.filter(x=>x.type==="file").map(x=>o.jsxs("li",{className:"af-palette-workspace-item af-palette-workspace-item--clickable",title:x.path,onClick:()=>Z({filePath:x.path,fileName:x.name}),children:[o.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:x.icon}),o.jsx("span",{className:"af-palette-workspace-item-label",children:x.name}),x.size!=null&&o.jsx("span",{className:"af-palette-workspace-item-size",children:x.size<1024?`${x.size}B`:x.size<1024*1024?`${(x.size/1024).toFixed(1)}KB`:`${(x.size/1024/1024).toFixed(1)}MB`})]},x.path))}):zr.files.filter(x=>x.type==="directory").length===0?o.jsx("div",{className:"af-palette-workspace-empty",children:"暂无文件"}):null]}),zr.files.filter(x=>{var N;return x.type==="directory"&&((N=x.children)==null?void 0:N.length)>0}).map(x=>o.jsxs("div",{className:"af-palette-workspace-group af-palette-workspace-group--sub",children:[o.jsxs("div",{className:"af-palette-workspace-group-head",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:x.icon}),o.jsxs("span",{children:[x.name,"/"]}),o.jsxs("span",{className:"af-palette-workspace-count",children:["(",x.children.length,")"]})]}),o.jsx("ul",{className:"af-palette-workspace-list",children:x.children.map(N=>o.jsxs("li",{className:`af-palette-workspace-item${N.type==="file"?" af-palette-workspace-item--clickable":""}`,title:N.path,onClick:N.type==="file"?()=>Z({filePath:N.path,fileName:N.name}):void 0,children:[o.jsx("span",{className:"material-symbols-outlined af-palette-workspace-item-icon","aria-hidden":!0,children:N.icon}),o.jsx("span",{className:"af-palette-workspace-item-label",children:N.name}),N.type==="file"&&N.size!=null&&o.jsx("span",{className:"af-palette-workspace-item-size",children:N.size<1024?`${N.size}B`:N.size<1024*1024?`${(N.size/1024).toFixed(1)}KB`:`${(N.size/1024/1024).toFixed(1)}MB`})]},N.path))})]},x.path))]}):o.jsx("div",{className:"af-palette-workspace-empty",children:e("flow:palette2.noPipelineSelected")})})]}),o.jsxs("div",{className:"af-node-palette-head",children:[o.jsxs("h2",{className:"af-node-palette-title",children:[o.jsx("span",{children:"Palette"}),o.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),o.jsxs("label",{className:"af-palette-search-wrap",children:[o.jsx("span",{className:"af-visually-hidden",children:Oe==="flows"?"搜索流程片段":e("flow:palette.searchNodes")}),o.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:et,type:"search",className:"af-palette-search-input",value:_e,onChange:x=>we(x.target.value),placeholder:(Oe==="flows"?"搜索流程片段":e("flow:palette.searchNodes"))+"…","aria-label":Oe==="flows"?"搜索流程片段":e("flow:palette.searchNodes")})]}),o.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[o.jsxs("button",{type:"button",role:"tab","aria-selected":Oe==="nodes",className:"af-palette-tab"+(Oe==="nodes"?" af-palette-tab--active":""),onClick:()=>Ie("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":Oe==="flows",className:"af-palette-tab"+(Oe==="flows"?" af-palette-tab--active":""),onClick:()=>Ie("flows"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),d?o.jsx("p",{className:"af-err af-palette-list-err",children:d}):null,o.jsx("div",{className:"af-node-palette-scroll",children:Oe==="flows"?o.jsxs(o.Fragment,{children:[o.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:o.jsxs("div",{className:"af-flow-snippet-actions",children:[o.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:m2,disabled:!c||Tr.length<2,title:Tr.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),o.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",Tr.length," 节点 / ",Yp.length," 连线"]})]})}),jt?o.jsx("p",{className:"af-err af-palette-list-err",children:jt}):null,bt?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段…"}):Y0.length>0?o.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[o.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),o.jsx("div",{className:"af-palette-cards",children:Y0.map(x=>{const N=`${x.id}@${x.version}`,H=x.displayName||x.name||x.id,q=x.description||`${x.nodeCount||0} 个节点,${x.edgeCount||0} 条连线`;return o.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",onClick:()=>X0(x),draggable:!!c,onDragStart:Y=>{Y.dataTransfer.setData("application/agentflow-snippet",N),Y.dataTransfer.effectAllowed="move"},disabled:!c,title:q,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:H}),o.jsxs("span",{className:"af-palette-card-id",children:[x.id,"@",x.version]})]})]}),q?o.jsx("span",{className:"af-palette-card-desc",children:q}):null,o.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[o.jsxs("span",{children:[x.nodeCount||0," nodes"]}),o.jsxs("span",{children:[x.edgeCount||0," edges"]})]})]},N)})})]}):o.jsx("p",{className:"af-palette-empty",children:_e.trim()?"无匹配流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[Wd.filter(x=>Ln[x].length>0).map(x=>o.jsxs("section",{className:`af-palette-section af-flow-palette-section--${x}`,children:[o.jsx("h3",{className:"af-palette-cat",children:x}),o.jsx("div",{className:"af-palette-cards",children:Ln[x].map(N=>{const H=t1(N.inputs,"input"),q=t1(N.outputs,"output"),J=N.id==="control_load_skills"?"从当前 Skills collection 或上游上下文自动注入 Skills,通常无需手填参数。":KT(N),ee=UT(N);return o.jsxs("button",{type:"button",className:"af-palette-card",onClick:()=>Hp(N),draggable:!!c,onDragStart:te=>{te.dataTransfer.setData("application/agentflow-node",N.id),te.dataTransfer.effectAllowed="move"},disabled:!c,title:J||N.id,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:ZK(x)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:ee}),ee!==N.id?o.jsx("span",{className:"af-palette-card-id",children:N.id}):null]})]}),J?o.jsx("span",{className:"af-palette-card-desc",children:J}):null,o.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[H.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[H.shown.map((te,me)=>o.jsxs("span",{className:"af-palette-card-port",title:e1("input",te,me),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:nr(te==null?void 0:te.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:Ax(te,me)})]},`in-${me}`)),H.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",H.hidden]}):null]})]}),o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[q.list.length," OUT"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[q.shown.map((te,me)=>o.jsxs("span",{className:"af-palette-card-port",title:e1("output",te,me),children:[o.jsx("span",{className:"af-palette-card-port-name",children:Ax(te,me)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:nr(te==null?void 0:te.type)}})]},`out-${me}`)),q.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",q.hidden]}):null]})]})]})]},N.id)})})]},x)),c&&ae.length===0?o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noComponents")}):null,c&&ae.length>0&&_e.trim()&&gi===0?o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.noMatch")}):null,c?null:o.jsx("p",{className:"af-palette-empty",children:e("flow:palette.selectPipeline")})]})}),o.jsxs("footer",{className:"af-palette-engine",children:[o.jsxs("div",{className:"af-palette-engine-head",children:[o.jsx("span",{className:"af-palette-engine-dot"+(ga?"":" af-palette-engine-dot--offline"),"aria-hidden":!0}),o.jsx("span",{className:"af-palette-engine-label",children:e(ga?"common:engine.online":"common:engine.offline")})]}),w?o.jsx("div",{className:"af-palette-tip"+mt,role:"status","aria-live":"polite",children:w}):null]})]}):Ee!=="edit"&&c?o.jsx(BK,{flowId:c.id,flowSource:c.source||"user",flowArchived:c.archived,provideNodes:A,edges:mn,nodes:Ct,onCliInputsChange:zs,onBackToEdit:Rl}):null,o.jsxs("div",{className:"af-pipeline-main-stack",children:[o.jsxs("div",{className:"af-pipeline-canvas-col",children:[y?o.jsx("div",{className:"af-banner af-banner--err af-pipeline-banner",children:y}):null,c&&Ne.length>0&&!V?o.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings",role:"region","aria-label":e("flow:validation.flowWarningAriaLabel"),children:[o.jsxs("div",{className:"af-flow-slot-warnings-head",children:[o.jsx("div",{className:"af-flow-slot-warnings-title",children:e("flow:palette.validationWarnings")}),o.jsxs("div",{className:"af-flow-slot-warnings-head-actions",children:[o.jsx("button",{type:"button",className:"af-icon-btn",disabled:de,"aria-label":e("flow:validation.reloadFromServer"),title:e("flow:validation.reloadFromServerShort"),onClick:()=>void ke(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"})}),o.jsx("button",{type:"button",className:"af-icon-btn","aria-label":e("flow:validation.closeBanner"),title:e("common:common.close"),onClick:()=>se(!0),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),o.jsx("ul",{className:"af-flow-slot-warnings-list",children:Ne.map(x=>o.jsxs("li",{children:[e("flow:validation.nodePrefix"),' "',o.jsx("a",{href:"#",className:"af-flow-slot-warning-node-link","aria-label":e("flow:validation.focusNodeAriaLabel",{nodeId:x.nodeId}),onClick:N=>{N.preventDefault(),Oi(x.nodeId)},children:x.nodeId}),'"',x.suffix]},x.key))})]}):null,c&&Ne.length>0&&V?o.jsxs("div",{className:"af-banner af-banner--warn af-flow-slot-warnings af-flow-slot-warnings--collapsed",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"af-flow-slot-warnings-collapsed-text",children:e("flow:validation.slotWarningCount",{count:Ne.length})}),o.jsxs("button",{type:"button",className:"af-flow-slot-warnings-kbd-hint",onClick:ek,title:e("flow:validation.shortcutHint"),children:[o.jsx("kbd",{children:"?"})," ",e("flow:validation.shortcutHintLabel")]}),o.jsxs("div",{className:"af-flow-slot-warnings-collapsed-actions",children:[o.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",onClick:()=>se(!1),children:e("flow:validation.show")}),o.jsx("button",{type:"button",className:"af-flow-slot-warnings-collapsed-btn",disabled:de,onClick:()=>void ke(),children:e("common:common.refresh")})]})]}):null,Ze==="settings"&&c&&Ee==="edit"?b2():o.jsx("div",{className:"af-react-flow-wrap af-pipeline-flow",children:c?o.jsxs(o.Fragment,{children:[o.jsx(N7,{fitViewEpoch:m,canvasTool:kp,nodes:Q,edges:re,onNodesChange:Ee!=="edit"?void 0:fy,onEdgesChange:Ee!=="edit"?void 0:py,onConnect:Ee!=="edit"?void 0:Nn,onConnectStart:Ee!=="edit"?void 0:gn,onConnectEnd:Ee!=="edit"?void 0:At,isValidConnection:Ee!=="edit"?void 0:Ut,onNodesDelete:Ee!=="edit"?void 0:sn,onNodeClick:De,onNodeDoubleClick:Ot,onEdgeClick:Qt,onFlowInit:os,onDrop:t2,onDragOver:e2,hideMinimapAndControls:!!(c&&Ze),bottomSlot:Ee==="edit"?o.jsx("div",{className:"af-bottom-composer-stack af-flow-bottom-composer",children:o.jsxs("div",{className:"af-pipeline-composer-inner",children:[o.jsx("div",{className:"af-composer-selected","aria-label":e("flow:composer.selectedNodesAriaLabel"),children:Gp.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:e("flow:composer.selectedNodesEmpty")}):Gp.map((x,N)=>{var me,ye;if(x.kind==="definition"){const Fe=x.definition,ue=String(Fe.label??Fe.id),$e=[Fe.id,Fe.description?String(Fe.description).slice(0,120):""].filter(Boolean).join(" — ");return o.jsxs("div",{className:"af-composer-node-chip af-composer-node-chip--definition",title:$e,children:[o.jsx("span",{className:"af-composer-node-chip-label",children:ue}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>Z0(x),"aria-label":e("flow:composer.removeFromInput",{id:Fe.id}),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},`def-${Fe.id}`)}const H=x.node,q=x.kind,Y=String(((me=H.data)==null?void 0:me.label)??H.id),J=(ye=H.data)!=null&&ye.definitionId?String(H.data.definitionId):"",ee=J&&J!==Y?`${Y} · ${H.id} · ${J}`:`${Y} · ${H.id}`,te=q==="canvas"?e("flow:composer.deselectNode",{id:H.id}):e("flow:composer.removeFromInput",{id:H.id});return o.jsxs("div",{className:"af-composer-node-chip"+(q==="mention"?" af-composer-node-chip--mention":""),title:ee,children:[o.jsx("span",{className:"af-composer-node-chip-label",children:Y}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>Z0(x),"aria-label":te,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},H.id)})}),o.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[o.jsxs("div",{className:"af-composer-input-wrap",children:[o.jsx("textarea",{ref:td,className:"af-composer-textarea",placeholder:e("flow:composer.inputPlaceholder"),disabled:!c,value:xs,rows:2,onChange:x=>{Ae(x.target.value),Sa(x.target.selectionStart??x.target.value.length)},onSelect:x=>{const N=x.target;N instanceof HTMLTextAreaElement&&Sa(N.selectionStart??0)},onKeyDown:x=>{if((x.metaKey||x.ctrlKey)&&x.key==="Enter"){x.preventDefault(),Ll();return}if(hd&&Mi.length>0&&(x.key==="ArrowDown"||x.key==="ArrowUp"||x.key==="Enter")){if(x.key==="ArrowDown")x.preventDefault(),di(N=>(N+1)%Mi.length);else if(x.key==="ArrowUp")x.preventDefault(),di(N=>(N-1+Mi.length)%Mi.length);else if(x.key==="Enter"){x.preventDefault();const N=Mi[Na];N&&Sy(N.id)}}},onKeyUp:x=>{const N=x.target;N instanceof HTMLTextAreaElement&&Sa(N.selectionStart??N.value.length)},onClick:x=>{const N=x.target;N instanceof HTMLTextAreaElement&&Sa(N.selectionStart??0)},"aria-label":e("flow:composer.inputAriaLabel"),autoComplete:"off",spellCheck:!1}),hd&&c&&Mi.length>0?o.jsxs("ul",{className:"af-composer-mention-menu",role:"listbox","aria-label":e("flow:composer.mentionAriaLabel"),children:[md.instances.length>0?o.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:o.jsx("div",{className:"af-composer-mention-section-title",children:"Instances"})}):null,md.instances.map((x,N)=>{const H=N;return o.jsx("li",{role:"option","aria-selected":H===Na,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(H===Na?" af-composer-mention-item--active":""),onMouseDown:q=>q.preventDefault(),onMouseEnter:()=>di(H),onClick:()=>Sy(x.id),children:[o.jsx("span",{className:"af-composer-mention-id",children:x.title}),x.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:x.subtitle}):null]})},`i-${x.id}`)}),md.definitions.length>0?o.jsx("li",{className:"af-composer-mention-section",role:"presentation",children:o.jsx("div",{className:"af-composer-mention-section-title",children:"Node"})}):null,md.definitions.map((x,N)=>{const H=md.instances.length+N;return o.jsx("li",{role:"option","aria-selected":H===Na,children:o.jsxs("button",{type:"button",className:"af-composer-mention-item"+(H===Na?" af-composer-mention-item--active":""),onMouseDown:q=>q.preventDefault(),onMouseEnter:()=>di(H),onClick:()=>Sy(x.id),children:[o.jsx("span",{className:"af-composer-mention-id",children:x.title}),x.subtitle?o.jsx("span",{className:"af-composer-mention-sub",children:x.subtitle}):null]})},`d-${x.id}`)})]}):null]}),o.jsxs("div",{className:"af-composer-toolbar",children:[ss.length>0&&o.jsx("label",{className:"af-composer-session-field",children:o.jsxs("select",{className:"af-composer-session-select",value:Qn||"",onChange:x=>{x.target.value==="__new__"?Op():Uo(x.target.value)},disabled:Sn,"aria-label":e("flow:composer.switchConversation"),children:[ss.map(x=>o.jsxs("option",{value:x.id,children:[x.label,x.running?" ⏳":""]},x.id)),o.jsxs("option",{value:"__new__",children:["+ ",e("flow:composer.newConversation")]})]})}),o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:qt,type:"button",className:"af-composer-skills-button"+(ky>0?" af-composer-skills-button--active":""),disabled:!c||Sn,"aria-haspopup":"listbox","aria-expanded":Ti,onClick:()=>ut(x=>!x),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:ky>0?`Skills ${ky}`:"Skills"})]}),Ti&&!Sn?Or.createPortal(o.jsx("div",{ref:yc,className:"af-composer-skills-menu",role:"listbox","aria-label":"Composer skills",style:dy,children:pi.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[Xp.groups.map(x=>{const N=il(x,pi),H=Q_(x,vy,pi),q=Ip.has(x.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(q?" af-composer-skill-group--collapsed":""),children:[o.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[o.jsxs("label",{className:"af-composer-skill-group-check",children:[o.jsx("input",{type:"checkbox",checked:H==="all",disabled:N.length===0,onChange:Y=>{const J=Y.target.checked;so(ee=>J?X_(ee,N):J_(ee,N))}}),o.jsxs("span",{className:"af-composer-skill-group-title-main",children:[o.jsx("span",{children:x.name}),x.builtin?o.jsx("em",{children:"built-in"}):null,H==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":q?`展开 ${x.name}`:`收起 ${x.name}`,onClick:()=>{jl(Y=>{const J=new Set(Y);return J.has(x.id)?J.delete(x.id):J.add(x.id),J})},children:[o.jsx("span",{children:x.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:q?"expand_more":"expand_less"})]})]}),q?null:o.jsx("div",{className:"af-composer-skill-group-items",children:x.skills.map(Y=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:vy.has(Y.key),onChange:J=>{const ee=J.target.checked;so(te=>ee?te.includes(Y.key)?te:[...te,Y.key]:te.filter(me=>me!==Y.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:Y.name}),Y.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:Y.description}):null]})]},`${x.id}:${Y.key}`))})]},x.id)}),Xp.ungrouped.length>0?o.jsxs("div",{className:"af-composer-skill-group",children:[o.jsxs("div",{className:"af-composer-skill-group-title",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("span",{children:Xp.ungrouped.length})]}),Xp.ungrouped.map(x=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:vy.has(x.key),onChange:N=>{const H=N.target.checked;so(q=>H?q.includes(x.key)?q:[...q,x.key]:q.filter(Y=>Y!==x.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:x.name}),x.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:x.description}):null]})]},`ungrouped:${x.key}`))]}):null]})}),document.body):null]}),o.jsxs("label",{className:"af-composer-model-field",children:[o.jsx("span",{className:"af-visually-hidden",children:e("flow:composer.modelLabel")}),o.jsxs("select",{className:"af-composer-model-select",value:(fi||"").trim()?ks.currentNotInLists?ks.currentNotInLists:Rh(fi,ks.cursorList,ks.opencodeList,ks.claudeCodeList):"",onChange:x=>Sl(x.target.value),disabled:!c||Sn,"aria-label":e("flow:composer.modelAriaLabel"),children:[o.jsx("option",{value:"",children:e("flow:composer.modelDefault")}),ks.currentNotInLists?o.jsxs("option",{value:ks.currentNotInLists,children:[ks.currentNotInLists,e("flow:composer.modelNotInList")]}):null,ks.cursorList.length>0?o.jsx("optgroup",{label:"Cursor",children:ks.cursorList.map(x=>o.jsx("option",{value:Qo(x),children:x},`composer-c-${x}`))}):null,ks.opencodeList.length>0?o.jsx("optgroup",{label:"OpenCode",children:ks.opencodeList.map(x=>o.jsx("option",{value:`opencode:${Qo(x)}`,children:x},`composer-o-${x}`))}):null,ks.claudeCodeList.length>0?o.jsx("optgroup",{label:"Claude Code",children:ks.claudeCodeList.map(x=>o.jsx("option",{value:`claude-code:${Qo(x)}`,children:x},`composer-cc-${x}`))}):null]})]}),o.jsx("button",{type:"button",className:"af-composer-send"+(c&&xs.trim()&&!Sn?" af-composer-send--active":"")+(Sn?" af-composer-send--stop":""),disabled:!c||!Sn&&!xs.trim(),"aria-label":e(Sn?"flow:composer.stopGeneration":"flow:composer.send"),title:Sn?e("flow:composer.stopGeneration"):void 0,onClick:()=>{var x;if(Sn){(x=_l.current)==null||x.abort();return}Ll()},children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Sn?"stop":"arrow_upward"})})]})]}),vc?Or.createPortal(o.jsx("div",{className:"af-node-props-expand-overlay af-composer-thread-dialog-overlay",role:"dialog","aria-modal":"true","aria-label":e("flow:composer.conversationOutput"),onMouseDown:x=>{x.target===x.currentTarget&&Vo(!1)},children:o.jsxs("div",{className:"af-node-props-expand-panel af-composer-thread-dialog-panel",children:[o.jsxs("div",{className:"af-node-props-expand-head af-composer-thread-dialog-head",children:[o.jsxs("div",{className:"af-composer-thread-dialog-head-main",children:[o.jsx("span",{className:"af-node-props-expand-title",children:e("flow:nodeProps.conversationOutput")}),o.jsx("div",{className:"af-composer-thread-dialog-status"+(Sn?" af-composer-thread-dialog-status--running":""),role:"status","aria-live":"polite",title:El||void 0,children:Sn&&!El?e("flow:composer.executing"):El||e("flow:composer.ready")})]}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Vo(!1),"aria-label":e("flow:composer.collapseAriaLabel"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),ad.length>1&&!(Nt&&Array.isArray(Nt.phases)&&Nt.phases.length>1)?o.jsx("div",{className:"af-composer-steps-track-wrap",children:o.jsx(d7,{steps:ad})}):null,Nt&&Array.isArray(Nt.phases)&&Nt.phases.length>1?o.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Nt.phases.map((x,N)=>{const H=x.status||(N<(Nt.currentPhase??0)?"done":N===(Nt.currentPhase??0)?Sn?"running":Nt.nextPhase||Nt.isLastPhase?"done":"running":"pending");return o.jsxs("div",{className:"af-composer-phase-item"+(H==="done"?" af-composer-phase-item--done":"")+(H==="running"?" af-composer-phase-item--running":"")+(H==="pending"?" af-composer-phase-item--pending":""),title:`${x.label}${x.description?":"+x.description:""}`,children:[o.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:H==="done"?o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):o.jsx("span",{children:N+1})}),o.jsx("span",{className:"af-composer-phase-label",children:x.label})]},x.name||N)})}):null,o.jsx("div",{className:"af-composer-thread-dialog-scroll",children:o.jsx(o1,{thread:ao,liveSegments:Wo,running:Sn})}),Nt&&!Nt.isLastPhase&&Nt.nextPhase&&!Sn?o.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[o.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Nt.nextPhase.label})}),o.jsxs("div",{className:"af-composer-phase-review-buttons",children:[o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:Q0,children:e("flow:composer.phaseReviewContinue",{label:Nt.nextPhase.label})}),o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:J0,children:e("flow:composer.phaseReviewSkip")})]})]}):null]})}),document.body):null]})}):null}),rn&&Ee==="edit"?(()=>{var q;const x=String(rn.query||"").trim().toLowerCase(),N=x?rn.candidates.filter(Y=>{var J,ee,te;return[(J=Y.def)==null?void 0:J.id,Y.displayLabel,Y.description,(ee=Y.slot)==null?void 0:ee.name,(te=Y.slot)==null?void 0:te.type].filter(Boolean).some(me=>String(me).toLowerCase().includes(x))}):rn.candidates,H=rn.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:rn.left,top:rn.top},role:"dialog","aria-label":"选择匹配节点",children:[o.jsxs("div",{className:"af-connect-node-menu__head",children:[o.jsxs("div",{className:"af-connect-node-menu__title",children:[o.jsx("span",{className:"af-connect-node-menu__dot",style:{background:nr((q=rn.draft.slot)==null?void 0:q.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",rn.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>Li(null),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("label",{className:"af-connect-node-menu__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:rn.query,onChange:Y=>Li(J=>J&&{...J,query:Y.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[N.map(Y=>{var te,me;const J=Y.displayLabel||((te=Y.def)==null?void 0:te.id),ee=Ax(Y.slot,Y.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>my(Y),title:Y.description||Y.def.id,children:[o.jsxs("span",{className:"af-connect-node-menu__item-main",children:[o.jsx("span",{className:"af-connect-node-menu__item-label",children:J}),J!==Y.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:Y.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:H}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:nr((me=Y.slot)==null?void 0:me.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:ee})]})]},`${Y.def.id}-${Y.slotIndex}`)}),N.length===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null]}):o.jsx("div",{className:"af-placeholder af-pipeline-placeholder",children:e("flow:pipeline.selectPipeline")})})]}),Ee!=="edit"&&Qe&&o.jsxs("div",{className:"af-run-console",style:{height:yr},children:[o.jsx("div",{className:"af-run-console__resize",role:"separator","aria-orientation":"horizontal","aria-label":e("flow:run.resizeConsole"),onPointerDown:i2,onPointerMove:o2,onPointerUp:K0,onPointerCancel:K0,onLostPointerCapture:a2}),o.jsxs("div",{className:"af-run-console__head",children:[o.jsxs("span",{className:"af-run-console__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"terminal"}),"EXECUTION CONSOLE"]}),o.jsxs("div",{className:"af-run-console__head-right",children:[Ee==="running"&&o.jsx("span",{className:"af-run-console__live-badge",children:"LIVE"}),o.jsx("button",{type:"button",className:"af-icon-btn af-run-console__close",onClick:()=>dr(!1),"aria-label":e("flow:run.closeLog"),children:o.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})})]})]}),o.jsxs("div",{className:"af-run-console__body",children:[ur.map((x,N)=>o.jsxs("div",{className:"af-run-console__line"+(x.type==="error"?" af-run-console__line--error":"")+(x.type==="warn"?" af-run-console__line--warn":"")+(x.type==="node-start"?" af-run-console__line--start":"")+(x.type==="node-done"?" af-run-console__line--done":"")+(x.type==="node-failed"?" af-run-console__line--error":"")+(x.type==="done"?" af-run-console__line--done":""),children:[o.jsxs("span",{className:"af-run-console__ts",children:["[",x.ts?new Date(x.ts).toLocaleTimeString():"--:--:--","]"]}),o.jsx("span",{className:"af-run-console__text",children:x.text!=null?String(x.text):""})]},N)),o.jsx("div",{ref:Mo})]})]})]}),Ee!=="edit"&&gs&&c?o.jsx($K,{instanceId:gs,flowId:c.id,runId:un,nodeStatus:((tk=Wr[gs])==null?void 0:tk.status)??null,onClose:()=>Vr(null)}):null,Ze&&Ze!=="settings"&&c&&Ee==="edit"?o.jsx("aside",{className:"af-pipeline-drawer"+(Ze==="node"?" af-pipeline-drawer--wide":"")+(Ze==="composer"?" af-pipeline-drawer--wide":""),"aria-label":Ze==="settings"?e("flow:settings.title"):Ze==="history"?e("flow:history.title"):Ze==="composer"?"AI Composer":e("flow:nodeProps.title"),children:Ze==="composer"?o.jsxs("div",{className:"af-composer-sidebar",children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:gd,"aria-label":e("flow:composer.closeSidebar"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),ss.length>0&&o.jsxs("div",{className:"af-composer-session-tabs",children:[ss.map(x=>o.jsxs("button",{type:"button",ref:N=>{N&&x.id===Qn&&N.scrollIntoView({block:"nearest",inline:"nearest"})},className:["af-composer-session-tab",x.id===Qn?"af-composer-session-tab--active":"",x.running?"af-composer-session-tab--running":""].filter(Boolean).join(" "),onClick:()=>Uo(x.id),title:x.label,children:[o.jsx("span",{className:"af-composer-session-label",children:x.label}),o.jsx("span",{className:"af-composer-session-close",role:"button",tabIndex:0,onClick:N=>{N.stopPropagation(),Mp(x.id)},onKeyDown:N=>{N.key!=="Enter"&&N.key!==" "||(N.preventDefault(),N.stopPropagation(),Mp(x.id))},title:x.running?e("flow:composer.endConversation"):e("flow:composer.closeConversation"),children:o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.75rem"},children:"close"})})]},x.id)),o.jsx("button",{type:"button",className:"af-composer-session-add",onClick:()=>Op(),title:e("flow:composer.newConversation"),children:o.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),o.jsx("div",{className:"af-composer-sidebar-status"+(Sn?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:Sn&&!El?e("flow:composer.executing"):El||e("flow:composer.ready")}),Nt&&Array.isArray(Nt.phases)&&Nt.phases.length>1?o.jsx("div",{className:"af-composer-phase-bar","aria-label":e("flow:composer.phaseProgress"),children:Nt.phases.map((x,N)=>{const H=x.status||(N<(Nt.currentPhase??0)?"done":N===(Nt.currentPhase??0)?Sn?"running":Nt.isLastPhase&&N===Nt.phases.length-1||Nt.nextPhase?"done":"running":"pending");return o.jsxs("div",{className:"af-composer-phase-item"+(H==="done"?" af-composer-phase-item--done":"")+(H==="running"?" af-composer-phase-item--running":"")+(H==="pending"?" af-composer-phase-item--pending":""),title:`${x.label}${x.description?":"+x.description:""}`,children:[o.jsx("span",{className:"af-composer-phase-dot","aria-hidden":!0,children:H==="done"?o.jsx("span",{className:"material-symbols-outlined",style:{fontSize:"0.85rem"},children:"check"}):o.jsx("span",{children:N+1})}),o.jsx("span",{className:"af-composer-phase-label",children:x.label})]},x.name||N)})}):null,o.jsx("div",{className:"af-composer-sidebar-thread",ref:Lp,children:o.jsx(o1,{thread:ao,liveSegments:Wo,running:Sn})}),Nt&&!Nt.isLastPhase&&Nt.nextPhase&&!Sn?o.jsxs("div",{className:"af-composer-phase-review af-composer-phase-review--minimal","aria-label":e("flow:composer.phaseReviewLabel"),children:[o.jsx("span",{className:"af-composer-phase-auto-hint",children:e("flow:composer.phaseReviewHint",{nextPhase:Nt.nextPhase.label})}),o.jsxs("div",{className:"af-composer-phase-review-buttons",children:[o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--continue",onClick:Q0,children:e("flow:composer.phaseReviewContinue",{label:Nt.nextPhase.label})}),o.jsx("button",{type:"button",className:"af-composer-phase-btn af-composer-phase-btn--skip",onClick:J0,children:e("flow:composer.phaseReviewSkip")})]})]}):null]}):Ze==="node"&&le?yt?o.jsx(zT,{draft:yt,setDraft:rd,definitionId:String(((nk=le.data)==null?void 0:nk.definitionId)??le.id),systemPromptReadonly:String((Ue==null?void 0:Ue.description)??""),modelLists:wt,disabled:!c,onIdBlur:s2,onClose:gd,onPublishToMarketplace:Ec,error:Cp,ioSlots:{inputs:Array.isArray(yt==null?void 0:yt.inputs)?yt.inputs:[],outputs:Array.isArray(yt==null?void 0:yt.outputs)?yt.outputs:[]}}):o.jsx("div",{className:"af-pipeline-drawer-body",children:o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.loadingProps")})}):o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:e(Ze==="settings"?"flow:settings.title":"flow:history.title")}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:gd,"aria-label":e("flow:composer.closeSidebar"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-pipeline-drawer-body",children:Ze==="settings"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.pipelineId")}),(c.source==="user"||c.source==="workspace")&&!c.archived?o.jsxs("div",{className:"af-pipeline-rename-row",children:[o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:D,onChange:x=>{F(x.target.value),O("")},onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),Vp())},onBlur:()=>{D.trim()&&D.trim()!==c.id&&Vp()},placeholder:c.id,disabled:R,spellCheck:!1}),o.jsx("span",{className:"af-pipeline-drawer-badge",children:Oc(c.source??"user",e)})]}):o.jsxs("div",{className:"af-pipeline-drawer-readonly",children:[c.id,o.jsx("span",{className:"af-pipeline-drawer-badge",children:Oc(c.source??"user",e)}),c.archived?o.jsx("span",{className:"af-pipeline-drawer-badge af-pipeline-drawer-badge--muted",children:e("flow:settings.archived")}):null]}),W?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:W}):null]}),typeof c.path=="string"&&c.path?o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.diskPath")}),o.jsxs("div",{className:"af-pipeline-drawer-readonly af-pipeline-drawer-readonly--mono af-pipeline-path-row",children:[o.jsx("span",{className:"af-pipeline-path-text",children:c.path}),o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-copy-btn",onClick:()=>W0(c.path),title:e("flow:settings.copyPath"),children:o.jsx("span",{className:"material-symbols-outlined",children:$?"check":"content_copy"})})]})]}):null,c.source==="user"||c.source==="workspace"?c.archived?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.archivedNote")}):o.jsxs("div",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.storageLocation")}),o.jsx("div",{className:"af-pipeline-move-actions",children:c.source==="user"?o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:L,onClick:()=>Wp("workspace"),children:e(L?"flow:settings.moveBusy":"flow:settings.moveToWorkspace")}):o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:L,onClick:()=>Wp("user"),children:e(L?"flow:settings.moveBusy":"flow:settings.moveToUserDir")})}),P?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:P}):null]}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:settings.builtinNote")}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:pipeline.introduction")}),o.jsx("textarea",{className:"af-pipeline-drawer-textarea",value:b,onChange:x=>k(x.target.value),placeholder:e("flow:pipeline.introductionPlaceholder"),rows:5,spellCheck:!1})]}),o.jsxs("div",{className:"af-pipeline-meta-card",children:[o.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:schedule.title")}),Gu?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"af-new-pipeline-radio",children:[o.jsx("input",{type:"checkbox",checked:!!or.enabled,disabled:Ai||c.archived||xi(c.source),onChange:x=>ne(N=>({...N,enabled:x.target.checked}))}),o.jsx("span",{children:e("flow:schedule.enabled")})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.cron")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:or.cron||"",disabled:Ai||c.archived||xi(c.source),onChange:x=>ne(N=>({...N,cron:x.target.value})),placeholder:"0 9 * * *",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.timezone")}),o.jsx("input",{type:"text",className:"af-pipeline-rename-input",value:or.timezone||"",disabled:Ai||c.archived||xi(c.source),onChange:x=>ne(N=>({...N,timezone:x.target.value})),placeholder:"Asia/Shanghai",spellCheck:!1})]}),o.jsxs("label",{className:"af-pipeline-drawer-field",children:[o.jsx("span",{className:"af-pipeline-drawer-label",children:e("flow:schedule.preset")}),o.jsxs("select",{className:"af-pipeline-flow-select",value:or.preset||"",disabled:Ai||c.archived||xi(c.source),onChange:x=>ne(N=>({...N,preset:x.target.value})),children:[o.jsx("option",{value:"",children:e("flow:schedule.defaultPreset")}),Object.keys(dn).map(x=>o.jsx("option",{value:x,children:x},x))]})]}),o.jsx("div",{className:"af-pipeline-drawer-readonly",children:o.jsx("span",{children:e("flow:schedule.overlapSkip")})}),or.nextRunAt?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.nextRun",{time:new Date(or.nextRunAt).toLocaleString()})}):o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.noNextRun")}),o.jsxs("dl",{className:"af-pipeline-meta-dl",children:[o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.runtime")}),o.jsx("dd",{children:zt!=null&&zt.running?e("flow:schedule.running"):or.enabled?e("flow:schedule.waiting"):e("flow:schedule.disabled")})]}),Vt.lastTriggeredAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastTriggeredAt")}),o.jsx("dd",{children:new Date(Vt.lastTriggeredAt).toLocaleString()})]}):null,Vt.lastSkippedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastSkippedAt")}),o.jsxs("dd",{children:[new Date(Vt.lastSkippedAt).toLocaleString(),Vt.lastSkipReason?` · ${Vt.lastSkipReason}`:""]})]}):null,Vt.lastRunUuid?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastRun")}),o.jsx("dd",{children:Vt.lastRunUuid})]}):null,Vt.lastExitCode!=null?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastExit")}),o.jsx("dd",{children:String(Vt.lastExitCode)})]}):null,Vt.lastFinishedAt?o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:schedule.lastFinishedAt")}),o.jsx("dd",{children:new Date(Vt.lastFinishedAt).toLocaleString()})]}):null]}),zt!=null&&zt.lastError||Vt.lastError?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:(zt==null?void 0:zt.lastError)||Vt.lastError}):null,c.archived||xi(c.source)?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:schedule.readonlyNote")}):null,ml?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:ml}):null,gl?o.jsx("p",{className:"af-pipeline-drawer-muted",children:gl}):null,o.jsx("button",{type:"button",className:"af-btn-secondary",disabled:Ai||c.archived||xi(c.source),onClick:gy,children:e(Ai?"flow:schedule.saving":"flow:schedule.save")})]})]}),o.jsxs("div",{className:"af-pipeline-meta-card",children:[o.jsx("h3",{className:"af-pipeline-meta-title",children:e("flow:pipeline.metadata")}),o.jsx("dl",{className:"af-pipeline-meta-dl",children:o.jsxs("div",{className:"af-pipeline-meta-row",children:[o.jsx("dt",{children:e("flow:pipeline.nodeCount")}),o.jsxs("dd",{children:[Ct.length," ",e("flow:pipeline.nodesUnit")]})]})})]}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-link",onClick:()=>n("/settings"),children:e("flow:settings.globalSettings")})]}):o.jsxs(o.Fragment,{children:[o.jsxs("p",{className:"af-pipeline-drawer-lead",children:[e("flow:settings.currentPipeline"),o.jsx("strong",{children:c.id})]}),cn?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("common:common.loading")}):He?o.jsx("p",{className:"af-err af-pipeline-drawer-err",children:He}):pd.length===0?o.jsx("p",{className:"af-pipeline-drawer-muted",children:e("flow:pipeline.noRuns")}):o.jsxs(o.Fragment,{children:[as.success+as.failed+as.running+as.stopped+as.interrupted>0?o.jsxs("div",{className:"af-exec-history-summary","aria-label":e("flow:history.summary"),children:[as.success>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--success",children:e("flow:history.successCount",{count:as.success})}):null,as.failed>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--failed",children:e("flow:history.failedCount",{count:as.failed})}):null,as.stopped>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--stopped",children:e("flow:history.stoppedCount",{count:as.stopped})}):null,as.interrupted>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--interrupted",children:e("flow:history.interruptedCount",{count:as.interrupted})}):null,as.running>0?o.jsx("span",{className:"af-exec-history-pill af-exec-history-pill--running",children:e("flow:history.runningCount",{count:as.running})}):null]}):null,o.jsx("ul",{className:"af-exec-history-list",children:pd.map((x,N)=>{const H=x.status||"unknown",q=H==="success"?"af-exec-history-card--success":H==="failed"?"af-exec-history-card--failed":H==="stopped"?"af-exec-history-card--stopped":H==="interrupted"?"af-exec-history-card--interrupted":H==="running"?"af-exec-history-card--running":"af-exec-history-card--unknown",Y=e(H==="success"?"flow:history.success":H==="failed"?"flow:history.failed":H==="stopped"?"flow:history.stopped":H==="interrupted"?"flow:history.interrupted":H==="running"?"flow:history.running":"flow:history.unknown"),J=H==="success"?"check_circle":H==="failed"?"error":H==="stopped"?"stop_circle":H==="interrupted"?"sync_disabled":H==="running"?"progress_activity":"help",ee=x.runId||`${x.at}-${N}`,te=x.runId!=null&&x.runId.length>=6?e("flow:history.runLabel",{id:x.runId.length>8?x.runId.slice(-8):x.runId}):e("flow:history.runLabel",{id:pd.length-N});return o.jsx("li",{className:"af-exec-history-list-item",children:o.jsxs("button",{type:"button",className:`af-exec-history-card ${q}`,onClick:()=>h2(x),title:e("flow:history.enterRunView"),children:[o.jsxs("div",{className:"af-exec-history-card-top",children:[o.jsx("span",{className:"af-exec-history-card-title",children:te}),o.jsx("span",{className:"af-exec-history-card-time",children:Hw(x.at,e)})]}),o.jsxs("div",{className:"af-exec-history-card-bottom",children:[o.jsxs("span",{className:"af-exec-history-card-status",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:J}),Y]}),o.jsxs("span",{className:"af-exec-history-card-duration",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timer"}),kM(x.durationMs,e)]})]})]})},`${c.id}-${ee}`)})})]})]})})]})}):null]}),o.jsx(Dj,{open:l2,title:e("flow:run.pauseTitle",{defaultValue:"暂停运行"}),message:e("flow:run.pauseConfirm"),confirmLabel:e("flow:run.pauseConfirmOk",{defaultValue:"暂停"}),onConfirm:u2,onCancel:()=>wy(!1)}),o.jsx(Dj,{open:d2,title:e("flow:run.backPromptTitle",{defaultValue:"返回项目列表"}),message:e("flow:run.backPromptMessage",{defaultValue:"流水线仍在运行,请选择处理方式:后台继续运行并退出,或停止后返回编辑。"}),confirmLabel:e("flow:run.backBackground",{defaultValue:"后台运行并退出"}),secondaryLabel:e("flow:run.backStopEdit",{defaultValue:"停止并进入编辑"}),secondaryDestructive:!0,onConfirm:p2,onSecondary:f2,onCancel:()=>qp(!1)}),o.jsx(LT,{open:fr,onClose:()=>ro(!1)}),v2(),o.jsx(OT,{open:Rn,onClose:()=>Sp(!1),onJump:co,nodes:Ct}),o.jsx(qK,{open:ms,onClose:()=>Lo(!1),flowId:(c==null?void 0:c.id)??""}),o.jsx(TT,{open:z,onClose:()=>C(!1),flowId:(c==null?void 0:c.id)??"",flowSource:(c==null?void 0:c.source)??"user",onArchived:async()=>{C(!1),await Ks(),n("/projects?tab=archived")}}),o.jsx(RT,{open:T&&!!(c!=null&&c.id),onClose:()=>E(!1),flowId:(c==null?void 0:c.id)??"",flowSource:(c==null?void 0:c.source)??"user",flowArchived:!!(c!=null&&c.archived),onDeleted:async()=>{E(!1),p(null),vt([]),Yt([]),Al(null),await Ks(),n("/projects")}}),pn&&Or.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>In(!1),"aria-label":e("common:common.close"),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"名称"}),o.jsx("input",{type:"text",value:en.name,onChange:x=>{const N=x.target.value;Wn(H=>({...H,name:N,id:H.id?H.id:N.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:PR 检查片段",autoFocus:!0})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"ID"}),o.jsx("input",{type:"text",value:en.id,onChange:x=>Wn(N=>({...N,id:x.target.value})),placeholder:"pr-check-snippet"})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:en.description,onChange:x=>Wn(N=>({...N,description:x.target.value})),placeholder:"这段流程适合什么场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",Tr.length," 个节点和 ",Yp.length," 条内部连线。"]}),ve?o.jsx("div",{className:"af-flow-snippet-error",children:ve}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>In(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Tn||!en.name.trim(),onClick:()=>void g2(),children:Tn?"发布中…":"发布"})]})]})}),document.body),o.jsx(SK,{open:!!G,onClose:()=>Z(null),flowId:(c==null?void 0:c.id)??"",flowSource:(c==null?void 0:c.source)??"user",flowArchived:!!(c!=null&&c.archived),filePath:(G==null?void 0:G.filePath)??"",fileName:(G==null?void 0:G.fileName)??"",onSaved:()=>{st(x=>({...x}))}})]}),xr&&Ee!=="edit"&&Or.createPortal(o.jsx("div",{className:"af-user-check-modal-overlay",children:o.jsxs("div",{className:"af-user-check-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-user-check-modal__head",children:[o.jsxs("span",{className:"af-user-check-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),e("flow:userCheck.title",{instanceId:xr.instanceId})]}),o.jsx("div",{className:"af-user-check-modal__actions",children:mc?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--save",onClick:async()=>{if(!xr||!c||!un)return;const x=ai||xr.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"save-user-check-content",runUuid:un,instanceId:xr.instanceId,content:x})})).ok?(wl(H=>H&&{...H,content:x}),Do(!1),pt(H=>[...H,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.contentSaved")}])):pt(H=>[...H,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{pt(N=>[...N,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:userCheck.save")]}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>{Ii(xr.content),Do(!1)},children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:userCheck.cancel")]})]}):o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>Do(!0),children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit"}),e("flow:userCheck.edit")]}),o.jsx("button",{type:"button",className:"af-user-check-modal__btn",onClick:()=>wl(null),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})})]}),o.jsx("div",{className:"af-user-check-modal__body",children:mc?o.jsx("textarea",{ref:Ju,className:"af-user-check-modal__textarea",value:ai||xr.content,onChange:x=>Ii(x.target.value)}):o.jsx("div",{className:"af-user-check-modal__preview",children:o.jsx("pre",{children:ai||xr.content})})}),o.jsxs("div",{className:"af-user-check-modal__ai-bar",children:[o.jsx("input",{type:"text",className:"af-user-check-modal__ai-input",placeholder:e("flow:userCheck.aiEditPlaceholder"),value:ba,onChange:x=>Fo(x.target.value),disabled:bl}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--ai",disabled:bl||!ba.trim(),onClick:()=>{!xr||!c||!un||!ba.trim()||(vl(!0),pt(x=>[...x,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditStarted")}]),fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"ai-edit-user-check-content",runUuid:un,instanceId:xr.instanceId,content:ai||xr.content,prompt:ba})}).then(x=>x.json()).then(x=>{vl(!1),x.ok&&x.content?(Ii(x.content),Do(!0),Fo(""),pt(N=>[...N,{ts:new Date().toISOString(),type:"info",text:e("flow:userCheck.aiEditDone")}])):pt(N=>[...N,{ts:new Date().toISOString(),type:"error",text:x.error||e("flow:userCheck.aiEditFailed")}])}).catch(()=>{vl(!1),pt(x=>[...x,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.aiEditFailed")}])}))},children:[bl?o.jsx("span",{className:"material-symbols-outlined af-spin",children:"sync"}):o.jsx("span",{className:"material-symbols-outlined",children:"auto_fix_high"}),e("flow:userCheck.aiEditBtn")]})]}),o.jsxs("div",{className:"af-user-check-modal__foot",children:[o.jsx("span",{className:"af-user-check-modal__hint",children:e("flow:userCheck.hint")}),o.jsxs("button",{type:"button",className:"af-user-check-modal__btn af-user-check-modal__btn--continue",onClick:async()=>{if(!xr||!c||!un)return;const x=ai||xr.content;try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"save-user-check-content",runUuid:un,instanceId:xr.instanceId,content:x})})).ok?(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"confirm-user-check",runUuid:un,instanceId:xr.instanceId,execId:xr.execId})}),wl(null),Fo(""),uo({runUuid:un})):pt(H=>[...H,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}catch{pt(N=>[...N,{ts:new Date().toISOString(),type:"error",text:e("flow:userCheck.saveFailed")}])}},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:userCheck.continue")]})]})]})}),document.body),li&&Ee!=="edit"&&Or.createPortal(o.jsx("div",{className:"af-user-ask-modal-overlay",children:o.jsxs("div",{className:"af-user-ask-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-user-ask-modal__head",children:[o.jsxs("span",{className:"af-user-ask-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"help"}),e("flow:userAsk.title",{instanceId:li.instanceId})]}),o.jsx("div",{className:"af-user-ask-modal__actions",children:o.jsx("button",{type:"button",className:"af-user-ask-modal__btn",onClick:()=>Ar(null),"aria-label":e("flow:userAsk.close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})})]}),o.jsxs("div",{className:"af-user-ask-modal__body",children:[li.question.trim()?o.jsx("div",{className:"af-user-ask-modal__question",children:o.jsx("pre",{children:li.question})}):null,li.options.length===0?o.jsx("div",{className:"af-user-ask-modal__empty",children:e("flow:userAsk.noOptions")}):o.jsx("div",{className:"af-user-ask-modal__options",children:li.options.map(x=>o.jsxs("button",{type:"button",className:"af-user-ask-option",disabled:Qu,onClick:async()=>{if(!(!li||!c||!un)){ci(!0);try{(await fetch("/api/flow",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:c.id,flowSource:c.source??"user",action:"confirm-user-ask",runUuid:un,instanceId:li.instanceId,execId:li.execId,branch:x.name,selectedIndex:x.index,selectedLabel:x.label})})).ok?(Ar(null),ci(!1),uo({runUuid:un})):(ci(!1),pt(H=>[...H,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}]))}catch{ci(!1),pt(N=>[...N,{ts:new Date().toISOString(),type:"error",text:e("flow:userAsk.submitFailed")}])}}},children:[o.jsxs("span",{className:"af-user-ask-option__index",children:["[",x.index,"]"]}),o.jsx("span",{className:"af-user-ask-option__label",children:x.label})]},x.name))})]}),o.jsx("div",{className:"af-user-ask-modal__foot",children:o.jsx("span",{className:"af-user-ask-modal__hint",children:e(Qu?"flow:userAsk.submitting":"flow:userAsk.hint")})})]})}),document.body),va&&Ee!=="edit"&&o.jsxs("div",{className:"af-tool-print-toast"+(ys?" af-tool-print-toast--expanded":""),role:"status","aria-live":"polite",children:[o.jsxs("div",{className:"af-tool-print-toast__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"print"}),o.jsx("span",{className:"af-tool-print-toast__title",children:e("flow:toolPrint.title",{instanceId:va.instanceId})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>Zu(x=>!x),"aria-label":e(ys?"flow:toolPrint.restore":"flow:toolPrint.expand"),title:e(ys?"flow:toolPrint.restore":"flow:toolPrint.expand"),children:o.jsx("span",{className:"material-symbols-outlined",children:ys?"close_fullscreen":"open_in_full"})}),o.jsx("button",{type:"button",className:"af-tool-print-toast__close",onClick:()=>zo(null),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-tool-print-toast__body",children:o.jsx("div",{className:"af-tool-print-toast__markdown",children:o.jsx(pp,{children:va.content})})})]}),Kr&&o.jsx("div",{className:"af-provide-edit-overlay",children:o.jsxs("div",{className:"af-provide-edit-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-provide-edit-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_document"}),o.jsx("span",{className:"af-provide-edit-modal__title",children:Kr.label}),o.jsx("button",{type:"button",className:"af-provide-edit-modal__close",onClick:()=>ka(null),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-provide-edit-modal__body",children:o.jsx("textarea",{ref:ui,className:"af-provide-edit-modal__textarea",defaultValue:Kr.content,autoFocus:!0})}),o.jsxs("div",{className:"af-provide-edit-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn af-provide-edit-modal__btn--save",onClick:he,children:[o.jsx("span",{className:"material-symbols-outlined",children:"save"}),e("flow:provideEdit.save")]}),o.jsxs("button",{type:"button",className:"af-provide-edit-modal__btn",onClick:()=>ka(null),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:provideEdit.cancel")]})]})]})}),Re&&o.jsx("div",{className:"af-run-params-overlay",children:o.jsxs("div",{className:"af-run-params-modal",role:"dialog","aria-modal":"true",children:[o.jsxs("div",{className:"af-run-params-modal__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"edit_note"}),o.jsx("span",{className:"af-run-params-modal__title",children:e("flow:runParams.title")}),o.jsx("button",{type:"button",className:"af-run-params-modal__close",onClick:()=>We(!1),"aria-label":e("common:close"),children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsx("div",{className:"af-run-params-modal__body",children:A.length===0?o.jsx("div",{className:"af-run-params-empty",children:e("flow:runParams.noParams")}):o.jsx("div",{className:"af-run-params-list",children:A.map(x=>{var me,ye;const N=U[x.id];if(!N)return null;const H=((me=x.data)==null?void 0:me.definitionId)||"",q=H.startsWith("provide_file"),Y=H==="provide_bool",J=((ye=x.data)==null?void 0:ye.label)||x.id,ee=Jt[N]??"",te=["true","1","yes","on"].includes(String(ee).trim().toLowerCase());return o.jsxs("div",{className:"af-run-params-item",children:[o.jsxs("div",{className:"af-run-params-item__head",children:[o.jsx("span",{className:"af-run-params-item__icon material-symbols-outlined"+(q?" af-run-params-item__icon--file":""),children:q?"description":Y?"toggle_on":"text_fields"}),o.jsx("span",{className:"af-run-params-item__label",children:J}),o.jsx("span",{className:"af-run-params-item__slot",children:N})]}),Y?o.jsx("button",{type:"button",className:"af-run-config-bool-toggle"+(te?" af-run-config-bool-toggle--true":""),onClick:()=>Rt(Fe=>({...Fe,[N]:te?"false":"true"})),"aria-pressed":te,children:te?"true":"false"}):o.jsx("input",{type:"text",className:"af-run-params-item__input",value:ee,onChange:Fe=>Rt(ue=>({...ue,[N]:Fe.target.value})),placeholder:e(q?"flow:runConfig.filePathPlaceholder":"flow:runConfig.stringValuePlaceholder")})]},x.id)})})}),o.jsxs("div",{className:"af-run-params-modal__foot",children:[o.jsxs("button",{type:"button",className:"af-run-params-modal__btn af-run-params-modal__btn--run",onClick:()=>{var N;const x={};for(const H of A){const q=U[H.id];if(!q)continue;const Y=((N=H.data)==null?void 0:N.definitionId)||"",J=Jt[q]??"";Y.startsWith("provide_file")?x[q]={type:"file",path:J}:x[q]={type:"str",value:J}}We(!1),Te(!1),uo({cliInputsOverride:x})},children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_arrow"}),e("flow:runParams.run")]}),o.jsxs("button",{type:"button",className:"af-run-params-modal__btn",onClick:()=>We(!1),children:[o.jsx("span",{className:"material-symbols-outlined",children:"close"}),e("flow:runParams.cancel")]})]})]})})]})]})}const P7="modulepreload",A7=function(e){return"/"+e},p1={},I7=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(u=>{if(u=A7(u),u in p1)return;p1[u]=!0;const d=u.endsWith(".css"),f=d?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${u}"]${f}`))return;const c=document.createElement("link");if(c.rel=d?"stylesheet":P7,d||(c.as="script"),c.crossOrigin="",c.href=u,l&&c.setAttribute("nonce",l),document.head.appendChild(c),d)return new Promise((p,m)=>{c.addEventListener("load",p),c.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${u}`)))})}))}function i(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"&&i(l.reason);return t().catch(i)})},T7=new Set(["echarts"]),R7=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),L7=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),O7=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function nl(e){return e&&typeof e=="object"&&!Array.isArray(e)}function lc(e,t){if(!nl(e))return{...t};const n={...e};for(const[r,s]of Object.entries(t))n[r]==null?n[r]=s:nl(n[r])&&nl(s)&&(n[r]=lc(n[r],s));return n}function ry(e,t){return e==null?e:Array.isArray(e)?e.map(n=>nl(n)?lc(n,t):n):nl(e)?lc(e,t):e}function M7(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 Ab(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)=>Ab(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||L7.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);Ab(r,`${t}.${n}`)}}}function $7(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 D7(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:lc(e,t)}function F7(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(!nl(r))return r;const i=s===0&&t&&r.text==null?{...r,text:t}:r;return lc(i,n)}):nl(e)?lc(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function z7(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:ry(e,n)}function h1(e,t="rgba(255, 255, 255, 0.62)"){return ry(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 B7(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:ry(e,n)}function H7(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:ry(e,t)}function W7(e,t,n){const r=F7(e.title,n),s=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>nl(a)&&a.text),i=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??O7,textStyle:lc(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:D7(e.tooltip),legend:z7(e.legend,s),grid:e.xAxis!=null||e.yAxis!=null?B7(e.grid,s||i):e.grid,xAxis:h1(e.xAxis),yAxis:h1(e.yAxis),radar:H7(e.radar),series:t}}function V7(e){const t=M7(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(!T7.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");Ab(n);const r=$7(n.option.series),s=n.title==null?"":String(n.title),i=W7(n.option,r,s);return{ok:!0,spec:{...n,title:s,option:i}}}catch(n){return{ok:!1,error:String((n==null?void 0:n.message)||n)}}}function ra(e){let t=String(e||"").trim();return t.includes("|")?(t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&(t=t.slice(0,-1)),t.split("|").map(n=>n.trim())):[]}function XT(e){const t=ra(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function JT(e){return ra(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function U7(e){const t=String(e||"").replace(/\r\n/g,`
137
- `).split(`
138
- `),n=[];let r=[],s=!1;const i=()=>{r.length&&(n.push({type:"markdown",text:r.join(`
139
- `)}),r=[])};for(let a=0;a<t.length;){const l=t[a]||"";if(/^\s*```/.test(l)){s=!s,r.push(l),a++;continue}if(!s&&a+1<t.length&&ra(l).length>1&&XT(t[a+1])){i();const u=ra(l),d=JT(t[a+1]),f=[];for(a+=2;a<t.length&&t[a].trim()&&ra(t[a]).length>1;)f.push(ra(t[a])),a++;n.push({type:"table",headers:u,align:d,rows:f});continue}r.push(l),a++}return i(),n}function QT(e,t=!1){return{...t?{p:({children:n})=>o.jsx(o.Fragment,{children:n})}:{},img:({src:n,alt:r})=>o.jsx("img",{src:e?e(n):n||"",alt:r||"",loading:"lazy"}),a:({href:n,children:r})=>o.jsx("a",{href:n||"",target:"_blank",rel:"noopener noreferrer",children:r})}}function m1({children:e,resolveSrc:t}){return o.jsx(pp,{components:QT(t,!0),children:String(e||"")})}function E0({content:e,resolveSrc:t}){const n=h.useMemo(()=>U7(e),[e]),r=h.useMemo(()=>QT(t),[t]);return o.jsx(o.Fragment,{children:n.map((s,i)=>s.type!=="table"?o.jsx(pp,{components:r,children:s.text},`md-${i}`):o.jsx("div",{className:"af-work-display-table-wrap",children:o.jsxs("table",{className:"af-work-display-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:s.headers.map((a,l)=>o.jsx("th",{style:{textAlign:s.align[l]||"left"},children:o.jsx(m1,{resolveSrc:t,children:a})},l))})}),o.jsx("tbody",{children:s.rows.map((a,l)=>o.jsx("tr",{children:s.headers.map((u,d)=>o.jsx("td",{style:{textAlign:s.align[d]||"left"},children:o.jsx(m1,{resolveSrc:t,children:a[d]||""})},d))},l))})]})},`table-${i}`))})}function K7(e,t=","){const n=[];let r=[],s="",i=!1;const a=String(e||"").replace(/\r\n/g,`
140
- `);for(let l=0;l<a.length;l+=1){const u=a[l],d=a[l+1];if(i){u==='"'&&d==='"'?(s+='"',l+=1):u==='"'?i=!1:s+=u;continue}u==='"'?i=!0:u===t?(r.push(s.trim()),s=""):u===`
141
- `?(r.push(s.trim()),n.push(r),r=[],s=""):s+=u}return(s||r.length)&&(r.push(s.trim()),n.push(r)),n.filter(l=>l.some(u=>String(u||"").trim()))}function ho(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 q7(e){if(Array.isArray(e)){if(e.every(s=>s&&typeof s=="object"&&!Array.isArray(s))){const s=Array.from(new Set(e.flatMap(i=>Object.keys(i))));return{columns:s.map(i=>({key:i,label:i,align:"left"})),rows:e.map(i=>s.map(a=>ho(i[a])))}}if(e.every(Array.isArray)&&e.length>0){const s=e[0].map((i,a)=>ho(i)||`Column ${a+1}`);return{columns:s.map((i,a)=>({key:String(a),label:i,align:"left"})),rows:e.slice(1).map(i=>s.map((a,l)=>ho(i[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,i)=>s&&typeof s=="object"?{key:String(s.key||s.name||s.field||i),label:String(s.label||s.title||s.name||s.key||`Column ${i+1}`),align:["left","center","right"].includes(s.align)?s.align:"left"}:{key:String(i),label:ho(s)||`Column ${i+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,i)=>({key:String(i),label:ho(s)||`Column ${i+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(s=>r.map((i,a)=>ho(s[a])))}):{columns:r,rows:n.map(s=>Array.isArray(s)?r.map((i,a)=>ho(s[a])):s&&typeof s=="object"?r.map(i=>ho(s[i.key])):r.map((i,a)=>a===0?ho(s):""))}}function Y7(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=q7(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const s=r.replace(/\r\n/g,`
142
- `).split(`
143
- `).filter(l=>l.trim());if(s.length>=2&&ra(s[0]).length>1&&XT(s[1])){const l=ra(s[0]),u=JT(s[1]);return{columns:l.map((d,f)=>({key:String(f),label:d,align:u[f]||"left"})),rows:s.slice(2).map(d=>ra(d)),error:""}}const i=r.includes(" ")?" ":",",a=K7(r,i);return a.length>0&&a[0].length>1?{columns:a[0].map((u,d)=>u||`Column ${d+1}`).map((u,d)=>({key:String(d),label:u,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function _0({content:e}){const t=h.useMemo(()=>Y7(e),[e]);return t.error||t.columns.length===0?o.jsxs("div",{className:"af-work-display-table-empty",children:[o.jsx("strong",{children:"Table data error"}),o.jsx("span",{children:t.error||"No columns found"})]}):o.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:o.jsxs("table",{className:"af-work-display-table",children:[o.jsx("thead",{children:o.jsx("tr",{children:t.columns.map((n,r)=>o.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),o.jsx("tbody",{children:t.rows.map((n,r)=>o.jsx("tr",{children:t.columns.map((s,i)=>o.jsx("td",{style:{textAlign:s.align||"left"},children:ho(n[i])},`${s.key}-${i}`))},r))})]})})}function P0({content:e}){const t=h.useRef(null),n=h.useMemo(()=>V7(e),[e]),[r,s]=h.useState({loading:!1,error:""});return h.useEffect(()=>{if(!n.ok){s({loading:!1,error:n.error||"Invalid chart spec"});return}let i=!1,a=null,l=null,u=null;return s({loading:!0,error:""}),I7(()=>import("./index-DgQRkS4v.js"),[]).then(d=>{i||!t.current||(a=d.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),u=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(u),l.observe(t.current)),window.addEventListener("resize",u),window.requestAnimationFrame(u),i||s({loading:!1,error:""}))}).catch(d=>{i||s({loading:!1,error:String((d==null?void 0:d.message)||d)})}),()=>{var d,f;i=!0,u&&window.removeEventListener("resize",u),(d=l==null?void 0:l.disconnect)==null||d.call(l),(f=a==null?void 0:a.dispose)==null||f.call(a)}},[n]),!n.ok||r.error?o.jsxs("div",{className:"af-work-display-chart-error",children:[o.jsx("strong",{children:"Chart configuration error"}),o.jsx("span",{children:r.error||n.error})]}):o.jsxs("div",{className:"af-work-display-chart",children:[o.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?o.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}const G7="af:workspace-graph:v2",Fc=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],X7=new Set(["control_start","control_end","control_load_skills","control_load_mcp"]),J7={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:""}]},Q7={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}]},Z7={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}]},eq=new Set(["png","jpg","jpeg","gif","webp","svg"]),tq=320,ZT=180,eR=960,Ib=96,tR=900,Tb="display-ref:",nq="0.1.61";function rq(){const e=new URLSearchParams(window.location.search);return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",archived:e.get("archived")==="1"||e.get("flowArchived")==="1"}}function Xo(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.archived&&t.set("archived","1"),t}function cg(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 eq.has(n)}function ug(e,t){const n=String(e||"").trim();if(!n)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(n)||n.startsWith("/"))return n;const r=Xo(t||{});return r.set("path",n),`/api/workspace/file/raw?${r.toString()}`}function sq(e,t){const n=String(e||"").trim();if(!n)return"";const r=Xo(t||{});return r.set("path",n),r.set("download","1"),`/api/workspace/file/raw?${r.toString()}`}function iq(e){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=String((e==null?void 0:e.flowSource)||"user").trim()||"user";return`af:composer-skills:workspace:${t}:${n}${e!=null&&e.archived?":archived":""}`}function oq(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function aq(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 lq(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!aq(e)}function cq(e){const t=String(e||"").trim();if(!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 i=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return s==="completed"?`完成:${i}`:`执行:${i}`}return/^\[stderr\]/.test(t)?t:""}function g1(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=String((e==null?void 0:e.text)||"").trim();if(!t)return"";try{const n=JSON.parse(t);if((n==null?void 0:n.type)!=="thinking")return"";const r=String((n==null?void 0:n.subtype)||"");return r&&r!=="delta"?"":String((n==null?void 0:n.text)||(n==null?void 0:n.delta)||(n==null?void 0:n.thinking)||"").trim()}catch{return""}}function nR(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 rR(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function A0(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();if(!t)return String(e.id||"").trim();const n=e.runtime&&typeof e.runtime=="object"?e.runtime:{};return!!(n.entry||n.command)&&t==="tool_nodejs"?String(e.id||"").trim():t}function Vd(e){const t=String(A0(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function y1(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function dg(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function Ud(e){return dg(e)}function Rb(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function Rx(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 x1(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(),i=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,s?`type: ${s}`:"",i?`default: ${i}`:""].filter(Boolean).join(" · ")}function w1(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 b1(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])),i=Ou(s.get(n),e.sourceHandle||"output-0","source"),a=Ou(s.get(r),e.targetHandle||"input-0","target");return!!(i&&a&&Lu(i,a))}function uq(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 i=t.find(l=>l.id===n),a=Ou(i,r,s);return a?{nodeId:n,handleId:r,handleType:s,slot:a,slotType:PT(a)}:null}function dq(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 i=0;i<s.length;i+=1){const a=s[i];if(!(t.handleType==="source"?Lu(t.slot,a):Lu(a,t.slot)))continue;const u=Vd(n);return{def:n,order:r,category:u,categoryRank:Fc.indexOf(u),slot:a,slotIndex:i,displayLabel:Ud(n),description:Rb(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const s=(a=n.slot)!=null&&a.required?0:1,i=(l=r.slot)!=null&&l.required?0:1;return s-i||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function Kd(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 fq(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 i=`${n}_${s}`;if(!r.has(i))return i}return`${n}_${Date.now().toString(36)}`}function pq(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function Oh(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:pq(t),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 sR(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((s,i)=>(s==null?void 0:s.showOnNode)===!1?"":[i,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 hq(e){var s,i;const t=(e==null?void 0:e.data)||{},n=t!=null&&t.displaySize&&typeof t.displaySize=="object"?t.displaySize:{},r=t!=null&&t.nodeSize&&typeof t.nodeSize=="object"?t.nodeSize:{};return[sR(e),Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((s=e==null?void 0:e.measured)==null?void 0:s.width)||0)||"",Number(((i=e==null?void 0:e.measured)==null?void 0:i.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)||"",(t==null?void 0:t.runningRunNodeId)||""].join("::")}function Lx(e,t){var c,p;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=oR(n),s=Array.isArray(e==null?void 0:e.edges)?e.edges:[],i=(c=e==null?void 0:e.ui)!=null&&c.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(p=e==null?void 0:e.ui)!=null&&p.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const m of s)m!=null&&m.source&&l.add(String(m.source)),m!=null&&m.target&&l.add(String(m.target));const d=Array.from(l).map(m=>{const g=r[m]||{},b=g.definitionId||m,k=t.find(B=>B.id===b),y=A0(k)||b,v=t.find(B=>B.id===y)||k,w=g.marketplaceRef||rR(k),j=i[m]&&typeof i[m].x=="number"&&typeof i[m].y=="number"?i[m]:{x:320+l.size*20,y:180+l.size*12},P=!!Kn(y),_=a[m]&&typeof a[m].width=="number"&&typeof a[m].height=="number"?{width:a[m].width,height:a[m].height}:null,L=mu(_,{display:P});return{id:m,type:mp,position:j,...L?{width:L.width,height:L.height}:{},data:{label:g.label||dg(k)||dg(v)||m,definitionId:y,...w?{marketplaceRef:w}:{},...k!=null&&k.packageId?{marketplacePackageId:k.packageId}:{},...k!=null&&k.version?{marketplaceVersion:k.version}:{},schemaType:nR(y,v||k),role:g.role||"normal",model:g.model||void 0,body:g.body||"",script:g.script||"",...L?{nodeSize:L}:{},...P&&L?{displaySize:L}:{}}}}).map(m=>qf(m,r,t)),f=s.filter(m=>(m==null?void 0:m.source)&&(m==null?void 0:m.target)).map((m,g)=>({id:m.id||`we-${m.source}-${m.target}-${g}`,source:String(m.source),target:String(m.target),sourceHandle:m.sourceHandle??void 0,targetHandle:m.targetHandle??void 0,markerEnd:{type:Ls.ArrowClosed}}));return{nodes:d,edges:ET(f,d),instances:r}}function v1(e){return`${Tb}${e}`}function Ox(e){const t=String(e||"");return t.startsWith(Tb)?t.slice(Tb.length):t}function iR(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 Lb(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(c=>{var p;return Kn((p=c==null?void 0:c.data)==null?void 0:p.definitionId)}).map(c=>[c.id,c])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],s=[],i=new Set;for(const c of r){const p=String(c||"").trim();!p||i.has(p)||!n.has(p)||(i.add(p),s.push(p))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};s.forEach((c,p)=>{const m=l[c];a[c]=m&&typeof m.x=="number"&&typeof m.y=="number"?{x:m.x,y:m.y}:{x:180+p*36,y:120+p*28}});const u={},d=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};s.forEach(c=>{const p=mu(d[c],{display:!0});p&&(u[c]=p)});const f=iR(e==null?void 0:e.viewport);return{nodeIds:s,nodePositions:a,nodeSizes:u,...f?{viewport:f}:{}}}function mq(e,t=[]){return Lb(e,t)}function gq(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function yq(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 k1(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function mu(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:k1(n,ZT,eR)||tq,height:k1(r,Ib,tR)||Ib}}function zc(e){var s,i,a,l,u,d,f,c,p,m,g;const t=!!Kn((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Number(((a=(i=e==null?void 0:e.data)==null?void 0:i.displaySize)==null?void 0:a.width)||((u=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:u.width)||(e==null?void 0:e.width)||(t?(d=e==null?void 0:e.measured)==null?void 0:d.width:0)||0),r=Number(((c=(f=e==null?void 0:e.data)==null?void 0:f.displaySize)==null?void 0:c.height)||((m=(p=e==null?void 0:e.data)==null?void 0:p.nodeSize)==null?void 0:m.height)||(e==null?void 0:e.height)||(t?(g=e==null?void 0:e.measured)==null?void 0:g.height:0)||0);return mu({width:n,height:r},{display:t})}function Mh(e,t,n){var l,u;const r=oR(hp(e,n||{})),s=t.map(d=>({source:d.source,target:d.target,sourceHandle:d.sourceHandle??null,targetHandle:d.targetHandle??null})),i={},a={};for(const d of e){i[d.id]={x:((l=d.position)==null?void 0:l.x)||0,y:((u=d.position)==null?void 0:u.y)||0};const f=zc(d);f&&(a[d.id]=f)}return{version:1,instances:r,edges:s,ui:{nodePositions:i,nodeSizes:a}}}function oR(e){const t={};for(const[n,r]of Object.entries(e||{})){const s=String((r==null?void 0:r.definitionId)||n);if(!!Kn(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 Kn(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function Jl(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],r=Kn(e==null?void 0:e.definitionId)==="image"?"src":"content",s=l=>String((l==null?void 0:l.value)??(l==null?void 0:l.default)??""),i=l=>s(l).trim(),a=t.find(l=>(l==null?void 0:l.name)===r&&i(l))||t.find(l=>(l==null?void 0:l.name)==="filePath"&&i(l))||t.find(l=>(l==null?void 0:l.type)==="text"&&i(l));return String((e==null?void 0:e.body)||(a?s(a):""))}function Wu(e){let t=String(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 i=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);i&&i[1]&&(t=i[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((i,a)=>{const l=a.exec(t);return l?i<0?l.index:Math.min(i,l.index):i},-1);return s>0&&(t=t.slice(s).trim()),t}function aR(e){const t=Wu(e);if(!t.trim())return"";if(/<base\s+[^>]*target\s*=/i.test(t))return t;const n='<base target="_blank">';return/<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 xq(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 wq(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function S1(e,t){const n=URL.createObjectURL(e);try{wq(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function bq(e){const t=Wu(e),n=new DOMParser().parseFromString(t||"<body></body>","text/html"),r=new XMLSerializer,s=Array.from(n.querySelectorAll("style")).map(a=>r.serializeToString(a)).join(`
144
- `),i=n.body?Array.from(n.body.childNodes).map(a=>r.serializeToString(a)).join(""):t;return`
145
- <style>
146
- * { box-sizing: border-box; }
147
- html, body { margin: 0; min-height: 100%; background: transparent; }
148
- .af-html-snapshot-root { width: 100%; min-height: 100%; overflow: hidden; }
149
- </style>
150
- ${s}
151
- <div xmlns="http://www.w3.org/1999/xhtml" class="af-html-snapshot-root">${i}</div>
152
- `}async function vq({content:e,width:t,height:n,filename:r}){const s=Math.max(1,Math.round(Number(t)||960)),i=Math.max(1,Math.round(Number(n)||640)),a=`<?xml version="1.0" encoding="UTF-8"?>
153
- <svg xmlns="http://www.w3.org/2000/svg" width="${s}" height="${i}" viewBox="0 0 ${s} ${i}">
154
- <foreignObject width="100%" height="100%">
155
- <div xmlns="http://www.w3.org/1999/xhtml" style="width:${s}px;height:${i}px;overflow:hidden;background:#ffffff;">
156
- ${bq(e)}
157
- </div>
158
- </foreignObject>
159
- </svg>`,l=new Blob([a],{type:"image/svg+xml;charset=utf-8"}),u=URL.createObjectURL(l);try{const d=new Image;d.decoding="async",d.src=u,await d.decode();const f=document.createElement("canvas");f.width=s,f.height=i;const c=f.getContext("2d");if(!c)throw new Error("Canvas is unavailable");c.drawImage(d,0,0,s,i);const p=await new Promise(m=>f.toBlob(m,"image/png"));if(!p)throw new Error("Could not encode PNG");S1(p,r)}catch(d){throw S1(l,r.replace(/\.png$/i,".svg")),d}finally{URL.revokeObjectURL(u)}}function kq(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 Sq(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function Nq(e){const t=String(e||"").split(/\r?\n/).map(l=>l.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[];let s="TD";const i=(l,u="")=>{const d=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(d)?u&&(n.get(d).label=u):n.set(d,{id:d,label:u||d}),d},a=l=>{const u=String(l||"").trim().replace(/[;,]+$/,""),d=u.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return d?i(d[1],d[2]||d[3]||d[4]||d[1]):i(u.replace(/[^A-Za-z0-9_]/g,"_"),u)};for(const l of t){const u=l.match(/^(graph|flowchart)\s+(TD|TB|BT|LR|RL)\b/i);if(u){s=u[2].toUpperCase();continue}const d=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(d){r.push({from:a(d[1]),to:a(d[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:s}}function lR({code:e}){const t=h.useMemo(()=>Nq(e),[e]);if(!String(e||"").trim())return null;const n=t.direction==="LR"||t.direction==="RL",r=142,s=44,i=n?96:32,a=n?30:68,l=new Map;t.nodes.forEach((f,c)=>{l.set(f.id,{x:24+(n?c*(r+i):c%3*(r+i)),y:24+(n?c%3*(s+a):c*(s+a))})});const u=Math.max(360,...Array.from(l.values()).map(f=>f.x+r+24)),d=Math.max(180,...Array.from(l.values()).map(f=>f.y+s+24));return o.jsx("div",{className:"af-work-node__mermaid-preview",children:o.jsxs("svg",{viewBox:`0 0 ${u} ${d}`,role:"img","aria-label":"Mermaid preview",children:[o.jsx("defs",{children:o.jsx("marker",{id:"af-work-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:o.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((f,c)=>{const p=l.get(f.from),m=l.get(f.to);if(!p||!m)return null;const g=n?`M ${p.x+r} ${p.y+s/2} C ${(p.x+m.x+r)/2} ${p.y+s/2}, ${(p.x+m.x+r)/2} ${m.y+s/2}, ${m.x} ${m.y+s/2}`:`M ${p.x+r/2} ${p.y+s} C ${p.x+r/2} ${p.y+s+28}, ${m.x+r/2} ${m.y-28}, ${m.x+r/2} ${m.y}`;return o.jsx("path",{className:"af-work-node__mermaid-edge",d:g,markerEnd:"url(#af-work-arrow)"},`${f.from}-${f.to}-${c}`)}),t.nodes.map(f=>{const c=l.get(f.id);return o.jsxs("g",{children:[o.jsx("rect",{className:"af-work-node__mermaid-box",x:c.x,y:c.y,width:r,height:s,rx:"8"}),o.jsx("text",{className:"af-work-node__mermaid-text",x:c.x+r/2,y:c.y+s/2+5,textAnchor:"middle",children:f.label.slice(0,22)})]},f.id)})]})})}function La({className:e="",children:t}){const n=h.useRef(null),r=h.useRef(null),[s,i]=h.useState({visible:!1,top:0,height:100}),a=h.useCallback(()=>{const f=n.current;if(!f)return;const c=Math.max(1,f.scrollHeight),p=Math.max(1,f.clientHeight),m=c>p+1,g=m?Math.max(12,p/c*100):100,b=Math.max(0,100-g),k=m?Math.min(b,f.scrollTop/Math.max(1,c-p)*b):0;i({visible:m,top:k,height:g})},[]);h.useEffect(()=>{const f=requestAnimationFrame(a),c=n.current;if(!c||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(f);const p=new ResizeObserver(a);p.observe(c);for(const m of Array.from(c.children))p.observe(m);return()=>{cancelAnimationFrame(f),p.disconnect()}},[t,a]);const l=h.useCallback(f=>{const c=n.current;if(!c)return;const p=Math.max(0,c.scrollHeight-c.clientHeight);c.scrollTop=Math.min(1,Math.max(0,f))*p,a()},[a]),u=h.useCallback((f,c=0)=>{const p=r.current;if(!p)return 0;const m=p.getBoundingClientRect(),g=s.height/100*m.height,b=Math.max(1,m.height-g);return(f-m.top-c)/b},[s.height]),d=h.useCallback(f=>{var j,P;if(!s.visible)return;f.preventDefault(),f.stopPropagation();const c=r.current;if(!c)return;const p=c.getBoundingClientRect(),m=s.top/100*p.height,g=s.height/100*p.height,k=f.clientY>=p.top+m&&f.clientY<=p.top+m+g?f.clientY-p.top-m:g/2;l(u(f.clientY,k));const y=f.pointerId;(P=(j=f.currentTarget).setPointerCapture)==null||P.call(j,y);const v=_=>{_.preventDefault(),l(u(_.clientY,k))},w=()=>{window.removeEventListener("pointermove",v),window.removeEventListener("pointerup",w),window.removeEventListener("pointercancel",w)};window.addEventListener("pointermove",v),window.addEventListener("pointerup",w),window.addEventListener("pointercancel",w)},[u,l,s.height,s.top,s.visible]);return o.jsxs("div",{className:`af-visible-scroll-frame ${e}`,children:[o.jsx("div",{ref:n,className:`af-visible-scroll-frame__scroller ${e}`,onScroll:a,children:t}),o.jsx("div",{ref:r,className:"af-visible-scrollbar"+(s.visible?" af-visible-scrollbar--visible":""),onPointerDown:d,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function jq({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const s=Kn(e==null?void 0:e.definitionId);if(!s)return null;const i=Jl(e),a=s==="html"?Wu(i):i;if(!a.trim())return o.jsx(La,{className:"af-work-display-empty",children:"No display content"});if(s==="html")return o.jsx(La,{className:"af-work-display-body af-work-display-body--html",children:o.jsx("iframe",{ref:n,className:"af-work-display-html-frame",title:(e==null?void 0:e.label)||"HTML preview",sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:aR(a)},r)});if(s==="image"){const l=ug(a,t);return o.jsx(La,{className:"af-work-display-body af-work-display-body--image",children:o.jsx("img",{className:"af-work-display-image",src:l,alt:kq(e),loading:"lazy"})})}return s==="markdown"?o.jsx(La,{className:"af-work-display-body af-work-display-body--markdown",children:o.jsx(E0,{content:a,resolveSrc:l=>ug(l,t)})}):s==="chart"?o.jsx(La,{className:"af-work-display-body af-work-display-body--chart",children:o.jsx(P0,{content:a})}):s==="table"?o.jsx(La,{className:"af-work-display-body af-work-display-body--table",children:o.jsx(_0,{content:a})}):s==="mermaid"?o.jsxs(La,{className:"af-work-display-body",children:[o.jsx(lR,{code:a}),o.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:a})]}):o.jsx(La,{className:"af-work-display-body af-work-display-body--ascii",children:o.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--ascii",children:a})})}function Cq({node:e}){var s,i,a,l;const t=Kn((s=e==null?void 0:e.data)==null?void 0:s.definitionId),n=Jl(e==null?void 0:e.data),r=t==="html"?Wu(n):n;return r.trim()?t==="html"?o.jsx("iframe",{title:((i=e==null?void 0:e.data)==null?void 0:i.label)||(e==null?void 0:e.id),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:aR(r)}):t==="image"?o.jsx("img",{src:ug(r,(a=e==null?void 0:e.data)==null?void 0:a.flowParams),alt:((l=e==null?void 0:e.data)==null?void 0:l.label)||(e==null?void 0:e.id),loading:"lazy"}):t==="markdown"?o.jsx("div",{className:"af-display-picker-preview__markdown",children:o.jsx(E0,{content:r,resolveSrc:u=>{var d;return ug(u,(d=e==null?void 0:e.data)==null?void 0:d.flowParams)}})}):t==="chart"?o.jsx(P0,{content:r}):t==="table"?o.jsx(_0,{content:r}):t==="mermaid"?o.jsxs("div",{className:"af-display-picker-preview__diagram",children:[o.jsx(lR,{code:r}),o.jsx("pre",{children:r})]}):o.jsx("pre",{className:"af-display-picker-preview__pre",children:r}):o.jsx("div",{className:"af-display-picker-preview__empty",children:"No content"})}function Eq({value:e,onChange:t,onUploadImage:n,readOnly:r=!1}){const s=h.useRef(null),i=h.useRef(null),[a,l]=h.useState(!1),u=h.useCallback(f=>{const c=String(e||""),p=s.current,m=Number((p==null?void 0:p.selectionStart)??c.length),g=Number((p==null?void 0:p.selectionEnd)??m),b=c.slice(0,m),k=c.slice(g),y=b&&!b.endsWith(`
160
- `)?`
161
- `:"",v=k&&!k.startsWith(`
162
- `)?`
163
- `:"",w=`${b}${y}${f}${v}${k}`;t==null||t(w),window.requestAnimationFrame(()=>{var P,_;const j=b.length+y.length+f.length;(P=s.current)==null||P.focus(),(_=s.current)==null||_.setSelectionRange(j,j)})},[t,e]),d=h.useCallback(async f=>{if(!r&&!(!f||a)){l(!0);try{const c=await(n==null?void 0:n(f)),p=String(c||"").trim();if(p){const m=String(f.name||"image").replace(/\.[^.]+$/g,"").trim()||"image";u(`![${m}](${p})`)}}finally{l(!1)}}},[u,n,r,a]);return o.jsxs("div",{className:"af-work-display-editor nodrag nopan",onClick:f=>f.stopPropagation(),onDragOver:f=>{var p;Array.from(((p=f.dataTransfer)==null?void 0:p.items)||[]).some(m=>String((m==null?void 0:m.type)||"").startsWith("image/"))&&(f.preventDefault(),f.dataTransfer.dropEffect="copy")},onDrop:f=>{var p;const c=Array.from(((p=f.dataTransfer)==null?void 0:p.files)||[]).find(cg);c&&(f.preventDefault(),d(c))},children:[o.jsxs("div",{className:"af-work-display-editor__toolbar",children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:a||r,onClick:()=>{var f;return(f=i.current)==null?void 0:f.click()},"aria-label":"上传图片",title:"上传图片",children:o.jsx("span",{className:"material-symbols-outlined",children:a?"hourglass_top":"add_photo_alternate"})}),o.jsx("input",{ref:i,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:f=>{var p;const c=(p=f.target.files)==null?void 0:p[0];f.target.value="",c&&d(c)}})]}),o.jsx("textarea",{ref:s,className:"af-work-display-editor__textarea",value:e,onChange:f=>t==null?void 0:t(f.target.value),onKeyDown:f=>{f.key==="Escape"&&f.stopPropagation()},placeholder:"输入 Markdown 内容",spellCheck:!1,readOnly:r})]})}function _q({nodeId:e,data:t}){const n=t==null?void 0:t.nodeChatActive,r=!!(t!=null&&t.selected),s=(t==null?void 0:t.nodeChat)||{},i=Array.isArray(s.messages)?s.messages:[],a=String(s.draft||""),[l,u]=h.useState(a),d=h.useRef(!1),f=String(s.candidateContent||""),c=!!s.running,p=!!(t!=null&&t.readOnly),m=String(s.error||"");return h.useEffect(()=>{d.current||u(a)},[a]),!n&&!r?null:n?o.jsxs("div",{className:"af-work-node-chat nodrag nopan",onClick:g=>g.stopPropagation(),children:[o.jsxs("div",{className:"af-work-node-chat__head",children:[o.jsxs("div",{children:[o.jsx("strong",{children:"继续微调"}),o.jsx("span",{children:(t==null?void 0:t.label)||e})]}),o.jsx("button",{type:"button",onClick:()=>{var g;return(g=t==null?void 0:t.onCloseNodeChat)==null?void 0:g.call(t)},"aria-label":"关闭节点微调",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),i.length>0||c||m||f.trim()?o.jsxs("div",{className:"af-work-node-chat__messages",children:[i.slice(-4).map((g,b)=>o.jsxs("div",{className:`af-work-node-chat__msg af-work-node-chat__msg--${g.role==="assistant"?"assistant":"user"}`,children:[o.jsx("span",{children:g.role==="assistant"?"AI":"你"}),o.jsx("p",{children:g.text})]},`${g.at||b}-${b}`)),c?o.jsx("div",{className:"af-work-node-chat__pending",children:"生成中..."}):null,m?o.jsx("div",{className:"af-work-node-chat__error",children:m}):null]}):null,o.jsxs("div",{className:"af-work-node-chat__composer",children:[o.jsx("button",{type:"button",className:"af-work-node-chat__add",disabled:c||p,"aria-label":"添加上下文",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),o.jsx("textarea",{className:"af-work-node-chat__input",rows:2,value:l,disabled:c||p,placeholder:"描述你想怎么调整这个展示",onCompositionStart:()=>{d.current=!0},onCompositionEnd:g=>{var k;d.current=!1;const b=g.currentTarget.value;u(b),(k=t==null?void 0:t.onUpdateNodeChatDraft)==null||k.call(t,e,b)},onChange:g=>{var k;const b=g.target.value;u(b),d.current||(k=t==null?void 0:t.onUpdateNodeChatDraft)==null||k.call(t,e,b)},onKeyDown:g=>{var b,k;g.isComposing||(b=g.nativeEvent)!=null&&b.isComposing||g.keyCode===229||(g.metaKey||g.ctrlKey)&&g.key==="Enter"&&(g.preventDefault(),(k=t==null?void 0:t.onSendNodeChat)==null||k.call(t,e,l))}}),o.jsx("button",{type:"button",className:"af-work-node-chat__send",disabled:c||p||!l.trim(),onClick:()=>{var g;return(g=t==null?void 0:t.onSendNodeChat)==null?void 0:g.call(t,e,l)},"aria-label":"发送",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]}),o.jsxs("div",{className:"af-work-node-chat__actions",children:[o.jsx("button",{type:"button",disabled:c||p||!f.trim(),onClick:()=>{var g;return(g=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:g.call(t,e,"replace")},children:"替换当前内容"}),o.jsx("button",{type:"button",disabled:c||p||!f.trim(),onClick:()=>{var g;return(g=t==null?void 0:t.onApplyNodeChatCandidate)==null?void 0:g.call(t,e,"append")},children:"追加"})]})]}):o.jsxs("button",{type:"button",className:"af-work-node-chat-anchor nodrag nopan",onClick:g=>{var b;g.stopPropagation(),(b=t==null?void 0:t.onToggleNodeChat)==null||b.call(t,e)},title:"微调这个节点","aria-label":"微调这个节点",children:[o.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__plus","aria-hidden":!0,children:"add"}),o.jsx("span",{className:"af-work-node-chat-anchor__label",children:"继续微调这个展示"}),o.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__expand","aria-hidden":!0,children:"open_in_full"})]})}function Pq(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function Aq(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function Iq(e,t){const n=Kn(t==null?void 0:t.definitionId)||"markdown";return`outputs/${Aq((t==null?void 0:t.label)||e||n)}.${Pq(n)}`}function Tq({id:e,data:t,selected:n,deleteNode:r}){const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],a=(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).map((C,T)=>({slot:C,idx:T})).sort((C,T)=>{var se,de,fe,pe;const E=String(((se=C.slot)==null?void 0:se.name)||"").trim(),G=String(((de=T.slot)==null?void 0:de.name)||"").trim();if(E==="next"&&G!=="next")return-1;if(G==="next"&&E!=="next")return 1;const Z=String(((fe=C.slot)==null?void 0:fe.type)||"").trim(),V=String(((pe=T.slot)==null?void 0:pe.type)||"").trim();return Z==="node"&&V!=="node"?-1:V==="node"&&Z!=="node"?1:C.idx-T.idx}),l=Kn(t==null?void 0:t.definitionId),u=h.useRef(null),[d,f]=h.useState(0),[c,p]=h.useState(!1),[m,g]=h.useState(!1),[b,k]=h.useState(!1),[y,v]=h.useState(""),[w,j]=h.useState(!1),P=h.useRef(null),_=Jl(t),L=l==="markdown"?_:"",B=!!(t!=null&&t.readOnly),D=!!(t!=null&&t.displayPageMode);h.useEffect(()=>{if(!m)return;const C=()=>g(!1);return window.addEventListener("pointerup",C,!0),window.addEventListener("pointercancel",C,!0),window.addEventListener("mouseup",C,!0),window.addEventListener("blur",C),()=>{window.removeEventListener("pointerup",C,!0),window.removeEventListener("pointercancel",C,!0),window.removeEventListener("mouseup",C,!0),window.removeEventListener("blur",C)}},[m]),h.useEffect(()=>{b||v(String(L||""))},[L,b]);const F=(t==null?void 0:t.label)||(l==="mermaid"?"Mermaid":l==="ascii"?"ASCII":l==="html"?"HTML":l==="image"?"Image":l==="chart"?"Chart":l==="table"?"Table":"Markdown"),R=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,M=h.useCallback(async()=>{var Z,V;if(l!=="html"||c)return;const C=Wu(Jl(t));if(!C.trim())return;const T=(V=(Z=u.current)==null?void 0:Z.getBoundingClientRect)==null?void 0:V.call(Z),E=Math.round((T==null?void 0:T.width)||Math.max(320,Number((R==null?void 0:R.width)||960)-2)),G=Math.round((T==null?void 0:T.height)||Math.max(180,Number((R==null?void 0:R.height)||640)-46));p(!0);try{await vq({content:C,width:E,height:G,filename:xq((t==null?void 0:t.label)||e||"html-render","png")})}catch(se){console.warn("Failed to save HTML display as PNG; downloaded SVG fallback.",se)}finally{p(!1)}},[t,R==null?void 0:R.height,R==null?void 0:R.width,e,l,c]),W=h.useCallback(C=>{var T;B||!C||l!=="image"||(T=t==null?void 0:t.onUploadImageToDisplayNode)==null||T.call(t,e,C)},[t,e,l,B]),O=h.useCallback(C=>{var T,E;(T=C==null?void 0:C.stopPropagation)==null||T.call(C),!B&&((E=t==null?void 0:t.onSetDisplayNodeContent)==null||E.call(t,e,"","replace",{logChat:!1,statusMessage:"已清空 Display 内容"}),l==="markdown"&&(v(""),k(!1)))},[t,e,l,B]),$=h.useCallback(C=>{var G,Z;B||l!=="image"||!(Array.from(((G=C.dataTransfer)==null?void 0:G.files)||[]).some(cg)||Array.from(((Z=C.dataTransfer)==null?void 0:Z.items)||[]).some(V=>String((V==null?void 0:V.type)||"").startsWith("image/")))||(C.preventDefault(),C.stopPropagation(),C.dataTransfer.dropEffect="copy",j(!0))},[l,B]),I=h.useCallback(C=>{l==="image"&&(C.currentTarget.contains(C.relatedTarget)||j(!1))},[l]),z=h.useCallback(C=>{var E;if(l!=="image")return;const T=Array.from(((E=C.dataTransfer)==null?void 0:E.files)||[]).find(cg);T&&(C.preventDefault(),C.stopPropagation(),j(!1),W(T))},[l,W]);return o.jsxs("div",{className:"af-work-display-card"+(R?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(m?" af-work-display-card--resizing":"")+(w?" af-work-display-card--image-drop":"")+(D?" 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:R?{width:R.width,height:R.height}:void 0,onDragOver:$,onDragLeave:I,onDrop:z,children:[o.jsx(XA,{className:"af-work-display-resize nodrag",position:"bottom-right",minWidth:320,minHeight:180,onResizeStart:()=>g(!0),onResizeEnd:()=>g(!1),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),s.map((C,T)=>{if(C.showOnNode===!1)return null;const E=`${4.15+T*1.75}rem`,G=C.name||`#${T+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:E},children:G}),o.jsx(Ms,{type:"target",position:Xe.Left,id:`input-${T}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:E,background:nr(C.type)},title:`${G} · ${C.type}`})]},`in-${T}`)}),a.map(({slot:C,idx:T},E)=>{if(C.showOnNode===!1)return null;const G=`${4.15+E*1.75}rem`,Z=C.name||`#${T+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:G},children:Z}),o.jsx(Ms,{type:"source",position:Xe.Right,id:`output-${T}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:G,background:nr(C.type)},title:`${Z} · ${C.type}`})]},`out-${T}`)}),o.jsxs("div",{className:"af-work-display-card__head",children:[o.jsxs("div",{className:"af-work-display-card__title",children:[o.jsx("span",{className:"material-symbols-outlined",children:Sq(l)}),o.jsx("strong",{children:F}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"display"})]}),l==="html"?o.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:C=>C.stopPropagation(),children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var C,T,E,G;try{(G=(E=(T=(C=u.current)==null?void 0:C.contentWindow)==null?void 0:T.history)==null?void 0:E.back)==null||G.call(E)}catch{}},"aria-label":"后退",title:"后退",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var C,T,E,G;try{(G=(E=(T=(C=u.current)==null?void 0:C.contentWindow)==null?void 0:T.history)==null?void 0:E.forward)==null||G.call(E)}catch{}},"aria-label":"前进",title:"前进",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_forward"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>f(C=>C+1),"aria-label":"刷新",title:"刷新",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:c,onClick:M,"aria-label":"截图另存为图片",title:"截图另存为图片",children:o.jsx("span",{className:"material-symbols-outlined",children:c?"hourglass_empty":"photo_camera"})})]}):null,l==="markdown"?b?o.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:C=>C.stopPropagation(),children:[o.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:B,onClick:()=>{var C;(C=t==null?void 0:t.onSetDisplayNodeContent)==null||C.call(t,e,y,"replace",{logChat:!1,statusMessage:"已更新 Markdown 内容"}),k(!1)},"aria-label":"保存并预览",title:"保存并预览",children:o.jsx("span",{className:"material-symbols-outlined",children:"done"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{v(String(L||"")),k(!1)},"aria-label":"取消编辑",title:"取消编辑",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}):o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:B,onClick:C=>{C.stopPropagation(),v(String(L||"")),k(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:o.jsx("span",{className:"material-symbols-outlined",children:"edit"})}):null,l==="image"?o.jsxs(o.Fragment,{children:[o.jsx("input",{ref:P,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:C=>{var E;const T=(E=C.target.files)==null?void 0:E[0];C.target.value="",T&&W(T)}}),o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:B,onClick:C=>{var T;C.stopPropagation(),(T=P.current)==null||T.click()},"aria-label":"上传图片",title:"上传图片",children:o.jsx("span",{className:"material-symbols-outlined",children:"upload"})})]}):null,o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:B,onClick:O,"aria-label":"清空内容",title:"清空内容",children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_sweep"})}),o.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:B,onClick:()=>{var C;return(C=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:C.call(t,e,t)},"aria-label":"另存为文件",title:"另存为文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"save"})}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:B,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),l==="markdown"&&b?o.jsx(Eq,{value:y,onChange:v,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:B}):o.jsx(jq,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:u,htmlFrameVersion:d}),o.jsx(_q,{nodeId:e,data:t})]})}function Rq({id:e,data:t,selected:n,deleteNode:r}){const s=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],i=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=(t==null?void 0:t.runningRunNodeId)===e,l=(t==null?void 0:t.nodeStatus)==="stopped",u=!!(t!=null&&t.readOnly);return o.jsxs("div",{className:"af-work-run-card"+(n?" af-work-run-card--selected":"")+(a?" af-work-run-card--running":"")+(t!=null&&t.isExecuting?" af-work-run-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-run-card--failed":"")+(l?" af-work-run-card--stopped":""),children:[s.map((d,f)=>{if(d.showOnNode===!1)return null;const c=`${2.25+f*1.75}rem`,p=d.name||`#${f+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:c},children:p}),o.jsx(Ms,{type:"target",position:Xe.Left,id:`input-${f}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:c,background:nr(d.type)},title:`${p} · ${d.type}`})]},`in-${f}`)}),i.map((d,f)=>{if(d.showOnNode===!1)return null;const c=`${2.25+f*1.75}rem`,p=d.name||`#${f+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:c},children:p}),o.jsx(Ms,{type:"source",position:Xe.Right,id:`output-${f}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:c,background:nr(d.type)},title:`${p} · ${d.type}`})]},`out-${f}`)}),o.jsxs("div",{className:"af-work-run-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"play_circle"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Run"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_run"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:u,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("button",{type:"button",className:"af-work-run-card__button nodrag"+(a?" af-work-run-card__button--stop":""),disabled:u,onClick:d=>{var f,c;d.stopPropagation(),a?(f=t==null?void 0:t.onStopWorkspaceNode)==null||f.call(t,e):(c=t==null?void 0:t.onRunWorkspaceNode)==null||c.call(t,e)},children:[o.jsx("span",{className:"material-symbols-outlined",children:a?"stop_circle":"play_arrow"}),o.jsx("span",{children:a?"Stop":"Run line"})]})]})}function Lq(e){var m,g,b,k,y,v,w,j,P,_,L,B,D;const{setEdges:t,setNodes:n}=fc(),r=(m=e.data)==null?void 0:m.onSyncNodePropDraft,s=!!((g=e.data)!=null&&g.readOnly),[i,a]=h.useState(!1),l=(b=e.data)!=null&&b.nodeSize&&Number(e.data.nodeSize.width)>0&&Number(e.data.nodeSize.height)>0?{width:Number(e.data.nodeSize.width),height:Number(e.data.nodeSize.height)}:null,u=h.useCallback(F=>{s||(n(R=>R.filter(M=>M.id!==F)),t(R=>R.filter(M=>M.source!==F&&M.target!==F)))},[s,t,n]),d=h.useCallback((F,R)=>{s||(n(M=>M.map(W=>W.id===F?{...W,data:{...W.data,model:R}}:W)),r==null||r(F,{model:R}))},[s,n,r]),f=h.useCallback((F,R)=>{s||(n(M=>M.map(W=>{var $;if(W.id!==F)return W;const O=Array.isArray(($=W.data)==null?void 0:$.outputs)&&W.data.outputs.length?W.data.outputs.map((I,z)=>z===0?{...I,default:R,value:R}:I):[{type:"bool",name:"value",default:R,value:R}];return{...W,data:{...W.data,body:"",outputs:O}}})),r==null||r(F,M=>({body:"",outputs:Array.isArray(M==null?void 0:M.outputs)&&M.outputs.length?M.outputs.map((O,$)=>$===0?{...O,default:R,value:R}:O):[{type:"bool",name:"value",default:R,value:R}]})))},[s,n,r]),c=h.useCallback((F,R)=>{s||(n(M=>M.map(W=>W.id===F?{...W,data:{...W.data,body:R}}:W)),r==null||r(F,{body:R}))},[s,n,r]),p=h.useCallback((F,R)=>{if(s)return;const M=Ps(R);n(W=>W.map(O=>O.id===F?{...O,data:{...O.data,images:M}}:O)),r==null||r(F,{images:M})},[s,n,r]);return Kn((k=e.data)==null?void 0:k.definitionId)?o.jsx(Tq,{...e,deleteNode:u}):((y=e.data)==null?void 0:y.definitionId)==="workspace_run"?o.jsx(Rq,{...e,deleteNode:u}):((v=e.data)==null?void 0:v.definitionId)==="control_load_skills"?o.jsx(Kq,{...e,deleteNode:u,skills:(w=e.data)==null?void 0:w.skills,skillCollections:(j=e.data)==null?void 0:j.skillCollections,onChangeSkillKeys:(P=e.data)==null?void 0:P.onChangeLoadSkillKeys}):((_=e.data)==null?void 0:_.definitionId)==="control_load_mcp"?o.jsx(qq,{...e,deleteNode:u,servers:(L=e.data)==null?void 0:L.mcpServers,onChangeMcpNames:(B=e.data)==null?void 0:B.onChangeLoadMcpNames}):o.jsxs("div",{className:"af-work-flow-node"+(e.selected?" af-work-flow-node--selected":"")+(i?" af-work-flow-node--resizing":""),style:l?{width:l.width,height:l.height}:void 0,children:[s?null:o.jsx(XA,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:ZT,minHeight:Ib,maxWidth:eR,maxHeight:tR,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),o.jsx(AT,{...e,deleteNode:u,modelLists:(D=e.data)==null?void 0:D.modelLists,onModelChange:d,onProvideValueChange:f,onNodeBodyChange:c,onNodeImagesChange:p})]})}const Oq={[mp]:Lq};function cR(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&cR(n.children,t);return t}function uR(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&uR(n.children,t));return t}function $h(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 Mq(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function $q(e,t,n=0){const r=String(t||"").replace(/\\/g,"/").split("/").filter(Boolean);if(r.length===0)return e;const s=(i,a,l)=>{const u=r[a],d=l?`${l}/${u}`:u,f=a===r.length-1;let c=!1;const p=(Array.isArray(i)?i:[]).map(m=>m.name!==u?m:(c=!0,f?{...m,type:"file",name:u,path:d,icon:Kd(u),size:n}:{...m,type:"directory",name:u,path:d,icon:Kd(u,!0),children:s(m.children||[],a+1,d)}));return c||p.push(f?{type:"file",name:u,path:d,icon:Kd(u),size:n}:{type:"directory",name:u,path:d,icon:Kd(u,!0),children:s([],a+1,d)}),Mq(p)};return s(e||[],0,"")}function dR({items:e,flowParams:t,onOpen:n,collapsedDirs:r,onToggleDir:s,onCreateFile:i,onCreateFolder:a,onDelete:l,onFileDragStart:u}){return o.jsx("ul",{className:"af-work-files",children:(e||[]).map(d=>{var p;const f=d.type==="directory",c=f&&(r==null?void 0:r.has(d.path));return o.jsxs("li",{children:[o.jsxs("div",{className:"af-work-file-row",children:[o.jsxs("button",{type:"button",className:"af-work-file af-work-file--"+d.type,draggable:!f,onDragStart:m=>{f||u==null||u(m,d)},onClick:()=>f?s==null?void 0:s(d.path):n(d),title:d.path,children:[f?o.jsx("span",{className:"material-symbols-outlined af-work-file__chevron",children:c?"chevron_right":"expand_more"}):null,o.jsx("span",{className:"material-symbols-outlined",children:d.icon||Kd(d.name,f)}),o.jsx("span",{children:d.name})]}),f?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"af-work-file-action",onClick:()=>i==null?void 0:i(d.path),title:"新增文件","aria-label":`在 ${d.name} 新增文件`,children:o.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),o.jsx("button",{type:"button",className:"af-work-file-action",onClick:()=>a==null?void 0:a(d.path),title:"新增文件夹","aria-label":`在 ${d.name} 新增文件夹`,children:o.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})})]}):null,f?null:o.jsx("a",{className:"af-work-file-action",href:sq(d.path,t),download:d.name,onClick:m=>m.stopPropagation(),title:"下载","aria-label":`下载 ${d.name}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"download"})}),o.jsx("button",{type:"button",className:"af-work-file-action af-work-file-action--danger",onClick:()=>l==null?void 0:l(d),title:"删除","aria-label":`删除 ${d.name}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]}),f&&!c&&((p=d.children)!=null&&p.length)?o.jsx(dR,{items:d.children,flowParams:t,onOpen:n,collapsedDirs:r,onToggleDir:s,onCreateFile:i,onCreateFolder:a,onDelete:l,onFileDragStart:u}):null]},d.path)})})}function Dq({messages:e,running:t,showRunningIndicator:n=!0}){const r=e.length>0;return o.jsxs("div",{className:"af-composer-ai-stack af-composer-ai-stack--in-panel af-composer-thread-stack",children:[e.map((s,i)=>{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 o.jsxs("section",{className:`af-composer-ai-block af-composer-ai-block--${a}${s.kind?` af-composer-ai-block--kind-${s.kind}`:""}`,children:[o.jsx("div",{className:"af-composer-ai-block-label",children:l}),o.jsx("div",{className:"af-composer-ai-block-body",children:s.text})]},`${i}-${s.role}-${String(s.text||"").slice(0,24)}`)}),n&&t&&!r?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--reply af-composer-ai-block--pending",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:"Reply"}),o.jsx("div",{className:"af-composer-ai-block-body",children:"Waiting..."})]}):null,n&&t&&r?o.jsxs("section",{className:"af-composer-ai-block af-composer-ai-block--thinking",children:[o.jsx("div",{className:"af-composer-ai-block-label",children:"Thinking"}),o.jsx("div",{className:"af-composer-ai-block-body",children:"Workspace agent is running..."})]}):null]})}function fg(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 Fq(e){const t=fg((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 fg((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function zq(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function Bq(e){const t=fg((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 fg((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function Hq(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function N1(e){var r,s,i,a,l,u;if(!e)return null;const{inputs:t,outputs:n}=CT(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(((i=e.data)==null?void 0:i.model)??""),body:String(((a=e.data)==null?void 0:a.body)??""),images:Ps((l=e.data)==null?void 0:l.images),script:String(((u=e.data)==null?void 0:u.script)??""),inputs:t,outputs:n}}function j1(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 Wq(e,t,n){var f,c;const r=String(((f=e==null?void 0:e.data)==null?void 0:f.definitionId)??n),s=r.startsWith("provide_"),i=String((t==null?void 0:t.role)||"").trim(),a=al.includes(i)?i:"normal",l=String((t==null?void 0:t.model)||"").trim(),u={...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?[]:Ps(t==null?void 0:t.images),inputs:j1(t==null?void 0:t.inputs),outputs:s&&Array.isArray((c=e.data)==null?void 0:c.outputs)?e.data.outputs:j1(t==null?void 0:t.outputs)},d=String((t==null?void 0:t.script)??"").trim();return r==="tool_nodejs"||d!==""?u.script=String((t==null?void 0:t.script)??""):delete u.script,u}function C1({nodes:e,edges:t,instances:n,selectedNode:r,draft:s,allowRename:i=!1}){if(!s||!r)return{ok:!1,error:""};const a=r.id,l=String(s.newId||"").trim(),u=i?l:a;if(i){if(!FT.test(u))return{ok:!1,error:"Invalid instance id"};if(e.some(b=>b.id===u&&b.id!==a))return{ok:!1,error:"Duplicate instance id"}}const d=Wq(r,s,u),f=r.data||{};if(!(u!==a||f.label!==d.label||f.role!==d.role||f.model!==d.model||f.body!==d.body||JSON.stringify(Ps(f.images))!==JSON.stringify(d.images)||(f.script??void 0)!==(d.script??void 0)||JSON.stringify(f.inputs||[])!==JSON.stringify(d.inputs||[])||JSON.stringify(f.outputs||[])!==JSON.stringify(d.outputs||[])))return{ok:!0,changed:!1,nextId:u,nodes:e,edges:t,instances:n};const p=e.map(b=>b.id===a?{...b,id:u,selected:!0,data:d}:b);let m=t,g=n;if(u!==a){g={...n||{}};const b={...g[a]||{}};delete g[a],g[u]=b,m=t.map((k,y)=>({...k,source:k.source===a?u:k.source,target:k.target===a?u:k.target,id:`we-${k.source===a?u:k.source}-${k.target===a?u:k.target}-${y}`}))}return{ok:!0,changed:!0,nextId:u,nodes:p,edges:m,instances:g}}function Vq(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function Uq(e,t,n){if(!e||!t||!n)return n;const r={...e};for(const s of["newId","label","role","model","body","images","script","inputs","outputs"])Vq(e[s],t[s])&&(r[s]=n[s]);return r}function Kq({id:e,data:t,selected:n,deleteNode:r,skills:s,skillCollections:i,onChangeSkillKeys:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],u=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],d=Array.isArray(s)?s:[],f=Array.isArray(i)?i:[],[c,p]=h.useState(!1),[m,g]=h.useState(""),[b,k]=h.useState(()=>new Set),y=h.useRef(null),v=h.useRef(null),[w,j]=h.useState({visible:!1,top:0,height:100}),P=h.useMemo(()=>new Set(Fq(t)),[t]),_=h.useMemo(()=>new Map(d.map($=>[$.key,$])),[d]),L=h.useMemo(()=>{const $=new Set,I=f.map(C=>{const T=il(C,d).map(E=>_.get(E)).filter(Boolean);for(const E of T)$.add(E.key);return{...C,skills:T}}).filter(C=>C.skills.length>0),z=d.filter(C=>!$.has(C.key));return{collectionGroups:I,ungrouped:z}},[_,f,d]);h.useEffect(()=>{k($=>{let I=!1;const z=new Set($);for(const C of L.collectionGroups)z.has(C.id)||(z.add(C.id),I=!0);return I?z:$})},[L.collectionGroups]);const B=h.useMemo(()=>{const $=m.trim().toLowerCase();if(!$)return L;const I=C=>[C==null?void 0:C.key,C==null?void 0:C.name,C==null?void 0:C.description].map(E=>String(E||"").toLowerCase()).join(" ").includes($);return{collectionGroups:L.collectionGroups.map(C=>{const E=[C==null?void 0:C.id,C==null?void 0:C.name,C==null?void 0:C.description].map(G=>String(G||"").toLowerCase()).join(" ").includes($)?C.skills:C.skills.filter(I);return{...C,skills:E}}).filter(C=>C.skills.length>0),ungrouped:L.ungrouped.filter(I)}},[L,m]),D=h.useCallback(($,I)=>{const z=new Set(P);for(const C of $)I?z.add(C):z.delete(C);a==null||a(e,Array.from(z))},[e,P,a]),F=h.useCallback($=>{k(I=>{const z=new Set(I);return z.has($)?z.delete($):z.add($),z})},[]),R=h.useCallback(()=>{const $=y.current;if(!$)return;const I=Math.max(1,$.scrollHeight),z=Math.max(1,$.clientHeight),C=I>z+1,T=C?Math.max(12,z/I*100):100,E=Math.max(0,100-T),G=C?Math.min(E,$.scrollTop/Math.max(1,I-z)*E):0;j({visible:C,top:G,height:T})},[]);h.useEffect(()=>{if(!c)return;const $=requestAnimationFrame(R);return()=>cancelAnimationFrame($)},[b,B,P.size,c,R]);const M=h.useCallback($=>{const I=y.current;if(!I)return;const z=Math.max(0,I.scrollHeight-I.clientHeight);I.scrollTop=Math.min(1,Math.max(0,$))*z,R()},[R]),W=h.useCallback(($,I=0)=>{const z=v.current;if(!z)return 0;const C=z.getBoundingClientRect(),T=w.height/100*C.height,E=Math.max(1,C.height-T);return($-C.top-I)/E},[w.height]),O=h.useCallback($=>{var de,fe;if(!w.visible)return;$.preventDefault(),$.stopPropagation();const I=v.current;if(!I)return;const z=I.getBoundingClientRect(),C=w.top/100*z.height,T=w.height/100*z.height,G=$.clientY>=z.top+C&&$.clientY<=z.top+C+T?$.clientY-z.top-C:T/2;M(W($.clientY,G));const Z=$.pointerId;(fe=(de=$.currentTarget).setPointerCapture)==null||fe.call(de,Z);const V=pe=>{pe.preventDefault(),M(W(pe.clientY,G))},se=()=>{window.removeEventListener("pointermove",V),window.removeEventListener("pointerup",se),window.removeEventListener("pointercancel",se)};window.addEventListener("pointermove",V),window.addEventListener("pointerup",se),window.addEventListener("pointercancel",se)},[W,M,w.height,w.top,w.visible]);return o.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":""),children:[l.map(($,I)=>{if($.showOnNode===!1)return null;const z=`${2.6+I*1.7}rem`,C=$.name||`#${I+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:z},children:C}),o.jsx(Ms,{type:"target",position:Xe.Left,id:`input-${I}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:z,background:nr($.type)},title:`${C} · ${$.type}`})]},`in-${I}`)}),u.map(($,I)=>{if($.showOnNode===!1)return null;const z=`${2.6+I*1.7}rem`,C=$.name||`#${I+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:z},children:C}),o.jsx(Ms,{type:"source",position:Xe.Right,id:`output-${I}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:z,background:nr($.type)},title:`${C} · ${$.type}`})]},`out-${I}`)}),o.jsxs("div",{className:"af-work-load-skills-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"extension"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Load Skills"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_skills"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[o.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:$=>{var I;$.stopPropagation(),c||(I=t==null?void 0:t.onRefreshSkills)==null||I.call(t),p(z=>!z)},children:[o.jsx("span",{children:P.size>0?`${P.size} skills selected`:"选择 Skills"}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:c?"expand_less":"expand_more"})]}),c?o.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:$=>$.stopPropagation(),children:[o.jsxs("div",{className:"af-work-load-skills-search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:m,onChange:$=>g($.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),m?o.jsx("button",{type:"button",onClick:()=>g(""),"aria-label":"清空搜索",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),o.jsxs("div",{ref:y,className:"af-work-load-skills-menu",onScroll:R,children:[B.collectionGroups.map($=>{const I=$.skills.map(E=>E.key),z=I.filter(E=>P.has(E)).length,C=I.length>0&&z===I.length,T=b.has($.id);return o.jsxs("section",{className:"af-work-load-skills-menu__group"+(T?" af-work-load-skills-menu__group--collapsed":""),children:[o.jsxs("div",{className:"af-work-load-skills-menu__group-head",children:[o.jsx("input",{type:"checkbox",checked:C,onChange:E=>D(I,E.target.checked),"aria-label":`选择 ${$.name}`}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>F($.id),"aria-expanded":!T,children:o.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[o.jsx("span",{children:$.name}),$.description?o.jsx("em",{children:$.description}):null]})}),o.jsxs("small",{children:[z,"/",I.length]}),o.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>F($.id),"aria-label":T?`展开 ${$.name}`:`收起 ${$.name}`,children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:T?"chevron_right":"expand_more"})})]}),T?null:o.jsx("div",{className:"af-work-load-skills-menu__options",children:$.skills.map(E=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:P.has(E.key),onChange:G=>D([E.key],G.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:E.name}),E.description?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:E.description}):null]})]},`${$.id}:${E.key}`))})]},$.id)}),B.ungrouped.length>0?o.jsxs("section",{className:"af-work-load-skills-menu__group",children:[o.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("small",{children:B.ungrouped.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:B.ungrouped.map($=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:P.has($.key),onChange:I=>D([$.key],I.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:$.name}),$.description?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:$.description}):null]})]},`ungrouped:${$.key}`))})]}):null,B.collectionGroups.length===0&&B.ungrouped.length===0?o.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Skills"}):null,o.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>a==null?void 0:a(e,[]),children:"清空"})]}),o.jsx("div",{ref:v,className:"af-work-load-skills-scrollbar"+(w.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:O,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${w.height}%`,top:`${w.top}%`}})})]}):null]})]})}function qq({id:e,data:t,selected:n,deleteNode:r,servers:s=[],onChangeMcpNames:i}){const a=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],l=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[u,d]=h.useState(!1),[f,c]=h.useState(""),p=h.useMemo(()=>new Set(Bq(t)),[t]),m=h.useMemo(()=>(Array.isArray(s)?s:[]).map(k=>({name:String((k==null?void 0:k.name)||""),description:String((k==null?void 0:k.description)||""),detail:String((k==null?void 0:k.url)||[k==null?void 0:k.command,...Array.isArray(k==null?void 0:k.args)?k.args:[]].filter(Boolean).join(" ")||""),type:String((k==null?void 0:k.type)||"")})).filter(k=>k.name),[s]),g=h.useMemo(()=>{const k=f.trim().toLowerCase();return k?m.filter(y=>[y.name,y.description,y.detail,y.type].join(" ").toLowerCase().includes(k)):m},[f,m]),b=h.useCallback((k,y)=>{const v=new Set(p);for(const w of k)y?v.add(w):v.delete(w);i==null||i(e,Array.from(v))},[e,p,i]);return o.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":""),children:[a.map((k,y)=>{if(k.showOnNode===!1)return null;const v=`${2.6+y*1.7}rem`,w=k.name||`#${y+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:v},children:w}),o.jsx(Ms,{type:"target",position:Xe.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:v,background:nr(k.type)},title:`${w} · ${k.type}`})]},`in-${y}`)}),l.map((k,y)=>{if(k.showOnNode===!1)return null;const v=`${2.6+y*1.7}rem`,w=k.name||`#${y+1}`;return o.jsxs(h.Fragment,{children:[o.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:v},children:w}),o.jsx(Ms,{type:"source",position:Xe.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:v,background:nr(k.type)},title:`${w} · ${k.type}`})]},`out-${y}`)}),o.jsxs("div",{className:"af-work-load-skills-card__head",children:[o.jsx("span",{className:"material-symbols-outlined",children:"hub"}),o.jsx("strong",{children:(t==null?void 0:t.label)||"Load MCP"}),o.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_mcp"}),o.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[o.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:k=>{var y;k.stopPropagation(),u||(y=t==null?void 0:t.onRefreshMcps)==null||y.call(t),d(v=>!v)},children:[o.jsx("span",{children:p.size>0?`${p.size} MCP selected`:"选择 MCP"}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:u?"expand_less":"expand_more"})]}),u?o.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:k=>k.stopPropagation(),children:[o.jsxs("div",{className:"af-work-load-skills-search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:f,onChange:k=>c(k.target.value),placeholder:"搜索 MCP...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 MCP"}),f?o.jsx("button",{type:"button",onClick:()=>c(""),"aria-label":"清空搜索",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),o.jsxs("div",{className:"af-work-load-skills-menu",children:[o.jsxs("section",{className:"af-work-load-skills-menu__group",children:[o.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[o.jsx("span",{children:"MCP Servers"}),o.jsx("small",{children:g.length})]}),o.jsx("div",{className:"af-work-load-skills-menu__options",children:g.map(k=>o.jsxs("label",{className:"af-work-load-skills-menu__option",children:[o.jsx("input",{type:"checkbox",checked:p.has(k.name),onChange:y=>b([k.name],y.target.checked)}),o.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[o.jsx("span",{className:"af-work-load-skills-menu__option-title",children:k.name}),k.description||k.detail?o.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:k.description||k.detail}):null]})]},k.name))})]}),g.length===0?o.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 MCP"}):null,o.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>i==null?void 0:i(e,[]),children:"清空"})]})]}):null]})]})}function Yq(){var dd,fd;const{t:e,i18n:t}=Pn(),{navigate:n}=Io(),r=fc(),s=n0(),i=h.useMemo(rq,[]),[a,l]=h.useState(()=>new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace"),[u,d]=h.useState(!1),[f,c]=h.useState(!1),[p,m]=UA([]),[g,b,k]=KA([]),y=h.useRef([]),v=h.useRef([]),[w,j]=h.useState(()=>Lb(null,[])),P=h.useRef(w),[_,L]=h.useState(null),B=h.useRef(null),[D,F]=h.useState([]),R=h.useRef(new Map),M=h.useRef(new Map),W=h.useRef(null),O=h.useRef(null),$=h.useRef(null),[I,z]=h.useState(null),[C,T]=h.useState({}),E=h.useRef({}),G=h.useRef(!1),Z=h.useRef(null),[V,se]=h.useState([]),[de,fe]=h.useState(""),[pe,ae]=h.useState("nodes"),[be,_e]=h.useState([]),[we,Oe]=h.useState(!1),[Ie,et]=h.useState(""),[ft,Je]=h.useState(!1),[bt,Ve]=h.useState({name:"",id:"",description:""}),[jt,An]=h.useState(!1),[pn,In]=h.useState(""),[en,Wn]=h.useState(""),Tn=h.useRef(null),[ce,ve]=h.useState(!1),[ze,it]=h.useState(!1),[ot,Tt]=h.useState(""),[tt,an]=h.useState(null),[Xt,rr]=h.useState({title:"",layout:"gallery",nodeIds:[]}),[vn,ln]=h.useState(!1),[hn,sr]=h.useState(""),[xe,Me]=h.useState(!1),[Ze,Dt]=h.useState(""),[ie,Pe]=h.useState(!1),[He,Ft]=h.useState("nodes"),[cn,ir]=h.useState(""),[Ds,ns]=h.useState(0),[cr,Xn]=h.useState(""),zr=h.useRef(""),[st,Br]=h.useState(null),_i=h.useRef(null),[ga,hs]=h.useState(""),[Ee,tn]=h.useState([]),[ur,pt]=h.useState(""),[Le,Hr]=h.useState(!0),[Vn,Wr]=h.useState(""),[kr,ct]=h.useState(()=>new Set),Wt=h.useRef(null),[nn,Sr]=h.useState(()=>{try{const S=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(S)&&S>=160)return S}catch{}return 360}),[Qe,dr]=h.useState(!1),[Fs,ya]=h.useState({cursor:[],opencode:[],claudeCode:[]}),[ms,Lo]=h.useState(""),[yr,Oo]=h.useState([]),[Pi,un]=h.useState(!1),[Jn,gs]=h.useState([]),[Vr,ii]=h.useState([]),[zs,K]=h.useState(!1),[ge,Te]=h.useState([]),Re=h.useCallback(S=>{Tn.current&&window.clearTimeout(Tn.current),Wn(S),Tn.current=window.setTimeout(()=>{Wn(""),Tn.current=null},3800)},[]),We=h.useCallback(S=>{const A=String(S||"").trim();if(!A)return;const U=()=>s(A);window.requestAnimationFrame(U),window.setTimeout(U,80)},[s]);h.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(nn)))}catch{}},[nn]);const Jt=h.useCallback(S=>{const A=Wt.current;if(!A)return;const U=A.getBoundingClientRect(),X=16,Q=150,re=230,ne=U.top+X,oe=U.bottom-X,he=Math.max(Q,oe-ne-re),le=Math.min(Math.max(S-ne,Q),he);Sr(le)},[]),Rt=h.useCallback(S=>{S.preventDefault(),S.stopPropagation(),dr(!0),Jt(S.clientY);const A=X=>{X.preventDefault(),Jt(X.clientY)},U=()=>{dr(!1),window.removeEventListener("pointermove",A,!0),window.removeEventListener("pointerup",U,!0),window.removeEventListener("pointercancel",U,!0)};window.addEventListener("pointermove",A,!0),window.addEventListener("pointerup",U,!0),window.addEventListener("pointercancel",U,!0)},[Jt]);h.useEffect(()=>()=>{Tn.current&&window.clearTimeout(Tn.current)},[]);const[dn,Ur]=h.useState(()=>new Set),[rs,Bs]=h.useState(!1),or=h.useRef(null),xa=h.useRef(null),Gu=h.useRef(null),[vp,Ai]=h.useState({}),[wa,ml]=h.useState(""),[Nr,gl]=h.useState(!1),[yl,Vt]=h.useState([]),[hc,zt]=h.useState([]),[xl,no]=h.useState("workspace"),[oi,Mo]=h.useState(!1),[Xu,$o]=h.useState(!0),[xr,wl]=h.useState(""),[ai,Ii]=h.useState({}),[mc,Do]=h.useState(!1),[ba,Fo]=h.useState(!1),[bl,vl]=h.useState(!1),[Ju,li]=h.useState("pan"),[Ar,Qu]=h.useState(null),[ci,va]=h.useState(""),zo=h.useRef(null),ys=h.useRef(!1),[Zu,Kr]=h.useState(()=>new Set),[ka,ui]=h.useState({}),[xs,Ae]=h.useState(""),ws=h.useMemo(()=>iq(i),[i]),[Sa,Na]=h.useState(""),di=i.flowSource||"user",kp=!!(i.flowId&&!i.archived&&(di==="user"||di==="workspace")),ed=h.useMemo(()=>{if(!i.flowId)return"/flow?panel=settings";const S=Af({id:i.flowId,source:di,archived:!!i.archived},"pipeline"),[A,U=""]=S.split("?"),X=new URLSearchParams(U);return X.set("panel","settings"),`${A}?${X.toString()}`},[i.archived,i.flowId,di]);h.useEffect(()=>{i.flowId&&G_(i.flowId,i.flowSource||"user","workspace",!!i.archived)},[i]),h.useEffect(()=>{const S=()=>{l(new URLSearchParams(window.location.search).get("view")==="display"?"display":"workspace")};return window.addEventListener("popstate",S),()=>window.removeEventListener("popstate",S)},[]),h.useEffect(()=>{Vt([]),zt([]),no("workspace"),$o(!0)},[i]);const fr=h.useCallback(async()=>{const S=Xo(i),A=await fetch(`/api/workspace/files?${S.toString()}`),U=await A.json();if(!A.ok)throw new Error(U.error||"读取 workspace 失败");const X=U.files||[];tn(X),ct(new Set(uR(X))),pt(U.root||"")},[i]),ro=h.useCallback(async()=>{Oe(!0),et("");try{const S=await fetch("/api/marketplace/flow-snippets"),A=await S.json().catch(()=>({}));if(!S.ok)throw new Error(A.error||"读取流程片段失败");_e(Array.isArray(A.snippets)?A.snippets:[])}catch(S){et(String(S.message||S)),_e([])}finally{Oe(!1)}},[]),Rn=h.useCallback(async(S=p,A=g)=>{var re;if(!G.current)return;if(!Le)throw Ae("Readonly workspace"),new Error("Readonly workspace");const U=Mh(S,A,E.current);U.ui={...U.ui||{},...B.current?{viewport:B.current}:{},displayPage:mq(P.current,S)};const X=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,graph:U})}),Q=await X.json();if(!X.ok)throw new Error(Q.error||"保存 workspace graph 失败");E.current=((re=Q.graph)==null?void 0:re.instances)||U.instances,T(E.current),Ae("Workspace graph saved")},[g,i,p,Le]),Sp=h.useCallback(S=>{var U;const A=(U=S==null?void 0:S.extra)!=null&&U.instances&&typeof S.extra.instances=="object"?S.extra.instances:{};E.current=A,T(A),m(Array.isArray(S==null?void 0:S.nodes)?S.nodes:[]),b(Array.isArray(S==null?void 0:S.edges)?S.edges:[]),Xn(""),z(null)},[b,m]),td=h.useMemo(()=>({instances:C}),[C]),nd=_T({nodes:p,edges:g,extra:td,enabled:G.current,onRestore:Sp}),{resetHistory:ja,undo:Np,redo:jp}=nd,yt=h.useCallback(async()=>{var at,Ue;G.current=!1;const S=Xo(i),A=Xo(i);A.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[U,X]=await Promise.all([fetch(`/api/nodes?${A.toString()}`),fetch(`/api/workspace/graph?${S.toString()}`),fr()]),Q=await U.json(),re=await X.json();if(!U.ok)throw new Error(Q.error||"读取节点定义失败");if(!X.ok)throw new Error(re.error||"读取 workspace graph 失败");const ne=[...(Array.isArray(Q)?Q:Q.nodes||[]).filter(Lt=>!X7.has(Lt.id)),Q7,Z7,J7];se(ne);const oe=re.graph||JSON.parse(localStorage.getItem(G7)||"null")||{},he=Lx(oe,ne),le=Lb((at=oe==null?void 0:oe.ui)==null?void 0:at.displayPage,he.nodes),Ne=iR((Ue=oe==null?void 0:oe.ui)==null?void 0:Ue.viewport);E.current=he.instances,T(he.instances),m(he.nodes),b(he.edges),j(le),P.current=le,L(Ne),B.current=Ne,F([]),ja(he.nodes,he.edges,{instances:he.instances});const Be=re.writable!==!1;Hr(Be),Ae(Be?"Workspace ready":"Readonly workspace"),G.current=!0},[i,t.language,fr,ja,b,m]),rd=h.useCallback(async(S,A)=>{const U={packageId:(S==null?void 0:S.newId)||(S==null?void 0:S.id)||(S==null?void 0:S.label),label:(S==null?void 0:S.label)||(S==null?void 0:S.newId)||(S==null?void 0:S.id),version:"1.0.0",definitionId:A,body:(S==null?void 0:S.body)||"",script:(S==null?void 0:S.script)||"",inputs:Array.isArray(S==null?void 0:S.inputs)?S.inputs:[],outputs:Array.isArray(S==null?void 0:S.outputs)?S.outputs:[],flowId:i.flowId,flowSource:i.flowSource||"user",archived:!!i.archived},X=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(U)}),Q=await X.json().catch(()=>({}));if(!X.ok||(Q==null?void 0:Q.ok)===!1)throw new Error((Q==null?void 0:Q.error)||"Publish failed");return await yt(),Ae(`Published node ${Q.definitionId||Q.id||U.packageId}`),Q},[i,yt]),Cp=h.useCallback((S="workspace")=>{Mo(!0),Br(null),no(S||"workspace")},[]),kl=h.useCallback(async(S="")=>{const A=String(S||ci||"").trim();ys.current=!0,zo.current&&(zo.current.abort(),zo.current=null),va(""),Kr(new Set),ui(U=>{const X={...U};for(const[Q,re]of Object.entries(X))(re==null?void 0:re.status)==="running"&&(X[Q]={status:"stopped"});return A&&(X[A]={status:"stopped"}),X}),Ae(A?`Workspace run stopped: ${A}`:"Workspace run stopped"),zt(U=>U.map(X=>(!A||X.runNodeId===A)&&X.status==="running"?{...X,status:"stopped",endedAt:Date.now(),messages:[...Array.isArray(X.messages)?X.messages:[],{role:"assistant",kind:"status",text:"Workspace run stopped.",at:Date.now()}].slice(-160)}:X));try{await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,runNodeId:A})})}catch{}},[i,ci]),wt=h.useCallback(async()=>{if(i.flowId)try{const S=Xo(i),A=await fetch(`/api/workspace/run/status?${S.toString()}`),U=await A.json().catch(()=>({}));if(!A.ok||!U.running)return;const X=String(U.runNodeId||"").trim();X?(va(X),Kr(new Set([X])),ui(Q=>({...Q,[X]:{status:"running"}})),Ae(`Workspace run still running: ${X}`)):Ae("Workspace run still running"),zt(Q=>{if(Q.some(ne=>ne.status==="running"&&(!X||ne.runNodeId===X)))return Q;const re=`run-restored-${U.startedAt||Date.now()}`;return[...Q.slice(-7),{id:re,label:X?`Run ${X}`:"Workspace Run",runNodeId:X,status:"running",startedAt:U.startedAt||Date.now(),steps:X?[{id:X,label:X,status:"running"}]:[],messages:[{role:"assistant",kind:"run-summary",text:"Workspace run is still running in the background.",at:Date.now()}]}]})}catch{}},[i]),Ep=h.useCallback(async S=>{if(!Le){Ae("Readonly workspace");return}if(!S||ci)return;let A=p,U=g,X=E.current;const Q=_i.current;if(Q!=null&&Q.id){const le=A.find(Be=>Be.id===Q.id),Ne=C1({nodes:A,edges:U,instances:X,selectedNode:le,draft:Q,allowRename:!1});if(Ne!=null&&Ne.error){hs(Ne.error),Ae(Ne.error);return}Ne!=null&&Ne.ok&&Ne.changed&&(A=Ne.nodes,U=Ne.edges,X=Ne.instances,E.current=X,T(X),m(A),b(U),We(Ne.nextId||Q.id))}const re=Mh(A,U,X),ne=`run-${Date.now()}-${String(S).replace(/[^a-z0-9_-]+/gi,"_")}`,oe=`Run ${S}`,he=new AbortController;zo.current=he,ys.current=!1,va(S),Kr(new Set([S])),ui({[S]:{status:"running"}}),Ae(`Running ${S}...`),no(ne),zt(le=>[...le.slice(-7),{id:ne,label:oe,runNodeId:S,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);try{await Rn(A,U);const le=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},signal:he.signal,body:JSON.stringify({...i,graph:re,runNodeId:S,model:ms,selectedSkills:Jn,stream:!0})});if(!le.ok){const ke=await le.json().catch(()=>({}));throw new Error(ke.error||"Workspace run failed")}if(!le.body)throw new Error("Workspace run stream unavailable");const Ne=le.body.getReader(),Be=new TextDecoder;let at="",Ue=[],Lt=[],Ln=S;const gi=(ke,dt)=>{var Ot,Qt;const mt=p.find(Ut=>Ut.id===ke),nt=String(((Ot=mt==null?void 0:mt.data)==null?void 0:Ot.label)||ke||"").trim(),De=String(dt||((Qt=mt==null?void 0:mt.data)==null?void 0:Qt.definitionId)||"").trim();return De&&De!==nt?`${nt} (${De})`:nt},Pt=(ke,dt,mt)=>{const nt=String(ke||"").trim();nt&&zt(De=>De.map(Ot=>{if(Ot.id!==ne)return Ot;const Ut=[...Array.isArray(Ot.steps)?Ot.steps:[]],Nn=Ut.findIndex(vs=>vs.id===nt),gn={id:nt,label:gi(nt,dt),status:mt};Nn>=0?Ut[Nn]={...Ut[Nn],...gn}:Ut.push(gn);const At=Ut.map((vs,Hp)=>{const my=vs.status==="done"?"[done]":vs.status==="failed"?"[failed]":"[running]";return`${Hp+1}. ${my} ${vs.label}`}).join(`
164
- `),sn=Array.isArray(Ot.messages)?Ot.messages:[],os=sn.findIndex(vs=>vs.kind==="run-summary"),Oi={role:"assistant",kind:"run-summary",text:At||"准备运行...",at:Date.now()},co=[...sn];return os>=0?co[os]=Oi:co.unshift(Oi),{...Ot,steps:Ut,messages:co.slice(-160)}}))},jr=ke=>{const dt=String(ke||"").trim();if(!dt)return;const mt=Ln;Ln=dt,Kr(new Set([dt])),ui(nt=>{var De;return{...nt,...mt&&mt!==dt&&((De=nt[mt])==null?void 0:De.status)==="running"?{[mt]:{status:"success"}}:{},[dt]:{status:"running"}}})},Ks=ke=>{const dt=String(ke||"").trim();dt&&(Kr(mt=>{const nt=new Set(mt);return nt.delete(dt),nt}),ui(mt=>({...mt,[dt]:{status:"success"}})))},Ir=(ke,dt)=>{const mt=String(dt||"");if(!mt.trim())return;const nt=["assistant","thinking","result","error","prompt"].includes(ke)?ke:"assistant";zt(De=>De.map(Ot=>{if(Ot.id!==ne)return Ot;let Qt=Array.isArray(Ot.messages)?Ot.messages:[];if(nt==="result"){const gn=[...Qt].reverse().find(At=>At.kind==="assistant");if(String((gn==null?void 0:gn.text)||"").trim()===mt.trim())return Ot}if(nt==="assistant"){const gn=Qt.findIndex(At=>At.kind==="result"&&String(At.text||"").trim()===mt.trim());gn>=0&&(Qt=Qt.filter((At,sn)=>sn!==gn))}const Ut=[...Qt],Nn=Ut[Ut.length-1];return Nn&&Nn.kind===nt&&!Nn.error?Ut[Ut.length-1]={...Nn,text:`${Nn.text||""}${Nn.text?`
165
- `:""}${mt}`}:Ut.push({role:"assistant",kind:nt,text:mt,...nt==="error"?{error:!0}:{},at:Date.now()}),{...Ot,messages:Ut.slice(-160)}}))},Un=ke=>{const dt=String(ke||"");dt.trim()&&zt(mt=>mt.map(nt=>{var Ut;if(nt.id!==ne)return nt;const De=Array.isArray(nt.messages)?nt.messages:[],Ot=De.findIndex(Nn=>Nn.kind==="thinking"),Qt=[...De];if(Ot>=0){const Nn=String(((Ut=Qt[Ot])==null?void 0:Ut.text)||"");Qt[Ot]={...Qt[Ot],text:`${Nn}${Nn&&!Nn.endsWith(`
166
- `),""}${dt}`,at:Date.now()}}else{const Nn=Qt.findIndex(gn=>gn.kind==="activity");Qt.splice(Nn>=0?Nn+1:Qt.length,0,{role:"assistant",kind:"thinking",text:dt,at:Date.now()})}return{...nt,messages:Qt.slice(-160)}}))},ht=ke=>{const dt=cq(ke);dt&&zt(mt=>mt.map(nt=>{if(nt.id!==ne)return nt;const De=Array.isArray(nt.activities)?nt.activities:[],Ot=De[De.length-1]===dt?De:[...De,dt].slice(-8),Qt=Array.isArray(nt.messages)?nt.messages:[],Ut=Qt.findIndex(At=>At.kind==="activity"),Nn={role:"assistant",kind:"activity",text:Ot.map((At,sn)=>`${sn+1}. ${At}`).join(`
167
- `),at:Date.now()},gn=[...Qt];if(Ut>=0)gn[Ut]=Nn;else{const At=gn.findIndex(sn=>sn.kind==="run-summary");gn.splice(At>=0?At+1:0,0,Nn)}return{...nt,activities:Ot,messages:gn.slice(-160)}}))},fn=ke=>{const dt=String((ke==null?void 0:ke.source)||"runner"),mt=String((ke==null?void 0:ke.stream)||""),nt=String((ke==null?void 0:ke.eventType)||"event"),De=String((ke==null?void 0:ke.text)||"").trim();if(!De)return;const Ot=`[${dt}${mt?`:${mt}`:""}] ${nt}
168
- ${De}`;zt(Qt=>Qt.map(Ut=>{if(Ut.id!==ne)return Ut;const gn=[...Array.isArray(Ut.rawTrace)?Ut.rawTrace:[],Ot].slice(-80),At=Array.isArray(Ut.messages)?Ut.messages:[],sn=At.findIndex(co=>co.kind==="raw"),os={role:"assistant",kind:"raw",text:gn.join(`
169
-
170
- ---
171
-
172
- `),at:Date.now()},Oi=[...At];return sn>=0?Oi[sn]=os:Oi.push(os),{...Ut,rawTrace:gn,messages:Oi.slice(-160)}}))},is=ke=>{zt(dt=>dt.map(mt=>mt.id===ne?{...mt,status:ke,endedAt:Date.now()}:mt))},Cc=ke=>{const dt=new Set,mt=String((ke==null?void 0:ke.nodeId)||"").trim();mt&&dt.add(mt);for(const nt of Array.isArray(ke==null?void 0:ke.displayNodeIds)?ke.displayNodeIds:[]){const De=String(nt||"").trim();De&&dt.add(De)}for(const nt of Array.isArray(ke==null?void 0:ke.touchedNodeIds)?ke.touchedNodeIds:[]){const De=String(nt||"").trim();De&&dt.add(De)}if(dt.size===0)for(const nt of Array.isArray(ke==null?void 0:ke.order)?ke.order:[]){const De=String(nt||"").trim();De&&dt.add(De)}return dt},Ec=(ke,dt=null)=>{const mt=Lx(ke||re,V),nt=new Map(mt.nodes.map(Qt=>[Qt.id,Qt])),De=mt.instances||{},Ot=dt instanceof Set?dt:null;m(Qt=>{const Ut=new Set(Qt.map(At=>At.id)),gn={...Mh(Qt,v.current,E.current).instances||{}};for(const[At,sn]of Object.entries(De)){if(Ot&&!Ot.has(At)||!Ut.has(At))continue;const os=gn[At];Kn((sn==null?void 0:sn.definitionId)||(os==null?void 0:os.definitionId))?gn[At]=sn:Array.isArray(sn==null?void 0:sn.output)&&(gn[At]={...os||sn,output:sn.output})}return E.current=gn,T(gn),Qt.map(At=>{var os,Oi,co;if(Ot&&!Ot.has(At.id))return At;const sn=nt.get(At.id);return sn?Kn(((os=sn.data)==null?void 0:os.definitionId)||((Oi=At.data)==null?void 0:Oi.definitionId))?{...At,data:{...At.data,...sn.data}}:Array.isArray((co=sn.data)==null?void 0:co.outputs)?{...At,data:{...At.data,outputs:sn.data.outputs}}:At:At})})};for(;;){const{value:ke,done:dt}=await Ne.read();if(dt)break;at+=Be.decode(ke,{stream:!0});const mt=at.split(`
173
- `);at=mt.pop()||"";for(const nt of mt){if(!nt.trim())continue;const De=JSON.parse(nt);if(De.type==="error")throw new Error(De.error||"Workspace run failed");if(De.type==="stopped"){ys.current=!0,Ue=Array.isArray(De.order)?De.order:Ue;continue}if(De.type==="node-start"&&(Ae(`Running ${De.nodeId}...`),jr(De.nodeId),Pt(De.nodeId,De.definitionId,"running")),De.type==="node-done"&&(Ks(De.nodeId),Pt(De.nodeId,De.definitionId,"done")),De.type==="status"&&ht(De.line||De.message||""),De.type==="paused"&&(Lt=Array.isArray(De.nodeIds)?De.nodeIds:[]),De.type==="natural"&&(De.kind==="thinking"?Un(De.text||""):Ir(De.kind,De.text||"")),De.type==="raw"){const Ot=g1(De);Ot&&Un(Ot),fn(De)}De.type==="graph"&&De.graph&&Ec(De.graph,Cc(De)),De.type==="done"&&(De.graph&&Ec(De.graph,Cc(De)),Ue=Array.isArray(De.order)?De.order:[],Lt=Array.isArray(De.pauseNodeIds)?De.pauseNodeIds:Lt)}}if(at.trim()){const ke=JSON.parse(at);if(ke.type==="error")throw new Error(ke.error||"Workspace run failed");if(ke.type==="stopped"&&(ys.current=!0),ke.type==="node-start"&&(Ae(`Running ${ke.nodeId}...`),jr(ke.nodeId),Pt(ke.nodeId,ke.definitionId,"running")),ke.type==="node-done"&&(Ks(ke.nodeId),Pt(ke.nodeId,ke.definitionId,"done")),ke.type==="status"&&ht(ke.line||ke.message||""),ke.type==="paused"&&(Lt=Array.isArray(ke.nodeIds)?ke.nodeIds:[]),ke.type==="natural"&&(ke.kind==="thinking"?Un(ke.text||""):Ir(ke.kind,ke.text||"")),ke.type==="raw"){const dt=g1(ke);dt&&Un(dt),fn(ke)}ke.type==="graph"&&ke.graph&&Ec(ke.graph,Cc(ke)),ke.type==="done"&&(ke.graph&&Ec(ke.graph,Cc(ke)),Ue=Array.isArray(ke.order)?ke.order:[],Lt=Array.isArray(ke.pauseNodeIds)?ke.pauseNodeIds:Lt)}ys.current&&(Kr(new Set),ui(ke=>{var mt;const dt=((mt=Object.entries(ke).find(([,nt])=>(nt==null?void 0:nt.status)==="running"))==null?void 0:mt[0])||S;return dt?{...ke,[dt]:{status:"stopped"}}:ke})),Ae(ys.current?`Workspace run stopped: ${S}`:Lt.length?`Workspace run paused at ${Lt.join(", ")}`:`Workspace run done: ${Ue.length?Ue.join(" -> "):S}`),is(ys.current?"stopped":Lt.length?"paused":"done"),ys.current||await fr()}catch(le){if(ys.current||(le==null?void 0:le.name)==="AbortError"){Kr(new Set),ui(Ne=>{var at;const Be=((at=Object.entries(Ne).find(([,Ue])=>(Ue==null?void 0:Ue.status)==="running"))==null?void 0:at[0])||S;return Be?{...Ne,[Be]:{status:"stopped"}}:Ne}),Ae(`Workspace run stopped: ${S}`),zt(Ne=>Ne.map(Be=>Be.id===ne?{...Be,status:"stopped",endedAt:Date.now()}:Be));return}Kr(new Set),ui(Ne=>{var at;const Be=(at=Object.entries(Ne).find(([,Ue])=>(Ue==null?void 0:Ue.status)==="running"))==null?void 0:at[0];return Be?{...Ne,[Be]:{status:"failed"}}:Ne}),Ae(String(le.message||le)),zt(Ne=>Ne.map(Be=>Be.id===ne?{...Be,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(Be.messages)?Be.messages:[],{role:"assistant",error:!0,text:String(le.message||le),at:Date.now()}].slice(-160)}:Be))}finally{zo.current===he&&(zo.current=null),va(""),Kr(new Set)}},[ms,g,i,fr,p,V,We,ci,Rn,Jn,b,m,Le]),fi=h.useCallback(async()=>{try{const A=await(await fetch("/api/skills")).json().catch(()=>({})),U=Array.isArray(A.skills)?A.skills.map(X=>({key:String(X.key),name:String(X.name||X.id||X.key),description:X.description?String(X.description):"",sourceLabel:X.sourceLabel?String(X.sourceLabel):""})):[];Oo(U),un(!0)}catch{un(!0)}},[]),Sl=h.useCallback(async()=>{try{const A=await(await fetch("/api/mcps")).json().catch(()=>({})),U=Array.isArray(A.servers)?A.servers.map(X=>({name:String((X==null?void 0:X.name)||""),type:String((X==null?void 0:X.type)||""),url:String((X==null?void 0:X.url)||""),command:String((X==null?void 0:X.command)||""),args:Array.isArray(X==null?void 0:X.args)?X.args.map(String):[],description:String((X==null?void 0:X.description)||"")})).filter(X=>X.name):[];Te(U)}catch{Te([])}},[]);h.useEffect(()=>{yt().catch(S=>Ae(String(S.message||S))),ro(),fetch("/api/model-lists").then(S=>S.json()).then(S=>ya({cursor:Array.isArray(S.cursor)?S.cursor.map(String):[],opencode:Array.isArray(S.opencode)?S.opencode.map(String):[],claudeCode:Array.isArray(S.claudeCode)?S.claudeCode.map(String):[]})).catch(()=>{}),fi(),Sl(),wt(),fetch("/api/skill-collections").then(S=>S.json()).then(S=>{ii(Za(S)),K(!0)}).catch(()=>{}),fetch("/api/auth/me").then(S=>S.json()).then(S=>Qu(S.user||null)).catch(()=>Qu(null))},[yt,ro,Sl,fi,wt,ws]),h.useEffect(()=>{if(Na(""),!(!Pi||!zs)){if(!ws){gs([]);return}gs(Z_(ws,"workspace",yr,Vr)),Na(ws)}},[Vr,zs,yr,Pi,ws]),h.useEffect(()=>{if(!(Sa!==ws||!ws))try{localStorage.setItem(ws,JSON.stringify(Jn))}catch{}},[Jn,ws,Sa]),h.useEffect(()=>{E.current=C},[C]),h.useEffect(()=>{y.current=p},[p]),h.useEffect(()=>{const S=R.current,A=new Map,U=[];for(const ne of p){const oe=sR(ne);A.set(ne.id,oe),S.get(ne.id)!==oe&&U.push(ne.id)}if(R.current=A,U.length===0)return;const X=()=>U.forEach(ne=>s(ne)),Q=window.requestAnimationFrame(X),re=window.setTimeout(X,80);return()=>{window.cancelAnimationFrame(Q),window.clearTimeout(re)}},[p,s]),h.useEffect(()=>{v.current=g},[g]),h.useEffect(()=>{P.current=w},[w]),h.useEffect(()=>{B.current=_},[_]),h.useEffect(()=>{_i.current=st},[st]),h.useEffect(()=>{zr.current=cr},[cr]),h.useEffect(()=>{$.current=I},[I]),h.useEffect(()=>{if(!I)return;const S=U=>{U.key==="Escape"&&z(null)},A=U=>{var X,Q;(Q=(X=U.target)==null?void 0:X.closest)!=null&&Q.call(X,".af-connect-node-menu")||z(null)};return document.addEventListener("keydown",S),document.addEventListener("pointerdown",A),()=>{document.removeEventListener("keydown",S),document.removeEventListener("pointerdown",A)}},[I]),h.useEffect(()=>{if(G.current&&Le)return Z.current&&window.clearTimeout(Z.current),Z.current=window.setTimeout(()=>{Rn().catch(S=>Ae(String(S.message||S)))},650),()=>{Z.current&&window.clearTimeout(Z.current)}},[p,g,w,Rn,Le]);const gc=h.useCallback((S,A)=>{if(!Le){Ae("Readonly workspace");return}const U=zq(A),X=he=>Array.isArray(he)?he.map(le=>(le==null?void 0:le.name)!=="skillKeys"&&(le==null?void 0:le.name)!=="skillsContext"&&(le==null?void 0:le.type)!=="text"?le:{...le,default:U,value:U}):[],Q=p.map(he=>{var le;return he.id!==S?he:{...he,data:{...he.data,body:U,inputs:X((le=he.data)==null?void 0:le.inputs)}}}),re=E.current||{},ne=re[S]&&typeof re[S]=="object"?re[S]:{},oe={...re,[S]:{...ne,body:U,input:X(ne.input)}};E.current=oe,m(Q),T(oe),Br(he=>!he||he.id!==S?he:{...he,body:U,inputs:X(he.inputs)}),Rn(Q,g).catch(he=>Ae(String(he.message||he)))},[g,p,Rn,m,Le]),uy=h.useCallback((S,A)=>{if(!Le){Ae("Readonly workspace");return}const U=Hq(A),X=he=>Array.isArray(he)?he.map(le=>(le==null?void 0:le.name)!=="serverNames"&&(le==null?void 0:le.name)!=="mcpContext"&&(le==null?void 0:le.type)!=="text"?le:{...le,default:U,value:U}):[],Q=p.map(he=>{var le;return he.id!==S?he:{...he,data:{...he.data,body:U,inputs:X((le=he.data)==null?void 0:le.inputs)}}}),re=E.current||{},ne=re[S]&&typeof re[S]=="object"?re[S]:{},oe={...re,[S]:{...ne,body:U,input:X(ne.input)}};E.current=oe,m(Q),T(oe),Br(he=>!he||he.id!==S?he:{...he,body:U,inputs:X(he.inputs)}),Rn(Q,g).catch(he=>Ae(String(he.message||he)))},[g,p,Rn,m,Le]),pi=h.useCallback(S=>{const A=String(S||"").trim();A&&(wl(U=>U===A?"":A),Ii(U=>({...U,[A]:U[A]||{sessionId:`nodechat_${Date.now()}_${A.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),_p=h.useCallback((S,A)=>{const U=String(S||"").trim();U&&Ii(X=>({...X,[U]:{...X[U]||{sessionId:`nodechat_${Date.now()}_${U.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(A||""),error:""}}))},[]),bs=h.useCallback((S,A,U="replace",X={})=>{var gi;if(!Le){Ae("Readonly workspace");return}const Q=String(S||"").trim();if(!Q)return;const re=y.current.find(Pt=>Pt.id===Q),ne=Kn((gi=re==null?void 0:re.data)==null?void 0:gi.definitionId),oe=ne==="html"?Wu(A):String(A||""),he=re?Jl(re.data):"",le=U==="append"&&String(he||"").trim()?`${String(he).replace(/\s+$/g,"")}
174
-
175
- ${oe.trim()}`:oe,Ne=ne==="image"?"src":"content",Be=Pt=>{let jr=!1;return(Array.isArray(Pt)?Pt:[]).map(Ir=>{const Un=String((Ir==null?void 0:Ir.name)||""),ht=String((Ir==null?void 0:Ir.type)||"");return!jr&&(Un===Ne||Un==="filePath"||ht==="text")?(jr=!0,{...Ir,default:le,value:le}):Ir})},at=y.current.map(Pt=>{var jr,Ks;return Pt.id!==Q?Pt:{...Pt,data:{...Pt.data,body:le,inputs:Be((jr=Pt.data)==null?void 0:jr.inputs),outputs:Be((Ks=Pt.data)==null?void 0:Ks.outputs)}}}),Ue=E.current||{},Lt=Ue[Q]&&typeof Ue[Q]=="object"?Ue[Q]:{},Ln={...Ue,[Q]:{...Lt,body:le,input:Be(Lt.input),output:Be(Lt.output)}};E.current=Ln,m(at),T(Ln),Br(Pt=>(Pt==null?void 0:Pt.id)===Q?{...Pt,body:le}:Pt),(X==null?void 0:X.logChat)!==!1&&Ii(Pt=>{var jr;return{...Pt,[Q]:{...Pt[Q]||{},candidateContent:"",messages:[...(jr=Pt[Q])!=null&&jr.messages&&Array.isArray(Pt[Q].messages)?Pt[Q].messages:[],{role:"assistant",text:U==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),Rn(at,v.current).catch(Pt=>Ae(String(Pt.message||Pt))),Ae(String((X==null?void 0:X.statusMessage)||"")||(U==="append"?"已追加节点内容":"已替换节点内容"))},[Rn,m,Le]),so=h.useCallback(async S=>{if(!Le)return Ae("Readonly workspace"),"";if(!cg(S))return Ae("请选择图片文件"),"";try{const A=new FormData;A.set("file",S),A.set("dir","img"),i.flowId&&A.set("flowId",i.flowId),i.flowSource&&A.set("flowSource",i.flowSource),i.archived&&A.set("archived","1");const U=await fetch("/api/workspace/upload",{method:"POST",body:A}),X=await U.json().catch(()=>({}));if(!U.ok)throw new Error(X.error||"上传图片失败");const Q=String(X.path||"").trim();if(!Q)throw new Error("上传图片失败:未返回路径");return await fr(),ct(re=>{const ne=new Set(re);for(const oe of $h(Q))ne.delete(oe);return ne}),Ae(`已上传图片 ${Q}`),Q}catch(A){return Ae(String(A.message||A)),""}},[i,fr,Le]),sd=h.useCallback(async(S,A)=>{const U=String(S||"").trim();if(!U)return;const X=await so(A);X&&bs(U,X,"replace",{logChat:!1,statusMessage:`已上传图片 ${X}`})},[bs,so]),Pp=h.useCallback((S,A="replace")=>{var Q;const U=String(S||"").trim(),X=String(((Q=ai[U])==null?void 0:Q.candidateContent)||"").trim();!U||!X||bs(U,X,A)},[ai,bs]),Nl=h.useCallback(async(S,A=void 0)=>{var le,Ne,Be;if(!Le){Ae("Readonly workspace");return}const U=String(S||"").trim();if(!U)return;const X=ai[U]||{},Q=String(A!==void 0?A:X.draft||"").trim();if(!Q||X.running)return;const re=y.current.find(at=>at.id===U);if(!re)return;const ne={role:"user",text:Q,at:Date.now()},oe=Array.isArray(X.messages)?X.messages:[],he=X.sessionId||`nodechat_${Date.now()}_${U.replace(/[^a-z0-9_-]+/gi,"_")}`;Ii(at=>({...at,[U]:{...X,sessionId:he,messages:[...oe,ne],draft:"",running:!0,error:""}}));try{const at=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,sessionId:he,node:{id:U,label:((le=re.data)==null?void 0:le.label)||U,definitionId:((Ne=re.data)==null?void 0:Ne.definitionId)||""},nodeKind:Kn((Be=re.data)==null?void 0:Be.definitionId)||"markdown",currentContent:Jl(re.data),messages:oe,message:Q,model:ms})}),Ue=await at.json().catch(()=>({}));if(!at.ok)throw new Error(Ue.error||"节点微调失败");const Lt=String(Ue.candidateContent||Ue.reply||"").trim();Ii(Ln=>{var gi;return{...Ln,[U]:{...Ln[U]||{},sessionId:String(Ue.sessionId||he),running:!1,candidateContent:Lt,messages:[...(gi=Ln[U])!=null&&gi.messages&&Array.isArray(Ln[U].messages)?Ln[U].messages:[...oe,ne],{role:"assistant",text:Lt||"已生成候选内容。",at:Date.now()}]}}})}catch(at){const Ue=String(at.message||at);Ii(Lt=>({...Lt,[U]:{...Lt[U]||{},running:!1,error:Ue}})),Ae(Ue)}},[ms,i,ai,Le]),Ap=h.useCallback(async(S,A)=>{if(!Le){Ae("Readonly workspace");return}const U=Jl(A);if(!String(U||"").trim()){Ae("展示节点没有可保存内容");return}const X=Iq(S,A),Q=window.prompt("保存到 workspace 相对路径",X);if(Q)try{const re=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:Q,content:U})}),ne=await re.json().catch(()=>({}));if(!re.ok)throw new Error(ne.error||"保存文件失败");const oe=ne.path||Q,he=Xo(i);he.set("path",oe);const le=await fetch(`/api/workspace/file?${he.toString()}`);if(!le.ok){const Ne=await le.json().catch(()=>({}));throw new Error(Ne.error||`保存后读取失败:${oe}`)}await fr(),tn(Ne=>$q(Ne,oe,String(U||"").length)),ct(Ne=>{const Be=new Set(Ne);for(const at of $h(oe))Be.delete(at);return Be}),Ae(`已保存 ${oe}`)}catch(re){Ae(String(re.message||re))}},[i,fr,Le]),id=h.useCallback((S,A)=>{const U=String(S||"");U&&Br(X=>{if(!X||X.id!==U)return X;const Q=typeof A=="function"?A(X):A;return!Q||typeof Q!="object"?X:{...X,...Q}})},[]),Hs=h.useMemo(()=>p.map(S=>{var A,U;return{...S,data:{...S.data,selected:S.selected===!0,modelLists:Fs,showBodyPreview:!0,isExecuting:Zu.has(S.id),nodeStatus:((A=ka[S.id])==null?void 0:A.status)??null,nodeElapsed:((U=ka[S.id])==null?void 0:U.elapsed)??null,flowParams:i,readOnly:!Le,onRunWorkspaceNode:Ep,onStopWorkspaceNode:kl,runningRunNodeId:ci,skills:yr,skillCollections:Vr,onChangeLoadSkillKeys:gc,onRefreshSkills:fi,mcpServers:ge,onChangeLoadMcpNames:uy,onRefreshMcps:Sl,onSaveDisplayNodeToFile:Ap,onUploadWorkspaceImage:so,onUploadImageToDisplayNode:sd,nodeChatActive:xr===S.id,nodeChat:ai[S.id]||null,onSetDisplayNodeContent:bs,onToggleNodeChat:pi,onCloseNodeChat:()=>wl(""),onUpdateNodeChatDraft:_p,onSendNodeChat:Nl,onApplyNodeChatCandidate:Pp,onSyncNodePropDraft:id}}}),[xr,Pp,uy,gc,i,ge,Fs,ai,p,Sl,fi,Ep,ci,Ap,Nl,bs,Vr,yr,kl,id,pi,_p,sd,so,Zu,ka,Le]),Ip=h.useMemo(()=>new Map(Hs.map(S=>[S.id,S])),[Hs]),jl=h.useMemo(()=>{const S=new Set(D);return w.nodeIds.map((A,U)=>{var oe;const X=Ip.get(A);if(!X||!Kn((oe=X.data)==null?void 0:oe.definitionId))return null;const Q=zc(X)||{width:520,height:320},re=mu(w.nodeSizes[A]||Q,{display:!0})||Q,ne=w.nodePositions[A]||{x:180+U*36,y:120+U*28};return{...X,id:v1(A),position:ne,selected:S.has(A),width:re.width,height:re.height,data:{...X.data,sourceNodeId:A,displayPageMode:!0,readOnly:!0,selected:S.has(A),displaySize:re,nodeSize:re}}}).filter(Boolean)},[w,Ip,D]),Ti=h.useMemo(()=>Hs.filter(S=>{var A;return Kn((A=S==null?void 0:S.data)==null?void 0:A.definitionId)}),[Hs]),ut=a==="display";h.useEffect(()=>{if(!ut||!w.viewport)return;const S=w.viewport,A=()=>{try{r.setViewport(S,{duration:0})}catch{}},U=window.requestAnimationFrame(()=>window.requestAnimationFrame(A));return()=>window.cancelAnimationFrame(U)},[w.viewport,ut,r]),h.useEffect(()=>{if(ut||!_)return;const S=_,A=()=>{try{r.setViewport(S,{duration:0})}catch{}},U=window.requestAnimationFrame(()=>window.requestAnimationFrame(A));return()=>window.cancelAnimationFrame(U)},[ut,r,_]),h.useEffect(()=>{const S=M.current,A=new Map,U=[];for(const ne of[...Hs,...jl]){const oe=hq(ne);A.set(ne.id,oe),S.get(ne.id)!==oe&&U.push(ne.id)}if(M.current=A,U.length===0)return;const X=()=>U.forEach(ne=>s(ne)),Q=window.requestAnimationFrame(X),re=window.setTimeout(X,80);return()=>{window.cancelAnimationFrame(Q),window.clearTimeout(re)}},[jl,Hs,s]);const qt=h.useMemo(()=>p.find(S=>S.id===cr)||null,[p,cr]),yc=h.useRef({id:"",draft:null}),dy=h.useMemo(()=>{const S=N1(qt);return S?JSON.stringify(S):""},[qt]);h.useEffect(()=>{if(!qt){yc.current={id:"",draft:null},Br(null),hs("");return}const S=N1(qt),A=yc.current;yc.current={id:qt.id,draft:S},Br(U=>!U||U.id!==qt.id||A.id!==qt.id||!A.draft?S:Uq(U,A.draft,S)),hs("")},[qt==null?void 0:qt.id,dy]);const od=h.useCallback((S=!1)=>{if(!st||!qt)return!1;if(!Le)return hs("Readonly workspace"),Ae("Readonly workspace"),!1;hs("");const A=C1({nodes:p,edges:g,instances:E.current,selectedNode:qt,draft:st,allowRename:S});return A!=null&&A.error?(hs(A.error),!1):(!(A!=null&&A.ok)||!A.changed||(E.current=A.instances,T(A.instances),m(A.nodes),b(A.edges),A.nextId!==qt.id&&Xn(A.nextId),We(A.nextId)),!0)},[g,st,p,qt,b,m,We,Le]);h.useEffect(()=>{if(!Le||!st||!qt)return;const S=window.setTimeout(()=>{od(!1)},350);return()=>window.clearTimeout(S)},[st==null?void 0:st.label,st==null?void 0:st.role,st==null?void 0:st.model,st==null?void 0:st.body,JSON.stringify((st==null?void 0:st.images)||[]),st==null?void 0:st.script,JSON.stringify((st==null?void 0:st.inputs)||[]),JSON.stringify((st==null?void 0:st.outputs)||[]),od,qt==null?void 0:qt.id,Le]);const xc=h.useMemo(()=>{const S=new Map(Hs.map(A=>[A.id,A]));return g.map(A=>{var le,Ne,Be,at;const U=S.get(A.source),X=S.get(A.target),Q=/^output-(\d+)$/.exec(A.sourceHandle||""),re=/^input-(\d+)$/.exec(A.targetHandle||""),ne=U&&Q?(Ne=(le=U.data)==null?void 0:le.outputs)==null?void 0:Ne[parseInt(Q[1],10)]:null,oe=X&&re?(at=(Be=X.data)==null?void 0:Be.inputs)==null?void 0:at[parseInt(re[1],10)]:null,he=ne!=null&&ne.type?nr(ne.type):oe!=null&&oe.type?nr(oe.type):"";return he?{...A,style:{...A.style||{},stroke:he,strokeWidth:2},markerEnd:{type:Ls.ArrowClosed,color:he}}:A})},[g,Hs]),Tp=ut?jl:Hs,Rp=ut?[]:xc,wc=h.useMemo(()=>ut?jl.map(S=>({...S,id:Ox(S.id)})):Hs,[jl,Hs,ut]),Bo=h.useCallback(S=>{const A=String(S||"").trim();if(!A)return;const U=ut?v1(A):A;ut?F([A]):(m(Q=>Q.map(re=>({...re,selected:re.id===U}))),b(Q=>Q.map(re=>({...re,selected:!1}))),Xn(U));const X=()=>{var le,Ne,Be;const Q=r.getNode(U);if(!Q)return;const re=(le=r.getInternalNode)==null?void 0:le.call(r,U),ne=((Ne=re==null?void 0:re.measured)==null?void 0:Ne.width)??(re==null?void 0:re.width)??Q.width??260,oe=((Be=re==null?void 0:re.measured)==null?void 0:Be.height)??(re==null?void 0:re.height)??Q.height??120,{zoom:he}=r.getViewport();r.setCenter(Q.position.x+ne/2,Q.position.y+oe/2,{zoom:gq(he),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(X))},[ut,r,b,m]),Cl=h.useCallback(()=>{const S=r.getViewport(),A={x:Number(S.x)||0,y:Number(S.y)||0,zoom:Math.min(Math.max(Number(S.zoom)||1,.1),4)};if(ut){const U={...P.current,viewport:A};P.current=U,j(U),Ae("已固定 Display 进入视角")}else B.current=A,L(A),Ae("已固定 Workspace 进入视角");Rn(y.current,v.current).catch(U=>Ae(String(U.message||U)))},[ut,r,Rn]),ss=h.useMemo(()=>{const S=de.trim().toLowerCase(),A={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const U of V)S&&![U.id,U.label,U.displayName,U.description].some(X=>String(X||"").toLowerCase().includes(S))||A[Vd(U)].push(U);for(const U of Fc)A[U].sort((X,Q)=>X.id.localeCompare(Q.id));return A},[V,de]),qr=h.useMemo(()=>{const S=cn.trim().toLowerCase();return V.filter(A=>!S||[A.id,A.label,A.displayName,A.description].some(U=>String(U||"").toLowerCase().includes(S))).sort((A,U)=>{const X=Fc.indexOf(Vd(A)),Q=Fc.indexOf(Vd(U));return X!==Q?X-Q:Ud(A).localeCompare(Ud(U))}).slice(0,30)},[V,cn]),Qn=h.useMemo(()=>{const S=cn.trim().toLowerCase();return be.filter(A=>!S||[A.id,A.version,A.displayName,A.name,A.description,...Array.isArray(A.tags)?A.tags:[]].some(U=>String(U||"").toLowerCase().includes(S))).sort((A,U)=>String(A.displayName||A.name||A.id).localeCompare(String(U.displayName||U.name||U.id))).slice(0,30)},[be,cn]);h.useEffect(()=>{ns(0)},[cn,ie,He]),h.useEffect(()=>{if(!ie)return;const S=window.setTimeout(()=>{var A;return(A=Gu.current)==null?void 0:A.focus()},0);return()=>window.clearTimeout(S)},[ie]);const io=h.useMemo(()=>{const S=Vn.trim().toLowerCase();return S?cR(Ee).filter(A=>A.path.toLowerCase().includes(S)):Ee},[Vn,Ee]),oo=[...(Fs.cursor||[]).map(S=>({label:`Cursor · ${S.split(" - ")[0]}`,value:`cursor:${S.split(" - ")[0]}`})),...(Fs.opencode||[]).map(S=>({label:`OpenCode · ${S.split(" - ")[0]}`,value:`opencode:${S.split(" - ")[0]}`})),...(Fs.claudeCode||[]).map(S=>({label:`Claude · ${S.split(" - ")[0]}`,value:`claude-code:${S.split(" - ")[0]}`}))],bc=h.useMemo(()=>new Set(Jn),[Jn]),Ho=h.useMemo(()=>{const S=new Map(yr.map(re=>[re.key,re])),A=new Set,U=new Set,X=Vr.map(re=>{const ne=il(re,yr).map(oe=>S.get(oe)).filter(Boolean);for(const oe of ne)A.add(oe.key),U.add(String(oe.name||oe.id||oe.key||"").trim());return{...re,skills:ne}}).filter(re=>re.skills.length>0),Q=yr.filter(re=>{const ne=String(re.name||re.id||re.key||"").trim();return!A.has(re.key)&&!U.has(ne)});return{groups:X,ungrouped:Q}},[Vr,yr]);h.useEffect(()=>{Ur(S=>{let A=!1;const U=new Set(S);for(const X of Ho.groups)U.has(X.id)||(U.add(X.id),A=!0);return A?U:S})},[Ho.groups]);const Fn=h.useMemo(()=>{const S=p.filter(A=>A.selected);return S.length>0?S:cr?p.filter(A=>A.id===cr):[]},[p,cr]),Ca=h.useMemo(()=>Fn.map(S=>S.id),[Fn]),kn=h.useMemo(()=>p.filter(S=>{var A;return Kn((A=S==null?void 0:S.data)==null?void 0:A.definitionId)}),[p]),Sn=h.useMemo(()=>Fn.filter(S=>{var A;return Kn((A=S==null?void 0:S.data)==null?void 0:A.definitionId)}).map(S=>S.id),[Fn]),El=h.useMemo(()=>{const S=String((Ar==null?void 0:Ar.username)||(Ar==null?void 0:Ar.userId)||"").trim();return S?S.slice(0,1).toUpperCase():"?"},[Ar]),Wo=h.useMemo(()=>new Set(Ca),[Ca]),ao=h.useMemo(()=>g.filter(S=>Wo.has(S.source)&&Wo.has(S.target)),[g,Wo]),ad=h.useCallback(S=>{const A=S==="display"?"display":"workspace";l(A),Xn(""),F([]),z(null),Pe(!1),Me(!1);const U=Xo(i);A==="display"&&U.set("view","display");const X=`/workspace${U.toString()?`?${U.toString()}`:""}`;window.history.pushState({},"",X)},[i]),Nt=h.useCallback(S=>{var X;const A=String(S||"").trim();if(!A)return;const U=y.current.find(Q=>Q.id===A);if(!U||!Kn((X=U.data)==null?void 0:X.definitionId)){Ae("展示节点不可用");return}j(Q=>{if(Q.nodeIds.includes(A))return Q;const re=Q.nodeIds.length,ne=zc(U);return{nodeIds:[...Q.nodeIds,A],nodePositions:{...Q.nodePositions,[A]:{x:180+re*36,y:120+re*28}},nodeSizes:{...Q.nodeSizes,...ne?{[A]:ne}:{}}}}),F([A])},[]),ld=h.useCallback(S=>{const A=String(S||"").trim();A&&(j(U=>{const X=U.nodeIds.filter(ne=>ne!==A),Q={...U.nodePositions},re={...U.nodeSizes};return delete Q[A],delete re[A],{nodeIds:X,nodePositions:Q,nodeSizes:re}}),F(U=>U.filter(X=>X!==A)))},[]),vc=h.useCallback(S=>{const A=String(S||"").trim();A&&(P.current.nodeIds.includes(A)?ld(A):Nt(A))},[Nt,ld]),Vo=h.useMemo(()=>{const S=Ze.trim().toLowerCase();return S?Ti.filter(A=>{var U,X;return[A.id,(U=A.data)==null?void 0:U.label,(X=A.data)==null?void 0:X.definitionId].filter(Boolean).some(Q=>String(Q).toLowerCase().includes(S))}):Ti},[Ti,Ze]),_l=h.useMemo(()=>{const S=Vo.length,A=S<=1?1:S<=4?2:3,U=Array.from({length:A},()=>({height:0,nodes:[]}));for(const X of Vo){const Q=zc(X)||{width:420,height:260},re=Math.max(1,Number(Q.width)||420),ne=Math.max(1,Number(Q.height)||260),oe=Math.min(26,Math.max(5.5,ne/re*16))+3.2;let he=U[0];for(const le of U)le.height<he.height&&(he=le);he.nodes.push(X),he.height+=oe}return U.map(X=>X.nodes)},[Vo]),Lp=h.useCallback(S=>{var re,ne;const A=w.nodeIds.includes(S.id),U=zc(S)||{width:420,height:260},X=Math.max(1,Math.round(Number(U.width)||420)),Q=Math.max(1,Math.round(Number(U.height)||260));return o.jsxs("button",{type:"button",className:"af-display-picker-card"+(A?" af-display-picker-card--selected":""),style:{"--af-display-picker-card-ratio":`${X} / ${Q}`},onClick:()=>vc(S.id),children:[o.jsx("span",{className:"af-display-picker-card__check","aria-hidden":!0,children:o.jsx("input",{type:"checkbox",checked:A,readOnly:!0,tabIndex:-1})}),o.jsx("span",{className:"af-display-picker-card__preview",children:o.jsx(Cq,{node:S})}),o.jsxs("span",{className:"af-display-picker-card__meta",children:[o.jsx("strong",{children:((re=S.data)==null?void 0:re.label)||S.id}),o.jsxs("small",{children:[Kn((ne=S.data)==null?void 0:ne.definitionId)," · ",S.id]})]})]},S.id)},[w.nodeIds,vc]),kc=h.useMemo(()=>{const S=de.trim().toLowerCase();return S?be.filter(A=>[A.id,A.version,A.displayName,A.name,A.description,...Array.isArray(A.tags)?A.tags:[]].filter(Boolean).some(U=>String(U).toLowerCase().includes(S))):be},[be,de]),Sc=h.useCallback((S,A)=>{const U=String(S||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let X=`${U}_${Date.now().toString(36)}`,Q=2;for(;A.has(X);)X=`${U}_${Date.now().toString(36)}_${Q}`,Q+=1;return A.add(X),X},[]),Pl=h.useCallback((S,A)=>{var Ir,Un;if(!Le){Ae("Readonly workspace");return}const U=S!=null&&S.snippet&&typeof S.snippet=="object"?S.snippet:{},X=U.instances&&typeof U.instances=="object"?U.instances:{},Q=Object.keys(X);if(Q.length===0)return;const re=new Set(y.current.map(ht=>ht.id)),ne={};for(const ht of Q)ne[ht]=Sc(ht,re);const oe=(Ir=U.ui)!=null&&Ir.nodePositions&&typeof U.ui.nodePositions=="object"?U.ui.nodePositions:{},he=(Un=U.ui)!=null&&Un.nodeSizes&&typeof U.ui.nodeSizes=="object"?U.ui.nodeSizes:{},le=Q.map(ht=>{const fn=oe[ht];return{id:ht,x:typeof(fn==null?void 0:fn.x)=="number"?fn.x:0,y:typeof(fn==null?void 0:fn.y)=="number"?fn.y:0}}),Ne=Math.min(...le.map(ht=>ht.x)),Be=Math.min(...le.map(ht=>ht.y));let at=A||{x:360+y.current.length*24,y:180+y.current.length*18};if(!A){const ht=document.querySelector(".af-workspace-canvas .react-flow");if(ht){const fn=ht.getBoundingClientRect();at=r.screenToFlowPosition({x:fn.left+fn.width*.48,y:fn.top+fn.height*.32})}}const Ue={},Lt={},Ln={};for(const ht of le){const fn=ne[ht.id];Ue[fn]={...X[ht.id]||{}},Lt[fn]={x:at.x+(ht.x-Ne),y:at.y+(ht.y-Be)};const is=he[ht.id];typeof(is==null?void 0:is.width)=="number"&&typeof(is==null?void 0:is.height)=="number"&&(Ln[fn]={width:is.width,height:is.height})}const gi=new Set(Q),Pt=(Array.isArray(U.edges)?U.edges:[]).filter(ht=>gi.has(ht==null?void 0:ht.source)&&gi.has(ht==null?void 0:ht.target)).map(ht=>({source:ne[ht.source],target:ne[ht.target],sourceHandle:ht.sourceHandle??null,targetHandle:ht.targetHandle??null})),jr=Lx({instances:Ue,edges:Pt,ui:{nodePositions:Lt,nodeSizes:Ln}},V),Ks=jr.nodes.map(ht=>({...ht,selected:!0}));E.current={...E.current,...jr.instances},T(E.current),m(ht=>[...ht.map(fn=>({...fn,selected:!1})),...Ks]),b(ht=>[...ht.map(fn=>({...fn,selected:!1})),...jr.edges]),Ae(`已添加流程片段:${S.displayName||S.id}`)},[Sc,V,r,b,m,Le]),Op=h.useCallback(()=>{var U,X;if(Fn.length<2){et("请先在 workspace 画布上选择至少两个节点。"),ae("flows");return}const S=Fn[0],A=Fn.length===2?`${((U=S.data)==null?void 0:U.label)||S.id} 片段`:`${((X=S.data)==null?void 0:X.label)||S.id} 等 ${Fn.length} 个节点`;Ve({name:A,id:A.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),In(""),Je(!0),ae("flows")},[Fn]),Mp=h.useCallback(async()=>{var Q,re;if(Fn.length<2)return;const S=bt.name.trim();if(!S){In("请填写片段名称。");return}const A={},U={};for(const ne of Fn){A[ne.id]={x:((Q=ne.position)==null?void 0:Q.x)||0,y:((re=ne.position)==null?void 0:re.y)||0};const oe=zc(ne);oe&&(U[ne.id]=oe)}const X=ao.map(ne=>({source:ne.source,target:ne.target,sourceHandle:ne.sourceHandle??null,targetHandle:ne.targetHandle??null}));An(!0),In("");try{const ne=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:bt.id,name:S,displayName:S,version:"1.0.0",description:bt.description,snippet:{instances:hp(Fn,E.current),edges:X,ui:{nodePositions:A,nodeSizes:U}}})}),oe=await ne.json().catch(()=>({}));if(!ne.ok||oe.ok===!1)throw new Error(oe.error||"发布流程片段失败");Je(!1),Ae(`流程片段已发布:${oe.id||S}`),Re(`流程片段已发布:${oe.id||S}`),await ro(),ae("flows")}catch(ne){In(String(ne.message||ne))}finally{An(!1)}},[ro,bt,ao,Fn,Re]);h.useCallback(()=>{if(kn.length===0){Ae("当前 workspace 没有 display 节点");return}const S=Sn.length>0?Sn:kn.map(U=>U.id),A=i.flowId?`${i.flowId} 展示页`:"AgentFlow Display";rr({title:A,layout:"gallery",nodeIds:S}),Tt(""),an(null),ve(!0)},[i.flowId,Sn,kn]);const Yr=h.useCallback(S=>{rr(A=>{const U=Array.isArray(A.nodeIds)?A.nodeIds:[];return U.includes(S)?{...A,nodeIds:U.filter(X=>X!==S)}:{...A,nodeIds:[...U,S]}})},[]),$p=h.useCallback(async()=>{var U;const S=Xt.title.trim(),A=Array.isArray(Xt.nodeIds)?Xt.nodeIds:[];if(A.length===0){Tt("请选择至少一个 display 节点。");return}it(!0),Tt(""),an(null);try{await Rn(p,g);const X=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,title:S,layout:Xt.layout,nodeIds:A})}),Q=await X.json().catch(()=>({}));if(!X.ok||Q.ok===!1)throw new Error(Q.error||"发布展示页失败");const re=new URL(Q.url||`/display/${((U=Q.share)==null?void 0:U.id)||""}`,window.location.origin).href;an({...Q,absoluteUrl:re}),Ae("展示页已生成")}catch(X){Tt(String(X.message||X))}finally{it(!1)}},[Xt,g,i,p,Rn]),Ws=h.useCallback(async()=>{var A;const S=Array.isArray(w.nodeIds)?w.nodeIds:[];if(S.length===0){Tt("请先添加至少一个展示节点。"),Ae("请先添加至少一个展示节点"),Me(!0);return}it(!0),Tt("");try{await Rn(p,g);const U=i.flowId?`${i.flowId} 展示页`:"AgentFlow Display",X=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,title:U,layout:"canvas",nodeIds:S})}),Q=await X.json().catch(()=>({}));if(!X.ok||Q.ok===!1)throw new Error(Q.error||"生成展示链接失败");const re=new URL(Q.url||`/display/${((A=Q.share)==null?void 0:A.id)||""}`,window.location.origin).href;an({...Q,absoluteUrl:re}),ln(!0),Ae("展示链接已生成")}catch(U){const X=String(U.message||U);Tt(X),Ae(X)}finally{it(!1)}},[w.nodeIds,g,i,p,Rn]),Vs=h.useCallback(async()=>{const S=tt==null?void 0:tt.absoluteUrl;if(!S)return;const A=await yq(S);sr(A?"copied":"failed"),window.setTimeout(()=>sr(""),1600)},[tt==null?void 0:tt.absoluteUrl]),Dp=h.useCallback(S=>{m(A=>A.map(U=>U.id===S?{...U,selected:!1}:U)),Xn(A=>A===S?"":A)},[m]),hi=h.useCallback(()=>{const S=or.current;if(!S)return;const A=S.getBoundingClientRect(),U=Math.min(420,Math.max(320,A.width+160)),X=12,Q=Math.max(180,A.top-X*2),re=Math.min(560,Q);Ai({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-U-12,A.left)),top:Math.max(X,A.top-re-X),width:U,maxHeight:re,zIndex:1e4})},[]);h.useEffect(()=>{if(!rs)return;hi();const S=U=>{var Q,re;const X=U.target;(Q=or.current)!=null&&Q.contains(X)||(re=xa.current)!=null&&re.contains(X)||Bs(!1)},A=U=>{U.key==="Escape"&&Bs(!1)};return window.addEventListener("pointerdown",S),window.addEventListener("keydown",A),window.addEventListener("resize",hi),window.addEventListener("scroll",hi,!0),()=>{window.removeEventListener("pointerdown",S),window.removeEventListener("keydown",A),window.removeEventListener("resize",hi),window.removeEventListener("scroll",hi,!0)}},[rs,hi]);const Fp=h.useCallback(S=>{var X,Q,re;if(a==="display"){const ne=[];let oe=!1;j(he=>{var Be,at;const le={...he.nodePositions},Ne={...he.nodeSizes};for(const Ue of S||[]){const Lt=Ox(Ue==null?void 0:Ue.id);if(!(!Lt||!he.nodeIds.includes(Lt))){if(Ue.type==="select"){Ue.selected&&ne.push(Lt);continue}if(Ue.type==="position"&&Ue.position){le[Lt]={x:Ue.position.x,y:Ue.position.y},oe=!0;continue}if(Ue.type==="dimensions"&&((Be=Ue.dimensions)!=null&&Be.width)&&((at=Ue.dimensions)!=null&&at.height)){const Ln=mu({width:Math.round(Number(Ue.dimensions.width)),height:Math.round(Number(Ue.dimensions.height))},{display:!0});Ln&&(Ne[Lt]=Ln,oe=!0)}}}return oe?{...he,nodePositions:le,nodeSizes:Ne}:he}),(S||[]).some(he=>(he==null?void 0:he.type)==="select")&&F(ne);return}if(!Le){const ne=(S||[]).filter(oe=>(oe==null?void 0:oe.type)==="select");ne.length>0&&m(oe=>Ym(ne,oe));return}const A=new Map;for(const ne of S||[])if((ne==null?void 0:ne.type)==="dimensions"&&((X=ne.dimensions)!=null&&X.width)&&((Q=ne.dimensions)!=null&&Q.height)){const oe=p.find(Ne=>Ne.id===ne.id),he=!!Kn((re=oe==null?void 0:oe.data)==null?void 0:re.definitionId),le=mu({width:Math.round(Number(ne.dimensions.width)),height:Math.round(Number(ne.dimensions.height))},{display:he});le&&A.set(ne.id,le)}const U=Array.from(A.keys());if(m(ne=>Ym(S,ne).map(oe=>{var le;const he=A.get(oe.id);return he?Kn((le=oe.data)==null?void 0:le.definitionId)?{...oe,width:he.width,height:he.height,data:{...oe.data,nodeSize:he,displaySize:he}}:{...oe,width:he.width,height:he.height,data:{...oe.data,nodeSize:he}}:oe})),U.length>0){const ne=()=>U.forEach(oe=>s(oe));window.requestAnimationFrame(ne),window.setTimeout(ne,80)}},[p,m,s,a,Le]),Al=h.useCallback(S=>{if(a!=="display"){if(!Le){const A=(S||[]).filter(U=>(U==null?void 0:U.type)==="select");A.length>0&&b(U=>Zv(A,U));return}k(S)}},[k,b,a,Le]),Uo=h.useCallback(()=>{const S=document.querySelector(".af-workspace-canvas .react-flow");if(S){const A=S.getBoundingClientRect();return r.screenToFlowPosition({x:A.left+A.width*.48,y:A.top+A.height*.32})}return{x:360+p.length*36,y:180+p.length*28}},[p.length,r]),Zn=h.useCallback(()=>{var S,A,U;if(qt){const X=Number(((S=qt.measured)==null?void 0:S.width)||qt.width||260);return{x:Number(((A=qt.position)==null?void 0:A.x)||0)+X+140,y:Number(((U=qt.position)==null?void 0:U.y)||0)}}return Uo()},[Uo,qt]),mi=h.useCallback((S,A={})=>{if(!Le)return Ae("Readonly workspace"),null;if(!S)return null;const U=A0(S)||S.id,X=rR(S),Q=A.id||fq(U,p),re=Oh(S.inputs),ne=Oh(S.outputs),oe={definitionId:U,...X?{marketplaceRef:X}:{},...S.packageId?{marketplacePackageId:S.packageId}:{},...S.version?{marketplaceVersion:S.version}:{},label:A.label||dg(S),role:"normal",body:A.body||"",input:A.inputs||re,output:A.outputs||ne},he={id:Q,type:mp,position:A.position||Uo(),data:{label:oe.label,definitionId:U,...X?{marketplaceRef:X}:{},...S.packageId?{marketplacePackageId:S.packageId}:{},...S.version?{marketplaceVersion:S.version}:{},schemaType:nR(U,S),role:"normal",body:oe.body,inputs:oe.input,outputs:oe.output}},le={...qf(he,{...E.current,[Q]:oe},V),selected:!0};return m(Ne=>[...Ne.map(Be=>({...Be,selected:!1})),le]),A.openProperties&&Xn(Q),Q},[Uo,p,V,m,Le]),Ri=h.useCallback(S=>b1(S,y.current),[]),Nc=h.useCallback(S=>{if(!Le){Ae("Readonly workspace");return}if(!b1(S,y.current)){Ae("端口类型不匹配,已取消连线");return}z(null),m(A=>og(A,S)),b(A=>{const U=A.filter(X=>!(X.target===S.target&&X.targetHandle===S.targetHandle));return Ff({...S,markerEnd:{type:Ls.ArrowClosed}},U)})},[b,m,Le]),lo=h.useCallback((S,A)=>{Le&&(O.current=uq(A,y.current),z(null))},[Le]),Ea=h.useCallback((S,A)=>{var at,Ue,Lt,Ln;if(!Le)return;const U=O.current;if(O.current=null,!U||A!=null&&A.toNode)return;const X=dq(V,U);if(X.length===0){Ae(`没有匹配 ${U.slotType} 端口的节点`);return}const Q=((Ue=(at=S==null?void 0:S.changedTouches)==null?void 0:at[0])==null?void 0:Ue.clientX)??(S==null?void 0:S.clientX),re=((Ln=(Lt=S==null?void 0:S.changedTouches)==null?void 0:Lt[0])==null?void 0:Ln.clientY)??(S==null?void 0:S.clientY);if(!Number.isFinite(Q)||!Number.isFinite(re))return;const ne=document.querySelector(".af-workspace-canvas .react-flow");if(!ne)return;const oe=ne.getBoundingClientRect(),he=320,le=Math.min(440,104+X.length*58),Ne=Math.max(12,Math.min(Q-oe.left,oe.width-he-12)),Be=Math.max(12,Math.min(re-oe.top,oe.height-le-12));z({left:Ne,top:Be,flowPosition:r.screenToFlowPosition({x:Q,y:re}),draft:U,candidates:X,query:""})},[V,r,Le]),cd=h.useCallback(S=>{if(!Le){Ae("Readonly workspace"),z(null);return}const A=$.current;if(!A||!(S!=null&&S.def))return;const U=mi(S.def,{position:A.flowPosition});if(!U)return;const X=A.draft.handleType==="source"?{source:A.draft.nodeId,sourceHandle:A.draft.handleId,target:U,targetHandle:`input-${S.slotIndex}`}:{source:U,sourceHandle:`output-${S.slotIndex}`,target:A.draft.nodeId,targetHandle:A.draft.handleId};m(Q=>og(Q,X)),b(Q=>{const re=Q.filter(ne=>!(ne.target===X.target&&ne.targetHandle===X.targetHandle));return Ff({...X,markerEnd:{type:Ls.ArrowClosed}},re)}),z(null)},[mi,b,Le]),Il=h.useCallback(S=>{S&&(mi(S,{position:Zn()}),Pe(!1),ir(""))},[mi,Zn]),Ct=h.useCallback(S=>{S&&(Pl(S,Zn()),Pe(!1),ir(""))},[Pl,Zn]);h.useEffect(()=>{const S=A=>{var le;if(A.defaultPrevented)return;const U=IT(A.target)||oq(A.target);if((A.metaKey||A.ctrlKey)&&A.key.toLowerCase()==="s"){A.preventDefault(),Rn().catch(Ne=>Ae(String(Ne.message||Ne)));return}if((A.metaKey||A.ctrlKey)&&A.key.toLowerCase()==="k"){A.preventDefault(),A.stopPropagation(),vl(Ne=>!Ne);return}if(bl)return;if(ba){(A.key==="Escape"||lg(A))&&(A.preventDefault(),Fo(!1));return}const X=A.key.toLowerCase(),Q=(A.metaKey||A.ctrlKey)&&X==="c",re=(A.metaKey||A.ctrlKey)&&X==="v",ne=U&&Q&&lq(A.target);if(U&&!ne)return;const oe=(A.metaKey||A.ctrlKey)&&!A.shiftKey&&X==="z",he=(A.metaKey||A.ctrlKey)&&(A.shiftKey&&X==="z"||X==="y");if(oe||he){if(ut){A.preventDefault(),A.stopPropagation(),Ae("展示页布局会自动保存");return}if(!Le){A.preventDefault(),Ae("Readonly workspace");return}A.preventDefault(),A.stopPropagation();const Ne=oe?Np():jp();Ae(Ne?oe?"Undo canvas change":"Redo canvas change":oe?"Nothing to undo":"Nothing to redo");return}if(Q){if(ut)return;const Ne=zr.current,Be=(y.current||[]).some(Ue=>Ue==null?void 0:Ue.selected)?y.current:(y.current||[]).map(Ue=>Ne&&Ue.id===Ne?{...Ue,selected:!0}:Ue),at=kT(Be,v.current,E.current);at&&(A.preventDefault(),A.stopPropagation(),W.current=at,ne&&typeof((le=A.target)==null?void 0:le.blur)=="function"&&A.target.blur(),Ae(`Copied ${at.nodes.length} node${at.nodes.length>1?"s":""}`));return}if(re){if(ut){A.preventDefault(),A.stopPropagation();return}if(!Le){A.preventDefault(),Ae("Readonly workspace");return}const Ne=ST(W.current,y.current,v.current,E.current);Ne&&(A.preventDefault(),A.stopPropagation(),E.current=Ne.instances,T(Ne.instances),m(Ne.nodes),b(Ne.edges),Ae(`Pasted ${Ne.pastedNodeIds.length} node${Ne.pastedNodeIds.length>1?"s":""}`));return}if(lg(A)&&!A.metaKey&&!A.ctrlKey&&!A.altKey){A.preventDefault(),Fo(!0);return}if(A.key==="a"||A.key==="A"){if(A.metaKey||A.ctrlKey){A.preventDefault(),ut?F(P.current.nodeIds):(m(Ne=>Ne.map(Be=>({...Be,selected:!0}))),b(Ne=>Ne.map(Be=>({...Be,selected:!1}))));return}if(A.altKey)return;if(ut){A.preventDefault(),Me(!0);return}if(!Le){A.preventDefault(),Ae("Readonly workspace");return}A.preventDefault(),Pe(!0);return}if((A.key==="v"||A.key==="V")&&!A.metaKey&&!A.ctrlKey&&!A.altKey){A.preventDefault(),li("select");return}if((A.key==="h"||A.key==="H")&&!A.metaKey&&!A.ctrlKey&&!A.altKey){A.preventDefault(),li("pan");return}(A.key==="f"||A.key==="F")&&!A.metaKey&&!A.ctrlKey&&!A.altKey&&(A.preventDefault(),Cl())};return window.addEventListener("keydown",S,!0),()=>window.removeEventListener("keydown",S,!0)},[ut,bl,Cl,jp,Rn,ba,b,m,Np,Le]);const vt=h.useCallback(S=>{ct(A=>{const U=new Set(A);return U.has(S)?U.delete(S):U.add(S),U})},[]),fy=h.useCallback((S,A)=>{S.dataTransfer.effectAllowed="copy",S.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:A.path,name:A.name,type:A.type})),S.dataTransfer.setData("text/plain",A.path)},[]),mn=h.useCallback((S,A)=>{S.dataTransfer.effectAllowed="move",S.dataTransfer.setData("application/agentflow-node",A.id),S.dataTransfer.setData("text/plain",A.id)},[]),Yt=h.useCallback(async(S,A)=>{const U=String((S==null?void 0:S.name)||(S==null?void 0:S.path)||"").toLowerCase(),X=U.split(".").pop(),Q=X==="html"?"display_html":X==="csv"||X==="tsv"||X==="json"&&/\b(table|data|rows|report)\b/i.test(U)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(X)?"display_image":"display_markdown",re=V.find(Be=>Be.id===Q);if(!re){Ae("展示节点不可用");return}const ne=Q==="display_image";let oe=String(S.path||"");if(!ne){const Be=Xo(i);Be.set("path",S.path);const at=await fetch(`/api/workspace/file?${Be.toString()}`),Ue=await at.json();if(!at.ok)throw new Error(Ue.error||"读取文件失败");oe=String(Ue.content||"")}const he=Q==="display_image"?"src":"content",le=Oh(re.inputs).map(Be=>Be.name===he?{...Be,default:oe,value:oe}:Be),Ne=Oh(re.outputs).map(Be=>Be.name===he?{...Be,default:oe,value:oe}:Be);mi(re,{label:S.name||"Display",body:oe,inputs:le,outputs:Ne,position:A}),Ae(`已创建展示:${S.path}`)},[mi,i,V]),py=h.useCallback(S=>{if(!Le){Ae("Readonly workspace");return}Yt(S,Uo()).catch(A=>Ae(String(A.message||A)))},[Yt,Uo,Le]),Us=h.useCallback(S=>{if(!Le){S.preventDefault(),Ae("Readonly workspace");return}const A=S.dataTransfer.getData("application/x-agentflow-workspace-file");if(A){S.preventDefault();let ne;try{ne=JSON.parse(A)}catch{return}if(!(ne!=null&&ne.path))return;const oe=r.screenToFlowPosition({x:S.clientX,y:S.clientY});Yt(ne,oe).catch(he=>Ae(String(he.message||he)));return}const U=S.dataTransfer.getData("application/agentflow-snippet");if(U){const ne=be.find(he=>`${he.id}@${he.version}`===U);if(!ne)return;S.preventDefault();const oe=r.screenToFlowPosition({x:S.clientX,y:S.clientY});Pl(ne,oe);return}const X=S.dataTransfer.getData("application/agentflow-node");if(!X)return;const Q=V.find(ne=>ne.id===X);if(!Q)return;S.preventDefault();const re=r.screenToFlowPosition({x:S.clientX,y:S.clientY});mi(Q,{position:re})},[Yt,mi,be,Pl,V,r,Le]),Ko=h.useCallback(S=>{if(!Le)return;const A=Array.from(S.dataTransfer.types||[]);!A.includes("application/x-agentflow-workspace-file")&&!A.includes("application/agentflow-node")&&!A.includes("application/agentflow-snippet")||(S.preventDefault(),S.dataTransfer.dropEffect=A.includes("application/agentflow-node")||A.includes("application/agentflow-snippet")?"move":"copy")},[Le]),ud=h.useCallback(async(S="")=>{if(!Le){Ae("Readonly workspace");return}const A=window.prompt("新文件名",S?`${S}/notes.md`:"notes.md");if(!A)return;const U=S&&!A.includes("/")?`${S}/${A}`:A;try{const X=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:U,content:""})}),Q=await X.json();if(!X.ok)throw new Error(Q.error||"创建文件失败");await fr(),ct(re=>{const ne=new Set(re);for(const oe of $h(Q.path||U))ne.delete(oe);return ne}),Ae(`已创建 ${Q.path}`)}catch(X){Ae(String(X.message||X))}},[i,fr,Le]),jc=h.useCallback(async(S="")=>{if(!Le){Ae("Readonly workspace");return}const A=window.prompt("新文件夹名",S?`${S}/docs`:"docs");if(!A)return;const U=S&&!A.includes("/")?`${S}/${A}`:A;try{const X=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:U})}),Q=await X.json();if(!X.ok)throw new Error(Q.error||"创建文件夹失败");await fr(),ct(re=>{const ne=new Set(re);for(const oe of $h(Q.path||U))ne.delete(oe);return Q.path&&ne.delete(Q.path),ne}),Ae(`已创建 ${Q.path}`)}catch(X){Ae(String(X.message||X))}},[i,fr,Le]),zp=h.useCallback(async S=>{if(!Le){Ae("Readonly workspace");return}if(!(!(S!=null&&S.path)||!window.confirm(`删除 ${S.path}?`)))try{const A=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,path:S.path})}),U=await A.json();if(!A.ok)throw new Error(U.error||"删除失败");Ae(`已删除 ${U.path}`),await fr()}catch(A){Ae(String(A.message||A))}},[i,fr,Le]),Tl=h.useCallback(async()=>{if(!Le){Ae("Readonly workspace");return}const S=wa.trim();if(!S||Nr)return;const A=Mh(p,g,E.current);ml(""),gl(!0),Cp("workspace"),Vt(U=>[...U,{role:"user",text:S,at:Date.now()}]);try{await Rn(p,g);const U=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...i,prompt:S,outputKind:"markdown",workspaceGraph:A,allowFlowYaml:!1,model:ms,selectedSkills:Jn,selectedNodeIds:Ca})}),X=await U.json();if(!U.ok)throw new Error(X.error||"生成失败");const Q=String(X.content||"").trim();Vt(re=>[...re,{role:"assistant",text:Q,at:Date.now()}]),await yt(),Ae("AI 生成完成")}catch(U){const X=String(U.message||U);Vt(Q=>[...Q,{role:"assistant",text:X,error:!0,at:Date.now()}]),Ae(X)}finally{gl(!1)}},[ms,Nr,wa,g,i,yt,p,Cp,Rn,Ca,Jn,Le]),rn=hc.find(S=>S.id===xl)||null,Li=rn?Array.isArray(rn.messages)?rn.messages:[]:yl,Bp=rn?rn.status==="running":Nr,hy=rn?rn.status==="running"?`${rn.label} running`:rn.status==="paused"?`${rn.label} paused`:rn.status==="failed"?`${rn.label} failed`:`${rn.label} done`:Nr?"Workspace agent running":yl.length>0?"Workspace conversation":"Ready";return o.jsxs("div",{className:"af-workspace-page",children:[o.jsxs("header",{className:"af-pipeline-top af-workspace-top",children:[o.jsxs("div",{className:"af-pipeline-top-left",children:[o.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>n("/projects"),"aria-label":"返回",children:o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),o.jsxs("div",{className:"af-pipeline-brand",title:i.flowId?`${i.flowId} · ${ur}`:ur||"PROJECT",children:[o.jsx("span",{className:"af-pipeline-brand-name",children:"WORKSPACE"}),o.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",nq,"-STABLE"]})]}),o.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[o.jsx("button",{type:"button",onClick:()=>{n(Af({id:i.flowId,source:i.flowSource||"user",archived:!!i.archived},"pipeline"))},children:"Pipeline"}),o.jsx("button",{type:"button",className:a==="workspace"?"af-view-switch__active":"",onClick:()=>ad("workspace"),children:"Workspace"}),o.jsx("button",{type:"button",className:a==="display"?"af-view-switch__active":"",onClick:()=>ad("display"),children:"Display"})]})]}),o.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[o.jsx("span",{className:"af-workspace-save-status",children:xs}),ut?o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:ze||!(tt!=null&&tt.absoluteUrl)&&w.nodeIds.length===0,onClick:()=>{sr(""),tt!=null&&tt.absoluteUrl?ln(!0):Ws()},title:tt!=null&&tt.absoluteUrl?"查看展示链接":w.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ze?"hourglass_empty":"ios_share"}),ze?"生成中":tt!=null&&tt.absoluteUrl?"展示链接":"生成链接"]}),o.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:Ti.length===0,onClick:()=>Me(!0),title:Ti.length===0?"当前 workspace 没有 display 节点":"选择展示节点 (A)",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"添加展示"]})]}):null,o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>n(ed),"aria-label":e("flow:topbar.pipelineSettings"),title:e("flow:topbar.pipelineSettings"),children:o.jsx("span",{className:"material-symbols-outlined",children:"settings"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!kp,onClick:()=>d(!0),"aria-label":e("project:archiveModal.title"),title:e("project:archiveModal.title"),children:o.jsx("span",{className:"material-symbols-outlined",children:"archive"})}),o.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger",disabled:!kp,onClick:()=>c(!0),"aria-label":e("flow:topbar.deletePipeline"),title:e("flow:topbar.deletePipeline"),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_forever"})}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Fo(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:o.jsx("span",{className:"material-symbols-outlined",children:"help"})}),o.jsx("button",{type:"button",className:"af-composer-topbar-btn"+(oi?" af-composer-topbar-btn--active":"")+(Nr?" af-composer-topbar-btn--running":""),disabled:ut,onClick:()=>Mo(S=>!S),children:"AI"}),o.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!Le,onClick:()=>Rn().catch(S=>Ae(String(S.message||S))),children:"Save"})]})]}),en?o.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsx("span",{children:en}),o.jsx("button",{type:"button",onClick:()=>Wn(""),"aria-label":"关闭发布提示",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,o.jsxs("div",{className:"af-workspace-body"+(!ut&&(oi||st)?" af-workspace-body--drawer":"")+(!ut&&mc?" af-workspace-body--sidebar-collapsed":"")+(ut?" af-workspace-body--display-mode":""),children:[!ut&&mc?o.jsx("nav",{className:"af-workspace-rail","aria-label":"Workspace sidebar",children:o.jsxs("div",{className:"af-workspace-rail__stack",children:[o.jsxs("button",{type:"button",className:"af-workspace-rail__primary",onClick:()=>Pe(!0),"aria-label":"添加节点",title:"添加节点",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"}),o.jsx("span",{className:"af-workspace-rail__dot","aria-hidden":!0})]}),o.jsx("button",{type:"button",className:"af-workspace-rail__btn",onClick:()=>Do(!1),"aria-label":"展开文件",title:"展开文件",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"})}),o.jsx("span",{className:"af-workspace-rail__divider","aria-hidden":!0}),o.jsx("button",{type:"button",className:"af-workspace-rail__avatar",onClick:()=>Do(!1),"aria-label":"展开侧边栏",title:(Ar==null?void 0:Ar.username)||(Ar==null?void 0:Ar.userId)||"展开侧边栏",children:El})]})}):null,ut?null:o.jsxs("aside",{ref:Wt,className:"af-workspace-sidebar"+(Qe?" af-workspace-sidebar--resizing":""),"aria-hidden":mc,style:{"--af-work-files-pane-height":`${Math.round(nn)}px`},children:[o.jsxs("section",{className:"af-workspace-files-section",children:[o.jsxs("div",{className:"af-workspace-sidebar-head",children:[o.jsx("h2",{children:"Files"}),o.jsxs("div",{className:"af-workspace-sidebar-actions",children:[o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>Do(!0),"aria-label":"最小化侧边栏",title:"最小化侧边栏",children:o.jsx("span",{className:"material-symbols-outlined",children:"keyboard_double_arrow_left"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Le,onClick:()=>ud(""),"aria-label":"新增文件",title:"新增文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),o.jsx("button",{type:"button",className:"af-icon-btn",disabled:!Le,onClick:()=>jc(""),"aria-label":"新增文件夹",title:"新增文件夹",children:o.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),o.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void fr(),"aria-label":"刷新文件",title:"刷新文件",children:o.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]})]}),o.jsx("input",{className:"af-workspace-search",value:Vn,onChange:S=>Wr(S.target.value),placeholder:"搜索文件..."}),o.jsx("div",{className:"af-workspace-files-scroll",children:o.jsx(dR,{items:io,flowParams:i,onOpen:py,collapsedDirs:kr,onToggleDir:vt,onCreateFile:ud,onCreateFolder:jc,onDelete:zp,onFileDragStart:fy})})]}),o.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:Rt,role:"separator","aria-orientation":"horizontal","aria-label":"调整 Files 和 Palette 区域大小",title:"拖动调整 Files / Palette 高度"}),o.jsxs("section",{className:"af-workspace-nodes-section",children:[o.jsxs("div",{className:"af-node-palette-head af-workspace-node-palette-head",children:[o.jsxs("h2",{className:"af-node-palette-title",children:[o.jsx("span",{children:"Palette"}),o.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),o.jsxs("label",{className:"af-palette-search-wrap",children:[o.jsx("span",{className:"af-visually-hidden",children:pe==="flows"?"搜索流程片段":"搜索节点"}),o.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",className:"af-palette-search-input",value:de,onChange:S=>fe(S.target.value),placeholder:pe==="flows"?"搜索流程片段...":"搜索节点...","aria-label":pe==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[o.jsxs("button",{type:"button",role:"tab","aria-selected":pe==="nodes",className:"af-palette-tab"+(pe==="nodes"?" af-palette-tab--active":""),onClick:()=>ae("nodes"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),o.jsxs("button",{type:"button",role:"tab","aria-selected":pe==="flows",className:"af-palette-tab"+(pe==="flows"?" af-palette-tab--active":""),onClick:()=>ae("flows"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),o.jsx("div",{className:"af-node-palette-scroll af-workspace-node-palette-scroll",children:pe==="flows"?o.jsxs(o.Fragment,{children:[o.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:o.jsxs("div",{className:"af-flow-snippet-actions",children:[o.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:Op,disabled:Fn.length<2,title:Fn.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),o.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",Fn.length," 节点 / ",ao.length," 连线"]})]})}),Ie?o.jsx("p",{className:"af-err af-palette-list-err",children:Ie}):null,we?o.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):kc.length>0?o.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[o.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),o.jsx("div",{className:"af-palette-cards",children:kc.map(S=>{const A=`${S.id}@${S.version}`,U=S.displayName||S.name||S.id,X=S.description||`${S.nodeCount||0} 个节点,${S.edgeCount||0} 条连线`;return o.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",draggable:!0,onDragStart:Q=>{Q.dataTransfer.effectAllowed="move",Q.dataTransfer.setData("application/agentflow-snippet",A),Q.dataTransfer.setData("text/plain",A)},onClick:()=>Pl(S),title:X,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:U}),o.jsxs("span",{className:"af-palette-card-id",children:[S.id,"@",S.version]})]})]}),X?o.jsx("span",{className:"af-palette-card-desc",children:X}):null,o.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[o.jsxs("span",{children:[S.nodeCount||0," nodes"]}),o.jsxs("span",{children:[S.edgeCount||0," edges"]})]})]},A)})})]}):o.jsx("p",{className:"af-palette-empty",children:de.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):o.jsxs(o.Fragment,{children:[Fc.map(S=>{var A;return(A=ss[S])!=null&&A.length?o.jsxs("section",{className:`af-palette-section af-flow-palette-section--${S}`,children:[o.jsx("h3",{className:"af-palette-cat",children:S}),o.jsx("div",{className:"af-palette-cards",children:ss[S].map(U=>{const X=w1(U.inputs,"input"),Q=w1(U.outputs,"output"),re=Rb(U),ne=Ud(U);return o.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:oe=>mn(oe,U),onClick:()=>mi(U),title:re||U.id,children:[o.jsxs("span",{className:"af-palette-card-head",children:[o.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:y1(S)})}),o.jsxs("span",{className:"af-palette-card-main",children:[o.jsx("span",{className:"af-palette-card-label",children:ne}),ne!==U.id?o.jsx("span",{className:"af-palette-card-id",children:U.id}):null]})]}),re?o.jsx("span",{className:"af-palette-card-desc",children:re}):null,o.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[X.list.length," IN"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[X.shown.map((oe,he)=>o.jsxs("span",{className:"af-palette-card-port",title:x1("input",oe,he),children:[o.jsx("span",{className:"af-palette-card-port-dot",style:{background:nr(oe==null?void 0:oe.type)}}),o.jsx("span",{className:"af-palette-card-port-name",children:Rx(oe,he)})]},`in-${he}`)),X.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",X.hidden]}):null]})]}),o.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[o.jsxs("span",{className:"af-palette-card-port-count",children:[Q.list.length," OUT"]}),o.jsxs("span",{className:"af-palette-card-port-list",children:[Q.shown.map((oe,he)=>o.jsxs("span",{className:"af-palette-card-port",title:x1("output",oe,he),children:[o.jsx("span",{className:"af-palette-card-port-name",children:Rx(oe,he)}),o.jsx("span",{className:"af-palette-card-port-dot",style:{background:nr(oe==null?void 0:oe.type)}})]},`out-${he}`)),Q.hidden>0?o.jsxs("span",{className:"af-palette-card-port-more",children:["+",Q.hidden]}):null]})]})]})]},U.id)})})]},S):null}),V.length>0&&de.trim()&&Fc.every(S=>{var A;return!((A=ss[S])!=null&&A.length)})?o.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}),o.jsxs("main",{className:"af-workspace-canvas",children:[o.jsx(t0,{className:"af-flow-canvas af-workspace-flow"+(Ju==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(ut?" af-workspace-flow--display-mode":""),nodes:Tp,edges:Rp,nodeTypes:Oq,onNodesChange:Fp,onEdgesChange:Al,onConnect:ut?void 0:Nc,onConnectStart:ut?void 0:lo,onConnectEnd:ut?void 0:Ea,isValidConnection:ut?void 0:Ri,onNodeClick:(S,A)=>{if(ut){F([Ox(A.id)]);return}cr&&Xn(A.id)},onNodeDoubleClick:(S,A)=>{S.preventDefault(),!ut&&(Mo(!1),m(U=>U.map(X=>({...X,selected:X.id===A.id}))),b(U=>U.map(X=>({...X,selected:!1}))),Xn(A.id))},onPaneClick:()=>{ut?F([]):Xn("")},onDrop:ut?void 0:Us,onDragOver:ut?void 0:Ko,nodesDraggable:ut?!0:Le,nodesConnectable:ut?!1:Le,edgesReconnectable:ut?!1:Le,deleteKeyCode:ut?null:Le?["Backspace","Delete"]:null,selectionOnDrag:Ju==="select",panOnDrag:Ju==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:o.jsx(r0,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!ut&&I?(()=>{var X;const S=String(I.query||"").trim().toLowerCase(),A=S?I.candidates.filter(Q=>{var re,ne,oe;return[(re=Q.def)==null?void 0:re.id,Q.displayLabel,Q.description,(ne=Q.slot)==null?void 0:ne.name,(oe=Q.slot)==null?void 0:oe.type].filter(Boolean).some(he=>String(he).toLowerCase().includes(S))}):I.candidates,U=I.draft.handleType==="source"?"IN":"OUT";return o.jsxs("div",{className:"af-connect-node-menu",style:{left:I.left,top:I.top},role:"dialog","aria-label":"选择匹配节点",children:[o.jsxs("div",{className:"af-connect-node-menu__head",children:[o.jsxs("div",{className:"af-connect-node-menu__title",children:[o.jsx("span",{className:"af-connect-node-menu__dot",style:{background:nr((X=I.draft.slot)==null?void 0:X.type)},"aria-hidden":!0}),o.jsxs("span",{children:["匹配 ",I.draft.slotType," 节点"]})]}),o.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>z(null),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("label",{className:"af-connect-node-menu__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:I.query,onChange:Q=>z(re=>re&&{...re,query:Q.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),o.jsxs("div",{className:"af-connect-node-menu__list",children:[A.map(Q=>{var oe,he;const re=Q.displayLabel||((oe=Q.def)==null?void 0:oe.id),ne=Rx(Q.slot,Q.slotIndex);return o.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>cd(Q),title:Q.description||Q.def.id,children:[o.jsxs("span",{className:"af-connect-node-menu__item-main",children:[o.jsx("span",{className:"af-connect-node-menu__item-label",children:re}),re!==Q.def.id?o.jsx("span",{className:"af-connect-node-menu__item-id",children:Q.def.id}):null]}),o.jsxs("span",{className:"af-connect-node-menu__port",children:[o.jsx("span",{children:U}),o.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:nr((he=Q.slot)==null?void 0:he.type)},"aria-hidden":!0}),o.jsx("span",{className:"af-connect-node-menu__port-name",children:ne})]})]},`${Q.def.id}-${Q.slotIndex}`)}),A.length===0?o.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!ut&&!Xu?o.jsx("div",{className:"af-workspace-composer af-bottom-composer-stack af-flow-bottom-composer",children:o.jsxs("div",{className:"af-pipeline-composer-inner",children:[o.jsx("button",{type:"button",className:"af-workspace-composer-minimize",onClick:()=>$o(!0),"aria-label":"最小化 AI 输入框",title:"最小化",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"remove"})}),o.jsx("div",{className:"af-composer-selected","aria-label":"Selected workspace nodes",children:Fn.length===0?o.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):Fn.map(S=>{var Q,re;const A=String(((Q=S.data)==null?void 0:Q.label)??S.id),U=(re=S.data)!=null&&re.definitionId?String(S.data.definitionId):"",X=U&&U!==A?`${A} · ${S.id} · ${U}`:`${A} · ${S.id}`;return o.jsxs("div",{className:"af-composer-node-chip",title:X,children:[o.jsx("span",{className:"af-composer-node-chip-kind",children:U||"node"}),o.jsx("span",{className:"af-composer-node-chip-label",children:A}),o.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>Dp(S.id),"aria-label":`取消选择 ${S.id}`,children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},S.id)})}),o.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[o.jsx("div",{className:"af-composer-input-wrap",children:o.jsx("textarea",{className:"af-composer-textarea",value:wa,rows:2,onChange:S=>ml(S.target.value),onKeyDown:S=>{(S.metaKey||S.ctrlKey)&&S.key==="Enter"&&(S.preventDefault(),Tl())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!Le})}),o.jsxs("div",{className:"af-composer-toolbar",children:[o.jsxs("div",{className:"af-composer-skills-field",children:[o.jsxs("button",{ref:or,type:"button",className:"af-composer-skills-button"+(Jn.length>0?" af-composer-skills-button--active":""),disabled:Nr||!Le,"aria-haspopup":"listbox","aria-expanded":rs,onClick:()=>Bs(S=>!S),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),o.jsx("span",{children:Jn.length>0?`Skills ${Jn.length}`:"Skills"})]}),rs&&!Nr?Or.createPortal(o.jsx("div",{ref:xa,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:vp,children:yr.length===0?o.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):o.jsxs(o.Fragment,{children:[Ho.groups.map(S=>{const A=il(S,yr),U=Q_(S,bc,yr),X=dn.has(S.id);return o.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(X?" af-composer-skill-group--collapsed":""),children:[o.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[o.jsxs("label",{className:"af-composer-skill-group-check",children:[o.jsx("input",{type:"checkbox",checked:U==="all",disabled:A.length===0,onChange:Q=>{const re=Q.target.checked;gs(ne=>re?X_(ne,A):J_(ne,A))}}),o.jsxs("span",{className:"af-composer-skill-group-title-main",children:[o.jsx("span",{children:S.name}),S.builtin?o.jsx("em",{children:"built-in"}):null,U==="partial"?o.jsx("em",{children:"partial"}):null]})]}),o.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":X?`展开 ${S.name}`:`收起 ${S.name}`,onClick:()=>{Ur(Q=>{const re=new Set(Q);return re.has(S.id)?re.delete(S.id):re.add(S.id),re})},children:[o.jsx("span",{children:S.skills.length}),o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:X?"expand_more":"expand_less"})]})]}),X?null:o.jsx("div",{className:"af-composer-skill-group-items",children:S.skills.map(Q=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:bc.has(Q.key),onChange:re=>{const ne=re.target.checked;gs(oe=>ne?oe.includes(Q.key)?oe:[...oe,Q.key]:oe.filter(he=>he!==Q.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:Q.name}),Q.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:Q.description}):null]})]},`${S.id}:${Q.key}`))})]},S.id)}),Ho.ungrouped.length>0?o.jsxs("div",{className:"af-composer-skill-group",children:[o.jsxs("div",{className:"af-composer-skill-group-title",children:[o.jsx("span",{children:"Ungrouped"}),o.jsx("span",{children:Ho.ungrouped.length})]}),Ho.ungrouped.map(S=>o.jsxs("label",{className:"af-composer-skill-option",children:[o.jsx("input",{type:"checkbox",checked:bc.has(S.key),onChange:A=>{const U=A.target.checked;gs(X=>U?X.includes(S.key)?X:[...X,S.key]:X.filter(Q=>Q!==S.key))}}),o.jsxs("span",{className:"af-composer-skill-option-main",children:[o.jsx("span",{className:"af-composer-skill-option-title",children:S.name}),S.description?o.jsx("span",{className:"af-composer-skill-option-desc",children:S.description}):null]})]},`ungrouped:${S.key}`))]}):null]})}),document.body):null]}),o.jsx("label",{className:"af-composer-model-field",children:o.jsxs("select",{className:"af-composer-model-select",value:ms,onChange:S=>Lo(S.target.value),"aria-label":"模型",children:[o.jsx("option",{value:"",children:"默认模型"}),oo.map(S=>o.jsx("option",{value:S.value,children:S.label},S.value))]})}),o.jsx("button",{type:"button",className:"af-composer-send"+(wa.trim()&&!Nr?" af-composer-send--active":"")+(Nr?" af-composer-send--stop":""),disabled:Nr||!wa.trim()||!Le,"aria-label":Nr?"Running":"Send",onClick:()=>void Tl(),children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Nr?"sync":"arrow_upward"})})]})]})]})}):ut?null:o.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>$o(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})})]}),!ut&&oi?o.jsx("aside",{className:"af-pipeline-drawer af-pipeline-drawer--wide af-workspace-composer-drawer","aria-label":"Workspace AI Composer",children:o.jsxs("div",{className:"af-composer-sidebar",children:[o.jsxs("div",{className:"af-pipeline-drawer-head",children:[o.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),o.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:()=>Mo(!1),"aria-label":"关闭 AI 对话侧栏",children:o.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),o.jsxs("div",{className:"af-composer-session-tabs",children:[o.jsx("button",{type:"button",className:"af-composer-session-tab"+(xl==="workspace"?" af-composer-session-tab--active":""),onClick:()=>no("workspace"),children:o.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),hc.map(S=>o.jsx("button",{type:"button",className:"af-composer-session-tab"+(xl===S.id?" af-composer-session-tab--active":"")+(S.status==="running"?" af-composer-session-tab--running":""),onClick:()=>no(S.id),title:S.runNodeId||S.label,children:o.jsx("span",{className:"af-composer-session-label",children:S.label})},S.id))]}),o.jsx("div",{className:"af-composer-sidebar-status"+(Bp?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:hy}),o.jsx("div",{className:"af-composer-sidebar-thread",children:o.jsx(Dq,{messages:Li,running:Bp,showRunningIndicator:!rn})})]})}):!ut&&st&&qt?o.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:o.jsx(zT,{draft:st,setDraft:Br,definitionId:String(((dd=qt.data)==null?void 0:dd.definitionId)||qt.id),systemPromptReadonly:String(((fd=qt.data)==null?void 0:fd.description)||""),modelLists:Fs,disabled:!Le,onIdBlur:()=>od(!0),onClose:()=>Xn(""),onPublishToMarketplace:rd,error:ga,ioSlots:{inputs:Array.isArray(st==null?void 0:st.inputs)?st.inputs:[],outputs:Array.isArray(st==null?void 0:st.outputs)?st.outputs:[]}})}):null,o.jsx(LT,{open:ba,onClose:()=>Fo(!1)}),o.jsx(OT,{open:bl,onClose:()=>vl(!1),onJump:Bo,nodes:wc}),o.jsx(TT,{open:u,onClose:()=>d(!1),flowId:i.flowId||"",flowSource:di,onArchived:()=>{d(!1),n("/projects?tab=archived")}}),o.jsx(RT,{open:f&&!!i.flowId,onClose:()=>c(!1),flowId:i.flowId||"",flowSource:di,flowArchived:!!i.archived,onDeleted:async()=>{c(!1),n("/projects")}}),ft?Or.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Je(!1),"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"名称"}),o.jsx("input",{type:"text",value:bt.name,onChange:S=>{const A=S.target.value;Ve(U=>({...U,name:A,id:U.id?U.id:A.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:内容整理片段",autoFocus:!0})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"ID"}),o.jsx("input",{type:"text",value:bt.id,onChange:S=>Ve(A=>({...A,id:S.target.value})),placeholder:"content-cleanup-snippet"})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"说明"}),o.jsx("textarea",{value:bt.description,onChange:S=>Ve(A=>({...A,description:S.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),o.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",Fn.length," 个节点和 ",ao.length," 条内部连线。"]}),pn?o.jsx("div",{className:"af-flow-snippet-error",children:pn}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Je(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:jt||!bt.name.trim(),onClick:()=>void Mp(),children:jt?"发布中...":"发布"})]})]})}),document.body):null,ce?Or.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal",role:"dialog","aria-modal":"true","aria-label":"发布展示页",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"present_to_all"}),"发布展示页"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>ve(!1),"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"标题"}),o.jsx("input",{type:"text",value:Xt.title,onChange:S=>rr(A=>({...A,title:S.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),o.jsxs("label",{className:"af-flow-snippet-field",children:[o.jsx("span",{children:"布局"}),o.jsxs("select",{className:"af-display-share-select",value:Xt.layout,onChange:S=>rr(A=>({...A,layout:S.target.value})),children:[o.jsx("option",{value:"gallery",children:"Gallery"}),o.jsx("option",{value:"document",children:"Document"}),o.jsx("option",{value:"slides",children:"Slides"})]})]}),o.jsx("div",{className:"af-display-share-node-list",role:"group","aria-label":"选择展示节点",children:kn.map(S=>{var U,X;const A=Array.isArray(Xt.nodeIds)&&Xt.nodeIds.includes(S.id);return o.jsxs("label",{className:"af-display-share-node-row",children:[o.jsx("input",{type:"checkbox",checked:A,onChange:()=>Yr(S.id)}),o.jsxs("span",{className:"af-display-share-node-row__main",children:[o.jsx("strong",{children:((U=S.data)==null?void 0:U.label)||S.id}),o.jsxs("small",{children:[Kn((X=S.data)==null?void 0:X.definitionId)," · ",S.id]})]})]},S.id)})}),tt!=null&&tt.absoluteUrl?o.jsxs("div",{className:"af-display-share-result",children:[o.jsx("input",{type:"text",readOnly:!0,value:tt.absoluteUrl,onFocus:S=>S.target.select()}),o.jsx("button",{type:"button",onClick:()=>window.open(tt.absoluteUrl,"_blank","noopener,noreferrer"),children:"打开"}),o.jsx("button",{type:"button",onClick:()=>void Vs(),children:hn==="copied"?"已复制":hn==="failed"?"复制失败":"复制"})]}):null,ot?o.jsx("div",{className:"af-flow-snippet-error",children:ot}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>ve(!1),children:"取消"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:ze||!Array.isArray(Xt.nodeIds)||Xt.nodeIds.length===0,onClick:()=>void $p(),children:ze?"生成中...":"生成链接"})]})]})}),document.body):null,vn?Or.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-link-modal",role:"dialog","aria-modal":"true","aria-label":"展示链接",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"link"}),"展示链接"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>{sr(""),ln(!1)},"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[tt!=null&&tt.absoluteUrl?o.jsxs("div",{className:"af-display-link-modal__url",children:[o.jsx("input",{type:"text",readOnly:!0,value:tt.absoluteUrl,onFocus:S=>S.target.select(),autoFocus:!0}),o.jsxs("button",{type:"button",onClick:()=>window.open(tt.absoluteUrl,"_blank","noopener,noreferrer"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),o.jsxs("button",{type:"button",onClick:()=>void Vs(),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:hn==="copied"?"check":"content_copy"}),hn==="copied"?"已复制":hn==="failed"?"复制失败":"复制"]})]}):o.jsx("div",{className:"af-display-link-modal__empty",children:"还没有生成展示链接"}),ot?o.jsx("div",{className:"af-flow-snippet-error",children:ot}):null]}),o.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>{sr(""),ln(!1)},children:"关闭"}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:ze||w.nodeIds.length===0,onClick:()=>void Ws(),children:ze?"生成中...":tt!=null&&tt.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,xe?Or.createPortal(o.jsx("div",{className:"af-flow-snippet-modal-overlay",children:o.jsxs("div",{className:"af-flow-snippet-modal af-display-picker-modal",role:"dialog","aria-modal":"true","aria-label":"选择展示节点",children:[o.jsxs("div",{className:"af-flow-snippet-modal__head",children:[o.jsxs("span",{className:"af-flow-snippet-modal__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"选择展示节点"]}),o.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Me(!1),"aria-label":"关闭",children:o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.jsxs("div",{className:"af-flow-snippet-modal__body",children:[o.jsxs("label",{className:"af-display-picker-search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{type:"search",value:Ze,onChange:S=>Dt(S.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),o.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":_l.length||1},children:Vo.length>0?_l.map((S,A)=>o.jsx("div",{className:"af-display-picker-column",children:S.map(Lp)},`display-picker-column-${A}`)):o.jsx("div",{className:"af-display-picker-empty",children:Ti.length===0?"当前 Workspace 没有 display 节点":"没有匹配的展示节点"})})]}),o.jsx("div",{className:"af-flow-snippet-modal__foot",children:o.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>Me(!1),children:"完成"})})]})}),document.body):null,!ut&&ie?Or.createPortal(o.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>Pe(!1),children:o.jsxs("div",{className:"af-workspace-quick-add",role:"dialog","aria-modal":"true","aria-label":"Add workspace node",onMouseDown:S=>S.stopPropagation(),children:[o.jsxs("div",{className:"af-workspace-quick-add__tabs",role:"tablist","aria-label":"选择添加类型",children:[o.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:()=>Ft("nodes"),children:"节点"}),o.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:()=>Ft("flows"),children:"流程"})]}),o.jsxs("div",{className:"af-workspace-quick-add__search",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),o.jsx("input",{ref:Gu,value:cn,onChange:S=>ir(S.target.value),onKeyDown:S=>{if(S.key==="Escape")S.preventDefault(),Pe(!1);else if(S.key==="ArrowDown"){S.preventDefault();const A=He==="flows"?Qn.length:qr.length;ns(U=>Math.min(Math.max(0,A-1),U+1))}else S.key==="ArrowUp"?(S.preventDefault(),ns(A=>Math.max(0,A-1))):S.key==="Tab"?(S.preventDefault(),Ft(A=>A==="nodes"?"flows":"nodes")):S.key==="Enter"&&(S.preventDefault(),He==="flows"?Ct(Qn[Ds]||Qn[0]):Il(qr[Ds]||qr[0]))},placeholder:He==="flows"?"搜索流程片段...":"搜索节点...","aria-label":He==="flows"?"搜索流程片段":"搜索节点"})]}),o.jsx("div",{className:"af-workspace-quick-add__list",children:He==="flows"?Qn.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:we?"正在加载流程片段...":Ie||"没有匹配的流程片段"}):Qn.map((S,A)=>{const U=S.displayName||S.name||S.id,X=S.snippet&&typeof S.snippet=="object"?S.snippet.instances:null,Q=S.snippet&&typeof S.snippet=="object"?S.snippet.edges:null,re=Number.isFinite(Number(S.nodeCount))?Number(S.nodeCount):Object.keys(X||{}).length,ne=Number.isFinite(Number(S.edgeCount))?Number(S.edgeCount):Array.isArray(Q)?Q.length:0;return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(A===Ds?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>ns(A),onClick:()=>Ct(S),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:"schema"}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:U}),o.jsxs("span",{className:"af-workspace-quick-add__meta",children:[S.id,S.version?` · v${S.version}`:""]}),o.jsx("span",{className:"af-workspace-quick-add__desc",children:S.description||`${re} 节点 / ${ne} 连线`})]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${S.id}@${S.version}`)}):qr.length===0?o.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):qr.map((S,A)=>{const U=Vd(S),X=Ud(S),Q=Rb(S);return o.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(A===Ds?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>ns(A),onClick:()=>Il(S),children:[o.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:y1(U)}),o.jsxs("span",{className:"af-workspace-quick-add__main",children:[o.jsx("span",{className:"af-workspace-quick-add__label",children:X}),o.jsx("span",{className:"af-workspace-quick-add__meta",children:S.id}),Q?o.jsx("span",{className:"af-workspace-quick-add__desc",children:Q}):null]}),o.jsx("span",{className:"af-workspace-quick-add__cat",children:U})]},S.id)})})]})}),document.body):null]})]})}function Gq(){return o.jsx(Jg,{children:o.jsx(Yq,{})})}function Xq(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(),i=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)||(i?r(i):""))}function Jq(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function fR(e){let t=String(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 i=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);i&&i[1]&&(t=i[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((i,a)=>{const l=a.exec(t);return l?i<0?l.index:Math.min(i,l.index):i},-1);return s>0&&(t=t.slice(s).trim()),t}function Qq(e){const t=fR(e);if(!t.trim())return"";if(/<base\s+[^>]*target\s*=/i.test(t))return t;const n='<base target="_blank">';return/<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 pR(e,t){const n=String(e||"").trim();if(!n)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(n)||n.startsWith("/"))return n;const r=new URLSearchParams;return r.set("id",t),r.set("path",n),`/api/display/file/raw?${r.toString()}`}function Zq(e,t){const n=String(e||"").trim();return n?pR(n,t):""}function eY({className:e="",children:t}){const n=h.useRef(null),r=h.useRef(null),[s,i]=h.useState({visible:!1,top:0,height:100}),a=h.useCallback(()=>{const f=n.current;if(!f)return;const c=Math.max(1,f.scrollHeight),p=Math.max(1,f.clientHeight),m=c>p+1,g=m?Math.max(12,p/c*100):100,b=Math.max(0,100-g),k=m?Math.min(b,f.scrollTop/Math.max(1,c-p)*b):0;i({visible:m,top:k,height:g})},[]);h.useEffect(()=>{const f=requestAnimationFrame(a),c=n.current;if(!c||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(f);const p=new ResizeObserver(a);p.observe(c);for(const m of Array.from(c.children))p.observe(m);return()=>{cancelAnimationFrame(f),p.disconnect()}},[t,a]);const l=h.useCallback(f=>{const c=n.current;if(!c)return;const p=Math.max(0,c.scrollHeight-c.clientHeight);c.scrollTop=Math.min(1,Math.max(0,f))*p,a()},[a]),u=h.useCallback((f,c=0)=>{const p=r.current;if(!p)return 0;const m=p.getBoundingClientRect(),g=s.height/100*m.height,b=Math.max(1,m.height-g);return(f-m.top-c)/b},[s.height]),d=h.useCallback(f=>{if(!s.visible)return;f.preventDefault(),f.stopPropagation();const c=r.current;if(!c)return;const p=c.getBoundingClientRect(),m=s.top/100*p.height,g=s.height/100*p.height,k=f.clientY>=p.top+m&&f.clientY<=p.top+m+g?f.clientY-p.top-m:g/2;l(u(f.clientY,k));const y=w=>{w.preventDefault(),l(u(w.clientY,k))},v=()=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",v),window.removeEventListener("pointercancel",v)};window.addEventListener("pointermove",y),window.addEventListener("pointerup",v),window.addEventListener("pointercancel",v)},[u,l,s.height,s.top,s.visible]);return o.jsxs("div",{className:`af-public-display-node__body ${e} nowheel nopan nodrag`,children:[o.jsx("div",{ref:n,className:`af-public-display-node__scroller ${e} nowheel nopan nodrag`,onScroll:a,children:t}),o.jsx("div",{ref:r,className:"af-public-display-scrollbar"+(s.visible?" af-public-display-scrollbar--visible":""),onPointerDown:d,"aria-hidden":"true",children:o.jsx("span",{style:{height:`${s.height}%`,top:`${s.top}%`}})})]})}function tY({node:e,shareId:t,style:n}){const r=Xq(e),s=e.kind==="html"?fR(r):r,i=`af-public-display-node__body--${e.kind||"unknown"}`;return o.jsxs("section",{className:`af-public-display-node af-public-display-node--${e.kind||"unknown"}`,style:n,children:[o.jsx("div",{className:"af-public-display-node__head",children:o.jsxs("div",{className:"af-public-display-node__title",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Jq(e.kind)}),o.jsx("strong",{children:e.label||e.id}),o.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),o.jsx(eY,{className:i,children:s.trim()?o.jsxs(o.Fragment,{children:[e.kind==="html"?o.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:Qq(s)}):null,e.kind==="image"?o.jsx("img",{src:pR(s,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?o.jsx("div",{className:"af-public-display-markdown",children:o.jsx(E0,{content:s,resolveSrc:a=>Zq(a,t)})}):null,e.kind==="chart"?o.jsx(P0,{content:s}):null,e.kind==="table"?o.jsx(_0,{content:s}):null,e.kind==="mermaid"||e.kind==="ascii"?o.jsx("pre",{children:s}):null]}):o.jsx("div",{className:"af-public-display-empty",children:"No display content"})})]})}function nY({data:e}){return o.jsx(tY,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const rY={publicDisplay:nY};function sY(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 hR(){var a;const{path:e}=Io(),t=h.useMemo(()=>sY(e),[e]),[n,r]=h.useState({loading:!0,error:"",share:null,nodes:[]});h.useEffect(()=>{let l=!1;async function u(){if(!t){r({loading:!1,error:"Missing display share id",share:null,nodes:[]});return}r(d=>({...d,loading:!0,error:""}));try{const d=await fetch(`/api/display/share?id=${encodeURIComponent(t)}`),f=await d.json().catch(()=>({}));if(!d.ok)throw new Error(f.error||"展示页不存在");l||r({loading:!1,error:"",share:f.share||null,nodes:Array.isArray(f.nodes)?f.nodes:[]})}catch(d){l||r({loading:!1,error:String((d==null?void 0:d.message)||d),share:null,nodes:[]})}}return u(),()=>{l=!0}},[t]);const s=h.useMemo(()=>(Array.isArray(n.nodes)?n.nodes:[]).map((u,d)=>{const f=u.position&&typeof u.position.x=="number"&&typeof u.position.y=="number"?u.position:{x:120+d*40,y:100+d*32},c=u.size&&typeof u.size.width=="number"&&typeof u.size.height=="number"?u.size:{width:520,height:320};return{id:u.id,type:"publicDisplay",position:f,data:{node:u,shareId:t},selectable:!1,draggable:!1,style:{width:Math.max(1,Number(c.width)||520),height:Math.max(1,Number(c.height)||320)}}}),[t,n.nodes]),i=h.useMemo(()=>{var c;const l=(c=n.share)==null?void 0:c.viewport;if(!l||typeof l!="object")return null;const u=Number(l.x),d=Number(l.y),f=Number(l.zoom);return!Number.isFinite(u)||!Number.isFinite(d)||!Number.isFinite(f)?null:{x:u,y:d,zoom:Math.min(Math.max(f,.1),4)}},[(a=n.share)==null?void 0:a.viewport]);return n.loading?o.jsx("main",{className:"af-public-display-page",children:o.jsx("div",{className:"af-public-display-status",children:"Loading..."})}):n.error?o.jsx("main",{className:"af-public-display-page",children:o.jsxs("div",{className:"af-public-display-status af-public-display-status--error",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"error"}),o.jsx("span",{children:n.error})]})}):o.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:o.jsx(Jg,{children:o.jsx(t0,{className:"af-public-display-flow",nodes:s,edges:[],nodeTypes:rY,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!0,noPanClassName:"nopan",noDragClassName:"nodrag",noWheelClassName:"nowheel",panOnScroll:!0,zoomOnScroll:!0,zoomOnPinch:!0,defaultViewport:i||void 0,fitView:!i,fitViewOptions:{padding:.18,duration:180},minZoom:.1,maxZoom:4,proOptions:{hideAttribution:!0},children:o.jsx(r0,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const St=e=>typeof e=="string",Td=()=>{let e,t;const n=new Promise((r,s)=>{e=r,t=s});return n.resolve=e,n.reject=t,n},E1=e=>e==null?"":""+e,iY=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},oY=/###/g,_1=e=>e&&e.indexOf("###")>-1?e.replace(oY,"."):e,P1=e=>!e||St(e),df=(e,t,n)=>{const r=St(t)?t.split("."):t;let s=0;for(;s<r.length-1;){if(P1(e))return{};const i=_1(r[s]);!e[i]&&n&&(e[i]=new n),Object.prototype.hasOwnProperty.call(e,i)?e=e[i]:e={},++s}return P1(e)?{}:{obj:e,k:_1(r[s])}},A1=(e,t,n)=>{const{obj:r,k:s}=df(e,t,Object);if(r!==void 0||t.length===1){r[s]=n;return}let i=t[t.length-1],a=t.slice(0,t.length-1),l=df(e,a,Object);for(;l.obj===void 0&&a.length;)i=`${a[a.length-1]}.${i}`,a=a.slice(0,a.length-1),l=df(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${i}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${i}`]=n},aY=(e,t,n,r)=>{const{obj:s,k:i}=df(e,t,Object);s[i]=s[i]||[],s[i].push(n)},pg=(e,t)=>{const{obj:n,k:r}=df(e,t);if(n)return n[r]},lY=(e,t,n)=>{const r=pg(e,n);return r!==void 0?r:pg(t,n)},mR=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?St(e[r])||e[r]instanceof String||St(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):mR(e[r],t[r],n):e[r]=t[r]);return e},Mc=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var cY={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#39;","/":"&#x2F;"};const uY=e=>St(e)?e.replace(/[&<>"'\/]/g,t=>cY[t]):e;class dY{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 fY=[" ",",","?","!",";"],pY=new dY(20),hY=(e,t,n)=>{t=t||"",n=n||"";const r=fY.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const s=pY.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let i=!s.test(e);if(!i){const a=e.indexOf(n);a>0&&!s.test(e.substring(0,a))&&(i=!0)}return i},Ob=function(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:".";if(!e)return;if(e[t])return e[t];const r=t.split(n);let s=e;for(let i=0;i<r.length;){if(!s||typeof s!="object")return;let a,l="";for(let u=i;u<r.length;++u)if(u!==i&&(l+=n),l+=r[u],a=s[l],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&u<r.length-1)continue;i+=u-i+1;break}s=a}return s},hg=e=>e&&e.replace("_","-"),mY={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 mg{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||mY,this.options=n,this.debug=n.debug}log(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"log","",!0)}warn(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","",!0)}error(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"error","")}deprecate(){for(var t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return this.forward(n,"warn","WARNING DEPRECATED: ",!0)}forward(t,n,r,s){return s&&!this.debug?null:(St(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new mg(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new mg(this.logger,t)}}var ko=new mg;class sy{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,u]=a;for(let d=0;d<u;d++)l(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[l,u]=a;for(let d=0;d<u;d++)l.apply(l,[t,...r])})}}class I1 extends sy{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 i=s.keySeparator!==void 0?s.keySeparator:this.options.keySeparator,a=s.ignoreJSONStructure!==void 0?s.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.indexOf(".")>-1?l=t.split("."):(l=[t,n],r&&(Array.isArray(r)?l.push(...r):St(r)&&i?l.push(...r.split(i)):l.push(r)));const u=pg(this.data,l);return!u&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),u||!a||!St(r)?u:Ob(this.data&&this.data[t]&&this.data[t][n],r,i)}addResource(t,n,r,s){let i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=i.keySeparator!==void 0?i.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),A1(this.data,l,s),i.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 i in r)(St(r[i])||Array.isArray(r[i]))&&this.addResource(t,n,i,r[i],{silent:!0});s.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,s,i){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 u=pg(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),s?mR(u,r,i):u={...u,...r},A1(this.data,l,u),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 gR={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,s){return e.forEach(i=>{this.processors[i]&&(t=this.processors[i].process(t,n,r,s))}),t}};const T1={};class gg extends sy{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),iY(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=ko.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 i=n.ns||this.options.defaultNS||[];const a=r&&t.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!hY(t,r,s);if(a&&!l){const u=t.match(this.interpolator.nestingRegexp);if(u&&u.length>0)return{key:t,namespaces:St(i)?[i]:i};const d=t.split(r);(r!==s||r===s&&this.options.ns.indexOf(d[0])>-1)&&(i=d.shift()),t=d.join(s)}return{key:t,namespaces:St(i)?[i]:i}}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,i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(t[t.length-1],n),u=l[l.length-1],d=n.lng||this.language,f=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(d&&d.toLowerCase()==="cimode"){if(f){const j=n.nsSeparator||this.options.nsSeparator;return s?{res:`${u}${j}${a}`,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:u,usedParams:this.getUsedParamsDetails(n)}:`${u}${j}${a}`}return s?{res:a,usedKey:a,exactUsedKey:a,usedLng:d,usedNS:u,usedParams:this.getUsedParamsDetails(n)}:a}const c=this.resolve(t,n);let p=c&&c.res;const m=c&&c.usedKey||a,g=c&&c.exactUsedKey||a,b=Object.prototype.toString.apply(p),k=["[object Number]","[object Function]","[object RegExp]"],y=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,v=!this.i18nFormat||this.i18nFormat.handleAsObject,w=!St(p)&&typeof p!="boolean"&&typeof p!="number";if(v&&p&&w&&k.indexOf(b)<0&&!(St(y)&&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(m,p,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return s?(c.res=j,c.usedParams=this.getUsedParamsDetails(n),c):j}if(i){const j=Array.isArray(p),P=j?[]:{},_=j?g:m;for(const L in p)if(Object.prototype.hasOwnProperty.call(p,L)){const B=`${_}${i}${L}`;P[L]=this.translate(B,{...n,joinArrays:!1,ns:l}),P[L]===B&&(P[L]=p[L])}p=P}}else if(v&&St(y)&&Array.isArray(p))p=p.join(y),p&&(p=this.extendTranslation(p,t,n,r));else{let j=!1,P=!1;const _=n.count!==void 0&&!St(n.count),L=gg.hasDefaultValue(n),B=_?this.pluralResolver.getSuffix(d,n.count,n):"",D=n.ordinal&&_?this.pluralResolver.getSuffix(d,n.count,{ordinal:!1}):"",F=_&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),R=F&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${B}`]||n[`defaultValue${D}`]||n.defaultValue;!this.isValidLookup(p)&&L&&(j=!0,p=R),this.isValidLookup(p)||(P=!0,p=a);const W=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&P?void 0:p,O=L&&R!==p&&this.options.updateMissing;if(P||j||O){if(this.logger.log(O?"updateKey":"missingKey",d,u,a,O?R:p),i){const C=this.resolve(a,{...n,keySeparator:!1});C&&C.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 $=[];const I=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&I&&I[0])for(let C=0;C<I.length;C++)$.push(I[C]);else this.options.saveMissingTo==="all"?$=this.languageUtils.toResolveHierarchy(n.lng||this.language):$.push(n.lng||this.language);const z=(C,T,E)=>{const G=L&&E!==p?E:W;this.options.missingKeyHandler?this.options.missingKeyHandler(C,u,T,G,O,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(C,u,T,G,O,n),this.emit("missingKey",C,u,T,p)};this.options.saveMissing&&(this.options.saveMissingPlurals&&_?$.forEach(C=>{const T=this.pluralResolver.getSuffixes(C,n);F&&n[`defaultValue${this.options.pluralSeparator}zero`]&&T.indexOf(`${this.options.pluralSeparator}zero`)<0&&T.push(`${this.options.pluralSeparator}zero`),T.forEach(E=>{z([C],a+E,n[`defaultValue${E}`]||R)})}):z($,a,R))}p=this.extendTranslation(p,t,n,c,r),P&&p===a&&this.options.appendNamespaceToMissingKey&&(p=`${u}:${a}`),(P||j)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?p=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${u}:${a}`:a,j?p:void 0):p=this.options.parseMissingKeyHandler(p))}return s?(c.res=p,c.usedParams=this.getUsedParamsDetails(n),c):p}extendTranslation(t,n,r,s,i){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||s.usedLng,s.usedNS,s.usedKey,{resolved:s});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const d=St(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(d){const p=t.match(this.interpolator.nestingRegexp);f=p&&p.length}let c=r.replace&&!St(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(c={...this.options.interpolation.defaultVariables,...c}),t=this.interpolator.interpolate(t,c,r.lng||this.language||s.usedLng,r),d){const p=t.match(this.interpolator.nestingRegexp),m=p&&p.length;f<m&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&s&&s.res&&(r.lng=this.language||s.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var p=arguments.length,m=new Array(p),g=0;g<p;g++)m[g]=arguments[g];return i&&i[0]===m[0]&&!r.context?(a.logger.warn(`It seems you are nesting recursively key: ${m[0]} in key: ${n[0]}`),null):a.translate(...m,n)},r)),r.interpolation&&this.interpolator.reset()}const l=r.postProcess||this.options.postProcess,u=St(l)?[l]:l;return t!=null&&u&&u.length&&r.applyPostProcessor!==!1&&(t=gR.handle(u,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,i,a,l;return St(t)&&(t=[t]),t.forEach(u=>{if(this.isValidLookup(r))return;const d=this.extractFromKey(u,n),f=d.key;s=f;let c=d.namespaces;this.options.fallbackNS&&(c=c.concat(this.options.fallbackNS));const p=n.count!==void 0&&!St(n.count),m=p&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),g=n.context!==void 0&&(St(n.context)||typeof n.context=="number")&&n.context!=="",b=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);c.forEach(k=>{this.isValidLookup(r)||(l=k,!T1[`${b[0]}-${k}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(T1[`${b[0]}-${k}`]=!0,this.logger.warn(`key "${s}" for languages "${b.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!!!")),b.forEach(y=>{if(this.isValidLookup(r))return;a=y;const v=[f];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(v,f,y,k,n);else{let j;p&&(j=this.pluralResolver.getSuffix(y,n.count,n));const P=`${this.options.pluralSeparator}zero`,_=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(p&&(v.push(f+j),n.ordinal&&j.indexOf(_)===0&&v.push(f+j.replace(_,this.options.pluralSeparator)),m&&v.push(f+P)),g){const L=`${f}${this.options.contextSeparator}${n.context}`;v.push(L),p&&(v.push(L+j),n.ordinal&&j.indexOf(_)===0&&v.push(L+j.replace(_,this.options.pluralSeparator)),m&&v.push(L+P))}}let w;for(;w=v.pop();)this.isValidLookup(r)||(i=w,r=this.getResource(y,k,w,n))}))})}),{res:r,usedKey:s,exactUsedKey:i,usedLng:a,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,n,r,s):this.resourceStore.getResource(t,n,r,s)}getUsedParamsDetails(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};const n=["defaultValue","ordinal","context","replace","lng","lngs","fallbackLng","ns","keySeparator","nsSeparator","returnObjects","returnDetails","joinArrays","postProcess","interpolation"],r=t.replace&&!St(t.replace);let s=r?t.replace:t;if(r&&typeof t.count<"u"&&(s.count=t.count),this.options.interpolation.defaultVariables&&(s={...this.options.interpolation.defaultVariables,...s}),!r){s={...s};for(const i of n)delete s[i]}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 Mx=e=>e.charAt(0).toUpperCase()+e.slice(1);class R1{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=ko.create("languageUtils")}getScriptPartFromCode(t){if(t=hg(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=hg(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(St(t)&&t.indexOf("-")>-1){if(typeof Intl<"u"&&typeof Intl.getCanonicalLocales<"u")try{let s=Intl.getCanonicalLocales(t)[0];if(s&&this.options.lowerCaseLng&&(s=s.toLowerCase()),s)return s}catch{}const n=["hans","hant","latn","cyrl","cans","mong","arab"];let r=t.split("-");return this.options.lowerCaseLng?r=r.map(s=>s.toLowerCase()):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=Mx(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]=Mx(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Mx(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(i=>{if(i===s)return i;if(!(i.indexOf("-")<0&&s.indexOf("-")<0)&&(i.indexOf("-")>0&&s.indexOf("-")<0&&i.substring(0,i.indexOf("-"))===s||i.indexOf(s)===0&&s.length>1))return i})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),St(t)&&(t=[t]),Array.isArray(t))return t;if(!n)return t.default||[];let r=t[n];return r||(r=t[this.getScriptPartFromCode(n)]),r||(r=t[this.formatLanguageCode(n)]),r||(r=t[this.getLanguagePartFromCode(n)]),r||(r=t.default),r||[]}toResolveHierarchy(t,n){const r=this.getFallbackCodes(n||this.options.fallbackLng||[],t),s=[],i=a=>{a&&(this.isSupportedCode(a)?s.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return St(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&i(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&i(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&i(this.getLanguagePartFromCode(t))):St(t)&&i(this.formatLanguageCode(t)),r.forEach(a=>{s.indexOf(a)<0&&i(this.formatLanguageCode(a))}),s}}let gY=[{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}],yY={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 xY=["v1","v2","v3"],wY=["v4"],L1={zero:0,one:1,two:2,few:3,many:4,other:5},bY=()=>{const e={};return gY.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:yY[t.fc]}})}),e};class vY{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=ko.create("pluralResolver"),(!this.options.compatibilityJSON||wY.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=bY(),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=hg(t==="dev"?"en":t),s=n.ordinal?"ordinal":"cardinal",i=JSON.stringify({cleanedCode:r,type:s});if(i in this.pluralRulesCache)return this.pluralRulesCache[i];let a;try{a=new Intl.PluralRules(r,{type:s})}catch{if(!t.match(/-|_/))return;const u=this.languageUtils.getLanguagePartFromCode(t);a=this.getRule(u,n)}return this.pluralRulesCache[i]=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,i)=>L1[s]-L1[i]).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 i=()=>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()}`:i():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?i():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!xY.includes(this.options.compatibilityJSON)}}const O1=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,i=lY(e,t,n);return!i&&s&&St(n)&&(i=Ob(e,n,r),i===void 0&&(i=Ob(t,n,r))),i},$x=e=>e.replace(/\$/g,"$$$$");class kY{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=ko.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:i,prefixEscaped:a,suffix:l,suffixEscaped:u,formatSeparator:d,unescapeSuffix:f,unescapePrefix:c,nestingPrefix:p,nestingPrefixEscaped:m,nestingSuffix:g,nestingSuffixEscaped:b,nestingOptionsSeparator:k,maxReplaces:y,alwaysFormat:v}=t.interpolation;this.escape=n!==void 0?n:uY,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=s!==void 0?s:!1,this.prefix=i?Mc(i):a||"{{",this.suffix=l?Mc(l):u||"}}",this.formatSeparator=d||",",this.unescapePrefix=f?"":c||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=p?Mc(p):m||Mc("$t("),this.nestingSuffix=g?Mc(g):b||Mc(")"),this.nestingOptionsSeparator=k||",",this.maxReplaces=y||1e3,this.alwaysFormat=v!==void 0?v:!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 i,a,l;const u=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},d=m=>{if(m.indexOf(this.formatSeparator)<0){const y=O1(n,u,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(y,void 0,r,{...s,...n,interpolationkey:m}):y}const g=m.split(this.formatSeparator),b=g.shift().trim(),k=g.join(this.formatSeparator).trim();return this.format(O1(n,u,b,this.options.keySeparator,this.options.ignoreJSONStructure),k,r,{...s,...n,interpolationkey:b})};this.resetRegExp();const f=s&&s.missingInterpolationHandler||this.options.missingInterpolationHandler,c=s&&s.interpolation&&s.interpolation.skipOnVariables!==void 0?s.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>$x(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?$x(this.escape(m)):$x(m)}].forEach(m=>{for(l=0;i=m.regex.exec(t);){const g=i[1].trim();if(a=d(g),a===void 0)if(typeof f=="function"){const k=f(t,i,s);a=St(k)?k:""}else if(s&&Object.prototype.hasOwnProperty.call(s,g))a="";else if(c){a=i[0];continue}else this.logger.warn(`missed to pass in variable ${g} for interpolating ${t}`),a="";else!St(a)&&!this.useRawValueToEscape&&(a=E1(a));const b=m.safeValue(a);if(t=t.replace(i[0],b),c?(m.regex.lastIndex+=a.length,m.regex.lastIndex-=i[0].length):m.regex.lastIndex=0,l++,l>=this.maxReplaces)break}}),t}nest(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s,i,a;const l=(u,d)=>{const f=this.nestingOptionsSeparator;if(u.indexOf(f)<0)return u;const c=u.split(new RegExp(`${f}[ ]*{`));let p=`{${c[1]}`;u=c[0],p=this.interpolate(p,a);const m=p.match(/'/g),g=p.match(/"/g);(m&&m.length%2===0&&!g||g.length%2!==0)&&(p=p.replace(/'/g,'"'));try{a=JSON.parse(p),d&&(a={...d,...a})}catch(b){return this.logger.warn(`failed parsing options string in nesting for key ${u}`,b),`${u}${f}${p}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,u};for(;s=this.nestingRegexp.exec(t);){let u=[];a={...r},a=a.replace&&!St(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let d=!1;if(s[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(s[1])){const f=s[1].split(this.formatSeparator).map(c=>c.trim());s[1]=f.shift(),u=f,d=!0}if(i=n(l.call(this,s[1].trim(),a),a),i&&s[0]===t&&!St(i))return i;St(i)||(i=E1(i)),i||(this.logger.warn(`missed to resolve ${s[1]} for nesting ${t}`),i=""),d&&(i=u.reduce((f,c)=>this.format(f,c,r.lng,{...r,interpolationkey:s[1].trim()}),i.trim())),t=t.replace(s[0],i),this.regexp.lastIndex=0}return t}}const SY=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,...u]=a.split(":"),d=u.join(":").trim().replace(/^'+|'+$/g,""),f=l.trim();n[f]||(n[f]=d),d==="false"&&(n[f]=!1),d==="true"&&(n[f]=!0),isNaN(d)||(n[f]=parseInt(d,10))}})}return{formatName:t,formatOptions:n}},$c=e=>{const t={};return(n,r,s)=>{let i=s;s&&s.interpolationkey&&s.formatParams&&s.formatParams[s.interpolationkey]&&s[s.interpolationkey]&&(i={...i,[s.interpolationkey]:void 0});const a=r+JSON.stringify(i);let l=t[a];return l||(l=e(hg(r),s),t[a]=l),l(n)}};class NY{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=ko.create("formatter"),this.options=t,this.formats={number:$c((n,r)=>{const s=new Intl.NumberFormat(n,{...r});return i=>s.format(i)}),currency:$c((n,r)=>{const s=new Intl.NumberFormat(n,{...r,style:"currency"});return i=>s.format(i)}),datetime:$c((n,r)=>{const s=new Intl.DateTimeFormat(n,{...r});return i=>s.format(i)}),relativetime:$c((n,r)=>{const s=new Intl.RelativeTimeFormat(n,{...r});return i=>s.format(i,r.range||"day")}),list:$c((n,r)=>{const s=new Intl.ListFormat(n,{...r});return i=>s.format(i)})},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()]=$c(n)}format(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const i=n.split(this.formatSeparator);if(i.length>1&&i[0].indexOf("(")>1&&i[0].indexOf(")")<0&&i.find(l=>l.indexOf(")")>-1)){const l=i.findIndex(u=>u.indexOf(")")>-1);i[0]=[i[0],...i.splice(1,l)].join(this.formatSeparator)}return i.reduce((l,u)=>{const{formatName:d,formatOptions:f}=SY(u);if(this.formats[d]){let c=l;try{const p=s&&s.formatParams&&s.formatParams[s.interpolationkey]||{},m=p.locale||p.lng||s.locale||s.lng||r;c=this.formats[d](l,m,{...f,...s,...p})}catch(p){this.logger.warn(p)}return c}else this.logger.warn(`there was no format function for ${d}`);return l},t)}}const jY=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class CY extends sy{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=ko.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 i={},a={},l={},u={};return t.forEach(d=>{let f=!0;n.forEach(c=>{const p=`${d}|${c}`;!r.reload&&this.store.hasResourceBundle(d,c)?this.state[p]=2:this.state[p]<0||(this.state[p]===1?a[p]===void 0&&(a[p]=!0):(this.state[p]=1,f=!1,a[p]===void 0&&(a[p]=!0),i[p]===void 0&&(i[p]=!0),u[c]===void 0&&(u[c]=!0)))}),f||(l[d]=!0)}),(Object.keys(i).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:s}),{toLoad:Object.keys(i),pending:Object.keys(a),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(u)}}loaded(t,n,r){const s=t.split("|"),i=s[0],a=s[1];n&&this.emit("failedLoading",i,a,n),!n&&r&&this.store.addResourceBundle(i,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(u=>{aY(u.loaded,[i],a),jY(u,t),n&&u.errors.push(n),u.pendingCount===0&&!u.done&&(Object.keys(u.loaded).forEach(d=>{l[d]||(l[d]={});const f=u.loaded[d];f.length&&f.forEach(c=>{l[d][c]===void 0&&(l[d][c]=!0)})}),u.done=!0,u.errors.length?u.callback(u.errors):u.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(u=>!u.done)}read(t,n,r){let s=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,i=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:i,callback:a});return}this.readingCalls++;const l=(d,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const c=this.waitingReads.shift();this.read(c.lng,c.ns,c.fcName,c.tried,c.wait,c.callback)}if(d&&f&&s<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,s+1,i*2,a)},i);return}a(d,f)},u=this.backend[r].bind(this.backend);if(u.length===2){try{const d=u(t,n);d&&typeof d.then=="function"?d.then(f=>l(null,f)).catch(l):l(null,d)}catch(d){l(d)}return}return u(t,n,l)}prepareLoading(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},s=arguments.length>3?arguments[3]:void 0;if(!this.backend)return this.logger.warn("No backend was added via i18next.use. Will not load resources."),s&&s();St(t)&&(t=this.languageUtils.toResolveHierarchy(t)),St(n)&&(n=[n]);const i=this.queueLoad(t,n,r,s);if(!i.toLoad.length)return i.pending.length||s(),null;i.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],i=r[1];this.read(s,i,"read",void 0,void 0,(a,l)=>{a&&this.logger.warn(`${n}loading namespace ${i} for language ${s} failed`,a),!a&&l&&this.logger.log(`${n}loaded namespace ${i} for language ${s}`,l),this.loaded(t,a,l)})}saveMissing(t,n,r,s,i){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 u={...a,isUpdate:i},d=this.backend.create.bind(this.backend);if(d.length<6)try{let f;d.length===5?f=d(t,n,r,s,u):f=d(t,n,r,s),f&&typeof f.then=="function"?f.then(c=>l(null,c)).catch(l):l(null,f)}catch(f){l(f)}else d(t,n,r,s,l,u)}!t||!t[0]||this.store.addResource(t[0],n,r,s)}}}const M1=()=>({debug:!1,initImmediate:!0,ns:["translation"],defaultNS:["translation"],fallbackLng:["dev"],fallbackNS:!1,supportedLngs:!1,nonExplicitSupportedLngs:!1,load:"all",preload:!1,simplifyPluralSuffix:!0,keySeparator:".",nsSeparator:":",pluralSeparator:"_",contextSeparator:"_",partialBundledLanguages:!1,saveMissing:!1,updateMissing:!1,saveMissingTo:"fallback",saveMissingPlurals:!0,missingKeyHandler:!1,missingInterpolationHandler:!1,postProcess:!1,postProcessPassResolved:!1,returnNull:!1,returnEmptyString:!0,returnObjects:!1,joinArrays:!1,returnedObjectHandler:!1,parseMissingKeyHandler:!1,appendNamespaceToMissingKey:!1,appendNamespaceToCIMode:!1,overloadTranslationOptionHandler:e=>{let t={};if(typeof e[1]=="object"&&(t=e[1]),St(e[1])&&(t.defaultValue=e[1]),St(e[2])&&(t.tDescription=e[2]),typeof e[2]=="object"||typeof e[3]=="object"){const n=e[3]||e[2];Object.keys(n).forEach(r=>{t[r]=n[r]})}return t},interpolation:{escapeValue:!0,format:e=>e,prefix:"{{",suffix:"}}",formatSeparator:",",unescapePrefix:"-",nestingPrefix:"$t(",nestingSuffix:")",nestingOptionsSeparator:",",maxReplaces:1e3,skipOnVariables:!0}}),$1=e=>(St(e.ns)&&(e.ns=[e.ns]),St(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),St(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),Dh=()=>{},EY=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class Yf extends sy{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=$1(t),this.services={},this.logger=ko,this.modules={external:[]},EY(this),n&&!this.isInitialized&&!t.isClone){if(!this.options.initImmediate)return this.init(t,n),this;setTimeout(()=>{this.init(t,n)},0)}}init(){var t=this;let n=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},r=arguments.length>1?arguments[1]:void 0;this.isInitializing=!0,typeof n=="function"&&(r=n,n={}),!n.defaultNS&&n.defaultNS!==!1&&n.ns&&(St(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const s=M1();this.options={...s,...this.options,...$1(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 i=f=>f?typeof f=="function"?new f:f:null;if(!this.options.isClone){this.modules.logger?ko.init(i(this.modules.logger),this.options):ko.init(null,this.options);let f;this.modules.formatter?f=this.modules.formatter:typeof Intl<"u"&&(f=NY);const c=new R1(this.options);this.store=new I1(this.options.resources,this.options);const p=this.services;p.logger=ko,p.resourceStore=this.store,p.languageUtils=c,p.pluralResolver=new vY(c,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),f&&(!this.options.interpolation.format||this.options.interpolation.format===s.interpolation.format)&&(p.formatter=i(f),p.formatter.init(p,this.options),this.options.interpolation.format=p.formatter.format.bind(p.formatter)),p.interpolator=new kY(this.options),p.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},p.backendConnector=new CY(i(this.modules.backend),p.resourceStore,p,this.options),p.backendConnector.on("*",function(m){for(var g=arguments.length,b=new Array(g>1?g-1:0),k=1;k<g;k++)b[k-1]=arguments[k];t.emit(m,...b)}),this.modules.languageDetector&&(p.languageDetector=i(this.modules.languageDetector),p.languageDetector.init&&p.languageDetector.init(p,this.options.detection,this.options)),this.modules.i18nFormat&&(p.i18nFormat=i(this.modules.i18nFormat),p.i18nFormat.init&&p.i18nFormat.init(this)),this.translator=new gg(this.services,this.options),this.translator.on("*",function(m){for(var g=arguments.length,b=new Array(g>1?g-1:0),k=1;k<g;k++)b[k-1]=arguments[k];t.emit(m,...b)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,r||(r=Dh),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const f=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);f.length>0&&f[0]!=="dev"&&(this.options.lng=f[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(f=>{this[f]=function(){return t.store[f](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(f=>{this[f]=function(){return t.store[f](...arguments),t}});const u=Td(),d=()=>{const f=(c,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),u.resolve(p),r(c,p)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return f(null,this.t.bind(this));this.changeLanguage(this.options.lng,f)};return this.options.resources||!this.options.initImmediate?d():setTimeout(d,0),u}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Dh;const s=St(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(s&&s.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const i=[],a=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(d=>{d!=="cimode"&&i.indexOf(d)<0&&i.push(d)})};s?a(s):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(u=>a(u)),this.options.preload&&this.options.preload.forEach(l=>a(l)),this.services.backendConnector.load(i,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(t,n,r){const s=Td();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=Dh),this.services.backendConnector.reload(t,n,i=>{s.resolve(),r(i)}),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"&&gR.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=Td();this.emit("languageChanging",t);const i=u=>{this.language=u,this.languages=this.services.languageUtils.toResolveHierarchy(u),this.resolvedLanguage=void 0,this.setResolvedLanguage(u)},a=(u,d)=>{d?(i(d),this.translator.changeLanguage(d),this.isLanguageChangingTo=void 0,this.emit("languageChanged",d),this.logger.log("languageChanged",d)):this.isLanguageChangingTo=void 0,s.resolve(function(){return r.t(...arguments)}),n&&n(u,function(){return r.t(...arguments)})},l=u=>{!t&&!u&&this.services.languageDetector&&(u=[]);const d=St(u)?u:this.services.languageUtils.getBestMatchFromCodes(u);d&&(this.language||i(d),this.translator.language||this.translator.changeLanguage(d),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(d)),this.loadResources(d,f=>{a(f,d)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),s}getFixedT(t,n,r){var s=this;const i=function(a,l){let u;if(typeof l!="object"){for(var d=arguments.length,f=new Array(d>2?d-2:0),c=2;c<d;c++)f[c-2]=arguments[c];u=s.options.overloadTranslationOptionHandler([a,l].concat(f))}else u={...l};u.lng=u.lng||i.lng,u.lngs=u.lngs||i.lngs,u.ns=u.ns||i.ns,u.keyPrefix!==""&&(u.keyPrefix=u.keyPrefix||r||i.keyPrefix);const p=s.options.keySeparator||".";let m;return u.keyPrefix&&Array.isArray(a)?m=a.map(g=>`${u.keyPrefix}${p}${g}`):m=u.keyPrefix?`${u.keyPrefix}${p}${a}`:a,s.t(m,u)};return St(t)?i.lng=t:i.lngs=t,i.ns=n,i.keyPrefix=r,i}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,i=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,u)=>{const d=this.services.backendConnector.state[`${l}|${u}`];return d===-1||d===0||d===2};if(n.precheck){const l=n.precheck(this,a);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,t)&&(!s||a(i,t)))}loadNamespaces(t,n){const r=Td();return this.options.ns?(St(t)&&(t=[t]),t.forEach(s=>{this.options.ns.indexOf(s)<0&&this.options.ns.push(s)}),this.loadResources(s=>{r.resolve(),n&&n(s)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=Td();St(t)&&(t=[t]);const s=this.options.preload||[],i=t.filter(a=>s.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return i.length?(this.options.preload=s.concat(i),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 R1(M1());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 Yf(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:Dh;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const s={...this.options,...t,isClone:!0},i=new Yf(s);return(t.debug!==void 0||t.prefix!==void 0)&&(i.logger=i.logger.clone(t)),["store","services","language"].forEach(l=>{i[l]=this[l]}),i.services={...this.services},i.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},r&&(i.store=new I1(this.store.data,s),i.services.resourceStore=i.store),i.translator=new gg(i.services,s),i.translator.on("*",function(l){for(var u=arguments.length,d=new Array(u>1?u-1:0),f=1;f<u;f++)d[f-1]=arguments[f];i.emit(l,...d)}),i.init(s,n),i.translator.options=s,i.translator.backendConnector.services.utils={hasLoadedNamespace:i.hasLoadedNamespace.bind(i)},i}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Fr=Yf.createInstance();Fr.createInstance=Yf.createInstance;Fr.createInstance;Fr.dir;Fr.init;Fr.loadResources;Fr.reloadResources;Fr.use;Fr.changeLanguage;Fr.getFixedT;Fr.t;Fr.exists;Fr.setDefaultNamespace;Fr.hasLoadedNamespace;Fr.loadNamespaces;Fr.loadLanguages;function _Y(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function Gf(e){"@babel/helpers - typeof";return Gf=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(t){return typeof t}:function(t){return t&&typeof Symbol=="function"&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Gf(e)}function PY(e,t){if(Gf(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(Gf(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function AY(e){var t=PY(e,"string");return Gf(t)=="symbol"?t:t+""}function IY(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,AY(r.key),r)}}function TY(e,t,n){return t&&IY(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var yR=[],RY=yR.forEach,LY=yR.slice;function OY(e){return RY.call(LY.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var D1=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,MY=function(t,n,r){var s=r||{};s.path=s.path||"/";var i=encodeURIComponent(n),a="".concat(t,"=").concat(i);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(!D1.test(s.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(s.domain)}if(s.path){if(!D1.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 u=typeof s.sameSite=="string"?s.sameSite.toLowerCase():s.sameSite;switch(u){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},F1={create:function(t,n,r,s){var i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(i.expires=new Date,i.expires.setTime(i.expires.getTime()+r*60*1e3)),s&&(i.domain=s),document.cookie=MY(t,encodeURIComponent(n),i)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),s=0;s<r.length;s++){for(var i=r[s];i.charAt(0)===" ";)i=i.substring(1,i.length);if(i.indexOf(n)===0)return i.substring(n.length,i.length)}return null},remove:function(t){this.create(t,"",-1)}},$Y={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=F1.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&F1.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},DY={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),i=s.split("&"),a=0;a<i.length;a++){var l=i[a].indexOf("=");if(l>0){var u=i[a].substring(0,l);u===t.lookupQuerystring&&(n=i[a].substring(l+1))}}}return n}},Rd=null,z1=function(){if(Rd!==null)return Rd;try{Rd=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{Rd=!1}return Rd},FY={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&z1()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&z1()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},Ld=null,B1=function(){if(Ld!==null)return Ld;try{Ld=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{Ld=!1}return Ld},zY={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&B1()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&B1()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},BY={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}},HY={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}},WY={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}},VY={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]}},xR=!1;try{document.cookie,xR=!0}catch{}var wR=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];xR||wR.splice(1,1);function UY(){return{order:wR,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var bR=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};_Y(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return TY(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=OY(r,this.options||{},UY()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(i){return i.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=s,this.addDetector($Y),this.addDetector(DY),this.addDetector(FY),this.addDetector(zY),this.addDetector(BY),this.addDetector(HY),this.addDetector(WY),this.addDetector(VY)}},{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(i){if(r.detectors[i]){var a=r.detectors[i].lookup(r.options);a&&typeof a=="string"&&(a=[a]),a&&(s=s.concat(a))}}),s=s.map(function(i){return r.options.convertDetectedLanguage(i)}),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(i){s.detectors[i]&&s.detectors[i].cacheUserLanguage(n,s.options)}))}}])}();bR.type="languageDetector";const KY={name:"AgentFlow",tagline:"AI Workflow Orchestration"},qY={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},YY={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"},GY={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},XY={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},JY={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},QY={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},ZY={app:KY,nav:qY,common:YY,status:GY,nodeTypes:XY,engine:JY,links:QY},eG="Flow Editor",tG="Nodes",nG="Edges",rG="Properties",sG={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"},iG={title:"Node Properties",noInputPins:"No input pins",noOutputPins:"No output pins",type:"Type",name:"Name",defaultValue:"Default / value",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",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}}"},oG={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},aG={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},lG={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"},cG={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)"},uG={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},dG={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},fG={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},pG={node:"Node",text:"Text",file:"File",bool:"Boolean"},hG={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"},mG={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"},gG={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},yG={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."},xG={mainNav:"Main Navigation"},wG={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'},bG={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):
176
- {{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
177
- 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}}"},vG={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"},kG={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},SG={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}}"},NG={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"},jG={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"},CG={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"},EG={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"},_G={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"},PG={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},AG={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},IG={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"},TG={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."},RG={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},LG={save:"Save",cancel:"Cancel"},OG={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},MG={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},$G={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"},DG={title:eG,nodes:tG,edges:nG,properties:rG,node:sG,nodeProps:iG,actions:oG,panel:aG,palette:lG,pipeline:cG,status:uG,roles:dG,phases:fG,types:pG,runContext:hG,shortcuts:mG,jumpPalette:gG,emptyCanvas:yG,sidebar:xG,validation:wG,composer:bG,topbar:vG,palette2:kG,run:SG,fileEdit:NG,settings:jG,schedule:CG,history:EG,nodePropsError:_G,placeholder:PG,time:AG,userCheck:IG,userAsk:TG,toolPrint:RG,provideEdit:LG,runParams:OG,runPreset:MG,runConfig:$G},FG="Settings",zG={engine:"Engine Settings",preferences:"Global Preferences"},BG={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)."},HG={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..."}},WG={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."},VG={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."},UG={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)"},KG={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"},qG={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models"},YG={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},GG={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},XG={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."},JG={title:FG,crumb:zG,workspace:BG,cursor:HG,opencode:WG,claudeCode:VG,env:UG,allowlist:KG,system:qG,shortcuts:YG,language:GG,onboarding:XG},QG={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},ZG={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)"},eX={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},tX={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},nX={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},rX={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},sX={aiLabels:QG,placeholders:ZG,actions:eX,labels:tX,tooltips:nX,rightPanel:rX},iX="Projects",oX="All",aX="Archived",lX="Nodes",cX="My Nodes",uX="My Flows",dX="Skills",fX="Active Projects",pX="Archived Pipelines",hX="Global Nodes",mX="Manage node versions published to the current workspace marketplace, {{count}} total.",gX="Manage flow snippets published to the current workspace marketplace, {{count}} total.",yX="Global Skills",xX="Create New Project",wX="New Pipeline",bX="SEARCH PIPELINES...",vX="SEARCH NODES...",kX="SEARCH FLOW SNIPPETS...",SX="SEARCH SKILLS...",NX="Refresh Resources",jX="Loading pipelines...",CX="Loading global resources...",EX="Filter result: {{count}} items (matching title, description, path and tags)",_X="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",PX="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",AX="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",IX="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",TX="Executable building blocks for pipeline runtime",RX="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.",LX="Published local node packages",OX="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",MX="Published flow snippets",$X="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",DX="Operating guides for Composer and agents",FX="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",zX="No archived projects.",BX="No active pipelines; archived items are in the Archived tab.",HX="No global nodes available.",WX="No marketplace nodes have been published.",VX="No flow snippets have been published. Select multiple canvas nodes and publish them first.",UX="No skills available.",KX="No description.",qX='No node matches "{{query}}".',YX='No flow snippet matches "{{query}}".',GX='No skill matches "{{query}}".',XX="{{inputs}} in / {{outputs}} out",JX="Flow Snippet",QX="{{nodes}} nodes / {{edges}} edges",ZX="Skill",eJ="Node detail",tJ="Flow snippet detail",nJ="Skill detail",rJ="Type",sJ="Source",iJ="Package",oJ="Version",aJ="Path",lJ="Editable",cJ="Read only",uJ="Editable",dJ="Schema",fJ="Inputs",pJ="Outputs",hJ="Runtime",mJ="Node Body",gJ="Files",yJ="Usage",xJ="No runtime manifest.",wJ="No node body or README.",bJ="No previewable files.",vJ="Select a file to preview.",kJ="Binary file preview is not supported.",SJ="Large file; showing the first 256KB only.",NJ="No pipelines using this node were found.",jJ="Node Management",CJ="Delete Node Version",EJ="Deleting...",_J="AgentFlow checks all flow references before deleting; installed or used versions are kept.",PJ="Delete {{id}}@{{version}}? This cannot be undone.",AJ="Deleted {{id}}@{{version}}.",IJ="{{count}} flow(s) still use it.",TJ="Flow Snippet Management",RJ="Delete Flow Snippet",LJ="Deleting...",OJ="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",MJ="Delete {{id}}@{{version}}? This cannot be undone.",$J="Deleted {{id}}@{{version}}.",DJ="No slots",FJ="Purpose",zJ="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",BJ="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.",HJ="Scale",WJ="Flow Preview",VJ="Edges",UJ="Snippet JSON",KJ="{{count}} more edge(s)",qJ="No previewable nodes.",YJ="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",GJ="SKILL.md Preview",XJ="No preview content available.",JJ="Select a resource to inspect details.",QJ="Failed to load pipeline list.",ZJ="No pipelines in current workspace.",eQ="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.",tQ='No pipelines found matching "{{query}}". Try different keywords or clear the search.',nQ="Recent Activity",rQ="No recent activity",sQ="No recent activity matching the keyword",iQ="Recent Run",oQ="Recent Open",aQ={builtin:"Built-in",workspace:"Workspace",user:"User"},lQ={flow:"Flow",global:"Global",marketplace:"Marketplace"},cQ={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},uQ={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},dQ="Open to edit this pipeline in the node canvas.",fQ={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>"},pQ={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"},hQ={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"},mQ={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"},gQ={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"},yQ={title:iX,all:oX,archived:aX,nodes:lX,myNodes:cX,myFlows:uX,skills:dX,activeProjects:fX,archivedPipelines:pX,globalNodes:hX,myNodesHint:mX,myFlowsHint:gX,globalSkills:yX,createNew:xX,newPipeline:wX,searchPipelines:bX,searchNodes:vX,searchFlows:kX,searchSkills:SX,refreshResources:NX,loadingPipelines:jX,loadingResources:CX,filterResult:EX,archivedHint:_X,activeHint:PX,nodesHint:AX,skillsHint:IX,nodesPurposeTitle:TX,nodesPurposeDesc:RX,myNodesPurposeTitle:LX,myNodesPurposeDesc:OX,myFlowsPurposeTitle:MX,myFlowsPurposeDesc:$X,skillsPurposeTitle:DX,skillsPurposeDesc:FX,noArchived:zX,noActive:BX,noNodes:HX,noMyNodes:WX,noMyFlows:VX,noSkills:UX,noDescription:KX,noNodeMatch:qX,noFlowSnippetMatch:YX,noSkillMatch:GX,nodeSlots:XX,flowSnippet:JX,flowSnippetNodes:QX,skill:ZX,nodeDetail:eJ,flowDetail:tJ,skillDetail:nJ,detailType:rJ,detailSource:sJ,detailPackage:iJ,detailVersion:oJ,detailPath:aJ,detailEditable:lJ,readOnly:cJ,editable:uJ,nodeSchema:dJ,nodeInputs:fJ,nodeOutputs:pJ,nodeRuntime:hJ,nodeBody:mJ,nodeFiles:gJ,nodeUsage:yJ,noRuntimeManifest:xJ,noNodeBody:wJ,noNodeFiles:bJ,selectNodeFile:vJ,binaryFile:kJ,fileTruncated:SJ,noNodeUsage:NJ,myNodeManagement:jJ,deleteMyNode:CJ,deletingMyNode:EJ,deleteMyNodeHint:_J,deleteMyNodeConfirm:PJ,deleteMyNodeSuccess:AJ,deleteMyNodeUsedBy:IJ,myFlowManagement:TJ,deleteMyFlow:RJ,deletingMyFlow:LJ,deleteMyFlowHint:OJ,deleteMyFlowConfirm:MJ,deleteMyFlowSuccess:$J,noSlots:DJ,resourceMeaning:FJ,nodesMeaning:zJ,myFlowsMeaning:BJ,flowSnippetScale:HJ,flowSnippetPreview:WJ,flowSnippetEdges:VJ,flowSnippetJson:UJ,flowSnippetMoreEdges:KJ,noFlowSnippetPreview:qJ,skillsMeaning:YJ,skillPreview:GJ,skillPreviewEmpty:XJ,selectResource:JJ,loadFailed:QJ,noPipelines:ZJ,emptyHint:eQ,noMatch:tQ,recentActivity:nQ,noRecentActivity:rQ,noMatchRecent:sQ,recentRun:iQ,recentOpen:oQ,sourceBadge:aQ,resourceSource:lQ,resourceFilter:cQ,nodeDetailTabs:uQ,defaultCardDesc:dQ,hubCard:fQ,newPipelineModal:pQ,importModal:hQ,deleteModal:mQ,archiveModal:gQ},xQ="Back",wQ="Next",bQ="Skip",vQ="Done",kQ="Start Creating",SQ={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
178
-
179
- Click the button below to create your first pipeline.`,hubIntro:`Don't want to start from scratch?
180
-
181
- Browse ready-made pipelines on AgentFlow Hub — community-shared flows you can install and run in one click.`},NQ={intro:`Now you're in the flow editor.
182
-
183
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
184
-
185
- The left node panel allows you to freely drag, delete, and adjust connections.`,introEmpty:`The canvas is empty. Start creating your flow!
186
-
187
- Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
188
-
189
- The left node panel allows you to freely drag, delete, and adjust connections.`},jQ={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"},CQ={back:xQ,next:wQ,skip:bQ,done:vQ,startCreate:kQ,projects:SQ,flow:NQ,newPipeline:jQ},EQ={name:"AgentFlow",tagline:"AI 工作流编排"},_Q={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},PQ={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},AQ={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},IQ={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},TQ={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},RQ={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},LQ={app:EQ,nav:_Q,common:PQ,status:AQ,nodeTypes:IQ,engine:TQ,links:RQ},OQ="流程编辑器",MQ="节点",$Q="连线",DQ="属性",FQ={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:"编辑内容"},zQ={title:"节点属性",noInputPins:"当前无输入引脚",noOutputPins:"当前无输出引脚",type:"类型",name:"名称",defaultValue:"默认值 / value",required:"必填",showOnNode:"卡片",requiredHint:"标记为必填,用于提示用户该槽位必须提供值或连线",showOnNodeHint:"是否在画布节点卡片旁展示这个引脚名称;关闭后仍可连线",pinRequiredAriaLabel:"{{label}} {{index}} 是否必填",pinShowOnNodeAriaLabel:"{{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}}"},BQ={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},HQ={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},WQ={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},VQ={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},UQ={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},KQ={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},qQ={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},YQ={node:"节点",text:"文本",file:"文件",bool:"布尔"},GQ={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:"等待"},XQ={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},JQ={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},QQ={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},ZQ={mainNav:"主导航"},eZ={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},tZ={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}} 步):
190
- {{summary}}`,step:"步骤 {{current}}/{{total}}: {{description}}",phaseGeneration:`分阶段生成({{count}} 阶段):{{labels}}
191
- 当前:{{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}}"},nZ={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},rZ={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},sZ={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}} 的分支"},iZ={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},oZ={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:"已复制"},aZ={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:"定时配置已保存"},lZ={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},cZ={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},uZ={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},dZ={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},fZ={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},pZ={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},hZ={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},mZ={save:"保存",cancel:"取消"},gZ={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},yZ={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},xZ={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},wZ={title:OQ,nodes:MQ,edges:$Q,properties:DQ,node:FQ,nodeProps:zQ,actions:BQ,panel:HQ,palette:WQ,pipeline:VQ,status:UQ,roles:KQ,phases:qQ,types:YQ,runContext:GQ,shortcuts:XQ,jumpPalette:JQ,emptyCanvas:QQ,sidebar:ZQ,validation:eZ,composer:tZ,topbar:nZ,palette2:rZ,run:sZ,fileEdit:iZ,settings:oZ,schedule:aZ,history:lZ,nodePropsError:cZ,placeholder:uZ,time:dZ,userCheck:fZ,userAsk:pZ,toolPrint:hZ,provideEdit:mZ,runParams:gZ,runPreset:yZ,runConfig:xZ},bZ="设置",vZ={engine:"引擎设置",preferences:"全局首选项"},kZ={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},SZ={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},NZ={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},jZ={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},CZ={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},EZ={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:"添加"},_Z={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型"},PZ={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},AZ={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},IZ={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},TZ={title:bZ,crumb:vZ,workspace:kZ,cursor:SZ,opencode:NZ,claudeCode:jZ,env:CZ,allowlist:EZ,system:_Z,shortcuts:PZ,language:AZ,onboarding:IZ},RZ={thinking:"思考",result:"结果",reply:"回复",error:"错误"},LZ={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},OZ={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},MZ={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},$Z={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},DZ={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},FZ={aiLabels:RZ,placeholders:LZ,actions:OZ,labels:MZ,tooltips:$Z,rightPanel:DZ},zZ="项目",BZ="全部",HZ="已归档",WZ="Nodes",VZ="我的 Nodes",UZ="我的流程",KZ="Skills",qZ="活跃项目",YZ="已归档流水线",GZ="全局 Nodes",XZ="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",JZ="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",QZ="全局 Skills",ZZ="创建新项目",eee="新建流水线",tee="搜索流水线…",nee="搜索 nodes…",ree="搜索流程片段…",see="搜索 skills…",iee="刷新资源",oee="加载流水线列表…",aee="加载全局资源…",lee="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",cee="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",uee="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",dee="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",fee="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",pee="流程运行时的可执行积木",hee="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",mee="已发布的本地节点包",gee="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",yee="已发布的流程片段",xee="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",wee="Composer/Agent 的操作指南",bee="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",vee="暂无归档项目。",kee="暂无未归档流水线;已归档项在 Archived 标签中查看。",See="暂无可用全局 nodes。",Nee="暂无已发布的 marketplace nodes。",jee="暂无已发布的流程片段。可在画布中选中多个节点后发布。",Cee="暂无可用 skills。",Eee="暂无描述。",_ee="未找到与「{{query}}」匹配的 node。",Pee="未找到与「{{query}}」匹配的流程片段。",Aee="未找到与「{{query}}」匹配的 skill。",Iee="{{inputs}} in / {{outputs}} out",Tee="流程片段",Ree="{{nodes}} 节点 / {{edges}} 连线",Lee="Skill",Oee="Node 详情",Mee="流程片段详情",$ee="Skill 详情",Dee="类型",Fee="来源",zee="包",Bee="版本",Hee="路径",Wee="可编辑",Vee="只读",Uee="可编辑",Kee="Schema",qee="输入",Yee="输出",Gee="Runtime",Xee="节点内容",Jee="Files",Qee="Usage",Zee="暂无 runtime manifest。",ete="暂无节点正文或 README。",tte="暂无可预览文件。",nte="请选择文件查看内容。",rte="二进制文件暂不支持预览。",ste="文件较大,仅显示前 256KB。",ite="暂未发现使用此 node 的流水线。",ote="节点管理",ate="删除节点版本",lte="删除中…",cte="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",ute="确定删除 {{id}}@{{version}}?此操作不可撤销。",dte="已删除 {{id}}@{{version}}。",fte="仍有 {{count}} 个 Flow 使用它。",pte="流程片段管理",hte="删除流程片段",mte="删除中…",gte="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",yte="确定删除 {{id}}@{{version}}?此操作不可撤销。",xte="已删除 {{id}}@{{version}}。",wte="无槽位",bte="作用",vte="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",kte="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",Ste="规模",Nte="流程预览",jte="连线",Cte="片段 JSON",Ete="还有 {{count}} 条连线",_te="暂无可预览节点。",Pte="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",Ate="SKILL.md 预览",Ite="暂无可预览内容。",Tte="请选择一个资源查看详情。",Rte="未能加载流水线列表。",Lte="当前工作区暂无流水线。",Ote="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",Mte="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",$te="最近打开或最近运行",Dte="暂无打开或运行记录",Fte="暂无与关键词匹配的最近记录",zte="最近运行",Bte="最近打开",Hte={builtin:"内置",workspace:"工作区",user:"用户"},Wte={flow:"Flow",global:"Global",marketplace:"Marketplace"},Vte={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},Ute={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Kte="打开以在节点画布中编辑此流水线。",qte={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},Yte={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:"关闭"},Gte={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},Xte={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},Jte={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},Qte={title:zZ,all:BZ,archived:HZ,nodes:WZ,myNodes:VZ,myFlows:UZ,skills:KZ,activeProjects:qZ,archivedPipelines:YZ,globalNodes:GZ,myNodesHint:XZ,myFlowsHint:JZ,globalSkills:QZ,createNew:ZZ,newPipeline:eee,searchPipelines:tee,searchNodes:nee,searchFlows:ree,searchSkills:see,refreshResources:iee,loadingPipelines:oee,loadingResources:aee,filterResult:lee,archivedHint:cee,activeHint:uee,nodesHint:dee,skillsHint:fee,nodesPurposeTitle:pee,nodesPurposeDesc:hee,myNodesPurposeTitle:mee,myNodesPurposeDesc:gee,myFlowsPurposeTitle:yee,myFlowsPurposeDesc:xee,skillsPurposeTitle:wee,skillsPurposeDesc:bee,noArchived:vee,noActive:kee,noNodes:See,noMyNodes:Nee,noMyFlows:jee,noSkills:Cee,noDescription:Eee,noNodeMatch:_ee,noFlowSnippetMatch:Pee,noSkillMatch:Aee,nodeSlots:Iee,flowSnippet:Tee,flowSnippetNodes:Ree,skill:Lee,nodeDetail:Oee,flowDetail:Mee,skillDetail:$ee,detailType:Dee,detailSource:Fee,detailPackage:zee,detailVersion:Bee,detailPath:Hee,detailEditable:Wee,readOnly:Vee,editable:Uee,nodeSchema:Kee,nodeInputs:qee,nodeOutputs:Yee,nodeRuntime:Gee,nodeBody:Xee,nodeFiles:Jee,nodeUsage:Qee,noRuntimeManifest:Zee,noNodeBody:ete,noNodeFiles:tte,selectNodeFile:nte,binaryFile:rte,fileTruncated:ste,noNodeUsage:ite,myNodeManagement:ote,deleteMyNode:ate,deletingMyNode:lte,deleteMyNodeHint:cte,deleteMyNodeConfirm:ute,deleteMyNodeSuccess:dte,deleteMyNodeUsedBy:fte,myFlowManagement:pte,deleteMyFlow:hte,deletingMyFlow:mte,deleteMyFlowHint:gte,deleteMyFlowConfirm:yte,deleteMyFlowSuccess:xte,noSlots:wte,resourceMeaning:bte,nodesMeaning:vte,myFlowsMeaning:kte,flowSnippetScale:Ste,flowSnippetPreview:Nte,flowSnippetEdges:jte,flowSnippetJson:Cte,flowSnippetMoreEdges:Ete,noFlowSnippetPreview:_te,skillsMeaning:Pte,skillPreview:Ate,skillPreviewEmpty:Ite,selectResource:Tte,loadFailed:Rte,noPipelines:Lte,emptyHint:Ote,noMatch:Mte,recentActivity:$te,noRecentActivity:Dte,noMatchRecent:Fte,recentRun:zte,recentOpen:Bte,sourceBadge:Hte,resourceSource:Wte,resourceFilter:Vte,nodeDetailTabs:Ute,defaultCardDesc:Kte,hubCard:qte,newPipelineModal:Yte,importModal:Gte,deleteModal:Xte,archiveModal:Jte},Zte="返回",ene="下一步",tne="跳过",nne="完成",rne="开始创建",sne={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
192
-
193
- 点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
194
-
195
- 在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},ine={intro:`现在进入流程编辑器。
196
-
197
- 在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
198
-
199
- 左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
200
-
201
- 在下方输入框用自然语言描述需求,AI 会自动生成流程图。
202
-
203
- 左侧节点面板可以自由拖拽、删除和调整连接。`},one={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},ane={back:Zte,next:ene,skip:tne,done:nne,startCreate:rne,projects:sne,flow:ine,newPipeline:one},lne={en:{common:ZY,flow:DG,settings:JG,composer:sX,project:yQ,onboarding:CQ},zh:{common:LQ,flow:wZ,settings:TZ,composer:FZ,project:Qte,onboarding:ane}};Fr.use(bR).use(uM).init({resources:lne,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 cne=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function une(e){return Fr.changeLanguage(e)}const Mb="agentflow-settings-opencode-plan-v1";function Dx(e){if(!e||typeof e!="object")return{cursor:[],opencode:[],claudeCode:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null};const t=e;return{cursor:Array.isArray(t.cursor)?t.cursor.map(String):[],opencode:Array.isArray(t.opencode)?t.opencode.map(String):[],claudeCode:Array.isArray(t.claudeCode)?t.claudeCode.map(String):[],cursorFetchedAt:t.cursorFetchedAt??null,opencodeFetchedAt:t.opencodeFetchedAt??null,claudeCodeFetchedAt:t.claudeCodeFetchedAt??null}}function vR(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function dne(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function zl(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(),i=String(r.value??""),a=String(r.id??"").trim()||vR(),u=String(r.scope??t).trim()==="global"?"global":"user";!s&&!i||n.push({id:a,key:s,value:i,scope:u})}return n}function H1(e){return zl(e).map(({key:t,value:n})=>({key:t,value:n}))}function W1(){try{return localStorage.getItem(Mb)??""}catch{return""}}function fne(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function V1(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 pne({authUser:e}){const{t,i18n:n}=Pn(["common","settings"]),r=n.language||"zh",[s,i]=h.useState(""),[a,l]=h.useState(""),[u,d]=h.useState({cursor:[],opencode:[],claudeCode:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null}),[f,c]=h.useState(""),[p,m]=h.useState(!1),[g,b]=h.useState(!1),[k,y]=h.useState(""),[v,w]=h.useState([]),[j,P]=h.useState(""),[_,L]=h.useState(!1),[B,D]=h.useState(""),[F,R]=h.useState(""),[M,W]=h.useState(!1),[O,$]=h.useState(()=>new Set),[I,z]=h.useState(""),[C,T]=h.useState([]),[E,G]=h.useState(!1),[Z,V]=h.useState(""),[se,de]=h.useState([]),[fe,pe]=h.useState([]),[ae,be]=h.useState(""),[_e,we]=h.useState(""),[Oe,Ie]=h.useState(!1),[et,ft]=h.useState(!1),[Je,bt]=h.useState(""),Ve=h.useRef(null),jt=h.useRef(!1),An=h.useRef(!1),pn=h.useRef(""),In=h.useCallback(async()=>{l("");try{const ie=await fetch("/api/ui-context");if(!ie.ok)throw new Error("HTTP "+ie.status);const Pe=await ie.json();i(typeof Pe.workspaceRoot=="string"?Pe.workspaceRoot:"")}catch(ie){l(String(ie.message||ie)),i("")}},[]),en=h.useCallback(async()=>{c(""),m(!0);try{const ie=await fetch("/api/model-lists");if(!ie.ok)throw new Error("HTTP "+ie.status);const Pe=await ie.json();d(Dx(Pe))}catch(ie){c(String(ie.message||ie))}finally{m(!1)}},[]),Wn=h.useCallback(async()=>{P("");try{const ie=await fetch("/api/user-env"),Pe=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Pe.error=="string"?Pe.error:"HTTP "+ie.status);const He=zl(Array.isArray(Pe.env)?Pe.env:[],"user").map(ir=>({...ir,scope:"user"})),cn=[...e!=null&&e.isAdmin?zl(Array.isArray(Pe.globalEnv)?Pe.globalEnv:[],"global").map(ir=>({...ir,scope:"global"})):[],...He];pn.current=JSON.stringify(cn),w(cn)}catch(ie){w([]),P(String(ie.message||ie))}finally{An.current=!0}},[e==null?void 0:e.isAdmin]),Tn=h.useCallback(async()=>{if(e!=null&&e.isAdmin){G(!0),V("");try{const ie=await fetch("/api/feedback"),Pe=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Pe.error=="string"?Pe.error:"HTTP "+ie.status);T(Array.isArray(Pe.feedback)?Pe.feedback:[])}catch(ie){V(String(ie.message||ie))}finally{G(!1)}}},[e==null?void 0:e.isAdmin]),ce=h.useCallback(async()=>{if(e!=null&&e.isAdmin){Ie(!0),bt("");try{const ie=await fetch("/api/admin/user-allowlist"),Pe=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Pe.error=="string"?Pe.error:"HTTP "+ie.status);const He=Pe.allowlist&&typeof Pe.allowlist=="object"?Pe.allowlist:{};de(Array.isArray(He.fileUsers)?He.fileUsers.map(String):[]),pe(Array.isArray(He.envUsers)?He.envUsers.map(String):[]),be(typeof He.path=="string"?He.path:"")}catch(ie){bt(String(ie.message||ie))}finally{Ie(!1)}}},[e==null?void 0:e.isAdmin]),ve=h.useCallback(async ie=>{if(e!=null&&e.isAdmin){ft(!0),bt("");try{const Pe=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:ie})}),He=await Pe.json().catch(()=>({}));if(!Pe.ok)throw new Error(typeof He.error=="string"?He.error:"HTTP "+Pe.status);const Ft=He.allowlist&&typeof He.allowlist=="object"?He.allowlist:{};de(Array.isArray(Ft.fileUsers)?Ft.fileUsers.map(String):[]),pe(Array.isArray(Ft.envUsers)?Ft.envUsers.map(String):[]),be(typeof Ft.path=="string"?Ft.path:"")}catch(Pe){bt(String(Pe.message||Pe))}finally{ft(!1)}}},[e==null?void 0:e.isAdmin]),ze=h.useCallback(async ie=>{const Pe=zl(ie),He=Pe.filter(cn=>cn.scope!=="global"),Ft=Pe.filter(cn=>cn.scope==="global");L(!0),P("");try{const cn=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:H1(He),...e!=null&&e.isAdmin?{globalEnv:H1(Ft)}:{}})}),ir=await cn.json().catch(()=>({}));if(!cn.ok)throw new Error(typeof ir.error=="string"?ir.error:"HTTP "+cn.status);const Ds=zl(Array.isArray(ir.env)?ir.env:[],"user").map(Xn=>({...Xn,scope:"user"})),cr=[...e!=null&&e.isAdmin?zl(Array.isArray(ir.globalEnv)?ir.globalEnv:[],"global").map(Xn=>({...Xn,scope:"global"})):[],...Ds];pn.current=JSON.stringify(cr),w(cr)}catch(cn){P(String(cn.message||cn))}finally{L(!1)}},[e==null?void 0:e.isAdmin]),it=h.useCallback(async()=>{c(""),m(!0);try{const ie=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:I.trim()})}),Pe=await ie.json().catch(()=>({}));if(!ie.ok)throw new Error(typeof Pe.error=="string"?Pe.error:"HTTP "+ie.status);d(Dx(Pe.modelLists))}catch(ie){c(String(ie.message||ie))}finally{m(!1)}},[I]);h.useEffect(()=>{In(),en(),Wn(),e!=null&&e.isAdmin&&(Tn(),ce()),(async()=>{try{const ie=await fetch("/api/agentflow-config");if(ie.ok){const Pe=await ie.json(),He=typeof Pe.opencodeProvider=="string"?Pe.opencodeProvider:"";z(He),Ve.current=He;try{localStorage.setItem(Mb,He)}catch{}}else{const Pe=W1();z(Pe),Ve.current=Pe}}catch{const ie=W1();z(ie),Ve.current=ie}finally{jt.current=!0}})()},[e==null?void 0:e.isAdmin,In,Tn,en,ce,Wn]),h.useEffect(()=>{if(!An.current||JSON.stringify(zl(v))===pn.current)return;const Pe=setTimeout(()=>{ze(v)},350);return()=>clearTimeout(Pe)},[v,ze]),h.useEffect(()=>{if(!jt.current)return;const ie=I.trim();if(ie===Ve.current)return;const Pe=setTimeout(()=>{(async()=>{b(!0),y("");try{const He=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:ie})}),Ft=await He.json().catch(()=>({}));if(!He.ok)throw new Error(typeof Ft.error=="string"?Ft.error:"HTTP "+He.status);Ve.current=ie;try{localStorage.setItem(Mb,ie)}catch{}Ft.modelLists&&d(Dx(Ft.modelLists))}catch(He){y(String(He.message||He))}finally{b(!1)}})()},450);return()=>clearTimeout(Pe)},[I]);const ot=u.cursor.length>0,Tt=u.opencode.length>0,tt=u.claudeCode.length>0,an=se.length>0||fe.length>0,Xt=h.useCallback(()=>{var ie;s&&((ie=navigator.clipboard)==null||ie.writeText(s))},[s]),rr=h.useCallback(()=>{const ie=B.trim(),Pe=F;if(ie){if(!dne(ie)){P(t("settings:env.invalidKey"));return}w(He=>[...He,{id:vR(),key:ie,value:Pe,scope:e!=null&&e.isAdmin&&M?"global":"user"}]),D(""),R("")}},[e==null?void 0:e.isAdmin,M,B,F,t]),vn=h.useCallback(ie=>{w(Pe=>Pe.filter(He=>He.id!==ie))},[]),ln=h.useCallback((ie,Pe)=>{w(He=>He.map(Ft=>Ft.id===ie?{...Ft,...Pe}:Ft))},[]),hn=h.useCallback(ie=>{$(Pe=>{const He=new Set(Pe);return He.has(ie)?He.delete(ie):He.add(ie),He})},[]),sr=h.useCallback(()=>{const ie=_e.trim();if(!ie)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(ie)){bt("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(se.map(He=>String(He||"").trim().toLowerCase())).has(ie.toLowerCase())){we("");return}we(""),ve([...se,ie])},[_e,se,ve]),xe=h.useCallback(ie=>{const Pe=String(ie||"").trim().toLowerCase();Pe&&ve(se.filter(He=>String(He||"").trim().toLowerCase()!==Pe))},[se,ve]),Me=h.useCallback(ie=>{const Pe=ie.target.value;une(Pe)},[]),Ze=ie=>{const Pe=V1(ie,r);return Pe?t("settings:cursor.modelList.fetchedAt",{time:Pe}):t("settings:cursor.modelList.never")},Dt=ie=>V1(ie,r)||String(ie||"");return o.jsxs("div",{className:"af-settings-page",children:[o.jsx("header",{className:"af-settings-top",children:o.jsxs("div",{className:"af-settings-crumb","aria-label":t("settings:title"),children:[o.jsx("span",{className:"af-settings-crumb-muted",children:t("settings:crumb.engine")}),o.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),o.jsx("span",{className:"af-settings-crumb-active",children:t("settings:crumb.preferences")})]})}),o.jsx("div",{className:"af-settings-body",children:o.jsxs("div",{className:"af-settings-inner",children:[o.jsxs("header",{className:"af-settings-hero",children:[o.jsxs("h1",{className:"af-settings-h1",children:[t("common:app.name")," ",t("settings:title")]}),o.jsx("p",{className:"af-settings-lead",children:t("settings:workspace.description")}),a?o.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,f?o.jsx("p",{className:"af-err af-settings-api-hint",children:f}):null,j?o.jsx("p",{className:"af-err af-settings-api-hint",children:j}):null]}),o.jsxs("div",{className:"af-settings-layout",children:[o.jsxs("div",{className:"af-settings-bento",children:[o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--low af-set-workspace",children:[o.jsxs("div",{className:"af-set-card-inner",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("span",{className:"material-symbols-outlined af-set-icon af-set-icon--secondary",children:"folder_managed"}),o.jsx("h2",{className:"af-set-h2",children:t("settings:workspace.title")})]}),o.jsx("label",{className:"af-set-label",htmlFor:"af-workspace-path",children:t("settings:workspace.currentPath")}),o.jsxs("div",{className:"af-set-input-wrap",children:[o.jsx("input",{id:"af-workspace-path",className:"af-set-input af-set-input--mono",type:"text",readOnly:!0,value:s,placeholder:t("common:loading")}),o.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:Xt,"aria-label":t("settings:workspace.copyPath"),disabled:!s,children:o.jsx("span",{className:"material-symbols-outlined",children:"content_copy"})})]}),o.jsx("p",{className:"af-set-hint",children:t("settings:workspace.description")})]}),o.jsx("div",{className:"af-set-watermark","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})})]}),o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"Cursor CLI"}),o.jsx("span",{className:"af-set-badge"+(ot?" af-set-badge--ok":" af-set-badge--muted"),children:t(ot?"settings:cursor.status.cached":"settings:cursor.status.notCached")})]}),o.jsxs("div",{className:"af-set-cli-block",children:[o.jsx("div",{className:"af-set-cli-icon",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:ot?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:t(ot?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:ot?t("settings:cursor.modelList.count",{count:u.cursor.length})+" · "+Ze(u.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),ot?o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:cursor.modelPreviewLabel"),children:u.cursor.join(`
204
- `)}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>it(),disabled:p,children:t(p?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"OpenCode"}),o.jsx("span",{className:"af-set-badge"+(Tt?" af-set-badge--ok":" af-set-badge--err"),children:t(Tt?"settings:opencode.status.ready":"settings:opencode.status.notFound")})]}),o.jsx("p",{className:"af-set-p",children:t("settings:opencode.description")}),o.jsxs("div",{children:[o.jsx("label",{className:"af-set-label-sm",htmlFor:"af-opencode-plan",children:t("settings:opencode.provider")}),o.jsx("input",{id:"af-opencode-plan",className:"af-set-input af-set-input--sm af-set-input--mono",type:"text",value:I,onChange:ie=>z(ie.target.value),placeholder:t("settings:opencode.providerPlaceholder"),autoComplete:"off"}),g?o.jsx("p",{className:"af-set-hint af-set-hint--inline","aria-live":"polite",children:t("settings:opencode.saving")}):null,k?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:k}):null]}),Tt?o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"af-set-cli-mono af-set-cli-mono--block",children:t("settings:cursor.modelList.count",{count:u.opencode.length})+" · "+Ze(u.opencodeFetchedAt)}),o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:opencode.modelPreviewLabel"),children:u.opencode.join(`
205
- `)})]}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>it(),disabled:p,children:t(p?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),o.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:claudeCode.title")}),o.jsx("span",{className:"af-set-badge"+(tt?" af-set-badge--ok":" af-set-badge--err"),children:t(tt?"settings:claudeCode.status.ready":"settings:claudeCode.status.notFound")})]}),o.jsxs("div",{className:"af-set-cli-block",children:[o.jsx("div",{className:"af-set-cli-icon",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:tt?"check_circle":"hourglass_empty"})}),o.jsxs("div",{children:[o.jsx("p",{className:"af-set-cli-title",children:t(tt?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),o.jsx("p",{className:"af-set-cli-mono",children:tt?t("settings:cursor.modelList.count",{count:u.claudeCode.length})+" · "+Ze(u.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),o.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),tt?o.jsx("pre",{className:"af-set-model-preview","aria-label":t("settings:claudeCode.modelPreviewLabel"),children:u.claudeCode.join(`
206
- `)}):null,o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>it(),disabled:p,children:t(p?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-env",children:[o.jsxs("div",{className:"af-set-env-head",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("div",{className:"af-set-env-icon-wrap",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"variables"})}),o.jsx("h2",{className:"af-set-h2",children:t("settings:env.title")})]}),o.jsx("span",{className:"af-set-env-note",children:_?t("settings:env.saving"):e!=null&&e.isAdmin?t("settings:env.noteAdmin"):t("settings:env.note")})]}),o.jsxs("div",{className:"af-set-env-rows"+(e!=null&&e.isAdmin?" af-set-env-rows--admin":""),children:[o.jsxs("div",{className:"af-set-env-row af-set-env-row--header","aria-hidden":!0,children:[o.jsx("span",{children:t("settings:env.key")}),e!=null&&e.isAdmin?o.jsx("span",{children:t("settings:env.scope")}):null,o.jsx("span",{children:t("settings:env.value")}),o.jsx("span",{})]}),v.map(ie=>o.jsxs("div",{className:"af-set-env-row"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[o.jsx("div",{className:"af-set-env-cell",children:o.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",value:ie.key,onChange:Pe=>ln(ie.id,{key:Pe.target.value}),"aria-label":t("settings:env.key"),spellCheck:!1})}),e!=null&&e.isAdmin?o.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:o.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[o.jsx("button",{type:"button",className:ie.scope!=="global"?"is-active":"",onClick:()=>ln(ie.id,{scope:"user"}),children:t("settings:env.personal")}),o.jsx("button",{type:"button",className:ie.scope==="global"?"is-active":"",onClick:()=>ln(ie.id,{scope:"global"}),children:t("settings:env.global")})]})}):null,o.jsxs("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:[o.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:O.has(ie.id)?"text":"password",value:ie.value,onChange:Pe=>ln(ie.id,{value:Pe.target.value}),placeholder:fne(ie.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),o.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>hn(ie.id),"aria-label":O.has(ie.id)?"Hide value":"Show value",children:o.jsx("span",{className:"material-symbols-outlined",children:O.has(ie.id)?"visibility_off":"visibility"})})]}),o.jsx("div",{className:"af-set-env-actions",children:o.jsx("button",{type:"button",className:"af-set-env-del","aria-label":t("settings:env.delete",{key:ie.key}),onClick:()=>vn(ie.id),children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},ie.id)),o.jsxs("div",{className:"af-set-env-row af-set-env-row--draft"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[o.jsx("div",{className:"af-set-env-cell",children:o.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",placeholder:"KEY_NAME",value:B,onChange:ie=>D(ie.target.value),"aria-label":t("settings:env.newKey")})}),e!=null&&e.isAdmin?o.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:o.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[o.jsx("button",{type:"button",className:M?"":"is-active",onClick:()=>W(!1),children:t("settings:env.personal")}),o.jsx("button",{type:"button",className:M?"is-active":"",onClick:()=>W(!0),children:t("settings:env.global")})]})}):null,o.jsx("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:o.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:"password",placeholder:t("settings:env.newValue"),value:F,onChange:ie=>R(ie.target.value),"aria-label":t("settings:env.newValue")})}),o.jsx("div",{className:"af-set-env-actions",children:o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:rr,disabled:!B.trim(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]})]})]}),e!=null&&e.isAdmin?o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--allowlist",children:[o.jsxs("div",{className:"af-set-env-head",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("div",{className:"af-set-env-icon-wrap",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"manage_accounts"})}),o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:t("settings:allowlist.title")}),o.jsx("p",{className:"af-set-card-subtitle",children:t("settings:allowlist.description")})]})]}),o.jsx("span",{className:"af-set-badge"+(an?" af-set-badge--ok":" af-set-badge--muted"),children:t(an?"settings:allowlist.enabled":"settings:allowlist.open")}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void ce(),disabled:Oe,children:t(Oe?"settings:allowlist.refreshing":"common:common.refresh")})]}),Je?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:Je}):null,ae?o.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:[t("settings:allowlist.file"),":",o.jsx("code",{children:ae})]}):null,o.jsxs("div",{className:"af-allowlist-grid",children:[o.jsxs("div",{className:"af-allowlist-main",children:[o.jsxs("div",{className:"af-allowlist-head",children:[o.jsx("span",{children:t("settings:allowlist.fileList")}),o.jsx("span",{children:et?t("settings:allowlist.saving"):t("settings:allowlist.userCount",{count:se.length})})]}),o.jsx("div",{className:"af-allowlist-list",children:se.length>0?se.map(ie=>o.jsxs("div",{className:"af-allowlist-row",children:[o.jsx("span",{className:"af-allowlist-name",children:ie}),o.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>xe(ie),"aria-label":t("settings:allowlist.remove",{username:ie}),disabled:et,children:o.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},ie)):o.jsx("div",{className:"af-allowlist-empty",children:t("settings:allowlist.emptyFile")})}),o.jsxs("div",{className:"af-allowlist-add",children:[o.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",value:_e,onChange:ie=>we(ie.target.value),onKeyDown:ie=>{ie.key==="Enter"&&sr()},placeholder:"username",autoComplete:"off"}),o.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:sr,disabled:et||!_e.trim(),children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:allowlist.add")]})]})]}),o.jsxs("div",{className:"af-allowlist-side",children:[o.jsxs("div",{className:"af-allowlist-head",children:[o.jsx("span",{children:t("settings:allowlist.envList")}),o.jsx("span",{children:t("settings:allowlist.readonly")})]}),o.jsx("div",{className:"af-allowlist-env-list",children:fe.length>0?fe.map(ie=>o.jsx("code",{children:ie},ie)):o.jsx("span",{children:t("settings:allowlist.emptyEnv")})}),o.jsx("p",{className:"af-set-hint af-set-hint--inline",children:t("settings:allowlist.unionHint")})]})]})]}):null,e!=null&&e.isAdmin?o.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--feedback",children:[o.jsxs("div",{className:"af-set-env-head",children:[o.jsxs("div",{className:"af-set-card-head",children:[o.jsx("div",{className:"af-set-env-icon-wrap",children:o.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"rate_review"})}),o.jsx("h2",{className:"af-set-h2",children:"意见反馈"})]}),o.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void Tn(),disabled:E,children:E?"刷新中...":"刷新"})]}),Z?o.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:Z}):null,o.jsx("div",{className:"af-feedback-list",children:C.length>0?C.map(ie=>o.jsxs("article",{className:"af-feedback-item",children:[o.jsxs("header",{className:"af-feedback-item__head",children:[o.jsxs("div",{children:[o.jsx("h3",{children:ie.title||"未命名反馈"}),o.jsxs("p",{children:[o.jsx("span",{children:ie.username||ie.userId||"unknown"}),o.jsx("span",{children:Dt(ie.createdAt)})]})]}),ie.contact?o.jsx("span",{className:"af-feedback-item__contact",children:ie.contact}):null]}),o.jsx("p",{className:"af-feedback-item__content",children:ie.content}),ie.pageUrl?o.jsx("code",{className:"af-feedback-item__url",children:ie.pageUrl}):null]},ie.id)):o.jsx("div",{className:"af-feedback-empty",children:E?"正在加载反馈...":"暂无反馈"})})]}):null]}),o.jsxs("aside",{className:"af-settings-rail","aria-label":t("settings:title"),children:[o.jsxs("div",{className:"af-set-rail-card af-set-rail-card--accent",children:[o.jsxs("div",{className:"af-set-rail-inner",children:[o.jsx("h3",{className:"af-set-rail-h3",children:t("settings:system.title")}),o.jsxs("div",{className:"af-set-health-line",children:[o.jsx("span",{className:"af-set-pulse-dot","aria-hidden":!0}),o.jsx("span",{className:"af-set-health-label",children:t(!a&&!f?"settings:system.normal":"settings:system.abnormal")})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.cursorModels")}),o.jsx("span",{children:u.cursor.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,u.cursor.length>0?12+u.cursor.length*3:4)}%`}})})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.opencodeModels")}),o.jsx("span",{children:u.opencode.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,u.opencode.length>0?12+u.opencode.length*3:4)}%`}})})]}),o.jsxs("div",{className:"af-set-meter",children:[o.jsxs("div",{className:"af-set-meter-row",children:[o.jsx("span",{children:t("settings:system.claudeCodeModels")}),o.jsx("span",{children:u.claudeCode.length})]}),o.jsx("div",{className:"af-set-meter-bar",children:o.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,u.claudeCode.length>0?12+u.claudeCode.length*3:4)}%`}})})]})]}),o.jsx("div",{className:"af-set-rail-watermark","aria-hidden":!0,children:o.jsx("span",{className:"material-symbols-outlined",children:"vital_signs"})})]}),o.jsxs("div",{className:"af-set-rail-card",children:[o.jsx("h3",{className:"af-set-rail-h3 af-set-rail-h3--sm",children:t("settings:language.title")}),o.jsxs("div",{className:"af-set-language-selector",children:[o.jsx("select",{className:"af-set-input af-set-input--sm",value:r,onChange:Me,"aria-label":t("settings:language.description"),children:cne.map(ie=>o.jsxs("option",{value:ie.code,children:[ie.flag," ",ie.name]},ie.code))}),o.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})]})})]})}function hne(){const{navigate:e}=Io(),[t,n]=h.useState(""),[r,s]=h.useState(""),[i,a]=h.useState(!1),[l,u]=h.useState(""),[d,f]=h.useState(!1),c=async p=>{if(p.preventDefault(),!i){a(!0),u("");try{const m=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:t,content:r,pageUrl:window.location.href})}),g=await m.json().catch(()=>({}));if(!m.ok)throw new Error(g.error||"提交失败");f(!0),n(""),s("")}catch(m){u(String(m.message||m))}finally{a(!1)}}};return o.jsx("main",{className:"af-feedback-page",children:o.jsxs("section",{className:"af-feedback-panel",children:[o.jsxs("div",{className:"af-feedback-head",children:[o.jsxs("div",{children:[o.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),o.jsx("h1",{children:"意见反馈"}),o.jsx("p",{children:"提交使用中遇到的问题、改进建议或功能需求,管理员会在设置页统一查看。"})]}),o.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>e("/projects"),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]}),d?o.jsxs("div",{className:"af-feedback-success",role:"status",children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),o.jsxs("div",{children:[o.jsx("strong",{children:"已提交"}),o.jsx("span",{children:"感谢反馈,管理员可以在设置页查看这条记录。"})]})]}):null,o.jsxs("form",{className:"af-feedback-form",onSubmit:c,children:[o.jsxs("label",{className:"af-feedback-field",children:[o.jsx("span",{children:"标题"}),o.jsx("input",{value:t,onChange:p=>n(p.target.value),placeholder:"一句话说明问题或建议",maxLength:120,required:!0})]}),o.jsxs("label",{className:"af-feedback-field",children:[o.jsx("span",{children:"反馈内容"}),o.jsx("textarea",{value:r,onChange:p=>s(p.target.value),placeholder:"描述具体场景、期望表现、实际表现或复现步骤",maxLength:5e3,rows:9,required:!0})]}),l?o.jsx("p",{className:"af-err af-feedback-error",children:l}):null,o.jsx("div",{className:"af-feedback-actions",children:o.jsxs("button",{type:"submit",className:"af-feedback-submit",disabled:i||!t.trim()||!r.trim(),children:[o.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:i?"hourglass_empty":"send"}),i?"提交中...":"提交反馈"]})})]})]})})}function kR(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function U1(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,s])=>({id:kR(),key:r,value:String(s??""),private:n.has(r)}))}function K1(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 dm(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(`
207
- `),description:String((e==null?void 0:e.description)||t.description||""),envRows:U1(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:U1(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 Fx(){return dm({name:"",raw:{command:""}})}function mne(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 i=e.argsText.split(/\r?\n/g).map(a=>a.trim()).filter(Boolean);i.length&&(n.args=i)}const r=K1(e.envRows),s=K1(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(i=>i.private).map(i=>String(i.key||"").trim()).filter(Boolean),privateHeaderKeys:e.headerRows.filter(i=>i.private).map(i=>String(i.key||"").trim()).filter(Boolean)}}function q1(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function Y1(e){return e?e.ok?"ok":"error":"unknown"}function G1({title:e,rows:t,onChange:n,placeholderKey:r="KEY",placeholderValue:s="value"}){const i=(a,l,u)=>n(t.map(d=>d.id===a?{...d,[l]:u}:d));return o.jsxs("div",{className:"af-mcp-field",children:[o.jsxs("div",{className:"af-mcp-field-head",children:[o.jsx("span",{children:e}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>n([...t,{id:kR(),key:"",value:"",private:!0}]),children:"添加"})]}),o.jsxs("div",{className:"af-mcp-kv-list",children:[t.length===0?o.jsx("p",{className:"af-set-hint",children:"暂无"}):null,t.map(a=>o.jsxs("div",{className:"af-mcp-kv-row",children:[o.jsx("input",{className:"af-set-input af-set-input--mono",value:a.key,placeholder:r,onChange:l=>i(a.id,"key",l.target.value)}),o.jsx("input",{className:"af-set-input af-set-input--mono",value:a.value,placeholder:s,onChange:l=>i(a.id,"value",l.target.value)}),o.jsxs("label",{className:"af-mcp-private-toggle",title:"只保存到当前 AgentFlow 用户的个人配置",children:[o.jsx("input",{type:"checkbox",checked:!!a.private,onChange:l=>i(a.id,"private",l.target.checked)}),o.jsx("span",{children:"个人"})]}),o.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>n(t.filter(l=>l.id!==a.id)),"aria-label":"删除",children:o.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},a.id))]})]})}function gne(){var M;const[e,t]=h.useState(""),[n,r]=h.useState([]),[s,i]=h.useState(Fx),[a,l]=h.useState(""),[u,d]=h.useState(!1),[f,c]=h.useState(!1),[p,m]=h.useState(!1),[g,b]=h.useState({}),[k,y]=h.useState(""),[v,w]=h.useState(""),j=h.useMemo(()=>n.find(W=>W.name===a)||null,[a,n]),P=j&&g[j.name]||null,_=h.useCallback(async()=>{d(!0),y("");try{const W=await fetch("/api/mcps"),O=await W.json().catch(()=>({}));if(!W.ok)throw new Error(O.error||"MCP HTTP "+W.status);const $=Array.isArray(O.servers)?O.servers:[];t(String(O.path||"")),r($),a&&$.some(I=>I.name===a)&&i(dm($.find(I=>I.name===a)))}catch(W){y(String(W.message||W))}finally{d(!1)}},[a]);h.useEffect(()=>{_()},[_]);const L=()=>{l(""),i(Fx()),w(""),y("")},B=W=>{l(W.name),i(dm(W)),w(""),y("")},D=async(W="")=>{m(!0),y(""),w("");try{const O=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W?{name:W}:{})}),$=await O.json().catch(()=>({}));if(!O.ok)throw new Error($.error||"检测 MCP 失败");const I=Array.isArray($.results)?$.results:[];b(z=>{const C={...z};for(const T of I)T!=null&&T.name&&(C[T.name]=T);return C}),w(W?`已检测 ${W}。`:"已检测所有 MCP。")}catch(O){y(String(O.message||O))}finally{m(!1)}},F=async()=>{c(!0),y(""),w("");try{const W=mne(s);if(!W.nextName)throw new Error("请填写 MCP 名称");const O=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W)}),$=await O.json().catch(()=>({}));if(!O.ok)throw new Error($.error||"保存 MCP 失败");const I=Array.isArray($.servers)?$.servers:[];r(I),t(String($.path||e)),l(W.nextName),i(dm(I.find(z=>z.name===W.nextName)||null)),b(z=>{const C={...z};return s.originalName&&s.originalName!==W.nextName&&delete C[s.originalName],delete C[W.nextName],C}),w("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(W){y(String(W.message||W))}finally{c(!1)}},R=async W=>{if(W!=null&&W.name&&window.confirm(`删除 MCP "${W.name}"?`)){c(!0),y(""),w("");try{const O=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:W.name})}),$=await O.json().catch(()=>({}));if(!O.ok)throw new Error($.error||"删除 MCP 失败");r(Array.isArray($.servers)?$.servers:[]),l(""),i(Fx()),b(I=>{const z={...I};return delete z[W.name],z}),w("已删除。")}catch(O){y(String(O.message||O))}finally{c(!1)}}};return o.jsxs("main",{className:"af-settings-page",children:[o.jsxs("header",{className:"af-settings-top",children:[o.jsxs("div",{className:"af-settings-crumb",children:[o.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),o.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),o.jsx("span",{className:"af-settings-crumb-active",children:"MCP"})]}),o.jsxs("div",{className:"af-settings-top-right",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:_,disabled:u||f,children:"刷新"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>D(),disabled:p||u||f||n.length===0,children:p?"检测中...":"检测状态"}),o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:L,disabled:f,children:"新增 MCP"})]})]}),o.jsx("div",{className:"af-settings-body",children:o.jsxs("div",{className:"af-settings-inner",children:[o.jsxs("section",{className:"af-settings-hero",children:[o.jsx("h1",{className:"af-settings-h1",children:"MCP 管理"}),o.jsxs("p",{className:"af-settings-lead",children:["新增、编辑和删除 Cursor MCP server。当前配置文件:",o.jsx("span",{className:"af-settings-code",children:e||"~/.cursor/mcp.json"})]})]}),o.jsxs("div",{className:"af-mcp-layout",children:[o.jsxs("section",{className:"af-set-card af-mcp-list-card",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsx("h2",{className:"af-set-h2",children:"Servers"}),o.jsxs("div",{className:"af-mcp-list-head-actions",children:[o.jsx("span",{className:"af-set-badge af-set-badge--muted",children:n.length}),o.jsxs("button",{type:"button",className:"af-set-btn-mini",onClick:L,disabled:f,children:[o.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]})]}),u?o.jsx("p",{className:"af-set-p",children:"加载中..."}):null,n.length===0&&!u?o.jsxs("div",{className:"af-mcp-empty",children:[o.jsx("p",{className:"af-set-p",children:"暂无 MCP server。"}),o.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:L,disabled:f,children:"新增 MCP Server"})]}):null,o.jsx("div",{className:"af-mcp-server-list",children:n.map(W=>o.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===W.name?" af-mcp-server-item--active":""),onClick:()=>B(W),children:[o.jsx("span",{className:"material-symbols-outlined",children:W.type==="url"?"cloud":"terminal"}),o.jsxs("span",{children:[o.jsxs("span",{className:"af-mcp-server-title",children:[o.jsx("strong",{children:W.name}),o.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${Y1(g[W.name])}`,children:q1(g[W.name])})]}),o.jsx("em",{children:W.url||[W.command,...W.args||[]].filter(Boolean).join(" ")})]})]},W.name))})]}),o.jsxs("section",{className:"af-set-card af-mcp-editor-card",children:[o.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[o.jsxs("div",{children:[o.jsx("h2",{className:"af-set-h2",children:j?"编辑 MCP":"新增 MCP"}),o.jsx("p",{className:"af-set-p af-set-p--tight",children:"保存后会写入 Cursor MCP 配置。已运行的 agent 进程不会热更新,下一次启动会读取新配置。"})]}),j?o.jsxs("div",{className:"af-mcp-editor-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>D(j.name),disabled:p||f,children:p?"检测中...":"检测"}),o.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>R(j),disabled:f,children:"删除"})]}):null]}),k?o.jsx("p",{className:"af-mcp-error",children:k}):null,v?o.jsx("p",{className:"af-mcp-status",children:v}):null,P?o.jsxs("div",{className:`af-mcp-check af-mcp-check--${Y1(P)}`,children:[o.jsxs("div",{className:"af-mcp-check-head",children:[o.jsx("strong",{children:q1(P)}),o.jsxs("span",{children:[P.elapsedMs||0,"ms"]})]}),P.error?o.jsx("p",{children:P.error}):null,(M=P.tools)!=null&&M.length?o.jsx("div",{className:"af-mcp-tools-list",children:P.tools.map(W=>o.jsxs("div",{className:"af-mcp-tool-row",children:[o.jsx("strong",{children:W.name}),W.description?o.jsx("span",{children:W.description}):null]},W.name))}):null]}):null,o.jsxs("div",{className:"af-mcp-form",children:[o.jsxs("label",{className:"af-set-label",children:["MCP 名称",o.jsx("input",{className:"af-set-input af-set-input--mono",value:s.name,onChange:W=>i(O=>({...O,name:W.target.value})),placeholder:"github"})]}),o.jsxs("label",{className:"af-set-label",children:["类型",o.jsxs("select",{className:"af-set-input",value:s.type,onChange:W=>i(O=>({...O,type:W.target.value})),children:[o.jsx("option",{value:"url",children:"URL / HTTP"}),o.jsx("option",{value:"command",children:"Command / stdio"})]})]}),s.type==="url"?o.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["URL",o.jsx("input",{className:"af-set-input af-set-input--mono",value:s.url,onChange:W=>i(O=>({...O,url:W.target.value})),placeholder:"http://127.0.0.1:3845/mcp"})]}):o.jsxs(o.Fragment,{children:[o.jsxs("label",{className:"af-set-label",children:["Command",o.jsx("input",{className:"af-set-input af-set-input--mono",value:s.command,onChange:W=>i(O=>({...O,command:W.target.value})),placeholder:"uvx"})]}),o.jsxs("label",{className:"af-set-label",children:["Args,每行一个",o.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:4,value:s.argsText,onChange:W=>i(O=>({...O,argsText:W.target.value})),placeholder:`mcp-server-example
208
- --flag`})]})]}),o.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["描述",o.jsx("input",{className:"af-set-input",value:s.description,onChange:W=>i(O=>({...O,description:W.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),o.jsx(G1,{title:"Headers",rows:s.headerRows,onChange:W=>i(O=>({...O,headerRows:W})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),o.jsx(G1,{title:"Env",rows:s.envRows,onChange:W=>i(O=>({...O,envRows:W})),placeholderKey:"TOKEN",placeholderValue:"..."}),o.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["额外 JSON 字段",o.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:5,value:s.extraJson,onChange:W=>i(O=>({...O,extraJson:W.target.value}))})]})]}),o.jsxs("div",{className:"af-mcp-actions",children:[o.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:L,disabled:f,children:"清空"}),o.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:F,disabled:f,children:f?"保存中...":"保存 MCP"})]})]})]})]})})]})}const yne=[{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"}],xne=[{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 长文档","客户端原型预览","图表与表格","统一展示链接"]}],wne=[{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"}],bne=[["知识库","查客户端、后台、前端逻辑","广告、Feed、会员、增长、配置、接口调用链"],["数据","查 CK / Hive 并输出 SQL","PV、UV、转化、分页面、分国家、分实验组"],["产物","生成原型、PRD、Display 面板","Markdown、HTML 原型、图表、表格、交互预览"],["协作","同步 TAPD 与 Git 仓库","需求正文、变更记录、MR 链接、评审材料"]];function Fh({icon:e,title:t,label:n,tone:r="violet"}){return o.jsxs("div",{className:`likee-flow-node likee-flow-node-${r}`,children:[o.jsx("span",{className:"material-symbols-outlined",children:e}),o.jsxs("div",{children:[o.jsx("strong",{children:t}),o.jsx("small",{children:n})]})]})}function vne(){return o.jsxs("div",{className:"likee-workspace-scene","aria-hidden":"true",children:[o.jsx("div",{className:"likee-scene-grid"}),o.jsxs("svg",{className:"likee-scene-lines",viewBox:"0 0 980 560",fill:"none",children:[o.jsx("path",{d:"M96 154 C236 96 330 122 444 194 C552 262 654 260 814 160"}),o.jsx("path",{d:"M118 350 C248 288 344 304 458 372 C578 444 704 420 858 310"}),o.jsx("path",{d:"M472 196 C512 248 524 302 486 372"}),o.jsx("path",{d:"M622 126 C670 198 696 258 682 354"})]}),o.jsx("div",{className:"likee-node-pos likee-node-a",children:o.jsx(Fh,{icon:"travel_explore",title:"全局上下文",label:"Likee 业务、代码、数据",tone:"pink"})}),o.jsx("div",{className:"likee-node-pos likee-node-b",children:o.jsx(Fh,{icon:"database",title:"CK / Hive",label:"自动 SQL 与指标口径",tone:"cyan"})}),o.jsx("div",{className:"likee-node-pos likee-node-c",children:o.jsx(Fh,{icon:"article",title:"需求文档",label:"PRD、变更说明、评审稿",tone:"amber"})}),o.jsx("div",{className:"likee-node-pos likee-node-d",children:o.jsx(Fh,{icon:"sync_alt",title:"TAPD / Git",label:"同步需求与版本资产",tone:"green"})}),o.jsxs("div",{className:"likee-phone-preview",children:[o.jsxs("div",{className:"likee-phone-top",children:[o.jsx("span",{children:"关注"}),o.jsx("strong",{children:"推荐"}),o.jsx("span",{children:"直播"})]}),o.jsxs("div",{className:"likee-phone-card",children:[o.jsx("div",{className:"likee-gift",children:"AD"}),o.jsx("h4",{children:"广告个性化引导弹框"}),o.jsx("p",{children:"保持推荐体验,同时解释权益与关闭路径。"}),o.jsx("button",{children:"继续"}),o.jsx("button",{className:"secondary",children:"稍后"})]})]}),o.jsxs("div",{className:"likee-display-panel",children:[o.jsxs("div",{className:"likee-panel-header",children:[o.jsx("span",{children:"DISPLAY"}),o.jsx("strong",{children:"需求资产面板"})]}),o.jsxs("div",{className:"likee-table-row",children:[o.jsx("span",{children:"需求"}),o.jsx("strong",{children:"首页广告个性化引导"})]}),o.jsxs("div",{className:"likee-table-row",children:[o.jsx("span",{children:"数据"}),o.jsx("strong",{children:"m09 PV Top 1"})]}),o.jsxs("div",{className:"likee-table-row",children:[o.jsx("span",{children:"同步"}),o.jsx("strong",{children:"TAPD + Git MR"})]})]})]})}function fm({kicker:e,title:t,children:n}){return o.jsxs("div",{className:"likee-section-copy",children:[o.jsx("p",{className:"likee-section-kicker",children:e}),o.jsx("h2",{children:t}),o.jsx("p",{children:n})]})}function kne(){return o.jsx("section",{id:"likee-skills",className:"likee-section likee-section-dark",children:o.jsxs("div",{className:"likee-section-inner likee-two-column likee-two-column-skills",children:[o.jsx(fm,{kicker:"SKILLS",title:"用 Skills 把 Likee 上下文变成可复用能力",children:"Skills 是工作区里可加载的能力包。手动搭建工作区时,只需要按场景加载对应 Skill。"}),o.jsx("div",{className:"likee-skill-grid",children:wne.map(e=>o.jsxs("article",{className:`likee-skill-card likee-skill-${e.tone}`,children:[o.jsxs("div",{className:"likee-skill-head",children:[o.jsx("div",{className:"likee-skill-icon",children:o.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),o.jsxs("div",{children:[o.jsx("h3",{children:e.name}),o.jsx("span",{children:e.namespace})]})]}),o.jsx("div",{className:"likee-skill-mode",children:e.mode}),o.jsx("p",{children:e.usage}),o.jsx("div",{className:"likee-skill-examples",children:e.examples.map(t=>o.jsx("strong",{children:t},t))})]},e.name))})]})})}function SR(){return o.jsxs("div",{className:"likee-page",children:[o.jsx("div",{className:"likee-top-actions",children:o.jsxs("a",{href:"/projects",className:"likee-home-link",children:[o.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"}),"返回首页"]})}),o.jsxs("section",{className:"likee-hero",children:[o.jsx(vne,{}),o.jsxs("div",{className:"likee-hero-content",children:[o.jsx("p",{className:"likee-eyebrow",children:"LIKEE CONTEXT WORKSPACE"}),o.jsx("h1",{children:"Likee Agent 工作台"}),o.jsx("p",{className:"likee-hero-subtitle",children:"提供 Likee 全局上下文,赋能需求挖掘、书写和运营。"}),o.jsxs("div",{className:"likee-signal-row",children:[o.jsx("span",{children:"查业务逻辑"}),o.jsx("span",{children:"查 CK / Hive"}),o.jsx("span",{children:"生成原型"}),o.jsx("span",{children:"生成 PRD"}),o.jsx("span",{children:"同步 TAPD / Git"})]}),o.jsxs("div",{className:"likee-hero-actions",children:[o.jsxs("a",{href:"/projects",className:"likee-primary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"rocket_launch"}),"立即使用"]}),o.jsxs("a",{href:"#likee-scenarios",className:"likee-secondary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"ads_click"}),"按场景查看"]}),o.jsxs("a",{href:"#likee-usecases",className:"likee-secondary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"view_timeline"}),"查看 Use Cases"]}),o.jsxs("a",{href:"#likee-skills",className:"likee-secondary-action",children:[o.jsx("span",{className:"material-symbols-outlined",children:"extension"}),"查看 Skills"]})]})]})]}),o.jsx("section",{id:"likee-scenarios",className:"likee-section",children:o.jsxs("div",{className:"likee-section-inner",children:[o.jsx(fm,{kicker:"SCENARIO TRIGGERS",title:"打造 Likee 团队全景上下文",children:"不要求先会写 Prompt,也不要求知道该找哪个系统。选择一个业务场景,工作台会把需要的 Likee 上下文、数据查询和最终产物组织起来。"}),o.jsx("div",{className:"likee-scenario-grid",children:yne.map(e=>o.jsxs("article",{className:`likee-scenario-card likee-scenario-${e.tone}`,children:[o.jsx("div",{className:"likee-scenario-icon",children:o.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),o.jsxs("div",{children:[o.jsx("h3",{children:e.title}),o.jsx("p",{children:e.question})]}),o.jsx("div",{className:"likee-scenario-context",children:e.context.map(t=>o.jsx("span",{children:t},t))}),o.jsxs("div",{className:"likee-scenario-result",children:[o.jsx("span",{children:"产出"}),o.jsx("strong",{children:e.result})]})]},e.title))})]})}),o.jsx("section",{id:"likee-usecases",className:"likee-section likee-section-muted",children:o.jsxs("div",{className:"likee-section-inner likee-two-column likee-usecase-layout",children:[o.jsx(fm,{kicker:"USE CASES",title:"沉淀 Likee 业务流水线",children:"这里展示的是平台里实际可跑的工作流:加载流程片段,在子 Agent 或 Run 节点输入业务问题,执行当前 line,最终在 Display、TAPD 和 Git 中拿到结果。"}),o.jsx("div",{className:"likee-usecase-stack",children:xne.map(e=>o.jsxs("article",{className:"likee-usecase-card",children:[o.jsx("div",{className:`likee-usecase-media ${e.images.length>1?"likee-usecase-media-split":""}`,children:e.images.map((t,n)=>o.jsx("img",{src:t,alt:`${e.title} 工作区截图 ${n+1}`,loading:"lazy"},t))}),o.jsxs("div",{className:"likee-usecase-body",children:[o.jsx("div",{className:"likee-usecase-label",children:e.label}),o.jsx("h3",{children:e.title}),o.jsx("p",{children:e.trigger}),o.jsx("ol",{className:"likee-usecase-steps",children:e.steps.map(t=>o.jsx("li",{children:t},t))}),o.jsxs("div",{className:"likee-usecase-output",children:[o.jsx("span",{children:"实际产物"}),o.jsx("div",{children:e.outputs.map(t=>o.jsx("strong",{children:t},t))})]})]})]},e.label))})]})}),o.jsx(kne,{}),o.jsx("section",{className:"likee-section",children:o.jsxs("div",{className:"likee-section-inner likee-two-column likee-capability-layout",children:[o.jsx(fm,{kicker:"CAPABILITY MAP",title:"每个场景背后,都连接同一套 Likee 上下文能力",children:"工作台把知识库、CK / Hive、原型、PRD、TAPD 和 Git 放到同一条链路里。用户看到的是业务场景,系统处理的是上下文、产物和同步。"}),o.jsx("div",{className:"likee-capability-table",children:bne.map(([e,t,n])=>o.jsxs("div",{className:"likee-capability-row",children:[o.jsx("span",{children:e}),o.jsx("strong",{children:t}),o.jsx("p",{children:n})]},e))})]})})]})}function NR(e){return t=>typeof t===e}var Sne=NR("function"),Nne=e=>e===null,X1=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",J1=e=>!jne(e)&&!Nne(e)&&(Sne(e)||typeof e=="object"),jne=NR("undefined");function Cne(e,t,n){return Rne(n,e,t)?!0:(Lne(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?Ene(e,t,n):e instanceof Map&&t instanceof Map?Ane(e,t,n):e instanceof Set&&t instanceof Set?Tne(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?_ne(e,t):X1(e)&&X1(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?Pne(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():Ine(e,t,n))}function gp(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!J1(e)||!t||!J1(t)?!1:Cne(e,t,n)}function Ene(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let s=r;s--!==0;)if(!gp(e[s],t[s],n))return!1;return!0}function _ne(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 Pne(e,t,n){return e.message===t.message&&e.name===t.name&&gp(e.cause,t.cause,n)}function Ane(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(!gp(r[1],t.get(r[0]),n))return!1;return!0}function Ine(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 i=r[s];if(!(i==="_owner"&&e.$$typeof)&&!gp(e[i],t[i],n))return!1}return!0}function Tne(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 Rne(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function Lne(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function I0(e,t){return gp(e,t,new WeakMap)}function zx(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function One(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function Mne(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function $ne(){const e=h.useRef(!0);return e.current?(e.current=!1,!0):e.current}function Dne(e,t){const n=$ne();h.useEffect(()=>{if(!n)return e()},t)}function jR(e){const t=h.useRef(void 0);return h.useEffect(()=>{t.current=e}),t.current}function Fne(e,t){const n=h.useRef(t);return I0(t,n.current)||(n.current=t),h.useMemo(e,n.current)}function zne(e){h.useEffect(()=>{e()},[])}function Bne(e=0){const[t,n]=h.useState({height:zx()?window.innerHeight:0,width:zx()?window.innerWidth:0}),r=h.useRef(0),s=h.useRef(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(()=>{n({width:window.innerWidth,height:window.innerHeight})},e)});return h.useEffect(()=>{if(!zx())return()=>{};const i=s.current;return n({height:window.innerHeight,width:window.innerWidth}),Mne(window,"resize",i),()=>{One(window,"resize",i)}},[]),t}var Hne=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],Wne=["bigint","boolean","null","number","string","symbol","undefined"];function yp(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(Vne(t))return t}function to(e){return t=>yp(t)===e}function Vne(e){return Hne.includes(e)}function Vu(e){return t=>typeof t===e}function Une(e){return Wne.includes(e)}var Kne=["innerHTML","ownerDocument","style","attributes","nodeValue"],xp=e=>Array.isArray(e),qne=e=>yp(e)==="AsyncGeneratorFunction",Yne=to("AsyncFunction"),Gne=Vu("bigint"),Xne=e=>e===!0||e===!1,Jne=to("Date"),Qne=to("Error"),ll=Vu("function"),Zne=to("GeneratorFunction"),ere=e=>typeof e=="number"&&Number.isInteger(e),$b=to("Map"),CR=e=>Number.isNaN(e),T0=e=>e===null,ER=to("Function"),tre=to("Promise"),nre=to("RegExp"),Db=to("Set"),wp=Vu("string"),rre=Vu("symbol"),R0=Vu("undefined"),sre=to("WeakMap"),ire=to("WeakSet"),L0=e=>T0(e)||R0(e),_R=e=>!R0(e),ore=e=>Vu("number")(e)&&!CR(e),are=e=>wp(e)&&e.trim().length>0,lre=e=>{if(!wp(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},iy=e=>!L0(e)&&(ll(e)||typeof e=="object"),PR=e=>{if(yp(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},cre=e=>T0(e)||Une(typeof e),ure=e=>yp(e)==="URL",AR=e=>!L0(e)&&ll(e[Symbol.iterator]),dre=e=>AR(e)&&ll(e.next)&&ll(e.throw),fre=e=>ll(e)&&/^class\s/.test(e.toString()),pre=(e,t)=>!xp(e)||!ll(t)?!1:e.every(n=>t(n)),hre=e=>iy(e)&&!PR(e)&&e.nodeType===1&&wp(e.nodeName)&&Kne.every(t=>t in e),mre=e=>wp(e)&&e.length===0||xp(e)&&e.length===0||iy(e)&&!$b(e)&&!Db(e)&&Object.keys(e).length===0||Db(e)&&e.size===0||$b(e)&&e.size===0,gre=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,yre=(e,t)=>xp(e)?e.indexOf(t)>-1:!1,xre=(e,t,n)=>{if(!iy(e)||!t)return!1;const r=e[t];return ll(n)?n(r):_R(r)};function _t(e){if(e===null)return"null";switch(typeof e){case"bigint":return"bigint";case"boolean":return"boolean";case"number":return"number";case"string":return"string";case"symbol":return"symbol";case"undefined":return"undefined"}if(xp(e))return"Array";if(ER(e))return"Function";const t=yp(e);return t||"Object"}_t.array=xp;_t.arrayOf=pre;_t.asyncGeneratorFunction=qne;_t.asyncFunction=Yne;_t.bigint=Gne;_t.boolean=Xne;_t.class=fre;_t.date=Jne;_t.defined=_R;_t.domElement=hre;_t.empty=mre;_t.error=Qne;_t.function=ll;_t.generator=dre;_t.generatorFunction=Zne;_t.instanceOf=gre;_t.integer=ere;_t.iterable=AR;_t.map=$b;_t.nan=CR;_t.null=T0;_t.nullOrUndefined=L0;_t.nonEmptyString=are;_t.number=ore;_t.numericString=lre;_t.object=iy;_t.oneOf=yre;_t.plainFunction=ER;_t.plainObject=PR;_t.primitive=cre;_t.promise=tre;_t.propertyOf=xre;_t.regexp=nre;_t.set=Db;_t.string=wp;_t.symbol=rre;_t.undefined=R0;_t.url=ure;_t.weakMap=sre;_t.weakSet=ire;var Qr=_t;/* v8 ignore next -- @preserve */var wre=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},bre=function(e,t){return e+Xf(t)},Xf=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(bre,""):wre(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?Xf(e.props.children):""};Xf.default=Xf;var vre=Xf;const Bx=ul(vre);var IR={exports:{}};(function(e){const t=Object.getPrototypeOf({});function n(){return function(i){return typeof i=="object"&&i!==null&&!(i instanceof RegExp)&&!(i instanceof Date)}}function r(s){function i(P){return P!=="constructor"&&P!=="prototype"&&P!=="__proto__"}function a(P){let _=0;const L=P.length,B=new Array(L);for(_;_<L;++_)B[_]=y(P[_]);return B}function l(P){const _={};if(p&&Object.getPrototypeOf(P)!==t)return p(P);const L=c(P);let B,D,F;for(B=0,D=L.length;B<D;++B)i(F=L[B])&&(_[F]=y(P[F]));return _}function u(P,_){const L=P.length,B=_.length;let D=0;const F=new Array(L+B);for(D;D<L;++D)F[D]=y(P[D]);for(D=0;D<B;++D)F[D+L]=y(_[D]);return F}const d=Object.prototype.propertyIsEnumerable;function f(P){const _=Object.keys(P),L=Object.getOwnPropertySymbols(P);for(let B=0,D=L.length;B<D;++B)d.call(P,L[B])&&_.push(L[B]);return _}const c=s!=null&&s.symbols?f:Object.keys,p=typeof(s==null?void 0:s.cloneProtoObject)=="function"?s.cloneProtoObject:void 0,m=typeof(s==null?void 0:s.isMergeableObject)=="function"?s.isMergeableObject:n(),g=(s==null?void 0:s.onlyDefinedProperties)===!0;function b(P){return typeof P!="object"||P===null}const k=s&&typeof s.mergeArray=="function"?s.mergeArray({clone:y,deepmerge:w,getKeys:c,isMergeableObject:m}):u;function y(P){return m(P)?Array.isArray(P)?a(P):l(P):P}function v(P,_){const L={},B=c(P),D=c(_);let F,R,M;for(F=0,R=B.length;F<R;++F)i(M=B[F])&&D.indexOf(M)===-1&&(L[M]=y(P[M]));for(F=0,R=D.length;F<R;++F)if(i(M=D[F]))if(M in P)B.indexOf(M)!==-1&&(p&&m(_[M])&&Object.getPrototypeOf(_[M])!==t?L[M]=p(_[M]):L[M]=w(P[M],_[M]));else{if(g&&typeof _[M]>"u")continue;L[M]=y(_[M])}return L}function w(P,_){if(g&&typeof _>"u")return y(P);const L=Array.isArray(_),B=Array.isArray(P);return b(_)?_:m(P)?L&&B?k(P,_):L!==B?y(_):v(P,_):y(_)}function j(){switch(arguments.length){case 0:return{};case 1:return y(arguments[0]);case 2:return w(arguments[0],arguments[1])}let P;for(let _=0,L=arguments.length;_<L;++_)P=w(P,arguments[_]);return P}return s!=null&&s.all?j:w}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(IR);var kre=IR.exports;const Sre=ul(kre);var Nre=new Error("Element already at target scroll position"),jre=new Error("Scroll cancelled"),Cre=Math.min,Q1=Date.now,Ere={left:Z1("scrollLeft"),top:Z1("scrollTop")};function Z1(e){return function(n,r,s,i){s=s||{},typeof s=="function"&&(i=s,s={}),typeof i!="function"&&(i=Pre);var a=Q1(),l=n[e],u=s.ease||_re,d=isNaN(s.duration)?350:+s.duration,f=!1;return l===r?i(Nre,n[e]):requestAnimationFrame(p),c;function c(){f=!0}function p(m){if(f)return i(jre,n[e]);var g=Q1(),b=Cre(1,(g-a)/d),k=u(b);n[e]=k*(r-l)+l,b<1?requestAnimationFrame(p):requestAnimationFrame(function(){i(null,n[e])})}}}function _re(e){return .5*(1-Math.cos(Math.PI*e))}function Pre(){}const Are=ul(Ere);var TR={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(ff,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})})(TR);var Ire=TR.exports;const RR=ul(Ire),Tre=["top","right","bottom","left"],eC=["start","end"],tC=Tre.reduce((e,t)=>e.concat(t,t+"-"+eC[0],t+"-"+eC[1]),[]),Mu=Math.min,Ql=Math.max,yg=Math.round,zh=Math.floor,Eo=e=>({x:e,y:e}),Rre={left:"right",right:"left",bottom:"top",top:"bottom"};function Fb(e,t,n){return Ql(e,Mu(t,n))}function Uu(e,t){return typeof e=="function"?e(t):e}function fa(e){return e.split("-")[0]}function _o(e){return e.split("-")[1]}function LR(e){return e==="x"?"y":"x"}function O0(e){return e==="y"?"height":"width"}function Va(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function M0(e){return LR(Va(e))}function OR(e,t,n){n===void 0&&(n=!1);const r=_o(e),s=M0(e),i=O0(s);let a=s==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[i]>t.floating[i]&&(a=wg(a)),[a,wg(a)]}function Lre(e){const t=wg(e);return[xg(e),t,xg(t)]}function xg(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const nC=["left","right"],rC=["right","left"],Ore=["top","bottom"],Mre=["bottom","top"];function $re(e,t,n){switch(e){case"top":case"bottom":return n?t?rC:nC:t?nC:rC;case"left":case"right":return t?Ore:Mre;default:return[]}}function Dre(e,t,n,r){const s=_o(e);let i=$re(fa(e),n==="start",r);return s&&(i=i.map(a=>a+"-"+s),t&&(i=i.concat(i.map(xg)))),i}function wg(e){const t=fa(e);return Rre[t]+e.slice(t.length)}function Fre(e){return{top:0,right:0,bottom:0,left:0,...e}}function MR(e){return typeof e!="number"?Fre(e):{top:e,right:e,bottom:e,left:e}}function bg(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 sC(e,t,n){let{reference:r,floating:s}=e;const i=Va(t),a=M0(t),l=O0(a),u=fa(t),d=i==="y",f=r.x+r.width/2-s.width/2,c=r.y+r.height/2-s.height/2,p=r[l]/2-s[l]/2;let m;switch(u){case"top":m={x:f,y:r.y-s.height};break;case"bottom":m={x:f,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:c};break;case"left":m={x:r.x-s.width,y:c};break;default:m={x:r.x,y:r.y}}switch(_o(t)){case"start":m[a]-=p*(n&&d?-1:1);break;case"end":m[a]+=p*(n&&d?-1:1);break}return m}async function zre(e,t){var n;t===void 0&&(t={});const{x:r,y:s,platform:i,rects:a,elements:l,strategy:u}=e,{boundary:d="clippingAncestors",rootBoundary:f="viewport",elementContext:c="floating",altBoundary:p=!1,padding:m=0}=Uu(t,e),g=MR(m),k=l[p?c==="floating"?"reference":"floating":c],y=bg(await i.getClippingRect({element:(n=await(i.isElement==null?void 0:i.isElement(k)))==null||n?k:k.contextElement||await(i.getDocumentElement==null?void 0:i.getDocumentElement(l.floating)),boundary:d,rootBoundary:f,strategy:u})),v=c==="floating"?{x:r,y:s,width:a.floating.width,height:a.floating.height}:a.reference,w=await(i.getOffsetParent==null?void 0:i.getOffsetParent(l.floating)),j=await(i.isElement==null?void 0:i.isElement(w))?await(i.getScale==null?void 0:i.getScale(w))||{x:1,y:1}:{x:1,y:1},P=bg(i.convertOffsetParentRelativeRectToViewportRelativeRect?await i.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:v,offsetParent:w,strategy:u}):v);return{top:(y.top-P.top+g.top)/j.y,bottom:(P.bottom-y.bottom+g.bottom)/j.y,left:(y.left-P.left+g.left)/j.x,right:(P.right-y.right+g.right)/j.x}}const Bre=50,Hre=async(e,t,n)=>{const{placement:r="bottom",strategy:s="absolute",middleware:i=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:zre},u=await(a.isRTL==null?void 0:a.isRTL(t));let d=await a.getElementRects({reference:e,floating:t,strategy:s}),{x:f,y:c}=sC(d,r,u),p=r,m=0;const g={};for(let b=0;b<i.length;b++){const k=i[b];if(!k)continue;const{name:y,fn:v}=k,{x:w,y:j,data:P,reset:_}=await v({x:f,y:c,initialPlacement:r,placement:p,strategy:s,middlewareData:g,rects:d,platform:l,elements:{reference:e,floating:t}});f=w??f,c=j??c,g[y]={...g[y],...P},_&&m<Bre&&(m++,typeof _=="object"&&(_.placement&&(p=_.placement),_.rects&&(d=_.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:s}):_.rects),{x:f,y:c}=sC(d,p,u)),b=-1)}return{x:f,y:c,placement:p,strategy:s,middlewareData:g}},Wre=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:s,rects:i,platform:a,elements:l,middlewareData:u}=t,{element:d,padding:f=0}=Uu(e,t)||{};if(d==null)return{};const c=MR(f),p={x:n,y:r},m=M0(s),g=O0(m),b=await a.getDimensions(d),k=m==="y",y=k?"top":"left",v=k?"bottom":"right",w=k?"clientHeight":"clientWidth",j=i.reference[g]+i.reference[m]-p[m]-i.floating[g],P=p[m]-i.reference[m],_=await(a.getOffsetParent==null?void 0:a.getOffsetParent(d));let L=_?_[w]:0;(!L||!await(a.isElement==null?void 0:a.isElement(_)))&&(L=l.floating[w]||i.floating[g]);const B=j/2-P/2,D=L/2-b[g]/2-1,F=Mu(c[y],D),R=Mu(c[v],D),M=F,W=L-b[g]-R,O=L/2-b[g]/2+B,$=Fb(M,O,W),I=!u.arrow&&_o(s)!=null&&O!==$&&i.reference[g]/2-(O<M?F:R)-b[g]/2<0,z=I?O<M?O-M:O-W:0;return{[m]:p[m]+z,data:{[m]:$,centerOffset:O-$-z,...I&&{alignmentOffset:z}},reset:I}}});function Vre(e,t,n){return(e?[...n.filter(s=>_o(s)===e),...n.filter(s=>_o(s)!==e)]:n.filter(s=>fa(s)===s)).filter(s=>e?_o(s)===e||(t?xg(s)!==s:!1):!0)}const Ure=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,r,s;const{rects:i,middlewareData:a,placement:l,platform:u,elements:d}=t,{crossAxis:f=!1,alignment:c,allowedPlacements:p=tC,autoAlignment:m=!0,...g}=Uu(e,t),b=c!==void 0||p===tC?Vre(c||null,m,p):p,k=await u.detectOverflow(t,g),y=((n=a.autoPlacement)==null?void 0:n.index)||0,v=b[y];if(v==null)return{};const w=OR(v,i,await(u.isRTL==null?void 0:u.isRTL(d.floating)));if(l!==v)return{reset:{placement:b[0]}};const j=[k[fa(v)],k[w[0]],k[w[1]]],P=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:v,overflows:j}],_=b[y+1];if(_)return{data:{index:y+1,overflows:P},reset:{placement:_}};const L=P.map(F=>{const R=_o(F.placement);return[F.placement,R&&f?F.overflows.slice(0,2).reduce((M,W)=>M+W,0):F.overflows[0],F.overflows]}).sort((F,R)=>F[1]-R[1]),D=((s=L.filter(F=>F[2].slice(0,_o(F[0])?2:3).every(R=>R<=0))[0])==null?void 0:s[0])||L[0][0];return D!==l?{data:{index:y+1,overflows:P},reset:{placement:D}}:{}}}},Kre=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:s,middlewareData:i,rects:a,initialPlacement:l,platform:u,elements:d}=t,{mainAxis:f=!0,crossAxis:c=!0,fallbackPlacements:p,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:g="none",flipAlignment:b=!0,...k}=Uu(e,t);if((n=i.arrow)!=null&&n.alignmentOffset)return{};const y=fa(s),v=Va(l),w=fa(l)===l,j=await(u.isRTL==null?void 0:u.isRTL(d.floating)),P=p||(w||!b?[wg(l)]:Lre(l)),_=g!=="none";!p&&_&&P.push(...Dre(l,b,g,j));const L=[l,...P],B=await u.detectOverflow(t,k),D=[];let F=((r=i.flip)==null?void 0:r.overflows)||[];if(f&&D.push(B[y]),c){const O=OR(s,a,j);D.push(B[O[0]],B[O[1]])}if(F=[...F,{placement:s,overflows:D}],!D.every(O=>O<=0)){var R,M;const O=(((R=i.flip)==null?void 0:R.index)||0)+1,$=L[O];if($&&(!(c==="alignment"?v!==Va($):!1)||F.every(C=>Va(C.placement)===v?C.overflows[0]>0:!0)))return{data:{index:O,overflows:F},reset:{placement:$}};let I=(M=F.filter(z=>z.overflows[0]<=0).sort((z,C)=>z.overflows[1]-C.overflows[1])[0])==null?void 0:M.placement;if(!I)switch(m){case"bestFit":{var W;const z=(W=F.filter(C=>{if(_){const T=Va(C.placement);return T===v||T==="y"}return!0}).map(C=>[C.placement,C.overflows.filter(T=>T>0).reduce((T,E)=>T+E,0)]).sort((C,T)=>C[1]-T[1])[0])==null?void 0:W[0];z&&(I=z);break}case"initialPlacement":I=l;break}if(s!==I)return{reset:{placement:I}}}return{}}}},qre=new Set(["left","top"]);async function Yre(e,t){const{placement:n,platform:r,elements:s}=e,i=await(r.isRTL==null?void 0:r.isRTL(s.floating)),a=fa(n),l=_o(n),u=Va(n)==="y",d=qre.has(a)?-1:1,f=i&&u?-1:1,c=Uu(t,e);let{mainAxis:p,crossAxis:m,alignmentAxis:g}=typeof c=="number"?{mainAxis:c,crossAxis:0,alignmentAxis:null}:{mainAxis:c.mainAxis||0,crossAxis:c.crossAxis||0,alignmentAxis:c.alignmentAxis};return l&&typeof g=="number"&&(m=l==="end"?g*-1:g),u?{x:m*f,y:p*d}:{x:p*d,y:m*f}}const Gre=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:s,y:i,placement:a,middlewareData:l}=t,u=await Yre(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:s+u.x,y:i+u.y,data:{...u,placement:a}}}}},Xre=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:s,platform:i}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:u={fn:y=>{let{x:v,y:w}=y;return{x:v,y:w}}},...d}=Uu(e,t),f={x:n,y:r},c=await i.detectOverflow(t,d),p=Va(fa(s)),m=LR(p);let g=f[m],b=f[p];if(a){const y=m==="y"?"top":"left",v=m==="y"?"bottom":"right",w=g+c[y],j=g-c[v];g=Fb(w,g,j)}if(l){const y=p==="y"?"top":"left",v=p==="y"?"bottom":"right",w=b+c[y],j=b-c[v];b=Fb(w,b,j)}const k=u.fn({...t,[m]:g,[p]:b});return{...k,data:{x:k.x-n,y:k.y-r,enabled:{[m]:a,[p]:l}}}}}};function oy(){return typeof window<"u"}function Ku(e){return $R(e)?(e.nodeName||"").toLowerCase():"#document"}function ei(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Ro(e){var t;return(t=($R(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function $R(e){return oy()?e instanceof Node||e instanceof ei(e).Node:!1}function Qi(e){return oy()?e instanceof Element||e instanceof ei(e).Element:!1}function ma(e){return oy()?e instanceof HTMLElement||e instanceof ei(e).HTMLElement:!1}function iC(e){return!oy()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ei(e).ShadowRoot}function bp(e){const{overflow:t,overflowX:n,overflowY:r,display:s}=Zi(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&s!=="inline"&&s!=="contents"}function Jre(e){return/^(table|td|th)$/.test(Ku(e))}function ay(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Qre=/transform|translate|scale|rotate|perspective|filter/,Zre=/paint|layout|strict|content/,Ml=e=>!!e&&e!=="none";let Hx;function $0(e){const t=Qi(e)?Zi(e):e;return Ml(t.transform)||Ml(t.translate)||Ml(t.scale)||Ml(t.rotate)||Ml(t.perspective)||!D0()&&(Ml(t.backdropFilter)||Ml(t.filter))||Qre.test(t.willChange||"")||Zre.test(t.contain||"")}function ese(e){let t=cl(e);for(;ma(t)&&!$u(t);){if($0(t))return t;if(ay(t))return null;t=cl(t)}return null}function D0(){return Hx==null&&(Hx=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),Hx}function $u(e){return/^(html|body|#document)$/.test(Ku(e))}function Zi(e){return ei(e).getComputedStyle(e)}function ly(e){return Qi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function cl(e){if(Ku(e)==="html")return e;const t=e.assignedSlot||e.parentNode||iC(e)&&e.host||Ro(e);return iC(t)?t.host:t}function DR(e){const t=cl(e);return $u(t)?e.ownerDocument?e.ownerDocument.body:e.body:ma(t)&&bp(t)?t:DR(t)}function Jf(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const s=DR(e),i=s===((r=e.ownerDocument)==null?void 0:r.body),a=ei(s);if(i){const l=zb(a);return t.concat(a,a.visualViewport||[],bp(s)?s:[],l&&n?Jf(l):[])}else return t.concat(s,Jf(s,[],n))}function zb(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function FR(e){const t=Zi(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const s=ma(e),i=s?e.offsetWidth:n,a=s?e.offsetHeight:r,l=yg(n)!==i||yg(r)!==a;return l&&(n=i,r=a),{width:n,height:r,$:l}}function F0(e){return Qi(e)?e:e.contextElement}function gu(e){const t=F0(e);if(!ma(t))return Eo(1);const n=t.getBoundingClientRect(),{width:r,height:s,$:i}=FR(t);let a=(i?yg(n.width):n.width)/r,l=(i?yg(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const tse=Eo(0);function zR(e){const t=ei(e);return!D0()||!t.visualViewport?tse:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function nse(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ei(e)?!1:t}function cc(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const s=e.getBoundingClientRect(),i=F0(e);let a=Eo(1);t&&(r?Qi(r)&&(a=gu(r)):a=gu(e));const l=nse(i,n,r)?zR(i):Eo(0);let u=(s.left+l.x)/a.x,d=(s.top+l.y)/a.y,f=s.width/a.x,c=s.height/a.y;if(i){const p=ei(i),m=r&&Qi(r)?ei(r):r;let g=p,b=zb(g);for(;b&&r&&m!==g;){const k=gu(b),y=b.getBoundingClientRect(),v=Zi(b),w=y.left+(b.clientLeft+parseFloat(v.paddingLeft))*k.x,j=y.top+(b.clientTop+parseFloat(v.paddingTop))*k.y;u*=k.x,d*=k.y,f*=k.x,c*=k.y,u+=w,d+=j,g=ei(b),b=zb(g)}}return bg({width:f,height:c,x:u,y:d})}function cy(e,t){const n=ly(e).scrollLeft;return t?t.left+n:cc(Ro(e)).left+n}function BR(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-cy(e,n),s=n.top+t.scrollTop;return{x:r,y:s}}function rse(e){let{elements:t,rect:n,offsetParent:r,strategy:s}=e;const i=s==="fixed",a=Ro(r),l=t?ay(t.floating):!1;if(r===a||l&&i)return n;let u={scrollLeft:0,scrollTop:0},d=Eo(1);const f=Eo(0),c=ma(r);if((c||!c&&!i)&&((Ku(r)!=="body"||bp(a))&&(u=ly(r)),c)){const m=cc(r);d=gu(r),f.x=m.x+r.clientLeft,f.y=m.y+r.clientTop}const p=a&&!c&&!i?BR(a,u):Eo(0);return{width:n.width*d.x,height:n.height*d.y,x:n.x*d.x-u.scrollLeft*d.x+f.x+p.x,y:n.y*d.y-u.scrollTop*d.y+f.y+p.y}}function sse(e){return Array.from(e.getClientRects())}function ise(e){const t=Ro(e),n=ly(e),r=e.ownerDocument.body,s=Ql(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),i=Ql(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+cy(e);const l=-n.scrollTop;return Zi(r).direction==="rtl"&&(a+=Ql(t.clientWidth,r.clientWidth)-s),{width:s,height:i,x:a,y:l}}const oC=25;function ose(e,t){const n=ei(e),r=Ro(e),s=n.visualViewport;let i=r.clientWidth,a=r.clientHeight,l=0,u=0;if(s){i=s.width,a=s.height;const f=D0();(!f||f&&t==="fixed")&&(l=s.offsetLeft,u=s.offsetTop)}const d=cy(r);if(d<=0){const f=r.ownerDocument,c=f.body,p=getComputedStyle(c),m=f.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,g=Math.abs(r.clientWidth-c.clientWidth-m);g<=oC&&(i-=g)}else d<=oC&&(i+=d);return{width:i,height:a,x:l,y:u}}function ase(e,t){const n=cc(e,!0,t==="fixed"),r=n.top+e.clientTop,s=n.left+e.clientLeft,i=ma(e)?gu(e):Eo(1),a=e.clientWidth*i.x,l=e.clientHeight*i.y,u=s*i.x,d=r*i.y;return{width:a,height:l,x:u,y:d}}function aC(e,t,n){let r;if(t==="viewport")r=ose(e,n);else if(t==="document")r=ise(Ro(e));else if(Qi(t))r=ase(t,n);else{const s=zR(e);r={x:t.x-s.x,y:t.y-s.y,width:t.width,height:t.height}}return bg(r)}function HR(e,t){const n=cl(e);return n===t||!Qi(n)||$u(n)?!1:Zi(n).position==="fixed"||HR(n,t)}function lse(e,t){const n=t.get(e);if(n)return n;let r=Jf(e,[],!1).filter(l=>Qi(l)&&Ku(l)!=="body"),s=null;const i=Zi(e).position==="fixed";let a=i?cl(e):e;for(;Qi(a)&&!$u(a);){const l=Zi(a),u=$0(a);!u&&l.position==="fixed"&&(s=null),(i?!u&&!s:!u&&l.position==="static"&&!!s&&(s.position==="absolute"||s.position==="fixed")||bp(a)&&!u&&HR(e,a))?r=r.filter(f=>f!==a):s=l,a=cl(a)}return t.set(e,r),r}function cse(e){let{element:t,boundary:n,rootBoundary:r,strategy:s}=e;const a=[...n==="clippingAncestors"?ay(t)?[]:lse(t,this._c):[].concat(n),r],l=aC(t,a[0],s);let u=l.top,d=l.right,f=l.bottom,c=l.left;for(let p=1;p<a.length;p++){const m=aC(t,a[p],s);u=Ql(m.top,u),d=Mu(m.right,d),f=Mu(m.bottom,f),c=Ql(m.left,c)}return{width:d-c,height:f-u,x:c,y:u}}function use(e){const{width:t,height:n}=FR(e);return{width:t,height:n}}function dse(e,t,n){const r=ma(t),s=Ro(t),i=n==="fixed",a=cc(e,!0,i,t);let l={scrollLeft:0,scrollTop:0};const u=Eo(0);function d(){u.x=cy(s)}if(r||!r&&!i)if((Ku(t)!=="body"||bp(s))&&(l=ly(t)),r){const m=cc(t,!0,i,t);u.x=m.x+t.clientLeft,u.y=m.y+t.clientTop}else s&&d();i&&!r&&s&&d();const f=s&&!r&&!i?BR(s,l):Eo(0),c=a.left+l.scrollLeft-u.x-f.x,p=a.top+l.scrollTop-u.y-f.y;return{x:c,y:p,width:a.width,height:a.height}}function Wx(e){return Zi(e).position==="static"}function lC(e,t){if(!ma(e)||Zi(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Ro(e)===n&&(n=n.ownerDocument.body),n}function WR(e,t){const n=ei(e);if(ay(e))return n;if(!ma(e)){let s=cl(e);for(;s&&!$u(s);){if(Qi(s)&&!Wx(s))return s;s=cl(s)}return n}let r=lC(e,t);for(;r&&Jre(r)&&Wx(r);)r=lC(r,t);return r&&$u(r)&&Wx(r)&&!$0(r)?n:r||ese(e)||n}const fse=async function(e){const t=this.getOffsetParent||WR,n=this.getDimensions,r=await n(e.floating);return{reference:dse(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function pse(e){return Zi(e).direction==="rtl"}const hse={convertOffsetParentRelativeRectToViewportRelativeRect:rse,getDocumentElement:Ro,getClippingRect:cse,getOffsetParent:WR,getElementRects:fse,getClientRects:sse,getDimensions:use,getScale:gu,isElement:Qi,isRTL:pse};function VR(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function mse(e,t){let n=null,r;const s=Ro(e);function i(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),i();const d=e.getBoundingClientRect(),{left:f,top:c,width:p,height:m}=d;if(l||t(),!p||!m)return;const g=zh(c),b=zh(s.clientWidth-(f+p)),k=zh(s.clientHeight-(c+m)),y=zh(f),w={rootMargin:-g+"px "+-b+"px "+-k+"px "+-y+"px",threshold:Ql(0,Mu(1,u))||1};let j=!0;function P(_){const L=_[0].intersectionRatio;if(L!==u){if(!j)return a();L?a(!1,L):r=setTimeout(()=>{a(!1,1e-7)},1e3)}L===1&&!VR(d,e.getBoundingClientRect())&&a(),j=!1}try{n=new IntersectionObserver(P,{...w,root:s.ownerDocument})}catch{n=new IntersectionObserver(P,w)}n.observe(e)}return a(!0),i}function cC(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:i=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,d=F0(e),f=s||i?[...d?Jf(d):[],...t?Jf(t):[]]:[];f.forEach(y=>{s&&y.addEventListener("scroll",n,{passive:!0}),i&&y.addEventListener("resize",n)});const c=d&&l?mse(d,n):null;let p=-1,m=null;a&&(m=new ResizeObserver(y=>{let[v]=y;v&&v.target===d&&m&&t&&(m.unobserve(t),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var w;(w=m)==null||w.observe(t)})),n()}),d&&!u&&m.observe(d),t&&m.observe(t));let g,b=u?cc(e):null;u&&k();function k(){const y=cc(e);b&&!VR(b,y)&&n(),b=y,g=requestAnimationFrame(k)}return n(),()=>{var y;f.forEach(v=>{s&&v.removeEventListener("scroll",n),i&&v.removeEventListener("resize",n)}),c==null||c(),(y=m)==null||y.disconnect(),m=null,u&&cancelAnimationFrame(g)}}const gse=Gre,yse=Ure,xse=Xre,wse=Kre,uC=Wre,bse=(e,t,n)=>{const r=new Map,s={platform:hse,...n},i={...s.platform,_c:r};return Hre(e,t,{...s,platform:i})};var vse=typeof document<"u",kse=function(){},pm=vse?h.useLayoutEffect:kse;function vg(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(!vg(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 i=s[r];if(!(i==="_owner"&&e.$$typeof)&&!vg(e[i],t[i]))return!1}return!0}return e!==e&&t!==t}function UR(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function dC(e,t){const n=UR(e);return Math.round(t*n)/n}function Vx(e){const t=h.useRef(e);return pm(()=>{t.current=e}),t}function fC(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:s,elements:{reference:i,floating:a}={},transform:l=!0,whileElementsMounted:u,open:d}=e,[f,c]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[p,m]=h.useState(r);vg(p,r)||m(r);const[g,b]=h.useState(null),[k,y]=h.useState(null),v=h.useCallback(C=>{C!==_.current&&(_.current=C,b(C))},[]),w=h.useCallback(C=>{C!==L.current&&(L.current=C,y(C))},[]),j=i||g,P=a||k,_=h.useRef(null),L=h.useRef(null),B=h.useRef(f),D=u!=null,F=Vx(u),R=Vx(s),M=Vx(d),W=h.useCallback(()=>{if(!_.current||!L.current)return;const C={placement:t,strategy:n,middleware:p};R.current&&(C.platform=R.current),bse(_.current,L.current,C).then(T=>{const E={...T,isPositioned:M.current!==!1};O.current&&!vg(B.current,E)&&(B.current=E,Or.flushSync(()=>{c(E)}))})},[p,t,n,R,M]);pm(()=>{d===!1&&B.current.isPositioned&&(B.current.isPositioned=!1,c(C=>({...C,isPositioned:!1})))},[d]);const O=h.useRef(!1);pm(()=>(O.current=!0,()=>{O.current=!1}),[]),pm(()=>{if(j&&(_.current=j),P&&(L.current=P),j&&P){if(F.current)return F.current(j,P,W);W()}},[j,P,W,F,D]);const $=h.useMemo(()=>({reference:_,floating:L,setReference:v,setFloating:w}),[v,w]),I=h.useMemo(()=>({reference:j,floating:P}),[j,P]),z=h.useMemo(()=>{const C={position:n,left:0,top:0};if(!I.floating)return C;const T=dC(I.floating,f.x),E=dC(I.floating,f.y);return l?{...C,transform:"translate("+T+"px, "+E+"px)",...UR(I.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:T,top:E}},[n,l,I.floating,f.x,f.y]);return h.useMemo(()=>({...f,update:W,refs:$,elements:I,floatingStyles:z}),[f,W,$,I,z])}const Sse=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?uC({element:r.current,padding:s}).fn(n):{}:r?uC({element:r,padding:s}).fn(n):{}}}},pC=(e,t)=>{const n=gse(e);return{name:n.name,fn:n.fn,options:[e,t]}},Nse=(e,t)=>{const n=xse(e);return{name:n.name,fn:n.fn,options:[e,t]}},jse=(e,t)=>{const n=wse(e);return{name:n.name,fn:n.fn,options:[e,t]}},Cse=(e,t)=>{const n=yse(e);return{name:n.name,fn:n.fn,options:[e,t]}},Ese=(e,t)=>{const n=Sse(e);return{name:n.name,fn:n.fn,options:[e,t]}},_se={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},Pse={beaconOptions:{offset:-18}},KR={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},Ase={isFixed:!1,locale:KR,placement:"bottom"},Ise={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},$t={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},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"},Ke={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},xo={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},It={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},Tse="react-joyride-portal";function Rse(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function su(...e){return Sre({all:!0,isMergeableObject:t=>!(!Qr.plainObject(t)||h.isValidElement(t))})(...e)}function qR(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function Zo(e,t={}){const{defaultValue:n,step:r,steps:s}=t;let i=Bx(e);if(i)(i.includes("{current}")||i.includes("{total}"))&&r&&s&&(i=i.replace("{current}",r.toString()).replace("{total}",s.toString()));else if(h.isValidElement(e)&&!Object.values(e.props).length&&qR(e.type)==="function")try{i=Zo(e.type({}),t)}catch{i=Bx(n)}else i=Bx(n);return i}function _r(e,t,n,...r){if(!e)return;const s=new Date,i=`${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 ${i}`,"font-weight: bold","color: gray; font-weight: normal",...r)}function Lse(e,t){const n=Rse(t);return{...e,...n}}function Qf(){}function Ose(e){return Object.keys(e)}function kg(e,...t){if(!Qr.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 hC(e,...t){if(!Qr.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 Bb(e,t,n){const r=i=>i.replace("{current}",String(t)).replace("{total}",String(n));if(qR(e)==="string")return r(e);if(!h.isValidElement(e))return e;const{children:s}=e.props;if(Qr.string(s)&&s.includes("{current}"))return h.cloneElement(e,{children:r(s)});if(Array.isArray(s))return h.cloneElement(e,{children:s.map(i=>typeof i=="string"?r(i):Bb(i,t,n))});if(Qr.function(e.type)&&!Object.values(e.props).length)try{return Bb(e.type({}),t,n)}catch{return e}return e}function mC(e){return Ose(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function z0(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function gC(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 B0(e){return e?e.getBoundingClientRect():null}function Mse(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((i,a)=>i-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 Si(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 $se(e,t,n){const r=B0(e),s=qu(e),i=s?!s.isSameNode(As()):!1,a=n??Yu(e);let l=0,u=(r==null?void 0:r.top)??0;return i&&a?u=(r==null?void 0:r.top)??0:s instanceof HTMLElement&&(l=s.scrollTop,!i&&!a&&(u+=l),s.isSameNode(As())||(u+=As().scrollTop)),Math.floor(u-t)}function qu(e,t){if(!e)return As();const n=RR(e);if(n){if(n.isSameNode(As()))return t?document:As();if(!(n.scrollHeight>n.offsetHeight))return As()}return n}function Dse(e){const t=e.getBoundingClientRect(),n=As(),r=t.top+t.height/2,s=window.innerHeight/2;return Math.max(0,n.scrollTop+r-s)}function Fse(e,t){if(!e)return 0;const n=RR(e)??As(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,s=B0(n),i=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let u=e.getBoundingClientRect().top+l;if(a&&(YR(e)||zse(e))){const f=e.getBoundingClientRect(),c=f.top-((s==null?void 0:s.top)??0),p=c+f.height,m=n.clientHeight,g=m*.2;c>=g&&p<=m-g?u=i:u=c+i}const d=Math.floor(u-t-r);return d<0?0:d}function zse(e){return e.offsetParent!==document.body}function YR(e){if(!e)return!1;const t=qu(e);return t?!t.isSameNode(As()):!1}function Yu(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?Yu(e.parentNode,t):!1}function Bh(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 yC(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:s,targetLifecycle:i}=e;if(r.skipScroll||t&&!n&&i!==Ke.TOOLTIP||r.placement==="center")return!1;const a=s!=null&&s.isConnected?qu(s):As(),l=a?!a.isSameNode(As()):!1;return(r.isFixed||Yu(s))&&!l?!1:a.scrollHeight>a.clientHeight}function As(){return document.scrollingElement??document.documentElement}function xC(e,t){const{duration:n,element:r}=t;let s=()=>{};const i=new Promise(a=>{const{scrollTop:l}=r,u=e>l?e-l:l-e;s=Are.top(r,e,{duration:u<100?50:n},()=>{a()})});return{cancel:s,promise:i}}function Bse(e){const t=e.replace(/^#?([\da-f])([\da-f])([\da-f])$/i,(r,s,i,a)=>s+s+i+i+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 GR={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},Hh={...GR,borderRadius:4,padding:8};function Hse(e,t){const{styles:n}=e,r=su(n??{},t.styles??{});let{width:s}=t;z0()&&(s=typeof s=="number"&&window.innerWidth<s?window.innerWidth-30:s);const i={bottom:0,left:0,overflow:"hidden",position:"absolute",right:0,top:0,zIndex:t.zIndex};return su({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...GR,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(${Bse(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:{...Hh,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...Hh,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...Hh,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...Hh,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:{...i,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 Wse=["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 H0(e,t){if(!t)return null;const n=su(Ase,hC(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=su(_se,e.options??{},hC(t,...Wse)),s=Hse(e,{...n,...r}),i=su(Pse,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:su(KR,e.locale??{},n.locale||{}),floatingOptions:i,spotlightPadding:Vse(r.spotlightPadding),styles:s}}function Vse(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 Use(e,t,n){const{action:r}=t,s=n&&[$t.PREV,$t.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||s}function XR(e,t=!1){return Qr.plainObject(e)?e.target?!0:(_r(t,"tour","target is missing from the step"),!1):(_r(t,"tour","step must be an object"),!1)}function JR(e,t=!1){return Qr.array(e)?e.every(n=>XR(n,t)):(_r(t,"tour","steps must be an array"),!1)}var Kse=class{constructor(e){er(this,"beaconPosition",null);er(this,"debug");er(this,"eventListeners",new Map);er(this,"listeners",new Set);er(this,"props");er(this,"snapshot");er(this,"state");er(this,"steps");er(this,"tooltipPosition",null);er(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});er(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);er(this,"getServerSnapshot",()=>this.snapshot);er(this,"getSnapshot",()=>this.snapshot);er(this,"getEventState",()=>kg(this.snapshot,"positioned"));er(this,"getState",()=>kg(this.snapshot,"positioned"));er(this,"setPositionData",(e,t)=>{var r,s,i;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&_r(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===Ke.BEACON_BEFORE||this.state.lifecycle===Ke.TOOLTIP_BEFORE)&&!this.state.positioned&&this.updateState({positioned:!0});const n=(i=(s=this.getStep())==null?void 0:s.floatingOptions)==null?void 0:i.onPosition;n&&n(t)});er(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});er(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});er(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)}});er(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));er(this,"updateState",(e,t=!1)=>{const{controlled:n,index:r}=this.state,s=this.snapshot,i=n&&!t&&e.index!==void 0?r:e.index??r,a={action:e.action??this.state.action,controlled:n,index:i,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,!I0(s,l)){this.snapshot=Object.freeze({...l});for(const u of this.listeners)u(this.snapshot)}});const{initialStepIndex:t,stepIndex:n,steps:r=[]}=e??{},s=Qr.number(n);let i=0;this.debug=(e==null?void 0:e.debug)??!1,s?(i=n,Qr.number(t)&&_r(this.debug,"tour","initialStepIndex is ignored in controlled mode")):Qr.number(t)&&(t>=0&&t<r.length?i=t:r.length>0&&_r(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:$t.INIT,controlled:s,index:i,lifecycle:Ke.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?It.READY:It.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===It.WAITING&&e.size>0?{...e,status:It.RUNNING}:e}getStep(e){return H0(this.props,this.steps[e??this.state.index])}};function qse(e){return new Kse(e)}function wC(e,t){return Math.min(Math.max(e,0),t)}function Yse(e,t,n){const r=h.useRef(t),s=h.useRef(n);return r.current=t,s.current=n,h.useMemo(()=>{const i=()=>e.current.getSnapshot();return{close:(k=null)=>{const{index:y,status:v}=i();v===It.RUNNING&&e.current.updateState({action:$t.CLOSE,index:y+1,origin:k,lifecycle:Ke.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:k=>{const{controlled:y,size:v,status:w}=i();if(y){_r(r.current,"tour","go() is not supported in controlled mode");return}w===It.RUNNING&&e.current.updateState({action:$t.GO,index:k,lifecycle:Ke.COMPLETE,positioned:!1,scrolling:!1,status:k<v?w:It.FINISHED,waiting:!1})},info:()=>kg(e.current.getSnapshot(),"positioned"),next:k=>{const{index:y,size:v,status:w}=i();w===It.RUNNING&&e.current.updateState({action:$t.NEXT,index:wC(y+1,v),lifecycle:Ke.COMPLETE,origin:k,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:k}=i();k===It.RUNNING&&e.current.updateState({action:$t.UPDATE,lifecycle:Ke.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:k=>{const{index:y,size:v,status:w}=i();w===It.RUNNING&&e.current.updateState({action:$t.PREV,index:wC(y-1,v),lifecycle:Ke.COMPLETE,origin:k,positioned:!1,scrolling:!1,waiting:!1})},reset:(k=!1)=>{const{controlled:y}=i();if(y){_r(r.current,"tour","reset() is not supported in controlled mode");return}s.current(),e.current.updateState({action:$t.RESET,index:0,lifecycle:Ke.INIT,positioned:!1,scrolling:!1,status:k?It.RUNNING:It.READY,waiting:!1})},skip:k=>{const{status:y}=i();y===It.RUNNING&&e.current.updateState({action:$t.SKIP,lifecycle:Ke.COMPLETE,origin:k,positioned:!1,scrolling:!1,status:It.SKIPPED,waiting:!1})},start:k=>{const{index:y,size:v}=i();s.current(),e.current.updateState({action:$t.START,index:Qr.number(k)?k:y,lifecycle:Ke.INIT,positioned:!1,scrolling:!1,status:v?It.RUNNING:It.WAITING,waiting:!1},!0)},stop:(k=!1)=>{const{index:y,status:v}=i();[It.FINISHED,It.SKIPPED].includes(v)||e.current.updateState({action:$t.STOP,index:y+(k?1:0),lifecycle:Ke.COMPLETE,positioned:!1,scrolling:!1,status:It.PAUSED,waiting:!1})}}},[e])}const Gse=new Set(["origin","positioned"]);function Xse(e,t){const n=h.useRef(null);h.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return _r(!0,"tour","init",r),n.current=r,e.current.subscribe(s=>{const i=n.current;if(n.current=s,!i)return;const a={};let l=!1;for(const u of Object.keys(s))s[u]!==i[u]&&!Gse.has(u)&&(a[u]={from:i[u],to:s[u]},(u==="status"||u==="size")&&(l=!0));Object.keys(a).length&&(!l&&s.index>=s.size||_r(!0,l?"tour":`step:${s.index}`,"state",a))})},[t,e])}function Jse(e,t,n){const r=h.useRef(e),s=h.useRef(t);return r.current=e,s.current=t,h.useCallback((i,a,l)=>{var d;const u={...n.current.getEventState(),error:null,scroll:null,step:a,type:i,...l};(d=r.current)==null||d.call(r,u,s.current),n.current.dispatch(u,s.current)},[n])}function $a(e,t){return{hasChanged(n){return e[n]!==t[n]},hasChangedTo(n,r){const s=e[n],i=t[n];return Array.isArray(r)?r.includes(s)&&!r.includes(i):s===r&&i!==r},previous:t}}function Qse(e){const{addFailure:t,controls:n,emitEvent:r,previousState:s,props:i,state:a,step:l,store:u}=e,{action:d,index:f,lifecycle:c,positioned:p,scrolling:m,size:g,status:b}=a,k=jR(l)??null,y=h.useRef(null),v=h.useRef(i),w=h.useRef(a),j=h.useRef(s),P=h.useRef(l),_=h.useRef(k),L=h.useRef(n),B=h.useRef(null),D=h.useRef(null),F=h.useRef(null);v.current=i,w.current=a,j.current=s,P.current=l,_.current=k,L.current=n;const R=()=>{B.current&&(clearInterval(B.current),B.current=null),D.current=null,F.current&&(F.current.cancel(),F.current=null)};h.useEffect(()=>{if(!j.current)return;const{hasChangedTo:M}=$a(w.current,j.current);(M("action",[$t.NEXT,$t.PREV,$t.SKIP,$t.CLOSE])||y.current===$t.CLOSE&&d===$t.START)&&(y.current=d)},[d]),h.useEffect(()=>{if(!j.current)return()=>{R()};const{hasChanged:M}=$a(w.current,j.current),W=P.current;if(M("index")&&R(),b!==It.RUNNING||!W||c!==Ke.INIT)return()=>{R()};const{hasChangedTo:O}=$a(w.current,j.current);O("status",It.RUNNING)&&[It.IDLE,It.READY,It.PAUSED].includes(j.current.status)&&r(Cr.TOUR_START,W),u.current.cleanupPositionData();const{debug:$}=v.current;if(W.before&&!F.current){_r($,`step:${f}`,"before()",W),F.current={cancel:()=>{}},u.current.updateState({waiting:!0}),r(Cr.STEP_BEFORE_HOOK,W,{action:y.current??w.current.action});const I=()=>{F.current=null,u.current.updateState({action:y.current??w.current.action,waiting:!1,lifecycle:Ke.READY})},z=new AbortController,C=W.beforeTimeout;F.current={cancel:()=>z.abort()};const T=C?setTimeout(()=>{z.signal.aborted||(_r($,`step:${f}`,"before()","timed out",`${C}ms`),z.abort(),t(W,"before_hook"),r(Cr.ERROR,W,{error:new Error("Step before hook timed out")}),I())},C):null;W.before({...u.current.getState(),action:y.current??u.current.getState().action,step:W}).then(()=>{z.signal.aborted||(T&&clearTimeout(T),I())}).catch(E=>{z.signal.aborted||(T&&clearTimeout(T),t(W,"before_hook"),r(Cr.ERROR,W,{error:E instanceof Error?E:new Error(String(E))}),I())})}else if(!F.current){B.current&&D.current!==W.target&&R();const I=Si(W.target);if(I&&Bh(I))R(),u.current.updateState({action:y.current??$t.UPDATE,lifecycle:Ke.READY,waiting:!1});else if(W.targetWaitTimeout===0)u.current.updateState({action:y.current??$t.UPDATE,lifecycle:Ke.READY,waiting:!1});else if(!B.current){const{targetWaitTimeout:z}=W,C=Date.now();D.current=W.target,_r($,`step:${f}`,"polling","started",`${z}ms`),u.current.updateState({waiting:!0}),B.current=setInterval(()=>{const T=Si(W.target),E=Date.now()-C,G=E>=z;(T&&Bh(T)||G)&&(_r($,`step:${f}`,"polling",T&&Bh(T)?"found":"timed out",`${E}ms`),R(),u.current.updateState({action:y.current??$t.UPDATE,lifecycle:Ke.READY,waiting:!1}))},100)}}return()=>{R()}},[t,r,f,c,b,u]),h.useEffect(()=>{if(!j.current)return;const{hasChanged:M,hasChangedTo:W,previous:O}=$a(w.current,j.current),$=P.current;if(!$)return;const I=Si($.target),z=!!I;if(z&&Bh(I)){if(W("lifecycle",Ke.READY)&&O.lifecycle===Ke.INIT&&r(Cr.STEP_BEFORE,$,{action:y.current??w.current.action}),W("lifecycle",Ke.READY)){const C=w.current,T=Use($,C,v.current.continuous)?Ke.TOOLTIP:Ke.BEACON,E=Si($.scrollTarget??$.spotlightTarget??$.target),G=yC({isFirstStep:C.index===0,scrollToFirstStep:v.current.scrollToFirstStep,step:$,target:E,targetLifecycle:T}),Z=T===Ke.TOOLTIP?Ke.TOOLTIP_BEFORE:Ke.BEACON_BEFORE;_r(v.current.debug,`step:${f}`,"scroll",G?"needed":"skipped"),u.current.updateState({action:$t.UPDATE,lifecycle:Z,scrolling:G})}}else if(w.current.status===It.RUNNING&&c!==Ke.INIT&&c!==Ke.COMPLETE&&M("lifecycle")){_r(v.current.debug,`step:${f}`,z?"Target not visible":"Target not mounted",$),t($,"target_not_found"),r(Cr.TARGET_NOT_FOUND,$);const C=w.current;C.controlled||u.current.updateState({action:$t.UPDATE,index:C.index+(C.action===$t.PREV?-1:1),lifecycle:Ke.INIT})}},[t,r,f,c,u]),h.useEffect(()=>{if(!j.current)return;const{hasChangedTo:M,previous:W}=$a(w.current,j.current),O=P.current,$=_.current;if(O&&M("lifecycle",Ke.TOOLTIP_BEFORE)&&W.lifecycle===Ke.BEACON){const C=Si(O.scrollTarget??O.spotlightTarget??O.target);if(yC({isFirstStep:w.current.index===0,scrollToFirstStep:v.current.scrollToFirstStep,step:O,target:C,targetLifecycle:Ke.TOOLTIP})){u.current.updateState({scrolling:!0,positioned:!1});return}}const I=c===Ke.BEACON_BEFORE||c===Ke.TOOLTIP_BEFORE;if(O&&I&&!m){const C=c===Ke.TOOLTIP_BEFORE?Ke.TOOLTIP:Ke.BEACON;u.current.updateState({action:$t.UPDATE,lifecycle:C})}O&&M("lifecycle",Ke.BEACON)&&r(Cr.BEACON,O),O&&M("lifecycle",Ke.TOOLTIP)&&r(Cr.TOOLTIP,O);const z=w.current;if((z.status===It.RUNNING||z.controlled&&z.status===It.PAUSED&&O)&&$&&M("lifecycle",Ke.COMPLETE)&&W.lifecycle===Ke.TOOLTIP&&(r(Cr.STEP_AFTER,$,{action:y.current??$t.UPDATE,index:W.index??z.index,lifecycle:z.lifecycle}),$.after)){r(Cr.STEP_AFTER_HOOK,$,{action:y.current??$t.UPDATE,index:W.index??z.index,lifecycle:z.lifecycle});try{$.after({...u.current.getState(),action:y.current??$t.UPDATE,index:W.index??z.index,lifecycle:z.lifecycle,step:$})}catch{}}},[r,c,p,m,u]),h.useEffect(()=>{if(!j.current)return;const{hasChangedTo:M,previous:W}=$a(w.current,j.current),O=P.current,$=_.current;g&&!O&&c===Ke.INIT&&u.current.updateState({action:$t.UPDATE,lifecycle:Ke.COMPLETE,status:It.FINISHED}),!w.current.controlled&&b===It.RUNNING&&M("lifecycle",Ke.COMPLETE)&&f<g&&u.current.updateState({action:$t.UPDATE,lifecycle:Ke.INIT}),M("lifecycle",Ke.COMPLETE)&&f>=g&&u.current.updateState({action:$t.UPDATE,lifecycle:Ke.COMPLETE,status:It.FINISHED});const I=O??$??H0(v.current,v.current.steps[f-1]);if(I&&M("status",[It.FINISHED,It.SKIPPED])){let z;O?z=f:$?z=W.index??f:z=f-1,r(Cr.TOUR_END,I,{index:z}),w.current.controlled||L.current.reset(),y.current=null}O&&M("action",$t.STOP)&&(y.current=null,r(Cr.TOUR_STATUS,O)),O&&M("action",$t.RESET)&&(r(Cr.TOUR_STATUS,O),y.current=null)},[d,r,f,c,g,b,u])}function Zse({controls:e,emitEvent:t,props:n,state:r,store:s}){const{debug:i,initialStepIndex:a,run:l,stepIndex:u,steps:d}=n,f=h.useRef(void 0),c=h.useRef(r),p=h.useRef(e);c.current=r,p.current=e,h.useEffect(()=>{const m=f.current;if(f.current=n,!m||n===m)return;const{hasChanged:g}=$a(n,m);if(I0(m.steps,d)||(JR(d,i)?s.current.setSteps(d):(_r(i,"tour","Steps are not valid",d),t(Cr.ERROR,d[0]??{target:"",content:""},{error:new Error("Steps are not valid")}))),g("run"))l?s.current.getState().size&&p.current.start(u??a):p.current.stop();else if(Qr.number(u)&&g("stepIndex")){const b=Qr.number(m.stepIndex)&&m.stepIndex<u?$t.NEXT:$t.PREV;[It.FINISHED,It.SKIPPED].includes(c.current.status)||s.current.updateState({action:b,index:u,lifecycle:Ke.INIT,positioned:!1},!0)}},[i,t,a,n,l,u,d,s])}function eie(e,t){var l,u,d,f;const{beaconPosition:n,lifecycle:r,scrollOffset:s,step:i}=t;if(i.scrollTarget||i.spotlightTarget)return Math.max(0,e);let a=e-i.spotlightPadding.top;if(r===Ke.BEACON_BEFORE&&(n!=null&&n.placement)){const c=tie(n);["bottom"].includes(n.placement)||(a+=Math.floor(c-s))}else if(r===Ke.TOOLTIP_BEFORE){const{placement:c}=i;if(c==="top"){const p=((l=document.querySelector(".react-joyride__floater"))==null?void 0:l.getBoundingClientRect().height)??0,m=(u=i.floatingOptions)!=null&&u.hideArrow?0:i.arrowSize,g=i.offset+i.spotlightPadding.top+m;a-=p+g}else if(c==="left"||c==="right"){const p=((d=document.querySelector(".react-joyride__floater"))==null?void 0:d.getBoundingClientRect().height)??0,m=((f=Si(i.target))==null?void 0:f.getBoundingClientRect().height)??0,g=s+i.spotlightPadding.top+m/2-p/2;g<s&&(a-=s-g)}}return Math.max(0,a)}function tie(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 nie({emitEvent:e,previousState:t,props:n,state:r,step:s,store:i}){const{index:a,lifecycle:l,positioned:u,scrolling:d,status:f}=r,c=h.useRef(null),p=h.useRef(r),m=h.useRef(t),g=h.useRef(n),b=h.useRef(s);p.current=r,m.current=t,g.current=n,b.current=s,h.useEffect(()=>()=>{var k;(k=c.current)==null||k.call(c)},[]),h.useEffect(()=>{var P;if(!m.current||!b.current)return;const{hasChangedTo:k}=$a(p.current,m.current),y=b.current,{debug:v}=g.current,{scrollDuration:w}=y,j=l===Ke.BEACON_BEFORE||l===Ke.TOOLTIP_BEFORE;if(f===It.RUNNING&&j&&d&&k("positioned",!0)){const _=Si(y.scrollTarget??y.spotlightTarget??y.target),L=i.current.getPositionData("beacon"),B=qu(_),D=B?!B.isSameNode(As()):!1;(P=c.current)==null||P.call(c),(async()=>{if(D&&!Yu(B)){const z=As(),C=Dse(B),T={initial:z.scrollTop,target:C,element:z,duration:w};e(Cr.SCROLL_START,y,{scroll:T});const{cancel:E,promise:G}=xC(C,{element:z,duration:w});c.current=E,await G,e(Cr.SCROLL_END,y,{scroll:T})}const R=Math.floor(Fse(_,y.scrollOffset))||0,M=D?R:eie(R,{beaconPosition:L,lifecycle:l,scrollOffset:y.scrollOffset,step:y});_r(v,`step:${a}`,"scroll",D?"custom":"document",`${R} → ${M}`);const W=B,O={initial:W.scrollTop,target:M,element:W,duration:w};e(Cr.SCROLL_START,y,{scroll:O});const{cancel:$,promise:I}=xC(M,{element:W,duration:w});c.current=$,await I,e(Cr.SCROLL_END,y,{scroll:O}),i.current.updateState({scrolling:!1})})().catch(()=>{i.current.updateState({scrolling:!1})})}},[e,a,l,u,d,f,i])}function rie(e){const t=Fne(()=>Lse(Ise,e),[e]),{debug:n,initialStepIndex:r,onEvent:s,run:i,stepIndex:a,steps:l}=t,u=h.useRef(qse(t)),d=hA.useSyncExternalStore(u.current.subscribe,u.current.getSnapshot,u.current.getServerSnapshot),[f,c]=h.useState([]),p=h.useCallback((P,_)=>{c(L=>[...L,{reason:_,step:P}])},[]),m=h.useCallback(()=>{c([])},[]);Xse(u,n);const g=Yse(u,n,m),b=Jse(s,g,u),{index:k,size:y,status:v}=d,w=jR(d),j=h.useMemo(()=>H0(t,l[k]),[k,t,l]);return zne(()=>{i&&y&&JR(l,n)&&g.start(a??r)}),Dne(()=>{i&&y&&v===It.IDLE&&u.current.updateState({status:It.READY})},[i,y,v]),Zse({controls:g,emitEvent:b,props:t,state:d,store:u}),Qse({addFailure:p,controls:g,emitEvent:b,previousState:w,props:t,state:d,step:j,store:u}),nie({emitEvent:b,previousState:w,props:t,state:d,step:j,store:u}),{controls:g,failures:f,mergedProps:t,state:d,step:j,store:u}}function sie(e){const[t,n]=h.useState(null);return h.useEffect(()=>{let r=null,s=!1;if(e)if(Qr.domElement(e))r=e,s=!0;else{const i=document.querySelector(e);i&&(r=i)}else{const i=document.createElement("div");i.id=Tse,document.body.appendChild(i),r=i}return n(r),()=>{!r||s||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const iie={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function oie({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(h.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return Qf;const u=document.createElement("style");return u.id="joyride-loader-animation",e&&u.setAttribute("nonce",e),u.appendChild(document.createTextNode(`
209
- @keyframes joyride-loader-spin {
210
- to { transform: rotate(360deg); }
211
- }
212
- `)),document.head.appendChild(u),()=>{const d=document.getElementById("joyride-loader-animation");d!=null&&d.parentNode&&d.parentNode.removeChild(d)}},[r,e]),n===null)return null;const{height:s,width:i,...a}=t.styles.loader;let l;if(n){const u=n;l=lt.createElement(u,{step:t})}else l=lt.createElement("div",{style:{...iie,height:s,width:i,borderTopColor:t.primaryColor}});return lt.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const aie={height:0,isFixed:!1,left:0,top:0,width:0};function Od(e,t){const n=Si(e);if(!n)return aie;const r=B0(n),s=Yu(n),i=$se(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:i,width:Math.round(((r==null?void 0:r.width)??0)+t.left+t.right)}}function lie(e,t,n){const[r,s]=h.useState(()=>Od(e,t)),i=h.useRef(void 0),a=h.useRef(null),l=h.useRef(n),u=h.useRef(null),d=h.useCallback(()=>{clearTimeout(i.current),i.current=window.setTimeout(()=>{s(c=>{const p=Od(e,t);return c.top===p.top&&c.left===p.left&&c.width===p.width&&c.height===p.height&&c.isFixed===p.isFixed?c:p})},100)},[e,t]);h.useEffect(()=>{let c=null;const p=g=>{a.current=qu(g,!0),a.current&&a.current.addEventListener("scroll",d,{passive:!0}),window.addEventListener("scroll",d,{passive:!0}),window.addEventListener("resize",d),typeof ResizeObserver<"u"&&(u.current=new ResizeObserver(d),u.current.observe(g)),s(Od(e,t))},m=Si(e);return m?p(m):(c=new MutationObserver(()=>{const g=Si(e);g&&(c==null||c.disconnect(),c=null,p(g))}),c.observe(document.body,{childList:!0,subtree:!0})),()=>{var g;c==null||c.disconnect(),a.current&&a.current.removeEventListener("scroll",d),window.removeEventListener("scroll",d),window.removeEventListener("resize",d),(g=u.current)==null||g.disconnect(),clearTimeout(i.current)}},[e,t,d]),h.useEffect(()=>{l.current&&!n&&s(Od(e,t)),l.current=n},[n,e,t]);let f=r;return l.current&&!n&&(f=Od(e,t)),f}function cie(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function bC(e,t,n,r,s){if(n<=0||r<=0)return"";const i=Math.max(0,Math.min(s,n/2,r/2));let a=`M${e+i} ${t}`;return a+=`H${e+n-i}`,a+=`A${i} ${i} 0 0 1 ${e+n} ${t+i}`,a+=`V${t+r-i}`,a+=`A${i} ${i} 0 0 1 ${e+n-i} ${t+r}`,a+=`H${e+i}`,a+=`A${i} ${i} 0 0 1 ${e} ${t+r-i}`,a+=`V${t+i}`,a+=`A${i} ${i} 0 0 1 ${e+i} ${t}Z`,a}const uie=[Ke.BEACON_BEFORE,Ke.BEACON];function die(e){var I,z;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:s,onClickOverlay:i,overlayClickAction:a,placement:l,portalElement:u,scrolling:d,spotlightPadding:f,spotlightRadius:c,spotlightTarget:p,styles:m,target:g,waiting:b}=e,k=Bne(),y=lie(p??g,f,d||b),v=h.useRef(null),w=(s===Ke.TOOLTIP||s===Ke.TOOLTIP_BEFORE)&&l!=="center",[j,P]=h.useState(!1),_=u?(I=v.current)==null?void 0:I.offsetParent:null,L=(_==null?void 0:_.clientWidth)??k.width,B=(_==null?void 0:_.clientHeight)??Mse()??k.height,D=((z=m.overlay)==null?void 0:z.backgroundColor)??"rgba(0, 0, 0, 0.5)",F=h.useMemo(()=>{const{backgroundColor:C,mixBlendMode:T,...E}=m.overlay;return{height:B,pointerEvents:"none",...E}},[B,m.overlay]),R=w&&!d&&!b;h.useEffect(()=>{R?requestAnimationFrame(()=>P(!0)):P(!1)},[R]);const M=n&&uie.includes(s),W=!n&&s!==Ke.TOOLTIP;if(r||!b&&(M||W))return null;let O="";if(R)if(u&&_){const C=Si(p??g);if(C){const T=gC(C),E=gC(_);O=bC(T.left-E.left-f.left,T.top-E.top-f.top,C.offsetWidth+f.left+f.right,C.offsetHeight+f.top+f.bottom,c)}}else O=bC(y.left,y.top,y.width,y.height,c);const $=cie(L,B,O);return lt.createElement("div",{ref:v,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:F},lt.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:B,left:0,position:y.isFixed?"fixed":"absolute",top:0,width:L}},lt.createElement("path",{d:$,fill:D,fillRule:"evenodd",onClick:i,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),O&&lt.createElement("path",{d:O,fill:D,style:{opacity:j?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),O&&Object.keys(m.spotlight).length>0&&lt.createElement("path",{d:O,fill:"none",style:{pointerEvents:"none"},...m.spotlight})))}function QR(e){const{children:t,element:n}=e;return n?Or.createPortal(t,n):null}const fie='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function pie(e,t){const n=h.useRef(null);h.useEffect(()=>{if(!e)return Qf;n.current=document.activeElement;const r=i=>{if(i.key!=="Tab")return;const a=[...e.querySelectorAll(fie)],{shiftKey:l}=i;if(!a.length)return;i.preventDefault();let u=document.activeElement?a.indexOf(document.activeElement):0;u===-1||!l&&u+1===a.length?u=0:l&&u===0?u=a.length-1:u+=l?-1:1,a[u].focus()};e.addEventListener("keydown",r,!1);let s;{const i=e.querySelector(t);i&&(s=setTimeout(()=>{i.focus({preventScroll:!0})},100))}return()=>{var i;e.removeEventListener("keydown",r),s!==void 0&&clearTimeout(s),(i=n.current)==null||i.focus({preventScroll:!0})}},[e,t])}function sa(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 hie(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...sa(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...sa(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...sa(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...sa(e,t,n)};default:return null}}function mie(e,t,n,r){if(!t)return{};const[s]=e.split("-");switch(s){case"top":return{bottom:-n,left:t.x??0,...sa(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...sa(e,r,n)};case"left":return{right:-n,top:t.y??0,...sa(e,r,n)};case"right":return{left:-n,top:t.y??0,...sa(e,r,n)};default:return{}}}function gie({arrowComponent:e,arrowRef:t,base:n,placement:r,position:s,size:i,styles:a}){const l=e;let u=null;if(l){if(!sa(r,n,i))return null;u=lt.createElement("span",{style:{flexShrink:0}},lt.createElement(l,{base:n,placement:r,size:i}))}else{const d=hie(r,n,i);if(!d)return null;u=lt.createElement("svg",{height:d.height,width:d.width,xmlns:"http://www.w3.org/2000/svg"},lt.createElement("polygon",{fill:"currentColor",points:d.points}))}return lt.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,...mie(r,s,i,n),...s?{}:{visibility:"hidden"}}},u)}function yie(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:s,locale:i,nonce:a,onInteract:l,shouldFocus:u,size:d,step:f,styles:c}=e,p=h.useRef(null),m=!!t;h.useEffect(()=>{if(m||document.getElementById("joyride-beacon-animation"))return Qf;const k=document.createElement("style");k.id="joyride-beacon-animation",a&&k.setAttribute("nonce",a),k.appendChild(document.createTextNode(`
213
- @keyframes joyride-beacon-inner {
214
- 20% {
215
- opacity: 0.9;
216
- }
217
-
218
- 90% {
219
- opacity: 0.7;
220
- }
221
- }
222
-
223
- @keyframes joyride-beacon-outer {
224
- 0% {
225
- transform: scale(1);
226
- }
227
-
228
- 45% {
229
- opacity: 0.7;
230
- transform: scale(0.75);
231
- }
232
-
233
- 100% {
234
- opacity: 0.9;
235
- transform: scale(1);
236
- }
237
- }
238
- `)),document.head.appendChild(k);const y=setTimeout(()=>{Qr.domElement(p.current)&&u&&p.current.focus()},0);return()=>{clearTimeout(y);const v=document.getElementById("joyride-beacon-animation");v!=null&&v.parentNode&&v.parentNode.removeChild(v)}},[m,a,u]);const g=Zo(i.open);let b;if(t){const k=t;b=lt.createElement(k,{continuous:n,index:r,isLastStep:s,size:d,step:f})}else b=lt.createElement("span",{style:c.beacon},lt.createElement("span",{style:c.beaconOuter}),lt.createElement("span",{style:c.beaconInner}));return lt.createElement("button",{ref:p,"aria-label":g,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:c.beaconWrapper,title:g,type:"button"},b)}function xie({styles:e,...t}){const{color:n,height:r,width:s,...i}=e;return lt.createElement("button",{style:i,type:"button",...t},lt.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"},lt.createElement("g",null,lt.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 wie(e){const{backProps:t,closeProps:n,index:r,isLastStep:s,primaryProps:i,skipProps:a,step:l,tooltipProps:u}=e,{buttons:d,content:f,styles:c,title:p}=l,m={};d.includes("primary")&&(m.primary=lt.createElement("button",{"data-testid":"button-primary",style:c.buttonPrimary,type:"button",...i})),d.includes("skip")&&!s&&(m.skip=lt.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:c.buttonSkip,type:"button",...a})),d.includes("back")&&r>0&&(m.back=lt.createElement("button",{"data-testid":"button-back",style:c.buttonBack,type:"button",...t})),m.close=d.includes("close")&&lt.createElement(xie,{"data-testid":"button-close",styles:c.buttonClose,...n});const g=p?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":Zo(f),"aria-describedby":"joyride-tooltip-content"};return lt.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:c.tooltip,...u,...g},lt.createElement("div",{style:c.tooltipContainer},p&&lt.createElement("h4",{id:"joyride-tooltip-title",style:c.tooltipTitle},p),lt.createElement("div",{id:"joyride-tooltip-content",style:c.tooltipContent},f)),d.some(b=>b==="back"||b==="primary"||b==="skip")&&lt.createElement("div",{style:c.tooltipFooter},lt.createElement("div",{style:c.tooltipFooterSpacer},m.skip),m.back,m.primary),m.close)}function bie(e){const{continuous:t,controls:n,index:r,isLastStep:s,size:i,step:a}=e,l=y=>{y.preventDefault(),n.prev(xo.BUTTON_BACK)},u=y=>{y.preventDefault(),a.closeButtonAction==="skip"?n.skip(xo.BUTTON_CLOSE):n.close(xo.BUTTON_CLOSE)},d=y=>{if(y.preventDefault(),!t){n.close(xo.BUTTON_PRIMARY);return}n.next(xo.BUTTON_PRIMARY)},f=y=>{y.preventDefault(),n.skip(xo.BUTTON_SKIP)},c=()=>{const{back:y,close:v,last:w,next:j,nextWithProgress:P,skip:_}=a.locale,L=Zo(y),B=Zo(v),D=Zo(w),F=Zo(j),R=Zo(_);let M=v,W=B;if(t){if(M=j,W=F,a.showProgress&&!s){const O=Zo(P,{step:r+1,steps:i});M=Bb(P,r+1,i),W=O}s&&(M=w,W=D)}return{backProps:{"aria-label":L,children:y,"data-action":"back",onClick:l,role:"button",title:L},closeProps:{"aria-label":B,children:v,"data-action":"close",onClick:u,role:"button",title:B},primaryProps:{"aria-label":W,children:M,"data-action":"primary",onClick:d,role:"button",title:W},skipProps:{"aria-label":R,children:_,"data-action":"skip",onClick:f,role:"button",title:R},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:p,beaconComponent:m,tooltipComponent:g,...b}=a;let k;if(g){const y=g;k=lt.createElement(y,{...c(),continuous:t,controls:n,index:r,isLastStep:s,size:i,step:b})}else k=lt.createElement(wie,{...c(),continuous:t,controls:n,index:r,isLastStep:s,size:i,step:b});return k}function vie(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function kie(e,t,n){var r,s;return e?[Cse()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[jse({crossAxis:!1,fallbackPlacements:vie(n),padding:20,...(s=t.floatingOptions)==null?void 0:s.flipOptions})]}function Sie(e){var T,E,G,Z,V;const{continuous:t,controls:n,index:r,lifecycle:s,nonce:i,open:a,portalElement:l,setPositionData:u,setTooltipRef:d,shouldScroll:f,size:c,step:p,target:m,updateState:g}=e,b=h.useRef(null),k=h.useRef({}),y=h.useRef({}),v=p.placement==="center",w=p.placement==="auto",j=h.useMemo(()=>({getBoundingClientRect:()=>({x:window.innerWidth/2,y:window.innerHeight/2,top:window.innerHeight/2,left:window.innerWidth/2,bottom:window.innerHeight/2,right:window.innerWidth/2,width:0,height:0})}),[]),P=h.useMemo(()=>YR(m)?qu(m):void 0,[m]),_=h.useMemo(()=>Yu(m),[m]),L=h.useMemo(()=>P?{boundary:P,rootBoundary:"viewport"}:{},[P]),B=v||w?"bottom":p.placement,D=v?"fixed":((T=p.floatingOptions)==null?void 0:T.strategy)??(p.isFixed||_?"fixed":"absolute"),F=h.useMemo(()=>{var se,de,fe,pe;return v?[{name:"center",fn:({rects:ae})=>({x:(window.innerWidth-ae.floating.width)/2,y:(window.innerHeight-ae.floating.height)/2})}]:[pC(({placement:ae})=>{var we;let be="right";ae.startsWith("top")?be="top":ae.startsWith("bottom")?be="bottom":ae.startsWith("left")&&(be="left");const _e=p.spotlightTarget?0:p.spotlightPadding[be];return p.offset+_e+((we=p.floatingOptions)!=null&&we.hideArrow?0:p.arrowSize)},[p.offset,p.spotlightPadding,p.spotlightTarget,p.arrowSize,(se=p.floatingOptions)==null?void 0:se.hideArrow]),...kie(w,p,B),Nse({padding:10,...L,...(de=p.floatingOptions)==null?void 0:de.shiftOptions}),...(fe=p.floatingOptions)!=null&&fe.hideArrow?[]:[Ese({element:b,padding:p.arrowSpacing},[p.arrowSpacing,p.arrowBase])],...((pe=p.floatingOptions)==null?void 0:pe.middleware)??[]]},[v,p,w,B,L]),R=fC({...v?{elements:{reference:j}}:{},placement:B,strategy:D,middleware:F}),M=fC({strategy:D,placement:p.beaconPlacement??(w||v?"bottom":p.placement),middleware:h.useMemo(()=>{var se,de;return[pC(((de=(se=p.floatingOptions)==null?void 0:se.beaconOptions)==null?void 0:de.offset)??-18)]},[(G=(E=p.floatingOptions)==null?void 0:E.beaconOptions)==null?void 0:G.offset]),whileElementsMounted:cC});y.current=R.middlewareData,k.current=M.middlewareData,h.useEffect(()=>{var fe;const{floating:se,reference:de}=R.elements;if(!(!de||!se||s!==Ke.TOOLTIP))return cC(de,se,R.update,(fe=p.floatingOptions)==null?void 0:fe.autoUpdate)},[s,R.update,(Z=p.floatingOptions)==null?void 0:Z.autoUpdate,p.target,R.elements]),h.useEffect(()=>{!v&&m&&R.refs.setReference(m),m&&M.refs.setReference(m)},[M.refs,v,m,R.refs]),h.useEffect(()=>{R.isPositioned&&u("tooltip",{placement:R.placement,x:R.x??0,y:R.y??0,middlewareData:y.current})},[u,R.isPositioned,R.placement,R.x,R.y]),h.useEffect(()=>{M.isPositioned&&u("beacon",{placement:M.placement,x:M.x??0,y:M.y??0,middlewareData:k.current})},[u,M.isPositioned,M.placement,M.x,M.y]);const W=p.zIndex+100,O=h.useCallback(se=>{se.type==="mouseenter"&&p.beaconTrigger!=="hover"||g({lifecycle:Ke.TOOLTIP_BEFORE,positioned:!1})},[p.beaconTrigger,g]),$=h.useCallback(se=>{se&&(R.refs.setFloating(se),d(se))},[R.refs,d]),{arrow:I,floater:z}=p.styles;let C=null;if(s===Ke.TOOLTIP||s===Ke.TOOLTIP_BEFORE){const se=mC({...z,...R.floatingStyles,zIndex:W,opacity:a&&R.isPositioned?1:0,...!a&&{transition:"none"}});C=lt.createElement("div",{ref:$,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:se},lt.createElement(bie,{continuous:t,controls:n,index:r,isLastStep:r+1===c,size:c,step:p}),!v&&!((V=p.floatingOptions)!=null&&V.hideArrow)&&lt.createElement(gie,{arrowComponent:p.arrowComponent,arrowRef:b,base:p.arrowBase,placement:R.placement,position:R.middlewareData.arrow,size:p.arrowSize,styles:I}))}else(s===Ke.BEACON||s===Ke.BEACON_BEFORE)&&(C=lt.createElement("div",{ref:M.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:mC({...M.floatingStyles,zIndex:W})},lt.createElement(yie,{beaconComponent:p.beaconComponent,continuous:t,index:r,isLastStep:r+1===c,locale:p.locale,nonce:i,onInteract:O,shouldFocus:f,size:c,step:p,styles:p.styles})));return lt.createElement(QR,{element:l},C)}function Nie(e){const{continuous:t,controls:n,index:r,lifecycle:s,nonce:i,portalElement:a,setPositionData:l,shouldScroll:u,size:d,step:f,updateState:c}=e,[p,m]=h.useState(null);pie(f.disableFocusTrap?null:p,"[data-action=primary]");const g=Si(f.target),b=s===Ke.TOOLTIP;return!XR(f)||!Qr.domElement(g)?null:lt.createElement(Sie,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:s,nonce:i,open:b,portalElement:a,setPositionData:l,setTooltipRef:m,shouldScroll:u,size:d,step:f,target:g,updateState:c})}function jie({controls:e,mergedProps:t,state:n,step:r,store:s}){const{continuous:i,debug:a,nonce:l,portalElement:u,scrollToFirstStep:d}=t,f=sie(u),{index:c,lifecycle:p,status:m}=n,g=m===It.RUNNING,[b,k]=h.useState(!1),y=h.useRef(null),v=(r==null?void 0:r.loaderDelay)??0;h.useEffect(()=>(n.waiting?v===0?k(!0):y.current=setTimeout(()=>{k(!0)},v):k(!1),()=>{y.current&&(clearTimeout(y.current),y.current=null)}),[v,n.waiting]),h.useEffect(()=>{if(!g)return;const P=_=>{!r||p!==Ke.TOOLTIP||_.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(xo.KEYBOARD):e.close(xo.KEYBOARD))};return document.body.addEventListener("keydown",P,{passive:!0}),()=>{document.body.removeEventListener("keydown",P)}},[e,g,p,r]);const w=h.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(xo.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(xo.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!g)return null;const j=n.action===$t.START&&!r.skipBeacon&&r.placement!=="center";return lt.createElement(lt.Fragment,null,p!==Ke.INIT&&lt.createElement(Nie,{...n,continuous:i,controls:e,debug:a,nonce:l,portalElement:f,setPositionData:s.current.setPositionData,shouldScroll:!r.skipScroll&&(c!==0||d),step:r,updateState:s.current.updateState}),lt.createElement(QR,{element:f},lt.createElement(lt.Fragment,null,b&&lt.createElement(oie,{nonce:l,step:r}),!j&&lt.createElement(die,{...r,continuous:i,lifecycle:p,onClickOverlay:w,portalElement:u?f:null,scrolling:n.scrolling,waiting:n.waiting}))))}function Cie(e){const{controls:t,failures:n,mergedProps:r,state:s,step:i,store:a}=rie(e);return{controls:t,failures:n,on:h.useCallback((l,u)=>a.current.on(l,u),[a]),state:h.useMemo(()=>kg(s,"positioned"),[s]),step:i,Tour:z0()?lt.createElement(jie,{controls:t,mergedProps:r,state:s,step:i,store:a}):null}}function Eie(e){const{Tour:t}=Cie(e);return t}function _ie(e){return z0()?lt.createElement(Eie,e):null}function Pie(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 Aie(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function Iie(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const Ux="af:onboarding";function Tie({page:e,hasNodes:t=!1}){const{t:n}=Pn(),[r,s]=h.useState(!1),[i,a]=h.useState([]),l=h.useRef(null),u=h.useMemo(()=>e==="projects"?Pie(n):t?Aie(n):Iie(n),[e,t,n]);return h.useEffect(()=>{const d=localStorage.getItem(Ux);console.log("[Onboarding] localStorage:",d);const f=d?JSON.parse(d):{};if(console.log("[Onboarding] progress:",f,"page:",e),f.completed||f[e]){console.log("[Onboarding] skipped - already done"),s(!1),a([]);return}console.log("[Onboarding] starting with steps:",u),a(u),s(!0)},[e,t,u]),h.useEffect(()=>{if(!r)return;const d=f=>{var g;const c=f.target.closest("button");if(!c||!c.closest(".react-joyride__tooltip"))return;const m=(g=c.textContent)==null?void 0:g.trim();if(m===n("onboarding:done")||m===n("onboarding:startCreate")||m===n("onboarding:skip")){const b=localStorage.getItem(Ux)||"{}",k=JSON.parse(b);m===n("onboarding:skip")?(k.projects=!0,k.flow=!0,k.completed=!0):k[e]=!0,localStorage.setItem(Ux,JSON.stringify(k)),a([]),s(!1),e==="projects"&&(m===n("onboarding:done")||m===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const y=document.querySelector(".af-create-btn");y&&y.click()},500))}};return document.addEventListener("click",d,!0),()=>document.removeEventListener("click",d,!0)},[r,e,n]),!r||i.length===0?null:o.jsx(_ie,{ref:l,steps:i,run:r,continuous:!0,showSkipButton:!0,showProgress:i.length>1,styles:{options:{primaryColor:"#7c4dff",textColor:"#ffffff",backgroundColor:"#1a1a1a",arrowColor:"#1a1a1a",overlayColor:"rgba(0, 0, 0, 0.4)",zIndex:1e4},tooltip:{borderRadius:"1.5rem",padding:"1.5rem"},buttonNext:{borderRadius:"9999px",padding:"0.625rem 1.5rem"},buttonSkip:{borderRadius:"9999px",color:"#9ecaff"},buttonClose:{display:"none"}},locale:{back:n("onboarding:back"),next:n("onboarding:next"),skip:n("onboarding:skip"),last:n(e==="projects"?"onboarding:startCreate":"onboarding:done")},floaterProps:{disableAnimation:!0},scrollToFirstStep:!0})}function Rie(){const{navigate:e,path:t}=Io(),[n,r]=h.useState([]),[s,i]=h.useState(!1);if(h.useEffect(()=>{let f=!1;const c=async()=>{try{const m=await fetch("/api/pipeline-recent-runs");if(!m.ok)return;const g=await m.json();if(f)return;const b=Array.isArray(g.runs)?g.runs:[];r(b.filter(k=>k&&k.status==="running"))}catch{}};c();const p=window.setInterval(c,3e3);return()=>{f=!0,window.clearInterval(p)}},[]),n.length===0)return null;const a=f=>{const c=new URLSearchParams({flowId:f.flowId,flowSource:f.flowSource||"workspace"});e(`/flow?${c.toString()}`),i(!1)},l=t==="/flow"?new URLSearchParams(window.location.search):null,u=(l==null?void 0:l.get("flowId"))||"",d=n.length===1;return o.jsxs("div",{className:"af-run-indicator",role:"status","aria-live":"polite",children:[s&&!d&&o.jsx("div",{className:"af-run-indicator__menu",onMouseLeave:()=>i(!1),children:n.map(f=>o.jsxs("button",{type:"button",className:"af-run-indicator__item"+(f.flowId===u?" af-run-indicator__item--current":""),onClick:()=>a(f),title:`${f.flowId} · ${f.runId}`,children:[o.jsx("span",{className:"af-run-indicator__dot"}),o.jsx("span",{className:"af-run-indicator__flow",children:f.flowId}),o.jsx("span",{className:"af-run-indicator__run",children:f.runId.slice(0,12)})]},`${f.flowId}:${f.runId}`))}),o.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:()=>d?a(n[0]):i(f=>!f),title:d?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,children:[o.jsx("span",{className:"af-run-indicator__pulse"}),o.jsx("span",{className:"af-run-indicator__label",children:d?n[0].flowId:`${n.length} running`})]})]})}function ZR(e){return e==="/likee-context"||e==="/likee_context"}class Lie extends h.Component{constructor(t){super(t),this.state={error:null,info:null}}static getDerivedStateFromError(t){return{error:t}}componentDidCatch(t,n){console.error("[AgentFlow UI render error]",t,n),this.setState({error:t,info:n})}render(){var r,s,i;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(((i=this.state.info)==null?void 0:i.componentStack)||"");return o.jsx("div",{className:"af-auth-screen",children:o.jsxs("div",{className:"af-auth-panel af-ui-error-panel",children:[o.jsxs("div",{className:"af-auth-brand",children:[o.jsx("span",{className:"material-symbols-outlined",children:"error"}),o.jsxs("div",{children:[o.jsx("h1",{children:"AgentFlow UI Error"}),o.jsx("p",{children:"页面渲染失败,下面是调试堆栈。"})]})]}),o.jsx("pre",{children:t}),n?o.jsx("pre",{children:n}):null]})})}}function Oie({authUser:e}){const{path:t}=Io();return t==="/projects"||t==="/"?o.jsx(Ic,{authUser:e}):t==="/nodes"?o.jsx(Ic,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?o.jsx(Ic,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?o.jsx(Ic,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?o.jsx(Ic,{authUser:e,resourceKind:"skills"}):t==="/mcps"?o.jsx(gne,{}):t==="/flow"?o.jsx(_7,{}):t==="/workspace"?o.jsx(Gq,{}):t.startsWith("/display")?o.jsx(hR,{}):t==="/settings"?o.jsx(pne,{authUser:e}):t==="/feedback"?o.jsx(hne,{}):ZR(t)?o.jsx(SR,{}):o.jsx(Ic,{})}function Mie({children:e}){const[t,n]=h.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,s]=h.useState(""),[i,a]=h.useState(""),[l,u]=h.useState(!1),[d,f]=h.useState(""),c=async()=>{try{const g=await(await fetch("/api/auth/me")).json().catch(()=>({}));n({loading:!1,authenticated:!!g.authenticated,user:g.user||null,setupRequired:!!g.setupRequired}),f(g.error?String(g.error):"")}catch(m){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),f(String(m.message||m))}};h.useEffect(()=>{c()},[]);const p=async m=>{m.preventDefault(),u(!0),f("");try{const g=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:i})}),b=await g.json().catch(()=>({}));if(!g.ok)throw new Error(b.error||"登录失败");n({loading:!1,authenticated:!0,user:b.user||null,setupRequired:!1})}catch(g){f(String(g.message||g))}finally{u(!1)}};return t.loading?o.jsx("div",{className:"af-auth-screen",children:o.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})}}):o.jsx("div",{className:"af-auth-screen",children:o.jsxs("form",{className:"af-auth-panel",onSubmit:p,children:[o.jsxs("div",{className:"af-auth-brand",children:[o.jsx("span",{className:"material-symbols-outlined",children:"account_circle"}),o.jsxs("div",{children:[o.jsx("h1",{children:"AgentFlow"}),o.jsx("p",{children:t.setupRequired?"初始化管理员账号":"登录或创建用户"})]})]}),o.jsxs("label",{className:"af-auth-field",children:[o.jsx("span",{children:"用户名"}),o.jsx("input",{value:r,onChange:m=>s(m.target.value),autoComplete:"username",autoFocus:!0})]}),o.jsxs("label",{className:"af-auth-field",children:[o.jsx("span",{children:"密码"}),o.jsx("input",{type:"password",value:i,onChange:m=>a(m.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),d?o.jsx("p",{className:"af-auth-error",children:d}):null,o.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||i.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function $ie({authUser:e,onLogout:t}){const{path:n}=Io(),r=n==="/flow"||n==="/workspace";return o.jsxs("div",{className:"af-app",children:[n!=="/settings"?o.jsx(Tie,{page:r?"flow":"projects"}):null,r?null:o.jsx(yM,{authUser:e,onLogout:t}),o.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:o.jsx(Oie,{authUser:e})}),o.jsx(Rie,{})]})}function Die(){return o.jsx(Lie,{children:o.jsx(QO,{children:o.jsx(Fie,{})})})}function Fie(){const{path:e}=Io();return e.startsWith("/display")?o.jsx(hR,{}):ZR(e)?o.jsx(SR,{}):o.jsx(Mie,{children:({user:t,onLogout:n})=>o.jsx($ie,{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 vC=document.querySelector('link[rel="icon"]');vC&&(vC.href=$_);Kx.createRoot(document.getElementById("root")).render(o.jsx(lt.StrictMode,{children:o.jsx(Die,{})}));