@yiyi_zhang/reactflow-ui 0.4.0 → 0.5.0-beta.0
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/README.md +45 -14
- package/dist/AiWorkflowIDE.d.ts +217 -0
- package/dist/WorkflowIDE.d.ts +3 -2
- package/dist/ai-BJwQZcGK.js +15168 -0
- package/dist/ai.d.ts +30 -0
- package/dist/arc-BUGZGgtu.js +83 -0
- package/dist/architectureDiagram-3BPJPVTR-ZcgvTwSO.js +4692 -0
- package/dist/blockDiagram-GPEHLZMM-DtVtOBbH.js +2418 -0
- package/dist/c4Diagram-AAUBKEIU-tBS5Rcvm.js +1577 -0
- package/dist/channel-CURI9jmI.js +5 -0
- package/dist/chunk-2J33WTMH-D7gashNz.js +19 -0
- package/dist/chunk-4BX2VUAB-DE3VjyiZ.js +8 -0
- package/dist/chunk-55IACEB6-GYZ_m2MY.js +8 -0
- package/dist/chunk-727SXJPM-D4WVyvOg.js +1528 -0
- package/dist/chunk-AQP2D5EJ-Os2Uwqya.js +1387 -0
- package/dist/chunk-FMBD7UC4-B3CSVzS4.js +19 -0
- package/dist/chunk-ND2GUHAM-CNj_s1aK.js +68 -0
- package/dist/chunk-QZHKN3VN-DoV8iUKo.js +15 -0
- package/dist/classDiagram-4FO5ZUOK-Dr9C18x4.js +16 -0
- package/dist/classDiagram-v2-Q7XG4LA2-Dr9C18x4.js +16 -0
- package/dist/components/AiNative/AgentTimeline.d.ts +18 -0
- package/dist/components/AiNative/AiCommandCenter.d.ts +40 -0
- package/dist/components/AiNative/AiConfigPanel.d.ts +9 -0
- package/dist/components/AiNative/BusinessCanvas.d.ts +15 -0
- package/dist/components/AiNative/CanvasPreview.d.ts +16 -0
- package/dist/components/AiNative/ClarificationCard.d.ts +9 -0
- package/dist/components/AiNative/FailureSummaryCard.d.ts +20 -0
- package/dist/components/AiNative/LibraryPanel.d.ts +9 -0
- package/dist/components/AiNative/MermaidBlock.d.ts +6 -0
- package/dist/components/AiNative/PlanCard.d.ts +15 -0
- package/dist/components/AiNative/ProposalPreviewCard.d.ts +21 -0
- package/dist/components/AiNative/RecommendationCard.d.ts +10 -0
- package/dist/components/AiNative/RepairCard.d.ts +17 -0
- package/dist/components/AiNative/ReviewBar.d.ts +21 -0
- package/dist/components/AiNative/WorkflowRunCard.d.ts +14 -0
- package/dist/components/Controls/ModeSlider.d.ts +2 -0
- package/dist/components/nodes/NodeWrapper.d.ts +2 -1
- package/dist/cose-bilkent-S5V4N54A-CgQlI-io.js +2609 -0
- package/dist/cytoscape.esm-kVAWcYoG.js +18755 -0
- package/dist/dagre-BM42HDAG-CFMIuOmS.js +445 -0
- package/dist/defaultLocale-BgPVtth8.js +171 -0
- package/dist/diagram-2AECGRRQ-C5jZp2YX.js +217 -0
- package/dist/diagram-5GNKFQAL-DRUVcHpp.js +123 -0
- package/dist/diagram-KO2AKTUF-BOl4aaej.js +461 -0
- package/dist/diagram-LMA3HP47-ZeckPR2Q.js +142 -0
- package/dist/diagram-OG6HWLK6-qUWeLfa-.js +528 -0
- package/dist/erDiagram-TEJ5UH35-Bw_CWS13.js +899 -0
- package/dist/flowDiagram-I6XJVG4X-D3xEvQA-.js +1628 -0
- package/dist/ganttDiagram-6RSMTGT7-D8GvenY3.js +2707 -0
- package/dist/gitGraphDiagram-PVQCEYII-BWrN_HOm.js +815 -0
- package/dist/graph-BRoPeNF3.js +1545 -0
- package/dist/hooks/useNodeExecution.d.ts +1 -1
- package/dist/hooks/useNodeLayout.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/infoDiagram-5YYISTIA-Da8FG5tB.js +24 -0
- package/dist/init-DjUOC4st.js +16 -0
- package/dist/ishikawaDiagram-YF4QCWOH-Bg2_mKEc.js +621 -0
- package/dist/journeyDiagram-JHISSGLW-sFIxGfua.js +834 -0
- package/dist/kanban-definition-UN3LZRKU-CGmopzHd.js +724 -0
- package/dist/katex-DoRnZ_sp.js +11682 -0
- package/dist/layout-D9EpM4Fg.js +1728 -0
- package/dist/linear-BA49eco4.js +259 -0
- package/dist/mermaid.core-XSpZEAKP.js +16137 -0
- package/dist/mindmap-definition-RKZ34NQL-Bqf76QGB.js +827 -0
- package/dist/ordinal-B6-f3MAq.js +61 -0
- package/dist/pieDiagram-4H26LBE5-hHiP8HzL.js +163 -0
- package/dist/quadrantDiagram-W4KKPZXB-DSccwH8B.js +1024 -0
- package/dist/reactflow-ui-ai.es.js +12 -0
- package/dist/reactflow-ui.css +1 -1
- package/dist/reactflow-ui.es.js +5997 -5681
- package/dist/reactflow-ui.umd.js +32 -21
- package/dist/requirementDiagram-4Y6WPE33-DIpyoYZ_.js +882 -0
- package/dist/sankeyDiagram-5OEKKPKP-DsaPqq8D.js +847 -0
- package/dist/sequenceDiagram-3UESZ5HK-BNg7orie.js +2891 -0
- package/dist/services/ai/agentRunner.d.ts +51 -0
- package/dist/services/ai/contextEngine.d.ts +83 -0
- package/dist/services/ai/draftPersistence.d.ts +22 -0
- package/dist/services/ai/errorMessages.d.ts +16 -0
- package/dist/services/ai/intentClassifier.d.ts +17 -0
- package/dist/services/ai/protocolAdapter.d.ts +114 -0
- package/dist/services/ai/ruleEngine.d.ts +57 -0
- package/dist/services/ai/schemaRegistry.d.ts +51 -0
- package/dist/services/ai/systemPrompt.d.ts +30 -0
- package/dist/services/ai/toolDefs.d.ts +9 -0
- package/dist/services/ai/toolExecutor.d.ts +83 -0
- package/dist/services/ai/toolRegistry.d.ts +38 -0
- package/dist/services/ai/transport.d.ts +58 -0
- package/dist/services/aiService.d.ts +7 -5
- package/dist/stateDiagram-AJRCARHV-Rv1mSmnJ.js +263 -0
- package/dist/stateDiagram-v2-BHNVJYJU-BME16k02.js +16 -0
- package/dist/store/aiStore.d.ts +199 -0
- package/dist/store/ideStoresContext.d.ts +39 -0
- package/dist/store/libraryStore.d.ts +25 -0
- package/dist/timeline-definition-PNZ67QCA-CmmzdVk-.js +1055 -0
- package/dist/types/aiEvents.d.ts +38 -0
- package/dist/types/workflow.d.ts +11 -0
- package/dist/types/workflowLibrary.d.ts +27 -0
- package/dist/utils/nodeMeta.d.ts +6 -0
- package/dist/utils/proposalPreview.d.ts +19 -0
- package/dist/utils/taskTypeMeta.d.ts +18 -0
- package/dist/utils/workflowToMermaid.d.ts +7 -0
- package/dist/vennDiagram-CIIHVFJN-BQt00w9Q.js +1557 -0
- package/dist/wardley-L42UT6IY-D7b2ujEZ.js +22512 -0
- package/dist/wardleyDiagram-YWT4CUSO-LZpiODGN.js +675 -0
- package/dist/xychartDiagram-2RQKCTM6-BpJlv_mc.js +1342 -0
- package/package.json +14 -4
package/dist/reactflow-ui.umd.js
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(De,O){typeof exports=="object"&&typeof module<"u"?O(exports,require("react"),require("reactflow"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","reactflow","react-dom"],O):(De=typeof globalThis<"u"?globalThis:De||self,O(De.ReactflowUI={},De.React,De.ReactFlow,De.ReactDOM))})(this,(function(De,O,A,Qr){"use strict";var Er=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function cg(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Nr={exports:{}},ur={};var Yi;function dg(){if(Yi)return ur;Yi=1;var e=Symbol.for("react.transitional.element"),n=Symbol.for("react.fragment");function r(t,s,a){var o=null;if(a!==void 0&&(o=""+a),s.key!==void 0&&(o=""+s.key),"key"in s){a={};for(var i in s)i!=="key"&&(a[i]=s[i])}else a=s;return s=a.ref,{$$typeof:e,type:t,key:o,ref:s!==void 0?s:null,props:a}}return ur.Fragment=n,ur.jsx=r,ur.jsxs=r,ur}var fr={};var Xi;function ug(){return Xi||(Xi=1,process.env.NODE_ENV!=="production"&&(function(){function e(q){if(q==null)return null;if(typeof q=="function")return q.$$typeof===S?null:q.displayName||q.name||null;if(typeof q=="string")return q;switch(q){case v:return"Fragment";case x:return"Profiler";case y:return"StrictMode";case j:return"Suspense";case N:return"SuspenseList";case C:return"Activity"}if(typeof q=="object")switch(typeof q.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),q.$$typeof){case m:return"Portal";case k:return q.displayName||"Context";case b:return(q._context.displayName||"Context")+".Consumer";case w:var G=q.render;return q=q.displayName,q||(q=G.displayName||G.name||"",q=q!==""?"ForwardRef("+q+")":"ForwardRef"),q;case L:return G=q.displayName||null,G!==null?G:e(q.type)||"Memo";case T:G=q._payload,q=q._init;try{return e(q(G))}catch{}}return null}function n(q){return""+q}function r(q){try{n(q);var G=!1}catch{G=!0}if(G){G=console;var ie=G.error,R=typeof Symbol=="function"&&Symbol.toStringTag&&q[Symbol.toStringTag]||q.constructor.name||"Object";return ie.call(G,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",R),n(q)}}function t(q){if(q===v)return"<>";if(typeof q=="object"&&q!==null&&q.$$typeof===T)return"<...>";try{var G=e(q);return G?"<"+G+">":"<...>"}catch{return"<...>"}}function s(){var q=D.A;return q===null?null:q.getOwner()}function a(){return Error("react-stack-top-frame")}function o(q){if(I.call(q,"key")){var G=Object.getOwnPropertyDescriptor(q,"key").get;if(G&&G.isReactWarning)return!1}return q.key!==void 0}function i(q,G){function ie(){W||(W=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",G))}ie.isReactWarning=!0,Object.defineProperty(q,"key",{get:ie,configurable:!0})}function u(){var q=e(this.type);return K[q]||(K[q]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),q=this.props.ref,q!==void 0?q:null}function c(q,G,ie,R,M,_){var B=ie.ref;return q={$$typeof:g,type:q,key:G,props:ie,_owner:R},(B!==void 0?B:null)!==null?Object.defineProperty(q,"ref",{enumerable:!1,get:u}):Object.defineProperty(q,"ref",{enumerable:!1,value:null}),q._store={},Object.defineProperty(q._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(q,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(q,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:M}),Object.defineProperty(q,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:_}),Object.freeze&&(Object.freeze(q.props),Object.freeze(q)),q}function d(q,G,ie,R,M,_){var B=G.children;if(B!==void 0)if(R)if(P(B)){for(R=0;R<B.length;R++)f(B[R]);Object.freeze&&Object.freeze(B)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(B);if(I.call(G,"key")){B=e(q);var $=Object.keys(G).filter(function(U){return U!=="key"});R=0<$.length?"{key: someKey, "+$.join(": ..., ")+": ...}":"{key: someKey}",re[B+R]||($=0<$.length?"{"+$.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,R,B,z,B),ee[B+R]=!0)}if(B=null,se!==void 0&&(t(se),B=""+se),o(Y)&&(t(Y.key),B=""+Y.key),"key"in Y){se={};for(var Q in Y)Q!=="key"&&(se[Q]=Y[Q])}else se=Y;return B&&i(se,typeof D=="function"?D.displayName||D.name||"Unknown":D),c(D,B,se,s(),M,_)}function f(D){p(D)?D._store&&(D._store.validated=1):typeof D=="object"&&D!==null&&D.$$typeof===T&&(D._payload.status==="fulfilled"?p(D._payload.value)&&D._payload.value._store&&(D._payload.value._store.validated=1):D._store&&(D._store.validated=1))}function p(D){return typeof D=="object"&&D!==null&&D.$$typeof===g}var h=P,g=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),k=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),S=Symbol.for("react.client.reference"),q=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=Object.prototype.hasOwnProperty,O=Array.isArray,F=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(D){return D()}};var W,V={},Z=h.react_stack_bottom_frame.bind(h,a)(),ne=F(n(a)),ee={};dr.Fragment=v,dr.jsx=function(D,Y,se){var R=1e4>q.recentlyCreatedOwnerStacks++;return u(D,Y,se,!1,R?Error("react-stack-top-frame"):Z,R?F(n(D)):ne)},dr.jsxs=function(D,Y,se){var R=1e4>q.recentlyCreatedOwnerStacks++;return u(D,Y,se,!0,R?Error("react-stack-top-frame"):Z,R?F(n(D)):ne)}})()),dr}var Ji;function sg(){return Ji||(Ji=1,process.env.NODE_ENV==="production"?wr.exports=ng():wr.exports=ag()),wr.exports}var l=sg();const Gi=e=>{let r;const t=new Set,n=(c,u)=>{const f=typeof c=="function"?c(r):c;if(!Object.is(f,r)){const p=r;r=u??(typeof f!="object"||f===null)?f:Object.assign({},r,f),t.forEach(h=>h(r,p))}},s=()=>r,i={setState:n,getState:s,getInitialState:()=>d,subscribe:c=>(t.add(c),()=>t.delete(c))},d=r=e(n,s,i);return i},Vi=(e=>e?Gi(e):Gi),og=e=>e;function Xr(e,r=og){const t=P.useSyncExternalStore(e.subscribe,P.useCallback(()=>r(e.getState()),[e,r]),P.useCallback(()=>r(e.getInitialState()),[e,r]));return P.useDebugValue(t),t}const ig=e=>{const r=Vi(e),t=n=>Xr(r,n);return Object.assign(t,r),t},lg=(e=>ig);function Yi(e,r){let t;try{t=e()}catch{return}return{getItem:s=>{var a;const o=d=>d===null?null:JSON.parse(d,void 0),i=(a=t.getItem(s))!=null?a:null;return i instanceof Promise?i.then(o):o(i)},setItem:(s,a)=>t.setItem(s,JSON.stringify(a,void 0)),removeItem:s=>t.removeItem(s)}}const Zr=e=>r=>{try{const t=e(r);return t instanceof Promise?t:{then(n){return Zr(n)(t)},catch(n){return this}}}catch(t){return{then(n){return this},catch(n){return Zr(n)(t)}}}},cg=(e,r)=>(t,n,s)=>{let a={storage:Yi(()=>localStorage),partialize:m=>m,version:0,merge:(m,v)=>({...v,...m}),...r},o=!1;const i=new Set,d=new Set;let c=a.storage;if(!c)return e((...m)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),t(...m)},n,s);const u=()=>{const m=a.partialize({...n()});return c.setItem(a.name,{state:m,version:a.version})},f=s.setState;s.setState=(m,v)=>(f(m,v),u());const p=e((...m)=>(t(...m),u()),n,s);s.getInitialState=()=>p;let h;const g=()=>{var m,v;if(!c)return;o=!1,i.forEach(x=>{var b;return x((b=n())!=null?b:p)});const y=((v=a.onRehydrateStorage)==null?void 0:v.call(a,(m=n())!=null?m:p))||void 0;return Zr(c.getItem.bind(c))(a.name).then(x=>{if(x)if(typeof x.version=="number"&&x.version!==a.version){if(a.migrate){const b=a.migrate(x.state,x.version);return b instanceof Promise?b.then(k=>[!0,k]):[!0,b]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,x.state];return[!1,void 0]}).then(x=>{var b;const[k,w]=x;if(h=a.merge(w,(b=n())!=null?b:p),t(h,!0),k)return u()}).then(()=>{y?.(h,void 0),h=n(),o=!0,d.forEach(x=>x(h))}).catch(x=>{y?.(void 0,x)})};return s.persist={setOptions:m=>{a={...a,...m},m.storage&&(c=m.storage)},clearStorage:()=>{c?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>g(),hasHydrated:()=>o,onHydrate:m=>(i.add(m),()=>{i.delete(m)}),onFinishHydration:m=>(d.add(m),()=>{d.delete(m)})},a.skipHydration||g(),h||p};var Xi=(e,r,t)=>(s,a)=>({pastStates:t?.pastStates||[],futureStates:t?.futureStates||[],undo:(o=1)=>{if(a().pastStates.length){const i=t?.partialize?.(r())||r(),d=a().pastStates.splice(-o,o),c=d.shift();e(c),s({pastStates:a().pastStates,futureStates:a().futureStates.concat(t?.diff?.(i,c)||i,d.reverse())})}},redo:(o=1)=>{if(a().futureStates.length){const i=t?.partialize?.(r())||r(),d=a().futureStates.splice(-o,o),c=d.shift();e(c),s({pastStates:a().pastStates.concat(t?.diff?.(i,c)||i,d.reverse()),futureStates:a().futureStates})}},clear:()=>s({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>s({isTracking:!1}),resume:()=>s({isTracking:!0}),setOnSave:o=>s({_onSave:o}),_onSave:t?.onSave,_handleSet:(o,i,d,c)=>{t?.limit&&a().pastStates.length>=t?.limit&&a().pastStates.shift(),a()._onSave?.(o,d),s({pastStates:a().pastStates.concat(c||o),futureStates:[]})}}),ug=(e,r)=>(n,s,a)=>{a.temporal=Vi(r?.wrapTemporal?.(Xi(n,s,r))||Xi(n,s,r));const o=r?.handleSet?.(a.temporal.getState()._handleSet)||a.temporal.getState()._handleSet,i=c=>{if(!a.temporal.getState().isTracking)return;const u=r?.partialize?.(s())||s(),f=r?.diff?.(c,u);f===null||r?.equality?.(c,u)||o(c,void 0,u,f)},d=a.setState;return a.setState=(...c)=>{const u=r?.partialize?.(s())||s();d(...c),i(u)},e((...c)=>{const u=r?.partialize?.(s())||s();n(...c),i(u)},s,a)};function dg(e,r="TB",t){const n=t?.hideEmptyBranches??!1;if(!e||!e.tasks)return{nodes:[],edges:[],taskMap:{}};const s=[],a=[],o={};let i=0;const d=e.tasks;for(let c=0;c<d.length;c++){const u=d[c],f=Zi(u,i,o,r,d,n);if(s.push(...f.nodes),a.push(...f.edges),i=f.nextId,c>0){const p=d[c-1];Qr(p,u,a,n)}Object.assign(o,f.taskMap)}if(!n&&d.length>0){const c=d[0],u="__workflow_start__";s.push({id:u,type:"plusNode",data:{label:"+",taskReferenceName:u,taskType:"PLUS",parentRef:u,edgeData:{isWorkflowStart:!0},layoutDirection:r},position:{x:0,y:0},sourcePosition:r==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:r==="LR"?A.Position.Left:A.Position.Top}),a.push({id:`e-${u}-${c.taskReferenceName}`,source:u,target:c.taskReferenceName,animated:!0});const f=d[d.length-1],p="__workflow_end__";s.push({id:p,type:"plusNode",data:{label:"+",taskReferenceName:p,taskType:"PLUS",parentRef:f.taskReferenceName,layoutDirection:r},position:{x:0,y:0},sourcePosition:r==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:r==="LR"?A.Position.Left:A.Position.Top}),Qr(f,{taskReferenceName:p},a,n)}return{nodes:s,edges:a,taskMap:o}}function Zi(e,r,t,n="TB",s=[],a=!1){switch(e.type||"SIMPLE"){case"DECISION":case"SWITCH":return pg(e,r,t,n,a);case"FORK_JOIN":case"FORK_JOIN_DYNAMIC":return hg(e,r,t,n);case"JOIN":case"EXCLUSIVE_JOIN":return vg(e,r,t,n,s,a);case"DO_WHILE":return gg(e,r,t,n,a);case"SUB_WORKFLOW":return mg(e,r,t,n);default:return fg(e,r,t,n)}}function fg(e,r,t,n="TB"){const s={id:e.taskReferenceName,type:"taskNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type||"SIMPLE",task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:r+1}}function pg(e,r,t,n="TB",s=!1){const a=[],o=[];let i=r;const d={},c={id:e.taskReferenceName,type:"decisionNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top};a.push(c),d[e.taskReferenceName]=e;const u=e.decisionCases||{},f=e.defaultCase||[],p=Object.keys(u),h=(g,m)=>{if(n==="TB"){if(g===0&&m>1)return"left";if(g===1&&m>2)return"right"}else{if(g===0&&m>1)return"top";if(g===1&&m>2)return"bottom"}return null};if(p.forEach((g,m)=>{const v=u[g],y=h(m,p.length+1);if(v&&v.length>0){const x=Tr(v,i,{...t,...d},n,s);a.push(...x.nodes),o.push(...x.edges),Object.assign(d,x.taskMap),i=x.nextId;const b=v[0].taskReferenceName;o.push({id:`e-${e.taskReferenceName}-${b}`,source:e.taskReferenceName,sourceHandle:y||void 0,target:b,label:g,animated:!0,data:{branchCase:g},style:{stroke:"#3b82f6"}})}else if(!s){const x=`${e.taskReferenceName}_empty_${g}`;a.push({id:x,type:"plusNode",data:{label:`${g} (空)`,parentRef:e.taskReferenceName,edgeData:{branchCase:g},layoutDirection:n,taskReferenceName:x,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),o.push({id:`e-${e.taskReferenceName}-${x}`,source:e.taskReferenceName,sourceHandle:y||void 0,target:x,label:g,animated:!0,data:{branchCase:g},style:{stroke:"#3b82f6",strokeDasharray:"5,5"}})}}),f&&f.length>0){const g=Tr(f,i,{...t,...d},n,s);a.push(...g.nodes),o.push(...g.edges),Object.assign(d,g.taskMap),i=g.nextId;const m=f[0].taskReferenceName;o.push({id:`e-${e.taskReferenceName}-${m}`,source:e.taskReferenceName,target:m,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b"}})}else if(!s){const g=`${e.taskReferenceName}_empty_default`;a.push({id:g,type:"plusNode",data:{label:"default (空)",parentRef:e.taskReferenceName,edgeData:{branchCase:"default"},layoutDirection:n,taskReferenceName:g,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),o.push({id:`e-${e.taskReferenceName}-${g}`,source:e.taskReferenceName,target:g,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b",strokeDasharray:"5,5"}})}return{nodes:a,edges:o,taskMap:d,nextId:i}}function hg(e,r,t,n="TB"){const s=[],a=[];let o=r;const i={},d=e.type==="FORK_JOIN_DYNAMIC",c={id:e.taskReferenceName,type:"forkNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,isDynamic:d,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top};if(s.push(c),i[e.taskReferenceName]=e,d){const u=`${e.taskReferenceName}_dynamic_placeholder`;s.push({id:u,type:"dynamicPlaceholderNode",data:{label:"动态分支",taskReferenceName:u,taskType:"DYNAMIC_PLACEHOLDER",layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top}),a.push({id:`e-${e.taskReferenceName}-${u}`,source:e.taskReferenceName,target:u,animated:!0,style:{stroke:"#10b981",strokeDasharray:"5,5",strokeWidth:2}}),i[u]={taskReferenceName:u,type:"DYNAMIC_PLACEHOLDER"}}return d||(e.forkTasks||[]).forEach((f,p)=>{if(f&&f.length>0){const h=Tr(f,o,{...t,...i},n,!1);s.push(...h.nodes),a.push(...h.edges),Object.assign(i,h.taskMap),o=h.nextId;const g=f[0].taskReferenceName;a.push({id:`e-${e.taskReferenceName}-${g}`,source:e.taskReferenceName,sourceHandle:`branch_${p}`,target:g,label:`分支 ${p+1}`,animated:!0,data:{forkIndex:p},style:{stroke:"#10b981"}})}}),{nodes:s,edges:a,taskMap:i,nextId:o}}function gg(e,r,t,n="TB",s=!1){const a={},o=e.taskReferenceName,i={id:o,type:"loopNode",data:{label:e.name,taskReferenceName:o,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top,style:{pointerEvents:"none"}};a[o]=e;const d=e.loopOver||[],c=[],u=[];let f=r+1;if(d.length>0){const p=Tr(d,f,{...t,...a},n,s);if(f=p.nextId,Object.assign(a,p.taskMap),p.nodes.forEach(h=>{c.push({...h,parentId:h.parentId??o,extent:h.parentId?h.extent:"parent"})}),u.push(...p.edges),!s){const h=d[0],g=`__loop_start__${o}`;c.push({id:g,type:"plusNode",parentId:o,extent:"parent",data:{label:"+",taskReferenceName:g,taskType:"PLUS",parentRef:o,edgeData:{isLoopBodyStart:!0,loopId:o},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top}),u.push({id:`e-${g}-${h.taskReferenceName}`,source:g,target:h.taskReferenceName,animated:!0})}if(!s){const h=d[d.length-1],g=`__loop_end__${o}`;c.push({id:g,type:"plusNode",parentId:o,extent:"parent",data:{label:"+",taskReferenceName:g,taskType:"PLUS",parentRef:h.taskReferenceName,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top}),u.push({id:`e-${h.taskReferenceName}-${g}`,source:h.taskReferenceName,target:g,animated:!0})}}else if(!s){const p=`${o}_loop_empty_plus`;c.push({id:p,type:"plusNode",parentId:o,extent:"parent",data:{label:"+ 添加",taskReferenceName:p,taskType:"PLUS",parentRef:o,edgeData:{isLoopAdd:!0},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top})}return{nodes:[i,...c],edges:u,taskMap:a,nextId:f}}function mg(e,r,t,n="TB"){const s={id:e.taskReferenceName,type:"subWorkflowNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:r+1}}function vg(e,r,t,n="TB",s=[],a=!1){const o={id:e.taskReferenceName,type:"joinNode",data:{label:e.name||"JOIN",taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top},i={[e.taskReferenceName]:e},d=[],c=[];(e.joinOn||[]).forEach(p=>{const h=s.find(g=>g.taskReferenceName===p)||t[p];h&&Er(h,a).forEach(m=>{c.push({id:`e-${m}-${e.taskReferenceName}`,source:m,target:e.taskReferenceName,animated:!0})})});const f=s.findIndex(p=>p.taskReferenceName===e.taskReferenceName);if(f>0){const p=s[f-1];if(p.type==="FORK_JOIN_DYNAMIC"){const h=`${p.taskReferenceName}_dynamic_placeholder`;c.push({id:`e-${h}-${e.taskReferenceName}-dynamic`,source:h,target:e.taskReferenceName,animated:!0,style:{stroke:"#10b981",strokeWidth:2,strokeDasharray:"5,5",opacity:.8}})}else p.type==="FORK_JOIN"&&(p.forkTasks||[]).forEach((g,m)=>{if((!g||g.length===0)&&!a){const v=`${p.taskReferenceName}_empty_branch_${m}`;d.push({id:v,type:"default",data:{label:`分支 ${m+1} (空)`,layoutDirection:n,taskReferenceName:v,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),c.push({id:`e-${p.taskReferenceName}-${v}`,source:p.taskReferenceName,sourceHandle:`branch_${m}`,target:v,label:`分支 ${m+1}`,animated:!0,data:{forkIndex:m},style:{stroke:"#10b981",strokeDasharray:"5,5"}}),c.push({id:`e-${v}-${e.taskReferenceName}`,source:v,target:e.taskReferenceName,animated:!0,style:{strokeDasharray:"5,5"}})}})}return{nodes:[o,...d],edges:c,taskMap:i,nextId:r+1}}function Tr(e,r,t,n="TB",s=!1){const a=[],o=[];let i=r;const d={};for(let c=0;c<e.length;c++){const u=e[c],f={...t,...d},p=Zi(u,i,f,n,e,s);if(a.push(...p.nodes),o.push(...p.edges),Object.assign(d,p.taskMap),i=p.nextId,c>0){const h=e[c-1];Qr(h,u,o,s)}}return{nodes:a,edges:o,taskMap:d,nextId:i}}function Qr(e,r,t,n=!1){if(e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC")return;const s=Er(e,n),a=r.taskReferenceName;s.forEach(o=>{const i=`e-${o}-${a}`;t.find(d=>d.id===i)||t.push({id:i,source:o,target:a,animated:!0})})}function Er(e,r=!1){const t=e.type||"SIMPLE";if(t==="DECISION"||t==="SWITCH"){const n=[],s=e.decisionCases||{},a=e.defaultCase||[];if(Object.entries(s).forEach(([o,i])=>{if(i&&i.length>0){const d=i[i.length-1];n.push(...Er(d,r))}else r||n.push(`${e.taskReferenceName}_empty_${o}`)}),a.length>0){const o=a[a.length-1];n.push(...Er(o,r))}else r||n.push(`${e.taskReferenceName}_empty_default`);return n.length>0?n:[e.taskReferenceName]}return[e.taskReferenceName]}const Ee=dg;function et(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var rt,Qi;function yg(){if(Qi)return rt;Qi=1;function e(){this.__data__=[],this.size=0}return rt=e,rt}var tt,el;function er(){if(el)return tt;el=1;function e(r,t){return r===t||r!==r&&t!==t}return tt=e,tt}var nt,rl;function Nr(){if(rl)return nt;rl=1;var e=er();function r(t,n){for(var s=t.length;s--;)if(e(t[s][0],n))return s;return-1}return nt=r,nt}var at,tl;function xg(){if(tl)return at;tl=1;var e=Nr(),r=Array.prototype,t=r.splice;function n(s){var a=this.__data__,o=e(a,s);if(o<0)return!1;var i=a.length-1;return o==i?a.pop():t.call(a,o,1),--this.size,!0}return at=n,at}var st,nl;function bg(){if(nl)return st;nl=1;var e=Nr();function r(t){var n=this.__data__,s=e(n,t);return s<0?void 0:n[s][1]}return st=r,st}var ot,al;function kg(){if(al)return ot;al=1;var e=Nr();function r(t){return e(this.__data__,t)>-1}return ot=r,ot}var it,sl;function _g(){if(sl)return it;sl=1;var e=Nr();function r(t,n){var s=this.__data__,a=e(s,t);return a<0?(++this.size,s.push([t,n])):s[a][1]=n,this}return it=r,it}var lt,ol;function Cr(){if(ol)return lt;ol=1;var e=yg(),r=xg(),t=bg(),n=kg(),s=_g();function a(o){var i=-1,d=o==null?0:o.length;for(this.clear();++i<d;){var c=o[i];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=r,a.prototype.get=t,a.prototype.has=n,a.prototype.set=s,lt=a,lt}var ct,il;function Sg(){if(il)return ct;il=1;var e=Cr();function r(){this.__data__=new e,this.size=0}return ct=r,ct}var ut,ll;function wg(){if(ll)return ut;ll=1;function e(r){var t=this.__data__,n=t.delete(r);return this.size=t.size,n}return ut=e,ut}var dt,cl;function Tg(){if(cl)return dt;cl=1;function e(r){return this.__data__.get(r)}return dt=e,dt}var ft,ul;function Eg(){if(ul)return ft;ul=1;function e(r){return this.__data__.has(r)}return ft=e,ft}var pt,dl;function fl(){if(dl)return pt;dl=1;var e=typeof Sr=="object"&&Sr&&Sr.Object===Object&&Sr;return pt=e,pt}var ht,pl;function Oe(){if(pl)return ht;pl=1;var e=fl(),r=typeof self=="object"&&self&&self.Object===Object&&self,t=e||r||Function("return this")();return ht=t,ht}var gt,hl;function rr(){if(hl)return gt;hl=1;var e=Oe(),r=e.Symbol;return gt=r,gt}var mt,gl;function Ng(){if(gl)return mt;gl=1;var e=rr(),r=Object.prototype,t=r.hasOwnProperty,n=r.toString,s=e?e.toStringTag:void 0;function a(o){var i=t.call(o,s),d=o[s];try{o[s]=void 0;var c=!0}catch{}var u=n.call(o);return c&&(i?o[s]=d:delete o[s]),u}return mt=a,mt}var vt,ml;function Cg(){if(ml)return vt;ml=1;var e=Object.prototype,r=e.toString;function t(n){return r.call(n)}return vt=t,vt}var yt,vl;function Je(){if(vl)return yt;vl=1;var e=rr(),r=Ng(),t=Cg(),n="[object Null]",s="[object Undefined]",a=e?e.toStringTag:void 0;function o(i){return i==null?i===void 0?s:n:a&&a in Object(i)?r(i):t(i)}return yt=o,yt}var xt,yl;function je(){if(yl)return xt;yl=1;function e(r){var t=typeof r;return r!=null&&(t=="object"||t=="function")}return xt=e,xt}var bt,xl;function fr(){if(xl)return bt;xl=1;var e=Je(),r=je(),t="[object AsyncFunction]",n="[object Function]",s="[object GeneratorFunction]",a="[object Proxy]";function o(i){if(!r(i))return!1;var d=e(i);return d==n||d==s||d==t||d==a}return bt=o,bt}var kt,bl;function jg(){if(bl)return kt;bl=1;var e=Oe(),r=e["__core-js_shared__"];return kt=r,kt}var _t,kl;function Ig(){if(kl)return _t;kl=1;var e=jg(),r=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function t(n){return!!r&&r in n}return _t=t,_t}var St,_l;function Sl(){if(_l)return St;_l=1;var e=Function.prototype,r=e.toString;function t(n){if(n!=null){try{return r.call(n)}catch{}try{return n+""}catch{}}return""}return St=t,St}var wt,wl;function Rg(){if(wl)return wt;wl=1;var e=fr(),r=Ig(),t=je(),n=Sl(),s=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,i=Object.prototype,d=o.toString,c=i.hasOwnProperty,u=RegExp("^"+d.call(c).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function f(p){if(!t(p)||r(p))return!1;var h=e(p)?u:a;return h.test(n(p))}return wt=f,wt}var Tt,Tl;function Og(){if(Tl)return Tt;Tl=1;function e(r,t){return r?.[t]}return Tt=e,Tt}var Et,El;function Ge(){if(El)return Et;El=1;var e=Rg(),r=Og();function t(n,s){var a=r(n,s);return e(a)?a:void 0}return Et=t,Et}var Nt,Nl;function Ct(){if(Nl)return Nt;Nl=1;var e=Ge(),r=Oe(),t=e(r,"Map");return Nt=t,Nt}var jt,Cl;function jr(){if(Cl)return jt;Cl=1;var e=Ge(),r=e(Object,"create");return jt=r,jt}var It,jl;function Pg(){if(jl)return It;jl=1;var e=jr();function r(){this.__data__=e?e(null):{},this.size=0}return It=r,It}var Rt,Il;function Ag(){if(Il)return Rt;Il=1;function e(r){var t=this.has(r)&&delete this.__data__[r];return this.size-=t?1:0,t}return Rt=e,Rt}var Ot,Rl;function Lg(){if(Rl)return Ot;Rl=1;var e=jr(),r="__lodash_hash_undefined__",t=Object.prototype,n=t.hasOwnProperty;function s(a){var o=this.__data__;if(e){var i=o[a];return i===r?void 0:i}return n.call(o,a)?o[a]:void 0}return Ot=s,Ot}var Pt,Ol;function qg(){if(Ol)return Pt;Ol=1;var e=jr(),r=Object.prototype,t=r.hasOwnProperty;function n(s){var a=this.__data__;return e?a[s]!==void 0:t.call(a,s)}return Pt=n,Pt}var At,Pl;function Dg(){if(Pl)return At;Pl=1;var e=jr(),r="__lodash_hash_undefined__";function t(n,s){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=e&&s===void 0?r:s,this}return At=t,At}var Lt,Al;function Mg(){if(Al)return Lt;Al=1;var e=Pg(),r=Ag(),t=Lg(),n=qg(),s=Dg();function a(o){var i=-1,d=o==null?0:o.length;for(this.clear();++i<d;){var c=o[i];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=r,a.prototype.get=t,a.prototype.has=n,a.prototype.set=s,Lt=a,Lt}var qt,Ll;function Wg(){if(Ll)return qt;Ll=1;var e=Mg(),r=Cr(),t=Ct();function n(){this.size=0,this.__data__={hash:new e,map:new(t||r),string:new e}}return qt=n,qt}var Dt,ql;function Bg(){if(ql)return Dt;ql=1;function e(r){var t=typeof r;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?r!=="__proto__":r===null}return Dt=e,Dt}var Mt,Dl;function Ir(){if(Dl)return Mt;Dl=1;var e=Bg();function r(t,n){var s=t.__data__;return e(n)?s[typeof n=="string"?"string":"hash"]:s.map}return Mt=r,Mt}var Wt,Ml;function Fg(){if(Ml)return Wt;Ml=1;var e=Ir();function r(t){var n=e(this,t).delete(t);return this.size-=n?1:0,n}return Wt=r,Wt}var Bt,Wl;function $g(){if(Wl)return Bt;Wl=1;var e=Ir();function r(t){return e(this,t).get(t)}return Bt=r,Bt}var Ft,Bl;function zg(){if(Bl)return Ft;Bl=1;var e=Ir();function r(t){return e(this,t).has(t)}return Ft=r,Ft}var $t,Fl;function Hg(){if(Fl)return $t;Fl=1;var e=Ir();function r(t,n){var s=e(this,t),a=s.size;return s.set(t,n),this.size+=s.size==a?0:1,this}return $t=r,$t}var zt,$l;function Ht(){if($l)return zt;$l=1;var e=Wg(),r=Fg(),t=$g(),n=zg(),s=Hg();function a(o){var i=-1,d=o==null?0:o.length;for(this.clear();++i<d;){var c=o[i];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=r,a.prototype.get=t,a.prototype.has=n,a.prototype.set=s,zt=a,zt}var Kt,zl;function Kg(){if(zl)return Kt;zl=1;var e=Cr(),r=Ct(),t=Ht(),n=200;function s(a,o){var i=this.__data__;if(i instanceof e){var d=i.__data__;if(!r||d.length<n-1)return d.push([a,o]),this.size=++i.size,this;i=this.__data__=new t(d)}return i.set(a,o),this.size=i.size,this}return Kt=s,Kt}var Ut,Hl;function Rr(){if(Hl)return Ut;Hl=1;var e=Cr(),r=Sg(),t=wg(),n=Tg(),s=Eg(),a=Kg();function o(i){var d=this.__data__=new e(i);this.size=d.size}return o.prototype.clear=r,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=s,o.prototype.set=a,Ut=o,Ut}var Jt,Kl;function Gt(){if(Kl)return Jt;Kl=1;function e(r,t){for(var n=-1,s=r==null?0:r.length;++n<s&&t(r[n],n,r)!==!1;);return r}return Jt=e,Jt}var Vt,Ul;function Jl(){if(Ul)return Vt;Ul=1;var e=Ge(),r=(function(){try{var t=e(Object,"defineProperty");return t({},"",{}),t}catch{}})();return Vt=r,Vt}var Yt,Gl;function Or(){if(Gl)return Yt;Gl=1;var e=Jl();function r(t,n,s){n=="__proto__"&&e?e(t,n,{configurable:!0,enumerable:!0,value:s,writable:!0}):t[n]=s}return Yt=r,Yt}var Xt,Vl;function Pr(){if(Vl)return Xt;Vl=1;var e=Or(),r=er(),t=Object.prototype,n=t.hasOwnProperty;function s(a,o,i){var d=a[o];(!(n.call(a,o)&&r(d,i))||i===void 0&&!(o in a))&&e(a,o,i)}return Xt=s,Xt}var Zt,Yl;function pr(){if(Yl)return Zt;Yl=1;var e=Pr(),r=Or();function t(n,s,a,o){var i=!a;a||(a={});for(var d=-1,c=s.length;++d<c;){var u=s[d],f=o?o(a[u],n[u],u,a,n):void 0;f===void 0&&(f=n[u]),i?r(a,u,f):e(a,u,f)}return a}return Zt=t,Zt}var Qt,Xl;function Ug(){if(Xl)return Qt;Xl=1;function e(r,t){for(var n=-1,s=Array(r);++n<r;)s[n]=t(n);return s}return Qt=e,Qt}var en,Zl;function De(){if(Zl)return en;Zl=1;function e(r){return r!=null&&typeof r=="object"}return en=e,en}var rn,Ql;function Jg(){if(Ql)return rn;Ql=1;var e=Je(),r=De(),t="[object Arguments]";function n(s){return r(s)&&e(s)==t}return rn=n,rn}var tn,ec;function hr(){if(ec)return tn;ec=1;var e=Jg(),r=De(),t=Object.prototype,n=t.hasOwnProperty,s=t.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(o){return r(o)&&n.call(o,"callee")&&!s.call(o,"callee")};return tn=a,tn}var nn,rc;function be(){if(rc)return nn;rc=1;var e=Array.isArray;return nn=e,nn}var gr={exports:{}},an,tc;function Gg(){if(tc)return an;tc=1;function e(){return!1}return an=e,an}gr.exports;var nc;function tr(){return nc||(nc=1,(function(e,r){var t=Oe(),n=Gg(),s=r&&!r.nodeType&&r,a=s&&!0&&e&&!e.nodeType&&e,o=a&&a.exports===s,i=o?t.Buffer:void 0,d=i?i.isBuffer:void 0,c=d||n;e.exports=c})(gr,gr.exports)),gr.exports}var sn,ac;function Ar(){if(ac)return sn;ac=1;var e=9007199254740991,r=/^(?:0|[1-9]\d*)$/;function t(n,s){var a=typeof n;return s=s??e,!!s&&(a=="number"||a!="symbol"&&r.test(n))&&n>-1&&n%1==0&&n<s}return sn=t,sn}var on,sc;function ln(){if(sc)return on;sc=1;var e=9007199254740991;function r(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=e}return on=r,on}var cn,oc;function Vg(){if(oc)return cn;oc=1;var e=Je(),r=ln(),t=De(),n="[object Arguments]",s="[object Array]",a="[object Boolean]",o="[object Date]",i="[object Error]",d="[object Function]",c="[object Map]",u="[object Number]",f="[object Object]",p="[object RegExp]",h="[object Set]",g="[object String]",m="[object WeakMap]",v="[object ArrayBuffer]",y="[object DataView]",x="[object Float32Array]",b="[object Float64Array]",k="[object Int8Array]",w="[object Int16Array]",j="[object Int32Array]",N="[object Uint8Array]",L="[object Uint8ClampedArray]",T="[object Uint16Array]",C="[object Uint32Array]",S={};S[x]=S[b]=S[k]=S[w]=S[j]=S[N]=S[L]=S[T]=S[C]=!0,S[n]=S[s]=S[v]=S[a]=S[y]=S[o]=S[i]=S[d]=S[c]=S[u]=S[f]=S[p]=S[h]=S[g]=S[m]=!1;function q(I){return t(I)&&r(I.length)&&!!S[e(I)]}return cn=q,cn}var un,ic;function Lr(){if(ic)return un;ic=1;function e(r){return function(t){return r(t)}}return un=e,un}var mr={exports:{}};mr.exports;var lc;function dn(){return lc||(lc=1,(function(e,r){var t=fl(),n=r&&!r.nodeType&&r,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,o=a&&t.process,i=(function(){try{var d=s&&s.require&&s.require("util").types;return d||o&&o.binding&&o.binding("util")}catch{}})();e.exports=i})(mr,mr.exports)),mr.exports}var fn,cc;function vr(){if(cc)return fn;cc=1;var e=Vg(),r=Lr(),t=dn(),n=t&&t.isTypedArray,s=n?r(n):e;return fn=s,fn}var pn,uc;function dc(){if(uc)return pn;uc=1;var e=Ug(),r=hr(),t=be(),n=tr(),s=Ar(),a=vr(),o=Object.prototype,i=o.hasOwnProperty;function d(c,u){var f=t(c),p=!f&&r(c),h=!f&&!p&&n(c),g=!f&&!p&&!h&&a(c),m=f||p||h||g,v=m?e(c.length,String):[],y=v.length;for(var x in c)(u||i.call(c,x))&&!(m&&(x=="length"||h&&(x=="offset"||x=="parent")||g&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||s(x,y)))&&v.push(x);return v}return pn=d,pn}var hn,fc;function qr(){if(fc)return hn;fc=1;var e=Object.prototype;function r(t){var n=t&&t.constructor,s=typeof n=="function"&&n.prototype||e;return t===s}return hn=r,hn}var gn,pc;function hc(){if(pc)return gn;pc=1;function e(r,t){return function(n){return r(t(n))}}return gn=e,gn}var mn,gc;function Yg(){if(gc)return mn;gc=1;var e=hc(),r=e(Object.keys,Object);return mn=r,mn}var vn,mc;function yn(){if(mc)return vn;mc=1;var e=qr(),r=Yg(),t=Object.prototype,n=t.hasOwnProperty;function s(a){if(!e(a))return r(a);var o=[];for(var i in Object(a))n.call(a,i)&&i!="constructor"&&o.push(i);return o}return vn=s,vn}var xn,vc;function Be(){if(vc)return xn;vc=1;var e=fr(),r=ln();function t(n){return n!=null&&r(n.length)&&!e(n)}return xn=t,xn}var bn,yc;function ze(){if(yc)return bn;yc=1;var e=dc(),r=yn(),t=Be();function n(s){return t(s)?e(s):r(s)}return bn=n,bn}var kn,xc;function Xg(){if(xc)return kn;xc=1;var e=pr(),r=ze();function t(n,s){return n&&e(s,r(s),n)}return kn=t,kn}var _n,bc;function Zg(){if(bc)return _n;bc=1;function e(r){var t=[];if(r!=null)for(var n in Object(r))t.push(n);return t}return _n=e,_n}var Sn,kc;function Qg(){if(kc)return Sn;kc=1;var e=je(),r=qr(),t=Zg(),n=Object.prototype,s=n.hasOwnProperty;function a(o){if(!e(o))return t(o);var i=r(o),d=[];for(var c in o)c=="constructor"&&(i||!s.call(o,c))||d.push(c);return d}return Sn=a,Sn}var wn,_c;function Ve(){if(_c)return wn;_c=1;var e=dc(),r=Qg(),t=Be();function n(s){return t(s)?e(s,!0):r(s)}return wn=n,wn}var Tn,Sc;function em(){if(Sc)return Tn;Sc=1;var e=pr(),r=Ve();function t(n,s){return n&&e(s,r(s),n)}return Tn=t,Tn}var yr={exports:{}};yr.exports;var wc;function Tc(){return wc||(wc=1,(function(e,r){var t=Oe(),n=r&&!r.nodeType&&r,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,o=a?t.Buffer:void 0,i=o?o.allocUnsafe:void 0;function d(c,u){if(u)return c.slice();var f=c.length,p=i?i(f):new c.constructor(f);return c.copy(p),p}e.exports=d})(yr,yr.exports)),yr.exports}var En,Ec;function Nc(){if(Ec)return En;Ec=1;function e(r,t){var n=-1,s=r.length;for(t||(t=Array(s));++n<s;)t[n]=r[n];return t}return En=e,En}var Nn,Cc;function jc(){if(Cc)return Nn;Cc=1;function e(r,t){for(var n=-1,s=r==null?0:r.length,a=0,o=[];++n<s;){var i=r[n];t(i,n,r)&&(o[a++]=i)}return o}return Nn=e,Nn}var Cn,Ic;function Rc(){if(Ic)return Cn;Ic=1;function e(){return[]}return Cn=e,Cn}var jn,Oc;function In(){if(Oc)return jn;Oc=1;var e=jc(),r=Rc(),t=Object.prototype,n=t.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(o){return o==null?[]:(o=Object(o),e(s(o),function(i){return n.call(o,i)}))}:r;return jn=a,jn}var Rn,Pc;function rm(){if(Pc)return Rn;Pc=1;var e=pr(),r=In();function t(n,s){return e(n,r(n),s)}return Rn=t,Rn}var On,Ac;function Pn(){if(Ac)return On;Ac=1;function e(r,t){for(var n=-1,s=t.length,a=r.length;++n<s;)r[a+n]=t[n];return r}return On=e,On}var An,Lc;function Dr(){if(Lc)return An;Lc=1;var e=hc(),r=e(Object.getPrototypeOf,Object);return An=r,An}var Ln,qc;function Dc(){if(qc)return Ln;qc=1;var e=Pn(),r=Dr(),t=In(),n=Rc(),s=Object.getOwnPropertySymbols,a=s?function(o){for(var i=[];o;)e(i,t(o)),o=r(o);return i}:n;return Ln=a,Ln}var qn,Mc;function tm(){if(Mc)return qn;Mc=1;var e=pr(),r=Dc();function t(n,s){return e(n,r(n),s)}return qn=t,qn}var Dn,Wc;function Bc(){if(Wc)return Dn;Wc=1;var e=Pn(),r=be();function t(n,s,a){var o=s(n);return r(n)?o:e(o,a(n))}return Dn=t,Dn}var Mn,Fc;function $c(){if(Fc)return Mn;Fc=1;var e=Bc(),r=In(),t=ze();function n(s){return e(s,t,r)}return Mn=n,Mn}var Wn,zc;function nm(){if(zc)return Wn;zc=1;var e=Bc(),r=Dc(),t=Ve();function n(s){return e(s,t,r)}return Wn=n,Wn}var Bn,Hc;function am(){if(Hc)return Bn;Hc=1;var e=Ge(),r=Oe(),t=e(r,"DataView");return Bn=t,Bn}var Fn,Kc;function sm(){if(Kc)return Fn;Kc=1;var e=Ge(),r=Oe(),t=e(r,"Promise");return Fn=t,Fn}var $n,Uc;function Jc(){if(Uc)return $n;Uc=1;var e=Ge(),r=Oe(),t=e(r,"Set");return $n=t,$n}var zn,Gc;function om(){if(Gc)return zn;Gc=1;var e=Ge(),r=Oe(),t=e(r,"WeakMap");return zn=t,zn}var Hn,Vc;function nr(){if(Vc)return Hn;Vc=1;var e=am(),r=Ct(),t=sm(),n=Jc(),s=om(),a=Je(),o=Sl(),i="[object Map]",d="[object Object]",c="[object Promise]",u="[object Set]",f="[object WeakMap]",p="[object DataView]",h=o(e),g=o(r),m=o(t),v=o(n),y=o(s),x=a;return(e&&x(new e(new ArrayBuffer(1)))!=p||r&&x(new r)!=i||t&&x(t.resolve())!=c||n&&x(new n)!=u||s&&x(new s)!=f)&&(x=function(b){var k=a(b),w=k==d?b.constructor:void 0,j=w?o(w):"";if(j)switch(j){case h:return p;case g:return i;case m:return c;case v:return u;case y:return f}return k}),Hn=x,Hn}var Kn,Yc;function im(){if(Yc)return Kn;Yc=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n){var s=n.length,a=new n.constructor(s);return s&&typeof n[0]=="string"&&r.call(n,"index")&&(a.index=n.index,a.input=n.input),a}return Kn=t,Kn}var Un,Xc;function Zc(){if(Xc)return Un;Xc=1;var e=Oe(),r=e.Uint8Array;return Un=r,Un}var Jn,Qc;function Gn(){if(Qc)return Jn;Qc=1;var e=Zc();function r(t){var n=new t.constructor(t.byteLength);return new e(n).set(new e(t)),n}return Jn=r,Jn}var Vn,eu;function lm(){if(eu)return Vn;eu=1;var e=Gn();function r(t,n){var s=n?e(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.byteLength)}return Vn=r,Vn}var Yn,ru;function cm(){if(ru)return Yn;ru=1;var e=/\w*$/;function r(t){var n=new t.constructor(t.source,e.exec(t));return n.lastIndex=t.lastIndex,n}return Yn=r,Yn}var Xn,tu;function um(){if(tu)return Xn;tu=1;var e=rr(),r=e?e.prototype:void 0,t=r?r.valueOf:void 0;function n(s){return t?Object(t.call(s)):{}}return Xn=n,Xn}var Zn,nu;function au(){if(nu)return Zn;nu=1;var e=Gn();function r(t,n){var s=n?e(t.buffer):t.buffer;return new t.constructor(s,t.byteOffset,t.length)}return Zn=r,Zn}var Qn,su;function dm(){if(su)return Qn;su=1;var e=Gn(),r=lm(),t=cm(),n=um(),s=au(),a="[object Boolean]",o="[object Date]",i="[object Map]",d="[object Number]",c="[object RegExp]",u="[object Set]",f="[object String]",p="[object Symbol]",h="[object ArrayBuffer]",g="[object DataView]",m="[object Float32Array]",v="[object Float64Array]",y="[object Int8Array]",x="[object Int16Array]",b="[object Int32Array]",k="[object Uint8Array]",w="[object Uint8ClampedArray]",j="[object Uint16Array]",N="[object Uint32Array]";function L(T,C,S){var q=T.constructor;switch(C){case h:return e(T);case a:case o:return new q(+T);case g:return r(T,S);case m:case v:case y:case x:case b:case k:case w:case j:case N:return s(T,S);case i:return new q;case d:case f:return new q(T);case c:return t(T);case u:return new q;case p:return n(T)}}return Qn=L,Qn}var ea,ou;function iu(){if(ou)return ea;ou=1;var e=je(),r=Object.create,t=(function(){function n(){}return function(s){if(!e(s))return{};if(r)return r(s);n.prototype=s;var a=new n;return n.prototype=void 0,a}})();return ea=t,ea}var ra,lu;function cu(){if(lu)return ra;lu=1;var e=iu(),r=Dr(),t=qr();function n(s){return typeof s.constructor=="function"&&!t(s)?e(r(s)):{}}return ra=n,ra}var ta,uu;function fm(){if(uu)return ta;uu=1;var e=nr(),r=De(),t="[object Map]";function n(s){return r(s)&&e(s)==t}return ta=n,ta}var na,du;function pm(){if(du)return na;du=1;var e=fm(),r=Lr(),t=dn(),n=t&&t.isMap,s=n?r(n):e;return na=s,na}var aa,fu;function hm(){if(fu)return aa;fu=1;var e=nr(),r=De(),t="[object Set]";function n(s){return r(s)&&e(s)==t}return aa=n,aa}var sa,pu;function gm(){if(pu)return sa;pu=1;var e=hm(),r=Lr(),t=dn(),n=t&&t.isSet,s=n?r(n):e;return sa=s,sa}var oa,hu;function gu(){if(hu)return oa;hu=1;var e=Rr(),r=Gt(),t=Pr(),n=Xg(),s=em(),a=Tc(),o=Nc(),i=rm(),d=tm(),c=$c(),u=nm(),f=nr(),p=im(),h=dm(),g=cu(),m=be(),v=tr(),y=pm(),x=je(),b=gm(),k=ze(),w=Ve(),j=1,N=2,L=4,T="[object Arguments]",C="[object Array]",S="[object Boolean]",q="[object Date]",I="[object Error]",O="[object Function]",F="[object GeneratorFunction]",W="[object Map]",V="[object Number]",Z="[object Object]",ne="[object RegExp]",ee="[object Set]",D="[object String]",Y="[object Symbol]",se="[object WeakMap]",R="[object ArrayBuffer]",M="[object DataView]",_="[object Float32Array]",B="[object Float64Array]",z="[object Int8Array]",Q="[object Int16Array]",G="[object Int32Array]",oe="[object Uint8Array]",H="[object Uint8ClampedArray]",$="[object Uint16Array]",K="[object Uint32Array]",U={};U[T]=U[C]=U[R]=U[M]=U[S]=U[q]=U[_]=U[B]=U[z]=U[Q]=U[G]=U[W]=U[V]=U[Z]=U[ne]=U[ee]=U[D]=U[Y]=U[oe]=U[H]=U[$]=U[K]=!0,U[I]=U[O]=U[se]=!1;function J(te,ue,fe,me,de,pe){var ve,Te=ue&j,ye=ue&N,E=ue&L;if(fe&&(ve=de?fe(te,me,de,pe):fe(te)),ve!==void 0)return ve;if(!x(te))return te;var X=m(te);if(X){if(ve=p(te),!Te)return o(te,ve)}else{var ae=f(te),le=ae==O||ae==F;if(v(te))return a(te,Te);if(ae==Z||ae==T||le&&!de){if(ve=ye||le?{}:g(te),!Te)return ye?d(te,s(ve,te)):i(te,n(ve,te))}else{if(!U[ae])return de?te:{};ve=h(te,ae,Te)}}pe||(pe=new e);var ce=pe.get(te);if(ce)return ce;pe.set(te,ve),b(te)?te.forEach(function(re){ve.add(J(re,ue,fe,re,te,pe))}):y(te)&&te.forEach(function(re,xe){ve.set(xe,J(re,ue,fe,xe,te,pe))});var he=E?ye?u:c:ye?w:k,ke=X?void 0:he(te);return r(ke||te,function(re,xe){ke&&(xe=re,re=te[xe]),t(ve,xe,J(re,ue,fe,xe,te,pe))}),ve}return oa=J,oa}var ia,mu;function mm(){if(mu)return ia;mu=1;var e=gu(),r=4;function t(n){return e(n,r)}return ia=t,ia}var la,vu;function ca(){if(vu)return la;vu=1;function e(r){return function(){return r}}return la=e,la}var ua,yu;function vm(){if(yu)return ua;yu=1;function e(r){return function(t,n,s){for(var a=-1,o=Object(t),i=s(t),d=i.length;d--;){var c=i[r?d:++a];if(n(o[c],c,o)===!1)break}return t}}return ua=e,ua}var da,xu;function fa(){if(xu)return da;xu=1;var e=vm(),r=e();return da=r,da}var pa,bu;function ha(){if(bu)return pa;bu=1;var e=fa(),r=ze();function t(n,s){return n&&e(n,s,r)}return pa=t,pa}var ga,ku;function ym(){if(ku)return ga;ku=1;var e=Be();function r(t,n){return function(s,a){if(s==null)return s;if(!e(s))return t(s,a);for(var o=s.length,i=n?o:-1,d=Object(s);(n?i--:++i<o)&&a(d[i],i,d)!==!1;);return s}}return ga=r,ga}var ma,_u;function Mr(){if(_u)return ma;_u=1;var e=ha(),r=ym(),t=r(e);return ma=t,ma}var va,Su;function Ye(){if(Su)return va;Su=1;function e(r){return r}return va=e,va}var ya,wu;function Tu(){if(wu)return ya;wu=1;var e=Ye();function r(t){return typeof t=="function"?t:e}return ya=r,ya}var xa,Eu;function Nu(){if(Eu)return xa;Eu=1;var e=Gt(),r=Mr(),t=Tu(),n=be();function s(a,o){var i=n(a)?e:r;return i(a,t(o))}return xa=s,xa}var ba,Cu;function ju(){return Cu||(Cu=1,ba=Nu()),ba}var ka,Iu;function xm(){if(Iu)return ka;Iu=1;var e=Mr();function r(t,n){var s=[];return e(t,function(a,o,i){n(a,o,i)&&s.push(a)}),s}return ka=r,ka}var _a,Ru;function bm(){if(Ru)return _a;Ru=1;var e="__lodash_hash_undefined__";function r(t){return this.__data__.set(t,e),this}return _a=r,_a}var Sa,Ou;function km(){if(Ou)return Sa;Ou=1;function e(r){return this.__data__.has(r)}return Sa=e,Sa}var wa,Pu;function Au(){if(Pu)return wa;Pu=1;var e=Ht(),r=bm(),t=km();function n(s){var a=-1,o=s==null?0:s.length;for(this.__data__=new e;++a<o;)this.add(s[a])}return n.prototype.add=n.prototype.push=r,n.prototype.has=t,wa=n,wa}var Ta,Lu;function _m(){if(Lu)return Ta;Lu=1;function e(r,t){for(var n=-1,s=r==null?0:r.length;++n<s;)if(t(r[n],n,r))return!0;return!1}return Ta=e,Ta}var Ea,qu;function Du(){if(qu)return Ea;qu=1;function e(r,t){return r.has(t)}return Ea=e,Ea}var Na,Mu;function Wu(){if(Mu)return Na;Mu=1;var e=Au(),r=_m(),t=Du(),n=1,s=2;function a(o,i,d,c,u,f){var p=d&n,h=o.length,g=i.length;if(h!=g&&!(p&&g>h))return!1;var m=f.get(o),v=f.get(i);if(m&&v)return m==i&&v==o;var y=-1,x=!0,b=d&s?new e:void 0;for(f.set(o,i),f.set(i,o);++y<h;){var k=o[y],w=i[y];if(c)var j=p?c(w,k,y,i,o,f):c(k,w,y,o,i,f);if(j!==void 0){if(j)continue;x=!1;break}if(b){if(!r(i,function(N,L){if(!t(b,L)&&(k===N||u(k,N,d,c,f)))return b.push(L)})){x=!1;break}}else if(!(k===w||u(k,w,d,c,f))){x=!1;break}}return f.delete(o),f.delete(i),x}return Na=a,Na}var Ca,Bu;function Sm(){if(Bu)return Ca;Bu=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(s,a){n[++t]=[a,s]}),n}return Ca=e,Ca}var ja,Fu;function Ia(){if(Fu)return ja;Fu=1;function e(r){var t=-1,n=Array(r.size);return r.forEach(function(s){n[++t]=s}),n}return ja=e,ja}var Ra,$u;function wm(){if($u)return Ra;$u=1;var e=rr(),r=Zc(),t=er(),n=Wu(),s=Sm(),a=Ia(),o=1,i=2,d="[object Boolean]",c="[object Date]",u="[object Error]",f="[object Map]",p="[object Number]",h="[object RegExp]",g="[object Set]",m="[object String]",v="[object Symbol]",y="[object ArrayBuffer]",x="[object DataView]",b=e?e.prototype:void 0,k=b?b.valueOf:void 0;function w(j,N,L,T,C,S,q){switch(L){case x:if(j.byteLength!=N.byteLength||j.byteOffset!=N.byteOffset)return!1;j=j.buffer,N=N.buffer;case y:return!(j.byteLength!=N.byteLength||!S(new r(j),new r(N)));case d:case c:case p:return t(+j,+N);case u:return j.name==N.name&&j.message==N.message;case h:case m:return j==N+"";case f:var I=s;case g:var O=T&o;if(I||(I=a),j.size!=N.size&&!O)return!1;var F=q.get(j);if(F)return F==N;T|=i,q.set(j,N);var W=n(I(j),I(N),T,C,S,q);return q.delete(j),W;case v:if(k)return k.call(j)==k.call(N)}return!1}return Ra=w,Ra}var Oa,zu;function Tm(){if(zu)return Oa;zu=1;var e=$c(),r=1,t=Object.prototype,n=t.hasOwnProperty;function s(a,o,i,d,c,u){var f=i&r,p=e(a),h=p.length,g=e(o),m=g.length;if(h!=m&&!f)return!1;for(var v=h;v--;){var y=p[v];if(!(f?y in o:n.call(o,y)))return!1}var x=u.get(a),b=u.get(o);if(x&&b)return x==o&&b==a;var k=!0;u.set(a,o),u.set(o,a);for(var w=f;++v<h;){y=p[v];var j=a[y],N=o[y];if(d)var L=f?d(N,j,y,o,a,u):d(j,N,y,a,o,u);if(!(L===void 0?j===N||c(j,N,i,d,u):L)){k=!1;break}w||(w=y=="constructor")}if(k&&!w){var T=a.constructor,C=o.constructor;T!=C&&"constructor"in a&&"constructor"in o&&!(typeof T=="function"&&T instanceof T&&typeof C=="function"&&C instanceof C)&&(k=!1)}return u.delete(a),u.delete(o),k}return Oa=s,Oa}var Pa,Hu;function Em(){if(Hu)return Pa;Hu=1;var e=Rr(),r=Wu(),t=wm(),n=Tm(),s=nr(),a=be(),o=tr(),i=vr(),d=1,c="[object Arguments]",u="[object Array]",f="[object Object]",p=Object.prototype,h=p.hasOwnProperty;function g(m,v,y,x,b,k){var w=a(m),j=a(v),N=w?u:s(m),L=j?u:s(v);N=N==c?f:N,L=L==c?f:L;var T=N==f,C=L==f,S=N==L;if(S&&o(m)){if(!o(v))return!1;w=!0,T=!1}if(S&&!T)return k||(k=new e),w||i(m)?r(m,v,y,x,b,k):t(m,v,N,y,x,b,k);if(!(y&d)){var q=T&&h.call(m,"__wrapped__"),I=C&&h.call(v,"__wrapped__");if(q||I){var O=q?m.value():m,F=I?v.value():v;return k||(k=new e),b(O,F,y,x,k)}}return S?(k||(k=new e),n(m,v,y,x,b,k)):!1}return Pa=g,Pa}var Aa,Ku;function Uu(){if(Ku)return Aa;Ku=1;var e=Em(),r=De();function t(n,s,a,o,i){return n===s?!0:n==null||s==null||!r(n)&&!r(s)?n!==n&&s!==s:e(n,s,a,o,t,i)}return Aa=t,Aa}var La,Ju;function Nm(){if(Ju)return La;Ju=1;var e=Rr(),r=Uu(),t=1,n=2;function s(a,o,i,d){var c=i.length,u=c,f=!d;if(a==null)return!u;for(a=Object(a);c--;){var p=i[c];if(f&&p[2]?p[1]!==a[p[0]]:!(p[0]in a))return!1}for(;++c<u;){p=i[c];var h=p[0],g=a[h],m=p[1];if(f&&p[2]){if(g===void 0&&!(h in a))return!1}else{var v=new e;if(d)var y=d(g,m,h,a,o,v);if(!(y===void 0?r(m,g,t|n,d,v):y))return!1}}return!0}return La=s,La}var qa,Gu;function Vu(){if(Gu)return qa;Gu=1;var e=je();function r(t){return t===t&&!e(t)}return qa=r,qa}var Da,Yu;function Cm(){if(Yu)return Da;Yu=1;var e=Vu(),r=ze();function t(n){for(var s=r(n),a=s.length;a--;){var o=s[a],i=n[o];s[a]=[o,i,e(i)]}return s}return Da=t,Da}var Ma,Xu;function Zu(){if(Xu)return Ma;Xu=1;function e(r,t){return function(n){return n==null?!1:n[r]===t&&(t!==void 0||r in Object(n))}}return Ma=e,Ma}var Wa,Qu;function jm(){if(Qu)return Wa;Qu=1;var e=Nm(),r=Cm(),t=Zu();function n(s){var a=r(s);return a.length==1&&a[0][2]?t(a[0][0],a[0][1]):function(o){return o===s||e(o,s,a)}}return Wa=n,Wa}var Ba,ed;function ar(){if(ed)return Ba;ed=1;var e=Je(),r=De(),t="[object Symbol]";function n(s){return typeof s=="symbol"||r(s)&&e(s)==t}return Ba=n,Ba}var Fa,rd;function $a(){if(rd)return Fa;rd=1;var e=be(),r=ar(),t=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function s(a,o){if(e(a))return!1;var i=typeof a;return i=="number"||i=="symbol"||i=="boolean"||a==null||r(a)?!0:n.test(a)||!t.test(a)||o!=null&&a in Object(o)}return Fa=s,Fa}var za,td;function Im(){if(td)return za;td=1;var e=Ht(),r="Expected a function";function t(n,s){if(typeof n!="function"||s!=null&&typeof s!="function")throw new TypeError(r);var a=function(){var o=arguments,i=s?s.apply(this,o):o[0],d=a.cache;if(d.has(i))return d.get(i);var c=n.apply(this,o);return a.cache=d.set(i,c)||d,c};return a.cache=new(t.Cache||e),a}return t.Cache=e,za=t,za}var Ha,nd;function Rm(){if(nd)return Ha;nd=1;var e=Im(),r=500;function t(n){var s=e(n,function(o){return a.size===r&&a.clear(),o}),a=s.cache;return s}return Ha=t,Ha}var Ka,ad;function Om(){if(ad)return Ka;ad=1;var e=Rm(),r=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,t=/\\(\\)?/g,n=e(function(s){var a=[];return s.charCodeAt(0)===46&&a.push(""),s.replace(r,function(o,i,d,c){a.push(d?c.replace(t,"$1"):i||o)}),a});return Ka=n,Ka}var Ua,sd;function Wr(){if(sd)return Ua;sd=1;function e(r,t){for(var n=-1,s=r==null?0:r.length,a=Array(s);++n<s;)a[n]=t(r[n],n,r);return a}return Ua=e,Ua}var Ja,od;function Pm(){if(od)return Ja;od=1;var e=rr(),r=Wr(),t=be(),n=ar(),s=e?e.prototype:void 0,a=s?s.toString:void 0;function o(i){if(typeof i=="string")return i;if(t(i))return r(i,o)+"";if(n(i))return a?a.call(i):"";var d=i+"";return d=="0"&&1/i==-1/0?"-0":d}return Ja=o,Ja}var Ga,id;function ld(){if(id)return Ga;id=1;var e=Pm();function r(t){return t==null?"":e(t)}return Ga=r,Ga}var Va,cd;function Br(){if(cd)return Va;cd=1;var e=be(),r=$a(),t=Om(),n=ld();function s(a,o){return e(a)?a:r(a,o)?[a]:t(n(a))}return Va=s,Va}var Ya,ud;function xr(){if(ud)return Ya;ud=1;var e=ar();function r(t){if(typeof t=="string"||e(t))return t;var n=t+"";return n=="0"&&1/t==-1/0?"-0":n}return Ya=r,Ya}var Xa,dd;function Fr(){if(dd)return Xa;dd=1;var e=Br(),r=xr();function t(n,s){s=e(s,n);for(var a=0,o=s.length;n!=null&&a<o;)n=n[r(s[a++])];return a&&a==o?n:void 0}return Xa=t,Xa}var Za,fd;function Am(){if(fd)return Za;fd=1;var e=Fr();function r(t,n,s){var a=t==null?void 0:e(t,n);return a===void 0?s:a}return Za=r,Za}var Qa,pd;function Lm(){if(pd)return Qa;pd=1;function e(r,t){return r!=null&&t in Object(r)}return Qa=e,Qa}var es,hd;function gd(){if(hd)return es;hd=1;var e=Br(),r=hr(),t=be(),n=Ar(),s=ln(),a=xr();function o(i,d,c){d=e(d,i);for(var u=-1,f=d.length,p=!1;++u<f;){var h=a(d[u]);if(!(p=i!=null&&c(i,h)))break;i=i[h]}return p||++u!=f?p:(f=i==null?0:i.length,!!f&&s(f)&&n(h,f)&&(t(i)||r(i)))}return es=o,es}var rs,md;function vd(){if(md)return rs;md=1;var e=Lm(),r=gd();function t(n,s){return n!=null&&r(n,s,e)}return rs=t,rs}var ts,yd;function qm(){if(yd)return ts;yd=1;var e=Uu(),r=Am(),t=vd(),n=$a(),s=Vu(),a=Zu(),o=xr(),i=1,d=2;function c(u,f){return n(u)&&s(f)?a(o(u),f):function(p){var h=r(p,u);return h===void 0&&h===f?t(p,u):e(f,h,i|d)}}return ts=c,ts}var ns,xd;function bd(){if(xd)return ns;xd=1;function e(r){return function(t){return t?.[r]}}return ns=e,ns}var as,kd;function Dm(){if(kd)return as;kd=1;var e=Fr();function r(t){return function(n){return e(n,t)}}return as=r,as}var ss,_d;function Mm(){if(_d)return ss;_d=1;var e=bd(),r=Dm(),t=$a(),n=xr();function s(a){return t(a)?e(n(a)):r(a)}return ss=s,ss}var os,Sd;function Fe(){if(Sd)return os;Sd=1;var e=jm(),r=qm(),t=Ye(),n=be(),s=Mm();function a(o){return typeof o=="function"?o:o==null?t:typeof o=="object"?n(o)?r(o[0],o[1]):e(o):s(o)}return os=a,os}var is,wd;function Td(){if(wd)return is;wd=1;var e=jc(),r=xm(),t=Fe(),n=be();function s(a,o){var i=n(a)?e:r;return i(a,t(o,3))}return is=s,is}var ls,Ed;function Wm(){if(Ed)return ls;Ed=1;var e=Object.prototype,r=e.hasOwnProperty;function t(n,s){return n!=null&&r.call(n,s)}return ls=t,ls}var cs,Nd;function Cd(){if(Nd)return cs;Nd=1;var e=Wm(),r=gd();function t(n,s){return n!=null&&r(n,s,e)}return cs=t,cs}var us,jd;function Bm(){if(jd)return us;jd=1;var e=yn(),r=nr(),t=hr(),n=be(),s=Be(),a=tr(),o=qr(),i=vr(),d="[object Map]",c="[object Set]",u=Object.prototype,f=u.hasOwnProperty;function p(h){if(h==null)return!0;if(s(h)&&(n(h)||typeof h=="string"||typeof h.splice=="function"||a(h)||i(h)||t(h)))return!h.length;var g=r(h);if(g==d||g==c)return!h.size;if(o(h))return!e(h).length;for(var m in h)if(f.call(h,m))return!1;return!0}return us=p,us}var ds,Id;function Rd(){if(Id)return ds;Id=1;function e(r){return r===void 0}return ds=e,ds}var fs,Od;function Pd(){if(Od)return fs;Od=1;var e=Mr(),r=Be();function t(n,s){var a=-1,o=r(n)?Array(n.length):[];return e(n,function(i,d,c){o[++a]=s(i,d,c)}),o}return fs=t,fs}var ps,Ad;function Ld(){if(Ad)return ps;Ad=1;var e=Wr(),r=Fe(),t=Pd(),n=be();function s(a,o){var i=n(a)?e:t;return i(a,r(o,3))}return ps=s,ps}var hs,qd;function Fm(){if(qd)return hs;qd=1;function e(r,t,n,s){var a=-1,o=r==null?0:r.length;for(s&&o&&(n=r[++a]);++a<o;)n=t(n,r[a],a,r);return n}return hs=e,hs}var gs,Dd;function $m(){if(Dd)return gs;Dd=1;function e(r,t,n,s,a){return a(r,function(o,i,d){n=s?(s=!1,o):t(n,o,i,d)}),n}return gs=e,gs}var ms,Md;function Wd(){if(Md)return ms;Md=1;var e=Fm(),r=Mr(),t=Fe(),n=$m(),s=be();function a(o,i,d){var c=s(o)?e:n,u=arguments.length<3;return c(o,t(i,4),d,u,r)}return ms=a,ms}var vs,Bd;function zm(){if(Bd)return vs;Bd=1;var e=Je(),r=be(),t=De(),n="[object String]";function s(a){return typeof a=="string"||!r(a)&&t(a)&&e(a)==n}return vs=s,vs}var ys,Fd;function Hm(){if(Fd)return ys;Fd=1;var e=bd(),r=e("length");return ys=r,ys}var xs,$d;function Km(){if($d)return xs;$d=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",s=r+t+n,a="\\ufe0e\\ufe0f",o="\\u200d",i=RegExp("["+o+e+s+a+"]");function d(c){return i.test(c)}return xs=d,xs}var bs,zd;function Um(){if(zd)return bs;zd=1;var e="\\ud800-\\udfff",r="\\u0300-\\u036f",t="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",s=r+t+n,a="\\ufe0e\\ufe0f",o="["+e+"]",i="["+s+"]",d="\\ud83c[\\udffb-\\udfff]",c="(?:"+i+"|"+d+")",u="[^"+e+"]",f="(?:\\ud83c[\\udde6-\\uddff]){2}",p="[\\ud800-\\udbff][\\udc00-\\udfff]",h="\\u200d",g=c+"?",m="["+a+"]?",v="(?:"+h+"(?:"+[u,f,p].join("|")+")"+m+g+")*",y=m+g+v,x="(?:"+[u+i+"?",i,f,p,o].join("|")+")",b=RegExp(d+"(?="+d+")|"+x+y,"g");function k(w){for(var j=b.lastIndex=0;b.test(w);)++j;return j}return bs=k,bs}var ks,Hd;function Jm(){if(Hd)return ks;Hd=1;var e=Hm(),r=Km(),t=Um();function n(s){return r(s)?t(s):e(s)}return ks=n,ks}var _s,Kd;function Gm(){if(Kd)return _s;Kd=1;var e=yn(),r=nr(),t=Be(),n=zm(),s=Jm(),a="[object Map]",o="[object Set]";function i(d){if(d==null)return 0;if(t(d))return n(d)?s(d):d.length;var c=r(d);return c==a||c==o?d.size:e(d).length}return _s=i,_s}var Ss,Ud;function Vm(){if(Ud)return Ss;Ud=1;var e=Gt(),r=iu(),t=ha(),n=Fe(),s=Dr(),a=be(),o=tr(),i=fr(),d=je(),c=vr();function u(f,p,h){var g=a(f),m=g||o(f)||c(f);if(p=n(p,4),h==null){var v=f&&f.constructor;m?h=g?new v:[]:d(f)?h=i(v)?r(s(f)):{}:h={}}return(m?e:t)(f,function(y,x,b){return p(h,y,x,b)}),h}return Ss=u,Ss}var ws,Jd;function Ym(){if(Jd)return ws;Jd=1;var e=rr(),r=hr(),t=be(),n=e?e.isConcatSpreadable:void 0;function s(a){return t(a)||r(a)||!!(n&&a&&a[n])}return ws=s,ws}var Ts,Gd;function Es(){if(Gd)return Ts;Gd=1;var e=Pn(),r=Ym();function t(n,s,a,o,i){var d=-1,c=n.length;for(a||(a=r),i||(i=[]);++d<c;){var u=n[d];s>0&&a(u)?s>1?t(u,s-1,a,o,i):e(i,u):o||(i[i.length]=u)}return i}return Ts=t,Ts}var Ns,Vd;function Xm(){if(Vd)return Ns;Vd=1;function e(r,t,n){switch(n.length){case 0:return r.call(t);case 1:return r.call(t,n[0]);case 2:return r.call(t,n[0],n[1]);case 3:return r.call(t,n[0],n[1],n[2])}return r.apply(t,n)}return Ns=e,Ns}var Cs,Yd;function Xd(){if(Yd)return Cs;Yd=1;var e=Xm(),r=Math.max;function t(n,s,a){return s=r(s===void 0?n.length-1:s,0),function(){for(var o=arguments,i=-1,d=r(o.length-s,0),c=Array(d);++i<d;)c[i]=o[s+i];i=-1;for(var u=Array(s+1);++i<s;)u[i]=o[i];return u[s]=a(c),e(n,this,u)}}return Cs=t,Cs}var js,Zd;function Zm(){if(Zd)return js;Zd=1;var e=ca(),r=Jl(),t=Ye(),n=r?function(s,a){return r(s,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:t;return js=n,js}var Is,Qd;function Qm(){if(Qd)return Is;Qd=1;var e=800,r=16,t=Date.now;function n(s){var a=0,o=0;return function(){var i=t(),d=r-(i-o);if(o=i,d>0){if(++a>=e)return arguments[0]}else a=0;return s.apply(void 0,arguments)}}return Is=n,Is}var Rs,ef;function rf(){if(ef)return Rs;ef=1;var e=Zm(),r=Qm(),t=r(e);return Rs=t,Rs}var Os,tf;function $r(){if(tf)return Os;tf=1;var e=Ye(),r=Xd(),t=rf();function n(s,a){return t(r(s,a,e),s+"")}return Os=n,Os}var Ps,nf;function af(){if(nf)return Ps;nf=1;function e(r,t,n,s){for(var a=r.length,o=n+(s?1:-1);s?o--:++o<a;)if(t(r[o],o,r))return o;return-1}return Ps=e,Ps}var As,sf;function ev(){if(sf)return As;sf=1;function e(r){return r!==r}return As=e,As}var Ls,of;function rv(){if(of)return Ls;of=1;function e(r,t,n){for(var s=n-1,a=r.length;++s<a;)if(r[s]===t)return s;return-1}return Ls=e,Ls}var qs,lf;function tv(){if(lf)return qs;lf=1;var e=af(),r=ev(),t=rv();function n(s,a,o){return a===a?t(s,a,o):e(s,r,o)}return qs=n,qs}var Ds,cf;function nv(){if(cf)return Ds;cf=1;var e=tv();function r(t,n){var s=t==null?0:t.length;return!!s&&e(t,n,0)>-1}return Ds=r,Ds}var Ms,uf;function av(){if(uf)return Ms;uf=1;function e(r,t,n){for(var s=-1,a=r==null?0:r.length;++s<a;)if(n(t,r[s]))return!0;return!1}return Ms=e,Ms}var Ws,df;function sv(){if(df)return Ws;df=1;function e(){}return Ws=e,Ws}var Bs,ff;function ov(){if(ff)return Bs;ff=1;var e=Jc(),r=sv(),t=Ia(),n=1/0,s=e&&1/t(new e([,-0]))[1]==n?function(a){return new e(a)}:r;return Bs=s,Bs}var Fs,pf;function iv(){if(pf)return Fs;pf=1;var e=Au(),r=nv(),t=av(),n=Du(),s=ov(),a=Ia(),o=200;function i(d,c,u){var f=-1,p=r,h=d.length,g=!0,m=[],v=m;if(u)g=!1,p=t;else if(h>=o){var y=c?null:s(d);if(y)return a(y);g=!1,p=n,v=new e}else v=c?[]:m;e:for(;++f<h;){var x=d[f],b=c?c(x):x;if(x=u||x!==0?x:0,g&&b===b){for(var k=v.length;k--;)if(v[k]===b)continue e;c&&v.push(b),m.push(x)}else p(v,b,u)||(v!==m&&v.push(b),m.push(x))}return m}return Fs=i,Fs}var $s,hf;function gf(){if(hf)return $s;hf=1;var e=Be(),r=De();function t(n){return r(n)&&e(n)}return $s=t,$s}var zs,mf;function lv(){if(mf)return zs;mf=1;var e=Es(),r=$r(),t=iv(),n=gf(),s=r(function(a){return t(e(a,1,n,!0))});return zs=s,zs}var Hs,vf;function cv(){if(vf)return Hs;vf=1;var e=Wr();function r(t,n){return e(n,function(s){return t[s]})}return Hs=r,Hs}var Ks,yf;function xf(){if(yf)return Ks;yf=1;var e=cv(),r=ze();function t(n){return n==null?[]:e(n,r(n))}return Ks=t,Ks}var Us,bf;function Ie(){if(bf)return Us;bf=1;var e;if(typeof et=="function")try{e={clone:mm(),constant:ca(),each:ju(),filter:Td(),has:Cd(),isArray:be(),isEmpty:Bm(),isFunction:fr(),isUndefined:Rd(),keys:ze(),map:Ld(),reduce:Wd(),size:Gm(),transform:Vm(),union:lv(),values:xf()}}catch{}return e||(e=window._),Us=e,Us}var Js,kf;function Gs(){if(kf)return Js;kf=1;var e=Ie();Js=s;var r="\0",t="\0",n="";function s(u){this._isDirected=e.has(u,"directed")?u.directed:!0,this._isMultigraph=e.has(u,"multigraph")?u.multigraph:!1,this._isCompound=e.has(u,"compound")?u.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[t]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(u){return this._label=u,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(u){return e.isFunction(u)||(u=e.constant(u)),this._defaultNodeLabelFn=u,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var u=this;return e.filter(this.nodes(),function(f){return e.isEmpty(u._in[f])})},s.prototype.sinks=function(){var u=this;return e.filter(this.nodes(),function(f){return e.isEmpty(u._out[f])})},s.prototype.setNodes=function(u,f){var p=arguments,h=this;return e.each(u,function(g){p.length>1?h.setNode(g,f):h.setNode(g)}),this},s.prototype.setNode=function(u,f){return e.has(this._nodes,u)?(arguments.length>1&&(this._nodes[u]=f),this):(this._nodes[u]=arguments.length>1?f:this._defaultNodeLabelFn(u),this._isCompound&&(this._parent[u]=t,this._children[u]={},this._children[t][u]=!0),this._in[u]={},this._preds[u]={},this._out[u]={},this._sucs[u]={},++this._nodeCount,this)},s.prototype.node=function(u){return this._nodes[u]},s.prototype.hasNode=function(u){return e.has(this._nodes,u)},s.prototype.removeNode=function(u){var f=this;if(e.has(this._nodes,u)){var p=function(h){f.removeEdge(f._edgeObjs[h])};delete this._nodes[u],this._isCompound&&(this._removeFromParentsChildList(u),delete this._parent[u],e.each(this.children(u),function(h){f.setParent(h)}),delete this._children[u]),e.each(e.keys(this._in[u]),p),delete this._in[u],delete this._preds[u],e.each(e.keys(this._out[u]),p),delete this._out[u],delete this._sucs[u],--this._nodeCount}return this},s.prototype.setParent=function(u,f){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(f))f=t;else{f+="";for(var p=f;!e.isUndefined(p);p=this.parent(p))if(p===u)throw new Error("Setting "+f+" as parent of "+u+" would create a cycle");this.setNode(f)}return this.setNode(u),this._removeFromParentsChildList(u),this._parent[u]=f,this._children[f][u]=!0,this},s.prototype._removeFromParentsChildList=function(u){delete this._children[this._parent[u]][u]},s.prototype.parent=function(u){if(this._isCompound){var f=this._parent[u];if(f!==t)return f}},s.prototype.children=function(u){if(e.isUndefined(u)&&(u=t),this._isCompound){var f=this._children[u];if(f)return e.keys(f)}else{if(u===t)return this.nodes();if(this.hasNode(u))return[]}},s.prototype.predecessors=function(u){var f=this._preds[u];if(f)return e.keys(f)},s.prototype.successors=function(u){var f=this._sucs[u];if(f)return e.keys(f)},s.prototype.neighbors=function(u){var f=this.predecessors(u);if(f)return e.union(f,this.successors(u))},s.prototype.isLeaf=function(u){var f;return this.isDirected()?f=this.successors(u):f=this.neighbors(u),f.length===0},s.prototype.filterNodes=function(u){var f=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});f.setGraph(this.graph());var p=this;e.each(this._nodes,function(m,v){u(v)&&f.setNode(v,m)}),e.each(this._edgeObjs,function(m){f.hasNode(m.v)&&f.hasNode(m.w)&&f.setEdge(m,p.edge(m))});var h={};function g(m){var v=p.parent(m);return v===void 0||f.hasNode(v)?(h[m]=v,v):v in h?h[v]:g(v)}return this._isCompound&&e.each(f.nodes(),function(m){f.setParent(m,g(m))}),f},s.prototype.setDefaultEdgeLabel=function(u){return e.isFunction(u)||(u=e.constant(u)),this._defaultEdgeLabelFn=u,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(u,f){var p=this,h=arguments;return e.reduce(u,function(g,m){return h.length>1?p.setEdge(g,m,f):p.setEdge(g,m),m}),this},s.prototype.setEdge=function(){var u,f,p,h,g=!1,m=arguments[0];typeof m=="object"&&m!==null&&"v"in m?(u=m.v,f=m.w,p=m.name,arguments.length===2&&(h=arguments[1],g=!0)):(u=m,f=arguments[1],p=arguments[3],arguments.length>2&&(h=arguments[2],g=!0)),u=""+u,f=""+f,e.isUndefined(p)||(p=""+p);var v=i(this._isDirected,u,f,p);if(e.has(this._edgeLabels,v))return g&&(this._edgeLabels[v]=h),this;if(!e.isUndefined(p)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(u),this.setNode(f),this._edgeLabels[v]=g?h:this._defaultEdgeLabelFn(u,f,p);var y=d(this._isDirected,u,f,p);return u=y.v,f=y.w,Object.freeze(y),this._edgeObjs[v]=y,a(this._preds[f],u),a(this._sucs[u],f),this._in[f][v]=y,this._out[u][v]=y,this._edgeCount++,this},s.prototype.edge=function(u,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,u,f,p);return this._edgeLabels[h]},s.prototype.hasEdge=function(u,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,u,f,p);return e.has(this._edgeLabels,h)},s.prototype.removeEdge=function(u,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,u,f,p),g=this._edgeObjs[h];return g&&(u=g.v,f=g.w,delete this._edgeLabels[h],delete this._edgeObjs[h],o(this._preds[f],u),o(this._sucs[u],f),delete this._in[f][h],delete this._out[u][h],this._edgeCount--),this},s.prototype.inEdges=function(u,f){var p=this._in[u];if(p){var h=e.values(p);return f?e.filter(h,function(g){return g.v===f}):h}},s.prototype.outEdges=function(u,f){var p=this._out[u];if(p){var h=e.values(p);return f?e.filter(h,function(g){return g.w===f}):h}},s.prototype.nodeEdges=function(u,f){var p=this.inEdges(u,f);if(p)return p.concat(this.outEdges(u,f))};function a(u,f){u[f]?u[f]++:u[f]=1}function o(u,f){--u[f]||delete u[f]}function i(u,f,p,h){var g=""+f,m=""+p;if(!u&&g>m){var v=g;g=m,m=v}return g+n+m+n+(e.isUndefined(h)?r:h)}function d(u,f,p,h){var g=""+f,m=""+p;if(!u&&g>m){var v=g;g=m,m=v}var y={v:g,w:m};return h&&(y.name=h),y}function c(u,f){return i(u,f.v,f.w,f.name)}return Js}var Vs,_f;function uv(){return _f||(_f=1,Vs="2.1.8"),Vs}var Ys,Sf;function dv(){return Sf||(Sf=1,Ys={Graph:Gs(),version:uv()}),Ys}var Xs,wf;function fv(){if(wf)return Xs;wf=1;var e=Ie(),r=Gs();Xs={write:t,read:a};function t(o){var i={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:n(o),edges:s(o)};return e.isUndefined(o.graph())||(i.value=e.clone(o.graph())),i}function n(o){return e.map(o.nodes(),function(i){var d=o.node(i),c=o.parent(i),u={v:i};return e.isUndefined(d)||(u.value=d),e.isUndefined(c)||(u.parent=c),u})}function s(o){return e.map(o.edges(),function(i){var d=o.edge(i),c={v:i.v,w:i.w};return e.isUndefined(i.name)||(c.name=i.name),e.isUndefined(d)||(c.value=d),c})}function a(o){var i=new r(o.options).setGraph(o.value);return e.each(o.nodes,function(d){i.setNode(d.v,d.value),d.parent&&i.setParent(d.v,d.parent)}),e.each(o.edges,function(d){i.setEdge({v:d.v,w:d.w,name:d.name},d.value)}),i}return Xs}var Zs,Tf;function pv(){if(Tf)return Zs;Tf=1;var e=Ie();Zs=r;function r(t){var n={},s=[],a;function o(i){e.has(n,i)||(n[i]=!0,a.push(i),e.each(t.successors(i),o),e.each(t.predecessors(i),o))}return e.each(t.nodes(),function(i){a=[],o(i),a.length&&s.push(a)}),s}return Zs}var Qs,Ef;function Nf(){if(Ef)return Qs;Ef=1;var e=Ie();Qs=r;function r(){this._arr=[],this._keyIndices={}}return r.prototype.size=function(){return this._arr.length},r.prototype.keys=function(){return this._arr.map(function(t){return t.key})},r.prototype.has=function(t){return e.has(this._keyIndices,t)},r.prototype.priority=function(t){var n=this._keyIndices[t];if(n!==void 0)return this._arr[n].priority},r.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},r.prototype.add=function(t,n){var s=this._keyIndices;if(t=String(t),!e.has(s,t)){var a=this._arr,o=a.length;return s[t]=o,a.push({key:t,priority:n}),this._decrease(o),!0}return!1},r.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var t=this._arr.pop();return delete this._keyIndices[t.key],this._heapify(0),t.key},r.prototype.decrease=function(t,n){var s=this._keyIndices[t];if(n>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+t+" Old: "+this._arr[s].priority+" New: "+n);this._arr[s].priority=n,this._decrease(s)},r.prototype._heapify=function(t){var n=this._arr,s=2*t,a=s+1,o=t;s<n.length&&(o=n[s].priority<n[o].priority?s:o,a<n.length&&(o=n[a].priority<n[o].priority?a:o),o!==t&&(this._swap(t,o),this._heapify(o)))},r.prototype._decrease=function(t){for(var n=this._arr,s=n[t].priority,a;t!==0&&(a=t>>1,!(n[a].priority<s));)this._swap(t,a),t=a},r.prototype._swap=function(t,n){var s=this._arr,a=this._keyIndices,o=s[t],i=s[n];s[t]=i,s[n]=o,a[i.key]=t,a[o.key]=n},Qs}var eo,Cf;function jf(){if(Cf)return eo;Cf=1;var e=Ie(),r=Nf();eo=n;var t=e.constant(1);function n(a,o,i,d){return s(a,String(o),i||t,d||function(c){return a.outEdges(c)})}function s(a,o,i,d){var c={},u=new r,f,p,h=function(g){var m=g.v!==f?g.v:g.w,v=c[m],y=i(g),x=p.distance+y;if(y<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+g+" Weight: "+y);x<v.distance&&(v.distance=x,v.predecessor=f,u.decrease(m,x))};for(a.nodes().forEach(function(g){var m=g===o?0:Number.POSITIVE_INFINITY;c[g]={distance:m},u.add(g,m)});u.size()>0&&(f=u.removeMin(),p=c[f],p.distance!==Number.POSITIVE_INFINITY);)d(f).forEach(h);return c}return eo}var ro,If;function hv(){if(If)return ro;If=1;var e=jf(),r=Ie();ro=t;function t(n,s,a){return r.transform(n.nodes(),function(o,i){o[i]=e(n,i,s,a)},{})}return ro}var to,Rf;function Of(){if(Rf)return to;Rf=1;var e=Ie();to=r;function r(t){var n=0,s=[],a={},o=[];function i(d){var c=a[d]={onStack:!0,lowlink:n,index:n++};if(s.push(d),t.successors(d).forEach(function(p){e.has(a,p)?a[p].onStack&&(c.lowlink=Math.min(c.lowlink,a[p].index)):(i(p),c.lowlink=Math.min(c.lowlink,a[p].lowlink))}),c.lowlink===c.index){var u=[],f;do f=s.pop(),a[f].onStack=!1,u.push(f);while(d!==f);o.push(u)}}return t.nodes().forEach(function(d){e.has(a,d)||i(d)}),o}return to}var no,Pf;function gv(){if(Pf)return no;Pf=1;var e=Ie(),r=Of();no=t;function t(n){return e.filter(r(n),function(s){return s.length>1||s.length===1&&n.hasEdge(s[0],s[0])})}return no}var ao,Af;function mv(){if(Af)return ao;Af=1;var e=Ie();ao=t;var r=e.constant(1);function t(s,a,o){return n(s,a||r,o||function(i){return s.outEdges(i)})}function n(s,a,o){var i={},d=s.nodes();return d.forEach(function(c){i[c]={},i[c][c]={distance:0},d.forEach(function(u){c!==u&&(i[c][u]={distance:Number.POSITIVE_INFINITY})}),o(c).forEach(function(u){var f=u.v===c?u.w:u.v,p=a(u);i[c][f]={distance:p,predecessor:c}})}),d.forEach(function(c){var u=i[c];d.forEach(function(f){var p=i[f];d.forEach(function(h){var g=p[c],m=u[h],v=p[h],y=g.distance+m.distance;y<v.distance&&(v.distance=y,v.predecessor=m.predecessor)})})}),i}return ao}var so,Lf;function qf(){if(Lf)return so;Lf=1;var e=Ie();so=r,r.CycleException=t;function r(n){var s={},a={},o=[];function i(d){if(e.has(a,d))throw new t;e.has(s,d)||(a[d]=!0,s[d]=!0,e.each(n.predecessors(d),i),delete a[d],o.push(d))}if(e.each(n.sinks(),i),e.size(s)!==n.nodeCount())throw new t;return o}function t(){}return t.prototype=new Error,so}var oo,Df;function vv(){if(Df)return oo;Df=1;var e=qf();oo=r;function r(t){try{e(t)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return oo}var io,Mf;function Wf(){if(Mf)return io;Mf=1;var e=Ie();io=r;function r(n,s,a){e.isArray(s)||(s=[s]);var o=(n.isDirected()?n.successors:n.neighbors).bind(n),i=[],d={};return e.each(s,function(c){if(!n.hasNode(c))throw new Error("Graph does not have node: "+c);t(n,c,a==="post",d,o,i)}),i}function t(n,s,a,o,i,d){e.has(o,s)||(o[s]=!0,a||d.push(s),e.each(i(s),function(c){t(n,c,a,o,i,d)}),a&&d.push(s))}return io}var lo,Bf;function yv(){if(Bf)return lo;Bf=1;var e=Wf();lo=r;function r(t,n){return e(t,n,"post")}return lo}var co,Ff;function xv(){if(Ff)return co;Ff=1;var e=Wf();co=r;function r(t,n){return e(t,n,"pre")}return co}var uo,$f;function bv(){if($f)return uo;$f=1;var e=Ie(),r=Gs(),t=Nf();uo=n;function n(s,a){var o=new r,i={},d=new t,c;function u(p){var h=p.v===c?p.w:p.v,g=d.priority(h);if(g!==void 0){var m=a(p);m<g&&(i[h]=c,d.decrease(h,m))}}if(s.nodeCount()===0)return o;e.each(s.nodes(),function(p){d.add(p,Number.POSITIVE_INFINITY),o.setNode(p)}),d.decrease(s.nodes()[0],0);for(var f=!1;d.size()>0;){if(c=d.removeMin(),e.has(i,c))o.setEdge(c,i[c]);else{if(f)throw new Error("Input graph is not connected: "+s);f=!0}s.nodeEdges(c).forEach(u)}return o}return uo}var fo,zf;function kv(){return zf||(zf=1,fo={components:pv(),dijkstra:jf(),dijkstraAll:hv(),findCycles:gv(),floydWarshall:mv(),isAcyclic:vv(),postorder:yv(),preorder:xv(),prim:bv(),tarjan:Of(),topsort:qf()}),fo}var po,Hf;function _v(){if(Hf)return po;Hf=1;var e=dv();return po={Graph:e.Graph,json:fv(),alg:kv(),version:e.version},po}var ho,Kf;function Pe(){if(Kf)return ho;Kf=1;var e;if(typeof et=="function")try{e=_v()}catch{}return e||(e=window.graphlib),ho=e,ho}var go,Uf;function Sv(){if(Uf)return go;Uf=1;var e=gu(),r=1,t=4;function n(s){return e(s,r|t)}return go=n,go}var mo,Jf;function zr(){if(Jf)return mo;Jf=1;var e=er(),r=Be(),t=Ar(),n=je();function s(a,o,i){if(!n(i))return!1;var d=typeof o;return(d=="number"?r(i)&&t(o,i.length):d=="string"&&o in i)?e(i[o],a):!1}return mo=s,mo}var vo,Gf;function wv(){if(Gf)return vo;Gf=1;var e=$r(),r=er(),t=zr(),n=Ve(),s=Object.prototype,a=s.hasOwnProperty,o=e(function(i,d){i=Object(i);var c=-1,u=d.length,f=u>2?d[2]:void 0;for(f&&t(d[0],d[1],f)&&(u=1);++c<u;)for(var p=d[c],h=n(p),g=-1,m=h.length;++g<m;){var v=h[g],y=i[v];(y===void 0||r(y,s[v])&&!a.call(i,v))&&(i[v]=p[v])}return i});return vo=o,vo}var yo,Vf;function Tv(){if(Vf)return yo;Vf=1;var e=Fe(),r=Be(),t=ze();function n(s){return function(a,o,i){var d=Object(a);if(!r(a)){var c=e(o,3);a=t(a),o=function(f){return c(d[f],f,d)}}var u=s(a,o,i);return u>-1?d[c?a[u]:u]:void 0}}return yo=n,yo}var xo,Yf;function Ev(){if(Yf)return xo;Yf=1;var e=/\s/;function r(t){for(var n=t.length;n--&&e.test(t.charAt(n)););return n}return xo=r,xo}var bo,Xf;function Nv(){if(Xf)return bo;Xf=1;var e=Ev(),r=/^\s+/;function t(n){return n&&n.slice(0,e(n)+1).replace(r,"")}return bo=t,bo}var ko,Zf;function Cv(){if(Zf)return ko;Zf=1;var e=Nv(),r=je(),t=ar(),n=NaN,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,i=parseInt;function d(c){if(typeof c=="number")return c;if(t(c))return n;if(r(c)){var u=typeof c.valueOf=="function"?c.valueOf():c;c=r(u)?u+"":u}if(typeof c!="string")return c===0?c:+c;c=e(c);var f=a.test(c);return f||o.test(c)?i(c.slice(2),f?2:8):s.test(c)?n:+c}return ko=d,ko}var _o,Qf;function ep(){if(Qf)return _o;Qf=1;var e=Cv(),r=1/0,t=17976931348623157e292;function n(s){if(!s)return s===0?s:0;if(s=e(s),s===r||s===-r){var a=s<0?-1:1;return a*t}return s===s?s:0}return _o=n,_o}var So,rp;function jv(){if(rp)return So;rp=1;var e=ep();function r(t){var n=e(t),s=n%1;return n===n?s?n-s:n:0}return So=r,So}var wo,tp;function Iv(){if(tp)return wo;tp=1;var e=af(),r=Fe(),t=jv(),n=Math.max;function s(a,o,i){var d=a==null?0:a.length;if(!d)return-1;var c=i==null?0:t(i);return c<0&&(c=n(d+c,0)),e(a,r(o,3),c)}return wo=s,wo}var To,np;function Rv(){if(np)return To;np=1;var e=Tv(),r=Iv(),t=e(r);return To=t,To}var Eo,ap;function sp(){if(ap)return Eo;ap=1;var e=Es();function r(t){var n=t==null?0:t.length;return n?e(t,1):[]}return Eo=r,Eo}var No,op;function Ov(){if(op)return No;op=1;var e=fa(),r=Tu(),t=Ve();function n(s,a){return s==null?s:e(s,r(a),t)}return No=n,No}var Co,ip;function Pv(){if(ip)return Co;ip=1;function e(r){var t=r==null?0:r.length;return t?r[t-1]:void 0}return Co=e,Co}var jo,lp;function Av(){if(lp)return jo;lp=1;var e=Or(),r=ha(),t=Fe();function n(s,a){var o={};return a=t(a,3),r(s,function(i,d,c){e(o,d,a(i,d,c))}),o}return jo=n,jo}var Io,cp;function Ro(){if(cp)return Io;cp=1;var e=ar();function r(t,n,s){for(var a=-1,o=t.length;++a<o;){var i=t[a],d=n(i);if(d!=null&&(c===void 0?d===d&&!e(d):s(d,c)))var c=d,u=i}return u}return Io=r,Io}var Oo,up;function Lv(){if(up)return Oo;up=1;function e(r,t){return r>t}return Oo=e,Oo}var Po,dp;function qv(){if(dp)return Po;dp=1;var e=Ro(),r=Lv(),t=Ye();function n(s){return s&&s.length?e(s,t,r):void 0}return Po=n,Po}var Ao,fp;function pp(){if(fp)return Ao;fp=1;var e=Or(),r=er();function t(n,s,a){(a!==void 0&&!r(n[s],a)||a===void 0&&!(s in n))&&e(n,s,a)}return Ao=t,Ao}var Lo,hp;function Dv(){if(hp)return Lo;hp=1;var e=Je(),r=Dr(),t=De(),n="[object Object]",s=Function.prototype,a=Object.prototype,o=s.toString,i=a.hasOwnProperty,d=o.call(Object);function c(u){if(!t(u)||e(u)!=n)return!1;var f=r(u);if(f===null)return!0;var p=i.call(f,"constructor")&&f.constructor;return typeof p=="function"&&p instanceof p&&o.call(p)==d}return Lo=c,Lo}var qo,gp;function mp(){if(gp)return qo;gp=1;function e(r,t){if(!(t==="constructor"&&typeof r[t]=="function")&&t!="__proto__")return r[t]}return qo=e,qo}var Do,vp;function Mv(){if(vp)return Do;vp=1;var e=pr(),r=Ve();function t(n){return e(n,r(n))}return Do=t,Do}var Mo,yp;function Wv(){if(yp)return Mo;yp=1;var e=pp(),r=Tc(),t=au(),n=Nc(),s=cu(),a=hr(),o=be(),i=gf(),d=tr(),c=fr(),u=je(),f=Dv(),p=vr(),h=mp(),g=Mv();function m(v,y,x,b,k,w,j){var N=h(v,x),L=h(y,x),T=j.get(L);if(T){e(v,x,T);return}var C=w?w(N,L,x+"",v,y,j):void 0,S=C===void 0;if(S){var q=o(L),I=!q&&d(L),O=!q&&!I&&p(L);C=L,q||I||O?o(N)?C=N:i(N)?C=n(N):I?(S=!1,C=r(L,!0)):O?(S=!1,C=t(L,!0)):C=[]:f(L)||a(L)?(C=N,a(N)?C=g(N):(!u(N)||c(N))&&(C=s(L))):S=!1}S&&(j.set(L,C),k(C,L,b,w,j),j.delete(L)),e(v,x,C)}return Mo=m,Mo}var Wo,xp;function Bv(){if(xp)return Wo;xp=1;var e=Rr(),r=pp(),t=fa(),n=Wv(),s=je(),a=Ve(),o=mp();function i(d,c,u,f,p){d!==c&&t(c,function(h,g){if(p||(p=new e),s(h))n(d,c,g,u,i,f,p);else{var m=f?f(o(d,g),h,g+"",d,c,p):void 0;m===void 0&&(m=h),r(d,g,m)}},a)}return Wo=i,Wo}var Bo,bp;function Fv(){if(bp)return Bo;bp=1;var e=$r(),r=zr();function t(n){return e(function(s,a){var o=-1,i=a.length,d=i>1?a[i-1]:void 0,c=i>2?a[2]:void 0;for(d=n.length>3&&typeof d=="function"?(i--,d):void 0,c&&r(a[0],a[1],c)&&(d=i<3?void 0:d,i=1),s=Object(s);++o<i;){var u=a[o];u&&n(s,u,o,d)}return s})}return Bo=t,Bo}var Fo,kp;function $v(){if(kp)return Fo;kp=1;var e=Bv(),r=Fv(),t=r(function(n,s,a){e(n,s,a)});return Fo=t,Fo}var $o,_p;function Sp(){if(_p)return $o;_p=1;function e(r,t){return r<t}return $o=e,$o}var zo,wp;function zv(){if(wp)return zo;wp=1;var e=Ro(),r=Sp(),t=Ye();function n(s){return s&&s.length?e(s,t,r):void 0}return zo=n,zo}var Ho,Tp;function Hv(){if(Tp)return Ho;Tp=1;var e=Ro(),r=Fe(),t=Sp();function n(s,a){return s&&s.length?e(s,r(a,2),t):void 0}return Ho=n,Ho}var Ko,Ep;function Kv(){if(Ep)return Ko;Ep=1;var e=Oe(),r=function(){return e.Date.now()};return Ko=r,Ko}var Uo,Np;function Uv(){if(Np)return Uo;Np=1;var e=Pr(),r=Br(),t=Ar(),n=je(),s=xr();function a(o,i,d,c){if(!n(o))return o;i=r(i,o);for(var u=-1,f=i.length,p=f-1,h=o;h!=null&&++u<f;){var g=s(i[u]),m=d;if(g==="__proto__"||g==="constructor"||g==="prototype")return o;if(u!=p){var v=h[g];m=c?c(v,g,h):void 0,m===void 0&&(m=n(v)?v:t(i[u+1])?[]:{})}e(h,g,m),h=h[g]}return o}return Uo=a,Uo}var Jo,Cp;function Jv(){if(Cp)return Jo;Cp=1;var e=Fr(),r=Uv(),t=Br();function n(s,a,o){for(var i=-1,d=a.length,c={};++i<d;){var u=a[i],f=e(s,u);o(f,u)&&r(c,t(u,s),f)}return c}return Jo=n,Jo}var Go,jp;function Gv(){if(jp)return Go;jp=1;var e=Jv(),r=vd();function t(n,s){return e(n,s,function(a,o){return r(n,o)})}return Go=t,Go}var Vo,Ip;function Vv(){if(Ip)return Vo;Ip=1;var e=sp(),r=Xd(),t=rf();function n(s){return t(r(s,void 0,e),s+"")}return Vo=n,Vo}var Yo,Rp;function Yv(){if(Rp)return Yo;Rp=1;var e=Gv(),r=Vv(),t=r(function(n,s){return n==null?{}:e(n,s)});return Yo=t,Yo}var Xo,Op;function Xv(){if(Op)return Xo;Op=1;var e=Math.ceil,r=Math.max;function t(n,s,a,o){for(var i=-1,d=r(e((s-n)/(a||1)),0),c=Array(d);d--;)c[o?d:++i]=n,n+=a;return c}return Xo=t,Xo}var Zo,Pp;function Zv(){if(Pp)return Zo;Pp=1;var e=Xv(),r=zr(),t=ep();function n(s){return function(a,o,i){return i&&typeof i!="number"&&r(a,o,i)&&(o=i=void 0),a=t(a),o===void 0?(o=a,a=0):o=t(o),i=i===void 0?a<o?1:-1:t(i),e(a,o,i,s)}}return Zo=n,Zo}var Qo,Ap;function Qv(){if(Ap)return Qo;Ap=1;var e=Zv(),r=e();return Qo=r,Qo}var ei,Lp;function ey(){if(Lp)return ei;Lp=1;function e(r,t){var n=r.length;for(r.sort(t);n--;)r[n]=r[n].value;return r}return ei=e,ei}var ri,qp;function ry(){if(qp)return ri;qp=1;var e=ar();function r(t,n){if(t!==n){var s=t!==void 0,a=t===null,o=t===t,i=e(t),d=n!==void 0,c=n===null,u=n===n,f=e(n);if(!c&&!f&&!i&&t>n||i&&d&&u&&!c&&!f||a&&d&&u||!s&&u||!o)return 1;if(!a&&!i&&!f&&t<n||f&&s&&o&&!a&&!i||c&&s&&o||!d&&o||!u)return-1}return 0}return ri=r,ri}var ti,Dp;function ty(){if(Dp)return ti;Dp=1;var e=ry();function r(t,n,s){for(var a=-1,o=t.criteria,i=n.criteria,d=o.length,c=s.length;++a<d;){var u=e(o[a],i[a]);if(u){if(a>=c)return u;var f=s[a];return u*(f=="desc"?-1:1)}}return t.index-n.index}return ti=r,ti}var ni,Mp;function ny(){if(Mp)return ni;Mp=1;var e=Wr(),r=Fr(),t=Fe(),n=Pd(),s=ey(),a=Lr(),o=ty(),i=Ye(),d=be();function c(u,f,p){f.length?f=e(f,function(m){return d(m)?function(v){return r(v,m.length===1?m[0]:m)}:m}):f=[i];var h=-1;f=e(f,a(t));var g=n(u,function(m,v,y){var x=e(f,function(b){return b(m)});return{criteria:x,index:++h,value:m}});return s(g,function(m,v){return o(m,v,p)})}return ni=c,ni}var ai,Wp;function ay(){if(Wp)return ai;Wp=1;var e=Es(),r=ny(),t=$r(),n=zr(),s=t(function(a,o){if(a==null)return[];var i=o.length;return i>1&&n(a,o[0],o[1])?o=[]:i>2&&n(o[0],o[1],o[2])&&(o=[o[0]]),r(a,e(o,1),[])});return ai=s,ai}var si,Bp;function sy(){if(Bp)return si;Bp=1;var e=ld(),r=0;function t(n){var s=++r;return e(n)+s}return si=t,si}var oi,Fp;function oy(){if(Fp)return oi;Fp=1;function e(r,t,n){for(var s=-1,a=r.length,o=t.length,i={};++s<a;){var d=s<o?t[s]:void 0;n(i,r[s],d)}return i}return oi=e,oi}var ii,$p;function iy(){if($p)return ii;$p=1;var e=Pr(),r=oy();function t(n,s){return r(n||[],s||[],e)}return ii=t,ii}var li,zp;function ge(){if(zp)return li;zp=1;var e;if(typeof et=="function")try{e={cloneDeep:Sv(),constant:ca(),defaults:wv(),each:ju(),filter:Td(),find:Rv(),flatten:sp(),forEach:Nu(),forIn:Ov(),has:Cd(),isUndefined:Rd(),last:Pv(),map:Ld(),mapValues:Av(),max:qv(),merge:$v(),min:zv(),minBy:Hv(),now:Kv(),pick:Yv(),range:Qv(),reduce:Wd(),sortBy:ay(),uniqueId:sy(),values:xf(),zipObject:iy()}}catch{}return e||(e=window._),li=e,li}var ci,Hp;function ly(){if(Hp)return ci;Hp=1,ci=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,s=n._prev;if(s!==n)return r(s),s},e.prototype.enqueue=function(n){var s=this._sentinel;n._prev&&n._next&&r(n),n._next=s._next,s._next._prev=n,s._next=n,n._prev=s},e.prototype.toString=function(){for(var n=[],s=this._sentinel,a=s._prev;a!==s;)n.push(JSON.stringify(a,t)),a=a._prev;return"["+n.join(", ")+"]"};function r(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function t(n,s){if(n!=="_next"&&n!=="_prev")return s}return ci}var ui,Kp;function cy(){if(Kp)return ui;Kp=1;var e=ge(),r=Pe().Graph,t=ly();ui=s;var n=e.constant(1);function s(c,u){if(c.nodeCount()<=1)return[];var f=i(c,u||n),p=a(f.graph,f.buckets,f.zeroIdx);return e.flatten(e.map(p,function(h){return c.outEdges(h.v,h.w)}),!0)}function a(c,u,f){for(var p=[],h=u[u.length-1],g=u[0],m;c.nodeCount();){for(;m=g.dequeue();)o(c,u,f,m);for(;m=h.dequeue();)o(c,u,f,m);if(c.nodeCount()){for(var v=u.length-2;v>0;--v)if(m=u[v].dequeue(),m){p=p.concat(o(c,u,f,m,!0));break}}}return p}function o(c,u,f,p,h){var g=h?[]:void 0;return e.forEach(c.inEdges(p.v),function(m){var v=c.edge(m),y=c.node(m.v);h&&g.push({v:m.v,w:m.w}),y.out-=v,d(u,f,y)}),e.forEach(c.outEdges(p.v),function(m){var v=c.edge(m),y=m.w,x=c.node(y);x.in-=v,d(u,f,x)}),c.removeNode(p.v),g}function i(c,u){var f=new r,p=0,h=0;e.forEach(c.nodes(),function(v){f.setNode(v,{v,in:0,out:0})}),e.forEach(c.edges(),function(v){var y=f.edge(v.v,v.w)||0,x=u(v),b=y+x;f.setEdge(v.v,v.w,b),h=Math.max(h,f.node(v.v).out+=x),p=Math.max(p,f.node(v.w).in+=x)});var g=e.range(h+p+3).map(function(){return new t}),m=p+1;return e.forEach(f.nodes(),function(v){d(g,m,f.node(v))}),{graph:f,buckets:g,zeroIdx:m}}function d(c,u,f){f.out?f.in?c[f.out-f.in+u].enqueue(f):c[c.length-1].enqueue(f):c[0].enqueue(f)}return ui}var di,Up;function uy(){if(Up)return di;Up=1;var e=ge(),r=cy();di={run:t,undo:s};function t(a){var o=a.graph().acyclicer==="greedy"?r(a,i(a)):n(a);e.forEach(o,function(d){var c=a.edge(d);a.removeEdge(d),c.forwardName=d.name,c.reversed=!0,a.setEdge(d.w,d.v,c,e.uniqueId("rev"))});function i(d){return function(c){return d.edge(c).weight}}}function n(a){var o=[],i={},d={};function c(u){e.has(d,u)||(d[u]=!0,i[u]=!0,e.forEach(a.outEdges(u),function(f){e.has(i,f.w)?o.push(f):c(f.w)}),delete i[u])}return e.forEach(a.nodes(),c),o}function s(a){e.forEach(a.edges(),function(o){var i=a.edge(o);if(i.reversed){a.removeEdge(o);var d=i.forwardName;delete i.reversed,delete i.forwardName,a.setEdge(o.w,o.v,i,d)}})}return di}var fi,Jp;function Ne(){if(Jp)return fi;Jp=1;var e=ge(),r=Pe().Graph;fi={addDummyNode:t,simplify:n,asNonCompoundGraph:s,successorWeights:a,predecessorWeights:o,intersectRect:i,buildLayerMatrix:d,normalizeRanks:c,removeEmptyRanks:u,addBorderNode:f,maxRank:p,partition:h,time:g,notime:m};function t(v,y,x,b){var k;do k=e.uniqueId(b);while(v.hasNode(k));return x.dummy=y,v.setNode(k,x),k}function n(v){var y=new r().setGraph(v.graph());return e.forEach(v.nodes(),function(x){y.setNode(x,v.node(x))}),e.forEach(v.edges(),function(x){var b=y.edge(x.v,x.w)||{weight:0,minlen:1},k=v.edge(x);y.setEdge(x.v,x.w,{weight:b.weight+k.weight,minlen:Math.max(b.minlen,k.minlen)})}),y}function s(v){var y=new r({multigraph:v.isMultigraph()}).setGraph(v.graph());return e.forEach(v.nodes(),function(x){v.children(x).length||y.setNode(x,v.node(x))}),e.forEach(v.edges(),function(x){y.setEdge(x,v.edge(x))}),y}function a(v){var y=e.map(v.nodes(),function(x){var b={};return e.forEach(v.outEdges(x),function(k){b[k.w]=(b[k.w]||0)+v.edge(k).weight}),b});return e.zipObject(v.nodes(),y)}function o(v){var y=e.map(v.nodes(),function(x){var b={};return e.forEach(v.inEdges(x),function(k){b[k.v]=(b[k.v]||0)+v.edge(k).weight}),b});return e.zipObject(v.nodes(),y)}function i(v,y){var x=v.x,b=v.y,k=y.x-x,w=y.y-b,j=v.width/2,N=v.height/2;if(!k&&!w)throw new Error("Not possible to find intersection inside of the rectangle");var L,T;return Math.abs(w)*j>Math.abs(k)*N?(w<0&&(N=-N),L=N*k/w,T=N):(k<0&&(j=-j),L=j,T=j*w/k),{x:x+L,y:b+T}}function d(v){var y=e.map(e.range(p(v)+1),function(){return[]});return e.forEach(v.nodes(),function(x){var b=v.node(x),k=b.rank;e.isUndefined(k)||(y[k][b.order]=x)}),y}function c(v){var y=e.min(e.map(v.nodes(),function(x){return v.node(x).rank}));e.forEach(v.nodes(),function(x){var b=v.node(x);e.has(b,"rank")&&(b.rank-=y)})}function u(v){var y=e.min(e.map(v.nodes(),function(w){return v.node(w).rank})),x=[];e.forEach(v.nodes(),function(w){var j=v.node(w).rank-y;x[j]||(x[j]=[]),x[j].push(w)});var b=0,k=v.graph().nodeRankFactor;e.forEach(x,function(w,j){e.isUndefined(w)&&j%k!==0?--b:b&&e.forEach(w,function(N){v.node(N).rank+=b})})}function f(v,y,x,b){var k={width:0,height:0};return arguments.length>=4&&(k.rank=x,k.order=b),t(v,"border",k,y)}function p(v){return e.max(e.map(v.nodes(),function(y){var x=v.node(y).rank;if(!e.isUndefined(x))return x}))}function h(v,y){var x={lhs:[],rhs:[]};return e.forEach(v,function(b){y(b)?x.lhs.push(b):x.rhs.push(b)}),x}function g(v,y){var x=e.now();try{return y()}finally{console.log(v+" time: "+(e.now()-x)+"ms")}}function m(v,y){return y()}return fi}var pi,Gp;function dy(){if(Gp)return pi;Gp=1;var e=ge(),r=Ne();pi={run:t,undo:s};function t(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(o){n(a,o)})}function n(a,o){var i=o.v,d=a.node(i).rank,c=o.w,u=a.node(c).rank,f=o.name,p=a.edge(o),h=p.labelRank;if(u!==d+1){a.removeEdge(o);var g,m,v;for(v=0,++d;d<u;++v,++d)p.points=[],m={width:0,height:0,edgeLabel:p,edgeObj:o,rank:d},g=r.addDummyNode(a,"edge",m,"_d"),d===h&&(m.width=p.width,m.height=p.height,m.dummy="edge-label",m.labelpos=p.labelpos),a.setEdge(i,g,{weight:p.weight},f),v===0&&a.graph().dummyChains.push(g),i=g;a.setEdge(i,c,{weight:p.weight},f)}}function s(a){e.forEach(a.graph().dummyChains,function(o){var i=a.node(o),d=i.edgeLabel,c;for(a.setEdge(i.edgeObj,d);i.dummy;)c=a.successors(o)[0],a.removeNode(o),d.points.push({x:i.x,y:i.y}),i.dummy==="edge-label"&&(d.x=i.x,d.y=i.y,d.width=i.width,d.height=i.height),o=c,i=a.node(o)})}return pi}var hi,Vp;function Hr(){if(Vp)return hi;Vp=1;var e=ge();hi={longestPath:r,slack:t};function r(n){var s={};function a(o){var i=n.node(o);if(e.has(s,o))return i.rank;s[o]=!0;var d=e.min(e.map(n.outEdges(o),function(c){return a(c.w)-n.edge(c).minlen}));return(d===Number.POSITIVE_INFINITY||d===void 0||d===null)&&(d=0),i.rank=d}e.forEach(n.sources(),a)}function t(n,s){return n.node(s.w).rank-n.node(s.v).rank-n.edge(s).minlen}return hi}var gi,Yp;function Xp(){if(Yp)return gi;Yp=1;var e=ge(),r=Pe().Graph,t=Hr().slack;gi=n;function n(i){var d=new r({directed:!1}),c=i.nodes()[0],u=i.nodeCount();d.setNode(c,{});for(var f,p;s(d,i)<u;)f=a(d,i),p=d.hasNode(f.v)?t(i,f):-t(i,f),o(d,i,p);return d}function s(i,d){function c(u){e.forEach(d.nodeEdges(u),function(f){var p=f.v,h=u===p?f.w:p;!i.hasNode(h)&&!t(d,f)&&(i.setNode(h,{}),i.setEdge(u,h,{}),c(h))})}return e.forEach(i.nodes(),c),i.nodeCount()}function a(i,d){return e.minBy(d.edges(),function(c){if(i.hasNode(c.v)!==i.hasNode(c.w))return t(d,c)})}function o(i,d,c){e.forEach(i.nodes(),function(u){d.node(u).rank+=c})}return gi}var mi,Zp;function fy(){if(Zp)return mi;Zp=1;var e=ge(),r=Xp(),t=Hr().slack,n=Hr().longestPath,s=Pe().alg.preorder,a=Pe().alg.postorder,o=Ne().simplify;mi=i,i.initLowLimValues=f,i.initCutValues=d,i.calcCutValue=u,i.leaveEdge=h,i.enterEdge=g,i.exchangeEdges=m;function i(b){b=o(b),n(b);var k=r(b);f(k),d(k,b);for(var w,j;w=h(k);)j=g(k,b,w),m(k,b,w,j)}function d(b,k){var w=a(b,b.nodes());w=w.slice(0,w.length-1),e.forEach(w,function(j){c(b,k,j)})}function c(b,k,w){var j=b.node(w),N=j.parent;b.edge(w,N).cutvalue=u(b,k,w)}function u(b,k,w){var j=b.node(w),N=j.parent,L=!0,T=k.edge(w,N),C=0;return T||(L=!1,T=k.edge(N,w)),C=T.weight,e.forEach(k.nodeEdges(w),function(S){var q=S.v===w,I=q?S.w:S.v;if(I!==N){var O=q===L,F=k.edge(S).weight;if(C+=O?F:-F,y(b,w,I)){var W=b.edge(w,I).cutvalue;C+=O?-W:W}}}),C}function f(b,k){arguments.length<2&&(k=b.nodes()[0]),p(b,{},1,k)}function p(b,k,w,j,N){var L=w,T=b.node(j);return k[j]=!0,e.forEach(b.neighbors(j),function(C){e.has(k,C)||(w=p(b,k,w,C,j))}),T.low=L,T.lim=w++,N?T.parent=N:delete T.parent,w}function h(b){return e.find(b.edges(),function(k){return b.edge(k).cutvalue<0})}function g(b,k,w){var j=w.v,N=w.w;k.hasEdge(j,N)||(j=w.w,N=w.v);var L=b.node(j),T=b.node(N),C=L,S=!1;L.lim>T.lim&&(C=T,S=!0);var q=e.filter(k.edges(),function(I){return S===x(b,b.node(I.v),C)&&S!==x(b,b.node(I.w),C)});return e.minBy(q,function(I){return t(k,I)})}function m(b,k,w,j){var N=w.v,L=w.w;b.removeEdge(N,L),b.setEdge(j.v,j.w,{}),f(b),d(b,k),v(b,k)}function v(b,k){var w=e.find(b.nodes(),function(N){return!k.node(N).parent}),j=s(b,w);j=j.slice(1),e.forEach(j,function(N){var L=b.node(N).parent,T=k.edge(N,L),C=!1;T||(T=k.edge(L,N),C=!0),k.node(N).rank=k.node(L).rank+(C?T.minlen:-T.minlen)})}function y(b,k,w){return b.hasEdge(k,w)}function x(b,k,w){return w.low<=k.lim&&k.lim<=w.lim}return mi}var vi,Qp;function py(){if(Qp)return vi;Qp=1;var e=Hr(),r=e.longestPath,t=Xp(),n=fy();vi=s;function s(d){switch(d.graph().ranker){case"network-simplex":i(d);break;case"tight-tree":o(d);break;case"longest-path":a(d);break;default:i(d)}}var a=r;function o(d){r(d),t(d)}function i(d){n(d)}return vi}var yi,eh;function hy(){if(eh)return yi;eh=1;var e=ge();yi=r;function r(s){var a=n(s);e.forEach(s.graph().dummyChains,function(o){for(var i=s.node(o),d=i.edgeObj,c=t(s,a,d.v,d.w),u=c.path,f=c.lca,p=0,h=u[p],g=!0;o!==d.w;){if(i=s.node(o),g){for(;(h=u[p])!==f&&s.node(h).maxRank<i.rank;)p++;h===f&&(g=!1)}if(!g){for(;p<u.length-1&&s.node(h=u[p+1]).minRank<=i.rank;)p++;h=u[p]}s.setParent(o,h),o=s.successors(o)[0]}})}function t(s,a,o,i){var d=[],c=[],u=Math.min(a[o].low,a[i].low),f=Math.max(a[o].lim,a[i].lim),p,h;p=o;do p=s.parent(p),d.push(p);while(p&&(a[p].low>u||f>a[p].lim));for(h=p,p=i;(p=s.parent(p))!==h;)c.push(p);return{path:d.concat(c.reverse()),lca:h}}function n(s){var a={},o=0;function i(d){var c=o;e.forEach(s.children(d),i),a[d]={low:c,lim:o++}}return e.forEach(s.children(),i),a}return yi}var xi,rh;function gy(){if(rh)return xi;rh=1;var e=ge(),r=Ne();xi={run:t,cleanup:o};function t(i){var d=r.addDummyNode(i,"root",{},"_root"),c=s(i),u=e.max(e.values(c))-1,f=2*u+1;i.graph().nestingRoot=d,e.forEach(i.edges(),function(h){i.edge(h).minlen*=f});var p=a(i)+1;e.forEach(i.children(),function(h){n(i,d,f,p,u,c,h)}),i.graph().nodeRankFactor=f}function n(i,d,c,u,f,p,h){var g=i.children(h);if(!g.length){h!==d&&i.setEdge(d,h,{weight:0,minlen:c});return}var m=r.addBorderNode(i,"_bt"),v=r.addBorderNode(i,"_bb"),y=i.node(h);i.setParent(m,h),y.borderTop=m,i.setParent(v,h),y.borderBottom=v,e.forEach(g,function(x){n(i,d,c,u,f,p,x);var b=i.node(x),k=b.borderTop?b.borderTop:x,w=b.borderBottom?b.borderBottom:x,j=b.borderTop?u:2*u,N=k!==w?1:f-p[h]+1;i.setEdge(m,k,{weight:j,minlen:N,nestingEdge:!0}),i.setEdge(w,v,{weight:j,minlen:N,nestingEdge:!0})}),i.parent(h)||i.setEdge(d,m,{weight:0,minlen:f+p[h]})}function s(i){var d={};function c(u,f){var p=i.children(u);p&&p.length&&e.forEach(p,function(h){c(h,f+1)}),d[u]=f}return e.forEach(i.children(),function(u){c(u,1)}),d}function a(i){return e.reduce(i.edges(),function(d,c){return d+i.edge(c).weight},0)}function o(i){var d=i.graph();i.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(i.edges(),function(c){var u=i.edge(c);u.nestingEdge&&i.removeEdge(c)})}return xi}var bi,th;function my(){if(th)return bi;th=1;var e=ge(),r=Ne();bi=t;function t(s){function a(o){var i=s.children(o),d=s.node(o);if(i.length&&e.forEach(i,a),e.has(d,"minRank")){d.borderLeft=[],d.borderRight=[];for(var c=d.minRank,u=d.maxRank+1;c<u;++c)n(s,"borderLeft","_bl",o,d,c),n(s,"borderRight","_br",o,d,c)}}e.forEach(s.children(),a)}function n(s,a,o,i,d,c){var u={width:0,height:0,rank:c,borderType:a},f=d[a][c-1],p=r.addDummyNode(s,"border",u,o);d[a][c]=p,s.setParent(p,i),f&&s.setEdge(f,p,{weight:1})}return bi}var ki,nh;function vy(){if(nh)return ki;nh=1;var e=ge();ki={adjust:r,undo:t};function r(c){var u=c.graph().rankdir.toLowerCase();(u==="lr"||u==="rl")&&n(c)}function t(c){var u=c.graph().rankdir.toLowerCase();(u==="bt"||u==="rl")&&a(c),(u==="lr"||u==="rl")&&(i(c),n(c))}function n(c){e.forEach(c.nodes(),function(u){s(c.node(u))}),e.forEach(c.edges(),function(u){s(c.edge(u))})}function s(c){var u=c.width;c.width=c.height,c.height=u}function a(c){e.forEach(c.nodes(),function(u){o(c.node(u))}),e.forEach(c.edges(),function(u){var f=c.edge(u);e.forEach(f.points,o),e.has(f,"y")&&o(f)})}function o(c){c.y=-c.y}function i(c){e.forEach(c.nodes(),function(u){d(c.node(u))}),e.forEach(c.edges(),function(u){var f=c.edge(u);e.forEach(f.points,d),e.has(f,"x")&&d(f)})}function d(c){var u=c.x;c.x=c.y,c.y=u}return ki}var _i,ah;function yy(){if(ah)return _i;ah=1;var e=ge();_i=r;function r(t){var n={},s=e.filter(t.nodes(),function(c){return!t.children(c).length}),a=e.max(e.map(s,function(c){return t.node(c).rank})),o=e.map(e.range(a+1),function(){return[]});function i(c){if(!e.has(n,c)){n[c]=!0;var u=t.node(c);o[u.rank].push(c),e.forEach(t.successors(c),i)}}var d=e.sortBy(s,function(c){return t.node(c).rank});return e.forEach(d,i),o}return _i}var Si,sh;function xy(){if(sh)return Si;sh=1;var e=ge();Si=r;function r(n,s){for(var a=0,o=1;o<s.length;++o)a+=t(n,s[o-1],s[o]);return a}function t(n,s,a){for(var o=e.zipObject(a,e.map(a,function(p,h){return h})),i=e.flatten(e.map(s,function(p){return e.sortBy(e.map(n.outEdges(p),function(h){return{pos:o[h.w],weight:n.edge(h).weight}}),"pos")}),!0),d=1;d<a.length;)d<<=1;var c=2*d-1;d-=1;var u=e.map(new Array(c),function(){return 0}),f=0;return e.forEach(i.forEach(function(p){var h=p.pos+d;u[h]+=p.weight;for(var g=0;h>0;)h%2&&(g+=u[h+1]),h=h-1>>1,u[h]+=p.weight;f+=p.weight*g})),f}return Si}var wi,oh;function by(){if(oh)return wi;oh=1;var e=ge();wi=r;function r(t,n){return e.map(n,function(s){var a=t.inEdges(s);if(a.length){var o=e.reduce(a,function(i,d){var c=t.edge(d),u=t.node(d.v);return{sum:i.sum+c.weight*u.order,weight:i.weight+c.weight}},{sum:0,weight:0});return{v:s,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:s}})}return wi}var Ti,ih;function ky(){if(ih)return Ti;ih=1;var e=ge();Ti=r;function r(s,a){var o={};e.forEach(s,function(d,c){var u=o[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:c};e.isUndefined(d.barycenter)||(u.barycenter=d.barycenter,u.weight=d.weight)}),e.forEach(a.edges(),function(d){var c=o[d.v],u=o[d.w];!e.isUndefined(c)&&!e.isUndefined(u)&&(u.indegree++,c.out.push(o[d.w]))});var i=e.filter(o,function(d){return!d.indegree});return t(i)}function t(s){var a=[];function o(c){return function(u){u.merged||(e.isUndefined(u.barycenter)||e.isUndefined(c.barycenter)||u.barycenter>=c.barycenter)&&n(c,u)}}function i(c){return function(u){u.in.push(c),--u.indegree===0&&s.push(u)}}for(;s.length;){var d=s.pop();a.push(d),e.forEach(d.in.reverse(),o(d)),e.forEach(d.out,i(d))}return e.map(e.filter(a,function(c){return!c.merged}),function(c){return e.pick(c,["vs","i","barycenter","weight"])})}function n(s,a){var o=0,i=0;s.weight&&(o+=s.barycenter*s.weight,i+=s.weight),a.weight&&(o+=a.barycenter*a.weight,i+=a.weight),s.vs=a.vs.concat(s.vs),s.barycenter=o/i,s.weight=i,s.i=Math.min(a.i,s.i),a.merged=!0}return Ti}var Ei,lh;function _y(){if(lh)return Ei;lh=1;var e=ge(),r=Ne();Ei=t;function t(a,o){var i=r.partition(a,function(m){return e.has(m,"barycenter")}),d=i.lhs,c=e.sortBy(i.rhs,function(m){return-m.i}),u=[],f=0,p=0,h=0;d.sort(s(!!o)),h=n(u,c,h),e.forEach(d,function(m){h+=m.vs.length,u.push(m.vs),f+=m.barycenter*m.weight,p+=m.weight,h=n(u,c,h)});var g={vs:e.flatten(u,!0)};return p&&(g.barycenter=f/p,g.weight=p),g}function n(a,o,i){for(var d;o.length&&(d=e.last(o)).i<=i;)o.pop(),a.push(d.vs),i++;return i}function s(a){return function(o,i){return o.barycenter<i.barycenter?-1:o.barycenter>i.barycenter?1:a?i.i-o.i:o.i-i.i}}return Ei}var Ni,ch;function Sy(){if(ch)return Ni;ch=1;var e=ge(),r=by(),t=ky(),n=_y();Ni=s;function s(i,d,c,u){var f=i.children(d),p=i.node(d),h=p?p.borderLeft:void 0,g=p?p.borderRight:void 0,m={};h&&(f=e.filter(f,function(w){return w!==h&&w!==g}));var v=r(i,f);e.forEach(v,function(w){if(i.children(w.v).length){var j=s(i,w.v,c,u);m[w.v]=j,e.has(j,"barycenter")&&o(w,j)}});var y=t(v,c);a(y,m);var x=n(y,u);if(h&&(x.vs=e.flatten([h,x.vs,g],!0),i.predecessors(h).length)){var b=i.node(i.predecessors(h)[0]),k=i.node(i.predecessors(g)[0]);e.has(x,"barycenter")||(x.barycenter=0,x.weight=0),x.barycenter=(x.barycenter*x.weight+b.order+k.order)/(x.weight+2),x.weight+=2}return x}function a(i,d){e.forEach(i,function(c){c.vs=e.flatten(c.vs.map(function(u){return d[u]?d[u].vs:u}),!0)})}function o(i,d){e.isUndefined(i.barycenter)?(i.barycenter=d.barycenter,i.weight=d.weight):(i.barycenter=(i.barycenter*i.weight+d.barycenter*d.weight)/(i.weight+d.weight),i.weight+=d.weight)}return Ni}var Ci,uh;function wy(){if(uh)return Ci;uh=1;var e=ge(),r=Pe().Graph;Ci=t;function t(s,a,o){var i=n(s),d=new r({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(function(c){return s.node(c)});return e.forEach(s.nodes(),function(c){var u=s.node(c),f=s.parent(c);(u.rank===a||u.minRank<=a&&a<=u.maxRank)&&(d.setNode(c),d.setParent(c,f||i),e.forEach(s[o](c),function(p){var h=p.v===c?p.w:p.v,g=d.edge(h,c),m=e.isUndefined(g)?0:g.weight;d.setEdge(h,c,{weight:s.edge(p).weight+m})}),e.has(u,"minRank")&&d.setNode(c,{borderLeft:u.borderLeft[a],borderRight:u.borderRight[a]}))}),d}function n(s){for(var a;s.hasNode(a=e.uniqueId("_root")););return a}return Ci}var ji,dh;function Ty(){if(dh)return ji;dh=1;var e=ge();ji=r;function r(t,n,s){var a={},o;e.forEach(s,function(i){for(var d=t.parent(i),c,u;d;){if(c=t.parent(d),c?(u=a[c],a[c]=d):(u=o,o=d),u&&u!==d){n.setEdge(u,d);return}d=c}})}return ji}var Ii,fh;function Ey(){if(fh)return Ii;fh=1;var e=ge(),r=yy(),t=xy(),n=Sy(),s=wy(),a=Ty(),o=Pe().Graph,i=Ne();Ii=d;function d(p){var h=i.maxRank(p),g=c(p,e.range(1,h+1),"inEdges"),m=c(p,e.range(h-1,-1,-1),"outEdges"),v=r(p);f(p,v);for(var y=Number.POSITIVE_INFINITY,x,b=0,k=0;k<4;++b,++k){u(b%2?g:m,b%4>=2),v=i.buildLayerMatrix(p);var w=t(p,v);w<y&&(k=0,x=e.cloneDeep(v),y=w)}f(p,x)}function c(p,h,g){return e.map(h,function(m){return s(p,m,g)})}function u(p,h){var g=new o;e.forEach(p,function(m){var v=m.graph().root,y=n(m,v,g,h);e.forEach(y.vs,function(x,b){m.node(x).order=b}),a(m,g,y.vs)})}function f(p,h){e.forEach(h,function(g){e.forEach(g,function(m,v){p.node(m).order=v})})}return Ii}var Ri,ph;function Ny(){if(ph)return Ri;ph=1;var e=ge(),r=Pe().Graph,t=Ne();Ri={positionX:g,findType1Conflicts:n,findType2Conflicts:s,addConflict:o,hasConflict:i,verticalAlignment:d,horizontalCompaction:c,alignCoordinates:p,findSmallestWidthAlignment:f,balance:h};function n(y,x){var b={};function k(w,j){var N=0,L=0,T=w.length,C=e.last(j);return e.forEach(j,function(S,q){var I=a(y,S),O=I?y.node(I).order:T;(I||S===C)&&(e.forEach(j.slice(L,q+1),function(F){e.forEach(y.predecessors(F),function(W){var V=y.node(W),Z=V.order;(Z<N||O<Z)&&!(V.dummy&&y.node(F).dummy)&&o(b,W,F)})}),L=q+1,N=O)}),j}return e.reduce(x,k),b}function s(y,x){var b={};function k(j,N,L,T,C){var S;e.forEach(e.range(N,L),function(q){S=j[q],y.node(S).dummy&&e.forEach(y.predecessors(S),function(I){var O=y.node(I);O.dummy&&(O.order<T||O.order>C)&&o(b,I,S)})})}function w(j,N){var L=-1,T,C=0;return e.forEach(N,function(S,q){if(y.node(S).dummy==="border"){var I=y.predecessors(S);I.length&&(T=y.node(I[0]).order,k(N,C,q,L,T),C=q,L=T)}k(N,C,N.length,T,j.length)}),N}return e.reduce(x,w),b}function a(y,x){if(y.node(x).dummy)return e.find(y.predecessors(x),function(b){return y.node(b).dummy})}function o(y,x,b){if(x>b){var k=x;x=b,b=k}var w=y[x];w||(y[x]=w={}),w[b]=!0}function i(y,x,b){if(x>b){var k=x;x=b,b=k}return e.has(y[x],b)}function d(y,x,b,k){var w={},j={},N={};return e.forEach(x,function(L){e.forEach(L,function(T,C){w[T]=T,j[T]=T,N[T]=C})}),e.forEach(x,function(L){var T=-1;e.forEach(L,function(C){var S=k(C);if(S.length){S=e.sortBy(S,function(W){return N[W]});for(var q=(S.length-1)/2,I=Math.floor(q),O=Math.ceil(q);I<=O;++I){var F=S[I];j[C]===C&&T<N[F]&&!i(b,C,F)&&(j[F]=C,j[C]=w[C]=w[F],T=N[F])}}})}),{root:w,align:j}}function c(y,x,b,k,w){var j={},N=u(y,x,b,w),L=w?"borderLeft":"borderRight";function T(q,I){for(var O=N.nodes(),F=O.pop(),W={};F;)W[F]?q(F):(W[F]=!0,O.push(F),O=O.concat(I(F))),F=O.pop()}function C(q){j[q]=N.inEdges(q).reduce(function(I,O){return Math.max(I,j[O.v]+N.edge(O))},0)}function S(q){var I=N.outEdges(q).reduce(function(F,W){return Math.min(F,j[W.w]-N.edge(W))},Number.POSITIVE_INFINITY),O=y.node(q);I!==Number.POSITIVE_INFINITY&&O.borderType!==L&&(j[q]=Math.max(j[q],I))}return T(C,N.predecessors.bind(N)),T(S,N.successors.bind(N)),e.forEach(k,function(q){j[q]=j[b[q]]}),j}function u(y,x,b,k){var w=new r,j=y.graph(),N=m(j.nodesep,j.edgesep,k);return e.forEach(x,function(L){var T;e.forEach(L,function(C){var S=b[C];if(w.setNode(S),T){var q=b[T],I=w.edge(q,S);w.setEdge(q,S,Math.max(N(y,C,T),I||0))}T=C})}),w}function f(y,x){return e.minBy(e.values(x),function(b){var k=Number.NEGATIVE_INFINITY,w=Number.POSITIVE_INFINITY;return e.forIn(b,function(j,N){var L=v(y,N)/2;k=Math.max(j+L,k),w=Math.min(j-L,w)}),k-w})}function p(y,x){var b=e.values(x),k=e.min(b),w=e.max(b);e.forEach(["u","d"],function(j){e.forEach(["l","r"],function(N){var L=j+N,T=y[L],C;if(T!==x){var S=e.values(T);C=N==="l"?k-e.min(S):w-e.max(S),C&&(y[L]=e.mapValues(T,function(q){return q+C}))}})})}function h(y,x){return e.mapValues(y.ul,function(b,k){if(x)return y[x.toLowerCase()][k];var w=e.sortBy(e.map(y,k));return(w[1]+w[2])/2})}function g(y){var x=t.buildLayerMatrix(y),b=e.merge(n(y,x),s(y,x)),k={},w;e.forEach(["u","d"],function(N){w=N==="u"?x:e.values(x).reverse(),e.forEach(["l","r"],function(L){L==="r"&&(w=e.map(w,function(q){return e.values(q).reverse()}));var T=(N==="u"?y.predecessors:y.successors).bind(y),C=d(y,w,b,T),S=c(y,w,C.root,C.align,L==="r");L==="r"&&(S=e.mapValues(S,function(q){return-q})),k[N+L]=S})});var j=f(y,k);return p(k,j),h(k,y.graph().align)}function m(y,x,b){return function(k,w,j){var N=k.node(w),L=k.node(j),T=0,C;if(T+=N.width/2,e.has(N,"labelpos"))switch(N.labelpos.toLowerCase()){case"l":C=-N.width/2;break;case"r":C=N.width/2;break}if(C&&(T+=b?C:-C),C=0,T+=(N.dummy?x:y)/2,T+=(L.dummy?x:y)/2,T+=L.width/2,e.has(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":C=L.width/2;break;case"r":C=-L.width/2;break}return C&&(T+=b?C:-C),C=0,T}}function v(y,x){return y.node(x).width}return Ri}var Oi,hh;function Cy(){if(hh)return Oi;hh=1;var e=ge(),r=Ne(),t=Ny().positionX;Oi=n;function n(a){a=r.asNonCompoundGraph(a),s(a),e.forEach(t(a),function(o,i){a.node(i).x=o})}function s(a){var o=r.buildLayerMatrix(a),i=a.graph().ranksep,d=0;e.forEach(o,function(c){var u=e.max(e.map(c,function(f){return a.node(f).height}));e.forEach(c,function(f){a.node(f).y=d+u/2}),d+=u+i})}return Oi}var Pi,gh;function jy(){if(gh)return Pi;gh=1;var e=ge(),r=uy(),t=dy(),n=py(),s=Ne().normalizeRanks,a=hy(),o=Ne().removeEmptyRanks,i=gy(),d=my(),c=vy(),u=Ey(),f=Cy(),p=Ne(),h=Pe().Graph;Pi=g;function g(R,M){var _=M&&M.debugTiming?p.time:p.notime;_("layout",function(){var B=_(" buildLayoutGraph",function(){return T(R)});_(" runLayout",function(){m(B,_)}),_(" updateInputGraph",function(){v(R,B)})})}function m(R,M){M(" makeSpaceForEdgeLabels",function(){C(R)}),M(" removeSelfEdges",function(){ne(R)}),M(" acyclic",function(){r.run(R)}),M(" nestingGraph.run",function(){i.run(R)}),M(" rank",function(){n(p.asNonCompoundGraph(R))}),M(" injectEdgeLabelProxies",function(){S(R)}),M(" removeEmptyRanks",function(){o(R)}),M(" nestingGraph.cleanup",function(){i.cleanup(R)}),M(" normalizeRanks",function(){s(R)}),M(" assignRankMinMax",function(){q(R)}),M(" removeEdgeLabelProxies",function(){I(R)}),M(" normalize.run",function(){t.run(R)}),M(" parentDummyChains",function(){a(R)}),M(" addBorderSegments",function(){d(R)}),M(" order",function(){u(R)}),M(" insertSelfEdges",function(){ee(R)}),M(" adjustCoordinateSystem",function(){c.adjust(R)}),M(" position",function(){f(R)}),M(" positionSelfEdges",function(){D(R)}),M(" removeBorderNodes",function(){Z(R)}),M(" normalize.undo",function(){t.undo(R)}),M(" fixupEdgeLabelCoords",function(){W(R)}),M(" undoCoordinateSystem",function(){c.undo(R)}),M(" translateGraph",function(){O(R)}),M(" assignNodeIntersects",function(){F(R)}),M(" reversePoints",function(){V(R)}),M(" acyclic.undo",function(){r.undo(R)})}function v(R,M){e.forEach(R.nodes(),function(_){var B=R.node(_),z=M.node(_);B&&(B.x=z.x,B.y=z.y,M.children(_).length&&(B.width=z.width,B.height=z.height))}),e.forEach(R.edges(),function(_){var B=R.edge(_),z=M.edge(_);B.points=z.points,e.has(z,"x")&&(B.x=z.x,B.y=z.y)}),R.graph().width=M.graph().width,R.graph().height=M.graph().height}var y=["nodesep","edgesep","ranksep","marginx","marginy"],x={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},b=["acyclicer","ranker","rankdir","align"],k=["width","height"],w={width:0,height:0},j=["minlen","weight","width","height","labeloffset"],N={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},L=["labelpos"];function T(R){var M=new h({multigraph:!0,compound:!0}),_=se(R.graph());return M.setGraph(e.merge({},x,Y(_,y),e.pick(_,b))),e.forEach(R.nodes(),function(B){var z=se(R.node(B));M.setNode(B,e.defaults(Y(z,k),w)),M.setParent(B,R.parent(B))}),e.forEach(R.edges(),function(B){var z=se(R.edge(B));M.setEdge(B,e.merge({},N,Y(z,j),e.pick(z,L)))}),M}function C(R){var M=R.graph();M.ranksep/=2,e.forEach(R.edges(),function(_){var B=R.edge(_);B.minlen*=2,B.labelpos.toLowerCase()!=="c"&&(M.rankdir==="TB"||M.rankdir==="BT"?B.width+=B.labeloffset:B.height+=B.labeloffset)})}function S(R){e.forEach(R.edges(),function(M){var _=R.edge(M);if(_.width&&_.height){var B=R.node(M.v),z=R.node(M.w),Q={rank:(z.rank-B.rank)/2+B.rank,e:M};p.addDummyNode(R,"edge-proxy",Q,"_ep")}})}function q(R){var M=0;e.forEach(R.nodes(),function(_){var B=R.node(_);B.borderTop&&(B.minRank=R.node(B.borderTop).rank,B.maxRank=R.node(B.borderBottom).rank,M=e.max(M,B.maxRank))}),R.graph().maxRank=M}function I(R){e.forEach(R.nodes(),function(M){var _=R.node(M);_.dummy==="edge-proxy"&&(R.edge(_.e).labelRank=_.rank,R.removeNode(M))})}function O(R){var M=Number.POSITIVE_INFINITY,_=0,B=Number.POSITIVE_INFINITY,z=0,Q=R.graph(),G=Q.marginx||0,oe=Q.marginy||0;function H($){var K=$.x,U=$.y,J=$.width,te=$.height;M=Math.min(M,K-J/2),_=Math.max(_,K+J/2),B=Math.min(B,U-te/2),z=Math.max(z,U+te/2)}e.forEach(R.nodes(),function($){H(R.node($))}),e.forEach(R.edges(),function($){var K=R.edge($);e.has(K,"x")&&H(K)}),M-=G,B-=oe,e.forEach(R.nodes(),function($){var K=R.node($);K.x-=M,K.y-=B}),e.forEach(R.edges(),function($){var K=R.edge($);e.forEach(K.points,function(U){U.x-=M,U.y-=B}),e.has(K,"x")&&(K.x-=M),e.has(K,"y")&&(K.y-=B)}),Q.width=_-M+G,Q.height=z-B+oe}function F(R){e.forEach(R.edges(),function(M){var _=R.edge(M),B=R.node(M.v),z=R.node(M.w),Q,G;_.points?(Q=_.points[0],G=_.points[_.points.length-1]):(_.points=[],Q=z,G=B),_.points.unshift(p.intersectRect(B,Q)),_.points.push(p.intersectRect(z,G))})}function W(R){e.forEach(R.edges(),function(M){var _=R.edge(M);if(e.has(_,"x"))switch((_.labelpos==="l"||_.labelpos==="r")&&(_.width-=_.labeloffset),_.labelpos){case"l":_.x-=_.width/2+_.labeloffset;break;case"r":_.x+=_.width/2+_.labeloffset;break}})}function V(R){e.forEach(R.edges(),function(M){var _=R.edge(M);_.reversed&&_.points.reverse()})}function Z(R){e.forEach(R.nodes(),function(M){if(R.children(M).length){var _=R.node(M),B=R.node(_.borderTop),z=R.node(_.borderBottom),Q=R.node(e.last(_.borderLeft)),G=R.node(e.last(_.borderRight));_.width=Math.abs(G.x-Q.x),_.height=Math.abs(z.y-B.y),_.x=Q.x+_.width/2,_.y=B.y+_.height/2}}),e.forEach(R.nodes(),function(M){R.node(M).dummy==="border"&&R.removeNode(M)})}function ne(R){e.forEach(R.edges(),function(M){if(M.v===M.w){var _=R.node(M.v);_.selfEdges||(_.selfEdges=[]),_.selfEdges.push({e:M,label:R.edge(M)}),R.removeEdge(M)}})}function ee(R){var M=p.buildLayerMatrix(R);e.forEach(M,function(_){var B=0;e.forEach(_,function(z,Q){var G=R.node(z);G.order=Q+B,e.forEach(G.selfEdges,function(oe){p.addDummyNode(R,"selfedge",{width:oe.label.width,height:oe.label.height,rank:G.rank,order:Q+ ++B,e:oe.e,label:oe.label},"_se")}),delete G.selfEdges})})}function D(R){e.forEach(R.nodes(),function(M){var _=R.node(M);if(_.dummy==="selfedge"){var B=R.node(_.e.v),z=B.x+B.width/2,Q=B.y,G=_.x-z,oe=B.height/2;R.setEdge(_.e,_.label),R.removeNode(M),_.label.points=[{x:z+2*G/3,y:Q-oe},{x:z+5*G/6,y:Q-oe},{x:z+G,y:Q},{x:z+5*G/6,y:Q+oe},{x:z+2*G/3,y:Q+oe}],_.label.x=_.x,_.label.y=_.y}})}function Y(R,M){return e.mapValues(e.pick(R,M),Number)}function se(R){var M={};return e.forEach(R,function(_,B){M[B.toLowerCase()]=_}),M}return Pi}var Ai,mh;function Iy(){if(mh)return Ai;mh=1;var e=ge(),r=Ne(),t=Pe().Graph;Ai={debugOrdering:n};function n(s){var a=r.buildLayerMatrix(s),o=new t({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(i){o.setNode(i,{label:i}),o.setParent(i,"layer"+s.node(i).rank)}),e.forEach(s.edges(),function(i){o.setEdge(i.v,i.w,{},i.name)}),e.forEach(a,function(i,d){var c="layer"+d;o.setNode(c,{rank:"same"}),e.reduce(i,function(u,f){return o.setEdge(u,f,{style:"invis"}),f})}),o}return Ai}var Li,vh;function Ry(){return vh||(vh=1,Li="0.8.5"),Li}var qi,yh;function Oy(){return yh||(yh=1,qi={graphlib:Pe(),layout:jy(),debug:Iy(),util:{time:Ne().time,notime:Ne().notime},version:Ry()}),qi}var Py=Oy();const xh=tg(Py);function sr(e,r="TB"){if(e.data?._layoutWidth&&e.data?._layoutHeight)return{width:e.data._layoutWidth,height:e.data._layoutHeight};let t=240,n=80;switch(e.type){case"decisionNode":t=212,n=160;break;case"forkNode":t=240,n=95;break;case"joinNode":t=240,n=95;break;case"dynamicPlaceholderNode":t=220,n=70;break;case"loopNode":t=320,n=200;break;case"subWorkflowNode":t=240,n=95;break;case"eventNode":t=240,n=85;break;case"default":t=240,n=40;break;case"plusNode":t=e.data.label&&e.data.label!=="+"?120:32,n=32;break;default:t=240,n=95;break}return{width:t,height:n}}function Ay(e,r,t=8){const n=[];if(e.length<t)return n;const s=new Map,a={},o={};e.forEach(f=>{s.set(f.id,f),a[f.id]=[],o[f.id]=[]}),r.forEach(f=>{a[f.source]&&a[f.source].push(f.target),o[f.target]&&o[f.target].push(f.source)});const i=new Set,d=new Set(["input","output","decisionNode","forkNode","joinNode","loopNode","default","plusNode"]),c=f=>!d.has(f.type||""),u=[...e].sort((f,p)=>f.position.y-p.position.y);for(const f of u){if(i.has(f.id)||!c(f)||a[f.id].length>1)continue;const p=[f.id];let h=f,g=a[h.id];for(;g&&g.length===1;){const m=g[0],v=s.get(m);if(!v||i.has(m)||!c(v)||o[m].length!==1)break;p.push(m),h=v,g=a[h.id]}p.length>=t&&(n.push(p),p.forEach(m=>i.add(m)))}return n}function Ly(e,r,t,n,s,a=5,o="view"){const i=r.find(x=>x.id===e[0]),{width:d,height:c}=sr(i||r[0],t),u=Math.max(.7,1-(e.length-10)/80),f=o==="edit"||o==="run"?1.15:1,p=Math.min(n,Math.round(60*u*f)),h=Math.min(s,Math.round(80*u*f)),g=d+p,m=c+h;let v=0,y=0;if(t==="TB"){const x=Math.ceil(e.length/a);v=a*g-p,y=x*m-h}else v=Math.ceil(e.length/a)*g-p,y=a*m-h;return v+=40,y+=40,{width:v,height:y,gridKW:g,gridKH:m,cols:a}}const Di=58,bh=20,qy=16;function Dy(e,r,t,n){if(e.length===0)return{positionedChildren:[],containerWidth:280,containerHeight:Di+50};const s=e.map(f=>({...f,parentId:void 0,extent:void 0})),{nodes:a}=Mi(s,r,{direction:t,mode:n,enableSnakeLayout:!1});let o=0,i=0;a.forEach(f=>{const{width:p,height:h}=sr(f,t);o=Math.max(o,f.position.x+p),i=Math.max(i,f.position.y+h)});const d=Math.max(300,o+bh*2),c=Di+i+qy;return{positionedChildren:a.map(f=>{const p=e.find(h=>h.id===f.id);return{...f,parentId:p.parentId,extent:p.extent,position:{x:f.position.x+bh,y:f.position.y+Di}}}),containerWidth:d,containerHeight:c}}function Mi(e,r,t={}){const{direction:n="TB",mode:s="view",enableSnakeLayout:a=!0,snakeColumns:o=5,snakeMinChainLength:i=8,snakeMinNodeCount:d=10}=t,c=e.length,u=e.filter(T=>T.type!=="plusNode").length;let f=n==="LR"?150:120,p=n==="LR"?120:100,h=f,g=p;if(c>15){let T=Math.max(.5,1-(c-15)/50),C=Math.max(.4,1-(c-15)/40);(s==="edit"||s==="run")&&(T=1-(1-T)*.5,C=1-(1-C)*.5),h=Math.round(f*T),g=Math.round(p*C)}const m=a&&u>d?Ay(e,r,i):[],v={};m.forEach((T,C)=>{T.forEach(S=>{v[S]=C})});const y=new xh.graphlib.Graph;y.setDefaultEdgeLabel(()=>({})),y.setGraph({rankdir:n,ranker:"network-simplex",ranksep:h,nodesep:g,edgesep:50,marginx:50,marginy:50});const x=new Set,b={};e.forEach(T=>{const C=v[T.id];if(C!==void 0){if(!x.has(C)){x.add(C);const S=Ly(m[C],e,n,g,h,o,s);b[C]=S,y.setNode(`__CHAIN_${C}`,{width:S.width,height:S.height})}}else{const{width:S,height:q}=sr(T,n);y.setNode(T.id,{width:S,height:q})}}),r.forEach(T=>{const C=v[T.source],S=v[T.target];let q=T.source,I=T.target;C!==void 0&&(q=`__CHAIN_${C}`),S!==void 0&&(I=`__CHAIN_${S}`),q!==I&&y.setEdge(q,I)}),xh.layout(y);const k={};for(const T of e)k[T.id]={...T};const w=[],j=new Set;e.forEach(T=>{if(v[T.id]===void 0){const C=y.node(T.id),S=k[T.id],{width:q,height:I}=sr(S,n);S.position={x:C.x-q/2,y:C.y-I/2},S.data={...S.data,sourcePosition:void 0,targetPosition:void 0},S.sourcePosition=n==="LR"?A.Position.Right:A.Position.Bottom,S.targetPosition=n==="LR"?A.Position.Left:A.Position.Top,w.push(S)}else j.add(T.id)}),m.forEach((T,C)=>{const S=`__CHAIN_${C}`,q=y.node(S),I=b[C],O=q.x-I.width/2+20,F=q.y-I.height/2+20,W=I.cols,V=I.gridKW,Z=I.gridKH;T.forEach((ne,ee)=>{const D=k[ne];let Y=0,se=0,R,M;if(n==="TB"){const _=Math.floor(ee/W),B=ee%W,z=_%2===0,Q=Math.ceil(T.length/W),G=_===Q-1,oe=T.length%W||W,H=G?(W-oe)*V/2:0;let $;z?$=B*V+H:$=(W-1-B)*V-H;const K=_*Z;Y=O+$,se=F+K;const U=G?oe:W;z?(M=A.Position.Left,R=A.Position.Right,B===U-1&&ee!==T.length-1&&(R=A.Position.Bottom),B===0&&ee!==0&&(M=A.Position.Top)):(M=A.Position.Right,R=A.Position.Left,B===U-1&&ee!==T.length-1&&(R=A.Position.Bottom),B===0&&ee!==0&&(M=A.Position.Top)),ee===0&&(M=A.Position.Top),ee===T.length-1&&(R=A.Position.Bottom)}else{const _=Math.floor(ee/W),B=ee%W,z=_%2===0,Q=Math.ceil(T.length/W),G=_===Q-1,oe=T.length%W||W,H=G?Math.max(0,(W-oe)*Z)/2:0,$=_*V;let K;z?K=B*Z+H:K=(W-1-B)*Z-H,Y=O+$,se=F+K;const U=G?oe:W;z?(M=A.Position.Top,R=A.Position.Bottom,B===U-1&&ee!==T.length-1&&(R=A.Position.Right),B===0&&ee!==0&&(M=A.Position.Left)):(M=A.Position.Bottom,R=A.Position.Top,B===U-1&&ee!==T.length-1&&(R=A.Position.Right),B===0&&ee!==0&&(M=A.Position.Left)),ee===0&&(M=A.Position.Left),ee===T.length-1&&(R=A.Position.Right)}D.position={x:Y,y:se},D.data={...D.data,sourcePosition:R,targetPosition:M},D.sourcePosition=R,D.targetPosition=M,w.push(D)})});const N=w.reduce((T,C)=>({...T,[C.id]:C}),{}),L=r.map(T=>{const C=N[T.source],S=N[T.target];if(!C||!S||j.has(C.id)||C.type!=="decisionNode")return T;const{width:q,height:I}=sr(C,n),{width:O,height:F}=sr(S,n),W={x:C.position.x+q/2,y:C.position.y+I/2},V={x:S.position.x+O/2,y:S.position.y+F/2};let Z=null;if(n==="TB"){const ne=q*.25;V.x<W.x-ne?Z="left":V.x>W.x+ne&&(Z="right")}else{const ne=I*.25;V.y<W.y-ne?Z="top":V.y>W.y+ne&&(Z="bottom")}return{...T,sourceHandle:Z}});return{nodes:w,edges:L}}function _e(e,r,t={}){const n=t.direction||"TB",s=t.mode||"view",a=e.filter(y=>y.parentId),o=e.filter(y=>!y.parentId);if(a.length===0)return Mi(e,r,t);const i=new Map(a.map(y=>[y.id,y])),d={},c=[];r.forEach(y=>{const x=i.get(y.source),b=i.get(y.target);if(x?.parentId&&x.parentId===b?.parentId){const k=x.parentId;d[k]||(d[k]=[]),d[k].push(y)}else c.push(y)});const u={};a.forEach(y=>{const x=y.parentId;u[x]||(u[x]=[]),u[x].push(y)});const f={},p=[];for(const[y,x]of Object.entries(u)){const b=d[y]||[],{positionedChildren:k,containerWidth:w,containerHeight:j}=Dy(x,b,n,s);f[y]={width:w,height:j},p.push(...k)}const h=o.map(y=>{if(y.type==="loopNode"&&f[y.id]){const{width:x,height:b}=f[y.id];return{...y,data:{...y.data,_layoutWidth:x,_layoutHeight:b},style:{...y.style,width:x,height:b}}}return y}),{nodes:g,edges:m}=Mi(h,c,t);return{nodes:[...g.map(y=>{if(y.type==="loopNode"&&f[y.id]){const{width:x,height:b}=f[y.id];return{...y,width:x,height:b,style:{...y.style,width:x,height:b}}}return y}),...p],edges:[...m,...Object.values(d).flat()]}}function Ce(e,r){if(!e)return null;for(const t of e){if(t.taskReferenceName===r)return t;if(t.decisionCases){for(const s of Object.keys(t.decisionCases)){const a=Ce(t.decisionCases[s],r);if(a)return a}const n=Ce(t.defaultCase,r);if(n)return n}if(t.forkTasks)for(const n of t.forkTasks){const s=Ce(n,r);if(s)return s}if(t.loopOver){const n=Ce(t.loopOver,r);if(n)return n}}return null}function Me(e,r){if(!e)return!1;const t=e.findIndex(n=>n.taskReferenceName===r);if(t!==-1)return e.splice(t,1),!0;for(const n of e){if(n.decisionCases){for(const s of Object.keys(n.decisionCases))if(Me(n.decisionCases[s],r))return!0;if(Me(n.defaultCase,r))return!0}if(n.forkTasks){for(const s of n.forkTasks)if(Me(s,r))return!0}if(n.loopOver&&Me(n.loopOver,r))return!0}return!1}function or(e,r){if(!e)return null;if(e.some(t=>t.taskReferenceName===r))return e;for(const t of e){if(t.decisionCases){for(const s of Object.values(t.decisionCases)){const a=or(s,r);if(a)return a}const n=or(t.defaultCase,r);if(n)return n}if(t.forkTasks)for(const n of t.forkTasks){const s=or(n,r);if(s)return s}if(t.loopOver){const n=or(t.loopOver,r);if(n)return n}}return null}function kh(e,r){const t=e.findIndex(n=>n.taskReferenceName===r);if(t<0)return null;for(let n=t+1;n<e.length;n++)if(e[n].type==="JOIN"||e[n].type==="EXCLUSIVE_JOIN")return e[n].taskReferenceName;return null}function _h(e,r){const t=e.findIndex(n=>n.taskReferenceName===r);if(t<0)return null;for(let n=t-1;n>=0;n--)if(e[n].type==="FORK_JOIN"||e[n].type==="FORK_JOIN_DYNAMIC")return e[n].taskReferenceName;return null}function Ae(e,r,t){if(!e)return!1;const n=e.findIndex(s=>s.taskReferenceName===r);if(n!==-1)return e.splice(n+1,0,t),!0;for(const s of e){if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(Ae(s.decisionCases[a],r,t))return!0;if(Ae(s.defaultCase,r,t))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(Ae(a,r,t))return!0}if(s.loopOver&&Ae(s.loopOver,r,t))return!0}return!1}function ir(e,r,t,n){for(const s of e||[]){if(s.taskReferenceName===r){if(t.branchCase==="default")return s.defaultCase||(s.defaultCase=[]),s.defaultCase.unshift(n),!0;if(t.branchCase!==void 0)return s.decisionCases||(s.decisionCases={}),s.decisionCases[t.branchCase]||(s.decisionCases[t.branchCase]=[]),s.decisionCases[t.branchCase].unshift(n),!0;if(t.forkIndex!==void 0)return s.forkTasks||(s.forkTasks=[]),s.forkTasks[t.forkIndex].unshift(n),!0;if(t.isLoopAdd)return s.loopOver||(s.loopOver=[]),s.loopOver.unshift(n),!0}if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(ir(s.decisionCases[a],r,t,n))return!0;if(ir(s.defaultCase,r,t,n))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(ir(a,r,t,n))return!0}if(s.loopOver&&ir(s.loopOver,r,t,n))return!0}return!1}function we(e){if(e)for(let r=0;r<e.length;r++){const t=e[r];if(t.type==="FORK_JOIN"&&r+1<e.length){const n=e[r+1];if(n.type==="JOIN"){const s=[];(t.forkTasks||[]).forEach(a=>{a&&a.length>0&&s.push(a[a.length-1].taskReferenceName)}),n.joinOn=s}}t.decisionCases&&(Object.values(t.decisionCases).forEach(n=>we(n)),t.defaultCase&&we(t.defaultCase)),t.forkTasks&&t.forkTasks.forEach(n=>we(n)),t.loopOver&&we(t.loopOver)}}const My=[{field:"name",type:"required",message:"工作流名称 (name) 必填"},{field:"version",type:"required",message:"工作流版本 (version) 必填"},{field:"tasks",type:"min_length",value:1,message:"工作流必须包含至少一个任务"}],Sh={common:[{field:"name",type:"required",message:"任务类型名称 (name) 必填"},{field:"taskReferenceName",type:"required",message:"引用名 (taskReferenceName) 必填"},{field:"taskReferenceName",type:"pattern",value:/^[a-zA-Z0-9_]+$/,message:"引用名仅允许字母、数字和下划线"},{field:"taskReferenceName",type:"unique",message:"引用名在工作流中必须唯一"}],types:{HTTP:[{field:"inputParameters.http_request.uri",type:"required",message:"HTTP 任务缺少请求地址 (uri) 配置"},{field:"inputParameters.http_request.method",type:"required",level:"warning",message:"HTTP 任务未指定 Method,建议配置"}],INLINE:[{field:"inputParameters.expression",type:"custom",validate:(e,r)=>!!(r?.inputParameters?.expression||r?.inputParameters?.scriptExpression),message:"INLINE 任务缺少脚本表达式 (expression)"}],LAMBDA:[{field:"inputParameters.scriptExpression",type:"required",message:"LAMBDA 任务缺少脚本表达式 (scriptExpression)"}],JSON_JQ_TRANSFORM:[{field:"inputParameters.queryExpression",type:"required",message:"JQ 任务缺少查询表达式 (queryExpression)"}],SUB_WORKFLOW:[{field:"subWorkflowParam.name",type:"required",message:"子工作流任务缺少子流程名称 (name)"}],START_WORKFLOW:[{field:"inputParameters.startWorkflow.name",type:"custom",validate:(e,r)=>!!r?.inputParameters?.startWorkflow?.name,message:"START_WORKFLOW 任务缺少目标工作流名称"}],DYNAMIC:[{field:"dynamicTaskNameParam",type:"required",message:"DYNAMIC 任务缺少 dynamicTaskNameParam 配置"}],TERMINATE:[{field:"inputParameters.terminationStatus",type:"required",level:"warning",message:"终止任务未指定状态 (terminationStatus)"},{field:"inputParameters.terminationStatus",type:"enum",value:["COMPLETED","FAILED"],message:"终止状态必须为 COMPLETED 或 FAILED"}],DO_WHILE:[{field:"loopCondition",type:"custom",validate:(e,r)=>!!(r?.loopCondition||r?.inputParameters?.items),message:"循环任务需要配置退出条件 (loopCondition) 或列表 (items)"}],DECISION:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"决策任务必须至少包含一个分支 (decisionCases)"},{field:"decisionCases",type:"custom",validate:e=>{const r=Object.keys(e||{});return new Set(r).size===r.length},message:"决策分支条件不能重复"}],SWITCH:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"Switch 任务必须至少包含一个分支"}],FORK_JOIN_DYNAMIC:[{field:"dynamicForkTasksParam",type:"custom",validate:(e,r)=>!!(r?.dynamicForkTasksParam||r?.forkTaskType||r?.forkTaskWorkflow),message:"FORK_JOIN_DYNAMIC 任务需要配置 dynamicForkTasksParam 或 forkTaskType 或 forkTaskWorkflow",level:"warning"}]}},Wy=(e,r)=>r.split(".").reduce((t,n)=>t&&t[n]!==void 0?t[n]:void 0,e),Wi=(e,r,t,n)=>{const{errors:s,warnings:a}=n,o=e.taskReferenceName||"GLOBAL";r.forEach(i=>{const d=Wy(e,i.field);let c=!0;switch(i.type){case"required":c=d!=null&&d!=="";break;case"min_length":c=Array.isArray(d)&&d.length>=i.value;break;case"pattern":c=i.value.test(d);break;case"enum":c=i.value.includes(d);break;case"unique":i.field==="taskReferenceName"&&d&&(t.taskRefs.has(d)?c=!1:t.taskRefs.add(d));break;case"custom":typeof i.validate=="function"&&(c=i.validate(d,e,t));break}if(!c){const u={type:e.taskReferenceName?"TASK":"GLOBAL",ref:o,message:i.message};i.level==="warning"?a.push(u):s.push(u)}})},Re=e=>{const r=[],t=[],n={taskRefs:new Set,taskMap:{}};if(!e)return{isValid:!1,errors:[{type:"GLOBAL",ref:"",message:"工作流定义为空"}],warnings:[]};if(Wi(e,My,n,{errors:r,warnings:t}),!e.tasks||e.tasks.length===0)return{isValid:!1,errors:r,warnings:t};const s=o=>{o.forEach(i=>{Wi(i,Sh.common,n,{errors:r,warnings:t});const d=Sh.types[i.type];d&&Wi(i,d,n,{errors:r,warnings:t}),i.decisionCases&&Object.keys(i.decisionCases).forEach(c=>{s(i.decisionCases[c])}),i.defaultCase&&s(i.defaultCase),i.forkTasks&&i.forkTasks.forEach(c=>s(c)),i.loopOver&&s(i.loopOver)})};s(e.tasks);const a=By(e.tasks);return r.push(...a),{isValid:r.length===0,errors:r,warnings:t}},By=e=>{const r=[],t=new Map,n=new Set,s=u=>{for(let f=0;f<u.length;f++){const p=u[f],h=p.taskReferenceName;if(n.add(h),t.has(h)||t.set(h,[]),f<u.length-1){const g=u[f+1].taskReferenceName;p.type!=="FORK_JOIN"&&p.type!=="FORK_JOIN_DYNAMIC"&&t.get(h).push(g)}if(p.decisionCases)for(const g of Object.values(p.decisionCases))g.length>0&&(t.get(h).push(g[0].taskReferenceName),s(g));if(p.defaultCase&&p.defaultCase.length>0&&(t.get(h).push(p.defaultCase[0].taskReferenceName),s(p.defaultCase)),p.forkTasks)for(const g of p.forkTasks)g.length>0&&(t.get(h).push(g[0].taskReferenceName),s(g));if(p.loopOver)for(const g of p.loopOver)n.add(g.taskReferenceName);if(p.joinOn)for(const g of p.joinOn)t.has(g)||t.set(g,[]),t.get(g).push(h)}};s(e);const a=0,o=1,i=2,d=new Map;for(const u of n)d.set(u,a);const c=u=>{d.set(u,o);const f=t.get(u)||[];for(const p of f)if(d.has(p)){if(d.get(p)===o)return r.push({type:"GLOBAL",ref:p,message:`检测到环路:任务 "${u}" → "${p}" 形成了循环依赖`}),!0;if(d.get(p)===a&&c(p))return!0}return d.set(u,i),!1};for(const u of n)d.get(u)===a&&c(u);return r};function Fy(e,r){const t=new Set(e),n={};e.forEach(i=>n[i]=0),r.forEach(i=>{t.has(i.source)&&t.has(i.target)&&(n[i.target]=(n[i.target]??0)+1)});const s=[];let a=e.filter(i=>n[i]===0);const o={...n};for(;a.length>0;){s.push([...a]);const i=[];a.forEach(d=>{r.forEach(c=>{c.source===d&&t.has(c.target)&&(o[c.target]--,o[c.target]===0&&i.push(c.target))})}),a=i}return s}const ie=lg()(cg(ug((e,r)=>({mode:"view",workflowDef:null,workflowInstance:null,nodes:[],edges:[],taskMap:{},layoutDirection:"TB",selectedTask:null,selectedTaskInstance:null,isDetailPanelOpen:!1,executionData:null,dynamicRuntimeTasksByFork:{},validationResults:{isValid:!0,errors:[],warnings:[]},theme:"dark",themeColor:"blue",edgeType:"smoothstep",nodesLocked:!0,copiedTask:null,viewMode:"standard",simState:{},isSimRunning:!1,workflowLoadKey:0,runState:"idle",pendingExecutionId:null,executionError:null,showRunPanel:!1,showAnalysisPanel:!1,focusedParamKey:null,setWorkflow:(t,n)=>{const s=n||r().layoutDirection,a=JSON.parse(JSON.stringify(t));we(a.tasks);const{nodes:o,edges:i,taskMap:d}=Ee(a,s,{hideEmptyBranches:r().mode!=="edit"}),{nodes:c,edges:u}=_e(o,i,{direction:s,mode:r().mode}),f=Re(a);e({workflowDef:a,nodes:c,edges:u,taskMap:d,validationResults:f,layoutDirection:s,workflowLoadKey:r().workflowLoadKey+1})},setMode:t=>{r().mode==="run"&&t!=="run"&&e({executionData:null,workflowInstance:null,dynamicRuntimeTasksByFork:{}}),e({mode:t});const{workflowDef:s,layoutDirection:a}=r();if(s){const{nodes:o,edges:i,taskMap:d}=Ee(s,a,{hideEmptyBranches:t!=="edit"}),{nodes:c,edges:u}=_e(o,i,{direction:a,mode:t});e({nodes:c,edges:u,taskMap:d})}},setExecutionData:t=>e({executionData:t,dynamicRuntimeTasksByFork:t===null?{}:r().dynamicRuntimeTasksByFork}),updateTaskStatus:(t,n)=>{const{executionData:s}=r();if(!s)return;const a={...s};a[t]&&(a[t]={...a[t],status:n},e({executionData:a}))},loadSampleExecution:async()=>{try{const n=await(await fetch("/sample-workflows/sample-execution.json")).json();r().importExecutionJSON(n)}catch(t){console.error("Failed to load sample execution:",t),alert("加载示例运行数据失败")}},importExecutionJSON:t=>{if(!t)return;let n=[],s=null,a=r().workflowDef;if(Array.isArray(t.tasks)?(n=t.tasks,t.workflowId&&t.status&&(s=t,t.workflowDefinition&&(a=t.workflowDefinition))):Array.isArray(t)&&(n=t),n.length===0)return;const o={};n.forEach(p=>{const h=p.referenceTaskName;h&&(o[h]||(o[h]={taskReferenceName:h,status:p.status,attempts:[],startTime:p.startTime,endTime:p.endTime,output:p.outputData,input:p.inputData,reasonForIncompletion:p.reasonForIncompletion,iteration:p.iteration}),o[h].attempts.push(p))}),Object.values(o).forEach(p=>{p.attempts.some(m=>m.iteration!==void 0&&m.iteration>0)?(p.attempts.sort((m,v)=>(m.iteration??0)-(v.iteration??0)),p.totalIterations=p.attempts.reduce((m,v)=>Math.max(m,v.iteration??0),0),p.startTime=p.attempts[0]?.startTime):p.attempts.sort((m,v)=>(m.retryCount??0)-(v.retryCount??0));const g=p.attempts[p.attempts.length-1];g&&(p.status=g.status,p.endTime=g.endTime,p.output=g.outputData,p.input=g.inputData,p.reasonForIncompletion=g.reasonForIncompletion,p.iteration=g.iteration)}),a&&JSON.stringify(a)!==JSON.stringify(r().workflowDef)&&r().setWorkflow(a);const i=r().taskMap,c=r().workflowDef?.tasks||[],u=[];c.forEach((p,h)=>{if(p.type==="FORK_JOIN_DYNAMIC"){for(let g=h+1;g<c.length;g++)if(c[g].type==="JOIN"||c[g].type==="EXCLUSIVE_JOIN"){u.push({forkRef:p.taskReferenceName,joinRef:c[g].taskReferenceName});break}}});const f={};u.forEach(({forkRef:p,joinRef:h})=>{const g=n.findIndex(y=>y.referenceTaskName===p),m=n.findIndex(y=>y.referenceTaskName===h);if(g<0||m<0)return;const v=new Set;f[p]=n.slice(g+1,m).filter(y=>!y.referenceTaskName||!y.taskId||i[y.referenceTaskName]||v.has(y.referenceTaskName)?!1:(v.add(y.referenceTaskName),!0)).map(y=>y)}),e({executionData:o,dynamicRuntimeTasksByFork:f,workflowInstance:s,mode:"run"})},setSelectedTask:t=>e({selectedTask:t?{...t}:null}),setIsDetailPanelOpen:t=>e({isDetailPanelOpen:t}),selectTaskAction:(t,n=!0)=>{e({selectedTask:t?{...t}:null,isDetailPanelOpen:t?n:!1,selectedTaskInstance:null})},setSelectedTaskInstance:t=>e({selectedTaskInstance:t}),setLayoutDirection:t=>{const{workflowDef:n}=r();if(n){const{nodes:s,edges:a,taskMap:o}=Ee(n,t,{hideEmptyBranches:r().mode!=="edit"}),{nodes:i,edges:d}=_e(s,a,{direction:t,mode:r().mode});e({nodes:i,edges:d,taskMap:o,layoutDirection:t})}else e({layoutDirection:t})},onNodesChange:t=>{const n=r().nodes,s=new Set(n.map(o=>o.id)),a=t.filter(o=>"id"in o&&s.has(o.id));a.length!==0&&e({nodes:A.applyNodeChanges(a,n)})},onEdgesChange:t=>{const n=r().edges,s=A.applyEdgeChanges(t,n);s!==n&&e({edges:s})},onConnect:t=>{const{edges:n,layoutDirection:s}=r(),a=A.addEdge(t,n),{nodes:o,edges:i}=_e(r().nodes,a,{direction:s,mode:r().mode});e({edges:i,nodes:o})},checkTaskRefUniqueness:(t,n)=>{if(t===n)return!0;const{taskMap:s}=r();return!s[t]},updateTask:(t,n,s)=>{const{workflowDef:a,layoutDirection:o}=r();if(!a)return;const i=JSON.parse(JSON.stringify(a)),d=Ce(i.tasks,t);if(d){typeof n=="object"?Object.assign(d,n):d[n]=s,we(i.tasks);const{nodes:c,edges:u,taskMap:f}=Ee(i,o,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=_e(c,u,{direction:o,mode:r().mode}),g=Re(i);e({workflowDef:i,nodes:p,edges:h,taskMap:f,validationResults:g})}},updateWorkflowProperties:t=>{const{workflowDef:n,layoutDirection:s}=r();if(!n)return;const a=JSON.parse(JSON.stringify(n));Object.assign(a,t),we(a.tasks);const{nodes:o,edges:i,taskMap:d}=Ee(a,s,{hideEmptyBranches:r().mode!=="edit"}),{nodes:c,edges:u}=_e(o,i,{direction:s,mode:r().mode}),f=Re(a);e({workflowDef:a,nodes:c,edges:u,taskMap:d,validationResults:f})},addNode:(t,n,s,a,o={})=>{const{workflowDef:i,layoutDirection:d}=r();if(!i)return;const c=JSON.parse(JSON.stringify(i)),u={name:t.data.label,taskReferenceName:t.data.taskReferenceName,type:t.data.taskType||"SIMPLE",inputParameters:{}};switch(u.type){case"HTTP":u.httpRequest={method:"GET",uri:"https://example.com/api",headers:{"Content-Type":"application/json"},body:{}};break;case"KAFKA_PUBLISH":u.inputParameters={topic:"my_topic",value:"${workflow.input.value}",bootStrapServers:"localhost:9092",headers:{},key:"msg_key"};break;case"JSON_JQ_TRANSFORM":u.inputParameters={queryExpression:".name",input:{}};break;case"SET_VARIABLE":u.inputParameters={variableName:"variableValue"};break;case"SUB_WORKFLOW":u.subWorkflowParam={name:"execution_workflow",version:1};break;case"EVENT":u.sink="conductor";break;case"WAIT":u.inputParameters={duration:"30s"};break;case"TERMINATE":u.inputParameters={terminationStatus:"COMPLETED",workflowOutput:{}};break}if(u.type==="FORK_JOIN"||u.type==="FORK_JOIN_DYNAMIC"){u.type==="FORK_JOIN"?u.forkTasks=[[],[]]:(u.dynamicForkTasksParam="dynamic_tasks",u.dynamicForkTasksInputParamName="input");const y={name:`${u.name}_join`,taskReferenceName:`${u.taskReferenceName}_join`,type:"JOIN",joinOn:[]};if(o.isWorkflowStart)c.tasks.unshift(y),c.tasks.unshift(u);else if(o.isLoopBodyStart){const x=Ce(c.tasks,n);x&&(x.loopOver||(x.loopOver=[]),x.loopOver.unshift(y),x.loopOver.unshift(u))}else o.branchCase!==void 0||o.forkIndex!==void 0||o.isLoopAdd?(ir(c.tasks,n,o,u),Ae(c.tasks,u.taskReferenceName,y)):c.tasks.length===0?c.tasks.push(u,y):(Ae(c.tasks,n,u),Ae(c.tasks,u.taskReferenceName,y))}else if(u.type==="DECISION"||u.type==="SWITCH"?(u.evaluatorType="value-param",u.caseValueParam="case_param",u.decisionCases={case1:[]},u.defaultCase=[]):u.type==="DO_WHILE"?(u.loopCondition="$.taskReferenceName.output.value < 10",u.loopOver=[]):u.type==="INLINE"?(u.evaluatorType="graaljs",u.inputParameters={expression:`function execute(input) {
|
|
6
|
+
<%s key={someKey} {...props} />`,R,B,$,B),re[B+R]=!0)}if(B=null,ie!==void 0&&(r(ie),B=""+ie),o(G)&&(r(G.key),B=""+G.key),"key"in G){ie={};for(var X in G)X!=="key"&&(ie[X]=G[X])}else ie=G;return B&&i(ie,typeof q=="function"?q.displayName||q.name||"Unknown":q),c(q,B,ie,s(),M,_)}function f(q){p(q)?q._store&&(q._store.validated=1):typeof q=="object"&&q!==null&&q.$$typeof===T&&(q._payload.status==="fulfilled"?p(q._payload.value)&&q._payload.value._store&&(q._payload.value._store.validated=1):q._store&&(q._store.validated=1))}function p(q){return typeof q=="object"&&q!==null&&q.$$typeof===g}var h=O,g=Symbol.for("react.transitional.element"),m=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),y=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),k=Symbol.for("react.context"),w=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),N=Symbol.for("react.suspense_list"),L=Symbol.for("react.memo"),T=Symbol.for("react.lazy"),C=Symbol.for("react.activity"),S=Symbol.for("react.client.reference"),D=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,I=Object.prototype.hasOwnProperty,P=Array.isArray,F=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(q){return q()}};var W,K={},V=h.react_stack_bottom_frame.bind(h,a)(),te=F(t(a)),re={};fr.Fragment=v,fr.jsx=function(q,G,ie){var R=1e4>D.recentlyCreatedOwnerStacks++;return d(q,G,ie,!1,R?Error("react-stack-top-frame"):V,R?F(t(q)):te)},fr.jsxs=function(q,G,ie){var R=1e4>D.recentlyCreatedOwnerStacks++;return d(q,G,ie,!0,R?Error("react-stack-top-frame"):V,R?F(t(q)):te)}})()),fr}var Zi;function fg(){return Zi||(Zi=1,process.env.NODE_ENV==="production"?Nr.exports=dg():Nr.exports=ug()),Nr.exports}var l=fg();const Qi=e=>{let n;const r=new Set,t=(c,d)=>{const f=typeof c=="function"?c(n):c;if(!Object.is(f,n)){const p=n;n=d??(typeof f!="object"||f===null)?f:Object.assign({},n,f),r.forEach(h=>h(n,p))}},s=()=>n,i={setState:t,getState:s,getInitialState:()=>u,subscribe:c=>(r.add(c),()=>r.delete(c))},u=n=e(t,s,i);return i},el=(e=>e?Qi(e):Qi),pg=e=>e;function et(e,n=pg){const r=O.useSyncExternalStore(e.subscribe,O.useCallback(()=>n(e.getState()),[e,n]),O.useCallback(()=>n(e.getInitialState()),[e,n]));return O.useDebugValue(r),r}const hg=e=>{const n=el(e),r=t=>et(n,t);return Object.assign(r,n),r},rt=(e=>hg);function tt(e,n){let r;try{r=e()}catch{return}return{getItem:s=>{var a;const o=u=>u===null?null:JSON.parse(u,void 0),i=(a=r.getItem(s))!=null?a:null;return i instanceof Promise?i.then(o):o(i)},setItem:(s,a)=>r.setItem(s,JSON.stringify(a,void 0)),removeItem:s=>r.removeItem(s)}}const nt=e=>n=>{try{const r=e(n);return r instanceof Promise?r:{then(t){return nt(t)(r)},catch(t){return this}}}catch(r){return{then(t){return this},catch(t){return nt(t)(r)}}}},rl=(e,n)=>(r,t,s)=>{let a={storage:tt(()=>localStorage),partialize:m=>m,version:0,merge:(m,v)=>({...v,...m}),...n},o=!1;const i=new Set,u=new Set;let c=a.storage;if(!c)return e((...m)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),r(...m)},t,s);const d=()=>{const m=a.partialize({...t()});return c.setItem(a.name,{state:m,version:a.version})},f=s.setState;s.setState=(m,v)=>(f(m,v),d());const p=e((...m)=>(r(...m),d()),t,s);s.getInitialState=()=>p;let h;const g=()=>{var m,v;if(!c)return;o=!1,i.forEach(x=>{var b;return x((b=t())!=null?b:p)});const y=((v=a.onRehydrateStorage)==null?void 0:v.call(a,(m=t())!=null?m:p))||void 0;return nt(c.getItem.bind(c))(a.name).then(x=>{if(x)if(typeof x.version=="number"&&x.version!==a.version){if(a.migrate){const b=a.migrate(x.state,x.version);return b instanceof Promise?b.then(k=>[!0,k]):[!0,b]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,x.state];return[!1,void 0]}).then(x=>{var b;const[k,w]=x;if(h=a.merge(w,(b=t())!=null?b:p),r(h,!0),k)return d()}).then(()=>{y?.(h,void 0),h=t(),o=!0,u.forEach(x=>x(h))}).catch(x=>{y?.(void 0,x)})};return s.persist={setOptions:m=>{a={...a,...m},m.storage&&(c=m.storage)},clearStorage:()=>{c?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>g(),hasHydrated:()=>o,onHydrate:m=>(i.add(m),()=>{i.delete(m)}),onFinishHydration:m=>(u.add(m),()=>{u.delete(m)})},a.skipHydration||g(),h||p};var tl=(e,n,r)=>(s,a)=>({pastStates:r?.pastStates||[],futureStates:r?.futureStates||[],undo:(o=1)=>{if(a().pastStates.length){const i=r?.partialize?.(n())||n(),u=a().pastStates.splice(-o,o),c=u.shift();e(c),s({pastStates:a().pastStates,futureStates:a().futureStates.concat(r?.diff?.(i,c)||i,u.reverse())})}},redo:(o=1)=>{if(a().futureStates.length){const i=r?.partialize?.(n())||n(),u=a().futureStates.splice(-o,o),c=u.shift();e(c),s({pastStates:a().pastStates.concat(r?.diff?.(i,c)||i,u.reverse()),futureStates:a().futureStates})}},clear:()=>s({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>s({isTracking:!1}),resume:()=>s({isTracking:!0}),setOnSave:o=>s({_onSave:o}),_onSave:r?.onSave,_handleSet:(o,i,u,c)=>{r?.limit&&a().pastStates.length>=r?.limit&&a().pastStates.shift(),a()._onSave?.(o,u),s({pastStates:a().pastStates.concat(c||o),futureStates:[]})}}),gg=(e,n)=>(t,s,a)=>{a.temporal=el(n?.wrapTemporal?.(tl(t,s,n))||tl(t,s,n));const o=n?.handleSet?.(a.temporal.getState()._handleSet)||a.temporal.getState()._handleSet,i=c=>{if(!a.temporal.getState().isTracking)return;const d=n?.partialize?.(s())||s(),f=n?.diff?.(c,d);f===null||n?.equality?.(c,d)||o(c,void 0,d,f)},u=a.setState;return a.setState=(...c)=>{const d=n?.partialize?.(s())||s();u(...c),i(d)},e((...c)=>{const d=n?.partialize?.(s())||s();t(...c),i(d)},s,a)};function mg(e,n="TB",r){const t=r?.hideEmptyBranches??!1;if(!e||!e.tasks)return{nodes:[],edges:[],taskMap:{}};const s=[],a=[],o={};let i=0;const u=e.tasks;for(let c=0;c<u.length;c++){const d=u[c],f=nl(d,i,o,n,u,t);if(s.push(...f.nodes),a.push(...f.edges),i=f.nextId,c>0){const p=u[c-1];at(p,d,a,t)}Object.assign(o,f.taskMap)}if(!t&&u.length>0){const c=u[0],d="__workflow_start__";s.push({id:d,type:"plusNode",data:{label:"+",taskReferenceName:d,taskType:"PLUS",parentRef:d,edgeData:{isWorkflowStart:!0},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top}),a.push({id:`e-${d}-${c.taskReferenceName}`,source:d,target:c.taskReferenceName,animated:!0});const f=u[u.length-1],p="__workflow_end__";s.push({id:p,type:"plusNode",data:{label:"+",taskReferenceName:p,taskType:"PLUS",parentRef:f.taskReferenceName,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:n==="LR"?A.Position.Left:A.Position.Top}),at(f,{taskReferenceName:p},a,t)}return{nodes:s,edges:a,taskMap:o}}function nl(e,n,r,t="TB",s=[],a=!1){switch(e.type||"SIMPLE"){case"DECISION":case"SWITCH":return yg(e,n,r,t,a);case"FORK_JOIN":case"FORK_JOIN_DYNAMIC":return xg(e,n,r,t);case"JOIN":case"EXCLUSIVE_JOIN":return _g(e,n,r,t,s,a);case"DO_WHILE":return bg(e,n,r,t,a);case"SUB_WORKFLOW":return kg(e,n,r,t);default:return vg(e,n,r,t)}}function vg(e,n,r,t="TB"){const s={id:e.taskReferenceName,type:"taskNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type||"SIMPLE",task:e,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:n+1}}function yg(e,n,r,t="TB",s=!1){const a=[],o=[];let i=n;const u={},c={id:e.taskReferenceName,type:"decisionNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top};a.push(c),u[e.taskReferenceName]=e;const d=e.decisionCases||{},f=e.defaultCase||[],p=Object.keys(d),h=(g,m)=>{if(t==="TB"){if(g===0&&m>1)return"left";if(g===1&&m>2)return"right"}else{if(g===0&&m>1)return"top";if(g===1&&m>2)return"bottom"}return null};if(p.forEach((g,m)=>{const v=d[g],y=h(m,p.length+1);if(v&&v.length>0){const x=Cr(v,i,{...r,...u},t,s);a.push(...x.nodes),o.push(...x.edges),Object.assign(u,x.taskMap),i=x.nextId;const b=v[0].taskReferenceName;o.push({id:`e-${e.taskReferenceName}-${b}`,source:e.taskReferenceName,sourceHandle:y||void 0,target:b,label:g,animated:!0,data:{branchCase:g},style:{stroke:"#3b82f6"}})}else if(!s){const x=`${e.taskReferenceName}_empty_${g}`;a.push({id:x,type:"plusNode",data:{label:`${g} (空)`,parentRef:e.taskReferenceName,edgeData:{branchCase:g},layoutDirection:t,taskReferenceName:x,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),o.push({id:`e-${e.taskReferenceName}-${x}`,source:e.taskReferenceName,sourceHandle:y||void 0,target:x,label:g,animated:!0,data:{branchCase:g},style:{stroke:"#3b82f6",strokeDasharray:"5,5"}})}}),f&&f.length>0){const g=Cr(f,i,{...r,...u},t,s);a.push(...g.nodes),o.push(...g.edges),Object.assign(u,g.taskMap),i=g.nextId;const m=f[0].taskReferenceName;o.push({id:`e-${e.taskReferenceName}-${m}`,source:e.taskReferenceName,target:m,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b"}})}else if(!s){const g=`${e.taskReferenceName}_empty_default`;a.push({id:g,type:"plusNode",data:{label:"default (空)",parentRef:e.taskReferenceName,edgeData:{branchCase:"default"},layoutDirection:t,taskReferenceName:g,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),o.push({id:`e-${e.taskReferenceName}-${g}`,source:e.taskReferenceName,target:g,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b",strokeDasharray:"5,5"}})}return{nodes:a,edges:o,taskMap:u,nextId:i}}function xg(e,n,r,t="TB"){const s=[],a=[];let o=n;const i={},u=e.type==="FORK_JOIN_DYNAMIC",c={id:e.taskReferenceName,type:"forkNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,isDynamic:u,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top};if(s.push(c),i[e.taskReferenceName]=e,u){const d=`${e.taskReferenceName}_dynamic_placeholder`;s.push({id:d,type:"dynamicPlaceholderNode",data:{label:"动态分支",taskReferenceName:d,taskType:"DYNAMIC_PLACEHOLDER",layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top}),a.push({id:`e-${e.taskReferenceName}-${d}`,source:e.taskReferenceName,target:d,animated:!0,style:{stroke:"#10b981",strokeDasharray:"5,5",strokeWidth:2}}),i[d]={taskReferenceName:d,type:"DYNAMIC_PLACEHOLDER"}}return u||(e.forkTasks||[]).forEach((f,p)=>{if(f&&f.length>0){const h=Cr(f,o,{...r,...i},t,!1);s.push(...h.nodes),a.push(...h.edges),Object.assign(i,h.taskMap),o=h.nextId;const g=f[0].taskReferenceName;a.push({id:`e-${e.taskReferenceName}-${g}`,source:e.taskReferenceName,sourceHandle:`branch_${p}`,target:g,label:`分支 ${p+1}`,animated:!0,data:{forkIndex:p},style:{stroke:"#10b981"}})}}),{nodes:s,edges:a,taskMap:i,nextId:o}}function bg(e,n,r,t="TB",s=!1){const a={},o=e.taskReferenceName,i={id:o,type:"loopNode",data:{label:e.name,taskReferenceName:o,taskType:e.type,task:e,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top,style:{pointerEvents:"none"}};a[o]=e;const u=e.loopOver||[],c=[],d=[];let f=n+1;if(u.length>0){const p=Cr(u,f,{...r,...a},t,s);if(f=p.nextId,Object.assign(a,p.taskMap),p.nodes.forEach(h=>{c.push({...h,parentId:h.parentId??o,extent:h.parentId?h.extent:"parent"})}),d.push(...p.edges),!s){const h=u[0],g=`__loop_start__${o}`;c.push({id:g,type:"plusNode",parentId:o,extent:"parent",data:{label:"+",taskReferenceName:g,taskType:"PLUS",parentRef:o,edgeData:{isLoopBodyStart:!0,loopId:o},layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top}),d.push({id:`e-${g}-${h.taskReferenceName}`,source:g,target:h.taskReferenceName,animated:!0})}if(!s){const h=u[u.length-1],g=`__loop_end__${o}`;c.push({id:g,type:"plusNode",parentId:o,extent:"parent",data:{label:"+",taskReferenceName:g,taskType:"PLUS",parentRef:h.taskReferenceName,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top}),d.push({id:`e-${h.taskReferenceName}-${g}`,source:h.taskReferenceName,target:g,animated:!0})}}else if(!s){const p=`${o}_loop_empty_plus`;c.push({id:p,type:"plusNode",parentId:o,extent:"parent",data:{label:"+ 添加",taskReferenceName:p,taskType:"PLUS",parentRef:o,edgeData:{isLoopAdd:!0},layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top})}return{nodes:[i,...c],edges:d,taskMap:a,nextId:f}}function kg(e,n,r,t="TB"){const s={id:e.taskReferenceName,type:"subWorkflowNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:n+1}}function _g(e,n,r,t="TB",s=[],a=!1){const o={id:e.taskReferenceName,type:"joinNode",data:{label:e.name||"JOIN",taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top},i={[e.taskReferenceName]:e},u=[],c=[];(e.joinOn||[]).forEach(p=>{const h=s.find(g=>g.taskReferenceName===p)||r[p];h&&jr(h,a).forEach(m=>{c.push({id:`e-${m}-${e.taskReferenceName}`,source:m,target:e.taskReferenceName,animated:!0})})});const f=s.findIndex(p=>p.taskReferenceName===e.taskReferenceName);if(f>0){const p=s[f-1];if(p.type==="FORK_JOIN_DYNAMIC"){const h=`${p.taskReferenceName}_dynamic_placeholder`;c.push({id:`e-${h}-${e.taskReferenceName}-dynamic`,source:h,target:e.taskReferenceName,animated:!0,style:{stroke:"#10b981",strokeWidth:2,strokeDasharray:"5,5",opacity:.8}})}else p.type==="FORK_JOIN"&&(p.forkTasks||[]).forEach((g,m)=>{if((!g||g.length===0)&&!a){const v=`${p.taskReferenceName}_empty_branch_${m}`;u.push({id:v,type:"default",data:{label:`分支 ${m+1} (空)`,layoutDirection:t,taskReferenceName:v,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:t==="LR"?A.Position.Right:A.Position.Bottom,targetPosition:t==="LR"?A.Position.Left:A.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary, #64748b)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-tertiary, #94a3b8)",minWidth:"80px",textAlign:"center"}}),c.push({id:`e-${p.taskReferenceName}-${v}`,source:p.taskReferenceName,sourceHandle:`branch_${m}`,target:v,label:`分支 ${m+1}`,animated:!0,data:{forkIndex:m},style:{stroke:"#10b981",strokeDasharray:"5,5"}}),c.push({id:`e-${v}-${e.taskReferenceName}`,source:v,target:e.taskReferenceName,animated:!0,style:{strokeDasharray:"5,5"}})}})}return{nodes:[o,...u],edges:c,taskMap:i,nextId:n+1}}function Cr(e,n,r,t="TB",s=!1){const a=[],o=[];let i=n;const u={};for(let c=0;c<e.length;c++){const d=e[c],f={...r,...u},p=nl(d,i,f,t,e,s);if(a.push(...p.nodes),o.push(...p.edges),Object.assign(u,p.taskMap),i=p.nextId,c>0){const h=e[c-1];at(h,d,o,s)}}return{nodes:a,edges:o,taskMap:u,nextId:i}}function at(e,n,r,t=!1){if(e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC")return;const s=jr(e,t),a=n.taskReferenceName;s.forEach(o=>{const i=`e-${o}-${a}`;r.find(u=>u.id===i)||r.push({id:i,source:o,target:a,animated:!0})})}function jr(e,n=!1){const r=e.type||"SIMPLE";if(r==="DECISION"||r==="SWITCH"){const t=[],s=e.decisionCases||{},a=e.defaultCase||[];if(Object.entries(s).forEach(([o,i])=>{if(i&&i.length>0){const u=i[i.length-1];t.push(...jr(u,n))}else n||t.push(`${e.taskReferenceName}_empty_${o}`)}),a.length>0){const o=a[a.length-1];t.push(...jr(o,n))}else n||t.push(`${e.taskReferenceName}_empty_default`);return t.length>0?t:[e.taskReferenceName]}return[e.taskReferenceName]}const Te=mg;function st(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ot,al;function Sg(){if(al)return ot;al=1;function e(){this.__data__=[],this.size=0}return ot=e,ot}var it,sl;function Qe(){if(sl)return it;sl=1;function e(n,r){return n===r||n!==n&&r!==r}return it=e,it}var lt,ol;function Ir(){if(ol)return lt;ol=1;var e=Qe();function n(r,t){for(var s=r.length;s--;)if(e(r[s][0],t))return s;return-1}return lt=n,lt}var ct,il;function wg(){if(il)return ct;il=1;var e=Ir(),n=Array.prototype,r=n.splice;function t(s){var a=this.__data__,o=e(a,s);if(o<0)return!1;var i=a.length-1;return o==i?a.pop():r.call(a,o,1),--this.size,!0}return ct=t,ct}var dt,ll;function Tg(){if(ll)return dt;ll=1;var e=Ir();function n(r){var t=this.__data__,s=e(t,r);return s<0?void 0:t[s][1]}return dt=n,dt}var ut,cl;function Eg(){if(cl)return ut;cl=1;var e=Ir();function n(r){return e(this.__data__,r)>-1}return ut=n,ut}var ft,dl;function Ng(){if(dl)return ft;dl=1;var e=Ir();function n(r,t){var s=this.__data__,a=e(s,r);return a<0?(++this.size,s.push([r,t])):s[a][1]=t,this}return ft=n,ft}var pt,ul;function Rr(){if(ul)return pt;ul=1;var e=Sg(),n=wg(),r=Tg(),t=Eg(),s=Ng();function a(o){var i=-1,u=o==null?0:o.length;for(this.clear();++i<u;){var c=o[i];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=t,a.prototype.set=s,pt=a,pt}var ht,fl;function Cg(){if(fl)return ht;fl=1;var e=Rr();function n(){this.__data__=new e,this.size=0}return ht=n,ht}var gt,pl;function jg(){if(pl)return gt;pl=1;function e(n){var r=this.__data__,t=r.delete(n);return this.size=r.size,t}return gt=e,gt}var mt,hl;function Ig(){if(hl)return mt;hl=1;function e(n){return this.__data__.get(n)}return mt=e,mt}var vt,gl;function Rg(){if(gl)return vt;gl=1;function e(n){return this.__data__.has(n)}return vt=e,vt}var yt,ml;function vl(){if(ml)return yt;ml=1;var e=typeof Er=="object"&&Er&&Er.Object===Object&&Er;return yt=e,yt}var xt,yl;function Pe(){if(yl)return xt;yl=1;var e=vl(),n=typeof self=="object"&&self&&self.Object===Object&&self,r=e||n||Function("return this")();return xt=r,xt}var bt,xl;function er(){if(xl)return bt;xl=1;var e=Pe(),n=e.Symbol;return bt=n,bt}var kt,bl;function Og(){if(bl)return kt;bl=1;var e=er(),n=Object.prototype,r=n.hasOwnProperty,t=n.toString,s=e?e.toStringTag:void 0;function a(o){var i=r.call(o,s),u=o[s];try{o[s]=void 0;var c=!0}catch{}var d=t.call(o);return c&&(i?o[s]=u:delete o[s]),d}return kt=a,kt}var _t,kl;function Pg(){if(kl)return _t;kl=1;var e=Object.prototype,n=e.toString;function r(t){return n.call(t)}return _t=r,_t}var St,_l;function Je(){if(_l)return St;_l=1;var e=er(),n=Og(),r=Pg(),t="[object Null]",s="[object Undefined]",a=e?e.toStringTag:void 0;function o(i){return i==null?i===void 0?s:t:a&&a in Object(i)?n(i):r(i)}return St=o,St}var wt,Sl;function Ie(){if(Sl)return wt;Sl=1;function e(n){var r=typeof n;return n!=null&&(r=="object"||r=="function")}return wt=e,wt}var Tt,wl;function pr(){if(wl)return Tt;wl=1;var e=Je(),n=Ie(),r="[object AsyncFunction]",t="[object Function]",s="[object GeneratorFunction]",a="[object Proxy]";function o(i){if(!n(i))return!1;var u=e(i);return u==t||u==s||u==r||u==a}return Tt=o,Tt}var Et,Tl;function Ag(){if(Tl)return Et;Tl=1;var e=Pe(),n=e["__core-js_shared__"];return Et=n,Et}var Nt,El;function Lg(){if(El)return Nt;El=1;var e=Ag(),n=(function(){var t=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""})();function r(t){return!!n&&n in t}return Nt=r,Nt}var Ct,Nl;function Cl(){if(Nl)return Ct;Nl=1;var e=Function.prototype,n=e.toString;function r(t){if(t!=null){try{return n.call(t)}catch{}try{return t+""}catch{}}return""}return Ct=r,Ct}var jt,jl;function qg(){if(jl)return jt;jl=1;var e=pr(),n=Lg(),r=Ie(),t=Cl(),s=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,o=Function.prototype,i=Object.prototype,u=o.toString,c=i.hasOwnProperty,d=RegExp("^"+u.call(c).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function f(p){if(!r(p)||n(p))return!1;var h=e(p)?d:a;return h.test(t(p))}return jt=f,jt}var It,Il;function Dg(){if(Il)return It;Il=1;function e(n,r){return n?.[r]}return It=e,It}var Rt,Rl;function Ge(){if(Rl)return Rt;Rl=1;var e=qg(),n=Dg();function r(t,s){var a=n(t,s);return e(a)?a:void 0}return Rt=r,Rt}var Ot,Ol;function Pt(){if(Ol)return Ot;Ol=1;var e=Ge(),n=Pe(),r=e(n,"Map");return Ot=r,Ot}var At,Pl;function Or(){if(Pl)return At;Pl=1;var e=Ge(),n=e(Object,"create");return At=n,At}var Lt,Al;function Mg(){if(Al)return Lt;Al=1;var e=Or();function n(){this.__data__=e?e(null):{},this.size=0}return Lt=n,Lt}var qt,Ll;function Wg(){if(Ll)return qt;Ll=1;function e(n){var r=this.has(n)&&delete this.__data__[n];return this.size-=r?1:0,r}return qt=e,qt}var Dt,ql;function Bg(){if(ql)return Dt;ql=1;var e=Or(),n="__lodash_hash_undefined__",r=Object.prototype,t=r.hasOwnProperty;function s(a){var o=this.__data__;if(e){var i=o[a];return i===n?void 0:i}return t.call(o,a)?o[a]:void 0}return Dt=s,Dt}var Mt,Dl;function Fg(){if(Dl)return Mt;Dl=1;var e=Or(),n=Object.prototype,r=n.hasOwnProperty;function t(s){var a=this.__data__;return e?a[s]!==void 0:r.call(a,s)}return Mt=t,Mt}var Wt,Ml;function $g(){if(Ml)return Wt;Ml=1;var e=Or(),n="__lodash_hash_undefined__";function r(t,s){var a=this.__data__;return this.size+=this.has(t)?0:1,a[t]=e&&s===void 0?n:s,this}return Wt=r,Wt}var Bt,Wl;function zg(){if(Wl)return Bt;Wl=1;var e=Mg(),n=Wg(),r=Bg(),t=Fg(),s=$g();function a(o){var i=-1,u=o==null?0:o.length;for(this.clear();++i<u;){var c=o[i];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=t,a.prototype.set=s,Bt=a,Bt}var Ft,Bl;function Hg(){if(Bl)return Ft;Bl=1;var e=zg(),n=Rr(),r=Pt();function t(){this.size=0,this.__data__={hash:new e,map:new(r||n),string:new e}}return Ft=t,Ft}var $t,Fl;function Kg(){if(Fl)return $t;Fl=1;function e(n){var r=typeof n;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?n!=="__proto__":n===null}return $t=e,$t}var zt,$l;function Pr(){if($l)return zt;$l=1;var e=Kg();function n(r,t){var s=r.__data__;return e(t)?s[typeof t=="string"?"string":"hash"]:s.map}return zt=n,zt}var Ht,zl;function Ug(){if(zl)return Ht;zl=1;var e=Pr();function n(r){var t=e(this,r).delete(r);return this.size-=t?1:0,t}return Ht=n,Ht}var Kt,Hl;function Jg(){if(Hl)return Kt;Hl=1;var e=Pr();function n(r){return e(this,r).get(r)}return Kt=n,Kt}var Ut,Kl;function Gg(){if(Kl)return Ut;Kl=1;var e=Pr();function n(r){return e(this,r).has(r)}return Ut=n,Ut}var Jt,Ul;function Vg(){if(Ul)return Jt;Ul=1;var e=Pr();function n(r,t){var s=e(this,r),a=s.size;return s.set(r,t),this.size+=s.size==a?0:1,this}return Jt=n,Jt}var Gt,Jl;function Vt(){if(Jl)return Gt;Jl=1;var e=Hg(),n=Ug(),r=Jg(),t=Gg(),s=Vg();function a(o){var i=-1,u=o==null?0:o.length;for(this.clear();++i<u;){var c=o[i];this.set(c[0],c[1])}}return a.prototype.clear=e,a.prototype.delete=n,a.prototype.get=r,a.prototype.has=t,a.prototype.set=s,Gt=a,Gt}var Yt,Gl;function Yg(){if(Gl)return Yt;Gl=1;var e=Rr(),n=Pt(),r=Vt(),t=200;function s(a,o){var i=this.__data__;if(i instanceof e){var u=i.__data__;if(!n||u.length<t-1)return u.push([a,o]),this.size=++i.size,this;i=this.__data__=new r(u)}return i.set(a,o),this.size=i.size,this}return Yt=s,Yt}var Xt,Vl;function Ar(){if(Vl)return Xt;Vl=1;var e=Rr(),n=Cg(),r=jg(),t=Ig(),s=Rg(),a=Yg();function o(i){var u=this.__data__=new e(i);this.size=u.size}return o.prototype.clear=n,o.prototype.delete=r,o.prototype.get=t,o.prototype.has=s,o.prototype.set=a,Xt=o,Xt}var Zt,Yl;function Qt(){if(Yl)return Zt;Yl=1;function e(n,r){for(var t=-1,s=n==null?0:n.length;++t<s&&r(n[t],t,n)!==!1;);return n}return Zt=e,Zt}var en,Xl;function Zl(){if(Xl)return en;Xl=1;var e=Ge(),n=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return en=n,en}var rn,Ql;function Lr(){if(Ql)return rn;Ql=1;var e=Zl();function n(r,t,s){t=="__proto__"&&e?e(r,t,{configurable:!0,enumerable:!0,value:s,writable:!0}):r[t]=s}return rn=n,rn}var tn,ec;function qr(){if(ec)return tn;ec=1;var e=Lr(),n=Qe(),r=Object.prototype,t=r.hasOwnProperty;function s(a,o,i){var u=a[o];(!(t.call(a,o)&&n(u,i))||i===void 0&&!(o in a))&&e(a,o,i)}return tn=s,tn}var nn,rc;function hr(){if(rc)return nn;rc=1;var e=qr(),n=Lr();function r(t,s,a,o){var i=!a;a||(a={});for(var u=-1,c=s.length;++u<c;){var d=s[u],f=o?o(a[d],t[d],d,a,t):void 0;f===void 0&&(f=t[d]),i?n(a,d,f):e(a,d,f)}return a}return nn=r,nn}var an,tc;function Xg(){if(tc)return an;tc=1;function e(n,r){for(var t=-1,s=Array(n);++t<n;)s[t]=r(t);return s}return an=e,an}var sn,nc;function Me(){if(nc)return sn;nc=1;function e(n){return n!=null&&typeof n=="object"}return sn=e,sn}var on,ac;function Zg(){if(ac)return on;ac=1;var e=Je(),n=Me(),r="[object Arguments]";function t(s){return n(s)&&e(s)==r}return on=t,on}var ln,sc;function gr(){if(sc)return ln;sc=1;var e=Zg(),n=Me(),r=Object.prototype,t=r.hasOwnProperty,s=r.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(o){return n(o)&&t.call(o,"callee")&&!s.call(o,"callee")};return ln=a,ln}var cn,oc;function ke(){if(oc)return cn;oc=1;var e=Array.isArray;return cn=e,cn}var mr={exports:{}},dn,ic;function Qg(){if(ic)return dn;ic=1;function e(){return!1}return dn=e,dn}mr.exports;var lc;function rr(){return lc||(lc=1,(function(e,n){var r=Pe(),t=Qg(),s=n&&!n.nodeType&&n,a=s&&!0&&e&&!e.nodeType&&e,o=a&&a.exports===s,i=o?r.Buffer:void 0,u=i?i.isBuffer:void 0,c=u||t;e.exports=c})(mr,mr.exports)),mr.exports}var un,cc;function Dr(){if(cc)return un;cc=1;var e=9007199254740991,n=/^(?:0|[1-9]\d*)$/;function r(t,s){var a=typeof t;return s=s??e,!!s&&(a=="number"||a!="symbol"&&n.test(t))&&t>-1&&t%1==0&&t<s}return un=r,un}var fn,dc;function pn(){if(dc)return fn;dc=1;var e=9007199254740991;function n(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return fn=n,fn}var hn,uc;function em(){if(uc)return hn;uc=1;var e=Je(),n=pn(),r=Me(),t="[object Arguments]",s="[object Array]",a="[object Boolean]",o="[object Date]",i="[object Error]",u="[object Function]",c="[object Map]",d="[object Number]",f="[object Object]",p="[object RegExp]",h="[object Set]",g="[object String]",m="[object WeakMap]",v="[object ArrayBuffer]",y="[object DataView]",x="[object Float32Array]",b="[object Float64Array]",k="[object Int8Array]",w="[object Int16Array]",j="[object Int32Array]",N="[object Uint8Array]",L="[object Uint8ClampedArray]",T="[object Uint16Array]",C="[object Uint32Array]",S={};S[x]=S[b]=S[k]=S[w]=S[j]=S[N]=S[L]=S[T]=S[C]=!0,S[t]=S[s]=S[v]=S[a]=S[y]=S[o]=S[i]=S[u]=S[c]=S[d]=S[f]=S[p]=S[h]=S[g]=S[m]=!1;function D(I){return r(I)&&n(I.length)&&!!S[e(I)]}return hn=D,hn}var gn,fc;function Mr(){if(fc)return gn;fc=1;function e(n){return function(r){return n(r)}}return gn=e,gn}var vr={exports:{}};vr.exports;var pc;function mn(){return pc||(pc=1,(function(e,n){var r=vl(),t=n&&!n.nodeType&&n,s=t&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===t,o=a&&r.process,i=(function(){try{var u=s&&s.require&&s.require("util").types;return u||o&&o.binding&&o.binding("util")}catch{}})();e.exports=i})(vr,vr.exports)),vr.exports}var vn,hc;function yr(){if(hc)return vn;hc=1;var e=em(),n=Mr(),r=mn(),t=r&&r.isTypedArray,s=t?n(t):e;return vn=s,vn}var yn,gc;function mc(){if(gc)return yn;gc=1;var e=Xg(),n=gr(),r=ke(),t=rr(),s=Dr(),a=yr(),o=Object.prototype,i=o.hasOwnProperty;function u(c,d){var f=r(c),p=!f&&n(c),h=!f&&!p&&t(c),g=!f&&!p&&!h&&a(c),m=f||p||h||g,v=m?e(c.length,String):[],y=v.length;for(var x in c)(d||i.call(c,x))&&!(m&&(x=="length"||h&&(x=="offset"||x=="parent")||g&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||s(x,y)))&&v.push(x);return v}return yn=u,yn}var xn,vc;function Wr(){if(vc)return xn;vc=1;var e=Object.prototype;function n(r){var t=r&&r.constructor,s=typeof t=="function"&&t.prototype||e;return r===s}return xn=n,xn}var bn,yc;function xc(){if(yc)return bn;yc=1;function e(n,r){return function(t){return n(r(t))}}return bn=e,bn}var kn,bc;function rm(){if(bc)return kn;bc=1;var e=xc(),n=e(Object.keys,Object);return kn=n,kn}var _n,kc;function Sn(){if(kc)return _n;kc=1;var e=Wr(),n=rm(),r=Object.prototype,t=r.hasOwnProperty;function s(a){if(!e(a))return n(a);var o=[];for(var i in Object(a))t.call(a,i)&&i!="constructor"&&o.push(i);return o}return _n=s,_n}var wn,_c;function Be(){if(_c)return wn;_c=1;var e=pr(),n=pn();function r(t){return t!=null&&n(t.length)&&!e(t)}return wn=r,wn}var Tn,Sc;function ze(){if(Sc)return Tn;Sc=1;var e=mc(),n=Sn(),r=Be();function t(s){return r(s)?e(s):n(s)}return Tn=t,Tn}var En,wc;function tm(){if(wc)return En;wc=1;var e=hr(),n=ze();function r(t,s){return t&&e(s,n(s),t)}return En=r,En}var Nn,Tc;function nm(){if(Tc)return Nn;Tc=1;function e(n){var r=[];if(n!=null)for(var t in Object(n))r.push(t);return r}return Nn=e,Nn}var Cn,Ec;function am(){if(Ec)return Cn;Ec=1;var e=Ie(),n=Wr(),r=nm(),t=Object.prototype,s=t.hasOwnProperty;function a(o){if(!e(o))return r(o);var i=n(o),u=[];for(var c in o)c=="constructor"&&(i||!s.call(o,c))||u.push(c);return u}return Cn=a,Cn}var jn,Nc;function Ve(){if(Nc)return jn;Nc=1;var e=mc(),n=am(),r=Be();function t(s){return r(s)?e(s,!0):n(s)}return jn=t,jn}var In,Cc;function sm(){if(Cc)return In;Cc=1;var e=hr(),n=Ve();function r(t,s){return t&&e(s,n(s),t)}return In=r,In}var xr={exports:{}};xr.exports;var jc;function Ic(){return jc||(jc=1,(function(e,n){var r=Pe(),t=n&&!n.nodeType&&n,s=t&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===t,o=a?r.Buffer:void 0,i=o?o.allocUnsafe:void 0;function u(c,d){if(d)return c.slice();var f=c.length,p=i?i(f):new c.constructor(f);return c.copy(p),p}e.exports=u})(xr,xr.exports)),xr.exports}var Rn,Rc;function Oc(){if(Rc)return Rn;Rc=1;function e(n,r){var t=-1,s=n.length;for(r||(r=Array(s));++t<s;)r[t]=n[t];return r}return Rn=e,Rn}var On,Pc;function Ac(){if(Pc)return On;Pc=1;function e(n,r){for(var t=-1,s=n==null?0:n.length,a=0,o=[];++t<s;){var i=n[t];r(i,t,n)&&(o[a++]=i)}return o}return On=e,On}var Pn,Lc;function qc(){if(Lc)return Pn;Lc=1;function e(){return[]}return Pn=e,Pn}var An,Dc;function Ln(){if(Dc)return An;Dc=1;var e=Ac(),n=qc(),r=Object.prototype,t=r.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(o){return o==null?[]:(o=Object(o),e(s(o),function(i){return t.call(o,i)}))}:n;return An=a,An}var qn,Mc;function om(){if(Mc)return qn;Mc=1;var e=hr(),n=Ln();function r(t,s){return e(t,n(t),s)}return qn=r,qn}var Dn,Wc;function Mn(){if(Wc)return Dn;Wc=1;function e(n,r){for(var t=-1,s=r.length,a=n.length;++t<s;)n[a+t]=r[t];return n}return Dn=e,Dn}var Wn,Bc;function Br(){if(Bc)return Wn;Bc=1;var e=xc(),n=e(Object.getPrototypeOf,Object);return Wn=n,Wn}var Bn,Fc;function $c(){if(Fc)return Bn;Fc=1;var e=Mn(),n=Br(),r=Ln(),t=qc(),s=Object.getOwnPropertySymbols,a=s?function(o){for(var i=[];o;)e(i,r(o)),o=n(o);return i}:t;return Bn=a,Bn}var Fn,zc;function im(){if(zc)return Fn;zc=1;var e=hr(),n=$c();function r(t,s){return e(t,n(t),s)}return Fn=r,Fn}var $n,Hc;function Kc(){if(Hc)return $n;Hc=1;var e=Mn(),n=ke();function r(t,s,a){var o=s(t);return n(t)?o:e(o,a(t))}return $n=r,$n}var zn,Uc;function Jc(){if(Uc)return zn;Uc=1;var e=Kc(),n=Ln(),r=ze();function t(s){return e(s,r,n)}return zn=t,zn}var Hn,Gc;function lm(){if(Gc)return Hn;Gc=1;var e=Kc(),n=$c(),r=Ve();function t(s){return e(s,r,n)}return Hn=t,Hn}var Kn,Vc;function cm(){if(Vc)return Kn;Vc=1;var e=Ge(),n=Pe(),r=e(n,"DataView");return Kn=r,Kn}var Un,Yc;function dm(){if(Yc)return Un;Yc=1;var e=Ge(),n=Pe(),r=e(n,"Promise");return Un=r,Un}var Jn,Xc;function Zc(){if(Xc)return Jn;Xc=1;var e=Ge(),n=Pe(),r=e(n,"Set");return Jn=r,Jn}var Gn,Qc;function um(){if(Qc)return Gn;Qc=1;var e=Ge(),n=Pe(),r=e(n,"WeakMap");return Gn=r,Gn}var Vn,ed;function tr(){if(ed)return Vn;ed=1;var e=cm(),n=Pt(),r=dm(),t=Zc(),s=um(),a=Je(),o=Cl(),i="[object Map]",u="[object Object]",c="[object Promise]",d="[object Set]",f="[object WeakMap]",p="[object DataView]",h=o(e),g=o(n),m=o(r),v=o(t),y=o(s),x=a;return(e&&x(new e(new ArrayBuffer(1)))!=p||n&&x(new n)!=i||r&&x(r.resolve())!=c||t&&x(new t)!=d||s&&x(new s)!=f)&&(x=function(b){var k=a(b),w=k==u?b.constructor:void 0,j=w?o(w):"";if(j)switch(j){case h:return p;case g:return i;case m:return c;case v:return d;case y:return f}return k}),Vn=x,Vn}var Yn,rd;function fm(){if(rd)return Yn;rd=1;var e=Object.prototype,n=e.hasOwnProperty;function r(t){var s=t.length,a=new t.constructor(s);return s&&typeof t[0]=="string"&&n.call(t,"index")&&(a.index=t.index,a.input=t.input),a}return Yn=r,Yn}var Xn,td;function nd(){if(td)return Xn;td=1;var e=Pe(),n=e.Uint8Array;return Xn=n,Xn}var Zn,ad;function Qn(){if(ad)return Zn;ad=1;var e=nd();function n(r){var t=new r.constructor(r.byteLength);return new e(t).set(new e(r)),t}return Zn=n,Zn}var ea,sd;function pm(){if(sd)return ea;sd=1;var e=Qn();function n(r,t){var s=t?e(r.buffer):r.buffer;return new r.constructor(s,r.byteOffset,r.byteLength)}return ea=n,ea}var ra,od;function hm(){if(od)return ra;od=1;var e=/\w*$/;function n(r){var t=new r.constructor(r.source,e.exec(r));return t.lastIndex=r.lastIndex,t}return ra=n,ra}var ta,id;function gm(){if(id)return ta;id=1;var e=er(),n=e?e.prototype:void 0,r=n?n.valueOf:void 0;function t(s){return r?Object(r.call(s)):{}}return ta=t,ta}var na,ld;function cd(){if(ld)return na;ld=1;var e=Qn();function n(r,t){var s=t?e(r.buffer):r.buffer;return new r.constructor(s,r.byteOffset,r.length)}return na=n,na}var aa,dd;function mm(){if(dd)return aa;dd=1;var e=Qn(),n=pm(),r=hm(),t=gm(),s=cd(),a="[object Boolean]",o="[object Date]",i="[object Map]",u="[object Number]",c="[object RegExp]",d="[object Set]",f="[object String]",p="[object Symbol]",h="[object ArrayBuffer]",g="[object DataView]",m="[object Float32Array]",v="[object Float64Array]",y="[object Int8Array]",x="[object Int16Array]",b="[object Int32Array]",k="[object Uint8Array]",w="[object Uint8ClampedArray]",j="[object Uint16Array]",N="[object Uint32Array]";function L(T,C,S){var D=T.constructor;switch(C){case h:return e(T);case a:case o:return new D(+T);case g:return n(T,S);case m:case v:case y:case x:case b:case k:case w:case j:case N:return s(T,S);case i:return new D;case u:case f:return new D(T);case c:return r(T);case d:return new D;case p:return t(T)}}return aa=L,aa}var sa,ud;function fd(){if(ud)return sa;ud=1;var e=Ie(),n=Object.create,r=(function(){function t(){}return function(s){if(!e(s))return{};if(n)return n(s);t.prototype=s;var a=new t;return t.prototype=void 0,a}})();return sa=r,sa}var oa,pd;function hd(){if(pd)return oa;pd=1;var e=fd(),n=Br(),r=Wr();function t(s){return typeof s.constructor=="function"&&!r(s)?e(n(s)):{}}return oa=t,oa}var ia,gd;function vm(){if(gd)return ia;gd=1;var e=tr(),n=Me(),r="[object Map]";function t(s){return n(s)&&e(s)==r}return ia=t,ia}var la,md;function ym(){if(md)return la;md=1;var e=vm(),n=Mr(),r=mn(),t=r&&r.isMap,s=t?n(t):e;return la=s,la}var ca,vd;function xm(){if(vd)return ca;vd=1;var e=tr(),n=Me(),r="[object Set]";function t(s){return n(s)&&e(s)==r}return ca=t,ca}var da,yd;function bm(){if(yd)return da;yd=1;var e=xm(),n=Mr(),r=mn(),t=r&&r.isSet,s=t?n(t):e;return da=s,da}var ua,xd;function bd(){if(xd)return ua;xd=1;var e=Ar(),n=Qt(),r=qr(),t=tm(),s=sm(),a=Ic(),o=Oc(),i=om(),u=im(),c=Jc(),d=lm(),f=tr(),p=fm(),h=mm(),g=hd(),m=ke(),v=rr(),y=ym(),x=Ie(),b=bm(),k=ze(),w=Ve(),j=1,N=2,L=4,T="[object Arguments]",C="[object Array]",S="[object Boolean]",D="[object Date]",I="[object Error]",P="[object Function]",F="[object GeneratorFunction]",W="[object Map]",K="[object Number]",V="[object Object]",te="[object RegExp]",re="[object Set]",q="[object String]",G="[object Symbol]",ie="[object WeakMap]",R="[object ArrayBuffer]",M="[object DataView]",_="[object Float32Array]",B="[object Float64Array]",$="[object Int8Array]",X="[object Int16Array]",U="[object Int32Array]",le="[object Uint8Array]",Q="[object Uint8ClampedArray]",ee="[object Uint16Array]",he="[object Uint32Array]",z={};z[T]=z[C]=z[R]=z[M]=z[S]=z[D]=z[_]=z[B]=z[$]=z[X]=z[U]=z[W]=z[K]=z[V]=z[te]=z[re]=z[q]=z[G]=z[le]=z[Q]=z[ee]=z[he]=!0,z[I]=z[P]=z[ie]=!1;function Z(H,ne,Y,ge,ae,pe){var me,Ne=ne&j,ce=ne&N,E=ne&L;if(Y&&(me=ae?Y(H,ge,ae,pe):Y(H)),me!==void 0)return me;if(!x(H))return H;var J=m(H);if(J){if(me=p(H),!Ne)return o(H,me)}else{var se=f(H),ue=se==P||se==F;if(v(H))return a(H,Ne);if(se==V||se==T||ue&&!ae){if(me=ce||ue?{}:g(H),!Ne)return ce?u(H,s(me,H)):i(H,t(me,H))}else{if(!z[se])return ae?H:{};me=h(H,se,Ne)}}pe||(pe=new e);var de=pe.get(H);if(de)return de;pe.set(H,me),b(H)?H.forEach(function(fe){me.add(Z(fe,ne,Y,fe,H,pe))}):y(H)&&H.forEach(function(fe,_e){me.set(_e,Z(fe,ne,Y,_e,H,pe))});var ve=E?ce?d:c:ce?w:k,xe=J?void 0:ve(H);return n(xe||H,function(fe,_e){xe&&(_e=fe,fe=H[_e]),r(me,_e,Z(fe,ne,Y,_e,H,pe))}),me}return ua=Z,ua}var fa,kd;function km(){if(kd)return fa;kd=1;var e=bd(),n=4;function r(t){return e(t,n)}return fa=r,fa}var pa,_d;function ha(){if(_d)return pa;_d=1;function e(n){return function(){return n}}return pa=e,pa}var ga,Sd;function _m(){if(Sd)return ga;Sd=1;function e(n){return function(r,t,s){for(var a=-1,o=Object(r),i=s(r),u=i.length;u--;){var c=i[n?u:++a];if(t(o[c],c,o)===!1)break}return r}}return ga=e,ga}var ma,wd;function va(){if(wd)return ma;wd=1;var e=_m(),n=e();return ma=n,ma}var ya,Td;function xa(){if(Td)return ya;Td=1;var e=va(),n=ze();function r(t,s){return t&&e(t,s,n)}return ya=r,ya}var ba,Ed;function Sm(){if(Ed)return ba;Ed=1;var e=Be();function n(r,t){return function(s,a){if(s==null)return s;if(!e(s))return r(s,a);for(var o=s.length,i=t?o:-1,u=Object(s);(t?i--:++i<o)&&a(u[i],i,u)!==!1;);return s}}return ba=n,ba}var ka,Nd;function Fr(){if(Nd)return ka;Nd=1;var e=xa(),n=Sm(),r=n(e);return ka=r,ka}var _a,Cd;function Ye(){if(Cd)return _a;Cd=1;function e(n){return n}return _a=e,_a}var Sa,jd;function Id(){if(jd)return Sa;jd=1;var e=Ye();function n(r){return typeof r=="function"?r:e}return Sa=n,Sa}var wa,Rd;function Od(){if(Rd)return wa;Rd=1;var e=Qt(),n=Fr(),r=Id(),t=ke();function s(a,o){var i=t(a)?e:n;return i(a,r(o))}return wa=s,wa}var Ta,Pd;function Ad(){return Pd||(Pd=1,Ta=Od()),Ta}var Ea,Ld;function wm(){if(Ld)return Ea;Ld=1;var e=Fr();function n(r,t){var s=[];return e(r,function(a,o,i){t(a,o,i)&&s.push(a)}),s}return Ea=n,Ea}var Na,qd;function Tm(){if(qd)return Na;qd=1;var e="__lodash_hash_undefined__";function n(r){return this.__data__.set(r,e),this}return Na=n,Na}var Ca,Dd;function Em(){if(Dd)return Ca;Dd=1;function e(n){return this.__data__.has(n)}return Ca=e,Ca}var ja,Md;function Wd(){if(Md)return ja;Md=1;var e=Vt(),n=Tm(),r=Em();function t(s){var a=-1,o=s==null?0:s.length;for(this.__data__=new e;++a<o;)this.add(s[a])}return t.prototype.add=t.prototype.push=n,t.prototype.has=r,ja=t,ja}var Ia,Bd;function Nm(){if(Bd)return Ia;Bd=1;function e(n,r){for(var t=-1,s=n==null?0:n.length;++t<s;)if(r(n[t],t,n))return!0;return!1}return Ia=e,Ia}var Ra,Fd;function $d(){if(Fd)return Ra;Fd=1;function e(n,r){return n.has(r)}return Ra=e,Ra}var Oa,zd;function Hd(){if(zd)return Oa;zd=1;var e=Wd(),n=Nm(),r=$d(),t=1,s=2;function a(o,i,u,c,d,f){var p=u&t,h=o.length,g=i.length;if(h!=g&&!(p&&g>h))return!1;var m=f.get(o),v=f.get(i);if(m&&v)return m==i&&v==o;var y=-1,x=!0,b=u&s?new e:void 0;for(f.set(o,i),f.set(i,o);++y<h;){var k=o[y],w=i[y];if(c)var j=p?c(w,k,y,i,o,f):c(k,w,y,o,i,f);if(j!==void 0){if(j)continue;x=!1;break}if(b){if(!n(i,function(N,L){if(!r(b,L)&&(k===N||d(k,N,u,c,f)))return b.push(L)})){x=!1;break}}else if(!(k===w||d(k,w,u,c,f))){x=!1;break}}return f.delete(o),f.delete(i),x}return Oa=a,Oa}var Pa,Kd;function Cm(){if(Kd)return Pa;Kd=1;function e(n){var r=-1,t=Array(n.size);return n.forEach(function(s,a){t[++r]=[a,s]}),t}return Pa=e,Pa}var Aa,Ud;function La(){if(Ud)return Aa;Ud=1;function e(n){var r=-1,t=Array(n.size);return n.forEach(function(s){t[++r]=s}),t}return Aa=e,Aa}var qa,Jd;function jm(){if(Jd)return qa;Jd=1;var e=er(),n=nd(),r=Qe(),t=Hd(),s=Cm(),a=La(),o=1,i=2,u="[object Boolean]",c="[object Date]",d="[object Error]",f="[object Map]",p="[object Number]",h="[object RegExp]",g="[object Set]",m="[object String]",v="[object Symbol]",y="[object ArrayBuffer]",x="[object DataView]",b=e?e.prototype:void 0,k=b?b.valueOf:void 0;function w(j,N,L,T,C,S,D){switch(L){case x:if(j.byteLength!=N.byteLength||j.byteOffset!=N.byteOffset)return!1;j=j.buffer,N=N.buffer;case y:return!(j.byteLength!=N.byteLength||!S(new n(j),new n(N)));case u:case c:case p:return r(+j,+N);case d:return j.name==N.name&&j.message==N.message;case h:case m:return j==N+"";case f:var I=s;case g:var P=T&o;if(I||(I=a),j.size!=N.size&&!P)return!1;var F=D.get(j);if(F)return F==N;T|=i,D.set(j,N);var W=t(I(j),I(N),T,C,S,D);return D.delete(j),W;case v:if(k)return k.call(j)==k.call(N)}return!1}return qa=w,qa}var Da,Gd;function Im(){if(Gd)return Da;Gd=1;var e=Jc(),n=1,r=Object.prototype,t=r.hasOwnProperty;function s(a,o,i,u,c,d){var f=i&n,p=e(a),h=p.length,g=e(o),m=g.length;if(h!=m&&!f)return!1;for(var v=h;v--;){var y=p[v];if(!(f?y in o:t.call(o,y)))return!1}var x=d.get(a),b=d.get(o);if(x&&b)return x==o&&b==a;var k=!0;d.set(a,o),d.set(o,a);for(var w=f;++v<h;){y=p[v];var j=a[y],N=o[y];if(u)var L=f?u(N,j,y,o,a,d):u(j,N,y,a,o,d);if(!(L===void 0?j===N||c(j,N,i,u,d):L)){k=!1;break}w||(w=y=="constructor")}if(k&&!w){var T=a.constructor,C=o.constructor;T!=C&&"constructor"in a&&"constructor"in o&&!(typeof T=="function"&&T instanceof T&&typeof C=="function"&&C instanceof C)&&(k=!1)}return d.delete(a),d.delete(o),k}return Da=s,Da}var Ma,Vd;function Rm(){if(Vd)return Ma;Vd=1;var e=Ar(),n=Hd(),r=jm(),t=Im(),s=tr(),a=ke(),o=rr(),i=yr(),u=1,c="[object Arguments]",d="[object Array]",f="[object Object]",p=Object.prototype,h=p.hasOwnProperty;function g(m,v,y,x,b,k){var w=a(m),j=a(v),N=w?d:s(m),L=j?d:s(v);N=N==c?f:N,L=L==c?f:L;var T=N==f,C=L==f,S=N==L;if(S&&o(m)){if(!o(v))return!1;w=!0,T=!1}if(S&&!T)return k||(k=new e),w||i(m)?n(m,v,y,x,b,k):r(m,v,N,y,x,b,k);if(!(y&u)){var D=T&&h.call(m,"__wrapped__"),I=C&&h.call(v,"__wrapped__");if(D||I){var P=D?m.value():m,F=I?v.value():v;return k||(k=new e),b(P,F,y,x,k)}}return S?(k||(k=new e),t(m,v,y,x,b,k)):!1}return Ma=g,Ma}var Wa,Yd;function Xd(){if(Yd)return Wa;Yd=1;var e=Rm(),n=Me();function r(t,s,a,o,i){return t===s?!0:t==null||s==null||!n(t)&&!n(s)?t!==t&&s!==s:e(t,s,a,o,r,i)}return Wa=r,Wa}var Ba,Zd;function Om(){if(Zd)return Ba;Zd=1;var e=Ar(),n=Xd(),r=1,t=2;function s(a,o,i,u){var c=i.length,d=c,f=!u;if(a==null)return!d;for(a=Object(a);c--;){var p=i[c];if(f&&p[2]?p[1]!==a[p[0]]:!(p[0]in a))return!1}for(;++c<d;){p=i[c];var h=p[0],g=a[h],m=p[1];if(f&&p[2]){if(g===void 0&&!(h in a))return!1}else{var v=new e;if(u)var y=u(g,m,h,a,o,v);if(!(y===void 0?n(m,g,r|t,u,v):y))return!1}}return!0}return Ba=s,Ba}var Fa,Qd;function eu(){if(Qd)return Fa;Qd=1;var e=Ie();function n(r){return r===r&&!e(r)}return Fa=n,Fa}var $a,ru;function Pm(){if(ru)return $a;ru=1;var e=eu(),n=ze();function r(t){for(var s=n(t),a=s.length;a--;){var o=s[a],i=t[o];s[a]=[o,i,e(i)]}return s}return $a=r,$a}var za,tu;function nu(){if(tu)return za;tu=1;function e(n,r){return function(t){return t==null?!1:t[n]===r&&(r!==void 0||n in Object(t))}}return za=e,za}var Ha,au;function Am(){if(au)return Ha;au=1;var e=Om(),n=Pm(),r=nu();function t(s){var a=n(s);return a.length==1&&a[0][2]?r(a[0][0],a[0][1]):function(o){return o===s||e(o,s,a)}}return Ha=t,Ha}var Ka,su;function nr(){if(su)return Ka;su=1;var e=Je(),n=Me(),r="[object Symbol]";function t(s){return typeof s=="symbol"||n(s)&&e(s)==r}return Ka=t,Ka}var Ua,ou;function Ja(){if(ou)return Ua;ou=1;var e=ke(),n=nr(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,t=/^\w*$/;function s(a,o){if(e(a))return!1;var i=typeof a;return i=="number"||i=="symbol"||i=="boolean"||a==null||n(a)?!0:t.test(a)||!r.test(a)||o!=null&&a in Object(o)}return Ua=s,Ua}var Ga,iu;function Lm(){if(iu)return Ga;iu=1;var e=Vt(),n="Expected a function";function r(t,s){if(typeof t!="function"||s!=null&&typeof s!="function")throw new TypeError(n);var a=function(){var o=arguments,i=s?s.apply(this,o):o[0],u=a.cache;if(u.has(i))return u.get(i);var c=t.apply(this,o);return a.cache=u.set(i,c)||u,c};return a.cache=new(r.Cache||e),a}return r.Cache=e,Ga=r,Ga}var Va,lu;function qm(){if(lu)return Va;lu=1;var e=Lm(),n=500;function r(t){var s=e(t,function(o){return a.size===n&&a.clear(),o}),a=s.cache;return s}return Va=r,Va}var Ya,cu;function Dm(){if(cu)return Ya;cu=1;var e=qm(),n=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,t=e(function(s){var a=[];return s.charCodeAt(0)===46&&a.push(""),s.replace(n,function(o,i,u,c){a.push(u?c.replace(r,"$1"):i||o)}),a});return Ya=t,Ya}var Xa,du;function $r(){if(du)return Xa;du=1;function e(n,r){for(var t=-1,s=n==null?0:n.length,a=Array(s);++t<s;)a[t]=r(n[t],t,n);return a}return Xa=e,Xa}var Za,uu;function Mm(){if(uu)return Za;uu=1;var e=er(),n=$r(),r=ke(),t=nr(),s=e?e.prototype:void 0,a=s?s.toString:void 0;function o(i){if(typeof i=="string")return i;if(r(i))return n(i,o)+"";if(t(i))return a?a.call(i):"";var u=i+"";return u=="0"&&1/i==-1/0?"-0":u}return Za=o,Za}var Qa,fu;function pu(){if(fu)return Qa;fu=1;var e=Mm();function n(r){return r==null?"":e(r)}return Qa=n,Qa}var es,hu;function zr(){if(hu)return es;hu=1;var e=ke(),n=Ja(),r=Dm(),t=pu();function s(a,o){return e(a)?a:n(a,o)?[a]:r(t(a))}return es=s,es}var rs,gu;function br(){if(gu)return rs;gu=1;var e=nr();function n(r){if(typeof r=="string"||e(r))return r;var t=r+"";return t=="0"&&1/r==-1/0?"-0":t}return rs=n,rs}var ts,mu;function Hr(){if(mu)return ts;mu=1;var e=zr(),n=br();function r(t,s){s=e(s,t);for(var a=0,o=s.length;t!=null&&a<o;)t=t[n(s[a++])];return a&&a==o?t:void 0}return ts=r,ts}var ns,vu;function Wm(){if(vu)return ns;vu=1;var e=Hr();function n(r,t,s){var a=r==null?void 0:e(r,t);return a===void 0?s:a}return ns=n,ns}var as,yu;function Bm(){if(yu)return as;yu=1;function e(n,r){return n!=null&&r in Object(n)}return as=e,as}var ss,xu;function bu(){if(xu)return ss;xu=1;var e=zr(),n=gr(),r=ke(),t=Dr(),s=pn(),a=br();function o(i,u,c){u=e(u,i);for(var d=-1,f=u.length,p=!1;++d<f;){var h=a(u[d]);if(!(p=i!=null&&c(i,h)))break;i=i[h]}return p||++d!=f?p:(f=i==null?0:i.length,!!f&&s(f)&&t(h,f)&&(r(i)||n(i)))}return ss=o,ss}var os,ku;function _u(){if(ku)return os;ku=1;var e=Bm(),n=bu();function r(t,s){return t!=null&&n(t,s,e)}return os=r,os}var is,Su;function Fm(){if(Su)return is;Su=1;var e=Xd(),n=Wm(),r=_u(),t=Ja(),s=eu(),a=nu(),o=br(),i=1,u=2;function c(d,f){return t(d)&&s(f)?a(o(d),f):function(p){var h=n(p,d);return h===void 0&&h===f?r(p,d):e(f,h,i|u)}}return is=c,is}var ls,wu;function Tu(){if(wu)return ls;wu=1;function e(n){return function(r){return r?.[n]}}return ls=e,ls}var cs,Eu;function $m(){if(Eu)return cs;Eu=1;var e=Hr();function n(r){return function(t){return e(t,r)}}return cs=n,cs}var ds,Nu;function zm(){if(Nu)return ds;Nu=1;var e=Tu(),n=$m(),r=Ja(),t=br();function s(a){return r(a)?e(t(a)):n(a)}return ds=s,ds}var us,Cu;function Fe(){if(Cu)return us;Cu=1;var e=Am(),n=Fm(),r=Ye(),t=ke(),s=zm();function a(o){return typeof o=="function"?o:o==null?r:typeof o=="object"?t(o)?n(o[0],o[1]):e(o):s(o)}return us=a,us}var fs,ju;function Iu(){if(ju)return fs;ju=1;var e=Ac(),n=wm(),r=Fe(),t=ke();function s(a,o){var i=t(a)?e:n;return i(a,r(o,3))}return fs=s,fs}var ps,Ru;function Hm(){if(Ru)return ps;Ru=1;var e=Object.prototype,n=e.hasOwnProperty;function r(t,s){return t!=null&&n.call(t,s)}return ps=r,ps}var hs,Ou;function Pu(){if(Ou)return hs;Ou=1;var e=Hm(),n=bu();function r(t,s){return t!=null&&n(t,s,e)}return hs=r,hs}var gs,Au;function Km(){if(Au)return gs;Au=1;var e=Sn(),n=tr(),r=gr(),t=ke(),s=Be(),a=rr(),o=Wr(),i=yr(),u="[object Map]",c="[object Set]",d=Object.prototype,f=d.hasOwnProperty;function p(h){if(h==null)return!0;if(s(h)&&(t(h)||typeof h=="string"||typeof h.splice=="function"||a(h)||i(h)||r(h)))return!h.length;var g=n(h);if(g==u||g==c)return!h.size;if(o(h))return!e(h).length;for(var m in h)if(f.call(h,m))return!1;return!0}return gs=p,gs}var ms,Lu;function qu(){if(Lu)return ms;Lu=1;function e(n){return n===void 0}return ms=e,ms}var vs,Du;function Mu(){if(Du)return vs;Du=1;var e=Fr(),n=Be();function r(t,s){var a=-1,o=n(t)?Array(t.length):[];return e(t,function(i,u,c){o[++a]=s(i,u,c)}),o}return vs=r,vs}var ys,Wu;function Bu(){if(Wu)return ys;Wu=1;var e=$r(),n=Fe(),r=Mu(),t=ke();function s(a,o){var i=t(a)?e:r;return i(a,n(o,3))}return ys=s,ys}var xs,Fu;function Um(){if(Fu)return xs;Fu=1;function e(n,r,t,s){var a=-1,o=n==null?0:n.length;for(s&&o&&(t=n[++a]);++a<o;)t=r(t,n[a],a,n);return t}return xs=e,xs}var bs,$u;function Jm(){if($u)return bs;$u=1;function e(n,r,t,s,a){return a(n,function(o,i,u){t=s?(s=!1,o):r(t,o,i,u)}),t}return bs=e,bs}var ks,zu;function Hu(){if(zu)return ks;zu=1;var e=Um(),n=Fr(),r=Fe(),t=Jm(),s=ke();function a(o,i,u){var c=s(o)?e:t,d=arguments.length<3;return c(o,r(i,4),u,d,n)}return ks=a,ks}var _s,Ku;function Gm(){if(Ku)return _s;Ku=1;var e=Je(),n=ke(),r=Me(),t="[object String]";function s(a){return typeof a=="string"||!n(a)&&r(a)&&e(a)==t}return _s=s,_s}var Ss,Uu;function Vm(){if(Uu)return Ss;Uu=1;var e=Tu(),n=e("length");return Ss=n,Ss}var ws,Ju;function Ym(){if(Ju)return ws;Ju=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",t="\\u20d0-\\u20ff",s=n+r+t,a="\\ufe0e\\ufe0f",o="\\u200d",i=RegExp("["+o+e+s+a+"]");function u(c){return i.test(c)}return ws=u,ws}var Ts,Gu;function Xm(){if(Gu)return Ts;Gu=1;var e="\\ud800-\\udfff",n="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",t="\\u20d0-\\u20ff",s=n+r+t,a="\\ufe0e\\ufe0f",o="["+e+"]",i="["+s+"]",u="\\ud83c[\\udffb-\\udfff]",c="(?:"+i+"|"+u+")",d="[^"+e+"]",f="(?:\\ud83c[\\udde6-\\uddff]){2}",p="[\\ud800-\\udbff][\\udc00-\\udfff]",h="\\u200d",g=c+"?",m="["+a+"]?",v="(?:"+h+"(?:"+[d,f,p].join("|")+")"+m+g+")*",y=m+g+v,x="(?:"+[d+i+"?",i,f,p,o].join("|")+")",b=RegExp(u+"(?="+u+")|"+x+y,"g");function k(w){for(var j=b.lastIndex=0;b.test(w);)++j;return j}return Ts=k,Ts}var Es,Vu;function Zm(){if(Vu)return Es;Vu=1;var e=Vm(),n=Ym(),r=Xm();function t(s){return n(s)?r(s):e(s)}return Es=t,Es}var Ns,Yu;function Qm(){if(Yu)return Ns;Yu=1;var e=Sn(),n=tr(),r=Be(),t=Gm(),s=Zm(),a="[object Map]",o="[object Set]";function i(u){if(u==null)return 0;if(r(u))return t(u)?s(u):u.length;var c=n(u);return c==a||c==o?u.size:e(u).length}return Ns=i,Ns}var Cs,Xu;function ev(){if(Xu)return Cs;Xu=1;var e=Qt(),n=fd(),r=xa(),t=Fe(),s=Br(),a=ke(),o=rr(),i=pr(),u=Ie(),c=yr();function d(f,p,h){var g=a(f),m=g||o(f)||c(f);if(p=t(p,4),h==null){var v=f&&f.constructor;m?h=g?new v:[]:u(f)?h=i(v)?n(s(f)):{}:h={}}return(m?e:r)(f,function(y,x,b){return p(h,y,x,b)}),h}return Cs=d,Cs}var js,Zu;function rv(){if(Zu)return js;Zu=1;var e=er(),n=gr(),r=ke(),t=e?e.isConcatSpreadable:void 0;function s(a){return r(a)||n(a)||!!(t&&a&&a[t])}return js=s,js}var Is,Qu;function Rs(){if(Qu)return Is;Qu=1;var e=Mn(),n=rv();function r(t,s,a,o,i){var u=-1,c=t.length;for(a||(a=n),i||(i=[]);++u<c;){var d=t[u];s>0&&a(d)?s>1?r(d,s-1,a,o,i):e(i,d):o||(i[i.length]=d)}return i}return Is=r,Is}var Os,ef;function tv(){if(ef)return Os;ef=1;function e(n,r,t){switch(t.length){case 0:return n.call(r);case 1:return n.call(r,t[0]);case 2:return n.call(r,t[0],t[1]);case 3:return n.call(r,t[0],t[1],t[2])}return n.apply(r,t)}return Os=e,Os}var Ps,rf;function tf(){if(rf)return Ps;rf=1;var e=tv(),n=Math.max;function r(t,s,a){return s=n(s===void 0?t.length-1:s,0),function(){for(var o=arguments,i=-1,u=n(o.length-s,0),c=Array(u);++i<u;)c[i]=o[s+i];i=-1;for(var d=Array(s+1);++i<s;)d[i]=o[i];return d[s]=a(c),e(t,this,d)}}return Ps=r,Ps}var As,nf;function nv(){if(nf)return As;nf=1;var e=ha(),n=Zl(),r=Ye(),t=n?function(s,a){return n(s,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:r;return As=t,As}var Ls,af;function av(){if(af)return Ls;af=1;var e=800,n=16,r=Date.now;function t(s){var a=0,o=0;return function(){var i=r(),u=n-(i-o);if(o=i,u>0){if(++a>=e)return arguments[0]}else a=0;return s.apply(void 0,arguments)}}return Ls=t,Ls}var qs,sf;function of(){if(sf)return qs;sf=1;var e=nv(),n=av(),r=n(e);return qs=r,qs}var Ds,lf;function Kr(){if(lf)return Ds;lf=1;var e=Ye(),n=tf(),r=of();function t(s,a){return r(n(s,a,e),s+"")}return Ds=t,Ds}var Ms,cf;function df(){if(cf)return Ms;cf=1;function e(n,r,t,s){for(var a=n.length,o=t+(s?1:-1);s?o--:++o<a;)if(r(n[o],o,n))return o;return-1}return Ms=e,Ms}var Ws,uf;function sv(){if(uf)return Ws;uf=1;function e(n){return n!==n}return Ws=e,Ws}var Bs,ff;function ov(){if(ff)return Bs;ff=1;function e(n,r,t){for(var s=t-1,a=n.length;++s<a;)if(n[s]===r)return s;return-1}return Bs=e,Bs}var Fs,pf;function iv(){if(pf)return Fs;pf=1;var e=df(),n=sv(),r=ov();function t(s,a,o){return a===a?r(s,a,o):e(s,n,o)}return Fs=t,Fs}var $s,hf;function lv(){if(hf)return $s;hf=1;var e=iv();function n(r,t){var s=r==null?0:r.length;return!!s&&e(r,t,0)>-1}return $s=n,$s}var zs,gf;function cv(){if(gf)return zs;gf=1;function e(n,r,t){for(var s=-1,a=n==null?0:n.length;++s<a;)if(t(r,n[s]))return!0;return!1}return zs=e,zs}var Hs,mf;function dv(){if(mf)return Hs;mf=1;function e(){}return Hs=e,Hs}var Ks,vf;function uv(){if(vf)return Ks;vf=1;var e=Zc(),n=dv(),r=La(),t=1/0,s=e&&1/r(new e([,-0]))[1]==t?function(a){return new e(a)}:n;return Ks=s,Ks}var Us,yf;function fv(){if(yf)return Us;yf=1;var e=Wd(),n=lv(),r=cv(),t=$d(),s=uv(),a=La(),o=200;function i(u,c,d){var f=-1,p=n,h=u.length,g=!0,m=[],v=m;if(d)g=!1,p=r;else if(h>=o){var y=c?null:s(u);if(y)return a(y);g=!1,p=t,v=new e}else v=c?[]:m;e:for(;++f<h;){var x=u[f],b=c?c(x):x;if(x=d||x!==0?x:0,g&&b===b){for(var k=v.length;k--;)if(v[k]===b)continue e;c&&v.push(b),m.push(x)}else p(v,b,d)||(v!==m&&v.push(b),m.push(x))}return m}return Us=i,Us}var Js,xf;function bf(){if(xf)return Js;xf=1;var e=Be(),n=Me();function r(t){return n(t)&&e(t)}return Js=r,Js}var Gs,kf;function pv(){if(kf)return Gs;kf=1;var e=Rs(),n=Kr(),r=fv(),t=bf(),s=n(function(a){return r(e(a,1,t,!0))});return Gs=s,Gs}var Vs,_f;function hv(){if(_f)return Vs;_f=1;var e=$r();function n(r,t){return e(t,function(s){return r[s]})}return Vs=n,Vs}var Ys,Sf;function wf(){if(Sf)return Ys;Sf=1;var e=hv(),n=ze();function r(t){return t==null?[]:e(t,n(t))}return Ys=r,Ys}var Xs,Tf;function Re(){if(Tf)return Xs;Tf=1;var e;if(typeof st=="function")try{e={clone:km(),constant:ha(),each:Ad(),filter:Iu(),has:Pu(),isArray:ke(),isEmpty:Km(),isFunction:pr(),isUndefined:qu(),keys:ze(),map:Bu(),reduce:Hu(),size:Qm(),transform:ev(),union:pv(),values:wf()}}catch{}return e||(e=window._),Xs=e,Xs}var Zs,Ef;function Qs(){if(Ef)return Zs;Ef=1;var e=Re();Zs=s;var n="\0",r="\0",t="";function s(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(d){return this._label=d,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(f){return e.isEmpty(d._in[f])})},s.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(f){return e.isEmpty(d._out[f])})},s.prototype.setNodes=function(d,f){var p=arguments,h=this;return e.each(d,function(g){p.length>1?h.setNode(g,f):h.setNode(g)}),this},s.prototype.setNode=function(d,f){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=f),this):(this._nodes[d]=arguments.length>1?f:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=r,this._children[d]={},this._children[r][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},s.prototype.node=function(d){return this._nodes[d]},s.prototype.hasNode=function(d){return e.has(this._nodes,d)},s.prototype.removeNode=function(d){var f=this;if(e.has(this._nodes,d)){var p=function(h){f.removeEdge(f._edgeObjs[h])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(h){f.setParent(h)}),delete this._children[d]),e.each(e.keys(this._in[d]),p),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),p),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},s.prototype.setParent=function(d,f){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(f))f=r;else{f+="";for(var p=f;!e.isUndefined(p);p=this.parent(p))if(p===d)throw new Error("Setting "+f+" as parent of "+d+" would create a cycle");this.setNode(f)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=f,this._children[f][d]=!0,this},s.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},s.prototype.parent=function(d){if(this._isCompound){var f=this._parent[d];if(f!==r)return f}},s.prototype.children=function(d){if(e.isUndefined(d)&&(d=r),this._isCompound){var f=this._children[d];if(f)return e.keys(f)}else{if(d===r)return this.nodes();if(this.hasNode(d))return[]}},s.prototype.predecessors=function(d){var f=this._preds[d];if(f)return e.keys(f)},s.prototype.successors=function(d){var f=this._sucs[d];if(f)return e.keys(f)},s.prototype.neighbors=function(d){var f=this.predecessors(d);if(f)return e.union(f,this.successors(d))},s.prototype.isLeaf=function(d){var f;return this.isDirected()?f=this.successors(d):f=this.neighbors(d),f.length===0},s.prototype.filterNodes=function(d){var f=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});f.setGraph(this.graph());var p=this;e.each(this._nodes,function(m,v){d(v)&&f.setNode(v,m)}),e.each(this._edgeObjs,function(m){f.hasNode(m.v)&&f.hasNode(m.w)&&f.setEdge(m,p.edge(m))});var h={};function g(m){var v=p.parent(m);return v===void 0||f.hasNode(v)?(h[m]=v,v):v in h?h[v]:g(v)}return this._isCompound&&e.each(f.nodes(),function(m){f.setParent(m,g(m))}),f},s.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(d,f){var p=this,h=arguments;return e.reduce(d,function(g,m){return h.length>1?p.setEdge(g,m,f):p.setEdge(g,m),m}),this},s.prototype.setEdge=function(){var d,f,p,h,g=!1,m=arguments[0];typeof m=="object"&&m!==null&&"v"in m?(d=m.v,f=m.w,p=m.name,arguments.length===2&&(h=arguments[1],g=!0)):(d=m,f=arguments[1],p=arguments[3],arguments.length>2&&(h=arguments[2],g=!0)),d=""+d,f=""+f,e.isUndefined(p)||(p=""+p);var v=i(this._isDirected,d,f,p);if(e.has(this._edgeLabels,v))return g&&(this._edgeLabels[v]=h),this;if(!e.isUndefined(p)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(f),this._edgeLabels[v]=g?h:this._defaultEdgeLabelFn(d,f,p);var y=u(this._isDirected,d,f,p);return d=y.v,f=y.w,Object.freeze(y),this._edgeObjs[v]=y,a(this._preds[f],d),a(this._sucs[d],f),this._in[f][v]=y,this._out[d][v]=y,this._edgeCount++,this},s.prototype.edge=function(d,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,d,f,p);return this._edgeLabels[h]},s.prototype.hasEdge=function(d,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,d,f,p);return e.has(this._edgeLabels,h)},s.prototype.removeEdge=function(d,f,p){var h=arguments.length===1?c(this._isDirected,arguments[0]):i(this._isDirected,d,f,p),g=this._edgeObjs[h];return g&&(d=g.v,f=g.w,delete this._edgeLabels[h],delete this._edgeObjs[h],o(this._preds[f],d),o(this._sucs[d],f),delete this._in[f][h],delete this._out[d][h],this._edgeCount--),this},s.prototype.inEdges=function(d,f){var p=this._in[d];if(p){var h=e.values(p);return f?e.filter(h,function(g){return g.v===f}):h}},s.prototype.outEdges=function(d,f){var p=this._out[d];if(p){var h=e.values(p);return f?e.filter(h,function(g){return g.w===f}):h}},s.prototype.nodeEdges=function(d,f){var p=this.inEdges(d,f);if(p)return p.concat(this.outEdges(d,f))};function a(d,f){d[f]?d[f]++:d[f]=1}function o(d,f){--d[f]||delete d[f]}function i(d,f,p,h){var g=""+f,m=""+p;if(!d&&g>m){var v=g;g=m,m=v}return g+t+m+t+(e.isUndefined(h)?n:h)}function u(d,f,p,h){var g=""+f,m=""+p;if(!d&&g>m){var v=g;g=m,m=v}var y={v:g,w:m};return h&&(y.name=h),y}function c(d,f){return i(d,f.v,f.w,f.name)}return Zs}var eo,Nf;function gv(){return Nf||(Nf=1,eo="2.1.8"),eo}var ro,Cf;function mv(){return Cf||(Cf=1,ro={Graph:Qs(),version:gv()}),ro}var to,jf;function vv(){if(jf)return to;jf=1;var e=Re(),n=Qs();to={write:r,read:a};function r(o){var i={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:t(o),edges:s(o)};return e.isUndefined(o.graph())||(i.value=e.clone(o.graph())),i}function t(o){return e.map(o.nodes(),function(i){var u=o.node(i),c=o.parent(i),d={v:i};return e.isUndefined(u)||(d.value=u),e.isUndefined(c)||(d.parent=c),d})}function s(o){return e.map(o.edges(),function(i){var u=o.edge(i),c={v:i.v,w:i.w};return e.isUndefined(i.name)||(c.name=i.name),e.isUndefined(u)||(c.value=u),c})}function a(o){var i=new n(o.options).setGraph(o.value);return e.each(o.nodes,function(u){i.setNode(u.v,u.value),u.parent&&i.setParent(u.v,u.parent)}),e.each(o.edges,function(u){i.setEdge({v:u.v,w:u.w,name:u.name},u.value)}),i}return to}var no,If;function yv(){if(If)return no;If=1;var e=Re();no=n;function n(r){var t={},s=[],a;function o(i){e.has(t,i)||(t[i]=!0,a.push(i),e.each(r.successors(i),o),e.each(r.predecessors(i),o))}return e.each(r.nodes(),function(i){a=[],o(i),a.length&&s.push(a)}),s}return no}var ao,Rf;function Of(){if(Rf)return ao;Rf=1;var e=Re();ao=n;function n(){this._arr=[],this._keyIndices={}}return n.prototype.size=function(){return this._arr.length},n.prototype.keys=function(){return this._arr.map(function(r){return r.key})},n.prototype.has=function(r){return e.has(this._keyIndices,r)},n.prototype.priority=function(r){var t=this._keyIndices[r];if(t!==void 0)return this._arr[t].priority},n.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},n.prototype.add=function(r,t){var s=this._keyIndices;if(r=String(r),!e.has(s,r)){var a=this._arr,o=a.length;return s[r]=o,a.push({key:r,priority:t}),this._decrease(o),!0}return!1},n.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var r=this._arr.pop();return delete this._keyIndices[r.key],this._heapify(0),r.key},n.prototype.decrease=function(r,t){var s=this._keyIndices[r];if(t>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[s].priority+" New: "+t);this._arr[s].priority=t,this._decrease(s)},n.prototype._heapify=function(r){var t=this._arr,s=2*r,a=s+1,o=r;s<t.length&&(o=t[s].priority<t[o].priority?s:o,a<t.length&&(o=t[a].priority<t[o].priority?a:o),o!==r&&(this._swap(r,o),this._heapify(o)))},n.prototype._decrease=function(r){for(var t=this._arr,s=t[r].priority,a;r!==0&&(a=r>>1,!(t[a].priority<s));)this._swap(r,a),r=a},n.prototype._swap=function(r,t){var s=this._arr,a=this._keyIndices,o=s[r],i=s[t];s[r]=i,s[t]=o,a[i.key]=r,a[o.key]=t},ao}var so,Pf;function Af(){if(Pf)return so;Pf=1;var e=Re(),n=Of();so=t;var r=e.constant(1);function t(a,o,i,u){return s(a,String(o),i||r,u||function(c){return a.outEdges(c)})}function s(a,o,i,u){var c={},d=new n,f,p,h=function(g){var m=g.v!==f?g.v:g.w,v=c[m],y=i(g),x=p.distance+y;if(y<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+g+" Weight: "+y);x<v.distance&&(v.distance=x,v.predecessor=f,d.decrease(m,x))};for(a.nodes().forEach(function(g){var m=g===o?0:Number.POSITIVE_INFINITY;c[g]={distance:m},d.add(g,m)});d.size()>0&&(f=d.removeMin(),p=c[f],p.distance!==Number.POSITIVE_INFINITY);)u(f).forEach(h);return c}return so}var oo,Lf;function xv(){if(Lf)return oo;Lf=1;var e=Af(),n=Re();oo=r;function r(t,s,a){return n.transform(t.nodes(),function(o,i){o[i]=e(t,i,s,a)},{})}return oo}var io,qf;function Df(){if(qf)return io;qf=1;var e=Re();io=n;function n(r){var t=0,s=[],a={},o=[];function i(u){var c=a[u]={onStack:!0,lowlink:t,index:t++};if(s.push(u),r.successors(u).forEach(function(p){e.has(a,p)?a[p].onStack&&(c.lowlink=Math.min(c.lowlink,a[p].index)):(i(p),c.lowlink=Math.min(c.lowlink,a[p].lowlink))}),c.lowlink===c.index){var d=[],f;do f=s.pop(),a[f].onStack=!1,d.push(f);while(u!==f);o.push(d)}}return r.nodes().forEach(function(u){e.has(a,u)||i(u)}),o}return io}var lo,Mf;function bv(){if(Mf)return lo;Mf=1;var e=Re(),n=Df();lo=r;function r(t){return e.filter(n(t),function(s){return s.length>1||s.length===1&&t.hasEdge(s[0],s[0])})}return lo}var co,Wf;function kv(){if(Wf)return co;Wf=1;var e=Re();co=r;var n=e.constant(1);function r(s,a,o){return t(s,a||n,o||function(i){return s.outEdges(i)})}function t(s,a,o){var i={},u=s.nodes();return u.forEach(function(c){i[c]={},i[c][c]={distance:0},u.forEach(function(d){c!==d&&(i[c][d]={distance:Number.POSITIVE_INFINITY})}),o(c).forEach(function(d){var f=d.v===c?d.w:d.v,p=a(d);i[c][f]={distance:p,predecessor:c}})}),u.forEach(function(c){var d=i[c];u.forEach(function(f){var p=i[f];u.forEach(function(h){var g=p[c],m=d[h],v=p[h],y=g.distance+m.distance;y<v.distance&&(v.distance=y,v.predecessor=m.predecessor)})})}),i}return co}var uo,Bf;function Ff(){if(Bf)return uo;Bf=1;var e=Re();uo=n,n.CycleException=r;function n(t){var s={},a={},o=[];function i(u){if(e.has(a,u))throw new r;e.has(s,u)||(a[u]=!0,s[u]=!0,e.each(t.predecessors(u),i),delete a[u],o.push(u))}if(e.each(t.sinks(),i),e.size(s)!==t.nodeCount())throw new r;return o}function r(){}return r.prototype=new Error,uo}var fo,$f;function _v(){if($f)return fo;$f=1;var e=Ff();fo=n;function n(r){try{e(r)}catch(t){if(t instanceof e.CycleException)return!1;throw t}return!0}return fo}var po,zf;function Hf(){if(zf)return po;zf=1;var e=Re();po=n;function n(t,s,a){e.isArray(s)||(s=[s]);var o=(t.isDirected()?t.successors:t.neighbors).bind(t),i=[],u={};return e.each(s,function(c){if(!t.hasNode(c))throw new Error("Graph does not have node: "+c);r(t,c,a==="post",u,o,i)}),i}function r(t,s,a,o,i,u){e.has(o,s)||(o[s]=!0,a||u.push(s),e.each(i(s),function(c){r(t,c,a,o,i,u)}),a&&u.push(s))}return po}var ho,Kf;function Sv(){if(Kf)return ho;Kf=1;var e=Hf();ho=n;function n(r,t){return e(r,t,"post")}return ho}var go,Uf;function wv(){if(Uf)return go;Uf=1;var e=Hf();go=n;function n(r,t){return e(r,t,"pre")}return go}var mo,Jf;function Tv(){if(Jf)return mo;Jf=1;var e=Re(),n=Qs(),r=Of();mo=t;function t(s,a){var o=new n,i={},u=new r,c;function d(p){var h=p.v===c?p.w:p.v,g=u.priority(h);if(g!==void 0){var m=a(p);m<g&&(i[h]=c,u.decrease(h,m))}}if(s.nodeCount()===0)return o;e.each(s.nodes(),function(p){u.add(p,Number.POSITIVE_INFINITY),o.setNode(p)}),u.decrease(s.nodes()[0],0);for(var f=!1;u.size()>0;){if(c=u.removeMin(),e.has(i,c))o.setEdge(c,i[c]);else{if(f)throw new Error("Input graph is not connected: "+s);f=!0}s.nodeEdges(c).forEach(d)}return o}return mo}var vo,Gf;function Ev(){return Gf||(Gf=1,vo={components:yv(),dijkstra:Af(),dijkstraAll:xv(),findCycles:bv(),floydWarshall:kv(),isAcyclic:_v(),postorder:Sv(),preorder:wv(),prim:Tv(),tarjan:Df(),topsort:Ff()}),vo}var yo,Vf;function Nv(){if(Vf)return yo;Vf=1;var e=mv();return yo={Graph:e.Graph,json:vv(),alg:Ev(),version:e.version},yo}var xo,Yf;function Ae(){if(Yf)return xo;Yf=1;var e;if(typeof st=="function")try{e=Nv()}catch{}return e||(e=window.graphlib),xo=e,xo}var bo,Xf;function Cv(){if(Xf)return bo;Xf=1;var e=bd(),n=1,r=4;function t(s){return e(s,n|r)}return bo=t,bo}var ko,Zf;function Ur(){if(Zf)return ko;Zf=1;var e=Qe(),n=Be(),r=Dr(),t=Ie();function s(a,o,i){if(!t(i))return!1;var u=typeof o;return(u=="number"?n(i)&&r(o,i.length):u=="string"&&o in i)?e(i[o],a):!1}return ko=s,ko}var _o,Qf;function jv(){if(Qf)return _o;Qf=1;var e=Kr(),n=Qe(),r=Ur(),t=Ve(),s=Object.prototype,a=s.hasOwnProperty,o=e(function(i,u){i=Object(i);var c=-1,d=u.length,f=d>2?u[2]:void 0;for(f&&r(u[0],u[1],f)&&(d=1);++c<d;)for(var p=u[c],h=t(p),g=-1,m=h.length;++g<m;){var v=h[g],y=i[v];(y===void 0||n(y,s[v])&&!a.call(i,v))&&(i[v]=p[v])}return i});return _o=o,_o}var So,ep;function Iv(){if(ep)return So;ep=1;var e=Fe(),n=Be(),r=ze();function t(s){return function(a,o,i){var u=Object(a);if(!n(a)){var c=e(o,3);a=r(a),o=function(f){return c(u[f],f,u)}}var d=s(a,o,i);return d>-1?u[c?a[d]:d]:void 0}}return So=t,So}var wo,rp;function Rv(){if(rp)return wo;rp=1;var e=/\s/;function n(r){for(var t=r.length;t--&&e.test(r.charAt(t)););return t}return wo=n,wo}var To,tp;function Ov(){if(tp)return To;tp=1;var e=Rv(),n=/^\s+/;function r(t){return t&&t.slice(0,e(t)+1).replace(n,"")}return To=r,To}var Eo,np;function Pv(){if(np)return Eo;np=1;var e=Ov(),n=Ie(),r=nr(),t=NaN,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,o=/^0o[0-7]+$/i,i=parseInt;function u(c){if(typeof c=="number")return c;if(r(c))return t;if(n(c)){var d=typeof c.valueOf=="function"?c.valueOf():c;c=n(d)?d+"":d}if(typeof c!="string")return c===0?c:+c;c=e(c);var f=a.test(c);return f||o.test(c)?i(c.slice(2),f?2:8):s.test(c)?t:+c}return Eo=u,Eo}var No,ap;function sp(){if(ap)return No;ap=1;var e=Pv(),n=1/0,r=17976931348623157e292;function t(s){if(!s)return s===0?s:0;if(s=e(s),s===n||s===-n){var a=s<0?-1:1;return a*r}return s===s?s:0}return No=t,No}var Co,op;function Av(){if(op)return Co;op=1;var e=sp();function n(r){var t=e(r),s=t%1;return t===t?s?t-s:t:0}return Co=n,Co}var jo,ip;function Lv(){if(ip)return jo;ip=1;var e=df(),n=Fe(),r=Av(),t=Math.max;function s(a,o,i){var u=a==null?0:a.length;if(!u)return-1;var c=i==null?0:r(i);return c<0&&(c=t(u+c,0)),e(a,n(o,3),c)}return jo=s,jo}var Io,lp;function qv(){if(lp)return Io;lp=1;var e=Iv(),n=Lv(),r=e(n);return Io=r,Io}var Ro,cp;function dp(){if(cp)return Ro;cp=1;var e=Rs();function n(r){var t=r==null?0:r.length;return t?e(r,1):[]}return Ro=n,Ro}var Oo,up;function Dv(){if(up)return Oo;up=1;var e=va(),n=Id(),r=Ve();function t(s,a){return s==null?s:e(s,n(a),r)}return Oo=t,Oo}var Po,fp;function Mv(){if(fp)return Po;fp=1;function e(n){var r=n==null?0:n.length;return r?n[r-1]:void 0}return Po=e,Po}var Ao,pp;function Wv(){if(pp)return Ao;pp=1;var e=Lr(),n=xa(),r=Fe();function t(s,a){var o={};return a=r(a,3),n(s,function(i,u,c){e(o,u,a(i,u,c))}),o}return Ao=t,Ao}var Lo,hp;function qo(){if(hp)return Lo;hp=1;var e=nr();function n(r,t,s){for(var a=-1,o=r.length;++a<o;){var i=r[a],u=t(i);if(u!=null&&(c===void 0?u===u&&!e(u):s(u,c)))var c=u,d=i}return d}return Lo=n,Lo}var Do,gp;function Bv(){if(gp)return Do;gp=1;function e(n,r){return n>r}return Do=e,Do}var Mo,mp;function Fv(){if(mp)return Mo;mp=1;var e=qo(),n=Bv(),r=Ye();function t(s){return s&&s.length?e(s,r,n):void 0}return Mo=t,Mo}var Wo,vp;function yp(){if(vp)return Wo;vp=1;var e=Lr(),n=Qe();function r(t,s,a){(a!==void 0&&!n(t[s],a)||a===void 0&&!(s in t))&&e(t,s,a)}return Wo=r,Wo}var Bo,xp;function $v(){if(xp)return Bo;xp=1;var e=Je(),n=Br(),r=Me(),t="[object Object]",s=Function.prototype,a=Object.prototype,o=s.toString,i=a.hasOwnProperty,u=o.call(Object);function c(d){if(!r(d)||e(d)!=t)return!1;var f=n(d);if(f===null)return!0;var p=i.call(f,"constructor")&&f.constructor;return typeof p=="function"&&p instanceof p&&o.call(p)==u}return Bo=c,Bo}var Fo,bp;function kp(){if(bp)return Fo;bp=1;function e(n,r){if(!(r==="constructor"&&typeof n[r]=="function")&&r!="__proto__")return n[r]}return Fo=e,Fo}var $o,_p;function zv(){if(_p)return $o;_p=1;var e=hr(),n=Ve();function r(t){return e(t,n(t))}return $o=r,$o}var zo,Sp;function Hv(){if(Sp)return zo;Sp=1;var e=yp(),n=Ic(),r=cd(),t=Oc(),s=hd(),a=gr(),o=ke(),i=bf(),u=rr(),c=pr(),d=Ie(),f=$v(),p=yr(),h=kp(),g=zv();function m(v,y,x,b,k,w,j){var N=h(v,x),L=h(y,x),T=j.get(L);if(T){e(v,x,T);return}var C=w?w(N,L,x+"",v,y,j):void 0,S=C===void 0;if(S){var D=o(L),I=!D&&u(L),P=!D&&!I&&p(L);C=L,D||I||P?o(N)?C=N:i(N)?C=t(N):I?(S=!1,C=n(L,!0)):P?(S=!1,C=r(L,!0)):C=[]:f(L)||a(L)?(C=N,a(N)?C=g(N):(!d(N)||c(N))&&(C=s(L))):S=!1}S&&(j.set(L,C),k(C,L,b,w,j),j.delete(L)),e(v,x,C)}return zo=m,zo}var Ho,wp;function Kv(){if(wp)return Ho;wp=1;var e=Ar(),n=yp(),r=va(),t=Hv(),s=Ie(),a=Ve(),o=kp();function i(u,c,d,f,p){u!==c&&r(c,function(h,g){if(p||(p=new e),s(h))t(u,c,g,d,i,f,p);else{var m=f?f(o(u,g),h,g+"",u,c,p):void 0;m===void 0&&(m=h),n(u,g,m)}},a)}return Ho=i,Ho}var Ko,Tp;function Uv(){if(Tp)return Ko;Tp=1;var e=Kr(),n=Ur();function r(t){return e(function(s,a){var o=-1,i=a.length,u=i>1?a[i-1]:void 0,c=i>2?a[2]:void 0;for(u=t.length>3&&typeof u=="function"?(i--,u):void 0,c&&n(a[0],a[1],c)&&(u=i<3?void 0:u,i=1),s=Object(s);++o<i;){var d=a[o];d&&t(s,d,o,u)}return s})}return Ko=r,Ko}var Uo,Ep;function Jv(){if(Ep)return Uo;Ep=1;var e=Kv(),n=Uv(),r=n(function(t,s,a){e(t,s,a)});return Uo=r,Uo}var Jo,Np;function Cp(){if(Np)return Jo;Np=1;function e(n,r){return n<r}return Jo=e,Jo}var Go,jp;function Gv(){if(jp)return Go;jp=1;var e=qo(),n=Cp(),r=Ye();function t(s){return s&&s.length?e(s,r,n):void 0}return Go=t,Go}var Vo,Ip;function Vv(){if(Ip)return Vo;Ip=1;var e=qo(),n=Fe(),r=Cp();function t(s,a){return s&&s.length?e(s,n(a,2),r):void 0}return Vo=t,Vo}var Yo,Rp;function Yv(){if(Rp)return Yo;Rp=1;var e=Pe(),n=function(){return e.Date.now()};return Yo=n,Yo}var Xo,Op;function Xv(){if(Op)return Xo;Op=1;var e=qr(),n=zr(),r=Dr(),t=Ie(),s=br();function a(o,i,u,c){if(!t(o))return o;i=n(i,o);for(var d=-1,f=i.length,p=f-1,h=o;h!=null&&++d<f;){var g=s(i[d]),m=u;if(g==="__proto__"||g==="constructor"||g==="prototype")return o;if(d!=p){var v=h[g];m=c?c(v,g,h):void 0,m===void 0&&(m=t(v)?v:r(i[d+1])?[]:{})}e(h,g,m),h=h[g]}return o}return Xo=a,Xo}var Zo,Pp;function Zv(){if(Pp)return Zo;Pp=1;var e=Hr(),n=Xv(),r=zr();function t(s,a,o){for(var i=-1,u=a.length,c={};++i<u;){var d=a[i],f=e(s,d);o(f,d)&&n(c,r(d,s),f)}return c}return Zo=t,Zo}var Qo,Ap;function Qv(){if(Ap)return Qo;Ap=1;var e=Zv(),n=_u();function r(t,s){return e(t,s,function(a,o){return n(t,o)})}return Qo=r,Qo}var ei,Lp;function ey(){if(Lp)return ei;Lp=1;var e=dp(),n=tf(),r=of();function t(s){return r(n(s,void 0,e),s+"")}return ei=t,ei}var ri,qp;function ry(){if(qp)return ri;qp=1;var e=Qv(),n=ey(),r=n(function(t,s){return t==null?{}:e(t,s)});return ri=r,ri}var ti,Dp;function ty(){if(Dp)return ti;Dp=1;var e=Math.ceil,n=Math.max;function r(t,s,a,o){for(var i=-1,u=n(e((s-t)/(a||1)),0),c=Array(u);u--;)c[o?u:++i]=t,t+=a;return c}return ti=r,ti}var ni,Mp;function ny(){if(Mp)return ni;Mp=1;var e=ty(),n=Ur(),r=sp();function t(s){return function(a,o,i){return i&&typeof i!="number"&&n(a,o,i)&&(o=i=void 0),a=r(a),o===void 0?(o=a,a=0):o=r(o),i=i===void 0?a<o?1:-1:r(i),e(a,o,i,s)}}return ni=t,ni}var ai,Wp;function ay(){if(Wp)return ai;Wp=1;var e=ny(),n=e();return ai=n,ai}var si,Bp;function sy(){if(Bp)return si;Bp=1;function e(n,r){var t=n.length;for(n.sort(r);t--;)n[t]=n[t].value;return n}return si=e,si}var oi,Fp;function oy(){if(Fp)return oi;Fp=1;var e=nr();function n(r,t){if(r!==t){var s=r!==void 0,a=r===null,o=r===r,i=e(r),u=t!==void 0,c=t===null,d=t===t,f=e(t);if(!c&&!f&&!i&&r>t||i&&u&&d&&!c&&!f||a&&u&&d||!s&&d||!o)return 1;if(!a&&!i&&!f&&r<t||f&&s&&o&&!a&&!i||c&&s&&o||!u&&o||!d)return-1}return 0}return oi=n,oi}var ii,$p;function iy(){if($p)return ii;$p=1;var e=oy();function n(r,t,s){for(var a=-1,o=r.criteria,i=t.criteria,u=o.length,c=s.length;++a<u;){var d=e(o[a],i[a]);if(d){if(a>=c)return d;var f=s[a];return d*(f=="desc"?-1:1)}}return r.index-t.index}return ii=n,ii}var li,zp;function ly(){if(zp)return li;zp=1;var e=$r(),n=Hr(),r=Fe(),t=Mu(),s=sy(),a=Mr(),o=iy(),i=Ye(),u=ke();function c(d,f,p){f.length?f=e(f,function(m){return u(m)?function(v){return n(v,m.length===1?m[0]:m)}:m}):f=[i];var h=-1;f=e(f,a(r));var g=t(d,function(m,v,y){var x=e(f,function(b){return b(m)});return{criteria:x,index:++h,value:m}});return s(g,function(m,v){return o(m,v,p)})}return li=c,li}var ci,Hp;function cy(){if(Hp)return ci;Hp=1;var e=Rs(),n=ly(),r=Kr(),t=Ur(),s=r(function(a,o){if(a==null)return[];var i=o.length;return i>1&&t(a,o[0],o[1])?o=[]:i>2&&t(o[0],o[1],o[2])&&(o=[o[0]]),n(a,e(o,1),[])});return ci=s,ci}var di,Kp;function dy(){if(Kp)return di;Kp=1;var e=pu(),n=0;function r(t){var s=++n;return e(t)+s}return di=r,di}var ui,Up;function uy(){if(Up)return ui;Up=1;function e(n,r,t){for(var s=-1,a=n.length,o=r.length,i={};++s<a;){var u=s<o?r[s]:void 0;t(i,n[s],u)}return i}return ui=e,ui}var fi,Jp;function fy(){if(Jp)return fi;Jp=1;var e=qr(),n=uy();function r(t,s){return n(t||[],s||[],e)}return fi=r,fi}var pi,Gp;function be(){if(Gp)return pi;Gp=1;var e;if(typeof st=="function")try{e={cloneDeep:Cv(),constant:ha(),defaults:jv(),each:Ad(),filter:Iu(),find:qv(),flatten:dp(),forEach:Od(),forIn:Dv(),has:Pu(),isUndefined:qu(),last:Mv(),map:Bu(),mapValues:Wv(),max:Fv(),merge:Jv(),min:Gv(),minBy:Vv(),now:Yv(),pick:ry(),range:ay(),reduce:Hu(),sortBy:cy(),uniqueId:dy(),values:wf(),zipObject:fy()}}catch{}return e||(e=window._),pi=e,pi}var hi,Vp;function py(){if(Vp)return hi;Vp=1,hi=e;function e(){var t={};t._next=t._prev=t,this._sentinel=t}e.prototype.dequeue=function(){var t=this._sentinel,s=t._prev;if(s!==t)return n(s),s},e.prototype.enqueue=function(t){var s=this._sentinel;t._prev&&t._next&&n(t),t._next=s._next,s._next._prev=t,s._next=t,t._prev=s},e.prototype.toString=function(){for(var t=[],s=this._sentinel,a=s._prev;a!==s;)t.push(JSON.stringify(a,r)),a=a._prev;return"["+t.join(", ")+"]"};function n(t){t._prev._next=t._next,t._next._prev=t._prev,delete t._next,delete t._prev}function r(t,s){if(t!=="_next"&&t!=="_prev")return s}return hi}var gi,Yp;function hy(){if(Yp)return gi;Yp=1;var e=be(),n=Ae().Graph,r=py();gi=s;var t=e.constant(1);function s(c,d){if(c.nodeCount()<=1)return[];var f=i(c,d||t),p=a(f.graph,f.buckets,f.zeroIdx);return e.flatten(e.map(p,function(h){return c.outEdges(h.v,h.w)}),!0)}function a(c,d,f){for(var p=[],h=d[d.length-1],g=d[0],m;c.nodeCount();){for(;m=g.dequeue();)o(c,d,f,m);for(;m=h.dequeue();)o(c,d,f,m);if(c.nodeCount()){for(var v=d.length-2;v>0;--v)if(m=d[v].dequeue(),m){p=p.concat(o(c,d,f,m,!0));break}}}return p}function o(c,d,f,p,h){var g=h?[]:void 0;return e.forEach(c.inEdges(p.v),function(m){var v=c.edge(m),y=c.node(m.v);h&&g.push({v:m.v,w:m.w}),y.out-=v,u(d,f,y)}),e.forEach(c.outEdges(p.v),function(m){var v=c.edge(m),y=m.w,x=c.node(y);x.in-=v,u(d,f,x)}),c.removeNode(p.v),g}function i(c,d){var f=new n,p=0,h=0;e.forEach(c.nodes(),function(v){f.setNode(v,{v,in:0,out:0})}),e.forEach(c.edges(),function(v){var y=f.edge(v.v,v.w)||0,x=d(v),b=y+x;f.setEdge(v.v,v.w,b),h=Math.max(h,f.node(v.v).out+=x),p=Math.max(p,f.node(v.w).in+=x)});var g=e.range(h+p+3).map(function(){return new r}),m=p+1;return e.forEach(f.nodes(),function(v){u(g,m,f.node(v))}),{graph:f,buckets:g,zeroIdx:m}}function u(c,d,f){f.out?f.in?c[f.out-f.in+d].enqueue(f):c[c.length-1].enqueue(f):c[0].enqueue(f)}return gi}var mi,Xp;function gy(){if(Xp)return mi;Xp=1;var e=be(),n=hy();mi={run:r,undo:s};function r(a){var o=a.graph().acyclicer==="greedy"?n(a,i(a)):t(a);e.forEach(o,function(u){var c=a.edge(u);a.removeEdge(u),c.forwardName=u.name,c.reversed=!0,a.setEdge(u.w,u.v,c,e.uniqueId("rev"))});function i(u){return function(c){return u.edge(c).weight}}}function t(a){var o=[],i={},u={};function c(d){e.has(u,d)||(u[d]=!0,i[d]=!0,e.forEach(a.outEdges(d),function(f){e.has(i,f.w)?o.push(f):c(f.w)}),delete i[d])}return e.forEach(a.nodes(),c),o}function s(a){e.forEach(a.edges(),function(o){var i=a.edge(o);if(i.reversed){a.removeEdge(o);var u=i.forwardName;delete i.reversed,delete i.forwardName,a.setEdge(o.w,o.v,i,u)}})}return mi}var vi,Zp;function Ce(){if(Zp)return vi;Zp=1;var e=be(),n=Ae().Graph;vi={addDummyNode:r,simplify:t,asNonCompoundGraph:s,successorWeights:a,predecessorWeights:o,intersectRect:i,buildLayerMatrix:u,normalizeRanks:c,removeEmptyRanks:d,addBorderNode:f,maxRank:p,partition:h,time:g,notime:m};function r(v,y,x,b){var k;do k=e.uniqueId(b);while(v.hasNode(k));return x.dummy=y,v.setNode(k,x),k}function t(v){var y=new n().setGraph(v.graph());return e.forEach(v.nodes(),function(x){y.setNode(x,v.node(x))}),e.forEach(v.edges(),function(x){var b=y.edge(x.v,x.w)||{weight:0,minlen:1},k=v.edge(x);y.setEdge(x.v,x.w,{weight:b.weight+k.weight,minlen:Math.max(b.minlen,k.minlen)})}),y}function s(v){var y=new n({multigraph:v.isMultigraph()}).setGraph(v.graph());return e.forEach(v.nodes(),function(x){v.children(x).length||y.setNode(x,v.node(x))}),e.forEach(v.edges(),function(x){y.setEdge(x,v.edge(x))}),y}function a(v){var y=e.map(v.nodes(),function(x){var b={};return e.forEach(v.outEdges(x),function(k){b[k.w]=(b[k.w]||0)+v.edge(k).weight}),b});return e.zipObject(v.nodes(),y)}function o(v){var y=e.map(v.nodes(),function(x){var b={};return e.forEach(v.inEdges(x),function(k){b[k.v]=(b[k.v]||0)+v.edge(k).weight}),b});return e.zipObject(v.nodes(),y)}function i(v,y){var x=v.x,b=v.y,k=y.x-x,w=y.y-b,j=v.width/2,N=v.height/2;if(!k&&!w)throw new Error("Not possible to find intersection inside of the rectangle");var L,T;return Math.abs(w)*j>Math.abs(k)*N?(w<0&&(N=-N),L=N*k/w,T=N):(k<0&&(j=-j),L=j,T=j*w/k),{x:x+L,y:b+T}}function u(v){var y=e.map(e.range(p(v)+1),function(){return[]});return e.forEach(v.nodes(),function(x){var b=v.node(x),k=b.rank;e.isUndefined(k)||(y[k][b.order]=x)}),y}function c(v){var y=e.min(e.map(v.nodes(),function(x){return v.node(x).rank}));e.forEach(v.nodes(),function(x){var b=v.node(x);e.has(b,"rank")&&(b.rank-=y)})}function d(v){var y=e.min(e.map(v.nodes(),function(w){return v.node(w).rank})),x=[];e.forEach(v.nodes(),function(w){var j=v.node(w).rank-y;x[j]||(x[j]=[]),x[j].push(w)});var b=0,k=v.graph().nodeRankFactor;e.forEach(x,function(w,j){e.isUndefined(w)&&j%k!==0?--b:b&&e.forEach(w,function(N){v.node(N).rank+=b})})}function f(v,y,x,b){var k={width:0,height:0};return arguments.length>=4&&(k.rank=x,k.order=b),r(v,"border",k,y)}function p(v){return e.max(e.map(v.nodes(),function(y){var x=v.node(y).rank;if(!e.isUndefined(x))return x}))}function h(v,y){var x={lhs:[],rhs:[]};return e.forEach(v,function(b){y(b)?x.lhs.push(b):x.rhs.push(b)}),x}function g(v,y){var x=e.now();try{return y()}finally{console.log(v+" time: "+(e.now()-x)+"ms")}}function m(v,y){return y()}return vi}var yi,Qp;function my(){if(Qp)return yi;Qp=1;var e=be(),n=Ce();yi={run:r,undo:s};function r(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(o){t(a,o)})}function t(a,o){var i=o.v,u=a.node(i).rank,c=o.w,d=a.node(c).rank,f=o.name,p=a.edge(o),h=p.labelRank;if(d!==u+1){a.removeEdge(o);var g,m,v;for(v=0,++u;u<d;++v,++u)p.points=[],m={width:0,height:0,edgeLabel:p,edgeObj:o,rank:u},g=n.addDummyNode(a,"edge",m,"_d"),u===h&&(m.width=p.width,m.height=p.height,m.dummy="edge-label",m.labelpos=p.labelpos),a.setEdge(i,g,{weight:p.weight},f),v===0&&a.graph().dummyChains.push(g),i=g;a.setEdge(i,c,{weight:p.weight},f)}}function s(a){e.forEach(a.graph().dummyChains,function(o){var i=a.node(o),u=i.edgeLabel,c;for(a.setEdge(i.edgeObj,u);i.dummy;)c=a.successors(o)[0],a.removeNode(o),u.points.push({x:i.x,y:i.y}),i.dummy==="edge-label"&&(u.x=i.x,u.y=i.y,u.width=i.width,u.height=i.height),o=c,i=a.node(o)})}return yi}var xi,eh;function Jr(){if(eh)return xi;eh=1;var e=be();xi={longestPath:n,slack:r};function n(t){var s={};function a(o){var i=t.node(o);if(e.has(s,o))return i.rank;s[o]=!0;var u=e.min(e.map(t.outEdges(o),function(c){return a(c.w)-t.edge(c).minlen}));return(u===Number.POSITIVE_INFINITY||u===void 0||u===null)&&(u=0),i.rank=u}e.forEach(t.sources(),a)}function r(t,s){return t.node(s.w).rank-t.node(s.v).rank-t.edge(s).minlen}return xi}var bi,rh;function th(){if(rh)return bi;rh=1;var e=be(),n=Ae().Graph,r=Jr().slack;bi=t;function t(i){var u=new n({directed:!1}),c=i.nodes()[0],d=i.nodeCount();u.setNode(c,{});for(var f,p;s(u,i)<d;)f=a(u,i),p=u.hasNode(f.v)?r(i,f):-r(i,f),o(u,i,p);return u}function s(i,u){function c(d){e.forEach(u.nodeEdges(d),function(f){var p=f.v,h=d===p?f.w:p;!i.hasNode(h)&&!r(u,f)&&(i.setNode(h,{}),i.setEdge(d,h,{}),c(h))})}return e.forEach(i.nodes(),c),i.nodeCount()}function a(i,u){return e.minBy(u.edges(),function(c){if(i.hasNode(c.v)!==i.hasNode(c.w))return r(u,c)})}function o(i,u,c){e.forEach(i.nodes(),function(d){u.node(d).rank+=c})}return bi}var ki,nh;function vy(){if(nh)return ki;nh=1;var e=be(),n=th(),r=Jr().slack,t=Jr().longestPath,s=Ae().alg.preorder,a=Ae().alg.postorder,o=Ce().simplify;ki=i,i.initLowLimValues=f,i.initCutValues=u,i.calcCutValue=d,i.leaveEdge=h,i.enterEdge=g,i.exchangeEdges=m;function i(b){b=o(b),t(b);var k=n(b);f(k),u(k,b);for(var w,j;w=h(k);)j=g(k,b,w),m(k,b,w,j)}function u(b,k){var w=a(b,b.nodes());w=w.slice(0,w.length-1),e.forEach(w,function(j){c(b,k,j)})}function c(b,k,w){var j=b.node(w),N=j.parent;b.edge(w,N).cutvalue=d(b,k,w)}function d(b,k,w){var j=b.node(w),N=j.parent,L=!0,T=k.edge(w,N),C=0;return T||(L=!1,T=k.edge(N,w)),C=T.weight,e.forEach(k.nodeEdges(w),function(S){var D=S.v===w,I=D?S.w:S.v;if(I!==N){var P=D===L,F=k.edge(S).weight;if(C+=P?F:-F,y(b,w,I)){var W=b.edge(w,I).cutvalue;C+=P?-W:W}}}),C}function f(b,k){arguments.length<2&&(k=b.nodes()[0]),p(b,{},1,k)}function p(b,k,w,j,N){var L=w,T=b.node(j);return k[j]=!0,e.forEach(b.neighbors(j),function(C){e.has(k,C)||(w=p(b,k,w,C,j))}),T.low=L,T.lim=w++,N?T.parent=N:delete T.parent,w}function h(b){return e.find(b.edges(),function(k){return b.edge(k).cutvalue<0})}function g(b,k,w){var j=w.v,N=w.w;k.hasEdge(j,N)||(j=w.w,N=w.v);var L=b.node(j),T=b.node(N),C=L,S=!1;L.lim>T.lim&&(C=T,S=!0);var D=e.filter(k.edges(),function(I){return S===x(b,b.node(I.v),C)&&S!==x(b,b.node(I.w),C)});return e.minBy(D,function(I){return r(k,I)})}function m(b,k,w,j){var N=w.v,L=w.w;b.removeEdge(N,L),b.setEdge(j.v,j.w,{}),f(b),u(b,k),v(b,k)}function v(b,k){var w=e.find(b.nodes(),function(N){return!k.node(N).parent}),j=s(b,w);j=j.slice(1),e.forEach(j,function(N){var L=b.node(N).parent,T=k.edge(N,L),C=!1;T||(T=k.edge(L,N),C=!0),k.node(N).rank=k.node(L).rank+(C?T.minlen:-T.minlen)})}function y(b,k,w){return b.hasEdge(k,w)}function x(b,k,w){return w.low<=k.lim&&k.lim<=w.lim}return ki}var _i,ah;function yy(){if(ah)return _i;ah=1;var e=Jr(),n=e.longestPath,r=th(),t=vy();_i=s;function s(u){switch(u.graph().ranker){case"network-simplex":i(u);break;case"tight-tree":o(u);break;case"longest-path":a(u);break;default:i(u)}}var a=n;function o(u){n(u),r(u)}function i(u){t(u)}return _i}var Si,sh;function xy(){if(sh)return Si;sh=1;var e=be();Si=n;function n(s){var a=t(s);e.forEach(s.graph().dummyChains,function(o){for(var i=s.node(o),u=i.edgeObj,c=r(s,a,u.v,u.w),d=c.path,f=c.lca,p=0,h=d[p],g=!0;o!==u.w;){if(i=s.node(o),g){for(;(h=d[p])!==f&&s.node(h).maxRank<i.rank;)p++;h===f&&(g=!1)}if(!g){for(;p<d.length-1&&s.node(h=d[p+1]).minRank<=i.rank;)p++;h=d[p]}s.setParent(o,h),o=s.successors(o)[0]}})}function r(s,a,o,i){var u=[],c=[],d=Math.min(a[o].low,a[i].low),f=Math.max(a[o].lim,a[i].lim),p,h;p=o;do p=s.parent(p),u.push(p);while(p&&(a[p].low>d||f>a[p].lim));for(h=p,p=i;(p=s.parent(p))!==h;)c.push(p);return{path:u.concat(c.reverse()),lca:h}}function t(s){var a={},o=0;function i(u){var c=o;e.forEach(s.children(u),i),a[u]={low:c,lim:o++}}return e.forEach(s.children(),i),a}return Si}var wi,oh;function by(){if(oh)return wi;oh=1;var e=be(),n=Ce();wi={run:r,cleanup:o};function r(i){var u=n.addDummyNode(i,"root",{},"_root"),c=s(i),d=e.max(e.values(c))-1,f=2*d+1;i.graph().nestingRoot=u,e.forEach(i.edges(),function(h){i.edge(h).minlen*=f});var p=a(i)+1;e.forEach(i.children(),function(h){t(i,u,f,p,d,c,h)}),i.graph().nodeRankFactor=f}function t(i,u,c,d,f,p,h){var g=i.children(h);if(!g.length){h!==u&&i.setEdge(u,h,{weight:0,minlen:c});return}var m=n.addBorderNode(i,"_bt"),v=n.addBorderNode(i,"_bb"),y=i.node(h);i.setParent(m,h),y.borderTop=m,i.setParent(v,h),y.borderBottom=v,e.forEach(g,function(x){t(i,u,c,d,f,p,x);var b=i.node(x),k=b.borderTop?b.borderTop:x,w=b.borderBottom?b.borderBottom:x,j=b.borderTop?d:2*d,N=k!==w?1:f-p[h]+1;i.setEdge(m,k,{weight:j,minlen:N,nestingEdge:!0}),i.setEdge(w,v,{weight:j,minlen:N,nestingEdge:!0})}),i.parent(h)||i.setEdge(u,m,{weight:0,minlen:f+p[h]})}function s(i){var u={};function c(d,f){var p=i.children(d);p&&p.length&&e.forEach(p,function(h){c(h,f+1)}),u[d]=f}return e.forEach(i.children(),function(d){c(d,1)}),u}function a(i){return e.reduce(i.edges(),function(u,c){return u+i.edge(c).weight},0)}function o(i){var u=i.graph();i.removeNode(u.nestingRoot),delete u.nestingRoot,e.forEach(i.edges(),function(c){var d=i.edge(c);d.nestingEdge&&i.removeEdge(c)})}return wi}var Ti,ih;function ky(){if(ih)return Ti;ih=1;var e=be(),n=Ce();Ti=r;function r(s){function a(o){var i=s.children(o),u=s.node(o);if(i.length&&e.forEach(i,a),e.has(u,"minRank")){u.borderLeft=[],u.borderRight=[];for(var c=u.minRank,d=u.maxRank+1;c<d;++c)t(s,"borderLeft","_bl",o,u,c),t(s,"borderRight","_br",o,u,c)}}e.forEach(s.children(),a)}function t(s,a,o,i,u,c){var d={width:0,height:0,rank:c,borderType:a},f=u[a][c-1],p=n.addDummyNode(s,"border",d,o);u[a][c]=p,s.setParent(p,i),f&&s.setEdge(f,p,{weight:1})}return Ti}var Ei,lh;function _y(){if(lh)return Ei;lh=1;var e=be();Ei={adjust:n,undo:r};function n(c){var d=c.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&t(c)}function r(c){var d=c.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&a(c),(d==="lr"||d==="rl")&&(i(c),t(c))}function t(c){e.forEach(c.nodes(),function(d){s(c.node(d))}),e.forEach(c.edges(),function(d){s(c.edge(d))})}function s(c){var d=c.width;c.width=c.height,c.height=d}function a(c){e.forEach(c.nodes(),function(d){o(c.node(d))}),e.forEach(c.edges(),function(d){var f=c.edge(d);e.forEach(f.points,o),e.has(f,"y")&&o(f)})}function o(c){c.y=-c.y}function i(c){e.forEach(c.nodes(),function(d){u(c.node(d))}),e.forEach(c.edges(),function(d){var f=c.edge(d);e.forEach(f.points,u),e.has(f,"x")&&u(f)})}function u(c){var d=c.x;c.x=c.y,c.y=d}return Ei}var Ni,ch;function Sy(){if(ch)return Ni;ch=1;var e=be();Ni=n;function n(r){var t={},s=e.filter(r.nodes(),function(c){return!r.children(c).length}),a=e.max(e.map(s,function(c){return r.node(c).rank})),o=e.map(e.range(a+1),function(){return[]});function i(c){if(!e.has(t,c)){t[c]=!0;var d=r.node(c);o[d.rank].push(c),e.forEach(r.successors(c),i)}}var u=e.sortBy(s,function(c){return r.node(c).rank});return e.forEach(u,i),o}return Ni}var Ci,dh;function wy(){if(dh)return Ci;dh=1;var e=be();Ci=n;function n(t,s){for(var a=0,o=1;o<s.length;++o)a+=r(t,s[o-1],s[o]);return a}function r(t,s,a){for(var o=e.zipObject(a,e.map(a,function(p,h){return h})),i=e.flatten(e.map(s,function(p){return e.sortBy(e.map(t.outEdges(p),function(h){return{pos:o[h.w],weight:t.edge(h).weight}}),"pos")}),!0),u=1;u<a.length;)u<<=1;var c=2*u-1;u-=1;var d=e.map(new Array(c),function(){return 0}),f=0;return e.forEach(i.forEach(function(p){var h=p.pos+u;d[h]+=p.weight;for(var g=0;h>0;)h%2&&(g+=d[h+1]),h=h-1>>1,d[h]+=p.weight;f+=p.weight*g})),f}return Ci}var ji,uh;function Ty(){if(uh)return ji;uh=1;var e=be();ji=n;function n(r,t){return e.map(t,function(s){var a=r.inEdges(s);if(a.length){var o=e.reduce(a,function(i,u){var c=r.edge(u),d=r.node(u.v);return{sum:i.sum+c.weight*d.order,weight:i.weight+c.weight}},{sum:0,weight:0});return{v:s,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:s}})}return ji}var Ii,fh;function Ey(){if(fh)return Ii;fh=1;var e=be();Ii=n;function n(s,a){var o={};e.forEach(s,function(u,c){var d=o[u.v]={indegree:0,in:[],out:[],vs:[u.v],i:c};e.isUndefined(u.barycenter)||(d.barycenter=u.barycenter,d.weight=u.weight)}),e.forEach(a.edges(),function(u){var c=o[u.v],d=o[u.w];!e.isUndefined(c)&&!e.isUndefined(d)&&(d.indegree++,c.out.push(o[u.w]))});var i=e.filter(o,function(u){return!u.indegree});return r(i)}function r(s){var a=[];function o(c){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(c.barycenter)||d.barycenter>=c.barycenter)&&t(c,d)}}function i(c){return function(d){d.in.push(c),--d.indegree===0&&s.push(d)}}for(;s.length;){var u=s.pop();a.push(u),e.forEach(u.in.reverse(),o(u)),e.forEach(u.out,i(u))}return e.map(e.filter(a,function(c){return!c.merged}),function(c){return e.pick(c,["vs","i","barycenter","weight"])})}function t(s,a){var o=0,i=0;s.weight&&(o+=s.barycenter*s.weight,i+=s.weight),a.weight&&(o+=a.barycenter*a.weight,i+=a.weight),s.vs=a.vs.concat(s.vs),s.barycenter=o/i,s.weight=i,s.i=Math.min(a.i,s.i),a.merged=!0}return Ii}var Ri,ph;function Ny(){if(ph)return Ri;ph=1;var e=be(),n=Ce();Ri=r;function r(a,o){var i=n.partition(a,function(m){return e.has(m,"barycenter")}),u=i.lhs,c=e.sortBy(i.rhs,function(m){return-m.i}),d=[],f=0,p=0,h=0;u.sort(s(!!o)),h=t(d,c,h),e.forEach(u,function(m){h+=m.vs.length,d.push(m.vs),f+=m.barycenter*m.weight,p+=m.weight,h=t(d,c,h)});var g={vs:e.flatten(d,!0)};return p&&(g.barycenter=f/p,g.weight=p),g}function t(a,o,i){for(var u;o.length&&(u=e.last(o)).i<=i;)o.pop(),a.push(u.vs),i++;return i}function s(a){return function(o,i){return o.barycenter<i.barycenter?-1:o.barycenter>i.barycenter?1:a?i.i-o.i:o.i-i.i}}return Ri}var Oi,hh;function Cy(){if(hh)return Oi;hh=1;var e=be(),n=Ty(),r=Ey(),t=Ny();Oi=s;function s(i,u,c,d){var f=i.children(u),p=i.node(u),h=p?p.borderLeft:void 0,g=p?p.borderRight:void 0,m={};h&&(f=e.filter(f,function(w){return w!==h&&w!==g}));var v=n(i,f);e.forEach(v,function(w){if(i.children(w.v).length){var j=s(i,w.v,c,d);m[w.v]=j,e.has(j,"barycenter")&&o(w,j)}});var y=r(v,c);a(y,m);var x=t(y,d);if(h&&(x.vs=e.flatten([h,x.vs,g],!0),i.predecessors(h).length)){var b=i.node(i.predecessors(h)[0]),k=i.node(i.predecessors(g)[0]);e.has(x,"barycenter")||(x.barycenter=0,x.weight=0),x.barycenter=(x.barycenter*x.weight+b.order+k.order)/(x.weight+2),x.weight+=2}return x}function a(i,u){e.forEach(i,function(c){c.vs=e.flatten(c.vs.map(function(d){return u[d]?u[d].vs:d}),!0)})}function o(i,u){e.isUndefined(i.barycenter)?(i.barycenter=u.barycenter,i.weight=u.weight):(i.barycenter=(i.barycenter*i.weight+u.barycenter*u.weight)/(i.weight+u.weight),i.weight+=u.weight)}return Oi}var Pi,gh;function jy(){if(gh)return Pi;gh=1;var e=be(),n=Ae().Graph;Pi=r;function r(s,a,o){var i=t(s),u=new n({compound:!0}).setGraph({root:i}).setDefaultNodeLabel(function(c){return s.node(c)});return e.forEach(s.nodes(),function(c){var d=s.node(c),f=s.parent(c);(d.rank===a||d.minRank<=a&&a<=d.maxRank)&&(u.setNode(c),u.setParent(c,f||i),e.forEach(s[o](c),function(p){var h=p.v===c?p.w:p.v,g=u.edge(h,c),m=e.isUndefined(g)?0:g.weight;u.setEdge(h,c,{weight:s.edge(p).weight+m})}),e.has(d,"minRank")&&u.setNode(c,{borderLeft:d.borderLeft[a],borderRight:d.borderRight[a]}))}),u}function t(s){for(var a;s.hasNode(a=e.uniqueId("_root")););return a}return Pi}var Ai,mh;function Iy(){if(mh)return Ai;mh=1;var e=be();Ai=n;function n(r,t,s){var a={},o;e.forEach(s,function(i){for(var u=r.parent(i),c,d;u;){if(c=r.parent(u),c?(d=a[c],a[c]=u):(d=o,o=u),d&&d!==u){t.setEdge(d,u);return}u=c}})}return Ai}var Li,vh;function Ry(){if(vh)return Li;vh=1;var e=be(),n=Sy(),r=wy(),t=Cy(),s=jy(),a=Iy(),o=Ae().Graph,i=Ce();Li=u;function u(p){var h=i.maxRank(p),g=c(p,e.range(1,h+1),"inEdges"),m=c(p,e.range(h-1,-1,-1),"outEdges"),v=n(p);f(p,v);for(var y=Number.POSITIVE_INFINITY,x,b=0,k=0;k<4;++b,++k){d(b%2?g:m,b%4>=2),v=i.buildLayerMatrix(p);var w=r(p,v);w<y&&(k=0,x=e.cloneDeep(v),y=w)}f(p,x)}function c(p,h,g){return e.map(h,function(m){return s(p,m,g)})}function d(p,h){var g=new o;e.forEach(p,function(m){var v=m.graph().root,y=t(m,v,g,h);e.forEach(y.vs,function(x,b){m.node(x).order=b}),a(m,g,y.vs)})}function f(p,h){e.forEach(h,function(g){e.forEach(g,function(m,v){p.node(m).order=v})})}return Li}var qi,yh;function Oy(){if(yh)return qi;yh=1;var e=be(),n=Ae().Graph,r=Ce();qi={positionX:g,findType1Conflicts:t,findType2Conflicts:s,addConflict:o,hasConflict:i,verticalAlignment:u,horizontalCompaction:c,alignCoordinates:p,findSmallestWidthAlignment:f,balance:h};function t(y,x){var b={};function k(w,j){var N=0,L=0,T=w.length,C=e.last(j);return e.forEach(j,function(S,D){var I=a(y,S),P=I?y.node(I).order:T;(I||S===C)&&(e.forEach(j.slice(L,D+1),function(F){e.forEach(y.predecessors(F),function(W){var K=y.node(W),V=K.order;(V<N||P<V)&&!(K.dummy&&y.node(F).dummy)&&o(b,W,F)})}),L=D+1,N=P)}),j}return e.reduce(x,k),b}function s(y,x){var b={};function k(j,N,L,T,C){var S;e.forEach(e.range(N,L),function(D){S=j[D],y.node(S).dummy&&e.forEach(y.predecessors(S),function(I){var P=y.node(I);P.dummy&&(P.order<T||P.order>C)&&o(b,I,S)})})}function w(j,N){var L=-1,T,C=0;return e.forEach(N,function(S,D){if(y.node(S).dummy==="border"){var I=y.predecessors(S);I.length&&(T=y.node(I[0]).order,k(N,C,D,L,T),C=D,L=T)}k(N,C,N.length,T,j.length)}),N}return e.reduce(x,w),b}function a(y,x){if(y.node(x).dummy)return e.find(y.predecessors(x),function(b){return y.node(b).dummy})}function o(y,x,b){if(x>b){var k=x;x=b,b=k}var w=y[x];w||(y[x]=w={}),w[b]=!0}function i(y,x,b){if(x>b){var k=x;x=b,b=k}return e.has(y[x],b)}function u(y,x,b,k){var w={},j={},N={};return e.forEach(x,function(L){e.forEach(L,function(T,C){w[T]=T,j[T]=T,N[T]=C})}),e.forEach(x,function(L){var T=-1;e.forEach(L,function(C){var S=k(C);if(S.length){S=e.sortBy(S,function(W){return N[W]});for(var D=(S.length-1)/2,I=Math.floor(D),P=Math.ceil(D);I<=P;++I){var F=S[I];j[C]===C&&T<N[F]&&!i(b,C,F)&&(j[F]=C,j[C]=w[C]=w[F],T=N[F])}}})}),{root:w,align:j}}function c(y,x,b,k,w){var j={},N=d(y,x,b,w),L=w?"borderLeft":"borderRight";function T(D,I){for(var P=N.nodes(),F=P.pop(),W={};F;)W[F]?D(F):(W[F]=!0,P.push(F),P=P.concat(I(F))),F=P.pop()}function C(D){j[D]=N.inEdges(D).reduce(function(I,P){return Math.max(I,j[P.v]+N.edge(P))},0)}function S(D){var I=N.outEdges(D).reduce(function(F,W){return Math.min(F,j[W.w]-N.edge(W))},Number.POSITIVE_INFINITY),P=y.node(D);I!==Number.POSITIVE_INFINITY&&P.borderType!==L&&(j[D]=Math.max(j[D],I))}return T(C,N.predecessors.bind(N)),T(S,N.successors.bind(N)),e.forEach(k,function(D){j[D]=j[b[D]]}),j}function d(y,x,b,k){var w=new n,j=y.graph(),N=m(j.nodesep,j.edgesep,k);return e.forEach(x,function(L){var T;e.forEach(L,function(C){var S=b[C];if(w.setNode(S),T){var D=b[T],I=w.edge(D,S);w.setEdge(D,S,Math.max(N(y,C,T),I||0))}T=C})}),w}function f(y,x){return e.minBy(e.values(x),function(b){var k=Number.NEGATIVE_INFINITY,w=Number.POSITIVE_INFINITY;return e.forIn(b,function(j,N){var L=v(y,N)/2;k=Math.max(j+L,k),w=Math.min(j-L,w)}),k-w})}function p(y,x){var b=e.values(x),k=e.min(b),w=e.max(b);e.forEach(["u","d"],function(j){e.forEach(["l","r"],function(N){var L=j+N,T=y[L],C;if(T!==x){var S=e.values(T);C=N==="l"?k-e.min(S):w-e.max(S),C&&(y[L]=e.mapValues(T,function(D){return D+C}))}})})}function h(y,x){return e.mapValues(y.ul,function(b,k){if(x)return y[x.toLowerCase()][k];var w=e.sortBy(e.map(y,k));return(w[1]+w[2])/2})}function g(y){var x=r.buildLayerMatrix(y),b=e.merge(t(y,x),s(y,x)),k={},w;e.forEach(["u","d"],function(N){w=N==="u"?x:e.values(x).reverse(),e.forEach(["l","r"],function(L){L==="r"&&(w=e.map(w,function(D){return e.values(D).reverse()}));var T=(N==="u"?y.predecessors:y.successors).bind(y),C=u(y,w,b,T),S=c(y,w,C.root,C.align,L==="r");L==="r"&&(S=e.mapValues(S,function(D){return-D})),k[N+L]=S})});var j=f(y,k);return p(k,j),h(k,y.graph().align)}function m(y,x,b){return function(k,w,j){var N=k.node(w),L=k.node(j),T=0,C;if(T+=N.width/2,e.has(N,"labelpos"))switch(N.labelpos.toLowerCase()){case"l":C=-N.width/2;break;case"r":C=N.width/2;break}if(C&&(T+=b?C:-C),C=0,T+=(N.dummy?x:y)/2,T+=(L.dummy?x:y)/2,T+=L.width/2,e.has(L,"labelpos"))switch(L.labelpos.toLowerCase()){case"l":C=L.width/2;break;case"r":C=-L.width/2;break}return C&&(T+=b?C:-C),C=0,T}}function v(y,x){return y.node(x).width}return qi}var Di,xh;function Py(){if(xh)return Di;xh=1;var e=be(),n=Ce(),r=Oy().positionX;Di=t;function t(a){a=n.asNonCompoundGraph(a),s(a),e.forEach(r(a),function(o,i){a.node(i).x=o})}function s(a){var o=n.buildLayerMatrix(a),i=a.graph().ranksep,u=0;e.forEach(o,function(c){var d=e.max(e.map(c,function(f){return a.node(f).height}));e.forEach(c,function(f){a.node(f).y=u+d/2}),u+=d+i})}return Di}var Mi,bh;function Ay(){if(bh)return Mi;bh=1;var e=be(),n=gy(),r=my(),t=yy(),s=Ce().normalizeRanks,a=xy(),o=Ce().removeEmptyRanks,i=by(),u=ky(),c=_y(),d=Ry(),f=Py(),p=Ce(),h=Ae().Graph;Mi=g;function g(R,M){var _=M&&M.debugTiming?p.time:p.notime;_("layout",function(){var B=_(" buildLayoutGraph",function(){return T(R)});_(" runLayout",function(){m(B,_)}),_(" updateInputGraph",function(){v(R,B)})})}function m(R,M){M(" makeSpaceForEdgeLabels",function(){C(R)}),M(" removeSelfEdges",function(){te(R)}),M(" acyclic",function(){n.run(R)}),M(" nestingGraph.run",function(){i.run(R)}),M(" rank",function(){t(p.asNonCompoundGraph(R))}),M(" injectEdgeLabelProxies",function(){S(R)}),M(" removeEmptyRanks",function(){o(R)}),M(" nestingGraph.cleanup",function(){i.cleanup(R)}),M(" normalizeRanks",function(){s(R)}),M(" assignRankMinMax",function(){D(R)}),M(" removeEdgeLabelProxies",function(){I(R)}),M(" normalize.run",function(){r.run(R)}),M(" parentDummyChains",function(){a(R)}),M(" addBorderSegments",function(){u(R)}),M(" order",function(){d(R)}),M(" insertSelfEdges",function(){re(R)}),M(" adjustCoordinateSystem",function(){c.adjust(R)}),M(" position",function(){f(R)}),M(" positionSelfEdges",function(){q(R)}),M(" removeBorderNodes",function(){V(R)}),M(" normalize.undo",function(){r.undo(R)}),M(" fixupEdgeLabelCoords",function(){W(R)}),M(" undoCoordinateSystem",function(){c.undo(R)}),M(" translateGraph",function(){P(R)}),M(" assignNodeIntersects",function(){F(R)}),M(" reversePoints",function(){K(R)}),M(" acyclic.undo",function(){n.undo(R)})}function v(R,M){e.forEach(R.nodes(),function(_){var B=R.node(_),$=M.node(_);B&&(B.x=$.x,B.y=$.y,M.children(_).length&&(B.width=$.width,B.height=$.height))}),e.forEach(R.edges(),function(_){var B=R.edge(_),$=M.edge(_);B.points=$.points,e.has($,"x")&&(B.x=$.x,B.y=$.y)}),R.graph().width=M.graph().width,R.graph().height=M.graph().height}var y=["nodesep","edgesep","ranksep","marginx","marginy"],x={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},b=["acyclicer","ranker","rankdir","align"],k=["width","height"],w={width:0,height:0},j=["minlen","weight","width","height","labeloffset"],N={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},L=["labelpos"];function T(R){var M=new h({multigraph:!0,compound:!0}),_=ie(R.graph());return M.setGraph(e.merge({},x,G(_,y),e.pick(_,b))),e.forEach(R.nodes(),function(B){var $=ie(R.node(B));M.setNode(B,e.defaults(G($,k),w)),M.setParent(B,R.parent(B))}),e.forEach(R.edges(),function(B){var $=ie(R.edge(B));M.setEdge(B,e.merge({},N,G($,j),e.pick($,L)))}),M}function C(R){var M=R.graph();M.ranksep/=2,e.forEach(R.edges(),function(_){var B=R.edge(_);B.minlen*=2,B.labelpos.toLowerCase()!=="c"&&(M.rankdir==="TB"||M.rankdir==="BT"?B.width+=B.labeloffset:B.height+=B.labeloffset)})}function S(R){e.forEach(R.edges(),function(M){var _=R.edge(M);if(_.width&&_.height){var B=R.node(M.v),$=R.node(M.w),X={rank:($.rank-B.rank)/2+B.rank,e:M};p.addDummyNode(R,"edge-proxy",X,"_ep")}})}function D(R){var M=0;e.forEach(R.nodes(),function(_){var B=R.node(_);B.borderTop&&(B.minRank=R.node(B.borderTop).rank,B.maxRank=R.node(B.borderBottom).rank,M=e.max(M,B.maxRank))}),R.graph().maxRank=M}function I(R){e.forEach(R.nodes(),function(M){var _=R.node(M);_.dummy==="edge-proxy"&&(R.edge(_.e).labelRank=_.rank,R.removeNode(M))})}function P(R){var M=Number.POSITIVE_INFINITY,_=0,B=Number.POSITIVE_INFINITY,$=0,X=R.graph(),U=X.marginx||0,le=X.marginy||0;function Q(ee){var he=ee.x,z=ee.y,Z=ee.width,H=ee.height;M=Math.min(M,he-Z/2),_=Math.max(_,he+Z/2),B=Math.min(B,z-H/2),$=Math.max($,z+H/2)}e.forEach(R.nodes(),function(ee){Q(R.node(ee))}),e.forEach(R.edges(),function(ee){var he=R.edge(ee);e.has(he,"x")&&Q(he)}),M-=U,B-=le,e.forEach(R.nodes(),function(ee){var he=R.node(ee);he.x-=M,he.y-=B}),e.forEach(R.edges(),function(ee){var he=R.edge(ee);e.forEach(he.points,function(z){z.x-=M,z.y-=B}),e.has(he,"x")&&(he.x-=M),e.has(he,"y")&&(he.y-=B)}),X.width=_-M+U,X.height=$-B+le}function F(R){e.forEach(R.edges(),function(M){var _=R.edge(M),B=R.node(M.v),$=R.node(M.w),X,U;_.points?(X=_.points[0],U=_.points[_.points.length-1]):(_.points=[],X=$,U=B),_.points.unshift(p.intersectRect(B,X)),_.points.push(p.intersectRect($,U))})}function W(R){e.forEach(R.edges(),function(M){var _=R.edge(M);if(e.has(_,"x"))switch((_.labelpos==="l"||_.labelpos==="r")&&(_.width-=_.labeloffset),_.labelpos){case"l":_.x-=_.width/2+_.labeloffset;break;case"r":_.x+=_.width/2+_.labeloffset;break}})}function K(R){e.forEach(R.edges(),function(M){var _=R.edge(M);_.reversed&&_.points.reverse()})}function V(R){e.forEach(R.nodes(),function(M){if(R.children(M).length){var _=R.node(M),B=R.node(_.borderTop),$=R.node(_.borderBottom),X=R.node(e.last(_.borderLeft)),U=R.node(e.last(_.borderRight));_.width=Math.abs(U.x-X.x),_.height=Math.abs($.y-B.y),_.x=X.x+_.width/2,_.y=B.y+_.height/2}}),e.forEach(R.nodes(),function(M){R.node(M).dummy==="border"&&R.removeNode(M)})}function te(R){e.forEach(R.edges(),function(M){if(M.v===M.w){var _=R.node(M.v);_.selfEdges||(_.selfEdges=[]),_.selfEdges.push({e:M,label:R.edge(M)}),R.removeEdge(M)}})}function re(R){var M=p.buildLayerMatrix(R);e.forEach(M,function(_){var B=0;e.forEach(_,function($,X){var U=R.node($);U.order=X+B,e.forEach(U.selfEdges,function(le){p.addDummyNode(R,"selfedge",{width:le.label.width,height:le.label.height,rank:U.rank,order:X+ ++B,e:le.e,label:le.label},"_se")}),delete U.selfEdges})})}function q(R){e.forEach(R.nodes(),function(M){var _=R.node(M);if(_.dummy==="selfedge"){var B=R.node(_.e.v),$=B.x+B.width/2,X=B.y,U=_.x-$,le=B.height/2;R.setEdge(_.e,_.label),R.removeNode(M),_.label.points=[{x:$+2*U/3,y:X-le},{x:$+5*U/6,y:X-le},{x:$+U,y:X},{x:$+5*U/6,y:X+le},{x:$+2*U/3,y:X+le}],_.label.x=_.x,_.label.y=_.y}})}function G(R,M){return e.mapValues(e.pick(R,M),Number)}function ie(R){var M={};return e.forEach(R,function(_,B){M[B.toLowerCase()]=_}),M}return Mi}var Wi,kh;function Ly(){if(kh)return Wi;kh=1;var e=be(),n=Ce(),r=Ae().Graph;Wi={debugOrdering:t};function t(s){var a=n.buildLayerMatrix(s),o=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(i){o.setNode(i,{label:i}),o.setParent(i,"layer"+s.node(i).rank)}),e.forEach(s.edges(),function(i){o.setEdge(i.v,i.w,{},i.name)}),e.forEach(a,function(i,u){var c="layer"+u;o.setNode(c,{rank:"same"}),e.reduce(i,function(d,f){return o.setEdge(d,f,{style:"invis"}),f})}),o}return Wi}var Bi,_h;function qy(){return _h||(_h=1,Bi="0.8.5"),Bi}var Fi,Sh;function Dy(){return Sh||(Sh=1,Fi={graphlib:Ae(),layout:Ay(),debug:Ly(),util:{time:Ce().time,notime:Ce().notime},version:qy()}),Fi}var My=Dy();const wh=cg(My);function ar(e,n="TB"){if(e.data?._layoutWidth&&e.data?._layoutHeight)return{width:e.data._layoutWidth,height:e.data._layoutHeight};let r=240,t=80;switch(e.type){case"decisionNode":r=212,t=160;break;case"forkNode":r=240,t=95;break;case"joinNode":r=240,t=95;break;case"dynamicPlaceholderNode":r=220,t=70;break;case"loopNode":r=320,t=200;break;case"subWorkflowNode":r=240,t=95;break;case"eventNode":r=240,t=85;break;case"default":r=240,t=40;break;case"plusNode":r=e.data.label&&e.data.label!=="+"?120:32,t=32;break;default:r=240,t=95;break}return{width:r,height:t}}function Wy(e,n,r=8){const t=[];if(e.length<r)return t;const s=new Map,a={},o={};e.forEach(f=>{s.set(f.id,f),a[f.id]=[],o[f.id]=[]}),n.forEach(f=>{a[f.source]&&a[f.source].push(f.target),o[f.target]&&o[f.target].push(f.source)});const i=new Set,u=new Set(["input","output","decisionNode","forkNode","joinNode","loopNode","default","plusNode"]),c=f=>!u.has(f.type||""),d=[...e].sort((f,p)=>f.position.y-p.position.y);for(const f of d){if(i.has(f.id)||!c(f)||a[f.id].length>1)continue;const p=[f.id];let h=f,g=a[h.id];for(;g&&g.length===1;){const m=g[0],v=s.get(m);if(!v||i.has(m)||!c(v)||o[m].length!==1)break;p.push(m),h=v,g=a[h.id]}p.length>=r&&(t.push(p),p.forEach(m=>i.add(m)))}return t}function By(e,n,r,t,s,a=5,o="view"){const i=n.find(x=>x.id===e[0]),{width:u,height:c}=ar(i||n[0],r),d=Math.max(.7,1-(e.length-10)/80),f=o==="edit"||o==="run"?1.15:1,p=Math.min(t,Math.round(60*d*f)),h=Math.min(s,Math.round(80*d*f)),g=u+p,m=c+h;let v=0,y=0;if(r==="TB"){const x=Math.ceil(e.length/a);v=a*g-p,y=x*m-h}else v=Math.ceil(e.length/a)*g-p,y=a*m-h;return v+=40,y+=40,{width:v,height:y,gridKW:g,gridKH:m,cols:a}}const $i=58,Th=20,Fy=16;function $y(e,n,r,t){if(e.length===0)return{positionedChildren:[],containerWidth:280,containerHeight:$i+50};const s=e.map(f=>({...f,parentId:void 0,extent:void 0})),{nodes:a}=zi(s,n,{direction:r,mode:t,enableSnakeLayout:!1});let o=0,i=0;a.forEach(f=>{const{width:p,height:h}=ar(f,r);o=Math.max(o,f.position.x+p),i=Math.max(i,f.position.y+h)});const u=Math.max(300,o+Th*2),c=$i+i+Fy;return{positionedChildren:a.map(f=>{const p=e.find(h=>h.id===f.id);return{...f,parentId:p.parentId,extent:p.extent,position:{x:f.position.x+Th,y:f.position.y+$i}}}),containerWidth:u,containerHeight:c}}function zi(e,n,r={}){const{direction:t="TB",mode:s="view",enableSnakeLayout:a=!0,snakeColumns:o=5,snakeMinChainLength:i=8,snakeMinNodeCount:u=10}=r,c=e.length,d=e.filter(T=>T.type!=="plusNode").length;let f=t==="LR"?150:120,p=t==="LR"?120:100,h=f,g=p;if(c>15){let T=Math.max(.5,1-(c-15)/50),C=Math.max(.4,1-(c-15)/40);(s==="edit"||s==="run")&&(T=1-(1-T)*.5,C=1-(1-C)*.5),h=Math.round(f*T),g=Math.round(p*C)}const m=a&&d>u?Wy(e,n,i):[],v={};m.forEach((T,C)=>{T.forEach(S=>{v[S]=C})});const y=new wh.graphlib.Graph;y.setDefaultEdgeLabel(()=>({})),y.setGraph({rankdir:t,ranker:"network-simplex",ranksep:h,nodesep:g,edgesep:50,marginx:50,marginy:50});const x=new Set,b={};e.forEach(T=>{const C=v[T.id];if(C!==void 0){if(!x.has(C)){x.add(C);const S=By(m[C],e,t,g,h,o,s);b[C]=S,y.setNode(`__CHAIN_${C}`,{width:S.width,height:S.height})}}else{const{width:S,height:D}=ar(T,t);y.setNode(T.id,{width:S,height:D})}}),n.forEach(T=>{const C=v[T.source],S=v[T.target];let D=T.source,I=T.target;C!==void 0&&(D=`__CHAIN_${C}`),S!==void 0&&(I=`__CHAIN_${S}`),D!==I&&y.setEdge(D,I)}),wh.layout(y);const k={};for(const T of e)k[T.id]={...T};const w=[],j=new Set;e.forEach(T=>{if(v[T.id]===void 0){const C=y.node(T.id),S=k[T.id],{width:D,height:I}=ar(S,t);S.position={x:C.x-D/2,y:C.y-I/2},S.data={...S.data,sourcePosition:void 0,targetPosition:void 0},S.sourcePosition=t==="LR"?A.Position.Right:A.Position.Bottom,S.targetPosition=t==="LR"?A.Position.Left:A.Position.Top,w.push(S)}else j.add(T.id)}),m.forEach((T,C)=>{const S=`__CHAIN_${C}`,D=y.node(S),I=b[C],P=D.x-I.width/2+20,F=D.y-I.height/2+20,W=I.cols,K=I.gridKW,V=I.gridKH;T.forEach((te,re)=>{const q=k[te];let G=0,ie=0,R,M;if(t==="TB"){const _=Math.floor(re/W),B=re%W,$=_%2===0,X=Math.ceil(T.length/W),U=_===X-1,le=T.length%W||W,Q=U?(W-le)*K/2:0;let ee;$?ee=B*K+Q:ee=(W-1-B)*K-Q;const he=_*V;G=P+ee,ie=F+he;const z=U?le:W;$?(M=A.Position.Left,R=A.Position.Right,B===z-1&&re!==T.length-1&&(R=A.Position.Bottom),B===0&&re!==0&&(M=A.Position.Top)):(M=A.Position.Right,R=A.Position.Left,B===z-1&&re!==T.length-1&&(R=A.Position.Bottom),B===0&&re!==0&&(M=A.Position.Top)),re===0&&(M=A.Position.Top),re===T.length-1&&(R=A.Position.Bottom)}else{const _=Math.floor(re/W),B=re%W,$=_%2===0,X=Math.ceil(T.length/W),U=_===X-1,le=T.length%W||W,Q=U?Math.max(0,(W-le)*V)/2:0,ee=_*K;let he;$?he=B*V+Q:he=(W-1-B)*V-Q,G=P+ee,ie=F+he;const z=U?le:W;$?(M=A.Position.Top,R=A.Position.Bottom,B===z-1&&re!==T.length-1&&(R=A.Position.Right),B===0&&re!==0&&(M=A.Position.Left)):(M=A.Position.Bottom,R=A.Position.Top,B===z-1&&re!==T.length-1&&(R=A.Position.Right),B===0&&re!==0&&(M=A.Position.Left)),re===0&&(M=A.Position.Left),re===T.length-1&&(R=A.Position.Right)}q.position={x:G,y:ie},q.data={...q.data,sourcePosition:R,targetPosition:M},q.sourcePosition=R,q.targetPosition=M,w.push(q)})});const N=w.reduce((T,C)=>({...T,[C.id]:C}),{}),L=n.map(T=>{const C=N[T.source],S=N[T.target];if(!C||!S||j.has(C.id)||C.type!=="decisionNode")return T;const{width:D,height:I}=ar(C,t),{width:P,height:F}=ar(S,t),W={x:C.position.x+D/2,y:C.position.y+I/2},K={x:S.position.x+P/2,y:S.position.y+F/2};let V=null;if(t==="TB"){const te=D*.25;K.x<W.x-te?V="left":K.x>W.x+te&&(V="right")}else{const te=I*.25;K.y<W.y-te?V="top":K.y>W.y+te&&(V="bottom")}return{...T,sourceHandle:V}});return{nodes:w,edges:L}}function Se(e,n,r={}){const t=r.direction||"TB",s=r.mode||"view",a=e.filter(y=>y.parentId),o=e.filter(y=>!y.parentId);if(a.length===0)return zi(e,n,r);const i=new Map(a.map(y=>[y.id,y])),u={},c=[];n.forEach(y=>{const x=i.get(y.source),b=i.get(y.target);if(x?.parentId&&x.parentId===b?.parentId){const k=x.parentId;u[k]||(u[k]=[]),u[k].push(y)}else c.push(y)});const d={};a.forEach(y=>{const x=y.parentId;d[x]||(d[x]=[]),d[x].push(y)});const f={},p=[];for(const[y,x]of Object.entries(d)){const b=u[y]||[],{positionedChildren:k,containerWidth:w,containerHeight:j}=$y(x,b,t,s);f[y]={width:w,height:j},p.push(...k)}const h=o.map(y=>{if(y.type==="loopNode"&&f[y.id]){const{width:x,height:b}=f[y.id];return{...y,data:{...y.data,_layoutWidth:x,_layoutHeight:b},style:{...y.style,width:x,height:b}}}return y}),{nodes:g,edges:m}=zi(h,c,r);return{nodes:[...g.map(y=>{if(y.type==="loopNode"&&f[y.id]){const{width:x,height:b}=f[y.id];return{...y,width:x,height:b,style:{...y.style,width:x,height:b}}}return y}),...p],edges:[...m,...Object.values(u).flat()]}}function je(e,n){if(!e)return null;for(const r of e){if(r.taskReferenceName===n)return r;if(r.decisionCases){for(const s of Object.keys(r.decisionCases)){const a=je(r.decisionCases[s],n);if(a)return a}const t=je(r.defaultCase,n);if(t)return t}if(r.forkTasks)for(const t of r.forkTasks){const s=je(t,n);if(s)return s}if(r.loopOver){const t=je(r.loopOver,n);if(t)return t}}return null}function We(e,n){if(!e)return!1;const r=e.findIndex(t=>t.taskReferenceName===n);if(r!==-1)return e.splice(r,1),!0;for(const t of e){if(t.decisionCases){for(const s of Object.keys(t.decisionCases))if(We(t.decisionCases[s],n))return!0;if(We(t.defaultCase,n))return!0}if(t.forkTasks){for(const s of t.forkTasks)if(We(s,n))return!0}if(t.loopOver&&We(t.loopOver,n))return!0}return!1}function sr(e,n){if(!e)return null;if(e.some(r=>r.taskReferenceName===n))return e;for(const r of e){if(r.decisionCases){for(const s of Object.values(r.decisionCases)){const a=sr(s,n);if(a)return a}const t=sr(r.defaultCase,n);if(t)return t}if(r.forkTasks)for(const t of r.forkTasks){const s=sr(t,n);if(s)return s}if(r.loopOver){const t=sr(r.loopOver,n);if(t)return t}}return null}function Eh(e,n){const r=e.findIndex(t=>t.taskReferenceName===n);if(r<0)return null;for(let t=r+1;t<e.length;t++)if(e[t].type==="JOIN"||e[t].type==="EXCLUSIVE_JOIN")return e[t].taskReferenceName;return null}function Nh(e,n){const r=e.findIndex(t=>t.taskReferenceName===n);if(r<0)return null;for(let t=r-1;t>=0;t--)if(e[t].type==="FORK_JOIN"||e[t].type==="FORK_JOIN_DYNAMIC")return e[t].taskReferenceName;return null}function Le(e,n,r){if(!e)return!1;if(n==="start")return e.unshift(r),!0;const t=e.findIndex(s=>s.taskReferenceName===n);if(t!==-1)return e.splice(t+1,0,r),!0;for(const s of e){if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(Le(s.decisionCases[a],n,r))return!0;if(Le(s.defaultCase,n,r))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(Le(a,n,r))return!0}if(s.loopOver&&Le(s.loopOver,n,r))return!0}return!1}function or(e,n,r,t){for(const s of e||[]){if(s.taskReferenceName===n){if(r.branchCase==="default")return s.defaultCase||(s.defaultCase=[]),s.defaultCase.unshift(t),!0;if(r.branchCase!==void 0)return s.decisionCases||(s.decisionCases={}),s.decisionCases[r.branchCase]||(s.decisionCases[r.branchCase]=[]),s.decisionCases[r.branchCase].unshift(t),!0;if(r.forkIndex!==void 0)return s.forkTasks||(s.forkTasks=[]),s.forkTasks[r.forkIndex].unshift(t),!0;if(r.isLoopAdd)return s.loopOver||(s.loopOver=[]),s.loopOver.unshift(t),!0}if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(or(s.decisionCases[a],n,r,t))return!0;if(or(s.defaultCase,n,r,t))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(or(a,n,r,t))return!0}if(s.loopOver&&or(s.loopOver,n,r,t))return!0}return!1}function Ee(e){if(e)for(let n=0;n<e.length;n++){const r=e[n];if(r.type==="FORK_JOIN"&&n+1<e.length){const t=e[n+1];if(t.type==="JOIN"){const s=[];(r.forkTasks||[]).forEach(a=>{a&&a.length>0&&s.push(a[a.length-1].taskReferenceName)}),t.joinOn=s}}r.decisionCases&&(Object.values(r.decisionCases).forEach(t=>Ee(t)),r.defaultCase&&Ee(r.defaultCase)),r.forkTasks&&r.forkTasks.forEach(t=>Ee(t)),r.loopOver&&Ee(r.loopOver)}}const zy=[{field:"name",type:"required",message:"工作流名称 (name) 必填"},{field:"version",type:"required",message:"工作流版本 (version) 必填"},{field:"tasks",type:"min_length",value:1,message:"工作流必须包含至少一个任务"}],Ch={common:[{field:"name",type:"required",message:"任务类型名称 (name) 必填"},{field:"taskReferenceName",type:"required",message:"引用名 (taskReferenceName) 必填"},{field:"taskReferenceName",type:"pattern",value:/^[a-zA-Z0-9_]+$/,message:"引用名仅允许字母、数字和下划线"},{field:"taskReferenceName",type:"unique",message:"引用名在工作流中必须唯一"}],types:{HTTP:[{field:"inputParameters.http_request.uri",type:"required",message:"HTTP 任务缺少请求地址 (uri) 配置"},{field:"inputParameters.http_request.method",type:"required",level:"warning",message:"HTTP 任务未指定 Method,建议配置"}],INLINE:[{field:"inputParameters.expression",type:"custom",validate:(e,n)=>!!(n?.inputParameters?.expression||n?.inputParameters?.scriptExpression),message:"INLINE 任务缺少脚本表达式 (expression)"}],LAMBDA:[{field:"inputParameters.scriptExpression",type:"required",message:"LAMBDA 任务缺少脚本表达式 (scriptExpression)"}],JSON_JQ_TRANSFORM:[{field:"inputParameters.queryExpression",type:"required",message:"JQ 任务缺少查询表达式 (queryExpression)"}],SUB_WORKFLOW:[{field:"subWorkflowParam.name",type:"required",message:"子工作流任务缺少子流程名称 (name)"}],START_WORKFLOW:[{field:"inputParameters.startWorkflow.name",type:"custom",validate:(e,n)=>!!n?.inputParameters?.startWorkflow?.name,message:"START_WORKFLOW 任务缺少目标工作流名称"}],DYNAMIC:[{field:"dynamicTaskNameParam",type:"required",message:"DYNAMIC 任务缺少 dynamicTaskNameParam 配置"}],TERMINATE:[{field:"inputParameters.terminationStatus",type:"required",level:"warning",message:"终止任务未指定状态 (terminationStatus)"},{field:"inputParameters.terminationStatus",type:"enum",value:["COMPLETED","FAILED"],message:"终止状态必须为 COMPLETED 或 FAILED"}],DO_WHILE:[{field:"loopCondition",type:"custom",validate:(e,n)=>!!(n?.loopCondition||n?.inputParameters?.items),message:"循环任务需要配置退出条件 (loopCondition) 或列表 (items)"}],DECISION:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"决策任务必须至少包含一个分支 (decisionCases)"},{field:"decisionCases",type:"custom",validate:e=>{const n=Object.keys(e||{});return new Set(n).size===n.length},message:"决策分支条件不能重复"}],SWITCH:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"Switch 任务必须至少包含一个分支"}],FORK_JOIN_DYNAMIC:[{field:"dynamicForkTasksParam",type:"custom",validate:(e,n)=>!!(n?.dynamicForkTasksParam||n?.forkTaskType||n?.forkTaskWorkflow),message:"FORK_JOIN_DYNAMIC 任务需要配置 dynamicForkTasksParam 或 forkTaskType 或 forkTaskWorkflow",level:"warning"}]}};class Hy{rules=[];setRules(n){this.rules=[...n]}getRules(){return this.rules}hasRules(){return this.rules.length>0}runAll(n){const r=[],t=[];for(const s of this.rules)try{const a=s.validate(n);for(const o of a)s.level==="warning"?t.push(o):r.push(o)}catch{r.push({type:"GLOBAL",ref:"",message:`自定义规则 "${s.id}" 执行异常`})}return{errors:r,warnings:t}}buildPromptSection(){return this.rules.length===0?null:`## 业务校验规则(必须遵守)
|
|
7
|
+
以下规则由集成方定义,生成工作流时必须满足:
|
|
8
|
+
${this.rules.map(r=>`- ${r.description}`).join(`
|
|
9
|
+
`)}`}}const jh=new Hy,Ky=(e,n)=>n.split(".").reduce((r,t)=>r&&r[t]!==void 0?r[t]:void 0,e),Hi=(e,n,r,t)=>{const{errors:s,warnings:a}=t,o=e.taskReferenceName||"GLOBAL";n.forEach(i=>{const u=Ky(e,i.field);let c=!0;switch(i.type){case"required":c=u!=null&&u!=="";break;case"min_length":c=Array.isArray(u)&&u.length>=i.value;break;case"pattern":c=i.value.test(u);break;case"enum":c=i.value.includes(u);break;case"unique":i.field==="taskReferenceName"&&u&&(r.taskRefs.has(u)?c=!1:r.taskRefs.add(u));break;case"custom":typeof i.validate=="function"&&(c=i.validate(u,e,r));break}if(!c){const d={type:e.taskReferenceName?"TASK":"GLOBAL",ref:o,message:i.message};i.level==="warning"?a.push(d):s.push(d)}})},Oe=e=>{const n=[],r=[],t={taskRefs:new Set,taskMap:{}};if(!e)return{isValid:!1,errors:[{type:"GLOBAL",ref:"",message:"工作流定义为空"}],warnings:[]};if(Hi(e,zy,t,{errors:n,warnings:r}),!e.tasks||e.tasks.length===0)return{isValid:!1,errors:n,warnings:r};const s=o=>{o.forEach(i=>{Hi(i,Ch.common,t,{errors:n,warnings:r});const u=Ch.types[i.type];u&&Hi(i,u,t,{errors:n,warnings:r}),i.decisionCases&&Object.keys(i.decisionCases).forEach(c=>{s(i.decisionCases[c])}),i.defaultCase&&s(i.defaultCase),i.forkTasks&&i.forkTasks.forEach(c=>s(c)),i.loopOver&&s(i.loopOver)})};s(e.tasks);const a=Uy(e.tasks);if(n.push(...a),jh.hasRules()){const o=jh.runAll(e);n.push(...o.errors),r.push(...o.warnings)}return{isValid:n.length===0,errors:n,warnings:r}},Uy=e=>{const n=[],r=new Map,t=new Set,s=d=>{for(let f=0;f<d.length;f++){const p=d[f],h=p.taskReferenceName;if(t.add(h),r.has(h)||r.set(h,[]),f<d.length-1){const g=d[f+1].taskReferenceName;p.type!=="FORK_JOIN"&&p.type!=="FORK_JOIN_DYNAMIC"&&r.get(h).push(g)}if(p.decisionCases)for(const g of Object.values(p.decisionCases))g.length>0&&(r.get(h).push(g[0].taskReferenceName),s(g));if(p.defaultCase&&p.defaultCase.length>0&&(r.get(h).push(p.defaultCase[0].taskReferenceName),s(p.defaultCase)),p.forkTasks)for(const g of p.forkTasks)g.length>0&&(r.get(h).push(g[0].taskReferenceName),s(g));if(p.loopOver)for(const g of p.loopOver)t.add(g.taskReferenceName);if(p.joinOn)for(const g of p.joinOn)r.has(g)||r.set(g,[]),r.get(g).push(h)}};s(e);const a=0,o=1,i=2,u=new Map;for(const d of t)u.set(d,a);const c=d=>{u.set(d,o);const f=r.get(d)||[];for(const p of f)if(u.has(p)){if(u.get(p)===o)return n.push({type:"GLOBAL",ref:p,message:`检测到环路:任务 "${d}" → "${p}" 形成了循环依赖`}),!0;if(u.get(p)===a&&c(p))return!0}return u.set(d,i),!1};for(const d of t)u.get(d)===a&&c(d);return n};function Jy(e,n){const r=new Set(e),t={};e.forEach(i=>t[i]=0),n.forEach(i=>{r.has(i.source)&&r.has(i.target)&&(t[i.target]=(t[i.target]??0)+1)});const s=[];let a=e.filter(i=>t[i]===0);const o={...t};for(;a.length>0;){s.push([...a]);const i=[];a.forEach(u=>{n.forEach(c=>{c.source===u&&r.has(c.target)&&(o[c.target]--,o[c.target]===0&&i.push(c.target))})}),a=i}return s}const oe=rt()(rl(gg((e,n)=>({mode:"view",workflowDef:null,workflowInstance:null,nodes:[],edges:[],taskMap:{},layoutDirection:"TB",selectedTask:null,selectedTaskInstance:null,isDetailPanelOpen:!1,executionData:null,dynamicRuntimeTasksByFork:{},validationResults:{isValid:!0,errors:[],warnings:[]},theme:"dark",themeColor:"blue",edgeType:"smoothstep",nodesLocked:!0,copiedTask:null,viewMode:"business",simState:{},isSimRunning:!1,workflowLoadKey:0,runState:"idle",pendingExecutionId:null,executionError:null,showRunPanel:!1,showAnalysisPanel:!1,focusedParamKey:null,setWorkflow:(r,t)=>{const s=t||n().layoutDirection,a=JSON.parse(JSON.stringify(r));Ee(a.tasks);const{nodes:o,edges:i,taskMap:u}=Te(a,s,{hideEmptyBranches:n().mode!=="edit"}),{nodes:c,edges:d}=Se(o,i,{direction:s,mode:n().mode}),f=Oe(a);e({workflowDef:a,nodes:c,edges:d,taskMap:u,validationResults:f,layoutDirection:s,workflowLoadKey:n().workflowLoadKey+1})},setMode:r=>{n().mode==="run"&&r!=="run"&&e({executionData:null,workflowInstance:null,dynamicRuntimeTasksByFork:{}}),e({mode:r});const{workflowDef:s,layoutDirection:a}=n();if(s){const{nodes:o,edges:i,taskMap:u}=Te(s,a,{hideEmptyBranches:r!=="edit"}),{nodes:c,edges:d}=Se(o,i,{direction:a,mode:r});e({nodes:c,edges:d,taskMap:u})}},setExecutionData:r=>e({executionData:r,dynamicRuntimeTasksByFork:r===null?{}:n().dynamicRuntimeTasksByFork}),updateTaskStatus:(r,t)=>{const{executionData:s}=n();if(!s)return;const a={...s};a[r]&&(a[r]={...a[r],status:t},e({executionData:a}))},loadSampleExecution:async()=>{try{const t=await(await fetch("/sample-workflows/sample-execution.json")).json();n().importExecutionJSON(t)}catch(r){console.error("Failed to load sample execution:",r),alert("加载示例运行数据失败")}},importExecutionJSON:r=>{if(!r)return;let t=[],s=null,a=n().workflowDef;if(Array.isArray(r.tasks)?(t=r.tasks,r.workflowId&&r.status&&(s=r,r.workflowDefinition&&(a=r.workflowDefinition))):Array.isArray(r)&&(t=r),t.length===0)return;const o={};t.forEach(p=>{const h=p.referenceTaskName;h&&(o[h]||(o[h]={taskReferenceName:h,status:p.status,attempts:[],startTime:p.startTime,endTime:p.endTime,output:p.outputData,input:p.inputData,reasonForIncompletion:p.reasonForIncompletion,iteration:p.iteration}),o[h].attempts.push(p))}),Object.values(o).forEach(p=>{p.attempts.some(m=>m.iteration!==void 0&&m.iteration>0)?(p.attempts.sort((m,v)=>(m.iteration??0)-(v.iteration??0)),p.totalIterations=p.attempts.reduce((m,v)=>Math.max(m,v.iteration??0),0),p.startTime=p.attempts[0]?.startTime):p.attempts.sort((m,v)=>(m.retryCount??0)-(v.retryCount??0));const g=p.attempts[p.attempts.length-1];g&&(p.status=g.status,p.endTime=g.endTime,p.output=g.outputData,p.input=g.inputData,p.reasonForIncompletion=g.reasonForIncompletion,p.iteration=g.iteration)}),a&&JSON.stringify(a)!==JSON.stringify(n().workflowDef)&&n().setWorkflow(a);const i=n().taskMap,c=n().workflowDef?.tasks||[],d=[];c.forEach((p,h)=>{if(p.type==="FORK_JOIN_DYNAMIC"){for(let g=h+1;g<c.length;g++)if(c[g].type==="JOIN"||c[g].type==="EXCLUSIVE_JOIN"){d.push({forkRef:p.taskReferenceName,joinRef:c[g].taskReferenceName});break}}});const f={};d.forEach(({forkRef:p,joinRef:h})=>{const g=t.findIndex(y=>y.referenceTaskName===p),m=t.findIndex(y=>y.referenceTaskName===h);if(g<0||m<0)return;const v=new Set;f[p]=t.slice(g+1,m).filter(y=>!y.referenceTaskName||!y.taskId||i[y.referenceTaskName]||v.has(y.referenceTaskName)?!1:(v.add(y.referenceTaskName),!0)).map(y=>y)}),e({executionData:o,dynamicRuntimeTasksByFork:f,workflowInstance:s,mode:"run"})},setSelectedTask:r=>e({selectedTask:r?{...r}:null}),setIsDetailPanelOpen:r=>e({isDetailPanelOpen:r}),selectTaskAction:(r,t=!0)=>{e({selectedTask:r?{...r}:null,isDetailPanelOpen:r?t:!1,selectedTaskInstance:null})},setSelectedTaskInstance:r=>e({selectedTaskInstance:r}),setLayoutDirection:r=>{const{workflowDef:t}=n();if(t){const{nodes:s,edges:a,taskMap:o}=Te(t,r,{hideEmptyBranches:n().mode!=="edit"}),{nodes:i,edges:u}=Se(s,a,{direction:r,mode:n().mode});e({nodes:i,edges:u,taskMap:o,layoutDirection:r})}else e({layoutDirection:r})},onNodesChange:r=>{const t=n().nodes,s=new Set(t.map(o=>o.id)),a=r.filter(o=>"id"in o&&s.has(o.id));a.length!==0&&e({nodes:A.applyNodeChanges(a,t)})},onEdgesChange:r=>{const t=n().edges,s=A.applyEdgeChanges(r,t);s!==t&&e({edges:s})},onConnect:r=>{const{edges:t,layoutDirection:s}=n(),a=A.addEdge(r,t),{nodes:o,edges:i}=Se(n().nodes,a,{direction:s,mode:n().mode});e({edges:i,nodes:o})},checkTaskRefUniqueness:(r,t)=>{if(r===t)return!0;const{taskMap:s}=n();return!s[r]},updateTask:(r,t,s)=>{const{workflowDef:a,layoutDirection:o}=n();if(!a)return;const i=JSON.parse(JSON.stringify(a)),u=je(i.tasks,r);if(u){typeof t=="object"?Object.assign(u,t):u[t]=s,Ee(i.tasks);const{nodes:c,edges:d,taskMap:f}=Te(i,o,{hideEmptyBranches:n().mode!=="edit"}),{nodes:p,edges:h}=Se(c,d,{direction:o,mode:n().mode}),g=Oe(i);e({workflowDef:i,nodes:p,edges:h,taskMap:f,validationResults:g})}},updateWorkflowProperties:r=>{const{workflowDef:t,layoutDirection:s}=n();if(!t)return;const a=JSON.parse(JSON.stringify(t));Object.assign(a,r),Ee(a.tasks);const{nodes:o,edges:i,taskMap:u}=Te(a,s,{hideEmptyBranches:n().mode!=="edit"}),{nodes:c,edges:d}=Se(o,i,{direction:s,mode:n().mode}),f=Oe(a);e({workflowDef:a,nodes:c,edges:d,taskMap:u,validationResults:f})},addNode:(r,t,s,a,o={})=>{const{workflowDef:i,layoutDirection:u}=n();if(!i)return;const c=JSON.parse(JSON.stringify(i)),d={name:r.data.label,taskReferenceName:r.data.taskReferenceName,type:r.data.taskType||"SIMPLE",inputParameters:{}};switch(d.type){case"HTTP":d.httpRequest={method:"GET",uri:"https://example.com/api",headers:{"Content-Type":"application/json"},body:{}};break;case"KAFKA_PUBLISH":d.inputParameters={topic:"my_topic",value:"${workflow.input.value}",bootStrapServers:"localhost:9092",headers:{},key:"msg_key"};break;case"JSON_JQ_TRANSFORM":d.inputParameters={queryExpression:".name",input:{}};break;case"SET_VARIABLE":d.inputParameters={variableName:"variableValue"};break;case"SUB_WORKFLOW":d.subWorkflowParam={name:"execution_workflow",version:1};break;case"EVENT":d.sink="conductor";break;case"WAIT":d.inputParameters={duration:"30s"};break;case"TERMINATE":d.inputParameters={terminationStatus:"COMPLETED",workflowOutput:{}};break}if(d.type==="FORK_JOIN"||d.type==="FORK_JOIN_DYNAMIC"){d.type==="FORK_JOIN"?d.forkTasks=[[],[]]:(d.dynamicForkTasksParam="dynamic_tasks",d.dynamicForkTasksInputParamName="input");const y={name:`${d.name}_join`,taskReferenceName:`${d.taskReferenceName}_join`,type:"JOIN",joinOn:[]};if(o.isWorkflowStart)c.tasks.unshift(y),c.tasks.unshift(d);else if(o.isLoopBodyStart){const x=je(c.tasks,t);x&&(x.loopOver||(x.loopOver=[]),x.loopOver.unshift(y),x.loopOver.unshift(d))}else o.branchCase!==void 0||o.forkIndex!==void 0||o.isLoopAdd?(or(c.tasks,t,o,d),Le(c.tasks,d.taskReferenceName,y)):c.tasks.length===0?c.tasks.push(d,y):(Le(c.tasks,t,d),Le(c.tasks,d.taskReferenceName,y))}else if(d.type==="DECISION"||d.type==="SWITCH"?(d.evaluatorType="value-param",d.caseValueParam="case_param",d.decisionCases={case1:[]},d.defaultCase=[]):d.type==="DO_WHILE"?(d.loopCondition="$.taskReferenceName.output.value < 10",d.loopOver=[]):d.type==="INLINE"?(d.evaluatorType="graaljs",d.inputParameters={expression:`function execute(input) {
|
|
7
10
|
return { result: input };
|
|
8
11
|
}
|
|
9
|
-
execute($.input);`}):u.type==="DYNAMIC"?(u.dynamicTaskNameParam="taskToExecute",u.inputParameters={taskToExecute:"${workflow.input.taskName}"}):u.type==="HUMAN"?u.humanTaskDef={userFormTemplate:"",assignmentCompletionStrategy:"LEAVE_OPEN"}:u.type==="START_WORKFLOW"?u.inputParameters={startWorkflow:{name:"",version:1,input:{},correlationId:""}}:u.type==="NOOP"&&(u.inputParameters={}),o.isWorkflowStart)c.tasks.unshift(u);else if(o.isLoopBodyStart){const y=Ce(c.tasks,n);y&&(y.loopOver||(y.loopOver=[]),y.loopOver.unshift(u))}else o.branchCase!==void 0||o.forkIndex!==void 0||o.isLoopAdd?ir(c.tasks,n,o,u):c.tasks.length===0?c.tasks.push(u):Ae(c.tasks,n,u);we(c.tasks);const{nodes:f,edges:p,taskMap:h}=Ee(c,d,{hideEmptyBranches:r().mode!=="edit"}),{nodes:g,edges:m}=_e(f,p,{direction:d,mode:r().mode}),v=Re(c);e({workflowDef:c,nodes:g,edges:m,taskMap:h,validationResults:v})},removeNode:t=>{const{workflowDef:n,layoutDirection:s,nodes:a}=r();if(!n)return;const o=JSON.parse(JSON.stringify(n)),i=or(o.tasks,t);if(i){const g=a.find(m=>m.id===t)?.data?.taskType;if(g==="FORK_JOIN"||g==="FORK_JOIN_DYNAMIC"){const m=kh(i,t);m&&Me(o.tasks,m)}else if(g==="JOIN"||g==="EXCLUSIVE_JOIN"){const m=_h(i,t);m&&Me(o.tasks,m)}}Me(o.tasks,t),we(o.tasks);const{nodes:d,edges:c,taskMap:u}=Ee(o,s,{hideEmptyBranches:r().mode!=="edit"}),{nodes:f,edges:p}=_e(d,c,{direction:s,mode:r().mode}),h=Re(o);e({workflowDef:o,nodes:f,edges:p,taskMap:u,validationResults:h})},addLoopTask:(t,n)=>{const{workflowDef:s,layoutDirection:a}=r();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=Ce(o.tasks,t);if(i&&i.type==="DO_WHILE"){i.loopOver||(i.loopOver=[]);const d={name:`new_${n.toLowerCase()}`,taskReferenceName:`${t}_sub_${Date.now()}`,type:n,inputParameters:{}};i.loopOver.push(d),we(o.tasks);const{nodes:c,edges:u,taskMap:f}=Ee(o,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=_e(c,u,{direction:a,mode:r().mode}),g=Re(o);e({workflowDef:o,nodes:p,edges:h,taskMap:f,validationResults:g})}},removeLoopTask:(t,n)=>{const{workflowDef:s,layoutDirection:a}=r();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=Ce(o.tasks,t);if(i&&i.type==="DO_WHILE"&&i.loopOver){const d=or(i.loopOver,n);if(d){const m=d.find(v=>v.taskReferenceName===n);if(m?.type==="FORK_JOIN"||m?.type==="FORK_JOIN_DYNAMIC"){const v=kh(d,n);v&&Me(i.loopOver,v)}else if(m?.type==="JOIN"||m?.type==="EXCLUSIVE_JOIN"){const v=_h(d,n);v&&Me(i.loopOver,v)}}Me(i.loopOver,n),we(o.tasks);const{nodes:c,edges:u,taskMap:f}=Ee(o,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=_e(c,u,{direction:a,mode:r().mode}),g=Re(o);e({workflowDef:o,nodes:p,edges:h,taskMap:f,validationResults:g})}},addDecisionBranch:(t,n)=>{const{workflowDef:s,layoutDirection:a}=r();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=Ce(o.tasks,t);if(i&&(i.type==="DECISION"||i.type==="SWITCH")){n==="default"?i.defaultCase||(i.defaultCase=[]):(i.decisionCases||(i.decisionCases={}),i.decisionCases[n]||(i.decisionCases[n]=[])),we(o.tasks);const{nodes:d,edges:c,taskMap:u}=Ee(o,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:f,edges:p}=_e(d,c,{direction:a,mode:r().mode}),h=Re(o);e({workflowDef:o,nodes:f,edges:p,taskMap:u,validationResults:h})}},removeDecisionBranch:(t,n)=>{const{workflowDef:s,layoutDirection:a}=r();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=Ce(o.tasks,t);if(i&&(i.type==="DECISION"||i.type==="SWITCH")){n==="default"?i.defaultCase=[]:i.decisionCases&&delete i.decisionCases[n],we(o.tasks);const{nodes:d,edges:c,taskMap:u}=Ee(o,a,{hideEmptyBranches:r().mode!=="edit"}),{nodes:f,edges:p}=_e(d,c,{direction:a,mode:r().mode}),h=Re(o);e({workflowDef:o,nodes:f,edges:p,taskMap:u,validationResults:h})}},renameDecisionBranch:(t,n,s)=>{const{workflowDef:a,layoutDirection:o}=r();if(!a||!s.trim()||n===s)return;const i=JSON.parse(JSON.stringify(a)),d=Ce(i.tasks,t);if(d&&(d.type==="DECISION"||d.type==="SWITCH")){if(!d.decisionCases||!d.decisionCases[n])return;d.decisionCases[s.trim()]=d.decisionCases[n],delete d.decisionCases[n],we(i.tasks);const{nodes:c,edges:u,taskMap:f}=Ee(i,o,{hideEmptyBranches:r().mode!=="edit"}),{nodes:p,edges:h}=_e(c,u,{direction:o,mode:r().mode}),g=Re(i);e({workflowDef:i,nodes:p,edges:h,taskMap:f,validationResults:g})}},addForkBranch:t=>{const{workflowDef:n,layoutDirection:s}=r();if(!n)return;const a=JSON.parse(JSON.stringify(n)),o=Ce(a.tasks,t);if(o&&o.type==="FORK_JOIN"){o.forkTasks||(o.forkTasks=[]),o.forkTasks.push([]),we(a.tasks);const{nodes:i,edges:d,taskMap:c}=Ee(a,s,{hideEmptyBranches:r().mode!=="edit"}),{nodes:u,edges:f}=_e(i,d,{direction:s,mode:r().mode}),p=Re(a);e({workflowDef:a,nodes:u,edges:f,taskMap:c,validationResults:p})}},copyTask:t=>e({copiedTask:t}),pasteTask:t=>{const{workflowDef:n,layoutDirection:s,selectedTask:a}=r();if(!n)return;const o=JSON.parse(JSON.stringify(n)),d=`_copy_${Date.now()}`,c=JSON.parse(JSON.stringify(t)),u=x=>{x.taskReferenceName=`${x.taskReferenceName}${d}`,x.decisionCases&&Object.values(x.decisionCases).forEach(b=>b.forEach(u)),x.defaultCase&&x.defaultCase.forEach(u),x.forkTasks&&x.forkTasks.forEach(b=>b.forEach(u)),x.loopOver&&x.loopOver.forEach(u)};u(c);const f=a?a.taskReferenceName:o.tasks.length>0?o.tasks[o.tasks.length-1].taskReferenceName:"start";if(c.type==="FORK_JOIN"){c.forkTasks||(c.forkTasks=[[],[]]);const x={name:`${c.name}_join`,taskReferenceName:`${c.taskReferenceName}_join`,type:"JOIN",joinOn:[]};o.tasks.length===0?o.tasks.push(c,x):(Ae(o.tasks,f,c),Ae(o.tasks,c.taskReferenceName,x))}else o.tasks.length===0?o.tasks.push(c):Ae(o.tasks,f,c);we(o.tasks);const{nodes:p,edges:h,taskMap:g}=Ee(o,s,{hideEmptyBranches:r().mode!=="edit"}),{nodes:m,edges:v}=_e(p,h,{direction:s,mode:r().mode}),y=Re(o);e({workflowDef:o,nodes:m,edges:v,taskMap:g,validationResults:y})},setTheme:t=>e({theme:t}),setThemeColor:t=>e({themeColor:t}),setEdgeType:t=>e({edgeType:t}),setNodesLocked:t=>e({nodesLocked:t}),setViewMode:t=>e({viewMode:t}),startSimulation:()=>{const{edges:t,nodes:n,isSimRunning:s}=r();if(s)return;const a=n.filter(f=>!["plusNode","dynamicPlaceholderNode"].includes(f.type??"")).map(f=>f.id),o=t.map(f=>({source:f.source,target:f.target})),i=Fy(a,o);e({isSimRunning:!0,simState:{}});const d={timer:null};r().__simHandle=d;let c=0;const u=()=>{if(c>=i.length||!r().isSimRunning){e({isSimRunning:!1});return}const f=i[c];e(p=>{const h={...p.simState};return f.forEach(g=>h[g]="running"),{simState:h}}),d.timer=setTimeout(()=>{r().isSimRunning&&(e(p=>{const h={...p.simState};return f.forEach(g=>h[g]="done"),{simState:h}}),c++,d.timer=setTimeout(u,280))},700)};u()},stopSimulation:()=>{const t=r().__simHandle;t?.timer&&clearTimeout(t.timer),e({isSimRunning:!1,simState:{}})},createBlankWorkflow:t=>{const n={name:t||"new_workflow",description:"",tasks:[],version:1,schemaVersion:2};r().setWorkflow(n),e({mode:"edit"})},applyAIGeneratedWorkflow:t=>{const{tasks:n,...s}=t,a={...s,name:t.name||"AI_Generated_Workflow",tasks:n||[],version:t.version||1,schemaVersion:2};r().setWorkflow(a)},setShowRunPanel:t=>e({showRunPanel:t}),setShowAnalysisPanel:t=>e({showAnalysisPanel:t}),setRunState:(t,n,s)=>{e({runState:t,pendingExecutionId:n!==void 0?n:r().pendingExecutionId,executionError:s!==void 0?s:r().executionError})},switchToEditAndFocusParam:(t,n)=>{const{workflowDef:s,layoutDirection:a,taskMap:o}=r();if(!s)return;e({mode:"edit",focusedParamKey:n??null});const{nodes:i,edges:d,taskMap:c}=Ee(s,a,{hideEmptyBranches:!1}),{nodes:u,edges:f}=_e(i,d,{direction:a,mode:"edit"});e({nodes:u,edges:f,taskMap:c});const p=o[t]||c[t];p&&e({selectedTask:{...p},isDetailPanelOpen:!0,showAnalysisPanel:!1})}}),{partialize:e=>({workflowDef:e.workflowDef,layoutDirection:e.layoutDirection,nodes:e.nodes,edges:e.edges,taskMap:e.taskMap,theme:e.theme,themeColor:e.themeColor,mode:e.mode,edgeType:e.edgeType,nodesLocked:e.nodesLocked,copiedTask:e.copiedTask}),equality:(e,r)=>JSON.stringify(e.workflowDef)===JSON.stringify(r.workflowDef)}),{name:"conductor-ui-prefs",version:1,storage:Yi(()=>localStorage),migrate:(e,r)=>(r===0&&e.edgeType==="default"&&(e.edgeType="smoothstep"),e),partialize:e=>({theme:e.theme,themeColor:e.themeColor,layoutDirection:e.layoutDirection,edgeType:e.edgeType,nodesLocked:e.nodesLocked,copiedTask:e.copiedTask,viewMode:e.viewMode})}));const $y=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),zy=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(r,t,n)=>n?n.toUpperCase():t.toLowerCase()),wh=e=>{const r=zy(e);return r.charAt(0).toUpperCase()+r.slice(1)},Th=(...e)=>e.filter((r,t,n)=>!!r&&r.trim()!==""&&n.indexOf(r)===t).join(" ").trim(),Hy=e=>{for(const r in e)if(r.startsWith("aria-")||r==="role"||r==="title")return!0};var Ky={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Uy=P.forwardRef(({color:e="currentColor",size:r=24,strokeWidth:t=2,absoluteStrokeWidth:n,className:s="",children:a,iconNode:o,...i},d)=>P.createElement("svg",{ref:d,...Ky,width:r,height:r,stroke:e,strokeWidth:n?Number(t)*24/Number(r):t,className:Th("lucide",s),...!a&&!Hy(i)&&{"aria-hidden":"true"},...i},[...o.map(([c,u])=>P.createElement(c,u)),...Array.isArray(a)?a:[a]]));const Se=(e,r)=>{const t=P.forwardRef(({className:n,...s},a)=>P.createElement(Uy,{ref:a,iconNode:r,className:Th(`lucide-${$y(wh(e))}`,`lucide-${e}`,n),...s}));return t.displayName=wh(e),t};const Eh=Se("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const Jy=Se("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);const Gy=Se("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Nh=Se("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);const Vy=Se("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);const Kr=Se("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);const Ur=Se("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);const Yy=Se("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const Xy=Se("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);const Zy=Se("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const Qy=Se("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);const ex=Se("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Ch=Se("repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);const Bi=Se("shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]]);const rx=Se("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const tx=Se("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const nx=Se("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),ax={business:["business"],standard:["business","control"],developer:["business","control","data"]},Xe=[{type:"SIMPLE",label:"任务节点 (Worker)",description:"在远程 Worker 上执行的任务",category:"CORE",icon:Eh,viewCategory:"business"},{type:"SUB_WORKFLOW",label:"子工作流 (Sub Workflow)",description:"调用并执行另一个工作流",category:"CORE",icon:Ur,viewCategory:"business"},{type:"START_WORKFLOW",label:"启动工作流 (Start Workflow)",description:"启动另一个工作流(不等待结果)",category:"SYSTEM",icon:Qy,viewCategory:"business"},{type:"HTTP",label:"HTTP 请求",description:"发起 REST/HTTP 调用",category:"SYSTEM",icon:Yy,viewCategory:"business"},{type:"INLINE",label:"内联脚本 (Inline)",description:"执行内联脚本(JS/Python/GraalJS)",category:"SYSTEM",icon:Nh,viewCategory:"data"},{type:"JSON_JQ_TRANSFORM",label:"JSON 转换 (JQ)",description:"使用 JQ 表达式转换 JSON 数据",category:"SYSTEM",icon:rx,viewCategory:"data"},{type:"KAFKA_PUBLISH",label:"Kafka 推送",description:"向 Kafka 主题推送消息",category:"SYSTEM",icon:Xy,viewCategory:"data"},{type:"EVENT",label:"事件 (Event)",description:"向外部队列系统发布事件",category:"SYSTEM",icon:nx,viewCategory:"data"},{type:"WAIT",label:"等待 (Wait)",description:"暂停流程,直到特定时间或时长",category:"SYSTEM",icon:Gy,viewCategory:"control"},{type:"SET_VARIABLE",label:"设置变量 (Set Variable)",description:"设置工作流上下文变量",category:"SYSTEM",icon:Vy,viewCategory:"data"},{type:"TERMINATE",label:"终止 (Terminate)",description:"提前结束工作流执行",category:"SYSTEM",icon:Jy,viewCategory:"control"},{type:"HUMAN",label:"人工审批 (Human)",description:"等待人工审核或表单提交",category:"SYSTEM",icon:tx,viewCategory:"business"},{type:"DYNAMIC",label:"动态任务 (Dynamic)",description:"运行时动态决定任务类型",category:"SYSTEM",icon:Bi,viewCategory:"data"},{type:"NOOP",label:"空操作 (Noop)",description:"占位符任务,无实际操作",category:"SYSTEM",icon:Zy,viewCategory:"data"},{type:"LAMBDA",label:"Lambda 脚本 (旧)",description:"已被 INLINE 取代",category:"SYSTEM",icon:Nh,hidden:!0,viewCategory:"data"},{type:"SWITCH",label:"条件分支 (Switch)",description:"基于条件的逻辑分支 (Switch/Case)",category:"FLOW",icon:Bi,viewCategory:"control"},{type:"DECISION",label:"判断 (Decision,旧)",description:"基于条件的逻辑分支(旧版,推荐改用 Switch)",category:"FLOW",icon:Bi,hidden:!0,viewCategory:"control"},{type:"FORK_JOIN",label:"静态并行 (Fork)",description:"并行执行多个预定义任务分支",category:"FLOW",icon:Kr,viewCategory:"control"},{type:"FORK_JOIN_DYNAMIC",label:"动态并行 (Dynamic Fork)",description:"运行时动态生成并行分支",category:"FLOW",icon:Kr,viewCategory:"control"},{type:"DO_WHILE",label:"循环 (Do-While)",description:"循环执行直到满足条件",category:"FLOW",icon:Ch,viewCategory:"control"},{type:"JOIN",label:"汇聚 (Join)",description:"等待所有并行分支执行完成",category:"FLOW",icon:Ur,viewCategory:"control"}],sx=[{key:"CORE",label:"基础任务"},{key:"FLOW",label:"逻辑控制"},{key:"SYSTEM",label:"系统集成"}],Jr=({message:e,onConfirm:r,onCancel:t})=>{const n=P.useRef(null),{theme:s,themeColor:a}=ie();return P.useEffect(()=>{n.current?.focus({preventScroll:!0});const o=i=>{i.key==="Escape"&&t()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[t]),Yr.createPortal(l.jsx("div",{"data-mode":s,"data-brand":a,onClick:t,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:l.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"确认操作",onClick:o=>o.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"24px 28px",maxWidth:"380px",width:"90%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.18)"},children:[l.jsx("div",{style:{fontSize:"14px",color:"var(--text-primary)",marginBottom:"24px",lineHeight:"1.6"},children:e}),l.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[l.jsx("button",{ref:n,onClick:t,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:"取消"}),l.jsx("button",{onClick:r,style:{padding:"7px 18px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"6px",color:"#ffffff",cursor:"pointer",fontSize:"13px",fontWeight:600},children:"确定"})]})]})}),document.body)},br=({children:e,nodeId:r,selected:t=!1,isStartOrEnd:n=!1,isError:s=!1,hasWarning:a=!1,isDecision:o=!1,isHighlighted:i=!1,executionStatus:d,simRunning:c=!1,simDone:u=!1})=>{const{mode:f,removeNode:p}=ie(),[h,g]=P.useState(!1),m=k=>{k.stopPropagation(),g(!0)},v=f==="edit"&&!n,x=[o?"decision-node-wrapper":"node-wrapper-glass",t?"node-wrapper-selected":"",i?"node-wrapper-highlighted":"",c?"node-sim-running":"",u?"node-sim-done":""].filter(Boolean).join(" "),b=P.useMemo(()=>{if(f!=="run")return{};if(!d)return{opacity:.4};switch(d){case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":return{borderColor:"var(--status-failed)",boxShadow:"0 0 12px rgba(239, 68, 68, 0.5), 0 0 24px rgba(239, 68, 68, 0.2)"};case"TIMED_OUT":return{borderColor:"var(--status-timed-out)",boxShadow:"0 0 8px rgba(249, 115, 22, 0.4)"};case"IN_PROGRESS":case"SCHEDULED":return{borderColor:"var(--status-in-progress)",animation:"status-pulse 1.5s ease-in-out infinite"};case"COMPLETED":return{borderColor:"var(--status-completed)",opacity:.85};case"COMPLETED_WITH_ERRORS":return{borderColor:"var(--status-completed-with-errors)"};case"SKIPPED":case"CANCELED":return{opacity:.5};default:return{}}},[f,d]);return l.jsxs("div",{className:x,style:{position:"relative",...b},children:[v&&l.jsx("button",{onClick:m,"aria-label":"删除任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},title:"删除任务",children:"×"}),s&&l.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},title:"此节点配置有误",children:"❗"}),!s&&a&&l.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#f59e0b",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},title:"此节点有警告信息",children:"⚠️"}),e,h&&l.jsx(Jr,{message:"确定要删除此任务吗?",onConfirm:()=>{p(r),g(!1)},onCancel:()=>g(!1)})]})},ox=({status:e})=>{const r=()=>{switch(e){case"SCHEDULED":return{icon:"○",className:"scheduled"};case"IN_PROGRESS":return{icon:"◐",className:"in-progress"};case"COMPLETED":return{icon:"✓",className:"completed"};case"COMPLETED_WITH_ERRORS":return{icon:"⚠",className:"completed-with-errors"};case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":return{icon:"✗",className:"failed"};case"TIMED_OUT":return{icon:"⏱",className:"timed-out"};case"SKIPPED":return{icon:"⤳",className:"skipped"};case"CANCELED":return{icon:"⊘",className:"canceled"};default:return{icon:"?",className:"unknown"}}},{icon:t,className:n}=r();return l.jsx("div",{className:`execution-status-badge ${n}`,title:e,children:l.jsx("span",{className:"badge-icon",children:t})})},jh=P.memo(ox),ix=({icon:e,header:r,title:t,meta:n,color:s,status:a,isRunning:o,children:i,width:d="240px",border:c=!0})=>l.jsxs("div",{style:{display:"flex",flexDirection:"row",width:d,height:"100%",position:"relative",overflow:"hidden",border:c?"4px solid var(--border-primary)":"none",borderRadius:"8px"},children:[l.jsx("div",{style:{width:"48px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(205, 74, 74, 0.03)",borderRight:"1px solid var(--color-accent)",color:s},children:l.jsx(e,{size:20,strokeWidth:1.5})}),l.jsxs("div",{style:{flex:1,padding:"10px 14px",display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden"},children:[l.jsx("div",{style:{fontSize:"14px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.7,marginBottom:"4px",color:s},children:r}),l.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"2px"},title:t,children:t}),n&&l.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)",fontStyle:"italic",lineHeight:"1.4",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:n,children:n}),i&&l.jsx("div",{style:{marginTop:"8px"},children:i})]}),o&&a&&l.jsx("div",{style:{position:"absolute",top:"8px",right:"8px"},children:l.jsx(jh,{status:a})})]}),Gr=P.memo(ix),Ze=e=>{const r=e.layoutDirection||"TB",t=e.sourcePosition||(r==="LR"?A.Position.Right:A.Position.Bottom),n=e.targetPosition||(r==="LR"?A.Position.Left:A.Position.Top);return{layoutDirection:r,sourcePosition:t,targetPosition:n}},lr=e=>{const{mode:r,executionData:t}=ie(),n=r==="run"?t?.[e]:null,s=r==="run",a=n?.attempts.some(d=>d.iteration!==void 0&&d.iteration>1)??!1,o=n?.attempts[n.attempts.length-1],i=a?0:o?.retryCount??0;return{mode:r,execution:n,isRunning:s,retryCount:i}};function He(e,r){return e.length>r?e.slice(0,r)+"…":e}function kr(e,r,t,n){if(t==="business")return r.task?.description?.trim()||n;if(t==="standard")return n;const s=r.task;if(!s)return n;const a=s.inputParameters||{};switch(e){case"HTTP":case"HTTP_POLL":{const o=s.httpRequest||a.http_request;if(!o)return n;const i=(o.method||"GET").toUpperCase(),d=o.uri?He(String(o.uri),28):"";return d?`${i} ${d}`:i}case"SWITCH":{const o=s.caseExpression||a.expression,i=s.evaluatorType||a.evaluatorType;return o?He(o,35):i||n}case"DECISION":return s.caseValueParam?`param: ${s.caseValueParam}`:n;case"SIMPLE":return s.name?`worker: ${He(s.name,28)}`:n;case"INLINE":case"LAMBDA":{const o=s.evaluatorType||a.evaluatorType;return o?`${o} script`:n}case"SUB_WORKFLOW":{const o=s.subWorkflowParam;return o?`${o.name}${o.version?` v${o.version}`:""}`:n}case"DO_WHILE":{const o=s.loopCondition;return o?He(o,35):n}case"JSON_JQ_TRANSFORM":{const o=a.queryExpression||a.query_expression;return o?He(o,35):n}case"SET_VARIABLE":{const o=Object.keys(a);return o.length?`set: ${o.slice(0,2).join(", ")}${o.length>2?"…":""}`:n}case"EVENT":{const o=s.sink||a.sink;return o?`→ ${He(o,32)}`:n}case"KAFKA_PUBLISH":{const o=a.topic||a.kafka_request?.topic;return o?`topic: ${He(o,28)}`:n}case"START_WORKFLOW":{const o=s.startWorkflow?.name??a.startWorkflow?.name??a.start_workflow?.name;return o?`→ ${o}`:n}default:return n}}const lx=({id:e,data:r,selected:t})=>{const n=r.taskType||"SIMPLE",{sourcePosition:s,targetPosition:a}=Ze(r),{execution:o,isRunning:i,retryCount:d}=lr(r.taskReferenceName),c=ie(v=>v.viewMode),u=P.useMemo(()=>Xe.find(v=>v.type===n),[n]),f=u?.icon||Eh,p=n==="NOOP",h=r.isDynamicRuntime===!0,g=p?"var(--text-secondary)":"var(--color-accent)",m=P.useMemo(()=>{let v;return h?v=`Dynamic (${n})`:n==="SIMPLE"?v=r.label==="Worker Task"?"Execute on Worker":"Worker Task":n==="HTTP"?v="REST API Call":n==="JSON_JQ_TRANSFORM"?v="JQ Expression":n==="INLINE"||n==="LAMBDA"?v="Inline Script":n==="START_WORKFLOW"?v="Launch Workflow (no wait)":n==="DYNAMIC"?v="Dynamic Task Type":n==="HUMAN"?v="Human Approval":n==="NOOP"?v="No Operation":v=u?.label||n,kr(n,r,c,v)},[n,u,r,c,h]);return l.jsx(br,{nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,isHighlighted:r.isHighlighted,executionStatus:o?.status,simRunning:r.simRunning,simDone:r.simDone,children:l.jsxs("div",{style:{borderRadius:"8px",background:p?"var(--bg-tertiary)":"var(--bg-secondary)",opacity:p?.7:1,position:"relative",outline:h?"2px dashed var(--color-accent)":"none",outlineOffset:"-2px"},children:[l.jsx(Gr,{icon:f,header:n,title:r.taskReferenceName,meta:m,color:g,status:o?.status,isRunning:i}),i&&d>0&&l.jsxs("div",{style:{position:"absolute",bottom:"4px",right:"4px",background:"var(--status-failed, #ef4444)",color:"#fff",borderRadius:"10px",fontSize:"10px",fontWeight:"700",padding:"1px 6px",zIndex:10,lineHeight:"1.4",pointerEvents:"none"},children:["×",d]}),h&&l.jsx("div",{style:{position:"absolute",top:"4px",right:"4px",background:"var(--color-accent)",color:"#fff",borderRadius:"4px",fontSize:"9px",fontWeight:"700",padding:"1px 5px",zIndex:10,pointerEvents:"none",opacity:.9},children:"动态"}),l.jsx(A.Handle,{type:"target",position:a,style:{background:"#fff"}}),l.jsx(A.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})},cx=P.memo(lx),Ih=({title:e,label:r,defaultValue:t="",placeholder:n="",confirmText:s="确定",cancelText:a="取消",onConfirm:o,onCancel:i})=>{const{theme:d,themeColor:c}=ie(),[u,f]=P.useState(t),p=P.useRef(null);P.useEffect(()=>{p.current&&(p.current.focus({preventScroll:!0}),p.current.select());const g=m=>{m.key==="Escape"&&(m.stopPropagation(),i())};return window.addEventListener("keydown",g,!0),()=>window.removeEventListener("keydown",g,!0)},[i]);const h=()=>{const g=u.trim();g&&o(g)};return Yr.createPortal(l.jsx("div",{"data-mode":d,"data-brand":c,onClick:i,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:l.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e,onClick:g=>g.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"10px",padding:"24px 28px",maxWidth:"400px",width:"90%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.22)"},children:[l.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"var(--text-primary)",marginBottom:"16px"},children:e}),r&&l.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px"},children:r}),l.jsx("input",{ref:p,type:"text",value:u,placeholder:n,onChange:g=>f(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),h()),g.stopPropagation()},style:{width:"100%",padding:"9px 12px",borderRadius:"6px",border:"1px solid var(--border-primary)",background:"var(--bg-tertiary)",color:"var(--text-primary)",fontSize:"13px",outline:"none",boxSizing:"border-box",marginBottom:"20px",transition:"border-color 0.15s"},onFocus:g=>{g.currentTarget.style.borderColor="var(--color-accent)"},onBlur:g=>{g.currentTarget.style.borderColor="var(--border-primary)"}}),l.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[l.jsx("button",{onClick:i,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:a}),l.jsx("button",{onClick:h,disabled:!u.trim(),style:{padding:"7px 18px",backgroundColor:u.trim()?"var(--color-accent)":"var(--bg-tertiary)",border:"none",borderRadius:"6px",color:u.trim()?"#ffffff":"var(--text-secondary)",cursor:u.trim()?"pointer":"not-allowed",fontSize:"13px",fontWeight:600,transition:"background-color 0.15s, color 0.15s"},children:s})]})]})}),document.body)},ux=({id:e,data:r,selected:t})=>{const{layoutDirection:n}=Ze(r),{mode:s,execution:a,isRunning:o}=lr(r.taskReferenceName),{addDecisionBranch:i,removeDecisionBranch:d,renameDecisionBranch:c,viewMode:u}=ie(),[f,p]=P.useState(!1),[h,g]=P.useState({type:"none"}),m=n==="LR"?A.Position.Left:A.Position.Top,v=Object.keys(r.decisionCases||r.task?.decisionCases||{}),y=()=>{p(!1),g({type:"add"})},x=(C,S)=>{C.stopPropagation(),g({type:"delete",branch:S})},b=(C,S)=>{C.stopPropagation(),p(!1),g({type:"rename",branch:S})},k=C=>{C&&i(e,C),g({type:"none"})},w=C=>{h.type==="rename"&&(C&&C!==h.branch&&c(e,h.branch,C),g({type:"none"}))},j=()=>{h.type==="delete"&&(d(e,h.branch),g({type:"none"}))},N=()=>g({type:"none"}),T=o?(C=>C&&{SCHEDULED:"execution-node-scheduled",IN_PROGRESS:"execution-node-in-progress",COMPLETED:"execution-node-completed",COMPLETED_WITH_ERRORS:"execution-node-completed-with-errors",FAILED:"execution-node-failed",FAILED_WITH_TERMINAL_ERROR:"execution-node-failed-terminal",TIMED_OUT:"execution-node-timed-out",SKIPPED:"execution-node-skipped",CANCELED:"execution-node-canceled"}[C]||"")(a?.status):"";return l.jsxs(br,{nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,isDecision:!0,isHighlighted:r.isHighlighted,executionStatus:a?.status,simRunning:r.simRunning,simDone:r.simDone,children:[l.jsxs("div",{style:{position:"relative"},children:[l.jsx(A.Handle,{type:"target",position:m,style:{background:"#fff",[n==="LR"?"left":"top"]:"-5px"}}),o&&a?.status&&l.jsx("div",{style:{position:"absolute",top:0,right:0,zIndex:20},children:l.jsx(jh,{status:a.status})}),l.jsx("div",{className:T,style:{width:"150px",height:"150px",background:o&&a?.status?void 0:"var(--bg-secondary)",border:t?"4px solid #fbbf24":o&&a?.status?void 0:"4px solid var(--border-primary)",transform:"rotate(45deg)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:t?"0 10px 30px rgba(0,0,0,0.3), 0 0 0 4px rgba(251, 191, 36, 0.3)":o&&a?.status?void 0:"0 4px 12px rgba(0,0,0,0.15)",transition:"all 0.3s ease",cursor:"pointer"},onClick:()=>s==="edit"&&p(!f),children:l.jsxs("div",{style:{transform:"rotate(-45deg)",color:"#fff",textAlign:"center",padding:"10px",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[l.jsx("div",{style:{fontSize:"14px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.7,marginBottom:"4px",color:"var(--color-accent)"},children:r.taskType}),l.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)",lineHeight:"1.2",wordBreak:"break-word",maxHeight:"60px",overflow:"hidden",marginBottom:"4px"},children:r.label}),s==="edit"&&l.jsx("div",{style:{marginTop:"4px",width:"24px",height:"24px",fontSize:"16px",background:"rgba(255,255,255,0.1)",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:"4px auto 0",color:"var(--text-secondary)"},children:"+"}),o&&a?.startTime&&l.jsx("div",{style:{fontSize:"9px",opacity:.7,marginTop:"8px"},children:a.endTime?`${((a.endTime-a.startTime)/1e3).toFixed(1)}s`:"◌"})]})}),s==="edit"&&f&&l.jsxs("div",{className:"glass-panel",style:{position:"absolute",top:"160px",left:"50%",transform:"translateX(-50%)",backgroundColor:"var(--glass-surface)",border:"1px solid var(--glass-border)",borderRadius:"8px",padding:"8px",zIndex:1e3,minWidth:"200px",boxShadow:"0 10px 25px rgba(0,0,0,0.5)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",backdropFilter:"blur(12px)"},children:[l.jsx("div",{style:{padding:"4px 8px 6px",fontSize:"11px",color:"var(--text-secondary)",borderBottom:"1px solid var(--glass-border)",marginBottom:"4px",fontWeight:600,letterSpacing:"0.05em"},children:"分支管理"}),v.map(C=>l.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"5px 6px",borderRadius:"4px",gap:"4px"},children:[l.jsx("span",{style:{flex:1,fontSize:"12px",color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:C}),l.jsx("button",{onClick:S=>b(S,C),style:{width:"22px",height:"22px",borderRadius:"4px",backgroundColor:"var(--color-accent)",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",padding:0,flexShrink:0,opacity:.85},title:`重命名分支 "${C}"`,children:"✏"}),l.jsx("button",{onClick:S=>x(S,C),style:{width:"22px",height:"22px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",padding:0,flexShrink:0,opacity:.9},title:`删除分支 "${C}"`,children:"×"})]},C)),l.jsx("button",{onClick:y,style:{width:"100%",marginTop:"6px",padding:"8px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"4px",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:"bold"},children:"+ 添加新分支"})]}),u==="developer"&&(()=>{const C=r.task?.caseExpression||r.task?.inputParameters?.expression,S=r.task?.caseValueParam;return!C&&!S?null:l.jsx("div",{style:{position:"absolute",top:"158px",left:"50%",transform:"translateX(-50%)",textAlign:"center",fontSize:10,color:"var(--text-secondary)",maxWidth:140,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",fontFamily:"var(--font-mono, monospace)"},children:C?He(C,22):`param: ${S}`})})(),n==="TB"?l.jsxs(l.Fragment,{children:[l.jsx(A.Handle,{type:"source",position:A.Position.Bottom,style:{background:"#fff",bottom:"-5px"}}),l.jsx(A.Handle,{type:"source",position:A.Position.Left,id:"left",style:{background:"#fff",left:"-5px"}}),l.jsx(A.Handle,{type:"source",position:A.Position.Right,id:"right",style:{background:"#fff",right:"-5px"}})]}):l.jsxs(l.Fragment,{children:[l.jsx(A.Handle,{type:"source",position:A.Position.Right,style:{background:"#fff",right:"-5px"}}),l.jsx(A.Handle,{type:"source",position:A.Position.Top,id:"top",style:{background:"#fff",top:"-5px"}}),l.jsx(A.Handle,{type:"source",position:A.Position.Bottom,id:"bottom",style:{background:"#fff",bottom:"-5px"}})]})]}),h.type==="add"&&l.jsx(Ih,{title:"添加新分支",label:"分支条件值(Case Value)",defaultValue:`case_${v.length+1}`,placeholder:"例如:approved、rejected、pending",confirmText:"添加",onConfirm:k,onCancel:N}),h.type==="rename"&&l.jsx(Ih,{title:"重命名分支",label:`当前名称:${h.branch}`,defaultValue:h.branch,placeholder:"输入新的分支条件值",confirmText:"重命名",onConfirm:w,onCancel:N}),h.type==="delete"&&l.jsx(Jr,{message:`确定要删除分支 "${h.branch}" 及其下的所有任务吗?此操作不可撤销。`,onConfirm:j,onCancel:N})]})},dx=P.memo(ux),Rh="var(--color-accent)",Oh=P.memo(({id:e,data:r,selected:t})=>{const{layoutDirection:n,sourcePosition:s,targetPosition:a}=Ze(r),{mode:o,execution:i,isRunning:d}=lr(r.taskReferenceName),{addForkBranch:c}=ie(),u=A.useUpdateNodeInternals(),f=r.task?.forkTasks?.length||0;P.useEffect(()=>{u(e)},[f,e,u]);const p=r.isDynamic||r.taskType==="FORK_JOIN_DYNAMIC",h=ie(v=>v.viewMode),m=P.useMemo(()=>Xe.find(v=>v.type==="FORK_JOIN"),[])?.icon||Kr;return l.jsx(br,{isHighlighted:r.isHighlighted,nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,executionStatus:i?.status,simRunning:r.simRunning,simDone:r.simDone,children:l.jsxs("div",{className:`fork-node ${p?"dynamic":"static"}`,style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[l.jsx(Gr,{icon:m,header:p?"DYNAMIC FORK":"FORK",title:r.taskReferenceName,meta:kr(r.taskType,r,h,p?"Dynamic Parallel Execution":"Parallel Execution"),color:Rh,status:i?.status,isRunning:d}),o==="edit"&&!p&&l.jsx("div",{style:{position:"absolute",...n==="LR"?{top:"50%",right:-12,transform:"translateY(-50%)"}:{bottom:-12,left:"50%",transform:"translateX(-50%)"},width:20,height:20,background:"var(--color-accent)",borderRadius:"50%",color:"#fff",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:1e3,boxShadow:"0 2px 5px rgba(0,0,0,0.2)",border:"2px solid var(--bg-primary)"},onClick:v=>{v.stopPropagation(),c(e)},title:"添加分支",children:"+"}),l.jsx(A.Handle,{type:"target",position:a,style:{background:"#fff"}}),!p&&(r.task?.forkTasks||[]).map((v,y,x)=>{if(o!=="edit"&&(!v||v.length===0))return null;const b=o!=="edit"?x.filter(N=>N&&N.length>0):x,k=b.length,j=(b.indexOf(v)+1)/(k+1)*100;return l.jsx(A.Handle,{id:`branch_${y}`,type:"source",position:s,style:{background:"#fff",[n==="LR"?"top":"left"]:`${j}%`,[n==="LR"?"left":"top"]:void 0,[n==="LR"?"right":"bottom"]:"-4px",zIndex:10}},`branch_${y}`)}),!p&&(!r.task?.forkTasks||r.task.forkTasks.length===0)&&l.jsx(A.Handle,{type:"source",position:s,style:{background:"#fff"}}),p&&l.jsx(A.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})});Oh.displayName="ForkNode";const Ph=P.memo(({id:e,data:r,selected:t})=>{const{layoutDirection:n,sourcePosition:s,targetPosition:a}=Ze(r),{execution:o,isRunning:i}=lr(r.taskReferenceName),d=ie(f=>f.viewMode),u=P.useMemo(()=>Xe.find(f=>f.type==="JOIN"),[])?.icon||Ur;return l.jsx(br,{isHighlighted:r.isHighlighted,nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,executionStatus:o?.status,simRunning:r.simRunning,simDone:r.simDone,children:l.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[l.jsx(Gr,{icon:u,header:r.taskType==="EXCLUSIVE_JOIN"?"EXCLUSIVE JOIN":"JOIN",title:r.taskReferenceName,meta:kr(r.taskType,r,d,r.taskType==="EXCLUSIVE_JOIN"?"Wait for any task":"Wait for tasks"),color:Rh,status:o?.status,isRunning:i}),l.jsx(A.Handle,{type:"target",position:a,style:{background:"#fff"}}),n==="TB"&&l.jsxs(l.Fragment,{children:[l.jsx(A.Handle,{type:"target",position:A.Position.Left,id:"left",style:{background:"#fff"}}),l.jsx(A.Handle,{type:"target",position:A.Position.Right,id:"right",style:{background:"#fff"}})]}),n==="LR"&&l.jsxs(l.Fragment,{children:[l.jsx(A.Handle,{type:"target",position:A.Position.Top,id:"top",style:{background:"#fff"}}),l.jsx(A.Handle,{type:"target",position:A.Position.Bottom,id:"bottom",style:{background:"#fff"}})]}),l.jsx(A.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})});Ph.displayName="JoinNode";const Ah={ForkNode:Oh,JoinNode:Ph},fx=({id:e,data:r,selected:t})=>{const{sourcePosition:n,targetPosition:s}=Ze(r),{execution:a,isRunning:o}=lr(r.taskReferenceName),{executionData:i,selectTaskAction:d,mode:c,viewMode:u,removeNode:f}=ie(),[p,h]=P.useState(!1),g=r.task,m=g?.loopOver||[],y=P.useMemo(()=>Xe.find(T=>T.type==="DO_WHILE"),[])?.icon||Ch,x=P.useMemo(()=>{if(!o||!i||m.length===0)return 0;let T=0;return m.forEach(C=>{const S=i[C.taskReferenceName];S?.totalIterations?T=Math.max(T,S.totalIterations):S?.attempts.some(q=>(q.iteration??0)>0)&&(T=Math.max(T,S.attempts.length))}),T},[o,i,m]),b=r.loopCondition||g?.loopCondition||"",k=P.useMemo(()=>{const T=b?b.length>35?b.slice(0,35)+"…":b:"循环直到条件满足";return kr("DO_WHILE",r,u,T)},[r,u,b]),w=a?.status==="COMPLETED"?"var(--status-completed)":a?.status==="FAILED"||a?.status==="FAILED_WITH_TERMINAL_ERROR"?"var(--status-failed)":a?.status==="IN_PROGRESS"||a?.status==="SCHEDULED"?"var(--status-in-progress)":"var(--color-accent)",j=t?`2px solid ${w}`:`1.5px dashed ${o&&a?.status?w:"var(--color-accent)"}`,N=c==="edit",L=u==="developer"&&b;return l.jsxs("div",{style:{width:"100%",height:"100%",border:j,borderRadius:"10px",background:"transparent",display:"flex",flexDirection:"column",position:"relative",overflow:"visible",boxSizing:"border-box",pointerEvents:"none"},children:[N&&l.jsx("button",{onClick:T=>{T.stopPropagation(),h(!0)},"aria-label":"删除循环任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",padding:0,pointerEvents:"auto"},title:"删除循环任务",children:"×"}),r.isError&&l.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点配置有误",children:"❗"}),!r.isError&&r.hasWarning&&l.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#f59e0b",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点有警告信息",children:"⚠️"}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"8px 12px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",borderRadius:"8px 8px 0 0",flexShrink:0,minHeight:"42px",pointerEvents:"auto"},children:[l.jsx("div",{style:{color:"var(--color-accent)",display:"flex",alignItems:"center",flexShrink:0},children:l.jsx(y,{size:14})}),l.jsxs("div",{style:{flex:1,minWidth:0},children:[l.jsx("div",{style:{fontSize:"9px",fontWeight:700,color:"var(--color-accent)",letterSpacing:"0.08em",textTransform:"uppercase"},children:"DO WHILE"}),l.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.taskReferenceName}),(u==="business"||u==="developer")&&k&&l.jsx("div",{style:{fontSize:"9px",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"1px",fontStyle:"italic"},children:k})]}),o&&x>0&&l.jsxs("div",{onClick:()=>d(g||null),style:{padding:"2px 8px",borderRadius:"12px",background:"var(--color-accent)",color:"#fff",fontSize:"10px",fontWeight:700,cursor:"pointer",flexShrink:0},children:["×",x]}),o&&a?.status&&l.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:w,flexShrink:0}})]}),L&&l.jsxs("div",{style:{padding:"3px 12px",fontSize:"9px",color:"var(--text-secondary)",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:0,pointerEvents:"auto"},children:["until: ",b]}),l.jsx("div",{style:{flex:1,position:"relative",background:"var(--loop-body-bg, rgba(99,102,241,0.04))",borderRadius:"0 0 8px 8px",pointerEvents:"none"}}),l.jsx(A.Handle,{type:"target",position:s,style:{background:"var(--color-accent)",zIndex:10}}),l.jsx(A.Handle,{type:"source",position:n,style:{background:"var(--color-accent)",zIndex:10}}),p&&l.jsx(Jr,{message:"确定要删除此循环任务吗?循环体内的任务也会一并删除。",onConfirm:()=>{f(e),h(!1)},onCancel:()=>h(!1)})]})},px=P.memo(fx),hx="var(--color-accent)",gx=({id:e,data:r,selected:t})=>{const{sourcePosition:n,targetPosition:s}=Ze(r),{execution:a,isRunning:o}=lr(r.taskReferenceName),i=ie(p=>p.viewMode),c=P.useMemo(()=>Xe.find(p=>p.type==="SUB_WORKFLOW"),[])?.icon||Ur,u=r.task?.subWorkflowParam?.name||r.subWorkflowName||"Unknown",f=r.task?.subWorkflowParam?.version;return l.jsx(br,{nodeId:e,selected:t,isError:r.isError,hasWarning:r.hasWarning,isHighlighted:r.isHighlighted,executionStatus:a?.status,simRunning:r.simRunning,simDone:r.simDone,children:l.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[l.jsx(Gr,{icon:c,header:"SUB WORKFLOW",title:r.taskReferenceName,meta:kr("SUB_WORKFLOW",r,i,`Flow: ${u} (v${f})`),color:hx,status:a?.status,isRunning:o}),l.jsx(A.Handle,{type:"target",position:s,style:{background:"#fff"}}),l.jsx(A.Handle,{type:"source",position:n,style:{background:"#fff"}})]})})},mx=P.memo(gx),vx=({data:e})=>{const t=(e.layoutDirection||"TB")==="LR";return l.jsxs("div",{className:"plus-node-container",style:{width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"var(--bg-secondary, #1e293b)",border:"2px dashed var(--color-accent, #3b82f6)",color:"var(--color-accent, #3b82f6)",cursor:"pointer",transition:"all 0.2s ease",padding:e.label&&e.label!=="+"?"0 12px":"0",minWidth:e.label&&e.label!=="+"?"80px":"32px",gap:"4px"},children:[l.jsx(ex,{size:16}),e.label&&e.label!=="+"&&l.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:e.label}),l.jsx(A.Handle,{type:"target",position:t?A.Position.Left:A.Position.Top,style:{opacity:0}}),l.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
12
|
+
execute($.input);`}):d.type==="DYNAMIC"?(d.dynamicTaskNameParam="taskToExecute",d.inputParameters={taskToExecute:"${workflow.input.taskName}"}):d.type==="HUMAN"?d.humanTaskDef={userFormTemplate:"",assignmentCompletionStrategy:"LEAVE_OPEN"}:d.type==="START_WORKFLOW"?d.inputParameters={startWorkflow:{name:"",version:1,input:{},correlationId:""}}:d.type==="NOOP"&&(d.inputParameters={}),o.isWorkflowStart)c.tasks.unshift(d);else if(o.isLoopBodyStart){const y=je(c.tasks,t);y&&(y.loopOver||(y.loopOver=[]),y.loopOver.unshift(d))}else o.branchCase!==void 0||o.forkIndex!==void 0||o.isLoopAdd?or(c.tasks,t,o,d):c.tasks.length===0?c.tasks.push(d):Le(c.tasks,t,d);Ee(c.tasks);const{nodes:f,edges:p,taskMap:h}=Te(c,u,{hideEmptyBranches:n().mode!=="edit"}),{nodes:g,edges:m}=Se(f,p,{direction:u,mode:n().mode}),v=Oe(c);e({workflowDef:c,nodes:g,edges:m,taskMap:h,validationResults:v})},removeNode:r=>{const{workflowDef:t,layoutDirection:s,nodes:a}=n();if(!t)return;const o=JSON.parse(JSON.stringify(t)),i=sr(o.tasks,r);if(i){const g=a.find(m=>m.id===r)?.data?.taskType;if(g==="FORK_JOIN"||g==="FORK_JOIN_DYNAMIC"){const m=Eh(i,r);m&&We(o.tasks,m)}else if(g==="JOIN"||g==="EXCLUSIVE_JOIN"){const m=Nh(i,r);m&&We(o.tasks,m)}}We(o.tasks,r),Ee(o.tasks);const{nodes:u,edges:c,taskMap:d}=Te(o,s,{hideEmptyBranches:n().mode!=="edit"}),{nodes:f,edges:p}=Se(u,c,{direction:s,mode:n().mode}),h=Oe(o);e({workflowDef:o,nodes:f,edges:p,taskMap:d,validationResults:h})},addLoopTask:(r,t)=>{const{workflowDef:s,layoutDirection:a}=n();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=je(o.tasks,r);if(i&&i.type==="DO_WHILE"){i.loopOver||(i.loopOver=[]);const u={name:`new_${t.toLowerCase()}`,taskReferenceName:`${r}_sub_${Date.now()}`,type:t,inputParameters:{}};i.loopOver.push(u),Ee(o.tasks);const{nodes:c,edges:d,taskMap:f}=Te(o,a,{hideEmptyBranches:n().mode!=="edit"}),{nodes:p,edges:h}=Se(c,d,{direction:a,mode:n().mode}),g=Oe(o);e({workflowDef:o,nodes:p,edges:h,taskMap:f,validationResults:g})}},removeLoopTask:(r,t)=>{const{workflowDef:s,layoutDirection:a}=n();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=je(o.tasks,r);if(i&&i.type==="DO_WHILE"&&i.loopOver){const u=sr(i.loopOver,t);if(u){const m=u.find(v=>v.taskReferenceName===t);if(m?.type==="FORK_JOIN"||m?.type==="FORK_JOIN_DYNAMIC"){const v=Eh(u,t);v&&We(i.loopOver,v)}else if(m?.type==="JOIN"||m?.type==="EXCLUSIVE_JOIN"){const v=Nh(u,t);v&&We(i.loopOver,v)}}We(i.loopOver,t),Ee(o.tasks);const{nodes:c,edges:d,taskMap:f}=Te(o,a,{hideEmptyBranches:n().mode!=="edit"}),{nodes:p,edges:h}=Se(c,d,{direction:a,mode:n().mode}),g=Oe(o);e({workflowDef:o,nodes:p,edges:h,taskMap:f,validationResults:g})}},addDecisionBranch:(r,t)=>{const{workflowDef:s,layoutDirection:a}=n();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=je(o.tasks,r);if(i&&(i.type==="DECISION"||i.type==="SWITCH")){t==="default"?i.defaultCase||(i.defaultCase=[]):(i.decisionCases||(i.decisionCases={}),i.decisionCases[t]||(i.decisionCases[t]=[])),Ee(o.tasks);const{nodes:u,edges:c,taskMap:d}=Te(o,a,{hideEmptyBranches:n().mode!=="edit"}),{nodes:f,edges:p}=Se(u,c,{direction:a,mode:n().mode}),h=Oe(o);e({workflowDef:o,nodes:f,edges:p,taskMap:d,validationResults:h})}},removeDecisionBranch:(r,t)=>{const{workflowDef:s,layoutDirection:a}=n();if(!s)return;const o=JSON.parse(JSON.stringify(s)),i=je(o.tasks,r);if(i&&(i.type==="DECISION"||i.type==="SWITCH")){t==="default"?i.defaultCase=[]:i.decisionCases&&delete i.decisionCases[t],Ee(o.tasks);const{nodes:u,edges:c,taskMap:d}=Te(o,a,{hideEmptyBranches:n().mode!=="edit"}),{nodes:f,edges:p}=Se(u,c,{direction:a,mode:n().mode}),h=Oe(o);e({workflowDef:o,nodes:f,edges:p,taskMap:d,validationResults:h})}},renameDecisionBranch:(r,t,s)=>{const{workflowDef:a,layoutDirection:o}=n();if(!a||!s.trim()||t===s)return;const i=JSON.parse(JSON.stringify(a)),u=je(i.tasks,r);if(u&&(u.type==="DECISION"||u.type==="SWITCH")){if(!u.decisionCases||!u.decisionCases[t])return;u.decisionCases[s.trim()]=u.decisionCases[t],delete u.decisionCases[t],Ee(i.tasks);const{nodes:c,edges:d,taskMap:f}=Te(i,o,{hideEmptyBranches:n().mode!=="edit"}),{nodes:p,edges:h}=Se(c,d,{direction:o,mode:n().mode}),g=Oe(i);e({workflowDef:i,nodes:p,edges:h,taskMap:f,validationResults:g})}},addForkBranch:r=>{const{workflowDef:t,layoutDirection:s}=n();if(!t)return;const a=JSON.parse(JSON.stringify(t)),o=je(a.tasks,r);if(o&&o.type==="FORK_JOIN"){o.forkTasks||(o.forkTasks=[]),o.forkTasks.push([]),Ee(a.tasks);const{nodes:i,edges:u,taskMap:c}=Te(a,s,{hideEmptyBranches:n().mode!=="edit"}),{nodes:d,edges:f}=Se(i,u,{direction:s,mode:n().mode}),p=Oe(a);e({workflowDef:a,nodes:d,edges:f,taskMap:c,validationResults:p})}},copyTask:r=>e({copiedTask:r}),pasteTask:r=>{const{workflowDef:t,layoutDirection:s,selectedTask:a}=n();if(!t)return;const o=JSON.parse(JSON.stringify(t)),u=`_copy_${Date.now()}`,c=JSON.parse(JSON.stringify(r)),d=x=>{x.taskReferenceName=`${x.taskReferenceName}${u}`,x.decisionCases&&Object.values(x.decisionCases).forEach(b=>b.forEach(d)),x.defaultCase&&x.defaultCase.forEach(d),x.forkTasks&&x.forkTasks.forEach(b=>b.forEach(d)),x.loopOver&&x.loopOver.forEach(d)};d(c);const f=a?a.taskReferenceName:o.tasks.length>0?o.tasks[o.tasks.length-1].taskReferenceName:"start";if(c.type==="FORK_JOIN"){c.forkTasks||(c.forkTasks=[[],[]]);const x={name:`${c.name}_join`,taskReferenceName:`${c.taskReferenceName}_join`,type:"JOIN",joinOn:[]};o.tasks.length===0?o.tasks.push(c,x):(Le(o.tasks,f,c),Le(o.tasks,c.taskReferenceName,x))}else o.tasks.length===0?o.tasks.push(c):Le(o.tasks,f,c);Ee(o.tasks);const{nodes:p,edges:h,taskMap:g}=Te(o,s,{hideEmptyBranches:n().mode!=="edit"}),{nodes:m,edges:v}=Se(p,h,{direction:s,mode:n().mode}),y=Oe(o);e({workflowDef:o,nodes:m,edges:v,taskMap:g,validationResults:y})},flashNodes:r=>{if(r.length===0)return;const t=n().__flashTimeout;t&&clearTimeout(t);const s=new Set(r),a={};n().nodes.forEach(i=>{s.has(i.id)&&(a[i.id]=i.selected??!1)}),e(i=>({nodes:i.nodes.map(u=>s.has(u.id)?{...u,selected:!0}:u)}));const o=setTimeout(()=>{e(i=>({nodes:i.nodes.map(u=>s.has(u.id)?{...u,selected:a[u.id]??!1}:u)}))},2500);n().__flashTimeout=o},setTheme:r=>e({theme:r}),setThemeColor:r=>e({themeColor:r}),setEdgeType:r=>e({edgeType:r}),setNodesLocked:r=>e({nodesLocked:r}),setViewMode:r=>e({viewMode:r}),startSimulation:()=>{const{edges:r,nodes:t,isSimRunning:s}=n();if(s)return;const a=t.filter(f=>!["plusNode","dynamicPlaceholderNode"].includes(f.type??"")).map(f=>f.id),o=r.map(f=>({source:f.source,target:f.target})),i=Jy(a,o);e({isSimRunning:!0,simState:{}});const u={timer:null};n().__simHandle=u;let c=0;const d=()=>{if(c>=i.length||!n().isSimRunning){e({isSimRunning:!1});return}const f=i[c];e(p=>{const h={...p.simState};return f.forEach(g=>h[g]="running"),{simState:h}}),u.timer=setTimeout(()=>{n().isSimRunning&&(e(p=>{const h={...p.simState};return f.forEach(g=>h[g]="done"),{simState:h}}),c++,u.timer=setTimeout(d,280))},700)};d()},stopSimulation:()=>{const r=n().__simHandle;r?.timer&&clearTimeout(r.timer),e({isSimRunning:!1,simState:{}})},createBlankWorkflow:r=>{const t={name:r||"new_workflow",description:"",tasks:[],version:1,schemaVersion:2};n().setWorkflow(t),e({mode:"edit"})},applyAIGeneratedWorkflow:r=>{const{tasks:t,...s}=r,a={...s,name:r.name||"AI_Generated_Workflow",tasks:t||[],version:r.version||1,schemaVersion:2};n().setWorkflow(a)},setShowRunPanel:r=>e({showRunPanel:r}),setShowAnalysisPanel:r=>e({showAnalysisPanel:r}),setRunState:(r,t,s)=>{e({runState:r,pendingExecutionId:t!==void 0?t:n().pendingExecutionId,executionError:s!==void 0?s:n().executionError})},switchToEditAndFocusParam:(r,t)=>{const{workflowDef:s,layoutDirection:a,taskMap:o}=n();if(!s)return;e({mode:"edit",focusedParamKey:t??null});const{nodes:i,edges:u,taskMap:c}=Te(s,a,{hideEmptyBranches:!1}),{nodes:d,edges:f}=Se(i,u,{direction:a,mode:"edit"});e({nodes:d,edges:f,taskMap:c});const p=o[r]||c[r];p&&e({selectedTask:{...p},isDetailPanelOpen:!0,showAnalysisPanel:!1})}}),{partialize:e=>({workflowDef:e.workflowDef,layoutDirection:e.layoutDirection,nodes:e.nodes.map(n=>Object.assign({},n,{selected:!1})),edges:e.edges,taskMap:e.taskMap,theme:e.theme,themeColor:e.themeColor,mode:e.mode,edgeType:e.edgeType,nodesLocked:e.nodesLocked,copiedTask:e.copiedTask}),equality:(e,n)=>JSON.stringify(e.workflowDef)===JSON.stringify(n.workflowDef)}),{name:"conductor-ui-prefs",version:1,storage:tt(()=>localStorage),migrate:(e,n)=>(n===0&&e.edgeType==="default"&&(e.edgeType="smoothstep"),e),partialize:e=>({theme:e.theme,themeColor:e.themeColor,layoutDirection:e.layoutDirection,edgeType:e.edgeType,nodesLocked:e.nodesLocked,copiedTask:e.copiedTask,viewMode:e.viewMode})}));const Gy=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),Vy=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(n,r,t)=>t?t.toUpperCase():r.toLowerCase()),Ih=e=>{const n=Vy(e);return n.charAt(0).toUpperCase()+n.slice(1)},Rh=(...e)=>e.filter((n,r,t)=>!!n&&n.trim()!==""&&t.indexOf(n)===r).join(" ").trim(),Yy=e=>{for(const n in e)if(n.startsWith("aria-")||n==="role"||n==="title")return!0};var Xy={xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"};const Zy=O.forwardRef(({color:e="currentColor",size:n=24,strokeWidth:r=2,absoluteStrokeWidth:t,className:s="",children:a,iconNode:o,...i},u)=>O.createElement("svg",{ref:u,...Xy,width:n,height:n,stroke:e,strokeWidth:t?Number(r)*24/Number(n):r,className:Rh("lucide",s),...!a&&!Yy(i)&&{"aria-hidden":"true"},...i},[...o.map(([c,d])=>O.createElement(c,d)),...Array.isArray(a)?a:[a]]));const we=(e,n)=>{const r=O.forwardRef(({className:t,...s},a)=>O.createElement(Zy,{ref:a,iconNode:n,className:Rh(`lucide-${Gy(Ih(e))}`,`lucide-${e}`,t),...s}));return r.displayName=Ih(e),r};const Oh=we("activity",[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]]);const Qy=we("circle-stop",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["rect",{x:"9",y:"9",width:"6",height:"6",rx:"1",key:"1ssd4o"}]]);const ex=we("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Ph=we("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);const rx=we("database",[["ellipse",{cx:"12",cy:"5",rx:"9",ry:"3",key:"msslwz"}],["path",{d:"M3 5V19A9 3 0 0 0 21 19V5",key:"1wlel7"}],["path",{d:"M3 12A9 3 0 0 0 21 12",key:"mv7ke4"}]]);const Gr=we("git-branch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]);const Vr=we("git-merge",[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]]);const tx=we("globe",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]]);const nx=we("message-square",[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]]);const ax=we("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const sx=we("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);const ox=we("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Ah=we("repeat",[["path",{d:"m17 2 4 4-4 4",key:"nntrym"}],["path",{d:"M3 11v-1a4 4 0 0 1 4-4h14",key:"84bu3i"}],["path",{d:"m7 22-4-4 4-4",key:"1wqhfi"}],["path",{d:"M21 13v1a4 4 0 0 1-4 4H3",key:"1rx37r"}]]);const Ki=we("shuffle",[["path",{d:"m18 14 4 4-4 4",key:"10pe0f"}],["path",{d:"m18 2 4 4-4 4",key:"pucp1d"}],["path",{d:"M2 18h1.973a4 4 0 0 0 3.3-1.7l5.454-8.6a4 4 0 0 1 3.3-1.7H22",key:"1ailkh"}],["path",{d:"M2 6h1.972a4 4 0 0 1 3.6 2.2",key:"km57vx"}],["path",{d:"M22 18h-6.041a4 4 0 0 1-3.3-1.8l-.359-.45",key:"os18l9"}]]);const ix=we("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const lx=we("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const cx=we("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),dx={business:["business"],standard:["business","control"],developer:["business","control","data"]},He=[{type:"SIMPLE",label:"任务节点 (Worker)",description:"在远程 Worker 上执行的任务",category:"CORE",icon:Oh,viewCategory:"business"},{type:"SUB_WORKFLOW",label:"子工作流 (Sub Workflow)",description:"调用并执行另一个工作流",category:"CORE",icon:Vr,viewCategory:"business"},{type:"START_WORKFLOW",label:"启动工作流 (Start Workflow)",description:"启动另一个工作流(不等待结果)",category:"SYSTEM",icon:sx,viewCategory:"business"},{type:"HTTP",label:"HTTP 请求",description:"发起 REST/HTTP 调用",category:"SYSTEM",icon:tx,viewCategory:"business"},{type:"INLINE",label:"内联脚本 (Inline)",description:"执行内联脚本(JS/Python/GraalJS)",category:"SYSTEM",icon:Ph,viewCategory:"data"},{type:"JSON_JQ_TRANSFORM",label:"JSON 转换 (JQ)",description:"使用 JQ 表达式转换 JSON 数据",category:"SYSTEM",icon:ix,viewCategory:"data"},{type:"KAFKA_PUBLISH",label:"Kafka 推送",description:"向 Kafka 主题推送消息",category:"SYSTEM",icon:nx,viewCategory:"data"},{type:"EVENT",label:"事件 (Event)",description:"向外部队列系统发布事件",category:"SYSTEM",icon:cx,viewCategory:"data"},{type:"WAIT",label:"等待 (Wait)",description:"暂停流程,直到特定时间或时长",category:"SYSTEM",icon:ex,viewCategory:"control"},{type:"SET_VARIABLE",label:"设置变量 (Set Variable)",description:"设置工作流上下文变量",category:"SYSTEM",icon:rx,viewCategory:"data"},{type:"TERMINATE",label:"终止 (Terminate)",description:"提前结束工作流执行",category:"SYSTEM",icon:Qy,viewCategory:"control"},{type:"HUMAN",label:"人工审批 (Human)",description:"等待人工审核或表单提交",category:"SYSTEM",icon:lx,viewCategory:"business"},{type:"DYNAMIC",label:"动态任务 (Dynamic)",description:"运行时动态决定任务类型",category:"SYSTEM",icon:Ki,viewCategory:"data"},{type:"NOOP",label:"空操作 (Noop)",description:"占位符任务,无实际操作",category:"SYSTEM",icon:ax,viewCategory:"data"},{type:"LAMBDA",label:"Lambda 脚本 (旧)",description:"已被 INLINE 取代",category:"SYSTEM",icon:Ph,hidden:!0,viewCategory:"data"},{type:"SWITCH",label:"条件分支 (Switch)",description:"基于条件的逻辑分支 (Switch/Case)",category:"FLOW",icon:Ki,viewCategory:"control"},{type:"DECISION",label:"判断 (Decision,旧)",description:"基于条件的逻辑分支(旧版,推荐改用 Switch)",category:"FLOW",icon:Ki,hidden:!0,viewCategory:"control"},{type:"FORK_JOIN",label:"静态并行 (Fork)",description:"并行执行多个预定义任务分支",category:"FLOW",icon:Gr,viewCategory:"control"},{type:"FORK_JOIN_DYNAMIC",label:"动态并行 (Dynamic Fork)",description:"运行时动态生成并行分支",category:"FLOW",icon:Gr,viewCategory:"control"},{type:"DO_WHILE",label:"循环 (Do-While)",description:"循环执行直到满足条件",category:"FLOW",icon:Ah,viewCategory:"control"},{type:"JOIN",label:"汇聚 (Join)",description:"等待所有并行分支执行完成",category:"FLOW",icon:Vr,viewCategory:"control"}],ux=[{key:"CORE",label:"基础任务"},{key:"FLOW",label:"逻辑控制"},{key:"SYSTEM",label:"系统集成"}],Yr=({message:e,onConfirm:n,onCancel:r})=>{const t=O.useRef(null),{theme:s,themeColor:a}=oe();return O.useEffect(()=>{t.current?.focus({preventScroll:!0});const o=i=>{i.key==="Escape"&&r()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[r]),Qr.createPortal(l.jsx("div",{"data-mode":s,"data-brand":a,onClick:r,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:l.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"确认操作",onClick:o=>o.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"24px 28px",maxWidth:"380px",width:"90%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.18)"},children:[l.jsx("div",{style:{fontSize:"14px",color:"var(--text-primary)",marginBottom:"24px",lineHeight:"1.6"},children:e}),l.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[l.jsx("button",{ref:t,onClick:r,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:"取消"}),l.jsx("button",{onClick:n,style:{padding:"7px 18px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"6px",color:"#ffffff",cursor:"pointer",fontSize:"13px",fontWeight:600},children:"确定"})]})]})}),document.body)},kr=({children:e,nodeId:n,selected:r=!1,isStartOrEnd:t=!1,isError:s=!1,hasWarning:a=!1,isDecision:o=!1,isHighlighted:i=!1,executionStatus:u,simRunning:c=!1,simDone:d=!1,proposalStatus:f})=>{const{mode:p,removeNode:h}=oe(),[g,m]=O.useState(!1),v=w=>{w.stopPropagation(),m(!0)},y=p==="edit"&&!t,b=[o?"decision-node-wrapper":"node-wrapper-glass",r?"node-wrapper-selected":"",i?"node-wrapper-highlighted":"",c?"node-sim-running":"",d?"node-sim-done":"",f?`node-proposal-${f}`:""].filter(Boolean).join(" "),k=O.useMemo(()=>{if(p!=="run")return{};if(!u)return{opacity:.4};switch(u){case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":return{borderColor:"var(--status-failed)",boxShadow:"0 0 12px rgba(239, 68, 68, 0.5), 0 0 24px rgba(239, 68, 68, 0.2)"};case"TIMED_OUT":return{borderColor:"var(--status-timed-out)",boxShadow:"0 0 8px rgba(249, 115, 22, 0.4)"};case"IN_PROGRESS":case"SCHEDULED":return{borderColor:"var(--status-in-progress)",animation:"status-pulse 1.5s ease-in-out infinite"};case"COMPLETED":return{borderColor:"var(--status-completed)",opacity:.85};case"COMPLETED_WITH_ERRORS":return{borderColor:"var(--status-completed-with-errors)"};case"SKIPPED":case"CANCELED":return{opacity:.5};default:return{}}},[p,u]);return l.jsxs("div",{className:b,style:{position:"relative",...k},children:[y&&l.jsx("button",{onClick:v,"aria-label":"删除任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},title:"删除任务",children:"×"}),s&&l.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},title:"此节点配置有误",children:"❗"}),!s&&a&&l.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#f59e0b",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},title:"此节点有警告信息",children:"⚠️"}),f&&l.jsx("div",{className:`node-proposal-badge node-proposal-badge-${f}`,children:f==="added"?"+":f==="modified"?"~":"−"}),e,g&&l.jsx(Yr,{message:"确定要删除此任务吗?",onConfirm:()=>{h(n),m(!1)},onCancel:()=>m(!1)})]})},fx=({status:e})=>{const n=()=>{switch(e){case"SCHEDULED":return{icon:"○",className:"scheduled"};case"IN_PROGRESS":return{icon:"◐",className:"in-progress"};case"COMPLETED":return{icon:"✓",className:"completed"};case"COMPLETED_WITH_ERRORS":return{icon:"⚠",className:"completed-with-errors"};case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":return{icon:"✗",className:"failed"};case"TIMED_OUT":return{icon:"⏱",className:"timed-out"};case"SKIPPED":return{icon:"⤳",className:"skipped"};case"CANCELED":return{icon:"⊘",className:"canceled"};default:return{icon:"?",className:"unknown"}}},{icon:r,className:t}=n();return l.jsx("div",{className:`execution-status-badge ${t}`,title:e,children:l.jsx("span",{className:"badge-icon",children:r})})},Lh=O.memo(fx),px=/[一-龥]/,hx=({icon:e,header:n,title:r,meta:t,color:s,status:a,isRunning:o,children:i,width:u="240px",border:c=!0})=>l.jsxs("div",{style:{display:"flex",flexDirection:"row",width:u,height:"100%",position:"relative",overflow:"hidden",border:c?"4px solid var(--border-primary)":"none",borderRadius:"8px"},children:[l.jsx("div",{style:{width:"48px",display:"flex",alignItems:"center",justifyContent:"center",backgroundColor:"rgba(205, 74, 74, 0.03)",borderRight:"1px solid var(--color-accent)",color:s},children:l.jsx(e,{size:20,strokeWidth:1.5})}),l.jsxs("div",{style:{flex:1,padding:"10px 14px",display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden"},children:[l.jsx("div",{style:{fontSize:"11px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.7,marginBottom:"4px",color:s,...px.test(n)&&{letterSpacing:"0.3px",fontSize:"12px"}},children:n}),l.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"2px"},title:r,children:r}),t&&l.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)",fontStyle:"italic",lineHeight:"1.4",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:t,children:t}),i&&l.jsx("div",{style:{marginTop:"8px"},children:i})]}),o&&a&&l.jsx("div",{style:{position:"absolute",top:"8px",right:"8px"},children:l.jsx(Lh,{status:a})})]}),Xr=O.memo(hx),Xe=e=>{const n=e.layoutDirection||"TB",r=e.sourcePosition||(n==="LR"?A.Position.Right:A.Position.Bottom),t=e.targetPosition||(n==="LR"?A.Position.Left:A.Position.Top);return{layoutDirection:n,sourcePosition:r,targetPosition:t}},ir=e=>{const{mode:n,executionData:r}=oe(),t=n==="run"?r?.[e]:null,s=n==="run",a=t?.attempts.some(u=>u.iteration!==void 0&&u.iteration>1)??!1,o=t?.attempts[t.attempts.length-1],i=a?0:o?.retryCount??0;return{mode:n,execution:t,isRunning:s,retryCount:i}};function Ke(e,n){return e.length>n?e.slice(0,n)+"…":e}function _r(e,n,r,t){if(r==="business")return n.task?.description?.trim()||t;if(r==="standard")return t;const s=n.task;if(!s)return t;const a=s.inputParameters||{};switch(e){case"HTTP":case"HTTP_POLL":{const o=s.httpRequest||a.http_request;if(!o)return t;const i=(o.method||"GET").toUpperCase(),u=o.uri?Ke(String(o.uri),28):"";return u?`${i} ${u}`:i}case"SWITCH":{const o=s.caseExpression||a.expression,i=s.evaluatorType||a.evaluatorType;return o?Ke(o,35):i||t}case"DECISION":return s.caseValueParam?`param: ${s.caseValueParam}`:t;case"SIMPLE":return s.name?`worker: ${Ke(s.name,28)}`:t;case"INLINE":case"LAMBDA":{const o=s.evaluatorType||a.evaluatorType;return o?`${o} script`:t}case"SUB_WORKFLOW":{const o=s.subWorkflowParam;return o?`${o.name}${o.version?` v${o.version}`:""}`:t}case"DO_WHILE":{const o=s.loopCondition;return o?Ke(o,35):t}case"JSON_JQ_TRANSFORM":{const o=a.queryExpression||a.query_expression;return o?Ke(o,35):t}case"SET_VARIABLE":{const o=Object.keys(a);return o.length?`set: ${o.slice(0,2).join(", ")}${o.length>2?"…":""}`:t}case"EVENT":{const o=s.sink||a.sink;return o?`→ ${Ke(o,32)}`:t}case"KAFKA_PUBLISH":{const o=a.topic||a.kafka_request?.topic;return o?`topic: ${Ke(o,28)}`:t}case"START_WORKFLOW":{const o=s.startWorkflow?.name??a.startWorkflow?.name??a.start_workflow?.name;return o?`→ ${o}`:t}default:return t}}function lr(e,n){if(n!=="business")return e;const r=He.find(t=>t.type===e);return r?r.label.replace(/\s*\([^)]+\)$/,""):e==="JOIN"?"汇聚":e==="EXCLUSIVE_JOIN"?"排他汇聚":e}const gx=({id:e,data:n,selected:r})=>{const t=n.taskType||"SIMPLE",{sourcePosition:s,targetPosition:a}=Xe(n),{execution:o,isRunning:i,retryCount:u}=ir(n.taskReferenceName),c=oe(v=>v.viewMode),d=O.useMemo(()=>He.find(v=>v.type===t),[t]),f=d?.icon||Oh,p=t==="NOOP",h=n.isDynamicRuntime===!0,g=p?"var(--text-secondary)":"var(--color-accent)",m=O.useMemo(()=>{let v;return h?v=`Dynamic (${t})`:t==="SIMPLE"?v=n.label==="Worker Task"?"Execute on Worker":"Worker Task":t==="HTTP"?v="REST API Call":t==="JSON_JQ_TRANSFORM"?v="JQ Expression":t==="INLINE"||t==="LAMBDA"?v="Inline Script":t==="START_WORKFLOW"?v="Launch Workflow (no wait)":t==="DYNAMIC"?v="Dynamic Task Type":t==="HUMAN"?v="Human Approval":t==="NOOP"?v="No Operation":v=d?.label||t,_r(t,n,c,v)},[t,d,n,c,h]);return l.jsx(kr,{nodeId:e,selected:r,isError:n.isError,hasWarning:n.hasWarning,isHighlighted:n.isHighlighted,executionStatus:o?.status,simRunning:n.simRunning,simDone:n.simDone,proposalStatus:n.proposalStatus,children:l.jsxs("div",{style:{borderRadius:"8px",background:p?"var(--bg-tertiary)":"var(--bg-secondary)",opacity:p?.7:1,position:"relative",outline:h?"2px dashed var(--color-accent)":"none",outlineOffset:"-2px"},children:[l.jsx(Xr,{icon:f,header:lr(t,c),title:n.taskReferenceName,meta:m,color:g,status:o?.status,isRunning:i}),i&&u>0&&l.jsxs("div",{style:{position:"absolute",bottom:"4px",right:"4px",background:"var(--status-failed, #ef4444)",color:"#fff",borderRadius:"10px",fontSize:"10px",fontWeight:"700",padding:"1px 6px",zIndex:10,lineHeight:"1.4",pointerEvents:"none"},children:["×",u]}),h&&l.jsx("div",{style:{position:"absolute",top:"4px",right:"4px",background:"var(--color-accent)",color:"#fff",borderRadius:"4px",fontSize:"9px",fontWeight:"700",padding:"1px 5px",zIndex:10,pointerEvents:"none",opacity:.9},children:"动态"}),l.jsx(A.Handle,{type:"target",position:a,style:{background:"#fff"}}),l.jsx(A.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})},mx=O.memo(gx),qh=({title:e,label:n,defaultValue:r="",placeholder:t="",confirmText:s="确定",cancelText:a="取消",onConfirm:o,onCancel:i})=>{const{theme:u,themeColor:c}=oe(),[d,f]=O.useState(r),p=O.useRef(null);O.useEffect(()=>{p.current&&(p.current.focus({preventScroll:!0}),p.current.select());const g=m=>{m.key==="Escape"&&(m.stopPropagation(),i())};return window.addEventListener("keydown",g,!0),()=>window.removeEventListener("keydown",g,!0)},[i]);const h=()=>{const g=d.trim();g&&o(g)};return Qr.createPortal(l.jsx("div",{"data-mode":u,"data-brand":c,onClick:i,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:l.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e,onClick:g=>g.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"10px",padding:"24px 28px",maxWidth:"400px",width:"90%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.22)"},children:[l.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"var(--text-primary)",marginBottom:"16px"},children:e}),n&&l.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px"},children:n}),l.jsx("input",{ref:p,type:"text",value:d,placeholder:t,onChange:g=>f(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),h()),g.stopPropagation()},style:{width:"100%",padding:"9px 12px",borderRadius:"6px",border:"1px solid var(--border-primary)",background:"var(--bg-tertiary)",color:"var(--text-primary)",fontSize:"13px",outline:"none",boxSizing:"border-box",marginBottom:"20px",transition:"border-color 0.15s"},onFocus:g=>{g.currentTarget.style.borderColor="var(--color-accent)"},onBlur:g=>{g.currentTarget.style.borderColor="var(--border-primary)"}}),l.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[l.jsx("button",{onClick:i,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:a}),l.jsx("button",{onClick:h,disabled:!d.trim(),style:{padding:"7px 18px",backgroundColor:d.trim()?"var(--color-accent)":"var(--bg-tertiary)",border:"none",borderRadius:"6px",color:d.trim()?"#ffffff":"var(--text-secondary)",cursor:d.trim()?"pointer":"not-allowed",fontSize:"13px",fontWeight:600,transition:"background-color 0.15s, color 0.15s"},children:s})]})]})}),document.body)},vx=({id:e,data:n,selected:r})=>{const{layoutDirection:t}=Xe(n),{mode:s,execution:a,isRunning:o}=ir(n.taskReferenceName),{addDecisionBranch:i,removeDecisionBranch:u,renameDecisionBranch:c,viewMode:d}=oe(),[f,p]=O.useState(!1),[h,g]=O.useState({type:"none"}),m=t==="LR"?A.Position.Left:A.Position.Top,v=Object.keys(n.decisionCases||n.task?.decisionCases||{}),y=()=>{p(!1),g({type:"add"})},x=(C,S)=>{C.stopPropagation(),g({type:"delete",branch:S})},b=(C,S)=>{C.stopPropagation(),p(!1),g({type:"rename",branch:S})},k=C=>{C&&i(e,C),g({type:"none"})},w=C=>{h.type==="rename"&&(C&&C!==h.branch&&c(e,h.branch,C),g({type:"none"}))},j=()=>{h.type==="delete"&&(u(e,h.branch),g({type:"none"}))},N=()=>g({type:"none"}),T=o?(C=>C&&{SCHEDULED:"execution-node-scheduled",IN_PROGRESS:"execution-node-in-progress",COMPLETED:"execution-node-completed",COMPLETED_WITH_ERRORS:"execution-node-completed-with-errors",FAILED:"execution-node-failed",FAILED_WITH_TERMINAL_ERROR:"execution-node-failed-terminal",TIMED_OUT:"execution-node-timed-out",SKIPPED:"execution-node-skipped",CANCELED:"execution-node-canceled"}[C]||"")(a?.status):"";return l.jsxs(kr,{nodeId:e,selected:r,isError:n.isError,hasWarning:n.hasWarning,isDecision:!0,isHighlighted:n.isHighlighted,executionStatus:a?.status,simRunning:n.simRunning,simDone:n.simDone,proposalStatus:n.proposalStatus,children:[l.jsxs("div",{style:{position:"relative"},children:[l.jsx(A.Handle,{type:"target",position:m,style:{background:"#fff",[t==="LR"?"left":"top"]:"-5px"}}),o&&a?.status&&l.jsx("div",{style:{position:"absolute",top:0,right:0,zIndex:20},children:l.jsx(Lh,{status:a.status})}),l.jsx("div",{className:T,style:{width:"150px",height:"150px",background:o&&a?.status?void 0:"var(--bg-secondary)",border:r?"4px solid #fbbf24":o&&a?.status?void 0:"4px solid var(--border-primary)",transform:"rotate(45deg)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:r?"0 10px 30px rgba(0,0,0,0.3), 0 0 0 4px rgba(251, 191, 36, 0.3)":o&&a?.status?void 0:"0 4px 12px rgba(0,0,0,0.15)",transition:"all 0.3s ease",cursor:"pointer"},onClick:()=>s==="edit"&&p(!f),children:l.jsxs("div",{style:{transform:"rotate(-45deg)",color:"#fff",textAlign:"center",padding:"10px",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[l.jsx("div",{style:{fontSize:"14px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.7,marginBottom:"4px",color:"var(--color-accent)"},children:lr(n.taskType,d)}),l.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)",lineHeight:"1.2",wordBreak:"break-word",maxHeight:"60px",overflow:"hidden",marginBottom:"4px"},children:n.label}),s==="edit"&&l.jsx("div",{style:{marginTop:"4px",width:"24px",height:"24px",fontSize:"16px",background:"rgba(255,255,255,0.1)",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:"4px auto 0",color:"var(--text-secondary)"},children:"+"}),o&&a?.startTime&&l.jsx("div",{style:{fontSize:"9px",opacity:.7,marginTop:"8px"},children:a.endTime?`${((a.endTime-a.startTime)/1e3).toFixed(1)}s`:"◌"})]})}),s==="edit"&&f&&l.jsxs("div",{className:"glass-panel",style:{position:"absolute",top:"160px",left:"50%",transform:"translateX(-50%)",backgroundColor:"var(--glass-surface)",border:"1px solid var(--glass-border)",borderRadius:"8px",padding:"8px",zIndex:1e3,minWidth:"200px",boxShadow:"0 10px 25px rgba(0,0,0,0.5)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",backdropFilter:"blur(12px)"},children:[l.jsx("div",{style:{padding:"4px 8px 6px",fontSize:"11px",color:"var(--text-secondary)",borderBottom:"1px solid var(--glass-border)",marginBottom:"4px",fontWeight:600,letterSpacing:"0.05em"},children:"分支管理"}),v.map(C=>l.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"5px 6px",borderRadius:"4px",gap:"4px"},children:[l.jsx("span",{style:{flex:1,fontSize:"12px",color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:C}),l.jsx("button",{onClick:S=>b(S,C),style:{width:"22px",height:"22px",borderRadius:"4px",backgroundColor:"var(--color-accent)",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",padding:0,flexShrink:0,opacity:.85},title:`重命名分支 "${C}"`,children:"✏"}),l.jsx("button",{onClick:S=>x(S,C),style:{width:"22px",height:"22px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",padding:0,flexShrink:0,opacity:.9},title:`删除分支 "${C}"`,children:"×"})]},C)),l.jsx("button",{onClick:y,style:{width:"100%",marginTop:"6px",padding:"8px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"4px",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:"bold"},children:"+ 添加新分支"})]}),d==="developer"&&(()=>{const C=n.task?.caseExpression||n.task?.inputParameters?.expression,S=n.task?.caseValueParam;return!C&&!S?null:l.jsx("div",{style:{position:"absolute",top:"158px",left:"50%",transform:"translateX(-50%)",textAlign:"center",fontSize:10,color:"var(--text-secondary)",maxWidth:140,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",fontFamily:"var(--font-mono, monospace)"},children:C?Ke(C,22):`param: ${S}`})})(),t==="TB"?l.jsxs(l.Fragment,{children:[l.jsx(A.Handle,{type:"source",position:A.Position.Bottom,style:{background:"#fff",bottom:"-5px"}}),l.jsx(A.Handle,{type:"source",position:A.Position.Left,id:"left",style:{background:"#fff",left:"-5px"}}),l.jsx(A.Handle,{type:"source",position:A.Position.Right,id:"right",style:{background:"#fff",right:"-5px"}})]}):l.jsxs(l.Fragment,{children:[l.jsx(A.Handle,{type:"source",position:A.Position.Right,style:{background:"#fff",right:"-5px"}}),l.jsx(A.Handle,{type:"source",position:A.Position.Top,id:"top",style:{background:"#fff",top:"-5px"}}),l.jsx(A.Handle,{type:"source",position:A.Position.Bottom,id:"bottom",style:{background:"#fff",bottom:"-5px"}})]})]}),h.type==="add"&&l.jsx(qh,{title:"添加新分支",label:"分支条件值(Case Value)",defaultValue:`case_${v.length+1}`,placeholder:"例如:approved、rejected、pending",confirmText:"添加",onConfirm:k,onCancel:N}),h.type==="rename"&&l.jsx(qh,{title:"重命名分支",label:`当前名称:${h.branch}`,defaultValue:h.branch,placeholder:"输入新的分支条件值",confirmText:"重命名",onConfirm:w,onCancel:N}),h.type==="delete"&&l.jsx(Yr,{message:`确定要删除分支 "${h.branch}" 及其下的所有任务吗?此操作不可撤销。`,onConfirm:j,onCancel:N})]})},yx=O.memo(vx),Dh="var(--color-accent)",Mh=O.memo(({id:e,data:n,selected:r})=>{const{layoutDirection:t,sourcePosition:s,targetPosition:a}=Xe(n),{mode:o,execution:i,isRunning:u}=ir(n.taskReferenceName),{addForkBranch:c}=oe(),d=A.useUpdateNodeInternals(),f=n.task?.forkTasks?.length||0;O.useEffect(()=>{d(e)},[f,e,d]);const p=n.isDynamic||n.taskType==="FORK_JOIN_DYNAMIC",h=oe(v=>v.viewMode),m=O.useMemo(()=>He.find(v=>v.type==="FORK_JOIN"),[])?.icon||Gr;return l.jsx(kr,{isHighlighted:n.isHighlighted,nodeId:e,selected:r,isError:n.isError,hasWarning:n.hasWarning,executionStatus:i?.status,simRunning:n.simRunning,simDone:n.simDone,proposalStatus:n.proposalStatus,children:l.jsxs("div",{className:`fork-node ${p?"dynamic":"static"}`,style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[l.jsx(Xr,{icon:m,header:lr(p?"FORK_JOIN_DYNAMIC":"FORK_JOIN",h),title:n.taskReferenceName,meta:_r(n.taskType,n,h,p?"Dynamic Parallel Execution":"Parallel Execution"),color:Dh,status:i?.status,isRunning:u}),o==="edit"&&!p&&l.jsx("div",{style:{position:"absolute",...t==="LR"?{top:"50%",right:-12,transform:"translateY(-50%)"}:{bottom:-12,left:"50%",transform:"translateX(-50%)"},width:20,height:20,background:"var(--color-accent)",borderRadius:"50%",color:"#fff",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:1e3,boxShadow:"0 2px 5px rgba(0,0,0,0.2)",border:"2px solid var(--bg-primary)"},onClick:v=>{v.stopPropagation(),c(e)},title:"添加分支",children:"+"}),l.jsx(A.Handle,{type:"target",position:a,style:{background:"#fff"}}),!p&&(n.task?.forkTasks||[]).map((v,y,x)=>{if(o!=="edit"&&(!v||v.length===0))return null;const b=o!=="edit"?x.filter(N=>N&&N.length>0):x,k=b.length,j=(b.indexOf(v)+1)/(k+1)*100;return l.jsx(A.Handle,{id:`branch_${y}`,type:"source",position:s,style:{background:"#fff",[t==="LR"?"top":"left"]:`${j}%`,[t==="LR"?"left":"top"]:void 0,[t==="LR"?"right":"bottom"]:"-4px",zIndex:10}},`branch_${y}`)}),!p&&(!n.task?.forkTasks||n.task.forkTasks.length===0)&&l.jsx(A.Handle,{type:"source",position:s,style:{background:"#fff"}}),p&&l.jsx(A.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})});Mh.displayName="ForkNode";const Wh=O.memo(({id:e,data:n,selected:r})=>{const{layoutDirection:t,sourcePosition:s,targetPosition:a}=Xe(n),{execution:o,isRunning:i}=ir(n.taskReferenceName),u=oe(f=>f.viewMode),d=O.useMemo(()=>He.find(f=>f.type==="JOIN"),[])?.icon||Vr;return l.jsx(kr,{isHighlighted:n.isHighlighted,nodeId:e,selected:r,isError:n.isError,hasWarning:n.hasWarning,executionStatus:o?.status,simRunning:n.simRunning,simDone:n.simDone,proposalStatus:n.proposalStatus,children:l.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[l.jsx(Xr,{icon:d,header:lr(n.taskType==="EXCLUSIVE_JOIN"?"EXCLUSIVE_JOIN":"JOIN",u),title:n.taskReferenceName,meta:_r(n.taskType,n,u,n.taskType==="EXCLUSIVE_JOIN"?"Wait for any task":"Wait for tasks"),color:Dh,status:o?.status,isRunning:i}),l.jsx(A.Handle,{type:"target",position:a,style:{background:"#fff"}}),t==="TB"&&l.jsxs(l.Fragment,{children:[l.jsx(A.Handle,{type:"target",position:A.Position.Left,id:"left",style:{background:"#fff"}}),l.jsx(A.Handle,{type:"target",position:A.Position.Right,id:"right",style:{background:"#fff"}})]}),t==="LR"&&l.jsxs(l.Fragment,{children:[l.jsx(A.Handle,{type:"target",position:A.Position.Top,id:"top",style:{background:"#fff"}}),l.jsx(A.Handle,{type:"target",position:A.Position.Bottom,id:"bottom",style:{background:"#fff"}})]}),l.jsx(A.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})});Wh.displayName="JoinNode";const Bh={ForkNode:Mh,JoinNode:Wh},xx=({id:e,data:n,selected:r})=>{const{sourcePosition:t,targetPosition:s}=Xe(n),{execution:a,isRunning:o}=ir(n.taskReferenceName),{executionData:i,selectTaskAction:u,mode:c,viewMode:d,removeNode:f}=oe(),[p,h]=O.useState(!1),g=n.task,m=g?.loopOver||[],y=O.useMemo(()=>He.find(T=>T.type==="DO_WHILE"),[])?.icon||Ah,x=O.useMemo(()=>{if(!o||!i||m.length===0)return 0;let T=0;return m.forEach(C=>{const S=i[C.taskReferenceName];S?.totalIterations?T=Math.max(T,S.totalIterations):S?.attempts.some(D=>(D.iteration??0)>0)&&(T=Math.max(T,S.attempts.length))}),T},[o,i,m]),b=n.loopCondition||g?.loopCondition||"",k=O.useMemo(()=>{const T=b?b.length>35?b.slice(0,35)+"…":b:"循环直到条件满足";return _r("DO_WHILE",n,d,T)},[n,d,b]),w=a?.status==="COMPLETED"?"var(--status-completed)":a?.status==="FAILED"||a?.status==="FAILED_WITH_TERMINAL_ERROR"?"var(--status-failed)":a?.status==="IN_PROGRESS"||a?.status==="SCHEDULED"?"var(--status-in-progress)":"var(--color-accent)",j=r?`2px solid ${w}`:`1.5px dashed ${o&&a?.status?w:"var(--color-accent)"}`,N=c==="edit",L=d==="developer"&&b;return l.jsxs("div",{style:{width:"100%",height:"100%",border:j,borderRadius:"10px",background:"transparent",display:"flex",flexDirection:"column",position:"relative",overflow:"visible",boxSizing:"border-box",pointerEvents:"none"},children:[N&&l.jsx("button",{onClick:T=>{T.stopPropagation(),h(!0)},"aria-label":"删除循环任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",padding:0,pointerEvents:"auto"},title:"删除循环任务",children:"×"}),n.isError&&l.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点配置有误",children:"❗"}),!n.isError&&n.hasWarning&&l.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#f59e0b",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点有警告信息",children:"⚠️"}),n.proposalStatus&&l.jsx("div",{className:`node-proposal-badge node-proposal-badge-${n.proposalStatus}`,style:{pointerEvents:"auto"},children:n.proposalStatus==="added"?"+":n.proposalStatus==="modified"?"~":"−"}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"8px 12px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",borderRadius:"8px 8px 0 0",flexShrink:0,minHeight:"42px",pointerEvents:"auto"},children:[l.jsx("div",{style:{color:"var(--color-accent)",display:"flex",alignItems:"center",flexShrink:0},children:l.jsx(y,{size:14})}),l.jsxs("div",{style:{flex:1,minWidth:0},children:[l.jsx("div",{style:{fontSize:"9px",fontWeight:700,color:"var(--color-accent)",letterSpacing:"0.08em",textTransform:"uppercase"},children:lr("DO_WHILE",d)}),l.jsx("div",{style:{fontSize:"11px",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n.taskReferenceName}),(d==="business"||d==="developer")&&k&&l.jsx("div",{style:{fontSize:"9px",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"1px",fontStyle:"italic"},children:k})]}),o&&x>0&&l.jsxs("div",{onClick:()=>u(g||null),style:{padding:"2px 8px",borderRadius:"12px",background:"var(--color-accent)",color:"#fff",fontSize:"10px",fontWeight:700,cursor:"pointer",flexShrink:0},children:["×",x]}),o&&a?.status&&l.jsx("div",{style:{width:"8px",height:"8px",borderRadius:"50%",background:w,flexShrink:0}})]}),L&&l.jsxs("div",{style:{padding:"3px 12px",fontSize:"9px",color:"var(--text-secondary)",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:0,pointerEvents:"auto"},children:["until: ",b]}),l.jsx("div",{style:{flex:1,position:"relative",background:"var(--loop-body-bg, rgba(99,102,241,0.04))",borderRadius:"0 0 8px 8px",pointerEvents:"none"}}),l.jsx(A.Handle,{type:"target",position:s,style:{background:"var(--color-accent)",zIndex:10}}),l.jsx(A.Handle,{type:"source",position:t,style:{background:"var(--color-accent)",zIndex:10}}),p&&l.jsx(Yr,{message:"确定要删除此循环任务吗?循环体内的任务也会一并删除。",onConfirm:()=>{f(e),h(!1)},onCancel:()=>h(!1)})]})},bx=O.memo(xx),kx="var(--color-accent)",_x=({id:e,data:n,selected:r})=>{const{sourcePosition:t,targetPosition:s}=Xe(n),{execution:a,isRunning:o}=ir(n.taskReferenceName),i=oe(p=>p.viewMode),c=O.useMemo(()=>He.find(p=>p.type==="SUB_WORKFLOW"),[])?.icon||Vr,d=n.task?.subWorkflowParam?.name||n.subWorkflowName||"Unknown",f=n.task?.subWorkflowParam?.version;return l.jsx(kr,{nodeId:e,selected:r,isError:n.isError,hasWarning:n.hasWarning,isHighlighted:n.isHighlighted,executionStatus:a?.status,simRunning:n.simRunning,simDone:n.simDone,proposalStatus:n.proposalStatus,children:l.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[l.jsx(Xr,{icon:c,header:lr("SUB_WORKFLOW",i),title:n.taskReferenceName,meta:_r("SUB_WORKFLOW",n,i,`Flow: ${d} (v${f})`),color:kx,status:a?.status,isRunning:o}),l.jsx(A.Handle,{type:"target",position:s,style:{background:"#fff"}}),l.jsx(A.Handle,{type:"source",position:t,style:{background:"#fff"}})]})})},Sx=O.memo(_x),wx=({data:e})=>{const r=(e.layoutDirection||"TB")==="LR";return l.jsxs("div",{className:"plus-node-container",style:{width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"var(--bg-secondary, #1e293b)",border:"2px dashed var(--color-accent, #3b82f6)",color:"var(--color-accent, #3b82f6)",cursor:"pointer",transition:"all 0.2s ease",padding:e.label&&e.label!=="+"?"0 12px":"0",minWidth:e.label&&e.label!=="+"?"80px":"32px",gap:"4px"},children:[l.jsx(ox,{size:16}),e.label&&e.label!=="+"&&l.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:e.label}),l.jsx(A.Handle,{type:"target",position:r?A.Position.Left:A.Position.Top,style:{opacity:0}}),l.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
10
13
|
.plus-node-container:hover {
|
|
11
14
|
transform: scale(1.1);
|
|
12
15
|
background: var(--color-accent);
|
|
@@ -14,33 +17,41 @@ execute($.input);`}):u.type==="DYNAMIC"?(u.dynamicTaskNameParam="taskToExecute",
|
|
|
14
17
|
border-style: solid;
|
|
15
18
|
box-shadow: 0 0 10px var(--color-accent);
|
|
16
19
|
}
|
|
17
|
-
`}})]})},
|
|
20
|
+
`}})]})},Tx=O.memo(wx),Ex=({data:e})=>{const{sourcePosition:n,targetPosition:r}=Xe(e);return l.jsxs("div",{style:{width:"220px",height:"70px",border:"2px dashed var(--color-accent)",borderRadius:"8px",background:"var(--bg-secondary)",opacity:.75,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"4px",cursor:"default",userSelect:"none"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[l.jsx(Gr,{size:14,style:{color:"var(--color-accent)"}}),l.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--color-accent)"},children:"动态分支"})]}),l.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"运行时生成"}),l.jsx(A.Handle,{type:"target",position:r,style:{background:"var(--color-accent)",width:8,height:8}}),l.jsx(A.Handle,{type:"source",position:n,style:{background:"var(--color-accent)",width:8,height:8}})]})},Nx=O.memo(Ex),Cx=({onSelect:e,onCancel:n})=>{const[r,t]=O.useState("CORE");O.useEffect(()=>{const a=o=>{o.key==="Escape"&&n()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[n]);const s=He.filter(a=>a.category===r&&!a.hidden);return l.jsxs("div",{style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.6)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3,backdropFilter:"blur(4px)",animation:"fadeIn 0.2s ease-out"},onClick:n,children:[l.jsxs("div",{className:"glass-panel",style:{backgroundColor:"var(--glass-surface)",borderRadius:"16px",padding:"0",width:"600px",height:"500px",boxShadow:"0 20px 50px rgba(0,0,0,0.4)",border:"1px solid var(--glass-border)",display:"flex",flexDirection:"column",overflow:"hidden"},onClick:a=>a.stopPropagation(),children:[l.jsxs("div",{style:{padding:"20px 24px 0",borderBottom:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)"},children:[l.jsx("h3",{style:{marginTop:0,marginBottom:"16px",color:"var(--text-primary)",fontSize:"18px",fontWeight:"600"},children:"添加任务"}),l.jsx("div",{style:{display:"flex",gap:"24px"},children:ux.map(a=>l.jsx("button",{onClick:()=>t(a.key),style:{background:"none",border:"none",padding:"0 0 12px 0",fontSize:"14px",fontWeight:r===a.key?"600":"500",color:r===a.key?"var(--color-accent)":"var(--text-secondary)",borderBottom:r===a.key?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s"},children:a.label},a.key))})]}),l.jsx("div",{style:{flex:1,overflowY:"auto",padding:"24px",backgroundColor:"var(--bg-primary)"},children:l.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"12px"},children:s.map(a=>{const o=a.icon;return l.jsxs("button",{onClick:()=>e(a.type),style:{display:"flex",alignItems:"flex-start",gap:"16px",padding:"16px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"12px",cursor:"pointer",textAlign:"left",transition:"all 0.2s",color:"var(--text-primary)",position:"relative",overflow:"hidden"},onMouseEnter:i=>{i.currentTarget.style.borderColor="var(--color-accent)",i.currentTarget.style.backgroundColor="var(--bg-highlight)",i.currentTarget.style.transform="translateY(-2px)",i.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.1)"},onMouseLeave:i=>{i.currentTarget.style.borderColor="var(--border-primary)",i.currentTarget.style.backgroundColor="var(--bg-tertiary)",i.currentTarget.style.transform="translateY(0)",i.currentTarget.style.boxShadow="none"},children:[l.jsx("div",{style:{padding:"10px",borderRadius:"8px",backgroundColor:"var(--bg-secondary)",color:"var(--color-accent)",display:"flex",alignItems:"center",justifyContent:"center"},children:l.jsx(o,{size:24,strokeWidth:1.5})}),l.jsxs("div",{children:[l.jsx("div",{style:{fontWeight:"600",fontSize:"14px",marginBottom:"4px"},children:a.label}),l.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",lineHeight:"1.4"},children:a.description})]})]},a.type)})})}),l.jsx("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)",display:"flex",justifyContent:"flex-end"},children:l.jsx("button",{onClick:n,style:{padding:"8px 24px",backgroundColor:"transparent",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:"500",transition:"all 0.2s"},onMouseEnter:a=>a.currentTarget.style.backgroundColor="var(--bg-tertiary)",onMouseLeave:a=>a.currentTarget.style.backgroundColor="transparent",children:"取消"})})]}),l.jsx("style",{children:`
|
|
18
21
|
@keyframes fadeIn {
|
|
19
22
|
from { opacity: 0; }
|
|
20
23
|
to { opacity: 1; }
|
|
21
24
|
}
|
|
22
|
-
`})]})},
|
|
25
|
+
`})]})},jx=()=>{const{executionData:e,loadSampleExecution:n,importExecutionJSON:r,workflowInstance:t,setSelectedTask:s,nodes:a}=oe(),{fitView:o}=A.useReactFlow(),i=g=>{const m=g.target.files?.[0];if(m){const v=new FileReader;v.onload=y=>{try{const x=JSON.parse(y.target?.result);r(x)}catch(x){console.error("Failed to parse execution JSON:",x)}},v.readAsText(m)}};if(!e)return l.jsxs("div",{className:"execution-status-bar",children:[l.jsx("input",{type:"file",id:"execution-json-upload",accept:".json",onChange:i,style:{display:"none"}}),l.jsx("div",{className:"status-item",children:l.jsx("span",{className:"status-label",children:"准备就绪"})}),l.jsxs("div",{style:{display:"flex",gap:"8px"},children:[l.jsx("button",{onClick:n,style:{background:"var(--color-accent)",color:"#fff",border:"none",padding:"6px 14px",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:"600",boxShadow:"0 4px 12px rgba(0,0,0,0.2)",transition:"all 0.2s ease"},children:"🚀 加载示例运行"}),l.jsx("button",{onClick:()=>document.getElementById("execution-json-upload")?.click(),title:"上传 Conductor 运行态 JSON",style:{background:"rgba(255,255,255,0.1)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",padding:"6px 14px",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:"500",transition:"all 0.2s ease"},children:"📁 导入执行 JSON"})]})]});const u=Object.values(e),c=u.filter(g=>g.status==="COMPLETED").length,d=u.filter(g=>g.status==="FAILED"||g.status==="FAILED_WITH_TERMINAL_ERROR"||g.status==="TIMED_OUT"),f=d.length,p=u.filter(g=>g.status==="IN_PROGRESS"||g.status==="SCHEDULED").length,h=O.useCallback(()=>{if(f===0)return;const g=new Set(d.map(v=>v.taskReferenceName)),m=a.filter(v=>g.has(v.data?.taskReferenceName)).map(v=>v.id);m.length>0&&o({nodes:m.map(v=>({id:v})),duration:500,padding:.3})},[d,a,o,f]);return l.jsxs("div",{className:"execution-status-bar",children:[t&&l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:"status-item",children:[l.jsx("span",{className:"status-label",children:" Workflow ID:"}),l.jsx("span",{className:"status-value highlight",style:{color:"var(--text-primary)",opacity:.8},children:t.workflowId})]}),l.jsx("div",{className:"status-divider"})]}),l.jsxs("div",{className:"status-item",children:[l.jsx("span",{className:"status-label",children:"状态:"}),l.jsx("span",{className:"status-value highlight",style:{color:t?.status==="COMPLETED"?"var(--status-completed)":"var(--status-in-progress)"},children:t?.status||"运行中"})]}),l.jsx("div",{className:"status-divider"}),l.jsxs("div",{className:"status-item",children:[l.jsx("span",{className:"status-label",children:"已完成:"}),l.jsx("span",{className:"status-value",children:c})]}),l.jsxs("div",{className:"status-item",onClick:f>0?h:void 0,style:{cursor:f>0?"pointer":"default",borderRadius:"4px",padding:"2px 6px",transition:"background 0.2s",...f>0?{background:"rgba(239, 68, 68, 0.1)"}:{}},title:f>0?"点击聚焦失败节点":void 0,children:[l.jsx("span",{className:"status-label",style:{color:"var(--status-failed)"},children:"失败:"}),l.jsx("span",{className:"status-value",style:{color:"var(--status-failed)"},children:f})]}),l.jsxs("div",{className:"status-item",children:[l.jsx("span",{className:"status-label",style:{color:"var(--status-in-progress)"},children:"处理中:"}),l.jsx("span",{className:"status-value",style:{color:"var(--status-in-progress)"},children:p})]}),l.jsx("div",{className:"status-divider"}),l.jsx("div",{style:{display:"flex",gap:"8px"},children:l.jsx("button",{onClick:()=>{s({name:"Workflow Global Data",taskReferenceName:"__workflow_global__",type:"SIMPLE"})},style:{background:"rgba(255,255,255,0.05)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",padding:"4px 10px",borderRadius:"6px",cursor:"pointer",fontSize:"11px",fontWeight:"600"},children:"🔍 全局 I/O"})})]})},Fh=({isOpen:e,onClose:n,theme:r="dark",onTaskSelect:t})=>{const{validationResults:s,setSelectedTask:a,taskMap:o}=oe(),{errors:i,warnings:u}=s||{errors:[],warnings:[]},c=g=>{if(g&&g!=="UNKNOWN"){const m=o[g];m&&(t?t(m):a(m))}},d="var(--glass-surface)",f="var(--text-primary)",p="var(--glass-border)",h="var(--text-secondary)";return e?l.jsxs("div",{style:{position:"absolute",top:"80px",right:"24px",width:"320px",maxHeight:"500px",backgroundColor:d,border:`1px solid ${p}`,borderRadius:"12px",boxShadow:"0 10px 25px rgba(0,0,0,0.2)",zIndex:1100,display:"flex",flexDirection:"column",overflow:"hidden",animation:"fadeInSlide 0.2s ease-out"},children:[l.jsx("style",{children:`
|
|
23
26
|
@keyframes fadeInSlide {
|
|
24
27
|
from { opacity: 0; transform: translateY(-10px); }
|
|
25
28
|
to { opacity: 1; transform: translateY(0); }
|
|
26
29
|
}
|
|
27
30
|
.health-item:hover {
|
|
28
|
-
background-color: ${
|
|
31
|
+
background-color: ${r==="light"?"#f1f5f9":"rgba(255,255,255,0.05)"};
|
|
29
32
|
}
|
|
30
|
-
`}),l.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${p}`,display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"rgba(0,0,0,0.02)"},children:[l.jsxs("div",{style:{fontWeight:"bold",fontSize:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[l.jsx("span",{children:"🩺"})," 工作流体检报告"]}),l.jsx("button",{onClick:r,style:{background:"none",border:"none",color:h,cursor:"pointer",fontSize:"18px"},children:"✕"})]}),l.jsx("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:i.length===0&&d.length===0?l.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"#10b981"},children:[l.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:"✅"}),l.jsx("div",{style:{fontWeight:"bold"},children:"未发现问题"}),l.jsx("div",{style:{fontSize:"12px",opacity:.7,marginTop:"4px"},children:"工作流逻辑看起来很完美"})]}):l.jsxs(l.Fragment,{children:[i.map((g,m)=>l.jsxs("div",{className:"health-item",role:"button",tabIndex:g.ref?0:void 0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&c(g.ref)},onClick:()=>c(g.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:g.ref?"pointer":"default",borderLeft:"4px solid #ef4444",transition:"background 0.2s"},children:[l.jsxs("div",{style:{fontSize:"12px",color:"#ef4444",fontWeight:"bold",marginBottom:"2px"},children:["ERROR ",g.ref!=="UNKNOWN"&&`[${g.ref}]`]}),l.jsx("div",{style:{fontSize:"13px",color:f},children:g.message})]},`err-${m}`)),d.map((g,m)=>l.jsxs("div",{className:"health-item",role:"button",tabIndex:g.ref?0:void 0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&c(g.ref)},onClick:()=>c(g.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:g.ref?"pointer":"default",borderLeft:"4px solid #f59e0b",transition:"background 0.2s"},children:[l.jsxs("div",{style:{fontSize:"12px",color:"#f59e0b",fontWeight:"bold",marginBottom:"2px"},children:["WARNING ",g.ref!=="UNKNOWN"&&`[${g.ref}]`]}),l.jsx("div",{style:{fontSize:"13px",color:f},children:g.message})]},`warn-${m}`))]})}),l.jsxs("div",{style:{padding:"12px 16px",fontSize:"11px",color:h,borderTop:`1px solid ${p}`,backgroundColor:"rgba(0,0,0,0.02)",display:"flex",justifyContent:"space-between"},children:[l.jsxs("span",{children:["共 ",i.length," 个错误, ",d.length," 个警告"]}),i.length>0&&l.jsx("span",{style:{color:"#ef4444"},children:"无法保存/导出"})]})]}):null},Sx=({id:e,source:r,target:t,sourceX:n,sourceY:s,targetX:a,targetY:o,sourcePosition:i,targetPosition:d,style:c={},markerEnd:u,data:f})=>{const[p,h]=P.useState(!1),g=P.useRef(null),m=()=>{const N=f?.edgeType||"default",L={sourceX:n,sourceY:s,sourcePosition:i,targetX:a,targetY:o,targetPosition:d};switch(N){case"step":case"smoothstep":return A.getSmoothStepPath(L);case"straight":return A.getStraightPath(L);default:return A.getBezierPath(L)}},[v,y,x]=m(),b=N=>{N.stopPropagation(),N.preventDefault();const L=new CustomEvent("edgeAddNode",{detail:{id:e,source:r,target:t,edgeData:f}});window.dispatchEvent(L)},k=()=>{g.current&&clearTimeout(g.current),h(!0)},w=()=>{g.current=setTimeout(()=>{h(!1)},100)},j=f?.mode==="edit";return l.jsxs(l.Fragment,{children:[l.jsx(A.BaseEdge,{path:v,markerEnd:u,style:{...c,strokeWidth:p?4:2,stroke:p?"#fbbf24":c?.stroke,transition:"stroke 0.2s, stroke-width 0.2s",pointerEvents:"none"}}),l.jsx("path",{d:v,fill:"none",stroke:"transparent",strokeWidth:20,style:{cursor:j?"pointer":"default",pointerEvents:"all"},onMouseEnter:k,onMouseLeave:w}),j&&p&&l.jsx(A.EdgeLabelRenderer,{children:l.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${y}px,${x}px)`,fontSize:12,pointerEvents:"all",zIndex:2e3,display:"flex",flexDirection:"column",alignItems:"center"},className:"nodrag nopan",onMouseEnter:k,onMouseLeave:w,children:[f?.label&&l.jsx("div",{style:{background:"var(--glass-bg-accent)",backdropFilter:"var(--glass-blur)",color:"var(--color-accent)",padding:"4px 10px",borderRadius:"6px",fontSize:"11px",fontWeight:"700",marginBottom:"8px",border:"1px solid var(--color-accent)",boxShadow:"0 4px 12px rgba(0,0,0,0.3)",whiteSpace:"nowrap",letterSpacing:"0.5px"},children:f.label}),l.jsx("button",{style:{width:"32px",height:"32px",backgroundColor:"var(--color-accent)",color:"#fff",border:"2px solid rgba(255,255,255,0.8)",borderRadius:"50%",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"700",fontSize:"20px",boxShadow:"0 4px 15px rgba(var(--color-accent-rgb), 0.5)",transition:"all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},className:"edge-add-button",onClick:b,onMouseDown:N=>N.stopPropagation(),title:"在此处添加任务",children:"+"})]})})]})},Le=({onClick:e,icon:r,label:t,title:n,disabled:s=!1,active:a=!1,variant:o="default",style:i})=>{let d="var(--bg-tertiary)",c="var(--text-primary)",u="1px solid var(--border-primary)";return o==="primary"?(d="var(--color-accent)",c="#fff",u="none"):o==="danger"?(d=s?"rgba(239, 68, 68, 0.1)":"var(--status-failed)",c=s?"var(--text-secondary)":"#fff",u="none"):a&&(d="var(--bg-secondary)",c="var(--color-accent)",u="1px solid var(--color-accent)"),l.jsxs("button",{onClick:e,disabled:s,title:n,"aria-label":n||t,"aria-pressed":a,"aria-disabled":s,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:t?"6px":"0",background:d,color:c,border:u,borderRadius:"6px",padding:t?"6px 12px":"8px",cursor:s?"not-allowed":"pointer",opacity:s?.5:1,fontSize:"13px",fontWeight:500,transition:"all 0.2s",minWidth:t?"auto":"32px",height:"32px",boxShadow:o==="default"?"0 1px 2px rgba(0,0,0,0.05)":"none",...i},children:[r&&l.jsx("span",{style:{fontSize:"14px",display:"flex"},children:r}),t&&l.jsx("span",{children:t})]})},wx=()=>{const{zoomIn:e,zoomOut:r,fitView:t}=A.useReactFlow();return l.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px"},children:l.jsxs("div",{style:{display:"flex",background:"var(--bg-tertiary)",padding:"4px",borderRadius:"8px",border:"1px solid var(--border-primary)",gap:"4px",boxShadow:"0 2px 5px rgba(0,0,0,0.05)"},children:[l.jsx(Le,{icon:"➕",title:"放大",onClick:()=>e()}),l.jsx(Le,{icon:"➖",title:"缩小",onClick:()=>r()}),l.jsx(Le,{icon:"⤢",title:"适应屏幕",onClick:()=>t({duration:600})})]})})},Tx=({onShowHealthCheck:e,showHealthCheck:r,onShowSettings:t,executionActions:n})=>{const{mode:s,validationResults:a,workflowInstance:o,workflowDef:i}=ie(),d=ie.temporal,{undo:c,redo:u,pastStates:f,futureStates:p}=Xr(d,T=>T),[h,g]=P.useState(!1),m=P.useRef(null);P.useEffect(()=>{if(!h)return;const T=C=>{m.current&&!m.current.contains(C.target)&&g(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[h]);const v=(a?.errors?.length||0)>0,y=o?.status,x=o?.workflowId??"",b=y==="RUNNING",k=y==="PAUSED",w=y==="FAILED"||y==="TIMED_OUT"||y==="TERMINATED",j=y==="COMPLETED",N=i?.restartable===!0&&(w||j),L=n?.allowOperations!==!1;return l.jsxs("div",{className:"action-bar",style:{display:"flex",gap:"8px",alignItems:"center"},children:[s==="edit"&&l.jsxs(l.Fragment,{children:[l.jsx(Le,{icon:"↺",title:"撤销 (Cmd+Z)",onClick:()=>c(),disabled:f.length===0}),l.jsx(Le,{icon:"↻",title:"重做 (Cmd+Shift+Z)",onClick:()=>u(),disabled:p.length===0}),l.jsx("div",{style:{width:"1px",height:"20px",background:"var(--border-primary)",margin:"0 4px",alignSelf:"center"}}),l.jsx(Le,{icon:"🩺",label:v?`错误 (${a.errors.length})`:"诊断",title:"流程健康检查",onClick:e,active:r,variant:v?"danger":"secondary"}),l.jsx(Le,{icon:"⚙️",label:"配置",title:"工作流全局配置",onClick:()=>t?.()})]}),s==="run"&&o&&n&&l.jsxs(l.Fragment,{children:[k&&n.onResume&&l.jsx(Le,{icon:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("path",{d:"M4 3l9 5-9 5z"})}),label:"继续",title:L?"继续执行工作流":"操作权限受限",onClick:()=>L&&n.onResume(x),disabled:!L,variant:"primary"}),b&&n.onPause&&l.jsx(Le,{icon:l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:[l.jsx("rect",{x:"4",y:"3",width:"3",height:"10",rx:"1"}),l.jsx("rect",{x:"9",y:"3",width:"3",height:"10",rx:"1"})]}),label:"暂停",title:L?"暂停工作流执行":"操作权限受限",onClick:()=>L&&n.onPause(x),disabled:!L}),(b||k)&&n.onTerminate&&l.jsx(Le,{icon:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})}),label:"终止",title:L?"终止工作流执行":"操作权限受限",onClick:()=>L&&n.onTerminate(x),disabled:!L,variant:"danger"}),w&&n.onRetry&&l.jsx(Le,{icon:l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[l.jsx("path",{d:"M13 2v4h-4"}),l.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),label:"重试",title:L?"重试失败的工作流":"操作权限受限",onClick:()=>L&&n.onRetry(x),disabled:!L,variant:"primary"}),N&&n.onRestart&&l.jsxs("div",{ref:m,style:{position:"relative",display:"flex"},children:[l.jsxs("button",{disabled:!L,onClick:()=>L&&n.onRestart(x,{useLatestDef:!0}),title:L?"使用当前最新定义版本重新运行":"操作权限受限",style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--bg-tertiary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRight:"none",borderRadius:"6px 0 0 6px",padding:"6px 10px",cursor:L?"pointer":"not-allowed",opacity:L?1:.5,fontSize:"13px",fontWeight:500,height:"32px"},children:[l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[l.jsx("path",{d:"M3 14v-4h4"}),l.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"重启"]}),l.jsx("button",{disabled:!L,onClick:()=>L&&g(T=>!T),title:L?"展开重启版本选项":"操作权限受限",style:{display:"flex",alignItems:"center",justifyContent:"center",background:L&&h?"var(--bg-secondary)":"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border-primary)",borderRadius:"0 6px 6px 0",padding:"6px 6px",cursor:L?"pointer":"not-allowed",opacity:L?1:.5,height:"32px",width:"22px",fontSize:"10px"},children:l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:l.jsx("path",{d:"M1 3l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})})}),h&&l.jsxs("div",{style:{position:"absolute",top:"36px",right:0,background:"var(--glass-surface)",backdropFilter:"blur(12px)",border:"1px solid var(--glass-border)",borderRadius:"10px",boxShadow:"0 8px 24px rgba(0,0,0,0.25)",zIndex:2e3,minWidth:"180px",overflow:"hidden"},children:[l.jsx("div",{style:{padding:"6px 12px 4px",fontSize:"11px",color:"var(--text-secondary)",fontWeight:600,letterSpacing:"0.5px",textTransform:"uppercase"},children:"选择版本"}),l.jsxs("button",{onClick:()=>{n.onRestart(x,{useLatestDef:!0}),g(!1)},style:qh,onMouseEnter:T=>T.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:T=>T.currentTarget.style.background="transparent",children:[l.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("circle",{cx:"8",cy:"8",r:"6"}),l.jsx("path",{d:"M8 5v3l2 1"})]}),l.jsxs("div",{children:[l.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"当前版本"}),l.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用最新工作流定义"})]})]}),l.jsxs("button",{onClick:()=>{n.onRestart(x,{useLatestDef:!1}),g(!1)},style:qh,onMouseEnter:T=>T.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:T=>T.currentTarget.style.background="transparent",children:[l.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("rect",{x:"3",y:"2",width:"10",height:"12",rx:"1"}),l.jsx("path",{d:"M6 6h4M6 9h3"})]}),l.jsxs("div",{children:[l.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"执行版本"}),l.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用本次运行时的定义"})]})]})]})]})]})]})},qh={display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"8px 12px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",transition:"background 0.15s"};function Vr(e){return!e||e.length===0?[]:typeof e[0]=="string"?e.map(r=>({name:r})):e}const Ex=[{id:"basic",label:"基本信息"},{id:"timeout",label:"超时与容错"},{id:"params",label:"参数配置"},{id:"advanced",label:"高级设置"}],Nx=({isOpen:e,onClose:r})=>{const{workflowDef:t,updateWorkflowProperties:n,mode:s}=ie(),[a,o]=P.useState(t),[i,d]=P.useState("basic"),c=s!=="edit";P.useEffect(()=>{t&&o(t)},[t,e]);const u=P.useCallback(I=>{I.key==="Escape"&&r()},[r]);if(P.useEffect(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]),!e||!a)return null;const f="var(--text-primary)",p="var(--glass-border)",h="var(--bg-tertiary)",g="var(--text-secondary)",m=(I,O)=>{if(!a||c)return;const F={...a,[I]:O};o(F),n({[I]:O})},v=(I,O,F)=>{if(!a||c)return;const V={...a[I]||{},[O]:F};o(Z=>({...Z,[I]:V})),n({[I]:V})},y=(I,O)=>{if(!(!a||c))try{const F=JSON.parse(O),W={...a,[I]:F};o(W),n({[I]:F})}catch{o(F=>({...F,[`_${I}_str`]:O}))}},x={width:"100%",padding:"10px 14px",borderRadius:"8px",border:`1px solid ${p}`,background:h,color:f,fontSize:"14px",outline:"none",boxSizing:"border-box"},b={display:"block",fontSize:"11px",color:g,marginBottom:"8px",fontWeight:600},k=(I,O,F="text",W)=>l.jsxs("div",{style:{marginBottom:"20px"},children:[l.jsx("label",{style:b,children:I.toUpperCase()}),l.jsx("input",{className:"wsp-input",type:F,value:a?.[O]??"",onChange:V=>m(O,F==="number"?V.target.value===""?0:parseInt(V.target.value):V.target.value),disabled:c||W?.readOnly,placeholder:W?.placeholder,style:{...x,opacity:c||W?.readOnly?.6:1}})]}),w=(I,O,F=!1,W=6)=>{const V=a?.[`_${O}_str`]!==void 0?a[`_${O}_str`]:typeof a?.[O]=="object"?JSON.stringify(a[O],null,2):a?.[O];return l.jsxs("div",{style:{marginBottom:"20px"},children:[l.jsxs("label",{style:b,children:[I.toUpperCase()," ",F&&"(JSON)"]}),l.jsx("textarea",{className:"wsp-input",value:V||"",onChange:Z=>F?y(O,Z.target.value):m(O,Z.target.value),rows:W,disabled:c,style:{...x,fontSize:"13px",fontFamily:F?"var(--font-mono)":"inherit",resize:"vertical",opacity:c?.6:1}})]})},j=(I,O,F)=>l.jsxs("div",{style:{marginBottom:"20px"},children:[l.jsx("label",{style:b,children:I.toUpperCase()}),l.jsx("select",{className:"wsp-input",value:a?.[O]??F[0]?.value,onChange:W=>m(O,W.target.value),disabled:c,style:{...x,opacity:c?.6:1,cursor:c?"not-allowed":"pointer"},children:F.map(W=>l.jsx("option",{value:W.value,children:W.label},W.value))})]}),N=(I,O)=>{const F=!!a?.[O];return l.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[l.jsx("label",{style:{fontSize:"13px",color:f},children:I}),l.jsx("button",{type:"button",role:"switch","aria-checked":F,onClick:()=>!c&&m(O,!F),disabled:c,style:{width:"44px",height:"24px",borderRadius:"12px",border:"none",background:F?"var(--color-accent)":"var(--border-primary)",position:"relative",cursor:c?"not-allowed":"pointer",transition:"background 0.2s",opacity:c?.6:1,flexShrink:0},children:l.jsx("span",{style:{position:"absolute",top:"2px",left:F?"22px":"2px",width:"20px",height:"20px",borderRadius:"50%",background:"var(--text-inverse)",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})]})},L=()=>l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"3fr 1fr",gap:"20px"},children:[k("工作流名称","name"),k("版本号","version","number")]}),w("描述信息","description",!1,3),k("负责人邮箱","ownerEmail","text",{placeholder:"owner@example.com"}),k("Schema 版本","schemaVersion","number",{readOnly:!0})]}),T=()=>l.jsxs(l.Fragment,{children:[j("超时策略","timeoutPolicy",[{value:"ALERT_ONLY",label:"ALERT_ONLY — 仅告警"},{value:"TIME_OUT_WF",label:"TIME_OUT_WF — 超时终止"}]),l.jsxs("div",{children:[k("超时秒数","timeoutSeconds","number",{placeholder:"0 表示不超时"}),a?.timeoutPolicy==="ALERT_ONLY"&&l.jsx("p",{style:{fontSize:"11px",color:g,marginTop:"-12px",marginBottom:"20px"},children:"当前策略为 ALERT_ONLY,超时仅触发告警,不会终止工作流。"})]}),k("失败补偿工作流","failureWorkflow","text",{placeholder:"输入补偿工作流名称"}),N("允许重启 (restartable)","restartable")]}),C=()=>{const I=Vr(a?.inputParameters),O=ne=>{c||m("inputParameters",ne)},F=()=>{const ne=[...I,{name:`param_${I.length+1}`,type:"string",required:!1}];O(ne)},W=ne=>{const ee=I.filter((D,Y)=>Y!==ne);O(ee)},V=(ne,ee,D)=>{const Y=I.map((se,R)=>R===ne?{...se,[ee]:D}:se);O(Y)},Z={padding:"6px 10px",borderRadius:"6px",border:`1px solid ${p}`,background:h,color:f,fontSize:"12px",outline:"none",fontFamily:"inherit"};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{marginBottom:"20px"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[l.jsx("label",{style:b,children:"入参声明 (INPUT PARAMETERS)"}),!c&&l.jsx("button",{onClick:F,style:{background:"var(--color-accent)",color:"var(--text-inverse)",border:"none",borderRadius:"6px",padding:"5px 12px",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"+ 添加参数"})]}),I.length===0?l.jsx("p",{style:{fontSize:"12px",color:g,margin:0,padding:"12px",background:"var(--bg-secondary)",borderRadius:"8px",border:`1px solid ${p}`},children:'暂无入参声明。点击"+ 添加参数"来定义工作流的输入参数,这些参数将在执行验证时作为表单字段展示。'}):l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:I.map((ne,ee)=>l.jsxs("div",{style:{background:"var(--bg-secondary)",border:`1px solid ${p}`,borderRadius:"10px",padding:"12px"},children:[l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr auto auto",gap:"8px",alignItems:"center"},children:[l.jsx("input",{style:Z,placeholder:"参数名",value:ne.name,onChange:D=>V(ee,"name",D.target.value),disabled:c}),l.jsx("select",{style:{...Z,cursor:c?"not-allowed":"pointer"},value:ne.type??"string",onChange:D=>V(ee,"type",D.target.value),disabled:c,children:["string","number","boolean","object","array"].map(D=>l.jsx("option",{value:D,children:D},D))}),l.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:g,cursor:c?"not-allowed":"pointer",whiteSpace:"nowrap"},children:[l.jsx("input",{type:"checkbox",checked:!!ne.required,onChange:D=>V(ee,"required",D.target.checked),disabled:c,style:{accentColor:"var(--color-accent)"}}),"必填"]}),!c&&l.jsx("button",{onClick:()=>W(ee),style:{background:"none",border:"none",color:"var(--status-failed)",cursor:"pointer",fontSize:"16px",padding:"0 4px",opacity:.7,lineHeight:1},children:"✕"})]}),l.jsxs("div",{style:{marginTop:"8px",display:"flex",flexDirection:"column",gap:"6px"},children:[l.jsx("input",{style:Z,placeholder:"说明(可选)",value:ne.description??"",onChange:D=>V(ee,"description",D.target.value),disabled:c}),l.jsx("input",{style:Z,placeholder:`示例值(如 ${ne.type==="number"?"42":ne.type==="boolean"?"true":'"value"'})`,value:ne.example!==void 0?typeof ne.example=="object"?JSON.stringify(ne.example):String(ne.example):"",onChange:D=>{let Y=D.target.value;try{Y=JSON.parse(D.target.value)}catch{}V(ee,"example",Y)},disabled:c})]})]},ee))})]}),w("输出参数映射 (outputParameters)","outputParameters",!0),w("默认输入模板 (inputTemplate)","inputTemplate",!0),w("工作流级变量 (variables)","variables",!0)]})},S=()=>l.jsxs(l.Fragment,{children:[N("启用状态监听 (workflowStatusListenerEnabled)","workflowStatusListenerEnabled"),a?.workflowStatusListenerEnabled&&k("状态事件目标 (Listener Sink)","workflowStatusListenerSink","text",{placeholder:"conductor:workflow_status_event"}),l.jsxs("div",{style:{borderTop:`1px solid ${p}`,marginTop:"8px",paddingTop:"20px"},children:[N("强制 Schema 校验 (enforceSchema)","enforceSchema"),a?.enforceSchema&&l.jsxs(l.Fragment,{children:[w("输入 Schema (inputSchema)","inputSchema",!0,4),w("输出 Schema (outputSchema)","outputSchema",!0,4)]})]}),l.jsxs("div",{style:{borderTop:`1px solid ${p}`,marginTop:"8px",paddingTop:"20px"},children:[l.jsx("label",{style:{...b,marginBottom:"16px"},children:"并发限流 (RATE LIMIT)"}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"20px"},children:[l.jsxs("div",{children:[l.jsx("label",{style:b,children:"RATE LIMIT KEY"}),l.jsx("input",{className:"wsp-input",type:"text",value:a?.rateLimitConfig?.rateLimitKey??"",onChange:I=>v("rateLimitConfig","rateLimitKey",I.target.value),disabled:c,placeholder:"限流键",style:{...x,opacity:c?.6:1}})]}),l.jsxs("div",{children:[l.jsx("label",{style:b,children:"并发上限"}),l.jsx("input",{className:"wsp-input",type:"number",value:a?.rateLimitConfig?.concurrentExecLimit??"",onChange:I=>v("rateLimitConfig","concurrentExecLimit",I.target.value===""?0:parseInt(I.target.value)),disabled:c,placeholder:"0",style:{...x,opacity:c?.6:1}})]})]})]})]}),q=()=>{switch(i){case"basic":return L();case"timeout":return T();case"params":return C();case"advanced":return S()}};return l.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"工作流全局配置",onClick:r,style:{position:"fixed",left:0,top:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.5)",zIndex:1300,display:"flex",justifyContent:"center",alignItems:"center",backdropFilter:"blur(4px)",animation:"fadeIn 0.2s ease"},children:l.jsxs("div",{onClick:I=>I.stopPropagation(),style:{width:"680px",maxHeight:"85vh",background:"var(--glass-surface)",borderRadius:"16px",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.5)",display:"flex",flexDirection:"column",overflow:"hidden",animation:"slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1)",border:`1px solid ${p}`,backdropFilter:"blur(20px)"},children:[l.jsxs("div",{style:{padding:"24px 32px 0 32px",background:"var(--bg-highlight)"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[l.jsxs("div",{children:[l.jsx("h2",{style:{margin:0,fontSize:"20px",color:f},children:"工作流全局配置"}),l.jsx("p",{style:{margin:"4px 0 0 0",fontSize:"12px",color:g},children:c?"当前为只读模式":"配置工作流级属性,所有更改将实时保存"})]}),l.jsx("button",{className:"wsp-close",onClick:r,"aria-label":"关闭",style:{background:"none",border:"none",color:f,fontSize:"24px",cursor:"pointer",opacity:.6},children:"✕"})]}),l.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${p}`},children:Ex.map(I=>l.jsx("button",{className:"wsp-tab",onClick:()=>d(I.id),style:{padding:"10px 20px",fontSize:"13px",fontWeight:i===I.id?600:400,color:i===I.id?"var(--color-accent)":g,background:"none",border:"none",borderBottom:i===I.id?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s",marginBottom:"-1px"},children:I.label},I.id))})]}),l.jsx("div",{style:{flex:1,overflowY:"auto",padding:"28px 32px"},children:q()}),l.jsx("div",{style:{padding:"20px 32px",borderTop:`1px solid ${p}`,background:"var(--bg-highlight)",display:"flex",justifyContent:"flex-end"},children:l.jsx("button",{className:"wsp-footer-btn",onClick:r,style:{padding:"12px 32px",background:"var(--color-accent)",color:"var(--text-inverse)",border:"none",borderRadius:"12px",fontWeight:"bold",cursor:"pointer",boxShadow:"0 4px 12px var(--color-accent-bg)"},children:"完成并关闭"})})]})})},Cx=({onRequestImport:e})=>{const{createBlankWorkflow:r}=ie(),[t,n]=P.useState(""),s=()=>{r(t||void 0),ie.temporal.getState().clear()},a=()=>{r(t||void 0),ie.temporal.getState().clear(),window.dispatchEvent(new CustomEvent("open-ai-chat"))};return l.jsxs("div",{className:"empty-state-panel",children:[l.jsx("h2",{className:"empty-state-title",children:"创建新工作流"}),l.jsx("p",{className:"empty-state-subtitle",children:"从空白画布开始设计,或让 AI 帮你生成完整流程"}),l.jsx("input",{className:"empty-state-name-input",type:"text",placeholder:"工作流名称(可选)",value:t,onChange:o=>n(o.target.value),onKeyDown:o=>{o.key==="Enter"&&s()}}),l.jsxs("div",{className:"empty-state-actions",children:[l.jsxs("button",{className:"empty-state-btn primary",onClick:s,children:[l.jsx("span",{className:"empty-state-btn-icon",children:"📄"}),"空白工作流"]}),l.jsxs("button",{className:"empty-state-btn",onClick:a,children:[l.jsx("span",{className:"empty-state-btn-icon",children:"✨"}),"AI 生成"]}),e&&l.jsxs("button",{className:"empty-state-btn",onClick:e,children:[l.jsx("span",{className:"empty-state-btn-icon",children:"📤"}),"导入 JSON"]})]})]})},jx={success:{bg:"#10b981",text:"#fff"},error:{bg:"#ef4444",text:"#fff"},info:{bg:"var(--color-accent)",text:"#fff"}},Ix=({messages:e,onDismiss:r})=>e.length===0?null:l.jsx("div",{style:{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",zIndex:3e3,display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none"},children:e.map(t=>l.jsx(Rx,{message:t,onDismiss:r},t.id))}),Rx=({message:e,onDismiss:r})=>{const t=jx[e.type||"info"];return P.useEffect(()=>{const n=setTimeout(()=>r(e.id),2500);return()=>clearTimeout(n)},[e.id,r]),l.jsx("div",{role:"status","aria-live":"polite",style:{backgroundColor:t.bg,color:t.text,padding:"10px 20px",borderRadius:"8px",fontSize:"13px",fontWeight:500,boxShadow:"0 4px 16px rgba(0,0,0,0.2)",animation:"toastSlideUp 0.3s ease-out",pointerEvents:"auto",cursor:"pointer",whiteSpace:"nowrap"},onClick:()=>r(e.id),children:e.text})},Dh=["shift","alt","meta","mod","ctrl","control"],Ox={esc:"escape",return:"enter",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function Ke(e){return(Ox[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Mh(e){return Dh.includes(e)}function Fi(e,r=","){return e.toLowerCase().split(r)}function $i(e,r="+",t=">",n=!1,s){let a=[],o=!1;e=e.trim(),e.includes(t)?(o=!0,a=e.toLocaleLowerCase().split(t).map(c=>Ke(c))):a=e.toLocaleLowerCase().split(r).map(c=>Ke(c));const i={alt:a.includes("alt"),ctrl:a.includes("ctrl")||a.includes("control"),shift:a.includes("shift"),meta:a.includes("meta"),mod:a.includes("mod"),useKey:n},d=a.filter(c=>!Dh.includes(c));return{...i,keys:d,description:s,isSequence:o,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Wh([Ke(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&Bh([Ke(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{$e.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{$e.clear()},0)}));const $e=new Set;function zi(e){return Array.isArray(e)}function Px(e,r=","){return(zi(e)?e:e.split(r)).every(t=>$e.has(t.trim().toLowerCase()))}function Wh(e){const r=Array.isArray(e)?e:[e];$e.has("meta")&&$e.forEach(t=>!Mh(t)&&$e.delete(t.toLowerCase())),r.forEach(t=>$e.add(t.toLowerCase()))}function Bh(e){const r=Array.isArray(e)?e:[e];e==="meta"?$e.clear():r.forEach(t=>$e.delete(t.toLowerCase()))}function Ax(e,r,t){(typeof t=="function"&&t(e,r)||t===!0)&&e.preventDefault()}function Lx(e,r,t){return typeof t=="function"?t(e,r):t===!0||t===void 0}const qx=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Dx(e){return Fh(e,qx)}function Fh(e,r=!1){const{target:t,composed:n}=e;let s,a;return Mx(t)&&n?(s=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(s=t&&t.tagName,a=t&&t.role),zi(r)?!!(s&&r&&r.some(o=>o.toLowerCase()===s.toLowerCase()||o===a)):!!(s&&r&&r)}function Mx(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Wx(e,r){return e.length===0&&r?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):r?e.some(t=>r.includes(t))||e.includes("*"):!0}const Bx=(e,r,t=!1)=>{const{alt:n,meta:s,mod:a,shift:o,ctrl:i,keys:d,useKey:c}=r,{code:u,key:f,ctrlKey:p,metaKey:h,shiftKey:g,altKey:m}=e,v=Ke(u);if(c&&d?.length===1&&d.includes(f))return!0;if(!d?.includes(v)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(v))return!1;if(!t){if(n!==m&&v!=="alt"||o!==g&&v!=="shift")return!1;if(a){if(!h&&!p)return!1}else if(s!==h&&v!=="meta"&&v!=="os"||i!==p&&v!=="ctrl"&&v!=="control")return!1}return d&&d.length===1&&d.includes(v)?!0:d?Px(d):!d},Fx=P.createContext(void 0),$x=()=>P.useContext(Fx);function $h(e,r){return e&&r&&typeof e=="object"&&typeof r=="object"?Object.keys(e).length===Object.keys(r).length&&Object.keys(e).reduce((t,n)=>t&&$h(e[n],r[n]),!0):e===r}const zx=P.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Hx=()=>P.useContext(zx);function Kx(e){const r=P.useRef(void 0);return $h(r.current,e)||(r.current=e),r.current}const zh=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},Ux=typeof window<"u"?P.useLayoutEffect:P.useEffect;function cr(e,r,t,n){const s=P.useRef(null),a=P.useRef(!1),o=Array.isArray(t)?Array.isArray(n)?void 0:n:t,i=zi(e)?e.join(o?.delimiter):e,d=Array.isArray(t)?t:Array.isArray(n)?n:void 0,c=P.useCallback(r,d??[]),u=P.useRef(c);d?u.current=c:u.current=r;const f=Kx(o),{activeScopes:p}=Hx(),h=$x();return Ux(()=>{if(f?.enabled===!1||!Wx(p,f?.scopes))return;let g=[],m;const v=(k,w=!1)=>{if(!(Dx(k)&&!Fh(k,f?.enableOnFormTags))){if(s.current!==null){const j=s.current.getRootNode();if((j instanceof Document||j instanceof ShadowRoot)&&j.activeElement!==s.current&&!s.current.contains(j.activeElement)){zh(k);return}}k.target?.isContentEditable&&!f?.enableOnContentEditable||Fi(i,f?.delimiter).forEach(j=>{if(j.includes(f?.splitKey??"+")&&j.includes(f?.sequenceSplitKey??">")){console.warn(`Hotkey ${j} contains both ${f?.splitKey??"+"} and ${f?.sequenceSplitKey??">"} which is not supported.`);return}const N=$i(j,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description);if(N.isSequence){m=setTimeout(()=>{g=[]},f?.sequenceTimeoutMs??1e3);const L=N.useKey?k.key:Ke(k.code);if(Mh(L.toLowerCase()))return;g.push(L);const T=N.keys?.[g.length-1];if(L!==T){g=[],m&&clearTimeout(m);return}g.length===N.keys?.length&&(u.current(k,N),m&&clearTimeout(m),g=[])}else if(Bx(k,N,f?.ignoreModifiers)||N.keys?.includes("*")){if(f?.ignoreEventWhen?.(k)||w&&a.current)return;if(Ax(k,N,f?.preventDefault),!Lx(k,N,f?.enabled)){zh(k);return}u.current(k,N),w||(a.current=!0)}})}},y=k=>{k.code!==void 0&&(Wh(Ke(k.code)),(f?.keydown===void 0&&f?.keyup!==!0||f?.keydown)&&v(k))},x=k=>{k.code!==void 0&&(Bh(Ke(k.code)),a.current=!1,f?.keyup&&v(k,!0))},b=s.current||o?.document||document;return b.addEventListener("keyup",x,o?.eventListenerOptions),b.addEventListener("keydown",y,o?.eventListenerOptions),h&&Fi(i,f?.delimiter).forEach(k=>h.addHotkey($i(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),()=>{b.removeEventListener("keyup",x,o?.eventListenerOptions),b.removeEventListener("keydown",y,o?.eventListenerOptions),h&&Fi(i,f?.delimiter).forEach(k=>h.removeHotkey($i(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),g=[],m&&clearTimeout(m)}},[i,f,p]),s}const Jx=e=>{const{mode:r,removeNode:t,selectedTask:n,pasteTask:s}=ie(),a=ie.temporal,{undo:o,redo:i}=Xr(a,p=>p),d=e?.confirm||(p=>Promise.resolve(window.confirm(p))),c=e?.showToast,u=p=>{const h=p.target;return h.tagName==="INPUT"||h.tagName==="TEXTAREA"||h.isContentEditable},f=()=>{requestAnimationFrame(()=>{const p=ie.getState(),{nodes:h,edges:g}=_e(p.nodes,p.edges,{direction:p.layoutDirection,mode:p.mode});ie.setState({nodes:h,edges:g})})};return cr("mod+z",p=>{r==="edit"&&(u(p)||(p.preventDefault(),o(),f()))},[r,o]),cr(["mod+shift+z","mod+y"],p=>{r==="edit"&&(u(p)||(p.preventDefault(),i(),f()))},[r,i]),cr("delete, backspace",p=>{r!=="edit"||!n||u(p)||(p.preventDefault(),d("确定要删除此任务吗?").then(h=>{h&&t(n.taskReferenceName)}))},[r,n,t,d]),cr("mod+c",p=>{if(!(r!=="edit"||!n)&&!u(p)){if(n.type==="JOIN"){c?.("JOIN 任务不能独立复制","error");return}p.preventDefault();try{localStorage.setItem("conductor-clipboard",JSON.stringify(n)),c?.("任务已复制","success")}catch{c?.("复制失败","error")}}},[r,n,c]),cr("mod+v",p=>{if(r==="edit"&&!u(p)){p.preventDefault();try{const h=localStorage.getItem("conductor-clipboard");if(h){const g=JSON.parse(h);s(g),c?.("任务已粘贴","success")}}catch{c?.("粘贴失败","error")}}},[r,s,c]),cr("mod+s",p=>{p.preventDefault();const h=ie.getState().workflowDef;h&&e?.onSave&&e.onSave(h)},[e?.onSave]),{}},Gx=()=>{const[e,r]=P.useState(null),t=P.useCallback(a=>new Promise(o=>{r({message:a,resolve:o})}),[]),n=P.useCallback(()=>{e?.resolve(!0),r(null)},[e]),s=P.useCallback(()=>{e?.resolve(!1),r(null)},[e]);return{confirm:t,confirmState:e,handleConfirm:n,handleCancel:s}},Vx=()=>{const[e,r]=P.useState([]),t=P.useCallback((s,a="info")=>{const o=Date.now().toString();r(i=>[...i,{id:o,text:s,type:a}])},[]),n=P.useCallback(s=>{r(a=>a.filter(o=>o.id!==s))},[]);return{toasts:e,showToast:t,dismissToast:n}},Yx={taskNode:cx,decisionNode:dx,forkNode:Ah.ForkNode,joinNode:Ah.JoinNode,loopNode:px,subWorkflowNode:mx,plusNode:yx,dynamicPlaceholderNode:bx},Xx={addableEdge:Sx},Zx=({onNodeClick:e,searchQuery:r="",onSave:t,onRequestImport:n,executionActions:s})=>{const{nodes:a,edges:o,onNodesChange:i,onEdgesChange:d,onConnect:c,mode:u,viewMode:f,selectedTask:p,setSelectedTask:h,theme:g,edgeType:m,addNode:v,nodesLocked:y,executionData:x,validationResults:b,setIsDetailPanelOpen:k,workflowDef:w,dynamicRuntimeTasksByFork:j,layoutDirection:N,simState:L,workflowLoadKey:T}=ie(),C=P.useMemo(()=>{if(u==="run"||u==="edit")return new Set(a.map(K=>K.id));const H=ax[f],$=new Set;return a.forEach(K=>{if(K.type==="plusNode"||K.type==="dynamicPlaceholderNode"){$.add(K.id);return}if(K.parentId)return;const J=Xe.find(te=>te.type===K.data.taskType)?.viewCategory??"business";H.includes(J)&&$.add(K.id)}),a.forEach(K=>{K.parentId&&$.has(K.parentId)&&$.add(K.id)}),$},[a,f,u]),S=P.useCallback(H=>{if(C.size===a.length)return H;const $={};H.forEach(J=>{$[J.source]||($[J.source]=[]),$[J.source].push(J)});const K=[],U=new Set;return H.forEach(J=>{if(!C.has(J.source))return;if(C.has(J.target)){const fe=`${J.source}->${J.target}`;U.has(fe)||(U.add(fe),K.push(J));return}const te=[{to:J.target,label:J.label}],ue=new Set;for(;te.length;){const fe=te.shift();if(!ue.has(fe.to)){if(ue.add(fe.to),C.has(fe.to)){const me=`${J.source}->${fe.to}`;U.has(me)||(U.add(me),K.push({...J,id:me,target:fe.to,label:fe.label??J.label}));continue}($[fe.to]??[]).forEach(me=>te.push({to:me.target,label:fe.label??me.label}))}}}),K},[C,a.length]),{fitView:q}=A.useReactFlow(),[I,O]=P.useState(!1),[F,W]=P.useState(null),[V,Z]=P.useState(!1),[ne,ee]=P.useState(!1),{confirm:D,confirmState:Y,handleConfirm:se,handleCancel:R}=Gx(),{toasts:M,showToast:_,dismissToast:B}=Vx();Jx({confirm:D,showToast:_,onSave:t}),P.useEffect(()=>{if(p){const H=a.find($=>$.data.taskReferenceName===p.taskReferenceName);H&&q({nodes:[H],duration:800,padding:.5})}},[p?.taskReferenceName,q]),P.useEffect(()=>{const H=()=>{q({duration:800})};return window.addEventListener("workflow-zoom-to-fit",H),()=>window.removeEventListener("workflow-zoom-to-fit",H)},[q]),P.useEffect(()=>{if(T===0)return;const H=setTimeout(()=>{q({duration:600,padding:.12})},50);return()=>clearTimeout(H)},[T,q]),P.useEffect(()=>{const H=U=>{e&&U.detail&&U.detail.task&&e(U.detail.task)},$=U=>{if(u==="edit"){const{loopId:J,afterRef:te}=U.detail;W(te?{sourceId:te,edgeData:{}}:{sourceId:J,edgeData:{isLoopAdd:!0}}),O(!0)}},K=U=>{u==="edit"&&(W({sourceId:U.detail.source,targetId:U.detail.target,edgeId:U.detail.id,edgeData:U.detail.edgeData}),O(!0))};return document.addEventListener("miniTaskClick",H),document.addEventListener("loopAddNodeRequested",$),window.addEventListener("edgeAddNode",K),()=>{document.removeEventListener("miniTaskClick",H),document.removeEventListener("loopAddNodeRequested",$),window.removeEventListener("edgeAddNode",K)}},[u,e]);const z=P.useCallback(H=>{if(F){const{sourceId:$,targetId:K,edgeId:U,edgeData:J}=F;v({data:{label:`New ${H}`,taskReferenceName:`${H.toLowerCase()}_${Date.now()}`,taskType:H}},$,K,U,J)}O(!1),W(null)},[F,v]),Q=P.useMemo(()=>{const H={extraNodes:[],extraEdges:[],removedEdgeIds:new Set,removedNodeIds:new Set};if(u!=="run")return H;const $=a.filter(pe=>pe.type==="forkNode"&&pe.data.taskType==="FORK_JOIN_DYNAMIC");if(!$.length)return H;const K=[],U=[],J=new Set,te=new Set,ue=N==="LR",fe=47,me=120,de={animated:!0,style:{stroke:"#10b981",strokeDasharray:"4,4"},markerEnd:{type:A.MarkerType.ArrowClosed,color:"#10b981"}};for(const pe of $){const ve=j[pe.id]||[],Te=`${pe.id}_dynamic_placeholder`,ye=a.find(re=>re.id===Te),E=o.find(re=>re.target===Te),X=o.find(re=>re.source===Te);let ae,le;if(X)ae=X.target,le=a.find(re=>re.id===ae);else{const re=a.indexOf(pe);if(le=a.slice(re).find(xe=>xe.type==="joinNode"),!le)continue;ae=le.id}if(!le||(X&&J.add(X.id),E&&J.add(E.id),te.add(Te),!ve.length))continue;const ce=ve.length,he=ye?ye.position.x+110:(pe.position.x+le.position.x)/2,ke=ye?ye.position.y+35:(pe.position.y+le.position.y)/2;ve.forEach((re,xe)=>{const Ue=`dynamic_rt_${re.referenceTaskName}`,We=ue?he-me:pe.position.x+(xe-(ce-1)/2)*280,Hi=ue?ke-fe+(xe-(ce-1)/2)*110:ke-fe;K.push({id:Ue,type:"taskNode",data:{label:re.referenceTaskName,task:{name:re.referenceTaskName,taskReferenceName:re.referenceTaskName,type:re.taskType||"SIMPLE"},taskReferenceName:re.referenceTaskName,taskType:re.taskType||"SIMPLE",isDynamicRuntime:!0,layoutDirection:N},position:{x:We,y:Hi}}),U.push({id:`e-${pe.id}-${Ue}`,source:pe.id,target:Ue,...de}),U.push({id:`e-${Ue}-${ae}`,source:Ue,target:ae,...de})})}return{extraNodes:K,extraEdges:U,removedEdgeIds:J,removedNodeIds:te}},[u,j,a,o,N]),G=P.useMemo(()=>[...S(o.filter(K=>!Q.removedEdgeIds.has(K.id))).map(K=>{const U=K.id.includes("loop-back"),J=g==="light"?"#64748b":"#94a3b8";let ue={...{...K.style,stroke:J,strokeWidth:2,strokeDasharray:U?"5,5":void 0}},fe=!1;if(u==="run"&&x){const ve=x[K.source]?.status,Te=x[K.target]?.status,ye=ve==="COMPLETED";ye&&Te==="COMPLETED"?(ue={...ue,stroke:"var(--status-completed)",strokeWidth:4},fe=!1):ye&&Te==="IN_PROGRESS"&&(ue={...ue,stroke:"var(--status-in-progress)",strokeWidth:4},fe=!0)}const me=K.source.endsWith("_dynamic_placeholder")||K.target.endsWith("_dynamic_placeholder"),de=K.source==="__workflow_start__"||K.source.startsWith("__loop_start__");return{...K,type:u==="edit"&&!U&&!me&&!de?"addableEdge":m,data:{...K.data,mode:u,edgeType:m,label:K.label},markerEnd:{type:A.MarkerType.ArrowClosed,width:20,height:20,color:ue.stroke},style:ue,animated:fe}}),...Q.extraEdges],[o,m,g,u,x,Q,S]);return l.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",background:"var(--bg-secondary)"},children:[l.jsxs(A,{nodes:P.useMemo(()=>{const H=new Set(b.errors.filter(J=>J.type==="TASK").map(J=>J.ref)),$=new Set(b.warnings.filter(J=>J.type==="TASK").map(J=>J.ref)),K=r.toLowerCase();return a.filter(J=>!Q.removedNodeIds.has(J.id)&&C.has(J.id)).map(J=>{const te=J.data.taskReferenceName,ue=L[te];return{...J,selected:p?.taskReferenceName===te,data:{...J.data,isError:u==="edit"&&H.has(te),hasWarning:u==="edit"&&$.has(te),isHighlighted:r?J.data.label.toLowerCase().includes(K)||J.data.taskReferenceName.toLowerCase().includes(K):!1,simRunning:ue==="running",simDone:ue==="done"}}}).concat(Q.extraNodes.map(J=>({...J,data:{...J.data,isError:!1,hasWarning:!1,isHighlighted:!1}})))},[a,b,r,p,Q,C,L,u]),edges:G,onNodesChange:i,onEdgesChange:d,onConnect:c,nodeTypes:Yx,edgeTypes:Xx,onNodeClick:(H,$)=>{if($.type==="plusNode"){W({sourceId:$.data.parentRef,edgeData:$.data.edgeData||{}}),O(!0);return}if($.type==="loopNode"){const U=$.data.task||null;h(U),e&&e(U);return}const K=$.data.task||null;h(K),e&&e(K)},onPaneClick:()=>{h(null),u!=="run"&&k(!1)},fitView:!0,nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!0,minZoom:.2,maxZoom:2,children:[l.jsx(A.Background,{color:"var(--border-primary)",gap:20}),l.jsx(A.Panel,{position:"bottom-left",style:{marginBottom:"20px",marginLeft:"20px",zIndex:1e3},children:l.jsx(wx,{})}),u==="run"&&l.jsx(A.Panel,{position:"bottom-center",children:l.jsx(_x,{})}),l.jsx(Lh,{isOpen:V,onClose:()=>Z(!1),theme:g,onTaskSelect:H=>{h(H)}}),l.jsx("div",{style:{position:"absolute",top:20,right:20,zIndex:1e3},children:l.jsx(Tx,{onShowHealthCheck:()=>Z(!V),showHealthCheck:V,onShowSettings:()=>ee(!0),executionActions:s})})]}),!w&&l.jsx(Cx,{onRequestImport:n}),w&&a.length===0&&u==="edit"&&l.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:10,display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:l.jsxs("button",{className:"empty-state-btn primary",style:{padding:"12px 24px",borderRadius:"8px",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",fontSize:"16px",fontWeight:500,boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},onClick:()=>{W({sourceId:"start",targetId:"end",edgeId:"new",edgeData:{}}),O(!0)},children:[l.jsx("span",{style:{fontSize:"20px",lineHeight:1},children:"+"}),"添加第一个任务"]})}),I&&l.jsx(kx,{theme:g,onSelect:z,onCancel:()=>O(!1)}),l.jsx(Nx,{isOpen:ne,onClose:()=>ee(!1)}),Y&&l.jsx(Jr,{message:Y.message,onConfirm:se,onCancel:R}),l.jsx(Ix,{messages:M,onDismiss:B})]})},Hh={apiKey:"",baseUrl:"https://api.openai.com/v1",model:"gpt-4o"},Kh=async(e,r={},t)=>{const n={...Hh,...r};if(!n.apiKey)throw new Error("Please configure AI API Key in settings.");const s=await fetch(`${n.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.apiKey}`},body:JSON.stringify({model:n.model,messages:e,temperature:.7,stream:!1}),signal:t});if(!s.ok){const o=await s.json();throw new Error(o.error?.message||"AI request failed")}return(await s.json()).choices[0].message.content},Qx=async(e,r={},t,n,s)=>{const a={...Hh,...r};if(!a.apiKey)throw new Error("Please configure AI API Key in settings.");const o=await fetch(`${a.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.apiKey}`},body:JSON.stringify({model:a.model,messages:e,temperature:.7,stream:!0}),signal:s});if(!o.ok){const u=await o.json();throw new Error(u.error?.message||"AI request failed")}const i=o.body?.getReader();if(!i)throw new Error("ReadableStream not supported");const d=new TextDecoder;let c="";for(;;){const{done:u,value:f}=await i.read();if(u)break;const h=d.decode(f,{stream:!0}).split(`
|
|
31
|
-
|
|
33
|
+
`}),l.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${p}`,display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"rgba(0,0,0,0.02)"},children:[l.jsxs("div",{style:{fontWeight:"bold",fontSize:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[l.jsx("span",{children:"🩺"})," 工作流体检报告"]}),l.jsx("button",{onClick:n,style:{background:"none",border:"none",color:h,cursor:"pointer",fontSize:"18px"},children:"✕"})]}),l.jsx("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:i.length===0&&u.length===0?l.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"#10b981"},children:[l.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:"✅"}),l.jsx("div",{style:{fontWeight:"bold"},children:"未发现问题"}),l.jsx("div",{style:{fontSize:"12px",opacity:.7,marginTop:"4px"},children:"工作流逻辑看起来很完美"})]}):l.jsxs(l.Fragment,{children:[i.map((g,m)=>l.jsxs("div",{className:"health-item",role:"button",tabIndex:g.ref?0:void 0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&c(g.ref)},onClick:()=>c(g.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:g.ref?"pointer":"default",borderLeft:"4px solid #ef4444",transition:"background 0.2s"},children:[l.jsxs("div",{style:{fontSize:"12px",color:"#ef4444",fontWeight:"bold",marginBottom:"2px"},children:["ERROR ",g.ref!=="UNKNOWN"&&`[${g.ref}]`]}),l.jsx("div",{style:{fontSize:"13px",color:f},children:g.message})]},`err-${m}`)),u.map((g,m)=>l.jsxs("div",{className:"health-item",role:"button",tabIndex:g.ref?0:void 0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&c(g.ref)},onClick:()=>c(g.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:g.ref?"pointer":"default",borderLeft:"4px solid #f59e0b",transition:"background 0.2s"},children:[l.jsxs("div",{style:{fontSize:"12px",color:"#f59e0b",fontWeight:"bold",marginBottom:"2px"},children:["WARNING ",g.ref!=="UNKNOWN"&&`[${g.ref}]`]}),l.jsx("div",{style:{fontSize:"13px",color:f},children:g.message})]},`warn-${m}`))]})}),l.jsxs("div",{style:{padding:"12px 16px",fontSize:"11px",color:h,borderTop:`1px solid ${p}`,backgroundColor:"rgba(0,0,0,0.02)",display:"flex",justifyContent:"space-between"},children:[l.jsxs("span",{children:["共 ",i.length," 个错误, ",u.length," 个警告"]}),i.length>0&&l.jsx("span",{style:{color:"#ef4444"},children:"无法保存/导出"})]})]}):null},Ix=({id:e,source:n,target:r,sourceX:t,sourceY:s,targetX:a,targetY:o,sourcePosition:i,targetPosition:u,style:c={},markerEnd:d,data:f})=>{const[p,h]=O.useState(!1),g=O.useRef(null),m=()=>{const N=f?.edgeType||"default",L={sourceX:t,sourceY:s,sourcePosition:i,targetX:a,targetY:o,targetPosition:u};switch(N){case"step":case"smoothstep":return A.getSmoothStepPath(L);case"straight":return A.getStraightPath(L);default:return A.getBezierPath(L)}},[v,y,x]=m(),b=N=>{N.stopPropagation(),N.preventDefault();const L=new CustomEvent("edgeAddNode",{detail:{id:e,source:n,target:r,edgeData:f}});window.dispatchEvent(L)},k=()=>{g.current&&clearTimeout(g.current),h(!0)},w=()=>{g.current=setTimeout(()=>{h(!1)},100)},j=f?.mode==="edit";return l.jsxs(l.Fragment,{children:[l.jsx(A.BaseEdge,{path:v,markerEnd:d,style:{...c,strokeWidth:p?4:2,stroke:p?"#fbbf24":c?.stroke,transition:"stroke 0.2s, stroke-width 0.2s",pointerEvents:"none"}}),l.jsx("path",{d:v,fill:"none",stroke:"transparent",strokeWidth:20,style:{cursor:j?"pointer":"default",pointerEvents:"all"},onMouseEnter:k,onMouseLeave:w}),j&&p&&l.jsx(A.EdgeLabelRenderer,{children:l.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${y}px,${x}px)`,fontSize:12,pointerEvents:"all",zIndex:2e3,display:"flex",flexDirection:"column",alignItems:"center"},className:"nodrag nopan",onMouseEnter:k,onMouseLeave:w,children:[f?.label&&l.jsx("div",{style:{background:"var(--glass-bg-accent)",backdropFilter:"var(--glass-blur)",color:"var(--color-accent)",padding:"4px 10px",borderRadius:"6px",fontSize:"11px",fontWeight:"700",marginBottom:"8px",border:"1px solid var(--color-accent)",boxShadow:"0 4px 12px rgba(0,0,0,0.3)",whiteSpace:"nowrap",letterSpacing:"0.5px"},children:f.label}),l.jsx("button",{style:{width:"32px",height:"32px",backgroundColor:"var(--color-accent)",color:"#fff",border:"2px solid rgba(255,255,255,0.8)",borderRadius:"50%",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:"700",fontSize:"20px",boxShadow:"0 4px 15px rgba(var(--color-accent-rgb), 0.5)",transition:"all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},className:"edge-add-button",onClick:b,onMouseDown:N=>N.stopPropagation(),title:"在此处添加任务",children:"+"})]})})]})},qe=({onClick:e,icon:n,label:r,title:t,disabled:s=!1,active:a=!1,variant:o="default",style:i})=>{let u="var(--bg-tertiary)",c="var(--text-primary)",d="1px solid var(--border-primary)";return o==="primary"?(u="var(--color-accent)",c="#fff",d="none"):o==="danger"?(u=s?"rgba(239, 68, 68, 0.1)":"var(--status-failed)",c=s?"var(--text-secondary)":"#fff",d="none"):a&&(u="var(--bg-secondary)",c="var(--color-accent)",d="1px solid var(--color-accent)"),l.jsxs("button",{onClick:e,disabled:s,title:t,"aria-label":t||r,"aria-pressed":a,"aria-disabled":s,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:r?"6px":"0",background:u,color:c,border:d,borderRadius:"6px",padding:r?"6px 12px":"8px",cursor:s?"not-allowed":"pointer",opacity:s?.5:1,fontSize:"13px",fontWeight:500,transition:"all 0.2s",minWidth:r?"auto":"32px",height:"32px",boxShadow:o==="default"?"0 1px 2px rgba(0,0,0,0.05)":"none",...i},children:[n&&l.jsx("span",{style:{fontSize:"14px",display:"flex"},children:n}),r&&l.jsx("span",{children:r})]})},Rx=()=>{const{zoomIn:e,zoomOut:n,fitView:r}=A.useReactFlow();return l.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px"},children:l.jsxs("div",{style:{display:"flex",background:"var(--bg-tertiary)",padding:"4px",borderRadius:"8px",border:"1px solid var(--border-primary)",gap:"4px",boxShadow:"0 2px 5px rgba(0,0,0,0.05)"},children:[l.jsx(qe,{icon:"➕",title:"放大",onClick:()=>e()}),l.jsx(qe,{icon:"➖",title:"缩小",onClick:()=>n()}),l.jsx(qe,{icon:"⤢",title:"适应屏幕",onClick:()=>r({duration:600})})]})})},Ox=({onShowHealthCheck:e,showHealthCheck:n,onShowSettings:r,executionActions:t})=>{const{mode:s,validationResults:a,workflowInstance:o,workflowDef:i}=oe(),u=oe.temporal,{undo:c,redo:d,pastStates:f,futureStates:p}=et(u,T=>T),[h,g]=O.useState(!1),m=O.useRef(null);O.useEffect(()=>{if(!h)return;const T=C=>{m.current&&!m.current.contains(C.target)&&g(!1)};return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[h]);const v=(a?.errors?.length||0)>0,y=o?.status,x=o?.workflowId??"",b=y==="RUNNING",k=y==="PAUSED",w=y==="FAILED"||y==="TIMED_OUT"||y==="TERMINATED",j=y==="COMPLETED",N=i?.restartable===!0&&(w||j),L=t?.allowOperations!==!1;return l.jsxs("div",{className:"action-bar",style:{display:"flex",gap:"8px",alignItems:"center"},children:[s==="edit"&&l.jsxs(l.Fragment,{children:[l.jsx(qe,{icon:"↺",title:"撤销 (Cmd+Z)",onClick:()=>c(),disabled:f.length===0}),l.jsx(qe,{icon:"↻",title:"重做 (Cmd+Shift+Z)",onClick:()=>d(),disabled:p.length===0}),l.jsx("div",{style:{width:"1px",height:"20px",background:"var(--border-primary)",margin:"0 4px",alignSelf:"center"}}),l.jsx(qe,{icon:"🩺",label:v?`错误 (${a.errors.length})`:"诊断",title:"流程健康检查",onClick:e,active:n,variant:v?"danger":"secondary"}),l.jsx(qe,{icon:"⚙️",label:"配置",title:"工作流全局配置",onClick:()=>r?.()})]}),s==="run"&&o&&t&&l.jsxs(l.Fragment,{children:[k&&t.onResume&&l.jsx(qe,{icon:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("path",{d:"M4 3l9 5-9 5z"})}),label:"继续",title:L?"继续执行工作流":"操作权限受限",onClick:()=>L&&t.onResume(x),disabled:!L,variant:"primary"}),b&&t.onPause&&l.jsx(qe,{icon:l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:[l.jsx("rect",{x:"4",y:"3",width:"3",height:"10",rx:"1"}),l.jsx("rect",{x:"9",y:"3",width:"3",height:"10",rx:"1"})]}),label:"暂停",title:L?"暂停工作流执行":"操作权限受限",onClick:()=>L&&t.onPause(x),disabled:!L}),(b||k)&&t.onTerminate&&l.jsx(qe,{icon:l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})}),label:"终止",title:L?"终止工作流执行":"操作权限受限",onClick:()=>L&&t.onTerminate(x),disabled:!L,variant:"danger"}),w&&t.onRetry&&l.jsx(qe,{icon:l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[l.jsx("path",{d:"M13 2v4h-4"}),l.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),label:"重试",title:L?"重试失败的工作流":"操作权限受限",onClick:()=>L&&t.onRetry(x),disabled:!L,variant:"primary"}),N&&t.onRestart&&l.jsxs("div",{ref:m,style:{position:"relative",display:"flex"},children:[l.jsxs("button",{disabled:!L,onClick:()=>L&&t.onRestart(x,{useLatestDef:!0}),title:L?"使用当前最新定义版本重新运行":"操作权限受限",style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--bg-tertiary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRight:"none",borderRadius:"6px 0 0 6px",padding:"6px 10px",cursor:L?"pointer":"not-allowed",opacity:L?1:.5,fontSize:"13px",fontWeight:500,height:"32px"},children:[l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[l.jsx("path",{d:"M3 14v-4h4"}),l.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"重启"]}),l.jsx("button",{disabled:!L,onClick:()=>L&&g(T=>!T),title:L?"展开重启版本选项":"操作权限受限",style:{display:"flex",alignItems:"center",justifyContent:"center",background:L&&h?"var(--bg-secondary)":"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border-primary)",borderRadius:"0 6px 6px 0",padding:"6px 6px",cursor:L?"pointer":"not-allowed",opacity:L?1:.5,height:"32px",width:"22px",fontSize:"10px"},children:l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:l.jsx("path",{d:"M1 3l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})})}),h&&l.jsxs("div",{style:{position:"absolute",top:"36px",right:0,background:"var(--glass-surface)",backdropFilter:"blur(12px)",border:"1px solid var(--glass-border)",borderRadius:"10px",boxShadow:"0 8px 24px rgba(0,0,0,0.25)",zIndex:2e3,minWidth:"180px",overflow:"hidden"},children:[l.jsx("div",{style:{padding:"6px 12px 4px",fontSize:"11px",color:"var(--text-secondary)",fontWeight:600,letterSpacing:"0.5px",textTransform:"uppercase"},children:"选择版本"}),l.jsxs("button",{onClick:()=>{t.onRestart(x,{useLatestDef:!0}),g(!1)},style:$h,onMouseEnter:T=>T.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:T=>T.currentTarget.style.background="transparent",children:[l.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("circle",{cx:"8",cy:"8",r:"6"}),l.jsx("path",{d:"M8 5v3l2 1"})]}),l.jsxs("div",{children:[l.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"当前版本"}),l.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用最新工作流定义"})]})]}),l.jsxs("button",{onClick:()=>{t.onRestart(x,{useLatestDef:!1}),g(!1)},style:$h,onMouseEnter:T=>T.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:T=>T.currentTarget.style.background="transparent",children:[l.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("rect",{x:"3",y:"2",width:"10",height:"12",rx:"1"}),l.jsx("path",{d:"M6 6h4M6 9h3"})]}),l.jsxs("div",{children:[l.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"执行版本"}),l.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用本次运行时的定义"})]})]})]})]})]})]})},$h={display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"8px 12px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",transition:"background 0.15s"},zh=[{id:"business",label:"业务",title:"仅展示核心业务节点"},{id:"standard",label:"标准",title:"业务 + 控制流节点"},{id:"developer",label:"全开发",title:"展示所有节点(含数据转换)"}];function Px(){const e=oe(a=>a.viewMode),n=oe(a=>a.setViewMode),r=O.useRef([]),[t,s]=O.useState({x:3,w:0});return O.useEffect(()=>{const a=zh.findIndex(i=>i.id===e),o=r.current[a];o&&s({x:o.offsetLeft,w:o.offsetWidth})},[e]),l.jsxs("div",{className:"mode-slider",role:"group","aria-label":"视图模式",children:[l.jsx("div",{className:"mode-slider-knob",style:{width:t.w,transform:`translateX(${t.x-3}px)`}}),zh.map((a,o)=>l.jsxs("button",{ref:i=>{r.current[o]=i},className:`mode-slider-opt${e===a.id?" active":""}`,onClick:()=>n(a.id),title:a.title,"aria-pressed":e===a.id,children:[l.jsx("span",{className:"mode-dot"}),a.label]},a.id))]})}function Zr(e){return!e||e.length===0?[]:typeof e[0]=="string"?e.map(n=>({name:n})):e}const Ax=[{id:"basic",label:"基本信息"},{id:"timeout",label:"超时与容错"},{id:"params",label:"参数配置"},{id:"advanced",label:"高级设置"}],Lx=({isOpen:e,onClose:n})=>{const{workflowDef:r,updateWorkflowProperties:t,mode:s}=oe(),[a,o]=O.useState(r),[i,u]=O.useState("basic"),c=s!=="edit";O.useEffect(()=>{r&&o(r)},[r,e]);const d=O.useCallback(I=>{I.key==="Escape"&&n()},[n]);if(O.useEffect(()=>{if(e)return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,d]),!e||!a)return null;const f="var(--text-primary)",p="var(--glass-border)",h="var(--bg-tertiary)",g="var(--text-secondary)",m=(I,P)=>{if(!a||c)return;const F={...a,[I]:P};o(F),t({[I]:P})},v=(I,P,F)=>{if(!a||c)return;const K={...a[I]||{},[P]:F};o(V=>({...V,[I]:K})),t({[I]:K})},y=(I,P)=>{if(!(!a||c))try{const F=JSON.parse(P),W={...a,[I]:F};o(W),t({[I]:F})}catch{o(F=>({...F,[`_${I}_str`]:P}))}},x={width:"100%",padding:"10px 14px",borderRadius:"8px",border:`1px solid ${p}`,background:h,color:f,fontSize:"14px",outline:"none",boxSizing:"border-box"},b={display:"block",fontSize:"11px",color:g,marginBottom:"8px",fontWeight:600},k=(I,P,F="text",W)=>l.jsxs("div",{style:{marginBottom:"20px"},children:[l.jsx("label",{style:b,children:I.toUpperCase()}),l.jsx("input",{className:"wsp-input",type:F,value:a?.[P]??"",onChange:K=>m(P,F==="number"?K.target.value===""?0:parseInt(K.target.value):K.target.value),disabled:c||W?.readOnly,placeholder:W?.placeholder,style:{...x,opacity:c||W?.readOnly?.6:1}})]}),w=(I,P,F=!1,W=6)=>{const K=a?.[`_${P}_str`]!==void 0?a[`_${P}_str`]:typeof a?.[P]=="object"?JSON.stringify(a[P],null,2):a?.[P];return l.jsxs("div",{style:{marginBottom:"20px"},children:[l.jsxs("label",{style:b,children:[I.toUpperCase()," ",F&&"(JSON)"]}),l.jsx("textarea",{className:"wsp-input",value:K||"",onChange:V=>F?y(P,V.target.value):m(P,V.target.value),rows:W,disabled:c,style:{...x,fontSize:"13px",fontFamily:F?"var(--font-mono)":"inherit",resize:"vertical",opacity:c?.6:1}})]})},j=(I,P,F)=>l.jsxs("div",{style:{marginBottom:"20px"},children:[l.jsx("label",{style:b,children:I.toUpperCase()}),l.jsx("select",{className:"wsp-input",value:a?.[P]??F[0]?.value,onChange:W=>m(P,W.target.value),disabled:c,style:{...x,opacity:c?.6:1,cursor:c?"not-allowed":"pointer"},children:F.map(W=>l.jsx("option",{value:W.value,children:W.label},W.value))})]}),N=(I,P)=>{const F=!!a?.[P];return l.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[l.jsx("label",{style:{fontSize:"13px",color:f},children:I}),l.jsx("button",{type:"button",role:"switch","aria-checked":F,onClick:()=>!c&&m(P,!F),disabled:c,style:{width:"44px",height:"24px",borderRadius:"12px",border:"none",background:F?"var(--color-accent)":"var(--border-primary)",position:"relative",cursor:c?"not-allowed":"pointer",transition:"background 0.2s",opacity:c?.6:1,flexShrink:0},children:l.jsx("span",{style:{position:"absolute",top:"2px",left:F?"22px":"2px",width:"20px",height:"20px",borderRadius:"50%",background:"var(--text-inverse)",transition:"left 0.2s",boxShadow:"0 1px 3px rgba(0,0,0,0.2)"}})})]})},L=()=>l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"3fr 1fr",gap:"20px"},children:[k("工作流名称","name"),k("版本号","version","number")]}),w("描述信息","description",!1,3),k("负责人邮箱","ownerEmail","text",{placeholder:"owner@example.com"}),k("Schema 版本","schemaVersion","number",{readOnly:!0})]}),T=()=>l.jsxs(l.Fragment,{children:[j("超时策略","timeoutPolicy",[{value:"ALERT_ONLY",label:"ALERT_ONLY — 仅告警"},{value:"TIME_OUT_WF",label:"TIME_OUT_WF — 超时终止"}]),l.jsxs("div",{children:[k("超时秒数","timeoutSeconds","number",{placeholder:"0 表示不超时"}),a?.timeoutPolicy==="ALERT_ONLY"&&l.jsx("p",{style:{fontSize:"11px",color:g,marginTop:"-12px",marginBottom:"20px"},children:"当前策略为 ALERT_ONLY,超时仅触发告警,不会终止工作流。"})]}),k("失败补偿工作流","failureWorkflow","text",{placeholder:"输入补偿工作流名称"}),N("允许重启 (restartable)","restartable")]}),C=()=>{const I=Zr(a?.inputParameters),P=te=>{c||m("inputParameters",te)},F=()=>{const te=[...I,{name:`param_${I.length+1}`,type:"string",required:!1}];P(te)},W=te=>{const re=I.filter((q,G)=>G!==te);P(re)},K=(te,re,q)=>{const G=I.map((ie,R)=>R===te?{...ie,[re]:q}:ie);P(G)},V={padding:"6px 10px",borderRadius:"6px",border:`1px solid ${p}`,background:h,color:f,fontSize:"12px",outline:"none",fontFamily:"inherit"};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{marginBottom:"20px"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[l.jsx("label",{style:b,children:"入参声明 (INPUT PARAMETERS)"}),!c&&l.jsx("button",{onClick:F,style:{background:"var(--color-accent)",color:"var(--text-inverse)",border:"none",borderRadius:"6px",padding:"5px 12px",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"+ 添加参数"})]}),I.length===0?l.jsx("p",{style:{fontSize:"12px",color:g,margin:0,padding:"12px",background:"var(--bg-secondary)",borderRadius:"8px",border:`1px solid ${p}`},children:'暂无入参声明。点击"+ 添加参数"来定义工作流的输入参数,这些参数将在执行验证时作为表单字段展示。'}):l.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:I.map((te,re)=>l.jsxs("div",{style:{background:"var(--bg-secondary)",border:`1px solid ${p}`,borderRadius:"10px",padding:"12px"},children:[l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr auto auto",gap:"8px",alignItems:"center"},children:[l.jsx("input",{style:V,placeholder:"参数名",value:te.name,onChange:q=>K(re,"name",q.target.value),disabled:c}),l.jsx("select",{style:{...V,cursor:c?"not-allowed":"pointer"},value:te.type??"string",onChange:q=>K(re,"type",q.target.value),disabled:c,children:["string","number","boolean","object","array"].map(q=>l.jsx("option",{value:q,children:q},q))}),l.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:g,cursor:c?"not-allowed":"pointer",whiteSpace:"nowrap"},children:[l.jsx("input",{type:"checkbox",checked:!!te.required,onChange:q=>K(re,"required",q.target.checked),disabled:c,style:{accentColor:"var(--color-accent)"}}),"必填"]}),!c&&l.jsx("button",{onClick:()=>W(re),style:{background:"none",border:"none",color:"var(--status-failed)",cursor:"pointer",fontSize:"16px",padding:"0 4px",opacity:.7,lineHeight:1},children:"✕"})]}),l.jsxs("div",{style:{marginTop:"8px",display:"flex",flexDirection:"column",gap:"6px"},children:[l.jsx("input",{style:V,placeholder:"说明(可选)",value:te.description??"",onChange:q=>K(re,"description",q.target.value),disabled:c}),l.jsx("input",{style:V,placeholder:`示例值(如 ${te.type==="number"?"42":te.type==="boolean"?"true":'"value"'})`,value:te.example!==void 0?typeof te.example=="object"?JSON.stringify(te.example):String(te.example):"",onChange:q=>{let G=q.target.value;try{G=JSON.parse(q.target.value)}catch{}K(re,"example",G)},disabled:c})]})]},re))})]}),w("输出参数映射 (outputParameters)","outputParameters",!0),w("默认输入模板 (inputTemplate)","inputTemplate",!0),w("工作流级变量 (variables)","variables",!0)]})},S=()=>l.jsxs(l.Fragment,{children:[N("启用状态监听 (workflowStatusListenerEnabled)","workflowStatusListenerEnabled"),a?.workflowStatusListenerEnabled&&k("状态事件目标 (Listener Sink)","workflowStatusListenerSink","text",{placeholder:"conductor:workflow_status_event"}),l.jsxs("div",{style:{borderTop:`1px solid ${p}`,marginTop:"8px",paddingTop:"20px"},children:[N("强制 Schema 校验 (enforceSchema)","enforceSchema"),a?.enforceSchema&&l.jsxs(l.Fragment,{children:[w("输入 Schema (inputSchema)","inputSchema",!0,4),w("输出 Schema (outputSchema)","outputSchema",!0,4)]})]}),l.jsxs("div",{style:{borderTop:`1px solid ${p}`,marginTop:"8px",paddingTop:"20px"},children:[l.jsx("label",{style:{...b,marginBottom:"16px"},children:"并发限流 (RATE LIMIT)"}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"20px"},children:[l.jsxs("div",{children:[l.jsx("label",{style:b,children:"RATE LIMIT KEY"}),l.jsx("input",{className:"wsp-input",type:"text",value:a?.rateLimitConfig?.rateLimitKey??"",onChange:I=>v("rateLimitConfig","rateLimitKey",I.target.value),disabled:c,placeholder:"限流键",style:{...x,opacity:c?.6:1}})]}),l.jsxs("div",{children:[l.jsx("label",{style:b,children:"并发上限"}),l.jsx("input",{className:"wsp-input",type:"number",value:a?.rateLimitConfig?.concurrentExecLimit??"",onChange:I=>v("rateLimitConfig","concurrentExecLimit",I.target.value===""?0:parseInt(I.target.value)),disabled:c,placeholder:"0",style:{...x,opacity:c?.6:1}})]})]})]})]}),D=()=>{switch(i){case"basic":return L();case"timeout":return T();case"params":return C();case"advanced":return S()}};return l.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"工作流全局配置",onClick:n,style:{position:"fixed",left:0,top:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.5)",zIndex:1300,display:"flex",justifyContent:"center",alignItems:"center",backdropFilter:"blur(4px)",animation:"fadeIn 0.2s ease"},children:l.jsxs("div",{onClick:I=>I.stopPropagation(),style:{width:"680px",maxHeight:"85vh",background:"var(--glass-surface)",borderRadius:"16px",boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.5)",display:"flex",flexDirection:"column",overflow:"hidden",animation:"slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1)",border:`1px solid ${p}`,backdropFilter:"blur(20px)"},children:[l.jsxs("div",{style:{padding:"24px 32px 0 32px",background:"var(--bg-highlight)"},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[l.jsxs("div",{children:[l.jsx("h2",{style:{margin:0,fontSize:"20px",color:f},children:"工作流全局配置"}),l.jsx("p",{style:{margin:"4px 0 0 0",fontSize:"12px",color:g},children:c?"当前为只读模式":"配置工作流级属性,所有更改将实时保存"})]}),l.jsx("button",{className:"wsp-close",onClick:n,"aria-label":"关闭",style:{background:"none",border:"none",color:f,fontSize:"24px",cursor:"pointer",opacity:.6},children:"✕"})]}),l.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${p}`},children:Ax.map(I=>l.jsx("button",{className:"wsp-tab",onClick:()=>u(I.id),style:{padding:"10px 20px",fontSize:"13px",fontWeight:i===I.id?600:400,color:i===I.id?"var(--color-accent)":g,background:"none",border:"none",borderBottom:i===I.id?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s",marginBottom:"-1px"},children:I.label},I.id))})]}),l.jsx("div",{style:{flex:1,overflowY:"auto",padding:"28px 32px"},children:D()}),l.jsx("div",{style:{padding:"20px 32px",borderTop:`1px solid ${p}`,background:"var(--bg-highlight)",display:"flex",justifyContent:"flex-end"},children:l.jsx("button",{className:"wsp-footer-btn",onClick:n,style:{padding:"12px 32px",background:"var(--color-accent)",color:"var(--text-inverse)",border:"none",borderRadius:"12px",fontWeight:"bold",cursor:"pointer",boxShadow:"0 4px 12px var(--color-accent-bg)"},children:"完成并关闭"})})]})})},qx=({onRequestImport:e})=>{const{createBlankWorkflow:n}=oe(),[r,t]=O.useState(""),s=()=>{n(r||void 0),oe.temporal.getState().clear()},a=()=>{n(r||void 0),oe.temporal.getState().clear(),window.dispatchEvent(new CustomEvent("open-ai-chat"))};return l.jsxs("div",{className:"empty-state-panel",children:[l.jsx("h2",{className:"empty-state-title",children:"创建新工作流"}),l.jsx("p",{className:"empty-state-subtitle",children:"从空白画布开始设计,或让 AI 帮你生成完整流程"}),l.jsx("input",{className:"empty-state-name-input",type:"text",placeholder:"工作流名称(可选)",value:r,onChange:o=>t(o.target.value),onKeyDown:o=>{o.key==="Enter"&&s()}}),l.jsxs("div",{className:"empty-state-actions",children:[l.jsxs("button",{className:"empty-state-btn primary",onClick:s,children:[l.jsx("span",{className:"empty-state-btn-icon",children:"📄"}),"空白工作流"]}),l.jsxs("button",{className:"empty-state-btn",onClick:a,children:[l.jsx("span",{className:"empty-state-btn-icon",children:"✨"}),"AI 生成"]}),e&&l.jsxs("button",{className:"empty-state-btn",onClick:e,children:[l.jsx("span",{className:"empty-state-btn-icon",children:"📤"}),"导入 JSON"]})]})]})},Dx={success:{bg:"#10b981",text:"#fff"},error:{bg:"#ef4444",text:"#fff"},info:{bg:"var(--color-accent)",text:"#fff"}},Mx=({messages:e,onDismiss:n})=>e.length===0?null:l.jsx("div",{style:{position:"fixed",bottom:"24px",left:"50%",transform:"translateX(-50%)",zIndex:3e3,display:"flex",flexDirection:"column",gap:"8px",pointerEvents:"none"},children:e.map(r=>l.jsx(Wx,{message:r,onDismiss:n},r.id))}),Wx=({message:e,onDismiss:n})=>{const r=Dx[e.type||"info"];return O.useEffect(()=>{const t=setTimeout(()=>n(e.id),2500);return()=>clearTimeout(t)},[e.id,n]),l.jsx("div",{role:"status","aria-live":"polite",style:{backgroundColor:r.bg,color:r.text,padding:"10px 20px",borderRadius:"8px",fontSize:"13px",fontWeight:500,boxShadow:"0 4px 16px rgba(0,0,0,0.2)",animation:"toastSlideUp 0.3s ease-out",pointerEvents:"auto",cursor:"pointer",whiteSpace:"nowrap"},onClick:()=>n(e.id),children:e.text})},Hh=["shift","alt","meta","mod","ctrl","control"],Bx={esc:"escape",return:"enter",left:"arrowleft",right:"arrowright",up:"arrowup",down:"arrowdown",ShiftLeft:"shift",ShiftRight:"shift",AltLeft:"alt",AltRight:"alt",MetaLeft:"meta",MetaRight:"meta",OSLeft:"meta",OSRight:"meta",ControlLeft:"ctrl",ControlRight:"ctrl"};function Ue(e){return(Bx[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function Kh(e){return Hh.includes(e)}function Ui(e,n=","){return e.toLowerCase().split(n)}function Ji(e,n="+",r=">",t=!1,s){let a=[],o=!1;e=e.trim(),e.includes(r)?(o=!0,a=e.toLocaleLowerCase().split(r).map(c=>Ue(c))):a=e.toLocaleLowerCase().split(n).map(c=>Ue(c));const i={alt:a.includes("alt"),ctrl:a.includes("ctrl")||a.includes("control"),shift:a.includes("shift"),meta:a.includes("meta"),mod:a.includes("mod"),useKey:t},u=a.filter(c=>!Hh.includes(c));return{...i,keys:u,description:s,isSequence:o,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Uh([Ue(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&Jh([Ue(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{$e.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{$e.clear()},0)}));const $e=new Set;function Gi(e){return Array.isArray(e)}function Fx(e,n=","){return(Gi(e)?e:e.split(n)).every(r=>$e.has(r.trim().toLowerCase()))}function Uh(e){const n=Array.isArray(e)?e:[e];$e.has("meta")&&$e.forEach(r=>!Kh(r)&&$e.delete(r.toLowerCase())),n.forEach(r=>$e.add(r.toLowerCase()))}function Jh(e){const n=Array.isArray(e)?e:[e];e==="meta"?$e.clear():n.forEach(r=>$e.delete(r.toLowerCase()))}function $x(e,n,r){(typeof r=="function"&&r(e,n)||r===!0)&&e.preventDefault()}function zx(e,n,r){return typeof r=="function"?r(e,n):r===!0||r===void 0}const Hx=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Kx(e){return Gh(e,Hx)}function Gh(e,n=!1){const{target:r,composed:t}=e;let s,a;return Ux(r)&&t?(s=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(s=r&&r.tagName,a=r&&r.role),Gi(n)?!!(s&&n&&n.some(o=>o.toLowerCase()===s.toLowerCase()||o===a)):!!(s&&n&&n)}function Ux(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function Jx(e,n){return e.length===0&&n?(console.warn('A hotkey has the "scopes" option set, however no active scopes were found. If you want to use the global scopes feature, you need to wrap your app in a <HotkeysProvider>'),!0):n?e.some(r=>n.includes(r))||e.includes("*"):!0}const Gx=(e,n,r=!1)=>{const{alt:t,meta:s,mod:a,shift:o,ctrl:i,keys:u,useKey:c}=n,{code:d,key:f,ctrlKey:p,metaKey:h,shiftKey:g,altKey:m}=e,v=Ue(d);if(c&&u?.length===1&&u.includes(f))return!0;if(!u?.includes(v)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(v))return!1;if(!r){if(t!==m&&v!=="alt"||o!==g&&v!=="shift")return!1;if(a){if(!h&&!p)return!1}else if(s!==h&&v!=="meta"&&v!=="os"||i!==p&&v!=="ctrl"&&v!=="control")return!1}return u&&u.length===1&&u.includes(v)?!0:u?Fx(u):!u},Vx=O.createContext(void 0),Yx=()=>O.useContext(Vx);function Vh(e,n){return e&&n&&typeof e=="object"&&typeof n=="object"?Object.keys(e).length===Object.keys(n).length&&Object.keys(e).reduce((r,t)=>r&&Vh(e[t],n[t]),!0):e===n}const Xx=O.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),Zx=()=>O.useContext(Xx);function Qx(e){const n=O.useRef(void 0);return Vh(n.current,e)||(n.current=e),n.current}const Yh=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},eb=typeof window<"u"?O.useLayoutEffect:O.useEffect;function cr(e,n,r,t){const s=O.useRef(null),a=O.useRef(!1),o=Array.isArray(r)?Array.isArray(t)?void 0:t:r,i=Gi(e)?e.join(o?.delimiter):e,u=Array.isArray(r)?r:Array.isArray(t)?t:void 0,c=O.useCallback(n,u??[]),d=O.useRef(c);u?d.current=c:d.current=n;const f=Qx(o),{activeScopes:p}=Zx(),h=Yx();return eb(()=>{if(f?.enabled===!1||!Jx(p,f?.scopes))return;let g=[],m;const v=(k,w=!1)=>{if(!(Kx(k)&&!Gh(k,f?.enableOnFormTags))){if(s.current!==null){const j=s.current.getRootNode();if((j instanceof Document||j instanceof ShadowRoot)&&j.activeElement!==s.current&&!s.current.contains(j.activeElement)){Yh(k);return}}k.target?.isContentEditable&&!f?.enableOnContentEditable||Ui(i,f?.delimiter).forEach(j=>{if(j.includes(f?.splitKey??"+")&&j.includes(f?.sequenceSplitKey??">")){console.warn(`Hotkey ${j} contains both ${f?.splitKey??"+"} and ${f?.sequenceSplitKey??">"} which is not supported.`);return}const N=Ji(j,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description);if(N.isSequence){m=setTimeout(()=>{g=[]},f?.sequenceTimeoutMs??1e3);const L=N.useKey?k.key:Ue(k.code);if(Kh(L.toLowerCase()))return;g.push(L);const T=N.keys?.[g.length-1];if(L!==T){g=[],m&&clearTimeout(m);return}g.length===N.keys?.length&&(d.current(k,N),m&&clearTimeout(m),g=[])}else if(Gx(k,N,f?.ignoreModifiers)||N.keys?.includes("*")){if(f?.ignoreEventWhen?.(k)||w&&a.current)return;if($x(k,N,f?.preventDefault),!zx(k,N,f?.enabled)){Yh(k);return}d.current(k,N),w||(a.current=!0)}})}},y=k=>{k.code!==void 0&&(Uh(Ue(k.code)),(f?.keydown===void 0&&f?.keyup!==!0||f?.keydown)&&v(k))},x=k=>{k.code!==void 0&&(Jh(Ue(k.code)),a.current=!1,f?.keyup&&v(k,!0))},b=s.current||o?.document||document;return b.addEventListener("keyup",x,o?.eventListenerOptions),b.addEventListener("keydown",y,o?.eventListenerOptions),h&&Ui(i,f?.delimiter).forEach(k=>h.addHotkey(Ji(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),()=>{b.removeEventListener("keyup",x,o?.eventListenerOptions),b.removeEventListener("keydown",y,o?.eventListenerOptions),h&&Ui(i,f?.delimiter).forEach(k=>h.removeHotkey(Ji(k,f?.splitKey,f?.sequenceSplitKey,f?.useKey,f?.description))),g=[],m&&clearTimeout(m)}},[i,f,p]),s}const rb=e=>{const{mode:n,removeNode:r,selectedTask:t,pasteTask:s}=oe(),a=oe.temporal,{undo:o,redo:i}=et(a,p=>p),u=e?.confirm||(p=>Promise.resolve(window.confirm(p))),c=e?.showToast,d=p=>{const h=p.target;return h.tagName==="INPUT"||h.tagName==="TEXTAREA"||h.isContentEditable},f=()=>{requestAnimationFrame(()=>{const p=oe.getState(),{nodes:h,edges:g}=Se(p.nodes,p.edges,{direction:p.layoutDirection,mode:p.mode});oe.setState({nodes:h,edges:g})})};return cr("mod+z",p=>{n==="edit"&&(d(p)||(p.preventDefault(),o(),f()))},[n,o]),cr(["mod+shift+z","mod+y"],p=>{n==="edit"&&(d(p)||(p.preventDefault(),i(),f()))},[n,i]),cr("delete, backspace",p=>{n!=="edit"||!t||d(p)||(p.preventDefault(),u("确定要删除此任务吗?").then(h=>{h&&r(t.taskReferenceName)}))},[n,t,r,u]),cr("mod+c",p=>{if(!(n!=="edit"||!t)&&!d(p)){if(t.type==="JOIN"){c?.("JOIN 任务不能独立复制","error");return}p.preventDefault();try{localStorage.setItem("conductor-clipboard",JSON.stringify(t)),c?.("任务已复制","success")}catch{c?.("复制失败","error")}}},[n,t,c]),cr("mod+v",p=>{if(n==="edit"&&!d(p)){p.preventDefault();try{const h=localStorage.getItem("conductor-clipboard");if(h){const g=JSON.parse(h);s(g),c?.("任务已粘贴","success")}}catch{c?.("粘贴失败","error")}}},[n,s,c]),cr("mod+s",p=>{p.preventDefault();const h=oe.getState().workflowDef;h&&e?.onSave&&e.onSave(h)},[e?.onSave]),{}},tb=()=>{const[e,n]=O.useState(null),r=O.useCallback(a=>new Promise(o=>{n({message:a,resolve:o})}),[]),t=O.useCallback(()=>{e?.resolve(!0),n(null)},[e]),s=O.useCallback(()=>{e?.resolve(!1),n(null)},[e]);return{confirm:r,confirmState:e,handleConfirm:t,handleCancel:s}},nb=()=>{const[e,n]=O.useState([]),r=O.useCallback((s,a="info")=>{const o=Date.now().toString();n(i=>[...i,{id:o,text:s,type:a}])},[]),t=O.useCallback(s=>{n(a=>a.filter(o=>o.id!==s))},[]);return{toasts:e,showToast:r,dismissToast:t}},Vi={id:"welcome",role:"assistant",content:`你好!我是 AI 工作流助手。
|
|
34
|
+
|
|
35
|
+
我可以帮你:
|
|
36
|
+
- 🆕 **从零创建**工作流(描述业务场景即可)
|
|
37
|
+
- ➕ **添加/修改/删除**任务节点
|
|
38
|
+
- 🔀 **重构拓扑**(如串行改并行)
|
|
39
|
+
- 🔍 **诊断问题**和优化建议
|
|
40
|
+
|
|
41
|
+
直接告诉我你想做什么吧!`,timestamp:Date.now()},ab=()=>(e,n)=>({config:{provider:"auto",apiKey:""},messages:[Vi],isStreaming:!1,streamingText:"",chatPanelOpen:!0,pendingProposal:null,pendingPlan:null,pendingRepair:null,followUpChips:null,undoStack:[],pendingClarification:null,pendingRecommendation:null,pendingAutoSend:null,toolStatus:"",retryInput:null,timelineEntries:[],metrics:{totalProposals:0,acceptedProposals:0,rejectedProposals:0,totalPromptTokens:0,totalCompletionTokens:0},setConfig:r=>e(t=>({config:{...t.config,...r}})),addMessage:r=>{const t=`msg_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,s={...r,id:t,timestamp:Date.now()};return e(a=>({messages:[...a.messages,s]})),t},updateMessage:(r,t)=>e(s=>({messages:s.messages.map(a=>a.id===r?{...a,content:t}:a)})),setStreaming:r=>e({isStreaming:r}),setStreamingText:r=>e({streamingText:r}),appendStreamingText:r=>e(t=>({streamingText:t.streamingText+r})),clearMessages:()=>e({messages:[Vi],streamingText:"",isStreaming:!1,pendingProposal:null,pendingPlan:null,pendingRepair:null,followUpChips:null,pendingClarification:null,pendingRecommendation:null,pendingAutoSend:null,toolStatus:"",retryInput:null,timelineEntries:[]}),setChatPanelOpen:r=>e({chatPanelOpen:r}),toggleChatPanel:()=>e(r=>({chatPanelOpen:!r.chatPanelOpen})),setProposal:r=>{const t=`prop_${Date.now()}`,s=oe.getState().workflowDef,a=JSON.stringify(s);return e(o=>({pendingProposal:{...r,id:t,baselineHash:a},metrics:{...o.metrics,totalProposals:o.metrics.totalProposals+1}})),t},clearProposal:()=>e({pendingProposal:null}),recordAccept:()=>e(r=>({metrics:{...r.metrics,acceptedProposals:r.metrics.acceptedProposals+1},pendingProposal:null})),recordReject:()=>e(r=>({metrics:{...r.metrics,rejectedProposals:r.metrics.rejectedProposals+1},pendingProposal:null})),getMetrics:()=>n().metrics,recordUsage:r=>e(t=>({metrics:{...t.metrics,totalPromptTokens:t.metrics.totalPromptTokens+(r.promptTokens??0),totalCompletionTokens:t.metrics.totalCompletionTokens+(r.completionTokens??0)}})),setFollowUpChips:r=>e({followUpChips:r}),clearFollowUpChips:()=>e({followUpChips:null}),setPlan:r=>{const t=`plan_${Date.now()}`;return e({pendingPlan:{...r,id:t}}),t},clearPlan:()=>e({pendingPlan:null}),setRepair:r=>{const t=`repair_${Date.now()}`;return e({pendingRepair:{...r,id:t}}),t},clearRepair:()=>e({pendingRepair:null}),pushUndo:r=>e(t=>({undoStack:[...t.undoStack.slice(-4),r]})),popUndo:()=>{const r=n().undoStack;if(r.length===0)return null;const t=r[r.length-1];return e({undoStack:r.slice(0,-1)}),t},clearUndo:()=>e({undoStack:[]}),canUndo:()=>n().undoStack.length>0,setClarification:r=>{const t=`clarif_${Date.now()}`;return e({pendingClarification:{...r,id:t}}),t},clearClarification:()=>e({pendingClarification:null}),setRecommendation:r=>{const t=`rec_${Date.now()}`;return e({pendingRecommendation:{...r,id:t}}),t},clearRecommendation:()=>e({pendingRecommendation:null}),setPendingAutoSend:r=>e({pendingAutoSend:r}),setToolStatus:r=>e({toolStatus:r}),setRetryInput:r=>e({retryInput:r}),addTimelineEntry:(r,t="done")=>e(s=>({timelineEntries:[...s.timelineEntries,{id:`tl_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,label:r,icon:t}]})),clearTimeline:()=>e({timelineEntries:[]}),hydrateFromDraft:(r,t)=>e({messages:r.length>0?r:[Vi],pendingProposal:t})});function sb(e="ai-workflow-config"){const n=ab();return e===!1?rt()(n):rt()(rl(n,{name:e,storage:tt(()=>localStorage),partialize:r=>({config:{...r.config,apiKey:""},metrics:r.metrics})}))}const ob=sb(),ib=O.createContext(null);function lb(){return O.useContext(ib)}const cb={taskNode:mx,decisionNode:yx,forkNode:Bh.ForkNode,joinNode:Bh.JoinNode,loopNode:bx,subWorkflowNode:Sx,plusNode:Tx,dynamicPlaceholderNode:Nx},db={addableEdge:Ix},ub=({onNodeClick:e,searchQuery:n="",onSave:r,onRequestImport:t,executionActions:s})=>{const{nodes:a,edges:o,onNodesChange:i,onEdgesChange:u,onConnect:c,mode:d,viewMode:f,selectedTask:p,setSelectedTask:h,theme:g,edgeType:m,addNode:v,nodesLocked:y,executionData:x,validationResults:b,setIsDetailPanelOpen:k,workflowDef:w,dynamicRuntimeTasksByFork:j,layoutDirection:N,simState:L,workflowLoadKey:T}=oe(),C=O.useMemo(()=>{if(d==="run"||d==="edit")return new Set(a.map(H=>H.id));const z=dx[f],Z=new Set;return a.forEach(H=>{if(H.type==="plusNode"||H.type==="dynamicPlaceholderNode"){Z.add(H.id);return}if(H.parentId)return;const Y=He.find(ge=>ge.type===H.data.taskType)?.viewCategory??"business";z.includes(Y)&&Z.add(H.id)}),a.forEach(H=>{H.parentId&&Z.has(H.parentId)&&Z.add(H.id)}),Z},[a,f,d]),S=O.useCallback(z=>{if(C.size===a.length)return z;const Z={};z.forEach(Y=>{Z[Y.source]||(Z[Y.source]=[]),Z[Y.source].push(Y)});const H=[],ne=new Set;return z.forEach(Y=>{if(!C.has(Y.source))return;if(C.has(Y.target)){const pe=`${Y.source}->${Y.target}`;ne.has(pe)||(ne.add(pe),H.push(Y));return}const ge=[{to:Y.target,label:Y.label}],ae=new Set;for(;ge.length;){const pe=ge.shift();if(!ae.has(pe.to)){if(ae.add(pe.to),C.has(pe.to)){const me=`${Y.source}->${pe.to}`;ne.has(me)||(ne.add(me),H.push({...Y,id:me,target:pe.to,label:pe.label??Y.label}));continue}(Z[pe.to]??[]).forEach(me=>ge.push({to:me.target,label:pe.label??me.label}))}}}),H},[C,a.length]),I=(lb()?.aiStore??ob)(z=>z.pendingProposal),P=O.useMemo(()=>{if(!I)return null;try{const{nodes:z,edges:Z}=Te(I.proposedDef,N,{hideEmptyBranches:!1}),{nodes:H,edges:ne}=Se(z,Z,{direction:N,mode:"edit"}),Y=new Set(I.diff.added),ge=new Set(I.diff.modified),ae=new Set(I.diff.removed),pe=new Map(a.map(ce=>[ce.data?.taskReferenceName,ce])),me=H.filter(ce=>ce.type!=="plusNode").map(ce=>{const E=ce.data?.taskReferenceName,J=Y.has(E)?"added":ge.has(E)?"modified":void 0;return{...ce,draggable:!1,selectable:!1,data:{...ce.data,proposalStatus:J,layoutDirection:N}}}),Ne=[...ae].map(ce=>pe.get(ce)).filter(ce=>ce!=null).map(ce=>({...ce,draggable:!1,selectable:!1,data:{...ce.data,proposalStatus:"removed"}}));return{nodes:[...me,...Ne],edges:ne}}catch{return null}},[I,a,N]),{fitView:F}=A.useReactFlow(),[W,K]=O.useState(!1),[V,te]=O.useState(null),[re,q]=O.useState(!1),[G,ie]=O.useState(!1),{confirm:R,confirmState:M,handleConfirm:_,handleCancel:B}=tb(),{toasts:$,showToast:X,dismissToast:U}=nb();rb({confirm:R,showToast:X,onSave:r}),O.useEffect(()=>{if(p){const z=a.find(Z=>Z.data.taskReferenceName===p.taskReferenceName);z&&F({nodes:[z],duration:800,padding:.5})}},[p?.taskReferenceName,F]),O.useEffect(()=>{const z=()=>{F({duration:800})};return window.addEventListener("workflow-zoom-to-fit",z),()=>window.removeEventListener("workflow-zoom-to-fit",z)},[F]),O.useEffect(()=>{if(T===0)return;const z=setTimeout(()=>{F({duration:600,padding:.12})},50);return()=>clearTimeout(z)},[T,F]),O.useEffect(()=>{const z=ne=>{e&&ne.detail&&ne.detail.task&&e(ne.detail.task)},Z=ne=>{if(d==="edit"){const{loopId:Y,afterRef:ge}=ne.detail;te(ge?{sourceId:ge,edgeData:{}}:{sourceId:Y,edgeData:{isLoopAdd:!0}}),K(!0)}},H=ne=>{d==="edit"&&(te({sourceId:ne.detail.source,targetId:ne.detail.target,edgeId:ne.detail.id,edgeData:ne.detail.edgeData}),K(!0))};return document.addEventListener("miniTaskClick",z),document.addEventListener("loopAddNodeRequested",Z),window.addEventListener("edgeAddNode",H),()=>{document.removeEventListener("miniTaskClick",z),document.removeEventListener("loopAddNodeRequested",Z),window.removeEventListener("edgeAddNode",H)}},[d,e]);const le=O.useCallback(z=>{if(V){const{sourceId:Z,targetId:H,edgeId:ne,edgeData:Y}=V;v({data:{label:`New ${z}`,taskReferenceName:`${z.toLowerCase()}_${Date.now()}`,taskType:z}},Z,H,ne,Y)}K(!1),te(null)},[V,v]),Q=O.useMemo(()=>{const z={extraNodes:[],extraEdges:[],removedEdgeIds:new Set,removedNodeIds:new Set};if(d!=="run")return z;const Z=a.filter(ce=>ce.type==="forkNode"&&ce.data.taskType==="FORK_JOIN_DYNAMIC");if(!Z.length)return z;const H=[],ne=[],Y=new Set,ge=new Set,ae=N==="LR",pe=47,me=120,Ne={animated:!0,style:{stroke:"#10b981",strokeDasharray:"4,4"},markerEnd:{type:A.MarkerType.ArrowClosed,color:"#10b981"}};for(const ce of Z){const E=j[ce.id]||[],J=`${ce.id}_dynamic_placeholder`,se=a.find(ye=>ye.id===J),ue=o.find(ye=>ye.target===J),de=o.find(ye=>ye.source===J);let ve,xe;if(de)ve=de.target,xe=a.find(ye=>ye.id===ve);else{const ye=a.indexOf(ce);if(xe=a.slice(ye).find(dr=>dr.type==="joinNode"),!xe)continue;ve=xe.id}if(!xe||(de&&Y.add(de.id),ue&&Y.add(ue.id),ge.add(J),!E.length))continue;const fe=E.length,_e=se?se.position.x+110:(ce.position.x+xe.position.x)/2,wr=se?se.position.y+35:(ce.position.y+xe.position.y)/2;E.forEach((ye,dr)=>{const Tr=`dynamic_rt_${ye.referenceTaskName}`,$b=ae?_e-me:ce.position.x+(dr-(fe-1)/2)*280,zb=ae?wr-pe+(dr-(fe-1)/2)*110:wr-pe;H.push({id:Tr,type:"taskNode",data:{label:ye.referenceTaskName,task:{name:ye.referenceTaskName,taskReferenceName:ye.referenceTaskName,type:ye.taskType||"SIMPLE"},taskReferenceName:ye.referenceTaskName,taskType:ye.taskType||"SIMPLE",isDynamicRuntime:!0,layoutDirection:N},position:{x:$b,y:zb}}),ne.push({id:`e-${ce.id}-${Tr}`,source:ce.id,target:Tr,...Ne}),ne.push({id:`e-${Tr}-${ve}`,source:Tr,target:ve,...Ne})})}return{extraNodes:H,extraEdges:ne,removedEdgeIds:Y,removedNodeIds:ge}},[d,j,a,o,N]),ee=O.useMemo(()=>[...S(o.filter(H=>!Q.removedEdgeIds.has(H.id))).map(H=>{const ne=H.id.includes("loop-back"),Y=g==="light"?"#64748b":"#94a3b8";let ae={...{...H.style,stroke:Y,strokeWidth:2,strokeDasharray:ne?"5,5":void 0}},pe=!1;if(d==="run"&&x){const E=x[H.source]?.status,J=x[H.target]?.status,se=E==="COMPLETED";se&&J==="COMPLETED"?(ae={...ae,stroke:"var(--status-completed)",strokeWidth:4},pe=!1):se&&J==="IN_PROGRESS"&&(ae={...ae,stroke:"var(--status-in-progress)",strokeWidth:4},pe=!0)}const me=H.source.endsWith("_dynamic_placeholder")||H.target.endsWith("_dynamic_placeholder"),Ne=H.source==="__workflow_start__"||H.source.startsWith("__loop_start__");return{...H,type:d==="edit"&&!ne&&!me&&!Ne?"addableEdge":m,data:{...H.data,mode:d,edgeType:m,label:H.label},markerEnd:{type:A.MarkerType.ArrowClosed,width:20,height:20,color:ae.stroke},style:ae,animated:pe}}),...Q.extraEdges],[o,m,g,d,x,Q,S]);return l.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",background:"var(--bg-secondary)"},children:[l.jsxs(A,{nodes:O.useMemo(()=>{if(P)return P.nodes;const z=new Set(b.errors.filter(Y=>Y.type==="TASK").map(Y=>Y.ref)),Z=new Set(b.warnings.filter(Y=>Y.type==="TASK").map(Y=>Y.ref)),H=n.toLowerCase();return a.filter(Y=>!Q.removedNodeIds.has(Y.id)&&C.has(Y.id)).map(Y=>{const ge=Y.data.taskReferenceName,ae=L[ge];return{...Y,selected:p?.taskReferenceName===ge,data:{...Y.data,isError:d==="edit"&&z.has(ge),hasWarning:d==="edit"&&Z.has(ge),isHighlighted:n?Y.data.label.toLowerCase().includes(H)||Y.data.taskReferenceName.toLowerCase().includes(H):!1,simRunning:ae==="running",simDone:ae==="done"}}}).concat(Q.extraNodes.map(Y=>({...Y,data:{...Y.data,isError:!1,hasWarning:!1,isHighlighted:!1}})))},[a,b,n,p,Q,C,L,d,P]),edges:P?.edges??ee,onNodesChange:i,onEdgesChange:u,onConnect:c,nodeTypes:cb,edgeTypes:db,onNodeClick:(z,Z)=>{if(Z.type==="plusNode"){te({sourceId:Z.data.parentRef,edgeData:Z.data.edgeData||{}}),K(!0);return}if(Z.type==="loopNode"){const ne=Z.data.task||null;h(ne),e&&e(ne);return}const H=Z.data.task||null;h(H),e&&e(H)},onPaneClick:()=>{h(null),d!=="run"&&k(!1)},fitView:!0,nodesDraggable:!y,nodesConnectable:!y,elementsSelectable:!0,minZoom:.2,maxZoom:2,children:[l.jsx(A.Background,{color:"var(--border-primary)",gap:20}),l.jsx(A.Panel,{position:"bottom-left",style:{marginBottom:"20px",marginLeft:"20px",zIndex:1e3},children:l.jsx(Rx,{})}),d==="run"&&l.jsx(A.Panel,{position:"bottom-center",children:l.jsx(jx,{})}),l.jsx(Fh,{isOpen:re,onClose:()=>q(!1),theme:g,onTaskSelect:z=>{h(z)}}),d!=="run"&&l.jsx(A.Panel,{position:"top-center",style:{marginTop:"14px"},children:l.jsx(Px,{})}),l.jsx("div",{style:{position:"absolute",top:20,right:20,zIndex:1e3},children:l.jsx(Ox,{onShowHealthCheck:()=>q(!re),showHealthCheck:re,onShowSettings:()=>ie(!0),executionActions:s})})]}),!w&&!I&&l.jsx(qx,{onRequestImport:t}),w&&a.length===0&&d==="edit"&&l.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:10,display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:l.jsxs("button",{className:"empty-state-btn primary",style:{padding:"12px 24px",borderRadius:"8px",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",fontSize:"16px",fontWeight:500,boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},onClick:()=>{te({sourceId:"start",targetId:"end",edgeId:"new",edgeData:{}}),K(!0)},children:[l.jsx("span",{style:{fontSize:"20px",lineHeight:1},children:"+"}),"添加第一个任务"]})}),W&&l.jsx(Cx,{theme:g,onSelect:le,onCancel:()=>K(!1)}),l.jsx(Lx,{isOpen:G,onClose:()=>ie(!1)}),M&&l.jsx(Yr,{message:M.message,onConfirm:_,onCancel:B}),l.jsx(Mx,{messages:$,onDismiss:U})]})},Xh={apiKey:"",baseUrl:"https://api.openai.com/v1",model:"gpt-4o"},Zh=async(e,n={},r)=>{const t={...Xh,...n};if(!t.apiKey)throw new Error("Please configure AI API Key in settings.");const s=await fetch(`${t.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${t.apiKey}`},body:JSON.stringify({model:t.model,messages:e,temperature:.7,stream:!1}),signal:r});if(!s.ok){const o=await s.json();throw new Error(o.error?.message||"AI request failed")}return(await s.json()).choices[0].message.content},fb=async(e,n={},r,t,s)=>{const a={...Xh,...n};if(!a.apiKey)throw new Error("Please configure AI API Key in settings.");const o=await fetch(`${a.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.apiKey}`},body:JSON.stringify({model:a.model,messages:e,temperature:.7,stream:!0}),signal:s});if(!o.ok){const d=await o.json();throw new Error(d.error?.message||"AI request failed")}const i=o.body?.getReader();if(!i)throw new Error("ReadableStream not supported");const u=new TextDecoder;let c="";for(;;){const{done:d,value:f}=await i.read();if(d)break;const h=u.decode(f,{stream:!0}).split(`
|
|
42
|
+
`).filter(g=>g.trim()!=="");for(const g of h)if(g.startsWith("data: ")){const m=g.slice(6);if(m==="[DONE]")return c;try{const y=JSON.parse(m).choices?.[0]?.delta?.content;y&&(c+=y,r(y))}catch{console.warn("[AI SSE] malformed chunk:",m)}}}return c},pb=(e,n,r,t,s)=>`
|
|
32
43
|
You are a Netflix Conductor expert. Generate a complete "inputParameters" JSON object for the following task.
|
|
33
44
|
|
|
34
45
|
Task Type: ${e}
|
|
35
|
-
Task Reference Name: ${
|
|
46
|
+
Task Reference Name: ${n}
|
|
36
47
|
Current inputParameters (may be incomplete): ${JSON.stringify(s,null,2)}
|
|
37
48
|
|
|
38
49
|
Available workflow input parameters (accessible via \${workflow.input.XXX}):
|
|
39
|
-
${
|
|
50
|
+
${r.length>0?r.map(a=>` - ${a}`).join(`
|
|
40
51
|
`):" (none defined)"}
|
|
41
52
|
|
|
42
53
|
Upstream tasks (accessible via \${taskRef.output.XXX}):
|
|
43
|
-
${
|
|
54
|
+
${t.length>0?t.map(a=>` - ${a.ref} (type: ${a.type})`).join(`
|
|
44
55
|
`):" (no upstream tasks)"}
|
|
45
56
|
|
|
46
57
|
Rules:
|
|
@@ -52,7 +63,7 @@ Rules:
|
|
|
52
63
|
6. Return ONLY the JSON object (no explanation, no markdown code block).
|
|
53
64
|
|
|
54
65
|
Return format: { "paramKey": "paramValue", ... }
|
|
55
|
-
`,
|
|
66
|
+
`,hb=async(e,n,r,t,s,a={})=>{const o=pb(e,n,r,t,s),u=(await Zh([{role:"system",content:"You are a Conductor expert. Return only valid JSON objects, no markdown."},{role:"user",content:o}],a)).replace(/```json\n?/g,"").replace(/```\n?/g,"").trim();return JSON.parse(u)},gb=`
|
|
56
67
|
You are an expert in Netflix Conductor Workflow modeling.
|
|
57
68
|
Your goal is to help users design JSON-based workflows.
|
|
58
69
|
|
|
@@ -64,11 +75,11 @@ CONSTRANTS:
|
|
|
64
75
|
5. For FORK_JOIN, ensure a corresponding JOIN task follows.
|
|
65
76
|
|
|
66
77
|
Provide clear, enterprise-grade logic with proper error handling paths.
|
|
67
|
-
`,
|
|
68
|
-
${JSON.stringify({name:
|
|
78
|
+
`,mb=(e,n)=>{const r=n?`当前工作流(JSON):
|
|
79
|
+
${JSON.stringify({name:n.name,tasks:n.tasks.map(t=>({ref:t.taskReferenceName,type:t.type,name:t.name}))},null,2)}`:"当前工作流:尚未定义。";return`
|
|
69
80
|
用户请求:${e}
|
|
70
81
|
|
|
71
|
-
${
|
|
82
|
+
${r}
|
|
72
83
|
|
|
73
84
|
请用中文回答,简明说明你将做什么修改,并在回答末尾(如果有工作流变更)输出一个结构化 diff 块,格式如下:
|
|
74
85
|
|
|
@@ -95,17 +106,17 @@ ${t}
|
|
|
95
106
|
|
|
96
107
|
如果是全量生成新工作流,使用 kind="replace" 并在 diff-json 中加入 "payload": {...完整工作流JSON...}。
|
|
97
108
|
如果不涉及工作流变更(仅解释/回答),则不需要输出 diff-json 块。
|
|
98
|
-
`},
|
|
109
|
+
`},vb=(e,n)=>`
|
|
99
110
|
Context: I am configuring a Conductor task in a workflow.
|
|
100
111
|
Task Reference Name: ${e.taskReferenceName}
|
|
101
112
|
Task Type: ${e.type}
|
|
102
113
|
|
|
103
114
|
Full Workflow Structure for reference:
|
|
104
|
-
${JSON.stringify(
|
|
115
|
+
${JSON.stringify(n,null,2)}
|
|
105
116
|
|
|
106
117
|
Requirement: Suggest 3 meaningful 'inputParameters' or JSONPath expressions for this task based on the workflow context.
|
|
107
118
|
Return the suggestions as a JSON array of objects with { label, value, description }.
|
|
108
|
-
`,
|
|
109
|
-
`).length," 行"]}),l.jsxs("span",{children:[d.length," 字符"]}),d!==r&&l.jsx("span",{style:{color:"#f59e0b",fontWeight:600},children:"● 未保存"})]})]}),document.body)},ib=[{label:"工作流输入",value:"${workflow.input.fieldName}",desc:"引用工作流启动时传入的参数"},{label:"上游任务输出",value:"${taskRef.output.result}",desc:"引用上游任务的输出字段"},{label:"工作流变量",value:"${workflow.variables.varName}",desc:"引用 SET_VARIABLE 设置的变量"},{label:"工作流 ID",value:"${workflow.workflowId}",desc:"当前工作流实例 ID"},{label:"关联 ID",value:"${workflow.correlationId}",desc:"工作流关联 ID"},{label:"工作流状态",value:"${workflow.status}",desc:"当前工作流状态"}],lb=({task:e,isOpen:r=!0,onClose:t,aiConfig:n})=>{const{mode:s,updateTask:a,checkTaskRefUniqueness:o}=ie(),[i,d]=P.useState(e),[c,u]=P.useState(e?.taskReferenceName??null),[f,p]=P.useState(null),[h,g]=P.useState(!1),[m,v]=P.useState(null),[y,x]=P.useState(()=>e?.type==="WAIT"&&e.inputParameters?.until?"until":"duration"),[b,k]=P.useState(()=>e?.type==="DO_WHILE"&&e.inputParameters?.items?"items":"condition"),[w,j]=P.useState(()=>!e||e.type!=="FORK_JOIN_DYNAMIC"?"classic":e.forkTaskWorkflow?"workflow":e.forkTaskType?"task":"classic"),[N,L]=P.useState(!1),[T,C]=P.useState(),[S,q]=P.useState([]),[I,O]=P.useState(()=>()=>{}),[F,W]=P.useState(null),[V,Z]=P.useState(!1),[ne,ee]=P.useState(null),D=(E,X,ae,le)=>{W({title:E,value:X,language:ae,onSave:le})},Y=[{label:"引用工作流输入",value:"${workflow.input.data}",description:"引用工作流启动时传入的原始数据"},{label:"引用前序任务输出",value:"${previous_task.output.result}",description:"引用上一个节点的计算结果"},{label:"环境变量",value:"${workflow.variables.api_key}",description:"引用工作流定义的全局变量"}],se=async()=>{const E=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!E){alert("请先在设置中配置 AI API Key");return}if(M){Z(!0);try{const{workflowDef:X,taskMap:ae}=ie.getState(),le=Vr(X?.inputParameters).map(re=>re.name),ce=Object.values(ae).filter(re=>re.taskReferenceName!==M.taskReferenceName).map(re=>({ref:re.taskReferenceName,type:re.type,name:re.name})).slice(0,10),he={apiKey:E};n?.baseUrl&&(he.baseUrl=n.baseUrl),n?.model&&(he.model=n.model);const ke=await rb(M.type,M.taskReferenceName,le,ce,M.inputParameters??{},he);ee({generated:ke,original:M.inputParameters??{}})}catch(X){alert(`AI 生成失败:${X?.message||"未知错误"}`)}finally{Z(!1)}}},R=async(E,X)=>{const ae=E.currentTarget.getBoundingClientRect();C(ae),O(()=>X),q([]),L(!0);const le=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!le){q(Y);return}try{const ce=n?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",he=n?.model||localStorage.getItem("AI_MODEL")||"",ke={apiKey:le};ce&&(ke.baseUrl=ce),he&&(ke.model=he);const{workflowDef:re}=ie.getState(),xe=ab(M,re),We=(await Kh([{role:"system",content:"You are a Conductor workflow expert. Return only valid JSON."},{role:"user",content:xe}],ke)).match(/\[[\s\S]*\]/);if(We){const Hi=JSON.parse(We[0]);q(Hi)}else q(Y)}catch{q(Y)}};if(P.useEffect(()=>{e&&(d(e),u(e.taskReferenceName),p(null),e.type==="WAIT"&&x(e.inputParameters?.until?"until":"duration"),e.type==="DO_WHILE"&&k(e.inputParameters?.items?"items":"condition"),e.type==="FORK_JOIN_DYNAMIC"&&(e.forkTaskWorkflow?j("workflow"):e.forkTaskType?j("task"):j("classic")))},[e]),!e&&!i)return null;const M=e||i,_=i&&e&&c===e.taskReferenceName?i:M,B=r&&e?"panel-enter-active":"panel-exit",z=s==="edit",Q="var(--text-primary)",G="var(--glass-border)",oe="var(--bg-tertiary)",H="var(--text-secondary)",$=(E,X)=>{const ae={..._,[E]:X};d(ae),a(_.taskReferenceName,{[E]:X})},K=(E,X,ae)=>{const ce={..._[E]||{},[X]:ae},he={..._,[E]:ce};d(he),a(_.taskReferenceName,{[E]:ce})},U=(E,X)=>{const ae=_.inputParameters||{},ce={...ae.http_request||_.httpRequest||{},[E]:X},ke={inputParameters:{...ae,http_request:ce}};_.httpRequest&&(ke.httpRequest=ce);const re={..._,...ke};d(re),a(_.taskReferenceName,ke)},J=(E,X)=>{const le={inputParameters:{..._.inputParameters,[E]:X}},ce={..._,...le};d(ce),a(_.taskReferenceName,le)},te=E=>{if(!m)return;const X=m.selectionStart??0,ae=m.selectionEnd??0,le=m.value,ce=le.substring(0,X)+E+le.substring(ae),he=m.getAttribute("data-field");he&&$(he,ce),g(!1)},ue=(E,X,ae,le)=>l.jsxs("div",{style:{marginBottom:"24px",padding:"16px",borderRadius:"12px",background:`${ae}10`,border:`1px solid ${ae}30`,boxShadow:"0 4px 12px rgba(0,0,0,0.05)"},children:[l.jsxs("div",{style:{fontSize:"12px",fontWeight:"bold",marginBottom:"16px",color:ae,display:"flex",alignItems:"center",gap:"8px"},children:[l.jsx("span",{children:X})," ",E]}),le]}),fe=(E,X,ae="text",le)=>{const ce=X==="taskReferenceName",he=ce&&f!==null?f:_[X]??"",ke=ce&&!o(he,_.taskReferenceName);return l.jsxs("div",{style:{marginBottom:"16px"},children:[l.jsxs("label",{style:{display:"block",fontSize:"11px",color:H,marginBottom:"6px",fontWeight:"600",textTransform:"uppercase"},children:[E,ce&&ke&&l.jsx("span",{style:{color:"#ef4444",marginLeft:"8px",textTransform:"none"},children:"⚠️ 已存在相同引用名"})]}),l.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[l.jsx("input",{type:ae,value:he,placeholder:le,onChange:re=>{ce?p(re.target.value):$(X,ae==="number"?re.target.value===""?void 0:Number(re.target.value):re.target.value)},onFocus:ce?()=>{f===null&&p(_.taskReferenceName??"")}:void 0,onBlur:ce?re=>{const xe=re.target.value.trim();p(null),xe&&xe!==_.taskReferenceName&&$("taskReferenceName",xe)}:void 0,onKeyDown:ce?re=>{re.key==="Enter"&&re.currentTarget.blur(),re.stopPropagation()}:void 0,disabled:!z,style:{width:"100%",padding:`8px ${z&&!ce?"32px":"12px"} 8px 12px`,borderRadius:"6px",border:`1px solid ${ke?"#ef4444":G}`,background:oe,color:Q,fontSize:"13px",outline:"none",opacity:z?1:.8,fontFamily:ce?"monospace":"inherit"}}),z&&!ce&&l.jsx("button",{className:"ai-hint-trigger",onClick:re=>R(re,xe=>$(X,xe)),title:"AI 智能提示",style:{position:"absolute",right:"8px",background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"4px",opacity:.6,display:"flex",alignItems:"center",justifyContent:"center"},children:"✨"})]})]})},me=(E,X,ae,le={})=>{const{rows:ce=5,language:he="text",style:ke,placeholder:re,"data-field":xe}=le,Ue={width:"100%",padding:"12px",borderRadius:"8px",border:`1px solid ${G}`,background:oe,color:Q,fontSize:"12px",fontFamily:"monospace",lineHeight:"1.5",resize:"vertical",...ke};return l.jsxs("div",{style:{marginBottom:"8px"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"},children:[l.jsx("label",{style:{fontSize:"10px",color:H},children:E}),z&&l.jsx("button",{onClick:()=>D(E,X,he,We=>{ae(We),W(null)}),title:"全屏编辑",style:{background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"2px 4px",color:"var(--text-secondary)",opacity:.7,lineHeight:1},children:"⛶"})]}),l.jsx("textarea",{value:X,placeholder:re,onChange:We=>ae(We.target.value),disabled:!z,rows:ce,"data-field":xe,onFocus:We=>v(We.currentTarget),style:Ue})]})},de=(E,X,ae,le="text",ce)=>l.jsxs("div",{style:{marginBottom:"12px"},children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:E}),l.jsx("input",{type:le,value:X??"",placeholder:ce,onChange:he=>ae(le==="number"?he.target.value===""?void 0:Number(he.target.value):he.target.value),disabled:!z,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${G}`,background:oe,color:Q,fontSize:"12px",outline:"none"}})]}),pe=(E,X,ae,le)=>l.jsxs("div",{style:{marginBottom:"12px"},children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:E}),l.jsx("select",{value:ae,onChange:ce=>le(ce.target.value),disabled:!z,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${G}`,background:oe,color:Q,fontSize:"12px",outline:"none",cursor:"pointer"},children:X.map(ce=>l.jsx("option",{value:ce,children:ce},ce))})]}),ve=(E,X,ae)=>l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[l.jsx("span",{style:{fontSize:"11px",color:H},children:E}),l.jsx("button",{onClick:()=>ae(!X),disabled:!z,style:{width:"36px",height:"20px",borderRadius:"10px",border:"none",cursor:"pointer",background:X?"var(--color-accent)":G,position:"relative",transition:"background 0.2s"},children:l.jsx("span",{style:{position:"absolute",top:"2px",left:X?"18px":"2px",width:"16px",height:"16px",borderRadius:"50%",background:"#fff",transition:"left 0.2s"}})})]}),Te=(E,X,ae)=>l.jsx("div",{style:{display:"flex",gap:"6px",marginBottom:"12px"},children:E.map(le=>l.jsx("button",{onClick:()=>ae(le.key),disabled:!z,style:{flex:1,padding:"6px",borderRadius:"6px",border:`1px solid ${G}`,cursor:"pointer",fontSize:"11px",fontWeight:X===le.key?"bold":"normal",background:X===le.key?"var(--color-accent)":oe,color:X===le.key?"#fff":Q},children:le.label},le.key))}),ye=_.inputParameters?.http_request||_.httpRequest||{};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:`detail-panel-container ${B}`,style:{position:"absolute",right:0,top:0,bottom:0,width:"450px",zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${G}`,boxShadow:"-10px 0 30px rgba(0, 0, 0, 0.2)",overflowY:"hidden"},children:[l.jsxs("div",{style:{padding:"24px",borderBottom:`1px solid ${G}`,background:"var(--bg-secondary)",flexShrink:0},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[l.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:"4px",fontSize:"10px",fontWeight:"bold",letterSpacing:"1px"},children:_.type||"TASK"}),l.jsx("button",{onClick:t,style:{background:"none",border:"none",color:Q,cursor:"pointer",fontSize:"20px"},children:"✕"})]}),z?l.jsx("input",{value:_.name||"",onChange:E=>$("name",E.target.value),placeholder:"任务名称",style:{display:"block",width:"100%",fontSize:"22px",fontWeight:"bold",background:"transparent",border:"none",color:Q,outline:"none",borderBottom:"2px dashed var(--color-accent)"}}):l.jsx("div",{style:{fontSize:"22px",fontWeight:"bold"},children:_.name}),l.jsxs("div",{style:{fontSize:"12px",color:H,marginTop:"8px",fontFamily:"monospace",opacity:.8},children:["REF: ",_.taskReferenceName]})]}),l.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px",background:"var(--bg-primary)"},children:[_.type==="HTTP"&&ue("HTTP 请求配置","🌐","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"12px"},children:[l.jsx("select",{value:ye.method||"GET",onChange:E=>U("method",E.target.value),disabled:!z,style:{width:"90px",padding:"10px",borderRadius:"8px",background:oe,color:Q,border:`1px solid ${G}`,cursor:"pointer"},children:["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"].map(E=>l.jsx("option",{value:E,children:E},E))}),l.jsx("input",{placeholder:"URI (支持 ${workflow.input.uri})",value:ye.uri||"",onChange:E=>U("uri",E.target.value),disabled:!z,style:{flex:1,padding:"10px",borderRadius:"8px",background:oe,color:Q,border:`1px solid ${G}`}})]}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"CONTENT-TYPE"}),l.jsx("input",{placeholder:"application/json",value:ye.contentType||"",onChange:E=>U("contentType",E.target.value),disabled:!z,style:{width:"100%",padding:"8px",borderRadius:"6px",background:oe,color:Q,border:`1px solid ${G}`,fontSize:"12px"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"ACCEPT"}),l.jsx("input",{placeholder:"application/json",value:ye.accept||"",onChange:E=>U("accept",E.target.value),disabled:!z,style:{width:"100%",padding:"8px",borderRadius:"6px",background:oe,color:Q,border:`1px solid ${G}`,fontSize:"12px"}})]})]}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"连接超时 (ms)"}),l.jsx("input",{type:"number",placeholder:"3000",value:ye.connectionTimeOut??"",onChange:E=>U("connectionTimeOut",E.target.value===""?void 0:Number(E.target.value)),disabled:!z,style:{width:"100%",padding:"8px",borderRadius:"6px",background:oe,color:Q,border:`1px solid ${G}`,fontSize:"12px"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"读取超时 (ms)"}),l.jsx("input",{type:"number",placeholder:"3000",value:ye.readTimeOut??"",onChange:E=>U("readTimeOut",E.target.value===""?void 0:Number(E.target.value)),disabled:!z,style:{width:"100%",padding:"8px",borderRadius:"6px",background:oe,color:Q,border:`1px solid ${G}`,fontSize:"12px"}})]})]}),l.jsxs("div",{style:{marginBottom:"12px"},children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"HEADERS (JSON)"}),l.jsx("textarea",{value:typeof ye.headers=="object"?JSON.stringify(ye.headers,null,2):"{}",onChange:E=>{try{U("headers",JSON.parse(E.target.value))}catch{}},disabled:!z,rows:3,style:{width:"100%",padding:"8px",borderRadius:"8px",background:oe,color:Q,border:`1px solid ${G}`,fontSize:"11px",fontFamily:"monospace"}})]}),l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"BODY (RAW/JSON)"}),l.jsx("textarea",{value:typeof ye.body=="object"?JSON.stringify(ye.body,null,2):ye.body||"",onChange:E=>{let X=E.target.value;try{X=JSON.parse(E.target.value)}catch{}U("body",X)},disabled:!z,rows:4,style:{width:"100%",padding:"8px",borderRadius:"8px",background:oe,color:Q,border:`1px solid ${G}`,fontSize:"11px",fontFamily:"monospace"}})]})),(_.type==="INLINE"||_.type==="LAMBDA")&&ue("内联脚本配置 (Inline)","📜","var(--color-accent)",l.jsxs(l.Fragment,{children:[pe("脚本引擎",["graaljs","javascript","value-param","python"],_.evaluatorType||"graaljs",E=>$("evaluatorType",E)),me(`EXPRESSION ${_.evaluatorType==="value-param"?"(值引用)":"(脚本)"}`,_.inputParameters?.expression||_.inputParameters?.scriptExpression||"",E=>{const X=_.inputParameters?.scriptExpression!==void 0?"scriptExpression":"expression";J(X,E)},{rows:10,language:_.evaluatorType||"javascript",style:{background:"#000",color:"var(--color-accent)",border:"1px solid var(--color-accent)"}}),l.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:H,fontStyle:"italic"},children:"提示: 使用 $.input.key 访问输入参数,返回值作为任务输出。"})]})),_.type==="JSON_JQ_TRANSFORM"&&ue("JQ 数据转换","🔍","var(--color-accent)",l.jsxs(l.Fragment,{children:[me("JQ QUERY EXPRESSION",_.inputParameters?.queryExpression||"",E=>J("queryExpression",E),{rows:6,language:"jq",style:{color:"var(--color-accent)"}}),l.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:H},children:"输出字段: result(首个结果)、resultList(完整列表)"})]})),_.type==="SUB_WORKFLOW"&&ue("子工作流配置","🏗️","var(--color-accent)",l.jsxs(l.Fragment,{children:[de("WORKFLOW NAME *",_.subWorkflowParam?.name||"",E=>K("subWorkflowParam","name",E),"text","e.g. my_workflow"),de("VERSION",_.subWorkflowParam?.version??"",E=>K("subWorkflowParam","version",E?parseInt(E):void 0),"number","1"),me("INPUT PARAMETERS MAPPING (JSON)",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):"{}",E=>{try{$("inputParameters",JSON.parse(E))}catch{}},{rows:5,language:"json"}),l.jsxs("div",{style:{fontSize:"10px",color:H,marginTop:"4px"},children:["传递给子工作流的参数,支持 ","${workflow.input.xxx}"," 表达式"]})]})),_.type==="START_WORKFLOW"&&ue("启动工作流配置","▶️","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{fontSize:"11px",color:H,marginBottom:"12px",padding:"8px",borderRadius:"6px",background:"rgba(255,165,0,0.1)",border:"1px solid rgba(255,165,0,0.3)"},children:["⚡ 注意:此任务启动目标工作流后立即继续,",l.jsx("b",{children:"不等待"}),"目标工作流完成。"]}),de("WORKFLOW NAME *",_.inputParameters?.startWorkflow?.name||"",E=>{const X={..._.inputParameters?.startWorkflow||{},name:E};J("startWorkflow",X)},"text","e.g. target_workflow"),de("VERSION",_.inputParameters?.startWorkflow?.version??"",E=>{const X={..._.inputParameters?.startWorkflow||{},version:E?parseInt(E):void 0};J("startWorkflow",X)},"number","1"),de("CORRELATION ID",_.inputParameters?.startWorkflow?.correlationId||"",E=>{const X={..._.inputParameters?.startWorkflow||{},correlationId:E};J("startWorkflow",X)},"text","${workflow.correlationId}"),me("WORKFLOW INPUT (JSON)",typeof _.inputParameters?.startWorkflow?.input=="object"?JSON.stringify(_.inputParameters.startWorkflow.input,null,2):"{}",E=>{try{const X={..._.inputParameters?.startWorkflow||{},input:JSON.parse(E)};J("startWorkflow",X)}catch{}},{rows:4,language:"json"})]})),_.type==="TERMINATE"&&ue("终止状态配置","⏹️","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"TERMINATION STATUS"}),l.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:["COMPLETED","FAILED"].map(E=>l.jsx("button",{onClick:()=>J("terminationStatus",E),disabled:!z,style:{flex:1,padding:"8px",borderRadius:"6px",cursor:"pointer",background:(_.inputParameters?.terminationStatus||"COMPLETED")===E?"var(--color-accent)":oe,color:(_.inputParameters?.terminationStatus||"COMPLETED")===E?"#fff":Q,border:`1px solid ${G}`,fontWeight:"bold",fontSize:"11px"},children:E},E))}),de("TERMINATION REASON",_.inputParameters?.terminationReason||"",E=>J("terminationReason",E),"text","终止原因..."),me("WORKFLOW OUTPUT (JSON)",typeof _.inputParameters?.workflowOutput=="object"?JSON.stringify(_.inputParameters.workflowOutput,null,2):"{}",E=>{try{J("workflowOutput",JSON.parse(E))}catch{}},{rows:3,language:"json"})]})),_.type==="EVENT"&&ue("事件发送配置","✉️","var(--color-accent)",l.jsxs(l.Fragment,{children:[de("EVENT SINK *",_.sink||"",E=>$("sink",E),"text","e.g. sqs:queue_name 或 conductor"),l.jsx("div",{style:{fontSize:"10px",color:H,marginTop:"4px",marginBottom:"8px"},children:"支持前缀: conductor | sqs | kafka | amqp | nats"}),ve("异步完成 (asyncComplete)",!!_.asyncComplete,E=>$("asyncComplete",E))]})),_.type==="WAIT"&&ue("等待状态配置","⏳","var(--color-accent)",l.jsxs(l.Fragment,{children:[Te([{key:"duration",label:"等待时长"},{key:"until",label:"等待到指定时间"}],y,E=>x(E)),y==="duration"?de("DURATION",_.inputParameters?.duration||"",E=>J("duration",E),"text","e.g. 30s, 10m, 2 hours"):de("UNTIL (时间点)",_.inputParameters?.until||"",E=>J("until",E),"text","e.g. 2025-06-15 09:00 GMT+00:00"),l.jsxs("div",{style:{fontSize:"11px",color:H,lineHeight:"1.6",marginTop:"8px"},children:["此任务会使工作流进入 ",l.jsx("b",{children:"IN_PROGRESS"})," 状态,直到时间满足或外部 API 触发完成。"]})]})),(_.type==="DECISION"||_.type==="SWITCH")&&ue("条件分支配置","⚖️","var(--color-accent)",l.jsxs(l.Fragment,{children:[pe("评估模式 (evaluatorType)",["value-param","javascript"],_.evaluatorType||"value-param",E=>$("evaluatorType",E)),(_.evaluatorType||"value-param")==="value-param"?de("CASE VALUE PARAM (参数名)",_.caseValueParam||"",E=>$("caseValueParam",E),"text","e.g. status"):l.jsx(l.Fragment,{children:me("CASE EXPRESSION (JS)",_.caseExpression||"",E=>$("caseExpression",E),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}})}),l.jsx("div",{style:{fontSize:"10px",color:H,marginTop:"8px"},children:'分支可在图中通过右键节点→"添加分支"进行管理'})]})),_.type==="DO_WHILE"&&ue("循环逻辑配置","🔄","var(--color-accent)",l.jsxs(l.Fragment,{children:[Te([{key:"condition",label:"条件循环"},{key:"items",label:"列表迭代"}],b,E=>k(E)),b==="condition"?l.jsxs(l.Fragment,{children:[me("LOOP CONDITION (JS) *",_.loopCondition||"",E=>$("loopCondition",E),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}}),l.jsx("div",{style:{fontSize:"10px",color:H,marginTop:"4px"},children:"条件为 true 时继续循环,false 时退出"})]}):l.jsxs(l.Fragment,{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:H,marginBottom:"4px"},children:"ITEMS (列表表达式)"}),l.jsx("input",{value:_.inputParameters?.items||"",onChange:E=>J("items",E.target.value),disabled:!z,placeholder:"${workflow.input.myList}",style:{width:"100%",padding:"8px",borderRadius:"6px",border:`1px solid ${G}`,background:oe,color:Q,fontSize:"12px",outline:"none"}}),l.jsx("div",{style:{fontSize:"10px",color:H,marginTop:"4px"},children:"引用一个数组,对每个元素执行一次循环体"})]}),l.jsx("div",{style:{marginTop:"12px"},children:de("KEEP LAST N 次迭代",_.keepLastN??"",E=>$("keepLastN",E?parseInt(E):void 0),"number","0 = 保留全部")})]})),_.type==="FORK_JOIN_DYNAMIC"&&ue("动态并行配置","⚡","var(--color-accent)",l.jsxs(l.Fragment,{children:[Te([{key:"classic",label:"经典模式"},{key:"task",label:"任务简化"},{key:"workflow",label:"工作流简化"}],w,E=>j(E)),w==="classic"&&l.jsxs(l.Fragment,{children:[de("DYNAMIC_FORK_TASKS_PARAM",_.dynamicForkTasksParam||"",E=>$("dynamicForkTasksParam",E),"text","e.g. dynamic_tasks"),de("DYNAMIC_FORK_TASKS_INPUT_PARAM",_.dynamicForkTasksInputParamName||"",E=>$("dynamicForkTasksInputParamName",E),"text","e.g. input"),l.jsx("div",{style:{fontSize:"10px",color:H},children:"经典模式:通过 inputParameters 传入 dynamicTasks 数组和 dynamicTasksInput 映射"})]}),w==="task"&&l.jsxs(l.Fragment,{children:[de("FORK TASK TYPE *",_.forkTaskType||"",E=>$("forkTaskType",E),"text","e.g. HTTP"),de("FORK TASK NAME (仅 SIMPLE 任务)",_.forkTaskName||"",E=>$("forkTaskName",E),"text","e.g. my_task"),de("FORK TASK INPUTS PARAM",_.forkTaskInputs||"",E=>$("forkTaskInputs",E),"text","e.g. inputs"),l.jsx("div",{style:{fontSize:"10px",color:H},children:"所有分支执行相同任务类型,每个元素作为一个分支输入"})]}),w==="workflow"&&l.jsxs(l.Fragment,{children:[de("FORK WORKFLOW NAME *",_.forkTaskWorkflow||"",E=>$("forkTaskWorkflow",E),"text","e.g. sub_workflow"),de("WORKFLOW VERSION",_.forkTaskWorkflowVersion||"",E=>$("forkTaskWorkflowVersion",E),"text","1"),de("FORK TASK INPUTS PARAM",_.forkTaskInputs||"",E=>$("forkTaskInputs",E),"text","e.g. inputs"),l.jsx("div",{style:{fontSize:"10px",color:H},children:"所有分支执行相同子工作流,每个元素作为一个子工作流输入"})]})]})),_.type==="DYNAMIC"&&ue("动态任务配置","🎯","var(--color-accent)",l.jsxs(l.Fragment,{children:[de("DYNAMIC TASK NAME PARAM *",_.dynamicTaskNameParam||"",E=>$("dynamicTaskNameParam",E),"text","e.g. taskToExecute"),l.jsx("div",{style:{fontSize:"10px",color:H,marginTop:"4px"},children:'运行时从 inputParameters 的指定键中读取实际任务类型名(如 "HTTP"、"SIMPLE")'})]})),_.type==="HUMAN"&&ue("人工审批配置","👤","var(--color-accent)",l.jsxs(l.Fragment,{children:[de("表单模板名 (userFormTemplate)",_.humanTaskDef?.userFormTemplate||"",E=>K("humanTaskDef","userFormTemplate",E),"text","e.g. approval_form"),pe("分配策略 (assignmentCompletionStrategy)",["LEAVE_OPEN","TERMINATE"],_.humanTaskDef?.assignmentCompletionStrategy||"LEAVE_OPEN",E=>K("humanTaskDef","assignmentCompletionStrategy",E)),de("显示名称 (displayName)",_.humanTaskDef?.displayName||"",E=>K("humanTaskDef","displayName",E),"text","审批任务")]})),_.type==="KAFKA_PUBLISH"&&ue("Kafka 推送配置","📨","var(--color-accent)",l.jsxs(l.Fragment,{children:[de("BOOTSTRAP SERVERS *",_.inputParameters?.bootStrapServers||"",E=>J("bootStrapServers",E),"text","localhost:9092"),de("TOPIC *",_.inputParameters?.topic||"",E=>J("topic",E),"text","my_topic"),de("KEY (消息分区键)",_.inputParameters?.key||"",E=>J("key",E),"text",""),me("VALUE (消息内容)",typeof _.inputParameters?.value=="object"?JSON.stringify(_.inputParameters.value,null,2):_.inputParameters?.value||"",E=>{let X=E;try{X=JSON.parse(E)}catch{}J("value",X)},{rows:4,language:"json"}),me("HEADERS (JSON)",typeof _.inputParameters?.headers=="object"?JSON.stringify(_.inputParameters.headers,null,2):"{}",E=>{try{J("headers",JSON.parse(E))}catch{}},{rows:3,language:"json"})]})),_.type==="SET_VARIABLE"&&ue("变量配置","📦","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{fontSize:"11px",color:H,marginBottom:"12px"},children:["在 inputParameters 中定义要设置的变量名和值,后续任务通过 ","${workflow.variables.varName}"," 访问。"]}),me("VARIABLES (JSON)",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):"{}",E=>{try{$("inputParameters",JSON.parse(E))}catch{}},{rows:6,language:"json"})]})),l.jsxs("div",{style:{marginTop:"32px",borderTop:`1px solid ${G}`,paddingTop:"24px"},children:[l.jsx("div",{style:{fontSize:"11px",fontWeight:"bold",marginBottom:"16px",opacity:.6,textTransform:"uppercase",letterSpacing:"1px"},children:"通用参数与属性"}),fe("任务唯一引用名 (Reference Name)","taskReferenceName"),fe("任务描述","description"),l.jsxs("div",{style:{marginBottom:"16px"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px",gap:"6px"},children:[l.jsxs("label",{style:{fontSize:"11px",color:H,fontWeight:"600",textTransform:"uppercase",flex:1},children:["输入参数 (inputParameters) ",l.jsx("span",{style:{opacity:.5,fontWeight:"normal"},children:"(JSON)"})]}),z&&l.jsxs("div",{style:{display:"flex",gap:"6px"},children:[l.jsxs("button",{onClick:se,disabled:V,title:"AI 根据上下文自动生成 inputParameters",style:{fontSize:"11px",background:"linear-gradient(135deg, #6366f1, #8b5cf6)",border:"none",borderRadius:"4px",padding:"2px 8px",cursor:V?"not-allowed":"pointer",color:"#fff",fontWeight:600,display:"flex",alignItems:"center",gap:"4px",opacity:V?.7:1},children:[V?"⏳":"✨"," AI 填充"]}),l.jsxs("button",{onClick:()=>g(!h),title:"快捷表达式",style:{fontSize:"11px",background:h?"var(--color-accent)":"none",border:`1px solid ${G}`,borderRadius:"4px",padding:"2px 6px",cursor:"pointer",color:h?"#fff":H},children:["{}"," 片段"]})]})]}),h&&l.jsx("div",{style:{marginBottom:"8px",padding:"8px",borderRadius:"6px",border:`1px solid ${G}`,background:"var(--bg-secondary)",display:"flex",flexWrap:"wrap",gap:"6px"},children:ib.map(E=>l.jsx("button",{onClick:()=>te(E.value),title:E.desc,style:{fontSize:"10px",padding:"3px 8px",borderRadius:"4px",border:`1px solid ${G}`,background:oe,color:Q,cursor:"pointer",fontFamily:"monospace"},children:E.label},E.value))}),ne&&l.jsxs("div",{style:{marginBottom:"8px",borderRadius:"8px",border:"1px solid #6366f130",background:"#6366f108",overflow:"hidden"},children:[l.jsxs("div",{style:{padding:"8px 12px",background:"#6366f118",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[l.jsx("span",{style:{fontSize:"11px",fontWeight:700,color:"#6366f1"},children:"✨ AI 建议的 inputParameters"}),l.jsxs("div",{style:{display:"flex",gap:"6px"},children:[l.jsx("button",{onClick:()=>{$("inputParameters",ne.generated),ee(null)},style:{fontSize:"11px",background:"#6366f1",color:"#fff",border:"none",borderRadius:"4px",padding:"3px 10px",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:"应用"}),l.jsx("button",{onClick:()=>ee(null),style:{fontSize:"11px",background:"none",color:H,border:`1px solid ${G}`,borderRadius:"4px",padding:"3px 8px",cursor:"pointer",fontFamily:"inherit"},children:"取消"})]})]}),l.jsx("pre",{style:{margin:0,padding:"10px 12px",fontSize:"12px",fontFamily:"var(--font-mono)",overflowX:"auto",color:Q,maxHeight:"180px",overflowY:"auto"},children:JSON.stringify(ne.generated,null,2)})]}),me("",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):_.inputParameters??"",E=>{try{$("inputParameters",JSON.parse(E))}catch{d(X=>({...X,inputParameters:E}))}},{rows:5,language:"json","data-field":"inputParameters",style:{outline:"none"}})]}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[fe("重试次数","retryCount","number"),fe("超时限制 (秒)","timeoutSeconds","number")]}),l.jsxs("details",{style:{marginTop:"16px"},children:[l.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",color:H,userSelect:"none",fontWeight:"600"},children:"▸ 执行控制(高级)"}),l.jsxs("div",{style:{marginTop:"12px"},children:[pe("重试策略 (retryLogic)",["FIXED","EXPONENTIAL_BACKOFF","LINEAR_BACKOFF"],_.retryLogic||"FIXED",E=>$("retryLogic",E)),de("重试延迟 (秒)",_.retryDelaySeconds??"",E=>$("retryDelaySeconds",E?parseInt(E):void 0),"number","0"),pe("超时策略 (timeoutPolicy)",["TIME_OUT_WF","ALERT_ONLY","RETRY","FAIL_WORKFLOW"],_.timeoutPolicy||"TIME_OUT_WF",E=>$("timeoutPolicy",E)),de("启动延迟 (秒)",_.startDelay??"",E=>$("startDelay",E?parseInt(E):void 0),"number","0"),ve("可选任务 (optional) — 失败不影响工作流",!!_.optional,E=>$("optional",E)),ve("异步完成 (asyncComplete)",!!_.asyncComplete,E=>$("asyncComplete",E))]})]})]}),l.jsx("div",{style:{marginTop:"48px",opacity:.6},children:l.jsxs("details",{children:[l.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",marginBottom:"8px"},children:"查看完整 JSON (只读)"}),l.jsx("pre",{style:{background:"rgba(0,0,0,0.2)",padding:"16px",borderRadius:"8px",fontSize:"10px",overflow:"auto",border:`1px solid ${G}`,color:H},children:JSON.stringify(_,null,2)})]})})]}),z&&l.jsxs("div",{style:{padding:"24px",borderTop:`1px solid ${G}`,background:"var(--bg-secondary)",display:"flex",gap:"12px",flexShrink:0},children:[l.jsx("div",{style:{flex:1,fontSize:"11px",color:H,display:"flex",alignItems:"center"},children:"✅ 所有修改已实时同步"}),l.jsx("button",{onClick:t,style:{padding:"10px 24px",background:"var(--color-accent)",color:"#fff",border:"none",borderRadius:"8px",fontWeight:"bold",cursor:"pointer",boxShadow:"0 4px 12px var(--color-accent-bg)"},children:"完成退出"})]}),l.jsx(sb,{isOpen:N,onClose:()=>L(!1),onSelect:I,suggestions:S,anchorRect:T})]}),F&&l.jsx(ob,{title:F.title,value:F.value,language:F.language,onSave:F.onSave,onClose:()=>W(null)})]})},cb=P.memo(lb),ub={COMPLETED:"var(--status-completed)",FAILED:"var(--status-failed)",FAILED_WITH_TERMINAL_ERROR:"var(--status-failed-terminal)",IN_PROGRESS:"var(--status-in-progress)",SCHEDULED:"var(--status-scheduled)",TIMED_OUT:"var(--status-timed-out)",CANCELED:"var(--status-canceled)",SKIPPED:"var(--status-skipped)"},_r=e=>ub[e??""]??"var(--text-secondary)",db=(e,r)=>{if(!e)return"-";const t=(r??Date.now())-e;return t<1e3?`${t}ms`:`${(t/1e3).toFixed(2)}s`},Uh=e=>e?new Date(e).toLocaleTimeString():"-",fb=({executionActions:e})=>{const{selectedTask:r,selectedTaskInstance:t,setSelectedTask:n,setSelectedTaskInstance:s,executionData:a,workflowInstance:o}=ie(),[i,d]=P.useState("summary"),c=P.useRef(null);P.useEffect(()=>{c.current?.scrollTo({top:0})},[i,r?.taskReferenceName]),P.useEffect(()=>{d("summary")},[r?.taskReferenceName]);const u=r?.taskReferenceName==="__workflow_global__",f=r?a?.[r.taskReferenceName]:null;if(!r||!f&&!u)return null;const p=f?.attempts??[],h=t??p[p.length-1],g=o?.workflowId??"",m=o?.status,v=f?.status,y=u?m:h?.status??v,x=u?o?.startTime:h?.startTime,b=u?o?.endTime:h?.endTime,k=u?o?.reasonForIncompletion:h?.reasonForIncompletion,w=u?o?.workflowId:h?.taskId,j=u?o?.input:h?.inputData,N=u?o?.output:h?.outputData,L=!u&&e?.onSkipTask&&(v==="SCHEDULED"||v==="IN_PROGRESS")&&(m==="RUNNING"||m==="PAUSED"),T=!u&&e?.onRerunFromTask&&(m==="FAILED"||m==="TERMINATED"||m==="COMPLETED"||m==="TIMED_OUT"),C=L||T,S=e?.allowOperations!==!1,q=()=>{n(null),s(null)},I="var(--glass-border)",O="var(--text-secondary)",F="var(--bg-tertiary)";return l.jsxs("div",{className:"detail-panel-container panel-enter-active",style:{position:"absolute",right:0,top:0,bottom:0,width:450,zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${I}`,boxShadow:"-10px 0 30px rgba(0,0,0,0.2)",overflow:"hidden"},children:[l.jsxs("div",{style:{padding:"20px 24px",borderBottom:`1px solid ${I}`,background:"var(--bg-secondary)",flexShrink:0},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[l.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:"bold",letterSpacing:"1px",flexShrink:0},children:u?"WORKFLOW":r.type||"TASK"}),y&&l.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,background:`${_r(y)}18`,color:_r(y),letterSpacing:"0.5px",flexShrink:0},children:["● ",y]}),l.jsx("div",{style:{flex:1}}),l.jsx("button",{onClick:q,style:{background:"none",border:"none",color:O,cursor:"pointer",fontSize:20,lineHeight:1,padding:4},children:"✕"})]}),l.jsx("div",{style:{fontSize:20,fontWeight:700,color:"var(--text-primary)",lineHeight:1.3},children:u?"工作流全局数据":r.name}),l.jsxs("div",{style:{fontSize:12,color:O,marginTop:6,fontFamily:"monospace",opacity:.8},children:["REF: ",r.taskReferenceName]})]}),p.length>1&&l.jsxs("div",{style:{padding:"12px 24px",borderBottom:`1px solid ${I}`,background:"var(--bg-secondary)",flexShrink:0},children:[l.jsxs("div",{style:{fontSize:11,fontWeight:600,color:O,marginBottom:8,textTransform:"uppercase",letterSpacing:"0.5px"},children:["执行记录(",p.length," 次",p.some(W=>W.iteration)?" / 迭代":"尝试",")"]}),l.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:p.map((W,V)=>{const Z=h?.taskId===W.taskId;return l.jsx("button",{onClick:()=>s(W),style:{padding:"4px 12px",borderRadius:20,fontSize:12,cursor:"pointer",border:`1px solid ${Z?"var(--color-accent)":I}`,background:Z?"var(--color-accent)":"var(--bg-tertiary)",color:Z?"#fff":"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},children:W.iteration?`迭代 ${W.iteration}`:`尝试 ${V+1}`},W.taskId)})})]}),l.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${I}`,background:"var(--bg-secondary)",flexShrink:0},children:["summary","input","output"].map(W=>{const V={summary:"概览",input:"输入 JSON",output:"输出 JSON"},Z=i===W;return l.jsx("button",{onClick:()=>d(W),style:{padding:"10px 20px",background:"none",border:"none",borderBottom:`2px solid ${Z?"var(--color-accent)":"transparent"}`,color:Z?"var(--color-accent)":O,cursor:"pointer",fontSize:13,fontWeight:Z?600:400,fontFamily:"inherit",transition:"all 0.15s"},children:V[W]},W)})}),l.jsxs("div",{ref:c,style:{flex:1,overflowY:"auto",padding:24,background:"var(--bg-primary)"},children:[i==="summary"&&l.jsxs(l.Fragment,{children:[l.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:24},children:[{label:"总耗时",value:db(x,b)},{label:"开始时间",value:Uh(x)},{label:"结束时间",value:Uh(b)},{label:u?"Workflow ID":"Task ID",value:l.jsx("span",{style:{fontSize:10,fontFamily:"monospace",opacity:.7,wordBreak:"break-all"},children:w??"-"})}].map(({label:W,value:V})=>l.jsxs("div",{style:{padding:"12px 14px",background:F,borderRadius:10,border:`1px solid ${I}`},children:[l.jsx("div",{style:{fontSize:10,color:O,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:6,fontWeight:600},children:W}),l.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:13},children:V})]},W))}),p.length>1&&l.jsxs("div",{style:{marginBottom:20,padding:"10px 14px",background:`${_r(v)}10`,border:`1px solid ${_r(v)}30`,borderRadius:8,fontSize:12,color:_r(v),display:"flex",alignItems:"center",gap:8},children:[l.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("path",{d:"M13 2v4h-4"}),l.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),"已重试 ",p.length-1," 次,共 ",p.length," 次尝试"]}),!u&&h?.workerId&&l.jsxs("div",{style:{marginBottom:20},children:[l.jsx("div",{style:{fontSize:10,color:O,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:4,fontWeight:600},children:"Worker"}),l.jsx("div",{style:{fontSize:12,fontFamily:"monospace",color:"var(--text-primary)",opacity:.8},children:h.workerId})]}),k&&l.jsxs("div",{style:{padding:14,background:"rgba(239,68,68,0.08)",borderLeft:"3px solid var(--status-failed)",borderRadius:"0 8px 8px 0",fontSize:12,color:"var(--status-failed)",lineHeight:1.6},children:[l.jsx("strong",{children:"异常信息"}),l.jsx("div",{style:{marginTop:6,opacity:.9},children:k})]}),C&&l.jsxs("div",{style:{marginTop:24,paddingTop:20,borderTop:`1px solid ${I}`},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,color:O,textTransform:"uppercase",letterSpacing:"0.5px"},children:"任务操作"}),!S&&l.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 7px",borderRadius:4,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",color:"var(--status-failed)",fontSize:10,fontWeight:600},children:[l.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[l.jsx("circle",{cx:"8",cy:"8",r:"6"}),l.jsx("path",{d:"M8 5v3M8 11v.5"})]}),"操作权限受限"]})]}),l.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[T&&l.jsxs("button",{disabled:!S,onClick:()=>S&&e.onRerunFromTask(g,r.taskReferenceName,h?.taskId),title:S?`从任务 ${r.taskReferenceName} 处重新运行工作流`:"操作权限受限",style:S?Qe:Gh,onMouseEnter:W=>!S||Object.assign(W.currentTarget.style,pb),onMouseLeave:W=>!S||Object.assign(W.currentTarget.style,Qe),children:[l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("path",{d:"M3 14v-4h4"}),l.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"从此处重新运行"]}),L&&l.jsxs("button",{disabled:!S,onClick:()=>S&&e.onSkipTask(g,r.taskReferenceName,h?.taskId),title:S?`跳过任务 ${r.taskReferenceName}`:"操作权限受限",style:S?Qe:Gh,onMouseEnter:W=>!S||Object.assign(W.currentTarget.style,hb),onMouseLeave:W=>!S||Object.assign(W.currentTarget.style,Qe),children:[l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:l.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})}),"跳过此任务"]})]})]})]}),i==="input"&&l.jsx(Jh,{data:j}),i==="output"&&l.jsx(Jh,{data:N})]})]})},Jh=({data:e})=>l.jsx("div",{style:{background:"var(--bg-tertiary)",padding:16,borderRadius:10,border:"1px solid var(--glass-border)",fontFamily:"'Fira Code', monospace",fontSize:12,lineHeight:1.6,color:"var(--text-primary)",wordBreak:"break-all",whiteSpace:"pre-wrap"},children:JSON.stringify(e??{},null,2)}),Qe={display:"inline-flex",alignItems:"center",gap:6,padding:"7px 14px",borderRadius:8,fontSize:12,fontWeight:500,cursor:"pointer",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},pb={...Qe,borderColor:"var(--color-accent)",color:"var(--color-accent)",background:"var(--bg-primary)"},hb={...Qe,borderColor:"var(--status-failed)",color:"var(--status-failed)",background:"rgba(239,68,68,0.08)"},Gh={...Qe,opacity:.45,cursor:"not-allowed",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-secondary)"},gb={add:"新增",mod:"修改",del:"删除",replace:"替换"},mb={add:"+",mod:"~",del:"−"};function vb({diff:e,applied:r,onApply:t,onUndo:n}){const s=e.kind==="replace"?"add":e.kind;return l.jsxs("div",{className:"diff-card",children:[l.jsxs("div",{className:"diff-head",children:[l.jsx("span",{className:`diff-badge ${s}`,children:gb[e.kind]??e.kind}),l.jsx("span",{className:"diff-summary",children:e.summary})]}),e.rows&&e.rows.length>0&&l.jsx("div",{className:"diff-list",children:e.rows.map((a,o)=>l.jsxs("div",{className:`diff-row ${a.kind}`,children:[l.jsx("div",{className:"diff-marker",children:mb[a.kind]??"·"}),l.jsx("div",{className:"diff-desc",children:a.desc})]},o))}),l.jsx("div",{className:"diff-actions",children:r?l.jsxs(l.Fragment,{children:[l.jsxs("button",{className:"diff-btn applied",disabled:!0,children:[l.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:l.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"已应用"]}),l.jsxs("button",{className:"diff-btn undo",onClick:n,children:[l.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[l.jsx("path",{d:"M3.5 8a4.5 4.5 0 1 1 1.4 3.3",strokeLinecap:"round"}),l.jsx("path",{d:"M3 4.5L4.5 8L7 6.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"撤销"]})]}):l.jsxs("button",{className:"diff-btn apply",onClick:t,children:[l.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:l.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"应用更改"]})})]})}function Vh(e,r){const t=JSON.parse(JSON.stringify(e));if(r.kind==="replace"&&r.payload)return{next:JSON.parse(JSON.stringify(r.payload)),inverse:{kind:"replace",summary:"撤销替换",rows:[],payload:e}};if(r.kind==="add"&&r.payload)return{next:JSON.parse(JSON.stringify(r.payload)),inverse:{kind:"replace",summary:"撤销生成",rows:[],payload:e}};if(!r.patch)return{next:t,inverse:{kind:r.kind,summary:"(无变更)",rows:[]}};const n=[],s=[];for(const a of r.patch)if(a.op==="patchTask"){const o=t.tasks.find(d=>d.taskReferenceName===a.ref);if(!o)continue;const i={};for(const d of Object.keys(a.set))i[d]=o[d];Object.assign(o,a.set),n.push({op:"patchTask",ref:a.ref,set:i}),s.push({kind:"mod",desc:`还原 ${a.ref} 属性`})}else if(a.op==="addEdge")t.edges=t.edges??[],t.edges.push({from:a.from,to:a.to,label:a.label}),n.push({op:"removeEdge",from:a.from,to:a.to}),s.push({kind:"del",desc:`移除边 ${a.from} → ${a.to}`});else if(a.op==="removeEdge")t.edges=(t.edges??[]).filter(o=>!(o.from===a.from&&o.to===a.to)),n.push({op:"addEdge",from:a.from,to:a.to}),s.push({kind:"add",desc:`恢复边 ${a.from} → ${a.to}`});else if(a.op==="addTask")t.tasks.push(a.task),t.edges=t.edges??[],a.removeEdges&&a.removeEdges.forEach(o=>{t.edges=t.edges.filter(i=>!(i.from===o.from&&i.to===o.to))}),a.extraEdges&&a.extraEdges.forEach(o=>t.edges.push(o)),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}`});else if(a.op==="removeTask"){const o=t.tasks.findIndex(c=>c.taskReferenceName===a.ref);if(o<0)continue;const[i]=t.tasks.splice(o,1),d=(t.edges??[]).filter(c=>c.from===a.ref||c.to===a.ref);t.edges=(t.edges??[]).filter(c=>c.from!==a.ref&&c.to!==a.ref),n.push({op:"addTask",task:i,extraEdges:d}),s.push({kind:"add",desc:`恢复 ${a.ref}`})}else if(a.op==="insertAfter"){t.tasks.push(a.task),t.edges=t.edges??[];const o=t.edges.findIndex(i=>i.from===a.after&&i.to===a.edgeTo);o>=0&&t.edges.splice(o,1),t.edges.push({from:a.after,to:a.task.taskReferenceName}),t.edges.push({from:a.task.taskReferenceName,to:a.edgeTo}),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复直连边)`})}else if(a.op==="insertBefore"){t.tasks.push(a.task),t.edges=t.edges??[];const o=t.edges.filter(i=>i.to===a.before);t.edges=t.edges.filter(i=>i.to!==a.before),o.forEach(i=>t.edges.push({from:i.from,to:a.task.taskReferenceName,label:i.label})),t.edges.push({from:a.task.taskReferenceName,to:a.before}),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复原有入边)`})}return{next:t,inverse:{kind:r.kind,summary:`撤销:${r.summary}`,rows:s,patch:n.reverse()}}}function yb(e){const r=e.match(/```diff-json\n([\s\S]*?)\n```/);if(!r)return null;try{const t=JSON.parse(r[1]);return!t.kind||!t.summary?null:t}catch{return null}}const Yh={id:"1",role:"ai",content:"你好!我是您的流程助手。我可以帮你生成工作流框架、优化逻辑或提供参数配置建议。你想实现什么样的流程?"},Xh=e=>e.split(/(```[\s\S]*?```)/).map((t,n)=>{if(t.startsWith("```")&&t.endsWith("```")){const s=t.slice(3,-3),a=s.indexOf(`
|
|
110
|
-
`),o=a>=0?s.slice(a+1):s;return l.jsx("pre",{children:l.jsx("code",{children:o})},
|
|
111
|
-
`&&r.push(l.jsx("br",{},s.index)),n=s.index+a.length}return n<e.length&&r.push(e.slice(n)),r},bb=({aiConfig:e})=>{const{workflowDef:r,setWorkflow:t,mode:n}=ie(),[s,a]=P.useState(!1),[o,i]=P.useState(""),[d,c]=P.useState(!1),[u,f]=P.useState([Yh]),[p,h]=P.useState(""),[g,m]=P.useState(null),v=P.useRef(null),y=P.useRef(null),x=P.useRef(null),b=P.useCallback(O=>{if(!O.diff||O.applied||!r)return;const{next:F,inverse:W}=Vh(r,O.diff);t(F),f(V=>V.map(Z=>Z.id===O.id?{...Z,applied:!0,inverse:W}:Z))},[r,t]),k=P.useCallback(O=>{if(!O.inverse||!O.applied||!r)return;const{next:F}=Vh(r,O.inverse);t(F),f(W=>W.map(V=>V.id===O.id?{...V,applied:!1,inverse:void 0}:V))},[r,t]),w=()=>{const O=y.current;O&&(O.style.height="auto",O.style.height=Math.min(O.scrollHeight,120)+"px")},j=()=>{const O=y.current;O&&(O.style.height="auto")};P.useEffect(()=>()=>{x.current?.abort()},[]),P.useEffect(()=>{const O=()=>a(!0);return window.addEventListener("open-ai-chat",O),()=>window.removeEventListener("open-ai-chat",O)},[]);const N=()=>{v.current?.scrollIntoView({behavior:"smooth"})};P.useEffect(()=>{s&&N()},[u,s,p]);const L=P.useCallback(O=>{const F=[{role:"system",content:tb}];for(const V of u)V.role==="user"&&V.content?F.push({role:"user",content:V.content}):V.role==="ai"&&V.content&&!V.thinking&&F.push({role:"assistant",content:V.content});const W=nb(O,r);return F.push({role:"user",content:W}),F},[u,r]),T=async O=>{const F=o.trim();if(!F||d)return;x.current?.abort();const W=new AbortController;x.current=W;const V={id:Date.now().toString(),role:"user",content:F};f(Z=>[...Z,V]),i(""),j(),c(!0),h("");try{const Z=e?.apiKey||localStorage.getItem("AI_API_KEY")||"",ne=e?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",ee=e?.model||localStorage.getItem("AI_MODEL")||"";if(!Z){setTimeout(()=>{if(W.signal.aborted)return;const B={name:"demo_approval_workflow",description:"演示审批流程",tasks:[{name:"submit_request",taskReferenceName:"submit_request",type:"SIMPLE",inputParameters:{}},{name:"human_approval",taskReferenceName:"human_approval",type:"HUMAN",inputParameters:{}},{name:"process_result",taskReferenceName:"process_result",type:"SIMPLE",inputParameters:{}}]},z={id:(Date.now()+1).toString(),role:"ai",content:"**演示模式**:未检测到 API Key,以下是一个示例审批流程供体验。请在标题栏 🤖 按钮中配置真实 API Key 以启用 AI 功能。",diff:{kind:"replace",summary:"生成三步审批流程(演示)",rows:[{kind:"add",desc:"submit_request — 提交申请任务"},{kind:"add",desc:"human_approval — 人工审批任务"},{kind:"add",desc:"process_result — 处理审批结果"}],payload:B}};f(Q=>[...Q,z]),c(!1)},800);return}const D={apiKey:Z};ne&&(D.baseUrl=ne),ee&&(D.model=ee);const Y=L(F),se=await Qx(Y,D,B=>{h(z=>z+B)},()=>{},W.signal);let M=yb(se);if(!M){const B=se.match(/```json\n([\s\S]*?)\n```/);if(B)try{const z=JSON.parse(B[1]);M={kind:"replace",summary:"应用 AI 生成的工作流",rows:[{kind:"add",desc:"全量替换为 AI 生成的工作流定义"}],payload:z}}catch{}}const _={id:(Date.now()+1).toString(),role:"ai",content:se,diff:M??void 0,applied:!1};f(B=>[...B,_]),h("")}catch(Z){if(Z.name==="AbortError")h(ne=>{if(ne){const ee={id:(Date.now()+1).toString(),role:"ai",content:ne};f(D=>[...D,ee])}return""});else{const ne={id:Date.now().toString(),role:"ai",content:`抱歉,目前无法连接到 AI 服务: ${Z.message}`};f(ee=>[...ee,ne]),h("")}}finally{c(!1)}},C=()=>{x.current?.abort()},S=()=>{x.current?.abort(),f([Yh]),h(""),c(!1)},q=O=>{navigator.clipboard.writeText(O.content??""),m(O.id),setTimeout(()=>m(null),1500)},I=O=>{O.nativeEvent.isComposing||O.keyCode===229||O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),T())};return n!=="edit"?null:s?l.jsxs("div",{className:"ai-chat-panel",children:[l.jsxs("div",{className:"ai-header",children:[l.jsxs("div",{className:"ai-title",children:[l.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]}),l.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[l.jsx("button",{className:"ai-close",onClick:S,title:"清空对话",children:"🗑"}),l.jsx("button",{className:"ai-close",onClick:()=>a(!1),children:"×"})]})]}),l.jsxs("div",{className:"ai-messages",children:[u.map(O=>l.jsxs("div",{className:`message ${O.role}`,children:[l.jsx("div",{className:"message-content",children:O.thinking?l.jsxs("div",{className:"thinking-skeleton",children:[l.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),l.jsx("div",{className:"skeleton-line",style:{width:"60%"}})]}):O.role==="ai"?Xh(O.content??""):O.content}),O.diff&&!O.thinking&&l.jsx(vb,{diff:O.diff,applied:O.applied??!1,onApply:()=>b(O),onUndo:()=>k(O)}),O.role==="ai"&&O.content&&l.jsx("button",{className:"copy-btn",onClick:()=>q(O),title:"复制",children:g===O.id?"✓":"📋"})]},O.id)),d&&p&&l.jsxs("div",{className:"message ai",style:{opacity:.9},children:[l.jsx("div",{className:"message-content",children:Xh(p)}),l.jsx("span",{className:"streaming-cursor",children:"▊"})]}),d&&!p&&l.jsxs("div",{className:"message ai thinking-skeleton",children:[l.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),l.jsx("div",{className:"skeleton-line",style:{width:"60%"}}),l.jsx("div",{className:"skeleton-line",style:{width:"70%"}})]}),l.jsx("div",{ref:v})]}),l.jsx("div",{className:"ai-input-area",children:l.jsxs("div",{className:"ai-input-container",children:[l.jsx("textarea",{ref:y,className:"ai-input",placeholder:d?"AI 正在响应...":"描述您的需求…(Shift+Enter 换行)",value:o,onChange:O=>i(O.target.value),onInput:w,onKeyDown:I,disabled:d,rows:2}),d?l.jsx("button",{className:"ai-send stop",onClick:C,title:"停止生成",children:"⏹"}):l.jsx("button",{className:"ai-send",onClick:()=>T(),title:"发送",children:"🚀"})]})})]}):l.jsx("div",{className:"ai-chat-panel collapsed",onClick:()=>a(!0),children:l.jsx("div",{className:"ai-header",style:{borderBottom:"none"},children:l.jsxs("div",{className:"ai-title",children:[l.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]})})})},kb=new Set(["COMPLETED","FAILED","TIMED_OUT","TERMINATED"]),_b=({onTriggerExecution:e,onPollExecution:r,executionPollInterval:t=3e3})=>{const{workflowDef:n,showRunPanel:s,setShowRunPanel:a,setRunState:o,importExecutionJSON:i,setMode:d}=ie(),[c,u]=P.useState("form"),[f,p]=P.useState({}),[h,g]=P.useState("{}"),[m,v]=P.useState(""),[y,x]=P.useState(!1),[b,k]=P.useState(""),w=Vr(n?.inputParameters);P.useEffect(()=>{s&&(p({}),g("{}"),v(""),k(""),x(!1))},[s]);const j=P.useCallback(()=>{try{const S={};w.forEach(q=>{const I=f[q.name];if(I!==void 0&&I!=="")if(q.type==="number")S[q.name]=Number(I);else if(q.type==="boolean")S[q.name]=I==="true";else if(q.type==="object"||q.type==="array")try{S[q.name]=JSON.parse(I)}catch{S[q.name]=I}else S[q.name]=I;else q.defaultValue!==void 0&&(S[q.name]=q.defaultValue)}),g(JSON.stringify(S,null,2))}catch{}u("json")},[f,w]),N=P.useCallback(()=>{try{const S=JSON.parse(h),q={};w.forEach(I=>{const O=S[I.name];O!==void 0&&(q[I.name]=typeof O=="object"?JSON.stringify(O,null,2):String(O))}),p(q),v("")}catch{v("JSON 格式有误,无法切换为表单模式")}u("form")},[h,w]),L=P.useCallback(()=>{if(c==="json")try{return JSON.parse(h)}catch{return v("JSON 格式有误,请检查后重试"),null}const S={};return w.forEach(q=>{const I=f[q.name]??(q.defaultValue!==void 0?String(q.defaultValue):"");if(!(I===""&&!q.required))if(q.type==="number")S[q.name]=Number(I);else if(q.type==="boolean")S[q.name]=I==="true";else if(q.type==="object"||q.type==="array")try{S[q.name]=JSON.parse(I)}catch{S[q.name]=I}else S[q.name]=I}),S},[c,h,f,w]),T=P.useCallback(async()=>{if(!e||!n)return;const S=L();if(S===null)return;const q=w.filter(I=>I.required&&(S[I.name]===void 0||S[I.name]===""));if(q.length>0){k(`必填参数未填写:${q.map(I=>I.name).join(", ")}`);return}x(!0),k(""),o("triggering");try{const{workflowId:I}=await e(n.name,n.version??1,S);if(o("polling",I),a(!1),d("run"),!r)return;let O=t;const F=15e3;let W;const V=async()=>{try{const Z=await r(I);if(Z&&(i(Z),kb.has(Z.status))){o("done",I);return}}catch{}O=Math.min(O*1.5,F),W=setTimeout(V,O)};W=setTimeout(V,O),ie.getState().__pollTimer=W}catch(I){const O=I?.message||"执行触发失败,请检查配置后重试";o("error",null,O),k(O),x(!1)}},[e,r,n,L,w,o,a,i,d,t]);if(!s||!n)return null;const C=w.length>0;return l.jsx("div",{className:"wrp-overlay",onClick:()=>a(!1),children:l.jsxs("div",{className:"wrp-panel",onClick:S=>S.stopPropagation(),children:[l.jsxs("div",{className:"wrp-header",children:[l.jsxs("div",{className:"wrp-header-title",children:[l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",style:{color:"var(--status-completed)"},children:l.jsx("path",{d:"M4 3l9 5-9 5z"})}),"执行验证"]}),l.jsxs("div",{className:"wrp-workflow-name",children:[n.name," ",l.jsxs("span",{className:"wrp-version",children:["v",n.version??1]})]}),l.jsx("button",{className:"wrp-close",onClick:()=>a(!1),children:"✕"})]}),l.jsxs("div",{className:"wrp-content",children:[l.jsxs("div",{className:"wrp-section-label",children:["工作流输入参数",C&&l.jsxs("div",{className:"wrp-mode-toggle",children:[l.jsx("button",{className:c==="form"?"active":"",onClick:c==="json"?N:void 0,children:"表单模式"}),l.jsx("button",{className:c==="json"?"active":"",onClick:c==="form"?j:void 0,children:"JSON 编辑器"})]})]}),!C&&c==="form"&&l.jsxs("p",{className:"wrp-hint",children:["该工作流未声明输入参数。你可以在 ",l.jsx("strong",{children:"工作流设置 → 参数配置"})," 中添加,也可以直接在 JSON 编辑器中手动填写。"]}),c==="form"?l.jsxs("div",{className:"wrp-form",children:[w.map(S=>l.jsxs("div",{className:"wrp-field",children:[l.jsxs("label",{className:"wrp-field-label",children:[S.name,S.required&&l.jsx("span",{className:"wrp-required",children:"*"}),S.type&&l.jsx("span",{className:"wrp-type",children:S.type})]}),S.description&&l.jsx("p",{className:"wrp-field-desc",children:S.description}),S.type==="object"||S.type==="array"?l.jsx("textarea",{className:"wrp-input",rows:3,placeholder:S.example?JSON.stringify(S.example,null,2):"{}",value:f[S.name]??"",onChange:q=>p(I=>({...I,[S.name]:q.target.value}))}):S.type==="boolean"?l.jsxs("select",{className:"wrp-input",value:f[S.name]??(S.defaultValue!==void 0?String(S.defaultValue):""),onChange:q=>p(I=>({...I,[S.name]:q.target.value})),children:[l.jsx("option",{value:"",children:"请选择"}),l.jsx("option",{value:"true",children:"true"}),l.jsx("option",{value:"false",children:"false"})]}):l.jsx("input",{className:"wrp-input",type:S.type==="number"?"number":"text",placeholder:S.example!==void 0?String(S.example):S.defaultValue!==void 0?String(S.defaultValue):"",value:f[S.name]??"",onChange:q=>p(I=>({...I,[S.name]:q.target.value}))})]},S.name)),!C&&l.jsx("button",{className:"wrp-switch-json",onClick:j,children:"切换为 JSON 编辑器手动填写"})]}):l.jsxs("div",{className:"wrp-json-editor",children:[l.jsx("textarea",{className:"wrp-input wrp-json",rows:12,value:h,onChange:S=>{g(S.target.value),v("")},spellCheck:!1,placeholder:'{\\n "key": "value"\\n}'}),m&&l.jsx("p",{className:"wrp-error",children:m})]}),b&&l.jsx("p",{className:"wrp-error wrp-submit-error",children:b})]}),l.jsxs("div",{className:"wrp-footer",children:[l.jsx("button",{className:"wrp-btn wrp-btn-cancel",onClick:()=>a(!1),children:"取消"}),e?l.jsx("button",{className:"wrp-btn wrp-btn-execute",onClick:T,disabled:y,children:y?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"wrp-spinner"}),"执行中..."]}):l.jsxs(l.Fragment,{children:[l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("path",{d:"M4 3l9 5-9 5z"})}),"发起执行"]})}):l.jsx("span",{className:"wrp-hint-inline",children:"未配置 onTriggerExecution 回调"})]})]})})},Sb=[{pattern:/NullPointerException|null.*inputData|inputData.*null/i,category:"parameter",title:"参数引用为空",explanation:"某个 inputParameters 字段引用的上游任务输出为 null。请检查 JSONPath 表达式,确认前序任务确实返回了对应字段。",suggestEditParam:"inputParameters"},{pattern:/PathNotFoundException|No results for path|path not found/i,category:"parameter",title:"JSONPath 路径不存在",explanation:"参数中的 JSONPath 表达式(如 ${task.output.field})在实际执行数据中找不到对应路径。请核查前序任务的实际输出结构。",suggestEditParam:"inputParameters"},{pattern:/ClassCastException|cannot cast|type mismatch/i,category:"parameter",title:"参数类型不匹配",explanation:"输入参数的数据类型与任务期望不符(如将字符串传给了数字类型参数)。请检查参数值的类型。",suggestEditParam:"inputParameters"},{pattern:/Connection refused|connect.*timeout|SocketException/i,category:"network",title:"网络连接失败",explanation:"无法连接到目标服务器。请检查 HTTP 任务的 uri 是否正确,以及目标服务是否可访问。",suggestEditParam:"uri"},{pattern:/HTTP.*4\d\d|status.*4\d\d|4\d\d.*status/i,category:"network",title:"HTTP 客户端错误",explanation:"HTTP 请求返回 4xx 错误,通常由请求参数、认证或权限问题引起。请检查 uri、headers、body 配置。",suggestEditParam:"inputParameters"},{pattern:/HTTP.*5\d\d|status.*5\d\d|5\d\d.*status/i,category:"network",title:"HTTP 服务端错误",explanation:"目标服务返回 5xx 错误,服务端发生异常。可尝试重试,或检查传入的请求体是否符合服务端期望。",suggestEditParam:"inputParameters"},{pattern:/Unauthorized|401|authentication|auth.*failed/i,category:"auth",title:"认证失败",explanation:"请求被拒绝,认证信息无效或缺失。请检查 headers 中的 Authorization 或 token 参数配置。",suggestEditParam:"inputParameters"},{pattern:/timeout|timed.?out|TIMED_OUT/i,category:"timeout",title:"任务超时",explanation:"任务执行时间超过配置的超时阈值。可考虑增大 timeoutSeconds,或优化被调用服务的响应速度。",suggestEditParam:"timeoutSeconds"},{pattern:/loopCondition|loop.*condition|condition.*false/i,category:"logic",title:"循环条件配置问题",explanation:"DO_WHILE 的 loopCondition 表达式可能无法正常求值。请检查条件表达式引用的变量是否正确。",suggestEditParam:"loopCondition"},{pattern:/expression.*error|script.*error|evaluator.*failed/i,category:"logic",title:"脚本表达式错误",explanation:"INLINE/LAMBDA 任务的脚本表达式执行时出错。请检查 expression 或 scriptExpression 的语法和逻辑。",suggestEditParam:"inputParameters"}];function wb(e,r){const t=r[e];if(!t)return[];const n=t.reasonForIncompletion||"";if(!n)return[];const s=[];for(const a of Sb)a.pattern.test(n)&&s.push({category:a.category,title:a.title,explanation:a.explanation,suggestEditParam:a.suggestEditParam});return s.length===0&&n.length>0&&s.push({category:"logic",title:"执行异常",explanation:`任务执行失败,原因:${n.slice(0,200)}${n.length>200?"...":""}`}),s}function Tb(e,r){const t=Object.values(e).map(h=>{const g=h.startTime&&h.endTime?h.endTime-h.startTime:void 0,m=Math.max(0,(h.attempts?.length??1)-1);return{taskRef:h.taskReferenceName,status:h.status,startTime:h.startTime,endTime:h.endTime,durationMs:g,retryCount:m,reasonForIncompletion:h.reasonForIncompletion,diagnostics:wb(h.taskReferenceName,e)}}).sort((h,g)=>(h.startTime??0)-(g.startTime??0)),n=["FAILED","FAILED_WITH_TERMINAL_ERROR","TIMED_OUT"],s=t.filter(h=>h.status==="COMPLETED"||h.status==="COMPLETED_WITH_ERRORS").length,a=t.filter(h=>n.includes(h.status)).length,o=t.filter(h=>h.status==="SKIPPED").length,i=t.flatMap(h=>[h.startTime,h.endTime]).filter(h=>!!h),d=i.length?Math.min(...i):0,u=(i.length?Math.max(...i):0)-d,f=r?.status,p=f==="FAILED"||f==="TIMED_OUT"||f==="TERMINATED"||a>0;return{totalTasks:t.length,completedTasks:s,failedTasks:a,skippedTasks:o,totalDurationMs:u,steps:t,hasFailed:p}}function Zh(e){return e===void 0||e<0?"-":e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`}function Eb(e){return{parameter:"⚙️",timeout:"⏱️",auth:"🔐",network:"🌐",logic:"🔧"}[e]??"⚠️"}function Nb(e){return{parameter:"#f59e0b",timeout:"#8b5cf6",auth:"#ef4444",network:"#3b82f6",logic:"#10b981"}[e]??"#6b7280"}const Qh={COMPLETED:"完成",COMPLETED_WITH_ERRORS:"完成(含错误)",FAILED:"失败",FAILED_WITH_TERMINAL_ERROR:"终态失败",IN_PROGRESS:"执行中",SCHEDULED:"等待中",TIMED_OUT:"超时",SKIPPED:"跳过",CANCELED:"已取消"},eg={COMPLETED:"var(--status-completed)",COMPLETED_WITH_ERRORS:"var(--status-completed)",FAILED:"var(--status-failed)",FAILED_WITH_TERMINAL_ERROR:"var(--status-failed)",IN_PROGRESS:"var(--status-running)",SCHEDULED:"var(--status-scheduled)",TIMED_OUT:"var(--status-failed)",SKIPPED:"var(--status-skipped, #6b7280)",CANCELED:"var(--status-failed)"},Cb=()=>{const{executionData:e,workflowInstance:r,showAnalysisPanel:t,setShowAnalysisPanel:n,switchToEditAndFocusParam:s,selectTaskAction:a,taskMap:o}=ie(),i=P.useMemo(()=>e?Tb(e,r??null):null,[e,r]);if(!t||!i)return null;const{totalTasks:d,completedTasks:c,failedTasks:u,skippedTasks:f,totalDurationMs:p,steps:h}=i,g=d>0?Math.round(c/d*100):0,m=r?.status,v=m?eg[m]??"var(--text-secondary)":"var(--text-secondary)";return l.jsxs("div",{className:"esp-panel glass-panel",children:[l.jsxs("div",{className:"esp-header",children:[l.jsxs("div",{className:"esp-title",children:[l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),l.jsx("path",{d:"M5 8h6M5 5h3M5 11h4"})]}),"执行分析"]}),m&&l.jsx("span",{className:"esp-wf-status",style:{color:v},children:Qh[m]??m}),l.jsx("button",{className:"esp-close",onClick:()=>n(!1),children:"✕"})]}),l.jsxs("div",{className:"esp-content",children:[l.jsxs("div",{className:"esp-overview",children:[l.jsxs("div",{className:"esp-card",children:[l.jsx("span",{className:"esp-card-value",children:d}),l.jsx("span",{className:"esp-card-label",children:"总任务数"})]}),l.jsxs("div",{className:"esp-card esp-card-success",children:[l.jsx("span",{className:"esp-card-value",style:{color:"var(--status-completed)"},children:c}),l.jsx("span",{className:"esp-card-label",children:"已完成"})]}),l.jsxs("div",{className:"esp-card esp-card-failed",children:[l.jsx("span",{className:"esp-card-value",style:{color:u>0?"var(--status-failed)":"var(--text-secondary)"},children:u}),l.jsx("span",{className:"esp-card-label",children:"失败"})]}),l.jsxs("div",{className:"esp-card",children:[l.jsx("span",{className:"esp-card-value",children:Zh(p)}),l.jsx("span",{className:"esp-card-label",children:"总耗时"})]})]}),l.jsx("div",{className:"esp-progress-bar",children:l.jsx("div",{className:"esp-progress-fill",style:{width:`${g}%`,background:u>0?"var(--status-failed)":"var(--status-completed)"},title:`成功率 ${g}%`})}),l.jsxs("div",{className:"esp-progress-label",children:[g,"% 成功率",f>0?`,${f} 个任务已跳过`:""]}),h.filter(y=>y.diagnostics.length>0).map(y=>l.jsxs("div",{className:"esp-diagnostic-card",children:[l.jsxs("div",{className:"esp-diag-task-ref",children:[l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",style:{color:"var(--status-failed)",flexShrink:0},children:l.jsx("path",{d:"M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 4a.75.75 0 011.5 0v3.5a.75.75 0 01-1.5 0V5zm.75 7a1 1 0 110-2 1 1 0 010 2z"})}),y.taskRef]}),y.diagnostics.map((x,b)=>l.jsxs("div",{className:"esp-diag-item",style:{borderLeftColor:Nb(x.category)},children:[l.jsxs("div",{className:"esp-diag-title",children:[l.jsx("span",{children:Eb(x.category)}),x.title]}),l.jsx("p",{className:"esp-diag-explanation",children:x.explanation}),l.jsxs("button",{className:"esp-fix-btn",onClick:()=>s(y.taskRef,x.suggestEditParam),children:["去修复",l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:l.jsx("path",{d:"M5 8h6M9 5l3 3-3 3"})})]})]},b))]},y.taskRef)),l.jsx("div",{className:"esp-section-label",children:"步骤执行时序"}),l.jsxs("div",{className:"esp-steps-table",children:[l.jsxs("div",{className:"esp-steps-header",children:[l.jsx("span",{children:"#"}),l.jsx("span",{children:"任务引用名"}),l.jsx("span",{children:"状态"}),l.jsx("span",{children:"耗时"}),l.jsx("span",{children:"重试"})]}),h.map((y,x)=>{const b=eg[y.status]??"var(--text-secondary)",k=o[y.taskRef];return l.jsxs("button",{className:"esp-step-row",onClick:()=>k&&a(k,!0),title:y.reasonForIncompletion||y.taskRef,children:[l.jsx("span",{className:"esp-step-idx",children:x+1}),l.jsx("span",{className:"esp-step-ref",children:y.taskRef}),l.jsxs("span",{className:"esp-step-status",style:{color:b},children:[l.jsx("span",{className:"esp-status-dot",style:{background:b}}),Qh[y.status]??y.status]}),l.jsx("span",{className:"esp-step-duration",children:Zh(y.durationMs)}),l.jsx("span",{className:"esp-step-retry",style:{color:y.retryCount>0?"var(--status-failed)":"var(--text-secondary)"},children:y.retryCount>0?`${y.retryCount}次`:"-"})]},y.taskRef)})]})]})]})},rg=P.forwardRef(({workflowDef:e,readOnly:r=!1,theme:t="dark",themeColor:n="blue",layoutDirection:s="LR",searchQuery:a="",workflowExecution:o,onRequestImport:i,executionActions:d,aiConfig:c,viewMode:u="developer",onSave:f,onWorkflowChange:p,height:h="100%",onTriggerExecution:g,onPollExecution:m,executionPollInterval:v=3e3},y)=>{const{setWorkflow:x,setTheme:b,setThemeColor:k,setLayoutDirection:w,setNodesLocked:j,selectedTask:N,setSelectedTask:L,edgeType:T,importExecutionJSON:C,setMode:S,setViewMode:q,isDetailPanelOpen:I,setIsDetailPanelOpen:O,selectTaskAction:F,workflowDef:W,isSimRunning:V,startSimulation:Z,stopSimulation:ne,mode:ee,setShowRunPanel:D,showAnalysisPanel:Y,setShowAnalysisPanel:se,executionData:R}=ie(),[M,_]=P.useState(!1),B=P.useCallback(()=>{if(!W)return;const G=new Blob([JSON.stringify(W,null,2)],{type:"application/json"}),oe=URL.createObjectURL(G),H=document.createElement("a");H.href=oe,H.download=`${W.name||"workflow"}.json`,H.click(),URL.revokeObjectURL(oe)},[W]),z=P.useCallback(()=>{W&&navigator.clipboard.writeText(JSON.stringify(W,null,2))},[W]);P.useEffect(()=>{b(t),k(n),w(s),j(r||!!o)},[t,n,s,r,o,b,k,w,j]),P.useEffect(()=>{q(o?"developer":u)},[u,o,q]),P.useEffect(()=>{e&&(x(e,s),ie.temporal.getState().clear())},[e,x,s]),P.useEffect(()=>{o?C(o):S(r?"view":"edit")},[o,C,S,r]),P.useImperativeHandle(y,()=>({getWorkflowDef:()=>ie.getState().workflowDef,getValidationResults:()=>ie.getState().validationResults,save:()=>{const G=ie.getState().workflowDef;G&&f&&f(G)},createBlankWorkflow:G=>{ie.getState().createBlankWorkflow(G),ie.temporal.getState().clear()}}),[f]),P.useEffect(()=>{if(!p)return;let G=!0,oe=ie.getState().workflowDef;return ie.subscribe($=>{const K=$.workflowDef;if(K!==oe){if(oe=K,G){G=!1;return}K&&p(K)}})},[p]);const Q=G=>{o?L(G):F(G,!0)};return l.jsxs("div",{className:`workflow-ide ${t==="light"?"light-theme":""}`,"data-mode":t,"data-brand":n,style:{width:"100%",height:h,display:"flex",flexDirection:"column",position:"relative",overflow:"hidden"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderBottom:"1px solid var(--border)",background:"var(--bg-primary)",flexShrink:0,flexWrap:"wrap"},children:[l.jsx("div",{style:{flex:1}}),ee==="edit"&&W&&l.jsxs("button",{onClick:()=>D(!0),style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--color-accent) 15%, transparent)",color:"var(--color-accent)",border:"1px solid color-mix(in srgb, var(--color-accent) 40%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:600,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"填写工作流入参并触发真实执行",children:[l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("path",{d:"M4 3l9 5-9 5z"})}),"执行验证"]}),ee==="run"&&R&&l.jsxs("button",{onClick:()=>se(!Y),style:{height:28,padding:"0 10px",background:Y?"color-mix(in srgb, var(--color-accent) 20%, transparent)":"transparent",color:Y?"var(--color-accent)":"var(--text-secondary)",border:`1px solid ${Y?"color-mix(in srgb, var(--color-accent) 40%, transparent)":"var(--border-strong)"}`,borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"查看执行概览与异常分析",children:[l.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),l.jsx("path",{d:"M5 8h6M5 5h3M5 11h4"})]}),"分析"]}),ee!=="run"&&W&&(V?l.jsxs("button",{onClick:ne,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-failed) 15%, transparent)",color:"var(--status-failed)",border:"1px solid color-mix(in srgb, var(--status-failed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"停止模拟",children:[l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1"})}),"停止"]}):l.jsxs("button",{onClick:Z,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-completed) 15%, transparent)",color:"var(--status-completed)",border:"1px solid color-mix(in srgb, var(--status-completed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"模拟执行工作流",children:[l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("path",{d:"M4 3l9 5-9 5z"})}),"模拟运行"]})),W&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{onClick:B,style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-strong)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"导出工作流 JSON 文件",children:[l.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:l.jsx("path",{d:"M3 10v2.5a.5.5 0 0 0 .5.5h9a.5.5 0 0 0 .5-.5V10M5 7l3 3 3-3M8 2v8",strokeLinecap:"round",strokeLinejoin:"round"})}),"导出 JSON"]}),l.jsxs("button",{onClick:z,style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-strong)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"复制 Conductor DSL 到剪贴板",children:[l.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[l.jsx("rect",{x:"4",y:"4",width:"9",height:"10",rx:"1"}),l.jsx("path",{d:"M2 10V3a1 1 0 0 1 1-1h7",strokeLinecap:"round"})]}),"复制 DSL"]})]})]}),l.jsx("div",{className:"workflow-viewer",style:{flex:1,position:"relative",overflow:"hidden"},children:l.jsx(A.ReactFlowProvider,{children:l.jsx(Zx,{onNodeClick:Q,edgeType:T,theme:t,nodesLocked:r||!!o,searchQuery:a,onSave:f,onRequestImport:i,executionActions:d})})}),l.jsx(cb,{task:N,isOpen:I,onClose:()=>O(!1),theme:t,aiConfig:c}),l.jsx(Lh,{isOpen:M,onClose:()=>_(!1),theme:t,onTaskSelect:G=>{F(G,!0)}}),o&&l.jsx(fb,{executionActions:d}),l.jsx(bb,{aiConfig:c}),l.jsx(_b,{onTriggerExecution:g,onPollExecution:m,executionPollInterval:v}),ee==="run"&&l.jsx(Cb,{})]})});rg.displayName="WorkflowIDE",qe.WorkflowIDE=rg,qe.parseWorkflowInputParams=Vr,Object.defineProperty(qe,Symbol.toStringTag,{value:"Module"})}));
|
|
119
|
+
`,yb=({isOpen:e,onClose:n,onSelect:r,suggestions:t,anchorRect:s})=>{if(!e||!s)return null;const a={position:"fixed",top:s.bottom+8,left:Math.max(s.left-200,20),width:"280px",zIndex:3e3};return l.jsxs(l.Fragment,{children:[l.jsx("div",{className:"suggester-overlay",onClick:n}),l.jsxs("div",{className:"parameter-suggester-popover glass-panel",style:a,children:[l.jsxs("div",{className:"suggester-header",children:[l.jsx("span",{className:"sparkle-icon",children:"✨"}),"AI Suggestions"]}),l.jsx("div",{className:"suggester-list",children:t.length===0?l.jsxs("div",{className:"suggester-loading",children:[l.jsx("div",{className:"suggester-skeleton-line",style:{width:"85%"}}),l.jsx("div",{className:"suggester-skeleton-line",style:{width:"65%"}}),l.jsx("div",{className:"suggester-skeleton-line",style:{width:"75%"}})]}):t.map((o,i)=>l.jsxs("div",{className:"suggestion-item",onClick:()=>{r(o.value),n()},children:[l.jsx("div",{className:"suggestion-label",children:o.label}),l.jsx("div",{className:"suggestion-value",children:o.value}),l.jsx("div",{className:"suggestion-desc",children:o.description})]},i))})]})]})},xb=({title:e,value:n,language:r="text",placeholder:t="",onSave:s,onClose:a})=>{const{theme:o,themeColor:i}=oe(),[u,c]=O.useState(n),d=O.useRef(null);O.useEffect(()=>{d.current?.focus();const h=g=>{g.key==="Escape"&&(g.stopPropagation(),a()),(g.ctrlKey||g.metaKey)&&g.key==="s"&&(g.preventDefault(),g.stopPropagation(),s(u))};return window.addEventListener("keydown",h,!0),()=>window.removeEventListener("keydown",h,!0)},[u,s,a]);const p={javascript:"#f7df1e",js:"#f7df1e",json:"#89b4fa",jq:"#a6e3a1",groovy:"#4ec994",python:"#3572A5",text:"var(--text-secondary)"}[r.toLowerCase()]??"var(--text-secondary)";return Qr.createPortal(l.jsxs("div",{"data-mode":o,"data-brand":i,style:{position:"fixed",inset:0,zIndex:3e3,display:"flex",flexDirection:"column",background:"var(--bg-primary)"},onClick:h=>h.stopPropagation(),children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 20px",background:"var(--bg-secondary)",borderBottom:"1px solid var(--glass-border)",flexShrink:0},children:[l.jsx("span",{style:{fontSize:"11px",fontWeight:700,color:p,background:`${p}18`,border:`1px solid ${p}44`,padding:"2px 8px",borderRadius:"4px",fontFamily:"monospace",letterSpacing:"0.5px",textTransform:"uppercase",flexShrink:0},children:r}),l.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),l.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)",flexShrink:0},children:"Ctrl+S 保存 · Esc 取消"}),l.jsx("button",{onClick:a,style:{padding:"6px 14px",background:"var(--bg-tertiary)",border:"1px solid var(--glass-border)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"12px",fontWeight:500,flexShrink:0},children:"取消"}),l.jsx("button",{onClick:()=>s(u),style:{padding:"6px 16px",background:"var(--color-accent)",border:"none",borderRadius:"6px",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:600,flexShrink:0},children:"应用"})]}),l.jsx("textarea",{ref:d,value:u,placeholder:t,onChange:h=>c(h.target.value),onKeyDown:h=>h.stopPropagation(),spellCheck:!1,style:{flex:1,width:"100%",padding:"20px 24px",background:"var(--bg-primary)",color:r==="javascript"||r==="js"||r==="groovy"?"var(--color-accent)":"var(--text-primary)",border:"none",outline:"none",resize:"none",fontFamily:'var(--font-mono, "Fira Code", "Cascadia Code", Consolas, monospace)',fontSize:"14px",lineHeight:"1.7",boxSizing:"border-box",caretColor:"var(--color-accent)"}}),l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px",padding:"5px 20px",background:"var(--bg-secondary)",borderTop:"1px solid var(--glass-border)",flexShrink:0,fontSize:"11px",color:"var(--text-secondary)"},children:[l.jsxs("span",{children:[u.split(`
|
|
120
|
+
`).length," 行"]}),l.jsxs("span",{children:[u.length," 字符"]}),u!==n&&l.jsx("span",{style:{color:"#f59e0b",fontWeight:600},children:"● 未保存"})]})]}),document.body)},bb=[{label:"工作流输入",value:"${workflow.input.fieldName}",desc:"引用工作流启动时传入的参数"},{label:"上游任务输出",value:"${taskRef.output.result}",desc:"引用上游任务的输出字段"},{label:"工作流变量",value:"${workflow.variables.varName}",desc:"引用 SET_VARIABLE 设置的变量"},{label:"工作流 ID",value:"${workflow.workflowId}",desc:"当前工作流实例 ID"},{label:"关联 ID",value:"${workflow.correlationId}",desc:"工作流关联 ID"},{label:"工作流状态",value:"${workflow.status}",desc:"当前工作流状态"}],kb=({task:e,isOpen:n=!0,onClose:r,aiConfig:t})=>{const{mode:s,updateTask:a,checkTaskRefUniqueness:o}=oe(),[i,u]=O.useState(e),[c,d]=O.useState(e?.taskReferenceName??null),[f,p]=O.useState(null),[h,g]=O.useState(!1),[m,v]=O.useState(null),[y,x]=O.useState(()=>e?.type==="WAIT"&&e.inputParameters?.until?"until":"duration"),[b,k]=O.useState(()=>e?.type==="DO_WHILE"&&e.inputParameters?.items?"items":"condition"),[w,j]=O.useState(()=>!e||e.type!=="FORK_JOIN_DYNAMIC"?"classic":e.forkTaskWorkflow?"workflow":e.forkTaskType?"task":"classic"),[N,L]=O.useState(!1),[T,C]=O.useState(),[S,D]=O.useState([]),[I,P]=O.useState(()=>()=>{}),[F,W]=O.useState(null),[K,V]=O.useState(!1),[te,re]=O.useState(null),q=(E,J,se,ue)=>{W({title:E,value:J,language:se,onSave:ue})},G=[{label:"引用工作流输入",value:"${workflow.input.data}",description:"引用工作流启动时传入的原始数据"},{label:"引用前序任务输出",value:"${previous_task.output.result}",description:"引用上一个节点的计算结果"},{label:"环境变量",value:"${workflow.variables.api_key}",description:"引用工作流定义的全局变量"}],ie=async()=>{const E=t?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!E){alert("请先在设置中配置 AI API Key");return}if(M){V(!0);try{const{workflowDef:J,taskMap:se}=oe.getState(),ue=Zr(J?.inputParameters).map(fe=>fe.name),de=Object.values(se).filter(fe=>fe.taskReferenceName!==M.taskReferenceName).map(fe=>({ref:fe.taskReferenceName,type:fe.type,name:fe.name})).slice(0,10),ve={apiKey:E};t?.baseUrl&&(ve.baseUrl=t.baseUrl),t?.model&&(ve.model=t.model);const xe=await hb(M.type,M.taskReferenceName,ue,de,M.inputParameters??{},ve);re({generated:xe,original:M.inputParameters??{}})}catch(J){alert(`AI 生成失败:${J?.message||"未知错误"}`)}finally{V(!1)}}},R=async(E,J)=>{const se=E.currentTarget.getBoundingClientRect();C(se),P(()=>J),D([]),L(!0);const ue=t?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!ue){D(G);return}try{const de=t?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",ve=t?.model||localStorage.getItem("AI_MODEL")||"",xe={apiKey:ue};de&&(xe.baseUrl=de),ve&&(xe.model=ve);const{workflowDef:fe}=oe.getState(),_e=vb(M,fe),ye=(await Zh([{role:"system",content:"You are a Conductor workflow expert. Return only valid JSON."},{role:"user",content:_e}],xe)).match(/\[[\s\S]*\]/);if(ye){const dr=JSON.parse(ye[0]);D(dr)}else D(G)}catch{D(G)}};if(O.useEffect(()=>{e&&(u(e),d(e.taskReferenceName),p(null),e.type==="WAIT"&&x(e.inputParameters?.until?"until":"duration"),e.type==="DO_WHILE"&&k(e.inputParameters?.items?"items":"condition"),e.type==="FORK_JOIN_DYNAMIC"&&(e.forkTaskWorkflow?j("workflow"):e.forkTaskType?j("task"):j("classic")))},[e]),!e&&!i)return null;const M=e||i,_=i&&e&&c===e.taskReferenceName?i:M,B=n&&e?"panel-enter-active":"panel-exit",$=s==="edit",X="var(--text-primary)",U="var(--glass-border)",le="var(--bg-tertiary)",Q="var(--text-secondary)",ee=(E,J)=>{const se={..._,[E]:J};u(se),a(_.taskReferenceName,{[E]:J})},he=(E,J,se)=>{const de={..._[E]||{},[J]:se},ve={..._,[E]:de};u(ve),a(_.taskReferenceName,{[E]:de})},z=(E,J)=>{const se=_.inputParameters||{},de={...se.http_request||_.httpRequest||{},[E]:J},xe={inputParameters:{...se,http_request:de}};_.httpRequest&&(xe.httpRequest=de);const fe={..._,...xe};u(fe),a(_.taskReferenceName,xe)},Z=(E,J)=>{const ue={inputParameters:{..._.inputParameters,[E]:J}},de={..._,...ue};u(de),a(_.taskReferenceName,ue)},H=E=>{if(!m)return;const J=m.selectionStart??0,se=m.selectionEnd??0,ue=m.value,de=ue.substring(0,J)+E+ue.substring(se),ve=m.getAttribute("data-field");ve&&ee(ve,de),g(!1)},ne=(E,J,se,ue)=>l.jsxs("div",{style:{marginBottom:"24px",padding:"16px",borderRadius:"12px",background:`${se}10`,border:`1px solid ${se}30`,boxShadow:"0 4px 12px rgba(0,0,0,0.05)"},children:[l.jsxs("div",{style:{fontSize:"12px",fontWeight:"bold",marginBottom:"16px",color:se,display:"flex",alignItems:"center",gap:"8px"},children:[l.jsx("span",{children:J})," ",E]}),ue]}),Y=(E,J,se="text",ue)=>{const de=J==="taskReferenceName",ve=de&&f!==null?f:_[J]??"",xe=de&&!o(ve,_.taskReferenceName);return l.jsxs("div",{style:{marginBottom:"16px"},children:[l.jsxs("label",{style:{display:"block",fontSize:"11px",color:Q,marginBottom:"6px",fontWeight:"600",textTransform:"uppercase"},children:[E,de&&xe&&l.jsx("span",{style:{color:"#ef4444",marginLeft:"8px",textTransform:"none"},children:"⚠️ 已存在相同引用名"})]}),l.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[l.jsx("input",{type:se,value:ve,placeholder:ue,onChange:fe=>{de?p(fe.target.value):ee(J,se==="number"?fe.target.value===""?void 0:Number(fe.target.value):fe.target.value)},onFocus:de?()=>{f===null&&p(_.taskReferenceName??"")}:void 0,onBlur:de?fe=>{const _e=fe.target.value.trim();p(null),_e&&_e!==_.taskReferenceName&&ee("taskReferenceName",_e)}:void 0,onKeyDown:de?fe=>{fe.key==="Enter"&&fe.currentTarget.blur(),fe.stopPropagation()}:void 0,disabled:!$,style:{width:"100%",padding:`8px ${$&&!de?"32px":"12px"} 8px 12px`,borderRadius:"6px",border:`1px solid ${xe?"#ef4444":U}`,background:le,color:X,fontSize:"13px",outline:"none",opacity:$?1:.8,fontFamily:de?"monospace":"inherit"}}),$&&!de&&l.jsx("button",{className:"ai-hint-trigger",onClick:fe=>R(fe,_e=>ee(J,_e)),title:"AI 智能提示",style:{position:"absolute",right:"8px",background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"4px",opacity:.6,display:"flex",alignItems:"center",justifyContent:"center"},children:"✨"})]})]})},ge=(E,J,se,ue={})=>{const{rows:de=5,language:ve="text",style:xe,placeholder:fe,"data-field":_e}=ue,wr={width:"100%",padding:"12px",borderRadius:"8px",border:`1px solid ${U}`,background:le,color:X,fontSize:"12px",fontFamily:"monospace",lineHeight:"1.5",resize:"vertical",...xe};return l.jsxs("div",{style:{marginBottom:"8px"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"},children:[l.jsx("label",{style:{fontSize:"10px",color:Q},children:E}),$&&l.jsx("button",{onClick:()=>q(E,J,ve,ye=>{se(ye),W(null)}),title:"全屏编辑",style:{background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"2px 4px",color:"var(--text-secondary)",opacity:.7,lineHeight:1},children:"⛶"})]}),l.jsx("textarea",{value:J,placeholder:fe,onChange:ye=>se(ye.target.value),disabled:!$,rows:de,"data-field":_e,onFocus:ye=>v(ye.currentTarget),style:wr})]})},ae=(E,J,se,ue="text",de)=>l.jsxs("div",{style:{marginBottom:"12px"},children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:E}),l.jsx("input",{type:ue,value:J??"",placeholder:de,onChange:ve=>se(ue==="number"?ve.target.value===""?void 0:Number(ve.target.value):ve.target.value),disabled:!$,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${U}`,background:le,color:X,fontSize:"12px",outline:"none"}})]}),pe=(E,J,se,ue)=>l.jsxs("div",{style:{marginBottom:"12px"},children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:E}),l.jsx("select",{value:se,onChange:de=>ue(de.target.value),disabled:!$,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${U}`,background:le,color:X,fontSize:"12px",outline:"none",cursor:"pointer"},children:J.map(de=>l.jsx("option",{value:de,children:de},de))})]}),me=(E,J,se)=>l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[l.jsx("span",{style:{fontSize:"11px",color:Q},children:E}),l.jsx("button",{onClick:()=>se(!J),disabled:!$,style:{width:"36px",height:"20px",borderRadius:"10px",border:"none",cursor:"pointer",background:J?"var(--color-accent)":U,position:"relative",transition:"background 0.2s"},children:l.jsx("span",{style:{position:"absolute",top:"2px",left:J?"18px":"2px",width:"16px",height:"16px",borderRadius:"50%",background:"#fff",transition:"left 0.2s"}})})]}),Ne=(E,J,se)=>l.jsx("div",{style:{display:"flex",gap:"6px",marginBottom:"12px"},children:E.map(ue=>l.jsx("button",{onClick:()=>se(ue.key),disabled:!$,style:{flex:1,padding:"6px",borderRadius:"6px",border:`1px solid ${U}`,cursor:"pointer",fontSize:"11px",fontWeight:J===ue.key?"bold":"normal",background:J===ue.key?"var(--color-accent)":le,color:J===ue.key?"#fff":X},children:ue.label},ue.key))}),ce=_.inputParameters?.http_request||_.httpRequest||{};return l.jsxs(l.Fragment,{children:[l.jsxs("div",{className:`detail-panel-container ${B}`,style:{position:"absolute",right:0,top:0,bottom:0,width:"450px",zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${U}`,boxShadow:"-10px 0 30px rgba(0, 0, 0, 0.2)",overflowY:"hidden"},children:[l.jsxs("div",{style:{padding:"24px",borderBottom:`1px solid ${U}`,background:"var(--bg-secondary)",flexShrink:0},children:[l.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[l.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:"4px",fontSize:"10px",fontWeight:"bold",letterSpacing:"1px"},children:_.type||"TASK"}),l.jsx("button",{onClick:r,style:{background:"none",border:"none",color:X,cursor:"pointer",fontSize:"20px"},children:"✕"})]}),$?l.jsx("input",{value:_.name||"",onChange:E=>ee("name",E.target.value),placeholder:"任务名称",style:{display:"block",width:"100%",fontSize:"22px",fontWeight:"bold",background:"transparent",border:"none",color:X,outline:"none",borderBottom:"2px dashed var(--color-accent)"}}):l.jsx("div",{style:{fontSize:"22px",fontWeight:"bold"},children:_.name}),l.jsxs("div",{style:{fontSize:"12px",color:Q,marginTop:"8px",fontFamily:"monospace",opacity:.8},children:["REF: ",_.taskReferenceName]})]}),l.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px",background:"var(--bg-primary)"},children:[_.type==="HTTP"&&ne("HTTP 请求配置","🌐","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"12px"},children:[l.jsx("select",{value:ce.method||"GET",onChange:E=>z("method",E.target.value),disabled:!$,style:{width:"90px",padding:"10px",borderRadius:"8px",background:le,color:X,border:`1px solid ${U}`,cursor:"pointer"},children:["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"].map(E=>l.jsx("option",{value:E,children:E},E))}),l.jsx("input",{placeholder:"URI (支持 ${workflow.input.uri})",value:ce.uri||"",onChange:E=>z("uri",E.target.value),disabled:!$,style:{flex:1,padding:"10px",borderRadius:"8px",background:le,color:X,border:`1px solid ${U}`}})]}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:"CONTENT-TYPE"}),l.jsx("input",{placeholder:"application/json",value:ce.contentType||"",onChange:E=>z("contentType",E.target.value),disabled:!$,style:{width:"100%",padding:"8px",borderRadius:"6px",background:le,color:X,border:`1px solid ${U}`,fontSize:"12px"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:"ACCEPT"}),l.jsx("input",{placeholder:"application/json",value:ce.accept||"",onChange:E=>z("accept",E.target.value),disabled:!$,style:{width:"100%",padding:"8px",borderRadius:"6px",background:le,color:X,border:`1px solid ${U}`,fontSize:"12px"}})]})]}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:"连接超时 (ms)"}),l.jsx("input",{type:"number",placeholder:"3000",value:ce.connectionTimeOut??"",onChange:E=>z("connectionTimeOut",E.target.value===""?void 0:Number(E.target.value)),disabled:!$,style:{width:"100%",padding:"8px",borderRadius:"6px",background:le,color:X,border:`1px solid ${U}`,fontSize:"12px"}})]}),l.jsxs("div",{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:"读取超时 (ms)"}),l.jsx("input",{type:"number",placeholder:"3000",value:ce.readTimeOut??"",onChange:E=>z("readTimeOut",E.target.value===""?void 0:Number(E.target.value)),disabled:!$,style:{width:"100%",padding:"8px",borderRadius:"6px",background:le,color:X,border:`1px solid ${U}`,fontSize:"12px"}})]})]}),l.jsxs("div",{style:{marginBottom:"12px"},children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:"HEADERS (JSON)"}),l.jsx("textarea",{value:typeof ce.headers=="object"?JSON.stringify(ce.headers,null,2):"{}",onChange:E=>{try{z("headers",JSON.parse(E.target.value))}catch{}},disabled:!$,rows:3,style:{width:"100%",padding:"8px",borderRadius:"8px",background:le,color:X,border:`1px solid ${U}`,fontSize:"11px",fontFamily:"monospace"}})]}),l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:"BODY (RAW/JSON)"}),l.jsx("textarea",{value:typeof ce.body=="object"?JSON.stringify(ce.body,null,2):ce.body||"",onChange:E=>{let J=E.target.value;try{J=JSON.parse(E.target.value)}catch{}z("body",J)},disabled:!$,rows:4,style:{width:"100%",padding:"8px",borderRadius:"8px",background:le,color:X,border:`1px solid ${U}`,fontSize:"11px",fontFamily:"monospace"}})]})),(_.type==="INLINE"||_.type==="LAMBDA")&&ne("内联脚本配置 (Inline)","📜","var(--color-accent)",l.jsxs(l.Fragment,{children:[pe("脚本引擎",["graaljs","javascript","value-param","python"],_.evaluatorType||"graaljs",E=>ee("evaluatorType",E)),ge(`EXPRESSION ${_.evaluatorType==="value-param"?"(值引用)":"(脚本)"}`,_.inputParameters?.expression||_.inputParameters?.scriptExpression||"",E=>{const J=_.inputParameters?.scriptExpression!==void 0?"scriptExpression":"expression";Z(J,E)},{rows:10,language:_.evaluatorType||"javascript",style:{background:"#000",color:"var(--color-accent)",border:"1px solid var(--color-accent)"}}),l.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:Q,fontStyle:"italic"},children:"提示: 使用 $.input.key 访问输入参数,返回值作为任务输出。"})]})),_.type==="JSON_JQ_TRANSFORM"&&ne("JQ 数据转换","🔍","var(--color-accent)",l.jsxs(l.Fragment,{children:[ge("JQ QUERY EXPRESSION",_.inputParameters?.queryExpression||"",E=>Z("queryExpression",E),{rows:6,language:"jq",style:{color:"var(--color-accent)"}}),l.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:Q},children:"输出字段: result(首个结果)、resultList(完整列表)"})]})),_.type==="SUB_WORKFLOW"&&ne("子工作流配置","🏗️","var(--color-accent)",l.jsxs(l.Fragment,{children:[ae("WORKFLOW NAME *",_.subWorkflowParam?.name||"",E=>he("subWorkflowParam","name",E),"text","e.g. my_workflow"),ae("VERSION",_.subWorkflowParam?.version??"",E=>he("subWorkflowParam","version",E?parseInt(E):void 0),"number","1"),ge("INPUT PARAMETERS MAPPING (JSON)",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):"{}",E=>{try{ee("inputParameters",JSON.parse(E))}catch{}},{rows:5,language:"json"}),l.jsxs("div",{style:{fontSize:"10px",color:Q,marginTop:"4px"},children:["传递给子工作流的参数,支持 ","${workflow.input.xxx}"," 表达式"]})]})),_.type==="START_WORKFLOW"&&ne("启动工作流配置","▶️","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{fontSize:"11px",color:Q,marginBottom:"12px",padding:"8px",borderRadius:"6px",background:"rgba(255,165,0,0.1)",border:"1px solid rgba(255,165,0,0.3)"},children:["⚡ 注意:此任务启动目标工作流后立即继续,",l.jsx("b",{children:"不等待"}),"目标工作流完成。"]}),ae("WORKFLOW NAME *",_.inputParameters?.startWorkflow?.name||"",E=>{const J={..._.inputParameters?.startWorkflow||{},name:E};Z("startWorkflow",J)},"text","e.g. target_workflow"),ae("VERSION",_.inputParameters?.startWorkflow?.version??"",E=>{const J={..._.inputParameters?.startWorkflow||{},version:E?parseInt(E):void 0};Z("startWorkflow",J)},"number","1"),ae("CORRELATION ID",_.inputParameters?.startWorkflow?.correlationId||"",E=>{const J={..._.inputParameters?.startWorkflow||{},correlationId:E};Z("startWorkflow",J)},"text","${workflow.correlationId}"),ge("WORKFLOW INPUT (JSON)",typeof _.inputParameters?.startWorkflow?.input=="object"?JSON.stringify(_.inputParameters.startWorkflow.input,null,2):"{}",E=>{try{const J={..._.inputParameters?.startWorkflow||{},input:JSON.parse(E)};Z("startWorkflow",J)}catch{}},{rows:4,language:"json"})]})),_.type==="TERMINATE"&&ne("终止状态配置","⏹️","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:"TERMINATION STATUS"}),l.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:["COMPLETED","FAILED"].map(E=>l.jsx("button",{onClick:()=>Z("terminationStatus",E),disabled:!$,style:{flex:1,padding:"8px",borderRadius:"6px",cursor:"pointer",background:(_.inputParameters?.terminationStatus||"COMPLETED")===E?"var(--color-accent)":le,color:(_.inputParameters?.terminationStatus||"COMPLETED")===E?"#fff":X,border:`1px solid ${U}`,fontWeight:"bold",fontSize:"11px"},children:E},E))}),ae("TERMINATION REASON",_.inputParameters?.terminationReason||"",E=>Z("terminationReason",E),"text","终止原因..."),ge("WORKFLOW OUTPUT (JSON)",typeof _.inputParameters?.workflowOutput=="object"?JSON.stringify(_.inputParameters.workflowOutput,null,2):"{}",E=>{try{Z("workflowOutput",JSON.parse(E))}catch{}},{rows:3,language:"json"})]})),_.type==="EVENT"&&ne("事件发送配置","✉️","var(--color-accent)",l.jsxs(l.Fragment,{children:[ae("EVENT SINK *",_.sink||"",E=>ee("sink",E),"text","e.g. sqs:queue_name 或 conductor"),l.jsx("div",{style:{fontSize:"10px",color:Q,marginTop:"4px",marginBottom:"8px"},children:"支持前缀: conductor | sqs | kafka | amqp | nats"}),me("异步完成 (asyncComplete)",!!_.asyncComplete,E=>ee("asyncComplete",E))]})),_.type==="WAIT"&&ne("等待状态配置","⏳","var(--color-accent)",l.jsxs(l.Fragment,{children:[Ne([{key:"duration",label:"等待时长"},{key:"until",label:"等待到指定时间"}],y,E=>x(E)),y==="duration"?ae("DURATION",_.inputParameters?.duration||"",E=>Z("duration",E),"text","e.g. 30s, 10m, 2 hours"):ae("UNTIL (时间点)",_.inputParameters?.until||"",E=>Z("until",E),"text","e.g. 2025-06-15 09:00 GMT+00:00"),l.jsxs("div",{style:{fontSize:"11px",color:Q,lineHeight:"1.6",marginTop:"8px"},children:["此任务会使工作流进入 ",l.jsx("b",{children:"IN_PROGRESS"})," 状态,直到时间满足或外部 API 触发完成。"]})]})),(_.type==="DECISION"||_.type==="SWITCH")&&ne("条件分支配置","⚖️","var(--color-accent)",l.jsxs(l.Fragment,{children:[pe("评估模式 (evaluatorType)",["value-param","javascript"],_.evaluatorType||"value-param",E=>ee("evaluatorType",E)),(_.evaluatorType||"value-param")==="value-param"?ae("CASE VALUE PARAM (参数名)",_.caseValueParam||"",E=>ee("caseValueParam",E),"text","e.g. status"):l.jsx(l.Fragment,{children:ge("CASE EXPRESSION (JS)",_.caseExpression||"",E=>ee("caseExpression",E),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}})}),l.jsx("div",{style:{fontSize:"10px",color:Q,marginTop:"8px"},children:'分支可在图中通过右键节点→"添加分支"进行管理'})]})),_.type==="DO_WHILE"&&ne("循环逻辑配置","🔄","var(--color-accent)",l.jsxs(l.Fragment,{children:[Ne([{key:"condition",label:"条件循环"},{key:"items",label:"列表迭代"}],b,E=>k(E)),b==="condition"?l.jsxs(l.Fragment,{children:[ge("LOOP CONDITION (JS) *",_.loopCondition||"",E=>ee("loopCondition",E),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}}),l.jsx("div",{style:{fontSize:"10px",color:Q,marginTop:"4px"},children:"条件为 true 时继续循环,false 时退出"})]}):l.jsxs(l.Fragment,{children:[l.jsx("label",{style:{display:"block",fontSize:"10px",color:Q,marginBottom:"4px"},children:"ITEMS (列表表达式)"}),l.jsx("input",{value:_.inputParameters?.items||"",onChange:E=>Z("items",E.target.value),disabled:!$,placeholder:"${workflow.input.myList}",style:{width:"100%",padding:"8px",borderRadius:"6px",border:`1px solid ${U}`,background:le,color:X,fontSize:"12px",outline:"none"}}),l.jsx("div",{style:{fontSize:"10px",color:Q,marginTop:"4px"},children:"引用一个数组,对每个元素执行一次循环体"})]}),l.jsx("div",{style:{marginTop:"12px"},children:ae("KEEP LAST N 次迭代",_.keepLastN??"",E=>ee("keepLastN",E?parseInt(E):void 0),"number","0 = 保留全部")})]})),_.type==="FORK_JOIN_DYNAMIC"&&ne("动态并行配置","⚡","var(--color-accent)",l.jsxs(l.Fragment,{children:[Ne([{key:"classic",label:"经典模式"},{key:"task",label:"任务简化"},{key:"workflow",label:"工作流简化"}],w,E=>j(E)),w==="classic"&&l.jsxs(l.Fragment,{children:[ae("DYNAMIC_FORK_TASKS_PARAM",_.dynamicForkTasksParam||"",E=>ee("dynamicForkTasksParam",E),"text","e.g. dynamic_tasks"),ae("DYNAMIC_FORK_TASKS_INPUT_PARAM",_.dynamicForkTasksInputParamName||"",E=>ee("dynamicForkTasksInputParamName",E),"text","e.g. input"),l.jsx("div",{style:{fontSize:"10px",color:Q},children:"经典模式:通过 inputParameters 传入 dynamicTasks 数组和 dynamicTasksInput 映射"})]}),w==="task"&&l.jsxs(l.Fragment,{children:[ae("FORK TASK TYPE *",_.forkTaskType||"",E=>ee("forkTaskType",E),"text","e.g. HTTP"),ae("FORK TASK NAME (仅 SIMPLE 任务)",_.forkTaskName||"",E=>ee("forkTaskName",E),"text","e.g. my_task"),ae("FORK TASK INPUTS PARAM",_.forkTaskInputs||"",E=>ee("forkTaskInputs",E),"text","e.g. inputs"),l.jsx("div",{style:{fontSize:"10px",color:Q},children:"所有分支执行相同任务类型,每个元素作为一个分支输入"})]}),w==="workflow"&&l.jsxs(l.Fragment,{children:[ae("FORK WORKFLOW NAME *",_.forkTaskWorkflow||"",E=>ee("forkTaskWorkflow",E),"text","e.g. sub_workflow"),ae("WORKFLOW VERSION",_.forkTaskWorkflowVersion||"",E=>ee("forkTaskWorkflowVersion",E),"text","1"),ae("FORK TASK INPUTS PARAM",_.forkTaskInputs||"",E=>ee("forkTaskInputs",E),"text","e.g. inputs"),l.jsx("div",{style:{fontSize:"10px",color:Q},children:"所有分支执行相同子工作流,每个元素作为一个子工作流输入"})]})]})),_.type==="DYNAMIC"&&ne("动态任务配置","🎯","var(--color-accent)",l.jsxs(l.Fragment,{children:[ae("DYNAMIC TASK NAME PARAM *",_.dynamicTaskNameParam||"",E=>ee("dynamicTaskNameParam",E),"text","e.g. taskToExecute"),l.jsx("div",{style:{fontSize:"10px",color:Q,marginTop:"4px"},children:'运行时从 inputParameters 的指定键中读取实际任务类型名(如 "HTTP"、"SIMPLE")'})]})),_.type==="HUMAN"&&ne("人工审批配置","👤","var(--color-accent)",l.jsxs(l.Fragment,{children:[ae("表单模板名 (userFormTemplate)",_.humanTaskDef?.userFormTemplate||"",E=>he("humanTaskDef","userFormTemplate",E),"text","e.g. approval_form"),pe("分配策略 (assignmentCompletionStrategy)",["LEAVE_OPEN","TERMINATE"],_.humanTaskDef?.assignmentCompletionStrategy||"LEAVE_OPEN",E=>he("humanTaskDef","assignmentCompletionStrategy",E)),ae("显示名称 (displayName)",_.humanTaskDef?.displayName||"",E=>he("humanTaskDef","displayName",E),"text","审批任务")]})),_.type==="KAFKA_PUBLISH"&&ne("Kafka 推送配置","📨","var(--color-accent)",l.jsxs(l.Fragment,{children:[ae("BOOTSTRAP SERVERS *",_.inputParameters?.bootStrapServers||"",E=>Z("bootStrapServers",E),"text","localhost:9092"),ae("TOPIC *",_.inputParameters?.topic||"",E=>Z("topic",E),"text","my_topic"),ae("KEY (消息分区键)",_.inputParameters?.key||"",E=>Z("key",E),"text",""),ge("VALUE (消息内容)",typeof _.inputParameters?.value=="object"?JSON.stringify(_.inputParameters.value,null,2):_.inputParameters?.value||"",E=>{let J=E;try{J=JSON.parse(E)}catch{}Z("value",J)},{rows:4,language:"json"}),ge("HEADERS (JSON)",typeof _.inputParameters?.headers=="object"?JSON.stringify(_.inputParameters.headers,null,2):"{}",E=>{try{Z("headers",JSON.parse(E))}catch{}},{rows:3,language:"json"})]})),_.type==="SET_VARIABLE"&&ne("变量配置","📦","var(--color-accent)",l.jsxs(l.Fragment,{children:[l.jsxs("div",{style:{fontSize:"11px",color:Q,marginBottom:"12px"},children:["在 inputParameters 中定义要设置的变量名和值,后续任务通过 ","${workflow.variables.varName}"," 访问。"]}),ge("VARIABLES (JSON)",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):"{}",E=>{try{ee("inputParameters",JSON.parse(E))}catch{}},{rows:6,language:"json"})]})),l.jsxs("div",{style:{marginTop:"32px",borderTop:`1px solid ${U}`,paddingTop:"24px"},children:[l.jsx("div",{style:{fontSize:"11px",fontWeight:"bold",marginBottom:"16px",opacity:.6,textTransform:"uppercase",letterSpacing:"1px"},children:"通用参数与属性"}),Y("任务唯一引用名 (Reference Name)","taskReferenceName"),Y("任务描述","description"),l.jsxs("div",{style:{marginBottom:"16px"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px",gap:"6px"},children:[l.jsxs("label",{style:{fontSize:"11px",color:Q,fontWeight:"600",textTransform:"uppercase",flex:1},children:["输入参数 (inputParameters) ",l.jsx("span",{style:{opacity:.5,fontWeight:"normal"},children:"(JSON)"})]}),$&&l.jsxs("div",{style:{display:"flex",gap:"6px"},children:[l.jsxs("button",{onClick:ie,disabled:K,title:"AI 根据上下文自动生成 inputParameters",style:{fontSize:"11px",background:"linear-gradient(135deg, #6366f1, #8b5cf6)",border:"none",borderRadius:"4px",padding:"2px 8px",cursor:K?"not-allowed":"pointer",color:"#fff",fontWeight:600,display:"flex",alignItems:"center",gap:"4px",opacity:K?.7:1},children:[K?"⏳":"✨"," AI 填充"]}),l.jsxs("button",{onClick:()=>g(!h),title:"快捷表达式",style:{fontSize:"11px",background:h?"var(--color-accent)":"none",border:`1px solid ${U}`,borderRadius:"4px",padding:"2px 6px",cursor:"pointer",color:h?"#fff":Q},children:["{}"," 片段"]})]})]}),h&&l.jsx("div",{style:{marginBottom:"8px",padding:"8px",borderRadius:"6px",border:`1px solid ${U}`,background:"var(--bg-secondary)",display:"flex",flexWrap:"wrap",gap:"6px"},children:bb.map(E=>l.jsx("button",{onClick:()=>H(E.value),title:E.desc,style:{fontSize:"10px",padding:"3px 8px",borderRadius:"4px",border:`1px solid ${U}`,background:le,color:X,cursor:"pointer",fontFamily:"monospace"},children:E.label},E.value))}),te&&l.jsxs("div",{style:{marginBottom:"8px",borderRadius:"8px",border:"1px solid #6366f130",background:"#6366f108",overflow:"hidden"},children:[l.jsxs("div",{style:{padding:"8px 12px",background:"#6366f118",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[l.jsx("span",{style:{fontSize:"11px",fontWeight:700,color:"#6366f1"},children:"✨ AI 建议的 inputParameters"}),l.jsxs("div",{style:{display:"flex",gap:"6px"},children:[l.jsx("button",{onClick:()=>{ee("inputParameters",te.generated),re(null)},style:{fontSize:"11px",background:"#6366f1",color:"#fff",border:"none",borderRadius:"4px",padding:"3px 10px",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:"应用"}),l.jsx("button",{onClick:()=>re(null),style:{fontSize:"11px",background:"none",color:Q,border:`1px solid ${U}`,borderRadius:"4px",padding:"3px 8px",cursor:"pointer",fontFamily:"inherit"},children:"取消"})]})]}),l.jsx("pre",{style:{margin:0,padding:"10px 12px",fontSize:"12px",fontFamily:"var(--font-mono)",overflowX:"auto",color:X,maxHeight:"180px",overflowY:"auto"},children:JSON.stringify(te.generated,null,2)})]}),ge("",typeof _.inputParameters=="object"&&_.inputParameters!==null?JSON.stringify(_.inputParameters,null,2):_.inputParameters??"",E=>{try{ee("inputParameters",JSON.parse(E))}catch{u(J=>({...J,inputParameters:E}))}},{rows:5,language:"json","data-field":"inputParameters",style:{outline:"none"}})]}),l.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[Y("重试次数","retryCount","number"),Y("超时限制 (秒)","timeoutSeconds","number")]}),l.jsxs("details",{style:{marginTop:"16px"},children:[l.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",color:Q,userSelect:"none",fontWeight:"600"},children:"▸ 执行控制(高级)"}),l.jsxs("div",{style:{marginTop:"12px"},children:[pe("重试策略 (retryLogic)",["FIXED","EXPONENTIAL_BACKOFF","LINEAR_BACKOFF"],_.retryLogic||"FIXED",E=>ee("retryLogic",E)),ae("重试延迟 (秒)",_.retryDelaySeconds??"",E=>ee("retryDelaySeconds",E?parseInt(E):void 0),"number","0"),pe("超时策略 (timeoutPolicy)",["TIME_OUT_WF","ALERT_ONLY","RETRY","FAIL_WORKFLOW"],_.timeoutPolicy||"TIME_OUT_WF",E=>ee("timeoutPolicy",E)),ae("启动延迟 (秒)",_.startDelay??"",E=>ee("startDelay",E?parseInt(E):void 0),"number","0"),me("可选任务 (optional) — 失败不影响工作流",!!_.optional,E=>ee("optional",E)),me("异步完成 (asyncComplete)",!!_.asyncComplete,E=>ee("asyncComplete",E))]})]})]}),l.jsx("div",{style:{marginTop:"48px",opacity:.6},children:l.jsxs("details",{children:[l.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",marginBottom:"8px"},children:"查看完整 JSON (只读)"}),l.jsx("pre",{style:{background:"rgba(0,0,0,0.2)",padding:"16px",borderRadius:"8px",fontSize:"10px",overflow:"auto",border:`1px solid ${U}`,color:Q},children:JSON.stringify(_,null,2)})]})})]}),$&&l.jsxs("div",{style:{padding:"24px",borderTop:`1px solid ${U}`,background:"var(--bg-secondary)",display:"flex",gap:"12px",flexShrink:0},children:[l.jsx("div",{style:{flex:1,fontSize:"11px",color:Q,display:"flex",alignItems:"center"},children:"✅ 所有修改已实时同步"}),l.jsx("button",{onClick:r,style:{padding:"10px 24px",background:"var(--color-accent)",color:"#fff",border:"none",borderRadius:"8px",fontWeight:"bold",cursor:"pointer",boxShadow:"0 4px 12px var(--color-accent-bg)"},children:"完成退出"})]}),l.jsx(yb,{isOpen:N,onClose:()=>L(!1),onSelect:I,suggestions:S,anchorRect:T})]}),F&&l.jsx(xb,{title:F.title,value:F.value,language:F.language,onSave:F.onSave,onClose:()=>W(null)})]})},_b=O.memo(kb),Sb={COMPLETED:"var(--status-completed)",FAILED:"var(--status-failed)",FAILED_WITH_TERMINAL_ERROR:"var(--status-failed-terminal)",IN_PROGRESS:"var(--status-in-progress)",SCHEDULED:"var(--status-scheduled)",TIMED_OUT:"var(--status-timed-out)",CANCELED:"var(--status-canceled)",SKIPPED:"var(--status-skipped)"},Sr=e=>Sb[e??""]??"var(--text-secondary)",wb=(e,n)=>{if(!e)return"-";const r=(n??Date.now())-e;return r<1e3?`${r}ms`:`${(r/1e3).toFixed(2)}s`},Qh=e=>e?new Date(e).toLocaleTimeString():"-",Tb=({executionActions:e})=>{const{selectedTask:n,selectedTaskInstance:r,setSelectedTask:t,setSelectedTaskInstance:s,executionData:a,workflowInstance:o}=oe(),[i,u]=O.useState("summary"),c=O.useRef(null);O.useEffect(()=>{c.current?.scrollTo({top:0})},[i,n?.taskReferenceName]),O.useEffect(()=>{u("summary")},[n?.taskReferenceName]);const d=n?.taskReferenceName==="__workflow_global__",f=n?a?.[n.taskReferenceName]:null;if(!n||!f&&!d)return null;const p=f?.attempts??[],h=r??p[p.length-1],g=o?.workflowId??"",m=o?.status,v=f?.status,y=d?m:h?.status??v,x=d?o?.startTime:h?.startTime,b=d?o?.endTime:h?.endTime,k=d?o?.reasonForIncompletion:h?.reasonForIncompletion,w=d?o?.workflowId:h?.taskId,j=d?o?.input:h?.inputData,N=d?o?.output:h?.outputData,L=!d&&e?.onSkipTask&&(v==="SCHEDULED"||v==="IN_PROGRESS")&&(m==="RUNNING"||m==="PAUSED"),T=!d&&e?.onRerunFromTask&&(m==="FAILED"||m==="TERMINATED"||m==="COMPLETED"||m==="TIMED_OUT"),C=L||T,S=e?.allowOperations!==!1,D=()=>{t(null),s(null)},I="var(--glass-border)",P="var(--text-secondary)",F="var(--bg-tertiary)";return l.jsxs("div",{className:"detail-panel-container panel-enter-active",style:{position:"absolute",right:0,top:0,bottom:0,width:450,zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${I}`,boxShadow:"-10px 0 30px rgba(0,0,0,0.2)",overflow:"hidden"},children:[l.jsxs("div",{style:{padding:"20px 24px",borderBottom:`1px solid ${I}`,background:"var(--bg-secondary)",flexShrink:0},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[l.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:"bold",letterSpacing:"1px",flexShrink:0},children:d?"WORKFLOW":n.type||"TASK"}),y&&l.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,background:`${Sr(y)}18`,color:Sr(y),letterSpacing:"0.5px",flexShrink:0},children:["● ",y]}),l.jsx("div",{style:{flex:1}}),l.jsx("button",{onClick:D,style:{background:"none",border:"none",color:P,cursor:"pointer",fontSize:20,lineHeight:1,padding:4},children:"✕"})]}),l.jsx("div",{style:{fontSize:20,fontWeight:700,color:"var(--text-primary)",lineHeight:1.3},children:d?"工作流全局数据":n.name}),l.jsxs("div",{style:{fontSize:12,color:P,marginTop:6,fontFamily:"monospace",opacity:.8},children:["REF: ",n.taskReferenceName]})]}),p.length>1&&l.jsxs("div",{style:{padding:"12px 24px",borderBottom:`1px solid ${I}`,background:"var(--bg-secondary)",flexShrink:0},children:[l.jsxs("div",{style:{fontSize:11,fontWeight:600,color:P,marginBottom:8,textTransform:"uppercase",letterSpacing:"0.5px"},children:["执行记录(",p.length," 次",p.some(W=>W.iteration)?" / 迭代":"尝试",")"]}),l.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:p.map((W,K)=>{const V=h?.taskId===W.taskId;return l.jsx("button",{onClick:()=>s(W),style:{padding:"4px 12px",borderRadius:20,fontSize:12,cursor:"pointer",border:`1px solid ${V?"var(--color-accent)":I}`,background:V?"var(--color-accent)":"var(--bg-tertiary)",color:V?"#fff":"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},children:W.iteration?`迭代 ${W.iteration}`:`尝试 ${K+1}`},W.taskId)})})]}),l.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${I}`,background:"var(--bg-secondary)",flexShrink:0},children:["summary","input","output"].map(W=>{const K={summary:"概览",input:"输入 JSON",output:"输出 JSON"},V=i===W;return l.jsx("button",{onClick:()=>u(W),style:{padding:"10px 20px",background:"none",border:"none",borderBottom:`2px solid ${V?"var(--color-accent)":"transparent"}`,color:V?"var(--color-accent)":P,cursor:"pointer",fontSize:13,fontWeight:V?600:400,fontFamily:"inherit",transition:"all 0.15s"},children:K[W]},W)})}),l.jsxs("div",{ref:c,style:{flex:1,overflowY:"auto",padding:24,background:"var(--bg-primary)"},children:[i==="summary"&&l.jsxs(l.Fragment,{children:[l.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:24},children:[{label:"总耗时",value:wb(x,b)},{label:"开始时间",value:Qh(x)},{label:"结束时间",value:Qh(b)},{label:d?"Workflow ID":"Task ID",value:l.jsx("span",{style:{fontSize:10,fontFamily:"monospace",opacity:.7,wordBreak:"break-all"},children:w??"-"})}].map(({label:W,value:K})=>l.jsxs("div",{style:{padding:"12px 14px",background:F,borderRadius:10,border:`1px solid ${I}`},children:[l.jsx("div",{style:{fontSize:10,color:P,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:6,fontWeight:600},children:W}),l.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:13},children:K})]},W))}),p.length>1&&l.jsxs("div",{style:{marginBottom:20,padding:"10px 14px",background:`${Sr(v)}10`,border:`1px solid ${Sr(v)}30`,borderRadius:8,fontSize:12,color:Sr(v),display:"flex",alignItems:"center",gap:8},children:[l.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("path",{d:"M13 2v4h-4"}),l.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),"已重试 ",p.length-1," 次,共 ",p.length," 次尝试"]}),!d&&h?.workerId&&l.jsxs("div",{style:{marginBottom:20},children:[l.jsx("div",{style:{fontSize:10,color:P,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:4,fontWeight:600},children:"Worker"}),l.jsx("div",{style:{fontSize:12,fontFamily:"monospace",color:"var(--text-primary)",opacity:.8},children:h.workerId})]}),k&&l.jsxs("div",{style:{padding:14,background:"rgba(239,68,68,0.08)",borderLeft:"3px solid var(--status-failed)",borderRadius:"0 8px 8px 0",fontSize:12,color:"var(--status-failed)",lineHeight:1.6},children:[l.jsx("strong",{children:"异常信息"}),l.jsx("div",{style:{marginTop:6,opacity:.9},children:k})]}),C&&l.jsxs("div",{style:{marginTop:24,paddingTop:20,borderTop:`1px solid ${I}`},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[l.jsx("div",{style:{fontSize:11,fontWeight:600,color:P,textTransform:"uppercase",letterSpacing:"0.5px"},children:"任务操作"}),!S&&l.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 7px",borderRadius:4,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",color:"var(--status-failed)",fontSize:10,fontWeight:600},children:[l.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[l.jsx("circle",{cx:"8",cy:"8",r:"6"}),l.jsx("path",{d:"M8 5v3M8 11v.5"})]}),"操作权限受限"]})]}),l.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[T&&l.jsxs("button",{disabled:!S,onClick:()=>S&&e.onRerunFromTask(g,n.taskReferenceName,h?.taskId),title:S?`从任务 ${n.taskReferenceName} 处重新运行工作流`:"操作权限受限",style:S?Ze:rg,onMouseEnter:W=>!S||Object.assign(W.currentTarget.style,Eb),onMouseLeave:W=>!S||Object.assign(W.currentTarget.style,Ze),children:[l.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("path",{d:"M3 14v-4h4"}),l.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"从此处重新运行"]}),L&&l.jsxs("button",{disabled:!S,onClick:()=>S&&e.onSkipTask(g,n.taskReferenceName,h?.taskId),title:S?`跳过任务 ${n.taskReferenceName}`:"操作权限受限",style:S?Ze:rg,onMouseEnter:W=>!S||Object.assign(W.currentTarget.style,Nb),onMouseLeave:W=>!S||Object.assign(W.currentTarget.style,Ze),children:[l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:l.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})}),"跳过此任务"]})]})]})]}),i==="input"&&l.jsx(eg,{data:j}),i==="output"&&l.jsx(eg,{data:N})]})]})},eg=({data:e})=>l.jsx("div",{style:{background:"var(--bg-tertiary)",padding:16,borderRadius:10,border:"1px solid var(--glass-border)",fontFamily:"'Fira Code', monospace",fontSize:12,lineHeight:1.6,color:"var(--text-primary)",wordBreak:"break-all",whiteSpace:"pre-wrap"},children:JSON.stringify(e??{},null,2)}),Ze={display:"inline-flex",alignItems:"center",gap:6,padding:"7px 14px",borderRadius:8,fontSize:12,fontWeight:500,cursor:"pointer",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},Eb={...Ze,borderColor:"var(--color-accent)",color:"var(--color-accent)",background:"var(--bg-primary)"},Nb={...Ze,borderColor:"var(--status-failed)",color:"var(--status-failed)",background:"rgba(239,68,68,0.08)"},rg={...Ze,opacity:.45,cursor:"not-allowed",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-secondary)"},Cb={add:"新增",mod:"修改",del:"删除",replace:"替换"},jb={add:"+",mod:"~",del:"−"};function Ib({diff:e,applied:n,onApply:r,onUndo:t}){const s=e.kind==="replace"?"add":e.kind;return l.jsxs("div",{className:"diff-card",children:[l.jsxs("div",{className:"diff-head",children:[l.jsx("span",{className:`diff-badge ${s}`,children:Cb[e.kind]??e.kind}),l.jsx("span",{className:"diff-summary",children:e.summary})]}),e.rows&&e.rows.length>0&&l.jsx("div",{className:"diff-list",children:e.rows.map((a,o)=>l.jsxs("div",{className:`diff-row ${a.kind}`,children:[l.jsx("div",{className:"diff-marker",children:jb[a.kind]??"·"}),l.jsx("div",{className:"diff-desc",children:a.desc})]},o))}),l.jsx("div",{className:"diff-actions",children:n?l.jsxs(l.Fragment,{children:[l.jsxs("button",{className:"diff-btn applied",disabled:!0,children:[l.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:l.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"已应用"]}),l.jsxs("button",{className:"diff-btn undo",onClick:t,children:[l.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[l.jsx("path",{d:"M3.5 8a4.5 4.5 0 1 1 1.4 3.3",strokeLinecap:"round"}),l.jsx("path",{d:"M3 4.5L4.5 8L7 6.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"撤销"]})]}):l.jsxs("button",{className:"diff-btn apply",onClick:r,children:[l.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:l.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"应用更改"]})})]})}function tg(e,n){const r=JSON.parse(JSON.stringify(e));if(n.kind==="replace"&&n.payload)return{next:JSON.parse(JSON.stringify(n.payload)),inverse:{kind:"replace",summary:"撤销替换",rows:[],payload:e}};if(n.kind==="add"&&n.payload)return{next:JSON.parse(JSON.stringify(n.payload)),inverse:{kind:"replace",summary:"撤销生成",rows:[],payload:e}};if(!n.patch)return{next:r,inverse:{kind:n.kind,summary:"(无变更)",rows:[]}};const t=[],s=[];for(const a of n.patch)if(a.op==="patchTask"){const o=r.tasks.find(u=>u.taskReferenceName===a.ref);if(!o)continue;const i={};for(const u of Object.keys(a.set))i[u]=o[u];Object.assign(o,a.set),t.push({op:"patchTask",ref:a.ref,set:i}),s.push({kind:"mod",desc:`还原 ${a.ref} 属性`})}else if(a.op==="addEdge")r.edges=r.edges??[],r.edges.push({from:a.from,to:a.to,label:a.label}),t.push({op:"removeEdge",from:a.from,to:a.to}),s.push({kind:"del",desc:`移除边 ${a.from} → ${a.to}`});else if(a.op==="removeEdge")r.edges=(r.edges??[]).filter(o=>!(o.from===a.from&&o.to===a.to)),t.push({op:"addEdge",from:a.from,to:a.to}),s.push({kind:"add",desc:`恢复边 ${a.from} → ${a.to}`});else if(a.op==="addTask")r.tasks.push(a.task),r.edges=r.edges??[],a.removeEdges&&a.removeEdges.forEach(o=>{r.edges=r.edges.filter(i=>!(i.from===o.from&&i.to===o.to))}),a.extraEdges&&a.extraEdges.forEach(o=>r.edges.push(o)),t.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}`});else if(a.op==="removeTask"){const o=r.tasks.findIndex(c=>c.taskReferenceName===a.ref);if(o<0)continue;const[i]=r.tasks.splice(o,1),u=(r.edges??[]).filter(c=>c.from===a.ref||c.to===a.ref);r.edges=(r.edges??[]).filter(c=>c.from!==a.ref&&c.to!==a.ref),t.push({op:"addTask",task:i,extraEdges:u}),s.push({kind:"add",desc:`恢复 ${a.ref}`})}else if(a.op==="insertAfter"){r.tasks.push(a.task),r.edges=r.edges??[];const o=r.edges.findIndex(i=>i.from===a.after&&i.to===a.edgeTo);o>=0&&r.edges.splice(o,1),r.edges.push({from:a.after,to:a.task.taskReferenceName}),r.edges.push({from:a.task.taskReferenceName,to:a.edgeTo}),t.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复直连边)`})}else if(a.op==="insertBefore"){r.tasks.push(a.task),r.edges=r.edges??[];const o=r.edges.filter(i=>i.to===a.before);r.edges=r.edges.filter(i=>i.to!==a.before),o.forEach(i=>r.edges.push({from:i.from,to:a.task.taskReferenceName,label:i.label})),r.edges.push({from:a.task.taskReferenceName,to:a.before}),t.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复原有入边)`})}return{next:r,inverse:{kind:n.kind,summary:`撤销:${n.summary}`,rows:s,patch:t.reverse()}}}function Rb(e){const n=e.match(/```diff-json\n([\s\S]*?)\n```/);if(!n)return null;try{const r=JSON.parse(n[1]);return!r.kind||!r.summary?null:r}catch{return null}}const ng={id:"1",role:"ai",content:"你好!我是您的流程助手。我可以帮你生成工作流框架、优化逻辑或提供参数配置建议。你想实现什么样的流程?"},ag=e=>e.split(/(```[\s\S]*?```)/).map((r,t)=>{if(r.startsWith("```")&&r.endsWith("```")){const s=r.slice(3,-3),a=s.indexOf(`
|
|
121
|
+
`),o=a>=0?s.slice(a+1):s;return l.jsx("pre",{children:l.jsx("code",{children:o})},t)}return l.jsx("span",{children:Ob(r)},t)}),Ob=e=>{const n=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\n)/g;let t=0,s;for(;(s=r.exec(e))!==null;){s.index>t&&n.push(e.slice(t,s.index));const a=s[0];a.startsWith("**")&&a.endsWith("**")?n.push(l.jsx("strong",{children:a.slice(2,-2)},s.index)):a.startsWith("`")&&a.endsWith("`")?n.push(l.jsx("code",{children:a.slice(1,-1)},s.index)):a===`
|
|
122
|
+
`&&n.push(l.jsx("br",{},s.index)),t=s.index+a.length}return t<e.length&&n.push(e.slice(t)),n},Pb=({aiConfig:e})=>{const{workflowDef:n,setWorkflow:r,mode:t}=oe(),[s,a]=O.useState(!1),[o,i]=O.useState(""),[u,c]=O.useState(!1),[d,f]=O.useState([ng]),[p,h]=O.useState(""),[g,m]=O.useState(null),v=O.useRef(null),y=O.useRef(null),x=O.useRef(null),b=O.useCallback(P=>{if(!P.diff||P.applied||!n)return;const{next:F,inverse:W}=tg(n,P.diff);r(F),f(K=>K.map(V=>V.id===P.id?{...V,applied:!0,inverse:W}:V))},[n,r]),k=O.useCallback(P=>{if(!P.inverse||!P.applied||!n)return;const{next:F}=tg(n,P.inverse);r(F),f(W=>W.map(K=>K.id===P.id?{...K,applied:!1,inverse:void 0}:K))},[n,r]),w=()=>{const P=y.current;P&&(P.style.height="auto",P.style.height=Math.min(P.scrollHeight,120)+"px")},j=()=>{const P=y.current;P&&(P.style.height="auto")};O.useEffect(()=>()=>{x.current?.abort()},[]),O.useEffect(()=>{const P=()=>a(!0);return window.addEventListener("open-ai-chat",P),()=>window.removeEventListener("open-ai-chat",P)},[]);const N=()=>{v.current?.scrollIntoView({behavior:"smooth"})};O.useEffect(()=>{s&&N()},[d,s,p]);const L=O.useCallback(P=>{const F=[{role:"system",content:gb}];for(const K of d)K.role==="user"&&K.content?F.push({role:"user",content:K.content}):K.role==="ai"&&K.content&&!K.thinking&&F.push({role:"assistant",content:K.content});const W=mb(P,n);return F.push({role:"user",content:W}),F},[d,n]),T=async P=>{const F=o.trim();if(!F||u)return;x.current?.abort();const W=new AbortController;x.current=W;const K={id:Date.now().toString(),role:"user",content:F};f(V=>[...V,K]),i(""),j(),c(!0),h("");try{const V=e?.apiKey||localStorage.getItem("AI_API_KEY")||"",te=e?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",re=e?.model||localStorage.getItem("AI_MODEL")||"";if(!V){setTimeout(()=>{if(W.signal.aborted)return;const B={name:"demo_approval_workflow",description:"演示审批流程",tasks:[{name:"submit_request",taskReferenceName:"submit_request",type:"SIMPLE",inputParameters:{}},{name:"human_approval",taskReferenceName:"human_approval",type:"HUMAN",inputParameters:{}},{name:"process_result",taskReferenceName:"process_result",type:"SIMPLE",inputParameters:{}}]},$={id:(Date.now()+1).toString(),role:"ai",content:"**演示模式**:未检测到 API Key,以下是一个示例审批流程供体验。请在标题栏 🤖 按钮中配置真实 API Key 以启用 AI 功能。",diff:{kind:"replace",summary:"生成三步审批流程(演示)",rows:[{kind:"add",desc:"submit_request — 提交申请任务"},{kind:"add",desc:"human_approval — 人工审批任务"},{kind:"add",desc:"process_result — 处理审批结果"}],payload:B}};f(X=>[...X,$]),c(!1)},800);return}const q={apiKey:V};te&&(q.baseUrl=te),re&&(q.model=re);const G=L(F),ie=await fb(G,q,B=>{h($=>$+B)},()=>{},W.signal);let M=Rb(ie);if(!M){const B=ie.match(/```json\n([\s\S]*?)\n```/);if(B)try{const $=JSON.parse(B[1]);M={kind:"replace",summary:"应用 AI 生成的工作流",rows:[{kind:"add",desc:"全量替换为 AI 生成的工作流定义"}],payload:$}}catch{}}const _={id:(Date.now()+1).toString(),role:"ai",content:ie,diff:M??void 0,applied:!1};f(B=>[...B,_]),h("")}catch(V){if(V.name==="AbortError")h(te=>{if(te){const re={id:(Date.now()+1).toString(),role:"ai",content:te};f(q=>[...q,re])}return""});else{const te={id:Date.now().toString(),role:"ai",content:`抱歉,目前无法连接到 AI 服务: ${V.message}`};f(re=>[...re,te]),h("")}}finally{c(!1)}},C=()=>{x.current?.abort()},S=()=>{x.current?.abort(),f([ng]),h(""),c(!1)},D=P=>{navigator.clipboard.writeText(P.content??""),m(P.id),setTimeout(()=>m(null),1500)},I=P=>{P.nativeEvent.isComposing||P.keyCode===229||P.key==="Enter"&&!P.shiftKey&&(P.preventDefault(),T())};return t!=="edit"?null:s?l.jsxs("div",{className:"ai-chat-panel",children:[l.jsxs("div",{className:"ai-header",children:[l.jsxs("div",{className:"ai-title",children:[l.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]}),l.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[l.jsx("button",{className:"ai-close",onClick:S,title:"清空对话",children:"🗑"}),l.jsx("button",{className:"ai-close",onClick:()=>a(!1),children:"×"})]})]}),l.jsxs("div",{className:"ai-messages",children:[d.map(P=>l.jsxs("div",{className:`message ${P.role}`,children:[l.jsx("div",{className:"message-content",children:P.thinking?l.jsxs("div",{className:"thinking-skeleton",children:[l.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),l.jsx("div",{className:"skeleton-line",style:{width:"60%"}})]}):P.role==="ai"?ag(P.content??""):P.content}),P.diff&&!P.thinking&&l.jsx(Ib,{diff:P.diff,applied:P.applied??!1,onApply:()=>b(P),onUndo:()=>k(P)}),P.role==="ai"&&P.content&&l.jsx("button",{className:"copy-btn",onClick:()=>D(P),title:"复制",children:g===P.id?"✓":"📋"})]},P.id)),u&&p&&l.jsxs("div",{className:"message ai",style:{opacity:.9},children:[l.jsx("div",{className:"message-content",children:ag(p)}),l.jsx("span",{className:"streaming-cursor",children:"▊"})]}),u&&!p&&l.jsxs("div",{className:"message ai thinking-skeleton",children:[l.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),l.jsx("div",{className:"skeleton-line",style:{width:"60%"}}),l.jsx("div",{className:"skeleton-line",style:{width:"70%"}})]}),l.jsx("div",{ref:v})]}),l.jsx("div",{className:"ai-input-area",children:l.jsxs("div",{className:"ai-input-container",children:[l.jsx("textarea",{ref:y,className:"ai-input",placeholder:u?"AI 正在响应...":"描述您的需求…(Shift+Enter 换行)",value:o,onChange:P=>i(P.target.value),onInput:w,onKeyDown:I,disabled:u,rows:2}),u?l.jsx("button",{className:"ai-send stop",onClick:C,title:"停止生成",children:"⏹"}):l.jsx("button",{className:"ai-send",onClick:()=>T(),title:"发送",children:"🚀"})]})})]}):l.jsx("div",{className:"ai-chat-panel collapsed",onClick:()=>a(!0),children:l.jsx("div",{className:"ai-header",style:{borderBottom:"none"},children:l.jsxs("div",{className:"ai-title",children:[l.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]})})})},Ab=new Set(["COMPLETED","FAILED","TIMED_OUT","TERMINATED"]),Lb=({onTriggerExecution:e,onPollExecution:n,executionPollInterval:r=3e3})=>{const{workflowDef:t,showRunPanel:s,setShowRunPanel:a,setRunState:o,importExecutionJSON:i,setMode:u}=oe(),[c,d]=O.useState("form"),[f,p]=O.useState({}),[h,g]=O.useState("{}"),[m,v]=O.useState(""),[y,x]=O.useState(!1),[b,k]=O.useState(""),w=Zr(t?.inputParameters);O.useEffect(()=>{s&&(p({}),g("{}"),v(""),k(""),x(!1))},[s]);const j=O.useCallback(()=>{try{const S={};w.forEach(D=>{const I=f[D.name];if(I!==void 0&&I!=="")if(D.type==="number")S[D.name]=Number(I);else if(D.type==="boolean")S[D.name]=I==="true";else if(D.type==="object"||D.type==="array")try{S[D.name]=JSON.parse(I)}catch{S[D.name]=I}else S[D.name]=I;else D.defaultValue!==void 0&&(S[D.name]=D.defaultValue)}),g(JSON.stringify(S,null,2))}catch{}d("json")},[f,w]),N=O.useCallback(()=>{try{const S=JSON.parse(h),D={};w.forEach(I=>{const P=S[I.name];P!==void 0&&(D[I.name]=typeof P=="object"?JSON.stringify(P,null,2):String(P))}),p(D),v("")}catch{v("JSON 格式有误,无法切换为表单模式")}d("form")},[h,w]),L=O.useCallback(()=>{if(c==="json")try{return JSON.parse(h)}catch{return v("JSON 格式有误,请检查后重试"),null}const S={};return w.forEach(D=>{const I=f[D.name]??(D.defaultValue!==void 0?String(D.defaultValue):"");if(!(I===""&&!D.required))if(D.type==="number")S[D.name]=Number(I);else if(D.type==="boolean")S[D.name]=I==="true";else if(D.type==="object"||D.type==="array")try{S[D.name]=JSON.parse(I)}catch{S[D.name]=I}else S[D.name]=I}),S},[c,h,f,w]),T=O.useCallback(async()=>{if(!e||!t)return;const S=L();if(S===null)return;const D=w.filter(I=>I.required&&(S[I.name]===void 0||S[I.name]===""));if(D.length>0){k(`必填参数未填写:${D.map(I=>I.name).join(", ")}`);return}x(!0),k(""),o("triggering");try{const{workflowId:I}=await e(t.name,t.version??1,S);if(o("polling",I),a(!1),u("run"),!n)return;let P=r;const F=15e3;let W;const K=async()=>{try{const V=await n(I);if(V&&(i(V),Ab.has(V.status))){o("done",I);return}}catch{}P=Math.min(P*1.5,F),W=setTimeout(K,P)};W=setTimeout(K,P),oe.getState().__pollTimer=W}catch(I){const P=I?.message||"执行触发失败,请检查配置后重试";o("error",null,P),k(P),x(!1)}},[e,n,t,L,w,o,a,i,u,r]);if(!s||!t)return null;const C=w.length>0;return l.jsx("div",{className:"wrp-overlay",onClick:()=>a(!1),children:l.jsxs("div",{className:"wrp-panel",onClick:S=>S.stopPropagation(),children:[l.jsxs("div",{className:"wrp-header",children:[l.jsxs("div",{className:"wrp-header-title",children:[l.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",style:{color:"var(--status-completed)"},children:l.jsx("path",{d:"M4 3l9 5-9 5z"})}),"执行验证"]}),l.jsxs("div",{className:"wrp-workflow-name",children:[t.name," ",l.jsxs("span",{className:"wrp-version",children:["v",t.version??1]})]}),l.jsx("button",{className:"wrp-close",onClick:()=>a(!1),children:"✕"})]}),l.jsxs("div",{className:"wrp-content",children:[l.jsxs("div",{className:"wrp-section-label",children:["工作流输入参数",C&&l.jsxs("div",{className:"wrp-mode-toggle",children:[l.jsx("button",{className:c==="form"?"active":"",onClick:c==="json"?N:void 0,children:"表单模式"}),l.jsx("button",{className:c==="json"?"active":"",onClick:c==="form"?j:void 0,children:"JSON 编辑器"})]})]}),!C&&c==="form"&&l.jsxs("p",{className:"wrp-hint",children:["该工作流未声明输入参数。你可以在 ",l.jsx("strong",{children:"工作流设置 → 参数配置"})," 中添加,也可以直接在 JSON 编辑器中手动填写。"]}),c==="form"?l.jsxs("div",{className:"wrp-form",children:[w.map(S=>l.jsxs("div",{className:"wrp-field",children:[l.jsxs("label",{className:"wrp-field-label",children:[S.name,S.required&&l.jsx("span",{className:"wrp-required",children:"*"}),S.type&&l.jsx("span",{className:"wrp-type",children:S.type})]}),S.description&&l.jsx("p",{className:"wrp-field-desc",children:S.description}),S.type==="object"||S.type==="array"?l.jsx("textarea",{className:"wrp-input",rows:3,placeholder:S.example?JSON.stringify(S.example,null,2):"{}",value:f[S.name]??"",onChange:D=>p(I=>({...I,[S.name]:D.target.value}))}):S.type==="boolean"?l.jsxs("select",{className:"wrp-input",value:f[S.name]??(S.defaultValue!==void 0?String(S.defaultValue):""),onChange:D=>p(I=>({...I,[S.name]:D.target.value})),children:[l.jsx("option",{value:"",children:"请选择"}),l.jsx("option",{value:"true",children:"true"}),l.jsx("option",{value:"false",children:"false"})]}):l.jsx("input",{className:"wrp-input",type:S.type==="number"?"number":"text",placeholder:S.example!==void 0?String(S.example):S.defaultValue!==void 0?String(S.defaultValue):"",value:f[S.name]??"",onChange:D=>p(I=>({...I,[S.name]:D.target.value}))})]},S.name)),!C&&l.jsx("button",{className:"wrp-switch-json",onClick:j,children:"切换为 JSON 编辑器手动填写"})]}):l.jsxs("div",{className:"wrp-json-editor",children:[l.jsx("textarea",{className:"wrp-input wrp-json",rows:12,value:h,onChange:S=>{g(S.target.value),v("")},spellCheck:!1,placeholder:'{\\n "key": "value"\\n}'}),m&&l.jsx("p",{className:"wrp-error",children:m})]}),b&&l.jsx("p",{className:"wrp-error wrp-submit-error",children:b})]}),l.jsxs("div",{className:"wrp-footer",children:[l.jsx("button",{className:"wrp-btn wrp-btn-cancel",onClick:()=>a(!1),children:"取消"}),e?l.jsx("button",{className:"wrp-btn wrp-btn-execute",onClick:T,disabled:y,children:y?l.jsxs(l.Fragment,{children:[l.jsx("span",{className:"wrp-spinner"}),"执行中..."]}):l.jsxs(l.Fragment,{children:[l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("path",{d:"M4 3l9 5-9 5z"})}),"发起执行"]})}):l.jsx("span",{className:"wrp-hint-inline",children:"未配置 onTriggerExecution 回调"})]})]})})},qb=[{pattern:/NullPointerException|null.*inputData|inputData.*null/i,category:"parameter",title:"参数引用为空",explanation:"某个 inputParameters 字段引用的上游任务输出为 null。请检查 JSONPath 表达式,确认前序任务确实返回了对应字段。",suggestEditParam:"inputParameters"},{pattern:/PathNotFoundException|No results for path|path not found/i,category:"parameter",title:"JSONPath 路径不存在",explanation:"参数中的 JSONPath 表达式(如 ${task.output.field})在实际执行数据中找不到对应路径。请核查前序任务的实际输出结构。",suggestEditParam:"inputParameters"},{pattern:/ClassCastException|cannot cast|type mismatch/i,category:"parameter",title:"参数类型不匹配",explanation:"输入参数的数据类型与任务期望不符(如将字符串传给了数字类型参数)。请检查参数值的类型。",suggestEditParam:"inputParameters"},{pattern:/Connection refused|connect.*timeout|SocketException/i,category:"network",title:"网络连接失败",explanation:"无法连接到目标服务器。请检查 HTTP 任务的 uri 是否正确,以及目标服务是否可访问。",suggestEditParam:"uri"},{pattern:/HTTP.*4\d\d|status.*4\d\d|4\d\d.*status/i,category:"network",title:"HTTP 客户端错误",explanation:"HTTP 请求返回 4xx 错误,通常由请求参数、认证或权限问题引起。请检查 uri、headers、body 配置。",suggestEditParam:"inputParameters"},{pattern:/HTTP.*5\d\d|status.*5\d\d|5\d\d.*status/i,category:"network",title:"HTTP 服务端错误",explanation:"目标服务返回 5xx 错误,服务端发生异常。可尝试重试,或检查传入的请求体是否符合服务端期望。",suggestEditParam:"inputParameters"},{pattern:/Unauthorized|401|authentication|auth.*failed/i,category:"auth",title:"认证失败",explanation:"请求被拒绝,认证信息无效或缺失。请检查 headers 中的 Authorization 或 token 参数配置。",suggestEditParam:"inputParameters"},{pattern:/timeout|timed.?out|TIMED_OUT/i,category:"timeout",title:"任务超时",explanation:"任务执行时间超过配置的超时阈值。可考虑增大 timeoutSeconds,或优化被调用服务的响应速度。",suggestEditParam:"timeoutSeconds"},{pattern:/loopCondition|loop.*condition|condition.*false/i,category:"logic",title:"循环条件配置问题",explanation:"DO_WHILE 的 loopCondition 表达式可能无法正常求值。请检查条件表达式引用的变量是否正确。",suggestEditParam:"loopCondition"},{pattern:/expression.*error|script.*error|evaluator.*failed/i,category:"logic",title:"脚本表达式错误",explanation:"INLINE/LAMBDA 任务的脚本表达式执行时出错。请检查 expression 或 scriptExpression 的语法和逻辑。",suggestEditParam:"inputParameters"}];function Db(e,n){const r=n[e];if(!r)return[];const t=r.reasonForIncompletion||"";if(!t)return[];const s=[];for(const a of qb)a.pattern.test(t)&&s.push({category:a.category,title:a.title,explanation:a.explanation,suggestEditParam:a.suggestEditParam});return s.length===0&&t.length>0&&s.push({category:"logic",title:"执行异常",explanation:`任务执行失败,原因:${t.slice(0,200)}${t.length>200?"...":""}`}),s}function Mb(e,n){const r=Object.values(e).map(h=>{const g=h.startTime&&h.endTime?h.endTime-h.startTime:void 0,m=Math.max(0,(h.attempts?.length??1)-1);return{taskRef:h.taskReferenceName,status:h.status,startTime:h.startTime,endTime:h.endTime,durationMs:g,retryCount:m,reasonForIncompletion:h.reasonForIncompletion,diagnostics:Db(h.taskReferenceName,e)}}).sort((h,g)=>(h.startTime??0)-(g.startTime??0)),t=["FAILED","FAILED_WITH_TERMINAL_ERROR","TIMED_OUT"],s=r.filter(h=>h.status==="COMPLETED"||h.status==="COMPLETED_WITH_ERRORS").length,a=r.filter(h=>t.includes(h.status)).length,o=r.filter(h=>h.status==="SKIPPED").length,i=r.flatMap(h=>[h.startTime,h.endTime]).filter(h=>!!h),u=i.length?Math.min(...i):0,d=(i.length?Math.max(...i):0)-u,f=n?.status,p=f==="FAILED"||f==="TIMED_OUT"||f==="TERMINATED"||a>0;return{totalTasks:r.length,completedTasks:s,failedTasks:a,skippedTasks:o,totalDurationMs:d,steps:r,hasFailed:p}}function sg(e){return e===void 0||e<0?"-":e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`}function Wb(e){return{parameter:"⚙️",timeout:"⏱️",auth:"🔐",network:"🌐",logic:"🔧"}[e]??"⚠️"}function Bb(e){return{parameter:"#f59e0b",timeout:"#8b5cf6",auth:"#ef4444",network:"#3b82f6",logic:"#10b981"}[e]??"#6b7280"}const og={COMPLETED:"完成",COMPLETED_WITH_ERRORS:"完成(含错误)",FAILED:"失败",FAILED_WITH_TERMINAL_ERROR:"终态失败",IN_PROGRESS:"执行中",SCHEDULED:"等待中",TIMED_OUT:"超时",SKIPPED:"跳过",CANCELED:"已取消"},ig={COMPLETED:"var(--status-completed)",COMPLETED_WITH_ERRORS:"var(--status-completed)",FAILED:"var(--status-failed)",FAILED_WITH_TERMINAL_ERROR:"var(--status-failed)",IN_PROGRESS:"var(--status-running)",SCHEDULED:"var(--status-scheduled)",TIMED_OUT:"var(--status-failed)",SKIPPED:"var(--status-skipped, #6b7280)",CANCELED:"var(--status-failed)"},Fb=()=>{const{executionData:e,workflowInstance:n,showAnalysisPanel:r,setShowAnalysisPanel:t,switchToEditAndFocusParam:s,selectTaskAction:a,taskMap:o}=oe(),i=O.useMemo(()=>e?Mb(e,n??null):null,[e,n]);if(!r||!i)return null;const{totalTasks:u,completedTasks:c,failedTasks:d,skippedTasks:f,totalDurationMs:p,steps:h}=i,g=u>0?Math.round(c/u*100):0,m=n?.status,v=m?ig[m]??"var(--text-secondary)":"var(--text-secondary)";return l.jsxs("div",{className:"esp-panel glass-panel",children:[l.jsxs("div",{className:"esp-header",children:[l.jsxs("div",{className:"esp-title",children:[l.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),l.jsx("path",{d:"M5 8h6M5 5h3M5 11h4"})]}),"执行分析"]}),m&&l.jsx("span",{className:"esp-wf-status",style:{color:v},children:og[m]??m}),l.jsx("button",{className:"esp-close",onClick:()=>t(!1),children:"✕"})]}),l.jsxs("div",{className:"esp-content",children:[l.jsxs("div",{className:"esp-overview",children:[l.jsxs("div",{className:"esp-card",children:[l.jsx("span",{className:"esp-card-value",children:u}),l.jsx("span",{className:"esp-card-label",children:"总任务数"})]}),l.jsxs("div",{className:"esp-card esp-card-success",children:[l.jsx("span",{className:"esp-card-value",style:{color:"var(--status-completed)"},children:c}),l.jsx("span",{className:"esp-card-label",children:"已完成"})]}),l.jsxs("div",{className:"esp-card esp-card-failed",children:[l.jsx("span",{className:"esp-card-value",style:{color:d>0?"var(--status-failed)":"var(--text-secondary)"},children:d}),l.jsx("span",{className:"esp-card-label",children:"失败"})]}),l.jsxs("div",{className:"esp-card",children:[l.jsx("span",{className:"esp-card-value",children:sg(p)}),l.jsx("span",{className:"esp-card-label",children:"总耗时"})]})]}),l.jsx("div",{className:"esp-progress-bar",children:l.jsx("div",{className:"esp-progress-fill",style:{width:`${g}%`,background:d>0?"var(--status-failed)":"var(--status-completed)"},title:`成功率 ${g}%`})}),l.jsxs("div",{className:"esp-progress-label",children:[g,"% 成功率",f>0?`,${f} 个任务已跳过`:""]}),h.filter(y=>y.diagnostics.length>0).map(y=>l.jsxs("div",{className:"esp-diagnostic-card",children:[l.jsxs("div",{className:"esp-diag-task-ref",children:[l.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",style:{color:"var(--status-failed)",flexShrink:0},children:l.jsx("path",{d:"M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 4a.75.75 0 011.5 0v3.5a.75.75 0 01-1.5 0V5zm.75 7a1 1 0 110-2 1 1 0 010 2z"})}),y.taskRef]}),y.diagnostics.map((x,b)=>l.jsxs("div",{className:"esp-diag-item",style:{borderLeftColor:Bb(x.category)},children:[l.jsxs("div",{className:"esp-diag-title",children:[l.jsx("span",{children:Wb(x.category)}),x.title]}),l.jsx("p",{className:"esp-diag-explanation",children:x.explanation}),l.jsxs("button",{className:"esp-fix-btn",onClick:()=>s(y.taskRef,x.suggestEditParam),children:["去修复",l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:l.jsx("path",{d:"M5 8h6M9 5l3 3-3 3"})})]})]},b))]},y.taskRef)),l.jsx("div",{className:"esp-section-label",children:"步骤执行时序"}),l.jsxs("div",{className:"esp-steps-table",children:[l.jsxs("div",{className:"esp-steps-header",children:[l.jsx("span",{children:"#"}),l.jsx("span",{children:"任务引用名"}),l.jsx("span",{children:"状态"}),l.jsx("span",{children:"耗时"}),l.jsx("span",{children:"重试"})]}),h.map((y,x)=>{const b=ig[y.status]??"var(--text-secondary)",k=o[y.taskRef];return l.jsxs("button",{className:"esp-step-row",onClick:()=>k&&a(k,!0),title:y.reasonForIncompletion||y.taskRef,children:[l.jsx("span",{className:"esp-step-idx",children:x+1}),l.jsx("span",{className:"esp-step-ref",children:y.taskRef}),l.jsxs("span",{className:"esp-step-status",style:{color:b},children:[l.jsx("span",{className:"esp-status-dot",style:{background:b}}),og[y.status]??y.status]}),l.jsx("span",{className:"esp-step-duration",children:sg(y.durationMs)}),l.jsx("span",{className:"esp-step-retry",style:{color:y.retryCount>0?"var(--status-failed)":"var(--text-secondary)"},children:y.retryCount>0?`${y.retryCount}次`:"-"})]},y.taskRef)})]})]})]})},lg=O.forwardRef(({workflowDef:e,readOnly:n=!1,theme:r="dark",themeColor:t="blue",layoutDirection:s="LR",searchQuery:a="",workflowExecution:o,onRequestImport:i,executionActions:u,aiConfig:c,viewMode:d="developer",onSave:f,onWorkflowChange:p,height:h="100%",onTriggerExecution:g,onPollExecution:m,executionPollInterval:v=3e3},y)=>{const{setWorkflow:x,setTheme:b,setThemeColor:k,setLayoutDirection:w,setNodesLocked:j,selectedTask:N,setSelectedTask:L,edgeType:T,importExecutionJSON:C,setMode:S,setViewMode:D,isDetailPanelOpen:I,setIsDetailPanelOpen:P,selectTaskAction:F,workflowDef:W,isSimRunning:K,startSimulation:V,stopSimulation:te,mode:re,setShowRunPanel:q,showAnalysisPanel:G,setShowAnalysisPanel:ie,executionData:R}=oe(),[M,_]=O.useState(!1),B=O.useCallback(()=>{if(!W)return;const U=new Blob([JSON.stringify(W,null,2)],{type:"application/json"}),le=URL.createObjectURL(U),Q=document.createElement("a");Q.href=le,Q.download=`${W.name||"workflow"}.json`,Q.click(),URL.revokeObjectURL(le)},[W]),$=O.useCallback(()=>{W&&navigator.clipboard.writeText(JSON.stringify(W,null,2))},[W]);O.useEffect(()=>{b(r),k(t),w(s),j(n||!!o)},[r,t,s,n,o,b,k,w,j]),O.useEffect(()=>{D(o?"developer":d)},[d,o,D]),O.useEffect(()=>{e&&(x(e,s),oe.temporal.getState().clear())},[e,x,s]),O.useEffect(()=>{o?C(o):S(n?"view":"edit")},[o,C,S,n]),O.useImperativeHandle(y,()=>({getWorkflowDef:()=>oe.getState().workflowDef,getValidationResults:()=>oe.getState().validationResults,save:()=>{const U=oe.getState().workflowDef;U&&f&&f(U)},createBlankWorkflow:U=>{oe.getState().createBlankWorkflow(U),oe.temporal.getState().clear()}}),[f]),O.useEffect(()=>{if(!p)return;let U=!0,le=oe.getState().workflowDef;return oe.subscribe(ee=>{const he=ee.workflowDef;if(he!==le){if(le=he,U){U=!1;return}he&&p(he)}})},[p]);const X=U=>{o?L(U):F(U,!0)};return l.jsxs("div",{className:`workflow-ide ${r==="light"?"light-theme":""}`,"data-mode":r,"data-brand":t,style:{width:"100%",height:h,display:"flex",flexDirection:"column",position:"relative",overflow:"hidden"},children:[l.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderBottom:"1px solid var(--border)",background:"var(--bg-primary)",flexShrink:0,flexWrap:"wrap"},children:[l.jsx("div",{style:{flex:1}}),re==="edit"&&W&&l.jsxs("button",{onClick:()=>q(!0),style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--color-accent) 15%, transparent)",color:"var(--color-accent)",border:"1px solid color-mix(in srgb, var(--color-accent) 40%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:600,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"填写工作流入参并触发真实执行",children:[l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("path",{d:"M4 3l9 5-9 5z"})}),"执行验证"]}),re==="run"&&R&&l.jsxs("button",{onClick:()=>ie(!G),style:{height:28,padding:"0 10px",background:G?"color-mix(in srgb, var(--color-accent) 20%, transparent)":"transparent",color:G?"var(--color-accent)":"var(--text-secondary)",border:`1px solid ${G?"color-mix(in srgb, var(--color-accent) 40%, transparent)":"var(--border-strong)"}`,borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"查看执行概览与异常分析",children:[l.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[l.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),l.jsx("path",{d:"M5 8h6M5 5h3M5 11h4"})]}),"分析"]}),re!=="run"&&W&&(K?l.jsxs("button",{onClick:te,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-failed) 15%, transparent)",color:"var(--status-failed)",border:"1px solid color-mix(in srgb, var(--status-failed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"停止模拟",children:[l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1"})}),"停止"]}):l.jsxs("button",{onClick:V,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-completed) 15%, transparent)",color:"var(--status-completed)",border:"1px solid color-mix(in srgb, var(--status-completed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"模拟执行工作流",children:[l.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:l.jsx("path",{d:"M4 3l9 5-9 5z"})}),"模拟运行"]})),W&&l.jsxs(l.Fragment,{children:[l.jsxs("button",{onClick:B,style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-secondary)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"导出工作流 JSON 文件",children:[l.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:l.jsx("path",{d:"M3 10v2.5a.5.5 0 0 0 .5.5h9a.5.5 0 0 0 .5-.5V10M5 7l3 3 3-3M8 2v8",strokeLinecap:"round",strokeLinejoin:"round"})}),"导出 JSON"]}),l.jsxs("button",{onClick:$,style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-secondary)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"复制 Conductor DSL 到剪贴板",children:[l.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[l.jsx("rect",{x:"4",y:"4",width:"9",height:"10",rx:"1"}),l.jsx("path",{d:"M2 10V3a1 1 0 0 1 1-1h7",strokeLinecap:"round"})]}),"复制 DSL"]})]})]}),l.jsx("div",{className:"workflow-viewer",style:{flex:1,position:"relative",overflow:"hidden"},children:l.jsx(A.ReactFlowProvider,{children:l.jsx(ub,{onNodeClick:X,edgeType:T,theme:r,nodesLocked:n||!!o,searchQuery:a,onSave:f,onRequestImport:i,executionActions:u})})}),l.jsx(_b,{task:N,isOpen:I,onClose:()=>P(!1),theme:r,aiConfig:c}),l.jsx(Fh,{isOpen:M,onClose:()=>_(!1),theme:r,onTaskSelect:U=>{F(U,!0)}}),o&&l.jsx(Tb,{executionActions:u}),l.jsx(Pb,{aiConfig:c}),l.jsx(Lb,{onTriggerExecution:g,onPollExecution:m,executionPollInterval:v}),re==="run"&&l.jsx(Fb,{})]})});lg.displayName="WorkflowIDE",De.WorkflowIDE=lg,De.parseWorkflowInputParams=Zr,Object.defineProperty(De,Symbol.toStringTag,{value:"Module"})}));
|