@yiyi_zhang/reactflow-ui 0.1.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.
Files changed (53) hide show
  1. package/README.md +107 -0
  2. package/dist/WorkflowIDE.d.ts +108 -0
  3. package/dist/components/AICopilot/AIChatPanel.d.ts +8 -0
  4. package/dist/components/AICopilot/ParameterSuggester.d.ts +16 -0
  5. package/dist/components/ConfirmDialog.d.ts +7 -0
  6. package/dist/components/Controls/ActionBar.d.ts +10 -0
  7. package/dist/components/Controls/ControlButton.d.ts +13 -0
  8. package/dist/components/Controls/ControlHub.d.ts +3 -0
  9. package/dist/components/Editor/NodeSelector.d.ts +8 -0
  10. package/dist/components/EmptyStatePanel.d.ts +7 -0
  11. package/dist/components/ExecutionStatusBar.d.ts +5 -0
  12. package/dist/components/ExecutionTaskPanel.d.ts +5 -0
  13. package/dist/components/HealthCheckPanel.d.ts +12 -0
  14. package/dist/components/TaskDetailPanel.d.ts +11 -0
  15. package/dist/components/Toast.d.ts +11 -0
  16. package/dist/components/WorkflowDesigner.d.ts +15 -0
  17. package/dist/components/WorkflowSettingsPanel.d.ts +10 -0
  18. package/dist/components/edges/AddableEdge.d.ts +8 -0
  19. package/dist/components/nodes/DecisionNode.d.ts +5 -0
  20. package/dist/components/nodes/ExecutionStatusBadge.d.ts +7 -0
  21. package/dist/components/nodes/ForkJoinNode.d.ts +16 -0
  22. package/dist/components/nodes/LoopNode.d.ts +5 -0
  23. package/dist/components/nodes/NodeLayout.d.ts +16 -0
  24. package/dist/components/nodes/NodeWrapper.d.ts +15 -0
  25. package/dist/components/nodes/SubWorkflowNode.d.ts +5 -0
  26. package/dist/components/nodes/TaskNode.d.ts +5 -0
  27. package/dist/config/taskTypes.d.ts +14 -0
  28. package/dist/hooks/useConfirm.d.ts +14 -0
  29. package/dist/hooks/useNodeExecution.d.ts +8 -0
  30. package/dist/hooks/useNodeLayout.d.ts +10 -0
  31. package/dist/hooks/useShortcuts.d.ts +11 -0
  32. package/dist/hooks/useToast.d.ts +9 -0
  33. package/dist/index.d.ts +5 -0
  34. package/dist/layout/autoLayout.d.ts +22 -0
  35. package/dist/parser/conductorGenerator.d.ts +28 -0
  36. package/dist/parser/conductorParser.d.ts +24 -0
  37. package/dist/reactflow-ui.css +1 -0
  38. package/dist/reactflow-ui.es.js +11035 -0
  39. package/dist/reactflow-ui.umd.js +229 -0
  40. package/dist/sample-workflows/complex-workflow.json +210 -0
  41. package/dist/sample-workflows/decision-workflow.json +118 -0
  42. package/dist/sample-workflows/fork-join-workflow.json +112 -0
  43. package/dist/sample-workflows/sample-execution.json +327 -0
  44. package/dist/sample-workflows/simple-workflow.json +42 -0
  45. package/dist/services/aiService.d.ts +24 -0
  46. package/dist/services/promptTemplates.d.ts +6 -0
  47. package/dist/store/workflowStore.d.ts +30 -0
  48. package/dist/types/conductor.d.ts +170 -0
  49. package/dist/types/workflow.d.ts +165 -0
  50. package/dist/utils/validationRules.d.ts +85 -0
  51. package/dist/utils/validator.d.ts +6 -0
  52. package/dist/vite.svg +1 -0
  53. package/package.json +71 -0
