@fieldwangai/agentflow 0.1.137 → 0.1.141
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/lib/catalog-flows.mjs +17 -3
- package/bin/lib/composer-node-schema.mjs +4 -0
- package/bin/lib/i18n.mjs +2 -2
- package/bin/lib/jenkins.mjs +380 -0
- package/bin/lib/locales/en.json +22 -0
- package/bin/lib/locales/zh.json +22 -0
- package/bin/lib/paths.mjs +1 -0
- package/bin/lib/prd-workflow-collaboration.mjs +139 -1
- package/bin/lib/recent-runs.mjs +16 -0
- package/bin/lib/run-node-statuses-from-disk.mjs +41 -3
- package/bin/lib/scheduler.mjs +59 -25
- package/bin/lib/ui-server.mjs +721 -63
- package/bin/pipeline/pre-process-node.mjs +122 -11
- package/bin/pipeline/run-log.mjs +2 -2
- package/bin/pipeline/write-result.mjs +4 -4
- package/builtin/nodes/tool_jenkins_build.md +64 -0
- package/builtin/pipelines/jenkins-build-notify/flow.yaml +217 -0
- package/builtin/web-ui/dist/assets/WorkflowAssistantThread-ubxHcM7p.js +6 -0
- package/builtin/web-ui/dist/assets/index-B6TWUomI.css +1 -0
- package/builtin/web-ui/dist/assets/index-DQzcZp7S.js +590 -0
- package/builtin/web-ui/dist/index.html +2 -2
- package/package.json +1 -1
- package/skills/agentflow-workflow-report/SKILL.md +3 -0
- package/skills/agentflow-workflow-report/references/protocol.md +8 -5
- package/builtin/web-ui/dist/assets/index-CQsrSc3u.css +0 -1
- package/builtin/web-ui/dist/assets/index-DQvqqAeQ.js +0 -590
|
@@ -0,0 +1,590 @@
|
|
|
1
|
+
var UO=Object.defineProperty;var GO=(e,t,n)=>t in e?UO(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Un=(e,t,n)=>GO(e,typeof t!="symbol"?t+"":t,n);function YO(e,t){for(var n=0;n<t.length;n++){const r=t[n];if(typeof r!="string"&&!Array.isArray(r)){for(const i in r)if(i!=="default"&&!(i in e)){const o=Object.getOwnPropertyDescriptor(r,i);o&&Object.defineProperty(e,i,o.get?o:{enumerable:!0,get:()=>r[i]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const o of i)if(o.type==="childList")for(const a of o.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const o={};return i.integrity&&(o.integrity=i.integrity),i.referrerPolicy&&(o.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?o.credentials="include":i.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(i){if(i.ep)return;i.ep=!0;const o=n(i);fetch(i.href,o)}})();var Fd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function xa(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var HA={exports:{}},ng={},VA={exports:{}},zt={};/**
|
|
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 Af=Symbol.for("react.element"),JO=Symbol.for("react.portal"),XO=Symbol.for("react.fragment"),QO=Symbol.for("react.strict_mode"),ZO=Symbol.for("react.profiler"),e2=Symbol.for("react.provider"),t2=Symbol.for("react.context"),n2=Symbol.for("react.forward_ref"),r2=Symbol.for("react.suspense"),s2=Symbol.for("react.memo"),i2=Symbol.for("react.lazy"),S0=Symbol.iterator;function o2(e){return e===null||typeof e!="object"?null:(e=S0&&e[S0]||e["@@iterator"],typeof e=="function"?e:null)}var KA={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},qA=Object.assign,UA={};function tu(e,t,n){this.props=e,this.context=t,this.refs=UA,this.updater=n||KA}tu.prototype.isReactComponent={};tu.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")};tu.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,"forceUpdate")};function GA(){}GA.prototype=tu.prototype;function ak(e,t,n){this.props=e,this.context=t,this.refs=UA,this.updater=n||KA}var lk=ak.prototype=new GA;lk.constructor=ak;qA(lk,tu.prototype);lk.isPureReactComponent=!0;var j0=Array.isArray,YA=Object.prototype.hasOwnProperty,ck={current:null},JA={key:!0,ref:!0,__self:!0,__source:!0};function XA(e,t,n){var r,i={},o=null,a=null;if(t!=null)for(r in t.ref!==void 0&&(a=t.ref),t.key!==void 0&&(o=""+t.key),t)YA.call(t,r)&&!JA.hasOwnProperty(r)&&(i[r]=t[r]);var l=arguments.length-2;if(l===1)i.children=n;else if(1<l){for(var c=Array(l),u=0;u<l;u++)c[u]=arguments[u+2];i.children=c}if(e&&e.defaultProps)for(r in l=e.defaultProps,l)i[r]===void 0&&(i[r]=l[r]);return{$$typeof:Af,type:e,key:o,ref:a,props:i,_owner:ck.current}}function a2(e,t){return{$$typeof:Af,type:e.type,key:t,ref:e.ref,props:e.props,_owner:e._owner}}function uk(e){return typeof e=="object"&&e!==null&&e.$$typeof===Af}function l2(e){var t={"=":"=0",":":"=2"};return"$"+e.replace(/[=:]/g,function(n){return t[n]})}var N0=/\/+/g;function Ry(e,t){return typeof e=="object"&&e!==null&&e.key!=null?l2(""+e.key):t.toString(36)}function vh(e,t,n,r,i){var o=typeof e;(o==="undefined"||o==="boolean")&&(e=null);var a=!1;if(e===null)a=!0;else switch(o){case"string":case"number":a=!0;break;case"object":switch(e.$$typeof){case Af:case JO:a=!0}}if(a)return a=e,i=i(a),e=r===""?"."+Ry(a,0):r,j0(i)?(n="",e!=null&&(n=e.replace(N0,"$&/")+"/"),vh(i,t,n,"",function(u){return u})):i!=null&&(uk(i)&&(i=a2(i,n+(!i.key||a&&a.key===i.key?"":(""+i.key).replace(N0,"$&/")+"/")+e)),t.push(i)),1;if(a=0,r=r===""?".":r+":",j0(e))for(var l=0;l<e.length;l++){o=e[l];var c=r+Ry(o,l);a+=vh(o,t,n,c,i)}else if(c=o2(e),typeof c=="function")for(e=c.call(e),l=0;!(o=e.next()).done;)o=o.value,c=r+Ry(o,l++),a+=vh(o,t,n,c,i);else if(o==="object")throw t=String(e),Error("Objects are not valid as a React child (found: "+(t==="[object Object]"?"object with keys {"+Object.keys(e).join(", ")+"}":t)+"). If you meant to render a collection of children, use an array instead.");return a}function Cp(e,t,n){if(e==null)return e;var r=[],i=0;return vh(e,r,"","",function(o){return t.call(n,o,i++)}),r}function c2(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 Yr={current:null},Sh={transition:null},u2={ReactCurrentDispatcher:Yr,ReactCurrentBatchConfig:Sh,ReactCurrentOwner:ck};function QA(){throw Error("act(...) is not supported in production builds of React.")}zt.Children={map:Cp,forEach:function(e,t,n){Cp(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return Cp(e,function(){t++}),t},toArray:function(e){return Cp(e,function(t){return t})||[]},only:function(e){if(!uk(e))throw Error("React.Children.only expected to receive a single React element child.");return e}};zt.Component=tu;zt.Fragment=XO;zt.Profiler=ZO;zt.PureComponent=ak;zt.StrictMode=QO;zt.Suspense=r2;zt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=u2;zt.act=QA;zt.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=qA({},e.props),i=e.key,o=e.ref,a=e._owner;if(t!=null){if(t.ref!==void 0&&(o=t.ref,a=ck.current),t.key!==void 0&&(i=""+t.key),e.type&&e.type.defaultProps)var l=e.type.defaultProps;for(c in t)YA.call(t,c)&&!JA.hasOwnProperty(c)&&(r[c]=t[c]===void 0&&l!==void 0?l[c]:t[c])}var c=arguments.length-2;if(c===1)r.children=n;else if(1<c){l=Array(c);for(var u=0;u<c;u++)l[u]=arguments[u+2];r.children=l}return{$$typeof:Af,type:e.type,key:i,ref:o,props:r,_owner:a}};zt.createContext=function(e){return e={$$typeof:t2,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},e.Provider={$$typeof:e2,_context:e},e.Consumer=e};zt.createElement=XA;zt.createFactory=function(e){var t=XA.bind(null,e);return t.type=e,t};zt.createRef=function(){return{current:null}};zt.forwardRef=function(e){return{$$typeof:n2,render:e}};zt.isValidElement=uk;zt.lazy=function(e){return{$$typeof:i2,_payload:{_status:-1,_result:e},_init:c2}};zt.memo=function(e,t){return{$$typeof:s2,type:e,compare:t===void 0?null:t}};zt.startTransition=function(e){var t=Sh.transition;Sh.transition={};try{e()}finally{Sh.transition=t}};zt.unstable_act=QA;zt.useCallback=function(e,t){return Yr.current.useCallback(e,t)};zt.useContext=function(e){return Yr.current.useContext(e)};zt.useDebugValue=function(){};zt.useDeferredValue=function(e){return Yr.current.useDeferredValue(e)};zt.useEffect=function(e,t){return Yr.current.useEffect(e,t)};zt.useId=function(){return Yr.current.useId()};zt.useImperativeHandle=function(e,t,n){return Yr.current.useImperativeHandle(e,t,n)};zt.useInsertionEffect=function(e,t){return Yr.current.useInsertionEffect(e,t)};zt.useLayoutEffect=function(e,t){return Yr.current.useLayoutEffect(e,t)};zt.useMemo=function(e,t){return Yr.current.useMemo(e,t)};zt.useReducer=function(e,t,n){return Yr.current.useReducer(e,t,n)};zt.useRef=function(e){return Yr.current.useRef(e)};zt.useState=function(e){return Yr.current.useState(e)};zt.useSyncExternalStore=function(e,t,n){return Yr.current.useSyncExternalStore(e,t,n)};zt.useTransition=function(){return Yr.current.useTransition()};zt.version="18.3.1";VA.exports=zt;var h=VA.exports;const ft=xa(h),Gde=YO({__proto__:null,default:ft},[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 d2=h,f2=Symbol.for("react.element"),p2=Symbol.for("react.fragment"),h2=Object.prototype.hasOwnProperty,m2=d2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,g2={key:!0,ref:!0,__self:!0,__source:!0};function ZA(e,t,n){var r,i={},o=null,a=null;n!==void 0&&(o=""+n),t.key!==void 0&&(o=""+t.key),t.ref!==void 0&&(a=t.ref);for(r in t)h2.call(t,r)&&!g2.hasOwnProperty(r)&&(i[r]=t[r]);if(e&&e.defaultProps)for(r in t=e.defaultProps,t)i[r]===void 0&&(i[r]=t[r]);return{$$typeof:f2,type:e,key:o,ref:a,props:i,_owner:m2.current}}ng.Fragment=p2;ng.jsx=ZA;ng.jsxs=ZA;HA.exports=ng;var s=HA.exports,ix={},eE={exports:{}},js={},tE={exports:{}},nE={};/**
|
|
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(M,H){var A=M.length;M.push(H);e:for(;0<A;){var X=A-1>>>1,q=M[X];if(0<i(q,H))M[X]=H,M[A]=q,A=X;else break e}}function n(M){return M.length===0?null:M[0]}function r(M){if(M.length===0)return null;var H=M[0],A=M.pop();if(A!==H){M[0]=A;e:for(var X=0,q=M.length,B=q>>>1;X<B;){var ne=2*(X+1)-1,ce=M[ne],K=ne+1,ee=M[K];if(0>i(ce,A))K<q&&0>i(ee,ce)?(M[X]=ee,M[K]=A,X=K):(M[X]=ce,M[ne]=A,X=ne);else if(K<q&&0>i(ee,A))M[X]=ee,M[K]=A,X=K;else break e}}return H}function i(M,H){var A=M.sortIndex-H.sortIndex;return A!==0?A:M.id-H.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var a=Date,l=a.now();e.unstable_now=function(){return a.now()-l}}var c=[],u=[],f=1,p=null,d=3,m=!1,y=!1,v=!1,b=typeof setTimeout=="function"?setTimeout:null,g=typeof clearTimeout=="function"?clearTimeout:null,k=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function x(M){for(var H=n(u);H!==null;){if(H.callback===null)r(u);else if(H.startTime<=M)r(u),H.sortIndex=H.expirationTime,t(c,H);else break;H=n(u)}}function _(M){if(v=!1,x(M),!y)if(n(c)!==null)y=!0,W(j);else{var H=n(u);H!==null&&F(_,H.startTime-M)}}function j(M,H){y=!1,v&&(v=!1,g(T),T=-1),m=!0;var A=d;try{for(x(H),p=n(c);p!==null&&(!(p.expirationTime>H)||M&&!O());){var X=p.callback;if(typeof X=="function"){p.callback=null,d=p.priorityLevel;var q=X(p.expirationTime<=H);H=e.unstable_now(),typeof q=="function"?p.callback=q:p===n(c)&&r(c),x(H)}else r(c);p=n(c)}if(p!==null)var B=!0;else{var ne=n(u);ne!==null&&F(_,ne.startTime-H),B=!1}return B}finally{p=null,d=A,m=!1}}var N=!1,P=null,T=-1,z=5,E=-1;function O(){return!(e.unstable_now()-E<z)}function D(){if(P!==null){var M=e.unstable_now();E=M;var H=!0;try{H=P(!0,M)}finally{H?L():(N=!1,P=null)}}else N=!1}var L;if(typeof k=="function")L=function(){k(D)};else if(typeof MessageChannel<"u"){var $=new MessageChannel,V=$.port2;$.port1.onmessage=D,L=function(){V.postMessage(null)}}else L=function(){b(D,0)};function W(M){P=M,N||(N=!0,L())}function F(M,H){T=b(function(){M(e.unstable_now())},H)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(M){M.callback=null},e.unstable_continueExecution=function(){y||m||(y=!0,W(j))},e.unstable_forceFrameRate=function(M){0>M||125<M?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):z=0<M?Math.floor(1e3/M):5},e.unstable_getCurrentPriorityLevel=function(){return d},e.unstable_getFirstCallbackNode=function(){return n(c)},e.unstable_next=function(M){switch(d){case 1:case 2:case 3:var H=3;break;default:H=d}var A=d;d=H;try{return M()}finally{d=A}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(M,H){switch(M){case 1:case 2:case 3:case 4:case 5:break;default:M=3}var A=d;d=M;try{return H()}finally{d=A}},e.unstable_scheduleCallback=function(M,H,A){var X=e.unstable_now();switch(typeof A=="object"&&A!==null?(A=A.delay,A=typeof A=="number"&&0<A?X+A:X):A=X,M){case 1:var q=-1;break;case 2:q=250;break;case 5:q=1073741823;break;case 4:q=1e4;break;default:q=5e3}return q=A+q,M={id:f++,callback:H,priorityLevel:M,startTime:A,expirationTime:q,sortIndex:-1},A>X?(M.sortIndex=A,t(u,M),n(c)===null&&M===n(u)&&(v?(g(T),T=-1):v=!0,F(_,A-X))):(M.sortIndex=q,t(c,M),y||m||(y=!0,W(j))),M},e.unstable_shouldYield=O,e.unstable_wrapCallback=function(M){var H=d;return function(){var A=d;d=H;try{return M.apply(this,arguments)}finally{d=A}}}})(nE);tE.exports=nE;var y2=tE.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 w2=h,vs=y2;function Pe(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 rE=new Set,zd={};function wl(e,t){Lc(e,t),Lc(e+"Capture",t)}function Lc(e,t){for(zd[e]=t,e=0;e<t.length;e++)rE.add(t[e])}var po=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),ox=Object.prototype.hasOwnProperty,x2=/^[: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]*$/,_0={},C0={};function b2(e){return ox.call(C0,e)?!0:ox.call(_0,e)?!1:x2.test(e)?C0[e]=!0:(_0[e]=!0,!1)}function k2(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 v2(e,t,n,r){if(t===null||typeof t>"u"||k2(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 Jr(e,t,n,r,i,o,a){this.acceptsBooleans=t===2||t===3||t===4,this.attributeName=r,this.attributeNamespace=i,this.mustUseProperty=n,this.propertyName=e,this.type=t,this.sanitizeURL=o,this.removeEmptyString=a}var Ir={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(e){Ir[e]=new Jr(e,0,!1,e,null,!1,!1)});[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(e){var t=e[0];Ir[t]=new Jr(t,1,!1,e[1],null,!1,!1)});["contentEditable","draggable","spellCheck","value"].forEach(function(e){Ir[e]=new Jr(e,2,!1,e.toLowerCase(),null,!1,!1)});["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(e){Ir[e]=new Jr(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){Ir[e]=new Jr(e,3,!1,e.toLowerCase(),null,!1,!1)});["checked","multiple","muted","selected"].forEach(function(e){Ir[e]=new Jr(e,3,!0,e,null,!1,!1)});["capture","download"].forEach(function(e){Ir[e]=new Jr(e,4,!1,e,null,!1,!1)});["cols","rows","size","span"].forEach(function(e){Ir[e]=new Jr(e,6,!1,e,null,!1,!1)});["rowSpan","start"].forEach(function(e){Ir[e]=new Jr(e,5,!1,e.toLowerCase(),null,!1,!1)});var dk=/[\-:]([a-z])/g;function fk(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(dk,fk);Ir[t]=new Jr(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(dk,fk);Ir[t]=new Jr(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(dk,fk);Ir[t]=new Jr(t,1,!1,e,"http://www.w3.org/XML/1998/namespace",!1,!1)});["tabIndex","crossOrigin"].forEach(function(e){Ir[e]=new Jr(e,1,!1,e.toLowerCase(),null,!1,!1)});Ir.xlinkHref=new Jr("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1);["src","href","action","formAction"].forEach(function(e){Ir[e]=new Jr(e,1,!1,e.toLowerCase(),null,!0,!0)});function pk(e,t,n,r){var i=Ir.hasOwnProperty(t)?Ir[t]:null;(i!==null?i.type!==0:r||!(2<t.length)||t[0]!=="o"&&t[0]!=="O"||t[1]!=="n"&&t[1]!=="N")&&(v2(t,n,i,r)&&(n=null),r||i===null?b2(t)&&(n===null?e.removeAttribute(t):e.setAttribute(t,""+n)):i.mustUseProperty?e[i.propertyName]=n===null?i.type===3?!1:"":n:(t=i.attributeName,r=i.attributeNamespace,n===null?e.removeAttribute(t):(i=i.type,n=i===3||i===4&&n===!0?"":""+n,r?e.setAttributeNS(r,t,n):e.setAttribute(t,n))))}var ko=w2.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,Ap=Symbol.for("react.element"),sc=Symbol.for("react.portal"),ic=Symbol.for("react.fragment"),hk=Symbol.for("react.strict_mode"),ax=Symbol.for("react.profiler"),sE=Symbol.for("react.provider"),iE=Symbol.for("react.context"),mk=Symbol.for("react.forward_ref"),lx=Symbol.for("react.suspense"),cx=Symbol.for("react.suspense_list"),gk=Symbol.for("react.memo"),Ho=Symbol.for("react.lazy"),oE=Symbol.for("react.offscreen"),A0=Symbol.iterator;function Hu(e){return e===null||typeof e!="object"?null:(e=A0&&e[A0]||e["@@iterator"],typeof e=="function"?e:null)}var Hn=Object.assign,My;function ld(e){if(My===void 0)try{throw Error()}catch(n){var t=n.stack.trim().match(/\n( *(at )?)/);My=t&&t[1]||""}return`
|
|
34
|
+
`+My+e}var $y=!1;function Ly(e,t){if(!e||$y)return"";$y=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(t)if(t=function(){throw Error()},Object.defineProperty(t.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(t,[])}catch(u){var r=u}Reflect.construct(e,[],t)}else{try{t.call()}catch(u){r=u}e.call(t.prototype)}else{try{throw Error()}catch(u){r=u}e()}}catch(u){if(u&&r&&typeof u.stack=="string"){for(var i=u.stack.split(`
|
|
35
|
+
`),o=r.stack.split(`
|
|
36
|
+
`),a=i.length-1,l=o.length-1;1<=a&&0<=l&&i[a]!==o[l];)l--;for(;1<=a&&0<=l;a--,l--)if(i[a]!==o[l]){if(a!==1||l!==1)do if(a--,l--,0>l||i[a]!==o[l]){var c=`
|
|
37
|
+
`+i[a].replace(" at new "," at ");return e.displayName&&c.includes("<anonymous>")&&(c=c.replace("<anonymous>",e.displayName)),c}while(1<=a&&0<=l);break}}}finally{$y=!1,Error.prepareStackTrace=n}return(e=e?e.displayName||e.name:"")?ld(e):""}function S2(e){switch(e.tag){case 5:return ld(e.type);case 16:return ld("Lazy");case 13:return ld("Suspense");case 19:return ld("SuspenseList");case 0:case 2:case 15:return e=Ly(e.type,!1),e;case 11:return e=Ly(e.type.render,!1),e;case 1:return e=Ly(e.type,!0),e;default:return""}}function ux(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 ic:return"Fragment";case sc:return"Portal";case ax:return"Profiler";case hk:return"StrictMode";case lx:return"Suspense";case cx:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case iE:return(e.displayName||"Context")+".Consumer";case sE:return(e._context.displayName||"Context")+".Provider";case mk:var t=e.render;return e=e.displayName,e||(e=t.displayName||t.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case gk:return t=e.displayName||null,t!==null?t:ux(e.type)||"Memo";case Ho:t=e._payload,e=e._init;try{return ux(e(t))}catch{}}return null}function j2(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 ux(t);case 8:return t===hk?"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 da(e){switch(typeof e){case"boolean":case"number":case"string":case"undefined":return e;case"object":return e;default:return""}}function aE(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()==="input"&&(t==="checkbox"||t==="radio")}function N2(e){var t=aE(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 i=n.get,o=n.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(a){r=""+a,o.call(this,a)}}),Object.defineProperty(e,t,{enumerable:n.enumerable}),{getValue:function(){return r},setValue:function(a){r=""+a},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Ep(e){e._valueTracker||(e._valueTracker=N2(e))}function lE(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r="";return e&&(r=aE(e)?e.checked?"true":"false":e.value),e=r,e!==n?(t.setValue(e),!0):!1}function Gh(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 dx(e,t){var n=t.checked;return Hn({},t,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:n??e._wrapperState.initialChecked})}function E0(e,t){var n=t.defaultValue==null?"":t.defaultValue,r=t.checked!=null?t.checked:t.defaultChecked;n=da(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 cE(e,t){t=t.checked,t!=null&&pk(e,"checked",t,!1)}function fx(e,t){cE(e,t);var n=da(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")?px(e,t.type,n):t.hasOwnProperty("defaultValue")&&px(e,t.type,da(t.defaultValue)),t.checked==null&&t.defaultChecked!=null&&(e.defaultChecked=!!t.defaultChecked)}function I0(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 px(e,t,n){(t!=="number"||Gh(e.ownerDocument)!==e)&&(n==null?e.defaultValue=""+e._wrapperState.initialValue:e.defaultValue!==""+n&&(e.defaultValue=""+n))}var cd=Array.isArray;function vc(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t["$"+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty("$"+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=""+da(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function hx(e,t){if(t.dangerouslySetInnerHTML!=null)throw Error(Pe(91));return Hn({},t,{value:void 0,defaultValue:void 0,children:""+e._wrapperState.initialValue})}function P0(e,t){var n=t.value;if(n==null){if(n=t.children,t=t.defaultValue,n!=null){if(t!=null)throw Error(Pe(92));if(cd(n)){if(1<n.length)throw Error(Pe(93));n=n[0]}t=n}t==null&&(t=""),n=t}e._wrapperState={initialValue:da(n)}}function uE(e,t){var n=da(t.value),r=da(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 T0(e){var t=e.textContent;t===e._wrapperState.initialValue&&t!==""&&t!==null&&(e.value=t)}function dE(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 mx(e,t){return e==null||e==="http://www.w3.org/1999/xhtml"?dE(t):e==="http://www.w3.org/2000/svg"&&t==="foreignObject"?"http://www.w3.org/1999/xhtml":e}var Ip,fE=function(e){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(t,n,r,i){MSApp.execUnsafeLocalFunction(function(){return e(t,n,r,i)})}:e}(function(e,t){if(e.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in e)e.innerHTML=t;else{for(Ip=Ip||document.createElement("div"),Ip.innerHTML="<svg>"+t.valueOf().toString()+"</svg>",t=Ip.firstChild;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)}});function Bd(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var bd={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},_2=["Webkit","ms","Moz","O"];Object.keys(bd).forEach(function(e){_2.forEach(function(t){t=t+e.charAt(0).toUpperCase()+e.substring(1),bd[t]=bd[e]})});function pE(e,t,n){return t==null||typeof t=="boolean"||t===""?"":n||typeof t!="number"||t===0||bd.hasOwnProperty(e)&&bd[e]?(""+t).trim():t+"px"}function hE(e,t){e=e.style;for(var n in t)if(t.hasOwnProperty(n)){var r=n.indexOf("--")===0,i=pE(n,t[n],r);n==="float"&&(n="cssFloat"),r?e.setProperty(n,i):e[n]=i}}var C2=Hn({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 gx(e,t){if(t){if(C2[e]&&(t.children!=null||t.dangerouslySetInnerHTML!=null))throw Error(Pe(137,e));if(t.dangerouslySetInnerHTML!=null){if(t.children!=null)throw Error(Pe(60));if(typeof t.dangerouslySetInnerHTML!="object"||!("__html"in t.dangerouslySetInnerHTML))throw Error(Pe(61))}if(t.style!=null&&typeof t.style!="object")throw Error(Pe(62))}}function yx(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 wx=null;function yk(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var xx=null,Sc=null,jc=null;function R0(e){if(e=Pf(e)){if(typeof xx!="function")throw Error(Pe(280));var t=e.stateNode;t&&(t=ag(t),xx(e.stateNode,e.type,t))}}function mE(e){Sc?jc?jc.push(e):jc=[e]:Sc=e}function gE(){if(Sc){var e=Sc,t=jc;if(jc=Sc=null,R0(e),t)for(e=0;e<t.length;e++)R0(t[e])}}function yE(e,t){return e(t)}function wE(){}var Oy=!1;function xE(e,t,n){if(Oy)return e(t,n);Oy=!0;try{return yE(e,t,n)}finally{Oy=!1,(Sc!==null||jc!==null)&&(wE(),gE())}}function Wd(e,t){var n=e.stateNode;if(n===null)return null;var r=ag(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(Pe(231,t,typeof n));return n}var bx=!1;if(po)try{var Vu={};Object.defineProperty(Vu,"passive",{get:function(){bx=!0}}),window.addEventListener("test",Vu,Vu),window.removeEventListener("test",Vu,Vu)}catch{bx=!1}function A2(e,t,n,r,i,o,a,l,c){var u=Array.prototype.slice.call(arguments,3);try{t.apply(n,u)}catch(f){this.onError(f)}}var kd=!1,Yh=null,Jh=!1,kx=null,E2={onError:function(e){kd=!0,Yh=e}};function I2(e,t,n,r,i,o,a,l,c){kd=!1,Yh=null,A2.apply(E2,arguments)}function P2(e,t,n,r,i,o,a,l,c){if(I2.apply(this,arguments),kd){if(kd){var u=Yh;kd=!1,Yh=null}else throw Error(Pe(198));Jh||(Jh=!0,kx=u)}}function xl(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 bE(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 M0(e){if(xl(e)!==e)throw Error(Pe(188))}function T2(e){var t=e.alternate;if(!t){if(t=xl(e),t===null)throw Error(Pe(188));return t!==e?null:e}for(var n=e,r=t;;){var i=n.return;if(i===null)break;var o=i.alternate;if(o===null){if(r=i.return,r!==null){n=r;continue}break}if(i.child===o.child){for(o=i.child;o;){if(o===n)return M0(i),e;if(o===r)return M0(i),t;o=o.sibling}throw Error(Pe(188))}if(n.return!==r.return)n=i,r=o;else{for(var a=!1,l=i.child;l;){if(l===n){a=!0,n=i,r=o;break}if(l===r){a=!0,r=i,n=o;break}l=l.sibling}if(!a){for(l=o.child;l;){if(l===n){a=!0,n=o,r=i;break}if(l===r){a=!0,r=o,n=i;break}l=l.sibling}if(!a)throw Error(Pe(189))}}if(n.alternate!==r)throw Error(Pe(190))}if(n.tag!==3)throw Error(Pe(188));return n.stateNode.current===n?e:t}function kE(e){return e=T2(e),e!==null?vE(e):null}function vE(e){if(e.tag===5||e.tag===6)return e;for(e=e.child;e!==null;){var t=vE(e);if(t!==null)return t;e=e.sibling}return null}var SE=vs.unstable_scheduleCallback,$0=vs.unstable_cancelCallback,R2=vs.unstable_shouldYield,M2=vs.unstable_requestPaint,tr=vs.unstable_now,$2=vs.unstable_getCurrentPriorityLevel,wk=vs.unstable_ImmediatePriority,jE=vs.unstable_UserBlockingPriority,Xh=vs.unstable_NormalPriority,L2=vs.unstable_LowPriority,NE=vs.unstable_IdlePriority,rg=null,Mi=null;function O2(e){if(Mi&&typeof Mi.onCommitFiberRoot=="function")try{Mi.onCommitFiberRoot(rg,e,void 0,(e.current.flags&128)===128)}catch{}}var ci=Math.clz32?Math.clz32:z2,D2=Math.log,F2=Math.LN2;function z2(e){return e>>>=0,e===0?32:31-(D2(e)/F2|0)|0}var Pp=64,Tp=4194304;function ud(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 Qh(e,t){var n=e.pendingLanes;if(n===0)return 0;var r=0,i=e.suspendedLanes,o=e.pingedLanes,a=n&268435455;if(a!==0){var l=a&~i;l!==0?r=ud(l):(o&=a,o!==0&&(r=ud(o)))}else a=n&~i,a!==0?r=ud(a):o!==0&&(r=ud(o));if(r===0)return 0;if(t!==0&&t!==r&&!(t&i)&&(i=r&-r,o=t&-t,i>=o||i===16&&(o&4194240)!==0))return t;if(r&4&&(r|=n&16),t=e.entangledLanes,t!==0)for(e=e.entanglements,t&=r;0<t;)n=31-ci(t),i=1<<n,r|=e[n],t&=~i;return r}function B2(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 W2(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,o=e.pendingLanes;0<o;){var a=31-ci(o),l=1<<a,c=i[a];c===-1?(!(l&n)||l&r)&&(i[a]=B2(l,t)):c<=t&&(e.expiredLanes|=l),o&=~l}}function vx(e){return e=e.pendingLanes&-1073741825,e!==0?e:e&1073741824?1073741824:0}function _E(){var e=Pp;return Pp<<=1,!(Pp&4194240)&&(Pp=64),e}function Dy(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function Ef(e,t,n){e.pendingLanes|=t,t!==536870912&&(e.suspendedLanes=0,e.pingedLanes=0),e=e.eventTimes,t=31-ci(t),e[t]=n}function H2(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 i=31-ci(n),o=1<<i;t[i]=0,r[i]=-1,e[i]=-1,n&=~o}}function xk(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-ci(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}var cn=0;function CE(e){return e&=-e,1<e?4<e?e&268435455?16:536870912:4:1}var AE,bk,EE,IE,PE,Sx=!1,Rp=[],ta=null,na=null,ra=null,Hd=new Map,Vd=new Map,qo=[],V2="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 L0(e,t){switch(e){case"focusin":case"focusout":ta=null;break;case"dragenter":case"dragleave":na=null;break;case"mouseover":case"mouseout":ra=null;break;case"pointerover":case"pointerout":Hd.delete(t.pointerId);break;case"gotpointercapture":case"lostpointercapture":Vd.delete(t.pointerId)}}function Ku(e,t,n,r,i,o){return e===null||e.nativeEvent!==o?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:o,targetContainers:[i]},t!==null&&(t=Pf(t),t!==null&&bk(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function K2(e,t,n,r,i){switch(t){case"focusin":return ta=Ku(ta,e,t,n,r,i),!0;case"dragenter":return na=Ku(na,e,t,n,r,i),!0;case"mouseover":return ra=Ku(ra,e,t,n,r,i),!0;case"pointerover":var o=i.pointerId;return Hd.set(o,Ku(Hd.get(o)||null,e,t,n,r,i)),!0;case"gotpointercapture":return o=i.pointerId,Vd.set(o,Ku(Vd.get(o)||null,e,t,n,r,i)),!0}return!1}function TE(e){var t=Ha(e.target);if(t!==null){var n=xl(t);if(n!==null){if(t=n.tag,t===13){if(t=bE(n),t!==null){e.blockedOn=t,PE(e.priority,function(){EE(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 jh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=jx(e.domEventName,e.eventSystemFlags,t[0],e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);wx=r,n.target.dispatchEvent(r),wx=null}else return t=Pf(n),t!==null&&bk(t),e.blockedOn=n,!1;t.shift()}return!0}function O0(e,t,n){jh(e)&&n.delete(t)}function q2(){Sx=!1,ta!==null&&jh(ta)&&(ta=null),na!==null&&jh(na)&&(na=null),ra!==null&&jh(ra)&&(ra=null),Hd.forEach(O0),Vd.forEach(O0)}function qu(e,t){e.blockedOn===t&&(e.blockedOn=null,Sx||(Sx=!0,vs.unstable_scheduleCallback(vs.unstable_NormalPriority,q2)))}function Kd(e){function t(i){return qu(i,e)}if(0<Rp.length){qu(Rp[0],e);for(var n=1;n<Rp.length;n++){var r=Rp[n];r.blockedOn===e&&(r.blockedOn=null)}}for(ta!==null&&qu(ta,e),na!==null&&qu(na,e),ra!==null&&qu(ra,e),Hd.forEach(t),Vd.forEach(t),n=0;n<qo.length;n++)r=qo[n],r.blockedOn===e&&(r.blockedOn=null);for(;0<qo.length&&(n=qo[0],n.blockedOn===null);)TE(n),n.blockedOn===null&&qo.shift()}var Nc=ko.ReactCurrentBatchConfig,Zh=!0;function U2(e,t,n,r){var i=cn,o=Nc.transition;Nc.transition=null;try{cn=1,kk(e,t,n,r)}finally{cn=i,Nc.transition=o}}function G2(e,t,n,r){var i=cn,o=Nc.transition;Nc.transition=null;try{cn=4,kk(e,t,n,r)}finally{cn=i,Nc.transition=o}}function kk(e,t,n,r){if(Zh){var i=jx(e,t,n,r);if(i===null)Gy(e,t,r,em,n),L0(e,r);else if(K2(i,e,t,n,r))r.stopPropagation();else if(L0(e,r),t&4&&-1<V2.indexOf(e)){for(;i!==null;){var o=Pf(i);if(o!==null&&AE(o),o=jx(e,t,n,r),o===null&&Gy(e,t,r,em,n),o===i)break;i=o}i!==null&&r.stopPropagation()}else Gy(e,t,r,null,n)}}var em=null;function jx(e,t,n,r){if(em=null,e=yk(r),e=Ha(e),e!==null)if(t=xl(e),t===null)e=null;else if(n=t.tag,n===13){if(e=bE(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 em=e,null}function RE(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($2()){case wk:return 1;case jE:return 4;case Xh:case L2:return 16;case NE:return 536870912;default:return 16}default:return 16}}var Xo=null,vk=null,Nh=null;function ME(){if(Nh)return Nh;var e,t=vk,n=t.length,r,i="value"in Xo?Xo.value:Xo.textContent,o=i.length;for(e=0;e<n&&t[e]===i[e];e++);var a=n-e;for(r=1;r<=a&&t[n-r]===i[o-r];r++);return Nh=i.slice(e,1<r?1-r:void 0)}function _h(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 Mp(){return!0}function D0(){return!1}function Ns(e){function t(n,r,i,o,a){this._reactName=n,this._targetInst=i,this.type=r,this.nativeEvent=o,this.target=a,this.currentTarget=null;for(var l in e)e.hasOwnProperty(l)&&(n=e[l],this[l]=n?n(o):o[l]);return this.isDefaultPrevented=(o.defaultPrevented!=null?o.defaultPrevented:o.returnValue===!1)?Mp:D0,this.isPropagationStopped=D0,this}return Hn(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=Mp)},stopPropagation:function(){var n=this.nativeEvent;n&&(n.stopPropagation?n.stopPropagation():typeof n.cancelBubble!="unknown"&&(n.cancelBubble=!0),this.isPropagationStopped=Mp)},persist:function(){},isPersistent:Mp}),t}var nu={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Sk=Ns(nu),If=Hn({},nu,{view:0,detail:0}),Y2=Ns(If),Fy,zy,Uu,sg=Hn({},If,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:jk,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!==Uu&&(Uu&&e.type==="mousemove"?(Fy=e.screenX-Uu.screenX,zy=e.screenY-Uu.screenY):zy=Fy=0,Uu=e),Fy)},movementY:function(e){return"movementY"in e?e.movementY:zy}}),F0=Ns(sg),J2=Hn({},sg,{dataTransfer:0}),X2=Ns(J2),Q2=Hn({},If,{relatedTarget:0}),By=Ns(Q2),Z2=Hn({},nu,{animationName:0,elapsedTime:0,pseudoElement:0}),eD=Ns(Z2),tD=Hn({},nu,{clipboardData:function(e){return"clipboardData"in e?e.clipboardData:window.clipboardData}}),nD=Ns(tD),rD=Hn({},nu,{data:0}),z0=Ns(rD),sD={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},iD={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"},oD={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function aD(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=oD[e])?!!t[e]:!1}function jk(){return aD}var lD=Hn({},If,{key:function(e){if(e.key){var t=sD[e.key]||e.key;if(t!=="Unidentified")return t}return e.type==="keypress"?(e=_h(e),e===13?"Enter":String.fromCharCode(e)):e.type==="keydown"||e.type==="keyup"?iD[e.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:jk,charCode:function(e){return e.type==="keypress"?_h(e):0},keyCode:function(e){return e.type==="keydown"||e.type==="keyup"?e.keyCode:0},which:function(e){return e.type==="keypress"?_h(e):e.type==="keydown"||e.type==="keyup"?e.keyCode:0}}),cD=Ns(lD),uD=Hn({},sg,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),B0=Ns(uD),dD=Hn({},If,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:jk}),fD=Ns(dD),pD=Hn({},nu,{propertyName:0,elapsedTime:0,pseudoElement:0}),hD=Ns(pD),mD=Hn({},sg,{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}),gD=Ns(mD),yD=[9,13,27,32],Nk=po&&"CompositionEvent"in window,vd=null;po&&"documentMode"in document&&(vd=document.documentMode);var wD=po&&"TextEvent"in window&&!vd,$E=po&&(!Nk||vd&&8<vd&&11>=vd),W0=" ",H0=!1;function LE(e,t){switch(e){case"keyup":return yD.indexOf(t.keyCode)!==-1;case"keydown":return t.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function OE(e){return e=e.detail,typeof e=="object"&&"data"in e?e.data:null}var oc=!1;function xD(e,t){switch(e){case"compositionend":return OE(t);case"keypress":return t.which!==32?null:(H0=!0,W0);case"textInput":return e=t.data,e===W0&&H0?null:e;default:return null}}function bD(e,t){if(oc)return e==="compositionend"||!Nk&&LE(e,t)?(e=ME(),Nh=vk=Xo=null,oc=!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 $E&&t.locale!=="ko"?null:t.data;default:return null}}var kD={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 V0(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t==="input"?!!kD[e.type]:t==="textarea"}function DE(e,t,n,r){mE(r),t=tm(t,"onChange"),0<t.length&&(n=new Sk("onChange","change",null,n,r),e.push({event:n,listeners:t}))}var Sd=null,qd=null;function vD(e){YE(e,0)}function ig(e){var t=cc(e);if(lE(t))return e}function SD(e,t){if(e==="change")return t}var FE=!1;if(po){var Wy;if(po){var Hy="oninput"in document;if(!Hy){var K0=document.createElement("div");K0.setAttribute("oninput","return;"),Hy=typeof K0.oninput=="function"}Wy=Hy}else Wy=!1;FE=Wy&&(!document.documentMode||9<document.documentMode)}function q0(){Sd&&(Sd.detachEvent("onpropertychange",zE),qd=Sd=null)}function zE(e){if(e.propertyName==="value"&&ig(qd)){var t=[];DE(t,qd,e,yk(e)),xE(vD,t)}}function jD(e,t,n){e==="focusin"?(q0(),Sd=t,qd=n,Sd.attachEvent("onpropertychange",zE)):e==="focusout"&&q0()}function ND(e){if(e==="selectionchange"||e==="keyup"||e==="keydown")return ig(qd)}function _D(e,t){if(e==="click")return ig(t)}function CD(e,t){if(e==="input"||e==="change")return ig(t)}function AD(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var fi=typeof Object.is=="function"?Object.is:AD;function Ud(e,t){if(fi(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 i=n[r];if(!ox.call(t,i)||!fi(e[i],t[i]))return!1}return!0}function U0(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function G0(e,t){var n=U0(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=U0(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 WE(){for(var e=window,t=Gh();t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href=="string"}catch{n=!1}if(n)e=t.contentWindow;else break;t=Gh(e.document)}return t}function _k(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 ED(e){var t=WE(),n=e.focusedElem,r=e.selectionRange;if(t!==n&&n&&n.ownerDocument&&BE(n.ownerDocument.documentElement,n)){if(r!==null&&_k(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 i=n.textContent.length,o=Math.min(r.start,i);r=r.end===void 0?o:Math.min(r.end,i),!e.extend&&o>r&&(i=r,r=o,o=i),i=G0(n,o);var a=G0(n,r);i&&a&&(e.rangeCount!==1||e.anchorNode!==i.node||e.anchorOffset!==i.offset||e.focusNode!==a.node||e.focusOffset!==a.offset)&&(t=t.createRange(),t.setStart(i.node,i.offset),e.removeAllRanges(),o>r?(e.addRange(t),e.extend(a.node,a.offset)):(t.setEnd(a.node,a.offset),e.addRange(t)))}}for(t=[],e=n;e=e.parentNode;)e.nodeType===1&&t.push({element:e,left:e.scrollLeft,top:e.scrollTop});for(typeof n.focus=="function"&&n.focus(),n=0;n<t.length;n++)e=t[n],e.element.scrollLeft=e.left,e.element.scrollTop=e.top}}var ID=po&&"documentMode"in document&&11>=document.documentMode,ac=null,Nx=null,jd=null,_x=!1;function Y0(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;_x||ac==null||ac!==Gh(r)||(r=ac,"selectionStart"in r&&_k(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&&Ud(jd,r)||(jd=r,r=tm(Nx,"onSelect"),0<r.length&&(t=new Sk("onSelect","select",null,t,n),e.push({event:t,listeners:r}),t.target=ac)))}function $p(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n["Webkit"+e]="webkit"+t,n["Moz"+e]="moz"+t,n}var lc={animationend:$p("Animation","AnimationEnd"),animationiteration:$p("Animation","AnimationIteration"),animationstart:$p("Animation","AnimationStart"),transitionend:$p("Transition","TransitionEnd")},Vy={},HE={};po&&(HE=document.createElement("div").style,"AnimationEvent"in window||(delete lc.animationend.animation,delete lc.animationiteration.animation,delete lc.animationstart.animation),"TransitionEvent"in window||delete lc.transitionend.transition);function og(e){if(Vy[e])return Vy[e];if(!lc[e])return e;var t=lc[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in HE)return Vy[e]=t[n];return e}var VE=og("animationend"),KE=og("animationiteration"),qE=og("animationstart"),UE=og("transitionend"),GE=new Map,J0="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 ba(e,t){GE.set(e,t),wl(t,[e])}for(var Ky=0;Ky<J0.length;Ky++){var qy=J0[Ky],PD=qy.toLowerCase(),TD=qy[0].toUpperCase()+qy.slice(1);ba(PD,"on"+TD)}ba(VE,"onAnimationEnd");ba(KE,"onAnimationIteration");ba(qE,"onAnimationStart");ba("dblclick","onDoubleClick");ba("focusin","onFocus");ba("focusout","onBlur");ba(UE,"onTransitionEnd");Lc("onMouseEnter",["mouseout","mouseover"]);Lc("onMouseLeave",["mouseout","mouseover"]);Lc("onPointerEnter",["pointerout","pointerover"]);Lc("onPointerLeave",["pointerout","pointerover"]);wl("onChange","change click focusin focusout input keydown keyup selectionchange".split(" "));wl("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" "));wl("onBeforeInput",["compositionend","keypress","textInput","paste"]);wl("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" "));wl("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" "));wl("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var dd="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(" "),RD=new Set("cancel close invalid load scroll toggle".split(" ").concat(dd));function X0(e,t,n){var r=e.type||"unknown-event";e.currentTarget=n,P2(r,t,void 0,e),e.currentTarget=null}function YE(e,t){t=(t&4)!==0;for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;e:{var o=void 0;if(t)for(var a=r.length-1;0<=a;a--){var l=r[a],c=l.instance,u=l.currentTarget;if(l=l.listener,c!==o&&i.isPropagationStopped())break e;X0(i,l,u),o=c}else for(a=0;a<r.length;a++){if(l=r[a],c=l.instance,u=l.currentTarget,l=l.listener,c!==o&&i.isPropagationStopped())break e;X0(i,l,u),o=c}}}if(Jh)throw e=kx,Jh=!1,kx=null,e}function An(e,t){var n=t[Px];n===void 0&&(n=t[Px]=new Set);var r=e+"__bubble";n.has(r)||(JE(t,e,2,!1),n.add(r))}function Uy(e,t,n){var r=0;t&&(r|=4),JE(n,e,r,t)}var Lp="_reactListening"+Math.random().toString(36).slice(2);function Gd(e){if(!e[Lp]){e[Lp]=!0,rE.forEach(function(n){n!=="selectionchange"&&(RD.has(n)||Uy(n,!1,e),Uy(n,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[Lp]||(t[Lp]=!0,Uy("selectionchange",!1,t))}}function JE(e,t,n,r){switch(RE(t)){case 1:var i=U2;break;case 4:i=G2;break;default:i=kk}n=i.bind(null,t,n,e),i=void 0,!bx||t!=="touchstart"&&t!=="touchmove"&&t!=="wheel"||(i=!0),r?i!==void 0?e.addEventListener(t,n,{capture:!0,passive:i}):e.addEventListener(t,n,!0):i!==void 0?e.addEventListener(t,n,{passive:i}):e.addEventListener(t,n,!1)}function Gy(e,t,n,r,i){var o=r;if(!(t&1)&&!(t&2)&&r!==null)e:for(;;){if(r===null)return;var a=r.tag;if(a===3||a===4){var l=r.stateNode.containerInfo;if(l===i||l.nodeType===8&&l.parentNode===i)break;if(a===4)for(a=r.return;a!==null;){var c=a.tag;if((c===3||c===4)&&(c=a.stateNode.containerInfo,c===i||c.nodeType===8&&c.parentNode===i))return;a=a.return}for(;l!==null;){if(a=Ha(l),a===null)return;if(c=a.tag,c===5||c===6){r=o=a;continue e}l=l.parentNode}}r=r.return}xE(function(){var u=o,f=yk(n),p=[];e:{var d=GE.get(e);if(d!==void 0){var m=Sk,y=e;switch(e){case"keypress":if(_h(n)===0)break e;case"keydown":case"keyup":m=cD;break;case"focusin":y="focus",m=By;break;case"focusout":y="blur",m=By;break;case"beforeblur":case"afterblur":m=By;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=F0;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":m=X2;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":m=fD;break;case VE:case KE:case qE:m=eD;break;case UE:m=hD;break;case"scroll":m=Y2;break;case"wheel":m=gD;break;case"copy":case"cut":case"paste":m=nD;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":m=B0}var v=(t&4)!==0,b=!v&&e==="scroll",g=v?d!==null?d+"Capture":null:d;v=[];for(var k=u,x;k!==null;){x=k;var _=x.stateNode;if(x.tag===5&&_!==null&&(x=_,g!==null&&(_=Wd(k,g),_!=null&&v.push(Yd(k,_,x)))),b)break;k=k.return}0<v.length&&(d=new m(d,y,null,n,f),p.push({event:d,listeners:v}))}}if(!(t&7)){e:{if(d=e==="mouseover"||e==="pointerover",m=e==="mouseout"||e==="pointerout",d&&n!==wx&&(y=n.relatedTarget||n.fromElement)&&(Ha(y)||y[ho]))break e;if((m||d)&&(d=f.window===f?f:(d=f.ownerDocument)?d.defaultView||d.parentWindow:window,m?(y=n.relatedTarget||n.toElement,m=u,y=y?Ha(y):null,y!==null&&(b=xl(y),y!==b||y.tag!==5&&y.tag!==6)&&(y=null)):(m=null,y=u),m!==y)){if(v=F0,_="onMouseLeave",g="onMouseEnter",k="mouse",(e==="pointerout"||e==="pointerover")&&(v=B0,_="onPointerLeave",g="onPointerEnter",k="pointer"),b=m==null?d:cc(m),x=y==null?d:cc(y),d=new v(_,k+"leave",m,n,f),d.target=b,d.relatedTarget=x,_=null,Ha(f)===u&&(v=new v(g,k+"enter",y,n,f),v.target=x,v.relatedTarget=b,_=v),b=_,m&&y)t:{for(v=m,g=y,k=0,x=v;x;x=Kl(x))k++;for(x=0,_=g;_;_=Kl(_))x++;for(;0<k-x;)v=Kl(v),k--;for(;0<x-k;)g=Kl(g),x--;for(;k--;){if(v===g||g!==null&&v===g.alternate)break t;v=Kl(v),g=Kl(g)}v=null}else v=null;m!==null&&Q0(p,d,m,v,!1),y!==null&&b!==null&&Q0(p,b,y,v,!0)}}e:{if(d=u?cc(u):window,m=d.nodeName&&d.nodeName.toLowerCase(),m==="select"||m==="input"&&d.type==="file")var j=SD;else if(V0(d))if(FE)j=CD;else{j=ND;var N=jD}else(m=d.nodeName)&&m.toLowerCase()==="input"&&(d.type==="checkbox"||d.type==="radio")&&(j=_D);if(j&&(j=j(e,u))){DE(p,j,n,f);break e}N&&N(e,d,u),e==="focusout"&&(N=d._wrapperState)&&N.controlled&&d.type==="number"&&px(d,"number",d.value)}switch(N=u?cc(u):window,e){case"focusin":(V0(N)||N.contentEditable==="true")&&(ac=N,Nx=u,jd=null);break;case"focusout":jd=Nx=ac=null;break;case"mousedown":_x=!0;break;case"contextmenu":case"mouseup":case"dragend":_x=!1,Y0(p,n,f);break;case"selectionchange":if(ID)break;case"keydown":case"keyup":Y0(p,n,f)}var P;if(Nk)e:{switch(e){case"compositionstart":var T="onCompositionStart";break e;case"compositionend":T="onCompositionEnd";break e;case"compositionupdate":T="onCompositionUpdate";break e}T=void 0}else oc?LE(e,n)&&(T="onCompositionEnd"):e==="keydown"&&n.keyCode===229&&(T="onCompositionStart");T&&($E&&n.locale!=="ko"&&(oc||T!=="onCompositionStart"?T==="onCompositionEnd"&&oc&&(P=ME()):(Xo=f,vk="value"in Xo?Xo.value:Xo.textContent,oc=!0)),N=tm(u,T),0<N.length&&(T=new z0(T,e,null,n,f),p.push({event:T,listeners:N}),P?T.data=P:(P=OE(n),P!==null&&(T.data=P)))),(P=wD?xD(e,n):bD(e,n))&&(u=tm(u,"onBeforeInput"),0<u.length&&(f=new z0("onBeforeInput","beforeinput",null,n,f),p.push({event:f,listeners:u}),f.data=P))}YE(p,t)})}function Yd(e,t,n){return{instance:e,listener:t,currentTarget:n}}function tm(e,t){for(var n=t+"Capture",r=[];e!==null;){var i=e,o=i.stateNode;i.tag===5&&o!==null&&(i=o,o=Wd(e,n),o!=null&&r.unshift(Yd(e,o,i)),o=Wd(e,t),o!=null&&r.push(Yd(e,o,i))),e=e.return}return r}function Kl(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5);return e||null}function Q0(e,t,n,r,i){for(var o=t._reactName,a=[];n!==null&&n!==r;){var l=n,c=l.alternate,u=l.stateNode;if(c!==null&&c===r)break;l.tag===5&&u!==null&&(l=u,i?(c=Wd(n,o),c!=null&&a.unshift(Yd(n,c,l))):i||(c=Wd(n,o),c!=null&&a.push(Yd(n,c,l)))),n=n.return}a.length!==0&&e.push({event:t,listeners:a})}var MD=/\r\n?/g,$D=/\u0000|\uFFFD/g;function Z0(e){return(typeof e=="string"?e:""+e).replace(MD,`
|
|
38
|
+
`).replace($D,"")}function Op(e,t,n){if(t=Z0(t),Z0(e)!==t&&n)throw Error(Pe(425))}function nm(){}var Cx=null,Ax=null;function Ex(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 Ix=typeof setTimeout=="function"?setTimeout:void 0,LD=typeof clearTimeout=="function"?clearTimeout:void 0,eN=typeof Promise=="function"?Promise:void 0,OD=typeof queueMicrotask=="function"?queueMicrotask:typeof eN<"u"?function(e){return eN.resolve(null).then(e).catch(DD)}:Ix;function DD(e){setTimeout(function(){throw e})}function Yy(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8)if(n=i.data,n==="/$"){if(r===0){e.removeChild(i),Kd(t);return}r--}else n!=="$"&&n!=="$?"&&n!=="$!"||r++;n=i}while(n);Kd(t)}function sa(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 tN(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 ru=Math.random().toString(36).slice(2),Ai="__reactFiber$"+ru,Jd="__reactProps$"+ru,ho="__reactContainer$"+ru,Px="__reactEvents$"+ru,FD="__reactListeners$"+ru,zD="__reactHandles$"+ru;function Ha(e){var t=e[Ai];if(t)return t;for(var n=e.parentNode;n;){if(t=n[ho]||n[Ai]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=tN(e);e!==null;){if(n=e[Ai])return n;e=tN(e)}return t}e=n,n=e.parentNode}return null}function Pf(e){return e=e[Ai]||e[ho],!e||e.tag!==5&&e.tag!==6&&e.tag!==13&&e.tag!==3?null:e}function cc(e){if(e.tag===5||e.tag===6)return e.stateNode;throw Error(Pe(33))}function ag(e){return e[Jd]||null}var Tx=[],uc=-1;function ka(e){return{current:e}}function In(e){0>uc||(e.current=Tx[uc],Tx[uc]=null,uc--)}function bn(e,t){uc++,Tx[uc]=e.current,e.current=t}var fa={},Fr=ka(fa),os=ka(!1),nl=fa;function Oc(e,t){var n=e.type.contextTypes;if(!n)return fa;var r=e.stateNode;if(r&&r.__reactInternalMemoizedUnmaskedChildContext===t)return r.__reactInternalMemoizedMaskedChildContext;var i={},o;for(o in n)i[o]=t[o];return r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=t,e.__reactInternalMemoizedMaskedChildContext=i),i}function as(e){return e=e.childContextTypes,e!=null}function rm(){In(os),In(Fr)}function nN(e,t,n){if(Fr.current!==fa)throw Error(Pe(168));bn(Fr,t),bn(os,n)}function XE(e,t,n){var r=e.stateNode;if(t=t.childContextTypes,typeof r.getChildContext!="function")return n;r=r.getChildContext();for(var i in r)if(!(i in t))throw Error(Pe(108,j2(e)||"Unknown",i));return Hn({},n,r)}function sm(e){return e=(e=e.stateNode)&&e.__reactInternalMemoizedMergedChildContext||fa,nl=Fr.current,bn(Fr,e),bn(os,os.current),!0}function rN(e,t,n){var r=e.stateNode;if(!r)throw Error(Pe(169));n?(e=XE(e,t,nl),r.__reactInternalMemoizedMergedChildContext=e,In(os),In(Fr),bn(Fr,e)):In(os),bn(os,n)}var to=null,lg=!1,Jy=!1;function QE(e){to===null?to=[e]:to.push(e)}function BD(e){lg=!0,QE(e)}function va(){if(!Jy&&to!==null){Jy=!0;var e=0,t=cn;try{var n=to;for(cn=1;e<n.length;e++){var r=n[e];do r=r(!0);while(r!==null)}to=null,lg=!1}catch(i){throw to!==null&&(to=to.slice(e+1)),SE(wk,va),i}finally{cn=t,Jy=!1}}return null}var dc=[],fc=0,im=null,om=0,Ls=[],Os=0,rl=null,ro=1,so="";function La(e,t){dc[fc++]=om,dc[fc++]=im,im=e,om=t}function ZE(e,t,n){Ls[Os++]=ro,Ls[Os++]=so,Ls[Os++]=rl,rl=e;var r=ro;e=so;var i=32-ci(r)-1;r&=~(1<<i),n+=1;var o=32-ci(t)+i;if(30<o){var a=i-i%5;o=(r&(1<<a)-1).toString(32),r>>=a,i-=a,ro=1<<32-ci(t)+i|n<<i|r,so=o+e}else ro=1<<o|n<<i|r,so=e}function Ck(e){e.return!==null&&(La(e,1),ZE(e,1,0))}function Ak(e){for(;e===im;)im=dc[--fc],dc[fc]=null,om=dc[--fc],dc[fc]=null;for(;e===rl;)rl=Ls[--Os],Ls[Os]=null,so=Ls[--Os],Ls[Os]=null,ro=Ls[--Os],Ls[Os]=null}var bs=null,ws=null,Rn=!1,si=null;function eI(e,t){var n=zs(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 sN(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,bs=e,ws=sa(t.firstChild),!0):!1;case 6:return t=e.pendingProps===""||t.nodeType!==3?null:t,t!==null?(e.stateNode=t,bs=e,ws=null,!0):!1;case 13:return t=t.nodeType!==8?null:t,t!==null?(n=rl!==null?{id:ro,overflow:so}:null,e.memoizedState={dehydrated:t,treeContext:n,retryLane:1073741824},n=zs(18,null,null,0),n.stateNode=t,n.return=e,e.child=n,bs=e,ws=null,!0):!1;default:return!1}}function Rx(e){return(e.mode&1)!==0&&(e.flags&128)===0}function Mx(e){if(Rn){var t=ws;if(t){var n=t;if(!sN(e,t)){if(Rx(e))throw Error(Pe(418));t=sa(n.nextSibling);var r=bs;t&&sN(e,t)?eI(r,n):(e.flags=e.flags&-4097|2,Rn=!1,bs=e)}}else{if(Rx(e))throw Error(Pe(418));e.flags=e.flags&-4097|2,Rn=!1,bs=e}}}function iN(e){for(e=e.return;e!==null&&e.tag!==5&&e.tag!==3&&e.tag!==13;)e=e.return;bs=e}function Dp(e){if(e!==bs)return!1;if(!Rn)return iN(e),Rn=!0,!1;var t;if((t=e.tag!==3)&&!(t=e.tag!==5)&&(t=e.type,t=t!=="head"&&t!=="body"&&!Ex(e.type,e.memoizedProps)),t&&(t=ws)){if(Rx(e))throw tI(),Error(Pe(418));for(;t;)eI(e,t),t=sa(t.nextSibling)}if(iN(e),e.tag===13){if(e=e.memoizedState,e=e!==null?e.dehydrated:null,!e)throw Error(Pe(317));e:{for(e=e.nextSibling,t=0;e;){if(e.nodeType===8){var n=e.data;if(n==="/$"){if(t===0){ws=sa(e.nextSibling);break e}t--}else n!=="$"&&n!=="$!"&&n!=="$?"||t++}e=e.nextSibling}ws=null}}else ws=bs?sa(e.stateNode.nextSibling):null;return!0}function tI(){for(var e=ws;e;)e=sa(e.nextSibling)}function Dc(){ws=bs=null,Rn=!1}function Ek(e){si===null?si=[e]:si.push(e)}var WD=ko.ReactCurrentBatchConfig;function Gu(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(Pe(309));var r=n.stateNode}if(!r)throw Error(Pe(147,e));var i=r,o=""+e;return t!==null&&t.ref!==null&&typeof t.ref=="function"&&t.ref._stringRef===o?t.ref:(t=function(a){var l=i.refs;a===null?delete l[o]:l[o]=a},t._stringRef=o,t)}if(typeof e!="string")throw Error(Pe(284));if(!n._owner)throw Error(Pe(290,e))}return e}function Fp(e,t){throw e=Object.prototype.toString.call(t),Error(Pe(31,e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e))}function oN(e){var t=e._init;return t(e._payload)}function nI(e){function t(g,k){if(e){var x=g.deletions;x===null?(g.deletions=[k],g.flags|=16):x.push(k)}}function n(g,k){if(!e)return null;for(;k!==null;)t(g,k),k=k.sibling;return null}function r(g,k){for(g=new Map;k!==null;)k.key!==null?g.set(k.key,k):g.set(k.index,k),k=k.sibling;return g}function i(g,k){return g=la(g,k),g.index=0,g.sibling=null,g}function o(g,k,x){return g.index=x,e?(x=g.alternate,x!==null?(x=x.index,x<k?(g.flags|=2,k):x):(g.flags|=2,k)):(g.flags|=1048576,k)}function a(g){return e&&g.alternate===null&&(g.flags|=2),g}function l(g,k,x,_){return k===null||k.tag!==6?(k=rw(x,g.mode,_),k.return=g,k):(k=i(k,x),k.return=g,k)}function c(g,k,x,_){var j=x.type;return j===ic?f(g,k,x.props.children,_,x.key):k!==null&&(k.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===Ho&&oN(j)===k.type)?(_=i(k,x.props),_.ref=Gu(g,k,x),_.return=g,_):(_=Rh(x.type,x.key,x.props,null,g.mode,_),_.ref=Gu(g,k,x),_.return=g,_)}function u(g,k,x,_){return k===null||k.tag!==4||k.stateNode.containerInfo!==x.containerInfo||k.stateNode.implementation!==x.implementation?(k=sw(x,g.mode,_),k.return=g,k):(k=i(k,x.children||[]),k.return=g,k)}function f(g,k,x,_,j){return k===null||k.tag!==7?(k=Ja(x,g.mode,_,j),k.return=g,k):(k=i(k,x),k.return=g,k)}function p(g,k,x){if(typeof k=="string"&&k!==""||typeof k=="number")return k=rw(""+k,g.mode,x),k.return=g,k;if(typeof k=="object"&&k!==null){switch(k.$$typeof){case Ap:return x=Rh(k.type,k.key,k.props,null,g.mode,x),x.ref=Gu(g,null,k),x.return=g,x;case sc:return k=sw(k,g.mode,x),k.return=g,k;case Ho:var _=k._init;return p(g,_(k._payload),x)}if(cd(k)||Hu(k))return k=Ja(k,g.mode,x,null),k.return=g,k;Fp(g,k)}return null}function d(g,k,x,_){var j=k!==null?k.key:null;if(typeof x=="string"&&x!==""||typeof x=="number")return j!==null?null:l(g,k,""+x,_);if(typeof x=="object"&&x!==null){switch(x.$$typeof){case Ap:return x.key===j?c(g,k,x,_):null;case sc:return x.key===j?u(g,k,x,_):null;case Ho:return j=x._init,d(g,k,j(x._payload),_)}if(cd(x)||Hu(x))return j!==null?null:f(g,k,x,_,null);Fp(g,x)}return null}function m(g,k,x,_,j){if(typeof _=="string"&&_!==""||typeof _=="number")return g=g.get(x)||null,l(k,g,""+_,j);if(typeof _=="object"&&_!==null){switch(_.$$typeof){case Ap:return g=g.get(_.key===null?x:_.key)||null,c(k,g,_,j);case sc:return g=g.get(_.key===null?x:_.key)||null,u(k,g,_,j);case Ho:var N=_._init;return m(g,k,x,N(_._payload),j)}if(cd(_)||Hu(_))return g=g.get(x)||null,f(k,g,_,j,null);Fp(k,_)}return null}function y(g,k,x,_){for(var j=null,N=null,P=k,T=k=0,z=null;P!==null&&T<x.length;T++){P.index>T?(z=P,P=null):z=P.sibling;var E=d(g,P,x[T],_);if(E===null){P===null&&(P=z);break}e&&P&&E.alternate===null&&t(g,P),k=o(E,k,T),N===null?j=E:N.sibling=E,N=E,P=z}if(T===x.length)return n(g,P),Rn&&La(g,T),j;if(P===null){for(;T<x.length;T++)P=p(g,x[T],_),P!==null&&(k=o(P,k,T),N===null?j=P:N.sibling=P,N=P);return Rn&&La(g,T),j}for(P=r(g,P);T<x.length;T++)z=m(P,g,T,x[T],_),z!==null&&(e&&z.alternate!==null&&P.delete(z.key===null?T:z.key),k=o(z,k,T),N===null?j=z:N.sibling=z,N=z);return e&&P.forEach(function(O){return t(g,O)}),Rn&&La(g,T),j}function v(g,k,x,_){var j=Hu(x);if(typeof j!="function")throw Error(Pe(150));if(x=j.call(x),x==null)throw Error(Pe(151));for(var N=j=null,P=k,T=k=0,z=null,E=x.next();P!==null&&!E.done;T++,E=x.next()){P.index>T?(z=P,P=null):z=P.sibling;var O=d(g,P,E.value,_);if(O===null){P===null&&(P=z);break}e&&P&&O.alternate===null&&t(g,P),k=o(O,k,T),N===null?j=O:N.sibling=O,N=O,P=z}if(E.done)return n(g,P),Rn&&La(g,T),j;if(P===null){for(;!E.done;T++,E=x.next())E=p(g,E.value,_),E!==null&&(k=o(E,k,T),N===null?j=E:N.sibling=E,N=E);return Rn&&La(g,T),j}for(P=r(g,P);!E.done;T++,E=x.next())E=m(P,g,T,E.value,_),E!==null&&(e&&E.alternate!==null&&P.delete(E.key===null?T:E.key),k=o(E,k,T),N===null?j=E:N.sibling=E,N=E);return e&&P.forEach(function(D){return t(g,D)}),Rn&&La(g,T),j}function b(g,k,x,_){if(typeof x=="object"&&x!==null&&x.type===ic&&x.key===null&&(x=x.props.children),typeof x=="object"&&x!==null){switch(x.$$typeof){case Ap:e:{for(var j=x.key,N=k;N!==null;){if(N.key===j){if(j=x.type,j===ic){if(N.tag===7){n(g,N.sibling),k=i(N,x.props.children),k.return=g,g=k;break e}}else if(N.elementType===j||typeof j=="object"&&j!==null&&j.$$typeof===Ho&&oN(j)===N.type){n(g,N.sibling),k=i(N,x.props),k.ref=Gu(g,N,x),k.return=g,g=k;break e}n(g,N);break}else t(g,N);N=N.sibling}x.type===ic?(k=Ja(x.props.children,g.mode,_,x.key),k.return=g,g=k):(_=Rh(x.type,x.key,x.props,null,g.mode,_),_.ref=Gu(g,k,x),_.return=g,g=_)}return a(g);case sc:e:{for(N=x.key;k!==null;){if(k.key===N)if(k.tag===4&&k.stateNode.containerInfo===x.containerInfo&&k.stateNode.implementation===x.implementation){n(g,k.sibling),k=i(k,x.children||[]),k.return=g,g=k;break e}else{n(g,k);break}else t(g,k);k=k.sibling}k=sw(x,g.mode,_),k.return=g,g=k}return a(g);case Ho:return N=x._init,b(g,k,N(x._payload),_)}if(cd(x))return y(g,k,x,_);if(Hu(x))return v(g,k,x,_);Fp(g,x)}return typeof x=="string"&&x!==""||typeof x=="number"?(x=""+x,k!==null&&k.tag===6?(n(g,k.sibling),k=i(k,x),k.return=g,g=k):(n(g,k),k=rw(x,g.mode,_),k.return=g,g=k),a(g)):n(g,k)}return b}var Fc=nI(!0),rI=nI(!1),am=ka(null),lm=null,pc=null,Ik=null;function Pk(){Ik=pc=lm=null}function Tk(e){var t=am.current;In(am),e._currentValue=t}function $x(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 _c(e,t){lm=e,Ik=pc=null,e=e.dependencies,e!==null&&e.firstContext!==null&&(e.lanes&t&&(rs=!0),e.firstContext=null)}function Ws(e){var t=e._currentValue;if(Ik!==e)if(e={context:e,memoizedValue:t,next:null},pc===null){if(lm===null)throw Error(Pe(308));pc=e,lm.dependencies={lanes:0,firstContext:e}}else pc=pc.next=e;return t}var Va=null;function Rk(e){Va===null?Va=[e]:Va.push(e)}function sI(e,t,n,r){var i=t.interleaved;return i===null?(n.next=n,Rk(t)):(n.next=i.next,i.next=n),t.interleaved=n,mo(e,r)}function mo(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 Vo=!1;function Mk(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function iI(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 lo(e,t){return{eventTime:e,lane:t,tag:0,payload:null,callback:null,next:null}}function ia(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,Xt&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,mo(e,n)}return i=r.interleaved,i===null?(t.next=t,Rk(r)):(t.next=i.next,i.next=t),r.interleaved=t,mo(e,n)}function Ch(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,xk(e,n)}}function aN(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,o=null;if(n=n.firstBaseUpdate,n!==null){do{var a={eventTime:n.eventTime,lane:n.lane,tag:n.tag,payload:n.payload,callback:n.callback,next:null};o===null?i=o=a:o=o.next=a,n=n.next}while(n!==null);o===null?i=o=t:o=o.next=t}else i=o=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:o,shared:r.shared,effects:r.effects},e.updateQueue=n;return}e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}function cm(e,t,n,r){var i=e.updateQueue;Vo=!1;var o=i.firstBaseUpdate,a=i.lastBaseUpdate,l=i.shared.pending;if(l!==null){i.shared.pending=null;var c=l,u=c.next;c.next=null,a===null?o=u:a.next=u,a=c;var f=e.alternate;f!==null&&(f=f.updateQueue,l=f.lastBaseUpdate,l!==a&&(l===null?f.firstBaseUpdate=u:l.next=u,f.lastBaseUpdate=c))}if(o!==null){var p=i.baseState;a=0,f=u=c=null,l=o;do{var d=l.lane,m=l.eventTime;if((r&d)===d){f!==null&&(f=f.next={eventTime:m,lane:0,tag:l.tag,payload:l.payload,callback:l.callback,next:null});e:{var y=e,v=l;switch(d=t,m=n,v.tag){case 1:if(y=v.payload,typeof y=="function"){p=y.call(m,p,d);break e}p=y;break e;case 3:y.flags=y.flags&-65537|128;case 0:if(y=v.payload,d=typeof y=="function"?y.call(m,p,d):y,d==null)break e;p=Hn({},p,d);break e;case 2:Vo=!0}}l.callback!==null&&l.lane!==0&&(e.flags|=64,d=i.effects,d===null?i.effects=[l]:d.push(l))}else m={eventTime:m,lane:d,tag:l.tag,payload:l.payload,callback:l.callback,next:null},f===null?(u=f=m,c=p):f=f.next=m,a|=d;if(l=l.next,l===null){if(l=i.shared.pending,l===null)break;d=l,l=d.next,d.next=null,i.lastBaseUpdate=d,i.shared.pending=null}}while(!0);if(f===null&&(c=p),i.baseState=c,i.firstBaseUpdate=u,i.lastBaseUpdate=f,t=i.shared.interleaved,t!==null){i=t;do a|=i.lane,i=i.next;while(i!==t)}else o===null&&(i.shared.lanes=0);il|=a,e.lanes=a,e.memoizedState=p}}function lN(e,t,n){if(e=t.effects,t.effects=null,e!==null)for(t=0;t<e.length;t++){var r=e[t],i=r.callback;if(i!==null){if(r.callback=null,r=n,typeof i!="function")throw Error(Pe(191,i));i.call(r)}}}var Tf={},$i=ka(Tf),Xd=ka(Tf),Qd=ka(Tf);function Ka(e){if(e===Tf)throw Error(Pe(174));return e}function $k(e,t){switch(bn(Qd,t),bn(Xd,e),bn($i,Tf),e=t.nodeType,e){case 9:case 11:t=(t=t.documentElement)?t.namespaceURI:mx(null,"");break;default:e=e===8?t.parentNode:t,t=e.namespaceURI||null,e=e.tagName,t=mx(t,e)}In($i),bn($i,t)}function zc(){In($i),In(Xd),In(Qd)}function oI(e){Ka(Qd.current);var t=Ka($i.current),n=mx(t,e.type);t!==n&&(bn(Xd,e),bn($i,n))}function Lk(e){Xd.current===e&&(In($i),In(Xd))}var zn=ka(0);function um(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 Xy=[];function Ok(){for(var e=0;e<Xy.length;e++)Xy[e]._workInProgressVersionPrimary=null;Xy.length=0}var Ah=ko.ReactCurrentDispatcher,Qy=ko.ReactCurrentBatchConfig,sl=0,Wn=null,hr=null,vr=null,dm=!1,Nd=!1,Zd=0,HD=0;function Rr(){throw Error(Pe(321))}function Dk(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!fi(e[n],t[n]))return!1;return!0}function Fk(e,t,n,r,i,o){if(sl=o,Wn=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,Ah.current=e===null||e.memoizedState===null?UD:GD,e=n(r,i),Nd){o=0;do{if(Nd=!1,Zd=0,25<=o)throw Error(Pe(301));o+=1,vr=hr=null,t.updateQueue=null,Ah.current=YD,e=n(r,i)}while(Nd)}if(Ah.current=fm,t=hr!==null&&hr.next!==null,sl=0,vr=hr=Wn=null,dm=!1,t)throw Error(Pe(300));return e}function zk(){var e=Zd!==0;return Zd=0,e}function ji(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return vr===null?Wn.memoizedState=vr=e:vr=vr.next=e,vr}function Hs(){if(hr===null){var e=Wn.alternate;e=e!==null?e.memoizedState:null}else e=hr.next;var t=vr===null?Wn.memoizedState:vr.next;if(t!==null)vr=t,hr=e;else{if(e===null)throw Error(Pe(310));hr=e,e={memoizedState:hr.memoizedState,baseState:hr.baseState,baseQueue:hr.baseQueue,queue:hr.queue,next:null},vr===null?Wn.memoizedState=vr=e:vr=vr.next=e}return vr}function ef(e,t){return typeof t=="function"?t(e):t}function Zy(e){var t=Hs(),n=t.queue;if(n===null)throw Error(Pe(311));n.lastRenderedReducer=e;var r=hr,i=r.baseQueue,o=n.pending;if(o!==null){if(i!==null){var a=i.next;i.next=o.next,o.next=a}r.baseQueue=i=o,n.pending=null}if(i!==null){o=i.next,r=r.baseState;var l=a=null,c=null,u=o;do{var f=u.lane;if((sl&f)===f)c!==null&&(c=c.next={lane:0,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),r=u.hasEagerState?u.eagerState:e(r,u.action);else{var p={lane:f,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null};c===null?(l=c=p,a=r):c=c.next=p,Wn.lanes|=f,il|=f}u=u.next}while(u!==null&&u!==o);c===null?a=r:c.next=l,fi(r,t.memoizedState)||(rs=!0),t.memoizedState=r,t.baseState=a,t.baseQueue=c,n.lastRenderedState=r}if(e=n.interleaved,e!==null){i=e;do o=i.lane,Wn.lanes|=o,il|=o,i=i.next;while(i!==e)}else i===null&&(n.lanes=0);return[t.memoizedState,n.dispatch]}function ew(e){var t=Hs(),n=t.queue;if(n===null)throw Error(Pe(311));n.lastRenderedReducer=e;var r=n.dispatch,i=n.pending,o=t.memoizedState;if(i!==null){n.pending=null;var a=i=i.next;do o=e(o,a.action),a=a.next;while(a!==i);fi(o,t.memoizedState)||(rs=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function aI(){}function lI(e,t){var n=Wn,r=Hs(),i=t(),o=!fi(r.memoizedState,i);if(o&&(r.memoizedState=i,rs=!0),r=r.queue,Bk(dI.bind(null,n,r,e),[e]),r.getSnapshot!==t||o||vr!==null&&vr.memoizedState.tag&1){if(n.flags|=2048,tf(9,uI.bind(null,n,r,i,t),void 0,null),Nr===null)throw Error(Pe(349));sl&30||cI(n,t,i)}return i}function cI(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Wn.updateQueue,t===null?(t={lastEffect:null,stores:null},Wn.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function uI(e,t,n,r){t.value=n,t.getSnapshot=r,fI(t)&&pI(e)}function dI(e,t,n){return n(function(){fI(t)&&pI(e)})}function fI(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!fi(e,n)}catch{return!0}}function pI(e){var t=mo(e,1);t!==null&&ui(t,e,1,-1)}function cN(e){var t=ji();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=qD.bind(null,Wn,e),[t.memoizedState,e]}function tf(e,t,n,r){return e={tag:e,create:t,destroy:n,deps:r,next:null},t=Wn.updateQueue,t===null?(t={lastEffect:null,stores:null},Wn.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 hI(){return Hs().memoizedState}function Eh(e,t,n,r){var i=ji();Wn.flags|=e,i.memoizedState=tf(1|t,n,void 0,r===void 0?null:r)}function cg(e,t,n,r){var i=Hs();r=r===void 0?null:r;var o=void 0;if(hr!==null){var a=hr.memoizedState;if(o=a.destroy,r!==null&&Dk(r,a.deps)){i.memoizedState=tf(t,n,o,r);return}}Wn.flags|=e,i.memoizedState=tf(1|t,n,o,r)}function uN(e,t){return Eh(8390656,8,e,t)}function Bk(e,t){return cg(2048,8,e,t)}function mI(e,t){return cg(4,2,e,t)}function gI(e,t){return cg(4,4,e,t)}function yI(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 wI(e,t,n){return n=n!=null?n.concat([e]):null,cg(4,4,yI.bind(null,t,e),n)}function Wk(){}function xI(e,t){var n=Hs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Dk(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function bI(e,t){var n=Hs();t=t===void 0?null:t;var r=n.memoizedState;return r!==null&&t!==null&&Dk(t,r[1])?r[0]:(e=e(),n.memoizedState=[e,t],e)}function kI(e,t,n){return sl&21?(fi(n,t)||(n=_E(),Wn.lanes|=n,il|=n,e.baseState=!0),t):(e.baseState&&(e.baseState=!1,rs=!0),e.memoizedState=n)}function VD(e,t){var n=cn;cn=n!==0&&4>n?n:4,e(!0);var r=Qy.transition;Qy.transition={};try{e(!1),t()}finally{cn=n,Qy.transition=r}}function vI(){return Hs().memoizedState}function KD(e,t,n){var r=aa(e);if(n={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null},SI(e))jI(t,n);else if(n=sI(e,t,n,r),n!==null){var i=Gr();ui(n,e,r,i),NI(n,t,r)}}function qD(e,t,n){var r=aa(e),i={lane:r,action:n,hasEagerState:!1,eagerState:null,next:null};if(SI(e))jI(t,i);else{var o=e.alternate;if(e.lanes===0&&(o===null||o.lanes===0)&&(o=t.lastRenderedReducer,o!==null))try{var a=t.lastRenderedState,l=o(a,n);if(i.hasEagerState=!0,i.eagerState=l,fi(l,a)){var c=t.interleaved;c===null?(i.next=i,Rk(t)):(i.next=c.next,c.next=i),t.interleaved=i;return}}catch{}finally{}n=sI(e,t,i,r),n!==null&&(i=Gr(),ui(n,e,r,i),NI(n,t,r))}}function SI(e){var t=e.alternate;return e===Wn||t!==null&&t===Wn}function jI(e,t){Nd=dm=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function NI(e,t,n){if(n&4194240){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,xk(e,n)}}var fm={readContext:Ws,useCallback:Rr,useContext:Rr,useEffect:Rr,useImperativeHandle:Rr,useInsertionEffect:Rr,useLayoutEffect:Rr,useMemo:Rr,useReducer:Rr,useRef:Rr,useState:Rr,useDebugValue:Rr,useDeferredValue:Rr,useTransition:Rr,useMutableSource:Rr,useSyncExternalStore:Rr,useId:Rr,unstable_isNewReconciler:!1},UD={readContext:Ws,useCallback:function(e,t){return ji().memoizedState=[e,t===void 0?null:t],e},useContext:Ws,useEffect:uN,useImperativeHandle:function(e,t,n){return n=n!=null?n.concat([e]):null,Eh(4194308,4,yI.bind(null,t,e),n)},useLayoutEffect:function(e,t){return Eh(4194308,4,e,t)},useInsertionEffect:function(e,t){return Eh(4,2,e,t)},useMemo:function(e,t){var n=ji();return t=t===void 0?null:t,e=e(),n.memoizedState=[e,t],e},useReducer:function(e,t,n){var r=ji();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=KD.bind(null,Wn,e),[r.memoizedState,e]},useRef:function(e){var t=ji();return e={current:e},t.memoizedState=e},useState:cN,useDebugValue:Wk,useDeferredValue:function(e){return ji().memoizedState=e},useTransition:function(){var e=cN(!1),t=e[0];return e=VD.bind(null,e[1]),ji().memoizedState=e,[t,e]},useMutableSource:function(){},useSyncExternalStore:function(e,t,n){var r=Wn,i=ji();if(Rn){if(n===void 0)throw Error(Pe(407));n=n()}else{if(n=t(),Nr===null)throw Error(Pe(349));sl&30||cI(r,t,n)}i.memoizedState=n;var o={value:n,getSnapshot:t};return i.queue=o,uN(dI.bind(null,r,o,e),[e]),r.flags|=2048,tf(9,uI.bind(null,r,o,n,t),void 0,null),n},useId:function(){var e=ji(),t=Nr.identifierPrefix;if(Rn){var n=so,r=ro;n=(r&~(1<<32-ci(r)-1)).toString(32)+n,t=":"+t+"R"+n,n=Zd++,0<n&&(t+="H"+n.toString(32)),t+=":"}else n=HD++,t=":"+t+"r"+n.toString(32)+":";return e.memoizedState=t},unstable_isNewReconciler:!1},GD={readContext:Ws,useCallback:xI,useContext:Ws,useEffect:Bk,useImperativeHandle:wI,useInsertionEffect:mI,useLayoutEffect:gI,useMemo:bI,useReducer:Zy,useRef:hI,useState:function(){return Zy(ef)},useDebugValue:Wk,useDeferredValue:function(e){var t=Hs();return kI(t,hr.memoizedState,e)},useTransition:function(){var e=Zy(ef)[0],t=Hs().memoizedState;return[e,t]},useMutableSource:aI,useSyncExternalStore:lI,useId:vI,unstable_isNewReconciler:!1},YD={readContext:Ws,useCallback:xI,useContext:Ws,useEffect:Bk,useImperativeHandle:wI,useInsertionEffect:mI,useLayoutEffect:gI,useMemo:bI,useReducer:ew,useRef:hI,useState:function(){return ew(ef)},useDebugValue:Wk,useDeferredValue:function(e){var t=Hs();return hr===null?t.memoizedState=e:kI(t,hr.memoizedState,e)},useTransition:function(){var e=ew(ef)[0],t=Hs().memoizedState;return[e,t]},useMutableSource:aI,useSyncExternalStore:lI,useId:vI,unstable_isNewReconciler:!1};function ti(e,t){if(e&&e.defaultProps){t=Hn({},t),e=e.defaultProps;for(var n in e)t[n]===void 0&&(t[n]=e[n]);return t}return t}function Lx(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:Hn({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var ug={isMounted:function(e){return(e=e._reactInternals)?xl(e)===e:!1},enqueueSetState:function(e,t,n){e=e._reactInternals;var r=Gr(),i=aa(e),o=lo(r,i);o.payload=t,n!=null&&(o.callback=n),t=ia(e,o,i),t!==null&&(ui(t,e,i,r),Ch(t,e,i))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=Gr(),i=aa(e),o=lo(r,i);o.tag=1,o.payload=t,n!=null&&(o.callback=n),t=ia(e,o,i),t!==null&&(ui(t,e,i,r),Ch(t,e,i))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=Gr(),r=aa(e),i=lo(n,r);i.tag=2,t!=null&&(i.callback=t),t=ia(e,i,r),t!==null&&(ui(t,e,r,n),Ch(t,e,r))}};function dN(e,t,n,r,i,o,a){return e=e.stateNode,typeof e.shouldComponentUpdate=="function"?e.shouldComponentUpdate(r,o,a):t.prototype&&t.prototype.isPureReactComponent?!Ud(n,r)||!Ud(i,o):!0}function _I(e,t,n){var r=!1,i=fa,o=t.contextType;return typeof o=="object"&&o!==null?o=Ws(o):(i=as(t)?nl:Fr.current,r=t.contextTypes,o=(r=r!=null)?Oc(e,i):fa),t=new t(n,o),e.memoizedState=t.state!==null&&t.state!==void 0?t.state:null,t.updater=ug,e.stateNode=t,t._reactInternals=e,r&&(e=e.stateNode,e.__reactInternalMemoizedUnmaskedChildContext=i,e.__reactInternalMemoizedMaskedChildContext=o),t}function fN(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&&ug.enqueueReplaceState(t,t.state,null)}function Ox(e,t,n,r){var i=e.stateNode;i.props=n,i.state=e.memoizedState,i.refs={},Mk(e);var o=t.contextType;typeof o=="object"&&o!==null?i.context=Ws(o):(o=as(t)?nl:Fr.current,i.context=Oc(e,o)),i.state=e.memoizedState,o=t.getDerivedStateFromProps,typeof o=="function"&&(Lx(e,t,o,n),i.state=e.memoizedState),typeof t.getDerivedStateFromProps=="function"||typeof i.getSnapshotBeforeUpdate=="function"||typeof i.UNSAFE_componentWillMount!="function"&&typeof i.componentWillMount!="function"||(t=i.state,typeof i.componentWillMount=="function"&&i.componentWillMount(),typeof i.UNSAFE_componentWillMount=="function"&&i.UNSAFE_componentWillMount(),t!==i.state&&ug.enqueueReplaceState(i,i.state,null),cm(e,n,i,r),i.state=e.memoizedState),typeof i.componentDidMount=="function"&&(e.flags|=4194308)}function Bc(e,t){try{var n="",r=t;do n+=S2(r),r=r.return;while(r);var i=n}catch(o){i=`
|
|
39
|
+
Error generating stack: `+o.message+`
|
|
40
|
+
`+o.stack}return{value:e,source:t,stack:i,digest:null}}function tw(e,t,n){return{value:e,source:null,stack:n??null,digest:t??null}}function Dx(e,t){try{console.error(t.value)}catch(n){setTimeout(function(){throw n})}}var JD=typeof WeakMap=="function"?WeakMap:Map;function CI(e,t,n){n=lo(-1,n),n.tag=3,n.payload={element:null};var r=t.value;return n.callback=function(){hm||(hm=!0,Gx=r),Dx(e,t)},n}function AI(e,t,n){n=lo(-1,n),n.tag=3;var r=e.type.getDerivedStateFromError;if(typeof r=="function"){var i=t.value;n.payload=function(){return r(i)},n.callback=function(){Dx(e,t)}}var o=e.stateNode;return o!==null&&typeof o.componentDidCatch=="function"&&(n.callback=function(){Dx(e,t),typeof r!="function"&&(oa===null?oa=new Set([this]):oa.add(this));var a=t.stack;this.componentDidCatch(t.value,{componentStack:a!==null?a:""})}),n}function pN(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new JD;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(i.add(n),e=uF.bind(null,e,t,n),t.then(e,e))}function hN(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 mN(e,t,n,r,i){return e.mode&1?(e.flags|=65536,e.lanes=i,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=lo(-1,1),t.tag=2,ia(n,t,1))),n.lanes|=1),e)}var XD=ko.ReactCurrentOwner,rs=!1;function Ur(e,t,n,r){t.child=e===null?rI(t,null,n,r):Fc(t,e.child,n,r)}function gN(e,t,n,r,i){n=n.render;var o=t.ref;return _c(t,i),r=Fk(e,t,n,r,o,i),n=zk(),e!==null&&!rs?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,go(e,t,i)):(Rn&&n&&Ck(t),t.flags|=1,Ur(e,t,r,i),t.child)}function yN(e,t,n,r,i){if(e===null){var o=n.type;return typeof o=="function"&&!Jk(o)&&o.defaultProps===void 0&&n.compare===null&&n.defaultProps===void 0?(t.tag=15,t.type=o,EI(e,t,o,r,i)):(e=Rh(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(o=e.child,!(e.lanes&i)){var a=o.memoizedProps;if(n=n.compare,n=n!==null?n:Ud,n(a,r)&&e.ref===t.ref)return go(e,t,i)}return t.flags|=1,e=la(o,r),e.ref=t.ref,e.return=t,t.child=e}function EI(e,t,n,r,i){if(e!==null){var o=e.memoizedProps;if(Ud(o,r)&&e.ref===t.ref)if(rs=!1,t.pendingProps=r=o,(e.lanes&i)!==0)e.flags&131072&&(rs=!0);else return t.lanes=e.lanes,go(e,t,i)}return Fx(e,t,n,r,i)}function II(e,t,n){var r=t.pendingProps,i=r.children,o=e!==null?e.memoizedState:null;if(r.mode==="hidden")if(!(t.mode&1))t.memoizedState={baseLanes:0,cachePool:null,transitions:null},bn(mc,ms),ms|=n;else{if(!(n&1073741824))return e=o!==null?o.baseLanes|n:n,t.lanes=t.childLanes=1073741824,t.memoizedState={baseLanes:e,cachePool:null,transitions:null},t.updateQueue=null,bn(mc,ms),ms|=e,null;t.memoizedState={baseLanes:0,cachePool:null,transitions:null},r=o!==null?o.baseLanes:n,bn(mc,ms),ms|=r}else o!==null?(r=o.baseLanes|n,t.memoizedState=null):r=n,bn(mc,ms),ms|=r;return Ur(e,t,i,n),t.child}function PI(e,t){var n=t.ref;(e===null&&n!==null||e!==null&&e.ref!==n)&&(t.flags|=512,t.flags|=2097152)}function Fx(e,t,n,r,i){var o=as(n)?nl:Fr.current;return o=Oc(t,o),_c(t,i),n=Fk(e,t,n,r,o,i),r=zk(),e!==null&&!rs?(t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~i,go(e,t,i)):(Rn&&r&&Ck(t),t.flags|=1,Ur(e,t,n,i),t.child)}function wN(e,t,n,r,i){if(as(n)){var o=!0;sm(t)}else o=!1;if(_c(t,i),t.stateNode===null)Ih(e,t),_I(t,n,r),Ox(t,n,r,i),r=!0;else if(e===null){var a=t.stateNode,l=t.memoizedProps;a.props=l;var c=a.context,u=n.contextType;typeof u=="object"&&u!==null?u=Ws(u):(u=as(n)?nl:Fr.current,u=Oc(t,u));var f=n.getDerivedStateFromProps,p=typeof f=="function"||typeof a.getSnapshotBeforeUpdate=="function";p||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==r||c!==u)&&fN(t,a,r,u),Vo=!1;var d=t.memoizedState;a.state=d,cm(t,r,a,i),c=t.memoizedState,l!==r||d!==c||os.current||Vo?(typeof f=="function"&&(Lx(t,n,f,r),c=t.memoizedState),(l=Vo||dN(t,n,l,r,d,c,u))?(p||typeof a.UNSAFE_componentWillMount!="function"&&typeof a.componentWillMount!="function"||(typeof a.componentWillMount=="function"&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount=="function"&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount=="function"&&(t.flags|=4194308)):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=c),a.props=r,a.state=c,a.context=u,r=l):(typeof a.componentDidMount=="function"&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,iI(e,t),l=t.memoizedProps,u=t.type===t.elementType?l:ti(t.type,l),a.props=u,p=t.pendingProps,d=a.context,c=n.contextType,typeof c=="object"&&c!==null?c=Ws(c):(c=as(n)?nl:Fr.current,c=Oc(t,c));var m=n.getDerivedStateFromProps;(f=typeof m=="function"||typeof a.getSnapshotBeforeUpdate=="function")||typeof a.UNSAFE_componentWillReceiveProps!="function"&&typeof a.componentWillReceiveProps!="function"||(l!==p||d!==c)&&fN(t,a,r,c),Vo=!1,d=t.memoizedState,a.state=d,cm(t,r,a,i);var y=t.memoizedState;l!==p||d!==y||os.current||Vo?(typeof m=="function"&&(Lx(t,n,m,r),y=t.memoizedState),(u=Vo||dN(t,n,u,r,d,y,c)||!1)?(f||typeof a.UNSAFE_componentWillUpdate!="function"&&typeof a.componentWillUpdate!="function"||(typeof a.componentWillUpdate=="function"&&a.componentWillUpdate(r,y,c),typeof a.UNSAFE_componentWillUpdate=="function"&&a.UNSAFE_componentWillUpdate(r,y,c)),typeof a.componentDidUpdate=="function"&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate=="function"&&(t.flags|=1024)):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=y),a.props=r,a.state=y,a.context=c,r=u):(typeof a.componentDidUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!="function"||l===e.memoizedProps&&d===e.memoizedState||(t.flags|=1024),r=!1)}return zx(e,t,n,r,o,i)}function zx(e,t,n,r,i,o){PI(e,t);var a=(t.flags&128)!==0;if(!r&&!a)return i&&rN(t,n,!1),go(e,t,o);r=t.stateNode,XD.current=t;var l=a&&typeof n.getDerivedStateFromError!="function"?null:r.render();return t.flags|=1,e!==null&&a?(t.child=Fc(t,e.child,null,o),t.child=Fc(t,null,l,o)):Ur(e,t,l,o),t.memoizedState=r.state,i&&rN(t,n,!0),t.child}function TI(e){var t=e.stateNode;t.pendingContext?nN(e,t.pendingContext,t.pendingContext!==t.context):t.context&&nN(e,t.context,!1),$k(e,t.containerInfo)}function xN(e,t,n,r,i){return Dc(),Ek(i),t.flags|=256,Ur(e,t,n,r),t.child}var Bx={dehydrated:null,treeContext:null,retryLane:0};function Wx(e){return{baseLanes:e,cachePool:null,transitions:null}}function RI(e,t,n){var r=t.pendingProps,i=zn.current,o=!1,a=(t.flags&128)!==0,l;if((l=a)||(l=e!==null&&e.memoizedState===null?!1:(i&2)!==0),l?(o=!0,t.flags&=-129):(e===null||e.memoizedState!==null)&&(i|=1),bn(zn,i&1),e===null)return Mx(t),e=t.memoizedState,e!==null&&(e=e.dehydrated,e!==null)?(t.mode&1?e.data==="$!"?t.lanes=8:t.lanes=1073741824:t.lanes=1,null):(a=r.children,e=r.fallback,o?(r=t.mode,o=t.child,a={mode:"hidden",children:a},!(r&1)&&o!==null?(o.childLanes=0,o.pendingProps=a):o=pg(a,r,0,null),e=Ja(e,r,n,null),o.return=t,e.return=t,o.sibling=e,t.child=o,t.child.memoizedState=Wx(n),t.memoizedState=Bx,e):Hk(t,a));if(i=e.memoizedState,i!==null&&(l=i.dehydrated,l!==null))return QD(e,t,a,r,l,i,n);if(o){o=r.fallback,a=t.mode,i=e.child,l=i.sibling;var c={mode:"hidden",children:r.children};return!(a&1)&&t.child!==i?(r=t.child,r.childLanes=0,r.pendingProps=c,t.deletions=null):(r=la(i,c),r.subtreeFlags=i.subtreeFlags&14680064),l!==null?o=la(l,o):(o=Ja(o,a,n,null),o.flags|=2),o.return=t,r.return=t,r.sibling=o,t.child=r,r=o,o=t.child,a=e.child.memoizedState,a=a===null?Wx(n):{baseLanes:a.baseLanes|n,cachePool:null,transitions:a.transitions},o.memoizedState=a,o.childLanes=e.childLanes&~n,t.memoizedState=Bx,r}return o=e.child,e=o.sibling,r=la(o,{mode:"visible",children:r.children}),!(t.mode&1)&&(r.lanes=n),r.return=t,r.sibling=null,e!==null&&(n=t.deletions,n===null?(t.deletions=[e],t.flags|=16):n.push(e)),t.child=r,t.memoizedState=null,r}function Hk(e,t){return t=pg({mode:"visible",children:t},e.mode,0,null),t.return=e,e.child=t}function zp(e,t,n,r){return r!==null&&Ek(r),Fc(t,e.child,null,n),e=Hk(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function QD(e,t,n,r,i,o,a){if(n)return t.flags&256?(t.flags&=-257,r=tw(Error(Pe(422))),zp(e,t,a,r)):t.memoizedState!==null?(t.child=e.child,t.flags|=128,null):(o=r.fallback,i=t.mode,r=pg({mode:"visible",children:r.children},i,0,null),o=Ja(o,i,a,null),o.flags|=2,r.return=t,o.return=t,r.sibling=o,t.child=r,t.mode&1&&Fc(t,e.child,null,a),t.child.memoizedState=Wx(a),t.memoizedState=Bx,o);if(!(t.mode&1))return zp(e,t,a,null);if(i.data==="$!"){if(r=i.nextSibling&&i.nextSibling.dataset,r)var l=r.dgst;return r=l,o=Error(Pe(419)),r=tw(o,r,void 0),zp(e,t,a,r)}if(l=(a&e.childLanes)!==0,rs||l){if(r=Nr,r!==null){switch(a&-a){case 4:i=2;break;case 16:i=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:i=32;break;case 536870912:i=268435456;break;default:i=0}i=i&(r.suspendedLanes|a)?0:i,i!==0&&i!==o.retryLane&&(o.retryLane=i,mo(e,i),ui(r,e,i,-1))}return Yk(),r=tw(Error(Pe(421))),zp(e,t,a,r)}return i.data==="$?"?(t.flags|=128,t.child=e.child,t=dF.bind(null,e),i._reactRetry=t,null):(e=o.treeContext,ws=sa(i.nextSibling),bs=t,Rn=!0,si=null,e!==null&&(Ls[Os++]=ro,Ls[Os++]=so,Ls[Os++]=rl,ro=e.id,so=e.overflow,rl=t),t=Hk(t,r.children),t.flags|=4096,t)}function bN(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),$x(e.return,t,n)}function nw(e,t,n,r,i){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i)}function MI(e,t,n){var r=t.pendingProps,i=r.revealOrder,o=r.tail;if(Ur(e,t,r.children,n),r=zn.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&&bN(e,n,t);else if(e.tag===19)bN(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(bn(zn,r),!(t.mode&1))t.memoizedState=null;else switch(i){case"forwards":for(n=t.child,i=null;n!==null;)e=n.alternate,e!==null&&um(e)===null&&(i=n),n=n.sibling;n=i,n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),nw(t,!1,i,n,o);break;case"backwards":for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&um(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}nw(t,!0,n,null,o);break;case"together":nw(t,!1,null,null,void 0);break;default:t.memoizedState=null}return t.child}function Ih(e,t){!(t.mode&1)&&e!==null&&(e.alternate=null,t.alternate=null,t.flags|=2)}function go(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),il|=t.lanes,!(n&t.childLanes))return null;if(e!==null&&t.child!==e.child)throw Error(Pe(153));if(t.child!==null){for(e=t.child,n=la(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=la(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function ZD(e,t,n){switch(t.tag){case 3:TI(t),Dc();break;case 5:oI(t);break;case 1:as(t.type)&&sm(t);break;case 4:$k(t,t.stateNode.containerInfo);break;case 10:var r=t.type._context,i=t.memoizedProps.value;bn(am,r._currentValue),r._currentValue=i;break;case 13:if(r=t.memoizedState,r!==null)return r.dehydrated!==null?(bn(zn,zn.current&1),t.flags|=128,null):n&t.child.childLanes?RI(e,t,n):(bn(zn,zn.current&1),e=go(e,t,n),e!==null?e.sibling:null);bn(zn,zn.current&1);break;case 19:if(r=(n&t.childLanes)!==0,e.flags&128){if(r)return MI(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),bn(zn,zn.current),r)break;return null;case 22:case 23:return t.lanes=0,II(e,t,n)}return go(e,t,n)}var $I,Hx,LI,OI;$I=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}};Hx=function(){};LI=function(e,t,n,r){var i=e.memoizedProps;if(i!==r){e=t.stateNode,Ka($i.current);var o=null;switch(n){case"input":i=dx(e,i),r=dx(e,r),o=[];break;case"select":i=Hn({},i,{value:void 0}),r=Hn({},r,{value:void 0}),o=[];break;case"textarea":i=hx(e,i),r=hx(e,r),o=[];break;default:typeof i.onClick!="function"&&typeof r.onClick=="function"&&(e.onclick=nm)}gx(n,r);var a;n=null;for(u in i)if(!r.hasOwnProperty(u)&&i.hasOwnProperty(u)&&i[u]!=null)if(u==="style"){var l=i[u];for(a in l)l.hasOwnProperty(a)&&(n||(n={}),n[a]="")}else u!=="dangerouslySetInnerHTML"&&u!=="children"&&u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&u!=="autoFocus"&&(zd.hasOwnProperty(u)?o||(o=[]):(o=o||[]).push(u,null));for(u in r){var c=r[u];if(l=i!=null?i[u]:void 0,r.hasOwnProperty(u)&&c!==l&&(c!=null||l!=null))if(u==="style")if(l){for(a in l)!l.hasOwnProperty(a)||c&&c.hasOwnProperty(a)||(n||(n={}),n[a]="");for(a in c)c.hasOwnProperty(a)&&l[a]!==c[a]&&(n||(n={}),n[a]=c[a])}else n||(o||(o=[]),o.push(u,n)),n=c;else u==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,l=l?l.__html:void 0,c!=null&&l!==c&&(o=o||[]).push(u,c)):u==="children"?typeof c!="string"&&typeof c!="number"||(o=o||[]).push(u,""+c):u!=="suppressContentEditableWarning"&&u!=="suppressHydrationWarning"&&(zd.hasOwnProperty(u)?(c!=null&&u==="onScroll"&&An("scroll",e),o||l===c||(o=[])):(o=o||[]).push(u,c))}n&&(o=o||[]).push("style",n);var u=o;(t.updateQueue=u)&&(t.flags|=4)}};OI=function(e,t,n,r){n!==r&&(t.flags|=4)};function Yu(e,t){if(!Rn)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 Mr(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&14680064,r|=i.flags&14680064,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function eF(e,t,n){var r=t.pendingProps;switch(Ak(t),t.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Mr(t),null;case 1:return as(t.type)&&rm(),Mr(t),null;case 3:return r=t.stateNode,zc(),In(os),In(Fr),Ok(),r.pendingContext&&(r.context=r.pendingContext,r.pendingContext=null),(e===null||e.child===null)&&(Dp(t)?t.flags|=4:e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,si!==null&&(Xx(si),si=null))),Hx(e,t),Mr(t),null;case 5:Lk(t);var i=Ka(Qd.current);if(n=t.type,e!==null&&t.stateNode!=null)LI(e,t,n,r,i),e.ref!==t.ref&&(t.flags|=512,t.flags|=2097152);else{if(!r){if(t.stateNode===null)throw Error(Pe(166));return Mr(t),null}if(e=Ka($i.current),Dp(t)){r=t.stateNode,n=t.type;var o=t.memoizedProps;switch(r[Ai]=t,r[Jd]=o,e=(t.mode&1)!==0,n){case"dialog":An("cancel",r),An("close",r);break;case"iframe":case"object":case"embed":An("load",r);break;case"video":case"audio":for(i=0;i<dd.length;i++)An(dd[i],r);break;case"source":An("error",r);break;case"img":case"image":case"link":An("error",r),An("load",r);break;case"details":An("toggle",r);break;case"input":E0(r,o),An("invalid",r);break;case"select":r._wrapperState={wasMultiple:!!o.multiple},An("invalid",r);break;case"textarea":P0(r,o),An("invalid",r)}gx(n,o),i=null;for(var a in o)if(o.hasOwnProperty(a)){var l=o[a];a==="children"?typeof l=="string"?r.textContent!==l&&(o.suppressHydrationWarning!==!0&&Op(r.textContent,l,e),i=["children",l]):typeof l=="number"&&r.textContent!==""+l&&(o.suppressHydrationWarning!==!0&&Op(r.textContent,l,e),i=["children",""+l]):zd.hasOwnProperty(a)&&l!=null&&a==="onScroll"&&An("scroll",r)}switch(n){case"input":Ep(r),I0(r,o,!0);break;case"textarea":Ep(r),T0(r);break;case"select":case"option":break;default:typeof o.onClick=="function"&&(r.onclick=nm)}r=i,t.updateQueue=r,r!==null&&(t.flags|=4)}else{a=i.nodeType===9?i:i.ownerDocument,e==="http://www.w3.org/1999/xhtml"&&(e=dE(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[Ai]=t,e[Jd]=r,$I(e,t,!1,!1),t.stateNode=e;e:{switch(a=yx(n,r),n){case"dialog":An("cancel",e),An("close",e),i=r;break;case"iframe":case"object":case"embed":An("load",e),i=r;break;case"video":case"audio":for(i=0;i<dd.length;i++)An(dd[i],e);i=r;break;case"source":An("error",e),i=r;break;case"img":case"image":case"link":An("error",e),An("load",e),i=r;break;case"details":An("toggle",e),i=r;break;case"input":E0(e,r),i=dx(e,r),An("invalid",e);break;case"option":i=r;break;case"select":e._wrapperState={wasMultiple:!!r.multiple},i=Hn({},r,{value:void 0}),An("invalid",e);break;case"textarea":P0(e,r),i=hx(e,r),An("invalid",e);break;default:i=r}gx(n,i),l=i;for(o in l)if(l.hasOwnProperty(o)){var c=l[o];o==="style"?hE(e,c):o==="dangerouslySetInnerHTML"?(c=c?c.__html:void 0,c!=null&&fE(e,c)):o==="children"?typeof c=="string"?(n!=="textarea"||c!=="")&&Bd(e,c):typeof c=="number"&&Bd(e,""+c):o!=="suppressContentEditableWarning"&&o!=="suppressHydrationWarning"&&o!=="autoFocus"&&(zd.hasOwnProperty(o)?c!=null&&o==="onScroll"&&An("scroll",e):c!=null&&pk(e,o,c,a))}switch(n){case"input":Ep(e),I0(e,r,!1);break;case"textarea":Ep(e),T0(e);break;case"option":r.value!=null&&e.setAttribute("value",""+da(r.value));break;case"select":e.multiple=!!r.multiple,o=r.value,o!=null?vc(e,!!r.multiple,o,!1):r.defaultValue!=null&&vc(e,!!r.multiple,r.defaultValue,!0);break;default:typeof i.onClick=="function"&&(e.onclick=nm)}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 Mr(t),null;case 6:if(e&&t.stateNode!=null)OI(e,t,e.memoizedProps,r);else{if(typeof r!="string"&&t.stateNode===null)throw Error(Pe(166));if(n=Ka(Qd.current),Ka($i.current),Dp(t)){if(r=t.stateNode,n=t.memoizedProps,r[Ai]=t,(o=r.nodeValue!==n)&&(e=bs,e!==null))switch(e.tag){case 3:Op(r.nodeValue,n,(e.mode&1)!==0);break;case 5:e.memoizedProps.suppressHydrationWarning!==!0&&Op(r.nodeValue,n,(e.mode&1)!==0)}o&&(t.flags|=4)}else r=(n.nodeType===9?n:n.ownerDocument).createTextNode(r),r[Ai]=t,t.stateNode=r}return Mr(t),null;case 13:if(In(zn),r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(Rn&&ws!==null&&t.mode&1&&!(t.flags&128))tI(),Dc(),t.flags|=98560,o=!1;else if(o=Dp(t),r!==null&&r.dehydrated!==null){if(e===null){if(!o)throw Error(Pe(318));if(o=t.memoizedState,o=o!==null?o.dehydrated:null,!o)throw Error(Pe(317));o[Ai]=t}else Dc(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;Mr(t),o=!1}else si!==null&&(Xx(si),si=null),o=!0;if(!o)return t.flags&65536?t:null}return t.flags&128?(t.lanes=n,t):(r=r!==null,r!==(e!==null&&e.memoizedState!==null)&&r&&(t.child.flags|=8192,t.mode&1&&(e===null||zn.current&1?mr===0&&(mr=3):Yk())),t.updateQueue!==null&&(t.flags|=4),Mr(t),null);case 4:return zc(),Hx(e,t),e===null&&Gd(t.stateNode.containerInfo),Mr(t),null;case 10:return Tk(t.type._context),Mr(t),null;case 17:return as(t.type)&&rm(),Mr(t),null;case 19:if(In(zn),o=t.memoizedState,o===null)return Mr(t),null;if(r=(t.flags&128)!==0,a=o.rendering,a===null)if(r)Yu(o,!1);else{if(mr!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(a=um(e),a!==null){for(t.flags|=128,Yu(o,!1),r=a.updateQueue,r!==null&&(t.updateQueue=r,t.flags|=4),t.subtreeFlags=0,r=n,n=t.child;n!==null;)o=n,e=r,o.flags&=14680066,a=o.alternate,a===null?(o.childLanes=0,o.lanes=e,o.child=null,o.subtreeFlags=0,o.memoizedProps=null,o.memoizedState=null,o.updateQueue=null,o.dependencies=null,o.stateNode=null):(o.childLanes=a.childLanes,o.lanes=a.lanes,o.child=a.child,o.subtreeFlags=0,o.deletions=null,o.memoizedProps=a.memoizedProps,o.memoizedState=a.memoizedState,o.updateQueue=a.updateQueue,o.type=a.type,e=a.dependencies,o.dependencies=e===null?null:{lanes:e.lanes,firstContext:e.firstContext}),n=n.sibling;return bn(zn,zn.current&1|2),t.child}e=e.sibling}o.tail!==null&&tr()>Wc&&(t.flags|=128,r=!0,Yu(o,!1),t.lanes=4194304)}else{if(!r)if(e=um(a),e!==null){if(t.flags|=128,r=!0,n=e.updateQueue,n!==null&&(t.updateQueue=n,t.flags|=4),Yu(o,!0),o.tail===null&&o.tailMode==="hidden"&&!a.alternate&&!Rn)return Mr(t),null}else 2*tr()-o.renderingStartTime>Wc&&n!==1073741824&&(t.flags|=128,r=!0,Yu(o,!1),t.lanes=4194304);o.isBackwards?(a.sibling=t.child,t.child=a):(n=o.last,n!==null?n.sibling=a:t.child=a,o.last=a)}return o.tail!==null?(t=o.tail,o.rendering=t,o.tail=t.sibling,o.renderingStartTime=tr(),t.sibling=null,n=zn.current,bn(zn,r?n&1|2:n&1),t):(Mr(t),null);case 22:case 23:return Gk(),r=t.memoizedState!==null,e!==null&&e.memoizedState!==null!==r&&(t.flags|=8192),r&&t.mode&1?ms&1073741824&&(Mr(t),t.subtreeFlags&6&&(t.flags|=8192)):Mr(t),null;case 24:return null;case 25:return null}throw Error(Pe(156,t.tag))}function tF(e,t){switch(Ak(t),t.tag){case 1:return as(t.type)&&rm(),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return zc(),In(os),In(Fr),Ok(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 5:return Lk(t),null;case 13:if(In(zn),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(Pe(340));Dc()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return In(zn),null;case 4:return zc(),null;case 10:return Tk(t.type._context),null;case 22:case 23:return Gk(),null;case 24:return null;default:return null}}var Bp=!1,Lr=!1,nF=typeof WeakSet=="function"?WeakSet:Set,tt=null;function hc(e,t){var n=e.ref;if(n!==null)if(typeof n=="function")try{n(null)}catch(r){Gn(e,t,r)}else n.current=null}function Vx(e,t,n){try{n()}catch(r){Gn(e,t,r)}}var kN=!1;function rF(e,t){if(Cx=Zh,e=WE(),_k(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 i=r.anchorOffset,o=r.focusNode;r=r.focusOffset;try{n.nodeType,o.nodeType}catch{n=null;break e}var a=0,l=-1,c=-1,u=0,f=0,p=e,d=null;t:for(;;){for(var m;p!==n||i!==0&&p.nodeType!==3||(l=a+i),p!==o||r!==0&&p.nodeType!==3||(c=a+r),p.nodeType===3&&(a+=p.nodeValue.length),(m=p.firstChild)!==null;)d=p,p=m;for(;;){if(p===e)break t;if(d===n&&++u===i&&(l=a),d===o&&++f===r&&(c=a),(m=p.nextSibling)!==null)break;p=d,d=p.parentNode}p=m}n=l===-1||c===-1?null:{start:l,end:c}}else n=null}n=n||{start:0,end:0}}else n=null;for(Ax={focusedElem:e,selectionRange:n},Zh=!1,tt=t;tt!==null;)if(t=tt,e=t.child,(t.subtreeFlags&1028)!==0&&e!==null)e.return=t,tt=e;else for(;tt!==null;){t=tt;try{var y=t.alternate;if(t.flags&1024)switch(t.tag){case 0:case 11:case 15:break;case 1:if(y!==null){var v=y.memoizedProps,b=y.memoizedState,g=t.stateNode,k=g.getSnapshotBeforeUpdate(t.elementType===t.type?v:ti(t.type,v),b);g.__reactInternalSnapshotBeforeUpdate=k}break;case 3:var x=t.stateNode.containerInfo;x.nodeType===1?x.textContent="":x.nodeType===9&&x.documentElement&&x.removeChild(x.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(Pe(163))}}catch(_){Gn(t,t.return,_)}if(e=t.sibling,e!==null){e.return=t.return,tt=e;break}tt=t.return}return y=kN,kN=!1,y}function _d(e,t,n){var r=t.updateQueue;if(r=r!==null?r.lastEffect:null,r!==null){var i=r=r.next;do{if((i.tag&e)===e){var o=i.destroy;i.destroy=void 0,o!==void 0&&Vx(t,n,o)}i=i.next}while(i!==r)}}function dg(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 Kx(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 DI(e){var t=e.alternate;t!==null&&(e.alternate=null,DI(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&(delete t[Ai],delete t[Jd],delete t[Px],delete t[FD],delete t[zD])),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 FI(e){return e.tag===5||e.tag===3||e.tag===4}function vN(e){e:for(;;){for(;e.sibling===null;){if(e.return===null||FI(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 qx(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=nm));else if(r!==4&&(e=e.child,e!==null))for(qx(e,t,n),e=e.sibling;e!==null;)qx(e,t,n),e=e.sibling}function Ux(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(Ux(e,t,n),e=e.sibling;e!==null;)Ux(e,t,n),e=e.sibling}var Ar=null,ni=!1;function $o(e,t,n){for(n=n.child;n!==null;)zI(e,t,n),n=n.sibling}function zI(e,t,n){if(Mi&&typeof Mi.onCommitFiberUnmount=="function")try{Mi.onCommitFiberUnmount(rg,n)}catch{}switch(n.tag){case 5:Lr||hc(n,t);case 6:var r=Ar,i=ni;Ar=null,$o(e,t,n),Ar=r,ni=i,Ar!==null&&(ni?(e=Ar,n=n.stateNode,e.nodeType===8?e.parentNode.removeChild(n):e.removeChild(n)):Ar.removeChild(n.stateNode));break;case 18:Ar!==null&&(ni?(e=Ar,n=n.stateNode,e.nodeType===8?Yy(e.parentNode,n):e.nodeType===1&&Yy(e,n),Kd(e)):Yy(Ar,n.stateNode));break;case 4:r=Ar,i=ni,Ar=n.stateNode.containerInfo,ni=!0,$o(e,t,n),Ar=r,ni=i;break;case 0:case 11:case 14:case 15:if(!Lr&&(r=n.updateQueue,r!==null&&(r=r.lastEffect,r!==null))){i=r=r.next;do{var o=i,a=o.destroy;o=o.tag,a!==void 0&&(o&2||o&4)&&Vx(n,t,a),i=i.next}while(i!==r)}$o(e,t,n);break;case 1:if(!Lr&&(hc(n,t),r=n.stateNode,typeof r.componentWillUnmount=="function"))try{r.props=n.memoizedProps,r.state=n.memoizedState,r.componentWillUnmount()}catch(l){Gn(n,t,l)}$o(e,t,n);break;case 21:$o(e,t,n);break;case 22:n.mode&1?(Lr=(r=Lr)||n.memoizedState!==null,$o(e,t,n),Lr=r):$o(e,t,n);break;default:$o(e,t,n)}}function SN(e){var t=e.updateQueue;if(t!==null){e.updateQueue=null;var n=e.stateNode;n===null&&(n=e.stateNode=new nF),t.forEach(function(r){var i=fF.bind(null,e,r);n.has(r)||(n.add(r),r.then(i,i))})}}function Qs(e,t){var n=t.deletions;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];try{var o=e,a=t,l=a;e:for(;l!==null;){switch(l.tag){case 5:Ar=l.stateNode,ni=!1;break e;case 3:Ar=l.stateNode.containerInfo,ni=!0;break e;case 4:Ar=l.stateNode.containerInfo,ni=!0;break e}l=l.return}if(Ar===null)throw Error(Pe(160));zI(o,a,i),Ar=null,ni=!1;var c=i.alternate;c!==null&&(c.return=null),i.return=null}catch(u){Gn(i,t,u)}}if(t.subtreeFlags&12854)for(t=t.child;t!==null;)BI(t,e),t=t.sibling}function BI(e,t){var n=e.alternate,r=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(Qs(t,e),ki(e),r&4){try{_d(3,e,e.return),dg(3,e)}catch(v){Gn(e,e.return,v)}try{_d(5,e,e.return)}catch(v){Gn(e,e.return,v)}}break;case 1:Qs(t,e),ki(e),r&512&&n!==null&&hc(n,n.return);break;case 5:if(Qs(t,e),ki(e),r&512&&n!==null&&hc(n,n.return),e.flags&32){var i=e.stateNode;try{Bd(i,"")}catch(v){Gn(e,e.return,v)}}if(r&4&&(i=e.stateNode,i!=null)){var o=e.memoizedProps,a=n!==null?n.memoizedProps:o,l=e.type,c=e.updateQueue;if(e.updateQueue=null,c!==null)try{l==="input"&&o.type==="radio"&&o.name!=null&&cE(i,o),yx(l,a);var u=yx(l,o);for(a=0;a<c.length;a+=2){var f=c[a],p=c[a+1];f==="style"?hE(i,p):f==="dangerouslySetInnerHTML"?fE(i,p):f==="children"?Bd(i,p):pk(i,f,p,u)}switch(l){case"input":fx(i,o);break;case"textarea":uE(i,o);break;case"select":var d=i._wrapperState.wasMultiple;i._wrapperState.wasMultiple=!!o.multiple;var m=o.value;m!=null?vc(i,!!o.multiple,m,!1):d!==!!o.multiple&&(o.defaultValue!=null?vc(i,!!o.multiple,o.defaultValue,!0):vc(i,!!o.multiple,o.multiple?[]:"",!1))}i[Jd]=o}catch(v){Gn(e,e.return,v)}}break;case 6:if(Qs(t,e),ki(e),r&4){if(e.stateNode===null)throw Error(Pe(162));i=e.stateNode,o=e.memoizedProps;try{i.nodeValue=o}catch(v){Gn(e,e.return,v)}}break;case 3:if(Qs(t,e),ki(e),r&4&&n!==null&&n.memoizedState.isDehydrated)try{Kd(t.containerInfo)}catch(v){Gn(e,e.return,v)}break;case 4:Qs(t,e),ki(e);break;case 13:Qs(t,e),ki(e),i=e.child,i.flags&8192&&(o=i.memoizedState!==null,i.stateNode.isHidden=o,!o||i.alternate!==null&&i.alternate.memoizedState!==null||(qk=tr())),r&4&&SN(e);break;case 22:if(f=n!==null&&n.memoizedState!==null,e.mode&1?(Lr=(u=Lr)||f,Qs(t,e),Lr=u):Qs(t,e),ki(e),r&8192){if(u=e.memoizedState!==null,(e.stateNode.isHidden=u)&&!f&&e.mode&1)for(tt=e,f=e.child;f!==null;){for(p=tt=f;tt!==null;){switch(d=tt,m=d.child,d.tag){case 0:case 11:case 14:case 15:_d(4,d,d.return);break;case 1:hc(d,d.return);var y=d.stateNode;if(typeof y.componentWillUnmount=="function"){r=d,n=d.return;try{t=r,y.props=t.memoizedProps,y.state=t.memoizedState,y.componentWillUnmount()}catch(v){Gn(r,n,v)}}break;case 5:hc(d,d.return);break;case 22:if(d.memoizedState!==null){NN(p);continue}}m!==null?(m.return=d,tt=m):NN(p)}f=f.sibling}e:for(f=null,p=e;;){if(p.tag===5){if(f===null){f=p;try{i=p.stateNode,u?(o=i.style,typeof o.setProperty=="function"?o.setProperty("display","none","important"):o.display="none"):(l=p.stateNode,c=p.memoizedProps.style,a=c!=null&&c.hasOwnProperty("display")?c.display:null,l.style.display=pE("display",a))}catch(v){Gn(e,e.return,v)}}}else if(p.tag===6){if(f===null)try{p.stateNode.nodeValue=u?"":p.memoizedProps}catch(v){Gn(e,e.return,v)}}else if((p.tag!==22&&p.tag!==23||p.memoizedState===null||p===e)&&p.child!==null){p.child.return=p,p=p.child;continue}if(p===e)break e;for(;p.sibling===null;){if(p.return===null||p.return===e)break e;f===p&&(f=null),p=p.return}f===p&&(f=null),p.sibling.return=p.return,p=p.sibling}}break;case 19:Qs(t,e),ki(e),r&4&&SN(e);break;case 21:break;default:Qs(t,e),ki(e)}}function ki(e){var t=e.flags;if(t&2){try{e:{for(var n=e.return;n!==null;){if(FI(n)){var r=n;break e}n=n.return}throw Error(Pe(160))}switch(r.tag){case 5:var i=r.stateNode;r.flags&32&&(Bd(i,""),r.flags&=-33);var o=vN(e);Ux(e,o,i);break;case 3:case 4:var a=r.stateNode.containerInfo,l=vN(e);qx(e,l,a);break;default:throw Error(Pe(161))}}catch(c){Gn(e,e.return,c)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function sF(e,t,n){tt=e,WI(e)}function WI(e,t,n){for(var r=(e.mode&1)!==0;tt!==null;){var i=tt,o=i.child;if(i.tag===22&&r){var a=i.memoizedState!==null||Bp;if(!a){var l=i.alternate,c=l!==null&&l.memoizedState!==null||Lr;l=Bp;var u=Lr;if(Bp=a,(Lr=c)&&!u)for(tt=i;tt!==null;)a=tt,c=a.child,a.tag===22&&a.memoizedState!==null?_N(i):c!==null?(c.return=a,tt=c):_N(i);for(;o!==null;)tt=o,WI(o),o=o.sibling;tt=i,Bp=l,Lr=u}jN(e)}else i.subtreeFlags&8772&&o!==null?(o.return=i,tt=o):jN(e)}}function jN(e){for(;tt!==null;){var t=tt;if(t.flags&8772){var n=t.alternate;try{if(t.flags&8772)switch(t.tag){case 0:case 11:case 15:Lr||dg(5,t);break;case 1:var r=t.stateNode;if(t.flags&4&&!Lr)if(n===null)r.componentDidMount();else{var i=t.elementType===t.type?n.memoizedProps:ti(t.type,n.memoizedProps);r.componentDidUpdate(i,n.memoizedState,r.__reactInternalSnapshotBeforeUpdate)}var o=t.updateQueue;o!==null&&lN(t,o,r);break;case 3:var a=t.updateQueue;if(a!==null){if(n=null,t.child!==null)switch(t.child.tag){case 5:n=t.child.stateNode;break;case 1:n=t.child.stateNode}lN(t,a,n)}break;case 5:var l=t.stateNode;if(n===null&&t.flags&4){n=l;var c=t.memoizedProps;switch(t.type){case"button":case"input":case"select":case"textarea":c.autoFocus&&n.focus();break;case"img":c.src&&(n.src=c.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(t.memoizedState===null){var u=t.alternate;if(u!==null){var f=u.memoizedState;if(f!==null){var p=f.dehydrated;p!==null&&Kd(p)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(Pe(163))}Lr||t.flags&512&&Kx(t)}catch(d){Gn(t,t.return,d)}}if(t===e){tt=null;break}if(n=t.sibling,n!==null){n.return=t.return,tt=n;break}tt=t.return}}function NN(e){for(;tt!==null;){var t=tt;if(t===e){tt=null;break}var n=t.sibling;if(n!==null){n.return=t.return,tt=n;break}tt=t.return}}function _N(e){for(;tt!==null;){var t=tt;try{switch(t.tag){case 0:case 11:case 15:var n=t.return;try{dg(4,t)}catch(c){Gn(t,n,c)}break;case 1:var r=t.stateNode;if(typeof r.componentDidMount=="function"){var i=t.return;try{r.componentDidMount()}catch(c){Gn(t,i,c)}}var o=t.return;try{Kx(t)}catch(c){Gn(t,o,c)}break;case 5:var a=t.return;try{Kx(t)}catch(c){Gn(t,a,c)}}}catch(c){Gn(t,t.return,c)}if(t===e){tt=null;break}var l=t.sibling;if(l!==null){l.return=t.return,tt=l;break}tt=t.return}}var iF=Math.ceil,pm=ko.ReactCurrentDispatcher,Vk=ko.ReactCurrentOwner,Bs=ko.ReactCurrentBatchConfig,Xt=0,Nr=null,or=null,Er=0,ms=0,mc=ka(0),mr=0,nf=null,il=0,fg=0,Kk=0,Cd=null,ts=null,qk=0,Wc=1/0,eo=null,hm=!1,Gx=null,oa=null,Wp=!1,Qo=null,mm=0,Ad=0,Yx=null,Ph=-1,Th=0;function Gr(){return Xt&6?tr():Ph!==-1?Ph:Ph=tr()}function aa(e){return e.mode&1?Xt&2&&Er!==0?Er&-Er:WD.transition!==null?(Th===0&&(Th=_E()),Th):(e=cn,e!==0||(e=window.event,e=e===void 0?16:RE(e.type)),e):1}function ui(e,t,n,r){if(50<Ad)throw Ad=0,Yx=null,Error(Pe(185));Ef(e,n,r),(!(Xt&2)||e!==Nr)&&(e===Nr&&(!(Xt&2)&&(fg|=n),mr===4&&Uo(e,Er)),ls(e,r),n===1&&Xt===0&&!(t.mode&1)&&(Wc=tr()+500,lg&&va()))}function ls(e,t){var n=e.callbackNode;W2(e,t);var r=Qh(e,e===Nr?Er:0);if(r===0)n!==null&&$0(n),e.callbackNode=null,e.callbackPriority=0;else if(t=r&-r,e.callbackPriority!==t){if(n!=null&&$0(n),t===1)e.tag===0?BD(CN.bind(null,e)):QE(CN.bind(null,e)),OD(function(){!(Xt&6)&&va()}),n=null;else{switch(CE(r)){case 1:n=wk;break;case 4:n=jE;break;case 16:n=Xh;break;case 536870912:n=NE;break;default:n=Xh}n=JI(n,HI.bind(null,e))}e.callbackPriority=t,e.callbackNode=n}}function HI(e,t){if(Ph=-1,Th=0,Xt&6)throw Error(Pe(327));var n=e.callbackNode;if(Cc()&&e.callbackNode!==n)return null;var r=Qh(e,e===Nr?Er:0);if(r===0)return null;if(r&30||r&e.expiredLanes||t)t=gm(e,r);else{t=r;var i=Xt;Xt|=2;var o=KI();(Nr!==e||Er!==t)&&(eo=null,Wc=tr()+500,Ya(e,t));do try{lF();break}catch(l){VI(e,l)}while(!0);Pk(),pm.current=o,Xt=i,or!==null?t=0:(Nr=null,Er=0,t=mr)}if(t!==0){if(t===2&&(i=vx(e),i!==0&&(r=i,t=Jx(e,i))),t===1)throw n=nf,Ya(e,0),Uo(e,r),ls(e,tr()),n;if(t===6)Uo(e,r);else{if(i=e.current.alternate,!(r&30)&&!oF(i)&&(t=gm(e,r),t===2&&(o=vx(e),o!==0&&(r=o,t=Jx(e,o))),t===1))throw n=nf,Ya(e,0),Uo(e,r),ls(e,tr()),n;switch(e.finishedWork=i,e.finishedLanes=r,t){case 0:case 1:throw Error(Pe(345));case 2:Oa(e,ts,eo);break;case 3:if(Uo(e,r),(r&130023424)===r&&(t=qk+500-tr(),10<t)){if(Qh(e,0)!==0)break;if(i=e.suspendedLanes,(i&r)!==r){Gr(),e.pingedLanes|=e.suspendedLanes&i;break}e.timeoutHandle=Ix(Oa.bind(null,e,ts,eo),t);break}Oa(e,ts,eo);break;case 4:if(Uo(e,r),(r&4194240)===r)break;for(t=e.eventTimes,i=-1;0<r;){var a=31-ci(r);o=1<<a,a=t[a],a>i&&(i=a),r&=~o}if(r=i,r=tr()-r,r=(120>r?120:480>r?480:1080>r?1080:1920>r?1920:3e3>r?3e3:4320>r?4320:1960*iF(r/1960))-r,10<r){e.timeoutHandle=Ix(Oa.bind(null,e,ts,eo),r);break}Oa(e,ts,eo);break;case 5:Oa(e,ts,eo);break;default:throw Error(Pe(329))}}}return ls(e,tr()),e.callbackNode===n?HI.bind(null,e):null}function Jx(e,t){var n=Cd;return e.current.memoizedState.isDehydrated&&(Ya(e,t).flags|=256),e=gm(e,t),e!==2&&(t=ts,ts=n,t!==null&&Xx(t)),e}function Xx(e){ts===null?ts=e:ts.push.apply(ts,e)}function oF(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 i=n[r],o=i.getSnapshot;i=i.value;try{if(!fi(o(),i))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 Uo(e,t){for(t&=~Kk,t&=~fg,e.suspendedLanes|=t,e.pingedLanes&=~t,e=e.expirationTimes;0<t;){var n=31-ci(t),r=1<<n;e[n]=-1,t&=~r}}function CN(e){if(Xt&6)throw Error(Pe(327));Cc();var t=Qh(e,0);if(!(t&1))return ls(e,tr()),null;var n=gm(e,t);if(e.tag!==0&&n===2){var r=vx(e);r!==0&&(t=r,n=Jx(e,r))}if(n===1)throw n=nf,Ya(e,0),Uo(e,t),ls(e,tr()),n;if(n===6)throw Error(Pe(345));return e.finishedWork=e.current.alternate,e.finishedLanes=t,Oa(e,ts,eo),ls(e,tr()),null}function Uk(e,t){var n=Xt;Xt|=1;try{return e(t)}finally{Xt=n,Xt===0&&(Wc=tr()+500,lg&&va())}}function ol(e){Qo!==null&&Qo.tag===0&&!(Xt&6)&&Cc();var t=Xt;Xt|=1;var n=Bs.transition,r=cn;try{if(Bs.transition=null,cn=1,e)return e()}finally{cn=r,Bs.transition=n,Xt=t,!(Xt&6)&&va()}}function Gk(){ms=mc.current,In(mc)}function Ya(e,t){e.finishedWork=null,e.finishedLanes=0;var n=e.timeoutHandle;if(n!==-1&&(e.timeoutHandle=-1,LD(n)),or!==null)for(n=or.return;n!==null;){var r=n;switch(Ak(r),r.tag){case 1:r=r.type.childContextTypes,r!=null&&rm();break;case 3:zc(),In(os),In(Fr),Ok();break;case 5:Lk(r);break;case 4:zc();break;case 13:In(zn);break;case 19:In(zn);break;case 10:Tk(r.type._context);break;case 22:case 23:Gk()}n=n.return}if(Nr=e,or=e=la(e.current,null),Er=ms=t,mr=0,nf=null,Kk=fg=il=0,ts=Cd=null,Va!==null){for(t=0;t<Va.length;t++)if(n=Va[t],r=n.interleaved,r!==null){n.interleaved=null;var i=r.next,o=n.pending;if(o!==null){var a=o.next;o.next=i,r.next=a}n.pending=r}Va=null}return e}function VI(e,t){do{var n=or;try{if(Pk(),Ah.current=fm,dm){for(var r=Wn.memoizedState;r!==null;){var i=r.queue;i!==null&&(i.pending=null),r=r.next}dm=!1}if(sl=0,vr=hr=Wn=null,Nd=!1,Zd=0,Vk.current=null,n===null||n.return===null){mr=1,nf=t,or=null;break}e:{var o=e,a=n.return,l=n,c=t;if(t=Er,l.flags|=32768,c!==null&&typeof c=="object"&&typeof c.then=="function"){var u=c,f=l,p=f.tag;if(!(f.mode&1)&&(p===0||p===11||p===15)){var d=f.alternate;d?(f.updateQueue=d.updateQueue,f.memoizedState=d.memoizedState,f.lanes=d.lanes):(f.updateQueue=null,f.memoizedState=null)}var m=hN(a);if(m!==null){m.flags&=-257,mN(m,a,l,o,t),m.mode&1&&pN(o,u,t),t=m,c=u;var y=t.updateQueue;if(y===null){var v=new Set;v.add(c),t.updateQueue=v}else y.add(c);break e}else{if(!(t&1)){pN(o,u,t),Yk();break e}c=Error(Pe(426))}}else if(Rn&&l.mode&1){var b=hN(a);if(b!==null){!(b.flags&65536)&&(b.flags|=256),mN(b,a,l,o,t),Ek(Bc(c,l));break e}}o=c=Bc(c,l),mr!==4&&(mr=2),Cd===null?Cd=[o]:Cd.push(o),o=a;do{switch(o.tag){case 3:o.flags|=65536,t&=-t,o.lanes|=t;var g=CI(o,c,t);aN(o,g);break e;case 1:l=c;var k=o.type,x=o.stateNode;if(!(o.flags&128)&&(typeof k.getDerivedStateFromError=="function"||x!==null&&typeof x.componentDidCatch=="function"&&(oa===null||!oa.has(x)))){o.flags|=65536,t&=-t,o.lanes|=t;var _=AI(o,l,t);aN(o,_);break e}}o=o.return}while(o!==null)}UI(n)}catch(j){t=j,or===n&&n!==null&&(or=n=n.return);continue}break}while(!0)}function KI(){var e=pm.current;return pm.current=fm,e===null?fm:e}function Yk(){(mr===0||mr===3||mr===2)&&(mr=4),Nr===null||!(il&268435455)&&!(fg&268435455)||Uo(Nr,Er)}function gm(e,t){var n=Xt;Xt|=2;var r=KI();(Nr!==e||Er!==t)&&(eo=null,Ya(e,t));do try{aF();break}catch(i){VI(e,i)}while(!0);if(Pk(),Xt=n,pm.current=r,or!==null)throw Error(Pe(261));return Nr=null,Er=0,mr}function aF(){for(;or!==null;)qI(or)}function lF(){for(;or!==null&&!R2();)qI(or)}function qI(e){var t=YI(e.alternate,e,ms);e.memoizedProps=e.pendingProps,t===null?UI(e):or=t,Vk.current=null}function UI(e){var t=e;do{var n=t.alternate;if(e=t.return,t.flags&32768){if(n=tF(n,t),n!==null){n.flags&=32767,or=n;return}if(e!==null)e.flags|=32768,e.subtreeFlags=0,e.deletions=null;else{mr=6,or=null;return}}else if(n=eF(n,t,ms),n!==null){or=n;return}if(t=t.sibling,t!==null){or=t;return}or=t=e}while(t!==null);mr===0&&(mr=5)}function Oa(e,t,n){var r=cn,i=Bs.transition;try{Bs.transition=null,cn=1,cF(e,t,n,r)}finally{Bs.transition=i,cn=r}return null}function cF(e,t,n,r){do Cc();while(Qo!==null);if(Xt&6)throw Error(Pe(327));n=e.finishedWork;var i=e.finishedLanes;if(n===null)return null;if(e.finishedWork=null,e.finishedLanes=0,n===e.current)throw Error(Pe(177));e.callbackNode=null,e.callbackPriority=0;var o=n.lanes|n.childLanes;if(H2(e,o),e===Nr&&(or=Nr=null,Er=0),!(n.subtreeFlags&2064)&&!(n.flags&2064)||Wp||(Wp=!0,JI(Xh,function(){return Cc(),null})),o=(n.flags&15990)!==0,n.subtreeFlags&15990||o){o=Bs.transition,Bs.transition=null;var a=cn;cn=1;var l=Xt;Xt|=4,Vk.current=null,rF(e,n),BI(n,e),ED(Ax),Zh=!!Cx,Ax=Cx=null,e.current=n,sF(n),M2(),Xt=l,cn=a,Bs.transition=o}else e.current=n;if(Wp&&(Wp=!1,Qo=e,mm=i),o=e.pendingLanes,o===0&&(oa=null),O2(n.stateNode),ls(e,tr()),t!==null)for(r=e.onRecoverableError,n=0;n<t.length;n++)i=t[n],r(i.value,{componentStack:i.stack,digest:i.digest});if(hm)throw hm=!1,e=Gx,Gx=null,e;return mm&1&&e.tag!==0&&Cc(),o=e.pendingLanes,o&1?e===Yx?Ad++:(Ad=0,Yx=e):Ad=0,va(),null}function Cc(){if(Qo!==null){var e=CE(mm),t=Bs.transition,n=cn;try{if(Bs.transition=null,cn=16>e?16:e,Qo===null)var r=!1;else{if(e=Qo,Qo=null,mm=0,Xt&6)throw Error(Pe(331));var i=Xt;for(Xt|=4,tt=e.current;tt!==null;){var o=tt,a=o.child;if(tt.flags&16){var l=o.deletions;if(l!==null){for(var c=0;c<l.length;c++){var u=l[c];for(tt=u;tt!==null;){var f=tt;switch(f.tag){case 0:case 11:case 15:_d(8,f,o)}var p=f.child;if(p!==null)p.return=f,tt=p;else for(;tt!==null;){f=tt;var d=f.sibling,m=f.return;if(DI(f),f===u){tt=null;break}if(d!==null){d.return=m,tt=d;break}tt=m}}}var y=o.alternate;if(y!==null){var v=y.child;if(v!==null){y.child=null;do{var b=v.sibling;v.sibling=null,v=b}while(v!==null)}}tt=o}}if(o.subtreeFlags&2064&&a!==null)a.return=o,tt=a;else e:for(;tt!==null;){if(o=tt,o.flags&2048)switch(o.tag){case 0:case 11:case 15:_d(9,o,o.return)}var g=o.sibling;if(g!==null){g.return=o.return,tt=g;break e}tt=o.return}}var k=e.current;for(tt=k;tt!==null;){a=tt;var x=a.child;if(a.subtreeFlags&2064&&x!==null)x.return=a,tt=x;else e:for(a=k;tt!==null;){if(l=tt,l.flags&2048)try{switch(l.tag){case 0:case 11:case 15:dg(9,l)}}catch(j){Gn(l,l.return,j)}if(l===a){tt=null;break e}var _=l.sibling;if(_!==null){_.return=l.return,tt=_;break e}tt=l.return}}if(Xt=i,va(),Mi&&typeof Mi.onPostCommitFiberRoot=="function")try{Mi.onPostCommitFiberRoot(rg,e)}catch{}r=!0}return r}finally{cn=n,Bs.transition=t}}return!1}function AN(e,t,n){t=Bc(n,t),t=CI(e,t,1),e=ia(e,t,1),t=Gr(),e!==null&&(Ef(e,1,t),ls(e,t))}function Gn(e,t,n){if(e.tag===3)AN(e,e,n);else for(;t!==null;){if(t.tag===3){AN(t,e,n);break}else if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError=="function"||typeof r.componentDidCatch=="function"&&(oa===null||!oa.has(r))){e=Bc(n,e),e=AI(t,e,1),t=ia(t,e,1),e=Gr(),t!==null&&(Ef(t,1,e),ls(t,e));break}}t=t.return}}function uF(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),t=Gr(),e.pingedLanes|=e.suspendedLanes&n,Nr===e&&(Er&n)===n&&(mr===4||mr===3&&(Er&130023424)===Er&&500>tr()-qk?Ya(e,0):Kk|=n),ls(e,t)}function GI(e,t){t===0&&(e.mode&1?(t=Tp,Tp<<=1,!(Tp&130023424)&&(Tp=4194304)):t=1);var n=Gr();e=mo(e,t),e!==null&&(Ef(e,t,n),ls(e,n))}function dF(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),GI(e,n)}function fF(e,t){var n=0;switch(e.tag){case 13:var r=e.stateNode,i=e.memoizedState;i!==null&&(n=i.retryLane);break;case 19:r=e.stateNode;break;default:throw Error(Pe(314))}r!==null&&r.delete(t),GI(e,n)}var YI;YI=function(e,t,n){if(e!==null)if(e.memoizedProps!==t.pendingProps||os.current)rs=!0;else{if(!(e.lanes&n)&&!(t.flags&128))return rs=!1,ZD(e,t,n);rs=!!(e.flags&131072)}else rs=!1,Rn&&t.flags&1048576&&ZE(t,om,t.index);switch(t.lanes=0,t.tag){case 2:var r=t.type;Ih(e,t),e=t.pendingProps;var i=Oc(t,Fr.current);_c(t,n),i=Fk(null,t,r,e,i,n);var o=zk();return t.flags|=1,typeof i=="object"&&i!==null&&typeof i.render=="function"&&i.$$typeof===void 0?(t.tag=1,t.memoizedState=null,t.updateQueue=null,as(r)?(o=!0,sm(t)):o=!1,t.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,Mk(t),i.updater=ug,t.stateNode=i,i._reactInternals=t,Ox(t,r,e,n),t=zx(null,t,r,!0,o,n)):(t.tag=0,Rn&&o&&Ck(t),Ur(null,t,i,n),t=t.child),t;case 16:r=t.elementType;e:{switch(Ih(e,t),e=t.pendingProps,i=r._init,r=i(r._payload),t.type=r,i=t.tag=hF(r),e=ti(r,e),i){case 0:t=Fx(null,t,r,e,n);break e;case 1:t=wN(null,t,r,e,n);break e;case 11:t=gN(null,t,r,e,n);break e;case 14:t=yN(null,t,r,ti(r.type,e),n);break e}throw Error(Pe(306,r,""))}return t;case 0:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ti(r,i),Fx(e,t,r,i,n);case 1:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ti(r,i),wN(e,t,r,i,n);case 3:e:{if(TI(t),e===null)throw Error(Pe(387));r=t.pendingProps,o=t.memoizedState,i=o.element,iI(e,t),cm(t,r,null,n);var a=t.memoizedState;if(r=a.element,o.isDehydrated)if(o={element:r,isDehydrated:!1,cache:a.cache,pendingSuspenseBoundaries:a.pendingSuspenseBoundaries,transitions:a.transitions},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){i=Bc(Error(Pe(423)),t),t=xN(e,t,r,n,i);break e}else if(r!==i){i=Bc(Error(Pe(424)),t),t=xN(e,t,r,n,i);break e}else for(ws=sa(t.stateNode.containerInfo.firstChild),bs=t,Rn=!0,si=null,n=rI(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|4096,n=n.sibling;else{if(Dc(),r===i){t=go(e,t,n);break e}Ur(e,t,r,n)}t=t.child}return t;case 5:return oI(t),e===null&&Mx(t),r=t.type,i=t.pendingProps,o=e!==null?e.memoizedProps:null,a=i.children,Ex(r,i)?a=null:o!==null&&Ex(r,o)&&(t.flags|=32),PI(e,t),Ur(e,t,a,n),t.child;case 6:return e===null&&Mx(t),null;case 13:return RI(e,t,n);case 4:return $k(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=Fc(t,null,r,n):Ur(e,t,r,n),t.child;case 11:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ti(r,i),gN(e,t,r,i,n);case 7:return Ur(e,t,t.pendingProps,n),t.child;case 8:return Ur(e,t,t.pendingProps.children,n),t.child;case 12:return Ur(e,t,t.pendingProps.children,n),t.child;case 10:e:{if(r=t.type._context,i=t.pendingProps,o=t.memoizedProps,a=i.value,bn(am,r._currentValue),r._currentValue=a,o!==null)if(fi(o.value,a)){if(o.children===i.children&&!os.current){t=go(e,t,n);break e}}else for(o=t.child,o!==null&&(o.return=t);o!==null;){var l=o.dependencies;if(l!==null){a=o.child;for(var c=l.firstContext;c!==null;){if(c.context===r){if(o.tag===1){c=lo(-1,n&-n),c.tag=2;var u=o.updateQueue;if(u!==null){u=u.shared;var f=u.pending;f===null?c.next=c:(c.next=f.next,f.next=c),u.pending=c}}o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),$x(o.return,n,t),l.lanes|=n;break}c=c.next}}else if(o.tag===10)a=o.type===t.type?null:o.child;else if(o.tag===18){if(a=o.return,a===null)throw Error(Pe(341));a.lanes|=n,l=a.alternate,l!==null&&(l.lanes|=n),$x(a,n,t),a=o.sibling}else a=o.child;if(a!==null)a.return=o;else for(a=o;a!==null;){if(a===t){a=null;break}if(o=a.sibling,o!==null){o.return=a.return,a=o;break}a=a.return}o=a}Ur(e,t,i.children,n),t=t.child}return t;case 9:return i=t.type,r=t.pendingProps.children,_c(t,n),i=Ws(i),r=r(i),t.flags|=1,Ur(e,t,r,n),t.child;case 14:return r=t.type,i=ti(r,t.pendingProps),i=ti(r.type,i),yN(e,t,r,i,n);case 15:return EI(e,t,t.type,t.pendingProps,n);case 17:return r=t.type,i=t.pendingProps,i=t.elementType===r?i:ti(r,i),Ih(e,t),t.tag=1,as(r)?(e=!0,sm(t)):e=!1,_c(t,n),_I(t,r,i),Ox(t,r,i,n),zx(null,t,r,!0,e,n);case 19:return MI(e,t,n);case 22:return II(e,t,n)}throw Error(Pe(156,t.tag))};function JI(e,t){return SE(e,t)}function pF(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 zs(e,t,n,r){return new pF(e,t,n,r)}function Jk(e){return e=e.prototype,!(!e||!e.isReactComponent)}function hF(e){if(typeof e=="function")return Jk(e)?1:0;if(e!=null){if(e=e.$$typeof,e===mk)return 11;if(e===gk)return 14}return 2}function la(e,t){var n=e.alternate;return n===null?(n=zs(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 Rh(e,t,n,r,i,o){var a=2;if(r=e,typeof e=="function")Jk(e)&&(a=1);else if(typeof e=="string")a=5;else e:switch(e){case ic:return Ja(n.children,i,o,t);case hk:a=8,i|=8;break;case ax:return e=zs(12,n,t,i|2),e.elementType=ax,e.lanes=o,e;case lx:return e=zs(13,n,t,i),e.elementType=lx,e.lanes=o,e;case cx:return e=zs(19,n,t,i),e.elementType=cx,e.lanes=o,e;case oE:return pg(n,i,o,t);default:if(typeof e=="object"&&e!==null)switch(e.$$typeof){case sE:a=10;break e;case iE:a=9;break e;case mk:a=11;break e;case gk:a=14;break e;case Ho:a=16,r=null;break e}throw Error(Pe(130,e==null?e:typeof e,""))}return t=zs(a,n,t,i),t.elementType=e,t.type=r,t.lanes=o,t}function Ja(e,t,n,r){return e=zs(7,e,r,t),e.lanes=n,e}function pg(e,t,n,r){return e=zs(22,e,r,t),e.elementType=oE,e.lanes=n,e.stateNode={isHidden:!1},e}function rw(e,t,n){return e=zs(6,e,null,t),e.lanes=n,e}function sw(e,t,n){return t=zs(4,e.children!==null?e.children:[],e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}function mF(e,t,n,r,i){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=Dy(0),this.expirationTimes=Dy(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Dy(0),this.identifierPrefix=r,this.onRecoverableError=i,this.mutableSourceEagerHydrationData=null}function Xk(e,t,n,r,i,o,a,l,c){return e=new mF(e,t,n,l,c),t===1?(t=1,o===!0&&(t|=8)):t=0,o=zs(3,null,null,t),e.current=o,o.stateNode=e,o.memoizedState={element:r,isDehydrated:n,cache:null,transitions:null,pendingSuspenseBoundaries:null},Mk(o),e}function gF(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:sc,key:r==null?null:""+r,children:e,containerInfo:t,implementation:n}}function XI(e){if(!e)return fa;e=e._reactInternals;e:{if(xl(e)!==e||e.tag!==1)throw Error(Pe(170));var t=e;do{switch(t.tag){case 3:t=t.stateNode.context;break e;case 1:if(as(t.type)){t=t.stateNode.__reactInternalMemoizedMergedChildContext;break e}}t=t.return}while(t!==null);throw Error(Pe(171))}if(e.tag===1){var n=e.type;if(as(n))return XE(e,n,t)}return t}function QI(e,t,n,r,i,o,a,l,c){return e=Xk(n,r,!0,e,i,o,a,l,c),e.context=XI(null),n=e.current,r=Gr(),i=aa(n),o=lo(r,i),o.callback=t??null,ia(n,o,i),e.current.lanes=i,Ef(e,i,r),ls(e,r),e}function hg(e,t,n,r){var i=t.current,o=Gr(),a=aa(i);return n=XI(n),t.context===null?t.context=n:t.pendingContext=n,t=lo(o,a),t.payload={element:e},r=r===void 0?null:r,r!==null&&(t.callback=r),e=ia(i,t,a),e!==null&&(ui(e,i,a,o),Ch(e,i,a)),a}function ym(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 EN(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Qk(e,t){EN(e,t),(e=e.alternate)&&EN(e,t)}function yF(){return null}var ZI=typeof reportError=="function"?reportError:function(e){console.error(e)};function Zk(e){this._internalRoot=e}mg.prototype.render=Zk.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(Pe(409));hg(e,t,null,null)};mg.prototype.unmount=Zk.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;ol(function(){hg(null,e,null,null)}),t[ho]=null}};function mg(e){this._internalRoot=e}mg.prototype.unstable_scheduleHydration=function(e){if(e){var t=IE();e={blockedOn:null,target:e,priority:t};for(var n=0;n<qo.length&&t!==0&&t<qo[n].priority;n++);qo.splice(n,0,e),n===0&&TE(e)}};function ev(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function gg(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11&&(e.nodeType!==8||e.nodeValue!==" react-mount-point-unstable "))}function IN(){}function wF(e,t,n,r,i){if(i){if(typeof r=="function"){var o=r;r=function(){var u=ym(a);o.call(u)}}var a=QI(t,r,e,0,null,!1,!1,"",IN);return e._reactRootContainer=a,e[ho]=a.current,Gd(e.nodeType===8?e.parentNode:e),ol(),a}for(;i=e.lastChild;)e.removeChild(i);if(typeof r=="function"){var l=r;r=function(){var u=ym(c);l.call(u)}}var c=Xk(e,0,!1,null,null,!1,!1,"",IN);return e._reactRootContainer=c,e[ho]=c.current,Gd(e.nodeType===8?e.parentNode:e),ol(function(){hg(t,c,n,r)}),c}function yg(e,t,n,r,i){var o=n._reactRootContainer;if(o){var a=o;if(typeof i=="function"){var l=i;i=function(){var c=ym(a);l.call(c)}}hg(t,a,e,i)}else a=wF(n,t,e,i,r);return ym(a)}AE=function(e){switch(e.tag){case 3:var t=e.stateNode;if(t.current.memoizedState.isDehydrated){var n=ud(t.pendingLanes);n!==0&&(xk(t,n|1),ls(t,tr()),!(Xt&6)&&(Wc=tr()+500,va()))}break;case 13:ol(function(){var r=mo(e,1);if(r!==null){var i=Gr();ui(r,e,1,i)}}),Qk(e,1)}};bk=function(e){if(e.tag===13){var t=mo(e,134217728);if(t!==null){var n=Gr();ui(t,e,134217728,n)}Qk(e,134217728)}};EE=function(e){if(e.tag===13){var t=aa(e),n=mo(e,t);if(n!==null){var r=Gr();ui(n,e,t,r)}Qk(e,t)}};IE=function(){return cn};PE=function(e,t){var n=cn;try{return cn=e,t()}finally{cn=n}};xx=function(e,t,n){switch(t){case"input":if(fx(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 i=ag(r);if(!i)throw Error(Pe(90));lE(r),fx(r,i)}}}break;case"textarea":uE(e,n);break;case"select":t=n.value,t!=null&&vc(e,!!n.multiple,t,!1)}};yE=Uk;wE=ol;var xF={usingClientEntryPoint:!1,Events:[Pf,cc,ag,mE,gE,Uk]},Ju={findFiberByHostInstance:Ha,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},bF={bundleType:Ju.bundleType,version:Ju.version,rendererPackageName:Ju.rendererPackageName,rendererConfig:Ju.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:ko.ReactCurrentDispatcher,findHostInstanceByFiber:function(e){return e=kE(e),e===null?null:e.stateNode},findFiberByHostInstance:Ju.findFiberByHostInstance||yF,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 Hp=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Hp.isDisabled&&Hp.supportsFiber)try{rg=Hp.inject(bF),Mi=Hp}catch{}}js.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=xF;js.createPortal=function(e,t){var n=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!ev(t))throw Error(Pe(200));return gF(e,t,null,n)};js.createRoot=function(e,t){if(!ev(e))throw Error(Pe(299));var n=!1,r="",i=ZI;return t!=null&&(t.unstable_strictMode===!0&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onRecoverableError!==void 0&&(i=t.onRecoverableError)),t=Xk(e,1,!1,null,null,n,!1,r,i),e[ho]=t.current,Gd(e.nodeType===8?e.parentNode:e),new Zk(t)};js.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(Pe(188)):(e=Object.keys(e).join(","),Error(Pe(268,e)));return e=kE(t),e=e===null?null:e.stateNode,e};js.flushSync=function(e){return ol(e)};js.hydrate=function(e,t,n){if(!gg(t))throw Error(Pe(200));return yg(null,e,t,!0,n)};js.hydrateRoot=function(e,t,n){if(!ev(e))throw Error(Pe(405));var r=n!=null&&n.hydratedSources||null,i=!1,o="",a=ZI;if(n!=null&&(n.unstable_strictMode===!0&&(i=!0),n.identifierPrefix!==void 0&&(o=n.identifierPrefix),n.onRecoverableError!==void 0&&(a=n.onRecoverableError)),t=QI(t,null,e,1,n??null,i,!1,o,a),e[ho]=t.current,Gd(e),r)for(e=0;e<r.length;e++)n=r[e],i=n._getVersion,i=i(n._source),t.mutableSourceEagerHydrationData==null?t.mutableSourceEagerHydrationData=[n,i]:t.mutableSourceEagerHydrationData.push(n,i);return new mg(t)};js.render=function(e,t,n){if(!gg(t))throw Error(Pe(200));return yg(null,e,t,!1,n)};js.unmountComponentAtNode=function(e){if(!gg(e))throw Error(Pe(40));return e._reactRootContainer?(ol(function(){yg(null,null,e,!1,function(){e._reactRootContainer=null,e[ho]=null})}),!0):!1};js.unstable_batchedUpdates=Uk;js.unstable_renderSubtreeIntoContainer=function(e,t,n,r){if(!gg(n))throw Error(Pe(200));if(e==null||e._reactInternals===void 0)throw Error(Pe(38));return yg(e,t,n,!1,r)};js.version="18.3.1-next-f1338f8080-20240426";function eP(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(eP)}catch(e){console.error(e)}}eP(),eE.exports=js;var er=eE.exports,PN=er;ix.createRoot=PN.createRoot,ix.hydrateRoot=PN.hydrateRoot;const tP=h.createContext(null);function Qx(e){let t=e||"/";return t.length>1&&t.endsWith("/")&&(t=t.slice(0,-1)),t||"/"}function kF(){const e=Qx(window.location.pathname);return e==="/"?(window.history.replaceState({},"","/projects"),"/projects"):e}function vF({children:e}){const[t,n]=h.useState(kF);h.useEffect(()=>{const o=()=>n(Qx(window.location.pathname));return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[]);const r=h.useCallback(o=>{const a=o.startsWith("/")?o:`/${o}`;let l;try{l=new URL(a,window.location.origin)}catch{l=new URL("/",window.location.origin)}const c=Qx(l.pathname),u=l.search||"";window.history.pushState({},"",c+u),n(c)},[]),i=h.useMemo(()=>({path:t,navigate:r}),[t,r]);return s.jsx(tP.Provider,{value:i,children:e})}function us(){const e=h.useContext(tP);if(!e)throw new Error("useRoute must be used within RouteProvider");return e}function SF(){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 TN={};function Zx(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];typeof t[0]=="string"&&TN[t[0]]||(typeof t[0]=="string"&&(TN[t[0]]=new Date),SF(...t))}const nP=(e,t)=>()=>{if(e.isInitialized)t();else{const n=()=>{setTimeout(()=>{e.off("initialized",n)},0),t()};e.on("initialized",n)}};function RN(e,t,n){e.loadNamespaces(t,nP(e,n))}function MN(e,t,n,r){typeof n=="string"&&(n=[n]),n.forEach(i=>{e.options.ns.indexOf(i)<0&&e.options.ns.push(i)}),e.loadLanguages(t,nP(e,r))}function jF(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const r=t.languages[0],i=t.options?t.options.fallbackLng:!1,o=t.languages[t.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const u=t.services.backendConnector.state[`${l}|${c}`];return u===-1||u===2};return n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&t.services.backendConnector.backend&&t.isLanguageChangingTo&&!a(t.isLanguageChangingTo,e)?!1:!!(t.hasResourceBundle(r,e)||!t.services.backendConnector.backend||t.options.resources&&!t.options.partialBundledLanguages||a(r,e)&&(!i||a(o,e)))}function NF(e,t){let n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return!t.languages||!t.languages.length?(Zx("i18n.languages were undefined or empty",t.languages),!0):t.options.ignoreJSONStructure!==void 0?t.hasLoadedNamespace(e,{lng:n.lng,precheck:(i,o)=>{if(n.bindI18n&&n.bindI18n.indexOf("languageChanging")>-1&&i.services.backendConnector.backend&&i.isLanguageChangingTo&&!o(i.isLanguageChangingTo,e))return!1}}):jF(e,t,n)}const _F=/&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g,CF={"&":"&","&":"&","<":"<","<":"<",">":">",">":">","'":"'","'":"'",""":'"',""":'"'," ":" "," ":" ","©":"©","©":"©","®":"®","®":"®","…":"…","…":"…","/":"/","/":"/"},AF=e=>CF[e],EF=e=>e.replace(_F,AF);let eb={bindI18n:"languageChanged",bindI18nStore:"",transEmptyNodeValue:"",transSupportBasicHtmlNodes:!0,transWrapTextNodes:"",transKeepBasicHtmlNodesFor:["br","strong","i","p"],useSuspense:!0,unescape:EF};function IF(){let e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};eb={...eb,...e}}function PF(){return eb}let rP;function TF(e){rP=e}function RF(){return rP}const MF={type:"3rdParty",init(e){IF(e.options.react),TF(e)}},$F=h.createContext();class LF{constructor(){this.usedNamespaces={}}addUsedNamespaces(t){t.forEach(n=>{this.usedNamespaces[n]||(this.usedNamespaces[n]=!0)})}getUsedNamespaces(){return Object.keys(this.usedNamespaces)}}const OF=(e,t)=>{const n=h.useRef();return h.useEffect(()=>{n.current=e},[e,t]),n.current};function zr(e){let t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const{i18n:n}=t,{i18n:r,defaultNS:i}=h.useContext($F)||{},o=n||r||RF();if(o&&!o.reportNamespaces&&(o.reportNamespaces=new LF),!o){Zx("You will need to pass in an i18next instance by using initReactI18next");const x=(j,N)=>typeof N=="string"?N:N&&typeof N=="object"&&typeof N.defaultValue=="string"?N.defaultValue:Array.isArray(j)?j[j.length-1]:j,_=[x,{},!1];return _.t=x,_.i18n={},_.ready=!1,_}o.options.react&&o.options.react.wait!==void 0&&Zx("It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");const a={...PF(),...o.options.react,...t},{useSuspense:l,keyPrefix:c}=a;let u=e||i||o.options&&o.options.defaultNS;u=typeof u=="string"?[u]:u||["translation"],o.reportNamespaces.addUsedNamespaces&&o.reportNamespaces.addUsedNamespaces(u);const f=(o.isInitialized||o.initializedStoreOnce)&&u.every(x=>NF(x,o,a));function p(){return o.getFixedT(t.lng||null,a.nsMode==="fallback"?u:u[0],c)}const[d,m]=h.useState(p);let y=u.join();t.lng&&(y=`${t.lng}${y}`);const v=OF(y),b=h.useRef(!0);h.useEffect(()=>{const{bindI18n:x,bindI18nStore:_}=a;b.current=!0,!f&&!l&&(t.lng?MN(o,t.lng,u,()=>{b.current&&m(p)}):RN(o,u,()=>{b.current&&m(p)})),f&&v&&v!==y&&b.current&&m(p);function j(){b.current&&m(p)}return x&&o&&o.on(x,j),_&&o&&o.store.on(_,j),()=>{b.current=!1,x&&o&&x.split(" ").forEach(N=>o.off(N,j)),_&&o&&_.split(" ").forEach(N=>o.store.off(N,j))}},[o,y]);const g=h.useRef(!0);h.useEffect(()=>{b.current&&!g.current&&m(p),g.current=!1},[o,c]);const k=[d,o,f];if(k.t=d,k.i18n=o,k.ready=f,f||!f&&!l)return k;throw new Promise(x=>{t.lng?MN(o,t.lng,u,()=>x()):RN(o,u,()=>x())})}const sP="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",DF=[{to:"/projects",labelKey:"common:nav.projects",icon:"folder_open"},{to:"/workflows",label:"迭代",icon:"timeline"},{to:"/workspaces",label:"知识库",icon:"folder_managed"},{to:"/nodes",labelKey:"common:nav.nodes",icon:"account_tree"},{to:"/my-flows",labelKey:"common:nav.myFlows",icon:"schema"},{to:"/skills",labelKey:"common:nav.skills",icon:"extension"},{to:"/mcps",labelKey:"common:nav.mcps",icon:"hub"},{to:"/node-studio",label:"节点编辑器",icon:"draw"},{to:"/schedules",label:"定时任务",icon:"event_busy"},{to:"/admin/usage",label:"管理看板",icon:"query_stats",adminOnly:!0},{to:"/admin/teams",label:"团队管理",icon:"groups",adminOnly:!0},{to:"/feedback",labelKey:"common:nav.feedback",icon:"rate_review"},{to:"/settings",labelKey:"common:nav.settings",icon:"settings"}],FF=[{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 zF(e,t){return t==="/projects"?e==="/projects"||e==="/":t==="/nodes"?e==="/nodes"||e==="/my-nodes":e===t||e.startsWith(t+"/")}function BF({authUser:e,onLogout:t}){const{path:n,navigate:r}=us(),{t:i}=zr(),[o,a]=h.useState(!1);return h.useEffect(()=>{let l=!1;return fetch("/api/ui-context").then(c=>c.json()).then(c=>{l||a(!!c.hideCommunityLinks)}).catch(()=>{}),()=>{l=!0}},[]),s.jsxs("aside",{className:"af-sidebar","aria-label":i("flow:sidebar.mainNav"),children:[s.jsxs("div",{className:"af-brand",children:[s.jsx("div",{className:"af-brand-mark","aria-hidden":!0,children:s.jsx("img",{src:sP,alt:"",width:"36",height:"36",decoding:"async"})}),s.jsxs("div",{children:[s.jsx("h1",{className:"af-brand-title",children:"Agentflow"}),s.jsx("p",{className:"af-brand-tag",children:"Orchestration Engine"})]})]}),s.jsx("nav",{className:"af-nav",children:DF.filter(l=>!l.adminOnly||(e==null?void 0:e.isAdmin)).map(l=>s.jsxs("button",{type:"button",className:"af-nav-link"+(zF(n,l.to)?" af-nav-link--active":""),onClick:()=>r(l.to),children:[s.jsx("span",{className:"material-symbols-outlined",children:l.icon}),s.jsx("span",{children:l.label||i(l.labelKey)})]},l.to))}),s.jsxs("div",{className:"af-sidebar-footer",children:[s.jsxs("div",{className:"af-sidebar-user",title:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||"",children:[s.jsx("span",{className:"material-symbols-outlined",children:"person"}),s.jsx("span",{children:(e==null?void 0:e.username)||(e==null?void 0:e.userId)||""}),e!=null&&e.isAdmin?s.jsx("span",{className:"af-sidebar-admin-badge",children:"Admin"}):null,s.jsx("button",{type:"button",className:"af-sidebar-logout",onClick:t,"aria-label":"Logout",title:"Logout",children:s.jsx("span",{className:"material-symbols-outlined",children:"logout"})})]}),!o&&FF.map(l=>{const c=i(l.labelKey);return s.jsx("a",{className:"af-sidebar-ext",href:l.href,target:"_blank",rel:"noopener noreferrer","aria-label":c,title:c,children:s.jsx("span",{className:"material-symbols-outlined",children:l.icon})},l.href)})]})]})}const WF="agentflow.pipelineRecent",HF=15;function VF(e){try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}}function KF(){if(typeof localStorage>"u")return[];const e=localStorage.getItem(WF);return e?VF(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 qF(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 $N(e,t){const n=Date.now(),r=Math.max(0,n-e),i=Math.floor(r/1e3);if(i<60)return t("flow:time.justNow");const o=Math.floor(i/60);if(o<60)return t("flow:time.minutesAgo",{n:o});const a=Math.floor(o/60);if(a<24)return t("flow:time.hoursAgo",{n:a});const l=new Date(e),c=new Date,u=new Date(c);if(u.setDate(u.getDate()-1),l.toDateString()===u.toDateString())return t("flow:time.yesterday");const f=Math.floor(a/24);return f<7?t("flow:time.daysAgo",{n:f}):`${l.getMonth()+1}/${l.getDate()}`}function UF(e,t,n){const r=[];for(const i of e)!i||typeof i.flowId!="string"||typeof i.at!="number"||r.push({flowId:i.flowId,flowSource:qF(n,i.flowId),kind:"executed",at:i.at});for(const i of t)r.push({flowId:i.flowId,flowSource:i.flowSource,kind:"opened",at:i.at});return r.sort((i,o)=>o.at-i.at),r.slice(0,HF)}var gs=Uint8Array,gc=Uint16Array,GF=Int32Array,iP=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]),oP=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]),YF=new gs([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),aP=function(e,t){for(var n=new gc(31),r=0;r<31;++r)n[r]=t+=1<<e[r-1];for(var i=new GF(n[30]),r=1;r<30;++r)for(var o=n[r];o<n[r+1];++o)i[o]=o-n[r]<<5|r;return{b:n,r:i}},lP=aP(iP,2),cP=lP.b,JF=lP.r;cP[28]=258,JF[258]=28;var XF=aP(oP,0),QF=XF.b,tb=new gc(32768);for(var En=0;En<32768;++En){var Lo=(En&43690)>>1|(En&21845)<<1;Lo=(Lo&52428)>>2|(Lo&13107)<<2,Lo=(Lo&61680)>>4|(Lo&3855)<<4,tb[En]=((Lo&65280)>>8|(Lo&255)<<8)>>1}var Ed=function(e,t,n){for(var r=e.length,i=0,o=new gc(t);i<r;++i)e[i]&&++o[e[i]-1];var a=new gc(t);for(i=1;i<t;++i)a[i]=a[i-1]+o[i-1]<<1;var l;if(n){l=new gc(1<<t);var c=15-t;for(i=0;i<r;++i)if(e[i])for(var u=i<<4|e[i],f=t-e[i],p=a[e[i]-1]++<<f,d=p|(1<<f)-1;p<=d;++p)l[tb[p]>>c]=u}else for(l=new gc(r),i=0;i<r;++i)e[i]&&(l[i]=tb[a[e[i]-1]++]>>15-e[i]);return l},Rf=new gs(288);for(var En=0;En<144;++En)Rf[En]=8;for(var En=144;En<256;++En)Rf[En]=9;for(var En=256;En<280;++En)Rf[En]=7;for(var En=280;En<288;++En)Rf[En]=8;var uP=new gs(32);for(var En=0;En<32;++En)uP[En]=5;var ZF=Ed(Rf,9,1),ez=Ed(uP,5,1),iw=function(e){for(var t=e[0],n=1;n<e.length;++n)e[n]>t&&(t=e[n]);return t},Zs=function(e,t,n){var r=t/8|0;return(e[r]|e[r+1]<<8)>>(t&7)&n},ow=function(e,t){var n=t/8|0;return(e[n]|e[n+1]<<8|e[n+2]<<16)>>(t&7)},tz=function(e){return(e+7)/8|0},tv=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))},nz=["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"],$s=function(e,t,n){var r=new Error(t||nz[e]);if(r.code=e,Error.captureStackTrace&&Error.captureStackTrace(r,$s),!n)throw r;return r},rz=function(e,t,n,r){var i=e.length,o=r?r.length:0;if(!i||t.f&&!t.l)return n||new gs(0);var a=!n,l=a||t.i!=2,c=t.i;a&&(n=new gs(i*3));var u=function(le){var fe=n.length;if(le>fe){var me=new gs(Math.max(fe*2,le));me.set(n),n=me}},f=t.f||0,p=t.p||0,d=t.b||0,m=t.l,y=t.d,v=t.m,b=t.n,g=i*8;do{if(!m){f=Zs(e,p,1);var k=Zs(e,p+1,3);if(p+=3,k)if(k==1)m=ZF,y=ez,v=9,b=5;else if(k==2){var N=Zs(e,p,31)+257,P=Zs(e,p+10,15)+4,T=N+Zs(e,p+5,31)+1;p+=14;for(var z=new gs(T),E=new gs(19),O=0;O<P;++O)E[YF[O]]=Zs(e,p+O*3,7);p+=P*3;for(var D=iw(E),L=(1<<D)-1,$=Ed(E,D,1),O=0;O<T;){var V=$[Zs(e,p,L)];p+=V&15;var x=V>>4;if(x<16)z[O++]=x;else{var W=0,F=0;for(x==16?(F=3+Zs(e,p,3),p+=2,W=z[O-1]):x==17?(F=3+Zs(e,p,7),p+=3):x==18&&(F=11+Zs(e,p,127),p+=7);F--;)z[O++]=W}}var M=z.subarray(0,N),H=z.subarray(N);v=iw(M),b=iw(H),m=Ed(M,v,1),y=Ed(H,b,1)}else $s(1);else{var x=tz(p)+4,_=e[x-4]|e[x-3]<<8,j=x+_;if(j>i){c&&$s(0);break}l&&u(d+_),n.set(e.subarray(x,j),d),t.b=d+=_,t.p=p=j*8,t.f=f;continue}if(p>g){c&&$s(0);break}}l&&u(d+131072);for(var A=(1<<v)-1,X=(1<<b)-1,q=p;;q=p){var W=m[ow(e,p)&A],B=W>>4;if(p+=W&15,p>g){c&&$s(0);break}if(W||$s(2),B<256)n[d++]=B;else if(B==256){q=p,m=null;break}else{var ne=B-254;if(B>264){var O=B-257,ce=iP[O];ne=Zs(e,p,(1<<ce)-1)+cP[O],p+=ce}var K=y[ow(e,p)&X],ee=K>>4;K||$s(3),p+=K&15;var H=QF[ee];if(ee>3){var ce=oP[ee];H+=ow(e,p)&(1<<ce)-1,p+=ce}if(p>g){c&&$s(0);break}l&&u(d+131072);var re=d+ne;if(d<H){var se=o-H,Q=Math.min(H,re);for(se+d<0&&$s(3);d<Q;++d)n[d]=r[se+d]}for(;d<re;++d)n[d]=n[d-H]}}t.l=m,t.p=q,t.b=d,t.f=f,m&&(f=1,t.m=v,t.d=y,t.n=b)}while(!f);return d!=n.length&&a?tv(n,0,d):n.subarray(0,d)},sz=new gs(0),Ei=function(e,t){return e[t]|e[t+1]<<8},ii=function(e,t){return(e[t]|e[t+1]<<8|e[t+2]<<16|e[t+3]<<24)>>>0},aw=function(e,t){return ii(e,t)+ii(e,t+4)*4294967296};function iz(e,t){return rz(e,{i:2},t&&t.out,t&&t.dictionary)}var nb=typeof TextDecoder<"u"&&new TextDecoder,oz=0;try{nb.decode(sz,{stream:!0}),oz=1}catch{}var az=function(e){for(var t="",n=0;;){var r=e[n++],i=(r>127)+(r>223)+(r>239);if(n+i>e.length)return{s:t,r:tv(e,n-1)};i?i==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)):i&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 lz(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(nb)return nb.decode(e);var i=az(e),o=i.s,n=i.r;return n.length&&$s(8),o}}var cz=function(e,t){return t+30+Ei(e,t+26)+Ei(e,t+28)},uz=function(e,t,n){var r=Ei(e,t+28),i=lz(e.subarray(t+46,t+46+r),!(Ei(e,t+8)&2048)),o=t+46+r,a=ii(e,t+20),l=n&&a==4294967295?dz(e,o):[a,ii(e,t+24),ii(e,t+42)],c=l[0],u=l[1],f=l[2];return[Ei(e,t+10),c,u,i,o+Ei(e,t+30)+Ei(e,t+32),f]},dz=function(e,t){for(;Ei(e,t)!=1;t+=4+Ei(e,t+2));return[aw(e,t+12),aw(e,t+4),aw(e,t+20)]};function fz(e,t){for(var n={},r=e.length-22;ii(e,r)!=101010256;--r)(!r||e.length-r>65558)&&$s(13);var i=Ei(e,r+8);if(!i)return{};var o=ii(e,r+16),a=o==4294967295||i==65535;if(a){var l=ii(e,r-12);a=ii(e,l)==101075792,a&&(i=ii(e,l+32),o=ii(e,l+48))}for(var c=0;c<i;++c){var u=uz(e,o,a),f=u[0],p=u[1],d=u[2],m=u[3],y=u[4],v=u[5],b=cz(e,v);o=y,f?f==8?n[m]=iz(e.subarray(b,b+p),{out:new gs(d)}):$s(14,"unknown compression type "+f):n[m]=tv(e,b,b+p)}return n}const pz=8*1024*1024,hz=500;function mz(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 gz(e){return e?e.split("/").some(n=>n==="__MACOSX"||n.startsWith("._")):!0}function yz(e){const t=e.toLowerCase();if(t==="flow.yaml"||t==="flow.yml")return"";const n="/flow.yaml",r="/flow.yml";let i=null;if(t.endsWith(n))i=e.slice(0,-n.length);else if(t.endsWith(r))i=e.slice(0,-r.length);else return null;return i.includes("/")?null:i}const wz=/^[a-zA-Z][a-zA-Z0-9_-]*$/;async function xz(e){try{const t=new Uint8Array(await e.arrayBuffer()),n=fz(t),r=new Map;let i=0,o=0;for(const[c,u]of Object.entries(n)){if(c.endsWith("/"))continue;const f=mz(c);if(!f||gz(f))continue;const p=(u==null?void 0:u.length)??0;if(i+=p,i>pz||(o+=1,o>hz))return null;r.set(f,p)}if(r.size===0)return null;const a=new Set;for(const c of r.keys()){const u=yz(c);u!==null&&a.add(u)}if(a.size!==1)return null;const[l]=[...a];if(l==="")return null;for(const c of r.keys())if(!(c===l||c.startsWith(`${l}/`)))return null;return wz.test(l)?l:null}catch{return null}}const lw=/^[a-zA-Z][a-zA-Z0-9_-]*$/;function bz({file:e,onClose:t,onImported:n}){const{t:r}=zr(),i=h.useId(),o=h.useRef(null),a=h.useRef(null),[l,c]=h.useState(""),[u,f]=h.useState("user"),[p,d]=h.useState(!1),[m,y]=h.useState(""),[v,b]=h.useState(null),g=v??e;h.useEffect(()=>{const j=requestAnimationFrame(()=>{var N;return(N=o.current)==null?void 0:N.focus()});return()=>cancelAnimationFrame(j)},[]),h.useEffect(()=>{let j=!1;return(async()=>{const N=g.name||"",P=N.toLowerCase();let T="";if(P.endsWith(".zip")){if(T=await xz(g)||"",!T){const z=N.replace(/\.zip$/i,"");lw.test(z)&&(T=z)}}else if(P.endsWith(".yaml")||P.endsWith(".yml")){const z=N.replace(/\.ya?ml$/i,"");lw.test(z)&&(T=z)}j||c(T)})(),()=>{j=!0}},[g]);const k=l.trim(),x=k.length>0&&lw.test(k);async function _(j){if(j.preventDefault(),!(!x||p)){d(!0),y("");try{const N=new FormData;N.set("flowId",k),N.set("targetSpace",u),N.set("file",g,g.name);const P=await fetch("/api/flows/import",{method:"POST",body:N}),T=await P.json().catch(()=>({}));if(!P.ok){y(typeof T.error=="string"?T.error:r("project:importModal.importFailed"));return}n({id:T.flowId,source:T.flowSource??"user"})}catch(N){y(String((N==null?void 0:N.message)||N))}finally{d(!1)}}}return s.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:j=>{j.target===j.currentTarget&&t()},children:s.jsxs("div",{ref:o,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":i,tabIndex:-1,onMouseDown:j=>j.stopPropagation(),children:[s.jsxs("div",{className:"af-shortcuts-panel__head",children:[s.jsx("h2",{id:i,className:"af-shortcuts-panel__title",children:r("project:importModal.title")}),s.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":r("project:importModal.close"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:_,children:[s.jsx("p",{className:"af-new-pipeline-lead",children:r("project:importModal.lead",{filename:g.name})}),s.jsx("input",{ref:a,type:"file",className:"af-import-file-input",accept:".yaml,.yml,.zip,application/zip","aria-hidden":!0,tabIndex:-1,onChange:j=>{var P;const N=(P=j.target.files)==null?void 0:P[0];N&&b(N),j.target.value=""}}),s.jsxs("label",{className:"af-pipeline-drawer-field",children:[s.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:importModal.nameLabel")}),s.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"importFlowId",autoComplete:"off",spellCheck:!1,placeholder:r("project:importModal.namePlaceholder"),value:l,onChange:j=>c(j.target.value),"aria-invalid":k.length>0&&!x}),s.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r("project:importModal.nameHint")})]}),s.jsx("div",{className:"af-import-repick",children:s.jsx("button",{type:"button",className:"af-btn-secondary af-import-repick-btn",onClick:()=>{var j;return(j=a.current)==null?void 0:j.click()},children:r("project:importModal.changeFile")})}),m?s.jsx("p",{className:"af-err af-new-pipeline-err",children:m}):null,s.jsxs("div",{className:"af-new-pipeline-actions",children:[s.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:p,children:r("project:importModal.cancel")}),s.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!x||p,children:r(p?"project:importModal.importing":"project:importModal.importAndOpen")})]})]})]})})}const kz=/^[a-zA-Z][a-zA-Z0-9_-]*$/,LN="af:newPipelineGuide";function vz({open:e,onClose:t,onCreated:n}){const{t:r}=zr(),i=h.useId(),o=h.useRef(null),[a,l]=h.useState(""),[c,u]=h.useState(""),[f,p]=h.useState("user"),[d,m]=h.useState(!1),[y,v]=h.useState(""),[b,g]=h.useState(!1);h.useEffect(()=>{if(!e)return;l(""),u(""),p("user"),v(""),m(!1),localStorage.getItem(LN)==="true"&&g(!0);const P=requestAnimationFrame(()=>{var T;return(T=o.current)==null?void 0:T.focus()});return()=>cancelAnimationFrame(P)},[e]);const k=()=>{localStorage.removeItem(LN),g(!1)};if(!e)return null;const x=a.trim(),_=x.length>0&&kz.test(x);async function j(N){if(N.preventDefault(),!(!_||d)){m(!0),v(""),k();try{const P=await fetch("/api/flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:x,description:c.trim(),targetSpace:f})}),T=await P.json().catch(()=>({}));if(!P.ok){v(typeof T.error=="string"?T.error:r("project:newPipelineModal.createFailed"));return}n({id:T.flowId,source:T.flowSource??"user"})}catch(P){v(String((P==null?void 0:P.message)||P))}finally{m(!1)}}}return s.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:N=>{N.target===N.currentTarget&&(k(),t())},children:s.jsxs("div",{ref:o,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":i,tabIndex:-1,onMouseDown:N=>N.stopPropagation(),children:[s.jsxs("div",{className:"af-shortcuts-panel__head",children:[s.jsx("h2",{id:i,className:"af-shortcuts-panel__title",children:r("project:newPipelineModal.title")}),s.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:()=>{k(),t()},"aria-label":r("project:newPipelineModal.close"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),b?s.jsx("div",{className:"af-new-pipeline-guide",children:s.jsxs("div",{className:"af-new-pipeline-guide-content",children:[s.jsx("span",{className:"material-symbols-outlined af-new-pipeline-guide-icon",children:"lightbulb"}),s.jsxs("div",{className:"af-new-pipeline-guide-text",children:[s.jsx("p",{children:s.jsx("strong",{children:r("onboarding:newPipeline.guideTitle")})}),s.jsx("p",{children:r("onboarding:newPipeline.guideDesc")})]}),s.jsx("button",{type:"button",className:"af-new-pipeline-guide-close",onClick:k,children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})}):null,s.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:j,children:[s.jsx("p",{className:"af-new-pipeline-lead",children:r("project:newPipelineModal.lead")}),s.jsxs("label",{className:"af-pipeline-drawer-field",children:[s.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.nameLabel")}),s.jsx("input",{className:"af-new-pipeline-input",type:"text",name:"pipelineName",autoComplete:"off",spellCheck:!1,placeholder:r("project:newPipelineModal.namePlaceholder"),value:a,onChange:N=>l(N.target.value),"aria-invalid":x.length>0&&!_}),s.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-hint",children:r(b?"onboarding:newPipeline.nameHintGuide":"project:newPipelineModal.nameHint")})]}),s.jsxs("label",{className:"af-pipeline-drawer-field",children:[s.jsx("span",{className:"af-pipeline-drawer-label",children:r("project:newPipelineModal.descLabel")}),s.jsx("textarea",{className:"af-pipeline-drawer-textarea af-new-pipeline-textarea",name:"pipelineDescription",rows:3,placeholder:r(b?"onboarding:newPipeline.descPlaceholderGuide":"project:newPipelineModal.descPlaceholder"),value:c,onChange:N=>u(N.target.value)}),b?s.jsx("span",{className:"af-pipeline-drawer-muted af-new-pipeline-guide-hint",children:r("onboarding:newPipeline.descHintGuide")}):null]}),y?s.jsx("p",{className:"af-err af-new-pipeline-err",children:y}):null,s.jsxs("div",{className:"af-new-pipeline-actions",children:[s.jsx("button",{type:"button",className:"af-btn-secondary",onClick:()=>{k(),t()},disabled:d,children:r("project:newPipelineModal.cancel")}),s.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!_||d,children:r(d?"project:newPipelineModal.creating":b?"onboarding:newPipeline.createGuide":"project:newPipelineModal.createAndOpen")})]})]})]})})}const dP="agentflow.pipelineViewPreference";function fP(e,t="user",n=!1){return`${String(t||"user")}:${String(e||"")}:${n?"archived":"active"}`}function pP(){if(typeof localStorage>"u")return{};try{const e=JSON.parse(localStorage.getItem(dP)||"{}");return e&&typeof e=="object"&&!Array.isArray(e)?e:{}}catch{return{}}}function Sz(e){if(!(typeof localStorage>"u"))try{localStorage.setItem(dP,JSON.stringify(e))}catch{}}function nv(e){return e==="display"?"display":"workspace"}function jz(e){const t=String(e||"").toLowerCase();return t==="builtin"||t==="admin"}function hP(e,t){const n=nv(t);return n==="pipeline"&&jz(e==null?void 0:e.source)?"workspace":n}function Nz(e){return(e==null?void 0:e.hasPipeline)!==!1&&(e==null?void 0:e.hasFlow)!==!1&&(e==null?void 0:e.flowYaml)!==!1}function _z(e,t,n,r=!1){if(!e)return;const i=pP();i[fP(e,t,r)]={view:nv(n),at:Date.now()},Sz(i)}function Cz(e,t="workspace"){if(!(e!=null&&e.id))return nv(t);const r=pP()[fP(e.id,e.source??"user",!!e.archived)],i=hP(e,(r==null?void 0:r.view)||t);return i==="pipeline"&&!Nz(e)?"workspace":i}function Az(e,t="workspace"){var i;const n=hP(e,t);if(!(e!=null&&e.id))return n==="display"?"/workspace?view=display":"/workspace";const r=new URLSearchParams({flowId:e.id,flowSource:e.source??"user"});return(i=e.collaboration)!=null&&i.id&&r.set("workspaceId",e.collaboration.id),e.archived&&r.set("archived","1"),n==="display"&&r.set("view","display"),`/workspace?${r.toString()}`}function Vp(e,t="workspace"){return Az(e,Cz(e,t))}function Ez(e,t){const n=String(e||"").split(/[.-]/).map(o=>Number.parseInt(o,10)),r=String(t||"").split(/[.-]/).map(o=>Number.parseInt(o,10)),i=Math.max(n.length,r.length);for(let o=0;o<i;o+=1){const a=Number.isFinite(n[o])?n[o]:0,l=Number.isFinite(r[o])?r[o]:0;if(a!==l)return a>l?1:-1}return 0}function rb(e){return String((e==null?void 0:e.version)||"").trim()}function Iz(e){const t=rb(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 Pz({onChanged:e,canManage:t=!1}){const[n,r]=h.useState({available:!1,version:"",loggedIn:!1,user:"",error:""}),[i,o]=h.useState([]),[a,l]=h.useState(""),[c,u]=h.useState(""),[f,p]=h.useState("keyword"),[d,m]=h.useState([]),[y,v]=h.useState({}),[b,g]=h.useState(""),[k,x]=h.useState(""),[_,j]=h.useState(""),N=h.useCallback(async()=>{x("");try{const[D,L]=await Promise.all([fetch("/api/skillhub/status"),fetch("/api/skillhub/list?target=agentflow&agent=codex")]),$=await D.json().catch(()=>({}));D.ok&&r({available:!!$.available,version:typeof $.version=="string"?$.version:"",loggedIn:!!$.loggedIn,user:typeof $.user=="string"?$.user:"",error:typeof $.error=="string"?$.error:""});const V=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof V.error=="string"?V.error:"HTTP "+L.status);o(Array.isArray(V.skills)?V.skills:[]),l(typeof V.skillsRoot=="string"?V.skillsRoot:""),v({})}catch(D){x(String(D.message||D))}},[]);h.useEffect(()=>{N()},[N]);const P=h.useCallback(async()=>{const D=c.trim();if(D){g("search"),x(""),j("");try{const L=await fetch(`/api/skillhub/search?q=${encodeURIComponent(D)}&mode=${encodeURIComponent(f)}`),$=await L.json().catch(()=>({}));if(!L.ok)throw new Error(typeof $.error=="string"?$.error:"HTTP "+L.status);m(Array.isArray($.items)?$.items:[])}catch(L){x(String(L.message||L))}finally{g("")}}},[c,f]),T=h.useCallback(async(D,L=!1)=>{if(!t)return;const $=D&&typeof D=="object"?D:null,V=String($?$.slug||$.name||$.collection||$.skillId||$.id:D||"").trim();if(V){g(`install:${V}`),x(""),j("");try{const W=$?{slug:$.slug||"",skillId:$.skillId||"",collection:$.collection||"",collectionName:$.collection&&$.name||"",target:"agentflow",agent:"codex",force:L}:{slug:V,target:"agentflow",agent:"codex",force:L},F=await fetch("/api/skillhub/install",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(W)}),M=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof M.error=="string"?M.error:"HTTP "+F.status);j(L?`已更新 ${V}`:`已安装 ${V}`),await N(),typeof e=="function"&&await e()}catch(W){x(String(W.message||W))}finally{g("")}}},[t,N,e]),z=h.useCallback(async()=>{if(t&&i.length!==0){g("check-updates"),x(""),j("");try{const D=await Promise.all(i.map(async V=>{const W=String(V.name||"").trim();if(!W)return null;try{const F=await fetch(`/api/skillhub/search?q=${encodeURIComponent(W)}&mode=keyword`),M=await F.json().catch(()=>({}));if(!F.ok)throw new Error(typeof M.error=="string"?M.error:"HTTP "+F.status);const H=Array.isArray(M.items)?M.items:[],A=H.find(ne=>ne.slug===W||ne.name===W||ne.id===W)||H[0],X=rb(V),q=String((A==null?void 0:A.version)||"").trim();let B="unknown";return A?X&&q?B=Ez(X,q)<0?"update":"current":q&&(B="remote-only"):B="missing",[W,{state:B,latestVersion:q,installedVersion:X,summary:(A==null?void 0:A.summary)||""}]}catch(F){return[W,{state:"error",error:String(F.message||F),installedVersion:rb(V)}]}})),L={};for(const V of D)V&&(L[V[0]]=V[1]);v(L);const $=Object.values(L).filter(V=>V.state==="update").length;j($>0?`发现 ${$} 个可更新 skill`:"已检查,暂无明确可更新项")}finally{g("")}}},[t,i]),E=h.useCallback(async D=>{if(!t)return;const L=String(D||"").trim();if(L){g(`uninstall:${L}`),x(""),j("");try{const $=await fetch("/api/skillhub/uninstall",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({slug:L,target:"agentflow",agent:"codex"})}),V=await $.json().catch(()=>({}));if(!$.ok)throw new Error(typeof V.error=="string"?V.error:"HTTP "+$.status);j(`已卸载 ${L}`),await N(),typeof e=="function"&&await e()}catch($){x(String($.message||$))}finally{g("")}}},[t,N,e]),O=h.useCallback(async()=>{if(t){g("update-cli"),x(""),j("");try{const D=await fetch("/api/skillhub/update",{method:"POST"}),L=await D.json().catch(()=>({}));if(!D.ok)throw new Error(typeof L.error=="string"?L.error:"HTTP "+D.status);j("SkillHub CLI 已更新"),await N()}catch(D){x(String(D.message||D))}finally{g("")}}},[t,N]);return s.jsxs("section",{className:"af-set-card af-set-card--span-all af-set-skillhub",children:[s.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"af-set-h2",children:"SkillHub"}),s.jsx("p",{className:"af-set-p af-set-p--tight",children:t?"搜索、安装、更新和卸载 AgentFlow 共享 skills。":"查看 AgentFlow 共享 skills;使用时在 Workspace 中通过 Load Skills 加载。"}),a?s.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:["Skills Root:",s.jsx("code",{children:a})]}):null]}),s.jsxs("div",{className:"af-set-skillhub-head-actions",children:[s.jsxs("div",{className:"af-set-skillhub-status",children:[s.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:"extension"}),s.jsx("span",{children:n.loggedIn?`已登录 ${n.user}`:"未登录 SkillHub"}),s.jsx("span",{className:"af-set-badge"+(n.available?" af-set-badge--ok":" af-set-badge--err"),children:n.available?`v${n.version}`:"not found"})]}),s.jsxs("div",{className:"af-set-skillhub-toolbar",children:[s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:N,disabled:!!b,children:"刷新"}),s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:z,disabled:!t||!!b||i.length===0,children:b==="check-updates"?"检查中…":"检查更新"}),s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:O,disabled:!t||!!b,children:b==="update-cli"?"更新中…":"更新 CLI"})]})]})]}),s.jsxs("div",{className:"af-set-skillhub-search",children:[s.jsxs("select",{className:"af-set-input af-set-input--sm af-set-skillhub-search-mode",value:f,onChange:D=>{p(D.target.value),m([])},children:[s.jsx("option",{value:"keyword",children:"关键词"}),s.jsx("option",{value:"skillId",children:"Skill ID"}),s.jsx("option",{value:"collectionId",children:"Collection ID"})]}),s.jsx("input",{className:"af-set-input af-set-input--sm",value:c,onChange:D=>u(D.target.value),onKeyDown:D=>{D.key==="Enter"&&P()},placeholder:f==="collectionId"?"输入 collection id,例如 1":f==="skillId"?"输入 skill id":"搜索 skill slug / 关键词,例如 android、issue-tracker"}),s.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:()=>P(),disabled:!c.trim()||b==="search",children:[s.jsx("span",{className:"material-symbols-outlined",children:"search"}),b==="search"?"搜索中…":"搜索"]})]}),k?s.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:k}):null,_?s.jsx("p",{className:"af-set-hint af-set-hint--inline",children:_}):null,s.jsxs("div",{className:"af-set-skillhub-grid",children:[s.jsxs("div",{className:"af-set-skillhub-pane",children:[s.jsxs("div",{className:"af-set-skillhub-pane-head",children:[s.jsx("h3",{children:"已安装"}),s.jsx("span",{children:i.length})]}),s.jsx("div",{className:"af-set-skillhub-list",children:i.length===0?s.jsx("div",{className:"af-set-skillhub-empty",children:"暂无 AgentFlow 共享 skills"}):i.map(D=>{const L=y[D.name],$=!L||L.state==="update"||L.state==="remote-only"||L.state==="unknown"||L.state==="error",V=b===`install:${D.name}`?"更新中…":(L==null?void 0:L.state)==="current"?"已最新":(L==null?void 0:L.state)==="update"&&L.latestVersion?`更新到 v${L.latestVersion}`:(L==null?void 0:L.state)==="remote-only"&&L.latestVersion?`安装 v${L.latestVersion}`:"重装";return s.jsxs("div",{className:"af-set-skillhub-item",children:[s.jsxs("div",{children:[s.jsx("div",{className:"af-set-skillhub-title",children:D.displayName||D.name}),s.jsx("div",{className:"af-set-skillhub-meta",children:Iz(D)}),s.jsx("div",{className:"af-set-skillhub-version-row",children:L?L.state==="update"?s.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--warn",children:["可更新 ",L.installedVersion?`v${L.installedVersion} -> `:"","v",L.latestVersion]}):L.state==="current"?s.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--ok",children:["已最新 v",L.latestVersion||L.installedVersion]}):L.state==="remote-only"?s.jsxs("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:["远端 v",L.latestVersion,",本地版本未知"]}):L.state==="missing"?s.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未找到远端匹配项"}):L.state==="error"?s.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--err",children:"检查失败"}):s.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"状态未知"}):s.jsx("span",{className:"af-set-skillhub-version af-set-skillhub-version--muted",children:"未检查远端版本"})})]}),s.jsxs("div",{className:"af-set-skillhub-actions",children:[s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>T(D.name,!0),disabled:!t||!!b||!$,children:V}),s.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>E(D.name),disabled:!t||!!b,children:"卸载"})]})]},`${D.agent}:${D.path}:${D.name}`)})})]}),s.jsxs("div",{className:"af-set-skillhub-pane",children:[s.jsxs("div",{className:"af-set-skillhub-pane-head",children:[s.jsx("h3",{children:"搜索结果"}),s.jsx("span",{children:d.length})]}),s.jsx("div",{className:"af-set-skillhub-list",children:d.length===0?s.jsx("div",{className:"af-set-skillhub-empty",children:"输入关键词后搜索 SkillHub"}):d.map(D=>{const L=D.slug||D.name,$=D.kind==="collection"||D.collection,V=!$&&i.some(W=>W.name===L||W.name===D.name);return s.jsxs("div",{className:"af-set-skillhub-item",children:[s.jsxs("div",{children:[s.jsx("div",{className:"af-set-skillhub-title",children:D.name||L}),s.jsxs("div",{className:"af-set-skillhub-meta",children:[$?`collection:${D.collection}`:L,D.skillId?` · id:${D.skillId}`:"",D.version?` · ${D.version}`:""]}),D.summary?s.jsx("p",{className:"af-set-skillhub-summary",children:D.summary}):null]}),s.jsx("button",{type:"button",className:V?"af-set-btn-mini":"af-set-btn-add af-set-btn-add--compact",onClick:()=>T(D,V),disabled:!t||!!b,children:V?"更新":$?"安装合集":"安装"})]},D.id||L)})})]})]})]})}function Xa(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 Tz(e){return{version:1,collections:Xa({collections:e})}}function Rz(e){const t=String(e||"").trim(),n=t.indexOf(":");return n>=0?t.slice(n+1).trim():t}function mP(e){const t=new Map,n=new Map;for(const r of Array.isArray(e)?e:[])r!=null&&r.key&&t.set(r.key,r.key),r!=null&&r.name&&(r!=null&&r.key)&&!n.has(r.name)&&n.set(r.name,r.key);return r=>{const i=String(r||"").trim();return i&&(t.get(i)||n.get(Rz(i)))||""}}function pa(e,t){const n=mP(t);return Array.from(new Set((Array.isArray(e==null?void 0:e.skillKeys)?e.skillKeys:[]).map(r=>n(r)).filter(Boolean)))}function Mz(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 $z(e,t){const n=new Set(Array.isArray(t)?t:[]);return(Array.isArray(e)?e:[]).filter(r=>!n.has(r))}function Lz(e,t,n){const r=pa(e,n);if(r.length===0)return"empty";const i=r.filter(o=>t.has(o)).length;return i===0?"none":i===r.length?"all":"partial"}function Oz(e,t,n){const r=String(e).trim().toLowerCase(),i=Xa({collections:n}).find(o=>o.id===r||o.name.toLowerCase()===r);return pa(i,t)}function Dz(e,t,n,r){const i=(Array.isArray(n)?n:[]).map(u=>u.key).filter(Boolean),o=String(t).trim().toLowerCase(),a=Xa({collections:r}),l=Oz(t,n,r),c=l.length>0?l:i;if(!e)return c;try{const u=localStorage.getItem(e);if(u!==null){const f=JSON.parse(u);if(Array.isArray(f)){const p=mP(n),d=Array.from(new Set(f.map(p).filter(Boolean)));if(i.length>0&&d.length===i.length)return c;const m=new Set(d),y=new Set(l),v=l.length>0&&l.every(g=>m.has(g)),b=a.some(g=>{if(!g.builtin||g.id===o||g.name.toLowerCase()===o)return!1;const k=pa(g,n);return k.length>0&&k.every(x=>m.has(x))});return l.length>0&&b&&!v?c:d}}}catch{}return c}function ql(e){return e==="builtin"?"af-proj-badge af-proj-badge--builtin":e==="secondary"?"af-proj-badge af-proj-badge--secondary":e==="primary"?"af-proj-badge af-proj-badge--primary":e==="muted"?"af-proj-badge af-proj-badge--muted":"af-proj-badge"}function Fz(e){const t=e??"user";return t==="builtin"||t==="admin"?"af-project-card af-project-card--builtin":"af-project-card"}function zz(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 sb(e,t){return e==="builtin"?{label:t("project:sourceBadge.builtin"),tone:"builtin"}:e==="admin"?{label:t("project:sourceBadge.builtin"),tone:"builtin"}:e==="workspace"?{label:t("project:sourceBadge.workspace"),tone:"secondary"}:{label:t("project:sourceBadge.user"),tone:"primary"}}function gP(e){var n;if((n=e.collaboration)!=null&&n.role&&e.collaboration.role!=="owner")return`共享 Project / ${e.collaboration.ownerUsername||e.collaboration.ownerId} / ${e.id}`;const t=e.source??"user";return t==="builtin"?`builtin/pipelines / ${e.id}`:t==="admin"?`admin builtin / ${e.ownerUserId||"-"} / ${e.id}`:t==="workspace"?e.archived?`.workspace/agentflow/pipelines/_archived / ${e.id}`:`.workspace/agentflow/pipelines / ${e.id}`:e.archived?`~/agentflow/pipelines/_archived / ${e.id}`:`~/agentflow/pipelines / ${e.id}`}const Bz="project:defaultCardDesc";function yP(e,t){const n=e.description!=null?String(e.description).trim():"";return n!==""?n:t(Bz)}function Wz(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Qn({children:e,className:t="",query:n}){const r=n.trim(),i=String(e);if(!r)return s.jsx("span",{className:t,children:i});const o=new RegExp(`(${Wz(r)})`,"gi"),a=i.split(o);return s.jsx("span",{className:t,children:a.map((l,c)=>c%2===1?s.jsx("mark",{className:"af-search-hit",children:l},c):s.jsx("span",{children:l},c))})}function Hz(e,t,n){const r=[String(e.id),yP(e,n),gP(e),sb(e.source,n).label];return e.archived&&r.push(n("project:archived")),r.join(`
|
|
41
|
+
`).toLowerCase()}function Vz(e,t,n){return t?Hz(e,t,n).includes(t):!0}function Kz(e,t){const n=e.trim().toLowerCase();if(!n)return!0;const r=String(t.flowId).toLowerCase(),i=String(t.flowSource??"user").toLowerCase();return r.includes(n)||i.includes(n)}function cw(e,t){const n=e.trim().toLowerCase();return n?t.filter(Boolean).join(`
|
|
42
|
+
`).toLowerCase().includes(n):!0}function ON(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 DN(e){return e!=null&&e.packageDir?e.packageDir:`marketplace/flow-snippets / ${(e==null?void 0:e.id)||""}`}const qz=["all","agent","control","provide","marketplace"],Uz=["all","agent","control","provide"],wP="agentflow.projects.activityPanelOpen",ib="agentflow.projects.activitySelected",xP="agentflow.projects.scopeView";function Gz(){if(typeof localStorage>"u")return"personal";try{return localStorage.getItem(xP)==="team"?"team":"personal"}catch{return"personal"}}function Yz(){if(typeof localStorage>"u")return!0;const e=localStorage.getItem(wP);return e!=="0"}function FN(e){return`${(e==null?void 0:e.flowSource)||"user"}:${(e==null?void 0:e.flowId)||""}`}function Jz(){return typeof localStorage>"u"?"":localStorage.getItem(ib)||""}function Kp(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 Xz(e,t){if((e==null?void 0:e.source)!=="marketplace")return!1;const n=String((e==null?void 0:e.ownerUserId)||(e==null?void 0:e.createdBy)||"").trim();return n?new Set([String((t==null?void 0:t.userId)||"").trim(),String((t==null?void 0:t.username)||"").trim()].filter(Boolean)).has(n):!0}function Oo(e){return`${(e==null?void 0:e.id)||""}:${(e==null?void 0:e.version)||""}:${(e==null?void 0:e.packageDir)||""}`}function bP(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,i])=>({...i&&typeof i=="object"?i:{},instanceId:(i==null?void 0:i.instanceId)||r})):[]}function kP(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 ob(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 zN(e,t){return String((e==null?void 0:e.label)||(e==null?void 0:e.displayName)||(e==null?void 0:e.name)||ob(e,t))}function Qz(e){return String((e==null?void 0:e.definitionId)||(e==null?void 0:e.type)||(e==null?void 0:e.runtimeType)||"").replace(/^marketplace:/,"")}function BN(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 Zz(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 uw(e,t=16){const n=String(e||"").trim();return n.length<=t?n:`${n.slice(0,t-1)}…`}function e3(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 t3(e,t){const n=e.map(f=>f.id),r=new Set(n),i=new Map(n.map(f=>[f,0])),o=new Map(n.map(f=>[f,[]]));t.forEach(f=>{var p;!r.has(f.sourceId)||!r.has(f.targetId)||(i.set(f.targetId,(i.get(f.targetId)||0)+1),(p=o.get(f.sourceId))==null||p.push(f.targetId))});const a=new Map,l=n.filter(f=>(i.get(f)||0)===0);l.length===0&&n[0]&&l.push(n[0]),l.forEach(f=>a.set(f,0));for(let f=0;f<l.length;f+=1){const p=l[f],d=(a.get(p)||0)+1;for(const m of o.get(p)||[])(!a.has(m)||d>a.get(m))&&(a.set(m,d),l.push(m))}n.forEach((f,p)=>{a.has(f)||a.set(f,p%3)});const c=new Map,u=new Map;return n.forEach(f=>{const p=a.get(f)||0,d=c.get(p)||0;c.set(p,d+1),u.set(f,{x:p*190,y:d*86})}),u}function n3(e){var v,b,g,k;const t=bP(e),n=kP(e),r=new Map(t.map((x,_)=>[ob(x,_),zN(x,_)])),i=t.map((x,_)=>({id:ob(x,_),title:zN(x,_),meta:Qz(x)})),o=n.map((x,_)=>{const j=BN(x,"source"),N=BN(x,"target");return{key:(x==null?void 0:x.id)||`${j}-${N}-${_}`,sourceId:j,targetId:N,source:r.get(j)||j||"?",target:r.get(N)||N||"?",label:Zz(x)}}),a=(b=(v=e==null?void 0:e.snippet)==null?void 0:v.ui)!=null&&b.nodePositions&&typeof e.snippet.ui.nodePositions=="object"?e.snippet.ui.nodePositions:{},l=(k=(g=e==null?void 0:e.snippet)==null?void 0:g.ui)!=null&&k.nodeSizes&&typeof e.snippet.ui.nodeSizes=="object"?e.snippet.ui.nodeSizes:{},c=t3(i,o),u=i.map(x=>{const _=e3(a[x.id])||c.get(x.id)||{x:0,y:0},j=l[x.id]&&typeof l[x.id]=="object"?l[x.id]:{},N=Number(j.width),P=Number(j.height),T=Math.max(132,Math.min(210,Number.isFinite(N)?N*.62:150)),z=Math.max(48,Math.min(76,Number.isFinite(P)?P*.46:54));return{...x,x:_.x,y:_.y,width:T,height:z}}),f=new Map(u.map(x=>[x.id,x])),p=o.map(x=>{const _=f.get(x.sourceId),j=f.get(x.targetId);if(!_||!j)return null;const N=_.x+_.width,P=_.y+_.height/2,T=j.x,z=j.y+j.height/2,E=Math.max(48,Math.abs(T-N)*.45);return{...x,path:`M ${N} ${P} C ${N+E} ${P}, ${T-E} ${z}, ${T} ${z}`,labelX:(N+T)/2,labelY:(P+z)/2}}).filter(Boolean),d=u.reduce((x,_)=>({minX:Math.min(x.minX,_.x),minY:Math.min(x.minY,_.y),maxX:Math.max(x.maxX,_.x+_.width),maxY:Math.max(x.maxY,_.y+_.height)}),{minX:0,minY:0,maxX:420,maxY:220}),m=36,y=`${d.minX-m} ${d.minY-m} ${Math.max(360,d.maxX-d.minX+m*2)} ${Math.max(180,d.maxY-d.minY+m*2)}`;return{nodes:i,edges:o,diagram:{nodes:u,edges:p,viewBox:y}}}function Ul({resourceKind:e="",authUser:t=null}){var Dt,sn,_n,Xn,_s,Cs;const{t:n}=zr(),{navigate:r,path:i}=us(),o=!!(t!=null&&t.isAdmin),[a,l]=h.useState(e||"all"),[c,u]=h.useState([]),[f,p]=h.useState(Gz),[d,m]=h.useState([]),[y,v]=h.useState([]),[b,g]=h.useState([]),[k,x]=h.useState([]),[_,j]=h.useState(""),[N,P]=h.useState(!1),[T,z]=h.useState([]),[E,O]=h.useState(""),[D,L]=h.useState(""),[$,V]=h.useState(!1),[W,F]=h.useState(!1),[M,H]=h.useState(!1),[A,X]=h.useState(null),[q,B]=h.useState(!1),[ne,ce]=h.useState(""),[K,ee]=h.useState(Yz),[re,se]=h.useState(Jz),[Q,le]=h.useState("all"),[fe,me]=h.useState(""),[De,Ce]=h.useState("overview"),[Se,Ue]=h.useState({}),[lt,xt]=h.useState(""),[at,ze]=h.useState({}),[Xe,Bt]=h.useState(""),[Mt,Qt]=h.useState(""),[de,ke]=h.useState({}),[qe,st]=h.useState(""),[Ee,rt]=h.useState(""),[un,Kt]=h.useState(""),[yt,pn]=h.useState(""),[ie,Ne]=h.useState(""),[Ye,He]=h.useState(!1),[It,jt]=h.useState(""),[cr,$n]=h.useState({hiddenBuiltins:[],promoted:[]}),ur=h.useRef(0),rn=h.useRef(0),gn=h.useRef(0),Yn=h.useCallback(async()=>{var we,$e;const G=++rn.current;O("");try{const Ie=await fetch(`/api/flows?view=${encodeURIComponent(f)}`);if(G!==rn.current)return;if(!Ie.ok)throw new Error("HTTP "+Ie.status);const nt=await Ie.json();if(G!==rn.current)return;u(Array.isArray(nt)?nt:[])}catch(Ie){if(G!==rn.current)return;u([]),O(String(Ie.message||Ie))}try{const Ie=await fetch("/api/pipeline-recent-runs");if(G!==rn.current)return;if(Ie.ok){const nt=await Ie.json();if(G!==rn.current)return;z(Array.isArray(nt.runs)?nt.runs:[])}else z([])}catch{if(G!==rn.current)return;z([])}if(t!=null&&t.isAdmin)try{const Ie=await fetch("/api/admin/builtin-flows");if(G!==rn.current)return;const nt=await Ie.json().catch(()=>({}));Ie.ok&&$n({hiddenBuiltins:Array.isArray((we=nt==null?void 0:nt.config)==null?void 0:we.hiddenBuiltins)?nt.config.hiddenBuiltins:[],promoted:Array.isArray(($e=nt==null?void 0:nt.config)==null?void 0:$e.promoted)?nt.config.promoted:[]})}catch{if(G!==rn.current)return;$n({hiddenBuiltins:[],promoted:[]})}else $n({hiddenBuiltins:[],promoted:[]});V(!0)},[t==null?void 0:t.isAdmin,f]),gr=h.useCallback(async(G,we)=>{if(!(t!=null&&t.isAdmin)||!(G!=null&&G.id))return;const $e=`${we}:${G.source}:${G.id}`;jt($e),O("");try{const Ie=await fetch("/api/admin/builtin-flows",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:we,flowId:G.id,ownerUserId:G.ownerUserId||t.userId})}),nt=await Ie.json().catch(()=>({}));if(!Ie.ok)throw new Error(nt.error||"更新内置配置失败");await Yn()}catch(Ie){O(String(Ie.message||Ie))}finally{jt("")}},[t==null?void 0:t.isAdmin,t==null?void 0:t.userId,Yn]),yn=h.useCallback(async()=>{const G=++gn.current;L(""),F(!1);const we="/api/nodes",$e=e==="my-flows"?"/api/marketplace/flow-snippets?scope=owned":"/api/marketplace/flow-snippets";m([]),g([]),me("");try{const[Ie,nt,Tn,Wt]=await Promise.all([fetch(we),fetch("/api/skills"),fetch("/api/skill-collections"),fetch($e)]),Ln=await Ie.json().catch(()=>({})),wr=await nt.json().catch(()=>({})),Cr=await Tn.json().catch(()=>({})),on=await Wt.json().catch(()=>({}));if(!Ie.ok)throw new Error(Ln.error||"Nodes HTTP "+Ie.status);if(!nt.ok)throw new Error(wr.error||"Skills HTTP "+nt.status);if(!Tn.ok)throw new Error(Cr.error||"Collections HTTP "+Tn.status);if(!Wt.ok)throw new Error(on.error||"Flow snippets HTTP "+Wt.status);if(G!==gn.current)return;m(Array.isArray(Ln.nodes)?Ln.nodes:Array.isArray(Ln)?Ln:[]),v(Array.isArray(wr.skills)?wr.skills:[]),x(Xa(Cr)),g(Array.isArray(on.snippets)?on.snippets:[])}catch(Ie){if(G!==gn.current)return;m([]),v([]),g([]),x([]),L(String(Ie.message||Ie))}finally{if(G!==gn.current)return;F(!0)}},[e]);h.useEffect(()=>{V(!1),Yn(),yn()},[Yn,yn]),h.useEffect(()=>{try{localStorage.setItem(wP,K?"1":"0")}catch{}},[K]),h.useEffect(()=>{try{localStorage.setItem(xP,f)}catch{}},[f]),h.useEffect(()=>{try{re?localStorage.setItem(ib,re):localStorage.removeItem(ib)}catch{}},[re]),h.useEffect(()=>{let G=!1;return fetch("/api/ui-context").then(we=>we.json()).then(we=>{G||He(!!we.hideCommunityLinks)}).catch(()=>{}),()=>{G=!0}},[]);const Pn=h.useCallback(async G=>{if(!o)return;const we=Xa({collections:G});P(!0),L("");try{const $e=await fetch("/api/skill-collections",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Tz(we))}),Ie=await $e.json().catch(()=>({}));if(!$e.ok)throw new Error(Ie.error||"Collections HTTP "+$e.status);x(Xa(Ie))}catch($e){L(String($e.message||$e))}finally{P(!1)}},[o]),nr=h.useCallback(()=>{if(!o)return;const G=_.trim();if(!G)return;const we=G.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,48)||"collection",$e=new Set(k.map(Wt=>Wt.id));let Ie=we,nt=2;for(;$e.has(Ie);)Ie=`${we}-${nt++}`;const Tn=Date.now();Pn([...k,{id:Ie,name:G,skillKeys:[],createdAt:Tn,updatedAt:Tn}]),j(""),le(`collection:${Ie}`)},[o,_,Pn,k]),Wr=h.useCallback(G=>{if(!o)return;const we=k.find(Ie=>Ie.id===G);if(we!=null&&we.builtin)return;const $e=k.filter(Ie=>Ie.id!==G);Q===`collection:${G}`&&le("all"),Pn($e)},[o,Q,Pn,k]),Sn=h.useCallback((G,we,$e)=>{if(!o)return;const Ie=String(we||"").trim();if(!Ie)return;const nt=Date.now(),Tn=k.map(Wt=>{if(Wt.id!==G)return Wt;const Ln=new Set(Wt.skillKeys||[]);return $e?Ln.add(Ie):Ln.delete(Ie),{...Wt,skillKeys:Array.from(Ln),updatedAt:nt}});Pn(Tn)},[o,Pn,k]),Jn=h.useCallback(async G=>{const we=G==null?void 0:G.packageId,$e=G==null?void 0:G.version;if(!we||!$e||!window.confirm(n("project:deleteMyNodeConfirm",{id:we,version:$e})))return;const Ie=Zn(G);rt(Ie),Kt(""),L("");try{const nt=new URLSearchParams({id:we,version:$e}),Tn=await fetch(`/api/marketplace/node?${nt.toString()}`,{method:"DELETE"}),Wt=await Tn.json().catch(()=>({}));if(!Tn.ok||(Wt==null?void 0:Wt.ok)===!1){const Ln=Array.isArray(Wt==null?void 0:Wt.usage)&&Wt.usage.length>0?` ${n("project:deleteMyNodeUsedBy",{count:Wt.usage.length})}`:"";throw new Error(((Wt==null?void 0:Wt.error)||"Delete failed")+Ln)}Kt(n("project:deleteMyNodeSuccess",{id:we,version:$e})),ze(Ln=>{const wr={...Ln};return delete wr[Ie],wr}),ke(Ln=>{const wr={};for(const[Cr,on]of Object.entries(Ln))Cr.startsWith(`${Ie}:`)||(wr[Cr]=on);return wr}),me(""),await yn()}catch(nt){Kt(String(nt.message||nt))}finally{rt("")}},[yn,n]),Hr=h.useCallback(async G=>{const we=G==null?void 0:G.id,$e=(G==null?void 0:G.version)||"1.0.0";if(!we||!$e||!window.confirm(n("project:deleteMyFlowConfirm",{id:we,version:$e})))return;const Ie=Oo(G);pn(Ie),Ne(""),L("");try{const nt=new URLSearchParams({id:we,version:$e}),Tn=await fetch(`/api/marketplace/flow-snippet?${nt.toString()}`,{method:"DELETE"}),Wt=await Tn.json().catch(()=>({}));if(!Tn.ok||(Wt==null?void 0:Wt.ok)===!1)throw new Error((Wt==null?void 0:Wt.error)||"Delete failed");Ne(n("project:deleteMyFlowSuccess",{id:we,version:$e})),me(""),await yn()}catch(nt){Ne(String(nt.message||nt))}finally{pn("")}},[yn,n]);h.useEffect(()=>{if(e==="nodes"||e==="my-nodes"||e==="my-flows"||e==="skills"){l(e),le("all"),me(""),Ce("overview");return}l(G=>G==="archived"?"archived":"all")},[e]),h.useEffect(()=>{if(i!=="/projects"&&i!=="/")return;const G=new URLSearchParams(window.location.search),we=G.get("tab");let $e=!1;if(we==="nodes"){r("/nodes");return}if(we==="my-nodes"){r("/my-nodes");return}if(we==="my-flows"){r("/my-flows");return}if(we==="skills"){r("/skills");return}if(we==="archived"?(l("archived"),G.delete("tab"),$e=!0):we&&(l("all"),G.delete("tab"),$e=!0),G.get("new")==="1"&&(H(!0),G.delete("new"),$e=!0),$e){const Ie=G.toString();window.history.replaceState({},"",Ie?`/projects?${Ie}`:"/projects")}},[i,r]);const Vn=h.useMemo(()=>UF(T,KF(),c),[T,c,i]),Kn=h.useMemo(()=>Vn.filter(G=>Kz(ne,G)),[Vn,ne]),dr=ne.trim().toLowerCase(),fr=h.useMemo(()=>a==="archived"?c.filter(G=>G.archived):c.filter(G=>!G.archived),[c,a]),qn=h.useMemo(()=>fr.filter(G=>Vz(G,dr,n)),[fr,dr,n]),_r=h.useMemo(()=>new Set((cr.promoted||[]).map(G=>String((G==null?void 0:G.id)||"").trim()).filter(Boolean)),[cr.promoted]),yr=h.useMemo(()=>(cr.hiddenBuiltins||[]).map(G=>String(G||"").trim()).filter(Boolean),[cr.hiddenBuiltins]),kt=a==="nodes"||a==="my-nodes",ct=a==="my-nodes",Zt=a==="my-flows",Nt=h.useMemo(()=>d.filter(G=>ct&&!Xz(G,t)?!1:(Q==="all"||(Q==="marketplace"?G.source==="marketplace":G.type===Q))&&cw(ne,[G.id,G.label,G.displayName,G.description,G.type,G.source,G.packageId,G.version])),[t,d,ct,ne,Q]),jn=h.useMemo(()=>{const G=new Map;for(const we of k)G.set(we.id,new Set(pa(we,y)));return G},[y,k]),ue=h.useMemo(()=>[{id:"all",label:"全部"},...k.map(G=>{var we;return{id:`collection:${G.id}`,label:G.name,count:((we=jn.get(G.id))==null?void 0:we.size)||0,collection:G}}),{id:"ungrouped",label:"未分组"}],[jn,k]),te=h.useMemo(()=>y.filter(G=>{var Ie;const we=Zn(G);let $e=Q==="all";if(Q.startsWith("collection:")){const nt=Q.slice(11);$e=!!((Ie=jn.get(nt))!=null&&Ie.has(we))}else Q==="ungrouped"&&($e=!Array.from(jn.values()).some(nt=>nt.has(we)));return $e&&cw(ne,[G.name,G.id,G.description,G.sourceLabel,G.source,G.path])}),[y,ne,Q,jn]),ye=h.useMemo(()=>b.filter(G=>cw(ne,[G.id,G.name,G.displayName,G.description,G.version,G.packageDir,Array.isArray(G.tags)?G.tags.join(" "):""])),[b,ne]),Me=kt||Zt||a==="skills",Ae=h.useMemo(()=>Nt.find(G=>Zn(G)===fe)||Nt[0]||null,[Nt,fe]),ut=h.useMemo(()=>te.find(G=>Zn(G)===fe)||te[0]||null,[te,fe]),Pt=h.useMemo(()=>ye.find(G=>Oo(G)===fe)||ye[0]||null,[ye,fe]),Nn=ut?Se[Zn(ut)]:null,Je=Ae?at[Zn(Ae)]:null,hn=Ae&&Mt?de[`${Zn(Ae)}:${Mt}`]:null,rr=n(kt?"project:searchNodes":Zt?"project:searchFlows":a==="skills"?"project:searchSkills":"project:searchPipelines");h.useEffect(()=>{if(a!=="skills"||!ut)return;const G=Zn(ut);if(Se[G])return;let we=!1;return xt(G),fetch(`/api/skills/detail?key=${encodeURIComponent(G)}`).then($e=>$e.json().then(Ie=>({ok:$e.ok,json:Ie}))).then(({ok:$e,json:Ie})=>{we||$e&&Ie.skill&&Ue(nt=>({...nt,[G]:Ie.skill}))}).catch(()=>{}).finally(()=>{we||xt("")}),()=>{we=!0}},[a,ut,Se]),h.useEffect(()=>{if(!kt||!Ae)return;const G=Zn(Ae);if(at[G])return;let we=!1;return Bt(G),fetch(`/api/nodes/detail?id=${encodeURIComponent(Ae.id)}`).then($e=>$e.json().then(Ie=>({ok:$e.ok,json:Ie}))).then(({ok:$e,json:Ie})=>{we||$e&&ze(nt=>({...nt,[G]:Ie}))}).catch(()=>{}).finally(()=>{we||Bt("")}),()=>{we=!0}},[kt,Ae,at]),h.useEffect(()=>{if(!kt)return;const G=Array.isArray(Je==null?void 0:Je.files)?Je.files:[];Qt(we=>{var $e;return we&&G.some(Ie=>Ie.path===we)?we:(($e=G[0])==null?void 0:$e.path)||""})},[kt,Je]),h.useEffect(()=>{if(!kt||!Ae||!Mt)return;const G=`${Zn(Ae)}:${Mt}`;if(de[G])return;let we=!1;return st(G),fetch(`/api/nodes/file?id=${encodeURIComponent(Ae.id)}&path=${encodeURIComponent(Mt)}`).then($e=>$e.json().then(Ie=>({ok:$e.ok,json:Ie}))).then(({ok:$e,json:Ie})=>{we||$e&&ke(nt=>({...nt,[G]:Ie}))}).catch(()=>{}).finally(()=>{we||st("")}),()=>{we=!0}},[kt,Ae,Mt,de]),h.useEffect(()=>{Kt("")},[fe,a]);const dn=G=>{r(Vp(G,"workspace"))},Tr=G=>{se(FN(G)),r(Vp({id:G.flowId,source:G.flowSource,archived:!!G.archived},"workspace"))},oe=h.useCallback(G=>{var we,$e;G.preventDefault(),G.stopPropagation(),($e=(we=G.dataTransfer)==null?void 0:we.types)!=null&&$e.includes("Files")&&(ur.current+=1,B(!0))},[]),ve=h.useCallback(G=>{G.preventDefault(),G.stopPropagation(),ur.current-=1,ur.current<=0&&(ur.current=0,B(!1))},[]),Re=h.useCallback(G=>{G.preventDefault(),G.stopPropagation()},[]),St=h.useCallback(G=>{var Ie,nt;G.preventDefault(),G.stopPropagation(),ur.current=0,B(!1);const we=(nt=(Ie=G.dataTransfer)==null?void 0:Ie.files)==null?void 0:nt[0];if(!we)return;const $e=we.name.toLowerCase();!$e.endsWith(".yaml")&&!$e.endsWith(".yml")&&!$e.endsWith(".zip")||X(we)},[]);return s.jsxs("div",{className:"af-projects"+(q?" af-projects--drop-target":""),onDragEnter:oe,onDragLeave:ve,onDragOver:Re,onDrop:St,children:[s.jsxs("header",{className:"af-projects-top",children:[e?s.jsx("div",{className:"af-projects-tabs af-projects-tabs--empty","aria-hidden":!0}):s.jsxs("div",{className:"af-projects-tabs",children:[s.jsx("button",{type:"button",className:a==="all"?"af-tab af-tab--active":"af-tab",onClick:()=>l("all"),children:n("project:all")}),s.jsx("button",{type:"button",className:a==="archived"?"af-tab af-tab--active":"af-tab",onClick:()=>l("archived"),children:n("project:archived")})]}),s.jsxs("div",{className:"af-projects-top-right",children:[Me?null:s.jsxs("div",{className:"af-scope-switch af-project-scope-switch","aria-label":"Project 视图",children:[s.jsx("button",{type:"button",className:f==="personal"?"is-active":"",onClick:()=>p("personal"),children:"个人"}),s.jsx("button",{type:"button",className:f==="team"?"is-active":"",onClick:()=>p("team"),children:"团队"})]}),s.jsxs("div",{className:"af-search-wrap",children:[s.jsx("span",{className:"material-symbols-outlined af-search-icon",children:"search"}),s.jsx("input",{className:"af-search"+(ne.trim()?" af-search--has-clear":""),type:"search",placeholder:rr,"aria-label":rr,autoComplete:"off",value:ne,onChange:G=>ce(G.target.value),onKeyDown:G=>{G.key==="Escape"&&(ce(""),G.currentTarget.blur())}}),ne.trim()?s.jsx("button",{type:"button",className:"af-search-clear","aria-label":"Clear search",onClick:()=>ce(""),children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),Me?s.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>yn(),children:n("project:refreshResources")}):s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"af-icon-btn"+(K?" af-icon-btn--active":""),"aria-label":n("flow:palette.toggleRecentActivity"),"aria-expanded":K,"aria-controls":"af-recent-activity-panel",onClick:()=>ee(G=>!G),children:s.jsx("span",{className:"material-symbols-outlined",children:"notifications"})}),s.jsx("button",{type:"button",className:"af-btn-primary af-create-btn",onClick:()=>H(!0),children:n("project:createNew")})]})]})]}),s.jsxs("div",{className:"af-projects-body",children:[s.jsxs("section",{className:"af-projects-main",children:[s.jsxs("header",{className:"af-projects-section-head",children:[s.jsx("h2",{className:"af-projects-h2",children:n(a==="my-nodes"?"project:myNodes":a==="my-flows"?"project:myFlows":a==="nodes"?"project:nodes":a==="skills"?"project:globalSkills":a==="archived"?"project:archivedPipelines":"project:activeProjects")}),s.jsx("p",{className:"af-projects-sub",children:dr?n("project:filterResult",{count:a==="nodes"||a==="my-nodes"?Nt.length:a==="my-flows"?ye.length:a==="skills"?te.length:qn.length}):a==="my-nodes"?n("project:myNodesHint",{count:Nt.length}):a==="my-flows"?n("project:myFlowsHint",{count:ye.length}):a==="nodes"?n("project:nodesHint",{count:d.length}):a==="skills"?n("project:skillsHint",{count:y.length}):n(a==="archived"?"project:archivedHint":"project:activeHint")}),E?s.jsx("p",{className:"af-err af-projects-api-hint",children:E}):null,D&&Me?s.jsx("p",{className:"af-err af-projects-api-hint",children:D}):null]}),Me?s.jsxs("div",{className:"af-resource-toolbar",children:[a==="skills"?s.jsx(Pz,{onChanged:yn,canManage:!!(t!=null&&t.isAdmin)}):null,s.jsxs("div",{className:"af-resource-purpose",children:[s.jsx("span",{className:"material-symbols-outlined",children:Zt?"schema":kt?ct?"deployed_code":"account_tree":"extension"}),s.jsxs("div",{children:[s.jsx("h3",{children:n(Zt?"project:myFlowsPurposeTitle":ct?"project:myNodesPurposeTitle":kt?"project:nodesPurposeTitle":"project:skillsPurposeTitle")}),s.jsx("p",{children:n(Zt?"project:myFlowsPurposeDesc":ct?"project:myNodesPurposeDesc":kt?"project:nodesPurposeDesc":"project:skillsPurposeDesc")})]})]}),Zt?null:s.jsxs(s.Fragment,{children:[kt?s.jsxs("div",{className:"af-resource-filter-row",children:[s.jsx("button",{type:"button",className:"af-resource-filter"+(ct?"":" af-resource-filter--active"),onClick:()=>{l("nodes"),le("all"),me("")},children:n("project:nodeScopeAll")}),s.jsx("button",{type:"button",className:"af-resource-filter"+(ct?" af-resource-filter--active":""),onClick:()=>{l("my-nodes"),le("all"),me("")},children:n("project:nodeScopeMine")})]}):null,s.jsx("div",{className:"af-resource-filter-row",children:(kt?(ct?Uz:qz).map(G=>({id:G,label:n(`project:resourceFilter.${G}`)})):ue).map(G=>G.collection?s.jsxs("span",{className:"af-resource-filter-chip"+(Q===G.id?" af-resource-filter-chip--active":""),children:[s.jsxs("button",{type:"button",className:"af-resource-filter af-resource-filter--embedded",onClick:()=>{le(G.id),me("")},children:[G.label,s.jsx("em",{children:G.count}),G.collection.builtin?s.jsx("strong",{children:"built-in"}):null]}),o&&!G.collection.builtin?s.jsx("button",{type:"button",className:"af-resource-filter-chip__delete",disabled:N,"aria-label":`删除 ${G.collection.name}`,onClick:()=>Wr(G.collection.id),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})}):null]},G.id):s.jsx("button",{type:"button",className:"af-resource-filter"+(Q===G.id?" af-resource-filter--active":""),onClick:()=>{le(G.id),me("")},children:G.label},G.id))})]}),a==="skills"&&o?s.jsx("div",{className:"af-skill-collections-manager",children:s.jsxs("div",{className:"af-skill-collections-create",children:[s.jsx("input",{className:"af-set-input af-set-input--sm",value:_,onChange:G=>j(G.target.value),onKeyDown:G=>{G.key==="Enter"&&nr()},placeholder:"新建 skill collection"}),s.jsxs("button",{type:"button",className:"af-set-btn-add af-set-btn-add--compact",disabled:!_.trim()||N,onClick:()=>nr(),children:[s.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新建"]})]})}):null]}):null,kt?s.jsx("div",{className:"af-resource-grid",children:Nt.length>0?Nt.map(G=>s.jsxs("button",{type:"button",className:"af-resource-card"+(Ae&&Zn(G)===Zn(Ae)?" af-resource-card--active":""),onClick:()=>me(Zn(G)),children:[s.jsxs("div",{className:"af-resource-card-head",children:[s.jsx("span",{className:ql(G.type==="control"?"secondary":G.type==="provide"?"primary":"muted"),children:s.jsx(Qn,{query:ne,children:G.type||"node"})}),s.jsx("span",{className:"af-resource-source",children:s.jsx(Qn,{query:ne,children:ON(G.source,n)})})]}),s.jsx("h3",{className:"af-project-title",children:s.jsx(Qn,{query:ne,children:G.label||G.displayName||G.id})}),s.jsx("p",{className:"af-project-desc",children:s.jsx(Qn,{query:ne,children:G.description||n("project:noDescription")})}),s.jsxs("div",{className:"af-resource-meta-row",children:[s.jsx("span",{children:s.jsx(Qn,{query:ne,children:G.id})}),s.jsx("span",{children:n("project:nodeSlots",{inputs:Object.keys(G.inputs||{}).length,outputs:Object.keys(G.outputs||{}).length})})]}),G.packageId?s.jsxs("div",{className:"af-project-path",children:[s.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"deployed_code"}),s.jsx("span",{className:"af-path-text",children:s.jsx(Qn,{query:ne,children:`${G.packageId}${G.version?` / ${G.version}`:""}`})})]}):null]},`${G.id}:${G.source||""}:${G.packageId||""}`)):W?s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:dr?n("project:noNodeMatch",{query:ne.trim()}):n(ct?"project:noMyNodes":"project:noNodes")})}):s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):Zt?s.jsx("div",{className:"af-resource-grid",children:ye.length>0?ye.map(G=>{const we=bP(G),$e=kP(G),Ie=Number.isFinite(Number(G.nodeCount))?Number(G.nodeCount):we.length,nt=Number.isFinite(Number(G.edgeCount))?Number(G.edgeCount):$e.length;return s.jsxs("button",{type:"button",className:"af-resource-card"+(Pt&&Oo(G)===Oo(Pt)?" af-resource-card--active":""),onClick:()=>me(Oo(G)),children:[s.jsxs("div",{className:"af-resource-card-head",children:[s.jsx("span",{className:ql("primary"),children:s.jsx(Qn,{query:ne,children:G.version?`v${G.version}`:"flow"})}),s.jsx("span",{className:"af-resource-source",children:n("project:flowSnippet")})]}),s.jsx("h3",{className:"af-project-title",children:s.jsx(Qn,{query:ne,children:G.displayName||G.name||G.id})}),s.jsx("p",{className:"af-project-desc",children:s.jsx(Qn,{query:ne,children:G.description||n("project:noDescription")})}),s.jsxs("div",{className:"af-resource-meta-row",children:[s.jsx("span",{children:n("project:flowSnippetNodes",{nodes:Ie,edges:nt})}),s.jsx("span",{children:s.jsx(Qn,{query:ne,children:G.id})})]}),s.jsxs("div",{className:"af-project-path",children:[s.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"schema"}),s.jsx("span",{className:"af-path-text",children:s.jsx(Qn,{query:ne,children:DN(G)})})]})]},Oo(G))}):W?s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:dr?n("project:noFlowSnippetMatch",{query:ne.trim()}):n("project:noMyFlows")})}):s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):a==="skills"?s.jsx("div",{className:"af-resource-grid",children:te.length>0?te.map(G=>{const we=Zn(G),$e=k.filter(Ie=>{var nt;return(nt=jn.get(Ie.id))==null?void 0:nt.has(we)});return s.jsxs("button",{type:"button",className:"af-resource-card"+(ut&&we===Zn(ut)?" af-resource-card--active":""),onClick:()=>me(we),children:[s.jsxs("div",{className:"af-resource-card-head",children:[s.jsx("span",{className:ql(G.source==="builtin"?"muted":"primary"),children:s.jsx(Qn,{query:ne,children:G.sourceLabel||G.source||"skill"})}),s.jsx("span",{className:"af-resource-source",children:n("project:skill")})]}),s.jsx("h3",{className:"af-project-title",children:s.jsx(Qn,{query:ne,children:G.name||G.id})}),s.jsx("p",{className:"af-project-desc",children:s.jsx(Qn,{query:ne,children:G.description||n("project:noDescription")})}),s.jsxs("div",{className:"af-project-path",children:[s.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"extension"}),s.jsx("span",{className:"af-path-text",children:s.jsx(Qn,{query:ne,children:G.path||G.key||""})})]}),s.jsxs("div",{className:"af-skill-card-collections",children:[$e.slice(0,3).map(Ie=>s.jsx("span",{children:Ie.name},Ie.id)),$e.length===0?s.jsx("span",{className:"af-skill-card-collection-empty",children:"未分组"}):null]})]},G.key||`${G.source}:${G.name}`)}):W?s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:dr?n("project:noSkillMatch",{query:ne.trim()}):n("project:noSkills")})}):s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:n("project:loadingResources")})})}):s.jsxs(s.Fragment,{children:[t!=null&&t.isAdmin&&a==="all"&&yr.length>0?s.jsxs("div",{className:"af-project-admin-panel",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"已隐藏内置"}),s.jsx("span",{children:"这些包内置流水线不会出现在普通项目列表中。"})]}),s.jsx("div",{className:"af-project-admin-hidden-list",children:yr.map(G=>{const we=It===`show-builtin:builtin:${G}`;return s.jsxs("button",{type:"button",disabled:we,onClick:()=>gr({id:G,source:"builtin"},"show-builtin"),children:[s.jsx("span",{children:G}),s.jsx("em",{children:we?"恢复中":"恢复"})]},G)})})]}):null,s.jsxs("div",{className:"af-project-grid",children:[qn.length>0?qn.map(G=>{var Tn,Wt,Ln,wr,Cr;const we=(t==null?void 0:t.isAdmin)&&G.source==="user"&&!G.archived&&!_r.has(G.id),$e=(t==null?void 0:t.isAdmin)&&G.source==="admin",Ie=(t==null?void 0:t.isAdmin)&&G.source==="builtin",nt=It.endsWith(`:${G.source}:${G.id}`);return s.jsx("div",{className:Fz(G.source),role:"button",tabIndex:0,onClick:()=>dn(G),onKeyDown:on=>{(on.key==="Enter"||on.key===" ")&&(on.preventDefault(),dn(G))},children:s.jsxs("div",{className:"af-project-card-body",children:[s.jsx("span",{className:ql(sb(G.source,n).tone),children:s.jsx(Qn,{query:ne,children:sb(G.source,n).label})}),(Tn=G.collaboration)!=null&&Tn.role?s.jsx("span",{className:ql(G.collaboration.role==="owner"?"primary":"muted"),children:G.collaboration.role==="owner"?(Wt=G.collaboration.teamShares)!=null&&Wt.length?"已分享团队":"我创建的":G.collaboration.accessSource==="team"?`${((wr=(Ln=G.collaboration.teamShares)==null?void 0:Ln.find(on=>on.teamId===G.collaboration.teamId))==null?void 0:wr.teamName)||"团队"}共享`:`${G.collaboration.ownerUsername||G.collaboration.ownerId} 分享`}):null,G.archived?s.jsx("span",{className:ql("muted"),children:s.jsx(Qn,{query:ne,children:n("project:archived")})}):null,s.jsx("h3",{className:"af-project-title",children:s.jsx(Qn,{query:ne,children:G.id})}),s.jsx("p",{className:"af-project-desc",children:s.jsx(Qn,{query:ne,children:yP(G,n)})}),s.jsxs("div",{className:"af-project-path",children:[s.jsx("span",{className:"material-symbols-outlined af-path-icon",children:"database"}),s.jsx("span",{className:"af-path-text",children:s.jsx(Qn,{query:ne,children:gP(G)})})]}),t!=null&&t.isAdmin?s.jsxs("div",{className:"af-project-admin-actions",onClick:on=>on.stopPropagation(),onKeyDown:on=>on.stopPropagation(),children:[we?s.jsx("button",{type:"button",disabled:nt,onClick:()=>gr(G,"promote"),children:"设为内置"}):null,$e?s.jsx("button",{type:"button",disabled:nt,onClick:()=>gr(G,"unpromote"),children:"取消内置"}):null,Ie?s.jsx("button",{type:"button",disabled:nt,onClick:()=>gr(G,"hide-builtin"),children:"隐藏内置"}):null]}):null]})},`${G.id}:${G.source??"user"}:${G.archived?"a":""}:${((Cr=G.collaboration)==null?void 0:Cr.id)||"own"}`)}):$?fr.length===0?s.jsxs("div",{className:"af-projects-empty-block",children:[s.jsx("p",{className:"af-projects-empty",children:a==="archived"?n("project:noArchived"):c.length>0?n("project:noActive"):n(E?"project:loadFailed":"project:noPipelines")}),!E&&c.length===0&&a==="all"?s.jsx("p",{className:"af-projects-empty-hint",children:n("project:emptyHint",{code1:"agentflow ui",code2:".agentflow/pipelines"})}):null]}):s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:n("project:noMatch",{query:ne.trim()})})}):s.jsx("div",{className:"af-projects-empty-block",children:s.jsx("p",{className:"af-projects-empty",children:n("project:loadingPipelines")})}),s.jsxs("button",{type:"button",className:"af-project-add",onClick:()=>H(!0),children:[s.jsx("span",{className:"material-symbols-outlined af-project-add-icon",children:"add_circle"}),s.jsx("span",{className:"af-project-add-label",children:n("project:newPipeline")})]}),Ye?null:s.jsxs("a",{className:"af-hub-card",href:"https://agentflow-hub.com",target:"_blank",rel:"noopener noreferrer",children:[s.jsx("div",{className:"af-hub-card__glow","aria-hidden":!0}),s.jsxs("span",{className:"af-hub-card__eyebrow",children:[s.jsx("span",{className:"material-symbols-outlined af-hub-card__eyebrow-icon",children:"hub"}),n("project:hubCard.eyebrow")]}),s.jsx("h3",{className:"af-hub-card__title",children:n("project:hubCard.title")}),s.jsx("p",{className:"af-hub-card__desc",children:n("project:hubCard.desc")}),s.jsxs("span",{className:"af-hub-card__cta",children:[n("project:hubCard.cta"),s.jsx("span",{className:"material-symbols-outlined af-hub-card__cta-icon",children:"arrow_outward"})]}),s.jsx("code",{className:"af-hub-card__cli",children:n("project:hubCard.cliHint")})]})]})]})]}),Me?s.jsx("aside",{className:"af-resource-detail","aria-label":n(kt?"project:nodeDetail":Zt?"project:flowDetail":"project:skillDetail"),children:kt&&Ae?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"af-resource-detail-head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),s.jsxs("div",{children:[s.jsx("h3",{children:Ae.label||Ae.displayName||Ae.id}),s.jsx("p",{children:Ae.id})]})]}),s.jsx("div",{className:"af-resource-detail-tabs",children:["overview","schema","runtime","files","usage"].map(G=>s.jsx("button",{type:"button",className:"af-resource-detail-tab"+(De===G?" af-resource-detail-tab--active":""),onClick:()=>Ce(G),children:n(`project:nodeDetailTabs.${G}`)},G))}),Xe===Zn(Ae)?s.jsx("p",{className:"af-resource-detail-desc",children:n("project:loadingResources")}):De==="overview"?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"af-resource-detail-desc",children:Ae.description||((Dt=Je==null?void 0:Je.node)==null?void 0:Dt.description)||n("project:noDescription")}),s.jsxs("dl",{className:"af-resource-detail-kv",children:[s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailType")}),s.jsx("dd",{children:Ae.type||((sn=Je==null?void 0:Je.node)==null?void 0:sn.type)||"node"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailSource")}),s.jsx("dd",{children:ON(Ae.source,n)})]}),Ae.packageId?s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailPackage")}),s.jsx("dd",{children:Ae.packageId})]}):null,Ae.version?s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailVersion")}),s.jsx("dd",{children:Ae.version})]}):null,Ae.packageDir||Je!=null&&Je.baseDir?s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailPath")}),s.jsx("dd",{children:Ae.packageDir||(Je==null?void 0:Je.baseDir)})]}):null,s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailEditable")}),s.jsx("dd",{children:(Je==null?void 0:Je.readOnly)===!1?n("project:editable"):n("project:readOnly")})]})]}),ct&&Ae.source==="marketplace"?s.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[s.jsx("h4",{children:n("project:myNodeManagement")}),s.jsx("p",{children:n("project:deleteMyNodeHint")}),s.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:Ee===Zn(Ae),onClick:()=>Jn(Ae),children:[s.jsx("span",{className:"material-symbols-outlined",children:"delete"}),Ee===Zn(Ae)?n("project:deletingMyNode"):n("project:deleteMyNode")]}),un?s.jsx("p",{className:"af-resource-action-message",children:un}):null]}):null,s.jsxs("div",{className:"af-resource-detail-section",children:[s.jsx("h4",{children:n("project:resourceMeaning")}),s.jsx("p",{children:n("project:nodesMeaning")})]})]}):De==="schema"?s.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[s.jsx("h4",{children:n("project:nodeSchema")}),s.jsxs("div",{className:"af-resource-slot-group",children:[s.jsx("span",{children:n("project:nodeInputs")}),Kp(((_n=Je==null?void 0:Je.node)==null?void 0:_n.inputs)||Ae.inputs).length>0?Kp(((Xn=Je==null?void 0:Je.node)==null?void 0:Xn.inputs)||Ae.inputs).map(G=>s.jsxs("code",{children:[G.name||G.key,G.type?`: ${G.type}`:""]},G.key)):s.jsx("em",{children:n("project:noSlots")})]}),s.jsxs("div",{className:"af-resource-slot-group",children:[s.jsx("span",{children:n("project:nodeOutputs")}),Kp(((_s=Je==null?void 0:Je.node)==null?void 0:_s.outputs)||Ae.outputs).length>0?Kp(((Cs=Je==null?void 0:Je.node)==null?void 0:Cs.outputs)||Ae.outputs).map(G=>s.jsxs("code",{children:[G.name||G.key,G.type?`: ${G.type}`:""]},G.key)):s.jsx("em",{children:n("project:noSlots")})]})]}):De==="runtime"?s.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[s.jsx("h4",{children:n("project:nodeRuntime")}),Je!=null&&Je.runtime?s.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(Je.runtime,null,2)}):s.jsx("p",{children:n("project:noRuntimeManifest")}),Je!=null&&Je.body?s.jsxs(s.Fragment,{children:[s.jsx("h4",{className:"af-resource-detail-subtitle",children:n("project:nodeBody")}),s.jsx("pre",{className:"af-resource-skill-preview",children:Je.body})]}):s.jsx("p",{children:n("project:noNodeBody")})]}):De==="files"?s.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[s.jsx("h4",{children:n("project:nodeFiles")}),Array.isArray(Je==null?void 0:Je.files)&&Je.files.length>0?s.jsxs("div",{className:"af-node-file-browser",children:[s.jsx("div",{className:"af-node-file-list",children:Je.files.map(G=>s.jsxs("button",{type:"button",className:"af-node-file-item"+(Mt===G.path?" af-node-file-item--active":""),onClick:()=>Qt(G.path),children:[s.jsx("span",{className:"material-symbols-outlined",children:"description"}),s.jsx("span",{children:G.path})]},G.path))}),s.jsxs("pre",{className:"af-resource-skill-preview",children:[qe===`${Zn(Ae)}:${Mt}`?n("project:loadingResources"):hn!=null&&hn.binary?n("project:binaryFile"):(hn==null?void 0:hn.content)||n("project:selectNodeFile"),hn!=null&&hn.truncated?`
|
|
43
|
+
|
|
44
|
+
${n("project:fileTruncated")}`:""]})]}):s.jsx("p",{children:n("project:noNodeFiles")})]}):s.jsxs("div",{className:"af-resource-detail-section af-resource-detail-section--plain",children:[s.jsx("h4",{children:n("project:nodeUsage")}),Array.isArray(Je==null?void 0:Je.usage)&&Je.usage.length>0?s.jsx("div",{className:"af-node-usage-list",children:Je.usage.map(G=>s.jsxs("div",{className:"af-node-usage-item",children:[s.jsx("strong",{children:G.flowId}),s.jsxs("span",{children:[G.flowSource,G.archived?` · ${n("project:archived")}`:""]}),s.jsx("em",{children:G.instances.map(we=>we.label||we.instanceId).join(", ")})]},`${G.flowSource}:${G.flowId}:${G.archived?"a":""}`))}):s.jsx("p",{children:n("project:noNodeUsage")})]})]}):Zt&&Pt?(()=>{const G=n3(Pt);return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"af-resource-detail-head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"schema"}),s.jsxs("div",{children:[s.jsx("h3",{children:Pt.displayName||Pt.name||Pt.id}),s.jsx("p",{children:Pt.id})]})]}),s.jsx("p",{className:"af-resource-detail-desc",children:Pt.description||n("project:noDescription")}),s.jsxs("dl",{className:"af-resource-detail-kv",children:[s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailVersion")}),s.jsx("dd",{children:Pt.version||"1.0.0"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailPath")}),s.jsx("dd",{children:DN(Pt)})]}),s.jsxs("div",{children:[s.jsx("dt",{children:n("project:flowSnippetScale")}),s.jsx("dd",{children:n("project:flowSnippetNodes",{nodes:Number.isFinite(Number(Pt.nodeCount))?Number(Pt.nodeCount):G.nodes.length,edges:Number.isFinite(Number(Pt.edgeCount))?Number(Pt.edgeCount):G.edges.length})})]})]}),s.jsxs("div",{className:"af-resource-detail-section",children:[s.jsx("h4",{children:n("project:resourceMeaning")}),s.jsx("p",{children:n("project:myFlowsMeaning")})]}),s.jsxs("div",{className:"af-resource-detail-section af-resource-danger-zone",children:[s.jsx("h4",{children:n("project:myFlowManagement")}),s.jsx("p",{children:n("project:deleteMyFlowHint")}),s.jsxs("button",{type:"button",className:"af-btn-secondary af-btn-danger",disabled:yt===Oo(Pt),onClick:()=>Hr(Pt),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"}),yt===Oo(Pt)?n("project:deletingMyFlow"):n("project:deleteMyFlow")]}),ie?s.jsx("p",{className:"af-resource-action-message",children:ie}):null]}),s.jsxs("div",{className:"af-resource-detail-section",children:[s.jsx("h4",{children:n("project:flowSnippetPreview")}),G.diagram.nodes.length>0?s.jsx("div",{className:"af-flow-snippet-map",children:s.jsxs("svg",{viewBox:G.diagram.viewBox,role:"img","aria-label":n("project:flowSnippetPreview"),children:[s.jsx("defs",{children:s.jsx("marker",{id:"af-flow-snippet-arrow",markerWidth:"8",markerHeight:"8",refX:"7",refY:"4",orient:"auto",markerUnits:"strokeWidth",children:s.jsx("path",{d:"M 0 0 L 8 4 L 0 8 z"})})}),s.jsx("g",{className:"af-flow-snippet-map__edges",children:G.diagram.edges.map(we=>s.jsxs("g",{children:[s.jsx("path",{d:we.path}),we.label?s.jsx("text",{x:we.labelX,y:we.labelY-5,textAnchor:"middle",children:uw(we.label,18)}):null]},we.key))}),s.jsx("g",{className:"af-flow-snippet-map__nodes",children:G.diagram.nodes.map((we,$e)=>s.jsxs("g",{transform:`translate(${we.x} ${we.y})`,children:[s.jsx("rect",{width:we.width,height:we.height,rx:"10"}),s.jsx("circle",{cx:"19",cy:we.height/2,r:"12"}),s.jsx("text",{className:"af-flow-snippet-map__node-index",x:"19",y:we.height/2+4,textAnchor:"middle",children:$e+1}),s.jsx("text",{className:"af-flow-snippet-map__node-title",x:"40",y:we.height/2-3,children:uw(we.title)}),s.jsx("text",{className:"af-flow-snippet-map__node-meta",x:"40",y:we.height/2+16,children:uw(we.meta||we.id,20)})]},we.id))})]})}):s.jsx("p",{className:"af-resource-detail-desc",children:n("project:noFlowSnippetPreview")}),s.jsxs("details",{className:"af-flow-snippet-json",children:[s.jsx("summary",{children:n("project:flowSnippetJson")}),s.jsx("pre",{className:"af-resource-skill-preview",children:JSON.stringify(Pt.snippet||{},null,2)})]})]})]})})():a==="skills"&&ut?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"af-resource-detail-head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"extension"}),s.jsxs("div",{children:[s.jsx("h3",{children:ut.name||ut.id}),s.jsx("p",{children:ut.sourceLabel||ut.source})]})]}),s.jsx("p",{className:"af-resource-detail-desc",children:ut.description||n("project:noDescription")}),s.jsxs("dl",{className:"af-resource-detail-kv",children:[s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailSource")}),s.jsx("dd",{children:ut.sourceLabel||ut.source})]}),s.jsxs("div",{children:[s.jsx("dt",{children:n("project:detailPath")}),s.jsx("dd",{children:ut.path||ut.key})]})]}),s.jsxs("div",{className:"af-resource-detail-section",children:[s.jsx("h4",{children:"Collections"}),k.length===0?s.jsx("p",{children:"暂无 collection。可在左侧新建后再添加。"}):s.jsx("div",{className:"af-skill-detail-collections",children:k.map(G=>{const we=Zn(ut),$e=jn.get(G.id)||new Set,Ie=$e.has(we);return s.jsxs("label",{className:"af-composer-skill-option af-skill-detail-collection-option",children:[s.jsx("input",{type:"checkbox",checked:Ie,disabled:N||!o,onChange:nt=>Sn(G.id,we,nt.target.checked)}),s.jsxs("span",{className:"af-composer-skill-option-main",children:[s.jsx("span",{className:"af-composer-skill-option-title",children:G.name}),s.jsxs("span",{className:"af-composer-skill-option-desc",children:[$e.size," skills"]})]})]},G.id)})})]}),s.jsxs("div",{className:"af-resource-detail-section",children:[s.jsx("h4",{children:n("project:resourceMeaning")}),s.jsx("p",{children:n("project:skillsMeaning")})]}),s.jsxs("div",{className:"af-resource-detail-section",children:[s.jsx("h4",{children:n("project:skillPreview")}),s.jsx("pre",{className:"af-resource-skill-preview",children:lt===Zn(ut)?n("project:loadingResources"):(Nn==null?void 0:Nn.body)||(Nn==null?void 0:Nn.content)||n("project:skillPreviewEmpty")})]})]}):s.jsx("p",{className:"af-activity-empty",children:n("project:selectResource")})}):s.jsxs("aside",{id:"af-recent-activity-panel",className:"af-activity"+(K?"":" af-activity--hidden"),"aria-hidden":!K,"aria-label":n("project:recentActivity"),children:[s.jsxs("h2",{className:"af-activity-title",children:[s.jsx("span",{className:"af-activity-bullet"}),n("project:recentActivity")]}),s.jsx("div",{className:"af-activity-list",children:Kn.length===0?s.jsx("p",{className:"af-activity-empty",children:Vn.length===0?n("project:noRecentActivity"):n("project:noMatchRecent")}):Kn.map(G=>{const we=re===FN(G);return s.jsxs("button",{type:"button",className:"af-activity-row af-activity-row--action"+(we?" af-activity-row--active":""),"aria-current":we?"page":void 0,onClick:()=>Tr(G),children:[s.jsxs("div",{className:"af-activity-row-top",children:[s.jsx("h4",{className:"af-activity-name",children:s.jsx(Qn,{query:ne,children:G.flowId})}),s.jsx("span",{className:"af-activity-time",children:$N(G.at,n)})]}),s.jsxs("div",{className:"af-activity-meta",children:[s.jsx("span",{className:zz(G.kind),children:G.kind==="executed"?"play_arrow":"visibility"}),s.jsxs("p",{className:"af-activity-text",children:[G.kind==="executed"?n("project:recentRun"):n("project:recentOpen")," · ",$N(G.at,n)]})]})]},`${G.kind}-${G.flowId}-${G.flowSource}-${G.at}`)})})]})]}),s.jsx(vz,{open:M,onClose:()=>H(!1),onCreated:async G=>{H(!1),await Yn();const we=G.source??"user";r(Vp({id:G.id,source:we},"workspace"))}}),A?s.jsx(bz,{file:A,onClose:()=>X(null),onImported:async G=>{X(null),await Yn();const we=G.source??"user";r(Vp({id:G.id,source:we},"workspace"))}},`${A.name}-${A.size}-${A.lastModified}`):null]})}const r3="modulepreload",s3=function(e){return"/"+e},WN={},vP=function(t,n,r){let i=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"));i=Promise.allSettled(n.map(c=>{if(c=s3(c),c in WN)return;WN[c]=!0;const u=c.endsWith(".css"),f=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${c}"]${f}`))return;const p=document.createElement("link");if(p.rel=u?"stylesheet":r3,u||(p.as="script"),p.crossOrigin="",p.href=c,l&&p.setAttribute("nonce",l),document.head.appendChild(p),u)return new Promise((d,m)=>{p.addEventListener("load",d),p.addEventListener("error",()=>m(new Error(`Unable to preload CSS for ${c}`)))})}))}function o(a){const l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=a,window.dispatchEvent(l),!l.defaultPrevented)throw a}return i.then(a=>{for(const l of a||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})};function lr(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=lr(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var i3={value:()=>{}};function wg(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new Mh(n)}function Mh(e){this._=e}function o3(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",i=n.indexOf(".");if(i>=0&&(r=n.slice(i+1),n=n.slice(0,i)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}Mh.prototype=wg.prototype={constructor:Mh,on:function(e,t){var n=this._,r=o3(e+"",n),i,o=-1,a=r.length;if(arguments.length<2){for(;++o<a;)if((i=(e=r[o]).type)&&(i=a3(n[i],e.name)))return i;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<a;)if(i=(e=r[o]).type)n[i]=HN(n[i],e.name,t);else if(t==null)for(i in n)n[i]=HN(n[i],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Mh(e)},call:function(e,t){if((i=arguments.length-2)>0)for(var n=new Array(i),r=0,i,o;r<i;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,i=o.length;r<i;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],i=0,o=r.length;i<o;++i)r[i].value.apply(t,n)}};function a3(e,t){for(var n=0,r=e.length,i;n<r;++n)if((i=e[n]).name===t)return i.value}function HN(e,t,n){for(var r=0,i=e.length;r<i;++r)if(e[r].name===t){e[r]=i3,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var ab="http://www.w3.org/1999/xhtml";const VN={svg:"http://www.w3.org/2000/svg",xhtml:ab,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function xg(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),VN.hasOwnProperty(t)?{space:VN[t],local:e}:e}function l3(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===ab&&t.documentElement.namespaceURI===ab?t.createElement(e):t.createElementNS(n,e)}}function c3(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function SP(e){var t=xg(e);return(t.local?c3:l3)(t)}function u3(){}function rv(e){return e==null?u3:function(){return this.querySelector(e)}}function d3(e){typeof e!="function"&&(e=rv(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],a=o.length,l=r[i]=new Array(a),c,u,f=0;f<a;++f)(c=o[f])&&(u=e.call(c,c.__data__,f,o))&&("__data__"in c&&(u.__data__=c.__data__),l[f]=u);return new Ss(r,this._parents)}function f3(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function p3(){return[]}function jP(e){return e==null?p3:function(){return this.querySelectorAll(e)}}function h3(e){return function(){return f3(e.apply(this,arguments))}}function m3(e){typeof e=="function"?e=h3(e):e=jP(e);for(var t=this._groups,n=t.length,r=[],i=[],o=0;o<n;++o)for(var a=t[o],l=a.length,c,u=0;u<l;++u)(c=a[u])&&(r.push(e.call(c,c.__data__,u,a)),i.push(c));return new Ss(r,i)}function NP(e){return function(){return this.matches(e)}}function _P(e){return function(t){return t.matches(e)}}var g3=Array.prototype.find;function y3(e){return function(){return g3.call(this.children,e)}}function w3(){return this.firstElementChild}function x3(e){return this.select(e==null?w3:y3(typeof e=="function"?e:_P(e)))}var b3=Array.prototype.filter;function k3(){return Array.from(this.children)}function v3(e){return function(){return b3.call(this.children,e)}}function S3(e){return this.selectAll(e==null?k3:v3(typeof e=="function"?e:_P(e)))}function j3(e){typeof e!="function"&&(e=NP(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],a=o.length,l=r[i]=[],c,u=0;u<a;++u)(c=o[u])&&e.call(c,c.__data__,u,o)&&l.push(c);return new Ss(r,this._parents)}function CP(e){return new Array(e.length)}function N3(){return new Ss(this._enter||this._groups.map(CP),this._parents)}function wm(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}wm.prototype={constructor:wm,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 _3(e){return function(){return e}}function C3(e,t,n,r,i,o){for(var a=0,l,c=t.length,u=o.length;a<u;++a)(l=t[a])?(l.__data__=o[a],r[a]=l):n[a]=new wm(e,o[a]);for(;a<c;++a)(l=t[a])&&(i[a]=l)}function A3(e,t,n,r,i,o,a){var l,c,u=new Map,f=t.length,p=o.length,d=new Array(f),m;for(l=0;l<f;++l)(c=t[l])&&(d[l]=m=a.call(c,c.__data__,l,t)+"",u.has(m)?i[l]=c:u.set(m,c));for(l=0;l<p;++l)m=a.call(e,o[l],l,o)+"",(c=u.get(m))?(r[l]=c,c.__data__=o[l],u.delete(m)):n[l]=new wm(e,o[l]);for(l=0;l<f;++l)(c=t[l])&&u.get(d[l])===c&&(i[l]=c)}function E3(e){return e.__data__}function I3(e,t){if(!arguments.length)return Array.from(this,E3);var n=t?A3:C3,r=this._parents,i=this._groups;typeof e!="function"&&(e=_3(e));for(var o=i.length,a=new Array(o),l=new Array(o),c=new Array(o),u=0;u<o;++u){var f=r[u],p=i[u],d=p.length,m=P3(e.call(f,f&&f.__data__,u,r)),y=m.length,v=l[u]=new Array(y),b=a[u]=new Array(y),g=c[u]=new Array(d);n(f,p,v,b,g,m,t);for(var k=0,x=0,_,j;k<y;++k)if(_=v[k]){for(k>=x&&(x=k+1);!(j=b[x])&&++x<y;);_._next=j||null}}return a=new Ss(a,r),a._enter=l,a._exit=c,a}function P3(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function T3(){return new Ss(this._exit||this._groups.map(CP),this._parents)}function R3(e,t,n){var r=this.enter(),i=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(i=t(i),i&&(i=i.selection())),n==null?o.remove():n(o),r&&i?r.merge(i).order():i}function M3(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,i=n.length,o=r.length,a=Math.min(i,o),l=new Array(i),c=0;c<a;++c)for(var u=n[c],f=r[c],p=u.length,d=l[c]=new Array(p),m,y=0;y<p;++y)(m=u[y]||f[y])&&(d[y]=m);for(;c<i;++c)l[c]=n[c];return new Ss(l,this._parents)}function $3(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],i=r.length-1,o=r[i],a;--i>=0;)(a=r[i])&&(o&&a.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(a,o),o=a);return this}function L3(e){e||(e=O3);function t(p,d){return p&&d?e(p.__data__,d.__data__):!p-!d}for(var n=this._groups,r=n.length,i=new Array(r),o=0;o<r;++o){for(var a=n[o],l=a.length,c=i[o]=new Array(l),u,f=0;f<l;++f)(u=a[f])&&(c[f]=u);c.sort(t)}return new Ss(i,this._parents).order()}function O3(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function D3(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function F3(){return Array.from(this)}function z3(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length;i<o;++i){var a=r[i];if(a)return a}return null}function B3(){let e=0;for(const t of this)++e;return e}function W3(){return!this.node()}function H3(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var i=t[n],o=0,a=i.length,l;o<a;++o)(l=i[o])&&e.call(l,l.__data__,o,i);return this}function V3(e){return function(){this.removeAttribute(e)}}function K3(e){return function(){this.removeAttributeNS(e.space,e.local)}}function q3(e,t){return function(){this.setAttribute(e,t)}}function U3(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function G3(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Y3(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 J3(e,t){var n=xg(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?K3:V3:typeof t=="function"?n.local?Y3:G3:n.local?U3:q3)(n,t))}function AP(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function X3(e){return function(){this.style.removeProperty(e)}}function Q3(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Z3(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function eB(e,t,n){return arguments.length>1?this.each((t==null?X3:typeof t=="function"?Z3:Q3)(e,t,n??"")):Hc(this.node(),e)}function Hc(e,t){return e.style.getPropertyValue(t)||AP(e).getComputedStyle(e,null).getPropertyValue(t)}function tB(e){return function(){delete this[e]}}function nB(e,t){return function(){this[e]=t}}function rB(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function sB(e,t){return arguments.length>1?this.each((t==null?tB:typeof t=="function"?rB:nB)(e,t)):this.node()[e]}function EP(e){return e.trim().split(/^|\s+/)}function sv(e){return e.classList||new IP(e)}function IP(e){this._node=e,this._names=EP(e.getAttribute("class")||"")}IP.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=sv(e),r=-1,i=t.length;++r<i;)n.add(t[r])}function TP(e,t){for(var n=sv(e),r=-1,i=t.length;++r<i;)n.remove(t[r])}function iB(e){return function(){PP(this,e)}}function oB(e){return function(){TP(this,e)}}function aB(e,t){return function(){(t.apply(this,arguments)?PP:TP)(this,e)}}function lB(e,t){var n=EP(e+"");if(arguments.length<2){for(var r=sv(this.node()),i=-1,o=n.length;++i<o;)if(!r.contains(n[i]))return!1;return!0}return this.each((typeof t=="function"?aB:t?iB:oB)(n,t))}function cB(){this.textContent=""}function uB(e){return function(){this.textContent=e}}function dB(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function fB(e){return arguments.length?this.each(e==null?cB:(typeof e=="function"?dB:uB)(e)):this.node().textContent}function pB(){this.innerHTML=""}function hB(e){return function(){this.innerHTML=e}}function mB(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function gB(e){return arguments.length?this.each(e==null?pB:(typeof e=="function"?mB:hB)(e)):this.node().innerHTML}function yB(){this.nextSibling&&this.parentNode.appendChild(this)}function wB(){return this.each(yB)}function xB(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function bB(){return this.each(xB)}function kB(e){var t=typeof e=="function"?e:SP(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function vB(){return null}function SB(e,t){var n=typeof e=="function"?e:SP(e),r=t==null?vB:typeof t=="function"?t:rv(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function jB(){var e=this.parentNode;e&&e.removeChild(this)}function NB(){return this.each(jB)}function _B(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function CB(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function AB(e){return this.select(e?CB:_B)}function EB(e){return arguments.length?this.property("__data__",e):this.node().__data__}function IB(e){return function(t){e.call(this,t,this.__data__)}}function PB(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 TB(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,i=t.length,o;n<i;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function RB(e,t,n){return function(){var r=this.__on,i,o=IB(t);if(r){for(var a=0,l=r.length;a<l;++a)if((i=r[a]).type===e.type&&i.name===e.name){this.removeEventListener(i.type,i.listener,i.options),this.addEventListener(i.type,i.listener=o,i.options=n),i.value=t;return}}this.addEventListener(e.type,o,n),i={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(i):this.__on=[i]}}function MB(e,t,n){var r=PB(e+""),i,o=r.length,a;if(arguments.length<2){var l=this.node().__on;if(l){for(var c=0,u=l.length,f;c<u;++c)for(i=0,f=l[c];i<o;++i)if((a=r[i]).type===f.type&&a.name===f.name)return f.value}return}for(l=t?RB:TB,i=0;i<o;++i)this.each(l(r[i],t,n));return this}function RP(e,t,n){var r=AP(e),i=r.CustomEvent;typeof i=="function"?i=new i(t,n):(i=r.document.createEvent("Event"),n?(i.initEvent(t,n.bubbles,n.cancelable),i.detail=n.detail):i.initEvent(t,!1,!1)),e.dispatchEvent(i)}function $B(e,t){return function(){return RP(this,e,t)}}function LB(e,t){return function(){return RP(this,e,t.apply(this,arguments))}}function OB(e,t){return this.each((typeof t=="function"?LB:$B)(e,t))}function*DB(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],i=0,o=r.length,a;i<o;++i)(a=r[i])&&(yield a)}var MP=[null];function Ss(e,t){this._groups=e,this._parents=t}function Mf(){return new Ss([[document.documentElement]],MP)}function FB(){return this}Ss.prototype=Mf.prototype={constructor:Ss,select:d3,selectAll:m3,selectChild:x3,selectChildren:S3,filter:j3,data:I3,enter:N3,exit:T3,join:R3,merge:M3,selection:FB,order:$3,sort:L3,call:D3,nodes:F3,node:z3,size:B3,empty:W3,each:H3,attr:J3,style:eB,property:sB,classed:lB,text:fB,html:gB,raise:wB,lower:bB,append:kB,insert:SB,remove:NB,clone:AB,datum:EB,on:MB,dispatch:OB,[Symbol.iterator]:DB};function ys(e){return typeof e=="string"?new Ss([[document.querySelector(e)]],[document.documentElement]):new Ss([[e]],MP)}function zB(e){let t;for(;t=e.sourceEvent;)e=t;return e}function ri(e,t){if(e=zB(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 i=t.getBoundingClientRect();return[e.clientX-i.left-t.clientLeft,e.clientY-i.top-t.clientTop]}}return[e.pageX,e.pageY]}const BB={passive:!1},rf={capture:!0,passive:!1};function dw(e){e.stopImmediatePropagation()}function Ac(e){e.preventDefault(),e.stopImmediatePropagation()}function $P(e){var t=e.document.documentElement,n=ys(e).on("dragstart.drag",Ac,rf);"onselectstart"in t?n.on("selectstart.drag",Ac,rf):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function LP(e,t){var n=e.document.documentElement,r=ys(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ac,rf),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 qp=e=>()=>e;function lb(e,{sourceEvent:t,subject:n,target:r,identifier:i,active:o,x:a,y:l,dx:c,dy:u,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:i,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:a,enumerable:!0,configurable:!0},y:{value:l,enumerable:!0,configurable:!0},dx:{value:c,enumerable:!0,configurable:!0},dy:{value:u,enumerable:!0,configurable:!0},_:{value:f}})}lb.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function WB(e){return!e.ctrlKey&&!e.button}function HB(){return this.parentNode}function VB(e,t){return t??{x:e.x,y:e.y}}function KB(){return navigator.maxTouchPoints||"ontouchstart"in this}function OP(){var e=WB,t=HB,n=VB,r=KB,i={},o=wg("start","drag","end"),a=0,l,c,u,f,p=0;function d(_){_.on("mousedown.drag",m).filter(r).on("touchstart.drag",b).on("touchmove.drag",g,BB).on("touchend.drag touchcancel.drag",k).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function m(_,j){if(!(f||!e.call(this,_,j))){var N=x(this,t.call(this,_,j),_,j,"mouse");N&&(ys(_.view).on("mousemove.drag",y,rf).on("mouseup.drag",v,rf),$P(_.view),dw(_),u=!1,l=_.clientX,c=_.clientY,N("start",_))}}function y(_){if(Ac(_),!u){var j=_.clientX-l,N=_.clientY-c;u=j*j+N*N>p}i.mouse("drag",_)}function v(_){ys(_.view).on("mousemove.drag mouseup.drag",null),LP(_.view,u),Ac(_),i.mouse("end",_)}function b(_,j){if(e.call(this,_,j)){var N=_.changedTouches,P=t.call(this,_,j),T=N.length,z,E;for(z=0;z<T;++z)(E=x(this,P,_,j,N[z].identifier,N[z]))&&(dw(_),E("start",_,N[z]))}}function g(_){var j=_.changedTouches,N=j.length,P,T;for(P=0;P<N;++P)(T=i[j[P].identifier])&&(Ac(_),T("drag",_,j[P]))}function k(_){var j=_.changedTouches,N=j.length,P,T;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),P=0;P<N;++P)(T=i[j[P].identifier])&&(dw(_),T("end",_,j[P]))}function x(_,j,N,P,T,z){var E=o.copy(),O=ri(z||N,j),D,L,$;if(($=n.call(_,new lb("beforestart",{sourceEvent:N,target:d,identifier:T,active:a,x:O[0],y:O[1],dx:0,dy:0,dispatch:E}),P))!=null)return D=$.x-O[0]||0,L=$.y-O[1]||0,function V(W,F,M){var H=O,A;switch(W){case"start":i[T]=V,A=a++;break;case"end":delete i[T],--a;case"drag":O=ri(M||F,j),A=a;break}E.call(W,_,new lb(W,{sourceEvent:F,subject:$,target:d,identifier:T,active:A,x:O[0]+D,y:O[1]+L,dx:O[0]-H[0],dy:O[1]-H[1],dispatch:E}),P)}}return d.filter=function(_){return arguments.length?(e=typeof _=="function"?_:qp(!!_),d):e},d.container=function(_){return arguments.length?(t=typeof _=="function"?_:qp(_),d):t},d.subject=function(_){return arguments.length?(n=typeof _=="function"?_:qp(_),d):n},d.touchable=function(_){return arguments.length?(r=typeof _=="function"?_:qp(!!_),d):r},d.on=function(){var _=o.on.apply(o,arguments);return _===o?d:_},d.clickDistance=function(_){return arguments.length?(p=(_=+_)*_,d):Math.sqrt(p)},d}function iv(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function DP(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function $f(){}var sf=.7,xm=1/sf,Ec="\\s*([+-]?\\d+)\\s*",of="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Li="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",qB=/^#([0-9a-f]{3,8})$/,UB=new RegExp(`^rgb\\(${Ec},${Ec},${Ec}\\)$`),GB=new RegExp(`^rgb\\(${Li},${Li},${Li}\\)$`),YB=new RegExp(`^rgba\\(${Ec},${Ec},${Ec},${of}\\)$`),JB=new RegExp(`^rgba\\(${Li},${Li},${Li},${of}\\)$`),XB=new RegExp(`^hsl\\(${of},${Li},${Li}\\)$`),QB=new RegExp(`^hsla\\(${of},${Li},${Li},${of}\\)$`),KN={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};iv($f,al,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:qN,formatHex:qN,formatHex8:ZB,formatHsl:eW,formatRgb:UN,toString:UN});function qN(){return this.rgb().formatHex()}function ZB(){return this.rgb().formatHex8()}function eW(){return FP(this).formatHsl()}function UN(){return this.rgb().formatRgb()}function al(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=qB.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?GN(t):n===3?new ss(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Up(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Up(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=UB.exec(e))?new ss(t[1],t[2],t[3],1):(t=GB.exec(e))?new ss(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=YB.exec(e))?Up(t[1],t[2],t[3],t[4]):(t=JB.exec(e))?Up(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=XB.exec(e))?XN(t[1],t[2]/100,t[3]/100,1):(t=QB.exec(e))?XN(t[1],t[2]/100,t[3]/100,t[4]):KN.hasOwnProperty(e)?GN(KN[e]):e==="transparent"?new ss(NaN,NaN,NaN,0):null}function GN(e){return new ss(e>>16&255,e>>8&255,e&255,1)}function Up(e,t,n,r){return r<=0&&(e=t=n=NaN),new ss(e,t,n,r)}function tW(e){return e instanceof $f||(e=al(e)),e?(e=e.rgb(),new ss(e.r,e.g,e.b,e.opacity)):new ss}function cb(e,t,n,r){return arguments.length===1?tW(e):new ss(e,t,n,r??1)}function ss(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}iv(ss,cb,DP($f,{brighter(e){return e=e==null?xm:Math.pow(xm,e),new ss(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?sf:Math.pow(sf,e),new ss(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ss(Qa(this.r),Qa(this.g),Qa(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:YN,formatHex:YN,formatHex8:nW,formatRgb:JN,toString:JN}));function YN(){return`#${qa(this.r)}${qa(this.g)}${qa(this.b)}`}function nW(){return`#${qa(this.r)}${qa(this.g)}${qa(this.b)}${qa((isNaN(this.opacity)?1:this.opacity)*255)}`}function JN(){const e=bm(this.opacity);return`${e===1?"rgb(":"rgba("}${Qa(this.r)}, ${Qa(this.g)}, ${Qa(this.b)}${e===1?")":`, ${e})`}`}function bm(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Qa(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function qa(e){return e=Qa(e),(e<16?"0":"")+e.toString(16)}function XN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new oi(e,t,n,r)}function FP(e){if(e instanceof oi)return new oi(e.h,e.s,e.l,e.opacity);if(e instanceof $f||(e=al(e)),!e)return new oi;if(e instanceof oi)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,i=Math.min(t,n,r),o=Math.max(t,n,r),a=NaN,l=o-i,c=(o+i)/2;return l?(t===o?a=(n-r)/l+(n<r)*6:n===o?a=(r-t)/l+2:a=(t-n)/l+4,l/=c<.5?o+i:2-o-i,a*=60):l=c>0&&c<1?0:a,new oi(a,l,c,e.opacity)}function rW(e,t,n,r){return arguments.length===1?FP(e):new oi(e,t,n,r??1)}function oi(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}iv(oi,rW,DP($f,{brighter(e){return e=e==null?xm:Math.pow(xm,e),new oi(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?sf:Math.pow(sf,e),new oi(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,i=2*n-r;return new ss(fw(e>=240?e-240:e+120,i,r),fw(e,i,r),fw(e<120?e+240:e-120,i,r),this.opacity)},clamp(){return new oi(QN(this.h),Gp(this.s),Gp(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("}${QN(this.h)}, ${Gp(this.s)*100}%, ${Gp(this.l)*100}%${e===1?")":`, ${e})`}`}}));function QN(e){return e=(e||0)%360,e<0?e+360:e}function Gp(e){return Math.max(0,Math.min(1,e||0))}function fw(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 ov=e=>()=>e;function sW(e,t){return function(n){return e+n*t}}function iW(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 oW(e){return(e=+e)==1?zP:function(t,n){return n-t?iW(t,n,e):ov(isNaN(t)?n:t)}}function zP(e,t){var n=t-e;return n?sW(e,n):ov(isNaN(e)?t:e)}const km=function e(t){var n=oW(t);function r(i,o){var a=n((i=cb(i)).r,(o=cb(o)).r),l=n(i.g,o.g),c=n(i.b,o.b),u=zP(i.opacity,o.opacity);return function(f){return i.r=a(f),i.g=l(f),i.b=c(f),i.opacity=u(f),i+""}}return r.gamma=e,r}(1);function aW(e,t){t||(t=[]);var n=e?Math.min(t.length,e.length):0,r=t.slice(),i;return function(o){for(i=0;i<n;++i)r[i]=e[i]*(1-o)+t[i]*o;return r}}function lW(e){return ArrayBuffer.isView(e)&&!(e instanceof DataView)}function cW(e,t){var n=t?t.length:0,r=e?Math.min(n,e.length):0,i=new Array(r),o=new Array(n),a;for(a=0;a<r;++a)i[a]=Id(e[a],t[a]);for(;a<n;++a)o[a]=t[a];return function(l){for(a=0;a<r;++a)o[a]=i[a](l);return o}}function uW(e,t){var n=new Date;return e=+e,t=+t,function(r){return n.setTime(e*(1-r)+t*r),n}}function _i(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}function dW(e,t){var n={},r={},i;(e===null||typeof e!="object")&&(e={}),(t===null||typeof t!="object")&&(t={});for(i in t)i in e?n[i]=Id(e[i],t[i]):r[i]=t[i];return function(o){for(i in n)r[i]=n[i](o);return r}}var ub=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,pw=new RegExp(ub.source,"g");function fW(e){return function(){return e}}function pW(e){return function(t){return e(t)+""}}function BP(e,t){var n=ub.lastIndex=pw.lastIndex=0,r,i,o,a=-1,l=[],c=[];for(e=e+"",t=t+"";(r=ub.exec(e))&&(i=pw.exec(t));)(o=i.index)>n&&(o=t.slice(n,o),l[a]?l[a]+=o:l[++a]=o),(r=r[0])===(i=i[0])?l[a]?l[a]+=i:l[++a]=i:(l[++a]=null,c.push({i:a,x:_i(r,i)})),n=pw.lastIndex;return n<t.length&&(o=t.slice(n),l[a]?l[a]+=o:l[++a]=o),l.length<2?c[0]?pW(c[0].x):fW(t):(t=c.length,function(u){for(var f=0,p;f<t;++f)l[(p=c[f]).i]=p.x(u);return l.join("")})}function Id(e,t){var n=typeof t,r;return t==null||n==="boolean"?ov(t):(n==="number"?_i:n==="string"?(r=al(t))?(t=r,km):BP:t instanceof al?km:t instanceof Date?uW:lW(t)?aW:Array.isArray(t)?cW:typeof t.valueOf!="function"&&typeof t.toString!="function"||isNaN(t)?dW:_i)(e,t)}var ZN=180/Math.PI,db={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function WP(e,t,n,r,i,o){var a,l,c;return(a=Math.sqrt(e*e+t*t))&&(e/=a,t/=a),(c=e*n+t*r)&&(n-=e*c,r-=t*c),(l=Math.sqrt(n*n+r*r))&&(n/=l,r/=l,c/=l),e*r<t*n&&(e=-e,t=-t,c=-c,a=-a),{translateX:i,translateY:o,rotate:Math.atan2(t,e)*ZN,skewX:Math.atan(c)*ZN,scaleX:a,scaleY:l}}var Yp;function hW(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?db:WP(t.a,t.b,t.c,t.d,t.e,t.f)}function mW(e){return e==null||(Yp||(Yp=document.createElementNS("http://www.w3.org/2000/svg","g")),Yp.setAttribute("transform",e),!(e=Yp.transform.baseVal.consolidate()))?db:(e=e.matrix,WP(e.a,e.b,e.c,e.d,e.e,e.f))}function HP(e,t,n,r){function i(u){return u.length?u.pop()+" ":""}function o(u,f,p,d,m,y){if(u!==p||f!==d){var v=m.push("translate(",null,t,null,n);y.push({i:v-4,x:_i(u,p)},{i:v-2,x:_i(f,d)})}else(p||d)&&m.push("translate("+p+t+d+n)}function a(u,f,p,d){u!==f?(u-f>180?f+=360:f-u>180&&(u+=360),d.push({i:p.push(i(p)+"rotate(",null,r)-2,x:_i(u,f)})):f&&p.push(i(p)+"rotate("+f+r)}function l(u,f,p,d){u!==f?d.push({i:p.push(i(p)+"skewX(",null,r)-2,x:_i(u,f)}):f&&p.push(i(p)+"skewX("+f+r)}function c(u,f,p,d,m,y){if(u!==p||f!==d){var v=m.push(i(m)+"scale(",null,",",null,")");y.push({i:v-4,x:_i(u,p)},{i:v-2,x:_i(f,d)})}else(p!==1||d!==1)&&m.push(i(m)+"scale("+p+","+d+")")}return function(u,f){var p=[],d=[];return u=e(u),f=e(f),o(u.translateX,u.translateY,f.translateX,f.translateY,p,d),a(u.rotate,f.rotate,p,d),l(u.skewX,f.skewX,p,d),c(u.scaleX,u.scaleY,f.scaleX,f.scaleY,p,d),u=f=null,function(m){for(var y=-1,v=d.length,b;++y<v;)p[(b=d[y]).i]=b.x(m);return p.join("")}}}var gW=HP(hW,"px, ","px)","deg)"),yW=HP(mW,", ",")",")"),wW=1e-12;function e_(e){return((e=Math.exp(e))+1/e)/2}function xW(e){return((e=Math.exp(e))-1/e)/2}function bW(e){return((e=Math.exp(2*e))-1)/(e+1)}const $h=function e(t,n,r){function i(o,a){var l=o[0],c=o[1],u=o[2],f=a[0],p=a[1],d=a[2],m=f-l,y=p-c,v=m*m+y*y,b,g;if(v<wW)g=Math.log(d/u)/t,b=function(P){return[l+P*m,c+P*y,u*Math.exp(t*P*g)]};else{var k=Math.sqrt(v),x=(d*d-u*u+r*v)/(2*u*n*k),_=(d*d-u*u-r*v)/(2*d*n*k),j=Math.log(Math.sqrt(x*x+1)-x),N=Math.log(Math.sqrt(_*_+1)-_);g=(N-j)/t,b=function(P){var T=P*g,z=e_(j),E=u/(n*k)*(z*bW(t*T+j)-xW(j));return[l+E*m,c+E*y,u*z/e_(t*T+j)]}}return b.duration=g*1e3*t/Math.SQRT2,b}return i.rho=function(o){var a=Math.max(.001,+o),l=a*a,c=l*l;return e(a,l,c)},i}(Math.SQRT2,2,4);var Vc=0,fd=0,Xu=0,VP=1e3,vm,pd,Sm=0,ll=0,bg=0,af=typeof performance=="object"&&performance.now?performance:Date,KP=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function av(){return ll||(KP(kW),ll=af.now()+bg)}function kW(){ll=0}function jm(){this._call=this._time=this._next=null}jm.prototype=qP.prototype={constructor:jm,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?av():+n)+(t==null?0:+t),!this._next&&pd!==this&&(pd?pd._next=this:vm=this,pd=this),this._call=e,this._time=n,fb()},stop:function(){this._call&&(this._call=null,this._time=1/0,fb())}};function qP(e,t,n){var r=new jm;return r.restart(e,t,n),r}function vW(){av(),++Vc;for(var e=vm,t;e;)(t=ll-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Vc}function t_(){ll=(Sm=af.now())+bg,Vc=fd=0;try{vW()}finally{Vc=0,jW(),ll=0}}function SW(){var e=af.now(),t=e-Sm;t>VP&&(bg-=t,Sm=e)}function jW(){for(var e,t=vm,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:vm=n);pd=e,fb(r)}function fb(e){if(!Vc){fd&&(fd=clearTimeout(fd));var t=e-ll;t>24?(e<1/0&&(fd=setTimeout(t_,e-af.now()-bg)),Xu&&(Xu=clearInterval(Xu))):(Xu||(Sm=af.now(),Xu=setInterval(SW,VP)),Vc=1,KP(t_))}}function n_(e,t,n){var r=new jm;return t=t==null?0:+t,r.restart(i=>{r.stop(),e(i+t)},t,n),r}var NW=wg("start","end","cancel","interrupt"),_W=[],UP=0,r_=1,pb=2,Lh=3,s_=4,hb=5,Oh=6;function kg(e,t,n,r,i,o){var a=e.__transition;if(!a)e.__transition={};else if(n in a)return;CW(e,n,{name:t,index:r,group:i,on:NW,tween:_W,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:UP})}function lv(e,t){var n=mi(e,t);if(n.state>UP)throw new Error("too late; already scheduled");return n}function Hi(e,t){var n=mi(e,t);if(n.state>Lh)throw new Error("too late; already running");return n}function mi(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function CW(e,t,n){var r=e.__transition,i;r[t]=n,n.timer=qP(o,0,n.time);function o(u){n.state=r_,n.timer.restart(a,n.delay,n.time),n.delay<=u&&a(u-n.delay)}function a(u){var f,p,d,m;if(n.state!==r_)return c();for(f in r)if(m=r[f],m.name===n.name){if(m.state===Lh)return n_(a);m.state===s_?(m.state=Oh,m.timer.stop(),m.on.call("interrupt",e,e.__data__,m.index,m.group),delete r[f]):+f<t&&(m.state=Oh,m.timer.stop(),m.on.call("cancel",e,e.__data__,m.index,m.group),delete r[f])}if(n_(function(){n.state===Lh&&(n.state=s_,n.timer.restart(l,n.delay,n.time),l(u))}),n.state=pb,n.on.call("start",e,e.__data__,n.index,n.group),n.state===pb){for(n.state=Lh,i=new Array(d=n.tween.length),f=0,p=-1;f<d;++f)(m=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(i[++p]=m);i.length=p+1}}function l(u){for(var f=u<n.duration?n.ease.call(null,u/n.duration):(n.timer.restart(c),n.state=hb,1),p=-1,d=i.length;++p<d;)i[p].call(e,f);n.state===hb&&(n.on.call("end",e,e.__data__,n.index,n.group),c())}function c(){n.state=Oh,n.timer.stop(),delete r[t];for(var u in r)return;delete e.__transition}}function Dh(e,t){var n=e.__transition,r,i,o=!0,a;if(n){t=t==null?null:t+"";for(a in n){if((r=n[a]).name!==t){o=!1;continue}i=r.state>pb&&r.state<hb,r.state=Oh,r.timer.stop(),r.on.call(i?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[a]}o&&delete e.__transition}}function AW(e){return this.each(function(){Dh(this,e)})}function EW(e,t){var n,r;return function(){var i=Hi(this,e),o=i.tween;if(o!==n){r=n=o;for(var a=0,l=r.length;a<l;++a)if(r[a].name===t){r=r.slice(),r.splice(a,1);break}}i.tween=r}}function IW(e,t,n){var r,i;if(typeof n!="function")throw new Error;return function(){var o=Hi(this,e),a=o.tween;if(a!==r){i=(r=a).slice();for(var l={name:t,value:n},c=0,u=i.length;c<u;++c)if(i[c].name===t){i[c]=l;break}c===u&&i.push(l)}o.tween=i}}function PW(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=mi(this.node(),n).tween,i=0,o=r.length,a;i<o;++i)if((a=r[i]).name===e)return a.value;return null}return this.each((t==null?EW:IW)(n,e,t))}function cv(e,t,n){var r=e._id;return e.each(function(){var i=Hi(this,r);(i.value||(i.value={}))[t]=n.apply(this,arguments)}),function(i){return mi(i,r).value[t]}}function GP(e,t){var n;return(typeof t=="number"?_i:t instanceof al?km:(n=al(t))?(t=n,km):BP)(e,t)}function TW(e){return function(){this.removeAttribute(e)}}function RW(e){return function(){this.removeAttributeNS(e.space,e.local)}}function MW(e,t,n){var r,i=n+"",o;return function(){var a=this.getAttribute(e);return a===i?null:a===r?o:o=t(r=a,n)}}function $W(e,t,n){var r,i=n+"",o;return function(){var a=this.getAttributeNS(e.space,e.local);return a===i?null:a===r?o:o=t(r=a,n)}}function LW(e,t,n){var r,i,o;return function(){var a,l=n(this),c;return l==null?void this.removeAttribute(e):(a=this.getAttribute(e),c=l+"",a===c?null:a===r&&c===i?o:(i=c,o=t(r=a,l)))}}function OW(e,t,n){var r,i,o;return function(){var a,l=n(this),c;return l==null?void this.removeAttributeNS(e.space,e.local):(a=this.getAttributeNS(e.space,e.local),c=l+"",a===c?null:a===r&&c===i?o:(i=c,o=t(r=a,l)))}}function DW(e,t){var n=xg(e),r=n==="transform"?yW:GP;return this.attrTween(e,typeof t=="function"?(n.local?OW:LW)(n,r,cv(this,"attr."+e,t)):t==null?(n.local?RW:TW)(n):(n.local?$W:MW)(n,r,t))}function FW(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function zW(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function BW(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&zW(e,o)),n}return i._value=t,i}function WW(e,t){var n,r;function i(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&FW(e,o)),n}return i._value=t,i}function HW(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=xg(e);return this.tween(n,(r.local?BW:WW)(r,t))}function VW(e,t){return function(){lv(this,e).delay=+t.apply(this,arguments)}}function KW(e,t){return t=+t,function(){lv(this,e).delay=t}}function qW(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?VW:KW)(t,e)):mi(this.node(),t).delay}function UW(e,t){return function(){Hi(this,e).duration=+t.apply(this,arguments)}}function GW(e,t){return t=+t,function(){Hi(this,e).duration=t}}function YW(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?UW:GW)(t,e)):mi(this.node(),t).duration}function JW(e,t){if(typeof t!="function")throw new Error;return function(){Hi(this,e).ease=t}}function XW(e){var t=this._id;return arguments.length?this.each(JW(t,e)):mi(this.node(),t).ease}function QW(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Hi(this,e).ease=n}}function ZW(e){if(typeof e!="function")throw new Error;return this.each(QW(this._id,e))}function e4(e){typeof e!="function"&&(e=NP(e));for(var t=this._groups,n=t.length,r=new Array(n),i=0;i<n;++i)for(var o=t[i],a=o.length,l=r[i]=[],c,u=0;u<a;++u)(c=o[u])&&e.call(c,c.__data__,u,o)&&l.push(c);return new yo(r,this._parents,this._name,this._id)}function t4(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,i=n.length,o=Math.min(r,i),a=new Array(r),l=0;l<o;++l)for(var c=t[l],u=n[l],f=c.length,p=a[l]=new Array(f),d,m=0;m<f;++m)(d=c[m]||u[m])&&(p[m]=d);for(;l<r;++l)a[l]=t[l];return new yo(a,this._parents,this._name,this._id)}function n4(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 r4(e,t,n){var r,i,o=n4(t)?lv:Hi;return function(){var a=o(this,e),l=a.on;l!==r&&(i=(r=l).copy()).on(t,n),a.on=i}}function s4(e,t){var n=this._id;return arguments.length<2?mi(this.node(),n).on.on(e):this.each(r4(n,e,t))}function i4(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function o4(){return this.on("end.remove",i4(this._id))}function a4(e){var t=this._name,n=this._id;typeof e!="function"&&(e=rv(e));for(var r=this._groups,i=r.length,o=new Array(i),a=0;a<i;++a)for(var l=r[a],c=l.length,u=o[a]=new Array(c),f,p,d=0;d<c;++d)(f=l[d])&&(p=e.call(f,f.__data__,d,l))&&("__data__"in f&&(p.__data__=f.__data__),u[d]=p,kg(u[d],t,n,d,u,mi(f,n)));return new yo(o,this._parents,t,n)}function l4(e){var t=this._name,n=this._id;typeof e!="function"&&(e=jP(e));for(var r=this._groups,i=r.length,o=[],a=[],l=0;l<i;++l)for(var c=r[l],u=c.length,f,p=0;p<u;++p)if(f=c[p]){for(var d=e.call(f,f.__data__,p,c),m,y=mi(f,n),v=0,b=d.length;v<b;++v)(m=d[v])&&kg(m,t,n,v,d,y);o.push(d),a.push(f)}return new yo(o,a,t,n)}var c4=Mf.prototype.constructor;function u4(){return new c4(this._groups,this._parents)}function d4(e,t){var n,r,i;return function(){var o=Hc(this,e),a=(this.style.removeProperty(e),Hc(this,e));return o===a?null:o===n&&a===r?i:i=t(n=o,r=a)}}function YP(e){return function(){this.style.removeProperty(e)}}function f4(e,t,n){var r,i=n+"",o;return function(){var a=Hc(this,e);return a===i?null:a===r?o:o=t(r=a,n)}}function p4(e,t,n){var r,i,o;return function(){var a=Hc(this,e),l=n(this),c=l+"";return l==null&&(c=l=(this.style.removeProperty(e),Hc(this,e))),a===c?null:a===r&&c===i?o:(i=c,o=t(r=a,l))}}function h4(e,t){var n,r,i,o="style."+t,a="end."+o,l;return function(){var c=Hi(this,e),u=c.on,f=c.value[o]==null?l||(l=YP(t)):void 0;(u!==n||i!==f)&&(r=(n=u).copy()).on(a,i=f),c.on=r}}function m4(e,t,n){var r=(e+="")=="transform"?gW:GP;return t==null?this.styleTween(e,d4(e,r)).on("end.style."+e,YP(e)):typeof t=="function"?this.styleTween(e,p4(e,r,cv(this,"style."+e,t))).each(h4(this._id,e)):this.styleTween(e,f4(e,r,t),n).on("end.style."+e,null)}function g4(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function y4(e,t,n){var r,i;function o(){var a=t.apply(this,arguments);return a!==i&&(r=(i=a)&&g4(e,a,n)),r}return o._value=t,o}function w4(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,y4(e,t,n??""))}function x4(e){return function(){this.textContent=e}}function b4(e){return function(){var t=e(this);this.textContent=t??""}}function k4(e){return this.tween("text",typeof e=="function"?b4(cv(this,"text",e)):x4(e==null?"":e+""))}function v4(e){return function(t){this.textContent=e.call(this,t)}}function S4(e){var t,n;function r(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&v4(i)),t}return r._value=e,r}function j4(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,S4(e))}function N4(){for(var e=this._name,t=this._id,n=JP(),r=this._groups,i=r.length,o=0;o<i;++o)for(var a=r[o],l=a.length,c,u=0;u<l;++u)if(c=a[u]){var f=mi(c,t);kg(c,e,n,u,a,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new yo(r,this._parents,e,n)}function _4(){var e,t,n=this,r=n._id,i=n.size();return new Promise(function(o,a){var l={value:a},c={value:function(){--i===0&&o()}};n.each(function(){var u=Hi(this,r),f=u.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(c)),u.on=t}),i===0&&o()})}var C4=0;function yo(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function JP(){return++C4}var Xi=Mf.prototype;yo.prototype={constructor:yo,select:a4,selectAll:l4,selectChild:Xi.selectChild,selectChildren:Xi.selectChildren,filter:e4,merge:t4,selection:u4,transition:N4,call:Xi.call,nodes:Xi.nodes,node:Xi.node,size:Xi.size,empty:Xi.empty,each:Xi.each,on:s4,attr:DW,attrTween:HW,style:m4,styleTween:w4,text:k4,textTween:j4,remove:o4,tween:PW,delay:qW,duration:YW,ease:XW,easeVarying:ZW,end:_4,[Symbol.iterator]:Xi[Symbol.iterator]};function A4(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var E4={time:null,delay:0,duration:250,ease:A4};function I4(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 P4(e){var t,n;e instanceof yo?(t=e._id,e=e._name):(t=JP(),(n=E4).time=av(),e=e==null?null:e+"");for(var r=this._groups,i=r.length,o=0;o<i;++o)for(var a=r[o],l=a.length,c,u=0;u<l;++u)(c=a[u])&&kg(c,e,t,u,a,n||I4(c,t));return new yo(r,this._parents,e,t)}Mf.prototype.interrupt=AW;Mf.prototype.transition=P4;const Jp=e=>()=>e;function T4(e,{sourceEvent:t,target:n,transform:r,dispatch:i}){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:i}})}function io(e,t,n){this.k=e,this.x=t,this.y=n}io.prototype={constructor:io,scale:function(e){return e===1?this:new io(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new io(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 vg=new io(1,0,0);XP.prototype=io.prototype;function XP(e){for(;!e.__zoom;)if(!(e=e.parentNode))return vg;return e.__zoom}function hw(e){e.stopImmediatePropagation()}function Qu(e){e.preventDefault(),e.stopImmediatePropagation()}function R4(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function M4(){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 i_(){return this.__zoom||vg}function $4(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function L4(){return navigator.maxTouchPoints||"ontouchstart"in this}function O4(e,t,n){var r=e.invertX(t[0][0])-n[0][0],i=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],a=e.invertY(t[1][1])-n[1][1];return e.translate(i>r?(r+i)/2:Math.min(0,r)||Math.max(0,i),a>o?(o+a)/2:Math.min(0,o)||Math.max(0,a))}function QP(){var e=R4,t=M4,n=O4,r=$4,i=L4,o=[0,1/0],a=[[-1/0,-1/0],[1/0,1/0]],l=250,c=$h,u=wg("start","zoom","end"),f,p,d,m=500,y=150,v=0,b=10;function g($){$.property("__zoom",i_).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",z).on("dblclick.zoom",E).filter(i).on("touchstart.zoom",O).on("touchmove.zoom",D).on("touchend.zoom touchcancel.zoom",L).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}g.transform=function($,V,W,F){var M=$.selection?$.selection():$;M.property("__zoom",i_),$!==M?j($,V,W,F):M.interrupt().each(function(){N(this,arguments).event(F).start().zoom(null,typeof V=="function"?V.apply(this,arguments):V).end()})},g.scaleBy=function($,V,W,F){g.scaleTo($,function(){var M=this.__zoom.k,H=typeof V=="function"?V.apply(this,arguments):V;return M*H},W,F)},g.scaleTo=function($,V,W,F){g.transform($,function(){var M=t.apply(this,arguments),H=this.__zoom,A=W==null?_(M):typeof W=="function"?W.apply(this,arguments):W,X=H.invert(A),q=typeof V=="function"?V.apply(this,arguments):V;return n(x(k(H,q),A,X),M,a)},W,F)},g.translateBy=function($,V,W,F){g.transform($,function(){return n(this.__zoom.translate(typeof V=="function"?V.apply(this,arguments):V,typeof W=="function"?W.apply(this,arguments):W),t.apply(this,arguments),a)},null,F)},g.translateTo=function($,V,W,F,M){g.transform($,function(){var H=t.apply(this,arguments),A=this.__zoom,X=F==null?_(H):typeof F=="function"?F.apply(this,arguments):F;return n(vg.translate(X[0],X[1]).scale(A.k).translate(typeof V=="function"?-V.apply(this,arguments):-V,typeof W=="function"?-W.apply(this,arguments):-W),H,a)},F,M)};function k($,V){return V=Math.max(o[0],Math.min(o[1],V)),V===$.k?$:new io(V,$.x,$.y)}function x($,V,W){var F=V[0]-W[0]*$.k,M=V[1]-W[1]*$.k;return F===$.x&&M===$.y?$:new io($.k,F,M)}function _($){return[(+$[0][0]+ +$[1][0])/2,(+$[0][1]+ +$[1][1])/2]}function j($,V,W,F){$.on("start.zoom",function(){N(this,arguments).event(F).start()}).on("interrupt.zoom end.zoom",function(){N(this,arguments).event(F).end()}).tween("zoom",function(){var M=this,H=arguments,A=N(M,H).event(F),X=t.apply(M,H),q=W==null?_(X):typeof W=="function"?W.apply(M,H):W,B=Math.max(X[1][0]-X[0][0],X[1][1]-X[0][1]),ne=M.__zoom,ce=typeof V=="function"?V.apply(M,H):V,K=c(ne.invert(q).concat(B/ne.k),ce.invert(q).concat(B/ce.k));return function(ee){if(ee===1)ee=ce;else{var re=K(ee),se=B/re[2];ee=new io(se,q[0]-re[0]*se,q[1]-re[1]*se)}A.zoom(null,ee)}})}function N($,V,W){return!W&&$.__zooming||new P($,V)}function P($,V){this.that=$,this.args=V,this.active=0,this.sourceEvent=null,this.extent=t.apply($,V),this.taps=0}P.prototype={event:function($){return $&&(this.sourceEvent=$),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function($,V){return this.mouse&&$!=="mouse"&&(this.mouse[1]=V.invert(this.mouse[0])),this.touch0&&$!=="touch"&&(this.touch0[1]=V.invert(this.touch0[0])),this.touch1&&$!=="touch"&&(this.touch1[1]=V.invert(this.touch1[0])),this.that.__zoom=V,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function($){var V=ys(this.that).datum();u.call($,this.that,new T4($,{sourceEvent:this.sourceEvent,target:g,transform:this.that.__zoom,dispatch:u}),V)}};function T($,...V){if(!e.apply(this,arguments))return;var W=N(this,V).event($),F=this.__zoom,M=Math.max(o[0],Math.min(o[1],F.k*Math.pow(2,r.apply(this,arguments)))),H=ri($);if(W.wheel)(W.mouse[0][0]!==H[0]||W.mouse[0][1]!==H[1])&&(W.mouse[1]=F.invert(W.mouse[0]=H)),clearTimeout(W.wheel);else{if(F.k===M)return;W.mouse=[H,F.invert(H)],Dh(this),W.start()}Qu($),W.wheel=setTimeout(A,y),W.zoom("mouse",n(x(k(F,M),W.mouse[0],W.mouse[1]),W.extent,a));function A(){W.wheel=null,W.end()}}function z($,...V){if(d||!e.apply(this,arguments))return;var W=$.currentTarget,F=N(this,V,!0).event($),M=ys($.view).on("mousemove.zoom",q,!0).on("mouseup.zoom",B,!0),H=ri($,W),A=$.clientX,X=$.clientY;$P($.view),hw($),F.mouse=[H,this.__zoom.invert(H)],Dh(this),F.start();function q(ne){if(Qu(ne),!F.moved){var ce=ne.clientX-A,K=ne.clientY-X;F.moved=ce*ce+K*K>v}F.event(ne).zoom("mouse",n(x(F.that.__zoom,F.mouse[0]=ri(ne,W),F.mouse[1]),F.extent,a))}function B(ne){M.on("mousemove.zoom mouseup.zoom",null),LP(ne.view,F.moved),Qu(ne),F.event(ne).end()}}function E($,...V){if(e.apply(this,arguments)){var W=this.__zoom,F=ri($.changedTouches?$.changedTouches[0]:$,this),M=W.invert(F),H=W.k*($.shiftKey?.5:2),A=n(x(k(W,H),F,M),t.apply(this,V),a);Qu($),l>0?ys(this).transition().duration(l).call(j,A,F,$):ys(this).call(g.transform,A,F,$)}}function O($,...V){if(e.apply(this,arguments)){var W=$.touches,F=W.length,M=N(this,V,$.changedTouches.length===F).event($),H,A,X,q;for(hw($),A=0;A<F;++A)X=W[A],q=ri(X,this),q=[q,this.__zoom.invert(q),X.identifier],M.touch0?!M.touch1&&M.touch0[2]!==q[2]&&(M.touch1=q,M.taps=0):(M.touch0=q,H=!0,M.taps=1+!!f);f&&(f=clearTimeout(f)),H&&(M.taps<2&&(p=q[0],f=setTimeout(function(){f=null},m)),Dh(this),M.start())}}function D($,...V){if(this.__zooming){var W=N(this,V).event($),F=$.changedTouches,M=F.length,H,A,X,q;for(Qu($),H=0;H<M;++H)A=F[H],X=ri(A,this),W.touch0&&W.touch0[2]===A.identifier?W.touch0[0]=X:W.touch1&&W.touch1[2]===A.identifier&&(W.touch1[0]=X);if(A=W.that.__zoom,W.touch1){var B=W.touch0[0],ne=W.touch0[1],ce=W.touch1[0],K=W.touch1[1],ee=(ee=ce[0]-B[0])*ee+(ee=ce[1]-B[1])*ee,re=(re=K[0]-ne[0])*re+(re=K[1]-ne[1])*re;A=k(A,Math.sqrt(ee/re)),X=[(B[0]+ce[0])/2,(B[1]+ce[1])/2],q=[(ne[0]+K[0])/2,(ne[1]+K[1])/2]}else if(W.touch0)X=W.touch0[0],q=W.touch0[1];else return;W.zoom("touch",n(x(A,X,q),W.extent,a))}}function L($,...V){if(this.__zooming){var W=N(this,V).event($),F=$.changedTouches,M=F.length,H,A;for(hw($),d&&clearTimeout(d),d=setTimeout(function(){d=null},m),H=0;H<M;++H)A=F[H],W.touch0&&W.touch0[2]===A.identifier?delete W.touch0:W.touch1&&W.touch1[2]===A.identifier&&delete W.touch1;if(W.touch1&&!W.touch0&&(W.touch0=W.touch1,delete W.touch1),W.touch0)W.touch0[1]=this.__zoom.invert(W.touch0[0]);else if(W.end(),W.taps===2&&(A=ri(A,this),Math.hypot(p[0]-A[0],p[1]-A[1])<b)){var X=ys(this).on("dblclick.zoom");X&&X.apply(this,arguments)}}}return g.wheelDelta=function($){return arguments.length?(r=typeof $=="function"?$:Jp(+$),g):r},g.filter=function($){return arguments.length?(e=typeof $=="function"?$:Jp(!!$),g):e},g.touchable=function($){return arguments.length?(i=typeof $=="function"?$:Jp(!!$),g):i},g.extent=function($){return arguments.length?(t=typeof $=="function"?$:Jp([[+$[0][0],+$[0][1]],[+$[1][0],+$[1][1]]]),g):t},g.scaleExtent=function($){return arguments.length?(o[0]=+$[0],o[1]=+$[1],g):[o[0],o[1]]},g.translateExtent=function($){return arguments.length?(a[0][0]=+$[0][0],a[1][0]=+$[1][0],a[0][1]=+$[0][1],a[1][1]=+$[1][1],g):[[a[0][0],a[0][1]],[a[1][0],a[1][1]]]},g.constrain=function($){return arguments.length?(n=$,g):n},g.duration=function($){return arguments.length?(l=+$,g):l},g.interpolate=function($){return arguments.length?(c=$,g):c},g.on=function(){var $=u.on.apply(u,arguments);return $===u?g:$},g.clickDistance=function($){return arguments.length?(v=($=+$)*$,g):Math.sqrt(v)},g.tapDistance=function($){return arguments.length?(b=+$,g):b},g}const Bi={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."},lf=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ZP=["Enter"," ","Escape"],eT={"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 Kc;(function(e){e.Strict="strict",e.Loose="loose"})(Kc||(Kc={}));var Za;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Za||(Za={}));var cf;(function(e){e.Partial="partial",e.Full="full"})(cf||(cf={}));const tT={inProgress:!1,isValid:null,from:null,fromHandle:null,fromPosition:null,fromNode:null,to:null,toHandle:null,toPosition:null,toNode:null,pointer:null};var Go;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Go||(Go={}));var Ii;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Ii||(Ii={}));var Ge;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ge||(Ge={}));const o_={[Ge.Left]:Ge.Right,[Ge.Right]:Ge.Left,[Ge.Top]:Ge.Bottom,[Ge.Bottom]:Ge.Top};function nT(e){return e===null?null:e?"valid":"invalid"}const rT=e=>"id"in e&&"source"in e&&"target"in e,D4=e=>"id"in e&&"position"in e&&!("source"in e)&&!("target"in e),uv=e=>"id"in e&&"internals"in e&&!("source"in e)&&!("target"in e),Lf=(e,t=[0,0])=>{const{width:n,height:r}=vo(e),i=e.origin??t,o=n*i[0],a=r*i[1];return{x:e.position.x-o,y:e.position.y-a}},F4=(e,t={nodeOrigin:[0,0]})=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,i)=>{const o=typeof i=="string";let a=!t.nodeLookup&&!o?i:void 0;t.nodeLookup&&(a=o?t.nodeLookup.get(i):uv(i)?i:t.nodeLookup.get(i.id));const l=a?Nm(a,t.nodeOrigin):{x:0,y:0,x2:0,y2:0};return Sg(r,l)},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return jg(n)},Of=(e,t={})=>{let n={x:1/0,y:1/0,x2:-1/0,y2:-1/0},r=!1;return e.forEach(i=>{(t.filter===void 0||t.filter(i))&&(n=Sg(n,Nm(i)),r=!0)}),r?jg(n):{x:0,y:0,width:0,height:0}},dv=(e,t,[n,r,i]=[0,0,1],o=!1,a=!1)=>{const l={...Ff(t,[n,r,i]),width:t.width/i,height:t.height/i},c=[];for(const u of e.values()){const{measured:f,selectable:p=!0,hidden:d=!1}=u;if(a&&!p||d)continue;const m=f.width??u.width??u.initialWidth??null,y=f.height??u.height??u.initialHeight??null,v=uf(l,Uc(u)),b=(m??0)*(y??0),g=o&&v>0;(!u.internals.handleBounds||g||v>=b||u.dragging)&&c.push(u)}return c},z4=(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 B4(e,t){const n=new Map,r=t!=null&&t.nodes?new Set(t.nodes.map(i=>i.id)):null;return e.forEach(i=>{i.measured.width&&i.measured.height&&((t==null?void 0:t.includeHiddenNodes)||!i.hidden)&&(!r||r.has(i.id))&&n.set(i.id,i)}),n}async function W4({nodes:e,width:t,height:n,panZoom:r,minZoom:i,maxZoom:o},a){if(e.size===0)return Promise.resolve(!0);const l=B4(e,a),c=Of(l),u=fv(c,t,n,(a==null?void 0:a.minZoom)??i,(a==null?void 0:a.maxZoom)??o,(a==null?void 0:a.padding)??.1);return await r.setViewport(u,{duration:a==null?void 0:a.duration,ease:a==null?void 0:a.ease,interpolate:a==null?void 0:a.interpolate}),Promise.resolve(!0)}function sT({nodeId:e,nextPosition:t,nodeLookup:n,nodeOrigin:r=[0,0],nodeExtent:i,onError:o}){const a=n.get(e),l=a.parentId?n.get(a.parentId):void 0,{x:c,y:u}=l?l.internals.positionAbsolute:{x:0,y:0},f=a.origin??r;let p=a.extent||i;if(a.extent==="parent"&&!a.expandParent)if(!l)o==null||o("005",Bi.error005());else{const m=l.measured.width,y=l.measured.height;m&&y&&(p=[[c,u],[c+m,u+y]])}else l&&Gc(a.extent)&&(p=[[a.extent[0][0]+c,a.extent[0][1]+u],[a.extent[1][0]+c,a.extent[1][1]+u]]);const d=Gc(p)?cl(t,p,a.measured):t;return(a.measured.width===void 0||a.measured.height===void 0)&&(o==null||o("015",Bi.error015())),{position:{x:d.x-c+(a.measured.width??0)*f[0],y:d.y-u+(a.measured.height??0)*f[1]},positionAbsolute:d}}async function H4({nodesToRemove:e=[],edgesToRemove:t=[],nodes:n,edges:r,onBeforeDelete:i}){const o=new Set(e.map(d=>d.id)),a=[];for(const d of n){if(d.deletable===!1)continue;const m=o.has(d.id),y=!m&&d.parentId&&a.find(v=>v.id===d.parentId);(m||y)&&a.push(d)}const l=new Set(t.map(d=>d.id)),c=r.filter(d=>d.deletable!==!1),f=z4(a,c);for(const d of c)l.has(d.id)&&!f.find(y=>y.id===d.id)&&f.push(d);if(!i)return{edges:f,nodes:a};const p=await i({nodes:a,edges:f});return typeof p=="boolean"?p?{edges:f,nodes:a}:{edges:[],nodes:[]}:p}const qc=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),cl=(e={x:0,y:0},t,n)=>({x:qc(e.x,t[0][0],t[1][0]-((n==null?void 0:n.width)??0)),y:qc(e.y,t[0][1],t[1][1]-((n==null?void 0:n.height)??0))});function iT(e,t,n){const{width:r,height:i}=vo(n),{x:o,y:a}=n.internals.positionAbsolute;return cl(e,[[o,a],[o+r,a+i]],t)}const a_=(e,t,n)=>e<t?qc(Math.abs(e-t),1,t)/t:e>n?-qc(Math.abs(e-n),1,t)/t:0,oT=(e,t,n=15,r=40)=>{const i=a_(e.x,r,t.width-r)*n,o=a_(e.y,r,t.height-r)*n;return[i,o]},Sg=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),mb=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),jg=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),Uc=(e,t=[0,0])=>{var i,o;const{x:n,y:r}=uv(e)?e.internals.positionAbsolute:Lf(e,t);return{x:n,y:r,width:((i=e.measured)==null?void 0:i.width)??e.width??e.initialWidth??0,height:((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0}},Nm=(e,t=[0,0])=>{var i,o;const{x:n,y:r}=uv(e)?e.internals.positionAbsolute:Lf(e,t);return{x:n,y:r,x2:n+(((i=e.measured)==null?void 0:i.width)??e.width??e.initialWidth??0),y2:r+(((o=e.measured)==null?void 0:o.height)??e.height??e.initialHeight??0)}},aT=(e,t)=>jg(Sg(mb(e),mb(t))),uf=(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)},l_=e=>ai(e.width)&&ai(e.height)&&ai(e.x)&&ai(e.y),ai=e=>!isNaN(e)&&isFinite(e),V4=(e,t)=>{},Df=(e,t=[1,1])=>({x:t[0]*Math.round(e.x/t[0]),y:t[1]*Math.round(e.y/t[1])}),Ff=({x:e,y:t},[n,r,i],o=!1,a=[1,1])=>{const l={x:(e-n)/i,y:(t-r)/i};return o?Df(l,a):l},_m=({x:e,y:t},[n,r,i])=>({x:e*i+n,y:t*i+r});function Gl(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 K4(e,t,n){if(typeof e=="string"||typeof e=="number"){const r=Gl(e,n),i=Gl(e,t);return{top:r,right:i,bottom:r,left:i,x:i*2,y:r*2}}if(typeof e=="object"){const r=Gl(e.top??e.y??0,n),i=Gl(e.bottom??e.y??0,n),o=Gl(e.left??e.x??0,t),a=Gl(e.right??e.x??0,t);return{top:r,right:a,bottom:i,left:o,x:o+a,y:r+i}}return{top:0,right:0,bottom:0,left:0,x:0,y:0}}function q4(e,t,n,r,i,o){const{x:a,y:l}=_m(e,[t,n,r]),{x:c,y:u}=_m({x:e.x+e.width,y:e.y+e.height},[t,n,r]),f=i-c,p=o-u;return{left:Math.floor(a),top:Math.floor(l),right:Math.floor(f),bottom:Math.floor(p)}}const fv=(e,t,n,r,i,o)=>{const a=K4(o,t,n),l=(t-a.x)/e.width,c=(n-a.y)/e.height,u=Math.min(l,c),f=qc(u,r,i),p=e.x+e.width/2,d=e.y+e.height/2,m=t/2-p*f,y=n/2-d*f,v=q4(e,m,y,f,t,n),b={left:Math.min(v.left-a.left,0),top:Math.min(v.top-a.top,0),right:Math.min(v.right-a.right,0),bottom:Math.min(v.bottom-a.bottom,0)};return{x:m-b.left+b.right,y:y-b.top+b.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 Gc(e){return e!=null&&e!=="parent"}function vo(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 lT(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 cT(e,t={width:0,height:0},n,r,i){const o={...e},a=r.get(n);if(a){const l=a.origin||i;o.x+=a.internals.positionAbsolute.x-(t.width??0)*l[0],o.y+=a.internals.positionAbsolute.y-(t.height??0)*l[1]}return o}function c_(e,t){if(e.size!==t.size)return!1;for(const n of e)if(!t.has(n))return!1;return!0}function U4(){let e,t;return{promise:new Promise((r,i)=>{e=r,t=i}),resolve:e,reject:t}}function G4(e){return{...eT,...e||{}}}function Pd(e,{snapGrid:t=[0,0],snapToGrid:n=!1,transform:r,containerBounds:i}){const{x:o,y:a}=li(e),l=Ff({x:o-((i==null?void 0:i.left)??0),y:a-((i==null?void 0:i.top)??0)},r),{x:c,y:u}=n?Df(l,t):l;return{xSnapped:c,ySnapped:u,...l}}const pv=e=>({width:e.offsetWidth,height:e.offsetHeight}),uT=e=>{var t;return((t=e==null?void 0:e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Y4=["INPUT","SELECT","TEXTAREA"];function dT(e){var r,i;const t=((i=(r=e.composedPath)==null?void 0:r.call(e))==null?void 0:i[0])||e.target;return(t==null?void 0:t.nodeType)!==1?!1:Y4.includes(t.nodeName)||t.hasAttribute("contenteditable")||!!t.closest(".nokey")}const fT=e=>"clientX"in e,li=(e,t)=>{var o,a;const n=fT(e),r=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,i=n?e.clientY:(a=e.touches)==null?void 0:a[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:i-((t==null?void 0:t.top)??0)}},u_=(e,t,n,r,i)=>{const o=t.querySelectorAll(`.${e}`);return!o||!o.length?null:Array.from(o).map(a=>{const l=a.getBoundingClientRect();return{id:a.getAttribute("data-handleid"),type:e,nodeId:i,position:a.getAttribute("data-handlepos"),x:(l.left-n.left)/r,y:(l.top-n.top)/r,...pv(a)}})};function pT({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:i,sourceControlY:o,targetControlX:a,targetControlY:l}){const c=e*.125+i*.375+a*.375+n*.125,u=t*.125+o*.375+l*.375+r*.125,f=Math.abs(c-e),p=Math.abs(u-t);return[c,u,f,p]}function Xp(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function d_({pos:e,x1:t,y1:n,x2:r,y2:i,c:o}){switch(e){case Ge.Left:return[t-Xp(t-r,o),n];case Ge.Right:return[t+Xp(r-t,o),n];case Ge.Top:return[t,n-Xp(n-i,o)];case Ge.Bottom:return[t,n+Xp(i-n,o)]}}function hT({sourceX:e,sourceY:t,sourcePosition:n=Ge.Bottom,targetX:r,targetY:i,targetPosition:o=Ge.Top,curvature:a=.25}){const[l,c]=d_({pos:n,x1:e,y1:t,x2:r,y2:i,c:a}),[u,f]=d_({pos:o,x1:r,y1:i,x2:e,y2:t,c:a}),[p,d,m,y]=pT({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:l,sourceControlY:c,targetControlX:u,targetControlY:f});return[`M${e},${t} C${l},${c} ${u},${f} ${r},${i}`,p,d,m,y]}function mT({sourceX:e,sourceY:t,targetX:n,targetY:r}){const i=Math.abs(n-e)/2,o=n<e?n+i:n-i,a=Math.abs(r-t)/2,l=r<t?r+a:r-a;return[o,l,i,a]}function J4({sourceNode:e,targetNode:t,selected:n=!1,zIndex:r=0,elevateOnSelect:i=!1,zIndexMode:o="basic"}){if(o==="manual")return r;const a=i&&n?r+1e3:r,l=Math.max(e.parentId||i&&e.selected?e.internals.z:0,t.parentId||i&&t.selected?t.internals.z:0);return a+l}function X4({sourceNode:e,targetNode:t,width:n,height:r,transform:i}){const o=Sg(Nm(e),Nm(t));o.x===o.x2&&(o.x2+=1),o.y===o.y2&&(o.y2+=1);const a={x:-i[0]/i[2],y:-i[1]/i[2],width:n/i[2],height:r/i[2]};return uf(a,jg(o))>0}const Q4=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`xy-edge__${e}${t||""}-${n}${r||""}`,Z4=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),Fh=(e,t,n={})=>{if(!e.source||!e.target)return t;const r=n.getEdgeId||Q4;let i;return rT(e)?i={...e}:i={...e,id:r(e)},Z4(i,t)?t:(i.sourceHandle===null&&delete i.sourceHandle,i.targetHandle===null&&delete i.targetHandle,t.concat(i))};function gT({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[i,o,a,l]=mT({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,i,o,a,l]}const f_={[Ge.Left]:{x:-1,y:0},[Ge.Right]:{x:1,y:0},[Ge.Top]:{x:0,y:-1},[Ge.Bottom]:{x:0,y:1}},eH=({source:e,sourcePosition:t=Ge.Bottom,target:n})=>t===Ge.Left||t===Ge.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},p_=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function tH({source:e,sourcePosition:t=Ge.Bottom,target:n,targetPosition:r=Ge.Top,center:i,offset:o,stepPosition:a}){const l=f_[t],c=f_[r],u={x:e.x+l.x*o,y:e.y+l.y*o},f={x:n.x+c.x*o,y:n.y+c.y*o},p=eH({source:u,sourcePosition:t,target:f}),d=p.x!==0?"x":"y",m=p[d];let y=[],v,b;const g={x:0,y:0},k={x:0,y:0},[,,x,_]=mT({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[d]*c[d]===-1){d==="x"?(v=i.x??u.x+(f.x-u.x)*a,b=i.y??(u.y+f.y)/2):(v=i.x??(u.x+f.x)/2,b=i.y??u.y+(f.y-u.y)*a);const T=[{x:v,y:u.y},{x:v,y:f.y}],z=[{x:u.x,y:b},{x:f.x,y:b}];l[d]===m?y=d==="x"?T:z:y=d==="x"?z:T}else{const T=[{x:u.x,y:f.y}],z=[{x:f.x,y:u.y}];if(d==="x"?y=l.x===m?z:T:y=l.y===m?T:z,t===r){const $=Math.abs(e[d]-n[d]);if($<=o){const V=Math.min(o-1,o-$);l[d]===m?g[d]=(u[d]>e[d]?-1:1)*V:k[d]=(f[d]>n[d]?-1:1)*V}}if(t!==r){const $=d==="x"?"y":"x",V=l[d]===c[$],W=u[$]>f[$],F=u[$]<f[$];(l[d]===1&&(!V&&W||V&&F)||l[d]!==1&&(!V&&F||V&&W))&&(y=d==="x"?T:z)}const E={x:u.x+g.x,y:u.y+g.y},O={x:f.x+k.x,y:f.y+k.y},D=Math.max(Math.abs(E.x-y[0].x),Math.abs(O.x-y[0].x)),L=Math.max(Math.abs(E.y-y[0].y),Math.abs(O.y-y[0].y));D>=L?(v=(E.x+O.x)/2,b=y[0].y):(v=y[0].x,b=(E.y+O.y)/2)}const j={x:u.x+g.x,y:u.y+g.y},N={x:f.x+k.x,y:f.y+k.y};return[[e,...j.x!==y[0].x||j.y!==y[0].y?[j]:[],...y,...N.x!==y[y.length-1].x||N.y!==y[y.length-1].y?[N]:[],n],v,b,x,_]}function nH(e,t,n,r){const i=Math.min(p_(e,t)/2,p_(t,n)/2,r),{x:o,y:a}=t;if(e.x===o&&o===n.x||e.y===a&&a===n.y)return`L${o} ${a}`;if(e.y===a){const u=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${o+i*u},${a}Q ${o},${a} ${o},${a+i*f}`}const l=e.x<n.x?1:-1,c=e.y<n.y?-1:1;return`L ${o},${a+i*c}Q ${o},${a} ${o+i*l},${a}`}function gb({sourceX:e,sourceY:t,sourcePosition:n=Ge.Bottom,targetX:r,targetY:i,targetPosition:o=Ge.Top,borderRadius:a=5,centerX:l,centerY:c,offset:u=20,stepPosition:f=.5}){const[p,d,m,y,v]=tH({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:i},targetPosition:o,center:{x:l,y:c},offset:u,stepPosition:f});let b=`M${p[0].x} ${p[0].y}`;for(let g=1;g<p.length-1;g++)b+=nH(p[g-1],p[g],p[g+1],a);return b+=`L${p[p.length-1].x} ${p[p.length-1].y}`,[b,d,m,y,v]}function h_(e){var t;return e&&!!(e.internals.handleBounds||(t=e.handles)!=null&&t.length)&&!!(e.measured.width||e.width||e.initialWidth)}function rH(e){var p;const{sourceNode:t,targetNode:n}=e;if(!h_(t)||!h_(n))return null;const r=t.internals.handleBounds||m_(t.handles),i=n.internals.handleBounds||m_(n.handles),o=g_((r==null?void 0:r.source)??[],e.sourceHandle),a=g_(e.connectionMode===Kc.Strict?(i==null?void 0:i.target)??[]:((i==null?void 0:i.target)??[]).concat((i==null?void 0:i.source)??[]),e.targetHandle);if(!o||!a)return(p=e.onError)==null||p.call(e,"008",Bi.error008(o?"target":"source",{id:e.id,sourceHandle:e.sourceHandle,targetHandle:e.targetHandle})),null;const l=(o==null?void 0:o.position)||Ge.Bottom,c=(a==null?void 0:a.position)||Ge.Top,u=ul(t,o,l),f=ul(n,a,c);return{sourceX:u.x,sourceY:u.y,targetX:f.x,targetY:f.y,sourcePosition:l,targetPosition:c}}function m_(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 ul(e,t,n=Ge.Left,r=!1){const i=((t==null?void 0:t.x)??0)+e.internals.positionAbsolute.x,o=((t==null?void 0:t.y)??0)+e.internals.positionAbsolute.y,{width:a,height:l}=t??vo(e);if(r)return{x:i+a/2,y:o+l/2};switch((t==null?void 0:t.position)??n){case Ge.Top:return{x:i+a/2,y:o};case Ge.Right:return{x:i+a,y:o+l/2};case Ge.Bottom:return{x:i+a/2,y:o+l};case Ge.Left:return{x:i,y:o+l/2}}}function g_(e,t){return e&&(t?e.find(n=>n.id===t):e[0])||null}function yb(e,t){return e?typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`:""}function sH(e,{id:t,defaultColor:n,defaultMarkerStart:r,defaultMarkerEnd:i}){const o=new Set;return e.reduce((a,l)=>([l.markerStart||r,l.markerEnd||i].forEach(c=>{if(c&&typeof c=="object"){const u=yb(c,t);o.has(u)||(a.push({id:u,color:c.color||n,...c}),o.add(u))}}),a),[]).sort((a,l)=>a.id.localeCompare(l.id))}const yT=1e3,iH=10,hv={nodeOrigin:[0,0],nodeExtent:lf,elevateNodesOnSelect:!0,zIndexMode:"basic",defaults:{}},oH={...hv,checkEquality:!0};function mv(e,t){const n={...e};for(const r in t)t[r]!==void 0&&(n[r]=t[r]);return n}function aH(e,t,n){const r=mv(hv,n);for(const i of e.values())if(i.parentId)yv(i,e,t,r);else{const o=Lf(i,r.nodeOrigin),a=Gc(i.extent)?i.extent:r.nodeExtent,l=cl(o,a,vo(i));i.internals.positionAbsolute=l}}function lH(e,t){if(!e.handles)return e.measured?t==null?void 0:t.internals.handleBounds:void 0;const n=[],r=[];for(const i of e.handles){const o={id:i.id,width:i.width??1,height:i.height??1,nodeId:e.id,x:i.x,y:i.y,position:i.position,type:i.type};i.type==="source"?n.push(o):i.type==="target"&&r.push(o)}return{source:n,target:r}}function gv(e){return e==="manual"}function wb(e,t,n,r={}){var f,p;const i=mv(oH,r),o={i:0},a=new Map(t),l=i!=null&&i.elevateNodesOnSelect&&!gv(i.zIndexMode)?yT:0;let c=e.length>0,u=!1;t.clear(),n.clear();for(const d of e){let m=a.get(d.id);if(i.checkEquality&&d===(m==null?void 0:m.internals.userNode))t.set(d.id,m);else{const y=Lf(d,i.nodeOrigin),v=Gc(d.extent)?d.extent:i.nodeExtent,b=cl(y,v,vo(d));m={...i.defaults,...d,measured:{width:(f=d.measured)==null?void 0:f.width,height:(p=d.measured)==null?void 0:p.height},internals:{positionAbsolute:b,handleBounds:lH(d,m),z:wT(d,l,i.zIndexMode),userNode:d}},t.set(d.id,m)}(m.measured===void 0||m.measured.width===void 0||m.measured.height===void 0)&&!m.hidden&&(c=!1),d.parentId&&yv(m,t,n,r,o),u||(u=d.selected??!1)}return{nodesInitialized:c,hasSelectedNodes:u}}function cH(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 yv(e,t,n,r,i){const{elevateNodesOnSelect:o,nodeOrigin:a,nodeExtent:l,zIndexMode:c}=mv(hv,r),u=e.parentId,f=t.get(u);if(!f){console.warn(`Parent node ${u} not found. Please make sure that parent nodes are in front of their child nodes in the nodes array.`);return}cH(e,n),i&&!f.parentId&&f.internals.rootParentIndex===void 0&&c==="auto"&&(f.internals.rootParentIndex=++i.i,f.internals.z=f.internals.z+i.i*iH),i&&f.internals.rootParentIndex!==void 0&&(i.i=f.internals.rootParentIndex);const p=o&&!gv(c)?yT:0,{x:d,y:m,z:y}=uH(e,f,a,l,p,c),{positionAbsolute:v}=e.internals,b=d!==v.x||m!==v.y;(b||y!==e.internals.z)&&t.set(e.id,{...e,internals:{...e.internals,positionAbsolute:b?{x:d,y:m}:v,z:y}})}function wT(e,t,n){const r=ai(e.zIndex)?e.zIndex:0;return gv(n)?r:r+(e.selected?t:0)}function uH(e,t,n,r,i,o){const{x:a,y:l}=t.internals.positionAbsolute,c=vo(e),u=Lf(e,n),f=Gc(e.extent)?cl(u,e.extent,c):u;let p=cl({x:a+f.x,y:l+f.y},r,c);e.extent==="parent"&&(p=iT(p,c,t));const d=wT(e,i,o),m=t.internals.z??0;return{x:p.x,y:p.y,z:m>=d?m+1:d}}function wv(e,t,n,r=[0,0]){var a;const i=[],o=new Map;for(const l of e){const c=t.get(l.parentId);if(!c)continue;const u=((a=o.get(l.parentId))==null?void 0:a.expandedRect)??Uc(c),f=aT(u,l.rect);o.set(l.parentId,{expandedRect:f,parent:c})}return o.size>0&&o.forEach(({expandedRect:l,parent:c},u)=>{var x;const f=c.internals.positionAbsolute,p=vo(c),d=c.origin??r,m=l.x<f.x?Math.round(Math.abs(f.x-l.x)):0,y=l.y<f.y?Math.round(Math.abs(f.y-l.y)):0,v=Math.max(p.width,Math.round(l.width)),b=Math.max(p.height,Math.round(l.height)),g=(v-p.width)*d[0],k=(b-p.height)*d[1];(m>0||y>0||g||k)&&(i.push({id:u,type:"position",position:{x:c.position.x-m+g,y:c.position.y-y+k}}),(x=n.get(u))==null||x.forEach(_=>{e.some(j=>j.id===_.id)||i.push({id:_.id,type:"position",position:{x:_.position.x+m,y:_.position.y+y}})})),(p.width<l.width||p.height<l.height||m||y)&&i.push({id:u,type:"dimensions",setAttributes:!0,dimensions:{width:v+(m?d[0]*m-g:0),height:b+(y?d[1]*y-k:0)}})}),i}function dH(e,t,n,r,i,o,a){const l=r==null?void 0:r.querySelector(".xyflow__viewport");let c=!1;if(!l)return{changes:[],updatedInternals:c};const u=[],f=window.getComputedStyle(l),{m22:p}=new window.DOMMatrixReadOnly(f.transform),d=[];for(const m of e.values()){const y=t.get(m.id);if(!y)continue;if(y.hidden){t.set(y.id,{...y,internals:{...y.internals,handleBounds:void 0}}),c=!0;continue}const v=pv(m.nodeElement),b=y.measured.width!==v.width||y.measured.height!==v.height;if(!!(v.width&&v.height&&(b||!y.internals.handleBounds||m.force))){const k=m.nodeElement.getBoundingClientRect(),x=Gc(y.extent)?y.extent:o;let{positionAbsolute:_}=y.internals;y.parentId&&y.extent==="parent"?_=iT(_,v,t.get(y.parentId)):x&&(_=cl(_,x,v));const j={...y,measured:v,internals:{...y.internals,positionAbsolute:_,handleBounds:{source:u_("source",m.nodeElement,k,p,y.id),target:u_("target",m.nodeElement,k,p,y.id)}}};t.set(y.id,j),y.parentId&&yv(j,t,n,{nodeOrigin:i,zIndexMode:a}),c=!0,b&&(u.push({id:y.id,type:"dimensions",dimensions:v}),y.expandParent&&y.parentId&&d.push({id:y.id,parentId:y.parentId,rect:Uc(j,i)}))}}if(d.length>0){const m=wv(d,t,n,i);u.push(...m)}return{changes:u,updatedInternals:c}}async function fH({delta:e,panZoom:t,transform:n,translateExtent:r,width:i,height:o}){if(!t||!e.x&&!e.y)return Promise.resolve(!1);const a=await t.setViewportConstrained({x:n[0]+e.x,y:n[1]+e.y,zoom:n[2]},[[0,0],[i,o]],r),l=!!a&&(a.x!==n[0]||a.y!==n[1]||a.k!==n[2]);return Promise.resolve(l)}function y_(e,t,n,r,i,o){let a=i;const l=r.get(a)||new Map;r.set(a,l.set(n,t)),a=`${i}-${e}`;const c=r.get(a)||new Map;if(r.set(a,c.set(n,t)),o){a=`${i}-${e}-${o}`;const u=r.get(a)||new Map;r.set(a,u.set(n,t))}}function xT(e,t,n){e.clear(),t.clear();for(const r of n){const{source:i,target:o,sourceHandle:a=null,targetHandle:l=null}=r,c={edgeId:r.id,source:i,target:o,sourceHandle:a,targetHandle:l},u=`${i}-${a}--${o}-${l}`,f=`${o}-${l}--${i}-${a}`;y_("source",c,f,e,i,a),y_("target",c,u,e,o,l),t.set(r.id,r)}}function bT(e,t){if(!e.parentId)return!1;const n=t.get(e.parentId);return n?n.selected?!0:bT(n,t):!1}function w_(e,t,n){var i;let r=e;do{if((i=r==null?void 0:r.matches)!=null&&i.call(r,t))return!0;if(r===n)return!1;r=r==null?void 0:r.parentElement}while(r);return!1}function pH(e,t,n,r){const i=new Map;for(const[o,a]of e)if((a.selected||a.id===r)&&(!a.parentId||!bT(a,e))&&(a.draggable||t&&typeof a.draggable>"u")){const l=e.get(o);l&&i.set(o,{id:o,position:l.position||{x:0,y:0},distance:{x:n.x-l.internals.positionAbsolute.x,y:n.y-l.internals.positionAbsolute.y},extent:l.extent,parentId:l.parentId,origin:l.origin,expandParent:l.expandParent,internals:{positionAbsolute:l.internals.positionAbsolute||{x:0,y:0}},measured:{width:l.measured.width??0,height:l.measured.height??0}})}return i}function mw({nodeId:e,dragItems:t,nodeLookup:n,dragging:r=!0}){var a,l,c;const i=[];for(const[u,f]of t){const p=(a=n.get(u))==null?void 0:a.internals.userNode;p&&i.push({...p,position:f.position,dragging:r})}if(!e)return[i[0],i];const o=(l=n.get(e))==null?void 0:l.internals.userNode;return[o?{...o,position:((c=t.get(e))==null?void 0:c.position)||o.position,dragging:r}:i[0],i]}function hH({dragItems:e,snapGrid:t,x:n,y:r}){const i=e.values().next().value;if(!i)return null;const o={x:n-i.distance.x,y:r-i.distance.y},a=Df(o,t);return{x:a.x-o.x,y:a.y-o.y}}function mH({onNodeMouseDown:e,getStoreItems:t,onDragStart:n,onDrag:r,onDragStop:i}){let o={x:null,y:null},a=0,l=new Map,c=!1,u={x:0,y:0},f=null,p=!1,d=null,m=!1,y=!1,v=null;function b({noDragClassName:k,handleSelector:x,domNode:_,isSelectable:j,nodeId:N,nodeClickDistance:P=0}){d=ys(_);function T({x:D,y:L}){const{nodeLookup:$,nodeExtent:V,snapGrid:W,snapToGrid:F,nodeOrigin:M,onNodeDrag:H,onSelectionDrag:A,onError:X,updateNodePositions:q}=t();o={x:D,y:L};let B=!1;const ne=l.size>1,ce=ne&&V?mb(Of(l)):null,K=ne&&F?hH({dragItems:l,snapGrid:W,x:D,y:L}):null;for(const[ee,re]of l){if(!$.has(ee))continue;let se={x:D-re.distance.x,y:L-re.distance.y};F&&(se=K?{x:Math.round(se.x+K.x),y:Math.round(se.y+K.y)}:Df(se,W));let Q=null;if(ne&&V&&!re.extent&&ce){const{positionAbsolute:me}=re.internals,De=me.x-ce.x+V[0][0],Ce=me.x+re.measured.width-ce.x2+V[1][0],Se=me.y-ce.y+V[0][1],Ue=me.y+re.measured.height-ce.y2+V[1][1];Q=[[De,Se],[Ce,Ue]]}const{position:le,positionAbsolute:fe}=sT({nodeId:ee,nextPosition:se,nodeLookup:$,nodeExtent:Q||V,nodeOrigin:M,onError:X});B=B||re.position.x!==le.x||re.position.y!==le.y,re.position=le,re.internals.positionAbsolute=fe}if(y=y||B,!!B&&(q(l,!0),v&&(r||H||!N&&A))){const[ee,re]=mw({nodeId:N,dragItems:l,nodeLookup:$});r==null||r(v,l,ee,re),H==null||H(v,ee,re),N||A==null||A(v,re)}}async function z(){if(!f)return;const{transform:D,panBy:L,autoPanSpeed:$,autoPanOnNodeDrag:V}=t();if(!V){c=!1,cancelAnimationFrame(a);return}const[W,F]=oT(u,f,$);(W!==0||F!==0)&&(o.x=(o.x??0)-W/D[2],o.y=(o.y??0)-F/D[2],await L({x:W,y:F})&&T(o)),a=requestAnimationFrame(z)}function E(D){var ne;const{nodeLookup:L,multiSelectionActive:$,nodesDraggable:V,transform:W,snapGrid:F,snapToGrid:M,selectNodesOnDrag:H,onNodeDragStart:A,onSelectionDragStart:X,unselectNodesAndEdges:q}=t();p=!0,(!H||!j)&&!$&&N&&((ne=L.get(N))!=null&&ne.selected||q()),j&&H&&N&&(e==null||e(N));const B=Pd(D.sourceEvent,{transform:W,snapGrid:F,snapToGrid:M,containerBounds:f});if(o=B,l=pH(L,V,B,N),l.size>0&&(n||A||!N&&X)){const[ce,K]=mw({nodeId:N,dragItems:l,nodeLookup:L});n==null||n(D.sourceEvent,l,ce,K),A==null||A(D.sourceEvent,ce,K),N||X==null||X(D.sourceEvent,K)}}const O=OP().clickDistance(P).on("start",D=>{const{domNode:L,nodeDragThreshold:$,transform:V,snapGrid:W,snapToGrid:F}=t();f=(L==null?void 0:L.getBoundingClientRect())||null,m=!1,y=!1,v=D.sourceEvent,$===0&&E(D),o=Pd(D.sourceEvent,{transform:V,snapGrid:W,snapToGrid:F,containerBounds:f}),u=li(D.sourceEvent,f)}).on("drag",D=>{const{autoPanOnNodeDrag:L,transform:$,snapGrid:V,snapToGrid:W,nodeDragThreshold:F,nodeLookup:M}=t(),H=Pd(D.sourceEvent,{transform:$,snapGrid:V,snapToGrid:W,containerBounds:f});if(v=D.sourceEvent,(D.sourceEvent.type==="touchmove"&&D.sourceEvent.touches.length>1||N&&!M.has(N))&&(m=!0),!m){if(!c&&L&&p&&(c=!0,z()),!p){const A=li(D.sourceEvent,f),X=A.x-u.x,q=A.y-u.y;Math.sqrt(X*X+q*q)>F&&E(D)}(o.x!==H.xSnapped||o.y!==H.ySnapped)&&l&&p&&(u=li(D.sourceEvent,f),T(H))}}).on("end",D=>{if(!(!p||m)&&(c=!1,p=!1,cancelAnimationFrame(a),l.size>0)){const{nodeLookup:L,updateNodePositions:$,onNodeDragStop:V,onSelectionDragStop:W}=t();if(y&&($(l,!1),y=!1),i||V||!N&&W){const[F,M]=mw({nodeId:N,dragItems:l,nodeLookup:L,dragging:!1});i==null||i(D.sourceEvent,l,F,M),V==null||V(D.sourceEvent,F,M),N||W==null||W(D.sourceEvent,M)}}}).filter(D=>{const L=D.target;return!D.button&&(!k||!w_(L,`.${k}`,_))&&(!x||w_(L,x,_))});d.call(O)}function g(){d==null||d.on(".drag",null)}return{update:b,destroy:g}}function gH(e,t,n){const r=[],i={x:e.x-n,y:e.y-n,width:n*2,height:n*2};for(const o of t.values())uf(i,Uc(o))>0&&r.push(o);return r}const yH=250;function wH(e,t,n,r){var l,c;let i=[],o=1/0;const a=gH(e,n,t+yH);for(const u of a){const f=[...((l=u.internals.handleBounds)==null?void 0:l.source)??[],...((c=u.internals.handleBounds)==null?void 0:c.target)??[]];for(const p of f){if(r.nodeId===p.nodeId&&r.type===p.type&&r.id===p.id)continue;const{x:d,y:m}=ul(u,p,p.position,!0),y=Math.sqrt(Math.pow(d-e.x,2)+Math.pow(m-e.y,2));y>t||(y<o?(i=[{...p,x:d,y:m}],o=y):y===o&&i.push({...p,x:d,y:m}))}}if(!i.length)return null;if(i.length>1){const u=r.type==="source"?"target":"source";return i.find(f=>f.type===u)??i[0]}return i[0]}function kT(e,t,n,r,i,o=!1){var u,f,p;const a=r.get(e);if(!a)return null;const l=i==="strict"?(u=a.internals.handleBounds)==null?void 0:u[t]:[...((f=a.internals.handleBounds)==null?void 0:f.source)??[],...((p=a.internals.handleBounds)==null?void 0:p.target)??[]],c=(n?l==null?void 0:l.find(d=>d.id===n):l==null?void 0:l[0])??null;return c&&o?{...c,...ul(a,c,c.position,!0)}:c}function vT(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function xH(e,t){let n=null;return t?n=!0:e&&!t&&(n=!1),n}const ST=()=>!0;function bH(e,{connectionMode:t,connectionRadius:n,handleId:r,nodeId:i,edgeUpdaterType:o,isTarget:a,domNode:l,nodeLookup:c,lib:u,autoPanOnConnect:f,flowId:p,panBy:d,cancelConnection:m,onConnectStart:y,onConnect:v,onConnectEnd:b,isValidConnection:g=ST,onReconnectEnd:k,updateConnection:x,getTransform:_,getFromHandle:j,autoPanSpeed:N,dragThreshold:P=1,handleDomNode:T}){const z=uT(e.target);let E=0,O;const{x:D,y:L}=li(e),$=vT(o,T),V=l==null?void 0:l.getBoundingClientRect();let W=!1;if(!V||!$)return;const F=kT(i,$,r,c,t);if(!F)return;let M=li(e,V),H=!1,A=null,X=!1,q=null;function B(){if(!f||!V)return;const[le,fe]=oT(M,V,N);d({x:le,y:fe}),E=requestAnimationFrame(B)}const ne={...F,nodeId:i,type:$,position:F.position},ce=c.get(i);let ee={inProgress:!0,isValid:null,from:ul(ce,ne,Ge.Left,!0),fromHandle:ne,fromPosition:ne.position,fromNode:ce,to:M,toHandle:null,toPosition:o_[ne.position],toNode:null,pointer:M};function re(){W=!0,x(ee),y==null||y(e,{nodeId:i,handleId:r,handleType:$})}P===0&&re();function se(le){if(!W){const{x:Ue,y:lt}=li(le),xt=Ue-D,at=lt-L;if(!(xt*xt+at*at>P*P))return;re()}if(!j()||!ne){Q(le);return}const fe=_();M=li(le,V),O=wH(Ff(M,fe,!1,[1,1]),n,c,ne),H||(B(),H=!0);const me=jT(le,{handle:O,connectionMode:t,fromNodeId:i,fromHandleId:r,fromType:a?"target":"source",isValidConnection:g,doc:z,lib:u,flowId:p,nodeLookup:c});q=me.handleDomNode,A=me.connection,X=xH(!!O,me.isValid);const De=c.get(i),Ce=De?ul(De,ne,Ge.Left,!0):ee.from,Se={...ee,from:Ce,isValid:X,to:me.toHandle&&X?_m({x:me.toHandle.x,y:me.toHandle.y},fe):M,toHandle:me.toHandle,toPosition:X&&me.toHandle?me.toHandle.position:o_[ne.position],toNode:me.toHandle?c.get(me.toHandle.nodeId):null,pointer:M};x(Se),ee=Se}function Q(le){if(!("touches"in le&&le.touches.length>0)){if(W){(O||q)&&A&&X&&(v==null||v(A));const{inProgress:fe,...me}=ee,De={...me,toPosition:ee.toHandle?ee.toPosition:null};b==null||b(le,De),o&&(k==null||k(le,De))}m(),cancelAnimationFrame(E),H=!1,X=!1,A=null,q=null,z.removeEventListener("mousemove",se),z.removeEventListener("mouseup",Q),z.removeEventListener("touchmove",se),z.removeEventListener("touchend",Q)}}z.addEventListener("mousemove",se),z.addEventListener("mouseup",Q),z.addEventListener("touchmove",se),z.addEventListener("touchend",Q)}function jT(e,{handle:t,connectionMode:n,fromNodeId:r,fromHandleId:i,fromType:o,doc:a,lib:l,flowId:c,isValidConnection:u=ST,nodeLookup:f}){const p=o==="target",d=t?a.querySelector(`.${l}-flow__handle[data-id="${c}-${t==null?void 0:t.nodeId}-${t==null?void 0:t.id}-${t==null?void 0:t.type}"]`):null,{x:m,y}=li(e),v=a.elementFromPoint(m,y),b=v!=null&&v.classList.contains(`${l}-flow__handle`)?v:d,g={handleDomNode:b,isValid:!1,connection:null,toHandle:null};if(b){const k=vT(void 0,b),x=b.getAttribute("data-nodeid"),_=b.getAttribute("data-handleid"),j=b.classList.contains("connectable"),N=b.classList.contains("connectableend");if(!x||!k)return g;const P={source:p?x:r,sourceHandle:p?_:i,target:p?r:x,targetHandle:p?i:_};g.connection=P;const z=j&&N&&(n===Kc.Strict?p&&k==="source"||!p&&k==="target":x!==r||_!==i);g.isValid=z&&u(P),g.toHandle=kT(x,k,_,f,n,!0)}return g}const xb={onPointerDown:bH,isValid:jT};function kH({domNode:e,panZoom:t,getTransform:n,getViewScale:r}){const i=ys(e);function o({translateExtent:l,width:c,height:u,zoomStep:f=1,pannable:p=!0,zoomable:d=!0,inversePan:m=!1}){const y=x=>{if(x.sourceEvent.type!=="wheel"||!t)return;const _=n(),j=x.sourceEvent.ctrlKey&&df()?10:1,N=-x.sourceEvent.deltaY*(x.sourceEvent.deltaMode===1?.05:x.sourceEvent.deltaMode?1:.002)*f,P=_[2]*Math.pow(2,N*j);t.scaleTo(P)};let v=[0,0];const b=x=>{(x.sourceEvent.type==="mousedown"||x.sourceEvent.type==="touchstart")&&(v=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY])},g=x=>{const _=n();if(x.sourceEvent.type!=="mousemove"&&x.sourceEvent.type!=="touchmove"||!t)return;const j=[x.sourceEvent.clientX??x.sourceEvent.touches[0].clientX,x.sourceEvent.clientY??x.sourceEvent.touches[0].clientY],N=[j[0]-v[0],j[1]-v[1]];v=j;const P=r()*Math.max(_[2],Math.log(_[2]))*(m?-1:1),T={x:_[0]-N[0]*P,y:_[1]-N[1]*P},z=[[0,0],[c,u]];t.setViewportConstrained({x:T.x,y:T.y,zoom:_[2]},z,l)},k=QP().on("start",b).on("zoom",p?g:null).on("zoom.wheel",d?y:null);i.call(k,{})}function a(){i.on("zoom",null)}return{update:o,destroy:a,pointer:ri}}const Ng=e=>({x:e.x,y:e.y,zoom:e.k}),gw=({x:e,y:t,zoom:n})=>vg.translate(e,t).scale(n),yc=(e,t)=>e.target.closest(`.${t}`),NT=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),vH=e=>((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2,yw=(e,t=0,n=vH,r=()=>{})=>{const i=typeof t=="number"&&t>0;return i||r(),i?e.transition().duration(t).ease(n).on("end",r):e},_T=e=>{const t=e.ctrlKey&&df()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t};function SH({zoomPanValues:e,noWheelClassName:t,d3Selection:n,d3Zoom:r,panOnScrollMode:i,panOnScrollSpeed:o,zoomOnPinch:a,onPanZoomStart:l,onPanZoom:c,onPanZoomEnd:u}){return f=>{if(yc(f,t))return f.ctrlKey&&f.preventDefault(),!1;f.preventDefault(),f.stopImmediatePropagation();const p=n.property("__zoom").k||1;if(f.ctrlKey&&a){const b=ri(f),g=_T(f),k=p*Math.pow(2,g);r.scaleTo(n,k,b,f);return}const d=f.deltaMode===1?20:1;let m=i===Za.Vertical?0:f.deltaX*d,y=i===Za.Horizontal?0:f.deltaY*d;!df()&&f.shiftKey&&i!==Za.Vertical&&(m=f.deltaY*d,y=0),r.translateBy(n,-(m/p)*o,-(y/p)*o,{internal:!0});const v=Ng(n.property("__zoom"));clearTimeout(e.panScrollTimeout),e.isPanScrolling?(c==null||c(f,v),e.panScrollTimeout=setTimeout(()=>{u==null||u(f,v),e.isPanScrolling=!1},150)):(e.isPanScrolling=!0,l==null||l(f,v))}}function jH({noWheelClassName:e,preventScrolling:t,d3ZoomHandler:n}){return function(r,i){const o=r.type==="wheel",a=!t&&o&&!r.ctrlKey,l=yc(r,e);if(r.ctrlKey&&o&&l&&r.preventDefault(),a||l)return null;r.preventDefault(),n.call(this,r,i)}}function NH({zoomPanValues:e,onDraggingChange:t,onPanZoomStart:n}){return r=>{var o,a,l;if((o=r.sourceEvent)!=null&&o.internal)return;const i=Ng(r.transform);e.mouseButton=((a=r.sourceEvent)==null?void 0:a.button)||0,e.isZoomingOrPanning=!0,e.prevViewport=i,((l=r.sourceEvent)==null?void 0:l.type)==="mousedown"&&t(!0),n&&(n==null||n(r.sourceEvent,i))}}function _H({zoomPanValues:e,panOnDrag:t,onPaneContextMenu:n,onTransformChange:r,onPanZoom:i}){return o=>{var a,l;e.usedRightMouseButton=!!(n&&NT(t,e.mouseButton??0)),(a=o.sourceEvent)!=null&&a.sync||r([o.transform.x,o.transform.y,o.transform.k]),i&&!((l=o.sourceEvent)!=null&&l.internal)&&(i==null||i(o.sourceEvent,Ng(o.transform)))}}function CH({zoomPanValues:e,panOnDrag:t,panOnScroll:n,onDraggingChange:r,onPanZoomEnd:i,onPaneContextMenu:o}){return a=>{var l;if(!((l=a.sourceEvent)!=null&&l.internal)&&(e.isZoomingOrPanning=!1,o&&NT(t,e.mouseButton??0)&&!e.usedRightMouseButton&&a.sourceEvent&&o(a.sourceEvent),e.usedRightMouseButton=!1,r(!1),i)){const c=Ng(a.transform);e.prevViewport=c,clearTimeout(e.timerId),e.timerId=setTimeout(()=>{i==null||i(a.sourceEvent,c)},n?150:0)}}}function AH({zoomActivationKeyPressed:e,zoomOnScroll:t,zoomOnPinch:n,panOnDrag:r,panOnScroll:i,zoomOnDoubleClick:o,userSelectionActive:a,noWheelClassName:l,noPanClassName:c,lib:u,connectionInProgress:f}){return p=>{var b;const d=e||t,m=n&&p.ctrlKey,y=p.type==="wheel";if(p.button===1&&p.type==="mousedown"&&(yc(p,`${u}-flow__node`)||yc(p,`${u}-flow__edge`)))return!0;if(!r&&!d&&!i&&!o&&!n||a||f&&!y||yc(p,l)&&y||yc(p,c)&&(!y||i&&y&&!e)||!n&&p.ctrlKey&&y)return!1;if(!n&&p.type==="touchstart"&&((b=p.touches)==null?void 0:b.length)>1)return p.preventDefault(),!1;if(!d&&!i&&!m&&y||!r&&(p.type==="mousedown"||p.type==="touchstart")||Array.isArray(r)&&!r.includes(p.button)&&p.type==="mousedown")return!1;const v=Array.isArray(r)&&r.includes(p.button)||!p.button||p.button<=1;return(!p.ctrlKey||y)&&v}}function EH({domNode:e,minZoom:t,maxZoom:n,translateExtent:r,viewport:i,onPanZoom:o,onPanZoomStart:a,onPanZoomEnd:l,onDraggingChange:c}){const u={isZoomingOrPanning:!1,usedRightMouseButton:!1,prevViewport:{},mouseButton:0,timerId:void 0,panScrollTimeout:void 0,isPanScrolling:!1},f=e.getBoundingClientRect(),p=QP().scaleExtent([t,n]).translateExtent(r),d=ys(e).call(p);k({x:i.x,y:i.y,zoom:qc(i.zoom,t,n)},[[0,0],[f.width,f.height]],r);const m=d.on("wheel.zoom"),y=d.on("dblclick.zoom");p.wheelDelta(_T);function v(O,D){return d?new Promise(L=>{p==null||p.interpolate((D==null?void 0:D.interpolate)==="linear"?Id:$h).transform(yw(d,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>L(!0)),O)}):Promise.resolve(!1)}function b({noWheelClassName:O,noPanClassName:D,onPaneContextMenu:L,userSelectionActive:$,panOnScroll:V,panOnDrag:W,panOnScrollMode:F,panOnScrollSpeed:M,preventScrolling:H,zoomOnPinch:A,zoomOnScroll:X,zoomOnDoubleClick:q,zoomActivationKeyPressed:B,lib:ne,onTransformChange:ce,connectionInProgress:K,paneClickDistance:ee,selectionOnDrag:re}){$&&!u.isZoomingOrPanning&&g();const se=V&&!B&&!$;p.clickDistance(re?1/0:!ai(ee)||ee<0?0:ee);const Q=se?SH({zoomPanValues:u,noWheelClassName:O,d3Selection:d,d3Zoom:p,panOnScrollMode:F,panOnScrollSpeed:M,zoomOnPinch:A,onPanZoomStart:a,onPanZoom:o,onPanZoomEnd:l}):jH({noWheelClassName:O,preventScrolling:H,d3ZoomHandler:m});if(d.on("wheel.zoom",Q,{passive:!1}),!$){const fe=NH({zoomPanValues:u,onDraggingChange:c,onPanZoomStart:a});p.on("start",fe);const me=_H({zoomPanValues:u,panOnDrag:W,onPaneContextMenu:!!L,onPanZoom:o,onTransformChange:ce});p.on("zoom",me);const De=CH({zoomPanValues:u,panOnDrag:W,panOnScroll:V,onPaneContextMenu:L,onPanZoomEnd:l,onDraggingChange:c});p.on("end",De)}const le=AH({zoomActivationKeyPressed:B,panOnDrag:W,zoomOnScroll:X,panOnScroll:V,zoomOnDoubleClick:q,zoomOnPinch:A,userSelectionActive:$,noPanClassName:D,noWheelClassName:O,lib:ne,connectionInProgress:K});p.filter(le),q?d.on("dblclick.zoom",y):d.on("dblclick.zoom",null)}function g(){p.on("zoom",null)}async function k(O,D,L){const $=gw(O),V=p==null?void 0:p.constrain()($,D,L);return V&&await v(V),new Promise(W=>W(V))}async function x(O,D){const L=gw(O);return await v(L,D),new Promise($=>$(L))}function _(O){if(d){const D=gw(O),L=d.property("__zoom");(L.k!==O.zoom||L.x!==O.x||L.y!==O.y)&&(p==null||p.transform(d,D,null,{sync:!0}))}}function j(){const O=d?XP(d.node()):{x:0,y:0,k:1};return{x:O.x,y:O.y,zoom:O.k}}function N(O,D){return d?new Promise(L=>{p==null||p.interpolate((D==null?void 0:D.interpolate)==="linear"?Id:$h).scaleTo(yw(d,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>L(!0)),O)}):Promise.resolve(!1)}function P(O,D){return d?new Promise(L=>{p==null||p.interpolate((D==null?void 0:D.interpolate)==="linear"?Id:$h).scaleBy(yw(d,D==null?void 0:D.duration,D==null?void 0:D.ease,()=>L(!0)),O)}):Promise.resolve(!1)}function T(O){p==null||p.scaleExtent(O)}function z(O){p==null||p.translateExtent(O)}function E(O){const D=!ai(O)||O<0?0:O;p==null||p.clickDistance(D)}return{update:b,destroy:g,setViewport:x,setViewportConstrained:k,getViewport:j,scaleTo:N,scaleBy:P,setScaleExtent:T,setTranslateExtent:z,syncViewport:_,setClickDistance:E}}var Yc;(function(e){e.Line="line",e.Handle="handle"})(Yc||(Yc={}));function IH({width:e,prevWidth:t,height:n,prevHeight:r,affectsX:i,affectsY:o}){const a=e-t,l=n-r,c=[a>0?1:a<0?-1:0,l>0?1:l<0?-1:0];return a&&i&&(c[0]=c[0]*-1),l&&o&&(c[1]=c[1]*-1),c}function x_(e){const t=e.includes("right")||e.includes("left"),n=e.includes("bottom")||e.includes("top"),r=e.includes("left"),i=e.includes("top");return{isHorizontal:t,isVertical:n,affectsX:r,affectsY:i}}function Do(e,t){return Math.max(0,t-e)}function Fo(e,t){return Math.max(0,e-t)}function Qp(e,t,n){return Math.max(0,t-e,e-n)}function b_(e,t){return e?!t:t}function PH(e,t,n,r,i,o,a,l){let{affectsX:c,affectsY:u}=t;const{isHorizontal:f,isVertical:p}=t,d=f&&p,{xSnapped:m,ySnapped:y}=n,{minWidth:v,maxWidth:b,minHeight:g,maxHeight:k}=r,{x,y:_,width:j,height:N,aspectRatio:P}=e;let T=Math.floor(f?m-e.pointerX:0),z=Math.floor(p?y-e.pointerY:0);const E=j+(c?-T:T),O=N+(u?-z:z),D=-o[0]*j,L=-o[1]*N;let $=Qp(E,v,b),V=Qp(O,g,k);if(a){let M=0,H=0;c&&T<0?M=Do(x+T+D,a[0][0]):!c&&T>0&&(M=Fo(x+E+D,a[1][0])),u&&z<0?H=Do(_+z+L,a[0][1]):!u&&z>0&&(H=Fo(_+O+L,a[1][1])),$=Math.max($,M),V=Math.max(V,H)}if(l){let M=0,H=0;c&&T>0?M=Fo(x+T,l[0][0]):!c&&T<0&&(M=Do(x+E,l[1][0])),u&&z>0?H=Fo(_+z,l[0][1]):!u&&z<0&&(H=Do(_+O,l[1][1])),$=Math.max($,M),V=Math.max(V,H)}if(i){if(f){const M=Qp(E/P,g,k)*P;if($=Math.max($,M),a){let H=0;!c&&!u||c&&!u&&d?H=Fo(_+L+E/P,a[1][1])*P:H=Do(_+L+(c?T:-T)/P,a[0][1])*P,$=Math.max($,H)}if(l){let H=0;!c&&!u||c&&!u&&d?H=Do(_+E/P,l[1][1])*P:H=Fo(_+(c?T:-T)/P,l[0][1])*P,$=Math.max($,H)}}if(p){const M=Qp(O*P,v,b)/P;if(V=Math.max(V,M),a){let H=0;!c&&!u||u&&!c&&d?H=Fo(x+O*P+D,a[1][0])/P:H=Do(x+(u?z:-z)*P+D,a[0][0])/P,V=Math.max(V,H)}if(l){let H=0;!c&&!u||u&&!c&&d?H=Do(x+O*P,l[1][0])/P:H=Fo(x+(u?z:-z)*P,l[0][0])/P,V=Math.max(V,H)}}}z=z+(z<0?V:-V),T=T+(T<0?$:-$),i&&(d?E>O*P?z=(b_(c,u)?-T:T)/P:T=(b_(c,u)?-z:z)*P:f?(z=T/P,u=c):(T=z*P,c=u));const W=c?x+T:x,F=u?_+z:_;return{width:j+(c?-T:T),height:N+(u?-z:z),x:o[0]*T*(c?-1:1)+W,y:o[1]*z*(u?-1:1)+F}}const CT={width:0,height:0,x:0,y:0},TH={...CT,pointerX:0,pointerY:0,aspectRatio:1};function RH(e){return[[0,0],[e.measured.width,e.measured.height]]}function MH(e,t,n){const r=t.position.x+e.position.x,i=t.position.y+e.position.y,o=e.measured.width??0,a=e.measured.height??0,l=n[0]*o,c=n[1]*a;return[[r-l,i-c],[r+o-l,i+a-c]]}function $H({domNode:e,nodeId:t,getStoreItems:n,onChange:r,onEnd:i}){const o=ys(e);let a={controlDirection:x_("bottom-right"),boundaries:{minWidth:0,minHeight:0,maxWidth:Number.MAX_VALUE,maxHeight:Number.MAX_VALUE},resizeDirection:void 0,keepAspectRatio:!1};function l({controlPosition:u,boundaries:f,keepAspectRatio:p,resizeDirection:d,onResizeStart:m,onResize:y,onResizeEnd:v,shouldResize:b}){let g={...CT},k={...TH};a={boundaries:f,resizeDirection:d,keepAspectRatio:p,controlDirection:x_(u)};let x,_=null,j=[],N,P,T,z=!1;const E=OP().on("start",O=>{const{nodeLookup:D,transform:L,snapGrid:$,snapToGrid:V,nodeOrigin:W,paneDomNode:F}=n();if(x=D.get(t),!x)return;_=(F==null?void 0:F.getBoundingClientRect())??null;const{xSnapped:M,ySnapped:H}=Pd(O.sourceEvent,{transform:L,snapGrid:$,snapToGrid:V,containerBounds:_});g={width:x.measured.width??0,height:x.measured.height??0,x:x.position.x??0,y:x.position.y??0},k={...g,pointerX:M,pointerY:H,aspectRatio:g.width/g.height},N=void 0,x.parentId&&(x.extent==="parent"||x.expandParent)&&(N=D.get(x.parentId),P=N&&x.extent==="parent"?RH(N):void 0),j=[],T=void 0;for(const[A,X]of D)if(X.parentId===t&&(j.push({id:A,position:{...X.position},extent:X.extent}),X.extent==="parent"||X.expandParent)){const q=MH(X,x,X.origin??W);T?T=[[Math.min(q[0][0],T[0][0]),Math.min(q[0][1],T[0][1])],[Math.max(q[1][0],T[1][0]),Math.max(q[1][1],T[1][1])]]:T=q}m==null||m(O,{...g})}).on("drag",O=>{const{transform:D,snapGrid:L,snapToGrid:$,nodeOrigin:V}=n(),W=Pd(O.sourceEvent,{transform:D,snapGrid:L,snapToGrid:$,containerBounds:_}),F=[];if(!x)return;const{x:M,y:H,width:A,height:X}=g,q={},B=x.origin??V,{width:ne,height:ce,x:K,y:ee}=PH(k,a.controlDirection,W,a.boundaries,a.keepAspectRatio,B,P,T),re=ne!==A,se=ce!==X,Q=K!==M&&re,le=ee!==H&&se;if(!Q&&!le&&!re&&!se)return;if((Q||le||B[0]===1||B[1]===1)&&(q.x=Q?K:g.x,q.y=le?ee:g.y,g.x=q.x,g.y=q.y,j.length>0)){const Ce=K-M,Se=ee-H;for(const Ue of j)Ue.position={x:Ue.position.x-Ce+B[0]*(ne-A),y:Ue.position.y-Se+B[1]*(ce-X)},F.push(Ue)}if((re||se)&&(q.width=re&&(!a.resizeDirection||a.resizeDirection==="horizontal")?ne:g.width,q.height=se&&(!a.resizeDirection||a.resizeDirection==="vertical")?ce:g.height,g.width=q.width,g.height=q.height),N&&x.expandParent){const Ce=B[0]*(q.width??0);q.x&&q.x<Ce&&(g.x=Ce,k.x=k.x-(q.x-Ce));const Se=B[1]*(q.height??0);q.y&&q.y<Se&&(g.y=Se,k.y=k.y-(q.y-Se))}const fe=IH({width:g.width,prevWidth:A,height:g.height,prevHeight:X,affectsX:a.controlDirection.affectsX,affectsY:a.controlDirection.affectsY}),me={...g,direction:fe};(b==null?void 0:b(O,me))!==!1&&(z=!0,y==null||y(O,me),r(q,F))}).on("end",O=>{z&&(v==null||v(O,{...g}),i==null||i({...g}),z=!1)});o.call(E)}function c(){o.on(".drag",null)}return{update:l,destroy:c}}var AT={exports:{}},ET={},IT={exports:{}},PT={};/**
|
|
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 Jc=h;function LH(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var OH=typeof Object.is=="function"?Object.is:LH,DH=Jc.useState,FH=Jc.useEffect,zH=Jc.useLayoutEffect,BH=Jc.useDebugValue;function WH(e,t){var n=t(),r=DH({inst:{value:n,getSnapshot:t}}),i=r[0].inst,o=r[1];return zH(function(){i.value=n,i.getSnapshot=t,ww(i)&&o({inst:i})},[e,n,t]),FH(function(){return ww(i)&&o({inst:i}),e(function(){ww(i)&&o({inst:i})})},[e]),BH(n),n}function ww(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!OH(e,n)}catch{return!0}}function HH(e,t){return t()}var VH=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?HH:WH;PT.useSyncExternalStore=Jc.useSyncExternalStore!==void 0?Jc.useSyncExternalStore:VH;IT.exports=PT;var TT=IT.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 _g=h,KH=TT;function qH(e,t){return e===t&&(e!==0||1/e===1/t)||e!==e&&t!==t}var UH=typeof Object.is=="function"?Object.is:qH,GH=KH.useSyncExternalStore,YH=_g.useRef,JH=_g.useEffect,XH=_g.useMemo,QH=_g.useDebugValue;ET.useSyncExternalStoreWithSelector=function(e,t,n,r,i){var o=YH(null);if(o.current===null){var a={hasValue:!1,value:null};o.current=a}else a=o.current;o=XH(function(){function c(m){if(!u){if(u=!0,f=m,m=r(m),i!==void 0&&a.hasValue){var y=a.value;if(i(y,m))return p=y}return p=m}if(y=p,UH(f,m))return y;var v=r(m);return i!==void 0&&i(y,v)?(f=m,y):(f=m,p=v)}var u=!1,f,p,d=n===void 0?null:n;return[function(){return c(t())},d===null?void 0:function(){return c(d())}]},[t,n,r,i]);var l=GH(e,o[0],o[1]);return JH(function(){a.hasValue=!0,a.value=l},[l]),QH(l),l};AT.exports=ET;var ZH=AT.exports;const e5=xa(ZH),t5={},k_=e=>{let t;const n=new Set,r=(f,p)=>{const d=typeof f=="function"?f(t):f;if(!Object.is(d,t)){const m=t;t=p??(typeof d!="object"||d===null)?d:Object.assign({},t,d),n.forEach(y=>y(t,m))}},i=()=>t,c={setState:r,getState:i,getInitialState:()=>u,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(t5?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},u=t=e(r,i,c);return c},n5=e=>e?k_(e):k_,{useDebugValue:r5}=ft,{useSyncExternalStoreWithSelector:s5}=e5,i5=e=>e;function RT(e,t=i5,n){const r=s5(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return r5(r),r}const v_=(e,t)=>{const n=n5(e),r=(i,o=t)=>RT(n,i,o);return Object.assign(r,n),r},o5=(e,t)=>e?v_(e,t):v_;function Mn(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,i]of e)if(!Object.is(i,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 Cg=h.createContext(null),a5=Cg.Provider,MT=Bi.error001();function Yt(e,t){const n=h.useContext(Cg);if(n===null)throw new Error(MT);return RT(n,e,t)}function vn(){const e=h.useContext(Cg);if(e===null)throw new Error(MT);return h.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe}),[e])}const S_={display:"none"},l5={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},$T="react-flow__node-desc",LT="react-flow__edge-desc",c5="react-flow__aria-live",u5=e=>e.ariaLiveMessage,d5=e=>e.ariaLabelConfig;function f5({rfId:e}){const t=Yt(u5);return s.jsx("div",{id:`${c5}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:l5,children:t})}function p5({rfId:e,disableKeyboardA11y:t}){const n=Yt(d5);return s.jsxs(s.Fragment,{children:[s.jsx("div",{id:`${$T}-${e}`,style:S_,children:t?n["node.a11yDescription.default"]:n["node.a11yDescription.keyboardDisabled"]}),s.jsx("div",{id:`${LT}-${e}`,style:S_,children:n["edge.a11yDescription.default"]}),!t&&s.jsx(f5,{rfId:e})]})}const Ag=h.forwardRef(({position:e="top-left",children:t,className:n,style:r,...i},o)=>{const a=`${e}`.split("-");return s.jsx("div",{className:lr(["react-flow__panel",n,...a]),style:r,ref:o,...i,children:t})});Ag.displayName="Panel";function h5({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:s.jsx(Ag,{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:s.jsx("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution",children:"React Flow"})})}const m5=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}},Zp=e=>e.id;function g5(e,t){return Mn(e.selectedNodes.map(Zp),t.selectedNodes.map(Zp))&&Mn(e.selectedEdges.map(Zp),t.selectedEdges.map(Zp))}function y5({onSelectionChange:e}){const t=vn(),{selectedNodes:n,selectedEdges:r}=Yt(m5,g5);return h.useEffect(()=>{const i={nodes:n,edges:r};e==null||e(i),t.getState().onSelectionChangeHandlers.forEach(o=>o(i))},[n,r,e]),null}const w5=e=>!!e.onSelectionChangeHandlers;function x5({onSelectionChange:e}){const t=Yt(w5);return e||t?s.jsx(y5,{onSelectionChange:e}):null}const bb=typeof window<"u"?h.useLayoutEffect:h.useEffect,OT=[0,0],b5={x:0,y:0,zoom:1},k5=["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"],j_=[...k5,"rfId"],v5=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}),N_={translateExtent:lf,nodeOrigin:OT,minZoom:.5,maxZoom:2,elementsSelectable:!0,noPanClassName:"nopan",rfId:"1"};function S5(e){const{setNodes:t,setEdges:n,setMinZoom:r,setMaxZoom:i,setTranslateExtent:o,setNodeExtent:a,reset:l,setDefaultNodesAndEdges:c}=Yt(v5,Mn),u=vn();bb(()=>(c(e.defaultNodes,e.defaultEdges),()=>{f.current=N_,l()}),[]);const f=h.useRef(N_);return bb(()=>{for(const p of j_){const d=e[p],m=f.current[p];d!==m&&(typeof e[p]>"u"||(p==="nodes"?t(d):p==="edges"?n(d):p==="minZoom"?r(d):p==="maxZoom"?i(d):p==="translateExtent"?o(d):p==="nodeExtent"?a(d):p==="ariaLabelConfig"?u.setState({ariaLabelConfig:G4(d)}):p==="fitView"?u.setState({fitViewQueued:d}):p==="fitViewOptions"?u.setState({fitViewOptions:d}):u.setState({[p]:d})))}f.current=e},j_.map(p=>e[p])),null}function __(){return typeof window>"u"||!window.matchMedia?null:window.matchMedia("(prefers-color-scheme: dark)")}function j5(e){var r;const[t,n]=h.useState(e==="system"?null:e);return h.useEffect(()=>{if(e!=="system"){n(e);return}const i=__(),o=()=>n(i!=null&&i.matches?"dark":"light");return o(),i==null||i.addEventListener("change",o),()=>{i==null||i.removeEventListener("change",o)}},[e]),t!==null?t:(r=__())!=null&&r.matches?"dark":"light"}const C_=typeof document<"u"?document:null;function ff(e=null,t={target:C_,actInsideInputWithModifier:!0}){const[n,r]=h.useState(!1),i=h.useRef(!1),o=h.useRef(new Set([])),[a,l]=h.useMemo(()=>{if(e!==null){const u=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.replace("+",`
|
|
61
|
+
`).replace(`
|
|
62
|
+
|
|
63
|
+
`,`
|
|
64
|
+
+`).split(`
|
|
65
|
+
`)),f=u.reduce((p,d)=>p.concat(...d),[]);return[u,f]}return[[],[]]},[e]);return h.useEffect(()=>{const c=(t==null?void 0:t.target)??C_,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const f=m=>{var b,g;if(i.current=m.ctrlKey||m.metaKey||m.shiftKey||m.altKey,(!i.current||i.current&&!u)&&dT(m))return!1;const v=E_(m.code,l);if(o.current.add(m[v]),A_(a,o.current,!1)){const k=((g=(b=m.composedPath)==null?void 0:b.call(m))==null?void 0:g[0])||m.target,x=(k==null?void 0:k.nodeName)==="BUTTON"||(k==null?void 0:k.nodeName)==="A";t.preventDefault!==!1&&(i.current||!x)&&m.preventDefault(),r(!0)}},p=m=>{const y=E_(m.code,l);A_(a,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(m[y]),m.key==="Meta"&&o.current.clear(),i.current=!1},d=()=>{o.current.clear(),r(!1)};return c==null||c.addEventListener("keydown",f),c==null||c.addEventListener("keyup",p),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{c==null||c.removeEventListener("keydown",f),c==null||c.removeEventListener("keyup",p),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,r]),n}function A_(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(i=>t.has(i)))}function E_(e,t){return t.includes(e)?"code":"key"}const N5=()=>{const e=vn();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,i,o],panZoom:a}=e.getState();return a?(await a.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??o},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:i,minZoom:o,maxZoom:a,panZoom:l}=e.getState(),c=fv(t,r,i,o,a,(n==null?void 0:n.padding)??.1);return l?(await l.setViewport(c,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:i,snapToGrid:o,domNode:a}=e.getState();if(!a)return t;const{x:l,y:c}=a.getBoundingClientRect(),u={x:t.x-l,y:t.y-c},f=n.snapGrid??i,p=n.snapToGrid??o;return Ff(u,r,p,f)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:i,y:o}=r.getBoundingClientRect(),a=_m(t,n);return{x:a.x+i,y:a.y+o}}}),[])};function DT(e,t){const n=[],r=new Map,i=[];for(const o of e)if(o.type==="add"){i.push(o);continue}else if(o.type==="remove"||o.type==="replace")r.set(o.id,[o]);else{const a=r.get(o.id);a?a.push(o):r.set(o.id,[o])}for(const o of t){const a=r.get(o.id);if(!a){n.push(o);continue}if(a[0].type==="remove")continue;if(a[0].type==="replace"){n.push({...a[0].item});continue}const l={...o};for(const c of a)_5(c,l);n.push(l)}return i.length&&i.forEach(o=>{o.index!==void 0?n.splice(o.index,0,{...o.item}):n.push({...o.item})}),n}function _5(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 Td(e,t){return DT(e,t)}function Cm(e,t){return DT(e,t)}function Da(e,t){return{id:e,type:"select",selected:t}}function wc(e,t=new Set,n=!1){const r=[];for(const[i,o]of e){const a=t.has(i);!(o.selected===void 0&&!a)&&o.selected!==a&&(n&&(o.selected=a),r.push(Da(o.id,a)))}return r}function I_({items:e=[],lookup:t}){var i;const n=[],r=new Map(e.map(o=>[o.id,o]));for(const[o,a]of e.entries()){const l=t.get(a.id),c=((i=l==null?void 0:l.internals)==null?void 0:i.userNode)??l;c!==void 0&&c!==a&&n.push({id:a.id,item:a,type:"replace"}),c===void 0&&n.push({item:a,type:"add",index:o})}for(const[o]of t)r.get(o)===void 0&&n.push({id:o,type:"remove"});return n}function P_(e){return{id:e.id,type:"remove"}}const T_=e=>D4(e),C5=e=>rT(e);function FT(e){return h.forwardRef(e)}function R_(e){const[t,n]=h.useState(BigInt(0)),[r]=h.useState(()=>A5(()=>n(i=>i+BigInt(1))));return bb(()=>{const i=r.get();i.length&&(e(i),r.reset())},[t]),r}function A5(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const zT=h.createContext(null);function E5({children:e}){const t=vn(),n=h.useCallback(l=>{const{nodes:c=[],setNodes:u,hasDefaultNodes:f,onNodesChange:p,nodeLookup:d,fitViewQueued:m,onNodesChangeMiddlewareMap:y}=t.getState();let v=c;for(const g of l)v=typeof g=="function"?g(v):g;let b=I_({items:v,lookup:d});for(const g of y.values())b=g(b);f&&u(v),b.length>0?p==null||p(b):m&&window.requestAnimationFrame(()=>{const{fitViewQueued:g,nodes:k,setNodes:x}=t.getState();g&&x(k)})},[]),r=R_(n),i=h.useCallback(l=>{const{edges:c=[],setEdges:u,hasDefaultEdges:f,onEdgesChange:p,edgeLookup:d}=t.getState();let m=c;for(const y of l)m=typeof y=="function"?y(m):y;f?u(m):p&&p(I_({items:m,lookup:d}))},[]),o=R_(i),a=h.useMemo(()=>({nodeQueue:r,edgeQueue:o}),[]);return s.jsx(zT.Provider,{value:a,children:e})}function I5(){const e=h.useContext(zT);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const P5=e=>!!e.panZoom;function su(){const e=N5(),t=vn(),n=I5(),r=Yt(P5),i=h.useMemo(()=>{const o=p=>t.getState().nodeLookup.get(p),a=p=>{n.nodeQueue.push(p)},l=p=>{n.edgeQueue.push(p)},c=p=>{var g,k;const{nodeLookup:d,nodeOrigin:m}=t.getState(),y=T_(p)?p:d.get(p.id),v=y.parentId?cT(y.position,y.measured,y.parentId,d,m):y.position,b={...y,position:v,width:((g=y.measured)==null?void 0:g.width)??y.width,height:((k=y.measured)==null?void 0:k.height)??y.height};return Uc(b)},u=(p,d,m={replace:!1})=>{a(y=>y.map(v=>{if(v.id===p){const b=typeof d=="function"?d(v):d;return m.replace&&T_(b)?b:{...v,...b}}return v}))},f=(p,d,m={replace:!1})=>{l(y=>y.map(v=>{if(v.id===p){const b=typeof d=="function"?d(v):d;return m.replace&&C5(b)?b:{...v,...b}}return v}))};return{getNodes:()=>t.getState().nodes.map(p=>({...p})),getNode:p=>{var d;return(d=o(p))==null?void 0:d.internals.userNode},getInternalNode:o,getEdges:()=>{const{edges:p=[]}=t.getState();return p.map(d=>({...d}))},getEdge:p=>t.getState().edgeLookup.get(p),setNodes:a,setEdges:l,addNodes:p=>{const d=Array.isArray(p)?p:[p];n.nodeQueue.push(m=>[...m,...d])},addEdges:p=>{const d=Array.isArray(p)?p:[p];n.edgeQueue.push(m=>[...m,...d])},toObject:()=>{const{nodes:p=[],edges:d=[],transform:m}=t.getState(),[y,v,b]=m;return{nodes:p.map(g=>({...g})),edges:d.map(g=>({...g})),viewport:{x:y,y:v,zoom:b}}},deleteElements:async({nodes:p=[],edges:d=[]})=>{const{nodes:m,edges:y,onNodesDelete:v,onEdgesDelete:b,triggerNodeChanges:g,triggerEdgeChanges:k,onDelete:x,onBeforeDelete:_}=t.getState(),{nodes:j,edges:N}=await H4({nodesToRemove:p,edgesToRemove:d,nodes:m,edges:y,onBeforeDelete:_}),P=N.length>0,T=j.length>0;if(P){const z=N.map(P_);b==null||b(N),k(z)}if(T){const z=j.map(P_);v==null||v(j),g(z)}return(T||P)&&(x==null||x({nodes:j,edges:N})),{deletedNodes:j,deletedEdges:N}},getIntersectingNodes:(p,d=!0,m)=>{const y=l_(p),v=y?p:c(p),b=m!==void 0;return v?(m||t.getState().nodes).filter(g=>{const k=t.getState().nodeLookup.get(g.id);if(k&&!y&&(g.id===p.id||!k.internals.positionAbsolute))return!1;const x=Uc(b?g:k),_=uf(x,v);return d&&_>0||_>=x.width*x.height||_>=v.width*v.height}):[]},isNodeIntersecting:(p,d,m=!0)=>{const v=l_(p)?p:c(p);if(!v)return!1;const b=uf(v,d);return m&&b>0||b>=d.width*d.height||b>=v.width*v.height},updateNode:u,updateNodeData:(p,d,m={replace:!1})=>{u(p,y=>{const v=typeof d=="function"?d(y):d;return m.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},m)},updateEdge:f,updateEdgeData:(p,d,m={replace:!1})=>{f(p,y=>{const v=typeof d=="function"?d(y):d;return m.replace?{...y,data:v}:{...y,data:{...y.data,...v}}},m)},getNodesBounds:p=>{const{nodeLookup:d,nodeOrigin:m}=t.getState();return F4(p,{nodeLookup:d,nodeOrigin:m})},getHandleConnections:({type:p,id:d,nodeId:m})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${m}-${p}${d?`-${d}`:""}`))==null?void 0:y.values())??[])},getNodeConnections:({type:p,handleId:d,nodeId:m})=>{var y;return Array.from(((y=t.getState().connectionLookup.get(`${m}${p?d?`-${p}-${d}`:`-${p}`:""}`))==null?void 0:y.values())??[])},fitView:async p=>{const d=t.getState().fitViewResolver??U4();return t.setState({fitViewQueued:!0,fitViewOptions:p,fitViewResolver:d}),n.nodeQueue.push(m=>[...m]),d.promise}}},[]);return h.useMemo(()=>({...i,...e,viewportInitialized:r}),[r])}const M_=e=>e.selected,T5=typeof window<"u"?window:void 0;function R5({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=vn(),{deleteElements:r}=su(),i=ff(e,{actInsideInputWithModifier:!1}),o=ff(t,{target:T5});h.useEffect(()=>{if(i){const{edges:a,nodes:l}=n.getState();r({nodes:l.filter(M_),edges:a.filter(M_)}),n.setState({nodesSelectionActive:!1})}},[i]),h.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])}function M5(e){const t=vn();h.useEffect(()=>{const n=()=>{var i,o,a,l;if(!e.current||!(((o=(i=e.current).checkVisibility)==null?void 0:o.call(i))??!0))return!1;const r=pv(e.current);(r.height===0||r.width===0)&&((l=(a=t.getState()).onError)==null||l.call(a,"004",Bi.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const Eg={position:"absolute",width:"100%",height:"100%",top:0,left:0},$5=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function L5({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:o=Za.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:u,minZoom:f,maxZoom:p,zoomActivationKeyCode:d,preventScrolling:m=!0,children:y,noWheelClassName:v,noPanClassName:b,onViewportChange:g,isControlledViewport:k,paneClickDistance:x,selectionOnDrag:_}){const j=vn(),N=h.useRef(null),{userSelectionActive:P,lib:T,connectionInProgress:z}=Yt($5,Mn),E=ff(d),O=h.useRef();M5(N);const D=h.useCallback(L=>{g==null||g({x:L[0],y:L[1],zoom:L[2]}),k||j.setState({transform:L})},[g,k]);return h.useEffect(()=>{if(N.current){O.current=EH({domNode:N.current,minZoom:f,maxZoom:p,translateExtent:u,viewport:c,onDraggingChange:W=>j.setState(F=>F.paneDragging===W?F:{paneDragging:W}),onPanZoomStart:(W,F)=>{const{onViewportChangeStart:M,onMoveStart:H}=j.getState();H==null||H(W,F),M==null||M(F)},onPanZoom:(W,F)=>{const{onViewportChange:M,onMove:H}=j.getState();H==null||H(W,F),M==null||M(F)},onPanZoomEnd:(W,F)=>{const{onViewportChangeEnd:M,onMoveEnd:H}=j.getState();H==null||H(W,F),M==null||M(F)}});const{x:L,y:$,zoom:V}=O.current.getViewport();return j.setState({panZoom:O.current,transform:[L,$,V],domNode:N.current.closest(".react-flow")}),()=>{var W;(W=O.current)==null||W.destroy()}}},[]),h.useEffect(()=>{var L;(L=O.current)==null||L.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:o,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:E,preventScrolling:m,noPanClassName:b,userSelectionActive:P,noWheelClassName:v,lib:T,onTransformChange:D,connectionInProgress:z,selectionOnDrag:_,paneClickDistance:x})},[e,t,n,r,i,o,a,l,E,m,b,P,v,T,D,z,_,x]),s.jsx("div",{className:"react-flow__renderer",ref:N,style:Eg,children:y})}const O5=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function D5(){const{userSelectionActive:e,userSelectionRect:t}=Yt(O5,Mn);return e&&t?s.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 xw=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},F5=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function z5({isSelecting:e,selectionKeyPressed:t,selectionMode:n=cf.Full,panOnDrag:r,paneClickDistance:i,selectionOnDrag:o,onSelectionStart:a,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:u,onPaneScroll:f,onPaneMouseEnter:p,onPaneMouseMove:d,onPaneMouseLeave:m,children:y}){const v=vn(),{userSelectionActive:b,elementsSelectable:g,dragging:k,connectionInProgress:x}=Yt(F5,Mn),_=g&&(e||b),j=h.useRef(null),N=h.useRef(),P=h.useRef(new Set),T=h.useRef(new Set),z=h.useRef(!1),E=M=>{if(z.current||x){z.current=!1;return}c==null||c(M),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},O=M=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){M.preventDefault();return}u==null||u(M)},D=f?M=>f(M):void 0,L=M=>{z.current&&(M.stopPropagation(),z.current=!1)},$=M=>{var ce,K;const{domNode:H}=v.getState();if(N.current=H==null?void 0:H.getBoundingClientRect(),!N.current)return;const A=M.target===j.current;if(!A&&!!M.target.closest(".nokey")||!e||!(o&&A||t)||M.button!==0||!M.isPrimary)return;(K=(ce=M.target)==null?void 0:ce.setPointerCapture)==null||K.call(ce,M.pointerId),z.current=!1;const{x:B,y:ne}=li(M.nativeEvent,N.current);v.setState({userSelectionRect:{width:0,height:0,startX:B,startY:ne,x:B,y:ne}}),A||(M.stopPropagation(),M.preventDefault())},V=M=>{const{userSelectionRect:H,transform:A,nodeLookup:X,edgeLookup:q,connectionLookup:B,triggerNodeChanges:ne,triggerEdgeChanges:ce,defaultEdgeOptions:K,resetSelectedElements:ee}=v.getState();if(!N.current||!H)return;const{x:re,y:se}=li(M.nativeEvent,N.current),{startX:Q,startY:le}=H;if(!z.current){const Se=t?0:i;if(Math.hypot(re-Q,se-le)<=Se)return;ee(),a==null||a(M)}z.current=!0;const fe={startX:Q,startY:le,x:re<Q?re:Q,y:se<le?se:le,width:Math.abs(re-Q),height:Math.abs(se-le)},me=P.current,De=T.current;P.current=new Set(dv(X,fe,A,n===cf.Partial,!0).map(Se=>Se.id)),T.current=new Set;const Ce=(K==null?void 0:K.selectable)??!0;for(const Se of P.current){const Ue=B.get(Se);if(Ue)for(const{edgeId:lt}of Ue.values()){const xt=q.get(lt);xt&&(xt.selectable??Ce)&&T.current.add(lt)}}if(!c_(me,P.current)){const Se=wc(X,P.current,!0);ne(Se)}if(!c_(De,T.current)){const Se=wc(q,T.current);ce(Se)}v.setState({userSelectionRect:fe,userSelectionActive:!0,nodesSelectionActive:!1})},W=M=>{var H,A;M.button===0&&((A=(H=M.target)==null?void 0:H.releasePointerCapture)==null||A.call(H,M.pointerId),!b&&M.target===j.current&&v.getState().userSelectionRect&&(E==null||E(M)),v.setState({userSelectionActive:!1,userSelectionRect:null}),z.current&&(l==null||l(M),v.setState({nodesSelectionActive:P.current.size>0})))},F=r===!0||Array.isArray(r)&&r.includes(0);return s.jsxs("div",{className:lr(["react-flow__pane",{draggable:F,dragging:k,selection:e}]),onClick:_?void 0:xw(E,j),onContextMenu:xw(O,j),onWheel:xw(D,j),onPointerEnter:_?void 0:p,onPointerMove:_?V:d,onPointerUp:_?W:void 0,onPointerDownCapture:_?$:void 0,onClickCapture:_?L:void 0,onPointerLeave:m,ref:j,style:Eg,children:[y,s.jsx(D5,{})]})}function kb({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:i,unselectNodesAndEdges:o,multiSelectionActive:a,nodeLookup:l,onError:c}=t.getState(),u=l.get(e);if(!u){c==null||c("012",Bi.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&a)&&(o({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):i([e])}function BT({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:o,nodeClickDistance:a}){const l=vn(),[c,u]=h.useState(!1),f=h.useRef();return h.useEffect(()=>{f.current=mH({getStoreItems:()=>l.getState(),onNodeMouseDown:p=>{kb({id:p,store:l,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}})},[]),h.useEffect(()=>{if(!(t||!e.current||!f.current))return f.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:o,nodeId:i,nodeClickDistance:a}),()=>{var p;(p=f.current)==null||p.destroy()}},[n,r,t,o,e,i,a]),c}const B5=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function WT(){const e=vn();return h.useCallback(n=>{const{nodeExtent:r,snapToGrid:i,snapGrid:o,nodesDraggable:a,onError:l,updateNodePositions:c,nodeLookup:u,nodeOrigin:f}=e.getState(),p=new Map,d=B5(a),m=i?o[0]:5,y=i?o[1]:5,v=n.direction.x*m*n.factor,b=n.direction.y*y*n.factor;for(const[,g]of u){if(!d(g))continue;let k={x:g.internals.positionAbsolute.x+v,y:g.internals.positionAbsolute.y+b};i&&(k=Df(k,o));const{position:x,positionAbsolute:_}=sT({nodeId:g.id,nextPosition:k,nodeLookup:u,nodeExtent:r,nodeOrigin:f,onError:l});g.position=x,g.internals.positionAbsolute=_,p.set(g.id,g)}c(p)},[])}const xv=h.createContext(null),W5=xv.Provider;xv.Consumer;const HT=()=>h.useContext(xv),H5=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),V5=(e,t,n)=>r=>{const{connectionClickStartHandle:i,connectionMode:o,connection:a}=r,{fromHandle:l,toHandle:c,isValid:u}=a,f=(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.id)===t&&(c==null?void 0:c.type)===n;return{connectingFrom:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n,connectingTo:f,clickConnecting:(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.id)===t&&(i==null?void 0:i.type)===n,isPossibleEndHandle:o===Kc.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:!!i,valid:f&&u}};function K5({type:e="source",position:t=Ge.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:o=!0,id:a,onConnect:l,children:c,className:u,onMouseDown:f,onTouchStart:p,...d},m){var V,W;const y=a||null,v=e==="target",b=vn(),g=HT(),{connectOnClick:k,noPanClassName:x,rfId:_}=Yt(H5,Mn),{connectingFrom:j,connectingTo:N,clickConnecting:P,isPossibleEndHandle:T,connectionInProcess:z,clickConnectionInProcess:E,valid:O}=Yt(V5(g,y,e),Mn);g||(W=(V=b.getState()).onError)==null||W.call(V,"010",Bi.error010());const D=F=>{const{defaultEdgeOptions:M,onConnect:H,hasDefaultEdges:A}=b.getState(),X={...M,...F};if(A){const{edges:q,setEdges:B}=b.getState();B(Fh(X,q))}H==null||H(X),l==null||l(X)},L=F=>{if(!g)return;const M=fT(F.nativeEvent);if(i&&(M&&F.button===0||!M)){const H=b.getState();xb.onPointerDown(F.nativeEvent,{handleDomNode:F.currentTarget,autoPanOnConnect:H.autoPanOnConnect,connectionMode:H.connectionMode,connectionRadius:H.connectionRadius,domNode:H.domNode,nodeLookup:H.nodeLookup,lib:H.lib,isTarget:v,handleId:y,nodeId:g,flowId:H.rfId,panBy:H.panBy,cancelConnection:H.cancelConnection,onConnectStart:H.onConnectStart,onConnectEnd:(...A)=>{var X,q;return(q=(X=b.getState()).onConnectEnd)==null?void 0:q.call(X,...A)},updateConnection:H.updateConnection,onConnect:D,isValidConnection:n||((...A)=>{var X,q;return((q=(X=b.getState()).isValidConnection)==null?void 0:q.call(X,...A))??!0}),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:H.autoPanSpeed,dragThreshold:H.connectionDragThreshold})}M?f==null||f(F):p==null||p(F)},$=F=>{const{onClickConnectStart:M,onClickConnectEnd:H,connectionClickStartHandle:A,connectionMode:X,isValidConnection:q,lib:B,rfId:ne,nodeLookup:ce,connection:K}=b.getState();if(!g||!A&&!i)return;if(!A){M==null||M(F.nativeEvent,{nodeId:g,handleId:y,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:g,type:e,id:y}});return}const ee=uT(F.target),re=n||q,{connection:se,isValid:Q}=xb.isValid(F.nativeEvent,{handle:{nodeId:g,id:y,type:e},connectionMode:X,fromNodeId:A.nodeId,fromHandleId:A.id||null,fromType:A.type,isValidConnection:re,flowId:ne,doc:ee,lib:B,nodeLookup:ce});Q&&se&&D(se);const le=structuredClone(K);delete le.inProgress,le.toPosition=le.toHandle?le.toHandle.position:null,H==null||H(F,le),b.setState({connectionClickStartHandle:null})};return s.jsx("div",{"data-handleid":y,"data-nodeid":g,"data-handlepos":t,"data-id":`${_}-${g}-${y}-${e}`,className:lr(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",x,u,{source:!v,target:v,connectable:r,connectablestart:i,connectableend:o,clickconnecting:P,connectingfrom:j,connectingto:N,valid:O,connectionindicator:r&&(!z||T)&&(z||E?o:i)}]),onMouseDown:L,onTouchStart:L,onClick:k?$:void 0,ref:m,...d,children:c})}const ar=h.memo(FT(K5));function q5({data:e,isConnectable:t,sourcePosition:n=Ge.Bottom}){return s.jsxs(s.Fragment,{children:[e==null?void 0:e.label,s.jsx(ar,{type:"source",position:n,isConnectable:t})]})}function U5({data:e,isConnectable:t,targetPosition:n=Ge.Top,sourcePosition:r=Ge.Bottom}){return s.jsxs(s.Fragment,{children:[s.jsx(ar,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,s.jsx(ar,{type:"source",position:r,isConnectable:t})]})}function G5(){return null}function Y5({data:e,isConnectable:t,targetPosition:n=Ge.Top}){return s.jsxs(s.Fragment,{children:[s.jsx(ar,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Am={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},$_={input:q5,default:U5,output:Y5,group:G5};function J5(e){var t,n,r,i;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??((i=e.style)==null?void 0:i.height)}}const X5=e=>{const{width:t,height:n,x:r,y:i}=Of(e.nodeLookup,{filter:o=>!!o.selected});return{width:ai(t)?t:null,height:ai(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function Q5({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=vn(),{width:i,height:o,transformString:a,userSelectionActive:l}=Yt(X5,Mn),c=WT(),u=h.useRef(null);h.useEffect(()=>{var m;n||(m=u.current)==null||m.focus({preventScroll:!0})},[n]);const f=!l&&i!==null&&o!==null;if(BT({nodeRef:u,disabled:!f}),!f)return null;const p=e?m=>{const y=r.getState().nodes.filter(v=>v.selected);e(m,y)}:void 0,d=m=>{Object.prototype.hasOwnProperty.call(Am,m.key)&&(m.preventDefault(),c({direction:Am[m.key],factor:m.shiftKey?4:1}))};return s.jsx("div",{className:lr(["react-flow__nodesselection","react-flow__container",t]),style:{transform:a},children:s.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:p,tabIndex:n?void 0:-1,onKeyDown:n?void 0:d,style:{width:i,height:o}})})}const L_=typeof window<"u"?window:void 0,Z5=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function VT({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:a,paneClickDistance:l,deleteKeyCode:c,selectionKeyCode:u,selectionOnDrag:f,selectionMode:p,onSelectionStart:d,onSelectionEnd:m,multiSelectionKeyCode:y,panActivationKeyCode:v,zoomActivationKeyCode:b,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:x,panOnScroll:_,panOnScrollSpeed:j,panOnScrollMode:N,zoomOnDoubleClick:P,panOnDrag:T,defaultViewport:z,translateExtent:E,minZoom:O,maxZoom:D,preventScrolling:L,onSelectionContextMenu:$,noWheelClassName:V,noPanClassName:W,disableKeyboardA11y:F,onViewportChange:M,isControlledViewport:H}){const{nodesSelectionActive:A,userSelectionActive:X}=Yt(Z5,Mn),q=ff(u,{target:L_}),B=ff(v,{target:L_}),ne=B||T,ce=B||_,K=f&&ne!==!0,ee=q||X||K;return R5({deleteKeyCode:c,multiSelectionKeyCode:y}),s.jsx(L5,{onPaneContextMenu:o,elementsSelectable:g,zoomOnScroll:k,zoomOnPinch:x,panOnScroll:ce,panOnScrollSpeed:j,panOnScrollMode:N,zoomOnDoubleClick:P,panOnDrag:!q&&ne,defaultViewport:z,translateExtent:E,minZoom:O,maxZoom:D,zoomActivationKeyCode:b,preventScrolling:L,noWheelClassName:V,noPanClassName:W,onViewportChange:M,isControlledViewport:H,paneClickDistance:l,selectionOnDrag:K,children:s.jsxs(z5,{onSelectionStart:d,onSelectionEnd:m,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:o,onPaneScroll:a,panOnDrag:ne,isSelecting:!!ee,selectionMode:p,selectionKeyPressed:q,paneClickDistance:l,selectionOnDrag:K,children:[e,A&&s.jsx(Q5,{onSelectionContextMenu:$,noPanClassName:W,disableKeyboardA11y:F})]})})}VT.displayName="FlowRenderer";const e6=h.memo(VT),t6=e=>t=>e?dv(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 n6(e){return Yt(h.useCallback(t6(e),[e]),Mn)}const r6=e=>e.updateNodeInternals;function s6(){const e=Yt(r6),[t]=h.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(i=>{const o=i.target.getAttribute("data-id");r.set(o,{id:o,nodeElement:i.target,force:!0})}),e(r)}));return h.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function i6({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const i=vn(),o=h.useRef(null),a=h.useRef(null),l=h.useRef(e.sourcePosition),c=h.useRef(e.targetPosition),u=h.useRef(t),f=n&&!!e.internals.handleBounds;return h.useEffect(()=>{o.current&&!e.hidden&&(!f||a.current!==o.current)&&(a.current&&(r==null||r.unobserve(a.current)),r==null||r.observe(o.current),a.current=o.current)},[f,e.hidden]),h.useEffect(()=>()=>{a.current&&(r==null||r.unobserve(a.current),a.current=null)},[]),h.useEffect(()=>{if(o.current){const p=u.current!==t,d=l.current!==e.sourcePosition,m=c.current!==e.targetPosition;(p||d||m)&&(u.current=t,l.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:o.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),o}function o6({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:o,onDoubleClick:a,nodesDraggable:l,elementsSelectable:c,nodesConnectable:u,nodesFocusable:f,resizeObserver:p,noDragClassName:d,noPanClassName:m,disableKeyboardA11y:y,rfId:v,nodeTypes:b,nodeClickDistance:g,onError:k}){const{node:x,internals:_,isParent:j}=Yt(re=>{const se=re.nodeLookup.get(e),Q=re.parentLookup.has(e);return{node:se,internals:se.internals,isParent:Q}},Mn);let N=x.type||"default",P=(b==null?void 0:b[N])||$_[N];P===void 0&&(k==null||k("003",Bi.error003(N)),N="default",P=(b==null?void 0:b.default)||$_.default);const T=!!(x.draggable||l&&typeof x.draggable>"u"),z=!!(x.selectable||c&&typeof x.selectable>"u"),E=!!(x.connectable||u&&typeof x.connectable>"u"),O=!!(x.focusable||f&&typeof x.focusable>"u"),D=vn(),L=lT(x),$=i6({node:x,nodeType:N,hasDimensions:L,resizeObserver:p}),V=BT({nodeRef:$,disabled:x.hidden||!T,noDragClassName:d,handleSelector:x.dragHandle,nodeId:e,isSelectable:z,nodeClickDistance:g}),W=WT();if(x.hidden)return null;const F=vo(x),M=J5(x),H=z||T||t||n||r||i,A=n?re=>n(re,{..._.userNode}):void 0,X=r?re=>r(re,{..._.userNode}):void 0,q=i?re=>i(re,{..._.userNode}):void 0,B=o?re=>o(re,{..._.userNode}):void 0,ne=a?re=>a(re,{..._.userNode}):void 0,ce=re=>{const{selectNodesOnDrag:se,nodeDragThreshold:Q}=D.getState();z&&(!se||!T||Q>0)&&kb({id:e,store:D,nodeRef:$}),t&&t(re,{..._.userNode})},K=re=>{if(!(dT(re.nativeEvent)||y)){if(ZP.includes(re.key)&&z){const se=re.key==="Escape";kb({id:e,store:D,unselect:se,nodeRef:$})}else if(T&&x.selected&&Object.prototype.hasOwnProperty.call(Am,re.key)){re.preventDefault();const{ariaLabelConfig:se}=D.getState();D.setState({ariaLiveMessage:se["node.a11yDescription.ariaLiveMessage"]({direction:re.key.replace("Arrow","").toLowerCase(),x:~~_.positionAbsolute.x,y:~~_.positionAbsolute.y})}),W({direction:Am[re.key],factor:re.shiftKey?4:1})}}},ee=()=>{var De;if(y||!((De=$.current)!=null&&De.matches(":focus-visible")))return;const{transform:re,width:se,height:Q,autoPanOnNodeFocus:le,setCenter:fe}=D.getState();if(!le)return;dv(new Map([[e,x]]),{x:0,y:0,width:se,height:Q},re,!0).length>0||fe(x.position.x+F.width/2,x.position.y+F.height/2,{zoom:re[2]})};return s.jsx("div",{className:lr(["react-flow__node",`react-flow__node-${N}`,{[m]:T},x.className,{selected:x.selected,selectable:z,parent:j,draggable:T,dragging:V}]),ref:$,style:{zIndex:_.z,transform:`translate(${_.positionAbsolute.x}px,${_.positionAbsolute.y}px)`,pointerEvents:H?"all":"none",visibility:L?"visible":"hidden",...x.style,...M},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:A,onMouseMove:X,onMouseLeave:q,onContextMenu:B,onClick:ce,onDoubleClick:ne,onKeyDown:O?K:void 0,tabIndex:O?0:void 0,onFocus:O?ee:void 0,role:x.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":y?void 0:`${$T}-${v}`,"aria-label":x.ariaLabel,...x.domAttributes,children:s.jsx(W5,{value:e,children:s.jsx(P,{id:e,data:x.data,type:N,positionAbsoluteX:_.positionAbsolute.x,positionAbsoluteY:_.positionAbsolute.y,selected:x.selected??!1,selectable:z,draggable:T,deletable:x.deletable??!0,isConnectable:E,sourcePosition:x.sourcePosition,targetPosition:x.targetPosition,dragging:V,dragHandle:x.dragHandle,zIndex:_.z,parentId:x.parentId,...F})})})}var a6=h.memo(o6);const l6=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function KT(e){const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:o}=Yt(l6,Mn),a=n6(e.onlyRenderVisibleElements),l=s6();return s.jsx("div",{className:"react-flow__nodes",style:Eg,children:a.map(c=>s.jsx(a6,{id:c,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:l,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:o},c))})}KT.displayName="NodeRenderer";const c6=h.memo(KT);function u6(e){return Yt(h.useCallback(n=>{if(!e)return n.edges.map(i=>i.id);const r=[];if(n.width&&n.height)for(const i of n.edges){const o=n.nodeLookup.get(i.source),a=n.nodeLookup.get(i.target);o&&a&&X4({sourceNode:o,targetNode:a,width:n.width,height:n.height,transform:n.transform})&&r.push(i.id)}return r},[e]),Mn)}const d6=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return s.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},f6=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return s.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},O_={[Ii.Arrow]:d6,[Ii.ArrowClosed]:f6};function p6(e){const t=vn();return h.useMemo(()=>{var i,o;return Object.prototype.hasOwnProperty.call(O_,e)?O_[e]:((o=(i=t.getState()).onError)==null||o.call(i,"009",Bi.error009(e)),null)},[e])}const h6=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:o="strokeWidth",strokeWidth:a,orient:l="auto-start-reverse"})=>{const c=p6(t);return c?s.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:l,refX:"0",refY:"0",children:s.jsx(c,{color:n,strokeWidth:a})}):null},qT=({defaultColor:e,rfId:t})=>{const n=Yt(o=>o.edges),r=Yt(o=>o.defaultEdgeOptions),i=h.useMemo(()=>sH(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return i.length?s.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:s.jsx("defs",{children:i.map(o=>s.jsx(h6,{id:o.id,type:o.type,color:o.color,width:o.width,height:o.height,markerUnits:o.markerUnits,strokeWidth:o.strokeWidth,orient:o.orient},o.id))})}):null};qT.displayName="MarkerDefinitions";var m6=h.memo(qT);function UT({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:o,labelBgPadding:a=[2,4],labelBgBorderRadius:l=2,children:c,className:u,...f}){const[p,d]=h.useState({x:1,y:0,width:0,height:0}),m=lr(["react-flow__edge-textwrapper",u]),y=h.useRef(null);return h.useEffect(()=>{if(y.current){const v=y.current.getBBox();d({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),n?s.jsxs("g",{transform:`translate(${e-p.width/2} ${t-p.height/2})`,className:m,visibility:p.width?"visible":"hidden",...f,children:[i&&s.jsx("rect",{width:p.width+2*a[0],x:-a[0],y:-a[1],height:p.height+2*a[1],className:"react-flow__edge-textbg",style:o,rx:l,ry:l}),s.jsx("text",{className:"react-flow__edge-text",y:p.height/2,dy:"0.3em",ref:y,style:r,children:n}),c]}):null}UT.displayName="EdgeText";const g6=h.memo(UT);function Ig({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c,interactionWidth:u=20,...f}){return s.jsxs(s.Fragment,{children:[s.jsx("path",{...f,d:e,fill:"none",className:lr(["react-flow__edge-path",f.className])}),u?s.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&ai(t)&&ai(n)?s.jsx(g6,{x:t,y:n,label:r,labelStyle:i,labelShowBg:o,labelBgStyle:a,labelBgPadding:l,labelBgBorderRadius:c}):null]})}function D_({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===Ge.Left||e===Ge.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function GT({sourceX:e,sourceY:t,sourcePosition:n=Ge.Bottom,targetX:r,targetY:i,targetPosition:o=Ge.Top}){const[a,l]=D_({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,u]=D_({pos:o,x1:r,y1:i,x2:e,y2:t}),[f,p,d,m]=pT({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:a,sourceControlY:l,targetControlX:c,targetControlY:u});return[`M${e},${t} C${a},${l} ${c},${u} ${r},${i}`,f,p,d,m]}function YT(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,sourcePosition:a,targetPosition:l,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:b,interactionWidth:g})=>{const[k,x,_]=GT({sourceX:n,sourceY:r,sourcePosition:a,targetX:i,targetY:o,targetPosition:l}),j=e.isInternal?void 0:t;return s.jsx(Ig,{id:j,path:k,labelX:x,labelY:_,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:b,interactionWidth:g})})}const y6=YT({isInternal:!1}),JT=YT({isInternal:!0});y6.displayName="SimpleBezierEdge";JT.displayName="SimpleBezierEdgeInternal";function XT(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:d,sourcePosition:m=Ge.Bottom,targetPosition:y=Ge.Top,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,_,j]=gb({sourceX:n,sourceY:r,sourcePosition:m,targetX:i,targetY:o,targetPosition:y,borderRadius:g==null?void 0:g.borderRadius,offset:g==null?void 0:g.offset,stepPosition:g==null?void 0:g.stepPosition}),N=e.isInternal?void 0:t;return s.jsx(Ig,{id:N,path:x,labelX:_,labelY:j,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:d,markerEnd:v,markerStart:b,interactionWidth:k})})}const QT=XT({isInternal:!1}),ZT=XT({isInternal:!0});QT.displayName="SmoothStepEdge";ZT.displayName="SmoothStepEdgeInternal";function eR(e){return h.memo(({id:t,...n})=>{var i;const r=e.isInternal?void 0:t;return s.jsx(QT,{...n,id:r,pathOptions:h.useMemo(()=>{var o;return{borderRadius:0,offset:(o=n.pathOptions)==null?void 0:o.offset}},[(i=n.pathOptions)==null?void 0:i.offset])})})}const w6=eR({isInternal:!1}),tR=eR({isInternal:!0});w6.displayName="StepEdge";tR.displayName="StepEdgeInternal";function nR(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:d,markerEnd:m,markerStart:y,interactionWidth:v})=>{const[b,g,k]=gT({sourceX:n,sourceY:r,targetX:i,targetY:o}),x=e.isInternal?void 0:t;return s.jsx(Ig,{id:x,path:b,labelX:g,labelY:k,label:a,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:d,markerEnd:m,markerStart:y,interactionWidth:v})})}const x6=nR({isInternal:!1}),rR=nR({isInternal:!0});x6.displayName="StraightEdge";rR.displayName="StraightEdgeInternal";function sR(e){return h.memo(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:o,sourcePosition:a=Ge.Bottom,targetPosition:l=Ge.Top,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:b,pathOptions:g,interactionWidth:k})=>{const[x,_,j]=hT({sourceX:n,sourceY:r,sourcePosition:a,targetX:i,targetY:o,targetPosition:l,curvature:g==null?void 0:g.curvature}),N=e.isInternal?void 0:t;return s.jsx(Ig,{id:N,path:x,labelX:_,labelY:j,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:d,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:b,interactionWidth:k})})}const b6=sR({isInternal:!1}),iR=sR({isInternal:!0});b6.displayName="BezierEdge";iR.displayName="BezierEdgeInternal";const F_={default:iR,straight:rR,step:tR,smoothstep:ZT,simplebezier:JT},z_={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},k6=(e,t,n)=>n===Ge.Left?e-t:n===Ge.Right?e+t:e,v6=(e,t,n)=>n===Ge.Top?e-t:n===Ge.Bottom?e+t:e,B_="react-flow__edgeupdater";function W_({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:o,onMouseOut:a,type:l}){return s.jsx("circle",{onMouseDown:i,onMouseEnter:o,onMouseOut:a,className:lr([B_,`${B_}-${l}`]),cx:k6(t,r,e),cy:v6(n,r,e),r,stroke:"transparent",fill:"transparent"})}function S6({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:o,targetY:a,sourcePosition:l,targetPosition:c,onReconnect:u,onReconnectStart:f,onReconnectEnd:p,setReconnecting:d,setUpdateHover:m}){const y=vn(),v=(_,j)=>{if(_.button!==0)return;const{autoPanOnConnect:N,domNode:P,connectionMode:T,connectionRadius:z,lib:E,onConnectStart:O,cancelConnection:D,nodeLookup:L,rfId:$,panBy:V,updateConnection:W}=y.getState(),F=j.type==="target",M=(X,q)=>{d(!1),p==null||p(X,n,j.type,q)},H=X=>u==null?void 0:u(n,X),A=(X,q)=>{d(!0),f==null||f(_,n,j.type),O==null||O(X,q)};xb.onPointerDown(_.nativeEvent,{autoPanOnConnect:N,connectionMode:T,connectionRadius:z,domNode:P,handleId:j.id,nodeId:j.nodeId,nodeLookup:L,isTarget:F,edgeUpdaterType:j.type,lib:E,flowId:$,cancelConnection:D,panBy:V,isValidConnection:(...X)=>{var q,B;return((B=(q=y.getState()).isValidConnection)==null?void 0:B.call(q,...X))??!0},onConnect:H,onConnectStart:A,onConnectEnd:(...X)=>{var q,B;return(B=(q=y.getState()).onConnectEnd)==null?void 0:B.call(q,...X)},onReconnectEnd:M,updateConnection:W,getTransform:()=>y.getState().transform,getFromHandle:()=>y.getState().connection.fromHandle,dragThreshold:y.getState().connectionDragThreshold,handleDomNode:_.currentTarget})},b=_=>v(_,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),g=_=>v(_,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),k=()=>m(!0),x=()=>m(!1);return s.jsxs(s.Fragment,{children:[(e===!0||e==="source")&&s.jsx(W_,{position:l,centerX:r,centerY:i,radius:t,onMouseDown:b,onMouseEnter:k,onMouseOut:x,type:"source"}),(e===!0||e==="target")&&s.jsx(W_,{position:c,centerX:o,centerY:a,radius:t,onMouseDown:g,onMouseEnter:k,onMouseOut:x,type:"target"})]})}function j6({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,reconnectRadius:f,onReconnect:p,onReconnectStart:d,onReconnectEnd:m,rfId:y,edgeTypes:v,noPanClassName:b,onError:g,disableKeyboardA11y:k}){let x=Yt(fe=>fe.edgeLookup.get(e));const _=Yt(fe=>fe.defaultEdgeOptions);x=_?{..._,...x}:x;let j=x.type||"default",N=(v==null?void 0:v[j])||F_[j];N===void 0&&(g==null||g("011",Bi.error011(j)),j="default",N=(v==null?void 0:v.default)||F_.default);const P=!!(x.focusable||t&&typeof x.focusable>"u"),T=typeof p<"u"&&(x.reconnectable||n&&typeof x.reconnectable>"u"),z=!!(x.selectable||r&&typeof x.selectable>"u"),E=h.useRef(null),[O,D]=h.useState(!1),[L,$]=h.useState(!1),V=vn(),{zIndex:W,sourceX:F,sourceY:M,targetX:H,targetY:A,sourcePosition:X,targetPosition:q}=Yt(h.useCallback(fe=>{const me=fe.nodeLookup.get(x.source),De=fe.nodeLookup.get(x.target);if(!me||!De)return{zIndex:x.zIndex,...z_};const Ce=rH({id:e,sourceNode:me,targetNode:De,sourceHandle:x.sourceHandle||null,targetHandle:x.targetHandle||null,connectionMode:fe.connectionMode,onError:g});return{zIndex:J4({selected:x.selected,zIndex:x.zIndex,sourceNode:me,targetNode:De,elevateOnSelect:fe.elevateEdgesOnSelect,zIndexMode:fe.zIndexMode}),...Ce||z_}},[x.source,x.target,x.sourceHandle,x.targetHandle,x.selected,x.zIndex]),Mn),B=h.useMemo(()=>x.markerStart?`url('#${yb(x.markerStart,y)}')`:void 0,[x.markerStart,y]),ne=h.useMemo(()=>x.markerEnd?`url('#${yb(x.markerEnd,y)}')`:void 0,[x.markerEnd,y]);if(x.hidden||F===null||M===null||H===null||A===null)return null;const ce=fe=>{var Se;const{addSelectedEdges:me,unselectNodesAndEdges:De,multiSelectionActive:Ce}=V.getState();z&&(V.setState({nodesSelectionActive:!1}),x.selected&&Ce?(De({nodes:[],edges:[x]}),(Se=E.current)==null||Se.blur()):me([e])),i&&i(fe,x)},K=o?fe=>{o(fe,{...x})}:void 0,ee=a?fe=>{a(fe,{...x})}:void 0,re=l?fe=>{l(fe,{...x})}:void 0,se=c?fe=>{c(fe,{...x})}:void 0,Q=u?fe=>{u(fe,{...x})}:void 0,le=fe=>{var me;if(!k&&ZP.includes(fe.key)&&z){const{unselectNodesAndEdges:De,addSelectedEdges:Ce}=V.getState();fe.key==="Escape"?((me=E.current)==null||me.blur(),De({edges:[x]})):Ce([e])}};return s.jsx("svg",{style:{zIndex:W},children:s.jsxs("g",{className:lr(["react-flow__edge",`react-flow__edge-${j}`,x.className,b,{selected:x.selected,animated:x.animated,inactive:!z&&!i,updating:O,selectable:z}]),onClick:ce,onDoubleClick:K,onContextMenu:ee,onMouseEnter:re,onMouseMove:se,onMouseLeave:Q,onKeyDown:P?le:void 0,tabIndex:P?0:void 0,role:x.ariaRole??(P?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":x.ariaLabel===null?void 0:x.ariaLabel||`Edge from ${x.source} to ${x.target}`,"aria-describedby":P?`${LT}-${y}`:void 0,ref:E,...x.domAttributes,children:[!L&&s.jsx(N,{id:e,source:x.source,target:x.target,type:x.type,selected:x.selected,animated:x.animated,selectable:z,deletable:x.deletable??!0,label:x.label,labelStyle:x.labelStyle,labelShowBg:x.labelShowBg,labelBgStyle:x.labelBgStyle,labelBgPadding:x.labelBgPadding,labelBgBorderRadius:x.labelBgBorderRadius,sourceX:F,sourceY:M,targetX:H,targetY:A,sourcePosition:X,targetPosition:q,data:x.data,style:x.style,sourceHandleId:x.sourceHandle,targetHandleId:x.targetHandle,markerStart:B,markerEnd:ne,pathOptions:"pathOptions"in x?x.pathOptions:void 0,interactionWidth:x.interactionWidth}),T&&s.jsx(S6,{edge:x,isReconnectable:T,reconnectRadius:f,onReconnect:p,onReconnectStart:d,onReconnectEnd:m,sourceX:F,sourceY:M,targetX:H,targetY:A,sourcePosition:X,targetPosition:q,setUpdateHover:D,setReconnecting:$})]})})}var N6=h.memo(j6);const _6=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function oR({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:o,onEdgeContextMenu:a,onEdgeMouseEnter:l,onEdgeMouseMove:c,onEdgeMouseLeave:u,onEdgeClick:f,reconnectRadius:p,onEdgeDoubleClick:d,onReconnectStart:m,onReconnectEnd:y,disableKeyboardA11y:v}){const{edgesFocusable:b,edgesReconnectable:g,elementsSelectable:k,onError:x}=Yt(_6,Mn),_=u6(t);return s.jsxs("div",{className:"react-flow__edges",children:[s.jsx(m6,{defaultColor:e,rfId:n}),_.map(j=>s.jsx(N6,{id:j,edgesFocusable:b,edgesReconnectable:g,elementsSelectable:k,noPanClassName:i,onReconnect:o,onContextMenu:a,onMouseEnter:l,onMouseMove:c,onMouseLeave:u,onClick:f,reconnectRadius:p,onDoubleClick:d,onReconnectStart:m,onReconnectEnd:y,rfId:n,onError:x,edgeTypes:r,disableKeyboardA11y:v},j))]})}oR.displayName="EdgeRenderer";const C6=h.memo(oR),A6=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function E6({children:e}){const t=Yt(A6);return s.jsx("div",{className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:t},children:e})}function I6(e){const t=su(),n=h.useRef(!1);h.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const P6=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function T6(e){const t=Yt(P6),n=vn();return h.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function R6(e){return e.connection.inProgress?{...e.connection,to:Ff(e.connection.to,e.transform)}:{...e.connection}}function M6(e){return R6}function $6(e){const t=M6();return Yt(t,Mn)}const L6=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function O6({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:i,width:o,height:a,isValid:l,inProgress:c}=Yt(L6,Mn);return!(o&&i&&c)?null:s.jsx("svg",{style:e,width:o,height:a,className:"react-flow__connectionline react-flow__container",children:s.jsx("g",{className:lr(["react-flow__connection",nT(l)]),children:s.jsx(aR,{style:t,type:n,CustomComponent:r,isValid:l})})})}const aR=({style:e,type:t=Go.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:i,from:o,fromNode:a,fromHandle:l,fromPosition:c,to:u,toNode:f,toHandle:p,toPosition:d,pointer:m}=$6();if(!i)return;if(n)return s.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:a,fromHandle:l,fromX:o.x,fromY:o.y,toX:u.x,toY:u.y,fromPosition:c,toPosition:d,connectionStatus:nT(r),toNode:f,toHandle:p,pointer:m});let y="";const v={sourceX:o.x,sourceY:o.y,sourcePosition:c,targetX:u.x,targetY:u.y,targetPosition:d};switch(t){case Go.Bezier:[y]=hT(v);break;case Go.SimpleBezier:[y]=GT(v);break;case Go.Step:[y]=gb({...v,borderRadius:0});break;case Go.SmoothStep:[y]=gb(v);break;default:[y]=gT(v)}return s.jsx("path",{d:y,fill:"none",className:"react-flow__connection-path",style:e})};aR.displayName="ConnectionLine";const D6={};function H_(e=D6){h.useRef(e),vn(),h.useEffect(()=>{},[e])}function F6(){vn(),h.useRef(!1),h.useEffect(()=>{},[])}function lR({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:o,onEdgeDoubleClick:a,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:f,onSelectionContextMenu:p,onSelectionStart:d,onSelectionEnd:m,connectionLineType:y,connectionLineStyle:v,connectionLineComponent:b,connectionLineContainerStyle:g,selectionKeyCode:k,selectionOnDrag:x,selectionMode:_,multiSelectionKeyCode:j,panActivationKeyCode:N,zoomActivationKeyCode:P,deleteKeyCode:T,onlyRenderVisibleElements:z,elementsSelectable:E,defaultViewport:O,translateExtent:D,minZoom:L,maxZoom:$,preventScrolling:V,defaultMarkerColor:W,zoomOnScroll:F,zoomOnPinch:M,panOnScroll:H,panOnScrollSpeed:A,panOnScrollMode:X,zoomOnDoubleClick:q,panOnDrag:B,onPaneClick:ne,onPaneMouseEnter:ce,onPaneMouseMove:K,onPaneMouseLeave:ee,onPaneScroll:re,onPaneContextMenu:se,paneClickDistance:Q,nodeClickDistance:le,onEdgeContextMenu:fe,onEdgeMouseEnter:me,onEdgeMouseMove:De,onEdgeMouseLeave:Ce,reconnectRadius:Se,onReconnect:Ue,onReconnectStart:lt,onReconnectEnd:xt,noDragClassName:at,noWheelClassName:ze,noPanClassName:Xe,disableKeyboardA11y:Bt,nodeExtent:Mt,rfId:Qt,viewport:de,onViewportChange:ke}){return H_(e),H_(t),F6(),I6(n),T6(de),s.jsx(e6,{onPaneClick:ne,onPaneMouseEnter:ce,onPaneMouseMove:K,onPaneMouseLeave:ee,onPaneContextMenu:se,onPaneScroll:re,paneClickDistance:Q,deleteKeyCode:T,selectionKeyCode:k,selectionOnDrag:x,selectionMode:_,onSelectionStart:d,onSelectionEnd:m,multiSelectionKeyCode:j,panActivationKeyCode:N,zoomActivationKeyCode:P,elementsSelectable:E,zoomOnScroll:F,zoomOnPinch:M,zoomOnDoubleClick:q,panOnScroll:H,panOnScrollSpeed:A,panOnScrollMode:X,panOnDrag:B,defaultViewport:O,translateExtent:D,minZoom:L,maxZoom:$,onSelectionContextMenu:p,preventScrolling:V,noDragClassName:at,noWheelClassName:ze,noPanClassName:Xe,disableKeyboardA11y:Bt,onViewportChange:ke,isControlledViewport:!!de,children:s.jsxs(E6,{children:[s.jsx(C6,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:a,onReconnect:Ue,onReconnectStart:lt,onReconnectEnd:xt,onlyRenderVisibleElements:z,onEdgeContextMenu:fe,onEdgeMouseEnter:me,onEdgeMouseMove:De,onEdgeMouseLeave:Ce,reconnectRadius:Se,defaultMarkerColor:W,noPanClassName:Xe,disableKeyboardA11y:Bt,rfId:Qt}),s.jsx(O6,{style:v,type:y,component:b,containerStyle:g}),s.jsx("div",{className:"react-flow__edgelabel-renderer"}),s.jsx(c6,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:o,onNodeMouseEnter:l,onNodeMouseMove:c,onNodeMouseLeave:u,onNodeContextMenu:f,nodeClickDistance:le,onlyRenderVisibleElements:z,noPanClassName:Xe,noDragClassName:at,disableKeyboardA11y:Bt,nodeExtent:Mt,rfId:Qt}),s.jsx("div",{className:"react-flow__viewport-portal"})]})})}lR.displayName="GraphView";const z6=h.memo(lR),V_=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:a,fitViewOptions:l,minZoom:c=.5,maxZoom:u=2,nodeOrigin:f,nodeExtent:p,zIndexMode:d="basic"}={})=>{const m=new Map,y=new Map,v=new Map,b=new Map,g=r??t??[],k=n??e??[],x=f??[0,0],_=p??lf;xT(v,b,g);const{nodesInitialized:j}=wb(k,m,y,{nodeOrigin:x,nodeExtent:_,zIndexMode:d});let N=[0,0,1];if(a&&i&&o){const P=Of(m,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:T,y:z,zoom:E}=fv(P,i,o,c,u,(l==null?void 0:l.padding)??.1);N=[T,z,E]}return{rfId:"1",width:i??0,height:o??0,transform:N,nodes:k,nodesInitialized:j,nodeLookup:m,parentLookup:y,edges:g,edgeLookup:b,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:u,translateExtent:lf,nodeExtent:_,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Kc.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:x,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:a??!1,fitViewOptions:l,fitViewResolver:null,connection:{...tT},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:V4,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:eT,zIndexMode:d,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},B6=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:f,nodeExtent:p,zIndexMode:d})=>o5((m,y)=>{async function v(){const{nodeLookup:b,panZoom:g,fitViewOptions:k,fitViewResolver:x,width:_,height:j,minZoom:N,maxZoom:P}=y();g&&(await W4({nodes:b,width:_,height:j,panZoom:g,minZoom:N,maxZoom:P},k),x==null||x.resolve(!0),m({fitViewResolver:null}))}return{...V_({nodes:e,edges:t,width:i,height:o,fitView:a,fitViewOptions:l,minZoom:c,maxZoom:u,nodeOrigin:f,nodeExtent:p,defaultNodes:n,defaultEdges:r,zIndexMode:d}),setNodes:b=>{const{nodeLookup:g,parentLookup:k,nodeOrigin:x,elevateNodesOnSelect:_,fitViewQueued:j,zIndexMode:N,nodesSelectionActive:P}=y(),{nodesInitialized:T,hasSelectedNodes:z}=wb(b,g,k,{nodeOrigin:x,nodeExtent:p,elevateNodesOnSelect:_,checkEquality:!0,zIndexMode:N}),E=P&&z;j&&T?(v(),m({nodes:b,nodesInitialized:T,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:E})):m({nodes:b,nodesInitialized:T,nodesSelectionActive:E})},setEdges:b=>{const{connectionLookup:g,edgeLookup:k}=y();xT(g,k,b),m({edges:b})},setDefaultNodesAndEdges:(b,g)=>{if(b){const{setNodes:k}=y();k(b),m({hasDefaultNodes:!0})}if(g){const{setEdges:k}=y();k(g),m({hasDefaultEdges:!0})}},updateNodeInternals:b=>{const{triggerNodeChanges:g,nodeLookup:k,parentLookup:x,domNode:_,nodeOrigin:j,nodeExtent:N,debug:P,fitViewQueued:T,zIndexMode:z}=y(),{changes:E,updatedInternals:O}=dH(b,k,x,_,j,N,z);O&&(aH(k,x,{nodeOrigin:j,nodeExtent:N,zIndexMode:z}),T?(v(),m({fitViewQueued:!1,fitViewOptions:void 0})):m({}),(E==null?void 0:E.length)>0&&(P&&console.log("React Flow: trigger node changes",E),g==null||g(E)))},updateNodePositions:(b,g=!1)=>{const k=[];let x=[];const{nodeLookup:_,triggerNodeChanges:j,connection:N,updateConnection:P,onNodesChangeMiddlewareMap:T}=y();for(const[z,E]of b){const O=_.get(z),D=!!(O!=null&&O.expandParent&&(O!=null&&O.parentId)&&(E!=null&&E.position)),L={id:z,type:"position",position:D?{x:Math.max(0,E.position.x),y:Math.max(0,E.position.y)}:E.position,dragging:g};if(O&&N.inProgress&&N.fromNode.id===O.id){const $=ul(O,N.fromHandle,Ge.Left,!0);P({...N,from:$})}D&&O.parentId&&k.push({id:z,parentId:O.parentId,rect:{...E.internals.positionAbsolute,width:E.measured.width??0,height:E.measured.height??0}}),x.push(L)}if(k.length>0){const{parentLookup:z,nodeOrigin:E}=y(),O=wv(k,_,z,E);x.push(...O)}for(const z of T.values())x=z(x);j(x)},triggerNodeChanges:b=>{const{onNodesChange:g,setNodes:k,nodes:x,hasDefaultNodes:_,debug:j}=y();if(b!=null&&b.length){if(_){const N=Td(b,x);k(N)}j&&console.log("React Flow: trigger node changes",b),g==null||g(b)}},triggerEdgeChanges:b=>{const{onEdgesChange:g,setEdges:k,edges:x,hasDefaultEdges:_,debug:j}=y();if(b!=null&&b.length){if(_){const N=Cm(b,x);k(N)}j&&console.log("React Flow: trigger edge changes",b),g==null||g(b)}},addSelectedNodes:b=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:x,triggerNodeChanges:_,triggerEdgeChanges:j}=y();if(g){const N=b.map(P=>Da(P,!0));_(N);return}_(wc(x,new Set([...b]),!0)),j(wc(k))},addSelectedEdges:b=>{const{multiSelectionActive:g,edgeLookup:k,nodeLookup:x,triggerNodeChanges:_,triggerEdgeChanges:j}=y();if(g){const N=b.map(P=>Da(P,!0));j(N);return}j(wc(k,new Set([...b]))),_(wc(x,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:g}={})=>{const{edges:k,nodes:x,nodeLookup:_,triggerNodeChanges:j,triggerEdgeChanges:N}=y(),P=b||x,T=g||k,z=[];for(const O of P){if(!O.selected)continue;const D=_.get(O.id);D&&(D.selected=!1),z.push(Da(O.id,!1))}const E=[];for(const O of T)O.selected&&E.push(Da(O.id,!1));j(z),N(E)},setMinZoom:b=>{const{panZoom:g,maxZoom:k}=y();g==null||g.setScaleExtent([b,k]),m({minZoom:b})},setMaxZoom:b=>{const{panZoom:g,minZoom:k}=y();g==null||g.setScaleExtent([k,b]),m({maxZoom:b})},setTranslateExtent:b=>{var g;(g=y().panZoom)==null||g.setTranslateExtent(b),m({translateExtent:b})},resetSelectedElements:()=>{const{edges:b,nodes:g,triggerNodeChanges:k,triggerEdgeChanges:x,elementsSelectable:_}=y();if(!_)return;const j=g.reduce((P,T)=>T.selected?[...P,Da(T.id,!1)]:P,[]),N=b.reduce((P,T)=>T.selected?[...P,Da(T.id,!1)]:P,[]);k(j),x(N)},setNodeExtent:b=>{const{nodes:g,nodeLookup:k,parentLookup:x,nodeOrigin:_,elevateNodesOnSelect:j,nodeExtent:N,zIndexMode:P}=y();b[0][0]===N[0][0]&&b[0][1]===N[0][1]&&b[1][0]===N[1][0]&&b[1][1]===N[1][1]||(wb(g,k,x,{nodeOrigin:_,nodeExtent:b,elevateNodesOnSelect:j,checkEquality:!1,zIndexMode:P}),m({nodeExtent:b}))},panBy:b=>{const{transform:g,width:k,height:x,panZoom:_,translateExtent:j}=y();return fH({delta:b,panZoom:_,transform:g,translateExtent:j,width:k,height:x})},setCenter:async(b,g,k)=>{const{width:x,height:_,maxZoom:j,panZoom:N}=y();if(!N)return Promise.resolve(!1);const P=typeof(k==null?void 0:k.zoom)<"u"?k.zoom:j;return await N.setViewport({x:x/2-b*P,y:_/2-g*P,zoom:P},{duration:k==null?void 0:k.duration,ease:k==null?void 0:k.ease,interpolate:k==null?void 0:k.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{m({connection:{...tT}})},updateConnection:b=>{m({connection:b})},reset:()=>m({...V_()})}},Object.is);function bv({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:o,initialMinZoom:a,initialMaxZoom:l,initialFitViewOptions:c,fitView:u,nodeOrigin:f,nodeExtent:p,zIndexMode:d,children:m}){const[y]=h.useState(()=>B6({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:o,fitView:u,minZoom:a,maxZoom:l,fitViewOptions:c,nodeOrigin:f,nodeExtent:p,zIndexMode:d}));return s.jsx(a5,{value:y,children:s.jsx(E5,{children:m})})}function W6({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:o,height:a,fitView:l,fitViewOptions:c,minZoom:u,maxZoom:f,nodeOrigin:p,nodeExtent:d,zIndexMode:m}){return h.useContext(Cg)?s.jsx(s.Fragment,{children:e}):s.jsx(bv,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:o,initialHeight:a,fitView:l,initialFitViewOptions:c,initialMinZoom:u,initialMaxZoom:f,nodeOrigin:p,nodeExtent:d,zIndexMode:m,children:e})}const H6={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function V6({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:o,edgeTypes:a,onNodeClick:l,onEdgeClick:c,onInit:u,onMove:f,onMoveStart:p,onMoveEnd:d,onConnect:m,onConnectStart:y,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:g,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:_,onNodeContextMenu:j,onNodeDoubleClick:N,onNodeDragStart:P,onNodeDrag:T,onNodeDragStop:z,onNodesDelete:E,onEdgesDelete:O,onDelete:D,onSelectionChange:L,onSelectionDragStart:$,onSelectionDrag:V,onSelectionDragStop:W,onSelectionContextMenu:F,onSelectionStart:M,onSelectionEnd:H,onBeforeDelete:A,connectionMode:X,connectionLineType:q=Go.Bezier,connectionLineStyle:B,connectionLineComponent:ne,connectionLineContainerStyle:ce,deleteKeyCode:K="Backspace",selectionKeyCode:ee="Shift",selectionOnDrag:re=!1,selectionMode:se=cf.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:le=df()?"Meta":"Control",zoomActivationKeyCode:fe=df()?"Meta":"Control",snapToGrid:me,snapGrid:De,onlyRenderVisibleElements:Ce=!1,selectNodesOnDrag:Se,nodesDraggable:Ue,autoPanOnNodeFocus:lt,nodesConnectable:xt,nodesFocusable:at,nodeOrigin:ze=OT,edgesFocusable:Xe,edgesReconnectable:Bt,elementsSelectable:Mt=!0,defaultViewport:Qt=b5,minZoom:de=.5,maxZoom:ke=2,translateExtent:qe=lf,preventScrolling:st=!0,nodeExtent:Ee,defaultMarkerColor:rt="#b1b1b7",zoomOnScroll:un=!0,zoomOnPinch:Kt=!0,panOnScroll:yt=!1,panOnScrollSpeed:pn=.5,panOnScrollMode:ie=Za.Free,zoomOnDoubleClick:Ne=!0,panOnDrag:Ye=!0,onPaneClick:He,onPaneMouseEnter:It,onPaneMouseMove:jt,onPaneMouseLeave:cr,onPaneScroll:$n,onPaneContextMenu:ur,paneClickDistance:rn=1,nodeClickDistance:gn=0,children:Yn,onReconnect:gr,onReconnectStart:yn,onReconnectEnd:Pn,onEdgeContextMenu:nr,onEdgeDoubleClick:Wr,onEdgeMouseEnter:Sn,onEdgeMouseMove:Jn,onEdgeMouseLeave:Hr,reconnectRadius:Vn=10,onNodesChange:Kn,onEdgesChange:dr,noDragClassName:fr="nodrag",noWheelClassName:qn="nowheel",noPanClassName:_r="nopan",fitView:yr,fitViewOptions:kt,connectOnClick:ct,attributionPosition:Zt,proOptions:Nt,defaultEdgeOptions:jn,elevateNodesOnSelect:ue=!0,elevateEdgesOnSelect:te=!1,disableKeyboardA11y:ye=!1,autoPanOnConnect:Me,autoPanOnNodeDrag:Ae,autoPanSpeed:ut,connectionRadius:Pt,isValidConnection:Nn,onError:Je,style:hn,id:rr,nodeDragThreshold:dn,connectionDragThreshold:Tr,viewport:oe,onViewportChange:ve,width:Re,height:St,colorMode:Dt="light",debug:sn,onScroll:_n,ariaLabelConfig:Xn,zIndexMode:_s="basic",...Cs},G){const we=rr||"1",$e=j5(Dt),Ie=h.useCallback(nt=>{nt.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),_n==null||_n(nt)},[_n]);return s.jsx("div",{"data-testid":"rf__wrapper",...Cs,onScroll:Ie,style:{...hn,...H6},ref:G,className:lr(["react-flow",i,$e]),id:rr,role:"application",children:s.jsxs(W6,{nodes:e,edges:t,width:Re,height:St,fitView:yr,fitViewOptions:kt,minZoom:de,maxZoom:ke,nodeOrigin:ze,nodeExtent:Ee,zIndexMode:_s,children:[s.jsx(S5,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:m,onConnectStart:y,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:g,nodesDraggable:Ue,autoPanOnNodeFocus:lt,nodesConnectable:xt,nodesFocusable:at,edgesFocusable:Xe,edgesReconnectable:Bt,elementsSelectable:Mt,elevateNodesOnSelect:ue,elevateEdgesOnSelect:te,minZoom:de,maxZoom:ke,nodeExtent:Ee,onNodesChange:Kn,onEdgesChange:dr,snapToGrid:me,snapGrid:De,connectionMode:X,translateExtent:qe,connectOnClick:ct,defaultEdgeOptions:jn,fitView:yr,fitViewOptions:kt,onNodesDelete:E,onEdgesDelete:O,onDelete:D,onNodeDragStart:P,onNodeDrag:T,onNodeDragStop:z,onSelectionDrag:V,onSelectionDragStart:$,onSelectionDragStop:W,onMove:f,onMoveStart:p,onMoveEnd:d,noPanClassName:_r,nodeOrigin:ze,rfId:we,autoPanOnConnect:Me,autoPanOnNodeDrag:Ae,autoPanSpeed:ut,onError:Je,connectionRadius:Pt,isValidConnection:Nn,selectNodesOnDrag:Se,nodeDragThreshold:dn,connectionDragThreshold:Tr,onBeforeDelete:A,debug:sn,ariaLabelConfig:Xn,zIndexMode:_s}),s.jsx(z6,{onInit:u,onNodeClick:l,onEdgeClick:c,onNodeMouseEnter:k,onNodeMouseMove:x,onNodeMouseLeave:_,onNodeContextMenu:j,onNodeDoubleClick:N,nodeTypes:o,edgeTypes:a,connectionLineType:q,connectionLineStyle:B,connectionLineComponent:ne,connectionLineContainerStyle:ce,selectionKeyCode:ee,selectionOnDrag:re,selectionMode:se,deleteKeyCode:K,multiSelectionKeyCode:le,panActivationKeyCode:Q,zoomActivationKeyCode:fe,onlyRenderVisibleElements:Ce,defaultViewport:Qt,translateExtent:qe,minZoom:de,maxZoom:ke,preventScrolling:st,zoomOnScroll:un,zoomOnPinch:Kt,zoomOnDoubleClick:Ne,panOnScroll:yt,panOnScrollSpeed:pn,panOnScrollMode:ie,panOnDrag:Ye,onPaneClick:He,onPaneMouseEnter:It,onPaneMouseMove:jt,onPaneMouseLeave:cr,onPaneScroll:$n,onPaneContextMenu:ur,paneClickDistance:rn,nodeClickDistance:gn,onSelectionContextMenu:F,onSelectionStart:M,onSelectionEnd:H,onReconnect:gr,onReconnectStart:yn,onReconnectEnd:Pn,onEdgeContextMenu:nr,onEdgeDoubleClick:Wr,onEdgeMouseEnter:Sn,onEdgeMouseMove:Jn,onEdgeMouseLeave:Hr,reconnectRadius:Vn,defaultMarkerColor:rt,noDragClassName:fr,noWheelClassName:qn,noPanClassName:_r,rfId:we,disableKeyboardA11y:ye,nodeExtent:Ee,viewport:oe,onViewportChange:ve}),s.jsx(x5,{onSelectionChange:L}),Yn,s.jsx(h5,{proOptions:Nt,position:Zt}),s.jsx(p5,{rfId:we,disableKeyboardA11y:ye})]})})}var cR=FT(V6);function K6(){const e=vn();return h.useCallback(t=>{const{domNode:n,updateNodeInternals:r}=e.getState(),i=Array.isArray(t)?t:[t],o=new Map;i.forEach(a=>{const l=n==null?void 0:n.querySelector(`.react-flow__node[data-id="${a}"]`);l&&o.set(a,{id:a,nodeElement:l,force:!0})}),requestAnimationFrame(()=>r(o,{triggerFitView:!1}))},[])}function q6(e){const[t,n]=h.useState(e),r=h.useCallback(i=>n(o=>Td(i,o)),[]);return[t,n,r]}function U6(e){const[t,n]=h.useState(e),r=h.useCallback(i=>n(o=>Cm(i,o)),[]);return[t,n,r]}function G6({dimensions:e,lineWidth:t,variant:n,className:r}){return s.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:lr(["react-flow__background-pattern",n,r])})}function Y6({radius:e,className:t}){return s.jsx("circle",{cx:e,cy:e,r:e,className:lr(["react-flow__background-pattern","dots",t])})}var ca;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(ca||(ca={}));const J6={[ca.Dots]:1,[ca.Lines]:1,[ca.Cross]:6},X6=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function uR({id:e,variant:t=ca.Dots,gap:n=20,size:r,lineWidth:i=1,offset:o=0,color:a,bgColor:l,style:c,className:u,patternClassName:f}){const p=h.useRef(null),{transform:d,patternId:m}=Yt(X6,Mn),y=r||J6[t],v=t===ca.Dots,b=t===ca.Cross,g=Array.isArray(n)?n:[n,n],k=[g[0]*d[2]||1,g[1]*d[2]||1],x=y*d[2],_=Array.isArray(o)?o:[o,o],j=b?[x,x]:k,N=[_[0]*d[2]||1+j[0]/2,_[1]*d[2]||1+j[1]/2],P=`${m}${e||""}`;return s.jsxs("svg",{className:lr(["react-flow__background",u]),style:{...c,...Eg,"--xy-background-color-props":l,"--xy-background-pattern-color-props":a},ref:p,"data-testid":"rf__background",children:[s.jsx("pattern",{id:P,x:d[0]%k[0],y:d[1]%k[1],width:k[0],height:k[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${N[0]},-${N[1]})`,children:v?s.jsx(Y6,{radius:x/2,className:f}):s.jsx(G6,{dimensions:j,lineWidth:i,variant:t,className:f})}),s.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${P})`})]})}uR.displayName="Background";const dR=h.memo(uR);function Q6(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:s.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Z6(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:s.jsx("path",{d:"M0 0h32v4.2H0z"})})}function e8(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:s.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 t8(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.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 n8(){return s.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:s.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 eh({children:e,className:t,...n}){return s.jsx("button",{type:"button",className:lr(["react-flow__controls-button",t]),...n,children:e})}const r8=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function fR({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:o,onZoomOut:a,onFitView:l,onInteractiveChange:c,className:u,children:f,position:p="bottom-left",orientation:d="vertical","aria-label":m}){const y=vn(),{isInteractive:v,minZoomReached:b,maxZoomReached:g,ariaLabelConfig:k}=Yt(r8,Mn),{zoomIn:x,zoomOut:_,fitView:j}=su(),N=()=>{x(),o==null||o()},P=()=>{_(),a==null||a()},T=()=>{j(i),l==null||l()},z=()=>{y.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),c==null||c(!v)},E=d==="horizontal"?"horizontal":"vertical";return s.jsxs(Ag,{className:lr(["react-flow__controls",E,u]),position:p,style:e,"data-testid":"rf__controls","aria-label":m??k["controls.ariaLabel"],children:[t&&s.jsxs(s.Fragment,{children:[s.jsx(eh,{onClick:N,className:"react-flow__controls-zoomin",title:k["controls.zoomIn.ariaLabel"],"aria-label":k["controls.zoomIn.ariaLabel"],disabled:g,children:s.jsx(Q6,{})}),s.jsx(eh,{onClick:P,className:"react-flow__controls-zoomout",title:k["controls.zoomOut.ariaLabel"],"aria-label":k["controls.zoomOut.ariaLabel"],disabled:b,children:s.jsx(Z6,{})})]}),n&&s.jsx(eh,{className:"react-flow__controls-fitview",onClick:T,title:k["controls.fitView.ariaLabel"],"aria-label":k["controls.fitView.ariaLabel"],children:s.jsx(e8,{})}),r&&s.jsx(eh,{className:"react-flow__controls-interactive",onClick:z,title:k["controls.interactive.ariaLabel"],"aria-label":k["controls.interactive.ariaLabel"],children:v?s.jsx(n8,{}):s.jsx(t8,{})}),f]})}fR.displayName="Controls";h.memo(fR);function s8({id:e,x:t,y:n,width:r,height:i,style:o,color:a,strokeColor:l,strokeWidth:c,className:u,borderRadius:f,shapeRendering:p,selected:d,onClick:m}){const{background:y,backgroundColor:v}=o||{},b=a||y||v;return s.jsx("rect",{className:lr(["react-flow__minimap-node",{selected:d},u]),x:t,y:n,rx:f,ry:f,width:r,height:i,style:{fill:b,stroke:l,strokeWidth:c},shapeRendering:p,onClick:m?g=>m(g,e):void 0})}const i8=h.memo(s8),o8=e=>e.nodes.map(t=>t.id),bw=e=>e instanceof Function?e:()=>e;function a8({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:o=i8,onClick:a}){const l=Yt(o8,Mn),c=bw(t),u=bw(e),f=bw(n),p=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return s.jsx(s.Fragment,{children:l.map(d=>s.jsx(c8,{id:d,nodeColorFunc:c,nodeStrokeColorFunc:u,nodeClassNameFunc:f,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:o,onClick:a,shapeRendering:p},d))})}function l8({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:o,shapeRendering:a,NodeComponent:l,onClick:c}){const{node:u,x:f,y:p,width:d,height:m}=Yt(y=>{const v=y.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};const b=v.internals.userNode,{x:g,y:k}=v.internals.positionAbsolute,{width:x,height:_}=vo(b);return{node:b,x:g,y:k,width:x,height:_}},Mn);return!u||u.hidden||!lT(u)?null:s.jsx(l,{x:f,y:p,width:d,height:m,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:i,strokeColor:n(u),strokeWidth:o,shapeRendering:a,onClick:c,id:u.id})}const c8=h.memo(l8);var u8=h.memo(a8);const d8=200,f8=150,p8=e=>!e.hidden,h8=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?aT(Of(e.nodeLookup,{filter:p8}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},m8="react-flow__minimap-desc";function pR({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i="",nodeBorderRadius:o=5,nodeStrokeWidth:a,nodeComponent:l,bgColor:c,maskColor:u,maskStrokeColor:f,maskStrokeWidth:p,position:d="bottom-right",onClick:m,onNodeClick:y,pannable:v=!1,zoomable:b=!1,ariaLabel:g,inversePan:k,zoomStep:x=1,offsetScale:_=5}){const j=vn(),N=h.useRef(null),{boundingRect:P,viewBB:T,rfId:z,panZoom:E,translateExtent:O,flowWidth:D,flowHeight:L,ariaLabelConfig:$}=Yt(h8,Mn),V=(e==null?void 0:e.width)??d8,W=(e==null?void 0:e.height)??f8,F=P.width/V,M=P.height/W,H=Math.max(F,M),A=H*V,X=H*W,q=_*H,B=P.x-(A-P.width)/2-q,ne=P.y-(X-P.height)/2-q,ce=A+q*2,K=X+q*2,ee=`${m8}-${z}`,re=h.useRef(0),se=h.useRef();re.current=H,h.useEffect(()=>{if(N.current&&E)return se.current=kH({domNode:N.current,panZoom:E,getTransform:()=>j.getState().transform,getViewScale:()=>re.current}),()=>{var me;(me=se.current)==null||me.destroy()}},[E]),h.useEffect(()=>{var me;(me=se.current)==null||me.update({translateExtent:O,width:D,height:L,inversePan:k,pannable:v,zoomStep:x,zoomable:b})},[v,b,k,x,O,D,L]);const Q=m?me=>{var Se;const[De,Ce]=((Se=se.current)==null?void 0:Se.pointer(me))||[0,0];m(me,{x:De,y:Ce})}:void 0,le=y?h.useCallback((me,De)=>{const Ce=j.getState().nodeLookup.get(De).internals.userNode;y(me,Ce)},[]):void 0,fe=g??$["minimap.ariaLabel"];return s.jsx(Ag,{position:d,style:{...e,"--xy-minimap-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof p=="number"?p*H:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof a=="number"?a:void 0},className:lr(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:s.jsxs("svg",{width:V,height:W,viewBox:`${B} ${ne} ${ce} ${K}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ee,ref:N,onClick:Q,children:[fe&&s.jsx("title",{id:ee,children:fe}),s.jsx(u8,{onClick:le,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:i,nodeStrokeWidth:a,nodeComponent:l}),s.jsx("path",{className:"react-flow__minimap-mask",d:`M${B-q},${ne-q}h${ce+q*2}v${K+q*2}h${-ce-q*2}z
|
|
66
|
+
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}pR.displayName="MiniMap";h.memo(pR);const g8=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,y8={[Yc.Line]:"right",[Yc.Handle]:"bottom-right"};function w8({nodeId:e,position:t,variant:n=Yc.Handle,className:r,style:i=void 0,children:o,color:a,minWidth:l=10,minHeight:c=10,maxWidth:u=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:p=!1,resizeDirection:d,autoScale:m=!0,shouldResize:y,onResizeStart:v,onResize:b,onResizeEnd:g}){const k=HT(),x=typeof e=="string"?e:k,_=vn(),j=h.useRef(null),N=n===Yc.Handle,P=Yt(h.useCallback(g8(N&&m),[N,m]),Mn),T=h.useRef(null),z=t??y8[n];h.useEffect(()=>{if(!(!j.current||!x))return T.current||(T.current=$H({domNode:j.current,nodeId:x,getStoreItems:()=>{const{nodeLookup:O,transform:D,snapGrid:L,snapToGrid:$,nodeOrigin:V,domNode:W}=_.getState();return{nodeLookup:O,transform:D,snapGrid:L,snapToGrid:$,nodeOrigin:V,paneDomNode:W}},onChange:(O,D)=>{const{triggerNodeChanges:L,nodeLookup:$,parentLookup:V,nodeOrigin:W}=_.getState(),F=[],M={x:O.x,y:O.y},H=$.get(x);if(H&&H.expandParent&&H.parentId){const A=H.origin??W,X=O.width??H.measured.width??0,q=O.height??H.measured.height??0,B={id:H.id,parentId:H.parentId,rect:{width:X,height:q,...cT({x:O.x??H.position.x,y:O.y??H.position.y},{width:X,height:q},H.parentId,$,A)}},ne=wv([B],$,V,W);F.push(...ne),M.x=O.x?Math.max(A[0]*X,O.x):void 0,M.y=O.y?Math.max(A[1]*q,O.y):void 0}if(M.x!==void 0&&M.y!==void 0){const A={id:x,type:"position",position:{...M}};F.push(A)}if(O.width!==void 0&&O.height!==void 0){const X={id:x,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};F.push(X)}for(const A of D){const X={...A,type:"position"};F.push(X)}L(F)},onEnd:({width:O,height:D})=>{const L={id:x,type:"dimensions",resizing:!1,dimensions:{width:O,height:D}};_.getState().triggerNodeChanges([L])}})),T.current.update({controlPosition:z,boundaries:{minWidth:l,minHeight:c,maxWidth:u,maxHeight:f},keepAspectRatio:p,resizeDirection:d,onResizeStart:v,onResize:b,onResizeEnd:g,shouldResize:y}),()=>{var O;(O=T.current)==null||O.destroy()}},[z,l,c,u,f,p,v,b,g,y]);const E=z.split("-");return s.jsx("div",{className:lr(["react-flow__resize-control","nodrag",...E,n,r]),ref:j,style:{...i,scale:P,...a&&{[N?"backgroundColor":"borderColor"]:a}},children:o})}const kv=h.memo(w8);function x8(e,t){const n={};return(e[e.length-1]===""?[...e,""]:e).join((n.padRight?" ":"")+","+(n.padLeft===!1?"":" ")).trim()}const b8=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,k8=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,v8={};function K_(e,t){return(v8.jsx?k8:b8).test(e)}const S8=/[ \t\n\f\r]/g;function j8(e){return typeof e=="object"?e.type==="text"?q_(e.value):!1:q_(e)}function q_(e){return e.replace(S8,"")===""}class zf{constructor(t,n,r){this.normal=n,this.property=t,r&&(this.space=r)}}zf.prototype.normal={};zf.prototype.property={};zf.prototype.space=void 0;function hR(e,t){const n={},r={};for(const i of e)Object.assign(n,i.property),Object.assign(r,i.normal);return new zf(n,r,t)}function vb(e){return e.toLowerCase()}class ds{constructor(t,n){this.attribute=n,this.property=t}}ds.prototype.attribute="";ds.prototype.booleanish=!1;ds.prototype.boolean=!1;ds.prototype.commaOrSpaceSeparated=!1;ds.prototype.commaSeparated=!1;ds.prototype.defined=!1;ds.prototype.mustUseProperty=!1;ds.prototype.number=!1;ds.prototype.overloadedBoolean=!1;ds.prototype.property="";ds.prototype.spaceSeparated=!1;ds.prototype.space=void 0;let N8=0;const At=bl(),ir=bl(),Sb=bl(),Te=bl(),xn=bl(),Ic=bl(),hs=bl();function bl(){return 2**++N8}const jb=Object.freeze(Object.defineProperty({__proto__:null,boolean:At,booleanish:ir,commaOrSpaceSeparated:hs,commaSeparated:Ic,number:Te,overloadedBoolean:Sb,spaceSeparated:xn},Symbol.toStringTag,{value:"Module"})),kw=Object.keys(jb);class vv extends ds{constructor(t,n,r,i){let o=-1;if(super(t,n),U_(this,"space",i),typeof r=="number")for(;++o<kw.length;){const a=kw[o];U_(this,kw[o],(r&jb[a])===jb[a])}}}vv.prototype.defined=!0;function U_(e,t,n){n&&(e[t]=n)}function iu(e){const t={},n={};for(const[r,i]of Object.entries(e.properties)){const o=new vv(r,e.transform(e.attributes||{},r),i,e.space);e.mustUseProperty&&e.mustUseProperty.includes(r)&&(o.mustUseProperty=!0),t[r]=o,n[vb(r)]=r,n[vb(o.attribute)]=r}return new zf(t,n,e.space)}const mR=iu({properties:{ariaActiveDescendant:null,ariaAtomic:ir,ariaAutoComplete:null,ariaBusy:ir,ariaChecked:ir,ariaColCount:Te,ariaColIndex:Te,ariaColSpan:Te,ariaControls:xn,ariaCurrent:null,ariaDescribedBy:xn,ariaDetails:null,ariaDisabled:ir,ariaDropEffect:xn,ariaErrorMessage:null,ariaExpanded:ir,ariaFlowTo:xn,ariaGrabbed:ir,ariaHasPopup:null,ariaHidden:ir,ariaInvalid:null,ariaKeyShortcuts:null,ariaLabel:null,ariaLabelledBy:xn,ariaLevel:Te,ariaLive:null,ariaModal:ir,ariaMultiLine:ir,ariaMultiSelectable:ir,ariaOrientation:null,ariaOwns:xn,ariaPlaceholder:null,ariaPosInSet:Te,ariaPressed:ir,ariaReadOnly:ir,ariaRelevant:null,ariaRequired:ir,ariaRoleDescription:xn,ariaRowCount:Te,ariaRowIndex:Te,ariaRowSpan:Te,ariaSelected:ir,ariaSetSize:Te,ariaSort:null,ariaValueMax:Te,ariaValueMin:Te,ariaValueNow:Te,ariaValueText:null,role:null},transform(e,t){return t==="role"?t:"aria-"+t.slice(4).toLowerCase()}});function gR(e,t){return t in e?e[t]:t}function yR(e,t){return gR(e,t.toLowerCase())}const _8=iu({attributes:{acceptcharset:"accept-charset",classname:"class",htmlfor:"for",httpequiv:"http-equiv"},mustUseProperty:["checked","multiple","muted","selected"],properties:{abbr:null,accept:Ic,acceptCharset:xn,accessKey:xn,action:null,allow:null,allowFullScreen:At,allowPaymentRequest:At,allowUserMedia:At,alt:null,as:null,async:At,autoCapitalize:null,autoComplete:xn,autoFocus:At,autoPlay:At,blocking:xn,capture:null,charSet:null,checked:At,cite:null,className:xn,cols:Te,colSpan:null,content:null,contentEditable:ir,controls:At,controlsList:xn,coords:Te|Ic,crossOrigin:null,data:null,dateTime:null,decoding:null,default:At,defer:At,dir:null,dirName:null,disabled:At,download:Sb,draggable:ir,encType:null,enterKeyHint:null,fetchPriority:null,form:null,formAction:null,formEncType:null,formMethod:null,formNoValidate:At,formTarget:null,headers:xn,height:Te,hidden:Sb,high:Te,href:null,hrefLang:null,htmlFor:xn,httpEquiv:xn,id:null,imageSizes:null,imageSrcSet:null,inert:At,inputMode:null,integrity:null,is:null,isMap:At,itemId:null,itemProp:xn,itemRef:xn,itemScope:At,itemType:xn,kind:null,label:null,lang:null,language:null,list:null,loading:null,loop:At,low:Te,manifest:null,max:null,maxLength:Te,media:null,method:null,min:null,minLength:Te,multiple:At,muted:At,name:null,nonce:null,noModule:At,noValidate:At,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:At,optimum:Te,pattern:null,ping:xn,placeholder:null,playsInline:At,popover:null,popoverTarget:null,popoverTargetAction:null,poster:null,preload:null,readOnly:At,referrerPolicy:null,rel:xn,required:At,reversed:At,rows:Te,rowSpan:Te,sandbox:xn,scope:null,scoped:At,seamless:At,selected:At,shadowRootClonable:At,shadowRootDelegatesFocus:At,shadowRootMode:null,shape:null,size:Te,sizes:null,slot:null,span:Te,spellCheck:ir,src:null,srcDoc:null,srcLang:null,srcSet:null,start:Te,step:null,style:null,tabIndex:Te,target:null,title:null,translate:null,type:null,typeMustMatch:At,useMap:null,value:ir,width:Te,wrap:null,writingSuggestions:null,align:null,aLink:null,archive:xn,axis:null,background:null,bgColor:null,border:Te,borderColor:null,bottomMargin:Te,cellPadding:null,cellSpacing:null,char:null,charOff:null,classId:null,clear:null,code:null,codeBase:null,codeType:null,color:null,compact:At,declare:At,event:null,face:null,frame:null,frameBorder:null,hSpace:Te,leftMargin:Te,link:null,longDesc:null,lowSrc:null,marginHeight:Te,marginWidth:Te,noResize:At,noHref:At,noShade:At,noWrap:At,object:null,profile:null,prompt:null,rev:null,rightMargin:Te,rules:null,scheme:null,scrolling:ir,standby:null,summary:null,text:null,topMargin:Te,valueType:null,version:null,vAlign:null,vLink:null,vSpace:Te,allowTransparency:null,autoCorrect:null,autoSave:null,disablePictureInPicture:At,disableRemotePlayback:At,prefix:null,property:null,results:Te,security:null,unselectable:null},space:"html",transform:yR}),C8=iu({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:hs,accentHeight:Te,accumulate:null,additive:null,alignmentBaseline:null,alphabetic:Te,amplitude:Te,arabicForm:null,ascent:Te,attributeName:null,attributeType:null,azimuth:Te,bandwidth:null,baselineShift:null,baseFrequency:null,baseProfile:null,bbox:null,begin:null,bias:Te,by:null,calcMode:null,capHeight:Te,className:xn,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:Te,diffuseConstant:Te,direction:null,display:null,dur:null,divisor:Te,dominantBaseline:null,download:At,dx:null,dy:null,edgeMode:null,editable:null,elevation:Te,enableBackground:null,end:null,event:null,exponent:Te,externalResourcesRequired:null,fill:null,fillOpacity:Te,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:Ic,g2:Ic,glyphName:Ic,glyphOrientationHorizontal:null,glyphOrientationVertical:null,glyphRef:null,gradientTransform:null,gradientUnits:null,handler:null,hanging:Te,hatchContentUnits:null,hatchUnits:null,height:null,href:null,hrefLang:null,horizAdvX:Te,horizOriginX:Te,horizOriginY:Te,id:null,ideographic:Te,imageRendering:null,initialVisibility:null,in:null,in2:null,intercept:Te,k:Te,k1:Te,k2:Te,k3:Te,k4:Te,kernelMatrix:hs,kernelUnitLength:null,keyPoints:null,keySplines:null,keyTimes:null,kerning:null,lang:null,lengthAdjust:null,letterSpacing:null,lightingColor:null,limitingConeAngle:Te,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:Te,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:Te,overlineThickness:Te,paintOrder:null,panose1:null,path:null,pathLength:Te,patternContentUnits:null,patternTransform:null,patternUnits:null,phase:null,ping:xn,pitch:null,playbackOrder:null,pointerEvents:null,points:null,pointsAtX:Te,pointsAtY:Te,pointsAtZ:Te,preserveAlpha:null,preserveAspectRatio:null,primitiveUnits:null,propagate:null,property:hs,r:null,radius:null,referrerPolicy:null,refX:null,refY:null,rel:hs,rev:hs,renderingIntent:null,repeatCount:null,repeatDur:null,requiredExtensions:hs,requiredFeatures:hs,requiredFonts:hs,requiredFormats:hs,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:Te,specularExponent:Te,spreadMethod:null,spacing:null,startOffset:null,stdDeviation:null,stemh:null,stemv:null,stitchTiles:null,stopColor:null,stopOpacity:null,strikethroughPosition:Te,strikethroughThickness:Te,string:null,stroke:null,strokeDashArray:hs,strokeDashOffset:null,strokeLineCap:null,strokeLineJoin:null,strokeMiterLimit:Te,strokeOpacity:Te,strokeWidth:null,style:null,surfaceScale:Te,syncBehavior:null,syncBehaviorDefault:null,syncMaster:null,syncTolerance:null,syncToleranceDefault:null,systemLanguage:hs,tabIndex:Te,tableValues:null,target:null,targetX:Te,targetY:Te,textAnchor:null,textDecoration:null,textRendering:null,textLength:null,timelineBegin:null,title:null,transformBehavior:null,type:null,typeOf:hs,to:null,transform:null,transformOrigin:null,u1:null,u2:null,underlinePosition:Te,underlineThickness:Te,unicode:null,unicodeBidi:null,unicodeRange:null,unitsPerEm:Te,values:null,vAlphabetic:Te,vMathematical:Te,vectorEffect:null,vHanging:Te,vIdeographic:Te,version:null,vertAdvY:Te,vertOriginX:Te,vertOriginY:Te,viewBox:null,viewTarget:null,visibility:null,width:null,widths:null,wordSpacing:null,writingMode:null,x:null,x1:null,x2:null,xChannelSelector:null,xHeight:Te,y:null,y1:null,y2:null,yChannelSelector:null,z:null,zoomAndPan:null},space:"svg",transform:gR}),wR=iu({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()}}),xR=iu({attributes:{xmlnsxlink:"xmlns:xlink"},properties:{xmlnsXLink:null,xmlns:null},space:"xmlns",transform:yR}),bR=iu({properties:{xmlBase:null,xmlLang:null,xmlSpace:null},space:"xml",transform(e,t){return"xml:"+t.slice(3).toLowerCase()}}),A8={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"},E8=/[A-Z]/g,G_=/-[a-z]/g,I8=/^data[-\w.:]+$/i;function P8(e,t){const n=vb(t);let r=t,i=ds;if(n in e.normal)return e.property[e.normal[n]];if(n.length>4&&n.slice(0,4)==="data"&&I8.test(t)){if(t.charAt(4)==="-"){const o=t.slice(5).replace(G_,R8);r="data"+o.charAt(0).toUpperCase()+o.slice(1)}else{const o=t.slice(4);if(!G_.test(o)){let a=o.replace(E8,T8);a.charAt(0)!=="-"&&(a="-"+a),t="data"+a}}i=vv}return new i(r,t)}function T8(e){return"-"+e.toLowerCase()}function R8(e){return e.charAt(1).toUpperCase()}const M8=hR([mR,_8,wR,xR,bR],"html"),Sv=hR([mR,C8,wR,xR,bR],"svg");function $8(e){return e.join(" ").trim()}var jv={},Y_=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,L8=/\n/g,O8=/^\s*/,D8=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,F8=/^:\s*/,z8=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,B8=/^[;\s]*/,W8=/^\s+|\s+$/g,H8=`
|
|
67
|
+
`,J_="/",X_="*",za="",V8="comment",K8="declaration";function q8(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 i(y){var v=y.match(L8);v&&(n+=v.length);var b=y.lastIndexOf(H8);r=~b?y.length-b:r+y.length}function o(){var y={line:n,column:r};return function(v){return v.position=new a(y),u(),v}}function a(y){this.start=y,this.end={line:n,column:r},this.source=t.source}a.prototype.content=e;function l(y){var v=new Error(t.source+":"+n+":"+r+": "+y);if(v.reason=y,v.filename=t.source,v.line=n,v.column=r,v.source=e,!t.silent)throw v}function c(y){var v=y.exec(e);if(v){var b=v[0];return i(b),e=e.slice(b.length),v}}function u(){c(O8)}function f(y){var v;for(y=y||[];v=p();)v!==!1&&y.push(v);return y}function p(){var y=o();if(!(J_!=e.charAt(0)||X_!=e.charAt(1))){for(var v=2;za!=e.charAt(v)&&(X_!=e.charAt(v)||J_!=e.charAt(v+1));)++v;if(v+=2,za===e.charAt(v-1))return l("End of comment missing");var b=e.slice(2,v-2);return r+=2,i(b),e=e.slice(v),r+=2,y({type:V8,comment:b})}}function d(){var y=o(),v=c(D8);if(v){if(p(),!c(F8))return l("property missing ':'");var b=c(z8),g=y({type:K8,property:Q_(v[0].replace(Y_,za)),value:b?Q_(b[0].replace(Y_,za)):za});return c(B8),g}}function m(){var y=[];f(y);for(var v;v=d();)v!==!1&&(y.push(v),f(y));return y}return u(),m()}function Q_(e){return e?e.replace(W8,za):za}var U8=q8,G8=Fd&&Fd.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(jv,"__esModule",{value:!0});jv.default=J8;const Y8=G8(U8);function J8(e,t){let n=null;if(!e||typeof e!="string")return n;const r=(0,Y8.default)(e),i=typeof t=="function";return r.forEach(o=>{if(o.type!=="declaration")return;const{property:a,value:l}=o;i?t(a,l,o):l&&(n=n||{},n[a]=l)}),n}var Pg={};Object.defineProperty(Pg,"__esModule",{value:!0});Pg.camelCase=void 0;var X8=/^--[a-zA-Z0-9_-]+$/,Q8=/-([a-z])/g,Z8=/^[^-]+$/,eV=/^-(webkit|moz|ms|o|khtml)-/,tV=/^-(ms)-/,nV=function(e){return!e||Z8.test(e)||X8.test(e)},rV=function(e,t){return t.toUpperCase()},Z_=function(e,t){return"".concat(t,"-")},sV=function(e,t){return t===void 0&&(t={}),nV(e)?e:(e=e.toLowerCase(),t.reactCompat?e=e.replace(tV,Z_):e=e.replace(eV,Z_),e.replace(Q8,rV))};Pg.camelCase=sV;var iV=Fd&&Fd.__importDefault||function(e){return e&&e.__esModule?e:{default:e}},oV=iV(jv),aV=Pg;function Nb(e,t){var n={};return!e||typeof e!="string"||(0,oV.default)(e,function(r,i){r&&i&&(n[(0,aV.camelCase)(r,t)]=i)}),n}Nb.default=Nb;var lV=Nb;const cV=xa(lV),kR=vR("end"),Nv=vR("start");function vR(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 uV(e){const t=Nv(e),n=kR(e);if(t&&n)return{start:t,end:n}}function Rd(e){return!e||typeof e!="object"?"":"position"in e||"type"in e?e1(e.position):"start"in e||"end"in e?e1(e):"line"in e||"column"in e?_b(e):""}function _b(e){return t1(e&&e.line)+":"+t1(e&&e.column)}function e1(e){return _b(e&&e.start)+"-"+_b(e&&e.end)}function t1(e){return e&&typeof e=="number"?e:1}class Br extends Error{constructor(t,n,r){super(),typeof n=="string"&&(r=n,n=void 0);let i="",o={},a=!1;if(n&&("line"in n&&"column"in n?o={place:n}:"start"in n&&"end"in n?o={place:n}:"type"in n?o={ancestors:[n],place:n.position}:o={...n}),typeof t=="string"?i=t:!o.cause&&t&&(a=!0,i=t.message,o.cause=t),!o.ruleId&&!o.source&&typeof r=="string"){const c=r.indexOf(":");c===-1?o.ruleId=r:(o.source=r.slice(0,c),o.ruleId=r.slice(c+1))}if(!o.place&&o.ancestors&&o.ancestors){const c=o.ancestors[o.ancestors.length-1];c&&(o.place=c.position)}const l=o.place&&"start"in o.place?o.place.start:o.place;this.ancestors=o.ancestors||void 0,this.cause=o.cause||void 0,this.column=l?l.column:void 0,this.fatal=void 0,this.file="",this.message=i,this.line=l?l.line:void 0,this.name=Rd(o.place)||"1:1",this.place=o.place||void 0,this.reason=this.message,this.ruleId=o.ruleId||void 0,this.source=o.source||void 0,this.stack=a&&o.cause&&typeof o.cause.stack=="string"?o.cause.stack:"",this.actual=void 0,this.expected=void 0,this.note=void 0,this.url=void 0}}Br.prototype.file="";Br.prototype.name="";Br.prototype.reason="";Br.prototype.message="";Br.prototype.stack="";Br.prototype.column=void 0;Br.prototype.line=void 0;Br.prototype.ancestors=void 0;Br.prototype.cause=void 0;Br.prototype.fatal=void 0;Br.prototype.place=void 0;Br.prototype.ruleId=void 0;Br.prototype.source=void 0;const _v={}.hasOwnProperty,dV=new Map,fV=/[A-Z]/g,pV=new Set(["table","tbody","thead","tfoot","tr"]),hV=new Set(["td","th"]),SR="https://github.com/syntax-tree/hast-util-to-jsx-runtime";function mV(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=SV(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=vV(n,t.jsx,t.jsxs)}const i={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"?Sv:M8,stylePropertyNameCase:t.stylePropertyNameCase||"dom",tableCellAlignToStyle:t.tableCellAlignToStyle!==!1},o=jR(i,e,void 0);return o&&typeof o!="string"?o:i.create(e,i.Fragment,{children:o||void 0},void 0)}function jR(e,t,n){if(t.type==="element")return gV(e,t,n);if(t.type==="mdxFlowExpression"||t.type==="mdxTextExpression")return yV(e,t);if(t.type==="mdxJsxFlowElement"||t.type==="mdxJsxTextElement")return xV(e,t,n);if(t.type==="mdxjsEsm")return wV(e,t);if(t.type==="root")return bV(e,t,n);if(t.type==="text")return kV(e,t)}function gV(e,t,n){const r=e.schema;let i=r;t.tagName.toLowerCase()==="svg"&&r.space==="html"&&(i=Sv,e.schema=i),e.ancestors.push(t);const o=_R(e,t.tagName,!1),a=jV(e,t);let l=Av(e,t);return pV.has(t.tagName)&&(l=l.filter(function(c){return typeof c=="string"?!j8(c):!0})),NR(e,a,o,t),Cv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function yV(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)}pf(e,t.position)}function wV(e,t){if(t.data&&t.data.estree&&e.evaluater)return e.evaluater.evaluateProgram(t.data.estree);pf(e,t.position)}function xV(e,t,n){const r=e.schema;let i=r;t.name==="svg"&&r.space==="html"&&(i=Sv,e.schema=i),e.ancestors.push(t);const o=t.name===null?e.Fragment:_R(e,t.name,!0),a=NV(e,t),l=Av(e,t);return NR(e,a,o,t),Cv(a,l),e.ancestors.pop(),e.schema=r,e.create(t,o,a,n)}function bV(e,t,n){const r={};return Cv(r,Av(e,t)),e.create(t,e.Fragment,r,n)}function kV(e,t){return t.value}function NR(e,t,n,r){typeof n!="string"&&n!==e.Fragment&&e.passNode&&(t.node=r)}function Cv(e,t){if(t.length>0){const n=t.length>1?t:t[0];n&&(e.children=n)}}function vV(e,t,n){return r;function r(i,o,a,l){const u=Array.isArray(a.children)?n:t;return l?u(o,a,l):u(o,a)}}function SV(e,t){return n;function n(r,i,o,a){const l=Array.isArray(o.children),c=Nv(r);return t(i,o,a,l,{columnNumber:c?c.column-1:void 0,fileName:e,lineNumber:c?c.line:void 0},void 0)}}function jV(e,t){const n={};let r,i;for(i in t.properties)if(i!=="children"&&_v.call(t.properties,i)){const o=_V(e,i,t.properties[i]);if(o){const[a,l]=o;e.tableCellAlignToStyle&&a==="align"&&typeof l=="string"&&hV.has(t.tagName)?r=l:n[a]=l}}if(r){const o=n.style||(n.style={});o[e.stylePropertyNameCase==="css"?"text-align":"textAlign"]=r}return n}function NV(e,t){const n={};for(const r of t.attributes)if(r.type==="mdxJsxExpressionAttribute")if(r.data&&r.data.estree&&e.evaluater){const o=r.data.estree.body[0];o.type;const a=o.expression;a.type;const l=a.properties[0];l.type,Object.assign(n,e.evaluater.evaluateExpression(l.argument))}else pf(e,t.position);else{const i=r.name;let o;if(r.value&&typeof r.value=="object")if(r.value.data&&r.value.data.estree&&e.evaluater){const l=r.value.data.estree.body[0];l.type,o=e.evaluater.evaluateExpression(l.expression)}else pf(e,t.position);else o=r.value===null?!0:r.value;n[i]=o}return n}function Av(e,t){const n=[];let r=-1;const i=e.passKeys?new Map:dV;for(;++r<t.children.length;){const o=t.children[r];let a;if(e.passKeys){const c=o.type==="element"?o.tagName:o.type==="mdxJsxFlowElement"||o.type==="mdxJsxTextElement"?o.name:void 0;if(c){const u=i.get(c)||0;a=c+"-"+u,i.set(c,u+1)}}const l=jR(e,o,a);l!==void 0&&n.push(l)}return n}function _V(e,t,n){const r=P8(e.schema,t);if(!(n==null||typeof n=="number"&&Number.isNaN(n))){if(Array.isArray(n)&&(n=r.commaSeparated?x8(n):$8(n)),r.property==="style"){let i=typeof n=="object"?n:CV(e,String(n));return e.stylePropertyNameCase==="css"&&(i=AV(i)),["style",i]}return[e.elementAttributeNameCase==="react"&&r.space?A8[r.property]||r.property:r.attribute,n]}}function CV(e,t){try{return cV(t,{reactCompat:!0})}catch(n){if(e.ignoreInvalidStyle)return{};const r=n,i=new Br("Cannot parse `style` attribute",{ancestors:e.ancestors,cause:r,ruleId:"style",source:"hast-util-to-jsx-runtime"});throw i.file=e.filePath||void 0,i.url=SR+"#cannot-parse-style-attribute",i}}function _R(e,t,n){let r;if(!n)r={type:"Literal",value:t};else if(t.includes(".")){const i=t.split(".");let o=-1,a;for(;++o<i.length;){const l=K_(i[o])?{type:"Identifier",name:i[o]}:{type:"Literal",value:i[o]};a=a?{type:"MemberExpression",object:a,property:l,computed:!!(o&&l.type==="Literal"),optional:!1}:l}r=a}else r=K_(t)&&!/^[a-z]/.test(t)?{type:"Identifier",name:t}:{type:"Literal",value:t};if(r.type==="Literal"){const i=r.value;return _v.call(e.components,i)?e.components[i]:i}if(e.evaluater)return e.evaluater.evaluateExpression(r);pf(e)}function pf(e,t){const n=new Br("Cannot handle MDX estrees without `createEvaluater`",{ancestors:e.ancestors,place:t,ruleId:"mdx-estree",source:"hast-util-to-jsx-runtime"});throw n.file=e.filePath||void 0,n.url=SR+"#cannot-handle-mdx-estrees-without-createevaluater",n}function AV(e){const t={};let n;for(n in e)_v.call(e,n)&&(t[EV(n)]=e[n]);return t}function EV(e){let t=e.replace(fV,IV);return t.slice(0,3)==="ms-"&&(t="-"+t),t}function IV(e){return"-"+e.toLowerCase()}const vw={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"]},PV={};function TV(e,t){const n=PV,r=typeof n.includeImageAlt=="boolean"?n.includeImageAlt:!0,i=typeof n.includeHtml=="boolean"?n.includeHtml:!0;return CR(e,r,i)}function CR(e,t,n){if(RV(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 n1(e.children,t,n)}return Array.isArray(e)?n1(e,t,n):""}function n1(e,t,n){const r=[];let i=-1;for(;++i<e.length;)r[i]=CR(e[i],t,n);return r.join("")}function RV(e){return!!(e&&typeof e=="object")}const r1=document.createElement("i");function Ev(e){const t="&"+e+";";r1.innerHTML=t;const n=r1.textContent;return n.charCodeAt(n.length-1)===59&&e!=="semi"||n===t?!1:n}function Wi(e,t,n,r){const i=e.length;let o=0,a;if(t<0?t=-t>i?0:i+t:t=t>i?i:t,n=n>0?n:0,r.length<1e4)a=Array.from(r),a.unshift(t,n),e.splice(...a);else for(n&&e.splice(t,n);o<r.length;)a=r.slice(o,o+1e4),a.unshift(t,0),e.splice(...a),o+=1e4,t+=1e4}function Ds(e,t){return e.length>0?(Wi(e,e.length,0,t),e):t}const s1={}.hasOwnProperty;function MV(e){const t={};let n=-1;for(;++n<e.length;)$V(t,e[n]);return t}function $V(e,t){let n;for(n in t){const i=(s1.call(e,n)?e[n]:void 0)||(e[n]={}),o=t[n];let a;if(o)for(a in o){s1.call(i,a)||(i[a]=[]);const l=o[a];LV(i[a],Array.isArray(l)?l:l?[l]:[])}}}function LV(e,t){let n=-1;const r=[];for(;++n<t.length;)(t[n].add==="after"?e:r).push(t[n]);Wi(e,0,0,r)}function AR(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 Pc(e){return e.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}const Pi=Sa(/[A-Za-z]/),xs=Sa(/[\dA-Za-z]/),OV=Sa(/[#-'*+\--9=?A-Z^-~]/);function Cb(e){return e!==null&&(e<32||e===127)}const Ab=Sa(/\d/),DV=Sa(/[\dA-Fa-f]/),FV=Sa(/[!-/:-@[-`{-~]/);function bt(e){return e!==null&&e<-2}function cs(e){return e!==null&&(e<0||e===32)}function nn(e){return e===-2||e===-1||e===32}const zV=Sa(new RegExp("\\p{P}|\\p{S}","u")),BV=Sa(/\s/);function Sa(e){return t;function t(n){return n!==null&&n>-1&&e.test(String.fromCharCode(n))}}function ou(e){const t=[];let n=-1,r=0,i=0;for(;++n<e.length;){const o=e.charCodeAt(n);let a="";if(o===37&&xs(e.charCodeAt(n+1))&&xs(e.charCodeAt(n+2)))i=2;else if(o<128)/[!#$&-;=?-Z_a-z~]/.test(String.fromCharCode(o))||(a=String.fromCharCode(o));else if(o>55295&&o<57344){const l=e.charCodeAt(n+1);o<56320&&l>56319&&l<57344?(a=String.fromCharCode(o,l),i=1):a="�"}else a=String.fromCharCode(o);a&&(t.push(e.slice(r,n),encodeURIComponent(a)),r=n+i+1,a=""),i&&(n+=i,i=0)}return t.join("")+e.slice(r)}function kn(e,t,n,r){const i=r?r-1:Number.POSITIVE_INFINITY;let o=0;return a;function a(c){return nn(c)?(e.enter(n),l(c)):t(c)}function l(c){return nn(c)&&o++<i?(e.consume(c),l):(e.exit(n),t(c))}}const WV={tokenize:HV};function HV(e){const t=e.attempt(this.parser.constructs.contentInitial,r,i);let n;return t;function r(l){if(l===null){e.consume(l);return}return e.enter("lineEnding"),e.consume(l),e.exit("lineEnding"),kn(e,t,"linePrefix")}function i(l){return e.enter("paragraph"),o(l)}function o(l){const c=e.enter("chunkText",{contentType:"text",previous:n});return n&&(n.next=c),n=c,a(l)}function a(l){if(l===null){e.exit("chunkText"),e.exit("paragraph"),e.consume(l);return}return bt(l)?(e.consume(l),e.exit("chunkText"),o):(e.consume(l),a)}}const VV={tokenize:KV},i1={tokenize:qV};function KV(e){const t=this,n=[];let r=0,i,o,a;return l;function l(x){if(r<n.length){const _=n[r];return t.containerState=_[1],e.attempt(_[0].continuation,c,u)(x)}return u(x)}function c(x){if(r++,t.containerState._closeFlow){t.containerState._closeFlow=void 0,i&&k();const _=t.events.length;let j=_,N;for(;j--;)if(t.events[j][0]==="exit"&&t.events[j][1].type==="chunkFlow"){N=t.events[j][1].end;break}g(r);let P=_;for(;P<t.events.length;)t.events[P][1].end={...N},P++;return Wi(t.events,j+1,0,t.events.slice(_)),t.events.length=P,u(x)}return l(x)}function u(x){if(r===n.length){if(!i)return d(x);if(i.currentConstruct&&i.currentConstruct.concrete)return y(x);t.interrupt=!!(i.currentConstruct&&!i._gfmTableDynamicInterruptHack)}return t.containerState={},e.check(i1,f,p)(x)}function f(x){return i&&k(),g(r),d(x)}function p(x){return t.parser.lazy[t.now().line]=r!==n.length,a=t.now().offset,y(x)}function d(x){return t.containerState={},e.attempt(i1,m,y)(x)}function m(x){return r++,n.push([t.currentConstruct,t.containerState]),d(x)}function y(x){if(x===null){i&&k(),g(0),e.consume(x);return}return i=i||t.parser.flow(t.now()),e.enter("chunkFlow",{_tokenizer:i,contentType:"flow",previous:o}),v(x)}function v(x){if(x===null){b(e.exit("chunkFlow"),!0),g(0),e.consume(x);return}return bt(x)?(e.consume(x),b(e.exit("chunkFlow")),r=0,t.interrupt=void 0,l):(e.consume(x),v)}function b(x,_){const j=t.sliceStream(x);if(_&&j.push(null),x.previous=o,o&&(o.next=x),o=x,i.defineSkip(x.start),i.write(j),t.parser.lazy[x.start.line]){let N=i.events.length;for(;N--;)if(i.events[N][1].start.offset<a&&(!i.events[N][1].end||i.events[N][1].end.offset>a))return;const P=t.events.length;let T=P,z,E;for(;T--;)if(t.events[T][0]==="exit"&&t.events[T][1].type==="chunkFlow"){if(z){E=t.events[T][1].end;break}z=!0}for(g(r),N=P;N<t.events.length;)t.events[N][1].end={...E},N++;Wi(t.events,T+1,0,t.events.slice(P)),t.events.length=N}}function g(x){let _=n.length;for(;_-- >x;){const j=n[_];t.containerState=j[1],j[0].exit.call(t,e)}n.length=x}function k(){i.write([null]),o=void 0,i=void 0,t.containerState._closeFlow=void 0}}function qV(e,t,n){return kn(e,e.attempt(this.parser.constructs.document,t,n),"linePrefix",this.parser.constructs.disable.null.includes("codeIndented")?void 0:4)}function o1(e){if(e===null||cs(e)||BV(e))return 1;if(zV(e))return 2}function Iv(e,t,n){const r=[];let i=-1;for(;++i<e.length;){const o=e[i].resolveAll;o&&!r.includes(o)&&(t=o(t,n),r.push(o))}return t}const Eb={name:"attention",resolveAll:UV,tokenize:GV};function UV(e,t){let n=-1,r,i,o,a,l,c,u,f;for(;++n<e.length;)if(e[n][0]==="enter"&&e[n][1].type==="attentionSequence"&&e[n][1]._close){for(r=n;r--;)if(e[r][0]==="exit"&&e[r][1].type==="attentionSequence"&&e[r][1]._open&&t.sliceSerialize(e[r][1]).charCodeAt(0)===t.sliceSerialize(e[n][1]).charCodeAt(0)){if((e[r][1]._close||e[n][1]._open)&&(e[n][1].end.offset-e[n][1].start.offset)%3&&!((e[r][1].end.offset-e[r][1].start.offset+e[n][1].end.offset-e[n][1].start.offset)%3))continue;c=e[r][1].end.offset-e[r][1].start.offset>1&&e[n][1].end.offset-e[n][1].start.offset>1?2:1;const p={...e[r][1].end},d={...e[n][1].start};a1(p,-c),a1(d,c),a={type:c>1?"strongSequence":"emphasisSequence",start:p,end:{...e[r][1].end}},l={type:c>1?"strongSequence":"emphasisSequence",start:{...e[n][1].start},end:d},o={type:c>1?"strongText":"emphasisText",start:{...e[r][1].end},end:{...e[n][1].start}},i={type:c>1?"strong":"emphasis",start:{...a.start},end:{...l.end}},e[r][1].end={...a.start},e[n][1].start={...l.end},u=[],e[r][1].end.offset-e[r][1].start.offset&&(u=Ds(u,[["enter",e[r][1],t],["exit",e[r][1],t]])),u=Ds(u,[["enter",i,t],["enter",a,t],["exit",a,t],["enter",o,t]]),u=Ds(u,Iv(t.parser.constructs.insideSpan.null,e.slice(r+1,n),t)),u=Ds(u,[["exit",o,t],["enter",l,t],["exit",l,t],["exit",i,t]]),e[n][1].end.offset-e[n][1].start.offset?(f=2,u=Ds(u,[["enter",e[n][1],t],["exit",e[n][1],t]])):f=0,Wi(e,r-1,n-r+3,u),n=r+u.length-f-2;break}}for(n=-1;++n<e.length;)e[n][1].type==="attentionSequence"&&(e[n][1].type="data");return e}function GV(e,t){const n=this.parser.constructs.attentionMarkers.null,r=this.previous,i=o1(r);let o;return a;function a(c){return o=c,e.enter("attentionSequence"),l(c)}function l(c){if(c===o)return e.consume(c),l;const u=e.exit("attentionSequence"),f=o1(c),p=!f||f===2&&i||n.includes(c),d=!i||i===2&&f||n.includes(r);return u._open=!!(o===42?p:p&&(i||!d)),u._close=!!(o===42?d:d&&(f||!p)),t(c)}}function a1(e,t){e.column+=t,e.offset+=t,e._bufferIndex+=t}const YV={name:"autolink",tokenize:JV};function JV(e,t,n){let r=0;return i;function i(m){return e.enter("autolink"),e.enter("autolinkMarker"),e.consume(m),e.exit("autolinkMarker"),e.enter("autolinkProtocol"),o}function o(m){return Pi(m)?(e.consume(m),a):m===64?n(m):u(m)}function a(m){return m===43||m===45||m===46||xs(m)?(r=1,l(m)):u(m)}function l(m){return m===58?(e.consume(m),r=0,c):(m===43||m===45||m===46||xs(m))&&r++<32?(e.consume(m),l):(r=0,u(m))}function c(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||Cb(m)?n(m):(e.consume(m),c)}function u(m){return m===64?(e.consume(m),f):OV(m)?(e.consume(m),u):n(m)}function f(m){return xs(m)?p(m):n(m)}function p(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):d(m)}function d(m){if((m===45||xs(m))&&r++<63){const y=m===45?d:p;return e.consume(m),y}return n(m)}}const Tg={partial:!0,tokenize:XV};function XV(e,t,n){return r;function r(o){return nn(o)?kn(e,i,"linePrefix")(o):i(o)}function i(o){return o===null||bt(o)?t(o):n(o)}}const ER={continuation:{tokenize:ZV},exit:e9,name:"blockQuote",tokenize:QV};function QV(e,t,n){const r=this;return i;function i(a){if(a===62){const l=r.containerState;return l.open||(e.enter("blockQuote",{_container:!0}),l.open=!0),e.enter("blockQuotePrefix"),e.enter("blockQuoteMarker"),e.consume(a),e.exit("blockQuoteMarker"),o}return n(a)}function o(a){return nn(a)?(e.enter("blockQuotePrefixWhitespace"),e.consume(a),e.exit("blockQuotePrefixWhitespace"),e.exit("blockQuotePrefix"),t):(e.exit("blockQuotePrefix"),t(a))}}function ZV(e,t,n){const r=this;return i;function i(a){return nn(a)?kn(e,o,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(a):o(a)}function o(a){return e.attempt(ER,t,n)(a)}}function e9(e){e.exit("blockQuote")}const IR={name:"characterEscape",tokenize:t9};function t9(e,t,n){return r;function r(o){return e.enter("characterEscape"),e.enter("escapeMarker"),e.consume(o),e.exit("escapeMarker"),i}function i(o){return FV(o)?(e.enter("characterEscapeValue"),e.consume(o),e.exit("characterEscapeValue"),e.exit("characterEscape"),t):n(o)}}const PR={name:"characterReference",tokenize:n9};function n9(e,t,n){const r=this;let i=0,o,a;return l;function l(p){return e.enter("characterReference"),e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),c}function c(p){return p===35?(e.enter("characterReferenceMarkerNumeric"),e.consume(p),e.exit("characterReferenceMarkerNumeric"),u):(e.enter("characterReferenceValue"),o=31,a=xs,f(p))}function u(p){return p===88||p===120?(e.enter("characterReferenceMarkerHexadecimal"),e.consume(p),e.exit("characterReferenceMarkerHexadecimal"),e.enter("characterReferenceValue"),o=6,a=DV,f):(e.enter("characterReferenceValue"),o=7,a=Ab,f(p))}function f(p){if(p===59&&i){const d=e.exit("characterReferenceValue");return a===xs&&!Ev(r.sliceSerialize(d))?n(p):(e.enter("characterReferenceMarker"),e.consume(p),e.exit("characterReferenceMarker"),e.exit("characterReference"),t)}return a(p)&&i++<o?(e.consume(p),f):n(p)}}const l1={partial:!0,tokenize:s9},c1={concrete:!0,name:"codeFenced",tokenize:r9};function r9(e,t,n){const r=this,i={partial:!0,tokenize:j};let o=0,a=0,l;return c;function c(N){return u(N)}function u(N){const P=r.events[r.events.length-1];return o=P&&P[1].type==="linePrefix"?P[2].sliceSerialize(P[1],!0).length:0,l=N,e.enter("codeFenced"),e.enter("codeFencedFence"),e.enter("codeFencedFenceSequence"),f(N)}function f(N){return N===l?(a++,e.consume(N),f):a<3?n(N):(e.exit("codeFencedFenceSequence"),nn(N)?kn(e,p,"whitespace")(N):p(N))}function p(N){return N===null||bt(N)?(e.exit("codeFencedFence"),r.interrupt?t(N):e.check(l1,v,_)(N)):(e.enter("codeFencedFenceInfo"),e.enter("chunkString",{contentType:"string"}),d(N))}function d(N){return N===null||bt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),p(N)):nn(N)?(e.exit("chunkString"),e.exit("codeFencedFenceInfo"),kn(e,m,"whitespace")(N)):N===96&&N===l?n(N):(e.consume(N),d)}function m(N){return N===null||bt(N)?p(N):(e.enter("codeFencedFenceMeta"),e.enter("chunkString",{contentType:"string"}),y(N))}function y(N){return N===null||bt(N)?(e.exit("chunkString"),e.exit("codeFencedFenceMeta"),p(N)):N===96&&N===l?n(N):(e.consume(N),y)}function v(N){return e.attempt(i,_,b)(N)}function b(N){return e.enter("lineEnding"),e.consume(N),e.exit("lineEnding"),g}function g(N){return o>0&&nn(N)?kn(e,k,"linePrefix",o+1)(N):k(N)}function k(N){return N===null||bt(N)?e.check(l1,v,_)(N):(e.enter("codeFlowValue"),x(N))}function x(N){return N===null||bt(N)?(e.exit("codeFlowValue"),k(N)):(e.consume(N),x)}function _(N){return e.exit("codeFenced"),t(N)}function j(N,P,T){let z=0;return E;function E(V){return N.enter("lineEnding"),N.consume(V),N.exit("lineEnding"),O}function O(V){return N.enter("codeFencedFence"),nn(V)?kn(N,D,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(V):D(V)}function D(V){return V===l?(N.enter("codeFencedFenceSequence"),L(V)):T(V)}function L(V){return V===l?(z++,N.consume(V),L):z>=a?(N.exit("codeFencedFenceSequence"),nn(V)?kn(N,$,"whitespace")(V):$(V)):T(V)}function $(V){return V===null||bt(V)?(N.exit("codeFencedFence"),P(V)):T(V)}}}function s9(e,t,n){const r=this;return i;function i(a){return a===null?n(a):(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}const Sw={name:"codeIndented",tokenize:o9},i9={partial:!0,tokenize:a9};function o9(e,t,n){const r=this;return i;function i(u){return e.enter("codeIndented"),kn(e,o,"linePrefix",5)(u)}function o(u){const f=r.events[r.events.length-1];return f&&f[1].type==="linePrefix"&&f[2].sliceSerialize(f[1],!0).length>=4?a(u):n(u)}function a(u){return u===null?c(u):bt(u)?e.attempt(i9,a,c)(u):(e.enter("codeFlowValue"),l(u))}function l(u){return u===null||bt(u)?(e.exit("codeFlowValue"),a(u)):(e.consume(u),l)}function c(u){return e.exit("codeIndented"),t(u)}}function a9(e,t,n){const r=this;return i;function i(a){return r.parser.lazy[r.now().line]?n(a):bt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),i):kn(e,o,"linePrefix",5)(a)}function o(a){const l=r.events[r.events.length-1];return l&&l[1].type==="linePrefix"&&l[2].sliceSerialize(l[1],!0).length>=4?t(a):bt(a)?i(a):n(a)}}const l9={name:"codeText",previous:u9,resolve:c9,tokenize:d9};function c9(e){let t=e.length-4,n=3,r,i;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;)i===void 0?r!==t&&e[r][1].type!=="lineEnding"&&(i=r):(r===t||e[r][1].type==="lineEnding")&&(e[i][1].type="codeTextData",r!==i+2&&(e[i][1].end=e[r-1][1].end,e.splice(i+2,r-i-2),t-=r-i-2,r=i+2),i=void 0);return e}function u9(e){return e!==96||this.events[this.events.length-1][1].type==="characterEscape"}function d9(e,t,n){let r=0,i,o;return a;function a(p){return e.enter("codeText"),e.enter("codeTextSequence"),l(p)}function l(p){return p===96?(e.consume(p),r++,l):(e.exit("codeTextSequence"),c(p))}function c(p){return p===null?n(p):p===32?(e.enter("space"),e.consume(p),e.exit("space"),c):p===96?(o=e.enter("codeTextSequence"),i=0,f(p)):bt(p)?(e.enter("lineEnding"),e.consume(p),e.exit("lineEnding"),c):(e.enter("codeTextData"),u(p))}function u(p){return p===null||p===32||p===96||bt(p)?(e.exit("codeTextData"),c(p)):(e.consume(p),u)}function f(p){return p===96?(e.consume(p),i++,f):i===r?(e.exit("codeTextSequence"),e.exit("codeText"),t(p)):(o.type="codeTextData",u(p))}}class f9{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 i=n||0;this.setCursor(Math.trunc(t));const o=this.right.splice(this.right.length-i,Number.POSITIVE_INFINITY);return r&&Zu(this.left,r),o.reverse()}pop(){return this.setCursor(Number.POSITIVE_INFINITY),this.left.pop()}push(t){this.setCursor(Number.POSITIVE_INFINITY),this.left.push(t)}pushMany(t){this.setCursor(Number.POSITIVE_INFINITY),Zu(this.left,t)}unshift(t){this.setCursor(0),this.right.push(t)}unshiftMany(t){this.setCursor(0),Zu(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);Zu(this.right,n.reverse())}else{const n=this.right.splice(this.left.length+this.right.length-t,Number.POSITIVE_INFINITY);Zu(this.left,n.reverse())}}}function Zu(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 TR(e){const t={};let n=-1,r,i,o,a,l,c,u;const f=new f9(e);for(;++n<f.length;){for(;n in t;)n=t[n];if(r=f.get(n),n&&r[1].type==="chunkFlow"&&f.get(n-1)[1].type==="listItemPrefix"&&(c=r[1]._tokenizer.events,o=0,o<c.length&&c[o][1].type==="lineEndingBlank"&&(o+=2),o<c.length&&c[o][1].type==="content"))for(;++o<c.length&&c[o][1].type!=="content";)c[o][1].type==="chunkText"&&(c[o][1]._isInFirstContentOfListItem=!0,o++);if(r[0]==="enter")r[1].contentType&&(Object.assign(t,p9(f,n)),n=t[n],u=!0);else if(r[1]._container){for(o=n,i=void 0;o--;)if(a=f.get(o),a[1].type==="lineEnding"||a[1].type==="lineEndingBlank")a[0]==="enter"&&(i&&(f.get(i)[1].type="lineEndingBlank"),a[1].type="lineEnding",i=o);else if(!(a[1].type==="linePrefix"||a[1].type==="listItemIndent"))break;i&&(r[1].end={...f.get(i)[1].start},l=f.slice(i,n),l.unshift(r),f.splice(i,n-i+1,l))}}return Wi(e,0,Number.POSITIVE_INFINITY,f.slice(0)),!u}function p9(e,t){const n=e.get(t)[1],r=e.get(t)[2];let i=t-1;const o=[];let a=n._tokenizer;a||(a=r.parser[n.contentType](n.start),n._contentTypeTextTrailing&&(a._contentTypeTextTrailing=!0));const l=a.events,c=[],u={};let f,p,d=-1,m=n,y=0,v=0;const b=[v];for(;m;){for(;e.get(++i)[1]!==m;);o.push(i),m._tokenizer||(f=r.sliceStream(m),m.next||f.push(null),p&&a.defineSkip(m.start),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=!0),a.write(f),m._isInFirstContentOfListItem&&(a._gfmTasklistFirstContentOfListItem=void 0)),p=m,m=m.next}for(m=n;++d<l.length;)l[d][0]==="exit"&&l[d-1][0]==="enter"&&l[d][1].type===l[d-1][1].type&&l[d][1].start.line!==l[d][1].end.line&&(v=d+1,b.push(v),m._tokenizer=void 0,m.previous=void 0,m=m.next);for(a.events=[],m?(m._tokenizer=void 0,m.previous=void 0):b.pop(),d=b.length;d--;){const g=l.slice(b[d],b[d+1]),k=o.pop();c.push([k,k+g.length-1]),e.splice(k,2,g)}for(c.reverse(),d=-1;++d<c.length;)u[y+c[d][0]]=y+c[d][1],y+=c[d][1]-c[d][0]-1;return u}const h9={resolve:g9,tokenize:y9},m9={partial:!0,tokenize:w9};function g9(e){return TR(e),e}function y9(e,t){let n;return r;function r(l){return e.enter("content"),n=e.enter("chunkContent",{contentType:"content"}),i(l)}function i(l){return l===null?o(l):bt(l)?e.check(m9,a,o)(l):(e.consume(l),i)}function o(l){return e.exit("chunkContent"),e.exit("content"),t(l)}function a(l){return e.consume(l),e.exit("chunkContent"),n.next=e.enter("chunkContent",{contentType:"content",previous:n}),n=n.next,i}}function w9(e,t,n){const r=this;return i;function i(a){return e.exit("chunkContent"),e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),kn(e,o,"linePrefix")}function o(a){if(a===null||bt(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 RR(e,t,n,r,i,o,a,l,c){const u=c||Number.POSITIVE_INFINITY;let f=0;return p;function p(g){return g===60?(e.enter(r),e.enter(i),e.enter(o),e.consume(g),e.exit(o),d):g===null||g===32||g===41||Cb(g)?n(g):(e.enter(r),e.enter(a),e.enter(l),e.enter("chunkString",{contentType:"string"}),v(g))}function d(g){return g===62?(e.enter(o),e.consume(g),e.exit(o),e.exit(i),e.exit(r),t):(e.enter(l),e.enter("chunkString",{contentType:"string"}),m(g))}function m(g){return g===62?(e.exit("chunkString"),e.exit(l),d(g)):g===null||g===60||bt(g)?n(g):(e.consume(g),g===92?y:m)}function y(g){return g===60||g===62||g===92?(e.consume(g),m):m(g)}function v(g){return!f&&(g===null||g===41||cs(g))?(e.exit("chunkString"),e.exit(l),e.exit(a),e.exit(r),t(g)):f<u&&g===40?(e.consume(g),f++,v):g===41?(e.consume(g),f--,v):g===null||g===32||g===40||Cb(g)?n(g):(e.consume(g),g===92?b:v)}function b(g){return g===40||g===41||g===92?(e.consume(g),v):v(g)}}function MR(e,t,n,r,i,o){const a=this;let l=0,c;return u;function u(m){return e.enter(r),e.enter(i),e.consume(m),e.exit(i),e.enter(o),f}function f(m){return l>999||m===null||m===91||m===93&&!c||m===94&&!l&&"_hiddenFootnoteSupport"in a.parser.constructs?n(m):m===93?(e.exit(o),e.enter(i),e.consume(m),e.exit(i),e.exit(r),t):bt(m)?(e.enter("lineEnding"),e.consume(m),e.exit("lineEnding"),f):(e.enter("chunkString",{contentType:"string"}),p(m))}function p(m){return m===null||m===91||m===93||bt(m)||l++>999?(e.exit("chunkString"),f(m)):(e.consume(m),c||(c=!nn(m)),m===92?d:p)}function d(m){return m===91||m===92||m===93?(e.consume(m),l++,p):p(m)}}function $R(e,t,n,r,i,o){let a;return l;function l(d){return d===34||d===39||d===40?(e.enter(r),e.enter(i),e.consume(d),e.exit(i),a=d===40?41:d,c):n(d)}function c(d){return d===a?(e.enter(i),e.consume(d),e.exit(i),e.exit(r),t):(e.enter(o),u(d))}function u(d){return d===a?(e.exit(o),c(a)):d===null?n(d):bt(d)?(e.enter("lineEnding"),e.consume(d),e.exit("lineEnding"),kn(e,u,"linePrefix")):(e.enter("chunkString",{contentType:"string"}),f(d))}function f(d){return d===a||d===null||bt(d)?(e.exit("chunkString"),u(d)):(e.consume(d),d===92?p:f)}function p(d){return d===a||d===92?(e.consume(d),f):f(d)}}function Md(e,t){let n;return r;function r(i){return bt(i)?(e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),n=!0,r):nn(i)?kn(e,r,n?"linePrefix":"lineSuffix")(i):t(i)}}const x9={name:"definition",tokenize:k9},b9={partial:!0,tokenize:v9};function k9(e,t,n){const r=this;let i;return o;function o(m){return e.enter("definition"),a(m)}function a(m){return MR.call(r,e,l,n,"definitionLabel","definitionLabelMarker","definitionLabelString")(m)}function l(m){return i=Pc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)),m===58?(e.enter("definitionMarker"),e.consume(m),e.exit("definitionMarker"),c):n(m)}function c(m){return cs(m)?Md(e,u)(m):u(m)}function u(m){return RR(e,f,n,"definitionDestination","definitionDestinationLiteral","definitionDestinationLiteralMarker","definitionDestinationRaw","definitionDestinationString")(m)}function f(m){return e.attempt(b9,p,p)(m)}function p(m){return nn(m)?kn(e,d,"whitespace")(m):d(m)}function d(m){return m===null||bt(m)?(e.exit("definition"),r.parser.defined.push(i),t(m)):n(m)}}function v9(e,t,n){return r;function r(l){return cs(l)?Md(e,i)(l):n(l)}function i(l){return $R(e,o,n,"definitionTitle","definitionTitleMarker","definitionTitleString")(l)}function o(l){return nn(l)?kn(e,a,"whitespace")(l):a(l)}function a(l){return l===null||bt(l)?t(l):n(l)}}const S9={name:"hardBreakEscape",tokenize:j9};function j9(e,t,n){return r;function r(o){return e.enter("hardBreakEscape"),e.consume(o),i}function i(o){return bt(o)?(e.exit("hardBreakEscape"),t(o)):n(o)}}const N9={name:"headingAtx",resolve:_9,tokenize:C9};function _9(e,t){let n=e.length-2,r=3,i,o;return e[r][1].type==="whitespace"&&(r+=2),n-2>r&&e[n][1].type==="whitespace"&&(n-=2),e[n][1].type==="atxHeadingSequence"&&(r===n-1||n-4>r&&e[n-2][1].type==="whitespace")&&(n-=r+1===n?2:4),n>r&&(i={type:"atxHeadingText",start:e[r][1].start,end:e[n][1].end},o={type:"chunkText",start:e[r][1].start,end:e[n][1].end,contentType:"text"},Wi(e,r,n-r+1,[["enter",i,t],["enter",o,t],["exit",o,t],["exit",i,t]])),e}function C9(e,t,n){let r=0;return i;function i(f){return e.enter("atxHeading"),o(f)}function o(f){return e.enter("atxHeadingSequence"),a(f)}function a(f){return f===35&&r++<6?(e.consume(f),a):f===null||cs(f)?(e.exit("atxHeadingSequence"),l(f)):n(f)}function l(f){return f===35?(e.enter("atxHeadingSequence"),c(f)):f===null||bt(f)?(e.exit("atxHeading"),t(f)):nn(f)?kn(e,l,"whitespace")(f):(e.enter("atxHeadingText"),u(f))}function c(f){return f===35?(e.consume(f),c):(e.exit("atxHeadingSequence"),l(f))}function u(f){return f===null||f===35||cs(f)?(e.exit("atxHeadingText"),l(f)):(e.consume(f),u)}}const A9=["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"],u1=["pre","script","style","textarea"],E9={concrete:!0,name:"htmlFlow",resolveTo:T9,tokenize:R9},I9={partial:!0,tokenize:$9},P9={partial:!0,tokenize:M9};function T9(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 R9(e,t,n){const r=this;let i,o,a,l,c;return u;function u(B){return f(B)}function f(B){return e.enter("htmlFlow"),e.enter("htmlFlowData"),e.consume(B),p}function p(B){return B===33?(e.consume(B),d):B===47?(e.consume(B),o=!0,v):B===63?(e.consume(B),i=3,r.interrupt?t:A):Pi(B)?(e.consume(B),a=String.fromCharCode(B),b):n(B)}function d(B){return B===45?(e.consume(B),i=2,m):B===91?(e.consume(B),i=5,l=0,y):Pi(B)?(e.consume(B),i=4,r.interrupt?t:A):n(B)}function m(B){return B===45?(e.consume(B),r.interrupt?t:A):n(B)}function y(B){const ne="CDATA[";return B===ne.charCodeAt(l++)?(e.consume(B),l===ne.length?r.interrupt?t:D:y):n(B)}function v(B){return Pi(B)?(e.consume(B),a=String.fromCharCode(B),b):n(B)}function b(B){if(B===null||B===47||B===62||cs(B)){const ne=B===47,ce=a.toLowerCase();return!ne&&!o&&u1.includes(ce)?(i=1,r.interrupt?t(B):D(B)):A9.includes(a.toLowerCase())?(i=6,ne?(e.consume(B),g):r.interrupt?t(B):D(B)):(i=7,r.interrupt&&!r.parser.lazy[r.now().line]?n(B):o?k(B):x(B))}return B===45||xs(B)?(e.consume(B),a+=String.fromCharCode(B),b):n(B)}function g(B){return B===62?(e.consume(B),r.interrupt?t:D):n(B)}function k(B){return nn(B)?(e.consume(B),k):E(B)}function x(B){return B===47?(e.consume(B),E):B===58||B===95||Pi(B)?(e.consume(B),_):nn(B)?(e.consume(B),x):E(B)}function _(B){return B===45||B===46||B===58||B===95||xs(B)?(e.consume(B),_):j(B)}function j(B){return B===61?(e.consume(B),N):nn(B)?(e.consume(B),j):x(B)}function N(B){return B===null||B===60||B===61||B===62||B===96?n(B):B===34||B===39?(e.consume(B),c=B,P):nn(B)?(e.consume(B),N):T(B)}function P(B){return B===c?(e.consume(B),c=null,z):B===null||bt(B)?n(B):(e.consume(B),P)}function T(B){return B===null||B===34||B===39||B===47||B===60||B===61||B===62||B===96||cs(B)?j(B):(e.consume(B),T)}function z(B){return B===47||B===62||nn(B)?x(B):n(B)}function E(B){return B===62?(e.consume(B),O):n(B)}function O(B){return B===null||bt(B)?D(B):nn(B)?(e.consume(B),O):n(B)}function D(B){return B===45&&i===2?(e.consume(B),W):B===60&&i===1?(e.consume(B),F):B===62&&i===4?(e.consume(B),X):B===63&&i===3?(e.consume(B),A):B===93&&i===5?(e.consume(B),H):bt(B)&&(i===6||i===7)?(e.exit("htmlFlowData"),e.check(I9,q,L)(B)):B===null||bt(B)?(e.exit("htmlFlowData"),L(B)):(e.consume(B),D)}function L(B){return e.check(P9,$,q)(B)}function $(B){return e.enter("lineEnding"),e.consume(B),e.exit("lineEnding"),V}function V(B){return B===null||bt(B)?L(B):(e.enter("htmlFlowData"),D(B))}function W(B){return B===45?(e.consume(B),A):D(B)}function F(B){return B===47?(e.consume(B),a="",M):D(B)}function M(B){if(B===62){const ne=a.toLowerCase();return u1.includes(ne)?(e.consume(B),X):D(B)}return Pi(B)&&a.length<8?(e.consume(B),a+=String.fromCharCode(B),M):D(B)}function H(B){return B===93?(e.consume(B),A):D(B)}function A(B){return B===62?(e.consume(B),X):B===45&&i===2?(e.consume(B),A):D(B)}function X(B){return B===null||bt(B)?(e.exit("htmlFlowData"),q(B)):(e.consume(B),X)}function q(B){return e.exit("htmlFlow"),t(B)}}function M9(e,t,n){const r=this;return i;function i(a){return bt(a)?(e.enter("lineEnding"),e.consume(a),e.exit("lineEnding"),o):n(a)}function o(a){return r.parser.lazy[r.now().line]?n(a):t(a)}}function $9(e,t,n){return r;function r(i){return e.enter("lineEnding"),e.consume(i),e.exit("lineEnding"),e.attempt(Tg,t,n)}}const L9={name:"htmlText",tokenize:O9};function O9(e,t,n){const r=this;let i,o,a;return l;function l(A){return e.enter("htmlText"),e.enter("htmlTextData"),e.consume(A),c}function c(A){return A===33?(e.consume(A),u):A===47?(e.consume(A),j):A===63?(e.consume(A),x):Pi(A)?(e.consume(A),T):n(A)}function u(A){return A===45?(e.consume(A),f):A===91?(e.consume(A),o=0,y):Pi(A)?(e.consume(A),k):n(A)}function f(A){return A===45?(e.consume(A),m):n(A)}function p(A){return A===null?n(A):A===45?(e.consume(A),d):bt(A)?(a=p,F(A)):(e.consume(A),p)}function d(A){return A===45?(e.consume(A),m):p(A)}function m(A){return A===62?W(A):A===45?d(A):p(A)}function y(A){const X="CDATA[";return A===X.charCodeAt(o++)?(e.consume(A),o===X.length?v:y):n(A)}function v(A){return A===null?n(A):A===93?(e.consume(A),b):bt(A)?(a=v,F(A)):(e.consume(A),v)}function b(A){return A===93?(e.consume(A),g):v(A)}function g(A){return A===62?W(A):A===93?(e.consume(A),g):v(A)}function k(A){return A===null||A===62?W(A):bt(A)?(a=k,F(A)):(e.consume(A),k)}function x(A){return A===null?n(A):A===63?(e.consume(A),_):bt(A)?(a=x,F(A)):(e.consume(A),x)}function _(A){return A===62?W(A):x(A)}function j(A){return Pi(A)?(e.consume(A),N):n(A)}function N(A){return A===45||xs(A)?(e.consume(A),N):P(A)}function P(A){return bt(A)?(a=P,F(A)):nn(A)?(e.consume(A),P):W(A)}function T(A){return A===45||xs(A)?(e.consume(A),T):A===47||A===62||cs(A)?z(A):n(A)}function z(A){return A===47?(e.consume(A),W):A===58||A===95||Pi(A)?(e.consume(A),E):bt(A)?(a=z,F(A)):nn(A)?(e.consume(A),z):W(A)}function E(A){return A===45||A===46||A===58||A===95||xs(A)?(e.consume(A),E):O(A)}function O(A){return A===61?(e.consume(A),D):bt(A)?(a=O,F(A)):nn(A)?(e.consume(A),O):z(A)}function D(A){return A===null||A===60||A===61||A===62||A===96?n(A):A===34||A===39?(e.consume(A),i=A,L):bt(A)?(a=D,F(A)):nn(A)?(e.consume(A),D):(e.consume(A),$)}function L(A){return A===i?(e.consume(A),i=void 0,V):A===null?n(A):bt(A)?(a=L,F(A)):(e.consume(A),L)}function $(A){return A===null||A===34||A===39||A===60||A===61||A===96?n(A):A===47||A===62||cs(A)?z(A):(e.consume(A),$)}function V(A){return A===47||A===62||cs(A)?z(A):n(A)}function W(A){return A===62?(e.consume(A),e.exit("htmlTextData"),e.exit("htmlText"),t):n(A)}function F(A){return e.exit("htmlTextData"),e.enter("lineEnding"),e.consume(A),e.exit("lineEnding"),M}function M(A){return nn(A)?kn(e,H,"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(A):H(A)}function H(A){return e.enter("htmlTextData"),a(A)}}const Pv={name:"labelEnd",resolveAll:B9,resolveTo:W9,tokenize:H9},D9={tokenize:V9},F9={tokenize:K9},z9={tokenize:q9};function B9(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 i=r.type==="labelImage"?4:2;r.type="data",t+=i}}return e.length!==n.length&&Wi(e,0,e.length,n),e}function W9(e,t){let n=e.length,r=0,i,o,a,l;for(;n--;)if(i=e[n][1],o){if(i.type==="link"||i.type==="labelLink"&&i._inactive)break;e[n][0]==="enter"&&i.type==="labelLink"&&(i._inactive=!0)}else if(a){if(e[n][0]==="enter"&&(i.type==="labelImage"||i.type==="labelLink")&&!i._balanced&&(o=n,i.type!=="labelLink")){r=2;break}}else i.type==="labelEnd"&&(a=n);const c={type:e[o][1].type==="labelLink"?"link":"image",start:{...e[o][1].start},end:{...e[e.length-1][1].end}},u={type:"label",start:{...e[o][1].start},end:{...e[a][1].end}},f={type:"labelText",start:{...e[o+r+2][1].end},end:{...e[a-2][1].start}};return l=[["enter",c,t],["enter",u,t]],l=Ds(l,e.slice(o+1,o+r+3)),l=Ds(l,[["enter",f,t]]),l=Ds(l,Iv(t.parser.constructs.insideSpan.null,e.slice(o+r+4,a-3),t)),l=Ds(l,[["exit",f,t],e[a-2],e[a-1],["exit",u,t]]),l=Ds(l,e.slice(a+1)),l=Ds(l,[["exit",c,t]]),Wi(e,o,e.length,l),e}function H9(e,t,n){const r=this;let i=r.events.length,o,a;for(;i--;)if((r.events[i][1].type==="labelImage"||r.events[i][1].type==="labelLink")&&!r.events[i][1]._balanced){o=r.events[i][1];break}return l;function l(d){return o?o._inactive?p(d):(a=r.parser.defined.includes(Pc(r.sliceSerialize({start:o.end,end:r.now()}))),e.enter("labelEnd"),e.enter("labelMarker"),e.consume(d),e.exit("labelMarker"),e.exit("labelEnd"),c):n(d)}function c(d){return d===40?e.attempt(D9,f,a?f:p)(d):d===91?e.attempt(F9,f,a?u:p)(d):a?f(d):p(d)}function u(d){return e.attempt(z9,f,p)(d)}function f(d){return t(d)}function p(d){return o._balanced=!0,n(d)}}function V9(e,t,n){return r;function r(p){return e.enter("resource"),e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),i}function i(p){return cs(p)?Md(e,o)(p):o(p)}function o(p){return p===41?f(p):RR(e,a,l,"resourceDestination","resourceDestinationLiteral","resourceDestinationLiteralMarker","resourceDestinationRaw","resourceDestinationString",32)(p)}function a(p){return cs(p)?Md(e,c)(p):f(p)}function l(p){return n(p)}function c(p){return p===34||p===39||p===40?$R(e,u,n,"resourceTitle","resourceTitleMarker","resourceTitleString")(p):f(p)}function u(p){return cs(p)?Md(e,f)(p):f(p)}function f(p){return p===41?(e.enter("resourceMarker"),e.consume(p),e.exit("resourceMarker"),e.exit("resource"),t):n(p)}}function K9(e,t,n){const r=this;return i;function i(l){return MR.call(r,e,o,a,"reference","referenceMarker","referenceString")(l)}function o(l){return r.parser.defined.includes(Pc(r.sliceSerialize(r.events[r.events.length-1][1]).slice(1,-1)))?t(l):n(l)}function a(l){return n(l)}}function q9(e,t,n){return r;function r(o){return e.enter("reference"),e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),i}function i(o){return o===93?(e.enter("referenceMarker"),e.consume(o),e.exit("referenceMarker"),e.exit("reference"),t):n(o)}}const U9={name:"labelStartImage",resolveAll:Pv.resolveAll,tokenize:G9};function G9(e,t,n){const r=this;return i;function i(l){return e.enter("labelImage"),e.enter("labelImageMarker"),e.consume(l),e.exit("labelImageMarker"),o}function o(l){return l===91?(e.enter("labelMarker"),e.consume(l),e.exit("labelMarker"),e.exit("labelImage"),a):n(l)}function a(l){return l===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(l):t(l)}}const Y9={name:"labelStartLink",resolveAll:Pv.resolveAll,tokenize:J9};function J9(e,t,n){const r=this;return i;function i(a){return e.enter("labelLink"),e.enter("labelMarker"),e.consume(a),e.exit("labelMarker"),e.exit("labelLink"),o}function o(a){return a===94&&"_hiddenFootnoteSupport"in r.parser.constructs?n(a):t(a)}}const jw={name:"lineEnding",tokenize:X9};function X9(e,t){return n;function n(r){return e.enter("lineEnding"),e.consume(r),e.exit("lineEnding"),kn(e,t,"linePrefix")}}const zh={name:"thematicBreak",tokenize:Q9};function Q9(e,t,n){let r=0,i;return o;function o(u){return e.enter("thematicBreak"),a(u)}function a(u){return i=u,l(u)}function l(u){return u===i?(e.enter("thematicBreakSequence"),c(u)):r>=3&&(u===null||bt(u))?(e.exit("thematicBreak"),t(u)):n(u)}function c(u){return u===i?(e.consume(u),r++,c):(e.exit("thematicBreakSequence"),nn(u)?kn(e,l,"whitespace")(u):l(u))}}const es={continuation:{tokenize:nK},exit:sK,name:"list",tokenize:tK},Z9={partial:!0,tokenize:iK},eK={partial:!0,tokenize:rK};function tK(e,t,n){const r=this,i=r.events[r.events.length-1];let o=i&&i[1].type==="linePrefix"?i[2].sliceSerialize(i[1],!0).length:0,a=0;return l;function l(m){const y=r.containerState.type||(m===42||m===43||m===45?"listUnordered":"listOrdered");if(y==="listUnordered"?!r.containerState.marker||m===r.containerState.marker:Ab(m)){if(r.containerState.type||(r.containerState.type=y,e.enter(y,{_container:!0})),y==="listUnordered")return e.enter("listItemPrefix"),m===42||m===45?e.check(zh,n,u)(m):u(m);if(!r.interrupt||m===49)return e.enter("listItemPrefix"),e.enter("listItemValue"),c(m)}return n(m)}function c(m){return Ab(m)&&++a<10?(e.consume(m),c):(!r.interrupt||a<2)&&(r.containerState.marker?m===r.containerState.marker:m===41||m===46)?(e.exit("listItemValue"),u(m)):n(m)}function u(m){return e.enter("listItemMarker"),e.consume(m),e.exit("listItemMarker"),r.containerState.marker=r.containerState.marker||m,e.check(Tg,r.interrupt?n:f,e.attempt(Z9,d,p))}function f(m){return r.containerState.initialBlankLine=!0,o++,d(m)}function p(m){return nn(m)?(e.enter("listItemPrefixWhitespace"),e.consume(m),e.exit("listItemPrefixWhitespace"),d):n(m)}function d(m){return r.containerState.size=o+r.sliceSerialize(e.exit("listItemPrefix"),!0).length,t(m)}}function nK(e,t,n){const r=this;return r.containerState._closeFlow=void 0,e.check(Tg,i,o);function i(l){return r.containerState.furtherBlankLines=r.containerState.furtherBlankLines||r.containerState.initialBlankLine,kn(e,t,"listItemIndent",r.containerState.size+1)(l)}function o(l){return r.containerState.furtherBlankLines||!nn(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(eK,t,a)(l))}function a(l){return r.containerState._closeFlow=!0,r.interrupt=void 0,kn(e,e.attempt(es,t,n),"linePrefix",r.parser.constructs.disable.null.includes("codeIndented")?void 0:4)(l)}}function rK(e,t,n){const r=this;return kn(e,i,"listItemIndent",r.containerState.size+1);function i(o){const a=r.events[r.events.length-1];return a&&a[1].type==="listItemIndent"&&a[2].sliceSerialize(a[1],!0).length===r.containerState.size?t(o):n(o)}}function sK(e){e.exit(this.containerState.type)}function iK(e,t,n){const r=this;return kn(e,i,"listItemPrefixWhitespace",r.parser.constructs.disable.null.includes("codeIndented")?void 0:5);function i(o){const a=r.events[r.events.length-1];return!nn(o)&&a&&a[1].type==="listItemPrefixWhitespace"?t(o):n(o)}}const d1={name:"setextUnderline",resolveTo:oK,tokenize:aK};function oK(e,t){let n=e.length,r,i,o;for(;n--;)if(e[n][0]==="enter"){if(e[n][1].type==="content"){r=n;break}e[n][1].type==="paragraph"&&(i=n)}else e[n][1].type==="content"&&e.splice(n,1),!o&&e[n][1].type==="definition"&&(o=n);const a={type:"setextHeading",start:{...e[r][1].start},end:{...e[e.length-1][1].end}};return e[i][1].type="setextHeadingText",o?(e.splice(i,0,["enter",a,t]),e.splice(o+1,0,["exit",e[r][1],t]),e[r][1].end={...e[o][1].end}):e[r][1]=a,e.push(["exit",a,t]),e}function aK(e,t,n){const r=this;let i;return o;function o(u){let f=r.events.length,p;for(;f--;)if(r.events[f][1].type!=="lineEnding"&&r.events[f][1].type!=="linePrefix"&&r.events[f][1].type!=="content"){p=r.events[f][1].type==="paragraph";break}return!r.parser.lazy[r.now().line]&&(r.interrupt||p)?(e.enter("setextHeadingLine"),i=u,a(u)):n(u)}function a(u){return e.enter("setextHeadingLineSequence"),l(u)}function l(u){return u===i?(e.consume(u),l):(e.exit("setextHeadingLineSequence"),nn(u)?kn(e,c,"lineSuffix")(u):c(u))}function c(u){return u===null||bt(u)?(e.exit("setextHeadingLine"),t(u)):n(u)}}const lK={tokenize:cK};function cK(e){const t=this,n=e.attempt(Tg,r,e.attempt(this.parser.constructs.flowInitial,i,kn(e,e.attempt(this.parser.constructs.flow,i,e.attempt(h9,i)),"linePrefix")));return n;function r(o){if(o===null){e.consume(o);return}return e.enter("lineEndingBlank"),e.consume(o),e.exit("lineEndingBlank"),t.currentConstruct=void 0,n}function i(o){if(o===null){e.consume(o);return}return e.enter("lineEnding"),e.consume(o),e.exit("lineEnding"),t.currentConstruct=void 0,n}}const uK={resolveAll:OR()},dK=LR("string"),fK=LR("text");function LR(e){return{resolveAll:OR(e==="text"?pK:void 0),tokenize:t};function t(n){const r=this,i=this.parser.constructs[e],o=n.attempt(i,a,l);return a;function a(f){return u(f)?o(f):l(f)}function l(f){if(f===null){n.consume(f);return}return n.enter("data"),n.consume(f),c}function c(f){return u(f)?(n.exit("data"),o(f)):(n.consume(f),c)}function u(f){if(f===null)return!0;const p=i[f];let d=-1;if(p)for(;++d<p.length;){const m=p[d];if(!m.previous||m.previous.call(r,r.previous))return!0}return!1}}}function OR(e){return t;function t(n,r){let i=-1,o;for(;++i<=n.length;)o===void 0?n[i]&&n[i][1].type==="data"&&(o=i,i++):(!n[i]||n[i][1].type!=="data")&&(i!==o+2&&(n[o][1].end=n[i-1][1].end,n.splice(o+2,i-o-2),i=o+2),o=void 0);return e?e(n,r):n}}function pK(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],i=t.sliceStream(r);let o=i.length,a=-1,l=0,c;for(;o--;){const u=i[o];if(typeof u=="string"){for(a=u.length;u.charCodeAt(a-1)===32;)l++,a--;if(a)break;a=-1}else if(u===-2)c=!0,l++;else if(u!==-1){o++;break}}if(t._contentTypeTextTrailing&&n===e.length&&(l=0),l){const u={type:n===e.length||c||l<2?"lineSuffix":"hardBreakTrailing",start:{_bufferIndex:o?a:r.start._bufferIndex+a,_index:r.start._index+o,line:r.end.line,column:r.end.column-l,offset:r.end.offset-l},end:{...r.end}};r.end={...u.start},r.start.offset===r.end.offset?Object.assign(r,u):(e.splice(n,0,["enter",u,t],["exit",u,t]),n+=2)}n++}return e}const hK={42:es,43:es,45:es,48:es,49:es,50:es,51:es,52:es,53:es,54:es,55:es,56:es,57:es,62:ER},mK={91:x9},gK={[-2]:Sw,[-1]:Sw,32:Sw},yK={35:N9,42:zh,45:[d1,zh],60:E9,61:d1,95:zh,96:c1,126:c1},wK={38:PR,92:IR},xK={[-5]:jw,[-4]:jw,[-3]:jw,33:U9,38:PR,42:Eb,60:[YV,L9],91:Y9,92:[S9,IR],93:Pv,95:Eb,96:l9},bK={null:[Eb,uK]},kK={null:[42,95]},vK={null:[]},SK=Object.freeze(Object.defineProperty({__proto__:null,attentionMarkers:kK,contentInitial:mK,disable:vK,document:hK,flow:yK,flowInitial:gK,insideSpan:bK,string:wK,text:xK},Symbol.toStringTag,{value:"Module"}));function jK(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 i={},o=[];let a=[],l=[];const c={attempt:P(j),check:P(N),consume:k,enter:x,exit:_,interrupt:P(N,{interrupt:!0})},u={code:null,containerState:{},defineSkip:v,events:[],now:y,parser:e,previous:null,sliceSerialize:d,sliceStream:m,write:p};let f=t.tokenize.call(u,c);return t.resolveAll&&o.push(t),u;function p(O){return a=Ds(a,O),b(),a[a.length-1]!==null?[]:(T(t,0),u.events=Iv(o,u.events,u),u.events)}function d(O,D){return _K(m(O),D)}function m(O){return NK(a,O)}function y(){const{_bufferIndex:O,_index:D,line:L,column:$,offset:V}=r;return{_bufferIndex:O,_index:D,line:L,column:$,offset:V}}function v(O){i[O.line]=O.column,E()}function b(){let O;for(;r._index<a.length;){const D=a[r._index];if(typeof D=="string")for(O=r._index,r._bufferIndex<0&&(r._bufferIndex=0);r._index===O&&r._bufferIndex<D.length;)g(D.charCodeAt(r._bufferIndex));else g(D)}}function g(O){f=f(O)}function k(O){bt(O)?(r.line++,r.column=1,r.offset+=O===-3?2:1,E()):O!==-1&&(r.column++,r.offset++),r._bufferIndex<0?r._index++:(r._bufferIndex++,r._bufferIndex===a[r._index].length&&(r._bufferIndex=-1,r._index++)),u.previous=O}function x(O,D){const L=D||{};return L.type=O,L.start=y(),u.events.push(["enter",L,u]),l.push(L),L}function _(O){const D=l.pop();return D.end=y(),u.events.push(["exit",D,u]),D}function j(O,D){T(O,D.from)}function N(O,D){D.restore()}function P(O,D){return L;function L($,V,W){let F,M,H,A;return Array.isArray($)?q($):"tokenize"in $?q([$]):X($);function X(K){return ee;function ee(re){const se=re!==null&&K[re],Q=re!==null&&K.null,le=[...Array.isArray(se)?se:se?[se]:[],...Array.isArray(Q)?Q:Q?[Q]:[]];return q(le)(re)}}function q(K){return F=K,M=0,K.length===0?W:B(K[M])}function B(K){return ee;function ee(re){return A=z(),H=K,K.partial||(u.currentConstruct=K),K.name&&u.parser.constructs.disable.null.includes(K.name)?ce():K.tokenize.call(D?Object.assign(Object.create(u),D):u,c,ne,ce)(re)}}function ne(K){return O(H,A),V}function ce(K){return A.restore(),++M<F.length?B(F[M]):W}}}function T(O,D){O.resolveAll&&!o.includes(O)&&o.push(O),O.resolve&&Wi(u.events,D,u.events.length-D,O.resolve(u.events.slice(D),u)),O.resolveTo&&(u.events=O.resolveTo(u.events,u))}function z(){const O=y(),D=u.previous,L=u.currentConstruct,$=u.events.length,V=Array.from(l);return{from:$,restore:W};function W(){r=O,u.previous=D,u.currentConstruct=L,u.events.length=$,l=V,E()}}function E(){r.line in i&&r.column<2&&(r.column=i[r.line],r.offset+=i[r.line]-1)}}function NK(e,t){const n=t.start._index,r=t.start._bufferIndex,i=t.end._index,o=t.end._bufferIndex;let a;if(n===i)a=[e[n].slice(r,o)];else{if(a=e.slice(n,i),r>-1){const l=a[0];typeof l=="string"?a[0]=l.slice(r):a.shift()}o>0&&a.push(e[i].slice(0,o))}return a}function _K(e,t){let n=-1;const r=[];let i;for(;++n<e.length;){const o=e[n];let a;if(typeof o=="string")a=o;else switch(o){case-5:{a="\r";break}case-4:{a=`
|
|
68
|
+
`;break}case-3:{a=`\r
|
|
69
|
+
`;break}case-2:{a=t?" ":" ";break}case-1:{if(!t&&i)continue;a=" ";break}default:a=String.fromCharCode(o)}i=o===-2,r.push(a)}return r.join("")}function CK(e){const r={constructs:MV([SK,...(e||{}).extensions||[]]),content:i(WV),defined:[],document:i(VV),flow:i(lK),lazy:{},string:i(dK),text:i(fK)};return r;function i(o){return a;function a(l){return jK(r,o,l)}}}function AK(e){for(;!TR(e););return e}const f1=/[\0\t\n\r]/g;function EK(){let e=1,t="",n=!0,r;return i;function i(o,a,l){const c=[];let u,f,p,d,m;for(o=t+(typeof o=="string"?o.toString():new TextDecoder(a||void 0).decode(o)),p=0,t="",n&&(o.charCodeAt(0)===65279&&p++,n=void 0);p<o.length;){if(f1.lastIndex=p,u=f1.exec(o),d=u&&u.index!==void 0?u.index:o.length,m=o.charCodeAt(d),!u){t=o.slice(p);break}if(m===10&&p===d&&r)c.push(-3),r=void 0;else switch(r&&(c.push(-5),r=void 0),p<d&&(c.push(o.slice(p,d)),e+=d-p),m){case 0:{c.push(65533),e++;break}case 9:{for(f=Math.ceil(e/4)*4,c.push(-2);e++<f;)c.push(-1);break}case 10:{c.push(-4),e=1;break}default:r=!0,e=1}p=d+1}return l&&(r&&c.push(-5),t&&c.push(t),c.push(null)),c}}const IK=/\\([!-/:-@[-`{-~])|&(#(?:\d{1,7}|x[\da-f]{1,6})|[\da-z]{1,31});/gi;function PK(e){return e.replace(IK,TK)}function TK(e,t,n){if(t)return t;if(n.charCodeAt(0)===35){const i=n.charCodeAt(1),o=i===120||i===88;return AR(n.slice(o?2:1),o?16:10)}return Ev(n)||e}const DR={}.hasOwnProperty;function RK(e,t,n){return t&&typeof t=="object"&&(n=t,t=void 0),MK(n)(AK(CK(n).document().write(EK()(e,t,!0))))}function MK(e){const t={transforms:[],canContainEols:["emphasis","fragment","heading","paragraph","strong"],enter:{autolink:o(xt),autolinkProtocol:z,autolinkEmail:z,atxHeading:o(Ce),blockQuote:o(Q),characterEscape:z,characterReference:z,codeFenced:o(le),codeFencedFenceInfo:a,codeFencedFenceMeta:a,codeIndented:o(le,a),codeText:o(fe,a),codeTextData:z,data:z,codeFlowValue:z,definition:o(me),definitionDestinationString:a,definitionLabelString:a,definitionTitleString:a,emphasis:o(De),hardBreakEscape:o(Se),hardBreakTrailing:o(Se),htmlFlow:o(Ue,a),htmlFlowData:z,htmlText:o(Ue,a),htmlTextData:z,image:o(lt),label:a,link:o(xt),listItem:o(ze),listItemValue:d,listOrdered:o(at,p),listUnordered:o(at),paragraph:o(Xe),reference:B,referenceString:a,resourceDestinationString:a,resourceTitleString:a,setextHeading:o(Ce),strong:o(Bt),thematicBreak:o(Qt)},exit:{atxHeading:c(),atxHeadingSequence:j,autolink:c(),autolinkEmail:se,autolinkProtocol:re,blockQuote:c(),characterEscapeValue:E,characterReferenceMarkerHexadecimal:ce,characterReferenceMarkerNumeric:ce,characterReferenceValue:K,characterReference:ee,codeFenced:c(b),codeFencedFence:v,codeFencedFenceInfo:m,codeFencedFenceMeta:y,codeFlowValue:E,codeIndented:c(g),codeText:c(V),codeTextData:E,data:E,definition:c(),definitionDestinationString:_,definitionLabelString:k,definitionTitleString:x,emphasis:c(),hardBreakEscape:c(D),hardBreakTrailing:c(D),htmlFlow:c(L),htmlFlowData:E,htmlText:c($),htmlTextData:E,image:c(F),label:H,labelText:M,lineEnding:O,link:c(W),listItem:c(),listOrdered:c(),listUnordered:c(),paragraph:c(),referenceString:ne,resourceDestinationString:A,resourceTitleString:X,resource:q,setextHeading:c(T),setextHeadingLineSequence:P,setextHeadingText:N,strong:c(),thematicBreak:c()}};FR(t,(e||{}).mdastExtensions||[]);const n={};return r;function r(de){let ke={type:"root",children:[]};const qe={stack:[ke],tokenStack:[],config:t,enter:l,exit:u,buffer:a,resume:f,data:n},st=[];let Ee=-1;for(;++Ee<de.length;)if(de[Ee][1].type==="listOrdered"||de[Ee][1].type==="listUnordered")if(de[Ee][0]==="enter")st.push(Ee);else{const rt=st.pop();Ee=i(de,rt,Ee)}for(Ee=-1;++Ee<de.length;){const rt=t[de[Ee][0]];DR.call(rt,de[Ee][1].type)&&rt[de[Ee][1].type].call(Object.assign({sliceSerialize:de[Ee][2].sliceSerialize},qe),de[Ee][1])}if(qe.tokenStack.length>0){const rt=qe.tokenStack[qe.tokenStack.length-1];(rt[1]||p1).call(qe,void 0,rt[0])}for(ke.position={start:zo(de.length>0?de[0][1].start:{line:1,column:1,offset:0}),end:zo(de.length>0?de[de.length-2][1].end:{line:1,column:1,offset:0})},Ee=-1;++Ee<t.transforms.length;)ke=t.transforms[Ee](ke)||ke;return ke}function i(de,ke,qe){let st=ke-1,Ee=-1,rt=!1,un,Kt,yt,pn;for(;++st<=qe;){const ie=de[st];switch(ie[1].type){case"listUnordered":case"listOrdered":case"blockQuote":{ie[0]==="enter"?Ee++:Ee--,pn=void 0;break}case"lineEndingBlank":{ie[0]==="enter"&&(un&&!pn&&!Ee&&!yt&&(yt=st),pn=void 0);break}case"linePrefix":case"listItemValue":case"listItemMarker":case"listItemPrefix":case"listItemPrefixWhitespace":break;default:pn=void 0}if(!Ee&&ie[0]==="enter"&&ie[1].type==="listItemPrefix"||Ee===-1&&ie[0]==="exit"&&(ie[1].type==="listUnordered"||ie[1].type==="listOrdered")){if(un){let Ne=st;for(Kt=void 0;Ne--;){const Ye=de[Ne];if(Ye[1].type==="lineEnding"||Ye[1].type==="lineEndingBlank"){if(Ye[0]==="exit")continue;Kt&&(de[Kt][1].type="lineEndingBlank",rt=!0),Ye[1].type="lineEnding",Kt=Ne}else if(!(Ye[1].type==="linePrefix"||Ye[1].type==="blockQuotePrefix"||Ye[1].type==="blockQuotePrefixWhitespace"||Ye[1].type==="blockQuoteMarker"||Ye[1].type==="listItemIndent"))break}yt&&(!Kt||yt<Kt)&&(un._spread=!0),un.end=Object.assign({},Kt?de[Kt][1].start:ie[1].end),de.splice(Kt||st,0,["exit",un,ie[2]]),st++,qe++}if(ie[1].type==="listItemPrefix"){const Ne={type:"listItem",_spread:!1,start:Object.assign({},ie[1].start),end:void 0};un=Ne,de.splice(st,0,["enter",Ne,ie[2]]),st++,qe++,yt=void 0,pn=!0}}}return de[ke][1]._spread=rt,qe}function o(de,ke){return qe;function qe(st){l.call(this,de(st),st),ke&&ke.call(this,st)}}function a(){this.stack.push({type:"fragment",children:[]})}function l(de,ke,qe){this.stack[this.stack.length-1].children.push(de),this.stack.push(de),this.tokenStack.push([ke,qe||void 0]),de.position={start:zo(ke.start),end:void 0}}function c(de){return ke;function ke(qe){de&&de.call(this,qe),u.call(this,qe)}}function u(de,ke){const qe=this.stack.pop(),st=this.tokenStack.pop();if(st)st[0].type!==de.type&&(ke?ke.call(this,de,st[0]):(st[1]||p1).call(this,de,st[0]));else throw new Error("Cannot close `"+de.type+"` ("+Rd({start:de.start,end:de.end})+"): it’s not open");qe.position.end=zo(de.end)}function f(){return TV(this.stack.pop())}function p(){this.data.expectingFirstListItemValue=!0}function d(de){if(this.data.expectingFirstListItemValue){const ke=this.stack[this.stack.length-2];ke.start=Number.parseInt(this.sliceSerialize(de),10),this.data.expectingFirstListItemValue=void 0}}function m(){const de=this.resume(),ke=this.stack[this.stack.length-1];ke.lang=de}function y(){const de=this.resume(),ke=this.stack[this.stack.length-1];ke.meta=de}function v(){this.data.flowCodeInside||(this.buffer(),this.data.flowCodeInside=!0)}function b(){const de=this.resume(),ke=this.stack[this.stack.length-1];ke.value=de.replace(/^(\r?\n|\r)|(\r?\n|\r)$/g,""),this.data.flowCodeInside=void 0}function g(){const de=this.resume(),ke=this.stack[this.stack.length-1];ke.value=de.replace(/(\r?\n|\r)$/g,"")}function k(de){const ke=this.resume(),qe=this.stack[this.stack.length-1];qe.label=ke,qe.identifier=Pc(this.sliceSerialize(de)).toLowerCase()}function x(){const de=this.resume(),ke=this.stack[this.stack.length-1];ke.title=de}function _(){const de=this.resume(),ke=this.stack[this.stack.length-1];ke.url=de}function j(de){const ke=this.stack[this.stack.length-1];if(!ke.depth){const qe=this.sliceSerialize(de).length;ke.depth=qe}}function N(){this.data.setextHeadingSlurpLineEnding=!0}function P(de){const ke=this.stack[this.stack.length-1];ke.depth=this.sliceSerialize(de).codePointAt(0)===61?1:2}function T(){this.data.setextHeadingSlurpLineEnding=void 0}function z(de){const qe=this.stack[this.stack.length-1].children;let st=qe[qe.length-1];(!st||st.type!=="text")&&(st=Mt(),st.position={start:zo(de.start),end:void 0},qe.push(st)),this.stack.push(st)}function E(de){const ke=this.stack.pop();ke.value+=this.sliceSerialize(de),ke.position.end=zo(de.end)}function O(de){const ke=this.stack[this.stack.length-1];if(this.data.atHardBreak){const qe=ke.children[ke.children.length-1];qe.position.end=zo(de.end),this.data.atHardBreak=void 0;return}!this.data.setextHeadingSlurpLineEnding&&t.canContainEols.includes(ke.type)&&(z.call(this,de),E.call(this,de))}function D(){this.data.atHardBreak=!0}function L(){const de=this.resume(),ke=this.stack[this.stack.length-1];ke.value=de}function $(){const de=this.resume(),ke=this.stack[this.stack.length-1];ke.value=de}function V(){const de=this.resume(),ke=this.stack[this.stack.length-1];ke.value=de}function W(){const de=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";de.type+="Reference",de.referenceType=ke,delete de.url,delete de.title}else delete de.identifier,delete de.label;this.data.referenceType=void 0}function F(){const de=this.stack[this.stack.length-1];if(this.data.inReference){const ke=this.data.referenceType||"shortcut";de.type+="Reference",de.referenceType=ke,delete de.url,delete de.title}else delete de.identifier,delete de.label;this.data.referenceType=void 0}function M(de){const ke=this.sliceSerialize(de),qe=this.stack[this.stack.length-2];qe.label=PK(ke),qe.identifier=Pc(ke).toLowerCase()}function H(){const de=this.stack[this.stack.length-1],ke=this.resume(),qe=this.stack[this.stack.length-1];if(this.data.inReference=!0,qe.type==="link"){const st=de.children;qe.children=st}else qe.alt=ke}function A(){const de=this.resume(),ke=this.stack[this.stack.length-1];ke.url=de}function X(){const de=this.resume(),ke=this.stack[this.stack.length-1];ke.title=de}function q(){this.data.inReference=void 0}function B(){this.data.referenceType="collapsed"}function ne(de){const ke=this.resume(),qe=this.stack[this.stack.length-1];qe.label=ke,qe.identifier=Pc(this.sliceSerialize(de)).toLowerCase(),this.data.referenceType="full"}function ce(de){this.data.characterReferenceType=de.type}function K(de){const ke=this.sliceSerialize(de),qe=this.data.characterReferenceType;let st;qe?(st=AR(ke,qe==="characterReferenceMarkerNumeric"?10:16),this.data.characterReferenceType=void 0):st=Ev(ke);const Ee=this.stack[this.stack.length-1];Ee.value+=st}function ee(de){const ke=this.stack.pop();ke.position.end=zo(de.end)}function re(de){E.call(this,de);const ke=this.stack[this.stack.length-1];ke.url=this.sliceSerialize(de)}function se(de){E.call(this,de);const ke=this.stack[this.stack.length-1];ke.url="mailto:"+this.sliceSerialize(de)}function Q(){return{type:"blockquote",children:[]}}function le(){return{type:"code",lang:null,meta:null,value:""}}function fe(){return{type:"inlineCode",value:""}}function me(){return{type:"definition",identifier:"",label:null,title:null,url:""}}function De(){return{type:"emphasis",children:[]}}function Ce(){return{type:"heading",depth:0,children:[]}}function Se(){return{type:"break"}}function Ue(){return{type:"html",value:""}}function lt(){return{type:"image",title:null,url:"",alt:null}}function xt(){return{type:"link",title:null,url:"",children:[]}}function at(de){return{type:"list",ordered:de.type==="listOrdered",start:null,spread:de._spread,children:[]}}function ze(de){return{type:"listItem",spread:de._spread,checked:null,children:[]}}function Xe(){return{type:"paragraph",children:[]}}function Bt(){return{type:"strong",children:[]}}function Mt(){return{type:"text",value:""}}function Qt(){return{type:"thematicBreak"}}}function zo(e){return{line:e.line,column:e.column,offset:e.offset}}function FR(e,t){let n=-1;for(;++n<t.length;){const r=t[n];Array.isArray(r)?FR(e,r):$K(e,r)}}function $K(e,t){let n;for(n in t)if(DR.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 p1(e,t){throw e?new Error("Cannot close `"+e.type+"` ("+Rd({start:e.start,end:e.end})+"): a different token (`"+t.type+"`, "+Rd({start:t.start,end:t.end})+") is open"):new Error("Cannot close document, a token (`"+t.type+"`, "+Rd({start:t.start,end:t.end})+") is still open")}function LK(e){const t=this;t.parser=n;function n(r){return RK(r,{...t.data("settings"),...e,extensions:t.data("micromarkExtensions")||[],mdastExtensions:t.data("fromMarkdownExtensions")||[]})}}function OK(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 DK(e,t){const n={type:"element",tagName:"br",properties:{},children:[]};return e.patch(t,n),[e.applyData(t,n),{type:"text",value:`
|
|
70
|
+
`}]}function FK(e,t){const n=t.value?t.value+`
|
|
71
|
+
`:"",r={},i=t.lang?t.lang.split(/\s+/):[];i.length>0&&(r.className=["language-"+i[0]]);let o={type:"element",tagName:"code",properties:r,children:[{type:"text",value:n}]};return t.meta&&(o.data={meta:t.meta}),e.patch(t,o),o=e.applyData(t,o),o={type:"element",tagName:"pre",properties:{},children:[o]},e.patch(t,o),o}function zK(e,t){const n={type:"element",tagName:"del",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function BK(e,t){const n={type:"element",tagName:"em",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function WK(e,t){const n=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",r=String(t.identifier).toUpperCase(),i=ou(r.toLowerCase()),o=e.footnoteOrder.indexOf(r);let a,l=e.footnoteCounts.get(r);l===void 0?(l=0,e.footnoteOrder.push(r),a=e.footnoteOrder.length):a=o+1,l+=1,e.footnoteCounts.set(r,l);const c={type:"element",tagName:"a",properties:{href:"#"+n+"fn-"+i,id:n+"fnref-"+i+(l>1?"-"+l:""),dataFootnoteRef:!0,ariaDescribedBy:["footnote-label"]},children:[{type:"text",value:String(a)}]};e.patch(t,c);const u={type:"element",tagName:"sup",properties:{},children:[c]};return e.patch(t,u),e.applyData(t,u)}function HK(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 VK(e,t){if(e.options.allowDangerousHtml){const n={type:"raw",value:t.value};return e.patch(t,n),e.applyData(t,n)}}function zR(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 i=e.all(t),o=i[0];o&&o.type==="text"?o.value="["+o.value:i.unshift({type:"text",value:"["});const a=i[i.length-1];return a&&a.type==="text"?a.value+=r:i.push({type:"text",value:r}),i}function KK(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return zR(e,t);const i={src:ou(r.url||""),alt:t.alt};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"img",properties:i,children:[]};return e.patch(t,o),e.applyData(t,o)}function qK(e,t){const n={src:ou(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 UK(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 GK(e,t){const n=String(t.identifier).toUpperCase(),r=e.definitionById.get(n);if(!r)return zR(e,t);const i={href:ou(r.url||"")};r.title!==null&&r.title!==void 0&&(i.title=r.title);const o={type:"element",tagName:"a",properties:i,children:e.all(t)};return e.patch(t,o),e.applyData(t,o)}function YK(e,t){const n={href:ou(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 JK(e,t,n){const r=e.all(t),i=n?XK(n):BR(t),o={},a=[];if(typeof t.checked=="boolean"){const f=r[0];let p;f&&f.type==="element"&&f.tagName==="p"?p=f:(p={type:"element",tagName:"p",properties:{},children:[]},r.unshift(p)),p.children.length>0&&p.children.unshift({type:"text",value:" "}),p.children.unshift({type:"element",tagName:"input",properties:{type:"checkbox",checked:t.checked,disabled:!0},children:[]}),o.className=["task-list-item"]}let l=-1;for(;++l<r.length;){const f=r[l];(i||l!==0||f.type!=="element"||f.tagName!=="p")&&a.push({type:"text",value:`
|
|
72
|
+
`}),f.type==="element"&&f.tagName==="p"&&!i?a.push(...f.children):a.push(f)}const c=r[r.length-1];c&&(i||c.type!=="element"||c.tagName!=="p")&&a.push({type:"text",value:`
|
|
73
|
+
`});const u={type:"element",tagName:"li",properties:o,children:a};return e.patch(t,u),e.applyData(t,u)}function XK(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=BR(n[r])}return t}function BR(e){const t=e.spread;return t??e.children.length>1}function QK(e,t){const n={},r=e.all(t);let i=-1;for(typeof t.start=="number"&&t.start!==1&&(n.start=t.start);++i<r.length;){const a=r[i];if(a.type==="element"&&a.tagName==="li"&&a.properties&&Array.isArray(a.properties.className)&&a.properties.className.includes("task-list-item")){n.className=["contains-task-list"];break}}const o={type:"element",tagName:t.ordered?"ol":"ul",properties:n,children:e.wrap(r,!0)};return e.patch(t,o),e.applyData(t,o)}function ZK(e,t){const n={type:"element",tagName:"p",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function eq(e,t){const n={type:"root",children:e.wrap(e.all(t))};return e.patch(t,n),e.applyData(t,n)}function tq(e,t){const n={type:"element",tagName:"strong",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}function nq(e,t){const n=e.all(t),r=n.shift(),i=[];if(r){const a={type:"element",tagName:"thead",properties:{},children:e.wrap([r],!0)};e.patch(t.children[0],a),i.push(a)}if(n.length>0){const a={type:"element",tagName:"tbody",properties:{},children:e.wrap(n,!0)},l=Nv(t.children[1]),c=kR(t.children[t.children.length-1]);l&&c&&(a.position={start:l,end:c}),i.push(a)}const o={type:"element",tagName:"table",properties:{},children:e.wrap(i,!0)};return e.patch(t,o),e.applyData(t,o)}function rq(e,t,n){const r=n?n.children:void 0,o=(r?r.indexOf(t):1)===0?"th":"td",a=n&&n.type==="table"?n.align:void 0,l=a?a.length:t.children.length;let c=-1;const u=[];for(;++c<l;){const p=t.children[c],d={},m=a?a[c]:void 0;m&&(d.align=m);let y={type:"element",tagName:o,properties:d,children:[]};p&&(y.children=e.all(p),e.patch(p,y),y=e.applyData(p,y)),u.push(y)}const f={type:"element",tagName:"tr",properties:{},children:e.wrap(u,!0)};return e.patch(t,f),e.applyData(t,f)}function sq(e,t){const n={type:"element",tagName:"td",properties:{},children:e.all(t)};return e.patch(t,n),e.applyData(t,n)}const h1=9,m1=32;function iq(e){const t=String(e),n=/\r?\n|\r/g;let r=n.exec(t),i=0;const o=[];for(;r;)o.push(g1(t.slice(i,r.index),i>0,!0),r[0]),i=r.index+r[0].length,r=n.exec(t);return o.push(g1(t.slice(i),i>0,!1)),o.join("")}function g1(e,t,n){let r=0,i=e.length;if(t){let o=e.codePointAt(r);for(;o===h1||o===m1;)r++,o=e.codePointAt(r)}if(n){let o=e.codePointAt(i-1);for(;o===h1||o===m1;)i--,o=e.codePointAt(i-1)}return i>r?e.slice(r,i):""}function oq(e,t){const n={type:"text",value:iq(String(t.value))};return e.patch(t,n),e.applyData(t,n)}function aq(e,t){const n={type:"element",tagName:"hr",properties:{},children:[]};return e.patch(t,n),e.applyData(t,n)}const lq={blockquote:OK,break:DK,code:FK,delete:zK,emphasis:BK,footnoteReference:WK,heading:HK,html:VK,imageReference:KK,image:qK,inlineCode:UK,linkReference:GK,link:YK,listItem:JK,list:QK,paragraph:ZK,root:eq,strong:tq,table:nq,tableCell:sq,tableRow:rq,text:oq,thematicBreak:aq,toml:th,yaml:th,definition:th,footnoteDefinition:th};function th(){}const WR=-1,Rg=0,$d=1,Em=2,Tv=3,Rv=4,Mv=5,$v=6,HR=7,VR=8,y1=typeof self=="object"?self:globalThis,cq=(e,t)=>{const n=(i,o)=>(e.set(o,i),i),r=i=>{if(e.has(i))return e.get(i);const[o,a]=t[i];switch(o){case Rg:case WR:return n(a,i);case $d:{const l=n([],i);for(const c of a)l.push(r(c));return l}case Em:{const l=n({},i);for(const[c,u]of a)l[r(c)]=r(u);return l}case Tv:return n(new Date(a),i);case Rv:{const{source:l,flags:c}=a;return n(new RegExp(l,c),i)}case Mv:{const l=n(new Map,i);for(const[c,u]of a)l.set(r(c),r(u));return l}case $v:{const l=n(new Set,i);for(const c of a)l.add(r(c));return l}case HR:{const{name:l,message:c}=a;return n(new y1[l](c),i)}case VR:return n(BigInt(a),i);case"BigInt":return n(Object(BigInt(a)),i);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 y1[o](a),i)};return r},w1=e=>cq(new Map,e)(0),Yl="",{toString:uq}={},{keys:dq}=Object,ed=e=>{const t=typeof e;if(t!=="object"||!e)return[Rg,t];const n=uq.call(e).slice(8,-1);switch(n){case"Array":return[$d,Yl];case"Object":return[Em,Yl];case"Date":return[Tv,Yl];case"RegExp":return[Rv,Yl];case"Map":return[Mv,Yl];case"Set":return[$v,Yl];case"DataView":return[$d,n]}return n.includes("Array")?[$d,n]:n.includes("Error")?[HR,n]:[Em,n]},nh=([e,t])=>e===Rg&&(t==="function"||t==="symbol"),fq=(e,t,n,r)=>{const i=(a,l)=>{const c=r.push(a)-1;return n.set(l,c),c},o=a=>{if(n.has(a))return n.get(a);let[l,c]=ed(a);switch(l){case Rg:{let f=a;switch(c){case"bigint":l=VR,f=a.toString();break;case"function":case"symbol":if(e)throw new TypeError("unable to serialize "+c);f=null;break;case"undefined":return i([WR],a)}return i([l,f],a)}case $d:{if(c){let d=a;return c==="DataView"?d=new Uint8Array(a.buffer):c==="ArrayBuffer"&&(d=new Uint8Array(a)),i([c,[...d]],a)}const f=[],p=i([l,f],a);for(const d of a)f.push(o(d));return p}case Em:{if(c)switch(c){case"BigInt":return i([c,a.toString()],a);case"Boolean":case"Number":case"String":return i([c,a.valueOf()],a)}if(t&&"toJSON"in a)return o(a.toJSON());const f=[],p=i([l,f],a);for(const d of dq(a))(e||!nh(ed(a[d])))&&f.push([o(d),o(a[d])]);return p}case Tv:return i([l,a.toISOString()],a);case Rv:{const{source:f,flags:p}=a;return i([l,{source:f,flags:p}],a)}case Mv:{const f=[],p=i([l,f],a);for(const[d,m]of a)(e||!(nh(ed(d))||nh(ed(m))))&&f.push([o(d),o(m)]);return p}case $v:{const f=[],p=i([l,f],a);for(const d of a)(e||!nh(ed(d)))&&f.push(o(d));return p}}const{message:u}=a;return i([l,{name:c,message:u}],a)};return o},x1=(e,{json:t,lossy:n}={})=>{const r=[];return fq(!(t||n),!!t,new Map,r)(e),r},Im=typeof structuredClone=="function"?(e,t)=>t&&("json"in t||"lossy"in t)?w1(x1(e,t)):structuredClone(e):(e,t)=>w1(x1(e,t));function pq(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 hq(e,t){return"Back to reference "+(e+1)+(t>1?"-"+t:"")}function mq(e){const t=typeof e.options.clobberPrefix=="string"?e.options.clobberPrefix:"user-content-",n=e.options.footnoteBackContent||pq,r=e.options.footnoteBackLabel||hq,i=e.options.footnoteLabel||"Footnotes",o=e.options.footnoteLabelTagName||"h2",a=e.options.footnoteLabelProperties||{className:["sr-only"]},l=[];let c=-1;for(;++c<e.footnoteOrder.length;){const u=e.footnoteById.get(e.footnoteOrder[c]);if(!u)continue;const f=e.all(u),p=String(u.identifier).toUpperCase(),d=ou(p.toLowerCase());let m=0;const y=[],v=e.footnoteCounts.get(p);for(;v!==void 0&&++m<=v;){y.length>0&&y.push({type:"text",value:" "});let k=typeof n=="string"?n:n(c,m);typeof k=="string"&&(k={type:"text",value:k}),y.push({type:"element",tagName:"a",properties:{href:"#"+t+"fnref-"+d+(m>1?"-"+m:""),dataFootnoteBackref:"",ariaLabel:typeof r=="string"?r:r(c,m),className:["data-footnote-backref"]},children:Array.isArray(k)?k:[k]})}const b=f[f.length-1];if(b&&b.type==="element"&&b.tagName==="p"){const k=b.children[b.children.length-1];k&&k.type==="text"?k.value+=" ":b.children.push({type:"text",value:" "}),b.children.push(...y)}else f.push(...y);const g={type:"element",tagName:"li",properties:{id:t+"fn-"+d},children:e.wrap(f,!0)};e.patch(u,g),l.push(g)}if(l.length!==0)return{type:"element",tagName:"section",properties:{dataFootnotes:!0,className:["footnotes"]},children:[{type:"element",tagName:o,properties:{...Im(a),id:"footnote-label"},children:[{type:"text",value:i}]},{type:"text",value:`
|
|
74
|
+
`},{type:"element",tagName:"ol",properties:{},children:e.wrap(l,!0)},{type:"text",value:`
|
|
75
|
+
`}]}}const KR=function(e){if(e==null)return xq;if(typeof e=="function")return Mg(e);if(typeof e=="object")return Array.isArray(e)?gq(e):yq(e);if(typeof e=="string")return wq(e);throw new Error("Expected function, string, or object as test")};function gq(e){const t=[];let n=-1;for(;++n<e.length;)t[n]=KR(e[n]);return Mg(r);function r(...i){let o=-1;for(;++o<t.length;)if(t[o].apply(this,i))return!0;return!1}}function yq(e){const t=e;return Mg(n);function n(r){const i=r;let o;for(o in e)if(i[o]!==t[o])return!1;return!0}}function wq(e){return Mg(t);function t(n){return n&&n.type===e}}function Mg(e){return t;function t(n,r,i){return!!(bq(n)&&e.call(this,n,typeof r=="number"?r:void 0,i||void 0))}}function xq(){return!0}function bq(e){return e!==null&&typeof e=="object"&&"type"in e}const qR=[],kq=!0,b1=!1,vq="skip";function Sq(e,t,n,r){let i;typeof t=="function"&&typeof n!="function"?(r=n,n=t):i=t;const o=KR(i),a=r?-1:1;l(e,void 0,[])();function l(c,u,f){const p=c&&typeof c=="object"?c:{};if(typeof p.type=="string"){const m=typeof p.tagName=="string"?p.tagName:typeof p.name=="string"?p.name:void 0;Object.defineProperty(d,"name",{value:"node ("+(c.type+(m?"<"+m+">":""))+")"})}return d;function d(){let m=qR,y,v,b;if((!t||o(c,u,f[f.length-1]||void 0))&&(m=jq(n(c,f)),m[0]===b1))return m;if("children"in c&&c.children){const g=c;if(g.children&&m[0]!==vq)for(v=(r?g.children.length:-1)+a,b=f.concat(g);v>-1&&v<g.children.length;){const k=g.children[v];if(y=l(k,v,b)(),y[0]===b1)return y;v=typeof y[1]=="number"?y[1]:v+a}}return m}}}function jq(e){return Array.isArray(e)?e:typeof e=="number"?[kq,e]:e==null?qR:[e]}function UR(e,t,n,r){let i,o,a;typeof t=="function"&&typeof n!="function"?(o=void 0,a=t,i=n):(o=t,a=n,i=r),Sq(e,o,l,i);function l(c,u){const f=u[u.length-1],p=f?f.children.indexOf(c):void 0;return a(c,p,f)}}const Ib={}.hasOwnProperty,Nq={};function _q(e,t){const n=t||Nq,r=new Map,i=new Map,o=new Map,a={...lq,...n.handlers},l={all:u,applyData:Aq,definitionById:r,footnoteById:i,footnoteCounts:o,footnoteOrder:[],handlers:a,one:c,options:n,patch:Cq,wrap:Iq};return UR(e,function(f){if(f.type==="definition"||f.type==="footnoteDefinition"){const p=f.type==="definition"?r:i,d=String(f.identifier).toUpperCase();p.has(d)||p.set(d,f)}}),l;function c(f,p){const d=f.type,m=l.handlers[d];if(Ib.call(l.handlers,d)&&m)return m(l,f,p);if(l.options.passThrough&&l.options.passThrough.includes(d)){if("children"in f){const{children:v,...b}=f,g=Im(b);return g.children=l.all(f),g}return Im(f)}return(l.options.unknownHandler||Eq)(l,f,p)}function u(f){const p=[];if("children"in f){const d=f.children;let m=-1;for(;++m<d.length;){const y=l.one(d[m],f);if(y){if(m&&d[m-1].type==="break"&&(!Array.isArray(y)&&y.type==="text"&&(y.value=k1(y.value)),!Array.isArray(y)&&y.type==="element")){const v=y.children[0];v&&v.type==="text"&&(v.value=k1(v.value))}Array.isArray(y)?p.push(...y):p.push(y)}}}return p}}function Cq(e,t){e.position&&(t.position=uV(e))}function Aq(e,t){let n=t;if(e&&e.data){const r=e.data.hName,i=e.data.hChildren,o=e.data.hProperties;if(typeof r=="string")if(n.type==="element")n.tagName=r;else{const a="children"in n?n.children:[n];n={type:"element",tagName:r,properties:{},children:a}}n.type==="element"&&o&&Object.assign(n.properties,Im(o)),"children"in n&&n.children&&i!==null&&i!==void 0&&(n.children=i)}return n}function Eq(e,t){const n=t.data||{},r="value"in t&&!(Ib.call(n,"hProperties")||Ib.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 Iq(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 k1(e){let t=0,n=e.charCodeAt(t);for(;n===9||n===32;)t++,n=e.charCodeAt(t);return e.slice(t)}function v1(e,t){const n=_q(e,t),r=n.one(e,void 0),i=mq(n),o=Array.isArray(r)?{type:"root",children:r}:r||{type:"root",children:[]};return i&&o.children.push({type:"text",value:`
|
|
79
|
+
`},i),o}function Pq(e,t){return e&&"run"in e?async function(n,r){const i=v1(n,{file:r,...t});await e.run(i,r)}:function(n,r){return v1(n,{file:r,...e||t})}}function S1(e){if(e)throw e}var Bh=Object.prototype.hasOwnProperty,GR=Object.prototype.toString,j1=Object.defineProperty,N1=Object.getOwnPropertyDescriptor,_1=function(t){return typeof Array.isArray=="function"?Array.isArray(t):GR.call(t)==="[object Array]"},C1=function(t){if(!t||GR.call(t)!=="[object Object]")return!1;var n=Bh.call(t,"constructor"),r=t.constructor&&t.constructor.prototype&&Bh.call(t.constructor.prototype,"isPrototypeOf");if(t.constructor&&!n&&!r)return!1;var i;for(i in t);return typeof i>"u"||Bh.call(t,i)},A1=function(t,n){j1&&n.name==="__proto__"?j1(t,n.name,{enumerable:!0,configurable:!0,value:n.newValue,writable:!0}):t[n.name]=n.newValue},E1=function(t,n){if(n==="__proto__")if(Bh.call(t,n)){if(N1)return N1(t,n).value}else return;return t[n]},Tq=function e(){var t,n,r,i,o,a,l=arguments[0],c=1,u=arguments.length,f=!1;for(typeof l=="boolean"&&(f=l,l=arguments[1]||{},c=2),(l==null||typeof l!="object"&&typeof l!="function")&&(l={});c<u;++c)if(t=arguments[c],t!=null)for(n in t)r=E1(l,n),i=E1(t,n),l!==i&&(f&&i&&(C1(i)||(o=_1(i)))?(o?(o=!1,a=r&&_1(r)?r:[]):a=r&&C1(r)?r:{},A1(l,{name:n,newValue:e(f,a,i)})):typeof i<"u"&&A1(l,{name:n,newValue:i}));return l};const Nw=xa(Tq);function Pb(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 Rq(){const e=[],t={run:n,use:r};return t;function n(...i){let o=-1;const a=i.pop();if(typeof a!="function")throw new TypeError("Expected function as last argument, not "+a);l(null,...i);function l(c,...u){const f=e[++o];let p=-1;if(c){a(c);return}for(;++p<i.length;)(u[p]===null||u[p]===void 0)&&(u[p]=i[p]);i=u,f?Mq(f,l)(...u):a(null,...u)}}function r(i){if(typeof i!="function")throw new TypeError("Expected `middelware` to be a function, not "+i);return e.push(i),t}}function Mq(e,t){let n;return r;function r(...a){const l=e.length>a.length;let c;l&&a.push(i);try{c=e.apply(this,a)}catch(u){const f=u;if(l&&n)throw f;return i(f)}l||(c&&c.then&&typeof c.then=="function"?c.then(o,i):c instanceof Error?i(c):o(c))}function i(a,...l){n||(n=!0,t(a,...l))}function o(a){i(null,a)}}const Ni={basename:$q,dirname:Lq,extname:Oq,join:Dq,sep:"/"};function $q(e,t){if(t!==void 0&&typeof t!="string")throw new TypeError('"ext" argument must be a string');Bf(e);let n=0,r=-1,i=e.length,o;if(t===void 0||t.length===0||t.length>e.length){for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else r<0&&(o=!0,r=i+1);return r<0?"":e.slice(n,r)}if(t===e)return"";let a=-1,l=t.length-1;for(;i--;)if(e.codePointAt(i)===47){if(o){n=i+1;break}}else a<0&&(o=!0,a=i+1),l>-1&&(e.codePointAt(i)===t.codePointAt(l--)?l<0&&(r=i):(l=-1,r=a));return n===r?r=a:r<0&&(r=e.length),e.slice(n,r)}function Lq(e){if(Bf(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 Oq(e){Bf(e);let t=e.length,n=-1,r=0,i=-1,o=0,a;for(;t--;){const l=e.codePointAt(t);if(l===47){if(a){r=t+1;break}continue}n<0&&(a=!0,n=t+1),l===46?i<0?i=t:o!==1&&(o=1):i>-1&&(o=-1)}return i<0||n<0||o===0||o===1&&i===n-1&&i===r+1?"":e.slice(i,n)}function Dq(...e){let t=-1,n;for(;++t<e.length;)Bf(e[t]),e[t]&&(n=n===void 0?e[t]:n+"/"+e[t]);return n===void 0?".":Fq(n)}function Fq(e){Bf(e);const t=e.codePointAt(0)===47;let n=zq(e,!t);return n.length===0&&!t&&(n="."),n.length>0&&e.codePointAt(e.length-1)===47&&(n+="/"),t?"/"+n:n}function zq(e,t){let n="",r=0,i=-1,o=0,a=-1,l,c;for(;++a<=e.length;){if(a<e.length)l=e.codePointAt(a);else{if(l===47)break;l=47}if(l===47){if(!(i===a-1||o===1))if(i!==a-1&&o===2){if(n.length<2||r!==2||n.codePointAt(n.length-1)!==46||n.codePointAt(n.length-2)!==46){if(n.length>2){if(c=n.lastIndexOf("/"),c!==n.length-1){c<0?(n="",r=0):(n=n.slice(0,c),r=n.length-1-n.lastIndexOf("/")),i=a,o=0;continue}}else if(n.length>0){n="",r=0,i=a,o=0;continue}}t&&(n=n.length>0?n+"/..":"..",r=2)}else n.length>0?n+="/"+e.slice(i+1,a):n=e.slice(i+1,a),r=a-i-1;i=a,o=0}else l===46&&o>-1?o++:o=-1}return n}function Bf(e){if(typeof e!="string")throw new TypeError("Path must be a string. Received "+JSON.stringify(e))}const Bq={cwd:Wq};function Wq(){return"/"}function Tb(e){return!!(e!==null&&typeof e=="object"&&"href"in e&&e.href&&"protocol"in e&&e.protocol&&e.auth===void 0)}function Hq(e){if(typeof e=="string")e=new URL(e);else if(!Tb(e)){const t=new TypeError('The "path" argument must be of type string or an instance of URL. Received `'+e+"`");throw t.code="ERR_INVALID_ARG_TYPE",t}if(e.protocol!=="file:"){const t=new TypeError("The URL must be of scheme file");throw t.code="ERR_INVALID_URL_SCHEME",t}return Vq(e)}function Vq(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 i=new TypeError("File URL path must not include encoded / characters");throw i.code="ERR_INVALID_FILE_URL_PATH",i}}return decodeURIComponent(t)}const _w=["history","path","basename","stem","extname","dirname"];class YR{constructor(t){let n;t?Tb(t)?n={path:t}:typeof t=="string"||Kq(t)?n={value:t}:n=t:n={},this.cwd="cwd"in n?"":Bq.cwd(),this.data={},this.history=[],this.messages=[],this.value,this.map,this.result,this.stored;let r=-1;for(;++r<_w.length;){const o=_w[r];o in n&&n[o]!==void 0&&n[o]!==null&&(this[o]=o==="history"?[...n[o]]:n[o])}let i;for(i in n)_w.includes(i)||(this[i]=n[i])}get basename(){return typeof this.path=="string"?Ni.basename(this.path):void 0}set basename(t){Aw(t,"basename"),Cw(t,"basename"),this.path=Ni.join(this.dirname||"",t)}get dirname(){return typeof this.path=="string"?Ni.dirname(this.path):void 0}set dirname(t){I1(this.basename,"dirname"),this.path=Ni.join(t||"",this.basename)}get extname(){return typeof this.path=="string"?Ni.extname(this.path):void 0}set extname(t){if(Cw(t,"extname"),I1(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=Ni.join(this.dirname,this.stem+(t||""))}get path(){return this.history[this.history.length-1]}set path(t){Tb(t)&&(t=Hq(t)),Aw(t,"path"),this.path!==t&&this.history.push(t)}get stem(){return typeof this.path=="string"?Ni.basename(this.path,this.extname):void 0}set stem(t){Aw(t,"stem"),Cw(t,"stem"),this.path=Ni.join(this.dirname||"",t+(this.extname||""))}fail(t,n,r){const i=this.message(t,n,r);throw i.fatal=!0,i}info(t,n,r){const i=this.message(t,n,r);return i.fatal=void 0,i}message(t,n,r){const i=new Br(t,n,r);return this.path&&(i.name=this.path+":"+i.name,i.file=this.path),i.fatal=!1,this.messages.push(i),i}toString(t){return this.value===void 0?"":typeof this.value=="string"?this.value:new TextDecoder(t||void 0).decode(this.value)}}function Cw(e,t){if(e&&e.includes(Ni.sep))throw new Error("`"+t+"` cannot be a path: did not expect `"+Ni.sep+"`")}function Aw(e,t){if(!e)throw new Error("`"+t+"` cannot be empty")}function I1(e,t){if(!e)throw new Error("Setting `"+t+"` requires `path` to be set too")}function Kq(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const qq=function(e){const r=this.constructor.prototype,i=r[e],o=function(){return i.apply(o,arguments)};return Object.setPrototypeOf(o,r),o},Uq={}.hasOwnProperty;class Lv extends qq{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=Rq()}copy(){const t=new Lv;let n=-1;for(;++n<this.attachers.length;){const r=this.attachers[n];t.use(...r)}return t.data(Nw(!0,{},this.namespace)),t}data(t,n){return typeof t=="string"?arguments.length===2?(Pw("data",this.frozen),this.namespace[t]=n,this):Uq.call(this.namespace,t)&&this.namespace[t]||void 0:t?(Pw("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 i=n.call(t,...r);typeof i=="function"&&this.transformers.use(i)}return this.frozen=!0,this.freezeIndex=Number.POSITIVE_INFINITY,this}parse(t){this.freeze();const n=rh(t),r=this.parser||this.Parser;return Ew("parse",r),r(String(n),n)}process(t,n){const r=this;return this.freeze(),Ew("process",this.parser||this.Parser),Iw("process",this.compiler||this.Compiler),n?i(void 0,n):new Promise(i);function i(o,a){const l=rh(t),c=r.parse(l);r.run(c,l,function(f,p,d){if(f||!p||!d)return u(f);const m=p,y=r.stringify(m,d);Jq(y)?d.value=y:d.result=y,u(f,d)});function u(f,p){f||!p?a(f):o?o(p):n(void 0,p)}}}processSync(t){let n=!1,r;return this.freeze(),Ew("processSync",this.parser||this.Parser),Iw("processSync",this.compiler||this.Compiler),this.process(t,i),T1("processSync","process",n),r;function i(o,a){n=!0,S1(o),r=a}}run(t,n,r){P1(t),this.freeze();const i=this.transformers;return!r&&typeof n=="function"&&(r=n,n=void 0),r?o(void 0,r):new Promise(o);function o(a,l){const c=rh(n);i.run(t,c,u);function u(f,p,d){const m=p||t;f?l(f):a?a(m):r(void 0,m,d)}}}runSync(t,n){let r=!1,i;return this.run(t,n,o),T1("runSync","run",r),i;function o(a,l){S1(a),i=l,r=!0}}stringify(t,n){this.freeze();const r=rh(n),i=this.compiler||this.Compiler;return Iw("stringify",i),P1(t),i(t,r)}use(t,...n){const r=this.attachers,i=this.namespace;if(Pw("use",this.frozen),t!=null)if(typeof t=="function")c(t,n);else if(typeof t=="object")Array.isArray(t)?l(t):a(t);else throw new TypeError("Expected usable value, not `"+t+"`");return this;function o(u){if(typeof u=="function")c(u,[]);else if(typeof u=="object")if(Array.isArray(u)){const[f,...p]=u;c(f,p)}else a(u);else throw new TypeError("Expected usable value, not `"+u+"`")}function a(u){if(!("plugins"in u)&&!("settings"in u))throw new Error("Expected usable value but received an empty preset, which is probably a mistake: presets typically come with `plugins` and sometimes with `settings`, but this has neither");l(u.plugins),u.settings&&(i.settings=Nw(!0,i.settings,u.settings))}function l(u){let f=-1;if(u!=null)if(Array.isArray(u))for(;++f<u.length;){const p=u[f];o(p)}else throw new TypeError("Expected a list of plugins, not `"+u+"`")}function c(u,f){let p=-1,d=-1;for(;++p<r.length;)if(r[p][0]===u){d=p;break}if(d===-1)r.push([u,...f]);else if(f.length>0){let[m,...y]=f;const v=r[d][1];Pb(v)&&Pb(m)&&(m=Nw(!0,v,m)),r[d]=[u,m,...y]}}}}const Gq=new Lv().freeze();function Ew(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `parser`")}function Iw(e,t){if(typeof t!="function")throw new TypeError("Cannot `"+e+"` without `compiler`")}function Pw(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 P1(e){if(!Pb(e)||typeof e.type!="string")throw new TypeError("Expected node, got `"+e+"`")}function T1(e,t,n){if(!n)throw new Error("`"+e+"` finished async. Use `"+t+"` instead")}function rh(e){return Yq(e)?e:new YR(e)}function Yq(e){return!!(e&&typeof e=="object"&&"message"in e&&"messages"in e)}function Jq(e){return typeof e=="string"||Xq(e)}function Xq(e){return!!(e&&typeof e=="object"&&"byteLength"in e&&"byteOffset"in e)}const Qq="https://github.com/remarkjs/react-markdown/blob/main/changelog.md",R1=[],M1={allowDangerousHtml:!0},Zq=/^(https?|ircs?|mailto|xmpp)$/i,e7=[{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 JR(e){const t=t7(e),n=n7(e);return r7(t.runSync(t.parse(n),n),e)}function t7(e){const t=e.rehypePlugins||R1,n=e.remarkPlugins||R1,r=e.remarkRehypeOptions?{...e.remarkRehypeOptions,...M1}:M1;return Gq().use(LK).use(n).use(Pq,r).use(t)}function n7(e){const t=e.children||"",n=new YR;return typeof t=="string"&&(n.value=t),n}function r7(e,t){const n=t.allowedElements,r=t.allowElement,i=t.components,o=t.disallowedElements,a=t.skipHtml,l=t.unwrapDisallowed,c=t.urlTransform||s7;for(const f of e7)Object.hasOwn(t,f.from)&&(""+f.from+(f.to?"use `"+f.to+"` instead":"remove it")+Qq+f.id,void 0);return UR(e,u),mV(e,{Fragment:s.Fragment,components:i,ignoreInvalidStyle:!0,jsx:s.jsx,jsxs:s.jsxs,passKeys:!0,passNode:!0});function u(f,p,d){if(f.type==="raw"&&d&&typeof p=="number")return a?d.children.splice(p,1):d.children[p]={type:"text",value:f.value},p;if(f.type==="element"){let m;for(m in vw)if(Object.hasOwn(vw,m)&&Object.hasOwn(f.properties,m)){const y=f.properties[m],v=vw[m];(v===null||v.includes(f.tagName))&&(f.properties[m]=c(String(y||""),m,f))}}if(f.type==="element"){let m=n?!n.includes(f.tagName):o?o.includes(f.tagName):!1;if(!m&&r&&typeof p=="number"&&(m=!r(f,p,d)),m&&d&&typeof p=="number")return l&&f.children?d.children.splice(p,1,...f.children):d.children.splice(p,1),p}}}function s7(e){const t=e.indexOf(":"),n=e.indexOf("?"),r=e.indexOf("#"),i=e.indexOf("/");return t===-1||i!==-1&&t>i||n!==-1&&t>n||r!==-1&&t>r||Zq.test(e.slice(0,t))?e:""}const i7=new Set(["echarts"]),o7=new Set(["line","bar","pie","scatter","radar","heatmap","tree","treemap","sunburst","sankey","graph","gauge","funnel"]),a7=new Set(["onclick","ondblclick","onmousedown","onmouseup","onmouseover","onmouseout","onmousemove","onmouseenter","onmouseleave","oncontextmenu","onkeydown","onkeyup","onkeypress","onload","onerror"]),l7=["#7c9cff","#a8e66f","#ffcf5c","#68d8d6","#ff8fb3","#b79cff","#f59e73","#8bd17c"];function ua(e){return e&&typeof e=="object"&&!Array.isArray(e)}function dl(e,t){if(!ua(e))return{...t};const n={...e};for(const[r,i]of Object.entries(t))n[r]==null?n[r]=i:ua(n[r])&&ua(i)&&(n[r]=dl(n[r],i));return n}function $g(e,t){return e==null?e:Array.isArray(e)?e.map(n=>ua(n)?dl(n,t):n):ua(e)?dl(e,t):e}function c7(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("{"),i=t.lastIndexOf("}");r>=0&&i>r&&(t=t.slice(r,i+1).trim())}return t.replace(/^json\s*\n/i,"").trim()}function Rb(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)=>Rb(n,`${t}[${r}]`));return}if(typeof e=="object")for(const[n,r]of Object.entries(e)){if(/^on[A-Z]/.test(n)||a7.has(n.toLowerCase()))throw new Error(`${t}.${n} is not allowed`);Rb(r,`${t}.${n}`)}}}function u7(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(!o7.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:dl(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,i)=>{if(!ua(r))return r;const o=i===0&&t&&r.text==null?{...r,text:t}:r;return dl(o,n)}):ua(e)?dl(t&&e.text==null?{...e,text:t}:e,n):t?{...n,text:t}:e}function p7(e,t){const n={top:t?42:14,textStyle:{color:"rgba(255, 255, 255, 0.72)"},itemGap:14};return e==null?e:$g(e,n)}function $1(e,t="rgba(255, 255, 255, 0.62)"){return $g(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 h7(e,t){const n={left:52,right:42,top:t?78:42,bottom:42,containLabel:!0};return e==null?n:$g(e,n)}function m7(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:$g(e,t)}function g7(e,t,n){const r=f7(e.title,n),i=!!(Array.isArray(r)?r:[r]).filter(Boolean).some(a=>ua(a)&&a.text),o=e.legend!=null&&e.legend!==!1;return{...e,backgroundColor:e.backgroundColor??"transparent",color:e.color??l7,textStyle:dl(e.textStyle,{color:"rgba(255, 255, 255, 0.78)"}),title:r,tooltip:d7(e.tooltip),legend:p7(e.legend,i),grid:e.xAxis!=null||e.yAxis!=null?h7(e.grid,i||o):e.grid,xAxis:$1(e.xAxis),yAxis:$1(e.yAxis),radar:m7(e.radar),series:t}}function y7(e){const t=c7(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(!i7.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");Rb(n);const r=u7(n.option.series),i=n.title==null?"":String(n.title),o=g7(n.option,r,i);return{ok:!0,spec:{...n,title:i,option:o}}}catch(n){return{ok:!1,error:String((n==null?void 0:n.message)||n)}}}function sh(e,t){let n=0;for(let r=t-1;r>=0&&e[r]==="\\";r-=1)n+=1;return n%2===1}function w7(e,t){let n=t;for(;n<e.length&&e[n]==="`";)n+=1;return n-t}function oo(e){let t=String(e||"").trim();if(!t.includes("|"))return[];t.startsWith("|")&&(t=t.slice(1)),t.endsWith("|")&&!sh(t,t.length-1)&&(t=t.slice(0,-1));const n=[];let r="",i=0;for(let o=0;o<t.length;o+=1){const a=t[o];if(a==="`"&&!sh(t,o)){const l=w7(t,o);r+=t.slice(o,o+l),i===0?i=l:i===l&&(i=0),o+=l-1;continue}if(i===0&&a==="|"&&!sh(t,o)){n.push(r.trim()),r="";continue}if(i===0&&a==="\\"&&t[o+1]==="|"&&sh(t,o+1)){r+="|",o+=1;continue}r+=a}return n.push(r.trim()),n}function XR(e,t){if(!t)return e;const n=e.slice(0,t);for(e.length>t&&(n[t-1]=[e[t-1],...e.slice(t)].filter(Boolean).join(" | "));n.length<t;)n.push("");return n}function QR(e){const t=oo(e);return t.length>1&&t.every(n=>/^:?-{3,}:?$/.test(n))}function ZR(e){return oo(e).map(t=>t.startsWith(":")&&t.endsWith(":")?"center":t.endsWith(":")?"right":"left")}function x7(e){return/^\s*(sequenceDiagram|flowchart\s+(?:TD|TB|BT|LR|RL)|graph\s+(?:TD|TB|BT|LR|RL))\b/i.test(String(e||""))}function b7(e){const t=String(e||"").split(/\r?\n/).map(l=>l.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[];let i="TD";const o=(l,c="")=>{const u=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(u)?c&&(n.get(u).label=c):n.set(u,{id:u,label:c||u}),u},a=l=>{const c=String(l||"").trim().replace(/[;,]+$/,""),u=c.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return u?o(u[1],u[2]||u[3]||u[4]||u[1]):o(c.replace(/[^A-Za-z0-9_]/g,"_"),c)};for(const l of t){const c=l.match(/^(graph|flowchart)\s+(TD|TB|BT|LR|RL)\b/i);if(c){i=c[2].toUpperCase();continue}const u=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(u){r.push({from:a(u[1]),to:a(u[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:i}}function k7({code:e}){const t=h.useMemo(()=>b7(e),[e]),n=t.direction==="LR"||t.direction==="RL",r=150,i=46,o=n?102:38,a=n?34:72,l=new Map;t.nodes.forEach((f,p)=>{l.set(f.id,{x:28+(n?p*(r+o):p%3*(r+o)),y:28+(n?p%3*(i+a):p*(i+a))})});const c=Math.max(520,...Array.from(l.values()).map(f=>f.x+r+28)),u=Math.max(220,...Array.from(l.values()).map(f=>f.y+i+28));return s.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid flowchart preview",children:[s.jsx("defs",{children:s.jsx("marker",{id:"af-md-mermaid-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((f,p)=>{const d=l.get(f.from),m=l.get(f.to);if(!d||!m)return null;const y=n?`M ${d.x+r} ${d.y+i/2} C ${(d.x+m.x+r)/2} ${d.y+i/2}, ${(d.x+m.x+r)/2} ${m.y+i/2}, ${m.x} ${m.y+i/2}`:`M ${d.x+r/2} ${d.y+i} C ${d.x+r/2} ${d.y+i+28}, ${m.x+r/2} ${m.y-28}, ${m.x+r/2} ${m.y}`;return s.jsx("path",{className:"af-md-mermaid-edge",d:y,markerEnd:"url(#af-md-mermaid-arrow)"},`${f.from}-${f.to}-${p}`)}),t.nodes.map(f=>{const p=l.get(f.id);return s.jsxs("g",{children:[s.jsx("rect",{className:"af-md-mermaid-box",x:p.x,y:p.y,width:r,height:i,rx:"8"}),s.jsx("text",{className:"af-md-mermaid-text",x:p.x+r/2,y:p.y+i/2+5,textAnchor:"middle",children:f.label.slice(0,24)})]},f.id)})]})}function v7(e){const t=String(e||"").split(/\r?\n/).map(o=>o.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[],i=(o,a="")=>{const l=String(o||"").trim();l&&(n.has(l)||n.set(l,a||l))};for(const o of t){if(/^sequenceDiagram\b/i.test(o))continue;const a=o.match(/^(participant|actor)\s+([A-Za-z0-9_]+)(?:\s+as\s+(.+))?$/i);if(a){i(a[2],a[3]||a[2]);continue}const l=o.match(/^([A-Za-z0-9_]+)\s*[-=]+>>\+?\s*([A-Za-z0-9_]+)\s*:\s*(.+)$/);if(l){i(l[1]),i(l[2]),r.push({type:"message",from:l[1],to:l[2],text:l[3]});continue}const c=o.match(/^note\s+(?:over|right of|left of)\s+([^:]+):\s*(.+)$/i);r.push({type:"note",text:c?c[2]:o})}return{participants:Array.from(n,([o,a])=>({id:o,label:a})),rows:r}}function S7({code:e}){const t=h.useMemo(()=>v7(e),[e]),n=t.participants.length?t.participants:[{id:"A",label:"A"},{id:"B",label:"B"}],r=190,i=48,o=26,a=44,l=48,c=Math.max(620,i*2+n.length*r),u=Math.max(220,o+a+Math.max(1,t.rows.length)*l+34),f=p=>{const d=Math.max(0,n.findIndex(m=>m.id===p));return i+d*r+r/2};return s.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid sequence diagram preview",children:[s.jsx("defs",{children:s.jsx("marker",{id:"af-md-sequence-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),n.map((p,d)=>{const m=i+d*r+r/2;return s.jsxs("g",{children:[s.jsx("rect",{className:"af-md-mermaid-box",x:m-68,y:o,width:"136",height:"34",rx:"8"}),s.jsx("text",{className:"af-md-mermaid-text",x:m,y:o+22,textAnchor:"middle",children:p.label.slice(0,18)}),s.jsx("line",{className:"af-md-sequence-life",x1:m,y1:o+a,x2:m,y2:u-18})]},p.id)}),t.rows.map((p,d)=>{const m=o+a+d*l+24;if(p.type!=="message")return s.jsxs("g",{children:[s.jsx("rect",{className:"af-md-sequence-note",x:i,y:m-17,width:c-i*2,height:"30",rx:"7"}),s.jsx("text",{className:"af-md-mermaid-text",x:i+12,y:m+4,children:p.text.slice(0,120)})]},`note-${d}`);const y=f(p.from),v=f(p.to),b=(y+v)/2;return s.jsxs("g",{children:[s.jsx("line",{className:"af-md-mermaid-edge",x1:y,y1:m,x2:v,y2:m,markerEnd:"url(#af-md-sequence-arrow)"}),s.jsx("text",{className:"af-md-sequence-label",x:b,y:m-8,textAnchor:"middle",children:p.text.slice(0,72)})]},`msg-${d}`)})]})}function eM({code:e}){const t=String(e||"").trim();if(!t)return null;const n=/^sequenceDiagram\b/i.test(t);return s.jsx("div",{className:"af-md-mermaid-preview",children:n?s.jsx(S7,{code:t}):s.jsx(k7,{code:t})})}function j7(e){const t=String(e||"").replace(/\r\n/g,`
|
|
80
|
+
`).split(`
|
|
81
|
+
`),n=[];let r=[],i=!1;const o=()=>{r.length&&(n.push({type:"markdown",text:r.join(`
|
|
82
|
+
`)}),r=[])};for(let a=0;a<t.length;){const l=t[a]||"",c=l.match(/^\s*```\s*(mermaid|mmd)\s*$/i);if(!i&&c){o();const u=[];for(a++;a<t.length&&!/^\s*```\s*$/.test(t[a]||"");)u.push(t[a]||""),a++;a<t.length&&a++,n.push({type:"mermaid",text:u.join(`
|
|
83
|
+
`)});continue}if(!i&&x7(l)){o();const u=[];for(;a<t.length;){const f=t[a]||"";if(u.length>0&&(!f.trim()||/^-{3,}\s*$/.test(f)||/^#{1,6}\s+/.test(f)))break;u.push(f),a++}n.push({type:"mermaid",text:u.join(`
|
|
84
|
+
`)});continue}if(/^\s*```/.test(l)){i=!i,r.push(l),a++;continue}if(!i&&a+1<t.length&&oo(l).length>1&&QR(t[a+1])){o();const u=oo(l),f=ZR(t[a+1]),p=[];for(a+=2;a<t.length&&t[a].trim()&&oo(t[a]).length>1;)p.push(XR(oo(t[a]),u.length)),a++;n.push({type:"table",headers:u,align:f,rows:p});continue}r.push(l),a++}return o(),n}function L1(e,t=""){const n=String(e||"").trim();if(!n||/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(n)||n.startsWith("/")||n.startsWith("#")||!t||n.startsWith("outputs/"))return n;const r=String(t||"").split("/").filter(Boolean);r.pop();const i=[...r,...n.split("/")].filter(Boolean),o=[];for(const a of i)if(a!=="."){if(a===".."){if(o.length===0)return n;o.pop();continue}o.push(a)}return o.join("/")}function tM(e){const t=String(e||"").replace(/\r\n/g,`
|
|
85
|
+
`).split(`
|
|
86
|
+
`);let n=!1;return t.map(r=>{if(/^\s*```/.test(r))return n=!n,r;if(n)return r;let i="",o=0,a=!1;for(;o<r.length;){const l=r[o];if(l==="`"){a=!a,i+=l,o+=1;continue}if(!(!a&&/^https?:\/\//i.test(r.slice(o)))){i+=l,o+=1;continue}if((o>0?r[o-1]:"")==="("){i+=l,o+=1;continue}let f=o;for(;f<r.length&&!/\s|<|>/.test(r[f]);)f+=1;let p=r.slice(o,f),d="";for(;/[.,;:!?)}\]]$/.test(p);)d=p.slice(-1)+d,p=p.slice(0,-1);p?i+=`[${p}](${p})${d}`:i+=r.slice(o,f),o=f}return i}).join(`
|
|
87
|
+
`)}function nM(e,t=!1,n=""){const r=o=>{const a=String(o||"").trim();if(!a)return"";if(/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(a)||a.startsWith("#"))return a;const l=L1(a,n);return e?e(l,{kind:"link",download:!0}):l},i=(o,a)=>{const l=r(a);!l||l.startsWith("#")||/^(?:javascript):/i.test(l)||(o.stopPropagation(),!(o.defaultPrevented||o.button!==0)&&(o.preventDefault(),window.open(l,"_blank","noopener,noreferrer")))};return{...t?{p:({children:o})=>s.jsx(s.Fragment,{children:o})}:{},code:({inline:o,className:a,children:l})=>{var f;const c=((f=String(a||"").match(/language-(\w+)/i))==null?void 0:f[1])||"",u=String(l||"").replace(/\n$/,"");return!o&&/^(mermaid|mmd)$/i.test(c)?s.jsx(eM,{code:u}):o?s.jsx("code",{className:a,children:l}):s.jsx("code",{className:a,children:l})},img:({src:o,alt:a})=>s.jsx("img",{src:e?e(L1(o,n)):o||"",alt:a||"",loading:"lazy"}),a:({href:o,children:a})=>s.jsx("a",{href:r(o),target:"_blank",rel:"noopener noreferrer",onClick:l=>i(l,o),children:a})}}function O1({children:e,resolveSrc:t,basePath:n=""}){return s.jsx(JR,{components:nM(t,!0,n),children:tM(e)})}function hf({content:e,resolveSrc:t,basePath:n=""}){const r=h.useMemo(()=>j7(e),[e]),i=h.useMemo(()=>nM(t,!1,n),[n,t]);return s.jsx(s.Fragment,{children:r.map((o,a)=>o.type==="mermaid"?s.jsx(eM,{code:o.text},`mermaid-${a}`):o.type!=="table"?s.jsx(JR,{components:i,children:tM(o.text)},`md-${a}`):s.jsx("div",{className:"af-work-display-table-wrap",children:s.jsxs("table",{className:"af-work-display-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:o.headers.map((l,c)=>s.jsx("th",{style:{textAlign:o.align[c]||"left"},children:s.jsx(O1,{resolveSrc:t,basePath:n,children:l})},c))})}),s.jsx("tbody",{children:o.rows.map((l,c)=>s.jsx("tr",{children:o.headers.map((u,f)=>s.jsx("td",{style:{textAlign:o.align[f]||"left"},children:s.jsx(O1,{resolveSrc:t,basePath:n,children:l[f]||""})},f))},c))})]})},`table-${a}`))})}function N7(e,t=","){const n=[];let r=[],i="",o=!1;const a=String(e||"").replace(/\r\n/g,`
|
|
88
|
+
`);for(let l=0;l<a.length;l+=1){const c=a[l],u=a[l+1];if(o){c==='"'&&u==='"'?(i+='"',l+=1):c==='"'?o=!1:i+=c;continue}c==='"'?o=!0:c===t?(r.push(i.trim()),i=""):c===`
|
|
89
|
+
`?(r.push(i.trim()),n.push(r),r=[],i=""):i+=c}return(i||r.length)&&(r.push(i.trim()),n.push(r)),n.filter(l=>l.some(c=>String(c||"").trim()))}function Si(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 _7(e){if(Array.isArray(e)){if(e.every(i=>i&&typeof i=="object"&&!Array.isArray(i))){const i=Array.from(new Set(e.flatMap(o=>Object.keys(o))));return{columns:i.map(o=>({key:o,label:o,align:"left"})),rows:e.map(o=>i.map(a=>Si(o[a])))}}if(e.every(Array.isArray)&&e.length>0){const i=e[0].map((o,a)=>Si(o)||`Column ${a+1}`);return{columns:i.map((o,a)=>({key:String(a),label:o,align:"left"})),rows:e.slice(1).map(o=>i.map((a,l)=>Si(o[l])))}}}if(!e||typeof e!="object")return null;const t=Array.isArray(e.columns)?e.columns:Array.isArray(e.headers)?e.headers:[],n=Array.isArray(e.rows)?e.rows:Array.isArray(e.data)?e.data:[];let r=t.map((i,o)=>i&&typeof i=="object"?{key:String(i.key||i.name||i.field||o),label:String(i.label||i.title||i.name||i.key||`Column ${o+1}`),align:["left","center","right"].includes(i.align)?i.align:"left"}:{key:String(o),label:Si(i)||`Column ${o+1}`,align:"left"});return r.length===0&&n.every(i=>i&&typeof i=="object"&&!Array.isArray(i))&&(r=Array.from(new Set(n.flatMap(i=>Object.keys(i)))).map(i=>({key:i,label:i,align:"left"}))),r.length===0&&n.every(Array.isArray)&&n.length>0?(r=n[0].map((i,o)=>({key:String(o),label:Si(i)||`Column ${o+1}`,align:"left"})),{columns:r,rows:n.slice(1).map(i=>r.map((o,a)=>Si(i[a])))}):{columns:r,rows:n.map(i=>Array.isArray(i)?r.map((o,a)=>Si(i[a])):i&&typeof i=="object"?r.map(o=>Si(i[o.key])):r.map((o,a)=>a===0?Si(i):""))}}function C7(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=_7(JSON.parse(r));if(l&&l.columns.length)return{...l,error:""}}catch{}const i=r.replace(/\r\n/g,`
|
|
90
|
+
`).split(`
|
|
91
|
+
`).filter(l=>l.trim());if(i.length>=2&&oo(i[0]).length>1&&QR(i[1])){const l=oo(i[0]),c=ZR(i[1]);return{columns:l.map((u,f)=>({key:String(f),label:u,align:c[f]||"left"})),rows:i.slice(2).map(u=>XR(oo(u),l.length)),error:""}}const o=r.includes(" ")?" ":",",a=N7(r,o);return a.length>0&&a[0].length>1?{columns:a[0].map((c,u)=>c||`Column ${u+1}`).map((c,u)=>({key:String(u),label:c,align:"left"})),rows:a.slice(1),error:""}:{columns:[],rows:[],error:"No table data detected"}}function Ov({content:e}){const t=h.useMemo(()=>C7(e),[e]);return t.error||t.columns.length===0?s.jsxs("div",{className:"af-work-display-table-empty",children:[s.jsx("strong",{children:"Table data error"}),s.jsx("span",{children:t.error||"No columns found"})]}):s.jsx("div",{className:"af-work-display-table-wrap af-work-display-table-wrap--standalone",children:s.jsxs("table",{className:"af-work-display-table",children:[s.jsx("thead",{children:s.jsx("tr",{children:t.columns.map((n,r)=>s.jsx("th",{style:{textAlign:n.align||"left"},children:n.label},`${n.key}-${r}`))})}),s.jsx("tbody",{children:t.rows.map((n,r)=>s.jsx("tr",{children:t.columns.map((i,o)=>s.jsx("td",{style:{textAlign:i.align||"left"},children:Si(n[o])},`${i.key}-${o}`))},r))})]})})}function Dv({content:e}){const t=h.useRef(null),n=h.useMemo(()=>y7(e),[e]),[r,i]=h.useState({loading:!1,error:""});return h.useEffect(()=>{if(!n.ok){i({loading:!1,error:n.error||"Invalid chart spec"});return}let o=!1,a=null,l=null,c=null;return i({loading:!0,error:""}),vP(()=>import("./index-DgQRkS4v.js"),[]).then(u=>{o||!t.current||(a=u.init(t.current,"dark",{renderer:"canvas"}),a.setOption(n.spec.option,!0),c=()=>a==null?void 0:a.resize(),typeof ResizeObserver<"u"&&(l=new ResizeObserver(c),l.observe(t.current)),window.addEventListener("resize",c),window.requestAnimationFrame(c),o||i({loading:!1,error:""}))}).catch(u=>{o||i({loading:!1,error:String((u==null?void 0:u.message)||u)})}),()=>{var u,f;o=!0,c&&window.removeEventListener("resize",c),(u=l==null?void 0:l.disconnect)==null||u.call(l),(f=a==null?void 0:a.dispose)==null||f.call(a)}},[n]),!n.ok||r.error?s.jsxs("div",{className:"af-work-display-chart-error",children:[s.jsx("strong",{children:"Chart configuration error"}),s.jsx("span",{children:r.error||n.error})]}):s.jsxs("div",{className:"af-work-display-chart",children:[s.jsx("div",{ref:t,className:"af-work-display-chart__canvas"}),r.loading?s.jsx("div",{className:"af-work-display-chart__loading",children:"Loading chart..."}):null]})}/*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */function rM(e){return typeof e>"u"||e===null}function A7(e){return typeof e=="object"&&e!==null}function E7(e){return Array.isArray(e)?e:rM(e)?[]:[e]}function I7(e,t){var n,r,i,o;if(t)for(o=Object.keys(t),n=0,r=o.length;n<r;n+=1)i=o[n],e[i]=t[i];return e}function P7(e,t){var n="",r;for(r=0;r<t;r+=1)n+=e;return n}function T7(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var R7=rM,M7=A7,$7=E7,L7=P7,O7=T7,D7=I7,Fv={isNothing:R7,isObject:M7,toArray:$7,repeat:L7,isNegativeZero:O7,extend:D7};function sM(e,t){var n="",r=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(n+='in "'+e.mark.name+'" '),n+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!t&&e.mark.snippet&&(n+=`
|
|
92
|
+
|
|
93
|
+
`+e.mark.snippet),r+" "+n):r}function mf(e,t){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=t,this.message=sM(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}mf.prototype=Object.create(Error.prototype);mf.prototype.constructor=mf;mf.prototype.toString=function(t){return this.name+": "+sM(this,t)};var Ba=mf,F7=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],z7=["scalar","sequence","mapping"];function B7(e){var t={};return e!==null&&Object.keys(e).forEach(function(n){e[n].forEach(function(r){t[String(r)]=n})}),t}function W7(e,t){if(t=t||{},Object.keys(t).forEach(function(n){if(F7.indexOf(n)===-1)throw new Ba('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=B7(t.styleAliases||null),z7.indexOf(this.kind)===-1)throw new Ba('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var Or=W7;function D1(e,t){var n=[];return e[t].forEach(function(r){var i=n.length;n.forEach(function(o,a){o.tag===r.tag&&o.kind===r.kind&&o.multi===r.multi&&(i=a)}),n[i]=r}),n}function H7(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},t,n;function r(i){i.multi?(e.multi[i.kind].push(i),e.multi.fallback.push(i)):e[i.kind][i.tag]=e.fallback[i.tag]=i}for(t=0,n=arguments.length;t<n;t+=1)arguments[t].forEach(r);return e}function Mb(e){return this.extend(e)}Mb.prototype.extend=function(t){var n=[],r=[];if(t instanceof Or)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 Ba("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");n.forEach(function(o){if(!(o instanceof Or))throw new Ba("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(o.loadKind&&o.loadKind!=="scalar")throw new Ba("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(o.multi)throw new Ba("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),r.forEach(function(o){if(!(o instanceof Or))throw new Ba("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var i=Object.create(Mb.prototype);return i.implicit=(this.implicit||[]).concat(n),i.explicit=(this.explicit||[]).concat(r),i.compiledImplicit=D1(i,"implicit"),i.compiledExplicit=D1(i,"explicit"),i.compiledTypeMap=H7(i.compiledImplicit,i.compiledExplicit),i};var V7=Mb,K7=new Or("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),q7=new Or("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),U7=new Or("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),G7=new V7({explicit:[K7,q7,U7]});function Y7(e){if(e===null)return!0;var t=e.length;return t===1&&e==="~"||t===4&&(e==="null"||e==="Null"||e==="NULL")}function J7(){return null}function X7(e){return e===null}var Q7=new Or("tag:yaml.org,2002:null",{kind:"scalar",resolve:Y7,construct:J7,predicate:X7,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function Z7(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 eU(e){return e==="true"||e==="True"||e==="TRUE"}function tU(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var nU=new Or("tag:yaml.org,2002:bool",{kind:"scalar",resolve:Z7,construct:eU,predicate:tU,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 rU(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function sU(e){return 48<=e&&e<=55}function iU(e){return 48<=e&&e<=57}function oU(e){if(e===null)return!1;var t=e.length,n=0,r=!1,i;if(!t)return!1;if(i=e[n],(i==="-"||i==="+")&&(i=e[++n]),i==="0"){if(n+1===t)return!0;if(i=e[++n],i==="b"){for(n++;n<t;n++)if(i=e[n],i!=="_"){if(i!=="0"&&i!=="1")return!1;r=!0}return r&&i!=="_"}if(i==="x"){for(n++;n<t;n++)if(i=e[n],i!=="_"){if(!rU(e.charCodeAt(n)))return!1;r=!0}return r&&i!=="_"}if(i==="o"){for(n++;n<t;n++)if(i=e[n],i!=="_"){if(!sU(e.charCodeAt(n)))return!1;r=!0}return r&&i!=="_"}}if(i==="_")return!1;for(;n<t;n++)if(i=e[n],i!=="_"){if(!iU(e.charCodeAt(n)))return!1;r=!0}return!(!r||i==="_")}function aU(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 lU(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!Fv.isNegativeZero(e)}var cU=new Or("tag:yaml.org,2002:int",{kind:"scalar",resolve:oU,construct:aU,predicate:lU,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"]}}),uU=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function dU(e){return!(e===null||!uU.test(e)||e[e.length-1]==="_")}function fU(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 pU=/^[-+]?[0-9]+e/;function hU(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(Fv.isNegativeZero(e))return"-0.0";return n=e.toString(10),pU.test(n)?n.replace("e",".e"):n}function mU(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||Fv.isNegativeZero(e))}var gU=new Or("tag:yaml.org,2002:float",{kind:"scalar",resolve:dU,construct:fU,predicate:mU,represent:hU,defaultStyle:"lowercase"}),yU=G7.extend({implicit:[Q7,nU,cU,gU]}),wU=yU,iM=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),oM=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 xU(e){return e===null?!1:iM.exec(e)!==null||oM.exec(e)!==null}function bU(e){var t,n,r,i,o,a,l,c=0,u=null,f,p,d;if(t=iM.exec(e),t===null&&(t=oM.exec(e)),t===null)throw new Error("Date resolve error");if(n=+t[1],r=+t[2]-1,i=+t[3],!t[4])return new Date(Date.UTC(n,r,i));if(o=+t[4],a=+t[5],l=+t[6],t[7]){for(c=t[7].slice(0,3);c.length<3;)c+="0";c=+c}return t[9]&&(f=+t[10],p=+(t[11]||0),u=(f*60+p)*6e4,t[9]==="-"&&(u=-u)),d=new Date(Date.UTC(n,r,i,o,a,l,c)),u&&d.setTime(d.getTime()-u),d}function kU(e){return e.toISOString()}var vU=new Or("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:xU,construct:bU,instanceOf:Date,represent:kU});function SU(e){return e==="<<"||e===null}var jU=new Or("tag:yaml.org,2002:merge",{kind:"scalar",resolve:SU}),zv=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
|
|
94
|
+
\r`;function NU(e){if(e===null)return!1;var t,n,r=0,i=e.length,o=zv;for(n=0;n<i;n++)if(t=o.indexOf(e.charAt(n)),!(t>64)){if(t<0)return!1;r+=6}return r%8===0}function _U(e){var t,n,r=e.replace(/[\r\n=]/g,""),i=r.length,o=zv,a=0,l=[];for(t=0;t<i;t++)t%4===0&&t&&(l.push(a>>16&255),l.push(a>>8&255),l.push(a&255)),a=a<<6|o.indexOf(r.charAt(t));return n=i%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 CU(e){var t="",n=0,r,i,o=e.length,a=zv;for(r=0;r<o;r++)r%3===0&&r&&(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]),n=(n<<8)+e[r];return i=o%3,i===0?(t+=a[n>>18&63],t+=a[n>>12&63],t+=a[n>>6&63],t+=a[n&63]):i===2?(t+=a[n>>10&63],t+=a[n>>4&63],t+=a[n<<2&63],t+=a[64]):i===1&&(t+=a[n>>2&63],t+=a[n<<4&63],t+=a[64],t+=a[64]),t}function AU(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var EU=new Or("tag:yaml.org,2002:binary",{kind:"scalar",resolve:NU,construct:_U,predicate:AU,represent:CU}),IU=Object.prototype.hasOwnProperty,PU=Object.prototype.toString;function TU(e){if(e===null)return!0;var t=[],n,r,i,o,a,l=e;for(n=0,r=l.length;n<r;n+=1){if(i=l[n],a=!1,PU.call(i)!=="[object Object]")return!1;for(o in i)if(IU.call(i,o))if(!a)a=!0;else return!1;if(!a)return!1;if(t.indexOf(o)===-1)t.push(o);else return!1}return!0}function RU(e){return e!==null?e:[]}var MU=new Or("tag:yaml.org,2002:omap",{kind:"sequence",resolve:TU,construct:RU}),$U=Object.prototype.toString;function LU(e){if(e===null)return!0;var t,n,r,i,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1){if(r=a[t],$U.call(r)!=="[object Object]"||(i=Object.keys(r),i.length!==1))return!1;o[t]=[i[0],r[i[0]]]}return!0}function OU(e){if(e===null)return[];var t,n,r,i,o,a=e;for(o=new Array(a.length),t=0,n=a.length;t<n;t+=1)r=a[t],i=Object.keys(r),o[t]=[i[0],r[i[0]]];return o}var DU=new Or("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:LU,construct:OU}),FU=Object.prototype.hasOwnProperty;function zU(e){if(e===null)return!0;var t,n=e;for(t in n)if(FU.call(n,t)&&n[t]!==null)return!1;return!0}function BU(e){return e!==null?e:{}}var WU=new Or("tag:yaml.org,2002:set",{kind:"mapping",resolve:zU,construct:BU});wU.extend({implicit:[vU,jU],explicit:[EU,MU,DU,WU]});function F1(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
|
|
95
|
+
`:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"
":e===95?" ":e===76?"\u2028":e===80?"\u2029":""}var HU=new Array(256),VU=new Array(256);for(var Jl=0;Jl<256;Jl++)HU[Jl]=F1(Jl)?1:0,VU[Jl]=F1(Jl);const gf=["requirement","planning","code","test","normal"],z1={普通:"normal",技术规划:"planning",代码执行:"code",测试回归:"test",需求拆解:"requirement"};function Bv(e,t){var i,o,a,l,c,u,f,p,d,m,y,v,b,g;const n=k=>{const x={type:(k==null?void 0:k.type)??"node",name:(k==null?void 0:k.name)??"",value:(k==null?void 0:k.value)??(k==null?void 0:k.default)??""};return(k==null?void 0:k.required)===!0&&(x.required=!0),(k==null?void 0:k.description)!=null&&String(k.description).trim()&&(x.description=String(k.description)),(k==null?void 0:k.showOnNode)!=null&&(x.showOnNode=!!k.showOnNode),x},r={};for(const k of e){if((i=k==null?void 0:k.data)!=null&&i.isWorkspaceGroup)continue;const x=t[k.id]&&typeof t[k.id]=="object"?{...t[k.id]}:{},_=((o=k.data)==null?void 0:o.definitionId)||k.id,j=((a=k.data)==null?void 0:a.inputs)??[],N=((l=k.data)==null?void 0:l.outputs)??[],P=((c=k.data)==null?void 0:c.role)!=null?String(k.data.role).trim():"",T=x.role!=null?String(x.role).trim():"",z=z1[P]||P,E=z1[T]||T,O=gf.includes(z)?z:gf.includes(E)?E:"normal",D=Array.isArray(j)?j.map(n):Array.isArray(x.input)?x.input.map(ce=>n(ce)):[],L=Array.isArray(N)?N.map(n):Array.isArray(x.output)?x.output.map(ce=>n(ce)):[],$=((u=k.data)==null?void 0:u.label)!=null?String(k.data.label):x.label!=null?String(x.label):k.id,V=(f=k.data)==null?void 0:f.body,W=V!=null?String(V):x.body!=null?String(x.body):"";let F=((p=k.data)==null?void 0:p.model)!=null&&String(k.data.model).trim()!==""?String(k.data.model).trim():x.model!=null&&String(x.model).trim()!==""?String(x.model).trim():void 0;(F===""||F==="default")&&(F=void 0);const M={...x,definitionId:_,label:$,role:O,model:F,input:D,output:L},H=((d=k.data)==null?void 0:d.marketplaceRef)||x.marketplaceRef;H?M.marketplaceRef=String(H):delete M.marketplaceRef;const A=((m=k.data)==null?void 0:m.marketplacePackageId)||x.marketplacePackageId;A?M.marketplacePackageId=String(A):delete M.marketplacePackageId;const X=((y=k.data)==null?void 0:y.marketplaceVersion)||x.marketplaceVersion;X?M.marketplaceVersion=String(X):delete M.marketplaceVersion,_.startsWith("provide_")||W.trim()===""?delete M.body:M.body=W;const q=Array.isArray((v=k.data)==null?void 0:v.images)?k.data.images:Array.isArray(x.images)?x.images:[];q.length>0?M.images=q:delete M.images;const B=(b=k.data)==null?void 0:b.script,ne=B!=null?String(B):x.script!=null?String(x.script):"";ne.trim()===""?delete M.script:M.script=ne;for(const ce of["scriptRef","implementationRef","implementationMode"]){const K=(g=k.data)==null?void 0:g[ce],ee=K!=null?String(K):x[ce]!=null?String(x[ce]):"";ee.trim()===""?delete M[ce]:M[ce]=ee.trim()}delete M.temperature,delete M.maxTokens,delete M.description,r[k.id]=M}return r}function Ld(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`,i=2;for(;t.has(r);)r=`${n}_copy_${i}`,i+=1;return t.add(r),r}function qU(e,t,n){const r=(e||[]).filter(a=>a==null?void 0:a.selected);if(r.length===0)return null;const i=new Set(r.map(a=>a.id)),o=(t||[]).filter(a=>i.has(a.source)&&i.has(a.target));return{version:1,nodes:r.map(a=>Ld(a)),edges:o.map(a=>Ld(a)),instances:Bv(r,n||{})}}function UU(e,t,n,r,i={}){var p;if(!e||!Array.isArray(e.nodes)||e.nodes.length===0)return null;const o=i.offset||{x:48,y:48},a=new Set((t||[]).map(d=>d.id)),l=new Map;for(const d of e.nodes)l.set(d.id,KU(d.id,a));const c=e.nodes.map(d=>{var y,v;const m=l.get(d.id);return{...Ld(d),id:m,selected:!0,dragging:!1,position:{x:Number(((y=d.position)==null?void 0:y.x)||0)+o.x,y:Number(((v=d.position)==null?void 0:v.y)||0)+o.y}}}),u=(e.edges||[]).filter(d=>l.has(d.source)&&l.has(d.target)).map((d,m)=>{const y=l.get(d.source),v=l.get(d.target);return{...Ld(d),id:`e-${y}-${v}-${Date.now()}-${m}`,source:y,target:v,selected:!1}}),f={...r||{}};for(const[d,m]of l.entries()){const y=(p=e.instances)==null?void 0:p[d];y&&(f[m]={...Ld(y),label:y.label!=null?String(y.label):m})}return{nodes:[...(t||[]).map(d=>({...d,selected:!1})),...c],edges:[...(n||[]).map(d=>({...d,selected:!1})),...u],instances:f,pastedNodeIds:c.map(d=>d.id)}}function Bn(e){switch(Pm(e)){case"text":return"#2196f3";case"file":return"#4caf50";case"node":return"#ff9800";case"bool":return"#9c27b0";default:return"#9e9e9e"}}function Pm(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 GU(e,t){const n=Pm(e),r=Pm(t);return!n||!r?!1:n==="any"||r==="any"?!0:n===r}const YU=new Set(["knowledgeContext","workspaceContext","skillsContext","mcpContext"]);function $b(e){const t=Pm(e==null?void 0:e.type),n=String((e==null?void 0:e.name)||(e==null?void 0:e.id)||"").trim();return t==="text"&&YU.has(n)?`${t}+${n}`:t}function JU(e){return $b(e)}function yf(e,t){if(!e||!t||!GU(e.type,t.type))return!1;const n=$b(e),r=$b(t),i=n.includes("+"),o=r.includes("+");return i||o?n===r:!0}function XU(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 Lb(e,t,n){var l;const r=n==="source"?"outputs":"inputs",o=XU(t,n==="source"?"output":"input");return o<0?null:(Array.isArray((l=e==null?void 0:e.data)==null?void 0:l[r])?e.data[r]:[])[o]||null}const Tm=/\[image\s+(\d+)\]/gi;function So(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 QU(e){return`image ${So(e).length+1}`}function ZU(e,t){const n=String(e||""),r=`[${t}]`;return n.trim()?`${n.replace(/[ \t]+$/u,"")} ${r}`:r}function eG(e,t){const n=So(e),r=String(t||""),i=new Set;Tm.lastIndex=0;let o;for(;o=Tm.exec(r);)i.add(`image ${o[1]}`.toLowerCase());return i.size===0?[]:n.filter(a=>i.has(String(a.label||"").toLowerCase()))}function tG(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 aM(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 Od(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 lM({files:e,body:t,images:n}){const r=Array.from(e||[]);if(r.length===0)return null;let i=String(t||"");const o=So(n);for(const a of r){const l=await tG(a),c=QU(o);o.push({id:`${Date.now().toString(36)}-${o.length+1}`,label:c,...l}),i=ZU(i,c)}return{body:i,images:o}}function Ts(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function nG(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 rG(e){return["true","1","yes","on"].includes(String((e==null?void 0:e.value)??(e==null?void 0:e.default)??"").trim().toLowerCase())}function Rt(e){e.stopPropagation()}function sG(e){return String(e||"").replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function iG(e,t){const n=`\\[${sG(t)}\\]`;return String(e||"").replace(new RegExp(`[ \\t]*${n}`,"gi"),"").replace(/[ \t]+\n/g,`
|
|
96
|
+
`).replace(/\n{3,}/g,`
|
|
97
|
+
|
|
98
|
+
`).trimEnd()}function Tw(e){return String(e||"").replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function oG(e){const t=String(e||"");let n="",r=0;Tm.lastIndex=0;let i;for(;i=Tm.exec(t);)n+=Tw(t.slice(r,i.index)),n+=`<span class="af-flow-node__image-token">${Tw(i[0])}</span>`,r=i.index+i[0].length;return n+=Tw(t.slice(r)),n||" "}function Rw(e){return(Array.isArray(e)?e:[]).map(t=>String(t??"").trim()).filter(Boolean)}function aG({nodeTitle:e,definitionId:t,description:n,guide:r,inputs:i,outputs:o,onClose:a}){const{t:l}=zr(),[c,u]=h.useState(!1),f=String((r==null?void 0:r.summary)||n||"").trim(),p=Rw(r==null?void 0:r.prerequisites),d=Rw(r==null?void 0:r.steps),m=Rw(r==null?void 0:r.notes),y=String((r==null?void 0:r.example)||"").trim();h.useEffect(()=>{const g=k=>{k.key==="Escape"&&(k.preventDefault(),a())};return window.addEventListener("keydown",g),()=>window.removeEventListener("keydown",g)},[a]);const v=async()=>{var g;if(!(!y||typeof navigator>"u"||!((g=navigator.clipboard)!=null&&g.writeText)))try{await navigator.clipboard.writeText(y),u(!0),window.setTimeout(()=>u(!1),1600)}catch{}},b=(g,k)=>s.jsx("div",{className:"af-node-guide__slots",children:(Array.isArray(g)?g:[]).map((x,_)=>{const j=String((x==null?void 0:x.name)||`#${_+1}`),N=String((x==null?void 0:x.type)||"node"),P=String((x==null?void 0:x.default)??(x==null?void 0:x.value)??"");return s.jsxs("div",{className:"af-node-guide__slot",children:[s.jsxs("div",{className:"af-node-guide__slot-head",children:[s.jsx("code",{children:j}),s.jsx("span",{children:N}),s.jsx("em",{className:x!=null&&x.required?"is-required":"",children:x!=null&&x.required?l("flow:node.guideRequired"):l("flow:node.guideOptional")})]}),x!=null&&x.description?s.jsx("p",{children:String(x.description)}):null,P!==""?s.jsx("small",{children:l("flow:node.guideDefault",{value:P})}):null]},`${k}-${_}-${j}`)})});return er.createPortal(s.jsx("div",{className:"af-node-guide nodrag",role:"presentation",onClick:a,onPointerDown:Rt,onMouseDown:Rt,onWheel:Rt,children:s.jsxs("section",{className:"af-node-guide__panel",role:"dialog","aria-modal":"true","aria-label":`${e} · ${l("flow:node.guideTitle")}`,onClick:Rt,children:[s.jsxs("header",{className:"af-node-guide__header",children:[s.jsxs("div",{className:"af-node-guide__heading",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":"true",children:"help"}),s.jsxs("div",{children:[s.jsx("h2",{children:e}),s.jsxs("p",{children:[t," · ",l("flow:node.guideTitle")]})]})]}),s.jsx("button",{type:"button",onClick:a,"aria-label":l("flow:node.guideClose"),title:l("flow:node.guideClose"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-node-guide__content",children:[f?s.jsxs("section",{children:[s.jsx("h3",{children:l("flow:node.guideSummary")}),s.jsx("p",{children:f})]}):null,p.length?s.jsxs("section",{children:[s.jsx("h3",{children:l("flow:node.guidePrerequisites")}),s.jsx("ul",{children:p.map((g,k)=>s.jsx("li",{children:g},`pre-${k}`))})]}):null,d.length?s.jsxs("section",{children:[s.jsx("h3",{children:l("flow:node.guideSteps")}),s.jsx("ol",{children:d.map((g,k)=>s.jsx("li",{children:g},`step-${k}`))})]}):null,i!=null&&i.length?s.jsxs("section",{children:[s.jsx("h3",{children:l("flow:node.guideInputs")}),b(i,"input")]}):null,o!=null&&o.length?s.jsxs("section",{children:[s.jsx("h3",{children:l("flow:node.guideOutputs")}),b(o,"output")]}):null,y?s.jsxs("section",{children:[s.jsxs("div",{className:"af-node-guide__section-heading",children:[s.jsx("h3",{children:l("flow:node.guideExample")}),s.jsxs("button",{type:"button",className:"af-node-guide__copy",onClick:v,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":"true",children:c?"check":"content_copy"}),l(c?"flow:node.guideCopied":"flow:node.guideCopy")]})]}),s.jsx("pre",{children:y})]}):null,m.length?s.jsxs("section",{children:[s.jsx("h3",{children:l("flow:node.guideNotes")}),s.jsx("ul",{children:m.map((g,k)=>s.jsx("li",{children:g},`note-${k}`))})]}):null]})]})}),document.body)}function lG(e,t){const n=window.getComputedStyle(e),r=Number.parseFloat(n.lineHeight)||18,i=Number.parseFloat(n.paddingTop)||0,o=Number.parseFloat(n.paddingBottom)||0,a=Number.parseFloat(n.borderTopWidth)||0,l=Number.parseFloat(n.borderBottomWidth)||0,c=String(t||"").split(/\r\n|\r|\n/).length,u=Math.min(Math.max(c,2),8);return Math.ceil(u*r+i+o+a+l)}function cG({data:e,selected:t,id:n,deleteNode:r,onProvideExpand:i,onProvideValueChange:o,onNodeBodyChange:a,onNodeImagesChange:l,modelLists:c,onModelChange:u,deferTextCommit:f=!1}){var Nt,jn;const{t:p}=zr(),d=(e==null?void 0:e.inputs)??[],m=(e==null?void 0:e.outputs)??[],y=((e==null?void 0:e.schemaType)??"agent").toLowerCase(),v=nG(e),b=(e==null?void 0:e.isRunMode)??!1,g=!!(e!=null&&e.readOnly),k=(e==null?void 0:e.isExecuting)??!1,x=(e==null?void 0:e.isDim)??!1,_=(e==null?void 0:e.nodeStatus)??null,j=(e==null?void 0:e.nodeElapsed)??null,N=(e==null?void 0:e.nodeRunDetail)??null,P=(e==null?void 0:e.definitionId)||"",T=P==="tool_jenkins_build",z=String((N==null?void 0:N.jenkinsStatus)||((N==null?void 0:N.phase)==="queued"?"QUEUED":(N==null?void 0:N.phase)==="running"?"RUNNING":"")).toUpperCase(),E=P.startsWith("provide_"),O=P==="provide_bool",D=P==="provide_str",L=P==="provide_file",$=P==="provide_password",V=P==="agent_subAgent",W=P==="control_agent_toBool",F=(V||W)&&!b,M=O?rG(m[0]):!1,H=E?String(((Nt=m[0])==null?void 0:Nt.value)??((jn=m[0])==null?void 0:jn.default)??(e==null?void 0:e.body)??""):"",A=String((e==null?void 0:e.body)||""),X=(e==null?void 0:e.displayLabel)||(e==null?void 0:e.label)||p("flow:node.fallbackLabel"),q=!E&&!F&&(e!=null&&e.showBodyPreview)?String((e==null?void 0:e.body)||"").trim():"",B=So(e==null?void 0:e.images),ne=O||D||L||$||F||!!q,ce=h.useRef(!1),K=h.useRef(!1),ee=h.useRef(null),re=h.useRef(null),se=h.useRef(null),Q=h.useRef(null),le=h.useRef(null),[fe,me]=h.useState(H),[De,Ce]=h.useState(!1),[Se,Ue]=h.useState(A),[lt,xt]=h.useState(!1),[at,ze]=h.useState({visible:!1,top:0,height:100}),[Xe,Bt]=h.useState(!1),[Mt,Qt]=h.useState(!1),de=h.useCallback(()=>{const ue=re.current;if(!ue)return;const te=Math.max(1,ue.scrollHeight),ye=Math.max(1,ue.clientHeight),Me=te>ye+1,Ae=Me?Math.max(12,ye/te*100):100,ut=Math.max(0,100-Ae),Pt=Me?Math.min(ut,ue.scrollTop/Math.max(1,te-ye)*ut):0;ze({visible:Me,top:Pt,height:Ae})},[]);h.useEffect(()=>{ce.current||me(H)},[n,H]),h.useEffect(()=>{K.current||Ue(A)},[n,A]),h.useEffect(()=>{const ue=re.current;if(!ue)return;if(F){ue.style.minHeight="",ue.style.height="",se.current&&(se.current.style.minHeight="",se.current.style.height="");return}const te=lG(ue,Se);ue.style.minHeight=`${te}px`,ue.style.height="",se.current&&(se.current.style.minHeight=`${te}px`,se.current.style.height="")},[Se,F]),h.useEffect(()=>{if(!F)return;const ue=window.requestAnimationFrame(de),te=re.current;if(!te||typeof ResizeObserver>"u")return()=>window.cancelAnimationFrame(ue);const ye=new ResizeObserver(de);return ye.observe(te),()=>{window.cancelAnimationFrame(ue),ye.disconnect()}},[Se,F,de]),h.useEffect(()=>{const ue=ee.current,te=e==null?void 0:e.onNodeContentResize;if(!F||!ue||!te||typeof ResizeObserver>"u")return;let ye=0;const Me=()=>{window.cancelAnimationFrame(ye),ye=window.requestAnimationFrame(()=>te(n))},Ae=new ResizeObserver(Me);return Ae.observe(ue),Me(),()=>{window.cancelAnimationFrame(ye),Ae.disconnect()}},[e==null?void 0:e.onNodeContentResize,F,n]),h.useEffect(()=>{if(!Xe)return;const ue=window.setTimeout(()=>{const te=le.current;if(!te)return;te.focus();const ye=te.value.length;te.setSelectionRange(ye,ye)},0);return()=>window.clearTimeout(ue)},[Xe]);const ke=Array.isArray(c==null?void 0:c.cursor)?c.cursor:[],qe=Array.isArray(c==null?void 0:c.opencode)?c.opencode:[],st=Array.isArray(c==null?void 0:c.claudeCode)?c.claudeCode:[],Ee=Array.isArray(c==null?void 0:c.codex)?c.codex:[],rt=((e==null?void 0:e.model)??"").trim(),un=y==="agent"&&!P.startsWith("tool_nodejs"),Kt=new Set(ke.map(Ts)),yt=new Set(qe.map(Ts)),pn=new Set(st.map(Ts)),ie=new Set(Ee.map(Ts)),Ne=rt?rt.startsWith("cursor:")||rt.startsWith("opencode:")||rt.startsWith("codex:")||rt.startsWith("claude-code:")?rt:pn.has(rt)?`claude-code:${rt}`:ie.has(rt)?`codex:${rt}`:yt.has(rt)?`opencode:${rt}`:Kt.has(rt)?`cursor:${rt}`:rt:"",Ye=rt&&!Ne.startsWith("cursor:")&&!Ne.startsWith("opencode:")&&!Ne.startsWith("codex:")&&!Ne.startsWith("claude-code:")&&!Kt.has(rt)&&!yt.has(rt)&&!pn.has(rt)&&!ie.has(rt),He=rt.startsWith("cursor:")?rt.slice(7):rt.startsWith("opencode:")?rt.slice(9):rt.startsWith("codex:")?rt.slice(6):rt.startsWith("claude-code:")?rt.slice(12):rt,It=ue=>{if(g)return;const te=ue.target.value;u&&u(n,te)},jt=ue=>{ue.stopPropagation(),!g&&r&&r(n)},cr=ue=>{ue.stopPropagation(),i&&i()},$n=ue=>{ue.stopPropagation(),!g&&(o==null||o(n,ue.target.value==="true"?"true":"false"))},ur=ue=>{if(ue.stopPropagation(),g)return;const te=ue.target.value;me(te),!f&&!ce.current&&(o==null||o(n,te))},rn=ue=>{ue.stopPropagation(),ce.current=!0},gn=ue=>{if(ue.stopPropagation(),g)return;ce.current=!1;const te=ue.currentTarget.value;me(te),f||o==null||o(n,te)},Yn=()=>{g||f&&fe===H||o==null||o(n,fe)},gr=ue=>{if(ue.stopPropagation(),g)return;if(typeof(e==null?void 0:e.onOpenProvideFilePicker)=="function"){e.onOpenProvideFilePicker(n,fe);return}const te=window.prompt("文件路径",fe);te!=null&&(me(te),o==null||o(n,te))},yn=ue=>{ue.stopPropagation(),Ce(te=>!te)},Pn=ue=>{if(Ue(ue),a==null||a(n,ue),l){const te=eG(B,ue);(te.length!==B.length||te.some((ye,Me)=>{var Ae;return ye.id!==((Ae=B[Me])==null?void 0:Ae.id)}))&&l(n,te)}},nr=ue=>{if(ue.stopPropagation(),g)return;const te=ue.target.value;f||K.current?Ue(te):Pn(te)},Wr=ue=>{ue.stopPropagation(),!g&&(K.current=!0,xt(!0))},Sn=ue=>{if(ue.stopPropagation(),g)return;K.current=!1,xt(!1);const te=ue.currentTarget.value;f?Ue(te):Pn(te)},Jn=()=>{g||(K.current=!1,xt(!1),!(f&&Se===A)&&Pn(Se))},Hr=ue=>{ue.stopPropagation(),ue.preventDefault(),!g&&Bt(!0)},Vn=()=>{Bt(!1),Jn()},Kn=ue=>{ue.stopPropagation(),ue.key==="Escape"&&(ue.preventDefault(),Vn())},dr=h.useCallback(ue=>{const te=re.current;if(!te)return;const ye=Math.max(0,te.scrollHeight-te.clientHeight);te.scrollTop=Math.min(1,Math.max(0,ue))*ye,de()},[de]),fr=h.useCallback((ue,te=0)=>{const ye=Q.current;if(!ye)return 0;const Me=ye.getBoundingClientRect(),Ae=at.height/100*Me.height,ut=Math.max(1,Me.height-Ae);return(ue-Me.top-te)/ut},[at.height]),qn=h.useCallback(ue=>{var rr,dn;if(!at.visible)return;ue.preventDefault(),ue.stopPropagation();const te=Q.current;if(!te)return;const ye=te.getBoundingClientRect(),Me=at.top/100*ye.height,Ae=at.height/100*ye.height,Pt=ue.clientY>=ye.top+Me&&ue.clientY<=ye.top+Me+Ae?ue.clientY-ye.top-Me:Ae/2;dr(fr(ue.clientY,Pt));const Nn=ue.pointerId;(dn=(rr=ue.currentTarget).setPointerCapture)==null||dn.call(rr,Nn);const Je=Tr=>{Tr.preventDefault(),dr(fr(Tr.clientY,Pt))},hn=()=>{window.removeEventListener("pointermove",Je),window.removeEventListener("pointerup",hn),window.removeEventListener("pointercancel",hn)};window.addEventListener("pointermove",Je),window.addEventListener("pointerup",hn),window.addEventListener("pointercancel",hn)},[fr,at.height,at.top,at.visible,dr]),_r=async ue=>{if(g)return;const te=await lM({files:ue,body:Se,images:B});te&&(Ue(te.body),a==null||a(n,te.body),l==null||l(n,te.images))},yr=(ue,te)=>{if(ue.stopPropagation(),g)return;const ye=B.filter(Ae=>Ae.id!==te.id),Me=iG(Se,te.label);Ue(Me),a==null||a(n,Me),l==null||l(n,ye)},kt=ue=>{if(g)return;const te=aM(ue);te.length!==0&&(ue.preventDefault(),ue.stopPropagation(),_r(te).catch(()=>{}))},ct=ue=>{if(g)return;const te=Od(ue);te.length!==0&&(ue.preventDefault(),ue.stopPropagation(),_r(te).catch(()=>{}))},Zt=()=>{const ue=re.current,te=se.current;!ue||!te||(te.scrollTop=ue.scrollTop,te.scrollLeft=ue.scrollLeft)};return s.jsxs("div",{className:"af-flow-node"+(t?" af-flow-node--selected":"")+(k?" af-flow-node--executing":"")+(_==="success"?" af-flow-node--done":"")+(_==="failed"?" af-flow-node--failed":"")+(_==="outcome_failed"?" af-flow-node--failed":"")+(_==="waiting"?" af-flow-node--waiting":"")+(_==="running"&&!k?" af-flow-node--running-disk":"")+(x?" af-flow-node--dim":"")+(F?" af-flow-node--inline-body-editor":"")+(D?" af-flow-node--provide-text":"")+($?" af-flow-node--provide-password":"")+" af-flow-node--"+y.replace(/[^a-z0-9_-]/g,""),"data-schema":y,children:[s.jsxs("div",{className:"af-flow-node__chrome",children:[s.jsx("span",{className:"af-flow-node__title af-flow-node__title--chrome",title:`${X}${n?` (${n})`:""}${v?` · ${v}`:""}`,children:X}),!b&&un&&s.jsxs("div",{className:"af-flow-node__model-wrap nodrag",onPointerDown:Rt,onMouseDown:Rt,onClick:Rt,children:[s.jsxs("select",{className:"af-flow-node__model nodrag",value:Ne,onChange:It,onPointerDown:Rt,onMouseDown:Rt,onClick:Rt,"aria-label":p("flow:node.model"),title:He||p("flow:node.defaultModel"),disabled:g,children:[s.jsx("option",{value:"",children:p("flow:node.defaultModel")}),Ye&&s.jsx("option",{value:rt,children:rt}),ke.length>0&&s.jsx("optgroup",{label:"Cursor",children:ke.map(ue=>s.jsx("option",{value:`cursor:${Ts(ue)}`,children:Ts(ue)},`c-${ue}`))}),qe.length>0&&s.jsx("optgroup",{label:"OpenCode",children:qe.map(ue=>s.jsx("option",{value:`opencode:${Ts(ue)}`,children:Ts(ue)},`o-${ue}`))}),Ee.length>0&&s.jsx("optgroup",{label:"Codex",children:Ee.map(ue=>s.jsx("option",{value:`codex:${Ts(ue)}`,children:Ts(ue)},`codex-${ue}`))}),st.length>0&&s.jsx("optgroup",{label:"Claude Code",children:st.map(ue=>s.jsx("option",{value:`claude-code:${Ts(ue)}`,children:Ts(ue)},`cc-${ue}`))})]}),s.jsx("span",{className:"af-flow-node__model-arrow material-symbols-outlined",children:"expand_more"})]}),k&&s.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--executing",children:"EXECUTING"}),_==="running"&&!k&&s.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--running-disk",title:p("flow:node.diskRunning"),children:"RUNNING"}),_==="success"&&s.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--done",children:T&&z?z:j!=null&&String(j).trim()!==""?j:"--"}),_==="waiting"&&s.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--waiting",children:(N==null?void 0:N.phase)==="queued"?"QUEUED":(N==null?void 0:N.phase)==="triggering"?"TRIGGERING":"BUILDING"}),_==="outcome_failed"&&s.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:z||"FAILED"}),_==="failed"&&s.jsx("span",{className:"af-flow-node__status-badge af-flow-node__status-badge--failed",children:"FAILED"}),s.jsx("button",{type:"button",className:"af-flow-node__guide-button nodrag",onClick:ue=>{ue.stopPropagation(),Qt(!0)},onPointerDown:Rt,onMouseDown:Rt,"aria-label":p("flow:node.openGuide"),title:p("flow:node.openGuide"),children:s.jsx("span",{className:"material-symbols-outlined",children:"help"})}),!b&&E&&!O&&!D&&!L&&!$&&s.jsx("button",{type:"button",className:"af-flow-node__expand",onClick:cr,"aria-label":p("flow:node.expandProvide"),title:p("flow:node.expandProvide"),children:s.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),!b&&s.jsx("button",{type:"button",className:"af-flow-node__delete",disabled:g,onClick:jt,"aria-label":p("flow:node.deleteNode"),title:p("flow:node.deleteNode"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-flow-node__body",children:[s.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--in",children:d.map((ue,te)=>{if(ue.showOnNode===!1)return null;const ye=p("flow:node.inputTooltip",{name:ue.name||`#${te}`,type:ue.type})+(ue.default!=null&&ue.default!==""?p("flow:node.defaultSuffix",{value:ue.default}):""),Me=ue.name||`#${te+1}`;return s.jsxs("div",{className:"af-flow-node__port-row",title:ye,children:[s.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--in",children:[Me,ue.required?s.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),s.jsx(ar,{type:"target",position:Ge.Left,id:`input-${te}`,className:"af-flow-node__handle",style:{background:Bn(ue.type)},title:ye})]},`in-${te}`)})}),s.jsxs("div",{className:"af-flow-node__title-wrap",children:[b&&T&&N?s.jsxs("div",{className:"af-flow-node__jenkins-runtime",children:[s.jsxs("div",{className:"af-flow-node__jenkins-runtime-main",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":"true",children:_==="waiting"?"progress_activity":_==="success"?"check_circle":"error"}),s.jsx("span",{children:N.message||z||"Jenkins Build"})]}),N.buildNumber?s.jsxs("small",{children:["Build #",N.buildNumber]}):null,N.url||N.qrUrl?s.jsxs("div",{className:"af-flow-node__jenkins-runtime-links nodrag",children:[N.url?s.jsx("a",{href:N.url,target:"_blank",rel:"noreferrer",onPointerDown:Rt,onClick:Rt,children:"查看结果"}):null,N.qrUrl?s.jsx("a",{href:N.qrUrl,target:"_blank",rel:"noreferrer",onPointerDown:Rt,onClick:Rt,children:"二维码"}):null]}):null]}):null,O?s.jsxs("select",{className:"af-flow-node__bool-select nodrag"+(M?" af-flow-node__bool-select--true":""),value:M?"true":"false",onChange:$n,onPointerDown:Rt,onMouseDown:Rt,onClick:Rt,"aria-label":"Boolean value",title:M?"true":"false",disabled:g,children:[s.jsx("option",{value:"false",children:"false"}),s.jsx("option",{value:"true",children:"true"})]}):D?s.jsx("textarea",{className:"af-flow-node__inline-text nodrag",value:fe,onChange:ur,onCompositionStart:rn,onCompositionEnd:gn,onBlur:Yn,onPointerDown:Rt,onMouseDown:Rt,onClick:Rt,placeholder:"输入文本",rows:2,readOnly:g}):L?s.jsxs("div",{className:"af-flow-node__file-value nodrag",onPointerDown:Rt,onMouseDown:Rt,onClick:Rt,children:[s.jsx("input",{className:"af-flow-node__file-input nodrag",value:fe,onChange:ur,onCompositionStart:rn,onCompositionEnd:gn,onBlur:Yn,placeholder:"选择或输入文件路径",title:fe||"选择或输入文件路径",readOnly:g}),s.jsx("button",{type:"button",className:"af-flow-node__file-picker nodrag",disabled:g,onClick:gr,"aria-label":"选择文件",title:"选择文件",children:s.jsx("span",{className:"material-symbols-outlined",children:"folder_open"})})]}):$?s.jsxs("div",{className:"af-flow-node__password-value nodrag",onPointerDown:Rt,onMouseDown:Rt,onClick:Rt,children:[s.jsx("input",{className:"af-flow-node__password-input nodrag",type:De?"text":"password",value:fe,onChange:ur,onCompositionStart:rn,onCompositionEnd:gn,onBlur:Yn,placeholder:"输入密码或密钥",title:De?fe:"密码已隐藏",autoComplete:"off",readOnly:g}),s.jsx("button",{type:"button",className:"af-flow-node__password-toggle nodrag",disabled:g,onClick:yn,"aria-label":De?"隐藏密码":"预览密码",title:De?"隐藏密码":"预览密码",children:s.jsx("span",{className:"material-symbols-outlined",children:De?"visibility_off":"visibility"})})]}):F?s.jsxs("div",{ref:ee,className:"af-flow-node__prompt-stack nodrag"+(lt?" af-flow-node__prompt-stack--composing":""),children:[s.jsx("pre",{ref:se,className:"af-flow-node__prompt-backdrop","aria-hidden":"true",dangerouslySetInnerHTML:{__html:oG(Se)+`
|
|
99
|
+
`}}),s.jsx("textarea",{ref:re,className:"af-flow-node__prompt-editor nodrag",value:Se,onChange:nr,onCompositionStart:Wr,onCompositionEnd:Sn,onBlur:Jn,onPaste:kt,onDrop:ct,onScroll:ue=>{Zt(),de()},onPointerDown:Rt,onMouseDown:Rt,onClick:Rt,onKeyDown:Rt,onDragOver:ue=>{Od(ue).length>0&&ue.preventDefault()},placeholder:W?"输入判断条件 / prompt":"输入 prompt",rows:2,readOnly:g}),!g&&s.jsx("button",{type:"button",className:"af-flow-node__prompt-expand nodrag",onPointerDown:Rt,onMouseDown:Rt,onClick:Hr,"aria-label":"放大编辑",title:"放大编辑",children:s.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),s.jsx("div",{ref:Q,className:"af-flow-node__prompt-scrollbar"+(at.visible?" af-flow-node__prompt-scrollbar--visible":""),onPointerDown:qn,"aria-hidden":"true",children:s.jsx("span",{style:{height:`${at.height}%`,top:`${at.top}%`}})})]}):null,F&&B.length>0?s.jsx("div",{className:"af-flow-node__image-chips",children:B.map((ue,te)=>s.jsxs("span",{className:"af-flow-node__image-chip",title:ue.name,children:[s.jsx("img",{src:ue.dataUrl,alt:""}),s.jsxs("span",{children:["[",ue.label||`image ${te+1}`,"]"]}),s.jsx("button",{type:"button",className:"af-flow-node__image-remove nodrag",disabled:g,onClick:ye=>yr(ye,ue),onPointerDown:Rt,onMouseDown:Rt,"aria-label":`删除 ${ue.label||`image ${te+1}`}`,title:"删除图片",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},ue.id||te))}):null,q?s.jsx("span",{className:"af-flow-node__prompt-preview",title:q,children:q}):null,ne?null:s.jsx("span",{className:"af-flow-node__body-title",title:X,children:X})]}),s.jsx("div",{className:"af-flow-node__ports af-flow-node__ports--out",children:m.map((ue,te)=>{if(ue.showOnNode===!1)return null;const ye=p("flow:node.outputTooltip",{name:ue.name||`#${te}`,type:ue.type})+(ue.default!=null&&ue.default!==""?p("flow:node.defaultSuffix",{value:ue.default}):""),Me=ue.name||`#${te+1}`;return s.jsxs("div",{className:"af-flow-node__port-row",title:ye,children:[s.jsxs("span",{className:"af-flow-node__port-label af-flow-node__port-label--out",children:[Me,ue.required?s.jsx("span",{className:"af-flow-node__port-required",children:"*"}):null]}),s.jsx(ar,{type:"source",position:Ge.Right,id:`output-${te}`,className:"af-flow-node__handle",style:{background:Bn(ue.type)},title:ye})]},`out-${te}`)})})]}),Xe?er.createPortal(s.jsx("div",{className:"af-flow-node-full-editor nodrag",onPointerDown:Rt,onMouseDown:Rt,onClick:Rt,onWheel:Rt,children:s.jsxs("div",{className:"af-flow-node-full-editor__panel",children:[s.jsxs("div",{className:"af-flow-node-full-editor__header",children:[s.jsxs("div",{children:[s.jsx("div",{className:"af-flow-node-full-editor__title",children:X}),s.jsx("div",{className:"af-flow-node-full-editor__hint",children:"编辑 prompt,Esc 关闭"})]}),s.jsx("button",{type:"button",className:"af-flow-node-full-editor__close",onClick:Vn,"aria-label":"关闭",title:"关闭",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsx("textarea",{ref:le,className:"af-flow-node-full-editor__textarea",value:Se,onChange:nr,onCompositionStart:Wr,onCompositionEnd:Sn,onPaste:kt,onDrop:ct,onKeyDown:Kn,onDragOver:ue=>{Od(ue).length>0&&ue.preventDefault()},placeholder:W?"输入判断条件 / prompt":"输入 prompt",readOnly:g})]})}),document.body):null,Mt?s.jsx(aG,{nodeTitle:X,definitionId:P,description:e==null?void 0:e.description,guide:e==null?void 0:e.guide,inputs:d,outputs:m,onClose:()=>Qt(!1)}):null]})}const Tc="flowNode";function Ob(e){const t=e.type||"node",n=e.showOnNode!=null,r={type:t,name:e.name||"",default:e.value!==void 0&&e.value!==null?String(e.value):e.default!==void 0?String(e.default):""};return e.required!=null&&(r.required=!!e.required),e.description!=null&&(r.description=String(e.description)),r.showOnNode=n?!!e.showOnNode:!!r.required||String(t).trim().toLowerCase()==="node",r._showOnNodeExplicit=n,r}const uG={agent_subAgent:["SubAgent"],control_start:["Start"],control_end:["End"],control_agent_toBool:["Agent ToBool"],control_anyOne:["Any One"],control_cancelled:["Cancelled","Cancel Check"],control_cd_workspace:["CD Workspace","Load Workspace"],control_delay:["Delay"],control_if:["If Branch"],control_interval_loop:["Interval Loop"],control_load_skills:["Load Skills"],control_load_mcp:["Load MCP"],workspace_scheduled_run:["Scheduled Run"],workspace_run:["Run"],control_user_workspace:["User Workspace"],control_toBool:["To Bool","Code ToBool"],control_wait_until:["Wait Until"],tool_git_checkout:["Git Checkout"],tool_get_env:["Get Env"],tool_load_key:["Load Key"],tool_set_run_env:["Set Run Env","Set Env"],tool_display_share_link:["Display Share Link","Share Link"],tool_nodejs:["Node.js Script"],tool_print:["Print"],tool_save_key:["Save Key"],tool_user_ask:["UserAsk"],tool_user_check:["User Confirm"],provide_file:["File"],provide_password:["Password"],provide_bool:["Boolean"],provide_text:["Text"],provide_str:["Text"],display_markdown:["Markdown Display"],display_react_app:["React App"],display_mermaid:["Mermaid Display"],display_ascii:["ASCII Display"],display_chart:["Chart Display"],display_table:["Table Display"]};function dG(e,t,n){const r=String((n==null?void 0:n.displayName)||"").trim(),i=String(t||"").trim();return!r||!i||r===i?i:(uG[e]||[]).includes(i)?r:i}const fG={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"])},pG={control_cd_workspace:new Set(["mode","label","workspaceContext","cwd","previous"]),control_user_workspace:new Set(["cwd"]),display_markdown:new Set(["prev","next"]),display_mermaid:new Set(["prev","next"]),display_ascii:new Set(["prev","next"]),display_html:new Set(["prev","next"]),display_react_app:new Set(["prev","next"]),display_image:new Set(["prev","next"]),display_chart:new Set(["prev","next"]),display_table:new Set(["prev","next"]),tool_git_checkout:new Set(["branch","targetDir","pullIfExists","includeSubmodules","repoPath","commit","changed"]),tool_gitlab_create_mr:new Set(["repoPath","workspaceContext","sourceBranch","targetBranch","title","description","draft","labels","push","remote","tokenEnv","gitlabApiBase","removeSourceBranch","squash","created","mrIid","projectId","message"])},hG={agent_subAgent:new Set(["knowledgeContext","skillsContext"])},mG=new Set(["display_markdown","display_mermaid","display_ascii","display_html","display_react_app","display_image","display_chart","display_table"]);function gG(e,t){if(!mG.has(String(e||"")))return!1;const n=String((t==null?void 0:t.name)||"");return n==="content"||n==="src"}function yG(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function wG(e,t){const n=String((e==null?void 0:e.baseDefinitionId)||"").trim();return n||t}function cM(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function xG(e,t){const n=String((e==null?void 0:e.language)||"").trim().toLowerCase(),r=String(t||"").trim().toLowerCase();return n.includes("python")||r.endsWith(".py")?"python3":n.includes("shell")||n==="bash"||r.endsWith(".sh")||r.endsWith(".bash")?"bash":"node"}function bG(e){const t=String(e??"").trim();return t?t.includes("${")?t:cM(t):""}function kG(e){if(String((e==null?void 0:e.baseDefinitionId)||"").trim()!=="tool_nodejs")return"";const t=e!=null&&e.runtime&&typeof e.runtime=="object"?e.runtime:{},n=String(t.entry||"").trim().replace(/^\/+/,"");if(n){const r=String((e==null?void 0:e.packageDir)||"").trim().replace(/\/+$/,""),i=r?`${r}/${n}`:`\${flowDir}/${n}`,o=Array.isArray(t.args)?t.args.map(bG).filter(Boolean):[];return[xG(t,n),cM(i),...o].join(" ")}return String(t.command||"").trim()}function B1(e,t,n){return!Array.isArray(t)||!Array.isArray(n)||n.length===0?t:t.map((r,i)=>{var u,f,p;const o=n[i],l=n.find(d=>(d==null?void 0:d.name)&&d.name===r.name)||o;if(!l)return r;const c=r.showOnNode===!1&&l.showOnNode==null&&((u=fG[e])==null?void 0:u.has(r.name));return{...r,...r.required==null&&l.required!=null?{required:!!l.required}:{},...r.description==null&&l.description!=null?{description:String(l.description)}:{},...c?{showOnNode:!0}:{},...!r._showOnNodeExplicit&&l.showOnNode!=null?{showOnNode:!!l.showOnNode}:{},...!r._showOnNodeExplicit&&l.showOnNode==null?{showOnNode:!!r.required||String(r.type||"").trim().toLowerCase()==="node"}:{},...!r._showOnNodeExplicit&&gG(e,r)?{showOnNode:!0}:{},...(f=hG[e])!=null&&f.has(r.name)?{showOnNode:!0}:{},...(p=pG[e])!=null&&p.has(r.name)?{showOnNode:!1}:{}}})}function vG(e){var i,o;const t=Array.isArray((i=e==null?void 0:e.data)==null?void 0:i.inputs)?e.data.inputs:[],n=Array.isArray((o=e==null?void 0:e.data)==null?void 0:o.outputs)?e.data.outputs:[],r=a=>a.map(l=>{const c=Ob(l);return{type:String(c.type||"node"),name:String(c.name??""),default:String(c.default??""),required:!!c.required,description:String(c.description??""),showOnNode:c.showOnNode!=null?c.showOnNode!==!1:!!c.required||String(c.type||"").trim().toLowerCase()==="node"}});return{inputs:r(t),outputs:r(n)}}function Db(e,t,n,r,i){var M,H,A,X,q,B,ne,ce,K,ee,re,se,Q,le,fe,me,De,Ce,Se,Ue,lt,xt,at;const o=((M=e.data)==null?void 0:M.definitionId)||String(e.id).replace(/-\d+$/,""),a=n.find(ze=>ze.id===o),l=t[e.id];let c=[],u=[],f=((H=e.data)==null?void 0:H.label)??e.id,p,d,m,y,v;const b=!!l;l&&(Array.isArray(l.input)&&(c=l.input.map(Ob)),Array.isArray(l.output)&&(u=l.output.map(Ob)),l.label&&(f=String(l.label)),l.role&&typeof l.role=="string"&&(p=l.role),l.model!=null&&(d=String(l.model).trim()),l.body!=null&&(m=String(l.body)),Array.isArray(l.images)&&(y=l.images),l.script!=null&&(v=String(l.script)));const g=p??(typeof((A=e.data)==null?void 0:A.role)=="string"?e.data.role:"普通"),k=d??((X=e.data)==null?void 0:X.model)??void 0,x=(a==null?void 0:a.description)!=null?String(a.description).trim():"",_=x!==""?x:void 0,j=m??((q=e.data)==null?void 0:q.body)??"",N=Array.isArray(y)?y:Array.isArray((B=e.data)==null?void 0:B.images)?e.data.images:[],P=kG(a),T=v!==void 0?v:((ne=e.data)==null?void 0:ne.script)!=null?String(e.data.script):P,z=String(e.id),E=(ce=r==null?void 0:r[i])==null?void 0:ce[z],O=(K=E==null?void 0:E.label)==null?void 0:K.label,D=E==null?void 0:E.body,L=E==null?void 0:E.description;b||(c.length===0&&((ee=a==null?void 0:a.inputs)!=null&&ee.length)&&(c=a.inputs.map(ze=>({...ze}))),u.length===0&&((re=a==null?void 0:a.outputs)!=null&&re.length)&&(u=a.outputs.map(ze=>({...ze}))));const $=wG(a,(a==null?void 0:a.id)??o),V=(l==null?void 0:l.marketplaceRef)||((se=e.data)==null?void 0:se.marketplaceRef)||yG(a);if($==="agent_subAgent"&&!u.some(ze=>(ze==null?void 0:ze.name)==="result")){const ze=(Q=a==null?void 0:a.outputs)==null?void 0:Q.find(Xe=>(Xe==null?void 0:Xe.name)==="result");u=[...u,ze?{...ze}:{type:"text",name:"result",default:""}]}if($==="agent_subAgent"&&!c.some(ze=>(ze==null?void 0:ze.name)==="knowledgeContext")){const ze=(le=a==null?void 0:a.inputs)==null?void 0:le.find(Xe=>(Xe==null?void 0:Xe.name)==="knowledgeContext");c=[...c,ze?{...ze}:{type:"text",name:"knowledgeContext",default:"",showOnNode:!0}]}if(($==="display_markdown"||$==="display_mermaid"||$==="display_ascii"||$==="display_chart"||$==="display_table")&&!u.some(ze=>(ze==null?void 0:ze.name)==="next")){const ze=(fe=a==null?void 0:a.outputs)==null?void 0:fe.find(Xe=>(Xe==null?void 0:Xe.name)==="next");u=[...u,ze?{...ze}:{type:"node",name:"next",default:""}]}if($==="workspace_run"){if(!c.some(ze=>(ze==null?void 0:ze.name)==="prev")){const ze=(me=a==null?void 0:a.inputs)==null?void 0:me.find(Xe=>(Xe==null?void 0:Xe.name)==="prev");c=[ze?{...ze}:{type:"node",name:"prev",default:""},...c]}if(!u.some(ze=>(ze==null?void 0:ze.name)==="next")){const ze=(De=a==null?void 0:a.outputs)==null?void 0:De.find(Xe=>(Xe==null?void 0:Xe.name)==="next");u=[...u,ze?{...ze}:{type:"node",name:"next",default:""}]}}c=B1($,c,a==null?void 0:a.inputs),u=B1($,u,a==null?void 0:a.outputs),$.startsWith("provide_")&&u[0]&&String(u[0].default??u[0].value??"").trim()===""&&String(j).trim()!==""&&(u=u.map((ze,Xe)=>Xe===0?{...ze,default:j,value:j}:ze));const W=dG($,f,a),F=$==="tool_nodejs"||String(T).trim()!=="";return{...e,type:"flowNode",data:{...e.data,label:O||f,displayLabel:W,definitionDisplayName:a==null?void 0:a.displayName,definitionId:$,...V?{marketplaceRef:V}:{},...l!=null&&l.marketplacePackageId||(Ce=e.data)!=null&&Ce.marketplacePackageId||a!=null&&a.packageId?{marketplacePackageId:(l==null?void 0:l.marketplacePackageId)||((Se=e.data)==null?void 0:Se.marketplacePackageId)||(a==null?void 0:a.packageId)}:{},...l!=null&&l.marketplaceVersion||(Ue=e.data)!=null&&Ue.marketplaceVersion||a!=null&&a.version?{marketplaceVersion:(l==null?void 0:l.marketplaceVersion)||((lt=e.data)==null?void 0:lt.marketplaceVersion)||(a==null?void 0:a.version)}:{},schemaType:((xt=e.data)==null?void 0:xt.schemaType)??e.type??"agent",role:g,model:k,body:D||j,images:N,script:T,inputs:c,outputs:u,description:L||_,guide:(a==null?void 0:a.guide)||((at=e.data)==null?void 0:at.guide),originalLabel:f,originalBody:j,...F?{script:T}:{}}}}function SG(e,t){const n=new Map(t.map(r=>[r.id,r]));return e.filter(r=>{var f,p,d,m;const i=n.get(r.source),o=n.get(r.target),a=((p=(f=i==null?void 0:i.data)==null?void 0:f.outputs)==null?void 0:p.length)??0,l=((m=(d=o==null?void 0:o.data)==null?void 0:d.inputs)==null?void 0:m.length)??0,c=r.sourceHandle?parseInt(String(r.sourceHandle).replace("output-",""),10):0,u=r.targetHandle?parseInt(String(r.targetHandle).replace("input-",""),10):0;return i&&o&&c>=0&&c<a&&u>=0&&u<l})}function W1(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 H1(e,t){return!Array.isArray(e)||!e[t]||e[t].showOnNode===!0?e:e.map((n,r)=>r===t?{...n,showOnNode:!0}:n)}function Mw(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 i=W1(t==null?void 0:t.sourceHandle,"output"),o=W1(t==null?void 0:t.targetHandle,"input");let a=!1;const l=(e||[]).map(c=>{var u,f,p,d;if(c.id===n){const m=H1((u=c.data)==null?void 0:u.outputs,i);if(m!==((f=c.data)==null?void 0:f.outputs))return a=!0,{...c,data:{...c.data,outputs:m}}}if(c.id===r){const m=H1((p=c.data)==null?void 0:p.inputs,o);if(m!==((d=c.data)==null?void 0:d.inputs))return a=!0,{...c,data:{...c.data,inputs:m}}}return c});return a?l:e}function jG(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 V1(e){return e.key==="?"||e.key==="/"&&e.shiftKey}function NG(){return typeof navigator>"u"?!1:/Mac|iPhone|iPod|iPad/i.test(navigator.platform||navigator.userAgent||"")}function _G({children:e}){return s.jsx("kbd",{className:"af-kbd",children:e})}function ei({keys:e}){return s.jsx("span",{className:"af-shortcuts-keys",children:e.map((t,n)=>s.jsxs("span",{children:[n>0?s.jsx("span",{className:"af-shortcuts-keys__plus",children:"+"}):null,s.jsx(_G,{children:t})]},n))})}function CG({open:e,onClose:t}){const{t:n}=zr(),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 o=NG()?"⌘":"Ctrl";return s.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:a=>{a.target===a.currentTarget&&t()},children:s.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:[s.jsxs("div",{className:"af-shortcuts-panel__head",children:[s.jsx("h2",{id:"af-shortcuts-title",className:"af-shortcuts-panel__title",children:n("flow:shortcuts.title")}),s.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":n("common:common.close"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-shortcuts-panel__body",children:[s.jsxs("section",{className:"af-shortcuts-section",children:[s.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.general")}),s.jsxs("ul",{className:"af-shortcuts-list",children:[s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveDesc")}),s.jsx(ei,{keys:[o,"S"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.shortcutsLabel")}),s.jsx(ei,{keys:["?"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.jumpToNode")}),s.jsx(ei,{keys:[o,"K"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.openNodePalette")}),s.jsx(ei,{keys:["A"]})]})]})]}),s.jsxs("section",{className:"af-shortcuts-section",children:[s.jsx("h3",{className:"af-shortcuts-cat",children:n("flow:shortcuts.canvas")}),s.jsxs("ul",{className:"af-shortcuts-list",children:[s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectTool")}),s.jsx(ei,{keys:["V"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.panTool")}),s.jsx(ei,{keys:["H"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.holdSpacePan")}),s.jsx(ei,{keys:["Space"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.saveViewport")}),s.jsx(ei,{keys:["F"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.selectAll")}),s.jsx(ei,{keys:[o,"A"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.undo")}),s.jsx(ei,{keys:[o,"Z"]})]}),s.jsxs("li",{className:"af-shortcuts-row",children:[s.jsx("span",{className:"af-shortcuts-row__label",children:n("flow:shortcuts.redo")}),s.jsx(ei,{keys:[o,"Shift","Z"]})]})]})]})]})]})})}function AG(e,t){if(!t)return 1;const n=t.toLowerCase(),r=(e.id||"").toLowerCase(),i=(e.label||"").toLowerCase(),o=(e.definitionId||"").toLowerCase();return r===n?100:r.startsWith(n)?80:r.includes(n)?60:i.startsWith(n)?40:i.includes(n)?30:o.includes(n)?15:0}function EG({open:e,onClose:t,onJump:n,nodes:r}){const{t:i}=zr(),[o,a]=h.useState(""),[l,c]=h.useState(0),u=h.useRef(null),f=h.useRef(null);h.useEffect(()=>{if(!e)return;a(""),c(0);const y=requestAnimationFrame(()=>{var v;return(v=u.current)==null?void 0:v.focus()});return()=>cancelAnimationFrame(y)},[e]);const p=h.useMemo(()=>{const y=(r||[]).map(g=>{var k,x,_;return{id:g.id,label:((k=g.data)==null?void 0:k.label)||"",definitionId:((x=g.data)==null?void 0:x.definitionId)||"",schemaType:((_=g.data)==null?void 0:_.schemaType)||""}}),v=o.trim(),b=y.map(g=>({e:g,s:AG(g,v)})).filter(g=>g.s>0);return b.sort((g,k)=>k.s-g.s||g.e.id.localeCompare(k.e.id)),b.slice(0,50).map(g=>g.e)},[r,o]);if(h.useEffect(()=>{l>=p.length&&c(0)},[p.length,l]),h.useEffect(()=>{var v;const y=(v=f.current)==null?void 0:v.querySelector(`[data-idx="${l}"]`);y&&y.scrollIntoView({block:"nearest"})},[l]),!e)return null;const d=y=>{const v=p[y];v&&(n(v.id),t())},m=y=>{if(y.key==="Escape"){y.preventDefault(),t();return}if(y.key==="ArrowDown"){y.preventDefault(),c(v=>Math.min(p.length-1,v+1));return}if(y.key==="ArrowUp"){y.preventDefault(),c(v=>Math.max(0,v-1));return}y.key==="Enter"&&(y.preventDefault(),d(l))};return s.jsx("div",{className:"af-jump-overlay",role:"presentation",onMouseDown:y=>{y.target===y.currentTarget&&t()},children:s.jsxs("div",{className:"af-jump-panel",role:"dialog","aria-modal":"true","aria-label":i("flow:jumpPalette.title"),onMouseDown:y=>y.stopPropagation(),children:[s.jsxs("div",{className:"af-jump-panel__input-wrap",children:[s.jsx("span",{className:"af-jump-panel__icon material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{ref:u,type:"text",className:"af-jump-panel__input",placeholder:i("flow:jumpPalette.placeholder"),value:o,onChange:y=>{a(y.target.value),c(0)},onKeyDown:m,spellCheck:!1,autoComplete:"off"}),s.jsx("span",{className:"af-jump-panel__count",children:p.length})]}),p.length===0?s.jsx("div",{className:"af-jump-panel__empty",children:i("flow:jumpPalette.empty")}):s.jsx("ul",{ref:f,className:"af-jump-panel__list",role:"listbox",children:p.map((y,v)=>s.jsxs("li",{"data-idx":v,role:"option","aria-selected":v===l,className:"af-jump-panel__item"+(v===l?" af-jump-panel__item--active":""),onMouseEnter:()=>c(v),onMouseDown:b=>{b.preventDefault(),d(v)},children:[s.jsx("span",{className:"af-jump-panel__id",children:y.id}),y.label&&y.label!==y.id&&s.jsx("span",{className:"af-jump-panel__label",children:y.label}),y.definitionId&&s.jsx("span",{className:"af-jump-panel__tag",children:y.definitionId})]},y.id))}),s.jsxs("div",{className:"af-jump-panel__hint",children:[s.jsxs("span",{children:[s.jsx("kbd",{className:"af-kbd",children:"↑"}),s.jsx("kbd",{className:"af-kbd",children:"↓"})," ",i("flow:jumpPalette.hintNavigate")]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"af-kbd",children:"Enter"})," ",i("flow:jumpPalette.hintJump")]}),s.jsxs("span",{children:[s.jsx("kbd",{className:"af-kbd",children:"Esc"})," ",i("flow:jumpPalette.hintClose")]})]})]})})}function K1(e){const t=Number(e||0);if(!Number.isFinite(t)||t<=0)return"-";const n=new Date(t),r=i=>String(i).padStart(2,"0");return`${r(n.getMonth()+1)}-${r(n.getDate())} ${r(n.getHours())}:${r(n.getMinutes())}:${r(n.getSeconds())}`}function IG(e){const t=Number(e||0);if(!Number.isFinite(t)||t<=0)return"-";if(t<1e3)return`${Math.round(t)}ms`;const n=Math.round(t/1e3);if(n<60)return`${n}s`;const r=Math.floor(n/60),i=n%60;return`${r}m${String(i).padStart(2,"0")}s`}function q1(e){if(!e||typeof e!="object")return"";if(e.line)return String(e.line);if(e.text)return String(e.text);if(e.error)return String(e.error);if(e.message)return String(e.message);if(e.status)return String(e.status);if(e.type==="graph"){const n=Array.isArray(e.displayNodeIds)?e.displayNodeIds.join(", "):"";return n?`graph updated: ${n}`:"graph updated"}const t=JSON.stringify(e);return t.length>4e3?`${t.slice(0,4e3)}
|
|
100
|
+
... [truncated]`:t}function $w(e){return String((e==null?void 0:e.nodeId)||(e==null?void 0:e.runNodeId)||"")}function U1(e){const t=String(e||"").toLowerCase();return t.includes("success")?"success":t.includes("fail")||t.includes("error")?"failed":t.includes("skip")||t.includes("disabled")?"skipped":t.includes("running")?"running":t.includes("stop")?"stopped":"idle"}function PG({flowParams:e,scheduleNodeId:t="",runNodeId:n="",lastRunId:r="",label:i="",onClose:o}){const[a,l]=h.useState([]),[c,u]=h.useState(""),[f,p]=h.useState(null),[d,m]=h.useState(!1),[y,v]=h.useState(!1),[b,g]=h.useState(""),[k,x]=h.useState(""),_=h.useCallback(async()=>{if(e!=null&&e.flowId){m(!0),g("");try{const T=new URLSearchParams;T.set("flowId",e.flowId),T.set("flowSource",e.flowSource||"user"),t?T.set("scheduleNodeId",t):n&&T.set("runNodeId",n),T.set("limit","80");const z=await fetch(`/api/workspace/run-logs?${T.toString()}`),E=await z.json().catch(()=>({}));if(!z.ok)throw new Error(E.error||"读取日志失败");const O=Array.isArray(E.runs)?E.runs:[];l(O),u(D=>{const L=O[0]||null;return L&&String(L.status||"")==="running"&&L.runId!==D?L.runId:D&&O.some($=>$.runId===D)?D:r&&O.some($=>$.runId===r)?r:(L==null?void 0:L.runId)||""})}catch(T){g(String(T.message||T)),l([])}finally{m(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,r,n,t]),j=h.useCallback(async T=>{if(!T){p(null);return}v(!0);try{const z=new URLSearchParams({flowId:(e==null?void 0:e.flowId)||"",flowSource:(e==null?void 0:e.flowSource)||"user"});e!=null&&e.archived&&z.set("archived","1");const E=await fetch(`/api/workspace/run-logs/${encodeURIComponent(T)}?${z.toString()}`),O=await E.json().catch(()=>({}));if(!E.ok)throw new Error(O.error||"读取日志详情失败");p(O)}catch(z){p({error:String(z.message||z),events:[]})}finally{v(!1)}},[e==null?void 0:e.archived,e==null?void 0:e.flowId,e==null?void 0:e.flowSource]);h.useEffect(()=>{_()},[_]),h.useEffect(()=>{j(c)},[j,c]),h.useEffect(()=>{const T=a.find(E=>E.runId===c),z=window.setInterval(()=>{_(),(!T||T.status==="running")&&c&&j(c)},2e3);return()=>window.clearInterval(z)},[j,_,a,c]);const N=h.useMemo(()=>{const T=Array.isArray(f==null?void 0:f.events)?f.events:[],z=k.trim().toLowerCase();return z?T.filter(E=>String(E.type||"").toLowerCase().includes(z)||$w(E).toLowerCase().includes(z)||q1(E).toLowerCase().includes(z)):T},[f==null?void 0:f.events,k]),P=(f==null?void 0:f.run)||a.find(T=>T.runId===c)||null;return s.jsxs("div",{className:"af-work-run-logs",children:[s.jsxs("div",{className:"af-pipeline-drawer-head",children:[s.jsx("h2",{className:"af-pipeline-drawer-title",children:"执行日志"}),s.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:o,"aria-label":"关闭日志侧栏",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-work-run-logs__meta",children:[s.jsx("span",{children:i||t||n||"Workspace Run"}),s.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void _(),title:"刷新日志","aria-label":"刷新日志",children:s.jsx("span",{className:"material-symbols-outlined",children:"refresh"})})]}),b?s.jsx("div",{className:"af-work-run-logs__error",children:b}):null,s.jsxs("div",{className:"af-work-run-logs__body",children:[s.jsxs("div",{className:"af-work-run-logs__list",children:[s.jsx("div",{className:"af-work-run-logs__section-title",children:"最近执行"}),d?s.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,!d&&a.length===0?s.jsx("div",{className:"af-work-run-logs__empty",children:"暂无执行日志"}):null,a.map(T=>s.jsxs("button",{type:"button",className:"af-work-run-logs__run"+(T.runId===c?" af-work-run-logs__run--active":""),onClick:()=>u(T.runId),title:T.runId,children:[s.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${U1(T.status)}`,children:T.status||"unknown"}),s.jsx("span",{className:"af-work-run-logs__run-label",children:T.label||T.runNodeId||T.scheduleNodeId||"Workspace Run"}),s.jsx("span",{children:K1(T.startedAt)}),s.jsx("span",{children:IG(T.durationMs)})]},T.runId))]}),s.jsxs("div",{className:"af-work-run-logs__detail",children:[s.jsxs("div",{className:"af-work-run-logs__detail-head",children:[s.jsxs("div",{children:[s.jsx("div",{className:"af-work-run-logs__section-title",children:"详情"}),P!=null&&P.label?s.jsx("div",{className:"af-work-run-logs__detail-label",children:P.label}):null,s.jsx("div",{className:"af-work-run-logs__run-id",children:(P==null?void 0:P.runId)||"-"})]}),P?s.jsx("span",{className:`af-work-run-logs__status af-work-run-logs__status--${U1(P.status)}`,children:P.status}):null]}),s.jsxs("label",{className:"af-work-run-logs__search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{value:k,onChange:T=>x(T.target.value),placeholder:"搜索事件、节点、错误"})]}),y?s.jsx("div",{className:"af-work-run-logs__empty",children:"Loading..."}):null,f!=null&&f.error?s.jsx("div",{className:"af-work-run-logs__error",children:f.error}):null,!y&&!N.length?s.jsx("div",{className:"af-work-run-logs__empty",children:"暂无事件"}):null,s.jsx("div",{className:"af-work-run-logs__events",children:N.map((T,z)=>s.jsxs("div",{className:"af-work-run-logs__event",children:[s.jsx("span",{className:"af-work-run-logs__event-time",children:K1(T.ts)}),s.jsx("span",{className:"af-work-run-logs__event-type",children:T.type||"event"}),$w(T)?s.jsx("span",{className:"af-work-run-logs__event-node",children:$w(T)}):null,s.jsx("pre",{children:q1(T)})]},`${T.ts||z}-${z}`))})]})]})]})}function TG({label:e="AgentFlow AI 正在处理"}){return s.jsxs("div",{className:"af-workflow-assistant-pending",role:"status","aria-label":e,children:[s.jsx("span",{}),s.jsx("span",{}),s.jsx("span",{}),s.jsx("em",{children:e})]})}function Lw({role:e="assistant",content:t="",pending:n=!1,pendingLabel:r="AgentFlow AI 正在处理",error:i=!1,copy:o=!0}){const[a,l]=h.useState(!1),c=String(t||"").trim();h.useEffect(()=>{if(!a)return;const f=window.setTimeout(()=>l(!1),1600);return()=>window.clearTimeout(f)},[a]);const u=async()=>{var f;if(!(!c||!((f=navigator.clipboard)!=null&&f.writeText)))try{await navigator.clipboard.writeText(c),l(!0)}catch{l(!1)}};return e==="user"?s.jsxs("section",{className:"af-workflow-assistant-message af-workflow-assistant-message--user",children:[s.jsx("div",{className:"af-workflow-assistant-message__meta",children:"你"}),s.jsx("div",{className:"af-workflow-assistant-message__bubble",children:s.jsx(hf,{content:c})})]}):s.jsxs("section",{className:`af-workflow-assistant-message af-workflow-assistant-message--assistant${i?" af-workflow-assistant-message--error":""}`,children:[s.jsxs("div",{className:"af-workflow-assistant-message__identity",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:i?"error":"auto_awesome"}),s.jsx("strong",{children:i?"执行遇到问题":"AgentFlow AI"})]}),s.jsxs("div",{className:"af-workflow-assistant-message__bubble",children:[c?s.jsx(hf,{content:c}):null,n?s.jsx(TG,{label:r}):null]}),o&&c&&!i?s.jsx("div",{className:"af-workflow-assistant-actions",children:s.jsxs("button",{type:"button",className:"af-workflow-assistant-copy","data-copied":a?"true":"false",onClick:()=>void u(),"aria-label":"复制回答",children:[s.jsx("span",{className:"material-symbols-outlined af-workflow-assistant-copy__idle","aria-hidden":!0,children:"content_copy"}),s.jsx("span",{className:"material-symbols-outlined af-workflow-assistant-copy__done","aria-hidden":!0,children:"check"}),s.jsx("span",{className:"af-workflow-assistant-copy__label",children:"复制"})]})}):null]})}function RG({items:e=[],running:t=!1,label:n="执行过程",defaultOpen:r=!1}){const i=(Array.isArray(e)?e:[]).map((o,a)=>({id:String((o==null?void 0:o.id)||`${(o==null?void 0:o.kind)||"activity"}-${a}`),kind:String((o==null?void 0:o.kind)||"activity"),label:String((o==null?void 0:o.label)||(o==null?void 0:o.kind)||"Activity"),text:String((o==null?void 0:o.text)||(o==null?void 0:o.content)||"").trim()})).filter(o=>o.text);return!i.length&&!t?null:s.jsxs("details",{className:`af-composer-assistant-activity${t?" af-composer-assistant-activity--running":""}`,defaultOpen:r,children:[s.jsxs("summary",{children:[s.jsx("span",{className:"af-composer-assistant-activity__pulse","aria-hidden":!0}),s.jsx("strong",{children:n}),s.jsx("span",{children:t?"进行中":`已完成 ${i.length} 项`}),s.jsx("span",{className:"material-symbols-outlined af-composer-assistant-activity__chevron","aria-hidden":!0,children:"expand_more"})]}),s.jsxs("div",{className:"af-composer-assistant-activity__body",children:[i.map(o=>s.jsxs("article",{className:`af-composer-assistant-activity__item af-composer-assistant-activity__item--${o.kind}`,children:[s.jsx("small",{children:o.label}),s.jsx("pre",{children:o.text})]},o.id)),t&&!i.length?s.jsx("p",{className:"af-composer-assistant-activity__status",children:"正在分析当前画布并生成执行步骤…"}):null]})]})}function MG({value:e="",onChange:t,onSend:n,placeholder:r="继续描述你想让 AI 调整什么…",disabled:i=!1,busy:o=!1}){const a=!i&&!o&&!!String(e||"").trim(),l=c=>{var u;c.key!=="Enter"||c.shiftKey||(u=c.nativeEvent)!=null&&u.isComposing||(c.preventDefault(),a&&(n==null||n()))};return s.jsx("div",{className:"af-composer-sidebar-input af-composer-sidebar-input--assistant",children:s.jsxs("div",{className:"af-workflow-assistant-composer",children:[s.jsx("textarea",{className:"af-workflow-assistant-composer__input",value:e,rows:1,onChange:c=>t==null?void 0:t(c.target.value),onKeyDown:l,placeholder:r,disabled:i||o,"aria-label":"输入 AI Composer 要求"}),s.jsxs("div",{className:"af-workflow-assistant-composer__bottom",children:[s.jsx("small",{children:o?"AI 正在执行当前任务":"Enter 发送 · Shift + Enter 换行"}),s.jsx("button",{type:"button",className:"af-workflow-assistant-composer__send",disabled:!a,onClick:()=>n==null?void 0:n(),"aria-label":"发送 AI Composer 对话",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:o?"more_horiz":"arrow_upward"})})]})]})})}function $G(e){let t=String(e||"").trim();const n=t.match(/```(?:json|jsx|tsx|javascript|js)?\s*\n?([\s\S]*?)```/i);if(n&&n[1])t=n[1].trim();else{const r=t.match(/```(?:json|jsx|tsx|javascript|js)?\s*\n?([\s\S]*)$/i);r&&r[1]&&(t=r[1].trim())}return t.replace(/```\s*$/g,"").trim()}function uM(e){const t=$G(e);if(!t)return{title:"React App",entry:"src/App.jsx",files:{"src/App.jsx":"export default function App() { return <main><h1>React App</h1><p>No project files yet.</p></main>; }"},inputs:{}};try{const n=JSON.parse(t);if(n&&typeof n=="object"&&!Array.isArray(n)){const r=n.files&&typeof n.files=="object"&&!Array.isArray(n.files)?n.files:{};return{title:String(n.title||n.name||"React App"),entry:String(n.entry||n.main||"src/App.jsx"),files:Object.fromEntries(Object.entries(r).map(([i,o])=>[String(i),String(o??"")])),packageJson:n.packageJson&&typeof n.packageJson=="object"?n.packageJson:null,inputs:n.inputs&&typeof n.inputs=="object"&&!Array.isArray(n.inputs)?n.inputs:{}}}}catch{}return{title:"React App",entry:"src/App.jsx",files:{"src/App.jsx":t},inputs:{}}}function LG(e){let t=String(e||"");return t=t.replace(/^\s*import\s+[^;]+;\s*$/gm,""),t=t.replace(/^\s*import\s+["'][^"']+["'];\s*$/gm,""),t=t.replace(/\bexport\s+default\s+function\s+([A-Za-z_$][\w$]*)\s*\(/g,"const __AgentFlowDefault = function $1("),t=t.replace(/\bexport\s+default\s+function\s*\(/g,"const __AgentFlowDefault = function App("),t=t.replace(/\bexport\s+default\s+class\s+([A-Za-z_$][\w$]*)\s+extends/g,"const __AgentFlowDefault = class $1 extends"),t=t.replace(/\bexport\s+default\s+class\s+extends/g,"const __AgentFlowDefault = class extends"),t=t.replace(/\bexport\s+default\s+(\([^)]*\)\s*=>)/g,"const __AgentFlowDefault = $1"),t=t.replace(/\bexport\s+default\s+([A-Za-z_$][\w$]*\s*=>)/g,"const __AgentFlowDefault = $1"),t=t.replace(/\bexport\s+default\s+([A-Za-z_$][\w$]*)\s*;?/g,"const __AgentFlowDefault = $1;"),t=t.replace(/\bexport\s+(const|let|var|function|class)\s+/g,"$1 "),t=t.replace(/^\s*export\s+\{[^}]+\};?\s*$/gm,""),t.trim()}function OG(e){return String(e).replace(/<\/script/gi,"<\\/script")}function Lg(e){const t=uM(e);return JSON.stringify({title:t.title,entry:t.entry,packageJson:t.packageJson||{scripts:{dev:"vite --host 0.0.0.0",build:"vite build"},dependencies:{"@vitejs/plugin-react":"latest",vite:"latest",react:"latest","react-dom":"latest"},devDependencies:{}},files:t.files,inputs:t.inputs},null,2)}function Wv(e,t=""){const n=uM(e),r=n.files||{},i=r[n.entry]!=null?n.entry:Object.keys(r).find(d=>/(?:^|\/)App\.[jt]sx$/i.test(d))||Object.keys(r).find(d=>/\.[jt]sx?$/i.test(d))||n.entry,o=LG(r[i]||""),a=Object.entries(r).filter(([d])=>/\.css$/i.test(d)).map(([,d])=>String(d||"")).join(`
|
|
101
|
+
|
|
102
|
+
`),l=String(n.title||"React App"),c=JSON.stringify(String(t||"")),u=JSON.stringify(n.inputs||{}),f=OG(o||"function App() { return <main><h1>React App</h1><p>No entry file content.</p></main>; }"),p=a||`
|
|
103
|
+
* { box-sizing: border-box; }
|
|
104
|
+
body { margin: 0; min-height: 100vh; background: #111112; color: #f4f0ff; font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
|
|
105
|
+
main { min-height: 100vh; padding: 24px; }
|
|
106
|
+
button, input, select, textarea { font: inherit; }
|
|
107
|
+
`;return`<!doctype html>
|
|
108
|
+
<html>
|
|
109
|
+
<head>
|
|
110
|
+
<meta charset="utf-8" />
|
|
111
|
+
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
112
|
+
<base target="_blank" />
|
|
113
|
+
<title>${l.replace(/[<&>]/g,d=>({"<":"<",">":">","&":"&"})[d])}</title>
|
|
114
|
+
<style>${p.replace(/<\/style/gi,"<\\/style")}</style>
|
|
115
|
+
</head>
|
|
116
|
+
<body>
|
|
117
|
+
<div id="root"></div>
|
|
118
|
+
<script crossorigin src="https://unpkg.com/react@18/umd/react.production.min.js"><\/script>
|
|
119
|
+
<script crossorigin src="https://unpkg.com/react-dom@18/umd/react-dom.production.min.js"><\/script>
|
|
120
|
+
<script crossorigin src="https://unpkg.com/@babel/standalone/babel.min.js"><\/script>
|
|
121
|
+
<script>
|
|
122
|
+
window.AGENTFLOW_INPUTS = ${u};
|
|
123
|
+
window.addEventListener("error", (event) => {
|
|
124
|
+
const root = document.getElementById("root");
|
|
125
|
+
if (root && !root.__agentflowRendered) {
|
|
126
|
+
root.innerHTML = '<pre style="margin:16px;padding:16px;border:1px solid rgba(255,117,117,.35);border-radius:8px;background:rgba(127,29,29,.18);color:#ffb8b8;white-space:pre-wrap;">' + String(event.message || event.error || 'React app failed').replace(/[<>&]/g, (ch) => ({'<':'<','>':'>','&':'&'}[ch])) + '</pre>';
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
document.addEventListener("click", (event) => {
|
|
130
|
+
const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
|
|
131
|
+
if (!link) return;
|
|
132
|
+
const rawHref = String(link.getAttribute("href") || "").trim();
|
|
133
|
+
if (!rawHref || rawHref.startsWith("#")) return;
|
|
134
|
+
if (/^javascript:/i.test(rawHref)) {
|
|
135
|
+
event.preventDefault();
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
event.preventDefault();
|
|
139
|
+
window.open(link.href, "_blank", "noopener,noreferrer");
|
|
140
|
+
}, true);
|
|
141
|
+
<\/script>
|
|
142
|
+
<script type="text/babel">
|
|
143
|
+
const { useCallback, useEffect, useMemo, useRef, useState } = React;
|
|
144
|
+
${f}
|
|
145
|
+
const RootComponent = typeof __AgentFlowDefault !== "undefined" ? __AgentFlowDefault : (typeof App !== "undefined" ? App : function MissingApp() {
|
|
146
|
+
return <main><h1>React App</h1><p>Entry file must export or define an App component.</p></main>;
|
|
147
|
+
});
|
|
148
|
+
ReactDOM.createRoot(document.getElementById("root")).render(<RootComponent inputs={window.AGENTFLOW_INPUTS} />);
|
|
149
|
+
document.getElementById("root").__agentflowRendered = true;
|
|
150
|
+
<\/script>
|
|
151
|
+
<script>
|
|
152
|
+
(() => {
|
|
153
|
+
const frameId = ${c};
|
|
154
|
+
const postSize = () => {
|
|
155
|
+
const doc = document.documentElement;
|
|
156
|
+
const body = document.body;
|
|
157
|
+
const height = Math.ceil(Math.max(
|
|
158
|
+
doc ? doc.scrollHeight : 0,
|
|
159
|
+
doc ? doc.offsetHeight : 0,
|
|
160
|
+
doc ? doc.clientHeight : 0,
|
|
161
|
+
body ? body.scrollHeight : 0,
|
|
162
|
+
body ? body.offsetHeight : 0,
|
|
163
|
+
body ? body.clientHeight : 0,
|
|
164
|
+
window.innerHeight || 0
|
|
165
|
+
));
|
|
166
|
+
window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
|
|
167
|
+
};
|
|
168
|
+
window.addEventListener("load", postSize);
|
|
169
|
+
window.addEventListener("resize", postSize);
|
|
170
|
+
requestAnimationFrame(postSize);
|
|
171
|
+
setTimeout(postSize, 300);
|
|
172
|
+
setTimeout(postSize, 1000);
|
|
173
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
174
|
+
const resizeObserver = new ResizeObserver(postSize);
|
|
175
|
+
resizeObserver.observe(document.documentElement);
|
|
176
|
+
if (document.body) resizeObserver.observe(document.body);
|
|
177
|
+
}
|
|
178
|
+
})();
|
|
179
|
+
<\/script>
|
|
180
|
+
</body>
|
|
181
|
+
</html>`}const dM=new Set(["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"]),DG=["workspaceRoot","pipelineWorkspace","cwd","flowName","runDir","flowDir"];function FG(e,t){const n=e.slice(0,t),r=n.lastIndexOf("${");if(r<0)return null;const i=n.slice(r+2);return i.includes("}")?null:{atIndex:r,query:i}}function zG(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 G1(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 fM(e,{inputNames:t,outputNames:n}){const r=e.trim();if(!r)return!1;if(r.startsWith("input.")){const i=r.slice(6).trim();return i!==""&&t.has(i)}if(r.startsWith("output.")){const i=r.slice(7).trim();return i!==""&&n.has(i)}if(dM.has(r)||t.has(r)||n.has(r))return!0;if(!r.includes(".")){const i=`${r}.md`;if(t.has(i)||n.has(i))return!0}return!1}function pM(e){return{inputNames:G1(e==null?void 0:e.inputs),outputNames:G1(e==null?void 0:e.outputs)}}function BG(e,t,n){const r=pM(t),i=zG(e),o=[];for(const a of i)if(!fM(a.key,r)){const l=a.key.trim()===""?n("flow:placeholder.empty"):a.key.trim();o.push({start:a.start,end:a.end,message:n("flow:placeholder.invalidPlaceholder",{hint:l})})}return o}function WG(e,t){const n=pM(t),r=/\$\{([^}]*)\}/g,i=[];let o=0,a;for(;(a=r.exec(e))!==null;){a.index>o&&i.push({kind:"plain",text:e.slice(o,a.index)});const l=a[0],c=fM(a[1],n);i.push({kind:c?"ph-valid":"ph-invalid",text:l}),o=a.index+l.length}return o<e.length&&i.push({kind:"plain",text:e.slice(o)}),i}function HG(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""")}function VG(e){return e.map(t=>{const n=HG(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 KG(e,t){const n=[];for(const r of(e==null?void 0:e.inputs)??[]){const i=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!i)continue;const o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"input",insert:`input.${i}`,label:i,subtitle:o?t("flow:placeholder.inputSubtitle",{type:o}):t("flow:placeholder.inputSubtitleNoType")})}for(const r of(e==null?void 0:e.outputs)??[]){const i=(r==null?void 0:r.name)!=null?String(r.name).trim():"";if(!i)continue;const o=(r==null?void 0:r.type)!=null?String(r.type):"";n.push({section:"output",insert:`output.${i}`,label:i,subtitle:o?t("flow:placeholder.outputSubtitle",{type:o}):t("flow:placeholder.outputSubtitleNoType")})}for(const r of DG)dM.has(r)&&n.push({section:"runtime",insert:r,label:r,subtitle:t("flow:placeholder.runtimeConst")});return n}function qG(e,t){const n=t.toLowerCase();return n?e.filter(r=>[r.insert,r.label,r.subtitle??""].map(o=>String(o).toLowerCase()).some(o=>o.includes(n))):e}function UG(e,t){if(!e||t<0)return null;const n=Math.min(t,e.value.length),r=getComputedStyle(e),i=document.createElement("div");i.setAttribute("aria-hidden","true"),i.style.visibility="hidden",i.style.position="fixed",i.style.top="0",i.style.left="-99999px",i.style.whiteSpace="pre-wrap",i.style.wordWrap="break-word",i.style.overflow="hidden";const o=e.clientWidth;if(o<=0)return null;i.style.width=`${o}px`,i.style.font=r.font,i.style.lineHeight=r.lineHeight,i.style.padding=r.padding,i.style.border=r.border,i.style.boxSizing=r.boxSizing,i.style.letterSpacing=r.letterSpacing,i.style.textIndent=r.textIndent,i.style.tabSize=r.tabSize||"8",i.textContent=e.value.slice(0,n);const a=document.createElement("span");a.textContent="",i.appendChild(a),document.body.appendChild(i);const l=a.getBoundingClientRect(),c=parseFloat(r.lineHeight),u=Number.isFinite(c)&&c>0?c:l.height||16;return document.body.removeChild(i),{top:l.top,left:l.left,bottom:l.bottom,height:u}}function ih({value:e,onChange:t,disabled:n,placeholder:r,rows:i=8,textareaClassName:o,ioSlots:a,variant:l="drawer",images:c,onImagesChange:u}){const{t:f}=zr(),p=h.useId(),d=h.useRef(null),m=h.useRef(null),[y,v]=h.useState(0),[b,g]=h.useState(0),[k,x]=h.useState(null),_=h.useMemo(()=>So(c),[c]),j=h.useMemo(()=>BG(e,a,f),[e,a,f]),N=j.length>0,P=h.useMemo(()=>WG(e,a),[e,a]),T=h.useMemo(()=>VG(P),[P]),z=h.useMemo(()=>n?null:FG(e,y),[e,y,n]),E=h.useMemo(()=>{if(!z)return[];const W=KG(a,f);return qG(W,z.query)},[z,a,f]);h.useEffect(()=>{g(W=>{const F=Math.max(0,E.length-1);return Math.min(Math.max(0,W),F)})},[E.length]);const O=h.useCallback(()=>{const W=d.current;if(!W||!z||E.length===0){x(null);return}const F=UG(W,y);if(!F){x(null);return}const M=4,H=44,A=13.5*16,X=Math.min(E.length*H+8,A);let q=F.bottom+M;q+X>window.innerHeight-8&&(q=Math.max(8,F.top-X-M));const B=288;let ne=F.left;ne=Math.max(8,Math.min(ne,window.innerWidth-B-8)),x({top:q,left:ne})},[z,E.length,y]);h.useLayoutEffect(()=>{if(!z||E.length===0){x(null);return}const W=requestAnimationFrame(()=>O());return()=>cancelAnimationFrame(W)},[z,E.length,y,e,O]),h.useEffect(()=>{if(!z||E.length===0)return;const W=()=>O();return window.addEventListener("scroll",W,!0),window.addEventListener("resize",W),()=>{window.removeEventListener("scroll",W,!0),window.removeEventListener("resize",W)}},[z,E.length,O]);const D=h.useCallback(W=>{if(!z)return;const{atIndex:F}=z,M=e.slice(0,F)+"${"+W+"}"+e.slice(y);t(M);const H=F+W.length+3;queueMicrotask(()=>{const A=d.current;A&&(A.focus(),A.setSelectionRange(H,H)),v(H)})},[z,e,y,t]),L=h.useCallback(()=>{const W=d.current,F=m.current;!W||!F||(F.scrollTop=W.scrollTop,F.scrollLeft=W.scrollLeft,z&&E.length>0&&queueMicrotask(()=>O()))},[z,E.length,O]),$=h.useCallback(W=>{if(!n&&z&&E.length>0&&(W.key==="ArrowDown"||W.key==="ArrowUp"||W.key==="Enter")){if(W.key==="ArrowDown")W.preventDefault(),g(F=>(F+1)%E.length);else if(W.key==="ArrowUp")W.preventDefault(),g(F=>(F-1+E.length)%E.length);else if(W.key==="Enter"&&!W.shiftKey){W.preventDefault();const F=E[b];F&&D(F.insert)}}},[n,z,E,b,D]),V=h.useCallback(async W=>{if(n||typeof u!="function")return!1;const F=await lM({files:W,body:e,images:_});return F?(t(F.body),u(F.images),queueMicrotask(()=>{const M=d.current;if(!M)return;M.focus();const H=F.body.length;M.setSelectionRange(H,H),v(H)}),!0):!1},[n,_,t,u,e]);return s.jsxs("div",{className:"af-body-prompt-editor"+(l==="expand"?" af-body-prompt-editor--expand":""),children:[_.length>0?s.jsx("div",{className:"af-body-image-list","aria-label":"image attachments",children:_.map((W,F)=>s.jsxs("span",{className:"af-body-image-chip",title:W.name,children:[s.jsx("img",{src:W.dataUrl,alt:""}),s.jsxs("span",{children:["[",W.label||`image ${F+1}`,"]"]})]},W.id||F))}):null,s.jsxs("div",{className:"af-body-prompt-stack",children:[s.jsx("pre",{ref:m,className:"af-body-prompt-backdrop "+o,"aria-hidden":"true",dangerouslySetInnerHTML:{__html:T+`
|
|
182
|
+
`}}),s.jsx("textarea",{ref:d,className:"af-body-prompt-textarea "+o,rows:i,value:e,disabled:n,placeholder:r,spellCheck:!1,"aria-invalid":N,"aria-describedby":N?p:void 0,onChange:W=>{t(W.target.value),v(W.target.selectionStart??W.target.value.length)},onSelect:W=>{const F=W.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onClick:W=>{const F=W.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??0)},onKeyUp:W=>{const F=W.target;F instanceof HTMLTextAreaElement&&v(F.selectionStart??F.value.length)},onKeyDown:$,onPaste:W=>{const F=aM(W);F.length!==0&&(W.preventDefault(),V(F).catch(()=>{}))},onDragOver:W=>{Od(W).length>0&&W.preventDefault()},onDrop:W=>{const F=Od(W);F.length!==0&&(W.preventDefault(),V(F).catch(()=>{}))},onScroll:L})]}),z&&E.length>0&&k?er.createPortal(s.jsx("ul",{className:"af-body-ph-menu af-body-ph-menu--pop af-composer-mention-menu",role:"listbox","aria-label":f("flow:nodeProps.placeholderSlots"),style:{position:"fixed",top:k.top,left:k.left,right:"auto",bottom:"auto",margin:0,zIndex:2e4},children:E.map((W,F)=>s.jsx("li",{role:"option","aria-selected":F===b,children:s.jsxs("button",{type:"button",className:"af-composer-mention-item"+(F===b?" af-composer-mention-item--active":""),onMouseDown:M=>M.preventDefault(),onMouseEnter:()=>g(F),onClick:()=>D(W.insert),children:[s.jsx("span",{className:"af-composer-mention-id",children:`\${${W.insert}}`}),W.subtitle?s.jsx("span",{className:"af-composer-mention-sub",children:W.subtitle}):null]})},`${W.section}-${W.insert}`))}),document.body):null,N?s.jsx("p",{id:p,className:"af-body-ph-issues",role:"status",children:j.map(W=>W.message).join(" · ")}):null]})}const GG=/^[a-zA-Z_][a-zA-Z0-9_-]*$/;function td(e){const t=e.indexOf(" - ");return t>=0?e.slice(0,t).trim():e.trim()}function Y1({kind:e,label:t,slots:n,onSlotsChange:r,disabled:i,requiredReadonly:o=!0}){const{t:a}=zr(),l=()=>r([...n,{type:"text",name:"",default:"",required:!1,showOnNode:!1}]),c=p=>r(n.filter((d,m)=>m!==p)),u=(p,d,m)=>{const y=n.map((v,b)=>{if(b!==p)return v;const g={...v,[d]:m};return d==="required"&&m===!0&&(g.showOnNode=!0),g});r(y)},f=e==="input"?"input":"output";return s.jsxs("div",{className:"af-node-props-field af-node-props-field--io",children:[s.jsxs("div",{className:"af-node-props-io-head",children:[s.jsx("span",{className:"af-node-props-label",children:t}),s.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-io-add",onClick:l,disabled:i,"aria-label":a("flow:nodeProps.addPinAriaLabel",{label:t}),children:a("flow:nodeProps.addPin")})]}),s.jsx("p",{className:"af-node-props-io-hint",children:a("flow:nodeProps.handleHint",{prefix:f})}),n.length===0?s.jsx("p",{className:"af-node-props-io-empty",children:a(e==="input"?"flow:nodeProps.noInputPins":"flow:nodeProps.noOutputPins")}):null,n.length>0?s.jsxs("div",{className:"af-node-props-io-table",role:"group","aria-label":t,children:[s.jsxs("div",{className:"af-node-props-io-table-head","aria-hidden":!0,children:[s.jsx("span",{children:a("flow:nodeProps.handle")}),s.jsx("span",{children:a("flow:nodeProps.type")}),s.jsx("span",{children:a("flow:nodeProps.name")}),s.jsx("span",{children:a("flow:nodeProps.defaultValue")}),s.jsx("span",{children:a("flow:nodeProps.description")}),s.jsx("span",{children:a("flow:nodeProps.required")}),s.jsx("span",{children:a("flow:nodeProps.showOnNode")}),s.jsx("span",{})]}),n.map((p,d)=>s.jsxs("div",{className:"af-node-props-io-row",children:[s.jsxs("span",{className:"af-node-props-io-handle",title:`${f}-${d}`,children:[f,"-",d]}),s.jsx("select",{className:"af-node-props-input af-node-props-io-cell",value:p.type,onChange:m=>u(d,"type",m.target.value),disabled:i,"aria-label":a("flow:nodeProps.pinTypeAriaLabel",{label:t,index:d}),children:["node","text","file","bool"].map(m=>s.jsx("option",{value:m,children:m},m))}),s.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:p.name,onChange:m=>u(d,"name",m.target.value),disabled:i,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinNameAriaLabel",{label:t,index:d})}),s.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:p.default,onChange:m=>u(d,"default",m.target.value),disabled:i,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDefaultAriaLabel",{label:t,index:d})}),s.jsx("input",{type:"text",className:"af-node-props-input af-node-props-io-cell",value:p.description||"",onChange:m=>u(d,"description",m.target.value),disabled:i,spellCheck:!1,autoComplete:"off","aria-label":a("flow:nodeProps.pinDescriptionAriaLabel",{label:t,index:d})}),s.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.requiredHint"),children:s.jsx("input",{type:"checkbox",checked:!!p.required,onChange:m=>{o||u(d,"required",m.target.checked)},disabled:i||o,"aria-label":a("flow:nodeProps.pinRequiredAriaLabel",{label:t,index:d})})}),s.jsx("label",{className:"af-node-props-io-flag",title:a("flow:nodeProps.showOnNodeHint"),children:s.jsx("input",{type:"checkbox",checked:p.showOnNode!==!1,onChange:m=>u(d,"showOnNode",m.target.checked),disabled:i,"aria-label":a("flow:nodeProps.pinShowOnNodeAriaLabel",{label:t,index:d})})}),s.jsx("button",{type:"button",className:"af-icon-btn af-node-props-io-remove",onClick:()=>c(d),disabled:i,"aria-label":a("flow:nodeProps.deletePinAriaLabel",{label:t,index:d}),title:a("flow:nodeProps.deletePin"),children:s.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},`${f}-${d}`))]}):null]})}function YG({draft:e,setDraft:t,definitionId:n,systemPromptReadonly:r,modelLists:i,disabled:o,onIdBlur:a,onClose:l,onPublishToMarketplace:c,allowEditRequiredPins:u=!1,error:f,ioSlots:p}){const{t:d}=zr(),[m,y]=h.useState(!1),[v,b]=h.useState(!1),[g,k]=h.useState({status:"idle",message:""}),x=h.useCallback(L=>{t($=>$&&{...$,...L})},[t]),{cursorList:_,opencodeList:j,claudeCodeList:N,codexList:P,currentNotInLists:T}=h.useMemo(()=>{const L=Array.isArray(i==null?void 0:i.cursor)?i.cursor:[],$=Array.isArray(i==null?void 0:i.opencode)?i.opencode:[],V=Array.isArray(i==null?void 0:i.claudeCode)?i.claudeCode:[],W=Array.isArray(i==null?void 0:i.codex)?i.codex:[],F=new Set([...L,...$,...V,...W].map(td)),M=((e==null?void 0:e.model)??"").trim(),H=M.startsWith("cursor:")?M.slice(7):M.startsWith("opencode:")?M.slice(9):M.startsWith("codex:")?M.slice(6):M.startsWith("claude-code:")?M.slice(12):M,A=M&&!F.has(H)?M:"";return{cursorList:L,opencodeList:$,claudeCodeList:V,codexList:W,currentNotInLists:A}},[i,e==null?void 0:e.model]);if(!e)return null;const z=String(e.script??""),E=n==="tool_nodejs"||z.trim()!=="",O=typeof c=="function"&&!o&&(e==null?void 0:e.newId),D=async()=>{if(O){k({status:"running",message:d("flow:nodeProps.publishRunning")});try{const L=await c(e,n);k({status:"success",message:L!=null&&L.definitionId?d("flow:nodeProps.publishSuccessWithId",{id:L.definitionId}):d("flow:nodeProps.publishSuccess")})}catch(L){k({status:"error",message:String((L==null?void 0:L.message)||L)})}}};return s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"af-pipeline-drawer-head af-node-props-head",children:[s.jsx("h2",{className:"af-pipeline-drawer-title",children:d("flow:nodeProps.title")}),s.jsxs("div",{className:"af-node-props-head-actions",children:[s.jsxs("button",{type:"button",className:"af-btn-ghost af-node-props-market-btn",onClick:D,disabled:!O||g.status==="running",title:d("flow:nodeProps.publishToMarketplaceHint"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"inventory_2"}),g.status==="running"?d("flow:nodeProps.publishing"):d("flow:nodeProps.publishToMarketplace")]}),s.jsx("button",{type:"button",className:"af-btn-ghost af-node-props-close-secondary",onClick:l,children:d("common:common.close")})]})]}),s.jsxs("div",{className:"af-pipeline-drawer-body af-node-props-body",children:[f?s.jsx("p",{className:"af-err af-node-props-err",children:f}):null,g.message?s.jsx("p",{className:`af-node-props-market-status af-node-props-market-status--${g.status}`,children:g.message}):null,s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsx("span",{className:"af-node-props-label",children:d("flow:node.nodeType")}),s.jsx("div",{className:"af-pipeline-drawer-readonly af-node-props-readonly-mono",children:n})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsxs("span",{className:"af-node-props-label",children:[d("flow:nodeProps.instanceId"),s.jsx("span",{className:"af-node-props-hint",children:d("flow:node.displayNameHint")})]}),s.jsx("input",{type:"text",className:"af-node-props-input",value:e.newId,onChange:L=>x({newId:L.target.value}),onBlur:a,disabled:o,spellCheck:!1,autoComplete:"off","aria-label":d("flow:nodeProps.instanceId")})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.displayName"),"(LABEL)"]}),s.jsx("input",{type:"text",className:"af-node-props-input",value:e.label,onChange:L=>x({label:L.target.value}),disabled:o,spellCheck:!1})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.role"),"(ROLE)"]}),s.jsx("select",{className:"af-node-props-select",value:gf.includes(e.role)?e.role:d("flow:roles.normal"),onChange:L=>x({role:L.target.value}),disabled:o,children:gf.map(L=>s.jsx("option",{value:L,children:L},L))})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.model"),"(MODEL)"]}),s.jsx("span",{className:"af-node-props-sublabel",children:d("flow:node.modelHint")}),s.jsxs("select",{className:"af-node-props-select",value:(()=>{const L=(e.model||"").trim();return L?T||L:""})(),onChange:L=>x({model:L.target.value}),disabled:o,"aria-label":d("flow:nodeProps.modelAriaLabel"),children:[s.jsx("option",{value:"",children:d("flow:node.defaultModel")}),T?s.jsxs("option",{value:T,children:[T,d("flow:nodeProps.yamlValueNotInList")]}):null,_.length>0?s.jsx("optgroup",{label:"Cursor",children:_.map(L=>s.jsx("option",{value:td(L),children:L},`c-${L}`))}):null,j.length>0?s.jsx("optgroup",{label:"OpenCode",children:j.map(L=>s.jsx("option",{value:`opencode:${td(L)}`,children:L},`o-${L}`))}):null,P.length>0?s.jsx("optgroup",{label:"Codex",children:P.map(L=>s.jsx("option",{value:`codex:${td(L)}`,children:L},`codex-${L}`))}):null,N.length>0?s.jsx("optgroup",{label:"Claude Code",children:N.map(L=>s.jsx("option",{value:`claude-code:${td(L)}`,children:L},`cc-${L}`))}):null]})]}),s.jsx(Y1,{kind:"input",label:d("flow:nodeProps.inputPins"),slots:Array.isArray(e.inputs)?e.inputs:[],onSlotsChange:L=>x({inputs:L}),disabled:o,requiredReadonly:!u}),s.jsx(Y1,{kind:"output",label:d("flow:nodeProps.outputPins"),slots:Array.isArray(e.outputs)?e.outputs:[],onSlotsChange:L=>x({outputs:L}),disabled:o,requiredReadonly:!u}),E?s.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[s.jsxs("div",{className:"af-node-props-prompt-head",children:[s.jsxs("span",{className:"af-node-props-label",children:[d("flow:node.directCommand"),"(script)",s.jsx("span",{className:"af-node-props-hint",children:d("flow:node.scriptHint")})]}),s.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>b(!0),"aria-label":d("flow:nodeProps.expandEditScript"),title:d("flow:nodeProps.expand"),disabled:o,children:s.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),s.jsx(ih,{value:z,onChange:L=>x({script:L}),disabled:o,placeholder:d("flow:nodeProps.scriptPlaceholder"),rows:6,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea af-node-props-script-textarea",ioSlots:p,variant:"drawer"})]}):null,s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsx("span",{className:"af-node-props-label",children:"Script file(scriptRef)"}),s.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/script.mjs"]}),s.jsx("input",{type:"text",className:"af-node-props-input",value:e.scriptRef||"",onChange:L=>x({scriptRef:L.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsx("span",{className:"af-node-props-label",children:"Implementation file(implementationRef)"}),s.jsxs("span",{className:"af-node-props-sublabel",children:["Relative path under this flow, for example nodes/",e.id,"/implementation.md"]}),s.jsx("input",{type:"text",className:"af-node-props-input",value:e.implementationRef||"",onChange:L=>x({implementationRef:L.target.value}),disabled:o,spellCheck:!1,autoComplete:"off"})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsx("span",{className:"af-node-props-label",children:"Implementation mode"}),s.jsxs("select",{className:"af-node-props-select",value:e.implementationMode||"",onChange:L=>x({implementationMode:L.target.value}),disabled:o,children:[s.jsx("option",{value:"",children:"auto"}),s.jsx("option",{value:"script",children:"script"}),s.jsx("option",{value:"steps",children:"steps"}),s.jsx("option",{value:"hybrid",children:"hybrid"})]})]}),s.jsxs("div",{className:"af-pipeline-drawer-field af-node-props-field af-node-props-field--prompt",children:[s.jsxs("div",{className:"af-node-props-prompt-head",children:[s.jsx("span",{className:"af-node-props-label",children:d("flow:node.userPrompt")}),s.jsx("button",{type:"button",className:"af-icon-btn af-node-props-expand",onClick:()=>y(!0),"aria-label":d("flow:nodeProps.expandEdit"),title:d("flow:nodeProps.expand"),disabled:o,children:s.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})})]}),s.jsx(ih,{value:e.body,onChange:L=>x({body:L}),images:e.images,onImagesChange:L=>x({images:L}),disabled:o,placeholder:d("flow:nodeProps.bodyPlaceholder"),rows:8,textareaClassName:"af-pipeline-drawer-textarea af-node-props-body-textarea",ioSlots:p,variant:"drawer"})]}),s.jsxs("label",{className:"af-pipeline-drawer-field af-node-props-field",children:[s.jsx("span",{className:"af-node-props-label",children:d("flow:node.systemDescription")}),s.jsx("textarea",{className:"af-pipeline-drawer-textarea af-node-props-system-readonly",rows:4,readOnly:!0,value:r||d("flow:nodeProps.noDescription"),spellCheck:!1})]})]}),v?s.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":d("flow:nodeProps.editScript"),onMouseDown:L=>{L.target===L.currentTarget&&b(!1)},children:s.jsxs("div",{className:"af-node-props-expand-panel",children:[s.jsxs("div",{className:"af-node-props-expand-head",children:[s.jsx("span",{className:"af-node-props-expand-title",children:d("flow:node.directCommand")}),s.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>b(!1),"aria-label":d("flow:nodeProps.collapse"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsx(ih,{value:z,onChange:L=>x({script:L}),disabled:o,placeholder:d("flow:nodeProps.scriptPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:p,variant:"expand"})]})}):null,m?s.jsx("div",{className:"af-node-props-expand-overlay",role:"dialog","aria-modal":"true","aria-label":d("flow:nodeProps.editUserPrompt"),onMouseDown:L=>{L.target===L.currentTarget&&y(!1)},children:s.jsxs("div",{className:"af-node-props-expand-panel",children:[s.jsxs("div",{className:"af-node-props-expand-head",children:[s.jsx("span",{className:"af-node-props-expand-title",children:d("flow:node.body")}),s.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>y(!1),"aria-label":d("flow:nodeProps.collapse"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsx(ih,{value:e.body,onChange:L=>x({body:L}),images:e.images,onImagesChange:L=>x({images:L}),disabled:o,placeholder:d("flow:nodeProps.bodyPlaceholderExpand"),rows:16,textareaClassName:"af-node-props-expand-textarea",ioSlots:p,variant:"expand"})]})}):null]})}function JG({open:e,onClose:t,flowId:n,flowSource:r,onArchived:i}){const{t:o}=zr(),a=h.useId(),l=h.useRef(null),[c,u]=h.useState(""),[f,p]=h.useState(!1),[d,m]=h.useState("");if(h.useEffect(()=>{if(!e)return;u(""),m(""),p(!1);const g=requestAnimationFrame(()=>{var k;return(k=l.current)==null?void 0:k.focus()});return()=>cancelAnimationFrame(g)},[e,n]),!e)return null;const y=c.trim(),v=y===n;async function b(g){if(g.preventDefault(),!(!v||f)){p(!0),m("");try{const k=await fetch("/api/flow/archive",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:y})}),x=await k.json().catch(()=>({}));if(!k.ok){m(typeof x.error=="string"?x.error:o("project:archiveModal.archiveFailed"));return}i()}catch(k){m(String((k==null?void 0:k.message)||k))}finally{p(!1)}}}return s.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:g=>{g.target===g.currentTarget&&t()},children:s.jsxs("div",{ref:l,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":a,tabIndex:-1,onMouseDown:g=>g.stopPropagation(),children:[s.jsxs("div",{className:"af-shortcuts-panel__head",children:[s.jsx("h2",{id:a,className:"af-shortcuts-panel__title",children:o("project:archiveModal.title")}),s.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":o("project:archiveModal.close"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:b,children:[s.jsx("p",{className:"af-new-pipeline-lead",children:o("project:archiveModal.lead",{flowId:n})}),s.jsxs("label",{className:"af-new-pipeline-field",children:[s.jsx("span",{className:"af-pipeline-drawer-label",children:o("project:archiveModal.confirmLabel")}),s.jsx("input",{type:"text",className:"af-new-pipeline-input",value:c,onChange:g=>u(g.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":y.length>0&&!v})]}),d?s.jsx("p",{className:"af-err af-new-pipeline-err",children:d}):null,s.jsxs("div",{className:"af-new-pipeline-actions",children:[s.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:f,children:o("project:archiveModal.cancel")}),s.jsx("button",{type:"submit",className:"af-btn-primary",disabled:!v||f,children:o(f?"project:archiveModal.archiving":"project:archiveModal.confirmArchive")})]})]})]})})}function XG({open:e,onClose:t,flowId:n,flowSource:r,flowArchived:i=!1,workspaceId:o="",leaveShared:a=!1,onDeleted:l}){const{t:c}=zr(),u=h.useId(),f=h.useRef(null),[p,d]=h.useState(""),[m,y]=h.useState(!1),[v,b]=h.useState("");if(h.useEffect(()=>{if(!e)return;d(""),b(""),y(!1);const _=requestAnimationFrame(()=>{var j;return(j=f.current)==null?void 0:j.focus()});return()=>cancelAnimationFrame(_)},[e,n]),!e)return null;const g=p.trim(),k=a||g===n;async function x(_){if(_.preventDefault(),!k||m)return;y(!0),b("");let j=null;try{const N=new AbortController;j=setTimeout(()=>N.abort(),15e3);const P=await fetch("/api/flow/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({flowId:n,flowSource:r,confirmFlowId:a?n:g,flowArchived:i,workspaceId:o}),signal:N.signal}),T=await P.json().catch(()=>({}));if(!P.ok){b(typeof T.error=="string"?T.error:c("project:deleteModal.deleteFailed"));return}try{for(let z=localStorage.length-1;z>=0;z--){const E=localStorage.key(z);E&&(E.startsWith(`af:composer-sessions:${n}:${r}`)||E.startsWith(`af:composer-active-session:${n}:${r}`)||E.startsWith(`af:workspace-composer:${n}:${r}`))&&localStorage.removeItem(E)}}catch{}await l()}catch(N){if((N==null?void 0:N.name)==="AbortError"){b(c("project:deleteModal.deleteTimeout"));return}b(String((N==null?void 0:N.message)||N))}finally{j&&clearTimeout(j),y(!1)}}return s.jsx("div",{className:"af-shortcuts-overlay",role:"presentation",onMouseDown:_=>{_.target===_.currentTarget&&t()},children:s.jsxs("div",{ref:f,className:"af-shortcuts-panel af-new-pipeline-panel",role:"dialog","aria-modal":"true","aria-labelledby":u,tabIndex:-1,onMouseDown:_=>_.stopPropagation(),children:[s.jsxs("div",{className:"af-shortcuts-panel__head",children:[s.jsx("h2",{id:u,className:"af-shortcuts-panel__title",children:a?"退出共享 Workspace":c("project:deleteModal.title")}),s.jsx("button",{type:"button",className:"af-shortcuts-panel__close af-icon-btn",onClick:t,"aria-label":c("project:deleteModal.close"),children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("form",{className:"af-shortcuts-panel__body af-new-pipeline-form",onSubmit:x,children:[s.jsx("p",{className:"af-new-pipeline-lead",children:a?`退出后,${n} 将从你的项目列表移除;源项目和其他成员的数据不会被删除。`:c("project:deleteModal.lead",{flowId:n})}),a?null:s.jsxs("label",{className:"af-new-pipeline-field",children:[s.jsx("span",{className:"af-pipeline-drawer-label",children:c("project:deleteModal.confirmLabel")}),s.jsx("input",{type:"text",className:"af-new-pipeline-input",value:p,onChange:_=>d(_.target.value),placeholder:n,autoComplete:"off",spellCheck:!1,"aria-invalid":g.length>0&&!k})]}),v?s.jsx("p",{className:"af-err af-new-pipeline-err",children:v}):null,s.jsxs("div",{className:"af-new-pipeline-actions",children:[s.jsx("button",{type:"button",className:"af-btn-secondary",onClick:t,disabled:m,children:c("project:deleteModal.cancel")}),s.jsx("button",{type:"submit",className:"af-btn-primary af-btn-destructive",disabled:!k||m,children:m?a?"退出中...":c("project:deleteModal.deleting"):a?"确认退出":c("project:deleteModal.confirmDelete")})]})]})]})})}const J1=80,QG=220;function ZG(e){if(!e||typeof e!="object")return e;const{selected:t,dragging:n,resizing:r,className:i,positionAbsolute:o,measured:a,internals:l,...c}=e;return c}function eY(e){if(!e||typeof e!="object")return e;const{selected:t,className:n,...r}=e;return r}function oh(e,t,n){const r={nodes:Array.isArray(e)?e.map(ZG):[],edges:Array.isArray(t)?t.map(eY):[],extra:n&&typeof n=="object"?n:{}},i=JSON.stringify(r);return{value:JSON.parse(i),signature:i}}function Ow(e,t){const n=[...e,t];return n.length>J1?n.slice(n.length-J1):n}function tY({nodes:e,edges:t,extra:n,enabled:r=!0,onRestore:i}){const[o,a]=h.useState(0),l=h.useRef([]),c=h.useRef([]),u=h.useRef(null),f=h.useRef(null),p=h.useRef(null),d=h.useRef(null),m=h.useRef(!1),y=h.useCallback(()=>a(j=>j+1),[]),v=h.useCallback(()=>{d.current&&(window.clearTimeout(d.current),d.current=null)},[]),b=h.useCallback(()=>{v();const j=f.current,N=p.current;return f.current=null,p.current=null,!j||!N||j.signature===N.signature?(N&&(u.current=N),!1):(l.current=Ow(l.current,j),c.current=[],u.current=N,y(),!0)},[y,v]),g=h.useCallback((j=[],N=[],P={})=>{v(),l.current=[],c.current=[],f.current=null,p.current=null,u.current=oh(j,N,P),m.current=!1,y()},[y,v]),k=h.useCallback(j=>{m.current=!0,u.current=j,f.current=null,p.current=null,v(),i==null||i(j.value),y()},[y,v,i]),x=h.useCallback(()=>{b();const j=u.current||oh(e,t,n),N=l.current.pop();return N?(c.current=Ow(c.current,j),k(N),!0):(y(),!1)},[y,t,n,b,e,k]),_=h.useCallback(()=>{b();const j=u.current||oh(e,t,n),N=c.current.pop();return N?(l.current=Ow(l.current,j),k(N),!0):(y(),!1)},[y,t,n,b,e,k]);return h.useEffect(()=>()=>v(),[v]),h.useEffect(()=>{if(!r)return;const j=oh(e,t,n);if(!u.current){u.current=j;return}if(m.current){m.current=!1,u.current=j;return}j.signature!==u.current.signature&&(f.current||(f.current=u.current),p.current=j,v(),d.current=window.setTimeout(()=>{b()},QG))},[v,t,r,n,b,e]),{canUndo:l.current.length>0||!!f.current,canRedo:c.current.length>0,resetHistory:g,undo:x,redo:_,version:o}}function wo(e){return String(e??"").trim()}function X1(e){return e===!0?!0:["true","yes","done","waived","not_required"].includes(wo(e).toLowerCase())}function nY(e){return e===!1?!0:["false","no","not_required","waived"].includes(wo(e).toLowerCase())}function rY(e,t=""){return wo((e==null?void 0:e.key)||(e==null?void 0:e.issueKey)||(e==null?void 0:e.issue_key)||(e==null?void 0:e.id)||t)}function hM(e){return wo((e==null?void 0:e.platform)||"all").toLowerCase()||"all"}function mM(e){return hM(e)==="all"}function sY(e,t=[]){const n=wo((e==null?void 0:e.sourceIssue)||(e==null?void 0:e.source_issue)||(e==null?void 0:e.parentKey)||(e==null?void 0:e.parent_key)||(e==null?void 0:e.parentIssue)||(e==null?void 0:e.parent_issue)||(e==null?void 0:e.parent));if(n)return n;const r=hM(e),i=rY(e);if(!i||!["android","ios"].includes(r))return"";const o=`-${r}`;if(!i.endsWith(o))return"";const a=i.slice(0,-o.length);return new Set(t.map(l=>wo(l))).has(a)?a:""}function Rm(e){const t=wo(e==null?void 0:e.label).toLowerCase(),n=wo((e==null?void 0:e.href)||(e==null?void 0:e.url)).toLowerCase();return/\/merge_requests\/\d+/.test(n)||/\bmr\b|merge request|合并请求|实现 mr|修复 mr|提测 mr|集成 mr/i.test(t)?"mr":/\/issues\/\d+/.test(n)||/gitlab issue/i.test(t)?"issue":"other"}function iY(e=[]){const t={issue:0,mr:1,other:2};return[...e].sort((n,r)=>t[Rm(n)]-t[Rm(r)])}function oY(e){const t=wo((e==null?void 0:e.noMrReason)||(e==null?void 0:e.no_mr_reason)||(e==null?void 0:e.mrWaiverReason)||(e==null?void 0:e.mr_waiver_reason)||(e==null?void 0:e.implementationNotRequiredReason)||(e==null?void 0:e.implementation_not_required_reason));return/user confirmed self-test completion without implementation mr evidence/i.test(t)?"自测确认,无需实现 MR":t}function aY(e,t=[]){if(mM(e))return{kind:"aggregate",label:"双端汇总",detail:"由 Android / iOS 端侧 Issue 承接"};const n=t.map(Rm);if(n.includes("mr"))return{kind:"linked",label:"MR 已关联",detail:""};const r=(e==null?void 0:e.mrRequired)??(e==null?void 0:e.mr_required)??(e==null?void 0:e.requiresMr)??(e==null?void 0:e.requires_mr);return X1(e==null?void 0:e.implementationNotRequired)||X1(e==null?void 0:e.implementation_not_required)||nY(r)?{kind:"not-required",label:oY(e)||"无需实现 MR",detail:""}:n.includes("issue")?{kind:"pending",label:"MR 尚未记录",detail:""}:{kind:"missing-issue",label:"GitLab Issue 未绑定",detail:"端侧执行项应先创建或绑定 GitLab Issue"}}function Fb(e=[]){return e.reduce((t,n)=>t+1+Fb(Array.isArray(n==null?void 0:n.children)?n.children:[]),0)}function Sr(e){return String(e||"").trim()}function Yo(e){return Sr(e).toLowerCase()}function Mm(e){return typeof e=="string"?Yo(e):!e||typeof e!="object"||Array.isArray(e)?"":Yo(e.kind||e.type||e.persistence||e.durability)}function gM(e,t="http://localhost"){const n=Sr(e);if(!n)return"";try{const r=new URL(n,t);return r.origin==="null"?`${r.protocol}//${r.host}${r.pathname}`:`${r.origin}${r.pathname}`}catch{return n.split(/[?#]/)[0]}}function yM(e={}){const t=Sr(e.href||e.url);if(!t)return!1;const n=Yo(e.kind||e.type),r=Yo(e.durability),i=Yo(e.persistence),o=Yo(e.truth||e.stateTruth||e.state_truth),a=Yo(e.authority),l=Mm(e.source)||Mm(e.sourceArtifact||e.source_artifact),c=[e.label,n].map(Sr).join(" "),u=[e.label,e.title,n,i,a,l,t].map(Sr).join(" ");if(r==="temporary"||i==="runtime"&&l&&l!=="ai-doc"||l==="local-draft"||n==="temporary-review"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(u)||/gitlab[-_ ]?(issue|epic|mr)|merge[-_ ]?request|jenkins|tapd|实现\s*mr|修复\s*mr|提测\s*mr|集成\s*mr|安装包|二维码/i.test(c)||/tapd[-_ ]?(baseline|snapshot)|baseline[-_ ]?snapshot|tapd_snapshot|snapshot_v\d+\.md/i.test(`${c} ${t}`))return!1;const d=/ai[-_ ]?doc|方案文档|技术方案|设计文档|代码审查|code[-_ ]?review|文档预览|markdown[-_ ]?review/i.test(c),m=n==="ai-doc"||l==="ai-doc"||a==="ai-doc"||i==="ai-doc"&&d,y=o==="durable_fact"||o==="project_fact"||e.confirmed===!0;return m&&(r==="durable"||m||y)}function wM(e={}){const t=[e.label,e.kind,e.title,e.documentType].map(Sr).join(" ");return/技术方案|tech(?:nical)?[-_ ]?design/i.test(t)?"tech-design":/方案文档|方案已确认|plan(?:[-_ ]?doc)?/i.test(t)?"plan":/代码审查|code[-_ ]?review/i.test(t)?"code-review":/设计文档|design[-_ ]?doc/i.test(t)?"design":"document"}function lY(e={},{issueTitle:t="",requirementTitle:n=""}={}){const r=Sr(e.articleTitle||e.article_title||e.documentTitle||e.document_title||e.docTitle||e.doc_title);return r||(Sr(t)?Sr(t):wM(e)==="tech-design"&&Sr(n)?Sr(n):Sr(e.title||e.label))}function cY(e={},t="http://localhost"){const n=Sr(e.issueKey||e.issue_key||e.issue),r=wM(e);if(n)return`issue:${n}:${r}`;if(r==="tech-design")return"requirement:tech-design";const i=Sr(e.documentPath||e.document_path||e.path);return i?`path:${i.replace(/\\/g,"/").replace(/\/+/g,"/")}`:`url:${gM(e.href||e.url,t)}`}function Q1(e={}){const t=Sr(e.href||e.url),n=Yo(e.kind||e.type),r=Mm(e.source)||Mm(e.sourceArtifact||e.source_artifact),i=Sr(e.label);let o=0;return e.confirmed===!0&&(o+=100),r==="ai-doc"&&(o+=80),n==="ai-doc"&&(o+=70),/^https?:\/\//i.test(t)&&(o+=30),/\/api\/prd-workflow\/review\//.test(t)&&(o+=20),/预览|review/i.test(i)||(o+=10),o}function uY(e,t){const n=Q1(t)>Q1(e)?t:e,r=n===t?e:t;return{...r,...n,title:Z1(e.title)>=Z1(t.title)?e.title:t.title,issueKey:e.issueKey||t.issueKey,platform:e.platform||t.platform,documentPath:n.documentPath||r.documentPath,source:n.source||r.source}}function Z1(e){const t=Sr(e);if(!t)return 0;const n=t.replace(/^Issue\s*\d+\s*/i,"").trim();return/^(方案文档预览|方案文档|技术方案|设计文档|代码审查|Markdown Review|文档预览)$/i.test(n)?10:100+Math.min(t.length,100)}function Dw(e,t){const n=new Map,r=[];for(const i of e){const o=t(i);if(!o){r.push(i);continue}const a=n.get(o);if(a===void 0){n.set(o,r.length),r.push(i);continue}r[a]=uY(r[a],i)}return r}function dY(e=[],t="http://localhost"){const n=(Array.isArray(e)?e:[]).filter(o=>yM(o)),r=Dw(n,o=>gM(o.href||o.url,t)),i=Dw(r,o=>Sr(o.documentPath||o.document_path||o.path).replace(/\\/g,"/").replace(/\/+/g,"/"));return Dw(i,o=>cY(o,t))}function Ot(e){return String(e||"").trim()}function xo(e){return typeof e=="string"?Ot(e).toLowerCase():!e||typeof e!="object"||Array.isArray(e)?"":Ot(e.kind||e.type||e.persistence||e.durability).toLowerCase()}function xc(e){return Ot((e==null?void 0:e.key)||(e==null?void 0:e.artifactKey)||(e==null?void 0:e.artifact_key))}function xM(e){return Ot((e==null?void 0:e.canonicalUrl)||(e==null?void 0:e.canonical_url)||(e==null?void 0:e.reviewUrl)||(e==null?void 0:e.review_url)||(e==null?void 0:e.href)||(e==null?void 0:e.url))}function bM(e){const t=Ot(e);if(!t)return"";try{const n=new URL(t,"http://agentflow.local");return`${n.origin}${n.pathname}`}catch{return t.split(/[?#]/)[0]}}function fY(e){const t=Ot(e);if(!t)return"";try{const n=new URL(t,"http://agentflow.local");return n.hash="",n.searchParams.sort(),n.href}catch{return t.split("#")[0]}}function pY(e={}){if(!e||typeof e!="object"||Array.isArray(e))return"";const t=Ot(e.issueKey||e.issue_key||e.issue),n=Ot(e.action||e.actionId||e.action_id),r=Ot(e.stageKey||e.stage_key||e.stage||e.phase||e.code||n),i=r.toLowerCase(),o=[r,n,e.code,e.type].map(a=>Ot(a).toLowerCase()).filter(Boolean);return t?/^(?:issue-plan|issue-gitlab|implementation|bugfix|integration):/.test(i)?r:o.some(a=>/^code-review(?::|$)/.test(a)||a==="code_review_completed")?`implementation:${t}`:o.some(a=>/plan_draft_local|submit-plan|plan-doc/.test(a)||["plan_mr","plan_approved","issue-plan"].includes(a))?`issue-plan:${t}`:o.some(a=>/gitlab_issue_missing|ensure-gitlab-issue/.test(a)||a==="issue-gitlab")?`issue-gitlab:${t}`:o.some(a=>["fix_mr","bugfix"].includes(a))?`bugfix:${t}`:o.some(a=>["integration_mr","integrated","integration"].includes(a))?`integration:${t}`:o.some(a=>["implementation_mr","implementation_done","implementation_merged","impl_mr","impl_done","impl_merged","runtime_marker","status","implementation"].includes(a))?`implementation:${t}`:r||n:r||n}function hY(e={}){var o,a;if(!e||typeof e!="object"||Array.isArray(e)||Ot(e.type||e.kind).toLowerCase()!=="workflow-report")return!1;const n=!!Ot(e.action||e.actionId||e.action_id||((o=e.actionModel)==null?void 0:o.key)||((a=e.action_model)==null?void 0:a.key)),r=Ot(e.artifactScope||e.artifact_scope||e.scope).toLowerCase()==="global",i=e.aggregateByStage??e.aggregate_by_stage;return!n&&(r||i===!1)}function Xc(e){const t=xc(e);if(/^prd-review:/i.test(t)||Ot((e==null?void 0:e.reviewId)||(e==null?void 0:e.review_id))||/\/api\/prd-workflow\/review\//.test(xM(e)))return!0;const n=Ot((e==null?void 0:e.href)||(e==null?void 0:e.url)||(e==null?void 0:e.shortUrl)||(e==null?void 0:e.short_url)),r=Ot((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),i=Ot(e==null?void 0:e.durability).toLowerCase(),o=xo(e==null?void 0:e.source)||xo((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact));return(r==="review"||r==="temporary-review"||i==="temporary"||i==="durable"||o==="local-draft"||o==="ai-doc")&&/\/r\/[A-Za-z0-9_-]{8,32}(?:[?#]|$)/.test(n)}function eC(e){const t=[e==null?void 0:e.label,e==null?void 0:e.kind,e==null?void 0:e.type,e==null?void 0:e.durability,xo(e==null?void 0:e.source)].map(Ot).join(" ");return/方案文档/.test(t)?50:/临时/.test(t)?40:/Markdown Review/i.test(t)?20:/预览|review/i.test(t)?10:0}function tC(e){const t=[],n=xc(e);if(n&&t.push(`key:${n}`),Xc(e)){const i=bM(xM(e));i&&t.push(`review:${i}`)}const r=fY((e==null?void 0:e.href)||(e==null?void 0:e.url));return r&&t.push(`url:${r}`),t.length||t.push(`link:${Ot(e==null?void 0:e.label)}
|
|
183
|
+
${r}`),t}function mY(e){const t=[],n=new Map;for(const r of e){if(!r)continue;const i=tC(r),o=i.map(m=>n.get(m)).find(m=>m!=null);if(o==null){i.forEach(m=>n.set(m,t.length)),t.push(r);continue}const a=t[o],l=eC(r)>=eC(a)?Ot(r==null?void 0:r.label)||Ot(a==null?void 0:a.label):Ot(a==null?void 0:a.label)||Ot(r==null?void 0:r.label),c=!!xc(a),u=!!xc(r),f=c&&!u?a:r,p=f===a?r:a,d=xc(f)&&!xc(p)&&Ot(f==null?void 0:f.label)||l;t[o]={...p,...f,...d?{label:d}:{}},tC(t[o]).forEach(m=>n.set(m,o))}return t}function kM(e){const t=Ot((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Ot(e==null?void 0:e.durability).toLowerCase(),r=Ot(e==null?void 0:e.persistence).toLowerCase(),i=xo(e==null?void 0:e.source)||xo((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,i].map(Ot).join(" ");return t==="temporary-review"||n==="temporary"||i==="local-draft"||/临时\s*(markdown)?\s*(预览|review)|local[-_ ]?draft/i.test(o)}function gY(e){if(!Xc(e)||kM(e))return!1;const t=Ot((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Ot(e==null?void 0:e.durability).toLowerCase(),r=Ot(e==null?void 0:e.persistence).toLowerCase(),i=xo(e==null?void 0:e.source)||xo((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),o=[e==null?void 0:e.label,t,n,r,i].map(Ot).join(" ");return t==="review"||n==="durable"||i==="ai-doc"||r==="ai-doc"||/方案文档预览|durable/i.test(o)}function yY(e){if(Xc(e))return!1;const t=Ot((e==null?void 0:e.kind)||(e==null?void 0:e.type)).toLowerCase(),n=Ot(e==null?void 0:e.persistence).toLowerCase(),r=xo(e==null?void 0:e.source)||xo((e==null?void 0:e.sourceArtifact)||(e==null?void 0:e.source_artifact)),i=[e==null?void 0:e.label,t].map(Ot).join(" ");return t==="ai-doc"||n==="ai-doc"||r==="ai-doc"||/方案文档|技术方案/.test(i)}function wY(e={}){const t=[e.stage,e.stageKey,e.stage_key,e.action,e.id,e.title].map(Ot).join(" ");return/(?:^|[:_-])issue[-_:]?plan(?:$|[:_-])|plan[-_:]?doc|submit[-_:]?plan/i.test(t)||/方案(?:文档)?(?:已确认|预览)/.test(t)}function xY(e=[],t={}){const n=mY(Array.isArray(e)?e:[]);if(!wY(t))return n;const r=n.filter(Xc);if(r.length===0)return n;const i=r.filter(gY),a=i.length>0||n.some(yY)?i.at(-1):r.filter(kM).at(-1);return n.filter(l=>!Xc(l)||l===a)}function Ti(e,t){const n=[],r=new Map,i=a=>{if(typeof a=="string")return[`value:${a}`];if(!a||typeof a!="object")return[];const l=[],c=Ot(a.key||a.artifactKey||a.artifact_key);c&&l.push(`key:${c}`);const u=bM(a.canonicalUrl||a.canonical_url||a.reviewUrl||a.review_url||a.href||a.url);u&&l.push(`url:${u}`);const f=Ot(a.path);return f&&l.push(`path:${f}`),l.length||l.push(`value:${JSON.stringify(a)}`),l},o=a=>{if(!a)return;const l=i(a);if(!l.length)return;const c=l.map(u=>r.get(u)).find(u=>u!=null);if(c==null){const u=n.length;n.push(a),l.forEach(f=>r.set(f,u));return}n[c]=a,i(a).forEach(u=>r.set(u,c))};return(Array.isArray(e)?e:[]).forEach(o),(Array.isArray(t)?t:[]).forEach(o),n}function ns(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function $m(e){return Array.isArray(e)?e.map($m):ns(e)?Object.fromEntries(Object.keys(e).sort().map(t=>[t,$m(e[t])])):e}function co(e,t){return JSON.stringify($m(e))===JSON.stringify($m(t))}function vM(e){return ns(e==null?void 0:e.instances)?e.instances:{}}function wf(e){return ns(e==null?void 0:e.ui)?e.ui:{}}function ah(e,t){if(!ns(e))return{};const n=new Set(t);return Object.fromEntries(Object.entries(e).filter(([r])=>!n.has(r)))}function bY(e,t){if(!ns(e)||!ns(t)||!ns(e.instances)||!ns(t.instances)||!Array.isArray(e.edges)||!Array.isArray(t.edges)||!ns(e.ui)||!ns(t.ui)||Number(e.version||1)!==Number(t.version||1))return!1;const n=ah(e,["version","instances","edges","ui"]),r=ah(t,["version","instances","edges","ui"]);if(!co(n,r))return!1;const i=["nodePositions","nodeSizes","groups","displayPage","viewport"];return co(ah(e.ui,i),ah(t.ui,i))}function SM(e){const t=Array.isArray(wf(e).groups)?wf(e).groups:[];return new Map(t.filter(n=>n==null?void 0:n.id).map(n=>[String(n.id),n]))}function nC(e){const t=new Set(Object.keys(vM(e)));for(const n of Array.isArray(e==null?void 0:e.edges)?e.edges:[])n!=null&&n.source&&t.add(String(n.source)),n!=null&&n.target&&t.add(String(n.target));for(const n of SM(e).keys())t.add(n);return t}function rC(e,t){const n=vM(e),r=wf(e),i=SM(e);return{instance:Object.prototype.hasOwnProperty.call(n,t)?n[t]:null,position:ns(r.nodePositions)&&Object.prototype.hasOwnProperty.call(r.nodePositions,t)?r.nodePositions[t]:null,size:ns(r.nodeSizes)&&Object.prototype.hasOwnProperty.call(r.nodeSizes,t)?r.nodeSizes[t]:null,group:i.get(t)||null}}function sC(e){return(Array.isArray(e==null?void 0:e.edges)?e.edges:[]).map(t=>({...t})).sort((t,n)=>{const r=[t.source,t.target,t.sourceHandle,t.targetHandle,t.id].map(o=>String(o??"")).join("\0"),i=[n.source,n.target,n.sourceHandle,n.targetHandle,n.id].map(o=>String(o??"")).join("\0");return r.localeCompare(i)})}function kY(e,t){if(!bY(e,t))return{safe:!1,changedNodeIds:[],nodesChanged:!0,edgesChanged:!0,displayPageChanged:!0};const n=new Set([...nC(e),...nC(t)]),r=Array.from(n).filter(i=>!co(rC(e,i),rC(t,i)));return{safe:!0,changedNodeIds:r,nodesChanged:r.length>0,edgesChanged:!co(sC(e),sC(t)),displayPageChanged:!co(wf(e).displayPage||null,wf(t).displayPage||null)}}function vY(e,t,n){const r=new Map((Array.isArray(e)?e:[]).map(o=>[o.id,o])),i=new Set(Array.isArray(n)?n:[]);return(Array.isArray(t)?t:[]).map(o=>{const a=r.get(o.id);return a&&!i.has(o.id)?a:a?{...o,selected:a.selected===!0}:o})}function iC(e){return[e==null?void 0:e.source,e==null?void 0:e.target,e==null?void 0:e.sourceHandle,e==null?void 0:e.targetHandle].map(t=>String(t??"")).join("\0")}function oC(e){if(!e||typeof e!="object")return e;const t={...e};return delete t.selected,t}function SY(e,t){const n=new Map((Array.isArray(e)?e:[]).map(r=>[iC(r),r]));return(Array.isArray(t)?t:[]).map(r=>{const i=n.get(iC(r));return i?co(oC(i),oC(r))?i:{...r,selected:i.selected===!0}:r})}function jY(e,t,n){const r=ns(e)?e:{},i=ns(t)?t:{},o=new Set(Array.isArray(n)?n:[]);return Object.fromEntries(Object.entries(i).map(([a,l])=>[a,!o.has(a)&&Object.prototype.hasOwnProperty.call(r,a)?r[a]:l]))}function NY({background:e=!1,requestId:t=0,currentRequestId:n=0,dirty:r=!1,startedEditVersion:i=0,currentEditVersion:o=0,startedRevision:a="",currentRevision:l=""}={}){return t!==n?"superseded":e&&(r||o!==i||l!==a)?"local-edits":""}function _Y({savedGraph:e,sentGraph:t,savedRevision:n="",currentRevision:r=""}={}){return{graph:e||t||null,revision:String(n||r||"")}}function jM(e=[]){let t=!1,n=!1,r=!1;for(const i of Array.isArray(e)?e:[]){if((i==null?void 0:i.type)==="position"&&i.position){r=!0,i.dragging===!0&&(t=!0),i.dragging===!1&&(n=!0);continue}if((i==null?void 0:i.type)==="dimensions"&&i.dimensions){r=!0,i.resizing===!0&&(t=!0),i.resizing===!1&&(n=!0);continue}["add","remove","replace"].includes(i==null?void 0:i.type)&&(r=!0)}return{active:t,finished:n,mutated:r}}function CY({nodeInteraction:e=!1,pointerCount:t=0,viewportInteraction:n=!1}={}){return!!(e||n||Number(t)>0)}function AY(e=[]){const t=jM(e);return t.mutated&&!t.active}function EY(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!0||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!0)}function IY(e){return!!((e==null?void 0:e.type)==="position"&&e.position&&e.dragging===!1||(e==null?void 0:e.type)==="dimensions"&&e.dimensions&&e.resizing===!1)}function PY(e=[]){const t=[],n=[];let r=!1;for(const i of Array.isArray(e)?e:[]){if(EY(i)){t.push(i);continue}n.push(i),IY(i)&&(r=!0)}return{transient:t,committed:n,finishesInteraction:r}}function zb(e=[]){const t=[],n=new Map;for(const r of Array.isArray(e)?e:[]){const i=String((r==null?void 0:r.id)||"").trim();if(!(i&&((r==null?void 0:r.type)==="position"||(r==null?void 0:r.type)==="dimensions"))){t.push(r);continue}const a=`${r.type}:${i}`,l=n.get(a);l==null?(n.set(a,t.length),t.push(r)):t[l]=r}return t}function TY(e=[]){return zb(e).map(t=>(t==null?void 0:t.type)==="position"&&t.position&&t.dragging===!0?{...t,dragging:!1}:(t==null?void 0:t.type)==="dimensions"&&t.dimensions&&t.resizing===!0?{...t,resizing:!1}:t)}function aC(e,t){return{...t,waiters:[...Array.isArray(e==null?void 0:e.waiters)?e.waiters:[],...Array.isArray(t==null?void 0:t.waiters)?t.waiters:[]]}}function RY({background:e=!1}={}){return{graph:!0,nodes:!e,files:!e}}function MY({eventType:e="",revision:t="",currentRevision:n="",targetRevision:r="",refreshPending:i=!1}={}){return e!=="graph.committed"||!t?!1:t===n?!0:t===r&&i}const $Y=h.lazy(()=>vP(()=>import("./WorkflowAssistantThread-ubxHcM7p.js"),[])),LY="af:workspace-graph:v2",lC="agentflow.workspace.sidebarCollapsed",tc=["DISPLAY","CONTROL","TOOL","PROVIDE","AGENT"],OY=new Set(["control_start","control_end","control_load_skills","control_load_mcp","control_cd_workspace","control_user_workspace"]),DY={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:""}]},FY={id:"workspace_scheduled_run",displayName:"Scheduled Run",label:"Scheduled Run",description:"Run the downstream workspace subgraph on a schedule.",type:"control",inputs:[{type:"node",name:"prev",default:""}],outputs:[{type:"node",name:"next",default:""}]},zY={id:"control_load_skills",displayName:"Load Skills",label:"Load Skills",description:"Load the currently selected Workspace skill collection for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"skillsContext",default:"",showOnNode:!0}]},BY={id:"control_load_mcp",displayName:"Load MCP",label:"Load MCP",description:"Load selected Cursor MCP server tool manifests for downstream agent nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"serverNames",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"mcpContext",default:"",showOnNode:!0}]},WY={id:"control_cd_workspace",displayName:"加载知识库",label:"加载知识库",description:"Select one or more knowledge sources and pass knowledgeContext to downstream nodes.",type:"control",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"path",default:"",showOnNode:!1},{type:"text",name:"label",default:"",showOnNode:!1},{type:"text",name:"knowledgeContext",default:"",showOnNode:!1},{type:"text",name:"workspaceContext",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"knowledgeContext",default:"",showOnNode:!0},{type:"text",name:"workspaceContext",default:"",showOnNode:!1},{type:"file",name:"cwd",default:"",showOnNode:!1}]},HY={id:"workspace_one_click_task",displayName:"一键任务",label:"一键任务",description:"输入任务,选择 Skills、workspace 上下文和输出类型后直接运行。",type:"agent",inputs:[{type:"node",name:"prev",default:""},{type:"text",name:"skillKeys",default:"",showOnNode:!1},{type:"bool",name:"includeWorkspaceContext",default:"true",showOnNode:!1},{type:"text",name:"displayType",default:"markdown",showOnNode:!1},{type:"text",name:"knowledgeContext",default:"",showOnNode:!1},{type:"text",name:"workspaceContext",default:"",showOnNode:!1}],outputs:[{type:"node",name:"next",default:""},{type:"text",name:"content",default:"",showOnNode:!0},{type:"text",name:"displayType",default:"markdown",showOnNode:!1}]},VY=new Set(["png","jpg","jpeg","gif","webp","svg"]),NM=320,_M=180,CM=960,Lm=96,AM=900,Bb=520,Wb=320,lh=52,fl=240,pl=160,Hb="display-ref:",xf="0 9 * * *",KY="Asia/Shanghai",qY="0.1.141";function UY(){const e=new URLSearchParams(window.location.search),t=String(e.get("returnTo")||"").trim();return{flowId:e.get("flowId")||"",flowSource:e.get("flowSource")||"user",workspaceId:e.get("workspaceId")||"",workflowShare:e.get("workflowShare")||"",adminOwnerId:e.get("adminOwnerId")||"",archived:e.get("archived")==="1"||e.get("flowArchived")==="1",returnTo:t==="/workflows"?t:"",workflowDemo:e.get("workflowDemo")==="1"}}function $r(e){const t=new URLSearchParams;return e.flowId&&t.set("flowId",e.flowId),e.flowSource&&t.set("flowSource",e.flowSource),e.workspaceId&&t.set("workspaceId",e.workspaceId),e.workflowShare&&t.set("workflowShare",e.workflowShare),e.adminOwnerId&&t.set("adminOwnerId",e.adminOwnerId),e.archived&&t.set("archived","1"),e.returnTo&&t.set("returnTo",e.returnTo),e.workflowDemo&&t.set("workflowDemo","1"),t}function Bo(e={}){return[e.workspaceId||"",e.flowSource||"user",e.flowId||""].join(" ")}function GY(e){const t=String(e||"").trim();if(!t)return null;try{const n=JSON.parse(window.sessionStorage.getItem(`agentflow.workflow.demo:${t}`)||"null");return n&&typeof n=="object"&&!Array.isArray(n)?n:null}catch{return null}}function Hv(e,t=4e3){const n=String(e??"").trim();return n?n.length>t?`${n.slice(0,t)}
|
|
184
|
+
...[truncated ${n.length-t} chars]`:n:""}function YY(e){const t=Hv(e==null?void 0:e.text,4e3);return t?{role:(e==null?void 0:e.role)==="user"?"user":"assistant",...e!=null&&e.kind?{kind:String(e.kind)}:{},text:t,...e!=null&&e.error?{error:!0}:{},at:Number.isFinite(Number(e==null?void 0:e.at))?Number(e.at):Date.now()}:null}function Vv(e,t=80){return(Array.isArray(e)?e:[]).map(YY).filter(Boolean).slice(-t)}function JY(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const[r,i]of Object.entries(t).slice(-80)){const o=String(r||"").trim();if(!o||!i||typeof i!="object")continue;const a=Vv(i.messages,40),l=Hv(i.draft||"",2e3);!a.length&&!l||(n[o]={sessionId:String(i.sessionId||`nodechat_${o}`),messages:a,...l?{draft:l}:{},candidateContent:"",running:!1,error:""})}return n}function XY(e){return(Array.isArray(e)?e:[]).map(t=>{const n=String((t==null?void 0:t.id)||"").trim();if(!n)return null;const r=Vv(t==null?void 0:t.messages,80);if(!r.length)return null;const i=String((t==null?void 0:t.status)||"done");return{id:n,label:Hv((t==null?void 0:t.label)||n,120),status:i==="failed"?"failed":"done",messages:r}}).filter(Boolean).slice(-20)}function cC(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n=t.composer&&typeof t.composer=="object"&&!Array.isArray(t.composer)?t.composer:{};return{composer:{activeSessionId:String(n.activeSessionId||"workspace").trim()||"workspace",messages:Vv(n.messages,100),runSessions:XY(n.runSessions)},nodeChats:JY(t.nodeChats)}}function Om(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 VY.has(n)}function bf(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const i=$r(t||{});return i.set("path",r),n.download&&i.set("download","1"),`/api/workspace/file/raw?${i.toString()}`}function QY(e){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=String((e==null?void 0:e.flowSource)||"user").trim()||"user",r=String((e==null?void 0:e.adminOwnerId)||"").trim();return`af:composer-skills:workspace:${t}:${n}${r?`:admin:${r}`:""}${e!=null&&e.archived?":archived":""}`}function ZY(e){const t=String((e==null?void 0:e.username)||(e==null?void 0:e.userId)||"").trim();return t?`${lC}:${t}`:lC}function eJ(e){try{const t=window.localStorage.getItem(e);if(t==="false")return!1;if(t==="true")return!0}catch{}return!0}function uC(e){return!e||typeof e.closest!="function"?!1:!!e.closest("input, textarea, select, [contenteditable='true']")}function tJ(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 nJ(e){return!e||typeof e.closest!="function"?!1:!!e.closest(".af-flow-node__prompt-stack")&&!tJ(e)}function rJ(e){const t=String(e||"").trim();if(!t||sJ(t))return"";if(/^运行完成/.test(t))return"运行完成";if(/^运行暂停/.test(t))return"运行暂停";if(/^运行停止/.test(t))return"运行停止";if(/^思考中/.test(t))return"模型正在思考";if(/^生成回复中/.test(t))return"模型正在生成回复";if(/^Timing\s+(.+?):\s+(\d+)ms/i.test(t)){const n=t.match(/^Timing\s+(.+?):\s+(\d+)ms/i);return`耗时:${(n==null?void 0:n[1])||"step"} ${(n==null?void 0:n[2])||"0"}ms`}if(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i.test(t)){const n=t.match(/^工具\s+(.+?)(?:\s+\((started|completed)\))?$/i),r=String((n==null?void 0:n[1])||"tool").trim(),i=String((n==null?void 0:n[2])||"").toLowerCase();if(r==="thinking")return"模型正在思考";const o=r==="readToolCall"?"读取文件/上下文":r==="grepToolCall"?"搜索代码":r==="editToolCall"?"编辑文件":r;return i==="completed"?`完成:${o}`:`执行:${o}`}return/^\[stderr\]/.test(t)?t:""}function sJ(e){return/^\[stderr\]/.test(e)?/Reading additional input from stdin/i.test(e)||/rmcp::transport::worker/i.test(e)||/Transport channel closed/i.test(e)||/http\/request failed/i.test(e)||/AuthRequiredError/i.test(e)||/No access token was provided/i.test(e)||/api\.githubcopilot\.com/i.test(e):!1}function iJ(e){const t=String(e||"").trim();return t?/^模型/.test(t)?"model":/^(执行|完成|耗时):/.test(t)?"tool":/^运行/.test(t)?"run":/^\[stderr\]/.test(t)?"error":"other":"other"}function Fw(e,t,n,r="Workspace Run"){var c;const i=String(n||"").trim(),o=Array.isArray(e)?e.find(u=>String((u==null?void 0:u.id)||"")===i):null,a=t&&typeof t=="object"?t[i]:null;return String(((c=o==null?void 0:o.data)==null?void 0:c.label)||(a==null?void 0:a.label)||"").trim()||i||r}function zw(e,t,n="Workspace Run"){const r=String(e||"").trim()||n,i=String(t||"").trim();return!i||r===i?r:`${r} (${i})`}function Wa(e){const t=Math.max(0,Number(e)||0);if(t<1e3)return`${t}ms`;if(t<6e4)return`${(t/1e3).toFixed(t<1e4?1:0)}s`;const n=Math.floor(t/6e4),r=Math.round(t%6e4/1e3);return`${n}m${r?`${r}s`:""}`}function dC(e){const t=String(e||"").trim().toLowerCase();return{unselected:"未选择需求",unavailable:"未连接",json_unsupported:"待升级",command_failed:"读取失败",uninitialized:"未初始化",preflight_blocked:"环境阻塞",tech_design_missing:"缺技术方案",tech_design_draft_review:"方案待确认",tech_design_confirmed:"方案已确认",baseline_missing:"缺基线",plan_missing:"缺计划",plan_draft_review:"计划待确认",issue_binding_missing:"待绑定 Issue",ready_for_implementation:"待实现",implementation_ready:"待实现",implementing:"实现中",implementation_in_progress:"实现中",implementation_review:"实现待审",self_test_ready:"待自测",bugfix:"修 Bug",fix_ready:"待修复",fix_in_progress:"修复中",testing:"已提测",done:"完成",blocked:"阻塞",conflict:"冲突",requirement_changed:"需求变更"}[t]||t||"未知"}function oJ(e){const t=String(e||"").trim().toLowerCase();return!t||["unselected","unavailable","json_unsupported","command_failed","uninitialized","preflight_blocked"].includes(t)?-1:/done|complete|closed|finished/.test(t)?3:/bug|fix|testing|test|self_test|submit_test/.test(t)?2:/implement|development|ready_for_implementation|issue_binding|gitlab|mr/.test(t)?1:0}function aJ(e){const t=oJ(e);return["方案确定","开发","Bug 修复","完成"].map((n,r)=>{let i="pending";return t>r?i="done":t===r&&(i=r===3?"done":"current"),{label:n,status:i}})}function lJ(e,t=""){var o,a,l,c;const n=e!=null&&e.globalState&&typeof e.globalState=="object"?e.globalState:{},r=(o=e==null?void 0:e.overall)!=null&&o.requirement&&typeof e.overall.requirement=="object"?e.overall.requirement:{};return String(n.title||r.title||r.name||((a=e==null?void 0:e.prd)==null?void 0:a.title)||((c=(l=e==null?void 0:e.raw)==null?void 0:l.prd)==null?void 0:c.title)||"").trim()||(t?`TAPD ${t}`:"选择 TAPD 需求后读取状态")}function kf(e){const t=String(e||"").trim();if(!t)return"";if(t.startsWith("/")&&!t.startsWith("//")||t.startsWith("#"))return t;if(!/^https?:\/\//i.test(t))return"";try{const n=new URL(t);if(n.hostname==="0.0.0.0"||n.hostname==="::"||n.hostname==="[::]"){const i=window.location.hostname;n.hostname=i&&i!=="0.0.0.0"&&i!=="::"?i:"127.0.0.1"}const r=String(new URLSearchParams(window.location.search).get("workflowShare")||"").trim();return r&&n.pathname.startsWith("/api/prd-workflow/review/")&&!n.searchParams.has("workflowShare")&&n.searchParams.set("workflowShare",r),n.href}catch{return t}}function Rc(e){const t=String((e==null?void 0:e.url)||(e==null?void 0:e.href)||"").trim();if(t)return kf(t);const n=String((e==null?void 0:e.path)||"").trim();return n&&/^https?:\/\//i.test(n)?kf(n):""}function ja(e){const t=String(e||"").trim().toLowerCase();return["done","success","completed","passed"].includes(t)?"done":["current","running","active","next"].includes(t)?"current":["observed","observation"].includes(t)?"observed":["superseded","stale","replaced"].includes(t)?"superseded":["blocked","failed","error","conflict"].includes(t)?"blocked":"pending"}function ha(e){if(!e||typeof e!="object")return"";const t=String(e.truth||e.stateTruth||e.state_truth||"").trim().toLowerCase();return t||(String(e.idempotencyKey||e.idempotency_key||"").trim().startsWith("snapshot-action:")||String(e.source||"")==="prd-flow-client"&&String(e.type||"")==="workflow-action"?"observation":String(e.type||"")==="review-link"?"runtime_event":"")}function Kv(e){return ja(e==null?void 0:e.status)==="done"&&ha(e)!=="observation"}function uo(e,t){return!e||typeof e!="object"?`Action ${t+1}`:String(e.title||e.label||e.name||e.actionLabel||e.action_label||e.id||e.action||`Action ${t+1}`)}function Wh(e){return!e||typeof e!="object"?"":String(e.detail||e.description||e.summary||e.message||e.reason||"")}function qv(e){return!e||typeof e!="object"?"":[e.code,e.action,e.actionId,e.action_id,e.stage,e.stageKey,e.stage_key,e.type,e.title].map(t=>String(t||"")).join(" ").toLowerCase()}function cJ(e,t="当前任务"){const r=[e==null?void 0:e.issueLabel,e==null?void 0:e.issue_label,e==null?void 0:e.title,e==null?void 0:e.label,e==null?void 0:e.name].map(i=>String(i||"")).join(" ").match(/\b(Issue\d+|Bug\d+)\b/i);return r?r[1].replace(/^issue/i,"Issue").replace(/^bug/i,"Bug"):t}function uJ(e,t){const n=uo(e,t),r=ja(e==null?void 0:e.status),i=Kv(e),a=`${hl(e)} ${qv(e)}`,l=cJ(e);if(/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(a)){if(i)return`${l} 方案已确认`;if(r==="observed"||r==="superseded"||ha(e)==="observation")return`${l} 方案状态已观察`;if(r==="current"&&/^确认\s+/.test(n))return n}if(/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(a)){if(i)return`已为 ${l} 创建/绑定 GitLab Issue`;if(r==="observed"||r==="superseded"||ha(e)==="observation")return`${l} GitLab Issue 状态已观察`}return/implementation_in_progress|impl_in_progress/.test(a)?`正在实现 ${l}`:/implementation_ready/.test(a)?`可以开始实现 ${l}`:n}function dJ(e){if(!e||typeof e!="object")return"";const t=ja(e.status),n=ha(e),r=Kv(e),o=`${hl(e)} ${qv(e)}`,a=Uv(e),l=a.some(p=>/方案|plan|markdown|review|预览/i.test(String(p.label||""))),c=a.some(p=>/gitlab issue/i.test(String(p.label||""))),u=a.some(p=>/gitlab epic/i.test(String(p.label||"")));if(/issue-plan:|plan_draft_local|submit-plan|plan-doc|plan_doc_confirmed/.test(o))return r?l?"方案已确认并归档;可从下方打开方案文档预览。":"方案已确认并归档。":n==="observation"||t==="observed"?"客户端上报了当前方案阶段;这不是 ai-doc 确认结果。":t==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":t==="current"?"方案草稿已生成,等待确认;确认后会归档为正式方案。":"方案草稿已生成,等待确认。";if(/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue/.test(o))return r?c&&u?"GitLab Issue 和 Epic 已绑定;可从下方打开关联链接。":c?"GitLab Issue 已绑定;可从下方打开关联链接。":"GitLab Issue 绑定步骤已完成。":n==="observation"||t==="observed"?"客户端上报了 GitLab Issue 阶段;是否已绑定以 GitLab/ai-doc 事实为准。":t==="superseded"?"该客户端观察已被更新状态替代,仅保留为运行态记录。":"方案文档已归档,等待创建或绑定 GitLab Issue。";if(/implementation_in_progress|impl_in_progress/.test(o))return"需求分支已就绪,当前处于实现中;实现 MR 创建后会记录到本 Issue。";if(/implementation_ready/.test(o))return"方案文档和 GitLab Issue 已就绪,等待开始实现。";const f=Wh(e);return f?f.length>180&&a.length?"相关结果和产物已更新;可从下方链接查看。":f:""}function Dm(e){return!e||typeof e!="object"?"":String(e.stageEnteredAt||e.stage_entered_at||e.time||e.at||e.observedAt||e.observed_at||e.reportedAt||e.reported_at||e.startedAt||e.started_at||e.completedAt||e.completed_at||e.updatedAt||e.updated_at||e.createdAt||e.created_at||"")}const EM="Asia/Shanghai",fJ=new Intl.DateTimeFormat("zh-CN",{timeZone:EM,year:"numeric",month:"2-digit",day:"2-digit"}),pJ=new Intl.DateTimeFormat("zh-CN",{timeZone:EM,hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1});function IM(e){const t=Dm(e);if(!t)return null;const n=Date.parse(t);return Number.isFinite(n)?new Date(n):null}function hJ(e){const t=IM(e);return t?fJ.format(t).replace(/\//g,"-"):"无时间"}function mJ(e){const t=IM(e);return t?pJ.format(t):""}function gJ(e=[]){const t=[];return(Array.isArray(e)?e:[]).forEach((n,r)=>{const i=hJ(n);let o=t[t.length-1];(!o||o.day!==i)&&(o={day:i,items:[]},t.push(o)),o.items.push({item:n,index:r})}),t}function PM(e){const t=ja(e);return t==="done"?"完成":t==="current"?"当前":t==="observed"?"已观察":t==="superseded"?"已更新":t==="blocked"?"阻塞":"待处理"}function Jo(e){const t=String(e||"").trim(),n=t.toLowerCase();return n==="android"?"Android":n==="ios"?"iOS":["all","both","cross-platform","cross_platform"].includes(n)?"双端":t}function yJ(e){const t=ja(e==null?void 0:e.status);return ha(e)==="observation"&&t==="done"?"已观察":PM(t)}function TM(e){if(!e||typeof e!="object")return[];const t=[],n=(o,a,l)=>{const c=String(l||"").trim();c&&t.push({key:`${o}:${c}`,type:o,label:String(a||c),value:c})},r=ja(e.status),i=ha(e)==="observation"&&r==="done"?"observed":r;return n("status",PM(i),i),n("issue",e.issueKey||e.issue_key||e.issue,e.issueKey||e.issue_key||e.issue),n("platform",Jo(e.platform),e.platform),t}function wJ(e=[]){const t=new Map;return(Array.isArray(e)?e:[]).forEach(n=>{TM(n).forEach(r=>{const i=t.get(r.key);t.set(r.key,{...r,count:((i==null?void 0:i.count)||0)+1})})}),Array.from(t.values()).sort((n,r)=>{const i={status:0,issue:1,platform:2,source:3,actor:4};return(i[n.type]??9)-(i[r.type]??9)||r.count-n.count||n.label.localeCompare(r.label)})}function xJ(e,t){const n=String(t||"all");return!n||n==="all"?!0:TM(e).some(r=>r.key===n)}function bJ(e){if(!e||typeof e!="object")return[];const t=[],n=(r,i)=>{const o=String(i||"").trim();o&&t.push({label:r,value:o})};return n("Issue",e.issueKey||e.issue_key||e.issue),n("平台",Jo(e.platform)),t}function Uv(e){const t=[],n=(c,u,f={})=>{const p=kf(u);p&&t.push({...f,label:String(c||p).trim()||p,href:p})},r=(c,u="链接",f=0)=>{if(f>3||c==null)return;if(typeof c=="string"){(/^(https?:\/\/|file:\/\/)/i.test(c)||c.startsWith("/"))&&n(u,c);return}if(Array.isArray(c)){c.forEach((d,m)=>r(d,`${u} ${m+1}`,f+1));return}if(typeof c!="object")return;const p=c.label||c.title||c.name||c.kind||c.type||u;n(p,c.url||c.href||c.path||c.file||c.filePath||c.file_path,c);for(const d of["links","urls","artifacts","outputs","output","results","result","files"])c[d]!=null&&r(c[d],d,f+1)},i=Array.isArray(e==null?void 0:e.links)?e.links:[];for(const c of i)typeof c=="string"?n("链接",c):n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"链接",(c==null?void 0:c.url)||(c==null?void 0:c.href),c);for(const c of Array.isArray(e==null?void 0:e.artifacts)?e.artifacts:[])n((c==null?void 0:c.label)||(c==null?void 0:c.title)||(c==null?void 0:c.kind)||"Artifact",Rc(c),c);n("TAPD",(e==null?void 0:e.tapdUrl)||(e==null?void 0:e.tapd_url)),n("ai-doc",(e==null?void 0:e.docUrl)||(e==null?void 0:e.doc_url)||(e==null?void 0:e.aiDocUrl)||(e==null?void 0:e.ai_doc_url)),n("Plan",(e==null?void 0:e.planDocUrl)||(e==null?void 0:e.plan_doc_url)||(e==null?void 0:e.planUrl)||(e==null?void 0:e.plan_url)),n("Issue",(e==null?void 0:e.issueUrl)||(e==null?void 0:e.issue_url)),n("GitLab Issue",(e==null?void 0:e.gitlabIssue)||(e==null?void 0:e.gitlab_issue)),n("GitLab Epic",(e==null?void 0:e.gitlabEpic)||(e==null?void 0:e.gitlab_epic)),n("MR",(e==null?void 0:e.mrUrl)||(e==null?void 0:e.mr_url)||(e==null?void 0:e.mergeRequestUrl)||(e==null?void 0:e.merge_request_url)),n("实现 MR",(e==null?void 0:e.implMr)||(e==null?void 0:e.impl_mr)),n("修复 MR",(e==null?void 0:e.fixMr)||(e==null?void 0:e.fix_mr)),n("提测 MR",(e==null?void 0:e.testMr)||(e==null?void 0:e.test_mr)),n("集成 MR",(e==null?void 0:e.integrationMr)||(e==null?void 0:e.integration_mr)),n("Jenkins",(e==null?void 0:e.jenkinsUrl)||(e==null?void 0:e.jenkins_url)||(e==null?void 0:e.jenkinsBuildUrl)||(e==null?void 0:e.jenkins_build_url)),n("安装包",(e==null?void 0:e.jenkinsPackageUrl)||(e==null?void 0:e.jenkins_package_url)),n("二维码",(e==null?void 0:e.jenkinsQrUrl)||(e==null?void 0:e.jenkins_qr_url)),n("调整",(e==null?void 0:e.editUrl)||(e==null?void 0:e.edit_url)||(e==null?void 0:e.adjustUrl)||(e==null?void 0:e.adjust_url)),n("链接",(e==null?void 0:e.url)||(e==null?void 0:e.href)),r(e==null?void 0:e.urls,"URL"),r(e==null?void 0:e.outputs,"产物"),r(e==null?void 0:e.output,"产物"),r(e==null?void 0:e.results,"结果"),r(e==null?void 0:e.result,"结果"),r(e==null?void 0:e.files,"文件");const o=c=>{const u=String(c||"").trim();try{const f=new URL(u,window.location.origin);return`${f.origin}${f.pathname}`}catch{return u.split(/[?#]/)[0]}},a=c=>{const u=String(c||"");return/方案文档/.test(u)?50:/临时/.test(u)?40:/Markdown Review/i.test(u)?20:/预览|review/i.test(u)?10:0},l=new Map;for(const c of t){const u=Xc(c),f=String(c.key||c.artifactKey||c.artifact_key||"").trim(),p=f?`key:${f}`:u?`review:${o(c.canonicalUrl||c.canonical_url||c.href)}`:`${c.label}
|
|
185
|
+
${c.href}`,d=l.get(p);if(!d){l.set(p,c);continue}if(u){const m=a(d.label),y=a(c.label);(y>m||y===m&&String(c.label||"").length>String(d.label||"").length)&&l.set(p,c)}}return xY(Array.from(l.values()),e)}function kJ(e,t=[]){var l,c,u,f,p;const n=[],r=new Map,i=String(((c=(l=e==null?void 0:e.overall)==null?void 0:l.requirement)==null?void 0:c.title)||((f=(u=e==null?void 0:e.overall)==null?void 0:u.requirement)==null?void 0:f.name)||"").trim();for(const d of Vb(e)){const m=Oi(d),y=String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim();m&&y&&r.set(m,y)}const o=(d,m={})=>{if(!d||typeof d!="object")return;const y=(b,g={})=>{if(!b||typeof b!="object")return;const k=String(m.issueKey||(d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),x=b.source||b.sourceArtifact||b.source_artifact||d.sourceArtifact||d.source_artifact||d.source||m.source||null,_=lY({...b,title:b.title||m.documentTitle||(d==null?void 0:d.title)||"",documentTitle:b.documentTitle||b.document_title||(d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||""},{issueTitle:r.get(k)||"",requirementTitle:i}),j={label:String(b.label||"ai-doc").trim()||"ai-doc",href:String(b.href||b.url||"").trim(),kind:String(b.kind||b.type||d.kind||d.type||"").trim(),title:_,issueKey:k,platform:m.platform||Jo(d.platform),durability:b.durability||d.durability||m.durability||"",persistence:b.persistence||d.persistence||m.persistence||"",truth:b.truth||b.stateTruth||b.state_truth||ha(d)||m.truth||"",authority:b.authority||d.authority||m.authority||"",confirmed:b.confirmed??d.confirmed??m.confirmed,source:x,documentPath:b.documentPath||b.document_path||b.path||g.documentPath||(x==null?void 0:x.path)||(x==null?void 0:x.documentPath)||(x==null?void 0:x.document_path)||""};j.href&&n.push(j)};for(const b of Array.isArray(d==null?void 0:d.artifacts)?d.artifacts:[])!b||typeof b!="object"||y({...b,label:b.label||b.title||b.kind||"ai-doc",href:Rc(b)},{documentPath:b.path});for(const b of Array.isArray(d==null?void 0:d.links)?d.links:[])!b||typeof b!="object"||y({...b,label:b.label||b.title||b.kind||"ai-doc",href:Rc(b)},{documentPath:b.path});const v=Rc(d);v&&y({...d,label:d.label||d.title||d.kind||"ai-doc",href:v},{documentPath:d.path})};o(e);for(const d of Array.isArray(t)?t:[])o(d,{issueKey:String((d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||(d==null?void 0:d.issue)||"").trim(),platform:Jo(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.documentTitle)||(d==null?void 0:d.document_title)||(d==null?void 0:d.title)||"").trim()});for(const d of["actions","workflowActions","workflow_actions","timeline","history","events","runtimeEvents","runtime_events"])for(const m of Array.isArray(e==null?void 0:e[d])?e[d]:[])o(m,{issueKey:String((m==null?void 0:m.issueKey)||(m==null?void 0:m.issue_key)||(m==null?void 0:m.issue)||"").trim(),platform:Jo(m==null?void 0:m.platform),documentTitle:String((m==null?void 0:m.documentTitle)||(m==null?void 0:m.document_title)||(m==null?void 0:m.title)||"").trim()});for(const d of Vb(e))o(d,{issueKey:Oi(d),platform:Jo(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.title)||(d==null?void 0:d.name)||(d==null?void 0:d.summary)||"").trim()});const a=(p=e==null?void 0:e.extensions)!=null&&p["prd-flow"]&&typeof e.extensions["prd-flow"]=="object"?e.extensions["prd-flow"]:{};for(const d of[...Array.isArray(e==null?void 0:e.aiDocs)?e.aiDocs:[],...Array.isArray(e==null?void 0:e.ai_docs)?e.ai_docs:[],...Array.isArray(a.aiDocs)?a.aiDocs:[],...Array.isArray(a.ai_docs)?a.ai_docs:[]])o(d,{issueKey:String((d==null?void 0:d.issueKey)||(d==null?void 0:d.issue_key)||"").trim(),platform:Jo(d==null?void 0:d.platform),documentTitle:String((d==null?void 0:d.title)||(d==null?void 0:d.label)||"").trim()});return dY(n,window.location.origin)}function vJ(e){return!e||typeof e!="object"?{}:{marker:e.marker||e.flag||"",command:e.command||e.nextCommand||e.next_command||"",runtimeOnly:e.runtimeOnly===!0||e.runtime_only===!0,markerOnly:e.markerOnly===!0||e.marker_only===!0,url:e.url||e.href||e.mrUrl||e.mr_url||e.mergeRequestUrl||e.merge_request_url||"",mr:e.mr||e.mrUrl||e.mr_url||e.mergeRequestUrl||e.merge_request_url||"",testEnv:e.testEnv||e.test_environment||"",summary:e.summary||e.detail||e.description||"",links:Array.isArray(e.links)?e.links:[],artifacts:Array.isArray(e.artifacts)?e.artifacts:[],outputs:Array.isArray(e.outputs)?e.outputs:[],results:Array.isArray(e.results)?e.results:[]}}function Oi(e,t=0){return String((e==null?void 0:e.key)||(e==null?void 0:e.issueKey)||(e==null?void 0:e.issue_key)||(e==null?void 0:e.id)||(e==null?void 0:e.iid)||(e==null?void 0:e.title)||`issue-${t+1}`).trim()}function SJ(e,t=0){return String((e==null?void 0:e.title)||(e==null?void 0:e.name)||(e==null?void 0:e.label)||(e==null?void 0:e.summary)||Oi(e,t)||`Issue ${t+1}`).trim()}function jJ(e){return String((e==null?void 0:e.epicKey)||(e==null?void 0:e.epic_key)||(e==null?void 0:e.epic)||(e==null?void 0:e.epicTitle)||(e==null?void 0:e.epic_title)||(e==null?void 0:e.parentEpic)||(e==null?void 0:e.parent_epic)||"未归类").trim()}function NJ(e){return String((e==null?void 0:e.sourceIssue)||(e==null?void 0:e.source_issue)||(e==null?void 0:e.parentKey)||(e==null?void 0:e.parent_key)||(e==null?void 0:e.parent)||(e==null?void 0:e.parentIssue)||(e==null?void 0:e.parent_issue)||"").trim()}function _J(e){const t=Uv(e),n=(i,o)=>{if(Array.isArray(i)){for(const a of i)if(a)if(typeof a=="string")t.push({label:o,href:a});else{const l=a.url||a.href||a.webUrl||a.web_url||a.mrUrl||a.mr_url||a.issueUrl||a.issue_url;l&&t.push({label:a.label||a.title||a.platform||a.kind||o,href:l})}}};n(e==null?void 0:e.mrs,"MR"),n(e==null?void 0:e.mergeRequests,"MR"),n(e==null?void 0:e.merge_requests,"MR"),n(e==null?void 0:e.implMrs,"MR"),n(e==null?void 0:e.impl_mrs,"MR"),n(e==null?void 0:e.platformMrs,"MR"),n(e==null?void 0:e.platform_mrs,"MR");const r=new Set;return t.filter(i=>{const o=String(i.href||"").trim();if(!o)return!1;const a=`${i.label}
|
|
186
|
+
${o}`;return r.has(a)?!1:(r.add(a),!0)})}function CJ(e){const t=Array.isArray(e==null?void 0:e.epics)?e.epics:Array.isArray(e==null?void 0:e.epicGroups)?e.epicGroups:Array.isArray(e==null?void 0:e.epic_groups)?e.epic_groups:[],n=[],r=new Map,i=(a,l="")=>{const c=String(a||"未归类").trim()||"未归类";return r.has(c)?l&&r.get(c).title===c&&(r.get(c).title=String(l)):r.set(c,{key:c,title:String(l||c),issues:[]}),r.get(c)};for(const a of t){const l=String((a==null?void 0:a.key)||(a==null?void 0:a.id)||(a==null?void 0:a.title)||(a==null?void 0:a.name)||"未归类").trim(),c=i(l,(a==null?void 0:a.title)||(a==null?void 0:a.name)||l),u=Array.isArray(a==null?void 0:a.issues)?a.issues:Array.isArray(a==null?void 0:a.children)?a.children:Array.isArray(a==null?void 0:a.items)?a.items:[];for(const f of u)f&&typeof f=="object"&&c.issues.push({...f,epicKey:l})}for(const a of Array.isArray(e==null?void 0:e.issues)?e.issues:[])a&&typeof a=="object"&&n.push(a);for(const a of n)i(jJ(a)).issues.push(a);const o=a=>{const l=new Map,c=[],u=a.map((f,p)=>Oi(f,p));return a.forEach((f,p)=>{const d=Oi(f,p);l.set(d,{issue:f,children:[]})}),a.forEach((f,p)=>{const d=Oi(f,p),m=NJ(f)||sY(f,u),y=l.get(d);m&&l.has(m)?l.get(m).children.push(y):c.push(y)}),c};return Array.from(r.values()).map(a=>({...a,issues:o(a.issues)}))}function Fm(e){return String((e==null?void 0:e.actionId)||(e==null?void 0:e.action_id)||(e==null?void 0:e.action)||(e==null?void 0:e.id)||"").trim()}function hl(e){return pY(e)}function zm(e){const t=Dm(e)||String((e==null?void 0:e.startedAt)||(e==null?void 0:e.started_at)||(e==null?void 0:e.createdAt)||(e==null?void 0:e.created_at)||(e==null?void 0:e.updatedAt)||(e==null?void 0:e.updated_at)||""),n=Date.parse(t);return Number.isFinite(n)?n:NaN}function Vb(e){var i,o,a,l,c,u,f,p,d,m,y,v;const t=[],n=b=>{b&&typeof b=="object"&&!Array.isArray(b)&&t.push(b)},r=b=>{if(!b||typeof b!="object"||Array.isArray(b))return;const g=Array.isArray(b.issues)?b.issues:Array.isArray(b.children)?b.children:Array.isArray(b.items)?b.items:[];for(const k of g)!k||typeof k!="object"||Array.isArray(k)||(k.issue&&typeof k.issue=="object"?(n(k.issue),Array.isArray(k.children)&&k.children.forEach(x=>n((x==null?void 0:x.issue)||x))):n(k))};return[e==null?void 0:e.issues,(i=e==null?void 0:e.raw)==null?void 0:i.issues,(a=(o=e==null?void 0:e.raw)==null?void 0:o.prd)==null?void 0:a.issues].forEach(b=>{Array.isArray(b)&&b.forEach(n)}),[e==null?void 0:e.epics,e==null?void 0:e.epicGroups,e==null?void 0:e.epic_groups,(l=e==null?void 0:e.raw)==null?void 0:l.epics,(c=e==null?void 0:e.raw)==null?void 0:c.epicGroups,(u=e==null?void 0:e.raw)==null?void 0:u.epic_groups,(p=(f=e==null?void 0:e.raw)==null?void 0:f.prd)==null?void 0:p.epics,(m=(d=e==null?void 0:e.raw)==null?void 0:d.prd)==null?void 0:m.epicGroups,(v=(y=e==null?void 0:e.raw)==null?void 0:y.prd)==null?void 0:v.epic_groups].forEach(b=>{Array.isArray(b)&&b.forEach(r)}),t}function AJ(e,t){const n=String(t||"").trim();return n&&Vb(e).find((r,i)=>Oi(r,i)===n)||null}function EJ(e){var t,n,r,i,o,a,l,c;return String((e==null?void 0:e.gitlabEpic)||(e==null?void 0:e.gitlab_epic)||((t=e==null?void 0:e.prd)==null?void 0:t.gitlabEpic)||((n=e==null?void 0:e.prd)==null?void 0:n.gitlab_epic)||((r=e==null?void 0:e.raw)==null?void 0:r.gitlabEpic)||((i=e==null?void 0:e.raw)==null?void 0:i.gitlab_epic)||((a=(o=e==null?void 0:e.raw)==null?void 0:o.prd)==null?void 0:a.gitlabEpic)||((c=(l=e==null?void 0:e.raw)==null?void 0:l.prd)==null?void 0:c.gitlab_epic)||"").trim()}function IJ(e,t){if(!t||typeof t!="object")return t;const n=String(t.issueKey||t.issue_key||t.issue||"").trim(),r=AJ(e,n),i=String(t.platform||(r==null?void 0:r.platform)||"").trim(),o=i&&!t.platform?{...t,platform:i}:t,a=String((r==null?void 0:r.gitlabIssue)||(r==null?void 0:r.gitlab_issue)||o.gitlabIssue||o.gitlab_issue||"").trim(),l=EJ(e);if(!a&&!l)return o;const c=hl(o),u=`${c} ${qv(o)}`;if(!/issue-gitlab:|gitlab_issue_missing|ensure-gitlab-issue|implementation|impl_|fix_|testing|submit-test|self-test/i.test(u))return o;const p=[];a&&p.push({key:`gitlab-issue:${n}:${(i||"all").toLowerCase()}`,label:"GitLab Issue",kind:"gitlab-issue",durability:"durable",url:a}),l&&p.push({key:"gitlab-epic:requirement",label:"GitLab Epic",kind:"gitlab-epic",durability:"durable",url:l});const d=ja(o.status),m=a&&d==="done"&&/^issue-gitlab:/.test(c)&&/需要.*GitLab Issue/.test(String(o.title||o.label||""));return{...o,...m?{title:String(o.title||o.label||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定"),label:String(o.label||o.title||"GitLab Issue 已绑定").replace(/^需要为/,"已为").replace("创建或绑定","创建/绑定")}:{},artifacts:Ti(o.artifacts,p)}}function fC(e,t){const n=zm(t),r=zm(e),i=Number.isFinite(n)&&(!Number.isFinite(r)||n>=r)?t:e,o=(i==null?void 0:i.status)||(t==null?void 0:t.status)||(e==null?void 0:e.status);return{...e,...t,title:uo(i,0)||uo(t,0)||uo(e,0),detail:Wh(i)||Wh(t)||Wh(e),status:o,links:Ti(e==null?void 0:e.links,t==null?void 0:t.links),artifacts:Ti(e==null?void 0:e.artifacts,t==null?void 0:t.artifacts),outputs:Ti(e==null?void 0:e.outputs,t==null?void 0:t.outputs),results:Ti(e==null?void 0:e.results,t==null?void 0:t.results),events:Ti(e==null?void 0:e.events,t==null?void 0:t.events),createdAt:(e==null?void 0:e.createdAt)||(e==null?void 0:e.created_at)||(t==null?void 0:t.createdAt)||(t==null?void 0:t.created_at),startedAt:(e==null?void 0:e.startedAt)||(e==null?void 0:e.started_at)||(t==null?void 0:t.startedAt)||(t==null?void 0:t.started_at),updatedAt:(i==null?void 0:i.updatedAt)||(i==null?void 0:i.updated_at)||(t==null?void 0:t.updatedAt)||(t==null?void 0:t.updated_at)||(e==null?void 0:e.updatedAt)||(e==null?void 0:e.updated_at)}}function PJ(e,t){const n=[],r=new Map,i=new Map,o=new Map,a=p=>{var d,m;return!!(!p||typeof p!="object"||p.auxiliary===!0||p.auxiliary_event===!0||hY(p)||String(p.type||"")==="review-link"||String(p.type||"")==="action-preview"||p.preview===!0||String(p.type||"")==="same-platform-stage-conflict"&&/\/api\/prd-workflow\/review\//.test(String(((d=p.conflict)==null?void 0:d.previousArtifact)||((m=p.conflict)==null?void 0:m.incomingArtifact)||"")))},l=(p,d)=>({...p,links:Ti(p==null?void 0:p.links,d==null?void 0:d.links),artifacts:Ti(p==null?void 0:p.artifacts,d==null?void 0:d.artifacts),outputs:Ti(p==null?void 0:p.outputs,d==null?void 0:d.outputs),results:Ti(p==null?void 0:p.results,d==null?void 0:d.results)}),c=(p,d)=>{if(!p)return;const m=r.get(p);if(m!=null){n[m]=l(n[m],d);return}o.set(p,l(o.get(p)||{},d))},u=(p,d)=>p&&o.has(p)?l(d,o.get(p)):d,f=p=>{if(Array.isArray(p))for(const d of p){const m=hl(d);if(a(d)){c(m,d);continue}const y=String(d.id||d.eventId||d.event_id||d.actionId||d.action_id||"").trim(),v=m||y,b=v?r.get(v)??i.get(y):null;v&&b!=null?(n[b]=u(m,fC(n[b],d)),m&&r.set(m,b),y&&i.set(y,b)):(v&&r.set(v,n.length),y&&i.set(y,n.length),n.push(u(m,d)))}};if(f(e==null?void 0:e.actions),f(e==null?void 0:e.workflowActions),f(e==null?void 0:e.workflow_actions),f(e==null?void 0:e.timeline),f(e==null?void 0:e.history),f(e==null?void 0:e.events),f(e==null?void 0:e.runtimeEvents),f(e==null?void 0:e.runtime_events),t&&typeof t=="object"){const p=Fm(t),d=hl(t),m=d?r.get(d):p?i.get(p):null,y={...t,status:t.status||"next",kind:"next_action"};m!=null&&(n[m]=fC(n[m],y))}return n.map((p,d)=>({item:p,index:d,ts:zm(p)})).filter(p=>Number.isFinite(p.ts)).sort((p,d)=>d.ts-p.ts||p.index-d.index).map(p=>IJ(e,p.item))}function TJ(e){const t=Array.isArray(e==null?void 0:e.runtimeEvents)?e.runtimeEvents:Array.isArray(e==null?void 0:e.runtime_events)?e.runtime_events:[],n=Array.isArray(e==null?void 0:e.snapshotAudit)?e.snapshotAudit:Array.isArray(e==null?void 0:e.snapshot_audit)?e.snapshot_audit:[];return[...t,...n].filter(i=>i&&typeof i=="object").map((i,o)=>({item:i,index:o,ts:zm(i)})).sort((i,o)=>{const a=Number.isFinite(i.ts),l=Number.isFinite(o.ts);return a&&l?o.ts-i.ts||o.index-i.index:a?-1:l?1:o.index-i.index}).slice(0,8).map(i=>i.item)}function RJ(e,t){const n=String(t||"all");if(n==="all")return!0;const r=[e==null?void 0:e.status,e==null?void 0:e.type,e==null?void 0:e.kind,e==null?void 0:e.title,e==null?void 0:e.detail,e==null?void 0:e.error,JSON.stringify((e==null?void 0:e.links)||[]),JSON.stringify((e==null?void 0:e.artifacts)||[])].join(" ").toLowerCase();return n==="errors"?/error|failed|conflict|blocked|stale|revision|冲突|失败/.test(r):n==="review"?/review|temporary-review|临时/.test(r):n==="external"?/mr|merge request|gitlab|jenkins|package|build|tapd/.test(r):!0}function MJ(e,t){const n=typeof e=="string"?e:String((e==null?void 0:e.text)||""),r=typeof e=="object"?Number(e==null?void 0:e.stepMs):NaN,i=typeof e=="object"?Number(e==null?void 0:e.totalMs):NaN,o=Number.isFinite(r)&&Number.isFinite(i)?`(+${Wa(r)} / 总 ${Wa(i)})`:"";return`${t+1}. ${n}${o}`}function RM(e){if(String((e==null?void 0:e.type)||"")!=="raw")return null;const t=String((e==null?void 0:e.text)||"").trim();if(!t)return null;try{return JSON.parse(t)}catch{return null}}function nc(...e){for(const t of e){const n=Number(t);if(Number.isFinite(n))return n}return NaN}function $J(e){const t=e!=null&&e.tool_call&&typeof e.tool_call=="object"?e.tool_call:{},n=Object.keys(t).find(r=>/ToolCall$/i.test(r))||"";return n||String((e==null?void 0:e.name)||(e==null?void 0:e.tool)||"tool_call")}function LJ(e){const t=e!=null&&e.tool_call&&typeof e.tool_call=="object"?e.tool_call:{},n=Object.keys(t).find(r=>/ToolCall$/i.test(r))||"";return n&&t[n]&&typeof t[n]=="object"?t[n]:{}}function OJ(e,t){var i;const n=String(((i=t==null?void 0:t.args)==null?void 0:i.command)||"");return/ck_fetch\.py/.test(n)?"CK 查询":/collect_important_mails\.py|list_mails_by_date\.py|read_mail_content\.py/.test(n)?"邮件脚本":/npm\s+run\s+build|build:web-ui/.test(n)?"前端构建":/python3/.test(n)?"Python 脚本":{shellToolCall:"Shell 命令",readToolCall:"读取文件/上下文",grepToolCall:"搜索代码",globToolCall:"查找文件",editToolCall:"编辑文件",writeToolCall:"写入文件"}[e]||e||"工具调用"}function DJ(e){var o,a,l;const t=RM(e);if(!t||typeof t!="object")return null;const n=String(t.type||""),r=String(t.subtype||""),i=nc(t.timestamp_ms,t.completedAtMs,t.startedAtMs,e==null?void 0:e.ts,Date.now());if(n==="tool_call"&&r==="completed"){const c=LJ(t),u=$J(t),f=nc(t.startedAtMs,c==null?void 0:c.startedAtMs),p=nc(t.completedAtMs,c==null?void 0:c.completedAtMs),d=((o=c==null?void 0:c.result)==null?void 0:o.success)||((a=c==null?void 0:c.result)==null?void 0:a.failure)||{},m=Number.isFinite(f)&&Number.isFinite(p)?Math.max(0,p-f):nc(d.executionTime,d.localExecutionTimeMs),y=String(((l=c==null?void 0:c.args)==null?void 0:l.command)||d.command||"").trim(),v=y?y.split(`
|
|
187
|
+
`).find(Boolean)||y:"";return{kind:"tool",label:OJ(u,c),durationMs:Number.isFinite(m)?m:null,at:i,detail:v?v.slice(0,90):""}}if(n==="result"){const c=nc(t.duration_ms,t.duration_api_ms);return{kind:"total",label:"运行总耗时",durationMs:Number.isFinite(c)?c:null,at:i,detail:t.is_error?"失败结束":"成功结束"}}return n==="connection"?{kind:"network",label:r==="reconnecting"?"连接重连":r==="reconnected"?"连接恢复":"连接事件",durationMs:null,at:i,detail:""}:n==="retry"?{kind:"network",label:r==="resuming"?"会话恢复":r==="starting"?"开始重试":"重试事件",durationMs:null,at:i,detail:""}:null}function pC(e,t,n,r){const i=(Array.isArray(e)?e:[]).map(b=>typeof b=="string"?{text:b}:b).filter(b=>b&&String(b.text||"").trim()),o=Array.isArray(t)?t:[],a=[...o].reverse().find(b=>(b==null?void 0:b.kind)==="total"&&Number.isFinite(Number(b.durationMs))),l=[...i].reverse().find(b=>Number.isFinite(Number(b.totalMs))),c=Number.isFinite(Number(r))&&Number.isFinite(Number(n))?Math.max(0,Number(r)-Number(n)):NaN,u=nc(a==null?void 0:a.durationMs,l==null?void 0:l.totalMs,c),f=i.filter(b=>b.kind==="model").reduce((b,g)=>b+(Number(g.stepMs)||0),0),p=o.filter(b=>(b==null?void 0:b.kind)==="tool"),d=p.reduce((b,g)=>b+(Number(g.durationMs)||0),0),m=o.filter(b=>(b==null?void 0:b.kind)==="network").length,y=[...i.filter(b=>Number(b.stepMs)>=1e3).map(b=>({label:b.text,durationMs:Number(b.stepMs),detail:"Activity 间隔"})),...p.filter(b=>Number(b.durationMs)>=1e3).map(b=>({label:b.label,durationMs:Number(b.durationMs),detail:b.detail||"工具实际执行"}))].sort((b,g)=>g.durationMs-b.durationMs).slice(0,6),v=["耗时概览"];return Number.isFinite(u)&&v.push(`- 当前总耗时:${Wa(u)}`),f>0&&v.push(`- 模型相关间隔:约 ${Wa(f)}(按 Activity 间隔估算)`),p.length>0&&v.push(`- 工具实际执行:${Wa(d)}(${p.length} 次完成事件)`),m>0&&v.push(`- 网络/会话恢复事件:${m} 次`),y.length>0&&(v.push(""),v.push("慢步骤"),y.forEach((b,g)=>{const k=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}:${Wa(b.durationMs)}${k}`)})),i.length>0&&(v.push(""),v.push("最近 Activity"),i.slice(-10).forEach((b,g)=>{v.push(MJ(b,g))})),p.length>0&&(v.push(""),v.push("最近工具完成"),p.slice(-8).forEach((b,g)=>{const k=Number.isFinite(Number(b.durationMs))?` ${Wa(b.durationMs)}`:"",x=b.detail?` · ${b.detail}`:"";v.push(`${g+1}. ${b.label}${k}${x}`)})),v.join(`
|
|
188
|
+
`)}function hC(e){if(String((e==null?void 0:e.type)||"")!=="raw"||String((e==null?void 0:e.eventType)||"")!=="thinking")return"";const t=RM(e);if((t==null?void 0:t.type)!=="thinking")return"";const n=String((t==null?void 0:t.subtype)||"");return n&&n!=="delta"?"":String((t==null?void 0:t.text)||(t==null?void 0:t.delta)||(t==null?void 0:t.thinking)||"").trim()}function MM(e,t){const n=String(e||(t==null?void 0:t.id)||"").toLowerCase();return n.startsWith("control_")?"control":n.startsWith("provide_")?"provide":n.startsWith("tool_")?"agent":(t==null?void 0:t.type)||"agent"}function $M(e){const t=String((e==null?void 0:e.marketplaceDefinitionId)||(e==null?void 0:e.id)||"").trim();return t.startsWith("marketplace:")?t:""}function Gv(e){if(!e)return"";const t=String(e.baseDefinitionId||"").trim();return t||String(e.id||"").trim()}function LM(e){const t=String(e??"");return/^[A-Za-z0-9_@%+=:,./-]+$/.test(t)?t:"'"+t.replace(/'/g,"'\\''")+"'"}function FJ(e,t){const n=String((e==null?void 0:e.language)||"").trim().toLowerCase(),r=String(t||"").trim().toLowerCase();return n.includes("python")||r.endsWith(".py")?"python3":n.includes("shell")||n==="bash"||r.endsWith(".sh")||r.endsWith(".bash")?"bash":"node"}function zJ(e){const t=String(e??"").trim();return t?t.includes("${")?t:LM(t):""}function OM(e){if(String((e==null?void 0:e.baseDefinitionId)||"").trim()!=="tool_nodejs")return"";const t=e!=null&&e.runtime&&typeof e.runtime=="object"?e.runtime:{},n=String(t.entry||"").trim().replace(/^\/+/,"");if(n){const i=String((e==null?void 0:e.packageDir)||"").trim().replace(/\/+$/,""),o=i?`${i}/${n}`:`\${flowDir}/${n}`,a=Array.isArray(t.args)?t.args.map(zJ).filter(Boolean):[];return[FJ(t,n),LM(o),...a].join(" ")}return String(t.command||"").trim()}function hd(e){const t=String(Gv(e)||(e==null?void 0:e.id)||"");return t==="workspace_run"||t==="workspace_scheduled_run"?"CONTROL":t.startsWith("display_")?"DISPLAY":/^control/i.test(t)?"CONTROL":/^tool/i.test(t)?"TOOL":/^provide/i.test(t)?"PROVIDE":"AGENT"}function mC(e){return e==="DISPLAY"?"preview":e==="CONTROL"?"account_tree":e==="TOOL"?"build":e==="PROVIDE"?"database":"smart_toy"}function Bm(e){return String((e==null?void 0:e.displayName)||(e==null?void 0:e.label)||(e==null?void 0:e.id)||"Node")}function md(e){return Bm(e)}function Kb(e){return String((e==null?void 0:e.description)||(e==null?void 0:e.body)||"").replace(/\s+/g," ").trim()}function ch(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 gC(e,t,n){const r=String((t==null?void 0:t.name)||(t==null?void 0:t.id)||`#${n+1}`).trim(),i=String((t==null?void 0:t.type)||"").trim(),o=String((t==null?void 0:t.default)??(t==null?void 0:t.value)??"").trim();return[e,r,i?`type: ${i}`:"",o?`default: ${o}`:""].filter(Boolean).join(" · ")}function yC(e,t){const n=Array.isArray(e)?e:[],r=n.slice(0,4),i=Math.max(0,n.length-r.length);return{list:n,shown:r,hidden:i,kind:t}}function Bw(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 i=new Map(t.map(l=>[l.id,l])),o=Lb(i.get(n),e.sourceHandle||"output-0","source"),a=Lb(i.get(r),e.targetHandle||"input-0","target");return!!(o&&a&&yf(o,a))}function BJ(e,t){const n=String((e==null?void 0:e.nodeId)||""),r=String((e==null?void 0:e.handleId)||""),i=(e==null?void 0:e.handleType)==="target"?"target":(e==null?void 0:e.handleType)==="source"?"source":"";if(!n||!r||!i)return null;const o=t.find(l=>l.id===n),a=Lb(o,r,i);return a?{nodeId:n,handleId:r,handleType:i,slot:a,slotType:JU(a)}:null}function WJ(e,t){return t?e.map((n,r)=>{const i=Array.isArray(t.handleType==="source"?n.inputs:n.outputs)?t.handleType==="source"?n.inputs:n.outputs:[];for(let o=0;o<i.length;o+=1){const a=i[o];if(!(t.handleType==="source"?yf(t.slot,a):yf(a,t.slot)))continue;const c=hd(n);return{def:n,order:r,category:c,categoryRank:tc.indexOf(c),slot:a,slotIndex:o,displayLabel:md(n),description:Kb(n)}}return null}).filter(Boolean).sort((n,r)=>{var a,l;const i=(a=n.slot)!=null&&a.required?0:1,o=(l=r.slot)!=null&&l.required?0:1;return i-o||n.slotIndex-r.slotIndex||n.categoryRank-r.categoryRank||n.order-r.order}):[]}function HJ(e,t,n){var o,a,l,c;if(!n)return[];const r=[],i=n.handleType==="source";for(const u of e||[]){if(!u||u.id===n.nodeId)continue;const f=Array.isArray(i?(o=u.data)==null?void 0:o.inputs:(a=u.data)==null?void 0:a.outputs)?i?u.data.inputs:u.data.outputs:[];for(let p=0;p<f.length;p+=1){const d=f[p];if((d==null?void 0:d.showOnNode)===!1||!(i?yf(n.slot,d):yf(d,n.slot)))continue;const y=i?{source:n.nodeId,sourceHandle:n.handleId,target:u.id,targetHandle:`input-${p}`}:{source:u.id,sourceHandle:`output-${p}`,target:n.nodeId,targetHandle:n.handleId},v=(t||[]).some(b=>b.target===y.target&&b.targetHandle===y.targetHandle);r.push({node:u,nodeId:u.id,nodeLabel:((l=u.data)==null?void 0:l.label)||u.id,definitionId:((c=u.data)==null?void 0:c.definitionId)||"",slot:d,slotIndex:p,handleId:i?y.targetHandle:y.sourceHandle,connection:y,occupied:v})}}return r.sort((u,f)=>{var v,b,g,k,x,_,j,N;const p=Number(((b=(v=u.node)==null?void 0:v.position)==null?void 0:b.y)||0),d=Number(((k=(g=f.node)==null?void 0:g.position)==null?void 0:k.y)||0),m=Number(((_=(x=u.node)==null?void 0:x.position)==null?void 0:_.x)||0),y=Number(((N=(j=f.node)==null?void 0:j.position)==null?void 0:N.x)||0);return p-d||m-y||u.slotIndex-f.slotIndex||String(u.nodeId).localeCompare(String(f.nodeId))})}function bc(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 VJ(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(i=>i.id));for(let i=1;i<1e4;i++){const o=`${n}_${i}`;if(!r.has(o))return o}return`${n}_${Date.now().toString(36)}`}function KJ(e){return(e==null?void 0:e.default)!=null?String(e.default):(e==null?void 0:e.value)!=null?String(e.value):""}function qJ(e){const t=Number(e);if(!Number.isFinite(t)||t<=0)return xf;const n=Math.max(1,Math.min(1440,Math.round(t)));return n<60?`*/${n} * * * *`:n===60?"0 * * * *":n<1440&&n%60===0?`0 */${n/60} * * *`:xf}function Zo(e,t=0,n=0,r=59){const i=Math.max(n,Math.min(r,Number.parseInt(String(e??t),10)||t));return String(i).padStart(2,"0")}function Yv(e){const t=String(e||"").trim().match(/^(\d{1,2}):(\d{1,2})$/);return t?`${Zo(t[1],9,0,23)}:${Zo(t[2],0,0,59)}`:"09:00"}function gd(e,t,n,r,i){const o=Yv(t),[a,l]=o.split(":").map(u=>Number.parseInt(u,10)),c=String(e||"daily");if(c==="weekly"){const u=Math.max(0,Math.min(6,Number.parseInt(String(n??1),10)||1));return`${l} ${a} * * ${u}`}if(c==="monthly"){const u=Math.max(1,Math.min(31,Number.parseInt(String(r??1),10)||1));return`${l} ${a} ${u} * *`}return c==="custom"?String(i||"").trim()||xf:`${l} ${a} * * *`}function UJ(e){const n=String(e||xf).trim().split(/\s+/);if(n.length!==5)return{scheduleType:"custom",time:"09:00",weekday:1,monthDay:1};const[r,i,o,a,l]=n,c=Number.parseInt(r,10),u=Number.parseInt(i,10),f=Number.isFinite(c)&&Number.isFinite(u)&&r===String(c)&&i===String(u),p=f?`${Zo(u,9,0,23)}:${Zo(c,0,0,59)}`:"09:00";return f&&o==="*"&&a==="*"&&l==="*"?{scheduleType:"daily",time:p,weekday:1,monthDay:1}:f&&o==="*"&&a==="*"&&/^\d+$/.test(l)?{scheduleType:"weekly",time:p,weekday:Math.max(0,Math.min(6,Number.parseInt(l,10))),monthDay:1}:f&&/^\d+$/.test(o)&&a==="*"&&l==="*"?{scheduleType:"monthly",time:p,weekday:1,monthDay:Math.max(1,Math.min(31,Number.parseInt(o,10)))}:{scheduleType:"custom",time:p,weekday:1,monthDay:1}}function Jv(e){let t={};const n=String(e||"").trim();if(n)try{t=JSON.parse(n)}catch{t={}}const r=Number(t.intervalMinutes),i=qJ(r),o=typeof t.cron=="string"&&t.cron.trim()?t.cron.trim():i,a=UJ(o),l=["daily","weekly","monthly","custom"].includes(t.scheduleType)?t.scheduleType:a.scheduleType,c=Yv(t.time||a.time||"09:00"),u=Math.max(0,Math.min(6,Number.parseInt(String(t.weekday??a.weekday??1),10)||1)),f=Math.max(1,Math.min(31,Number.parseInt(String(t.monthDay??a.monthDay??1),10)||1)),p=gd(l,c,u,f,o);return{enabled:t.enabled===!0,scheduleType:l,time:c,weekday:u,monthDay:f,cron:p,timezone:KY,targetRunNodeId:typeof t.targetRunNodeId=="string"?t.targetRunNodeId.trim():"",overlapPolicy:"skip"}}function GJ(e){const t=Jv(JSON.stringify(e||{}));return JSON.stringify(t)}function YJ(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Date(t).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function JJ(e){return e==="weekly"?"每周":e==="monthly"?"每月":e==="custom"?"高级 Cron":"每天"}function wC(e){if(typeof e=="number"&&Number.isFinite(e))return e;if(typeof e=="string"&&e.trim()){const t=Date.parse(e);if(Number.isFinite(t))return t}return 0}function uh(e){const t={};for(const n of Array.isArray(e)?e:[]){const r=String((n==null?void 0:n.scheduleNodeId)||(n==null?void 0:n.runNodeId)||"").trim();r&&(t[r]={nextAt:wC(n.nextRunAt),lastAt:wC(n.lastTriggeredAt),lastStatus:String(n.lastStatus||(n.enabled?"armed":"disabled")),lastError:String(n.lastError||""),lastRunId:String(n.lastRunId||""),targetRunNodeId:String(n.targetRunNodeId||n.runNodeId||""),cron:String(n.cron||""),timezone:String(n.timezone||"")})}return t}function Wm(e){var t;return!!((t=e==null?void 0:e.data)!=null&&t.isWorkspaceGroup)}function Hm(e){return e>0?`Group ${e+1}`:"Group"}function XJ(e){return(Array.isArray(e)?e:[]).map((n,r)=>{const i=String((n==null?void 0:n.id)||`group_${r+1}`).trim(),o=Number(n==null?void 0:n.x),a=Number(n==null?void 0:n.y),l=Number(n==null?void 0:n.width),c=Number(n==null?void 0:n.height);return!i||!Number.isFinite(o)||!Number.isFinite(a)||!Number.isFinite(l)||!Number.isFinite(c)?null:{id:i,title:String((n==null?void 0:n.title)||Hm(r)).trim()||Hm(r),color:String((n==null?void 0:n.color)||"purple").trim()||"purple",x:o,y:a,width:Math.max(fl,Math.round(l)),height:Math.max(pl,Math.round(c))}}).filter(Boolean)}function QJ(e){var n;return XJ((n=e==null?void 0:e.ui)==null?void 0:n.groups).map(r=>({id:r.id,type:Tc,position:{x:r.x,y:r.y},width:r.width,height:r.height,selected:!1,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:r.title,title:r.title,color:r.color,nodeSize:{width:r.width,height:r.height}}}))}function qb(e){const t=Number(e==null?void 0:e.width),n=Number(e==null?void 0:e.height);return!Number.isFinite(t)||!Number.isFinite(n)?null:{width:Math.max(fl,Math.round(t)),height:Math.max(pl,Math.round(n))}}function yd(e){return(Array.isArray(e)?e:[]).map(t=>({type:(t==null?void 0:t.type)||"node",name:(t==null?void 0:t.name)||"",default:KJ(t),required:!!(t!=null&&t.required),description:String((t==null?void 0:t.description)||""),showOnNode:(t==null?void 0:t.showOnNode)!=null?t.showOnNode!==!1:!!(t!=null&&t.required)||String((t==null?void 0:t.type)||"node").trim().toLowerCase()==="node"}))}function DM(e){const t=(e==null?void 0:e.data)||{},n=r=>(Array.isArray(r)?r:[]).map((i,o)=>(i==null?void 0:i.showOnNode)===!1?"":[o,String((i==null?void 0:i.type)||""),String((i==null?void 0:i.name)||""),i!=null&&i.required?"1":"0"].join(":")).filter(Boolean).join("|");return`${n(t.inputs)}=>${n(t.outputs)}`}function ZJ(e){var o,a,l,c;const t=(e==null?void 0:e.data)||{},n=t!=null&&t.displaySize&&typeof t.displaySize=="object"?t.displaySize:{},r=t!=null&&t.nodeSize&&typeof t.nodeSize=="object"?t.nodeSize:{},i=Og(t);return[DM(e),Fn(t)||"",i?"has-result":"",(t==null?void 0:t.contextRunResultNonce)||"",Number((e==null?void 0:e.width)||0)||"",Number((e==null?void 0:e.height)||0)||"",Number(((o=e==null?void 0:e.measured)==null?void 0:o.width)||0)||"",Number(((a=e==null?void 0:e.measured)==null?void 0:a.height)||0)||"",Number(r.width||0)||"",Number(r.height||0)||"",Number(n.width||0)||"",Number(n.height||0)||"",t!=null&&t.isExecuting?"executing":"",(t==null?void 0:t.nodeStatus)||"",(c=(l=t==null?void 0:t.runningRunNodeIds)==null?void 0:l.has)!=null&&c.call(l,e==null?void 0:e.id)?"running-run":""].join("::")}function xC(e,t){return!e||!t?!1:e.selected===t.selected&&e.isExecuting===t.isExecuting&&e.nodeStatus===t.nodeStatus&&e.nodeElapsed===t.nodeElapsed&&e.optimizingRun===t.optimizingRun&&e.scheduledRunState===t.scheduledRunState&&e.nodeChatActive===t.nodeChatActive&&e.nodeChat===t.nodeChat}const eX=new Map,tX=[];function nd(e,t){var m,y;const n=e!=null&&e.instances&&typeof e.instances=="object"?e.instances:{},r=BM(n),i=Array.isArray(e==null?void 0:e.edges)?e.edges:[],o=(m=e==null?void 0:e.ui)!=null&&m.nodePositions&&typeof e.ui.nodePositions=="object"?e.ui.nodePositions:{},a=(y=e==null?void 0:e.ui)!=null&&y.nodeSizes&&typeof e.ui.nodeSizes=="object"?e.ui.nodeSizes:{},l=new Set(Object.keys(r));for(const v of i)v!=null&&v.source&&l.add(String(v.source)),v!=null&&v.target&&l.add(String(v.target));const u=Array.from(l).map(v=>{const b=r[v]||{},g=b.definitionId||v,k=t.find(D=>D.id===g),x=Gv(k)||g,_=t.find(D=>D.id===x)||k,j=b.marketplaceRef||$M(k),N=OM(k),P=o[v]&&typeof o[v].x=="number"&&typeof o[v].y=="number"?o[v]:{x:320+l.size*20,y:180+l.size*12},T=!!Fn({definitionId:x,inputs:b.input,outputs:b.output}),z=a[v]&&typeof a[v].width=="number"&&typeof a[v].height=="number"?{width:a[v].width,height:a[v].height}:null,E=el(z,{display:T}),O=E&&!di(x);return{id:v,type:Tc,position:P,...O?{width:E.width,height:E.height}:{},data:{label:b.label||Bm(k)||Bm(_)||v,definitionId:x,...j?{marketplaceRef:j}:{},...k!=null&&k.packageId?{marketplacePackageId:k.packageId}:{},...k!=null&&k.version?{marketplaceVersion:k.version}:{},schemaType:MM(x,_||k),role:b.role||"normal",model:b.model||void 0,body:b.body||"",script:b.script||N||"",scriptRef:b.scriptRef||"",implementationRef:b.implementationRef||"",implementationMode:b.implementationMode||"",displayReloadKey:b.displayReloadKey||"",...O?{nodeSize:E}:{},...T&&O?{displaySize:E}:{}}}}).map(v=>Db(v,r,t)),f=QJ(e),p=i.filter(v=>(v==null?void 0:v.source)&&(v==null?void 0:v.target)).filter(v=>!f.some(b=>b.id===String(v.source)||b.id===String(v.target))).map((v,b)=>({id:v.id||`we-${v.source}-${v.target}-${b}`,source:String(v.source),target:String(v.target),sourceHandle:v.sourceHandle??void 0,targetHandle:v.targetHandle??void 0,markerEnd:{type:Ii.ArrowClosed}})),d=[...f,...u];return{nodes:d,edges:SG(p,d),instances:r}}function bC(e){return`${Hb}${e}`}function dh(e){const t=String(e||"");return t.startsWith(Hb)?t.slice(Hb.length):t}function Ub(e){if(!e||typeof e!="object")return null;const t=Number(e.x),n=Number(e.y),r=Number(e.zoom);return!Number.isFinite(t)||!Number.isFinite(n)||!Number.isFinite(r)?null:{x:t,y:n,zoom:Math.min(Math.max(r,.1),4)}}function Hh(e,t=[]){const n=new Map((Array.isArray(t)?t:[]).filter(p=>{var d;return ml((d=p==null?void 0:p.data)==null?void 0:d.definitionId)}).map(p=>[p.id,p])),r=Array.isArray(e==null?void 0:e.nodeIds)?e.nodeIds:[],i=[],o=new Set;for(const p of r){const d=String(p||"").trim();!d||o.has(d)||!n.has(d)||(o.add(d),i.push(d))}const a={},l=e!=null&&e.nodePositions&&typeof e.nodePositions=="object"?e.nodePositions:{};i.forEach((p,d)=>{const m=l[p];a[p]=m&&typeof m.x=="number"&&typeof m.y=="number"?{x:m.x,y:m.y}:{x:180+d*36,y:120+d*28}});const c={},u=e!=null&&e.nodeSizes&&typeof e.nodeSizes=="object"?e.nodeSizes:{};i.forEach(p=>{const d=el(u[p],{display:!0});d&&(c[p]=d)});const f=Ub(e==null?void 0:e.viewport);return{nodeIds:i,nodePositions:a,nodeSizes:c,...f?{viewport:f}:{}}}function kC(e,t=[]){return Hh(e,t)}const Ww=[{value:"1",label:"1 天"},{value:"7",label:"7 天"},{value:"30",label:"30 天"},{value:"90",label:"90 天"},{value:"365",label:"1 年"},{value:"permanent",label:"永久"}];function Hw(e={}){return{title:"",layout:"gallery",nodeIds:[],expiresInDays:30,permanent:!1,...e}}function vC(e={}){return e.permanent?"permanent":String(e.expiresInDays||30)}function SC(e={}){if(e.permanent)return{expiresMode:"permanent",permanent:!0};const t=Number(e.expiresInDays||30);return{expiresMode:"days",expiresInDays:Number.isFinite(t)?t:30}}function nX(e={}){if(!e.expiresAt)return"永久有效";const t=Date.parse(String(e.expiresAt||""));return Number.isFinite(t)?`有效期至 ${new Date(t).toLocaleString()}`:"永久有效"}function jC(e={}){return new URL(e.url||`/display/${e.id||""}`,window.location.origin).href}const FM="af:workspace:canvas-clipboard",zM="agentflow.workspace.canvas-clipboard";function rX(e){return JSON.stringify({type:zM,version:1,clipboard:e})}function sX(e){try{const t=JSON.parse(String(e||""));if((t==null?void 0:t.type)!==zM)return null;const n=t.clipboard;return!n||!Array.isArray(n.nodes)||n.nodes.length===0?null:n}catch{return null}}function iX(e){try{localStorage.setItem(FM,rX(e))}catch{}}function oX(){try{return sX(localStorage.getItem(FM))}catch{return null}}function aX(e){const t=Number.isFinite(e)?e:1;return Math.min(Math.max(t,.75),1)}async function Gb(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 i=document.execCommand("copy");return document.body.removeChild(r),i}catch{return!1}}function NC(e,t,n){const r=Number(e);return!Number.isFinite(r)||r<=0?0:Math.min(n,Math.max(t,Math.round(r)))}function el(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:NC(n,_M,CM)||NM,height:NC(r,Lm,AM)||Lm}}function Vm(e){const t=el(e,{display:!0});return t?{width:Math.max(320,Math.round(t.width)),height:Math.max(180,Math.round(t.height))}:null}function lX(e){const t=String(e||"").trim().toLowerCase();return t==="html"||t==="react"?{width:720,height:520}:t==="table"||t==="chart"?{width:640,height:380}:t==="image"?{width:520,height:360}:{width:Bb,height:Wb}}function cX(e,t=""){const n=Vm(e==null?void 0:e.displaySize);if(n)return n;const r=Vm(e==null?void 0:e.nodeSize);if(r)return r;const i=ml(t)||Wf(ga((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown"));return lX(i)}function rc(e){var i,o,a,l,c,u,f,p,d,m,y;if(di((i=e==null?void 0:e.data)==null?void 0:i.definitionId))return null;const t=!!Fn(e==null?void 0:e.data),n=Number(((a=(o=e==null?void 0:e.data)==null?void 0:o.displaySize)==null?void 0:a.width)||((c=(l=e==null?void 0:e.data)==null?void 0:l.nodeSize)==null?void 0:c.width)||(e==null?void 0:e.width)||(t?(u=e==null?void 0:e.measured)==null?void 0:u.width:0)||0),r=Number(((p=(f=e==null?void 0:e.data)==null?void 0:f.displaySize)==null?void 0:p.height)||((m=(d=e==null?void 0:e.data)==null?void 0:d.nodeSize)==null?void 0:m.height)||(e==null?void 0:e.height)||(t?(y=e==null?void 0:e.measured)==null?void 0:y.height:0)||0);return el({width:n,height:r},{display:t})}function Xl(e,t,n){var f,p,d,m,y,v,b,g,k,x,_,j,N;const r=(e||[]).filter(P=>!Wm(P)),i=(e||[]).filter(Wm),o=BM(Bv(r,n||{})),a=t.map(P=>({source:P.source,target:P.target,sourceHandle:P.sourceHandle??null,targetHandle:P.targetHandle??null})).filter(P=>!i.some(T=>T.id===P.source||T.id===P.target)),l={},c={},u=[];for(const P of r){l[P.id]={x:((f=P.position)==null?void 0:f.x)||0,y:((p=P.position)==null?void 0:p.y)||0};const T=rc(P);T&&(c[P.id]=T)}for(const P of i){const T=Number(((m=(d=P.data)==null?void 0:d.nodeSize)==null?void 0:m.width)||P.width||((y=P.measured)==null?void 0:y.width)||0),z=Number(((b=(v=P.data)==null?void 0:v.nodeSize)==null?void 0:b.height)||P.height||((g=P.measured)==null?void 0:g.height)||0);u.push({id:P.id,title:String(((k=P.data)==null?void 0:k.title)||((x=P.data)==null?void 0:x.label)||"Group"),color:String(((_=P.data)==null?void 0:_.color)||"purple"),x:Number(((j=P.position)==null?void 0:j.x)||0),y:Number(((N=P.position)==null?void 0:N.y)||0),width:Math.max(fl,Math.round(T||fl)),height:Math.max(pl,Math.round(z||pl))})}return{version:1,instances:o,edges:a,ui:{nodePositions:l,nodeSizes:c,groups:u}}}function BM(e){const t={};for(const[n,r]of Object.entries(e||{})){const i=String((r==null?void 0:r.definitionId)||n);if(!!ml(i)||i.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 ml(e){const t=String(e||"");return t==="display_markdown"?"markdown":t==="display_mermaid"?"mermaid":t==="display_ascii"?"ascii":t==="display_html"?"html":t==="display_react_app"?"react":t==="display_image"?"image":t==="display_chart"?"chart":t==="display_table"?"table":""}function Fn(e){const t=ml(e==null?void 0:e.definitionId);return t||(di(e==null?void 0:e.definitionId)&&Og(e)?Wf(ga((e==null?void 0:e.inputs)||(e==null?void 0:e.input)||[],"displayType","markdown")):"")}function fo(e){const t=[...(e==null?void 0:e.inputs)||[],...(e==null?void 0:e.outputs)||[]],n=Fn(e),r=di(e==null?void 0:e.definitionId),i=n==="image"?"src":"content",o=u=>String((u==null?void 0:u.value)??(u==null?void 0:u.default)??""),a=u=>o(u).trim(),l=t.find(u=>(u==null?void 0:u.name)===i&&a(u))||t.find(u=>(u==null?void 0:u.name)==="filePath"&&a(u))||t.find(u=>(u==null?void 0:u.type)==="text"&&a(u)),c=l?o(l):"";return String(r?c:(e==null?void 0:e.body)||c)}function ma(e,t=""){const n=String(e||"").trim();if(!n||n.length>260||/[\r\n<>]/.test(n)||/^(?:https?:|data:|blob:|file:|javascript:|mailto:|tel:)/i.test(n))return"";const r=n.replace(/^\/+/,"");if(r.includes("..")||r.startsWith("."))return"";const i=r.split("?")[0].split("#")[0].toLowerCase().split(".").pop()||"";return({html:new Set(["html","htm"]),react:new Set(["json","jsx","tsx","js","txt"]),markdown:new Set(["md","markdown","txt"]),mermaid:new Set(["mmd","mermaid","txt"]),ascii:new Set(["txt","log"]),chart:new Set(["json"]),table:new Set(["json","csv","tsv"])}[t]||new Set(["html","htm","md","markdown","txt","json","csv","tsv"])).has(i)?r:""}function uX(e){let t=String(e||"").replace(/\r\n/g,`
|
|
189
|
+
`).trim();return t.includes(`
|
|
190
|
+
`)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
|
|
191
|
+
$1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
|
|
192
|
+
$2`)),t}function Di(e){const t=String(e||"").trim();if(!t)return String(e||"");const n=t.match(/---agentflow\b([\s\S]*?)---end/i);if(n!=null&&n[1]){const a=uX(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const f=String(c[1]||"").trim();return f==="|"||f===">"?a.slice((c.index||0)+c[0].length).split(`
|
|
193
|
+
`).filter(d=>/^\s+/.test(d)||!d.trim()).map(d=>d.replace(/^\s{2}/,"")).join(`
|
|
194
|
+
`).replace(/\s+$/g,""):f.replace(/^["']|["']$/g,"")}const u=t.replace(n[0],"").trim();if(u)return u}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],i=t.indexOf("{"),o=t.lastIndexOf("}");i>=0&&o>i&&r.unshift(t.slice(i,o+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}async function gl(e,t){const n=$r(e);n.set("path",t);const r=await fetch(`/api/workspace/file?${n.toString()}`),i=await r.json().catch(()=>({}));if(!r.ok)throw new Error(i.error||`读取文件失败:${t}`);return String(i.content||"")}async function Yb(e,t,n){const r=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,path:t,content:String(n||"")})}),i=await r.json().catch(()=>({}));if(!r.ok)throw new Error(i.error||`写入文件失败:${t}`);return i.path||t}function dX(e,t=[],n=[]){const r=String(e||"");if(!r)return"";const i=new Map(t.map(o=>[o.id,o]));return(Array.isArray(n)?n:[]).filter(o=>String((o==null?void 0:o.target)||"")===r).slice(0,4).map(o=>{const a=i.get(String((o==null?void 0:o.source)||""));if(!a)return"";const l=a.data||{},c=String(l.body||"").trim(),u=[`- upstreamId: ${a.id}`,` label: ${String(l.label||a.id).trim()}`,` definitionId: ${String(l.definitionId||"").trim()}`];return c&&u.push(` task: ${c.slice(0,4e3)}`),u.join(`
|
|
195
|
+
`)}).filter(Boolean).join(`
|
|
196
|
+
|
|
197
|
+
`)}function au(e){let t=Di(e).trim();if(!t)return"";const n=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*?)```/);if(n&&n[1])t=n[1].trim();else{const o=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);o&&o[1]&&(t=o[1].trim())}t=t.replace(/^html\s*\n/i,"").replace(/```\s*$/g,"").trim();const i=[/<!doctype\b/i,/<html\b/i,/<head\b/i,/<body\b/i,/<style\b/i,/<script\b/i,/<main\b/i,/<section\b/i,/<article\b/i,/<div\b/i,/<svg\b/i,/<canvas\b/i].reduce((o,a)=>{const l=a.exec(t);return l?o<0?l.index:Math.min(o,l.index):o},-1);return i>0&&(t=t.slice(i).trim()),t}function fX(e){const t=au(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function Ua(e,t){return e==="html"?fX(t):""}function WM(e,t=""){const n=au(e);if(!n.trim())return"";const i=`<base target="_blank"><script data-agentflow-display-link-guard="1">
|
|
198
|
+
(() => {
|
|
199
|
+
const frameId = ${JSON.stringify(String(t||""))};
|
|
200
|
+
const postSize = () => {
|
|
201
|
+
const doc = document.documentElement;
|
|
202
|
+
const body = document.body;
|
|
203
|
+
const height = Math.ceil(Math.max(
|
|
204
|
+
doc ? doc.scrollHeight : 0,
|
|
205
|
+
doc ? doc.offsetHeight : 0,
|
|
206
|
+
doc ? doc.clientHeight : 0,
|
|
207
|
+
body ? body.scrollHeight : 0,
|
|
208
|
+
body ? body.offsetHeight : 0,
|
|
209
|
+
body ? body.clientHeight : 0,
|
|
210
|
+
window.innerHeight || 0
|
|
211
|
+
));
|
|
212
|
+
window.parent.postMessage({ source: "agentflow-html-display-size", frameId, height }, "*");
|
|
213
|
+
};
|
|
214
|
+
document.addEventListener("click", (event) => {
|
|
215
|
+
const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
|
|
216
|
+
if (!link) return;
|
|
217
|
+
const rawHref = String(link.getAttribute("href") || "").trim();
|
|
218
|
+
if (!rawHref || rawHref.startsWith("#")) return;
|
|
219
|
+
if (/^javascript:/i.test(rawHref)) {
|
|
220
|
+
event.preventDefault();
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
event.preventDefault();
|
|
224
|
+
window.open(link.href, "_blank", "noopener,noreferrer");
|
|
225
|
+
}, true);
|
|
226
|
+
window.addEventListener("load", postSize);
|
|
227
|
+
window.addEventListener("resize", postSize);
|
|
228
|
+
requestAnimationFrame(postSize);
|
|
229
|
+
setTimeout(postSize, 60);
|
|
230
|
+
setTimeout(postSize, 300);
|
|
231
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
232
|
+
const resizeObserver = new ResizeObserver(postSize);
|
|
233
|
+
resizeObserver.observe(document.documentElement);
|
|
234
|
+
if (document.body) resizeObserver.observe(document.body);
|
|
235
|
+
}
|
|
236
|
+
if (typeof MutationObserver !== "undefined") {
|
|
237
|
+
const mutationObserver = new MutationObserver(postSize);
|
|
238
|
+
mutationObserver.observe(document.documentElement, { childList: true, subtree: true, attributes: true, characterData: true });
|
|
239
|
+
}
|
|
240
|
+
})();
|
|
241
|
+
<\/script>`;return/data-agentflow-display-link-guard=["']1["']/i.test(n)?n:/<head\b[^>]*>/i.test(n)?n.replace(/<head\b([^>]*)>/i,`<head$1>${i}`):/<html\b[^>]*>/i.test(n)?n.replace(/<html\b([^>]*)>/i,`<html$1><head>${i}</head>`):`<!doctype html><html><head>${i}</head><body>${n}</body></html>`}function pX(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 hX(e,t){const n=document.createElement("a");n.href=e,n.download=t,document.body.appendChild(n),n.click(),n.remove()}function mX(e,t){const n=URL.createObjectURL(e);try{hX(n,t)}finally{window.setTimeout(()=>URL.revokeObjectURL(n),1e3)}}function HM(e){var t;try{return(e==null?void 0:e.contentDocument)||((t=e==null?void 0:e.contentWindow)==null?void 0:t.document)||null}catch{return null}}function gX(e){const t=HM(e);return t!=null&&t.documentElement?`${t.doctype?`<!DOCTYPE ${t.doctype.name}${t.doctype.publicId?` PUBLIC "${t.doctype.publicId}"`:""}${t.doctype.systemId?` "${t.doctype.systemId}"`:""}>`:"<!DOCTYPE html>"}
|
|
242
|
+
${t.documentElement.outerHTML}`:""}function Vw(e){var n;if(!e)return null;const t=(n=e.getBoundingClientRect)==null?void 0:n.call(e);return{rectWidth:t!=null&&t.width?Math.round(t.width):null,rectHeight:t!=null&&t.height?Math.round(t.height):null,clientWidth:e.clientWidth||null,clientHeight:e.clientHeight||null,scrollWidth:e.scrollWidth||null,scrollHeight:e.scrollHeight||null,offsetWidth:e.offsetWidth||null,offsetHeight:e.offsetHeight||null}}function yX(e,t,n,r={}){var b;const i=(b=e==null?void 0:e.getBoundingClientRect)==null?void 0:b.call(e),o=HM(e),a=o==null?void 0:o.documentElement,l=o==null?void 0:o.body,c=(r==null?void 0:r.card)||null,u=(r==null?void 0:r.displayBody)||null,f=(r==null?void 0:r.scroller)||null,p=(r==null?void 0:r.displaySize)||null,d={fallbackWidth:Number(t)||null,fallbackHeight:Number(n)||null,displaySizeWidth:Number((p==null?void 0:p.width)||0)||null,displaySizeHeight:Number((p==null?void 0:p.height)||0)||null,rectWidth:i!=null&&i.width?Math.round(i.width):null,rectHeight:i!=null&&i.height?Math.round(i.height):null,iframeClientWidth:(e==null?void 0:e.clientWidth)||null,iframeClientHeight:(e==null?void 0:e.clientHeight)||null,docScrollWidth:(a==null?void 0:a.scrollWidth)||null,docScrollHeight:(a==null?void 0:a.scrollHeight)||null,bodyScrollWidth:(l==null?void 0:l.scrollWidth)||null,bodyScrollHeight:(l==null?void 0:l.scrollHeight)||null,docOffsetWidth:(a==null?void 0:a.offsetWidth)||null,bodyOffsetWidth:(l==null?void 0:l.offsetWidth)||null,card:Vw(c),displayBody:Vw(u),scroller:Vw(f)},m=[Number(t)||0,Number((p==null?void 0:p.width)||0),Number((c==null?void 0:c.clientWidth)||0),Number((c==null?void 0:c.scrollWidth)||0),Number((u==null?void 0:u.clientWidth)||0),Number((u==null?void 0:u.scrollWidth)||0),Number((f==null?void 0:f.clientWidth)||0),Number((f==null?void 0:f.scrollWidth)||0),Number(i==null?void 0:i.width)||0,Number(e==null?void 0:e.clientWidth)||0,Number((a==null?void 0:a.scrollWidth)||0),Number((l==null?void 0:l.scrollWidth)||0),Number((a==null?void 0:a.offsetWidth)||0),Number((l==null?void 0:l.offsetWidth)||0)].map(g=>Math.ceil(g)).filter(g=>g>0),y=Math.max(1,...m.length?m:[960]),v=Math.max(1,Math.round(Number(n)||(i==null?void 0:i.height)||(e==null?void 0:e.clientHeight)||640),Math.ceil(Number((a==null?void 0:a.scrollHeight)||0)),Math.ceil(Number((l==null?void 0:l.scrollHeight)||0)));return{width:y,height:v,debug:d}}async function wX({flowParams:e,content:t,sourceFilePath:n,iframe:r,width:i,height:o,filename:a,snapshotElements:l,displaySize:c}){const u=yX(r,i,o,{...l||{},displaySize:c}),f=gX(r),p=await fetch("/api/workspace/html-screenshot",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,content:f||t,sourceFilePath:n||"",width:u.width,height:u.height,filename:a})});if(!p.ok){const m=await p.json().catch(()=>({}));throw new Error(m.error||"截图失败")}const d=await p.blob();mX(d,a)}function xX(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 VM(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="react"?"deployed_code":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function bX(e){const t=String(e||"").split(/\r?\n/).map(l=>l.replace(/%%.*$/,"").trim()).filter(Boolean),n=new Map,r=[];let i="TD";const o=(l,c="")=>{const u=String(l||"").replace(/[^A-Za-z0-9_]/g,"_")||`N${n.size+1}`;return n.has(u)?c&&(n.get(u).label=c):n.set(u,{id:u,label:c||u}),u},a=l=>{const c=String(l||"").trim().replace(/[;,]+$/,""),u=c.match(/^([A-Za-z][A-Za-z0-9_]*)(?:\[(.+?)\]|\((.+?)\)|\{(.+?)\})?$/);return u?o(u[1],u[2]||u[3]||u[4]||u[1]):o(c.replace(/[^A-Za-z0-9_]/g,"_"),c)};for(const l of t){const c=l.match(/^(graph|flowchart)\s+(TD|TB|BT|LR|RL)\b/i);if(c){i=c[2].toUpperCase();continue}const u=l.match(/^(.+?)\s*-{1,2}>+\s*(.+)$/);if(u){r.push({from:a(u[1]),to:a(u[2])});continue}a(l)}return{nodes:Array.from(n.values()),edges:r,direction:i}}function KM({code:e}){const t=h.useMemo(()=>bX(e),[e]);if(!String(e||"").trim())return null;const n=t.direction==="LR"||t.direction==="RL",r=142,i=44,o=n?96:32,a=n?30:68,l=new Map;t.nodes.forEach((f,p)=>{l.set(f.id,{x:24+(n?p*(r+o):p%3*(r+o)),y:24+(n?p%3*(i+a):p*(i+a))})});const c=Math.max(360,...Array.from(l.values()).map(f=>f.x+r+24)),u=Math.max(180,...Array.from(l.values()).map(f=>f.y+i+24));return s.jsx("div",{className:"af-work-node__mermaid-preview",children:s.jsxs("svg",{viewBox:`0 0 ${c} ${u}`,role:"img","aria-label":"Mermaid preview",children:[s.jsx("defs",{children:s.jsx("marker",{id:"af-work-arrow",viewBox:"0 0 10 10",refX:"9",refY:"5",markerWidth:"6",markerHeight:"6",orient:"auto-start-reverse",children:s.jsx("path",{d:"M 0 0 L 10 5 L 0 10 z"})})}),t.edges.map((f,p)=>{const d=l.get(f.from),m=l.get(f.to);if(!d||!m)return null;const y=n?`M ${d.x+r} ${d.y+i/2} C ${(d.x+m.x+r)/2} ${d.y+i/2}, ${(d.x+m.x+r)/2} ${m.y+i/2}, ${m.x} ${m.y+i/2}`:`M ${d.x+r/2} ${d.y+i} C ${d.x+r/2} ${d.y+i+28}, ${m.x+r/2} ${m.y-28}, ${m.x+r/2} ${m.y}`;return s.jsx("path",{className:"af-work-node__mermaid-edge",d:y,markerEnd:"url(#af-work-arrow)"},`${f.from}-${f.to}-${p}`)}),t.nodes.map(f=>{const p=l.get(f.id);return s.jsxs("g",{children:[s.jsx("rect",{className:"af-work-node__mermaid-box",x:p.x,y:p.y,width:r,height:i,rx:"8"}),s.jsx("text",{className:"af-work-node__mermaid-text",x:p.x+r/2,y:p.y+i/2+5,textAnchor:"middle",children:f.label.slice(0,22)})]},f.id)})]})})}function vi({className:e="",children:t}){const n=h.useRef(null),r=h.useRef(null),[i,o]=h.useState({visible:!1,top:0,height:100}),a=h.useCallback(()=>{const f=n.current;if(!f)return;const p=Math.max(1,f.scrollHeight),d=Math.max(1,f.clientHeight),m=p>d+1,y=m?Math.max(12,d/p*100):100,v=Math.max(0,100-y),b=m?Math.min(v,f.scrollTop/Math.max(1,p-d)*v):0;o({visible:m,top:b,height:y})},[]);h.useEffect(()=>{const f=requestAnimationFrame(a),p=n.current;if(!p||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(f);const d=new ResizeObserver(a);d.observe(p);for(const m of Array.from(p.children))d.observe(m);return()=>{cancelAnimationFrame(f),d.disconnect()}},[t,a]);const l=h.useCallback(f=>{const p=n.current;if(!p)return;const d=Math.max(0,p.scrollHeight-p.clientHeight);p.scrollTop=Math.min(1,Math.max(0,f))*d,a()},[a]),c=h.useCallback((f,p=0)=>{const d=r.current;if(!d)return 0;const m=d.getBoundingClientRect(),y=i.height/100*m.height,v=Math.max(1,m.height-y);return(f-m.top-p)/v},[i.height]),u=h.useCallback(f=>{var _,j;if(!i.visible)return;f.preventDefault(),f.stopPropagation();const p=r.current;if(!p)return;const d=p.getBoundingClientRect(),m=i.top/100*d.height,y=i.height/100*d.height,b=f.clientY>=d.top+m&&f.clientY<=d.top+m+y?f.clientY-d.top-m:y/2;l(c(f.clientY,b));const g=f.pointerId;(j=(_=f.currentTarget).setPointerCapture)==null||j.call(_,g);const k=N=>{N.preventDefault(),l(c(N.clientY,b))},x=()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)};window.addEventListener("pointermove",k),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x)},[c,l,i.height,i.top,i.visible]);return s.jsxs("div",{className:`af-visible-scroll-frame ${e}`,children:[s.jsx("div",{ref:n,className:`af-visible-scroll-frame__scroller ${e}`,onScroll:a,children:t}),s.jsx("div",{ref:r,className:"af-visible-scrollbar"+(i.visible?" af-visible-scrollbar--visible":""),onPointerDown:u,"aria-hidden":"true",children:s.jsx("span",{style:{height:`${i.height}%`,top:`${i.top}%`}})})]})}function qM({data:e,flowParams:t,htmlFrameRef:n,htmlFrameVersion:r=0}){const i=Fn(e),o=fo(e),a=i==="image"?o:Di(o),l=i==="image"?"":ma(a,i),[c,u]=h.useState(""),[f,p]=h.useState(""),[d,m]=h.useState(!1);h.useEffect(()=>{let k=!1;return l?(m(!0),p(""),u(""),gl(t,l).then(x=>{k||u(x)}).catch(x=>{k||p(String(x.message||x))}).finally(()=>{k||m(!1)}),()=>{k=!0}):(u(""),p(""),m(!1),()=>{k=!0})},[l,t==null?void 0:t.flowId,t==null?void 0:t.flowSource,t==null?void 0:t.archived,e==null?void 0:e.displayReloadKey]);const y=l?c:a,v=i==="html"?au(y):i==="react"?Lg(y):Di(y),b=h.useRef("");if(b.current||(b.current=`html-display-${Math.random().toString(36).slice(2,10)}`),!i)return null;const g=Ua(i,v);if(d)return s.jsxs(vi,{className:"af-work-display-empty",children:["Loading ",l,"..."]});if(f)return s.jsx(vi,{className:"af-work-display-empty",children:f});if(g)return s.jsx(vi,{className:"af-work-display-empty",children:g});if(!v.trim())return s.jsx(vi,{className:"af-work-display-empty",children:"No display content"});if(i==="html"||i==="react")return s.jsx("div",{className:"af-work-display-body af-work-display-body--html",children:s.jsx("iframe",{ref:n,className:"af-work-display-html-frame",title:(e==null?void 0:e.label)||(i==="react"?"React app preview":"HTML preview"),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:i==="react"?Wv(v,b.current):WM(v,b.current)},r)});if(i==="image"){const k=bf(v,t);return s.jsx(vi,{className:"af-work-display-body af-work-display-body--image",children:s.jsx("img",{className:"af-work-display-image",src:k,alt:xX(e),loading:"lazy"})})}return i==="markdown"?s.jsx(vi,{className:"af-work-display-body af-work-display-body--markdown",children:s.jsx(hf,{content:v,basePath:l,resolveSrc:(k,x)=>bf(k,t,x)})}):i==="chart"?s.jsx(vi,{className:"af-work-display-body af-work-display-body--chart",children:s.jsx(Dv,{content:v})}):i==="table"?s.jsx(vi,{className:"af-work-display-body af-work-display-body--table",children:s.jsx(Ov,{content:v})}):i==="mermaid"?s.jsxs(vi,{className:"af-work-display-body",children:[s.jsx(KM,{code:v}),s.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--mermaid",children:v})]}):s.jsx(vi,{className:"af-work-display-body af-work-display-body--ascii",children:s.jsx("pre",{className:"af-work-node__diagram af-work-node__diagram--ascii",children:v})})}function kX({node:e,onClose:t}){var k,x,_,j,N,P,T,z,E,O,D;const n=h.useRef(null),r=Fn(e==null?void 0:e.data),i=((k=e==null?void 0:e.data)==null?void 0:k.label)||(r==="html"?"HTML 展示":r==="markdown"?"Markdown 展示":"Display 预览"),o=!!((x=e==null?void 0:e.data)!=null&&x.readOnly),[a,l]=h.useState(!1),[c,u]=h.useState(""),[f,p]=h.useState(""),[d,m]=h.useState(!1),y=fo(e==null?void 0:e.data),v=r==="markdown"?Di(y):"",b=r==="markdown"?ma(v,"markdown"):"",g=r==="markdown"?b?f:v:"";return h.useEffect(()=>{const L=$=>{if($.key==="Escape"){if(a){u(String(g||"")),l(!1);return}t==null||t()}};return window.addEventListener("keydown",L),()=>window.removeEventListener("keydown",L)},[g,a,t]),h.useEffect(()=>{var $;let L=!1;return r!=="markdown"||!b?(p(""),m(!1),()=>{L=!0}):(m(!0),gl((($=e==null?void 0:e.data)==null?void 0:$.flowParams)||{},b).then(V=>{L||p(V)}).catch(V=>{var W,F;L||(p(""),(F=(W=e==null?void 0:e.data)==null?void 0:W.onStatus)==null||F.call(W,String(V.message||V)))}).finally(()=>{L||m(!1)}),()=>{L=!0})},[r,b,(j=(_=e==null?void 0:e.data)==null?void 0:_.flowParams)==null?void 0:j.flowId,(P=(N=e==null?void 0:e.data)==null?void 0:N.flowParams)==null?void 0:P.flowSource,(z=(T=e==null?void 0:e.data)==null?void 0:T.flowParams)==null?void 0:z.archived,(E=e==null?void 0:e.data)==null?void 0:E.displayReloadKey]),h.useEffect(()=>{a||u(String(g||""))},[g,a]),e?er.createPortal(s.jsx("div",{className:"af-display-preview-overlay",role:"dialog","aria-modal":"true","aria-label":"全屏预览",children:s.jsxs("div",{className:"af-display-preview-shell",children:[s.jsxs("div",{className:"af-display-preview-head",children:[s.jsxs("div",{className:"af-display-preview-title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:VM(r)}),s.jsx("strong",{children:i}),s.jsx("span",{children:e.id})]}),s.jsxs("div",{className:"af-display-preview-actions",children:[r==="markdown"?a?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"af-display-preview-action",disabled:o||d,onClick:async()=>{var L,$;try{await GM({nodeId:e.id,data:e.data,filePath:b,content:c,setFileContent:p}),l(!1)}catch(V){($=(L=e==null?void 0:e.data)==null?void 0:L.onStatus)==null||$.call(L,String(V.message||V))}},"aria-label":"保存并预览",title:"保存并预览",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"done"})}),s.jsx("button",{type:"button",className:"af-display-preview-action",onClick:()=>{u(String(g||"")),l(!1)},"aria-label":"取消编辑",title:"取消编辑",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):s.jsx("button",{type:"button",className:"af-display-preview-action",disabled:o||d,onClick:()=>{u(String(g||"")),l(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"edit"})}):null,s.jsx("button",{type:"button",className:"af-display-preview-action",onClick:t,"aria-label":"关闭全屏预览",title:"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close_fullscreen"})})]})]}),s.jsx("div",{className:"af-display-preview-content",children:r==="markdown"&&a?s.jsx(UM,{value:c,onChange:u,onUploadImage:(O=e.data)==null?void 0:O.onUploadWorkspaceImage,readOnly:o}):s.jsx(qM,{data:e.data,flowParams:(D=e.data)==null?void 0:D.flowParams,htmlFrameRef:n})})]})}),document.body):null}function vX({node:e}){var d,m,y,v,b,g,k,x,_,j;const t=Fn(e==null?void 0:e.data),n=fo(e==null?void 0:e.data),r=t==="image"?n:Di(n),i=t==="image"?"":ma(r,t),[o,a]=h.useState(""),[l,c]=h.useState(!1);h.useEffect(()=>{var P;let N=!1;return i?(c(!0),a(""),gl(((P=e==null?void 0:e.data)==null?void 0:P.flowParams)||{},i).then(T=>{N||a(T)}).catch(()=>{N||a("")}).finally(()=>{N||c(!1)}),()=>{N=!0}):(a(""),c(!1),()=>{N=!0})},[i,(m=(d=e==null?void 0:e.data)==null?void 0:d.flowParams)==null?void 0:m.flowId,(v=(y=e==null?void 0:e.data)==null?void 0:y.flowParams)==null?void 0:v.flowSource,(g=(b=e==null?void 0:e.data)==null?void 0:b.flowParams)==null?void 0:g.archived,(k=e==null?void 0:e.data)==null?void 0:k.displayReloadKey]);const u=i?o:r,f=t==="html"?au(u):t==="react"?Lg(u):Di(u),p=Ua(t,f);return l?s.jsx("div",{className:"af-display-picker-preview__empty",children:"Loading"}):p?s.jsx("div",{className:"af-display-picker-preview__empty",children:p}):f.trim()?t==="html"||t==="react"?s.jsx("iframe",{title:((x=e==null?void 0:e.data)==null?void 0:x.label)||(e==null?void 0:e.id),sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:t==="react"?Wv(f):WM(f)}):t==="image"?s.jsx("img",{src:bf(f,(_=e==null?void 0:e.data)==null?void 0:_.flowParams),alt:((j=e==null?void 0:e.data)==null?void 0:j.label)||(e==null?void 0:e.id),loading:"lazy"}):t==="markdown"?s.jsx("div",{className:"af-display-picker-preview__markdown",children:s.jsx(hf,{content:f,basePath:i,resolveSrc:(N,P)=>{var T;return bf(N,(T=e==null?void 0:e.data)==null?void 0:T.flowParams,P)}})}):t==="chart"?s.jsx(Dv,{content:f}):t==="table"?s.jsx(Ov,{content:f}):t==="mermaid"?s.jsxs("div",{className:"af-display-picker-preview__diagram",children:[s.jsx(KM,{code:f}),s.jsx("pre",{children:f})]}):s.jsx("pre",{className:"af-display-picker-preview__pre",children:f}):s.jsx("div",{className:"af-display-picker-preview__empty",children:"No content"})}function UM({value:e,onChange:t,onUploadImage:n,readOnly:r=!1}){const i=h.useRef(null),o=h.useRef(null),a=h.useRef(null),[l,c]=h.useState(!1),[u,f]=h.useState({visible:!1,top:0,height:100}),p=h.useCallback(()=>{const g=i.current;if(!g)return;const k=Math.max(1,g.scrollHeight),x=Math.max(1,g.clientHeight),_=k>x+1,j=_?Math.max(12,x/k*100):100,N=Math.max(0,100-j),P=_?Math.min(N,g.scrollTop/Math.max(1,k-x)*N):0;f({visible:_,top:P,height:j})},[]);h.useEffect(()=>{const g=requestAnimationFrame(p),k=i.current;if(!k||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(g);const x=new ResizeObserver(p);return x.observe(k),()=>{cancelAnimationFrame(g),x.disconnect()}},[p,e]);const d=h.useCallback(g=>{const k=i.current;if(!k)return;const x=Math.max(0,k.scrollHeight-k.clientHeight);k.scrollTop=Math.min(1,Math.max(0,g))*x,p()},[p]),m=h.useCallback((g,k=0)=>{const x=a.current;if(!x)return 0;const _=x.getBoundingClientRect(),j=u.height/100*_.height,N=Math.max(1,_.height-j);return(g-_.top-k)/N},[u.height]),y=h.useCallback(g=>{if(!u.visible)return;g.preventDefault(),g.stopPropagation();const k=a.current;if(!k)return;const x=k.getBoundingClientRect(),_=u.top/100*x.height,j=u.height/100*x.height,P=g.clientY>=x.top+_&&g.clientY<=x.top+_+j?g.clientY-x.top-_:j/2;d(m(g.clientY,P));const T=E=>{E.preventDefault(),d(m(E.clientY,P))},z=()=>{window.removeEventListener("pointermove",T),window.removeEventListener("pointerup",z),window.removeEventListener("pointercancel",z)};window.addEventListener("pointermove",T),window.addEventListener("pointerup",z),window.addEventListener("pointercancel",z)},[m,d,u.height,u.top,u.visible]),v=h.useCallback(g=>{const k=String(e||""),x=i.current,_=Number((x==null?void 0:x.selectionStart)??k.length),j=Number((x==null?void 0:x.selectionEnd)??_),N=k.slice(0,_),P=k.slice(j),T=N&&!N.endsWith(`
|
|
243
|
+
`)?`
|
|
244
|
+
`:"",z=P&&!P.startsWith(`
|
|
245
|
+
`)?`
|
|
246
|
+
`:"",E=`${N}${T}${g}${z}${P}`;t==null||t(E),window.requestAnimationFrame(()=>{var D,L;const O=N.length+T.length+g.length;(D=i.current)==null||D.focus(),(L=i.current)==null||L.setSelectionRange(O,O)})},[t,e]),b=h.useCallback(async g=>{if(!r&&!(!g||l)){c(!0);try{const k=await(n==null?void 0:n(g)),x=String(k||"").trim();if(x){const _=String(g.name||"image").replace(/\.[^.]+$/g,"").trim()||"image";v(``)}}finally{c(!1)}}},[v,n,r,l]);return s.jsxs("div",{className:"af-work-display-editor nodrag nopan",onClick:g=>g.stopPropagation(),onDragOver:g=>{var x;Array.from(((x=g.dataTransfer)==null?void 0:x.items)||[]).some(_=>String((_==null?void 0:_.type)||"").startsWith("image/"))&&(g.preventDefault(),g.dataTransfer.dropEffect="copy")},onDrop:g=>{var x;const k=Array.from(((x=g.dataTransfer)==null?void 0:x.files)||[]).find(Om);k&&(g.preventDefault(),b(k))},children:[s.jsxs("div",{className:"af-work-display-editor__toolbar",children:[s.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:l||r,onClick:()=>{var g;return(g=o.current)==null?void 0:g.click()},"aria-label":"上传图片",title:"上传图片",children:s.jsx("span",{className:"material-symbols-outlined",children:l?"hourglass_top":"add_photo_alternate"})}),s.jsx("input",{ref:o,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:g=>{var x;const k=(x=g.target.files)==null?void 0:x[0];g.target.value="",k&&b(k)}})]}),s.jsx("textarea",{ref:i,className:"af-work-display-editor__textarea",value:e,onChange:g=>t==null?void 0:t(g.target.value),onScroll:p,onKeyDown:g=>{g.key==="Escape"&&g.stopPropagation()},placeholder:"输入 Markdown 内容",spellCheck:!1,readOnly:r}),s.jsx("div",{ref:a,className:"af-work-display-editor__scrollbar"+(u.visible?" af-work-display-editor__scrollbar--visible":""),onPointerDown:y,"aria-hidden":"true",children:s.jsx("span",{style:{height:`${u.height}%`,top:`${u.top}%`}})})]})}function SX({nodeId:e,data:t}){const n=t==null?void 0:t.nodeChatActive,r=!!(t!=null&&t.selected),i=(t==null?void 0:t.nodeChat)||{},o=Array.isArray(i.messages)?i.messages:[],a=String(i.draft||""),[l,c]=h.useState(a),u=h.useRef(!1),f=String(i.candidateContent||""),p=!!i.running,d=!!(t!=null&&t.readOnly),m=String(i.error||""),y=o.slice(-2);return h.useEffect(()=>{u.current||c(a)},[a]),!n&&!r?null:n?s.jsxs("div",{className:"af-work-node-chat nodrag nopan",onClick:v=>v.stopPropagation(),children:[s.jsxs("div",{className:"af-work-node-chat__head",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"继续微调"}),s.jsx("span",{children:(t==null?void 0:t.label)||e})]}),s.jsx("button",{type:"button",onClick:()=>{var v;return(v=t==null?void 0:t.onCloseNodeChat)==null?void 0:v.call(t)},"aria-label":"关闭节点微调",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),o.length>0||p||m?s.jsxs("div",{className:"af-work-node-chat__messages",children:[y.map((v,b)=>s.jsxs("div",{className:`af-work-node-chat__msg af-work-node-chat__msg--${v.role==="assistant"?"assistant":"user"}`,children:[s.jsx("span",{children:v.role==="assistant"?"AI":"你"}),s.jsx("p",{children:v.text})]},`${v.at||b}-${b}`)),p?s.jsx("div",{className:"af-work-node-chat__pending",children:"生成中..."}):null,m?s.jsx("div",{className:"af-work-node-chat__error",children:m}):null]}):null,s.jsxs("div",{className:"af-work-node-chat__composer",children:[s.jsx("button",{type:"button",className:"af-work-node-chat__add",disabled:p||d,"aria-label":"添加上下文",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"})}),s.jsx("textarea",{className:"af-work-node-chat__input",rows:2,value:l,disabled:p||d,placeholder:"描述你想怎么调整这个展示",onCompositionStart:()=>{u.current=!0},onCompositionEnd:v=>{var g;u.current=!1;const b=v.currentTarget.value;c(b),(g=t==null?void 0:t.onUpdateNodeChatDraft)==null||g.call(t,e,b)},onChange:v=>{var g;const b=v.target.value;c(b),u.current||(g=t==null?void 0:t.onUpdateNodeChatDraft)==null||g.call(t,e,b)},onKeyDown:v=>{var b,g;v.isComposing||(b=v.nativeEvent)!=null&&b.isComposing||v.keyCode===229||(v.metaKey||v.ctrlKey)&&v.key==="Enter"&&(v.preventDefault(),(g=t==null?void 0:t.onSendNodeChat)==null||g.call(t,e,l))}}),s.jsx("button",{type:"button",className:"af-work-node-chat__send",disabled:p||d||!l.trim(),onClick:()=>{var v;return(v=t==null?void 0:t.onSendNodeChat)==null?void 0:v.call(t,e,l)},"aria-label":"发送",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_upward"})})]}),f.trim()?s.jsx("div",{className:"af-work-node-chat__messages",children:s.jsxs("div",{className:"af-work-node-chat__msg af-work-node-chat__msg--assistant",children:[s.jsx("span",{children:"AI"}),s.jsx("p",{children:f})]})}):null]}):s.jsxs("button",{type:"button",className:"af-work-node-chat-anchor nodrag nopan",onClick:v=>{var b;v.stopPropagation(),(b=t==null?void 0:t.onToggleNodeChat)==null||b.call(t,e)},title:"微调这个节点","aria-label":"微调这个节点",children:[s.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__plus","aria-hidden":!0,children:"add"}),s.jsx("span",{className:"af-work-node-chat-anchor__label",children:"继续微调这个展示"}),s.jsx("span",{className:"material-symbols-outlined af-work-node-chat-anchor__expand","aria-hidden":!0,children:"open_in_full"})]})}function jX(e){return e==="mermaid"?"mmd":e==="ascii"?"txt":e==="html"?"html":e==="react"?"json":e==="image"?"txt":e==="chart"||e==="table"?"json":"md"}function NX(e){return String(e).trim().toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"").slice(0,80)||"display"}function _X(e){return String(e||"node").trim().replace(/[^a-zA-Z0-9._-]+/g,"_").replace(/^_+|_+$/g,"").slice(0,120)||"node"}function _C(e,t=""){const n=ma(e,t).replace(/^\/+/,"");return n.startsWith("outputs/")?n:""}function CX(e,t){const n=_X(e),r=new Set,i=Fn(t)||"";di(t==null?void 0:t.definitionId)&&r.add(`outputs/${n}`);const o=_C(fo(t),i);return o&&r.add(o),(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).some(c=>{const u=String((c==null?void 0:c.value)??(c==null?void 0:c.default)??"").trim().replace(/^\/+/,""),f=_C(u,i);return f&&r.add(f),u===`outputs/${n}`||u.startsWith(`outputs/${n}/`)})&&r.add(`outputs/${n}`),Array.from(r)}function CC(e,t){const n=Fn(t)||"markdown";return`outputs/${NX((t==null?void 0:t.label)||e||n)}.${jX(n)}`}async function GM({nodeId:e,data:t,filePath:n,content:r,setFileContent:i}){var o,a;if(n){const l=await Yb((t==null?void 0:t.flowParams)||{},n,r);i==null||i(r),(o=t==null?void 0:t.onSetDisplayNodeContent)==null||o.call(t,e,l,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已更新 ${l}`});return}(a=t==null?void 0:t.onSetDisplayNodeContent)==null||a.call(t,e,r,"replace",{logChat:!1,statusMessage:"已更新 Markdown 内容"})}function YM({id:e,data:t,selected:n,deleteNode:r}){var ee,re,se;const i=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],a=(Array.isArray(t==null?void 0:t.outputs)?t.outputs:[]).map((Q,le)=>({slot:Q,idx:le})).sort((Q,le)=>{var Se,Ue,lt,xt;const fe=String(((Se=Q.slot)==null?void 0:Se.name)||"").trim(),me=String(((Ue=le.slot)==null?void 0:Ue.name)||"").trim();if(fe==="next"&&me!=="next")return-1;if(me==="next"&&fe!=="next")return 1;const De=String(((lt=Q.slot)==null?void 0:lt.type)||"").trim(),Ce=String(((xt=le.slot)==null?void 0:xt.type)||"").trim();return De==="node"&&Ce!=="node"?-1:Ce==="node"&&De!=="node"?1:Q.idx-le.idx}),l=Fn(t),c=h.useRef(null),u=h.useRef(null),[f,p]=h.useState(0),[d,m]=h.useState(!1),[y,v]=h.useState(!1),[b,g]=h.useState(!1),[k,x]=h.useState(""),[_,j]=h.useState(""),[N,P]=h.useState(!1),[T,z]=h.useState(!1),E=h.useRef(null),O=fo(t),D=l==="markdown"?Di(O):"",L=l==="markdown"?ma(D,"markdown"):"",$=l==="markdown"?L?_:D:"",V=!!(t!=null&&t.readOnly),W=!!(t!=null&&t.displayPageMode);h.useEffect(()=>{let Q=!1;return l!=="markdown"||!L?(j(""),P(!1),()=>{Q=!0}):(P(!0),gl((t==null?void 0:t.flowParams)||{},L).then(le=>{Q||j(le)}).catch(le=>{var fe;Q||(j(""),(fe=t==null?void 0:t.onStatus)==null||fe.call(t,String(le.message||le)))}).finally(()=>{Q||P(!1)}),()=>{Q=!0})},[l,L,(ee=t==null?void 0:t.flowParams)==null?void 0:ee.flowId,(re=t==null?void 0:t.flowParams)==null?void 0:re.flowSource,(se=t==null?void 0:t.flowParams)==null?void 0:se.archived,t==null?void 0:t.displayReloadKey]),h.useEffect(()=>{if(!y)return;const Q=()=>v(!1);return window.addEventListener("pointerup",Q,!0),window.addEventListener("pointercancel",Q,!0),window.addEventListener("mouseup",Q,!0),window.addEventListener("blur",Q),()=>{window.removeEventListener("pointerup",Q,!0),window.removeEventListener("pointercancel",Q,!0),window.removeEventListener("mouseup",Q,!0),window.removeEventListener("blur",Q)}},[y]),h.useEffect(()=>{b||x(String($||""))},[$,b]);const F=(t==null?void 0:t.label)||(l==="mermaid"?"Mermaid":l==="ascii"?"ASCII":l==="html"?"HTML":l==="react"?"React App":l==="image"?"Image":l==="chart"?"Chart":l==="table"?"Table":"Markdown"),M=String((t==null?void 0:t.sourceNodeId)||e),H=(t==null?void 0:t.sharingDisplayNodeId)===M,A=t!=null&&t.displaySize&&Number(t.displaySize.width)>0&&Number(t.displaySize.height)>0?{width:Number(t.displaySize.width),height:Number(t.displaySize.height)}:null,X=h.useCallback(async()=>{var at,ze,Xe,Bt,Mt,Qt,de,ke,qe,st;if(l!=="html"||d)return;const Q=fo(t),le=ma(Q,l);let fe=Q;if(le)try{fe=await gl((t==null?void 0:t.flowParams)||{},le)}catch(Ee){m(!1),console.warn("Failed to read HTML display file before saving image.",Ee);return}const me=au(fe);if(!me.trim())return;const De=Ua(l,me);if(De){console.warn(De);return}const Ce=(ze=(at=u.current)==null?void 0:at.getBoundingClientRect)==null?void 0:ze.call(at),Se=(Bt=(Xe=c.current)==null?void 0:Xe.querySelector)==null?void 0:Bt.call(Xe,".af-work-display-body"),Ue=(Qt=(Mt=c.current)==null?void 0:Mt.querySelector)==null?void 0:Qt.call(Mt,".af-visible-scroll-frame__scroller"),lt=Math.round(Math.max(Number((Ce==null?void 0:Ce.width)||0),Number((A==null?void 0:A.width)||0),Number(((de=c.current)==null?void 0:de.clientWidth)||0),Number((Se==null?void 0:Se.clientWidth)||0),Number((Ue==null?void 0:Ue.clientWidth)||0),Math.max(320,Number((A==null?void 0:A.width)||960)-2))),xt=Math.round(Math.max(Number((Ce==null?void 0:Ce.height)||0),Number((A==null?void 0:A.height)||0),Number(((ke=c.current)==null?void 0:ke.clientHeight)||0),Number((Se==null?void 0:Se.clientHeight)||0),Number((Ue==null?void 0:Ue.clientHeight)||0),Math.max(180,Number((A==null?void 0:A.height)||640)-46)));m(!0);try{await wX({flowParams:(t==null?void 0:t.flowParams)||{},content:me,sourceFilePath:le,iframe:u.current,width:lt,height:xt,filename:pX((t==null?void 0:t.label)||e||"html-render","png"),snapshotElements:{card:c.current,displayBody:Se,scroller:Ue},displaySize:A}),(qe=t==null?void 0:t.onStatus)==null||qe.call(t,"已导出 HTML 展示截图")}catch(Ee){const rt=String((Ee==null?void 0:Ee.message)||Ee||"截图失败");(st=t==null?void 0:t.onStatus)==null||st.call(t,`HTML 截图失败:${rt}`),console.warn("Failed to save HTML display as PNG.",Ee)}finally{m(!1)}},[t,A==null?void 0:A.height,A==null?void 0:A.width,e,l,d]),q=h.useCallback(Q=>{var le;V||!Q||l!=="image"||(le=t==null?void 0:t.onUploadImageToDisplayNode)==null||le.call(t,e,Q)},[t,e,l,V]),B=h.useCallback(Q=>{var le,fe;(le=Q==null?void 0:Q.stopPropagation)==null||le.call(Q),!V&&((fe=t==null?void 0:t.onSetDisplayNodeContent)==null||fe.call(t,e,"","replace",{logChat:!1,reloadDisplay:!0,statusMessage:"已清空 Display 内容"}),l==="markdown"&&(x(""),g(!1)))},[t,e,l,V]),ne=h.useCallback(Q=>{var me,De;V||l!=="image"||!(Array.from(((me=Q.dataTransfer)==null?void 0:me.files)||[]).some(Om)||Array.from(((De=Q.dataTransfer)==null?void 0:De.items)||[]).some(Ce=>String((Ce==null?void 0:Ce.type)||"").startsWith("image/")))||(Q.preventDefault(),Q.stopPropagation(),Q.dataTransfer.dropEffect="copy",z(!0))},[l,V]),ce=h.useCallback(Q=>{l==="image"&&(Q.currentTarget.contains(Q.relatedTarget)||z(!1))},[l]),K=h.useCallback(Q=>{var fe;if(l!=="image")return;const le=Array.from(((fe=Q.dataTransfer)==null?void 0:fe.files)||[]).find(Om);le&&(Q.preventDefault(),Q.stopPropagation(),z(!1),q(le))},[l,q]);return s.jsxs("div",{className:"af-work-display-card"+(A?" af-work-display-card--sized":"")+(n?" af-work-display-card--selected":"")+(y?" af-work-display-card--resizing":"")+(T?" af-work-display-card--image-drop":"")+(W?" af-work-display-card--presentation":"")+(t!=null&&t.isExecuting?" af-work-display-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-display-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-display-card--failed":""),style:A?{width:A.width,height:A.height}:void 0,ref:c,onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,onDragOver:ne,onDragLeave:ce,onDrop:K,children:[s.jsx(kv,{className:"af-work-display-resize nodrag",position:"bottom-right",minWidth:320,minHeight:180,onResizeStart:()=>v(!0),onResizeEnd:()=>v(!1),children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),i.map((Q,le)=>{if(Q.showOnNode===!1)return null;const fe=`${4.15+le*1.75}rem`,me=Q.name||`#${le+1}`;return s.jsxs(h.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:fe},children:me}),s.jsx(ar,{type:"target",position:Ge.Left,id:`input-${le}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:fe,background:Bn(Q.type)},title:`${me} · ${Q.type}`})]},`in-${le}`)}),a.map(({slot:Q,idx:le},fe)=>{if(Q.showOnNode===!1)return null;const me=`${4.15+fe*1.75}rem`,De=Q.name||`#${le+1}`;return s.jsxs(h.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:me},children:De}),s.jsx(ar,{type:"source",position:Ge.Right,id:`output-${le}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:me,background:Bn(Q.type)},title:`${De} · ${Q.type}`})]},`out-${le}`)}),s.jsxs("div",{className:"af-work-display-card__head",children:[s.jsxs("div",{className:"af-work-display-card__title",children:[s.jsx("span",{className:"material-symbols-outlined",children:VM(l)}),s.jsx("strong",{children:F}),s.jsx("span",{children:(t==null?void 0:t.definitionId)||"display"})]}),l==="html"?s.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:Q=>Q.stopPropagation(),children:[s.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var Q,le,fe,me;try{(me=(fe=(le=(Q=u.current)==null?void 0:Q.contentWindow)==null?void 0:le.history)==null?void 0:fe.back)==null||me.call(fe)}catch{}},"aria-label":"后退",title:"后退",children:s.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),s.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{var Q,le,fe,me;try{(me=(fe=(le=(Q=u.current)==null?void 0:Q.contentWindow)==null?void 0:le.history)==null?void 0:fe.forward)==null||me.call(fe)}catch{}},"aria-label":"前进",title:"前进",children:s.jsx("span",{className:"material-symbols-outlined",children:"arrow_forward"})}),s.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>p(Q=>Q+1),"aria-label":"刷新",title:"刷新",children:s.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),s.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:d,onClick:X,"aria-label":"截图另存为图片",title:"截图另存为图片",children:s.jsx("span",{className:"material-symbols-outlined",children:d?"hourglass_empty":"photo_camera"})})]}):null,l==="markdown"?b?s.jsxs("div",{className:"af-work-display-card__html-controls nodrag",onClick:Q=>Q.stopPropagation(),children:[s.jsx("button",{type:"button",className:"af-work-display-card__action",disabled:V||N,onClick:async()=>{var Q;try{await GM({nodeId:e,data:t,filePath:L,content:k,setFileContent:j}),g(!1)}catch(le){(Q=t==null?void 0:t.onStatus)==null||Q.call(t,String(le.message||le))}},"aria-label":"保存并预览",title:"保存并预览",children:s.jsx("span",{className:"material-symbols-outlined",children:"done"})}),s.jsx("button",{type:"button",className:"af-work-display-card__action",onClick:()=>{x(String($||"")),g(!1)},"aria-label":"取消编辑",title:"取消编辑",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}):s.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V||N,onClick:Q=>{Q.stopPropagation(),x(String($||"")),g(!0)},"aria-label":"编辑 Markdown",title:"编辑 Markdown",children:s.jsx("span",{className:"material-symbols-outlined",children:"edit"})}):null,l==="image"?s.jsxs(s.Fragment,{children:[s.jsx("input",{ref:E,className:"af-hidden-file-input",type:"file",accept:"image/*",onChange:Q=>{var fe;const le=(fe=Q.target.files)==null?void 0:fe[0];Q.target.value="",le&&q(le)}}),s.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V,onClick:Q=>{var le;Q.stopPropagation(),(le=E.current)==null||le.click()},"aria-label":"上传图片",title:"上传图片",children:s.jsx("span",{className:"material-symbols-outlined",children:"upload"})})]}):null,s.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",onClick:Q=>{var le;Q.stopPropagation(),(le=t==null?void 0:t.onOpenDisplayPreview)==null||le.call(t,M)},"aria-label":"全屏预览",title:"全屏预览",children:s.jsx("span",{className:"material-symbols-outlined",children:"fullscreen"})}),s.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:H,onClick:Q=>{var le;Q.stopPropagation(),(le=t==null?void 0:t.onShareDisplayNode)==null||le.call(t,M)},"aria-label":"分享展示",title:"分享展示",children:s.jsx("span",{className:"material-symbols-outlined",children:H?"hourglass_empty":"ios_share"})}),s.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V,onClick:B,"aria-label":"清空内容",title:"清空内容",children:s.jsx("span",{className:"material-symbols-outlined",children:"delete_sweep"})}),s.jsx("button",{type:"button",className:"af-work-display-card__action nodrag",disabled:V,onClick:()=>{var Q;return(Q=t==null?void 0:t.onSaveDisplayNodeToFile)==null?void 0:Q.call(t,e,t)},"aria-label":"另存为文件",title:"另存为文件",children:s.jsx("span",{className:"material-symbols-outlined",children:"save"})}),s.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:V,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),l==="markdown"&&b?s.jsx(UM,{value:k,onChange:x,onUploadImage:t==null?void 0:t.onUploadWorkspaceImage,readOnly:V}):s.jsx(qM,{data:t,flowParams:t==null?void 0:t.flowParams,htmlFrameRef:u,htmlFrameVersion:f}),s.jsx(SX,{nodeId:e,data:t})]})}function AX({id:e,data:t,selected:n,deleteNode:r}){var f,p,d;const i=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=((p=(f=t==null?void 0:t.runningRunNodeIds)==null?void 0:f.has)==null?void 0:p.call(f,e))||((d=t==null?void 0:t.runningRunNodeIds)==null?void 0:d[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",l=(t==null?void 0:t.optimizingRun)===!0,c=(t==null?void 0:t.nodeStatus)==="stopped",u=!!(t!=null&&t.readOnly);return s.jsxs("div",{className:"af-work-run-card"+(n?" af-work-run-card--selected":"")+(a?" af-work-run-card--running":"")+(t!=null&&t.isExecuting?" af-work-run-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-run-card--failed":"")+(c?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[i.map((m,y)=>{if(m.showOnNode===!1)return null;const v=`${2.25+y*1.75}rem`,b=m.name||`#${y+1}`;return s.jsxs(h.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:v},children:b}),s.jsx(ar,{type:"target",position:Ge.Left,id:`input-${y}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:v,background:Bn(m.type)},title:`${b} · ${m.type}`})]},`in-${y}`)}),o.map((m,y)=>{if(m.showOnNode===!1)return null;const v=`${2.25+y*1.75}rem`,b=m.name||`#${y+1}`;return s.jsxs(h.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:v},children:b}),s.jsx(ar,{type:"source",position:Ge.Right,id:`output-${y}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:v,background:Bn(m.type)},title:`${b} · ${m.type}`})]},`out-${y}`)}),s.jsxs("div",{className:"af-work-run-card__head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"play_circle"}),s.jsx("strong",{children:(t==null?void 0:t.label)||"Run"}),s.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_run"}),s.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:u,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-work-run-card__actions",children:[s.jsxs("button",{type:"button",className:"af-work-run-card__button nodrag"+(a?" af-work-run-card__button--stop":""),disabled:u||l,onClick:m=>{var y,v;m.stopPropagation(),a?(y=t==null?void 0:t.onStopWorkspaceNode)==null||y.call(t,e):(v=t==null?void 0:t.onRunWorkspaceNode)==null||v.call(t,e)},children:[s.jsx("span",{className:"material-symbols-outlined",children:a?"stop_circle":"play_arrow"}),s.jsx("span",{children:a?"Stop":"Run line"})]}),s.jsx("button",{type:"button",className:"af-work-run-card__button af-work-run-card__optimize nodrag"+(l?" af-work-run-card__optimize--running":""),disabled:u||a||l,title:l?"正在优化":"为下游节点提前生成 implementation","aria-label":l?"正在优化":"优化",onClick:m=>{var y;m.stopPropagation(),(y=t==null?void 0:t.onOptimizeWorkspaceRun)==null||y.call(t,e)},children:s.jsx("span",{className:"material-symbols-outlined",children:l?"sync":"auto_fix_high"})}),s.jsx("button",{type:"button",className:"af-work-run-card__button af-work-run-card__logs nodrag",title:"查看执行日志","aria-label":"查看执行日志",onClick:m=>{var y;m.stopPropagation(),(y=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||y.call(t,{nodeId:e,runNodeId:e,scheduleNodeId:"",label:(t==null?void 0:t.label)||"Run"})},children:s.jsx("span",{className:"material-symbols-outlined",children:"article"})})]})]})}function EX({id:e,data:t,selected:n,deleteNode:r,skills:i,skillCollections:o,workspaces:a}){var st,Ee,rt,un,Kt,yt,pn;const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],u=qX(t),[f,p]=h.useState(u.task),d=h.useRef(!1),m=h.useRef(u.task),y=((Ee=(st=t==null?void 0:t.runningRunNodeIds)==null?void 0:st.has)==null?void 0:Ee.call(st,e))||((rt=t==null?void 0:t.runningRunNodeIds)==null?void 0:rt[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",v=(t==null?void 0:t.nodeStatus)==="stopped",b=!!(t!=null&&t.readOnly),g=Array.isArray(i)?i:[],k=Array.isArray(o)?o:[],x=h.useMemo(()=>(Array.isArray(a)?a:[]).map(ie=>({id:String((ie==null?void 0:ie.id)||""),label:String((ie==null?void 0:ie.label)||(ie==null?void 0:ie.name)||"知识库"),kind:(ie==null?void 0:ie.kind)==="git"?"git":"local",path:String((ie==null?void 0:ie.path)||""),repoUrl:String((ie==null?void 0:ie.repoUrl)||""),branch:String((ie==null?void 0:ie.branch)||""),mountPath:String((ie==null?void 0:ie.mountPath)||""),builtin:(ie==null?void 0:ie.builtin)===!0,exists:(ie==null?void 0:ie.exists)!==!1,type:String((ie==null?void 0:ie.type)||"")})).filter(ie=>ie.path),[a]),[_,j]=h.useState(!1),[N,P]=h.useState(""),[T,z]=h.useState(()=>new Set),[E,O]=h.useState(!1),[D,L]=h.useState(""),[$,V]=h.useState("config"),W=Og(t),F=!!W,M=n$(u.displayType),H=h.useMemo(()=>cX(t,M),[t==null?void 0:t.displaySize,t==null?void 0:t.nodeSize,t==null?void 0:t.inputs,t==null?void 0:t.input,M]),A=h.useMemo(()=>({...t,sourceNodeId:e,label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务",definitionId:M,displaySize:H,nodeSize:H,body:W,inputs:[{type:"text",name:M==="display_image"?"src":"content",value:W,default:W}],outputs:c.length?c:[{type:"node",name:"next",default:""}]}),[t,M,e,W,c,H]),X=Array.isArray((un=t==null?void 0:t.modelLists)==null?void 0:un.cursor)?t.modelLists.cursor:[],q=Array.isArray((Kt=t==null?void 0:t.modelLists)==null?void 0:Kt.opencode)?t.modelLists.opencode:[],B=Array.isArray((yt=t==null?void 0:t.modelLists)==null?void 0:yt.claudeCode)?t.modelLists.claudeCode:[],ne=Array.isArray((pn=t==null?void 0:t.modelLists)==null?void 0:pn.codex)?t.modelLists.codex:[],ce=h.useMemo(()=>new Set(X.map(Rs)),[X]),K=h.useMemo(()=>new Set(q.map(Rs)),[q]),ee=h.useMemo(()=>new Set(B.map(Rs)),[B]),re=h.useMemo(()=>new Set(ne.map(Rs)),[ne]),se=u.model,Q=h.useMemo(()=>se?se.startsWith("cursor:")||se.startsWith("opencode:")||se.startsWith("codex:")||se.startsWith("claude-code:")?se:ee.has(se)?`claude-code:${se}`:re.has(se)?`codex:${se}`:K.has(se)?`opencode:${se}`:ce.has(se)?`cursor:${se}`:se:"",[ee,re,ce,K,se]),le=se.startsWith("cursor:")?se.slice(7):se.startsWith("opencode:")?se.slice(9):se.startsWith("codex:")?se.slice(6):se.startsWith("claude-code:")?se.slice(12):se,fe=le,me=!!se&&!ce.has(fe)&&!K.has(fe)&&!ee.has(fe)&&!re.has(fe),De=h.useMemo(()=>new Set(u.skillKeys),[u.skillKeys]),Ce=h.useMemo(()=>new Map(g.map(ie=>[ie.key,ie])),[g]),Se=h.useMemo(()=>{const ie=new Set,Ne=k.map(He=>{const It=pa(He,g).map(jt=>Ce.get(jt)).filter(Boolean);for(const jt of It)ie.add(jt.key);return{...He,skills:It}}).filter(He=>He.skills.length>0),Ye=g.filter(He=>!ie.has(He.key));return{collectionGroups:Ne,ungrouped:Ye}},[k,Ce,g]);h.useEffect(()=>{z(ie=>{let Ne=!1;const Ye=new Set(ie);for(const He of Se.collectionGroups)Ye.has(He.id)||(Ye.add(He.id),Ne=!0);return Ne?Ye:ie})},[Se.collectionGroups]);const Ue=h.useMemo(()=>{const ie=N.trim().toLowerCase();if(!ie)return Se;const Ne=He=>[He==null?void 0:He.key,He==null?void 0:He.name,He==null?void 0:He.description].map(It=>String(It||"").toLowerCase()).join(" ").includes(ie);return{collectionGroups:Se.collectionGroups.map(He=>{const It=[He==null?void 0:He.id,He==null?void 0:He.name,He==null?void 0:He.description].map(jt=>String(jt||"").toLowerCase()).join(" ").includes(ie);return{...He,skills:It?He.skills:He.skills.filter(Ne)}}).filter(He=>He.skills.length>0),ungrouped:Se.ungrouped.filter(Ne)}},[Se,N]),lt=Jb(_,[Ue.collectionGroups.length,Ue.ungrouped.length,T.size,u.skillKeys.length,N]),xt=h.useMemo(()=>{const ie=D.trim().toLowerCase();return ie?x.filter(Ne=>[Ne.id,Ne.label,Ne.path,Ne.repoUrl,Ne.branch,Ne.mountPath,Ne.type].join(" ").toLowerCase().includes(ie)):x},[x,D]),at=h.useMemo(()=>o$(u.knowledgeContext),[u.knowledgeContext]),ze=h.useMemo(()=>new Set(at.map(ie=>ie.id||ie.path||ie.repoPath).filter(Boolean)),[at]),Xe=Jb(E,[xt.length,at.length,D]);h.useEffect(()=>{u.task!==m.current&&(m.current=u.task,d.current||p(u.task))},[u.task]),h.useEffect(()=>{if(!F){V("config");return}y||V("result")},[F,W,y]),h.useEffect(()=>{var Ne,Ye;if(!($==="result"&&F))return;(Ne=t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize)==null||Ne.call(t,e,H),(Ye=t==null?void 0:t.onRefreshNodeInternals)==null||Ye.call(t,e);const ie=window.setTimeout(()=>{var He;return(He=t==null?void 0:t.onRefreshNodeInternals)==null?void 0:He.call(t,e)},120);return()=>window.clearTimeout(ie)},[t==null?void 0:t.onEnsureWorkspaceNodeDisplaySize,t==null?void 0:t.onRefreshNodeInternals,M,F,e,W,H,$]);const Bt=ie=>{var Ne;(Ne=t==null?void 0:t.onChangeContextRunConfig)==null||Ne.call(t,e,{...u,task:f,...ie})},Mt=(ie=f)=>{var Ye;const Ne=String(ie??"");Ne!==u.task&&(m.current=Ne,(Ye=t==null?void 0:t.onChangeContextRunConfig)==null||Ye.call(t,e,{...u,task:Ne}))},Qt=(ie,Ne)=>{const Ye=new Set(u.skillKeys);for(const He of ie){const It=String(He||"").trim();It&&(Ne?Ye.add(It):Ye.delete(It))}Bt({skillKeys:Array.from(Ye)})},de=ie=>{z(Ne=>{const Ye=new Set(Ne);return Ye.has(ie)?Ye.delete(ie):Ye.add(ie),Ye})},ke=(ie,Ne)=>{const Ye=(ie==null?void 0:ie.id)||(ie==null?void 0:ie.path)||"";if(!Ye)return;const He=x.filter(It=>{const jt=It.id||It.path||"";return jt===Ye?Ne:ze.has(jt)});Bt({knowledgeContext:Dg(He)})},qe=()=>{Bt({knowledgeContext:null})};return $==="result"&&F?s.jsx(YM,{id:e,data:{...A,selected:t==null?void 0:t.selected,onSelectNodePointerDown:t==null?void 0:t.onSelectNodePointerDown},selected:n,deleteNode:r}):s.jsxs("div",{className:"af-work-context-run-card"+(n?" af-work-context-run-card--selected":"")+($==="result"&&F?" af-work-context-run-card--result":"")+(y?" af-work-context-run-card--running":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-context-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-context-run-card--failed":"")+(v?" af-work-context-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((ie,Ne)=>{if(ie.showOnNode===!1)return null;const Ye=`${2.25+Ne*1.75}rem`,He=ie.name||`#${Ne+1}`;return s.jsxs(h.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:Ye},children:He}),s.jsx(ar,{type:"target",position:Ge.Left,id:`input-${Ne}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:Ye,background:Bn(ie.type)},title:`${He} · ${ie.type}`})]},`in-${Ne}`)}),c.map((ie,Ne)=>{if(ie.showOnNode===!1)return null;const Ye=`${2.25+Ne*1.75}rem`,He=ie.name||`#${Ne+1}`;return s.jsxs(h.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:Ye},children:He}),s.jsx(ar,{type:"source",position:Ge.Right,id:`output-${Ne}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:Ye,background:Bn(ie.type)},title:`${He} · ${ie.type}`})]},`out-${Ne}`)}),s.jsxs("div",{className:"af-work-context-run-card__head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"automation"}),s.jsx("strong",{children:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务"}),s.jsxs("div",{className:"af-work-context-run-card__model-wrap nodrag",onPointerDown:ie=>ie.stopPropagation(),onMouseDown:ie=>ie.stopPropagation(),onClick:ie=>ie.stopPropagation(),children:[s.jsxs("select",{className:"af-work-context-run-card__model",value:Q,disabled:b,"aria-label":"模型",title:le||"默认模型",onChange:ie=>Bt({model:ie.target.value}),children:[s.jsx("option",{value:"",children:"默认"}),me?s.jsx("option",{value:se,children:se}):null,X.length?s.jsx("optgroup",{label:"Cursor",children:X.map(ie=>s.jsx("option",{value:`cursor:${Rs(ie)}`,children:Rs(ie)},`context-cursor-${ie}`))}):null,q.length?s.jsx("optgroup",{label:"OpenCode",children:q.map(ie=>s.jsx("option",{value:`opencode:${Rs(ie)}`,children:Rs(ie)},`context-opencode-${ie}`))}):null,ne.length?s.jsx("optgroup",{label:"Codex",children:ne.map(ie=>s.jsx("option",{value:`codex:${Rs(ie)}`,children:Rs(ie)},`context-codex-${ie}`))}):null,B.length?s.jsx("optgroup",{label:"Claude Code",children:B.map(ie=>s.jsx("option",{value:`claude-code:${Rs(ie)}`,children:Rs(ie)},`context-claude-${ie}`))}):null]}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"expand_more"})]}),s.jsx("span",{className:"af-work-context-run-card__kind",children:di(t==null?void 0:t.definitionId)?"workspace_one_click_task":(t==null?void 0:t.definitionId)||"workspace_one_click_task"}),F?s.jsxs("div",{className:"af-work-context-run-card__view-switch nodrag",onClick:ie=>ie.stopPropagation(),children:[s.jsx("button",{type:"button",className:$==="config"?"is-active":"",onClick:()=>V("config"),"aria-label":"切换到任务配置",children:s.jsx("span",{className:"material-symbols-outlined",children:"tune"})}),s.jsx("button",{type:"button",className:$==="result"?"is-active":"",onClick:()=>V("result"),"aria-label":"切换到展示结果",children:s.jsx("span",{className:"material-symbols-outlined",children:"preview"})})]}):null,s.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:b,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-work-context-run-card__body nodrag",children:[s.jsxs(s.Fragment,{children:[s.jsx("textarea",{value:f,disabled:b,placeholder:"输入任务,例如:基于选中的知识库总结需求并生成展示页",onCompositionStart:()=>{d.current=!0},onCompositionEnd:ie=>{d.current=!1,p(ie.currentTarget.value),Mt(ie.currentTarget.value)},onChange:ie=>{p(ie.target.value)},onBlur:ie=>Mt(ie.currentTarget.value)}),s.jsxs("div",{className:"af-work-context-run-card__grid",children:[s.jsxs("div",{className:"af-work-context-run-card__skills",children:[s.jsxs("button",{type:"button",disabled:b,className:"af-work-context-run-card__select",onClick:ie=>{var Ne;ie.stopPropagation(),_||(Ne=t==null?void 0:t.onRefreshSkills)==null||Ne.call(t),j(Ye=>!Ye)},children:[s.jsx("span",{className:"material-symbols-outlined",children:"extension"}),s.jsx("span",{children:u.skillKeys.length?`${u.skillKeys.length} skills`:"Skills"}),s.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})]}),_?s.jsxs("div",{className:"af-work-context-run-card__skills-menu",onClick:ie=>ie.stopPropagation(),children:[s.jsxs("div",{className:"af-work-load-skills-search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",value:N,onChange:ie=>P(ie.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),N?s.jsx("button",{type:"button",onClick:()=>P(""),"aria-label":"清空搜索",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),s.jsxs("div",{ref:lt.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:lt.updateMenuScrollbar,children:[Ue.collectionGroups.map(ie=>{const Ne=ie.skills.map(jt=>jt.key),Ye=Ne.filter(jt=>De.has(jt)).length,He=Ne.length>0&&Ye===Ne.length,It=T.has(ie.id);return s.jsxs("section",{className:"af-work-load-skills-menu__group"+(It?" af-work-load-skills-menu__group--collapsed":""),children:[s.jsxs("div",{className:"af-work-load-skills-menu__group-head",children:[s.jsx("input",{type:"checkbox",checked:He,disabled:b,onChange:jt=>Qt(Ne,jt.target.checked),"aria-label":`选择 ${ie.name}`}),s.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>de(ie.id),"aria-expanded":!It,children:s.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[s.jsx("span",{children:ie.name}),ie.description?s.jsx("em",{children:ie.description}):null]})}),s.jsxs("small",{children:[Ye,"/",Ne.length]}),s.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>de(ie.id),"aria-label":It?`展开 ${ie.name}`:`收起 ${ie.name}`,children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:It?"chevron_right":"expand_more"})})]}),It?null:s.jsx("div",{className:"af-work-load-skills-menu__options",children:ie.skills.map(jt=>s.jsxs("label",{className:"af-work-load-skills-menu__option",children:[s.jsx("input",{type:"checkbox",checked:De.has(jt.key),disabled:b,onChange:cr=>Qt([jt.key],cr.target.checked)}),s.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[s.jsx("span",{className:"af-work-load-skills-menu__option-title",children:jt.name}),jt.description?s.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:jt.description}):null]})]},`${ie.id}:${jt.key}`))})]},ie.id)}),Ue.ungrouped.length>0?s.jsxs("section",{className:"af-work-load-skills-menu__group",children:[s.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[s.jsx("span",{children:"Ungrouped"}),s.jsx("small",{children:Ue.ungrouped.length})]}),s.jsx("div",{className:"af-work-load-skills-menu__options",children:Ue.ungrouped.map(ie=>s.jsxs("label",{className:"af-work-load-skills-menu__option",children:[s.jsx("input",{type:"checkbox",checked:De.has(ie.key),disabled:b,onChange:Ne=>Qt([ie.key],Ne.target.checked)}),s.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[s.jsx("span",{className:"af-work-load-skills-menu__option-title",children:ie.name}),ie.description?s.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:ie.description}):null]})]},`ungrouped:${ie.key}`))})]}):null,Ue.collectionGroups.length===0&&Ue.ungrouped.length===0?s.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Skills"}):null,s.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>Bt({skillKeys:[]}),children:"清空"})]}),s.jsx("div",{ref:lt.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(lt.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:lt.handleScrollbarPointerDown,"aria-hidden":"true",children:s.jsx("span",{style:{height:`${lt.scrollbar.height}%`,top:`${lt.scrollbar.top}%`}})})]}):null]}),s.jsxs("div",{className:"af-work-context-run-card__workspace",children:[s.jsxs("button",{type:"button",disabled:b,className:"af-work-context-run-card__select",onClick:ie=>{var Ne;ie.stopPropagation(),E||(Ne=t==null?void 0:t.onRefreshWorkspaces)==null||Ne.call(t),O(Ye=>!Ye)},children:[s.jsx("span",{className:"material-symbols-outlined",children:at.length?"folder_open":"folder_off"}),s.jsx("span",{children:at.length?`${at.length} 知识库`:"知识库"}),s.jsx("span",{className:"material-symbols-outlined",children:"expand_more"})]}),E?s.jsxs("div",{className:"af-work-context-run-card__workspace-menu",onClick:ie=>ie.stopPropagation(),children:[s.jsxs("div",{className:"af-work-load-skills-search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",value:D,onChange:ie=>L(ie.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),D?s.jsx("button",{type:"button",onClick:()=>L(""),"aria-label":"清空搜索",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),s.jsxs("div",{ref:Xe.menuRef,className:"af-work-load-skills-menu af-work-context-run-card__menu-scroll",onScroll:Xe.updateMenuScrollbar,children:[s.jsxs("section",{className:"af-work-load-skills-menu__group",children:[s.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[s.jsx("span",{children:"知识库"}),s.jsx("small",{children:xt.length})]}),s.jsx("div",{className:"af-work-load-skills-menu__options",children:xt.map(ie=>s.jsxs("label",{className:"af-work-load-skills-menu__option",children:[s.jsx("input",{type:"checkbox",checked:ze.has(ie.id||ie.path),disabled:b,onChange:Ne=>ke(ie,Ne.target.checked)}),s.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[s.jsx("span",{className:"af-work-load-skills-menu__option-title",children:ie.label}),s.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[ie.kind==="git"&&ie.repoUrl?`${ie.repoUrl}${ie.branch?` · ${ie.branch}`:""}${ie.mountPath?` · ${ie.mountPath}`:""}`:ie.path,ie.exists?"":" · 路径未就绪"]})]})]},`${ie.id}:${ie.path}`))})]}),xt.length===0?s.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的知识库"}):null,s.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:qe,children:"清空知识库"})]}),s.jsx("div",{ref:Xe.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(Xe.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:Xe.handleScrollbarPointerDown,"aria-hidden":"true",children:s.jsx("span",{style:{height:`${Xe.scrollbar.height}%`,top:`${Xe.scrollbar.top}%`}})})]}):null]}),s.jsxs("select",{value:u.displayType,disabled:b,onChange:ie=>Bt({displayType:ie.target.value}),children:[s.jsx("option",{value:"markdown",children:"Markdown"}),s.jsx("option",{value:"html",children:"HTML"}),s.jsx("option",{value:"react",children:"React"}),s.jsx("option",{value:"table",children:"Table"}),s.jsx("option",{value:"chart",children:"Chart"}),s.jsx("option",{value:"ascii",children:"ASCII"}),s.jsx("option",{value:"mermaid",children:"Mermaid"})]})]}),W?s.jsx("pre",{className:"af-work-context-run-card__preview",children:W.slice(0,520)}):null]}),s.jsxs("div",{className:"af-work-context-run-card__actions",children:[s.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-context-run-card__run nodrag"+(y?" af-work-run-card__button--stop":""),disabled:b,onClick:ie=>{var Ne,Ye;ie.stopPropagation(),Mt(),y?(Ne=t==null?void 0:t.onStopWorkspaceNode)==null||Ne.call(t,e):(Ye=t==null?void 0:t.onRunWorkspaceNode)==null||Ye.call(t,e)},children:[s.jsx("span",{className:"material-symbols-outlined",children:y?"stop_circle":"play_arrow"}),s.jsx("span",{children:y?"Stop":"Run"})]}),s.jsx("button",{type:"button",className:"af-work-run-card__button af-work-context-run-card__logs nodrag",onClick:ie=>{var Ne;ie.stopPropagation(),(Ne=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||Ne.call(t,{nodeId:e,runNodeId:e,scheduleNodeId:"",label:t!=null&&t.label&&t.label!=="Context Run"?t.label:"一键任务"})},children:s.jsx("span",{className:"material-symbols-outlined",children:"article"})})]})]})]})}function IX({id:e,data:t,selected:n,deleteNode:r}){var P,T,z;const i=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],o=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],a=Jv((t==null?void 0:t.body)||""),[l,c]=h.useState(a.cron),u=(t==null?void 0:t.scheduledRunState)||{},f=((T=(P=t==null?void 0:t.runningRunNodeIds)==null?void 0:P.has)==null?void 0:T.call(P,e))||((z=t==null?void 0:t.runningRunNodeIds)==null?void 0:z[e])===!0||(t==null?void 0:t.isExecuting)||(t==null?void 0:t.nodeStatus)==="running",p=(t==null?void 0:t.optimizingRun)===!0,d=(t==null?void 0:t.nodeStatus)==="stopped",m=!!(t!=null&&t.readOnly),y=E=>{var O;(O=t==null?void 0:t.onChangeScheduledRunConfig)==null||O.call(t,e,{...a,...E})},v=E=>{y({scheduleType:E,cron:gd(E,a.time,a.weekday,a.monthDay,a.cron)})},b=E=>{y({time:E,cron:gd(a.scheduleType,E,a.weekday,a.monthDay,a.cron)})},[g,k]=Yv(a.time).split(":"),x=(E,O)=>{b(`${Zo(E,9,0,23)}:${Zo(O,0,0,59)}`)},_=E=>{y({weekday:E,cron:gd(a.scheduleType,a.time,E,a.monthDay,a.cron)})},j=E=>{y({monthDay:E,cron:gd(a.scheduleType,a.time,a.weekday,E,a.cron)})};h.useEffect(()=>{c(a.cron)},[a.cron,e]);const N=()=>{m||l===a.cron||y({cron:l})};return s.jsxs("div",{className:"af-work-run-card af-work-schedule-card"+(n?" af-work-run-card--selected":"")+(a.enabled?" af-work-schedule-card--enabled":"")+(f?" af-work-run-card--running":"")+(t!=null&&t.isExecuting?" af-work-run-card--executing":"")+((t==null?void 0:t.nodeStatus)==="success"?" af-work-run-card--done":"")+((t==null?void 0:t.nodeStatus)==="failed"?" af-work-run-card--failed":"")+(d?" af-work-run-card--stopped":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[i.map((E,O)=>{if(E.showOnNode===!1)return null;const D=`${2.25+O*1.75}rem`,L=E.name||`#${O+1}`;return s.jsxs(h.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:D},children:L}),s.jsx(ar,{type:"target",position:Ge.Left,id:`input-${O}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:D,background:Bn(E.type)},title:`${L} · ${E.type}`})]},`in-${O}`)}),o.map((E,O)=>{if(E.showOnNode===!1)return null;const D=`${2.25+O*1.75}rem`,L=E.name||`#${O+1}`;return s.jsxs(h.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:D},children:L}),s.jsx(ar,{type:"source",position:Ge.Right,id:`output-${O}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:D,background:Bn(E.type)},title:`${L} · ${E.type}`})]},`out-${O}`)}),s.jsxs("div",{className:"af-work-run-card__head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"event_repeat"}),s.jsx("strong",{children:(t==null?void 0:t.label)||"Scheduled Run"}),s.jsx("span",{children:(t==null?void 0:t.definitionId)||"workspace_scheduled_run"}),s.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",disabled:m,onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-work-schedule-card__body nodrag",children:[s.jsxs("label",{className:"af-work-schedule-card__toggle",children:[s.jsx("input",{type:"checkbox",checked:a.enabled,disabled:m,onChange:E=>y({enabled:E.target.checked})}),s.jsx("span",{children:a.enabled?"定时开启":"定时关闭"})]}),s.jsxs("label",{className:"af-work-schedule-card__field",children:[s.jsx("span",{children:"频率"}),s.jsxs("select",{value:a.scheduleType,disabled:m,onChange:E=>v(E.target.value),children:[s.jsx("option",{value:"daily",children:"每天"}),s.jsx("option",{value:"weekly",children:"每周"}),s.jsx("option",{value:"monthly",children:"每月"}),s.jsx("option",{value:"custom",children:"高级 Cron"})]})]}),a.scheduleType!=="custom"?s.jsxs("label",{className:"af-work-schedule-card__field",children:[s.jsx("span",{children:"时间"}),s.jsxs("div",{className:"af-work-schedule-time-selects",children:[s.jsx("select",{value:g,disabled:m,"aria-label":"小时",onChange:E=>x(E.target.value,k),children:Array.from({length:24},(E,O)=>Zo(O,0,0,23)).map(E=>s.jsxs("option",{value:E,children:[E," 时"]},E))}),s.jsx("select",{value:k,disabled:m,"aria-label":"分钟",onChange:E=>x(g,E.target.value),children:Array.from({length:12},(E,O)=>Zo(O*5,0,0,59)).map(E=>s.jsxs("option",{value:E,children:[E," 分"]},E))})]})]}):null,a.scheduleType==="weekly"?s.jsxs("label",{className:"af-work-schedule-card__field",children:[s.jsx("span",{children:"星期"}),s.jsxs("select",{value:a.weekday,disabled:m,onChange:E=>_(E.target.value),children:[s.jsx("option",{value:1,children:"周一"}),s.jsx("option",{value:2,children:"周二"}),s.jsx("option",{value:3,children:"周三"}),s.jsx("option",{value:4,children:"周四"}),s.jsx("option",{value:5,children:"周五"}),s.jsx("option",{value:6,children:"周六"}),s.jsx("option",{value:0,children:"周日"})]})]}):null,a.scheduleType==="monthly"?s.jsxs("label",{className:"af-work-schedule-card__field",children:[s.jsx("span",{children:"日期"}),s.jsx("select",{value:a.monthDay,disabled:m,onChange:E=>j(E.target.value),children:Array.from({length:31},(E,O)=>O+1).map(E=>s.jsxs("option",{value:E,children:[E," 日"]},E))})]}):null,a.scheduleType==="custom"?s.jsxs("label",{className:"af-work-schedule-card__field",children:[s.jsx("span",{children:"Cron"}),s.jsx("input",{type:"text",value:l,disabled:m,spellCheck:!1,placeholder:xf,onChange:E=>c(E.target.value),onBlur:N,onKeyDown:E=>{E.key==="Enter"&&E.currentTarget.blur()}})]}):null,s.jsxs("div",{className:"af-work-schedule-card__meta",children:[s.jsxs("span",{children:[JJ(a.scheduleType)," ",a.scheduleType==="custom"?"":a.time]}),s.jsxs("span",{children:["Next ",YJ(u.nextAt)]}),s.jsx("span",{children:f?"running":u.lastStatus||"idle"})]}),u.lastError?s.jsx("div",{className:"af-work-schedule-card__error",children:u.lastError}):null,s.jsxs("div",{className:"af-work-schedule-card__actions",children:[s.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__run-now nodrag"+(f?" af-work-run-card__button--stop":""),disabled:m||p,onClick:E=>{var O,D;E.stopPropagation(),f?(O=t==null?void 0:t.onStopWorkspaceNode)==null||O.call(t,e):(D=t==null?void 0:t.onRunWorkspaceNode)==null||D.call(t,e)},children:[s.jsx("span",{className:"material-symbols-outlined",children:f?"stop_circle":"play_arrow"}),s.jsx("span",{children:f?"停止":"立即运行"})]}),s.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__optimize nodrag"+(p?" af-work-schedule-card__optimize--running":""),disabled:m||f||p,title:"为下游节点提前生成 implementation",onClick:E=>{var O;E.stopPropagation(),(O=t==null?void 0:t.onOptimizeWorkspaceSchedule)==null||O.call(t,e)},children:[s.jsx("span",{className:"material-symbols-outlined",children:p?"sync":"auto_fix_high"}),s.jsx("span",{children:p?"优化中":"优化"})]}),s.jsxs("button",{type:"button",className:"af-work-run-card__button af-work-schedule-card__logs nodrag",onClick:E=>{var O;E.stopPropagation(),(O=t==null?void 0:t.onOpenWorkspaceRunLogs)==null||O.call(t,{nodeId:e,scheduleNodeId:e,runNodeId:u.targetRunNodeId||e,lastRunId:u.lastRunId||"",label:(t==null?void 0:t.label)||"Scheduled Run"})},children:[s.jsx("span",{className:"material-symbols-outlined",children:"article"}),s.jsx("span",{children:"日志"})]})]})]})]})}function PX({id:e,data:t,selected:n,deleteNode:r}){const{setNodes:i}=su(),o=!!(t!=null&&t.readOnly),a=qb(t==null?void 0:t.nodeSize)||{width:fl,height:pl},l=h.useCallback(c=>{var u,f;c.button!==0||c.metaKey||c.ctrlKey||c.shiftKey||(f=(u=c.target)==null?void 0:u.closest)!=null&&f.call(u,".af-work-group-node__resize, .af-work-group-node__delete")||i(p=>QM(p,e))},[e,i]);return s.jsxs("div",{className:"af-work-group-node"+(n?" af-work-group-node--selected":""),style:{width:a.width,height:a.height},onPointerDownCapture:l,children:[o?null:s.jsx(kv,{className:"af-work-group-node__resize nodrag",minWidth:fl,minHeight:pl,position:"bottom-right",children:s.jsx("span",{className:"material-symbols-outlined",children:"open_in_full"})}),s.jsxs("div",{className:"af-work-group-node__title nodrag",children:[s.jsx("span",{children:(t==null?void 0:t.title)||(t==null?void 0:t.label)||"Group"}),s.jsx("button",{type:"button",className:"af-work-group-node__delete",disabled:o,onClick:c=>{c.stopPropagation(),r==null||r(e)},"aria-label":"删除分组",title:"删除分组",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]})]})}function TX(e){var y,v,b,g,k,x,_,j,N,P,T,z,E,O,D,L,$,V,W,F,M,H,A,X,q,B,ne,ce;const{setEdges:t,setNodes:n}=su(),r=(y=e.data)==null?void 0:y.onSyncNodePropDraft,i=!!((v=e.data)!=null&&v.readOnly),[o,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,c=h.useCallback(K=>{var se,Q,le;if(i)return;(Q=(se=e.data)==null?void 0:se.onCleanupWorkspaceNodeOutputs)==null||Q.call(se,K,e.data);const ee=di((le=e.data)==null?void 0:le.definitionId)?r$(K):"",re=new Set([K,ee].filter(Boolean));n(fe=>fe.filter(me=>!re.has(me.id))),t(fe=>fe.filter(me=>!re.has(me.source)&&!re.has(me.target)))},[e.data,i,t,n]),u=h.useCallback(K=>{var ee,re;K.button!==0||K.metaKey||K.ctrlKey||K.shiftKey||(re=(ee=K.target)==null?void 0:ee.closest)!=null&&re.call(ee,".react-flow__handle, .af-work-display-resize")||(n(se=>QM(se,e.id)),t(se=>LX(se)))},[e.id,t,n]),f=h.useCallback((K,ee)=>{i||(n(re=>re.map(se=>se.id===K?{...se,data:{...se.data,model:ee}}:se)),r==null||r(K,{model:ee}))},[i,n,r]),p=h.useCallback((K,ee)=>{i||(n(re=>re.map(se=>{var le;if(se.id!==K)return se;const Q=Array.isArray((le=se.data)==null?void 0:le.outputs)&&se.data.outputs.length?se.data.outputs.map((fe,me)=>me===0?{...fe,default:ee,value:ee}:fe):[{type:"bool",name:"value",default:ee,value:ee}];return{...se,data:{...se.data,body:"",outputs:Q}}})),r==null||r(K,re=>({body:"",outputs:Array.isArray(re==null?void 0:re.outputs)&&re.outputs.length?re.outputs.map((Q,le)=>le===0?{...Q,default:ee,value:ee}:Q):[{type:"bool",name:"value",default:ee,value:ee}]})))},[i,n,r]),d=h.useCallback((K,ee)=>{i||(n(re=>re.map(se=>se.id===K?{...se,data:{...se.data,body:ee}}:se)),r==null||r(K,{body:ee}))},[i,n,r]),m=h.useCallback((K,ee)=>{if(i)return;const re=So(ee);n(se=>se.map(Q=>Q.id===K?{...Q,data:{...Q.data,images:re}}:Q)),r==null||r(K,{images:re})},[i,n,r]);return(g=e.data)!=null&&g.isWorkspaceGroup?s.jsx(PX,{...e,deleteNode:c}):ml((k=e.data)==null?void 0:k.definitionId)?s.jsx(YM,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((x=e.data)==null?void 0:x.definitionId)==="workspace_run"?s.jsx(AX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):((_=e.data)==null?void 0:_.definitionId)==="workspace_scheduled_run"?s.jsx(IX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c}):di((j=e.data)==null?void 0:j.definitionId)?s.jsx(EX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(N=e.data)==null?void 0:N.skills,skillCollections:(P=e.data)==null?void 0:P.skillCollections,workspaces:(T=e.data)==null?void 0:T.workspaceTargets}):((z=e.data)==null?void 0:z.definitionId)==="control_load_skills"?s.jsx(ZX,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,skills:(E=e.data)==null?void 0:E.skills,skillCollections:(O=e.data)==null?void 0:O.skillCollections,onChangeSkillKeys:(D=e.data)==null?void 0:D.onChangeLoadSkillKeys}):((L=e.data)==null?void 0:L.definitionId)==="control_load_mcp"?s.jsx(eQ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,servers:($=e.data)==null?void 0:$.mcpServers,onChangeMcpNames:(V=e.data)==null?void 0:V.onChangeLoadMcpNames}):((W=e.data)==null?void 0:W.definitionId)==="control_cd_workspace"?s.jsx(tQ,{...e,data:{...e.data,onSelectNodePointerDown:u},deleteNode:c,workspaces:(F=e.data)==null?void 0:F.workspaceTargets,onChangeWorkspace:(M=e.data)==null?void 0:M.onChangeLoadWorkspace,onRefreshWorkspaces:(H=e.data)==null?void 0:H.onRefreshWorkspaces}):s.jsxs("div",{className:"af-work-flow-node"+(e.selected?" af-work-flow-node--selected":"")+(o?" af-work-flow-node--resizing":"")+((A=e.data)!=null&&A.isExecuting||((X=e.data)==null?void 0:X.nodeStatus)==="running"?" af-work-flow-node--executing":"")+(((q=e.data)==null?void 0:q.nodeStatus)==="success"?" af-work-flow-node--done":"")+(((B=e.data)==null?void 0:B.nodeStatus)==="failed"?" af-work-flow-node--failed":"")+(((ne=e.data)==null?void 0:ne.nodeStatus)==="stopped"?" af-work-flow-node--stopped":""),style:l?{width:l.width,height:l.height}:void 0,onPointerDownCapture:u,children:[i?null:s.jsx(kv,{className:"af-work-display-resize af-work-flow-resize nodrag",position:"bottom-right",minWidth:_M,minHeight:Lm,maxWidth:CM,maxHeight:AM,onResizeStart:()=>a(!0),onResizeEnd:()=>a(!1),children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_full"})}),s.jsx(cG,{...e,deleteNode:c,deferTextCommit:!0,modelLists:(ce=e.data)==null?void 0:ce.modelLists,onModelChange:f,onProvideValueChange:p,onNodeBodyChange:d,onNodeImagesChange:m})]})}const RX={[Tc]:h.memo(TX)};function Xv(e,t=[]){for(const n of e||[])n.type==="file"&&t.push(n),Array.isArray(n.children)&&Xv(n.children,t);return t}function JM(e,t){const n=String(t||"");if(!n)return null;for(const r of e||[]){if(r.path===n)return r;const i=Array.isArray(r.children)?JM(r.children,n):null;if(i)return i}return null}function MX(e){const t=String(e||"").replace(/\\/g,"/").replace(/^\/+|\/+$/g,"");return!t||!t.includes("/")?"":t.split("/").slice(0,-1).join("/")}function XM(e,t=[]){for(const n of e||[])n.type==="directory"&&(t.push(n.path),Array.isArray(n.children)&&XM(n.children,t));return t}function fh(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 $X(e,t){const n=String(t||"");let r=!1;const i=(e||[]).map(o=>{const a=o.id===n;return o.selected===a?o:(r=!0,{...o,selected:a})});return r?i:e}function QM(e,t){const n=String(t||""),r=(e||[]).find(o=>o.id===n),i=(e||[]).reduce((o,a)=>o+(a.selected?1:0),0);return r!=null&&r.selected&&i>1?e:$X(e,n)}function LX(e){let t=!1;const n=(e||[]).map(r=>r.selected?(t=!0,{...r,selected:!1}):r);return t?n:e}function OX(e){return[...e||[]].sort((t,n)=>t.type!==n.type?t.type==="directory"?-1:1:String(t.name||"").localeCompare(String(n.name||"")))}function DX(e,t,n=0){const r=String(t||"").replace(/\\/g,"/").split("/").filter(Boolean);if(r.length===0)return e;const i=(o,a,l)=>{const c=r[a],u=l?`${l}/${c}`:c,f=a===r.length-1;let p=!1;const d=(Array.isArray(o)?o:[]).map(m=>m.name!==c?m:(p=!0,f?{...m,type:"file",name:c,path:u,icon:bc(c),size:n}:{...m,type:"directory",name:c,path:u,icon:bc(c,!0),children:i(m.children||[],a+1,u)}));return p||d.push(f?{type:"file",name:c,path:u,icon:bc(c),size:n}:{type:"directory",name:c,path:u,icon:bc(c,!0),children:i([],a+1,u)}),OX(d)};return i(e||[],0,"")}function FX(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"":t<1024?`${t} B`:t<1024*1024?`${Math.round(t/102.4)/10} KB`:`${Math.round(t/1024/102.4)/10} MB`}function ZM({items:e,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:i,onSelect:o,onFileDragStart:a,onDelete:l,onDownload:c}){return s.jsx("ul",{className:"af-work-files",children:(e||[]).map(u=>{var m;const f=u.type==="directory",p=f&&(r==null?void 0:r.has(u.path)),d=n===u.path;return s.jsxs("li",{children:[s.jsxs("div",{className:"af-work-file-row",children:[s.jsxs("button",{type:"button",className:"af-work-file af-work-file--"+u.type+(d?" af-work-file--selected":""),draggable:!f,onDragStart:y=>{f||a==null||a(y,u)},onClick:()=>{o==null||o(u),f&&(i==null||i(u.path))},onDoubleClick:()=>{f||t(u)},title:u.path,children:[f?s.jsx("span",{className:"material-symbols-outlined af-work-file__chevron",children:p?"chevron_right":"expand_more"}):null,s.jsx("span",{className:"material-symbols-outlined",children:u.icon||bc(u.name,f)}),s.jsx("span",{children:u.name})]}),d?s.jsxs("div",{className:"af-work-file-actions",children:[f?null:s.jsx("button",{type:"button",className:"af-work-file-action",onClick:y=>{y.stopPropagation(),c==null||c(u)},"aria-label":`下载 ${u.name}`,title:`下载 ${u.path}`,children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"download"})}),s.jsx("button",{type:"button",className:"af-work-file-action af-work-file-action--danger",onClick:y=>{y.stopPropagation(),l==null||l(u)},"aria-label":`删除 ${u.name}`,title:`删除 ${u.path}`,children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"delete"})})]}):null]}),f&&!p&&((m=u.children)!=null&&m.length)?s.jsx(ZM,{items:u.children,onOpen:t,selectedPath:n,collapsedDirs:r,onToggleDir:i,onSelect:o,onFileDragStart:a,onDelete:l,onDownload:c}):null]},u.path)})})}function zX({files:e,query:t,onQueryChange:n,onSelect:r,onUpload:i,onClose:o}){const a=h.useMemo(()=>Xv(e),[e]),l=String(t||"").trim().toLowerCase(),c=a.filter(u=>l?`${u.path} ${u.name}`.toLowerCase().includes(l):!0);return s.jsx("div",{className:"af-flow-snippet-modal-overlay",onMouseDown:o,children:s.jsxs("div",{className:"af-flow-snippet-modal af-work-file-picker-modal",role:"dialog","aria-modal":"true","aria-label":"选择文件",onMouseDown:u=>u.stopPropagation(),children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined",children:"folder_open"}),"选择文件"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:o,"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("div",{className:"af-work-file-picker-modal__tools",children:[s.jsx("input",{value:t,onChange:u=>n(u.target.value),placeholder:"搜索文件路径...",autoFocus:!0}),s.jsxs("button",{type:"button",onClick:()=>i==null?void 0:i(""),children:[s.jsx("span",{className:"material-symbols-outlined",children:"upload_file"}),"上传"]})]}),s.jsxs("div",{className:"af-work-file-picker-modal__list",children:[c.map(u=>s.jsxs("button",{type:"button",className:"af-work-file-picker-modal__item",onClick:()=>r(u),children:[s.jsx("span",{className:"material-symbols-outlined",children:u.icon||bc(u.name)}),s.jsxs("span",{className:"af-work-file-picker-modal__main",children:[s.jsx("strong",{children:u.name}),s.jsx("small",{children:u.path})]}),u.size?s.jsx("em",{children:FX(u.size)}):null]},u.path)),c.length===0?s.jsx("div",{className:"af-work-file-picker-modal__empty",children:"没有匹配文件,可先上传或调整搜索词。"}):null]})]})]})})}function BX(e){return e.kind==="run-summary"?"Steps":e.kind==="run-log"?"Run":e.kind==="activity"?"Activity":e.kind==="prompt"?"Prompt":e.kind==="raw"?"Raw Trace":e.kind==="thinking"?"Thinking":"Activity"}function AC({messages:e,running:t,showRunningIndicator:n=!0,technical:r=!1}){if(r)return s.jsx(RG,{items:e.map((o,a)=>({id:`${o.kind||"activity"}-${a}-${String(o.text||"").slice(0,24)}`,kind:o.kind||"activity",label:BX(o),text:o.text})),running:t,label:"执行过程",defaultOpen:t});const i=e.length>0;return s.jsxs("div",{className:"af-composer-ai-stack af-composer-ai-stack--in-panel af-composer-thread-stack af-composer-assistant-thread",children:[e.map((o,a)=>s.jsx(Lw,{role:o.role==="user"?"user":"assistant",content:o.text,error:!!o.error,copy:!o.error},`${a}-${o.role}-${String(o.text||"").slice(0,24)}`)),n&&t&&!i?s.jsx(Lw,{pending:!0,pendingLabel:"正在理解 Workspace 并规划修改"}):null,n&&t&&i?s.jsx(Lw,{pending:!0,pendingLabel:"仍在生成并同步 Workspace",copy:!1}):null]})}function e$(e){const t=String((e==null?void 0:e.kind)||"");return["run-log","run-summary","activity","prompt","raw","thinking"].includes(t)}function WX(e,t=!1){const n=Array.isArray(e)?e:[],r=n.filter(o=>!e$(o));if(r.length>0)return r;const i=[...n].reverse().find(o=>(o==null?void 0:o.kind)==="result"||(o==null?void 0:o.kind)==="assistant"||(o==null?void 0:o.error));return i?[i]:n.length>0||t?t?[]:[{role:"assistant",kind:"assistant",text:"运行已完成。可以在下方继续追问、要求总结或调整结果。",at:0}]:[]}function HX(e){return(Array.isArray(e)?e:[]).filter(e$)}function vf(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 VX(e){const t=vf((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(i=>(i==null?void 0:i.name)==="skillsContext"||(i==null?void 0:i.name)==="skillKeys"||(i==null?void 0:i.type)==="text");return vf((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function KX(e){const n=[...Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],...Array.isArray(e==null?void 0:e.outputs)?e.outputs:[]].find(r=>(r==null?void 0:r.name)==="skillKeys"||(r==null?void 0:r.name)==="skillsContext");return vf((n==null?void 0:n.default)||(n==null?void 0:n.value)||"")}function t$(e,t,n=1){const r=(Array.isArray(e)?e:[]).map(o=>String(o||"").trim()).filter(Boolean);return r.length?{head:r.slice(0,n).join("、"),extra:r.length>n?`等 ${r.length} 个`:"",title:r.join(", ")}:{head:t,extra:"",title:""}}function EC(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function ga(e,t,n=""){const r=(Array.isArray(e)?e:[]).find(o=>(o==null?void 0:o.name)===t);return String((r==null?void 0:r.value)??(r==null?void 0:r.default)??"").trim()||n}function Km(e,t){const n=ga(e,t,"");if(!n)return null;try{const r=JSON.parse(n);return r&&typeof r=="object"&&!Array.isArray(r)?r:null}catch{return null}}function Wf(e){const t=String(e||"").trim().toLowerCase();return["markdown","html","react","table","chart","ascii","mermaid"].includes(t)?t:"markdown"}function Rs(e){const t=String(e||""),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t.trim()}function n$(e){const t=Wf(e);return t==="html"?"display_html":t==="react"?"display_react_app":t==="table"?"display_table":t==="chart"?"display_chart":t==="ascii"?"display_ascii":t==="mermaid"?"display_mermaid":"display_markdown"}function r$(e){return`${String(e||"context_run").trim()||"context_run"}__display`}function s$(e){return e==="display_image"?"src":"content"}function IC(e,t,n){const r=s$(t),i=yd(e);let o=!1;const a=i.map(l=>(l==null?void 0:l.name)===r?(o=!0,{...l,default:n,value:n,showOnNode:l.showOnNode!==!1}):(l==null?void 0:l.name)==="filePath"?{...l,default:"",value:""}:l);return o||a.push({type:"text",name:r,default:n,value:n,required:!0,showOnNode:!0}),a}function PC(e,t,n=[],r=[]){const i=Array.isArray(e)?e:[],o=new Set((Array.isArray(n)?n:[]).map(u=>String(u||"").trim()).filter(Boolean)),a=new Set((Array.isArray(r)?r:[]).map(u=>String(u||"").trim()).filter(Boolean)),l=u=>(u==null?void 0:u.showOnNode)!==!1;let c=i.findIndex(u=>l(u)&&o.has(String((u==null?void 0:u.name)||"").trim()));return c<0&&(c=i.findIndex(u=>o.has(String((u==null?void 0:u.name)||"").trim()))),c<0&&(c=i.findIndex(u=>l(u)&&a.has(String((u==null?void 0:u.type)||"").trim()))),c<0&&(c=i.findIndex(u=>l(u))),c<0&&(c=0),`${t}-${c}`}function TC(e){return(Array.isArray(e)?e:[]).map(t=>(t==null?void 0:t.type)==="node"||(t==null?void 0:t.name)==="next"?t:{...t,default:"",value:""})}function Og(e){const t=Array.isArray(e==null?void 0:e.outputs)?e.outputs:Array.isArray(e==null?void 0:e.output)?e.output:[],n=i=>String((i==null?void 0:i.value)??(i==null?void 0:i.default)??"").trim(),r=t.find(i=>((i==null?void 0:i.name)==="content"||(i==null?void 0:i.name)==="result")&&n(i))||t.find(i=>(i==null?void 0:i.name)==="resultFile"&&n(i))||t.find(i=>(i==null?void 0:i.type)!=="node"&&(i==null?void 0:i.name)!=="next"&&(i==null?void 0:i.name)!=="displayType"&&n(i));return r?n(r):""}function qX(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=ga(t,"includeWorkspaceContext","true").toLowerCase(),r=Km(t,"knowledgeContext"),i=Km(t,"workspaceContext");return{task:String((e==null?void 0:e.body)||""),skillKeys:KX(e),includeWorkspaceContext:n!=="false"&&n!=="0"&&n!=="off",knowledgeContext:r||(i?Dg([i]):null),workspaceContext:i,displayType:Wf(ga(t,"displayType","markdown")),model:String((e==null?void 0:e.model)||"").trim()}}function di(e){const t=String(e||"");return t==="workspace_one_click_task"||t==="workspace_context_run"}function UX(e){const t=vf((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(i=>(i==null?void 0:i.name)==="mcpContext"||(i==null?void 0:i.name)==="serverNames"||(i==null?void 0:i.type)==="text");return vf((r==null?void 0:r.default)||(r==null?void 0:r.value)||"")}function GX(e){return JSON.stringify(Array.from(new Set((e||[]).map(String).filter(Boolean))))}function i$(e={},t="context"){const n=String((e==null?void 0:e.cwd)||(e==null?void 0:e.workspaceRoot)||(e==null?void 0:e.path)||"").trim(),r=String((e==null?void 0:e.id)||"").trim(),i=String((e==null?void 0:e.label)||(e==null?void 0:e.name)||"").trim();if(!n&&!r&&!i)return null;const o=String(i||r||"知识库").trim();return{id:r,label:o,kind:(e==null?void 0:e.kind)==="git"?"git":"local",type:String((e==null?void 0:e.type)||""),repoPath:n,path:n,mountPath:String((e==null?void 0:e.mountPath)||r||o).trim(),repoUrl:String((e==null?void 0:e.repoUrl)||"").trim(),branch:String((e==null?void 0:e.branch)||"").trim(),readonly:!0,role:t}}function Dg(e=[]){const t=(Array.isArray(e)?e:[e]).map((n,r)=>i$(n,r===0?"primary":"context")).filter(Boolean);return t.length?{version:1,sources:t}:null}function o$(e){return(e&&typeof e=="object"&&Array.isArray(e.sources)?e.sources:[]).map(n=>i$(n,(n==null?void 0:n.role)||"context")).filter(Boolean)}function YX(e){const t=Array.isArray(e==null?void 0:e.inputs)?e.inputs:[],n=Km(t,"knowledgeContext"),r=Km(t,"workspaceContext");return{sources:o$(n||(r?Dg([r]):null)),path:ga(t,"path",""),label:ga(t,"label","")}}function RC(e){var r,i,o,a,l,c,u,f,p;if(!e)return null;const{inputs:t,outputs:n}=vG(e);return{id:e.id,newId:e.id,label:String(((r=e.data)==null?void 0:r.label)??e.id),role:String(((i=e.data)==null?void 0:i.role)??"normal"),model:String(((o=e.data)==null?void 0:o.model)??""),body:String(((a=e.data)==null?void 0:a.body)??""),images:So((l=e.data)==null?void 0:l.images),script:String(((c=e.data)==null?void 0:c.script)??""),scriptRef:String(((u=e.data)==null?void 0:u.scriptRef)??""),implementationRef:String(((f=e.data)==null?void 0:f.implementationRef)??""),implementationMode:String(((p=e.data)==null?void 0:p.implementationMode)??""),inputs:t,outputs:n}}function MC(e,t,n,r=""){var c,u;const i=String(n||"").trim(),o=(Array.isArray(e)?e:[]).find(f=>String((f==null?void 0:f.id)||"")===i),a=String(((c=o==null?void 0:o.data)==null?void 0:c.model)||"").trim();if(a&&a!=="default")return a;const l=String(((u=t==null?void 0:t[i])==null?void 0:u.model)||"").trim();return l&&l!=="default"?l:String(r||"").trim()}function $C(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 JX(e,t,n){var f,p;const r=String(((f=e==null?void 0:e.data)==null?void 0:f.definitionId)??n),i=r.startsWith("provide_"),o=String((t==null?void 0:t.role)||"").trim(),a=gf.includes(o)?o:"normal",l=String((t==null?void 0:t.model)||"").trim(),c={...e.data,label:String((t==null?void 0:t.label)||"").trim()||n,role:a,model:l===""||l==="default"?void 0:l,body:i?"":String((t==null?void 0:t.body)??""),images:i?[]:So(t==null?void 0:t.images),inputs:$C(t==null?void 0:t.inputs),outputs:i&&Array.isArray((p=e.data)==null?void 0:p.outputs)?e.data.outputs:$C(t==null?void 0:t.outputs)},u=String((t==null?void 0:t.script)??"").trim();r==="tool_nodejs"||u!==""?c.script=String((t==null?void 0:t.script)??""):delete c.script;for(const d of["scriptRef","implementationRef","implementationMode"]){const m=String((t==null?void 0:t[d])??"").trim();m?c[d]=m:delete c[d]}return c}function LC({nodes:e,edges:t,instances:n,selectedNode:r,draft:i,allowRename:o=!1}){if(!i||!r)return{ok:!1,error:""};const a=r.id,l=String(i.newId||"").trim(),c=o?l:a;if(o){if(!GG.test(c))return{ok:!1,error:"Invalid instance id"};if(e.some(v=>v.id===c&&v.id!==a))return{ok:!1,error:"Duplicate instance id"}}const u=JX(r,i,c),f=r.data||{};if(!(c!==a||f.label!==u.label||f.role!==u.role||f.model!==u.model||f.body!==u.body||JSON.stringify(So(f.images))!==JSON.stringify(u.images)||(f.script??void 0)!==(u.script??void 0)||(f.scriptRef??void 0)!==(u.scriptRef??void 0)||(f.implementationRef??void 0)!==(u.implementationRef??void 0)||(f.implementationMode??void 0)!==(u.implementationMode??void 0)||JSON.stringify(f.inputs||[])!==JSON.stringify(u.inputs||[])||JSON.stringify(f.outputs||[])!==JSON.stringify(u.outputs||[])))return{ok:!0,changed:!1,nextId:c,nodes:e,edges:t,instances:n};const d=e.map(v=>v.id===a?{...v,id:c,selected:!0,data:u}:v);let m=t,y=n;if(c!==a){y={...n||{}};const v={...y[a]||{}};delete y[a],y[c]=v,m=t.map((b,g)=>({...b,source:b.source===a?c:b.source,target:b.target===a?c:b.target,id:`we-${b.source===a?c:b.source}-${b.target===a?c:b.target}-${g}`}))}return{ok:!0,changed:!0,nextId:c,nodes:d,edges:m,instances:y}}function XX(e,t){return JSON.stringify(e??null)===JSON.stringify(t??null)}function QX(e,t,n){if(!e||!t||!n)return n;const r={...e};for(const i of["newId","label","role","model","body","images","script","scriptRef","implementationRef","implementationMode","inputs","outputs"])XX(e[i],t[i])&&(r[i]=n[i]);return r}function Jb(e,t=[]){const n=h.useRef(null),r=h.useRef(null),[i,o]=h.useState({visible:!1,top:0,height:100}),a=h.useCallback(()=>{const f=n.current;if(!f)return;const p=Math.max(1,f.scrollHeight),d=Math.max(1,f.clientHeight),m=p>d+1,y=m?Math.max(12,d/p*100):100,v=Math.max(0,100-y),b=m?Math.min(v,f.scrollTop/Math.max(1,p-d)*v):0;o({visible:m,top:b,height:y})},[]);h.useEffect(()=>{if(!e)return;const f=requestAnimationFrame(a);return()=>cancelAnimationFrame(f)},[e,a,...t]);const l=h.useCallback(f=>{const p=n.current;if(!p)return;const d=Math.max(0,p.scrollHeight-p.clientHeight);p.scrollTop=Math.min(1,Math.max(0,f))*d,a()},[a]),c=h.useCallback((f,p=0)=>{const d=r.current;if(!d)return 0;const m=d.getBoundingClientRect(),y=i.height/100*m.height,v=Math.max(1,m.height-y);return(f-m.top-p)/v},[i.height]),u=h.useCallback(f=>{var _,j;if(!i.visible)return;f.preventDefault(),f.stopPropagation();const p=r.current;if(!p)return;const d=p.getBoundingClientRect(),m=i.top/100*d.height,y=i.height/100*d.height,b=f.clientY>=d.top+m&&f.clientY<=d.top+m+y?f.clientY-d.top-m:y/2;l(c(f.clientY,b));const g=f.pointerId;(j=(_=f.currentTarget).setPointerCapture)==null||j.call(_,g);const k=N=>{N.preventDefault(),l(c(N.clientY,b))},x=()=>{window.removeEventListener("pointermove",k),window.removeEventListener("pointerup",x),window.removeEventListener("pointercancel",x)};window.addEventListener("pointermove",k),window.addEventListener("pointerup",x),window.addEventListener("pointercancel",x)},[c,l,i.height,i.top,i.visible]);return{menuRef:n,scrollbarTrackRef:r,scrollbar:i,updateMenuScrollbar:a,handleScrollbarPointerDown:u}}function ZX({id:e,data:t,selected:n,deleteNode:r,skills:i,skillCollections:o,onChangeSkillKeys:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],u=Array.isArray(i)?i:[],f=Array.isArray(o)?o:[],[p,d]=h.useState(!1),[m,y]=h.useState(""),[v,b]=h.useState(()=>new Set),g=h.useRef(null),k=h.useRef(null),[x,_]=h.useState({visible:!1,top:0,height:100}),j=h.useMemo(()=>new Set(VX(t)),[t]),N=h.useMemo(()=>new Map(u.map(F=>[F.key,F])),[u]),P=h.useMemo(()=>Array.from(j).map(F=>{var M;return((M=N.get(F))==null?void 0:M.name)||F}),[N,j]),T=h.useMemo(()=>t$(P,"选择 Skills"),[P]),z=h.useMemo(()=>{const F=new Set,M=f.map(A=>{const X=pa(A,u).map(q=>N.get(q)).filter(Boolean);for(const q of X)F.add(q.key);return{...A,skills:X}}).filter(A=>A.skills.length>0),H=u.filter(A=>!F.has(A.key));return{collectionGroups:M,ungrouped:H}},[N,f,u]);h.useEffect(()=>{b(F=>{let M=!1;const H=new Set(F);for(const A of z.collectionGroups)H.has(A.id)||(H.add(A.id),M=!0);return M?H:F})},[z.collectionGroups]);const E=h.useMemo(()=>{const F=m.trim().toLowerCase();if(!F)return z;const M=A=>[A==null?void 0:A.key,A==null?void 0:A.name,A==null?void 0:A.description].map(q=>String(q||"").toLowerCase()).join(" ").includes(F);return{collectionGroups:z.collectionGroups.map(A=>{const q=[A==null?void 0:A.id,A==null?void 0:A.name,A==null?void 0:A.description].map(B=>String(B||"").toLowerCase()).join(" ").includes(F)?A.skills:A.skills.filter(M);return{...A,skills:q}}).filter(A=>A.skills.length>0),ungrouped:z.ungrouped.filter(M)}},[z,m]),O=h.useCallback((F,M)=>{const H=new Set(j);for(const A of F)M?H.add(A):H.delete(A);a==null||a(e,Array.from(H))},[e,j,a]),D=h.useCallback(F=>{b(M=>{const H=new Set(M);return H.has(F)?H.delete(F):H.add(F),H})},[]),L=h.useCallback(()=>{const F=g.current;if(!F)return;const M=Math.max(1,F.scrollHeight),H=Math.max(1,F.clientHeight),A=M>H+1,X=A?Math.max(12,H/M*100):100,q=Math.max(0,100-X),B=A?Math.min(q,F.scrollTop/Math.max(1,M-H)*q):0;_({visible:A,top:B,height:X})},[]);h.useEffect(()=>{if(!p)return;const F=requestAnimationFrame(L);return()=>cancelAnimationFrame(F)},[v,E,j.size,p,L]);const $=h.useCallback(F=>{const M=g.current;if(!M)return;const H=Math.max(0,M.scrollHeight-M.clientHeight);M.scrollTop=Math.min(1,Math.max(0,F))*H,L()},[L]),V=h.useCallback((F,M=0)=>{const H=k.current;if(!H)return 0;const A=H.getBoundingClientRect(),X=x.height/100*A.height,q=Math.max(1,A.height-X);return(F-A.top-M)/q},[x.height]),W=h.useCallback(F=>{var ee,re;if(!x.visible)return;F.preventDefault(),F.stopPropagation();const M=k.current;if(!M)return;const H=M.getBoundingClientRect(),A=x.top/100*H.height,X=x.height/100*H.height,B=F.clientY>=H.top+A&&F.clientY<=H.top+A+X?F.clientY-H.top-A:X/2;$(V(F.clientY,B));const ne=F.pointerId;(re=(ee=F.currentTarget).setPointerCapture)==null||re.call(ee,ne);const ce=se=>{se.preventDefault(),$(V(se.clientY,B))},K=()=>{window.removeEventListener("pointermove",ce),window.removeEventListener("pointerup",K),window.removeEventListener("pointercancel",K)};window.addEventListener("pointermove",ce),window.addEventListener("pointerup",K),window.addEventListener("pointercancel",K)},[V,$,x.height,x.top,x.visible]);return s.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":"")+(p?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((F,M)=>{if(F.showOnNode===!1)return null;const H=`${2.6+M*1.7}rem`,A=F.name||`#${M+1}`;return s.jsxs(h.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:H},children:A}),s.jsx(ar,{type:"target",position:Ge.Left,id:`input-${M}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:H,background:Bn(F.type)},title:`${A} · ${F.type}`})]},`in-${M}`)}),c.map((F,M)=>{if(F.showOnNode===!1)return null;const H=`${2.6+M*1.7}rem`,A=F.name||`#${M+1}`;return s.jsxs(h.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:H},children:A}),s.jsx(ar,{type:"source",position:Ge.Right,id:`output-${M}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:H,background:Bn(F.type)},title:`${A} · ${F.type}`})]},`out-${M}`)}),s.jsxs("div",{className:"af-work-load-skills-card__head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"extension"}),s.jsx("strong",{children:(t==null?void 0:t.label)||"Load Skills"}),s.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_skills"}),s.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[s.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:F=>{var M;F.stopPropagation(),p||(M=t==null?void 0:t.onRefreshSkills)==null||M.call(t),d(H=>!H)},children:[s.jsxs("span",{className:"af-work-load-skills-card__summary",title:T.title,children:[s.jsx("span",{className:"af-work-load-skills-card__summary-main",children:T.head}),T.extra?s.jsx("span",{className:"af-work-load-skills-card__summary-extra",children:T.extra}):null]}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:p?"expand_less":"expand_more"})]}),p?s.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:F=>F.stopPropagation(),children:[s.jsxs("div",{className:"af-work-load-skills-search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",value:m,onChange:F=>y(F.target.value),placeholder:"搜索 Skills...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 Skills"}),m?s.jsx("button",{type:"button",onClick:()=>y(""),"aria-label":"清空搜索",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),s.jsxs("div",{ref:g,className:"af-work-load-skills-menu",onScroll:L,children:[E.collectionGroups.map(F=>{const M=F.skills.map(q=>q.key),H=M.filter(q=>j.has(q)).length,A=M.length>0&&H===M.length,X=v.has(F.id);return s.jsxs("section",{className:"af-work-load-skills-menu__group"+(X?" af-work-load-skills-menu__group--collapsed":""),children:[s.jsxs("div",{className:"af-work-load-skills-menu__group-head",children:[s.jsx("input",{type:"checkbox",checked:A,onChange:q=>O(M,q.target.checked),"aria-label":`选择 ${F.name}`}),s.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-toggle",onClick:()=>D(F.id),"aria-expanded":!X,children:s.jsxs("span",{className:"af-work-load-skills-menu__group-main",children:[s.jsx("span",{children:F.name}),F.description?s.jsx("em",{children:F.description}):null]})}),s.jsxs("small",{children:[H,"/",M.length]}),s.jsx("button",{type:"button",className:"af-work-load-skills-menu__group-arrow",onClick:()=>D(F.id),"aria-label":X?`展开 ${F.name}`:`收起 ${F.name}`,children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:X?"chevron_right":"expand_more"})})]}),X?null:s.jsx("div",{className:"af-work-load-skills-menu__options",children:F.skills.map(q=>s.jsxs("label",{className:"af-work-load-skills-menu__option",children:[s.jsx("input",{type:"checkbox",checked:j.has(q.key),onChange:B=>O([q.key],B.target.checked)}),s.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[s.jsx("span",{className:"af-work-load-skills-menu__option-title",children:q.name}),q.description?s.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:q.description}):null]})]},`${F.id}:${q.key}`))})]},F.id)}),E.ungrouped.length>0?s.jsxs("section",{className:"af-work-load-skills-menu__group",children:[s.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[s.jsx("span",{children:"Ungrouped"}),s.jsx("small",{children:E.ungrouped.length})]}),s.jsx("div",{className:"af-work-load-skills-menu__options",children:E.ungrouped.map(F=>s.jsxs("label",{className:"af-work-load-skills-menu__option",children:[s.jsx("input",{type:"checkbox",checked:j.has(F.key),onChange:M=>O([F.key],M.target.checked)}),s.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[s.jsx("span",{className:"af-work-load-skills-menu__option-title",children:F.name}),F.description?s.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:F.description}):null]})]},`ungrouped:${F.key}`))})]}):null,E.collectionGroups.length===0&&E.ungrouped.length===0?s.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 Skills"}):null,s.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>a==null?void 0:a(e,[]),children:"清空"})]}),s.jsx("div",{ref:k,className:"af-work-load-skills-scrollbar"+(x.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:W,"aria-hidden":"true",children:s.jsx("span",{style:{height:`${x.height}%`,top:`${x.top}%`}})})]}):null]})]})}function eQ({id:e,data:t,selected:n,deleteNode:r,servers:i=[],onChangeMcpNames:o}){const a=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],l=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[c,u]=h.useState(!1),[f,p]=h.useState(""),d=h.useMemo(()=>new Set(UX(t)),[t]),m=h.useMemo(()=>(Array.isArray(i)?i:[]).map(b=>({name:String((b==null?void 0:b.name)||""),description:String((b==null?void 0:b.description)||""),detail:String((b==null?void 0:b.url)||[b==null?void 0:b.command,...Array.isArray(b==null?void 0:b.args)?b.args:[]].filter(Boolean).join(" ")||""),type:String((b==null?void 0:b.type)||"")})).filter(b=>b.name),[i]),y=h.useMemo(()=>{const b=f.trim().toLowerCase();return b?m.filter(g=>[g.name,g.description,g.detail,g.type].join(" ").toLowerCase().includes(b)):m},[f,m]),v=h.useCallback((b,g)=>{const k=new Set(d);for(const x of b)g?k.add(x):k.delete(x);o==null||o(e,Array.from(k))},[e,d,o]);return s.jsxs("div",{className:"af-work-load-skills-card"+(n?" af-work-load-skills-card--selected":"")+(c?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[a.map((b,g)=>{if(b.showOnNode===!1)return null;const k=`${2.6+g*1.7}rem`,x=b.name||`#${g+1}`;return s.jsxs(h.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:k},children:x}),s.jsx(ar,{type:"target",position:Ge.Left,id:`input-${g}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:k,background:Bn(b.type)},title:`${x} · ${b.type}`})]},`in-${g}`)}),l.map((b,g)=>{if(b.showOnNode===!1)return null;const k=`${2.6+g*1.7}rem`,x=b.name||`#${g+1}`;return s.jsxs(h.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:k},children:x}),s.jsx(ar,{type:"source",position:Ge.Right,id:`output-${g}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:k,background:Bn(b.type)},title:`${x} · ${b.type}`})]},`out-${g}`)}),s.jsxs("div",{className:"af-work-load-skills-card__head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"hub"}),s.jsx("strong",{children:(t==null?void 0:t.label)||"Load MCP"}),s.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_load_mcp"}),s.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[s.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:b=>{var g;b.stopPropagation(),c||(g=t==null?void 0:t.onRefreshMcps)==null||g.call(t),u(k=>!k)},children:[s.jsx("span",{children:d.size>0?`${d.size} MCP selected`:"选择 MCP"}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:c?"expand_less":"expand_more"})]}),c?s.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:b=>b.stopPropagation(),children:[s.jsxs("div",{className:"af-work-load-skills-search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",value:f,onChange:b=>p(b.target.value),placeholder:"搜索 MCP...",spellCheck:!1,autoComplete:"off","aria-label":"搜索 MCP"}),f?s.jsx("button",{type:"button",onClick:()=>p(""),"aria-label":"清空搜索",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),s.jsxs("div",{className:"af-work-load-skills-menu",children:[s.jsxs("section",{className:"af-work-load-skills-menu__group",children:[s.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[s.jsx("span",{children:"MCP Servers"}),s.jsx("small",{children:y.length})]}),s.jsx("div",{className:"af-work-load-skills-menu__options",children:y.map(b=>s.jsxs("label",{className:"af-work-load-skills-menu__option",children:[s.jsx("input",{type:"checkbox",checked:d.has(b.name),onChange:g=>v([b.name],g.target.checked)}),s.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[s.jsx("span",{className:"af-work-load-skills-menu__option-title",children:b.name}),b.description||b.detail?s.jsx("span",{className:"af-work-load-skills-menu__option-desc",children:b.description||b.detail}):null]})]},b.name))})]}),y.length===0?s.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的 MCP"}):null,s.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>o==null?void 0:o(e,[]),children:"清空"})]})]}):null]})]})}function tQ({id:e,data:t,selected:n,deleteNode:r,workspaces:i=[],onChangeWorkspace:o,onRefreshWorkspaces:a}){const l=Array.isArray(t==null?void 0:t.inputs)?t.inputs:[],c=Array.isArray(t==null?void 0:t.outputs)?t.outputs:[],[u,f]=h.useState(!1),[p,d]=h.useState(""),m=YX(t),y=h.useMemo(()=>(Array.isArray(i)?i:[]).map(j=>({id:String((j==null?void 0:j.id)||""),label:String((j==null?void 0:j.label)||(j==null?void 0:j.name)||"知识库"),kind:(j==null?void 0:j.kind)==="git"?"git":"local",path:String((j==null?void 0:j.path)||""),repoUrl:String((j==null?void 0:j.repoUrl)||""),branch:String((j==null?void 0:j.branch)||""),mountPath:String((j==null?void 0:j.mountPath)||""),builtin:(j==null?void 0:j.builtin)===!0,exists:(j==null?void 0:j.exists)!==!1})).filter(j=>j.path),[i]),v=h.useMemo(()=>{const j=p.trim().toLowerCase();return j?y.filter(N=>[N.id,N.label,N.path,N.repoUrl,N.branch,N.mountPath].join(" ").toLowerCase().includes(j)):y},[p,y]),b=h.useMemo(()=>new Set((m.sources||[]).map(j=>j.id||j.path||j.repoPath).filter(Boolean)),[m.sources]),g=h.useMemo(()=>(m.sources||[]).map(j=>j.label||j.id||j.mountPath||j.path),[m.sources]),k=h.useMemo(()=>t$(g,"选择知识库"),[g]),x=Jb(u,[v.length,g.length,p]),_=(j,N)=>{const P=(j==null?void 0:j.id)||(j==null?void 0:j.path)||"",T=y.filter(z=>{const E=z.id||z.path||"";return E===P?N:b.has(E)});o==null||o(e,T)};return s.jsxs("div",{className:"af-work-load-skills-card af-work-load-workspace-card"+(n?" af-work-load-skills-card--selected":"")+(u?" af-work-load-skills-card--menu-open":""),onPointerDownCapture:t==null?void 0:t.onSelectNodePointerDown,children:[l.map((j,N)=>{if(j.showOnNode===!1)return null;const P=`${2.6+N*1.7}rem`,T=j.name||`#${N+1}`;return s.jsxs(h.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--in",style:{top:P},children:T}),s.jsx(ar,{type:"target",position:Ge.Left,id:`input-${N}`,className:"af-work-display-handle af-work-display-handle--in",style:{top:P,background:Bn(j.type)},title:`${T} · ${j.type}`})]},`in-${N}`)}),c.map((j,N)=>{if(j.showOnNode===!1)return null;const P=`${2.6+N*1.7}rem`,T=j.name||`#${N+1}`;return s.jsxs(h.Fragment,{children:[s.jsx("span",{className:"af-work-port-label af-work-port-label--out",style:{top:P},children:T}),s.jsx(ar,{type:"source",position:Ge.Right,id:`output-${N}`,className:"af-work-display-handle af-work-display-handle--out",style:{top:P,background:Bn(j.type)},title:`${T} · ${j.type}`})]},`out-${N}`)}),s.jsxs("div",{className:"af-work-load-skills-card__head",children:[s.jsx("span",{className:"material-symbols-outlined",children:"folder_managed"}),s.jsx("strong",{children:(t==null?void 0:t.label)||"加载知识库"}),s.jsx("span",{children:(t==null?void 0:t.definitionId)||"control_cd_workspace"}),s.jsx("button",{type:"button",className:"af-work-display-card__close nodrag",onClick:()=>r==null?void 0:r(e),"aria-label":"删除节点",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-work-load-skills-card__body nodrag",children:[s.jsxs("button",{type:"button",className:"af-work-load-skills-card__select",onClick:j=>{j.stopPropagation(),u||a==null||a(),f(N=>!N)},children:[s.jsxs("span",{className:"af-work-load-skills-card__summary",title:k.title,children:[s.jsx("span",{className:"af-work-load-skills-card__summary-main",children:k.head}),k.extra?s.jsx("span",{className:"af-work-load-skills-card__summary-extra",children:k.extra}):null]}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:u?"expand_less":"expand_more"})]}),u?s.jsxs("div",{className:"af-work-load-skills-menu-shell",onClick:j=>j.stopPropagation(),children:[s.jsxs("div",{className:"af-work-load-skills-search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",value:p,onChange:j=>d(j.target.value),placeholder:"搜索知识库...",spellCheck:!1,autoComplete:"off","aria-label":"搜索知识库"}),p?s.jsx("button",{type:"button",onClick:()=>d(""),"aria-label":"清空搜索",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})}):null]}),s.jsxs("div",{ref:x.menuRef,className:"af-work-load-skills-menu",onScroll:x.updateMenuScrollbar,children:[s.jsxs("section",{className:"af-work-load-skills-menu__group",children:[s.jsxs("div",{className:"af-work-load-skills-menu__group-head af-work-load-skills-menu__group-head--plain",children:[s.jsx("span",{children:"知识库"}),s.jsx("small",{children:v.length})]}),s.jsx("div",{className:"af-work-load-skills-menu__options",children:v.map(j=>s.jsxs("label",{className:"af-work-load-skills-menu__option",children:[s.jsx("input",{type:"checkbox",checked:b.has(j.id||j.path),onChange:N=>_(j,N.target.checked)}),s.jsxs("span",{className:"af-work-load-skills-menu__option-main",children:[s.jsx("span",{className:"af-work-load-skills-menu__option-title",children:j.label}),s.jsxs("span",{className:"af-work-load-skills-menu__option-desc",children:[j.kind==="git"&&j.repoUrl?`${j.repoUrl}${j.branch?` · ${j.branch}`:""}${j.mountPath?` · ${j.mountPath}`:""}`:j.path,j.exists?"":" · 路径未就绪"]})]})]},`${j.id}:${j.path}`))})]}),v.length===0?s.jsx("div",{className:"af-work-load-skills-menu__empty",children:"没有匹配的知识库"}):null,s.jsx("button",{type:"button",className:"af-work-load-skills-menu__clear",onClick:()=>o==null?void 0:o(e,[]),children:"清空知识库"})]}),s.jsx("div",{ref:x.scrollbarTrackRef,className:"af-work-load-skills-scrollbar"+(x.scrollbar.visible?" af-work-load-skills-scrollbar--visible":""),onPointerDown:x.handleScrollbarPointerDown,"aria-hidden":"true",children:s.jsx("span",{style:{height:`${x.scrollbar.height}%`,top:`${x.scrollbar.top}%`}})})]}):null]})]})}function a$({row:e,index:t=0,child:n=!1}){const r=(e==null?void 0:e.issue)||{},i=mM(r),o=iY(_J(r)),a=i?o.filter(d=>!["issue","mr"].includes(Rm(d))):o,l=aY(r,o),c=Oi(r,t),u=i?"":Jo(r.platform),f=Array.isArray(e==null?void 0:e.children)?e.children.length:0,p=[c,i&&f?`${f} 个端侧 Issue`:u,r.status].filter(Boolean);return s.jsxs("div",{className:`af-prd-workflow-issue${n?" af-prd-workflow-issue--child":""}${i?" af-prd-workflow-issue--aggregate":""}`,children:[s.jsx("strong",{children:SJ(r,t)}),s.jsx("small",{children:p.join(" · ")}),s.jsxs("div",{className:"af-prd-workflow-issue__state-row",children:[s.jsx("span",{className:`af-prd-workflow-issue__state af-prd-workflow-issue__state--${l.kind}`,children:l.label}),l.detail?s.jsx("small",{children:l.detail}):null]}),a.length?s.jsx("div",{className:"af-prd-workflow-issue__links",children:a.map(d=>s.jsx("a",{href:d.href,target:"_blank",rel:"noreferrer",children:d.label},`${d.label}-${d.href}`))}):null,f?s.jsx("div",{className:"af-prd-workflow-issue__children",children:e.children.map((d,m)=>s.jsx(a$,{row:d,index:m,child:!0},Oi((d==null?void 0:d.issue)||{},m)))}):null]})}function l$(e){return e==null?"":typeof e=="string"||typeof e=="number"?String(e).trim():typeof e!="object"||Array.isArray(e)?"":String(e.label||e.name||e.value||e.key||e.code||e.username||e.userId||"").trim()}function c$(e){return(Array.isArray(e)?e:e==null||e===""?[]:[e]).map(n=>l$(n)).filter(Boolean)}function nQ({fieldKey:e,field:t}){if(!t||typeof t!="object"||Array.isArray(t))return null;const n=String(t.label||e||"").trim(),r=String(t.type||"text").trim().toLowerCase(),i=["text","user","chips","list","link"].includes(r)?r:"text",o=c$(t.value);if(!o.length)return null;if(i==="list")return s.jsxs("div",{className:"af-prd-overall-platform__rules",children:[s.jsx("small",{children:n}),s.jsx("ul",{children:o.map((a,l)=>s.jsx("li",{children:a},`${e}-${l}-${a}`))})]});if(i==="link"){const a=t.value&&typeof t.value=="object"&&!Array.isArray(t.value)?t.value:{},l=kf(t.href||t.url||a.href||a.url||"");return s.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--link",children:[s.jsx("small",{children:n}),l?s.jsxs("a",{href:l,target:"_blank",rel:"noreferrer",children:[s.jsx("span",{children:o[0]}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]}):s.jsx("strong",{children:o[0]})]})}return s.jsxs("div",{className:`af-prd-overall-platform__row af-prd-overall-platform__row--${i}`,children:[s.jsx("small",{children:n}),s.jsx("div",{children:o.map((a,l)=>s.jsx("span",{children:a},`${e}-${l}-${a}`))})]})}function rQ({sectionKey:e,section:t}){if(!t||typeof t!="object"||Array.isArray(t))return null;const r=(t.fields&&typeof t.fields=="object"&&!Array.isArray(t.fields)?Object.entries(t.fields):[]).filter(([,o])=>o&&typeof o=="object"&&c$(o.value).length);if(!r.length)return null;const i=e==="progress";return s.jsxs("section",{className:`af-prd-overall-platform${i?" af-prd-overall-platform--compact":""}`,children:[s.jsx("div",{className:"af-prd-overall-platform__head",children:s.jsx("strong",{children:String(t.title||e||"").trim()})}),s.jsx("div",{className:"af-prd-overall-platform__fields",children:r.map(([o,a])=>s.jsx(nQ,{fieldKey:o,field:a},o))})]})}function sQ({globalState:e,tapdId:t}){const n=e&&typeof e=="object"&&!Array.isArray(e)?e:{},r=n.workflow&&typeof n.workflow=="object"&&!Array.isArray(n.workflow)?n.workflow:{},i=n.sections&&typeof n.sections=="object"&&!Array.isArray(n.sections)?n.sections:{},o=String(n.title||"").trim(),a=kf(n.url||""),l=l$(n.status),c=String(r.id||t||"").trim(),u=Object.entries(i).filter(([p,d])=>p&&d&&typeof d=="object"&&!Array.isArray(d)),f=!!(o||a||l||u.length);return!c&&!f?null:s.jsxs("article",{className:"af-prd-workflow-card af-prd-overall",children:[s.jsxs("div",{className:"af-prd-workflow-card__head",children:[s.jsx("h2",{children:"需求概览"}),l?s.jsx("span",{className:"af-prd-overall__status",children:l}):null]}),o||a||c?s.jsx("div",{className:"af-prd-overall__requirement",children:a?s.jsxs("a",{href:a,target:"_blank",rel:"noreferrer",children:[s.jsx("strong",{children:o||`${r.namespace||"Workflow"} ${c}`}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]}):s.jsx("strong",{children:o||`${r.namespace==="tapd"?"TAPD":"Workflow"} ${c}`})}):null,f?s.jsx("div",{className:"af-prd-overall__platforms",children:u.map(([p,d])=>s.jsx(rQ,{sectionKey:p,section:d},p))}):s.jsx("p",{className:"af-prd-workflow-muted",children:"暂无全局状态。各阶段可通过 Workflow 上报逐步补充负责人、配置、规则和其它上下文。"})]})}function iQ({flowParams:e={},tapdId:t,setTapdId:n,collaborationOpenRequest:r=0,assistantOpenRequest:i=0,snapshot:o,loading:a,error:l,actionRunning:c,actionOutput:u,pendingConfirm:f,conflict:p,reviewPublishing:d,onRefresh:m,onRunDryRun:y,onConfirmAction:v,onRetryConflict:b,onPublishReview:g}){var Nt,jn,ue;const[k,x]=h.useState("all"),[_,j]=h.useState("all"),[N,P]=h.useState(!1),[T,z]=h.useState(!1),[E,O]=h.useState(!1),[D,L]=h.useState(""),[$,V]=h.useState(!1),[W,F]=h.useState(""),[M,H]=h.useState(null),[A,X]=h.useState(null),[q,B]=h.useState(""),[ne,ce]=h.useState("reporter"),[K,ee]=h.useState(!1),[re,se]=h.useState(""),[Q,le]=h.useState([]),[fe,me]=h.useState([]),[De,Ce]=h.useState([]),[Se,Ue]=h.useState(!1),[lt,xt]=h.useState(!1),[at,ze]=h.useState(!1),[Xe,Bt]=h.useState([]),[Mt,Qt]=h.useState(!1),[de,ke]=h.useState(""),[qe,st]=h.useState([]),Ee=String((o==null?void 0:o.phase)||(t?"unavailable":"unselected")),rt=Array.isArray(o==null?void 0:o.issues)?o.issues:[],un=CJ(o),Kt=un.reduce((te,ye)=>te+Fb(ye.issues),0),yt=Array.isArray(o==null?void 0:o.artifacts)?o.artifacts:[];Array.isArray(o==null?void 0:o.optionalGaps)&&o.optionalGaps;const pn=o!=null&&o.nextAction&&typeof o.nextAction=="object"?o.nextAction:null,ie=PJ(o,pn),Ne=kJ(o,ie),Ye=yt.filter(te=>!yM({...te,href:Rc(te)})),He=h.useMemo(()=>wJ(ie),[ie]);h.useEffect(()=>{_!=="all"&&(He.some(te=>te.key===_)||j("all"))},[_,He]);const It=ie.filter(te=>xJ(te,_)),jt=gJ(It),cr=TJ(o),$n=cr.filter(te=>RJ(te,k)),ur=It.filter(te=>Kv(te)).length,rn=o!=null&&o.collaboration&&typeof o.collaboration=="object"?o.collaboration:{},gn=rn.activeAction&&typeof rn.activeAction=="object"?rn.activeAction:null;Array.isArray(o==null?void 0:o.clientObservations)&&o.clientObservations;const Yn=String((o==null?void 0:o.rawOutput)||""),gr=o!=null&&o.globalState&&typeof o.globalState=="object"?o.globalState:null,yn=lJ(o,t),Pn=aJ(Ee),nr=h.useCallback(async()=>{const te=String(t||"").trim();if(!te||e.workflowShare){le([]),Ce([]),me([]),Ue(!1);return}const ye=await fetch(`/api/workflows/knowledge-bindings?tapdId=${encodeURIComponent(te)}`),Me=await ye.json().catch(()=>({}));if(!ye.ok)throw new Error(Me.error||"读取知识工作区绑定失败");const Ae=Array.isArray(Me.bindings)?Me.bindings:[];le(Ae),Ce(Ae.map(ut=>ut.workspaceId).filter(Boolean)),me(Array.isArray(Me.availableWorkspaces)?Me.availableWorkspaces:[]),Ue(Me.canManage===!0)},[e.workflowShare,t]);h.useEffect(()=>{nr().catch(()=>{le([]),Ce([]),me([]),Ue(!1)})},[nr]);const Wr=h.useCallback(async()=>{const te=String(t||"").trim();if(!te){H(null),X(null);return}z(!0),L(""),F("");try{const ye=new URLSearchParams({tapdId:te});e.workflowShare&&ye.set("workflowShare",e.workflowShare);const[Me,Ae]=await Promise.all([fetch(`/api/prd-workflow/share?${ye.toString()}`),fetch(`/api/prd-workflow/collaboration?tapdId=${encodeURIComponent(te)}`)]),[ut,Pt]=await Promise.all([Me.json().catch(()=>({})),Ae.json().catch(()=>({}))]);if(!Me.ok)throw new Error(ut.error||"读取 Workflow 分享状态失败");Ae.ok&&X(Pt.collaboration||null);let Nn=ut.share||null;const Je=ut.canCreate===!0&&!e.workflowShare;if(V(Je),!Nn&&Je){const hn=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:te})}),rr=await hn.json().catch(()=>({}));if(!hn.ok)throw new Error(rr.error||"生成 Workflow 分享链接失败");if(Nn=rr.share||null,!Pt.collaboration){const dn=await fetch(`/api/prd-workflow/collaboration?tapdId=${encodeURIComponent(te)}`),Tr=await dn.json().catch(()=>({}));dn.ok&&X(Tr.collaboration||null)}}H(Nn)}catch(ye){L(String(ye.message||ye))}finally{z(!1)}},[e,t]),Sn=h.useRef(0),Jn=h.useCallback(()=>{P(!0),Wr(),nr().catch(te=>L(String(te.message||te)))},[nr,Wr]);h.useEffect(()=>{!r||r===Sn.current||(Sn.current=r,Jn())},[r,Jn]);const Hr=h.useRef(0),Vn=h.useCallback(async()=>{if(!(!t||e.workflowShare)){ze(!0),ke("");try{const[te,ye]=await Promise.all([nr(),fetch(`/api/workflows/conversation?tapdId=${encodeURIComponent(t)}`)]),Me=await ye.json().catch(()=>({}));ye.ok&&Bt(Array.isArray(Me.messages)?Me.messages:[])}catch(te){ke(String(te.message||te))}}},[e.workflowShare,nr,t]);h.useEffect(()=>{!i||i===Hr.current||(Hr.current=i,Vn())},[i,Vn]);const Kn=async()=>{if(!(!t||lt||!Se)){xt(!0),L("");try{const te=await fetch("/api/workflows/knowledge-bindings",{method:"PUT",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t,workspaceIds:De})}),ye=await te.json().catch(()=>({}));if(!te.ok)throw new Error(ye.error||"保存知识工作区绑定失败");le(Array.isArray(ye.bindings)?ye.bindings:[]),ye.collaboration&&X(ye.collaboration)}catch(te){L(String(te.message||te))}finally{xt(!1)}}},dr=async te=>{const ye=String(te||"").trim();if(!t||!ye||Mt)return;const Me=[...Xe,{role:"user",content:ye}];Bt(Me),Qt(!0),ke("");try{const Ae=await fetch("/api/workflows/query",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t,question:ye,messages:Xe})}),ut=await Ae.json().catch(()=>({}));if(!Ae.ok)throw new Error(ut.error||"Workflow AI 分析失败");Bt(Array.isArray(ut.messages)?ut.messages:[...Me,{role:"assistant",content:ut.content||""}]),st(Array.isArray(ut.sources)?ut.sources:[])}catch(Ae){ke(String(Ae.message||Ae)),Bt(Xe)}finally{Qt(!1)}},fr=async()=>{if(!(!t||E||e.workflowShare)){O(!0),L(""),F("");try{const te=await fetch("/api/prd-workflow/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...e,tapdId:t})}),ye=await te.json().catch(()=>({}));if(!te.ok)throw new Error(ye.error||"生成 Workflow 分享链接失败");H(ye.share||null),V(!0);const Me=await fetch(`/api/prd-workflow/collaboration?tapdId=${encodeURIComponent(t)}`),Ae=await Me.json().catch(()=>({}));Me.ok&&X(Ae.collaboration||null)}catch(te){L(String(te.message||te))}finally{O(!1)}}},qn=async()=>{const te=await Gb((M==null?void 0:M.shortUrl)||(M==null?void 0:M.url)||"");F(te?"已复制":"复制失败")},_r=async()=>{if(!(!t||E||!(M!=null&&M.canManage))){O(!0),L(""),F("");try{const te=await fetch("/api/prd-workflow/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t})}),ye=await te.json().catch(()=>({}));if(!te.ok)throw new Error(ye.error||"取消 Workflow 分享链接失败");H(null),V(!0)}catch(te){L(String(te.message||te))}finally{O(!1)}}},yr=async(te=q,ye=ne)=>{const Me=String(te||"").trim();if(!(!t||!Me||K)){ee(!0),L("");try{const Ae=await fetch("/api/prd-workflow/collaboration/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t,username:Me,role:ye})}),ut=await Ae.json().catch(()=>({}));if(!Ae.ok)throw new Error(ut.error||"更新成员权限失败");X(ut.collaboration||null),B("")}catch(Ae){L(String(Ae.message||Ae))}finally{ee(!1)}}},kt=async te=>{const ye=String((te==null?void 0:te.userId)||"").trim();if(!(!t||!ye||re)){se(ye),L("");try{const Me=await fetch("/api/prd-workflow/collaboration/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:t,memberUserId:ye})}),Ae=await Me.json().catch(()=>({}));if(!Me.ok)throw new Error(Ae.error||"移除成员授权失败");X(Ae.collaboration||null)}catch(Me){L(String(Me.message||Me))}finally{se("")}}},ct=(M==null?void 0:M.shortUrl)||(M==null?void 0:M.url)||"",Zt=(A==null?void 0:A.role)==="owner";return s.jsxs("main",{className:"af-prd-workflow af-prd-workflow--timeline","aria-label":"PRD Workflow",children:[s.jsxs("section",{className:"af-prd-workflow__statusbar",children:[s.jsxs("div",{className:"af-prd-workflow__status-main",children:[s.jsx("span",{className:`af-prd-workflow-phase af-prd-workflow-phase--${Ee.toLowerCase().replace(/[^a-z0-9_-]+/gi,"_")}`,children:dC(Ee)}),s.jsx("h1",{children:yn}),s.jsx("p",{className:"af-prd-workflow__status-subtitle",children:t?s.jsxs(s.Fragment,{children:["TAPD ",s.jsx("strong",{children:t})," · ",e.workflowDemo?"本地只读示例":"独立需求 Workflow"]}):s.jsx(s.Fragment,{children:"尚未选择 TAPD 需求"})}),l?s.jsx("p",{className:"af-prd-workflow-error",children:l}):null,gn||rn.subscribers||Q.length?s.jsxs("div",{className:"af-prd-workflow-collab",children:[gn?s.jsxs("span",{children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"lock"}),gn.title||gn.action||"Workflow action"," 执行中",gn.userId?s.jsx("small",{children:gn.userId}):null]}):null,rn.subscribers?s.jsxs("span",{children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group"}),rn.subscribers," 个连接"]}):null,Q.slice(0,3).map(te=>s.jsxs("span",{className:"af-prd-workflow-knowledge-chip",title:[te.label,te.branch,te.repoUrl].filter(Boolean).join(" · "),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"database"}),te.label,te.type||te.branch?s.jsx("small",{children:[te.type,te.branch].filter(Boolean).join(" · ")}):null]},te.workspaceId)),Q.length>3?s.jsxs("span",{className:"af-prd-workflow-knowledge-chip af-prd-workflow-knowledge-chip--more",children:["+",Q.length-3," 个知识库"]}):null]}):null]}),s.jsxs("form",{className:"af-prd-workflow__lookup",onSubmit:te=>{te.preventDefault(),m==null||m()},children:[s.jsx("div",{className:"af-prd-workflow-flow","aria-label":"需求流程阶段",children:Pn.map(te=>s.jsxs("div",{className:`af-prd-workflow-flow__step af-prd-workflow-flow__step--${te.status}`,children:[s.jsx("span",{"aria-hidden":"true"}),s.jsx("small",{children:te.label})]},te.label))}),s.jsxs("div",{className:"af-prd-workflow__lookup-row",children:[s.jsxs("label",{children:[s.jsx("span",{children:"TAPD Workflow"}),s.jsx("input",{value:t,onChange:te=>n(te.target.value),readOnly:e.workflowDemo,placeholder:"输入需求 ID",autoComplete:"off",spellCheck:!1})]}),s.jsxs("button",{type:"submit",disabled:a,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:a?"hourglass_empty":"sync"}),a?"读取中":t?"刷新":"读取"]})]})]})]}),p?s.jsxs("section",{className:"af-prd-workflow-conflict","aria-label":"Workflow conflict",children:[s.jsxs("div",{children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"sync_problem"}),s.jsxs("div",{children:[s.jsx("strong",{children:"状态已变化,需要重新确认"}),s.jsx("p",{children:p.message||"当前 workflow 状态和执行前不一致。"})]})]}),s.jsxs("dl",{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"执行时 revision"}),s.jsx("dd",{children:p.expectedRevision||"空"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"当前 revision"}),s.jsx("dd",{children:p.currentRevision||"未知"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"当前状态"}),s.jsx("dd",{children:[dC(p.currentPhase),p.currentPointer].filter(Boolean).join(" · ")||"未知"})]})]}),s.jsx("div",{className:"af-prd-workflow-conflict__actions",children:s.jsx("button",{type:"button",onClick:()=>m==null?void 0:m(),disabled:a||c,children:"刷新状态"})})]}):null,s.jsxs("section",{className:"af-prd-workflow__main",children:[s.jsxs("article",{className:"af-prd-workflow-actions","aria-label":"Workflow actions",children:[s.jsxs("div",{className:"af-prd-workflow-actions__head",children:[s.jsxs("div",{children:[s.jsx("h2",{children:"Action 时间线"}),s.jsx("p",{children:ie.length?`${ur}/${It.length} 已完成${_!=="all"?` · 共 ${ie.length}`:""}`:"等待 prd-flow 返回 action 列表"})]}),pn&&Fm(pn)?s.jsxs("div",{className:"af-prd-workflow-local-command",children:[s.jsx("span",{children:"本地 agent 执行"}),s.jsx("code",{children:pn.command||uo(pn,0)})]}):null]}),He.length?s.jsxs("div",{className:"af-prd-workflow-action-filters","aria-label":"Action tag filters",children:[s.jsxs("button",{type:"button",className:_==="all"?"is-active":"","aria-pressed":_==="all",onClick:()=>j("all"),children:["全部 ",s.jsx("span",{children:ie.length})]}),He.map(te=>s.jsxs("button",{type:"button",className:_===te.key?"is-active":"","aria-pressed":_===te.key,onClick:()=>j(te.key),children:[te.label," ",s.jsx("span",{children:te.count})]},te.key))]}):null,s.jsx("div",{className:"af-prd-workflow-action-list",children:It.length?jt.map(te=>s.jsxs("section",{className:"af-prd-workflow-action-day",children:[s.jsxs("div",{className:"af-prd-workflow-action-day__label",children:[s.jsx("span",{children:te.day}),s.jsx("small",{children:"北京时间"})]}),s.jsx("div",{className:"af-prd-workflow-action-day__items",children:te.items.map(({item:ye,index:Me})=>{const Ae=ja(ye.status),ut=ha(ye)==="observation"&&Ae==="done"?"observed":Ae,Pt=Uv(ye),Nn=mJ(ye),Je=bJ(ye),hn=uJ(ye,Me),rr=dJ(ye);return s.jsxs("div",{className:`af-prd-workflow-action af-prd-workflow-action--${ut}`,children:[s.jsx("div",{className:"af-prd-workflow-action__rail",children:s.jsx("span",{className:"af-prd-workflow-action__dot"})}),s.jsxs("div",{className:"af-prd-workflow-action__body",children:[s.jsxs("div",{className:"af-prd-workflow-action__top",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"af-prd-workflow-action__title",children:[Nn?s.jsx("time",{dateTime:Dm(ye),children:Nn}):null,s.jsx("strong",{children:hn})]}),rr?s.jsx("p",{children:rr}):null,Je.length?s.jsx("div",{className:"af-prd-workflow-action__meta",children:Je.map(dn=>s.jsxs("span",{className:`af-prd-workflow-action__meta-item af-prd-workflow-action__meta-item--${dn.label==="Issue"?"issue":"platform"}`,title:`${dn.label} · ${dn.value}`,children:[s.jsx("b",{children:dn.label}),s.jsx("span",{className:"af-prd-workflow-action__meta-value",children:dn.value})]},`${dn.label}-${dn.value}`))}):null]}),s.jsx("span",{className:"af-prd-workflow-action__status",children:yJ(ye)})]}),Pt.length?s.jsx("div",{className:"af-prd-workflow-action__links",children:Pt.map(dn=>s.jsxs("a",{href:dn.href,target:"_blank",rel:"noreferrer",children:[s.jsx("span",{children:dn.label}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]},`${dn.label}-${dn.href}`))}):null]})]},ye.id||ye.actionId||`${uo(ye,Me)}-${Me}`)})})]},te.day)):s.jsxs("div",{className:"af-prd-workflow-action-empty",children:[s.jsx("strong",{children:t?ie.length?"当前 tag 下暂无 action":"暂无 prd-flow 上报 action":"先选择 TAPD 需求"}),s.jsx("p",{children:t?ie.length?"切换到其它 tag 或查看全部。":"Workflow tab 不会生成默认步骤;需要 prd-flow snapshot 返回 actions/timeline/events/history 或 nextAction。":"选择后从 prd-flow 读取真实 action、产物和 URL。"})]})})]}),s.jsxs("aside",{className:"af-prd-workflow-side","aria-label":"Workflow related links",children:[s.jsx(sQ,{globalState:gr,tapdId:t}),Ye.length?s.jsxs("article",{className:"af-prd-workflow-card",children:[s.jsxs("div",{className:"af-prd-workflow-card__head",children:[s.jsx("h2",{children:"关联产物"}),s.jsx("span",{children:Ye.length})]}),s.jsx("div",{className:"af-prd-workflow-list",children:Ye.map((te,ye)=>{const Me=Rc(te),Ae=String(te.label||te.title||te.kind||Me||`Artifact ${ye+1}`);return Me?s.jsxs("a",{href:Me,target:"_blank",rel:"noreferrer",children:[s.jsx("span",{children:Ae}),s.jsx("small",{children:te.kind||Me})]},`${Me}-${ye}`):s.jsxs("div",{children:[s.jsx("span",{children:Ae}),s.jsx("small",{children:te.kind||""})]},`${Ae}-${ye}`)})})]}):null,s.jsxs("article",{className:"af-prd-workflow-card",children:[s.jsxs("div",{className:"af-prd-workflow-card__head",children:[s.jsx("h2",{children:"AI Docs"}),s.jsx("span",{children:Ne.length})]}),s.jsx("div",{className:"af-prd-workflow-list",children:Ne.length?Ne.map(te=>{const ye=String(te.title||te.label||"ai-doc").trim(),Me=[te.label&&te.label!==ye?te.label:"",te.platform,te.issueKey].filter(Boolean);return s.jsxs("a",{className:"af-prd-ai-doc",href:te.href,target:"_blank",rel:"noreferrer",title:ye,children:[s.jsx("span",{className:"af-prd-ai-doc__title",children:ye}),s.jsx("small",{className:"af-prd-ai-doc__meta",children:Me.join(" · ")||te.kind||"ai-doc"})]},te.href)}):s.jsx("p",{className:"af-prd-workflow-muted",children:"暂无 ai-doc 文档。"})})]}),s.jsxs("article",{className:"af-prd-workflow-card",children:[s.jsxs("div",{className:"af-prd-workflow-card__head",children:[s.jsx("h2",{children:"Issues"}),s.jsx("span",{children:Kt||rt.length})]}),s.jsx("div",{className:"af-prd-workflow-issues",children:un.length?un.map(te=>s.jsxs("div",{className:"af-prd-workflow-epic",children:[s.jsxs("div",{className:"af-prd-workflow-epic__head",children:[s.jsx("strong",{children:te.title||te.key}),s.jsx("small",{children:Fb(te.issues)})]}),te.issues.map((ye,Me)=>s.jsx(a$,{row:ye,index:Me},Oi((ye==null?void 0:ye.issue)||{},Me)))]},te.key)):s.jsx("p",{className:"af-prd-workflow-muted",children:"暂无 Issue 信息。"})})]}),s.jsxs("article",{className:"af-prd-workflow-card",children:[s.jsxs("div",{className:"af-prd-workflow-card__head",children:[s.jsx("h2",{children:"运行审计"}),s.jsxs("span",{children:[$n.length,"/",cr.length]})]}),s.jsx("div",{className:"af-prd-workflow-audit-filter",role:"tablist","aria-label":"运行审计筛选",children:[["all","全部"],["errors","异常"],["review","Review"],["external","外部"]].map(([te,ye])=>s.jsx("button",{type:"button",className:k===te?"is-active":"",onClick:()=>x(te),children:ye},te))}),s.jsx("div",{className:"af-prd-workflow-audit",children:$n.length?$n.map((te,ye)=>s.jsxs("div",{children:[s.jsx("strong",{children:uo(te,ye)}),s.jsx("small",{children:[te.status,te.type,Dm(te)].filter(Boolean).join(" · ")})]},te.id||`${te.type}-${ye}`)):s.jsx("p",{className:"af-prd-workflow-muted",children:"暂无运行事件。"})})]}),Yn||u?s.jsxs("article",{className:"af-prd-workflow-card af-prd-workflow-card--raw",children:[s.jsx("div",{className:"af-prd-workflow-card__head",children:s.jsx("h2",{children:"Raw"})}),s.jsx("pre",{children:u||Yn})]}):null]})]}),N?er.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal af-display-link-modal",role:"dialog","aria-modal":"true","aria-label":"需求协作",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"需求协作"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>P(!1),"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("section",{className:"af-prd-workflow-access-panel","aria-label":"Workflow 成员权限",children:[s.jsxs("div",{className:"af-prd-workflow-access-panel__head",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"成员权限"}),s.jsx("small",{children:"TAPD Owner 自动管理;TAPD 参与人默认只读"})]}),((Nt=A==null?void 0:A.authority)==null?void 0:Nt.type)==="tapd"?s.jsx("span",{children:"TAPD 已同步"}):s.jsx("span",{children:"待 TAPD 同步"})]}),Zt?s.jsxs("div",{className:"af-workspace-member-add af-prd-workflow-member-add",children:[s.jsx("input",{type:"text",value:q,onChange:te=>B(te.target.value),onKeyDown:te=>{te.key==="Enter"&&q.trim()&&!K&&(te.preventDefault(),yr())},placeholder:"输入 AgentFlow 用户名","aria-label":"成员用户名"}),s.jsxs("select",{value:ne,onChange:te=>ce(te.target.value),"aria-label":"成员权限",children:[s.jsx("option",{value:"reporter",children:"可上报"}),s.jsx("option",{value:"viewer",children:"只读"})]}),s.jsx("button",{type:"button",disabled:K||!q.trim(),onClick:()=>void yr(),children:K?"保存中...":"保存权限"})]}):null,s.jsx("div",{className:"af-workspace-member-list",children:((A==null?void 0:A.members)||[]).map(te=>{const ye=te.role==="owner"||te.userId===(A==null?void 0:A.ownerId),Me=te.source==="explicit",Ae=ye?"需求 Owner":te.role==="reporter"?"可上报":te.source==="tapd"?"TAPD 参与人 · 只读":"只读";return s.jsxs("div",{className:"af-workspace-member-row",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:ye?"shield_person":"person"}),s.jsxs("div",{children:[s.jsx("strong",{children:te.username||te.userId}),s.jsx("small",{children:Ae})]}),Zt&&!ye?s.jsxs("div",{className:"af-prd-workflow-member-actions",children:[s.jsxs("select",{value:te.role==="reporter"?"reporter":"viewer",disabled:K||!!re,onChange:ut=>void yr(te.username||te.userId,ut.target.value),"aria-label":`${te.username||te.userId} 的权限`,children:[s.jsx("option",{value:"reporter",children:"可上报"}),s.jsx("option",{value:"viewer",children:"只读"})]}),Me?s.jsx("button",{type:"button",disabled:re===te.userId,onClick:()=>void kt(te),children:re===te.userId?"移除中...":"移除授权"}):null]}):null]},te.userId)})}),(ue=(jn=A==null?void 0:A.authority)==null?void 0:jn.unresolvedParticipants)!=null&&ue.length?s.jsxs("p",{className:"af-prd-workflow-access-panel__unresolved",children:["尚未匹配 AgentFlow 账号:",A.authority.unresolvedParticipants.join("、")]}):null]}),e.workflowShare?null:s.jsxs("section",{className:"af-prd-workflow-access-panel af-workflow-knowledge-panel","aria-label":"Workflow 知识工作区",children:[s.jsxs("div",{className:"af-prd-workflow-access-panel__head",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"AI 知识工作区"}),s.jsx("small",{children:"AI 会结合需求上下文,在隔离的代码快照中回答问题;不会修改真实仓库"})]}),s.jsx("span",{children:Q.length?`已绑定 ${Q.length} 个`:"未绑定"})]}),Se?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"af-workflow-knowledge-options",children:fe.length?fe.map(te=>{const ye=De.includes(te.workspaceId);return s.jsxs("label",{className:ye?"is-selected":"",children:[s.jsx("input",{type:"checkbox",checked:ye,onChange:()=>Ce(Me=>ye?Me.filter(Ae=>Ae!==te.workspaceId):[...Me,te.workspaceId])}),s.jsxs("span",{children:[s.jsx("strong",{children:te.label}),s.jsx("small",{children:[te.type,te.branch,te.repoUrl].filter(Boolean).join(" · ")})]})]},te.workspaceId)}):s.jsx("p",{className:"af-prd-workflow-muted",children:"暂无可绑定的知识工作区,请先在知识库页面配置并同步 Git 仓库。"})}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:lt,onClick:()=>void Kn(),children:lt?"保存中...":"保存知识绑定"})]}):s.jsx("div",{className:"af-workflow-knowledge-bindings",children:Q.length?Q.map(te=>s.jsxs("span",{children:[te.label,te.branch?` · ${te.branch}`:""]},te.workspaceId)):s.jsx("p",{className:"af-prd-workflow-muted",children:"Owner 尚未绑定代码知识工作区;仍可只基于需求上下文提问。"})})]}),s.jsx("div",{className:"af-prd-workflow-share-divider",children:s.jsx("span",{children:"只读链接"})}),s.jsxs("p",{className:"af-display-link-modal__empty",children:["通过链接分享 TAPD ",t,";不会授予上报权限,也不会分享当前 Project、画布或项目文件。"]}),T?s.jsx("div",{className:"af-display-link-modal__empty",children:"正在生成分享链接..."}):null,!T&&ct?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"af-display-link-modal__url",children:[s.jsx("input",{type:"text",value:ct,readOnly:!0,onFocus:te=>te.currentTarget.select(),"aria-label":"Workflow 分享链接"}),s.jsxs("button",{type:"button",disabled:E,onClick:()=>void qn(),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),W||"复制链接"]}),M.canManage?s.jsx("button",{type:"button",disabled:E,onClick:()=>void _r(),children:E?"处理中...":"取消分享"}):null]}),s.jsx("div",{className:"af-prd-workflow-share-note",children:"获得链接的人无需登录即可只读查看同一份 Workflow;链接不会授予需求推进或项目编辑权限。"})]}):null,!T&&!ct&&$?s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:E,onClick:()=>void fr(),children:E?"生成中...":"生成分享链接"}):null,D?s.jsx("div",{className:"af-flow-snippet-error",children:D}):null]}),s.jsx("div",{className:"af-flow-snippet-modal__foot",children:s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>P(!1),children:"完成"})})]})}),document.body):null,at?er.createPortal(s.jsx("aside",{className:"af-pipeline-drawer af-pipeline-drawer--wide af-workflow-ai-drawer","aria-label":"Workflow AI",children:s.jsxs("div",{className:"af-composer-sidebar",children:[s.jsxs("div",{className:"af-pipeline-drawer-head",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"af-pipeline-drawer-title",children:"Workflow AI"}),s.jsxs("small",{children:["TAPD ",t," · 需求与代码只读分析"]})]}),s.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:()=>ze(!1),"aria-label":"关闭 Workflow AI",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-workflow-ai-context",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"verified_user"}),s.jsxs("div",{children:[s.jsx("strong",{children:Q.length?`${Q.length} 个代码知识工作区`:"仅需求上下文"}),s.jsx("small",{children:Q.length?"优先使用上报 commit/ref,否则使用绑定分支或本地 HEAD":"请让需求 Owner 在“协作”中绑定代码仓库"})]})]}),s.jsx(h.Suspense,{fallback:s.jsxs("div",{className:"af-workflow-assistant-loading",role:"status",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"}),"正在准备需求 AI…"]}),children:s.jsx($Y,{messages:Xe,running:Mt,error:de,sources:qe,suggestions:["这个需求目前做到哪里了?","核心实现逻辑在哪些文件?","当前实现还有哪些风险或遗漏?"],onSend:dr})})]})}),document.body):null]})}function OC(e,t){if(!(e!=null&&e[`has${t[0].toUpperCase()}${t.slice(1)}`]))return"(删除该字段)";const n=e==null?void 0:e[t];if(typeof n=="string")return n;try{return JSON.stringify(n,null,2)}catch{return String(n)}}function rd(e){if(!(e!=null&&e.hasIncoming))return"null";try{return JSON.stringify(e.incoming,null,2)}catch{return JSON.stringify(String(e.incoming))}}function oQ(e,t,n,r=!0){const i=JSON.parse(JSON.stringify(e||{})),o=Array.isArray(t)?t:[];if(!o.length)return r?n:{};let a=i;for(let c=0;c<o.length-1;c+=1){const u=o[c],f=o[c+1];(!a[u]||typeof a[u]!="object")&&(a[u]=Number.isInteger(f)?[]:{}),a=a[u]}const l=o[o.length-1];return r?a[l]=n:Array.isArray(a)&&Number.isInteger(l)?a.splice(l,1):delete a[l],i}function aQ(){var i0,o0,a0,l0;const{t:e,i18n:t}=zr(),{navigate:n}=us(),r=su(),i=vn(),o=K6(),a=h.useMemo(UY,[]),l=!!a.workflowShare,c=h.useRef(new URLSearchParams(window.location.search).get("focusNodeId")||""),u=h.useMemo(()=>a.workspaceId?`agentflow.workspace.viewport:shared:${a.workspaceId}`:`agentflow.workspace.viewport:${a.flowSource||"user"}:${a.adminOwnerId||"self"}:${a.flowId||""}`,[a]),[f,p]=h.useState(()=>(()=>{if(a.workflowShare)return"workflow";const w=new URLSearchParams(window.location.search).get("view");return w==="display"||w==="workflow"?w:"workspace"})()),[d,m]=h.useState(!1),[y,v]=h.useState(!1),[b,g]=q6([]),[k,x]=U6([]),_=h.useRef([]),j=h.useRef([]),N=h.useRef(null),[P,T]=h.useState(()=>Hh(null,[])),z=h.useRef(P),[E,O]=h.useState(null),D=h.useRef(null),L=h.useRef(!1),[$,V]=h.useState([]),W=h.useRef(new Map),F=h.useRef(new Map),M=h.useRef(new Set),H=h.useRef(new Set),A=h.useRef(null),X=h.useRef(null),q=h.useRef([]),B=h.useRef(null),ne=h.useRef(null),ce=h.useRef(null),[K,ee]=h.useState(null),[re,se]=h.useState({}),Q=h.useRef({}),le=h.useRef(!1),fe=h.useRef(null),me=h.useRef(""),De=h.useRef(null),Ce=h.useRef(Promise.resolve()),Se=h.useRef({running:!1,pending:null}),Ue=h.useRef(0),lt=h.useRef(!1),xt=h.useRef(0),at=h.useRef(null),ze=h.useRef(!1),Xe=h.useRef(!1),Bt=h.useRef(""),Mt=h.useRef(!1),Qt=h.useRef(null),de=h.useRef(!1),ke=h.useRef(new Set),qe=h.useRef(!1),st=h.useRef(!1),Ee=h.useCallback(()=>CY({nodeInteraction:de.current,pointerCount:ke.current.size,viewportInteraction:qe.current}),[]),rt=h.useRef(typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`client-${Date.now()}-${Math.random().toString(36).slice(2)}`),un=h.useRef(!1),Kt=h.useRef(null),[yt,pn]=h.useState([]),ie=h.useRef([]),[Ne,Ye]=h.useState(""),[He,It]=h.useState("nodes"),[jt,cr]=h.useState([]),[$n,ur]=h.useState(!1),[rn,gn]=h.useState(""),[Yn,gr]=h.useState(!1),[yn,Pn]=h.useState({name:"",id:"",description:""}),[nr,Wr]=h.useState(!1),[Sn,Jn]=h.useState(""),[Hr,Vn]=h.useState(""),Kn=h.useRef(null),[dr,fr]=h.useState(!1),[qn,_r]=h.useState(!1),[yr,kt]=h.useState(""),[ct,Zt]=h.useState(null),[Nt,jn]=h.useState(()=>Hw()),[ue,te]=h.useState(""),[ye,Me]=h.useState(!1),[Ae,ut]=h.useState(""),[Pt,Nn]=h.useState(!1),[Je,hn]=h.useState([]),[rr,dn]=h.useState(!1),[Tr,oe]=h.useState(""),[ve,Re]=h.useState(""),[St,Dt]=h.useState(""),[sn,_n]=h.useState(!1),[Xn,_s]=h.useState(""),[Cs,G]=h.useState(""),[we,$e]=h.useState(!1),[Ie,nt]=h.useState("nodes"),[Tn,Wt]=h.useState(""),[Ln,wr]=h.useState(0),[Cr,on]=h.useState(""),fS=h.useRef(""),[wt,As]=h.useState(null),pS=h.useRef(null),[oL,kl]=h.useState(""),[vl,hS]=h.useState([]),[mS,aL]=h.useState(""),[_e,lL]=h.useState(!a.adminOwnerId),[Gf,cL]=h.useState(()=>a.adminOwnerId?{readonly:!0,ownerUserId:a.adminOwnerId,ownerUsername:a.adminOwnerId}:null),[Ft,Yf]=h.useState(null),[uL,Kg]=h.useState(!1),[qg,gS]=h.useState(!1),[yS,No]=h.useState(""),[pu,wS]=h.useState(""),[xS,bS]=h.useState(""),[Vs,dL]=h.useState(null),[Ug,kS]=h.useState("viewer"),[hu,vS]=h.useState(!1),[fL,pL]=h.useState(0),[hL,mL]=h.useState(0),[On,Sl]=h.useState(null),[gL,Na]=h.useState(!1),[Gg,jl]=h.useState({}),[Jf,SS]=h.useState(!1),[jS,mu]=h.useState(""),[Yg,yL]=h.useState(""),[wL,Nl]=h.useState(()=>new Set),[Jg,Xg]=h.useState(""),[gu,Qg]=h.useState({nodeId:"",query:""}),[NS,_S]=h.useState(!1),Zg=h.useRef(null),CS=h.useRef(null),AS=h.useRef(""),[ey,ES]=h.useState(()=>{try{const w=Number(window.localStorage.getItem("agentflow.workspace.filesPaneHeight")||0);if(Number.isFinite(w)&&w>=160)return w}catch{}return 360}),[xL,IS]=h.useState(!1),[_a,bL]=h.useState({cursor:[],opencode:[],claudeCode:[],codex:[]}),[Ki,kL]=h.useState(""),[Ks,vL]=h.useState([]),[PS,TS]=h.useState(!1),[qs,yu]=h.useState([]),[_l,SL]=h.useState([]),[RS,jL]=h.useState(!1),[MS,$S]=h.useState([]),[LS,OS]=h.useState([]),[en,NL]=h.useState(()=>{try{const w=String(new URLSearchParams(window.location.search).get("tapdId")||"").trim();return w||String(window.localStorage.getItem(`agentflow.workflow.tapdId:${a.flowSource||"user"}:${a.flowId||""}`)||"").trim()}catch{return""}}),[fn,wu]=h.useState(null),[_L,DS]=h.useState(!1),[CL,Cl]=h.useState(""),[ty,FS]=h.useState(!1),[ny,xu]=h.useState(""),[Es,bu]=h.useState(null),[ry,zS]=h.useState(!1),[ku,Al]=h.useState(null),[yi,vu]=h.useState([]),[Xf,Su]=h.useState([]),[AL,Qf]=h.useState(!1),[_o,Zf]=h.useState(!1),[BS,Co]=h.useState(""),[ep,tp]=h.useState(""),[WS,HS]=h.useState("workspace"),VS=h.useCallback(w=>{Kn.current&&window.clearTimeout(Kn.current),Vn(w),Kn.current=window.setTimeout(()=>{Vn(""),Kn.current=null},3800)},[]),Xr=h.useCallback(w=>{const S=Array.isArray(w)||w instanceof Set?w:[w];for(const C of S){const I=String(C||"").trim();I&&(M.current.add(I),H.current.add(I))}M.current.size!==0&&(A.current==null&&(A.current=window.requestAnimationFrame(()=>{A.current=null;const C=Array.from(M.current);M.current.clear(),C.forEach(I=>o(I))})),X.current!=null&&window.clearTimeout(X.current),X.current=window.setTimeout(()=>{X.current=null;const C=Array.from(H.current);H.current.clear(),C.forEach(I=>o(I))},80))},[o]);h.useEffect(()=>()=>{A.current!=null&&window.cancelAnimationFrame(A.current),X.current!=null&&window.clearTimeout(X.current),M.current.clear(),H.current.clear()},[]);const KS=h.useCallback((w,S)=>{const C=String(w||"").trim(),I=Vm(S);!C||!I||(g(R=>R.map(U=>{var ae;if(U.id!==C)return U;const Z=Vm((ae=U.data)==null?void 0:ae.displaySize),J=Z&&Z.width===I.width&&Z.height===I.height,Y=Math.round(Number(U.width||0))===I.width&&Math.round(Number(U.height||0))===I.height;return J&&Y?U:{...U,width:I.width,height:I.height,data:{...U.data,nodeSize:I,displaySize:I}}})),Xr(C))},[Xr,g]);h.useEffect(()=>{try{window.localStorage.setItem("agentflow.workspace.filesPaneHeight",String(Math.round(ey)))}catch{}},[ey]);const sy=h.useCallback(w=>{const S=Zg.current;if(!S)return null;const C=S.getBoundingClientRect(),I=16,R=150,U=230,Z=C.top+I,J=C.bottom-I,Y=Math.max(R,J-Z-U);return Math.min(Math.max(w-Z,R),Y)},[]),EL=h.useCallback(w=>{w.preventDefault(),w.stopPropagation();const S=Zg.current;if(!S)return;let C=sy(w.clientY);if(!Number.isFinite(C))return;IS(!0),ES(C);const I=U=>{U.preventDefault();const Z=sy(U.clientY);Number.isFinite(Z)&&(C=Z,S.style.setProperty("--af-work-files-pane-height",`${Math.round(Z)}px`))},R=()=>{ES(C),IS(!1),window.removeEventListener("pointermove",I,!0),window.removeEventListener("pointerup",R,!0),window.removeEventListener("pointercancel",R,!0)};window.addEventListener("pointermove",I,!0),window.addEventListener("pointerup",R,!0),window.addEventListener("pointercancel",R,!0)},[sy]);h.useEffect(()=>()=>{Kn.current&&window.clearTimeout(Kn.current),Kt.current&&window.clearTimeout(Kt.current)},[]);const[IL,qS]=h.useState(()=>new Set),[np,iy]=h.useState(!1),oy=h.useRef(null),US=h.useRef(null),GS=h.useRef(null),[PL,TL]=h.useState({}),[El,ay]=h.useState(""),[fs,YS]=h.useState(!1),[Ca,Il]=h.useState([]),[Us,sr]=h.useState([]),[Qr,Is]=h.useState("workspace"),[ju,Pl]=h.useState(!1),JS=h.useRef(null),ly=h.useRef(null),[Nu,Tl]=h.useState(null),[RL,cy]=h.useState(!0),[XS,QS]=h.useState(""),[Aa,Ao]=h.useState({}),[Vr,uy]=h.useState(null),[ZS,dy]=h.useState(!1),Rl=h.useMemo(()=>ZS?ZY(Vr):"",[ZS,Vr]),[_u,rp]=h.useState(!0);h.useEffect(()=>{Rl&&rp(eJ(Rl))},[Rl]),h.useEffect(()=>{if(Rl)try{window.localStorage.setItem(Rl,_u?"true":"false")}catch{}},[_u,Rl]);const[fy,sp]=h.useState(!1),[py,ej]=h.useState(!1),[hy,tj]=h.useState("pan"),[nj,ML]=h.useState({}),Cu=h.useRef({}),[rj,Ea]=h.useState({}),Au=h.useRef(new Map),Eu=h.useRef(new Set),[sj,Ml]=h.useState(()=>new Set),[my,$l]=h.useState({}),[ij,oj]=h.useState(""),[Bde,ge]=h.useState(""),[aj,Gs]=h.useState("loading"),[lj,Ys]=h.useState("正在载入 Project"),qi=h.useMemo(()=>QY(a),[a]),[cj,uj]=h.useState(""),Iu=a.flowSource||"user",dj=h.useMemo(()=>new Set(Object.values(nj||{}).map(w=>String((w==null?void 0:w.runNodeId)||"").trim()).filter(Boolean)),[nj]),Ui=h.useCallback(w=>{const S=Cu.current||{},C=typeof w=="function"?w(S):w,I=C&&typeof C=="object"&&!Array.isArray(C)?C:{};return Cu.current=I,ML(I),I},[]),fj=!!(a.flowId&&!a.adminOwnerId&&!a.archived&&(Ft!=null&&Ft.role?Ft.role==="owner":Iu==="user"||Iu==="workspace")),Pu=!!(!a.adminOwnerId&&Iu==="workspace"&&(Ft!=null&&Ft.role)&&Ft.role!=="owner"),pj={loading:"载入中",dirty:"有未同步修改",saving:"同步中",synced:"已同步",conflict:"同步冲突",error:"同步失败",readonly:"只读"}[aj]||"同步状态",wi=h.useCallback(()=>{!le.current||!_e||(Mt.current=!1,Ue.current+=1,lt.current=!0,Gs("dirty"),Ys("本地修改等待同步"))},[_e]);h.useEffect(()=>{a.flowId&&_z(a.flowId,a.flowSource||"user","workspace",!!a.archived)},[a]),h.useEffect(()=>{const w=()=>{const S=new URLSearchParams(window.location.search).get("view");p(S==="display"||S==="workflow"?S:"workspace")};return window.addEventListener("popstate",w),()=>window.removeEventListener("popstate",w)},[]),h.useEffect(()=>{Il([]),sr([]),Is("workspace"),cy(!0)},[a]);const Dn=h.useCallback(async()=>{const w=$r(a),S=await fetch(`/api/workspace/files?${w.toString()}`),C=await S.json();if(!S.ok)throw new Error(C.error||"读取 workspace 失败");const I=C.files||[];hS(I),Nl(new Set(XM(I))),aL(C.root||"")},[a]),ip=h.useCallback(async()=>{ur(!0),gn("");try{const w=await fetch("/api/marketplace/flow-snippets"),S=await w.json().catch(()=>({}));if(!w.ok)throw new Error(S.error||"读取流程片段失败");cr(Array.isArray(S.snippets)?S.snippets:[])}catch(w){gn(String(w.message||w)),cr([])}finally{ur(!1)}},[]),hj=h.useCallback(async(w,S,C)=>{var Y,ae,he;if(!le.current)return;if(!_e)throw ge("Readonly workspace"),Gs("readonly"),Ys("只读 Project"),new Error("Readonly workspace");Gs("saving"),Ys("正在同步修改");const I=Xl(w,S,Q.current);I.ui={...I.ui||{},displayPage:kC(z.current,w)};const R=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:I,baseRevision:me.current,baseGraph:De.current,clientId:rt.current})}),U=await R.json().catch(()=>({}));if(!R.ok){if(R.status===409||R.status===428){const je=Array.isArray(U.conflictItems)?U.conflictItems:[];Sl({currentRevision:String(U.currentRevision||""),message:U.error||"Workspace 已被其他成员更新",conflictPaths:Array.isArray(U.conflictPaths)?U.conflictPaths:[],conflictItems:je,mergeGraph:U.mergeGraph||null,currentGraph:U.currentGraph||null}),jl(Object.fromEntries(je.map((We,Le)=>[String(Le),{mode:"local",manual:rd(We)}]))),mu(""),Na(je.length>0),Gs("conflict"),Ys(U.error||"存在需要处理的字段冲突");const Ve=Array.isArray(U.conflictPaths)?U.conflictPaths:[],Be=Ve.length?`${U.error||"Workspace 已被其他成员更新"}:${Ve.join("、")}`:U.error||"Workspace 已被其他成员更新",Ke=new Error(Be);throw Ke.code="WORKSPACE_REVISION_CONFLICT",Ke.currentRevision=U.currentRevision||"",Ke}const pe=new Error(U.error||"保存 workspace graph 失败");throw Gs("error"),Ys(pe.message),pe}const Z=Ue.current!==C,J=_Y({savedGraph:U.graph,sentGraph:I,savedRevision:U.revision,currentRevision:me.current});if(me.current=J.revision,De.current=J.graph,!Z){if(Q.current=((Y=U.graph)==null?void 0:Y.instances)||I.instances,se(Q.current),U.merged&&U.graph){const pe=nd(U.graph,yt),je=Hh((he=(ae=U.graph)==null?void 0:ae.ui)==null?void 0:he.displayPage,pe.nodes);Q.current=pe.instances,se(pe.instances),g(pe.nodes),x(pe.edges),z.current=je,T(je)}lt.current=!1}return Ea(uh(U.workspaceSchedules||[])),Sl(null),Na(!1),Gs(Z?"dirty":"synced"),Ys(Z?"本地仍有修改等待同步":"所有修改已同步"),ge(Z?"已保存上一版,本地新修改正在排队":U.merged?"Workspace graph merged and saved":"Workspace graph saved"),U},[a,yt,x,g,_e]),an=h.useCallback((w=b,S=k)=>{const C=Se.current,I={nextNodes:w,nextEdges:S,saveEditVersion:Ue.current,waiters:[]},R=new Promise((J,Y)=>{I.waiters.push({resolve:J,reject:Y})});if(C.running)return C.pending=aC(C.pending,I),R;C.running=!0;const U=async()=>{let J=I;for(;J;){C.pending&&(J=aC(J,C.pending),C.pending=null);try{const Y=await hj(J.nextNodes,J.nextEdges,J.saveEditVersion);J.waiters.forEach(({resolve:ae})=>ae(Y))}catch(Y){(Y==null?void 0:Y.code)!=="WORKSPACE_REVISION_CONFLICT"&&(Gs("error"),Ys(String(Y.message||Y))),J.waiters.forEach(({reject:ae})=>ae(Y)),(Y==null?void 0:Y.code)==="WORKSPACE_REVISION_CONFLICT"&&C.pending&&(C.pending.waiters.forEach(({reject:ae})=>ae(Y)),C.pending=null)}J=C.pending,C.pending=null}C.running=!1},Z=Ce.current.catch(()=>{}).then(U);return Ce.current=Z,R},[k,b,hj]),$L=h.useCallback(w=>{var C;const S=(C=w==null?void 0:w.extra)!=null&&C.instances&&typeof w.extra.instances=="object"?w.extra.instances:{};Q.current=S,se(S),g(Array.isArray(w==null?void 0:w.nodes)?w.nodes:[]),x(Array.isArray(w==null?void 0:w.edges)?w.edges:[]),on(""),ee(null)},[x,g]),LL=h.useMemo(()=>({instances:re}),[re]),OL=tY({nodes:b,edges:k,extra:LL,enabled:le.current,onRestore:$L}),{resetHistory:Tu,undo:mj,redo:gj}=OL,Ps=h.useCallback(async(w={})=>{var Oe,Ht;const S=(w==null?void 0:w.background)===!0,C=xt.current+1;xt.current=C;const I=Ue.current,R=me.current;S||(le.current=!1);const U=RY({background:S}),Z=$r(a);let J=null,Y;if(!U.nodes&&!U.files)Y=await fetch(`/api/workspace/graph?${Z.toString()}`);else{const Fe=$r(a);Fe.set("lang",String(t.language||"zh").startsWith("zh")?"zh":"en");const[ht,$t]=await Promise.all([fetch(`/api/nodes?${Fe.toString()}`),fetch(`/api/workspace/graph?${Z.toString()}`),Dn()]);if(J=await ht.json(),!ht.ok)throw new Error(J.error||"读取节点定义失败");Y=$t}const ae=await Y.json();if(!Y.ok)throw new Error(ae.error||"读取 workspace graph 失败");const he=NY({background:S,requestId:C,currentRequestId:xt.current,dirty:lt.current,startedEditVersion:I,currentEditVersion:Ue.current,startedRevision:R,currentRevision:me.current});if(he==="superseded")return{skipped:!0,reason:he};if(he==="local-edits")return ge("检测到远端更新;本地修改将在保存时自动合并"),{skipped:!0,reason:he};const pe=S?ie.current:[...(Array.isArray(J)?J:J.nodes||[]).filter(Fe=>!OY.has(Fe.id)),HY,WY,zY,BY,DY,FY];S||(ie.current=pe,pn(pe));const je=ae.graph||JSON.parse(localStorage.getItem(LY)||"null")||{},Ve=nd(je,pe),Be=Hh((Oe=je==null?void 0:je.ui)==null?void 0:Oe.displayPage,Ve.nodes),Ke=!L.current;let We=D.current;if(Ke){let Fe=null;try{Fe=JSON.parse(window.localStorage.getItem(u)||"null")}catch{Fe=null}We=Ub(Fe)||Ub((Ht=je==null?void 0:je.ui)==null?void 0:Ht.viewport)}const Le=S?kY(De.current,je):null;if(S&&(Le!=null&&Le.safe)){const Fe=Le.nodesChanged?vY(_.current,Ve.nodes,Le.changedNodeIds):_.current,ht=Le.edgesChanged?SY(j.current,Ve.edges):j.current,$t=Le.displayPageChanged||!co(z.current,Be),Vl=Le.nodesChanged||Le.edgesChanged||$t;if(Vl&&(Mt.current=!0),Le.nodesChanged){const xi=jY(Q.current,Ve.instances,Le.changedNodeIds);Q.current=xi,_.current=Fe,se(xi),g(Fe)}if(Le.edgesChanged&&(j.current=ht,x(ht)),$t&&(z.current=Be,T(Be)),Vl&&Tu(Fe,ht,{instances:Le.nodesChanged?Q.current:Ve.instances}),Le.nodesChanged||$t){const xi=new Set(Be.nodeIds);V(Ta=>{const Ra=Ta.filter(kp=>xi.has(kp));return Ra.length===Ta.length?Ta:Ra})}}else Q.current=Ve.instances,_.current=Ve.nodes,j.current=Ve.edges,z.current=Be,Mt.current=!0,se(Ve.instances),g(Ve.nodes),x(Ve.edges),T(Be),V([]),Tu(Ve.nodes,Ve.edges,{instances:Ve.instances});const Ut=uh(ae.workspaceSchedules||[]);Ea(Fe=>co(Fe,Ut)?Fe:Ut),me.current=String(ae.revision||""),De.current=je,lt.current=!1;const ot=ae.collaboration||null;Yf(Fe=>co(Fe,ot)?Fe:ot),cL(ae.adminReview||null),Sl(null),Ke&&(O(We),D.current=We,L.current=!0);const Qe=ae.writable!==!1;return lL(Qe),ge(Qe?"Workspace ready":"Readonly workspace"),Gs(Qe?"synced":"readonly"),Ys(Qe?"所有修改已同步":ae.adminReview?`管理员只读查看:${ae.adminReview.ownerUsername||ae.adminReview.ownerUserId||"其他用户"}`:"只读 Project"),le.current=!0,{skipped:!1}},[a,t.language,Dn,Tu,x,g,u]),Ll=h.useCallback((w={})=>{if(!le.current)return;const S=String(w.revision||""),C=w.type==="graph.committed",I=!!(at.current||ze.current||Xe.current);if(MY({eventType:w.type,revision:S,currentRevision:me.current,targetRevision:Bt.current,refreshPending:I}))return;if(C&&S&&(Bt.current=S),lt.current){Xe.current=!1,ge("检测到其他成员的更新;保存时将自动合并");return}if(Xe.current=!0,at.current||ze.current)return;const R=async()=>{if(at.current=null,Ee()){Xe.current=!0;return}if(lt.current){Xe.current=!1,ge("检测到其他成员的更新;保存时将自动合并");return}Xe.current=!1,ze.current=!0;try{await Ps({background:!0}),Bt.current=me.current}catch(U){Bt.current="",ge(String(U.message||U))}finally{ze.current=!1,Xe.current&&!lt.current&&(at.current=window.setTimeout(R,40))}};at.current=window.setTimeout(R,40)},[Ps,Ee]),Ru=h.useCallback(async(w=en)=>{const S=String(w||"").trim();DS(!0),Cl("");try{if(a.workflowDemo){const U=GY(S);if(!U)throw new Error("本地示例数据已失效,请返回迭代页重新载入示例");wu(U),xu(""),bu(null),Al(null);return}const C=$r(a);C.set("tapdId",S),C.set("runtimeOnly","1");const I=await fetch(`/api/prd-workflow/snapshot?${C.toString()}`),R=await I.json().catch(()=>({}));if(!I.ok)throw new Error(R.error||"读取 PRD Workflow 失败");wu(R.snapshot||null),xu(""),bu(null),Al(null);try{const U=`agentflow.workflow.tapdId:${a.flowSource||"user"}:${a.flowId||""}`;S?window.localStorage.setItem(U,S):window.localStorage.removeItem(U)}catch{}}catch(C){Cl(String(C.message||C))}finally{DS(!1)}},[a,en]),gy=h.useCallback(async()=>{const w=String(en||"").trim();if(!w||a.workflowShare||a.workflowDemo){vu([]),Su([]);return}const S=await fetch(`/api/workflows/project-bindings?tapdId=${encodeURIComponent(w)}`),C=await S.json().catch(()=>({}));if(!S.ok)throw new Error(C.error||"读取 Project 绑定失败");const I=Array.isArray(C.bindings)?C.bindings:[],R=Array.isArray(C.availableProjects)?C.availableProjects:[];vu(I),Su(R),tp(U=>R.some(Z=>Bo(Z)===U)?U:R[0]?Bo(R[0]):"")},[a.workflowDemo,a.workflowShare,en]),DL=h.useCallback(async()=>{const w=Xf.find(S=>Bo(S)===ep);if(!(!w||!en||_o)){Zf(!0),Co("");try{const S=await fetch("/api/workflows/project-bindings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:en,...w})}),C=await S.json().catch(()=>({}));if(!S.ok)throw new Error(C.error||"绑定 Project 失败");const I=Array.isArray(C.availableProjects)?C.availableProjects:[];vu(Array.isArray(C.bindings)?C.bindings:[]),Su(I),tp(I[0]?Bo(I[0]):"")}catch(S){Co(String(S.message||S))}finally{Zf(!1)}}},[Xf,_o,ep,en]),FL=h.useCallback(async w=>{if(!(!(w!=null&&w.workspaceId)||!en||_o)){Zf(!0),Co("");try{const S=await fetch("/api/workflows/project-bindings",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({tapdId:en,workspaceId:w.workspaceId})}),C=await S.json().catch(()=>({}));if(!S.ok)throw new Error(C.error||"解除 Project 绑定失败");const I=Array.isArray(C.availableProjects)?C.availableProjects:[];vu(Array.isArray(C.bindings)?C.bindings:[]),Su(I),tp(R=>I.some(U=>Bo(U)===R)?R:I[0]?Bo(I[0]):"")}catch(S){Co(String(S.message||S))}finally{Zf(!1)}}},[_o,en]),Ol=h.useCallback(async(w=null,S={})=>{const C=w&&typeof w=="object"?w:fn==null?void 0:fn.nextAction,I=Fm(C);if(!I||ty)return;const R=(S==null?void 0:S.confirm)===!0,U=String((S==null?void 0:S.expectedRevision)||(fn==null?void 0:fn.revision)||"");FS(!0),Cl(""),R||(xu(""),bu(null),Al(null));try{const Z=await fetch("/api/prd-workflow/action",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,tapdId:en,action:I,stage:hl(C),title:uo(C,0),...vJ(C),dryRun:!R,confirm:R,issueKey:C.issueKey||C.issue_key||"",expectedRevision:U,idempotencyKey:`workflow-${Date.now()}-${Math.random().toString(36).slice(2)}`})}),J=await Z.json().catch(()=>({}));if(!Z.ok||J.ok===!1)throw J.snapshot&&wu(J.snapshot),J.conflict&&Al({...J.conflict,action:C}),new Error(J.error||"执行 PRD Workflow action 失败");xu(J.rawOutput||(J.output?JSON.stringify(J.output,null,2):"")),wu(J.snapshot||fn),Al(null),bu(R?null:{action:C,output:J.output||null,expectedRevision:U,at:new Date().toISOString()})}catch(Z){Cl(String(Z.message||Z))}finally{FS(!1)}},[a,ty,fn,en]),zL=h.useCallback((w=null)=>Ol(w,{confirm:!1}),[Ol]),BL=h.useCallback(()=>{const w=(Es==null?void 0:Es.action)||(fn==null?void 0:fn.nextAction);return Ol(w,{confirm:!0,expectedRevision:(Es==null?void 0:Es.expectedRevision)||""})},[Ol,Es,fn]),WL=h.useCallback(()=>{const w=(ku==null?void 0:ku.action)||(fn==null?void 0:fn.nextAction);return Al(null),Ol(w,{confirm:!1})},[Ol,ku,fn]),HL=h.useCallback(async()=>{var U,Z;const w=String(ny||(fn==null?void 0:fn.rawOutput)||"").trim();if(!w||ry)return;const S=(Es==null?void 0:Es.action)||(fn==null?void 0:fn.nextAction)||{},C=`Review: ${uo(S,0)||(fn==null?void 0:fn.pointer)||en||"PRD Workflow"}`,I=/^[\[{]/.test(w),R=w.startsWith("#")?w:`# ${C}
|
|
247
|
+
|
|
248
|
+
${I?`\`\`\`json
|
|
249
|
+
${w}
|
|
250
|
+
\`\`\``:w}`;zS(!0),Cl("");try{const J=await fetch("/api/workflow-artifacts/publish",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,workflow:{namespace:"tapd",id:en},title:C,markdown:R,action:Fm(S),stage:hl(S),issueKey:S.issueKey||S.issue_key||"",artifactLabel:"临时 Review"})}),Y=await J.json().catch(()=>({}));if(!J.ok||Y.ok===!1)throw new Error(Y.error||"生成 Review 链接失败");wu(Y.snapshot||fn);const ae=((U=Y.review)==null?void 0:U.shortUrl)||((Z=Y.review)==null?void 0:Z.url)||"";ae&&xu(he=>`${he||w}
|
|
251
|
+
|
|
252
|
+
Review link: ${ae}`)}catch(J){Cl(String(J.message||J))}finally{zS(!1)}},[a,ny,Es,ry,fn,en]),VL=h.useCallback(async(w,S)=>{const C={packageId:(w==null?void 0:w.newId)||(w==null?void 0:w.id)||(w==null?void 0:w.label),label:(w==null?void 0:w.label)||(w==null?void 0:w.newId)||(w==null?void 0:w.id),version:"1.0.0",definitionId:S,body:(w==null?void 0:w.body)||"",script:(w==null?void 0:w.script)||"",scriptRef:(w==null?void 0:w.scriptRef)||"",implementationRef:(w==null?void 0:w.implementationRef)||"",implementationMode:(w==null?void 0:w.implementationMode)||"",inputs:Array.isArray(w==null?void 0:w.inputs)?w.inputs:[],outputs:Array.isArray(w==null?void 0:w.outputs)?w.outputs:[],flowId:a.flowId,flowSource:a.flowSource||"user",archived:!!a.archived},I=await fetch("/api/marketplace/publish-node-from-instance",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(C)}),R=await I.json().catch(()=>({}));if(!I.ok||(R==null?void 0:R.ok)===!1)throw new Error((R==null?void 0:R.error)||"Publish failed");return await Ps(),ge(`Published node ${R.definitionId||R.id||C.packageId}`),R},[a,Ps]),Ia=h.useCallback((w=Us)=>{const S=Array.isArray(w)?w:[],I=[...S].reverse().find(R=>(R==null?void 0:R.status)==="running"||(R==null?void 0:R.status)==="stopping")||[...S].reverse().find(R=>R==null?void 0:R.id);return String((I==null?void 0:I.id)||"workspace")},[Us]),KL=h.useCallback(w=>{const S=String(w||"").trim();!S||S==="workspace"||sr(C=>{const I=(Array.isArray(C)?C:[]).filter(R=>R.id!==S);return Is(R=>R===S?Ia(I):R),I})},[Ia]);h.useCallback((w="")=>{Pl(!0),Tl(null),As(null),Is(w||Ia())},[Ia]);const yj=h.useCallback((w={})=>{Tl({scheduleNodeId:String(w.scheduleNodeId||""),runNodeId:String(w.runNodeId||w.nodeId||""),lastRunId:String(w.lastRunId||""),label:String(w.label||"")}),Pl(!1),As(null),on("")},[]),yy=h.useCallback(async(w="")=>{const S=String(w||"").trim();if(!(!S||!_e)){oj(S),ge(`Optimizing run: ${S}`);try{await an(_.current,j.current);const C=Xl(_.current,j.current,Q.current),I=MC(_.current,Q.current,S,Ki),R=await fetch("/api/workspace/run/optimize",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runNodeId:S,graph:C,model:I})}),U=await R.json().catch(()=>({}));if(!R.ok||U.ok===!1)throw new Error(U.error||"优化失败");const Z=U.graph||C,J=nd(Z,yt);Q.current=J.instances,se(J.instances),g(J.nodes),x(J.edges),Ea(uh(U.workspaceSchedules||[])),Tu(J.nodes,J.edges,{instances:J.instances});const Y=Array.isArray(U.optimized)?U.optimized.length:0;ge(Y>0?`已生成 ${Y} 个 implementation`:"没有需要优化的节点")}catch(C){ge(String(C.message||C))}finally{oj("")}}},[Ki,j,a,_,yt,Tu,an,x,g,_e]),wj=h.useCallback(async(w="")=>{const S=String(w||"").trim(),C=Cu.current||{},I=Object.entries(C).find(([Y,ae])=>Y===S||String((ae==null?void 0:ae.runNodeId)||"")===S)||Object.entries(C)[0]||null,R=(I==null?void 0:I[0])||"",U=(I==null?void 0:I[1])||null,Z=String((U==null?void 0:U.runNodeId)||S||"").trim();if((U==null?void 0:U.status)==="stopping")return;const J=new Set([Z,...Array.isArray(U==null?void 0:U.plannedNodeIds)?U.plannedNodeIds:[]].map(Y=>String(Y||"").trim()).filter(Boolean));R&&Ui(Y=>{const ae={...Y};return ae[R]&&(ae[R]={...ae[R],status:"stopping"}),ae}),ge(Z?`Stopping Workspace run: ${Z}...`:"Stopping Workspace run..."),sr(Y=>Y.map(ae=>(R?ae.id===R:!Z||ae.runNodeId===Z)&&ae.status==="running"?{...ae,status:"stopping"}:ae));try{const Y=await fetch("/api/workspace/run/stop",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,runId:R,runNodeId:Z})}),ae=await Y.json().catch(()=>({}));if(!Y.ok||(ae==null?void 0:ae.stopped)!==!0)throw new Error(ae.error||"Workspace run stop failed");const he=R?Au.current.get(R):null;he&&(he.abort(),Au.current.delete(R)),R&&Ui(pe=>{const je={...pe};return delete je[R],je}),Ml(pe=>{const je=new Set(pe);for(const Ve of J)je.delete(Ve);return je}),$l(pe=>{var Ve;const je={...pe};for(const Be of J)Be&&(!je[Be]||((Ve=je[Be])==null?void 0:Ve.status)==="running")&&(je[Be]={status:"stopped"});return je}),ge(Z?`Workspace run stopped: ${Z}`:"Workspace run stopped"),sr(pe=>pe.map(je=>(R?je.id===R:!Z||je.runNodeId===Z)?{...je,status:"stopped",endedAt:Date.now(),messages:[...Array.isArray(je.messages)?je.messages:[],{role:"assistant",kind:"status",text:"Workspace run stopped.",at:Date.now()}].slice(-160)}:je))}catch(Y){R&&Ui(he=>{const pe={...he};return pe[R]&&(pe[R]={...pe[R],status:"running"}),pe});const ae=String((Y==null?void 0:Y.message)||Y||"Workspace run stop failed");ge(`停止失败:${ae}`),sr(he=>he.map(pe=>(R?pe.id===R:!Z||pe.runNodeId===Z)?{...pe,status:"running",messages:[...Array.isArray(pe.messages)?pe.messages:[],{role:"assistant",kind:"error",error:!0,text:`停止失败:${ae}`,at:Date.now()}].slice(-160)}:pe))}},[a,Ui]),op=h.useCallback(async()=>{if(a.flowId)try{const w=$r(a),S=await fetch(`/api/workspace/run/status?${w.toString()}`),C=await S.json().catch(()=>({}));if(!S.ok||!C.running)return;const I=Array.isArray(C.runs)&&C.runs.length?C.runs:[{runId:`run-restored-${C.startedAt||Date.now()}`,runNodeId:C.runNodeId||"",startedAt:C.startedAt||Date.now(),plannedNodeIds:[]}],R={},U=[];for(const Z of I){const J=String((Z==null?void 0:Z.runNodeId)||"").trim(),Y=String((Z==null?void 0:Z.runId)||`run-restored-${(Z==null?void 0:Z.startedAt)||Date.now()}-${J}`).trim();if(!Y)continue;const ae=String((Z==null?void 0:Z.label)||"").trim()||Fw(_.current,Q.current,J,"Workspace Run");R[Y]={id:Y,runNodeId:J,label:ae,status:(Z==null?void 0:Z.state)==="stopping"?"stopping":"running",plannedNodeIds:Array.isArray(Z==null?void 0:Z.plannedNodeIds)?Z.plannedNodeIds:[],startedAt:(Z==null?void 0:Z.startedAt)||Date.now()},J&&U.push(J)}if(!Object.keys(R).length)return;Ui(Z=>({...Z,...R})),Ml(Z=>{const J=new Set(Z);for(const Y of U)J.add(Y);return J}),$l(Z=>{const J={...Z};for(const Y of U)J[Y]={status:"running"};return J}),ge(U.length?`Workspace run still running: ${U.join(", ")}`:"Workspace run still running"),sr(Z=>{const J=[...Z];for(const[Y,ae]of Object.entries(R)){if(J.some(je=>je.id===Y||["running","stopping"].includes(je.status)&&je.runNodeId===ae.runNodeId))continue;const he=String(ae.runNodeId||""),pe=String(ae.label||"").trim()||Fw(_.current,Q.current,he,"Workspace Run");J.push({id:Y,label:zw(pe,he,"Workspace Run"),alias:pe,runNodeId:he,status:ae.status,startedAt:ae.startedAt||Date.now(),steps:he?[{id:he,label:zw(pe,he,"Workspace Run"),status:"running"}]:[],messages:[{role:"assistant",kind:"run-summary",text:ae.status==="stopping"?"Workspace run is stopping in the background.":"Workspace run is still running in the background.",at:Date.now()}]})}return[...J.slice(-8)]})}catch{}},[a,_,Ui]),xj=h.useCallback(async w=>{if(!_e){ge("Readonly workspace");return}if(!w)return;if(Object.values(Cu.current||{}).find(ot=>String((ot==null?void 0:ot.runNodeId)||"")===String(w||""))){ge(`Workspace run already running: ${w}`);return}let C=_.current,I=j.current,R=Q.current;const U=pS.current;if(U!=null&&U.id){const ot=C.find(Oe=>Oe.id===U.id),Qe=LC({nodes:C,edges:I,instances:R,selectedNode:ot,draft:U,allowRename:!1});if(Qe!=null&&Qe.error){kl(Qe.error),ge(Qe.error);return}Qe!=null&&Qe.ok&&Qe.changed&&(C=Qe.nodes,I=Qe.edges,R=Qe.instances,Q.current=R,_.current=C,j.current=I,se(R),g(C),x(I),Xr(Qe.nextId||U.id))}const Z=Xl(C,I,R),J=`run-${Date.now()}-${String(w).replace(/[^a-z0-9_-]+/gi,"_")}`,Y=Fw(C,R,w,"Workspace Run"),ae=zw(Y,w,"Workspace Run");let he=[w];try{const ot=await fetch("/api/workspace/run/plan",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:Z,runNodeId:w})}),Qe=await ot.json().catch(()=>({}));if(!ot.ok||(Qe==null?void 0:Qe.ok)===!1)throw new Error(Qe.error||"Workspace run plan failed");he=Array.isArray(Qe.plannedNodeIds)&&Qe.plannedNodeIds.length?Qe.plannedNodeIds.map(Ht=>String(Ht||"").trim()).filter(Boolean):[w],he=Array.from(new Set([w,...he].filter(Boolean)));const Oe=Qe.conflict||null;if(Oe!=null&&Oe.runNodeId||Oe!=null&&Oe.runId){const Ht=Array.isArray(Oe.conflictNodeIds)&&Oe.conflictNodeIds.length?`: ${Oe.conflictNodeIds.join(", ")}`:"";ge(`Run ${w} conflicts with running ${Oe.runNodeId||Oe.runId}${Ht}`);return}}catch(ot){ge(String(ot.message||ot));return}const pe=new Set(he),je=Object.values(Cu.current||{}).find(ot=>(Array.isArray(ot==null?void 0:ot.plannedNodeIds)?ot.plannedNodeIds:[]).some(Qe=>pe.has(String(Qe||"").trim())));if(je){const ot=(Array.isArray(je.plannedNodeIds)?je.plannedNodeIds:[]).map(Qe=>String(Qe||"").trim()).filter(Qe=>Qe&&pe.has(Qe));ge(`Run ${w} conflicts with running ${je.runNodeId||"workspace run"}${ot.length?`: ${ot.join(", ")}`:""}`);return}const Ve=new AbortController;Au.current.set(J,Ve),Eu.current.delete(J),Ui(ot=>({...ot,[J]:{id:J,runNodeId:w,label:Y,plannedNodeIds:he,startedAt:Date.now()}})),Ml(ot=>new Set([...ot,w])),$l(ot=>({...ot,[w]:{status:"running"}})),ge(`Running ${ae}...`),Is(J),sr(ot=>[...ot.slice(-7),{id:J,label:ae,alias:Y,runNodeId:w,status:"running",startedAt:Date.now(),steps:[],messages:[{role:"assistant",kind:"run-summary",text:"准备运行...",at:Date.now()}]}]);let Be=w;const Ke=new Map,We=()=>Eu.current.has(J),Le=ot=>{const Qe=new Set((ot||[]).map(Oe=>String(Oe||"").trim()).filter(Boolean));Qe.size||Qe.add(String(w||"")),Ml(Oe=>{const Ht=new Set(Oe);for(const Fe of Qe)Ht.delete(Fe);return Ht})},Ut=(ot,Qe)=>{const Oe=new Set((ot||[]).map(Ht=>String(Ht||"").trim()).filter(Boolean));Oe.size||Oe.add(String(w||"")),$l(Ht=>{var ht;const Fe={...Ht};for(const $t of Oe)$t&&(!Fe[$t]||((ht=Fe[$t])==null?void 0:ht.status)==="running")&&(Fe[$t]={status:Qe});return Fe})};try{await an(C,I);const ot=MC(C,R,w,Ki),Qe=await fetch("/api/workspace/run",{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/x-ndjson"},signal:Ve.signal,body:JSON.stringify({...a,graph:Z,runNodeId:w,runAlias:Y,runSessionId:J,expectedRevision:me.current,clientId:rt.current,model:ot,selectedSkills:qs,stream:!0})});if(!Qe.ok){const xe=await Qe.json().catch(()=>({}));throw new Error(xe.error||"Workspace run failed")}if(!Qe.body)throw new Error("Workspace run stream unavailable");const Oe=Qe.body.getReader(),Ht=new TextDecoder;let Fe="",ht=[],$t=[];const Vl=(xe,it)=>{var dt,Tt;const Ze=b.find(qt=>qt.id===xe),mt=String(((dt=Ze==null?void 0:Ze.data)==null?void 0:dt.label)||xe||"").trim(),be=String(it||((Tt=Ze==null?void 0:Ze.data)==null?void 0:Tt.definitionId)||"").trim();return be&&be!==mt?`${mt} (${be})`:mt},xi=(xe,it,Ze)=>{const mt=String(xe||"").trim();mt&&sr(be=>be.map(dt=>{if(dt.id!==J)return dt;const qt=[...Array.isArray(dt.steps)?dt.steps:[]],gt=qt.findIndex(wn=>wn.id===mt),Ct={id:mt,label:Vl(mt,it),status:Ze};gt>=0?qt[gt]={...qt[gt],...Ct}:qt.push(Ct);const mn=qt.map((wn,To)=>{const Ji=wn.status==="done"?"[done]":wn.status==="failed"?"[failed]":"[running]";return`${To+1}. ${Ji} ${wn.label}`}).join(`
|
|
253
|
+
`),tn=Array.isArray(dt.messages)?dt.messages:[],ln=tn.findIndex(wn=>wn.kind==="run-summary"),Cn={role:"assistant",kind:"run-summary",text:mn||"准备运行...",at:Date.now()},Gt=[...tn];return ln>=0?Gt[ln]=Cn:Gt.unshift(Cn),{...dt,steps:qt,messages:Gt.slice(-160)}}))},Ta=(xe,it)=>{var p0,h0,m0,g0,y0,w0,x0,b0,k0,v0;const Ze=String(xe||"").trim(),mt=String(it||"").trim();if(!Ze||!mt)return;const be=(p0=Q.current)==null?void 0:p0[Ze];if(!di(be==null?void 0:be.definitionId))return;const dt=ga(be==null?void 0:be.input,"displayType","markdown"),Tt=n$(dt),qt=r$(Ze),gt=yt.find(Kr=>Kr.id===Tt),Ct=IC(gt==null?void 0:gt.inputs,Tt,mt),mn=IC(gt==null?void 0:gt.outputs,Tt,mt),tn=String((be==null?void 0:be.label)||Ze||"一键任务").trim(),ln={...Q.current||{},[Ze]:{...be||{},output:TC(be==null?void 0:be.output)},[qt]:{...((h0=Q.current)==null?void 0:h0[qt])||{},definitionId:Tt,label:tn,role:"normal",body:mt,input:Ct,output:mn,sourceContextRunNodeId:Ze,displayReloadKey:String(Date.now())}};Q.current=ln,se(ln);const Cn=_.current||[],Gt=Cn.find(Kr=>Kr.id===Ze),wn=Cn.find(Kr=>Kr.id===qt),To=Number(((m0=Gt==null?void 0:Gt.measured)==null?void 0:m0.width)||(Gt==null?void 0:Gt.width)||((y0=(g0=Gt==null?void 0:Gt.data)==null?void 0:g0.nodeSize)==null?void 0:y0.width)||520),Ji=(wn==null?void 0:wn.position)||{x:Number(((w0=Gt==null?void 0:Gt.position)==null?void 0:w0.x)||0)+To+120,y:Number(((x0=Gt==null?void 0:Gt.position)==null?void 0:x0.y)||0)},br=((b0=wn==null?void 0:wn.data)==null?void 0:b0.displaySize)||((k0=wn==null?void 0:wn.data)==null?void 0:k0.nodeSize)||{width:Bb,height:Wb},bi=Db({id:qt,type:Tc,position:Ji,width:Number(br.width)||Bb,height:Number(br.height)||Wb,data:{label:tn,definitionId:Tt,role:"normal",body:mt,inputs:Ct,outputs:mn,sourceContextRunNodeId:Ze,displayReloadKey:ln[qt].displayReloadKey,nodeSize:br,displaySize:br}},ln,yt),Ro=Cn.map(Kr=>{if(Kr.id===Ze){const{width:Wde,height:Hde,measured:Vde,...qO}=Kr,{nodeSize:Kde,displaySize:qde,..._p}=Kr.data||{};return{...qO,data:{..._p,outputs:TC(_p==null?void 0:_p.outputs),contextRunResultNonce:Date.now()}}}return Kr.id===qt?{...bi,selected:Kr.selected}:Kr});wn||Ro.push(bi),_.current=Ro,g(Ro);const Mo=j.current||[],Np=s$(Tt),Ty=PC((be==null?void 0:be.output)||((v0=Gt==null?void 0:Gt.data)==null?void 0:v0.outputs),"output",["content","result"],["text"]),VO=PC(Ct,"input",[Np,"content"],["text"]),KO={id:`we-${Ze}-${qt}`,source:Ze,target:qt,sourceHandle:Ty,targetHandle:VO,markerEnd:{type:Ii.ArrowClosed}},f0=[...Mo.filter(Kr=>!(Kr.source===Ze&&Kr.target===qt)),KO];j.current=f0,x(f0),window.requestAnimationFrame(()=>{o(Ze),o(qt)})},Ra=(xe,it=null)=>{const Ze=xe!=null&&xe.instances&&typeof xe.instances=="object"?xe.instances:{},mt=it instanceof Set?it:null;for(const[be,dt]of Object.entries(Ze)){if(mt&&!mt.has(be)||!di(dt==null?void 0:dt.definitionId))continue;const Tt=Og({outputs:dt.output});Tt&&Ta(be,Tt)}},kp=xe=>{const it=String(xe||"").trim();if(!it)return;const Ze=Be;Be=it,Ml(mt=>{const be=new Set(mt);return Ze&&Ze!==it&&Ze!==w&&be.delete(Ze),w&&be.add(w),be.add(it),be}),$l(mt=>{var be;return{...mt,...Ze&&Ze!==it&&Ze!==w&&((be=mt[Ze])==null?void 0:be.status)==="running"?{[Ze]:{status:"success"}}:{},...w?{[w]:{status:"running"}}:{},[it]:{status:"running"}}})},c0=xe=>{const it=String(xe||"").trim();it&&(Ml(Ze=>{const mt=new Set(Ze);return mt.delete(it),mt}),$l(Ze=>({...Ze,[it]:{status:"success"}})))},u0=(xe,it)=>{const Ze=String(it||"");if(!Ze.trim())return;const mt=["assistant","thinking","result","error","prompt"].includes(xe)?xe:"assistant";sr(be=>be.map(dt=>{if(dt.id!==J)return dt;let Tt=Array.isArray(dt.messages)?dt.messages:[];if(mt==="result"){const Ct=[...Tt].reverse().find(mn=>mn.kind==="assistant");if(String((Ct==null?void 0:Ct.text)||"").trim()===Ze.trim())return dt}if(mt==="assistant"){const Ct=Tt.findIndex(mn=>mn.kind==="result"&&String(mn.text||"").trim()===Ze.trim());Ct>=0&&(Tt=Tt.filter((mn,tn)=>tn!==Ct))}const qt=[...Tt],gt=qt[qt.length-1];return gt&>.kind===mt&&!gt.error?qt[qt.length-1]={...gt,text:`${gt.text||""}${gt.text?`
|
|
254
|
+
`:""}${Ze}`}:qt.push({role:"assistant",kind:mt,text:Ze,...mt==="error"?{error:!0}:{},at:Date.now()}),{...dt,messages:qt.slice(-160)}}))},vp=xe=>{const it=String(xe||"");it.trim()&&sr(Ze=>Ze.map(mt=>{var qt;if(mt.id!==J)return mt;const be=Array.isArray(mt.messages)?mt.messages:[],dt=be.findIndex(gt=>gt.kind==="thinking"),Tt=[...be];if(dt>=0){const gt=String(((qt=Tt[dt])==null?void 0:qt.text)||"");Tt[dt]={...Tt[dt],text:`${gt}${gt&&!gt.endsWith(`
|
|
255
|
+
`),""}${it}`,at:Date.now()}}else{const gt=Tt.findIndex(Ct=>Ct.kind==="activity");Tt.splice(gt>=0?gt+1:Tt.length,0,{role:"assistant",kind:"thinking",text:it,at:Date.now()})}return{...mt,messages:Tt.slice(-160)}}))},Po=(xe,it=null)=>{const Ze=rJ(xe);Ze&&sr(mt=>mt.map(be=>{if(be.id!==J)return be;const dt=Number(it==null?void 0:it.ts)||Date.now(),Tt=Number(be.startedAt)||dt,qt=Number(be.lastActivityAt)||Tt,gt=Math.max(0,dt-qt),Ct=Number.isFinite(Number(it==null?void 0:it.runElapsedMs))?Math.max(0,Number(it.runElapsedMs)):Math.max(0,dt-Tt),mn=Array.isArray(be.activities)?be.activities:[],tn=mn[mn.length-1],Cn=(typeof tn=="string"?tn:String((tn==null?void 0:tn.text)||""))===Ze?mn:[...mn,{text:Ze,kind:iJ(Ze),stepMs:gt,totalMs:Ct,at:dt}].slice(-30),Gt=Array.isArray(be.timingEntries)?be.timingEntries:[],wn=Array.isArray(be.messages)?be.messages:[],To=wn.findIndex(bi=>bi.kind==="activity"),Ji={role:"assistant",kind:"activity",text:pC(Cn,Gt,Tt,dt),at:Date.now()},br=[...wn];if(To>=0)br[To]=Ji;else{const bi=br.findIndex(Ro=>Ro.kind==="run-summary");br.splice(bi>=0?bi+1:0,0,Ji)}return{...be,activities:Cn,lastActivityAt:dt,messages:br.slice(-160)}}))},d0=xe=>{const it=String((xe==null?void 0:xe.source)||"runner"),Ze=String((xe==null?void 0:xe.stream)||""),mt=String((xe==null?void 0:xe.eventType)||"event"),be=String((xe==null?void 0:xe.text)||"").trim();if(!be)return;const dt=`[${it}${Ze?`:${Ze}`:""}] ${mt}
|
|
256
|
+
${be}`,Tt=DJ(xe);sr(qt=>qt.map(gt=>{if(gt.id!==J)return gt;const mn=[...Array.isArray(gt.rawTrace)?gt.rawTrace:[],dt].slice(-80),tn=Array.isArray(gt.timingEntries)?gt.timingEntries:[],ln=Tt?[...tn,Tt].slice(-80):tn,Cn=Array.isArray(gt.activities)?gt.activities:[],Gt=Number(gt.startedAt)||Number(xe==null?void 0:xe.ts)||Date.now(),wn=Number(Tt==null?void 0:Tt.at)||Number(xe==null?void 0:xe.ts)||Date.now(),To=Array.isArray(gt.messages)?gt.messages:[],Ji={role:"assistant",kind:"raw",text:mn.join(`
|
|
257
|
+
|
|
258
|
+
---
|
|
259
|
+
|
|
260
|
+
`),at:Date.now()},br=[...To],bi=br.findIndex(Mo=>Mo.kind==="activity");if(Tt){const Mo={role:"assistant",kind:"activity",text:pC(Cn,ln,Gt,wn),at:Date.now()};if(bi>=0)br[bi]=Mo;else{const Np=br.findIndex(Ty=>Ty.kind==="run-summary");br.splice(Np>=0?Np+1:0,0,Mo)}}const Ro=br.findIndex(Mo=>Mo.kind==="raw");return Ro>=0?br[Ro]=Ji:br.push(Ji),{...gt,rawTrace:mn,timingEntries:ln,messages:br.slice(-160)}}))},HO=xe=>{sr(it=>it.map(Ze=>Ze.id===J?{...Ze,status:xe,endedAt:Date.now()}:Ze))},Sp=xe=>{const it=new Set,Ze=String((xe==null?void 0:xe.nodeId)||"").trim();Ze&&it.add(Ze);for(const mt of Array.isArray(xe==null?void 0:xe.displayNodeIds)?xe.displayNodeIds:[]){const be=String(mt||"").trim();be&&it.add(be)}for(const mt of Array.isArray(xe==null?void 0:xe.touchedNodeIds)?xe.touchedNodeIds:[]){const be=String(mt||"").trim();be&&it.add(be)}if(it.size===0)for(const mt of Array.isArray(xe==null?void 0:xe.order)?xe.order:[]){const be=String(mt||"").trim();be&&it.add(be)}return it},jp=(xe,it=null)=>{const Ze=nd(xe||Z,yt),mt=new Map(Ze.nodes.map(gt=>[gt.id,gt])),be=Ze.instances||{},dt=it instanceof Set?it:null,Tt=(gt,Ct)=>{const mn={...gt||Ct};Array.isArray(Ct==null?void 0:Ct.output)&&(mn.output=Ct.output);for(const tn of["scriptRef","implementationRef","implementationMode"])(Ct==null?void 0:Ct[tn])!=null&&String(Ct[tn]).trim()!==""&&(mn[tn]=Ct[tn]);return mn},qt=(gt,Ct)=>{const mn={...gt||{}};Array.isArray(Ct==null?void 0:Ct.outputs)&&(mn.outputs=Ct.outputs);for(const tn of["scriptRef","implementationRef","implementationMode"])(Ct==null?void 0:Ct[tn])!=null&&String(Ct[tn]).trim()!==""&&(mn[tn]=Ct[tn]);return mn};g(gt=>{const Ct=new Set(gt.map(ln=>ln.id)),tn={...Xl(gt,j.current,Q.current).instances||{}};for(const[ln,Cn]of Object.entries(be)){if(dt&&!dt.has(ln)||!Ct.has(ln))continue;const Gt=tn[ln];ml((Cn==null?void 0:Cn.definitionId)||(Gt==null?void 0:Gt.definitionId))?tn[ln]=Cn:Array.isArray(Cn==null?void 0:Cn.output)&&(tn[ln]=Tt(Gt,Cn))}return Q.current=tn,se(tn),gt.map(ln=>{var Gt,wn;if(dt&&!dt.has(ln.id))return ln;const Cn=mt.get(ln.id);return Cn?ml(((Gt=Cn.data)==null?void 0:Gt.definitionId)||((wn=ln.data)==null?void 0:wn.definitionId))?{...ln,data:{...ln.data,...Cn.data}}:{...ln,data:qt(ln.data,Cn.data)}:ln})})};for(;;){const{value:xe,done:it}=await Oe.read();if(it)break;Fe+=Ht.decode(xe,{stream:!0});const Ze=Fe.split(`
|
|
261
|
+
`);Fe=Ze.pop()||"";for(const mt of Ze){if(!mt.trim())continue;const be=JSON.parse(mt);if(be.type==="error")throw new Error(be.error||"Workspace run failed");if(be.type==="stopped"){Eu.current.add(J),ht=Array.isArray(be.order)?be.order:ht,Po("运行停止",be);continue}if(be.type==="node-start"&&(ge(`Running ${be.nodeId}...`),kp(be.nodeId),xi(be.nodeId,be.definitionId,"running")),be.type==="node-done"){const dt=Ke.get(String(be.nodeId||"").trim());dt&&Ta(be.nodeId,dt),c0(be.nodeId),xi(be.nodeId,be.definitionId,"done")}if(be.type==="status"&&Po(be.line||be.message||"",be),be.type==="paused"&&($t=Array.isArray(be.nodeIds)?be.nodeIds:[],Po("运行暂停",be)),be.type==="natural"&&((be.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(be.text||"")))&&be.nodeId&&Ke.set(String(be.nodeId||"").trim(),String(be.text||"")),be.kind==="thinking"?vp(be.text||""):u0(be.kind,be.text||"")),be.type==="raw"){const dt=hC(be);dt&&vp(dt),d0(be)}if(be.type==="graph"&&be.graph){const dt=Sp(be);jp(be.graph,dt),Ra(be.graph,dt)}if(be.type==="done"){if(be.revision&&(me.current=String(be.revision)),be.graph){De.current=be.graph;const dt=Sp(be);jp(be.graph,dt),Ra(be.graph,dt)}ht=Array.isArray(be.order)?be.order:[],$t=Array.isArray(be.pauseNodeIds)?be.pauseNodeIds:$t,Po($t.length?"运行暂停":"运行完成",be)}}}if(Fe.trim()){const xe=JSON.parse(Fe);if(xe.type==="error")throw new Error(xe.error||"Workspace run failed");if(xe.type==="stopped"&&(Eu.current.add(J),Po("运行停止",xe)),xe.type==="node-start"&&(ge(`Running ${xe.nodeId}...`),kp(xe.nodeId),xi(xe.nodeId,xe.definitionId,"running")),xe.type==="node-done"){const it=Ke.get(String(xe.nodeId||"").trim());it&&Ta(xe.nodeId,it),c0(xe.nodeId),xi(xe.nodeId,xe.definitionId,"done")}if(xe.type==="status"&&Po(xe.line||xe.message||"",xe),xe.type==="paused"&&($t=Array.isArray(xe.nodeIds)?xe.nodeIds:[],Po("运行暂停",xe)),xe.type==="natural"&&((xe.kind==="result"||/---agentflow\b|resultFile\s*:|\"resultFile\"\s*:|\"result\"\s*:/i.test(String(xe.text||"")))&&xe.nodeId&&Ke.set(String(xe.nodeId||"").trim(),String(xe.text||"")),xe.kind==="thinking"?vp(xe.text||""):u0(xe.kind,xe.text||"")),xe.type==="raw"){const it=hC(xe);it&&vp(it),d0(xe)}if(xe.type==="graph"&&xe.graph){const it=Sp(xe);jp(xe.graph,it),Ra(xe.graph,it)}if(xe.type==="done"){if(xe.revision&&(me.current=String(xe.revision)),xe.graph){De.current=xe.graph;const it=Sp(xe);jp(xe.graph,it),Ra(xe.graph,it)}ht=Array.isArray(xe.order)?xe.order:[],$t=Array.isArray(xe.pauseNodeIds)?xe.pauseNodeIds:$t,Po($t.length?"运行暂停":"运行完成",xe)}}We()&&(Le(he),Ut(he,"stopped"));const Py=We()?`Workspace run stopped: ${w}`:$t.length?`Workspace run paused at ${$t.join(", ")}`:`Workspace run done: ${ht.length?ht.join(" -> "):w}`;if(ge(Py),We()||Ut(he,$t.length?"paused":"success"),HO(We()?"stopped":$t.length?"paused":"done"),!We()){try{await an(_.current,j.current),ge(Py)}catch(xe){ge(`${Py},但保存结果失败:${String(xe.message||xe)}`)}await Dn()}}catch(ot){if(We()||(ot==null?void 0:ot.name)==="AbortError"){Le(he),Ut(he,"stopped"),ge(`Workspace run stopped: ${w}`),sr(Qe=>Qe.map(Oe=>Oe.id===J?{...Oe,status:"stopped",endedAt:Date.now()}:Oe));return}Le(he),Ut([w,Be].filter(Boolean),"failed"),ge(String(ot.message||ot)),sr(Qe=>Qe.map(Oe=>Oe.id===J?{...Oe,status:"failed",endedAt:Date.now(),messages:[...Array.isArray(Oe.messages)?Oe.messages:[],{role:"assistant",error:!0,text:String(ot.message||ot),at:Date.now()}].slice(-160)}:Oe))}finally{Au.current.get(J)===Ve&&Au.current.delete(J),Ui(ot=>{const Qe={...ot};return delete Qe[J],Qe}),Eu.current.delete(J),Le(he)}},[Ki,k,a,Dn,b,yt,Xr,an,qs,x,g,Ui,o,_e]),ap=h.useCallback(async()=>{try{const S=await(await fetch("/api/skills")).json().catch(()=>({})),C=Array.isArray(S.skills)?S.skills.map(I=>({key:String(I.key),name:String(I.name||I.id||I.key),description:I.description?String(I.description):"",sourceLabel:I.sourceLabel?String(I.sourceLabel):""})):[];vL(C),TS(!0)}catch{TS(!0)}},[]),lp=h.useCallback(async()=>{try{const S=await(await fetch("/api/mcps")).json().catch(()=>({})),C=Array.isArray(S.servers)?S.servers.map(I=>({name:String((I==null?void 0:I.name)||""),type:String((I==null?void 0:I.type)||""),url:String((I==null?void 0:I.url)||""),command:String((I==null?void 0:I.command)||""),args:Array.isArray(I==null?void 0:I.args)?I.args.map(String):[],description:String((I==null?void 0:I.description)||"")})).filter(I=>I.name):[];$S(C)}catch{$S([])}},[]),cp=h.useCallback(async()=>{try{const w=$r(a),C=await(await fetch(`/api/workspaces?${w.toString()}`)).json().catch(()=>({})),I=Array.isArray(C.workspaces)?C.workspaces.map(R=>({id:String((R==null?void 0:R.id)||""),label:String((R==null?void 0:R.label)||(R==null?void 0:R.name)||"知识库"),path:String((R==null?void 0:R.path)||""),kind:(R==null?void 0:R.kind)==="git"?"git":"local",repoUrl:String((R==null?void 0:R.repoUrl)||""),branch:String((R==null?void 0:R.branch)||""),mountPath:String((R==null?void 0:R.mountPath)||""),type:String((R==null?void 0:R.type)||""),builtin:(R==null?void 0:R.builtin)===!0,exists:(R==null?void 0:R.exists)!==!1})).filter(R=>R.path):[];OS(I)}catch{OS([])}},[a]),bj=h.useCallback(async()=>{un.current=!1;try{const w=$r(a),S=await fetch(`/api/workspace/conversations?${w.toString()}`),C=await S.json().catch(()=>({}));if(!S.ok)throw new Error(C.error||`HTTP ${S.status}`);const I=cC(C.conversations||{});Il(I.composer.messages),sr(I.composer.runSessions),Is(I.composer.activeSessionId||"workspace"),Ao(I.nodeChats)}catch{Il([]),sr([]),Is("workspace"),Ao({})}finally{un.current=!0}},[a]),kj=h.useCallback(async()=>{if(!_e||a.archived)return;const w=cC({composer:{activeSessionId:Qr,messages:Ca,runSessions:Us},nodeChats:Aa});await fetch("/api/workspace/conversations",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,conversations:w})}).then(async S=>{if(!S.ok){const C=await S.json().catch(()=>({}));throw new Error(C.error||`HTTP ${S.status}`)}})},[Qr,Ca,Us,a,Aa,_e]);h.useEffect(()=>{let w=!1;return l?(uy(null),dy(!0),()=>{w=!0}):((async()=>{const C=new URL(window.location.href),I=String(C.searchParams.get("invite")||"").trim();if(I){ge("正在加入共享 Workspace...");const R=await fetch("/api/workspace/collaboration/accept",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:I})}),U=await R.json().catch(()=>({}));if(!R.ok)throw new Error(U.error||"加入共享 Workspace 失败");C.searchParams.delete("invite"),window.history.replaceState({},"",`${C.pathname}${C.search}${C.hash}`)}w||(await Ps(),w||await bj())})().catch(C=>{const I=String(C.message||C);ge(I),Gs("error"),Ys(I)}),ip(),fetch("/api/model-lists").then(C=>C.json()).then(C=>bL({cursor:Array.isArray(C.cursor)?C.cursor.map(String):[],opencode:Array.isArray(C.opencode)?C.opencode.map(String):[],claudeCode:Array.isArray(C.claudeCode)?C.claudeCode.map(String):[],codex:Array.isArray(C.codex)?C.codex.map(String):[]})).catch(()=>{}),ap(),lp(),cp(),op(),fetch("/api/skill-collections").then(C=>C.json()).then(C=>{SL(Xa(C)),jL(!0)}).catch(()=>{}),fetch("/api/auth/me").then(C=>C.json()).then(C=>{uy(C.user||null),dy(!0)}).catch(()=>{uy(null),dy(!0)}),()=>{w=!0})},[l,Ps,bj,ip,lp,ap,op,cp,qi]),h.useEffect(()=>{if(uj(""),!(!PS||!RS)){if(!qi){yu([]);return}yu(Dz(qi,"workspace",Ks,_l)),uj(qi)}},[_l,RS,Ks,PS,qi]),h.useEffect(()=>{if(!(cj!==qi||!qi))try{localStorage.setItem(qi,JSON.stringify(qs))}catch{}},[qs,qi,cj]),h.useEffect(()=>{Q.current=re},[re]),h.useEffect(()=>{_.current=b},[b]),h.useEffect(()=>{if(de.current)return;const w=W.current,S=new Map,C=[];for(const I of b){const R=DM(I);S.set(I.id,R),w.get(I.id)!==R&&C.push(I.id)}W.current=S,C.length!==0&&Xr(C)},[b,Xr]),h.useEffect(()=>{j.current=k},[k]),h.useEffect(()=>{z.current=P},[P]),h.useEffect(()=>{D.current=E},[E]),h.useEffect(()=>{pS.current=wt},[wt]),h.useEffect(()=>{fS.current=Cr},[Cr]),h.useEffect(()=>{ce.current=K},[K]),h.useEffect(()=>{if(!K)return;const w=C=>{C.key==="Escape"&&ee(null)},S=C=>{var I,R;(R=(I=C.target)==null?void 0:I.closest)!=null&&R.call(I,".af-connect-node-menu")||ee(null)};return document.addEventListener("keydown",w),document.addEventListener("pointerdown",S),()=>{document.removeEventListener("keydown",w),document.removeEventListener("pointerdown",S)}},[K]),h.useEffect(()=>{if(!le.current||!_e)return;if(de.current){fe.current&&window.clearTimeout(fe.current);return}const w=Qt.current;if(Qt.current=null,(w==null?void 0:w.nodes)===b&&w.edges===k&&w.displayPage===P)return;if(Mt.current){Mt.current=!1;return}wi(),fe.current&&window.clearTimeout(fe.current);const S=st.current?0:650;return st.current=!1,fe.current=window.setTimeout(()=>{an().catch(C=>ge(String(C.message||C)))},S),()=>{fe.current&&window.clearTimeout(fe.current)}},[b,k,P,wi,an,_e]),h.useEffect(()=>{if(un.current&&!(!_e||a.archived))return Kt.current&&window.clearTimeout(Kt.current),Kt.current=window.setTimeout(()=>{kj().catch(w=>ge(String(w.message||w)))},900),()=>{Kt.current&&window.clearTimeout(Kt.current)}},[Qr,Ca,Us,a.archived,Aa,kj,_e]);const Mu=h.useMemo(()=>b.filter(w=>{var S;return((S=w==null?void 0:w.data)==null?void 0:S.definitionId)==="workspace_scheduled_run"}).map(w=>{var S;return{id:w.id,config:Jv(((S=w.data)==null?void 0:S.body)||"")}}),[b]),qL=h.useMemo(()=>Mu.map(w=>`${w.id}:${w.config.enabled?"1":"0"}:${w.config.cron}:${w.config.timezone}`).join("|"),[Mu]);h.useEffect(()=>{if(!le.current||f!=="workspace"||!a.flowId){Ea({});return}if(!Mu.length){Ea({});return}let w=!1;const S=async()=>{try{const I=$r(a),R=await fetch(`/api/workspace/schedules?${I.toString()}`),U=await R.json().catch(()=>({}));if(!R.ok)throw new Error(U.error||"读取 Workspace 定时状态失败");w||Ea(uh(U.schedules||[]))}catch{w||Ea(I=>{var U;const R={};for(const Z of Mu)R[Z.id]={...I[Z.id]||{},lastStatus:((U=I[Z.id])==null?void 0:U.lastStatus)||"unknown"};return R})}};S();const C=window.setInterval(S,5e3);return()=>{w=!0,window.clearInterval(C)}},[a,Mu,qL,f]);const vj=h.useCallback((w,S)=>{if(!_e){ge("Readonly workspace");return}const C=EC(S),I=Y=>Array.isArray(Y)?Y.map(ae=>(ae==null?void 0:ae.name)!=="skillKeys"&&(ae==null?void 0:ae.name)!=="skillsContext"&&(ae==null?void 0:ae.type)!=="text"?ae:{...ae,default:C,value:C}):[],R=b.map(Y=>{var ae;return Y.id!==w?Y:{...Y,data:{...Y.data,body:C,inputs:I((ae=Y.data)==null?void 0:ae.inputs)}}}),U=Q.current||{},Z=U[w]&&typeof U[w]=="object"?U[w]:{},J={...U,[w]:{...Z,body:C,input:I(Z.input)}};Q.current=J,g(R),se(J),As(Y=>!Y||Y.id!==w?Y:{...Y,body:C,inputs:I(Y.inputs)}),an(R,k).catch(Y=>ge(String(Y.message||Y)))},[k,b,an,g,_e]),Sj=h.useCallback((w,S)=>{if(!_e){ge("Readonly workspace");return}const C=GX(S),I=Y=>Array.isArray(Y)?Y.map(ae=>(ae==null?void 0:ae.name)!=="serverNames"&&(ae==null?void 0:ae.name)!=="mcpContext"&&(ae==null?void 0:ae.type)!=="text"?ae:{...ae,default:C,value:C}):[],R=b.map(Y=>{var ae;return Y.id!==w?Y:{...Y,data:{...Y.data,body:C,inputs:I((ae=Y.data)==null?void 0:ae.inputs)}}}),U=Q.current||{},Z=U[w]&&typeof U[w]=="object"?U[w]:{},J={...U,[w]:{...Z,body:C,input:I(Z.input)}};Q.current=J,g(R),se(J),As(Y=>!Y||Y.id!==w?Y:{...Y,body:C,inputs:I(Y.inputs)}),an(R,k).catch(Y=>ge(String(Y.message||Y)))},[k,b,an,g,_e]),jj=h.useCallback((w,S)=>{if(!_e){ge("Readonly workspace");return}const C=(Array.isArray(S)?S:S?[S]:[]).filter(Be=>String((Be==null?void 0:Be.path)||"").trim()),I=C[0]||null,R=String((I==null?void 0:I.path)||"").trim(),U=C.length===1?String((I==null?void 0:I.label)||(I==null?void 0:I.id)||"知识库").trim():C.length?`${C.length} 个知识库`:"",Z=C.length?JSON.stringify(Dg(C)):"",J=I?JSON.stringify({version:1,id:(I==null?void 0:I.id)||"",label:String((I==null?void 0:I.label)||(I==null?void 0:I.id)||"知识库").trim(),kind:(I==null?void 0:I.kind)||"local",cwd:R,workspaceRoot:R,repoUrl:(I==null?void 0:I.repoUrl)||"",branch:(I==null?void 0:I.branch)||"",mountPath:(I==null?void 0:I.mountPath)||"",type:(I==null?void 0:I.type)||""}):"",Y=Be=>Array.isArray(Be)?Be.map(Ke=>(Ke==null?void 0:Ke.name)==="path"?{...Ke,default:R,value:R}:(Ke==null?void 0:Ke.name)==="label"?{...Ke,default:U,value:U}:(Ke==null?void 0:Ke.name)==="knowledgeContext"?{...Ke,default:Z,value:Z}:(Ke==null?void 0:Ke.name)==="workspaceContext"?{...Ke,default:J,value:J}:(Ke==null?void 0:Ke.name)==="mode"?{...Ke,default:"set",value:"set"}:Ke):[],ae=Be=>Array.isArray(Be)?Be.map(Ke=>(Ke==null?void 0:Ke.name)==="knowledgeContext"?{...Ke,default:Z,value:Z}:(Ke==null?void 0:Ke.name)==="workspaceContext"?{...Ke,default:J,value:J,showOnNode:!1}:(Ke==null?void 0:Ke.name)==="cwd"?{...Ke,default:R,value:R,showOnNode:!1}:Ke):[],he=b.map(Be=>{var Ke,We,Le;return Be.id===w?{...Be,data:{...Be.data,label:((Ke=Be.data)==null?void 0:Ke.label)||"加载知识库",inputs:Y((We=Be.data)==null?void 0:We.inputs),outputs:ae((Le=Be.data)==null?void 0:Le.outputs)}}:Be}),pe=Q.current||{},je=pe[w]&&typeof pe[w]=="object"?pe[w]:{},Ve={...pe,[w]:{...je,label:je.label||"加载知识库",input:Y(je.input),output:ae(je.output)}};Q.current=Ve,g(he),se(Ve),As(Be=>(Be==null?void 0:Be.id)===w?{...Be,inputs:Y(Be.inputs),outputs:ae(Be.outputs)}:Be),an(he,k).catch(Be=>ge(String(Be.message||Be)))},[k,b,an,g,_e]),Nj=h.useCallback((w,S)=>{if(!_e){ge("Readonly workspace");return}const C=String(w||"");if(!C)return;const I=EC((S==null?void 0:S.skillKeys)||[]),R=Wf((S==null?void 0:S.displayType)||"markdown"),U=String((S==null?void 0:S.model)||"").trim(),Z=(S==null?void 0:S.includeWorkspaceContext)===!1?"false":"true",J=S!=null&&S.workspaceContext&&typeof S.workspaceContext=="object"?JSON.stringify(S.workspaceContext):"",Y=S!=null&&S.knowledgeContext&&typeof S.knowledgeContext=="object"?JSON.stringify(S.knowledgeContext):"",ae=We=>Array.isArray(We)?We.map(Le=>(Le==null?void 0:Le.name)==="skillKeys"?{...Le,default:I,value:I}:(Le==null?void 0:Le.name)==="displayType"?{...Le,default:R,value:R}:(Le==null?void 0:Le.name)==="includeWorkspaceContext"?{...Le,default:Z,value:Z}:(Le==null?void 0:Le.name)==="knowledgeContext"?{...Le,default:Y,value:Y}:(Le==null?void 0:Le.name)==="workspaceContext"?{...Le,default:J,value:J}:Le):[],he=We=>Array.isArray(We)?We.map(Le=>(Le==null?void 0:Le.name)==="displayType"?{...Le,default:R,value:R}:Le):[],pe=String((S==null?void 0:S.task)??""),je=b.map(We=>{var Le,Ut;return We.id===C?{...We,data:{...We.data,body:pe,model:U,inputs:ae((Le=We.data)==null?void 0:Le.inputs),outputs:he((Ut=We.data)==null?void 0:Ut.outputs)}}:We}),Ve=Q.current||{},Be=Ve[C]&&typeof Ve[C]=="object"?Ve[C]:{},Ke={...Ve,[C]:{...Be,body:pe,model:U,input:ae(Be.input),output:he(Be.output)}};Q.current=Ke,g(je),se(Ke),As(We=>(We==null?void 0:We.id)===C?{...We,body:pe,model:U,inputs:ae(We.inputs),outputs:he(We.outputs)}:We),an(je,k).catch(We=>ge(String(We.message||We)))},[k,b,an,g,_e]),_j=h.useCallback((w,S)=>{if(!_e){ge("Readonly workspace");return}const C=GJ(S),I=b.map(J=>J.id===w?{...J,data:{...J.data,body:C}}:J),R=Q.current||{},U=R[w]&&typeof R[w]=="object"?R[w]:{},Z={...R,[w]:{...U,body:C}};Q.current=Z,Mt.current=!0,g(I),se(Z),As(J=>(J==null?void 0:J.id)===w?{...J,body:C}:J),an(I,k).catch(J=>ge(String(J.message||J)))},[k,b,an,g,_e]),Cj=h.useCallback(w=>{const S=String(w||"").trim();S&&(QS(C=>C===S?"":S),Ao(C=>({...C,[S]:C[S]||{sessionId:`nodechat_${Date.now()}_${S.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[],draft:"",candidateContent:"",running:!1,error:""}})))},[]),Aj=h.useCallback(()=>QS(""),[]),Ej=h.useCallback((w,S)=>{const C=String(w||"").trim();C&&Ao(I=>({...I,[C]:{...I[C]||{sessionId:`nodechat_${Date.now()}_${C.replace(/[^a-z0-9_-]+/gi,"_")}`,messages:[]},draft:String(S||""),error:""}}))},[]),Js=h.useCallback((w,S,C="replace",I={})=>{var ot,Qe;if(!_e){ge("Readonly workspace");return}const R=String(w||"").trim();if(!R)return;const U=_.current.find(Oe=>Oe.id===R),Z=Fn(U==null?void 0:U.data),J=di((ot=U==null?void 0:U.data)==null?void 0:ot.definitionId),Y=Di(S),ae=Z==="html"?au(Y):Z==="react"?Lg(Y):String(Y||""),he=U?fo(U.data):"",pe=C==="append"&&String(he||"").trim()?`${String(he).replace(/\s+$/g,"")}
|
|
262
|
+
|
|
263
|
+
${ae.trim()}`:ae,je=Z==="image"?"src":"content",Ve=I!=null&&I.reloadDisplay?Date.now():(Qe=U==null?void 0:U.data)==null?void 0:Qe.displayReloadKey,Be=Oe=>{let Ht=!1;return(Array.isArray(Oe)?Oe:[]).map(ht=>{const $t=String((ht==null?void 0:ht.name)||""),Vl=String((ht==null?void 0:ht.type)||"");return(J?$t===je||$t==="result"||$t==="filePath":$t===je||$t==="filePath"||Vl==="text")?Ht?{...ht,default:"",value:""}:(Ht=!0,{...ht,default:pe,value:pe}):ht})},Ke=_.current.map(Oe=>{var Ht,Fe;return Oe.id!==R?Oe:{...Oe,data:{...Oe.data,body:J?Oe.data.body:pe,...Ve?{displayReloadKey:Ve}:{},inputs:Be((Ht=Oe.data)==null?void 0:Ht.inputs),outputs:Be((Fe=Oe.data)==null?void 0:Fe.outputs)}}}),We=Q.current||{},Le=We[R]&&typeof We[R]=="object"?We[R]:{},Ut={...We,[R]:{...Le,body:J?Le.body:pe,input:Be(Le.input),output:Be(Le.output)}};Q.current=Ut,g(Ke),se(Ut),As(Oe=>(Oe==null?void 0:Oe.id)===R?{...Oe,...J?{}:{body:pe}}:Oe),(I==null?void 0:I.logChat)!==!1&&Ao(Oe=>{var Ht;return{...Oe,[R]:{...Oe[R]||{},candidateContent:"",messages:[...(Ht=Oe[R])!=null&&Ht.messages&&Array.isArray(Oe[R].messages)?Oe[R].messages:[],{role:"assistant",text:C==="append"?"已追加到当前节点内容。":"已替换当前节点内容。",at:Date.now()}]}}}),an(Ke,j.current).catch(Oe=>ge(String(Oe.message||Oe))),ge(String((I==null?void 0:I.statusMessage)||"")||(C==="append"?"已追加节点内容":"已替换节点内容"))},[an,g,_e]),up=h.useCallback(async(w,S="")=>{if(!_e)return ge("Readonly workspace"),"";if(!w)return"";try{const C=new FormData;C.set("file",w),C.set("dir",String(S||"")),a.flowId&&C.set("flowId",a.flowId),a.flowSource&&C.set("flowSource",a.flowSource),a.adminOwnerId&&C.set("adminOwnerId",a.adminOwnerId),a.archived&&C.set("archived","1");const I=await fetch("/api/workspace/upload",{method:"POST",body:C}),R=await I.json().catch(()=>({}));if(!I.ok)throw new Error(R.error||"上传文件失败");const U=String(R.path||"").trim();if(!U)throw new Error("上传文件失败:未返回路径");return await Dn(),Nl(Z=>{const J=new Set(Z);for(const Y of fh(U))J.delete(Y);return J}),ge(`已上传 ${U}`),U}catch(C){return ge(String(C.message||C)),""}},[a,Dn,_e]),dp=h.useCallback(async w=>Om(w)?up(w,"img"):(ge("请选择图片文件"),""),[up]),Ij=h.useCallback((w="")=>{var S;if(!_e){ge("Readonly workspace");return}AS.current=String(w||""),(S=CS.current)==null||S.click()},[_e]),UL=h.useCallback(async w=>{const S=Array.from(w.target.files||[]);if(w.target.value="",!S.length)return;const C=AS.current||"";_S(!0);try{let I="";for(const R of S){const U=await up(R,C);U&&(I=U)}S.length>1&&ge(`已上传 ${S.length} 个文件${I?`,最后一个:${I}`:""}`)}catch(I){ge(String(I.message||I))}finally{_S(!1)}},[up]),Pj=h.useCallback(async(w,S)=>{const C=String(w||"").trim();if(!C)return;const I=await dp(S);I&&Js(C,I,"replace",{logChat:!1,statusMessage:`已上传图片 ${I}`})},[Js,dp]),Tj=h.useCallback(async(w,S=void 0)=>{var Be,Ke;if(!_e){ge("Readonly workspace");return}const C=String(w||"").trim();if(!C)return;const I=Aa[C]||{},R=String(S!==void 0?S:I.draft||"").trim();if(!R||I.running)return;const U=_.current.find(We=>We.id===C);if(!U)return;const Z=Fn(U.data)||"markdown",J=fo(U.data);let Y=ma(J,Z),ae=Di(J);if(Y)try{ae=await gl(a,Y)}catch(We){ge(String(We.message||We))}else if(Z!=="image"&&String(ae||"").trim()){const We=Ua(Z,ae);if(We){ge(`${We} 未进入微调。`);return}try{const Le=await Yb(a,CC(C,U.data),ae);await Dn(),Js(C,Le,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已将展示保存为 ${Le}`}),Y=Le,ae=""}catch(Le){ge(String(Le.message||Le));return}}const he=dX(C,_.current,j.current),pe={role:"user",text:R,at:Date.now()},je=Array.isArray(I.messages)?I.messages:[],Ve=I.sessionId||`nodechat_${Date.now()}_${C.replace(/[^a-z0-9_-]+/gi,"_")}`;Ao(We=>({...We,[C]:{...I,sessionId:Ve,messages:[...je,pe],draft:"",running:!0,error:""}}));try{const We=await fetch("/api/workspace/node-chat",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,sessionId:Ve,node:{id:C,label:((Be=U.data)==null?void 0:Be.label)||C,definitionId:((Ke=U.data)==null?void 0:Ke.definitionId)||""},nodeKind:Z,currentContent:Y?"":ae,sourceContext:he,targetFilePath:Y,messages:je,message:R,model:Ki})}),Le=await We.json().catch(()=>({}));if(!We.ok)throw new Error(Le.error||"节点微调失败");const Ut=String(Le.candidateContent||Le.reply||"").trim(),ot=!!Le.directFileEdit,Qe=String(Le.artifactPath||Y||"").trim();if(ot&&Qe){const Oe=Ua(Z,Ut);if(Oe)throw new Error(`${Oe} 文件已由 agent 修改,请检查 ${Qe}。`);await Dn(),Js(C,Qe,"replace",{logChat:!1,reloadDisplay:!0,statusMessage:`已按微调描述更新 ${Qe}`})}else if(Ut){const Oe=Ua(Z,Ut);if(Oe)throw new Error(`${Oe} 已取消写入,避免覆盖当前展示文件。`);if(Y){const Ht=await Yb(a,Y,Ut);await Dn(),Js(C,Ht,"replace",{logChat:!1,statusMessage:`已按微调描述更新 ${Ht}`})}else Js(C,Ut,"replace",{logChat:!1,statusMessage:"已按微调描述更新展示内容"})}Ao(Oe=>{var Ht;return{...Oe,[C]:{...Oe[C]||{},sessionId:String(Le.sessionId||Ve),running:!1,candidateContent:"",messages:[...(Ht=Oe[C])!=null&&Ht.messages&&Array.isArray(Oe[C].messages)?Oe[C].messages:[...je,pe],{role:"assistant",text:Ut||ot?Qe?`已更新文件 ${Qe}。`:"已按你的描述更新当前展示。":"没有生成可更新的内容。",at:Date.now()}]}}})}catch(We){const Le=String(We.message||We);Ao(Ut=>({...Ut,[C]:{...Ut[C]||{},running:!1,error:Le}})),ge(Le)}},[Ki,a,Dn,Aa,Js,_e]),Rj=h.useCallback(async(w,S)=>{if(!_e){ge("Readonly workspace");return}const C=Fn(S)||"markdown",I=fo(S),R=ma(I,C);let U=Di(I);if(R)try{U=await gl(a,R)}catch(ae){ge(String(ae.message||ae));return}if(!String(U||"").trim()){ge("展示节点没有可保存内容");return}const Z=Ua(C,U);if(Z){ge(`${Z} 未保存文件。`);return}const J=CC(w,S),Y=window.prompt("保存到 workspace 相对路径",J);if(Y)try{const ae=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:Y,content:U})}),he=await ae.json().catch(()=>({}));if(!ae.ok)throw new Error(he.error||"保存文件失败");const pe=he.path||Y,je=$r(a);je.set("path",pe);const Ve=await fetch(`/api/workspace/file?${je.toString()}`);if(!Ve.ok){const Be=await Ve.json().catch(()=>({}));throw new Error(Be.error||`保存后读取失败:${pe}`)}await Dn(),hS(Be=>DX(Be,pe,String(U||"").length)),Nl(Be=>{const Ke=new Set(Be);for(const We of fh(pe))Ke.delete(We);return Ke}),Js(w,pe,"replace",{logChat:!1,statusMessage:`已保存并引用 ${pe}`}),ge(`已保存 ${pe}`)}catch(ae){ge(String(ae.message||ae))}},[a,Dn,Js,_e]),Mj=h.useCallback(w=>{var R,U;const S=String(w||"").trim();if(!S||ue)return;const C=_.current.find(Z=>Z.id===S);if(!C||!Fn(C==null?void 0:C.data)){ge("展示节点不可用");return}const I=String(((R=C.data)==null?void 0:R.label)||((U=C.data)==null?void 0:U.displayName)||S).trim()||"AgentFlow Display";jn(Hw({title:I,layout:"single",nodeIds:[S],mode:"single-node",sourceNodeId:S})),kt(""),Zt(null),fr(!0)},[ue]),fp=h.useCallback((w,S)=>{const C=String(w||"");C&&As(I=>{if(!I||I.id!==C)return I;const R=typeof S=="function"?S(I):S;return!R||typeof R!="object"?I:{...I,...R}})},[]),$j=h.useCallback((w,S)=>{const C=String(w||"");!C||!_e||(g(I=>I.map(R=>{var Z;if(R.id!==C)return R;const U=Array.isArray((Z=R.data)==null?void 0:Z.outputs)&&R.data.outputs.length?R.data.outputs.map((J,Y)=>Y===0?{...J,default:S,value:S}:J):[{type:"file",name:"value",default:S,value:S}];return{...R,data:{...R.data,body:"",outputs:U}}})),fp(C,I=>({body:"",outputs:Array.isArray(I==null?void 0:I.outputs)&&I.outputs.length?I.outputs.map((U,Z)=>Z===0?{...U,default:S,value:S}:U):[{type:"file",name:"value",default:S,value:S}]})),ge(`已选择文件 ${S}`))},[g,fp,_e]),Lj=h.useCallback(w=>{Qg({nodeId:String(w||""),query:""})},[]),wy=h.useCallback(()=>{Qg({nodeId:"",query:""})},[]),GL=h.useCallback(w=>{const S=String((w==null?void 0:w.path)||"").trim();!S||!gu.nodeId||($j(gu.nodeId,S),wy())},[wy,gu.nodeId,$j]),Oj=h.useCallback(async(w,S)=>{if(!_e)return;const C=CX(w,S);if(C.length===0)return;const I=[];try{for(const R of C){const U=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:R})});if(U.status===404)continue;const Z=await U.json().catch(()=>({}));if(!U.ok)throw new Error(Z.error||"清理节点输出失败");I.push(Z.path||R)}if(I.length===0)return;ge(`已清理 ${I.join(", ")}`),await Dn(),Xg(R=>C.some(U=>R===U||R.startsWith(`${U}/`))?"":R)}catch(R){ge(String(R.message||R))}},[a,Dn,_e]),$u=h.useMemo(()=>({modelLists:_a,showBodyPreview:!0,flowParams:a,readOnly:!_e,onRunWorkspaceNode:xj,onStopWorkspaceNode:wj,onOpenWorkspaceRunLogs:yj,onOptimizeWorkspaceRun:yy,onOptimizeWorkspaceSchedule:yy,runningRunNodeIds:dj,onChangeScheduledRunConfig:_j,onChangeContextRunConfig:Nj,skills:Ks,skillCollections:_l,onChangeLoadSkillKeys:vj,onRefreshSkills:ap,mcpServers:MS,onChangeLoadMcpNames:Sj,onRefreshMcps:lp,workspaceTargets:LS,onChangeLoadWorkspace:jj,onRefreshWorkspaces:cp,onSaveDisplayNodeToFile:Rj,onShareDisplayNode:Mj,onOpenDisplayPreview:G,onRefreshNodeInternals:Xr,onEnsureWorkspaceNodeDisplaySize:KS,sharingDisplayNodeId:ue,onUploadWorkspaceImage:dp,onUploadImageToDisplayNode:Pj,onOpenProvideFilePicker:Lj,onStatus:ge,onSetDisplayNodeContent:Js,onToggleNodeChat:Cj,onCloseNodeChat:Aj,onUpdateNodeChatDraft:Ej,onSendNodeChat:Tj,onSyncNodePropDraft:fp,onCleanupWorkspaceNodeOutputs:Oj}),[Nj,Sj,vj,jj,_j,Oj,Aj,KS,a,MS,_a,Lj,yj,yy,lp,Xr,ap,cp,xj,dj,Rj,Tj,Js,Mj,ue,_l,Ks,wj,fp,Cj,Ej,Pj,dp,LS,_e]),YL=h.useRef(new Map),ps=h.useMemo(()=>{const w=YL.current,S=new Set,C=b.map(I=>{var Y,ae,he;const R={selected:I.selected===!0,isExecuting:sj.has(I.id),nodeStatus:((Y=my[I.id])==null?void 0:Y.status)??null,nodeElapsed:((ae=my[I.id])==null?void 0:ae.elapsed)??null,optimizingRun:ij===I.id,scheduledRunState:rj[I.id]||null,nodeChatActive:XS===I.id,nodeChat:Aa[I.id]||null},U=w.get(I.id);if(U&&U.source===I&&U.commonData===$u&&xC(U.runtime,R))return S.add(I.id),U.node;const Z=!!(U&&((he=U.source)==null?void 0:he.data)===I.data&&U.commonData===$u&&xC(U.runtime,R)),J={...I,data:Z?U.node.data:{...I.data,...$u,...R}};return w.set(I.id,{source:I,commonData:$u,runtime:R,node:J}),S.add(I.id),J});for(const I of w.keys())S.has(I)||w.delete(I);return C},[XS,$u,Aa,b,ij,rj,sj,my]),pt=f==="display",_t=f==="workflow",Dj=h.useMemo(()=>pt?new Map(ps.map(w=>[w.id,w])):eX,[ps,pt]),Fj=h.useMemo(()=>Cs&&ps.find(w=>w.id===Cs)||null,[Cs,ps]),zj=h.useRef(new Map),Lu=h.useMemo(()=>{if(!pt)return zj.current.clear(),tX;const w=new Set($),S=zj.current,C=new Set,I=P.nodeIds.map((R,U)=>{var Ve,Be,Ke,We;const Z=Dj.get(R);if(!Z||!Fn(Z.data))return null;const J=rc(Z)||{width:520,height:320},Y=el(P.nodeSizes[R]||J,{display:!0})||J,ae=P.nodePositions[R]||{x:180+U*36,y:120+U*28},he=w.has(R),pe=S.get(R);if(pe&&pe.source===Z&&((Ve=pe.position)==null?void 0:Ve.x)===ae.x&&((Be=pe.position)==null?void 0:Be.y)===ae.y&&((Ke=pe.size)==null?void 0:Ke.width)===Y.width&&((We=pe.size)==null?void 0:We.height)===Y.height&&pe.selected===he)return C.add(R),pe.node;const je={...Z,id:bC(R),position:ae,selected:he,width:Y.width,height:Y.height,data:{...Z.data,sourceNodeId:R,displayPageMode:!0,readOnly:!0,selected:he,displaySize:Y,nodeSize:Y}};return S.set(R,{source:Z,position:ae,size:Y,selected:he,node:je}),C.add(R),je}).filter(Boolean);for(const R of S.keys())C.has(R)||S.delete(R);return I},[P,Dj,pt,$]),Dl=h.useMemo(()=>ps.filter(w=>Fn(w==null?void 0:w.data)),[ps]);h.useEffect(()=>{if(!pt||!P.viewport)return;const w=P.viewport,S=()=>{try{r.setViewport(w,{duration:0})}catch{}},C=window.requestAnimationFrame(()=>window.requestAnimationFrame(S));return()=>window.cancelAnimationFrame(C)},[P.viewport,pt,r]),h.useEffect(()=>{if(pt||_t||!E)return;const w=E,S=()=>{try{r.setViewport(w,{duration:0})}catch{}},C=window.requestAnimationFrame(()=>window.requestAnimationFrame(S));return()=>window.cancelAnimationFrame(C)},[pt,_t,r,E]),h.useEffect(()=>{_t&&Ru(en)},[_t]),h.useEffect(()=>{_t&&(Co(""),gy().catch(w=>{vu([]),Su([]),Co(String(w.message||w))}))},[_t,gy]),h.useEffect(()=>{if(!_t||!en||a.workflowDemo)return;const w=$r(a);w.set("tapdId",en);let S=null,C=null,I=!1;const R=()=>{C&&(window.clearTimeout(C),C=null),S&&(S.onmessage=null,S.onerror=null,S.close(),S=null)},U=()=>{I||document.hidden||S||(S=new EventSource(`/api/prd-workflow/events?${w.toString()}`),S.onmessage=()=>{Ru(en)},S.onerror=()=>{R(),!I&&!document.hidden&&(C=window.setTimeout(U,5e3))})},Z=()=>{if(document.hidden){R();return}Ru(en),U()};return U(),document.addEventListener("visibilitychange",Z),()=>{I=!0,document.removeEventListener("visibilitychange",Z),R()}},[a,_t,Ru,en]),h.useEffect(()=>{if(!a.flowId||_t)return;const w=$r(a);w.set("clientId",rt.current);let S=null,C=null,I=!1;const R=()=>{C&&(window.clearTimeout(C),C=null),S&&(S.onmessage=null,S.onerror=null,S.close(),S=null)},U=()=>{I||document.hidden||S||(S=new EventSource(`/api/workspace/events?${w.toString()}`),S.onmessage=J=>{let Y=null;try{Y=JSON.parse(J.data||"{}")}catch{Y=null}if(!(!Y||Y.clientId===rt.current)){if(Y.type==="graph.committed"){Ll(Y);return}if(Y.type==="runtime.committed"){Ll(Y);return}if(String(Y.type||"").startsWith("file.")){Dn();return}String(Y.type||"").startsWith("run.")&&op()}},S.onerror=()=>{R(),!I&&!document.hidden&&(C=window.setTimeout(U,5e3))})},Z=()=>{if(document.hidden){R();return}Ll({type:"visibility.resume"}),U()};return U(),document.addEventListener("visibilitychange",Z),()=>{I=!0,document.removeEventListener("visibilitychange",Z),R(),at.current&&(window.clearTimeout(at.current),at.current=null),Xe.current=!1}},[a,_t,Dn,op,Ll]),h.useEffect(()=>{if(de.current)return;const w=F.current,S=new Map,C=[];for(const I of[...ps,...Lu]){const R=ZJ(I);S.set(I.id,R),w.get(I.id)!==R&&C.push(I.id)}F.current=S,C.length!==0&&Xr(C)},[Lu,ps,Xr]);const Jt=h.useMemo(()=>b.find(w=>w.id===Cr)||null,[b,Cr]),xy=h.useRef({id:"",draft:null}),JL=h.useMemo(()=>{const w=RC(Jt);return w?JSON.stringify(w):""},[Jt==null?void 0:Jt.data,Jt==null?void 0:Jt.id]);h.useEffect(()=>{if(!Jt){xy.current={id:"",draft:null},As(null),kl("");return}const w=RC(Jt),S=xy.current;xy.current={id:Jt.id,draft:w},As(C=>!C||C.id!==Jt.id||S.id!==Jt.id||!S.draft?w:QX(C,S.draft,w)),kl("")},[Jt==null?void 0:Jt.id,JL]);const by=h.useCallback((w=!1)=>{if(!wt||!Jt)return!1;if(!_e)return kl("Readonly workspace"),ge("Readonly workspace"),!1;kl("");const S=LC({nodes:b,edges:k,instances:Q.current,selectedNode:Jt,draft:wt,allowRename:w});return S!=null&&S.error?(kl(S.error),!1):(!(S!=null&&S.ok)||!S.changed||(Q.current=S.instances,se(S.instances),g(S.nodes),x(S.edges),S.nextId!==Jt.id&&on(S.nextId),Xr(S.nextId)),!0)},[k,wt,b,Jt,x,g,Xr,_e]);h.useEffect(()=>{if(!_e||!wt||!Jt)return;const w=window.setTimeout(()=>{by(!1)},350);return()=>window.clearTimeout(w)},[wt==null?void 0:wt.label,wt==null?void 0:wt.role,wt==null?void 0:wt.model,wt==null?void 0:wt.body,JSON.stringify((wt==null?void 0:wt.images)||[]),wt==null?void 0:wt.script,wt==null?void 0:wt.scriptRef,wt==null?void 0:wt.implementationRef,wt==null?void 0:wt.implementationMode,JSON.stringify((wt==null?void 0:wt.inputs)||[]),JSON.stringify((wt==null?void 0:wt.outputs)||[]),by,Jt==null?void 0:Jt.id,_e]);const Bj=h.useRef({refs:new Map,nodeDataById:new Map}),ky=h.useMemo(()=>{const w=Bj.current;let S=w.refs.size!==b.length;const C=new Map;for(const R of b)C.set(R.id,R.data),(!w.refs.has(R.id)||w.refs.get(R.id)!==R.data)&&(S=!0);if(!S)return w.nodeDataById;const I=new Map(b.map(R=>[R.id,R.data]));return Bj.current={refs:C,nodeDataById:I},I},[b]),XL=h.useMemo(()=>k.map(w=>{var Y,ae;const S=ky.get(w.source),C=ky.get(w.target),I=/^output-(\d+)$/.exec(w.sourceHandle||""),R=/^input-(\d+)$/.exec(w.targetHandle||""),U=S&&I?(Y=S.outputs)==null?void 0:Y[parseInt(I[1],10)]:null,Z=C&&R?(ae=C.inputs)==null?void 0:ae[parseInt(R[1],10)]:null,J=U!=null&&U.type?Bn(U.type):Z!=null&&Z.type?Bn(Z.type):"";return J?{...w,style:{...w.style||{},stroke:J,strokeWidth:2},markerEnd:{type:Ii.ArrowClosed,color:J}}:w}),[ky,k]),pp=pt?Lu:ps,QL=pt?[]:XL,Wj=h.useRef(pp),Fl=h.useRef([]);de.current||(Wj.current=pp);const ZL=h.useMemo(()=>pt?Lu.map(w=>({...w,id:dh(w.id)})):ps,[Lu,ps,pt]),vy=h.useCallback(w=>{const S=String(w||"").trim();if(!S)return;const C=pt?bC(S):S;pt?V([S]):(g(R=>R.map(U=>({...U,selected:U.id===C}))),x(R=>R.map(U=>({...U,selected:!1}))),on(C));const I=()=>{var ae,he,pe;const R=r.getNode(C);if(!R)return;const U=(ae=r.getInternalNode)==null?void 0:ae.call(r,C),Z=((he=U==null?void 0:U.measured)==null?void 0:he.width)??(U==null?void 0:U.width)??R.width??260,J=((pe=U==null?void 0:U.measured)==null?void 0:pe.height)??(U==null?void 0:U.height)??R.height??120,{zoom:Y}=r.getViewport();r.setCenter(R.position.x+Z/2,R.position.y+J/2,{zoom:aX(Y),duration:240})};window.requestAnimationFrame(()=>window.requestAnimationFrame(I))},[pt,r,x,g]);h.useEffect(()=>{const w=String(c.current||"").trim();!w||!le.current||f!=="workspace"||ps.some(S=>S.id===w)&&(c.current="",Mt.current=!0,vy(w))},[ps,vy,f]);const Hj=h.useCallback(()=>{const w=r.getViewport(),S={x:Number(w.x)||0,y:Number(w.y)||0,zoom:Math.min(Math.max(Number(w.zoom)||1,.1),4)};if(pt){const C={...z.current,viewport:S};z.current=C,T(C),ge("已固定 Display 进入视角")}else{D.current=S,O(S);try{window.localStorage.setItem(u,JSON.stringify(S))}catch{}ge("已固定 Workspace 进入视角");return}an(_.current,j.current).catch(C=>ge(String(C.message||C)))},[pt,r,an,u]),Sy=h.useMemo(()=>{const w=Ne.trim().toLowerCase(),S={DISPLAY:[],CONTROL:[],TOOL:[],PROVIDE:[],AGENT:[]};for(const C of yt)w&&![C.id,C.label,C.displayName,C.description].some(I=>String(I||"").toLowerCase().includes(w))||S[hd(C)].push(C);for(const C of tc)S[C].sort((I,R)=>I.id.localeCompare(R.id));return S},[yt,Ne]),Ou=h.useMemo(()=>{const w=Tn.trim().toLowerCase();return yt.filter(S=>!w||[S.id,S.label,S.displayName,S.description].some(C=>String(C||"").toLowerCase().includes(w))).sort((S,C)=>{const I=tc.indexOf(hd(S)),R=tc.indexOf(hd(C));return I!==R?I-R:md(S).localeCompare(md(C))}).slice(0,30)},[yt,Tn]),Du=h.useMemo(()=>{const w=Tn.trim().toLowerCase();return jt.filter(S=>!w||[S.id,S.version,S.displayName,S.name,S.description,...Array.isArray(S.tags)?S.tags:[]].some(C=>String(C||"").toLowerCase().includes(w))).sort((S,C)=>String(S.displayName||S.name||S.id).localeCompare(String(C.displayName||C.name||C.id))).slice(0,30)},[jt,Tn]);h.useEffect(()=>{wr(0)},[Tn,we,Ie]),h.useEffect(()=>{if(!we)return;const w=window.setTimeout(()=>{var S;return(S=GS.current)==null?void 0:S.focus()},0);return()=>window.clearTimeout(w)},[we]);const eO=h.useMemo(()=>{const w=Yg.trim().toLowerCase();return w?Xv(vl).filter(S=>S.path.toLowerCase().includes(w)):vl},[Yg,vl]),Pa=h.useMemo(()=>JM(vl,Jg),[vl,Jg]),Gi=(Pa==null?void 0:Pa.type)==="directory"?Pa.path:MX((Pa==null?void 0:Pa.path)||""),tO=h.useCallback(w=>{var S,C;(C=(S=w.target)==null?void 0:S.closest)!=null&&C.call(S,".af-work-file")||Xg("")},[]),nO=[...(_a.cursor||[]).map(w=>({label:`Cursor · ${w.split(" - ")[0]}`,value:`cursor:${w.split(" - ")[0]}`})),...(_a.opencode||[]).map(w=>({label:`OpenCode · ${w.split(" - ")[0]}`,value:`opencode:${w.split(" - ")[0]}`})),...(_a.claudeCode||[]).map(w=>({label:`Claude · ${w.split(" - ")[0]}`,value:`claude-code:${w.split(" - ")[0]}`})),...(_a.codex||[]).map(w=>({label:`Codex · ${w.split(" - ")[0]}`,value:`codex:${w.split(" - ")[0]}`}))],jy=h.useMemo(()=>new Set(qs),[qs]),zl=h.useMemo(()=>{const w=new Map(Ks.map(U=>[U.key,U])),S=new Set,C=new Set,I=_l.map(U=>{const Z=pa(U,Ks).map(J=>w.get(J)).filter(Boolean);for(const J of Z)S.add(J.key),C.add(String(J.name||J.id||J.key||"").trim());return{...U,skills:Z}}).filter(U=>U.skills.length>0),R=Ks.filter(U=>{const Z=String(U.name||U.id||U.key||"").trim();return!S.has(U.key)&&!C.has(Z)});return{groups:I,ungrouped:R}},[_l,Ks]);h.useEffect(()=>{qS(w=>{let S=!1;const C=new Set(w);for(const I of zl.groups)C.has(I.id)||(C.add(I.id),S=!0);return S?C:w})},[zl.groups]);const pr=h.useMemo(()=>{const w=b.filter(S=>S.selected);return w.length>0?w:Cr?b.filter(S=>S.id===Cr):[]},[b,Cr]),hp=h.useMemo(()=>pr.map(w=>w.id),[pr]),Vj=h.useCallback(()=>{if(pt)return;if(!_e){ge("Readonly workspace");return}const w=(_.current||[]).filter(J=>(J==null?void 0:J.selected)&&!Wm(J));if(w.length<2){ge("选择至少两个节点后按 G 创建 Group");return}const S=w.reduce((J,Y)=>{var Ve,Be,Ke,We,Le,Ut,ot,Qe,Oe,Ht,Fe,ht;const ae=Number(((Ve=Y.position)==null?void 0:Ve.x)||0),he=Number(((Be=Y.position)==null?void 0:Be.y)||0),pe=Number(((Ke=Y.measured)==null?void 0:Ke.width)||Y.width||((Le=(We=Y.data)==null?void 0:We.nodeSize)==null?void 0:Le.width)||((ot=(Ut=Y.data)==null?void 0:Ut.displaySize)==null?void 0:ot.width)||NM),je=Number(((Qe=Y.measured)==null?void 0:Qe.height)||Y.height||((Ht=(Oe=Y.data)==null?void 0:Oe.nodeSize)==null?void 0:Ht.height)||((ht=(Fe=Y.data)==null?void 0:Fe.displaySize)==null?void 0:ht.height)||Lm);return{minX:Math.min(J.minX,ae),minY:Math.min(J.minY,he),maxX:Math.max(J.maxX,ae+pe),maxY:Math.max(J.maxY,he+je)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});if(!Number.isFinite(S.minX)||!Number.isFinite(S.minY))return;const C=new Set((_.current||[]).map(J=>J.id));let I=1,R=`group_${I}`;for(;C.has(R);)I+=1,R=`group_${I}`;const U=qb({width:S.maxX-S.minX+lh*2,height:S.maxY-S.minY+lh*2})||{width:fl,height:pl},Z={id:R,type:Tc,position:{x:S.minX-lh,y:S.minY-lh},width:U.width,height:U.height,selected:!0,draggable:!0,selectable:!0,zIndex:0,data:{isWorkspaceGroup:!0,label:Hm(I-1),title:Hm(I-1),color:"purple",nodeSize:U}};g(J=>[Z,...J.map(Y=>({...Y,selected:!1}))]),x(J=>J.map(Y=>({...Y,selected:!1}))),on(""),ge(`Created group for ${w.length} nodes`)},[pt,x,g,_e]),Fu=h.useMemo(()=>b.filter(w=>Fn(w==null?void 0:w.data)),[b]),Ny=h.useMemo(()=>pr.filter(w=>Fn(w==null?void 0:w.data)).map(w=>w.id),[pr]),rO=h.useMemo(()=>{const w=String((Vr==null?void 0:Vr.username)||(Vr==null?void 0:Vr.userId)||"").trim();return w?w.slice(0,1).toUpperCase():"?"},[Vr]),_y=h.useMemo(()=>new Set(hp),[hp]),mp=h.useMemo(()=>k.filter(w=>_y.has(w.source)&&_y.has(w.target)),[k,_y]),zu=h.useCallback((w,S="workspace")=>{if(!(w!=null&&w.flowId))return;const C=$r({...a,flowId:w.flowId,flowSource:w.flowSource||"user",workspaceId:w.workspaceId||"",archived:w.archived===!0,workflowShare:"",workflowDemo:!1}),I=S==="display"?"display":S==="workflow"?"workflow":"workspace";I!=="workspace"&&C.set("view",I),en.trim()&&C.set("tapdId",en.trim()),window.location.assign(`/workspace?${C.toString()}`)},[a,en]),Cy=h.useCallback(w=>{const S=w==="display"?"display":w==="workflow"?"workflow":"workspace";if(_t&&!a.flowId&&S!=="workflow"){yi.length===1?zu(yi[0],S):(HS(S),Qf(!0));return}p(S),on(""),V([]),ee(null),$e(!1),_n(!1);const C=$r(a);S==="display"&&C.set("view","display"),S==="workflow"&&(C.set("view","workflow"),en.trim()&&C.set("tapdId",en.trim()));const I=`/workspace${C.toString()?`?${C.toString()}`:""}`;window.history.pushState({},"",I)},[a,_t,zu,yi,en]),Kj=h.useCallback(w=>{const S=String(w||"").trim();if(!S)return;const C=_.current.find(I=>I.id===S);if(!C||!Fn(C.data)){ge("展示节点不可用");return}T(I=>{if(I.nodeIds.includes(S))return I;const R=I.nodeIds.length,U=rc(C);return{nodeIds:[...I.nodeIds,S],nodePositions:{...I.nodePositions,[S]:{x:180+R*36,y:120+R*28}},nodeSizes:{...I.nodeSizes,...U?{[S]:U}:{}}}}),V([S])},[]),qj=h.useCallback(w=>{const S=String(w||"").trim();S&&(T(C=>{const I=C.nodeIds.filter(Z=>Z!==S),R={...C.nodePositions},U={...C.nodeSizes};return delete R[S],delete U[S],{nodeIds:I,nodePositions:R,nodeSizes:U}}),V(C=>C.filter(I=>I!==S)))},[]),Uj=h.useCallback(w=>{const S=String(w||"").trim();S&&(z.current.nodeIds.includes(S)?qj(S):Kj(S))},[Kj,qj]),gp=h.useMemo(()=>{const w=Xn.trim().toLowerCase();return w?Dl.filter(S=>{var C,I;return[S.id,(C=S.data)==null?void 0:C.label,(I=S.data)==null?void 0:I.definitionId].filter(Boolean).some(R=>String(R).toLowerCase().includes(w))}):Dl},[Dl,Xn]),Gj=h.useMemo(()=>{const w=gp.length,S=w<=1?1:w<=4?2:3,C=Array.from({length:S},()=>({height:0,nodes:[]}));for(const I of gp){const R=rc(I)||{width:420,height:260},U=Math.max(1,Number(R.width)||420),Z=Math.max(1,Number(R.height)||260),J=Math.min(26,Math.max(5.5,Z/U*16))+3.2;let Y=C[0];for(const ae of C)ae.height<Y.height&&(Y=ae);Y.nodes.push(I),Y.height+=J}return C.map(I=>I.nodes)},[gp]),sO=h.useCallback(w=>{var U;const S=P.nodeIds.includes(w.id),C=rc(w)||{width:420,height:260},I=Math.max(1,Math.round(Number(C.width)||420)),R=Math.max(1,Math.round(Number(C.height)||260));return s.jsxs("button",{type:"button",className:"af-display-picker-card"+(S?" af-display-picker-card--selected":""),style:{"--af-display-picker-card-ratio":`${I} / ${R}`},onClick:()=>Uj(w.id),children:[s.jsx("span",{className:"af-display-picker-card__check","aria-hidden":!0,children:s.jsx("input",{type:"checkbox",checked:S,readOnly:!0,tabIndex:-1})}),s.jsx("span",{className:"af-display-picker-card__preview",children:s.jsx(vX,{node:w})}),s.jsxs("span",{className:"af-display-picker-card__meta",children:[s.jsx("strong",{children:((U=w.data)==null?void 0:U.label)||w.id}),s.jsxs("small",{children:[Fn(w.data)," · ",w.id]})]})]},w.id)},[P.nodeIds,Uj]),Yj=h.useMemo(()=>{const w=Ne.trim().toLowerCase();return w?jt.filter(S=>[S.id,S.version,S.displayName,S.name,S.description,...Array.isArray(S.tags)?S.tags:[]].filter(Boolean).some(C=>String(C).toLowerCase().includes(w))):jt},[jt,Ne]),Jj=h.useCallback((w,S)=>{const C=String(w||"snippet_node").trim().replace(/[^a-zA-Z0-9_]+/g,"_").replace(/^_+|_+$/g,"")||"snippet_node";let I=`${C}_${Date.now().toString(36)}`,R=2;for(;S.has(I);)I=`${C}_${Date.now().toString(36)}_${R}`,R+=1;return S.add(I),I},[]),Bu=h.useCallback((w,S)=>{var Oe,Ht;if(!_e){ge("Readonly workspace");return}const C=w!=null&&w.snippet&&typeof w.snippet=="object"?w.snippet:{},I=C.instances&&typeof C.instances=="object"?C.instances:{},R=Object.keys(I);if(R.length===0)return;const U=new Set(_.current.map(Fe=>Fe.id)),Z={};for(const Fe of R)Z[Fe]=Jj(Fe,U);const J=(Oe=C.ui)!=null&&Oe.nodePositions&&typeof C.ui.nodePositions=="object"?C.ui.nodePositions:{},Y=(Ht=C.ui)!=null&&Ht.nodeSizes&&typeof C.ui.nodeSizes=="object"?C.ui.nodeSizes:{},ae=R.map(Fe=>{const ht=J[Fe];return{id:Fe,x:typeof(ht==null?void 0:ht.x)=="number"?ht.x:0,y:typeof(ht==null?void 0:ht.y)=="number"?ht.y:0}}),he=Math.min(...ae.map(Fe=>Fe.x)),pe=Math.min(...ae.map(Fe=>Fe.y));let je=S||{x:360+_.current.length*24,y:180+_.current.length*18};if(!S){const Fe=document.querySelector(".af-workspace-canvas .react-flow");if(Fe){const ht=Fe.getBoundingClientRect();je=r.screenToFlowPosition({x:ht.left+ht.width*.48,y:ht.top+ht.height*.32})}}const Ve={},Be={},Ke={};for(const Fe of ae){const ht=Z[Fe.id];Ve[ht]={...I[Fe.id]||{}},Be[ht]={x:je.x+(Fe.x-he),y:je.y+(Fe.y-pe)};const $t=Y[Fe.id];typeof($t==null?void 0:$t.width)=="number"&&typeof($t==null?void 0:$t.height)=="number"&&(Ke[ht]={width:$t.width,height:$t.height})}const We=new Set(R),Le=(Array.isArray(C.edges)?C.edges:[]).filter(Fe=>We.has(Fe==null?void 0:Fe.source)&&We.has(Fe==null?void 0:Fe.target)).map(Fe=>({source:Z[Fe.source],target:Z[Fe.target],sourceHandle:Fe.sourceHandle??null,targetHandle:Fe.targetHandle??null})),Ut=nd({instances:Ve,edges:Le,ui:{nodePositions:Be,nodeSizes:Ke}},yt),ot=Ut.nodes.map(Fe=>Fe.id),Qe=Ut.nodes.map(Fe=>({...Fe,selected:!0}));Q.current={...Q.current,...Ut.instances},se(Q.current),g(Fe=>[...Fe.map(ht=>({...ht,selected:!1})),...Qe]),x(Fe=>[...Fe.map(ht=>({...ht,selected:!1})),...Ut.edges.map(ht=>({...ht,selected:!1}))]),on(""),V([]),ge(`已添加流程片段:${w.displayName||w.id}(已选中 ${ot.length} 个节点)`)},[Jj,yt,r,x,g,_e]),iO=h.useCallback(()=>{var C,I;if(pr.length<2){gn("请先在 workspace 画布上选择至少两个节点。"),It("flows");return}const w=pr[0],S=pr.length===2?`${((C=w.data)==null?void 0:C.label)||w.id} 片段`:`${((I=w.data)==null?void 0:I.label)||w.id} 等 ${pr.length} 个节点`;Pn({name:S,id:S.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,""),description:""}),Jn(""),gr(!0),It("flows")},[pr]),oO=h.useCallback(async()=>{var R,U;if(pr.length<2)return;const w=yn.name.trim();if(!w){Jn("请填写片段名称。");return}const S={},C={};for(const Z of pr){S[Z.id]={x:((R=Z.position)==null?void 0:R.x)||0,y:((U=Z.position)==null?void 0:U.y)||0};const J=rc(Z);J&&(C[Z.id]=J)}const I=mp.map(Z=>({source:Z.source,target:Z.target,sourceHandle:Z.sourceHandle??null,targetHandle:Z.targetHandle??null}));Wr(!0),Jn("");try{const Z=await fetch("/api/marketplace/publish-flow-snippet",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:yn.id,name:w,displayName:w,version:"1.0.0",description:yn.description,snippet:{instances:Bv(pr,Q.current),edges:I,ui:{nodePositions:S,nodeSizes:C}}})}),J=await Z.json().catch(()=>({}));if(!Z.ok||J.ok===!1)throw new Error(J.error||"发布流程片段失败");gr(!1),ge(`流程片段已发布:${J.id||w}`),VS(`流程片段已发布:${J.id||w}`),await ip(),It("flows")}catch(Z){Jn(String(Z.message||Z))}finally{Wr(!1)}},[ip,yn,mp,pr,VS]),Xj=h.useCallback(async()=>{var S;const w=pu.trim();if(w){gS(!0),No("");try{const C=await fetch("/api/workspace/collaboration/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,username:w,role:"editor"})}),I=await C.json().catch(()=>({}));if(!C.ok)throw new Error(I.error||"添加协作成员失败");Yf(I.workspace||null),wS(""),ge(`已将 Workspace 分享给 ${((S=I.member)==null?void 0:S.username)||w}`)}catch(C){No(String(C.message||C))}finally{gS(!1)}}},[a,pu]),aO=h.useCallback(()=>{No(""),Kg(!0),fetch("/api/teams/me").then(w=>w.json().then(S=>({response:w,payload:S}))).then(({response:w,payload:S})=>{var R;if(!w.ok)throw new Error(S.error||"读取团队失败");const C=S.team||null;dL(C);const I=(R=Ft==null?void 0:Ft.teamShares)==null?void 0:R.find(U=>U.teamId===(C==null?void 0:C.id));kS((I==null?void 0:I.role)==="editor"?"editor":"viewer")}).catch(w=>No(String(w.message||w)))},[Ft==null?void 0:Ft.teamShares]),Ay=h.useCallback(async(w=!1)=>{if(Vs!=null&&Vs.id){vS(!0),No("");try{const S=await fetch("/api/workspace/collaboration/team-share",{method:w?"DELETE":"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,teamId:Vs.id,role:Ug})}),C=await S.json().catch(()=>({}));if(!S.ok)throw new Error(C.error||(w?"取消团队分享失败":"分享到团队失败"));Yf(C.workspace||null),ge(w?`已取消对「${Vs.name}」的分享`:`已分享到「${Vs.name}」`)}catch(S){No(String(S.message||S))}finally{vS(!1)}}},[a,Vs,Ug]),lO=h.useCallback(async w=>{const S=String((w==null?void 0:w.userId)||"").trim();if(!(!S||S===(Ft==null?void 0:Ft.ownerId))){bS(S),No("");try{const C=await fetch("/api/workspace/collaboration/share",{method:"DELETE",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,memberUserId:S})}),I=await C.json().catch(()=>({}));if(!C.ok)throw new Error(I.error||"取消成员分享失败");Yf(I.workspace||null),ge(`已取消对 ${(w==null?void 0:w.username)||S} 的分享`)}catch(C){No(String(C.message||C))}finally{bS("")}}},[a,Ft==null?void 0:Ft.ownerId]),Qj=h.useCallback(async()=>{const w=Xl(_.current,j.current,Q.current);w.ui={...w.ui||{},...D.current?{viewport:D.current}:{},displayPage:kC(z.current,_.current)};const S=new Blob([`${JSON.stringify(w,null,2)}
|
|
264
|
+
`],{type:"application/json"}),C=URL.createObjectURL(S),I=document.createElement("a");I.href=C,I.download=`${a.flowId||"workspace"}-conflict-draft-${Date.now()}.json`,document.body.appendChild(I),I.click(),I.remove(),URL.revokeObjectURL(C),await Ps(),Sl(null),Na(!1),ge("已备份本地草稿并载入远端最新版本")},[j,a.flowId,Ps,_]),cO=h.useCallback(async()=>{const w=Array.isArray(On==null?void 0:On.conflictItems)?On.conflictItems:[];if(!w.length||!(On!=null&&On.mergeGraph)||!(On!=null&&On.currentGraph)){mu("当前冲突缺少字段合并数据,请改用“备份并载入远端”。");return}let S=On.mergeGraph;try{w.forEach((I,R)=>{const U=Gg[String(R)]||{mode:"local"};let Z,J=!0;U.mode==="remote"?(Z=I.current,J=I.hasCurrent!==!1):U.mode==="manual"?Z=JSON.parse(String(U.manual||"")):(Z=I.incoming,J=I.hasIncoming!==!1),S=oQ(S,I.pathParts,Z,J)})}catch(I){mu(`手动值不是有效 JSON:${String(I.message||I)}`);return}SS(!0),mu(""),Gs("saving"),Ys("正在提交冲突解决结果");const C=Ce.current.catch(()=>{}).then(async()=>{const I=await fetch("/api/workspace/graph",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,graph:S,baseRevision:On.currentRevision,baseGraph:On.currentGraph,clientId:rt.current})}),R=await I.json().catch(()=>({}));if(!I.ok){if(I.status===409&&Array.isArray(R.conflictItems)){const U=R.conflictItems;Sl({currentRevision:String(R.currentRevision||""),message:R.error||"Workspace 再次出现冲突",conflictPaths:Array.isArray(R.conflictPaths)?R.conflictPaths:[],conflictItems:U,mergeGraph:R.mergeGraph||null,currentGraph:R.currentGraph||null}),jl(Object.fromEntries(U.map((Z,J)=>[String(J),{mode:"local",manual:rd(Z)}])))}throw new Error(R.error||"提交冲突解决结果失败")}await Ps(),Sl(null),Na(!1),ge("冲突已解决并保存")});Ce.current=C;try{await C}catch(I){mu(String(I.message||I)),Gs("error"),Ys(String(I.message||I))}finally{SS(!1)}},[a,Ps,On,Gg]);h.useCallback(()=>{if(Fu.length===0){ge("当前 workspace 没有 display 节点");return}const w=Ny.length>0?Ny:Fu.map(C=>C.id),S=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display";jn(Hw({title:S,layout:"gallery",nodeIds:w,mode:"multi-node"})),kt(""),Zt(null),fr(!0)},[a.flowId,Ny,Fu]);const uO=h.useCallback(w=>{jn(S=>{const C=Array.isArray(S.nodeIds)?S.nodeIds:[];return C.includes(w)?{...S,nodeIds:C.filter(I=>I!==w)}:{...S,nodeIds:[...C,w]}})},[]),Xs=h.useCallback(async()=>{dn(!0),oe("");try{const w=await fetch("/api/display/shares"),S=await w.json().catch(()=>({}));if(!w.ok)throw new Error(S.error||"读取分享列表失败");hn(Array.isArray(S.shares)?S.shares:[])}catch(w){oe(String(w.message||w)),hn([])}finally{dn(!1)}},[]),dO=h.useCallback(()=>{Nn(!0),Dt(""),Xs()},[Xs]),fO=h.useCallback(async()=>{var C,I;const w=Nt.title.trim(),S=Array.isArray(Nt.nodeIds)?Nt.nodeIds:[];if(S.length===0){kt("请选择至少一个 display 节点。");return}_r(!0),kt(""),Zt(null);try{await an(b,k);const R=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:w,layout:Nt.layout,nodeIds:S,...SC(Nt)})}),U=await R.json().catch(()=>({}));if(!R.ok||U.ok===!1)throw new Error(U.error||"发布展示页失败");const Z=new URL(U.url||`/display/${((C=U.share)==null?void 0:C.id)||""}`,window.location.origin).href;Zt({...U,absoluteUrl:Z}),ge((I=U.share)!=null&&I.expiresAt?"展示页已生成":"展示页已生成:永久有效"),Pt&&Xs()}catch(R){kt(String(R.message||R))}finally{_r(!1)}},[Nt,Pt,k,a,Xs,b,an]),pO=h.useCallback(async()=>{var S,C;const w=Array.isArray(P.nodeIds)?P.nodeIds:[];if(w.length===0){kt("请先添加至少一个展示节点。"),ge("请先添加至少一个展示节点"),_n(!0);return}_r(!0),kt("");try{await an(b,k);const I=a.flowId?`${a.flowId} 展示页`:"AgentFlow Display",R=await fetch("/api/display/share",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,title:I,layout:"canvas",nodeIds:w,...SC(Nt)})}),U=await R.json().catch(()=>({}));if(!R.ok||U.ok===!1)throw new Error(U.error||"生成展示链接失败");const Z=new URL(U.url||`/display/${((S=U.share)==null?void 0:S.id)||""}`,window.location.origin).href;Zt({...U,absoluteUrl:Z}),Me(!0),ge((C=U.share)!=null&&C.expiresAt?"展示链接已生成":"展示链接已生成:永久有效"),Pt&&Xs()}catch(I){const R=String(I.message||I);kt(R),ge(R)}finally{_r(!1)}},[P.nodeIds,Nt,Pt,k,a,Xs,b,an]),Zj=h.useCallback(async()=>{const w=ct==null?void 0:ct.absoluteUrl;if(!w)return;const S=await Gb(w);ut(S?"copied":"failed"),window.setTimeout(()=>ut(""),1600)},[ct==null?void 0:ct.absoluteUrl]),hO=h.useCallback(async w=>{const S=jC(w),C=await Gb(S);Dt(C?String((w==null?void 0:w.id)||""):"failed"),window.setTimeout(()=>Dt(""),1600)},[]),mO=h.useCallback(async(w,S)=>{const C=String((w==null?void 0:w.id)||"");if(C){Re(C),oe("");try{const I=S==="permanent"?{id:C,expiresMode:"permanent",permanent:!0}:{id:C,expiresMode:"days",expiresInDays:Number(S||30)},R=await fetch("/api/display/share",{method:"PATCH",headers:{"Content-Type":"application/json"},body:JSON.stringify(I)}),U=await R.json().catch(()=>({}));if(!R.ok||U.ok===!1)throw new Error(U.error||"更新分享有效期失败");await Xs(),ge("分享有效期已更新")}catch(I){oe(String(I.message||I))}finally{Re("")}}},[Xs]),gO=h.useCallback(async w=>{const S=String((w==null?void 0:w.id)||"");if(S){Re(S),oe("");try{const C=await fetch(`/api/display/share?id=${encodeURIComponent(S)}`,{method:"DELETE"}),I=await C.json().catch(()=>({}));if(!C.ok||I.ok===!1)throw new Error(I.error||"撤销分享失败");await Xs(),ge("分享已撤销")}catch(C){oe(String(C.message||C))}finally{Re("")}}},[Xs]),yO=h.useCallback(w=>{g(S=>S.map(C=>C.id===w?{...C,selected:!1}:C)),on(S=>S===w?"":S)},[g]),Bl=h.useCallback(()=>{const w=oy.current;if(!w)return;const S=w.getBoundingClientRect(),C=Math.min(420,Math.max(320,S.width+160)),I=12,R=Math.max(180,S.top-I*2),U=Math.min(560,R);TL({position:"fixed",left:Math.max(12,Math.min(window.innerWidth-C-12,S.left)),top:Math.max(I,S.top-U-I),width:C,maxHeight:U,zIndex:1e4})},[]);h.useEffect(()=>{if(!np)return;Bl();const w=C=>{var R,U;const I=C.target;(R=oy.current)!=null&&R.contains(I)||(U=US.current)!=null&&U.contains(I)||iy(!1)},S=C=>{C.key==="Escape"&&iy(!1)};return window.addEventListener("pointerdown",w),window.addEventListener("keydown",S),window.addEventListener("resize",Bl),window.addEventListener("scroll",Bl,!0),()=>{window.removeEventListener("pointerdown",w),window.removeEventListener("keydown",S),window.removeEventListener("resize",Bl),window.removeEventListener("scroll",Bl,!0)}},[np,Bl]);const yp=h.useCallback(w=>{const S=jM(w);if(S.active&&(de.current=!0),S.finished&&(de.current=!1,st.current=!0),AY(w)&&wi(),f==="display"){T(R=>{var Y,ae;let U=R.nodePositions,Z=R.nodeSizes;for(const he of w||[]){const pe=dh(he==null?void 0:he.id);if(!(!pe||!R.nodeIds.includes(pe))&&he.type!=="select"){if(he.type==="position"&&he.position){const je=U[pe];if((je==null?void 0:je.x)===he.position.x&&(je==null?void 0:je.y)===he.position.y)continue;U===R.nodePositions&&(U={...R.nodePositions}),U[pe]={x:he.position.x,y:he.position.y};continue}if(he.type==="dimensions"&&((Y=he.dimensions)!=null&&Y.width)&&((ae=he.dimensions)!=null&&ae.height)){const je=el({width:Math.round(Number(he.dimensions.width)),height:Math.round(Number(he.dimensions.height))},{display:!0});if(je){const Ve=Z[pe];if((Ve==null?void 0:Ve.width)===je.width&&(Ve==null?void 0:Ve.height)===je.height)continue;Z===R.nodeSizes&&(Z={...R.nodeSizes}),Z[pe]=je}}}}if(U===R.nodePositions&&Z===R.nodeSizes)return R;const J={...R,nodePositions:U,nodeSizes:Z};return z.current=J,J});const I=(w||[]).filter(R=>(R==null?void 0:R.type)==="select");I.length>0&&V(R=>{const U=new Set(R);for(const J of I){const Y=dh(J==null?void 0:J.id);Y&&(J.selected?U.add(Y):U.delete(Y))}const Z=Array.from(U);return Z.length===R.length&&Z.every((J,Y)=>J===R[Y])?R:Z});return}if(!_e){const I=(w||[]).filter(R=>(R==null?void 0:R.type)==="select");I.length>0&&g(R=>Td(I,R));return}const C=(w||[]).filter(I=>{var R,U;return(I==null?void 0:I.type)==="dimensions"&&((R=I.dimensions)==null?void 0:R.width)&&((U=I.dimensions)==null?void 0:U.height)});g(I=>{const R=new Map;if(C.length>0){const J=new Map(I.map(Y=>[Y.id,Y]));for(const Y of C){const ae=J.get(Y.id),he={width:Math.round(Number(Y.dimensions.width)),height:Math.round(Number(Y.dimensions.height))},pe=Wm(ae)?qb(he):el(he,{display:!!Fn(ae==null?void 0:ae.data)});pe&&R.set(Y.id,pe)}}const U=Td(w,I),Z=R.size===0?U:U.map(J=>{const Y=R.get(J.id);if(!Y)return J;const ae={...J.data,nodeSize:Y};return Fn(J.data)&&(ae.displaySize=Y),{...J,width:Y.width,height:Y.height,data:ae}});return S.mutated||(Qt.current={nodes:Z,edges:j.current,displayPage:z.current}),_.current=Z,Z}),C.length>0&&Xr(C.map(I=>I.id))},[wi,Xr,g,f,_e]),wp=h.useCallback((w=[],{finish:S=!1}={})=>{const C=S?TY([...q.current,...w]):zb(w);S&&(q.current=[]),C.length>0&&yp(C)},[yp]),wO=h.useCallback(w=>{const{transient:S,committed:C,finishesInteraction:I}=PY(w);if(S.length>0){fe.current&&(window.clearTimeout(fe.current),fe.current=null),de.current||(de.current=!0,Fl.current=Wj.current),q.current=zb([...q.current,...S]);const R=Td(S,Fl.current);Fl.current=R,i.getState().setNodes(R)}if(I){Fl.current=[],wp(C,{finish:!0});return}C.length>0&&yp(C)},[yp,wp,i]),Wl=h.useCallback(()=>{ke.current.size>0||qe.current||((de.current||q.current.length>0)&&(wp([],{finish:!0}),Fl.current=[]),Xe.current&&Ll({type:"interaction.finished"}))},[wp,Ll]),xO=h.useCallback(w=>{(w==null?void 0:w.pointerId)!=null&&ke.current.add(w.pointerId)},[]),Eo=h.useCallback(w=>{(w==null?void 0:w.pointerId)!=null&&ke.current.delete(w.pointerId),window.queueMicrotask(Wl)},[Wl]),bO=h.useCallback(()=>{qe.current=!0},[]),kO=h.useCallback(()=>{qe.current=!1,window.queueMicrotask(Wl)},[Wl]);h.useEffect(()=>{const w=()=>{ke.current.clear(),qe.current=!1,Wl()},S=()=>{document.visibilityState==="hidden"&&w()};return window.addEventListener("pointerup",Eo,!0),window.addEventListener("pointercancel",Eo,!0),window.addEventListener("lostpointercapture",Eo,!0),window.addEventListener("blur",w),document.addEventListener("visibilitychange",S),()=>{window.removeEventListener("pointerup",Eo,!0),window.removeEventListener("pointercancel",Eo,!0),window.removeEventListener("lostpointercapture",Eo,!0),window.removeEventListener("blur",w),document.removeEventListener("visibilitychange",S),ke.current.clear(),qe.current=!1,q.current=[],Fl.current=[]}},[Eo,Wl]);const vO=h.useCallback(w=>{if(f!=="display"){if(!_e){const S=(w||[]).filter(C=>(C==null?void 0:C.type)==="select");S.length>0&&x(C=>{const I=Cm(S,C);return j.current=I,I});return}(w||[]).some(S=>(S==null?void 0:S.type)!=="select")&&wi(),x(S=>{const C=Cm(w,S);return j.current=C,C})}},[wi,x,f,_e]),Hl=h.useCallback(()=>{const w=document.querySelector(".af-workspace-canvas .react-flow");if(w){const S=w.getBoundingClientRect();return r.screenToFlowPosition({x:S.left+S.width*.48,y:S.top+S.height*.32})}return{x:360+b.length*36,y:180+b.length*28}},[b.length,r]),xp=h.useCallback(()=>{var w,S,C;if(Jt){const I=Number(((w=Jt.measured)==null?void 0:w.width)||Jt.width||260);return{x:Number(((S=Jt.position)==null?void 0:S.x)||0)+I+140,y:Number(((C=Jt.position)==null?void 0:C.y)||0)}}return Hl()},[Hl,Jt]),Yi=h.useCallback((w,S={})=>{if(!_e)return ge("Readonly workspace"),null;if(!w)return null;const C=Gv(w)||w.id,I=$M(w),R=OM(w),U=S.id||VJ(C,b),Z=yd(w.inputs),J=yd(w.outputs),Y={definitionId:C,...I?{marketplaceRef:I}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},label:S.label||Bm(w),role:"normal",body:S.body||"",...S.script||R?{script:S.script||R}:{},...S.scriptRef?{scriptRef:S.scriptRef}:{},...S.implementationRef?{implementationRef:S.implementationRef}:{},...S.implementationMode?{implementationMode:S.implementationMode}:{},input:S.inputs||Z,output:S.outputs||J},ae={id:U,type:Tc,position:S.position||Hl(),data:{label:Y.label,definitionId:C,...I?{marketplaceRef:I}:{},...w.packageId?{marketplacePackageId:w.packageId}:{},...w.version?{marketplaceVersion:w.version}:{},schemaType:MM(C,w),role:"normal",body:Y.body,...Y.script?{script:Y.script}:{},...Y.scriptRef?{scriptRef:Y.scriptRef}:{},...Y.implementationRef?{implementationRef:Y.implementationRef}:{},...Y.implementationMode?{implementationMode:Y.implementationMode}:{},inputs:Y.input,outputs:Y.output}},he={...Db(ae,{...Q.current,[U]:Y},yt),selected:!0};return wi(),g(pe=>[...pe.map(je=>({...je,selected:!1})),he]),S.openProperties&&on(U),U},[Hl,wi,b,yt,g,_e]),SO=h.useCallback(w=>Bw(w,_.current),[]),jO=h.useCallback(w=>{if(!_e){ge("Readonly workspace");return}if(!Bw(w,_.current)){ge("端口类型不匹配,已取消连线");return}ee(null),wi(),g(S=>Mw(S,w)),x(S=>{const C=S.filter(R=>!(R.target===w.target&&R.targetHandle===w.targetHandle)),I=Fh({...w,markerEnd:{type:Ii.ArrowClosed}},C);return j.current=I,I})},[wi,x,g,_e]),NO=h.useCallback((w,S)=>{if(!_e)return;const C=BJ(S,_.current);ne.current=C?{...C,preferExisting:!!(w!=null&&w.shiftKey)}:null,ee(null)},[_e]),_O=h.useCallback((w,S)=>{var We,Le,Ut,ot;if(!_e)return;const C=ne.current;if(ne.current=null,!C||S!=null&&S.toNode)return;const I=WJ(yt,C),R=HJ(_.current,j.current,C);if(I.length===0&&R.length===0){ge(`没有匹配 ${C.slotType} 端口的节点`);return}const Z=!!(w!=null&&w.shiftKey||C.preferExisting)?R.length>0?"existing":"create":I.length>0?"create":"existing",J=((Le=(We=w==null?void 0:w.changedTouches)==null?void 0:We[0])==null?void 0:Le.clientX)??(w==null?void 0:w.clientX),Y=((ot=(Ut=w==null?void 0:w.changedTouches)==null?void 0:Ut[0])==null?void 0:ot.clientY)??(w==null?void 0:w.clientY);if(!Number.isFinite(J)||!Number.isFinite(Y))return;const ae=document.querySelector(".af-workspace-canvas .react-flow");if(!ae)return;const he=ae.getBoundingClientRect(),pe=320,je=Math.max(I.length,R.length),Ve=Math.min(480,150+je*58),Be=Math.max(12,Math.min(J-he.left,he.width-pe-12)),Ke=Math.max(12,Math.min(Y-he.top,he.height-Ve-12));ee({left:Be,top:Ke,flowPosition:r.screenToFlowPosition({x:J,y:Y}),draft:C,candidates:I,existingCandidates:R,mode:Z,query:""})},[yt,r,_e]),CO=h.useCallback(w=>{if(!_e){ge("Readonly workspace"),ee(null);return}const S=ce.current;if(!S||!(w!=null&&w.def))return;const C=Yi(w.def,{position:S.flowPosition});if(!C)return;const I=S.draft.handleType==="source"?{source:S.draft.nodeId,sourceHandle:S.draft.handleId,target:C,targetHandle:`input-${w.slotIndex}`}:{source:C,sourceHandle:`output-${w.slotIndex}`,target:S.draft.nodeId,targetHandle:S.draft.handleId};g(R=>Mw(R,I)),x(R=>{const U=R.filter(J=>!(J.target===I.target&&J.targetHandle===I.targetHandle)),Z=Fh({...I,markerEnd:{type:Ii.ArrowClosed}},U);return j.current=Z,Z}),ee(null)},[Yi,x,_e]),AO=h.useCallback(w=>{if(!_e){ge("Readonly workspace"),ee(null);return}const S=w==null?void 0:w.connection;if(!S||!Bw(S,_.current)){ge("端口类型不匹配,已取消连线"),ee(null);return}g(C=>Mw(C,S)),x(C=>{const I=C.filter(U=>!(U.target===S.target&&U.targetHandle===S.targetHandle)),R=Fh({...S,markerEnd:{type:Ii.ArrowClosed}},I);return j.current=R,R}),ee(null)},[x,g,_e]),e0=h.useCallback(w=>{w&&(Yi(w,{position:xp()}),$e(!1),Wt(""))},[Yi,xp]),t0=h.useCallback(w=>{w&&(Bu(w,xp()),$e(!1),Wt(""))},[Bu,xp]),EO=h.useCallback(w=>{var C,I,R;if(pt||_t)return;const S=w==null?void 0:w.target;uC(S)||(C=S==null?void 0:S.closest)!=null&&C.call(S,"button, a, [role='button'], .react-flow__handle")||(R=(I=N.current)==null?void 0:I.focus)==null||R.call(I,{preventScroll:!0})},[pt,_t]);h.useEffect(()=>{const w=S=>{var ae;if(S.defaultPrevented)return;const C=jG(S.target)||uC(S.target);if((S.metaKey||S.ctrlKey)&&S.key.toLowerCase()==="s"){S.preventDefault(),an().catch(he=>ge(String(he.message||he)));return}if((S.metaKey||S.ctrlKey)&&S.key.toLowerCase()==="k"){S.preventDefault(),S.stopPropagation(),ej(he=>!he);return}if(py)return;if(fy){(S.key==="Escape"||V1(S))&&(S.preventDefault(),sp(!1));return}const I=S.key.toLowerCase(),R=(S.metaKey||S.ctrlKey)&&I==="c",U=(S.metaKey||S.ctrlKey)&&I==="v",Z=C&&R&&nJ(S.target);if(C&&!Z)return;const J=(S.metaKey||S.ctrlKey)&&!S.shiftKey&&I==="z",Y=(S.metaKey||S.ctrlKey)&&(S.shiftKey&&I==="z"||I==="y");if(J||Y){if(pt){S.preventDefault(),S.stopPropagation(),ge("展示页布局会自动保存");return}if(!_e){S.preventDefault(),ge("Readonly workspace");return}S.preventDefault(),S.stopPropagation();const he=J?mj():gj();ge(he?J?"Undo canvas change":"Redo canvas change":J?"Nothing to undo":"Nothing to redo");return}if(R){if(pt)return;const he=fS.current,pe=(_.current||[]).some(Ve=>Ve==null?void 0:Ve.selected)?_.current:(_.current||[]).map(Ve=>he&&Ve.id===he?{...Ve,selected:!0}:Ve),je=qU(pe,j.current,Q.current);je&&(S.preventDefault(),S.stopPropagation(),B.current=je,iX(je),Z&&typeof((ae=S.target)==null?void 0:ae.blur)=="function"&&S.target.blur(),ge(`Copied ${je.nodes.length} node${je.nodes.length>1?"s":""}`));return}if(U){if(pt){S.preventDefault(),S.stopPropagation();return}if(!_e){S.preventDefault(),ge("Readonly workspace");return}const he=B.current||oX();he&&!B.current&&(B.current=he);const pe=UU(he,_.current,j.current,Q.current);pe&&(S.preventDefault(),S.stopPropagation(),Q.current=pe.instances,se(pe.instances),g(pe.nodes),x(pe.edges),ge(`Pasted ${pe.pastedNodeIds.length} node${pe.pastedNodeIds.length>1?"s":""}`));return}if(V1(S)&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),sp(!0);return}if(I==="g"&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),Vj();return}if(S.key==="a"||S.key==="A"){if(S.metaKey||S.ctrlKey){S.preventDefault(),pt?V(z.current.nodeIds):(g(he=>he.map(pe=>({...pe,selected:!0}))),x(he=>he.map(pe=>({...pe,selected:!1}))));return}if(S.altKey)return;if(pt){S.preventDefault(),_n(!0);return}if(!_e){S.preventDefault(),ge("Readonly workspace");return}S.preventDefault(),$e(!0);return}if((S.key==="v"||S.key==="V")&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),tj("select");return}if((S.key==="h"||S.key==="H")&&!S.metaKey&&!S.ctrlKey&&!S.altKey){S.preventDefault(),tj("pan");return}(S.key==="f"||S.key==="F")&&!S.metaKey&&!S.ctrlKey&&!S.altKey&&(S.preventDefault(),Hj())};return window.addEventListener("keydown",w,!0),()=>window.removeEventListener("keydown",w,!0)},[Vj,pt,py,Hj,gj,an,fy,x,g,mj,_e]);const IO=h.useCallback(w=>{Nl(S=>{const C=new Set(S);return C.has(w)?C.delete(w):C.add(w),C})},[]),PO=h.useCallback((w,S)=>{w.dataTransfer.effectAllowed="copy",w.dataTransfer.setData("application/x-agentflow-workspace-file",JSON.stringify({path:S.path,name:S.name,type:S.type})),w.dataTransfer.setData("text/plain",S.path)},[]),TO=h.useCallback((w,S)=>{w.dataTransfer.effectAllowed="move",w.dataTransfer.setData("application/agentflow-node",S.id),w.dataTransfer.setData("text/plain",S.id)},[]),bp=h.useCallback(async(w,S)=>{const C=String((w==null?void 0:w.name)||(w==null?void 0:w.path)||"").toLowerCase(),I=C.split(".").pop(),R=["jsx","tsx","js"].includes(I)?"display_react_app":I==="html"?"display_html":I==="csv"||I==="tsv"||I==="json"&&/\b(table|data|rows|report)\b/i.test(C)?"display_table":["png","jpg","jpeg","gif","webp","svg"].includes(I)?"display_image":"display_markdown",U=yt.find(pe=>pe.id===R);if(!U){ge("展示节点不可用");return}const Z=R==="display_image";let J=String(w.path||"");if(!Z){const pe=$r(a);pe.set("path",w.path);const je=await fetch(`/api/workspace/file?${pe.toString()}`),Ve=await je.json();if(!je.ok)throw new Error(Ve.error||"读取文件失败");J=String(Ve.content||"")}const Y=R==="display_image"?"src":"content",ae=yd(U.inputs).map(pe=>pe.name===Y?{...pe,default:J,value:J}:pe),he=yd(U.outputs).map(pe=>pe.name===Y?{...pe,default:J,value:J}:pe);Yi(U,{label:w.name||"Display",body:J,inputs:ae,outputs:he,position:S}),ge(`已创建展示:${w.path}`)},[Yi,a,yt]),RO=h.useCallback(w=>{if(!_e){ge("Readonly workspace");return}bp(w,Hl()).catch(S=>ge(String(S.message||S)))},[bp,Hl,_e]),MO=h.useCallback(w=>{if(!_e){w.preventDefault(),ge("Readonly workspace");return}const S=w.dataTransfer.getData("application/x-agentflow-workspace-file");if(S){w.preventDefault();let Z;try{Z=JSON.parse(S)}catch{return}if(!(Z!=null&&Z.path))return;const J=r.screenToFlowPosition({x:w.clientX,y:w.clientY});bp(Z,J).catch(Y=>ge(String(Y.message||Y)));return}const C=w.dataTransfer.getData("application/agentflow-snippet");if(C){const Z=jt.find(Y=>`${Y.id}@${Y.version}`===C);if(!Z)return;w.preventDefault();const J=r.screenToFlowPosition({x:w.clientX,y:w.clientY});Bu(Z,J);return}const I=w.dataTransfer.getData("application/agentflow-node");if(!I)return;const R=yt.find(Z=>Z.id===I);if(!R)return;w.preventDefault();const U=r.screenToFlowPosition({x:w.clientX,y:w.clientY});Yi(R,{position:U})},[bp,Yi,jt,Bu,yt,r,_e]),$O=h.useCallback(w=>{if(!_e)return;const S=Array.from(w.dataTransfer.types||[]);!S.includes("application/x-agentflow-workspace-file")&&!S.includes("application/agentflow-node")&&!S.includes("application/agentflow-snippet")||(w.preventDefault(),w.dataTransfer.dropEffect=S.includes("application/agentflow-node")||S.includes("application/agentflow-snippet")?"move":"copy")},[_e]),LO=h.useCallback(async(w="")=>{if(!_e){ge("Readonly workspace");return}const S=window.prompt("新文件名",w?`${w}/notes.md`:"notes.md");if(!S)return;const C=w&&!S.includes("/")?`${w}/${S}`:S;try{const I=await fetch("/api/workspace/file",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:C,content:""})}),R=await I.json();if(!I.ok)throw new Error(R.error||"创建文件失败");await Dn(),Nl(U=>{const Z=new Set(U);for(const J of fh(R.path||C))Z.delete(J);return Z}),ge(`已创建 ${R.path}`)}catch(I){ge(String(I.message||I))}},[a,Dn,_e]),OO=h.useCallback(async(w="")=>{if(!_e){ge("Readonly workspace");return}const S=window.prompt("新文件夹名",w?`${w}/docs`:"docs");if(!S)return;const C=w&&!S.includes("/")?`${w}/${S}`:S;try{const I=await fetch("/api/workspace/folder",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:C})}),R=await I.json();if(!I.ok)throw new Error(R.error||"创建文件夹失败");await Dn(),Nl(U=>{const Z=new Set(U);for(const J of fh(R.path||C))Z.delete(J);return R.path&&Z.delete(R.path),Z}),ge(`已创建 ${R.path}`)}catch(I){ge(String(I.message||I))}},[a,Dn,_e]),DO=h.useCallback(async w=>{if(!_e){ge("Readonly workspace");return}if(!(!(w!=null&&w.path)||!window.confirm(`删除 ${w.path}?`)))try{const S=await fetch("/api/workspace/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,path:w.path})}),C=await S.json();if(!S.ok)throw new Error(C.error||"删除失败");ge(`已删除 ${C.path}`),await Dn()}catch(S){ge(String(S.message||S))}},[a,Dn,_e]),FO=h.useCallback(w=>{if(!(w!=null&&w.path)||w.type==="directory")return;const S=bf(w.path,a,{download:!0});if(!S)return;const C=document.createElement("a");C.href=S,C.download=w.name||w.path.split("/").pop()||"download",C.rel="noopener",document.body.appendChild(C),C.click(),C.remove()},[a]),Ey=h.useCallback(async()=>{if(!_e){ge("Readonly workspace");return}const w=El.trim(),S=Qr,C=Us.find(Z=>Z.id===S)||null;if(!w||fs||(C==null?void 0:C.status)==="running"||(C==null?void 0:C.status)==="stopping")return;const I=C?Array.isArray(C.messages)?C.messages:[]:Ca,R=Xl(b,k,Q.current);ay(""),YS(!0),Pl(!0),Tl(null);const U={role:"user",text:w,at:Date.now()};C?sr(Z=>Z.map(J=>J.id===S?{...J,status:"running",messages:[...Array.isArray(J.messages)?J.messages:[],U].slice(-180)}:J)):(Is("workspace"),Il(Z=>[...Z,U]));try{await an(b,k);const Z=await fetch("/api/workspace/generate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({...a,prompt:w,outputKind:"markdown",workspaceGraph:R,allowFlowYaml:!1,model:Ki,selectedSkills:qs,selectedNodeIds:hp,messages:I})}),J=await Z.json();if(!Z.ok)throw new Error(J.error||"生成失败");const ae={role:"assistant",kind:"assistant",text:String(J.content||"").trim(),at:Date.now()};C?sr(he=>he.map(pe=>pe.id===S?{...pe,status:"done",messages:[...Array.isArray(pe.messages)?pe.messages:[],ae].slice(-180)}:pe)):Il(he=>[...he,ae]),await Ps(),ge("AI 生成完成")}catch(Z){const J=String(Z.message||Z),Y={role:"assistant",text:J,error:!0,at:Date.now()};C?sr(ae=>ae.map(he=>he.id===S?{...he,status:"failed",messages:[...Array.isArray(he.messages)?he.messages:[],Y].slice(-180)}:he)):Il(ae=>[...ae,Y]),ge(J)}finally{YS(!1)}},[Qr,Ca,Ki,Us,fs,El,k,a,Ps,b,an,hp,qs,_e]),xr=Us.find(w=>w.id===Qr)||null,Iy=xr?Array.isArray(xr.messages)?xr.messages:[]:Ca,Wu=xr&&(xr.status==="running"||xr.status==="stopping")||fs,zO=WX(Iy,Wu),n0=HX(Iy),r0=xr?xr.status==="stopping"?`${xr.label} stopping`:xr.status==="running"?`${xr.label} running`:xr.status==="paused"?`${xr.label} paused`:xr.status==="failed"?`${xr.label} failed`:`${xr.label} done`:fs?"Workspace agent running":Ca.length>0?"Workspace conversation":"Ready";h.useEffect(()=>{Qr!=="workspace"&&(Us.some(w=>w.id===Qr)||Is(Ia()))},[Qr,Us,Ia]),h.useEffect(()=>{if(!ju)return;const w=window.requestAnimationFrame(()=>{var C,I;const S=JS.current;S&&(S.scrollTop=S.scrollHeight),(I=(C=ly.current)==null?void 0:C.scrollIntoView)==null||I.call(C,{block:"nearest",inline:"nearest"})});return()=>window.cancelAnimationFrame(w)},[Iy.length,Qr,r0,n0.length,ju]);const BO=String(a.flowId||"").trim()||"Workspace",Io=(Nt==null?void 0:Nt.mode)==="single-node",s0=Io&&Fu.find(w=>{var S;return w.id===Nt.sourceNodeId||((S=Nt.nodeIds)==null?void 0:S.includes(w.id))})||null,WO=Io&&s0?[s0]:Fu;return s.jsxs("div",{className:"af-workspace-page",children:[l?null:s.jsxs("header",{className:"af-pipeline-top af-workspace-top",children:[s.jsxs("div",{className:"af-pipeline-top-left",children:[s.jsx("button",{type:"button",className:"af-icon-btn af-pipeline-back",onClick:()=>n(a.adminOwnerId?"/admin/usage":a.returnTo||"/projects"),"aria-label":"返回",children:s.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"})}),s.jsxs("div",{className:"af-pipeline-brand",title:a.flowId?`${a.flowId} · ${mS}`:mS||"PROJECT",children:[s.jsx("span",{className:"af-pipeline-brand-name",children:BO}),s.jsxs("span",{className:"af-pipeline-brand-ver",children:["V",qY,"-STABLE"]})]}),Gf?s.jsxs("span",{className:"af-workspace-admin-review-badge",title:"管理员审阅模式不会修改、运行或加入该 Workspace",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),"只读查看 · ",Gf.ownerUsername||Gf.ownerUserId]}):null,s.jsxs("div",{className:"af-view-switch","aria-label":"视图切换",children:[s.jsx("button",{type:"button",className:f==="workspace"?"af-view-switch__active":"",onClick:()=>Cy("workspace"),children:"Workspace"}),s.jsx("button",{type:"button",className:f==="display"?"af-view-switch__active":"",onClick:()=>Cy("display"),children:"Display"}),s.jsx("button",{type:"button",className:f==="workflow"?"af-view-switch__active":"",onClick:()=>Cy("workflow"),children:"Workflow"})]})]}),s.jsxs("div",{className:"af-pipeline-top-right af-workspace-actions",children:[_t?null:s.jsx("span",{className:`af-workspace-sync-light is-${aj}`,title:`${pj} · ${lj}`,role:"status","aria-label":`${pj}:${lj}`,children:s.jsx("span",{className:"af-workspace-sync-light__dot","aria-hidden":!0})}),_t&&!a.workflowShare&&!a.workflowDemo?s.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:()=>{HS("workspace"),Qf(!0),Co(""),gy().catch(w=>{Co(String(w.message||w))})},title:"管理当前迭代绑定的 Projects",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"hub"}),"Projects",yi.length?` · ${yi.length}`:""]}):null,!_t&&On?s.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:()=>{var w;(w=On.conflictItems)!=null&&w.length?Na(!0):Qj()},title:["先下载当前本地草稿,再载入远端最新版本",...On.conflictPaths||[]].join(`
|
|
265
|
+
`),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"difference"}),"处理冲突"]}):null,pt?s.jsxs(s.Fragment,{children:[s.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!_e||qn||!(ct!=null&&ct.absoluteUrl)&&P.nodeIds.length===0,onClick:()=>{ut(""),Me(!0)},title:ct!=null&&ct.absoluteUrl?"查看展示链接":P.nodeIds.length===0?"先添加展示节点":"生成展示链接",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:qn?"hourglass_empty":"ios_share"}),qn?"生成中":ct!=null&&ct.absoluteUrl?"展示链接":"生成链接"]}),s.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:!_e||Dl.length===0,onClick:()=>_n(!0),title:Dl.length===0?"当前 workspace 没有 display 节点":"选择展示节点 (A)",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"添加展示"]})]}):null,s.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",disabled:_t?!en:!_e||!!(Ft!=null&&Ft.role&&Ft.role!=="owner"),onClick:()=>{_t?pL(w=>w+1):aO()},title:_t?en?"管理当前需求的成员权限和只读链接":"先读取一个 TAPD 需求":Ft!=null&&Ft.role&&Ft.role!=="owner"?"仅 Workspace 所有者可以管理项目协作":"管理项目的团队和成员协作",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"协作"]}),!Gf&&!_t?s.jsxs("button",{type:"button",className:"af-workspace-display-share-btn",onClick:dO,title:"查看我的展示分享",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_shared"}),"我的分享"]}):null,_t?null:s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",className:"af-icon-btn",disabled:!fj,onClick:()=>m(!0),"aria-label":e("project:archiveModal.title"),title:e("project:archiveModal.title"),children:s.jsx("span",{className:"material-symbols-outlined",children:"archive"})}),s.jsx("button",{type:"button",className:"af-icon-btn af-icon-btn--danger",disabled:!fj&&!Pu,onClick:()=>v(!0),"aria-label":Pu?"退出共享 Workspace":e("flow:topbar.deletePipeline"),title:Pu?"退出共享 Workspace":e("flow:topbar.deletePipeline"),children:s.jsx("span",{className:"material-symbols-outlined",children:Pu?"logout":"delete_forever"})})]}),s.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>sp(!0),"aria-label":"快捷键",title:"快捷键 (?)",children:s.jsx("span",{className:"material-symbols-outlined",children:"help"})}),s.jsxs("button",{type:"button",className:"af-composer-topbar-btn"+(_t?" af-composer-topbar-btn--workflow":"")+(ju?" af-composer-topbar-btn--active":"")+(fs?" af-composer-topbar-btn--running":""),disabled:pt||(_t?!en||!!a.workflowShare:!_e),onClick:()=>{if(_t){mL(w=>w+1);return}Tl(null),Pl(w=>(w||Is(Ia()),!w))},title:_t?"结合需求上下文和绑定代码仓库进行 AI 问答":"打开 Workspace AI",children:[_t?s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"}):null,_t?"需求 AI":"AI"]}),_t?null:s.jsx("button",{type:"button",className:"af-btn-primary af-btn-primary--lg",disabled:!_e,onClick:()=>an().catch(w=>ge(String(w.message||w))),children:"Save"})]})]}),Hr?s.jsxs("div",{className:"af-flow-snippet-toast",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),s.jsx("span",{children:Hr}),s.jsx("button",{type:"button",onClick:()=>Vn(""),"aria-label":"关闭发布提示",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}):null,s.jsxs("div",{className:"af-workspace-body"+(!pt&&!_t&&(ju||wt)?" af-workspace-body--drawer":"")+(!pt&&!_t&&_u?" af-workspace-body--sidebar-collapsed":"")+(pt?" af-workspace-body--display-mode":"")+(_t?" af-workspace-body--workflow-mode":""),children:[!pt&&!_t&&_u?s.jsx("nav",{className:"af-workspace-rail","aria-label":"Workspace sidebar",children:s.jsxs("div",{className:"af-workspace-rail__stack",children:[s.jsxs("button",{type:"button",className:"af-workspace-rail__primary",onClick:()=>$e(!0),"aria-label":"添加节点",title:"添加节点",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add"}),s.jsx("span",{className:"af-workspace-rail__dot","aria-hidden":!0})]}),s.jsx("button",{type:"button",className:"af-workspace-rail__btn",onClick:()=>rp(!1),"aria-label":"展开文件",title:"展开文件",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder"})}),s.jsx("span",{className:"af-workspace-rail__divider","aria-hidden":!0}),s.jsx("button",{type:"button",className:"af-workspace-rail__avatar",onClick:()=>rp(!1),"aria-label":"展开侧边栏",title:(Vr==null?void 0:Vr.username)||(Vr==null?void 0:Vr.userId)||"展开侧边栏",children:rO})]})}):null,!pt&&!_t?s.jsxs("aside",{ref:Zg,className:"af-workspace-sidebar"+(xL?" af-workspace-sidebar--resizing":""),"aria-hidden":_u,style:{"--af-work-files-pane-height":`${Math.round(ey)}px`},children:[s.jsxs("section",{className:"af-workspace-files-section",children:[s.jsxs("div",{className:"af-workspace-sidebar-head",children:[s.jsx("h2",{children:"Files"}),s.jsxs("div",{className:"af-workspace-sidebar-actions",children:[s.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>rp(!0),"aria-label":"最小化侧边栏",title:"最小化侧边栏",children:s.jsx("span",{className:"material-symbols-outlined",children:"keyboard_double_arrow_left"})}),s.jsx("button",{type:"button",className:"af-icon-btn",disabled:!_e,onClick:()=>LO(Gi),"aria-label":"新增文件",title:Gi?`在 ${Gi} 新增文件`:"新增文件",children:s.jsx("span",{className:"material-symbols-outlined",children:"note_add"})}),s.jsx("button",{type:"button",className:"af-icon-btn",disabled:!_e,onClick:()=>OO(Gi),"aria-label":"新增文件夹",title:Gi?`在 ${Gi} 新增文件夹`:"新增文件夹",children:s.jsx("span",{className:"material-symbols-outlined",children:"create_new_folder"})}),s.jsx("button",{type:"button",className:"af-icon-btn",disabled:!_e||NS,onClick:()=>Ij(Gi),"aria-label":"上传文件",title:Gi?`上传到 ${Gi}`:"上传文件",children:s.jsx("span",{className:"material-symbols-outlined",children:NS?"hourglass_top":"upload_file"})}),s.jsx("button",{type:"button",className:"af-icon-btn",onClick:()=>void Dn(),"aria-label":"刷新文件",title:"刷新文件",children:s.jsx("span",{className:"material-symbols-outlined",children:"refresh"})}),s.jsx("input",{ref:CS,type:"file",multiple:!0,className:"af-visually-hidden",onChange:UL})]})]}),s.jsx("input",{className:"af-workspace-search",value:Yg,onChange:w=>yL(w.target.value),placeholder:"搜索文件..."}),s.jsx("div",{className:"af-workspace-files-scroll",onClick:tO,children:s.jsx(ZM,{items:eO,onOpen:RO,selectedPath:Jg,collapsedDirs:wL,onToggleDir:IO,onSelect:w=>Xg(w.path||""),onFileDragStart:PO,onDelete:DO,onDownload:FO})})]}),s.jsx("button",{type:"button",className:"af-workspace-sidebar-resizer",onPointerDown:EL,role:"separator","aria-orientation":"horizontal","aria-label":"调整 Files 和 Palette 区域大小",title:"拖动调整 Files / Palette 高度"}),s.jsxs("section",{className:"af-workspace-nodes-section",children:[s.jsxs("div",{className:"af-node-palette-head af-workspace-node-palette-head",children:[s.jsxs("h2",{className:"af-node-palette-title",children:[s.jsx("span",{children:"Palette"}),s.jsx("span",{className:"af-node-palette-title-kbd","aria-label":"快捷键 A",children:"A"})]}),s.jsxs("label",{className:"af-palette-search-wrap",children:[s.jsx("span",{className:"af-visually-hidden",children:He==="flows"?"搜索流程片段":"搜索节点"}),s.jsx("span",{className:"af-palette-search-icon material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",className:"af-palette-search-input",value:Ne,onChange:w=>Ye(w.target.value),placeholder:He==="flows"?"搜索流程片段...":"搜索节点...","aria-label":He==="flows"?"搜索流程片段":"搜索节点"})]}),s.jsxs("div",{className:"af-palette-tabs",role:"tablist","aria-label":"Palette 类型",children:[s.jsxs("button",{type:"button",role:"tab","aria-selected":He==="nodes",className:"af-palette-tab"+(He==="nodes"?" af-palette-tab--active":""),onClick:()=>It("nodes"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"category"}),"节点"]}),s.jsxs("button",{type:"button",role:"tab","aria-selected":He==="flows",className:"af-palette-tab"+(He==="flows"?" af-palette-tab--active":""),onClick:()=>It("flows"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"account_tree"}),"流程"]})]})]}),s.jsx("div",{className:"af-node-palette-scroll af-workspace-node-palette-scroll",children:He==="flows"?s.jsxs(s.Fragment,{children:[s.jsx("section",{className:"af-palette-section af-flow-palette-section--snippets",children:s.jsxs("div",{className:"af-flow-snippet-actions",children:[s.jsxs("button",{type:"button",className:"af-flow-snippet-publish-btn",onClick:iO,disabled:pr.length<2,title:pr.length<2?"选择至少两个节点后发布流程片段":"发布选中的流程片段",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布选中片段"]}),s.jsxs("span",{className:"af-flow-snippet-selection",children:["已选 ",pr.length," 节点 / ",mp.length," 连线"]})]})}),rn?s.jsx("p",{className:"af-err af-palette-list-err",children:rn}):null,$n?s.jsx("p",{className:"af-palette-empty",children:"正在加载流程片段..."}):Yj.length>0?s.jsxs("section",{className:"af-palette-section af-flow-palette-section--snippets",children:[s.jsx("h3",{className:"af-palette-cat",children:"FLOW SNIPPETS"}),s.jsx("div",{className:"af-palette-cards",children:Yj.map(w=>{const S=`${w.id}@${w.version}`,C=w.displayName||w.name||w.id,I=w.description||`${w.nodeCount||0} 个节点,${w.edgeCount||0} 条连线`;return s.jsxs("button",{type:"button",className:"af-palette-card af-flow-snippet-card",draggable:!0,onDragStart:R=>{R.dataTransfer.effectAllowed="move",R.dataTransfer.setData("application/agentflow-snippet",S),R.dataTransfer.setData("text/plain",S)},onClick:()=>Bu(w),title:I,children:[s.jsxs("span",{className:"af-palette-card-head",children:[s.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:s.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})}),s.jsxs("span",{className:"af-palette-card-main",children:[s.jsx("span",{className:"af-palette-card-label",children:C}),s.jsxs("span",{className:"af-palette-card-id",children:[w.id,"@",w.version]})]})]}),I?s.jsx("span",{className:"af-palette-card-desc",children:I}):null,s.jsxs("span",{className:"af-flow-snippet-meta","aria-hidden":!0,children:[s.jsxs("span",{children:[w.nodeCount||0," nodes"]}),s.jsxs("span",{children:[w.edgeCount||0," edges"]})]})]},S)})})]}):s.jsx("p",{className:"af-palette-empty",children:Ne.trim()?"没有匹配的流程片段":"暂无流程片段。选择多个节点后发布。"})]}):s.jsxs(s.Fragment,{children:[tc.map(w=>{var S;return(S=Sy[w])!=null&&S.length?s.jsxs("section",{className:`af-palette-section af-flow-palette-section--${w}`,children:[s.jsx("h3",{className:"af-palette-cat",children:w}),s.jsx("div",{className:"af-palette-cards",children:Sy[w].map(C=>{const I=yC(C.inputs,"input"),R=yC(C.outputs,"output"),U=Kb(C),Z=md(C);return s.jsxs("button",{type:"button",className:"af-palette-card",draggable:!0,onDragStart:J=>TO(J,C),onClick:()=>Yi(C),title:U||C.id,children:[s.jsxs("span",{className:"af-palette-card-head",children:[s.jsx("span",{className:"af-palette-card-icon","aria-hidden":!0,children:s.jsx("span",{className:"material-symbols-outlined",children:mC(w)})}),s.jsxs("span",{className:"af-palette-card-main",children:[s.jsx("span",{className:"af-palette-card-label",children:Z}),Z!==C.id?s.jsx("span",{className:"af-palette-card-id",children:C.id}):null]})]}),U?s.jsx("span",{className:"af-palette-card-desc",children:U}):null,s.jsxs("span",{className:"af-palette-card-ports","aria-hidden":!0,children:[s.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--in",children:[s.jsxs("span",{className:"af-palette-card-port-count",children:[I.list.length," IN"]}),s.jsxs("span",{className:"af-palette-card-port-list",children:[I.shown.map((J,Y)=>s.jsxs("span",{className:"af-palette-card-port",title:gC("input",J,Y),children:[s.jsx("span",{className:"af-palette-card-port-dot",style:{background:Bn(J==null?void 0:J.type)}}),s.jsx("span",{className:"af-palette-card-port-name",children:ch(J,Y)})]},`in-${Y}`)),I.hidden>0?s.jsxs("span",{className:"af-palette-card-port-more",children:["+",I.hidden]}):null]})]}),s.jsxs("span",{className:"af-palette-card-port-side af-palette-card-port-side--out",children:[s.jsxs("span",{className:"af-palette-card-port-count",children:[R.list.length," OUT"]}),s.jsxs("span",{className:"af-palette-card-port-list",children:[R.shown.map((J,Y)=>s.jsxs("span",{className:"af-palette-card-port",title:gC("output",J,Y),children:[s.jsx("span",{className:"af-palette-card-port-name",children:ch(J,Y)}),s.jsx("span",{className:"af-palette-card-port-dot",style:{background:Bn(J==null?void 0:J.type)}})]},`out-${Y}`)),R.hidden>0?s.jsxs("span",{className:"af-palette-card-port-more",children:["+",R.hidden]}):null]})]})]})]},C.id)})})]},w):null}),yt.length>0&&Ne.trim()&&tc.every(w=>{var S;return!((S=Sy[w])!=null&&S.length)})?s.jsx("p",{className:"af-palette-empty",children:"没有匹配的节点"}):null]})})]})]}):null,_t?s.jsx(iQ,{flowParams:a,tapdId:en,setTapdId:NL,collaborationOpenRequest:fL,assistantOpenRequest:hL,snapshot:fn,loading:_L,error:CL,actionRunning:ty,actionOutput:ny,pendingConfirm:Es,conflict:ku,reviewPublishing:ry,onRefresh:()=>Ru(en),onRunDryRun:zL,onConfirmAction:BL,onRetryConflict:WL,onPublishReview:HL}):s.jsxs("main",{ref:N,className:"af-workspace-canvas",tabIndex:-1,onPointerDownCapture:w=>{EO(w),xO(w)},onLostPointerCaptureCapture:Eo,children:[s.jsx(cR,{className:"af-flow-canvas af-workspace-flow"+(hy==="pan"?" af-flow-canvas--tool-pan":" af-flow-canvas--tool-select")+(pt?" af-workspace-flow--display-mode":""),nodes:pp,edges:QL,nodeTypes:RX,onNodesChange:wO,onEdgesChange:vO,onMoveStart:bO,onMoveEnd:kO,onConnect:pt?void 0:jO,onConnectStart:pt?void 0:NO,onConnectEnd:pt?void 0:_O,isValidConnection:pt?void 0:SO,onNodeClick:(w,S)=>{var C;if(pt){V([dh(S.id)]);return}if((C=S==null?void 0:S.data)!=null&&C.isWorkspaceGroup){on("");return}if(w.detail>=3){Pl(!1),g(I=>I.map(R=>({...R,selected:R.id===S.id}))),x(I=>I.map(R=>({...R,selected:!1}))),on(S.id);return}Cr&&on(S.id)},onNodeDoubleClick:w=>{w.preventDefault()},onPaneClick:()=>{pt?V([]):on("")},onDrop:pt?void 0:MO,onDragOver:pt?void 0:$O,nodesDraggable:_e,nodesConnectable:pt?!1:_e,edgesReconnectable:pt?!1:_e,onlyRenderVisibleElements:pp.length>=80,deleteKeyCode:pt?null:_e?["Backspace","Delete"]:null,selectionOnDrag:hy==="select",panOnDrag:hy==="pan"?!0:[1,2],panActivationKeyCode:"Space",proOptions:{hideAttribution:!0},fitView:!1,minZoom:.1,maxZoom:4,children:s.jsx(dR,{color:"rgba(255,255,255,0.12)",gap:22,size:1})}),!pt&&K?(()=>{var J;const w=String(K.query||"").trim().toLowerCase(),S=K.mode==="create"?"create":"existing",C=Array.isArray(K.candidates)?K.candidates:[],I=Array.isArray(K.existingCandidates)?K.existingCandidates:[],R=w?C.filter(Y=>{var ae,he,pe;return[(ae=Y.def)==null?void 0:ae.id,Y.displayLabel,Y.description,(he=Y.slot)==null?void 0:he.name,(pe=Y.slot)==null?void 0:pe.type].filter(Boolean).some(je=>String(je).toLowerCase().includes(w))}):C,U=w?I.filter(Y=>{var ae,he;return[Y.nodeId,Y.nodeLabel,Y.definitionId,(ae=Y.slot)==null?void 0:ae.name,(he=Y.slot)==null?void 0:he.type].filter(Boolean).some(pe=>String(pe).toLowerCase().includes(w))}):I,Z=K.draft.handleType==="source"?"IN":"OUT";return s.jsxs("div",{className:"af-connect-node-menu",style:{left:K.left,top:K.top},role:"dialog","aria-label":"选择匹配节点",children:[s.jsxs("div",{className:"af-connect-node-menu__head",children:[s.jsxs("div",{className:"af-connect-node-menu__title",children:[s.jsx("span",{className:"af-connect-node-menu__dot",style:{background:Bn((J=K.draft.slot)==null?void 0:J.type)},"aria-hidden":!0}),s.jsxs("span",{children:["匹配 ",K.draft.slotType," 节点"]})]}),s.jsx("button",{type:"button",className:"af-connect-node-menu__close","aria-label":"关闭",onClick:()=>ee(null),children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-connect-node-menu__tabs",role:"tablist","aria-label":"连接方式",children:[s.jsxs("button",{type:"button",className:S==="existing"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:I.length===0,onClick:()=>ee(Y=>Y&&{...Y,mode:"existing",query:""}),children:["连接已有 ",s.jsx("span",{children:I.length})]}),s.jsxs("button",{type:"button",className:S==="create"?"af-connect-node-menu__tab af-connect-node-menu__tab--active":"af-connect-node-menu__tab",disabled:C.length===0,onClick:()=>ee(Y=>Y&&{...Y,mode:"create",query:""}),children:["新建节点 ",s.jsx("span",{children:C.length})]})]}),s.jsxs("label",{className:"af-connect-node-menu__search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",value:K.query,onChange:Y=>ee(ae=>ae&&{...ae,query:Y.target.value}),placeholder:"搜索节点",autoFocus:!0})]}),s.jsxs("div",{className:"af-connect-node-menu__list",children:[S==="create"?R.map(Y=>{var pe,je;const ae=Y.displayLabel||((pe=Y.def)==null?void 0:pe.id),he=ch(Y.slot,Y.slotIndex);return s.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>CO(Y),title:Y.description||Y.def.id,children:[s.jsxs("span",{className:"af-connect-node-menu__item-main",children:[s.jsx("span",{className:"af-connect-node-menu__item-label",children:ae}),ae!==Y.def.id?s.jsx("span",{className:"af-connect-node-menu__item-id",children:Y.def.id}):null]}),s.jsxs("span",{className:"af-connect-node-menu__port",children:[s.jsx("span",{children:Z}),s.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Bn((je=Y.slot)==null?void 0:je.type)},"aria-hidden":!0}),s.jsx("span",{className:"af-connect-node-menu__port-name",children:he})]})]},`${Y.def.id}-${Y.slotIndex}`)}):U.map(Y=>{var pe;const ae=Y.nodeLabel||Y.nodeId,he=ch(Y.slot,Y.slotIndex);return s.jsxs("button",{type:"button",className:"af-connect-node-menu__item",onClick:()=>AO(Y),title:`${Y.definitionId||Y.nodeId} · ${he}`,children:[s.jsxs("span",{className:"af-connect-node-menu__item-main",children:[s.jsx("span",{className:"af-connect-node-menu__item-label",children:ae}),s.jsxs("span",{className:"af-connect-node-menu__item-id",children:[Y.definitionId?`${Y.definitionId} · `:"",Y.nodeId]})]}),s.jsxs("span",{className:"af-connect-node-menu__port",children:[s.jsx("span",{children:Z}),s.jsx("span",{className:"af-connect-node-menu__port-dot",style:{background:Bn((pe=Y.slot)==null?void 0:pe.type)},"aria-hidden":!0}),s.jsx("span",{className:"af-connect-node-menu__port-name",children:he}),Y.occupied?s.jsx("span",{className:"af-connect-node-menu__port-badge",children:"替换"}):null]})]},`${Y.nodeId}-${Y.handleId}`)}),(S==="create"?R.length:U.length)===0?s.jsx("div",{className:"af-connect-node-menu__empty",children:"没有匹配结果"}):null]})]})})():null,!pt&&!_t&&!RL?s.jsx("div",{className:"af-workspace-composer af-bottom-composer-stack af-flow-bottom-composer",children:s.jsxs("div",{className:"af-pipeline-composer-inner",children:[s.jsx("button",{type:"button",className:"af-workspace-composer-minimize",onClick:()=>cy(!0),"aria-label":"最小化 AI 输入框",title:"最小化",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"remove"})}),s.jsx("div",{className:"af-composer-selected","aria-label":"Selected workspace nodes",children:pr.length===0?s.jsx("span",{className:"af-composer-selected-empty",children:"选择画布节点后,可作为本次 Workspace AI 的上下文。"}):pr.map(w=>{var R,U;const S=String(((R=w.data)==null?void 0:R.label)??w.id),C=(U=w.data)!=null&&U.definitionId?String(w.data.definitionId):"",I=C&&C!==S?`${S} · ${w.id} · ${C}`:`${S} · ${w.id}`;return s.jsxs("div",{className:"af-composer-node-chip",title:I,children:[s.jsx("span",{className:"af-composer-node-chip-kind",children:C||"node"}),s.jsx("span",{className:"af-composer-node-chip-label",children:S}),s.jsx("button",{type:"button",className:"af-composer-node-chip-dismiss",onClick:()=>yO(w.id),"aria-label":`取消选择 ${w.id}`,children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]},w.id)})}),s.jsxs("div",{className:"af-composer-card af-composer-card--input-only",children:[s.jsx("div",{className:"af-composer-input-wrap",children:s.jsx("textarea",{className:"af-composer-textarea",value:El,rows:2,onChange:w=>ay(w.target.value),onKeyDown:w=>{(w.metaKey||w.ctrlKey)&&w.key==="Enter"&&(w.preventDefault(),Ey())},placeholder:"描述你想在 workspace 中生成、分析或展示的内容",autoComplete:"off",spellCheck:!1,disabled:!_e})}),s.jsxs("div",{className:"af-composer-toolbar",children:[s.jsxs("div",{className:"af-composer-skills-field",children:[s.jsxs("button",{ref:oy,type:"button",className:"af-composer-skills-button"+(qs.length>0?" af-composer-skills-button--active":""),disabled:fs||!_e,"aria-haspopup":"listbox","aria-expanded":np,onClick:()=>iy(w=>!w),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"extension"}),s.jsx("span",{children:qs.length>0?`Skills ${qs.length}`:"Skills"})]}),np&&!fs?er.createPortal(s.jsx("div",{ref:US,className:"af-composer-skills-menu",role:"listbox","aria-label":"Skills",style:PL,children:Ks.length===0?s.jsx("div",{className:"af-composer-skills-empty",children:"No skills found"}):s.jsxs(s.Fragment,{children:[zl.groups.map(w=>{const S=pa(w,Ks),C=Lz(w,jy,Ks),I=IL.has(w.id);return s.jsxs("div",{className:"af-composer-skill-group af-composer-skill-group--framed"+(I?" af-composer-skill-group--collapsed":""),children:[s.jsxs("div",{className:"af-composer-skill-group-title af-composer-skill-group-title--selectable",children:[s.jsxs("label",{className:"af-composer-skill-group-check",children:[s.jsx("input",{type:"checkbox",checked:C==="all",disabled:S.length===0,onChange:R=>{const U=R.target.checked;yu(Z=>U?Mz(Z,S):$z(Z,S))}}),s.jsxs("span",{className:"af-composer-skill-group-title-main",children:[s.jsx("span",{children:w.name}),w.builtin?s.jsx("em",{children:"built-in"}):null,C==="partial"?s.jsx("em",{children:"partial"}):null]})]}),s.jsxs("button",{type:"button",className:"af-composer-skill-group-toggle","aria-label":I?`展开 ${w.name}`:`收起 ${w.name}`,onClick:()=>{qS(R=>{const U=new Set(R);return U.has(w.id)?U.delete(w.id):U.add(w.id),U})},children:[s.jsx("span",{children:w.skills.length}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:I?"expand_more":"expand_less"})]})]}),I?null:s.jsx("div",{className:"af-composer-skill-group-items",children:w.skills.map(R=>s.jsxs("label",{className:"af-composer-skill-option",children:[s.jsx("input",{type:"checkbox",checked:jy.has(R.key),onChange:U=>{const Z=U.target.checked;yu(J=>Z?J.includes(R.key)?J:[...J,R.key]:J.filter(Y=>Y!==R.key))}}),s.jsxs("span",{className:"af-composer-skill-option-main",children:[s.jsx("span",{className:"af-composer-skill-option-title",children:R.name}),R.description?s.jsx("span",{className:"af-composer-skill-option-desc",children:R.description}):null]})]},`${w.id}:${R.key}`))})]},w.id)}),zl.ungrouped.length>0?s.jsxs("div",{className:"af-composer-skill-group",children:[s.jsxs("div",{className:"af-composer-skill-group-title",children:[s.jsx("span",{children:"Ungrouped"}),s.jsx("span",{children:zl.ungrouped.length})]}),zl.ungrouped.map(w=>s.jsxs("label",{className:"af-composer-skill-option",children:[s.jsx("input",{type:"checkbox",checked:jy.has(w.key),onChange:S=>{const C=S.target.checked;yu(I=>C?I.includes(w.key)?I:[...I,w.key]:I.filter(R=>R!==w.key))}}),s.jsxs("span",{className:"af-composer-skill-option-main",children:[s.jsx("span",{className:"af-composer-skill-option-title",children:w.name}),w.description?s.jsx("span",{className:"af-composer-skill-option-desc",children:w.description}):null]})]},`ungrouped:${w.key}`))]}):null]})}),document.body):null]}),s.jsx("label",{className:"af-composer-model-field",children:s.jsxs("select",{className:"af-composer-model-select",value:Ki,onChange:w=>kL(w.target.value),"aria-label":"模型",children:[s.jsx("option",{value:"",children:"默认模型"}),nO.map(w=>s.jsx("option",{value:w.value,children:w.label},w.value))]})}),s.jsx("button",{type:"button",className:"af-composer-send"+(El.trim()&&!fs?" af-composer-send--active":"")+(fs?" af-composer-send--stop":""),disabled:fs||!El.trim()||!_e,"aria-label":fs?"Running":"Send",onClick:()=>void Ey(),children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:fs?"sync":"arrow_upward"})})]})]})]})}):!pt&&!_t?s.jsx("button",{type:"button",className:"af-workspace-composer-fab",onClick:()=>cy(!1),"aria-label":"展开 AI 输入框",title:"展开 AI 输入框",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"})}):null]}),!pt&&!_t&&ju?s.jsx("aside",{className:"af-pipeline-drawer af-pipeline-drawer--wide af-workspace-composer-drawer","aria-label":"Workspace AI Composer",children:s.jsxs("div",{className:"af-composer-sidebar",children:[s.jsxs("div",{className:"af-pipeline-drawer-head",children:[s.jsx("h2",{className:"af-pipeline-drawer-title",children:"AI Composer"}),s.jsx("button",{type:"button",className:"af-pipeline-drawer-close af-icon-btn",onClick:()=>Pl(!1),"aria-label":"关闭 AI 对话侧栏",children:s.jsx("span",{className:"material-symbols-outlined",children:"close"})})]}),s.jsxs("div",{className:"af-composer-session-tabs",children:[s.jsx("button",{type:"button",className:"af-composer-session-tab"+(Qr==="workspace"?" af-composer-session-tab--active":""),ref:Qr==="workspace"?ly:null,onClick:()=>Is("workspace"),children:s.jsx("span",{className:"af-composer-session-label",children:"Workspace"})}),Us.map(w=>s.jsxs("div",{role:"tab",tabIndex:0,ref:Qr===w.id?ly:null,className:"af-composer-session-tab"+(Qr===w.id?" af-composer-session-tab--active":"")+(w.status==="running"||w.status==="stopping"?" af-composer-session-tab--running":""),onClick:()=>Is(w.id),onKeyDown:S=>{(S.key==="Enter"||S.key===" ")&&(S.preventDefault(),Is(w.id))},title:w.runNodeId||w.label,children:[s.jsx("span",{className:"af-composer-session-label",children:w.label}),s.jsx("button",{type:"button",className:"af-composer-session-close",onClick:S=>{S.preventDefault(),S.stopPropagation(),KL(w.id)},"aria-label":`关闭 ${w.label}`,title:"关闭 tab",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]},w.id))]}),s.jsx("div",{className:"af-composer-sidebar-status"+(Wu?" af-composer-sidebar-status--running":""),role:"status","aria-live":"polite",children:r0}),s.jsxs("div",{className:"af-composer-sidebar-thread",ref:JS,children:[s.jsx(AC,{messages:zO,running:Wu,showRunningIndicator:!xr}),s.jsx(AC,{messages:n0,running:Wu,showRunningIndicator:!1,technical:!0})]}),s.jsx(MG,{value:El,onChange:ay,onSend:()=>void Ey(),placeholder:xr?"继续追问、总结或要求调整这次结果":"继续描述你想让 AI 在 Workspace 中做什么",disabled:!_e,busy:Wu})]})}):!pt&&!_t&&wt&&Jt?s.jsx("aside",{className:"af-pipeline-drawer af-workspace-node-drawer","aria-label":"Workspace Node Properties",children:s.jsx(YG,{draft:wt,setDraft:As,definitionId:String(((i0=Jt.data)==null?void 0:i0.definitionId)||Jt.id),systemPromptReadonly:String(((o0=Jt.data)==null?void 0:o0.description)||""),modelLists:_a,disabled:!_e,onIdBlur:()=>by(!0),onClose:()=>on(""),onPublishToMarketplace:VL,error:oL,ioSlots:{inputs:Array.isArray(wt==null?void 0:wt.inputs)?wt.inputs:[],outputs:Array.isArray(wt==null?void 0:wt.outputs)?wt.outputs:[]}})}):null,!pt&&!_t&&Nu?er.createPortal(s.jsx("div",{className:"af-workspace-run-logs-overlay",role:"presentation",onMouseDown:()=>Tl(null),children:s.jsx("aside",{className:"af-workspace-run-logs-drawer","aria-label":"Workspace Run Logs",onMouseDown:w=>w.stopPropagation(),children:s.jsx(PG,{flowParams:a,scheduleNodeId:Nu.scheduleNodeId,runNodeId:Nu.runNodeId,lastRunId:Nu.lastRunId,label:Nu.label,onClose:()=>Tl(null)})})}),document.body):null,s.jsx(CG,{open:fy,onClose:()=>sp(!1)}),s.jsx(EG,{open:py,onClose:()=>ej(!1),onJump:vy,nodes:ZL}),s.jsx(JG,{open:d,onClose:()=>m(!1),flowId:a.flowId||"",flowSource:Iu,onArchived:()=>{m(!1),n("/projects?tab=archived")}}),s.jsx(XG,{open:y&&!!a.flowId,onClose:()=>v(!1),flowId:a.flowId||"",flowSource:Iu,flowArchived:!!a.archived,workspaceId:a.workspaceId||"",leaveShared:Pu,onDeleted:async()=>{v(!1),n("/projects")}}),AL&&_t?er.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal af-workflow-project-modal",role:"dialog","aria-modal":"true","aria-label":"迭代绑定的 Projects",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"hub"}),"迭代绑定的 Projects"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Qf(!1),"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsx("p",{className:"af-workflow-project-modal__lead",children:"Workspace 和 Display 属于 Project。只有主动绑定后,全局迭代才能进入对应的 Project 视图。"}),BS?s.jsx("p",{className:"af-workflow-project-modal__error",children:BS}):null,s.jsxs("section",{className:"af-workflow-project-modal__section",children:[s.jsxs("div",{className:"af-workflow-project-modal__section-head",children:[s.jsx("strong",{children:"已绑定"}),s.jsx("span",{children:yi.length})]}),yi.length?s.jsx("div",{className:"af-workflow-project-modal__list",children:yi.map(w=>s.jsxs("article",{className:"af-workflow-project-modal__item",children:[s.jsxs("div",{children:[s.jsx("strong",{children:w.label||w.flowId}),s.jsx("small",{children:w.description||`${w.flowSource||"user"} · ${w.role||"member"}`})]}),s.jsxs("div",{className:"af-workflow-project-modal__actions",children:[s.jsx("button",{type:"button",onClick:()=>zu(w,"workspace"),children:"Workspace"}),s.jsx("button",{type:"button",onClick:()=>zu(w,"display"),children:"Display"}),w.canManage?s.jsx("button",{type:"button",className:"af-workflow-project-modal__unbind",disabled:_o,onClick:()=>void FL(w),children:"解绑"}):null]})]},w.workspaceId))}):s.jsx("p",{className:"af-display-link-modal__empty",children:"当前迭代尚未绑定 Project。"})]}),s.jsxs("section",{className:"af-workflow-project-modal__section",children:[s.jsxs("div",{className:"af-workflow-project-modal__section-head",children:[s.jsx("strong",{children:"绑定 Project"}),s.jsx("span",{children:"Owner / Editor"})]}),Xf.length?s.jsxs("div",{className:"af-workflow-project-modal__bind-row",children:[s.jsx("select",{value:ep,disabled:_o,onChange:w=>tp(w.target.value),"aria-label":"选择要绑定的 Project",children:Xf.map(w=>s.jsx("option",{value:Bo(w),children:w.label||w.flowId},Bo(w)))}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:_o||!ep,onClick:()=>void DL(),children:_o?"处理中…":"确认绑定"})]}):s.jsx("p",{className:"af-display-link-modal__empty",children:"没有你可编辑且尚未绑定的 Project。"})]})]}),s.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Qf(!1),children:"关闭"}),yi.length===1?s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>zu(yi[0],WS),children:WS==="display"?"进入 Display":"进入 Workspace"}):null]})]})}),document.body):null,gL&&On?er.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal af-workspace-conflict-modal",role:"dialog","aria-modal":"true","aria-label":"解决 Workspace 冲突",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"difference"}),"解决 ",((a0=On.conflictItems)==null?void 0:a0.length)||0," 处字段冲突"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Na(!1),"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("div",{className:"af-workspace-conflict-summary",children:["未冲突的改动已经自动合并。这里只需要决定双方同时修改的字段。",s.jsxs("div",{className:"af-workspace-conflict-bulk",children:[s.jsx("button",{type:"button",onClick:()=>jl(Object.fromEntries((On.conflictItems||[]).map((w,S)=>[String(S),{mode:"local",manual:rd(w)}]))),children:"全部保留我的"}),s.jsx("button",{type:"button",onClick:()=>jl(Object.fromEntries((On.conflictItems||[]).map((w,S)=>[String(S),{mode:"remote",manual:rd(w)}]))),children:"全部使用远端"})]})]}),(On.conflictItems||[]).map((w,S)=>{const C=Gg[String(S)]||{mode:"local",manual:rd(w)};return s.jsxs("section",{className:"af-workspace-conflict-item",children:[s.jsx("code",{className:"af-workspace-conflict-path",children:w.path}),s.jsx("div",{className:"af-workspace-conflict-options",children:[["local","保留我的"],["remote","使用远端"],["manual","手动编辑"]].map(([I,R])=>s.jsx("button",{type:"button",className:C.mode===I?"is-active":"",onClick:()=>jl(U=>({...U,[String(S)]:{...C,mode:I}})),children:R},I))}),s.jsxs("div",{className:"af-workspace-conflict-values",children:[s.jsxs("div",{className:C.mode==="local"?"is-selected":"",children:[s.jsx("span",{children:"我的修改"}),s.jsx("pre",{children:OC(w,"incoming")})]}),s.jsxs("div",{className:C.mode==="remote"?"is-selected":"",children:[s.jsx("span",{children:"远端修改"}),s.jsx("pre",{children:OC(w,"current")})]})]}),C.mode==="manual"?s.jsxs("label",{className:"af-workspace-conflict-manual",children:[s.jsx("span",{children:"最终值(JSON)"}),s.jsx("textarea",{value:C.manual,onChange:I=>jl(R=>({...R,[String(S)]:{...C,manual:I.target.value}})),rows:5})]}):null]},`${w.path||"conflict"}-${S}`)}),jS?s.jsx("div",{className:"af-flow-snippet-error",children:jS}):null]}),s.jsxs("div",{className:"af-flow-snippet-modal__foot af-workspace-conflict-foot",children:[s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:Jf,onClick:()=>void Qj(),children:"备份并载入远端"}),s.jsx("span",{className:"af-workspace-conflict-foot__spacer"}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",disabled:Jf,onClick:()=>Na(!1),children:"稍后处理"}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:Jf||!(On.conflictItems||[]).length,onClick:()=>void cO(),children:Jf?"保存中...":"应用选择并保存"})]})]})}),document.body):null,Yn?er.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal",role:"dialog","aria-modal":"true","aria-label":"发布流程片段",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"ios_share"}),"发布流程片段"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>gr(!1),"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("label",{className:"af-flow-snippet-field",children:[s.jsx("span",{children:"名称"}),s.jsx("input",{type:"text",value:yn.name,onChange:w=>{const S=w.target.value;Pn(C=>({...C,name:S,id:C.id?C.id:S.toLowerCase().replace(/[^a-z0-9_-]+/g,"-").replace(/^-+|-+$/g,"")}))},placeholder:"例如:内容整理片段",autoFocus:!0})]}),s.jsxs("label",{className:"af-flow-snippet-field",children:[s.jsx("span",{children:"ID"}),s.jsx("input",{type:"text",value:yn.id,onChange:w=>Pn(S=>({...S,id:w.target.value})),placeholder:"content-cleanup-snippet"})]}),s.jsxs("label",{className:"af-flow-snippet-field",children:[s.jsx("span",{children:"说明"}),s.jsx("textarea",{value:yn.description,onChange:w=>Pn(S=>({...S,description:w.target.value})),placeholder:"这段流程适合什么 workspace 场景、需要接哪些上下游。",rows:4})]}),s.jsxs("div",{className:"af-flow-snippet-summary",children:["将发布 ",pr.length," 个节点和 ",mp.length," 条内部连线。"]}),Sn?s.jsx("div",{className:"af-flow-snippet-error",children:Sn}):null]}),s.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>gr(!1),children:"取消"}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:nr||!yn.name.trim(),onClick:()=>void oO(),children:nr?"发布中...":"发布"})]})]})}),document.body):null,Fj?s.jsx(kX,{node:Fj,onClose:()=>G("")}):null,dr?er.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal",role:"dialog","aria-modal":"true","aria-label":Io?"新建分享":"发布展示页",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"present_to_all"}),Io?"新建分享":"发布展示页"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>fr(!1),"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("label",{className:"af-flow-snippet-field",children:[s.jsx("span",{children:"标题"}),s.jsx("input",{type:"text",value:Nt.title,onChange:w=>jn(S=>({...S,title:w.target.value})),placeholder:"展示页标题",autoFocus:!0})]}),Io?null:s.jsxs("label",{className:"af-flow-snippet-field",children:[s.jsx("span",{children:"布局"}),s.jsxs("select",{className:"af-display-share-select",value:Nt.layout,onChange:w=>jn(S=>({...S,layout:w.target.value})),children:[s.jsx("option",{value:"gallery",children:"Gallery"}),s.jsx("option",{value:"document",children:"Document"}),s.jsx("option",{value:"slides",children:"Slides"})]})]}),s.jsxs("label",{className:"af-flow-snippet-field",children:[s.jsx("span",{children:"有效期"}),s.jsx("select",{className:"af-display-share-select",value:vC(Nt),onChange:w=>{const S=w.target.value;jn(C=>({...C,permanent:S==="permanent",expiresInDays:S==="permanent"?C.expiresInDays||30:Number(S)}))},children:Ww.map(w=>s.jsx("option",{value:w.value,children:w.label},w.value))})]}),s.jsxs("div",{className:"af-display-share-node-list",role:"group","aria-label":Io?"分享内容":"选择展示节点",children:[Io?s.jsx("span",{className:"af-display-share-node-list__label",children:"分享内容"}):null,WO.map(w=>{var C;const S=Array.isArray(Nt.nodeIds)&&Nt.nodeIds.includes(w.id);return s.jsxs("label",{className:"af-display-share-node-row",children:[s.jsx("input",{type:"checkbox",checked:S,disabled:Io,onChange:()=>uO(w.id)}),s.jsxs("span",{className:"af-display-share-node-row__main",children:[s.jsx("strong",{children:((C=w.data)==null?void 0:C.label)||w.id}),s.jsxs("small",{children:[Fn(w.data)," · ",w.id]})]})]},w.id)})]}),ct!=null&&ct.absoluteUrl?s.jsxs("div",{className:"af-display-share-result",children:[s.jsx("input",{type:"text",readOnly:!0,value:ct.absoluteUrl,onFocus:w=>w.target.select()}),s.jsx("button",{type:"button",onClick:()=>window.open(ct.absoluteUrl,"_blank","noopener,noreferrer"),children:"打开"}),s.jsx("button",{type:"button",onClick:()=>void Zj(),children:Ae==="copied"?"已复制":Ae==="failed"?"复制失败":"复制"})]}):null,yr?s.jsx("div",{className:"af-flow-snippet-error",children:yr}):null]}),s.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>fr(!1),children:"取消"}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:qn||!Array.isArray(Nt.nodeIds)||Nt.nodeIds.length===0,onClick:()=>void fO(),children:qn?"生成中...":"生成链接"})]})]})}),document.body):null,ye?er.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal af-display-link-modal",role:"dialog","aria-modal":"true","aria-label":"展示链接",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"link"}),"展示链接"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>{ut(""),Me(!1)},"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[ct!=null&&ct.absoluteUrl?s.jsxs("div",{className:"af-display-link-modal__url",children:[s.jsx("input",{type:"text",readOnly:!0,value:ct.absoluteUrl,onFocus:w=>w.target.select(),autoFocus:!0}),s.jsxs("button",{type:"button",onClick:()=>window.open(ct.absoluteUrl,"_blank","noopener,noreferrer"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),s.jsxs("button",{type:"button",onClick:()=>void Zj(),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:Ae==="copied"?"check":"content_copy"}),Ae==="copied"?"已复制":Ae==="failed"?"复制失败":"复制"]})]}):s.jsx("div",{className:"af-display-link-modal__empty",children:"还没有生成展示链接"}),s.jsxs("label",{className:"af-flow-snippet-field",children:[s.jsx("span",{children:"新链接有效期"}),s.jsx("select",{className:"af-display-share-select",value:vC(Nt),onChange:w=>{const S=w.target.value;jn(C=>({...C,permanent:S==="permanent",expiresInDays:S==="permanent"?C.expiresInDays||30:Number(S)}))},children:Ww.map(w=>s.jsx("option",{value:w.value,children:w.label},w.value))})]}),yr?s.jsx("div",{className:"af-flow-snippet-error",children:yr}):null]}),s.jsxs("div",{className:"af-flow-snippet-modal__foot",children:[s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>{ut(""),Me(!1)},children:"关闭"}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",disabled:qn||P.nodeIds.length===0,onClick:()=>void pO(),children:qn?"生成中...":ct!=null&&ct.absoluteUrl?"更新链接":"生成链接"})]})]})}),document.body):null,uL?er.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal af-display-share-modal",role:"dialog","aria-modal":"true","aria-label":"项目协作",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"group_add"}),"项目协作"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Kg(!1),"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("div",{className:"af-workspace-team-share",children:[s.jsxs("div",{className:"af-workspace-team-share__head",children:[s.jsx("strong",{children:"分享到团队"}),s.jsx("span",{children:Vs?Vs.name:"尚未加入团队"})]}),Vs?s.jsxs("div",{className:"af-workspace-team-share__actions",children:[s.jsxs("select",{value:Ug,onChange:w=>kS(w.target.value),"aria-label":"团队权限",children:[s.jsx("option",{value:"viewer",children:"只读"}),s.jsx("option",{value:"editor",children:"可编辑和运行"})]}),(l0=Ft==null?void 0:Ft.teamShares)!=null&&l0.some(w=>w.teamId===Vs.id)?s.jsxs(s.Fragment,{children:[s.jsx("button",{type:"button",disabled:hu,onClick:()=>void Ay(!1),children:hu?"处理中...":"更新权限"}),s.jsx("button",{type:"button",disabled:hu,onClick:()=>void Ay(!0),children:"取消分享"})]}):s.jsx("button",{type:"button",disabled:hu,onClick:()=>void Ay(!1),children:hu?"分享中...":"分享到团队"})]}):s.jsx("p",{className:"af-display-link-modal__empty",children:"联系超级管理员将你加入团队后,即可在这里分享。"})]}),s.jsx("p",{className:"af-display-link-modal__empty",children:"输入已注册用户名。添加后,这个 Workspace 会直接出现在对方的项目列表中。"}),s.jsxs("div",{className:"af-workspace-member-add",children:[s.jsx("input",{type:"text",value:pu,onChange:w=>wS(w.target.value),onKeyDown:w=>{w.key==="Enter"&&pu.trim()&&!qg&&(w.preventDefault(),Xj())},placeholder:"输入用户名",autoFocus:!0}),s.jsx("button",{type:"button",disabled:qg||!pu.trim(),onClick:()=>void Xj(),children:qg?"添加中...":"添加成员"})]}),yS?s.jsx("div",{className:"af-flow-snippet-error",children:yS}):null,s.jsx("div",{className:"af-workspace-member-list",children:((Ft==null?void 0:Ft.members)||[]).map(w=>{const S=w.userId===(Ft==null?void 0:Ft.ownerId)||w.role==="owner";return s.jsxs("div",{className:"af-workspace-member-row",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:S?"shield_person":"person"}),s.jsxs("div",{children:[s.jsx("strong",{children:w.username||w.userId}),s.jsx("small",{children:S?"所有者":w.role==="viewer"?"只读成员":"编辑成员"})]}),S?null:s.jsx("button",{type:"button",disabled:xS===w.userId,onClick:()=>void lO(w),children:xS===w.userId?"移除中...":"取消分享"})]},w.userId)})})]}),s.jsx("div",{className:"af-flow-snippet-modal__foot",children:s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn",onClick:()=>Kg(!1),children:"完成"})})]})}),document.body):null,Pt?er.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal af-display-shares-modal",role:"dialog","aria-modal":"true","aria-label":"我的分享",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"folder_shared"}),"我的分享"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>Nn(!1),"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("div",{className:"af-display-shares-toolbar",children:[s.jsx("span",{children:Je.length?`${Je.length} 个分享`:"暂无分享"}),s.jsxs("button",{type:"button",onClick:()=>void Xs(),disabled:rr,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),"刷新"]})]}),Tr?s.jsx("div",{className:"af-flow-snippet-error",children:Tr}):null,rr?s.jsx("div",{className:"af-display-link-modal__empty",children:"Loading..."}):null,!rr&&Je.length===0?s.jsx("div",{className:"af-display-link-modal__empty",children:"还没有创建过展示分享"}):null,s.jsx("div",{className:"af-display-shares-list",children:Je.map(w=>{const S=jC(w),C=ve===w.id,I=w.expiresAt?String(w.expiresInDays||30):"permanent";return s.jsxs("article",{className:"af-display-share-item",children:[s.jsxs("div",{className:"af-display-share-item__main",children:[s.jsx("strong",{children:w.title||"AgentFlow Display"}),s.jsxs("span",{children:[w.flowId||"-"," · ",w.layout||"gallery"," · ",Array.isArray(w.nodeIds)?w.nodeIds.length:0," nodes"]}),s.jsx("small",{children:nX(w)})]}),s.jsx("input",{className:"af-display-share-item__url",type:"text",readOnly:!0,value:S,onFocus:R=>R.target.select()}),s.jsx("select",{className:"af-display-share-select",value:I,disabled:C,onChange:R=>void mO(w,R.target.value),"aria-label":"修改分享有效期",children:Ww.map(R=>s.jsx("option",{value:R.value,children:R.label},R.value))}),s.jsxs("div",{className:"af-display-share-item__actions",children:[s.jsxs("button",{type:"button",onClick:()=>window.open(S,"_blank","noopener,noreferrer"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),"打开"]}),s.jsxs("button",{type:"button",onClick:()=>void hO(w),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:St===w.id?"check":"content_copy"}),St===w.id?"已复制":"复制"]}),s.jsxs("button",{type:"button",className:"af-display-share-item__danger",disabled:C,onClick:()=>void gO(w),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:C?"hourglass_empty":"link_off"}),"撤销"]})]})]},w.id)})})]})]})}),document.body):null,sn?er.createPortal(s.jsx("div",{className:"af-flow-snippet-modal-overlay",children:s.jsxs("div",{className:"af-flow-snippet-modal af-display-picker-modal",role:"dialog","aria-modal":"true","aria-label":"选择展示节点",children:[s.jsxs("div",{className:"af-flow-snippet-modal__head",children:[s.jsxs("span",{className:"af-flow-snippet-modal__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_to_photos"}),"选择展示节点"]}),s.jsx("button",{type:"button",className:"af-flow-snippet-modal__close",onClick:()=>_n(!1),"aria-label":"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]}),s.jsxs("div",{className:"af-flow-snippet-modal__body",children:[s.jsxs("label",{className:"af-display-picker-search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{type:"search",value:Xn,onChange:w=>_s(w.target.value),placeholder:"搜索展示节点...",autoFocus:!0})]}),s.jsx("div",{className:"af-display-picker-grid",role:"group","aria-label":"选择展示节点",style:{"--af-display-picker-columns":Gj.length||1},children:gp.length>0?Gj.map((w,S)=>s.jsx("div",{className:"af-display-picker-column",children:w.map(sO)},`display-picker-column-${S}`)):s.jsx("div",{className:"af-display-picker-empty",children:Dl.length===0?"当前 Workspace 没有 display 节点":"没有匹配的展示节点"})})]}),s.jsx("div",{className:"af-flow-snippet-modal__foot",children:s.jsx("button",{type:"button",className:"af-flow-snippet-modal__btn af-flow-snippet-modal__btn--primary",onClick:()=>_n(!1),children:"完成"})})]})}),document.body):null,gu.nodeId?er.createPortal(s.jsx(zX,{files:vl,query:gu.query,onQueryChange:w=>Qg(S=>({...S,query:w})),onSelect:GL,onUpload:Ij,onClose:wy}),document.body):null,!pt&&!_t&&we?er.createPortal(s.jsx("div",{className:"af-workspace-quick-add-backdrop",onMouseDown:()=>$e(!1),children:s.jsxs("div",{className:"af-workspace-quick-add",role:"dialog","aria-modal":"true","aria-label":"Add workspace node",onMouseDown:w=>w.stopPropagation(),children:[s.jsxs("div",{className:"af-workspace-quick-add__tabs",role:"tablist","aria-label":"选择添加类型",children:[s.jsx("button",{type:"button",role:"tab","aria-selected":Ie==="nodes",className:"af-workspace-quick-add__tab"+(Ie==="nodes"?" af-workspace-quick-add__tab--active":""),onClick:()=>nt("nodes"),children:"节点"}),s.jsx("button",{type:"button",role:"tab","aria-selected":Ie==="flows",className:"af-workspace-quick-add__tab"+(Ie==="flows"?" af-workspace-quick-add__tab--active":""),onClick:()=>nt("flows"),children:"流程"})]}),s.jsxs("div",{className:"af-workspace-quick-add__search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{ref:GS,value:Tn,onChange:w=>Wt(w.target.value),onKeyDown:w=>{if(w.key==="Escape")w.preventDefault(),$e(!1);else if(w.key==="ArrowDown"){w.preventDefault();const S=Ie==="flows"?Du.length:Ou.length;wr(C=>Math.min(Math.max(0,S-1),C+1))}else w.key==="ArrowUp"?(w.preventDefault(),wr(S=>Math.max(0,S-1))):w.key==="Tab"?(w.preventDefault(),nt(S=>S==="nodes"?"flows":"nodes")):w.key==="Enter"&&(w.preventDefault(),Ie==="flows"?t0(Du[Ln]||Du[0]):e0(Ou[Ln]||Ou[0]))},placeholder:Ie==="flows"?"搜索流程片段...":"搜索节点...","aria-label":Ie==="flows"?"搜索流程片段":"搜索节点"})]}),s.jsx("div",{className:"af-workspace-quick-add__list",children:Ie==="flows"?Du.length===0?s.jsx("div",{className:"af-workspace-quick-add__empty",children:$n?"正在加载流程片段...":rn||"没有匹配的流程片段"}):Du.map((w,S)=>{const C=w.displayName||w.name||w.id,I=w.snippet&&typeof w.snippet=="object"?w.snippet.instances:null,R=w.snippet&&typeof w.snippet=="object"?w.snippet.edges:null,U=Number.isFinite(Number(w.nodeCount))?Number(w.nodeCount):Object.keys(I||{}).length,Z=Number.isFinite(Number(w.edgeCount))?Number(w.edgeCount):Array.isArray(R)?R.length:0;return s.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(S===Ln?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>wr(S),onClick:()=>t0(w),children:[s.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:"schema"}),s.jsxs("span",{className:"af-workspace-quick-add__main",children:[s.jsx("span",{className:"af-workspace-quick-add__label",children:C}),s.jsxs("span",{className:"af-workspace-quick-add__meta",children:[w.id,w.version?` · v${w.version}`:""]}),s.jsx("span",{className:"af-workspace-quick-add__desc",children:w.description||`${U} 节点 / ${Z} 连线`})]}),s.jsx("span",{className:"af-workspace-quick-add__cat",children:"FLOW"})]},`${w.id}@${w.version}`)}):Ou.length===0?s.jsx("div",{className:"af-workspace-quick-add__empty",children:"没有匹配的节点"}):Ou.map((w,S)=>{const C=hd(w),I=md(w),R=Kb(w);return s.jsxs("button",{type:"button",className:"af-workspace-quick-add__item"+(S===Ln?" af-workspace-quick-add__item--active":""),onMouseEnter:()=>wr(S),onClick:()=>e0(w),children:[s.jsx("span",{className:"af-workspace-quick-add__icon material-symbols-outlined","aria-hidden":!0,children:mC(C)}),s.jsxs("span",{className:"af-workspace-quick-add__main",children:[s.jsx("span",{className:"af-workspace-quick-add__label",children:I}),s.jsx("span",{className:"af-workspace-quick-add__meta",children:w.id}),R?s.jsx("span",{className:"af-workspace-quick-add__desc",children:R}):null]}),s.jsx("span",{className:"af-workspace-quick-add__cat",children:C})]},w.id)})})]})}),document.body):null]})]})}function u$(){return s.jsx(bv,{children:s.jsx(aQ,{})})}function lQ(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)??""),i=a=>r(a).trim(),o=t.find(a=>(a==null?void 0:a.name)===n&&i(a))||t.find(a=>(a==null?void 0:a.name)==="filePath"&&i(a))||t.find(a=>(a==null?void 0:a.type)==="text"&&i(a));return String((e==null?void 0:e.body)||(o?r(o):""))}function cQ(e){return e==="mermaid"?"account_tree":e==="ascii"?"notes":e==="html"?"html":e==="react"?"deployed_code":e==="image"?"image":e==="chart"?"bar_chart":e==="table"?"table":"article"}function uQ(e){let t=String(e||"").replace(/\r\n/g,`
|
|
266
|
+
`).trim();return t.includes(`
|
|
267
|
+
`)||(t=t.replace(/\s+(resultFile|result|outParams|outParams\.[A-Za-z_][A-Za-z0-9_-]*)\s*:/g,`
|
|
268
|
+
$1:`).replace(/(^|\n)outParams:\s+([A-Za-z_][A-Za-z0-9_-]*\s*:)/g,`$1outParams:
|
|
269
|
+
$2`)),t}function d$(e){const t=String(e||"").trim();if(!t)return String(e||"");const n=t.match(/---agentflow\b([\s\S]*?)---end/i);if(n!=null&&n[1]){const a=uQ(n[1]),l=a.match(/^resultFile\s*:\s*["']?([^"'\n]+)["']?/m);if(l!=null&&l[1])return l[1].trim();const c=a.match(/^result\s*:\s*(.*)$/m);if(c){const f=String(c[1]||"").trim();return f==="|"||f===">"?a.slice((c.index||0)+c[0].length).split(`
|
|
270
|
+
`).filter(d=>/^\s+/.test(d)||!d.trim()).map(d=>d.replace(/^\s{2}/,"")).join(`
|
|
271
|
+
`).replace(/\s+$/g,""):f.replace(/^["']|["']$/g,"")}const u=t.replace(n[0],"").trim();if(u)return u}if(!/["']result["']\s*:|["']outParams["']\s*:|["']resultFile["']\s*:/i.test(t))return String(e||"");const r=[t],i=t.indexOf("{"),o=t.lastIndexOf("}");i>=0&&o>i&&r.unshift(t.slice(i,o+1));for(const a of r)try{const l=JSON.parse(a);if(l&&typeof l=="object"&&!Array.isArray(l)&&(Object.prototype.hasOwnProperty.call(l,"result")||Object.prototype.hasOwnProperty.call(l,"resultFile"))){const c=l.resultFile||l.result;return typeof c=="string"?c:JSON.stringify(c,null,2)}}catch{}return String(e||"")}function Qv(e){let t=d$(e).trim();if(!t)return"";const n=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*?)```/);if(n&&n[1])t=n[1].trim();else{const o=t.match(/```(?:html|HTML)?\s*\n?([\s\S]*)$/);o&&o[1]&&(t=o[1].trim())}t=t.replace(/^html\s*\n/i,"").replace(/```\s*$/g,"").trim();const i=[/<!doctype\b/i,/<html\b/i,/<head\b/i,/<body\b/i,/<style\b/i,/<script\b/i,/<main\b/i,/<section\b/i,/<article\b/i,/<div\b/i,/<svg\b/i,/<canvas\b/i].reduce((o,a)=>{const l=a.exec(t);return l?o<0?l.index:Math.min(o,l.index):o},-1);return i>0&&(t=t.slice(i).trim()),t}function dQ(e){const t=Qv(e);return t.trim()?/<[^>]*$/g.test(t)?"HTML 内容末尾存在未闭合标签,可能是生成或保存时被截断。":/^(?:<!doctype\b|<html\b)/i.test(t)&&!/<\/html\s*>/i.test(t)?"完整 HTML 文档缺少 </html> 结束标签,可能是生成或保存时被截断。":"":""}function fQ(e){const t=Qv(e);if(!t.trim())return"";const n=`<base target="_blank"><script data-agentflow-display-link-guard="1">
|
|
272
|
+
(() => {
|
|
273
|
+
document.addEventListener("click", (event) => {
|
|
274
|
+
const link = event.target && event.target.closest ? event.target.closest("a[href]") : null;
|
|
275
|
+
if (!link) return;
|
|
276
|
+
const rawHref = String(link.getAttribute("href") || "").trim();
|
|
277
|
+
if (!rawHref || rawHref.startsWith("#")) return;
|
|
278
|
+
if (/^javascript:/i.test(rawHref)) {
|
|
279
|
+
event.preventDefault();
|
|
280
|
+
return;
|
|
281
|
+
}
|
|
282
|
+
event.preventDefault();
|
|
283
|
+
window.open(link.href, "_blank", "noopener,noreferrer");
|
|
284
|
+
}, true);
|
|
285
|
+
})();
|
|
286
|
+
<\/script>`;return/data-agentflow-display-link-guard=["']1["']/i.test(t)?t:/<head\b[^>]*>/i.test(t)?t.replace(/<head\b([^>]*)>/i,`<head$1>${n}`):/<html\b[^>]*>/i.test(t)?t.replace(/<html\b([^>]*)>/i,`<html$1><head>${n}</head>`):`<!doctype html><html><head>${n}</head><body>${t}</body></html>`}function f$(e,t,n={}){const r=String(e||"").trim();if(!r)return"";if(/^(?:https?:|data:|blob:|file:)/i.test(r)||r.startsWith("/"))return r;const i=new URLSearchParams;return i.set("id",t),i.set("path",r),n.download&&i.set("download","1"),`/api/display/file/raw?${i.toString()}`}function pQ(e,t,n={}){const r=String(e||"").trim();return r?f$(r,t,n):""}function hQ({className:e="",children:t}){const n=h.useRef(null),r=h.useRef(null),[i,o]=h.useState({visible:!1,top:0,height:100}),a=h.useCallback(()=>{const f=n.current;if(!f)return;const p=Math.max(1,f.scrollHeight),d=Math.max(1,f.clientHeight),m=p>d+1,y=m?Math.max(12,d/p*100):100,v=Math.max(0,100-y),b=m?Math.min(v,f.scrollTop/Math.max(1,p-d)*v):0;o({visible:m,top:b,height:y})},[]);h.useEffect(()=>{const f=requestAnimationFrame(a),p=n.current;if(!p||typeof ResizeObserver>"u")return()=>cancelAnimationFrame(f);const d=new ResizeObserver(a);d.observe(p);for(const m of Array.from(p.children))d.observe(m);return()=>{cancelAnimationFrame(f),d.disconnect()}},[t,a]);const l=h.useCallback(f=>{const p=n.current;if(!p)return;const d=Math.max(0,p.scrollHeight-p.clientHeight);p.scrollTop=Math.min(1,Math.max(0,f))*d,a()},[a]),c=h.useCallback((f,p=0)=>{const d=r.current;if(!d)return 0;const m=d.getBoundingClientRect(),y=i.height/100*m.height,v=Math.max(1,m.height-y);return(f-m.top-p)/v},[i.height]),u=h.useCallback(f=>{if(!i.visible)return;f.preventDefault(),f.stopPropagation();const p=r.current;if(!p)return;const d=p.getBoundingClientRect(),m=i.top/100*d.height,y=i.height/100*d.height,b=f.clientY>=d.top+m&&f.clientY<=d.top+m+y?f.clientY-d.top-m:y/2;l(c(f.clientY,b));const g=x=>{x.preventDefault(),l(c(x.clientY,b))},k=()=>{window.removeEventListener("pointermove",g),window.removeEventListener("pointerup",k),window.removeEventListener("pointercancel",k)};window.addEventListener("pointermove",g),window.addEventListener("pointerup",k),window.addEventListener("pointercancel",k)},[c,l,i.height,i.top,i.visible]);return s.jsxs("div",{className:`af-public-display-node__body ${e} nowheel nopan nodrag`,children:[s.jsx("div",{ref:n,className:`af-public-display-node__scroller ${e} nowheel nopan nodrag`,onScroll:a,children:t}),s.jsx("div",{ref:r,className:"af-public-display-scrollbar"+(i.visible?" af-public-display-scrollbar--visible":""),onPointerDown:u,"aria-hidden":"true",children:s.jsx("span",{style:{height:`${i.height}%`,top:`${i.top}%`}})})]})}function Xb({node:e,shareId:t,style:n,bare:r=!1}){const i=lQ(e),o=e.kind==="html"?Qv(i):e.kind==="react"?Lg(i):d$(i),a=e.kind==="html"?dQ(o):"",l=`af-public-display-node__body--${e.kind||"unknown"}`;return s.jsxs("section",{className:`af-public-display-node af-public-display-node--${e.kind||"unknown"}${r?" af-public-display-node--bare":""}`,style:n,children:[r?null:s.jsx("div",{className:"af-public-display-node__head",children:s.jsxs("div",{className:"af-public-display-node__title",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:cQ(e.kind)}),s.jsx("strong",{children:e.label||e.id}),s.jsx("em",{children:e.definitionId||e.kind||"display"})]})}),s.jsx(hQ,{className:l,children:a?s.jsx("div",{className:"af-public-display-empty",children:a}):o.trim()?s.jsxs(s.Fragment,{children:[e.kind==="html"?s.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:fQ(o)}):null,e.kind==="react"?s.jsx("iframe",{title:e.label||e.id,sandbox:"allow-scripts allow-forms allow-modals allow-popups allow-popups-to-escape-sandbox",srcDoc:Wv(o)}):null,e.kind==="image"?s.jsx("img",{src:f$(o,t),alt:e.label||e.id,loading:"lazy"}):null,e.kind==="markdown"?s.jsx("div",{className:"af-public-display-markdown",children:s.jsx(hf,{content:o,resolveSrc:(c,u)=>pQ(c,t,u)})}):null,e.kind==="chart"?s.jsx(Dv,{content:o}):null,e.kind==="table"?s.jsx(Ov,{content:o}):null,e.kind==="mermaid"||e.kind==="ascii"?s.jsx("pre",{children:o}):null]}):s.jsx("div",{className:"af-public-display-empty",children:"No display content"})})]})}function mQ({data:e}){return s.jsx(Xb,{node:e==null?void 0:e.node,shareId:e==null?void 0:e.shareId})}const gQ={publicDisplay:mQ};function yQ(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 p$(){var l,c,u,f;const{path:e}=us(),t=h.useMemo(()=>yQ(e),[e]),[n,r]=h.useState({loading:!0,error:"",share:null,nodes:[]});h.useEffect(()=>{let p=!1;async function d(){if(!t){r({loading:!1,error:"Missing display share id",share:null,nodes:[]});return}r(m=>({...m,loading:!0,error:""}));try{const m=await fetch(`/api/display/share?id=${encodeURIComponent(t)}`),y=await m.json().catch(()=>({}));if(!m.ok)throw new Error(y.error||"展示页不存在");p||r({loading:!1,error:"",share:y.share||null,nodes:Array.isArray(y.nodes)?y.nodes:[]})}catch(m){p||r({loading:!1,error:String((m==null?void 0:m.message)||m),share:null,nodes:[]})}}return d(),()=>{p=!0}},[t]);const i=h.useMemo(()=>(Array.isArray(n.nodes)?n.nodes:[]).map((d,m)=>{const y=d.position&&typeof d.position.x=="number"&&typeof d.position.y=="number"?d.position:{x:120+m*40,y:100+m*32},v=d.size&&typeof d.size.width=="number"&&typeof d.size.height=="number"?d.size:{width:520,height:320};return{id:d.id,type:"publicDisplay",position:y,data:{node:d,shareId:t},selectable:!1,draggable:!1,style:{width:Math.max(1,Number(v.width)||520),height:Math.max(1,Number(v.height)||320)}}}),[t,n.nodes]),o=h.useMemo(()=>{var v;const p=(v=n.share)==null?void 0:v.viewport;if(!p||typeof p!="object")return null;const d=Number(p.x),m=Number(p.y),y=Number(p.zoom);return!Number.isFinite(d)||!Number.isFinite(m)||!Number.isFinite(y)?null:{x:d,y:m,zoom:Math.min(Math.max(y,.1),4)}},[(l=n.share)==null?void 0:l.viewport]);if(n.loading)return s.jsx("main",{className:"af-public-display-page",children:s.jsx("div",{className:"af-public-display-status",children:"Loading..."})});if(n.error)return s.jsx("main",{className:"af-public-display-page",children:s.jsxs("div",{className:"af-public-display-status af-public-display-status--error",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"error"}),s.jsx("span",{children:n.error})]})});const a=String(((c=n.share)==null?void 0:c.layout)||"").trim()||"gallery";if(a!=="canvas"){if(a==="single")return s.jsx("main",{className:"af-public-display-page af-public-display-page--single",children:s.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(d=>s.jsx(Xb,{node:d,shareId:t,bare:!0},d.id))})});const p=a==="slides"?"af-public-display-page--slides":a==="document"?"af-public-display-page--document":"af-public-display-page--gallery";return s.jsxs("main",{className:`af-public-display-page ${p}`,children:[s.jsxs("header",{className:"af-public-display-hero",children:[s.jsxs("div",{children:[s.jsx("p",{children:"AgentFlow Display"}),s.jsx("h1",{children:((u=n.share)==null?void 0:u.title)||"AgentFlow Display"})]}),s.jsx("span",{children:(f=n.share)!=null&&f.expiresAt?`有效期至 ${new Date(n.share.expiresAt).toLocaleString()}`:"永久有效"})]}),s.jsx("div",{className:"af-public-display-grid",children:(n.nodes||[]).map(d=>s.jsx(Xb,{node:d,shareId:t},d.id))})]})}return s.jsx("main",{className:"af-public-display-page af-public-display-page--canvas",children:s.jsx(bv,{children:s.jsx(cR,{className:"af-public-display-flow",nodes:i,edges:[],nodeTypes:gQ,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!1,panOnDrag:!0,noPanClassName:"nopan",noDragClassName:"nodrag",noWheelClassName:"nowheel",panOnScroll:!0,zoomOnScroll:!0,zoomOnPinch:!0,defaultViewport:o||void 0,fitView:!o,fitViewOptions:{padding:.18,duration:180},minZoom:.1,maxZoom:4,proOptions:{hideAttribution:!0},children:s.jsx(dR,{color:"rgba(255,255,255,0.12)",gap:22,size:1})})})})}const vt=e=>typeof e=="string",sd=()=>{let e,t;const n=new Promise((r,i)=>{e=r,t=i});return n.resolve=e,n.reject=t,n},DC=e=>e==null?"":""+e,wQ=(e,t,n)=>{e.forEach(r=>{t[r]&&(n[r]=t[r])})},xQ=/###/g,FC=e=>e&&e.indexOf("###")>-1?e.replace(xQ,"."):e,zC=e=>!e||vt(e),Dd=(e,t,n)=>{const r=vt(t)?t.split("."):t;let i=0;for(;i<r.length-1;){if(zC(e))return{};const o=FC(r[i]);!e[o]&&n&&(e[o]=new n),Object.prototype.hasOwnProperty.call(e,o)?e=e[o]:e={},++i}return zC(e)?{}:{obj:e,k:FC(r[i])}},BC=(e,t,n)=>{const{obj:r,k:i}=Dd(e,t,Object);if(r!==void 0||t.length===1){r[i]=n;return}let o=t[t.length-1],a=t.slice(0,t.length-1),l=Dd(e,a,Object);for(;l.obj===void 0&&a.length;)o=`${a[a.length-1]}.${o}`,a=a.slice(0,a.length-1),l=Dd(e,a,Object),l&&l.obj&&typeof l.obj[`${l.k}.${o}`]<"u"&&(l.obj=void 0);l.obj[`${l.k}.${o}`]=n},bQ=(e,t,n,r)=>{const{obj:i,k:o}=Dd(e,t,Object);i[o]=i[o]||[],i[o].push(n)},qm=(e,t)=>{const{obj:n,k:r}=Dd(e,t);if(n)return n[r]},kQ=(e,t,n)=>{const r=qm(e,n);return r!==void 0?r:qm(t,n)},h$=(e,t,n)=>{for(const r in t)r!=="__proto__"&&r!=="constructor"&&(r in e?vt(e[r])||e[r]instanceof String||vt(t[r])||t[r]instanceof String?n&&(e[r]=t[r]):h$(e[r],t[r],n):e[r]=t[r]);return e},Ql=e=>e.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&");var vQ={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};const SQ=e=>vt(e)?e.replace(/[&<>"'\/]/g,t=>vQ[t]):e;class jQ{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 NQ=[" ",",","?","!",";"],_Q=new jQ(20),CQ=(e,t,n)=>{t=t||"",n=n||"";const r=NQ.filter(a=>t.indexOf(a)<0&&n.indexOf(a)<0);if(r.length===0)return!0;const i=_Q.getRegExp(`(${r.map(a=>a==="?"?"\\?":a).join("|")})`);let o=!i.test(e);if(!o){const a=e.indexOf(n);a>0&&!i.test(e.substring(0,a))&&(o=!0)}return o},Qb=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 i=e;for(let o=0;o<r.length;){if(!i||typeof i!="object")return;let a,l="";for(let c=o;c<r.length;++c)if(c!==o&&(l+=n),l+=r[c],a=i[l],a!==void 0){if(["string","number","boolean"].indexOf(typeof a)>-1&&c<r.length-1)continue;o+=c-o+1;break}i=a}return i},Um=e=>e&&e.replace("_","-"),AQ={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 Gm{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||AQ,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,i){return i&&!this.debug?null:(vt(t[0])&&(t[0]=`${r}${this.prefix} ${t[0]}`),this.logger[n](t))}create(t){return new Gm(this.logger,{prefix:`${this.prefix}:${t}:`,...this.options})}clone(t){return t=t||this.options,t.prefix=t.prefix||this.prefix,new Gm(this.logger,t)}}var Ri=new Gm;class Fg{constructor(){this.observers={}}on(t,n){return t.split(" ").forEach(r=>{this.observers[r]||(this.observers[r]=new Map);const i=this.observers[r].get(n)||0;this.observers[r].set(n,i+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),i=1;i<n;i++)r[i-1]=arguments[i];this.observers[t]&&Array.from(this.observers[t].entries()).forEach(a=>{let[l,c]=a;for(let u=0;u<c;u++)l(...r)}),this.observers["*"]&&Array.from(this.observers["*"].entries()).forEach(a=>{let[l,c]=a;for(let u=0;u<c;u++)l.apply(l,[t,...r])})}}class WC extends Fg{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{ns:["translation"],defaultNS:"translation"};super(),this.data=t||{},this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.options.ignoreJSONStructure===void 0&&(this.options.ignoreJSONStructure=!0)}addNamespaces(t){this.options.ns.indexOf(t)<0&&this.options.ns.push(t)}removeNamespaces(t){const n=this.options.ns.indexOf(t);n>-1&&this.options.ns.splice(n,1)}getResource(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=i.keySeparator!==void 0?i.keySeparator:this.options.keySeparator,a=i.ignoreJSONStructure!==void 0?i.ignoreJSONStructure:this.options.ignoreJSONStructure;let l;t.indexOf(".")>-1?l=t.split("."):(l=[t,n],r&&(Array.isArray(r)?l.push(...r):vt(r)&&o?l.push(...r.split(o)):l.push(r)));const c=qm(this.data,l);return!c&&!n&&!r&&t.indexOf(".")>-1&&(t=l[0],n=l[1],r=l.slice(2).join(".")),c||!a||!vt(r)?c:Qb(this.data&&this.data[t]&&this.data[t][n],r,o)}addResource(t,n,r,i){let o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{silent:!1};const a=o.keySeparator!==void 0?o.keySeparator:this.options.keySeparator;let l=[t,n];r&&(l=l.concat(a?r.split(a):r)),t.indexOf(".")>-1&&(l=t.split("."),i=n,n=l[1]),this.addNamespaces(n),BC(this.data,l,i),o.silent||this.emit("added",t,n,r,i)}addResources(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{silent:!1};for(const o in r)(vt(r[o])||Array.isArray(r[o]))&&this.addResource(t,n,o,r[o],{silent:!0});i.silent||this.emit("added",t,n,r)}addResourceBundle(t,n,r,i,o){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{silent:!1,skipCopy:!1},l=[t,n];t.indexOf(".")>-1&&(l=t.split("."),i=r,r=n,n=l[1]),this.addNamespaces(n);let c=qm(this.data,l)||{};a.skipCopy||(r=JSON.parse(JSON.stringify(r))),i?h$(c,r,o):c={...c,...r},BC(this.data,l,c),a.silent||this.emit("added",t,n,r)}removeResourceBundle(t,n){this.hasResourceBundle(t,n)&&delete this.data[t][n],this.removeNamespaces(n),this.emit("removed",t,n)}hasResourceBundle(t,n){return this.getResource(t,n)!==void 0}getResourceBundle(t,n){return n||(n=this.options.defaultNS),this.options.compatibilityAPI==="v1"?{...this.getResource(t,n)}:this.getResource(t,n)}getDataByLanguage(t){return this.data[t]}hasLanguageSomeTranslations(t){const n=this.getDataByLanguage(t);return!!(n&&Object.keys(n)||[]).find(i=>n[i]&&Object.keys(n[i]).length>0)}toJSON(){return this.data}}var m$={processors:{},addPostProcessor(e){this.processors[e.name]=e},handle(e,t,n,r,i){return e.forEach(o=>{this.processors[o]&&(t=this.processors[o].process(t,n,r,i))}),t}};const HC={};class Ym extends Fg{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};super(),wQ(["resourceStore","languageUtils","pluralResolver","interpolator","backendConnector","i18nFormat","utils"],t,this),this.options=n,this.options.keySeparator===void 0&&(this.options.keySeparator="."),this.logger=Ri.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 i=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator;let o=n.ns||this.options.defaultNS||[];const a=r&&t.indexOf(r)>-1,l=!this.options.userDefinedKeySeparator&&!n.keySeparator&&!this.options.userDefinedNsSeparator&&!n.nsSeparator&&!CQ(t,r,i);if(a&&!l){const c=t.match(this.interpolator.nestingRegexp);if(c&&c.length>0)return{key:t,namespaces:vt(o)?[o]:o};const u=t.split(r);(r!==i||r===i&&this.options.ns.indexOf(u[0])>-1)&&(o=u.shift()),t=u.join(i)}return{key:t,namespaces:vt(o)?[o]:o}}translate(t,n,r){if(typeof n!="object"&&this.options.overloadTranslationOptionHandler&&(n=this.options.overloadTranslationOptionHandler(arguments)),typeof n=="object"&&(n={...n}),n||(n={}),t==null)return"";Array.isArray(t)||(t=[String(t)]);const i=n.returnDetails!==void 0?n.returnDetails:this.options.returnDetails,o=n.keySeparator!==void 0?n.keySeparator:this.options.keySeparator,{key:a,namespaces:l}=this.extractFromKey(t[t.length-1],n),c=l[l.length-1],u=n.lng||this.language,f=n.appendNamespaceToCIMode||this.options.appendNamespaceToCIMode;if(u&&u.toLowerCase()==="cimode"){if(f){const _=n.nsSeparator||this.options.nsSeparator;return i?{res:`${c}${_}${a}`,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:`${c}${_}${a}`}return i?{res:a,usedKey:a,exactUsedKey:a,usedLng:u,usedNS:c,usedParams:this.getUsedParamsDetails(n)}:a}const p=this.resolve(t,n);let d=p&&p.res;const m=p&&p.usedKey||a,y=p&&p.exactUsedKey||a,v=Object.prototype.toString.apply(d),b=["[object Number]","[object Function]","[object RegExp]"],g=n.joinArrays!==void 0?n.joinArrays:this.options.joinArrays,k=!this.i18nFormat||this.i18nFormat.handleAsObject,x=!vt(d)&&typeof d!="boolean"&&typeof d!="number";if(k&&d&&x&&b.indexOf(v)<0&&!(vt(g)&&Array.isArray(d))){if(!n.returnObjects&&!this.options.returnObjects){this.options.returnedObjectHandler||this.logger.warn("accessing an object - but returnObjects options is not enabled!");const _=this.options.returnedObjectHandler?this.options.returnedObjectHandler(m,d,{...n,ns:l}):`key '${a} (${this.language})' returned an object instead of string.`;return i?(p.res=_,p.usedParams=this.getUsedParamsDetails(n),p):_}if(o){const _=Array.isArray(d),j=_?[]:{},N=_?y:m;for(const P in d)if(Object.prototype.hasOwnProperty.call(d,P)){const T=`${N}${o}${P}`;j[P]=this.translate(T,{...n,joinArrays:!1,ns:l}),j[P]===T&&(j[P]=d[P])}d=j}}else if(k&&vt(g)&&Array.isArray(d))d=d.join(g),d&&(d=this.extendTranslation(d,t,n,r));else{let _=!1,j=!1;const N=n.count!==void 0&&!vt(n.count),P=Ym.hasDefaultValue(n),T=N?this.pluralResolver.getSuffix(u,n.count,n):"",z=n.ordinal&&N?this.pluralResolver.getSuffix(u,n.count,{ordinal:!1}):"",E=N&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),O=E&&n[`defaultValue${this.options.pluralSeparator}zero`]||n[`defaultValue${T}`]||n[`defaultValue${z}`]||n.defaultValue;!this.isValidLookup(d)&&P&&(_=!0,d=O),this.isValidLookup(d)||(j=!0,d=a);const L=(n.missingKeyNoValueFallbackToKey||this.options.missingKeyNoValueFallbackToKey)&&j?void 0:d,$=P&&O!==d&&this.options.updateMissing;if(j||_||$){if(this.logger.log($?"updateKey":"missingKey",u,c,a,$?O:d),o){const M=this.resolve(a,{...n,keySeparator:!1});M&&M.res&&this.logger.warn("Seems the loaded translations were in flat JSON format instead of nested. Either set keySeparator: false on init or make sure your translations are published in nested format.")}let V=[];const W=this.languageUtils.getFallbackCodes(this.options.fallbackLng,n.lng||this.language);if(this.options.saveMissingTo==="fallback"&&W&&W[0])for(let M=0;M<W.length;M++)V.push(W[M]);else this.options.saveMissingTo==="all"?V=this.languageUtils.toResolveHierarchy(n.lng||this.language):V.push(n.lng||this.language);const F=(M,H,A)=>{const X=P&&A!==d?A:L;this.options.missingKeyHandler?this.options.missingKeyHandler(M,c,H,X,$,n):this.backendConnector&&this.backendConnector.saveMissing&&this.backendConnector.saveMissing(M,c,H,X,$,n),this.emit("missingKey",M,c,H,d)};this.options.saveMissing&&(this.options.saveMissingPlurals&&N?V.forEach(M=>{const H=this.pluralResolver.getSuffixes(M,n);E&&n[`defaultValue${this.options.pluralSeparator}zero`]&&H.indexOf(`${this.options.pluralSeparator}zero`)<0&&H.push(`${this.options.pluralSeparator}zero`),H.forEach(A=>{F([M],a+A,n[`defaultValue${A}`]||O)})}):F(V,a,O))}d=this.extendTranslation(d,t,n,p,r),j&&d===a&&this.options.appendNamespaceToMissingKey&&(d=`${c}:${a}`),(j||_)&&this.options.parseMissingKeyHandler&&(this.options.compatibilityAPI!=="v1"?d=this.options.parseMissingKeyHandler(this.options.appendNamespaceToMissingKey?`${c}:${a}`:a,_?d:void 0):d=this.options.parseMissingKeyHandler(d))}return i?(p.res=d,p.usedParams=this.getUsedParamsDetails(n),p):d}extendTranslation(t,n,r,i,o){var a=this;if(this.i18nFormat&&this.i18nFormat.parse)t=this.i18nFormat.parse(t,{...this.options.interpolation.defaultVariables,...r},r.lng||this.language||i.usedLng,i.usedNS,i.usedKey,{resolved:i});else if(!r.skipInterpolation){r.interpolation&&this.interpolator.init({...r,interpolation:{...this.options.interpolation,...r.interpolation}});const u=vt(t)&&(r&&r.interpolation&&r.interpolation.skipOnVariables!==void 0?r.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables);let f;if(u){const d=t.match(this.interpolator.nestingRegexp);f=d&&d.length}let p=r.replace&&!vt(r.replace)?r.replace:r;if(this.options.interpolation.defaultVariables&&(p={...this.options.interpolation.defaultVariables,...p}),t=this.interpolator.interpolate(t,p,r.lng||this.language||i.usedLng,r),u){const d=t.match(this.interpolator.nestingRegexp),m=d&&d.length;f<m&&(r.nest=!1)}!r.lng&&this.options.compatibilityAPI!=="v1"&&i&&i.res&&(r.lng=this.language||i.usedLng),r.nest!==!1&&(t=this.interpolator.nest(t,function(){for(var d=arguments.length,m=new Array(d),y=0;y<d;y++)m[y]=arguments[y];return o&&o[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,c=vt(l)?[l]:l;return t!=null&&c&&c.length&&r.applyPostProcessor!==!1&&(t=m$.handle(c,t,n,this.options&&this.options.postProcessPassResolved?{i18nResolved:{...i,usedParams:this.getUsedParamsDetails(r)},...r}:r,this)),t}resolve(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},r,i,o,a,l;return vt(t)&&(t=[t]),t.forEach(c=>{if(this.isValidLookup(r))return;const u=this.extractFromKey(c,n),f=u.key;i=f;let p=u.namespaces;this.options.fallbackNS&&(p=p.concat(this.options.fallbackNS));const d=n.count!==void 0&&!vt(n.count),m=d&&!n.ordinal&&n.count===0&&this.pluralResolver.shouldUseIntlApi(),y=n.context!==void 0&&(vt(n.context)||typeof n.context=="number")&&n.context!=="",v=n.lngs?n.lngs:this.languageUtils.toResolveHierarchy(n.lng||this.language,n.fallbackLng);p.forEach(b=>{this.isValidLookup(r)||(l=b,!HC[`${v[0]}-${b}`]&&this.utils&&this.utils.hasLoadedNamespace&&!this.utils.hasLoadedNamespace(l)&&(HC[`${v[0]}-${b}`]=!0,this.logger.warn(`key "${i}" for languages "${v.join(", ")}" won't get resolved as namespace "${l}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!")),v.forEach(g=>{if(this.isValidLookup(r))return;a=g;const k=[f];if(this.i18nFormat&&this.i18nFormat.addLookupKeys)this.i18nFormat.addLookupKeys(k,f,g,b,n);else{let _;d&&(_=this.pluralResolver.getSuffix(g,n.count,n));const j=`${this.options.pluralSeparator}zero`,N=`${this.options.pluralSeparator}ordinal${this.options.pluralSeparator}`;if(d&&(k.push(f+_),n.ordinal&&_.indexOf(N)===0&&k.push(f+_.replace(N,this.options.pluralSeparator)),m&&k.push(f+j)),y){const P=`${f}${this.options.contextSeparator}${n.context}`;k.push(P),d&&(k.push(P+_),n.ordinal&&_.indexOf(N)===0&&k.push(P+_.replace(N,this.options.pluralSeparator)),m&&k.push(P+j))}}let x;for(;x=k.pop();)this.isValidLookup(r)||(o=x,r=this.getResource(g,b,x,n))}))})}),{res:r,usedKey:i,exactUsedKey:o,usedLng:a,usedNS:l}}isValidLookup(t){return t!==void 0&&!(!this.options.returnNull&&t===null)&&!(!this.options.returnEmptyString&&t==="")}getResource(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};return this.i18nFormat&&this.i18nFormat.getResource?this.i18nFormat.getResource(t,n,r,i):this.resourceStore.getResource(t,n,r,i)}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&&!vt(t.replace);let i=r?t.replace:t;if(r&&typeof t.count<"u"&&(i.count=t.count),this.options.interpolation.defaultVariables&&(i={...this.options.interpolation.defaultVariables,...i}),!r){i={...i};for(const o of n)delete i[o]}return i}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 Kw=e=>e.charAt(0).toUpperCase()+e.slice(1);class VC{constructor(t){this.options=t,this.supportedLngs=this.options.supportedLngs||!1,this.logger=Ri.create("languageUtils")}getScriptPartFromCode(t){if(t=Um(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=Um(t),!t||t.indexOf("-")<0)return t;const n=t.split("-");return this.formatLanguageCode(n[0])}formatLanguageCode(t){if(vt(t)&&t.indexOf("-")>-1){if(typeof Intl<"u"&&typeof Intl.getCanonicalLocales<"u")try{let i=Intl.getCanonicalLocales(t)[0];if(i&&this.options.lowerCaseLng&&(i=i.toLowerCase()),i)return i}catch{}const n=["hans","hant","latn","cyrl","cans","mong","arab"];let r=t.split("-");return this.options.lowerCaseLng?r=r.map(i=>i.toLowerCase()):r.length===2?(r[0]=r[0].toLowerCase(),r[1]=r[1].toUpperCase(),n.indexOf(r[1].toLowerCase())>-1&&(r[1]=Kw(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]=Kw(r[1].toLowerCase())),n.indexOf(r[2].toLowerCase())>-1&&(r[2]=Kw(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 i=this.formatLanguageCode(r);(!this.options.supportedLngs||this.isSupportedCode(i))&&(n=i)}),!n&&this.options.supportedLngs&&t.forEach(r=>{if(n)return;const i=this.getLanguagePartFromCode(r);if(this.isSupportedCode(i))return n=i;n=this.options.supportedLngs.find(o=>{if(o===i)return o;if(!(o.indexOf("-")<0&&i.indexOf("-")<0)&&(o.indexOf("-")>0&&i.indexOf("-")<0&&o.substring(0,o.indexOf("-"))===i||o.indexOf(i)===0&&i.length>1))return o})}),n||(n=this.getFallbackCodes(this.options.fallbackLng)[0]),n}getFallbackCodes(t,n){if(!t)return[];if(typeof t=="function"&&(t=t(n)),vt(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),i=[],o=a=>{a&&(this.isSupportedCode(a)?i.push(a):this.logger.warn(`rejecting language code not found in supportedLngs: ${a}`))};return vt(t)&&(t.indexOf("-")>-1||t.indexOf("_")>-1)?(this.options.load!=="languageOnly"&&o(this.formatLanguageCode(t)),this.options.load!=="languageOnly"&&this.options.load!=="currentOnly"&&o(this.getScriptPartFromCode(t)),this.options.load!=="currentOnly"&&o(this.getLanguagePartFromCode(t))):vt(t)&&o(this.formatLanguageCode(t)),r.forEach(a=>{i.indexOf(a)<0&&o(this.formatLanguageCode(a))}),i}}let EQ=[{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}],IQ={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 PQ=["v1","v2","v3"],TQ=["v4"],KC={zero:0,one:1,two:2,few:3,many:4,other:5},RQ=()=>{const e={};return EQ.forEach(t=>{t.lngs.forEach(n=>{e[n]={numbers:t.nr,plurals:IQ[t.fc]}})}),e};class MQ{constructor(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};this.languageUtils=t,this.options=n,this.logger=Ri.create("pluralResolver"),(!this.options.compatibilityJSON||TQ.includes(this.options.compatibilityJSON))&&(typeof Intl>"u"||!Intl.PluralRules)&&(this.options.compatibilityJSON="v3",this.logger.error("Your environment seems not to be Intl API compatible, use an Intl.PluralRules polyfill. Will fallback to the compatibilityJSON v3 format handling.")),this.rules=RQ(),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=Um(t==="dev"?"en":t),i=n.ordinal?"ordinal":"cardinal",o=JSON.stringify({cleanedCode:r,type:i});if(o in this.pluralRulesCache)return this.pluralRulesCache[o];let a;try{a=new Intl.PluralRules(r,{type:i})}catch{if(!t.match(/-|_/))return;const c=this.languageUtils.getLanguagePartFromCode(t);a=this.getRule(c,n)}return this.pluralRulesCache[o]=a,a}return this.rules[t]||this.rules[this.languageUtils.getLanguagePartFromCode(t)]}needsPlural(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};const r=this.getRule(t,n);return this.shouldUseIntlApi()?r&&r.resolvedOptions().pluralCategories.length>1:r&&r.numbers.length>1}getPluralFormsOfKey(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return this.getSuffixes(t,r).map(i=>`${n}${i}`)}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((i,o)=>KC[i]-KC[o]).map(i=>`${this.options.prepend}${n.ordinal?`ordinal${this.options.prepend}`:""}${i}`):r.numbers.map(i=>this.getSuffix(t,i,n)):[]}getSuffix(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};const i=this.getRule(t,r);return i?this.shouldUseIntlApi()?`${this.options.prepend}${r.ordinal?`ordinal${this.options.prepend}`:""}${i.select(n)}`:this.getSuffixRetroCompatible(i,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 i=t.numbers[r];this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1&&(i===2?i="plural":i===1&&(i=""));const o=()=>this.options.prepend&&i.toString()?this.options.prepend+i.toString():i.toString();return this.options.compatibilityJSON==="v1"?i===1?"":typeof i=="number"?`_plural_${i.toString()}`:o():this.options.compatibilityJSON==="v2"||this.options.simplifyPluralSuffix&&t.numbers.length===2&&t.numbers[0]===1?o():this.options.prepend&&r.toString()?this.options.prepend+r.toString():r.toString()}shouldUseIntlApi(){return!PQ.includes(this.options.compatibilityJSON)}}const qC=function(e,t,n){let r=arguments.length>3&&arguments[3]!==void 0?arguments[3]:".",i=arguments.length>4&&arguments[4]!==void 0?arguments[4]:!0,o=kQ(e,t,n);return!o&&i&&vt(n)&&(o=Qb(e,n,r),o===void 0&&(o=Qb(t,n,r))),o},qw=e=>e.replace(/\$/g,"$$$$");class $Q{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Ri.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:i,prefix:o,prefixEscaped:a,suffix:l,suffixEscaped:c,formatSeparator:u,unescapeSuffix:f,unescapePrefix:p,nestingPrefix:d,nestingPrefixEscaped:m,nestingSuffix:y,nestingSuffixEscaped:v,nestingOptionsSeparator:b,maxReplaces:g,alwaysFormat:k}=t.interpolation;this.escape=n!==void 0?n:SQ,this.escapeValue=r!==void 0?r:!0,this.useRawValueToEscape=i!==void 0?i:!1,this.prefix=o?Ql(o):a||"{{",this.suffix=l?Ql(l):c||"}}",this.formatSeparator=u||",",this.unescapePrefix=f?"":p||"-",this.unescapeSuffix=this.unescapePrefix?"":f||"",this.nestingPrefix=d?Ql(d):m||Ql("$t("),this.nestingSuffix=y?Ql(y):v||Ql(")"),this.nestingOptionsSeparator=b||",",this.maxReplaces=g||1e3,this.alwaysFormat=k!==void 0?k:!1,this.resetRegExp()}reset(){this.options&&this.init(this.options)}resetRegExp(){const t=(n,r)=>n&&n.source===r?(n.lastIndex=0,n):new RegExp(r,"g");this.regexp=t(this.regexp,`${this.prefix}(.+?)${this.suffix}`),this.regexpUnescape=t(this.regexpUnescape,`${this.prefix}${this.unescapePrefix}(.+?)${this.unescapeSuffix}${this.suffix}`),this.nestingRegexp=t(this.nestingRegexp,`${this.nestingPrefix}(.+?)${this.nestingSuffix}`)}interpolate(t,n,r,i){let o,a,l;const c=this.options&&this.options.interpolation&&this.options.interpolation.defaultVariables||{},u=m=>{if(m.indexOf(this.formatSeparator)<0){const g=qC(n,c,m,this.options.keySeparator,this.options.ignoreJSONStructure);return this.alwaysFormat?this.format(g,void 0,r,{...i,...n,interpolationkey:m}):g}const y=m.split(this.formatSeparator),v=y.shift().trim(),b=y.join(this.formatSeparator).trim();return this.format(qC(n,c,v,this.options.keySeparator,this.options.ignoreJSONStructure),b,r,{...i,...n,interpolationkey:v})};this.resetRegExp();const f=i&&i.missingInterpolationHandler||this.options.missingInterpolationHandler,p=i&&i.interpolation&&i.interpolation.skipOnVariables!==void 0?i.interpolation.skipOnVariables:this.options.interpolation.skipOnVariables;return[{regex:this.regexpUnescape,safeValue:m=>qw(m)},{regex:this.regexp,safeValue:m=>this.escapeValue?qw(this.escape(m)):qw(m)}].forEach(m=>{for(l=0;o=m.regex.exec(t);){const y=o[1].trim();if(a=u(y),a===void 0)if(typeof f=="function"){const b=f(t,o,i);a=vt(b)?b:""}else if(i&&Object.prototype.hasOwnProperty.call(i,y))a="";else if(p){a=o[0];continue}else this.logger.warn(`missed to pass in variable ${y} for interpolating ${t}`),a="";else!vt(a)&&!this.useRawValueToEscape&&(a=DC(a));const v=m.safeValue(a);if(t=t.replace(o[0],v),p?(m.regex.lastIndex+=a.length,m.regex.lastIndex-=o[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]:{},i,o,a;const l=(c,u)=>{const f=this.nestingOptionsSeparator;if(c.indexOf(f)<0)return c;const p=c.split(new RegExp(`${f}[ ]*{`));let d=`{${p[1]}`;c=p[0],d=this.interpolate(d,a);const m=d.match(/'/g),y=d.match(/"/g);(m&&m.length%2===0&&!y||y.length%2!==0)&&(d=d.replace(/'/g,'"'));try{a=JSON.parse(d),u&&(a={...u,...a})}catch(v){return this.logger.warn(`failed parsing options string in nesting for key ${c}`,v),`${c}${f}${d}`}return a.defaultValue&&a.defaultValue.indexOf(this.prefix)>-1&&delete a.defaultValue,c};for(;i=this.nestingRegexp.exec(t);){let c=[];a={...r},a=a.replace&&!vt(a.replace)?a.replace:a,a.applyPostProcessor=!1,delete a.defaultValue;let u=!1;if(i[0].indexOf(this.formatSeparator)!==-1&&!/{.*}/.test(i[1])){const f=i[1].split(this.formatSeparator).map(p=>p.trim());i[1]=f.shift(),c=f,u=!0}if(o=n(l.call(this,i[1].trim(),a),a),o&&i[0]===t&&!vt(o))return o;vt(o)||(o=DC(o)),o||(this.logger.warn(`missed to resolve ${i[1]} for nesting ${t}`),o=""),u&&(o=c.reduce((f,p)=>this.format(f,p,r.lng,{...r,interpolationkey:i[1].trim()}),o.trim())),t=t.replace(i[0],o),this.regexp.lastIndex=0}return t}}const LQ=e=>{let t=e.toLowerCase().trim();const n={};if(e.indexOf("(")>-1){const r=e.split("(");t=r[0].toLowerCase().trim();const i=r[1].substring(0,r[1].length-1);t==="currency"&&i.indexOf(":")<0?n.currency||(n.currency=i.trim()):t==="relativetime"&&i.indexOf(":")<0?n.range||(n.range=i.trim()):i.split(";").forEach(a=>{if(a){const[l,...c]=a.split(":"),u=c.join(":").trim().replace(/^'+|'+$/g,""),f=l.trim();n[f]||(n[f]=u),u==="false"&&(n[f]=!1),u==="true"&&(n[f]=!0),isNaN(u)||(n[f]=parseInt(u,10))}})}return{formatName:t,formatOptions:n}},Zl=e=>{const t={};return(n,r,i)=>{let o=i;i&&i.interpolationkey&&i.formatParams&&i.formatParams[i.interpolationkey]&&i[i.interpolationkey]&&(o={...o,[i.interpolationkey]:void 0});const a=r+JSON.stringify(o);let l=t[a];return l||(l=e(Um(r),i),t[a]=l),l(n)}};class OQ{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{};this.logger=Ri.create("formatter"),this.options=t,this.formats={number:Zl((n,r)=>{const i=new Intl.NumberFormat(n,{...r});return o=>i.format(o)}),currency:Zl((n,r)=>{const i=new Intl.NumberFormat(n,{...r,style:"currency"});return o=>i.format(o)}),datetime:Zl((n,r)=>{const i=new Intl.DateTimeFormat(n,{...r});return o=>i.format(o)}),relativetime:Zl((n,r)=>{const i=new Intl.RelativeTimeFormat(n,{...r});return o=>i.format(o,r.range||"day")}),list:Zl((n,r)=>{const i=new Intl.ListFormat(n,{...r});return o=>i.format(o)})},this.init(t)}init(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{interpolation:{}};this.formatSeparator=n.interpolation.formatSeparator||","}add(t,n){this.formats[t.toLowerCase().trim()]=n}addCached(t,n){this.formats[t.toLowerCase().trim()]=Zl(n)}format(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:{};const o=n.split(this.formatSeparator);if(o.length>1&&o[0].indexOf("(")>1&&o[0].indexOf(")")<0&&o.find(l=>l.indexOf(")")>-1)){const l=o.findIndex(c=>c.indexOf(")")>-1);o[0]=[o[0],...o.splice(1,l)].join(this.formatSeparator)}return o.reduce((l,c)=>{const{formatName:u,formatOptions:f}=LQ(c);if(this.formats[u]){let p=l;try{const d=i&&i.formatParams&&i.formatParams[i.interpolationkey]||{},m=d.locale||d.lng||i.locale||i.lng||r;p=this.formats[u](l,m,{...f,...i,...d})}catch(d){this.logger.warn(d)}return p}else this.logger.warn(`there was no format function for ${u}`);return l},t)}}const DQ=(e,t)=>{e.pending[t]!==void 0&&(delete e.pending[t],e.pendingCount--)};class FQ extends Fg{constructor(t,n,r){let i=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=i,this.logger=Ri.create("backendConnector"),this.waitingReads=[],this.maxParallelReads=i.maxParallelReads||10,this.readingCalls=0,this.maxRetries=i.maxRetries>=0?i.maxRetries:5,this.retryTimeout=i.retryTimeout>=1?i.retryTimeout:350,this.state={},this.queue=[],this.backend&&this.backend.init&&this.backend.init(r,i.backend,i)}queueLoad(t,n,r,i){const o={},a={},l={},c={};return t.forEach(u=>{let f=!0;n.forEach(p=>{const d=`${u}|${p}`;!r.reload&&this.store.hasResourceBundle(u,p)?this.state[d]=2:this.state[d]<0||(this.state[d]===1?a[d]===void 0&&(a[d]=!0):(this.state[d]=1,f=!1,a[d]===void 0&&(a[d]=!0),o[d]===void 0&&(o[d]=!0),c[p]===void 0&&(c[p]=!0)))}),f||(l[u]=!0)}),(Object.keys(o).length||Object.keys(a).length)&&this.queue.push({pending:a,pendingCount:Object.keys(a).length,loaded:{},errors:[],callback:i}),{toLoad:Object.keys(o),pending:Object.keys(a),toLoadLanguages:Object.keys(l),toLoadNamespaces:Object.keys(c)}}loaded(t,n,r){const i=t.split("|"),o=i[0],a=i[1];n&&this.emit("failedLoading",o,a,n),!n&&r&&this.store.addResourceBundle(o,a,r,void 0,void 0,{skipCopy:!0}),this.state[t]=n?-1:2,n&&r&&(this.state[t]=0);const l={};this.queue.forEach(c=>{bQ(c.loaded,[o],a),DQ(c,t),n&&c.errors.push(n),c.pendingCount===0&&!c.done&&(Object.keys(c.loaded).forEach(u=>{l[u]||(l[u]={});const f=c.loaded[u];f.length&&f.forEach(p=>{l[u][p]===void 0&&(l[u][p]=!0)})}),c.done=!0,c.errors.length?c.callback(c.errors):c.callback())}),this.emit("loaded",l),this.queue=this.queue.filter(c=>!c.done)}read(t,n,r){let i=arguments.length>3&&arguments[3]!==void 0?arguments[3]:0,o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:this.retryTimeout,a=arguments.length>5?arguments[5]:void 0;if(!t.length)return a(null,{});if(this.readingCalls>=this.maxParallelReads){this.waitingReads.push({lng:t,ns:n,fcName:r,tried:i,wait:o,callback:a});return}this.readingCalls++;const l=(u,f)=>{if(this.readingCalls--,this.waitingReads.length>0){const p=this.waitingReads.shift();this.read(p.lng,p.ns,p.fcName,p.tried,p.wait,p.callback)}if(u&&f&&i<this.maxRetries){setTimeout(()=>{this.read.call(this,t,n,r,i+1,o*2,a)},o);return}a(u,f)},c=this.backend[r].bind(this.backend);if(c.length===2){try{const u=c(t,n);u&&typeof u.then=="function"?u.then(f=>l(null,f)).catch(l):l(null,u)}catch(u){l(u)}return}return c(t,n,l)}prepareLoading(t,n){let r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},i=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."),i&&i();vt(t)&&(t=this.languageUtils.toResolveHierarchy(t)),vt(n)&&(n=[n]);const o=this.queueLoad(t,n,r,i);if(!o.toLoad.length)return o.pending.length||i(),null;o.toLoad.forEach(a=>{this.loadOne(a)})}load(t,n,r){this.prepareLoading(t,n,{},r)}reload(t,n,r){this.prepareLoading(t,n,{reload:!0},r)}loadOne(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"";const r=t.split("|"),i=r[0],o=r[1];this.read(i,o,"read",void 0,void 0,(a,l)=>{a&&this.logger.warn(`${n}loading namespace ${o} for language ${i} failed`,a),!a&&l&&this.logger.log(`${n}loaded namespace ${o} for language ${i}`,l),this.loaded(t,a,l)})}saveMissing(t,n,r,i,o){let a=arguments.length>5&&arguments[5]!==void 0?arguments[5]:{},l=arguments.length>6&&arguments[6]!==void 0?arguments[6]:()=>{};if(this.services.utils&&this.services.utils.hasLoadedNamespace&&!this.services.utils.hasLoadedNamespace(n)){this.logger.warn(`did not save key "${r}" as the namespace "${n}" was not yet loaded`,"This means something IS WRONG in your setup. You access the t function before i18next.init / i18next.loadNamespace / i18next.changeLanguage was done. Wait for the callback or Promise to resolve before accessing it!!!");return}if(!(r==null||r==="")){if(this.backend&&this.backend.create){const c={...a,isUpdate:o},u=this.backend.create.bind(this.backend);if(u.length<6)try{let f;u.length===5?f=u(t,n,r,i,c):f=u(t,n,r,i),f&&typeof f.then=="function"?f.then(p=>l(null,p)).catch(l):l(null,f)}catch(f){l(f)}else u(t,n,r,i,l,c)}!t||!t[0]||this.store.addResource(t[0],n,r,i)}}}const UC=()=>({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]),vt(e[1])&&(t.defaultValue=e[1]),vt(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}}),GC=e=>(vt(e.ns)&&(e.ns=[e.ns]),vt(e.fallbackLng)&&(e.fallbackLng=[e.fallbackLng]),vt(e.fallbackNS)&&(e.fallbackNS=[e.fallbackNS]),e.supportedLngs&&e.supportedLngs.indexOf("cimode")<0&&(e.supportedLngs=e.supportedLngs.concat(["cimode"])),e),ph=()=>{},zQ=e=>{Object.getOwnPropertyNames(Object.getPrototypeOf(e)).forEach(n=>{typeof e[n]=="function"&&(e[n]=e[n].bind(e))})};class Sf extends Fg{constructor(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1?arguments[1]:void 0;if(super(),this.options=GC(t),this.services={},this.logger=Ri,this.modules={external:[]},zQ(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&&(vt(n.ns)?n.defaultNS=n.ns:n.ns.indexOf("translation")<0&&(n.defaultNS=n.ns[0]));const i=UC();this.options={...i,...this.options,...GC(n)},this.options.compatibilityAPI!=="v1"&&(this.options.interpolation={...i.interpolation,...this.options.interpolation}),n.keySeparator!==void 0&&(this.options.userDefinedKeySeparator=n.keySeparator),n.nsSeparator!==void 0&&(this.options.userDefinedNsSeparator=n.nsSeparator);const o=f=>f?typeof f=="function"?new f:f:null;if(!this.options.isClone){this.modules.logger?Ri.init(o(this.modules.logger),this.options):Ri.init(null,this.options);let f;this.modules.formatter?f=this.modules.formatter:typeof Intl<"u"&&(f=OQ);const p=new VC(this.options);this.store=new WC(this.options.resources,this.options);const d=this.services;d.logger=Ri,d.resourceStore=this.store,d.languageUtils=p,d.pluralResolver=new MQ(p,{prepend:this.options.pluralSeparator,compatibilityJSON:this.options.compatibilityJSON,simplifyPluralSuffix:this.options.simplifyPluralSuffix}),f&&(!this.options.interpolation.format||this.options.interpolation.format===i.interpolation.format)&&(d.formatter=o(f),d.formatter.init(d,this.options),this.options.interpolation.format=d.formatter.format.bind(d.formatter)),d.interpolator=new $Q(this.options),d.utils={hasLoadedNamespace:this.hasLoadedNamespace.bind(this)},d.backendConnector=new FQ(o(this.modules.backend),d.resourceStore,d,this.options),d.backendConnector.on("*",function(m){for(var y=arguments.length,v=new Array(y>1?y-1:0),b=1;b<y;b++)v[b-1]=arguments[b];t.emit(m,...v)}),this.modules.languageDetector&&(d.languageDetector=o(this.modules.languageDetector),d.languageDetector.init&&d.languageDetector.init(d,this.options.detection,this.options)),this.modules.i18nFormat&&(d.i18nFormat=o(this.modules.i18nFormat),d.i18nFormat.init&&d.i18nFormat.init(this)),this.translator=new Ym(this.services,this.options),this.translator.on("*",function(m){for(var y=arguments.length,v=new Array(y>1?y-1:0),b=1;b<y;b++)v[b-1]=arguments[b];t.emit(m,...v)}),this.modules.external.forEach(m=>{m.init&&m.init(this)})}if(this.format=this.options.interpolation.format,r||(r=ph),this.options.fallbackLng&&!this.services.languageDetector&&!this.options.lng){const f=this.services.languageUtils.getFallbackCodes(this.options.fallbackLng);f.length>0&&f[0]!=="dev"&&(this.options.lng=f[0])}!this.services.languageDetector&&!this.options.lng&&this.logger.warn("init: no languageDetector is used and no lng is defined"),["getResource","hasResourceBundle","getResourceBundle","getDataByLanguage"].forEach(f=>{this[f]=function(){return t.store[f](...arguments)}}),["addResource","addResources","addResourceBundle","removeResourceBundle"].forEach(f=>{this[f]=function(){return t.store[f](...arguments),t}});const c=sd(),u=()=>{const f=(p,d)=>{this.isInitializing=!1,this.isInitialized&&!this.initializedStoreOnce&&this.logger.warn("init: i18next is already initialized. You should call init just once!"),this.isInitialized=!0,this.options.isClone||this.logger.log("initialized",this.options),this.emit("initialized",this.options),c.resolve(d),r(p,d)};if(this.languages&&this.options.compatibilityAPI!=="v1"&&!this.isInitialized)return f(null,this.t.bind(this));this.changeLanguage(this.options.lng,f)};return this.options.resources||!this.options.initImmediate?u():setTimeout(u,0),c}loadResources(t){let r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ph;const i=vt(t)?t:this.language;if(typeof t=="function"&&(r=t),!this.options.resources||this.options.partialBundledLanguages){if(i&&i.toLowerCase()==="cimode"&&(!this.options.preload||this.options.preload.length===0))return r();const o=[],a=l=>{if(!l||l==="cimode")return;this.services.languageUtils.toResolveHierarchy(l).forEach(u=>{u!=="cimode"&&o.indexOf(u)<0&&o.push(u)})};i?a(i):this.services.languageUtils.getFallbackCodes(this.options.fallbackLng).forEach(c=>a(c)),this.options.preload&&this.options.preload.forEach(l=>a(l)),this.services.backendConnector.load(o,this.options.ns,l=>{!l&&!this.resolvedLanguage&&this.language&&this.setResolvedLanguage(this.language),r(l)})}else r(null)}reloadResources(t,n,r){const i=sd();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=ph),this.services.backendConnector.reload(t,n,o=>{i.resolve(),r(o)}),i}use(t){if(!t)throw new Error("You are passing an undefined module! Please check the object you are passing to i18next.use()");if(!t.type)throw new Error("You are passing a wrong module! Please check the object you are passing to i18next.use()");return t.type==="backend"&&(this.modules.backend=t),(t.type==="logger"||t.log&&t.warn&&t.error)&&(this.modules.logger=t),t.type==="languageDetector"&&(this.modules.languageDetector=t),t.type==="i18nFormat"&&(this.modules.i18nFormat=t),t.type==="postProcessor"&&m$.addPostProcessor(t),t.type==="formatter"&&(this.modules.formatter=t),t.type==="3rdParty"&&this.modules.external.push(t),this}setResolvedLanguage(t){if(!(!t||!this.languages)&&!(["cimode","dev"].indexOf(t)>-1))for(let n=0;n<this.languages.length;n++){const r=this.languages[n];if(!(["cimode","dev"].indexOf(r)>-1)&&this.store.hasLanguageSomeTranslations(r)){this.resolvedLanguage=r;break}}}changeLanguage(t,n){var r=this;this.isLanguageChangingTo=t;const i=sd();this.emit("languageChanging",t);const o=c=>{this.language=c,this.languages=this.services.languageUtils.toResolveHierarchy(c),this.resolvedLanguage=void 0,this.setResolvedLanguage(c)},a=(c,u)=>{u?(o(u),this.translator.changeLanguage(u),this.isLanguageChangingTo=void 0,this.emit("languageChanged",u),this.logger.log("languageChanged",u)):this.isLanguageChangingTo=void 0,i.resolve(function(){return r.t(...arguments)}),n&&n(c,function(){return r.t(...arguments)})},l=c=>{!t&&!c&&this.services.languageDetector&&(c=[]);const u=vt(c)?c:this.services.languageUtils.getBestMatchFromCodes(c);u&&(this.language||o(u),this.translator.language||this.translator.changeLanguage(u),this.services.languageDetector&&this.services.languageDetector.cacheUserLanguage&&this.services.languageDetector.cacheUserLanguage(u)),this.loadResources(u,f=>{a(f,u)})};return!t&&this.services.languageDetector&&!this.services.languageDetector.async?l(this.services.languageDetector.detect()):!t&&this.services.languageDetector&&this.services.languageDetector.async?this.services.languageDetector.detect.length===0?this.services.languageDetector.detect().then(l):this.services.languageDetector.detect(l):l(t),i}getFixedT(t,n,r){var i=this;const o=function(a,l){let c;if(typeof l!="object"){for(var u=arguments.length,f=new Array(u>2?u-2:0),p=2;p<u;p++)f[p-2]=arguments[p];c=i.options.overloadTranslationOptionHandler([a,l].concat(f))}else c={...l};c.lng=c.lng||o.lng,c.lngs=c.lngs||o.lngs,c.ns=c.ns||o.ns,c.keyPrefix!==""&&(c.keyPrefix=c.keyPrefix||r||o.keyPrefix);const d=i.options.keySeparator||".";let m;return c.keyPrefix&&Array.isArray(a)?m=a.map(y=>`${c.keyPrefix}${d}${y}`):m=c.keyPrefix?`${c.keyPrefix}${d}${a}`:a,i.t(m,c)};return vt(t)?o.lng=t:o.lngs=t,o.ns=n,o.keyPrefix=r,o}t(){return this.translator&&this.translator.translate(...arguments)}exists(){return this.translator&&this.translator.exists(...arguments)}setDefaultNamespace(t){this.options.defaultNS=t}hasLoadedNamespace(t){let n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!this.isInitialized)return this.logger.warn("hasLoadedNamespace: i18next was not initialized",this.languages),!1;if(!this.languages||!this.languages.length)return this.logger.warn("hasLoadedNamespace: i18n.languages were undefined or empty",this.languages),!1;const r=n.lng||this.resolvedLanguage||this.languages[0],i=this.options?this.options.fallbackLng:!1,o=this.languages[this.languages.length-1];if(r.toLowerCase()==="cimode")return!0;const a=(l,c)=>{const u=this.services.backendConnector.state[`${l}|${c}`];return u===-1||u===0||u===2};if(n.precheck){const l=n.precheck(this,a);if(l!==void 0)return l}return!!(this.hasResourceBundle(r,t)||!this.services.backendConnector.backend||this.options.resources&&!this.options.partialBundledLanguages||a(r,t)&&(!i||a(o,t)))}loadNamespaces(t,n){const r=sd();return this.options.ns?(vt(t)&&(t=[t]),t.forEach(i=>{this.options.ns.indexOf(i)<0&&this.options.ns.push(i)}),this.loadResources(i=>{r.resolve(),n&&n(i)}),r):(n&&n(),Promise.resolve())}loadLanguages(t,n){const r=sd();vt(t)&&(t=[t]);const i=this.options.preload||[],o=t.filter(a=>i.indexOf(a)<0&&this.services.languageUtils.isSupportedCode(a));return o.length?(this.options.preload=i.concat(o),this.loadResources(a=>{r.resolve(),n&&n(a)}),r):(n&&n(),Promise.resolve())}dir(t){if(t||(t=this.resolvedLanguage||(this.languages&&this.languages.length>0?this.languages[0]:this.language)),!t)return"rtl";const n=["ar","shu","sqr","ssh","xaa","yhd","yud","aao","abh","abv","acm","acq","acw","acx","acy","adf","ads","aeb","aec","afb","ajp","apc","apd","arb","arq","ars","ary","arz","auz","avl","ayh","ayl","ayn","ayp","bbz","pga","he","iw","ps","pbt","pbu","pst","prp","prd","ug","ur","ydd","yds","yih","ji","yi","hbo","men","xmn","fa","jpr","peo","pes","prs","dv","sam","ckb"],r=this.services&&this.services.languageUtils||new VC(UC());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 Sf(t,n)}cloneInstance(){let t=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:ph;const r=t.forkResourceStore;r&&delete t.forkResourceStore;const i={...this.options,...t,isClone:!0},o=new Sf(i);return(t.debug!==void 0||t.prefix!==void 0)&&(o.logger=o.logger.clone(t)),["store","services","language"].forEach(l=>{o[l]=this[l]}),o.services={...this.services},o.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},r&&(o.store=new WC(this.store.data,i),o.services.resourceStore=o.store),o.translator=new Ym(o.services,i),o.translator.on("*",function(l){for(var c=arguments.length,u=new Array(c>1?c-1:0),f=1;f<c;f++)u[f-1]=arguments[f];o.emit(l,...u)}),o.init(i,n),o.translator.options=i,o.translator.backendConnector.services.utils={hasLoadedNamespace:o.hasLoadedNamespace.bind(o)},o}toJSON(){return{options:this.options,store:this.store,language:this.language,languages:this.languages,resolvedLanguage:this.resolvedLanguage}}}const Pr=Sf.createInstance();Pr.createInstance=Sf.createInstance;Pr.createInstance;Pr.dir;Pr.init;Pr.loadResources;Pr.reloadResources;Pr.use;Pr.changeLanguage;Pr.getFixedT;Pr.t;Pr.exists;Pr.setDefaultNamespace;Pr.hasLoadedNamespace;Pr.loadNamespaces;Pr.loadLanguages;function BQ(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function jf(e){"@babel/helpers - typeof";return jf=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},jf(e)}function WQ(e,t){if(jf(e)!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t);if(jf(r)!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}function HQ(e){var t=WQ(e,"string");return jf(t)=="symbol"?t:t+""}function VQ(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,HQ(r.key),r)}}function KQ(e,t,n){return t&&VQ(e.prototype,t),Object.defineProperty(e,"prototype",{writable:!1}),e}var g$=[],qQ=g$.forEach,UQ=g$.slice;function GQ(e){return qQ.call(UQ.call(arguments,1),function(t){if(t)for(var n in t)e[n]===void 0&&(e[n]=t[n])}),e}var YC=/^[\u0009\u0020-\u007e\u0080-\u00ff]+$/,YQ=function(t,n,r){var i=r||{};i.path=i.path||"/";var o=encodeURIComponent(n),a="".concat(t,"=").concat(o);if(i.maxAge>0){var l=i.maxAge-0;if(Number.isNaN(l))throw new Error("maxAge should be a Number");a+="; Max-Age=".concat(Math.floor(l))}if(i.domain){if(!YC.test(i.domain))throw new TypeError("option domain is invalid");a+="; Domain=".concat(i.domain)}if(i.path){if(!YC.test(i.path))throw new TypeError("option path is invalid");a+="; Path=".concat(i.path)}if(i.expires){if(typeof i.expires.toUTCString!="function")throw new TypeError("option expires is invalid");a+="; Expires=".concat(i.expires.toUTCString())}if(i.httpOnly&&(a+="; HttpOnly"),i.secure&&(a+="; Secure"),i.sameSite){var c=typeof i.sameSite=="string"?i.sameSite.toLowerCase():i.sameSite;switch(c){case!0:a+="; SameSite=Strict";break;case"lax":a+="; SameSite=Lax";break;case"strict":a+="; SameSite=Strict";break;case"none":a+="; SameSite=None";break;default:throw new TypeError("option sameSite is invalid")}}return a},JC={create:function(t,n,r,i){var o=arguments.length>4&&arguments[4]!==void 0?arguments[4]:{path:"/",sameSite:"strict"};r&&(o.expires=new Date,o.expires.setTime(o.expires.getTime()+r*60*1e3)),i&&(o.domain=i),document.cookie=YQ(t,encodeURIComponent(n),o)},read:function(t){for(var n="".concat(t,"="),r=document.cookie.split(";"),i=0;i<r.length;i++){for(var o=r[i];o.charAt(0)===" ";)o=o.substring(1,o.length);if(o.indexOf(n)===0)return o.substring(n.length,o.length)}return null},remove:function(t){this.create(t,"",-1)}},JQ={name:"cookie",lookup:function(t){var n;if(t.lookupCookie&&typeof document<"u"){var r=JC.read(t.lookupCookie);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupCookie&&typeof document<"u"&&JC.create(n.lookupCookie,t,n.cookieMinutes,n.cookieDomain,n.cookieOptions)}},XQ={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 i=r.substring(1),o=i.split("&"),a=0;a<o.length;a++){var l=o[a].indexOf("=");if(l>0){var c=o[a].substring(0,l);c===t.lookupQuerystring&&(n=o[a].substring(l+1))}}}return n}},id=null,XC=function(){if(id!==null)return id;try{id=window!=="undefined"&&window.localStorage!==null;var t="i18next.translate.boo";window.localStorage.setItem(t,"foo"),window.localStorage.removeItem(t)}catch{id=!1}return id},QQ={name:"localStorage",lookup:function(t){var n;if(t.lookupLocalStorage&&XC()){var r=window.localStorage.getItem(t.lookupLocalStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupLocalStorage&&XC()&&window.localStorage.setItem(n.lookupLocalStorage,t)}},od=null,QC=function(){if(od!==null)return od;try{od=window!=="undefined"&&window.sessionStorage!==null;var t="i18next.translate.boo";window.sessionStorage.setItem(t,"foo"),window.sessionStorage.removeItem(t)}catch{od=!1}return od},ZQ={name:"sessionStorage",lookup:function(t){var n;if(t.lookupSessionStorage&&QC()){var r=window.sessionStorage.getItem(t.lookupSessionStorage);r&&(n=r)}return n},cacheUserLanguage:function(t,n){n.lookupSessionStorage&&QC()&&window.sessionStorage.setItem(n.lookupSessionStorage,t)}},eZ={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}},tZ={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}},nZ={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}},rZ={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]}},y$=!1;try{document.cookie,y$=!0}catch{}var w$=["querystring","cookie","localStorage","sessionStorage","navigator","htmlTag"];y$||w$.splice(1,1);function sZ(){return{order:w$,lookupQuerystring:"lng",lookupCookie:"i18next",lookupLocalStorage:"i18nextLng",lookupSessionStorage:"i18nextLng",caches:["localStorage"],excludeCacheFor:["cimode"],convertDetectedLanguage:function(t){return t}}}var x$=function(){function e(t){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};BQ(this,e),this.type="languageDetector",this.detectors={},this.init(t,n)}return KQ(e,[{key:"init",value:function(n){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},i=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};this.services=n||{languageUtils:{}},this.options=GQ(r,this.options||{},sZ()),typeof this.options.convertDetectedLanguage=="string"&&this.options.convertDetectedLanguage.indexOf("15897")>-1&&(this.options.convertDetectedLanguage=function(o){return o.replace("-","_")}),this.options.lookupFromUrlIndex&&(this.options.lookupFromPathIndex=this.options.lookupFromUrlIndex),this.i18nOptions=i,this.addDetector(JQ),this.addDetector(XQ),this.addDetector(QQ),this.addDetector(ZQ),this.addDetector(eZ),this.addDetector(tZ),this.addDetector(nZ),this.addDetector(rZ)}},{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 i=[];return n.forEach(function(o){if(r.detectors[o]){var a=r.detectors[o].lookup(r.options);a&&typeof a=="string"&&(a=[a]),a&&(i=i.concat(a))}}),i=i.map(function(o){return r.options.convertDetectedLanguage(o)}),this.services.languageUtils.getBestMatchFromCodes?i:i.length>0?i[0]:null}},{key:"cacheUserLanguage",value:function(n,r){var i=this;r||(r=this.options.caches),r&&(this.options.excludeCacheFor&&this.options.excludeCacheFor.indexOf(n)>-1||r.forEach(function(o){i.detectors[o]&&i.detectors[o].cacheUserLanguage(n,i.options)}))}}])}();x$.type="languageDetector";const iZ={name:"AgentFlow",tagline:"AI Workflow Orchestration"},oZ={projects:"Projects",nodes:"Nodes",myNodes:"My Nodes",myFlows:"My Flows",skills:"Skills",mcps:"MCP",feedback:"Feedback",flowEditor:"Flow Editor",settings:"Settings",back:"Back"},aZ={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"},lZ={success:"Success",failed:"Failed",pending:"Pending",running:"Running",skipped:"Skipped"},cZ={agent:"Agent",control:"Control",tool:"Tool",start:"Start",end:"End"},uZ={online:"Engine Online",offline:"Engine Offline",connecting:"Connecting…"},dZ={hub:"AgentFlow Hub",docs:"Documentation",github:"GitHub Repository"},fZ={app:iZ,nav:oZ,common:aZ,status:lZ,nodeTypes:cZ,engine:uZ,links:dZ},pZ="Flow Editor",hZ="Nodes",mZ="Edges",gZ="Properties",yZ={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",openGuide:"Open node guide",guideTitle:"Node Guide",guideSummary:"What this node does",guidePrerequisites:"Before you start",guideSteps:"How to configure it",guideInputs:"Inputs",guideOutputs:"Outputs",guideExample:"Configuration example",guideNotes:"Notes",guideRequired:"Required",guideOptional:"Optional",guideDefault:"Default: {{value}}",guideCopy:"Copy example",guideCopied:"Copied",guideClose:"Close node guide"},wZ={title:"Node Properties",noInputPins:"No input pins",noOutputPins:"No output pins",type:"Type",name:"Name",defaultValue:"Default / value",description:"Description / format",required:"Req",showOnNode:"Card",requiredHint:"Mark this pin as required so users know it must be connected or given a value",showOnNodeHint:"Show this pin name on the canvas node card; hidden pins can still be connected",pinRequiredAriaLabel:"{{label}} {{index}} required",pinShowOnNodeAriaLabel:"{{label}} {{index}} show on node card",pinDescriptionAriaLabel:"{{label}} {{index}} format description",conversationOutput:"Conversation & Output",addPin:"Add Pin",addPinAriaLabel:"Add {{label}}",handleHint:"Matches Handle index on canvas ({{prefix}}-0, {{prefix}}-1…). After adding/removing/reordering, existing connections may break — check validation after saving.",handle:"Handle",pinTypeAriaLabel:"{{label}} {{index}} type",pinNameAriaLabel:"{{label}} {{index}} name",pinDefaultAriaLabel:"{{label}} {{index}} default",deletePinAriaLabel:"Delete {{label}} {{index}}",deletePin:"Delete this pin",instanceId:"Node ID",yamlValueNotInList:"(YAML value, not in current list)",inputPins:"Input Pins (INPUT)",outputPins:"Output Pins (OUTPUT)",expand:"Expand",collapse:"Collapse",expandEditScript:"Expand edit script",expandEdit:"Expand edit",editScript:"Edit script",editUserPrompt:"Edit user prompt",scriptPlaceholder:"instances.*.script — full shell command; supports ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir}, ${runDir} and slot names (don't quote placeholders)",scriptPlaceholderExpand:"instances.*.script — full shell command; don't quote ${workspaceRoot}, ${pipelineWorkspace}, ${flowDir} placeholders",bodyPlaceholder:"instances.*.body — supports multiline and ${variables}; type ${ to pick a slot",bodyPlaceholderExpand:"instances.*.body — supports multiline and ${variables}",noDescription:"(No description in current node definition)",modelAriaLabel:"Model",placeholderSlots:"Placeholders: input/output slots",publishToMarketplace:"Publish Node",publishToMarketplaceHint:"Publish the current node to the workspace local marketplace",publishing:"Publishing…",publishRunning:"Publishing to local marketplace…",publishSuccess:"Node published to local marketplace",publishSuccessWithId:"Node published: {{id}}"},xZ={run:"Run Flow",stop:"Stop",resume:"Resume",validate:"Validate",export:"Export",import:"Import"},bZ={nodeList:"Node List",runHistory:"Run History",validation:"Validation Results"},kZ={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"},vZ={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)"},SZ={saving:"Saving...",saved:"Saved",saveFailed:"Save failed",runInTerminal:"Please use terminal to run"},jZ={requirement:"Requirement Analysis",planning:"Technical Planning",code:"Code Execution",test:"Test Regression",normal:"Normal"},NZ={phase:"Phase",allPhasesComplete:"All phases completed",currentPhaseComplete:"Current phase completed, waiting for confirmation..."},_Z={node:"Node",text:"Text",file:"File",bool:"Boolean"},CZ={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"},AZ={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"},EZ={title:"Jump to node",placeholder:"Type node ID or label…",empty:"No matching nodes",hintNavigate:"navigate",hintJump:"jump",hintClose:"close"},IZ={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."},PZ={mainNav:"Main Navigation"},TZ={flowWarningAriaLabel:"Flow validation warnings",reloadFromServer:"Reload flow from server and refresh validation",reloadFromServerShort:"Reload from server",closeBanner:"Close validation warning banner",nodePrefix:"Node",focusNodeAriaLabel:"Select and focus node {{nodeId}} on canvas",slotWarningCount:"Slot validation: {{count}} warnings (hidden)",show:"Show",shortcutHint:"Press ? to view keyboard shortcuts",shortcutHintLabel:"shortcuts",inputSlotNoEdge:' input slot "{{slotName}}" ({{handle}}) has no edge connection',outputSlotNoEdge:' output slot "{{slotName}}" ({{handle}}) has no edge connection'},RZ={title:"AI Assistant",placeholder:"Ask AI to help with this node...",thinking:"Thinking",reply:"Reply",result:"Result",error:"Error",waiting:"Waiting for response...",yourQuestion:"Your question",send:"Send",expand:"Expand conversation",collapse:"Collapse",connecting:"Connecting…",requestFailed:"Request failed",cannotReadStream:"Cannot read response stream",connectTimeout:"Connection timeout (120s), please confirm UI service is running and retry. [CONNECT_TIMEOUT]",aborted:"Aborted",executing:"Executing…",ready:"Ready",done:"Done",inputPlaceholder:"Type your question (⌘/Ctrl+Enter to send)",inputAriaLabel:"Question input",mentionAriaLabel:"Mention: instances and node types",modelLabel:"Model",modelAriaLabel:"Conversation model",modelDefault:"Default",modelNotInList:"(not in current list)",stopGeneration:"Stop generation",conversationOutput:"Conversation & Output",collapseAriaLabel:"Collapse",closeSidebar:"Close sidebar",endConversation:"End conversation (will stop generation)",closeConversation:"Close conversation",newConversation:"New conversation",switchConversation:"Switch conversation",selectedNodesAriaLabel:"Selected nodes list",selectedNodesEmpty:"Select nodes on canvas, or use @ in the input to pick Instances or Node types",removeFromInput:"Remove @{{id}} from input",deselectNode:"Deselect {{id}}",taskPlan:`📋 Task Plan ({{count}} steps):
|
|
287
|
+
{{summary}}`,step:"Step {{current}}/{{total}}: {{description}}",phaseGeneration:`Phased generation ({{count}} phases): {{labels}}
|
|
288
|
+
Current: {{current}}`,phaseComplete:"{{phaseName}} completed. Next phase: {{nextPhase}}",nextPhase:"Next phase",continuePhase:"Continue {{label}}",skipRemainingPhases:"Please complete all remaining steps at once (skip phased confirmation)",phaseProgress:"Phase progress",phaseReviewLabel:"Phase options",phaseReviewHint:'This phase is complete. Review the canvas, then continue to "{{nextPhase}}".',phaseReviewContinue:"Continue: {{label}}",phaseReviewSkip:"Skip — finish remaining in one pass",stepsAriaLabel:"Task steps progress",phasesAriaLabel:"Generation phases progress",phaseNumber:"Phase {{index}}",stepRoleLabel:"Role: {{role}}",stepInstanceLabel:"Instance: {{instanceId}}",pageRefreshReset:"Reset after page refresh",conversationLabel:"Conversation {{n}}"},MZ={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"},$Z={nodePalette:"Node Palette",noPipelineSelected:"No pipeline selected",moreRuns:"+{{count}} more",moreFlows:"+{{count}} more flows",runId:"Run ID: {{id}}"},LZ={connectingApi:"Connecting to /api/flow/run…",connectingApiResume:"Connecting to /api/flow/run (resuming run uuid={{uuid}})…",connectedReceiving:"Connected to execution stream, receiving NDJSON output…",noBody:"Response has no body (cannot stream), please check browser and agentflow ui version",nodeStart:"▶ Starting: {{instanceId}}",nodeStartWithLabel:"▶ Starting: {{instanceId}} ({{label}})",nodeDone:"✓ Done: {{instanceId}}",nodeDoneWithElapsed:"✓ Done: {{instanceId}} ({{elapsed}})",nodeFailed:"✗ Failed: {{instanceId}}",pipelineStart:"Pipeline started (uuid={{uuid}})",pipelineDone:"Pipeline completed",pipelineDoneWithElapsed:"Pipeline completed ({{elapsed}})",pipelinePaused:"Pipeline paused: waiting for user input ({{nodes}})",unknownError:"Unknown error",executionEnd:"Execution ended (exit code: {{exitCode}})",executionStopped:"Execution paused",pauseRun:"Pause run (can resume later)",pauseConfirm:"Pause the current run? You can resume from the interrupted node later.",pauseTitle:"Pause run",pauseConfirmOk:"Pause",backPromptTitle:"Back to projects",backPromptMessage:"Pipeline still running. Keep it in the background and exit, or stop it and return to edit mode?",backBackground:"Run in background & exit",backStopEdit:"Stop & enter edit",resizeConsole:"Drag to resize execution log height",closeLog:"Close log",userCheckContent:"Waiting for user to confirm content for node {{instanceId}}",userAskPrompt:"Waiting for user to choose branch for node {{instanceId}}"},OZ={close:"Close",loading:"Loading…",placeholder:"File content",largeFileWarning:"Large file, editor performance may be affected",reset:"Reset",aiEdit:"AI Edit",aiRunning:"AI processing…",save:"Save",saving:"Saving…",saved:"Saved"},DZ={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"},FZ={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"},zZ={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"},BZ={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"},WZ={invalidPlaceholder:"Invalid placeholder: {{hint}}",empty:"(empty)",inputSubtitle:"Input · {{type}}",inputSubtitleNoType:"Input",outputSubtitle:"Output · {{type}}",outputSubtitleNoType:"Output",runtimeConst:"Runtime constant"},HZ={justNow:"Just now",minutesAgo:"{{n}} min ago",hoursAgo:"{{n}} hr ago",yesterday:"Yesterday",daysAgo:"{{n}} days ago",milliseconds:"{{n}} ms",seconds:"{{n}} s"},VZ={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"},KZ={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."},qZ={title:"Print Output: {{instanceId}}",expand:"Expand",restore:"Restore"},UZ={save:"Save",cancel:"Cancel"},GZ={title:"Run with Params",noParams:"No input params in this flow",run:"Run",cancel:"Cancel"},YZ={title:"Run with Preset",noPresets:"No presets available",default:"Default run",run:"Run",cancel:"Cancel"},JZ={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"},XZ={title:pZ,nodes:hZ,edges:mZ,properties:gZ,node:yZ,nodeProps:wZ,actions:xZ,panel:bZ,palette:kZ,pipeline:vZ,status:SZ,roles:jZ,phases:NZ,types:_Z,runContext:CZ,shortcuts:AZ,jumpPalette:EZ,emptyCanvas:IZ,sidebar:PZ,validation:TZ,composer:RZ,topbar:MZ,palette2:$Z,run:LZ,fileEdit:OZ,settings:DZ,schedule:FZ,history:zZ,nodePropsError:BZ,placeholder:WZ,time:HZ,userCheck:VZ,userAsk:KZ,toolPrint:qZ,provideEdit:UZ,runParams:GZ,runPreset:YZ,runConfig:JZ},QZ="Settings",ZZ={engine:"Engine Settings",preferences:"Global Preferences"},eee={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)."},tee={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..."}},nee={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."},ree={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."},see={title:"Codex CLI",status:{ready:"Ready",notFound:"Not found"},modelPreviewLabel:"Codex model id list",description:"Model list comes from codex debug models --bundled. Run 'codex login' first."},iee={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)"},oee={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"},aee={title:"System Status",normal:"Service normal",abnormal:"Some interfaces abnormal",cursorModels:"Cursor Models",opencodeModels:"OpenCode Models",claudeCodeModels:"Claude Code Models",codexModels:"Codex Models"},lee={title:"Shortcuts",projects:"Projects & Pipelines",flowEditor:"Node Canvas"},cee={title:"Language",description:"Select your preferred language for the interface",options:{zh:"中文",en:"English",ja:"日本語"}},uee={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."},dee={title:QZ,crumb:ZZ,workspace:eee,cursor:tee,opencode:nee,claudeCode:ree,codex:see,env:iee,allowlist:oee,system:aee,shortcuts:lee,language:cee,onboarding:uee},fee={thinking:"Thinking",result:"Result",reply:"Reply",error:"Error"},pee={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)"},hee={send:"Send",stop:"Stop",expand:"Expand",collapse:"Collapse",clear:"Clear"},mee={conversation:"Chat",conversationWithNumber:"Chat {{num}}",default:"Default"},gee={endSession:"End chat (will stop generation)",closeSession:"Close chat",newSession:"New chat",expandComposer:"Expand chat and output"},yee={hint:"Use the bottom input box for AI chat, with @node mentions, model selection, and more"},wee={aiLabels:fee,placeholders:pee,actions:hee,labels:mee,tooltips:gee,rightPanel:yee},xee="Projects",bee="All",kee="Archived",vee="Nodes",See="My Nodes",jee="My Flows",Nee="Skills",_ee="Active Projects",Cee="Archived Pipelines",Aee="Global Nodes",Eee="All Nodes",Iee="My Nodes",Pee="Manage node versions published to the current workspace marketplace, {{count}} total.",Tee="Manage flow snippets published to the current workspace marketplace, {{count}} total.",Ree="Global Skills",Mee="Create New Project",$ee="New Pipeline",Lee="SEARCH PIPELINES...",Oee="SEARCH NODES...",Dee="SEARCH FLOW SNIPPETS...",Fee="SEARCH SKILLS...",zee="Refresh Resources",Bee="Loading pipelines...",Wee="Loading global resources...",Hee="Filter result: {{count}} items (matching title, description, path and tags)",Vee="Archived pipelines can still be opened and edited; files are located in the _archived subdirectory of each pipelines directory.",Kee="Manage your distributed node architectures and monitoring pipelines. Drag flow.yaml or .zip into this page to import shared flows.",qee="Review all globally available node definitions, {{count}} total, including built-in, workspace, and marketplace nodes.",Uee="Review Composer-selectable skills, {{count}} total, including AgentFlow built-ins and workspace skills.",Gee="Executable building blocks for pipeline runtime",Yee="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.",Jee="Published local node packages",Xee="Only node versions published to this workspace marketplace appear here. Inspect details and delete versions that no flow uses.",Qee="Published flow snippets",Zee="Flow snippets published from Pipeline or Workspace canvases appear here. Search and inspect them, then load them from the canvas flow palette.",ete="Operating guides for Composer and agents",tte="Skills tell AI which rules to follow for a task, how to change flows, and how to reuse project conventions.",nte="No archived projects.",rte="No active pipelines; archived items are in the Archived tab.",ste="No global nodes available.",ite="No marketplace nodes have been published.",ote="No flow snippets have been published. Select multiple canvas nodes and publish them first.",ate="No skills available.",lte="No description.",cte='No node matches "{{query}}".',ute='No flow snippet matches "{{query}}".',dte='No skill matches "{{query}}".',fte="{{inputs}} in / {{outputs}} out",pte="Flow Snippet",hte="{{nodes}} nodes / {{edges}} edges",mte="Skill",gte="Node detail",yte="Flow snippet detail",wte="Skill detail",xte="Type",bte="Source",kte="Package",vte="Version",Ste="Path",jte="Editable",Nte="Read only",_te="Editable",Cte="Schema",Ate="Inputs",Ete="Outputs",Ite="Runtime",Pte="Node Body",Tte="Files",Rte="Usage",Mte="No runtime manifest.",$te="No node body or README.",Lte="No previewable files.",Ote="Select a file to preview.",Dte="Binary file preview is not supported.",Fte="Large file; showing the first 256KB only.",zte="No pipelines using this node were found.",Bte="Node Management",Wte="Delete Node Version",Hte="Deleting...",Vte="AgentFlow checks all flow references before deleting; installed or used versions are kept.",Kte="Delete {{id}}@{{version}}? This cannot be undone.",qte="Deleted {{id}}@{{version}}.",Ute="{{count}} flow(s) still use it.",Gte="Flow Snippet Management",Yte="Delete Flow Snippet",Jte="Deleting...",Xte="Deleting it only removes this reusable marketplace snippet. Nodes already loaded onto canvases are not changed.",Qte="Delete {{id}}@{{version}}? This cannot be undone.",Zte="Deleted {{id}}@{{version}}.",ene="No slots",tne="Purpose",nne="This node is an execution unit in a pipeline. Its schema affects canvas wiring, parameter input, and runtime scheduling.",rne="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.",sne="Scale",ine="Flow Preview",one="Edges",ane="Snippet JSON",lne="{{count}} more edge(s)",cne="No previewable nodes.",une="This skill is injected into Composer as context for AI, constraining its decisions, edit strategy, and output format.",dne="SKILL.md Preview",fne="No preview content available.",pne="Select a resource to inspect details.",hne="Failed to load pipeline list.",mne="No pipelines in current workspace.",gne="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.",yne='No pipelines found matching "{{query}}". Try different keywords or clear the search.',wne="Recent Activity",xne="No recent activity",bne="No recent activity matching the keyword",kne="Recent Run",vne="Recent Open",Sne={builtin:"Built-in",workspace:"Workspace",user:"User"},jne={flow:"Flow",global:"Global",marketplace:"Marketplace"},Nne={all:"All",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},_ne={overview:"Overview",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},Cne="Open to edit this pipeline in the node canvas.",Ane={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>"},Ene={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"},Ine={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"},Pne={title:"Delete Pipeline",lead:'This will permanently delete the pipeline directory from disk (including flow.yaml, scripts, etc.) and cannot be undone. Please enter the pipeline ID "{{flowId}}" below to confirm.',confirmLabel:"Confirm Pipeline Name",deleteFailed:"Delete failed",deleteTimeout:"Delete request timed out, please retry (check UI service logs in terminal)",delete:"Delete",deleting:"Deleting...",confirmDelete:"Confirm Delete",cancel:"Cancel",close:"Close"},Tne={title:"Archive Pipeline",lead:'After archiving, the pipeline will be moved to the "Archived" list and can still be opened and edited from there. Please enter the pipeline ID "{{flowId}}" below to confirm.',confirmLabel:"Confirm Pipeline Name",archiveFailed:"Archive failed",archive:"Archive",archiving:"Archiving...",confirmArchive:"Confirm Archive",cancel:"Cancel",close:"Close"},Rne={title:xee,all:bee,archived:kee,nodes:vee,myNodes:See,myFlows:jee,skills:Nee,activeProjects:_ee,archivedPipelines:Cee,globalNodes:Aee,nodeScopeAll:Eee,nodeScopeMine:Iee,myNodesHint:Pee,myFlowsHint:Tee,globalSkills:Ree,createNew:Mee,newPipeline:$ee,searchPipelines:Lee,searchNodes:Oee,searchFlows:Dee,searchSkills:Fee,refreshResources:zee,loadingPipelines:Bee,loadingResources:Wee,filterResult:Hee,archivedHint:Vee,activeHint:Kee,nodesHint:qee,skillsHint:Uee,nodesPurposeTitle:Gee,nodesPurposeDesc:Yee,myNodesPurposeTitle:Jee,myNodesPurposeDesc:Xee,myFlowsPurposeTitle:Qee,myFlowsPurposeDesc:Zee,skillsPurposeTitle:ete,skillsPurposeDesc:tte,noArchived:nte,noActive:rte,noNodes:ste,noMyNodes:ite,noMyFlows:ote,noSkills:ate,noDescription:lte,noNodeMatch:cte,noFlowSnippetMatch:ute,noSkillMatch:dte,nodeSlots:fte,flowSnippet:pte,flowSnippetNodes:hte,skill:mte,nodeDetail:gte,flowDetail:yte,skillDetail:wte,detailType:xte,detailSource:bte,detailPackage:kte,detailVersion:vte,detailPath:Ste,detailEditable:jte,readOnly:Nte,editable:_te,nodeSchema:Cte,nodeInputs:Ate,nodeOutputs:Ete,nodeRuntime:Ite,nodeBody:Pte,nodeFiles:Tte,nodeUsage:Rte,noRuntimeManifest:Mte,noNodeBody:$te,noNodeFiles:Lte,selectNodeFile:Ote,binaryFile:Dte,fileTruncated:Fte,noNodeUsage:zte,myNodeManagement:Bte,deleteMyNode:Wte,deletingMyNode:Hte,deleteMyNodeHint:Vte,deleteMyNodeConfirm:Kte,deleteMyNodeSuccess:qte,deleteMyNodeUsedBy:Ute,myFlowManagement:Gte,deleteMyFlow:Yte,deletingMyFlow:Jte,deleteMyFlowHint:Xte,deleteMyFlowConfirm:Qte,deleteMyFlowSuccess:Zte,noSlots:ene,resourceMeaning:tne,nodesMeaning:nne,myFlowsMeaning:rne,flowSnippetScale:sne,flowSnippetPreview:ine,flowSnippetEdges:one,flowSnippetJson:ane,flowSnippetMoreEdges:lne,noFlowSnippetPreview:cne,skillsMeaning:une,skillPreview:dne,skillPreviewEmpty:fne,selectResource:pne,loadFailed:hne,noPipelines:mne,emptyHint:gne,noMatch:yne,recentActivity:wne,noRecentActivity:xne,noMatchRecent:bne,recentRun:kne,recentOpen:vne,sourceBadge:Sne,resourceSource:jne,resourceFilter:Nne,nodeDetailTabs:_ne,defaultCardDesc:Cne,hubCard:Ane,newPipelineModal:Ene,importModal:Ine,deleteModal:Pne,archiveModal:Tne},Mne="Back",$ne="Next",Lne="Skip",One="Done",Dne="Start Creating",Fne={intro:`Welcome to AgentFlow! This is a visual workflow orchestration tool.
|
|
289
|
+
|
|
290
|
+
Click the button below to create your first pipeline.`,hubIntro:`Don't want to start from scratch?
|
|
291
|
+
|
|
292
|
+
Browse ready-made pipelines on AgentFlow Hub — community-shared flows you can install and run in one click.`},zne={intro:`Now you're in the flow editor.
|
|
293
|
+
|
|
294
|
+
Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
|
|
295
|
+
|
|
296
|
+
The left node panel allows you to freely drag, delete, and adjust connections.`,introEmpty:`The canvas is empty. Start creating your flow!
|
|
297
|
+
|
|
298
|
+
Describe your requirements in natural language in the input box below, and AI will generate the flow graph.
|
|
299
|
+
|
|
300
|
+
The left node panel allows you to freely drag, delete, and adjust connections.`},Bne={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"},Wne={back:Mne,next:$ne,skip:Lne,done:One,startCreate:Dne,projects:Fne,flow:zne,newPipeline:Bne},Hne={name:"AgentFlow",tagline:"AI 工作流编排"},Vne={projects:"项目",nodes:"Nodes",myNodes:"我的 Nodes",myFlows:"我的流程",skills:"Skills",mcps:"MCP",feedback:"意见反馈",flowEditor:"流程编辑器",settings:"设置",back:"返回"},Kne={loading:"加载中…",saving:"保存中…",save:"保存",cancel:"取消",delete:"删除",edit:"编辑",create:"创建",close:"关闭",confirm:"确认",copy:"复制",copied:"已复制!",refresh:"刷新",search:"搜索",filter:"筛选",success:"成功",error:"错误",warning:"警告",info:"信息",done:"完成",pending:"待处理",running:"运行中",notFound:"未找到",required:"必填",optional:"可选"},qne={success:"成功",failed:"失败",pending:"等待",running:"运行中",skipped:"跳过"},Une={agent:"Agent 节点",control:"控制节点",tool:"工具节点",start:"开始",end:"结束"},Gne={online:"引擎在线",offline:"引擎离线",connecting:"连接中…"},Yne={hub:"AgentFlow Hub",docs:"文档",github:"GitHub 仓库"},Jne={app:Hne,nav:Vne,common:Kne,status:qne,nodeTypes:Une,engine:Gne,links:Yne},Xne="流程编辑器",Qne="节点",Zne="连线",ere="属性",tre={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:"编辑内容",openGuide:"查看节点指引",guideTitle:"节点使用指引",guideSummary:"这个节点做什么",guidePrerequisites:"使用前准备",guideSteps:"怎么填写",guideInputs:"输入参数",guideOutputs:"输出结果",guideExample:"配置示例",guideNotes:"注意事项",guideRequired:"必填",guideOptional:"可选",guideDefault:"默认:{{value}}",guideCopy:"复制示例",guideCopied:"已复制",guideClose:"关闭节点指引"},nre={title:"节点属性",noInputPins:"当前无输入引脚",noOutputPins:"当前无输出引脚",type:"类型",name:"名称",defaultValue:"默认值 / value",description:"描述 / 格式",required:"必填",showOnNode:"卡片",requiredHint:"标记为必填,用于提示用户该槽位必须提供值或连线",showOnNodeHint:"是否在画布节点卡片旁展示这个引脚名称;关闭后仍可连线",pinRequiredAriaLabel:"{{label}} {{index}} 是否必填",pinShowOnNodeAriaLabel:"{{label}} {{index}} 是否在节点卡片展示",pinDescriptionAriaLabel:"{{label}} {{index}} 格式描述",conversationOutput:"对话与输出",addPin:"添加引脚",addPinAriaLabel:"添加{{label}}",handleHint:"与画布上 Handle 序号一致({{prefix}}-0、{{prefix}}-1…)。增删或调整顺序后,原有连线可能失效,保存后请留意校验提示。",handle:"Handle",pinTypeAriaLabel:"{{label}} {{index}} 类型",pinNameAriaLabel:"{{label}} {{index}} 名称",pinDefaultAriaLabel:"{{label}} {{index}} 默认值",deletePinAriaLabel:"删除 {{label}} {{index}}",deletePin:"删除此引脚",instanceId:"节点 ID",yamlValueNotInList:"(YAML 中的值,不在当前列表)",inputPins:"输入引脚(INPUT)",outputPins:"输出引脚(OUTPUT)",expand:"展开",collapse:"收起",expandEditScript:"展开编辑 script",expandEdit:"展开编辑",editScript:"编辑 script",editUserPrompt:"编辑用户提示",scriptPlaceholder:"instances.*.script,完整 shell 命令;支持 ${workspaceRoot}、${pipelineWorkspace}、${flowDir}、${runDir} 与各槽位名(勿对占位符再包双引号)",scriptPlaceholderExpand:"instances.*.script,完整 shell 命令;勿对 ${workspaceRoot}、${pipelineWorkspace}、${flowDir} 等占位符再包双引号",bodyPlaceholder:"instances.*.body,支持多行与 ${变量};输入 ${ 选择槽位",bodyPlaceholderExpand:"instances.*.body,支持多行与 ${变量}",noDescription:"(当前节点定义无 description)",modelAriaLabel:"模型",placeholderSlots:"占位符:输入输出槽位",publishToMarketplace:"发布节点",publishToMarketplaceHint:"将当前节点发布到 Workspace 本地节点市场",publishing:"发布中…",publishRunning:"正在发布到本地节点市场…",publishSuccess:"节点已发布到本地节点市场",publishSuccessWithId:"节点已发布:{{id}}"},rre={run:"运行流程",stop:"停止",resume:"继续",validate:"校验",export:"导出",import:"导入"},sre={nodeList:"节点列表",runHistory:"运行历史",validation:"校验结果"},ire={workspace:"工作区",loading:"加载中…",archived:"已归档",noPipelines:"暂无流水线",more:"更多",moreFlows:"更多流程",noRuns:"暂无运行记录",searchNodes:"搜索节点",noComponents:"暂无可用组件(检查节点库目录)",noMatch:"无匹配节点,请调整搜索词",selectPipeline:"从上方选择一条流水线以加载组件与画布",validationWarnings:"校验警告(与 agentflow validate 槽位检查一致)",output:"输出",model:"模型",userDir:"用户目录",toggleRecentActivity:"展开或收起最近打开或最近运行"},ore={selectPipeline:"请从顶部下拉选择一条流水线",loadingProps:"加载节点属性…",pipelineId:"流水线 ID",diskPath:"磁盘路径",storageLocation:"存储位置",introduction:"介绍",introductionPlaceholder:"简要描述这条流水线的用途(写入 flow.yaml 的 ui.description)",metadata:"元数据",nodeCount:"节点数",nodesUnit:"个节点",loading:"加载中…",noRuns:"暂无运行记录(终端执行后会在工作区生成运行目录)"},are={saving:"保存中…",saved:"已保存",saveFailed:"保存失败",runInTerminal:"运行请使用终端"},lre={requirement:"需求拆解",planning:"技术规划",code:"代码执行",test:"测试回归",normal:"普通"},cre={phase:"阶段",allPhasesComplete:"所有阶段完成",currentPhaseComplete:"当前阶段完成,等待确认继续…"},ure={node:"节点",text:"文本",file:"文件",bool:"布尔"},dre={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:"等待"},fre={title:"快捷键",general:"常规",saveDesc:"保存;节点属性侧栏打开时先提交节点再保存 flow",shortcutsLabel:"快捷键",jumpToNode:"按 ID 跳转到节点",openNodePalette:"打开节点面板",canvas:"画布",selectTool:"选择工具",panTool:"平移工具",holdSpacePan:"按住空格临时平移",saveViewport:"保存当前进入视角",selectAll:"全选所有节点",undo:"撤销画布修改",redo:"重做画布修改"},pre={title:"跳转到节点",placeholder:"输入节点 ID 或名称…",empty:"未匹配到节点",hintNavigate:"切换",hintJump:"跳转",hintClose:"关闭"},hre={title:"开始构建你的流程",text:"在下方 AI 输入框中描述你的流程,或从左侧面板拖拽节点到画布",composerHint:"使用 AI Composer 构建 AgentFlow",composerSub:"从左侧拖入节点,或在<strong>下方输入框</strong>中用自然语言描述工作流。<br/>按 <kbd>?</kbd> 查看快捷键。"},mre={mainNav:"主导航"},gre={flowWarningAriaLabel:"流程校验警告",reloadFromServer:"从服务器重新加载流程并刷新校验",reloadFromServerShort:"从服务器重新加载",closeBanner:"关闭校验警告横幅",nodePrefix:"节点",focusNodeAriaLabel:"在画布中选中并定位节点 {{nodeId}}",slotWarningCount:"槽位校验 {{count}} 条(已隐藏)",show:"显示",shortcutHint:"按 ? 查看快捷键",shortcutHintLabel:"快捷键",inputSlotNoEdge:' 的 input 槽位 "{{slotName}}"({{handle}})无对应 edge 连接',outputSlotNoEdge:' 的 output 槽位 "{{slotName}}"({{handle}})无对应 edge 连接'},yre={title:"AI 助手",placeholder:"让 AI 协助编辑此节点…",thinking:"思考",reply:"回复",result:"结果",error:"错误",waiting:"等待响应…",yourQuestion:"您的问题",send:"发送",expand:"展开对话",collapse:"收起",connecting:"连接中…",requestFailed:"请求失败",cannotReadStream:"无法读取响应流",connectTimeout:"连接超时(120s),请确认 UI 服务正在运行并重试。[CONNECT_TIMEOUT]",aborted:"已中止",executing:"执行中…",ready:"就绪",done:"完成",inputPlaceholder:"在此输入问题(⌘/Ctrl+Enter 发送)",inputAriaLabel:"问题输入",mentionAriaLabel:"提及:实例与节点类型",modelLabel:"模型",modelAriaLabel:"对话模型",modelDefault:"默认",modelNotInList:"(不在当前列表)",stopGeneration:"停止生成",conversationOutput:"对话与输出",collapseAriaLabel:"收起",closeSidebar:"关闭侧栏",endConversation:"结束对话(将停止生成)",closeConversation:"关闭对话",newConversation:"新建对话",switchConversation:"切换对话",selectedNodesAriaLabel:"已选节点列表",selectedNodesEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",removeFromInput:"从输入中移除 @{{id}}",deselectNode:"取消选中 {{id}}",taskPlan:`📋 任务规划({{count}} 步):
|
|
301
|
+
{{summary}}`,step:"步骤 {{current}}/{{total}}: {{description}}",phaseGeneration:`分阶段生成({{count}} 阶段):{{labels}}
|
|
302
|
+
当前:{{current}}`,phaseComplete:"{{phaseName}}已完成。下一阶段:{{nextPhase}}",nextPhase:"下一阶段",continuePhase:"继续{{label}}",skipRemainingPhases:"请一次性完成剩余所有步骤(跳过分阶段确认)",phaseProgress:"分阶段进度",phaseReviewLabel:"分阶段选项",phaseReviewHint:"当前阶段完成,请在画布上检查结果,确认无误后进入「{{nextPhase}}」",phaseReviewContinue:"继续:{{label}}",phaseReviewSkip:"跳过,一次性完成剩余",stepsAriaLabel:"任务步骤进度",phasesAriaLabel:"生成阶段进度",phaseNumber:"第 {{index}} 阶段",stepRoleLabel:"角色:{{role}}",stepInstanceLabel:"实例:{{instanceId}}",pageRefreshReset:"页面刷新后重置",conversationLabel:"对话 {{n}}"},wre={currentPipeline:"当前流水线",backToEdit:"返回编辑",backToProjects:"返回项目",executionLog:"执行日志",history:"历史",pipelineSettings:"流水线设置",shortcutsLabel:"快捷键",shortcutsTitle:"快捷键 (?)",deletePipeline:"删除流水线",resumeTitle:"在同一 run 目录继续执行(uuid={{uuid}})",resumeTitleNoUuid:"尚未收到 apply-start,将发起新的 run",rerunTitle:"从头开始新的运行",runOptions:"运行选项",runWithParams:"带参数运行",runWithPreset:"指定预设运行",editRun:"编辑运行参数",startRun:"开始执行",stopRun:"停止后台运行"},xre={nodePalette:"节点调色板",noPipelineSelected:"未选择流水线",moreRuns:"+{{count}} 更多",moreFlows:"+{{count}} 更多流程",runId:"运行 ID: {{id}}"},bre={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}} 的分支"},kre={close:"关闭",loading:"加载中…",placeholder:"文件内容",largeFileWarning:"文件较大,编辑器性能可能受影响",reset:"重置",aiEdit:"AI 修改",aiRunning:"AI 处理中…",save:"保存",saving:"保存中…",saved:"已保存"},vre={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:"已复制"},Sre={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:"定时配置已保存"},jre={title:"执行历史",summary:"执行结果汇总",successCount:"{{count}} 成功",failedCount:"{{count}} 失败",stoppedCount:"{{count}} 已停止",interruptedCount:"{{count}} 已中断",runningCount:"{{count}} 进行中",success:"成功",failed:"失败",stopped:"已停止",interrupted:"已中断",running:"进行中",unknown:"未知",runLabel:"运行 #{{id}}",enterRunView:"进入该次运行的画布与日志态"},Nre={invalidInstanceId:"实例 ID 格式无效:仅允许英文字母、数字、下划线、短横线,且不能以数字开头。",duplicateInstanceId:"该实例 ID 已存在,请换一个。",loadFlowFailed:"读取 flow 失败",loadNodesFailed:"读取节点库失败"},_re={invalidPlaceholder:"无效占位符: {{hint}}",empty:"(空)",inputSubtitle:"输入 · {{type}}",inputSubtitleNoType:"输入",outputSubtitle:"输出 · {{type}}",outputSubtitleNoType:"输出",runtimeConst:"运行时常量"},Cre={justNow:"刚刚",minutesAgo:"{{n}} 分钟前",hoursAgo:"{{n}} 小时前",yesterday:"昨天",daysAgo:"{{n}} 天前",milliseconds:"{{n}} 毫秒",seconds:"{{n}} 秒"},Are={title:"用户确认 ({{instanceId}})",edit:"编辑",save:"保存",cancel:"取消",aiEditPlaceholder:"输入 AI 修改指令,如:删除第二项、合并前两项…",aiEditBtn:"AI 修改",aiEditStarted:"AI 正在修改内容…",aiEditDone:"AI 修改完成",aiEditFailed:"AI 修改失败",contentSaved:"内容已保存",saveFailed:"保存失败",close:"关闭",continue:"继续执行",hint:"编辑或使用 AI 修改后点击保存,然后点击「继续执行」恢复流程"},Ere={title:"用户选择 ({{instanceId}})",hint:"请从下方选项中选择一项以继续流程",submitting:"提交中…",submitFailed:"提交失败",close:"关闭",noOptions:"该节点未配置选项,请先在编辑器中为 output 槽位添加条目。"},Ire={title:"Print 输出: {{instanceId}}",expand:"放大",restore:"还原"},Pre={save:"保存",cancel:"取消"},Tre={title:"带参数运行",noParams:"此流程无输入参数",run:"运行",cancel:"取消"},Rre={title:"指定预设运行",noPresets:"无可用预设",default:"默认运行",run:"运行",cancel:"取消"},Mre={preset:"预设",default:"默认",newPreset:"新建预设",deletePreset:"删除预设",presetNamePlaceholder:"预设名称",inputParams:"输入参数",noProvideNodes:"此流程无 provide 节点",filePathPlaceholder:"文件路径…",stringValuePlaceholder:"值…",presetSaved:"预设已保存",presetDeleted:"预设已删除",savePreset:"保存当前预设",expandInput:"编辑内容"},$re={title:Xne,nodes:Qne,edges:Zne,properties:ere,node:tre,nodeProps:nre,actions:rre,panel:sre,palette:ire,pipeline:ore,status:are,roles:lre,phases:cre,types:ure,runContext:dre,shortcuts:fre,jumpPalette:pre,emptyCanvas:hre,sidebar:mre,validation:gre,composer:yre,topbar:wre,palette2:xre,run:bre,fileEdit:kre,settings:vre,schedule:Sre,history:jre,nodePropsError:Nre,placeholder:_re,time:Cre,userCheck:Are,userAsk:Ere,toolPrint:Ire,provideEdit:Pre,runParams:Tre,runPreset:Rre,runConfig:Mre},Lre="设置",Ore={engine:"引擎设置",preferences:"全局首选项"},Dre={title:"工作区",currentPath:"当前工作区根目录",placeholder:"加载中…",copyPath:"复制路径",description:"流水线与节点清单将相对于此目录解析(由启动 UI 时传入)。"},Fre={title:"Cursor CLI",status:{cached:"已缓存",notCached:"未缓存"},modelPreviewLabel:"Cursor 模型名称列表",modelList:{cached:"模型清单已缓存",empty:"暂无模型列表",count:"{{count}} 条",fetchedAt:"更新 {{time}}",never:"尚未拉取",refresh:"刷新清单",fetching:"拉取中…"}},zre={modelPreviewLabel:"OpenCode 模型名称列表",title:"OpenCode CLI",status:{ready:"就绪",notFound:"未找到"},provider:"方案 / Provider 标识",providerPlaceholder:"例如 bailian-coding-plan",saving:"正在保存并更新清单…",description:"对应 CLI opencode models <provider> 的参数;停止输入后会写入用户目录 config 并刷新 model-lists.json。"},Bre={title:"Claude Code CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Claude Code 模型名称列表",description:"内置模型列表(Claude Code CLI 无 models 子命令);刷新将探测 claude 二进制是否在 PATH 中。首次使用请先执行 claude /login。"},Wre={title:"Codex CLI",status:{ready:"就绪",notFound:"未找到"},modelPreviewLabel:"Codex 模型名称列表",description:"模型列表来自 codex debug models --bundled;首次使用请先执行 codex login。"},Hre={title:"环境变量",note:"当前登录用户私有,运行时优先于服务全局环境变量",noteAdmin:"可配置个人或全局环境变量;个人同名变量优先于全局",saving:"正在保存...",key:"键",value:"值",scope:"范围",personal:"个人",global:"全局",add:"添加",delete:"删除 {{key}}",invalidKey:"环境变量名必须以字母或下划线开头,且只能包含字母、数字和下划线。",newKey:"新环境变量键",newValue:"值(密钥请谨慎)"},Vre={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:"添加"},Kre={title:"系统状态",normal:"服务正常",abnormal:"部分接口异常",cursorModels:"Cursor 模型",opencodeModels:"OpenCode 模型",claudeCodeModels:"Claude Code 模型",codexModels:"Codex 模型"},qre={title:"快捷入口",projects:"项目与流水线",flowEditor:"节点画布"},Ure={title:"语言",description:"选择界面显示语言",options:{zh:"中文",en:"English",ja:"日本語"}},Gre={title:"新手引导",description:"重新启动产品引导流程,了解 AgentFlow 的核心功能。",reset:"重置引导",resetSuccess:"已重置,下次访问将自动启动引导"},Yre={title:Lre,crumb:Ore,workspace:Dre,cursor:Fre,opencode:zre,claudeCode:Bre,codex:Wre,env:Hre,allowlist:Vre,system:Kre,shortcuts:qre,language:Ure,onboarding:Gre},Jre={thinking:"思考",result:"结果",reply:"回复",error:"错误"},Xre={input:"让 AI 协助编辑此节点…",waiting:"等待响应…",selectedEmpty:"在画布上选择节点,或在输入框用 @ 选择实例(Instances)或节点类型(Node)",textarea:"描述你的流程或让 AI 协助编辑(⌘/Ctrl+Enter 发送)"},Qre={send:"发送",stop:"停止",expand:"展开",collapse:"收起",clear:"清空"},Zre={conversation:"对话",conversationWithNumber:"对话 {{num}}",default:"默认"},ese={endSession:"结束对话(将停止生成)",closeSession:"关闭对话",newSession:"新建对话",expandComposer:"展开对话与输出"},tse={hint:"使用底部输入框进行 AI 对话,支持 @节点、选择模型等功能"},nse={aiLabels:Jre,placeholders:Xre,actions:Qre,labels:Zre,tooltips:ese,rightPanel:tse},rse="项目",sse="全部",ise="已归档",ose="Nodes",ase="我的 Nodes",lse="我的流程",cse="Skills",use="活跃项目",dse="已归档流水线",fse="全局 Nodes",pse="全部 Nodes",hse="我的 Nodes",mse="管理当前工作区已发布到本地 Marketplace 的节点,共 {{count}} 个。",gse="管理当前工作区已发布到本地 Marketplace 的流程片段,共 {{count}} 个。",yse="全局 Skills",wse="创建新项目",xse="新建流水线",bse="搜索流水线…",kse="搜索 nodes…",vse="搜索流程片段…",Sse="搜索 skills…",jse="刷新资源",Nse="加载流水线列表…",_se="加载全局资源…",Cse="筛选结果:{{count}} 条(匹配标题、描述、路径与标签)",Ase="已归档的流水线仍可打开与编辑;文件位于各 pipelines 目录下的 _archived。",Ese="管理分布式节点架构与监控流水线。可将 flow.yaml 或 .zip 拖入本页导入分享流程。",Ise="查看当前可用的全局节点定义,共 {{count}} 个;包含内置、工作区与 marketplace 节点。",Pse="查看当前 Composer 可选择的 skills,共 {{count}} 个;包含 AgentFlow 内置与工作区 skills。",Tse="流程运行时的可执行积木",Rse="Nodes 决定画布上能拖什么、节点有哪些输入输出,以及运行时走 agent、control、provide 或 marketplace 哪类逻辑。",Mse="已发布的本地节点包",$se="这里仅显示你发布到当前 Workspace Marketplace 的节点版本;可查看详情并删除未被 Flow 使用的版本。",Lse="已发布的流程片段",Ose="这里显示从 Pipeline 或 Workspace 画布发布的流程片段,可搜索、检查内容,并从画布的流程面板中加载复用。",Dse="Composer/Agent 的操作指南",Fse="Skills 告诉 AI 在特定任务里应遵守什么规则、如何修改 flow、如何复用项目约定。",zse="暂无归档项目。",Bse="暂无未归档流水线;已归档项在 Archived 标签中查看。",Wse="暂无可用全局 nodes。",Hse="暂无已发布的 marketplace nodes。",Vse="暂无已发布的流程片段。可在画布中选中多个节点后发布。",Kse="暂无可用 skills。",qse="暂无描述。",Use="未找到与「{{query}}」匹配的 node。",Gse="未找到与「{{query}}」匹配的流程片段。",Yse="未找到与「{{query}}」匹配的 skill。",Jse="{{inputs}} in / {{outputs}} out",Xse="流程片段",Qse="{{nodes}} 节点 / {{edges}} 连线",Zse="Skill",eie="Node 详情",tie="流程片段详情",nie="Skill 详情",rie="类型",sie="来源",iie="包",oie="版本",aie="路径",lie="可编辑",cie="只读",uie="可编辑",die="Schema",fie="输入",pie="输出",hie="Runtime",mie="节点内容",gie="Files",yie="Usage",wie="暂无 runtime manifest。",xie="暂无节点正文或 README。",bie="暂无可预览文件。",kie="请选择文件查看内容。",vie="二进制文件暂不支持预览。",Sie="文件较大,仅显示前 256KB。",jie="暂未发现使用此 node 的流水线。",Nie="节点管理",_ie="删除节点版本",Cie="删除中…",Aie="删除前会检查所有 Flow 引用;仍被安装或使用的版本不会被删除。",Eie="确定删除 {{id}}@{{version}}?此操作不可撤销。",Iie="已删除 {{id}}@{{version}}。",Pie="仍有 {{count}} 个 Flow 使用它。",Tie="流程片段管理",Rie="删除流程片段",Mie="删除中…",$ie="删除后不会影响已经加载到画布里的节点,只会移除 Marketplace 中这个可复用片段。",Lie="确定删除 {{id}}@{{version}}?此操作不可撤销。",Oie="已删除 {{id}}@{{version}}。",Die="无槽位",Fie="作用",zie="这个 node 是 pipeline 的执行单元。它的 schema 会影响画布连线、参数输入和运行时调度。",Bie="流程片段是固定化流程的一部分。加载时会复制这组节点、连线和布局到当前画布,不覆盖已有内容。",Wie="规模",Hie="流程预览",Vie="连线",Kie="片段 JSON",qie="还有 {{count}} 条连线",Uie="暂无可预览节点。",Gie="这个 skill 会作为 Composer 的上下文注入给 AI,用于约束 AI 的判断、修改方式和输出口径。",Yie="SKILL.md 预览",Jie="暂无可预览内容。",Xie="请选择一个资源查看详情。",Qie="未能加载流水线列表。",Zie="当前工作区暂无流水线。",eoe="在仓库根目录执行 {{code1}} 并确认工作区包含 {{code2}} 或用户目录下的流水线;亦可点击 New Pipeline 新建。",toe="未找到与「{{query}}」匹配的流水线。可尝试其他关键词,或点击清除搜索。",noe="最近打开或最近运行",roe="暂无打开或运行记录",soe="暂无与关键词匹配的最近记录",ioe="最近运行",ooe="最近打开",aoe={builtin:"内置",workspace:"工作区",user:"用户"},loe={flow:"Flow",global:"Global",marketplace:"Marketplace"},coe={all:"全部",agent:"Agent",control:"Control",provide:"Provide",marketplace:"Marketplace",builtin:"AgentFlow","workspace-agents":".agents","workspace-cursor":".cursor"},uoe={overview:"概览",schema:"Schema",runtime:"Runtime",files:"Files",usage:"Usage"},doe="打开以在节点画布中编辑此流水线。",foe={eyebrow:"AgentFlow Hub",title:"浏览社区流程",desc:"发现并一键安装社区分享的现成流水线。",cta:"前往 Hub",cliHint:"或通过 CLI 安装:agentflow download <slug>"},poe={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:"关闭"},hoe={title:"导入流水线",lead:"已选择文件「{{filename}}」。请确认流水线名称与保存位置;ZIP 将保留目录内脚本等文件。",nameLabel:"名称(必填)",namePlaceholder:"例如 my_shared_flow",nameHint:"须以英文字母开头,仅可使用字母、数字、下划线 _ 与连字符 -",locationLabel:"保存位置",userDir:"用户目录(~/agentflow/pipelines)",workspaceDir:"当前工作区(.workspace/agentflow/pipelines)",changeFile:"更换文件…",importFailed:"导入失败",importing:"导入中…",importAndOpen:"导入并打开",cancel:"取消",close:"关闭"},moe={title:"删除流水线",lead:"将永久删除磁盘上的流水线目录(含 flow.yaml、脚本等),无法撤销。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",deleteFailed:"删除失败",deleteTimeout:"删除请求超时,请重试(可先检查终端中的 UI 服务日志)",delete:"删除",deleting:"删除中…",confirmDelete:"确认删除",cancel:"取消",close:"关闭"},goe={title:"归档流水线",lead:"归档后流水线将移入「Archived」列表,仍可从该列表打开与编辑。请在下方输入流水线 ID「{{flowId}}」以确认。",confirmLabel:"确认流水线名称",archiveFailed:"归档失败",archive:"归档",archiving:"归档中…",confirmArchive:"确认归档",cancel:"取消",close:"关闭"},yoe={title:rse,all:sse,archived:ise,nodes:ose,myNodes:ase,myFlows:lse,skills:cse,activeProjects:use,archivedPipelines:dse,globalNodes:fse,nodeScopeAll:pse,nodeScopeMine:hse,myNodesHint:mse,myFlowsHint:gse,globalSkills:yse,createNew:wse,newPipeline:xse,searchPipelines:bse,searchNodes:kse,searchFlows:vse,searchSkills:Sse,refreshResources:jse,loadingPipelines:Nse,loadingResources:_se,filterResult:Cse,archivedHint:Ase,activeHint:Ese,nodesHint:Ise,skillsHint:Pse,nodesPurposeTitle:Tse,nodesPurposeDesc:Rse,myNodesPurposeTitle:Mse,myNodesPurposeDesc:$se,myFlowsPurposeTitle:Lse,myFlowsPurposeDesc:Ose,skillsPurposeTitle:Dse,skillsPurposeDesc:Fse,noArchived:zse,noActive:Bse,noNodes:Wse,noMyNodes:Hse,noMyFlows:Vse,noSkills:Kse,noDescription:qse,noNodeMatch:Use,noFlowSnippetMatch:Gse,noSkillMatch:Yse,nodeSlots:Jse,flowSnippet:Xse,flowSnippetNodes:Qse,skill:Zse,nodeDetail:eie,flowDetail:tie,skillDetail:nie,detailType:rie,detailSource:sie,detailPackage:iie,detailVersion:oie,detailPath:aie,detailEditable:lie,readOnly:cie,editable:uie,nodeSchema:die,nodeInputs:fie,nodeOutputs:pie,nodeRuntime:hie,nodeBody:mie,nodeFiles:gie,nodeUsage:yie,noRuntimeManifest:wie,noNodeBody:xie,noNodeFiles:bie,selectNodeFile:kie,binaryFile:vie,fileTruncated:Sie,noNodeUsage:jie,myNodeManagement:Nie,deleteMyNode:_ie,deletingMyNode:Cie,deleteMyNodeHint:Aie,deleteMyNodeConfirm:Eie,deleteMyNodeSuccess:Iie,deleteMyNodeUsedBy:Pie,myFlowManagement:Tie,deleteMyFlow:Rie,deletingMyFlow:Mie,deleteMyFlowHint:$ie,deleteMyFlowConfirm:Lie,deleteMyFlowSuccess:Oie,noSlots:Die,resourceMeaning:Fie,nodesMeaning:zie,myFlowsMeaning:Bie,flowSnippetScale:Wie,flowSnippetPreview:Hie,flowSnippetEdges:Vie,flowSnippetJson:Kie,flowSnippetMoreEdges:qie,noFlowSnippetPreview:Uie,skillsMeaning:Gie,skillPreview:Yie,skillPreviewEmpty:Jie,selectResource:Xie,loadFailed:Qie,noPipelines:Zie,emptyHint:eoe,noMatch:toe,recentActivity:noe,noRecentActivity:roe,noMatchRecent:soe,recentRun:ioe,recentOpen:ooe,sourceBadge:aoe,resourceSource:loe,resourceFilter:coe,nodeDetailTabs:uoe,defaultCardDesc:doe,hubCard:foe,newPipelineModal:poe,importModal:hoe,deleteModal:moe,archiveModal:goe},woe="返回",xoe="下一步",boe="跳过",koe="完成",voe="开始创建",Soe={intro:`欢迎使用 AgentFlow!这是一个可视化流程编排工具。
|
|
303
|
+
|
|
304
|
+
点击下方按钮开始创建你的第一个流水线。`,hubIntro:`不想从零开始?
|
|
305
|
+
|
|
306
|
+
在 AgentFlow Hub 浏览社区分享的现成流水线,一键安装即可运行。`},joe={intro:`现在进入流程编辑器。
|
|
307
|
+
|
|
308
|
+
在下方输入框用自然语言描述你的需求,AI 会自动生成流程图。
|
|
309
|
+
|
|
310
|
+
左侧节点面板可以自由拖拽、删除和调整连接。`,introEmpty:`画布为空,开始创建你的流程吧!
|
|
311
|
+
|
|
312
|
+
在下方输入框用自然语言描述需求,AI 会自动生成流程图。
|
|
313
|
+
|
|
314
|
+
左侧节点面板可以自由拖拽、删除和调整连接。`},Noe={guideTitle:"首次创建提示",guideDesc:"输入名称和描述后,AI 会自动生成流程图。你可以在编辑器中自由调整节点和连接。",nameHintGuide:"例如:MyFirstFlow(字母开头,支持数字和下划线)",descPlaceholderGuide:"例如:实现用户登录功能,包含注册、验证、授权",descHintGuide:"描述越详细,AI 生成的流程越准确",createGuide:"创建并开始编辑",typeNode:"节点引用类型",typeStr:"字符串类型",typeFile:"文件路径类型",typeBool:"布尔值类型"},_oe={back:woe,next:xoe,skip:boe,done:koe,startCreate:voe,projects:Soe,flow:joe,newPipeline:Noe},Coe={en:{common:fZ,flow:XZ,settings:dee,composer:wee,project:Rne,onboarding:Wne},zh:{common:Jne,flow:$re,settings:Yre,composer:nse,project:yoe,onboarding:_oe}};Pr.use(x$).use(MF).init({resources:Coe,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 Aoe=[{code:"zh",name:"中文",flag:"🇨🇳"},{code:"en",name:"English",flag:"🇬🇧"}];function Eoe(e){return Pr.changeLanguage(e)}const Zb="agentflow-settings-opencode-plan-v1",wd="CURSOR_API_KEYS",xd="AGENTFLOW_CURSOR_API_KEY_COOLDOWN_MINUTES",Uw=new Set([wd,xd,"CURSOR_API_KEY_COOLDOWN_MINUTES"]),b$=["cursor","opencode","claudeCode","codex"];function k$(){return{cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}}function ek(e){const t=String(e||"").trim(),n=t.indexOf(" - ");return n>=0?t.slice(0,n).trim():t}function Ma(e){const t=e&&typeof e=="object"&&!Array.isArray(e)?e:{},n={};for(const r of b$)n[r]=Array.isArray(t[r])?[...new Set(t[r].map(ek).filter(Boolean))]:[];return n}function Qi(e){if(!e||typeof e!="object")return k$();const t=e;return{cursor:Array.isArray(t.cursor)?t.cursor.map(String):[],opencode:Array.isArray(t.opencode)?t.opencode.map(String):[],claudeCode:Array.isArray(t.claudeCode)?t.claudeCode.map(String):[],codex:Array.isArray(t.codex)?t.codex.map(String):[],cursorFetchedAt:t.cursorFetchedAt??null,opencodeFetchedAt:t.opencodeFetchedAt??null,claudeCodeFetchedAt:t.claudeCodeFetchedAt??null,codexFetchedAt:t.codexFetchedAt??null}}function Mc(){return`e_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function Ioe(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Fa(e,t="user"){if(!Array.isArray(e))return[];const n=[];for(const r of e){if(!r||typeof r!="object")continue;const i=String(r.key??"").trim(),o=String(r.value??""),a=String(r.id??"").trim()||Mc(),c=String(r.scope??t).trim()==="global"?"global":"user";!i&&!o||n.push({id:a,key:i,value:o,scope:c})}return n}function ZC(e){return Fa(e).map(({key:t,value:n})=>({key:t,value:n}))}function eA(){try{return localStorage.getItem(Zb)??""}catch{return""}}function v$(e){return e?e.length<=6?"•".repeat(e.length):`${"•".repeat(Math.min(20,e.length-4))}${e.slice(-4)}`:""}function Poe(e){const t=String(e||"").trim();if(!t)return[];const n=(r,i)=>{if(typeof r=="string"){const a=r.trim();return a?{id:`legacy_${i}_${a.slice(-6)}`,name:`Key ${i+1}`,key:a,createdAt:""}:null}if(!r||typeof r!="object")return null;const o=String(r.key??"").trim();return o?{id:String(r.id??"").trim()||Mc(),name:String(r.name??"").trim()||`Key ${i+1}`,key:o,createdAt:String(r.createdAt??"").trim()}:null};try{const r=JSON.parse(t);if(Array.isArray(r))return r.map(n).filter(Boolean)}catch{}return t.split(",").map((r,i)=>n(r,i)).filter(Boolean)}function tA(e){const t=Array.isArray(e)?e.map((n,r)=>({id:String((n==null?void 0:n.id)||"").trim()||Mc(),name:String((n==null?void 0:n.name)||"").trim()||`Key ${r+1}`,key:String((n==null?void 0:n.key)||"").trim(),createdAt:String((n==null?void 0:n.createdAt)||"").trim()||new Date().toISOString()})).filter(n=>n.key):[];return JSON.stringify(t)}function Toe(e){const t=String(e||"").trim();return t?t.length<=10?v$(t):`${t.slice(0,4)}${"•".repeat(Math.min(18,t.length-8))}${t.slice(-4)}`:""}function Roe(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 Moe({authUser:e}){const{t,i18n:n}=zr(["common","settings"]),r=n.language||"zh",[i,o]=h.useState(""),[a,l]=h.useState(""),[c,u]=h.useState({cursor:[],opencode:[],claudeCode:[],codex:[],cursorFetchedAt:null,opencodeFetchedAt:null,claudeCodeFetchedAt:null,codexFetchedAt:null}),[f,p]=h.useState(k$()),[d,m]=h.useState(()=>Ma({})),[y,v]=h.useState(!1),[b,g]=h.useState(""),[k,x]=h.useState(""),[_,j]=h.useState(!1),[N,P]=h.useState(!1),[T,z]=h.useState(""),[E,O]=h.useState([]),[D,L]=h.useState(""),[$,V]=h.useState(!1),[W,F]=h.useState(""),[M,H]=h.useState(""),[A,X]=h.useState(!1),[q,B]=h.useState(()=>new Set),[ne,ce]=h.useState(""),[K,ee]=h.useState(""),[re,se]=h.useState(!!(e!=null&&e.isAdmin)),[Q,le]=h.useState(""),[fe,me]=h.useState([]),[De,Ce]=h.useState([]),[Se,Ue]=h.useState(""),[lt,xt]=h.useState(""),[at,ze]=h.useState(!1),[Xe,Bt]=h.useState(!1),[Mt,Qt]=h.useState(""),[de,ke]=h.useState(""),[qe,st]=h.useState(""),[Ee,rt]=h.useState(null),[un,Kt]=h.useState(!1),[yt,pn]=h.useState(!1),[ie,Ne]=h.useState(""),Ye=h.useRef(null),He=h.useRef(!1),It=h.useRef(!1),jt=h.useRef(""),cr=h.useCallback(async()=>{l("");try{const oe=await fetch("/api/ui-context");if(!oe.ok)throw new Error("HTTP "+oe.status);const ve=await oe.json();o(typeof ve.workspaceRoot=="string"?ve.workspaceRoot:"")}catch(oe){l(String(oe.message||oe)),o("")}},[]),$n=h.useCallback(async()=>{x(""),j(!0),g("");try{const oe=await fetch(e!=null&&e.isAdmin?"/api/model-visibility":"/api/model-lists");if(!oe.ok)throw new Error("HTTP "+oe.status);const ve=await oe.json();if(e!=null&&e.isAdmin)u(Qi(ve.modelLists)),p(Qi(ve.allModelLists)),m(Ma(ve.hiddenModels));else{const Re=Qi(ve);u(Re),p(Re),m(Ma({}))}}catch(oe){x(String(oe.message||oe))}finally{j(!1)}},[e==null?void 0:e.isAdmin]),ur=h.useCallback(async()=>{L("");try{const oe=await fetch("/api/user-env"),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);const Re=Fa(Array.isArray(ve.env)?ve.env:[],"user").map(sn=>({...sn,scope:"user"})),Dt=[...e!=null&&e.isAdmin?Fa(Array.isArray(ve.globalEnv)?ve.globalEnv:[],"global").map(sn=>({...sn,scope:"global"})):[],...Re];jt.current=JSON.stringify(Dt),O(Dt)}catch(oe){O([]),L(String(oe.message||oe))}finally{It.current=!0}},[e==null?void 0:e.isAdmin]),rn=h.useCallback(async()=>{if(e!=null&&e.isAdmin){ze(!0),Qt("");try{const oe=await fetch("/api/admin/user-allowlist"),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);const Re=ve.allowlist&&typeof ve.allowlist=="object"?ve.allowlist:{};me(Array.isArray(Re.fileUsers)?Re.fileUsers.map(String):[]),Ce(Array.isArray(Re.envUsers)?Re.envUsers.map(String):[]),Ue(typeof Re.path=="string"?Re.path:"")}catch(oe){Qt(String(oe.message||oe))}finally{ze(!1)}}},[e==null?void 0:e.isAdmin]),gn=h.useCallback(async oe=>{if(e!=null&&e.isAdmin){Bt(!0),Qt("");try{const ve=await fetch("/api/admin/user-allowlist",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({users:oe})}),Re=await ve.json().catch(()=>({}));if(!ve.ok)throw new Error(typeof Re.error=="string"?Re.error:"HTTP "+ve.status);const St=Re.allowlist&&typeof Re.allowlist=="object"?Re.allowlist:{};me(Array.isArray(St.fileUsers)?St.fileUsers.map(String):[]),Ce(Array.isArray(St.envUsers)?St.envUsers.map(String):[]),Ue(typeof St.path=="string"?St.path:"")}catch(ve){Qt(String(ve.message||ve))}finally{Bt(!1)}}},[e==null?void 0:e.isAdmin]),Yn=h.useCallback(async()=>{if(e!=null&&e.isAdmin){Kt(!0),Ne("");try{const oe=await fetch("/api/admin/storage-config"),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);const Re=ve.config&&typeof ve.config=="object"?ve.config:{};rt(Re),ke(typeof Re.dataRoot=="string"?Re.dataRoot:""),st(typeof Re.skillsRoot=="string"?Re.skillsRoot:"")}catch(oe){Ne(String(oe.message||oe))}finally{Kt(!1)}}},[e==null?void 0:e.isAdmin]),gr=h.useCallback(async()=>{if(e!=null&&e.isAdmin){pn(!0),Ne("");try{const oe=await fetch("/api/admin/storage-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({dataRoot:de.trim(),skillsRoot:qe.trim(),migrateLegacySkills:!0})}),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);const Re=ve.config&&typeof ve.config=="object"?ve.config:{};rt(Re),ke(typeof Re.dataRoot=="string"?Re.dataRoot:""),st(typeof Re.skillsRoot=="string"?Re.skillsRoot:"")}catch(oe){Ne(String(oe.message||oe))}finally{pn(!1)}}},[e==null?void 0:e.isAdmin,de,qe]),yn=h.useCallback(async oe=>{const ve=Fa(oe),Re=ve.filter(Dt=>Dt.scope!=="global"),St=ve.filter(Dt=>Dt.scope==="global");V(!0),L("");try{const Dt=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:ZC(Re),...e!=null&&e.isAdmin?{globalEnv:ZC(St)}:{}})}),sn=await Dt.json().catch(()=>({}));if(!Dt.ok)throw new Error(typeof sn.error=="string"?sn.error:"HTTP "+Dt.status);const _n=Fa(Array.isArray(sn.env)?sn.env:[],"user").map(Cs=>({...Cs,scope:"user"})),_s=[...e!=null&&e.isAdmin?Fa(Array.isArray(sn.globalEnv)?sn.globalEnv:[],"global").map(Cs=>({...Cs,scope:"global"})):[],..._n];jt.current=JSON.stringify(_s),O(_s)}catch(Dt){L(String(Dt.message||Dt))}finally{V(!1)}},[e==null?void 0:e.isAdmin]),Pn=h.useCallback(async()=>{x(""),j(!0);try{const oe=await fetch("/api/update-model-lists",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:Q.trim()})}),ve=await oe.json().catch(()=>({}));if(!oe.ok)throw new Error(typeof ve.error=="string"?ve.error:"HTTP "+oe.status);u(Qi(ve.modelLists)),e!=null&&e.isAdmin?await $n():p(Qi(ve.modelLists))}catch(oe){x(String(oe.message||oe))}finally{j(!1)}},[e==null?void 0:e.isAdmin,$n,Q]),nr=h.useCallback(async oe=>{if(!(e!=null&&e.isAdmin))return;const ve=Ma(oe);m(ve),v(!0),g("");try{const Re=await fetch("/api/model-visibility",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hiddenModels:ve})}),St=await Re.json().catch(()=>({}));if(!Re.ok)throw new Error(typeof St.error=="string"?St.error:"HTTP "+Re.status);u(Qi(St.modelLists)),p(Qi(St.allModelLists)),m(Ma(St.hiddenModels))}catch(Re){g(String(Re.message||Re)),$n()}finally{v(!1)}},[e==null?void 0:e.isAdmin,$n]),Wr=h.useCallback((oe,ve,Re)=>{const St=b$.includes(oe)?oe:"cursor",Dt=ek(ve);if(!Dt)return;const sn=Ma(d),_n=new Set(sn[St]);Re?_n.delete(Dt):_n.add(Dt),nr({...sn,[St]:Array.from(_n)})},[d,nr]);h.useEffect(()=>{ur(),e!=null&&e.isAdmin?(cr(),$n(),rn(),Yn(),(async()=>{try{const oe=await fetch("/api/agentflow-config");if(oe.ok){const ve=await oe.json(),Re=typeof ve.opencodeProvider=="string"?ve.opencodeProvider:"";le(Re),Ye.current=Re;try{localStorage.setItem(Zb,Re)}catch{}}else{const ve=eA();le(ve),Ye.current=ve}}catch{const oe=eA();le(oe),Ye.current=oe}finally{He.current=!0}})()):(o(""),He.current=!1)},[e==null?void 0:e.isAdmin,cr,$n,Yn,rn,ur]),h.useEffect(()=>{if(!It.current||JSON.stringify(Fa(E))===jt.current)return;const ve=setTimeout(()=>{yn(E)},350);return()=>clearTimeout(ve)},[E,yn]),h.useEffect(()=>{if(!(e!=null&&e.isAdmin)||!He.current)return;const oe=Q.trim();if(oe===Ye.current)return;const ve=setTimeout(()=>{(async()=>{P(!0),z("");try{const Re=await fetch("/api/agentflow-config",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({opencodeProvider:oe})}),St=await Re.json().catch(()=>({}));if(!Re.ok)throw new Error(typeof St.error=="string"?St.error:"HTTP "+Re.status);Ye.current=oe;try{localStorage.setItem(Zb,oe)}catch{}St.modelLists&&(u(Qi(St.modelLists)),e!=null&&e.isAdmin?$n():p(Qi(St.modelLists)))}catch(Re){z(String(Re.message||Re))}finally{P(!1)}})()},450);return()=>clearTimeout(ve)},[e==null?void 0:e.isAdmin,$n,Q]);const Sn=e!=null&&e.isAdmin?f:c,Jn=Sn.cursor.length>0,Hr=Sn.opencode.length>0,Vn=Sn.claudeCode.length>0,Kn=Sn.codex.length>0,dr=Ma(d),fr={cursor:c.cursor.length,opencode:c.opencode.length,claudeCode:c.claudeCode.length,codex:c.codex.length},qn=h.useCallback((oe,ve,Re)=>{const St=Array.isArray(ve)?ve:[];if(!(e!=null&&e.isAdmin))return s.jsx("pre",{className:"af-set-model-preview","aria-label":Re,children:St.join(`
|
|
315
|
+
`)});const Dt=new Set(dr[oe]||[]);return s.jsxs("div",{className:"af-set-model-visibility","aria-label":Re,children:[s.jsxs("div",{className:"af-set-model-visibility-head",children:[s.jsxs("span",{children:["展示 ",fr[oe]||0," / ",St.length]}),s.jsx("span",{children:y?"保存中":"取消勾选后从模型下拉隐藏"})]}),s.jsx("div",{className:"af-set-model-visibility-list",children:St.map(sn=>{const _n=ek(sn),Xn=!Dt.has(_n);return s.jsxs("label",{className:"af-set-model-visibility-row",children:[s.jsx("input",{type:"checkbox",checked:Xn,disabled:y,onChange:_s=>Wr(oe,sn,_s.target.checked)}),s.jsx("span",{children:sn})]},`${oe}-${sn}`)})})]})},[e==null?void 0:e.isAdmin,dr,y,fr,Wr]),_r=fe.length>0||De.length>0,yr=e!=null&&e.isAdmin?E:E.filter(oe=>!Uw.has(String((oe==null?void 0:oe.key)||"").trim())),kt=e!=null&&e.isAdmin&&re?"global":"user",ct=h.useMemo(()=>E.find(oe=>oe.key===wd&&(oe.scope||"user")===kt)||null,[kt,E]),Zt=h.useMemo(()=>Poe((ct==null?void 0:ct.value)||""),[ct==null?void 0:ct.value]),Nt=h.useMemo(()=>E.find(oe=>oe.key===xd&&(oe.scope||"user")===kt)||null,[kt,E]),jn=Nt!=null&&Nt.value?String(Nt.value):"30",ue=h.useCallback((oe,ve,Re)=>{const St=String(oe||"").trim();if(!St)return;const Dt=String(ve??"");O(sn=>{const _n=sn.find(Xn=>Xn.key===St&&(Xn.scope||"user")===Re);return Dt?_n?sn.map(Xn=>Xn.id===_n.id?{...Xn,value:Dt,scope:Re}:Xn):[{id:Mc(),key:St,value:Dt,scope:Re},...sn]:sn.filter(Xn=>!(Xn.key===St&&(Xn.scope||"user")===Re))})},[]),te=h.useCallback(()=>{const oe=K.trim();if(!oe)return;const ve=[...Zt,{id:Mc(),name:ne.trim()||`Key ${Zt.length+1}`,key:oe,createdAt:new Date().toISOString()}];ue(wd,tA(ve),kt),ce(""),ee("")},[ne,Zt,kt,K,ue]),ye=h.useCallback(oe=>{const ve=Zt.filter(Re=>Re.id!==oe);ue(wd,ve.length?tA(ve):"",kt)},[Zt,kt,ue]),Me=h.useCallback(oe=>{const ve=String(oe||"").replace(/[^\d]/g,"");if(!ve){ue(xd,"",kt);return}const Re=Math.min(1440,Math.max(1,Number(ve)||30));ue(xd,String(Re),kt)},[kt,ue]),Ae=h.useCallback(()=>{var oe;i&&((oe=navigator.clipboard)==null||oe.writeText(i))},[i]),ut=h.useCallback(()=>{const oe=W.trim(),ve=M;if(oe){if(!Ioe(oe)){L(t("settings:env.invalidKey"));return}if(!(e!=null&&e.isAdmin)&&Uw.has(oe)){L("该运行基础设施变量仅管理员可配置。");return}O(Re=>[{id:Mc(),key:oe,value:ve,scope:e!=null&&e.isAdmin&&A?"global":"user"},...Re]),F(""),H("")}},[e==null?void 0:e.isAdmin,A,W,M,t]),Pt=h.useCallback(oe=>{O(ve=>ve.filter(Re=>Re.id!==oe))},[]),Nn=h.useCallback((oe,ve)=>{const Re=String((ve==null?void 0:ve.key)||"").trim();if(!(e!=null&&e.isAdmin)&&Re&&Uw.has(Re)){L("该运行基础设施变量仅管理员可配置。");return}O(St=>St.map(Dt=>Dt.id===oe?{...Dt,...ve}:Dt))},[e==null?void 0:e.isAdmin]),Je=h.useCallback(oe=>{B(ve=>{const Re=new Set(ve);return Re.has(oe)?Re.delete(oe):Re.add(oe),Re})},[]),hn=h.useCallback(()=>{const oe=lt.trim();if(!oe)return;if(!/^[A-Za-z][A-Za-z0-9_-]{0,63}$/.test(oe)){Qt("用户名须以字母开头,仅可使用字母、数字、下划线与连字符,最多 64 字符");return}if(new Set(fe.map(Re=>String(Re||"").trim().toLowerCase())).has(oe.toLowerCase())){xt("");return}xt(""),gn([...fe,oe])},[lt,fe,gn]),rr=h.useCallback(oe=>{const ve=String(oe||"").trim().toLowerCase();ve&&gn(fe.filter(Re=>String(Re||"").trim().toLowerCase()!==ve))},[fe,gn]),dn=h.useCallback(oe=>{const ve=oe.target.value;Eoe(ve)},[]),Tr=oe=>{const ve=Roe(oe,r);return ve?t("settings:cursor.modelList.fetchedAt",{time:ve}):t("settings:cursor.modelList.never")};return s.jsxs("div",{className:"af-settings-page",children:[s.jsx("header",{className:"af-settings-top",children:s.jsxs("div",{className:"af-settings-crumb","aria-label":t("settings:title"),children:[s.jsx("span",{className:"af-settings-crumb-muted",children:t("settings:crumb.engine")}),s.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),s.jsx("span",{className:"af-settings-crumb-active",children:t("settings:crumb.preferences")})]})}),s.jsx("div",{className:"af-settings-body",children:s.jsxs("div",{className:"af-settings-inner",children:[s.jsxs("header",{className:"af-settings-hero",children:[s.jsxs("h1",{className:"af-settings-h1",children:[t("common:app.name")," ",t("settings:title")]}),s.jsx("p",{className:"af-settings-lead",children:e!=null&&e.isAdmin?t("settings:workspace.description"):t("settings:env.note")}),e!=null&&e.isAdmin&&a?s.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,e!=null&&e.isAdmin&&k?s.jsx("p",{className:"af-err af-settings-api-hint",children:k}):null,D?s.jsx("p",{className:"af-err af-settings-api-hint",children:D}):null,ie?s.jsx("p",{className:"af-err af-settings-api-hint",children:ie}):null]}),s.jsx("div",{className:"af-settings-layout",children:s.jsxs("div",{className:"af-settings-bento",children:[e!=null&&e.isAdmin?s.jsxs(s.Fragment,{children:[s.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--low af-set-workspace",children:[s.jsxs("div",{className:"af-set-card-inner",children:[s.jsxs("div",{className:"af-set-card-head",children:[s.jsx("span",{className:"material-symbols-outlined af-set-icon af-set-icon--secondary",children:"folder_managed"}),s.jsx("h2",{className:"af-set-h2",children:t("settings:workspace.title")})]}),s.jsx("label",{className:"af-set-label",htmlFor:"af-workspace-path",children:t("settings:workspace.currentPath")}),s.jsxs("div",{className:"af-set-input-wrap",children:[s.jsx("input",{id:"af-workspace-path",className:"af-set-input af-set-input--mono",type:"text",readOnly:!0,value:i,placeholder:t("common:loading")}),s.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:Ae,"aria-label":t("settings:workspace.copyPath"),disabled:!i,children:s.jsx("span",{className:"material-symbols-outlined",children:"content_copy"})})]}),s.jsx("p",{className:"af-set-hint",children:"当前页面只展示运行时根目录。可被节点加载的代码库和文档目录请在左侧“知识库”里维护。"})]}),s.jsx("div",{className:"af-set-watermark","aria-hidden":!0,children:s.jsx("span",{className:"material-symbols-outlined",children:"account_tree"})})]}),s.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[s.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[s.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"Cursor CLI"}),s.jsx("span",{className:"af-set-badge"+(Jn?" af-set-badge--ok":" af-set-badge--muted"),children:t(Jn?"settings:cursor.status.cached":"settings:cursor.status.notCached")})]}),s.jsxs("div",{className:"af-set-cli-block",children:[s.jsx("div",{className:"af-set-cli-icon",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:Jn?"check_circle":"hourglass_empty"})}),s.jsxs("div",{children:[s.jsx("p",{className:"af-set-cli-title",children:t(Jn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),s.jsx("p",{className:"af-set-cli-mono",children:Jn?t("settings:cursor.modelList.count",{count:c.cursor.length})+(e!=null&&e.isAdmin?` / ${Sn.cursor.length}`:"")+" · "+Tr(c.cursorFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),Jn?qn("cursor",Sn.cursor,t("settings:cursor.modelPreviewLabel")):null,b?s.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:b}):null,s.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Pn(),disabled:_,children:t(_?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),s.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-cursor-pool",children:[s.jsxs("div",{className:"af-set-env-head",children:[s.jsxs("div",{className:"af-set-card-head",children:[s.jsx("div",{className:"af-set-env-icon-wrap",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"key"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"af-set-h2",children:"Cursor API Key 池"}),s.jsx("p",{className:"af-set-card-subtitle",children:"按请求轮换,遇到 usage limit 或 resource_exhausted 会自动尝试下一个 Key。"})]})]}),s.jsxs("span",{className:"af-set-badge"+(Zt.length?" af-set-badge--ok":" af-set-badge--muted"),children:[Zt.length," keys"]})]}),s.jsxs("div",{className:"af-set-cursor-pool-controls",children:[e!=null&&e.isAdmin?s.jsxs("div",{className:"af-set-env-scope-switch af-set-cursor-scope",role:"group","aria-label":"Cursor API Key scope",children:[s.jsx("button",{type:"button",className:re?"":"is-active",onClick:()=>se(!1),children:"个人"}),s.jsx("button",{type:"button",className:re?"is-active":"",onClick:()=>se(!0),children:"全局"})]}):null,s.jsxs("label",{className:"af-set-cursor-cooldown",children:[s.jsx("span",{children:"限额冷却"}),s.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",inputMode:"numeric",value:jn,onChange:oe=>Me(oe.target.value)}),s.jsx("span",{children:"分钟"})]}),s.jsx("span",{className:"af-set-env-note",children:$?"保存中":kt==="global"?"全局配置":"个人配置"})]}),s.jsx("div",{className:"af-set-cursor-key-list",children:Zt.length?Zt.map(oe=>s.jsxs("div",{className:"af-set-cursor-key-row",children:[s.jsxs("div",{className:"af-set-cursor-key-main",children:[s.jsx("strong",{children:oe.name}),s.jsx("code",{children:Toe(oe.key)})]}),s.jsx("span",{className:"af-set-cursor-key-meta",children:oe.createdAt?new Date(oe.createdAt).toLocaleString():"历史 Key"}),s.jsx("button",{type:"button",className:"af-set-env-del af-set-cursor-key-delete","aria-label":`删除 ${oe.name}`,onClick:()=>ye(oe.id),children:s.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},oe.id)):s.jsx("div",{className:"af-set-cursor-key-empty",children:"还没有配置 Key。配置后 Cursor CLI runner 会自动轮换使用。"})}),s.jsxs("div",{className:"af-set-cursor-key-add",children:[s.jsx("input",{className:"af-set-input",value:ne,onChange:oe=>ce(oe.target.value),placeholder:"名称,例如 Team Key 1"}),s.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:K,onChange:oe=>ee(oe.target.value),placeholder:"Cursor API Key"}),s.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:te,disabled:!K.trim(),children:[s.jsx("span",{className:"material-symbols-outlined",children:"add"}),"添加 Key"]})]}),s.jsxs("p",{className:"af-set-hint",children:["保存到 ",wd,";冷却时间保存到 ",xd,"。个人配置会覆盖全局配置。"]})]}),s.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[s.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[s.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:"OpenCode"}),s.jsx("span",{className:"af-set-badge"+(Hr?" af-set-badge--ok":" af-set-badge--err"),children:t(Hr?"settings:opencode.status.ready":"settings:opencode.status.notFound")})]}),s.jsx("p",{className:"af-set-p",children:t("settings:opencode.description")}),s.jsxs("div",{children:[s.jsx("label",{className:"af-set-label-sm",htmlFor:"af-opencode-plan",children:t("settings:opencode.provider")}),s.jsx("input",{id:"af-opencode-plan",className:"af-set-input af-set-input--sm af-set-input--mono",type:"text",value:Q,onChange:oe=>le(oe.target.value),placeholder:t("settings:opencode.providerPlaceholder"),autoComplete:"off"}),N?s.jsx("p",{className:"af-set-hint af-set-hint--inline","aria-live":"polite",children:t("settings:opencode.saving")}):null,T?s.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",role:"alert",children:T}):null]}),Hr?s.jsxs(s.Fragment,{children:[s.jsx("p",{className:"af-set-cli-mono af-set-cli-mono--block",children:t("settings:cursor.modelList.count",{count:c.opencode.length})+(e!=null&&e.isAdmin?` / ${Sn.opencode.length}`:"")+" · "+Tr(c.opencodeFetchedAt)}),qn("opencode",Sn.opencode,t("settings:opencode.modelPreviewLabel"))]}):null,s.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Pn(),disabled:_,children:t(_?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),s.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[s.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[s.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:claudeCode.title")}),s.jsx("span",{className:"af-set-badge"+(Vn?" af-set-badge--ok":" af-set-badge--err"),children:t(Vn?"settings:claudeCode.status.ready":"settings:claudeCode.status.notFound")})]}),s.jsxs("div",{className:"af-set-cli-block",children:[s.jsx("div",{className:"af-set-cli-icon",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:Vn?"check_circle":"hourglass_empty"})}),s.jsxs("div",{children:[s.jsx("p",{className:"af-set-cli-title",children:t(Vn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),s.jsx("p",{className:"af-set-cli-mono",children:Vn?t("settings:cursor.modelList.count",{count:c.claudeCode.length})+(e!=null&&e.isAdmin?` / ${Sn.claudeCode.length}`:"")+" · "+Tr(c.claudeCodeFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),s.jsx("p",{className:"af-set-p",children:t("settings:claudeCode.description")}),Vn?qn("claudeCode",Sn.claudeCode,t("settings:claudeCode.modelPreviewLabel")):null,s.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Pn(),disabled:_,children:t(_?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]}),s.jsxs("section",{className:"af-set-card af-set-card--narrow af-set-card--high",children:[s.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[s.jsx("h2",{className:"af-set-h2 af-set-h2--caps",children:t("settings:codex.title")}),s.jsx("span",{className:"af-set-badge"+(Kn?" af-set-badge--ok":" af-set-badge--err"),children:t(Kn?"settings:codex.status.ready":"settings:codex.status.notFound")})]}),s.jsxs("div",{className:"af-set-cli-block",children:[s.jsx("div",{className:"af-set-cli-icon",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--tertiary",children:Kn?"check_circle":"hourglass_empty"})}),s.jsxs("div",{children:[s.jsx("p",{className:"af-set-cli-title",children:t(Kn?"settings:cursor.modelList.cached":"settings:cursor.modelList.empty")}),s.jsx("p",{className:"af-set-cli-mono",children:Kn?t("settings:cursor.modelList.count",{count:c.codex.length})+(e!=null&&e.isAdmin?` / ${Sn.codex.length}`:"")+" · "+Tr(c.codexFetchedAt):t("settings:cursor.modelList.refresh")})]})]}),s.jsx("p",{className:"af-set-p",children:t("settings:codex.description")}),Kn?qn("codex",Sn.codex,t("settings:codex.modelPreviewLabel")):null,s.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:()=>Pn(),disabled:_,children:t(_?"settings:cursor.modelList.fetching":"settings:cursor.modelList.refresh")})]})]}):null,s.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-env",children:[s.jsxs("div",{className:"af-set-env-head",children:[s.jsxs("div",{className:"af-set-card-head",children:[s.jsx("div",{className:"af-set-env-icon-wrap",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"variables"})}),s.jsx("h2",{className:"af-set-h2",children:t("settings:env.title")})]}),s.jsx("span",{className:"af-set-env-note",children:$?t("settings:env.saving"):e!=null&&e.isAdmin?t("settings:env.noteAdmin"):t("settings:env.note")})]}),s.jsxs("div",{className:"af-set-env-rows"+(e!=null&&e.isAdmin?" af-set-env-rows--admin":""),children:[s.jsxs("div",{className:"af-set-env-row af-set-env-row--header","aria-hidden":!0,children:[s.jsx("span",{children:t("settings:env.key")}),e!=null&&e.isAdmin?s.jsx("span",{children:t("settings:env.scope")}):null,s.jsx("span",{children:t("settings:env.value")}),s.jsx("span",{})]}),s.jsxs("div",{className:"af-set-env-row af-set-env-row--draft"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[s.jsx("div",{className:"af-set-env-cell",children:s.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",placeholder:"KEY_NAME",value:W,onChange:oe=>F(oe.target.value),"aria-label":t("settings:env.newKey")})}),e!=null&&e.isAdmin?s.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:s.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[s.jsx("button",{type:"button",className:A?"":"is-active",onClick:()=>X(!1),children:t("settings:env.personal")}),s.jsx("button",{type:"button",className:A?"is-active":"",onClick:()=>X(!0),children:t("settings:env.global")})]})}):null,s.jsx("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:s.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:"password",placeholder:t("settings:env.newValue"),value:M,onChange:oe=>H(oe.target.value),"aria-label":t("settings:env.newValue")})}),s.jsx("div",{className:"af-set-env-actions",children:s.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:ut,disabled:!W.trim(),children:[s.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:env.add")]})})]}),yr.map(oe=>s.jsxs("div",{className:"af-set-env-row"+(e!=null&&e.isAdmin?" af-set-env-row--scoped":""),children:[s.jsx("div",{className:"af-set-env-cell",children:s.jsx("input",{className:"af-set-env-inline af-set-env-inline--key",value:oe.key,onChange:ve=>Nn(oe.id,{key:ve.target.value}),"aria-label":t("settings:env.key"),spellCheck:!1})}),e!=null&&e.isAdmin?s.jsx("div",{className:"af-set-env-cell af-set-env-cell--scope",children:s.jsxs("div",{className:"af-set-env-scope-switch",role:"group","aria-label":t("settings:env.scope"),children:[s.jsx("button",{type:"button",className:oe.scope!=="global"?"is-active":"",onClick:()=>Nn(oe.id,{scope:"user"}),children:t("settings:env.personal")}),s.jsx("button",{type:"button",className:oe.scope==="global"?"is-active":"",onClick:()=>Nn(oe.id,{scope:"global"}),children:t("settings:env.global")})]})}):null,s.jsxs("div",{className:"af-set-env-cell af-set-env-cell--grow af-set-env-cell--value",children:[s.jsx("input",{className:"af-set-env-inline af-set-env-inline--value",type:q.has(oe.id)?"text":"password",value:oe.value,onChange:ve=>Nn(oe.id,{value:ve.target.value}),placeholder:v$(oe.value)||t("settings:env.newValue"),"aria-label":t("settings:env.value")}),s.jsx("button",{type:"button",className:"af-set-env-value-toggle",onClick:()=>Je(oe.id),"aria-label":q.has(oe.id)?"Hide value":"Show value",children:s.jsx("span",{className:"material-symbols-outlined",children:q.has(oe.id)?"visibility_off":"visibility"})})]}),s.jsx("div",{className:"af-set-env-actions",children:s.jsx("button",{type:"button",className:"af-set-env-del","aria-label":t("settings:env.delete",{key:oe.key}),onClick:()=>Pt(oe.id),children:s.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})})]},oe.id))]})]}),e!=null&&e.isAdmin?s.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low",children:[s.jsxs("div",{className:"af-set-env-head",children:[s.jsxs("div",{className:"af-set-card-head",children:[s.jsx("div",{className:"af-set-env-icon-wrap",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"hard_drive_2"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"af-set-h2",children:"AgentFlow Data Root"}),s.jsx("p",{className:"af-set-card-subtitle",children:"配置整个 AgentFlow 数据目录的位置,保存时会迁移当前数据。"})]})]}),s.jsx("span",{className:"af-set-badge"+(Ee!=null&&Ee.envLocked?" af-set-badge--err":" af-set-badge--ok"),children:Ee!=null&&Ee.envLocked?"Env locked":"Configurable"}),s.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void Yn(),disabled:un||yt,children:un?"刷新中...":"刷新"})]}),ie?s.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:ie}):null,s.jsx("label",{className:"af-set-label-sm",htmlFor:"af-agentflow-data-root",children:"Data Root"}),s.jsxs("div",{className:"af-set-input-wrap",children:[s.jsx("input",{id:"af-agentflow-data-root",className:"af-set-input af-set-input--mono",type:"text",value:de,onChange:oe=>ke(oe.target.value),placeholder:"/data1/services/mengmai/agentflow",autoComplete:"off",disabled:!!(Ee!=null&&Ee.envLocked)||yt}),s.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void gr(),"aria-label":"保存 AgentFlow Data Root",disabled:yt||!!(Ee!=null&&Ee.envLocked),children:s.jsx("span",{className:"material-symbols-outlined",children:yt?"hourglass_empty":"save"})})]}),s.jsxs("p",{className:"af-set-hint",children:["当前目录:",s.jsx("code",{children:(Ee==null?void 0:Ee.dataRoot)||de||"-"}),Ee!=null&&Ee.configPath?s.jsxs(s.Fragment,{children:[";配置文件:",s.jsx("code",{children:Ee.configPath})]}):null]}),s.jsxs("p",{className:"af-set-hint",children:["这个目录包含 ",s.jsx("code",{children:"users/"}),"、",s.jsx("code",{children:"pipelines/"}),"、",s.jsx("code",{children:"runBuild/"}),"、",s.jsx("code",{children:"auth/"})," 和 admin 配置。 保存到新绝对路径时会复制旧目录内容;旧目录不会自动删除。",Ee!=null&&Ee.envLocked?" 当前设置了 AGENTFLOW_HOME,需要改环境变量才能生效。":""]}),s.jsx("label",{className:"af-set-label-sm",htmlFor:"af-agentflow-skills-root",children:"Skills Root"}),s.jsxs("div",{className:"af-set-input-wrap",children:[s.jsx("input",{id:"af-agentflow-skills-root",className:"af-set-input af-set-input--mono",type:"text",value:qe,onChange:oe=>st(oe.target.value),placeholder:"/data1/services/mengmai/agentflow/skills",autoComplete:"off",disabled:!!(Ee!=null&&Ee.skillsEnvLocked)||yt}),s.jsx("button",{type:"button",className:"af-set-input-suffix",onClick:()=>void gr(),"aria-label":"保存 AgentFlow Skills Root",disabled:yt||!!(Ee!=null&&Ee.skillsEnvLocked),children:s.jsx("span",{className:"material-symbols-outlined",children:yt?"hourglass_empty":"save"})})]}),s.jsxs("p",{className:"af-set-hint",children:["当前 Skills:",s.jsx("code",{children:(Ee==null?void 0:Ee.skillsRoot)||qe||"-"}),Ee!=null&&Ee.legacySkillsRootExists?s.jsxs(s.Fragment,{children:[";保存时会补迁移旧目录 ",s.jsx("code",{children:Ee.legacySkillsRoot})," 中缺失的 skills。"]}):null]}),s.jsxs("p",{className:"af-set-hint",children:["SkillHub 新安装、更新和卸载都作用于 Skills Root;普通用户只通过 Workspace 的 Load Skills 使用。",Ee!=null&&Ee.skillsEnvLocked?" 当前设置了 AGENTFLOW_SKILLS_ROOT,需要改环境变量才能生效。":""]})]}):null,e!=null&&e.isAdmin?s.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--allowlist",children:[s.jsxs("div",{className:"af-set-env-head",children:[s.jsxs("div",{className:"af-set-card-head",children:[s.jsx("div",{className:"af-set-env-icon-wrap",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"manage_accounts"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"af-set-h2",children:t("settings:allowlist.title")}),s.jsx("p",{className:"af-set-card-subtitle",children:t("settings:allowlist.description")})]})]}),s.jsx("span",{className:"af-set-badge"+(_r?" af-set-badge--ok":" af-set-badge--muted"),children:t(_r?"settings:allowlist.enabled":"settings:allowlist.open")}),s.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:()=>void rn(),disabled:at,children:t(at?"settings:allowlist.refreshing":"common:common.refresh")})]}),Mt?s.jsx("p",{className:"af-err af-set-hint af-set-hint--inline",children:Mt}):null,Se?s.jsxs("p",{className:"af-set-hint af-set-hint--inline",children:[t("settings:allowlist.file"),":",s.jsx("code",{children:Se})]}):null,s.jsxs("div",{className:"af-allowlist-grid",children:[s.jsxs("div",{className:"af-allowlist-main",children:[s.jsxs("div",{className:"af-allowlist-head",children:[s.jsx("span",{children:t("settings:allowlist.fileList")}),s.jsx("span",{children:Xe?t("settings:allowlist.saving"):t("settings:allowlist.userCount",{count:fe.length})})]}),s.jsx("div",{className:"af-allowlist-list",children:fe.length>0?fe.map(oe=>s.jsxs("div",{className:"af-allowlist-row",children:[s.jsx("span",{className:"af-allowlist-name",children:oe}),s.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>rr(oe),"aria-label":t("settings:allowlist.remove",{username:oe}),disabled:Xe,children:s.jsx("span",{className:"material-symbols-outlined",children:"delete_outline"})})]},oe)):s.jsx("div",{className:"af-allowlist-empty",children:t("settings:allowlist.emptyFile")})}),s.jsxs("div",{className:"af-allowlist-add",children:[s.jsx("input",{className:"af-set-input af-set-input--sm af-set-input--mono",value:lt,onChange:oe=>xt(oe.target.value),onKeyDown:oe=>{oe.key==="Enter"&&hn()},placeholder:"username",autoComplete:"off"}),s.jsxs("button",{type:"button",className:"af-set-btn-add",onClick:hn,disabled:Xe||!lt.trim(),children:[s.jsx("span",{className:"material-symbols-outlined",children:"add"}),t("settings:allowlist.add")]})]})]}),s.jsxs("div",{className:"af-allowlist-side",children:[s.jsxs("div",{className:"af-allowlist-head",children:[s.jsx("span",{children:t("settings:allowlist.envList")}),s.jsx("span",{children:t("settings:allowlist.readonly")})]}),s.jsx("div",{className:"af-allowlist-env-list",children:De.length>0?De.map(oe=>s.jsx("code",{children:oe},oe)):s.jsx("span",{children:t("settings:allowlist.emptyEnv")})}),s.jsx("p",{className:"af-set-hint af-set-hint--inline",children:t("settings:allowlist.unionHint")})]})]})]}):null,s.jsxs("section",{className:"af-settings-rail","aria-label":t("settings:title"),children:[e!=null&&e.isAdmin?s.jsxs("div",{className:"af-set-rail-card af-set-rail-card--accent",children:[s.jsxs("div",{className:"af-set-rail-inner",children:[s.jsx("h3",{className:"af-set-rail-h3",children:t("settings:system.title")}),s.jsxs("div",{className:"af-set-health-line",children:[s.jsx("span",{className:"af-set-pulse-dot","aria-hidden":!0}),s.jsx("span",{className:"af-set-health-label",children:t(!a&&!k?"settings:system.normal":"settings:system.abnormal")})]}),s.jsxs("div",{className:"af-set-meter",children:[s.jsxs("div",{className:"af-set-meter-row",children:[s.jsx("span",{children:t("settings:system.cursorModels")}),s.jsx("span",{children:c.cursor.length})]}),s.jsx("div",{className:"af-set-meter-bar",children:s.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.cursor.length>0?12+c.cursor.length*3:4)}%`}})})]}),s.jsxs("div",{className:"af-set-meter",children:[s.jsxs("div",{className:"af-set-meter-row",children:[s.jsx("span",{children:t("settings:system.opencodeModels")}),s.jsx("span",{children:c.opencode.length})]}),s.jsx("div",{className:"af-set-meter-bar",children:s.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.opencode.length>0?12+c.opencode.length*3:4)}%`}})})]}),s.jsxs("div",{className:"af-set-meter",children:[s.jsxs("div",{className:"af-set-meter-row",children:[s.jsx("span",{children:t("settings:system.claudeCodeModels")}),s.jsx("span",{children:c.claudeCode.length})]}),s.jsx("div",{className:"af-set-meter-bar",children:s.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.claudeCode.length>0?12+c.claudeCode.length*3:4)}%`}})})]}),s.jsxs("div",{className:"af-set-meter",children:[s.jsxs("div",{className:"af-set-meter-row",children:[s.jsx("span",{children:t("settings:system.codexModels")}),s.jsx("span",{children:c.codex.length})]}),s.jsx("div",{className:"af-set-meter-bar",children:s.jsx("div",{className:"af-set-meter-fill",style:{width:`${Math.min(100,c.codex.length>0?12+c.codex.length*3:4)}%`}})})]})]}),s.jsx("div",{className:"af-set-rail-watermark","aria-hidden":!0,children:s.jsx("span",{className:"material-symbols-outlined",children:"vital_signs"})})]}):null,s.jsxs("div",{className:"af-set-rail-card",children:[s.jsx("h3",{className:"af-set-rail-h3 af-set-rail-h3--sm",children:t("settings:language.title")}),s.jsxs("div",{className:"af-set-language-selector",children:[s.jsx("select",{className:"af-set-input af-set-input--sm",value:r,onChange:dn,"aria-label":t("settings:language.description"),children:Aoe.map(oe=>s.jsxs("option",{value:oe.code,children:[oe.flag," ",oe.name]},oe.code))}),s.jsx("p",{className:"af-set-hint",children:t("settings:language.description")})]})]})]})]})})]})})]})}function $oe(e){const t=Number(e||0);return!Number.isFinite(t)||t<=0?"-":new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",second:"2-digit"}).format(new Date(t))}function Loe(e){return e==="thinking"?"Thinking":e==="tool"?"工具":e==="error"?"错误":e==="result"?"结果":"过程"}function Ooe(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":t}function Doe({run:e,onClose:t}){const[n,r]=h.useState(null),[i,o]=h.useState(!1),[a,l]=h.useState(""),[c,u]=h.useState("timeline"),f=h.useCallback(async({quiet:v=!1}={})=>{if(e!=null&&e.runId){v||o(!0),l("");try{const b=new URLSearchParams({runType:e.runType||"pipeline",userId:e.userId||"",flowId:e.flowId||"",flowSource:e.flowSource||"user",runId:e.runId}),g=await fetch(`/api/admin/run-detail?${b.toString()}`),k=await g.json().catch(()=>({}));if(!g.ok)throw new Error(k.error||`HTTP ${g.status}`);r(k)}catch(b){l(String((b==null?void 0:b.message)||b))}finally{v||o(!1)}}},[e==null?void 0:e.flowId,e==null?void 0:e.flowSource,e==null?void 0:e.runId,e==null?void 0:e.runType,e==null?void 0:e.userId]);h.useEffect(()=>{r(null),u("timeline"),f()},[f]),h.useEffect(()=>{if((e==null?void 0:e.status)!=="running")return;const v=window.setInterval(()=>{document.hidden||f({quiet:!0})},5e3);return()=>window.clearInterval(v)},[f,e==null?void 0:e.status]);const p=Array.isArray(n==null?void 0:n.events)?n.events:[],d=h.useMemo(()=>p.filter(v=>(v==null?void 0:v.kind)==="thinking"),[p]),m=Array.isArray(n==null?void 0:n.rawLines)?n.rawLines:[],y=c==="thinking"?d:p;return s.jsx("div",{className:"af-admin-run-detail-overlay",role:"presentation",onMouseDown:t,children:s.jsxs("aside",{className:"af-admin-run-detail",role:"dialog","aria-modal":"true","aria-label":"Run 详情",onMouseDown:v=>v.stopPropagation(),children:[s.jsxs("header",{className:"af-admin-run-detail__head",children:[s.jsxs("div",{children:[s.jsxs("span",{className:"af-admin-run-detail__eyebrow",children:[e.runType==="workspace"?"Workspace Run":"Pipeline Run"," · ",Ooe(e.status)]}),s.jsx("h2",{children:e.flowId||"Run 详情"}),s.jsxs("p",{children:[e.username||e.userId," · ",s.jsx("code",{children:e.runId})]})]}),s.jsxs("div",{className:"af-admin-run-detail__actions",children:[s.jsx("button",{type:"button",onClick:()=>void f(),disabled:i,title:"刷新详情",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"})}),s.jsx("button",{type:"button",onClick:t,title:"关闭",children:s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"close"})})]})]}),s.jsxs("div",{className:"af-admin-run-detail__tabs",role:"tablist","aria-label":"Run 详情分类",children:[s.jsxs("button",{type:"button",className:c==="timeline"?"is-active":"",onClick:()=>u("timeline"),children:["过程 ",s.jsx("span",{children:p.length})]}),s.jsxs("button",{type:"button",className:c==="thinking"?"is-active":"",onClick:()=>u("thinking"),children:["Thinking ",s.jsx("span",{children:d.length})]}),s.jsxs("button",{type:"button",className:c==="raw"?"is-active":"",onClick:()=>u("raw"),children:["原始日志 ",s.jsx("span",{children:m.length})]})]}),n!=null&&n.truncated?s.jsx("div",{className:"af-admin-run-detail__notice",children:"日志较大,当前展示最新的 512 KB / 2000 条记录。"}):null,a?s.jsx("div",{className:"af-admin-run-detail__error",children:a}):null,i&&!n?s.jsx("div",{className:"af-admin-run-detail__empty",children:"正在读取 Run 详情..."}):null,s.jsx("div",{className:"af-admin-run-detail__body",children:c==="raw"?m.length>0?s.jsx("pre",{className:"af-admin-run-detail__raw",children:m.join(`
|
|
316
|
+
`)}):s.jsx("div",{className:"af-admin-run-detail__empty",children:"这个 Run 没有原始日志。"}):y.length>0?s.jsx("div",{className:"af-admin-run-detail__timeline",children:y.map((v,b)=>s.jsxs("article",{className:`af-admin-run-detail__event is-${v.kind||"process"}`,children:[s.jsxs("div",{className:"af-admin-run-detail__event-meta",children:[s.jsx("time",{children:$oe(v.ts)}),s.jsx("span",{className:`af-admin-run-detail__kind is-${v.kind||"process"}`,children:Loe(v.kind)}),s.jsx("span",{children:v.type||"event"}),v.nodeId?s.jsx("code",{children:v.nodeId}):null]}),s.jsx("pre",{children:v.text||"-"})]},v.id||`${v.ts||0}-${b}`))}):s.jsx("div",{className:"af-admin-run-detail__empty",children:c==="thinking"?"该模型或 CLI 没有为这个 Run 输出可记录的 Thinking。":"这个 Run 暂无过程事件。"})})]})})}function qr(e){return new Intl.NumberFormat(void 0,{maximumFractionDigits:0}).format(Math.max(0,Number(e||0)))}function hh(e){return`${Math.round(Math.max(0,Math.min(1,Number(e||0)))*100)}%`}function Gw(e){const t=Math.max(0,Number(e||0));if(!t)return"-";const n=Math.round(t/1e3);if(n<60)return`${n}s`;const r=Math.round(n/60);if(r<60)return`${r}m`;const i=Math.round(r/60);return i<48?`${i}h`:`${Math.round(i/24)}d`}function Foe(e){const t=String(e||"");return t.includes("-")?t.slice(5):t}function Yw(e){if(!e)return"无运行记录";try{return new Intl.DateTimeFormat(void 0,{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}).format(new Date(Number(e)))}catch{return String(e)}}function zoe(e){const t=String(e||"").trim();return t?t.length>18?t.slice(0,8)+"..."+t.slice(-6):t:"-"}function Boe(e){const t=String(e||"unknown");return t==="success"?"成功":t==="failed"?"失败":t==="running"?"运行中":t==="stopped"?"已停止":t==="interrupted"?"中断":"未知"}function Woe({authUser:e}){const{navigate:t}=us(),[n,r]=h.useState(null),[i,o]=h.useState(!1),[a,l]=h.useState(""),[c,u]=h.useState(null),[f,p]=h.useState(null),[d,m]=h.useState([]),[y,v]=h.useState(!1),[b,g]=h.useState(""),k=h.useCallback(async()=>{if(e!=null&&e.isAdmin){o(!0),l("");try{const E=await fetch("/api/admin/usage-dashboard"),O=await E.json().catch(()=>({}));if(!E.ok)throw new Error(typeof O.error=="string"?O.error:"HTTP "+E.status);r(O)}catch(E){r(null),l(String((E==null?void 0:E.message)||E))}finally{o(!1)}}},[e==null?void 0:e.isAdmin]),x=h.useCallback(async E=>{const O=String((E==null?void 0:E.userId)||"").trim();if(!(!(e!=null&&e.isAdmin)||!O)){p({userId:O,username:String((E==null?void 0:E.username)||O)}),m([]),g(""),v(!0);try{const D=new URLSearchParams({userId:O}),L=await fetch(`/api/admin/user-workspaces?${D.toString()}`),$=await L.json().catch(()=>({}));if(!L.ok)throw new Error($.error||"读取用户 Workspace 失败");p($.owner||{userId:O,username:String((E==null?void 0:E.username)||O)}),m(Array.isArray($.workspaces)?$.workspaces:[])}catch(D){g(String(D.message||D))}finally{v(!1)}}},[e==null?void 0:e.isAdmin]),_=h.useCallback(E=>{const O=String((E==null?void 0:E.ownerUserId)||(f==null?void 0:f.userId)||"").trim(),D=String((E==null?void 0:E.id)||"").trim();if(!O||!D)return;const L=new URLSearchParams({flowId:D,flowSource:"user",adminOwnerId:O});E!=null&&E.archived&&L.set("archived","1"),t(`/workspace?${L.toString()}`)},[t,f==null?void 0:f.userId]);h.useEffect(()=>{k()},[k]);const j=Array.isArray(n==null?void 0:n.dailyTrend)?n.dailyTrend:[],N=h.useMemo(()=>{const D={top:20,right:24,bottom:42,left:42},L=980-D.left-D.right,$=250-D.top-D.bottom,V=j.length>0?j:[],W=Math.max(1,...V.map(q=>Number(q.runs||0))),F=Math.max(1,...V.flatMap(q=>[Number(q.users||0),Number(q.pipelines||0)])),M=q=>D.left+(V.length<=1?L/2:q*L/(V.length-1)),H=q=>D.top+$-Math.max(0,Number(q||0))/W*$,A=q=>D.top+$-Math.max(0,Number(q||0))/F*$,X=q=>V.map((B,ne)=>`${ne===0?"M":"L"} ${M(ne)} ${A(B[q])}`).join(" ");return{width:980,height:250,margin:D,innerHeight:$,rows:V,x:M,yRuns:H,yLine:A,lineUsers:X("users"),linePipelines:X("pipelines"),barWidth:Math.min(34,Math.max(12,L/Math.max(1,V.length)*.44))}},[j]),P=(n==null?void 0:n.usage)||{},T=(n==null?void 0:n.totals)||{},z=Array.isArray(n==null?void 0:n.recentRuns)?n.recentRuns:[];return e!=null&&e.isAdmin?s.jsxs("main",{className:"af-admin-usage-page",children:[s.jsxs("section",{className:"af-admin-usage-hero",children:[s.jsxs("div",{children:[s.jsx("p",{className:"af-admin-usage-eyebrow",children:"Admin / Usage"}),s.jsx("h1",{children:"管理看板"}),s.jsx("p",{children:"重点观察使用率、每日趋势、成功率与各用户流水线活跃度。"})]}),s.jsxs("button",{type:"button",onClick:()=>void k(),disabled:i,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"refresh"}),i?"刷新中":"刷新"]})]}),a?s.jsx("div",{className:"af-project-admin-usage__error",children:a}):null,s.jsxs("section",{className:"af-admin-usage-rate-grid","aria-label":"使用率",children:[s.jsxs("div",{children:[s.jsx("span",{children:"7日活跃用户率"}),s.jsx("strong",{children:hh(P.activeUserRate)}),s.jsxs("em",{children:[qr(P.activeUsers)," / ",qr(T.users)," users"]})]}),s.jsxs("div",{children:[s.jsx("span",{children:"7日流水线使用率"}),s.jsx("strong",{children:hh(P.activePipelineRate)}),s.jsxs("em",{children:[qr(P.activePipelines)," / ",qr(T.activePipelines)," active"]})]}),s.jsxs("div",{children:[s.jsx("span",{children:"7日 Run"}),s.jsx("strong",{children:qr(P.runs)}),s.jsxs("em",{children:[qr(P.avgRunsPerDay)," / day"]})]}),s.jsxs("div",{children:[s.jsx("span",{children:"7日成功率"}),s.jsx("strong",{children:hh(P.successRate)}),s.jsxs("em",{children:["失败率 ",hh(P.failureRate)," · avg ",Gw(P.avgDurationMs)]})]})]}),s.jsxs("section",{className:"af-project-admin-usage af-admin-usage-trend",children:[s.jsx("div",{className:"af-project-admin-usage__head",children:s.jsxs("div",{children:[s.jsx("strong",{children:"每日趋势"}),s.jsx("span",{children:"上方看趋势,下方看最近 50 次具体运行。"})]})}),s.jsxs("div",{className:"af-admin-usage-chart",role:"img","aria-label":"最近 14 天运行趋势",children:[s.jsxs("div",{className:"af-admin-usage-chart__legend",children:[s.jsxs("span",{children:[s.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--runs"}),"Runs"]}),s.jsxs("span",{children:[s.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--users"}),"活跃用户"]}),s.jsxs("span",{children:[s.jsx("i",{className:"af-admin-usage-chart__swatch af-admin-usage-chart__swatch--pipelines"}),"活跃流水线"]})]}),s.jsx("div",{className:"af-admin-usage-chart__canvas",children:s.jsxs("svg",{viewBox:`0 0 ${N.width} ${N.height}`,preserveAspectRatio:"xMidYMid meet",children:[s.jsx("line",{className:"af-admin-usage-chart__axis",x1:N.margin.left,y1:N.margin.top+N.innerHeight,x2:N.width-N.margin.right,y2:N.margin.top+N.innerHeight}),[.25,.5,.75,1].map(E=>s.jsx("line",{className:"af-admin-usage-chart__grid",x1:N.margin.left,y1:N.margin.top+N.innerHeight-N.innerHeight*E,x2:N.width-N.margin.right,y2:N.margin.top+N.innerHeight-N.innerHeight*E},E)),N.rows.map((E,O)=>{const D=N.x(O),L=N.yRuns(E.runs),$=N.margin.top+N.innerHeight,V=Math.max(2,$-L);return s.jsxs("g",{children:[s.jsx("rect",{className:"af-admin-usage-chart__run-bar",x:D-N.barWidth/2,y:$-V,width:N.barWidth,height:V,rx:"5",children:s.jsx("title",{children:`${E.date}: ${E.runs} runs`})}),s.jsx("text",{className:"af-admin-usage-chart__value",x:D,y:$+22,children:qr(E.runs)}),s.jsx("text",{className:"af-admin-usage-chart__date",x:D,y:$+42,children:Foe(E.date)})]},E.date)}),N.rows.length>0?s.jsxs(s.Fragment,{children:[s.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--users",d:N.lineUsers}),s.jsx("path",{className:"af-admin-usage-chart__line af-admin-usage-chart__line--pipelines",d:N.linePipelines}),N.rows.map((E,O)=>{const D=N.x(O);return s.jsxs("g",{children:[s.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--users",cx:D,cy:N.yLine(E.users),r:"3.5"}),s.jsx("circle",{className:"af-admin-usage-chart__point af-admin-usage-chart__point--pipelines",cx:D,cy:N.yLine(E.pipelines),r:"3.5"})]},`${E.date}-points`)})]}):null]})})]}),s.jsx("div",{className:"af-project-admin-usage__table-wrap",children:s.jsxs("table",{className:"af-project-admin-usage__table af-admin-usage-table--recent",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"用户"}),s.jsx("th",{children:"流水线"}),s.jsx("th",{children:"运行时间"}),s.jsx("th",{children:"状态"}),s.jsx("th",{children:"耗时"}),s.jsx("th",{children:"Run ID"})]})}),s.jsx("tbody",{children:z.length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,children:"暂无运行明细"})}):z.map(E=>s.jsxs("tr",{className:"af-admin-usage-run-row",role:"button",tabIndex:0,title:"查看 Run 过程与 Thinking",onClick:()=>u(E),onKeyDown:O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),u(E))},children:[s.jsxs("td",{children:[s.jsx("strong",{children:E.username||E.userId||"-"}),s.jsx("span",{children:E.userId||"-"})]}),s.jsxs("td",{children:[s.jsx("strong",{children:E.flowId||"-"}),s.jsxs("span",{children:[E.runType==="workspace"?"Workspace Run":"Pipeline"," · ",E.flowSource||"user"]})]}),s.jsxs("td",{children:[s.jsx("strong",{children:Yw(E.at)}),E.endedAt?s.jsxs("span",{children:["结束 ",Yw(E.endedAt)]}):s.jsx("span",{children:"未结束"})]}),s.jsx("td",{children:s.jsx("span",{className:"af-project-admin-usage__chips",children:s.jsx("em",{children:Boe(E.status)})})}),s.jsx("td",{children:Gw(E.durationMs)}),s.jsx("td",{children:s.jsxs("span",{className:"af-admin-usage-run-link",children:[s.jsx("code",{className:"af-admin-usage-run-id",title:E.runId,children:zoe(E.runId)}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})})]},`${E.userId}:${E.flowSource}:${E.flowId}:${E.runId}:${E.at}`))})]})})]}),s.jsxs("section",{className:"af-project-admin-usage",children:[s.jsx("div",{className:"af-project-admin-usage__head",children:s.jsxs("div",{children:[s.jsx("strong",{children:"用户使用明细"}),s.jsx("span",{children:"按用户汇总 Pipeline 数、Run 次数和最近运行。"})]})}),s.jsx("div",{className:"af-project-admin-usage__table-wrap",children:s.jsxs("table",{className:"af-project-admin-usage__table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:"User"}),s.jsx("th",{children:"Pipeline"}),s.jsx("th",{children:"Runs"}),s.jsx("th",{children:"状态"}),s.jsx("th",{children:"最近运行"}),s.jsx("th",{children:"Workspace"})]})}),s.jsx("tbody",{children:i&&!n?s.jsx("tr",{children:s.jsx("td",{colSpan:6,children:"正在加载..."})}):((n==null?void 0:n.users)||[]).length===0?s.jsx("tr",{children:s.jsx("td",{colSpan:6,children:"暂无用户数据"})}):((n==null?void 0:n.users)||[]).map(E=>{var O,D,L,$,V,W,F,M,H,A,X,q,B;return s.jsxs("tr",{children:[s.jsxs("td",{children:[s.jsx("strong",{children:E.username||E.userId}),s.jsxs("span",{children:[E.userId,E.isAdmin?" · admin":""]})]}),s.jsxs("td",{children:[s.jsx("strong",{children:qr((O=E.pipelines)==null?void 0:O.total)}),s.jsxs("span",{children:[qr((D=E.pipelines)==null?void 0:D.active)," active / ",qr((L=E.pipelines)==null?void 0:L.archived)," archived"]})]}),s.jsxs("td",{children:[s.jsx("strong",{children:qr(($=E.runs)==null?void 0:$.total)}),s.jsxs("span",{children:["avg ",Gw((V=E.runs)==null?void 0:V.avgDurationMs)]})]}),s.jsx("td",{children:s.jsxs("span",{className:"af-project-admin-usage__chips",children:[s.jsxs("em",{children:["成功 ",qr((W=E.runs)==null?void 0:W.success)]}),s.jsxs("em",{children:["失败 ",qr((F=E.runs)==null?void 0:F.failed)]}),s.jsxs("em",{children:["运行中 ",qr((M=E.runs)==null?void 0:M.running)]})]})}),s.jsx("td",{children:(H=E.runs)!=null&&H.lastRunAt?s.jsxs(s.Fragment,{children:[s.jsx("strong",{children:((A=E.runs)==null?void 0:A.lastRunFlowId)||"-"}),s.jsxs("span",{children:[((X=E.runs)==null?void 0:X.lastRunStatus)||"unknown"," · ",Yw(E.runs.lastRunAt)]})]}):s.jsx("span",{children:"无运行记录"})}),s.jsx("td",{children:s.jsxs("button",{type:"button",className:"af-admin-workspace-review-button",disabled:!((q=E.pipelines)!=null&&q.total)||y&&(f==null?void 0:f.userId)===E.userId,onClick:()=>void x(E),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),y&&(f==null?void 0:f.userId)===E.userId?"读取中":`查看 ${qr((B=E.pipelines)==null?void 0:B.total)}`]})})]},E.userId)})})]})})]}),f?s.jsxs("section",{className:"af-project-admin-usage af-admin-user-workspaces",children:[s.jsxs("div",{className:"af-project-admin-usage__head",children:[s.jsxs("div",{children:[s.jsxs("strong",{children:[f.username||f.userId," 的 Workspace"]}),s.jsx("span",{children:"管理员审阅模式:只读查看,不会加入协作成员,也不能保存或运行。"})]}),s.jsx("button",{type:"button",onClick:()=>{p(null),m([]),g("")},children:"关闭"})]}),b?s.jsx("div",{className:"af-project-admin-usage__error",children:b}):null,s.jsx("div",{className:"af-admin-user-workspaces__grid",children:y?s.jsx("p",{children:"正在读取 Workspace..."}):d.length===0?s.jsx("p",{children:"该用户暂无 Workspace。"}):d.map(E=>s.jsxs("button",{type:"button",className:"af-admin-user-workspace-card",onClick:()=>_(E),children:[s.jsx("span",{className:"af-admin-user-workspace-card__icon material-symbols-outlined","aria-hidden":!0,children:E.archived?"inventory_2":"account_tree"}),s.jsxs("span",{className:"af-admin-user-workspace-card__content",children:[s.jsx("strong",{children:E.id}),s.jsx("small",{children:E.description||(E.archived?"已归档 Workspace":"用户 Workspace")})]}),s.jsx("span",{className:"af-admin-user-workspace-card__status",children:E.archived?"已归档":"只读打开"})]},`${E.id}:${E.archived?"archived":"active"}`))})]}):null,c?s.jsx(Doe,{run:c,onClose:()=>u(null)}):null]}):s.jsx("main",{className:"af-admin-usage-page",children:s.jsx("section",{className:"af-project-admin-usage",children:s.jsx("div",{className:"af-project-admin-usage__head",children:s.jsxs("div",{children:[s.jsx("strong",{children:"管理看板"}),s.jsx("span",{children:"需要管理员权限。"})]})})})})}function Hoe({authUser:e}){const[t,n]=h.useState([]),[r,i]=h.useState([]),[o,a]=h.useState(""),[l,c]=h.useState({name:"",description:"",status:"active",members:[]}),[u,f]=h.useState(""),[p,d]=h.useState(""),[m,y]=h.useState(!1),[v,b]=h.useState(""),g=h.useCallback(async()=>{b("");try{const j=await fetch("/api/admin/teams"),N=await j.json().catch(()=>({}));if(!j.ok)throw new Error(N.error||"读取团队失败");const P=Array.isArray(N.teams)?N.teams:[];n(P),i(Array.isArray(N.users)?N.users:[]),a(T=>{var z;return T&&P.some(E=>E.id===T)?T:((z=P[0])==null?void 0:z.id)||""})}catch(j){b(String(j.message||j))}},[]);h.useEffect(()=>{g()},[g]);const k=h.useMemo(()=>t.find(j=>j.id===o)||null,[o,t]);h.useEffect(()=>{if(!k){c({name:"",description:"",status:"active",members:[]});return}c({name:k.name||"",description:k.description||"",status:k.status||"active",members:(k.members||[]).map(j=>j.userId||j)})},[k]);const x=async(j,N)=>{y(!0),b("");try{const P=await fetch("/api/admin/teams",{method:j,headers:{"Content-Type":"application/json"},body:JSON.stringify(N)}),T=await P.json().catch(()=>({}));if(!P.ok)throw new Error(T.error||"更新团队失败");return await g(),T}catch(P){return b(String(P.message||P)),null}finally{y(!1)}};if(!(e!=null&&e.isAdmin))return s.jsx("main",{className:"af-team-admin-page",children:s.jsx("div",{className:"af-workflows-message af-workflows-message--error",children:"仅超级管理员可以管理团队。"})});const _=r.filter(j=>{const N=p.trim().toLowerCase();return!N||`${j.username} ${j.userId}`.toLowerCase().includes(N)});return s.jsxs("main",{className:"af-team-admin-page",children:[s.jsxs("header",{className:"af-team-admin-hero",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Admin / Organization"}),s.jsx("h1",{children:"团队管理"}),s.jsx("p",{children:"划分团队成员,并为团队迭代汇总与 Project 分享提供权限边界。"})]}),s.jsxs("button",{type:"button",onClick:()=>void g(),disabled:m,children:[s.jsx("span",{className:"material-symbols-outlined",children:"refresh"}),"刷新"]})]}),v?s.jsx("div",{className:"af-workflows-message af-workflows-message--error",children:v}):null,s.jsxs("div",{className:"af-team-admin-layout",children:[s.jsxs("aside",{className:"af-team-admin-list",children:[s.jsxs("form",{onSubmit:j=>{j.preventDefault(),u.trim()&&x("POST",{name:u.trim()}).then(N=>{var P;(P=N==null?void 0:N.team)!=null&&P.id&&a(N.team.id),N&&f("")})},children:[s.jsx("input",{value:u,onChange:j=>f(j.target.value),placeholder:"新团队名称"}),s.jsx("button",{type:"submit",disabled:m||!u.trim(),children:s.jsx("span",{className:"material-symbols-outlined",children:"add"})})]}),t.map(j=>s.jsxs("button",{type:"button",className:j.id===o?"is-active":"",onClick:()=>a(j.id),children:[s.jsxs("span",{children:[s.jsx("strong",{children:j.name}),s.jsxs("small",{children:[j.memberCount||0," 位成员"]})]}),j.status==="inactive"?s.jsx("em",{children:"已停用"}):null]},j.id)),t.length?null:s.jsx("p",{children:"还没有团队。"})]}),s.jsx("section",{className:"af-team-admin-detail",children:k?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"af-team-admin-fields",children:[s.jsxs("label",{children:[s.jsx("span",{children:"团队名称"}),s.jsx("input",{value:l.name,onChange:j=>c(N=>({...N,name:j.target.value}))})]}),s.jsxs("label",{children:[s.jsx("span",{children:"状态"}),s.jsxs("select",{value:l.status,onChange:j=>c(N=>({...N,status:j.target.value})),children:[s.jsx("option",{value:"active",children:"启用"}),s.jsx("option",{value:"inactive",children:"停用"})]})]}),s.jsxs("label",{className:"is-wide",children:[s.jsx("span",{children:"说明"}),s.jsx("textarea",{value:l.description,onChange:j=>c(N=>({...N,description:j.target.value})),placeholder:"团队职责或范围"})]})]}),s.jsxs("div",{className:"af-team-admin-members-head",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"团队成员"}),s.jsx("span",{children:"一个用户只能属于一个团队,保存后会自动从原团队移出。"})]}),s.jsx("input",{type:"search",value:p,onChange:j=>d(j.target.value),placeholder:"搜索用户"})]}),s.jsx("div",{className:"af-team-admin-members",children:_.map(j=>{var P;const N=l.members.includes(j.userId);return s.jsxs("label",{className:N?"is-selected":"",children:[s.jsx("input",{type:"checkbox",checked:N,onChange:T=>c(z=>({...z,members:T.target.checked?[...z.members,j.userId]:z.members.filter(E=>E!==j.userId)}))}),s.jsx("span",{className:"material-symbols-outlined",children:"person"}),s.jsxs("span",{children:[s.jsx("strong",{children:j.username}),s.jsxs("small",{children:[j.userId,j.isAdmin?" · Admin":""]})]}),j.teamId&&j.teamId!==k.id?s.jsx("em",{children:((P=t.find(T=>T.id===j.teamId))==null?void 0:P.name)||"其他团队"}):null]},j.userId)})}),s.jsxs("footer",{className:"af-team-admin-actions",children:[s.jsx("button",{type:"button",className:"is-danger",disabled:m||l.members.length>0,onClick:()=>{window.confirm(`删除团队「${k.name}」?`)&&x("DELETE",{teamId:k.id})},children:"删除团队"}),s.jsxs("div",{children:[s.jsx("button",{type:"button",disabled:m,onClick:()=>c({name:k.name,description:k.description||"",status:k.status,members:(k.members||[]).map(j=>j.userId||j)}),children:"重置"}),s.jsx("button",{type:"button",className:"is-primary",disabled:m||!l.name.trim(),onClick:async()=>{await x("PATCH",{teamId:k.id,name:l.name,description:l.description,status:l.status})&&await x("PUT",{teamId:k.id,members:l.members})},children:m?"保存中...":"保存团队"})]})]})]}):s.jsx("div",{className:"af-workflows-message",children:"创建或选择一个团队。"})})]})]})}function Voe(e){if(!e)return"";const t=Date.parse(e);if(Number.isNaN(t))return String(e);try{return new Intl.DateTimeFormat("zh-CN",{dateStyle:"short",timeStyle:"medium"}).format(new Date(t))}catch{return String(e)}}function Koe({authUser:e}){const{navigate:t}=us(),[n,r]=h.useState(""),[i,o]=h.useState(""),[a,l]=h.useState(!1),[c,u]=h.useState(""),[f,p]=h.useState(!1),[d,m]=h.useState([]),[y,v]=h.useState(!1),[b,g]=h.useState(""),k=!!(e!=null&&e.isAdmin),x=h.useCallback(async()=>{if(k){v(!0),g("");try{const j=await fetch("/api/feedback"),N=await j.json().catch(()=>({}));if(!j.ok)throw new Error(N.error||"加载失败");m(Array.isArray(N.feedback)?N.feedback:[])}catch(j){g(String(j.message||j)),m([])}finally{v(!1)}}},[k]);h.useEffect(()=>{x()},[x]);const _=async j=>{if(j.preventDefault(),!a){l(!0),u("");try{const N=await fetch("/api/feedback",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:n,content:i,pageUrl:window.location.href})}),P=await N.json().catch(()=>({}));if(!N.ok)throw new Error(P.error||"提交失败");p(!0),r(""),o("")}catch(N){u(String(N.message||N))}finally{l(!1)}}};return k?s.jsx("main",{className:"af-feedback-page",children:s.jsxs("section",{className:"af-feedback-panel af-feedback-panel--admin",children:[s.jsxs("div",{className:"af-feedback-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),s.jsx("h1",{children:"意见反馈"}),s.jsx("p",{children:"查看用户提交的问题、建议和功能需求。"})]}),s.jsxs("div",{className:"af-feedback-admin-actions",children:[s.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>void x(),disabled:y,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:y?"hourglass_empty":"refresh"}),y?"刷新中...":"刷新"]}),s.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>t("/projects"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]})]}),b?s.jsx("p",{className:"af-err af-feedback-error",children:b}):null,s.jsx("div",{className:"af-feedback-list af-feedback-list--page",children:d.length>0?d.map(j=>s.jsxs("article",{className:"af-feedback-item",children:[s.jsxs("header",{className:"af-feedback-item__head",children:[s.jsxs("div",{children:[s.jsx("h3",{children:j.title||"未命名反馈"}),s.jsxs("p",{children:[s.jsx("span",{children:j.username||j.userId||"unknown"}),s.jsx("span",{children:Voe(j.createdAt)})]})]}),j.contact?s.jsx("span",{className:"af-feedback-item__contact",children:j.contact}):null]}),s.jsx("p",{className:"af-feedback-item__content",children:j.content}),j.pageUrl?s.jsx("code",{className:"af-feedback-item__url",children:j.pageUrl}):null]},j.id)):s.jsx("div",{className:"af-feedback-empty",children:y?"正在加载反馈...":"暂无反馈"})})]})}):s.jsx("main",{className:"af-feedback-page",children:s.jsxs("section",{className:"af-feedback-panel",children:[s.jsxs("div",{className:"af-feedback-head",children:[s.jsxs("div",{children:[s.jsx("span",{className:"af-feedback-eyebrow",children:"Feedback"}),s.jsx("h1",{children:"意见反馈"}),s.jsx("p",{children:"提交使用中遇到的问题、改进建议或功能需求,管理员会在这里统一查看。"})]}),s.jsxs("button",{type:"button",className:"af-feedback-back",onClick:()=>t("/projects"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"arrow_back"}),"返回"]})]}),f?s.jsxs("div",{className:"af-feedback-success",role:"status",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),s.jsxs("div",{children:[s.jsx("strong",{children:"已提交"}),s.jsx("span",{children:"感谢反馈,管理员可以在意见反馈页查看这条记录。"})]})]}):null,s.jsxs("form",{className:"af-feedback-form",onSubmit:_,children:[s.jsxs("label",{className:"af-feedback-field",children:[s.jsx("span",{children:"标题"}),s.jsx("input",{value:n,onChange:j=>r(j.target.value),placeholder:"一句话说明问题或建议",maxLength:120,required:!0})]}),s.jsxs("label",{className:"af-feedback-field",children:[s.jsx("span",{children:"反馈内容"}),s.jsx("textarea",{value:i,onChange:j=>o(j.target.value),placeholder:"描述具体场景、期望表现、实际表现或复现步骤",maxLength:5e3,rows:9,required:!0})]}),c?s.jsx("p",{className:"af-err af-feedback-error",children:c}):null,s.jsx("div",{className:"af-feedback-actions",children:s.jsxs("button",{type:"submit",className:"af-feedback-submit",disabled:a||!n.trim()||!i.trim(),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:a?"hourglass_empty":"send"}),a?"提交中...":"提交反馈"]})})]})]})})}function S$(){return`m_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,8)}`}function nA(e,t=[]){const n=new Set((Array.isArray(t)?t:[]).map(String));return Object.entries(e&&typeof e=="object"?e:{}).map(([r,i])=>({id:S$(),key:r,value:String(i??""),private:n.has(r)}))}function rA(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 Vh(e=null){const t=e!=null&&e.raw&&typeof e.raw=="object"?e.raw:{},n=Array.isArray(t.args)?t.args:Array.isArray(e==null?void 0:e.args)?e.args:[];return{originalName:String((e==null?void 0:e.name)||""),name:String((e==null?void 0:e.name)||""),type:e!=null&&e.url||t.url?"url":"command",url:String((e==null?void 0:e.url)||t.url||""),command:String((e==null?void 0:e.command)||t.command||""),argsText:n.map(String).join(`
|
|
317
|
+
`),description:String((e==null?void 0:e.description)||t.description||""),envRows:nA(t.env||(e==null?void 0:e.env),e==null?void 0:e.privateEnvKeys),headerRows:nA(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 Jw(){return Vh({name:"",raw:{command:""}})}function qoe(e){const n={...e.extraJson.trim()?JSON.parse(e.extraJson):{}};if(e.type==="url")n.url=e.url.trim();else{n.command=e.command.trim();const o=e.argsText.split(/\r?\n/g).map(a=>a.trim()).filter(Boolean);o.length&&(n.args=o)}const r=rA(e.envRows),i=rA(e.headerRows);return Object.keys(r).length&&(n.env=r),Object.keys(i).length&&(n.headers=i),e.description.trim()&&(n.description=e.description.trim()),{name:e.originalName,nextName:e.name.trim(),server:n,privateEnvKeys:e.envRows.filter(o=>o.private).map(o=>String(o.key||"").trim()).filter(Boolean),privateHeaderKeys:e.headerRows.filter(o=>o.private).map(o=>String(o.key||"").trim()).filter(Boolean)}}function sA(e){return e?e.ok?`${e.toolCount||0} tools enabled`:`Error - ${e.error||"Show Output"}`:"未检测"}function iA(e){return e?e.ok?"ok":"error":"unknown"}function tk(e){return e==="ok"?"ok":e==="partial"?"partial":e==="unsupported"?"error":"unknown"}function Uoe(e,t){return e&&e.label||t}async function Xw(e){var n;const t=String(e||"");if(!t)return!1;try{if((n=navigator.clipboard)!=null&&n.writeText&&window.isSecureContext)return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.top="-9999px",r.style.left="-9999px",r.style.opacity="0",document.body.appendChild(r),r.focus(),r.select();const i=document.execCommand("copy");return r.remove(),i}catch{return!1}}function Zv(e){return String(e||"").trim()||"<AGENTFLOW_TOKEN>"}function j$({baseUrl:e="",token:t=""}){return JSON.stringify({mcpServers:{agentflow:{command:"agentflow",args:["mcp"],env:{AGENTFLOW_BASE_URL:String(e||"http://127.0.0.1:8875"),AGENTFLOW_TOKEN:Zv(t)}}}},null,2)}function N$({baseUrl:e="",token:t=""}){const n=JSON.stringify(String(e||"http://127.0.0.1:8875")),r=JSON.stringify(Zv(t));return["[mcp_servers.agentflow]",'command = "agentflow"','args = ["mcp"]',"","[mcp_servers.agentflow.env]",`AGENTFLOW_BASE_URL = ${n}`,`AGENTFLOW_TOKEN = ${r}`].join(`
|
|
318
|
+
`)}function Goe({baseUrl:e="",token:t=""}){const n=String(e||"http://127.0.0.1:8875"),r=j$({baseUrl:n,token:t}),i=N$({baseUrl:n,token:t});return["你是一个 AI Coding Agent。请帮我把 AgentFlow 配置成当前开发环境可用的 MCP server。","","这是一项配置任务,不是调用任务:请修改 Cursor 或 Codex 的 MCP 配置文件,让它们能连接本机 AgentFlow。","","AgentFlow MCP server 信息:","- server name: agentflow","- command: agentflow",'- args: ["mcp"]',`- env.AGENTFLOW_BASE_URL: ${n}`,`- env.AGENTFLOW_TOKEN: ${Zv(t)}`,"","Cursor 配置片段(合并到 .cursor/mcp.json 或 ~/.cursor/mcp.json):","```json",r,"```","","Codex 配置片段(合并到 ~/.codex/config.toml 的 mcp_servers 配置):","```toml",i,"```","","配置要求:","1. 先判断当前仓库主要使用 Cursor、Codex,还是两者都需要配置。","2. 不要覆盖已有 MCP server;只新增或更新名为 `agentflow` 的 server。","3. 保留已有配置文件里的其他字段、注释和 server。","4. 如果配置文件不存在,请创建父目录和配置文件。","5. 不要把 token 打印到最终回复里;如果需要说明,只写 `AGENTFLOW_TOKEN 已写入配置`。","6. 如果 token 仍是 `<AGENTFLOW_TOKEN>` 占位符,请提醒用户需要在配置文件中替换成真实 token,或回到 AgentFlow 的 MCP 页面点击“使用当前登录 Token”后重新复制。","7. 如果外部 Agent 启动 MCP 时找不到 `agentflow` 命令,请把 command 改成本机 agentflow 可执行文件的绝对路径,或先把 agentflow 安装/软链到 PATH。","","配置后验证:","- 如果配置使用 `command: agentflow`,确认外部 Agent 所在环境可以执行这个命令;如果使用绝对路径,则确认路径存在且可执行。","- 通过 MCP 客户端刷新或重启后,确认 `agentflow` server 出现在 MCP server 列表。","- 如果可以做工具探测,只验证 `tools/list` 能看到 `agentflow_list_flows`、`agentflow_run_flow`、`agentflow_get_display_outputs`。","","最终回复只需要说明:配置了哪些文件、是否验证成功、如果失败下一步该检查什么。"].join(`
|
|
319
|
+
`)}function Yoe({server:e}){const t=(e==null?void 0:e.backends)||{},n=[["Cursor",t.cursor],["Codex",t.codex]];return s.jsx("div",{className:"af-mcp-backends",children:n.map(([r,i])=>s.jsxs("div",{className:`af-mcp-backend af-mcp-backend--${tk(i==null?void 0:i.status)}`,children:[s.jsxs("div",{className:"af-mcp-backend-head",children:[s.jsx("strong",{children:r}),s.jsx("span",{children:Uoe(i,"Unknown")})]}),Array.isArray(i==null?void 0:i.reasons)&&i.reasons.length?s.jsx("ul",{children:i.reasons.map(o=>s.jsx("li",{children:o},o))}):s.jsx("p",{children:"当前配置可直接使用。"})]},r))})}function oA({title:e,rows:t,onChange:n,placeholderKey:r="KEY",placeholderValue:i="value"}){const o=(a,l,c)=>n(t.map(u=>u.id===a?{...u,[l]:c}:u));return s.jsxs("div",{className:"af-mcp-field",children:[s.jsxs("div",{className:"af-mcp-field-head",children:[s.jsx("span",{children:e}),s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>n([...t,{id:S$(),key:"",value:"",private:!0}]),children:"添加"})]}),s.jsxs("div",{className:"af-mcp-kv-list",children:[t.length===0?s.jsx("p",{className:"af-set-hint",children:"暂无"}):null,t.map(a=>s.jsxs("div",{className:"af-mcp-kv-row",children:[s.jsx("input",{className:"af-set-input af-set-input--mono",value:a.key,placeholder:r,onChange:l=>o(a.id,"key",l.target.value)}),s.jsx("input",{className:"af-set-input af-set-input--mono",value:a.value,placeholder:i,onChange:l=>o(a.id,"value",l.target.value)}),s.jsxs("label",{className:"af-mcp-private-toggle",title:"只保存到当前 AgentFlow 用户的个人配置",children:[s.jsx("input",{type:"checkbox",checked:!!a.private,onChange:l=>o(a.id,"private",l.target.checked)}),s.jsx("span",{children:"个人"})]}),s.jsx("button",{type:"button",className:"af-set-env-del",onClick:()=>n(t.filter(l=>l.id!==a.id)),"aria-label":"删除",children:s.jsx("span",{className:"material-symbols-outlined",children:"delete"})})]},a.id))]})]})}function Joe(){var ce;const[e,t]=h.useState(""),[n,r]=h.useState([]),[i,o]=h.useState(Jw),[a,l]=h.useState(""),[c,u]=h.useState(!1),[f,p]=h.useState(!1),[d,m]=h.useState(!1),[y,v]=h.useState({}),[b,g]=h.useState(""),[k,x]=h.useState(""),[_,j]=h.useState(()=>{var K;return typeof window<"u"&&((K=window.location)!=null&&K.origin)?window.location.origin:"http://127.0.0.1:8875"}),[N,P]=h.useState(""),[T,z]=h.useState(""),E=h.useMemo(()=>n.find(K=>K.name===a)||null,[a,n]),O=E&&y[E.name]||null,D=h.useMemo(()=>j$({baseUrl:_,token:N}),[_,N]),L=h.useMemo(()=>N$({baseUrl:_,token:N}),[_,N]),$=h.useMemo(()=>Goe({baseUrl:_,token:N}),[_,N]),V=h.useCallback(async()=>{u(!0),g("");try{const K=await fetch("/api/mcps"),ee=await K.json().catch(()=>({}));if(!K.ok)throw new Error(ee.error||"MCP HTTP "+K.status);const re=Array.isArray(ee.servers)?ee.servers:[];t(String(ee.path||"")),r(re),a&&re.some(se=>se.name===a)&&o(Vh(re.find(se=>se.name===a)))}catch(K){g(String(K.message||K))}finally{u(!1)}},[a]);h.useEffect(()=>{V()},[V]);const W=()=>{l(""),o(Jw()),x(""),g("")},F=K=>{l(K.name),o(Vh(K)),x(""),g("")},M=h.useCallback(async()=>{if(!$)return;const K=await Xw($);z(K?"prompt":"copy-failed"),window.setTimeout(()=>z(""),1200)},[$]),H=h.useCallback(async()=>{const K=await Xw(D);z(K?"cursor":"copy-failed"),window.setTimeout(()=>z(""),1200)},[D]),A=h.useCallback(async()=>{const K=await Xw(L);z(K?"codex":"copy-failed"),window.setTimeout(()=>z(""),1200)},[L]),X=h.useCallback(async()=>{try{const K=await fetch("/api/auth/session-token"),ee=await K.json().catch(()=>({}));if(!K.ok)throw new Error(typeof ee.error=="string"?ee.error:"HTTP "+K.status);P(String(ee.token||"")),z("token"),window.setTimeout(()=>z(""),1200)}catch(K){z(""),g(String(K.message||K))}},[]),q=async(K="")=>{m(!0),g(""),x("");try{const ee=await fetch("/api/mcps/check",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(K?{name:K}:{})}),re=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(re.error||"检测 MCP 失败");const se=Array.isArray(re.results)?re.results:[];v(Q=>{const le={...Q};for(const fe of se)fe!=null&&fe.name&&(le[fe.name]=fe);return le}),x(K?`已检测 ${K}。`:"已检测所有 MCP。")}catch(ee){g(String(ee.message||ee))}finally{m(!1)}},B=async()=>{p(!0),g(""),x("");try{const K=qoe(i);if(!K.nextName)throw new Error("请填写 MCP 名称");const ee=await fetch("/api/mcps",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(K)}),re=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(re.error||"保存 MCP 失败");const se=Array.isArray(re.servers)?re.servers:[];r(se),t(String(re.path||e)),l(K.nextName),o(Vh(se.find(Q=>Q.name===K.nextName)||null)),v(Q=>{const le={...Q};return i.originalName&&i.originalName!==K.nextName&&delete le[i.originalName],delete le[K.nextName],le}),x("已保存。Cursor CLI 下次启动时会读取新配置。")}catch(K){g(String(K.message||K))}finally{p(!1)}},ne=async K=>{if(K!=null&&K.name&&window.confirm(`删除 MCP "${K.name}"?`)){p(!0),g(""),x("");try{const ee=await fetch("/api/mcps/delete",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:K.name})}),re=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(re.error||"删除 MCP 失败");r(Array.isArray(re.servers)?re.servers:[]),l(""),o(Jw()),v(se=>{const Q={...se};return delete Q[K.name],Q}),x("已删除。")}catch(ee){g(String(ee.message||ee))}finally{p(!1)}}};return s.jsxs("main",{className:"af-settings-page",children:[s.jsxs("header",{className:"af-settings-top",children:[s.jsxs("div",{className:"af-settings-crumb",children:[s.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),s.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),s.jsx("span",{className:"af-settings-crumb-active",children:"MCP"})]}),s.jsxs("div",{className:"af-settings-top-right",children:[s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:V,disabled:c||f,children:"刷新"}),s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>q(),disabled:d||c||f||n.length===0,children:d?"检测中...":"检测状态"}),s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:W,disabled:f,children:"新增 MCP"})]})]}),s.jsx("div",{className:"af-settings-body",children:s.jsxs("div",{className:"af-settings-inner",children:[s.jsxs("section",{className:"af-settings-hero",children:[s.jsx("h1",{className:"af-settings-h1",children:"MCP 管理"}),s.jsx("p",{className:"af-settings-lead",children:"管理 AgentFlow 暴露给外部 Agent 的 MCP 接入方式,以及 AgentFlow 自身可调用的外部 MCP server。"})]}),s.jsxs("section",{className:"af-set-card af-set-card--wide af-set-card--low af-set-mcp-personal",children:[s.jsxs("div",{className:"af-set-env-head",children:[s.jsxs("div",{className:"af-set-card-head",children:[s.jsx("div",{className:"af-set-env-icon-wrap",children:s.jsx("span",{className:"material-symbols-outlined af-set-icon--primary",children:"lan"})}),s.jsxs("div",{children:[s.jsx("h2",{className:"af-set-h2",children:"我的 MCP"}),s.jsx("p",{className:"af-set-card-subtitle",children:"给 Cursor、Codex 等外部 Agent 配置 AgentFlow MCP,用来运行流程并读取 display 结果。"})]})]}),s.jsx("span",{className:"af-set-badge af-set-badge--ok",children:"AgentFlow as MCP"})]}),s.jsx("p",{className:"af-set-hint",children:"这里生成的是让其他 Agent 连接本平台的配置;下方“外部 MCP Servers”管理的是 AgentFlow 运行时可调用的外部工具。"}),s.jsxs("div",{className:"af-set-mcp-connect-grid",children:[s.jsxs("label",{className:"af-set-mcp-field",children:[s.jsx("span",{children:"Base URL"}),s.jsx("input",{className:"af-set-input af-set-input--mono",value:_,onChange:K=>j(K.target.value),placeholder:"http://127.0.0.1:8875"})]}),s.jsxs("label",{className:"af-set-mcp-field",children:[s.jsx("span",{children:"Token"}),s.jsxs("div",{className:"af-set-mcp-token-row",children:[s.jsx("input",{className:"af-set-input af-set-input--mono",type:"password",value:N,onChange:K=>P(K.target.value),placeholder:"<AGENTFLOW_TOKEN>"}),s.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:X,children:T==="token"?"已填入":"使用当前登录 Token"})]})]})]}),s.jsxs("div",{className:"af-set-mcp-snippet-grid",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"af-set-mcp-snippet-head",children:[s.jsx("span",{children:"Cursor mcp.json"}),s.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:H,children:T==="cursor"?"已复制":T==="copy-failed"?"复制失败":"复制"})]}),s.jsx("pre",{className:"af-set-mcp-code",children:D})]}),s.jsxs("div",{children:[s.jsxs("div",{className:"af-set-mcp-snippet-head",children:[s.jsx("span",{children:"Codex config.toml"}),s.jsx("button",{type:"button",className:"af-set-btn-outline af-set-btn-outline--compact",onClick:A,children:T==="codex"?"已复制":T==="copy-failed"?"复制失败":"复制"})]}),s.jsx("pre",{className:"af-set-mcp-code",children:L})]})]}),s.jsx("div",{className:"af-set-mcp-copy-row",children:s.jsxs("button",{type:"button",className:"af-set-footer-primary",onClick:M,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"content_copy"}),T==="prompt"?"已复制 Prompt":T==="copy-failed"?"复制失败":"复制 AI 配置 Prompt"]})}),T==="copy-failed"?s.jsx("p",{className:"af-mcp-error",children:"浏览器禁止访问剪贴板,请手动选中下面的 Prompt 复制。"}):null,s.jsx("label",{className:"af-set-label-sm",htmlFor:"af-mcp-ai-prompt",children:"AI 配置 Prompt"}),s.jsx("textarea",{id:"af-mcp-ai-prompt",className:"af-set-input af-set-input--mono af-set-mcp-prompt",rows:12,readOnly:!0,value:$})]}),s.jsxs("section",{className:"af-settings-hero af-settings-hero--compact",children:[s.jsx("h2",{className:"af-settings-h2",children:"外部 MCP Servers"}),s.jsxs("p",{className:"af-settings-lead",children:["新增、编辑和删除 AgentFlow 可调用的外部 MCP server。当前配置文件:",s.jsx("span",{className:"af-settings-code",children:e||"~/.cursor/mcp.json"})]})]}),s.jsxs("div",{className:"af-mcp-layout",children:[s.jsxs("section",{className:"af-set-card af-mcp-list-card",children:[s.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[s.jsx("h2",{className:"af-set-h2",children:"Servers"}),s.jsxs("div",{className:"af-mcp-list-head-actions",children:[s.jsx("span",{className:"af-set-badge af-set-badge--muted",children:n.length}),s.jsxs("button",{type:"button",className:"af-set-btn-mini",onClick:W,disabled:f,children:[s.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]})]}),c?s.jsx("p",{className:"af-set-p",children:"加载中..."}):null,n.length===0&&!c?s.jsxs("div",{className:"af-mcp-empty",children:[s.jsx("p",{className:"af-set-p",children:"暂无 MCP server。"}),s.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:W,disabled:f,children:"新增 MCP Server"})]}):null,s.jsx("div",{className:"af-mcp-server-list",children:n.map(K=>{var ee,re,se,Q;return s.jsxs("button",{type:"button",className:"af-mcp-server-item"+(a===K.name?" af-mcp-server-item--active":""),onClick:()=>F(K),children:[s.jsx("span",{className:"material-symbols-outlined",children:K.type==="url"?"cloud":"terminal"}),s.jsxs("span",{children:[s.jsxs("span",{className:"af-mcp-server-title",children:[s.jsx("strong",{children:K.name}),s.jsx("small",{className:`af-mcp-server-health af-mcp-server-health--${iA(y[K.name])}`,children:sA(y[K.name])})]}),s.jsxs("span",{className:"af-mcp-server-backends",children:[s.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${tk((re=(ee=K.backends)==null?void 0:ee.cursor)==null?void 0:re.status)}`,children:"Cursor"}),s.jsx("small",{className:`af-mcp-backend-pill af-mcp-backend-pill--${tk((Q=(se=K.backends)==null?void 0:se.codex)==null?void 0:Q.status)}`,children:"Codex"})]}),s.jsx("em",{children:K.url||[K.command,...K.args||[]].filter(Boolean).join(" ")})]})]},K.name)})})]}),s.jsxs("section",{className:"af-set-card af-mcp-editor-card",children:[s.jsxs("div",{className:"af-set-card-head af-set-card-head--spread",children:[s.jsxs("div",{children:[s.jsx("h2",{className:"af-set-h2",children:E?"编辑 MCP":"新增 MCP"}),s.jsx("p",{className:"af-set-p af-set-p--tight",children:"保存后会写入 Cursor MCP 配置。已运行的 agent 进程不会热更新,下一次启动会读取新配置。"})]}),E?s.jsxs("div",{className:"af-mcp-editor-actions",children:[s.jsx("button",{type:"button",className:"af-set-btn-mini",onClick:()=>q(E.name),disabled:d||f,children:d?"检测中...":"检测"}),s.jsx("button",{type:"button",className:"af-set-btn-mini af-set-btn-mini--danger",onClick:()=>ne(E),disabled:f,children:"删除"})]}):null]}),b?s.jsx("p",{className:"af-mcp-error",children:b}):null,k?s.jsx("p",{className:"af-mcp-status",children:k}):null,E?s.jsx(Yoe,{server:E}):null,O?s.jsxs("div",{className:`af-mcp-check af-mcp-check--${iA(O)}`,children:[s.jsxs("div",{className:"af-mcp-check-head",children:[s.jsx("strong",{children:sA(O)}),s.jsxs("span",{children:[O.elapsedMs||0,"ms"]})]}),O.error?s.jsx("p",{children:O.error}):null,(ce=O.tools)!=null&&ce.length?s.jsx("div",{className:"af-mcp-tools-list",children:O.tools.map(K=>s.jsxs("div",{className:"af-mcp-tool-row",children:[s.jsx("strong",{children:K.name}),K.description?s.jsx("span",{children:K.description}):null]},K.name))}):null]}):null,s.jsxs("div",{className:"af-mcp-form",children:[s.jsxs("label",{className:"af-set-label",children:["MCP 名称",s.jsx("input",{className:"af-set-input af-set-input--mono",value:i.name,onChange:K=>o(ee=>({...ee,name:K.target.value})),placeholder:"github"})]}),s.jsxs("label",{className:"af-set-label",children:["类型",s.jsxs("select",{className:"af-set-input",value:i.type,onChange:K=>o(ee=>({...ee,type:K.target.value})),children:[s.jsx("option",{value:"url",children:"URL / HTTP"}),s.jsx("option",{value:"command",children:"Command / stdio"})]})]}),i.type==="url"?s.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["URL",s.jsx("input",{className:"af-set-input af-set-input--mono",value:i.url,onChange:K=>o(ee=>({...ee,url:K.target.value})),placeholder:"http://127.0.0.1:3845/mcp"})]}):s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"af-set-label",children:["Command",s.jsx("input",{className:"af-set-input af-set-input--mono",value:i.command,onChange:K=>o(ee=>({...ee,command:K.target.value})),placeholder:"uvx"})]}),s.jsxs("label",{className:"af-set-label",children:["Args,每行一个",s.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:4,value:i.argsText,onChange:K=>o(ee=>({...ee,argsText:K.target.value})),placeholder:`mcp-server-example
|
|
320
|
+
--flag`})]})]}),s.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["描述",s.jsx("input",{className:"af-set-input",value:i.description,onChange:K=>o(ee=>({...ee,description:K.target.value})),placeholder:"这个 MCP 提供什么能力"})]}),s.jsx(oA,{title:"Headers",rows:i.headerRows,onChange:K=>o(ee=>({...ee,headerRows:K})),placeholderKey:"Authorization",placeholderValue:"Bearer ..."}),s.jsx(oA,{title:"Env",rows:i.envRows,onChange:K=>o(ee=>({...ee,envRows:K})),placeholderKey:"TOKEN",placeholderValue:"..."}),s.jsxs("label",{className:"af-set-label af-mcp-field--wide",children:["额外 JSON 字段",s.jsx("textarea",{className:"af-set-input af-mcp-textarea af-set-input--mono",rows:5,value:i.extraJson,onChange:K=>o(ee=>({...ee,extraJson:K.target.value}))})]})]}),s.jsxs("div",{className:"af-mcp-actions",children:[s.jsx("button",{type:"button",className:"af-set-btn-outline",onClick:W,disabled:f,children:"清空"}),s.jsx("button",{type:"button",className:"af-set-footer-primary",onClick:B,disabled:f,children:f?"保存中...":"保存 MCP"})]})]})]})]})})]})}function Xoe(e={}){const t=String((e==null?void 0:e.flowId)||"").trim();if(!t)return"";const n=new URLSearchParams({flowId:t,flowSource:String((e==null?void 0:e.flowSource)||"user").trim()||"user"}),r=String((e==null?void 0:e.workspaceId)||"").trim();if(r&&n.set("workspaceId",r),(e==null?void 0:e.kind)==="workspace"){const i=String((e==null?void 0:e.scheduleNodeId)||"").trim();i&&n.set("focusNodeId",i)}return`/workspace?${n.toString()}`}function aA(e={}){return(e==null?void 0:e.kind)==="workspace"&&String((e==null?void 0:e.scheduleNodeId)||"").trim()?"打开节点":"打开项目"}function lA(e){if(!e)return"-";const t=typeof e=="number"?e:Date.parse(String(e));return Number.isFinite(t)?new Date(t).toLocaleString():String(e)}function Qoe(e){return(e==null?void 0:e.kind)==="workspace"?"Workspace":"Pipeline"}function Zoe(e){if(e!=null&&e.running)return"运行中";if(!(e!=null&&e.enabled))return"已停用";const t=String((e==null?void 0:e.lastStatus)||"").trim();return!t||t==="armed"||t==="enabled"?"已启用":t==="success"?"上次成功":t==="failed"?"上次失败":t==="invalid"?"配置异常":t.startsWith("skipped")?"已跳过":t}function eae(){const{navigate:e}=us(),[t,n]=h.useState([]),[r,i]=h.useState(!1),[o,a]=h.useState(""),[l,c]=h.useState(""),u=h.useCallback(async()=>{i(!0),a("");try{const d=await fetch("/api/schedules"),m=await d.json().catch(()=>({}));if(!d.ok)throw new Error(m.error||"读取定时任务失败");n(Array.isArray(m.schedules)?m.schedules:[])}catch(d){a(String(d.message||d)),n([])}finally{i(!1)}},[]);h.useEffect(()=>{u()},[u]);const f=h.useCallback(async d=>{const m=`${d.kind}:${d.flowSource||"user"}:${d.flowId||""}:${d.scheduleNodeId||""}`;c(m),a("");try{const y=await fetch("/api/schedule/toggle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({kind:d.kind,flowId:d.flowId,flowSource:d.flowSource||"user",scheduleNodeId:d.scheduleNodeId||"",enabled:!d.enabled})}),v=await y.json().catch(()=>({}));if(!y.ok||v.success===!1)throw new Error(v.error||"更新定时任务失败");await u()}catch(y){a(String(y.message||y))}finally{c("")}},[u]),p=h.useMemo(()=>{const d=t.filter(y=>y.enabled).length,m=t.filter(y=>y.kind==="workspace").length;return{total:t.length,enabled:d,workspace:m,pipeline:t.length-m}},[t]);return s.jsxs("div",{className:"af-settings-page af-schedules-page",children:[s.jsxs("div",{className:"af-settings-top",children:[s.jsxs("div",{className:"af-settings-crumb",children:[s.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),s.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),s.jsx("span",{className:"af-settings-crumb-active",children:"定时任务"})]}),s.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:()=>void u(),disabled:r,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:r?"hourglass_empty":"refresh"}),"刷新"]})]}),s.jsx("div",{className:"af-settings-body",children:s.jsxs("div",{className:"af-settings-inner",children:[s.jsxs("section",{className:"af-settings-hero",children:[s.jsx("h1",{className:"af-settings-h1",children:"定时任务"}),s.jsx("p",{className:"af-settings-lead",children:"统一查看服务器上的 Pipeline 定时任务和 Workspace Scheduled Run,并在这里快捷启停。"})]}),s.jsxs("div",{className:"af-schedules-summary","aria-label":"定时任务汇总",children:[s.jsxs("div",{children:[s.jsx("span",{children:"全部"}),s.jsx("strong",{children:p.total})]}),s.jsxs("div",{children:[s.jsx("span",{children:"启用中"}),s.jsx("strong",{children:p.enabled})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Workspace"}),s.jsx("strong",{children:p.workspace})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Pipeline"}),s.jsx("strong",{children:p.pipeline})]})]}),o?s.jsx("div",{className:"af-schedules-error",children:o}):null,r?s.jsx("div",{className:"af-schedules-empty",children:"Loading..."}):null,!r&&t.length===0?s.jsx("div",{className:"af-schedules-empty",children:"暂无定时任务"}):null,s.jsx("div",{className:"af-schedules-list",children:t.map(d=>{const m=`${d.kind}:${d.flowSource||"user"}:${d.flowId||""}:${d.scheduleNodeId||""}`,y=l===m,v=Xoe(d);return s.jsxs("article",{className:"af-schedule-card",children:[s.jsxs("div",{className:"af-schedule-card__main",children:[s.jsxs("div",{className:"af-schedule-card__title-row",children:[s.jsx("strong",{children:d.label||d.flowId||"-"}),s.jsx("span",{className:`af-schedule-badge af-schedule-badge--${d.kind||"pipeline"}`,children:Qoe(d)}),s.jsx("span",{className:`af-schedule-state ${d.enabled?"af-schedule-state--on":"af-schedule-state--off"}`,children:Zoe(d)})]}),s.jsxs("div",{className:"af-schedule-card__meta",children:[s.jsx("span",{children:d.flowId||"-"}),s.jsx("span",{children:d.flowSource||"user"}),d.scheduleNodeId?s.jsx("span",{children:d.scheduleNodeId}):null]}),s.jsxs("div",{className:"af-schedule-card__grid",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Cron"}),s.jsx("strong",{children:d.cron||"-"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"时区"}),s.jsx("strong",{children:d.timezone||"Asia/Shanghai"})]}),s.jsxs("div",{children:[s.jsx("span",{children:"下次执行"}),s.jsx("strong",{children:lA(d.nextRunAt)})]}),s.jsxs("div",{children:[s.jsx("span",{children:"最近执行"}),s.jsx("strong",{children:lA(d.lastTriggeredAt)})]})]}),d.lastError?s.jsx("p",{className:"af-schedule-card__error",children:d.lastError}):null]}),s.jsxs("div",{className:"af-schedule-card__actions",children:[v?s.jsxs("button",{type:"button",className:"af-schedule-open",title:aA(d),onClick:()=>e(v),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"}),aA(d)]}):null,s.jsxs("button",{type:"button",className:d.enabled?"af-schedule-toggle af-schedule-toggle--on":"af-schedule-toggle af-schedule-toggle--off",disabled:y,"aria-pressed":d.enabled,title:d.enabled?"点击停用":"点击启用",onClick:()=>void f(d),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:y?"hourglass_empty":d.enabled?"toggle_on":"toggle_off"}),d.enabled?"已启用":"已停用"]})]})]},m)})})]})})]})}const cA={id:"",title:"Untitled Node",definitionId:"",agentMessages:[],promptDraft:"",manifest:{id:"",version:"1.0.0",name:"",runtime:{type:"agent_subAgent"},inputs:[],outputs:[],configSchema:{fields:[]},ui:{card:{icon:"extension",variant:"default",actions:[]}}},config:{},files:{},test:{inputs:{},log:[],status:"not run"}};function uA(e){const t=(e==null?void 0:e.manifest)||{};return(e==null?void 0:e.definitionId)||`marketplace:${t.id||(e==null?void 0:e.id)||"node"}@${t.version||"1.0.0"}`}function tae(e){var c,u,f,p,d,m,y,v,b,g,k,x;const t=(e==null?void 0:e.manifest)||{},n=(e==null?void 0:e.files)||{},r=Array.isArray(t.inputs)?t.inputs:[],i=Array.isArray(t.outputs)?t.outputs:[],o=Array.isArray((c=t.configSchema)==null?void 0:c.fields)?t.configSchema.fields:[],a=Array.isArray((f=(u=t.ui)==null?void 0:u.card)==null?void 0:f.actions)?t.ui.card.actions:[],l=(p=e==null?void 0:e.test)!=null&&p.inputs&&typeof e.test.inputs=="object"?e.test.inputs:{};return[{id:"contract",label:"Contract",icon:"account_tree",rows:[...r.map(_=>[`input.${_.name||"-"}`,`${_.type||"text"}${_.required?" · required":""}${_.default?` · default: ${_.default}`:""}`]),...i.map(_=>[`output.${_.name||"-"}`,_.type||"text"]),...o.map(_=>[`config.${_.key||"-"}`,_.type||"text"])]},{id:"runtime",label:"Runtime",icon:"terminal",rows:[["runtime.type",((d=t.runtime)==null?void 0:d.type)||t.baseDefinitionId||"tool_nodejs"],["runtime.entry",((m=t.runtime)==null?void 0:m.entry)||"scripts/run.mjs"],["prompt.md",n["prompt.md"]||"-"],["implementation.md",n["implementation.md"]||"-"]]},{id:"ui",label:"UI",icon:"dashboard_customize",rows:[["card.variant",((v=(y=t.ui)==null?void 0:y.card)==null?void 0:v.variant)||"default"],["card.icon",((g=(b=t.ui)==null?void 0:b.card)==null?void 0:g.icon)||"extension"],...a.map(_=>[`action.${_.id||_.label||"-"}`,_.variant||_.label||"secondary"])]},{id:"tests",label:"Tests",icon:"science",rows:[...Object.entries(l).map(([_,j])=>[`sample.${_}`,String(j)]),["last run",`${((k=e==null?void 0:e.test)==null?void 0:k.status)||"not run"}${(x=e==null?void 0:e.test)!=null&&x.durationMs?` · ${e.test.durationMs}ms`:""}`]]}]}function nae(){var L,$,V,W,F,M,H;const[e,t]=h.useState(null),[n,r]=h.useState("runtime"),[i,o]=h.useState(!1),[a,l]=h.useState(!0),[c,u]=h.useState(""),[f,p]=h.useState(!1),[d,m]=h.useState(""),y=e||cA,v=h.useMemo(()=>tae(y),[y]),b=h.useMemo(()=>v.find(A=>A.id===n)||v[1],[n,v]),g=(y==null?void 0:y.manifest)||{},k=(y==null?void 0:y.config)||{},x=((L=y==null?void 0:y.test)==null?void 0:L.inputs)||{},_=Array.isArray(($=y==null?void 0:y.test)==null?void 0:$.log)?y.test.log:[],j=((W=(V=g.ui)==null?void 0:V.card)==null?void 0:W.icon)||"event_repeat",N=((M=(F=g.ui)==null?void 0:F.card)==null?void 0:M.variant)||"default",P=k.enabled===!0,T=h.useCallback(async()=>{var A;l(!0),u("");try{const X=await fetch("/api/node-studio/drafts"),q=await X.json().catch(()=>({}));if(!X.ok)throw new Error(q.error||"读取节点草稿失败");const B=Array.isArray(q.drafts)?q.drafts[0]:null;if(!(B!=null&&B.id)){t(null),m("");return}const ne=await fetch(`/api/node-studio/draft?id=${encodeURIComponent(B.id)}`),ce=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(ce.error||"读取节点草稿失败");t(ce.draft||null),m(String(((A=ce.draft)==null?void 0:A.promptDraft)||""))}catch(X){u(String(X.message||X))}finally{l(!1)}},[]);h.useEffect(()=>{T()},[T]);const z=h.useCallback(async(A={})=>{var X;p(!0),u("");try{const q=await fetch("/api/node-studio/draft",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:(e==null?void 0:e.id)||"untitled_node",...A})}),B=await q.json().catch(()=>({}));if(!q.ok||B.ok===!1)throw new Error(B.error||"保存节点草稿失败");t(B.draft||e),m(String(((X=B.draft||e)==null?void 0:X.promptDraft)||""))}catch(q){u(String(q.message||q))}finally{p(!1)}},[e]),E=()=>{o(!0),window.setTimeout(()=>o(!1),900)},O=A=>{const X={...k,enabled:A};t(q=>({...q||cA,config:X})),z({config:{enabled:A}})},D=()=>{z({promptDraft:d,appendUserMessage:!0})};return s.jsxs("div",{className:"af-node-studio-page",children:[s.jsxs("header",{className:"af-node-studio-top",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"af-settings-crumb",children:[s.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),s.jsx("span",{className:"af-settings-crumb-sep",children:"/"}),s.jsx("span",{className:"af-settings-crumb-active",children:"Node Studio"})]}),s.jsx("h1",{children:"节点编辑器"})]}),s.jsxs("div",{className:"af-node-studio-actions",children:[s.jsxs("button",{type:"button",onClick:()=>void T(),disabled:a,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"visibility"}),a?"Loading":"Preview"]}),s.jsxs("button",{type:"button",onClick:E,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:i?"sync":"science"}),"Test"]}),s.jsxs("button",{type:"button",className:"af-node-studio-actions__primary",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"publish"}),"Publish"]})]})]}),s.jsxs("main",{className:"af-node-studio-shell",children:[s.jsxs("aside",{className:"af-node-studio-agent","aria-label":"AI Agent",children:[s.jsxs("div",{className:"af-node-studio-panel-head",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"auto_awesome"}),s.jsx("strong",{children:"AI Agent"})]}),c?s.jsx("div",{className:"af-node-studio-error",children:c}):null,s.jsxs("div",{className:"af-node-studio-thread",children:[e?null:s.jsx("div",{className:"af-node-studio-empty",children:"还没有节点草稿。描述你要创建的节点,发送后会创建一个新的 draft。"}),(Array.isArray(y==null?void 0:y.agentMessages)?y.agentMessages:[]).map((A,X)=>s.jsx("div",{className:A.role==="user"?"af-node-studio-message af-node-studio-message--user":"af-node-studio-message",children:A.text||""},`${A.role||"message"}-${X}`)),s.jsxs("div",{className:"af-node-studio-agent-tools",children:[s.jsxs("button",{type:"button",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"edit"}),"修改 UI"]}),s.jsxs("button",{type:"button",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"code"}),"改脚本"]}),s.jsxs("button",{type:"button",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"bug_report"}),"修复报错"]})]})]}),s.jsxs("label",{className:"af-node-studio-prompt",children:[s.jsx("span",{children:"需求"}),s.jsx("textarea",{value:d,onChange:A=>m(A.target.value)})]}),s.jsxs("button",{type:"button",className:"af-node-studio-send",onClick:D,disabled:f,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:f?"sync":"send"}),f?"Saving":"Send"]})]}),s.jsxs("section",{className:"af-node-studio-preview","aria-label":"Preview and Test",children:[s.jsxs("div",{className:"af-node-studio-panel-head",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"view_in_ar"}),s.jsx("strong",{children:"Preview / Test"})]}),s.jsxs("div",{className:"af-node-studio-preview-grid",children:[s.jsx("div",{className:"af-node-studio-preview-stage",children:e?N==="schedule"?s.jsxs("div",{className:"af-node-preview-card",children:[s.jsxs("div",{className:"af-node-preview-card__head",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:j}),s.jsx("strong",{children:y.title||g.name||"Untitled Node"}),s.jsx("code",{children:uA(y)})]}),s.jsxs("label",{className:"af-node-preview-toggle",children:[s.jsx("input",{type:"checkbox",checked:P,onChange:A=>O(A.target.checked)}),s.jsx("span",{children:P?"定时开启":"定时关闭"})]}),s.jsxs("div",{className:"af-node-preview-fields",children:[s.jsxs("label",{children:[s.jsx("span",{children:"频率"}),s.jsxs("select",{value:k.scheduleType||"daily",onChange:A=>z({config:{scheduleType:A.target.value}}),children:[s.jsx("option",{value:"daily",children:"每天"}),s.jsx("option",{value:"weekly",children:"每周"})]})]}),s.jsxs("label",{children:[s.jsx("span",{children:"时间"}),s.jsxs("div",{children:[s.jsxs("select",{value:k.hour||"09",onChange:A=>z({config:{hour:A.target.value}}),children:[s.jsx("option",{children:"09"}),s.jsx("option",{children:"10"})]}),s.jsxs("select",{value:k.minute||"00",onChange:A=>z({config:{minute:A.target.value}}),children:[s.jsx("option",{children:"00"}),s.jsx("option",{children:"30"})]})]})]})]}),s.jsxs("div",{className:"af-node-preview-meta",children:[s.jsxs("span",{children:[k.scheduleType==="weekly"?"每周":"每天"," ",k.hour||"09",":",k.minute||"00"]}),s.jsx("span",{children:"Next -"}),s.jsx("span",{children:P?"enabled":"disabled"})]}),s.jsxs("div",{className:"af-node-preview-actions",children:[s.jsxs("button",{type:"button",className:"af-node-preview-run",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"play_arrow"}),"立即运行"]}),s.jsxs("button",{type:"button",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"article"}),"日志"]})]})]}):s.jsxs("div",{className:"af-node-preview-card af-node-preview-card--default",children:[s.jsxs("div",{className:"af-node-preview-card__head",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:j}),s.jsx("strong",{children:y.title||g.name||"Untitled Node"}),s.jsx("code",{children:uA(y)})]}),s.jsxs("div",{className:"af-node-preview-default-body",children:[s.jsx("p",{children:g.description||"这个节点还没有描述。AI 生成 runtime、prompt 或 script 后,内部信息会显示在右侧。"}),s.jsxs("div",{children:[s.jsxs("span",{children:[Array.isArray(g.inputs)?g.inputs.length:0," inputs"]}),s.jsxs("span",{children:[Array.isArray(g.outputs)?g.outputs.length:0," outputs"]}),s.jsx("span",{children:((H=g.runtime)==null?void 0:H.type)||g.baseDefinitionId||"agent_subAgent"})]})]})]}):s.jsxs("div",{className:"af-node-preview-empty",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"add_box"}),s.jsx("strong",{children:"暂无预览"}),s.jsx("p",{children:"先在左侧描述你要创建的节点,AI 生成 draft 后这里会展示节点卡片。"})]})}),s.jsxs("div",{className:"af-node-studio-test",children:[s.jsxs("div",{className:"af-node-studio-subhead",children:[s.jsx("strong",{children:"Test Inputs"}),s.jsxs("button",{type:"button",onClick:E,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:i?"sync":"play_arrow"}),"Run"]})]}),s.jsxs("div",{className:"af-node-studio-inputs",children:[s.jsxs("label",{children:[s.jsx("span",{children:"project"}),s.jsx("input",{value:x.project||"",readOnly:!0,placeholder:"-"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"date"}),s.jsx("input",{value:x.date||"",readOnly:!0,placeholder:"-"})]})]}),s.jsx("div",{className:"af-node-studio-log",children:(i?["running..."]:_.length?_:["No test run yet."]).map((A,X)=>s.jsx("span",{children:A},`${A}-${X}`))})]})]})]}),s.jsxs("aside",{className:"af-node-studio-internals","aria-label":"Internals",children:[s.jsxs("div",{className:"af-node-studio-panel-head",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"fact_check"}),s.jsx("strong",{children:"Internals"})]}),s.jsx("div",{className:"af-node-studio-tabs",role:"tablist","aria-label":"Internals sections",children:v.map(A=>s.jsxs("button",{type:"button",className:A.id===n?"af-node-studio-tab af-node-studio-tab--active":"af-node-studio-tab",onClick:()=>r(A.id),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:A.icon}),A.label]},A.id))}),s.jsx("div",{className:"af-node-studio-internal-list",children:b.rows.map(([A,X])=>s.jsxs("div",{className:"af-node-studio-internal-row",children:[s.jsx("span",{children:A}),s.jsx("strong",{children:X})]},A))}),s.jsx("pre",{className:"af-node-studio-code",children:b.id==="ui"?JSON.stringify(g.ui||{},null,2):b.id==="contract"?JSON.stringify({inputs:g.inputs||[],outputs:g.outputs||[],configSchema:g.configSchema||{}},null,2):b.id==="tests"?JSON.stringify((y==null?void 0:y.test)||{},null,2):JSON.stringify({runtime:g.runtime||{},files:(y==null?void 0:y.files)||{}},null,2)})]})]})]})}function rae(){return`ws_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function sae(e){return/^[A-Za-z_][A-Za-z0-9_]*$/.test(String(e||"").trim())}function Kh(e){const t=String(e||"").trim();if(!t)return"";let n=t;try{n=new URL(t).pathname}catch{n=t.split("?")[0].split("#")[0]}return(n.replace(/\/+$/,"").split("/").filter(Boolean).pop()||"").replace(/\.git$/i,"").replace(/[^A-Za-z0-9._-]+/g,"_").replace(/^_+|_+$/g,"")}function iae(e={},t={}){return`${String(e.mountPath||t.mountPath||e.label||t.label||e.id||t.id||"workspace").trim().toUpperCase().replace(/[^A-Z0-9]+/g,"_").replace(/^_+|_+$/g,"").slice(0,48)||"WORKSPACE"}_GIT_TOKEN`}function Qw(){return{id:"",label:"",kind:"git",path:"",repoUrl:"",branch:"master",mountPath:"",credentialRef:"",type:"code",description:"",enabled:!0}}function mh(e={}){return{id:String((e==null?void 0:e.id)||""),label:String((e==null?void 0:e.label)||(e==null?void 0:e.name)||""),kind:(e==null?void 0:e.kind)==="local"?"local":"git",path:String((e==null?void 0:e.path)||""),repoUrl:String((e==null?void 0:e.repoUrl)||""),branch:String((e==null?void 0:e.branch)||"master"),mountPath:String((e==null?void 0:e.mountPath)||""),credentialRef:String((e==null?void 0:e.credentialRef)||""),type:String((e==null?void 0:e.type)||((e==null?void 0:e.kind)==="local"?"local":"code")),description:String((e==null?void 0:e.description)||""),enabled:(e==null?void 0:e.enabled)!==!1}}function oae(e){const t=e.kind==="local"?"local":"git",n=t==="git"?String(e.repoUrl||"").trim():"",r=t==="git"?String(e.mountPath||Kh(n)||"").trim():"";return{id:String(e.id||"").trim(),label:String(e.label||"").trim(),kind:t,path:String(e.path||"").trim(),repoUrl:n,branch:t==="git"?String(e.branch||"master").trim()||"master":"",mountPath:r,credentialRef:t==="git"?String(e.credentialRef||"").trim():"",type:String(e.type||(t==="local"?"local":"code")).trim(),description:String(e.description||"").trim(),enabled:e.enabled!==!1}}function Zi(e,t=0){return(e==null?void 0:e.id)||(e==null?void 0:e.path)||(e==null?void 0:e.repoUrl)||`workspace-${t}`}function aae({ok:e}){return s.jsx("span",{className:"af-workspaces-dot"+(e?" af-workspaces-dot--ok":""),"aria-hidden":!0})}function dA({item:e,selected:t,onClick:n,readOnly:r}){return s.jsxs("button",{type:"button",className:"af-workspaces-card"+(t?" af-workspaces-card--selected":""),onClick:n,children:[s.jsxs("div",{className:"af-workspaces-card__head",children:[s.jsx("strong",{children:e.label||"知识库"}),s.jsx("span",{children:e.kind==="git"?"Git":"Local"})]}),s.jsx("p",{children:e.description||e.repoUrl||e.path||"-"}),s.jsxs("div",{className:"af-workspaces-card__meta",children:[s.jsx(aae,{ok:e.exists!==!1}),s.jsx("span",{children:e.exists===!1?"路径未就绪":"路径可用"}),r?s.jsx("em",{children:"内置"}):e.enabled===!1?s.jsx("em",{children:"disabled"}):null]})]})}function lae(){const[e,t]=h.useState(!1),[n,r]=h.useState(!1),[i,o]=h.useState(!1),[a,l]=h.useState(""),[c,u]=h.useState(""),[f,p]=h.useState(""),[d,m]=h.useState([]),[y,v]=h.useState([]),[b,g]=h.useState(Qw),[k,x]=h.useState(""),[_,j]=h.useState([]),[N,P]=h.useState(""),T=h.useMemo(()=>y.findIndex((q,B)=>Zi(q,B)===N),[y,N]),E=!!h.useMemo(()=>d.find((q,B)=>Zi(q,B)===N)||null,[d,N]),O=h.useMemo(()=>{const q=String(b.credentialRef||"").trim();return q?_.some(B=>String((B==null?void 0:B.key)||"").trim()===q&&String((B==null?void 0:B.value)??"")!==""):!1},[b.credentialRef,_]),D=h.useCallback(async()=>{t(!0),l("");try{const[q,B]=await Promise.all([fetch("/api/workspaces"),fetch("/api/user-env")]),ne=await q.json().catch(()=>({})),ce=await B.json().catch(()=>({}));if(!B.ok)throw new Error(typeof ce.error=="string"?ce.error:"ENV HTTP "+B.status);if(!q.ok)throw new Error(typeof ne.error=="string"?ne.error:"HTTP "+q.status);const K=Array.isArray(ne.workspaces)?ne.workspaces:[],ee=Array.isArray(ne.customWorkspaces)?ne.customWorkspaces:[];p(String(ne.path||"")),m(K.filter(re=>re==null?void 0:re.builtin)),v(ee),j(Array.isArray(ce.env)?ce.env.map(re=>({key:String((re==null?void 0:re.key)||""),value:String((re==null?void 0:re.value)??"")})):[])}catch(q){l(String(q.message||q))}finally{t(!1)}},[]);h.useEffect(()=>{D()},[D]);const L=h.useCallback(async(q,B="")=>{r(!0),l(""),u("");try{const ne=await fetch("/api/workspaces",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({workspaces:q})}),ce=await ne.json().catch(()=>({}));if(!ne.ok)throw new Error(typeof ce.error=="string"?ce.error:"HTTP "+ne.status);const K=Array.isArray(ce.customWorkspaces)?ce.customWorkspaces:q;v(K),m((Array.isArray(ce.workspaces)?ce.workspaces:[]).filter(ee=>ee==null?void 0:ee.builtin)),p(String(ce.path||f)),B&&P(B),u("已保存")}catch(ne){l(String(ne.message||ne))}finally{r(!1)}},[f]),$=h.useCallback(()=>{P(""),g(Qw()),x(""),u(""),l("")},[]),V=h.useCallback((q,B)=>{P(Zi(q,B)),g(mh(q)),x(""),u("")},[]),W=h.useCallback((q,B)=>{P(Zi(q,B)),g(mh(q)),x(""),u("")},[]),F=h.useCallback(async(q,B)=>{const ne=String(q||"").trim(),ce=String(B??"");if(!ne||!ce)return;const K=_.filter(se=>String((se==null?void 0:se.key)||"").trim()!==ne);K.push({key:ne,value:ce});const ee=await fetch("/api/user-env",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({env:K})}),re=await ee.json().catch(()=>({}));if(!ee.ok)throw new Error(typeof re.error=="string"?re.error:"ENV HTTP "+ee.status);j(Array.isArray(re.env)?re.env.map(se=>({key:String((se==null?void 0:se.key)||""),value:String((se==null?void 0:se.value)??"")})):K)},[_]),M=h.useCallback(()=>{const q=oae({...b,id:b.id||rae()}),B=k.trim();if(q.kind==="git"&&B&&!q.credentialRef&&(q.credentialRef=iae(b,q)),q.kind==="local"&&!q.path){l("本地知识库需要填写路径");return}if(q.kind==="git"&&!q.repoUrl){l("Git 知识库需要填写 repoUrl");return}if(!q.label){l("请填写名称");return}if(q.kind==="git"&&q.credentialRef&&!sae(q.credentialRef)){l("凭证环境变量只能使用字母、数字和下划线,且不能以数字开头");return}const ne=T>=0?y.map((ce,K)=>K===T?q:ce):[q,...y];g(mh(q)),(async()=>{r(!0);try{B&&await F(q.credentialRef,B),x(""),await L(ne,Zi(q))}catch(ce){l(String(ce.message||ce)),r(!1)}})()},[y,b,L,F,T,k]),H=h.useCallback(()=>{if(T<0)return;const q=y.filter((B,ne)=>ne!==T);g(Qw()),P(""),L(q)},[y,L,T]),A=h.useCallback(async()=>{if(!E){if(T<0||!b.id){l("请先保存知识库配置,再拉取更新");return}if(b.kind!=="git"){l("只有 Git 知识库支持拉取更新");return}o(!0),l(""),u("");try{const q=await fetch("/api/workspaces/sync",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:b.id})}),B=await q.json().catch(()=>({}));if(!q.ok)throw new Error(typeof B.error=="string"?B.error:"HTTP "+q.status);const ne=Array.isArray(B.customWorkspaces)?B.customWorkspaces:y;v(ne),m((Array.isArray(B.workspaces)?B.workspaces:[]).filter(ee=>ee==null?void 0:ee.builtin));const ce=ne.find(ee=>String((ee==null?void 0:ee.id)||"")===String(b.id||""));ce&&g(mh(ce));const K=String(B.commit||"").trim();u(B.changed?`已拉取更新${K?`:${K.slice(0,8)}`:""}`:`已是最新${K?`:${K.slice(0,8)}`:""}`)}catch(q){l(String(q.message||q))}finally{o(!1)}}},[y,b,E,T]),X=h.useCallback(q=>{g(B=>({...B,...q}))},[]);return s.jsxs("div",{className:"af-workspaces-page",children:[s.jsxs("header",{className:"af-settings-top",children:[s.jsxs("div",{className:"af-settings-crumb","aria-label":"知识库",children:[s.jsx("span",{className:"af-settings-crumb-muted",children:"AgentFlow"}),s.jsx("span",{className:"af-settings-crumb-sep","aria-hidden":!0,children:"/"}),s.jsx("span",{className:"af-settings-crumb-active",children:"知识库"})]}),s.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:D,disabled:e,children:[s.jsx("span",{className:"material-symbols-outlined",children:"refresh"}),"刷新"]})]}),s.jsx("main",{className:"af-settings-body",children:s.jsxs("div",{className:"af-workspaces-inner",children:[s.jsxs("header",{className:"af-settings-hero",children:[s.jsx("h1",{className:"af-settings-h1",children:"知识库"}),s.jsx("p",{className:"af-settings-lead",children:"维护可被加载知识库、一键任务和后续 Agent 使用的只读上下文源。Git 字段与 mengmai 的资源配置保持一致。"}),f?s.jsxs("p",{className:"af-workspaces-config",children:["配置文件:",f]}):null,a?s.jsx("p",{className:"af-err af-settings-api-hint",children:a}):null,c?s.jsx("p",{className:"af-workspaces-status",children:c}):null]}),s.jsxs("section",{className:"af-workspaces-summary",children:[s.jsxs("div",{children:[s.jsx("span",{children:"内置"}),s.jsx("strong",{children:d.length})]}),s.jsxs("div",{children:[s.jsx("span",{children:"自定义"}),s.jsx("strong",{children:y.length})]}),s.jsxs("div",{children:[s.jsx("span",{children:"Git"}),s.jsx("strong",{children:y.filter(q=>q.kind==="git").length})]})]}),s.jsxs("div",{className:"af-workspaces-layout",children:[s.jsxs("section",{className:"af-workspaces-list",children:[s.jsxs("div",{className:"af-workspaces-section-head",children:[s.jsx("h2",{children:"自定义知识库"}),s.jsxs("button",{type:"button",onClick:$,children:[s.jsx("span",{className:"material-symbols-outlined",children:"add"}),"新增"]})]}),y.length?y.map((q,B)=>s.jsx(dA,{item:q,selected:Zi(q,B)===N,onClick:()=>V(q,B)},Zi(q,B))):s.jsx("div",{className:"af-workspaces-empty",children:"暂无自定义知识库。新增 Git 或本地目录后,画布里的加载知识库和一键任务就可以选择它。"}),s.jsx("div",{className:"af-workspaces-section-head af-workspaces-section-head--sub",children:s.jsx("h2",{children:"内置知识库"})}),d.map((q,B)=>s.jsx(dA,{item:q,selected:Zi(q,B)===N,onClick:()=>W(q,B),readOnly:!0},Zi(q,B)))]}),s.jsxs("section",{className:"af-workspaces-editor",children:[s.jsxs("div",{className:"af-workspaces-editor__head",children:[s.jsxs("div",{children:[s.jsx("h2",{children:E?"查看内置知识库":T>=0?"编辑知识库":"新增知识库"}),s.jsx("p",{children:E?"内置项由当前运行环境提供,不能在这里修改。":"本地路径用于读取上下文,Git 字段用于后续同步和上下文挂载。"})]}),s.jsxs("label",{className:"af-workspaces-switch",children:[s.jsx("input",{type:"checkbox",checked:b.enabled!==!1,disabled:E,onChange:q=>X({enabled:q.target.checked})}),s.jsx("span",{children:"启用"})]})]}),s.jsxs("div",{className:"af-workspaces-kind",children:[s.jsxs("button",{type:"button",className:b.kind==="git"?"active":"",disabled:E,onClick:()=>X({kind:"git",type:b.type==="local"?"code":b.type}),children:[s.jsx("span",{className:"material-symbols-outlined",children:"account_tree"}),"Git"]}),s.jsxs("button",{type:"button",className:b.kind==="local"?"active":"",disabled:E,onClick:()=>X({kind:"local",type:"local"}),children:[s.jsx("span",{className:"material-symbols-outlined",children:"folder_open"}),"本地目录"]})]}),s.jsxs("div",{className:"af-workspaces-form",children:[s.jsxs("label",{children:[s.jsx("span",{children:"名称"}),s.jsx("input",{value:b.label,disabled:E,onChange:q=>X({label:q.target.value}),placeholder:"Likee Android"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"类型"}),s.jsxs("select",{value:b.type,disabled:E,onChange:q=>X({type:q.target.value}),children:[s.jsx("option",{value:"code",children:"code"}),s.jsx("option",{value:"docs",children:"docs"}),s.jsx("option",{value:"analytics",children:"analytics"}),s.jsx("option",{value:"config",children:"config"}),s.jsx("option",{value:"local",children:"local"}),s.jsx("option",{value:"other",children:"other"})]})]}),s.jsxs("label",{className:"af-workspaces-form__wide",children:[s.jsx("span",{children:"本地路径"}),s.jsx("input",{value:b.path,disabled:E,onChange:q=>X({path:q.target.value}),placeholder:b.kind==="git"?"可空,默认保存到全局资源目录/repos/<仓库名>":"/Users/.../project"})]}),b.kind==="git"?s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"af-workspaces-form__wide",children:[s.jsx("span",{children:"Git URL"}),s.jsx("input",{value:b.repoUrl,disabled:E,onChange:q=>{const B=q.target.value,ne=Kh(b.repoUrl),ce=String(b.mountPath||"").trim();X({repoUrl:B,...!ce||ce===ne?{mountPath:Kh(B)}:{}})},placeholder:"https://git.example.com/group/repo.git"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"分支"}),s.jsx("input",{value:b.branch,disabled:E,onChange:q=>X({branch:q.target.value}),placeholder:"master"})]}),s.jsxs("label",{children:[s.jsx("span",{children:"挂载目录"}),s.jsx("input",{value:b.mountPath,disabled:E,onChange:q=>X({mountPath:q.target.value}),placeholder:Kh(b.repoUrl)||"repo_name"})]}),s.jsxs("label",{className:"af-workspaces-form__wide",children:[s.jsx("span",{children:"凭证环境变量"}),s.jsx("input",{value:b.credentialRef,disabled:E,onChange:q=>X({credentialRef:q.target.value}),placeholder:"LIKEE_GIT_READONLY_TOKEN"})]}),s.jsxs("label",{className:"af-workspaces-form__wide",children:[s.jsx("span",{children:"Token"}),s.jsx("input",{type:"password",value:k,disabled:E,onChange:q=>x(q.target.value),placeholder:O?"已在个人环境变量中配置;留空则不修改":"保存到个人环境变量,不写入 workspace 配置"}),s.jsx("small",{children:"保存后只在知识库配置中保留 credentialRef,token 会写入当前用户的个人环境变量。"})]})]}):null,s.jsxs("label",{className:"af-workspaces-form__wide",children:[s.jsx("span",{children:"说明"}),s.jsx("textarea",{value:b.description,disabled:E,onChange:q=>X({description:q.target.value}),placeholder:"这个知识库包含哪些代码、文档或需求上下文"})]})]}),s.jsxs("div",{className:"af-workspaces-actions",children:[!E&&T>=0?s.jsxs("button",{type:"button",className:"af-workspaces-danger",onClick:H,disabled:n||i,children:[s.jsx("span",{className:"material-symbols-outlined",children:"delete"}),"删除"]}):s.jsx("span",{}),s.jsxs("div",{children:[b.kind==="git"&&T>=0?s.jsxs("button",{type:"button",onClick:A,disabled:E||n||i,children:[s.jsx("span",{className:"material-symbols-outlined",children:i?"sync":"download"}),i?"拉取中":"拉取更新"]}):null,s.jsx("button",{type:"button",onClick:$,disabled:n||i,children:"重置"}),s.jsxs("button",{type:"button",className:"af-workspaces-primary",onClick:M,disabled:E||n||i,children:[s.jsx("span",{className:"material-symbols-outlined",children:"save"}),n?"保存中":"保存"]})]})]})]})]})]})})]})}const _$="agentflow.workflows.scopeView",Ga=8,fA=24;function cae(){if(typeof localStorage>"u")return"personal";try{return localStorage.getItem(_$)==="team"?"team":"personal"}catch{return"personal"}}function uae(e){const t=Date.parse(String(e||""));return Number.isFinite(t)?new Date(t).toLocaleString([],{month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"}):"-"}function dae(e){const t=Date.parse(String(e||""));return Number.isFinite(t)?new Date(t).toLocaleDateString([],{year:"numeric",month:"2-digit",day:"2-digit"}):"日期待定"}function fae(e){return Object.values((e==null?void 0:e.dimensions)||{}).flatMap(t=>Array.isArray(t)?t:[t]).map(t=>String(t||"").trim()).filter(Boolean).join(" · ")}function pae(e){const t=Number((e==null?void 0:e.workflowCount)||0),n=Number((e==null?void 0:e.completedCount)||0);if(t>0&&n>=t)return{key:"completed",label:"已完成"};const r=Date.parse(String((e==null?void 0:e.date)||""));return Number.isFinite(r)&&r<Date.now()?{key:"overdue",label:"已到期"}:{key:"planned",label:"计划中"}}function ec(e){const t=new Date;return t.setHours(12,0,0,0),t.setDate(t.getDate()+e),t.toISOString().slice(0,10)}function hae(e){const t=Array.isArray(e)?e.length:0;if(t<=Ga)return{start:0,end:t};const n=Date.now();let r=e.findIndex(o=>{const a=Date.parse(String((o==null?void 0:o.date)||""));return Number.isFinite(a)&&a>=n});r<0&&(r=t-1);const i=Math.max(0,Math.min(r-3,t-Ga));return{start:i,end:Math.min(t,i+Ga)}}function mae(){const e=[{key:"prd-flow:version:demo-5.62.0",kind:"version",id:"demo-5.62.0",title:"Likee Android&iOS 5.62.0",date:ec(-12),source:"prd-flow",dimensions:{platform:["Android","iOS"]}},{key:"prd-flow:version:demo-5.63.0",kind:"version",id:"demo-5.63.0",title:"Likee Android&iOS 5.63.0",date:ec(6),source:"prd-flow",dimensions:{platform:["Android","iOS"]}},{key:"prd-flow:milestone:august-gray",kind:"milestone",id:"august-gray",title:"8 月灰度窗口",date:ec(18),source:"prd-flow",dimensions:{channel:"灰度"}},...Array.from({length:12},(i,o)=>({key:`prd-flow:version:demo-5.${50+o}.0`,kind:"version",id:`demo-5.${50+o}.0`,title:`Likee Android 5.${50+o}.0`,date:ec(-180+o*14),source:"prd-flow",dimensions:{platform:"Android"}})),...Array.from({length:8},(i,o)=>({key:`prd-flow:version:demo-5.${64+o}.0`,kind:"version",id:`demo-5.${64+o}.0`,title:`Likee Android 5.${64+o}.0`,date:ec(32+o*14),source:"prd-flow",dimensions:{platform:"Android"}}))],t=Object.fromEntries(e.map(i=>[i.key,i])),n=[{id:"demo-1",tapdId:"1020124",title:"Likee Android AI Runtime Hook Skill 搭建",pointer:"继续实现 Android Action 与通用 Hook 多层注入平台",phase:"IMPLEMENTATION_IN_PROGRESS",state:"active",role:"owner",ownerUsername:"wangfang",issueCount:2,platforms:["android"],actionCount:5,completedActionCount:4,latestAction:{title:"Android 实现协议已确认",at:new Date().toISOString()},timeline:[t["prd-flow:version:demo-5.63.0"]],demo:!0},{id:"demo-2",tapdId:"1013667",title:"激励视频增收方案",pointer:"检查并选择 TAPD 未解决 Bug",phase:"BUG_SELECTION_READY",state:"blocked",role:"viewer",ownerUsername:"surujija",issueCount:18,platforms:["android","ios"],actionCount:33,completedActionCount:32,latestAction:{title:"等待版本风险确认",at:new Date().toISOString()},timeline:[t["prd-flow:version:demo-5.63.0"]],demo:!0},{id:"demo-3",tapdId:"1133202860001018940",title:"Likee Android 5.62.0",pointer:"发版上下文已同步",phase:"RELEASED",state:"completed",role:"reporter",ownerUsername:"chenjunlun",issueCount:1,platforms:["ios"],actionCount:1,completedActionCount:1,latestAction:{title:"版本发布完成",at:ec(-12)},timeline:[t["prd-flow:version:demo-5.62.0"]],demo:!0},{id:"demo-4",tapdId:"1015046",title:"Remote Config 拉取频控",pointer:"双端方案进入提测准备",phase:"SUBMIT_TEST",state:"active",role:"owner",ownerUsername:"alice",issueCount:4,platforms:["android","ios"],actionCount:8,completedActionCount:6,latestAction:{title:"测试用例已归档",at:new Date().toISOString()},timeline:[t["prd-flow:version:demo-5.63.0"],t["prd-flow:milestone:august-gray"]],demo:!0},{id:"demo-5",tapdId:"1027788",title:"直播间礼物动效治理",pointer:"等待确认目标版本",phase:"PLANNING",state:"active",role:"editor",ownerUsername:"bob",issueCount:3,platforms:["all"],actionCount:4,completedActionCount:1,latestAction:{title:"技术方案评审中",at:new Date().toISOString()},timeline:[],demo:!0},...e.slice(4).map((i,o)=>({id:`demo-timeline-${o+1}`,tapdId:`DEMO-${String(o+1).padStart(3,"0")}`,title:`${i.title} 版本事项`,pointer:o<12?"历史版本事项已归档":"等待进入版本排期",phase:o<12?"RELEASED":"PLANNING",state:o<12?"completed":"active",role:o%3===0?"owner":"reporter",ownerUsername:o%3===0?"wangfang":"demo-user",issueCount:o%4+1,platforms:["android"],actionCount:4,completedActionCount:o<12?4:1,latestAction:{title:o<12?"版本归档完成":"版本排期已同步",at:i.date},timeline:[i],demo:!0}))],r=e.map(i=>{const o=n.filter(a=>a.timeline.some(l=>l.key===i.key));return{...i,workflowCount:o.length,completedCount:o.filter(a=>a.state==="completed").length,blockedCount:o.filter(a=>a.state==="blocked").length,workflowIds:o.map(a=>a.id)}}).sort((i,o)=>Date.parse(i.date)-Date.parse(o.date));return{workflows:n,timeline:r,unassignedCount:1}}function gae(e){return e==="owner"?"我创建的":e==="reporter"||e==="editor"?"可上报":e==="viewer"?"只读协作":"可访问"}function C$(e){return e==="completed"?"已完成":e==="blocked"?"需关注":"进行中"}function A$(e){const t=String(e||"").toLowerCase();return t==="android"?"Android":t==="ios"?"iOS":["all","both","cross-platform","cross_platform"].includes(t)?"双端":e||""}function yae(e){const t=new URLSearchParams({view:"workflow",tapdId:String((e==null?void 0:e.tapdId)||""),returnTo:"/workflows"}),n=Array.isArray(e==null?void 0:e.projectBindings)?e.projectBindings:[];if(n.length===1){const r=n[0];r.flowId&&t.set("flowId",String(r.flowId)),r.flowSource&&t.set("flowSource",String(r.flowSource)),r.workspaceId&&t.set("workspaceId",String(r.workspaceId)),r.archived&&t.set("archived","1")}return e!=null&&e.demo&&t.set("workflowDemo","1"),`/workspace?${t.toString()}`}function wae(e){var u,f,p;const t=String((e==null?void 0:e.tapdId)||"DEMO"),n=A$(((u=e==null?void 0:e.platforms)==null?void 0:u[0])||"all")||"双端",r=((f=e==null?void 0:e.timeline)==null?void 0:f[0])||{},i=[["方案已确认","需求范围和实现方案已完成确认。"],["研发任务已创建","Issue 与研发分支信息已经同步。"],["实现进度已更新","实现状态和当前风险已归档。"],["测试状态已更新","自测、提测状态已经同步。"],["版本归属已确认","版本排期和发布上下文已经确认。"]],o=Math.min(5,Math.max(1,Number((e==null?void 0:e.actionCount)||1))),a=Number((e==null?void 0:e.actionCount)||0)>0?Number((e==null?void 0:e.completedActionCount)||0)/Number(e.actionCount):0,l=Math.round(o*a),c=i.slice(0,o).map(([d,m],y)=>({id:`demo-action-${y+1}`,actionId:`demo-action-${y+1}`,stageKey:["plan","issue","implementation","test","release"][y],title:d,detail:m,status:y<l?"done":y===l?"current":"pending",issueKey:`demo-${t.toLowerCase()}`,platform:n,updatedAt:new Date(Date.now()-(o-y)*45*60*1e3).toISOString()}));return{revision:`demo-${t}`,phase:(e==null?void 0:e.phase)||"PLANNING",pointer:(e==null?void 0:e.pointer)||((p=e==null?void 0:e.latestAction)==null?void 0:p.title)||"本地 Workflow 示例",actions:c,issues:Array.from({length:Math.min(4,Math.max(1,Number((e==null?void 0:e.issueCount)||1)))},(d,m)=>({key:`demo-${t.toLowerCase()}-${m+1}`,title:m===0?(e==null?void 0:e.title)||"示例研发事项":`子任务 ${m+1}`,platform:n,status:(e==null?void 0:e.state)==="completed"?"done":m===0?"in_progress":"pending",epicKey:"示例需求"})),globalState:{title:(e==null?void 0:e.title)||`TAPD ${t}`,status:{label:C$(e==null?void 0:e.state)},workflow:{namespace:"tapd",id:t},sections:{version:{title:"版本归属",fields:{version:{label:"版本",type:"text",value:r.title||"待归属"},date:{label:"版本日期",type:"text",value:r.date||"待确认"},platform:{label:"平台",type:"chips",value:[n]}}},progress:{title:"研发进度",fields:{actions:{label:"Action",type:"text",value:`${(e==null?void 0:e.completedActionCount)||0}/${(e==null?void 0:e.actionCount)||0}`},issues:{label:"Issues",type:"text",value:String((e==null?void 0:e.issueCount)||0)},owner:{label:"Owner",type:"user",value:(e==null?void 0:e.ownerUsername)||"demo-user"}}}}},runtimeEvents:c.map(d=>({...d,type:"demo-runtime-event"})),demo:!0}}function xae(e,t){if(t!=null&&t.demo)try{window.sessionStorage.setItem(`agentflow.workflow.demo:${t.tapdId}`,JSON.stringify(wae(t)))}catch{}e(yae(t))}function bae(){const{navigate:e}=us(),[t,n]=h.useState([]),[r,i]=h.useState([]),[o,a]=h.useState(0),[l,c]=h.useState("all"),[u,f]=h.useState(cae),[p,d]=h.useState(null),[m,y]=h.useState(!1),[v,b]=h.useState(""),[g,k]=h.useState(""),[x,_]=h.useState("all"),[j,N]=h.useState("all"),[P,T]=h.useState(!1),[z,E]=h.useState({start:0,end:0}),O=h.useRef(null),D=h.useRef(null),L=h.useRef(!1),$=h.useRef(0),V=h.useRef(0),W=h.useCallback(async()=>{T(!1),y(!0),b("");try{const K=await fetch(`/api/prd-workflows?view=${encodeURIComponent(u)}`),ee=await K.json().catch(()=>({}));if(!K.ok)throw new Error(ee.error||"读取迭代列表失败");const re=Array.isArray(ee.workflows)?ee.workflows:[],se=Array.isArray(ee.timeline)?ee.timeline:[];n(re),i(se),a(Number(ee.unassignedCount||0)),c(Q=>Q==="all"||Q==="unassigned"&&Number(ee.unassignedCount||0)>0||se.some(le=>le.key===Q)?Q:"all"),d(ee.team||null)}catch(K){b(String(K.message||K)),n([]),i([]),a(0),c("all"),d(null)}finally{y(!1)}},[u]),F=h.useCallback(()=>{const K=mae();n(K.workflows),i(K.timeline),a(K.unassignedCount),c("all"),k(""),_("all"),N("all"),b(""),T(!0)},[]);h.useEffect(()=>{W()},[W]),h.useEffect(()=>{try{localStorage.setItem(_$,u)}catch{}},[u]),h.useEffect(()=>{E(hae(r))},[r]),h.useLayoutEffect(()=>{const K=D.current,ee=O.current;if(ee){if(K){D.current=null;const re=Array.from(ee.children).find(se=>se.dataset.timelineKey===K.key);re&&(ee.scrollLeft=K.scrollLeft+re.offsetLeft-K.offsetLeft)}window.clearTimeout($.current),$.current=window.setTimeout(()=>{L.current=!1},80)}},[z]),h.useEffect(()=>()=>{window.clearTimeout($.current),window.cancelAnimationFrame(V.current)},[]);const M=h.useMemo(()=>r.slice(z.start,z.end),[r,z]),H=z.start>0,A=z.end<r.length,X=h.useCallback(()=>{if(!H||L.current)return;L.current=!0;const K=O.current,ee=K==null?void 0:K.querySelector("[data-timeline-key]");D.current=ee?{key:ee.dataset.timelineKey,offsetLeft:ee.offsetLeft,scrollLeft:K.scrollLeft}:null,E(re=>({start:Math.max(0,re.start-Ga),end:Math.min(re.end,Math.max(0,re.start-Ga)+fA)}))},[H]),q=h.useCallback(()=>{if(!A||L.current)return;L.current=!0;const K=O.current,ee=K==null?void 0:K.querySelectorAll("[data-timeline-key]"),re=ee==null?void 0:ee[ee.length-1];D.current=re?{key:re.dataset.timelineKey,offsetLeft:re.offsetLeft,scrollLeft:K.scrollLeft}:null,E(se=>({start:Math.max(se.start,Math.min(r.length,se.end+Ga)-fA),end:Math.min(r.length,se.end+Ga)}))},[A,r.length]),B=h.useCallback(K=>{const ee=K.currentTarget;V.current||(V.current=window.requestAnimationFrame(()=>{V.current=0,!L.current&&(ee.scrollLeft<=32?X():ee.scrollLeft+ee.clientWidth>=ee.scrollWidth-32&&q())}))},[X,q]),ne=h.useMemo(()=>r.find(K=>K.key===l)||null,[r,l]),ce=h.useMemo(()=>{const K=g.trim().toLowerCase();return t.filter(ee=>{var re;if(l==="unassigned"&&(ee.timeline||[]).length>0)return!1;if(l!=="all"&&l!=="unassigned"){const se=String((ee==null?void 0:ee.id)||(ee==null?void 0:ee.tapdId)||""),Q=Array.isArray(ne==null?void 0:ne.workflowIds)?ne.workflowIds:[];if(!(Q.length>0?Q.includes(se):(ee.timeline||[]).some(fe=>fe.key===l)))return!1}return x==="owned"&&ee.role!=="owner"||x==="collaborating"&&ee.role==="owner"||j!=="all"&&ee.state!==j?!1:K?[ee.tapdId,ee.title,ee.pointer,ee.phase,ee.ownerUsername,(re=ee.latestAction)==null?void 0:re.title,...(ee.timeline||[]).flatMap(se=>[se.title,se.kind,se.date,...Object.values(se.dimensions||{})])].some(se=>String(se||"").toLowerCase().includes(K)):!0})},[g,x,ne,j,l,t]);return s.jsx("div",{className:"af-settings-page af-workflows-page",children:s.jsx("div",{className:"af-settings-body",children:s.jsxs("div",{className:"af-settings-inner af-workflows-inner",children:[s.jsxs("section",{className:"af-settings-hero af-workflows-hero",children:[s.jsxs("div",{children:[s.jsx("span",{className:"af-workflows-eyebrow",children:"Workflow Dashboard"}),s.jsx("h1",{className:"af-settings-h1",children:"迭代"}),s.jsx("p",{className:"af-settings-lead",children:u==="team"?`汇总${p!=null&&p.name?`「${p.name}」`:"当前团队"}的需求 Workflow,按负责人追踪进度与风险。`:"集中查看我创建和参与的需求 Workflow,追踪阶段、Action 进度与最新动态。"})]}),s.jsxs("div",{className:"af-workflows-hero-actions",children:[s.jsxs("button",{type:"button",className:"af-workflows-guide-link",onClick:()=>e("/workflow-report"),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"integration_instructions"}),"接入说明"]}),s.jsxs("div",{className:"af-scope-switch","aria-label":"迭代视图",children:[s.jsx("button",{type:"button",className:u==="personal"?"is-active":"",onClick:()=>f("personal"),children:"个人迭代"}),s.jsx("button",{type:"button",className:u==="team"?"is-active":"",onClick:()=>f("team"),children:"团队迭代"})]}),s.jsxs("button",{type:"button",className:"af-schedules-refresh",onClick:()=>void W(),disabled:m,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:m?"hourglass_empty":"refresh"}),"刷新"]})]})]}),r.length>0||o>0?s.jsxs("section",{className:"af-workflows-timeline","aria-label":"迭代时间线",children:[s.jsxs("div",{className:"af-workflows-timeline__heading",children:[s.jsxs("div",{children:[s.jsx("span",{children:"迭代时间线"}),s.jsx("strong",{children:"按排期归属汇总"}),P?s.jsx("em",{children:"本地示例"}):null]}),s.jsxs("div",{className:"af-workflows-timeline__actions",children:[l!=="all"?s.jsx("button",{type:"button",onClick:()=>c("all"),children:"查看全部"}):null,P?s.jsx("button",{type:"button",onClick:()=>void W(),children:"退出示例"}):null]})]}),s.jsxs("div",{className:"af-workflows-timeline__rail",ref:O,onScroll:B,children:[M.map(K=>{const ee=fae(K),re=pae(K);return s.jsxs("button",{type:"button","data-timeline-key":K.key,className:`is-${re.key}${l===K.key?" is-active":""}`,"aria-pressed":l===K.key,onClick:()=>c(se=>se===K.key?"all":K.key),children:[s.jsxs("span",{className:"af-workflows-timeline__date",children:[dae(K.date),s.jsx("em",{children:re.label})]}),s.jsx("strong",{children:K.title||K.id}),s.jsx("small",{children:[ee,`${K.workflowCount||0} 项`,K.completedCount?`${K.completedCount} 项已完成`:"",K.blockedCount?`${K.blockedCount} 项需关注`:""].filter(Boolean).join(" · ")})]},K.key)}),o>0&&!A?s.jsxs("button",{type:"button",className:`af-workflows-timeline__unassigned${l==="unassigned"?" is-active":""}`,"aria-pressed":l==="unassigned",onClick:()=>c(K=>K==="unassigned"?"all":"unassigned"),children:[s.jsx("span",{className:"af-workflows-timeline__date",children:"未排期"}),s.jsx("strong",{children:"未归属"}),s.jsxs("small",{children:[o," 项 Workflow"]})]}):null]})]}):null,s.jsxs("section",{className:"af-workflows-toolbar","aria-label":"迭代筛选",children:[s.jsxs("label",{className:"af-workflows-search",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"search"}),s.jsx("input",{value:g,onChange:K=>k(K.target.value),placeholder:"搜索 TAPD、需求、阶段或成员","aria-label":"搜索迭代"})]}),s.jsx("div",{className:"af-workflows-segments","aria-label":"协作范围",children:[["all","全部"],["owned","我创建的"],["collaborating","与我协作"]].map(([K,ee])=>s.jsx("button",{type:"button",className:x===K?"is-active":"","aria-pressed":x===K,onClick:()=>_(K),children:ee},K))}),s.jsxs("select",{value:j,onChange:K=>N(K.target.value),"aria-label":"迭代状态",children:[s.jsx("option",{value:"all",children:"全部状态"}),s.jsx("option",{value:"active",children:"进行中"}),s.jsx("option",{value:"completed",children:"已完成"}),s.jsx("option",{value:"blocked",children:"需关注"})]})]}),v?s.jsx("div",{className:"af-workflows-message af-workflows-message--error",children:v}):null,m?s.jsx("div",{className:"af-workflows-message",children:"正在读取迭代..."}):null,!m&&!v&&t.length===0?s.jsxs("div",{className:"af-workflows-empty",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"timeline"}),s.jsx("strong",{children:u==="team"&&!p?"尚未加入团队":"暂无迭代"}),s.jsx("p",{children:u==="team"&&!p?"请联系超级管理员完成团队划分。":"当 prd-flow 上报 Workflow 后,它会出现在这里。"}),s.jsxs("button",{type:"button",className:"af-workflows-demo-button",onClick:F,children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"science"}),"载入本地示例时间线"]})]}):null,!m&&t.length>0&&ce.length===0?s.jsx("div",{className:"af-workflows-message",children:"没有符合当前筛选条件的迭代。"}):null,s.jsx("div",{className:"af-workflows-list",children:ce.map(K=>{var re,se;const ee=K.actionCount>0?Math.round(K.completedActionCount/K.actionCount*100):0;return s.jsxs("article",{className:"af-workflow-card",children:[s.jsxs("div",{className:"af-workflow-card__identity",children:[s.jsxs("div",{className:"af-workflow-card__title-row",children:[s.jsxs("span",{className:"af-workflow-tapd",children:["TAPD ",K.tapdId]}),s.jsx("span",{className:`af-workflow-state af-workflow-state--${K.state||"active"}`,children:C$(K.state)}),s.jsx("span",{className:"af-workflow-role",children:gae(K.role)}),K.shareActive?s.jsxs("span",{className:"af-workflow-shared",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"link"}),"已分享"]}):null]}),s.jsx("h2",{children:K.title||`TAPD ${K.tapdId}`}),s.jsxs("div",{className:"af-workflow-card__meta",children:[s.jsx("span",{children:K.phase||"未识别阶段"}),s.jsxs("span",{children:[K.issueCount||0," Issues"]}),(K.platforms||[]).map(Q=>s.jsx("span",{children:A$(Q)},Q)),(K.timeline||[]).map(Q=>s.jsx("span",{children:Q.title||Q.id},Q.key)),(K.projectBindings||[]).map(Q=>s.jsxs("span",{children:["Project · ",Q.label||Q.flowId]},Q.workspaceId)),s.jsxs("span",{children:["Owner · ",K.ownerUsername||K.ownerId||"-"]}),u==="team"&&K.teamName?s.jsxs("span",{children:["团队 · ",K.teamName]}):null]})]}),s.jsxs("div",{className:"af-workflow-card__progress",children:[s.jsxs("div",{children:[s.jsx("span",{children:"Action 进度"}),s.jsxs("strong",{children:[K.completedActionCount||0,"/",K.actionCount||0]})]}),s.jsx("div",{className:"af-workflow-progress","aria-label":`Action 完成度 ${ee}%`,children:s.jsx("span",{style:{width:`${ee}%`}})}),s.jsxs("small",{children:[ee,"%"]})]}),s.jsxs("div",{className:"af-workflow-card__latest",children:[s.jsx("span",{children:"最新动态"}),s.jsx("strong",{children:((re=K.latestAction)==null?void 0:re.title)||"暂无 Action 记录"}),s.jsx("small",{children:uae(((se=K.latestAction)==null?void 0:se.at)||K.updatedAt)})]}),s.jsxs("button",{type:"button",className:"af-workflow-open",onClick:()=>xae(e,K),children:[K.demo?"查看示例":"打开 Workflow",s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:K.demo?"science":"arrow_forward"})]})]},K.id||K.tapdId)})})]})})})}const kae=`skillhub install agentflow-cli --global --agent codex
|
|
321
|
+
skillhub install agentflow-workflow-report --global --agent codex
|
|
322
|
+
|
|
323
|
+
export AGENTFLOW_BASE_URL=http://ai.mengma.bigo.inner
|
|
324
|
+
export AGENTFLOW_TOKEN=<your-token>
|
|
325
|
+
|
|
326
|
+
# 本地联调
|
|
327
|
+
# export AGENTFLOW_BASE_URL=http://127.0.0.1:8765`,vae=`{
|
|
328
|
+
"schemaVersion": 1,
|
|
329
|
+
"workflow": { "namespace": "tapd", "id": "1020124" },
|
|
330
|
+
"source": "my-adapter",
|
|
331
|
+
"action": {
|
|
332
|
+
"key": "requirement-imported",
|
|
333
|
+
"title": "需求已同步",
|
|
334
|
+
"status": "done",
|
|
335
|
+
"occurredAt": "2026-08-05T08:00:00.000Z"
|
|
336
|
+
},
|
|
337
|
+
"expectedVersions": {
|
|
338
|
+
"action:my-adapter:requirement-imported": "absent"
|
|
339
|
+
},
|
|
340
|
+
"idempotencyKey": "requirement-imported:1020124:v1"
|
|
341
|
+
}`,Sae=`# 1. 读取;记录本次要修改 key 的 snapshot.resourceVersions
|
|
342
|
+
node skills/agentflow-cli/scripts/agentflow-cli.mjs workflow-get \\
|
|
343
|
+
--workflow tapd:1020124 --runtime-only
|
|
344
|
+
|
|
345
|
+
# 2. 将右侧 JSON 保存为 workflow-report.json 后上报
|
|
346
|
+
node skills/agentflow-cli/scripts/agentflow-cli.mjs workflow-report \\
|
|
347
|
+
--workflow tapd:1020124 \\
|
|
348
|
+
--file workflow-report.json
|
|
349
|
+
|
|
350
|
+
# 3. 再读一次,确认 action 和对应 resourceVersions 已更新
|
|
351
|
+
node skills/agentflow-cli/scripts/agentflow-cli.mjs workflow-get \\
|
|
352
|
+
--workflow tapd:1020124 --runtime-only`,jae=`GET /api/workflows/state?workflow=tapd%3A1020124&runtimeOnly=1
|
|
353
|
+
Authorization: Bearer <AGENTFLOW_TOKEN>`,Nae=`{
|
|
354
|
+
"ok": true,
|
|
355
|
+
"workflow": {
|
|
356
|
+
"namespace": "tapd",
|
|
357
|
+
"id": "1020124",
|
|
358
|
+
"key": "tapd:1020124"
|
|
359
|
+
},
|
|
360
|
+
"snapshot": {
|
|
361
|
+
"runtimeRevision": "runtime:<current-revision>",
|
|
362
|
+
"resourceVersions": {
|
|
363
|
+
"action:my-adapter:requirement-imported": "rv:<resource-version>"
|
|
364
|
+
},
|
|
365
|
+
"globalState": {},
|
|
366
|
+
"actions": [],
|
|
367
|
+
"artifacts": [],
|
|
368
|
+
"projections": { "timeline": [] },
|
|
369
|
+
"extensions": {}
|
|
370
|
+
}
|
|
371
|
+
}`,_ae=`{
|
|
372
|
+
"workflow": { "namespace": "tapd", "id": "1020124" },
|
|
373
|
+
"authority": {
|
|
374
|
+
"type": "tapd",
|
|
375
|
+
"owner": { "username": "alice" },
|
|
376
|
+
"participants": ["alice", "bob", "carol"],
|
|
377
|
+
"observedAt": "2026-08-05T08:00:00.000Z",
|
|
378
|
+
"revision": "tapd-story-modified-at-or-content-digest"
|
|
379
|
+
}
|
|
380
|
+
}`,Cae=`{
|
|
381
|
+
"schemaVersion": 1,
|
|
382
|
+
"workflow": { "namespace": "tapd", "id": "1020124" },
|
|
383
|
+
"source": "prd-flow",
|
|
384
|
+
"globalState": {
|
|
385
|
+
"mode": "merge",
|
|
386
|
+
"patch": {
|
|
387
|
+
"tapdCurrentVersion": {
|
|
388
|
+
"id": "1133202860001000338",
|
|
389
|
+
"name": "Likee Android&iOS 5.63.0",
|
|
390
|
+
"date": "2026-08-31",
|
|
391
|
+
"platforms": ["android", "ios"]
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
},
|
|
395
|
+
"projections": {
|
|
396
|
+
"timeline": [
|
|
397
|
+
{
|
|
398
|
+
"kind": "version",
|
|
399
|
+
"id": "1133202860001000338",
|
|
400
|
+
"key": "prd-flow:tapd-current-version:1133202860001000338",
|
|
401
|
+
"title": "Likee Android&iOS 5.63.0",
|
|
402
|
+
"date": "2026-08-31",
|
|
403
|
+
"source": "prd-flow",
|
|
404
|
+
"dimensions": { "platform": ["android", "ios"] }
|
|
405
|
+
}
|
|
406
|
+
]
|
|
407
|
+
},
|
|
408
|
+
"expectedVersions": {
|
|
409
|
+
"global:tapdCurrentVersion.id": "rv:<version-from-get-or-absent>",
|
|
410
|
+
"global:tapdCurrentVersion.name": "rv:<version-from-get-or-absent>",
|
|
411
|
+
"global:tapdCurrentVersion.date": "rv:<version-from-get-or-absent>",
|
|
412
|
+
"global:tapdCurrentVersion.platforms": "rv:<version-from-get-or-absent>",
|
|
413
|
+
"projection:prd-flow:version:1133202860001000338": "absent"
|
|
414
|
+
},
|
|
415
|
+
"idempotencyKey": "timeline:1020124:version-1133202860001000338:v1"
|
|
416
|
+
}`,Aae=`{
|
|
417
|
+
"schemaVersion": 1,
|
|
418
|
+
"workflow": { "namespace": "tapd", "id": "1020124" },
|
|
419
|
+
"source": "prd-flow",
|
|
420
|
+
"action": {
|
|
421
|
+
"key": "implementation:runtime-hook:android",
|
|
422
|
+
"title": "Android 实现完成",
|
|
423
|
+
"detail": "MR !957 已合并",
|
|
424
|
+
"status": "done",
|
|
425
|
+
"group": "implementation",
|
|
426
|
+
"platform": "android",
|
|
427
|
+
"issueKey": "runtime-hook",
|
|
428
|
+
"occurredAt": "2026-08-05T08:25:00.000Z"
|
|
429
|
+
},
|
|
430
|
+
"artifacts": [{
|
|
431
|
+
"key": "implementation-mr:runtime-hook:android",
|
|
432
|
+
"type": "gitlab-mr",
|
|
433
|
+
"title": "实现 MR !957",
|
|
434
|
+
"url": "https://git.example.test/merge_requests/957",
|
|
435
|
+
"scope": "action",
|
|
436
|
+
"status": "ready"
|
|
437
|
+
}],
|
|
438
|
+
"expectedVersions": {
|
|
439
|
+
"action:prd-flow:implementation:runtime-hook:android": "absent",
|
|
440
|
+
"artifact:prd-flow:implementation-mr:runtime-hook:android": "absent"
|
|
441
|
+
},
|
|
442
|
+
"idempotencyKey": "implementation-finished:android:runtime-hook:v1"
|
|
443
|
+
}`,Eae=`{
|
|
444
|
+
"schemaVersion": 1,
|
|
445
|
+
"workflow": { "namespace": "tapd", "id": "1020124" },
|
|
446
|
+
"source": "prd-flow",
|
|
447
|
+
"extensions": {
|
|
448
|
+
"prd-flow": {
|
|
449
|
+
"aiDocs": [{
|
|
450
|
+
"key": "tech-design",
|
|
451
|
+
"title": "技术方案",
|
|
452
|
+
"url": "https://ai-doc.example.test/docs/123"
|
|
453
|
+
}],
|
|
454
|
+
"issues": [{
|
|
455
|
+
"key": "runtime-hook",
|
|
456
|
+
"title": "Runtime Hook",
|
|
457
|
+
"platform": "android",
|
|
458
|
+
"status": "implementing"
|
|
459
|
+
}]
|
|
460
|
+
}
|
|
461
|
+
},
|
|
462
|
+
"expectedVersions": {
|
|
463
|
+
"extension:prd-flow:aiDocs": "rv:<version-from-get-or-absent>",
|
|
464
|
+
"extension:prd-flow:issues": "rv:<version-from-get-or-absent>"
|
|
465
|
+
},
|
|
466
|
+
"idempotencyKey": "prd-panels:1020124:<semantic-digest>"
|
|
467
|
+
}`,Iae=`{
|
|
468
|
+
"workflow": { "namespace": "tapd", "id": "1020124" },
|
|
469
|
+
"source": "my-adapter",
|
|
470
|
+
"globalState": {
|
|
471
|
+
"mode": "merge",
|
|
472
|
+
"patch": {
|
|
473
|
+
"title": "Remote Config 拉取频控",
|
|
474
|
+
"url": "https://tapd.example.test/1020124",
|
|
475
|
+
"status": "实现中",
|
|
476
|
+
"sections": {
|
|
477
|
+
"ownership": {
|
|
478
|
+
"title": "归属信息",
|
|
479
|
+
"fields": {
|
|
480
|
+
"owner": {
|
|
481
|
+
"label": "负责人",
|
|
482
|
+
"type": "user",
|
|
483
|
+
"value": { "username": "alice" }
|
|
484
|
+
},
|
|
485
|
+
"platforms": {
|
|
486
|
+
"label": "平台",
|
|
487
|
+
"type": "chips",
|
|
488
|
+
"value": ["Android", "iOS"]
|
|
489
|
+
},
|
|
490
|
+
"branch": {
|
|
491
|
+
"label": "需求分支",
|
|
492
|
+
"type": "text",
|
|
493
|
+
"value": "story/1020124"
|
|
494
|
+
},
|
|
495
|
+
"risks": {
|
|
496
|
+
"label": "当前风险",
|
|
497
|
+
"type": "list",
|
|
498
|
+
"value": ["等待服务端字段确认", "灰度策略待补充"]
|
|
499
|
+
},
|
|
500
|
+
"design": {
|
|
501
|
+
"label": "技术方案",
|
|
502
|
+
"type": "link",
|
|
503
|
+
"value": "打开方案文档",
|
|
504
|
+
"url": "https://docs.example.test/1020124"
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
}
|
|
511
|
+
}`,Pae=`POST /api/workflow-artifacts/publish
|
|
512
|
+
Authorization: Bearer <AGENTFLOW_TOKEN>
|
|
513
|
+
Content-Type: application/json
|
|
514
|
+
|
|
515
|
+
{
|
|
516
|
+
"workflow": { "namespace": "tapd", "id": "1020124" },
|
|
517
|
+
"source": "prd-flow",
|
|
518
|
+
"title": "Issue1 · Android 方案草稿",
|
|
519
|
+
"markdown": "# 方案内容\\n...",
|
|
520
|
+
"stage": "issue-plan:runtime-hook",
|
|
521
|
+
"issueKey": "runtime-hook",
|
|
522
|
+
"platform": "android",
|
|
523
|
+
"artifactKey": "plan:runtime-hook:android",
|
|
524
|
+
"artifactLabel": "方案预览",
|
|
525
|
+
"durability": "temporary",
|
|
526
|
+
"ttlDays": 7,
|
|
527
|
+
"expectedVersions": {
|
|
528
|
+
"artifact:prd-flow:plan:runtime-hook:android": "absent"
|
|
529
|
+
},
|
|
530
|
+
"idempotencyKey": "review:plan:runtime-hook:android:<content-digest>"
|
|
531
|
+
}`,pA=`请使用 $agentflow-workflow-report 接入一个生产方,并完整阅读 references/protocol.md。
|
|
532
|
+
|
|
533
|
+
运行态数据只有三个正式接口,TAPD 人员权限另有一个控制面接口:
|
|
534
|
+
0. POST /api/workflows/access/sync:把 TAPD Owner 和参与人同步为 Workflow 派生权限;它不写业务状态。
|
|
535
|
+
1. GET /api/workflows/state:读取当前状态和 snapshot.resourceVersions。
|
|
536
|
+
2. POST /api/workflows/report:写全局信息、Action、普通产物、迭代投影或自定义区域。
|
|
537
|
+
3. POST /api/workflow-artifacts/publish:把本地 Markdown 内容发布成预览 URL。
|
|
538
|
+
|
|
539
|
+
先输出接入映射表:
|
|
540
|
+
- 稳定 Workflow 身份是什么;当前服务支持 tapd:<short-id>。
|
|
541
|
+
- 哪些事实进入 observation.state / globalState。
|
|
542
|
+
- 哪些关键业务节点进入 action;每个稳定 action.key 是什么。
|
|
543
|
+
- 哪些外部链接进入 artifacts;哪些本地 Markdown 需要先 publish。
|
|
544
|
+
- 哪些版本/Sprint/里程碑进入 projections.timeline。
|
|
545
|
+
- 普通自定义信息是否可用 globalState.sections 的 text/user/chips/list/link 渲染器表达。
|
|
546
|
+
- 只有通用渲染器不够时,才设计 extensions namespace/schema/前端渲染器。
|
|
547
|
+
|
|
548
|
+
实现 access sync → read → merge → report → verify:
|
|
549
|
+
- TAPD Owner 映射为 Workflow Owner;TAPD 参与人默认 Viewer;Owner 可在 AgentFlow 中显式授予 Reporter。
|
|
550
|
+
- owner/reporter 才能写;viewer、团队成员、分享链接、管理员代看只读。
|
|
551
|
+
- globalState 只 patch 自己拥有的路径;对象递归合并,数组/标量替换。
|
|
552
|
+
- source 使用真实业务 Adapter 的稳定小写名称;agentflow-cli 只是传输工具。
|
|
553
|
+
- 同一 source + action.key 更新同一阶段,不为刷新或重试创建新 key。
|
|
554
|
+
- timeline 只提交当前 source 的完整切片;服务端原子保留其他生产方条目。
|
|
555
|
+
- globalState.sections 是当前通用自定义卡片能力;优先使用现有 field type。
|
|
556
|
+
- extensions 只写自己的 namespace;当前仅 prd-flow 注册了 AI Docs / Issues 专用 renderer,保存其他 namespace 不会自动出现 UI。
|
|
557
|
+
- 为本次触及的每个业务 key 携带 expectedVersions 与稳定 idempotencyKey;任一 key 冲突时整次请求不落库,刷新冲突 key 后只重试一次。
|
|
558
|
+
- 不输出 Token,不新增生产方专用写接口,不使用 /api/prd-workflow/* 兼容接口。
|
|
559
|
+
|
|
560
|
+
最后验证 Workflow 全局区域、Action 时间轴、产物链接、个人/团队迭代和自定义区域。`,Tae=[{method:"POST",path:"/api/workflows/access/sync",title:"同步 TAPD 权限",detail:"把 TAPD Owner 和参与人投影为 Workflow 派生权限;不传业务状态。",permission:"首次为 TAPD Owner;后续为当前 Owner / 管理员",effect:"更新 Owner 与 TAPD Viewer,保留显式授权"},{method:"GET",path:"/api/workflows/state",title:"读取当前 Workflow",detail:"取得服务端物化快照与每个业务 key 的 resourceVersions;安全写入的第一步。",permission:"可访问该 Workflow 的用户可读",effect:"只读,不修改任何状态"},{method:"POST",path:"/api/workflows/report",title:"统一上报",detail:"写入全局信息、Action、普通产物、迭代归属和自定义区域。",permission:"owner / reporter",effect:"按区域执行替换、合并或更新"},{method:"POST",path:"/api/workflow-artifacts/publish",title:"发布 Markdown 预览",detail:"上传 Markdown 内容,生成可供浏览器查看的规范 URL 与短链。",permission:"owner / reporter",effect:"保存预览副本与辅助 Artifact,不推进阶段"}],Rae=[["workflow","string","二选一","规范 Workflow key,例如 tapd:1020124"],["namespace + id","string","二选一","拆分传入身份;当前 namespace 仅支持 tapd"],["runtimeOnly","0 | 1","否","1 只读已保存运行态,不主动刷新上游"],["flowId / flowSource","string","否","关联 AgentFlow 项目上下文;flowSource 默认 user"],["workspaceId","string","否","关联项目的工作区上下文"],["workflowShare","string","否","只读分享 token,不能用于写接口"]],Mae=[["workflow","object","规范身份 {namespace,id,key}"],["snapshot.resourceVersions","object","业务 key 到并发版本的映射;新接入按本次触及 key 取值"],["snapshot.runtimeRevision","string","整份运行态版本;页面缓存与旧客户端兼容使用"],["snapshot.globalState","object","服务端合并后的全局区域"],["snapshot.actions","array","已物化的 Action 时间轴"],["snapshot.artifacts","array","已物化的全局产物"],["snapshot.projections.timeline","array","当前完整迭代归属"],["snapshot.extensions","object","所有已保存的 namespace 数据"]],$ae=[["schemaVersion","number","否","当前固定为 1"],["workflow","object | string","是","{namespace,id} 或规范 key"],["source","string","是","真实业务 Adapter 的稳定小写名称;agentflow-cli 仅负责传输"],["expectedVersions","object","生产建议","本次触及的每个 resource key 及读取时版本;新建 key 使用 absent"],["expectedRevision","string","兼容","仅未提供 expectedVersions 时启用的整 Workflow 锁"],["idempotencyKey","string","建议","业务操作稳定身份,不使用时间戳或随机 UUID"],["observation","object","条件","同一 clientId 的完整生产方观察"],["globalState","object","条件","全局事实的 merge patch 与 remove"],["action","object","条件","一个关键业务阶段;key 必填"],["artifacts","array","条件","Action 证据或全局证据"],["projections","object","条件","当前 source 的完整 timeline 迭代归属切片"],["extensions","object","条件","按生产方 namespace 组织的自定义区域"]],Lae=[["workflow","object | string","是","规范 Workflow 身份;当前仅 tapd:<short-id>"],["authority.type","string","是","当前固定为 tapd;表示权限事实来源,不是 report source"],["authority.owner","string | object","是","TAPD 需求 Owner 的 AgentFlow username/userId;必须已登录或注册"],["authority.participants","array","否","TAPD 参与人用户名;匹配到账号后自动获得 Viewer"],["authority.observedAt","ISO date","建议","读取 TAPD 人员快照的时间;旧于已保存快照时返回 409"],["authority.revision","string","建议","TAPD modified 值或人员内容摘要,供审计和排查"]],Oae=[["key","string","是","稳定阶段身份;同 key 更新同一阶段"],["title / detail","string","否","时间轴卡片标题与摘要"],["status","enum","否","pending/running/done/error/conflict/skipped/cancelled/observed"],["group / scope","string","否","阶段分组与业务范围"],["platform / issueKey","string","否","平台和自定义 Issue 维度"],["tags","string[]","否","额外筛选标签"],["occurredAt","ISO date","否","业务发生时间,不是 HTTP 重试时间"]],Dae=[["schema","string","否","生产方观察 schema,建议带版本,例如 my-adapter/v1"],["clientId","string","建议","稳定客户端身份;决定哪份完整观察被替换"],["observedAt","ISO date","建议","本次事实采集时间"],["scope","string","否","观察范围,默认 client"],["state","object","是","该 clientId 的完整当前观察,不是 patch"]],Fae=[["mode","merge","是","当前只支持 merge"],["patch","object","条件","对象递归合并;数组、标量整体替换;null 删除字段"],["remove","string[]","条件","显式删除点路径,例如 sections.progress.fields.owner"]],zae=[["sections.<key>.title","string","建议","分区标题;key=progress 使用紧凑网格"],["fields.<key>.label","string","建议","字段显示名"],["fields.<key>.type","enum","否","text / user / chips / list / link;未知值回退 text"],["fields.<key>.value","any","是","展示值;空值不渲染"],["fields.<key>.url","string","link 条件","link 类型的跳转地址"]],Bae=[["timeline","array","是","替换当前 source 的完整切片;省略 projections 才表示不修改"],["timeline[].kind","string","是","version / sprint / milestone 或生产方自定义类型"],["timeline[].id","string","是","业务对象稳定 ID;改名、改期或平台范围变化时不改变"],["timeline[].key","string","建议","建议 source:kind:id;不要拼入 platform 等筛选维度"],["timeline[].title / date","string","否","卡片标题和 YYYY-MM-DD 排期"],["timeline[].source","string","建议","条目所有者,用于 read-merge 时识别自有条目"],["timeline[].dimensions","object","否","平台、发布列车等不透明筛选维度;多值可使用数组"]],Wae=[["extensions.<namespace>","object","是","生产方自有、带版本约定的结构化 JSON"],["namespace","string","是","小写稳定标识;建议与 report.source 相同"],["对象字段","object","否","递归合并;null 删除"],["数组 / 标量","any","否","整体替换,不做元素级 merge"],["renderer","前端注册","展示条件","未知 namespace 只保存,不自动出现面板"]],Hae=[["key","string","建议","稳定证据身份;不要依赖标题去重"],["type","string","否","gitlab-mr/build/test-report/document 等"],["title","string","否","页面展示标题"],["url / path","string","至少一个","外部地址或可识别路径"],["scope","action | global","否","有 Action 时默认 action"],["status","string","否","生产方定义的证据状态"]],Vae=[["workflow","object | string","是","目标 Workflow"],["source","string","是","真实生产方身份;agentflow-cli 只是传输工具"],["title","string","是","Review 页面标题"],["markdown","string","是","Markdown 实际内容,不是本地文件路径"],["stage / stageKey","string","建议","关联的稳定 Action 阶段"],["issueKey / platform","string","否","Issue 与平台维度"],["artifactKey","string","是","预览 Artifact 的稳定槽位"],["artifactLabel","string","否","页面按钮文案"],["durability","enum","否","temporary 或 durable"],["ttlDays","number","临时建议","临时预览有效期,通常 7 天"],["expectedVersions","object","生产建议","目标 artifact:source:key 的当前版本;新建使用 absent"],["expectedRevision","string","兼容","仅未提供 expectedVersions 时启用的整 Workflow 锁"],["idempotencyKey","string","建议","包含内容摘要;同 source + key 重放返回同一预览"]],hA=[["api","快速开始"],["model","区域模型"],["renderers","渲染效果"],["reference","参数参考"],["scenarios","关键场景"],["safety","权限与覆盖"],["design","设计思想"],["ai","AI 引导"]],Kae=[{icon:"dashboard",name:"全局区域",question:"这个需求现在是什么?",fields:"observation.state · globalState · projections.timeline",detail:"标题、状态、负责人、平台、版本事实和迭代归属。事实留在 globalState,迭代列表只读取可重建的 projection。"},{icon:"timeline",name:"Action 时间轴",question:"关键阶段发生了什么?",fields:"action · artifacts",detail:"方案确认、实现、提测、发布等业务节点及其 MR、构建、测试或文档证据。Action 不是刷新日志。"},{icon:"extension",name:"自定义展示",question:"生产方还需要展示什么?",fields:"globalState.sections · extensions[namespace]",detail:"普通键值、标签、列表和链接优先使用通用 sections;只有需要树形结构或专用交互时才使用 extensions 并开发 renderer。"}],qae=[["observation.state","同一 clientId 完整替换","省略不改","只替换自己的完整观察"],["globalState","对象递归合并;数组/标量替换","null 或 remove 删除","只 patch 自己拥有的路径"],["action","同 source + action.key 更新同一阶段","无通用物理删除","取消/跳过使用业务状态表达"],["artifacts","同 source + 稳定 key 更新/归并","无通用物理删除","不要改 key 来伪造删除"],["projections.timeline","当前 source 的完整切片替换","[] 只清空当前 source","其他生产方条目由服务端原子保留"],["extensions","仅 extensions[source] 内对象递归合并;数组/标量替换","null 删除自有字段","不能写别人的 namespace"]],Uae=[["TAPD Owner","可读","可写","Workflow Owner;可管理成员和分享"],["显式 Reporter","可读","可写","Owner 主动授权;不能管理成员"],["TAPD 参与人","可读","只读","由 TAPD 派生;移出 TAPD 后自动收回"],["显式 Viewer","可读","只读","Owner 主动授权;不依赖 TAPD"],["同团队成员","可读","只读","自动获得 team viewer"],["分享链接","可读","只读","不能用于上报"],["超级管理员代看","可读","只读","不会以管理员身份覆盖数据"]];async function Gae(e){var n;const t=String(e||"");if(!t)return!1;try{if((n=navigator.clipboard)!=null&&n.writeText&&window.isSecureContext)return await navigator.clipboard.writeText(t),!0}catch{}try{const r=document.createElement("textarea");r.value=t,r.setAttribute("readonly",""),r.style.position="fixed",r.style.top="-9999px",document.body.appendChild(r),r.select();const i=document.execCommand("copy");return r.remove(),i}catch{return!1}}function Wo({number:e,title:t,detail:n}){return s.jsxs("div",{className:"af-wr-section__head",children:[s.jsx("span",{children:e}),s.jsxs("div",{children:[s.jsx("h2",{children:t}),s.jsx("p",{children:n})]})]})}function Ms({title:e,value:t,copyKey:n,copied:r,onCopy:i,wrap:o=!1}){const a=r===`failed:${n}`;return s.jsxs("div",{className:`af-wr-code-panel${o?" is-wrap":""}`,children:[s.jsxs("div",{className:"af-wr-code-panel__head",children:[s.jsx("span",{children:e}),s.jsxs("button",{type:"button",onClick:()=>void i(n,t),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:r===n?"check":"content_copy"}),r===n?"已复制":"复制"]})]}),s.jsx("pre",{children:t}),a?s.jsx("p",{className:"af-wr-copy-error",children:"浏览器禁止访问剪贴板,请手动选择代码块内容。"}):null]})}function Zr({columns:e=["参数","类型","必填","含义"],rows:t,label:n}){return s.jsxs("div",{className:`af-wr-table is-${e.length}-columns`,role:"table","aria-label":n,children:[s.jsx("div",{className:"af-wr-table__row is-head",role:"row",children:e.map(r=>s.jsx("span",{role:"columnheader",children:r},r))}),t.map(r=>s.jsx("div",{className:"af-wr-table__row",role:"row",children:r.map((i,o)=>s.jsx("span",{role:"cell","data-label":e[o],children:i},`${r[0]}-${o}`))},r[0]))]})}function gh({method:e,path:t,title:n,permission:r,effect:i}){return s.jsxs("div",{className:"af-wr-endpoint__head",children:[s.jsxs("div",{className:"af-wr-endpoint__identity",children:[s.jsx("span",{className:`is-${e.toLowerCase()}`,children:e}),s.jsx("code",{children:t}),s.jsx("h3",{children:n})]}),s.jsxs("dl",{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"权限"}),s.jsx("dd",{children:r})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"副作用"}),s.jsx("dd",{children:i})]})]})]})}function Yae(){return s.jsxs("article",{className:"af-prd-workflow-card af-prd-overall af-wr-render-preview",children:[s.jsxs("div",{className:"af-prd-workflow-card__head",children:[s.jsx("h2",{children:"需求概览"}),s.jsx("span",{className:"af-prd-overall__status",children:"实现中"})]}),s.jsx("div",{className:"af-prd-overall__requirement",children:s.jsx("strong",{children:"Remote Config 拉取频控"})}),s.jsx("div",{className:"af-prd-overall__platforms",children:s.jsxs("section",{className:"af-prd-overall-platform",children:[s.jsx("div",{className:"af-prd-overall-platform__head",children:s.jsx("strong",{children:"归属信息"})}),s.jsxs("div",{className:"af-prd-overall-platform__fields",children:[s.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--user",children:[s.jsx("small",{children:"负责人 · user"}),s.jsx("div",{children:s.jsx("span",{children:"alice"})})]}),s.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--chips",children:[s.jsx("small",{children:"平台 · chips"}),s.jsxs("div",{children:[s.jsx("span",{children:"Android"}),s.jsx("span",{children:"iOS"})]})]}),s.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--text",children:[s.jsx("small",{children:"需求分支 · text"}),s.jsx("div",{children:s.jsx("span",{children:"story/1020124"})})]}),s.jsxs("div",{className:"af-prd-overall-platform__rules",children:[s.jsx("small",{children:"当前风险 · list"}),s.jsxs("ul",{children:[s.jsx("li",{children:"等待服务端字段确认"}),s.jsx("li",{children:"灰度策略待补充"})]})]}),s.jsxs("div",{className:"af-prd-overall-platform__row af-prd-overall-platform__row--link",children:[s.jsx("small",{children:"技术方案 · link"}),s.jsxs("span",{className:"af-wr-preview-link",children:[s.jsx("span",{children:"打开方案文档"}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})]})]})]})})]})}function Jae(){return s.jsxs("div",{className:"af-prd-workflow-action af-prd-workflow-action--done af-wr-render-preview",children:[s.jsx("div",{className:"af-prd-workflow-action__rail",children:s.jsx("span",{className:"af-prd-workflow-action__dot"})}),s.jsxs("div",{className:"af-prd-workflow-action__body",children:[s.jsxs("div",{className:"af-prd-workflow-action__top",children:[s.jsxs("div",{children:[s.jsxs("div",{className:"af-prd-workflow-action__title",children:[s.jsx("time",{children:"16:25:40"}),s.jsx("strong",{children:"Android 实现完成"})]}),s.jsx("p",{children:"MR !957 已合并"}),s.jsxs("div",{className:"af-prd-workflow-action__meta",children:[s.jsxs("span",{className:"af-prd-workflow-action__meta-item af-prd-workflow-action__meta-item--issue",children:[s.jsx("b",{children:"Issue"}),s.jsx("span",{className:"af-prd-workflow-action__meta-value",children:"runtime-hook"})]}),s.jsxs("span",{className:"af-prd-workflow-action__meta-item af-prd-workflow-action__meta-item--platform",children:[s.jsx("b",{children:"平台"}),s.jsx("span",{className:"af-prd-workflow-action__meta-value",children:"Android"})]})]})]}),s.jsx("span",{className:"af-prd-workflow-action__status",children:"完成"})]}),s.jsx("div",{className:"af-prd-workflow-action__links",children:s.jsxs("span",{className:"af-wr-preview-link",children:[s.jsx("span",{children:"实现 MR !957"}),s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"open_in_new"})]})})]})]})}function Xae(){return s.jsxs("article",{className:"af-prd-workflow-card af-wr-render-preview",children:[s.jsxs("div",{className:"af-prd-workflow-card__head",children:[s.jsx("h2",{children:"关联产物"}),s.jsx("span",{children:"2"})]}),s.jsxs("div",{className:"af-prd-workflow-list",children:[s.jsxs("span",{className:"af-wr-preview-link",children:[s.jsx("span",{children:"测试报告 #128"}),s.jsx("small",{children:"test-report"})]}),s.jsxs("span",{className:"af-wr-preview-link",children:[s.jsx("span",{children:"Jenkins Build #8451"}),s.jsx("small",{children:"build"})]})]})]})}function Qae(){return s.jsxs("section",{className:"af-workflows-timeline af-wr-render-preview",children:[s.jsx("div",{className:"af-workflows-timeline__heading",children:s.jsxs("div",{children:[s.jsx("span",{children:"迭代时间线"}),s.jsx("strong",{children:"按排期归属汇总"})]})}),s.jsx("div",{className:"af-workflows-timeline__rail",children:s.jsxs("button",{type:"button",className:"is-active",children:[s.jsxs("span",{className:"af-workflows-timeline__date",children:["2026/08/31",s.jsx("em",{children:"计划中"})]}),s.jsx("strong",{children:"Likee Android 5.63.0"}),s.jsx("small",{children:"Android · 3 项 · 1 项需关注"})]})})]})}function Zae(){return s.jsxs("div",{className:"af-wr-extension-preview",children:[s.jsxs("section",{children:[s.jsxs("div",{children:[s.jsx("span",{children:"AI DOCS"}),s.jsx("strong",{children:"2"})]}),s.jsx("p",{children:"技术方案"}),s.jsx("p",{children:"测试与灰度说明"})]}),s.jsxs("section",{children:[s.jsxs("div",{children:[s.jsx("span",{children:"ISSUES"}),s.jsx("strong",{children:"2 / 3"})]}),s.jsxs("p",{children:[s.jsx("i",{className:"is-done"})," Runtime Hook · Android"]}),s.jsxs("p",{children:[s.jsx("i",{})," iOS 容器适配"]})]})]})}function ele(){const{navigate:e}=us(),[t,n]=h.useState(""),[r,i]=h.useState("api"),o=h.useCallback(async(a,l)=>{n(await Gae(l)?a:`failed:${a}`)},[]);return h.useEffect(()=>{const a=hA.map(([c])=>document.getElementById(c)).filter(Boolean);if(!a.length||typeof IntersectionObserver>"u")return;const l=new IntersectionObserver(c=>{var f,p;const u=c.filter(d=>d.isIntersecting).sort((d,m)=>d.boundingClientRect.top-m.boundingClientRect.top);(p=(f=u[0])==null?void 0:f.target)!=null&&p.id&&i(u[0].target.id)},{rootMargin:"-18% 0px -68% 0px",threshold:[0,.1]});return a.forEach(c=>l.observe(c)),()=>l.disconnect()},[]),s.jsx("div",{className:"af-wr-page",children:s.jsxs("div",{className:"af-wr-inner",children:[s.jsxs("section",{className:"af-wr-hero",children:[s.jsxs("div",{children:[s.jsx("span",{className:"af-wr-kicker",children:"WORKFLOW REPORT · API REFERENCE"}),s.jsx("h1",{children:"Workflow 接入文档"}),s.jsx("p",{children:"用 3 个运行态数据接口和 1 个权限控制面接口,把生产流程的人员权限、全局信息、Action 时间轴、产物链接、迭代归属和自定义面板接入 AgentFlow。数据协议面向任意 Adapter;当前服务端的 Workflow 身份与权限适配器只支持 TAPD,prd-flow 仅作为 TAPD 研发场景的参考实现。"}),s.jsxs("div",{className:"af-wr-hero__boundary",children:[s.jsx("strong",{children:"当前边界"}),s.jsx("span",{children:"可接入任意事实来源"}),s.jsx("i",{children:"·"}),s.jsx("span",{children:"Workflow key 目前必须是 tapd:<short-id>"})]})]}),s.jsxs("div",{className:"af-wr-hero__actions",children:[s.jsxs("button",{type:"button",className:"is-primary",onClick:()=>void o("ai",pA),children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:t==="ai"?"check":"smart_toy"}),t==="ai"?"已复制 AI 引导":"复制 AI 接入引导"]}),s.jsx("button",{type:"button",onClick:()=>e("/workflows"),children:"打开 Workflow Dashboard"})]})]}),s.jsx("nav",{className:"af-wr-toc","aria-label":"接入文档目录",children:hA.map(([a,l])=>s.jsx("a",{className:r===a?"is-active":"",href:`#${a}`,children:l},a))}),s.jsxs("section",{className:"af-wr-section",id:"api",children:[s.jsx(Wo,{number:"01",title:"5 分钟跑通一次上报",detail:"运行态数据接口只有三个,人员权限由独立控制面接口同步。先准备登录 Token 和稳定 source,再执行 access sync → read → merge → report → verify;旧 /api/prd-workflow/* 仅为兼容入口。"}),s.jsx("div",{className:"af-wr-endpoint-grid",children:Tae.map(a=>s.jsxs("article",{children:[s.jsxs("div",{children:[s.jsx("span",{className:`is-${a.method.toLowerCase()}`,children:a.method}),s.jsx("code",{children:a.path})]}),s.jsx("h3",{children:a.title}),s.jsx("p",{children:a.detail}),s.jsxs("dl",{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"权限"}),s.jsx("dd",{children:a.permission})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"副作用"}),s.jsx("dd",{children:a.effect})]})]})]},a.path))}),s.jsxs("div",{className:"af-wr-quickstart",children:[s.jsxs("div",{children:[s.jsx("strong",{children:"开始前准备"}),s.jsxs("p",{children:["在 AgentFlow 的 MCP 页面点击“使用当前登录 Token”,仅在本机设置 ",s.jsx("code",{children:"AGENTFLOW_TOKEN"}),"。当前 Workflow 身份必须使用 ",s.jsx("code",{children:"tapd:<short-id>"}),";",s.jsx("code",{children:"source"})," 填业务 Adapter 名,不能填传输工具名。"]})]}),s.jsx(Ms,{title:"安装与认证",value:kae,copyKey:"install",copied:t,onCopy:o})]}),s.jsxs("div",{className:"af-wr-code-grid af-wr-quickstart-run",children:[s.jsx(Ms,{title:"可直接执行的三步命令",value:Sae,copyKey:"quickstart",copied:t,onCopy:o}),s.jsx(Ms,{title:"workflow-report.json 最小请求",value:vae,copyKey:"quickstart-report",copied:t,onCopy:o})]}),s.jsxs("div",{className:"af-wr-success-check",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"check_circle"}),s.jsxs("p",{children:[s.jsx("strong",{children:"成功标准:"}),"POST 返回 ",s.jsx("code",{children:"ok: true"})," 和实际 ",s.jsx("code",{children:"resourceKeys"}),",再次 GET 能看到 ",s.jsx("code",{children:"requirement-imported"}),",且对应 ",s.jsx("code",{children:"snapshot.resourceVersions"})," 已从 ",s.jsx("code",{children:"absent"})," 变为新版本。"]})]})]}),s.jsxs("section",{className:"af-wr-section",id:"model",children:[s.jsx(Wo,{number:"02",title:"先决定数据进入哪个区域",detail:"页面区域和协议字段一一对应。不要把所有内容都塞进一个 snapshot,也不要从 Action 标题反推结构化数据。"}),s.jsx("div",{className:"af-wr-region-grid",children:Kae.map(a=>s.jsxs("article",{children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:a.icon}),s.jsxs("div",{children:[s.jsx("small",{children:a.question}),s.jsx("h3",{children:a.name}),s.jsx("code",{children:a.fields}),s.jsx("p",{children:a.detail})]})]},a.name))}),s.jsxs("div",{className:"af-wr-model-note",children:[s.jsx("strong",{children:"核心原则"}),s.jsx("span",{children:"globalState.sections 解决通用自定义展示"}),s.jsx("i",{children:"→"}),s.jsx("span",{children:"Action 表达关键业务节点"}),s.jsx("i",{children:"→"}),s.jsx("span",{children:"projection 只做聚合索引"}),s.jsx("i",{children:"→"}),s.jsx("span",{children:"extension 承载专用结构"})]})]}),s.jsxs("section",{className:"af-wr-section",id:"renderers",children:[s.jsx(Wo,{number:"03",title:"当前可直接使用的通用渲染器",detail:"这些 schema 已经由 AgentFlow 页面识别,接入方只需上报数据,不需要开发前端。下面的预览使用与 Workflow 详情页相同的样式类。"}),s.jsxs("div",{className:"af-wr-renderer-notice",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"info"}),s.jsxs("p",{children:[s.jsx("strong",{children:"普通自定义信息不要放进 extensions。"}),"负责人、平台、分支、风险列表、文档链接等,直接使用 ",s.jsx("code",{children:"globalState.sections"}),"。只有通用组件无法表达的树形结构、复杂交互或专用业务面板,才需要 ",s.jsx("code",{children:"extensions"})," 和前端 renderer。"]})]}),s.jsxs("div",{className:"af-wr-renderer-feature",children:[s.jsxs("div",{className:"af-wr-renderer-feature__copy",children:[s.jsx("span",{children:"GENERIC · GLOBAL STATE"}),s.jsx("h3",{children:"概览分区 / 字段渲染器"}),s.jsxs("p",{children:["每个 section 生成一张分区卡片;字段按 ",s.jsx("code",{children:"type"})," 选择固定样式。section key 为 ",s.jsx("code",{children:"progress"})," 时使用紧凑响应式网格,其余分区纵向排列。"]}),s.jsxs("dl",{children:[s.jsxs("div",{children:[s.jsx("dt",{children:"text"}),s.jsx("dd",{children:"普通文本,无胶囊背景"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"user"}),s.jsx("dd",{children:"负责人文本,使用强调色"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"chips"}),s.jsx("dd",{children:"一个或多个标签胶囊"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"list"}),s.jsx("dd",{children:"纵向项目符号列表"})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"link"}),s.jsx("dd",{children:"可点击文本与外链图标"})]})]})]}),s.jsx(Yae,{})]}),s.jsx(Ms,{title:"globalState.sections 上报示例",value:Iae,copyKey:"generic-section",copied:t,onCopy:o}),s.jsxs("div",{className:"af-wr-renderer-grid",children:[s.jsxs("article",{children:[s.jsxs("div",{className:"af-wr-renderer-grid__head",children:[s.jsx("span",{children:"GENERIC"}),s.jsx("h3",{children:"Action 时间轴"}),s.jsx("code",{children:"action + artifacts[scope=action]"}),s.jsx("p",{children:"按日期分组,展示状态点、时间、标题、详情、Issue/平台标签和阶段产物按钮。"})]}),s.jsx(Jae,{})]}),s.jsxs("article",{children:[s.jsxs("div",{className:"af-wr-renderer-grid__head",children:[s.jsx("span",{children:"GENERIC"}),s.jsx("h3",{children:"关联产物列表"}),s.jsx("code",{children:"artifacts[scope=global]"}),s.jsx("p",{children:"用于构建、测试报告、外部文档等全局链接;显示标题、类型与跳转状态。"})]}),s.jsx(Xae,{})]}),s.jsxs("article",{children:[s.jsxs("div",{className:"af-wr-renderer-grid__head",children:[s.jsx("span",{children:"GENERIC"}),s.jsx("h3",{children:"迭代时间线"}),s.jsx("code",{children:"projections.timeline"}),s.jsx("p",{children:"根据 kind/id/title/date/dimensions 聚合个人与团队迭代,支持横向时间线和筛选。"})]}),s.jsx(Qae,{})]})]}),s.jsxs("div",{className:"af-wr-extension-registry",children:[s.jsxs("div",{children:[s.jsx("span",{children:"REGISTERED EXTENSION"}),s.jsx("h3",{children:s.jsx("code",{children:'extensions["prd-flow"]'})}),s.jsx("p",{children:"当前唯一已注册的专用 extension renderer。支持 AI Docs 链接列表和带父子层级、平台、MR 状态及关联链接的 Issues 树。"}),s.jsx(Zae,{})]}),s.jsxs("div",{children:[s.jsx("strong",{children:"其他 namespace 当前如何显示?"}),s.jsx("p",{children:"数据会被保存并参与 revision,但不会自动出现面板。若现有 sections / Action / Artifact / timeline 足够,应优先使用通用组件;确实需要新布局时,再提交扩展 schema、空态/错误态、响应式样式和 renderer 实现。"})]})]})]}),s.jsxs("section",{className:"af-wr-section",id:"reference",children:[s.jsx(Wo,{number:"04",title:"接口与参数参考",detail:"以下字段来自当前服务端真实校验与合并逻辑;可以按区域只提交本次需要更新的部分。"}),s.jsxs("article",{className:"af-wr-endpoint",children:[s.jsx(gh,{method:"POST",path:"/api/workflows/access/sync",title:"同步 TAPD 派生权限",permission:"首次:TAPD Owner;后续:当前 Owner / 管理员",effect:"只改权限控制面,不写运行态"}),s.jsxs("p",{className:"af-wr-endpoint__intro",children:["Adapter 读取 TAPD Story 后,先把 Owner 与参与人同步到 AgentFlow。Owner 必须已注册 AgentFlow;未匹配的参与人会在 ",s.jsx("code",{children:"unresolvedParticipants"})," 中返回,注册后下次同步即可获得 Viewer。"]}),s.jsx(Zr,{rows:Lae,label:"Workflow access sync 参数"}),s.jsx(Ms,{title:"权限同步请求",value:_ae,copyKey:"access-sync",copied:t,onCopy:o}),s.jsxs("div",{className:"af-wr-callout",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"security"}),s.jsxs("p",{children:[s.jsx("strong",{children:"派生权限与显式授权分开保存。"}),"TAPD 参与人只自动获得 Viewer;Owner 可在 Workflow 分享弹窗把某人提升为 Reporter。后续 TAPD 同步会替换派生参与人,但不会覆盖显式授权。"]})]})]}),s.jsxs("article",{className:"af-wr-endpoint",children:[s.jsx(gh,{method:"GET",path:"/api/workflows/state",title:"读取当前 Workflow",permission:"owner / reporter / viewer / team viewer / share viewer",effect:"无"}),s.jsxs("p",{className:"af-wr-endpoint__intro",children:["写入前读取当前快照,从 ",s.jsx("code",{children:"snapshot.resourceVersions"})," 保存本次将触及的业务 key 版本;不存在的 key 使用 ",s.jsx("code",{children:"absent"}),"。客户端提交的完整状态叫 ",s.jsx("code",{children:"observation.state"}),";只有服务端返回的数据才叫 ",s.jsx("code",{children:"snapshot"}),"。"]}),s.jsx(Zr,{rows:Rae,label:"Workflow state query 参数"}),s.jsx("h4",{children:"成功响应"}),s.jsx(Zr,{columns:["字段","类型","含义"],rows:Mae,label:"Workflow state 成功响应"}),s.jsxs("div",{className:"af-wr-code-grid",children:[s.jsx(Ms,{title:"请求",value:jae,copyKey:"read-request",copied:t,onCopy:o}),s.jsx(Ms,{title:"关键响应字段",value:Nae,copyKey:"read-response",copied:t,onCopy:o})]})]}),s.jsxs("article",{className:"af-wr-endpoint",children:[s.jsx(gh,{method:"POST",path:"/api/workflows/report",title:"统一上报 Workflow",permission:"owner / reporter",effect:"修改运行态并返回新 snapshot"}),s.jsx("p",{className:"af-wr-endpoint__intro",children:"至少提交 observation、globalState、action、artifacts、projections、extensions 之一。一次请求可以组合多个区域:每个业务 key 独立校验版本,任一冲突则整次请求原子失败,不会只写入一半。"}),s.jsx("h4",{children:"Envelope"}),s.jsx(Zr,{rows:$ae,label:"Workflow Report 顶层参数"}),s.jsxs("div",{className:"af-wr-subreference",children:[s.jsxs("div",{children:[s.jsx("h4",{children:"action"}),s.jsx("p",{children:"业务阶段,不是运行日志。"}),s.jsx(Zr,{rows:Oae,label:"Action 参数"})]}),s.jsxs("div",{children:[s.jsx("h4",{children:"artifacts"}),s.jsx("p",{children:"已有 HTTP URL 的证据直接上报。"}),s.jsx(Zr,{rows:Hae,label:"Artifact 参数"})]})]}),s.jsxs("div",{className:"af-wr-schema-reference",children:[s.jsxs("article",{children:[s.jsx("h4",{children:"observation"}),s.jsx("p",{children:"同一 clientId 的完整生产方观察。"}),s.jsx(Zr,{rows:Dae,label:"Observation 参数"})]}),s.jsxs("article",{children:[s.jsx("h4",{children:"globalState"}),s.jsx("p",{children:"可独立更新的全局事实和通用分区。"}),s.jsx(Zr,{rows:Fae,label:"Global State 参数"})]}),s.jsxs("article",{children:[s.jsx("h4",{children:"globalState.sections"}),s.jsx("p",{children:"无需前端开发的通用字段渲染器。"}),s.jsx(Zr,{rows:zae,label:"Global State Section 参数"})]}),s.jsxs("article",{children:[s.jsx("h4",{children:"projections.timeline"}),s.jsx("p",{children:"个人/团队 Dashboard 使用的可重建索引。"}),s.jsx(Zr,{rows:Bae,label:"Timeline Projection 参数"})]}),s.jsxs("article",{children:[s.jsx("h4",{children:"extensions"}),s.jsx("p",{children:"只有专用 renderer 才能显示的 namespace 数据。"}),s.jsx(Zr,{rows:Wae,label:"Workflow Extensions 参数"})]})]}),s.jsxs("p",{className:"af-wr-table-note",children:[s.jsx("strong",{children:"生产方隔离:"}),"Action、Artifact、Projection、Observation 和 Extension 都使用带 ",s.jsx("code",{children:"source"})," 的资源 key;不同 source 可以复用相同业务 key。",s.jsx("code",{children:"globalState"})," 按叶子路径分 key 并记录首次写入者,不能覆盖其他 source 的路径;timeline 只替换当前 source 的切片。"]})]}),s.jsxs("article",{className:"af-wr-endpoint",children:[s.jsx(gh,{method:"POST",path:"/api/workflow-artifacts/publish",title:"发布 Markdown 预览",permission:"owner / reporter",effect:"保存预览副本和辅助 Artifact;不推进 Action"}),s.jsx("p",{className:"af-wr-endpoint__intro",children:"客户端读取本地 Markdown,再发送实际内容。服务端不能访问调用方本地路径;外部系统已有 URL 时直接使用 Report artifacts,无需发布副本。"}),s.jsx(Zr,{rows:Vae,label:"Artifact Publish 参数"}),s.jsxs("div",{className:"af-wr-publish-layout",children:[s.jsxs("div",{className:"af-wr-result-list",children:[s.jsx("h4",{children:"返回什么"}),s.jsxs("p",{children:[s.jsx("code",{children:"artifact"}),":页面可识别的标准产物"]}),s.jsxs("p",{children:[s.jsx("code",{children:"review.url"}),":规范预览地址"]}),s.jsxs("p",{children:[s.jsx("code",{children:"review.shortUrl"}),":通常为 ",s.jsx("code",{children:"/r/<code>"})," 的分享短链"]}),s.jsxs("p",{children:[s.jsx("code",{children:"snapshot"}),":发布后的最新 Workflow 状态"]}),s.jsx("strong",{children:"不会确认方案、修改原文件、提交 ai-doc、创建 Issue 或推进阶段。"})]}),s.jsx(Ms,{title:"发布请求",value:Pae,copyKey:"publish",copied:t,onCopy:o})]})]})]}),s.jsxs("section",{className:"af-wr-section",id:"scenarios",children:[s.jsx(Wo,{number:"05",title:"三个关键接入场景",detail:"以 prd-flow 为例说明接口组合;它是 TAPD 研发流程的一种实现,不是协议依赖。"}),s.jsxs("div",{className:"af-wr-scenario",children:[s.jsxs("div",{className:"af-wr-scenario__copy",children:[s.jsx("span",{children:"场景 A"}),s.jsx("h3",{children:"更新迭代:绑定或切换版本"}),s.jsxs("ol",{children:[s.jsx("li",{children:"Adapter 从业务系统得到稳定 version ID、标题、日期、平台;prd-flow 的来源恰好是 TAPD。"}),s.jsx("li",{children:"GET 当前 snapshot,取版本事实叶子路径及自有 projection 的 resourceVersions。"}),s.jsx("li",{children:"版本事实写入 globalState;归属索引写入 kind=version projection。"}),s.jsx("li",{children:"只提交当前 source 的完整投影切片;其他 source 的 Sprint/版本由服务端保留。"})]}),s.jsxs("p",{children:[s.jsx("strong",{children:"改名/改期:"}),"保持 ID 和 key 不变。",s.jsx("strong",{children:"取消归属:"}),"移除自有条目后上报剩余自有切片;发送空数组只清空当前 source。"]})]}),s.jsx(Ms,{title:"版本事实 + 当前生产方迭代投影",value:Cae,copyKey:"version",copied:t,onCopy:o})]}),s.jsxs("div",{className:"af-wr-scenario",children:[s.jsxs("div",{className:"af-wr-scenario__copy",children:[s.jsx("span",{children:"场景 B"}),s.jsx("h3",{children:"上报 Action 和产物链接"}),s.jsxs("ol",{children:[s.jsx("li",{children:"先完成真实业务动作,例如创建并合并 MR。"}),s.jsx("li",{children:"用稳定 action.key 报告阶段,用 artifact.key 报告证据。"}),s.jsx("li",{children:"同一阶段刷新继续使用相同 key;occurredAt 使用业务时间。"}),s.jsx("li",{children:"本地 Markdown 先 publish,已有 HTTP URL 直接作为 Artifact。"})]}),s.jsx("p",{children:"AgentFlow 只记录和展示结果,不替接入方操作 TAPD、GitLab 或 Jenkins。"})]}),s.jsx(Ms,{title:"实现完成 + MR",value:Aae,copyKey:"action",copied:t,onCopy:o})]}),s.jsxs("div",{className:"af-wr-scenario",children:[s.jsxs("div",{className:"af-wr-scenario__copy",children:[s.jsx("span",{children:"场景 C"}),s.jsx("h3",{children:"上报自定义文档区 / Issue 区"}),s.jsxs("ol",{children:[s.jsx("li",{children:"定义生产方 namespace 和版本化 schema。"}),s.jsx("li",{children:"把结构化数组写入 extensions[namespace]。"}),s.jsx("li",{children:"数组上报完整新值,对象字段可以递归合并。"}),s.jsx("li",{children:"实现并注册专用渲染器,页面才会出现对应区域。"})]}),s.jsx("p",{children:"prd-flow 已有 AI Docs / Issues 渲染;其他生产方不能仅通过改字段名复用它。"})]}),s.jsx(Ms,{title:"prd-flow 专用扩展示例",value:Eae,copyKey:"extension",copied:t,onCopy:o})]})]}),s.jsxs("section",{className:"af-wr-section",id:"safety",children:[s.jsx(Wo,{number:"06",title:"权限、覆盖和冲突",detail:"接入前必须明确谁能写、每个区域怎么更新,以及冲突发生时是否可能误删其他生产方的数据。"}),s.jsxs("div",{className:"af-wr-safety-grid",children:[s.jsxs("div",{children:[s.jsx("h3",{children:"权限矩阵"}),s.jsx(Zr,{columns:["身份","读取","上报","说明"],rows:Uae,label:"Workflow 权限矩阵"}),s.jsx("p",{className:"af-wr-table-note",children:"完成 TAPD 权限同步后,Owner 和参与人以 TAPD 为准;参与人默认只读。尚未同步过的历史 Workflow 保留原 Owner,直到当前 Owner 或管理员执行首次同步。"})]}),s.jsxs("div",{children:[s.jsx("h3",{children:"覆盖矩阵"}),s.jsx(Zr,{columns:["区域","重复上报","删除/清空","接入方责任"],rows:qae,label:"Workflow 覆盖矩阵"})]})]}),s.jsxs("div",{className:"af-wr-conflict-flow",children:[s.jsx("span",{children:"GET snapshot.resourceVersions"}),s.jsx("i",{children:"→"}),s.jsx("span",{children:"计算触及的 resource keys"}),s.jsx("i",{children:"→"}),s.jsx("span",{children:"POST + expectedVersions + idempotencyKey"}),s.jsx("i",{children:"→"}),s.jsx("span",{children:"409 时只刷新冲突 key / 重算 / 重试一次"})]}),s.jsxs("div",{className:"af-wr-errors",children:[s.jsxs("div",{children:[s.jsx("code",{children:"400"}),s.jsx("p",{children:"字段或 schema 错误;按协议修正"})]}),s.jsxs("div",{children:[s.jsx("code",{children:"401"}),s.jsx("p",{children:"缺少认证;停止并配置 Token"})]}),s.jsxs("div",{children:[s.jsx("code",{children:"403"}),s.jsx("p",{children:"只读或无权限;由 Owner 授权 Reporter"})]}),s.jsxs("div",{children:[s.jsx("code",{children:"409"}),s.jsx("p",{children:"资源 key 冲突、路径属于其他 source,或权限快照过旧"})]})]})]}),s.jsxs("section",{className:"af-wr-section",id:"design",children:[s.jsx(Wo,{number:"07",title:"设计思想与运行关系",detail:"业务解释留在 Adapter,传输和存储保持通用;这样新生产方不需要复制 prd-flow 的 TAPD 私有模型。"}),s.jsxs("div",{className:"af-wr-runtime",children:[s.jsxs("article",{children:[s.jsx("small",{children:"事实来源"}),s.jsx("strong",{children:"TAPD / GitLab / Jenkins / 其他系统"}),s.jsx("p",{children:"提供原始业务事实。"})]}),s.jsx("i",{children:"→"}),s.jsxs("article",{className:"is-focus",children:[s.jsx("small",{children:"你需要实现"}),s.jsx("strong",{children:"业务 Adapter"}),s.jsx("p",{children:"先同步上游人员权限,再解释阶段、定义稳定 key、生成 Report。prd-flow 是一个现有 Adapter。"})]}),s.jsx("i",{children:"→"}),s.jsxs("article",{children:[s.jsx("small",{children:"通用传输"}),s.jsx("strong",{children:"Workflow Report Client / agentflow-cli"}),s.jsx("p",{children:"负责地址、Token、JSON 和 HTTP,不理解业务。"})]}),s.jsx("i",{children:"→"}),s.jsxs("article",{children:[s.jsx("small",{children:"接收与展示"}),s.jsx("strong",{children:"AgentFlow 服务与页面"}),s.jsx("p",{children:"鉴权、合并、存储并渲染三类区域。"})]})]}),s.jsxs("div",{className:"af-wr-design-rules",children:[s.jsxs("article",{children:[s.jsx("strong",{children:"事实与投影分离"}),s.jsx("p",{children:"版本完整信息属于 globalState;个人/团队迭代只读取 projection。投影可以重建,不成为第二份真相。"})]}),s.jsxs("article",{children:[s.jsx("strong",{children:"业务节点与技术日志分离"}),s.jsx("p",{children:"Action 只表达可理解的阶段。轮询、重试、刷新留在接入方日志,不污染时间轴。"})]}),s.jsxs("article",{children:[s.jsx("strong",{children:"通用存储与专用渲染分离"}),s.jsx("p",{children:"extensions 可以保存任意生产方结构,但专用面板必须显式注册 schema 和 renderer。"})]})]}),s.jsxs("div",{className:"af-wr-callout",children:[s.jsx("span",{className:"material-symbols-outlined","aria-hidden":!0,children:"psychology"}),s.jsxs("p",{children:[s.jsx("strong",{children:"Workflow AI 不属于 Report 协议。"}),"需求 Owner 在详情页“协作 → AI 知识工作区”绑定平台已有的 Git 知识工作区;成员通过顶部 AI 提问。AgentFlow 会把当前 Workflow snapshot 与隔离的 detached commit 快照一并交给 AI:优先使用上报且能匹配仓库的 commit/ref,否则使用绑定分支或本地 HEAD。它不会 fetch、切换或修改真实仓库,公开只读链接也不能调用 AI。绑定配置由 ",s.jsx("code",{children:"GET/PUT /api/workflows/knowledge-bindings"})," 管理,问答使用 ",s.jsx("code",{children:"POST /api/workflows/query"}),",不会写入 ",s.jsx("code",{children:"globalState"}),"、Action、Artifact 或 extensions。"]})]})]}),s.jsxs("section",{className:"af-wr-section af-wr-ai",id:"ai",children:[s.jsx(Wo,{number:"08",title:"给 AI 的接入引导",detail:"复制后交给 AI,它会先输出事实到页面区域的映射,再按真实协议实现。"}),s.jsx(Ms,{title:"$agentflow-workflow-report",value:pA,copyKey:"ai-bottom",copied:t,onCopy:o,wrap:!0})]})]})})}const tle=[{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"}],nle=[{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 长文档","客户端原型预览","图表与表格","统一展示链接"]}],rle=[{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"}],sle=[["知识库","查客户端、后台、前端逻辑","广告、Feed、会员、增长、配置、接口调用链"],["数据","查 CK / Hive 并输出 SQL","PV、UV、转化、分页面、分国家、分实验组"],["产物","生成原型、PRD、Display 面板","Markdown、HTML 原型、图表、表格、交互预览"],["协作","同步 TAPD 与 Git 仓库","需求正文、变更记录、MR 链接、评审材料"]];function yh({icon:e,title:t,label:n,tone:r="violet"}){return s.jsxs("div",{className:`likee-flow-node likee-flow-node-${r}`,children:[s.jsx("span",{className:"material-symbols-outlined",children:e}),s.jsxs("div",{children:[s.jsx("strong",{children:t}),s.jsx("small",{children:n})]})]})}function ile(){return s.jsxs("div",{className:"likee-workspace-scene","aria-hidden":"true",children:[s.jsx("div",{className:"likee-scene-grid"}),s.jsxs("svg",{className:"likee-scene-lines",viewBox:"0 0 980 560",fill:"none",children:[s.jsx("path",{d:"M96 154 C236 96 330 122 444 194 C552 262 654 260 814 160"}),s.jsx("path",{d:"M118 350 C248 288 344 304 458 372 C578 444 704 420 858 310"}),s.jsx("path",{d:"M472 196 C512 248 524 302 486 372"}),s.jsx("path",{d:"M622 126 C670 198 696 258 682 354"})]}),s.jsx("div",{className:"likee-node-pos likee-node-a",children:s.jsx(yh,{icon:"travel_explore",title:"全局上下文",label:"Likee 业务、代码、数据",tone:"pink"})}),s.jsx("div",{className:"likee-node-pos likee-node-b",children:s.jsx(yh,{icon:"database",title:"CK / Hive",label:"自动 SQL 与指标口径",tone:"cyan"})}),s.jsx("div",{className:"likee-node-pos likee-node-c",children:s.jsx(yh,{icon:"article",title:"需求文档",label:"PRD、变更说明、评审稿",tone:"amber"})}),s.jsx("div",{className:"likee-node-pos likee-node-d",children:s.jsx(yh,{icon:"sync_alt",title:"TAPD / Git",label:"同步需求与版本资产",tone:"green"})}),s.jsxs("div",{className:"likee-phone-preview",children:[s.jsxs("div",{className:"likee-phone-top",children:[s.jsx("span",{children:"关注"}),s.jsx("strong",{children:"推荐"}),s.jsx("span",{children:"直播"})]}),s.jsxs("div",{className:"likee-phone-card",children:[s.jsx("div",{className:"likee-gift",children:"AD"}),s.jsx("h4",{children:"广告个性化引导弹框"}),s.jsx("p",{children:"保持推荐体验,同时解释权益与关闭路径。"}),s.jsx("button",{children:"继续"}),s.jsx("button",{className:"secondary",children:"稍后"})]})]}),s.jsxs("div",{className:"likee-display-panel",children:[s.jsxs("div",{className:"likee-panel-header",children:[s.jsx("span",{children:"DISPLAY"}),s.jsx("strong",{children:"需求资产面板"})]}),s.jsxs("div",{className:"likee-table-row",children:[s.jsx("span",{children:"需求"}),s.jsx("strong",{children:"首页广告个性化引导"})]}),s.jsxs("div",{className:"likee-table-row",children:[s.jsx("span",{children:"数据"}),s.jsx("strong",{children:"m09 PV Top 1"})]}),s.jsxs("div",{className:"likee-table-row",children:[s.jsx("span",{children:"同步"}),s.jsx("strong",{children:"TAPD + Git MR"})]})]})]})}function qh({kicker:e,title:t,children:n}){return s.jsxs("div",{className:"likee-section-copy",children:[s.jsx("p",{className:"likee-section-kicker",children:e}),s.jsx("h2",{children:t}),s.jsx("p",{children:n})]})}function ole(){return s.jsx("section",{id:"likee-skills",className:"likee-section likee-section-dark",children:s.jsxs("div",{className:"likee-section-inner likee-two-column likee-two-column-skills",children:[s.jsx(qh,{kicker:"SKILLS",title:"用 Skills 把 Likee 上下文变成可复用能力",children:"Skills 是工作区里可加载的能力包。手动搭建工作区时,只需要按场景加载对应 Skill。"}),s.jsx("div",{className:"likee-skill-grid",children:rle.map(e=>s.jsxs("article",{className:`likee-skill-card likee-skill-${e.tone}`,children:[s.jsxs("div",{className:"likee-skill-head",children:[s.jsx("div",{className:"likee-skill-icon",children:s.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),s.jsxs("div",{children:[s.jsx("h3",{children:e.name}),s.jsx("span",{children:e.namespace})]})]}),s.jsx("div",{className:"likee-skill-mode",children:e.mode}),s.jsx("p",{children:e.usage}),s.jsx("div",{className:"likee-skill-examples",children:e.examples.map(t=>s.jsx("strong",{children:t},t))})]},e.name))})]})})}function E$(){return s.jsxs("div",{className:"likee-page",children:[s.jsx("div",{className:"likee-top-actions",children:s.jsxs("a",{href:"/projects",className:"likee-home-link",children:[s.jsx("span",{className:"material-symbols-outlined",children:"arrow_back"}),"返回首页"]})}),s.jsxs("section",{className:"likee-hero",children:[s.jsx(ile,{}),s.jsxs("div",{className:"likee-hero-content",children:[s.jsx("p",{className:"likee-eyebrow",children:"LIKEE CONTEXT WORKSPACE"}),s.jsx("h1",{children:"Likee Agent 工作台"}),s.jsx("p",{className:"likee-hero-subtitle",children:"提供 Likee 全局上下文,赋能需求挖掘、书写和运营。"}),s.jsxs("div",{className:"likee-signal-row",children:[s.jsx("span",{children:"查业务逻辑"}),s.jsx("span",{children:"查 CK / Hive"}),s.jsx("span",{children:"生成原型"}),s.jsx("span",{children:"生成 PRD"}),s.jsx("span",{children:"同步 TAPD / Git"})]}),s.jsxs("div",{className:"likee-hero-actions",children:[s.jsxs("a",{href:"/projects",className:"likee-primary-action",children:[s.jsx("span",{className:"material-symbols-outlined",children:"rocket_launch"}),"立即使用"]}),s.jsxs("a",{href:"#likee-scenarios",className:"likee-secondary-action",children:[s.jsx("span",{className:"material-symbols-outlined",children:"ads_click"}),"按场景查看"]}),s.jsxs("a",{href:"#likee-usecases",className:"likee-secondary-action",children:[s.jsx("span",{className:"material-symbols-outlined",children:"view_timeline"}),"查看 Use Cases"]}),s.jsxs("a",{href:"#likee-skills",className:"likee-secondary-action",children:[s.jsx("span",{className:"material-symbols-outlined",children:"extension"}),"查看 Skills"]})]})]})]}),s.jsx("section",{id:"likee-scenarios",className:"likee-section",children:s.jsxs("div",{className:"likee-section-inner",children:[s.jsx(qh,{kicker:"SCENARIO TRIGGERS",title:"打造 Likee 团队全景上下文",children:"不要求先会写 Prompt,也不要求知道该找哪个系统。选择一个业务场景,工作台会把需要的 Likee 上下文、数据查询和最终产物组织起来。"}),s.jsx("div",{className:"likee-scenario-grid",children:tle.map(e=>s.jsxs("article",{className:`likee-scenario-card likee-scenario-${e.tone}`,children:[s.jsx("div",{className:"likee-scenario-icon",children:s.jsx("span",{className:"material-symbols-outlined",children:e.icon})}),s.jsxs("div",{children:[s.jsx("h3",{children:e.title}),s.jsx("p",{children:e.question})]}),s.jsx("div",{className:"likee-scenario-context",children:e.context.map(t=>s.jsx("span",{children:t},t))}),s.jsxs("div",{className:"likee-scenario-result",children:[s.jsx("span",{children:"产出"}),s.jsx("strong",{children:e.result})]})]},e.title))})]})}),s.jsx("section",{id:"likee-usecases",className:"likee-section likee-section-muted",children:s.jsxs("div",{className:"likee-section-inner likee-two-column likee-usecase-layout",children:[s.jsx(qh,{kicker:"USE CASES",title:"沉淀 Likee 业务流水线",children:"这里展示的是平台里实际可跑的工作流:加载流程片段,在子 Agent 或 Run 节点输入业务问题,执行当前 line,最终在 Display、TAPD 和 Git 中拿到结果。"}),s.jsx("div",{className:"likee-usecase-stack",children:nle.map(e=>s.jsxs("article",{className:"likee-usecase-card",children:[s.jsx("div",{className:`likee-usecase-media ${e.images.length>1?"likee-usecase-media-split":""}`,children:e.images.map((t,n)=>s.jsx("img",{src:t,alt:`${e.title} 工作区截图 ${n+1}`,loading:"lazy"},t))}),s.jsxs("div",{className:"likee-usecase-body",children:[s.jsx("div",{className:"likee-usecase-label",children:e.label}),s.jsx("h3",{children:e.title}),s.jsx("p",{children:e.trigger}),s.jsx("ol",{className:"likee-usecase-steps",children:e.steps.map(t=>s.jsx("li",{children:t},t))}),s.jsxs("div",{className:"likee-usecase-output",children:[s.jsx("span",{children:"实际产物"}),s.jsx("div",{children:e.outputs.map(t=>s.jsx("strong",{children:t},t))})]})]})]},e.label))})]})}),s.jsx(ole,{}),s.jsx("section",{className:"likee-section",children:s.jsxs("div",{className:"likee-section-inner likee-two-column likee-capability-layout",children:[s.jsx(qh,{kicker:"CAPABILITY MAP",title:"每个场景背后,都连接同一套 Likee 上下文能力",children:"工作台把知识库、CK / Hive、原型、PRD、TAPD 和 Git 放到同一条链路里。用户看到的是业务场景,系统处理的是上下文、产物和同步。"}),s.jsx("div",{className:"likee-capability-table",children:sle.map(([e,t,n])=>s.jsxs("div",{className:"likee-capability-row",children:[s.jsx("span",{children:e}),s.jsx("strong",{children:t}),s.jsx("p",{children:n})]},e))})]})})]})}function I$(e){return t=>typeof t===e}var ale=I$("function"),lle=e=>e===null,mA=e=>Object.prototype.toString.call(e).slice(8,-1)==="RegExp",gA=e=>!cle(e)&&!lle(e)&&(ale(e)||typeof e=="object"),cle=I$("undefined");function ule(e,t,n){return yle(n,e,t)?!0:(wle(n,e,t),e.constructor!==t.constructor?!1:Array.isArray(e)&&Array.isArray(t)?dle(e,t,n):e instanceof Map&&t instanceof Map?hle(e,t,n):e instanceof Set&&t instanceof Set?gle(e,t):e instanceof WeakMap||e instanceof WeakSet?!1:ArrayBuffer.isView(e)&&ArrayBuffer.isView(t)?fle(e,t):mA(e)&&mA(t)?e.source===t.source&&e.flags===t.flags:e instanceof Error&&t instanceof Error?ple(e,t,n):e.valueOf!==Object.prototype.valueOf?e.valueOf()===t.valueOf():e.toString!==Object.prototype.toString?e.toString()===t.toString():mle(e,t,n))}function Hf(e,t,n){return e===t||Number.isNaN(e)&&Number.isNaN(t)?!0:!e||!gA(e)||!t||!gA(t)?!1:ule(e,t,n)}function dle(e,t,n){const{length:r}=e;if(r!==t.length)return!1;for(let i=r;i--!==0;)if(!Hf(e[i],t[i],n))return!1;return!0}function fle(e,t){if(e.byteLength!==t.byteLength)return!1;const n=new DataView(e.buffer),r=new DataView(t.buffer);let i=e.byteLength;for(;i--;)if(n.getUint8(i)!==r.getUint8(i))return!1;return!0}function ple(e,t,n){return e.message===t.message&&e.name===t.name&&Hf(e.cause,t.cause,n)}function hle(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(!Hf(r[1],t.get(r[0]),n))return!1;return!0}function mle(e,t,n){const r=Object.keys(e);if(r.length!==Object.keys(t).length)return!1;for(let i=r.length;i--!==0;)if(!Object.prototype.hasOwnProperty.call(t,r[i]))return!1;for(let i=r.length;i--!==0;){const o=r[i];if(!(o==="_owner"&&e.$$typeof)&&!Hf(e[o],t[o],n))return!1}return!0}function gle(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 yle(e,t,n){var r;return((r=e.get(t))==null?void 0:r.has(n))??!1}function wle(e,t,n){let r=e.get(t);r||(r=new WeakSet,e.set(t,r)),r.add(n)}function eS(e,t){return Hf(e,t,new WeakMap)}function Zw(){var e;return!!(typeof window<"u"&&((e=window==null?void 0:window.document)!=null&&e.createElement))}function xle(e,...t){e&&e.removeEventListener&&e.removeEventListener(...t)}function ble(e,...t){e&&e.addEventListener&&e.addEventListener(...t)}function kle(){const e=h.useRef(!0);return e.current?(e.current=!1,!0):e.current}function vle(e,t){const n=kle();h.useEffect(()=>{if(!n)return e()},t)}function P$(e){const t=h.useRef(void 0);return h.useEffect(()=>{t.current=e}),t.current}function Sle(e,t){const n=h.useRef(t);return eS(t,n.current)||(n.current=t),h.useMemo(e,n.current)}function jle(e){h.useEffect(()=>{e()},[])}function Nle(e=0){const[t,n]=h.useState({height:Zw()?window.innerHeight:0,width:Zw()?window.innerWidth:0}),r=h.useRef(0),i=h.useRef(()=>{window.clearTimeout(r.current),r.current=window.setTimeout(()=>{n({width:window.innerWidth,height:window.innerHeight})},e)});return h.useEffect(()=>{if(!Zw())return()=>{};const o=i.current;return n({height:window.innerHeight,width:window.innerWidth}),ble(window,"resize",o),()=>{xle(window,"resize",o)}},[]),t}var _le=["Array","ArrayBuffer","AsyncFunction","AsyncGenerator","AsyncGeneratorFunction","Date","Error","Function","Generator","GeneratorFunction","HTMLElement","Map","Object","Promise","RegExp","Set","URL","WeakMap","WeakSet"],Cle=["bigint","boolean","null","number","string","symbol","undefined"];function Vf(e){const t=Object.prototype.toString.call(e).slice(8,-1);if(/HTML\w+Element/.test(t))return"HTMLElement";if(Ale(t))return t}function gi(e){return t=>Vf(t)===e}function Ale(e){return _le.includes(e)}function lu(e){return t=>typeof t===e}function Ele(e){return Cle.includes(e)}var Ile=["innerHTML","ownerDocument","style","attributes","nodeValue"],Kf=e=>Array.isArray(e),Ple=e=>Vf(e)==="AsyncGeneratorFunction",Tle=gi("AsyncFunction"),Rle=lu("bigint"),Mle=e=>e===!0||e===!1,$le=gi("Date"),Lle=gi("Error"),ya=lu("function"),Ole=gi("GeneratorFunction"),Dle=e=>typeof e=="number"&&Number.isInteger(e),nk=gi("Map"),T$=e=>Number.isNaN(e),tS=e=>e===null,R$=gi("Function"),Fle=gi("Promise"),zle=gi("RegExp"),rk=gi("Set"),qf=lu("string"),Ble=lu("symbol"),nS=lu("undefined"),Wle=gi("WeakMap"),Hle=gi("WeakSet"),rS=e=>tS(e)||nS(e),M$=e=>!nS(e),Vle=e=>lu("number")(e)&&!T$(e),Kle=e=>qf(e)&&e.trim().length>0,qle=e=>{if(!qf(e)||e.length===0)return!1;const t=e.trim();return t.length>0&&Number.isFinite(Number(t))},zg=e=>!rS(e)&&(ya(e)||typeof e=="object"),$$=e=>{if(Vf(e)!=="Object")return!1;const t=Object.getPrototypeOf(e);return t===null||t===Object.getPrototypeOf({})},Ule=e=>tS(e)||Ele(typeof e),Gle=e=>Vf(e)==="URL",L$=e=>!rS(e)&&ya(e[Symbol.iterator]),Yle=e=>L$(e)&&ya(e.next)&&ya(e.throw),Jle=e=>ya(e)&&/^class\s/.test(e.toString()),Xle=(e,t)=>!Kf(e)||!ya(t)?!1:e.every(n=>t(n)),Qle=e=>zg(e)&&!$$(e)&&e.nodeType===1&&qf(e.nodeName)&&Ile.every(t=>t in e),Zle=e=>qf(e)&&e.length===0||Kf(e)&&e.length===0||zg(e)&&!nk(e)&&!rk(e)&&Object.keys(e).length===0||rk(e)&&e.size===0||nk(e)&&e.size===0,ece=(e,t)=>!e||!t?!1:Object.getPrototypeOf(e)===t.prototype,tce=(e,t)=>Kf(e)?e.indexOf(t)>-1:!1,nce=(e,t,n)=>{if(!zg(e)||!t)return!1;const r=e[t];return ya(n)?n(r):M$(r)};function Et(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(Kf(e))return"Array";if(R$(e))return"Function";const t=Vf(e);return t||"Object"}Et.array=Kf;Et.arrayOf=Xle;Et.asyncGeneratorFunction=Ple;Et.asyncFunction=Tle;Et.bigint=Rle;Et.boolean=Mle;Et.class=Jle;Et.date=$le;Et.defined=M$;Et.domElement=Qle;Et.empty=Zle;Et.error=Lle;Et.function=ya;Et.generator=Yle;Et.generatorFunction=Ole;Et.instanceOf=ece;Et.integer=Dle;Et.iterable=L$;Et.map=nk;Et.nan=T$;Et.null=tS;Et.nullOrUndefined=rS;Et.nonEmptyString=Kle;Et.number=Vle;Et.numericString=qle;Et.object=zg;Et.oneOf=tce;Et.plainFunction=R$;Et.plainObject=$$;Et.primitive=Ule;Et.promise=Fle;Et.propertyOf=nce;Et.regexp=zle;Et.set=rk;Et.string=qf;Et.symbol=Ble;Et.undefined=nS;Et.url=Gle;Et.weakMap=Wle;Et.weakSet=Hle;var Dr=Et;/* v8 ignore next -- @preserve */var rce=function(e){return Object.prototype.hasOwnProperty.call(e,"props")},sce=function(e,t){return e+Nf(t)},Nf=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(sce,""):rce(e)&&Object.prototype.hasOwnProperty.call(e.props,"children")?Nf(e.props.children):""};Nf.default=Nf;var ice=Nf;const ex=xa(ice);var O$={exports:{}};(function(e){const t=Object.getPrototypeOf({});function n(){return function(o){return typeof o=="object"&&o!==null&&!(o instanceof RegExp)&&!(o instanceof Date)}}function r(i){function o(j){return j!=="constructor"&&j!=="prototype"&&j!=="__proto__"}function a(j){let N=0;const P=j.length,T=new Array(P);for(N;N<P;++N)T[N]=g(j[N]);return T}function l(j){const N={};if(d&&Object.getPrototypeOf(j)!==t)return d(j);const P=p(j);let T,z,E;for(T=0,z=P.length;T<z;++T)o(E=P[T])&&(N[E]=g(j[E]));return N}function c(j,N){const P=j.length,T=N.length;let z=0;const E=new Array(P+T);for(z;z<P;++z)E[z]=g(j[z]);for(z=0;z<T;++z)E[z+P]=g(N[z]);return E}const u=Object.prototype.propertyIsEnumerable;function f(j){const N=Object.keys(j),P=Object.getOwnPropertySymbols(j);for(let T=0,z=P.length;T<z;++T)u.call(j,P[T])&&N.push(P[T]);return N}const p=i!=null&&i.symbols?f:Object.keys,d=typeof(i==null?void 0:i.cloneProtoObject)=="function"?i.cloneProtoObject:void 0,m=typeof(i==null?void 0:i.isMergeableObject)=="function"?i.isMergeableObject:n(),y=(i==null?void 0:i.onlyDefinedProperties)===!0;function v(j){return typeof j!="object"||j===null}const b=i&&typeof i.mergeArray=="function"?i.mergeArray({clone:g,deepmerge:x,getKeys:p,isMergeableObject:m}):c;function g(j){return m(j)?Array.isArray(j)?a(j):l(j):j}function k(j,N){const P={},T=p(j),z=p(N);let E,O,D;for(E=0,O=T.length;E<O;++E)o(D=T[E])&&z.indexOf(D)===-1&&(P[D]=g(j[D]));for(E=0,O=z.length;E<O;++E)if(o(D=z[E]))if(D in j)T.indexOf(D)!==-1&&(d&&m(N[D])&&Object.getPrototypeOf(N[D])!==t?P[D]=d(N[D]):P[D]=x(j[D],N[D]));else{if(y&&typeof N[D]>"u")continue;P[D]=g(N[D])}return P}function x(j,N){if(y&&typeof N>"u")return g(j);const P=Array.isArray(N),T=Array.isArray(j);return v(N)?N:m(j)?P&&T?b(j,N):P!==T?g(N):k(j,N):g(N)}function _(){switch(arguments.length){case 0:return{};case 1:return g(arguments[0]);case 2:return x(arguments[0],arguments[1])}let j;for(let N=0,P=arguments.length;N<P;++N)j=x(j,arguments[N]);return j}return i!=null&&i.all?_:x}e.exports=r,e.exports.default=r,e.exports.deepmerge=r,Object.defineProperty(e.exports,"isMergeableObject",{get:n})})(O$);var oce=O$.exports;const ace=xa(oce);var lce=new Error("Element already at target scroll position"),cce=new Error("Scroll cancelled"),uce=Math.min,yA=Date.now,dce={left:wA("scrollLeft"),top:wA("scrollTop")};function wA(e){return function(n,r,i,o){i=i||{},typeof i=="function"&&(o=i,i={}),typeof o!="function"&&(o=pce);var a=yA(),l=n[e],c=i.ease||fce,u=isNaN(i.duration)?350:+i.duration,f=!1;return l===r?o(lce,n[e]):requestAnimationFrame(d),p;function p(){f=!0}function d(m){if(f)return o(cce,n[e]);var y=yA(),v=uce(1,(y-a)/u),b=c(v);n[e]=b*(r-l)+l,v<1?requestAnimationFrame(d):requestAnimationFrame(function(){o(null,n[e])})}}}function fce(e){return .5*(1-Math.cos(Math.PI*e))}function pce(){}const hce=xa(dce);var D$={exports:{}};(function(e){(function(t,n){e.exports?e.exports=n():t.Scrollparent=n()})(Fd,function(){function t(r){var i=getComputedStyle(r,null).getPropertyValue("overflow");return i.indexOf("scroll")>-1||i.indexOf("auto")>-1}function n(r){if(r instanceof HTMLElement||r instanceof SVGElement){for(var i=r.parentNode;i.parentNode;){if(t(i))return i;i=i.parentNode}return document.scrollingElement||document.documentElement}}return n})})(D$);var mce=D$.exports;const F$=xa(mce),gce=["top","right","bottom","left"],xA=["start","end"],bA=gce.reduce((e,t)=>e.concat(t,t+"-"+xA[0],t+"-"+xA[1]),[]),Qc=Math.min,tl=Math.max,Jm=Math.round,wh=Math.floor,Fi=e=>({x:e,y:e}),yce={left:"right",right:"left",bottom:"top",top:"bottom"};function sk(e,t,n){return tl(e,Qc(t,n))}function cu(e,t){return typeof e=="function"?e(t):e}function bo(e){return e.split("-")[0]}function zi(e){return e.split("-")[1]}function z$(e){return e==="x"?"y":"x"}function sS(e){return e==="y"?"height":"width"}function ea(e){const t=e[0];return t==="t"||t==="b"?"y":"x"}function iS(e){return z$(ea(e))}function B$(e,t,n){n===void 0&&(n=!1);const r=zi(e),i=iS(e),o=sS(i);let a=i==="x"?r===(n?"end":"start")?"right":"left":r==="start"?"bottom":"top";return t.reference[o]>t.floating[o]&&(a=Qm(a)),[a,Qm(a)]}function wce(e){const t=Qm(e);return[Xm(e),t,Xm(t)]}function Xm(e){return e.includes("start")?e.replace("start","end"):e.replace("end","start")}const kA=["left","right"],vA=["right","left"],xce=["top","bottom"],bce=["bottom","top"];function kce(e,t,n){switch(e){case"top":case"bottom":return n?t?vA:kA:t?kA:vA;case"left":case"right":return t?xce:bce;default:return[]}}function vce(e,t,n,r){const i=zi(e);let o=kce(bo(e),n==="start",r);return i&&(o=o.map(a=>a+"-"+i),t&&(o=o.concat(o.map(Xm)))),o}function Qm(e){const t=bo(e);return yce[t]+e.slice(t.length)}function Sce(e){return{top:0,right:0,bottom:0,left:0,...e}}function W$(e){return typeof e!="number"?Sce(e):{top:e,right:e,bottom:e,left:e}}function Zm(e){const{x:t,y:n,width:r,height:i}=e;return{width:r,height:i,top:n,left:t,right:t+r,bottom:n+i,x:t,y:n}}function SA(e,t,n){let{reference:r,floating:i}=e;const o=ea(t),a=iS(t),l=sS(a),c=bo(t),u=o==="y",f=r.x+r.width/2-i.width/2,p=r.y+r.height/2-i.height/2,d=r[l]/2-i[l]/2;let m;switch(c){case"top":m={x:f,y:r.y-i.height};break;case"bottom":m={x:f,y:r.y+r.height};break;case"right":m={x:r.x+r.width,y:p};break;case"left":m={x:r.x-i.width,y:p};break;default:m={x:r.x,y:r.y}}switch(zi(t)){case"start":m[a]-=d*(n&&u?-1:1);break;case"end":m[a]+=d*(n&&u?-1:1);break}return m}async function jce(e,t){var n;t===void 0&&(t={});const{x:r,y:i,platform:o,rects:a,elements:l,strategy:c}=e,{boundary:u="clippingAncestors",rootBoundary:f="viewport",elementContext:p="floating",altBoundary:d=!1,padding:m=0}=cu(t,e),y=W$(m),b=l[d?p==="floating"?"reference":"floating":p],g=Zm(await o.getClippingRect({element:(n=await(o.isElement==null?void 0:o.isElement(b)))==null||n?b:b.contextElement||await(o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:u,rootBoundary:f,strategy:c})),k=p==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,x=await(o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating)),_=await(o.isElement==null?void 0:o.isElement(x))?await(o.getScale==null?void 0:o.getScale(x))||{x:1,y:1}:{x:1,y:1},j=Zm(o.convertOffsetParentRelativeRectToViewportRelativeRect?await o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:k,offsetParent:x,strategy:c}):k);return{top:(g.top-j.top+y.top)/_.y,bottom:(j.bottom-g.bottom+y.bottom)/_.y,left:(g.left-j.left+y.left)/_.x,right:(j.right-g.right+y.right)/_.x}}const Nce=50,_ce=async(e,t,n)=>{const{placement:r="bottom",strategy:i="absolute",middleware:o=[],platform:a}=n,l=a.detectOverflow?a:{...a,detectOverflow:jce},c=await(a.isRTL==null?void 0:a.isRTL(t));let u=await a.getElementRects({reference:e,floating:t,strategy:i}),{x:f,y:p}=SA(u,r,c),d=r,m=0;const y={};for(let v=0;v<o.length;v++){const b=o[v];if(!b)continue;const{name:g,fn:k}=b,{x,y:_,data:j,reset:N}=await k({x:f,y:p,initialPlacement:r,placement:d,strategy:i,middlewareData:y,rects:u,platform:l,elements:{reference:e,floating:t}});f=x??f,p=_??p,y[g]={...y[g],...j},N&&m<Nce&&(m++,typeof N=="object"&&(N.placement&&(d=N.placement),N.rects&&(u=N.rects===!0?await a.getElementRects({reference:e,floating:t,strategy:i}):N.rects),{x:f,y:p}=SA(u,d,c)),v=-1)}return{x:f,y:p,placement:d,strategy:i,middlewareData:y}},Cce=e=>({name:"arrow",options:e,async fn(t){const{x:n,y:r,placement:i,rects:o,platform:a,elements:l,middlewareData:c}=t,{element:u,padding:f=0}=cu(e,t)||{};if(u==null)return{};const p=W$(f),d={x:n,y:r},m=iS(i),y=sS(m),v=await a.getDimensions(u),b=m==="y",g=b?"top":"left",k=b?"bottom":"right",x=b?"clientHeight":"clientWidth",_=o.reference[y]+o.reference[m]-d[m]-o.floating[y],j=d[m]-o.reference[m],N=await(a.getOffsetParent==null?void 0:a.getOffsetParent(u));let P=N?N[x]:0;(!P||!await(a.isElement==null?void 0:a.isElement(N)))&&(P=l.floating[x]||o.floating[y]);const T=_/2-j/2,z=P/2-v[y]/2-1,E=Qc(p[g],z),O=Qc(p[k],z),D=E,L=P-v[y]-O,$=P/2-v[y]/2+T,V=sk(D,$,L),W=!c.arrow&&zi(i)!=null&&$!==V&&o.reference[y]/2-($<D?E:O)-v[y]/2<0,F=W?$<D?$-D:$-L:0;return{[m]:d[m]+F,data:{[m]:V,centerOffset:$-V-F,...W&&{alignmentOffset:F}},reset:W}}});function Ace(e,t,n){return(e?[...n.filter(i=>zi(i)===e),...n.filter(i=>zi(i)!==e)]:n.filter(i=>bo(i)===i)).filter(i=>e?zi(i)===e||(t?Xm(i)!==i:!1):!0)}const Ece=function(e){return e===void 0&&(e={}),{name:"autoPlacement",options:e,async fn(t){var n,r,i;const{rects:o,middlewareData:a,placement:l,platform:c,elements:u}=t,{crossAxis:f=!1,alignment:p,allowedPlacements:d=bA,autoAlignment:m=!0,...y}=cu(e,t),v=p!==void 0||d===bA?Ace(p||null,m,d):d,b=await c.detectOverflow(t,y),g=((n=a.autoPlacement)==null?void 0:n.index)||0,k=v[g];if(k==null)return{};const x=B$(k,o,await(c.isRTL==null?void 0:c.isRTL(u.floating)));if(l!==k)return{reset:{placement:v[0]}};const _=[b[bo(k)],b[x[0]],b[x[1]]],j=[...((r=a.autoPlacement)==null?void 0:r.overflows)||[],{placement:k,overflows:_}],N=v[g+1];if(N)return{data:{index:g+1,overflows:j},reset:{placement:N}};const P=j.map(E=>{const O=zi(E.placement);return[E.placement,O&&f?E.overflows.slice(0,2).reduce((D,L)=>D+L,0):E.overflows[0],E.overflows]}).sort((E,O)=>E[1]-O[1]),z=((i=P.filter(E=>E[2].slice(0,zi(E[0])?2:3).every(O=>O<=0))[0])==null?void 0:i[0])||P[0][0];return z!==l?{data:{index:g+1,overflows:j},reset:{placement:z}}:{}}}},Ice=function(e){return e===void 0&&(e={}),{name:"flip",options:e,async fn(t){var n,r;const{placement:i,middlewareData:o,rects:a,initialPlacement:l,platform:c,elements:u}=t,{mainAxis:f=!0,crossAxis:p=!0,fallbackPlacements:d,fallbackStrategy:m="bestFit",fallbackAxisSideDirection:y="none",flipAlignment:v=!0,...b}=cu(e,t);if((n=o.arrow)!=null&&n.alignmentOffset)return{};const g=bo(i),k=ea(l),x=bo(l)===l,_=await(c.isRTL==null?void 0:c.isRTL(u.floating)),j=d||(x||!v?[Qm(l)]:wce(l)),N=y!=="none";!d&&N&&j.push(...vce(l,v,y,_));const P=[l,...j],T=await c.detectOverflow(t,b),z=[];let E=((r=o.flip)==null?void 0:r.overflows)||[];if(f&&z.push(T[g]),p){const $=B$(i,a,_);z.push(T[$[0]],T[$[1]])}if(E=[...E,{placement:i,overflows:z}],!z.every($=>$<=0)){var O,D;const $=(((O=o.flip)==null?void 0:O.index)||0)+1,V=P[$];if(V&&(!(p==="alignment"?k!==ea(V):!1)||E.every(M=>ea(M.placement)===k?M.overflows[0]>0:!0)))return{data:{index:$,overflows:E},reset:{placement:V}};let W=(D=E.filter(F=>F.overflows[0]<=0).sort((F,M)=>F.overflows[1]-M.overflows[1])[0])==null?void 0:D.placement;if(!W)switch(m){case"bestFit":{var L;const F=(L=E.filter(M=>{if(N){const H=ea(M.placement);return H===k||H==="y"}return!0}).map(M=>[M.placement,M.overflows.filter(H=>H>0).reduce((H,A)=>H+A,0)]).sort((M,H)=>M[1]-H[1])[0])==null?void 0:L[0];F&&(W=F);break}case"initialPlacement":W=l;break}if(i!==W)return{reset:{placement:W}}}return{}}}},Pce=new Set(["left","top"]);async function Tce(e,t){const{placement:n,platform:r,elements:i}=e,o=await(r.isRTL==null?void 0:r.isRTL(i.floating)),a=bo(n),l=zi(n),c=ea(n)==="y",u=Pce.has(a)?-1:1,f=o&&c?-1:1,p=cu(t,e);let{mainAxis:d,crossAxis:m,alignmentAxis:y}=typeof p=="number"?{mainAxis:p,crossAxis:0,alignmentAxis:null}:{mainAxis:p.mainAxis||0,crossAxis:p.crossAxis||0,alignmentAxis:p.alignmentAxis};return l&&typeof y=="number"&&(m=l==="end"?y*-1:y),c?{x:m*f,y:d*u}:{x:d*u,y:m*f}}const Rce=function(e){return e===void 0&&(e=0),{name:"offset",options:e,async fn(t){var n,r;const{x:i,y:o,placement:a,middlewareData:l}=t,c=await Tce(t,e);return a===((n=l.offset)==null?void 0:n.placement)&&(r=l.arrow)!=null&&r.alignmentOffset?{}:{x:i+c.x,y:o+c.y,data:{...c,placement:a}}}}},Mce=function(e){return e===void 0&&(e={}),{name:"shift",options:e,async fn(t){const{x:n,y:r,placement:i,platform:o}=t,{mainAxis:a=!0,crossAxis:l=!1,limiter:c={fn:g=>{let{x:k,y:x}=g;return{x:k,y:x}}},...u}=cu(e,t),f={x:n,y:r},p=await o.detectOverflow(t,u),d=ea(bo(i)),m=z$(d);let y=f[m],v=f[d];if(a){const g=m==="y"?"top":"left",k=m==="y"?"bottom":"right",x=y+p[g],_=y-p[k];y=sk(x,y,_)}if(l){const g=d==="y"?"top":"left",k=d==="y"?"bottom":"right",x=v+p[g],_=v-p[k];v=sk(x,v,_)}const b=c.fn({...t,[m]:y,[d]:v});return{...b,data:{x:b.x-n,y:b.y-r,enabled:{[m]:a,[d]:l}}}}}};function Bg(){return typeof window<"u"}function uu(e){return H$(e)?(e.nodeName||"").toLowerCase():"#document"}function ks(e){var t;return(e==null||(t=e.ownerDocument)==null?void 0:t.defaultView)||window}function Vi(e){var t;return(t=(H$(e)?e.ownerDocument:e.document)||window.document)==null?void 0:t.documentElement}function H$(e){return Bg()?e instanceof Node||e instanceof ks(e).Node:!1}function pi(e){return Bg()?e instanceof Element||e instanceof ks(e).Element:!1}function jo(e){return Bg()?e instanceof HTMLElement||e instanceof ks(e).HTMLElement:!1}function jA(e){return!Bg()||typeof ShadowRoot>"u"?!1:e instanceof ShadowRoot||e instanceof ks(e).ShadowRoot}function Uf(e){const{overflow:t,overflowX:n,overflowY:r,display:i}=hi(e);return/auto|scroll|overlay|hidden|clip/.test(t+r+n)&&i!=="inline"&&i!=="contents"}function $ce(e){return/^(table|td|th)$/.test(uu(e))}function Wg(e){try{if(e.matches(":popover-open"))return!0}catch{}try{return e.matches(":modal")}catch{return!1}}const Lce=/transform|translate|scale|rotate|perspective|filter/,Oce=/paint|layout|strict|content/,$a=e=>!!e&&e!=="none";let tx;function oS(e){const t=pi(e)?hi(e):e;return $a(t.transform)||$a(t.translate)||$a(t.scale)||$a(t.rotate)||$a(t.perspective)||!aS()&&($a(t.backdropFilter)||$a(t.filter))||Lce.test(t.willChange||"")||Oce.test(t.contain||"")}function Dce(e){let t=wa(e);for(;jo(t)&&!Zc(t);){if(oS(t))return t;if(Wg(t))return null;t=wa(t)}return null}function aS(){return tx==null&&(tx=typeof CSS<"u"&&CSS.supports&&CSS.supports("-webkit-backdrop-filter","none")),tx}function Zc(e){return/^(html|body|#document)$/.test(uu(e))}function hi(e){return ks(e).getComputedStyle(e)}function Hg(e){return pi(e)?{scrollLeft:e.scrollLeft,scrollTop:e.scrollTop}:{scrollLeft:e.scrollX,scrollTop:e.scrollY}}function wa(e){if(uu(e)==="html")return e;const t=e.assignedSlot||e.parentNode||jA(e)&&e.host||Vi(e);return jA(t)?t.host:t}function V$(e){const t=wa(e);return Zc(t)?e.ownerDocument?e.ownerDocument.body:e.body:jo(t)&&Uf(t)?t:V$(t)}function _f(e,t,n){var r;t===void 0&&(t=[]),n===void 0&&(n=!0);const i=V$(e),o=i===((r=e.ownerDocument)==null?void 0:r.body),a=ks(i);if(o){const l=ik(a);return t.concat(a,a.visualViewport||[],Uf(i)?i:[],l&&n?_f(l):[])}else return t.concat(i,_f(i,[],n))}function ik(e){return e.parent&&Object.getPrototypeOf(e.parent)?e.frameElement:null}function K$(e){const t=hi(e);let n=parseFloat(t.width)||0,r=parseFloat(t.height)||0;const i=jo(e),o=i?e.offsetWidth:n,a=i?e.offsetHeight:r,l=Jm(n)!==o||Jm(r)!==a;return l&&(n=o,r=a),{width:n,height:r,$:l}}function lS(e){return pi(e)?e:e.contextElement}function $c(e){const t=lS(e);if(!jo(t))return Fi(1);const n=t.getBoundingClientRect(),{width:r,height:i,$:o}=K$(t);let a=(o?Jm(n.width):n.width)/r,l=(o?Jm(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const Fce=Fi(0);function q$(e){const t=ks(e);return!aS()||!t.visualViewport?Fce:{x:t.visualViewport.offsetLeft,y:t.visualViewport.offsetTop}}function zce(e,t,n){return t===void 0&&(t=!1),!n||t&&n!==ks(e)?!1:t}function yl(e,t,n,r){t===void 0&&(t=!1),n===void 0&&(n=!1);const i=e.getBoundingClientRect(),o=lS(e);let a=Fi(1);t&&(r?pi(r)&&(a=$c(r)):a=$c(e));const l=zce(o,n,r)?q$(o):Fi(0);let c=(i.left+l.x)/a.x,u=(i.top+l.y)/a.y,f=i.width/a.x,p=i.height/a.y;if(o){const d=ks(o),m=r&&pi(r)?ks(r):r;let y=d,v=ik(y);for(;v&&r&&m!==y;){const b=$c(v),g=v.getBoundingClientRect(),k=hi(v),x=g.left+(v.clientLeft+parseFloat(k.paddingLeft))*b.x,_=g.top+(v.clientTop+parseFloat(k.paddingTop))*b.y;c*=b.x,u*=b.y,f*=b.x,p*=b.y,c+=x,u+=_,y=ks(v),v=ik(y)}}return Zm({width:f,height:p,x:c,y:u})}function Vg(e,t){const n=Hg(e).scrollLeft;return t?t.left+n:yl(Vi(e)).left+n}function U$(e,t){const n=e.getBoundingClientRect(),r=n.left+t.scrollLeft-Vg(e,n),i=n.top+t.scrollTop;return{x:r,y:i}}function Bce(e){let{elements:t,rect:n,offsetParent:r,strategy:i}=e;const o=i==="fixed",a=Vi(r),l=t?Wg(t.floating):!1;if(r===a||l&&o)return n;let c={scrollLeft:0,scrollTop:0},u=Fi(1);const f=Fi(0),p=jo(r);if((p||!p&&!o)&&((uu(r)!=="body"||Uf(a))&&(c=Hg(r)),p)){const m=yl(r);u=$c(r),f.x=m.x+r.clientLeft,f.y=m.y+r.clientTop}const d=a&&!p&&!o?U$(a,c):Fi(0);return{width:n.width*u.x,height:n.height*u.y,x:n.x*u.x-c.scrollLeft*u.x+f.x+d.x,y:n.y*u.y-c.scrollTop*u.y+f.y+d.y}}function Wce(e){return Array.from(e.getClientRects())}function Hce(e){const t=Vi(e),n=Hg(e),r=e.ownerDocument.body,i=tl(t.scrollWidth,t.clientWidth,r.scrollWidth,r.clientWidth),o=tl(t.scrollHeight,t.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+Vg(e);const l=-n.scrollTop;return hi(r).direction==="rtl"&&(a+=tl(t.clientWidth,r.clientWidth)-i),{width:i,height:o,x:a,y:l}}const NA=25;function Vce(e,t){const n=ks(e),r=Vi(e),i=n.visualViewport;let o=r.clientWidth,a=r.clientHeight,l=0,c=0;if(i){o=i.width,a=i.height;const f=aS();(!f||f&&t==="fixed")&&(l=i.offsetLeft,c=i.offsetTop)}const u=Vg(r);if(u<=0){const f=r.ownerDocument,p=f.body,d=getComputedStyle(p),m=f.compatMode==="CSS1Compat"&&parseFloat(d.marginLeft)+parseFloat(d.marginRight)||0,y=Math.abs(r.clientWidth-p.clientWidth-m);y<=NA&&(o-=y)}else u<=NA&&(o+=u);return{width:o,height:a,x:l,y:c}}function Kce(e,t){const n=yl(e,!0,t==="fixed"),r=n.top+e.clientTop,i=n.left+e.clientLeft,o=jo(e)?$c(e):Fi(1),a=e.clientWidth*o.x,l=e.clientHeight*o.y,c=i*o.x,u=r*o.y;return{width:a,height:l,x:c,y:u}}function _A(e,t,n){let r;if(t==="viewport")r=Vce(e,n);else if(t==="document")r=Hce(Vi(e));else if(pi(t))r=Kce(t,n);else{const i=q$(e);r={x:t.x-i.x,y:t.y-i.y,width:t.width,height:t.height}}return Zm(r)}function G$(e,t){const n=wa(e);return n===t||!pi(n)||Zc(n)?!1:hi(n).position==="fixed"||G$(n,t)}function qce(e,t){const n=t.get(e);if(n)return n;let r=_f(e,[],!1).filter(l=>pi(l)&&uu(l)!=="body"),i=null;const o=hi(e).position==="fixed";let a=o?wa(e):e;for(;pi(a)&&!Zc(a);){const l=hi(a),c=oS(a);!c&&l.position==="fixed"&&(i=null),(o?!c&&!i:!c&&l.position==="static"&&!!i&&(i.position==="absolute"||i.position==="fixed")||Uf(a)&&!c&&G$(e,a))?r=r.filter(f=>f!==a):i=l,a=wa(a)}return t.set(e,r),r}function Uce(e){let{element:t,boundary:n,rootBoundary:r,strategy:i}=e;const a=[...n==="clippingAncestors"?Wg(t)?[]:qce(t,this._c):[].concat(n),r],l=_A(t,a[0],i);let c=l.top,u=l.right,f=l.bottom,p=l.left;for(let d=1;d<a.length;d++){const m=_A(t,a[d],i);c=tl(m.top,c),u=Qc(m.right,u),f=Qc(m.bottom,f),p=tl(m.left,p)}return{width:u-p,height:f-c,x:p,y:c}}function Gce(e){const{width:t,height:n}=K$(e);return{width:t,height:n}}function Yce(e,t,n){const r=jo(t),i=Vi(t),o=n==="fixed",a=yl(e,!0,o,t);let l={scrollLeft:0,scrollTop:0};const c=Fi(0);function u(){c.x=Vg(i)}if(r||!r&&!o)if((uu(t)!=="body"||Uf(i))&&(l=Hg(t)),r){const m=yl(t,!0,o,t);c.x=m.x+t.clientLeft,c.y=m.y+t.clientTop}else i&&u();o&&!r&&i&&u();const f=i&&!r&&!o?U$(i,l):Fi(0),p=a.left+l.scrollLeft-c.x-f.x,d=a.top+l.scrollTop-c.y-f.y;return{x:p,y:d,width:a.width,height:a.height}}function nx(e){return hi(e).position==="static"}function CA(e,t){if(!jo(e)||hi(e).position==="fixed")return null;if(t)return t(e);let n=e.offsetParent;return Vi(e)===n&&(n=n.ownerDocument.body),n}function Y$(e,t){const n=ks(e);if(Wg(e))return n;if(!jo(e)){let i=wa(e);for(;i&&!Zc(i);){if(pi(i)&&!nx(i))return i;i=wa(i)}return n}let r=CA(e,t);for(;r&&$ce(r)&&nx(r);)r=CA(r,t);return r&&Zc(r)&&nx(r)&&!oS(r)?n:r||Dce(e)||n}const Jce=async function(e){const t=this.getOffsetParent||Y$,n=this.getDimensions,r=await n(e.floating);return{reference:Yce(e.reference,await t(e.floating),e.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Xce(e){return hi(e).direction==="rtl"}const Qce={convertOffsetParentRelativeRectToViewportRelativeRect:Bce,getDocumentElement:Vi,getClippingRect:Uce,getOffsetParent:Y$,getElementRects:Jce,getClientRects:Wce,getDimensions:Gce,getScale:$c,isElement:pi,isRTL:Xce};function J$(e,t){return e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height}function Zce(e,t){let n=null,r;const i=Vi(e);function o(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,c){l===void 0&&(l=!1),c===void 0&&(c=1),o();const u=e.getBoundingClientRect(),{left:f,top:p,width:d,height:m}=u;if(l||t(),!d||!m)return;const y=wh(p),v=wh(i.clientWidth-(f+d)),b=wh(i.clientHeight-(p+m)),g=wh(f),x={rootMargin:-y+"px "+-v+"px "+-b+"px "+-g+"px",threshold:tl(0,Qc(1,c))||1};let _=!0;function j(N){const P=N[0].intersectionRatio;if(P!==c){if(!_)return a();P?a(!1,P):r=setTimeout(()=>{a(!1,1e-7)},1e3)}P===1&&!J$(u,e.getBoundingClientRect())&&a(),_=!1}try{n=new IntersectionObserver(j,{...x,root:i.ownerDocument})}catch{n=new IntersectionObserver(j,x)}n.observe(e)}return a(!0),o}function AA(e,t,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:c=!1}=r,u=lS(e),f=i||o?[...u?_f(u):[],...t?_f(t):[]]:[];f.forEach(g=>{i&&g.addEventListener("scroll",n,{passive:!0}),o&&g.addEventListener("resize",n)});const p=u&&l?Zce(u,n):null;let d=-1,m=null;a&&(m=new ResizeObserver(g=>{let[k]=g;k&&k.target===u&&m&&t&&(m.unobserve(t),cancelAnimationFrame(d),d=requestAnimationFrame(()=>{var x;(x=m)==null||x.observe(t)})),n()}),u&&!c&&m.observe(u),t&&m.observe(t));let y,v=c?yl(e):null;c&&b();function b(){const g=yl(e);v&&!J$(v,g)&&n(),v=g,y=requestAnimationFrame(b)}return n(),()=>{var g;f.forEach(k=>{i&&k.removeEventListener("scroll",n),o&&k.removeEventListener("resize",n)}),p==null||p(),(g=m)==null||g.disconnect(),m=null,c&&cancelAnimationFrame(y)}}const eue=Rce,tue=Ece,nue=Mce,rue=Ice,EA=Cce,sue=(e,t,n)=>{const r=new Map,i={platform:Qce,...n},o={...i.platform,_c:r};return _ce(e,t,{...i,platform:o})};var iue=typeof document<"u",oue=function(){},Uh=iue?h.useLayoutEffect:oue;function eg(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,i;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(!eg(e[r],t[r]))return!1;return!0}if(i=Object.keys(e),n=i.length,n!==Object.keys(t).length)return!1;for(r=n;r--!==0;)if(!{}.hasOwnProperty.call(t,i[r]))return!1;for(r=n;r--!==0;){const o=i[r];if(!(o==="_owner"&&e.$$typeof)&&!eg(e[o],t[o]))return!1}return!0}return e!==e&&t!==t}function X$(e){return typeof window>"u"?1:(e.ownerDocument.defaultView||window).devicePixelRatio||1}function IA(e,t){const n=X$(e);return Math.round(t*n)/n}function rx(e){const t=h.useRef(e);return Uh(()=>{t.current=e}),t}function PA(e){e===void 0&&(e={});const{placement:t="bottom",strategy:n="absolute",middleware:r=[],platform:i,elements:{reference:o,floating:a}={},transform:l=!0,whileElementsMounted:c,open:u}=e,[f,p]=h.useState({x:0,y:0,strategy:n,placement:t,middlewareData:{},isPositioned:!1}),[d,m]=h.useState(r);eg(d,r)||m(r);const[y,v]=h.useState(null),[b,g]=h.useState(null),k=h.useCallback(M=>{M!==N.current&&(N.current=M,v(M))},[]),x=h.useCallback(M=>{M!==P.current&&(P.current=M,g(M))},[]),_=o||y,j=a||b,N=h.useRef(null),P=h.useRef(null),T=h.useRef(f),z=c!=null,E=rx(c),O=rx(i),D=rx(u),L=h.useCallback(()=>{if(!N.current||!P.current)return;const M={placement:t,strategy:n,middleware:d};O.current&&(M.platform=O.current),sue(N.current,P.current,M).then(H=>{const A={...H,isPositioned:D.current!==!1};$.current&&!eg(T.current,A)&&(T.current=A,er.flushSync(()=>{p(A)}))})},[d,t,n,O,D]);Uh(()=>{u===!1&&T.current.isPositioned&&(T.current.isPositioned=!1,p(M=>({...M,isPositioned:!1})))},[u]);const $=h.useRef(!1);Uh(()=>($.current=!0,()=>{$.current=!1}),[]),Uh(()=>{if(_&&(N.current=_),j&&(P.current=j),_&&j){if(E.current)return E.current(_,j,L);L()}},[_,j,L,E,z]);const V=h.useMemo(()=>({reference:N,floating:P,setReference:k,setFloating:x}),[k,x]),W=h.useMemo(()=>({reference:_,floating:j}),[_,j]),F=h.useMemo(()=>{const M={position:n,left:0,top:0};if(!W.floating)return M;const H=IA(W.floating,f.x),A=IA(W.floating,f.y);return l?{...M,transform:"translate("+H+"px, "+A+"px)",...X$(W.floating)>=1.5&&{willChange:"transform"}}:{position:n,left:H,top:A}},[n,l,W.floating,f.x,f.y]);return h.useMemo(()=>({...f,update:L,refs:V,elements:W,floatingStyles:F}),[f,L,V,W,F])}const aue=e=>{function t(n){return{}.hasOwnProperty.call(n,"current")}return{name:"arrow",options:e,fn(n){const{element:r,padding:i}=typeof e=="function"?e(n):e;return r&&t(r)?r.current!=null?EA({element:r.current,padding:i}).fn(n):{}:r?EA({element:r,padding:i}).fn(n):{}}}},TA=(e,t)=>{const n=eue(e);return{name:n.name,fn:n.fn,options:[e,t]}},lue=(e,t)=>{const n=nue(e);return{name:n.name,fn:n.fn,options:[e,t]}},cue=(e,t)=>{const n=rue(e);return{name:n.name,fn:n.fn,options:[e,t]}},uue=(e,t)=>{const n=tue(e);return{name:n.name,fn:n.fn,options:[e,t]}},due=(e,t)=>{const n=aue(e);return{name:n.name,fn:n.fn,options:[e,t]}},fue={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},pue={beaconOptions:{offset:-18}},Q$={back:"Back",close:"Close",last:"Last",next:"Next",nextWithProgress:"Next ({current} of {total})",open:"Open the dialog",skip:"Skip"},hue={isFixed:!1,locale:Q$,placement:"bottom"},mue={continuous:!1,debug:!1,run:!1,scrollToFirstStep:!1,steps:[]},Vt={INIT:"init",START:"start",STOP:"stop",RESET:"reset",PREV:"prev",NEXT:"next",GO:"go",CLOSE:"close",SKIP:"skip",UPDATE:"update",COMPLETE:"complete"},kr={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"},et={INIT:"init",READY:"ready",BEACON_BEFORE:"beacon_before",BEACON:"beacon",TOOLTIP_BEFORE:"tooltip_before",TOOLTIP:"tooltip",COMPLETE:"complete"},Ci={BUTTON_BACK:"button_back",BUTTON_CLOSE:"button_close",BUTTON_PRIMARY:"button_primary",BUTTON_SKIP:"button_skip",KEYBOARD:"keyboard",OVERLAY:"overlay"},Lt={IDLE:"idle",READY:"ready",WAITING:"waiting",RUNNING:"running",PAUSED:"paused",SKIPPED:"skipped",FINISHED:"finished"},gue="react-joyride-portal";function yue(e){const t={};for(const n in e)e[n]!==void 0&&(t[n]=e[n]);return t}function kc(...e){return ace({all:!0,isMergeableObject:t=>!(!Dr.plainObject(t)||h.isValidElement(t))})(...e)}function Z$(e){return Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}function no(e,t={}){const{defaultValue:n,step:r,steps:i}=t;let o=ex(e);if(o)(o.includes("{current}")||o.includes("{total}"))&&r&&i&&(o=o.replace("{current}",r.toString()).replace("{total}",i.toString()));else if(h.isValidElement(e)&&!Object.values(e.props).length&&Z$(e.type)==="function")try{o=no(e.type({}),t)}catch{o=ex(n)}else o=ex(n);return o}function jr(e,t,n,...r){if(!e)return;const i=new Date,o=`${String(i.getHours()).padStart(2,"0")}:${String(i.getMinutes()).padStart(2,"0")}:${String(i.getSeconds()).padStart(2,"0")}.${String(i.getMilliseconds()).padStart(3,"0")}`;console.log(`${t} %c${n}%c ${o}`,"font-weight: bold","color: gray; font-weight: normal",...r)}function wue(e,t){const n=yue(t);return{...e,...n}}function Cf(){}function xue(e){return Object.keys(e)}function tg(e,...t){if(!Dr.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 RA(e,...t){if(!Dr.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 ok(e,t,n){const r=o=>o.replace("{current}",String(t)).replace("{total}",String(n));if(Z$(e)==="string")return r(e);if(!h.isValidElement(e))return e;const{children:i}=e.props;if(Dr.string(i)&&i.includes("{current}"))return h.cloneElement(e,{children:r(i)});if(Array.isArray(i))return h.cloneElement(e,{children:i.map(o=>typeof o=="string"?r(o):ok(o,t,n))});if(Dr.function(e.type)&&!Object.values(e.props).length)try{return ok(e.type({}),t,n)}catch{return e}return e}function MA(e){return xue(e).sort().reduce((t,n)=>(t[n]=e[n],t),{})}function cS(){var e;return!!(typeof window<"u"&&((e=window.document)!=null&&e.createElement))}function $A(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 uS(e){return e?e.getBoundingClientRect():null}function bue(e=!1){const{body:t,documentElement:n}=document;if(!t||!n)return 0;if(e){const r=[t.scrollHeight,t.offsetHeight,n.clientHeight,n.scrollHeight,n.offsetHeight].sort((o,a)=>o-a),i=Math.floor(r.length/2);return r.length%2===0?(r[i-1]+r[i])/2:r[i]}return Math.max(t.scrollHeight,t.offsetHeight,n.clientHeight,n.scrollHeight,n.offsetHeight)}function Fs(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 kue(e,t,n){const r=uS(e),i=du(e),o=i?!i.isSameNode(is()):!1,a=n??fu(e);let l=0,c=(r==null?void 0:r.top)??0;return o&&a?c=(r==null?void 0:r.top)??0:i instanceof HTMLElement&&(l=i.scrollTop,!o&&!a&&(c+=l),i.isSameNode(is())||(c+=is().scrollTop)),Math.floor(c-t)}function du(e,t){if(!e)return is();const n=F$(e);if(n){if(n.isSameNode(is()))return t?document:is();if(!(n.scrollHeight>n.offsetHeight))return is()}return n}function vue(e){const t=e.getBoundingClientRect(),n=is(),r=t.top+t.height/2,i=window.innerHeight/2;return Math.max(0,n.scrollTop+r-i)}function Sue(e,t){if(!e)return 0;const n=F$(e)??is(),r=parseFloat(getComputedStyle(e).scrollMarginTop)||0,i=uS(n),o=n.scrollTop??0,{offsetTop:a=0,scrollTop:l=0}=n;let c=e.getBoundingClientRect().top+l;if(a&&(eL(e)||jue(e))){const f=e.getBoundingClientRect(),p=f.top-((i==null?void 0:i.top)??0),d=p+f.height,m=n.clientHeight,y=m*.2;p>=y&&d<=m-y?c=o:c=p+o}const u=Math.floor(c-t-r);return u<0?0:u}function jue(e){return e.offsetParent!==document.body}function eL(e){if(!e)return!1;const t=du(e);return t?!t.isSameNode(is()):!1}function fu(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?fu(e.parentNode,t):!1}function xh(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 LA(e){const{isFirstStep:t,scrollToFirstStep:n,step:r,target:i,targetLifecycle:o}=e;if(r.skipScroll||t&&!n&&o!==et.TOOLTIP||r.placement==="center")return!1;const a=i!=null&&i.isConnected?du(i):is(),l=a?!a.isSameNode(is()):!1;return(r.isFixed||fu(i))&&!l?!1:a.scrollHeight>a.clientHeight}function is(){return document.scrollingElement??document.documentElement}function OA(e,t){const{duration:n,element:r}=t;let i=()=>{};const o=new Promise(a=>{const{scrollTop:l}=r,c=e>l?e-l:l-e;i=hce.top(r,e,{duration:c<100?50:n},()=>{a()})});return{cancel:i,promise:o}}function Nue(e){const t=e.replace(/^#?([\da-f])([\da-f])([\da-f])$/i,(r,i,o,a)=>i+i+o+o+a+a),n=/^#?([\da-f]{2})([\da-f]{2})([\da-f]{2})/i.exec(t);return n?[parseInt(n[1],16),parseInt(n[2],16),parseInt(n[3],16)]:[]}const tL={backgroundColor:"transparent",border:0,borderRadius:0,color:"#555555",cursor:"pointer",fontSize:16,lineHeight:1,padding:0,WebkitAppearance:"none"},bh={...tL,borderRadius:4,padding:8};function _ue(e,t){const{styles:n}=e,r=kc(n??{},t.styles??{});let{width:i}=t;cS()&&(i=typeof i=="number"&&window.innerWidth<i?window.innerWidth-30:i);const o={bottom:0,left:0,overflow:"hidden",position:"absolute",right:0,top:0,zIndex:t.zIndex};return kc({arrow:{alignItems:"center",color:t.arrowColor,display:"inline-flex",justifyContent:"center",position:"absolute"},beaconWrapper:{...tL,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(${Nue(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:{...bh,color:t.primaryColor,marginLeft:"auto",marginRight:5},buttonClose:{...bh,color:t.textColor,height:12,padding:8,position:"absolute",right:0,top:0,width:12},buttonPrimary:{...bh,backgroundColor:t.primaryColor,color:t.backgroundColor},buttonSkip:{...bh,color:t.textColor,fontSize:14},floater:{display:"inline-block",filter:"drop-shadow(0 0 3px rgba(0, 0, 0, 0.3))",maxWidth:"100%",transition:"opacity 0.3s"},loader:{alignItems:"center",display:"flex",height:48,inset:0,justifyContent:"center",pointerEvents:"none",position:"fixed",width:48,zIndex:t.zIndex+1},overlay:{...o,backgroundColor:t.overlayColor},spotlight:{},tooltip:{backgroundColor:t.backgroundColor,borderRadius:5,boxSizing:"border-box",color:t.textColor,fontSize:16,maxWidth:"100%",padding:12,position:"relative",width:i},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 Cue=["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 dS(e,t){if(!t)return null;const n=kc(hue,RA(e,"arrowComponent","beaconComponent","floatingOptions","loaderComponent","locale","styles","tooltipComponent"),t),r=kc(fue,e.options??{},RA(t,...Cue)),i=_ue(e,{...n,...r}),o=kc(pue,e.floatingOptions??{},n.floatingOptions??{});return{...n,...r,locale:kc(Q$,e.locale??{},n.locale||{}),floatingOptions:o,spotlightPadding:Aue(r.spotlightPadding),styles:i}}function Aue(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 Eue(e,t,n){const{action:r}=t,i=n&&[Vt.PREV,Vt.NEXT].includes(r);return e.skipBeacon||e.placement==="center"||i}function nL(e,t=!1){return Dr.plainObject(e)?e.target?!0:(jr(t,"tour","target is missing from the step"),!1):(jr(t,"tour","step must be an object"),!1)}function rL(e,t=!1){return Dr.array(e)?e.every(n=>nL(n,t)):(jr(t,"tour","steps must be an array"),!1)}var Iue=class{constructor(e){Un(this,"beaconPosition",null);Un(this,"debug");Un(this,"eventListeners",new Map);Un(this,"listeners",new Set);Un(this,"props");Un(this,"snapshot");Un(this,"state");Un(this,"steps");Un(this,"tooltipPosition",null);Un(this,"cleanupPositionData",()=>{this.beaconPosition=null,this.tooltipPosition=null});Un(this,"getPositionData",e=>e==="beacon"?this.beaconPosition:this.tooltipPosition);Un(this,"getServerSnapshot",()=>this.snapshot);Un(this,"getSnapshot",()=>this.snapshot);Un(this,"getEventState",()=>tg(this.snapshot,"positioned"));Un(this,"getState",()=>tg(this.snapshot,"positioned"));Un(this,"setPositionData",(e,t)=>{var r,i,o;((r=e==="beacon"?this.beaconPosition:this.tooltipPosition)==null?void 0:r.placement)!==t.placement&&jr(this.debug,`step:${this.state.index}`,"positioned",`${e} ${t.placement}`),e==="beacon"?this.beaconPosition=t:this.tooltipPosition=t,(this.state.lifecycle===et.BEACON_BEFORE||this.state.lifecycle===et.TOOLTIP_BEFORE)&&!this.state.positioned&&this.updateState({positioned:!0});const n=(o=(i=this.getStep())==null?void 0:i.floatingOptions)==null?void 0:o.onPosition;n&&n(t)});Un(this,"setSteps",e=>{this.steps=e,this.updateState({size:e.length})});Un(this,"dispatch",(e,t)=>{const n=this.eventListeners.get(e.type);if(n)for(const r of n)try{r(e,t)}catch{}});Un(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)}});Un(this,"subscribe",e=>(this.listeners.add(e),()=>{this.listeners.delete(e)}));Un(this,"updateState",(e,t=!1)=>{const{controlled:n,index:r}=this.state,i=this.snapshot,o=n&&!t&&e.index!==void 0?r:e.index??r,a={action:e.action??this.state.action,controlled:n,index:o,lifecycle:e.lifecycle??this.state.lifecycle,origin:e.origin??null,positioned:e.positioned??this.state.positioned,scrolling:e.scrolling??this.state.scrolling,size:e.size??this.state.size,status:e.status??this.state.status,waiting:e.waiting??this.state.waiting},l=this.applyTransitions(a);if(this.state=l,!eS(i,l)){this.snapshot=Object.freeze({...l});for(const c of this.listeners)c(this.snapshot)}});const{initialStepIndex:t,stepIndex:n,steps:r=[]}=e??{},i=Dr.number(n);let o=0;this.debug=(e==null?void 0:e.debug)??!1,i?(o=n,Dr.number(t)&&jr(this.debug,"tour","initialStepIndex is ignored in controlled mode")):Dr.number(t)&&(t>=0&&t<r.length?o=t:r.length>0&&jr(this.debug,"tour","initialStepIndex is out of bounds")),this.props=e??{steps:[]},this.steps=r,this.state={action:Vt.INIT,controlled:i,index:o,lifecycle:et.INIT,origin:null,positioned:!1,scrolling:!1,size:r.length,status:r.length?Lt.READY:Lt.IDLE,waiting:!1},this.snapshot=Object.freeze({...this.state})}applyTransitions(e){return e.status===Lt.WAITING&&e.size>0?{...e,status:Lt.RUNNING}:e}getStep(e){return dS(this.props,this.steps[e??this.state.index])}};function Pue(e){return new Iue(e)}function DA(e,t){return Math.min(Math.max(e,0),t)}function Tue(e,t,n){const r=h.useRef(t),i=h.useRef(n);return r.current=t,i.current=n,h.useMemo(()=>{const o=()=>e.current.getSnapshot();return{close:(b=null)=>{const{index:g,status:k}=o();k===Lt.RUNNING&&e.current.updateState({action:Vt.CLOSE,index:g+1,origin:b,lifecycle:et.COMPLETE,positioned:!1,scrolling:!1,waiting:!1})},go:b=>{const{controlled:g,size:k,status:x}=o();if(g){jr(r.current,"tour","go() is not supported in controlled mode");return}x===Lt.RUNNING&&e.current.updateState({action:Vt.GO,index:b,lifecycle:et.COMPLETE,positioned:!1,scrolling:!1,status:b<k?x:Lt.FINISHED,waiting:!1})},info:()=>tg(e.current.getSnapshot(),"positioned"),next:b=>{const{index:g,size:k,status:x}=o();x===Lt.RUNNING&&e.current.updateState({action:Vt.NEXT,index:DA(g+1,k),lifecycle:et.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},open:()=>{const{status:b}=o();b===Lt.RUNNING&&e.current.updateState({action:Vt.UPDATE,lifecycle:et.TOOLTIP_BEFORE,positioned:!1,scrolling:!1,waiting:!1})},prev:b=>{const{index:g,size:k,status:x}=o();x===Lt.RUNNING&&e.current.updateState({action:Vt.PREV,index:DA(g-1,k),lifecycle:et.COMPLETE,origin:b,positioned:!1,scrolling:!1,waiting:!1})},reset:(b=!1)=>{const{controlled:g}=o();if(g){jr(r.current,"tour","reset() is not supported in controlled mode");return}i.current(),e.current.updateState({action:Vt.RESET,index:0,lifecycle:et.INIT,positioned:!1,scrolling:!1,status:b?Lt.RUNNING:Lt.READY,waiting:!1})},skip:b=>{const{status:g}=o();g===Lt.RUNNING&&e.current.updateState({action:Vt.SKIP,lifecycle:et.COMPLETE,origin:b,positioned:!1,scrolling:!1,status:Lt.SKIPPED,waiting:!1})},start:b=>{const{index:g,size:k}=o();i.current(),e.current.updateState({action:Vt.START,index:Dr.number(b)?b:g,lifecycle:et.INIT,positioned:!1,scrolling:!1,status:k?Lt.RUNNING:Lt.WAITING,waiting:!1},!0)},stop:(b=!1)=>{const{index:g,status:k}=o();[Lt.FINISHED,Lt.SKIPPED].includes(k)||e.current.updateState({action:Vt.STOP,index:g+(b?1:0),lifecycle:et.COMPLETE,positioned:!1,scrolling:!1,status:Lt.PAUSED,waiting:!1})}}},[e])}const Rue=new Set(["origin","positioned"]);function Mue(e,t){const n=h.useRef(null);h.useEffect(()=>{if(!t)return;const r=e.current.getSnapshot();return jr(!0,"tour","init",r),n.current=r,e.current.subscribe(i=>{const o=n.current;if(n.current=i,!o)return;const a={};let l=!1;for(const c of Object.keys(i))i[c]!==o[c]&&!Rue.has(c)&&(a[c]={from:o[c],to:i[c]},(c==="status"||c==="size")&&(l=!0));Object.keys(a).length&&(!l&&i.index>=i.size||jr(!0,l?"tour":`step:${i.index}`,"state",a))})},[t,e])}function $ue(e,t,n){const r=h.useRef(e),i=h.useRef(t);return r.current=e,i.current=t,h.useCallback((o,a,l)=>{var u;const c={...n.current.getEventState(),error:null,scroll:null,step:a,type:o,...l};(u=r.current)==null||u.call(r,c,i.current),n.current.dispatch(c,i.current)},[n])}function Ko(e,t){return{hasChanged(n){return e[n]!==t[n]},hasChangedTo(n,r){const i=e[n],o=t[n];return Array.isArray(r)?r.includes(i)&&!r.includes(o):i===r&&o!==r},previous:t}}function Lue(e){const{addFailure:t,controls:n,emitEvent:r,previousState:i,props:o,state:a,step:l,store:c}=e,{action:u,index:f,lifecycle:p,positioned:d,scrolling:m,size:y,status:v}=a,b=P$(l)??null,g=h.useRef(null),k=h.useRef(o),x=h.useRef(a),_=h.useRef(i),j=h.useRef(l),N=h.useRef(b),P=h.useRef(n),T=h.useRef(null),z=h.useRef(null),E=h.useRef(null);k.current=o,x.current=a,_.current=i,j.current=l,N.current=b,P.current=n;const O=()=>{T.current&&(clearInterval(T.current),T.current=null),z.current=null,E.current&&(E.current.cancel(),E.current=null)};h.useEffect(()=>{if(!_.current)return;const{hasChangedTo:D}=Ko(x.current,_.current);(D("action",[Vt.NEXT,Vt.PREV,Vt.SKIP,Vt.CLOSE])||g.current===Vt.CLOSE&&u===Vt.START)&&(g.current=u)},[u]),h.useEffect(()=>{if(!_.current)return()=>{O()};const{hasChanged:D}=Ko(x.current,_.current),L=j.current;if(D("index")&&O(),v!==Lt.RUNNING||!L||p!==et.INIT)return()=>{O()};const{hasChangedTo:$}=Ko(x.current,_.current);$("status",Lt.RUNNING)&&[Lt.IDLE,Lt.READY,Lt.PAUSED].includes(_.current.status)&&r(kr.TOUR_START,L),c.current.cleanupPositionData();const{debug:V}=k.current;if(L.before&&!E.current){jr(V,`step:${f}`,"before()",L),E.current={cancel:()=>{}},c.current.updateState({waiting:!0}),r(kr.STEP_BEFORE_HOOK,L,{action:g.current??x.current.action});const W=()=>{E.current=null,c.current.updateState({action:g.current??x.current.action,waiting:!1,lifecycle:et.READY})},F=new AbortController,M=L.beforeTimeout;E.current={cancel:()=>F.abort()};const H=M?setTimeout(()=>{F.signal.aborted||(jr(V,`step:${f}`,"before()","timed out",`${M}ms`),F.abort(),t(L,"before_hook"),r(kr.ERROR,L,{error:new Error("Step before hook timed out")}),W())},M):null;L.before({...c.current.getState(),action:g.current??c.current.getState().action,step:L}).then(()=>{F.signal.aborted||(H&&clearTimeout(H),W())}).catch(A=>{F.signal.aborted||(H&&clearTimeout(H),t(L,"before_hook"),r(kr.ERROR,L,{error:A instanceof Error?A:new Error(String(A))}),W())})}else if(!E.current){T.current&&z.current!==L.target&&O();const W=Fs(L.target);if(W&&xh(W))O(),c.current.updateState({action:g.current??Vt.UPDATE,lifecycle:et.READY,waiting:!1});else if(L.targetWaitTimeout===0)c.current.updateState({action:g.current??Vt.UPDATE,lifecycle:et.READY,waiting:!1});else if(!T.current){const{targetWaitTimeout:F}=L,M=Date.now();z.current=L.target,jr(V,`step:${f}`,"polling","started",`${F}ms`),c.current.updateState({waiting:!0}),T.current=setInterval(()=>{const H=Fs(L.target),A=Date.now()-M,X=A>=F;(H&&xh(H)||X)&&(jr(V,`step:${f}`,"polling",H&&xh(H)?"found":"timed out",`${A}ms`),O(),c.current.updateState({action:g.current??Vt.UPDATE,lifecycle:et.READY,waiting:!1}))},100)}}return()=>{O()}},[t,r,f,p,v,c]),h.useEffect(()=>{if(!_.current)return;const{hasChanged:D,hasChangedTo:L,previous:$}=Ko(x.current,_.current),V=j.current;if(!V)return;const W=Fs(V.target),F=!!W;if(F&&xh(W)){if(L("lifecycle",et.READY)&&$.lifecycle===et.INIT&&r(kr.STEP_BEFORE,V,{action:g.current??x.current.action}),L("lifecycle",et.READY)){const M=x.current,H=Eue(V,M,k.current.continuous)?et.TOOLTIP:et.BEACON,A=Fs(V.scrollTarget??V.spotlightTarget??V.target),X=LA({isFirstStep:M.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:V,target:A,targetLifecycle:H}),q=H===et.TOOLTIP?et.TOOLTIP_BEFORE:et.BEACON_BEFORE;jr(k.current.debug,`step:${f}`,"scroll",X?"needed":"skipped"),c.current.updateState({action:Vt.UPDATE,lifecycle:q,scrolling:X})}}else if(x.current.status===Lt.RUNNING&&p!==et.INIT&&p!==et.COMPLETE&&D("lifecycle")){jr(k.current.debug,`step:${f}`,F?"Target not visible":"Target not mounted",V),t(V,"target_not_found"),r(kr.TARGET_NOT_FOUND,V);const M=x.current;M.controlled||c.current.updateState({action:Vt.UPDATE,index:M.index+(M.action===Vt.PREV?-1:1),lifecycle:et.INIT})}},[t,r,f,p,c]),h.useEffect(()=>{if(!_.current)return;const{hasChangedTo:D,previous:L}=Ko(x.current,_.current),$=j.current,V=N.current;if($&&D("lifecycle",et.TOOLTIP_BEFORE)&&L.lifecycle===et.BEACON){const M=Fs($.scrollTarget??$.spotlightTarget??$.target);if(LA({isFirstStep:x.current.index===0,scrollToFirstStep:k.current.scrollToFirstStep,step:$,target:M,targetLifecycle:et.TOOLTIP})){c.current.updateState({scrolling:!0,positioned:!1});return}}const W=p===et.BEACON_BEFORE||p===et.TOOLTIP_BEFORE;if($&&W&&!m){const M=p===et.TOOLTIP_BEFORE?et.TOOLTIP:et.BEACON;c.current.updateState({action:Vt.UPDATE,lifecycle:M})}$&&D("lifecycle",et.BEACON)&&r(kr.BEACON,$),$&&D("lifecycle",et.TOOLTIP)&&r(kr.TOOLTIP,$);const F=x.current;if((F.status===Lt.RUNNING||F.controlled&&F.status===Lt.PAUSED&&$)&&V&&D("lifecycle",et.COMPLETE)&&L.lifecycle===et.TOOLTIP&&(r(kr.STEP_AFTER,V,{action:g.current??Vt.UPDATE,index:L.index??F.index,lifecycle:F.lifecycle}),V.after)){r(kr.STEP_AFTER_HOOK,V,{action:g.current??Vt.UPDATE,index:L.index??F.index,lifecycle:F.lifecycle});try{V.after({...c.current.getState(),action:g.current??Vt.UPDATE,index:L.index??F.index,lifecycle:F.lifecycle,step:V})}catch{}}},[r,p,d,m,c]),h.useEffect(()=>{if(!_.current)return;const{hasChangedTo:D,previous:L}=Ko(x.current,_.current),$=j.current,V=N.current;y&&!$&&p===et.INIT&&c.current.updateState({action:Vt.UPDATE,lifecycle:et.COMPLETE,status:Lt.FINISHED}),!x.current.controlled&&v===Lt.RUNNING&&D("lifecycle",et.COMPLETE)&&f<y&&c.current.updateState({action:Vt.UPDATE,lifecycle:et.INIT}),D("lifecycle",et.COMPLETE)&&f>=y&&c.current.updateState({action:Vt.UPDATE,lifecycle:et.COMPLETE,status:Lt.FINISHED});const W=$??V??dS(k.current,k.current.steps[f-1]);if(W&&D("status",[Lt.FINISHED,Lt.SKIPPED])){let F;$?F=f:V?F=L.index??f:F=f-1,r(kr.TOUR_END,W,{index:F}),x.current.controlled||P.current.reset(),g.current=null}$&&D("action",Vt.STOP)&&(g.current=null,r(kr.TOUR_STATUS,$)),$&&D("action",Vt.RESET)&&(r(kr.TOUR_STATUS,$),g.current=null)},[u,r,f,p,y,v,c])}function Oue({controls:e,emitEvent:t,props:n,state:r,store:i}){const{debug:o,initialStepIndex:a,run:l,stepIndex:c,steps:u}=n,f=h.useRef(void 0),p=h.useRef(r),d=h.useRef(e);p.current=r,d.current=e,h.useEffect(()=>{const m=f.current;if(f.current=n,!m||n===m)return;const{hasChanged:y}=Ko(n,m);if(eS(m.steps,u)||(rL(u,o)?i.current.setSteps(u):(jr(o,"tour","Steps are not valid",u),t(kr.ERROR,u[0]??{target:"",content:""},{error:new Error("Steps are not valid")}))),y("run"))l?i.current.getState().size&&d.current.start(c??a):d.current.stop();else if(Dr.number(c)&&y("stepIndex")){const v=Dr.number(m.stepIndex)&&m.stepIndex<c?Vt.NEXT:Vt.PREV;[Lt.FINISHED,Lt.SKIPPED].includes(p.current.status)||i.current.updateState({action:v,index:c,lifecycle:et.INIT,positioned:!1},!0)}},[o,t,a,n,l,c,u,i])}function Due(e,t){var l,c,u,f;const{beaconPosition:n,lifecycle:r,scrollOffset:i,step:o}=t;if(o.scrollTarget||o.spotlightTarget)return Math.max(0,e);let a=e-o.spotlightPadding.top;if(r===et.BEACON_BEFORE&&(n!=null&&n.placement)){const p=Fue(n);["bottom"].includes(n.placement)||(a+=Math.floor(p-i))}else if(r===et.TOOLTIP_BEFORE){const{placement:p}=o;if(p==="top"){const d=((l=document.querySelector(".react-joyride__floater"))==null?void 0:l.getBoundingClientRect().height)??0,m=(c=o.floatingOptions)!=null&&c.hideArrow?0:o.arrowSize,y=o.offset+o.spotlightPadding.top+m;a-=d+y}else if(p==="left"||p==="right"){const d=((u=document.querySelector(".react-joyride__floater"))==null?void 0:u.getBoundingClientRect().height)??0,m=((f=Fs(o.target))==null?void 0:f.getBoundingClientRect().height)??0,y=i+o.spotlightPadding.top+m/2-d/2;y<i&&(a-=i-y)}}return Math.max(0,a)}function Fue(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 zue({emitEvent:e,previousState:t,props:n,state:r,step:i,store:o}){const{index:a,lifecycle:l,positioned:c,scrolling:u,status:f}=r,p=h.useRef(null),d=h.useRef(r),m=h.useRef(t),y=h.useRef(n),v=h.useRef(i);d.current=r,m.current=t,y.current=n,v.current=i,h.useEffect(()=>()=>{var b;(b=p.current)==null||b.call(p)},[]),h.useEffect(()=>{var j;if(!m.current||!v.current)return;const{hasChangedTo:b}=Ko(d.current,m.current),g=v.current,{debug:k}=y.current,{scrollDuration:x}=g,_=l===et.BEACON_BEFORE||l===et.TOOLTIP_BEFORE;if(f===Lt.RUNNING&&_&&u&&b("positioned",!0)){const N=Fs(g.scrollTarget??g.spotlightTarget??g.target),P=o.current.getPositionData("beacon"),T=du(N),z=T?!T.isSameNode(is()):!1;(j=p.current)==null||j.call(p),(async()=>{if(z&&!fu(T)){const F=is(),M=vue(T),H={initial:F.scrollTop,target:M,element:F,duration:x};e(kr.SCROLL_START,g,{scroll:H});const{cancel:A,promise:X}=OA(M,{element:F,duration:x});p.current=A,await X,e(kr.SCROLL_END,g,{scroll:H})}const O=Math.floor(Sue(N,g.scrollOffset))||0,D=z?O:Due(O,{beaconPosition:P,lifecycle:l,scrollOffset:g.scrollOffset,step:g});jr(k,`step:${a}`,"scroll",z?"custom":"document",`${O} → ${D}`);const L=T,$={initial:L.scrollTop,target:D,element:L,duration:x};e(kr.SCROLL_START,g,{scroll:$});const{cancel:V,promise:W}=OA(D,{element:L,duration:x});p.current=V,await W,e(kr.SCROLL_END,g,{scroll:$}),o.current.updateState({scrolling:!1})})().catch(()=>{o.current.updateState({scrolling:!1})})}},[e,a,l,c,u,f,o])}function Bue(e){const t=Sle(()=>wue(mue,e),[e]),{debug:n,initialStepIndex:r,onEvent:i,run:o,stepIndex:a,steps:l}=t,c=h.useRef(Pue(t)),u=TT.useSyncExternalStore(c.current.subscribe,c.current.getSnapshot,c.current.getServerSnapshot),[f,p]=h.useState([]),d=h.useCallback((j,N)=>{p(P=>[...P,{reason:N,step:j}])},[]),m=h.useCallback(()=>{p([])},[]);Mue(c,n);const y=Tue(c,n,m),v=$ue(i,y,c),{index:b,size:g,status:k}=u,x=P$(u),_=h.useMemo(()=>dS(t,l[b]),[b,t,l]);return jle(()=>{o&&g&&rL(l,n)&&y.start(a??r)}),vle(()=>{o&&g&&k===Lt.IDLE&&c.current.updateState({status:Lt.READY})},[o,g,k]),Oue({controls:y,emitEvent:v,props:t,state:u,store:c}),Lue({addFailure:d,controls:y,emitEvent:v,previousState:x,props:t,state:u,step:_,store:c}),zue({emitEvent:v,previousState:x,props:t,state:u,step:_,store:c}),{controls:y,failures:f,mergedProps:t,state:u,step:_,store:c}}function Wue(e){const[t,n]=h.useState(null);return h.useEffect(()=>{let r=null,i=!1;if(e)if(Dr.domElement(e))r=e,i=!0;else{const o=document.querySelector(e);o&&(r=o)}else{const o=document.createElement("div");o.id=gue,document.body.appendChild(o),r=o}return n(r),()=>{!r||i||r.parentNode===document.body&&document.body.removeChild(r)}},[e]),t}const Hue={animation:"joyride-loader-spin 1s linear infinite",border:"5px solid rgba(0, 0, 0, 0.1)",borderRadius:"50%",borderTopColor:"#555"};function Vue({nonce:e,step:t}){const{loaderComponent:n}=t,r=!!n;if(h.useEffect(()=>{if(r||document.getElementById("joyride-loader-animation"))return Cf;const c=document.createElement("style");return c.id="joyride-loader-animation",e&&c.setAttribute("nonce",e),c.appendChild(document.createTextNode(`
|
|
561
|
+
@keyframes joyride-loader-spin {
|
|
562
|
+
to { transform: rotate(360deg); }
|
|
563
|
+
}
|
|
564
|
+
`)),document.head.appendChild(c),()=>{const u=document.getElementById("joyride-loader-animation");u!=null&&u.parentNode&&u.parentNode.removeChild(u)}},[r,e]),n===null)return null;const{height:i,width:o,...a}=t.styles.loader;let l;if(n){const c=n;l=ft.createElement(c,{step:t})}else l=ft.createElement("div",{style:{...Hue,height:i,width:o,borderTopColor:t.primaryColor}});return ft.createElement("div",{className:"react-joyride__loader","data-testid":"loader",style:a},l)}const Kue={height:0,isFixed:!1,left:0,top:0,width:0};function ad(e,t){const n=Fs(e);if(!n)return Kue;const r=uS(n),i=fu(n),o=kue(n,t.top,i);return{height:Math.round(((r==null?void 0:r.height)??0)+t.top+t.bottom),isFixed:i,left:Math.round(((r==null?void 0:r.left)??0)-t.left),top:o,width:Math.round(((r==null?void 0:r.width)??0)+t.left+t.right)}}function que(e,t,n){const[r,i]=h.useState(()=>ad(e,t)),o=h.useRef(void 0),a=h.useRef(null),l=h.useRef(n),c=h.useRef(null),u=h.useCallback(()=>{clearTimeout(o.current),o.current=window.setTimeout(()=>{i(p=>{const d=ad(e,t);return p.top===d.top&&p.left===d.left&&p.width===d.width&&p.height===d.height&&p.isFixed===d.isFixed?p:d})},100)},[e,t]);h.useEffect(()=>{let p=null;const d=y=>{a.current=du(y,!0),a.current&&a.current.addEventListener("scroll",u,{passive:!0}),window.addEventListener("scroll",u,{passive:!0}),window.addEventListener("resize",u),typeof ResizeObserver<"u"&&(c.current=new ResizeObserver(u),c.current.observe(y)),i(ad(e,t))},m=Fs(e);return m?d(m):(p=new MutationObserver(()=>{const y=Fs(e);y&&(p==null||p.disconnect(),p=null,d(y))}),p.observe(document.body,{childList:!0,subtree:!0})),()=>{var y;p==null||p.disconnect(),a.current&&a.current.removeEventListener("scroll",u),window.removeEventListener("scroll",u),window.removeEventListener("resize",u),(y=c.current)==null||y.disconnect(),clearTimeout(o.current)}},[e,t,u]),h.useEffect(()=>{l.current&&!n&&i(ad(e,t)),l.current=n},[n,e,t]);let f=r;return l.current&&!n&&(f=ad(e,t)),f}function Uue(e,t,n){let r=`M0 0H${e}V${t}H0Z`;return n&&(r+=` ${n}`),r}function FA(e,t,n,r,i){if(n<=0||r<=0)return"";const o=Math.max(0,Math.min(i,n/2,r/2));let a=`M${e+o} ${t}`;return a+=`H${e+n-o}`,a+=`A${o} ${o} 0 0 1 ${e+n} ${t+o}`,a+=`V${t+r-o}`,a+=`A${o} ${o} 0 0 1 ${e+n-o} ${t+r}`,a+=`H${e+o}`,a+=`A${o} ${o} 0 0 1 ${e} ${t+r-o}`,a+=`V${t+o}`,a+=`A${o} ${o} 0 0 1 ${e+o} ${t}Z`,a}const Gue=[et.BEACON_BEFORE,et.BEACON];function Yue(e){var W,F;const{blockTargetInteraction:t,continuous:n,hideOverlay:r,lifecycle:i,onClickOverlay:o,overlayClickAction:a,placement:l,portalElement:c,scrolling:u,spotlightPadding:f,spotlightRadius:p,spotlightTarget:d,styles:m,target:y,waiting:v}=e,b=Nle(),g=que(d??y,f,u||v),k=h.useRef(null),x=(i===et.TOOLTIP||i===et.TOOLTIP_BEFORE)&&l!=="center",[_,j]=h.useState(!1),N=c?(W=k.current)==null?void 0:W.offsetParent:null,P=(N==null?void 0:N.clientWidth)??b.width,T=(N==null?void 0:N.clientHeight)??bue()??b.height,z=((F=m.overlay)==null?void 0:F.backgroundColor)??"rgba(0, 0, 0, 0.5)",E=h.useMemo(()=>{const{backgroundColor:M,mixBlendMode:H,...A}=m.overlay;return{height:T,pointerEvents:"none",...A}},[T,m.overlay]),O=x&&!u&&!v;h.useEffect(()=>{O?requestAnimationFrame(()=>j(!0)):j(!1)},[O]);const D=n&&Gue.includes(i),L=!n&&i!==et.TOOLTIP;if(r||!v&&(D||L))return null;let $="";if(O)if(c&&N){const M=Fs(d??y);if(M){const H=$A(M),A=$A(N);$=FA(H.left-A.left-f.left,H.top-A.top-f.top,M.offsetWidth+f.left+f.right,M.offsetHeight+f.top+f.bottom,p)}}else $=FA(g.left,g.top,g.width,g.height,p);const V=Uue(P,T,$);return ft.createElement("div",{ref:k,"aria-hidden":"true",className:"react-joyride__overlay","data-testid":"overlay",style:E},ft.createElement("svg",{className:"react-joyride__spotlight","data-testid":"spotlight",style:{height:T,left:0,position:g.isFixed?"fixed":"absolute",top:0,width:P}},ft.createElement("path",{d:V,fill:z,fillRule:"evenodd",onClick:o,style:{cursor:a?"pointer":"default",pointerEvents:"auto"}}),$&&ft.createElement("path",{d:$,fill:z,style:{opacity:_?0:1,pointerEvents:t?"auto":"none",transition:"opacity 0.2s"}}),$&&Object.keys(m.spotlight).length>0&&ft.createElement("path",{d:$,fill:"none",style:{pointerEvents:"none"},...m.spotlight})))}function sL(e){const{children:t,element:n}=e;return n?er.createPortal(t,n):null}const Jue='a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), area[href], [tabindex]:not([tabindex="-1"]), [contenteditable]';function Xue(e,t){const n=h.useRef(null);h.useEffect(()=>{if(!e)return Cf;n.current=document.activeElement;const r=o=>{if(o.key!=="Tab")return;const a=[...e.querySelectorAll(Jue)],{shiftKey:l}=o;if(!a.length)return;o.preventDefault();let c=document.activeElement?a.indexOf(document.activeElement):0;c===-1||!l&&c+1===a.length?c=0:l&&c===0?c=a.length-1:c+=l?-1:1,a[c].focus()};e.addEventListener("keydown",r,!1);let i;{const o=e.querySelector(t);o&&(i=setTimeout(()=>{o.focus({preventScroll:!0})},100))}return()=>{var o;e.removeEventListener("keydown",r),i!==void 0&&clearTimeout(i),(o=n.current)==null||o.focus({preventScroll:!0})}},[e,t])}function ao(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 Que(e,t,n){const[r]=e.split("-");switch(r){case"top":return{points:`0,0 ${t/2},${n} ${t},0`,...ao(e,t,n)};case"bottom":return{points:`${t},${n} ${t/2},0 0,${n}`,...ao(e,t,n)};case"left":return{points:`0,0 ${n},${t/2} 0,${t}`,...ao(e,t,n)};case"right":return{points:`${n},${t} ${n},0 0,${t/2}`,...ao(e,t,n)};default:return null}}function Zue(e,t,n,r){if(!t)return{};const[i]=e.split("-");switch(i){case"top":return{bottom:-n,left:t.x??0,...ao(e,r,n)};case"bottom":return{top:-n,left:t.x??0,...ao(e,r,n)};case"left":return{right:-n,top:t.y??0,...ao(e,r,n)};case"right":return{left:-n,top:t.y??0,...ao(e,r,n)};default:return{}}}function ede({arrowComponent:e,arrowRef:t,base:n,placement:r,position:i,size:o,styles:a}){const l=e;let c=null;if(l){if(!ao(r,n,o))return null;c=ft.createElement("span",{style:{flexShrink:0}},ft.createElement(l,{base:n,placement:r,size:o}))}else{const u=Que(r,n,o);if(!u)return null;c=ft.createElement("svg",{height:u.height,width:u.width,xmlns:"http://www.w3.org/2000/svg"},ft.createElement("polygon",{fill:"currentColor",points:u.points}))}return ft.createElement("span",{ref:t,className:"react-joyride__arrow","data-testid":"arrow",style:{...a,...Zue(r,i,o,n),...i?{}:{visibility:"hidden"}}},c)}function tde(e){const{beaconComponent:t,continuous:n,index:r,isLastStep:i,locale:o,nonce:a,onInteract:l,shouldFocus:c,size:u,step:f,styles:p}=e,d=h.useRef(null),m=!!t;h.useEffect(()=>{if(m||document.getElementById("joyride-beacon-animation"))return Cf;const b=document.createElement("style");b.id="joyride-beacon-animation",a&&b.setAttribute("nonce",a),b.appendChild(document.createTextNode(`
|
|
565
|
+
@keyframes joyride-beacon-inner {
|
|
566
|
+
20% {
|
|
567
|
+
opacity: 0.9;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
90% {
|
|
571
|
+
opacity: 0.7;
|
|
572
|
+
}
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
@keyframes joyride-beacon-outer {
|
|
576
|
+
0% {
|
|
577
|
+
transform: scale(1);
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
45% {
|
|
581
|
+
opacity: 0.7;
|
|
582
|
+
transform: scale(0.75);
|
|
583
|
+
}
|
|
584
|
+
|
|
585
|
+
100% {
|
|
586
|
+
opacity: 0.9;
|
|
587
|
+
transform: scale(1);
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
`)),document.head.appendChild(b);const g=setTimeout(()=>{Dr.domElement(d.current)&&c&&d.current.focus()},0);return()=>{clearTimeout(g);const k=document.getElementById("joyride-beacon-animation");k!=null&&k.parentNode&&k.parentNode.removeChild(k)}},[m,a,c]);const y=no(o.open);let v;if(t){const b=t;v=ft.createElement(b,{continuous:n,index:r,isLastStep:i,size:u,step:f})}else v=ft.createElement("span",{style:p.beacon},ft.createElement("span",{style:p.beaconOuter}),ft.createElement("span",{style:p.beaconInner}));return ft.createElement("button",{ref:d,"aria-label":y,className:"react-joyride__beacon","data-testid":"button-beacon",onClick:l,onMouseEnter:l,style:p.beaconWrapper,title:y,type:"button"},v)}function nde({styles:e,...t}){const{color:n,height:r,width:i,...o}=e;return ft.createElement("button",{style:o,type:"button",...t},ft.createElement("svg",{height:typeof r=="number"?`${r}px`:r,preserveAspectRatio:"xMidYMid",version:"1.1",viewBox:"0 0 18 18",width:typeof i=="number"?`${i}px`:i,xmlns:"http://www.w3.org/2000/svg"},ft.createElement("g",null,ft.createElement("path",{d:"M8.13911129,9.00268191 L0.171521827,17.0258467 C-0.0498027049,17.248715 -0.0498027049,17.6098394 0.171521827,17.8327545 C0.28204354,17.9443526 0.427188206,17.9998706 0.572051765,17.9998706 C0.71714958,17.9998706 0.862013139,17.9443526 0.972581703,17.8327545 L9.0000937,9.74924618 L17.0276057,17.8327545 C17.1384085,17.9443526 17.2832721,17.9998706 17.4281356,17.9998706 C17.5729992,17.9998706 17.718097,17.9443526 17.8286656,17.8327545 C18.0499901,17.6098862 18.0499901,17.2487618 17.8286656,17.0258467 L9.86135722,9.00268191 L17.8340066,0.973848225 C18.0553311,0.750979934 18.0553311,0.389855532 17.8340066,0.16694039 C17.6126821,-0.0556467968 17.254037,-0.0556467968 17.0329467,0.16694039 L9.00042166,8.25611765 L0.967006424,0.167268345 C0.745681892,-0.0553188426 0.387317931,-0.0553188426 0.165993399,0.167268345 C-0.0553311331,0.390136635 -0.0553311331,0.751261038 0.165993399,0.974176179 L8.13920499,9.00268191 L8.13911129,9.00268191 Z",fill:n}))))}function rde(e){const{backProps:t,closeProps:n,index:r,isLastStep:i,primaryProps:o,skipProps:a,step:l,tooltipProps:c}=e,{buttons:u,content:f,styles:p,title:d}=l,m={};u.includes("primary")&&(m.primary=ft.createElement("button",{"data-testid":"button-primary",style:p.buttonPrimary,type:"button",...o})),u.includes("skip")&&!i&&(m.skip=ft.createElement("button",{"aria-live":"off","data-testid":"button-skip",style:p.buttonSkip,type:"button",...a})),u.includes("back")&&r>0&&(m.back=ft.createElement("button",{"data-testid":"button-back",style:p.buttonBack,type:"button",...t})),m.close=u.includes("close")&&ft.createElement(nde,{"data-testid":"button-close",styles:p.buttonClose,...n});const y=d?{"aria-labelledby":"joyride-tooltip-title","aria-describedby":"joyride-tooltip-content"}:{"aria-label":no(f),"aria-describedby":"joyride-tooltip-content"};return ft.createElement("div",{key:"JoyrideTooltip",className:"react-joyride__tooltip","data-joyride-step":r,...l.id&&{"data-joyride-id":l.id},style:p.tooltip,...c,...y},ft.createElement("div",{style:p.tooltipContainer},d&&ft.createElement("h4",{id:"joyride-tooltip-title",style:p.tooltipTitle},d),ft.createElement("div",{id:"joyride-tooltip-content",style:p.tooltipContent},f)),u.some(v=>v==="back"||v==="primary"||v==="skip")&&ft.createElement("div",{style:p.tooltipFooter},ft.createElement("div",{style:p.tooltipFooterSpacer},m.skip),m.back,m.primary),m.close)}function sde(e){const{continuous:t,controls:n,index:r,isLastStep:i,size:o,step:a}=e,l=g=>{g.preventDefault(),n.prev(Ci.BUTTON_BACK)},c=g=>{g.preventDefault(),a.closeButtonAction==="skip"?n.skip(Ci.BUTTON_CLOSE):n.close(Ci.BUTTON_CLOSE)},u=g=>{if(g.preventDefault(),!t){n.close(Ci.BUTTON_PRIMARY);return}n.next(Ci.BUTTON_PRIMARY)},f=g=>{g.preventDefault(),n.skip(Ci.BUTTON_SKIP)},p=()=>{const{back:g,close:k,last:x,next:_,nextWithProgress:j,skip:N}=a.locale,P=no(g),T=no(k),z=no(x),E=no(_),O=no(N);let D=k,L=T;if(t){if(D=_,L=E,a.showProgress&&!i){const $=no(j,{step:r+1,steps:o});D=ok(j,r+1,o),L=$}i&&(D=x,L=z)}return{backProps:{"aria-label":P,children:g,"data-action":"back",onClick:l,role:"button",title:P},closeProps:{"aria-label":T,children:k,"data-action":"close",onClick:c,role:"button",title:T},primaryProps:{"aria-label":L,children:D,"data-action":"primary",onClick:u,role:"button",title:L},skipProps:{"aria-label":O,children:N,"data-action":"skip",onClick:f,role:"button",title:O},tooltipProps:{"aria-modal":!0,role:"alertdialog"}}},{arrowComponent:d,beaconComponent:m,tooltipComponent:y,...v}=a;let b;if(y){const g=y;b=ft.createElement(g,{...p(),continuous:t,controls:n,index:r,isLastStep:i,size:o,step:v})}else b=ft.createElement(rde,{...p(),continuous:t,controls:n,index:r,isLastStep:i,size:o,step:v});return b}function ide(e){if(e.startsWith("left"))return["top","bottom"];if(e.startsWith("right"))return["bottom","top"]}function ode(e,t,n){var r,i;return e?[uue()]:((r=t.floatingOptions)==null?void 0:r.flipOptions)===!1?[]:[cue({crossAxis:!1,fallbackPlacements:ide(n),padding:20,...(i=t.floatingOptions)==null?void 0:i.flipOptions})]}function ade(e){var H,A,X,q,B;const{continuous:t,controls:n,index:r,lifecycle:i,nonce:o,open:a,portalElement:l,setPositionData:c,setTooltipRef:u,shouldScroll:f,size:p,step:d,target:m,updateState:y}=e,v=h.useRef(null),b=h.useRef({}),g=h.useRef({}),k=d.placement==="center",x=d.placement==="auto",_=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})}),[]),j=h.useMemo(()=>eL(m)?du(m):void 0,[m]),N=h.useMemo(()=>fu(m),[m]),P=h.useMemo(()=>j?{boundary:j,rootBoundary:"viewport"}:{},[j]),T=k||x?"bottom":d.placement,z=k?"fixed":((H=d.floatingOptions)==null?void 0:H.strategy)??(d.isFixed||N?"fixed":"absolute"),E=h.useMemo(()=>{var ne,ce,K,ee;return k?[{name:"center",fn:({rects:re})=>({x:(window.innerWidth-re.floating.width)/2,y:(window.innerHeight-re.floating.height)/2})}]:[TA(({placement:re})=>{var le;let se="right";re.startsWith("top")?se="top":re.startsWith("bottom")?se="bottom":re.startsWith("left")&&(se="left");const Q=d.spotlightTarget?0:d.spotlightPadding[se];return d.offset+Q+((le=d.floatingOptions)!=null&&le.hideArrow?0:d.arrowSize)},[d.offset,d.spotlightPadding,d.spotlightTarget,d.arrowSize,(ne=d.floatingOptions)==null?void 0:ne.hideArrow]),...ode(x,d,T),lue({padding:10,...P,...(ce=d.floatingOptions)==null?void 0:ce.shiftOptions}),...(K=d.floatingOptions)!=null&&K.hideArrow?[]:[due({element:v,padding:d.arrowSpacing},[d.arrowSpacing,d.arrowBase])],...((ee=d.floatingOptions)==null?void 0:ee.middleware)??[]]},[k,d,x,T,P]),O=PA({...k?{elements:{reference:_}}:{},placement:T,strategy:z,middleware:E}),D=PA({strategy:z,placement:d.beaconPlacement??(x||k?"bottom":d.placement),middleware:h.useMemo(()=>{var ne,ce;return[TA(((ce=(ne=d.floatingOptions)==null?void 0:ne.beaconOptions)==null?void 0:ce.offset)??-18)]},[(X=(A=d.floatingOptions)==null?void 0:A.beaconOptions)==null?void 0:X.offset]),whileElementsMounted:AA});g.current=O.middlewareData,b.current=D.middlewareData,h.useEffect(()=>{var K;const{floating:ne,reference:ce}=O.elements;if(!(!ce||!ne||i!==et.TOOLTIP))return AA(ce,ne,O.update,(K=d.floatingOptions)==null?void 0:K.autoUpdate)},[i,O.update,(q=d.floatingOptions)==null?void 0:q.autoUpdate,d.target,O.elements]),h.useEffect(()=>{!k&&m&&O.refs.setReference(m),m&&D.refs.setReference(m)},[D.refs,k,m,O.refs]),h.useEffect(()=>{O.isPositioned&&c("tooltip",{placement:O.placement,x:O.x??0,y:O.y??0,middlewareData:g.current})},[c,O.isPositioned,O.placement,O.x,O.y]),h.useEffect(()=>{D.isPositioned&&c("beacon",{placement:D.placement,x:D.x??0,y:D.y??0,middlewareData:b.current})},[c,D.isPositioned,D.placement,D.x,D.y]);const L=d.zIndex+100,$=h.useCallback(ne=>{ne.type==="mouseenter"&&d.beaconTrigger!=="hover"||y({lifecycle:et.TOOLTIP_BEFORE,positioned:!1})},[d.beaconTrigger,y]),V=h.useCallback(ne=>{ne&&(O.refs.setFloating(ne),u(ne))},[O.refs,u]),{arrow:W,floater:F}=d.styles;let M=null;if(i===et.TOOLTIP||i===et.TOOLTIP_BEFORE){const ne=MA({...F,...O.floatingStyles,zIndex:L,opacity:a&&O.isPositioned?1:0,...!a&&{transition:"none"}});M=ft.createElement("div",{ref:V,className:"react-joyride__floater","data-testid":"floater",id:`react-joyride-step-${r}`,style:ne},ft.createElement(sde,{continuous:t,controls:n,index:r,isLastStep:r+1===p,size:p,step:d}),!k&&!((B=d.floatingOptions)!=null&&B.hideArrow)&&ft.createElement(ede,{arrowComponent:d.arrowComponent,arrowRef:v,base:d.arrowBase,placement:O.placement,position:O.middlewareData.arrow,size:d.arrowSize,styles:W}))}else(i===et.BEACON||i===et.BEACON_BEFORE)&&(M=ft.createElement("div",{ref:D.refs.setFloating,className:"react-joyride__floater","data-testid":"floater-beacon",id:`react-joyride-step-${r}-beacon`,style:MA({...D.floatingStyles,zIndex:L})},ft.createElement(tde,{beaconComponent:d.beaconComponent,continuous:t,index:r,isLastStep:r+1===p,locale:d.locale,nonce:o,onInteract:$,shouldFocus:f,size:p,step:d,styles:d.styles})));return ft.createElement(sL,{element:l},M)}function lde(e){const{continuous:t,controls:n,index:r,lifecycle:i,nonce:o,portalElement:a,setPositionData:l,shouldScroll:c,size:u,step:f,updateState:p}=e,[d,m]=h.useState(null);Xue(f.disableFocusTrap?null:d,"[data-action=primary]");const y=Fs(f.target),v=i===et.TOOLTIP;return!nL(f)||!Dr.domElement(y)?null:ft.createElement(ade,{key:`JoyrideStep-${r}`,continuous:t,controls:n,index:r,lifecycle:i,nonce:o,open:v,portalElement:a,setPositionData:l,setTooltipRef:m,shouldScroll:c,size:u,step:f,target:y,updateState:p})}function cde({controls:e,mergedProps:t,state:n,step:r,store:i}){const{continuous:o,debug:a,nonce:l,portalElement:c,scrollToFirstStep:u}=t,f=Wue(c),{index:p,lifecycle:d,status:m}=n,y=m===Lt.RUNNING,[v,b]=h.useState(!1),g=h.useRef(null),k=(r==null?void 0:r.loaderDelay)??0;h.useEffect(()=>(n.waiting?k===0?b(!0):g.current=setTimeout(()=>{b(!0)},k):b(!1),()=>{g.current&&(clearTimeout(g.current),g.current=null)}),[k,n.waiting]),h.useEffect(()=>{if(!y)return;const j=N=>{!r||d!==et.TOOLTIP||N.key==="Escape"&&r.dismissKeyAction&&(r.dismissKeyAction==="next"?e.next(Ci.KEYBOARD):e.close(Ci.KEYBOARD))};return document.body.addEventListener("keydown",j,{passive:!0}),()=>{document.body.removeEventListener("keydown",j)}},[e,y,d,r]);const x=h.useCallback(()=>{(r==null?void 0:r.overlayClickAction)==="close"?e.close(Ci.OVERLAY):(r==null?void 0:r.overlayClickAction)==="next"&&e.next(Ci.OVERLAY)},[e,r==null?void 0:r.overlayClickAction]);if(!r||!y)return null;const _=n.action===Vt.START&&!r.skipBeacon&&r.placement!=="center";return ft.createElement(ft.Fragment,null,d!==et.INIT&&ft.createElement(lde,{...n,continuous:o,controls:e,debug:a,nonce:l,portalElement:f,setPositionData:i.current.setPositionData,shouldScroll:!r.skipScroll&&(p!==0||u),step:r,updateState:i.current.updateState}),ft.createElement(sL,{element:f},ft.createElement(ft.Fragment,null,v&&ft.createElement(Vue,{nonce:l,step:r}),!_&&ft.createElement(Yue,{...r,continuous:o,lifecycle:d,onClickOverlay:x,portalElement:c?f:null,scrolling:n.scrolling,waiting:n.waiting}))))}function ude(e){const{controls:t,failures:n,mergedProps:r,state:i,step:o,store:a}=Bue(e);return{controls:t,failures:n,on:h.useCallback((l,c)=>a.current.on(l,c),[a]),state:h.useMemo(()=>tg(i,"positioned"),[i]),step:o,Tour:cS()?ft.createElement(cde,{controls:t,mergedProps:r,state:i,step:o,store:a}):null}}function dde(e){const{Tour:t}=ude(e);return t}function fde(e){return cS()?ft.createElement(dde,e):null}function pde(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 hde(e){return[{target:"body",content:e("onboarding:flow.intro"),disableBeacon:!0,placement:"center"}]}function mde(e){return[{target:"body",content:e("onboarding:flow.introEmpty"),disableBeacon:!0,placement:"center"}]}const kh="af:onboarding";function gde({page:e,hasNodes:t=!1}){const{t:n}=zr(),[r,i]=h.useState(!1),[o,a]=h.useState([]),l=h.useRef(null),c=h.useMemo(()=>e==="projects"?pde(n):t?hde(n):mde(n),[e,t,n]);return h.useEffect(()=>{const u=localStorage.getItem(kh),f=u?JSON.parse(u):{};if(f.completed||f[e]){i(!1),a([]);return}localStorage.setItem(kh,JSON.stringify({...f,[e]:!0})),a(c),i(!0)},[e,t,c]),h.useEffect(()=>{if(!r)return;const u=f=>{var y;const p=f.target.closest("button");if(!p||!p.closest(".react-joyride__tooltip"))return;const m=(y=p.textContent)==null?void 0:y.trim();if(m===n("onboarding:done")||m===n("onboarding:startCreate")||m===n("onboarding:skip")){const v=localStorage.getItem(kh)||"{}",b=JSON.parse(v);m===n("onboarding:skip")?(b.projects=!0,b.flow=!0,b.completed=!0):b[e]=!0,localStorage.setItem(kh,JSON.stringify(b)),a([]),i(!1),e==="projects"&&(m===n("onboarding:done")||m===n("onboarding:startCreate"))&&(localStorage.setItem("af:newPipelineGuide","true"),setTimeout(()=>{const g=document.querySelector(".af-create-btn");g&&g.click()},500))}};return document.addEventListener("click",u,!0),()=>document.removeEventListener("click",u,!0)},[r,e,n]),!r||o.length===0?null:s.jsx(fde,{ref:l,steps:o,run:r,continuous:!0,showSkipButton:!0,showProgress:o.length>1,styles:{options:{primaryColor:"#7c4dff",textColor:"#ffffff",backgroundColor:"#1a1a1a",arrowColor:"#1a1a1a",overlayColor:"rgba(0, 0, 0, 0.4)",zIndex:1e4},tooltip:{borderRadius:"1.5rem",padding:"1.5rem"},buttonNext:{borderRadius:"9999px",padding:"0.625rem 1.5rem"},buttonSkip:{borderRadius:"9999px",color:"#9ecaff"},buttonClose:{display:"none"}},locale:{back:n("onboarding:back"),next:n("onboarding:next"),skip:n("onboarding:skip"),last:n(e==="projects"?"onboarding:startCreate":"onboarding:done")},floaterProps:{disableAnimation:!0},scrollToFirstStep:!0})}const yde="agentflow:recent-runs:v1",wde="agentflow:recent-runs:poller",xde=3e3,bde=8e3,kde=2e3,zA=5e3,vde=16e3,BA=[1e4,3e4,6e4];function Sde(e){return BA[Math.min(Math.max(e-1,0),BA.length-1)]}function jde(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2)}`}function Nde(e){if(!e)return"暂无成功记录";try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return"暂无成功记录"}}function _de(){const{navigate:e,path:t}=us(),[n,r]=h.useState([]),[i,o]=h.useState(!1),[a,l]=h.useState(1),[c,u]=h.useState({status:"idle",failureCount:0,lastSuccessAt:0,message:""}),f=h.useRef(()=>{});h.useEffect(()=>{let _=!1,j=!1,N=!1,P=null,T=0,z=0,E=0,O=0,D=null,L=0,$=0;const V=jde(),W=new Map,F=typeof BroadcastChannel=="function"?new BroadcastChannel(yde):null,M=Ce=>{try{F==null||F.postMessage({...Ce,tabId:V,sentAt:Date.now()})}catch{}},H=()=>{const Ce=Date.now()-vde;for(const[Se,Ue]of W)Ue<Ce&&W.delete(Se);l(1+W.size)},A=(Ce="presence")=>{M({type:Ce,visible:!document.hidden})},X=Ce=>{if(!_&&(Array.isArray(Ce.runs)&&r(Ce.runs),Ce.syncHealth&&typeof Ce.syncHealth=="object")){const Se=Ce.syncHealth;L=Number(Se.failureCount)||0,$=Number(Se.lastSuccessAt)||0,u(Se)}},q=Ce=>{X(Ce),M({type:"state",...Ce})},B=()=>{T&&(window.clearTimeout(T),T=0)},ne=Ce=>{B(),!(_||!j||document.hidden)&&(T=window.setTimeout(()=>{T=0,ce()},Math.max(0,Ce)))},ce=async()=>{if(_||!j||document.hidden||D)return;const Ce=new AbortController;D=Ce;let Se=!1;const Ue=window.setTimeout(()=>{Se=!0,Ce.abort()},bde);try{const lt=await fetch("/api/pipeline-recent-runs",{signal:Ce.signal});if(!lt.ok)throw new Error(`HTTP ${lt.status}`);const xt=await lt.json();if(_||!j||document.hidden)return;L=0,$=Date.now();const at=Array.isArray(xt.runs)?xt.runs:[];q({runs:at.filter(ze=>ze&&ze.status==="running"),syncHealth:{status:"ok",failureCount:0,lastSuccessAt:$,message:""}}),ne(xde)}catch(lt){const xt=Ce.signal.aborted&&!Se;if(_||!j||document.hidden||xt)return;L+=1,q({syncHealth:{status:"delayed",failureCount:L,lastSuccessAt:$,message:Se?"运行状态同步超过 8 秒未响应":`运行状态同步失败:${String((lt==null?void 0:lt.message)||lt)}`}}),ne(Sde(L))}finally{window.clearTimeout(Ue),D===Ce&&(D=null)}},K=()=>{B(),D&&(D.abort(),D=null)},ee=()=>{if(K(),P){const Ce=P;P=null,Ce()}j=!1},re=(Ce=kde)=>{z&&window.clearTimeout(z),!(_||document.hidden||j||N)&&(z=window.setTimeout(()=>{z=0,Q()},Ce))},se=()=>{_||document.hidden||j||(j=!0,ne(0))},Q=async()=>{var Ce;if(!(_||document.hidden||j||N)){if(!((Ce=navigator.locks)!=null&&Ce.request)){se();return}N=!0;try{await navigator.locks.request(wde,{mode:"exclusive",ifAvailable:!0},async Se=>{if(N=!1,!Se||_||document.hidden){re();return}j=!0,ne(0),await new Promise(Ue=>{P=Ue}),P=null,j=!1})}catch{N=!1}finally{re()}}},le=()=>{if(!_){if(j){L=0,ne(0);return}M({type:"retry"}),re(0)}};f.current=le,F&&(F.onmessage=Ce=>{const Se=Ce.data;if(!(!Se||Se.tabId===V)){if(Se.type==="hello"||Se.type==="presence"){W.set(Se.tabId,Date.now()),H(),Se.type==="hello"&&A();return}if(Se.type==="bye"){W.delete(Se.tabId),H(),re(0);return}if(Se.type==="state"){W.set(Se.tabId,Date.now()),H(),X(Se);return}Se.type==="retry"&&j&&(L=0,ne(0))}});const fe=()=>{A(),document.hidden?ee():re(0)},me=()=>{A("bye"),ee()},De=()=>{A("hello"),re(0)};return document.addEventListener("visibilitychange",fe),window.addEventListener("pagehide",me),window.addEventListener("pageshow",De),A("hello"),E=window.setInterval(A,zA),O=window.setInterval(H,zA),re(0),()=>{_=!0,f.current=()=>{},A("bye"),ee(),z&&window.clearTimeout(z),E&&window.clearInterval(E),O&&window.clearInterval(O),document.removeEventListener("visibilitychange",fe),window.removeEventListener("pagehide",me),window.removeEventListener("pageshow",De),F==null||F.close()}},[]);const p=_=>{const j=new URLSearchParams({flowId:_.flowId,flowSource:_.flowSource||"workspace"});e(`/flow?${j.toString()}`),o(!1)},d=t==="/flow"?new URLSearchParams(window.location.search):null,m=(d==null?void 0:d.get("flowId"))||"",y=c.status==="delayed",v=a>1,b=n.length===1;if(n.length===0&&!y)return null;const g=y?"状态同步延迟":n.length>0?b?n[0].flowId:`${n.length} running`:"",k=y?`${c.message}${v?`;检测到 ${a} 个 AgentFlow 标签页`:""}`:v?`已合并 ${a} 个 AgentFlow 标签页的运行状态同步`:b?`${n[0].flowId} 运行中,点击跳转`:`${n.length} 个 pipeline 运行中`,x=()=>{if(!y&&!v&&b){p(n[0]);return}o(_=>!_)};return s.jsxs("div",{className:"af-run-indicator"+(y?" af-run-indicator--delayed":"")+(v?" af-run-indicator--coordinated":""),role:"status","aria-live":"polite",children:[i&&s.jsxs("div",{className:"af-run-indicator__menu",onMouseLeave:()=>o(!1),children:[(y||v)&&s.jsxs("div",{className:"af-run-indicator__sync",children:[s.jsx("div",{className:"af-run-indicator__sync-title",children:y?"运行状态同步延迟":"多标签页同步已合并"}),s.jsx("div",{className:"af-run-indicator__sync-copy",children:v?`检测到 ${a} 个 AgentFlow 标签页。当前只由一个可见标签页请求运行状态,后台页面不会重复建立连接。`:"运行状态接口暂未及时返回,已停止重复请求并自动降低刷新频率。"}),y&&s.jsxs("div",{className:"af-run-indicator__sync-meta",children:["最近成功:",Nde(c.lastSuccessAt)]}),y&&s.jsx("button",{type:"button",className:"af-run-indicator__retry",onClick:_=>{_.stopPropagation(),f.current()},children:"立即重试"})]}),n.map(_=>s.jsxs("button",{type:"button",className:"af-run-indicator__item"+(_.flowId===m?" af-run-indicator__item--current":""),onClick:()=>p(_),title:`${_.flowId} · ${_.runId}`,children:[s.jsx("span",{className:"af-run-indicator__dot"}),s.jsx("span",{className:"af-run-indicator__flow",children:_.flowId}),s.jsx("span",{className:"af-run-indicator__run",children:_.runId.slice(0,12)})]},`${_.flowId}:${_.runId}`))]}),s.jsxs("button",{type:"button",className:"af-run-indicator__btn",onClick:x,title:k,children:[s.jsx("span",{className:"af-run-indicator__pulse"}),s.jsx("span",{className:"af-run-indicator__label",children:g})]})]})}const sx="0.1.141",Cde=6e4,Ade=30*6e4;function eu(e){return String(e||"").trim().replace(/^v/i,"")}function Ede(e,t){const n=eu(e),r=eu(t);return!!(n&&r&&n!==r)}function Ide(e,t){return`agentflow.app-version.snooze:${eu(e)}:${eu(t)}`}function Pde(e){if(!e)return 0;try{const t=Number(window.sessionStorage.getItem(e));return Number.isFinite(t)?t:0}catch{return 0}}function Tde(){const[e,t]=h.useState(null);if(h.useEffect(()=>{let r=!1,i=!1;const o=async()=>{if(!(i||document.visibilityState==="hidden")){i=!0;try{const c=await fetch("/api/app-version",{cache:"no-store"}),u=await c.json().catch(()=>({}));if(!c.ok||r)return;const f=eu(u.version);if(!Ede(sx,f)){t(null);return}const p=Ide(sx,f);if(Pde(p)>Date.now())return;t({clientVersion:eu(sx),serverVersion:f,startedAt:String(u.startedAt||""),snoozeKey:p})}catch{}finally{i=!1}}},a=()=>{document.visibilityState==="visible"&&o()},l=window.setInterval(()=>void o(),Cde);return document.addEventListener("visibilitychange",a),window.addEventListener("focus",o),o(),()=>{r=!0,window.clearInterval(l),document.removeEventListener("visibilitychange",a),window.removeEventListener("focus",o)}},[]),!e)return null;const n=()=>{try{window.sessionStorage.setItem(e.snoozeKey,String(Date.now()+Ade))}catch{}t(null)};return s.jsxs("aside",{className:"af-app-version-notice",role:"status","aria-live":"polite",children:[s.jsx("span",{className:"material-symbols-outlined af-app-version-notice__icon","aria-hidden":!0,children:"system_update"}),s.jsxs("div",{className:"af-app-version-notice__copy",children:[s.jsx("strong",{children:"AgentFlow 已更新"}),s.jsxs("span",{children:["v",e.clientVersion," → v",e.serverVersion,",刷新后生效"]})]}),s.jsxs("div",{className:"af-app-version-notice__actions",children:[s.jsx("button",{type:"button",className:"af-app-version-notice__later",onClick:n,children:"稍后"}),s.jsx("button",{type:"button",className:"af-app-version-notice__refresh",onClick:()=>window.location.reload(),children:"刷新更新"})]})]})}function iL(e){return e==="/likee-context"||e==="/likee_context"}function Rde(e){if(e!=="/workspace")return!1;const t=new URLSearchParams(window.location.search);return!!String(t.get("workflowShare")||"").trim()}function Mde(){const{navigate:e}=us();return h.useEffect(()=>{const t=new URLSearchParams(window.location.search),n=new URLSearchParams,r=t.get("flowId")||"",i=t.get("flowSource")||"";r&&n.set("flowId",r),i&&n.set("flowSource",i),t.get("flowArchived")&&n.set("archived",t.get("flowArchived")),e(`/workspace${n.toString()?`?${n.toString()}`:""}`)},[e]),null}class $de 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,i,o;if(!this.state.error)return this.props.children;const t=String(((r=this.state.error)==null?void 0:r.stack)||((i=this.state.error)==null?void 0:i.message)||this.state.error),n=String(((o=this.state.info)==null?void 0:o.componentStack)||"");return s.jsx("div",{className:"af-auth-screen",children:s.jsxs("div",{className:"af-auth-panel af-ui-error-panel",children:[s.jsxs("div",{className:"af-auth-brand",children:[s.jsx("span",{className:"material-symbols-outlined",children:"error"}),s.jsxs("div",{children:[s.jsx("h1",{children:"AgentFlow UI Error"}),s.jsx("p",{children:"页面渲染失败,下面是调试堆栈。"})]})]}),s.jsx("pre",{children:t}),n?s.jsx("pre",{children:n}):null]})})}}function Lde({authUser:e}){const{path:t}=us();return t==="/projects"||t==="/"?s.jsx(Ul,{authUser:e}):t==="/nodes"?s.jsx(Ul,{authUser:e,resourceKind:"nodes"}):t==="/my-nodes"?s.jsx(Ul,{authUser:e,resourceKind:"my-nodes"}):t==="/my-flows"?s.jsx(Ul,{authUser:e,resourceKind:"my-flows"}):t==="/skills"?s.jsx(Ul,{authUser:e,resourceKind:"skills"}):t==="/workspaces"?s.jsx(lae,{authUser:e}):t==="/workflows"?s.jsx(bae,{}):t==="/workflow-report"?s.jsx(ele,{}):t==="/mcps"?s.jsx(Joe,{}):t==="/schedules"?s.jsx(eae,{}):t==="/node-studio"?s.jsx(nae,{}):t==="/flow"?s.jsx(Mde,{}):t==="/workspace"?s.jsx(u$,{}):t.startsWith("/display")?s.jsx(p$,{}):t==="/settings"?s.jsx(Moe,{authUser:e}):t==="/admin/usage"?s.jsx(Woe,{authUser:e}):t==="/admin/teams"?s.jsx(Hoe,{authUser:e}):t==="/feedback"?s.jsx(Koe,{authUser:e}):iL(t)?s.jsx(E$,{}):s.jsx(Ul,{})}function Ode({children:e}){const[t,n]=h.useState({loading:!0,authenticated:!1,user:null,setupRequired:!1}),[r,i]=h.useState(""),[o,a]=h.useState(""),[l,c]=h.useState(!1),[u,f]=h.useState(""),p=async()=>{try{const y=await(await fetch("/api/auth/me")).json().catch(()=>({}));n({loading:!1,authenticated:!!y.authenticated,user:y.user||null,setupRequired:!!y.setupRequired}),f(y.error?String(y.error):"")}catch(m){n({loading:!1,authenticated:!1,user:null,setupRequired:!1}),f(String(m.message||m))}};h.useEffect(()=>{p()},[]);const d=async m=>{m.preventDefault(),c(!0),f("");try{const y=await fetch("/api/auth/login",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({username:r,password:o})}),v=await y.json().catch(()=>({}));if(!y.ok)throw new Error(v.error||"登录失败");i(""),a(""),window.location.replace(window.location.href);return}catch(y){f(String(y.message||y))}finally{c(!1)}};return t.loading?s.jsx("div",{className:"af-auth-screen",children:s.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})}}):s.jsx("div",{className:"af-auth-screen",children:s.jsxs("form",{className:"af-auth-panel",onSubmit:d,autoComplete:"on",children:[s.jsxs("div",{className:"af-auth-brand",children:[s.jsx("span",{className:"material-symbols-outlined",children:"account_circle"}),s.jsxs("div",{children:[s.jsx("h1",{children:"AgentFlow"}),s.jsx("p",{children:t.setupRequired?"初始化管理员账号":"登录或创建用户"})]})]}),s.jsxs("label",{className:"af-auth-field",children:[s.jsx("span",{children:"用户名"}),s.jsx("input",{id:"agentflow-auth-username",name:"username",type:"text",value:r,onChange:m=>i(m.target.value),autoComplete:"username",autoFocus:!0})]}),s.jsxs("label",{className:"af-auth-field",children:[s.jsx("span",{children:"密码"}),s.jsx("input",{id:"agentflow-auth-password",name:"password",type:"password",value:o,onChange:m=>a(m.target.value),autoComplete:t.setupRequired?"new-password":"current-password"})]}),u?s.jsx("p",{className:"af-auth-error",children:u}):null,s.jsx("button",{className:"af-auth-submit",type:"submit",disabled:l||!r.trim()||o.length<4,children:l?"处理中...":t.setupRequired?"创建并登录":"登录"})]})})}function Dde({authUser:e,onLogout:t}){const{path:n}=us(),r=n==="/flow"||n==="/workspace";return s.jsxs("div",{className:"af-app",children:[n!=="/settings"?s.jsx(gde,{page:r?"flow":"projects"}):null,r?null:s.jsx(BF,{authUser:e,onLogout:t}),s.jsx("div",{className:r?"af-main af-main--pipeline":"af-main",children:s.jsx(Lde,{authUser:e})}),s.jsx(_de,{})]})}function Fde(){return s.jsx($de,{children:s.jsxs(vF,{children:[s.jsx(zde,{}),s.jsx(Tde,{})]})})}function zde(){const{path:e}=us();return e.startsWith("/display")?s.jsx(p$,{}):iL(e)?s.jsx(E$,{}):Rde(e)?s.jsx(u$,{}):s.jsx(Ode,{children:({user:t,onLogout:n})=>s.jsx(Dde,{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 WA=document.querySelector('link[rel="icon"]');WA&&(WA.href=sP);ix.createRoot(document.getElementById("root")).render(s.jsx(ft.StrictMode,{children:s.jsx(Fde,{})}));export{hf as M,ft as R,Gde as a,er as b,xa as g,s as j,h as r};
|