@@ -0,0 +1,229 @@
1
+ (function(Se,D){typeof exports=="object"&&typeof module<"u"?D(exports,require("react"),require("reactflow")):typeof define=="function"&&define.amd?define(["exports","react","reactflow"],D):(Se=typeof globalThis<"u"?globalThis:Se||self,D(Se.ReactflowUI={},Se.React,Se.ReactFlow))})(this,(function(Se,D,q){"use strict";var sr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ch(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var ur={exports:{}},Ke={};var ks;function Nh(){if(ks)return Ke;ks=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(n,a,i){var o=null;if(i!==void 0&&(o=""+i),a.key!==void 0&&(o=""+a.key),"key"in a){i={};for(var s in a)s!=="key"&&(i[s]=a[s])}else i=a;return a=i.ref,{$$typeof:e,type:n,key:o,ref:a!==void 0?a:null,props:i}}return Ke.Fragment=t,Ke.jsx=r,Ke.jsxs=r,Ke}var Je={};var Ss;function Rh(){return Ss||(Ss=1,process.env.NODE_ENV!=="production"&&(function(){function e(j){if(j==null)return null;if(typeof j=="function")return j.$$typeof===A?null:j.displayName||j.name||null;if(typeof j=="string")return j;switch(j){case v:return"Fragment";case b:return"Profiler";case x:return"StrictMode";case w:return"Suspense";case E:return"SuspenseList";case R:return"Activity"}if(typeof j=="object")switch(typeof j.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),j.$$typeof){case g:return"Portal";case y:return j.displayName||"Context";case _:return(j._context.displayName||"Context")+".Consumer";case S:var F=j.render;return j=j.displayName,j||(j=F.displayName||F.name||"",j=j!==""?"ForwardRef("+j+")":"ForwardRef"),j;case T:return F=j.displayName||null,F!==null?F:e(j.type)||"Memo";case C:F=j._payload,j=j._init;try{return e(j(F))}catch{}}return null}function t(j){return""+j}function r(j){try{t(j);var F=!1}catch{F=!0}if(F){F=console;var G=F.error,k=typeof Symbol=="function"&&Symbol.toStringTag&&j[Symbol.toStringTag]||j.constructor.name||"Object";return G.call(F,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",k),t(j)}}function n(j){if(j===v)return"<>";if(typeof j=="object"&&j!==null&&j.$$typeof===C)return"<...>";try{var F=e(j);return F?"<"+F+">":"<...>"}catch{return"<...>"}}function a(){var j=B.A;return j===null?null:j.getOwner()}function i(){return Error("react-stack-top-frame")}function o(j){if(N.call(j,"key")){var F=Object.getOwnPropertyDescriptor(j,"key").get;if(F&&F.isReactWarning)return!1}return j.key!==void 0}function s(j,F){function G(){$||($=!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)",F))}G.isReactWarning=!0,Object.defineProperty(j,"key",{get:G,configurable:!0})}function c(){var j=e(this.type);return U[j]||(U[j]=!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.")),j=this.props.ref,j!==void 0?j:null}function u(j,F,G,k,I,P){var O=G.ref;return j={$$typeof:m,type:j,key:F,props:G,_owner:k},(O!==void 0?O:null)!==null?Object.defineProperty(j,"ref",{enumerable:!1,get:c}):Object.defineProperty(j,"ref",{enumerable:!1,value:null}),j._store={},Object.defineProperty(j._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(j,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(j,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:I}),Object.defineProperty(j,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:P}),Object.freeze&&(Object.freeze(j.props),Object.freeze(j)),j}function d(j,F,G,k,I,P){var O=F.children;if(O!==void 0)if(k)if(M(O)){for(k=0;k<O.length;k++)l(O[k]);Object.freeze&&Object.freeze(O)}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 l(O);if(N.call(F,"key")){O=e(j);var H=Object.keys(F).filter(function(Z){return Z!=="key"});k=0<H.length?"{key: someKey, "+H.join(": ..., ")+": ...}":"{key: someKey}",K[O+k]||(H=0<H.length?"{"+H.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
2
+ let props = %s;
3
+ <%s {...props} />
4
+ React keys must be passed directly to JSX without using spread:
5
+ let props = %s;
6
+ <%s key={someKey} {...props} />`,k,O,H,O),K[O+k]=!0)}if(O=null,G!==void 0&&(r(G),O=""+G),o(F)&&(r(F.key),O=""+F.key),"key"in F){G={};for(var J in F)J!=="key"&&(G[J]=F[J])}else G=F;return O&&s(G,typeof j=="function"?j.displayName||j.name||"Unknown":j),u(j,O,G,a(),I,P)}function l(j){p(j)?j._store&&(j._store.validated=1):typeof j=="object"&&j!==null&&j.$$typeof===C&&(j._payload.status==="fulfilled"?p(j._payload.value)&&j._payload.value._store&&(j._payload.value._store.validated=1):j._store&&(j._store.validated=1))}function p(j){return typeof j=="object"&&j!==null&&j.$$typeof===m}var h=D,m=Symbol.for("react.transitional.element"),g=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),x=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),_=Symbol.for("react.consumer"),y=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),R=Symbol.for("react.activity"),A=Symbol.for("react.client.reference"),B=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,N=Object.prototype.hasOwnProperty,M=Array.isArray,L=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(j){return j()}};var $,U={},W=h.react_stack_bottom_frame.bind(h,i)(),z=L(n(i)),K={};Je.Fragment=v,Je.jsx=function(j,F,G){var k=1e4>B.recentlyCreatedOwnerStacks++;return d(j,F,G,!1,k?Error("react-stack-top-frame"):W,k?L(n(j)):z)},Je.jsxs=function(j,F,G){var k=1e4>B.recentlyCreatedOwnerStacks++;return d(j,F,G,!0,k?Error("react-stack-top-frame"):W,k?L(n(j)):z)}})()),Je}var ws;function Ih(){return ws||(ws=1,process.env.NODE_ENV==="production"?ur.exports=Nh():ur.exports=Rh()),ur.exports}var f=Ih();const Es=e=>{let t;const r=new Set,n=(u,d)=>{const l=typeof u=="function"?u(t):u;if(!Object.is(l,t)){const p=t;t=d??(typeof l!="object"||l===null)?l:Object.assign({},t,l),r.forEach(h=>h(t,p))}},a=()=>t,s={setState:n,getState:a,getInitialState:()=>c,subscribe:u=>(r.add(u),()=>r.delete(u))},c=t=e(n,a,s);return s},Ts=(e=>e?Es(e):Es),jh=e=>e;function jr(e,t=jh){const r=D.useSyncExternalStore(e.subscribe,D.useCallback(()=>t(e.getState()),[e,t]),D.useCallback(()=>t(e.getInitialState()),[e,t]));return D.useDebugValue(r),r}const Oh=e=>{const t=Ts(e),r=n=>jr(t,n);return Object.assign(r,t),r},qh=(e=>Oh);function Cs(e,t){let r;try{r=e()}catch{return}return{getItem:a=>{var i;const o=c=>c===null?null:JSON.parse(c,void 0),s=(i=r.getItem(a))!=null?i:null;return s instanceof Promise?s.then(o):o(s)},setItem:(a,i)=>r.setItem(a,JSON.stringify(i,void 0)),removeItem:a=>r.removeItem(a)}}const Or=e=>t=>{try{const r=e(t);return r instanceof Promise?r:{then(n){return Or(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return Or(n)(r)}}}},Ph=(e,t)=>(r,n,a)=>{let i={storage:Cs(()=>localStorage),partialize:g=>g,version:0,merge:(g,v)=>({...v,...g}),...t},o=!1;const s=new Set,c=new Set;let u=i.storage;if(!u)return e((...g)=>{console.warn(`[zustand persist middleware] Unable to update item '${i.name}', the given storage is currently unavailable.`),r(...g)},n,a);const d=()=>{const g=i.partialize({...n()});return u.setItem(i.name,{state:g,version:i.version})},l=a.setState;a.setState=(g,v)=>(l(g,v),d());const p=e((...g)=>(r(...g),d()),n,a);a.getInitialState=()=>p;let h;const m=()=>{var g,v;if(!u)return;o=!1,s.forEach(b=>{var _;return b((_=n())!=null?_:p)});const x=((v=i.onRehydrateStorage)==null?void 0:v.call(i,(g=n())!=null?g:p))||void 0;return Or(u.getItem.bind(u))(i.name).then(b=>{if(b)if(typeof b.version=="number"&&b.version!==i.version){if(i.migrate){const _=i.migrate(b.state,b.version);return _ instanceof Promise?_.then(y=>[!0,y]):[!0,_]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,b.state];return[!1,void 0]}).then(b=>{var _;const[y,S]=b;if(h=i.merge(S,(_=n())!=null?_:p),r(h,!0),y)return d()}).then(()=>{x?.(h,void 0),h=n(),o=!0,c.forEach(b=>b(h))}).catch(b=>{x?.(void 0,b)})};return a.persist={setOptions:g=>{i={...i,...g},g.storage&&(u=g.storage)},clearStorage:()=>{u?.removeItem(i.name)},getOptions:()=>i,rehydrate:()=>m(),hasHydrated:()=>o,onHydrate:g=>(s.add(g),()=>{s.delete(g)}),onFinishHydration:g=>(c.add(g),()=>{c.delete(g)})},i.skipHydration||m(),h||p};var Ns=(e,t,r)=>(a,i)=>({pastStates:r?.pastStates||[],futureStates:r?.futureStates||[],undo:(o=1)=>{if(i().pastStates.length){const s=r?.partialize?.(t())||t(),c=i().pastStates.splice(-o,o),u=c.shift();e(u),a({pastStates:i().pastStates,futureStates:i().futureStates.concat(r?.diff?.(s,u)||s,c.reverse())})}},redo:(o=1)=>{if(i().futureStates.length){const s=r?.partialize?.(t())||t(),c=i().futureStates.splice(-o,o),u=c.shift();e(u),a({pastStates:i().pastStates.concat(r?.diff?.(s,u)||s,c.reverse()),futureStates:i().futureStates})}},clear:()=>a({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>a({isTracking:!1}),resume:()=>a({isTracking:!0}),setOnSave:o=>a({_onSave:o}),_onSave:r?.onSave,_handleSet:(o,s,c,u)=>{r?.limit&&i().pastStates.length>=r?.limit&&i().pastStates.shift(),i()._onSave?.(o,c),a({pastStates:i().pastStates.concat(u||o),futureStates:[]})}}),Ah=(e,t)=>(n,a,i)=>{i.temporal=Ts(t?.wrapTemporal?.(Ns(n,a,t))||Ns(n,a,t));const o=t?.handleSet?.(i.temporal.getState()._handleSet)||i.temporal.getState()._handleSet,s=u=>{if(!i.temporal.getState().isTracking)return;const d=t?.partialize?.(a())||a(),l=t?.diff?.(u,d);l===null||t?.equality?.(u,d)||o(u,void 0,d,l)},c=i.setState;return i.setState=(...u)=>{const d=t?.partialize?.(a())||a();c(...u),s(d)},e((...u)=>{const d=t?.partialize?.(a())||a();n(...u),s(d)},a,i)};function Lh(e,t="TB",r){const n=r?.hideEmptyBranches??!1;if(!e||!e.tasks)return{nodes:[],edges:[],taskMap:{}};const a=[],i=[],o={};let s=0;const c={id:"start",type:"input",data:{label:"开始",layoutDirection:t,taskReferenceName:"start",taskType:"START"},position:{x:0,y:0},sourcePosition:t==="LR"?q.Position.Right:q.Position.Bottom,style:{background:"#4ade80",color:"#fff",border:"2px solid #22c55e",borderRadius:"50%",width:60,height:60,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"bold"}};a.push(c);const u=e.tasks;for(let p=0;p<u.length;p++){const h=u[p],m=Rs(h,s,o,t,u,n);if(a.push(...m.nodes),i.push(...m.edges),s=m.nextId,p===0)i.push({id:`e-start-${h.taskReferenceName}`,source:"start",target:h.taskReferenceName,animated:!0});else{const g=u[p-1];Is(g,h,i)}Object.assign(o,m.taskMap)}const d=u[u.length-1],l={id:"end",type:"output",data:{label:"结束",layoutDirection:t,taskReferenceName:"end",taskType:"END"},position:{x:0,y:0},targetPosition:t==="LR"?q.Position.Left:q.Position.Top,style:{background:"#f87171",color:"#fff",border:"2px solid #ef4444",borderRadius:"50%",width:60,height:60,display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",fontWeight:"bold"}};if(a.push(l),d){const p=Pr(d);i.push({id:`e-${p}-end`,source:p,target:"end",animated:!0})}else i.push({id:"e-start-end",source:"start",target:"end",type:"addableEdge",animated:!0});return{nodes:a,edges:i,taskMap:o}}function Rs(e,t,r,n="TB",a=[],i=!1){switch(e.type||"SIMPLE"){case"DECISION":case"SWITCH":return Mh(e,t,r,n,i);case"FORK_JOIN":case"FORK_JOIN_DYNAMIC":return Bh(e,t,r,n);case"JOIN":return $h(e,t,r,n,a,i);case"DO_WHILE":return Wh(e,t,r,n);case"SUB_WORKFLOW":return Fh(e,t,r,n);default:return Dh(e,t,r,n)}}function Dh(e,t,r,n="TB"){const a={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"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top},i={[e.taskReferenceName]:e};return{nodes:[a],edges:[],taskMap:i,nextId:t+1}}function Mh(e,t,r,n="TB",a=!1){const i=[],o=[];let s=t;const c={},u={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"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top};i.push(u),c[e.taskReferenceName]=e;const d=`${e.taskReferenceName}_join`,l={id:d,type:"default",data:{label:"合并",layoutDirection:n,taskReferenceName:d,taskType:"DECISION_JOIN"},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top,style:{background:"#a78bfa",color:"#fff",border:"2px solid #8b5cf6",borderRadius:"8px",padding:"10px",fontSize:"12px"}};i.push(l);const p=e.decisionCases||{},h=e.defaultCase||[],m=Object.keys(p),g=(v,x)=>{if(n==="TB"){if(v===0&&x>1)return"left";if(v===1&&x>2)return"right"}else{if(v===0&&x>1)return"top";if(v===1&&x>2)return"bottom"}return null};if(m.forEach((v,x)=>{const b=p[v],_=g(x,m.length+1);if(b&&b.length>0){const y=qr(b,s,{...r,...c},n);i.push(...y.nodes),o.push(...y.edges),Object.assign(c,y.taskMap),s=y.nextId;const S=b[0].taskReferenceName;o.push({id:`e-${e.taskReferenceName}-${S}`,source:e.taskReferenceName,sourceHandle:_||void 0,target:S,label:v,animated:!0,data:{branchCase:v},style:{stroke:"#3b82f6"}});const w=b[b.length-1].taskReferenceName;o.push({id:`e-${w}-${d}`,source:w,target:d,animated:!0})}else if(!a){const y=`${e.taskReferenceName}_empty_${v}`;i.push({id:y,type:"default",data:{label:`${v} (空)`,layoutDirection:n,taskReferenceName:y,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.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}-${y}`,source:e.taskReferenceName,sourceHandle:_||void 0,target:y,label:v,animated:!0,data:{branchCase:v},style:{stroke:"#3b82f6",strokeDasharray:"5,5"}}),o.push({id:`e-${y}-${d}`,source:y,target:d,animated:!0,style:{strokeDasharray:"5,5"}})}}),h&&h.length>0){const v=qr(h,s,{...r,...c},n);i.push(...v.nodes),o.push(...v.edges),Object.assign(c,v.taskMap),s=v.nextId;const x=h[0].taskReferenceName;o.push({id:`e-${e.taskReferenceName}-${x}`,source:e.taskReferenceName,target:x,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b"}});const b=h[h.length-1].taskReferenceName;o.push({id:`e-${b}-${d}`,source:b,target:d,animated:!0})}else if(!a){const v=`${e.taskReferenceName}_empty_default`;i.push({id:v,type:"default",data:{label:"default (空)",layoutDirection:n,taskReferenceName:v,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.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}-${v}`,source:e.taskReferenceName,target:v,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b",strokeDasharray:"5,5"}}),o.push({id:`e-${v}-${d}`,source:v,target:d,animated:!0,style:{strokeDasharray:"5,5"}})}return Object.keys(p).length===0&&(!h||h.length===0)&&o.push({id:`e-${e.taskReferenceName}-${d}`,source:e.taskReferenceName,target:d,animated:!0}),{nodes:i,edges:o,taskMap:c,nextId:s,joinNodeId:d}}function Bh(e,t,r,n="TB"){const a=[],i=[];let o=t;const s={},c=e.type==="FORK_JOIN_DYNAMIC",u={id:e.taskReferenceName,type:"forkNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,isDynamic:c,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top};return a.push(u),s[e.taskReferenceName]=e,c||(e.forkTasks||[]).forEach((l,p)=>{if(l&&l.length>0){const h=qr(l,o,{...r,...s},n);a.push(...h.nodes),i.push(...h.edges),Object.assign(s,h.taskMap),o=h.nextId;const m=l[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${m}`,source:e.taskReferenceName,sourceHandle:`branch_${p}`,target:m,label:`分支 ${p+1}`,animated:!0,data:{forkIndex:p},style:{stroke:"#10b981"}})}}),{nodes:a,edges:i,taskMap:s,nextId:o}}function Wh(e,t,r,n="TB"){const a={},i={id:e.taskReferenceName,type:"loopNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top};return a[e.taskReferenceName]=e,(e.loopOver||[]).forEach(s=>{a[s.taskReferenceName]=s}),{nodes:[i],edges:[],taskMap:a,nextId:t+1}}function Fh(e,t,r,n="TB"){const a={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"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top},i={[e.taskReferenceName]:e};return{nodes:[a],edges:[],taskMap:i,nextId:t+1}}function $h(e,t,r,n="TB",a=[],i=!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"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.Position.Top},s={[e.taskReferenceName]:e},c=[],u=[];(e.joinOn||[]).forEach(p=>{const h=a.find(m=>m.taskReferenceName===p)||r[p];if(h){const m=Pr(h);u.push({id:`e-${m}-${e.taskReferenceName}`,source:m,target:e.taskReferenceName,animated:!0})}});const l=a.findIndex(p=>p.taskReferenceName===e.taskReferenceName);if(l>0){const p=a[l-1];p.type==="FORK_JOIN_DYNAMIC"?u.push({id:`e-${p.taskReferenceName}-${e.taskReferenceName}-dynamic`,source:p.taskReferenceName,target:e.taskReferenceName,label:"动态分支",animated:!0,style:{stroke:"#10b981",strokeWidth:4,strokeDasharray:"5,5",opacity:.8}}):p.type==="FORK_JOIN"&&(p.forkTasks||[]).forEach((m,g)=>{if((!m||m.length===0)&&!i){const v=`${p.taskReferenceName}_empty_branch_${g}`;c.push({id:v,type:"default",data:{label:`分支 ${g+1} (空)`,layoutDirection:n,taskReferenceName:v,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?q.Position.Right:q.Position.Bottom,targetPosition:n==="LR"?q.Position.Left:q.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"}}),u.push({id:`e-${p.taskReferenceName}-${v}`,source:p.taskReferenceName,sourceHandle:`branch_${g}`,target:v,label:`分支 ${g+1}`,animated:!0,data:{forkIndex:g},style:{stroke:"#10b981",strokeDasharray:"5,5"}}),u.push({id:`e-${v}-${e.taskReferenceName}`,source:v,target:e.taskReferenceName,animated:!0,style:{strokeDasharray:"5,5"}})}})}return{nodes:[o,...c],edges:u,taskMap:s,nextId:t+1}}function qr(e,t,r,n="TB"){const a=[],i=[];let o=t;const s={};for(let c=0;c<e.length;c++){const u=e[c],d={...r,...s},l=Rs(u,o,d,n,e);if(a.push(...l.nodes),i.push(...l.edges),Object.assign(s,l.taskMap),o=l.nextId,c>0){const p=e[c-1];Is(p,u,i)}}return{nodes:a,edges:i,taskMap:s,nextId:o}}function Is(e,t,r){if(e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC")return;const n=Pr(e),a=t.taskReferenceName,i=`e-${n}-${a}`;r.find(o=>o.id===i)||r.push({id:i,source:n,target:a,animated:!0})}function Pr(e){const t=e.type||"SIMPLE";return t==="DECISION"||t==="SWITCH"?`${e.taskReferenceName}_join`:e.taskReferenceName}const ue=Lh;function Ar(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 Lr,js;function zh(){if(js)return Lr;js=1;function e(){this.__data__=[],this.size=0}return Lr=e,Lr}var Dr,Os;function Pe(){if(Os)return Dr;Os=1;function e(t,r){return t===r||t!==t&&r!==r}return Dr=e,Dr}var Mr,qs;function cr(){if(qs)return Mr;qs=1;var e=Pe();function t(r,n){for(var a=r.length;a--;)if(e(r[a][0],n))return a;return-1}return Mr=t,Mr}var Br,Ps;function Hh(){if(Ps)return Br;Ps=1;var e=cr(),t=Array.prototype,r=t.splice;function n(a){var i=this.__data__,o=e(i,a);if(o<0)return!1;var s=i.length-1;return o==s?i.pop():r.call(i,o,1),--this.size,!0}return Br=n,Br}var Wr,As;function Gh(){if(As)return Wr;As=1;var e=cr();function t(r){var n=this.__data__,a=e(n,r);return a<0?void 0:n[a][1]}return Wr=t,Wr}var Fr,Ls;function Uh(){if(Ls)return Fr;Ls=1;var e=cr();function t(r){return e(this.__data__,r)>-1}return Fr=t,Fr}var $r,Ds;function Kh(){if(Ds)return $r;Ds=1;var e=cr();function t(r,n){var a=this.__data__,i=e(a,r);return i<0?(++this.size,a.push([r,n])):a[i][1]=n,this}return $r=t,$r}var zr,Ms;function dr(){if(Ms)return zr;Ms=1;var e=zh(),t=Hh(),r=Gh(),n=Uh(),a=Kh();function i(o){var s=-1,c=o==null?0:o.length;for(this.clear();++s<c;){var u=o[s];this.set(u[0],u[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=a,zr=i,zr}var Hr,Bs;function Jh(){if(Bs)return Hr;Bs=1;var e=dr();function t(){this.__data__=new e,this.size=0}return Hr=t,Hr}var Gr,Ws;function Vh(){if(Ws)return Gr;Ws=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return Gr=e,Gr}var Ur,Fs;function Yh(){if(Fs)return Ur;Fs=1;function e(t){return this.__data__.get(t)}return Ur=e,Ur}var Kr,$s;function Xh(){if($s)return Kr;$s=1;function e(t){return this.__data__.has(t)}return Kr=e,Kr}var Jr,zs;function Hs(){if(zs)return Jr;zs=1;var e=typeof sr=="object"&&sr&&sr.Object===Object&&sr;return Jr=e,Jr}var Vr,Gs;function he(){if(Gs)return Vr;Gs=1;var e=Hs(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Vr=r,Vr}var Yr,Us;function Ae(){if(Us)return Yr;Us=1;var e=he(),t=e.Symbol;return Yr=t,Yr}var Xr,Ks;function Zh(){if(Ks)return Xr;Ks=1;var e=Ae(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,a=e?e.toStringTag:void 0;function i(o){var s=r.call(o,a),c=o[a];try{o[a]=void 0;var u=!0}catch{}var d=n.call(o);return u&&(s?o[a]=c:delete o[a]),d}return Xr=i,Xr}var Zr,Js;function Qh(){if(Js)return Zr;Js=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return Zr=r,Zr}var Qr,Vs;function Ne(){if(Vs)return Qr;Vs=1;var e=Ae(),t=Zh(),r=Qh(),n="[object Null]",a="[object Undefined]",i=e?e.toStringTag:void 0;function o(s){return s==null?s===void 0?a:n:i&&i in Object(s)?t(s):r(s)}return Qr=o,Qr}var et,Ys;function de(){if(Ys)return et;Ys=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return et=e,et}var rt,Xs;function Ve(){if(Xs)return rt;Xs=1;var e=Ne(),t=de(),r="[object AsyncFunction]",n="[object Function]",a="[object GeneratorFunction]",i="[object Proxy]";function o(s){if(!t(s))return!1;var c=e(s);return c==n||c==a||c==r||c==i}return rt=o,rt}var tt,Zs;function ev(){if(Zs)return tt;Zs=1;var e=he(),t=e["__core-js_shared__"];return tt=t,tt}var nt,Qs;function rv(){if(Qs)return nt;Qs=1;var e=ev(),t=(function(){var n=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""})();function r(n){return!!t&&t in n}return nt=r,nt}var at,eu;function ru(){if(eu)return at;eu=1;var e=Function.prototype,t=e.toString;function r(n){if(n!=null){try{return t.call(n)}catch{}try{return n+""}catch{}}return""}return at=r,at}var it,tu;function tv(){if(tu)return it;tu=1;var e=Ve(),t=rv(),r=de(),n=ru(),a=/[\\^$.*+?()[\]{}|]/g,i=/^\[object .+?Constructor\]$/,o=Function.prototype,s=Object.prototype,c=o.toString,u=s.hasOwnProperty,d=RegExp("^"+c.call(u).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function l(p){if(!r(p)||t(p))return!1;var h=e(p)?d:i;return h.test(n(p))}return it=l,it}var ot,nu;function nv(){if(nu)return ot;nu=1;function e(t,r){return t?.[r]}return ot=e,ot}var st,au;function Re(){if(au)return st;au=1;var e=tv(),t=nv();function r(n,a){var i=t(n,a);return e(i)?i:void 0}return st=r,st}var ut,iu;function ct(){if(iu)return ut;iu=1;var e=Re(),t=he(),r=e(t,"Map");return ut=r,ut}var dt,ou;function lr(){if(ou)return dt;ou=1;var e=Re(),t=e(Object,"create");return dt=t,dt}var lt,su;function av(){if(su)return lt;su=1;var e=lr();function t(){this.__data__=e?e(null):{},this.size=0}return lt=t,lt}var ft,uu;function iv(){if(uu)return ft;uu=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return ft=e,ft}var pt,cu;function ov(){if(cu)return pt;cu=1;var e=lr(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function a(i){var o=this.__data__;if(e){var s=o[i];return s===t?void 0:s}return n.call(o,i)?o[i]:void 0}return pt=a,pt}var ht,du;function sv(){if(du)return ht;du=1;var e=lr(),t=Object.prototype,r=t.hasOwnProperty;function n(a){var i=this.__data__;return e?i[a]!==void 0:r.call(i,a)}return ht=n,ht}var vt,lu;function uv(){if(lu)return vt;lu=1;var e=lr(),t="__lodash_hash_undefined__";function r(n,a){var i=this.__data__;return this.size+=this.has(n)?0:1,i[n]=e&&a===void 0?t:a,this}return vt=r,vt}var gt,fu;function cv(){if(fu)return gt;fu=1;var e=av(),t=iv(),r=ov(),n=sv(),a=uv();function i(o){var s=-1,c=o==null?0:o.length;for(this.clear();++s<c;){var u=o[s];this.set(u[0],u[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=a,gt=i,gt}var mt,pu;function dv(){if(pu)return mt;pu=1;var e=cv(),t=dr(),r=ct();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return mt=n,mt}var yt,hu;function lv(){if(hu)return yt;hu=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return yt=e,yt}var bt,vu;function fr(){if(vu)return bt;vu=1;var e=lv();function t(r,n){var a=r.__data__;return e(n)?a[typeof n=="string"?"string":"hash"]:a.map}return bt=t,bt}var xt,gu;function fv(){if(gu)return xt;gu=1;var e=fr();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return xt=t,xt}var _t,mu;function pv(){if(mu)return _t;mu=1;var e=fr();function t(r){return e(this,r).get(r)}return _t=t,_t}var kt,yu;function hv(){if(yu)return kt;yu=1;var e=fr();function t(r){return e(this,r).has(r)}return kt=t,kt}var St,bu;function vv(){if(bu)return St;bu=1;var e=fr();function t(r,n){var a=e(this,r),i=a.size;return a.set(r,n),this.size+=a.size==i?0:1,this}return St=t,St}var wt,xu;function Et(){if(xu)return wt;xu=1;var e=dv(),t=fv(),r=pv(),n=hv(),a=vv();function i(o){var s=-1,c=o==null?0:o.length;for(this.clear();++s<c;){var u=o[s];this.set(u[0],u[1])}}return i.prototype.clear=e,i.prototype.delete=t,i.prototype.get=r,i.prototype.has=n,i.prototype.set=a,wt=i,wt}var Tt,_u;function gv(){if(_u)return Tt;_u=1;var e=dr(),t=ct(),r=Et(),n=200;function a(i,o){var s=this.__data__;if(s instanceof e){var c=s.__data__;if(!t||c.length<n-1)return c.push([i,o]),this.size=++s.size,this;s=this.__data__=new r(c)}return s.set(i,o),this.size=s.size,this}return Tt=a,Tt}var Ct,ku;function pr(){if(ku)return Ct;ku=1;var e=dr(),t=Jh(),r=Vh(),n=Yh(),a=Xh(),i=gv();function o(s){var c=this.__data__=new e(s);this.size=c.size}return o.prototype.clear=t,o.prototype.delete=r,o.prototype.get=n,o.prototype.has=a,o.prototype.set=i,Ct=o,Ct}var Nt,Su;function Rt(){if(Su)return Nt;Su=1;function e(t,r){for(var n=-1,a=t==null?0:t.length;++n<a&&r(t[n],n,t)!==!1;);return t}return Nt=e,Nt}var It,wu;function Eu(){if(wu)return It;wu=1;var e=Re(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return It=t,It}var jt,Tu;function hr(){if(Tu)return jt;Tu=1;var e=Eu();function t(r,n,a){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:a,writable:!0}):r[n]=a}return jt=t,jt}var Ot,Cu;function vr(){if(Cu)return Ot;Cu=1;var e=hr(),t=Pe(),r=Object.prototype,n=r.hasOwnProperty;function a(i,o,s){var c=i[o];(!(n.call(i,o)&&t(c,s))||s===void 0&&!(o in i))&&e(i,o,s)}return Ot=a,Ot}var qt,Nu;function Ye(){if(Nu)return qt;Nu=1;var e=vr(),t=hr();function r(n,a,i,o){var s=!i;i||(i={});for(var c=-1,u=a.length;++c<u;){var d=a[c],l=o?o(i[d],n[d],d,i,n):void 0;l===void 0&&(l=n[d]),s?t(i,d,l):e(i,d,l)}return i}return qt=r,qt}var Pt,Ru;function mv(){if(Ru)return Pt;Ru=1;function e(t,r){for(var n=-1,a=Array(t);++n<t;)a[n]=r(n);return a}return Pt=e,Pt}var At,Iu;function ye(){if(Iu)return At;Iu=1;function e(t){return t!=null&&typeof t=="object"}return At=e,At}var Lt,ju;function yv(){if(ju)return Lt;ju=1;var e=Ne(),t=ye(),r="[object Arguments]";function n(a){return t(a)&&e(a)==r}return Lt=n,Lt}var Dt,Ou;function Xe(){if(Ou)return Dt;Ou=1;var e=yv(),t=ye(),r=Object.prototype,n=r.hasOwnProperty,a=r.propertyIsEnumerable,i=e((function(){return arguments})())?e:function(o){return t(o)&&n.call(o,"callee")&&!a.call(o,"callee")};return Dt=i,Dt}var Mt,qu;function ne(){if(qu)return Mt;qu=1;var e=Array.isArray;return Mt=e,Mt}var Ze={exports:{}},Bt,Pu;function bv(){if(Pu)return Bt;Pu=1;function e(){return!1}return Bt=e,Bt}Ze.exports;var Au;function Le(){return Au||(Au=1,(function(e,t){var r=he(),n=bv(),a=t&&!t.nodeType&&t,i=a&&!0&&e&&!e.nodeType&&e,o=i&&i.exports===a,s=o?r.Buffer:void 0,c=s?s.isBuffer:void 0,u=c||n;e.exports=u})(Ze,Ze.exports)),Ze.exports}var Wt,Lu;function gr(){if(Lu)return Wt;Lu=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,a){var i=typeof n;return a=a??e,!!a&&(i=="number"||i!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<a}return Wt=r,Wt}var Ft,Du;function $t(){if(Du)return Ft;Du=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return Ft=t,Ft}var zt,Mu;function xv(){if(Mu)return zt;Mu=1;var e=Ne(),t=$t(),r=ye(),n="[object Arguments]",a="[object Array]",i="[object Boolean]",o="[object Date]",s="[object Error]",c="[object Function]",u="[object Map]",d="[object Number]",l="[object Object]",p="[object RegExp]",h="[object Set]",m="[object String]",g="[object WeakMap]",v="[object ArrayBuffer]",x="[object DataView]",b="[object Float32Array]",_="[object Float64Array]",y="[object Int8Array]",S="[object Int16Array]",w="[object Int32Array]",E="[object Uint8Array]",T="[object Uint8ClampedArray]",C="[object Uint16Array]",R="[object Uint32Array]",A={};A[b]=A[_]=A[y]=A[S]=A[w]=A[E]=A[T]=A[C]=A[R]=!0,A[n]=A[a]=A[v]=A[i]=A[x]=A[o]=A[s]=A[c]=A[u]=A[d]=A[l]=A[p]=A[h]=A[m]=A[g]=!1;function B(N){return r(N)&&t(N.length)&&!!A[e(N)]}return zt=B,zt}var Ht,Bu;function mr(){if(Bu)return Ht;Bu=1;function e(t){return function(r){return t(r)}}return Ht=e,Ht}var Qe={exports:{}};Qe.exports;var Wu;function Gt(){return Wu||(Wu=1,(function(e,t){var r=Hs(),n=t&&!t.nodeType&&t,a=n&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===n,o=i&&r.process,s=(function(){try{var c=a&&a.require&&a.require("util").types;return c||o&&o.binding&&o.binding("util")}catch{}})();e.exports=s})(Qe,Qe.exports)),Qe.exports}var Ut,Fu;function er(){if(Fu)return Ut;Fu=1;var e=xv(),t=mr(),r=Gt(),n=r&&r.isTypedArray,a=n?t(n):e;return Ut=a,Ut}var Kt,$u;function zu(){if($u)return Kt;$u=1;var e=mv(),t=Xe(),r=ne(),n=Le(),a=gr(),i=er(),o=Object.prototype,s=o.hasOwnProperty;function c(u,d){var l=r(u),p=!l&&t(u),h=!l&&!p&&n(u),m=!l&&!p&&!h&&i(u),g=l||p||h||m,v=g?e(u.length,String):[],x=v.length;for(var b in u)(d||s.call(u,b))&&!(g&&(b=="length"||h&&(b=="offset"||b=="parent")||m&&(b=="buffer"||b=="byteLength"||b=="byteOffset")||a(b,x)))&&v.push(b);return v}return Kt=c,Kt}var Jt,Hu;function yr(){if(Hu)return Jt;Hu=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,a=typeof n=="function"&&n.prototype||e;return r===a}return Jt=t,Jt}var Vt,Gu;function Uu(){if(Gu)return Vt;Gu=1;function e(t,r){return function(n){return t(r(n))}}return Vt=e,Vt}var Yt,Ku;function _v(){if(Ku)return Yt;Ku=1;var e=Uu(),t=e(Object.keys,Object);return Yt=t,Yt}var Xt,Ju;function Zt(){if(Ju)return Xt;Ju=1;var e=yr(),t=_v(),r=Object.prototype,n=r.hasOwnProperty;function a(i){if(!e(i))return t(i);var o=[];for(var s in Object(i))n.call(i,s)&&s!="constructor"&&o.push(s);return o}return Xt=a,Xt}var Qt,Vu;function xe(){if(Vu)return Qt;Vu=1;var e=Ve(),t=$t();function r(n){return n!=null&&t(n.length)&&!e(n)}return Qt=r,Qt}var en,Yu;function we(){if(Yu)return en;Yu=1;var e=zu(),t=Zt(),r=xe();function n(a){return r(a)?e(a):t(a)}return en=n,en}var rn,Xu;function kv(){if(Xu)return rn;Xu=1;var e=Ye(),t=we();function r(n,a){return n&&e(a,t(a),n)}return rn=r,rn}var tn,Zu;function Sv(){if(Zu)return tn;Zu=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return tn=e,tn}var nn,Qu;function wv(){if(Qu)return nn;Qu=1;var e=de(),t=yr(),r=Sv(),n=Object.prototype,a=n.hasOwnProperty;function i(o){if(!e(o))return r(o);var s=t(o),c=[];for(var u in o)u=="constructor"&&(s||!a.call(o,u))||c.push(u);return c}return nn=i,nn}var an,ec;function Ie(){if(ec)return an;ec=1;var e=zu(),t=wv(),r=xe();function n(a){return r(a)?e(a,!0):t(a)}return an=n,an}var on,rc;function Ev(){if(rc)return on;rc=1;var e=Ye(),t=Ie();function r(n,a){return n&&e(a,t(a),n)}return on=r,on}var rr={exports:{}};rr.exports;var tc;function nc(){return tc||(tc=1,(function(e,t){var r=he(),n=t&&!t.nodeType&&t,a=n&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===n,o=i?r.Buffer:void 0,s=o?o.allocUnsafe:void 0;function c(u,d){if(d)return u.slice();var l=u.length,p=s?s(l):new u.constructor(l);return u.copy(p),p}e.exports=c})(rr,rr.exports)),rr.exports}var sn,ac;function ic(){if(ac)return sn;ac=1;function e(t,r){var n=-1,a=t.length;for(r||(r=Array(a));++n<a;)r[n]=t[n];return r}return sn=e,sn}var un,oc;function sc(){if(oc)return un;oc=1;function e(t,r){for(var n=-1,a=t==null?0:t.length,i=0,o=[];++n<a;){var s=t[n];r(s,n,t)&&(o[i++]=s)}return o}return un=e,un}var cn,uc;function cc(){if(uc)return cn;uc=1;function e(){return[]}return cn=e,cn}var dn,dc;function ln(){if(dc)return dn;dc=1;var e=sc(),t=cc(),r=Object.prototype,n=r.propertyIsEnumerable,a=Object.getOwnPropertySymbols,i=a?function(o){return o==null?[]:(o=Object(o),e(a(o),function(s){return n.call(o,s)}))}:t;return dn=i,dn}var fn,lc;function Tv(){if(lc)return fn;lc=1;var e=Ye(),t=ln();function r(n,a){return e(n,t(n),a)}return fn=r,fn}var pn,fc;function hn(){if(fc)return pn;fc=1;function e(t,r){for(var n=-1,a=r.length,i=t.length;++n<a;)t[i+n]=r[n];return t}return pn=e,pn}var vn,pc;function br(){if(pc)return vn;pc=1;var e=Uu(),t=e(Object.getPrototypeOf,Object);return vn=t,vn}var gn,hc;function vc(){if(hc)return gn;hc=1;var e=hn(),t=br(),r=ln(),n=cc(),a=Object.getOwnPropertySymbols,i=a?function(o){for(var s=[];o;)e(s,r(o)),o=t(o);return s}:n;return gn=i,gn}var mn,gc;function Cv(){if(gc)return mn;gc=1;var e=Ye(),t=vc();function r(n,a){return e(n,t(n),a)}return mn=r,mn}var yn,mc;function yc(){if(mc)return yn;mc=1;var e=hn(),t=ne();function r(n,a,i){var o=a(n);return t(n)?o:e(o,i(n))}return yn=r,yn}var bn,bc;function xc(){if(bc)return bn;bc=1;var e=yc(),t=ln(),r=we();function n(a){return e(a,r,t)}return bn=n,bn}var xn,_c;function Nv(){if(_c)return xn;_c=1;var e=yc(),t=vc(),r=Ie();function n(a){return e(a,r,t)}return xn=n,xn}var _n,kc;function Rv(){if(kc)return _n;kc=1;var e=Re(),t=he(),r=e(t,"DataView");return _n=r,_n}var kn,Sc;function Iv(){if(Sc)return kn;Sc=1;var e=Re(),t=he(),r=e(t,"Promise");return kn=r,kn}var Sn,wc;function Ec(){if(wc)return Sn;wc=1;var e=Re(),t=he(),r=e(t,"Set");return Sn=r,Sn}var wn,Tc;function jv(){if(Tc)return wn;Tc=1;var e=Re(),t=he(),r=e(t,"WeakMap");return wn=r,wn}var En,Cc;function De(){if(Cc)return En;Cc=1;var e=Rv(),t=ct(),r=Iv(),n=Ec(),a=jv(),i=Ne(),o=ru(),s="[object Map]",c="[object Object]",u="[object Promise]",d="[object Set]",l="[object WeakMap]",p="[object DataView]",h=o(e),m=o(t),g=o(r),v=o(n),x=o(a),b=i;return(e&&b(new e(new ArrayBuffer(1)))!=p||t&&b(new t)!=s||r&&b(r.resolve())!=u||n&&b(new n)!=d||a&&b(new a)!=l)&&(b=function(_){var y=i(_),S=y==c?_.constructor:void 0,w=S?o(S):"";if(w)switch(w){case h:return p;case m:return s;case g:return u;case v:return d;case x:return l}return y}),En=b,En}var Tn,Nc;function Ov(){if(Nc)return Tn;Nc=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var a=n.length,i=new n.constructor(a);return a&&typeof n[0]=="string"&&t.call(n,"index")&&(i.index=n.index,i.input=n.input),i}return Tn=r,Tn}var Cn,Rc;function Ic(){if(Rc)return Cn;Rc=1;var e=he(),t=e.Uint8Array;return Cn=t,Cn}var Nn,jc;function Rn(){if(jc)return Nn;jc=1;var e=Ic();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return Nn=t,Nn}var In,Oc;function qv(){if(Oc)return In;Oc=1;var e=Rn();function t(r,n){var a=n?e(r.buffer):r.buffer;return new r.constructor(a,r.byteOffset,r.byteLength)}return In=t,In}var jn,qc;function Pv(){if(qc)return jn;qc=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return jn=t,jn}var On,Pc;function Av(){if(Pc)return On;Pc=1;var e=Ae(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(a){return r?Object(r.call(a)):{}}return On=n,On}var qn,Ac;function Lc(){if(Ac)return qn;Ac=1;var e=Rn();function t(r,n){var a=n?e(r.buffer):r.buffer;return new r.constructor(a,r.byteOffset,r.length)}return qn=t,qn}var Pn,Dc;function Lv(){if(Dc)return Pn;Dc=1;var e=Rn(),t=qv(),r=Pv(),n=Av(),a=Lc(),i="[object Boolean]",o="[object Date]",s="[object Map]",c="[object Number]",u="[object RegExp]",d="[object Set]",l="[object String]",p="[object Symbol]",h="[object ArrayBuffer]",m="[object DataView]",g="[object Float32Array]",v="[object Float64Array]",x="[object Int8Array]",b="[object Int16Array]",_="[object Int32Array]",y="[object Uint8Array]",S="[object Uint8ClampedArray]",w="[object Uint16Array]",E="[object Uint32Array]";function T(C,R,A){var B=C.constructor;switch(R){case h:return e(C);case i:case o:return new B(+C);case m:return t(C,A);case g:case v:case x:case b:case _:case y:case S:case w:case E:return a(C,A);case s:return new B;case c:case l:return new B(C);case u:return r(C);case d:return new B;case p:return n(C)}}return Pn=T,Pn}var An,Mc;function Bc(){if(Mc)return An;Mc=1;var e=de(),t=Object.create,r=(function(){function n(){}return function(a){if(!e(a))return{};if(t)return t(a);n.prototype=a;var i=new n;return n.prototype=void 0,i}})();return An=r,An}var Ln,Wc;function Fc(){if(Wc)return Ln;Wc=1;var e=Bc(),t=br(),r=yr();function n(a){return typeof a.constructor=="function"&&!r(a)?e(t(a)):{}}return Ln=n,Ln}var Dn,$c;function Dv(){if($c)return Dn;$c=1;var e=De(),t=ye(),r="[object Map]";function n(a){return t(a)&&e(a)==r}return Dn=n,Dn}var Mn,zc;function Mv(){if(zc)return Mn;zc=1;var e=Dv(),t=mr(),r=Gt(),n=r&&r.isMap,a=n?t(n):e;return Mn=a,Mn}var Bn,Hc;function Bv(){if(Hc)return Bn;Hc=1;var e=De(),t=ye(),r="[object Set]";function n(a){return t(a)&&e(a)==r}return Bn=n,Bn}var Wn,Gc;function Wv(){if(Gc)return Wn;Gc=1;var e=Bv(),t=mr(),r=Gt(),n=r&&r.isSet,a=n?t(n):e;return Wn=a,Wn}var Fn,Uc;function Kc(){if(Uc)return Fn;Uc=1;var e=pr(),t=Rt(),r=vr(),n=kv(),a=Ev(),i=nc(),o=ic(),s=Tv(),c=Cv(),u=xc(),d=Nv(),l=De(),p=Ov(),h=Lv(),m=Fc(),g=ne(),v=Le(),x=Mv(),b=de(),_=Wv(),y=we(),S=Ie(),w=1,E=2,T=4,C="[object Arguments]",R="[object Array]",A="[object Boolean]",B="[object Date]",N="[object Error]",M="[object Function]",L="[object GeneratorFunction]",$="[object Map]",U="[object Number]",W="[object Object]",z="[object RegExp]",K="[object Set]",j="[object String]",F="[object Symbol]",G="[object WeakMap]",k="[object ArrayBuffer]",I="[object DataView]",P="[object Float32Array]",O="[object Float64Array]",H="[object Int8Array]",J="[object Int16Array]",Z="[object Int32Array]",ee="[object Uint8Array]",ce="[object Uint8ClampedArray]",te="[object Uint16Array]",re="[object Uint32Array]",Y={};Y[C]=Y[R]=Y[k]=Y[I]=Y[A]=Y[B]=Y[P]=Y[O]=Y[H]=Y[J]=Y[Z]=Y[$]=Y[U]=Y[W]=Y[z]=Y[K]=Y[j]=Y[F]=Y[ee]=Y[ce]=Y[te]=Y[re]=!0,Y[N]=Y[M]=Y[G]=!1;function Oe(X,He,Ge,wb,Nr,Te){var se,Rr=He&w,Ir=He&E,Eb=He&T;if(Ge&&(se=Nr?Ge(X,wb,Nr,Te):Ge(X)),se!==void 0)return se;if(!b(X))return X;var Sh=g(X);if(Sh){if(se=p(X),!Rr)return o(X,se)}else{var Ue=l(X),wh=Ue==M||Ue==L;if(v(X))return i(X,Rr);if(Ue==W||Ue==C||wh&&!Nr){if(se=Ir||wh?{}:m(X),!Rr)return Ir?c(X,a(se,X)):s(X,n(se,X))}else{if(!Y[Ue])return Nr?X:{};se=h(X,Ue,Rr)}}Te||(Te=new e);var Eh=Te.get(X);if(Eh)return Eh;Te.set(X,se),_(X)?X.forEach(function(Ce){se.add(Oe(Ce,He,Ge,Ce,X,Te))}):x(X)&&X.forEach(function(Ce,qe){se.set(qe,Oe(Ce,He,Ge,qe,X,Te))});var Tb=Eb?Ir?d:u:Ir?S:y,Th=Sh?void 0:Tb(X);return t(Th||X,function(Ce,qe){Th&&(qe=Ce,Ce=X[qe]),r(se,qe,Oe(Ce,He,Ge,qe,X,Te))}),se}return Fn=Oe,Fn}var $n,Jc;function Fv(){if(Jc)return $n;Jc=1;var e=Kc(),t=4;function r(n){return e(n,t)}return $n=r,$n}var zn,Vc;function Hn(){if(Vc)return zn;Vc=1;function e(t){return function(){return t}}return zn=e,zn}var Gn,Yc;function $v(){if(Yc)return Gn;Yc=1;function e(t){return function(r,n,a){for(var i=-1,o=Object(r),s=a(r),c=s.length;c--;){var u=s[t?c:++i];if(n(o[u],u,o)===!1)break}return r}}return Gn=e,Gn}var Un,Xc;function Kn(){if(Xc)return Un;Xc=1;var e=$v(),t=e();return Un=t,Un}var Jn,Zc;function Vn(){if(Zc)return Jn;Zc=1;var e=Kn(),t=we();function r(n,a){return n&&e(n,a,t)}return Jn=r,Jn}var Yn,Qc;function zv(){if(Qc)return Yn;Qc=1;var e=xe();function t(r,n){return function(a,i){if(a==null)return a;if(!e(a))return r(a,i);for(var o=a.length,s=n?o:-1,c=Object(a);(n?s--:++s<o)&&i(c[s],s,c)!==!1;);return a}}return Yn=t,Yn}var Xn,ed;function xr(){if(ed)return Xn;ed=1;var e=Vn(),t=zv(),r=t(e);return Xn=r,Xn}var Zn,rd;function je(){if(rd)return Zn;rd=1;function e(t){return t}return Zn=e,Zn}var Qn,td;function nd(){if(td)return Qn;td=1;var e=je();function t(r){return typeof r=="function"?r:e}return Qn=t,Qn}var ea,ad;function id(){if(ad)return ea;ad=1;var e=Rt(),t=xr(),r=nd(),n=ne();function a(i,o){var s=n(i)?e:t;return s(i,r(o))}return ea=a,ea}var ra,od;function sd(){return od||(od=1,ra=id()),ra}var ta,ud;function Hv(){if(ud)return ta;ud=1;var e=xr();function t(r,n){var a=[];return e(r,function(i,o,s){n(i,o,s)&&a.push(i)}),a}return ta=t,ta}var na,cd;function Gv(){if(cd)return na;cd=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return na=t,na}var aa,dd;function Uv(){if(dd)return aa;dd=1;function e(t){return this.__data__.has(t)}return aa=e,aa}var ia,ld;function fd(){if(ld)return ia;ld=1;var e=Et(),t=Gv(),r=Uv();function n(a){var i=-1,o=a==null?0:a.length;for(this.__data__=new e;++i<o;)this.add(a[i])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,ia=n,ia}var oa,pd;function Kv(){if(pd)return oa;pd=1;function e(t,r){for(var n=-1,a=t==null?0:t.length;++n<a;)if(r(t[n],n,t))return!0;return!1}return oa=e,oa}var sa,hd;function vd(){if(hd)return sa;hd=1;function e(t,r){return t.has(r)}return sa=e,sa}var ua,gd;function md(){if(gd)return ua;gd=1;var e=fd(),t=Kv(),r=vd(),n=1,a=2;function i(o,s,c,u,d,l){var p=c&n,h=o.length,m=s.length;if(h!=m&&!(p&&m>h))return!1;var g=l.get(o),v=l.get(s);if(g&&v)return g==s&&v==o;var x=-1,b=!0,_=c&a?new e:void 0;for(l.set(o,s),l.set(s,o);++x<h;){var y=o[x],S=s[x];if(u)var w=p?u(S,y,x,s,o,l):u(y,S,x,o,s,l);if(w!==void 0){if(w)continue;b=!1;break}if(_){if(!t(s,function(E,T){if(!r(_,T)&&(y===E||d(y,E,c,u,l)))return _.push(T)})){b=!1;break}}else if(!(y===S||d(y,S,c,u,l))){b=!1;break}}return l.delete(o),l.delete(s),b}return ua=i,ua}var ca,yd;function Jv(){if(yd)return ca;yd=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(a,i){n[++r]=[i,a]}),n}return ca=e,ca}var da,bd;function la(){if(bd)return da;bd=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(a){n[++r]=a}),n}return da=e,da}var fa,xd;function Vv(){if(xd)return fa;xd=1;var e=Ae(),t=Ic(),r=Pe(),n=md(),a=Jv(),i=la(),o=1,s=2,c="[object Boolean]",u="[object Date]",d="[object Error]",l="[object Map]",p="[object Number]",h="[object RegExp]",m="[object Set]",g="[object String]",v="[object Symbol]",x="[object ArrayBuffer]",b="[object DataView]",_=e?e.prototype:void 0,y=_?_.valueOf:void 0;function S(w,E,T,C,R,A,B){switch(T){case b:if(w.byteLength!=E.byteLength||w.byteOffset!=E.byteOffset)return!1;w=w.buffer,E=E.buffer;case x:return!(w.byteLength!=E.byteLength||!A(new t(w),new t(E)));case c:case u:case p:return r(+w,+E);case d:return w.name==E.name&&w.message==E.message;case h:case g:return w==E+"";case l:var N=a;case m:var M=C&o;if(N||(N=i),w.size!=E.size&&!M)return!1;var L=B.get(w);if(L)return L==E;C|=s,B.set(w,E);var $=n(N(w),N(E),C,R,A,B);return B.delete(w),$;case v:if(y)return y.call(w)==y.call(E)}return!1}return fa=S,fa}var pa,_d;function Yv(){if(_d)return pa;_d=1;var e=xc(),t=1,r=Object.prototype,n=r.hasOwnProperty;function a(i,o,s,c,u,d){var l=s&t,p=e(i),h=p.length,m=e(o),g=m.length;if(h!=g&&!l)return!1;for(var v=h;v--;){var x=p[v];if(!(l?x in o:n.call(o,x)))return!1}var b=d.get(i),_=d.get(o);if(b&&_)return b==o&&_==i;var y=!0;d.set(i,o),d.set(o,i);for(var S=l;++v<h;){x=p[v];var w=i[x],E=o[x];if(c)var T=l?c(E,w,x,o,i,d):c(w,E,x,i,o,d);if(!(T===void 0?w===E||u(w,E,s,c,d):T)){y=!1;break}S||(S=x=="constructor")}if(y&&!S){var C=i.constructor,R=o.constructor;C!=R&&"constructor"in i&&"constructor"in o&&!(typeof C=="function"&&C instanceof C&&typeof R=="function"&&R instanceof R)&&(y=!1)}return d.delete(i),d.delete(o),y}return pa=a,pa}var ha,kd;function Xv(){if(kd)return ha;kd=1;var e=pr(),t=md(),r=Vv(),n=Yv(),a=De(),i=ne(),o=Le(),s=er(),c=1,u="[object Arguments]",d="[object Array]",l="[object Object]",p=Object.prototype,h=p.hasOwnProperty;function m(g,v,x,b,_,y){var S=i(g),w=i(v),E=S?d:a(g),T=w?d:a(v);E=E==u?l:E,T=T==u?l:T;var C=E==l,R=T==l,A=E==T;if(A&&o(g)){if(!o(v))return!1;S=!0,C=!1}if(A&&!C)return y||(y=new e),S||s(g)?t(g,v,x,b,_,y):r(g,v,E,x,b,_,y);if(!(x&c)){var B=C&&h.call(g,"__wrapped__"),N=R&&h.call(v,"__wrapped__");if(B||N){var M=B?g.value():g,L=N?v.value():v;return y||(y=new e),_(M,L,x,b,y)}}return A?(y||(y=new e),n(g,v,x,b,_,y)):!1}return ha=m,ha}var va,Sd;function wd(){if(Sd)return va;Sd=1;var e=Xv(),t=ye();function r(n,a,i,o,s){return n===a?!0:n==null||a==null||!t(n)&&!t(a)?n!==n&&a!==a:e(n,a,i,o,r,s)}return va=r,va}var ga,Ed;function Zv(){if(Ed)return ga;Ed=1;var e=pr(),t=wd(),r=1,n=2;function a(i,o,s,c){var u=s.length,d=u,l=!c;if(i==null)return!d;for(i=Object(i);u--;){var p=s[u];if(l&&p[2]?p[1]!==i[p[0]]:!(p[0]in i))return!1}for(;++u<d;){p=s[u];var h=p[0],m=i[h],g=p[1];if(l&&p[2]){if(m===void 0&&!(h in i))return!1}else{var v=new e;if(c)var x=c(m,g,h,i,o,v);if(!(x===void 0?t(g,m,r|n,c,v):x))return!1}}return!0}return ga=a,ga}var ma,Td;function Cd(){if(Td)return ma;Td=1;var e=de();function t(r){return r===r&&!e(r)}return ma=t,ma}var ya,Nd;function Qv(){if(Nd)return ya;Nd=1;var e=Cd(),t=we();function r(n){for(var a=t(n),i=a.length;i--;){var o=a[i],s=n[o];a[i]=[o,s,e(s)]}return a}return ya=r,ya}var ba,Rd;function Id(){if(Rd)return ba;Rd=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return ba=e,ba}var xa,jd;function eg(){if(jd)return xa;jd=1;var e=Zv(),t=Qv(),r=Id();function n(a){var i=t(a);return i.length==1&&i[0][2]?r(i[0][0],i[0][1]):function(o){return o===a||e(o,a,i)}}return xa=n,xa}var _a,Od;function Me(){if(Od)return _a;Od=1;var e=Ne(),t=ye(),r="[object Symbol]";function n(a){return typeof a=="symbol"||t(a)&&e(a)==r}return _a=n,_a}var ka,qd;function Sa(){if(qd)return ka;qd=1;var e=ne(),t=Me(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function a(i,o){if(e(i))return!1;var s=typeof i;return s=="number"||s=="symbol"||s=="boolean"||i==null||t(i)?!0:n.test(i)||!r.test(i)||o!=null&&i in Object(o)}return ka=a,ka}var wa,Pd;function rg(){if(Pd)return wa;Pd=1;var e=Et(),t="Expected a function";function r(n,a){if(typeof n!="function"||a!=null&&typeof a!="function")throw new TypeError(t);var i=function(){var o=arguments,s=a?a.apply(this,o):o[0],c=i.cache;if(c.has(s))return c.get(s);var u=n.apply(this,o);return i.cache=c.set(s,u)||c,u};return i.cache=new(r.Cache||e),i}return r.Cache=e,wa=r,wa}var Ea,Ad;function tg(){if(Ad)return Ea;Ad=1;var e=rg(),t=500;function r(n){var a=e(n,function(o){return i.size===t&&i.clear(),o}),i=a.cache;return a}return Ea=r,Ea}var Ta,Ld;function ng(){if(Ld)return Ta;Ld=1;var e=tg(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(a){var i=[];return a.charCodeAt(0)===46&&i.push(""),a.replace(t,function(o,s,c,u){i.push(c?u.replace(r,"$1"):s||o)}),i});return Ta=n,Ta}var Ca,Dd;function _r(){if(Dd)return Ca;Dd=1;function e(t,r){for(var n=-1,a=t==null?0:t.length,i=Array(a);++n<a;)i[n]=r(t[n],n,t);return i}return Ca=e,Ca}var Na,Md;function ag(){if(Md)return Na;Md=1;var e=Ae(),t=_r(),r=ne(),n=Me(),a=e?e.prototype:void 0,i=a?a.toString:void 0;function o(s){if(typeof s=="string")return s;if(r(s))return t(s,o)+"";if(n(s))return i?i.call(s):"";var c=s+"";return c=="0"&&1/s==-1/0?"-0":c}return Na=o,Na}var Ra,Bd;function Wd(){if(Bd)return Ra;Bd=1;var e=ag();function t(r){return r==null?"":e(r)}return Ra=t,Ra}var Ia,Fd;function kr(){if(Fd)return Ia;Fd=1;var e=ne(),t=Sa(),r=ng(),n=Wd();function a(i,o){return e(i)?i:t(i,o)?[i]:r(n(i))}return Ia=a,Ia}var ja,$d;function tr(){if($d)return ja;$d=1;var e=Me();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return ja=t,ja}var Oa,zd;function Sr(){if(zd)return Oa;zd=1;var e=kr(),t=tr();function r(n,a){a=e(a,n);for(var i=0,o=a.length;n!=null&&i<o;)n=n[t(a[i++])];return i&&i==o?n:void 0}return Oa=r,Oa}var qa,Hd;function ig(){if(Hd)return qa;Hd=1;var e=Sr();function t(r,n,a){var i=r==null?void 0:e(r,n);return i===void 0?a:i}return qa=t,qa}var Pa,Gd;function og(){if(Gd)return Pa;Gd=1;function e(t,r){return t!=null&&r in Object(t)}return Pa=e,Pa}var Aa,Ud;function Kd(){if(Ud)return Aa;Ud=1;var e=kr(),t=Xe(),r=ne(),n=gr(),a=$t(),i=tr();function o(s,c,u){c=e(c,s);for(var d=-1,l=c.length,p=!1;++d<l;){var h=i(c[d]);if(!(p=s!=null&&u(s,h)))break;s=s[h]}return p||++d!=l?p:(l=s==null?0:s.length,!!l&&a(l)&&n(h,l)&&(r(s)||t(s)))}return Aa=o,Aa}var La,Jd;function Vd(){if(Jd)return La;Jd=1;var e=og(),t=Kd();function r(n,a){return n!=null&&t(n,a,e)}return La=r,La}var Da,Yd;function sg(){if(Yd)return Da;Yd=1;var e=wd(),t=ig(),r=Vd(),n=Sa(),a=Cd(),i=Id(),o=tr(),s=1,c=2;function u(d,l){return n(d)&&a(l)?i(o(d),l):function(p){var h=t(p,d);return h===void 0&&h===l?r(p,d):e(l,h,s|c)}}return Da=u,Da}var Ma,Xd;function Zd(){if(Xd)return Ma;Xd=1;function e(t){return function(r){return r?.[t]}}return Ma=e,Ma}var Ba,Qd;function ug(){if(Qd)return Ba;Qd=1;var e=Sr();function t(r){return function(n){return e(n,r)}}return Ba=t,Ba}var Wa,el;function cg(){if(el)return Wa;el=1;var e=Zd(),t=ug(),r=Sa(),n=tr();function a(i){return r(i)?e(n(i)):t(i)}return Wa=a,Wa}var Fa,rl;function _e(){if(rl)return Fa;rl=1;var e=eg(),t=sg(),r=je(),n=ne(),a=cg();function i(o){return typeof o=="function"?o:o==null?r:typeof o=="object"?n(o)?t(o[0],o[1]):e(o):a(o)}return Fa=i,Fa}var $a,tl;function nl(){if(tl)return $a;tl=1;var e=sc(),t=Hv(),r=_e(),n=ne();function a(i,o){var s=n(i)?e:t;return s(i,r(o,3))}return $a=a,$a}var za,al;function dg(){if(al)return za;al=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,a){return n!=null&&t.call(n,a)}return za=r,za}var Ha,il;function ol(){if(il)return Ha;il=1;var e=dg(),t=Kd();function r(n,a){return n!=null&&t(n,a,e)}return Ha=r,Ha}var Ga,sl;function lg(){if(sl)return Ga;sl=1;var e=Zt(),t=De(),r=Xe(),n=ne(),a=xe(),i=Le(),o=yr(),s=er(),c="[object Map]",u="[object Set]",d=Object.prototype,l=d.hasOwnProperty;function p(h){if(h==null)return!0;if(a(h)&&(n(h)||typeof h=="string"||typeof h.splice=="function"||i(h)||s(h)||r(h)))return!h.length;var m=t(h);if(m==c||m==u)return!h.size;if(o(h))return!e(h).length;for(var g in h)if(l.call(h,g))return!1;return!0}return Ga=p,Ga}var Ua,ul;function cl(){if(ul)return Ua;ul=1;function e(t){return t===void 0}return Ua=e,Ua}var Ka,dl;function ll(){if(dl)return Ka;dl=1;var e=xr(),t=xe();function r(n,a){var i=-1,o=t(n)?Array(n.length):[];return e(n,function(s,c,u){o[++i]=a(s,c,u)}),o}return Ka=r,Ka}var Ja,fl;function pl(){if(fl)return Ja;fl=1;var e=_r(),t=_e(),r=ll(),n=ne();function a(i,o){var s=n(i)?e:r;return s(i,t(o,3))}return Ja=a,Ja}var Va,hl;function fg(){if(hl)return Va;hl=1;function e(t,r,n,a){var i=-1,o=t==null?0:t.length;for(a&&o&&(n=t[++i]);++i<o;)n=r(n,t[i],i,t);return n}return Va=e,Va}var Ya,vl;function pg(){if(vl)return Ya;vl=1;function e(t,r,n,a,i){return i(t,function(o,s,c){n=a?(a=!1,o):r(n,o,s,c)}),n}return Ya=e,Ya}var Xa,gl;function ml(){if(gl)return Xa;gl=1;var e=fg(),t=xr(),r=_e(),n=pg(),a=ne();function i(o,s,c){var u=a(o)?e:n,d=arguments.length<3;return u(o,r(s,4),c,d,t)}return Xa=i,Xa}var Za,yl;function hg(){if(yl)return Za;yl=1;var e=Ne(),t=ne(),r=ye(),n="[object String]";function a(i){return typeof i=="string"||!t(i)&&r(i)&&e(i)==n}return Za=a,Za}var Qa,bl;function vg(){if(bl)return Qa;bl=1;var e=Zd(),t=e("length");return Qa=t,Qa}var ei,xl;function gg(){if(xl)return ei;xl=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",a=t+r+n,i="\\ufe0e\\ufe0f",o="\\u200d",s=RegExp("["+o+e+a+i+"]");function c(u){return s.test(u)}return ei=c,ei}var ri,_l;function mg(){if(_l)return ri;_l=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",a=t+r+n,i="\\ufe0e\\ufe0f",o="["+e+"]",s="["+a+"]",c="\\ud83c[\\udffb-\\udfff]",u="(?:"+s+"|"+c+")",d="[^"+e+"]",l="(?:\\ud83c[\\udde6-\\uddff]){2}",p="[\\ud800-\\udbff][\\udc00-\\udfff]",h="\\u200d",m=u+"?",g="["+i+"]?",v="(?:"+h+"(?:"+[d,l,p].join("|")+")"+g+m+")*",x=g+m+v,b="(?:"+[d+s+"?",s,l,p,o].join("|")+")",_=RegExp(c+"(?="+c+")|"+b+x,"g");function y(S){for(var w=_.lastIndex=0;_.test(S);)++w;return w}return ri=y,ri}var ti,kl;function yg(){if(kl)return ti;kl=1;var e=vg(),t=gg(),r=mg();function n(a){return t(a)?r(a):e(a)}return ti=n,ti}var ni,Sl;function bg(){if(Sl)return ni;Sl=1;var e=Zt(),t=De(),r=xe(),n=hg(),a=yg(),i="[object Map]",o="[object Set]";function s(c){if(c==null)return 0;if(r(c))return n(c)?a(c):c.length;var u=t(c);return u==i||u==o?c.size:e(c).length}return ni=s,ni}var ai,wl;function xg(){if(wl)return ai;wl=1;var e=Rt(),t=Bc(),r=Vn(),n=_e(),a=br(),i=ne(),o=Le(),s=Ve(),c=de(),u=er();function d(l,p,h){var m=i(l),g=m||o(l)||u(l);if(p=n(p,4),h==null){var v=l&&l.constructor;g?h=m?new v:[]:c(l)?h=s(v)?t(a(l)):{}:h={}}return(g?e:r)(l,function(x,b,_){return p(h,x,b,_)}),h}return ai=d,ai}var ii,El;function _g(){if(El)return ii;El=1;var e=Ae(),t=Xe(),r=ne(),n=e?e.isConcatSpreadable:void 0;function a(i){return r(i)||t(i)||!!(n&&i&&i[n])}return ii=a,ii}var oi,Tl;function si(){if(Tl)return oi;Tl=1;var e=hn(),t=_g();function r(n,a,i,o,s){var c=-1,u=n.length;for(i||(i=t),s||(s=[]);++c<u;){var d=n[c];a>0&&i(d)?a>1?r(d,a-1,i,o,s):e(s,d):o||(s[s.length]=d)}return s}return oi=r,oi}var ui,Cl;function kg(){if(Cl)return ui;Cl=1;function e(t,r,n){switch(n.length){case 0:return t.call(r);case 1:return t.call(r,n[0]);case 2:return t.call(r,n[0],n[1]);case 3:return t.call(r,n[0],n[1],n[2])}return t.apply(r,n)}return ui=e,ui}var ci,Nl;function Rl(){if(Nl)return ci;Nl=1;var e=kg(),t=Math.max;function r(n,a,i){return a=t(a===void 0?n.length-1:a,0),function(){for(var o=arguments,s=-1,c=t(o.length-a,0),u=Array(c);++s<c;)u[s]=o[a+s];s=-1;for(var d=Array(a+1);++s<a;)d[s]=o[s];return d[a]=i(u),e(n,this,d)}}return ci=r,ci}var di,Il;function Sg(){if(Il)return di;Il=1;var e=Hn(),t=Eu(),r=je(),n=t?function(a,i){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(i),writable:!0})}:r;return di=n,di}var li,jl;function wg(){if(jl)return li;jl=1;var e=800,t=16,r=Date.now;function n(a){var i=0,o=0;return function(){var s=r(),c=t-(s-o);if(o=s,c>0){if(++i>=e)return arguments[0]}else i=0;return a.apply(void 0,arguments)}}return li=n,li}var fi,Ol;function ql(){if(Ol)return fi;Ol=1;var e=Sg(),t=wg(),r=t(e);return fi=r,fi}var pi,Pl;function wr(){if(Pl)return pi;Pl=1;var e=je(),t=Rl(),r=ql();function n(a,i){return r(t(a,i,e),a+"")}return pi=n,pi}var hi,Al;function Ll(){if(Al)return hi;Al=1;function e(t,r,n,a){for(var i=t.length,o=n+(a?1:-1);a?o--:++o<i;)if(r(t[o],o,t))return o;return-1}return hi=e,hi}var vi,Dl;function Eg(){if(Dl)return vi;Dl=1;function e(t){return t!==t}return vi=e,vi}var gi,Ml;function Tg(){if(Ml)return gi;Ml=1;function e(t,r,n){for(var a=n-1,i=t.length;++a<i;)if(t[a]===r)return a;return-1}return gi=e,gi}var mi,Bl;function Cg(){if(Bl)return mi;Bl=1;var e=Ll(),t=Eg(),r=Tg();function n(a,i,o){return i===i?r(a,i,o):e(a,t,o)}return mi=n,mi}var yi,Wl;function Ng(){if(Wl)return yi;Wl=1;var e=Cg();function t(r,n){var a=r==null?0:r.length;return!!a&&e(r,n,0)>-1}return yi=t,yi}var bi,Fl;function Rg(){if(Fl)return bi;Fl=1;function e(t,r,n){for(var a=-1,i=t==null?0:t.length;++a<i;)if(n(r,t[a]))return!0;return!1}return bi=e,bi}var xi,$l;function Ig(){if($l)return xi;$l=1;function e(){}return xi=e,xi}var _i,zl;function jg(){if(zl)return _i;zl=1;var e=Ec(),t=Ig(),r=la(),n=1/0,a=e&&1/r(new e([,-0]))[1]==n?function(i){return new e(i)}:t;return _i=a,_i}var ki,Hl;function Og(){if(Hl)return ki;Hl=1;var e=fd(),t=Ng(),r=Rg(),n=vd(),a=jg(),i=la(),o=200;function s(c,u,d){var l=-1,p=t,h=c.length,m=!0,g=[],v=g;if(d)m=!1,p=r;else if(h>=o){var x=u?null:a(c);if(x)return i(x);m=!1,p=n,v=new e}else v=u?[]:g;e:for(;++l<h;){var b=c[l],_=u?u(b):b;if(b=d||b!==0?b:0,m&&_===_){for(var y=v.length;y--;)if(v[y]===_)continue e;u&&v.push(_),g.push(b)}else p(v,_,d)||(v!==g&&v.push(_),g.push(b))}return g}return ki=s,ki}var Si,Gl;function Ul(){if(Gl)return Si;Gl=1;var e=xe(),t=ye();function r(n){return t(n)&&e(n)}return Si=r,Si}var wi,Kl;function qg(){if(Kl)return wi;Kl=1;var e=si(),t=wr(),r=Og(),n=Ul(),a=t(function(i){return r(e(i,1,n,!0))});return wi=a,wi}var Ei,Jl;function Pg(){if(Jl)return Ei;Jl=1;var e=_r();function t(r,n){return e(n,function(a){return r[a]})}return Ei=t,Ei}var Ti,Vl;function Yl(){if(Vl)return Ti;Vl=1;var e=Pg(),t=we();function r(n){return n==null?[]:e(n,t(n))}return Ti=r,Ti}var Ci,Xl;function le(){if(Xl)return Ci;Xl=1;var e;if(typeof Ar=="function")try{e={clone:Fv(),constant:Hn(),each:sd(),filter:nl(),has:ol(),isArray:ne(),isEmpty:lg(),isFunction:Ve(),isUndefined:cl(),keys:we(),map:pl(),reduce:ml(),size:bg(),transform:xg(),union:qg(),values:Yl()}}catch{}return e||(e=window._),Ci=e,Ci}var Ni,Zl;function Ri(){if(Zl)return Ni;Zl=1;var e=le();Ni=a;var t="\0",r="\0",n="";function a(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={}}a.prototype._nodeCount=0,a.prototype._edgeCount=0,a.prototype.isDirected=function(){return this._isDirected},a.prototype.isMultigraph=function(){return this._isMultigraph},a.prototype.isCompound=function(){return this._isCompound},a.prototype.setGraph=function(d){return this._label=d,this},a.prototype.graph=function(){return this._label},a.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},a.prototype.nodeCount=function(){return this._nodeCount},a.prototype.nodes=function(){return e.keys(this._nodes)},a.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(l){return e.isEmpty(d._in[l])})},a.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(l){return e.isEmpty(d._out[l])})},a.prototype.setNodes=function(d,l){var p=arguments,h=this;return e.each(d,function(m){p.length>1?h.setNode(m,l):h.setNode(m)}),this},a.prototype.setNode=function(d,l){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=l),this):(this._nodes[d]=arguments.length>1?l: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)},a.prototype.node=function(d){return this._nodes[d]},a.prototype.hasNode=function(d){return e.has(this._nodes,d)},a.prototype.removeNode=function(d){var l=this;if(e.has(this._nodes,d)){var p=function(h){l.removeEdge(l._edgeObjs[h])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(h){l.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},a.prototype.setParent=function(d,l){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(l))l=r;else{l+="";for(var p=l;!e.isUndefined(p);p=this.parent(p))if(p===d)throw new Error("Setting "+l+" as parent of "+d+" would create a cycle");this.setNode(l)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=l,this._children[l][d]=!0,this},a.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},a.prototype.parent=function(d){if(this._isCompound){var l=this._parent[d];if(l!==r)return l}},a.prototype.children=function(d){if(e.isUndefined(d)&&(d=r),this._isCompound){var l=this._children[d];if(l)return e.keys(l)}else{if(d===r)return this.nodes();if(this.hasNode(d))return[]}},a.prototype.predecessors=function(d){var l=this._preds[d];if(l)return e.keys(l)},a.prototype.successors=function(d){var l=this._sucs[d];if(l)return e.keys(l)},a.prototype.neighbors=function(d){var l=this.predecessors(d);if(l)return e.union(l,this.successors(d))},a.prototype.isLeaf=function(d){var l;return this.isDirected()?l=this.successors(d):l=this.neighbors(d),l.length===0},a.prototype.filterNodes=function(d){var l=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});l.setGraph(this.graph());var p=this;e.each(this._nodes,function(g,v){d(v)&&l.setNode(v,g)}),e.each(this._edgeObjs,function(g){l.hasNode(g.v)&&l.hasNode(g.w)&&l.setEdge(g,p.edge(g))});var h={};function m(g){var v=p.parent(g);return v===void 0||l.hasNode(v)?(h[g]=v,v):v in h?h[v]:m(v)}return this._isCompound&&e.each(l.nodes(),function(g){l.setParent(g,m(g))}),l},a.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},a.prototype.edgeCount=function(){return this._edgeCount},a.prototype.edges=function(){return e.values(this._edgeObjs)},a.prototype.setPath=function(d,l){var p=this,h=arguments;return e.reduce(d,function(m,g){return h.length>1?p.setEdge(m,g,l):p.setEdge(m,g),g}),this},a.prototype.setEdge=function(){var d,l,p,h,m=!1,g=arguments[0];typeof g=="object"&&g!==null&&"v"in g?(d=g.v,l=g.w,p=g.name,arguments.length===2&&(h=arguments[1],m=!0)):(d=g,l=arguments[1],p=arguments[3],arguments.length>2&&(h=arguments[2],m=!0)),d=""+d,l=""+l,e.isUndefined(p)||(p=""+p);var v=s(this._isDirected,d,l,p);if(e.has(this._edgeLabels,v))return m&&(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(l),this._edgeLabels[v]=m?h:this._defaultEdgeLabelFn(d,l,p);var x=c(this._isDirected,d,l,p);return d=x.v,l=x.w,Object.freeze(x),this._edgeObjs[v]=x,i(this._preds[l],d),i(this._sucs[d],l),this._in[l][v]=x,this._out[d][v]=x,this._edgeCount++,this},a.prototype.edge=function(d,l,p){var h=arguments.length===1?u(this._isDirected,arguments[0]):s(this._isDirected,d,l,p);return this._edgeLabels[h]},a.prototype.hasEdge=function(d,l,p){var h=arguments.length===1?u(this._isDirected,arguments[0]):s(this._isDirected,d,l,p);return e.has(this._edgeLabels,h)},a.prototype.removeEdge=function(d,l,p){var h=arguments.length===1?u(this._isDirected,arguments[0]):s(this._isDirected,d,l,p),m=this._edgeObjs[h];return m&&(d=m.v,l=m.w,delete this._edgeLabels[h],delete this._edgeObjs[h],o(this._preds[l],d),o(this._sucs[d],l),delete this._in[l][h],delete this._out[d][h],this._edgeCount--),this},a.prototype.inEdges=function(d,l){var p=this._in[d];if(p){var h=e.values(p);return l?e.filter(h,function(m){return m.v===l}):h}},a.prototype.outEdges=function(d,l){var p=this._out[d];if(p){var h=e.values(p);return l?e.filter(h,function(m){return m.w===l}):h}},a.prototype.nodeEdges=function(d,l){var p=this.inEdges(d,l);if(p)return p.concat(this.outEdges(d,l))};function i(d,l){d[l]?d[l]++:d[l]=1}function o(d,l){--d[l]||delete d[l]}function s(d,l,p,h){var m=""+l,g=""+p;if(!d&&m>g){var v=m;m=g,g=v}return m+n+g+n+(e.isUndefined(h)?t:h)}function c(d,l,p,h){var m=""+l,g=""+p;if(!d&&m>g){var v=m;m=g,g=v}var x={v:m,w:g};return h&&(x.name=h),x}function u(d,l){return s(d,l.v,l.w,l.name)}return Ni}var Ii,Ql;function Ag(){return Ql||(Ql=1,Ii="2.1.8"),Ii}var ji,ef;function Lg(){return ef||(ef=1,ji={Graph:Ri(),version:Ag()}),ji}var Oi,rf;function Dg(){if(rf)return Oi;rf=1;var e=le(),t=Ri();Oi={write:r,read:i};function r(o){var s={options:{directed:o.isDirected(),multigraph:o.isMultigraph(),compound:o.isCompound()},nodes:n(o),edges:a(o)};return e.isUndefined(o.graph())||(s.value=e.clone(o.graph())),s}function n(o){return e.map(o.nodes(),function(s){var c=o.node(s),u=o.parent(s),d={v:s};return e.isUndefined(c)||(d.value=c),e.isUndefined(u)||(d.parent=u),d})}function a(o){return e.map(o.edges(),function(s){var c=o.edge(s),u={v:s.v,w:s.w};return e.isUndefined(s.name)||(u.name=s.name),e.isUndefined(c)||(u.value=c),u})}function i(o){var s=new t(o.options).setGraph(o.value);return e.each(o.nodes,function(c){s.setNode(c.v,c.value),c.parent&&s.setParent(c.v,c.parent)}),e.each(o.edges,function(c){s.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),s}return Oi}var qi,tf;function Mg(){if(tf)return qi;tf=1;var e=le();qi=t;function t(r){var n={},a=[],i;function o(s){e.has(n,s)||(n[s]=!0,i.push(s),e.each(r.successors(s),o),e.each(r.predecessors(s),o))}return e.each(r.nodes(),function(s){i=[],o(s),i.length&&a.push(i)}),a}return qi}var Pi,nf;function af(){if(nf)return Pi;nf=1;var e=le();Pi=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(r){return r.key})},t.prototype.has=function(r){return e.has(this._keyIndices,r)},t.prototype.priority=function(r){var n=this._keyIndices[r];if(n!==void 0)return this._arr[n].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(r,n){var a=this._keyIndices;if(r=String(r),!e.has(a,r)){var i=this._arr,o=i.length;return a[r]=o,i.push({key:r,priority:n}),this._decrease(o),!0}return!1},t.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},t.prototype.decrease=function(r,n){var a=this._keyIndices[r];if(n>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[a].priority+" New: "+n);this._arr[a].priority=n,this._decrease(a)},t.prototype._heapify=function(r){var n=this._arr,a=2*r,i=a+1,o=r;a<n.length&&(o=n[a].priority<n[o].priority?a:o,i<n.length&&(o=n[i].priority<n[o].priority?i:o),o!==r&&(this._swap(r,o),this._heapify(o)))},t.prototype._decrease=function(r){for(var n=this._arr,a=n[r].priority,i;r!==0&&(i=r>>1,!(n[i].priority<a));)this._swap(r,i),r=i},t.prototype._swap=function(r,n){var a=this._arr,i=this._keyIndices,o=a[r],s=a[n];a[r]=s,a[n]=o,i[s.key]=r,i[o.key]=n},Pi}var Ai,of;function sf(){if(of)return Ai;of=1;var e=le(),t=af();Ai=n;var r=e.constant(1);function n(i,o,s,c){return a(i,String(o),s||r,c||function(u){return i.outEdges(u)})}function a(i,o,s,c){var u={},d=new t,l,p,h=function(m){var g=m.v!==l?m.v:m.w,v=u[g],x=s(m),b=p.distance+x;if(x<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+x);b<v.distance&&(v.distance=b,v.predecessor=l,d.decrease(g,b))};for(i.nodes().forEach(function(m){var g=m===o?0:Number.POSITIVE_INFINITY;u[m]={distance:g},d.add(m,g)});d.size()>0&&(l=d.removeMin(),p=u[l],p.distance!==Number.POSITIVE_INFINITY);)c(l).forEach(h);return u}return Ai}var Li,uf;function Bg(){if(uf)return Li;uf=1;var e=sf(),t=le();Li=r;function r(n,a,i){return t.transform(n.nodes(),function(o,s){o[s]=e(n,s,a,i)},{})}return Li}var Di,cf;function df(){if(cf)return Di;cf=1;var e=le();Di=t;function t(r){var n=0,a=[],i={},o=[];function s(c){var u=i[c]={onStack:!0,lowlink:n,index:n++};if(a.push(c),r.successors(c).forEach(function(p){e.has(i,p)?i[p].onStack&&(u.lowlink=Math.min(u.lowlink,i[p].index)):(s(p),u.lowlink=Math.min(u.lowlink,i[p].lowlink))}),u.lowlink===u.index){var d=[],l;do l=a.pop(),i[l].onStack=!1,d.push(l);while(c!==l);o.push(d)}}return r.nodes().forEach(function(c){e.has(i,c)||s(c)}),o}return Di}var Mi,lf;function Wg(){if(lf)return Mi;lf=1;var e=le(),t=df();Mi=r;function r(n){return e.filter(t(n),function(a){return a.length>1||a.length===1&&n.hasEdge(a[0],a[0])})}return Mi}var Bi,ff;function Fg(){if(ff)return Bi;ff=1;var e=le();Bi=r;var t=e.constant(1);function r(a,i,o){return n(a,i||t,o||function(s){return a.outEdges(s)})}function n(a,i,o){var s={},c=a.nodes();return c.forEach(function(u){s[u]={},s[u][u]={distance:0},c.forEach(function(d){u!==d&&(s[u][d]={distance:Number.POSITIVE_INFINITY})}),o(u).forEach(function(d){var l=d.v===u?d.w:d.v,p=i(d);s[u][l]={distance:p,predecessor:u}})}),c.forEach(function(u){var d=s[u];c.forEach(function(l){var p=s[l];c.forEach(function(h){var m=p[u],g=d[h],v=p[h],x=m.distance+g.distance;x<v.distance&&(v.distance=x,v.predecessor=g.predecessor)})})}),s}return Bi}var Wi,pf;function hf(){if(pf)return Wi;pf=1;var e=le();Wi=t,t.CycleException=r;function t(n){var a={},i={},o=[];function s(c){if(e.has(i,c))throw new r;e.has(a,c)||(i[c]=!0,a[c]=!0,e.each(n.predecessors(c),s),delete i[c],o.push(c))}if(e.each(n.sinks(),s),e.size(a)!==n.nodeCount())throw new r;return o}function r(){}return r.prototype=new Error,Wi}var Fi,vf;function $g(){if(vf)return Fi;vf=1;var e=hf();Fi=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Fi}var $i,gf;function mf(){if(gf)return $i;gf=1;var e=le();$i=t;function t(n,a,i){e.isArray(a)||(a=[a]);var o=(n.isDirected()?n.successors:n.neighbors).bind(n),s=[],c={};return e.each(a,function(u){if(!n.hasNode(u))throw new Error("Graph does not have node: "+u);r(n,u,i==="post",c,o,s)}),s}function r(n,a,i,o,s,c){e.has(o,a)||(o[a]=!0,i||c.push(a),e.each(s(a),function(u){r(n,u,i,o,s,c)}),i&&c.push(a))}return $i}var zi,yf;function zg(){if(yf)return zi;yf=1;var e=mf();zi=t;function t(r,n){return e(r,n,"post")}return zi}var Hi,bf;function Hg(){if(bf)return Hi;bf=1;var e=mf();Hi=t;function t(r,n){return e(r,n,"pre")}return Hi}var Gi,xf;function Gg(){if(xf)return Gi;xf=1;var e=le(),t=Ri(),r=af();Gi=n;function n(a,i){var o=new t,s={},c=new r,u;function d(p){var h=p.v===u?p.w:p.v,m=c.priority(h);if(m!==void 0){var g=i(p);g<m&&(s[h]=u,c.decrease(h,g))}}if(a.nodeCount()===0)return o;e.each(a.nodes(),function(p){c.add(p,Number.POSITIVE_INFINITY),o.setNode(p)}),c.decrease(a.nodes()[0],0);for(var l=!1;c.size()>0;){if(u=c.removeMin(),e.has(s,u))o.setEdge(u,s[u]);else{if(l)throw new Error("Input graph is not connected: "+a);l=!0}a.nodeEdges(u).forEach(d)}return o}return Gi}var Ui,_f;function Ug(){return _f||(_f=1,Ui={components:Mg(),dijkstra:sf(),dijkstraAll:Bg(),findCycles:Wg(),floydWarshall:Fg(),isAcyclic:$g(),postorder:zg(),preorder:Hg(),prim:Gg(),tarjan:df(),topsort:hf()}),Ui}var Ki,kf;function Kg(){if(kf)return Ki;kf=1;var e=Lg();return Ki={Graph:e.Graph,json:Dg(),alg:Ug(),version:e.version},Ki}var Ji,Sf;function ve(){if(Sf)return Ji;Sf=1;var e;if(typeof Ar=="function")try{e=Kg()}catch{}return e||(e=window.graphlib),Ji=e,Ji}var Vi,wf;function Jg(){if(wf)return Vi;wf=1;var e=Kc(),t=1,r=4;function n(a){return e(a,t|r)}return Vi=n,Vi}var Yi,Ef;function Er(){if(Ef)return Yi;Ef=1;var e=Pe(),t=xe(),r=gr(),n=de();function a(i,o,s){if(!n(s))return!1;var c=typeof o;return(c=="number"?t(s)&&r(o,s.length):c=="string"&&o in s)?e(s[o],i):!1}return Yi=a,Yi}var Xi,Tf;function Vg(){if(Tf)return Xi;Tf=1;var e=wr(),t=Pe(),r=Er(),n=Ie(),a=Object.prototype,i=a.hasOwnProperty,o=e(function(s,c){s=Object(s);var u=-1,d=c.length,l=d>2?c[2]:void 0;for(l&&r(c[0],c[1],l)&&(d=1);++u<d;)for(var p=c[u],h=n(p),m=-1,g=h.length;++m<g;){var v=h[m],x=s[v];(x===void 0||t(x,a[v])&&!i.call(s,v))&&(s[v]=p[v])}return s});return Xi=o,Xi}var Zi,Cf;function Yg(){if(Cf)return Zi;Cf=1;var e=_e(),t=xe(),r=we();function n(a){return function(i,o,s){var c=Object(i);if(!t(i)){var u=e(o,3);i=r(i),o=function(l){return u(c[l],l,c)}}var d=a(i,o,s);return d>-1?c[u?i[d]:d]:void 0}}return Zi=n,Zi}var Qi,Nf;function Xg(){if(Nf)return Qi;Nf=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return Qi=t,Qi}var eo,Rf;function Zg(){if(Rf)return eo;Rf=1;var e=Xg(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return eo=r,eo}var ro,If;function Qg(){if(If)return ro;If=1;var e=Zg(),t=de(),r=Me(),n=NaN,a=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,o=/^0o[0-7]+$/i,s=parseInt;function c(u){if(typeof u=="number")return u;if(r(u))return n;if(t(u)){var d=typeof u.valueOf=="function"?u.valueOf():u;u=t(d)?d+"":d}if(typeof u!="string")return u===0?u:+u;u=e(u);var l=i.test(u);return l||o.test(u)?s(u.slice(2),l?2:8):a.test(u)?n:+u}return ro=c,ro}var to,jf;function Of(){if(jf)return to;jf=1;var e=Qg(),t=1/0,r=17976931348623157e292;function n(a){if(!a)return a===0?a:0;if(a=e(a),a===t||a===-t){var i=a<0?-1:1;return i*r}return a===a?a:0}return to=n,to}var no,qf;function em(){if(qf)return no;qf=1;var e=Of();function t(r){var n=e(r),a=n%1;return n===n?a?n-a:n:0}return no=t,no}var ao,Pf;function rm(){if(Pf)return ao;Pf=1;var e=Ll(),t=_e(),r=em(),n=Math.max;function a(i,o,s){var c=i==null?0:i.length;if(!c)return-1;var u=s==null?0:r(s);return u<0&&(u=n(c+u,0)),e(i,t(o,3),u)}return ao=a,ao}var io,Af;function tm(){if(Af)return io;Af=1;var e=Yg(),t=rm(),r=e(t);return io=r,io}var oo,Lf;function Df(){if(Lf)return oo;Lf=1;var e=si();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return oo=t,oo}var so,Mf;function nm(){if(Mf)return so;Mf=1;var e=Kn(),t=nd(),r=Ie();function n(a,i){return a==null?a:e(a,t(i),r)}return so=n,so}var uo,Bf;function am(){if(Bf)return uo;Bf=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return uo=e,uo}var co,Wf;function im(){if(Wf)return co;Wf=1;var e=hr(),t=Vn(),r=_e();function n(a,i){var o={};return i=r(i,3),t(a,function(s,c,u){e(o,c,i(s,c,u))}),o}return co=n,co}var lo,Ff;function fo(){if(Ff)return lo;Ff=1;var e=Me();function t(r,n,a){for(var i=-1,o=r.length;++i<o;){var s=r[i],c=n(s);if(c!=null&&(u===void 0?c===c&&!e(c):a(c,u)))var u=c,d=s}return d}return lo=t,lo}var po,$f;function om(){if($f)return po;$f=1;function e(t,r){return t>r}return po=e,po}var ho,zf;function sm(){if(zf)return ho;zf=1;var e=fo(),t=om(),r=je();function n(a){return a&&a.length?e(a,r,t):void 0}return ho=n,ho}var vo,Hf;function Gf(){if(Hf)return vo;Hf=1;var e=hr(),t=Pe();function r(n,a,i){(i!==void 0&&!t(n[a],i)||i===void 0&&!(a in n))&&e(n,a,i)}return vo=r,vo}var go,Uf;function um(){if(Uf)return go;Uf=1;var e=Ne(),t=br(),r=ye(),n="[object Object]",a=Function.prototype,i=Object.prototype,o=a.toString,s=i.hasOwnProperty,c=o.call(Object);function u(d){if(!r(d)||e(d)!=n)return!1;var l=t(d);if(l===null)return!0;var p=s.call(l,"constructor")&&l.constructor;return typeof p=="function"&&p instanceof p&&o.call(p)==c}return go=u,go}var mo,Kf;function Jf(){if(Kf)return mo;Kf=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return mo=e,mo}var yo,Vf;function cm(){if(Vf)return yo;Vf=1;var e=Ye(),t=Ie();function r(n){return e(n,t(n))}return yo=r,yo}var bo,Yf;function dm(){if(Yf)return bo;Yf=1;var e=Gf(),t=nc(),r=Lc(),n=ic(),a=Fc(),i=Xe(),o=ne(),s=Ul(),c=Le(),u=Ve(),d=de(),l=um(),p=er(),h=Jf(),m=cm();function g(v,x,b,_,y,S,w){var E=h(v,b),T=h(x,b),C=w.get(T);if(C){e(v,b,C);return}var R=S?S(E,T,b+"",v,x,w):void 0,A=R===void 0;if(A){var B=o(T),N=!B&&c(T),M=!B&&!N&&p(T);R=T,B||N||M?o(E)?R=E:s(E)?R=n(E):N?(A=!1,R=t(T,!0)):M?(A=!1,R=r(T,!0)):R=[]:l(T)||i(T)?(R=E,i(E)?R=m(E):(!d(E)||u(E))&&(R=a(T))):A=!1}A&&(w.set(T,R),y(R,T,_,S,w),w.delete(T)),e(v,b,R)}return bo=g,bo}var xo,Xf;function lm(){if(Xf)return xo;Xf=1;var e=pr(),t=Gf(),r=Kn(),n=dm(),a=de(),i=Ie(),o=Jf();function s(c,u,d,l,p){c!==u&&r(u,function(h,m){if(p||(p=new e),a(h))n(c,u,m,d,s,l,p);else{var g=l?l(o(c,m),h,m+"",c,u,p):void 0;g===void 0&&(g=h),t(c,m,g)}},i)}return xo=s,xo}var _o,Zf;function fm(){if(Zf)return _o;Zf=1;var e=wr(),t=Er();function r(n){return e(function(a,i){var o=-1,s=i.length,c=s>1?i[s-1]:void 0,u=s>2?i[2]:void 0;for(c=n.length>3&&typeof c=="function"?(s--,c):void 0,u&&t(i[0],i[1],u)&&(c=s<3?void 0:c,s=1),a=Object(a);++o<s;){var d=i[o];d&&n(a,d,o,c)}return a})}return _o=r,_o}var ko,Qf;function pm(){if(Qf)return ko;Qf=1;var e=lm(),t=fm(),r=t(function(n,a,i){e(n,a,i)});return ko=r,ko}var So,ep;function rp(){if(ep)return So;ep=1;function e(t,r){return t<r}return So=e,So}var wo,tp;function hm(){if(tp)return wo;tp=1;var e=fo(),t=rp(),r=je();function n(a){return a&&a.length?e(a,r,t):void 0}return wo=n,wo}var Eo,np;function vm(){if(np)return Eo;np=1;var e=fo(),t=_e(),r=rp();function n(a,i){return a&&a.length?e(a,t(i,2),r):void 0}return Eo=n,Eo}var To,ap;function gm(){if(ap)return To;ap=1;var e=he(),t=function(){return e.Date.now()};return To=t,To}var Co,ip;function mm(){if(ip)return Co;ip=1;var e=vr(),t=kr(),r=gr(),n=de(),a=tr();function i(o,s,c,u){if(!n(o))return o;s=t(s,o);for(var d=-1,l=s.length,p=l-1,h=o;h!=null&&++d<l;){var m=a(s[d]),g=c;if(m==="__proto__"||m==="constructor"||m==="prototype")return o;if(d!=p){var v=h[m];g=u?u(v,m,h):void 0,g===void 0&&(g=n(v)?v:r(s[d+1])?[]:{})}e(h,m,g),h=h[m]}return o}return Co=i,Co}var No,op;function ym(){if(op)return No;op=1;var e=Sr(),t=mm(),r=kr();function n(a,i,o){for(var s=-1,c=i.length,u={};++s<c;){var d=i[s],l=e(a,d);o(l,d)&&t(u,r(d,a),l)}return u}return No=n,No}var Ro,sp;function bm(){if(sp)return Ro;sp=1;var e=ym(),t=Vd();function r(n,a){return e(n,a,function(i,o){return t(n,o)})}return Ro=r,Ro}var Io,up;function xm(){if(up)return Io;up=1;var e=Df(),t=Rl(),r=ql();function n(a){return r(t(a,void 0,e),a+"")}return Io=n,Io}var jo,cp;function _m(){if(cp)return jo;cp=1;var e=bm(),t=xm(),r=t(function(n,a){return n==null?{}:e(n,a)});return jo=r,jo}var Oo,dp;function km(){if(dp)return Oo;dp=1;var e=Math.ceil,t=Math.max;function r(n,a,i,o){for(var s=-1,c=t(e((a-n)/(i||1)),0),u=Array(c);c--;)u[o?c:++s]=n,n+=i;return u}return Oo=r,Oo}var qo,lp;function Sm(){if(lp)return qo;lp=1;var e=km(),t=Er(),r=Of();function n(a){return function(i,o,s){return s&&typeof s!="number"&&t(i,o,s)&&(o=s=void 0),i=r(i),o===void 0?(o=i,i=0):o=r(o),s=s===void 0?i<o?1:-1:r(s),e(i,o,s,a)}}return qo=n,qo}var Po,fp;function wm(){if(fp)return Po;fp=1;var e=Sm(),t=e();return Po=t,Po}var Ao,pp;function Em(){if(pp)return Ao;pp=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return Ao=e,Ao}var Lo,hp;function Tm(){if(hp)return Lo;hp=1;var e=Me();function t(r,n){if(r!==n){var a=r!==void 0,i=r===null,o=r===r,s=e(r),c=n!==void 0,u=n===null,d=n===n,l=e(n);if(!u&&!l&&!s&&r>n||s&&c&&d&&!u&&!l||i&&c&&d||!a&&d||!o)return 1;if(!i&&!s&&!l&&r<n||l&&a&&o&&!i&&!s||u&&a&&o||!c&&o||!d)return-1}return 0}return Lo=t,Lo}var Do,vp;function Cm(){if(vp)return Do;vp=1;var e=Tm();function t(r,n,a){for(var i=-1,o=r.criteria,s=n.criteria,c=o.length,u=a.length;++i<c;){var d=e(o[i],s[i]);if(d){if(i>=u)return d;var l=a[i];return d*(l=="desc"?-1:1)}}return r.index-n.index}return Do=t,Do}var Mo,gp;function Nm(){if(gp)return Mo;gp=1;var e=_r(),t=Sr(),r=_e(),n=ll(),a=Em(),i=mr(),o=Cm(),s=je(),c=ne();function u(d,l,p){l.length?l=e(l,function(g){return c(g)?function(v){return t(v,g.length===1?g[0]:g)}:g}):l=[s];var h=-1;l=e(l,i(r));var m=n(d,function(g,v,x){var b=e(l,function(_){return _(g)});return{criteria:b,index:++h,value:g}});return a(m,function(g,v){return o(g,v,p)})}return Mo=u,Mo}var Bo,mp;function Rm(){if(mp)return Bo;mp=1;var e=si(),t=Nm(),r=wr(),n=Er(),a=r(function(i,o){if(i==null)return[];var s=o.length;return s>1&&n(i,o[0],o[1])?o=[]:s>2&&n(o[0],o[1],o[2])&&(o=[o[0]]),t(i,e(o,1),[])});return Bo=a,Bo}var Wo,yp;function Im(){if(yp)return Wo;yp=1;var e=Wd(),t=0;function r(n){var a=++t;return e(n)+a}return Wo=r,Wo}var Fo,bp;function jm(){if(bp)return Fo;bp=1;function e(t,r,n){for(var a=-1,i=t.length,o=r.length,s={};++a<i;){var c=a<o?r[a]:void 0;n(s,t[a],c)}return s}return Fo=e,Fo}var $o,xp;function Om(){if(xp)return $o;xp=1;var e=vr(),t=jm();function r(n,a){return t(n||[],a||[],e)}return $o=r,$o}var zo,_p;function Q(){if(_p)return zo;_p=1;var e;if(typeof Ar=="function")try{e={cloneDeep:Jg(),constant:Hn(),defaults:Vg(),each:sd(),filter:nl(),find:tm(),flatten:Df(),forEach:id(),forIn:nm(),has:ol(),isUndefined:cl(),last:am(),map:pl(),mapValues:im(),max:sm(),merge:pm(),min:hm(),minBy:vm(),now:gm(),pick:_m(),range:wm(),reduce:ml(),sortBy:Rm(),uniqueId:Im(),values:Yl(),zipObject:Om()}}catch{}return e||(e=window._),zo=e,zo}var Ho,kp;function qm(){if(kp)return Ho;kp=1,Ho=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,a=n._prev;if(a!==n)return t(a),a},e.prototype.enqueue=function(n){var a=this._sentinel;n._prev&&n._next&&t(n),n._next=a._next,a._next._prev=n,a._next=n,n._prev=a},e.prototype.toString=function(){for(var n=[],a=this._sentinel,i=a._prev;i!==a;)n.push(JSON.stringify(i,r)),i=i._prev;return"["+n.join(", ")+"]"};function t(n){n._prev._next=n._next,n._next._prev=n._prev,delete n._next,delete n._prev}function r(n,a){if(n!=="_next"&&n!=="_prev")return a}return Ho}var Go,Sp;function Pm(){if(Sp)return Go;Sp=1;var e=Q(),t=ve().Graph,r=qm();Go=a;var n=e.constant(1);function a(u,d){if(u.nodeCount()<=1)return[];var l=s(u,d||n),p=i(l.graph,l.buckets,l.zeroIdx);return e.flatten(e.map(p,function(h){return u.outEdges(h.v,h.w)}),!0)}function i(u,d,l){for(var p=[],h=d[d.length-1],m=d[0],g;u.nodeCount();){for(;g=m.dequeue();)o(u,d,l,g);for(;g=h.dequeue();)o(u,d,l,g);if(u.nodeCount()){for(var v=d.length-2;v>0;--v)if(g=d[v].dequeue(),g){p=p.concat(o(u,d,l,g,!0));break}}}return p}function o(u,d,l,p,h){var m=h?[]:void 0;return e.forEach(u.inEdges(p.v),function(g){var v=u.edge(g),x=u.node(g.v);h&&m.push({v:g.v,w:g.w}),x.out-=v,c(d,l,x)}),e.forEach(u.outEdges(p.v),function(g){var v=u.edge(g),x=g.w,b=u.node(x);b.in-=v,c(d,l,b)}),u.removeNode(p.v),m}function s(u,d){var l=new t,p=0,h=0;e.forEach(u.nodes(),function(v){l.setNode(v,{v,in:0,out:0})}),e.forEach(u.edges(),function(v){var x=l.edge(v.v,v.w)||0,b=d(v),_=x+b;l.setEdge(v.v,v.w,_),h=Math.max(h,l.node(v.v).out+=b),p=Math.max(p,l.node(v.w).in+=b)});var m=e.range(h+p+3).map(function(){return new r}),g=p+1;return e.forEach(l.nodes(),function(v){c(m,g,l.node(v))}),{graph:l,buckets:m,zeroIdx:g}}function c(u,d,l){l.out?l.in?u[l.out-l.in+d].enqueue(l):u[u.length-1].enqueue(l):u[0].enqueue(l)}return Go}var Uo,wp;function Am(){if(wp)return Uo;wp=1;var e=Q(),t=Pm();Uo={run:r,undo:a};function r(i){var o=i.graph().acyclicer==="greedy"?t(i,s(i)):n(i);e.forEach(o,function(c){var u=i.edge(c);i.removeEdge(c),u.forwardName=c.name,u.reversed=!0,i.setEdge(c.w,c.v,u,e.uniqueId("rev"))});function s(c){return function(u){return c.edge(u).weight}}}function n(i){var o=[],s={},c={};function u(d){e.has(c,d)||(c[d]=!0,s[d]=!0,e.forEach(i.outEdges(d),function(l){e.has(s,l.w)?o.push(l):u(l.w)}),delete s[d])}return e.forEach(i.nodes(),u),o}function a(i){e.forEach(i.edges(),function(o){var s=i.edge(o);if(s.reversed){i.removeEdge(o);var c=s.forwardName;delete s.reversed,delete s.forwardName,i.setEdge(o.w,o.v,s,c)}})}return Uo}var Ko,Ep;function oe(){if(Ep)return Ko;Ep=1;var e=Q(),t=ve().Graph;Ko={addDummyNode:r,simplify:n,asNonCompoundGraph:a,successorWeights:i,predecessorWeights:o,intersectRect:s,buildLayerMatrix:c,normalizeRanks:u,removeEmptyRanks:d,addBorderNode:l,maxRank:p,partition:h,time:m,notime:g};function r(v,x,b,_){var y;do y=e.uniqueId(_);while(v.hasNode(y));return b.dummy=x,v.setNode(y,b),y}function n(v){var x=new t().setGraph(v.graph());return e.forEach(v.nodes(),function(b){x.setNode(b,v.node(b))}),e.forEach(v.edges(),function(b){var _=x.edge(b.v,b.w)||{weight:0,minlen:1},y=v.edge(b);x.setEdge(b.v,b.w,{weight:_.weight+y.weight,minlen:Math.max(_.minlen,y.minlen)})}),x}function a(v){var x=new t({multigraph:v.isMultigraph()}).setGraph(v.graph());return e.forEach(v.nodes(),function(b){v.children(b).length||x.setNode(b,v.node(b))}),e.forEach(v.edges(),function(b){x.setEdge(b,v.edge(b))}),x}function i(v){var x=e.map(v.nodes(),function(b){var _={};return e.forEach(v.outEdges(b),function(y){_[y.w]=(_[y.w]||0)+v.edge(y).weight}),_});return e.zipObject(v.nodes(),x)}function o(v){var x=e.map(v.nodes(),function(b){var _={};return e.forEach(v.inEdges(b),function(y){_[y.v]=(_[y.v]||0)+v.edge(y).weight}),_});return e.zipObject(v.nodes(),x)}function s(v,x){var b=v.x,_=v.y,y=x.x-b,S=x.y-_,w=v.width/2,E=v.height/2;if(!y&&!S)throw new Error("Not possible to find intersection inside of the rectangle");var T,C;return Math.abs(S)*w>Math.abs(y)*E?(S<0&&(E=-E),T=E*y/S,C=E):(y<0&&(w=-w),T=w,C=w*S/y),{x:b+T,y:_+C}}function c(v){var x=e.map(e.range(p(v)+1),function(){return[]});return e.forEach(v.nodes(),function(b){var _=v.node(b),y=_.rank;e.isUndefined(y)||(x[y][_.order]=b)}),x}function u(v){var x=e.min(e.map(v.nodes(),function(b){return v.node(b).rank}));e.forEach(v.nodes(),function(b){var _=v.node(b);e.has(_,"rank")&&(_.rank-=x)})}function d(v){var x=e.min(e.map(v.nodes(),function(S){return v.node(S).rank})),b=[];e.forEach(v.nodes(),function(S){var w=v.node(S).rank-x;b[w]||(b[w]=[]),b[w].push(S)});var _=0,y=v.graph().nodeRankFactor;e.forEach(b,function(S,w){e.isUndefined(S)&&w%y!==0?--_:_&&e.forEach(S,function(E){v.node(E).rank+=_})})}function l(v,x,b,_){var y={width:0,height:0};return arguments.length>=4&&(y.rank=b,y.order=_),r(v,"border",y,x)}function p(v){return e.max(e.map(v.nodes(),function(x){var b=v.node(x).rank;if(!e.isUndefined(b))return b}))}function h(v,x){var b={lhs:[],rhs:[]};return e.forEach(v,function(_){x(_)?b.lhs.push(_):b.rhs.push(_)}),b}function m(v,x){var b=e.now();try{return x()}finally{console.log(v+" time: "+(e.now()-b)+"ms")}}function g(v,x){return x()}return Ko}var Jo,Tp;function Lm(){if(Tp)return Jo;Tp=1;var e=Q(),t=oe();Jo={run:r,undo:a};function r(i){i.graph().dummyChains=[],e.forEach(i.edges(),function(o){n(i,o)})}function n(i,o){var s=o.v,c=i.node(s).rank,u=o.w,d=i.node(u).rank,l=o.name,p=i.edge(o),h=p.labelRank;if(d!==c+1){i.removeEdge(o);var m,g,v;for(v=0,++c;c<d;++v,++c)p.points=[],g={width:0,height:0,edgeLabel:p,edgeObj:o,rank:c},m=t.addDummyNode(i,"edge",g,"_d"),c===h&&(g.width=p.width,g.height=p.height,g.dummy="edge-label",g.labelpos=p.labelpos),i.setEdge(s,m,{weight:p.weight},l),v===0&&i.graph().dummyChains.push(m),s=m;i.setEdge(s,u,{weight:p.weight},l)}}function a(i){e.forEach(i.graph().dummyChains,function(o){var s=i.node(o),c=s.edgeLabel,u;for(i.setEdge(s.edgeObj,c);s.dummy;)u=i.successors(o)[0],i.removeNode(o),c.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(c.x=s.x,c.y=s.y,c.width=s.width,c.height=s.height),o=u,s=i.node(o)})}return Jo}var Vo,Cp;function Tr(){if(Cp)return Vo;Cp=1;var e=Q();Vo={longestPath:t,slack:r};function t(n){var a={};function i(o){var s=n.node(o);if(e.has(a,o))return s.rank;a[o]=!0;var c=e.min(e.map(n.outEdges(o),function(u){return i(u.w)-n.edge(u).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),s.rank=c}e.forEach(n.sources(),i)}function r(n,a){return n.node(a.w).rank-n.node(a.v).rank-n.edge(a).minlen}return Vo}var Yo,Np;function Rp(){if(Np)return Yo;Np=1;var e=Q(),t=ve().Graph,r=Tr().slack;Yo=n;function n(s){var c=new t({directed:!1}),u=s.nodes()[0],d=s.nodeCount();c.setNode(u,{});for(var l,p;a(c,s)<d;)l=i(c,s),p=c.hasNode(l.v)?r(s,l):-r(s,l),o(c,s,p);return c}function a(s,c){function u(d){e.forEach(c.nodeEdges(d),function(l){var p=l.v,h=d===p?l.w:p;!s.hasNode(h)&&!r(c,l)&&(s.setNode(h,{}),s.setEdge(d,h,{}),u(h))})}return e.forEach(s.nodes(),u),s.nodeCount()}function i(s,c){return e.minBy(c.edges(),function(u){if(s.hasNode(u.v)!==s.hasNode(u.w))return r(c,u)})}function o(s,c,u){e.forEach(s.nodes(),function(d){c.node(d).rank+=u})}return Yo}var Xo,Ip;function Dm(){if(Ip)return Xo;Ip=1;var e=Q(),t=Rp(),r=Tr().slack,n=Tr().longestPath,a=ve().alg.preorder,i=ve().alg.postorder,o=oe().simplify;Xo=s,s.initLowLimValues=l,s.initCutValues=c,s.calcCutValue=d,s.leaveEdge=h,s.enterEdge=m,s.exchangeEdges=g;function s(_){_=o(_),n(_);var y=t(_);l(y),c(y,_);for(var S,w;S=h(y);)w=m(y,_,S),g(y,_,S,w)}function c(_,y){var S=i(_,_.nodes());S=S.slice(0,S.length-1),e.forEach(S,function(w){u(_,y,w)})}function u(_,y,S){var w=_.node(S),E=w.parent;_.edge(S,E).cutvalue=d(_,y,S)}function d(_,y,S){var w=_.node(S),E=w.parent,T=!0,C=y.edge(S,E),R=0;return C||(T=!1,C=y.edge(E,S)),R=C.weight,e.forEach(y.nodeEdges(S),function(A){var B=A.v===S,N=B?A.w:A.v;if(N!==E){var M=B===T,L=y.edge(A).weight;if(R+=M?L:-L,x(_,S,N)){var $=_.edge(S,N).cutvalue;R+=M?-$:$}}}),R}function l(_,y){arguments.length<2&&(y=_.nodes()[0]),p(_,{},1,y)}function p(_,y,S,w,E){var T=S,C=_.node(w);return y[w]=!0,e.forEach(_.neighbors(w),function(R){e.has(y,R)||(S=p(_,y,S,R,w))}),C.low=T,C.lim=S++,E?C.parent=E:delete C.parent,S}function h(_){return e.find(_.edges(),function(y){return _.edge(y).cutvalue<0})}function m(_,y,S){var w=S.v,E=S.w;y.hasEdge(w,E)||(w=S.w,E=S.v);var T=_.node(w),C=_.node(E),R=T,A=!1;T.lim>C.lim&&(R=C,A=!0);var B=e.filter(y.edges(),function(N){return A===b(_,_.node(N.v),R)&&A!==b(_,_.node(N.w),R)});return e.minBy(B,function(N){return r(y,N)})}function g(_,y,S,w){var E=S.v,T=S.w;_.removeEdge(E,T),_.setEdge(w.v,w.w,{}),l(_),c(_,y),v(_,y)}function v(_,y){var S=e.find(_.nodes(),function(E){return!y.node(E).parent}),w=a(_,S);w=w.slice(1),e.forEach(w,function(E){var T=_.node(E).parent,C=y.edge(E,T),R=!1;C||(C=y.edge(T,E),R=!0),y.node(E).rank=y.node(T).rank+(R?C.minlen:-C.minlen)})}function x(_,y,S){return _.hasEdge(y,S)}function b(_,y,S){return S.low<=y.lim&&y.lim<=S.lim}return Xo}var Zo,jp;function Mm(){if(jp)return Zo;jp=1;var e=Tr(),t=e.longestPath,r=Rp(),n=Dm();Zo=a;function a(c){switch(c.graph().ranker){case"network-simplex":s(c);break;case"tight-tree":o(c);break;case"longest-path":i(c);break;default:s(c)}}var i=t;function o(c){t(c),r(c)}function s(c){n(c)}return Zo}var Qo,Op;function Bm(){if(Op)return Qo;Op=1;var e=Q();Qo=t;function t(a){var i=n(a);e.forEach(a.graph().dummyChains,function(o){for(var s=a.node(o),c=s.edgeObj,u=r(a,i,c.v,c.w),d=u.path,l=u.lca,p=0,h=d[p],m=!0;o!==c.w;){if(s=a.node(o),m){for(;(h=d[p])!==l&&a.node(h).maxRank<s.rank;)p++;h===l&&(m=!1)}if(!m){for(;p<d.length-1&&a.node(h=d[p+1]).minRank<=s.rank;)p++;h=d[p]}a.setParent(o,h),o=a.successors(o)[0]}})}function r(a,i,o,s){var c=[],u=[],d=Math.min(i[o].low,i[s].low),l=Math.max(i[o].lim,i[s].lim),p,h;p=o;do p=a.parent(p),c.push(p);while(p&&(i[p].low>d||l>i[p].lim));for(h=p,p=s;(p=a.parent(p))!==h;)u.push(p);return{path:c.concat(u.reverse()),lca:h}}function n(a){var i={},o=0;function s(c){var u=o;e.forEach(a.children(c),s),i[c]={low:u,lim:o++}}return e.forEach(a.children(),s),i}return Qo}var es,qp;function Wm(){if(qp)return es;qp=1;var e=Q(),t=oe();es={run:r,cleanup:o};function r(s){var c=t.addDummyNode(s,"root",{},"_root"),u=a(s),d=e.max(e.values(u))-1,l=2*d+1;s.graph().nestingRoot=c,e.forEach(s.edges(),function(h){s.edge(h).minlen*=l});var p=i(s)+1;e.forEach(s.children(),function(h){n(s,c,l,p,d,u,h)}),s.graph().nodeRankFactor=l}function n(s,c,u,d,l,p,h){var m=s.children(h);if(!m.length){h!==c&&s.setEdge(c,h,{weight:0,minlen:u});return}var g=t.addBorderNode(s,"_bt"),v=t.addBorderNode(s,"_bb"),x=s.node(h);s.setParent(g,h),x.borderTop=g,s.setParent(v,h),x.borderBottom=v,e.forEach(m,function(b){n(s,c,u,d,l,p,b);var _=s.node(b),y=_.borderTop?_.borderTop:b,S=_.borderBottom?_.borderBottom:b,w=_.borderTop?d:2*d,E=y!==S?1:l-p[h]+1;s.setEdge(g,y,{weight:w,minlen:E,nestingEdge:!0}),s.setEdge(S,v,{weight:w,minlen:E,nestingEdge:!0})}),s.parent(h)||s.setEdge(c,g,{weight:0,minlen:l+p[h]})}function a(s){var c={};function u(d,l){var p=s.children(d);p&&p.length&&e.forEach(p,function(h){u(h,l+1)}),c[d]=l}return e.forEach(s.children(),function(d){u(d,1)}),c}function i(s){return e.reduce(s.edges(),function(c,u){return c+s.edge(u).weight},0)}function o(s){var c=s.graph();s.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(s.edges(),function(u){var d=s.edge(u);d.nestingEdge&&s.removeEdge(u)})}return es}var rs,Pp;function Fm(){if(Pp)return rs;Pp=1;var e=Q(),t=oe();rs=r;function r(a){function i(o){var s=a.children(o),c=a.node(o);if(s.length&&e.forEach(s,i),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var u=c.minRank,d=c.maxRank+1;u<d;++u)n(a,"borderLeft","_bl",o,c,u),n(a,"borderRight","_br",o,c,u)}}e.forEach(a.children(),i)}function n(a,i,o,s,c,u){var d={width:0,height:0,rank:u,borderType:i},l=c[i][u-1],p=t.addDummyNode(a,"border",d,o);c[i][u]=p,a.setParent(p,s),l&&a.setEdge(l,p,{weight:1})}return rs}var ts,Ap;function $m(){if(Ap)return ts;Ap=1;var e=Q();ts={adjust:t,undo:r};function t(u){var d=u.graph().rankdir.toLowerCase();(d==="lr"||d==="rl")&&n(u)}function r(u){var d=u.graph().rankdir.toLowerCase();(d==="bt"||d==="rl")&&i(u),(d==="lr"||d==="rl")&&(s(u),n(u))}function n(u){e.forEach(u.nodes(),function(d){a(u.node(d))}),e.forEach(u.edges(),function(d){a(u.edge(d))})}function a(u){var d=u.width;u.width=u.height,u.height=d}function i(u){e.forEach(u.nodes(),function(d){o(u.node(d))}),e.forEach(u.edges(),function(d){var l=u.edge(d);e.forEach(l.points,o),e.has(l,"y")&&o(l)})}function o(u){u.y=-u.y}function s(u){e.forEach(u.nodes(),function(d){c(u.node(d))}),e.forEach(u.edges(),function(d){var l=u.edge(d);e.forEach(l.points,c),e.has(l,"x")&&c(l)})}function c(u){var d=u.x;u.x=u.y,u.y=d}return ts}var ns,Lp;function zm(){if(Lp)return ns;Lp=1;var e=Q();ns=t;function t(r){var n={},a=e.filter(r.nodes(),function(u){return!r.children(u).length}),i=e.max(e.map(a,function(u){return r.node(u).rank})),o=e.map(e.range(i+1),function(){return[]});function s(u){if(!e.has(n,u)){n[u]=!0;var d=r.node(u);o[d.rank].push(u),e.forEach(r.successors(u),s)}}var c=e.sortBy(a,function(u){return r.node(u).rank});return e.forEach(c,s),o}return ns}var as,Dp;function Hm(){if(Dp)return as;Dp=1;var e=Q();as=t;function t(n,a){for(var i=0,o=1;o<a.length;++o)i+=r(n,a[o-1],a[o]);return i}function r(n,a,i){for(var o=e.zipObject(i,e.map(i,function(p,h){return h})),s=e.flatten(e.map(a,function(p){return e.sortBy(e.map(n.outEdges(p),function(h){return{pos:o[h.w],weight:n.edge(h).weight}}),"pos")}),!0),c=1;c<i.length;)c<<=1;var u=2*c-1;c-=1;var d=e.map(new Array(u),function(){return 0}),l=0;return e.forEach(s.forEach(function(p){var h=p.pos+c;d[h]+=p.weight;for(var m=0;h>0;)h%2&&(m+=d[h+1]),h=h-1>>1,d[h]+=p.weight;l+=p.weight*m})),l}return as}var is,Mp;function Gm(){if(Mp)return is;Mp=1;var e=Q();is=t;function t(r,n){return e.map(n,function(a){var i=r.inEdges(a);if(i.length){var o=e.reduce(i,function(s,c){var u=r.edge(c),d=r.node(c.v);return{sum:s.sum+u.weight*d.order,weight:s.weight+u.weight}},{sum:0,weight:0});return{v:a,barycenter:o.sum/o.weight,weight:o.weight}}else return{v:a}})}return is}var os,Bp;function Um(){if(Bp)return os;Bp=1;var e=Q();os=t;function t(a,i){var o={};e.forEach(a,function(c,u){var d=o[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:u};e.isUndefined(c.barycenter)||(d.barycenter=c.barycenter,d.weight=c.weight)}),e.forEach(i.edges(),function(c){var u=o[c.v],d=o[c.w];!e.isUndefined(u)&&!e.isUndefined(d)&&(d.indegree++,u.out.push(o[c.w]))});var s=e.filter(o,function(c){return!c.indegree});return r(s)}function r(a){var i=[];function o(u){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(u.barycenter)||d.barycenter>=u.barycenter)&&n(u,d)}}function s(u){return function(d){d.in.push(u),--d.indegree===0&&a.push(d)}}for(;a.length;){var c=a.pop();i.push(c),e.forEach(c.in.reverse(),o(c)),e.forEach(c.out,s(c))}return e.map(e.filter(i,function(u){return!u.merged}),function(u){return e.pick(u,["vs","i","barycenter","weight"])})}function n(a,i){var o=0,s=0;a.weight&&(o+=a.barycenter*a.weight,s+=a.weight),i.weight&&(o+=i.barycenter*i.weight,s+=i.weight),a.vs=i.vs.concat(a.vs),a.barycenter=o/s,a.weight=s,a.i=Math.min(i.i,a.i),i.merged=!0}return os}var ss,Wp;function Km(){if(Wp)return ss;Wp=1;var e=Q(),t=oe();ss=r;function r(i,o){var s=t.partition(i,function(g){return e.has(g,"barycenter")}),c=s.lhs,u=e.sortBy(s.rhs,function(g){return-g.i}),d=[],l=0,p=0,h=0;c.sort(a(!!o)),h=n(d,u,h),e.forEach(c,function(g){h+=g.vs.length,d.push(g.vs),l+=g.barycenter*g.weight,p+=g.weight,h=n(d,u,h)});var m={vs:e.flatten(d,!0)};return p&&(m.barycenter=l/p,m.weight=p),m}function n(i,o,s){for(var c;o.length&&(c=e.last(o)).i<=s;)o.pop(),i.push(c.vs),s++;return s}function a(i){return function(o,s){return o.barycenter<s.barycenter?-1:o.barycenter>s.barycenter?1:i?s.i-o.i:o.i-s.i}}return ss}var us,Fp;function Jm(){if(Fp)return us;Fp=1;var e=Q(),t=Gm(),r=Um(),n=Km();us=a;function a(s,c,u,d){var l=s.children(c),p=s.node(c),h=p?p.borderLeft:void 0,m=p?p.borderRight:void 0,g={};h&&(l=e.filter(l,function(S){return S!==h&&S!==m}));var v=t(s,l);e.forEach(v,function(S){if(s.children(S.v).length){var w=a(s,S.v,u,d);g[S.v]=w,e.has(w,"barycenter")&&o(S,w)}});var x=r(v,u);i(x,g);var b=n(x,d);if(h&&(b.vs=e.flatten([h,b.vs,m],!0),s.predecessors(h).length)){var _=s.node(s.predecessors(h)[0]),y=s.node(s.predecessors(m)[0]);e.has(b,"barycenter")||(b.barycenter=0,b.weight=0),b.barycenter=(b.barycenter*b.weight+_.order+y.order)/(b.weight+2),b.weight+=2}return b}function i(s,c){e.forEach(s,function(u){u.vs=e.flatten(u.vs.map(function(d){return c[d]?c[d].vs:d}),!0)})}function o(s,c){e.isUndefined(s.barycenter)?(s.barycenter=c.barycenter,s.weight=c.weight):(s.barycenter=(s.barycenter*s.weight+c.barycenter*c.weight)/(s.weight+c.weight),s.weight+=c.weight)}return us}var cs,$p;function Vm(){if($p)return cs;$p=1;var e=Q(),t=ve().Graph;cs=r;function r(a,i,o){var s=n(a),c=new t({compound:!0}).setGraph({root:s}).setDefaultNodeLabel(function(u){return a.node(u)});return e.forEach(a.nodes(),function(u){var d=a.node(u),l=a.parent(u);(d.rank===i||d.minRank<=i&&i<=d.maxRank)&&(c.setNode(u),c.setParent(u,l||s),e.forEach(a[o](u),function(p){var h=p.v===u?p.w:p.v,m=c.edge(h,u),g=e.isUndefined(m)?0:m.weight;c.setEdge(h,u,{weight:a.edge(p).weight+g})}),e.has(d,"minRank")&&c.setNode(u,{borderLeft:d.borderLeft[i],borderRight:d.borderRight[i]}))}),c}function n(a){for(var i;a.hasNode(i=e.uniqueId("_root")););return i}return cs}var ds,zp;function Ym(){if(zp)return ds;zp=1;var e=Q();ds=t;function t(r,n,a){var i={},o;e.forEach(a,function(s){for(var c=r.parent(s),u,d;c;){if(u=r.parent(c),u?(d=i[u],i[u]=c):(d=o,o=c),d&&d!==c){n.setEdge(d,c);return}c=u}})}return ds}var ls,Hp;function Xm(){if(Hp)return ls;Hp=1;var e=Q(),t=zm(),r=Hm(),n=Jm(),a=Vm(),i=Ym(),o=ve().Graph,s=oe();ls=c;function c(p){var h=s.maxRank(p),m=u(p,e.range(1,h+1),"inEdges"),g=u(p,e.range(h-1,-1,-1),"outEdges"),v=t(p);l(p,v);for(var x=Number.POSITIVE_INFINITY,b,_=0,y=0;y<4;++_,++y){d(_%2?m:g,_%4>=2),v=s.buildLayerMatrix(p);var S=r(p,v);S<x&&(y=0,b=e.cloneDeep(v),x=S)}l(p,b)}function u(p,h,m){return e.map(h,function(g){return a(p,g,m)})}function d(p,h){var m=new o;e.forEach(p,function(g){var v=g.graph().root,x=n(g,v,m,h);e.forEach(x.vs,function(b,_){g.node(b).order=_}),i(g,m,x.vs)})}function l(p,h){e.forEach(h,function(m){e.forEach(m,function(g,v){p.node(g).order=v})})}return ls}var fs,Gp;function Zm(){if(Gp)return fs;Gp=1;var e=Q(),t=ve().Graph,r=oe();fs={positionX:m,findType1Conflicts:n,findType2Conflicts:a,addConflict:o,hasConflict:s,verticalAlignment:c,horizontalCompaction:u,alignCoordinates:p,findSmallestWidthAlignment:l,balance:h};function n(x,b){var _={};function y(S,w){var E=0,T=0,C=S.length,R=e.last(w);return e.forEach(w,function(A,B){var N=i(x,A),M=N?x.node(N).order:C;(N||A===R)&&(e.forEach(w.slice(T,B+1),function(L){e.forEach(x.predecessors(L),function($){var U=x.node($),W=U.order;(W<E||M<W)&&!(U.dummy&&x.node(L).dummy)&&o(_,$,L)})}),T=B+1,E=M)}),w}return e.reduce(b,y),_}function a(x,b){var _={};function y(w,E,T,C,R){var A;e.forEach(e.range(E,T),function(B){A=w[B],x.node(A).dummy&&e.forEach(x.predecessors(A),function(N){var M=x.node(N);M.dummy&&(M.order<C||M.order>R)&&o(_,N,A)})})}function S(w,E){var T=-1,C,R=0;return e.forEach(E,function(A,B){if(x.node(A).dummy==="border"){var N=x.predecessors(A);N.length&&(C=x.node(N[0]).order,y(E,R,B,T,C),R=B,T=C)}y(E,R,E.length,C,w.length)}),E}return e.reduce(b,S),_}function i(x,b){if(x.node(b).dummy)return e.find(x.predecessors(b),function(_){return x.node(_).dummy})}function o(x,b,_){if(b>_){var y=b;b=_,_=y}var S=x[b];S||(x[b]=S={}),S[_]=!0}function s(x,b,_){if(b>_){var y=b;b=_,_=y}return e.has(x[b],_)}function c(x,b,_,y){var S={},w={},E={};return e.forEach(b,function(T){e.forEach(T,function(C,R){S[C]=C,w[C]=C,E[C]=R})}),e.forEach(b,function(T){var C=-1;e.forEach(T,function(R){var A=y(R);if(A.length){A=e.sortBy(A,function($){return E[$]});for(var B=(A.length-1)/2,N=Math.floor(B),M=Math.ceil(B);N<=M;++N){var L=A[N];w[R]===R&&C<E[L]&&!s(_,R,L)&&(w[L]=R,w[R]=S[R]=S[L],C=E[L])}}})}),{root:S,align:w}}function u(x,b,_,y,S){var w={},E=d(x,b,_,S),T=S?"borderLeft":"borderRight";function C(B,N){for(var M=E.nodes(),L=M.pop(),$={};L;)$[L]?B(L):($[L]=!0,M.push(L),M=M.concat(N(L))),L=M.pop()}function R(B){w[B]=E.inEdges(B).reduce(function(N,M){return Math.max(N,w[M.v]+E.edge(M))},0)}function A(B){var N=E.outEdges(B).reduce(function(L,$){return Math.min(L,w[$.w]-E.edge($))},Number.POSITIVE_INFINITY),M=x.node(B);N!==Number.POSITIVE_INFINITY&&M.borderType!==T&&(w[B]=Math.max(w[B],N))}return C(R,E.predecessors.bind(E)),C(A,E.successors.bind(E)),e.forEach(y,function(B){w[B]=w[_[B]]}),w}function d(x,b,_,y){var S=new t,w=x.graph(),E=g(w.nodesep,w.edgesep,y);return e.forEach(b,function(T){var C;e.forEach(T,function(R){var A=_[R];if(S.setNode(A),C){var B=_[C],N=S.edge(B,A);S.setEdge(B,A,Math.max(E(x,R,C),N||0))}C=R})}),S}function l(x,b){return e.minBy(e.values(b),function(_){var y=Number.NEGATIVE_INFINITY,S=Number.POSITIVE_INFINITY;return e.forIn(_,function(w,E){var T=v(x,E)/2;y=Math.max(w+T,y),S=Math.min(w-T,S)}),y-S})}function p(x,b){var _=e.values(b),y=e.min(_),S=e.max(_);e.forEach(["u","d"],function(w){e.forEach(["l","r"],function(E){var T=w+E,C=x[T],R;if(C!==b){var A=e.values(C);R=E==="l"?y-e.min(A):S-e.max(A),R&&(x[T]=e.mapValues(C,function(B){return B+R}))}})})}function h(x,b){return e.mapValues(x.ul,function(_,y){if(b)return x[b.toLowerCase()][y];var S=e.sortBy(e.map(x,y));return(S[1]+S[2])/2})}function m(x){var b=r.buildLayerMatrix(x),_=e.merge(n(x,b),a(x,b)),y={},S;e.forEach(["u","d"],function(E){S=E==="u"?b:e.values(b).reverse(),e.forEach(["l","r"],function(T){T==="r"&&(S=e.map(S,function(B){return e.values(B).reverse()}));var C=(E==="u"?x.predecessors:x.successors).bind(x),R=c(x,S,_,C),A=u(x,S,R.root,R.align,T==="r");T==="r"&&(A=e.mapValues(A,function(B){return-B})),y[E+T]=A})});var w=l(x,y);return p(y,w),h(y,x.graph().align)}function g(x,b,_){return function(y,S,w){var E=y.node(S),T=y.node(w),C=0,R;if(C+=E.width/2,e.has(E,"labelpos"))switch(E.labelpos.toLowerCase()){case"l":R=-E.width/2;break;case"r":R=E.width/2;break}if(R&&(C+=_?R:-R),R=0,C+=(E.dummy?b:x)/2,C+=(T.dummy?b:x)/2,C+=T.width/2,e.has(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":R=T.width/2;break;case"r":R=-T.width/2;break}return R&&(C+=_?R:-R),R=0,C}}function v(x,b){return x.node(b).width}return fs}var ps,Up;function Qm(){if(Up)return ps;Up=1;var e=Q(),t=oe(),r=Zm().positionX;ps=n;function n(i){i=t.asNonCompoundGraph(i),a(i),e.forEach(r(i),function(o,s){i.node(s).x=o})}function a(i){var o=t.buildLayerMatrix(i),s=i.graph().ranksep,c=0;e.forEach(o,function(u){var d=e.max(e.map(u,function(l){return i.node(l).height}));e.forEach(u,function(l){i.node(l).y=c+d/2}),c+=d+s})}return ps}var hs,Kp;function ey(){if(Kp)return hs;Kp=1;var e=Q(),t=Am(),r=Lm(),n=Mm(),a=oe().normalizeRanks,i=Bm(),o=oe().removeEmptyRanks,s=Wm(),c=Fm(),u=$m(),d=Xm(),l=Qm(),p=oe(),h=ve().Graph;hs=m;function m(k,I){var P=I&&I.debugTiming?p.time:p.notime;P("layout",function(){var O=P(" buildLayoutGraph",function(){return C(k)});P(" runLayout",function(){g(O,P)}),P(" updateInputGraph",function(){v(k,O)})})}function g(k,I){I(" makeSpaceForEdgeLabels",function(){R(k)}),I(" removeSelfEdges",function(){z(k)}),I(" acyclic",function(){t.run(k)}),I(" nestingGraph.run",function(){s.run(k)}),I(" rank",function(){n(p.asNonCompoundGraph(k))}),I(" injectEdgeLabelProxies",function(){A(k)}),I(" removeEmptyRanks",function(){o(k)}),I(" nestingGraph.cleanup",function(){s.cleanup(k)}),I(" normalizeRanks",function(){a(k)}),I(" assignRankMinMax",function(){B(k)}),I(" removeEdgeLabelProxies",function(){N(k)}),I(" normalize.run",function(){r.run(k)}),I(" parentDummyChains",function(){i(k)}),I(" addBorderSegments",function(){c(k)}),I(" order",function(){d(k)}),I(" insertSelfEdges",function(){K(k)}),I(" adjustCoordinateSystem",function(){u.adjust(k)}),I(" position",function(){l(k)}),I(" positionSelfEdges",function(){j(k)}),I(" removeBorderNodes",function(){W(k)}),I(" normalize.undo",function(){r.undo(k)}),I(" fixupEdgeLabelCoords",function(){$(k)}),I(" undoCoordinateSystem",function(){u.undo(k)}),I(" translateGraph",function(){M(k)}),I(" assignNodeIntersects",function(){L(k)}),I(" reversePoints",function(){U(k)}),I(" acyclic.undo",function(){t.undo(k)})}function v(k,I){e.forEach(k.nodes(),function(P){var O=k.node(P),H=I.node(P);O&&(O.x=H.x,O.y=H.y,I.children(P).length&&(O.width=H.width,O.height=H.height))}),e.forEach(k.edges(),function(P){var O=k.edge(P),H=I.edge(P);O.points=H.points,e.has(H,"x")&&(O.x=H.x,O.y=H.y)}),k.graph().width=I.graph().width,k.graph().height=I.graph().height}var x=["nodesep","edgesep","ranksep","marginx","marginy"],b={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},_=["acyclicer","ranker","rankdir","align"],y=["width","height"],S={width:0,height:0},w=["minlen","weight","width","height","labeloffset"],E={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},T=["labelpos"];function C(k){var I=new h({multigraph:!0,compound:!0}),P=G(k.graph());return I.setGraph(e.merge({},b,F(P,x),e.pick(P,_))),e.forEach(k.nodes(),function(O){var H=G(k.node(O));I.setNode(O,e.defaults(F(H,y),S)),I.setParent(O,k.parent(O))}),e.forEach(k.edges(),function(O){var H=G(k.edge(O));I.setEdge(O,e.merge({},E,F(H,w),e.pick(H,T)))}),I}function R(k){var I=k.graph();I.ranksep/=2,e.forEach(k.edges(),function(P){var O=k.edge(P);O.minlen*=2,O.labelpos.toLowerCase()!=="c"&&(I.rankdir==="TB"||I.rankdir==="BT"?O.width+=O.labeloffset:O.height+=O.labeloffset)})}function A(k){e.forEach(k.edges(),function(I){var P=k.edge(I);if(P.width&&P.height){var O=k.node(I.v),H=k.node(I.w),J={rank:(H.rank-O.rank)/2+O.rank,e:I};p.addDummyNode(k,"edge-proxy",J,"_ep")}})}function B(k){var I=0;e.forEach(k.nodes(),function(P){var O=k.node(P);O.borderTop&&(O.minRank=k.node(O.borderTop).rank,O.maxRank=k.node(O.borderBottom).rank,I=e.max(I,O.maxRank))}),k.graph().maxRank=I}function N(k){e.forEach(k.nodes(),function(I){var P=k.node(I);P.dummy==="edge-proxy"&&(k.edge(P.e).labelRank=P.rank,k.removeNode(I))})}function M(k){var I=Number.POSITIVE_INFINITY,P=0,O=Number.POSITIVE_INFINITY,H=0,J=k.graph(),Z=J.marginx||0,ee=J.marginy||0;function ce(te){var re=te.x,Y=te.y,Oe=te.width,X=te.height;I=Math.min(I,re-Oe/2),P=Math.max(P,re+Oe/2),O=Math.min(O,Y-X/2),H=Math.max(H,Y+X/2)}e.forEach(k.nodes(),function(te){ce(k.node(te))}),e.forEach(k.edges(),function(te){var re=k.edge(te);e.has(re,"x")&&ce(re)}),I-=Z,O-=ee,e.forEach(k.nodes(),function(te){var re=k.node(te);re.x-=I,re.y-=O}),e.forEach(k.edges(),function(te){var re=k.edge(te);e.forEach(re.points,function(Y){Y.x-=I,Y.y-=O}),e.has(re,"x")&&(re.x-=I),e.has(re,"y")&&(re.y-=O)}),J.width=P-I+Z,J.height=H-O+ee}function L(k){e.forEach(k.edges(),function(I){var P=k.edge(I),O=k.node(I.v),H=k.node(I.w),J,Z;P.points?(J=P.points[0],Z=P.points[P.points.length-1]):(P.points=[],J=H,Z=O),P.points.unshift(p.intersectRect(O,J)),P.points.push(p.intersectRect(H,Z))})}function $(k){e.forEach(k.edges(),function(I){var P=k.edge(I);if(e.has(P,"x"))switch((P.labelpos==="l"||P.labelpos==="r")&&(P.width-=P.labeloffset),P.labelpos){case"l":P.x-=P.width/2+P.labeloffset;break;case"r":P.x+=P.width/2+P.labeloffset;break}})}function U(k){e.forEach(k.edges(),function(I){var P=k.edge(I);P.reversed&&P.points.reverse()})}function W(k){e.forEach(k.nodes(),function(I){if(k.children(I).length){var P=k.node(I),O=k.node(P.borderTop),H=k.node(P.borderBottom),J=k.node(e.last(P.borderLeft)),Z=k.node(e.last(P.borderRight));P.width=Math.abs(Z.x-J.x),P.height=Math.abs(H.y-O.y),P.x=J.x+P.width/2,P.y=O.y+P.height/2}}),e.forEach(k.nodes(),function(I){k.node(I).dummy==="border"&&k.removeNode(I)})}function z(k){e.forEach(k.edges(),function(I){if(I.v===I.w){var P=k.node(I.v);P.selfEdges||(P.selfEdges=[]),P.selfEdges.push({e:I,label:k.edge(I)}),k.removeEdge(I)}})}function K(k){var I=p.buildLayerMatrix(k);e.forEach(I,function(P){var O=0;e.forEach(P,function(H,J){var Z=k.node(H);Z.order=J+O,e.forEach(Z.selfEdges,function(ee){p.addDummyNode(k,"selfedge",{width:ee.label.width,height:ee.label.height,rank:Z.rank,order:J+ ++O,e:ee.e,label:ee.label},"_se")}),delete Z.selfEdges})})}function j(k){e.forEach(k.nodes(),function(I){var P=k.node(I);if(P.dummy==="selfedge"){var O=k.node(P.e.v),H=O.x+O.width/2,J=O.y,Z=P.x-H,ee=O.height/2;k.setEdge(P.e,P.label),k.removeNode(I),P.label.points=[{x:H+2*Z/3,y:J-ee},{x:H+5*Z/6,y:J-ee},{x:H+Z,y:J},{x:H+5*Z/6,y:J+ee},{x:H+2*Z/3,y:J+ee}],P.label.x=P.x,P.label.y=P.y}})}function F(k,I){return e.mapValues(e.pick(k,I),Number)}function G(k){var I={};return e.forEach(k,function(P,O){I[O.toLowerCase()]=P}),I}return hs}var vs,Jp;function ry(){if(Jp)return vs;Jp=1;var e=Q(),t=oe(),r=ve().Graph;vs={debugOrdering:n};function n(a){var i=t.buildLayerMatrix(a),o=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(a.nodes(),function(s){o.setNode(s,{label:s}),o.setParent(s,"layer"+a.node(s).rank)}),e.forEach(a.edges(),function(s){o.setEdge(s.v,s.w,{},s.name)}),e.forEach(i,function(s,c){var u="layer"+c;o.setNode(u,{rank:"same"}),e.reduce(s,function(d,l){return o.setEdge(d,l,{style:"invis"}),l})}),o}return vs}var gs,Vp;function ty(){return Vp||(Vp=1,gs="0.8.5"),gs}var ms,Yp;function ny(){return Yp||(Yp=1,ms={graphlib:ve(),layout:ey(),debug:ry(),util:{time:oe().time,notime:oe().notime},version:ty()}),ms}var ay=ny();const Xp=Ch(ay);function nr(e,t="TB"){let r=240,n=80;switch(e.type){case"input":case"output":r=60,n=60;break;case"decisionNode":r=212,n=160;break;case"forkNode":r=240,n=95;break;case"joinNode":r=240,n=95;break;case"loopNode":const i=(e.data.loopOver||e.data.task?.loopOver||[]).length,o=!!(e.data.loopCondition||e.data.task?.loopCondition);t==="LR"?(r=320+i*50,r=Math.min(r,600),n=145+(o?20:0)):(r=320,n=120+i*40+(o?30:0),n=Math.min(n,400));break;case"subWorkflowNode":r=240,n=95;break;case"eventNode":r=240,n=85;break;case"default":r=240,n=40;break;default:r=240,n=95;break}return{width:r,height:n}}function iy(e,t,r=8){const n=[];if(e.length<r)return n;const a=new Map,i={},o={};e.forEach(l=>{a.set(l.id,l),i[l.id]=[],o[l.id]=[]}),t.forEach(l=>{i[l.source]&&i[l.source].push(l.target),o[l.target]&&o[l.target].push(l.source)});const s=new Set,c=new Set(["input","output","decisionNode","forkNode","joinNode","loopNode","default"]),u=l=>l.id!=="start"&&l.id!=="end"&&!c.has(l.type||""),d=[...e].sort((l,p)=>l.position.y-p.position.y);for(const l of d){if(s.has(l.id)||!u(l))continue;const p=[l.id];let h=l,m=i[h.id];for(;m&&m.length===1;){const g=m[0],v=a.get(g);if(!v||s.has(g)||!u(v)||o[g].length!==1)break;p.push(g),h=v,m=i[h.id]}p.length>=r&&(n.push(p),p.forEach(g=>s.add(g)))}return n}function oy(e,t,r,n,a,i=5,o="view"){const s=t.find(b=>b.id===e[0]),{width:c,height:u}=nr(s||t[0],r),d=Math.max(.7,1-(e.length-10)/80),l=o==="edit"||o==="run"?1.15:1,p=Math.min(n,Math.round(60*d*l)),h=Math.min(a,Math.round(80*d*l)),m=c+p,g=u+h;let v=0,x=0;if(r==="TB"){const b=Math.ceil(e.length/i);v=i*m-p,x=b*g-h}else v=Math.ceil(e.length/i)*m-p,x=i*g-h;return v+=40,x+=40,{width:v,height:x,gridKW:m,gridKH:g,cols:i}}function ae(e,t,r={}){const{direction:n="TB",mode:a="view",enableSnakeLayout:i=!0,snakeColumns:o=5,snakeMinChainLength:s=8,snakeMinNodeCount:c=10}=r,u=e.length;let d=n==="LR"?150:120,l=n==="LR"?120:100,p=d,h=l;if(u>15){let T=Math.max(.5,1-(u-15)/50),C=Math.max(.4,1-(u-15)/40);(a==="edit"||a==="run")&&(T=1-(1-T)*.5,C=1-(1-C)*.5),p=Math.round(d*T),h=Math.round(l*C)}const m=i&&u>c?iy(e,t,s):[],g={};m.forEach((T,C)=>{T.forEach(R=>{g[R]=C})});const v=new Xp.graphlib.Graph;v.setDefaultEdgeLabel(()=>({})),v.setGraph({rankdir:n,ranker:"network-simplex",ranksep:p,nodesep:h,edgesep:50,marginx:50,marginy:50});const x=new Set,b={};e.forEach(T=>{const C=g[T.id];if(C!==void 0){if(!x.has(C)){x.add(C);const R=oy(m[C],e,n,h,p,o,a);b[C]=R,v.setNode(`__CHAIN_${C}`,{width:R.width,height:R.height})}}else{const{width:R,height:A}=nr(T,n);v.setNode(T.id,{width:R,height:A})}}),t.forEach(T=>{const C=g[T.source],R=g[T.target];let A=T.source,B=T.target;C!==void 0&&(A=`__CHAIN_${C}`),R!==void 0&&(B=`__CHAIN_${R}`),A!==B&&v.setEdge(A,B)}),Xp.layout(v);const _={};for(const T of e)_[T.id]={...T};const y=[],S=new Set;e.forEach(T=>{if(g[T.id]===void 0){const C=v.node(T.id),R=_[T.id],{width:A,height:B}=nr(R,n);R.position={x:C.x-A/2,y:C.y-B/2},R.data={...R.data,sourcePosition:void 0,targetPosition:void 0},R.sourcePosition=n==="LR"?q.Position.Right:q.Position.Bottom,R.targetPosition=n==="LR"?q.Position.Left:q.Position.Top,y.push(R)}else S.add(T.id)}),m.forEach((T,C)=>{const R=`__CHAIN_${C}`,A=v.node(R),B=b[C],N=A.x-B.width/2+20,M=A.y-B.height/2+20,L=B.cols,$=B.gridKW,U=B.gridKH;T.forEach((W,z)=>{const K=_[W];let j=0,F=0,G,k;if(n==="TB"){const I=Math.floor(z/L),P=z%L,O=I%2===0,H=Math.ceil(T.length/L),J=I===H-1,Z=T.length%L||L,ee=J?(L-Z)*$/2:0;let ce;O?ce=P*$+ee:ce=(L-1-P)*$-ee;const te=I*U;j=N+ce,F=M+te;const re=J?Z:L;O?(k=q.Position.Left,G=q.Position.Right,P===re-1&&z!==T.length-1&&(G=q.Position.Bottom),P===0&&z!==0&&(k=q.Position.Top)):(k=q.Position.Right,G=q.Position.Left,P===re-1&&z!==T.length-1&&(G=q.Position.Bottom),P===0&&z!==0&&(k=q.Position.Top)),z===0&&(k=q.Position.Top),z===T.length-1&&(G=q.Position.Bottom)}else{const I=Math.floor(z/L),P=z%L,O=I%2===0,H=Math.ceil(T.length/L),J=I===H-1,Z=T.length%L||L,ee=J?(L-Z)*U/2:0,ce=I*$;let te;O?te=P*U+ee:te=(L-1-P)*U-ee,j=N+ce,F=M+te;const re=J?Z:L;O?(k=q.Position.Top,G=q.Position.Bottom,P===re-1&&z!==T.length-1&&(G=q.Position.Right),P===0&&z!==0&&(k=q.Position.Left)):(k=q.Position.Bottom,G=q.Position.Top,P===re-1&&z!==T.length-1&&(G=q.Position.Right),P===0&&z!==0&&(k=q.Position.Left)),z===0&&(k=q.Position.Left),z===T.length-1&&(G=q.Position.Right)}K.position={x:j,y:F},K.data={...K.data,sourcePosition:G,targetPosition:k},K.sourcePosition=G,K.targetPosition=k,y.push(K)})});const w=y.reduce((T,C)=>({...T,[C.id]:C}),{}),E=t.map(T=>{const C=w[T.source],R=w[T.target];if(!C||!R||S.has(C.id)||C.type!=="decisionNode")return T;const{width:A,height:B}=nr(C,n),{width:N,height:M}=nr(R,n),L={x:C.position.x+A/2,y:C.position.y+B/2},$={x:R.position.x+N/2,y:R.position.y+M/2};let U=null;if(n==="TB"){const W=A*.25;$.x<L.x-W?U="left":$.x>L.x+W&&(U="right")}else{const W=B*.25;$.y<L.y-W?U="top":$.y>L.y+W&&(U="bottom")}return{...T,sourceHandle:U}});return{nodes:y,edges:E}}function be(e,t){if(!e)return null;for(const r of e){if(r.taskReferenceName===t)return r;if(r.decisionCases){for(const a of Object.keys(r.decisionCases)){const i=be(r.decisionCases[a],t);if(i)return i}const n=be(r.defaultCase,t);if(n)return n}if(r.forkTasks)for(const n of r.forkTasks){const a=be(n,t);if(a)return a}if(r.loopOver){const n=be(r.loopOver,t);if(n)return n}}return null}function ar(e,t){if(!e)return!1;const r=e.findIndex(n=>n.taskReferenceName===t);if(r!==-1)return e.splice(r,1),!0;for(const n of e){if(n.decisionCases){for(const a of Object.keys(n.decisionCases))if(ar(n.decisionCases[a],t))return!0;if(ar(n.defaultCase,t))return!0}if(n.forkTasks){for(const a of n.forkTasks)if(ar(a,t))return!0}if(n.loopOver&&ar(n.loopOver,t))return!0}return!1}function ge(e,t,r){if(!e)return!1;const n=e.findIndex(a=>a.taskReferenceName===t);if(n!==-1)return e.splice(n+1,0,r),!0;if(t==="start")return e.unshift(r),!0;for(const a of e){if(a.decisionCases){for(const i of Object.keys(a.decisionCases))if(ge(a.decisionCases[i],t,r))return!0;if(ge(a.defaultCase,t,r))return!0}if(a.forkTasks){for(const i of a.forkTasks)if(ge(i,t,r))return!0}if(a.loopOver&&ge(a.loopOver,t,r))return!0}return!1}function ir(e,t,r,n){for(const a of e||[]){if(a.taskReferenceName===t){if(r.branchCase==="default")return a.defaultCase||(a.defaultCase=[]),a.defaultCase.unshift(n),!0;if(r.branchCase!==void 0)return a.decisionCases||(a.decisionCases={}),a.decisionCases[r.branchCase]||(a.decisionCases[r.branchCase]=[]),a.decisionCases[r.branchCase].unshift(n),!0;if(r.forkIndex!==void 0)return a.forkTasks||(a.forkTasks=[]),a.forkTasks[r.forkIndex].unshift(n),!0;if(r.isLoopAdd)return a.loopOver||(a.loopOver=[]),a.loopOver.unshift(n),!0}if(a.decisionCases){for(const i of Object.keys(a.decisionCases))if(ir(a.decisionCases[i],t,r,n))return!0;if(ir(a.defaultCase,t,r,n))return!0}if(a.forkTasks){for(const i of a.forkTasks)if(ir(i,t,r,n))return!0}}return!1}function ie(e){if(e)for(let t=0;t<e.length;t++){const r=e[t];if(r.type==="FORK_JOIN"&&t+1<e.length){const n=e[t+1];if(n.type==="JOIN"){const a=[];(r.forkTasks||[]).forEach(i=>{i&&i.length>0&&a.push(i[i.length-1].taskReferenceName)}),n.joinOn=a}}r.decisionCases&&(Object.values(r.decisionCases).forEach(n=>ie(n)),r.defaultCase&&ie(r.defaultCase)),r.forkTasks&&r.forkTasks.forEach(n=>ie(n)),r.loopOver&&ie(r.loopOver)}}const sy=[{field:"name",type:"required",message:"工作流名称 (name) 必填"},{field:"version",type:"required",message:"工作流版本 (version) 必填"},{field:"tasks",type:"min_length",value:1,message:"工作流必须包含至少一个任务"}],Zp={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,建议配置"}],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)"}],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:"required",message:"循环任务缺少退出条件 (loopCondition)"}],DECISION:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"决策任务必须至少包含一个分支 (decisionCases)"},{field:"decisionCases",type:"custom",validate:e=>{const t=Object.keys(e||{});return new Set(t).size===t.length},message:"决策分支条件不能重复"}],SWITCH:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"Switch 任务必须至少包含一个分支"}]}},uy=(e,t)=>t.split(".").reduce((r,n)=>r&&r[n]!==void 0?r[n]:void 0,e),ys=(e,t,r,n)=>{const{errors:a,warnings:i}=n,o=e.taskReferenceName||"GLOBAL";t.forEach(s=>{const c=uy(e,s.field);let u=!0;switch(s.type){case"required":u=c!=null&&c!=="";break;case"min_length":u=Array.isArray(c)&&c.length>=s.value;break;case"pattern":u=s.value.test(c);break;case"enum":u=s.value.includes(c);break;case"unique":s.field==="taskReferenceName"&&c&&(r.taskRefs.has(c)?u=!1:r.taskRefs.add(c));break;case"custom":typeof s.validate=="function"&&(u=s.validate(c,e,r));break}if(!u){const d={type:e.taskReferenceName?"TASK":"GLOBAL",ref:o,message:s.message};s.level==="warning"?i.push(d):a.push(d)}})},me=e=>{const t=[],r=[],n={taskRefs:new Set,taskMap:{}};if(!e)return{isValid:!1,errors:[{type:"GLOBAL",ref:"",message:"工作流定义为空"}],warnings:[]};if(ys(e,sy,n,{errors:t,warnings:r}),!e.tasks||e.tasks.length===0)return{isValid:!1,errors:t,warnings:r};const a=o=>{o.forEach(s=>{ys(s,Zp.common,n,{errors:t,warnings:r});const c=Zp.types[s.type];c&&ys(s,c,n,{errors:t,warnings:r}),s.decisionCases&&Object.keys(s.decisionCases).forEach(u=>{a(s.decisionCases[u])}),s.defaultCase&&a(s.defaultCase),s.forkTasks&&s.forkTasks.forEach(u=>a(u)),s.loopOver&&a(s.loopOver)})};a(e.tasks);const i=cy(e.tasks);return t.push(...i),{isValid:t.length===0,errors:t,warnings:r}},cy=e=>{const t=[],r=new Map,n=new Set,a=d=>{for(let l=0;l<d.length;l++){const p=d[l],h=p.taskReferenceName;if(n.add(h),r.has(h)||r.set(h,[]),l<d.length-1){const m=d[l+1].taskReferenceName;p.type!=="FORK_JOIN"&&p.type!=="FORK_JOIN_DYNAMIC"&&r.get(h).push(m)}if(p.decisionCases)for(const m of Object.values(p.decisionCases))m.length>0&&(r.get(h).push(m[0].taskReferenceName),a(m));if(p.defaultCase&&p.defaultCase.length>0&&(r.get(h).push(p.defaultCase[0].taskReferenceName),a(p.defaultCase)),p.forkTasks)for(const m of p.forkTasks)m.length>0&&(r.get(h).push(m[0].taskReferenceName),a(m));if(p.loopOver)for(const m of p.loopOver)n.add(m.taskReferenceName);if(p.joinOn)for(const m of p.joinOn)r.has(m)||r.set(m,[]),r.get(m).push(h)}};a(e);const i=0,o=1,s=2,c=new Map;for(const d of n)c.set(d,i);const u=d=>{c.set(d,o);const l=r.get(d)||[];for(const p of l)if(c.has(p)){if(c.get(p)===o)return t.push({type:"GLOBAL",ref:p,message:`检测到环路:任务 "${d}" → "${p}" 形成了循环依赖`}),!0;if(c.get(p)===i&&u(p))return!0}return c.set(d,s),!1};for(const d of n)c.get(d)===i&&u(d);return t},V=qh()(Ph(Ah((e,t)=>({mode:"view",workflowDef:null,workflowInstance:null,nodes:[],edges:[],taskMap:{},layoutDirection:"TB",selectedTask:null,selectedTaskInstance:null,isDetailPanelOpen:!1,executionData:null,validationResults:{isValid:!0,errors:[],warnings:[]},theme:"dark",themeColor:"blue",edgeType:"smoothstep",nodesLocked:!0,copiedTask:null,setWorkflow:(r,n)=>{const a=n||t().layoutDirection,i=JSON.parse(JSON.stringify(r));ie(i.tasks);const{nodes:o,edges:s,taskMap:c}=ue(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:u,edges:d}=ae(o,s,{direction:a,mode:t().mode}),l=me(i);e({workflowDef:i,nodes:u,edges:d,taskMap:c,validationResults:l,layoutDirection:a})},setMode:r=>{t().mode==="run"&&r!=="run"&&e({executionData:null,workflowInstance:null}),e({mode:r});const{workflowDef:a,layoutDirection:i}=t();if(a){const{nodes:o,edges:s,taskMap:c}=ue(a,i,{hideEmptyBranches:r!=="edit"}),{nodes:u,edges:d}=ae(o,s,{direction:i,mode:r});e({nodes:u,edges:d,taskMap:c})}},setExecutionData:r=>e({executionData:r}),updateTaskStatus:(r,n)=>{const{executionData:a}=t();if(!a)return;const i={...a};i[r]&&(i[r]={...i[r],status:n},e({executionData:i}))},loadSampleExecution:async()=>{try{const n=await(await fetch("/sample-workflows/sample-execution.json")).json();t().importExecutionJSON(n)}catch(r){console.error("Failed to load sample execution:",r),alert("加载示例运行数据失败")}},importExecutionJSON:r=>{if(!r)return;let n=[],a=null,i=t().workflowDef;if(Array.isArray(r.tasks)?(n=r.tasks,r.workflowId&&r.status&&(a=r,r.workflowDefinition&&(i=r.workflowDefinition))):Array.isArray(r)&&(n=r),n.length===0)return;const o={};n.forEach(s=>{const c=s.referenceTaskName;c&&(o[c]||(o[c]={taskReferenceName:c,status:s.status,attempts:[],startTime:s.startTime,endTime:s.endTime,output:s.outputData,input:s.inputData,reasonForIncompletion:s.reasonForIncompletion,iteration:s.iteration}),o[c].attempts.push(s),o[c].status=s.status,o[c].startTime=s.startTime,o[c].endTime=s.endTime,o[c].output=s.outputData,o[c].input=s.inputData,o[c].reasonForIncompletion=s.reasonForIncompletion,o[c].iteration=s.iteration)}),i&&JSON.stringify(i)!==JSON.stringify(t().workflowDef)&&t().setWorkflow(i),e({executionData:o,workflowInstance:a,mode:"run"})},setSelectedTask:r=>e({selectedTask:r?{...r}:null}),setIsDetailPanelOpen:r=>e({isDetailPanelOpen:r}),selectTaskAction:(r,n=!0)=>{e({selectedTask:r?{...r}:null,isDetailPanelOpen:r?n:!1,selectedTaskInstance:null})},setSelectedTaskInstance:r=>e({selectedTaskInstance:r}),setLayoutDirection:r=>{const{workflowDef:n}=t();if(n){const{nodes:a,edges:i,taskMap:o}=ue(n,r,{hideEmptyBranches:t().mode!=="edit"}),{nodes:s,edges:c}=ae(a,i,{direction:r,mode:t().mode});e({nodes:s,edges:c,taskMap:o,layoutDirection:r})}else e({layoutDirection:r})},onNodesChange:r=>{const n=t().nodes,a=q.applyNodeChanges(r,n);a!==n&&e({nodes:a})},onEdgesChange:r=>{const n=t().edges,a=q.applyEdgeChanges(r,n);a!==n&&e({edges:a})},onConnect:r=>{const{edges:n,layoutDirection:a}=t(),i=q.addEdge(r,n),{nodes:o,edges:s}=ae(t().nodes,i,{direction:a,mode:t().mode});e({edges:s,nodes:o})},checkTaskRefUniqueness:(r,n)=>{if(r===n)return!0;const{taskMap:a}=t();return!a[r]},updateTask:(r,n,a)=>{const{workflowDef:i,layoutDirection:o}=t();if(!i)return;const s=JSON.parse(JSON.stringify(i)),c=be(s.tasks,r);if(c){typeof n=="object"?Object.assign(c,n):c[n]=a,ie(s.tasks);const{nodes:u,edges:d,taskMap:l}=ue(s,o,{hideEmptyBranches:t().mode!=="edit"}),{nodes:p,edges:h}=ae(u,d,{direction:o,mode:t().mode}),m=me(s);e({workflowDef:s,nodes:p,edges:h,taskMap:l,validationResults:m})}},updateWorkflowProperties:r=>{const{workflowDef:n,layoutDirection:a}=t();if(!n)return;const i=JSON.parse(JSON.stringify(n));Object.assign(i,r),ie(i.tasks);const{nodes:o,edges:s,taskMap:c}=ue(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:u,edges:d}=ae(o,s,{direction:a,mode:t().mode}),l=me(i);e({workflowDef:i,nodes:u,edges:d,taskMap:c,validationResults:l})},addNode:(r,n,a,i,o={})=>{const{workflowDef:s,layoutDirection:c}=t();if(!s)return;const u=JSON.parse(JSON.stringify(s)),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 x={name:`${d.name}_join`,taskReferenceName:`${d.taskReferenceName}_join`,type:"JOIN",joinOn:[]};o.branchCase!==void 0||o.forkIndex!==void 0||o.isLoopAdd?(ir(u.tasks,n,o,d),ge(u.tasks,d.taskReferenceName,x)):n==="start"&&u.tasks.length===0?u.tasks.push(d,x):(ge(u.tasks,n,d),ge(u.tasks,d.taskReferenceName,x))}else d.type==="DECISION"?(d.caseValueParam="case_param",d.decisionCases={case1:[]},d.defaultCase=[]):d.type==="DO_WHILE"&&(d.loopCondition="$.taskReferenceName.output.value < 10",d.loopOver=[]),o.branchCase!==void 0||o.forkIndex!==void 0||o.isLoopAdd?ir(u.tasks,n,o,d):n==="start"&&u.tasks.length===0?u.tasks.push(d):ge(u.tasks,n,d);ie(u.tasks);const{nodes:l,edges:p,taskMap:h}=ue(u,c,{hideEmptyBranches:t().mode!=="edit"}),{nodes:m,edges:g}=ae(l,p,{direction:c,mode:t().mode}),v=me(u);e({workflowDef:u,nodes:m,edges:g,taskMap:h,validationResults:v})},removeNode:r=>{const{workflowDef:n,layoutDirection:a}=t();if(!n||r==="start"||r==="end")return;const i=JSON.parse(JSON.stringify(n));ar(i.tasks,r),ie(i.tasks);const{nodes:o,edges:s,taskMap:c}=ue(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:u,edges:d}=ae(o,s,{direction:a,mode:t().mode}),l=me(i);e({workflowDef:i,nodes:u,edges:d,taskMap:c,validationResults:l})},addLoopTask:(r,n)=>{const{workflowDef:a,layoutDirection:i}=t();if(!a)return;const o=JSON.parse(JSON.stringify(a)),s=be(o.tasks,r);if(s&&s.type==="DO_WHILE"){s.loopOver||(s.loopOver=[]);const c={name:`new_${n.toLowerCase()}`,taskReferenceName:`${r}_sub_${Date.now()}`,type:n,inputParameters:{}};s.loopOver.push(c),ie(o.tasks);const{nodes:u,edges:d,taskMap:l}=ue(o,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:p,edges:h}=ae(u,d,{direction:i,mode:t().mode}),m=me(o);e({workflowDef:o,nodes:p,edges:h,taskMap:l,validationResults:m})}},removeLoopTask:(r,n)=>{const{workflowDef:a,layoutDirection:i}=t();if(!a)return;const o=JSON.parse(JSON.stringify(a)),s=be(o.tasks,r);if(s&&s.type==="DO_WHILE"&&s.loopOver){s.loopOver=s.loopOver.filter(m=>m.taskReferenceName!==n),ie(o.tasks);const{nodes:c,edges:u,taskMap:d}=ue(o,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:l,edges:p}=ae(c,u,{direction:i,mode:t().mode}),h=me(o);e({workflowDef:o,nodes:l,edges:p,taskMap:d,validationResults:h})}},addDecisionBranch:(r,n)=>{const{workflowDef:a,layoutDirection:i}=t();if(!a)return;const o=JSON.parse(JSON.stringify(a)),s=be(o.tasks,r);if(s&&(s.type==="DECISION"||s.type==="SWITCH")){n==="default"?s.defaultCase||(s.defaultCase=[]):(s.decisionCases||(s.decisionCases={}),s.decisionCases[n]||(s.decisionCases[n]=[])),ie(o.tasks);const{nodes:c,edges:u,taskMap:d}=ue(o,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:l,edges:p}=ae(c,u,{direction:i,mode:t().mode}),h=me(o);e({workflowDef:o,nodes:l,edges:p,taskMap:d,validationResults:h})}},removeDecisionBranch:(r,n)=>{const{workflowDef:a,layoutDirection:i}=t();if(!a)return;const o=JSON.parse(JSON.stringify(a)),s=be(o.tasks,r);if(s&&(s.type==="DECISION"||s.type==="SWITCH")){n==="default"?s.defaultCase=[]:s.decisionCases&&delete s.decisionCases[n],ie(o.tasks);const{nodes:c,edges:u,taskMap:d}=ue(o,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:l,edges:p}=ae(c,u,{direction:i,mode:t().mode}),h=me(o);e({workflowDef:o,nodes:l,edges:p,taskMap:d,validationResults:h})}},addForkBranch:r=>{const{workflowDef:n,layoutDirection:a}=t();if(!n)return;const i=JSON.parse(JSON.stringify(n)),o=be(i.tasks,r);if(o&&o.type==="FORK_JOIN"){o.forkTasks||(o.forkTasks=[]),o.forkTasks.push([]),ie(i.tasks);const{nodes:s,edges:c,taskMap:u}=ue(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:d,edges:l}=ae(s,c,{direction:a,mode:t().mode}),p=me(i);e({workflowDef:i,nodes:d,edges:l,taskMap:u,validationResults:p})}},copyTask:r=>e({copiedTask:r}),pasteTask:r=>{const{workflowDef:n,layoutDirection:a,selectedTask:i}=t();if(!n)return;const o=JSON.parse(JSON.stringify(n)),c=`_copy_${Date.now()}`,u=JSON.parse(JSON.stringify(r)),d=b=>{b.taskReferenceName=`${b.taskReferenceName}${c}`,b.decisionCases&&Object.values(b.decisionCases).forEach(_=>_.forEach(d)),b.defaultCase&&b.defaultCase.forEach(d),b.forkTasks&&b.forkTasks.forEach(_=>_.forEach(d)),b.loopOver&&b.loopOver.forEach(d)};d(u);const l=i?i.taskReferenceName:o.tasks.length>0?o.tasks[o.tasks.length-1].taskReferenceName:"start";if(u.type==="FORK_JOIN"){u.forkTasks||(u.forkTasks=[[],[]]);const b={name:`${u.name}_join`,taskReferenceName:`${u.taskReferenceName}_join`,type:"JOIN",joinOn:[]};l==="start"&&o.tasks.length===0?o.tasks.push(u,b):(ge(o.tasks,l,u),ge(o.tasks,u.taskReferenceName,b))}else l==="start"&&o.tasks.length===0?o.tasks.push(u):ge(o.tasks,l,u);ie(o.tasks);const{nodes:p,edges:h,taskMap:m}=ue(o,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:g,edges:v}=ae(p,h,{direction:a,mode:t().mode}),x=me(o);e({workflowDef:o,nodes:g,edges:v,taskMap:m,validationResults:x})},setTheme:r=>e({theme:r}),setThemeColor:r=>e({themeColor:r}),setEdgeType:r=>e({edgeType:r}),setNodesLocked:r=>e({nodesLocked:r}),createBlankWorkflow:r=>{const n={name:r||"new_workflow",description:"",tasks:[],version:1,schemaVersion:2};t().setWorkflow(n),e({mode:"edit"})},applyAIGeneratedWorkflow:r=>{const{tasks:n,...a}=r,i={...a,name:r.name||"AI_Generated_Workflow",tasks:n||[],version:r.version||1,schemaVersion:2};t().setWorkflow(i)}}),{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,t)=>JSON.stringify(e.workflowDef)===JSON.stringify(t.workflowDef)}),{name:"conductor-ui-prefs",version:1,storage:Cs(()=>localStorage),migrate:(e,t)=>(t===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})})),Qp=({message:e,onConfirm:t,onCancel:r})=>{const n=D.useRef(null);return D.useEffect(()=>{n.current?.focus();const a=i=>{i.key==="Escape"&&r()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[r]),f.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"确认操作",style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0,0,0,0.5)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3,backdropFilter:"blur(4px)",animation:"fadeIn 0.15s ease-out"},onClick:r,children:f.jsxs("div",{style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",borderRadius:"12px",padding:"24px",maxWidth:"400px",width:"90%",boxShadow:"0 16px 40px rgba(0,0,0,0.3)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)"},onClick:a=>a.stopPropagation(),children:[f.jsx("div",{style:{fontSize:"14px",color:"var(--text-primary)",marginBottom:"20px",lineHeight:"1.5"},children:e}),f.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"8px"},children:[f.jsx("button",{ref:n,onClick:r,style:{padding:"8px 16px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px"},children:"取消"}),f.jsx("button",{onClick:t,style:{padding:"8px 16px",backgroundColor:"#ef4444",border:"none",borderRadius:"6px",color:"#fff",cursor:"pointer",fontSize:"13px",fontWeight:600},children:"确定"})]})]})})},Be=({children:e,nodeId:t,selected:r=!1,isStartOrEnd:n=!1,isError:a=!1,hasWarning:i=!1,isDecision:o=!1,isHighlighted:s=!1,executionStatus:c})=>{const{mode:u,removeNode:d}=V(),[l,p]=D.useState(!1),h=x=>{x.stopPropagation(),p(!0)},m=u==="edit"&&!n,g=o?`decision-node-wrapper ${r?"node-wrapper-selected":""} ${s?"node-wrapper-highlighted":""}`:`node-wrapper-glass ${r?"node-wrapper-selected":""} ${s?"node-wrapper-highlighted":""}`,v=D.useMemo(()=>{if(u!=="run")return{};if(!c)return{opacity:.4};switch(c){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{}}},[u,c]);return f.jsxs("div",{className:g,style:{position:"relative",...v},children:[m&&f.jsx("button",{onClick:h,"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:"×"}),a&&f.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:"❗"}),!a&&i&&f.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,l&&f.jsx(Qp,{message:"确定要删除此任务吗?",onConfirm:()=>{d(t),p(!1)},onCancel:()=>p(!1)})]})},dy=({status:e})=>{const t=()=>{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:n}=t();return f.jsx("div",{className:`execution-status-badge ${n}`,title:e,children:f.jsx("span",{className:"badge-icon",children:r})})},eh=D.memo(dy),ly=({icon:e,header:t,title:r,meta:n,color:a,status:i,isRunning:o,children:s,width:c="240px",border:u=!0})=>f.jsxs("div",{style:{display:"flex",flexDirection:"row",width:c,height:"100%",position:"relative",overflow:"hidden",border:u?"4px solid var(--border-primary)":"none",borderRadius:"8px"},children:[f.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:a},children:f.jsx(e,{size:20,strokeWidth:1.5})}),f.jsxs("div",{style:{flex:1,padding:"10px 14px",display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden"},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.7,marginBottom:"4px",color:a},children:t}),f.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",marginBottom:"2px"},title:r,children:r}),n&&f.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)",fontStyle:"italic",lineHeight:"1.4",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:n,children:n}),s&&f.jsx("div",{style:{marginTop:"8px"},children:s})]}),o&&i&&f.jsx("div",{style:{position:"absolute",top:"8px",right:"8px"},children:f.jsx(eh,{status:i})})]}),or=D.memo(ly),We=e=>{const t=e.layoutDirection||"TB",r=e.sourcePosition||(t==="LR"?q.Position.Right:q.Position.Bottom),n=e.targetPosition||(t==="LR"?q.Position.Left:q.Position.Top);return{layoutDirection:t,sourcePosition:r,targetPosition:n}},Fe=e=>{const{mode:t,executionData:r}=V(),n=t==="run"?r?.[e]:null;return{mode:t,execution:n,isRunning:t==="run"}};const fy=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),py=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),rh=e=>{const t=py(e);return t.charAt(0).toUpperCase()+t.slice(1)},th=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),hy=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var vy={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 gy=D.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:a="",children:i,iconNode:o,...s},c)=>D.createElement("svg",{ref:c,...vy,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:th("lucide",a),...!i&&!hy(s)&&{"aria-hidden":"true"},...s},[...o.map(([u,d])=>D.createElement(u,d)),...Array.isArray(i)?i:[i]]));const fe=(e,t)=>{const r=D.forwardRef(({className:n,...a},i)=>D.createElement(gy,{ref:i,iconNode:t,className:th(`lucide-${fy(rh(e))}`,`lucide-${e}`,n),...a}));return r.displayName=rh(e),r};const nh=fe("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 my=fe("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 yy=fe("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const by=fe("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 ah=fe("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 Cr=fe("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 xy=fe("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 _y=fe("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 ih=fe("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 ky=fe("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 Sy=fe("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const wy=fe("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"}]]),$e=[{type:"SIMPLE",label:"任务节点 (Worker)",description:"在远程 Worker 上执行的任务",category:"CORE",icon:nh},{type:"SUB_WORKFLOW",label:"子工作流 (Sub Workflow)",description:"调用并执行另一个工作流",category:"CORE",icon:Cr},{type:"HTTP",label:"HTTP 请求",description:"发起 REST/HTTP 调用",category:"SYSTEM",icon:xy},{type:"JSON_JQ_TRANSFORM",label:"JSON 转换 (JQ)",description:"使用 JQ 表达式转换 JSON 数据",category:"SYSTEM",icon:Sy},{type:"KAFKA_PUBLISH",label:"Kafka 推送",description:"向 Kafka 主题推送消息",category:"SYSTEM",icon:_y},{type:"EVENT",label:"事件 (Event)",description:"向外部队列系统发布事件",category:"SYSTEM",icon:wy},{type:"WAIT",label:"等待 (Wait)",description:"暂停流程,直到特定时间或时长",category:"SYSTEM",icon:yy},{type:"SET_VARIABLE",label:"设置变量 (Set Variable)",description:"设置工作流上下文变量",category:"SYSTEM",icon:by},{type:"TERMINATE",label:"终止 (Terminate)",description:"提前结束工作流执行",category:"SYSTEM",icon:my},{type:"DECISION",label:"判断 (Switch)",description:"基于条件的逻辑分支 (Switch/Case)",category:"FLOW",icon:ky},{type:"FORK_JOIN",label:"并行分支 (Fork)",description:"并行执行多个任务分支",category:"FLOW",icon:ah},{type:"DO_WHILE",label:"循环 (Do-While)",description:"循环执行直到满足条件",category:"FLOW",icon:ih},{type:"JOIN",label:"汇聚 (Join)",description:"等待并行分支执行完成",category:"FLOW",icon:Cr}],Ey=[{key:"CORE",label:"基础任务"},{key:"FLOW",label:"逻辑控制"},{key:"SYSTEM",label:"系统集成"}],Ty=({id:e,data:t,selected:r})=>{const n=t.taskType||"SIMPLE",{sourcePosition:a,targetPosition:i}=We(t),{execution:o,isRunning:s}=Fe(t.taskReferenceName),c=D.useMemo(()=>$e.find(p=>p.type===n),[n]),u=c?.icon||nh,d="var(--color-accent)",l=D.useMemo(()=>n==="SIMPLE"?t.label==="Worker Task"?"Execute on Worker":"Worker Task":n==="HTTP"?"REST API Call":n==="JSON_JQ_TRANSFORM"?"JQ Expression":c?.label||n,[n,c,t.label]);return f.jsx(Be,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:o?.status,children:f.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)"},children:[f.jsx(or,{icon:u,header:n,title:t.taskReferenceName,meta:l,color:d,status:o?.status,isRunning:s}),f.jsx(q.Handle,{type:"target",position:i,style:{background:"#fff"}}),f.jsx(q.Handle,{type:"source",position:a,style:{background:"#fff"}})]})})},Cy=D.memo(Ty),Ny=({id:e,data:t,selected:r})=>{const{layoutDirection:n}=We(t),{mode:a,execution:i,isRunning:o}=Fe(t.taskReferenceName),{addDecisionBranch:s,removeDecisionBranch:c}=V(),[u,d]=D.useState(!1),l=n==="LR"?q.Position.Left:q.Position.Top,p=Object.keys(t.decisionCases||t.task?.decisionCases||{}),h=()=>{const x=window.prompt("请输入新分支的名称 (case value):",`case_${p.length+1}`);x&&s(e,x),d(!1)},m=(x,b)=>{x.stopPropagation(),window.confirm(`确定要删除分支 "${b}" 及其下的所有任务吗?`)&&c(e,b)},v=o?(x=>x&&{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"}[x]||"")(i?.status):"";return f.jsx(Be,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isDecision:!0,isHighlighted:t.isHighlighted,executionStatus:i?.status,children:f.jsxs("div",{style:{position:"relative"},children:[f.jsx(q.Handle,{type:"target",position:l,style:{background:"#fff",[n==="LR"?"left":"top"]:"-5px"}}),o&&i?.status&&f.jsx("div",{style:{position:"absolute",top:0,right:0,zIndex:20},children:f.jsx(eh,{status:i.status})}),f.jsx("div",{className:v,style:{width:"150px",height:"150px",background:o&&i?.status?void 0:"var(--bg-secondary)",border:r?"4px solid #fbbf24":o&&i?.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&&i?.status?void 0:"0 4px 12px rgba(0,0,0,0.15)",transition:"all 0.3s ease",cursor:"pointer"},onClick:()=>a==="edit"&&d(!u),children:f.jsxs("div",{style:{transform:"rotate(-45deg)",color:"#fff",textAlign:"center",padding:"10px",width:"100%",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.7,marginBottom:"4px",color:"var(--color-accent)"},children:t.taskType}),f.jsx("div",{style:{fontSize:"18px",fontWeight:600,color:"var(--text-primary)",lineHeight:"1.2",wordBreak:"break-word",maxHeight:"60px",overflow:"hidden",marginBottom:"4px"},children:t.label}),a==="edit"&&f.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&&i?.startTime&&f.jsx("div",{style:{fontSize:"9px",opacity:.7,marginTop:"8px"},children:i.endTime?`${((i.endTime-i.startTime)/1e3).toFixed(1)}s`:"◌"})]})}),a==="edit"&&u&&f.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:"180px",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:[f.jsx("div",{style:{padding:"4px 8px",fontSize:"11px",color:"var(--text-secondary)",borderBottom:"1px solid var(--glass-border)",marginBottom:"4px"},children:"分支管理"}),p.map(x=>f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",padding:"6px 8px",fontSize:"12px",color:"var(--text-primary)"},children:[f.jsx("span",{children:x}),f.jsx("button",{onClick:b=>m(b,x),style:{width:"20px",height:"20px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"12px",padding:0},children:"×"})]},x)),f.jsx("button",{onClick:h,style:{width:"100%",marginTop:"4px",padding:"8px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"4px",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:"bold"},children:"+ 添加新分支"})]}),n==="TB"?f.jsxs(f.Fragment,{children:[f.jsx(q.Handle,{type:"source",position:q.Position.Bottom,style:{background:"#fff",bottom:"-5px"}}),f.jsx(q.Handle,{type:"source",position:q.Position.Left,id:"left",style:{background:"#fff",left:"-5px"}}),f.jsx(q.Handle,{type:"source",position:q.Position.Right,id:"right",style:{background:"#fff",right:"-5px"}})]}):f.jsxs(f.Fragment,{children:[f.jsx(q.Handle,{type:"source",position:q.Position.Right,style:{background:"#fff",right:"-5px"}}),f.jsx(q.Handle,{type:"source",position:q.Position.Top,id:"top",style:{background:"#fff",top:"-5px"}}),f.jsx(q.Handle,{type:"source",position:q.Position.Bottom,id:"bottom",style:{background:"#fff",bottom:"-5px"}})]})]})})},Ry=D.memo(Ny),oh="var(--color-accent)",sh=D.memo(({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:a,targetPosition:i}=We(t),{mode:o,execution:s,isRunning:c}=Fe(t.taskReferenceName),{addForkBranch:u}=V(),d=q.useUpdateNodeInternals(),l=t.task?.forkTasks?.length||0;D.useEffect(()=>{d(e)},[l,e,d]);const p=t.isDynamic||t.taskType==="FORK_JOIN_DYNAMIC",m=D.useMemo(()=>$e.find(g=>g.type==="FORK_JOIN"),[])?.icon||ah;return f.jsx(Be,{isHighlighted:t.isHighlighted,nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,executionStatus:s?.status,children:f.jsxs("div",{className:`fork-node ${p?"dynamic":"static"}`,style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[f.jsx(or,{icon:m,header:p?"DYNAMIC FORK":"FORK",title:t.taskReferenceName,meta:p?"Dynamic Parallel Execution":"Parallel Execution",color:oh,status:s?.status,isRunning:c}),o==="edit"&&!p&&f.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:g=>{g.stopPropagation(),u(e)},title:"添加分支",children:"+"}),f.jsx(q.Handle,{type:"target",position:i,style:{background:"#fff"}}),!p&&(t.task?.forkTasks||[]).map((g,v,x)=>{if(o!=="edit"&&(!g||g.length===0))return null;const b=o!=="edit"?x.filter(w=>w&&w.length>0):x,_=b.length,S=(b.indexOf(g)+1)/(_+1)*100;return f.jsx(q.Handle,{id:`branch_${v}`,type:"source",position:a,style:{background:"#fff",[n==="LR"?"top":"left"]:`${S}%`,[n==="LR"?"left":"top"]:void 0,[n==="LR"?"right":"bottom"]:"-4px",zIndex:10}},`branch_${v}`)}),!p&&(!t.task?.forkTasks||t.task.forkTasks.length===0)&&f.jsx(q.Handle,{type:"source",position:a,style:{background:"#fff"}})]})})});sh.displayName="ForkNode";const uh=D.memo(({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:a,targetPosition:i}=We(t),{execution:o,isRunning:s}=Fe(t.taskReferenceName),u=D.useMemo(()=>$e.find(d=>d.type==="JOIN"),[])?.icon||Cr;return f.jsx(Be,{isHighlighted:t.isHighlighted,nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,executionStatus:o?.status,children:f.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[f.jsx(or,{icon:u,header:"JOIN",title:t.taskReferenceName,meta:"Wait for tasks",color:oh,status:o?.status,isRunning:s}),f.jsx(q.Handle,{type:"target",position:i,style:{background:"#fff"}}),n==="TB"&&f.jsxs(f.Fragment,{children:[f.jsx(q.Handle,{type:"target",position:q.Position.Left,id:"left",style:{background:"#fff"}}),f.jsx(q.Handle,{type:"target",position:q.Position.Right,id:"right",style:{background:"#fff"}})]}),n==="LR"&&f.jsxs(f.Fragment,{children:[f.jsx(q.Handle,{type:"target",position:q.Position.Top,id:"top",style:{background:"#fff"}}),f.jsx(q.Handle,{type:"target",position:q.Position.Bottom,id:"bottom",style:{background:"#fff"}})]}),f.jsx(q.Handle,{type:"source",position:a,style:{background:"#fff"}})]})})});uh.displayName="JoinNode";const ch={ForkNode:sh,JoinNode:uh},Iy="var(--color-accent)",jy=({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:a,targetPosition:i}=We(t),{mode:o,execution:s,isRunning:c}=Fe(t.taskReferenceName),{removeLoopTask:u}=V(),d=t.loopOver||t.task?.loopOver||[],l=d.length,p=D.useCallback((_,y)=>{y.stopPropagation();const S=new CustomEvent("miniTaskClick",{detail:{task:_},bubbles:!0});document.dispatchEvent(S)},[]),h=(_,y)=>{_.stopPropagation(),window.confirm("确定要从循环中删除此任务吗?")&&u(e,y)},g=D.useMemo(()=>$e.find(_=>_.type==="DO_WHILE"),[])?.icon||ih,v=(_,y)=>{const S=n==="LR";return f.jsxs("div",{style:{position:"relative",marginBottom:!S&&(y<l-1||o==="edit")?"8px":"0",marginRight:S&&(y<l-1||o==="edit")?"8px":"0",display:S?"inline-block":"block"},children:[f.jsxs("div",{onClick:C=>p(_,C),style:{background:"var(--bg-tertiary)",borderRadius:"6px",padding:"6px 10px",fontSize:"10px",color:"var(--text-primary)",border:"1px solid var(--border-secondary)",cursor:"pointer",transition:"all 0.2s ease",minWidth:S?"80px":"auto",textAlign:"center",position:"relative"},children:[o==="edit"&&f.jsx("div",{onClick:C=>h(C,_.taskReferenceName),style:{position:"absolute",top:"-6px",right:"-6px",width:"16px",height:"16px",borderRadius:"50%",backgroundColor:"#ef4444",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"10px",border:"1px solid white"},children:"×"}),f.jsx("div",{style:{fontWeight:"600",marginBottom:"2px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:"100px"},children:_.name||_.taskReferenceName})]}),y<l-1&&(S?f.jsx("div",{style:{position:"absolute",right:"-8px",top:"50%",transform:"translateY(-50%)",width:"8px",height:"2px",background:"var(--border-secondary)",pointerEvents:"none"}}):f.jsx("div",{style:{position:"absolute",left:"50%",bottom:"-8px",transform:"translateX(-50%)",width:"2px",height:"8px",background:"var(--border-secondary)",pointerEvents:"none"}}))]},y)},x=n==="LR",b=c&&s?.iteration!==void 0?`Condition: ${t.loopCondition||"None"} | Iteration: ${s.iteration}`:`Condition: ${t.loopCondition||"None"}`;return f.jsx(Be,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:s?.status,children:f.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",minWidth:x&&n==="LR"?"320px":"240px",position:"relative",overflow:"visible"},children:[f.jsx(or,{icon:g,header:"DO WHILE",title:t.taskReferenceName,meta:b,color:Iy,status:s?.status,isRunning:c,width:"100%",children:(l>0||o==="edit")&&f.jsxs("div",{style:{background:"var(--bg-primary)",borderRadius:"6px",padding:"12px",marginTop:"8px",border:"1px dashed var(--border-secondary)",display:"flex",flexDirection:x?"row":"column",alignItems:x?"center":"stretch",flexWrap:"nowrap",gap:"8px",justifyContent:"flex-start"},children:[d.map((_,y)=>v(_,y)),o==="edit"&&f.jsx("div",{onClick:()=>{const _=new CustomEvent("loopAddNodeRequested",{detail:{loopId:e}});document.dispatchEvent(_)},style:{background:"var(--color-accent)",color:"#fff",borderRadius:"50%",width:"24px",height:"24px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",fontSize:"16px",fontWeight:"bold",marginLeft:"0",marginRight:"0",flexShrink:0},children:"+"})]})}),f.jsx(q.Handle,{type:"target",position:i,style:{background:"#fff"}}),f.jsx(q.Handle,{type:"source",position:a,style:{background:"#fff"}})]})})},Oy=D.memo(jy),qy="var(--color-accent)",Py=({id:e,data:t,selected:r})=>{const{sourcePosition:n,targetPosition:a}=We(t),{execution:i,isRunning:o}=Fe(t.taskReferenceName),c=D.useMemo(()=>$e.find(l=>l.type==="SUB_WORKFLOW"),[])?.icon||Cr,u=t.task?.subWorkflowParam?.name||t.subWorkflowName||"Unknown",d=t.task?.subWorkflowParam?.version;return f.jsx(Be,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:i?.status,children:f.jsxs("div",{style:{borderRadius:"8px",background:"var(--bg-secondary)",position:"relative"},children:[f.jsx(or,{icon:c,header:"SUB WORKFLOW",title:t.taskReferenceName,meta:`Flow: ${u} (v${d})`,color:qy,status:i?.status,isRunning:o}),f.jsx(q.Handle,{type:"target",position:a,style:{background:"#fff"}}),f.jsx(q.Handle,{type:"source",position:n,style:{background:"#fff"}})]})})},Ay=D.memo(Py),Ly=({onSelect:e,onCancel:t})=>{const[r,n]=D.useState("CORE");D.useEffect(()=>{const i=o=>{o.key==="Escape"&&t()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[t]);const a=$e.filter(i=>i.category===r);return f.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:t,children:[f.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:i=>i.stopPropagation(),children:[f.jsxs("div",{style:{padding:"20px 24px 0",borderBottom:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)"},children:[f.jsx("h3",{style:{marginTop:0,marginBottom:"16px",color:"var(--text-primary)",fontSize:"18px",fontWeight:"600"},children:"添加任务"}),f.jsx("div",{style:{display:"flex",gap:"24px"},children:Ey.map(i=>f.jsx("button",{onClick:()=>n(i.key),style:{background:"none",border:"none",padding:"0 0 12px 0",fontSize:"14px",fontWeight:r===i.key?"600":"500",color:r===i.key?"var(--color-accent)":"var(--text-secondary)",borderBottom:r===i.key?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s"},children:i.label},i.key))})]}),f.jsx("div",{style:{flex:1,overflowY:"auto",padding:"24px",backgroundColor:"var(--bg-primary)"},children:f.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"12px"},children:a.map(i=>{const o=i.icon;return f.jsxs("button",{onClick:()=>e(i.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:s=>{s.currentTarget.style.borderColor="var(--color-accent)",s.currentTarget.style.backgroundColor="var(--bg-highlight)",s.currentTarget.style.transform="translateY(-2px)",s.currentTarget.style.boxShadow="0 4px 12px rgba(0,0,0,0.1)"},onMouseLeave:s=>{s.currentTarget.style.borderColor="var(--border-primary)",s.currentTarget.style.backgroundColor="var(--bg-tertiary)",s.currentTarget.style.transform="translateY(0)",s.currentTarget.style.boxShadow="none"},children:[f.jsx("div",{style:{padding:"10px",borderRadius:"8px",backgroundColor:"var(--bg-secondary)",color:"var(--color-accent)",display:"flex",alignItems:"center",justifyContent:"center"},children:f.jsx(o,{size:24,strokeWidth:1.5})}),f.jsxs("div",{children:[f.jsx("div",{style:{fontWeight:"600",fontSize:"14px",marginBottom:"4px"},children:i.label}),f.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",lineHeight:"1.4"},children:i.description})]})]},i.type)})})}),f.jsx("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)",display:"flex",justifyContent:"flex-end"},children:f.jsx("button",{onClick:t,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:i=>i.currentTarget.style.backgroundColor="var(--bg-tertiary)",onMouseLeave:i=>i.currentTarget.style.backgroundColor="transparent",children:"取消"})})]}),f.jsx("style",{children:`
7
+ @keyframes fadeIn {
8
+ from { opacity: 0; }
9
+ to { opacity: 1; }
10
+ }
11
+ `})]})},dh=()=>{const{selectedTask:e,selectedTaskInstance:t,setSelectedTask:r,setSelectedTaskInstance:n,executionData:a,workflowInstance:i}=V(),[o,s]=D.useState("summary"),c=e?.taskReferenceName==="__workflow_global__",u=e?a?.[e.taskReferenceName]:null;if(!e||!u&&!c)return null;const d=u?.attempts||[],l=t||d[d.length-1],p=()=>{r(null),n(null)},h=(g,v)=>{if(!g)return"-";const b=(v||Date.now())-g;return b<1e3?`${b}ms`:`${(b/1e3).toFixed(2)}s`},m=g=>({COMPLETED:"var(--status-completed)",FAILED:"var(--status-failed)",IN_PROGRESS:"var(--status-in-progress)",SCHEDULED:"var(--status-scheduled)",TIMED_OUT:"var(--status-timed-out)",CANCELED:"var(--status-canceled)"})[g]||"var(--text-secondary)";return f.jsxs("div",{className:"execution-details-panel",children:[f.jsx("style",{children:`
12
+ .execution-details-panel {
13
+ position: fixed;
14
+ right: 20px;
15
+ top: 80px;
16
+ width: 400px;
17
+ max-height: calc(100vh - 120px);
18
+ background: var(--glass-surface);
19
+ backdrop-filter: blur(12px);
20
+ border: 1px solid var(--glass-border);
21
+ border-radius: 16px;
22
+ box-shadow: 0 20px 50px rgba(0,0,0,0.3);
23
+ z-index: 1000;
24
+ display: flex;
25
+ flex-direction: column;
26
+ overflow: hidden;
27
+ animation: slideInRight 0.3s cubic-bezier(0.16, 1, 0.3, 1);
28
+ }
29
+
30
+ @keyframes slideInRight {
31
+ from { transform: translateX(50px); opacity: 0; }
32
+ to { transform: translateX(0); opacity: 1; }
33
+ }
34
+
35
+ .panel-header {
36
+ padding: 20px;
37
+ border-bottom: 1px solid var(--border-primary);
38
+ display: flex;
39
+ justify-content: space-between;
40
+ align-items: flex-start;
41
+ }
42
+
43
+ .task-title {
44
+ margin: 0;
45
+ font-size: 18px;
46
+ font-weight: 700;
47
+ color: var(--text-primary);
48
+ }
49
+
50
+ .task-ref {
51
+ font-size: 12px;
52
+ color: var(--text-secondary);
53
+ margin-top: 4px;
54
+ font-family: monospace;
55
+ }
56
+
57
+ .close-btn {
58
+ background: none;
59
+ border: none;
60
+ color: var(--text-secondary);
61
+ font-size: 20px;
62
+ cursor: pointer;
63
+ padding: 4px;
64
+ }
65
+
66
+ .panel-content {
67
+ flex: 1;
68
+ overflow-y: auto;
69
+ padding: 20px;
70
+ }
71
+
72
+ .attempt-selector {
73
+ margin-bottom: 20px;
74
+ padding: 12px;
75
+ background: var(--bg-tertiary);
76
+ border-radius: 12px;
77
+ }
78
+
79
+ .selector-label {
80
+ font-size: 12px;
81
+ font-weight: 600;
82
+ margin-bottom: 8px;
83
+ color: var(--text-secondary);
84
+ display: block;
85
+ }
86
+
87
+ .attempt-list {
88
+ display: flex;
89
+ gap: 8px;
90
+ overflow-x: auto;
91
+ padding-bottom: 4px;
92
+ }
93
+
94
+ .attempt-pill {
95
+ padding: 6px 12px;
96
+ border-radius: 20px;
97
+ font-size: 12px;
98
+ cursor: pointer;
99
+ white-space: nowrap;
100
+ transition: all 0.2s;
101
+ border: 1px solid var(--border-primary);
102
+ background: var(--bg-secondary);
103
+ color: var(--text-primary);
104
+ }
105
+
106
+ .attempt-pill.active {
107
+ background: var(--color-accent);
108
+ color: #fff;
109
+ border-color: var(--color-accent);
110
+ }
111
+
112
+ .info-grid {
113
+ display: grid;
114
+ grid-template-columns: 1fr 1fr;
115
+ gap: 16px;
116
+ margin-bottom: 24px;
117
+ }
118
+
119
+ .info-item label {
120
+ font-size: 11px;
121
+ color: var(--text-secondary);
122
+ text-transform: uppercase;
123
+ letter-spacing: 0.5px;
124
+ display: block;
125
+ margin-bottom: 4px;
126
+ }
127
+
128
+ .info-item span {
129
+ font-weight: 600;
130
+ color: var(--text-primary);
131
+ }
132
+
133
+ .status-badge {
134
+ display: inline-flex;
135
+ align-items: center;
136
+ gap: 6px;
137
+ padding: 4px 10px;
138
+ border-radius: 6px;
139
+ font-size: 12px;
140
+ font-weight: 700;
141
+ }
142
+
143
+ .tabs {
144
+ display: flex;
145
+ border-bottom: 1px solid var(--border-primary);
146
+ margin-bottom: 20px;
147
+ }
148
+
149
+ .tab-btn {
150
+ padding: 10px 20px;
151
+ background: none;
152
+ border: none;
153
+ border-bottom: 2px solid transparent;
154
+ color: var(--text-secondary);
155
+ cursor: pointer;
156
+ font-size: 13px;
157
+ transition: all 0.2s;
158
+ }
159
+
160
+ .tab-btn.active {
161
+ color: var(--color-accent);
162
+ border-bottom-color: var(--color-accent);
163
+ font-weight: 600;
164
+ }
165
+
166
+ .json-block {
167
+ background: var(--bg-tertiary);
168
+ padding: 16px;
169
+ border-radius: 12px;
170
+ font-family: 'Fira Code', monospace;
171
+ font-size: 12px;
172
+ line-height: 1.5;
173
+ overflow: auto;
174
+ max-height: 300px;
175
+ color: var(--text-primary);
176
+ }
177
+
178
+ .error-message {
179
+ margin-top: 16px;
180
+ padding: 12px;
181
+ background: rgba(239, 68, 68, 0.1);
182
+ border-left: 3px solid var(--status-failed);
183
+ border-radius: 4px;
184
+ font-size: 12px;
185
+ color: var(--status-failed);
186
+ }
187
+ `}),f.jsxs("div",{className:"panel-header",children:[f.jsxs("div",{children:[f.jsx("h3",{className:"task-title",children:e.name}),f.jsx("div",{className:"task-ref",children:e.taskReferenceName})]}),f.jsx("button",{className:"close-btn",onClick:p,children:"✕"})]}),f.jsxs("div",{className:"panel-content",children:[d.length>1&&f.jsxs("div",{className:"attempt-selector",children:[f.jsxs("label",{className:"selector-label",children:["执行记录 (",d.length," 次尝试",d.some(g=>g.iteration)?" / 迭代":"",")"]}),f.jsx("div",{className:"attempt-list",children:d.map((g,v)=>f.jsx("div",{className:`attempt-pill ${l?.taskId===g.taskId?"active":""}`,onClick:()=>n(g),children:g.iteration?`迭代 ${g.iteration}`:`尝试 ${v+1}`},g.taskId))})]}),f.jsxs("div",{className:"tabs",children:[f.jsx("button",{className:`tab-btn ${o==="summary"?"active":""}`,onClick:()=>s("summary"),children:"概览"}),f.jsx("button",{className:`tab-btn ${o==="input"?"active":""}`,onClick:()=>s("input"),children:"输入 (JSON)"}),f.jsx("button",{className:`tab-btn ${o==="output"?"active":""}`,onClick:()=>s("output"),children:"输出 (JSON)"})]}),o==="summary"&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"info-grid",children:[f.jsxs("div",{className:"info-item",children:[f.jsx("label",{children:"执行状态"}),f.jsxs("div",{className:"status-badge",style:{background:`${m(c?i?.status:l?.status)}20`,color:m(c?i?.status:l?.status)},children:["● ",c?i?.status:l?.status]})]}),f.jsxs("div",{className:"info-item",children:[f.jsx("label",{children:"总耗时"}),f.jsx("span",{children:c?h(i?.startTime,i?.endTime):h(l?.startTime,l?.endTime)})]}),f.jsxs("div",{className:"info-item",children:[f.jsx("label",{children:"开始时间"}),f.jsx("span",{style:{fontSize:"12px"},children:(c?i?.startTime:l?.startTime)?new Date((c?i?.startTime:l?.startTime)||0).toLocaleTimeString():"-"})]}),f.jsxs("div",{className:"info-item",children:[f.jsx("label",{children:"结束时间"}),f.jsx("span",{style:{fontSize:"12px"},children:(c?i?.endTime:l?.endTime)?new Date((c?i?.endTime:l?.endTime)||0).toLocaleTimeString():"-"})]})]}),(c?i?.reasonForIncompletion:l?.reasonForIncompletion)&&f.jsxs("div",{className:"error-message",children:[f.jsx("strong",{children:"异常信息:"}),f.jsx("div",{style:{marginTop:"4px"},children:c?i?.reasonForIncompletion:l?.reasonForIncompletion})]}),f.jsxs("div",{className:"info-item",style:{marginTop:"20px"},children:[f.jsx("label",{children:c?"Workflow ID":"Task ID"}),f.jsx("span",{style:{fontSize:"11px",fontFamily:"monospace",opacity:.7},children:c?i?.workflowId:l?.taskId})]})]}),o==="input"&&f.jsx("div",{className:"json-block",children:f.jsx("pre",{children:JSON.stringify(c?i?.input:l?.inputData||{},null,2)})}),o==="output"&&f.jsx("div",{className:"json-block",children:f.jsx("pre",{children:JSON.stringify(c?i?.output:l?.outputData||{},null,2)})})]})]})},Dy=()=>{const{executionData:e,loadSampleExecution:t,importExecutionJSON:r,workflowInstance:n,setSelectedTask:a,nodes:i}=V(),{fitView:o}=q.useReactFlow(),s=m=>{const g=m.target.files?.[0];if(g){const v=new FileReader;v.onload=x=>{try{const b=JSON.parse(x.target?.result);r(b)}catch(b){console.error("Failed to parse execution JSON:",b)}},v.readAsText(g)}};if(!e)return f.jsxs("div",{className:"execution-status-bar",children:[f.jsx("input",{type:"file",id:"execution-json-upload",accept:".json",onChange:s,style:{display:"none"}}),f.jsx("div",{className:"status-item",children:f.jsx("span",{className:"status-label",children:"准备就绪"})}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("button",{onClick:t,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:"🚀 加载示例运行"}),f.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 c=Object.values(e),u=c.filter(m=>m.status==="COMPLETED").length,d=c.filter(m=>m.status==="FAILED"||m.status==="FAILED_WITH_TERMINAL_ERROR"||m.status==="TIMED_OUT"),l=d.length,p=c.filter(m=>m.status==="IN_PROGRESS"||m.status==="SCHEDULED").length,h=D.useCallback(()=>{if(l===0)return;const m=new Set(d.map(v=>v.taskReferenceName)),g=i.filter(v=>m.has(v.data?.taskReferenceName)).map(v=>v.id);g.length>0&&o({nodes:g.map(v=>({id:v})),duration:500,padding:.3})},[d,i,o,l]);return f.jsxs("div",{className:"execution-status-bar",children:[n&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{className:"status-item",children:[f.jsx("span",{className:"status-label",children:" Workflow ID:"}),f.jsx("span",{className:"status-value highlight",style:{color:"var(--text-primary)",opacity:.8},children:n.workflowId})]}),f.jsx("div",{className:"status-divider"})]}),f.jsxs("div",{className:"status-item",children:[f.jsx("span",{className:"status-label",children:"状态:"}),f.jsx("span",{className:"status-value highlight",style:{color:n?.status==="COMPLETED"?"var(--status-completed)":"var(--status-in-progress)"},children:n?.status||"运行中"})]}),f.jsx("div",{className:"status-divider"}),f.jsxs("div",{className:"status-item",children:[f.jsx("span",{className:"status-label",children:"已完成:"}),f.jsx("span",{className:"status-value",children:u})]}),f.jsxs("div",{className:"status-item",onClick:l>0?h:void 0,style:{cursor:l>0?"pointer":"default",borderRadius:"4px",padding:"2px 6px",transition:"background 0.2s",...l>0?{background:"rgba(239, 68, 68, 0.1)"}:{}},title:l>0?"点击聚焦失败节点":void 0,children:[f.jsx("span",{className:"status-label",style:{color:"var(--status-failed)"},children:"失败:"}),f.jsx("span",{className:"status-value",style:{color:"var(--status-failed)"},children:l})]}),f.jsxs("div",{className:"status-item",children:[f.jsx("span",{className:"status-label",style:{color:"var(--status-in-progress)"},children:"处理中:"}),f.jsx("span",{className:"status-value",style:{color:"var(--status-in-progress)"},children:p})]}),f.jsx("div",{className:"status-divider"}),f.jsx("div",{style:{display:"flex",gap:"8px"},children:f.jsx("button",{onClick:()=>{a({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"})})]})},lh=({isOpen:e,onClose:t,theme:r="dark",onTaskSelect:n})=>{const{validationResults:a,setSelectedTask:i,taskMap:o}=V(),{errors:s,warnings:c}=a||{errors:[],warnings:[]},u=m=>{if(m&&m!=="UNKNOWN"){const g=o[m];g&&(n?n(g):i(g))}},d="var(--glass-surface)",l="var(--text-primary)",p="var(--glass-border)",h="var(--text-secondary)";return e?f.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:[f.jsx("style",{children:`
188
+ @keyframes fadeInSlide {
189
+ from { opacity: 0; transform: translateY(-10px); }
190
+ to { opacity: 1; transform: translateY(0); }
191
+ }
192
+ .health-item:hover {
193
+ background-color: ${r==="light"?"#f1f5f9":"rgba(255,255,255,0.05)"};
194
+ }
195
+ `}),f.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${p}`,display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"rgba(0,0,0,0.02)"},children:[f.jsxs("div",{style:{fontWeight:"bold",fontSize:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[f.jsx("span",{children:"🩺"})," 工作流体检报告"]}),f.jsx("button",{onClick:t,style:{background:"none",border:"none",color:h,cursor:"pointer",fontSize:"18px"},children:"✕"})]}),f.jsx("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:s.length===0&&c.length===0?f.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"#10b981"},children:[f.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:"✅"}),f.jsx("div",{style:{fontWeight:"bold"},children:"未发现问题"}),f.jsx("div",{style:{fontSize:"12px",opacity:.7,marginTop:"4px"},children:"工作流逻辑看起来很完美"})]}):f.jsxs(f.Fragment,{children:[s.map((m,g)=>f.jsxs("div",{className:"health-item",role:"button",tabIndex:m.ref?0:void 0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&u(m.ref)},onClick:()=>u(m.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:m.ref?"pointer":"default",borderLeft:"4px solid #ef4444",transition:"background 0.2s"},children:[f.jsxs("div",{style:{fontSize:"12px",color:"#ef4444",fontWeight:"bold",marginBottom:"2px"},children:["ERROR ",m.ref!=="UNKNOWN"&&`[${m.ref}]`]}),f.jsx("div",{style:{fontSize:"13px",color:l},children:m.message})]},`err-${g}`)),c.map((m,g)=>f.jsxs("div",{className:"health-item",role:"button",tabIndex:m.ref?0:void 0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&u(m.ref)},onClick:()=>u(m.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:m.ref?"pointer":"default",borderLeft:"4px solid #f59e0b",transition:"background 0.2s"},children:[f.jsxs("div",{style:{fontSize:"12px",color:"#f59e0b",fontWeight:"bold",marginBottom:"2px"},children:["WARNING ",m.ref!=="UNKNOWN"&&`[${m.ref}]`]}),f.jsx("div",{style:{fontSize:"13px",color:l},children:m.message})]},`warn-${g}`))]})}),f.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:[f.jsxs("span",{children:["共 ",s.length," 个错误, ",c.length," 个警告"]}),s.length>0&&f.jsx("span",{style:{color:"#ef4444"},children:"无法保存/导出"})]})]}):null},My=({id:e,source:t,target:r,sourceX:n,sourceY:a,targetX:i,targetY:o,sourcePosition:s,targetPosition:c,style:u={},markerEnd:d,data:l})=>{const[p,h]=D.useState(!1),m=D.useRef(null),g=()=>{const E=l?.edgeType||"default",T={sourceX:n,sourceY:a,sourcePosition:s,targetX:i,targetY:o,targetPosition:c};switch(E){case"step":case"smoothstep":return q.getSmoothStepPath(T);case"straight":return q.getStraightPath(T);default:return q.getBezierPath(T)}},[v,x,b]=g(),_=E=>{E.stopPropagation(),E.preventDefault();const T=new CustomEvent("edgeAddNode",{detail:{id:e,source:t,target:r,edgeData:l}});window.dispatchEvent(T)},y=()=>{m.current&&clearTimeout(m.current),h(!0)},S=()=>{m.current=setTimeout(()=>{h(!1)},100)},w=l?.mode==="edit";return f.jsxs(f.Fragment,{children:[f.jsx(q.BaseEdge,{path:v,markerEnd:d,style:{...u,strokeWidth:p?4:2,stroke:p?"#fbbf24":u?.stroke,transition:"stroke 0.2s, stroke-width 0.2s",pointerEvents:"none"}}),f.jsx("path",{d:v,fill:"none",stroke:"transparent",strokeWidth:20,style:{cursor:w?"pointer":"default",pointerEvents:"all"},onMouseEnter:y,onMouseLeave:S}),w&&p&&f.jsx(q.EdgeLabelRenderer,{children:f.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${x}px,${b}px)`,fontSize:12,pointerEvents:"all",zIndex:2e3,display:"flex",flexDirection:"column",alignItems:"center"},className:"nodrag nopan",onMouseEnter:y,onMouseLeave:S,children:[l?.label&&f.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:l.label}),f.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:_,onMouseDown:E=>E.stopPropagation(),title:"在此处添加任务",children:"+"})]})})]})},pe=({onClick:e,icon:t,label:r,title:n,disabled:a=!1,active:i=!1,variant:o="default",style:s})=>{let c="var(--bg-tertiary)",u="var(--text-primary)",d="1px solid var(--border-primary)";return o==="primary"?(c="var(--color-accent)",u="#fff",d="none"):o==="danger"?(c=a?"rgba(239, 68, 68, 0.1)":"var(--status-failed)",u=a?"var(--text-secondary)":"#fff",d="none"):i&&(c="var(--bg-secondary)",u="var(--color-accent)",d="1px solid var(--color-accent)"),f.jsxs("button",{onClick:e,disabled:a,title:n,"aria-label":n||r,"aria-pressed":i,"aria-disabled":a,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:r?"6px":"0",background:c,color:u,border:d,borderRadius:"6px",padding:r?"6px 12px":"8px",cursor:a?"not-allowed":"pointer",opacity:a?.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",...s},children:[t&&f.jsx("span",{style:{fontSize:"14px",display:"flex"},children:t}),r&&f.jsx("span",{children:r})]})},By=()=>{const{zoomIn:e,zoomOut:t,fitView:r}=q.useReactFlow();return f.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px"},children:f.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:[f.jsx(pe,{icon:"➕",title:"放大",onClick:()=>e()}),f.jsx(pe,{icon:"➖",title:"缩小",onClick:()=>t()}),f.jsx(pe,{icon:"⤢",title:"适应屏幕",onClick:()=>r({duration:600})})]})})},Wy=({onShowHealthCheck:e,showHealthCheck:t,onShowSettings:r,executionActions:n})=>{const{mode:a,validationResults:i,workflowInstance:o,workflowDef:s}=V(),c=V.temporal,{undo:u,redo:d,pastStates:l,futureStates:p}=jr(c,v=>v),h=(i?.errors?.length||0)>0,m=o?.status,g=o?.workflowId??"";return f.jsxs("div",{className:"action-bar",style:{display:"flex",gap:"8px"},children:[a==="edit"&&f.jsxs(f.Fragment,{children:[f.jsx(pe,{icon:"↺",title:"撤销 (Cmd+Z)",onClick:()=>u(),disabled:l.length===0}),f.jsx(pe,{icon:"↻",title:"重做 (Cmd+Shift+Z)",onClick:()=>d(),disabled:p.length===0}),f.jsx("div",{style:{width:"1px",height:"20px",background:"var(--border-primary)",margin:"0 4px",alignSelf:"center"}}),f.jsx(pe,{icon:"🩺",label:h?`错误 (${i.errors.length})`:"诊断",title:"流程健康检查",onClick:e,active:t,variant:h?"danger":"secondary"}),f.jsx(pe,{icon:"⚙️",label:"配置",title:"工作流全局配置",onClick:()=>r?.()})]}),a==="run"&&o&&n&&f.jsx(f.Fragment,{children:m==="PAUSED"?n.onResume&&f.jsx(pe,{icon:"▶️",label:"恢复",title:"恢复执行",onClick:()=>n.onResume(g),variant:"primary"}):f.jsxs(f.Fragment,{children:[n.onPause&&m==="RUNNING"&&f.jsx(pe,{icon:"⏸️",label:"暂停",title:"暂停执行",onClick:()=>n.onPause(g)}),n.onTerminate&&m==="RUNNING"&&f.jsx(pe,{icon:"⏹️",label:"停止",title:"终止执行",onClick:()=>n.onTerminate(g),variant:"danger"}),n.onRetry&&(m==="FAILED"||m==="TIMED_OUT"||m==="TERMINATED")&&f.jsx(pe,{icon:"🔄",label:"重试",title:"重试执行",onClick:()=>n.onRetry(g),variant:"primary"}),n.onRestart&&s?.restartable===!0&&f.jsx(pe,{icon:"◀️",label:"重启",title:"重启执行",onClick:()=>n.onRestart(g)})]})})]})},Fy=[{id:"basic",label:"基本信息"},{id:"timeout",label:"超时与容错"},{id:"params",label:"参数配置"},{id:"advanced",label:"高级设置"}],$y=({isOpen:e,onClose:t})=>{const{workflowDef:r,updateWorkflowProperties:n,mode:a}=V(),[i,o]=D.useState(r),[s,c]=D.useState("basic"),u=a!=="edit";D.useEffect(()=>{r&&o(r)},[r,e]);const d=D.useCallback(N=>{N.key==="Escape"&&t()},[t]);if(D.useEffect(()=>{if(e)return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,d]),!e||!i)return null;const l="var(--text-primary)",p="var(--glass-border)",h="var(--bg-tertiary)",m="var(--text-secondary)",g=(N,M)=>{if(!i||u)return;const L={...i,[N]:M};o(L),n({[N]:M})},v=(N,M,L)=>{if(!i||u)return;const U={...i[N]||{},[M]:L};o(W=>({...W,[N]:U})),n({[N]:U})},x=(N,M)=>{if(!(!i||u))try{const L=JSON.parse(M),$={...i,[N]:L};o($),n({[N]:L})}catch{o(L=>({...L,[`_${N}_str`]:M}))}},b={width:"100%",padding:"10px 14px",borderRadius:"8px",border:`1px solid ${p}`,background:h,color:l,fontSize:"14px",outline:"none",boxSizing:"border-box"},_={display:"block",fontSize:"11px",color:m,marginBottom:"8px",fontWeight:600},y=(N,M,L="text",$)=>f.jsxs("div",{style:{marginBottom:"20px"},children:[f.jsx("label",{style:_,children:N.toUpperCase()}),f.jsx("input",{className:"wsp-input",type:L,value:i?.[M]??"",onChange:U=>g(M,L==="number"?U.target.value===""?0:parseInt(U.target.value):U.target.value),disabled:u||$?.readOnly,placeholder:$?.placeholder,style:{...b,opacity:u||$?.readOnly?.6:1}})]}),S=(N,M,L=!1,$=6)=>{const U=i?.[`_${M}_str`]!==void 0?i[`_${M}_str`]:typeof i?.[M]=="object"?JSON.stringify(i[M],null,2):i?.[M];return f.jsxs("div",{style:{marginBottom:"20px"},children:[f.jsxs("label",{style:_,children:[N.toUpperCase()," ",L&&"(JSON)"]}),f.jsx("textarea",{className:"wsp-input",value:U||"",onChange:W=>L?x(M,W.target.value):g(M,W.target.value),rows:$,disabled:u,style:{...b,fontSize:"13px",fontFamily:L?"var(--font-mono)":"inherit",resize:"vertical",opacity:u?.6:1}})]})},w=(N,M,L)=>f.jsxs("div",{style:{marginBottom:"20px"},children:[f.jsx("label",{style:_,children:N.toUpperCase()}),f.jsx("select",{className:"wsp-input",value:i?.[M]??L[0]?.value,onChange:$=>g(M,$.target.value),disabled:u,style:{...b,opacity:u?.6:1,cursor:u?"not-allowed":"pointer"},children:L.map($=>f.jsx("option",{value:$.value,children:$.label},$.value))})]}),E=(N,M)=>{const L=!!i?.[M];return f.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[f.jsx("label",{style:{fontSize:"13px",color:l},children:N}),f.jsx("button",{type:"button",role:"switch","aria-checked":L,onClick:()=>!u&&g(M,!L),disabled:u,style:{width:"44px",height:"24px",borderRadius:"12px",border:"none",background:L?"var(--color-accent)":"var(--border-primary)",position:"relative",cursor:u?"not-allowed":"pointer",transition:"background 0.2s",opacity:u?.6:1,flexShrink:0},children:f.jsx("span",{style:{position:"absolute",top:"2px",left:L?"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)"}})})]})},T=()=>f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"grid",gridTemplateColumns:"3fr 1fr",gap:"20px"},children:[y("工作流名称","name"),y("版本号","version","number")]}),S("描述信息","description",!1,3),y("负责人邮箱","ownerEmail","text",{placeholder:"owner@example.com"}),y("Schema 版本","schemaVersion","number",{readOnly:!0})]}),C=()=>f.jsxs(f.Fragment,{children:[w("超时策略","timeoutPolicy",[{value:"ALERT_ONLY",label:"ALERT_ONLY — 仅告警"},{value:"TIME_OUT_WF",label:"TIME_OUT_WF — 超时终止"}]),f.jsxs("div",{children:[y("超时秒数","timeoutSeconds","number",{placeholder:"0 表示不超时"}),i?.timeoutPolicy==="ALERT_ONLY"&&f.jsx("p",{style:{fontSize:"11px",color:m,marginTop:"-12px",marginBottom:"20px"},children:"当前策略为 ALERT_ONLY,超时仅触发告警,不会终止工作流。"})]}),y("失败补偿工作流","failureWorkflow","text",{placeholder:"输入补偿工作流名称"}),E("允许重启 (restartable)","restartable")]}),R=()=>f.jsxs(f.Fragment,{children:[S("输入参数声明 (inputParameters)","inputParameters",!0),S("输出参数映射 (outputParameters)","outputParameters",!0),S("默认输入模板 (inputTemplate)","inputTemplate",!0),S("工作流级变量 (variables)","variables",!0)]}),A=()=>f.jsxs(f.Fragment,{children:[E("启用状态监听 (workflowStatusListenerEnabled)","workflowStatusListenerEnabled"),i?.workflowStatusListenerEnabled&&y("状态事件目标 (Listener Sink)","workflowStatusListenerSink","text",{placeholder:"conductor:workflow_status_event"}),f.jsxs("div",{style:{borderTop:`1px solid ${p}`,marginTop:"8px",paddingTop:"20px"},children:[E("强制 Schema 校验 (enforceSchema)","enforceSchema"),i?.enforceSchema&&f.jsxs(f.Fragment,{children:[S("输入 Schema (inputSchema)","inputSchema",!0,4),S("输出 Schema (outputSchema)","outputSchema",!0,4)]})]}),f.jsxs("div",{style:{borderTop:`1px solid ${p}`,marginTop:"8px",paddingTop:"20px"},children:[f.jsx("label",{style:{..._,marginBottom:"16px"},children:"并发限流 (RATE LIMIT)"}),f.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"20px"},children:[f.jsxs("div",{children:[f.jsx("label",{style:_,children:"RATE LIMIT KEY"}),f.jsx("input",{className:"wsp-input",type:"text",value:i?.rateLimitConfig?.rateLimitKey??"",onChange:N=>v("rateLimitConfig","rateLimitKey",N.target.value),disabled:u,placeholder:"限流键",style:{...b,opacity:u?.6:1}})]}),f.jsxs("div",{children:[f.jsx("label",{style:_,children:"并发上限"}),f.jsx("input",{className:"wsp-input",type:"number",value:i?.rateLimitConfig?.concurrentExecLimit??"",onChange:N=>v("rateLimitConfig","concurrentExecLimit",N.target.value===""?0:parseInt(N.target.value)),disabled:u,placeholder:"0",style:{...b,opacity:u?.6:1}})]})]})]})]}),B=()=>{switch(s){case"basic":return T();case"timeout":return C();case"params":return R();case"advanced":return A()}};return f.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"工作流全局配置",onClick:t,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:f.jsxs("div",{onClick:N=>N.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:[f.jsxs("div",{style:{padding:"24px 32px 0 32px",background:"var(--bg-highlight)"},children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[f.jsxs("div",{children:[f.jsx("h2",{style:{margin:0,fontSize:"20px",color:l},children:"工作流全局配置"}),f.jsx("p",{style:{margin:"4px 0 0 0",fontSize:"12px",color:m},children:u?"当前为只读模式":"配置工作流级属性,所有更改将实时保存"})]}),f.jsx("button",{className:"wsp-close",onClick:t,"aria-label":"关闭",style:{background:"none",border:"none",color:l,fontSize:"24px",cursor:"pointer",opacity:.6},children:"✕"})]}),f.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${p}`},children:Fy.map(N=>f.jsx("button",{className:"wsp-tab",onClick:()=>c(N.id),style:{padding:"10px 20px",fontSize:"13px",fontWeight:s===N.id?600:400,color:s===N.id?"var(--color-accent)":m,background:"none",border:"none",borderBottom:s===N.id?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s",marginBottom:"-1px"},children:N.label},N.id))})]}),f.jsx("div",{style:{flex:1,overflowY:"auto",padding:"28px 32px"},children:B()}),f.jsx("div",{style:{padding:"20px 32px",borderTop:`1px solid ${p}`,background:"var(--bg-highlight)",display:"flex",justifyContent:"flex-end"},children:f.jsx("button",{className:"wsp-footer-btn",onClick:t,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:"完成并关闭"})})]})})},zy=({onRequestImport:e})=>{const{createBlankWorkflow:t}=V(),[r,n]=D.useState(""),a=()=>{t(r||void 0),V.temporal.getState().clear()},i=()=>{t(r||void 0),V.temporal.getState().clear(),window.dispatchEvent(new CustomEvent("open-ai-chat"))};return f.jsxs("div",{className:"empty-state-panel",children:[f.jsx("h2",{className:"empty-state-title",children:"创建新工作流"}),f.jsx("p",{className:"empty-state-subtitle",children:"从空白画布开始设计,或让 AI 帮你生成完整流程"}),f.jsx("input",{className:"empty-state-name-input",type:"text",placeholder:"工作流名称(可选)",value:r,onChange:o=>n(o.target.value),onKeyDown:o=>{o.key==="Enter"&&a()}}),f.jsxs("div",{className:"empty-state-actions",children:[f.jsxs("button",{className:"empty-state-btn primary",onClick:a,children:[f.jsx("span",{className:"empty-state-btn-icon",children:"📄"}),"空白工作流"]}),f.jsxs("button",{className:"empty-state-btn",onClick:i,children:[f.jsx("span",{className:"empty-state-btn-icon",children:"✨"}),"AI 生成"]}),e&&f.jsxs("button",{className:"empty-state-btn",onClick:e,children:[f.jsx("span",{className:"empty-state-btn-icon",children:"📤"}),"导入 JSON"]})]})]})},Hy={success:{bg:"#10b981",text:"#fff"},error:{bg:"#ef4444",text:"#fff"},info:{bg:"var(--color-accent)",text:"#fff"}},Gy=({messages:e,onDismiss:t})=>e.length===0?null:f.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=>f.jsx(Uy,{message:r,onDismiss:t},r.id))}),Uy=({message:e,onDismiss:t})=>{const r=Hy[e.type||"info"];return D.useEffect(()=>{const n=setTimeout(()=>t(e.id),2500);return()=>clearTimeout(n)},[e.id,t]),f.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:()=>t(e.id),children:e.text})},fh=["shift","alt","meta","mod","ctrl","control"],Ky={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 Ee(e){return(Ky[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function ph(e){return fh.includes(e)}function bs(e,t=","){return e.toLowerCase().split(t)}function xs(e,t="+",r=">",n=!1,a){let i=[],o=!1;e=e.trim(),e.includes(r)?(o=!0,i=e.toLocaleLowerCase().split(r).map(u=>Ee(u))):i=e.toLocaleLowerCase().split(t).map(u=>Ee(u));const s={alt:i.includes("alt"),ctrl:i.includes("ctrl")||i.includes("control"),shift:i.includes("shift"),meta:i.includes("meta"),mod:i.includes("mod"),useKey:n},c=i.filter(u=>!fh.includes(u));return{...s,keys:c,description:a,isSequence:o,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&hh([Ee(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&vh([Ee(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{ke.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{ke.clear()},0)}));const ke=new Set;function _s(e){return Array.isArray(e)}function Jy(e,t=","){return(_s(e)?e:e.split(t)).every(r=>ke.has(r.trim().toLowerCase()))}function hh(e){const t=Array.isArray(e)?e:[e];ke.has("meta")&&ke.forEach(r=>!ph(r)&&ke.delete(r.toLowerCase())),t.forEach(r=>ke.add(r.toLowerCase()))}function vh(e){const t=Array.isArray(e)?e:[e];e==="meta"?ke.clear():t.forEach(r=>ke.delete(r.toLowerCase()))}function Vy(e,t,r){(typeof r=="function"&&r(e,t)||r===!0)&&e.preventDefault()}function Yy(e,t,r){return typeof r=="function"?r(e,t):r===!0||r===void 0}const Xy=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function Zy(e){return gh(e,Xy)}function gh(e,t=!1){const{target:r,composed:n}=e;let a,i;return Qy(r)&&n?(a=e.composedPath()[0]&&e.composedPath()[0].tagName,i=e.composedPath()[0]&&e.composedPath()[0].role):(a=r&&r.tagName,i=r&&r.role),_s(t)?!!(a&&t&&t.some(o=>o.toLowerCase()===a.toLowerCase()||o===i)):!!(a&&t&&t)}function Qy(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function eb(e,t){return e.length===0&&t?(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):t?e.some(r=>t.includes(r))||e.includes("*"):!0}const rb=(e,t,r=!1)=>{const{alt:n,meta:a,mod:i,shift:o,ctrl:s,keys:c,useKey:u}=t,{code:d,key:l,ctrlKey:p,metaKey:h,shiftKey:m,altKey:g}=e,v=Ee(d);if(u&&c?.length===1&&c.includes(l))return!0;if(!c?.includes(v)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(v))return!1;if(!r){if(n!==g&&v!=="alt"||o!==m&&v!=="shift")return!1;if(i){if(!h&&!p)return!1}else if(a!==h&&v!=="meta"&&v!=="os"||s!==p&&v!=="ctrl"&&v!=="control")return!1}return c&&c.length===1&&c.includes(v)?!0:c?Jy(c):!c},tb=D.createContext(void 0),nb=()=>D.useContext(tb);function mh(e,t){return e&&t&&typeof e=="object"&&typeof t=="object"?Object.keys(e).length===Object.keys(t).length&&Object.keys(e).reduce((r,n)=>r&&mh(e[n],t[n]),!0):e===t}const ab=D.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),ib=()=>D.useContext(ab);function ob(e){const t=D.useRef(void 0);return mh(t.current,e)||(t.current=e),t.current}const yh=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},sb=typeof window<"u"?D.useLayoutEffect:D.useEffect;function ze(e,t,r,n){const a=D.useRef(null),i=D.useRef(!1),o=Array.isArray(r)?Array.isArray(n)?void 0:n:r,s=_s(e)?e.join(o?.delimiter):e,c=Array.isArray(r)?r:Array.isArray(n)?n:void 0,u=D.useCallback(t,c??[]),d=D.useRef(u);c?d.current=u:d.current=t;const l=ob(o),{activeScopes:p}=ib(),h=nb();return sb(()=>{if(l?.enabled===!1||!eb(p,l?.scopes))return;let m=[],g;const v=(y,S=!1)=>{if(!(Zy(y)&&!gh(y,l?.enableOnFormTags))){if(a.current!==null){const w=a.current.getRootNode();if((w instanceof Document||w instanceof ShadowRoot)&&w.activeElement!==a.current&&!a.current.contains(w.activeElement)){yh(y);return}}y.target?.isContentEditable&&!l?.enableOnContentEditable||bs(s,l?.delimiter).forEach(w=>{if(w.includes(l?.splitKey??"+")&&w.includes(l?.sequenceSplitKey??">")){console.warn(`Hotkey ${w} contains both ${l?.splitKey??"+"} and ${l?.sequenceSplitKey??">"} which is not supported.`);return}const E=xs(w,l?.splitKey,l?.sequenceSplitKey,l?.useKey,l?.description);if(E.isSequence){g=setTimeout(()=>{m=[]},l?.sequenceTimeoutMs??1e3);const T=E.useKey?y.key:Ee(y.code);if(ph(T.toLowerCase()))return;m.push(T);const C=E.keys?.[m.length-1];if(T!==C){m=[],g&&clearTimeout(g);return}m.length===E.keys?.length&&(d.current(y,E),g&&clearTimeout(g),m=[])}else if(rb(y,E,l?.ignoreModifiers)||E.keys?.includes("*")){if(l?.ignoreEventWhen?.(y)||S&&i.current)return;if(Vy(y,E,l?.preventDefault),!Yy(y,E,l?.enabled)){yh(y);return}d.current(y,E),S||(i.current=!0)}})}},x=y=>{y.code!==void 0&&(hh(Ee(y.code)),(l?.keydown===void 0&&l?.keyup!==!0||l?.keydown)&&v(y))},b=y=>{y.code!==void 0&&(vh(Ee(y.code)),i.current=!1,l?.keyup&&v(y,!0))},_=a.current||o?.document||document;return _.addEventListener("keyup",b,o?.eventListenerOptions),_.addEventListener("keydown",x,o?.eventListenerOptions),h&&bs(s,l?.delimiter).forEach(y=>h.addHotkey(xs(y,l?.splitKey,l?.sequenceSplitKey,l?.useKey,l?.description))),()=>{_.removeEventListener("keyup",b,o?.eventListenerOptions),_.removeEventListener("keydown",x,o?.eventListenerOptions),h&&bs(s,l?.delimiter).forEach(y=>h.removeHotkey(xs(y,l?.splitKey,l?.sequenceSplitKey,l?.useKey,l?.description))),m=[],g&&clearTimeout(g)}},[s,l,p]),a}const ub=e=>{const{mode:t,removeNode:r,selectedTask:n,pasteTask:a}=V(),i=V.temporal,{undo:o,redo:s}=jr(i,p=>p),c=e?.confirm||(p=>Promise.resolve(window.confirm(p))),u=e?.showToast,d=p=>{const h=p.target;return h.tagName==="INPUT"||h.tagName==="TEXTAREA"||h.isContentEditable},l=()=>{requestAnimationFrame(()=>{const p=V.getState(),{nodes:h,edges:m}=ae(p.nodes,p.edges,{direction:p.layoutDirection,mode:p.mode});V.setState({nodes:h,edges:m})})};return ze("mod+z",p=>{t==="edit"&&(d(p)||(p.preventDefault(),o(),l()))},[t,o]),ze(["mod+shift+z","mod+y"],p=>{t==="edit"&&(d(p)||(p.preventDefault(),s(),l()))},[t,s]),ze("delete, backspace",p=>{t!=="edit"||!n||d(p)||(p.preventDefault(),c("确定要删除此任务吗?").then(h=>{h&&r(n.taskReferenceName)}))},[t,n,r,c]),ze("mod+c",p=>{if(!(t!=="edit"||!n)&&!d(p)){if(n.type==="JOIN"){u?.("JOIN 任务不能独立复制","error");return}p.preventDefault();try{localStorage.setItem("conductor-clipboard",JSON.stringify(n)),u?.("任务已复制","success")}catch{u?.("复制失败","error")}}},[t,n,u]),ze("mod+v",p=>{if(t==="edit"&&!d(p)){p.preventDefault();try{const h=localStorage.getItem("conductor-clipboard");if(h){const m=JSON.parse(h);a(m),u?.("任务已粘贴","success")}}catch{u?.("粘贴失败","error")}}},[t,a,u]),ze("mod+s",p=>{p.preventDefault();const h=V.getState().workflowDef;h&&e?.onSave&&e.onSave(h)},[e?.onSave]),{}},cb=()=>{const[e,t]=D.useState(null),r=D.useCallback(i=>new Promise(o=>{t({message:i,resolve:o})}),[]),n=D.useCallback(()=>{e?.resolve(!0),t(null)},[e]),a=D.useCallback(()=>{e?.resolve(!1),t(null)},[e]);return{confirm:r,confirmState:e,handleConfirm:n,handleCancel:a}},db=()=>{const[e,t]=D.useState([]),r=D.useCallback((a,i="info")=>{const o=Date.now().toString();t(s=>[...s,{id:o,text:a,type:i}])},[]),n=D.useCallback(a=>{t(i=>i.filter(o=>o.id!==a))},[]);return{toasts:e,showToast:r,dismissToast:n}},lb={taskNode:Cy,decisionNode:Ry,forkNode:ch.ForkNode,joinNode:ch.JoinNode,loopNode:Oy,subWorkflowNode:Ay},fb={addableEdge:My},pb=({onNodeClick:e,searchQuery:t="",onSave:r,onRequestImport:n,executionActions:a})=>{const{nodes:i,edges:o,onNodesChange:s,onEdgesChange:c,onConnect:u,mode:d,selectedTask:l,setSelectedTask:p,theme:h,edgeType:m,addNode:g,nodesLocked:v,executionData:x,validationResults:b,setIsDetailPanelOpen:_,workflowDef:y}=V(),{fitView:S}=q.useReactFlow(),[w,E]=D.useState(!1),[T,C]=D.useState(null),[R,A]=D.useState(!1),[B,N]=D.useState(!1),{confirm:M,confirmState:L,handleConfirm:$,handleCancel:U}=cb(),{toasts:W,showToast:z,dismissToast:K}=db();ub({confirm:M,showToast:z,onSave:r}),D.useEffect(()=>{if(l){const k=i.find(I=>I.data.taskReferenceName===l.taskReferenceName);k&&S({nodes:[k],duration:800,padding:.5})}},[l?.taskReferenceName,S]),D.useEffect(()=>{const k=()=>{S({duration:800})};return window.addEventListener("workflow-zoom-to-fit",k),()=>window.removeEventListener("workflow-zoom-to-fit",k)},[S]),D.useEffect(()=>{const k=O=>{e&&O.detail&&O.detail.task&&e(O.detail.task)},I=O=>{d==="edit"&&(C({sourceId:O.detail.loopId,edgeData:{isLoopAdd:!0}}),E(!0))},P=O=>{d==="edit"&&(C({sourceId:O.detail.source,targetId:O.detail.target,edgeId:O.detail.id,edgeData:O.detail.edgeData}),E(!0))};return document.addEventListener("miniTaskClick",k),document.addEventListener("loopAddNodeRequested",I),window.addEventListener("edgeAddNode",P),()=>{document.removeEventListener("miniTaskClick",k),document.removeEventListener("loopAddNodeRequested",I),window.removeEventListener("edgeAddNode",P)}},[d,e]);const j=D.useCallback(k=>{if(T){const{sourceId:I,targetId:P,edgeId:O,edgeData:H}=T;g({data:{label:`New ${k}`,taskReferenceName:`${k.toLowerCase()}_${Date.now()}`,taskType:k}},I,P,O,H)}E(!1),C(null)},[T,g]),F=D.useMemo(()=>o.map(k=>{const I=k.id.includes("loop-back");let O={...{...k.style,stroke:h==="light"?"#475569":"#64748b",strokeWidth:2,strokeDasharray:I?"5,5":void 0}},H=!I;if(d==="run"&&x){const Z=x[k.source]?.status,ee=x[k.target]?.status,ce=Z==="COMPLETED"||k.source==="start";ce&&ee==="COMPLETED"?(O={...O,stroke:"var(--status-completed)",strokeWidth:4},H=!1):ce&&ee==="IN_PROGRESS"&&(O={...O,stroke:"var(--status-in-progress)",strokeWidth:4},H=!0)}return{...k,type:d==="edit"&&!I?"addableEdge":m,data:{...k.data,mode:d,edgeType:m,label:k.label},markerEnd:{type:q.MarkerType.ArrowClosed,width:20,height:20,color:O.stroke},style:O,animated:H}}),[o,m,h,d,x]);return f.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",background:"var(--bg-secondary)"},children:[f.jsxs(q,{nodes:D.useMemo(()=>{const k=new Set(b.errors.filter(O=>O.type==="TASK").map(O=>O.ref)),I=new Set(b.warnings.filter(O=>O.type==="TASK").map(O=>O.ref)),P=t.toLowerCase();return i.map(O=>{const H=O.data.taskReferenceName;return{...O,selected:l?.taskReferenceName===H,data:{...O.data,isError:k.has(H),hasWarning:I.has(H),isHighlighted:t?O.data.label.toLowerCase().includes(P)||O.data.taskReferenceName.toLowerCase().includes(P):!1}}})},[i,b,t,l]),edges:F,onNodesChange:s,onEdgesChange:c,onConnect:u,nodeTypes:lb,edgeTypes:fb,onNodeClick:(k,I)=>{const P=I.data.task||null;p(P),e&&e(P)},onPaneClick:()=>{p(null),d!=="run"&&_(!1)},fitView:!0,nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!0,minZoom:.2,maxZoom:2,children:[f.jsx(q.Background,{color:"var(--border-primary)",gap:20}),f.jsx(q.Panel,{position:"bottom-left",style:{marginBottom:"20px",marginLeft:"20px",zIndex:1e3},children:f.jsx(By,{})}),d==="run"&&f.jsx(q.Panel,{position:"bottom-center",children:f.jsx(Dy,{})}),d==="run"&&f.jsx(dh,{}),f.jsx(lh,{isOpen:R,onClose:()=>A(!1),theme:h,onTaskSelect:k=>{p(k)}}),f.jsx("div",{style:{position:"absolute",top:20,right:20,zIndex:1e3},children:f.jsx(Wy,{onShowHealthCheck:()=>A(!R),showHealthCheck:R,onShowSettings:()=>N(!0),executionActions:a})})]}),!y&&f.jsx(zy,{onRequestImport:n}),w&&f.jsx(Ly,{theme:h,onSelect:j,onCancel:()=>E(!1)}),f.jsx($y,{isOpen:B,onClose:()=>N(!1)}),L&&f.jsx(Qp,{message:L.message,onConfirm:$,onCancel:U}),f.jsx(Gy,{messages:W,onDismiss:K})]})},bh={apiKey:"",baseUrl:"https://api.openai.com/v1",model:"gpt-4o"},hb=async(e,t={},r)=>{const n={...bh,...t};if(!n.apiKey)throw new Error("Please configure AI API Key in settings.");const a=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:r});if(!a.ok){const o=await a.json();throw new Error(o.error?.message||"AI request failed")}return(await a.json()).choices[0].message.content},vb=async(e,t={},r,n,a)=>{const i={...bh,...t};if(!i.apiKey)throw new Error("Please configure AI API Key in settings.");const o=await fetch(`${i.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${i.apiKey}`},body:JSON.stringify({model:i.model,messages:e,temperature:.7,stream:!0}),signal:a});if(!o.ok){const d=await o.json();throw new Error(d.error?.message||"AI request failed")}const s=o.body?.getReader();if(!s)throw new Error("ReadableStream not supported");const c=new TextDecoder;let u="";for(;;){const{done:d,value:l}=await s.read();if(d)break;const h=c.decode(l,{stream:!0}).split(`
196
+ `).filter(m=>m.trim()!=="");for(const m of h)if(m.startsWith("data: ")){const g=m.slice(6);if(g==="[DONE]")return u;try{const x=JSON.parse(g).choices?.[0]?.delta?.content;x&&(u+=x,r(x))}catch{console.warn("[AI SSE] malformed chunk:",g)}}}return u},gb=`
197
+ You are an expert in Netflix Conductor Workflow modeling.
198
+ Your goal is to help users design JSON-based workflows.
199
+
200
+ CONSTRANTS:
201
+ 1. Always output valid Conductor JSON within blocks if suggesting changes.
202
+ 2. Use standard task types: SIMPLE, FORK_JOIN, SWITCH, DO_WHILE, SUB_WORKFLOW, EVENT, WAIT, TERMINATE.
203
+ 3. Every task must have a unique 'taskReferenceName'.
204
+ 4. For SWITCH/DECISION, ensure 'decisionCases' and 'defaultCase' are properly structured.
205
+ 5. For FORK_JOIN, ensure a corresponding JOIN task follows.
206
+
207
+ Provide clear, enterprise-grade logic with proper error handling paths.
208
+ `,mb=(e,t)=>{const r=t?`Current Workflow State:
209
+ ${JSON.stringify(t,null,2)}`:"Initial state: No workflow defined yet.";return`
210
+ User Request: ${e}
211
+
212
+ ${r}
213
+
214
+ Please provide a JSON suggestion that fulfills the user's request.
215
+ If modifying the current workflow, return the ENTIRE updated JSON.
216
+ Wrap the JSON in triple backticks with 'json' label.
217
+ `},yb=(e,t)=>`
218
+ Context: I am configuring a Conductor task in a workflow.
219
+ Task Reference Name: ${e.taskReferenceName}
220
+ Task Type: ${e.type}
221
+
222
+ Full Workflow Structure for reference:
223
+ ${JSON.stringify(t,null,2)}
224
+
225
+ Requirement: Suggest 3 meaningful 'inputParameters' or JSONPath expressions for this task based on the workflow context.
226
+ Return the suggestions as a JSON array of objects with { label, value, description }.
227
+ `,bb=({isOpen:e,onClose:t,onSelect:r,suggestions:n,anchorRect:a})=>{if(!e||!a)return null;const i={position:"fixed",top:a.bottom+8,left:Math.max(a.left-200,20),width:"280px",zIndex:3e3};return f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"suggester-overlay",onClick:t}),f.jsxs("div",{className:"parameter-suggester-popover glass-panel",style:i,children:[f.jsxs("div",{className:"suggester-header",children:[f.jsx("span",{className:"sparkle-icon",children:"✨"}),"AI Suggestions"]}),f.jsx("div",{className:"suggester-list",children:n.length===0?f.jsxs("div",{className:"suggester-loading",children:[f.jsx("div",{className:"suggester-skeleton-line",style:{width:"85%"}}),f.jsx("div",{className:"suggester-skeleton-line",style:{width:"65%"}}),f.jsx("div",{className:"suggester-skeleton-line",style:{width:"75%"}})]}):n.map((o,s)=>f.jsxs("div",{className:"suggestion-item",onClick:()=>{r(o.value),t()},children:[f.jsx("div",{className:"suggestion-label",children:o.label}),f.jsx("div",{className:"suggestion-value",children:o.value}),f.jsx("div",{className:"suggestion-desc",children:o.description})]},s))})]})]})},xb=({task:e,isOpen:t=!0,onClose:r,aiConfig:n})=>{const{mode:a,updateTask:i,checkTaskRefUniqueness:o}=V(),[s,c]=D.useState(e),[u,d]=D.useState(!1),[l,p]=D.useState(),[h,m]=D.useState([]),[g,v]=D.useState(()=>()=>{}),x=[{label:"引用工作流输入",value:"${workflow.input.data}",description:"引用工作流启动时传入的原始数据"},{label:"引用前序任务输出",value:"${previous_task.output.result}",description:"引用上一个节点的计算结果"},{label:"环境变量",value:"${workflow.variables.api_key}",description:"引用工作流定义的全局变量"}],b=async(W,z)=>{const K=W.currentTarget.getBoundingClientRect();p(K),v(()=>z),m([]),d(!0);const j=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!j){m(x);return}try{const F=n?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",G=n?.model||localStorage.getItem("AI_MODEL")||"",k={apiKey:j};F&&(k.baseUrl=F),G&&(k.model=G);const{workflowDef:I}=V.getState(),P=yb(_,I),H=(await hb([{role:"system",content:"You are a Conductor workflow expert. Return only valid JSON."},{role:"user",content:P}],k)).match(/\[[\s\S]*\]/);if(H){const J=JSON.parse(H[0]);m(J)}else m(x)}catch(F){console.warn("[AI ParameterSuggester] fallback to mock:",F),m(x)}};if(D.useEffect(()=>{e&&c(e)},[e]),!e&&!s)return null;const _=e||s,y=s&&e&&s.taskReferenceName===e.taskReferenceName?s:_,S=t&&e?"panel-enter-active":"panel-exit",w=a==="edit",E="var(--text-primary)",T="var(--glass-border)",C="var(--bg-tertiary)",R="var(--text-secondary)",A=(W,z)=>{const K={...y,[W]:z};c(K),i(y.taskReferenceName,{[W]:z})},B=(W,z,K)=>{const F={...y[W]||{},[z]:K},G={...y,[W]:F};c(G),i(y.taskReferenceName,{[W]:F})},N=(W,z)=>{const K=y.inputParameters||{},F={...K.http_request||y.httpRequest||{},[W]:z},k={inputParameters:{...K,http_request:F}};y.httpRequest&&(k.httpRequest=F);const I={...y,...k};c(I),i(y.taskReferenceName,k)},M=(W,z)=>{const j={inputParameters:{...y.inputParameters,[W]:z}},F={...y,...j};c(F),i(y.taskReferenceName,j)},L=(W,z,K,j)=>f.jsxs("div",{style:{marginBottom:"24px",padding:"16px",borderRadius:"12px",background:`${K}10`,border:`1px solid ${K}30`,boxShadow:"0 4px 12px rgba(0,0,0,0.05)"},children:[f.jsxs("div",{style:{fontSize:"12px",fontWeight:"bold",marginBottom:"16px",color:K,display:"flex",alignItems:"center",gap:"8px"},children:[f.jsx("span",{children:z})," ",W]}),j]}),$=(W,z,K="text")=>{const j=z==="taskReferenceName",F=j&&!o(y[z],y.taskReferenceName);return f.jsxs("div",{style:{marginBottom:"16px"},children:[f.jsxs("label",{style:{display:"block",fontSize:"11px",color:R,marginBottom:"6px",fontWeight:"600",textTransform:"uppercase"},children:[W,j&&F&&f.jsx("span",{style:{color:"#ef4444",marginLeft:"8px",textTransform:"none"},children:"⚠️ 已存在相同引用名"})]}),f.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[f.jsx("input",{type:K,value:y[z]||"",onChange:G=>A(z,G.target.value),disabled:!w||j&&!w,style:{width:"100%",padding:`8px ${w&&!j?"32px":"12px"} 8px 12px`,borderRadius:"6px",border:`1px solid ${F?"#ef4444":T}`,background:C,color:E,fontSize:"13px",outline:"none",opacity:w?1:.8,fontFamily:j?"monospace":"inherit"}}),w&&!j&&f.jsx("button",{className:"ai-hint-trigger",onClick:G=>b(G,k=>A(z,k)),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:"✨"})]})]})},U=(W,z,K=!1)=>{const j=typeof y[z]=="object"?JSON.stringify(y[z],null,2):y[z];return f.jsxs("div",{style:{marginBottom:"16px"},children:[f.jsxs("label",{style:{display:"block",fontSize:"11px",color:R,marginBottom:"6px",fontWeight:"600",textTransform:"uppercase"},children:[W," ",K&&f.jsx("span",{style:{opacity:.5,fontWeight:"normal"},children:"(JSON)"})]}),f.jsx("textarea",{value:j||"",onChange:F=>{let G=F.target.value;if(K)try{G=JSON.parse(F.target.value)}catch{c(I=>({...I,[z]:F.target.value}));return}A(z,G)},disabled:!w,rows:z==="description"?3:5,style:{width:"100%",padding:"8px 12px",borderRadius:"6px",border:`1px solid ${T}`,background:C,color:E,fontSize:"12px",fontFamily:"monospace",outline:"none",resize:"vertical"}})]})};return f.jsxs("div",{className:`detail-panel-container ${S}`,style:{position:"absolute",right:0,top:0,bottom:0,width:"450px",zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${T}`,boxShadow:"-10px 0 30px rgba(0, 0, 0, 0.2)",overflowY:"hidden"},children:[f.jsxs("div",{style:{padding:"24px",borderBottom:`1px solid ${T}`,background:"var(--bg-secondary)",flexShrink:0},children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[f.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:"4px",fontSize:"10px",fontWeight:"bold",letterSpacing:"1px"},children:y.type||"TASK"}),f.jsx("button",{onClick:r,style:{background:"none",border:"none",color:E,cursor:"pointer",fontSize:"20px"},children:"✕"})]}),w?f.jsx("input",{value:y.name||"",onChange:W=>A("name",W.target.value),placeholder:"任务名称",style:{display:"block",width:"100%",fontSize:"22px",fontWeight:"bold",background:"transparent",border:"none",color:E,outline:"none",borderBottom:"2px dashed var(--color-accent)"}}):f.jsx("div",{style:{fontSize:"22px",fontWeight:"bold"},children:y.name}),f.jsxs("div",{style:{fontSize:"12px",color:R,marginTop:"8px",fontFamily:"monospace",opacity:.8},children:["REF: ",y.taskReferenceName]})]}),f.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px",background:"var(--bg-primary)"},children:[y.type==="HTTP"&&L("HTTP 请求配置","🌐","var(--color-accent)",f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"12px"},children:[f.jsx("select",{value:y.inputParameters?.http_request?.method||y.httpRequest?.method||"GET",onChange:W=>N("method",W.target.value),disabled:!w,style:{width:"90px",padding:"10px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`,cursor:"pointer"},children:["GET","POST","PUT","DELETE","PATCH"].map(W=>f.jsx("option",{value:W,children:W},W))}),f.jsx("input",{placeholder:"URI (支持 ${workflow.input.uri})",value:y.inputParameters?.http_request?.uri||y.httpRequest?.uri||"",onChange:W=>N("uri",W.target.value),disabled:!w,style:{flex:1,padding:"10px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`}})]}),f.jsxs("div",{style:{marginBottom:"12px"},children:[f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"HEADERS (JSON)"}),f.jsx("textarea",{value:typeof(y.inputParameters?.http_request?.headers||y.httpRequest?.headers)=="object"?JSON.stringify(y.inputParameters?.http_request?.headers||y.httpRequest?.headers,null,2):"{}",onChange:W=>{try{N("headers",JSON.parse(W.target.value))}catch{}},disabled:!w,rows:3,style:{width:"100%",padding:"8px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`,fontSize:"11px",fontFamily:"monospace"}})]}),f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"BODY (RAW/JSON)"}),f.jsx("textarea",{value:typeof(y.inputParameters?.http_request?.body||y.httpRequest?.body)=="object"?JSON.stringify(y.inputParameters?.http_request?.body||y.httpRequest?.body,null,2):y.inputParameters?.http_request?.body||y.httpRequest?.body||"",onChange:W=>{let z=W.target.value;try{z=JSON.parse(W.target.value)}catch{}N("body",z)},disabled:!w,rows:4,style:{width:"100%",padding:"8px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`,fontSize:"11px",fontFamily:"monospace"}})]})),y.type==="LAMBDA"&&L("Lambda 脚本配置","📜","var(--color-accent)",f.jsxs(f.Fragment,{children:[f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"SCRIPT EXPRESSION (JS)"}),f.jsx("textarea",{value:y.inputParameters?.scriptExpression||"",onChange:W=>M("scriptExpression",W.target.value),disabled:!w,rows:10,style:{width:"100%",padding:"12px",borderRadius:"8px",background:"#000",color:"var(--color-accent)",border:"1px solid var(--color-accent)",fontSize:"12px",fontFamily:"monospace",lineHeight:"1.5"}}),f.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:R,fontStyle:"italic"},children:"提示: 使用 `$.input.key` 访问参数,返回值为节点输出。"})]})),y.type==="JSON_JQ_TRANSFORM"&&L("JQ 数据转换","🔍","var(--color-accent)",f.jsxs(f.Fragment,{children:[f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"JQ QUERY"}),f.jsx("textarea",{value:y.inputParameters?.queryExpression||"",onChange:W=>M("queryExpression",W.target.value),disabled:!w,rows:6,style:{width:"100%",padding:"12px",borderRadius:"8px",background:C,color:"var(--color-accent)",border:`1px solid ${T}`,fontSize:"12px",fontFamily:"monospace",lineHeight:"1.5"}})]})),y.type==="SUB_WORKFLOW"&&L("子工作流配置","🏗️","var(--color-accent)",f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{marginBottom:"12px"},children:[f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"WORKFLOW NAME"}),f.jsx("input",{value:y.subWorkflowParam?.name||"",onChange:W=>B("subWorkflowParam","name",W.target.value),disabled:!w,style:{width:"100%",padding:"10px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`}})]}),f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"VERSION"}),f.jsx("input",{type:"number",value:y.subWorkflowParam?.version||1,onChange:W=>B("subWorkflowParam","version",parseInt(W.target.value)),disabled:!w,style:{width:"100px",padding:"10px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`}})]})),y.type==="TERMINATE"&&L("终止状态配置","⏹️","var(--color-accent)",f.jsxs(f.Fragment,{children:[f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"TERMINATION STATUS"}),f.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:["COMPLETED","FAILED"].map(W=>f.jsx("button",{onClick:()=>M("terminationStatus",W),disabled:!w,style:{flex:1,padding:"8px",borderRadius:"6px",cursor:"pointer",background:(y.inputParameters?.terminationStatus||"COMPLETED")===W?"var(--color-accent)":C,color:(y.inputParameters?.terminationStatus||"COMPLETED")===W?"#fff":E,border:`1px solid ${T}`,fontWeight:"bold",fontSize:"11px"},children:W},W))}),f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"TERMINATION REASON"}),f.jsx("input",{placeholder:"终止原因...",value:y.inputParameters?.terminationReason||"",onChange:W=>M("terminationReason",W.target.value),disabled:!w,style:{width:"100%",padding:"10px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`}})]})),y.type==="EVENT"&&L("事件发送配置","✉️","var(--color-accent)",f.jsxs(f.Fragment,{children:[f.jsx("label",{style:{display:"block",fontSize:"10px",color:R,marginBottom:"4px"},children:"EVENT SINK (地址/队列名)"}),f.jsx("input",{placeholder:"e.g. sqs:queue_name or conductor",value:y.sink||"",onChange:W=>A("sink",W.target.value),disabled:!w,style:{width:"100%",padding:"10px",borderRadius:"8px",background:C,color:E,border:`1px solid ${T}`}})]})),y.type==="WAIT"&&L("等待状态配置","⏳","var(--color-accent)",f.jsxs("div",{style:{fontSize:"12px",color:R,lineHeight:"1.6"},children:["此任务将使工作流进入 ",f.jsx("b",{children:"IN_PROGRESS"})," 状态,直到外部信号触发更新或达到超时时间。",f.jsx("br",{}),f.jsx("br",{}),"您可以在下方设置超时限制。"]})),(y.type==="DECISION"||y.type==="SWITCH")&&L("决策条件配置","⚖️","var(--color-accent)",f.jsxs(f.Fragment,{children:[$("判断参数名","caseValueParam"),U("JS 表达式","caseExpression")]})),y.type==="DO_WHILE"&&L("循环逻辑配置","🔄","var(--color-accent)",f.jsx(f.Fragment,{children:U("循环结束条件 (JS)","loopCondition")})),f.jsxs("div",{style:{marginTop:"32px",borderTop:`1px solid ${T}`,paddingTop:"24px"},children:[f.jsx("div",{style:{fontSize:"11px",fontWeight:"bold",marginBottom:"16px",opacity:.6,textTransform:"uppercase",letterSpacing:"1px"},children:"通用参数与属性"}),$("任务唯一引用名 (Reference Name)","taskReferenceName"),$("任务描述","description"),U("输入参数 (inputParameters)","inputParameters",!0),f.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px",marginTop:"16px"},children:[$("重试次数","retryCount","number"),$("超时限制 (秒)","timeoutSeconds","number")]})]}),f.jsx("div",{style:{marginTop:"48px",opacity:.6},children:f.jsxs("details",{children:[f.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",marginBottom:"8px"},children:"查看完整 JSON (只读)"}),f.jsx("pre",{style:{background:"rgba(0,0,0,0.2)",padding:"16px",borderRadius:"8px",fontSize:"10px",overflow:"auto",border:`1px solid ${T}`,color:R},children:JSON.stringify(y,null,2)})]})})]}),w&&f.jsxs("div",{style:{padding:"24px",borderTop:`1px solid ${T}`,background:"var(--bg-secondary)",display:"flex",gap:"12px",flexShrink:0},children:[f.jsx("div",{style:{flex:1,fontSize:"11px",color:R,display:"flex",alignItems:"center"},children:"✅ 所有修改已实时同步"}),f.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:"完成退出"})]}),f.jsx(bb,{isOpen:u,onClose:()=>d(!1),onSelect:g,suggestions:h,anchorRect:l})]})},_b=D.memo(xb),xh={id:"1",role:"ai",content:"你好!我是您的流程助手。我可以帮你生成工作流框架、优化逻辑或提供参数配置建议。你想实现什么样的流程?",type:"text"},_h=e=>e.split(/(```[\s\S]*?```)/).map((r,n)=>{if(r.startsWith("```")&&r.endsWith("```")){const a=r.slice(3,-3),i=a.indexOf(`
228
+ `),o=i>=0?a.slice(i+1):a;return f.jsx("pre",{children:f.jsx("code",{children:o})},n)}return f.jsx("span",{children:kb(r)},n)}),kb=e=>{const t=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\n)/g;let n=0,a;for(;(a=r.exec(e))!==null;){a.index>n&&t.push(e.slice(n,a.index));const i=a[0];i.startsWith("**")&&i.endsWith("**")?t.push(f.jsx("strong",{children:i.slice(2,-2)},a.index)):i.startsWith("`")&&i.endsWith("`")?t.push(f.jsx("code",{children:i.slice(1,-1)},a.index)):i===`
229
+ `&&t.push(f.jsx("br",{},a.index)),n=a.index+i.length}return n<e.length&&t.push(e.slice(n)),t},Sb=({aiConfig:e})=>{const{workflowDef:t,applyAIGeneratedWorkflow:r}=V(),[n,a]=D.useState(!1),[i,o]=D.useState(""),[s,c]=D.useState(!1),[u,d]=D.useState([xh]),[l,p]=D.useState(""),[h,m]=D.useState(null),g=D.useRef(null),v=D.useRef(null),x=D.useRef(null),b=()=>{const N=v.current;N&&(N.style.height="auto",N.style.height=Math.min(N.scrollHeight,120)+"px")},_=()=>{const N=v.current;N&&(N.style.height="auto")};D.useEffect(()=>()=>{x.current?.abort()},[]),D.useEffect(()=>{const N=()=>a(!0);return window.addEventListener("open-ai-chat",N),()=>window.removeEventListener("open-ai-chat",N)},[]);const y=()=>{g.current?.scrollIntoView({behavior:"smooth"})};D.useEffect(()=>{n&&y()},[u,n,l]);const S=D.useCallback(N=>{const M=[{role:"system",content:gb}];for(const $ of u)$.role==="user"?M.push({role:"user",content:$.content}):$.role==="ai"&&!$.error&&M.push({role:"assistant",content:$.content});const L=mb(N,t);return M.push({role:"user",content:L}),M},[u,t]),w=async N=>{const M=N||i.trim();if(!M||s)return;x.current?.abort();const L=new AbortController;x.current=L;const $={id:Date.now().toString(),role:"user",content:M,type:"text"};N||(d(U=>[...U,$]),o(""),_()),c(!0),p("");try{const U=e?.apiKey||localStorage.getItem("AI_API_KEY")||"",W=e?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",z=e?.model||localStorage.getItem("AI_MODEL")||"";if(!U){setTimeout(()=>{if(L.signal.aborted)return;const P={id:(Date.now()+1).toString(),role:"ai",content:"由于未检测到 API Key,我为您模拟了一个简单的审批流程:",type:"change_suggestion",payload:{name:"demo_approval",tasks:[{name:"submit_request",taskReferenceName:"submit_1",type:"SIMPLE"},{name:"manager_approve",taskReferenceName:"approve_1",type:"SIMPLE"}]}};d(O=>[...O,P]),c(!1)},1e3);return}const K={apiKey:U};W&&(K.baseUrl=W),z&&(K.model=z);const j=S(M),F=await vb(j,K,P=>{p(O=>O+P)},()=>{},L.signal),G=F.match(/```json\n([\s\S]*?)\n```/),k=G?JSON.parse(G[1]):null,I={id:(Date.now()+1).toString(),role:"ai",content:F,type:k?"change_suggestion":"text",payload:k};d(P=>[...P,I]),p("")}catch(U){if(U.name==="AbortError")p(W=>{if(W){const z={id:(Date.now()+1).toString(),role:"ai",content:W,type:"text"};d(K=>[...K,z])}return""});else{const W={id:Date.now().toString(),role:"ai",content:`抱歉,目前无法连接到 AI 服务: ${U.message}`,error:!0};d(z=>[...z,W]),p("")}}finally{c(!1)}},E=()=>{x.current?.abort()},T=()=>{x.current?.abort(),d([xh]),p(""),c(!1)},C=N=>{navigator.clipboard.writeText(N.content),m(N.id),setTimeout(()=>m(null),1500)},R=()=>{const N=[...u].reverse().find(M=>M.role==="user");N&&(d(M=>M[M.length-1]?.error?M.slice(0,-1):M),w(N.content))},A=N=>{r(N)},B=N=>{N.nativeEvent.isComposing||N.keyCode===229||N.key==="Enter"&&!N.shiftKey&&(N.preventDefault(),w())};return n?f.jsxs("div",{className:"ai-chat-panel",children:[f.jsxs("div",{className:"ai-header",children:[f.jsxs("div",{className:"ai-title",children:[f.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]}),f.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[f.jsx("button",{className:"ai-close",onClick:T,title:"清空对话",children:"🗑"}),f.jsx("button",{className:"ai-close",onClick:()=>a(!1),children:"×"})]})]}),f.jsxs("div",{className:"ai-messages",children:[u.map(N=>f.jsxs("div",{className:`message ${N.role}${N.error?" error":""}`,children:[f.jsx("div",{className:"message-content",children:N.role==="ai"?_h(N.content):N.content}),N.type==="change_suggestion"&&N.payload&&f.jsxs("div",{className:"change-card",children:[f.jsx("div",{className:"card-header",children:"工作流修改建议"}),f.jsxs("div",{className:"card-actions",children:[f.jsx("button",{className:"card-btn",children:"预览"}),f.jsx("button",{className:"card-btn apply",onClick:()=>A(N.payload),children:"应用"})]})]}),N.role==="ai"&&!N.error&&f.jsx("button",{className:"copy-btn",onClick:()=>C(N),title:"复制",children:h===N.id?"✓":"📋"}),N.error&&f.jsx("button",{className:"retry-btn",onClick:R,children:"重试"})]},N.id)),s&&l&&f.jsxs("div",{className:"message ai",style:{opacity:.9},children:[f.jsx("div",{className:"message-content",children:_h(l)}),f.jsx("span",{className:"streaming-cursor",children:"▊"})]}),s&&!l&&f.jsxs("div",{className:"message ai thinking-skeleton",children:[f.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),f.jsx("div",{className:"skeleton-line",style:{width:"60%"}}),f.jsx("div",{className:"skeleton-line",style:{width:"70%"}})]}),f.jsx("div",{ref:g})]}),f.jsx("div",{className:"ai-input-area",children:f.jsxs("div",{className:"ai-input-container",children:[f.jsx("textarea",{ref:v,className:"ai-input",placeholder:s?"AI 正在响应...":"描述您的需求…(Shift+Enter 换行)",value:i,onChange:N=>o(N.target.value),onInput:b,onKeyDown:B,disabled:s,rows:2}),s?f.jsx("button",{className:"ai-send stop",onClick:E,title:"停止生成",children:"⏹"}):f.jsx("button",{className:"ai-send",onClick:()=>w(),title:"发送",children:"🚀"})]})})]}):f.jsx("div",{className:"ai-chat-panel collapsed",onClick:()=>a(!0),children:f.jsx("div",{className:"ai-header",style:{borderBottom:"none"},children:f.jsxs("div",{className:"ai-title",children:[f.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]})})})},kh=D.forwardRef(({workflowDef:e,readOnly:t=!1,theme:r="dark",themeColor:n="blue",layoutDirection:a="LR",searchQuery:i="",workflowExecution:o,onRequestImport:s,executionActions:c,aiConfig:u,onSave:d,onWorkflowChange:l,height:p="100%"},h)=>{const{setWorkflow:m,setTheme:g,setThemeColor:v,setLayoutDirection:x,setNodesLocked:b,selectedTask:_,setSelectedTask:y,edgeType:S,importExecutionJSON:w,setMode:E,isDetailPanelOpen:T,setIsDetailPanelOpen:C,selectTaskAction:R}=V(),[A,B]=D.useState(!1);D.useEffect(()=>{g(r),v(n),x(a),b(t||!!o)},[r,n,a,t,o,g,v,x,b]),D.useEffect(()=>{e&&(m(e,a),V.temporal.getState().clear())},[e,m,a]),D.useEffect(()=>{o?w(o):E(t?"view":"edit")},[o,w,E,t]),D.useImperativeHandle(h,()=>({getWorkflowDef:()=>V.getState().workflowDef,getValidationResults:()=>V.getState().validationResults,save:()=>{const M=V.getState().workflowDef;M&&d&&d(M)},createBlankWorkflow:M=>{V.getState().createBlankWorkflow(M),V.temporal.getState().clear()}}),[d]),D.useEffect(()=>{if(!l)return;let M=!0,L=V.getState().workflowDef;return V.subscribe(U=>{const W=U.workflowDef;if(W!==L){if(L=W,M){M=!1;return}W&&l(W)}})},[l]);const N=M=>{o?y(M):R(M,!0)};return f.jsxs("div",{className:`workflow-ide ${r==="light"?"light-theme":""}`,"data-mode":r,"data-brand":n,style:{width:"100%",height:p,display:"flex",position:"relative",overflow:"hidden"},children:[f.jsxs("div",{className:"workflow-viewer",style:{flex:1,position:"relative"},children:[f.jsx(q.ReactFlowProvider,{children:f.jsx(pb,{onNodeClick:N,edgeType:S,theme:r,nodesLocked:t||!!o,searchQuery:i,onSave:d,onRequestImport:s,executionActions:c})}),f.jsx("div",{style:{position:"absolute",top:10,right:10,zIndex:10,display:"flex",gap:8}})]}),f.jsx(_b,{task:_,isOpen:T,onClose:()=>C(!1),theme:r,aiConfig:u}),f.jsx(lh,{isOpen:A,onClose:()=>B(!1),theme:r,onTaskSelect:M=>{R(M,!0)}}),o&&f.jsx(dh,{}),f.jsx(Sb,{aiConfig:u})]})});kh.displayName="WorkflowIDE",Se.WorkflowIDE=kh,Object.defineProperty(Se,Symbol.toStringTag,{value:"Module"})}));