@yiyi_zhang/reactflow-ui 1.3.0 → 1.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/dist/AiWorkflowIDE.d.ts +23 -3
- package/dist/WorkflowIDE.d.ts +14 -1
- package/dist/actions/builtin/coerce.d.ts +9 -0
- package/dist/actions/types.d.ts +1 -0
- package/dist/ai.d.ts +5 -2
- package/dist/components/AiNative/AgentTimeline.d.ts +1 -1
- package/dist/components/AiNative/ClarificationCard.d.ts +3 -2
- package/dist/components/AiNative/InlineCanvasCopilot.d.ts +2 -1
- package/dist/components/AiNative/RepairCard.d.ts +3 -2
- package/dist/components/AiNative/mermaidParser.d.ts +31 -0
- package/dist/components/AiNative/repairActions.d.ts +16 -0
- package/dist/components/AiNative/runInputs.d.ts +13 -0
- package/dist/components/BrandLogo.d.ts +2 -3
- package/dist/components/ConfirmDialog.d.ts +3 -1
- package/dist/components/DraftCodeField.d.ts +26 -0
- package/dist/components/PromptDialog.d.ts +3 -1
- package/dist/components/UnsavedRunNotice.d.ts +16 -0
- package/dist/components/business/ActionPickerModal.d.ts +2 -0
- package/dist/components/business/BusinessEditorContext.d.ts +38 -0
- package/dist/components/business/DataPillInput.d.ts +10 -0
- package/dist/components/business/DecisionBranchCard.d.ts +2 -1
- package/dist/components/business/ForkJoinCard.d.ts +2 -1
- package/dist/components/business/LibraryVersionBadge.d.ts +1 -1
- package/dist/components/business/LoopDoWhileCard.d.ts +2 -1
- package/dist/components/business/NestedControlStep.d.ts +7 -1
- package/dist/components/business/RunStoryTimeline.d.ts +7 -0
- package/dist/components/business/StepCardParts.d.ts +73 -0
- package/dist/components/business/StepFlowEditor.d.ts +12 -1
- package/dist/components/business/StepListEditor.d.ts +6 -2
- package/dist/components/business/deleteMessage.d.ts +6 -0
- package/dist/components/business/runStatus.d.ts +11 -0
- package/dist/components/icons/CmIcon.d.ts +17 -0
- package/dist/components/icons/iconRegistry.d.ts +80 -0
- package/dist/components/onboarding/OnboardingController.d.ts +7 -0
- package/dist/components/onboarding/PromotionPanel.d.ts +9 -1
- package/dist/components/template/quickRunNotice.d.ts +13 -0
- package/dist/hooks/useConfirm.d.ts +3 -1
- package/dist/hooks/useShortcuts.d.ts +1 -1
- package/dist/import/common.d.ts +7 -1
- package/dist/import/selection.d.ts +17 -0
- package/dist/index.d.ts +5 -2
- package/dist/library/versionStatus.d.ts +2 -2
- package/dist/logo.svg +9 -36
- package/dist/onboarding/naming.d.ts +5 -0
- package/dist/onboarding/poll.d.ts +6 -3
- package/dist/parser/conductorGenerator.d.ts +17 -2
- package/dist/product-launch.html +10 -1394
- package/dist/providers/types.d.ts +2 -0
- package/dist/reactflow-ui-ai.es.js +18497 -14329
- package/dist/reactflow-ui.css +1 -1
- package/dist/reactflow-ui.es.js +21578 -15400
- package/dist/reactflow-ui.umd.js +183 -41
- package/dist/sample-workflows/complex-workflow.json +8 -4
- package/dist/sample-workflows/decision-workflow.json +1 -0
- package/dist/sample-workflows/ecs-lifecycle-automation.json +37 -4
- package/dist/services/ai/agentRunner.d.ts +46 -1
- package/dist/services/ai/errorMessages.d.ts +9 -1
- package/dist/services/ai/protocolAdapter.d.ts +5 -0
- package/dist/services/ai/systemPrompt.d.ts +1 -1
- package/dist/services/ai/toolExecutor.d.ts +26 -0
- package/dist/services/ai/workflowSynthesizer.d.ts +4 -4
- package/dist/services/aiService.d.ts +5 -1
- package/dist/stepmodel/compile.d.ts +2 -1
- package/dist/stepmodel/factory.d.ts +5 -0
- package/dist/stepmodel/pills.d.ts +32 -0
- package/dist/stepmodel/types.d.ts +10 -0
- package/dist/stepmodel/validate.d.ts +20 -0
- package/dist/store/aiStore.d.ts +30 -5
- package/dist/store/sandboxRunObserver.d.ts +2 -1
- package/dist/store/workflowStore.d.ts +8 -9
- package/dist/template/templateStore.d.ts +6 -0
- package/dist/template/types.d.ts +1 -0
- package/dist/types/conductor.d.ts +25 -1
- package/dist/types/workflow.d.ts +38 -3
- package/dist/types/workflowLibrary.d.ts +5 -5
- package/dist/utils/executionAnalyzer.d.ts +5 -0
- package/dist/utils/executionImport.d.ts +52 -0
- package/dist/utils/executionPoller.d.ts +37 -0
- package/dist/utils/hostSave.d.ts +10 -0
- package/dist/utils/localSandboxEngine.d.ts +51 -6
- package/dist/utils/runStory.d.ts +20 -0
- package/dist/utils/sameWorkflow.d.ts +6 -0
- package/dist/utils/sandbox/jq.d.ts +13 -0
- package/dist/utils/sandbox/scriptRunner.d.ts +38 -0
- package/dist/utils/sandbox/switchHints.d.ts +17 -0
- package/dist/utils/statusMeta.d.ts +35 -0
- package/dist/utils/taskEditing.d.ts +59 -0
- package/dist/utils/taskTypeMeta.d.ts +1 -0
- package/dist/utils/validationRules.d.ts +29 -4
- package/package.json +6 -2
package/dist/reactflow-ui.umd.js
CHANGED
|
@@ -1,48 +1,188 @@
|
|
|
1
|
-
(function(G,
|
|
1
|
+
(function(G,T){typeof exports=="object"&&typeof module<"u"?T(exports,require("react"),require("reactflow"),require("react-dom")):typeof define=="function"&&define.amd?define(["exports","react","reactflow","react-dom"],T):(G=typeof globalThis<"u"?globalThis:G||self,T(G.ReactflowUI={},G.React,G.ReactFlow,G.ReactDOM))})(this,(function(G,T,J,bt){"use strict";var Vn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function _0(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Kn={exports:{}},Jr={};var Vp;function j0(){if(Vp)return Jr;Vp=1;var e=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(n,s,a){var i=null;if(a!==void 0&&(i=""+a),s.key!==void 0&&(i=""+s.key),"key"in s){a={};for(var l in s)l!=="key"&&(a[l]=s[l])}else a=s;return s=a.ref,{$$typeof:e,type:n,key:i,ref:s!==void 0?s:null,props:a}}return Jr.Fragment=t,Jr.jsx=r,Jr.jsxs=r,Jr}var Ur={};var Kp;function T0(){return Kp||(Kp=1,process.env.NODE_ENV!=="production"&&(function(){function e(P){if(P==null)return null;if(typeof P=="function")return P.$$typeof===C?null:P.displayName||P.name||null;if(typeof P=="string")return P;switch(P){case x:return"Fragment";case v:return"Profiler";case g:return"StrictMode";case j:return"Suspense";case _:return"SuspenseList";case N:return"Activity"}if(typeof P=="object")switch(typeof P.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),P.$$typeof){case y:return"Portal";case b:return P.displayName||"Context";case k:return(P._context.displayName||"Context")+".Consumer";case S:var D=P.render;return P=P.displayName,P||(P=D.displayName||D.name||"",P=P!==""?"ForwardRef("+P+")":"ForwardRef"),P;case w:return D=P.displayName||null,D!==null?D:e(P.type)||"Memo";case I:D=P._payload,P=P._init;try{return e(P(D))}catch{}}return null}function t(P){return""+P}function r(P){try{t(P);var D=!1}catch{D=!0}if(D){D=console;var Z=D.error,L=typeof Symbol=="function"&&Symbol.toStringTag&&P[Symbol.toStringTag]||P.constructor.name||"Object";return Z.call(D,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",L),t(P)}}function n(P){if(P===x)return"<>";if(typeof P=="object"&&P!==null&&P.$$typeof===I)return"<...>";try{var D=e(P);return D?"<"+D+">":"<...>"}catch{return"<...>"}}function s(){var P=M.A;return P===null?null:P.getOwner()}function a(){return Error("react-stack-top-frame")}function i(P){if(R.call(P,"key")){var D=Object.getOwnPropertyDescriptor(P,"key").get;if(D&&D.isReactWarning)return!1}return P.key!==void 0}function l(P,D){function Z(){B||(B=!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)",D))}Z.isReactWarning=!0,Object.defineProperty(P,"key",{get:Z,configurable:!0})}function c(){var P=e(this.type);return q[P]||(q[P]=!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.")),P=this.props.ref,P!==void 0?P:null}function d(P,D,Z,L,H,U){var K=Z.ref;return P={$$typeof:h,type:P,key:D,props:Z,_owner:L},(K!==void 0?K:null)!==null?Object.defineProperty(P,"ref",{enumerable:!1,get:c}):Object.defineProperty(P,"ref",{enumerable:!1,value:null}),P._store={},Object.defineProperty(P._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(P,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(P,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:H}),Object.defineProperty(P,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:U}),Object.freeze&&(Object.freeze(P.props),Object.freeze(P)),P}function u(P,D,Z,L,H,U){var K=D.children;if(K!==void 0)if(L)if(O(K)){for(L=0;L<K.length;L++)p(K[L]);Object.freeze&&Object.freeze(K)}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 p(K);if(R.call(D,"key")){K=e(P);var se=Object.keys(D).filter(function(we){return we!=="key"});L=0<se.length?"{key: someKey, "+se.join(": ..., ")+": ...}":"{key: someKey}",W[K+L]||(se=0<se.length?"{"+se.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
2
2
|
let props = %s;
|
|
3
3
|
<%s {...props} />
|
|
4
4
|
React keys must be passed directly to JSX without using spread:
|
|
5
5
|
let props = %s;
|
|
6
|
-
<%s key={someKey} {...props} />`,$,V,te,V),M[V+$]=!0)}if(V=null,U!==void 0&&(r(U),V=""+U),i(W)&&(r(W.key),V=""+W.key),"key"in W){U={};for(var ue in W)ue!=="key"&&(U[ue]=W[ue])}else U=W;return V&&l(U,typeof O=="function"?O.displayName||O.name||"Unknown":O),u(O,V,U,s(),H,K)}function p(O){h(O)?O._store&&(O._store.validated=1):typeof O=="object"&&O!==null&&O.$$typeof===w&&(O._payload.status==="fulfilled"?h(O._payload.value)&&O._payload.value._store&&(O._payload.value._store.validated=1):O._store&&(O._store.validated=1))}function h(O){return typeof O=="object"&&O!==null&&O.$$typeof===m}var f=I,m=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),v=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),x=Symbol.for("react.profiler"),b=Symbol.for("react.consumer"),k=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),C=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),N=Symbol.for("react.memo"),w=Symbol.for("react.lazy"),_=Symbol.for("react.activity"),j=Symbol.for("react.client.reference"),P=f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,E=Object.prototype.hasOwnProperty,A=Array.isArray,L=console.createTask?console.createTask:function(){return null};f={react_stack_bottom_frame:function(O){return O()}};var B,z={},R=f.react_stack_bottom_frame.bind(f,a)(),q=L(n(a)),M={};zt.Fragment=v,zt.jsx=function(O,W,U){var $=1e4>P.recentlyCreatedOwnerStacks++;return d(O,W,U,!1,$?Error("react-stack-top-frame"):R,$?L(n(O)):q)},zt.jsxs=function(O,W,U){var $=1e4>P.recentlyCreatedOwnerStacks++;return d(O,W,U,!0,$?Error("react-stack-top-frame"):R,$?L(n(O)):q)}})()),zt}var Qc;function mb(){return Qc||(Qc=1,process.env.NODE_ENV==="production"?hr.exports=fb():hr.exports=hb()),hr.exports}var o=mb();const ed=e=>{let t;const r=new Set,n=(u,d)=>{const p=typeof u=="function"?u(t):u;if(!Object.is(p,t)){const h=t;t=d??(typeof p!="object"||p===null)?p:Object.assign({},t,p),r.forEach(f=>f(t,h))}},s=()=>t,l={setState:n,getState:s,getInitialState:()=>c,subscribe:u=>(r.add(u),()=>r.delete(u))},c=t=e(n,s,l);return l},td=(e=>e?ed(e):ed),gb=e=>e;function pn(e,t=gb){const r=I.useSyncExternalStore(e.subscribe,I.useCallback(()=>t(e.getState()),[e,t]),I.useCallback(()=>t(e.getInitialState()),[e,t]));return I.useDebugValue(r),r}const yb=e=>{const t=td(e),r=n=>pn(t,n);return Object.assign(r,t),r},fn=(e=>yb);function hn(e,t){let r;try{r=e()}catch{return}return{getItem:s=>{var a;const i=c=>c===null?null:JSON.parse(c,void 0),l=(a=r.getItem(s))!=null?a:null;return l instanceof Promise?l.then(i):i(l)},setItem:(s,a)=>r.setItem(s,JSON.stringify(a,void 0)),removeItem:s=>r.removeItem(s)}}const mn=e=>t=>{try{const r=e(t);return r instanceof Promise?r:{then(n){return mn(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return mn(n)(r)}}}},rd=(e,t)=>(r,n,s)=>{let a={storage:hn(()=>localStorage),partialize:y=>y,version:0,merge:(y,v)=>({...v,...y}),...t},i=!1;const l=new Set,c=new Set;let u=a.storage;if(!u)return e((...y)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),r(...y)},n,s);const d=()=>{const y=a.partialize({...n()});return u.setItem(a.name,{state:y,version:a.version})},p=s.setState;s.setState=(y,v)=>(p(y,v),d());const h=e((...y)=>(r(...y),d()),n,s);s.getInitialState=()=>h;let f;const m=()=>{var y,v;if(!u)return;i=!1,l.forEach(x=>{var b;return x((b=n())!=null?b:h)});const g=((v=a.onRehydrateStorage)==null?void 0:v.call(a,(y=n())!=null?y:h))||void 0;return mn(u.getItem.bind(u))(a.name).then(x=>{if(x)if(typeof x.version=="number"&&x.version!==a.version){if(a.migrate){const b=a.migrate(x.state,x.version);return b instanceof Promise?b.then(k=>[!0,k]):[!0,b]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,x.state];return[!1,void 0]}).then(x=>{var b;const[k,S]=x;if(f=a.merge(S,(b=n())!=null?b:h),r(f,!0),k)return d()}).then(()=>{g?.(f,void 0),f=n(),i=!0,c.forEach(x=>x(f))}).catch(x=>{g?.(void 0,x)})};return s.persist={setOptions:y=>{a={...a,...y},y.storage&&(u=y.storage)},clearStorage:()=>{u?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>m(),hasHydrated:()=>i,onHydrate:y=>(l.add(y),()=>{l.delete(y)}),onFinishHydration:y=>(c.add(y),()=>{c.delete(y)})},a.skipHydration||m(),f||h};var nd=(e,t,r)=>(s,a)=>({pastStates:r?.pastStates||[],futureStates:r?.futureStates||[],undo:(i=1)=>{if(a().pastStates.length){const l=r?.partialize?.(t())||t(),c=a().pastStates.splice(-i,i),u=c.shift();e(u),s({pastStates:a().pastStates,futureStates:a().futureStates.concat(r?.diff?.(l,u)||l,c.reverse())})}},redo:(i=1)=>{if(a().futureStates.length){const l=r?.partialize?.(t())||t(),c=a().futureStates.splice(-i,i),u=c.shift();e(u),s({pastStates:a().pastStates.concat(r?.diff?.(l,u)||l,c.reverse()),futureStates:a().futureStates})}},clear:()=>s({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>s({isTracking:!1}),resume:()=>s({isTracking:!0}),setOnSave:i=>s({_onSave:i}),_onSave:r?.onSave,_handleSet:(i,l,c,u)=>{r?.limit&&a().pastStates.length>=r?.limit&&a().pastStates.shift(),a()._onSave?.(i,c),s({pastStates:a().pastStates.concat(u||i),futureStates:[]})}}),xb=(e,t)=>(n,s,a)=>{a.temporal=td(t?.wrapTemporal?.(nd(n,s,t))||nd(n,s,t));const i=t?.handleSet?.(a.temporal.getState()._handleSet)||a.temporal.getState()._handleSet,l=u=>{if(!a.temporal.getState().isTracking)return;const d=t?.partialize?.(s())||s(),p=t?.diff?.(u,d);p===null||t?.equality?.(u,d)||i(u,void 0,d,p)},c=a.setState;return a.setState=(...u)=>{const d=t?.partialize?.(s())||s();c(...u),l(d)},e((...u)=>{const d=t?.partialize?.(s())||s();n(...u),l(d)},s,a)};function bb(e,t="TB",r){const n=r?.hideEmptyBranches??!1;if(!e||!e.tasks)return{nodes:[],edges:[],taskMap:{}};const s=[],a=[],i={};let l=0;const c=e.tasks;for(let u=0;u<c.length;u++){const d=c[u],p=od(d,l,i,t,c,n);if(s.push(...p.nodes),a.push(...p.edges),l=p.nextId,u>0){const h=c[u-1];gn(h,d,a,n)}Object.assign(i,p.taskMap)}if(!n&&c.length>0){const u=c[0],d="__workflow_start__";s.push({id:d,type:"plusNode",data:{label:"+",taskReferenceName:d,taskType:"PLUS",parentRef:d,edgeData:{isWorkflowStart:!0},layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?F.Position.Right:F.Position.Bottom,targetPosition:t==="LR"?F.Position.Left:F.Position.Top}),a.push({id:`e-${d}-${u.taskReferenceName}`,source:d,target:u.taskReferenceName,animated:!0});const p=c[c.length-1],h="__workflow_end__";s.push({id:h,type:"plusNode",data:{label:"+",taskReferenceName:h,taskType:"PLUS",parentRef:p.taskReferenceName,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?F.Position.Right:F.Position.Bottom,targetPosition:t==="LR"?F.Position.Left:F.Position.Top}),gn(p,{taskReferenceName:h},a,n)}return{nodes:s,edges:a,taskMap:i}}function od(e,t,r,n="TB",s=[],a=!1){switch(e.type||"SIMPLE"){case"DECISION":case"SWITCH":return kb(e,t,r,n,a);case"FORK_JOIN":case"FORK_JOIN_DYNAMIC":return Sb(e,t,r,n);case"JOIN":case"EXCLUSIVE_JOIN":return jb(e,t,r,n,s,a);case"DO_WHILE":return wb(e,t,r,n,a);case"SUB_WORKFLOW":return _b(e,t,r,n);default:return vb(e,t,r,n)}}function vb(e,t,r,n="TB"){const s={id:e.taskReferenceName,type:"taskNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type||"SIMPLE",task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?F.Position.Right:F.Position.Bottom,targetPosition:n==="LR"?F.Position.Left:F.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:t+1}}function kb(e,t,r,n="TB",s=!1){const a=[],i=[];let l=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"?F.Position.Right:F.Position.Bottom,targetPosition:n==="LR"?F.Position.Left:F.Position.Top};a.push(u),c[e.taskReferenceName]=e;const d=e.decisionCases||{},p=e.defaultCase||[],h=Object.keys(d),f=(m,y)=>{if(n==="TB"){if(m===0&&y>1)return"left";if(m===1&&y>2)return"right"}else{if(m===0&&y>1)return"top";if(m===1&&y>2)return"bottom"}return null};if(h.forEach((m,y)=>{const v=d[m],g=f(y,h.length+1);if(v&&v.length>0){const x=mr(v,l,{...r,...c},n,s);a.push(...x.nodes),i.push(...x.edges),Object.assign(c,x.taskMap),l=x.nextId;const b=v[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${b}`,source:e.taskReferenceName,sourceHandle:g||void 0,target:b,label:m,animated:!0,data:{branchCase:m},style:{stroke:"#3b82f6"}})}else if(!s){const x=`${e.taskReferenceName}_empty_${m}`;a.push({id:x,type:"plusNode",data:{label:`${m} (空)`,parentRef:e.taskReferenceName,edgeData:{branchCase:m},layoutDirection:n,taskReferenceName:x,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?F.Position.Right:F.Position.Bottom,targetPosition:n==="LR"?F.Position.Left:F.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"}}),i.push({id:`e-${e.taskReferenceName}-${x}`,source:e.taskReferenceName,sourceHandle:g||void 0,target:x,label:m,animated:!0,data:{branchCase:m},style:{stroke:"#3b82f6",strokeDasharray:"5,5"}})}}),p&&p.length>0){const m=mr(p,l,{...r,...c},n,s);a.push(...m.nodes),i.push(...m.edges),Object.assign(c,m.taskMap),l=m.nextId;const y=p[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${y}`,source:e.taskReferenceName,target:y,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b"}})}else if(!s){const m=`${e.taskReferenceName}_empty_default`;a.push({id:m,type:"plusNode",data:{label:"default (空)",parentRef:e.taskReferenceName,edgeData:{branchCase:"default"},layoutDirection:n,taskReferenceName:m,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?F.Position.Right:F.Position.Bottom,targetPosition:n==="LR"?F.Position.Left:F.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"}}),i.push({id:`e-${e.taskReferenceName}-${m}`,source:e.taskReferenceName,target:m,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"#f59e0b",strokeDasharray:"5,5"}})}return{nodes:a,edges:i,taskMap:c,nextId:l}}function Sb(e,t,r,n="TB"){const s=[],a=[];let i=t;const l={},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"?F.Position.Right:F.Position.Bottom,targetPosition:n==="LR"?F.Position.Left:F.Position.Top};if(s.push(u),l[e.taskReferenceName]=e,c){const d=`${e.taskReferenceName}_dynamic_placeholder`;s.push({id:d,type:"dynamicPlaceholderNode",data:{label:"动态分支",taskReferenceName:d,taskType:"DYNAMIC_PLACEHOLDER",layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?F.Position.Right:F.Position.Bottom,targetPosition:n==="LR"?F.Position.Left:F.Position.Top}),a.push({id:`e-${e.taskReferenceName}-${d}`,source:e.taskReferenceName,target:d,animated:!0,style:{stroke:"#10b981",strokeDasharray:"5,5",strokeWidth:2}}),l[d]={taskReferenceName:d,type:"DYNAMIC_PLACEHOLDER"}}return c||(e.forkTasks||[]).forEach((p,h)=>{if(p&&p.length>0){const f=mr(p,i,{...r,...l},n,!1);s.push(...f.nodes),a.push(...f.edges),Object.assign(l,f.taskMap),i=f.nextId;const m=p[0].taskReferenceName;a.push({id:`e-${e.taskReferenceName}-${m}`,source:e.taskReferenceName,sourceHandle:`branch_${h}`,target:m,label:`分支 ${h+1}`,animated:!0,data:{forkIndex:h},style:{stroke:"#10b981"}})}}),{nodes:s,edges:a,taskMap:l,nextId:i}}function wb(e,t,r,n="TB",s=!1){const a={},i=e.taskReferenceName,l={id:i,type:"loopNode",data:{label:e.name,taskReferenceName:i,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?F.Position.Right:F.Position.Bottom,targetPosition:n==="LR"?F.Position.Left:F.Position.Top,style:{pointerEvents:"none"}};a[i]=e;const c=e.loopOver||[],u=[],d=[];let p=t+1;if(c.length>0){const h=mr(c,p,{...r,...a},n,s);if(p=h.nextId,Object.assign(a,h.taskMap),h.nodes.forEach(f=>{u.push({...f,parentId:f.parentId??i,extent:f.parentId?f.extent:"parent"})}),d.push(...h.edges),!s){const f=c[0],m=`__loop_start__${i}`;u.push({id:m,type:"plusNode",parentId:i,extent:"parent",data:{label:"+",taskReferenceName:m,taskType:"PLUS",parentRef:i,edgeData:{isLoopBodyStart:!0,loopId:i},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?F.Position.Right:F.Position.Bottom,targetPosition:n==="LR"?F.Position.Left:F.Position.Top}),d.push({id:`e-${m}-${f.taskReferenceName}`,source:m,target:f.taskReferenceName,animated:!0})}if(!s){const f=c[c.length-1],m=`__loop_end__${i}`;u.push({id:m,type:"plusNode",parentId:i,extent:"parent",data:{label:"+",taskReferenceName:m,taskType:"PLUS",parentRef:f.taskReferenceName,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?F.Position.Right:F.Position.Bottom,targetPosition:n==="LR"?F.Position.Left:F.Position.Top}),d.push({id:`e-${f.taskReferenceName}-${m}`,source:f.taskReferenceName,target:m,animated:!0})}}else if(!s){const h=`${i}_loop_empty_plus`;u.push({id:h,type:"plusNode",parentId:i,extent:"parent",data:{label:"+ 添加",taskReferenceName:h,taskType:"PLUS",parentRef:i,edgeData:{isLoopAdd:!0},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?F.Position.Right:F.Position.Bottom,targetPosition:n==="LR"?F.Position.Left:F.Position.Top})}return{nodes:[l,...u],edges:d,taskMap:a,nextId:p}}function _b(e,t,r,n="TB"){const s={id:e.taskReferenceName,type:"subWorkflowNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?F.Position.Right:F.Position.Bottom,targetPosition:n==="LR"?F.Position.Left:F.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:t+1}}function jb(e,t,r,n="TB",s=[],a=!1){const i={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"?F.Position.Right:F.Position.Bottom,targetPosition:n==="LR"?F.Position.Left:F.Position.Top},l={[e.taskReferenceName]:e},c=[],u=[];(e.joinOn||[]).forEach(h=>{const f=s.find(m=>m.taskReferenceName===h)||r[h];f&&gr(f,a).forEach(y=>{u.push({id:`e-${y}-${e.taskReferenceName}`,source:y,target:e.taskReferenceName,animated:!0})})});const p=s.findIndex(h=>h.taskReferenceName===e.taskReferenceName);if(p>0){const h=s[p-1];if(h.type==="FORK_JOIN_DYNAMIC"){const f=`${h.taskReferenceName}_dynamic_placeholder`;u.push({id:`e-${f}-${e.taskReferenceName}-dynamic`,source:f,target:e.taskReferenceName,animated:!0,style:{stroke:"#10b981",strokeWidth:2,strokeDasharray:"5,5",opacity:.8}})}else h.type==="FORK_JOIN"&&(h.forkTasks||[]).forEach((m,y)=>{if((!m||m.length===0)&&!a){const v=`${h.taskReferenceName}_empty_branch_${y}`;c.push({id:v,type:"default",data:{label:`分支 ${y+1} (空)`,layoutDirection:n,taskReferenceName:v,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?F.Position.Right:F.Position.Bottom,targetPosition:n==="LR"?F.Position.Left:F.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-${h.taskReferenceName}-${v}`,source:h.taskReferenceName,sourceHandle:`branch_${y}`,target:v,label:`分支 ${y+1}`,animated:!0,data:{forkIndex:y},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:[i,...c],edges:u,taskMap:l,nextId:t+1}}function mr(e,t,r,n="TB",s=!1){const a=[],i=[];let l=t;const c={};for(let u=0;u<e.length;u++){const d=e[u],p={...r,...c},h=od(d,l,p,n,e,s);if(a.push(...h.nodes),i.push(...h.edges),Object.assign(c,h.taskMap),l=h.nextId,u>0){const f=e[u-1];gn(f,d,i,s)}}return{nodes:a,edges:i,taskMap:c,nextId:l}}function gn(e,t,r,n=!1){if(e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC")return;const s=gr(e,n),a=t.taskReferenceName;s.forEach(i=>{const l=`e-${i}-${a}`;r.find(c=>c.id===l)||r.push({id:l,source:i,target:a,animated:!0})})}function gr(e,t=!1){const r=e.type||"SIMPLE";if(r==="DECISION"||r==="SWITCH"){const n=[],s=e.decisionCases||{},a=e.defaultCase||[];if(Object.entries(s).forEach(([i,l])=>{if(l&&l.length>0){const c=l[l.length-1];n.push(...gr(c,t))}else t||n.push(`${e.taskReferenceName}_empty_${i}`)}),a.length>0){const i=a[a.length-1];n.push(...gr(i,t))}else t||n.push(`${e.taskReferenceName}_empty_default`);return n.length>0?n:[e.taskReferenceName]}return[e.taskReferenceName]}const Me=bb;function yn(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 xn,ad;function Tb(){if(ad)return xn;ad=1;function e(){this.__data__=[],this.size=0}return xn=e,xn}var bn,sd;function _t(){if(sd)return bn;sd=1;function e(t,r){return t===r||t!==t&&r!==r}return bn=e,bn}var vn,id;function yr(){if(id)return vn;id=1;var e=_t();function t(r,n){for(var s=r.length;s--;)if(e(r[s][0],n))return s;return-1}return vn=t,vn}var kn,ld;function Ib(){if(ld)return kn;ld=1;var e=yr(),t=Array.prototype,r=t.splice;function n(s){var a=this.__data__,i=e(a,s);if(i<0)return!1;var l=a.length-1;return i==l?a.pop():r.call(a,i,1),--this.size,!0}return kn=n,kn}var Sn,cd;function Cb(){if(cd)return Sn;cd=1;var e=yr();function t(r){var n=this.__data__,s=e(n,r);return s<0?void 0:n[s][1]}return Sn=t,Sn}var wn,dd;function Nb(){if(dd)return wn;dd=1;var e=yr();function t(r){return e(this.__data__,r)>-1}return wn=t,wn}var _n,ud;function Eb(){if(ud)return _n;ud=1;var e=yr();function t(r,n){var s=this.__data__,a=e(s,r);return a<0?(++this.size,s.push([r,n])):s[a][1]=n,this}return _n=t,_n}var jn,pd;function xr(){if(pd)return jn;pd=1;var e=Tb(),t=Ib(),r=Cb(),n=Nb(),s=Eb();function a(i){var l=-1,c=i==null?0:i.length;for(this.clear();++l<c;){var u=i[l];this.set(u[0],u[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=s,jn=a,jn}var Tn,fd;function Rb(){if(fd)return Tn;fd=1;var e=xr();function t(){this.__data__=new e,this.size=0}return Tn=t,Tn}var In,hd;function Pb(){if(hd)return In;hd=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return In=e,In}var Cn,md;function Ob(){if(md)return Cn;md=1;function e(t){return this.__data__.get(t)}return Cn=e,Cn}var Nn,gd;function Ab(){if(gd)return Nn;gd=1;function e(t){return this.__data__.has(t)}return Nn=e,Nn}var En,yd;function xd(){if(yd)return En;yd=1;var e=typeof fr=="object"&&fr&&fr.Object===Object&&fr;return En=e,En}var Rn,bd;function Ye(){if(bd)return Rn;bd=1;var e=xd(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return Rn=r,Rn}var Pn,vd;function jt(){if(vd)return Pn;vd=1;var e=Ye(),t=e.Symbol;return Pn=t,Pn}var On,kd;function Db(){if(kd)return On;kd=1;var e=jt(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,s=e?e.toStringTag:void 0;function a(i){var l=r.call(i,s),c=i[s];try{i[s]=void 0;var u=!0}catch{}var d=n.call(i);return u&&(l?i[s]=c:delete i[s]),d}return On=a,On}var An,Sd;function Lb(){if(Sd)return An;Sd=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return An=r,An}var Dn,wd;function ft(){if(wd)return Dn;wd=1;var e=jt(),t=Db(),r=Lb(),n="[object Null]",s="[object Undefined]",a=e?e.toStringTag:void 0;function i(l){return l==null?l===void 0?s:n:a&&a in Object(l)?t(l):r(l)}return Dn=i,Dn}var Ln,_d;function Je(){if(_d)return Ln;_d=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return Ln=e,Ln}var Mn,jd;function qt(){if(jd)return Mn;jd=1;var e=ft(),t=Je(),r="[object AsyncFunction]",n="[object Function]",s="[object GeneratorFunction]",a="[object Proxy]";function i(l){if(!t(l))return!1;var c=e(l);return c==n||c==s||c==r||c==a}return Mn=i,Mn}var $n,Td;function Mb(){if(Td)return $n;Td=1;var e=Ye(),t=e["__core-js_shared__"];return $n=t,$n}var zn,Id;function $b(){if(Id)return zn;Id=1;var e=Mb(),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 zn=r,zn}var qn,Cd;function Nd(){if(Cd)return qn;Cd=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 qn=r,qn}var Wn,Ed;function zb(){if(Ed)return Wn;Ed=1;var e=qt(),t=$b(),r=Je(),n=Nd(),s=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,i=Function.prototype,l=Object.prototype,c=i.toString,u=l.hasOwnProperty,d=RegExp("^"+c.call(u).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(h){if(!r(h)||t(h))return!1;var f=e(h)?d:a;return f.test(n(h))}return Wn=p,Wn}var Fn,Rd;function qb(){if(Rd)return Fn;Rd=1;function e(t,r){return t?.[r]}return Fn=e,Fn}var Bn,Pd;function ht(){if(Pd)return Bn;Pd=1;var e=zb(),t=qb();function r(n,s){var a=t(n,s);return e(a)?a:void 0}return Bn=r,Bn}var Hn,Od;function Un(){if(Od)return Hn;Od=1;var e=ht(),t=Ye(),r=e(t,"Map");return Hn=r,Hn}var Jn,Ad;function br(){if(Ad)return Jn;Ad=1;var e=ht(),t=e(Object,"create");return Jn=t,Jn}var Vn,Dd;function Wb(){if(Dd)return Vn;Dd=1;var e=br();function t(){this.__data__=e?e(null):{},this.size=0}return Vn=t,Vn}var Kn,Ld;function Fb(){if(Ld)return Kn;Ld=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return Kn=e,Kn}var Gn,Md;function Bb(){if(Md)return Gn;Md=1;var e=br(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function s(a){var i=this.__data__;if(e){var l=i[a];return l===t?void 0:l}return n.call(i,a)?i[a]:void 0}return Gn=s,Gn}var Yn,$d;function Hb(){if($d)return Yn;$d=1;var e=br(),t=Object.prototype,r=t.hasOwnProperty;function n(s){var a=this.__data__;return e?a[s]!==void 0:r.call(a,s)}return Yn=n,Yn}var Xn,zd;function Ub(){if(zd)return Xn;zd=1;var e=br(),t="__lodash_hash_undefined__";function r(n,s){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=e&&s===void 0?t:s,this}return Xn=r,Xn}var Zn,qd;function Jb(){if(qd)return Zn;qd=1;var e=Wb(),t=Fb(),r=Bb(),n=Hb(),s=Ub();function a(i){var l=-1,c=i==null?0:i.length;for(this.clear();++l<c;){var u=i[l];this.set(u[0],u[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=s,Zn=a,Zn}var Qn,Wd;function Vb(){if(Wd)return Qn;Wd=1;var e=Jb(),t=xr(),r=Un();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return Qn=n,Qn}var eo,Fd;function Kb(){if(Fd)return eo;Fd=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return eo=e,eo}var to,Bd;function vr(){if(Bd)return to;Bd=1;var e=Kb();function t(r,n){var s=r.__data__;return e(n)?s[typeof n=="string"?"string":"hash"]:s.map}return to=t,to}var ro,Hd;function Gb(){if(Hd)return ro;Hd=1;var e=vr();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return ro=t,ro}var no,Ud;function Yb(){if(Ud)return no;Ud=1;var e=vr();function t(r){return e(this,r).get(r)}return no=t,no}var oo,Jd;function Xb(){if(Jd)return oo;Jd=1;var e=vr();function t(r){return e(this,r).has(r)}return oo=t,oo}var ao,Vd;function Zb(){if(Vd)return ao;Vd=1;var e=vr();function t(r,n){var s=e(this,r),a=s.size;return s.set(r,n),this.size+=s.size==a?0:1,this}return ao=t,ao}var so,Kd;function io(){if(Kd)return so;Kd=1;var e=Vb(),t=Gb(),r=Yb(),n=Xb(),s=Zb();function a(i){var l=-1,c=i==null?0:i.length;for(this.clear();++l<c;){var u=i[l];this.set(u[0],u[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=s,so=a,so}var lo,Gd;function Qb(){if(Gd)return lo;Gd=1;var e=xr(),t=Un(),r=io(),n=200;function s(a,i){var l=this.__data__;if(l instanceof e){var c=l.__data__;if(!t||c.length<n-1)return c.push([a,i]),this.size=++l.size,this;l=this.__data__=new r(c)}return l.set(a,i),this.size=l.size,this}return lo=s,lo}var co,Yd;function kr(){if(Yd)return co;Yd=1;var e=xr(),t=Rb(),r=Pb(),n=Ob(),s=Ab(),a=Qb();function i(l){var c=this.__data__=new e(l);this.size=c.size}return i.prototype.clear=t,i.prototype.delete=r,i.prototype.get=n,i.prototype.has=s,i.prototype.set=a,co=i,co}var uo,Xd;function po(){if(Xd)return uo;Xd=1;function e(t,r){for(var n=-1,s=t==null?0:t.length;++n<s&&r(t[n],n,t)!==!1;);return t}return uo=e,uo}var fo,Zd;function Qd(){if(Zd)return fo;Zd=1;var e=ht(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return fo=t,fo}var ho,eu;function Sr(){if(eu)return ho;eu=1;var e=Qd();function t(r,n,s){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:s,writable:!0}):r[n]=s}return ho=t,ho}var mo,tu;function wr(){if(tu)return mo;tu=1;var e=Sr(),t=_t(),r=Object.prototype,n=r.hasOwnProperty;function s(a,i,l){var c=a[i];(!(n.call(a,i)&&t(c,l))||l===void 0&&!(i in a))&&e(a,i,l)}return mo=s,mo}var go,ru;function Wt(){if(ru)return go;ru=1;var e=wr(),t=Sr();function r(n,s,a,i){var l=!a;a||(a={});for(var c=-1,u=s.length;++c<u;){var d=s[c],p=i?i(a[d],n[d],d,a,n):void 0;p===void 0&&(p=n[d]),l?t(a,d,p):e(a,d,p)}return a}return go=r,go}var yo,nu;function ev(){if(nu)return yo;nu=1;function e(t,r){for(var n=-1,s=Array(t);++n<t;)s[n]=r(n);return s}return yo=e,yo}var xo,ou;function tt(){if(ou)return xo;ou=1;function e(t){return t!=null&&typeof t=="object"}return xo=e,xo}var bo,au;function tv(){if(au)return bo;au=1;var e=ft(),t=tt(),r="[object Arguments]";function n(s){return t(s)&&e(s)==r}return bo=n,bo}var vo,su;function Ft(){if(su)return vo;su=1;var e=tv(),t=tt(),r=Object.prototype,n=r.hasOwnProperty,s=r.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(i){return t(i)&&n.call(i,"callee")&&!s.call(i,"callee")};return vo=a,vo}var ko,iu;function Pe(){if(iu)return ko;iu=1;var e=Array.isArray;return ko=e,ko}var Bt={exports:{}},So,lu;function rv(){if(lu)return So;lu=1;function e(){return!1}return So=e,So}Bt.exports;var cu;function Tt(){return cu||(cu=1,(function(e,t){var r=Ye(),n=rv(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===s,l=i?r.Buffer:void 0,c=l?l.isBuffer:void 0,u=c||n;e.exports=u})(Bt,Bt.exports)),Bt.exports}var wo,du;function _r(){if(du)return wo;du=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,s){var a=typeof n;return s=s??e,!!s&&(a=="number"||a!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<s}return wo=r,wo}var _o,uu;function jo(){if(uu)return _o;uu=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return _o=t,_o}var To,pu;function nv(){if(pu)return To;pu=1;var e=ft(),t=jo(),r=tt(),n="[object Arguments]",s="[object Array]",a="[object Boolean]",i="[object Date]",l="[object Error]",c="[object Function]",u="[object Map]",d="[object Number]",p="[object Object]",h="[object RegExp]",f="[object Set]",m="[object String]",y="[object WeakMap]",v="[object ArrayBuffer]",g="[object DataView]",x="[object Float32Array]",b="[object Float64Array]",k="[object Int8Array]",S="[object Int16Array]",C="[object Int32Array]",T="[object Uint8Array]",N="[object Uint8ClampedArray]",w="[object Uint16Array]",_="[object Uint32Array]",j={};j[x]=j[b]=j[k]=j[S]=j[C]=j[T]=j[N]=j[w]=j[_]=!0,j[n]=j[s]=j[v]=j[a]=j[g]=j[i]=j[l]=j[c]=j[u]=j[d]=j[p]=j[h]=j[f]=j[m]=j[y]=!1;function P(E){return r(E)&&t(E.length)&&!!j[e(E)]}return To=P,To}var Io,fu;function jr(){if(fu)return Io;fu=1;function e(t){return function(r){return t(r)}}return Io=e,Io}var Ht={exports:{}};Ht.exports;var hu;function Co(){return hu||(hu=1,(function(e,t){var r=xd(),n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,i=a&&r.process,l=(function(){try{var c=s&&s.require&&s.require("util").types;return c||i&&i.binding&&i.binding("util")}catch{}})();e.exports=l})(Ht,Ht.exports)),Ht.exports}var No,mu;function Ut(){if(mu)return No;mu=1;var e=nv(),t=jr(),r=Co(),n=r&&r.isTypedArray,s=n?t(n):e;return No=s,No}var Eo,gu;function yu(){if(gu)return Eo;gu=1;var e=ev(),t=Ft(),r=Pe(),n=Tt(),s=_r(),a=Ut(),i=Object.prototype,l=i.hasOwnProperty;function c(u,d){var p=r(u),h=!p&&t(u),f=!p&&!h&&n(u),m=!p&&!h&&!f&&a(u),y=p||h||f||m,v=y?e(u.length,String):[],g=v.length;for(var x in u)(d||l.call(u,x))&&!(y&&(x=="length"||f&&(x=="offset"||x=="parent")||m&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||s(x,g)))&&v.push(x);return v}return Eo=c,Eo}var Ro,xu;function Tr(){if(xu)return Ro;xu=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,s=typeof n=="function"&&n.prototype||e;return r===s}return Ro=t,Ro}var Po,bu;function vu(){if(bu)return Po;bu=1;function e(t,r){return function(n){return t(r(n))}}return Po=e,Po}var Oo,ku;function ov(){if(ku)return Oo;ku=1;var e=vu(),t=e(Object.keys,Object);return Oo=t,Oo}var Ao,Su;function Do(){if(Su)return Ao;Su=1;var e=Tr(),t=ov(),r=Object.prototype,n=r.hasOwnProperty;function s(a){if(!e(a))return t(a);var i=[];for(var l in Object(a))n.call(a,l)&&l!="constructor"&&i.push(l);return i}return Ao=s,Ao}var Lo,wu;function ot(){if(wu)return Lo;wu=1;var e=qt(),t=jo();function r(n){return n!=null&&t(n.length)&&!e(n)}return Lo=r,Lo}var Mo,_u;function lt(){if(_u)return Mo;_u=1;var e=yu(),t=Do(),r=ot();function n(s){return r(s)?e(s):t(s)}return Mo=n,Mo}var $o,ju;function av(){if(ju)return $o;ju=1;var e=Wt(),t=lt();function r(n,s){return n&&e(s,t(s),n)}return $o=r,$o}var zo,Tu;function sv(){if(Tu)return zo;Tu=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return zo=e,zo}var qo,Iu;function iv(){if(Iu)return qo;Iu=1;var e=Je(),t=Tr(),r=sv(),n=Object.prototype,s=n.hasOwnProperty;function a(i){if(!e(i))return r(i);var l=t(i),c=[];for(var u in i)u=="constructor"&&(l||!s.call(i,u))||c.push(u);return c}return qo=a,qo}var Wo,Cu;function mt(){if(Cu)return Wo;Cu=1;var e=yu(),t=iv(),r=ot();function n(s){return r(s)?e(s,!0):t(s)}return Wo=n,Wo}var Fo,Nu;function lv(){if(Nu)return Fo;Nu=1;var e=Wt(),t=mt();function r(n,s){return n&&e(s,t(s),n)}return Fo=r,Fo}var Jt={exports:{}};Jt.exports;var Eu;function Ru(){return Eu||(Eu=1,(function(e,t){var r=Ye(),n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,i=a?r.Buffer:void 0,l=i?i.allocUnsafe:void 0;function c(u,d){if(d)return u.slice();var p=u.length,h=l?l(p):new u.constructor(p);return u.copy(h),h}e.exports=c})(Jt,Jt.exports)),Jt.exports}var Bo,Pu;function Ou(){if(Pu)return Bo;Pu=1;function e(t,r){var n=-1,s=t.length;for(r||(r=Array(s));++n<s;)r[n]=t[n];return r}return Bo=e,Bo}var Ho,Au;function Du(){if(Au)return Ho;Au=1;function e(t,r){for(var n=-1,s=t==null?0:t.length,a=0,i=[];++n<s;){var l=t[n];r(l,n,t)&&(i[a++]=l)}return i}return Ho=e,Ho}var Uo,Lu;function Mu(){if(Lu)return Uo;Lu=1;function e(){return[]}return Uo=e,Uo}var Jo,$u;function Vo(){if($u)return Jo;$u=1;var e=Du(),t=Mu(),r=Object.prototype,n=r.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(i){return i==null?[]:(i=Object(i),e(s(i),function(l){return n.call(i,l)}))}:t;return Jo=a,Jo}var Ko,zu;function cv(){if(zu)return Ko;zu=1;var e=Wt(),t=Vo();function r(n,s){return e(n,t(n),s)}return Ko=r,Ko}var Go,qu;function Yo(){if(qu)return Go;qu=1;function e(t,r){for(var n=-1,s=r.length,a=t.length;++n<s;)t[a+n]=r[n];return t}return Go=e,Go}var Xo,Wu;function Ir(){if(Wu)return Xo;Wu=1;var e=vu(),t=e(Object.getPrototypeOf,Object);return Xo=t,Xo}var Zo,Fu;function Bu(){if(Fu)return Zo;Fu=1;var e=Yo(),t=Ir(),r=Vo(),n=Mu(),s=Object.getOwnPropertySymbols,a=s?function(i){for(var l=[];i;)e(l,r(i)),i=t(i);return l}:n;return Zo=a,Zo}var Qo,Hu;function dv(){if(Hu)return Qo;Hu=1;var e=Wt(),t=Bu();function r(n,s){return e(n,t(n),s)}return Qo=r,Qo}var ea,Uu;function Ju(){if(Uu)return ea;Uu=1;var e=Yo(),t=Pe();function r(n,s,a){var i=s(n);return t(n)?i:e(i,a(n))}return ea=r,ea}var ta,Vu;function Ku(){if(Vu)return ta;Vu=1;var e=Ju(),t=Vo(),r=lt();function n(s){return e(s,r,t)}return ta=n,ta}var ra,Gu;function uv(){if(Gu)return ra;Gu=1;var e=Ju(),t=Bu(),r=mt();function n(s){return e(s,r,t)}return ra=n,ra}var na,Yu;function pv(){if(Yu)return na;Yu=1;var e=ht(),t=Ye(),r=e(t,"DataView");return na=r,na}var oa,Xu;function fv(){if(Xu)return oa;Xu=1;var e=ht(),t=Ye(),r=e(t,"Promise");return oa=r,oa}var aa,Zu;function Qu(){if(Zu)return aa;Zu=1;var e=ht(),t=Ye(),r=e(t,"Set");return aa=r,aa}var sa,ep;function hv(){if(ep)return sa;ep=1;var e=ht(),t=Ye(),r=e(t,"WeakMap");return sa=r,sa}var ia,tp;function It(){if(tp)return ia;tp=1;var e=pv(),t=Un(),r=fv(),n=Qu(),s=hv(),a=ft(),i=Nd(),l="[object Map]",c="[object Object]",u="[object Promise]",d="[object Set]",p="[object WeakMap]",h="[object DataView]",f=i(e),m=i(t),y=i(r),v=i(n),g=i(s),x=a;return(e&&x(new e(new ArrayBuffer(1)))!=h||t&&x(new t)!=l||r&&x(r.resolve())!=u||n&&x(new n)!=d||s&&x(new s)!=p)&&(x=function(b){var k=a(b),S=k==c?b.constructor:void 0,C=S?i(S):"";if(C)switch(C){case f:return h;case m:return l;case y:return u;case v:return d;case g:return p}return k}),ia=x,ia}var la,rp;function mv(){if(rp)return la;rp=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var s=n.length,a=new n.constructor(s);return s&&typeof n[0]=="string"&&t.call(n,"index")&&(a.index=n.index,a.input=n.input),a}return la=r,la}var ca,np;function op(){if(np)return ca;np=1;var e=Ye(),t=e.Uint8Array;return ca=t,ca}var da,ap;function ua(){if(ap)return da;ap=1;var e=op();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return da=t,da}var pa,sp;function gv(){if(sp)return pa;sp=1;var e=ua();function t(r,n){var s=n?e(r.buffer):r.buffer;return new r.constructor(s,r.byteOffset,r.byteLength)}return pa=t,pa}var fa,ip;function yv(){if(ip)return fa;ip=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return fa=t,fa}var ha,lp;function xv(){if(lp)return ha;lp=1;var e=jt(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(s){return r?Object(r.call(s)):{}}return ha=n,ha}var ma,cp;function dp(){if(cp)return ma;cp=1;var e=ua();function t(r,n){var s=n?e(r.buffer):r.buffer;return new r.constructor(s,r.byteOffset,r.length)}return ma=t,ma}var ga,up;function bv(){if(up)return ga;up=1;var e=ua(),t=gv(),r=yv(),n=xv(),s=dp(),a="[object Boolean]",i="[object Date]",l="[object Map]",c="[object Number]",u="[object RegExp]",d="[object Set]",p="[object String]",h="[object Symbol]",f="[object ArrayBuffer]",m="[object DataView]",y="[object Float32Array]",v="[object Float64Array]",g="[object Int8Array]",x="[object Int16Array]",b="[object Int32Array]",k="[object Uint8Array]",S="[object Uint8ClampedArray]",C="[object Uint16Array]",T="[object Uint32Array]";function N(w,_,j){var P=w.constructor;switch(_){case f:return e(w);case a:case i:return new P(+w);case m:return t(w,j);case y:case v:case g:case x:case b:case k:case S:case C:case T:return s(w,j);case l:return new P;case c:case p:return new P(w);case u:return r(w);case d:return new P;case h:return n(w)}}return ga=N,ga}var ya,pp;function fp(){if(pp)return ya;pp=1;var e=Je(),t=Object.create,r=(function(){function n(){}return function(s){if(!e(s))return{};if(t)return t(s);n.prototype=s;var a=new n;return n.prototype=void 0,a}})();return ya=r,ya}var xa,hp;function mp(){if(hp)return xa;hp=1;var e=fp(),t=Ir(),r=Tr();function n(s){return typeof s.constructor=="function"&&!r(s)?e(t(s)):{}}return xa=n,xa}var ba,gp;function vv(){if(gp)return ba;gp=1;var e=It(),t=tt(),r="[object Map]";function n(s){return t(s)&&e(s)==r}return ba=n,ba}var va,yp;function kv(){if(yp)return va;yp=1;var e=vv(),t=jr(),r=Co(),n=r&&r.isMap,s=n?t(n):e;return va=s,va}var ka,xp;function Sv(){if(xp)return ka;xp=1;var e=It(),t=tt(),r="[object Set]";function n(s){return t(s)&&e(s)==r}return ka=n,ka}var Sa,bp;function wv(){if(bp)return Sa;bp=1;var e=Sv(),t=jr(),r=Co(),n=r&&r.isSet,s=n?t(n):e;return Sa=s,Sa}var wa,vp;function kp(){if(vp)return wa;vp=1;var e=kr(),t=po(),r=wr(),n=av(),s=lv(),a=Ru(),i=Ou(),l=cv(),c=dv(),u=Ku(),d=uv(),p=It(),h=mv(),f=bv(),m=mp(),y=Pe(),v=Tt(),g=kv(),x=Je(),b=wv(),k=lt(),S=mt(),C=1,T=2,N=4,w="[object Arguments]",_="[object Array]",j="[object Boolean]",P="[object Date]",E="[object Error]",A="[object Function]",L="[object GeneratorFunction]",B="[object Map]",z="[object Number]",R="[object Object]",q="[object RegExp]",M="[object Set]",O="[object String]",W="[object Symbol]",U="[object WeakMap]",$="[object ArrayBuffer]",H="[object DataView]",K="[object Float32Array]",V="[object Float64Array]",te="[object Int8Array]",ue="[object Int16Array]",ye="[object Int32Array]",_e="[object Uint8Array]",Ne="[object Uint8ClampedArray]",J="[object Uint16Array]",Se="[object Uint32Array]",ne={};ne[w]=ne[_]=ne[$]=ne[H]=ne[j]=ne[P]=ne[K]=ne[V]=ne[te]=ne[ue]=ne[ye]=ne[B]=ne[z]=ne[R]=ne[q]=ne[M]=ne[O]=ne[W]=ne[_e]=ne[Ne]=ne[J]=ne[Se]=!0,ne[E]=ne[A]=ne[U]=!1;function xe(ie,je,me,ge,Fe,Te){var be,Re=je&C,Ee=je&T,nt=je&N;if(me&&(be=Fe?me(ie,ge,Fe,Te):me(ie)),be!==void 0)return be;if(!x(ie))return ie;var Z=y(ie);if(Z){if(be=h(ie),!Re)return i(ie,be)}else{var ee=p(ie),ae=ee==A||ee==L;if(v(ie))return a(ie,Re);if(ee==R||ee==w||ae&&!Fe){if(be=Ee||ae?{}:m(ie),!Re)return Ee?c(ie,s(be,ie)):l(ie,n(be,ie))}else{if(!ne[ee])return Fe?ie:{};be=f(ie,ee,Re)}}Te||(Te=new e);var pe=Te.get(ie);if(pe)return pe;Te.set(ie,be),b(ie)?ie.forEach(function(D){be.add(xe(D,je,me,D,ie,Te))}):g(ie)&&ie.forEach(function(D,Y){be.set(Y,xe(D,je,me,Y,ie,Te))});var Q=nt?Ee?d:u:Ee?S:k,fe=Z?void 0:Q(ie);return t(fe||ie,function(D,Y){fe&&(Y=D,D=ie[Y]),r(be,Y,xe(D,je,me,Y,ie,Te))}),be}return wa=xe,wa}var _a,Sp;function _v(){if(Sp)return _a;Sp=1;var e=kp(),t=4;function r(n){return e(n,t)}return _a=r,_a}var ja,wp;function Ta(){if(wp)return ja;wp=1;function e(t){return function(){return t}}return ja=e,ja}var Ia,_p;function jv(){if(_p)return Ia;_p=1;function e(t){return function(r,n,s){for(var a=-1,i=Object(r),l=s(r),c=l.length;c--;){var u=l[t?c:++a];if(n(i[u],u,i)===!1)break}return r}}return Ia=e,Ia}var Ca,jp;function Na(){if(jp)return Ca;jp=1;var e=jv(),t=e();return Ca=t,Ca}var Ea,Tp;function Ra(){if(Tp)return Ea;Tp=1;var e=Na(),t=lt();function r(n,s){return n&&e(n,s,t)}return Ea=r,Ea}var Pa,Ip;function Tv(){if(Ip)return Pa;Ip=1;var e=ot();function t(r,n){return function(s,a){if(s==null)return s;if(!e(s))return r(s,a);for(var i=s.length,l=n?i:-1,c=Object(s);(n?l--:++l<i)&&a(c[l],l,c)!==!1;);return s}}return Pa=t,Pa}var Oa,Cp;function Cr(){if(Cp)return Oa;Cp=1;var e=Ra(),t=Tv(),r=t(e);return Oa=r,Oa}var Aa,Np;function gt(){if(Np)return Aa;Np=1;function e(t){return t}return Aa=e,Aa}var Da,Ep;function Rp(){if(Ep)return Da;Ep=1;var e=gt();function t(r){return typeof r=="function"?r:e}return Da=t,Da}var La,Pp;function Op(){if(Pp)return La;Pp=1;var e=po(),t=Cr(),r=Rp(),n=Pe();function s(a,i){var l=n(a)?e:t;return l(a,r(i))}return La=s,La}var Ma,Ap;function Dp(){return Ap||(Ap=1,Ma=Op()),Ma}var $a,Lp;function Iv(){if(Lp)return $a;Lp=1;var e=Cr();function t(r,n){var s=[];return e(r,function(a,i,l){n(a,i,l)&&s.push(a)}),s}return $a=t,$a}var za,Mp;function Cv(){if(Mp)return za;Mp=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return za=t,za}var qa,$p;function Nv(){if($p)return qa;$p=1;function e(t){return this.__data__.has(t)}return qa=e,qa}var Wa,zp;function qp(){if(zp)return Wa;zp=1;var e=io(),t=Cv(),r=Nv();function n(s){var a=-1,i=s==null?0:s.length;for(this.__data__=new e;++a<i;)this.add(s[a])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,Wa=n,Wa}var Fa,Wp;function Ev(){if(Wp)return Fa;Wp=1;function e(t,r){for(var n=-1,s=t==null?0:t.length;++n<s;)if(r(t[n],n,t))return!0;return!1}return Fa=e,Fa}var Ba,Fp;function Bp(){if(Fp)return Ba;Fp=1;function e(t,r){return t.has(r)}return Ba=e,Ba}var Ha,Hp;function Up(){if(Hp)return Ha;Hp=1;var e=qp(),t=Ev(),r=Bp(),n=1,s=2;function a(i,l,c,u,d,p){var h=c&n,f=i.length,m=l.length;if(f!=m&&!(h&&m>f))return!1;var y=p.get(i),v=p.get(l);if(y&&v)return y==l&&v==i;var g=-1,x=!0,b=c&s?new e:void 0;for(p.set(i,l),p.set(l,i);++g<f;){var k=i[g],S=l[g];if(u)var C=h?u(S,k,g,l,i,p):u(k,S,g,i,l,p);if(C!==void 0){if(C)continue;x=!1;break}if(b){if(!t(l,function(T,N){if(!r(b,N)&&(k===T||d(k,T,c,u,p)))return b.push(N)})){x=!1;break}}else if(!(k===S||d(k,S,c,u,p))){x=!1;break}}return p.delete(i),p.delete(l),x}return Ha=a,Ha}var Ua,Jp;function Rv(){if(Jp)return Ua;Jp=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(s,a){n[++r]=[a,s]}),n}return Ua=e,Ua}var Ja,Vp;function Va(){if(Vp)return Ja;Vp=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(s){n[++r]=s}),n}return Ja=e,Ja}var Ka,Kp;function Pv(){if(Kp)return Ka;Kp=1;var e=jt(),t=op(),r=_t(),n=Up(),s=Rv(),a=Va(),i=1,l=2,c="[object Boolean]",u="[object Date]",d="[object Error]",p="[object Map]",h="[object Number]",f="[object RegExp]",m="[object Set]",y="[object String]",v="[object Symbol]",g="[object ArrayBuffer]",x="[object DataView]",b=e?e.prototype:void 0,k=b?b.valueOf:void 0;function S(C,T,N,w,_,j,P){switch(N){case x:if(C.byteLength!=T.byteLength||C.byteOffset!=T.byteOffset)return!1;C=C.buffer,T=T.buffer;case g:return!(C.byteLength!=T.byteLength||!j(new t(C),new t(T)));case c:case u:case h:return r(+C,+T);case d:return C.name==T.name&&C.message==T.message;case f:case y:return C==T+"";case p:var E=s;case m:var A=w&i;if(E||(E=a),C.size!=T.size&&!A)return!1;var L=P.get(C);if(L)return L==T;w|=l,P.set(C,T);var B=n(E(C),E(T),w,_,j,P);return P.delete(C),B;case v:if(k)return k.call(C)==k.call(T)}return!1}return Ka=S,Ka}var Ga,Gp;function Ov(){if(Gp)return Ga;Gp=1;var e=Ku(),t=1,r=Object.prototype,n=r.hasOwnProperty;function s(a,i,l,c,u,d){var p=l&t,h=e(a),f=h.length,m=e(i),y=m.length;if(f!=y&&!p)return!1;for(var v=f;v--;){var g=h[v];if(!(p?g in i:n.call(i,g)))return!1}var x=d.get(a),b=d.get(i);if(x&&b)return x==i&&b==a;var k=!0;d.set(a,i),d.set(i,a);for(var S=p;++v<f;){g=h[v];var C=a[g],T=i[g];if(c)var N=p?c(T,C,g,i,a,d):c(C,T,g,a,i,d);if(!(N===void 0?C===T||u(C,T,l,c,d):N)){k=!1;break}S||(S=g=="constructor")}if(k&&!S){var w=a.constructor,_=i.constructor;w!=_&&"constructor"in a&&"constructor"in i&&!(typeof w=="function"&&w instanceof w&&typeof _=="function"&&_ instanceof _)&&(k=!1)}return d.delete(a),d.delete(i),k}return Ga=s,Ga}var Ya,Yp;function Av(){if(Yp)return Ya;Yp=1;var e=kr(),t=Up(),r=Pv(),n=Ov(),s=It(),a=Pe(),i=Tt(),l=Ut(),c=1,u="[object Arguments]",d="[object Array]",p="[object Object]",h=Object.prototype,f=h.hasOwnProperty;function m(y,v,g,x,b,k){var S=a(y),C=a(v),T=S?d:s(y),N=C?d:s(v);T=T==u?p:T,N=N==u?p:N;var w=T==p,_=N==p,j=T==N;if(j&&i(y)){if(!i(v))return!1;S=!0,w=!1}if(j&&!w)return k||(k=new e),S||l(y)?t(y,v,g,x,b,k):r(y,v,T,g,x,b,k);if(!(g&c)){var P=w&&f.call(y,"__wrapped__"),E=_&&f.call(v,"__wrapped__");if(P||E){var A=P?y.value():y,L=E?v.value():v;return k||(k=new e),b(A,L,g,x,k)}}return j?(k||(k=new e),n(y,v,g,x,b,k)):!1}return Ya=m,Ya}var Xa,Xp;function Zp(){if(Xp)return Xa;Xp=1;var e=Av(),t=tt();function r(n,s,a,i,l){return n===s?!0:n==null||s==null||!t(n)&&!t(s)?n!==n&&s!==s:e(n,s,a,i,r,l)}return Xa=r,Xa}var Za,Qp;function Dv(){if(Qp)return Za;Qp=1;var e=kr(),t=Zp(),r=1,n=2;function s(a,i,l,c){var u=l.length,d=u,p=!c;if(a==null)return!d;for(a=Object(a);u--;){var h=l[u];if(p&&h[2]?h[1]!==a[h[0]]:!(h[0]in a))return!1}for(;++u<d;){h=l[u];var f=h[0],m=a[f],y=h[1];if(p&&h[2]){if(m===void 0&&!(f in a))return!1}else{var v=new e;if(c)var g=c(m,y,f,a,i,v);if(!(g===void 0?t(y,m,r|n,c,v):g))return!1}}return!0}return Za=s,Za}var Qa,ef;function tf(){if(ef)return Qa;ef=1;var e=Je();function t(r){return r===r&&!e(r)}return Qa=t,Qa}var es,rf;function Lv(){if(rf)return es;rf=1;var e=tf(),t=lt();function r(n){for(var s=t(n),a=s.length;a--;){var i=s[a],l=n[i];s[a]=[i,l,e(l)]}return s}return es=r,es}var ts,nf;function of(){if(nf)return ts;nf=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return ts=e,ts}var rs,af;function Mv(){if(af)return rs;af=1;var e=Dv(),t=Lv(),r=of();function n(s){var a=t(s);return a.length==1&&a[0][2]?r(a[0][0],a[0][1]):function(i){return i===s||e(i,s,a)}}return rs=n,rs}var ns,sf;function Ct(){if(sf)return ns;sf=1;var e=ft(),t=tt(),r="[object Symbol]";function n(s){return typeof s=="symbol"||t(s)&&e(s)==r}return ns=n,ns}var os,lf;function as(){if(lf)return os;lf=1;var e=Pe(),t=Ct(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function s(a,i){if(e(a))return!1;var l=typeof a;return l=="number"||l=="symbol"||l=="boolean"||a==null||t(a)?!0:n.test(a)||!r.test(a)||i!=null&&a in Object(i)}return os=s,os}var ss,cf;function $v(){if(cf)return ss;cf=1;var e=io(),t="Expected a function";function r(n,s){if(typeof n!="function"||s!=null&&typeof s!="function")throw new TypeError(t);var a=function(){var i=arguments,l=s?s.apply(this,i):i[0],c=a.cache;if(c.has(l))return c.get(l);var u=n.apply(this,i);return a.cache=c.set(l,u)||c,u};return a.cache=new(r.Cache||e),a}return r.Cache=e,ss=r,ss}var is,df;function zv(){if(df)return is;df=1;var e=$v(),t=500;function r(n){var s=e(n,function(i){return a.size===t&&a.clear(),i}),a=s.cache;return s}return is=r,is}var ls,uf;function qv(){if(uf)return ls;uf=1;var e=zv(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(s){var a=[];return s.charCodeAt(0)===46&&a.push(""),s.replace(t,function(i,l,c,u){a.push(c?u.replace(r,"$1"):l||i)}),a});return ls=n,ls}var cs,pf;function Nr(){if(pf)return cs;pf=1;function e(t,r){for(var n=-1,s=t==null?0:t.length,a=Array(s);++n<s;)a[n]=r(t[n],n,t);return a}return cs=e,cs}var ds,ff;function Wv(){if(ff)return ds;ff=1;var e=jt(),t=Nr(),r=Pe(),n=Ct(),s=e?e.prototype:void 0,a=s?s.toString:void 0;function i(l){if(typeof l=="string")return l;if(r(l))return t(l,i)+"";if(n(l))return a?a.call(l):"";var c=l+"";return c=="0"&&1/l==-1/0?"-0":c}return ds=i,ds}var us,hf;function mf(){if(hf)return us;hf=1;var e=Wv();function t(r){return r==null?"":e(r)}return us=t,us}var ps,gf;function Er(){if(gf)return ps;gf=1;var e=Pe(),t=as(),r=qv(),n=mf();function s(a,i){return e(a)?a:t(a,i)?[a]:r(n(a))}return ps=s,ps}var fs,yf;function Vt(){if(yf)return fs;yf=1;var e=Ct();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return fs=t,fs}var hs,xf;function Rr(){if(xf)return hs;xf=1;var e=Er(),t=Vt();function r(n,s){s=e(s,n);for(var a=0,i=s.length;n!=null&&a<i;)n=n[t(s[a++])];return a&&a==i?n:void 0}return hs=r,hs}var ms,bf;function Fv(){if(bf)return ms;bf=1;var e=Rr();function t(r,n,s){var a=r==null?void 0:e(r,n);return a===void 0?s:a}return ms=t,ms}var gs,vf;function Bv(){if(vf)return gs;vf=1;function e(t,r){return t!=null&&r in Object(t)}return gs=e,gs}var ys,kf;function Sf(){if(kf)return ys;kf=1;var e=Er(),t=Ft(),r=Pe(),n=_r(),s=jo(),a=Vt();function i(l,c,u){c=e(c,l);for(var d=-1,p=c.length,h=!1;++d<p;){var f=a(c[d]);if(!(h=l!=null&&u(l,f)))break;l=l[f]}return h||++d!=p?h:(p=l==null?0:l.length,!!p&&s(p)&&n(f,p)&&(r(l)||t(l)))}return ys=i,ys}var xs,wf;function _f(){if(wf)return xs;wf=1;var e=Bv(),t=Sf();function r(n,s){return n!=null&&t(n,s,e)}return xs=r,xs}var bs,jf;function Hv(){if(jf)return bs;jf=1;var e=Zp(),t=Fv(),r=_f(),n=as(),s=tf(),a=of(),i=Vt(),l=1,c=2;function u(d,p){return n(d)&&s(p)?a(i(d),p):function(h){var f=t(h,d);return f===void 0&&f===p?r(h,d):e(p,f,l|c)}}return bs=u,bs}var vs,Tf;function If(){if(Tf)return vs;Tf=1;function e(t){return function(r){return r?.[t]}}return vs=e,vs}var ks,Cf;function Uv(){if(Cf)return ks;Cf=1;var e=Rr();function t(r){return function(n){return e(n,r)}}return ks=t,ks}var Ss,Nf;function Jv(){if(Nf)return Ss;Nf=1;var e=If(),t=Uv(),r=as(),n=Vt();function s(a){return r(a)?e(n(a)):t(a)}return Ss=s,Ss}var ws,Ef;function at(){if(Ef)return ws;Ef=1;var e=Mv(),t=Hv(),r=gt(),n=Pe(),s=Jv();function a(i){return typeof i=="function"?i:i==null?r:typeof i=="object"?n(i)?t(i[0],i[1]):e(i):s(i)}return ws=a,ws}var _s,Rf;function Pf(){if(Rf)return _s;Rf=1;var e=Du(),t=Iv(),r=at(),n=Pe();function s(a,i){var l=n(a)?e:t;return l(a,r(i,3))}return _s=s,_s}var js,Of;function Vv(){if(Of)return js;Of=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,s){return n!=null&&t.call(n,s)}return js=r,js}var Ts,Af;function Df(){if(Af)return Ts;Af=1;var e=Vv(),t=Sf();function r(n,s){return n!=null&&t(n,s,e)}return Ts=r,Ts}var Is,Lf;function Kv(){if(Lf)return Is;Lf=1;var e=Do(),t=It(),r=Ft(),n=Pe(),s=ot(),a=Tt(),i=Tr(),l=Ut(),c="[object Map]",u="[object Set]",d=Object.prototype,p=d.hasOwnProperty;function h(f){if(f==null)return!0;if(s(f)&&(n(f)||typeof f=="string"||typeof f.splice=="function"||a(f)||l(f)||r(f)))return!f.length;var m=t(f);if(m==c||m==u)return!f.size;if(i(f))return!e(f).length;for(var y in f)if(p.call(f,y))return!1;return!0}return Is=h,Is}var Cs,Mf;function $f(){if(Mf)return Cs;Mf=1;function e(t){return t===void 0}return Cs=e,Cs}var Ns,zf;function qf(){if(zf)return Ns;zf=1;var e=Cr(),t=ot();function r(n,s){var a=-1,i=t(n)?Array(n.length):[];return e(n,function(l,c,u){i[++a]=s(l,c,u)}),i}return Ns=r,Ns}var Es,Wf;function Ff(){if(Wf)return Es;Wf=1;var e=Nr(),t=at(),r=qf(),n=Pe();function s(a,i){var l=n(a)?e:r;return l(a,t(i,3))}return Es=s,Es}var Rs,Bf;function Gv(){if(Bf)return Rs;Bf=1;function e(t,r,n,s){var a=-1,i=t==null?0:t.length;for(s&&i&&(n=t[++a]);++a<i;)n=r(n,t[a],a,t);return n}return Rs=e,Rs}var Ps,Hf;function Yv(){if(Hf)return Ps;Hf=1;function e(t,r,n,s,a){return a(t,function(i,l,c){n=s?(s=!1,i):r(n,i,l,c)}),n}return Ps=e,Ps}var Os,Uf;function Jf(){if(Uf)return Os;Uf=1;var e=Gv(),t=Cr(),r=at(),n=Yv(),s=Pe();function a(i,l,c){var u=s(i)?e:n,d=arguments.length<3;return u(i,r(l,4),c,d,t)}return Os=a,Os}var As,Vf;function Xv(){if(Vf)return As;Vf=1;var e=ft(),t=Pe(),r=tt(),n="[object String]";function s(a){return typeof a=="string"||!t(a)&&r(a)&&e(a)==n}return As=s,As}var Ds,Kf;function Zv(){if(Kf)return Ds;Kf=1;var e=If(),t=e("length");return Ds=t,Ds}var Ls,Gf;function Qv(){if(Gf)return Ls;Gf=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",s=t+r+n,a="\\ufe0e\\ufe0f",i="\\u200d",l=RegExp("["+i+e+s+a+"]");function c(u){return l.test(u)}return Ls=c,Ls}var Ms,Yf;function e1(){if(Yf)return Ms;Yf=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",s=t+r+n,a="\\ufe0e\\ufe0f",i="["+e+"]",l="["+s+"]",c="\\ud83c[\\udffb-\\udfff]",u="(?:"+l+"|"+c+")",d="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",h="[\\ud800-\\udbff][\\udc00-\\udfff]",f="\\u200d",m=u+"?",y="["+a+"]?",v="(?:"+f+"(?:"+[d,p,h].join("|")+")"+y+m+")*",g=y+m+v,x="(?:"+[d+l+"?",l,p,h,i].join("|")+")",b=RegExp(c+"(?="+c+")|"+x+g,"g");function k(S){for(var C=b.lastIndex=0;b.test(S);)++C;return C}return Ms=k,Ms}var $s,Xf;function t1(){if(Xf)return $s;Xf=1;var e=Zv(),t=Qv(),r=e1();function n(s){return t(s)?r(s):e(s)}return $s=n,$s}var zs,Zf;function r1(){if(Zf)return zs;Zf=1;var e=Do(),t=It(),r=ot(),n=Xv(),s=t1(),a="[object Map]",i="[object Set]";function l(c){if(c==null)return 0;if(r(c))return n(c)?s(c):c.length;var u=t(c);return u==a||u==i?c.size:e(c).length}return zs=l,zs}var qs,Qf;function n1(){if(Qf)return qs;Qf=1;var e=po(),t=fp(),r=Ra(),n=at(),s=Ir(),a=Pe(),i=Tt(),l=qt(),c=Je(),u=Ut();function d(p,h,f){var m=a(p),y=m||i(p)||u(p);if(h=n(h,4),f==null){var v=p&&p.constructor;y?f=m?new v:[]:c(p)?f=l(v)?t(s(p)):{}:f={}}return(y?e:r)(p,function(g,x,b){return h(f,g,x,b)}),f}return qs=d,qs}var Ws,eh;function o1(){if(eh)return Ws;eh=1;var e=jt(),t=Ft(),r=Pe(),n=e?e.isConcatSpreadable:void 0;function s(a){return r(a)||t(a)||!!(n&&a&&a[n])}return Ws=s,Ws}var Fs,th;function Bs(){if(th)return Fs;th=1;var e=Yo(),t=o1();function r(n,s,a,i,l){var c=-1,u=n.length;for(a||(a=t),l||(l=[]);++c<u;){var d=n[c];s>0&&a(d)?s>1?r(d,s-1,a,i,l):e(l,d):i||(l[l.length]=d)}return l}return Fs=r,Fs}var Hs,rh;function a1(){if(rh)return Hs;rh=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 Hs=e,Hs}var Us,nh;function oh(){if(nh)return Us;nh=1;var e=a1(),t=Math.max;function r(n,s,a){return s=t(s===void 0?n.length-1:s,0),function(){for(var i=arguments,l=-1,c=t(i.length-s,0),u=Array(c);++l<c;)u[l]=i[s+l];l=-1;for(var d=Array(s+1);++l<s;)d[l]=i[l];return d[s]=a(u),e(n,this,d)}}return Us=r,Us}var Js,ah;function s1(){if(ah)return Js;ah=1;var e=Ta(),t=Qd(),r=gt(),n=t?function(s,a){return t(s,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:r;return Js=n,Js}var Vs,sh;function i1(){if(sh)return Vs;sh=1;var e=800,t=16,r=Date.now;function n(s){var a=0,i=0;return function(){var l=r(),c=t-(l-i);if(i=l,c>0){if(++a>=e)return arguments[0]}else a=0;return s.apply(void 0,arguments)}}return Vs=n,Vs}var Ks,ih;function lh(){if(ih)return Ks;ih=1;var e=s1(),t=i1(),r=t(e);return Ks=r,Ks}var Gs,ch;function Pr(){if(ch)return Gs;ch=1;var e=gt(),t=oh(),r=lh();function n(s,a){return r(t(s,a,e),s+"")}return Gs=n,Gs}var Ys,dh;function uh(){if(dh)return Ys;dh=1;function e(t,r,n,s){for(var a=t.length,i=n+(s?1:-1);s?i--:++i<a;)if(r(t[i],i,t))return i;return-1}return Ys=e,Ys}var Xs,ph;function l1(){if(ph)return Xs;ph=1;function e(t){return t!==t}return Xs=e,Xs}var Zs,fh;function c1(){if(fh)return Zs;fh=1;function e(t,r,n){for(var s=n-1,a=t.length;++s<a;)if(t[s]===r)return s;return-1}return Zs=e,Zs}var Qs,hh;function d1(){if(hh)return Qs;hh=1;var e=uh(),t=l1(),r=c1();function n(s,a,i){return a===a?r(s,a,i):e(s,t,i)}return Qs=n,Qs}var ei,mh;function u1(){if(mh)return ei;mh=1;var e=d1();function t(r,n){var s=r==null?0:r.length;return!!s&&e(r,n,0)>-1}return ei=t,ei}var ti,gh;function p1(){if(gh)return ti;gh=1;function e(t,r,n){for(var s=-1,a=t==null?0:t.length;++s<a;)if(n(r,t[s]))return!0;return!1}return ti=e,ti}var ri,yh;function f1(){if(yh)return ri;yh=1;function e(){}return ri=e,ri}var ni,xh;function h1(){if(xh)return ni;xh=1;var e=Qu(),t=f1(),r=Va(),n=1/0,s=e&&1/r(new e([,-0]))[1]==n?function(a){return new e(a)}:t;return ni=s,ni}var oi,bh;function m1(){if(bh)return oi;bh=1;var e=qp(),t=u1(),r=p1(),n=Bp(),s=h1(),a=Va(),i=200;function l(c,u,d){var p=-1,h=t,f=c.length,m=!0,y=[],v=y;if(d)m=!1,h=r;else if(f>=i){var g=u?null:s(c);if(g)return a(g);m=!1,h=n,v=new e}else v=u?[]:y;e:for(;++p<f;){var x=c[p],b=u?u(x):x;if(x=d||x!==0?x:0,m&&b===b){for(var k=v.length;k--;)if(v[k]===b)continue e;u&&v.push(b),y.push(x)}else h(v,b,d)||(v!==y&&v.push(b),y.push(x))}return y}return oi=l,oi}var ai,vh;function kh(){if(vh)return ai;vh=1;var e=ot(),t=tt();function r(n){return t(n)&&e(n)}return ai=r,ai}var si,Sh;function g1(){if(Sh)return si;Sh=1;var e=Bs(),t=Pr(),r=m1(),n=kh(),s=t(function(a){return r(e(a,1,n,!0))});return si=s,si}var ii,wh;function y1(){if(wh)return ii;wh=1;var e=Nr();function t(r,n){return e(n,function(s){return r[s]})}return ii=t,ii}var li,_h;function jh(){if(_h)return li;_h=1;var e=y1(),t=lt();function r(n){return n==null?[]:e(n,t(n))}return li=r,li}var ci,Th;function Ve(){if(Th)return ci;Th=1;var e;if(typeof yn=="function")try{e={clone:_v(),constant:Ta(),each:Dp(),filter:Pf(),has:Df(),isArray:Pe(),isEmpty:Kv(),isFunction:qt(),isUndefined:$f(),keys:lt(),map:Ff(),reduce:Jf(),size:r1(),transform:n1(),union:g1(),values:jh()}}catch{}return e||(e=window._),ci=e,ci}var di,Ih;function ui(){if(Ih)return di;Ih=1;var e=Ve();di=s;var t="\0",r="\0",n="";function s(d){this._isDirected=e.has(d,"directed")?d.directed:!0,this._isMultigraph=e.has(d,"multigraph")?d.multigraph:!1,this._isCompound=e.has(d,"compound")?d.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(d){return this._label=d,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultNodeLabelFn=d,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var d=this;return e.filter(this.nodes(),function(p){return e.isEmpty(d._in[p])})},s.prototype.sinks=function(){var d=this;return e.filter(this.nodes(),function(p){return e.isEmpty(d._out[p])})},s.prototype.setNodes=function(d,p){var h=arguments,f=this;return e.each(d,function(m){h.length>1?f.setNode(m,p):f.setNode(m)}),this},s.prototype.setNode=function(d,p){return e.has(this._nodes,d)?(arguments.length>1&&(this._nodes[d]=p),this):(this._nodes[d]=arguments.length>1?p:this._defaultNodeLabelFn(d),this._isCompound&&(this._parent[d]=r,this._children[d]={},this._children[r][d]=!0),this._in[d]={},this._preds[d]={},this._out[d]={},this._sucs[d]={},++this._nodeCount,this)},s.prototype.node=function(d){return this._nodes[d]},s.prototype.hasNode=function(d){return e.has(this._nodes,d)},s.prototype.removeNode=function(d){var p=this;if(e.has(this._nodes,d)){var h=function(f){p.removeEdge(p._edgeObjs[f])};delete this._nodes[d],this._isCompound&&(this._removeFromParentsChildList(d),delete this._parent[d],e.each(this.children(d),function(f){p.setParent(f)}),delete this._children[d]),e.each(e.keys(this._in[d]),h),delete this._in[d],delete this._preds[d],e.each(e.keys(this._out[d]),h),delete this._out[d],delete this._sucs[d],--this._nodeCount}return this},s.prototype.setParent=function(d,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(p))p=r;else{p+="";for(var h=p;!e.isUndefined(h);h=this.parent(h))if(h===d)throw new Error("Setting "+p+" as parent of "+d+" would create a cycle");this.setNode(p)}return this.setNode(d),this._removeFromParentsChildList(d),this._parent[d]=p,this._children[p][d]=!0,this},s.prototype._removeFromParentsChildList=function(d){delete this._children[this._parent[d]][d]},s.prototype.parent=function(d){if(this._isCompound){var p=this._parent[d];if(p!==r)return p}},s.prototype.children=function(d){if(e.isUndefined(d)&&(d=r),this._isCompound){var p=this._children[d];if(p)return e.keys(p)}else{if(d===r)return this.nodes();if(this.hasNode(d))return[]}},s.prototype.predecessors=function(d){var p=this._preds[d];if(p)return e.keys(p)},s.prototype.successors=function(d){var p=this._sucs[d];if(p)return e.keys(p)},s.prototype.neighbors=function(d){var p=this.predecessors(d);if(p)return e.union(p,this.successors(d))},s.prototype.isLeaf=function(d){var p;return this.isDirected()?p=this.successors(d):p=this.neighbors(d),p.length===0},s.prototype.filterNodes=function(d){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var h=this;e.each(this._nodes,function(y,v){d(v)&&p.setNode(v,y)}),e.each(this._edgeObjs,function(y){p.hasNode(y.v)&&p.hasNode(y.w)&&p.setEdge(y,h.edge(y))});var f={};function m(y){var v=h.parent(y);return v===void 0||p.hasNode(v)?(f[y]=v,v):v in f?f[v]:m(v)}return this._isCompound&&e.each(p.nodes(),function(y){p.setParent(y,m(y))}),p},s.prototype.setDefaultEdgeLabel=function(d){return e.isFunction(d)||(d=e.constant(d)),this._defaultEdgeLabelFn=d,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(d,p){var h=this,f=arguments;return e.reduce(d,function(m,y){return f.length>1?h.setEdge(m,y,p):h.setEdge(m,y),y}),this},s.prototype.setEdge=function(){var d,p,h,f,m=!1,y=arguments[0];typeof y=="object"&&y!==null&&"v"in y?(d=y.v,p=y.w,h=y.name,arguments.length===2&&(f=arguments[1],m=!0)):(d=y,p=arguments[1],h=arguments[3],arguments.length>2&&(f=arguments[2],m=!0)),d=""+d,p=""+p,e.isUndefined(h)||(h=""+h);var v=l(this._isDirected,d,p,h);if(e.has(this._edgeLabels,v))return m&&(this._edgeLabels[v]=f),this;if(!e.isUndefined(h)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(d),this.setNode(p),this._edgeLabels[v]=m?f:this._defaultEdgeLabelFn(d,p,h);var g=c(this._isDirected,d,p,h);return d=g.v,p=g.w,Object.freeze(g),this._edgeObjs[v]=g,a(this._preds[p],d),a(this._sucs[d],p),this._in[p][v]=g,this._out[d][v]=g,this._edgeCount++,this},s.prototype.edge=function(d,p,h){var f=arguments.length===1?u(this._isDirected,arguments[0]):l(this._isDirected,d,p,h);return this._edgeLabels[f]},s.prototype.hasEdge=function(d,p,h){var f=arguments.length===1?u(this._isDirected,arguments[0]):l(this._isDirected,d,p,h);return e.has(this._edgeLabels,f)},s.prototype.removeEdge=function(d,p,h){var f=arguments.length===1?u(this._isDirected,arguments[0]):l(this._isDirected,d,p,h),m=this._edgeObjs[f];return m&&(d=m.v,p=m.w,delete this._edgeLabels[f],delete this._edgeObjs[f],i(this._preds[p],d),i(this._sucs[d],p),delete this._in[p][f],delete this._out[d][f],this._edgeCount--),this},s.prototype.inEdges=function(d,p){var h=this._in[d];if(h){var f=e.values(h);return p?e.filter(f,function(m){return m.v===p}):f}},s.prototype.outEdges=function(d,p){var h=this._out[d];if(h){var f=e.values(h);return p?e.filter(f,function(m){return m.w===p}):f}},s.prototype.nodeEdges=function(d,p){var h=this.inEdges(d,p);if(h)return h.concat(this.outEdges(d,p))};function a(d,p){d[p]?d[p]++:d[p]=1}function i(d,p){--d[p]||delete d[p]}function l(d,p,h,f){var m=""+p,y=""+h;if(!d&&m>y){var v=m;m=y,y=v}return m+n+y+n+(e.isUndefined(f)?t:f)}function c(d,p,h,f){var m=""+p,y=""+h;if(!d&&m>y){var v=m;m=y,y=v}var g={v:m,w:y};return f&&(g.name=f),g}function u(d,p){return l(d,p.v,p.w,p.name)}return di}var pi,Ch;function x1(){return Ch||(Ch=1,pi="2.1.8"),pi}var fi,Nh;function b1(){return Nh||(Nh=1,fi={Graph:ui(),version:x1()}),fi}var hi,Eh;function v1(){if(Eh)return hi;Eh=1;var e=Ve(),t=ui();hi={write:r,read:a};function r(i){var l={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:n(i),edges:s(i)};return e.isUndefined(i.graph())||(l.value=e.clone(i.graph())),l}function n(i){return e.map(i.nodes(),function(l){var c=i.node(l),u=i.parent(l),d={v:l};return e.isUndefined(c)||(d.value=c),e.isUndefined(u)||(d.parent=u),d})}function s(i){return e.map(i.edges(),function(l){var c=i.edge(l),u={v:l.v,w:l.w};return e.isUndefined(l.name)||(u.name=l.name),e.isUndefined(c)||(u.value=c),u})}function a(i){var l=new t(i.options).setGraph(i.value);return e.each(i.nodes,function(c){l.setNode(c.v,c.value),c.parent&&l.setParent(c.v,c.parent)}),e.each(i.edges,function(c){l.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),l}return hi}var mi,Rh;function k1(){if(Rh)return mi;Rh=1;var e=Ve();mi=t;function t(r){var n={},s=[],a;function i(l){e.has(n,l)||(n[l]=!0,a.push(l),e.each(r.successors(l),i),e.each(r.predecessors(l),i))}return e.each(r.nodes(),function(l){a=[],i(l),a.length&&s.push(a)}),s}return mi}var gi,Ph;function Oh(){if(Ph)return gi;Ph=1;var e=Ve();gi=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 s=this._keyIndices;if(r=String(r),!e.has(s,r)){var a=this._arr,i=a.length;return s[r]=i,a.push({key:r,priority:n}),this._decrease(i),!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 s=this._keyIndices[r];if(n>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[s].priority+" New: "+n);this._arr[s].priority=n,this._decrease(s)},t.prototype._heapify=function(r){var n=this._arr,s=2*r,a=s+1,i=r;s<n.length&&(i=n[s].priority<n[i].priority?s:i,a<n.length&&(i=n[a].priority<n[i].priority?a:i),i!==r&&(this._swap(r,i),this._heapify(i)))},t.prototype._decrease=function(r){for(var n=this._arr,s=n[r].priority,a;r!==0&&(a=r>>1,!(n[a].priority<s));)this._swap(r,a),r=a},t.prototype._swap=function(r,n){var s=this._arr,a=this._keyIndices,i=s[r],l=s[n];s[r]=l,s[n]=i,a[l.key]=r,a[i.key]=n},gi}var yi,Ah;function Dh(){if(Ah)return yi;Ah=1;var e=Ve(),t=Oh();yi=n;var r=e.constant(1);function n(a,i,l,c){return s(a,String(i),l||r,c||function(u){return a.outEdges(u)})}function s(a,i,l,c){var u={},d=new t,p,h,f=function(m){var y=m.v!==p?m.v:m.w,v=u[y],g=l(m),x=h.distance+g;if(g<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+m+" Weight: "+g);x<v.distance&&(v.distance=x,v.predecessor=p,d.decrease(y,x))};for(a.nodes().forEach(function(m){var y=m===i?0:Number.POSITIVE_INFINITY;u[m]={distance:y},d.add(m,y)});d.size()>0&&(p=d.removeMin(),h=u[p],h.distance!==Number.POSITIVE_INFINITY);)c(p).forEach(f);return u}return yi}var xi,Lh;function S1(){if(Lh)return xi;Lh=1;var e=Dh(),t=Ve();xi=r;function r(n,s,a){return t.transform(n.nodes(),function(i,l){i[l]=e(n,l,s,a)},{})}return xi}var bi,Mh;function $h(){if(Mh)return bi;Mh=1;var e=Ve();bi=t;function t(r){var n=0,s=[],a={},i=[];function l(c){var u=a[c]={onStack:!0,lowlink:n,index:n++};if(s.push(c),r.successors(c).forEach(function(h){e.has(a,h)?a[h].onStack&&(u.lowlink=Math.min(u.lowlink,a[h].index)):(l(h),u.lowlink=Math.min(u.lowlink,a[h].lowlink))}),u.lowlink===u.index){var d=[],p;do p=s.pop(),a[p].onStack=!1,d.push(p);while(c!==p);i.push(d)}}return r.nodes().forEach(function(c){e.has(a,c)||l(c)}),i}return bi}var vi,zh;function w1(){if(zh)return vi;zh=1;var e=Ve(),t=$h();vi=r;function r(n){return e.filter(t(n),function(s){return s.length>1||s.length===1&&n.hasEdge(s[0],s[0])})}return vi}var ki,qh;function _1(){if(qh)return ki;qh=1;var e=Ve();ki=r;var t=e.constant(1);function r(s,a,i){return n(s,a||t,i||function(l){return s.outEdges(l)})}function n(s,a,i){var l={},c=s.nodes();return c.forEach(function(u){l[u]={},l[u][u]={distance:0},c.forEach(function(d){u!==d&&(l[u][d]={distance:Number.POSITIVE_INFINITY})}),i(u).forEach(function(d){var p=d.v===u?d.w:d.v,h=a(d);l[u][p]={distance:h,predecessor:u}})}),c.forEach(function(u){var d=l[u];c.forEach(function(p){var h=l[p];c.forEach(function(f){var m=h[u],y=d[f],v=h[f],g=m.distance+y.distance;g<v.distance&&(v.distance=g,v.predecessor=y.predecessor)})})}),l}return ki}var Si,Wh;function Fh(){if(Wh)return Si;Wh=1;var e=Ve();Si=t,t.CycleException=r;function t(n){var s={},a={},i=[];function l(c){if(e.has(a,c))throw new r;e.has(s,c)||(a[c]=!0,s[c]=!0,e.each(n.predecessors(c),l),delete a[c],i.push(c))}if(e.each(n.sinks(),l),e.size(s)!==n.nodeCount())throw new r;return i}function r(){}return r.prototype=new Error,Si}var wi,Bh;function j1(){if(Bh)return wi;Bh=1;var e=Fh();wi=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return wi}var _i,Hh;function Uh(){if(Hh)return _i;Hh=1;var e=Ve();_i=t;function t(n,s,a){e.isArray(s)||(s=[s]);var i=(n.isDirected()?n.successors:n.neighbors).bind(n),l=[],c={};return e.each(s,function(u){if(!n.hasNode(u))throw new Error("Graph does not have node: "+u);r(n,u,a==="post",c,i,l)}),l}function r(n,s,a,i,l,c){e.has(i,s)||(i[s]=!0,a||c.push(s),e.each(l(s),function(u){r(n,u,a,i,l,c)}),a&&c.push(s))}return _i}var ji,Jh;function T1(){if(Jh)return ji;Jh=1;var e=Uh();ji=t;function t(r,n){return e(r,n,"post")}return ji}var Ti,Vh;function I1(){if(Vh)return Ti;Vh=1;var e=Uh();Ti=t;function t(r,n){return e(r,n,"pre")}return Ti}var Ii,Kh;function C1(){if(Kh)return Ii;Kh=1;var e=Ve(),t=ui(),r=Oh();Ii=n;function n(s,a){var i=new t,l={},c=new r,u;function d(h){var f=h.v===u?h.w:h.v,m=c.priority(f);if(m!==void 0){var y=a(h);y<m&&(l[f]=u,c.decrease(f,y))}}if(s.nodeCount()===0)return i;e.each(s.nodes(),function(h){c.add(h,Number.POSITIVE_INFINITY),i.setNode(h)}),c.decrease(s.nodes()[0],0);for(var p=!1;c.size()>0;){if(u=c.removeMin(),e.has(l,u))i.setEdge(u,l[u]);else{if(p)throw new Error("Input graph is not connected: "+s);p=!0}s.nodeEdges(u).forEach(d)}return i}return Ii}var Ci,Gh;function N1(){return Gh||(Gh=1,Ci={components:k1(),dijkstra:Dh(),dijkstraAll:S1(),findCycles:w1(),floydWarshall:_1(),isAcyclic:j1(),postorder:T1(),preorder:I1(),prim:C1(),tarjan:$h(),topsort:Fh()}),Ci}var Ni,Yh;function E1(){if(Yh)return Ni;Yh=1;var e=b1();return Ni={Graph:e.Graph,json:v1(),alg:N1(),version:e.version},Ni}var Ei,Xh;function Xe(){if(Xh)return Ei;Xh=1;var e;if(typeof yn=="function")try{e=E1()}catch{}return e||(e=window.graphlib),Ei=e,Ei}var Ri,Zh;function R1(){if(Zh)return Ri;Zh=1;var e=kp(),t=1,r=4;function n(s){return e(s,t|r)}return Ri=n,Ri}var Pi,Qh;function Or(){if(Qh)return Pi;Qh=1;var e=_t(),t=ot(),r=_r(),n=Je();function s(a,i,l){if(!n(l))return!1;var c=typeof i;return(c=="number"?t(l)&&r(i,l.length):c=="string"&&i in l)?e(l[i],a):!1}return Pi=s,Pi}var Oi,em;function P1(){if(em)return Oi;em=1;var e=Pr(),t=_t(),r=Or(),n=mt(),s=Object.prototype,a=s.hasOwnProperty,i=e(function(l,c){l=Object(l);var u=-1,d=c.length,p=d>2?c[2]:void 0;for(p&&r(c[0],c[1],p)&&(d=1);++u<d;)for(var h=c[u],f=n(h),m=-1,y=f.length;++m<y;){var v=f[m],g=l[v];(g===void 0||t(g,s[v])&&!a.call(l,v))&&(l[v]=h[v])}return l});return Oi=i,Oi}var Ai,tm;function O1(){if(tm)return Ai;tm=1;var e=at(),t=ot(),r=lt();function n(s){return function(a,i,l){var c=Object(a);if(!t(a)){var u=e(i,3);a=r(a),i=function(p){return u(c[p],p,c)}}var d=s(a,i,l);return d>-1?c[u?a[d]:d]:void 0}}return Ai=n,Ai}var Di,rm;function A1(){if(rm)return Di;rm=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return Di=t,Di}var Li,nm;function D1(){if(nm)return Li;nm=1;var e=A1(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return Li=r,Li}var Mi,om;function L1(){if(om)return Mi;om=1;var e=D1(),t=Je(),r=Ct(),n=NaN,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,i=/^0o[0-7]+$/i,l=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 p=a.test(u);return p||i.test(u)?l(u.slice(2),p?2:8):s.test(u)?n:+u}return Mi=c,Mi}var $i,am;function sm(){if(am)return $i;am=1;var e=L1(),t=1/0,r=17976931348623157e292;function n(s){if(!s)return s===0?s:0;if(s=e(s),s===t||s===-t){var a=s<0?-1:1;return a*r}return s===s?s:0}return $i=n,$i}var zi,im;function M1(){if(im)return zi;im=1;var e=sm();function t(r){var n=e(r),s=n%1;return n===n?s?n-s:n:0}return zi=t,zi}var qi,lm;function $1(){if(lm)return qi;lm=1;var e=uh(),t=at(),r=M1(),n=Math.max;function s(a,i,l){var c=a==null?0:a.length;if(!c)return-1;var u=l==null?0:r(l);return u<0&&(u=n(c+u,0)),e(a,t(i,3),u)}return qi=s,qi}var Wi,cm;function z1(){if(cm)return Wi;cm=1;var e=O1(),t=$1(),r=e(t);return Wi=r,Wi}var Fi,dm;function um(){if(dm)return Fi;dm=1;var e=Bs();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return Fi=t,Fi}var Bi,pm;function q1(){if(pm)return Bi;pm=1;var e=Na(),t=Rp(),r=mt();function n(s,a){return s==null?s:e(s,t(a),r)}return Bi=n,Bi}var Hi,fm;function W1(){if(fm)return Hi;fm=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return Hi=e,Hi}var Ui,hm;function F1(){if(hm)return Ui;hm=1;var e=Sr(),t=Ra(),r=at();function n(s,a){var i={};return a=r(a,3),t(s,function(l,c,u){e(i,c,a(l,c,u))}),i}return Ui=n,Ui}var Ji,mm;function Vi(){if(mm)return Ji;mm=1;var e=Ct();function t(r,n,s){for(var a=-1,i=r.length;++a<i;){var l=r[a],c=n(l);if(c!=null&&(u===void 0?c===c&&!e(c):s(c,u)))var u=c,d=l}return d}return Ji=t,Ji}var Ki,gm;function B1(){if(gm)return Ki;gm=1;function e(t,r){return t>r}return Ki=e,Ki}var Gi,ym;function H1(){if(ym)return Gi;ym=1;var e=Vi(),t=B1(),r=gt();function n(s){return s&&s.length?e(s,r,t):void 0}return Gi=n,Gi}var Yi,xm;function bm(){if(xm)return Yi;xm=1;var e=Sr(),t=_t();function r(n,s,a){(a!==void 0&&!t(n[s],a)||a===void 0&&!(s in n))&&e(n,s,a)}return Yi=r,Yi}var Xi,vm;function U1(){if(vm)return Xi;vm=1;var e=ft(),t=Ir(),r=tt(),n="[object Object]",s=Function.prototype,a=Object.prototype,i=s.toString,l=a.hasOwnProperty,c=i.call(Object);function u(d){if(!r(d)||e(d)!=n)return!1;var p=t(d);if(p===null)return!0;var h=l.call(p,"constructor")&&p.constructor;return typeof h=="function"&&h instanceof h&&i.call(h)==c}return Xi=u,Xi}var Zi,km;function Sm(){if(km)return Zi;km=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return Zi=e,Zi}var Qi,wm;function J1(){if(wm)return Qi;wm=1;var e=Wt(),t=mt();function r(n){return e(n,t(n))}return Qi=r,Qi}var el,_m;function V1(){if(_m)return el;_m=1;var e=bm(),t=Ru(),r=dp(),n=Ou(),s=mp(),a=Ft(),i=Pe(),l=kh(),c=Tt(),u=qt(),d=Je(),p=U1(),h=Ut(),f=Sm(),m=J1();function y(v,g,x,b,k,S,C){var T=f(v,x),N=f(g,x),w=C.get(N);if(w){e(v,x,w);return}var _=S?S(T,N,x+"",v,g,C):void 0,j=_===void 0;if(j){var P=i(N),E=!P&&c(N),A=!P&&!E&&h(N);_=N,P||E||A?i(T)?_=T:l(T)?_=n(T):E?(j=!1,_=t(N,!0)):A?(j=!1,_=r(N,!0)):_=[]:p(N)||a(N)?(_=T,a(T)?_=m(T):(!d(T)||u(T))&&(_=s(N))):j=!1}j&&(C.set(N,_),k(_,N,b,S,C),C.delete(N)),e(v,x,_)}return el=y,el}var tl,jm;function K1(){if(jm)return tl;jm=1;var e=kr(),t=bm(),r=Na(),n=V1(),s=Je(),a=mt(),i=Sm();function l(c,u,d,p,h){c!==u&&r(u,function(f,m){if(h||(h=new e),s(f))n(c,u,m,d,l,p,h);else{var y=p?p(i(c,m),f,m+"",c,u,h):void 0;y===void 0&&(y=f),t(c,m,y)}},a)}return tl=l,tl}var rl,Tm;function G1(){if(Tm)return rl;Tm=1;var e=Pr(),t=Or();function r(n){return e(function(s,a){var i=-1,l=a.length,c=l>1?a[l-1]:void 0,u=l>2?a[2]:void 0;for(c=n.length>3&&typeof c=="function"?(l--,c):void 0,u&&t(a[0],a[1],u)&&(c=l<3?void 0:c,l=1),s=Object(s);++i<l;){var d=a[i];d&&n(s,d,i,c)}return s})}return rl=r,rl}var nl,Im;function Y1(){if(Im)return nl;Im=1;var e=K1(),t=G1(),r=t(function(n,s,a){e(n,s,a)});return nl=r,nl}var ol,Cm;function Nm(){if(Cm)return ol;Cm=1;function e(t,r){return t<r}return ol=e,ol}var al,Em;function X1(){if(Em)return al;Em=1;var e=Vi(),t=Nm(),r=gt();function n(s){return s&&s.length?e(s,r,t):void 0}return al=n,al}var sl,Rm;function Z1(){if(Rm)return sl;Rm=1;var e=Vi(),t=at(),r=Nm();function n(s,a){return s&&s.length?e(s,t(a,2),r):void 0}return sl=n,sl}var il,Pm;function Q1(){if(Pm)return il;Pm=1;var e=Ye(),t=function(){return e.Date.now()};return il=t,il}var ll,Om;function ek(){if(Om)return ll;Om=1;var e=wr(),t=Er(),r=_r(),n=Je(),s=Vt();function a(i,l,c,u){if(!n(i))return i;l=t(l,i);for(var d=-1,p=l.length,h=p-1,f=i;f!=null&&++d<p;){var m=s(l[d]),y=c;if(m==="__proto__"||m==="constructor"||m==="prototype")return i;if(d!=h){var v=f[m];y=u?u(v,m,f):void 0,y===void 0&&(y=n(v)?v:r(l[d+1])?[]:{})}e(f,m,y),f=f[m]}return i}return ll=a,ll}var cl,Am;function tk(){if(Am)return cl;Am=1;var e=Rr(),t=ek(),r=Er();function n(s,a,i){for(var l=-1,c=a.length,u={};++l<c;){var d=a[l],p=e(s,d);i(p,d)&&t(u,r(d,s),p)}return u}return cl=n,cl}var dl,Dm;function rk(){if(Dm)return dl;Dm=1;var e=tk(),t=_f();function r(n,s){return e(n,s,function(a,i){return t(n,i)})}return dl=r,dl}var ul,Lm;function nk(){if(Lm)return ul;Lm=1;var e=um(),t=oh(),r=lh();function n(s){return r(t(s,void 0,e),s+"")}return ul=n,ul}var pl,Mm;function ok(){if(Mm)return pl;Mm=1;var e=rk(),t=nk(),r=t(function(n,s){return n==null?{}:e(n,s)});return pl=r,pl}var fl,$m;function ak(){if($m)return fl;$m=1;var e=Math.ceil,t=Math.max;function r(n,s,a,i){for(var l=-1,c=t(e((s-n)/(a||1)),0),u=Array(c);c--;)u[i?c:++l]=n,n+=a;return u}return fl=r,fl}var hl,zm;function sk(){if(zm)return hl;zm=1;var e=ak(),t=Or(),r=sm();function n(s){return function(a,i,l){return l&&typeof l!="number"&&t(a,i,l)&&(i=l=void 0),a=r(a),i===void 0?(i=a,a=0):i=r(i),l=l===void 0?a<i?1:-1:r(l),e(a,i,l,s)}}return hl=n,hl}var ml,qm;function ik(){if(qm)return ml;qm=1;var e=sk(),t=e();return ml=t,ml}var gl,Wm;function lk(){if(Wm)return gl;Wm=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return gl=e,gl}var yl,Fm;function ck(){if(Fm)return yl;Fm=1;var e=Ct();function t(r,n){if(r!==n){var s=r!==void 0,a=r===null,i=r===r,l=e(r),c=n!==void 0,u=n===null,d=n===n,p=e(n);if(!u&&!p&&!l&&r>n||l&&c&&d&&!u&&!p||a&&c&&d||!s&&d||!i)return 1;if(!a&&!l&&!p&&r<n||p&&s&&i&&!a&&!l||u&&s&&i||!c&&i||!d)return-1}return 0}return yl=t,yl}var xl,Bm;function dk(){if(Bm)return xl;Bm=1;var e=ck();function t(r,n,s){for(var a=-1,i=r.criteria,l=n.criteria,c=i.length,u=s.length;++a<c;){var d=e(i[a],l[a]);if(d){if(a>=u)return d;var p=s[a];return d*(p=="desc"?-1:1)}}return r.index-n.index}return xl=t,xl}var bl,Hm;function uk(){if(Hm)return bl;Hm=1;var e=Nr(),t=Rr(),r=at(),n=qf(),s=lk(),a=jr(),i=dk(),l=gt(),c=Pe();function u(d,p,h){p.length?p=e(p,function(y){return c(y)?function(v){return t(v,y.length===1?y[0]:y)}:y}):p=[l];var f=-1;p=e(p,a(r));var m=n(d,function(y,v,g){var x=e(p,function(b){return b(y)});return{criteria:x,index:++f,value:y}});return s(m,function(y,v){return i(y,v,h)})}return bl=u,bl}var vl,Um;function pk(){if(Um)return vl;Um=1;var e=Bs(),t=uk(),r=Pr(),n=Or(),s=r(function(a,i){if(a==null)return[];var l=i.length;return l>1&&n(a,i[0],i[1])?i=[]:l>2&&n(i[0],i[1],i[2])&&(i=[i[0]]),t(a,e(i,1),[])});return vl=s,vl}var kl,Jm;function fk(){if(Jm)return kl;Jm=1;var e=mf(),t=0;function r(n){var s=++t;return e(n)+s}return kl=r,kl}var Sl,Vm;function hk(){if(Vm)return Sl;Vm=1;function e(t,r,n){for(var s=-1,a=t.length,i=r.length,l={};++s<a;){var c=s<i?r[s]:void 0;n(l,t[s],c)}return l}return Sl=e,Sl}var wl,Km;function mk(){if(Km)return wl;Km=1;var e=wr(),t=hk();function r(n,s){return t(n||[],s||[],e)}return wl=r,wl}var _l,Gm;function Ce(){if(Gm)return _l;Gm=1;var e;if(typeof yn=="function")try{e={cloneDeep:R1(),constant:Ta(),defaults:P1(),each:Dp(),filter:Pf(),find:z1(),flatten:um(),forEach:Op(),forIn:q1(),has:Df(),isUndefined:$f(),last:W1(),map:Ff(),mapValues:F1(),max:H1(),merge:Y1(),min:X1(),minBy:Z1(),now:Q1(),pick:ok(),range:ik(),reduce:Jf(),sortBy:pk(),uniqueId:fk(),values:jh(),zipObject:mk()}}catch{}return e||(e=window._),_l=e,_l}var jl,Ym;function gk(){if(Ym)return jl;Ym=1,jl=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,s=n._prev;if(s!==n)return t(s),s},e.prototype.enqueue=function(n){var s=this._sentinel;n._prev&&n._next&&t(n),n._next=s._next,s._next._prev=n,s._next=n,n._prev=s},e.prototype.toString=function(){for(var n=[],s=this._sentinel,a=s._prev;a!==s;)n.push(JSON.stringify(a,r)),a=a._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,s){if(n!=="_next"&&n!=="_prev")return s}return jl}var Tl,Xm;function yk(){if(Xm)return Tl;Xm=1;var e=Ce(),t=Xe().Graph,r=gk();Tl=s;var n=e.constant(1);function s(u,d){if(u.nodeCount()<=1)return[];var p=l(u,d||n),h=a(p.graph,p.buckets,p.zeroIdx);return e.flatten(e.map(h,function(f){return u.outEdges(f.v,f.w)}),!0)}function a(u,d,p){for(var h=[],f=d[d.length-1],m=d[0],y;u.nodeCount();){for(;y=m.dequeue();)i(u,d,p,y);for(;y=f.dequeue();)i(u,d,p,y);if(u.nodeCount()){for(var v=d.length-2;v>0;--v)if(y=d[v].dequeue(),y){h=h.concat(i(u,d,p,y,!0));break}}}return h}function i(u,d,p,h,f){var m=f?[]:void 0;return e.forEach(u.inEdges(h.v),function(y){var v=u.edge(y),g=u.node(y.v);f&&m.push({v:y.v,w:y.w}),g.out-=v,c(d,p,g)}),e.forEach(u.outEdges(h.v),function(y){var v=u.edge(y),g=y.w,x=u.node(g);x.in-=v,c(d,p,x)}),u.removeNode(h.v),m}function l(u,d){var p=new t,h=0,f=0;e.forEach(u.nodes(),function(v){p.setNode(v,{v,in:0,out:0})}),e.forEach(u.edges(),function(v){var g=p.edge(v.v,v.w)||0,x=d(v),b=g+x;p.setEdge(v.v,v.w,b),f=Math.max(f,p.node(v.v).out+=x),h=Math.max(h,p.node(v.w).in+=x)});var m=e.range(f+h+3).map(function(){return new r}),y=h+1;return e.forEach(p.nodes(),function(v){c(m,y,p.node(v))}),{graph:p,buckets:m,zeroIdx:y}}function c(u,d,p){p.out?p.in?u[p.out-p.in+d].enqueue(p):u[u.length-1].enqueue(p):u[0].enqueue(p)}return Tl}var Il,Zm;function xk(){if(Zm)return Il;Zm=1;var e=Ce(),t=yk();Il={run:r,undo:s};function r(a){var i=a.graph().acyclicer==="greedy"?t(a,l(a)):n(a);e.forEach(i,function(c){var u=a.edge(c);a.removeEdge(c),u.forwardName=c.name,u.reversed=!0,a.setEdge(c.w,c.v,u,e.uniqueId("rev"))});function l(c){return function(u){return c.edge(u).weight}}}function n(a){var i=[],l={},c={};function u(d){e.has(c,d)||(c[d]=!0,l[d]=!0,e.forEach(a.outEdges(d),function(p){e.has(l,p.w)?i.push(p):u(p.w)}),delete l[d])}return e.forEach(a.nodes(),u),i}function s(a){e.forEach(a.edges(),function(i){var l=a.edge(i);if(l.reversed){a.removeEdge(i);var c=l.forwardName;delete l.reversed,delete l.forwardName,a.setEdge(i.w,i.v,l,c)}})}return Il}var Cl,Qm;function We(){if(Qm)return Cl;Qm=1;var e=Ce(),t=Xe().Graph;Cl={addDummyNode:r,simplify:n,asNonCompoundGraph:s,successorWeights:a,predecessorWeights:i,intersectRect:l,buildLayerMatrix:c,normalizeRanks:u,removeEmptyRanks:d,addBorderNode:p,maxRank:h,partition:f,time:m,notime:y};function r(v,g,x,b){var k;do k=e.uniqueId(b);while(v.hasNode(k));return x.dummy=g,v.setNode(k,x),k}function n(v){var g=new t().setGraph(v.graph());return e.forEach(v.nodes(),function(x){g.setNode(x,v.node(x))}),e.forEach(v.edges(),function(x){var b=g.edge(x.v,x.w)||{weight:0,minlen:1},k=v.edge(x);g.setEdge(x.v,x.w,{weight:b.weight+k.weight,minlen:Math.max(b.minlen,k.minlen)})}),g}function s(v){var g=new t({multigraph:v.isMultigraph()}).setGraph(v.graph());return e.forEach(v.nodes(),function(x){v.children(x).length||g.setNode(x,v.node(x))}),e.forEach(v.edges(),function(x){g.setEdge(x,v.edge(x))}),g}function a(v){var g=e.map(v.nodes(),function(x){var b={};return e.forEach(v.outEdges(x),function(k){b[k.w]=(b[k.w]||0)+v.edge(k).weight}),b});return e.zipObject(v.nodes(),g)}function i(v){var g=e.map(v.nodes(),function(x){var b={};return e.forEach(v.inEdges(x),function(k){b[k.v]=(b[k.v]||0)+v.edge(k).weight}),b});return e.zipObject(v.nodes(),g)}function l(v,g){var x=v.x,b=v.y,k=g.x-x,S=g.y-b,C=v.width/2,T=v.height/2;if(!k&&!S)throw new Error("Not possible to find intersection inside of the rectangle");var N,w;return Math.abs(S)*C>Math.abs(k)*T?(S<0&&(T=-T),N=T*k/S,w=T):(k<0&&(C=-C),N=C,w=C*S/k),{x:x+N,y:b+w}}function c(v){var g=e.map(e.range(h(v)+1),function(){return[]});return e.forEach(v.nodes(),function(x){var b=v.node(x),k=b.rank;e.isUndefined(k)||(g[k][b.order]=x)}),g}function u(v){var g=e.min(e.map(v.nodes(),function(x){return v.node(x).rank}));e.forEach(v.nodes(),function(x){var b=v.node(x);e.has(b,"rank")&&(b.rank-=g)})}function d(v){var g=e.min(e.map(v.nodes(),function(S){return v.node(S).rank})),x=[];e.forEach(v.nodes(),function(S){var C=v.node(S).rank-g;x[C]||(x[C]=[]),x[C].push(S)});var b=0,k=v.graph().nodeRankFactor;e.forEach(x,function(S,C){e.isUndefined(S)&&C%k!==0?--b:b&&e.forEach(S,function(T){v.node(T).rank+=b})})}function p(v,g,x,b){var k={width:0,height:0};return arguments.length>=4&&(k.rank=x,k.order=b),r(v,"border",k,g)}function h(v){return e.max(e.map(v.nodes(),function(g){var x=v.node(g).rank;if(!e.isUndefined(x))return x}))}function f(v,g){var x={lhs:[],rhs:[]};return e.forEach(v,function(b){g(b)?x.lhs.push(b):x.rhs.push(b)}),x}function m(v,g){var x=e.now();try{return g()}finally{console.log(v+" time: "+(e.now()-x)+"ms")}}function y(v,g){return g()}return Cl}var Nl,eg;function bk(){if(eg)return Nl;eg=1;var e=Ce(),t=We();Nl={run:r,undo:s};function r(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(i){n(a,i)})}function n(a,i){var l=i.v,c=a.node(l).rank,u=i.w,d=a.node(u).rank,p=i.name,h=a.edge(i),f=h.labelRank;if(d!==c+1){a.removeEdge(i);var m,y,v;for(v=0,++c;c<d;++v,++c)h.points=[],y={width:0,height:0,edgeLabel:h,edgeObj:i,rank:c},m=t.addDummyNode(a,"edge",y,"_d"),c===f&&(y.width=h.width,y.height=h.height,y.dummy="edge-label",y.labelpos=h.labelpos),a.setEdge(l,m,{weight:h.weight},p),v===0&&a.graph().dummyChains.push(m),l=m;a.setEdge(l,u,{weight:h.weight},p)}}function s(a){e.forEach(a.graph().dummyChains,function(i){var l=a.node(i),c=l.edgeLabel,u;for(a.setEdge(l.edgeObj,c);l.dummy;)u=a.successors(i)[0],a.removeNode(i),c.points.push({x:l.x,y:l.y}),l.dummy==="edge-label"&&(c.x=l.x,c.y=l.y,c.width=l.width,c.height=l.height),i=u,l=a.node(i)})}return Nl}var El,tg;function Ar(){if(tg)return El;tg=1;var e=Ce();El={longestPath:t,slack:r};function t(n){var s={};function a(i){var l=n.node(i);if(e.has(s,i))return l.rank;s[i]=!0;var c=e.min(e.map(n.outEdges(i),function(u){return a(u.w)-n.edge(u).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),l.rank=c}e.forEach(n.sources(),a)}function r(n,s){return n.node(s.w).rank-n.node(s.v).rank-n.edge(s).minlen}return El}var Rl,rg;function ng(){if(rg)return Rl;rg=1;var e=Ce(),t=Xe().Graph,r=Ar().slack;Rl=n;function n(l){var c=new t({directed:!1}),u=l.nodes()[0],d=l.nodeCount();c.setNode(u,{});for(var p,h;s(c,l)<d;)p=a(c,l),h=c.hasNode(p.v)?r(l,p):-r(l,p),i(c,l,h);return c}function s(l,c){function u(d){e.forEach(c.nodeEdges(d),function(p){var h=p.v,f=d===h?p.w:h;!l.hasNode(f)&&!r(c,p)&&(l.setNode(f,{}),l.setEdge(d,f,{}),u(f))})}return e.forEach(l.nodes(),u),l.nodeCount()}function a(l,c){return e.minBy(c.edges(),function(u){if(l.hasNode(u.v)!==l.hasNode(u.w))return r(c,u)})}function i(l,c,u){e.forEach(l.nodes(),function(d){c.node(d).rank+=u})}return Rl}var Pl,og;function vk(){if(og)return Pl;og=1;var e=Ce(),t=ng(),r=Ar().slack,n=Ar().longestPath,s=Xe().alg.preorder,a=Xe().alg.postorder,i=We().simplify;Pl=l,l.initLowLimValues=p,l.initCutValues=c,l.calcCutValue=d,l.leaveEdge=f,l.enterEdge=m,l.exchangeEdges=y;function l(b){b=i(b),n(b);var k=t(b);p(k),c(k,b);for(var S,C;S=f(k);)C=m(k,b,S),y(k,b,S,C)}function c(b,k){var S=a(b,b.nodes());S=S.slice(0,S.length-1),e.forEach(S,function(C){u(b,k,C)})}function u(b,k,S){var C=b.node(S),T=C.parent;b.edge(S,T).cutvalue=d(b,k,S)}function d(b,k,S){var C=b.node(S),T=C.parent,N=!0,w=k.edge(S,T),_=0;return w||(N=!1,w=k.edge(T,S)),_=w.weight,e.forEach(k.nodeEdges(S),function(j){var P=j.v===S,E=P?j.w:j.v;if(E!==T){var A=P===N,L=k.edge(j).weight;if(_+=A?L:-L,g(b,S,E)){var B=b.edge(S,E).cutvalue;_+=A?-B:B}}}),_}function p(b,k){arguments.length<2&&(k=b.nodes()[0]),h(b,{},1,k)}function h(b,k,S,C,T){var N=S,w=b.node(C);return k[C]=!0,e.forEach(b.neighbors(C),function(_){e.has(k,_)||(S=h(b,k,S,_,C))}),w.low=N,w.lim=S++,T?w.parent=T:delete w.parent,S}function f(b){return e.find(b.edges(),function(k){return b.edge(k).cutvalue<0})}function m(b,k,S){var C=S.v,T=S.w;k.hasEdge(C,T)||(C=S.w,T=S.v);var N=b.node(C),w=b.node(T),_=N,j=!1;N.lim>w.lim&&(_=w,j=!0);var P=e.filter(k.edges(),function(E){return j===x(b,b.node(E.v),_)&&j!==x(b,b.node(E.w),_)});return e.minBy(P,function(E){return r(k,E)})}function y(b,k,S,C){var T=S.v,N=S.w;b.removeEdge(T,N),b.setEdge(C.v,C.w,{}),p(b),c(b,k),v(b,k)}function v(b,k){var S=e.find(b.nodes(),function(T){return!k.node(T).parent}),C=s(b,S);C=C.slice(1),e.forEach(C,function(T){var N=b.node(T).parent,w=k.edge(T,N),_=!1;w||(w=k.edge(N,T),_=!0),k.node(T).rank=k.node(N).rank+(_?w.minlen:-w.minlen)})}function g(b,k,S){return b.hasEdge(k,S)}function x(b,k,S){return S.low<=k.lim&&k.lim<=S.lim}return Pl}var Ol,ag;function kk(){if(ag)return Ol;ag=1;var e=Ar(),t=e.longestPath,r=ng(),n=vk();Ol=s;function s(c){switch(c.graph().ranker){case"network-simplex":l(c);break;case"tight-tree":i(c);break;case"longest-path":a(c);break;default:l(c)}}var a=t;function i(c){t(c),r(c)}function l(c){n(c)}return Ol}var Al,sg;function Sk(){if(sg)return Al;sg=1;var e=Ce();Al=t;function t(s){var a=n(s);e.forEach(s.graph().dummyChains,function(i){for(var l=s.node(i),c=l.edgeObj,u=r(s,a,c.v,c.w),d=u.path,p=u.lca,h=0,f=d[h],m=!0;i!==c.w;){if(l=s.node(i),m){for(;(f=d[h])!==p&&s.node(f).maxRank<l.rank;)h++;f===p&&(m=!1)}if(!m){for(;h<d.length-1&&s.node(f=d[h+1]).minRank<=l.rank;)h++;f=d[h]}s.setParent(i,f),i=s.successors(i)[0]}})}function r(s,a,i,l){var c=[],u=[],d=Math.min(a[i].low,a[l].low),p=Math.max(a[i].lim,a[l].lim),h,f;h=i;do h=s.parent(h),c.push(h);while(h&&(a[h].low>d||p>a[h].lim));for(f=h,h=l;(h=s.parent(h))!==f;)u.push(h);return{path:c.concat(u.reverse()),lca:f}}function n(s){var a={},i=0;function l(c){var u=i;e.forEach(s.children(c),l),a[c]={low:u,lim:i++}}return e.forEach(s.children(),l),a}return Al}var Dl,ig;function wk(){if(ig)return Dl;ig=1;var e=Ce(),t=We();Dl={run:r,cleanup:i};function r(l){var c=t.addDummyNode(l,"root",{},"_root"),u=s(l),d=e.max(e.values(u))-1,p=2*d+1;l.graph().nestingRoot=c,e.forEach(l.edges(),function(f){l.edge(f).minlen*=p});var h=a(l)+1;e.forEach(l.children(),function(f){n(l,c,p,h,d,u,f)}),l.graph().nodeRankFactor=p}function n(l,c,u,d,p,h,f){var m=l.children(f);if(!m.length){f!==c&&l.setEdge(c,f,{weight:0,minlen:u});return}var y=t.addBorderNode(l,"_bt"),v=t.addBorderNode(l,"_bb"),g=l.node(f);l.setParent(y,f),g.borderTop=y,l.setParent(v,f),g.borderBottom=v,e.forEach(m,function(x){n(l,c,u,d,p,h,x);var b=l.node(x),k=b.borderTop?b.borderTop:x,S=b.borderBottom?b.borderBottom:x,C=b.borderTop?d:2*d,T=k!==S?1:p-h[f]+1;l.setEdge(y,k,{weight:C,minlen:T,nestingEdge:!0}),l.setEdge(S,v,{weight:C,minlen:T,nestingEdge:!0})}),l.parent(f)||l.setEdge(c,y,{weight:0,minlen:p+h[f]})}function s(l){var c={};function u(d,p){var h=l.children(d);h&&h.length&&e.forEach(h,function(f){u(f,p+1)}),c[d]=p}return e.forEach(l.children(),function(d){u(d,1)}),c}function a(l){return e.reduce(l.edges(),function(c,u){return c+l.edge(u).weight},0)}function i(l){var c=l.graph();l.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(l.edges(),function(u){var d=l.edge(u);d.nestingEdge&&l.removeEdge(u)})}return Dl}var Ll,lg;function _k(){if(lg)return Ll;lg=1;var e=Ce(),t=We();Ll=r;function r(s){function a(i){var l=s.children(i),c=s.node(i);if(l.length&&e.forEach(l,a),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var u=c.minRank,d=c.maxRank+1;u<d;++u)n(s,"borderLeft","_bl",i,c,u),n(s,"borderRight","_br",i,c,u)}}e.forEach(s.children(),a)}function n(s,a,i,l,c,u){var d={width:0,height:0,rank:u,borderType:a},p=c[a][u-1],h=t.addDummyNode(s,"border",d,i);c[a][u]=h,s.setParent(h,l),p&&s.setEdge(p,h,{weight:1})}return Ll}var Ml,cg;function jk(){if(cg)return Ml;cg=1;var e=Ce();Ml={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")&&a(u),(d==="lr"||d==="rl")&&(l(u),n(u))}function n(u){e.forEach(u.nodes(),function(d){s(u.node(d))}),e.forEach(u.edges(),function(d){s(u.edge(d))})}function s(u){var d=u.width;u.width=u.height,u.height=d}function a(u){e.forEach(u.nodes(),function(d){i(u.node(d))}),e.forEach(u.edges(),function(d){var p=u.edge(d);e.forEach(p.points,i),e.has(p,"y")&&i(p)})}function i(u){u.y=-u.y}function l(u){e.forEach(u.nodes(),function(d){c(u.node(d))}),e.forEach(u.edges(),function(d){var p=u.edge(d);e.forEach(p.points,c),e.has(p,"x")&&c(p)})}function c(u){var d=u.x;u.x=u.y,u.y=d}return Ml}var $l,dg;function Tk(){if(dg)return $l;dg=1;var e=Ce();$l=t;function t(r){var n={},s=e.filter(r.nodes(),function(u){return!r.children(u).length}),a=e.max(e.map(s,function(u){return r.node(u).rank})),i=e.map(e.range(a+1),function(){return[]});function l(u){if(!e.has(n,u)){n[u]=!0;var d=r.node(u);i[d.rank].push(u),e.forEach(r.successors(u),l)}}var c=e.sortBy(s,function(u){return r.node(u).rank});return e.forEach(c,l),i}return $l}var zl,ug;function Ik(){if(ug)return zl;ug=1;var e=Ce();zl=t;function t(n,s){for(var a=0,i=1;i<s.length;++i)a+=r(n,s[i-1],s[i]);return a}function r(n,s,a){for(var i=e.zipObject(a,e.map(a,function(h,f){return f})),l=e.flatten(e.map(s,function(h){return e.sortBy(e.map(n.outEdges(h),function(f){return{pos:i[f.w],weight:n.edge(f).weight}}),"pos")}),!0),c=1;c<a.length;)c<<=1;var u=2*c-1;c-=1;var d=e.map(new Array(u),function(){return 0}),p=0;return e.forEach(l.forEach(function(h){var f=h.pos+c;d[f]+=h.weight;for(var m=0;f>0;)f%2&&(m+=d[f+1]),f=f-1>>1,d[f]+=h.weight;p+=h.weight*m})),p}return zl}var ql,pg;function Ck(){if(pg)return ql;pg=1;var e=Ce();ql=t;function t(r,n){return e.map(n,function(s){var a=r.inEdges(s);if(a.length){var i=e.reduce(a,function(l,c){var u=r.edge(c),d=r.node(c.v);return{sum:l.sum+u.weight*d.order,weight:l.weight+u.weight}},{sum:0,weight:0});return{v:s,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:s}})}return ql}var Wl,fg;function Nk(){if(fg)return Wl;fg=1;var e=Ce();Wl=t;function t(s,a){var i={};e.forEach(s,function(c,u){var d=i[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(a.edges(),function(c){var u=i[c.v],d=i[c.w];!e.isUndefined(u)&&!e.isUndefined(d)&&(d.indegree++,u.out.push(i[c.w]))});var l=e.filter(i,function(c){return!c.indegree});return r(l)}function r(s){var a=[];function i(u){return function(d){d.merged||(e.isUndefined(d.barycenter)||e.isUndefined(u.barycenter)||d.barycenter>=u.barycenter)&&n(u,d)}}function l(u){return function(d){d.in.push(u),--d.indegree===0&&s.push(d)}}for(;s.length;){var c=s.pop();a.push(c),e.forEach(c.in.reverse(),i(c)),e.forEach(c.out,l(c))}return e.map(e.filter(a,function(u){return!u.merged}),function(u){return e.pick(u,["vs","i","barycenter","weight"])})}function n(s,a){var i=0,l=0;s.weight&&(i+=s.barycenter*s.weight,l+=s.weight),a.weight&&(i+=a.barycenter*a.weight,l+=a.weight),s.vs=a.vs.concat(s.vs),s.barycenter=i/l,s.weight=l,s.i=Math.min(a.i,s.i),a.merged=!0}return Wl}var Fl,hg;function Ek(){if(hg)return Fl;hg=1;var e=Ce(),t=We();Fl=r;function r(a,i){var l=t.partition(a,function(y){return e.has(y,"barycenter")}),c=l.lhs,u=e.sortBy(l.rhs,function(y){return-y.i}),d=[],p=0,h=0,f=0;c.sort(s(!!i)),f=n(d,u,f),e.forEach(c,function(y){f+=y.vs.length,d.push(y.vs),p+=y.barycenter*y.weight,h+=y.weight,f=n(d,u,f)});var m={vs:e.flatten(d,!0)};return h&&(m.barycenter=p/h,m.weight=h),m}function n(a,i,l){for(var c;i.length&&(c=e.last(i)).i<=l;)i.pop(),a.push(c.vs),l++;return l}function s(a){return function(i,l){return i.barycenter<l.barycenter?-1:i.barycenter>l.barycenter?1:a?l.i-i.i:i.i-l.i}}return Fl}var Bl,mg;function Rk(){if(mg)return Bl;mg=1;var e=Ce(),t=Ck(),r=Nk(),n=Ek();Bl=s;function s(l,c,u,d){var p=l.children(c),h=l.node(c),f=h?h.borderLeft:void 0,m=h?h.borderRight:void 0,y={};f&&(p=e.filter(p,function(S){return S!==f&&S!==m}));var v=t(l,p);e.forEach(v,function(S){if(l.children(S.v).length){var C=s(l,S.v,u,d);y[S.v]=C,e.has(C,"barycenter")&&i(S,C)}});var g=r(v,u);a(g,y);var x=n(g,d);if(f&&(x.vs=e.flatten([f,x.vs,m],!0),l.predecessors(f).length)){var b=l.node(l.predecessors(f)[0]),k=l.node(l.predecessors(m)[0]);e.has(x,"barycenter")||(x.barycenter=0,x.weight=0),x.barycenter=(x.barycenter*x.weight+b.order+k.order)/(x.weight+2),x.weight+=2}return x}function a(l,c){e.forEach(l,function(u){u.vs=e.flatten(u.vs.map(function(d){return c[d]?c[d].vs:d}),!0)})}function i(l,c){e.isUndefined(l.barycenter)?(l.barycenter=c.barycenter,l.weight=c.weight):(l.barycenter=(l.barycenter*l.weight+c.barycenter*c.weight)/(l.weight+c.weight),l.weight+=c.weight)}return Bl}var Hl,gg;function Pk(){if(gg)return Hl;gg=1;var e=Ce(),t=Xe().Graph;Hl=r;function r(s,a,i){var l=n(s),c=new t({compound:!0}).setGraph({root:l}).setDefaultNodeLabel(function(u){return s.node(u)});return e.forEach(s.nodes(),function(u){var d=s.node(u),p=s.parent(u);(d.rank===a||d.minRank<=a&&a<=d.maxRank)&&(c.setNode(u),c.setParent(u,p||l),e.forEach(s[i](u),function(h){var f=h.v===u?h.w:h.v,m=c.edge(f,u),y=e.isUndefined(m)?0:m.weight;c.setEdge(f,u,{weight:s.edge(h).weight+y})}),e.has(d,"minRank")&&c.setNode(u,{borderLeft:d.borderLeft[a],borderRight:d.borderRight[a]}))}),c}function n(s){for(var a;s.hasNode(a=e.uniqueId("_root")););return a}return Hl}var Ul,yg;function Ok(){if(yg)return Ul;yg=1;var e=Ce();Ul=t;function t(r,n,s){var a={},i;e.forEach(s,function(l){for(var c=r.parent(l),u,d;c;){if(u=r.parent(c),u?(d=a[u],a[u]=c):(d=i,i=c),d&&d!==c){n.setEdge(d,c);return}c=u}})}return Ul}var Jl,xg;function Ak(){if(xg)return Jl;xg=1;var e=Ce(),t=Tk(),r=Ik(),n=Rk(),s=Pk(),a=Ok(),i=Xe().Graph,l=We();Jl=c;function c(h){var f=l.maxRank(h),m=u(h,e.range(1,f+1),"inEdges"),y=u(h,e.range(f-1,-1,-1),"outEdges"),v=t(h);p(h,v);for(var g=Number.POSITIVE_INFINITY,x,b=0,k=0;k<4;++b,++k){d(b%2?m:y,b%4>=2),v=l.buildLayerMatrix(h);var S=r(h,v);S<g&&(k=0,x=e.cloneDeep(v),g=S)}p(h,x)}function u(h,f,m){return e.map(f,function(y){return s(h,y,m)})}function d(h,f){var m=new i;e.forEach(h,function(y){var v=y.graph().root,g=n(y,v,m,f);e.forEach(g.vs,function(x,b){y.node(x).order=b}),a(y,m,g.vs)})}function p(h,f){e.forEach(f,function(m){e.forEach(m,function(y,v){h.node(y).order=v})})}return Jl}var Vl,bg;function Dk(){if(bg)return Vl;bg=1;var e=Ce(),t=Xe().Graph,r=We();Vl={positionX:m,findType1Conflicts:n,findType2Conflicts:s,addConflict:i,hasConflict:l,verticalAlignment:c,horizontalCompaction:u,alignCoordinates:h,findSmallestWidthAlignment:p,balance:f};function n(g,x){var b={};function k(S,C){var T=0,N=0,w=S.length,_=e.last(C);return e.forEach(C,function(j,P){var E=a(g,j),A=E?g.node(E).order:w;(E||j===_)&&(e.forEach(C.slice(N,P+1),function(L){e.forEach(g.predecessors(L),function(B){var z=g.node(B),R=z.order;(R<T||A<R)&&!(z.dummy&&g.node(L).dummy)&&i(b,B,L)})}),N=P+1,T=A)}),C}return e.reduce(x,k),b}function s(g,x){var b={};function k(C,T,N,w,_){var j;e.forEach(e.range(T,N),function(P){j=C[P],g.node(j).dummy&&e.forEach(g.predecessors(j),function(E){var A=g.node(E);A.dummy&&(A.order<w||A.order>_)&&i(b,E,j)})})}function S(C,T){var N=-1,w,_=0;return e.forEach(T,function(j,P){if(g.node(j).dummy==="border"){var E=g.predecessors(j);E.length&&(w=g.node(E[0]).order,k(T,_,P,N,w),_=P,N=w)}k(T,_,T.length,w,C.length)}),T}return e.reduce(x,S),b}function a(g,x){if(g.node(x).dummy)return e.find(g.predecessors(x),function(b){return g.node(b).dummy})}function i(g,x,b){if(x>b){var k=x;x=b,b=k}var S=g[x];S||(g[x]=S={}),S[b]=!0}function l(g,x,b){if(x>b){var k=x;x=b,b=k}return e.has(g[x],b)}function c(g,x,b,k){var S={},C={},T={};return e.forEach(x,function(N){e.forEach(N,function(w,_){S[w]=w,C[w]=w,T[w]=_})}),e.forEach(x,function(N){var w=-1;e.forEach(N,function(_){var j=k(_);if(j.length){j=e.sortBy(j,function(B){return T[B]});for(var P=(j.length-1)/2,E=Math.floor(P),A=Math.ceil(P);E<=A;++E){var L=j[E];C[_]===_&&w<T[L]&&!l(b,_,L)&&(C[L]=_,C[_]=S[_]=S[L],w=T[L])}}})}),{root:S,align:C}}function u(g,x,b,k,S){var C={},T=d(g,x,b,S),N=S?"borderLeft":"borderRight";function w(P,E){for(var A=T.nodes(),L=A.pop(),B={};L;)B[L]?P(L):(B[L]=!0,A.push(L),A=A.concat(E(L))),L=A.pop()}function _(P){C[P]=T.inEdges(P).reduce(function(E,A){return Math.max(E,C[A.v]+T.edge(A))},0)}function j(P){var E=T.outEdges(P).reduce(function(L,B){return Math.min(L,C[B.w]-T.edge(B))},Number.POSITIVE_INFINITY),A=g.node(P);E!==Number.POSITIVE_INFINITY&&A.borderType!==N&&(C[P]=Math.max(C[P],E))}return w(_,T.predecessors.bind(T)),w(j,T.successors.bind(T)),e.forEach(k,function(P){C[P]=C[b[P]]}),C}function d(g,x,b,k){var S=new t,C=g.graph(),T=y(C.nodesep,C.edgesep,k);return e.forEach(x,function(N){var w;e.forEach(N,function(_){var j=b[_];if(S.setNode(j),w){var P=b[w],E=S.edge(P,j);S.setEdge(P,j,Math.max(T(g,_,w),E||0))}w=_})}),S}function p(g,x){return e.minBy(e.values(x),function(b){var k=Number.NEGATIVE_INFINITY,S=Number.POSITIVE_INFINITY;return e.forIn(b,function(C,T){var N=v(g,T)/2;k=Math.max(C+N,k),S=Math.min(C-N,S)}),k-S})}function h(g,x){var b=e.values(x),k=e.min(b),S=e.max(b);e.forEach(["u","d"],function(C){e.forEach(["l","r"],function(T){var N=C+T,w=g[N],_;if(w!==x){var j=e.values(w);_=T==="l"?k-e.min(j):S-e.max(j),_&&(g[N]=e.mapValues(w,function(P){return P+_}))}})})}function f(g,x){return e.mapValues(g.ul,function(b,k){if(x)return g[x.toLowerCase()][k];var S=e.sortBy(e.map(g,k));return(S[1]+S[2])/2})}function m(g){var x=r.buildLayerMatrix(g),b=e.merge(n(g,x),s(g,x)),k={},S;e.forEach(["u","d"],function(T){S=T==="u"?x:e.values(x).reverse(),e.forEach(["l","r"],function(N){N==="r"&&(S=e.map(S,function(P){return e.values(P).reverse()}));var w=(T==="u"?g.predecessors:g.successors).bind(g),_=c(g,S,b,w),j=u(g,S,_.root,_.align,N==="r");N==="r"&&(j=e.mapValues(j,function(P){return-P})),k[T+N]=j})});var C=p(g,k);return h(k,C),f(k,g.graph().align)}function y(g,x,b){return function(k,S,C){var T=k.node(S),N=k.node(C),w=0,_;if(w+=T.width/2,e.has(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":_=-T.width/2;break;case"r":_=T.width/2;break}if(_&&(w+=b?_:-_),_=0,w+=(T.dummy?x:g)/2,w+=(N.dummy?x:g)/2,w+=N.width/2,e.has(N,"labelpos"))switch(N.labelpos.toLowerCase()){case"l":_=N.width/2;break;case"r":_=-N.width/2;break}return _&&(w+=b?_:-_),_=0,w}}function v(g,x){return g.node(x).width}return Vl}var Kl,vg;function Lk(){if(vg)return Kl;vg=1;var e=Ce(),t=We(),r=Dk().positionX;Kl=n;function n(a){a=t.asNonCompoundGraph(a),s(a),e.forEach(r(a),function(i,l){a.node(l).x=i})}function s(a){var i=t.buildLayerMatrix(a),l=a.graph().ranksep,c=0;e.forEach(i,function(u){var d=e.max(e.map(u,function(p){return a.node(p).height}));e.forEach(u,function(p){a.node(p).y=c+d/2}),c+=d+l})}return Kl}var Gl,kg;function Mk(){if(kg)return Gl;kg=1;var e=Ce(),t=xk(),r=bk(),n=kk(),s=We().normalizeRanks,a=Sk(),i=We().removeEmptyRanks,l=wk(),c=_k(),u=jk(),d=Ak(),p=Lk(),h=We(),f=Xe().Graph;Gl=m;function m($,H){var K=H&&H.debugTiming?h.time:h.notime;K("layout",function(){var V=K(" buildLayoutGraph",function(){return w($)});K(" runLayout",function(){y(V,K)}),K(" updateInputGraph",function(){v($,V)})})}function y($,H){H(" makeSpaceForEdgeLabels",function(){_($)}),H(" removeSelfEdges",function(){q($)}),H(" acyclic",function(){t.run($)}),H(" nestingGraph.run",function(){l.run($)}),H(" rank",function(){n(h.asNonCompoundGraph($))}),H(" injectEdgeLabelProxies",function(){j($)}),H(" removeEmptyRanks",function(){i($)}),H(" nestingGraph.cleanup",function(){l.cleanup($)}),H(" normalizeRanks",function(){s($)}),H(" assignRankMinMax",function(){P($)}),H(" removeEdgeLabelProxies",function(){E($)}),H(" normalize.run",function(){r.run($)}),H(" parentDummyChains",function(){a($)}),H(" addBorderSegments",function(){c($)}),H(" order",function(){d($)}),H(" insertSelfEdges",function(){M($)}),H(" adjustCoordinateSystem",function(){u.adjust($)}),H(" position",function(){p($)}),H(" positionSelfEdges",function(){O($)}),H(" removeBorderNodes",function(){R($)}),H(" normalize.undo",function(){r.undo($)}),H(" fixupEdgeLabelCoords",function(){B($)}),H(" undoCoordinateSystem",function(){u.undo($)}),H(" translateGraph",function(){A($)}),H(" assignNodeIntersects",function(){L($)}),H(" reversePoints",function(){z($)}),H(" acyclic.undo",function(){t.undo($)})}function v($,H){e.forEach($.nodes(),function(K){var V=$.node(K),te=H.node(K);V&&(V.x=te.x,V.y=te.y,H.children(K).length&&(V.width=te.width,V.height=te.height))}),e.forEach($.edges(),function(K){var V=$.edge(K),te=H.edge(K);V.points=te.points,e.has(te,"x")&&(V.x=te.x,V.y=te.y)}),$.graph().width=H.graph().width,$.graph().height=H.graph().height}var g=["nodesep","edgesep","ranksep","marginx","marginy"],x={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},b=["acyclicer","ranker","rankdir","align"],k=["width","height"],S={width:0,height:0},C=["minlen","weight","width","height","labeloffset"],T={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},N=["labelpos"];function w($){var H=new f({multigraph:!0,compound:!0}),K=U($.graph());return H.setGraph(e.merge({},x,W(K,g),e.pick(K,b))),e.forEach($.nodes(),function(V){var te=U($.node(V));H.setNode(V,e.defaults(W(te,k),S)),H.setParent(V,$.parent(V))}),e.forEach($.edges(),function(V){var te=U($.edge(V));H.setEdge(V,e.merge({},T,W(te,C),e.pick(te,N)))}),H}function _($){var H=$.graph();H.ranksep/=2,e.forEach($.edges(),function(K){var V=$.edge(K);V.minlen*=2,V.labelpos.toLowerCase()!=="c"&&(H.rankdir==="TB"||H.rankdir==="BT"?V.width+=V.labeloffset:V.height+=V.labeloffset)})}function j($){e.forEach($.edges(),function(H){var K=$.edge(H);if(K.width&&K.height){var V=$.node(H.v),te=$.node(H.w),ue={rank:(te.rank-V.rank)/2+V.rank,e:H};h.addDummyNode($,"edge-proxy",ue,"_ep")}})}function P($){var H=0;e.forEach($.nodes(),function(K){var V=$.node(K);V.borderTop&&(V.minRank=$.node(V.borderTop).rank,V.maxRank=$.node(V.borderBottom).rank,H=e.max(H,V.maxRank))}),$.graph().maxRank=H}function E($){e.forEach($.nodes(),function(H){var K=$.node(H);K.dummy==="edge-proxy"&&($.edge(K.e).labelRank=K.rank,$.removeNode(H))})}function A($){var H=Number.POSITIVE_INFINITY,K=0,V=Number.POSITIVE_INFINITY,te=0,ue=$.graph(),ye=ue.marginx||0,_e=ue.marginy||0;function Ne(J){var Se=J.x,ne=J.y,xe=J.width,ie=J.height;H=Math.min(H,Se-xe/2),K=Math.max(K,Se+xe/2),V=Math.min(V,ne-ie/2),te=Math.max(te,ne+ie/2)}e.forEach($.nodes(),function(J){Ne($.node(J))}),e.forEach($.edges(),function(J){var Se=$.edge(J);e.has(Se,"x")&&Ne(Se)}),H-=ye,V-=_e,e.forEach($.nodes(),function(J){var Se=$.node(J);Se.x-=H,Se.y-=V}),e.forEach($.edges(),function(J){var Se=$.edge(J);e.forEach(Se.points,function(ne){ne.x-=H,ne.y-=V}),e.has(Se,"x")&&(Se.x-=H),e.has(Se,"y")&&(Se.y-=V)}),ue.width=K-H+ye,ue.height=te-V+_e}function L($){e.forEach($.edges(),function(H){var K=$.edge(H),V=$.node(H.v),te=$.node(H.w),ue,ye;K.points?(ue=K.points[0],ye=K.points[K.points.length-1]):(K.points=[],ue=te,ye=V),K.points.unshift(h.intersectRect(V,ue)),K.points.push(h.intersectRect(te,ye))})}function B($){e.forEach($.edges(),function(H){var K=$.edge(H);if(e.has(K,"x"))switch((K.labelpos==="l"||K.labelpos==="r")&&(K.width-=K.labeloffset),K.labelpos){case"l":K.x-=K.width/2+K.labeloffset;break;case"r":K.x+=K.width/2+K.labeloffset;break}})}function z($){e.forEach($.edges(),function(H){var K=$.edge(H);K.reversed&&K.points.reverse()})}function R($){e.forEach($.nodes(),function(H){if($.children(H).length){var K=$.node(H),V=$.node(K.borderTop),te=$.node(K.borderBottom),ue=$.node(e.last(K.borderLeft)),ye=$.node(e.last(K.borderRight));K.width=Math.abs(ye.x-ue.x),K.height=Math.abs(te.y-V.y),K.x=ue.x+K.width/2,K.y=V.y+K.height/2}}),e.forEach($.nodes(),function(H){$.node(H).dummy==="border"&&$.removeNode(H)})}function q($){e.forEach($.edges(),function(H){if(H.v===H.w){var K=$.node(H.v);K.selfEdges||(K.selfEdges=[]),K.selfEdges.push({e:H,label:$.edge(H)}),$.removeEdge(H)}})}function M($){var H=h.buildLayerMatrix($);e.forEach(H,function(K){var V=0;e.forEach(K,function(te,ue){var ye=$.node(te);ye.order=ue+V,e.forEach(ye.selfEdges,function(_e){h.addDummyNode($,"selfedge",{width:_e.label.width,height:_e.label.height,rank:ye.rank,order:ue+ ++V,e:_e.e,label:_e.label},"_se")}),delete ye.selfEdges})})}function O($){e.forEach($.nodes(),function(H){var K=$.node(H);if(K.dummy==="selfedge"){var V=$.node(K.e.v),te=V.x+V.width/2,ue=V.y,ye=K.x-te,_e=V.height/2;$.setEdge(K.e,K.label),$.removeNode(H),K.label.points=[{x:te+2*ye/3,y:ue-_e},{x:te+5*ye/6,y:ue-_e},{x:te+ye,y:ue},{x:te+5*ye/6,y:ue+_e},{x:te+2*ye/3,y:ue+_e}],K.label.x=K.x,K.label.y=K.y}})}function W($,H){return e.mapValues(e.pick($,H),Number)}function U($){var H={};return e.forEach($,function(K,V){H[V.toLowerCase()]=K}),H}return Gl}var Yl,Sg;function $k(){if(Sg)return Yl;Sg=1;var e=Ce(),t=We(),r=Xe().Graph;Yl={debugOrdering:n};function n(s){var a=t.buildLayerMatrix(s),i=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(l){i.setNode(l,{label:l}),i.setParent(l,"layer"+s.node(l).rank)}),e.forEach(s.edges(),function(l){i.setEdge(l.v,l.w,{},l.name)}),e.forEach(a,function(l,c){var u="layer"+c;i.setNode(u,{rank:"same"}),e.reduce(l,function(d,p){return i.setEdge(d,p,{style:"invis"}),p})}),i}return Yl}var Xl,wg;function zk(){return wg||(wg=1,Xl="0.8.5"),Xl}var Zl,_g;function qk(){return _g||(_g=1,Zl={graphlib:Xe(),layout:Mk(),debug:$k(),util:{time:We().time,notime:We().notime},version:zk()}),Zl}var Wk=qk();const jg=pb(Wk);function Nt(e,t="TB"){if(e.data?._layoutWidth&&e.data?._layoutHeight)return{width:e.data._layoutWidth,height:e.data._layoutHeight};let r=240,n=84;switch(e.type){case"decisionNode":r=164,n=164;break;case"forkNode":r=240,n=84;break;case"joinNode":r=240,n=84;break;case"dynamicPlaceholderNode":r=220,n=70;break;case"loopNode":r=320,n=200;break;case"subWorkflowNode":r=240,n=84;break;case"eventNode":r=240,n=84;break;case"default":r=240,n=40;break;case"plusNode":r=e.data.label&&e.data.label!=="+"?120:32,n=32;break;default:r=240,n=84;break}return{width:r,height:n}}function Fk(e,t,r=8){const n=[];if(e.length<r)return n;const s=new Map,a={},i={};e.forEach(p=>{s.set(p.id,p),a[p.id]=[],i[p.id]=[]}),t.forEach(p=>{a[p.source]&&a[p.source].push(p.target),i[p.target]&&i[p.target].push(p.source)});const l=new Set,c=new Set(["input","output","decisionNode","forkNode","joinNode","loopNode","default","plusNode"]),u=p=>!c.has(p.type||""),d=[...e].sort((p,h)=>p.position.y-h.position.y);for(const p of d){if(l.has(p.id)||!u(p)||a[p.id].length>1)continue;const h=[p.id];let f=p,m=a[f.id];for(;m&&m.length===1;){const y=m[0],v=s.get(y);if(!v||l.has(y)||!u(v)||i[y].length!==1)break;h.push(y),f=v,m=a[f.id]}h.length>=r&&(n.push(h),h.forEach(y=>l.add(y)))}return n}function Bk(e,t,r,n,s,a=5,i="view"){const l=t.find(x=>x.id===e[0]),{width:c,height:u}=Nt(l||t[0],r),d=Math.max(.7,1-(e.length-10)/80),p=i==="edit"||i==="run"?1.15:1,h=Math.min(n,Math.round(60*d*p)),f=Math.min(s,Math.round(80*d*p)),m=c+h,y=u+f;let v=0,g=0;if(r==="TB"){const x=Math.ceil(e.length/a);v=a*m-h,g=x*y-f}else v=Math.ceil(e.length/a)*m-h,g=a*y-f;return v+=40,g+=40,{width:v,height:g,gridKW:m,gridKH:y,cols:a}}const Ql=58,Tg=20,Hk=16;function Uk(e,t,r,n){if(e.length===0)return{positionedChildren:[],containerWidth:280,containerHeight:Ql+50};const s=e.map(p=>({...p,parentId:void 0,extent:void 0})),{nodes:a}=ec(s,t,{direction:r,mode:n,enableSnakeLayout:!1});let i=0,l=0;a.forEach(p=>{const{width:h,height:f}=Nt(p,r);i=Math.max(i,p.position.x+h),l=Math.max(l,p.position.y+f)});const c=Math.max(300,i+Tg*2),u=Ql+l+Hk;return{positionedChildren:a.map(p=>{const h=e.find(f=>f.id===p.id);return{...p,parentId:h.parentId,extent:h.extent,position:{x:p.position.x+Tg,y:p.position.y+Ql}}}),containerWidth:c,containerHeight:u}}function ec(e,t,r={}){const{direction:n="TB",mode:s="view",enableSnakeLayout:a=!0,snakeColumns:i=5,snakeMinChainLength:l=8,snakeMinNodeCount:c=10}=r,u=e.length,d=e.filter(_=>_.type!=="plusNode").length;let p=n==="LR"?150:120,h=n==="LR"?120:100,f=p,m=h;if(u>15){let _=Math.max(.5,1-(u-15)/50),j=Math.max(.4,1-(u-15)/40);(s==="edit"||s==="run")&&(_=1-(1-_)*.5,j=1-(1-j)*.5),f=Math.round(p*_),m=Math.round(h*j)}const y=a&&d>c?Fk(e,t,l):[],v={};y.forEach((_,j)=>{_.forEach(P=>{v[P]=j})});const g=new jg.graphlib.Graph;g.setDefaultEdgeLabel(()=>({})),g.setGraph({rankdir:n,ranker:"network-simplex",ranksep:f,nodesep:m,edgesep:50,marginx:50,marginy:50});const x=new Set,b={};e.forEach(_=>{const j=v[_.id];if(j!==void 0){if(!x.has(j)){x.add(j);const P=Bk(y[j],e,n,m,f,i,s);b[j]=P,g.setNode(`__CHAIN_${j}`,{width:P.width,height:P.height})}}else{const{width:P,height:E}=Nt(_,n);g.setNode(_.id,{width:P,height:E})}});const k={};t.forEach(_=>{const j=v[_.source],P=v[_.target],E=j!==void 0?`__CHAIN_${j}`:_.source,A=P!==void 0?`__CHAIN_${P}`:_.target;E!==A&&(k[A]=(k[A]||0)+1)}),t.forEach(_=>{const j=v[_.source],P=v[_.target];let E=_.source,A=_.target;if(j!==void 0&&(E=`__CHAIN_${j}`),P!==void 0&&(A=`__CHAIN_${P}`),E!==A){const L=(k[A]||0)>1;g.setEdge(E,A,{weight:L?1:2})}}),jg.layout(g);const S={};for(const _ of e)S[_.id]={..._};const C=[],T=new Set;e.forEach(_=>{if(v[_.id]===void 0){const j=g.node(_.id),P=S[_.id],{width:E,height:A}=Nt(P,n);P.position={x:j.x-E/2,y:j.y-A/2},P.data={...P.data,sourcePosition:void 0,targetPosition:void 0},P.sourcePosition=n==="LR"?F.Position.Right:F.Position.Bottom,P.targetPosition=n==="LR"?F.Position.Left:F.Position.Top,C.push(P)}else T.add(_.id)}),y.forEach((_,j)=>{const P=`__CHAIN_${j}`,E=g.node(P),A=b[j],L=E.x-A.width/2+20,B=E.y-A.height/2+20,z=A.cols,R=A.gridKW,q=A.gridKH;_.forEach((M,O)=>{const W=S[M];let U=0,$=0,H,K;if(n==="TB"){const V=Math.floor(O/z),te=O%z,ue=V%2===0,ye=Math.ceil(_.length/z),_e=V===ye-1,Ne=_.length%z||z,J=_e?(z-Ne)*R/2:0;let Se;ue?Se=te*R+J:Se=(z-1-te)*R-J;const ne=V*q;U=L+Se,$=B+ne;const xe=_e?Ne:z;ue?(K=F.Position.Left,H=F.Position.Right,te===xe-1&&O!==_.length-1&&(H=F.Position.Bottom),te===0&&O!==0&&(K=F.Position.Top)):(K=F.Position.Right,H=F.Position.Left,te===xe-1&&O!==_.length-1&&(H=F.Position.Bottom),te===0&&O!==0&&(K=F.Position.Top)),O===0&&(K=F.Position.Top),O===_.length-1&&(H=F.Position.Bottom)}else{const V=Math.floor(O/z),te=O%z,ue=V%2===0,ye=Math.ceil(_.length/z),_e=V===ye-1,Ne=_.length%z||z,J=_e?Math.max(0,(z-Ne)*q)/2:0,Se=V*R;let ne;ue?ne=te*q+J:ne=(z-1-te)*q-J,U=L+Se,$=B+ne;const xe=_e?Ne:z;ue?(K=F.Position.Top,H=F.Position.Bottom,te===xe-1&&O!==_.length-1&&(H=F.Position.Right),te===0&&O!==0&&(K=F.Position.Left)):(K=F.Position.Bottom,H=F.Position.Top,te===xe-1&&O!==_.length-1&&(H=F.Position.Right),te===0&&O!==0&&(K=F.Position.Left)),O===0&&(K=F.Position.Left),O===_.length-1&&(H=F.Position.Right)}W.position={x:U,y:$},W.data={...W.data,sourcePosition:H,targetPosition:K},W.sourcePosition=H,W.targetPosition=K,C.push(W)})});const N=C.reduce((_,j)=>({..._,[j.id]:j}),{}),w=t.map(_=>{const j=N[_.source],P=N[_.target];if(!j||!P||T.has(j.id)||j.type!=="decisionNode")return _;const{width:E,height:A}=Nt(j,n),{width:L,height:B}=Nt(P,n),z={x:j.position.x+E/2,y:j.position.y+A/2},R={x:P.position.x+L/2,y:P.position.y+B/2};let q=null;if(n==="TB"){const M=E*.25;R.x<z.x-M?q="left":R.x>z.x+M&&(q="right")}else{const M=A*.25;R.y<z.y-M?q="top":R.y>z.y+M&&(q="bottom")}return{..._,sourceHandle:q}});return{nodes:C,edges:w}}function Oe(e,t,r={}){const n=r.direction||"TB",s=r.mode||"view",a=e.filter(g=>g.parentId),i=e.filter(g=>!g.parentId);if(a.length===0)return ec(e,t,r);const l=new Map(a.map(g=>[g.id,g])),c={},u=[];t.forEach(g=>{const x=l.get(g.source),b=l.get(g.target);if(x?.parentId&&x.parentId===b?.parentId){const k=x.parentId;c[k]||(c[k]=[]),c[k].push(g)}else u.push(g)});const d={};a.forEach(g=>{const x=g.parentId;d[x]||(d[x]=[]),d[x].push(g)});const p={},h=[];for(const[g,x]of Object.entries(d)){const b=c[g]||[],{positionedChildren:k,containerWidth:S,containerHeight:C}=Uk(x,b,n,s);p[g]={width:S,height:C},h.push(...k)}const f=i.map(g=>{if(g.type==="loopNode"&&p[g.id]){const{width:x,height:b}=p[g.id];return{...g,data:{...g.data,_layoutWidth:x,_layoutHeight:b},style:{...g.style,width:x,height:b}}}return g}),{nodes:m,edges:y}=ec(f,u,r);return{nodes:[...m.map(g=>{if(g.type==="loopNode"&&p[g.id]){const{width:x,height:b}=p[g.id];return{...g,width:x,height:b,style:{...g.style,width:x,height:b}}}return g}),...h],edges:[...y,...Object.values(c).flat()]}}function Be(e,t){if(!e)return null;for(const r of e){if(r.taskReferenceName===t)return r;if(r.decisionCases){for(const s of Object.keys(r.decisionCases)){const a=Be(r.decisionCases[s],t);if(a)return a}const n=Be(r.defaultCase,t);if(n)return n}if(r.forkTasks)for(const n of r.forkTasks){const s=Be(n,t);if(s)return s}if(r.loopOver){const n=Be(r.loopOver,t);if(n)return n}}return null}function rt(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 s of Object.keys(n.decisionCases))if(rt(n.decisionCases[s],t))return!0;if(rt(n.defaultCase,t))return!0}if(n.forkTasks){for(const s of n.forkTasks)if(rt(s,t))return!0}if(n.loopOver&&rt(n.loopOver,t))return!0}return!1}function Et(e,t){if(!e)return null;if(e.some(r=>r.taskReferenceName===t))return e;for(const r of e){if(r.decisionCases){for(const s of Object.values(r.decisionCases)){const a=Et(s,t);if(a)return a}const n=Et(r.defaultCase,t);if(n)return n}if(r.forkTasks)for(const n of r.forkTasks){const s=Et(n,t);if(s)return s}if(r.loopOver){const n=Et(r.loopOver,t);if(n)return n}}return null}function Ig(e,t){const r=e.findIndex(n=>n.taskReferenceName===t);if(r<0)return null;for(let n=r+1;n<e.length;n++)if(e[n].type==="JOIN"||e[n].type==="EXCLUSIVE_JOIN")return e[n].taskReferenceName;return null}function Cg(e,t){const r=e.findIndex(n=>n.taskReferenceName===t);if(r<0)return null;for(let n=r-1;n>=0;n--)if(e[n].type==="FORK_JOIN"||e[n].type==="FORK_JOIN_DYNAMIC")return e[n].taskReferenceName;return null}function Ze(e,t,r){if(!e)return!1;if(t==="start")return e.unshift(r),!0;const n=e.findIndex(s=>s.taskReferenceName===t);if(n!==-1)return e.splice(n+1,0,r),!0;for(const s of e){if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(Ze(s.decisionCases[a],t,r))return!0;if(Ze(s.defaultCase,t,r))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(Ze(a,t,r))return!0}if(s.loopOver&&Ze(s.loopOver,t,r))return!0}return!1}function Rt(e,t,r,n){for(const s of e||[]){if(s.taskReferenceName===t){if(r.branchCase==="default")return s.defaultCase||(s.defaultCase=[]),s.defaultCase.unshift(n),!0;if(r.branchCase!==void 0)return s.decisionCases||(s.decisionCases={}),s.decisionCases[r.branchCase]||(s.decisionCases[r.branchCase]=[]),s.decisionCases[r.branchCase].unshift(n),!0;if(r.forkIndex!==void 0)return s.forkTasks||(s.forkTasks=[]),s.forkTasks[r.forkIndex].unshift(n),!0;if(r.isLoopAdd)return s.loopOver||(s.loopOver=[]),s.loopOver.unshift(n),!0}if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(Rt(s.decisionCases[a],t,r,n))return!0;if(Rt(s.defaultCase,t,r,n))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(Rt(a,t,r,n))return!0}if(s.loopOver&&Rt(s.loopOver,t,r,n))return!0}return!1}function $e(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 s=[];(r.forkTasks||[]).forEach(a=>{a&&a.length>0&&s.push(a[a.length-1].taskReferenceName)}),n.joinOn=s}}r.decisionCases&&(Object.values(r.decisionCases).forEach(n=>$e(n)),r.defaultCase&&$e(r.defaultCase)),r.forkTasks&&r.forkTasks.forEach(n=>$e(n)),r.loopOver&&$e(r.loopOver)}}const Jk=[{field:"name",type:"required",message:"工作流名称 (name) 必填"},{field:"version",type:"required",message:"工作流版本 (version) 必填"},{field:"tasks",type:"min_length",value:1,message:"工作流必须包含至少一个任务"}],Ng={common:[{field:"name",type:"required",message:"任务类型名称 (name) 必填"},{field:"taskReferenceName",type:"required",message:"引用名 (taskReferenceName) 必填"},{field:"taskReferenceName",type:"pattern",value:/^[a-zA-Z0-9_]+$/,message:"引用名仅允许字母、数字和下划线"},{field:"taskReferenceName",type:"unique",message:"引用名在工作流中必须唯一"}],types:{HTTP:[{field:"inputParameters.http_request.uri",type:"required",message:"HTTP 任务缺少请求地址 (uri) 配置"},{field:"inputParameters.http_request.method",type:"required",level:"warning",message:"HTTP 任务未指定 Method,建议配置"}],INLINE:[{field:"inputParameters.expression",type:"custom",validate:(e,t)=>!!(t?.inputParameters?.expression||t?.inputParameters?.scriptExpression),message:"INLINE 任务缺少脚本表达式 (expression)"}],LAMBDA:[{field:"inputParameters.scriptExpression",type:"required",message:"LAMBDA 任务缺少脚本表达式 (scriptExpression)"}],JSON_JQ_TRANSFORM:[{field:"inputParameters.queryExpression",type:"required",message:"JQ 任务缺少查询表达式 (queryExpression)"}],SUB_WORKFLOW:[{field:"subWorkflowParam.name",type:"required",message:"子工作流任务缺少子流程名称 (name)"}],START_WORKFLOW:[{field:"inputParameters.startWorkflow.name",type:"custom",validate:(e,t)=>!!t?.inputParameters?.startWorkflow?.name,message:"START_WORKFLOW 任务缺少目标工作流名称"}],DYNAMIC:[{field:"dynamicTaskNameParam",type:"required",message:"DYNAMIC 任务缺少 dynamicTaskNameParam 配置"}],TERMINATE:[{field:"inputParameters.terminationStatus",type:"required",level:"warning",message:"终止任务未指定状态 (terminationStatus)"},{field:"inputParameters.terminationStatus",type:"enum",value:["COMPLETED","FAILED"],message:"终止状态必须为 COMPLETED 或 FAILED"}],DO_WHILE:[{field:"loopCondition",type:"custom",validate:(e,t)=>!!(t?.loopCondition||t?.inputParameters?.items),message:"循环任务需要配置退出条件 (loopCondition) 或列表 (items)"}],DECISION:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"决策任务必须至少包含一个分支 (decisionCases)"},{field:"decisionCases",type:"custom",validate:e=>{const 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 任务必须至少包含一个分支"}],FORK_JOIN_DYNAMIC:[{field:"dynamicForkTasksParam",type:"custom",validate:(e,t)=>!!(t?.dynamicForkTasksParam||t?.forkTaskType||t?.forkTaskWorkflow),message:"FORK_JOIN_DYNAMIC 任务需要配置 dynamicForkTasksParam 或 forkTaskType 或 forkTaskWorkflow",level:"warning"}]}};class Vk{rules=[];setRules(t){this.rules=[...t]}getRules(){return this.rules}hasRules(){return this.rules.length>0}runAll(t){const r=[],n=[];for(const s of this.rules)try{const a=s.validate(t);for(const i of a)s.level==="warning"?n.push(i):r.push(i)}catch{r.push({type:"GLOBAL",ref:"",message:`自定义规则 "${s.id}" 执行异常`})}return{errors:r,warnings:n}}buildPromptSection(){return this.rules.length===0?null:`## 业务校验规则(必须遵守)
|
|
7
|
-
|
|
8
|
-
${this.rules.map(r=>`- ${r.description}`).join(`
|
|
9
|
-
`)}`}}const Eg=new Vk,Kk=(e,t)=>t.split(".").reduce((r,n)=>r&&r[n]!==void 0?r[n]:void 0,e),tc=(e,t,r,n)=>{const{errors:s,warnings:a}=n,i=e.taskReferenceName||"GLOBAL";t.forEach(l=>{const c=Kk(e,l.field);let u=!0;switch(l.type){case"required":u=c!=null&&c!=="";break;case"min_length":u=Array.isArray(c)&&c.length>=l.value;break;case"pattern":u=l.value.test(c);break;case"enum":u=l.value.includes(c);break;case"unique":l.field==="taskReferenceName"&&c&&(r.taskRefs.has(c)?u=!1:r.taskRefs.add(c));break;case"custom":typeof l.validate=="function"&&(u=l.validate(c,e,r));break}if(!u){const d={type:e.taskReferenceName?"TASK":"GLOBAL",ref:i,message:l.message};l.level==="warning"?a.push(d):s.push(d)}})},He=e=>{const t=[],r=[],n={taskRefs:new Set,taskMap:{}};if(!e)return{isValid:!1,errors:[{type:"GLOBAL",ref:"",message:"工作流定义为空"}],warnings:[]};if(tc(e,Jk,n,{errors:t,warnings:r}),!e.tasks||e.tasks.length===0)return{isValid:!1,errors:t,warnings:r};const s=i=>{i.forEach(l=>{tc(l,Ng.common,n,{errors:t,warnings:r});const c=Ng.types[l.type];c&&tc(l,c,n,{errors:t,warnings:r}),l.decisionCases&&Object.keys(l.decisionCases).forEach(u=>{s(l.decisionCases[u])}),l.defaultCase&&s(l.defaultCase),l.forkTasks&&l.forkTasks.forEach(u=>s(u)),l.loopOver&&s(l.loopOver)})};s(e.tasks);const a=Gk(e.tasks);if(t.push(...a),Eg.hasRules()){const i=Eg.runAll(e);t.push(...i.errors),r.push(...i.warnings)}return{isValid:t.length===0,errors:t,warnings:r}},Gk=e=>{const t=[],r=new Map,n=new Set,s=d=>{for(let p=0;p<d.length;p++){const h=d[p],f=h.taskReferenceName;if(n.add(f),r.has(f)||r.set(f,[]),p<d.length-1){const m=d[p+1].taskReferenceName;h.type!=="FORK_JOIN"&&h.type!=="FORK_JOIN_DYNAMIC"&&r.get(f).push(m)}if(h.decisionCases)for(const m of Object.values(h.decisionCases))m.length>0&&(r.get(f).push(m[0].taskReferenceName),s(m));if(h.defaultCase&&h.defaultCase.length>0&&(r.get(f).push(h.defaultCase[0].taskReferenceName),s(h.defaultCase)),h.forkTasks)for(const m of h.forkTasks)m.length>0&&(r.get(f).push(m[0].taskReferenceName),s(m));if(h.loopOver)for(const m of h.loopOver)n.add(m.taskReferenceName);if(h.joinOn)for(const m of h.joinOn)r.has(m)||r.set(m,[]),r.get(m).push(f)}};s(e);const a=0,i=1,l=2,c=new Map;for(const d of n)c.set(d,a);const u=d=>{c.set(d,i);const p=r.get(d)||[];for(const h of p)if(c.has(h)){if(c.get(h)===i)return t.push({type:"GLOBAL",ref:h,message:`检测到环路:任务 "${d}" → "${h}" 形成了循环依赖`}),!0;if(c.get(h)===a&&u(h))return!0}return c.set(d,l),!1};for(const d of n)c.get(d)===a&&u(d);return t};function Yk(e,t){const r=new Set(e),n={};e.forEach(l=>n[l]=0),t.forEach(l=>{r.has(l.source)&&r.has(l.target)&&(n[l.target]=(n[l.target]??0)+1)});const s=[];let a=e.filter(l=>n[l]===0);const i={...n};for(;a.length>0;){s.push([...a]);const l=[];a.forEach(c=>{t.forEach(u=>{u.source===c&&r.has(u.target)&&(i[u.target]--,i[u.target]===0&&l.push(u.target))})}),a=l}return s}function st(e){return!e||e.length===0?[]:typeof e[0]=="string"?e.map(t=>({name:t})):e}class Xk{schemas=new Map;setSchemas(t){this.schemas.clear();for(const r of t)this.schemas.set(r.taskName,r)}get(t){return this.schemas.get(t)}getAll(){return Array.from(this.schemas.values())}hasSchemas(){return this.schemas.size>0}buildPromptSection(t){if(!this.hasSchemas())return null;const r=this.getAll(),n=t?.limit,s=n!==void 0&&r.length>n?r.slice(0,Math.max(0,Math.floor(n))):r,a=["## 任务 Schema 注册表(数据流参考)","以下任务的输入/输出字段已注册。生成 inputParameters 时请引用正确的上游输出字段(格式:`${taskRef.output.fieldName}`)。"];for(const i of s){const l=i.taskType?`(${i.taskType})`:"",c=i.description?` — ${i.description}`:"";if(a.push(`
|
|
10
|
-
**${i.taskName}** ${l}${c}`),i.inputSchema&&Object.keys(i.inputSchema).length>0){const u=Object.entries(i.inputSchema).map(([d,p])=>`${d}: ${p}`).join(", ");a.push(`- 输入: ${u}`)}if(i.outputSchema&&Object.keys(i.outputSchema).length>0){const u=Object.entries(i.outputSchema).map(([d,p])=>`${d}: ${p}`).join(", ");a.push(`- 输出: ${u}`)}}return s.length<r.length&&a.push(`
|
|
6
|
+
<%s key={someKey} {...props} />`,L,K,se,K),W[K+L]=!0)}if(K=null,Z!==void 0&&(r(Z),K=""+Z),i(D)&&(r(D.key),K=""+D.key),"key"in D){Z={};for(var pe in D)pe!=="key"&&(Z[pe]=D[pe])}else Z=D;return K&&l(Z,typeof P=="function"?P.displayName||P.name||"Unknown":P),d(P,K,Z,s(),H,U)}function p(P){f(P)?P._store&&(P._store.validated=1):typeof P=="object"&&P!==null&&P.$$typeof===I&&(P._payload.status==="fulfilled"?f(P._payload.value)&&P._payload.value._store&&(P._payload.value._store.validated=1):P._store&&(P._store.validated=1))}function f(P){return typeof P=="object"&&P!==null&&P.$$typeof===h}var m=T,h=Symbol.for("react.transitional.element"),y=Symbol.for("react.portal"),x=Symbol.for("react.fragment"),g=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),k=Symbol.for("react.consumer"),b=Symbol.for("react.context"),S=Symbol.for("react.forward_ref"),j=Symbol.for("react.suspense"),_=Symbol.for("react.suspense_list"),w=Symbol.for("react.memo"),I=Symbol.for("react.lazy"),N=Symbol.for("react.activity"),C=Symbol.for("react.client.reference"),M=m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,R=Object.prototype.hasOwnProperty,O=Array.isArray,$=console.createTask?console.createTask:function(){return null};m={react_stack_bottom_frame:function(P){return P()}};var B,q={},F=m.react_stack_bottom_frame.bind(m,a)(),A=$(n(a)),W={};Ur.Fragment=x,Ur.jsx=function(P,D,Z){var L=1e4>M.recentlyCreatedOwnerStacks++;return u(P,D,Z,!1,L?Error("react-stack-top-frame"):F,L?$(n(P)):A)},Ur.jsxs=function(P,D,Z){var L=1e4>M.recentlyCreatedOwnerStacks++;return u(P,D,Z,!0,L?Error("react-stack-top-frame"):F,L?$(n(P)):A)}})()),Ur}var Gp;function I0(){return Gp||(Gp=1,process.env.NODE_ENV==="production"?Kn.exports=j0():Kn.exports=T0()),Kn.exports}var o=I0();const Yp=e=>{let t;const r=new Set,n=(d,u)=>{const p=typeof d=="function"?d(t):d;if(!Object.is(p,t)){const f=t;t=u??(typeof p!="object"||p===null)?p:Object.assign({},t,p),r.forEach(m=>m(t,f))}},s=()=>t,l={setState:n,getState:s,getInitialState:()=>c,subscribe:d=>(r.add(d),()=>r.delete(d))},c=t=e(n,s,l);return l},Xp=(e=>e?Yp(e):Yp),N0=e=>e;function ga(e,t=N0){const r=T.useSyncExternalStore(e.subscribe,T.useCallback(()=>t(e.getState()),[e,t]),T.useCallback(()=>t(e.getInitialState()),[e,t]));return T.useDebugValue(r),r}const Zp=e=>{const t=Xp(e),r=n=>ga(t,n);return Object.assign(r,t),r},Gn=(e=>e?Zp(e):Zp);function xa(e,t){let r;try{r=e()}catch{return}return{getItem:s=>{var a;const i=c=>c===null?null:JSON.parse(c,void 0),l=(a=r.getItem(s))!=null?a:null;return l instanceof Promise?l.then(i):i(l)},setItem:(s,a)=>r.setItem(s,JSON.stringify(a,void 0)),removeItem:s=>r.removeItem(s)}}const va=e=>t=>{try{const r=e(t);return r instanceof Promise?r:{then(n){return va(n)(r)},catch(n){return this}}}catch(r){return{then(n){return this},catch(n){return va(n)(r)}}}},Qp=(e,t)=>(r,n,s)=>{let a={storage:xa(()=>localStorage),partialize:y=>y,version:0,merge:(y,x)=>({...x,...y}),...t},i=!1;const l=new Set,c=new Set;let d=a.storage;if(!d)return e((...y)=>{console.warn(`[zustand persist middleware] Unable to update item '${a.name}', the given storage is currently unavailable.`),r(...y)},n,s);const u=()=>{const y=a.partialize({...n()});return d.setItem(a.name,{state:y,version:a.version})},p=s.setState;s.setState=(y,x)=>(p(y,x),u());const f=e((...y)=>(r(...y),u()),n,s);s.getInitialState=()=>f;let m;const h=()=>{var y,x;if(!d)return;i=!1,l.forEach(v=>{var k;return v((k=n())!=null?k:f)});const g=((x=a.onRehydrateStorage)==null?void 0:x.call(a,(y=n())!=null?y:f))||void 0;return va(d.getItem.bind(d))(a.name).then(v=>{if(v)if(typeof v.version=="number"&&v.version!==a.version){if(a.migrate){const k=a.migrate(v.state,v.version);return k instanceof Promise?k.then(b=>[!0,b]):[!0,k]}console.error("State loaded from storage couldn't be migrated since no migrate function was provided")}else return[!1,v.state];return[!1,void 0]}).then(v=>{var k;const[b,S]=v;if(m=a.merge(S,(k=n())!=null?k:f),r(m,!0),b)return u()}).then(()=>{g?.(m,void 0),m=n(),i=!0,c.forEach(v=>v(m))}).catch(v=>{g?.(void 0,v)})};return s.persist={setOptions:y=>{a={...a,...y},y.storage&&(d=y.storage)},clearStorage:()=>{d?.removeItem(a.name)},getOptions:()=>a,rehydrate:()=>h(),hasHydrated:()=>i,onHydrate:y=>(l.add(y),()=>{l.delete(y)}),onFinishHydration:y=>(c.add(y),()=>{c.delete(y)})},a.skipHydration||h(),m||f};var ef=(e,t,r)=>(s,a)=>({pastStates:r?.pastStates||[],futureStates:r?.futureStates||[],undo:(i=1)=>{if(a().pastStates.length){const l=r?.partialize?.(t())||t(),c=a().pastStates.splice(-i,i),d=c.shift();e(d),s({pastStates:a().pastStates,futureStates:a().futureStates.concat(r?.diff?.(l,d)||l,c.reverse())})}},redo:(i=1)=>{if(a().futureStates.length){const l=r?.partialize?.(t())||t(),c=a().futureStates.splice(-i,i),d=c.shift();e(d),s({pastStates:a().pastStates.concat(r?.diff?.(l,d)||l,c.reverse()),futureStates:a().futureStates})}},clear:()=>s({pastStates:[],futureStates:[]}),isTracking:!0,pause:()=>s({isTracking:!1}),resume:()=>s({isTracking:!0}),setOnSave:i=>s({_onSave:i}),_onSave:r?.onSave,_handleSet:(i,l,c,d)=>{r?.limit&&a().pastStates.length>=r?.limit&&a().pastStates.shift(),a()._onSave?.(i,c),s({pastStates:a().pastStates.concat(d||i),futureStates:[]})}}),C0=(e,t)=>(n,s,a)=>{a.temporal=Xp(t?.wrapTemporal?.(ef(n,s,t))||ef(n,s,t));const i=t?.handleSet?.(a.temporal.getState()._handleSet)||a.temporal.getState()._handleSet,l=d=>{if(!a.temporal.getState().isTracking)return;const u=t?.partialize?.(s())||s(),p=t?.diff?.(d,u);p===null||t?.equality?.(d,u)||i(d,void 0,u,p)},c=a.setState;return a.setState=(...d)=>{const u=t?.partialize?.(s())||s();c(...d),l(u)},e((...d)=>{const u=t?.partialize?.(s())||s();n(...d),l(u)},s,a)};function E0(e,t="TB",r){const n=r?.hideEmptyBranches??!1;if(!e||!e.tasks)return{nodes:[],edges:[],taskMap:{}};const s=[],a=[],i={};let l=0;const c=e.tasks;for(let d=0;d<c.length;d++){const u=c[d],p=tf(u,l,i,t,c,n);if(s.push(...p.nodes),a.push(...p.edges),l=p.nextId,d>0){const f=c[d-1];ba(f,u,a,n)}Object.assign(i,p.taskMap)}if(!n&&c.length>0){const d=c[0],u="__workflow_start__";s.push({id:u,type:"plusNode",data:{label:"+",taskReferenceName:u,taskType:"PLUS",parentRef:u,edgeData:{isWorkflowStart:!0},layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?J.Position.Right:J.Position.Bottom,targetPosition:t==="LR"?J.Position.Left:J.Position.Top}),a.push({id:`e-${u}-${d.taskReferenceName}`,source:u,target:d.taskReferenceName,animated:!0});const p=c[c.length-1],f="__workflow_end__";s.push({id:f,type:"plusNode",data:{label:"+",taskReferenceName:f,taskType:"PLUS",parentRef:p.taskReferenceName,layoutDirection:t},position:{x:0,y:0},sourcePosition:t==="LR"?J.Position.Right:J.Position.Bottom,targetPosition:t==="LR"?J.Position.Left:J.Position.Top}),ba(p,{taskReferenceName:f},a,n)}return{nodes:s,edges:a,taskMap:i}}function tf(e,t,r,n="TB",s=[],a=!1){switch(e.type||"SIMPLE"){case"DECISION":case"SWITCH":return O0(e,t,r,n,a);case"FORK_JOIN":case"FORK_JOIN_DYNAMIC":return P0(e,t,r,n);case"JOIN":case"EXCLUSIVE_JOIN":return D0(e,t,r,n,s,a);case"DO_WHILE":return A0(e,t,r,n,a);case"SUB_WORKFLOW":return $0(e,t,r,n);default:return R0(e,t,r,n)}}function R0(e,t,r,n="TB"){const s={id:e.taskReferenceName,type:"taskNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type||"SIMPLE",task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?J.Position.Right:J.Position.Bottom,targetPosition:n==="LR"?J.Position.Left:J.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:t+1}}function O0(e,t,r,n="TB",s=!1){const a=[],i=[];let l=t;const c={},d={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"?J.Position.Right:J.Position.Bottom,targetPosition:n==="LR"?J.Position.Left:J.Position.Top};a.push(d),c[e.taskReferenceName]=e;const u=e.decisionCases||{},p=e.defaultCase||[],f=Object.keys(u),m=(h,y)=>{if(n==="TB"){if(h===0&&y>1)return"left";if(h===1&&y>2)return"right"}else{if(h===0&&y>1)return"top";if(h===1&&y>2)return"bottom"}return null};if(f.forEach((h,y)=>{const x=u[h],g=m(y,f.length+1);if(x&&x.length>0){const v=Yn(x,l,{...r,...c},n,s);a.push(...v.nodes),i.push(...v.edges),Object.assign(c,v.taskMap),l=v.nextId;const k=x[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${k}`,source:e.taskReferenceName,sourceHandle:g||void 0,target:k,label:h,animated:!0,data:{branchCase:h},style:{stroke:"var(--cm-cat-control)"}})}else if(!s){const v=`${e.taskReferenceName}_empty_${h}`;a.push({id:v,type:"plusNode",data:{label:`${h} (空)`,parentRef:e.taskReferenceName,edgeData:{branchCase:h},layoutDirection:n,taskReferenceName:v,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?J.Position.Right:J.Position.Bottom,targetPosition:n==="LR"?J.Position.Left:J.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-muted)",minWidth:"80px",textAlign:"center"}}),i.push({id:`e-${e.taskReferenceName}-${v}`,source:e.taskReferenceName,sourceHandle:g||void 0,target:v,label:h,animated:!0,data:{branchCase:h},style:{stroke:"var(--cm-cat-control)",strokeDasharray:"5,5"}})}}),p&&p.length>0){const h=Yn(p,l,{...r,...c},n,s);a.push(...h.nodes),i.push(...h.edges),Object.assign(c,h.taskMap),l=h.nextId;const y=p[0].taskReferenceName;i.push({id:`e-${e.taskReferenceName}-${y}`,source:e.taskReferenceName,target:y,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"var(--cm-text-muted)"}})}else if(!s){const h=`${e.taskReferenceName}_empty_default`;a.push({id:h,type:"plusNode",data:{label:"default (空)",parentRef:e.taskReferenceName,edgeData:{branchCase:"default"},layoutDirection:n,taskReferenceName:h,taskType:"EMPTY_BRANCH"},position:{x:0,y:0},sourcePosition:n==="LR"?J.Position.Right:J.Position.Bottom,targetPosition:n==="LR"?J.Position.Left:J.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-muted)",minWidth:"80px",textAlign:"center"}}),i.push({id:`e-${e.taskReferenceName}-${h}`,source:e.taskReferenceName,target:h,label:"default",animated:!0,data:{branchCase:"default"},style:{stroke:"var(--cm-text-muted)",strokeDasharray:"5,5"}})}return{nodes:a,edges:i,taskMap:c,nextId:l}}function P0(e,t,r,n="TB"){const s=[],a=[];let i=t;const l={},c=e.type==="FORK_JOIN_DYNAMIC",d={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"?J.Position.Right:J.Position.Bottom,targetPosition:n==="LR"?J.Position.Left:J.Position.Top};if(s.push(d),l[e.taskReferenceName]=e,c){const u=`${e.taskReferenceName}_dynamic_placeholder`;s.push({id:u,type:"dynamicPlaceholderNode",data:{label:"动态分支",taskReferenceName:u,taskType:"DYNAMIC_PLACEHOLDER",layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?J.Position.Right:J.Position.Bottom,targetPosition:n==="LR"?J.Position.Left:J.Position.Top}),a.push({id:`e-${e.taskReferenceName}-${u}`,source:e.taskReferenceName,target:u,animated:!0,style:{stroke:"var(--cm-cat-control)",strokeDasharray:"5,5",strokeWidth:2}}),l[u]={taskReferenceName:u,type:"DYNAMIC_PLACEHOLDER"}}return c||(e.forkTasks||[]).forEach((p,f)=>{if(p&&p.length>0){const m=Yn(p,i,{...r,...l},n,!1);s.push(...m.nodes),a.push(...m.edges),Object.assign(l,m.taskMap),i=m.nextId;const h=p[0].taskReferenceName;a.push({id:`e-${e.taskReferenceName}-${h}`,source:e.taskReferenceName,sourceHandle:`branch_${f}`,target:h,label:`分支 ${f+1}`,animated:!0,data:{forkIndex:f},style:{stroke:"var(--cm-cat-control)"}})}}),{nodes:s,edges:a,taskMap:l,nextId:i}}function A0(e,t,r,n="TB",s=!1){const a={},i=e.taskReferenceName,l={id:i,type:"loopNode",data:{label:e.name,taskReferenceName:i,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?J.Position.Right:J.Position.Bottom,targetPosition:n==="LR"?J.Position.Left:J.Position.Top,style:{pointerEvents:"none"}};a[i]=e;const c=e.loopOver||[],d=[],u=[];let p=t+1;if(c.length>0){const f=Yn(c,p,{...r,...a},n,s);if(p=f.nextId,Object.assign(a,f.taskMap),f.nodes.forEach(m=>{d.push({...m,parentId:m.parentId??i,extent:m.parentId?m.extent:"parent"})}),u.push(...f.edges),!s){const m=c[0],h=`__loop_start__${i}`;d.push({id:h,type:"plusNode",parentId:i,extent:"parent",data:{label:"+",taskReferenceName:h,taskType:"PLUS",parentRef:i,edgeData:{isLoopBodyStart:!0,loopId:i},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?J.Position.Right:J.Position.Bottom,targetPosition:n==="LR"?J.Position.Left:J.Position.Top}),u.push({id:`e-${h}-${m.taskReferenceName}`,source:h,target:m.taskReferenceName,animated:!0})}if(!s){const m=c[c.length-1],h=`__loop_end__${i}`;d.push({id:h,type:"plusNode",parentId:i,extent:"parent",data:{label:"+",taskReferenceName:h,taskType:"PLUS",parentRef:m.taskReferenceName,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?J.Position.Right:J.Position.Bottom,targetPosition:n==="LR"?J.Position.Left:J.Position.Top}),u.push({id:`e-${m.taskReferenceName}-${h}`,source:m.taskReferenceName,target:h,animated:!0})}}else if(!s){const f=`${i}_loop_empty_plus`;d.push({id:f,type:"plusNode",parentId:i,extent:"parent",data:{label:"+ 添加",taskReferenceName:f,taskType:"PLUS",parentRef:i,edgeData:{isLoopAdd:!0},layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?J.Position.Right:J.Position.Bottom,targetPosition:n==="LR"?J.Position.Left:J.Position.Top})}return{nodes:[l,...d],edges:u,taskMap:a,nextId:p}}function $0(e,t,r,n="TB"){const s={id:e.taskReferenceName,type:"subWorkflowNode",data:{label:e.name,taskReferenceName:e.taskReferenceName,taskType:e.type,task:e,layoutDirection:n},position:{x:0,y:0},sourcePosition:n==="LR"?J.Position.Right:J.Position.Bottom,targetPosition:n==="LR"?J.Position.Left:J.Position.Top},a={[e.taskReferenceName]:e};return{nodes:[s],edges:[],taskMap:a,nextId:t+1}}function D0(e,t,r,n="TB",s=[],a=!1){const i={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"?J.Position.Right:J.Position.Bottom,targetPosition:n==="LR"?J.Position.Left:J.Position.Top},l={[e.taskReferenceName]:e},c=[],d=[],u=e.joinOn||[];u.forEach(f=>{const m=s.find(h=>h.taskReferenceName===f)||r[f];m&&Vr(m,a).forEach(y=>{d.push({id:`e-${y}-${e.taskReferenceName}`,source:y,target:e.taskReferenceName,animated:!0})})});const p=s.findIndex(f=>f.taskReferenceName===e.taskReferenceName);if(p>0){const f=s[p-1];if(f.type==="FORK_JOIN_DYNAMIC"){const m=`${f.taskReferenceName}_dynamic_placeholder`;d.push({id:`e-${m}-${e.taskReferenceName}-dynamic`,source:m,target:e.taskReferenceName,animated:!0,style:{stroke:"var(--cm-cat-control)",strokeWidth:2,strokeDasharray:"5,5",opacity:.8}})}else f.type==="FORK_JOIN"&&(f.forkTasks||[]).forEach((h,y)=>{if(h&&h.length>0){const x=h[h.length-1];u.includes(x.taskReferenceName)||Vr(x,a).forEach(g=>{const v=`e-${g}-${e.taskReferenceName}`;d.some(k=>k.id===v)||d.push({id:v,source:g,target:e.taskReferenceName,label:"不等待",animated:!1,data:{notJoined:!0},style:{strokeDasharray:"4,4",opacity:.6}})})}if((!h||h.length===0)&&!a){const x=`${f.taskReferenceName}_empty_branch_${y}`;c.push({id:x,type:"plusNode",data:{label:`分支 ${y+1} (空)`,layoutDirection:n,taskReferenceName:x,taskType:"EMPTY_BRANCH",parentRef:f.taskReferenceName,edgeData:{forkIndex:y}},position:{x:0,y:0},sourcePosition:n==="LR"?J.Position.Right:J.Position.Bottom,targetPosition:n==="LR"?J.Position.Left:J.Position.Top,style:{background:"transparent",border:"2px dashed var(--border-secondary)",borderRadius:"8px",padding:"6px 12px",fontSize:"11px",color:"var(--text-muted)",minWidth:"80px",textAlign:"center"}}),d.push({id:`e-${f.taskReferenceName}-${x}`,source:f.taskReferenceName,sourceHandle:`branch_${y}`,target:x,label:`分支 ${y+1}`,animated:!0,data:{forkIndex:y},style:{stroke:"var(--cm-cat-control)",strokeDasharray:"5,5"}}),d.push({id:`e-${x}-${e.taskReferenceName}`,source:x,target:e.taskReferenceName,animated:!0,data:{forkIndex:y,branchParentRef:f.taskReferenceName},style:{strokeDasharray:"5,5"}})}})}return{nodes:[i,...c],edges:d,taskMap:l,nextId:t+1}}function Yn(e,t,r,n="TB",s=!1){const a=[],i=[];let l=t;const c={};for(let d=0;d<e.length;d++){const u=e[d],p={...r,...c},f=tf(u,l,p,n,e,s);if(a.push(...f.nodes),i.push(...f.edges),Object.assign(c,f.taskMap),l=f.nextId,d>0){const m=e[d-1];ba(m,u,i,s)}}return{nodes:a,edges:i,taskMap:c,nextId:l}}function ba(e,t,r,n=!1){if(e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC")return;const s=Vr(e,n),a=t.taskReferenceName,i=e.type==="DECISION"||e.type==="SWITCH";s.forEach(l=>{const c=`e-${l}-${a}`;r.find(d=>d.id===c)||r.push({id:c,source:l,target:a,animated:!0,...i?{data:{exitOf:e.taskReferenceName}}:{}})})}function Vr(e,t=!1){const r=e.type||"SIMPLE";if(r==="DECISION"||r==="SWITCH"){const n=[],s=e.decisionCases||{},a=e.defaultCase||[];if(Object.entries(s).forEach(([i,l])=>{if(l&&l.length>0){const c=l[l.length-1];n.push(...Vr(c,t))}else t||n.push(`${e.taskReferenceName}_empty_${i}`)}),a.length>0){const i=a[a.length-1];n.push(...Vr(i,t))}else t||n.push(`${e.taskReferenceName}_empty_default`);return n.length>0?n:[e.taskReferenceName]}return[e.taskReferenceName]}const ht=E0;function ka(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 wa,rf;function L0(){if(rf)return wa;rf=1;function e(){this.__data__=[],this.size=0}return wa=e,wa}var Sa,nf;function Nr(){if(nf)return Sa;nf=1;function e(t,r){return t===r||t!==t&&r!==r}return Sa=e,Sa}var _a,sf;function Xn(){if(sf)return _a;sf=1;var e=Nr();function t(r,n){for(var s=r.length;s--;)if(e(r[s][0],n))return s;return-1}return _a=t,_a}var ja,af;function M0(){if(af)return ja;af=1;var e=Xn(),t=Array.prototype,r=t.splice;function n(s){var a=this.__data__,i=e(a,s);if(i<0)return!1;var l=a.length-1;return i==l?a.pop():r.call(a,i,1),--this.size,!0}return ja=n,ja}var Ta,of;function W0(){if(of)return Ta;of=1;var e=Xn();function t(r){var n=this.__data__,s=e(n,r);return s<0?void 0:n[s][1]}return Ta=t,Ta}var Ia,lf;function z0(){if(lf)return Ia;lf=1;var e=Xn();function t(r){return e(this.__data__,r)>-1}return Ia=t,Ia}var Na,cf;function q0(){if(cf)return Na;cf=1;var e=Xn();function t(r,n){var s=this.__data__,a=e(s,r);return a<0?(++this.size,s.push([r,n])):s[a][1]=n,this}return Na=t,Na}var Ca,df;function Zn(){if(df)return Ca;df=1;var e=L0(),t=M0(),r=W0(),n=z0(),s=q0();function a(i){var l=-1,c=i==null?0:i.length;for(this.clear();++l<c;){var d=i[l];this.set(d[0],d[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=s,Ca=a,Ca}var Ea,uf;function F0(){if(uf)return Ea;uf=1;var e=Zn();function t(){this.__data__=new e,this.size=0}return Ea=t,Ea}var Ra,pf;function B0(){if(pf)return Ra;pf=1;function e(t){var r=this.__data__,n=r.delete(t);return this.size=r.size,n}return Ra=e,Ra}var Oa,ff;function H0(){if(ff)return Oa;ff=1;function e(t){return this.__data__.get(t)}return Oa=e,Oa}var Pa,mf;function J0(){if(mf)return Pa;mf=1;function e(t){return this.__data__.has(t)}return Pa=e,Pa}var Aa,hf;function yf(){if(hf)return Aa;hf=1;var e=typeof Vn=="object"&&Vn&&Vn.Object===Object&&Vn;return Aa=e,Aa}var $a,gf;function kt(){if(gf)return $a;gf=1;var e=yf(),t=typeof self=="object"&&self&&self.Object===Object&&self,r=e||t||Function("return this")();return $a=r,$a}var Da,xf;function Cr(){if(xf)return Da;xf=1;var e=kt(),t=e.Symbol;return Da=t,Da}var La,vf;function U0(){if(vf)return La;vf=1;var e=Cr(),t=Object.prototype,r=t.hasOwnProperty,n=t.toString,s=e?e.toStringTag:void 0;function a(i){var l=r.call(i,s),c=i[s];try{i[s]=void 0;var d=!0}catch{}var u=n.call(i);return d&&(l?i[s]=c:delete i[s]),u}return La=a,La}var Ma,bf;function V0(){if(bf)return Ma;bf=1;var e=Object.prototype,t=e.toString;function r(n){return t.call(n)}return Ma=r,Ma}var Wa,kf;function fr(){if(kf)return Wa;kf=1;var e=Cr(),t=U0(),r=V0(),n="[object Null]",s="[object Undefined]",a=e?e.toStringTag:void 0;function i(l){return l==null?l===void 0?s:n:a&&a in Object(l)?t(l):r(l)}return Wa=i,Wa}var za,wf;function yt(){if(wf)return za;wf=1;function e(t){var r=typeof t;return t!=null&&(r=="object"||r=="function")}return za=e,za}var qa,Sf;function Kr(){if(Sf)return qa;Sf=1;var e=fr(),t=yt(),r="[object AsyncFunction]",n="[object Function]",s="[object GeneratorFunction]",a="[object Proxy]";function i(l){if(!t(l))return!1;var c=e(l);return c==n||c==s||c==r||c==a}return qa=i,qa}var Fa,_f;function K0(){if(_f)return Fa;_f=1;var e=kt(),t=e["__core-js_shared__"];return Fa=t,Fa}var Ba,jf;function G0(){if(jf)return Ba;jf=1;var e=K0(),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 Ba=r,Ba}var Ha,Tf;function If(){if(Tf)return Ha;Tf=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 Ha=r,Ha}var Ja,Nf;function Y0(){if(Nf)return Ja;Nf=1;var e=Kr(),t=G0(),r=yt(),n=If(),s=/[\\^$.*+?()[\]{}|]/g,a=/^\[object .+?Constructor\]$/,i=Function.prototype,l=Object.prototype,c=i.toString,d=l.hasOwnProperty,u=RegExp("^"+c.call(d).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(f){if(!r(f)||t(f))return!1;var m=e(f)?u:a;return m.test(n(f))}return Ja=p,Ja}var Ua,Cf;function X0(){if(Cf)return Ua;Cf=1;function e(t,r){return t?.[r]}return Ua=e,Ua}var Va,Ef;function mr(){if(Ef)return Va;Ef=1;var e=Y0(),t=X0();function r(n,s){var a=t(n,s);return e(a)?a:void 0}return Va=r,Va}var Ka,Rf;function Ga(){if(Rf)return Ka;Rf=1;var e=mr(),t=kt(),r=e(t,"Map");return Ka=r,Ka}var Ya,Of;function Qn(){if(Of)return Ya;Of=1;var e=mr(),t=e(Object,"create");return Ya=t,Ya}var Xa,Pf;function Z0(){if(Pf)return Xa;Pf=1;var e=Qn();function t(){this.__data__=e?e(null):{},this.size=0}return Xa=t,Xa}var Za,Af;function Q0(){if(Af)return Za;Af=1;function e(t){var r=this.has(t)&&delete this.__data__[t];return this.size-=r?1:0,r}return Za=e,Za}var Qa,$f;function ew(){if($f)return Qa;$f=1;var e=Qn(),t="__lodash_hash_undefined__",r=Object.prototype,n=r.hasOwnProperty;function s(a){var i=this.__data__;if(e){var l=i[a];return l===t?void 0:l}return n.call(i,a)?i[a]:void 0}return Qa=s,Qa}var eo,Df;function tw(){if(Df)return eo;Df=1;var e=Qn(),t=Object.prototype,r=t.hasOwnProperty;function n(s){var a=this.__data__;return e?a[s]!==void 0:r.call(a,s)}return eo=n,eo}var to,Lf;function rw(){if(Lf)return to;Lf=1;var e=Qn(),t="__lodash_hash_undefined__";function r(n,s){var a=this.__data__;return this.size+=this.has(n)?0:1,a[n]=e&&s===void 0?t:s,this}return to=r,to}var ro,Mf;function nw(){if(Mf)return ro;Mf=1;var e=Z0(),t=Q0(),r=ew(),n=tw(),s=rw();function a(i){var l=-1,c=i==null?0:i.length;for(this.clear();++l<c;){var d=i[l];this.set(d[0],d[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=s,ro=a,ro}var no,Wf;function sw(){if(Wf)return no;Wf=1;var e=nw(),t=Zn(),r=Ga();function n(){this.size=0,this.__data__={hash:new e,map:new(r||t),string:new e}}return no=n,no}var so,zf;function aw(){if(zf)return so;zf=1;function e(t){var r=typeof t;return r=="string"||r=="number"||r=="symbol"||r=="boolean"?t!=="__proto__":t===null}return so=e,so}var ao,qf;function es(){if(qf)return ao;qf=1;var e=aw();function t(r,n){var s=r.__data__;return e(n)?s[typeof n=="string"?"string":"hash"]:s.map}return ao=t,ao}var oo,Ff;function ow(){if(Ff)return oo;Ff=1;var e=es();function t(r){var n=e(this,r).delete(r);return this.size-=n?1:0,n}return oo=t,oo}var io,Bf;function iw(){if(Bf)return io;Bf=1;var e=es();function t(r){return e(this,r).get(r)}return io=t,io}var lo,Hf;function lw(){if(Hf)return lo;Hf=1;var e=es();function t(r){return e(this,r).has(r)}return lo=t,lo}var co,Jf;function cw(){if(Jf)return co;Jf=1;var e=es();function t(r,n){var s=e(this,r),a=s.size;return s.set(r,n),this.size+=s.size==a?0:1,this}return co=t,co}var uo,Uf;function po(){if(Uf)return uo;Uf=1;var e=sw(),t=ow(),r=iw(),n=lw(),s=cw();function a(i){var l=-1,c=i==null?0:i.length;for(this.clear();++l<c;){var d=i[l];this.set(d[0],d[1])}}return a.prototype.clear=e,a.prototype.delete=t,a.prototype.get=r,a.prototype.has=n,a.prototype.set=s,uo=a,uo}var fo,Vf;function dw(){if(Vf)return fo;Vf=1;var e=Zn(),t=Ga(),r=po(),n=200;function s(a,i){var l=this.__data__;if(l instanceof e){var c=l.__data__;if(!t||c.length<n-1)return c.push([a,i]),this.size=++l.size,this;l=this.__data__=new r(c)}return l.set(a,i),this.size=l.size,this}return fo=s,fo}var mo,Kf;function ts(){if(Kf)return mo;Kf=1;var e=Zn(),t=F0(),r=B0(),n=H0(),s=J0(),a=dw();function i(l){var c=this.__data__=new e(l);this.size=c.size}return i.prototype.clear=t,i.prototype.delete=r,i.prototype.get=n,i.prototype.has=s,i.prototype.set=a,mo=i,mo}var ho,Gf;function yo(){if(Gf)return ho;Gf=1;function e(t,r){for(var n=-1,s=t==null?0:t.length;++n<s&&r(t[n],n,t)!==!1;);return t}return ho=e,ho}var go,Yf;function Xf(){if(Yf)return go;Yf=1;var e=mr(),t=(function(){try{var r=e(Object,"defineProperty");return r({},"",{}),r}catch{}})();return go=t,go}var xo,Zf;function rs(){if(Zf)return xo;Zf=1;var e=Xf();function t(r,n,s){n=="__proto__"&&e?e(r,n,{configurable:!0,enumerable:!0,value:s,writable:!0}):r[n]=s}return xo=t,xo}var vo,Qf;function ns(){if(Qf)return vo;Qf=1;var e=rs(),t=Nr(),r=Object.prototype,n=r.hasOwnProperty;function s(a,i,l){var c=a[i];(!(n.call(a,i)&&t(c,l))||l===void 0&&!(i in a))&&e(a,i,l)}return vo=s,vo}var bo,em;function Gr(){if(em)return bo;em=1;var e=ns(),t=rs();function r(n,s,a,i){var l=!a;a||(a={});for(var c=-1,d=s.length;++c<d;){var u=s[c],p=i?i(a[u],n[u],u,a,n):void 0;p===void 0&&(p=n[u]),l?t(a,u,p):e(a,u,p)}return a}return bo=r,bo}var ko,tm;function uw(){if(tm)return ko;tm=1;function e(t,r){for(var n=-1,s=Array(t);++n<t;)s[n]=r(n);return s}return ko=e,ko}var wo,rm;function Nt(){if(rm)return wo;rm=1;function e(t){return t!=null&&typeof t=="object"}return wo=e,wo}var So,nm;function pw(){if(nm)return So;nm=1;var e=fr(),t=Nt(),r="[object Arguments]";function n(s){return t(s)&&e(s)==r}return So=n,So}var _o,sm;function Yr(){if(sm)return _o;sm=1;var e=pw(),t=Nt(),r=Object.prototype,n=r.hasOwnProperty,s=r.propertyIsEnumerable,a=e((function(){return arguments})())?e:function(i){return t(i)&&n.call(i,"callee")&&!s.call(i,"callee")};return _o=a,_o}var jo,am;function Ue(){if(am)return jo;am=1;var e=Array.isArray;return jo=e,jo}var Xr={exports:{}},To,om;function fw(){if(om)return To;om=1;function e(){return!1}return To=e,To}Xr.exports;var im;function Er(){return im||(im=1,(function(e,t){var r=kt(),n=fw(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,i=a&&a.exports===s,l=i?r.Buffer:void 0,c=l?l.isBuffer:void 0,d=c||n;e.exports=d})(Xr,Xr.exports)),Xr.exports}var Io,lm;function ss(){if(lm)return Io;lm=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function r(n,s){var a=typeof n;return s=s??e,!!s&&(a=="number"||a!="symbol"&&t.test(n))&&n>-1&&n%1==0&&n<s}return Io=r,Io}var No,cm;function Co(){if(cm)return No;cm=1;var e=9007199254740991;function t(r){return typeof r=="number"&&r>-1&&r%1==0&&r<=e}return No=t,No}var Eo,dm;function mw(){if(dm)return Eo;dm=1;var e=fr(),t=Co(),r=Nt(),n="[object Arguments]",s="[object Array]",a="[object Boolean]",i="[object Date]",l="[object Error]",c="[object Function]",d="[object Map]",u="[object Number]",p="[object Object]",f="[object RegExp]",m="[object Set]",h="[object String]",y="[object WeakMap]",x="[object ArrayBuffer]",g="[object DataView]",v="[object Float32Array]",k="[object Float64Array]",b="[object Int8Array]",S="[object Int16Array]",j="[object Int32Array]",_="[object Uint8Array]",w="[object Uint8ClampedArray]",I="[object Uint16Array]",N="[object Uint32Array]",C={};C[v]=C[k]=C[b]=C[S]=C[j]=C[_]=C[w]=C[I]=C[N]=!0,C[n]=C[s]=C[x]=C[a]=C[g]=C[i]=C[l]=C[c]=C[d]=C[u]=C[p]=C[f]=C[m]=C[h]=C[y]=!1;function M(R){return r(R)&&t(R.length)&&!!C[e(R)]}return Eo=M,Eo}var Ro,um;function as(){if(um)return Ro;um=1;function e(t){return function(r){return t(r)}}return Ro=e,Ro}var Zr={exports:{}};Zr.exports;var pm;function Oo(){return pm||(pm=1,(function(e,t){var r=yf(),n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,i=a&&r.process,l=(function(){try{var c=s&&s.require&&s.require("util").types;return c||i&&i.binding&&i.binding("util")}catch{}})();e.exports=l})(Zr,Zr.exports)),Zr.exports}var Po,fm;function Qr(){if(fm)return Po;fm=1;var e=mw(),t=as(),r=Oo(),n=r&&r.isTypedArray,s=n?t(n):e;return Po=s,Po}var Ao,mm;function hm(){if(mm)return Ao;mm=1;var e=uw(),t=Yr(),r=Ue(),n=Er(),s=ss(),a=Qr(),i=Object.prototype,l=i.hasOwnProperty;function c(d,u){var p=r(d),f=!p&&t(d),m=!p&&!f&&n(d),h=!p&&!f&&!m&&a(d),y=p||f||m||h,x=y?e(d.length,String):[],g=x.length;for(var v in d)(u||l.call(d,v))&&!(y&&(v=="length"||m&&(v=="offset"||v=="parent")||h&&(v=="buffer"||v=="byteLength"||v=="byteOffset")||s(v,g)))&&x.push(v);return x}return Ao=c,Ao}var $o,ym;function os(){if(ym)return $o;ym=1;var e=Object.prototype;function t(r){var n=r&&r.constructor,s=typeof n=="function"&&n.prototype||e;return r===s}return $o=t,$o}var Do,gm;function xm(){if(gm)return Do;gm=1;function e(t,r){return function(n){return t(r(n))}}return Do=e,Do}var Lo,vm;function hw(){if(vm)return Lo;vm=1;var e=xm(),t=e(Object.keys,Object);return Lo=t,Lo}var Mo,bm;function Wo(){if(bm)return Mo;bm=1;var e=os(),t=hw(),r=Object.prototype,n=r.hasOwnProperty;function s(a){if(!e(a))return t(a);var i=[];for(var l in Object(a))n.call(a,l)&&l!="constructor"&&i.push(l);return i}return Mo=s,Mo}var zo,km;function Mt(){if(km)return zo;km=1;var e=Kr(),t=Co();function r(n){return n!=null&&t(n.length)&&!e(n)}return zo=r,zo}var qo,wm;function Zt(){if(wm)return qo;wm=1;var e=hm(),t=Wo(),r=Mt();function n(s){return r(s)?e(s):t(s)}return qo=n,qo}var Fo,Sm;function yw(){if(Sm)return Fo;Sm=1;var e=Gr(),t=Zt();function r(n,s){return n&&e(s,t(s),n)}return Fo=r,Fo}var Bo,_m;function gw(){if(_m)return Bo;_m=1;function e(t){var r=[];if(t!=null)for(var n in Object(t))r.push(n);return r}return Bo=e,Bo}var Ho,jm;function xw(){if(jm)return Ho;jm=1;var e=yt(),t=os(),r=gw(),n=Object.prototype,s=n.hasOwnProperty;function a(i){if(!e(i))return r(i);var l=t(i),c=[];for(var d in i)d=="constructor"&&(l||!s.call(i,d))||c.push(d);return c}return Ho=a,Ho}var Jo,Tm;function hr(){if(Tm)return Jo;Tm=1;var e=hm(),t=xw(),r=Mt();function n(s){return r(s)?e(s,!0):t(s)}return Jo=n,Jo}var Uo,Im;function vw(){if(Im)return Uo;Im=1;var e=Gr(),t=hr();function r(n,s){return n&&e(s,t(s),n)}return Uo=r,Uo}var en={exports:{}};en.exports;var Nm;function Cm(){return Nm||(Nm=1,(function(e,t){var r=kt(),n=t&&!t.nodeType&&t,s=n&&!0&&e&&!e.nodeType&&e,a=s&&s.exports===n,i=a?r.Buffer:void 0,l=i?i.allocUnsafe:void 0;function c(d,u){if(u)return d.slice();var p=d.length,f=l?l(p):new d.constructor(p);return d.copy(f),f}e.exports=c})(en,en.exports)),en.exports}var Vo,Em;function Rm(){if(Em)return Vo;Em=1;function e(t,r){var n=-1,s=t.length;for(r||(r=Array(s));++n<s;)r[n]=t[n];return r}return Vo=e,Vo}var Ko,Om;function Pm(){if(Om)return Ko;Om=1;function e(t,r){for(var n=-1,s=t==null?0:t.length,a=0,i=[];++n<s;){var l=t[n];r(l,n,t)&&(i[a++]=l)}return i}return Ko=e,Ko}var Go,Am;function $m(){if(Am)return Go;Am=1;function e(){return[]}return Go=e,Go}var Yo,Dm;function Xo(){if(Dm)return Yo;Dm=1;var e=Pm(),t=$m(),r=Object.prototype,n=r.propertyIsEnumerable,s=Object.getOwnPropertySymbols,a=s?function(i){return i==null?[]:(i=Object(i),e(s(i),function(l){return n.call(i,l)}))}:t;return Yo=a,Yo}var Zo,Lm;function bw(){if(Lm)return Zo;Lm=1;var e=Gr(),t=Xo();function r(n,s){return e(n,t(n),s)}return Zo=r,Zo}var Qo,Mm;function ei(){if(Mm)return Qo;Mm=1;function e(t,r){for(var n=-1,s=r.length,a=t.length;++n<s;)t[a+n]=r[n];return t}return Qo=e,Qo}var ti,Wm;function is(){if(Wm)return ti;Wm=1;var e=xm(),t=e(Object.getPrototypeOf,Object);return ti=t,ti}var ri,zm;function qm(){if(zm)return ri;zm=1;var e=ei(),t=is(),r=Xo(),n=$m(),s=Object.getOwnPropertySymbols,a=s?function(i){for(var l=[];i;)e(l,r(i)),i=t(i);return l}:n;return ri=a,ri}var ni,Fm;function kw(){if(Fm)return ni;Fm=1;var e=Gr(),t=qm();function r(n,s){return e(n,t(n),s)}return ni=r,ni}var si,Bm;function Hm(){if(Bm)return si;Bm=1;var e=ei(),t=Ue();function r(n,s,a){var i=s(n);return t(n)?i:e(i,a(n))}return si=r,si}var ai,Jm;function Um(){if(Jm)return ai;Jm=1;var e=Hm(),t=Xo(),r=Zt();function n(s){return e(s,r,t)}return ai=n,ai}var oi,Vm;function ww(){if(Vm)return oi;Vm=1;var e=Hm(),t=qm(),r=hr();function n(s){return e(s,r,t)}return oi=n,oi}var ii,Km;function Sw(){if(Km)return ii;Km=1;var e=mr(),t=kt(),r=e(t,"DataView");return ii=r,ii}var li,Gm;function _w(){if(Gm)return li;Gm=1;var e=mr(),t=kt(),r=e(t,"Promise");return li=r,li}var ci,Ym;function Xm(){if(Ym)return ci;Ym=1;var e=mr(),t=kt(),r=e(t,"Set");return ci=r,ci}var di,Zm;function jw(){if(Zm)return di;Zm=1;var e=mr(),t=kt(),r=e(t,"WeakMap");return di=r,di}var ui,Qm;function Rr(){if(Qm)return ui;Qm=1;var e=Sw(),t=Ga(),r=_w(),n=Xm(),s=jw(),a=fr(),i=If(),l="[object Map]",c="[object Object]",d="[object Promise]",u="[object Set]",p="[object WeakMap]",f="[object DataView]",m=i(e),h=i(t),y=i(r),x=i(n),g=i(s),v=a;return(e&&v(new e(new ArrayBuffer(1)))!=f||t&&v(new t)!=l||r&&v(r.resolve())!=d||n&&v(new n)!=u||s&&v(new s)!=p)&&(v=function(k){var b=a(k),S=b==c?k.constructor:void 0,j=S?i(S):"";if(j)switch(j){case m:return f;case h:return l;case y:return d;case x:return u;case g:return p}return b}),ui=v,ui}var pi,eh;function Tw(){if(eh)return pi;eh=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n){var s=n.length,a=new n.constructor(s);return s&&typeof n[0]=="string"&&t.call(n,"index")&&(a.index=n.index,a.input=n.input),a}return pi=r,pi}var fi,th;function rh(){if(th)return fi;th=1;var e=kt(),t=e.Uint8Array;return fi=t,fi}var mi,nh;function hi(){if(nh)return mi;nh=1;var e=rh();function t(r){var n=new r.constructor(r.byteLength);return new e(n).set(new e(r)),n}return mi=t,mi}var yi,sh;function Iw(){if(sh)return yi;sh=1;var e=hi();function t(r,n){var s=n?e(r.buffer):r.buffer;return new r.constructor(s,r.byteOffset,r.byteLength)}return yi=t,yi}var gi,ah;function Nw(){if(ah)return gi;ah=1;var e=/\w*$/;function t(r){var n=new r.constructor(r.source,e.exec(r));return n.lastIndex=r.lastIndex,n}return gi=t,gi}var xi,oh;function Cw(){if(oh)return xi;oh=1;var e=Cr(),t=e?e.prototype:void 0,r=t?t.valueOf:void 0;function n(s){return r?Object(r.call(s)):{}}return xi=n,xi}var vi,ih;function lh(){if(ih)return vi;ih=1;var e=hi();function t(r,n){var s=n?e(r.buffer):r.buffer;return new r.constructor(s,r.byteOffset,r.length)}return vi=t,vi}var bi,ch;function Ew(){if(ch)return bi;ch=1;var e=hi(),t=Iw(),r=Nw(),n=Cw(),s=lh(),a="[object Boolean]",i="[object Date]",l="[object Map]",c="[object Number]",d="[object RegExp]",u="[object Set]",p="[object String]",f="[object Symbol]",m="[object ArrayBuffer]",h="[object DataView]",y="[object Float32Array]",x="[object Float64Array]",g="[object Int8Array]",v="[object Int16Array]",k="[object Int32Array]",b="[object Uint8Array]",S="[object Uint8ClampedArray]",j="[object Uint16Array]",_="[object Uint32Array]";function w(I,N,C){var M=I.constructor;switch(N){case m:return e(I);case a:case i:return new M(+I);case h:return t(I,C);case y:case x:case g:case v:case k:case b:case S:case j:case _:return s(I,C);case l:return new M;case c:case p:return new M(I);case d:return r(I);case u:return new M;case f:return n(I)}}return bi=w,bi}var ki,dh;function uh(){if(dh)return ki;dh=1;var e=yt(),t=Object.create,r=(function(){function n(){}return function(s){if(!e(s))return{};if(t)return t(s);n.prototype=s;var a=new n;return n.prototype=void 0,a}})();return ki=r,ki}var wi,ph;function fh(){if(ph)return wi;ph=1;var e=uh(),t=is(),r=os();function n(s){return typeof s.constructor=="function"&&!r(s)?e(t(s)):{}}return wi=n,wi}var Si,mh;function Rw(){if(mh)return Si;mh=1;var e=Rr(),t=Nt(),r="[object Map]";function n(s){return t(s)&&e(s)==r}return Si=n,Si}var _i,hh;function Ow(){if(hh)return _i;hh=1;var e=Rw(),t=as(),r=Oo(),n=r&&r.isMap,s=n?t(n):e;return _i=s,_i}var ji,yh;function Pw(){if(yh)return ji;yh=1;var e=Rr(),t=Nt(),r="[object Set]";function n(s){return t(s)&&e(s)==r}return ji=n,ji}var Ti,gh;function Aw(){if(gh)return Ti;gh=1;var e=Pw(),t=as(),r=Oo(),n=r&&r.isSet,s=n?t(n):e;return Ti=s,Ti}var Ii,xh;function vh(){if(xh)return Ii;xh=1;var e=ts(),t=yo(),r=ns(),n=yw(),s=vw(),a=Cm(),i=Rm(),l=bw(),c=kw(),d=Um(),u=ww(),p=Rr(),f=Tw(),m=Ew(),h=fh(),y=Ue(),x=Er(),g=Ow(),v=yt(),k=Aw(),b=Zt(),S=hr(),j=1,_=2,w=4,I="[object Arguments]",N="[object Array]",C="[object Boolean]",M="[object Date]",R="[object Error]",O="[object Function]",$="[object GeneratorFunction]",B="[object Map]",q="[object Number]",F="[object Object]",A="[object RegExp]",W="[object Set]",P="[object String]",D="[object Symbol]",Z="[object WeakMap]",L="[object ArrayBuffer]",H="[object DataView]",U="[object Float32Array]",K="[object Float64Array]",se="[object Int8Array]",pe="[object Int16Array]",we="[object Int32Array]",Ce="[object Uint8Array]",ne="[object Uint8ClampedArray]",Te="[object Uint16Array]",le="[object Uint32Array]",V={};V[I]=V[N]=V[L]=V[H]=V[C]=V[M]=V[U]=V[K]=V[se]=V[pe]=V[we]=V[B]=V[q]=V[F]=V[A]=V[W]=V[P]=V[D]=V[Ce]=V[ne]=V[Te]=V[le]=!0,V[R]=V[O]=V[Z]=!1;function X(z,ve,he,_e,Se,be){var ce,Re=ve&j,De=ve&_,Je=ve&w;if(he&&(ce=Se?he(z,_e,Se,be):he(z)),ce!==void 0)return ce;if(!v(z))return z;var ee=y(z);if(ee){if(ce=f(z),!Re)return i(z,ce)}else{var ue=p(z),ie=ue==O||ue==$;if(x(z))return a(z,Re);if(ue==F||ue==I||ie&&!Se){if(ce=De||ie?{}:h(z),!Re)return De?c(z,s(ce,z)):l(z,n(ce,z))}else{if(!V[ue])return Se?z:{};ce=m(z,ue,Re)}}be||(be=new e);var ge=be.get(z);if(ge)return ge;be.set(z,ce),k(z)?z.forEach(function(Oe){ce.add(X(Oe,ve,he,Oe,z,be))}):g(z)&&z.forEach(function(Oe,ke){ce.set(ke,X(Oe,ve,he,ke,z,be))});var re=Je?De?u:d:De?S:b,Ie=ee?void 0:re(z);return t(Ie||z,function(Oe,ke){Ie&&(ke=Oe,Oe=z[ke]),r(ce,ke,X(Oe,ve,he,ke,z,be))}),ce}return Ii=X,Ii}var Ni,bh;function $w(){if(bh)return Ni;bh=1;var e=vh(),t=4;function r(n){return e(n,t)}return Ni=r,Ni}var Ci,kh;function Ei(){if(kh)return Ci;kh=1;function e(t){return function(){return t}}return Ci=e,Ci}var Ri,wh;function Dw(){if(wh)return Ri;wh=1;function e(t){return function(r,n,s){for(var a=-1,i=Object(r),l=s(r),c=l.length;c--;){var d=l[t?c:++a];if(n(i[d],d,i)===!1)break}return r}}return Ri=e,Ri}var Oi,Sh;function Pi(){if(Sh)return Oi;Sh=1;var e=Dw(),t=e();return Oi=t,Oi}var Ai,_h;function $i(){if(_h)return Ai;_h=1;var e=Pi(),t=Zt();function r(n,s){return n&&e(n,s,t)}return Ai=r,Ai}var Di,jh;function Lw(){if(jh)return Di;jh=1;var e=Mt();function t(r,n){return function(s,a){if(s==null)return s;if(!e(s))return r(s,a);for(var i=s.length,l=n?i:-1,c=Object(s);(n?l--:++l<i)&&a(c[l],l,c)!==!1;);return s}}return Di=t,Di}var Li,Th;function ls(){if(Th)return Li;Th=1;var e=$i(),t=Lw(),r=t(e);return Li=r,Li}var Mi,Ih;function yr(){if(Ih)return Mi;Ih=1;function e(t){return t}return Mi=e,Mi}var Wi,Nh;function Ch(){if(Nh)return Wi;Nh=1;var e=yr();function t(r){return typeof r=="function"?r:e}return Wi=t,Wi}var zi,Eh;function Rh(){if(Eh)return zi;Eh=1;var e=yo(),t=ls(),r=Ch(),n=Ue();function s(a,i){var l=n(a)?e:t;return l(a,r(i))}return zi=s,zi}var qi,Oh;function Ph(){return Oh||(Oh=1,qi=Rh()),qi}var Fi,Ah;function Mw(){if(Ah)return Fi;Ah=1;var e=ls();function t(r,n){var s=[];return e(r,function(a,i,l){n(a,i,l)&&s.push(a)}),s}return Fi=t,Fi}var Bi,$h;function Ww(){if($h)return Bi;$h=1;var e="__lodash_hash_undefined__";function t(r){return this.__data__.set(r,e),this}return Bi=t,Bi}var Hi,Dh;function zw(){if(Dh)return Hi;Dh=1;function e(t){return this.__data__.has(t)}return Hi=e,Hi}var Ji,Lh;function Mh(){if(Lh)return Ji;Lh=1;var e=po(),t=Ww(),r=zw();function n(s){var a=-1,i=s==null?0:s.length;for(this.__data__=new e;++a<i;)this.add(s[a])}return n.prototype.add=n.prototype.push=t,n.prototype.has=r,Ji=n,Ji}var Ui,Wh;function qw(){if(Wh)return Ui;Wh=1;function e(t,r){for(var n=-1,s=t==null?0:t.length;++n<s;)if(r(t[n],n,t))return!0;return!1}return Ui=e,Ui}var Vi,zh;function qh(){if(zh)return Vi;zh=1;function e(t,r){return t.has(r)}return Vi=e,Vi}var Ki,Fh;function Bh(){if(Fh)return Ki;Fh=1;var e=Mh(),t=qw(),r=qh(),n=1,s=2;function a(i,l,c,d,u,p){var f=c&n,m=i.length,h=l.length;if(m!=h&&!(f&&h>m))return!1;var y=p.get(i),x=p.get(l);if(y&&x)return y==l&&x==i;var g=-1,v=!0,k=c&s?new e:void 0;for(p.set(i,l),p.set(l,i);++g<m;){var b=i[g],S=l[g];if(d)var j=f?d(S,b,g,l,i,p):d(b,S,g,i,l,p);if(j!==void 0){if(j)continue;v=!1;break}if(k){if(!t(l,function(_,w){if(!r(k,w)&&(b===_||u(b,_,c,d,p)))return k.push(w)})){v=!1;break}}else if(!(b===S||u(b,S,c,d,p))){v=!1;break}}return p.delete(i),p.delete(l),v}return Ki=a,Ki}var Gi,Hh;function Fw(){if(Hh)return Gi;Hh=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(s,a){n[++r]=[a,s]}),n}return Gi=e,Gi}var Yi,Jh;function Xi(){if(Jh)return Yi;Jh=1;function e(t){var r=-1,n=Array(t.size);return t.forEach(function(s){n[++r]=s}),n}return Yi=e,Yi}var Zi,Uh;function Bw(){if(Uh)return Zi;Uh=1;var e=Cr(),t=rh(),r=Nr(),n=Bh(),s=Fw(),a=Xi(),i=1,l=2,c="[object Boolean]",d="[object Date]",u="[object Error]",p="[object Map]",f="[object Number]",m="[object RegExp]",h="[object Set]",y="[object String]",x="[object Symbol]",g="[object ArrayBuffer]",v="[object DataView]",k=e?e.prototype:void 0,b=k?k.valueOf:void 0;function S(j,_,w,I,N,C,M){switch(w){case v:if(j.byteLength!=_.byteLength||j.byteOffset!=_.byteOffset)return!1;j=j.buffer,_=_.buffer;case g:return!(j.byteLength!=_.byteLength||!C(new t(j),new t(_)));case c:case d:case f:return r(+j,+_);case u:return j.name==_.name&&j.message==_.message;case m:case y:return j==_+"";case p:var R=s;case h:var O=I&i;if(R||(R=a),j.size!=_.size&&!O)return!1;var $=M.get(j);if($)return $==_;I|=l,M.set(j,_);var B=n(R(j),R(_),I,N,C,M);return M.delete(j),B;case x:if(b)return b.call(j)==b.call(_)}return!1}return Zi=S,Zi}var Qi,Vh;function Hw(){if(Vh)return Qi;Vh=1;var e=Um(),t=1,r=Object.prototype,n=r.hasOwnProperty;function s(a,i,l,c,d,u){var p=l&t,f=e(a),m=f.length,h=e(i),y=h.length;if(m!=y&&!p)return!1;for(var x=m;x--;){var g=f[x];if(!(p?g in i:n.call(i,g)))return!1}var v=u.get(a),k=u.get(i);if(v&&k)return v==i&&k==a;var b=!0;u.set(a,i),u.set(i,a);for(var S=p;++x<m;){g=f[x];var j=a[g],_=i[g];if(c)var w=p?c(_,j,g,i,a,u):c(j,_,g,a,i,u);if(!(w===void 0?j===_||d(j,_,l,c,u):w)){b=!1;break}S||(S=g=="constructor")}if(b&&!S){var I=a.constructor,N=i.constructor;I!=N&&"constructor"in a&&"constructor"in i&&!(typeof I=="function"&&I instanceof I&&typeof N=="function"&&N instanceof N)&&(b=!1)}return u.delete(a),u.delete(i),b}return Qi=s,Qi}var el,Kh;function Jw(){if(Kh)return el;Kh=1;var e=ts(),t=Bh(),r=Bw(),n=Hw(),s=Rr(),a=Ue(),i=Er(),l=Qr(),c=1,d="[object Arguments]",u="[object Array]",p="[object Object]",f=Object.prototype,m=f.hasOwnProperty;function h(y,x,g,v,k,b){var S=a(y),j=a(x),_=S?u:s(y),w=j?u:s(x);_=_==d?p:_,w=w==d?p:w;var I=_==p,N=w==p,C=_==w;if(C&&i(y)){if(!i(x))return!1;S=!0,I=!1}if(C&&!I)return b||(b=new e),S||l(y)?t(y,x,g,v,k,b):r(y,x,_,g,v,k,b);if(!(g&c)){var M=I&&m.call(y,"__wrapped__"),R=N&&m.call(x,"__wrapped__");if(M||R){var O=M?y.value():y,$=R?x.value():x;return b||(b=new e),k(O,$,g,v,b)}}return C?(b||(b=new e),n(y,x,g,v,k,b)):!1}return el=h,el}var tl,Gh;function Yh(){if(Gh)return tl;Gh=1;var e=Jw(),t=Nt();function r(n,s,a,i,l){return n===s?!0:n==null||s==null||!t(n)&&!t(s)?n!==n&&s!==s:e(n,s,a,i,r,l)}return tl=r,tl}var rl,Xh;function Uw(){if(Xh)return rl;Xh=1;var e=ts(),t=Yh(),r=1,n=2;function s(a,i,l,c){var d=l.length,u=d,p=!c;if(a==null)return!u;for(a=Object(a);d--;){var f=l[d];if(p&&f[2]?f[1]!==a[f[0]]:!(f[0]in a))return!1}for(;++d<u;){f=l[d];var m=f[0],h=a[m],y=f[1];if(p&&f[2]){if(h===void 0&&!(m in a))return!1}else{var x=new e;if(c)var g=c(h,y,m,a,i,x);if(!(g===void 0?t(y,h,r|n,c,x):g))return!1}}return!0}return rl=s,rl}var nl,Zh;function Qh(){if(Zh)return nl;Zh=1;var e=yt();function t(r){return r===r&&!e(r)}return nl=t,nl}var sl,ey;function Vw(){if(ey)return sl;ey=1;var e=Qh(),t=Zt();function r(n){for(var s=t(n),a=s.length;a--;){var i=s[a],l=n[i];s[a]=[i,l,e(l)]}return s}return sl=r,sl}var al,ty;function ry(){if(ty)return al;ty=1;function e(t,r){return function(n){return n==null?!1:n[t]===r&&(r!==void 0||t in Object(n))}}return al=e,al}var ol,ny;function Kw(){if(ny)return ol;ny=1;var e=Uw(),t=Vw(),r=ry();function n(s){var a=t(s);return a.length==1&&a[0][2]?r(a[0][0],a[0][1]):function(i){return i===s||e(i,s,a)}}return ol=n,ol}var il,sy;function Or(){if(sy)return il;sy=1;var e=fr(),t=Nt(),r="[object Symbol]";function n(s){return typeof s=="symbol"||t(s)&&e(s)==r}return il=n,il}var ll,ay;function cl(){if(ay)return ll;ay=1;var e=Ue(),t=Or(),r=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,n=/^\w*$/;function s(a,i){if(e(a))return!1;var l=typeof a;return l=="number"||l=="symbol"||l=="boolean"||a==null||t(a)?!0:n.test(a)||!r.test(a)||i!=null&&a in Object(i)}return ll=s,ll}var dl,oy;function Gw(){if(oy)return dl;oy=1;var e=po(),t="Expected a function";function r(n,s){if(typeof n!="function"||s!=null&&typeof s!="function")throw new TypeError(t);var a=function(){var i=arguments,l=s?s.apply(this,i):i[0],c=a.cache;if(c.has(l))return c.get(l);var d=n.apply(this,i);return a.cache=c.set(l,d)||c,d};return a.cache=new(r.Cache||e),a}return r.Cache=e,dl=r,dl}var ul,iy;function Yw(){if(iy)return ul;iy=1;var e=Gw(),t=500;function r(n){var s=e(n,function(i){return a.size===t&&a.clear(),i}),a=s.cache;return s}return ul=r,ul}var pl,ly;function Xw(){if(ly)return pl;ly=1;var e=Yw(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,r=/\\(\\)?/g,n=e(function(s){var a=[];return s.charCodeAt(0)===46&&a.push(""),s.replace(t,function(i,l,c,d){a.push(c?d.replace(r,"$1"):l||i)}),a});return pl=n,pl}var fl,cy;function cs(){if(cy)return fl;cy=1;function e(t,r){for(var n=-1,s=t==null?0:t.length,a=Array(s);++n<s;)a[n]=r(t[n],n,t);return a}return fl=e,fl}var ml,dy;function Zw(){if(dy)return ml;dy=1;var e=Cr(),t=cs(),r=Ue(),n=Or(),s=e?e.prototype:void 0,a=s?s.toString:void 0;function i(l){if(typeof l=="string")return l;if(r(l))return t(l,i)+"";if(n(l))return a?a.call(l):"";var c=l+"";return c=="0"&&1/l==-1/0?"-0":c}return ml=i,ml}var hl,uy;function py(){if(uy)return hl;uy=1;var e=Zw();function t(r){return r==null?"":e(r)}return hl=t,hl}var yl,fy;function ds(){if(fy)return yl;fy=1;var e=Ue(),t=cl(),r=Xw(),n=py();function s(a,i){return e(a)?a:t(a,i)?[a]:r(n(a))}return yl=s,yl}var gl,my;function tn(){if(my)return gl;my=1;var e=Or();function t(r){if(typeof r=="string"||e(r))return r;var n=r+"";return n=="0"&&1/r==-1/0?"-0":n}return gl=t,gl}var xl,hy;function us(){if(hy)return xl;hy=1;var e=ds(),t=tn();function r(n,s){s=e(s,n);for(var a=0,i=s.length;n!=null&&a<i;)n=n[t(s[a++])];return a&&a==i?n:void 0}return xl=r,xl}var vl,yy;function Qw(){if(yy)return vl;yy=1;var e=us();function t(r,n,s){var a=r==null?void 0:e(r,n);return a===void 0?s:a}return vl=t,vl}var bl,gy;function eS(){if(gy)return bl;gy=1;function e(t,r){return t!=null&&r in Object(t)}return bl=e,bl}var kl,xy;function vy(){if(xy)return kl;xy=1;var e=ds(),t=Yr(),r=Ue(),n=ss(),s=Co(),a=tn();function i(l,c,d){c=e(c,l);for(var u=-1,p=c.length,f=!1;++u<p;){var m=a(c[u]);if(!(f=l!=null&&d(l,m)))break;l=l[m]}return f||++u!=p?f:(p=l==null?0:l.length,!!p&&s(p)&&n(m,p)&&(r(l)||t(l)))}return kl=i,kl}var wl,by;function ky(){if(by)return wl;by=1;var e=eS(),t=vy();function r(n,s){return n!=null&&t(n,s,e)}return wl=r,wl}var Sl,wy;function tS(){if(wy)return Sl;wy=1;var e=Yh(),t=Qw(),r=ky(),n=cl(),s=Qh(),a=ry(),i=tn(),l=1,c=2;function d(u,p){return n(u)&&s(p)?a(i(u),p):function(f){var m=t(f,u);return m===void 0&&m===p?r(f,u):e(p,m,l|c)}}return Sl=d,Sl}var _l,Sy;function _y(){if(Sy)return _l;Sy=1;function e(t){return function(r){return r?.[t]}}return _l=e,_l}var jl,jy;function rS(){if(jy)return jl;jy=1;var e=us();function t(r){return function(n){return e(n,r)}}return jl=t,jl}var Tl,Ty;function nS(){if(Ty)return Tl;Ty=1;var e=_y(),t=rS(),r=cl(),n=tn();function s(a){return r(a)?e(n(a)):t(a)}return Tl=s,Tl}var Il,Iy;function Wt(){if(Iy)return Il;Iy=1;var e=Kw(),t=tS(),r=yr(),n=Ue(),s=nS();function a(i){return typeof i=="function"?i:i==null?r:typeof i=="object"?n(i)?t(i[0],i[1]):e(i):s(i)}return Il=a,Il}var Nl,Ny;function Cy(){if(Ny)return Nl;Ny=1;var e=Pm(),t=Mw(),r=Wt(),n=Ue();function s(a,i){var l=n(a)?e:t;return l(a,r(i,3))}return Nl=s,Nl}var Cl,Ey;function sS(){if(Ey)return Cl;Ey=1;var e=Object.prototype,t=e.hasOwnProperty;function r(n,s){return n!=null&&t.call(n,s)}return Cl=r,Cl}var El,Ry;function Oy(){if(Ry)return El;Ry=1;var e=sS(),t=vy();function r(n,s){return n!=null&&t(n,s,e)}return El=r,El}var Rl,Py;function aS(){if(Py)return Rl;Py=1;var e=Wo(),t=Rr(),r=Yr(),n=Ue(),s=Mt(),a=Er(),i=os(),l=Qr(),c="[object Map]",d="[object Set]",u=Object.prototype,p=u.hasOwnProperty;function f(m){if(m==null)return!0;if(s(m)&&(n(m)||typeof m=="string"||typeof m.splice=="function"||a(m)||l(m)||r(m)))return!m.length;var h=t(m);if(h==c||h==d)return!m.size;if(i(m))return!e(m).length;for(var y in m)if(p.call(m,y))return!1;return!0}return Rl=f,Rl}var Ol,Ay;function $y(){if(Ay)return Ol;Ay=1;function e(t){return t===void 0}return Ol=e,Ol}var Pl,Dy;function Ly(){if(Dy)return Pl;Dy=1;var e=ls(),t=Mt();function r(n,s){var a=-1,i=t(n)?Array(n.length):[];return e(n,function(l,c,d){i[++a]=s(l,c,d)}),i}return Pl=r,Pl}var Al,My;function Wy(){if(My)return Al;My=1;var e=cs(),t=Wt(),r=Ly(),n=Ue();function s(a,i){var l=n(a)?e:r;return l(a,t(i,3))}return Al=s,Al}var $l,zy;function oS(){if(zy)return $l;zy=1;function e(t,r,n,s){var a=-1,i=t==null?0:t.length;for(s&&i&&(n=t[++a]);++a<i;)n=r(n,t[a],a,t);return n}return $l=e,$l}var Dl,qy;function iS(){if(qy)return Dl;qy=1;function e(t,r,n,s,a){return a(t,function(i,l,c){n=s?(s=!1,i):r(n,i,l,c)}),n}return Dl=e,Dl}var Ll,Fy;function By(){if(Fy)return Ll;Fy=1;var e=oS(),t=ls(),r=Wt(),n=iS(),s=Ue();function a(i,l,c){var d=s(i)?e:n,u=arguments.length<3;return d(i,r(l,4),c,u,t)}return Ll=a,Ll}var Ml,Hy;function lS(){if(Hy)return Ml;Hy=1;var e=fr(),t=Ue(),r=Nt(),n="[object String]";function s(a){return typeof a=="string"||!t(a)&&r(a)&&e(a)==n}return Ml=s,Ml}var Wl,Jy;function cS(){if(Jy)return Wl;Jy=1;var e=_y(),t=e("length");return Wl=t,Wl}var zl,Uy;function dS(){if(Uy)return zl;Uy=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",s=t+r+n,a="\\ufe0e\\ufe0f",i="\\u200d",l=RegExp("["+i+e+s+a+"]");function c(d){return l.test(d)}return zl=c,zl}var ql,Vy;function uS(){if(Vy)return ql;Vy=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",r="\\ufe20-\\ufe2f",n="\\u20d0-\\u20ff",s=t+r+n,a="\\ufe0e\\ufe0f",i="["+e+"]",l="["+s+"]",c="\\ud83c[\\udffb-\\udfff]",d="(?:"+l+"|"+c+")",u="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",f="[\\ud800-\\udbff][\\udc00-\\udfff]",m="\\u200d",h=d+"?",y="["+a+"]?",x="(?:"+m+"(?:"+[u,p,f].join("|")+")"+y+h+")*",g=y+h+x,v="(?:"+[u+l+"?",l,p,f,i].join("|")+")",k=RegExp(c+"(?="+c+")|"+v+g,"g");function b(S){for(var j=k.lastIndex=0;k.test(S);)++j;return j}return ql=b,ql}var Fl,Ky;function pS(){if(Ky)return Fl;Ky=1;var e=cS(),t=dS(),r=uS();function n(s){return t(s)?r(s):e(s)}return Fl=n,Fl}var Bl,Gy;function fS(){if(Gy)return Bl;Gy=1;var e=Wo(),t=Rr(),r=Mt(),n=lS(),s=pS(),a="[object Map]",i="[object Set]";function l(c){if(c==null)return 0;if(r(c))return n(c)?s(c):c.length;var d=t(c);return d==a||d==i?c.size:e(c).length}return Bl=l,Bl}var Hl,Yy;function mS(){if(Yy)return Hl;Yy=1;var e=yo(),t=uh(),r=$i(),n=Wt(),s=is(),a=Ue(),i=Er(),l=Kr(),c=yt(),d=Qr();function u(p,f,m){var h=a(p),y=h||i(p)||d(p);if(f=n(f,4),m==null){var x=p&&p.constructor;y?m=h?new x:[]:c(p)?m=l(x)?t(s(p)):{}:m={}}return(y?e:r)(p,function(g,v,k){return f(m,g,v,k)}),m}return Hl=u,Hl}var Jl,Xy;function hS(){if(Xy)return Jl;Xy=1;var e=Cr(),t=Yr(),r=Ue(),n=e?e.isConcatSpreadable:void 0;function s(a){return r(a)||t(a)||!!(n&&a&&a[n])}return Jl=s,Jl}var Ul,Zy;function Vl(){if(Zy)return Ul;Zy=1;var e=ei(),t=hS();function r(n,s,a,i,l){var c=-1,d=n.length;for(a||(a=t),l||(l=[]);++c<d;){var u=n[c];s>0&&a(u)?s>1?r(u,s-1,a,i,l):e(l,u):i||(l[l.length]=u)}return l}return Ul=r,Ul}var Kl,Qy;function yS(){if(Qy)return Kl;Qy=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 Kl=e,Kl}var Gl,eg;function tg(){if(eg)return Gl;eg=1;var e=yS(),t=Math.max;function r(n,s,a){return s=t(s===void 0?n.length-1:s,0),function(){for(var i=arguments,l=-1,c=t(i.length-s,0),d=Array(c);++l<c;)d[l]=i[s+l];l=-1;for(var u=Array(s+1);++l<s;)u[l]=i[l];return u[s]=a(d),e(n,this,u)}}return Gl=r,Gl}var Yl,rg;function gS(){if(rg)return Yl;rg=1;var e=Ei(),t=Xf(),r=yr(),n=t?function(s,a){return t(s,"toString",{configurable:!0,enumerable:!1,value:e(a),writable:!0})}:r;return Yl=n,Yl}var Xl,ng;function xS(){if(ng)return Xl;ng=1;var e=800,t=16,r=Date.now;function n(s){var a=0,i=0;return function(){var l=r(),c=t-(l-i);if(i=l,c>0){if(++a>=e)return arguments[0]}else a=0;return s.apply(void 0,arguments)}}return Xl=n,Xl}var Zl,sg;function ag(){if(sg)return Zl;sg=1;var e=gS(),t=xS(),r=t(e);return Zl=r,Zl}var Ql,og;function ps(){if(og)return Ql;og=1;var e=yr(),t=tg(),r=ag();function n(s,a){return r(t(s,a,e),s+"")}return Ql=n,Ql}var ec,ig;function lg(){if(ig)return ec;ig=1;function e(t,r,n,s){for(var a=t.length,i=n+(s?1:-1);s?i--:++i<a;)if(r(t[i],i,t))return i;return-1}return ec=e,ec}var tc,cg;function vS(){if(cg)return tc;cg=1;function e(t){return t!==t}return tc=e,tc}var rc,dg;function bS(){if(dg)return rc;dg=1;function e(t,r,n){for(var s=n-1,a=t.length;++s<a;)if(t[s]===r)return s;return-1}return rc=e,rc}var nc,ug;function kS(){if(ug)return nc;ug=1;var e=lg(),t=vS(),r=bS();function n(s,a,i){return a===a?r(s,a,i):e(s,t,i)}return nc=n,nc}var sc,pg;function wS(){if(pg)return sc;pg=1;var e=kS();function t(r,n){var s=r==null?0:r.length;return!!s&&e(r,n,0)>-1}return sc=t,sc}var ac,fg;function SS(){if(fg)return ac;fg=1;function e(t,r,n){for(var s=-1,a=t==null?0:t.length;++s<a;)if(n(r,t[s]))return!0;return!1}return ac=e,ac}var oc,mg;function _S(){if(mg)return oc;mg=1;function e(){}return oc=e,oc}var ic,hg;function jS(){if(hg)return ic;hg=1;var e=Xm(),t=_S(),r=Xi(),n=1/0,s=e&&1/r(new e([,-0]))[1]==n?function(a){return new e(a)}:t;return ic=s,ic}var lc,yg;function TS(){if(yg)return lc;yg=1;var e=Mh(),t=wS(),r=SS(),n=qh(),s=jS(),a=Xi(),i=200;function l(c,d,u){var p=-1,f=t,m=c.length,h=!0,y=[],x=y;if(u)h=!1,f=r;else if(m>=i){var g=d?null:s(c);if(g)return a(g);h=!1,f=n,x=new e}else x=d?[]:y;e:for(;++p<m;){var v=c[p],k=d?d(v):v;if(v=u||v!==0?v:0,h&&k===k){for(var b=x.length;b--;)if(x[b]===k)continue e;d&&x.push(k),y.push(v)}else f(x,k,u)||(x!==y&&x.push(k),y.push(v))}return y}return lc=l,lc}var cc,gg;function xg(){if(gg)return cc;gg=1;var e=Mt(),t=Nt();function r(n){return t(n)&&e(n)}return cc=r,cc}var dc,vg;function IS(){if(vg)return dc;vg=1;var e=Vl(),t=ps(),r=TS(),n=xg(),s=t(function(a){return r(e(a,1,n,!0))});return dc=s,dc}var uc,bg;function NS(){if(bg)return uc;bg=1;var e=cs();function t(r,n){return e(n,function(s){return r[s]})}return uc=t,uc}var pc,kg;function wg(){if(kg)return pc;kg=1;var e=NS(),t=Zt();function r(n){return n==null?[]:e(n,t(n))}return pc=r,pc}var fc,Sg;function gt(){if(Sg)return fc;Sg=1;var e;if(typeof ka=="function")try{e={clone:$w(),constant:Ei(),each:Ph(),filter:Cy(),has:Oy(),isArray:Ue(),isEmpty:aS(),isFunction:Kr(),isUndefined:$y(),keys:Zt(),map:Wy(),reduce:By(),size:fS(),transform:mS(),union:IS(),values:wg()}}catch{}return e||(e=window._),fc=e,fc}var mc,_g;function hc(){if(_g)return mc;_g=1;var e=gt();mc=s;var t="\0",r="\0",n="";function s(u){this._isDirected=e.has(u,"directed")?u.directed:!0,this._isMultigraph=e.has(u,"multigraph")?u.multigraph:!1,this._isCompound=e.has(u,"compound")?u.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[r]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(u){return this._label=u,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(u){return e.isFunction(u)||(u=e.constant(u)),this._defaultNodeLabelFn=u,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var u=this;return e.filter(this.nodes(),function(p){return e.isEmpty(u._in[p])})},s.prototype.sinks=function(){var u=this;return e.filter(this.nodes(),function(p){return e.isEmpty(u._out[p])})},s.prototype.setNodes=function(u,p){var f=arguments,m=this;return e.each(u,function(h){f.length>1?m.setNode(h,p):m.setNode(h)}),this},s.prototype.setNode=function(u,p){return e.has(this._nodes,u)?(arguments.length>1&&(this._nodes[u]=p),this):(this._nodes[u]=arguments.length>1?p:this._defaultNodeLabelFn(u),this._isCompound&&(this._parent[u]=r,this._children[u]={},this._children[r][u]=!0),this._in[u]={},this._preds[u]={},this._out[u]={},this._sucs[u]={},++this._nodeCount,this)},s.prototype.node=function(u){return this._nodes[u]},s.prototype.hasNode=function(u){return e.has(this._nodes,u)},s.prototype.removeNode=function(u){var p=this;if(e.has(this._nodes,u)){var f=function(m){p.removeEdge(p._edgeObjs[m])};delete this._nodes[u],this._isCompound&&(this._removeFromParentsChildList(u),delete this._parent[u],e.each(this.children(u),function(m){p.setParent(m)}),delete this._children[u]),e.each(e.keys(this._in[u]),f),delete this._in[u],delete this._preds[u],e.each(e.keys(this._out[u]),f),delete this._out[u],delete this._sucs[u],--this._nodeCount}return this},s.prototype.setParent=function(u,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(p))p=r;else{p+="";for(var f=p;!e.isUndefined(f);f=this.parent(f))if(f===u)throw new Error("Setting "+p+" as parent of "+u+" would create a cycle");this.setNode(p)}return this.setNode(u),this._removeFromParentsChildList(u),this._parent[u]=p,this._children[p][u]=!0,this},s.prototype._removeFromParentsChildList=function(u){delete this._children[this._parent[u]][u]},s.prototype.parent=function(u){if(this._isCompound){var p=this._parent[u];if(p!==r)return p}},s.prototype.children=function(u){if(e.isUndefined(u)&&(u=r),this._isCompound){var p=this._children[u];if(p)return e.keys(p)}else{if(u===r)return this.nodes();if(this.hasNode(u))return[]}},s.prototype.predecessors=function(u){var p=this._preds[u];if(p)return e.keys(p)},s.prototype.successors=function(u){var p=this._sucs[u];if(p)return e.keys(p)},s.prototype.neighbors=function(u){var p=this.predecessors(u);if(p)return e.union(p,this.successors(u))},s.prototype.isLeaf=function(u){var p;return this.isDirected()?p=this.successors(u):p=this.neighbors(u),p.length===0},s.prototype.filterNodes=function(u){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var f=this;e.each(this._nodes,function(y,x){u(x)&&p.setNode(x,y)}),e.each(this._edgeObjs,function(y){p.hasNode(y.v)&&p.hasNode(y.w)&&p.setEdge(y,f.edge(y))});var m={};function h(y){var x=f.parent(y);return x===void 0||p.hasNode(x)?(m[y]=x,x):x in m?m[x]:h(x)}return this._isCompound&&e.each(p.nodes(),function(y){p.setParent(y,h(y))}),p},s.prototype.setDefaultEdgeLabel=function(u){return e.isFunction(u)||(u=e.constant(u)),this._defaultEdgeLabelFn=u,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(u,p){var f=this,m=arguments;return e.reduce(u,function(h,y){return m.length>1?f.setEdge(h,y,p):f.setEdge(h,y),y}),this},s.prototype.setEdge=function(){var u,p,f,m,h=!1,y=arguments[0];typeof y=="object"&&y!==null&&"v"in y?(u=y.v,p=y.w,f=y.name,arguments.length===2&&(m=arguments[1],h=!0)):(u=y,p=arguments[1],f=arguments[3],arguments.length>2&&(m=arguments[2],h=!0)),u=""+u,p=""+p,e.isUndefined(f)||(f=""+f);var x=l(this._isDirected,u,p,f);if(e.has(this._edgeLabels,x))return h&&(this._edgeLabels[x]=m),this;if(!e.isUndefined(f)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(u),this.setNode(p),this._edgeLabels[x]=h?m:this._defaultEdgeLabelFn(u,p,f);var g=c(this._isDirected,u,p,f);return u=g.v,p=g.w,Object.freeze(g),this._edgeObjs[x]=g,a(this._preds[p],u),a(this._sucs[u],p),this._in[p][x]=g,this._out[u][x]=g,this._edgeCount++,this},s.prototype.edge=function(u,p,f){var m=arguments.length===1?d(this._isDirected,arguments[0]):l(this._isDirected,u,p,f);return this._edgeLabels[m]},s.prototype.hasEdge=function(u,p,f){var m=arguments.length===1?d(this._isDirected,arguments[0]):l(this._isDirected,u,p,f);return e.has(this._edgeLabels,m)},s.prototype.removeEdge=function(u,p,f){var m=arguments.length===1?d(this._isDirected,arguments[0]):l(this._isDirected,u,p,f),h=this._edgeObjs[m];return h&&(u=h.v,p=h.w,delete this._edgeLabels[m],delete this._edgeObjs[m],i(this._preds[p],u),i(this._sucs[u],p),delete this._in[p][m],delete this._out[u][m],this._edgeCount--),this},s.prototype.inEdges=function(u,p){var f=this._in[u];if(f){var m=e.values(f);return p?e.filter(m,function(h){return h.v===p}):m}},s.prototype.outEdges=function(u,p){var f=this._out[u];if(f){var m=e.values(f);return p?e.filter(m,function(h){return h.w===p}):m}},s.prototype.nodeEdges=function(u,p){var f=this.inEdges(u,p);if(f)return f.concat(this.outEdges(u,p))};function a(u,p){u[p]?u[p]++:u[p]=1}function i(u,p){--u[p]||delete u[p]}function l(u,p,f,m){var h=""+p,y=""+f;if(!u&&h>y){var x=h;h=y,y=x}return h+n+y+n+(e.isUndefined(m)?t:m)}function c(u,p,f,m){var h=""+p,y=""+f;if(!u&&h>y){var x=h;h=y,y=x}var g={v:h,w:y};return m&&(g.name=m),g}function d(u,p){return l(u,p.v,p.w,p.name)}return mc}var yc,jg;function CS(){return jg||(jg=1,yc="2.1.8"),yc}var gc,Tg;function ES(){return Tg||(Tg=1,gc={Graph:hc(),version:CS()}),gc}var xc,Ig;function RS(){if(Ig)return xc;Ig=1;var e=gt(),t=hc();xc={write:r,read:a};function r(i){var l={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:n(i),edges:s(i)};return e.isUndefined(i.graph())||(l.value=e.clone(i.graph())),l}function n(i){return e.map(i.nodes(),function(l){var c=i.node(l),d=i.parent(l),u={v:l};return e.isUndefined(c)||(u.value=c),e.isUndefined(d)||(u.parent=d),u})}function s(i){return e.map(i.edges(),function(l){var c=i.edge(l),d={v:l.v,w:l.w};return e.isUndefined(l.name)||(d.name=l.name),e.isUndefined(c)||(d.value=c),d})}function a(i){var l=new t(i.options).setGraph(i.value);return e.each(i.nodes,function(c){l.setNode(c.v,c.value),c.parent&&l.setParent(c.v,c.parent)}),e.each(i.edges,function(c){l.setEdge({v:c.v,w:c.w,name:c.name},c.value)}),l}return xc}var vc,Ng;function OS(){if(Ng)return vc;Ng=1;var e=gt();vc=t;function t(r){var n={},s=[],a;function i(l){e.has(n,l)||(n[l]=!0,a.push(l),e.each(r.successors(l),i),e.each(r.predecessors(l),i))}return e.each(r.nodes(),function(l){a=[],i(l),a.length&&s.push(a)}),s}return vc}var bc,Cg;function Eg(){if(Cg)return bc;Cg=1;var e=gt();bc=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 s=this._keyIndices;if(r=String(r),!e.has(s,r)){var a=this._arr,i=a.length;return s[r]=i,a.push({key:r,priority:n}),this._decrease(i),!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 s=this._keyIndices[r];if(n>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+r+" Old: "+this._arr[s].priority+" New: "+n);this._arr[s].priority=n,this._decrease(s)},t.prototype._heapify=function(r){var n=this._arr,s=2*r,a=s+1,i=r;s<n.length&&(i=n[s].priority<n[i].priority?s:i,a<n.length&&(i=n[a].priority<n[i].priority?a:i),i!==r&&(this._swap(r,i),this._heapify(i)))},t.prototype._decrease=function(r){for(var n=this._arr,s=n[r].priority,a;r!==0&&(a=r>>1,!(n[a].priority<s));)this._swap(r,a),r=a},t.prototype._swap=function(r,n){var s=this._arr,a=this._keyIndices,i=s[r],l=s[n];s[r]=l,s[n]=i,a[l.key]=r,a[i.key]=n},bc}var kc,Rg;function Og(){if(Rg)return kc;Rg=1;var e=gt(),t=Eg();kc=n;var r=e.constant(1);function n(a,i,l,c){return s(a,String(i),l||r,c||function(d){return a.outEdges(d)})}function s(a,i,l,c){var d={},u=new t,p,f,m=function(h){var y=h.v!==p?h.v:h.w,x=d[y],g=l(h),v=f.distance+g;if(g<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+h+" Weight: "+g);v<x.distance&&(x.distance=v,x.predecessor=p,u.decrease(y,v))};for(a.nodes().forEach(function(h){var y=h===i?0:Number.POSITIVE_INFINITY;d[h]={distance:y},u.add(h,y)});u.size()>0&&(p=u.removeMin(),f=d[p],f.distance!==Number.POSITIVE_INFINITY);)c(p).forEach(m);return d}return kc}var wc,Pg;function PS(){if(Pg)return wc;Pg=1;var e=Og(),t=gt();wc=r;function r(n,s,a){return t.transform(n.nodes(),function(i,l){i[l]=e(n,l,s,a)},{})}return wc}var Sc,Ag;function $g(){if(Ag)return Sc;Ag=1;var e=gt();Sc=t;function t(r){var n=0,s=[],a={},i=[];function l(c){var d=a[c]={onStack:!0,lowlink:n,index:n++};if(s.push(c),r.successors(c).forEach(function(f){e.has(a,f)?a[f].onStack&&(d.lowlink=Math.min(d.lowlink,a[f].index)):(l(f),d.lowlink=Math.min(d.lowlink,a[f].lowlink))}),d.lowlink===d.index){var u=[],p;do p=s.pop(),a[p].onStack=!1,u.push(p);while(c!==p);i.push(u)}}return r.nodes().forEach(function(c){e.has(a,c)||l(c)}),i}return Sc}var _c,Dg;function AS(){if(Dg)return _c;Dg=1;var e=gt(),t=$g();_c=r;function r(n){return e.filter(t(n),function(s){return s.length>1||s.length===1&&n.hasEdge(s[0],s[0])})}return _c}var jc,Lg;function $S(){if(Lg)return jc;Lg=1;var e=gt();jc=r;var t=e.constant(1);function r(s,a,i){return n(s,a||t,i||function(l){return s.outEdges(l)})}function n(s,a,i){var l={},c=s.nodes();return c.forEach(function(d){l[d]={},l[d][d]={distance:0},c.forEach(function(u){d!==u&&(l[d][u]={distance:Number.POSITIVE_INFINITY})}),i(d).forEach(function(u){var p=u.v===d?u.w:u.v,f=a(u);l[d][p]={distance:f,predecessor:d}})}),c.forEach(function(d){var u=l[d];c.forEach(function(p){var f=l[p];c.forEach(function(m){var h=f[d],y=u[m],x=f[m],g=h.distance+y.distance;g<x.distance&&(x.distance=g,x.predecessor=y.predecessor)})})}),l}return jc}var Tc,Mg;function Wg(){if(Mg)return Tc;Mg=1;var e=gt();Tc=t,t.CycleException=r;function t(n){var s={},a={},i=[];function l(c){if(e.has(a,c))throw new r;e.has(s,c)||(a[c]=!0,s[c]=!0,e.each(n.predecessors(c),l),delete a[c],i.push(c))}if(e.each(n.sinks(),l),e.size(s)!==n.nodeCount())throw new r;return i}function r(){}return r.prototype=new Error,Tc}var Ic,zg;function DS(){if(zg)return Ic;zg=1;var e=Wg();Ic=t;function t(r){try{e(r)}catch(n){if(n instanceof e.CycleException)return!1;throw n}return!0}return Ic}var Nc,qg;function Fg(){if(qg)return Nc;qg=1;var e=gt();Nc=t;function t(n,s,a){e.isArray(s)||(s=[s]);var i=(n.isDirected()?n.successors:n.neighbors).bind(n),l=[],c={};return e.each(s,function(d){if(!n.hasNode(d))throw new Error("Graph does not have node: "+d);r(n,d,a==="post",c,i,l)}),l}function r(n,s,a,i,l,c){e.has(i,s)||(i[s]=!0,a||c.push(s),e.each(l(s),function(d){r(n,d,a,i,l,c)}),a&&c.push(s))}return Nc}var Cc,Bg;function LS(){if(Bg)return Cc;Bg=1;var e=Fg();Cc=t;function t(r,n){return e(r,n,"post")}return Cc}var Ec,Hg;function MS(){if(Hg)return Ec;Hg=1;var e=Fg();Ec=t;function t(r,n){return e(r,n,"pre")}return Ec}var Rc,Jg;function WS(){if(Jg)return Rc;Jg=1;var e=gt(),t=hc(),r=Eg();Rc=n;function n(s,a){var i=new t,l={},c=new r,d;function u(f){var m=f.v===d?f.w:f.v,h=c.priority(m);if(h!==void 0){var y=a(f);y<h&&(l[m]=d,c.decrease(m,y))}}if(s.nodeCount()===0)return i;e.each(s.nodes(),function(f){c.add(f,Number.POSITIVE_INFINITY),i.setNode(f)}),c.decrease(s.nodes()[0],0);for(var p=!1;c.size()>0;){if(d=c.removeMin(),e.has(l,d))i.setEdge(d,l[d]);else{if(p)throw new Error("Input graph is not connected: "+s);p=!0}s.nodeEdges(d).forEach(u)}return i}return Rc}var Oc,Ug;function zS(){return Ug||(Ug=1,Oc={components:OS(),dijkstra:Og(),dijkstraAll:PS(),findCycles:AS(),floydWarshall:$S(),isAcyclic:DS(),postorder:LS(),preorder:MS(),prim:WS(),tarjan:$g(),topsort:Wg()}),Oc}var Pc,Vg;function qS(){if(Vg)return Pc;Vg=1;var e=ES();return Pc={Graph:e.Graph,json:RS(),alg:zS(),version:e.version},Pc}var Ac,Kg;function wt(){if(Kg)return Ac;Kg=1;var e;if(typeof ka=="function")try{e=qS()}catch{}return e||(e=window.graphlib),Ac=e,Ac}var $c,Gg;function FS(){if(Gg)return $c;Gg=1;var e=vh(),t=1,r=4;function n(s){return e(s,t|r)}return $c=n,$c}var Dc,Yg;function fs(){if(Yg)return Dc;Yg=1;var e=Nr(),t=Mt(),r=ss(),n=yt();function s(a,i,l){if(!n(l))return!1;var c=typeof i;return(c=="number"?t(l)&&r(i,l.length):c=="string"&&i in l)?e(l[i],a):!1}return Dc=s,Dc}var Lc,Xg;function BS(){if(Xg)return Lc;Xg=1;var e=ps(),t=Nr(),r=fs(),n=hr(),s=Object.prototype,a=s.hasOwnProperty,i=e(function(l,c){l=Object(l);var d=-1,u=c.length,p=u>2?c[2]:void 0;for(p&&r(c[0],c[1],p)&&(u=1);++d<u;)for(var f=c[d],m=n(f),h=-1,y=m.length;++h<y;){var x=m[h],g=l[x];(g===void 0||t(g,s[x])&&!a.call(l,x))&&(l[x]=f[x])}return l});return Lc=i,Lc}var Mc,Zg;function HS(){if(Zg)return Mc;Zg=1;var e=Wt(),t=Mt(),r=Zt();function n(s){return function(a,i,l){var c=Object(a);if(!t(a)){var d=e(i,3);a=r(a),i=function(p){return d(c[p],p,c)}}var u=s(a,i,l);return u>-1?c[d?a[u]:u]:void 0}}return Mc=n,Mc}var Wc,Qg;function JS(){if(Qg)return Wc;Qg=1;var e=/\s/;function t(r){for(var n=r.length;n--&&e.test(r.charAt(n)););return n}return Wc=t,Wc}var zc,ex;function US(){if(ex)return zc;ex=1;var e=JS(),t=/^\s+/;function r(n){return n&&n.slice(0,e(n)+1).replace(t,"")}return zc=r,zc}var qc,tx;function VS(){if(tx)return qc;tx=1;var e=US(),t=yt(),r=Or(),n=NaN,s=/^[-+]0x[0-9a-f]+$/i,a=/^0b[01]+$/i,i=/^0o[0-7]+$/i,l=parseInt;function c(d){if(typeof d=="number")return d;if(r(d))return n;if(t(d)){var u=typeof d.valueOf=="function"?d.valueOf():d;d=t(u)?u+"":u}if(typeof d!="string")return d===0?d:+d;d=e(d);var p=a.test(d);return p||i.test(d)?l(d.slice(2),p?2:8):s.test(d)?n:+d}return qc=c,qc}var Fc,rx;function nx(){if(rx)return Fc;rx=1;var e=VS(),t=1/0,r=17976931348623157e292;function n(s){if(!s)return s===0?s:0;if(s=e(s),s===t||s===-t){var a=s<0?-1:1;return a*r}return s===s?s:0}return Fc=n,Fc}var Bc,sx;function KS(){if(sx)return Bc;sx=1;var e=nx();function t(r){var n=e(r),s=n%1;return n===n?s?n-s:n:0}return Bc=t,Bc}var Hc,ax;function GS(){if(ax)return Hc;ax=1;var e=lg(),t=Wt(),r=KS(),n=Math.max;function s(a,i,l){var c=a==null?0:a.length;if(!c)return-1;var d=l==null?0:r(l);return d<0&&(d=n(c+d,0)),e(a,t(i,3),d)}return Hc=s,Hc}var Jc,ox;function YS(){if(ox)return Jc;ox=1;var e=HS(),t=GS(),r=e(t);return Jc=r,Jc}var Uc,ix;function lx(){if(ix)return Uc;ix=1;var e=Vl();function t(r){var n=r==null?0:r.length;return n?e(r,1):[]}return Uc=t,Uc}var Vc,cx;function XS(){if(cx)return Vc;cx=1;var e=Pi(),t=Ch(),r=hr();function n(s,a){return s==null?s:e(s,t(a),r)}return Vc=n,Vc}var Kc,dx;function ZS(){if(dx)return Kc;dx=1;function e(t){var r=t==null?0:t.length;return r?t[r-1]:void 0}return Kc=e,Kc}var Gc,ux;function QS(){if(ux)return Gc;ux=1;var e=rs(),t=$i(),r=Wt();function n(s,a){var i={};return a=r(a,3),t(s,function(l,c,d){e(i,c,a(l,c,d))}),i}return Gc=n,Gc}var Yc,px;function Xc(){if(px)return Yc;px=1;var e=Or();function t(r,n,s){for(var a=-1,i=r.length;++a<i;){var l=r[a],c=n(l);if(c!=null&&(d===void 0?c===c&&!e(c):s(c,d)))var d=c,u=l}return u}return Yc=t,Yc}var Zc,fx;function e_(){if(fx)return Zc;fx=1;function e(t,r){return t>r}return Zc=e,Zc}var Qc,mx;function t_(){if(mx)return Qc;mx=1;var e=Xc(),t=e_(),r=yr();function n(s){return s&&s.length?e(s,r,t):void 0}return Qc=n,Qc}var ed,hx;function yx(){if(hx)return ed;hx=1;var e=rs(),t=Nr();function r(n,s,a){(a!==void 0&&!t(n[s],a)||a===void 0&&!(s in n))&&e(n,s,a)}return ed=r,ed}var td,gx;function r_(){if(gx)return td;gx=1;var e=fr(),t=is(),r=Nt(),n="[object Object]",s=Function.prototype,a=Object.prototype,i=s.toString,l=a.hasOwnProperty,c=i.call(Object);function d(u){if(!r(u)||e(u)!=n)return!1;var p=t(u);if(p===null)return!0;var f=l.call(p,"constructor")&&p.constructor;return typeof f=="function"&&f instanceof f&&i.call(f)==c}return td=d,td}var rd,xx;function vx(){if(xx)return rd;xx=1;function e(t,r){if(!(r==="constructor"&&typeof t[r]=="function")&&r!="__proto__")return t[r]}return rd=e,rd}var nd,bx;function n_(){if(bx)return nd;bx=1;var e=Gr(),t=hr();function r(n){return e(n,t(n))}return nd=r,nd}var sd,kx;function s_(){if(kx)return sd;kx=1;var e=yx(),t=Cm(),r=lh(),n=Rm(),s=fh(),a=Yr(),i=Ue(),l=xg(),c=Er(),d=Kr(),u=yt(),p=r_(),f=Qr(),m=vx(),h=n_();function y(x,g,v,k,b,S,j){var _=m(x,v),w=m(g,v),I=j.get(w);if(I){e(x,v,I);return}var N=S?S(_,w,v+"",x,g,j):void 0,C=N===void 0;if(C){var M=i(w),R=!M&&c(w),O=!M&&!R&&f(w);N=w,M||R||O?i(_)?N=_:l(_)?N=n(_):R?(C=!1,N=t(w,!0)):O?(C=!1,N=r(w,!0)):N=[]:p(w)||a(w)?(N=_,a(_)?N=h(_):(!u(_)||d(_))&&(N=s(w))):C=!1}C&&(j.set(w,N),b(N,w,k,S,j),j.delete(w)),e(x,v,N)}return sd=y,sd}var ad,wx;function a_(){if(wx)return ad;wx=1;var e=ts(),t=yx(),r=Pi(),n=s_(),s=yt(),a=hr(),i=vx();function l(c,d,u,p,f){c!==d&&r(d,function(m,h){if(f||(f=new e),s(m))n(c,d,h,u,l,p,f);else{var y=p?p(i(c,h),m,h+"",c,d,f):void 0;y===void 0&&(y=m),t(c,h,y)}},a)}return ad=l,ad}var od,Sx;function o_(){if(Sx)return od;Sx=1;var e=ps(),t=fs();function r(n){return e(function(s,a){var i=-1,l=a.length,c=l>1?a[l-1]:void 0,d=l>2?a[2]:void 0;for(c=n.length>3&&typeof c=="function"?(l--,c):void 0,d&&t(a[0],a[1],d)&&(c=l<3?void 0:c,l=1),s=Object(s);++i<l;){var u=a[i];u&&n(s,u,i,c)}return s})}return od=r,od}var id,_x;function i_(){if(_x)return id;_x=1;var e=a_(),t=o_(),r=t(function(n,s,a){e(n,s,a)});return id=r,id}var ld,jx;function Tx(){if(jx)return ld;jx=1;function e(t,r){return t<r}return ld=e,ld}var cd,Ix;function l_(){if(Ix)return cd;Ix=1;var e=Xc(),t=Tx(),r=yr();function n(s){return s&&s.length?e(s,r,t):void 0}return cd=n,cd}var dd,Nx;function c_(){if(Nx)return dd;Nx=1;var e=Xc(),t=Wt(),r=Tx();function n(s,a){return s&&s.length?e(s,t(a,2),r):void 0}return dd=n,dd}var ud,Cx;function d_(){if(Cx)return ud;Cx=1;var e=kt(),t=function(){return e.Date.now()};return ud=t,ud}var pd,Ex;function u_(){if(Ex)return pd;Ex=1;var e=ns(),t=ds(),r=ss(),n=yt(),s=tn();function a(i,l,c,d){if(!n(i))return i;l=t(l,i);for(var u=-1,p=l.length,f=p-1,m=i;m!=null&&++u<p;){var h=s(l[u]),y=c;if(h==="__proto__"||h==="constructor"||h==="prototype")return i;if(u!=f){var x=m[h];y=d?d(x,h,m):void 0,y===void 0&&(y=n(x)?x:r(l[u+1])?[]:{})}e(m,h,y),m=m[h]}return i}return pd=a,pd}var fd,Rx;function p_(){if(Rx)return fd;Rx=1;var e=us(),t=u_(),r=ds();function n(s,a,i){for(var l=-1,c=a.length,d={};++l<c;){var u=a[l],p=e(s,u);i(p,u)&&t(d,r(u,s),p)}return d}return fd=n,fd}var md,Ox;function f_(){if(Ox)return md;Ox=1;var e=p_(),t=ky();function r(n,s){return e(n,s,function(a,i){return t(n,i)})}return md=r,md}var hd,Px;function m_(){if(Px)return hd;Px=1;var e=lx(),t=tg(),r=ag();function n(s){return r(t(s,void 0,e),s+"")}return hd=n,hd}var yd,Ax;function h_(){if(Ax)return yd;Ax=1;var e=f_(),t=m_(),r=t(function(n,s){return n==null?{}:e(n,s)});return yd=r,yd}var gd,$x;function y_(){if($x)return gd;$x=1;var e=Math.ceil,t=Math.max;function r(n,s,a,i){for(var l=-1,c=t(e((s-n)/(a||1)),0),d=Array(c);c--;)d[i?c:++l]=n,n+=a;return d}return gd=r,gd}var xd,Dx;function g_(){if(Dx)return xd;Dx=1;var e=y_(),t=fs(),r=nx();function n(s){return function(a,i,l){return l&&typeof l!="number"&&t(a,i,l)&&(i=l=void 0),a=r(a),i===void 0?(i=a,a=0):i=r(i),l=l===void 0?a<i?1:-1:r(l),e(a,i,l,s)}}return xd=n,xd}var vd,Lx;function x_(){if(Lx)return vd;Lx=1;var e=g_(),t=e();return vd=t,vd}var bd,Mx;function v_(){if(Mx)return bd;Mx=1;function e(t,r){var n=t.length;for(t.sort(r);n--;)t[n]=t[n].value;return t}return bd=e,bd}var kd,Wx;function b_(){if(Wx)return kd;Wx=1;var e=Or();function t(r,n){if(r!==n){var s=r!==void 0,a=r===null,i=r===r,l=e(r),c=n!==void 0,d=n===null,u=n===n,p=e(n);if(!d&&!p&&!l&&r>n||l&&c&&u&&!d&&!p||a&&c&&u||!s&&u||!i)return 1;if(!a&&!l&&!p&&r<n||p&&s&&i&&!a&&!l||d&&s&&i||!c&&i||!u)return-1}return 0}return kd=t,kd}var wd,zx;function k_(){if(zx)return wd;zx=1;var e=b_();function t(r,n,s){for(var a=-1,i=r.criteria,l=n.criteria,c=i.length,d=s.length;++a<c;){var u=e(i[a],l[a]);if(u){if(a>=d)return u;var p=s[a];return u*(p=="desc"?-1:1)}}return r.index-n.index}return wd=t,wd}var Sd,qx;function w_(){if(qx)return Sd;qx=1;var e=cs(),t=us(),r=Wt(),n=Ly(),s=v_(),a=as(),i=k_(),l=yr(),c=Ue();function d(u,p,f){p.length?p=e(p,function(y){return c(y)?function(x){return t(x,y.length===1?y[0]:y)}:y}):p=[l];var m=-1;p=e(p,a(r));var h=n(u,function(y,x,g){var v=e(p,function(k){return k(y)});return{criteria:v,index:++m,value:y}});return s(h,function(y,x){return i(y,x,f)})}return Sd=d,Sd}var _d,Fx;function S_(){if(Fx)return _d;Fx=1;var e=Vl(),t=w_(),r=ps(),n=fs(),s=r(function(a,i){if(a==null)return[];var l=i.length;return l>1&&n(a,i[0],i[1])?i=[]:l>2&&n(i[0],i[1],i[2])&&(i=[i[0]]),t(a,e(i,1),[])});return _d=s,_d}var jd,Bx;function __(){if(Bx)return jd;Bx=1;var e=py(),t=0;function r(n){var s=++t;return e(n)+s}return jd=r,jd}var Td,Hx;function j_(){if(Hx)return Td;Hx=1;function e(t,r,n){for(var s=-1,a=t.length,i=r.length,l={};++s<a;){var c=s<i?r[s]:void 0;n(l,t[s],c)}return l}return Td=e,Td}var Id,Jx;function T_(){if(Jx)return Id;Jx=1;var e=ns(),t=j_();function r(n,s){return t(n||[],s||[],e)}return Id=r,Id}var Nd,Ux;function ze(){if(Ux)return Nd;Ux=1;var e;if(typeof ka=="function")try{e={cloneDeep:FS(),constant:Ei(),defaults:BS(),each:Ph(),filter:Cy(),find:YS(),flatten:lx(),forEach:Rh(),forIn:XS(),has:Oy(),isUndefined:$y(),last:ZS(),map:Wy(),mapValues:QS(),max:t_(),merge:i_(),min:l_(),minBy:c_(),now:d_(),pick:h_(),range:x_(),reduce:By(),sortBy:S_(),uniqueId:__(),values:wg(),zipObject:T_()}}catch{}return e||(e=window._),Nd=e,Nd}var Cd,Vx;function I_(){if(Vx)return Cd;Vx=1,Cd=e;function e(){var n={};n._next=n._prev=n,this._sentinel=n}e.prototype.dequeue=function(){var n=this._sentinel,s=n._prev;if(s!==n)return t(s),s},e.prototype.enqueue=function(n){var s=this._sentinel;n._prev&&n._next&&t(n),n._next=s._next,s._next._prev=n,s._next=n,n._prev=s},e.prototype.toString=function(){for(var n=[],s=this._sentinel,a=s._prev;a!==s;)n.push(JSON.stringify(a,r)),a=a._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,s){if(n!=="_next"&&n!=="_prev")return s}return Cd}var Ed,Kx;function N_(){if(Kx)return Ed;Kx=1;var e=ze(),t=wt().Graph,r=I_();Ed=s;var n=e.constant(1);function s(d,u){if(d.nodeCount()<=1)return[];var p=l(d,u||n),f=a(p.graph,p.buckets,p.zeroIdx);return e.flatten(e.map(f,function(m){return d.outEdges(m.v,m.w)}),!0)}function a(d,u,p){for(var f=[],m=u[u.length-1],h=u[0],y;d.nodeCount();){for(;y=h.dequeue();)i(d,u,p,y);for(;y=m.dequeue();)i(d,u,p,y);if(d.nodeCount()){for(var x=u.length-2;x>0;--x)if(y=u[x].dequeue(),y){f=f.concat(i(d,u,p,y,!0));break}}}return f}function i(d,u,p,f,m){var h=m?[]:void 0;return e.forEach(d.inEdges(f.v),function(y){var x=d.edge(y),g=d.node(y.v);m&&h.push({v:y.v,w:y.w}),g.out-=x,c(u,p,g)}),e.forEach(d.outEdges(f.v),function(y){var x=d.edge(y),g=y.w,v=d.node(g);v.in-=x,c(u,p,v)}),d.removeNode(f.v),h}function l(d,u){var p=new t,f=0,m=0;e.forEach(d.nodes(),function(x){p.setNode(x,{v:x,in:0,out:0})}),e.forEach(d.edges(),function(x){var g=p.edge(x.v,x.w)||0,v=u(x),k=g+v;p.setEdge(x.v,x.w,k),m=Math.max(m,p.node(x.v).out+=v),f=Math.max(f,p.node(x.w).in+=v)});var h=e.range(m+f+3).map(function(){return new r}),y=f+1;return e.forEach(p.nodes(),function(x){c(h,y,p.node(x))}),{graph:p,buckets:h,zeroIdx:y}}function c(d,u,p){p.out?p.in?d[p.out-p.in+u].enqueue(p):d[d.length-1].enqueue(p):d[0].enqueue(p)}return Ed}var Rd,Gx;function C_(){if(Gx)return Rd;Gx=1;var e=ze(),t=N_();Rd={run:r,undo:s};function r(a){var i=a.graph().acyclicer==="greedy"?t(a,l(a)):n(a);e.forEach(i,function(c){var d=a.edge(c);a.removeEdge(c),d.forwardName=c.name,d.reversed=!0,a.setEdge(c.w,c.v,d,e.uniqueId("rev"))});function l(c){return function(d){return c.edge(d).weight}}}function n(a){var i=[],l={},c={};function d(u){e.has(c,u)||(c[u]=!0,l[u]=!0,e.forEach(a.outEdges(u),function(p){e.has(l,p.w)?i.push(p):d(p.w)}),delete l[u])}return e.forEach(a.nodes(),d),i}function s(a){e.forEach(a.edges(),function(i){var l=a.edge(i);if(l.reversed){a.removeEdge(i);var c=l.forwardName;delete l.reversed,delete l.forwardName,a.setEdge(i.w,i.v,l,c)}})}return Rd}var Od,Yx;function ut(){if(Yx)return Od;Yx=1;var e=ze(),t=wt().Graph;Od={addDummyNode:r,simplify:n,asNonCompoundGraph:s,successorWeights:a,predecessorWeights:i,intersectRect:l,buildLayerMatrix:c,normalizeRanks:d,removeEmptyRanks:u,addBorderNode:p,maxRank:f,partition:m,time:h,notime:y};function r(x,g,v,k){var b;do b=e.uniqueId(k);while(x.hasNode(b));return v.dummy=g,x.setNode(b,v),b}function n(x){var g=new t().setGraph(x.graph());return e.forEach(x.nodes(),function(v){g.setNode(v,x.node(v))}),e.forEach(x.edges(),function(v){var k=g.edge(v.v,v.w)||{weight:0,minlen:1},b=x.edge(v);g.setEdge(v.v,v.w,{weight:k.weight+b.weight,minlen:Math.max(k.minlen,b.minlen)})}),g}function s(x){var g=new t({multigraph:x.isMultigraph()}).setGraph(x.graph());return e.forEach(x.nodes(),function(v){x.children(v).length||g.setNode(v,x.node(v))}),e.forEach(x.edges(),function(v){g.setEdge(v,x.edge(v))}),g}function a(x){var g=e.map(x.nodes(),function(v){var k={};return e.forEach(x.outEdges(v),function(b){k[b.w]=(k[b.w]||0)+x.edge(b).weight}),k});return e.zipObject(x.nodes(),g)}function i(x){var g=e.map(x.nodes(),function(v){var k={};return e.forEach(x.inEdges(v),function(b){k[b.v]=(k[b.v]||0)+x.edge(b).weight}),k});return e.zipObject(x.nodes(),g)}function l(x,g){var v=x.x,k=x.y,b=g.x-v,S=g.y-k,j=x.width/2,_=x.height/2;if(!b&&!S)throw new Error("Not possible to find intersection inside of the rectangle");var w,I;return Math.abs(S)*j>Math.abs(b)*_?(S<0&&(_=-_),w=_*b/S,I=_):(b<0&&(j=-j),w=j,I=j*S/b),{x:v+w,y:k+I}}function c(x){var g=e.map(e.range(f(x)+1),function(){return[]});return e.forEach(x.nodes(),function(v){var k=x.node(v),b=k.rank;e.isUndefined(b)||(g[b][k.order]=v)}),g}function d(x){var g=e.min(e.map(x.nodes(),function(v){return x.node(v).rank}));e.forEach(x.nodes(),function(v){var k=x.node(v);e.has(k,"rank")&&(k.rank-=g)})}function u(x){var g=e.min(e.map(x.nodes(),function(S){return x.node(S).rank})),v=[];e.forEach(x.nodes(),function(S){var j=x.node(S).rank-g;v[j]||(v[j]=[]),v[j].push(S)});var k=0,b=x.graph().nodeRankFactor;e.forEach(v,function(S,j){e.isUndefined(S)&&j%b!==0?--k:k&&e.forEach(S,function(_){x.node(_).rank+=k})})}function p(x,g,v,k){var b={width:0,height:0};return arguments.length>=4&&(b.rank=v,b.order=k),r(x,"border",b,g)}function f(x){return e.max(e.map(x.nodes(),function(g){var v=x.node(g).rank;if(!e.isUndefined(v))return v}))}function m(x,g){var v={lhs:[],rhs:[]};return e.forEach(x,function(k){g(k)?v.lhs.push(k):v.rhs.push(k)}),v}function h(x,g){var v=e.now();try{return g()}finally{console.log(x+" time: "+(e.now()-v)+"ms")}}function y(x,g){return g()}return Od}var Pd,Xx;function E_(){if(Xx)return Pd;Xx=1;var e=ze(),t=ut();Pd={run:r,undo:s};function r(a){a.graph().dummyChains=[],e.forEach(a.edges(),function(i){n(a,i)})}function n(a,i){var l=i.v,c=a.node(l).rank,d=i.w,u=a.node(d).rank,p=i.name,f=a.edge(i),m=f.labelRank;if(u!==c+1){a.removeEdge(i);var h,y,x;for(x=0,++c;c<u;++x,++c)f.points=[],y={width:0,height:0,edgeLabel:f,edgeObj:i,rank:c},h=t.addDummyNode(a,"edge",y,"_d"),c===m&&(y.width=f.width,y.height=f.height,y.dummy="edge-label",y.labelpos=f.labelpos),a.setEdge(l,h,{weight:f.weight},p),x===0&&a.graph().dummyChains.push(h),l=h;a.setEdge(l,d,{weight:f.weight},p)}}function s(a){e.forEach(a.graph().dummyChains,function(i){var l=a.node(i),c=l.edgeLabel,d;for(a.setEdge(l.edgeObj,c);l.dummy;)d=a.successors(i)[0],a.removeNode(i),c.points.push({x:l.x,y:l.y}),l.dummy==="edge-label"&&(c.x=l.x,c.y=l.y,c.width=l.width,c.height=l.height),i=d,l=a.node(i)})}return Pd}var Ad,Zx;function ms(){if(Zx)return Ad;Zx=1;var e=ze();Ad={longestPath:t,slack:r};function t(n){var s={};function a(i){var l=n.node(i);if(e.has(s,i))return l.rank;s[i]=!0;var c=e.min(e.map(n.outEdges(i),function(d){return a(d.w)-n.edge(d).minlen}));return(c===Number.POSITIVE_INFINITY||c===void 0||c===null)&&(c=0),l.rank=c}e.forEach(n.sources(),a)}function r(n,s){return n.node(s.w).rank-n.node(s.v).rank-n.edge(s).minlen}return Ad}var $d,Qx;function ev(){if(Qx)return $d;Qx=1;var e=ze(),t=wt().Graph,r=ms().slack;$d=n;function n(l){var c=new t({directed:!1}),d=l.nodes()[0],u=l.nodeCount();c.setNode(d,{});for(var p,f;s(c,l)<u;)p=a(c,l),f=c.hasNode(p.v)?r(l,p):-r(l,p),i(c,l,f);return c}function s(l,c){function d(u){e.forEach(c.nodeEdges(u),function(p){var f=p.v,m=u===f?p.w:f;!l.hasNode(m)&&!r(c,p)&&(l.setNode(m,{}),l.setEdge(u,m,{}),d(m))})}return e.forEach(l.nodes(),d),l.nodeCount()}function a(l,c){return e.minBy(c.edges(),function(d){if(l.hasNode(d.v)!==l.hasNode(d.w))return r(c,d)})}function i(l,c,d){e.forEach(l.nodes(),function(u){c.node(u).rank+=d})}return $d}var Dd,tv;function R_(){if(tv)return Dd;tv=1;var e=ze(),t=ev(),r=ms().slack,n=ms().longestPath,s=wt().alg.preorder,a=wt().alg.postorder,i=ut().simplify;Dd=l,l.initLowLimValues=p,l.initCutValues=c,l.calcCutValue=u,l.leaveEdge=m,l.enterEdge=h,l.exchangeEdges=y;function l(k){k=i(k),n(k);var b=t(k);p(b),c(b,k);for(var S,j;S=m(b);)j=h(b,k,S),y(b,k,S,j)}function c(k,b){var S=a(k,k.nodes());S=S.slice(0,S.length-1),e.forEach(S,function(j){d(k,b,j)})}function d(k,b,S){var j=k.node(S),_=j.parent;k.edge(S,_).cutvalue=u(k,b,S)}function u(k,b,S){var j=k.node(S),_=j.parent,w=!0,I=b.edge(S,_),N=0;return I||(w=!1,I=b.edge(_,S)),N=I.weight,e.forEach(b.nodeEdges(S),function(C){var M=C.v===S,R=M?C.w:C.v;if(R!==_){var O=M===w,$=b.edge(C).weight;if(N+=O?$:-$,g(k,S,R)){var B=k.edge(S,R).cutvalue;N+=O?-B:B}}}),N}function p(k,b){arguments.length<2&&(b=k.nodes()[0]),f(k,{},1,b)}function f(k,b,S,j,_){var w=S,I=k.node(j);return b[j]=!0,e.forEach(k.neighbors(j),function(N){e.has(b,N)||(S=f(k,b,S,N,j))}),I.low=w,I.lim=S++,_?I.parent=_:delete I.parent,S}function m(k){return e.find(k.edges(),function(b){return k.edge(b).cutvalue<0})}function h(k,b,S){var j=S.v,_=S.w;b.hasEdge(j,_)||(j=S.w,_=S.v);var w=k.node(j),I=k.node(_),N=w,C=!1;w.lim>I.lim&&(N=I,C=!0);var M=e.filter(b.edges(),function(R){return C===v(k,k.node(R.v),N)&&C!==v(k,k.node(R.w),N)});return e.minBy(M,function(R){return r(b,R)})}function y(k,b,S,j){var _=S.v,w=S.w;k.removeEdge(_,w),k.setEdge(j.v,j.w,{}),p(k),c(k,b),x(k,b)}function x(k,b){var S=e.find(k.nodes(),function(_){return!b.node(_).parent}),j=s(k,S);j=j.slice(1),e.forEach(j,function(_){var w=k.node(_).parent,I=b.edge(_,w),N=!1;I||(I=b.edge(w,_),N=!0),b.node(_).rank=b.node(w).rank+(N?I.minlen:-I.minlen)})}function g(k,b,S){return k.hasEdge(b,S)}function v(k,b,S){return S.low<=b.lim&&b.lim<=S.lim}return Dd}var Ld,rv;function O_(){if(rv)return Ld;rv=1;var e=ms(),t=e.longestPath,r=ev(),n=R_();Ld=s;function s(c){switch(c.graph().ranker){case"network-simplex":l(c);break;case"tight-tree":i(c);break;case"longest-path":a(c);break;default:l(c)}}var a=t;function i(c){t(c),r(c)}function l(c){n(c)}return Ld}var Md,nv;function P_(){if(nv)return Md;nv=1;var e=ze();Md=t;function t(s){var a=n(s);e.forEach(s.graph().dummyChains,function(i){for(var l=s.node(i),c=l.edgeObj,d=r(s,a,c.v,c.w),u=d.path,p=d.lca,f=0,m=u[f],h=!0;i!==c.w;){if(l=s.node(i),h){for(;(m=u[f])!==p&&s.node(m).maxRank<l.rank;)f++;m===p&&(h=!1)}if(!h){for(;f<u.length-1&&s.node(m=u[f+1]).minRank<=l.rank;)f++;m=u[f]}s.setParent(i,m),i=s.successors(i)[0]}})}function r(s,a,i,l){var c=[],d=[],u=Math.min(a[i].low,a[l].low),p=Math.max(a[i].lim,a[l].lim),f,m;f=i;do f=s.parent(f),c.push(f);while(f&&(a[f].low>u||p>a[f].lim));for(m=f,f=l;(f=s.parent(f))!==m;)d.push(f);return{path:c.concat(d.reverse()),lca:m}}function n(s){var a={},i=0;function l(c){var d=i;e.forEach(s.children(c),l),a[c]={low:d,lim:i++}}return e.forEach(s.children(),l),a}return Md}var Wd,sv;function A_(){if(sv)return Wd;sv=1;var e=ze(),t=ut();Wd={run:r,cleanup:i};function r(l){var c=t.addDummyNode(l,"root",{},"_root"),d=s(l),u=e.max(e.values(d))-1,p=2*u+1;l.graph().nestingRoot=c,e.forEach(l.edges(),function(m){l.edge(m).minlen*=p});var f=a(l)+1;e.forEach(l.children(),function(m){n(l,c,p,f,u,d,m)}),l.graph().nodeRankFactor=p}function n(l,c,d,u,p,f,m){var h=l.children(m);if(!h.length){m!==c&&l.setEdge(c,m,{weight:0,minlen:d});return}var y=t.addBorderNode(l,"_bt"),x=t.addBorderNode(l,"_bb"),g=l.node(m);l.setParent(y,m),g.borderTop=y,l.setParent(x,m),g.borderBottom=x,e.forEach(h,function(v){n(l,c,d,u,p,f,v);var k=l.node(v),b=k.borderTop?k.borderTop:v,S=k.borderBottom?k.borderBottom:v,j=k.borderTop?u:2*u,_=b!==S?1:p-f[m]+1;l.setEdge(y,b,{weight:j,minlen:_,nestingEdge:!0}),l.setEdge(S,x,{weight:j,minlen:_,nestingEdge:!0})}),l.parent(m)||l.setEdge(c,y,{weight:0,minlen:p+f[m]})}function s(l){var c={};function d(u,p){var f=l.children(u);f&&f.length&&e.forEach(f,function(m){d(m,p+1)}),c[u]=p}return e.forEach(l.children(),function(u){d(u,1)}),c}function a(l){return e.reduce(l.edges(),function(c,d){return c+l.edge(d).weight},0)}function i(l){var c=l.graph();l.removeNode(c.nestingRoot),delete c.nestingRoot,e.forEach(l.edges(),function(d){var u=l.edge(d);u.nestingEdge&&l.removeEdge(d)})}return Wd}var zd,av;function $_(){if(av)return zd;av=1;var e=ze(),t=ut();zd=r;function r(s){function a(i){var l=s.children(i),c=s.node(i);if(l.length&&e.forEach(l,a),e.has(c,"minRank")){c.borderLeft=[],c.borderRight=[];for(var d=c.minRank,u=c.maxRank+1;d<u;++d)n(s,"borderLeft","_bl",i,c,d),n(s,"borderRight","_br",i,c,d)}}e.forEach(s.children(),a)}function n(s,a,i,l,c,d){var u={width:0,height:0,rank:d,borderType:a},p=c[a][d-1],f=t.addDummyNode(s,"border",u,i);c[a][d]=f,s.setParent(f,l),p&&s.setEdge(p,f,{weight:1})}return zd}var qd,ov;function D_(){if(ov)return qd;ov=1;var e=ze();qd={adjust:t,undo:r};function t(d){var u=d.graph().rankdir.toLowerCase();(u==="lr"||u==="rl")&&n(d)}function r(d){var u=d.graph().rankdir.toLowerCase();(u==="bt"||u==="rl")&&a(d),(u==="lr"||u==="rl")&&(l(d),n(d))}function n(d){e.forEach(d.nodes(),function(u){s(d.node(u))}),e.forEach(d.edges(),function(u){s(d.edge(u))})}function s(d){var u=d.width;d.width=d.height,d.height=u}function a(d){e.forEach(d.nodes(),function(u){i(d.node(u))}),e.forEach(d.edges(),function(u){var p=d.edge(u);e.forEach(p.points,i),e.has(p,"y")&&i(p)})}function i(d){d.y=-d.y}function l(d){e.forEach(d.nodes(),function(u){c(d.node(u))}),e.forEach(d.edges(),function(u){var p=d.edge(u);e.forEach(p.points,c),e.has(p,"x")&&c(p)})}function c(d){var u=d.x;d.x=d.y,d.y=u}return qd}var Fd,iv;function L_(){if(iv)return Fd;iv=1;var e=ze();Fd=t;function t(r){var n={},s=e.filter(r.nodes(),function(d){return!r.children(d).length}),a=e.max(e.map(s,function(d){return r.node(d).rank})),i=e.map(e.range(a+1),function(){return[]});function l(d){if(!e.has(n,d)){n[d]=!0;var u=r.node(d);i[u.rank].push(d),e.forEach(r.successors(d),l)}}var c=e.sortBy(s,function(d){return r.node(d).rank});return e.forEach(c,l),i}return Fd}var Bd,lv;function M_(){if(lv)return Bd;lv=1;var e=ze();Bd=t;function t(n,s){for(var a=0,i=1;i<s.length;++i)a+=r(n,s[i-1],s[i]);return a}function r(n,s,a){for(var i=e.zipObject(a,e.map(a,function(f,m){return m})),l=e.flatten(e.map(s,function(f){return e.sortBy(e.map(n.outEdges(f),function(m){return{pos:i[m.w],weight:n.edge(m).weight}}),"pos")}),!0),c=1;c<a.length;)c<<=1;var d=2*c-1;c-=1;var u=e.map(new Array(d),function(){return 0}),p=0;return e.forEach(l.forEach(function(f){var m=f.pos+c;u[m]+=f.weight;for(var h=0;m>0;)m%2&&(h+=u[m+1]),m=m-1>>1,u[m]+=f.weight;p+=f.weight*h})),p}return Bd}var Hd,cv;function W_(){if(cv)return Hd;cv=1;var e=ze();Hd=t;function t(r,n){return e.map(n,function(s){var a=r.inEdges(s);if(a.length){var i=e.reduce(a,function(l,c){var d=r.edge(c),u=r.node(c.v);return{sum:l.sum+d.weight*u.order,weight:l.weight+d.weight}},{sum:0,weight:0});return{v:s,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:s}})}return Hd}var Jd,dv;function z_(){if(dv)return Jd;dv=1;var e=ze();Jd=t;function t(s,a){var i={};e.forEach(s,function(c,d){var u=i[c.v]={indegree:0,in:[],out:[],vs:[c.v],i:d};e.isUndefined(c.barycenter)||(u.barycenter=c.barycenter,u.weight=c.weight)}),e.forEach(a.edges(),function(c){var d=i[c.v],u=i[c.w];!e.isUndefined(d)&&!e.isUndefined(u)&&(u.indegree++,d.out.push(i[c.w]))});var l=e.filter(i,function(c){return!c.indegree});return r(l)}function r(s){var a=[];function i(d){return function(u){u.merged||(e.isUndefined(u.barycenter)||e.isUndefined(d.barycenter)||u.barycenter>=d.barycenter)&&n(d,u)}}function l(d){return function(u){u.in.push(d),--u.indegree===0&&s.push(u)}}for(;s.length;){var c=s.pop();a.push(c),e.forEach(c.in.reverse(),i(c)),e.forEach(c.out,l(c))}return e.map(e.filter(a,function(d){return!d.merged}),function(d){return e.pick(d,["vs","i","barycenter","weight"])})}function n(s,a){var i=0,l=0;s.weight&&(i+=s.barycenter*s.weight,l+=s.weight),a.weight&&(i+=a.barycenter*a.weight,l+=a.weight),s.vs=a.vs.concat(s.vs),s.barycenter=i/l,s.weight=l,s.i=Math.min(a.i,s.i),a.merged=!0}return Jd}var Ud,uv;function q_(){if(uv)return Ud;uv=1;var e=ze(),t=ut();Ud=r;function r(a,i){var l=t.partition(a,function(y){return e.has(y,"barycenter")}),c=l.lhs,d=e.sortBy(l.rhs,function(y){return-y.i}),u=[],p=0,f=0,m=0;c.sort(s(!!i)),m=n(u,d,m),e.forEach(c,function(y){m+=y.vs.length,u.push(y.vs),p+=y.barycenter*y.weight,f+=y.weight,m=n(u,d,m)});var h={vs:e.flatten(u,!0)};return f&&(h.barycenter=p/f,h.weight=f),h}function n(a,i,l){for(var c;i.length&&(c=e.last(i)).i<=l;)i.pop(),a.push(c.vs),l++;return l}function s(a){return function(i,l){return i.barycenter<l.barycenter?-1:i.barycenter>l.barycenter?1:a?l.i-i.i:i.i-l.i}}return Ud}var Vd,pv;function F_(){if(pv)return Vd;pv=1;var e=ze(),t=W_(),r=z_(),n=q_();Vd=s;function s(l,c,d,u){var p=l.children(c),f=l.node(c),m=f?f.borderLeft:void 0,h=f?f.borderRight:void 0,y={};m&&(p=e.filter(p,function(S){return S!==m&&S!==h}));var x=t(l,p);e.forEach(x,function(S){if(l.children(S.v).length){var j=s(l,S.v,d,u);y[S.v]=j,e.has(j,"barycenter")&&i(S,j)}});var g=r(x,d);a(g,y);var v=n(g,u);if(m&&(v.vs=e.flatten([m,v.vs,h],!0),l.predecessors(m).length)){var k=l.node(l.predecessors(m)[0]),b=l.node(l.predecessors(h)[0]);e.has(v,"barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+k.order+b.order)/(v.weight+2),v.weight+=2}return v}function a(l,c){e.forEach(l,function(d){d.vs=e.flatten(d.vs.map(function(u){return c[u]?c[u].vs:u}),!0)})}function i(l,c){e.isUndefined(l.barycenter)?(l.barycenter=c.barycenter,l.weight=c.weight):(l.barycenter=(l.barycenter*l.weight+c.barycenter*c.weight)/(l.weight+c.weight),l.weight+=c.weight)}return Vd}var Kd,fv;function B_(){if(fv)return Kd;fv=1;var e=ze(),t=wt().Graph;Kd=r;function r(s,a,i){var l=n(s),c=new t({compound:!0}).setGraph({root:l}).setDefaultNodeLabel(function(d){return s.node(d)});return e.forEach(s.nodes(),function(d){var u=s.node(d),p=s.parent(d);(u.rank===a||u.minRank<=a&&a<=u.maxRank)&&(c.setNode(d),c.setParent(d,p||l),e.forEach(s[i](d),function(f){var m=f.v===d?f.w:f.v,h=c.edge(m,d),y=e.isUndefined(h)?0:h.weight;c.setEdge(m,d,{weight:s.edge(f).weight+y})}),e.has(u,"minRank")&&c.setNode(d,{borderLeft:u.borderLeft[a],borderRight:u.borderRight[a]}))}),c}function n(s){for(var a;s.hasNode(a=e.uniqueId("_root")););return a}return Kd}var Gd,mv;function H_(){if(mv)return Gd;mv=1;var e=ze();Gd=t;function t(r,n,s){var a={},i;e.forEach(s,function(l){for(var c=r.parent(l),d,u;c;){if(d=r.parent(c),d?(u=a[d],a[d]=c):(u=i,i=c),u&&u!==c){n.setEdge(u,c);return}c=d}})}return Gd}var Yd,hv;function J_(){if(hv)return Yd;hv=1;var e=ze(),t=L_(),r=M_(),n=F_(),s=B_(),a=H_(),i=wt().Graph,l=ut();Yd=c;function c(f){var m=l.maxRank(f),h=d(f,e.range(1,m+1),"inEdges"),y=d(f,e.range(m-1,-1,-1),"outEdges"),x=t(f);p(f,x);for(var g=Number.POSITIVE_INFINITY,v,k=0,b=0;b<4;++k,++b){u(k%2?h:y,k%4>=2),x=l.buildLayerMatrix(f);var S=r(f,x);S<g&&(b=0,v=e.cloneDeep(x),g=S)}p(f,v)}function d(f,m,h){return e.map(m,function(y){return s(f,y,h)})}function u(f,m){var h=new i;e.forEach(f,function(y){var x=y.graph().root,g=n(y,x,h,m);e.forEach(g.vs,function(v,k){y.node(v).order=k}),a(y,h,g.vs)})}function p(f,m){e.forEach(m,function(h){e.forEach(h,function(y,x){f.node(y).order=x})})}return Yd}var Xd,yv;function U_(){if(yv)return Xd;yv=1;var e=ze(),t=wt().Graph,r=ut();Xd={positionX:h,findType1Conflicts:n,findType2Conflicts:s,addConflict:i,hasConflict:l,verticalAlignment:c,horizontalCompaction:d,alignCoordinates:f,findSmallestWidthAlignment:p,balance:m};function n(g,v){var k={};function b(S,j){var _=0,w=0,I=S.length,N=e.last(j);return e.forEach(j,function(C,M){var R=a(g,C),O=R?g.node(R).order:I;(R||C===N)&&(e.forEach(j.slice(w,M+1),function($){e.forEach(g.predecessors($),function(B){var q=g.node(B),F=q.order;(F<_||O<F)&&!(q.dummy&&g.node($).dummy)&&i(k,B,$)})}),w=M+1,_=O)}),j}return e.reduce(v,b),k}function s(g,v){var k={};function b(j,_,w,I,N){var C;e.forEach(e.range(_,w),function(M){C=j[M],g.node(C).dummy&&e.forEach(g.predecessors(C),function(R){var O=g.node(R);O.dummy&&(O.order<I||O.order>N)&&i(k,R,C)})})}function S(j,_){var w=-1,I,N=0;return e.forEach(_,function(C,M){if(g.node(C).dummy==="border"){var R=g.predecessors(C);R.length&&(I=g.node(R[0]).order,b(_,N,M,w,I),N=M,w=I)}b(_,N,_.length,I,j.length)}),_}return e.reduce(v,S),k}function a(g,v){if(g.node(v).dummy)return e.find(g.predecessors(v),function(k){return g.node(k).dummy})}function i(g,v,k){if(v>k){var b=v;v=k,k=b}var S=g[v];S||(g[v]=S={}),S[k]=!0}function l(g,v,k){if(v>k){var b=v;v=k,k=b}return e.has(g[v],k)}function c(g,v,k,b){var S={},j={},_={};return e.forEach(v,function(w){e.forEach(w,function(I,N){S[I]=I,j[I]=I,_[I]=N})}),e.forEach(v,function(w){var I=-1;e.forEach(w,function(N){var C=b(N);if(C.length){C=e.sortBy(C,function(B){return _[B]});for(var M=(C.length-1)/2,R=Math.floor(M),O=Math.ceil(M);R<=O;++R){var $=C[R];j[N]===N&&I<_[$]&&!l(k,N,$)&&(j[$]=N,j[N]=S[N]=S[$],I=_[$])}}})}),{root:S,align:j}}function d(g,v,k,b,S){var j={},_=u(g,v,k,S),w=S?"borderLeft":"borderRight";function I(M,R){for(var O=_.nodes(),$=O.pop(),B={};$;)B[$]?M($):(B[$]=!0,O.push($),O=O.concat(R($))),$=O.pop()}function N(M){j[M]=_.inEdges(M).reduce(function(R,O){return Math.max(R,j[O.v]+_.edge(O))},0)}function C(M){var R=_.outEdges(M).reduce(function($,B){return Math.min($,j[B.w]-_.edge(B))},Number.POSITIVE_INFINITY),O=g.node(M);R!==Number.POSITIVE_INFINITY&&O.borderType!==w&&(j[M]=Math.max(j[M],R))}return I(N,_.predecessors.bind(_)),I(C,_.successors.bind(_)),e.forEach(b,function(M){j[M]=j[k[M]]}),j}function u(g,v,k,b){var S=new t,j=g.graph(),_=y(j.nodesep,j.edgesep,b);return e.forEach(v,function(w){var I;e.forEach(w,function(N){var C=k[N];if(S.setNode(C),I){var M=k[I],R=S.edge(M,C);S.setEdge(M,C,Math.max(_(g,N,I),R||0))}I=N})}),S}function p(g,v){return e.minBy(e.values(v),function(k){var b=Number.NEGATIVE_INFINITY,S=Number.POSITIVE_INFINITY;return e.forIn(k,function(j,_){var w=x(g,_)/2;b=Math.max(j+w,b),S=Math.min(j-w,S)}),b-S})}function f(g,v){var k=e.values(v),b=e.min(k),S=e.max(k);e.forEach(["u","d"],function(j){e.forEach(["l","r"],function(_){var w=j+_,I=g[w],N;if(I!==v){var C=e.values(I);N=_==="l"?b-e.min(C):S-e.max(C),N&&(g[w]=e.mapValues(I,function(M){return M+N}))}})})}function m(g,v){return e.mapValues(g.ul,function(k,b){if(v)return g[v.toLowerCase()][b];var S=e.sortBy(e.map(g,b));return(S[1]+S[2])/2})}function h(g){var v=r.buildLayerMatrix(g),k=e.merge(n(g,v),s(g,v)),b={},S;e.forEach(["u","d"],function(_){S=_==="u"?v:e.values(v).reverse(),e.forEach(["l","r"],function(w){w==="r"&&(S=e.map(S,function(M){return e.values(M).reverse()}));var I=(_==="u"?g.predecessors:g.successors).bind(g),N=c(g,S,k,I),C=d(g,S,N.root,N.align,w==="r");w==="r"&&(C=e.mapValues(C,function(M){return-M})),b[_+w]=C})});var j=p(g,b);return f(b,j),m(b,g.graph().align)}function y(g,v,k){return function(b,S,j){var _=b.node(S),w=b.node(j),I=0,N;if(I+=_.width/2,e.has(_,"labelpos"))switch(_.labelpos.toLowerCase()){case"l":N=-_.width/2;break;case"r":N=_.width/2;break}if(N&&(I+=k?N:-N),N=0,I+=(_.dummy?v:g)/2,I+=(w.dummy?v:g)/2,I+=w.width/2,e.has(w,"labelpos"))switch(w.labelpos.toLowerCase()){case"l":N=w.width/2;break;case"r":N=-w.width/2;break}return N&&(I+=k?N:-N),N=0,I}}function x(g,v){return g.node(v).width}return Xd}var Zd,gv;function V_(){if(gv)return Zd;gv=1;var e=ze(),t=ut(),r=U_().positionX;Zd=n;function n(a){a=t.asNonCompoundGraph(a),s(a),e.forEach(r(a),function(i,l){a.node(l).x=i})}function s(a){var i=t.buildLayerMatrix(a),l=a.graph().ranksep,c=0;e.forEach(i,function(d){var u=e.max(e.map(d,function(p){return a.node(p).height}));e.forEach(d,function(p){a.node(p).y=c+u/2}),c+=u+l})}return Zd}var Qd,xv;function K_(){if(xv)return Qd;xv=1;var e=ze(),t=C_(),r=E_(),n=O_(),s=ut().normalizeRanks,a=P_(),i=ut().removeEmptyRanks,l=A_(),c=$_(),d=D_(),u=J_(),p=V_(),f=ut(),m=wt().Graph;Qd=h;function h(L,H){var U=H&&H.debugTiming?f.time:f.notime;U("layout",function(){var K=U(" buildLayoutGraph",function(){return I(L)});U(" runLayout",function(){y(K,U)}),U(" updateInputGraph",function(){x(L,K)})})}function y(L,H){H(" makeSpaceForEdgeLabels",function(){N(L)}),H(" removeSelfEdges",function(){A(L)}),H(" acyclic",function(){t.run(L)}),H(" nestingGraph.run",function(){l.run(L)}),H(" rank",function(){n(f.asNonCompoundGraph(L))}),H(" injectEdgeLabelProxies",function(){C(L)}),H(" removeEmptyRanks",function(){i(L)}),H(" nestingGraph.cleanup",function(){l.cleanup(L)}),H(" normalizeRanks",function(){s(L)}),H(" assignRankMinMax",function(){M(L)}),H(" removeEdgeLabelProxies",function(){R(L)}),H(" normalize.run",function(){r.run(L)}),H(" parentDummyChains",function(){a(L)}),H(" addBorderSegments",function(){c(L)}),H(" order",function(){u(L)}),H(" insertSelfEdges",function(){W(L)}),H(" adjustCoordinateSystem",function(){d.adjust(L)}),H(" position",function(){p(L)}),H(" positionSelfEdges",function(){P(L)}),H(" removeBorderNodes",function(){F(L)}),H(" normalize.undo",function(){r.undo(L)}),H(" fixupEdgeLabelCoords",function(){B(L)}),H(" undoCoordinateSystem",function(){d.undo(L)}),H(" translateGraph",function(){O(L)}),H(" assignNodeIntersects",function(){$(L)}),H(" reversePoints",function(){q(L)}),H(" acyclic.undo",function(){t.undo(L)})}function x(L,H){e.forEach(L.nodes(),function(U){var K=L.node(U),se=H.node(U);K&&(K.x=se.x,K.y=se.y,H.children(U).length&&(K.width=se.width,K.height=se.height))}),e.forEach(L.edges(),function(U){var K=L.edge(U),se=H.edge(U);K.points=se.points,e.has(se,"x")&&(K.x=se.x,K.y=se.y)}),L.graph().width=H.graph().width,L.graph().height=H.graph().height}var g=["nodesep","edgesep","ranksep","marginx","marginy"],v={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},k=["acyclicer","ranker","rankdir","align"],b=["width","height"],S={width:0,height:0},j=["minlen","weight","width","height","labeloffset"],_={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},w=["labelpos"];function I(L){var H=new m({multigraph:!0,compound:!0}),U=Z(L.graph());return H.setGraph(e.merge({},v,D(U,g),e.pick(U,k))),e.forEach(L.nodes(),function(K){var se=Z(L.node(K));H.setNode(K,e.defaults(D(se,b),S)),H.setParent(K,L.parent(K))}),e.forEach(L.edges(),function(K){var se=Z(L.edge(K));H.setEdge(K,e.merge({},_,D(se,j),e.pick(se,w)))}),H}function N(L){var H=L.graph();H.ranksep/=2,e.forEach(L.edges(),function(U){var K=L.edge(U);K.minlen*=2,K.labelpos.toLowerCase()!=="c"&&(H.rankdir==="TB"||H.rankdir==="BT"?K.width+=K.labeloffset:K.height+=K.labeloffset)})}function C(L){e.forEach(L.edges(),function(H){var U=L.edge(H);if(U.width&&U.height){var K=L.node(H.v),se=L.node(H.w),pe={rank:(se.rank-K.rank)/2+K.rank,e:H};f.addDummyNode(L,"edge-proxy",pe,"_ep")}})}function M(L){var H=0;e.forEach(L.nodes(),function(U){var K=L.node(U);K.borderTop&&(K.minRank=L.node(K.borderTop).rank,K.maxRank=L.node(K.borderBottom).rank,H=e.max(H,K.maxRank))}),L.graph().maxRank=H}function R(L){e.forEach(L.nodes(),function(H){var U=L.node(H);U.dummy==="edge-proxy"&&(L.edge(U.e).labelRank=U.rank,L.removeNode(H))})}function O(L){var H=Number.POSITIVE_INFINITY,U=0,K=Number.POSITIVE_INFINITY,se=0,pe=L.graph(),we=pe.marginx||0,Ce=pe.marginy||0;function ne(Te){var le=Te.x,V=Te.y,X=Te.width,z=Te.height;H=Math.min(H,le-X/2),U=Math.max(U,le+X/2),K=Math.min(K,V-z/2),se=Math.max(se,V+z/2)}e.forEach(L.nodes(),function(Te){ne(L.node(Te))}),e.forEach(L.edges(),function(Te){var le=L.edge(Te);e.has(le,"x")&&ne(le)}),H-=we,K-=Ce,e.forEach(L.nodes(),function(Te){var le=L.node(Te);le.x-=H,le.y-=K}),e.forEach(L.edges(),function(Te){var le=L.edge(Te);e.forEach(le.points,function(V){V.x-=H,V.y-=K}),e.has(le,"x")&&(le.x-=H),e.has(le,"y")&&(le.y-=K)}),pe.width=U-H+we,pe.height=se-K+Ce}function $(L){e.forEach(L.edges(),function(H){var U=L.edge(H),K=L.node(H.v),se=L.node(H.w),pe,we;U.points?(pe=U.points[0],we=U.points[U.points.length-1]):(U.points=[],pe=se,we=K),U.points.unshift(f.intersectRect(K,pe)),U.points.push(f.intersectRect(se,we))})}function B(L){e.forEach(L.edges(),function(H){var U=L.edge(H);if(e.has(U,"x"))switch((U.labelpos==="l"||U.labelpos==="r")&&(U.width-=U.labeloffset),U.labelpos){case"l":U.x-=U.width/2+U.labeloffset;break;case"r":U.x+=U.width/2+U.labeloffset;break}})}function q(L){e.forEach(L.edges(),function(H){var U=L.edge(H);U.reversed&&U.points.reverse()})}function F(L){e.forEach(L.nodes(),function(H){if(L.children(H).length){var U=L.node(H),K=L.node(U.borderTop),se=L.node(U.borderBottom),pe=L.node(e.last(U.borderLeft)),we=L.node(e.last(U.borderRight));U.width=Math.abs(we.x-pe.x),U.height=Math.abs(se.y-K.y),U.x=pe.x+U.width/2,U.y=K.y+U.height/2}}),e.forEach(L.nodes(),function(H){L.node(H).dummy==="border"&&L.removeNode(H)})}function A(L){e.forEach(L.edges(),function(H){if(H.v===H.w){var U=L.node(H.v);U.selfEdges||(U.selfEdges=[]),U.selfEdges.push({e:H,label:L.edge(H)}),L.removeEdge(H)}})}function W(L){var H=f.buildLayerMatrix(L);e.forEach(H,function(U){var K=0;e.forEach(U,function(se,pe){var we=L.node(se);we.order=pe+K,e.forEach(we.selfEdges,function(Ce){f.addDummyNode(L,"selfedge",{width:Ce.label.width,height:Ce.label.height,rank:we.rank,order:pe+ ++K,e:Ce.e,label:Ce.label},"_se")}),delete we.selfEdges})})}function P(L){e.forEach(L.nodes(),function(H){var U=L.node(H);if(U.dummy==="selfedge"){var K=L.node(U.e.v),se=K.x+K.width/2,pe=K.y,we=U.x-se,Ce=K.height/2;L.setEdge(U.e,U.label),L.removeNode(H),U.label.points=[{x:se+2*we/3,y:pe-Ce},{x:se+5*we/6,y:pe-Ce},{x:se+we,y:pe},{x:se+5*we/6,y:pe+Ce},{x:se+2*we/3,y:pe+Ce}],U.label.x=U.x,U.label.y=U.y}})}function D(L,H){return e.mapValues(e.pick(L,H),Number)}function Z(L){var H={};return e.forEach(L,function(U,K){H[K.toLowerCase()]=U}),H}return Qd}var eu,vv;function G_(){if(vv)return eu;vv=1;var e=ze(),t=ut(),r=wt().Graph;eu={debugOrdering:n};function n(s){var a=t.buildLayerMatrix(s),i=new r({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(l){i.setNode(l,{label:l}),i.setParent(l,"layer"+s.node(l).rank)}),e.forEach(s.edges(),function(l){i.setEdge(l.v,l.w,{},l.name)}),e.forEach(a,function(l,c){var d="layer"+c;i.setNode(d,{rank:"same"}),e.reduce(l,function(u,p){return i.setEdge(u,p,{style:"invis"}),p})}),i}return eu}var tu,bv;function Y_(){return bv||(bv=1,tu="0.8.5"),tu}var ru,kv;function X_(){return kv||(kv=1,ru={graphlib:wt(),layout:K_(),debug:G_(),util:{time:ut().time,notime:ut().notime},version:Y_()}),ru}var Z_=X_();const wv=_0(Z_);function Pr(e,t="TB"){if(e.data?._layoutWidth&&e.data?._layoutHeight)return{width:e.data._layoutWidth,height:e.data._layoutHeight};let r=240,n=84;switch(e.type){case"decisionNode":r=164,n=164;break;case"forkNode":r=240,n=84;break;case"joinNode":r=240,n=84;break;case"dynamicPlaceholderNode":r=220,n=70;break;case"loopNode":r=320,n=200;break;case"subWorkflowNode":r=240,n=84;break;case"eventNode":r=240,n=84;break;case"default":r=240,n=40;break;case"plusNode":r=e.data.label&&e.data.label!=="+"?120:32,n=32;break;default:r=240,n=84;break}return{width:r,height:n}}function Q_(e,t,r=8){const n=[];if(e.length<r)return n;const s=new Map,a={},i={};e.forEach(p=>{s.set(p.id,p),a[p.id]=[],i[p.id]=[]}),t.forEach(p=>{a[p.source]&&a[p.source].push(p.target),i[p.target]&&i[p.target].push(p.source)});const l=new Set,c=new Set(["input","output","decisionNode","forkNode","joinNode","loopNode","default","plusNode"]),d=p=>!c.has(p.type||""),u=[...e].sort((p,f)=>p.position.y-f.position.y);for(const p of u){if(l.has(p.id)||!d(p)||a[p.id].length>1)continue;const f=[p.id];let m=p,h=a[m.id];for(;h&&h.length===1;){const y=h[0],x=s.get(y);if(!x||l.has(y)||!d(x)||i[y].length!==1)break;f.push(y),m=x,h=a[m.id]}f.length>=r&&(n.push(f),f.forEach(y=>l.add(y)))}return n}function ej(e,t,r,n,s,a=5,i="view"){const l=t.find(v=>v.id===e[0]),{width:c,height:d}=Pr(l||t[0],r),u=Math.max(.7,1-(e.length-10)/80),p=i==="edit"||i==="run"?1.15:1,f=Math.min(n,Math.round(60*u*p)),m=Math.min(s,Math.round(80*u*p)),h=c+f,y=d+m;let x=0,g=0;if(r==="TB"){const v=Math.ceil(e.length/a);x=a*h-f,g=v*y-m}else x=Math.ceil(e.length/a)*h-f,g=a*y-m;return x+=40,g+=40,{width:x,height:g,gridKW:h,gridKH:y,cols:a}}const nu=58,Sv=20,tj=16;function rj(e,t,r,n){if(e.length===0)return{positionedChildren:[],containerWidth:280,containerHeight:nu+50};const s=e.map(p=>({...p,parentId:void 0,extent:void 0})),{nodes:a}=su(s,t,{direction:r,mode:n,enableSnakeLayout:!1});let i=0,l=0;a.forEach(p=>{const{width:f,height:m}=Pr(p,r);i=Math.max(i,p.position.x+f),l=Math.max(l,p.position.y+m)});const c=Math.max(300,i+Sv*2),d=nu+l+tj;return{positionedChildren:a.map(p=>{const f=e.find(m=>m.id===p.id);return{...p,parentId:f.parentId,extent:f.extent,position:{x:p.position.x+Sv,y:p.position.y+nu}}}),containerWidth:c,containerHeight:d}}function su(e,t,r={}){const{direction:n="TB",mode:s="view",enableSnakeLayout:a=!0,snakeColumns:i=5,snakeMinChainLength:l=8,snakeMinNodeCount:c=10}=r,d=e.length,u=e.filter(N=>N.type!=="plusNode").length;let p=n==="LR"?150:120,f=n==="LR"?120:100,m=p,h=f;if(d>15){let N=Math.max(.5,1-(d-15)/50),C=Math.max(.4,1-(d-15)/40);(s==="edit"||s==="run")&&(N=1-(1-N)*.5,C=1-(1-C)*.5),m=Math.round(p*N),h=Math.round(f*C)}const y=a&&u>c?Q_(e,t,l):[],x={};y.forEach((N,C)=>{N.forEach(M=>{x[M]=C})});const g=new wv.graphlib.Graph;g.setDefaultEdgeLabel(()=>({})),g.setGraph({rankdir:n,ranker:"network-simplex",ranksep:m,nodesep:h,edgesep:50,marginx:50,marginy:50});const v=new Set,k={};e.forEach(N=>{const C=x[N.id];if(C!==void 0){if(!v.has(C)){v.add(C);const M=ej(y[C],e,n,h,m,i,s);k[C]=M,g.setNode(`__CHAIN_${C}`,{width:M.width,height:M.height})}}else{const{width:M,height:R}=Pr(N,n);g.setNode(N.id,{width:M,height:R})}});const b={};t.forEach(N=>{const C=x[N.source],M=x[N.target],R=C!==void 0?`__CHAIN_${C}`:N.source,O=M!==void 0?`__CHAIN_${M}`:N.target;R!==O&&(b[O]=(b[O]||0)+1)}),t.forEach(N=>{const C=x[N.source],M=x[N.target];let R=N.source,O=N.target;if(C!==void 0&&(R=`__CHAIN_${C}`),M!==void 0&&(O=`__CHAIN_${M}`),R!==O){const $=(b[O]||0)>1;g.setEdge(R,O,{weight:$?1:2})}}),wv.layout(g);const S={};for(const N of e)S[N.id]={...N};const j=[],_=new Set;e.forEach(N=>{if(x[N.id]===void 0){const C=g.node(N.id),M=S[N.id],{width:R,height:O}=Pr(M,n);M.position={x:C.x-R/2,y:C.y-O/2},M.data={...M.data,sourcePosition:void 0,targetPosition:void 0},M.sourcePosition=n==="LR"?J.Position.Right:J.Position.Bottom,M.targetPosition=n==="LR"?J.Position.Left:J.Position.Top,j.push(M)}else _.add(N.id)}),y.forEach((N,C)=>{const M=`__CHAIN_${C}`,R=g.node(M),O=k[C],$=R.x-O.width/2+20,B=R.y-O.height/2+20,q=O.cols,F=O.gridKW,A=O.gridKH;N.forEach((W,P)=>{const D=S[W];let Z=0,L=0,H,U;if(n==="TB"){const K=Math.floor(P/q),se=P%q,pe=K%2===0,we=Math.ceil(N.length/q),Ce=K===we-1,ne=N.length%q||q,Te=Ce?(q-ne)*F/2:0;let le;pe?le=se*F+Te:le=(q-1-se)*F-Te;const V=K*A;Z=$+le,L=B+V;const X=Ce?ne:q;pe?(U=J.Position.Left,H=J.Position.Right,se===X-1&&P!==N.length-1&&(H=J.Position.Bottom),se===0&&P!==0&&(U=J.Position.Top)):(U=J.Position.Right,H=J.Position.Left,se===X-1&&P!==N.length-1&&(H=J.Position.Bottom),se===0&&P!==0&&(U=J.Position.Top)),P===0&&(U=J.Position.Top),P===N.length-1&&(H=J.Position.Bottom)}else{const K=Math.floor(P/q),se=P%q,pe=K%2===0,we=Math.ceil(N.length/q),Ce=K===we-1,ne=N.length%q||q,Te=Ce?Math.max(0,(q-ne)*A)/2:0,le=K*F;let V;pe?V=se*A+Te:V=(q-1-se)*A-Te,Z=$+le,L=B+V;const X=Ce?ne:q;pe?(U=J.Position.Top,H=J.Position.Bottom,se===X-1&&P!==N.length-1&&(H=J.Position.Right),se===0&&P!==0&&(U=J.Position.Left)):(U=J.Position.Bottom,H=J.Position.Top,se===X-1&&P!==N.length-1&&(H=J.Position.Right),se===0&&P!==0&&(U=J.Position.Left)),P===0&&(U=J.Position.Left),P===N.length-1&&(H=J.Position.Right)}D.position={x:Z,y:L},D.data={...D.data,sourcePosition:H,targetPosition:U},D.sourcePosition=H,D.targetPosition=U,j.push(D)})});const w=j.reduce((N,C)=>({...N,[C.id]:C}),{}),I=t.map(N=>{const C=w[N.source],M=w[N.target];if(!C||!M||_.has(C.id)||C.type!=="decisionNode")return N;const{width:R,height:O}=Pr(C,n),{width:$,height:B}=Pr(M,n),q={x:C.position.x+R/2,y:C.position.y+O/2},F={x:M.position.x+$/2,y:M.position.y+B/2};let A=null;if(n==="TB"){const W=R*.25;F.x<q.x-W?A="left":F.x>q.x+W&&(A="right")}else{const W=O*.25;F.y<q.y-W?A="top":F.y>q.y+W&&(A="bottom")}return{...N,sourceHandle:A}});return{nodes:j,edges:I}}function pt(e,t,r={}){const n=r.direction||"TB",s=r.mode||"view",a=e.filter(g=>g.parentId),i=e.filter(g=>!g.parentId);if(a.length===0)return su(e,t,r);const l=new Map(a.map(g=>[g.id,g])),c={},d=[];t.forEach(g=>{const v=l.get(g.source),k=l.get(g.target);if(v?.parentId&&v.parentId===k?.parentId){const b=v.parentId;c[b]||(c[b]=[]),c[b].push(g)}else d.push(g)});const u={};a.forEach(g=>{const v=g.parentId;u[v]||(u[v]=[]),u[v].push(g)});const p={},f=[];for(const[g,v]of Object.entries(u)){const k=c[g]||[],{positionedChildren:b,containerWidth:S,containerHeight:j}=rj(v,k,n,s);p[g]={width:S,height:j},f.push(...b)}const m=i.map(g=>{if(g.type==="loopNode"&&p[g.id]){const{width:v,height:k}=p[g.id];return{...g,data:{...g.data,_layoutWidth:v,_layoutHeight:k},style:{...g.style,width:v,height:k}}}return g}),{nodes:h,edges:y}=su(m,d,r);return{nodes:[...h.map(g=>{if(g.type==="loopNode"&&p[g.id]){const{width:v,height:k}=p[g.id];return{...g,width:v,height:k,style:{...g.style,width:v,height:k}}}return g}),...f],edges:[...y,...Object.values(c).flat()]}}function Qe(e,t){if(!e)return null;for(const r of e){if(r.taskReferenceName===t)return r;if(r.decisionCases){for(const s of Object.keys(r.decisionCases)){const a=Qe(r.decisionCases[s],t);if(a)return a}const n=Qe(r.defaultCase,t);if(n)return n}if(r.forkTasks)for(const n of r.forkTasks){const s=Qe(n,t);if(s)return s}if(r.loopOver){const n=Qe(r.loopOver,t);if(n)return n}}return null}function Ct(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 s of Object.keys(n.decisionCases))if(Ct(n.decisionCases[s],t))return!0;if(Ct(n.defaultCase,t))return!0}if(n.forkTasks){for(const s of n.forkTasks)if(Ct(s,t))return!0}if(n.loopOver&&Ct(n.loopOver,t))return!0}return!1}function zt(e,t){if(!e)return null;if(e.some(r=>r.taskReferenceName===t))return e;for(const r of e){if(r.decisionCases){for(const s of Object.values(r.decisionCases)){const a=zt(s,t);if(a)return a}const n=zt(r.defaultCase,t);if(n)return n}if(r.forkTasks)for(const n of r.forkTasks){const s=zt(n,t);if(s)return s}if(r.loopOver){const n=zt(r.loopOver,t);if(n)return n}}return null}function hs(e,t){const r=e.findIndex(n=>n.taskReferenceName===t);if(r<0)return null;for(let n=r+1;n<e.length;n++)if(e[n].type==="JOIN"||e[n].type==="EXCLUSIVE_JOIN")return e[n].taskReferenceName;return null}function au(e,t){const r=e.findIndex(n=>n.taskReferenceName===t);if(r<0)return null;for(let n=r-1;n>=0;n--)if(e[n].type==="FORK_JOIN"||e[n].type==="FORK_JOIN_DYNAMIC")return e[n].taskReferenceName;return null}function Qt(e,t,r){if(!e)return!1;if(t==="start")return e.unshift(r),!0;const n=e.findIndex(s=>s.taskReferenceName===t);if(n!==-1)return e.splice(n+1,0,r),!0;for(const s of e){if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(Qt(s.decisionCases[a],t,r))return!0;if(Qt(s.defaultCase,t,r))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(Qt(a,t,r))return!0}if(s.loopOver&&Qt(s.loopOver,t,r))return!0}return!1}function rn(e,t,r,n){for(const s of e||[]){if(s.taskReferenceName===t){if(r.branchCase==="default")return s.defaultCase||(s.defaultCase=[]),s.defaultCase.unshift(n),!0;if(r.branchCase!==void 0)return s.decisionCases||(s.decisionCases={}),s.decisionCases[r.branchCase]||(s.decisionCases[r.branchCase]=[]),s.decisionCases[r.branchCase].unshift(n),!0;if(r.forkIndex!==void 0){for(s.forkTasks||(s.forkTasks=[]);s.forkTasks.length<=r.forkIndex;)s.forkTasks.push([]);return Array.isArray(s.forkTasks[r.forkIndex])||(s.forkTasks[r.forkIndex]=[]),s.forkTasks[r.forkIndex].unshift(n),!0}else if(r.isLoopAdd)return s.loopOver||(s.loopOver=[]),s.loopOver.unshift(n),!0}if(s.decisionCases){for(const a of Object.keys(s.decisionCases))if(rn(s.decisionCases[a],t,r,n))return!0;if(rn(s.defaultCase,t,r,n))return!0}if(s.forkTasks){for(const a of s.forkTasks)if(rn(a,t,r,n))return!0}if(s.loopOver&&rn(s.loopOver,t,r,n))return!0}return!1}function st(e,t=new Set){for(const r of e||[])r&&(r.taskReferenceName&&t.add(r.taskReferenceName),r.decisionCases&&Object.values(r.decisionCases).forEach(n=>st(n,t)),r.defaultCase&&st(r.defaultCase,t),r.forkTasks&&r.forkTasks.forEach(n=>st(n,t)),r.loopOver&&st(r.loopOver,t));return t}const _v=e=>(e.forkTasks||[]).map(t=>t&&t.length>0?t[t.length-1].taskReferenceName:null);function at(e,t){if(!e)return;const r=t?st(e):null;nn(e,t??null,r)}function nn(e,t,r){for(let n=0;n<e.length;n++){const s=e[n];s&&(s.type==="FORK_JOIN"&&n+1<e.length&&e[n+1]?.type==="JOIN"&&nj(s,e[n+1],t,r),s.decisionCases&&Object.values(s.decisionCases).forEach(a=>a&&nn(a,t,r)),s.defaultCase&&nn(s.defaultCase,t,r),s.forkTasks&&s.forkTasks.forEach(a=>a&&nn(a,t,r)),s.loopOver&&nn(s.loopOver,t,r))}}function nj(e,t,r,n){const s=_v(e),a=Array.isArray(t.joinOn)?t.joinOn:[];if(!r){a.length===0&&(t.joinOn=s.filter(x=>!!x));return}const i=Qe(r,e.taskReferenceName);if(!i||i.type!=="FORK_JOIN"){a.length===0&&(t.joinOn=s.filter(x=>!!x));return}const l=_v(i);if(l.length===s.length&&l.every((x,g)=>x===s[g]))return;const d=x=>(x||[]).map(g=>new Set((g||[]).map(v=>v?.taskReferenceName).filter(Boolean))),u=d(i.forkTasks),p=d(e.forkTasks),f=u.length===p.length,m=p.map((x,g)=>{const v=u.findIndex(k=>[...x].some(b=>k.has(b)));return v>=0?v:f?g:-1}),h=[],y=x=>{x&&!h.includes(x)&&h.push(x)};for(const x of a){if(s.includes(x)){y(x);continue}const g=l.indexOf(x);if(g>=0){const v=m.indexOf(g);y(v>=0?s[v]:null)}else(!n||n.has(x))&&y(x)}s.forEach((x,g)=>{const v=m[g],k=v>=0&&v<l.length?l[v]:null;x&&k===null&&y(x)}),t.joinOn=h}function Ar(e){for(const t of e||[]){if(!t)continue;const r=t,n=s=>{if(r[s]===void 0)return;const a=r.inputParameters&&typeof r.inputParameters=="object"?r.inputParameters:{};a[s]===void 0&&(a[s]=r[s]),r.inputParameters=a,delete r[s]};r.type==="INLINE"&&n("evaluatorType"),r.type==="FORK_JOIN_DYNAMIC"&&["forkTaskName","forkTaskType","forkTaskWorkflow","forkTaskWorkflowVersion","forkTaskInputs"].forEach(n),r.decisionCases&&Object.values(r.decisionCases).forEach(s=>Ar(s)),r.defaultCase&&Ar(r.defaultCase),r.forkTasks&&r.forkTasks.forEach(s=>Ar(s)),r.loopOver&&Ar(r.loopOver)}}function jv(e,t){const r=zt(e,t);return r?hs(r,t):null}function St(e,t){if(!e||e.length===0)return[];if(typeof e[0]!="string")return e;const r=t?.inputSchema?.data&&typeof t.inputSchema.data.properties=="object"&&t.inputSchema.data.properties||{},n=Array.isArray(t?.inputSchema?.data?.required)?t.inputSchema.data.required:[],s=t?.inputTemplate||{};return e.map(a=>{const i={name:a},l=r[a];if(l&&typeof l=="object"){const c=Array.isArray(l.type)?l.type.find(d=>d!=="null"):l.type;c==="integer"?i.type="number":["string","number","boolean","object","array"].includes(c)&&(i.type=c),typeof l.description=="string"&&l.description&&(i.description=l.description),Array.isArray(l.examples)&&l.examples.length>0&&(i.example=l.examples[0])}return n.includes(a)&&(i.required=!0),s[a]!==void 0&&(i.defaultValue=s[a]),i})}const sj=e=>e.type!==void 0&&e.type!=="string"||!!e.description||!!e.required||e.example!==void 0&&e.example!=="";function aj(e,t){const r=St(t.inputParameters).map(c=>c.name),n=e.map(c=>c.name),s=new Set([...r,...n]),a={inputParameters:n},i={};Object.entries(t.inputTemplate||{}).forEach(([c,d])=>{s.has(c)||(i[c]=d)}),e.forEach(c=>{c.name&&c.defaultValue!==void 0&&c.defaultValue!==""&&(i[c.name]=c.defaultValue)}),(t.inputTemplate!==void 0||Object.keys(i).length>0)&&(a.inputTemplate=i);const l=t.inputSchema;if(l||e.some(sj)){const c={type:"object",...l?.data||{}},d=c.properties&&typeof c.properties=="object"?c.properties:{},u={};Object.entries(d).forEach(([m,h])=>{s.has(m)||(u[m]=h)});const f=(Array.isArray(c.required)?c.required:[]).filter(m=>!s.has(m));e.forEach(m=>{if(!m.name)return;const h={...d[m.name]||{}};h.type=m.type||"string",m.description?h.description=m.description:delete h.description,m.example!==void 0&&m.example!==""?h.examples=[m.example]:delete h.examples,u[m.name]=h,m.required&&f.push(m.name)}),c.properties=u,c.required=f,a.inputSchema={name:l?.name||`${t.name||"workflow"}_input`,version:l?.version??1,type:l?.type||"JSON",...l?.externalRef?{externalRef:l.externalRef}:{},data:c}}return a}class oj{schemas=new Map;setSchemas(t){this.schemas.clear();for(const r of t)this.schemas.set(r.taskName,r)}get(t){return this.schemas.get(t)}getAll(){return Array.from(this.schemas.values())}hasSchemas(){return this.schemas.size>0}buildPromptSection(t){if(!this.hasSchemas())return null;const r=this.getAll(),n=t?.limit,s=n!==void 0&&r.length>n?r.slice(0,Math.max(0,Math.floor(n))):r,a=["## 任务 Schema 注册表(数据流参考)","以下任务的输入/输出字段已注册。生成 inputParameters 时请引用正确的上游输出字段(格式:`${taskRef.output.fieldName}`)。"];for(const i of s){const l=i.taskType?`(${i.taskType})`:"",c=i.description?` — ${i.description}`:"";if(a.push(`
|
|
7
|
+
**${i.taskName}** ${l}${c}`),i.inputSchema&&Object.keys(i.inputSchema).length>0){const d=Object.entries(i.inputSchema).map(([u,p])=>`${u}: ${p}`).join(", ");a.push(`- 输入: ${d}`)}if(i.outputSchema&&Object.keys(i.outputSchema).length>0){const d=Object.entries(i.outputSchema).map(([u,p])=>`${u}: ${p}`).join(", ");a.push(`- 输出: ${d}`)}}return s.length<r.length&&a.push(`
|
|
11
8
|
(另有 ${r.length-s.length} 个任务的 Schema 未在此列出,引用前可调用 search_workflow_library 查询)`),a.join(`
|
|
12
|
-
`)}}const Zk=new Xk;function Pt(e,t,r){if(t.push({task:e,isConditional:r}),e.decisionCases)for(const n of Object.values(e.decisionCases))for(const s of n||[])Pt(s,t,!0);if(e.defaultCase)for(const n of e.defaultCase)Pt(n,t,!0);if(e.forkTasks)for(const n of e.forkTasks)for(const s of n||[])Pt(s,t,r);if(e.loopOver)for(const n of e.loopOver)Pt(n,t,r)}function Rg(e,t){if(!e||!Array.isArray(e.tasks))return[];const r=[];function n(a,i){for(let l=0;l<a.length;l++){const c=a[l];if(c.taskReferenceName===t)return!0;if(c.decisionCases||c.defaultCase){for(const u of Object.values(c.decisionCases||{})){const d=[];if(s(u||[],!0,d))return r.push({task:c,isConditional:i}),r.push(...d),!0}if(c.defaultCase){const u=[];if(s(c.defaultCase,!0,u))return r.push({task:c,isConditional:i}),r.push(...u),!0}}if(c.forkTasks)for(const u of c.forkTasks){const d=[];if(s(u||[],i,d))return r.push({task:c,isConditional:i}),r.push(...d),!0}if(c.loopOver){const u=[];if(s(c.loopOver,i,u))return r.push({task:c,isConditional:i}),r.push(...u),!0}Pt(c,r,i)}return!1}function s(a,i,l){for(let c=0;c<a.length;c++){const u=a[c];if(u.taskReferenceName===t)return!0;if(u.decisionCases||u.defaultCase){for(const d of Object.values(u.decisionCases||{})){const p=[];if(s(d||[],!0,p))return l.push({task:u,isConditional:i}),l.push(...p),!0}if(u.defaultCase){const d=[];if(s(u.defaultCase,!0,d))return l.push({task:u,isConditional:i}),l.push(...d),!0}}if(u.forkTasks)for(const d of u.forkTasks){const p=[];if(s(d||[],i,p))return l.push({task:u,isConditional:i}),l.push(...p),!0}if(u.loopOver){const d=[];if(s(u.loopOver,i,d))return l.push({task:u,isConditional:i}),l.push(...d),!0}Pt(u,l,i)}return!1}return n(e.tasks,!1),r}function rc(e,t){return Rg(e,t).map(r=>r.task)}function Dr(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e.length>32?`"${e.slice(0,32)}..."`:`"${e}"`;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return`Array(${e.length})`;if(typeof e=="object"){const t=Object.keys(e);return`{ ${t.slice(0,3).join(", ")}${t.length>3?", ...":""} }`}return String(e)}function nc(e){if(e==null)return"any";if(Array.isArray(e))return"array";const t=typeof e;return t==="string"||t==="number"||t==="boolean"||t==="object"?t:"any"}function oc(e,t,r="",n=0,s=3,a=[]){if(!e||typeof e!="object"||n>s)return a;for(const[i,l]of Object.entries(e)){const c=r?`${r}.${i}`:i,u=nc(l);a.push({path:c,expression:`\${${t}.output.${c}}`,valueType:u,sampleValue:Dr(l),source:"runtime_sample"}),u==="object"&&l!==null&&Object.keys(l).length>0&&n<s?oc(l,t,c,n+1,s,a):u==="array"&&Array.isArray(l)&&l.length>0&&typeof l[0]=="object"&&l[0]!==null&&n<s&&oc(l[0],t,`${c}[0]`,n+1,s,a)}return a}function Pg(e,t){const r=e.taskReferenceName,n=new Map,s=t?.[r]?.output;if(s&&typeof s=="object"){const l=oc(s,r);for(const c of l)n.set(c.path,c)}const a=Zk.get(e.name);if(a?.outputSchema){for(const[l,c]of Object.entries(a.outputSchema))if(!n.has(l)){const u=c.toLowerCase(),d=u.includes("number")||u.includes("int")?"number":u.includes("bool")?"boolean":u.includes("array")||u.includes("[]")?"array":u.includes("object")?"object":"string";n.set(l,{path:l,expression:`\${${r}.output.${l}}`,valueType:d,description:c,source:"schema_registry"})}}const i=(l,c,u)=>{n.has(l)||n.set(l,{path:l,expression:`\${${r}.output.${l}}`,valueType:c,description:u,source:"task_type_contract"})};switch(e.type){case"HTTP":i("response.body","object","HTTP 响应体 JSON 数据"),i("response.statusCode","number","HTTP 状态码 (如 200)"),i("response.headers","object","HTTP 响应头");break;case"JSON_JQ_TRANSFORM":i("result","any","JQ 表达式单值计算结果"),i("resultList","array","JQ 表达式列表计算结果");break;case"DO_WHILE":i("iteration","number","当前循环迭代轮次 (从 1 开始)");break;case"SUB_WORKFLOW":i("workflowId","string","子工作流实例 ID"),i("result","object","子工作流返回输出");break;case"HUMAN":i("approved","boolean","人工审批结果"),i("comment","string","审批意见备注"),i("assignee","string","实际审批人");break;default:n.size===0&&(i("result","any",`${e.name||r} 默认执行结果`),i("data","object",`${e.name||r} 业务输出对象`));break}return Array.from(n.values())}function Og(e,t,r,n){if(!e)return[];const s=[],a=st(e.inputParameters);if(a.length>0)for(const u of a){const d=n?.[u.name]??u.defaultValue;s.push({label:`workflow.input.${u.name}`,value:`\${workflow.input.${u.name}}`,category:"workflow_input",valueType:u.type==="number"?"number":u.type==="boolean"?"boolean":u.type==="object"?"object":u.type==="array"?"array":"string",sourceRef:"workflow.input",sourceLabel:"工作流输入",description:u.description||`工作流启动参数 ${u.name}`,sampleValue:d!==void 0&&d!==""?Dr(d):void 0})}else if(n&&typeof n=="object")for(const[u,d]of Object.entries(n))s.push({label:`workflow.input.${u}`,value:`\${workflow.input.${u}}`,category:"workflow_input",valueType:nc(d),sourceRef:"workflow.input",sourceLabel:"工作流输入",description:`工作流运行态输入字段 ${u}`,sampleValue:Dr(d)});else s.push({label:"workflow.input.data",value:"${workflow.input.data}",category:"workflow_input",valueType:"any",sourceRef:"workflow.input",sourceLabel:"工作流输入",description:"引用工作流启动时传入的参数(可在全局设置中定义 inputParameters)"});const i=Rg(e,t),l=new Set;for(let u=i.length-1;u>=0;u--){const{task:d,isConditional:p}=i[u];if(d.type==="SET_VARIABLE"&&d.inputParameters){for(const[f,m]of Object.entries(d.inputParameters))l.has(f)||(l.add(f),s.push({label:`workflow.variables.${f}`,value:`\${workflow.variables.${f}}`,category:"variable",valueType:nc(m),sourceRef:d.taskReferenceName,sourceLabel:`变量 (${d.name||d.taskReferenceName})`,description:`由上游 SET_VARIABLE 节点 [${d.taskReferenceName}] 设置的全局变量`,sampleValue:Dr(m),isConditional:p}));continue}if(d.type==="JOIN"||d.type==="TERMINATE")continue;const h=Pg(d,r);for(const f of h)s.push({label:`${d.taskReferenceName}.output.${f.path}`,value:f.expression,category:"upstream",valueType:f.valueType,sourceRef:d.taskReferenceName,sourceLabel:`${d.name||d.taskReferenceName} (${d.type})`,description:f.description||`来自上游任务 [${d.name||d.taskReferenceName}] 的输出字段`,sampleValue:f.sampleValue,isConditional:p})}const c=[{key:"workflow.workflowId",desc:"当前工作流执行实例唯一 ID"},{key:"workflow.correlationId",desc:"外部业务关联 ID (Correlation ID)"},{key:"workflow.status",desc:"当前工作流状态"},{key:"workflow.version",desc:"当前工作流定义版本号"}];for(const u of c)s.push({label:u.key,value:`\${${u.key}}`,category:"system",valueType:"string",sourceRef:"workflow",sourceLabel:"系统元数据",description:u.desc});return s}function yt(e,t=[]){if(!e)return t;for(const r of e){if(t.push(r),r.decisionCases)for(const n of Object.values(r.decisionCases))yt(n,t);if(r.defaultCase&&yt(r.defaultCase,t),r.forkTasks)for(const n of r.forkTasks)yt(n,t);r.loopOver&&yt(r.loopOver,t)}return t}function Ot(e,t=[]){if(typeof e=="string"){const r=/\$\{([^}]+)\}/g;let n;for(;(n=r.exec(e))!==null;)t.push(n[1].trim())}else if(Array.isArray(e))for(const r of e)Ot(r,t);else if(e&&typeof e=="object")for(const r of Object.values(e))Ot(r,t);return t}function Ag(e){if(!e||!Array.isArray(e.tasks))return{edges:[],diagnostics:[]};const t=yt(e.tasks),r=new Map,n=new Map;for(const l of t)if(r.set(l.taskReferenceName,l),l.type==="SET_VARIABLE"&&l.inputParameters)for(const c of Object.keys(l.inputParameters))n.set(c,l.taskReferenceName);const s=[],a=[],i=new Set;for(const l of t){const c=l.taskReferenceName,u=new Set(rc(e,c).map(p=>p.taskReferenceName)),d=[];Ot(l.inputParameters,d),Ot(l.httpRequest,d),l.loopCondition&&Ot(l.loopCondition,d),l.expression&&Ot(l.expression,d);for(const p of d){if(p.startsWith("workflow.input.")||p==="workflow.input")continue;if(p.startsWith("workflow.variables.")){const f=p.slice(19).split(".")[0],m=n.get(f);if(m&&m!==c){const y=u.has(m),v=`dfg-${m}->${c}-var:${f}`;i.has(v)||(i.add(v),s.push({id:v,sourceRef:m,targetRef:c,fieldPath:`variables.${f}`,expression:`\${${p}}`,sourceType:"workflow_variable",isValidUpstream:y,issue:y?void 0:"forward_ref"}))}continue}if(p.startsWith("workflow."))continue;const h=p.split(".");if(h.length>=2&&(h[1]==="output"||h[1]==="input")){const f=h[0],m=h.slice(2).join(".")||h[1];if(f===c)continue;const y=r.has(f),v=u.has(f);let g;y?v||(g="forward_ref",a.push({taskRef:c,expression:`\${${p}}`,issue:"forward_ref",message:`任务 [${c}] 引用了非上游或互斥分支任务 "${f}" 的输出`})):(g="undefined_ref",a.push({taskRef:c,expression:`\${${p}}`,issue:"undefined_ref",message:`任务 [${c}] 引用了不存在的任务 "${f}"`}));const x=`dfg-${f}->${c}-${m}`;i.has(x)||(i.add(x),s.push({id:x,sourceRef:f,targetRef:c,fieldPath:m,expression:`\${${p}}`,sourceType:"task_output",isValidUpstream:y&&v,issue:g}))}}}return{edges:s,diagnostics:a}}function Dg(e,t,r){const n=t.trim(),s=r.trim();if(!n||!s||n===s)return{updatedDef:e,replacedCount:0,affectedTaskRefs:[]};const a=JSON.parse(JSON.stringify(e));let i=0;const l=new Set,c=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),u=new RegExp(`\\$\\{\\s*${c}(\\.|\\s*\\})`,"g"),d=new RegExp(`\\$\\.\\b${c}\\b`,"g");function p(f,m){if(typeof f=="string"){let y=f;return u.lastIndex=0,u.test(y)&&(y=y.replace(u,(v,g)=>(i++,l.add(m),`\${${s}${g}`))),d.lastIndex=0,d.test(y)&&(y=y.replace(d,()=>(i++,l.add(m),`$.${s}`))),y}if(Array.isArray(f))return f.map(y=>p(y,m));if(f&&typeof f=="object"){const y={};for(const[v,g]of Object.entries(f))y[v]=p(g,m);return y}return f}const h=yt(a.tasks);for(const f of h){const m=f.taskReferenceName===n?s:f.taskReferenceName;f.taskReferenceName===n&&(f.taskReferenceName=s),f.inputParameters&&(f.inputParameters=p(f.inputParameters,m)),f.httpRequest&&(f.httpRequest=p(f.httpRequest,m)),f.loopCondition&&(f.loopCondition=p(f.loopCondition,m)),f.expression&&(f.expression=p(f.expression,m)),Array.isArray(f.joinOn)&&(f.joinOn=f.joinOn.map(y=>y===n?(i++,l.add(m),s):y)),Array.isArray(f.defaultExclusiveJoinTask)&&(f.defaultExclusiveJoinTask=f.defaultExclusiveJoinTask.map(y=>y===n?(i++,l.add(m),s):y))}return a.outputParameters&&(a.outputParameters=p(a.outputParameters,"__workflow_output__")),l.delete(s),{updatedDef:a,replacedCount:i,affectedTaskRefs:Array.from(l)}}function Lg(e){return!e||typeof e!="object"?null:e.__isMockOverride||"outputData"in e||"forceCase"in e||"durationMs"in e||"status"in e&&(e.status==="COMPLETED"||e.status==="FAILED"||e.status==="TIMED_OUT"||e.status==="COMPLETED_WITH_ERRORS")&&Object.keys(e).every(t=>["__isMockOverride","status","durationMs","forceCase","outputData","reasonForIncompletion"].includes(t))?e:{__isMockOverride:!0,outputData:e}}function Lr(e,t){if(!e||!t)return;const r=t.split(".");let n=e;for(const s of r){if(n==null)return;n=n[s]}return n}function Mr(e,t){if(typeof e=="string"){const r=e.match(/^\$\{([^}]+)\}$/);if(r){const n=Mg(r[1].trim(),t);return n!==void 0?n:e}return e.replace(/\$\{([^}]+)\}/g,(n,s)=>{const a=Mg(s.trim(),t);return a===void 0?n:typeof a=="object"?JSON.stringify(a):String(a)})}if(Array.isArray(e))return e.map(r=>Mr(r,t));if(e&&typeof e=="object"){const r={};for(const[n,s]of Object.entries(e))r[n]=Mr(s,t);return r}return e}function Mg(e,t){if(e==="workflow.input")return t.workflowInput;if(e.startsWith("workflow.input."))return Lr(t.workflowInput,e.slice(15));if(e==="workflow.variables")return t.variables;if(e.startsWith("workflow.variables."))return Lr(t.variables,e.slice(19));if(e==="workflow.workflowId")return"sandbox-dryrun-wf-001";if(e==="workflow.correlationId")return"corr-sandbox-9921";const r=e.indexOf(".output");if(r>0){const n=e.slice(0,r),s=e.slice(r+7),a=t.taskOutputs[n];if(!a)return;if(!s||s==="")return a;if(s.startsWith("."))return Lr(a,s.slice(1))}}function $r(e,t={},r){switch(e.type){case"HTTP":{const n=t.http_request||e.httpRequest||t;return{response:{statusCode:200,headers:{"content-type":"application/json","x-sandbox":"true"},body:{code:0,status:"SUCCESS",message:`Simulated HTTP ${n?.method||"GET"} response for ${e.name}`,requestEcho:n?.uri||"/api/v1/resource",data:{id:`res_${e.taskReferenceName}_${r||1}`,verified:!0,score:95,items:[{id:1,name:"item-alpha"},{id:2,name:"item-beta"}]}}}}}case"JSON_JQ_TRANSFORM":{const n=t.queryExpression||e.inputParameters?.queryExpression||".";if(n==="."||!n){const s={...t};return delete s.queryExpression,{result:s,resultList:[s]}}if(typeof n=="string"&&n.startsWith(".")){const s=n.slice(1).replace(/\[\]/g,""),a=s?Lr(t,s):t;return{result:a!==void 0?a:{transformed:!0,expression:n},resultList:Array.isArray(a)?a:[a??{transformed:!0}]}}return{result:{transformed:!0,queryExpression:n,sourceKeys:Object.keys(t)},resultList:[{transformed:!0}]}}case"SET_VARIABLE":return{variables:{...Object.keys(t).length?t:e.inputParameters||{}}};case"INLINE":return{result:{evaluated:!0,evaluatorType:t.evaluatorType||e.evaluatorType||"graaljs",summary:`Executed inline script for ${e.taskReferenceName}`,...t}};case"EVENT":return{event_produced:`conductor:event:${e.sink||e.name}`,payload:t};case"WAIT":return{waited:!0,duration:t.duration||"1s"};case"TERMINATE":return{terminationStatus:t.terminationStatus||"COMPLETED",terminationReason:t.terminationReason||"Terminated in sandbox dry-run",output:t.workflowOutput||{}};default:return{code:0,status:"OK",result:`Simulated output from ${e.name}`,processedAt:new Date().toISOString(),iteration:r??1,inputEcho:t,data:{id:`${e.taskReferenceName}_out_${r||1}`,approved:!0,amount:t.amount??100}}}}function Qk(e,t,r,n){const s=Lg(r.taskMocks[e.taskReferenceName]);if(s?.outputData)return e.type==="SET_VARIABLE"&&Object.assign(r.variables,s.outputData),structuredClone(s.outputData);e.type==="SET_VARIABLE"&&Object.assign(r.variables,t);const a=$r(e,t,n);return a.processedAt&&(a.processedAt=new Date(r.currentTimeMs).toISOString()),a}function e0(e,t,r,n){if(n)return n;const s=Object.keys(r);if(s.length===0)return"default";const a=e.caseValueParam||"case_value",i=t[a]??e.expression;if(i!=null){const l=String(i).trim();if(r[l])return l;for(const c of s)if(l.includes(c))return c}return s[0]}function zr(e,t,r){for(const n of e){const s=t0(n,t,r);if(s==="FAILED"||s==="TERMINATED")return s}return"COMPLETED"}function t0(e,t,r){t.seqCounter+=1;const n=t.seqCounter,s=t.currentTimeMs,a=8+n%5*4,i=s+a;t.currentTimeMs=i;const l=Lg(t.taskMocks[e.taskReferenceName]),c=Mr(e.inputParameters||{},t),u=r&&r>1?`${e.taskReferenceName}__${r}`:e.taskReferenceName;if(e.type==="SWITCH"||e.type==="DECISION"){const x=e.decisionCases||{},b=e0(e,c,x,l?.forceCase),k=b==="__default__"?e.defaultCase||[]:x[b]||e.defaultCase||[],S={taskId:`sandbox-task-${n}`,taskType:e.type,taskDefName:e.name,referenceTaskName:u,status:"COMPLETED",scheduledTime:s,startTime:i,endTime:i+(l?.durationMs??12),seq:n,pollCount:1,retryCount:0,iteration:r,inputData:{...c,case_value_param:b},outputData:l?.outputData||{selectedCase:b==="__default__"?"defaultCase":b,evaluatedExpression:e.expression||e.caseValueParam||"default"},workflowTask:e};return t.currentTimeMs=S.endTime,t.taskOutputs[e.taskReferenceName]=S.outputData,t.tasks.push(S),zr(k,t,r)}if(e.type==="FORK_JOIN"){const x=e.forkTasks||[],b=i,k={taskId:`sandbox-task-${n}`,taskType:"FORK_JOIN",taskDefName:e.name,referenceTaskName:u,status:"COMPLETED",scheduledTime:s,startTime:b,endTime:b+10,seq:n,pollCount:1,retryCount:0,iteration:r,inputData:c,outputData:{forkedBranches:x.length},workflowTask:e};t.tasks.push(k);const S=b+10;let C=S;for(const T of x){t.currentTimeMs=S;const N=zr(T,t,r);if(t.currentTimeMs>C&&(C=t.currentTimeMs),N!=="COMPLETED")return N}return t.currentTimeMs=C,t.taskOutputs[e.taskReferenceName]=k.outputData,"COMPLETED"}if(e.type==="JOIN"){const x=e.joinOn||[],b={};for(const C of x)t.taskOutputs[C]&&(b[C]=t.taskOutputs[C]);const k=i+15,S={taskId:`sandbox-task-${n}`,taskType:"JOIN",taskDefName:e.name,referenceTaskName:u,status:"COMPLETED",scheduledTime:s,startTime:i,endTime:k,seq:n,pollCount:1,retryCount:0,iteration:r,inputData:{joinOn:x},outputData:b,workflowTask:e};return t.currentTimeMs=k,t.taskOutputs[e.taskReferenceName]=b,t.tasks.push(S),"COMPLETED"}if(e.type==="DO_WHILE"){const x=e.loopOver||[],b=Math.max(1,Math.min(t.maxLoopIterations,10)),k={taskId:`sandbox-task-${n}`,taskType:"DO_WHILE",taskDefName:e.name,referenceTaskName:u,status:"COMPLETED",scheduledTime:s,startTime:i,endTime:i,seq:n,pollCount:1,retryCount:0,iteration:b,inputData:{loopCondition:e.loopCondition,resolvedInput:c},outputData:{iteration:b},workflowTask:e};t.tasks.push(k);const S={};for(let C=1;C<=b;C++){const T=zr(x,t,C);S[String(C)]={};for(const N of x)t.taskOutputs[N.taskReferenceName]&&(S[String(C)][N.taskReferenceName]=t.taskOutputs[N.taskReferenceName]);if(T!=="COMPLETED")return k.endTime=t.currentTimeMs,T}return k.endTime=t.currentTimeMs+10,k.outputData={iteration:b,...S},t.currentTimeMs=k.endTime,t.taskOutputs[e.taskReferenceName]=k.outputData,"COMPLETED"}const d=e.type==="HTTP"?145+n%4*35:e.type==="SIMPLE"?85+n%5*30:28+n%3*12,p=typeof l?.durationMs=="number"&&l.durationMs>=0?l.durationMs:d,h=i+p,f=Qk(e,c,t,r),m=e.type==="TERMINATE"&&c.terminationStatus==="FAILED",y=l?.status||(m?"FAILED_WITH_TERMINAL_ERROR":"COMPLETED"),v=y==="FAILED"||y==="FAILED_WITH_TERMINAL_ERROR"||y==="TIMED_OUT",g={taskId:`sandbox-task-${n}`,taskType:e.type,taskDefName:e.name,referenceTaskName:u,status:y,scheduledTime:s,startTime:i,endTime:h,seq:n,pollCount:1,retryCount:0,iteration:r,workerId:"browser-local-sandbox-worker",inputData:c,outputData:f,reasonForIncompletion:v?l?.reasonForIncompletion||(m?c.terminationReason||"Terminated with FAILED status":`沙箱人工模拟任务异常 (${y})`):void 0,workflowTask:e};return t.currentTimeMs=h,t.taskOutputs[e.taskReferenceName]=f,t.tasks.push(g),v?"FAILED":e.type==="TERMINATE"?m?"FAILED":"TERMINATED":"COMPLETED"}function Kt(e){const t={orderId:"ORD-2026-88412",userId:"usr_99201",amount:299,currency:"CNY",env:"sandbox"};if(Array.isArray(e.inputParameters))for(const r of e.inputParameters){const n=typeof r=="string"?r:r?.name,s=typeof r=="object"&&r!==null?r.example??r.defaultValue??`sample_${n}`:`sample_${n}`;n&&!(n in t)&&(t[n]=s)}try{const r=JSON.stringify(e.tasks||[]),n=/\$\{\s*workflow\.input\.([a-zA-Z0-9_]+)/g;let s;for(;(s=n.exec(r))!==null;){const a=s[1];a&&!(a in t)&&(t[a]=`mock_${a}`)}}catch{}return t}function Gt(e,t={}){const r=Date.now()-2e3,n=t.workflowInput||Kt(e),s={workflowInput:n,variables:{},taskOutputs:{},taskMocks:t.taskMocks||{},tasks:[],currentTimeMs:r,maxLoopIterations:t.maxLoopIterations??2,seqCounter:0},a=zr(e.tasks||[],s),i={};if(e.outputParameters&&Object.keys(e.outputParameters).length>0)Object.assign(i,Mr(e.outputParameters,s));else{const c=s.tasks[s.tasks.length-1];c?.outputData&&Object.assign(i,c.outputData)}const l=a==="FAILED"?"FAILED":a==="TERMINATED"?"TERMINATED":"COMPLETED";return{workflowId:`sandbox-dryrun-${Date.now().toString(36)}`,workflowName:e.name||"sandbox_workflow",workflowVersion:e.version||1,status:l,startTime:r,endTime:s.currentTimeMs,createTime:r,updateTime:s.currentTimeMs,input:n,output:i,variables:s.variables,tasks:s.tasks,workflowDefinition:structuredClone(e)}}const ac=new Set,sc=new Set;function $g(e,t){e.forEach(r=>{try{r(t)}catch(n){console.warn("[reactflow-ui] 埋点观察者出错,已忽略:",n)}})}function r0(e){return ac.add(e),()=>{ac.delete(e)}}function zg(e){$g(ac,e)}function n0(e){return sc.add(e),()=>{sc.delete(e)}}function o0(e){$g(sc,e)}function Yt(e,t=[]){return Array.isArray(e)&&e.forEach((r,n)=>{if(r){if(r.type==="FORK_JOIN_DYNAMIC"){for(let s=n+1;s<e.length;s++)if(e[s]?.type==="JOIN"||e[s]?.type==="EXCLUSIVE_JOIN"){t.push({forkRef:r.taskReferenceName,joinRef:e[s].taskReferenceName});break}}r.decisionCases&&Object.values(r.decisionCases).forEach(s=>Yt(s,t)),r.defaultCase&&Yt(r.defaultCase,t),Array.isArray(r.forkTasks)&&r.forkTasks.forEach(s=>Yt(s,t)),Array.isArray(r.loopOver)&&Yt(r.loopOver,t)}}),t}let qg=null,ic=[];function a0(e){return e===qg||(qg=e,ic=e.map(t=>Object.assign({},t,{selected:!1}))),ic}const oe=fn()(rd(xb((e,t)=>({mode:"view",workflowDef:null,workflowInstance:null,nodes:[],edges:[],taskMap:{},layoutDirection:"TB",selectedTask:null,selectedTaskInstance:null,isDetailPanelOpen:!1,executionData:null,dynamicRuntimeTasksByFork:{},validationResults:{isValid:!0,errors:[],warnings:[]},theme:"dark",themeColor:"blue",edgeType:"smoothstep",nodesLocked:!0,copiedTask:null,viewMode:"business",simState:{},isSimRunning:!1,workflowLoadKey:0,graphStale:!1,runState:"idle",pendingExecutionId:null,executionError:null,showRunPanel:!1,showAnalysisPanel:!1,focusedParamKey:null,showDataLineage:!1,lastRefactorNotice:null,showWaterfallPanel:!1,timeTravelTimestamp:null,activeLoopIterations:{},inlineCopilotTaskRef:null,setWorkflow:(r,n)=>{const s=n||t().layoutDirection,a=JSON.parse(JSON.stringify(r));$e(a.tasks);const{nodes:i,edges:l,taskMap:c}=Me(a,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:u,edges:d}=Oe(i,l,{direction:s,mode:t().mode}),p=He(a);e({workflowDef:a,nodes:u,edges:d,taskMap:c,validationResults:p,layoutDirection:s,workflowLoadKey:t().workflowLoadKey+1,graphStale:!1})},setWorkflowDefOnly:r=>{const n=JSON.parse(JSON.stringify(r));$e(n.tasks),e({workflowDef:n,validationResults:He(n),graphStale:!0})},refreshGraph:()=>{const{graphStale:r,workflowDef:n,layoutDirection:s,mode:a}=t();if(!r||!n)return;const{nodes:i,edges:l,taskMap:c}=Me(n,s,{hideEmptyBranches:a!=="edit"}),{nodes:u,edges:d}=Oe(i,l,{direction:s,mode:a});e({nodes:u,edges:d,taskMap:c,graphStale:!1})},setMode:r=>{t().mode==="run"&&r!=="run"&&e({executionData:null,workflowInstance:null,dynamicRuntimeTasksByFork:{},timeTravelTimestamp:null,showWaterfallPanel:!1,activeLoopIterations:{}}),e({mode:r});const{workflowDef:s,layoutDirection:a}=t();if(s){const{nodes:i,edges:l,taskMap:c}=Me(s,a,{hideEmptyBranches:r!=="edit"}),{nodes:u,edges:d}=Oe(i,l,{direction:a,mode:r});e({nodes:u,edges:d,taskMap:c,graphStale:!1})}},setExecutionData:r=>e({executionData:r,dynamicRuntimeTasksByFork:r===null?{}:t().dynamicRuntimeTasksByFork}),updateTaskStatus:(r,n)=>{const{executionData:s}=t();if(!s)return;const a={...s};a[r]&&(a[r]={...a[r],status:n},e({executionData:a}))},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=[],s=null,a=t().workflowDef;if(Array.isArray(r.tasks)?(n=r.tasks,r.workflowId&&r.status&&(s=r,r.workflowDefinition&&(a=r.workflowDefinition))):Array.isArray(r)&&(n=r),n.length===0)return;a&&JSON.stringify(a)!==JSON.stringify(t().workflowDef)&&t().setWorkflow(a);const i=t().taskMap,l={},c=(f,m,y)=>{const v=y!==void 0&&m.iteration===void 0?{...m,iteration:y}:m;l[f]||(l[f]={taskReferenceName:f,status:v.status,attempts:[],startTime:v.startTime,endTime:v.endTime,output:v.outputData,input:v.inputData,reasonForIncompletion:v.reasonForIncompletion,iteration:v.iteration}),l[f].attempts.push(v)};n.forEach(f=>{const m=f.referenceTaskName;if(!m)return;const y=m.match(/^(.+)__(\d+)$/);if(y&&i[y[1]]){const v=y[1],g=parseInt(y[2],10);c(v,f,g)}c(m,f)}),Object.values(l).forEach(f=>{f.attempts.some(v=>v.iteration!==void 0&&v.iteration>0)?(f.attempts.sort((v,g)=>(v.iteration??0)-(g.iteration??0)),f.totalIterations=f.attempts.reduce((v,g)=>Math.max(v,g.iteration??0),0),f.startTime=f.attempts[0]?.startTime):f.attempts.sort((v,g)=>(v.retryCount??0)-(g.retryCount??0));const y=f.attempts[f.attempts.length-1];y&&(f.status=y.status,f.endTime=y.endTime,f.output=y.outputData,f.input=y.inputData,f.reasonForIncompletion=y.reasonForIncompletion,f.iteration=y.iteration)});const d=t().workflowDef?.tasks||[],p=Yt(d),h={};p.forEach(({forkRef:f,joinRef:m})=>{const y=n.findIndex(x=>x.referenceTaskName===f),v=n.findIndex(x=>x.referenceTaskName===m);if(y<0||v<0)return;const g=new Set;h[f]=n.slice(y+1,v).filter(x=>!x.referenceTaskName||!x.taskId||i[x.referenceTaskName]||g.has(x.referenceTaskName)?!1:(g.add(x.referenceTaskName),!0)).map(x=>x)}),e({executionData:l,dynamicRuntimeTasksByFork:h,workflowInstance:s,timeTravelTimestamp:null,activeLoopIterations:{},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:s,edges:a,taskMap:i}=Me(n,r,{hideEmptyBranches:t().mode!=="edit"}),{nodes:l,edges:c}=Oe(s,a,{direction:r,mode:t().mode});e({nodes:l,edges:c,taskMap:i,layoutDirection:r})}else e({layoutDirection:r})},onNodesChange:r=>{const n=t().nodes,s=new Set(n.map(i=>i.id)),a=r.filter(i=>"id"in i&&s.has(i.id));a.length!==0&&e({nodes:F.applyNodeChanges(a,n)})},onEdgesChange:r=>{const n=t().edges,s=F.applyEdgeChanges(r,n);s!==n&&e({edges:s})},onConnect:r=>{const{edges:n,layoutDirection:s}=t(),a=F.addEdge(r,n),{nodes:i,edges:l}=Oe(t().nodes,a,{direction:s,mode:t().mode});e({edges:l,nodes:i})},checkTaskRefUniqueness:(r,n)=>{if(r===n)return!0;const{taskMap:s}=t();return!s[r]},updateTask:(r,n,s)=>{const{workflowDef:a,layoutDirection:i}=t();if(!a)return;let l=JSON.parse(JSON.stringify(a)),c=t().lastRefactorNotice;const u=typeof n=="object"?Object.keys(n):[n],d=typeof n=="object"?n.taskReferenceName:n==="taskReferenceName"?s:void 0;let p=r;if(typeof d=="string"&&d.trim()&&d.trim()!==r){const f=d.trim(),m=Dg(l,r,f);l=m.updatedDef,p=f,m.replacedCount>0&&(c={oldRef:r,newRef:f,replacedCount:m.replacedCount,affectedTasks:m.affectedTaskRefs,timestamp:Date.now()})}const h=Be(l.tasks,p);if(h){typeof n=="object"?Object.assign(h,n,{taskReferenceName:p}):n!=="taskReferenceName"&&(h[n]=s),$e(l.tasks);const f=He(l),m=new Set(["taskReferenceName","type","decisionCases","defaultCase","forkTasks","loopOver","joinOn"]);if(u.some(v=>m.has(v))){const{nodes:v,edges:g,taskMap:x}=Me(l,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:b,edges:k}=Oe(v,g,{direction:i,mode:t().mode}),S=t().selectedTask?.taskReferenceName===r?h:t().selectedTask;e({workflowDef:l,nodes:b,edges:k,taskMap:x,selectedTask:S,validationResults:f,lastRefactorNotice:c})}else{const v=t().nodes.map(b=>b.data?.taskReferenceName===r?{...b,data:{...b.data,label:h.name||b.data.label,task:h,loopCondition:h.loopCondition??b.data.loopCondition,subWorkflowName:h.subWorkflowParam?.name??b.data.subWorkflowName}}:b),g={...t().taskMap,[r]:h},x=t().selectedTask?.taskReferenceName===r?h:t().selectedTask;e({workflowDef:l,nodes:v,taskMap:g,selectedTask:x,validationResults:f})}}},updateWorkflowProperties:r=>{const{workflowDef:n,layoutDirection:s}=t();if(!n)return;const a=JSON.parse(JSON.stringify(n));Object.assign(a,r),$e(a.tasks);const i=He(a);if("tasks"in r){const{nodes:l,edges:c,taskMap:u}=Me(a,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:d,edges:p}=Oe(l,c,{direction:s,mode:t().mode});e({workflowDef:a,nodes:d,edges:p,taskMap:u,validationResults:i})}else e({workflowDef:a,validationResults:i})},addNode:(r,n,s,a,i={})=>{const{workflowDef:l,layoutDirection:c}=t();if(!l)return;const u=JSON.parse(JSON.stringify(l)),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 g={name:`${d.name}_join`,taskReferenceName:`${d.taskReferenceName}_join`,type:"JOIN",joinOn:[]};if(i.isWorkflowStart)u.tasks.unshift(g),u.tasks.unshift(d);else if(i.isLoopBodyStart){const x=Be(u.tasks,n);x&&(x.loopOver||(x.loopOver=[]),x.loopOver.unshift(g),x.loopOver.unshift(d))}else i.branchCase!==void 0||i.forkIndex!==void 0||i.isLoopAdd?(Rt(u.tasks,n,i,d),Ze(u.tasks,d.taskReferenceName,g)):u.tasks.length===0?u.tasks.push(d,g):(Ze(u.tasks,n,d),Ze(u.tasks,d.taskReferenceName,g))}else if(d.type==="DECISION"||d.type==="SWITCH"?(d.evaluatorType="value-param",d.caseValueParam="case_param",d.decisionCases={case1:[]},d.defaultCase=[]):d.type==="DO_WHILE"?(d.loopCondition="$.taskReferenceName.output.value < 10",d.loopOver=[]):d.type==="INLINE"?(d.evaluatorType="graaljs",d.inputParameters={expression:`function execute(input) {
|
|
9
|
+
`)}}const Tv=new oj;function $r(e,t,r){if(t.push({task:e,isConditional:r}),e.decisionCases)for(const n of Object.values(e.decisionCases))for(const s of n||[])$r(s,t,!0);if(e.defaultCase)for(const n of e.defaultCase)$r(n,t,!0);if(e.forkTasks)for(const n of e.forkTasks)for(const s of n||[])$r(s,t,r);if(e.loopOver)for(const n of e.loopOver)$r(n,t,r)}function Iv(e,t){if(!e||!Array.isArray(e.tasks))return[];const r=[];function n(a,i){for(let l=0;l<a.length;l++){const c=a[l];if(c.taskReferenceName===t)return!0;if(c.decisionCases||c.defaultCase){for(const d of Object.values(c.decisionCases||{})){const u=[];if(s(d||[],!0,u))return r.push({task:c,isConditional:i}),r.push(...u),!0}if(c.defaultCase){const d=[];if(s(c.defaultCase,!0,d))return r.push({task:c,isConditional:i}),r.push(...d),!0}}if(c.forkTasks)for(const d of c.forkTasks){const u=[];if(s(d||[],i,u))return r.push({task:c,isConditional:i}),r.push(...u),!0}if(c.loopOver){const d=[];if(s(c.loopOver,i,d))return r.push({task:c,isConditional:i}),r.push(...d),!0}$r(c,r,i)}return!1}function s(a,i,l){for(let c=0;c<a.length;c++){const d=a[c];if(d.taskReferenceName===t)return!0;if(d.decisionCases||d.defaultCase){for(const u of Object.values(d.decisionCases||{})){const p=[];if(s(u||[],!0,p))return l.push({task:d,isConditional:i}),l.push(...p),!0}if(d.defaultCase){const u=[];if(s(d.defaultCase,!0,u))return l.push({task:d,isConditional:i}),l.push(...u),!0}}if(d.forkTasks)for(const u of d.forkTasks){const p=[];if(s(u||[],i,p))return l.push({task:d,isConditional:i}),l.push(...p),!0}if(d.loopOver){const u=[];if(s(d.loopOver,i,u))return l.push({task:d,isConditional:i}),l.push(...u),!0}$r(d,l,i)}return!1}return n(e.tasks,!1),r}function ys(e,t){return Iv(e,t).map(r=>r.task)}function gs(e){if(e===null)return"null";if(e===void 0)return"undefined";if(typeof e=="string")return e.length>32?`"${e.slice(0,32)}..."`:`"${e}"`;if(typeof e=="number"||typeof e=="boolean")return String(e);if(Array.isArray(e))return`Array(${e.length})`;if(typeof e=="object"){const t=Object.keys(e);return`{ ${t.slice(0,3).join(", ")}${t.length>3?", ...":""} }`}return String(e)}function ou(e){if(e==null)return"any";if(Array.isArray(e))return"array";const t=typeof e;return t==="string"||t==="number"||t==="boolean"||t==="object"?t:"any"}function iu(e,t,r="",n=0,s=3,a=[]){if(!e||typeof e!="object"||n>s)return a;for(const[i,l]of Object.entries(e)){const c=r?`${r}.${i}`:i,d=ou(l);a.push({path:c,expression:`\${${t}.output.${c}}`,valueType:d,sampleValue:gs(l),source:"runtime_sample"}),d==="object"&&l!==null&&Object.keys(l).length>0&&n<s?iu(l,t,c,n+1,s,a):d==="array"&&Array.isArray(l)&&l.length>0&&typeof l[0]=="object"&&l[0]!==null&&n<s&&iu(l[0],t,`${c}[0]`,n+1,s,a)}return a}function Nv(e,t){const r=e.taskReferenceName,n=new Map,s=t?.[r]?.output;if(s&&typeof s=="object"){const l=iu(s,r);for(const c of l)n.set(c.path,c)}const a=Tv.get(e.name);if(a?.outputSchema){for(const[l,c]of Object.entries(a.outputSchema))if(!n.has(l)){const d=c.toLowerCase(),u=d.includes("number")||d.includes("int")?"number":d.includes("bool")?"boolean":d.includes("array")||d.includes("[]")?"array":d.includes("object")?"object":"string";n.set(l,{path:l,expression:`\${${r}.output.${l}}`,valueType:u,description:c,source:"schema_registry"})}}const i=(l,c,d)=>{n.has(l)||n.set(l,{path:l,expression:`\${${r}.output.${l}}`,valueType:c,description:d,source:"task_type_contract"})};switch(e.type){case"HTTP":i("response.body","object","HTTP 响应体 JSON 数据"),i("response.statusCode","number","HTTP 状态码 (如 200)"),i("response.headers","object","HTTP 响应头");break;case"JSON_JQ_TRANSFORM":i("result","any","JQ 表达式单值计算结果"),i("resultList","array","JQ 表达式列表计算结果");break;case"DO_WHILE":i("iteration","number","当前循环迭代轮次 (从 1 开始)");break;case"SUB_WORKFLOW":i("subWorkflowId","string","子工作流实例 ID");break;case"HUMAN":i("approved","boolean","人工审批结果"),i("comment","string","审批意见备注"),i("assignee","string","实际审批人");break;default:n.size===0&&(i("result","any",`${e.name||r} 默认执行结果`),i("data","object",`${e.name||r} 业务输出对象`));break}return Array.from(n.values())}function Cv(e,t,r,n){if(!e)return[];const s=[],a=St(e.inputParameters,e);if(a.length>0)for(const d of a){const u=n?.[d.name]??d.defaultValue;s.push({label:`workflow.input.${d.name}`,value:`\${workflow.input.${d.name}}`,category:"workflow_input",valueType:d.type==="number"?"number":d.type==="boolean"?"boolean":d.type==="object"?"object":d.type==="array"?"array":"string",sourceRef:"workflow.input",sourceLabel:"工作流输入",description:d.description||`工作流启动参数 ${d.name}`,sampleValue:u!==void 0&&u!==""?gs(u):void 0})}else if(n&&typeof n=="object")for(const[d,u]of Object.entries(n))s.push({label:`workflow.input.${d}`,value:`\${workflow.input.${d}}`,category:"workflow_input",valueType:ou(u),sourceRef:"workflow.input",sourceLabel:"工作流输入",description:`工作流运行态输入字段 ${d}`,sampleValue:gs(u)});else s.push({label:"workflow.input.data",value:"${workflow.input.data}",category:"workflow_input",valueType:"any",sourceRef:"workflow.input",sourceLabel:"工作流输入",description:"引用工作流启动时传入的参数(可在全局设置中定义 inputParameters)"});const i=Iv(e,t),l=new Set;for(let d=i.length-1;d>=0;d--){const{task:u,isConditional:p}=i[d];if(u.type==="SET_VARIABLE"&&u.inputParameters){for(const[m,h]of Object.entries(u.inputParameters))l.has(m)||(l.add(m),s.push({label:`workflow.variables.${m}`,value:`\${workflow.variables.${m}}`,category:"variable",valueType:ou(h),sourceRef:u.taskReferenceName,sourceLabel:`变量 (${u.name||u.taskReferenceName})`,description:`由上游 SET_VARIABLE 节点 [${u.taskReferenceName}] 设置的全局变量`,sampleValue:gs(h),isConditional:p}));continue}if(u.type==="JOIN"||u.type==="TERMINATE")continue;const f=Nv(u,r);for(const m of f)s.push({label:`${u.taskReferenceName}.output.${m.path}`,value:m.expression,category:"upstream",valueType:m.valueType,sourceRef:u.taskReferenceName,sourceLabel:`${u.name||u.taskReferenceName} (${u.type})`,description:m.description||`来自上游任务 [${u.name||u.taskReferenceName}] 的输出字段`,sampleValue:m.sampleValue,isConditional:p})}const c=[{key:"workflow.workflowId",desc:"当前工作流执行实例唯一 ID"},{key:"workflow.correlationId",desc:"外部业务关联 ID (Correlation ID)"},{key:"workflow.status",desc:"当前工作流状态"},{key:"workflow.version",desc:"当前工作流定义版本号"}];for(const d of c)s.push({label:d.key,value:`\${${d.key}}`,category:"system",valueType:"string",sourceRef:"workflow",sourceLabel:"系统元数据",description:d.desc});return s}function gr(e,t=[]){if(!e)return t;for(const r of e){if(t.push(r),r.decisionCases)for(const n of Object.values(r.decisionCases))gr(n,t);if(r.defaultCase&&gr(r.defaultCase,t),r.forkTasks)for(const n of r.forkTasks)gr(n,t);r.loopOver&&gr(r.loopOver,t)}return t}function Dr(e,t=[]){if(typeof e=="string"){const r=/\$\{([^}]+)\}/g;let n;for(;(n=r.exec(e))!==null;)t.push(n[1].trim())}else if(Array.isArray(e))for(const r of e)Dr(r,t);else if(e&&typeof e=="object")for(const r of Object.values(e))Dr(r,t);return t}function lu(e){if(!e||!Array.isArray(e.tasks))return{edges:[],diagnostics:[]};const t=gr(e.tasks),r=new Map,n=new Map;for(const l of t)if(r.set(l.taskReferenceName,l),l.type==="SET_VARIABLE"&&l.inputParameters)for(const c of Object.keys(l.inputParameters))n.set(c,l.taskReferenceName);const s=[],a=[],i=new Set;for(const l of t){const c=l.taskReferenceName,d=new Set(ys(e,c).map(p=>p.taskReferenceName)),u=[];Dr(l.inputParameters,u),Dr(l.httpRequest,u),l.loopCondition&&Dr(l.loopCondition,u),l.expression&&Dr(l.expression,u);for(const p of u){if(p.startsWith("workflow.input.")||p==="workflow.input")continue;if(p.startsWith("workflow.variables.")){const m=p.slice(19).split(".")[0],h=n.get(m);if(h&&h!==c){const y=d.has(h),x=`dfg-${h}->${c}-var:${m}`;i.has(x)||(i.add(x),s.push({id:x,sourceRef:h,targetRef:c,fieldPath:`variables.${m}`,expression:`\${${p}}`,sourceType:"workflow_variable",isValidUpstream:y,issue:y?void 0:"forward_ref"}))}continue}if(p.startsWith("workflow."))continue;const f=p.split(".");if(f.length>=2&&(f[1]==="output"||f[1]==="input")){const m=f[0],h=f.slice(2).join(".")||f[1];if(m===c)continue;const y=r.has(m),x=d.has(m);let g;y?x||(g="forward_ref",a.push({taskRef:c,expression:`\${${p}}`,issue:"forward_ref",message:`任务 [${c}] 引用了非上游或互斥分支任务 "${m}" 的输出`})):(g="undefined_ref",a.push({taskRef:c,expression:`\${${p}}`,issue:"undefined_ref",message:`任务 [${c}] 引用了不存在的任务 "${m}"`}));const v=`dfg-${m}->${c}-${h}`;i.has(v)||(i.add(v),s.push({id:v,sourceRef:m,targetRef:c,fieldPath:h,expression:`\${${p}}`,sourceType:"task_output",isValidUpstream:y&&x,issue:g}))}}}return{edges:s,diagnostics:a}}function xs(e,t,r){const n=t.trim(),s=r.trim();if(!n||!s||n===s)return{updatedDef:e,replacedCount:0,affectedTaskRefs:[]};const a=JSON.parse(JSON.stringify(e));let i=0;const l=new Set,c=n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),d=new RegExp(`\\$\\{\\s*${c}(\\.|\\s*\\})`,"g"),u=new RegExp(`\\$\\.\\b${c}\\b`,"g");function p(m,h){if(typeof m=="string"){let y=m;return d.lastIndex=0,d.test(y)&&(y=y.replace(d,(x,g)=>(i++,l.add(h),`\${${s}${g}`))),u.lastIndex=0,u.test(y)&&(y=y.replace(u,()=>(i++,l.add(h),`$.${s}`))),y}if(Array.isArray(m))return m.map(y=>p(y,h));if(m&&typeof m=="object"){const y={};for(const[x,g]of Object.entries(m))y[x]=p(g,h);return y}return m}const f=gr(a.tasks);for(const m of f){const h=m.taskReferenceName===n?s:m.taskReferenceName;m.taskReferenceName===n&&(m.taskReferenceName=s),m.inputParameters&&(m.inputParameters=p(m.inputParameters,h)),m.httpRequest&&(m.httpRequest=p(m.httpRequest,h)),m.loopCondition&&(m.loopCondition=p(m.loopCondition,h)),m.expression&&(m.expression=p(m.expression,h)),m.caseExpression&&(m.caseExpression=p(m.caseExpression,h)),Array.isArray(m.joinOn)&&(m.joinOn=m.joinOn.map(y=>y===n?(i++,l.add(h),s):y)),Array.isArray(m.defaultExclusiveJoinTask)&&(m.defaultExclusiveJoinTask=m.defaultExclusiveJoinTask.map(y=>y===n?(i++,l.add(h),s):y))}return a.outputParameters&&(a.outputParameters=p(a.outputParameters,"__workflow_output__")),l.delete(s),{updatedDef:a,replacedCount:i,affectedTaskRefs:Array.from(l)}}const ij=/^[a-zA-Z0-9_]+$/,lj=new Set(["workflow"]);function Ev(e,t,r){const n={name:t,taskReferenceName:r,type:e||"SIMPLE",inputParameters:{}};switch(n.type){case"HTTP":n.inputParameters={http_request:{uri:"https://example.com/api",method:"GET",accept:"application/json",contentType:"application/json",headers:{}}};break;case"KAFKA_PUBLISH":n.inputParameters={kafka_request:{bootStrapServers:"localhost:9092",topic:"my_topic",key:"msg_key",value:"${workflow.input.value}",headers:{}}};break;case"JSON_JQ_TRANSFORM":n.inputParameters={queryExpression:".name",input:{}};break;case"SET_VARIABLE":n.inputParameters={variableName:"variableValue"};break;case"SUB_WORKFLOW":n.subWorkflowParam={name:"execution_workflow",version:1};break;case"EVENT":n.sink="conductor";break;case"WAIT":n.inputParameters={duration:"30s"};break;case"TERMINATE":n.inputParameters={terminationStatus:"COMPLETED",workflowOutput:{}};break;case"SWITCH":n.evaluatorType="value-param",n.expression="switchCaseValue",n.inputParameters={switchCaseValue:"${workflow.input.case}"},n.decisionCases={case1:[]},n.defaultCase=[];break;case"DECISION":n.caseValueParam="case_param",n.inputParameters={case_param:"${workflow.input.case}"},n.decisionCases={case1:[]},n.defaultCase=[];break;case"DO_WHILE":n.loopCondition=`if ($.${r}['iteration'] < 3) { true; } else { false; }`,n.loopOver=[];break;case"INLINE":n.inputParameters={evaluatorType:"graaljs",expression:`function execute(input) {
|
|
13
10
|
return { result: input };
|
|
14
11
|
}
|
|
15
|
-
execute($.input);`}):d.type==="DYNAMIC"?(d.dynamicTaskNameParam="taskToExecute",d.inputParameters={taskToExecute:"${workflow.input.taskName}"}):d.type==="HUMAN"?d.humanTaskDef={userFormTemplate:"",assignmentCompletionStrategy:"LEAVE_OPEN"}:d.type==="START_WORKFLOW"?d.inputParameters={startWorkflow:{name:"",version:1,input:{},correlationId:""}}:d.type==="NOOP"&&(d.inputParameters={}),i.isWorkflowStart)u.tasks.unshift(d);else if(i.isLoopBodyStart){const g=Be(u.tasks,n);g&&(g.loopOver||(g.loopOver=[]),g.loopOver.unshift(d))}else i.branchCase!==void 0||i.forkIndex!==void 0||i.isLoopAdd?Rt(u.tasks,n,i,d):u.tasks.length===0?u.tasks.push(d):Ze(u.tasks,n,d);$e(u.tasks);const{nodes:p,edges:h,taskMap:f}=Me(u,c,{hideEmptyBranches:t().mode!=="edit"}),{nodes:m,edges:y}=Oe(p,h,{direction:c,mode:t().mode}),v=He(u);e({workflowDef:u,nodes:m,edges:y,taskMap:f,validationResults:v}),o0("builtin")},removeNode:r=>{const{workflowDef:n,layoutDirection:s,nodes:a}=t();if(!n)return;const i=JSON.parse(JSON.stringify(n)),l=Et(i.tasks,r);if(l){const m=a.find(y=>y.id===r)?.data?.taskType;if(m==="FORK_JOIN"||m==="FORK_JOIN_DYNAMIC"){const y=Ig(l,r);y&&rt(i.tasks,y)}else if(m==="JOIN"||m==="EXCLUSIVE_JOIN"){const y=Cg(l,r);y&&rt(i.tasks,y)}}rt(i.tasks,r),$e(i.tasks);const{nodes:c,edges:u,taskMap:d}=Me(i,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:p,edges:h}=Oe(c,u,{direction:s,mode:t().mode}),f=He(i);e({workflowDef:i,nodes:p,edges:h,taskMap:d,validationResults:f})},addLoopTask:(r,n)=>{const{workflowDef:s,layoutDirection:a}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=Be(i.tasks,r);if(l&&l.type==="DO_WHILE"){l.loopOver||(l.loopOver=[]);const c={name:`new_${n.toLowerCase()}`,taskReferenceName:`${r}_sub_${Date.now()}`,type:n,inputParameters:{}};l.loopOver.push(c),$e(i.tasks);const{nodes:u,edges:d,taskMap:p}=Me(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:h,edges:f}=Oe(u,d,{direction:a,mode:t().mode}),m=He(i);e({workflowDef:i,nodes:h,edges:f,taskMap:p,validationResults:m})}},removeLoopTask:(r,n)=>{const{workflowDef:s,layoutDirection:a}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=Be(i.tasks,r);if(l&&l.type==="DO_WHILE"&&l.loopOver){const c=Et(l.loopOver,n);if(c){const y=c.find(v=>v.taskReferenceName===n);if(y?.type==="FORK_JOIN"||y?.type==="FORK_JOIN_DYNAMIC"){const v=Ig(c,n);v&&rt(l.loopOver,v)}else if(y?.type==="JOIN"||y?.type==="EXCLUSIVE_JOIN"){const v=Cg(c,n);v&&rt(l.loopOver,v)}}rt(l.loopOver,n),$e(i.tasks);const{nodes:u,edges:d,taskMap:p}=Me(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:h,edges:f}=Oe(u,d,{direction:a,mode:t().mode}),m=He(i);e({workflowDef:i,nodes:h,edges:f,taskMap:p,validationResults:m})}},addDecisionBranch:(r,n)=>{const{workflowDef:s,layoutDirection:a}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=Be(i.tasks,r);if(l&&(l.type==="DECISION"||l.type==="SWITCH")){n==="default"?l.defaultCase||(l.defaultCase=[]):(l.decisionCases||(l.decisionCases={}),l.decisionCases[n]||(l.decisionCases[n]=[])),$e(i.tasks);const{nodes:c,edges:u,taskMap:d}=Me(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:p,edges:h}=Oe(c,u,{direction:a,mode:t().mode}),f=He(i);e({workflowDef:i,nodes:p,edges:h,taskMap:d,validationResults:f})}},removeDecisionBranch:(r,n)=>{const{workflowDef:s,layoutDirection:a}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=Be(i.tasks,r);if(l&&(l.type==="DECISION"||l.type==="SWITCH")){n==="default"?l.defaultCase=[]:l.decisionCases&&delete l.decisionCases[n],$e(i.tasks);const{nodes:c,edges:u,taskMap:d}=Me(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:p,edges:h}=Oe(c,u,{direction:a,mode:t().mode}),f=He(i);e({workflowDef:i,nodes:p,edges:h,taskMap:d,validationResults:f})}},renameDecisionBranch:(r,n,s)=>{const{workflowDef:a,layoutDirection:i}=t();if(!a||!s.trim()||n===s)return;const l=JSON.parse(JSON.stringify(a)),c=Be(l.tasks,r);if(c&&(c.type==="DECISION"||c.type==="SWITCH")){if(!c.decisionCases||!c.decisionCases[n])return;c.decisionCases[s.trim()]=c.decisionCases[n],delete c.decisionCases[n],$e(l.tasks);const{nodes:u,edges:d,taskMap:p}=Me(l,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:h,edges:f}=Oe(u,d,{direction:i,mode:t().mode}),m=He(l);e({workflowDef:l,nodes:h,edges:f,taskMap:p,validationResults:m})}},addForkBranch:r=>{const{workflowDef:n,layoutDirection:s}=t();if(!n)return;const a=JSON.parse(JSON.stringify(n)),i=Be(a.tasks,r);if(i&&i.type==="FORK_JOIN"){i.forkTasks||(i.forkTasks=[]),i.forkTasks.push([]),$e(a.tasks);const{nodes:l,edges:c,taskMap:u}=Me(a,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:d,edges:p}=Oe(l,c,{direction:s,mode:t().mode}),h=He(a);e({workflowDef:a,nodes:d,edges:p,taskMap:u,validationResults:h})}},copyTask:r=>e({copiedTask:r}),pasteTask:r=>{const{workflowDef:n,layoutDirection:s,selectedTask:a}=t();if(!n)return;const i=JSON.parse(JSON.stringify(n)),c=`_copy_${Date.now()}`,u=JSON.parse(JSON.stringify(r)),d=x=>{x.taskReferenceName=`${x.taskReferenceName}${c}`,x.decisionCases&&Object.values(x.decisionCases).forEach(b=>b.forEach(d)),x.defaultCase&&x.defaultCase.forEach(d),x.forkTasks&&x.forkTasks.forEach(b=>b.forEach(d)),x.loopOver&&x.loopOver.forEach(d)};d(u);const p=a?a.taskReferenceName:i.tasks.length>0?i.tasks[i.tasks.length-1].taskReferenceName:"start";if(u.type==="FORK_JOIN"){u.forkTasks||(u.forkTasks=[[],[]]);const x={name:`${u.name}_join`,taskReferenceName:`${u.taskReferenceName}_join`,type:"JOIN",joinOn:[]};i.tasks.length===0?i.tasks.push(u,x):(Ze(i.tasks,p,u),Ze(i.tasks,u.taskReferenceName,x))}else i.tasks.length===0?i.tasks.push(u):Ze(i.tasks,p,u);$e(i.tasks);const{nodes:h,edges:f,taskMap:m}=Me(i,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:y,edges:v}=Oe(h,f,{direction:s,mode:t().mode}),g=He(i);e({workflowDef:i,nodes:y,edges:v,taskMap:m,validationResults:g})},flashNodes:r=>{if(r.length===0)return;const n=t().__flashTimeout;n&&clearTimeout(n);const s=new Set(r),a={};t().nodes.forEach(l=>{s.has(l.id)&&(a[l.id]=l.selected??!1)}),e(l=>({nodes:l.nodes.map(c=>s.has(c.id)?{...c,selected:!0}:c)}));const i=setTimeout(()=>{e(l=>({nodes:l.nodes.map(c=>s.has(c.id)?{...c,selected:a[c.id]??!1}:c)}))},2500);t().__flashTimeout=i},setTheme:r=>e({theme:r}),setThemeColor:r=>e({themeColor:r}),setEdgeType:r=>e({edgeType:r}),setNodesLocked:r=>e({nodesLocked:r}),setViewMode:r=>e({viewMode:r}),startSimulation:()=>{const{edges:r,nodes:n,isSimRunning:s}=t();if(s)return;const a=n.filter(p=>!["plusNode","dynamicPlaceholderNode"].includes(p.type??"")).map(p=>p.id),i=r.map(p=>({source:p.source,target:p.target})),l=Yk(a,i);e({isSimRunning:!0,simState:{}});const c={timer:null};t().__simHandle=c;let u=0;const d=()=>{if(u>=l.length||!t().isSimRunning){e({isSimRunning:!1});return}const p=l[u];e(h=>{const f={...h.simState};return p.forEach(m=>f[m]="running"),{simState:f}}),c.timer=setTimeout(()=>{t().isSimRunning&&(e(h=>{const f={...h.simState};return p.forEach(m=>f[m]="done"),{simState:f}}),u++,c.timer=setTimeout(d,280))},700)};d()},stopSimulation:()=>{const r=t().__simHandle;r?.timer&&clearTimeout(r.timer),e({isSimRunning:!1,simState:{}})},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,...s}=r,a={...s,name:r.name||"AI_Generated_Workflow",tasks:n||[],version:r.version||1,schemaVersion:2};t().setWorkflow(a)},setShowRunPanel:r=>e({showRunPanel:r}),setShowAnalysisPanel:r=>e({showAnalysisPanel:r}),setRunState:(r,n,s)=>{e({runState:r,pendingExecutionId:n!==void 0?n:t().pendingExecutionId,executionError:s!==void 0?s:t().executionError})},switchToEditAndFocusParam:(r,n)=>{const{workflowDef:s,layoutDirection:a,taskMap:i}=t();if(!s)return;e({mode:"edit",focusedParamKey:n??null});const{nodes:l,edges:c,taskMap:u}=Me(s,a,{hideEmptyBranches:!1}),{nodes:d,edges:p}=Oe(l,c,{direction:a,mode:"edit"});e({nodes:d,edges:p,taskMap:u});const h=i[r]||u[r];h&&e({selectedTask:{...h},isDetailPanelOpen:!0,showAnalysisPanel:!1})},setShowDataLineage:r=>e({showDataLineage:r}),clearRefactorNotice:()=>e({lastRefactorNotice:null}),setShowWaterfallPanel:r=>e({showWaterfallPanel:r}),setTimeTravelTimestamp:r=>e({timeTravelTimestamp:r}),setLoopIteration:(r,n)=>e({activeLoopIterations:{...t().activeLoopIterations,[r]:n}}),runLocalSandboxDryRun:(r,n,s)=>{const{workflowDef:a}=t();if(!a)return;let i;try{i=Gt(a,{workflowInput:r,taskMocks:n,maxLoopIterations:s})}catch(l){throw zg("error"),l}t().importExecutionJSON(i),e({showWaterfallPanel:!0}),zg(String(i.status))},setInlineCopilotTaskRef:r=>e({inlineCopilotTaskRef:r})}),{partialize:e=>({workflowDef:e.workflowDef,layoutDirection:e.layoutDirection,nodes:a0(e.nodes),graphStale:e.graphStale,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)=>e.workflowDef===t.workflowDef?!0:JSON.stringify(e.workflowDef)===JSON.stringify(t.workflowDef),limit:100}),{name:"conductor-ui-prefs",version:1,storage:hn(()=>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,viewMode:e.viewMode})})),Wg=e=>Symbol.iterator in e,Fg=e=>"entries"in e,Bg=(e,t)=>{const r=e instanceof Map?e:new Map(e.entries()),n=t instanceof Map?t:new Map(t.entries());if(r.size!==n.size)return!1;for(const[s,a]of r)if(!n.has(s)||!Object.is(a,n.get(s)))return!1;return!0},s0=(e,t)=>{const r=e[Symbol.iterator](),n=t[Symbol.iterator]();let s=r.next(),a=n.next();for(;!s.done&&!a.done;){if(!Object.is(s.value,a.value))return!1;s=r.next(),a=n.next()}return!!s.done&&!!a.done};function i0(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:Wg(e)&&Wg(t)?Fg(e)&&Fg(t)?Bg(e,t):s0(e,t):Bg({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function ke(e){const t=I.useRef(void 0);return r=>{const n=e(r);return i0(t.current,n)?t.current:t.current=n}}const l0=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),c0=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),Hg=e=>{const t=c0(e);return t.charAt(0).toUpperCase()+t.slice(1)},Ug=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),d0=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var u0={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 p0=I.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:s="",children:a,iconNode:i,...l},c)=>I.createElement("svg",{ref:c,...u0,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:Ug("lucide",s),...!a&&!d0(l)&&{"aria-hidden":"true"},...l},[...i.map(([u,d])=>I.createElement(u,d)),...Array.isArray(a)?a:[a]]));const ze=(e,t)=>{const r=I.forwardRef(({className:n,...s},a)=>I.createElement(p0,{ref:a,iconNode:t,className:Ug(`lucide-${l0(Hg(e))}`,`lucide-${e}`,n),...s}));return r.displayName=Hg(e),r};const Jg=ze("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 f0=ze("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 h0=ze("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Vg=ze("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);const m0=ze("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 qr=ze("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 Wr=ze("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 g0=ze("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 y0=ze("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 x0=ze("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const b0=ze("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);const v0=ze("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const Kg=ze("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 lc=ze("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 k0=ze("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const S0=ze("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const w0=ze("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"}]]),_0={business:["business"],standard:["business","control"],developer:["business","control","data"]},Qe=[{type:"SIMPLE",label:"任务节点 (Worker)",description:"在远程 Worker 上执行的任务",category:"CORE",icon:Jg,viewCategory:"business"},{type:"SUB_WORKFLOW",label:"子工作流 (Sub Workflow)",description:"调用并执行另一个工作流",category:"CORE",icon:Wr,viewCategory:"business"},{type:"START_WORKFLOW",label:"启动工作流 (Start Workflow)",description:"启动另一个工作流(不等待结果)",category:"SYSTEM",icon:b0,viewCategory:"business"},{type:"HTTP",label:"HTTP 请求",description:"发起 REST/HTTP 调用",category:"SYSTEM",icon:g0,viewCategory:"business"},{type:"INLINE",label:"内联脚本 (Inline)",description:"执行内联脚本(JS/Python/GraalJS)",category:"SYSTEM",icon:Vg,viewCategory:"data"},{type:"JSON_JQ_TRANSFORM",label:"JSON 转换 (JQ)",description:"使用 JQ 表达式转换 JSON 数据",category:"SYSTEM",icon:k0,viewCategory:"data"},{type:"KAFKA_PUBLISH",label:"Kafka 推送",description:"向 Kafka 主题推送消息",category:"SYSTEM",icon:y0,viewCategory:"data"},{type:"EVENT",label:"事件 (Event)",description:"向外部队列系统发布事件",category:"SYSTEM",icon:w0,viewCategory:"data"},{type:"WAIT",label:"等待 (Wait)",description:"暂停流程,直到特定时间或时长",category:"SYSTEM",icon:h0,viewCategory:"control"},{type:"SET_VARIABLE",label:"设置变量 (Set Variable)",description:"设置工作流上下文变量",category:"SYSTEM",icon:m0,viewCategory:"data"},{type:"TERMINATE",label:"终止 (Terminate)",description:"提前结束工作流执行",category:"SYSTEM",icon:f0,viewCategory:"control"},{type:"HUMAN",label:"人工审批 (Human)",description:"等待人工审核或表单提交",category:"SYSTEM",icon:S0,viewCategory:"business"},{type:"DYNAMIC",label:"动态任务 (Dynamic)",description:"运行时动态决定任务类型",category:"SYSTEM",icon:lc,viewCategory:"data"},{type:"NOOP",label:"空操作 (Noop)",description:"占位符任务,无实际操作",category:"SYSTEM",icon:x0,viewCategory:"data"},{type:"LAMBDA",label:"Lambda 脚本 (旧)",description:"已被 INLINE 取代",category:"SYSTEM",icon:Vg,hidden:!0,viewCategory:"data"},{type:"SWITCH",label:"条件分支 (Switch)",description:"基于条件的逻辑分支 (Switch/Case)",category:"FLOW",icon:lc,viewCategory:"control"},{type:"DECISION",label:"判断 (Decision,旧)",description:"基于条件的逻辑分支(旧版,推荐改用 Switch)",category:"FLOW",icon:lc,hidden:!0,viewCategory:"control"},{type:"FORK_JOIN",label:"静态并行 (Fork)",description:"并行执行多个预定义任务分支",category:"FLOW",icon:qr,viewCategory:"control"},{type:"FORK_JOIN_DYNAMIC",label:"动态并行 (Dynamic Fork)",description:"运行时动态生成并行分支",category:"FLOW",icon:qr,viewCategory:"control"},{type:"DO_WHILE",label:"循环 (Do-While)",description:"循环执行直到满足条件",category:"FLOW",icon:Kg,viewCategory:"control"},{type:"JOIN",label:"汇聚 (Join)",description:"等待所有并行分支执行完成",category:"FLOW",icon:Wr,viewCategory:"control"}],j0=[{key:"CORE",label:"基础任务"},{key:"FLOW",label:"逻辑控制"},{key:"SYSTEM",label:"系统集成"}],xt=({message:e,onConfirm:t,onCancel:r})=>{const n=I.useRef(null),{theme:s,themeColor:a}=oe(ke(i=>({theme:i.theme,themeColor:i.themeColor})));return I.useEffect(()=>{n.current?.focus({preventScroll:!0});const i=l=>{l.key==="Escape"&&r()};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[r]),Ge.createPortal(o.jsx("div",{"data-mode":s,"data-brand":a,onClick:r,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"确认操作",onClick:i=>i.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"24px 28px",maxWidth:"380px",width:"90%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.18)"},children:[o.jsx("div",{style:{fontSize:"14px",color:"var(--text-primary)",marginBottom:"24px",lineHeight:"1.6",whiteSpace:"pre-wrap",maxHeight:"50vh",overflowY:"auto"},children:e}),o.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[o.jsx("button",{ref:n,onClick:r,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:"取消"}),o.jsx("button",{onClick:t,style:{padding:"7px 18px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"6px",color:"#ffffff",cursor:"pointer",fontSize:"13px",fontWeight:600},children:"确定"})]})]})}),document.body)},Xt=({children:e,nodeId:t,selected:r=!1,isStartOrEnd:n=!1,isError:s=!1,hasWarning:a=!1,isDecision:i=!1,isHighlighted:l=!1,executionStatus:c,simRunning:u=!1,simDone:d=!1,proposalStatus:p})=>{const{mode:h,removeNode:f}=oe(ke(S=>({mode:S.mode,removeNode:S.removeNode}))),[m,y]=I.useState(!1),v=S=>{S.stopPropagation(),y(!0)},g=h==="edit"&&!n,b=[i?"decision-node-wrapper":"node-wrapper-glass",r?"node-wrapper-selected":"",l?"node-wrapper-highlighted":"",u?"node-sim-running":"",d?"node-sim-done":"",p?`node-proposal-${p}`:""].filter(Boolean).join(" "),k=I.useMemo(()=>{if(h!=="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{}}},[h,c]);return o.jsxs("div",{className:b,style:{position:"relative",...k},children:[g&&o.jsx("button",{onClick:v,"aria-label":"删除任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},title:"删除任务",children:"×"}),s&&o.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)"},title:"此节点配置有误",children:"❗"}),!s&&a&&o.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:"⚠️"}),p&&o.jsx("div",{className:`node-proposal-badge node-proposal-badge-${p}`,children:p==="added"?"+":p==="modified"?"~":"−"}),e,m&&o.jsx(xt,{message:"确定要删除此任务吗?",onConfirm:()=>{f(t),y(!1)},onCancel:()=>y(!1)})]})},T0=({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 o.jsx("div",{className:`execution-status-badge ${n}`,title:e,children:o.jsx("span",{className:"badge-icon",children:r})})},cc=I.memo(T0),I0=/[一-龥]/,C0=({icon:e,header:t,title:r,subTitle:n,meta:s,duration:a,color:i,status:l,isRunning:c,children:u,width:d="240px"})=>{const p=c&&l?l==="COMPLETED"?"var(--status-completed)":l==="FAILED"||l==="FAILED_WITH_TERMINAL_ERROR"?"var(--status-failed)":l==="IN_PROGRESS"||l==="SCHEDULED"?"var(--status-in-progress)":l==="TIMED_OUT"||l==="COMPLETED_WITH_ERRORS"?"var(--status-timed-out)":i:i,h=d==="240px"||d===240?"237px":d;return o.jsxs("div",{style:{display:"flex",flexDirection:"row",width:h,height:u?void 0:"81px",minHeight:"81px",boxSizing:"border-box",position:"relative",overflow:"hidden",borderRadius:"10px"},children:[o.jsx("div",{style:{width:"44px",display:"flex",alignItems:"center",justifyContent:"center",background:"color-mix(in srgb, var(--color-accent) 8%, transparent)",borderLeft:`3px solid ${p}`,borderRight:"1px solid var(--border-primary)",color:p,flexShrink:0},children:o.jsx(e,{size:18,strokeWidth:1.75})}),o.jsxs("div",{style:{flex:1,padding:"6px 12px",display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden",minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",marginBottom:"2px",paddingRight:c&&l?"20px":0},children:[o.jsx("div",{style:{fontSize:"10px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",lineHeight:1.2,opacity:.85,color:i,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",...I0.test(t)&&{letterSpacing:"0.2px",fontSize:"11px"}},children:t}),c&&a&&o.jsx("span",{style:{fontSize:"10px",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",background:"var(--bg-tertiary)",padding:"1px 5px",borderRadius:"4px",flexShrink:0,lineHeight:1.2},children:a})]}),o.jsx("div",{style:{fontSize:"13.5px",fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.25,marginBottom:n||s?"1px":0},title:r,children:r}),n&&n!==r&&n!==s&&o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.25},title:n,children:n}),s&&o.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)",lineHeight:1.25,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:s,children:s}),u&&o.jsx("div",{style:{marginTop:"6px"},children:u})]}),c&&l&&o.jsx("div",{style:{position:"absolute",top:"7px",right:"7px"},children:o.jsx(cc,{status:l})})]})},Fr=I.memo(C0),bt=e=>{const t=e.layoutDirection||"TB",r=e.sourcePosition||(t==="LR"?F.Position.Right:F.Position.Bottom),n=e.targetPosition||(t==="LR"?F.Position.Left:F.Position.Top);return{layoutDirection:t,sourcePosition:r,targetPosition:n}},At=e=>{const{mode:t,executionData:r,workflowDef:n,activeLoopIterations:s,timeTravelTimestamp:a}=oe(ke(f=>({mode:f.mode,executionData:f.executionData,workflowDef:f.workflowDef,activeLoopIterations:f.activeLoopIterations,timeTravelTimestamp:f.timeTravelTimestamp}))),i=t==="run"?r?.[e]:null,l=t==="run";let c=i?{...i}:null;if(l&&c&&c.attempts.length>1&&n?.tasks){let f=0;for(const[m,y]of Object.entries(s)){if(!y)continue;if(r?.[m]||c.attempts.some(g=>g.iteration===y)){f=y;break}}if(f>0){const m=c.attempts.find(y=>y.iteration===f)||c.attempts[f-1];m&&(c={...c,status:m.status,startTime:m.startTime,endTime:m.endTime,input:m.inputData,output:m.outputData,iteration:m.iteration??f})}}if(l&&c&&a!==null){const f=c.startTime??0,m=c.endTime??f;f>a?c={...c,status:"SCHEDULED"}:f<=a&&m>a&&(c={...c,status:"IN_PROGRESS"})}const u=c?.attempts.some(f=>f.iteration!==void 0&&f.iteration>1)??!1,d=c?.attempts[c.attempts.length-1],p=u?0:d?.retryCount??0;let h;if(l&&c?.startTime)if(a!==null&&c.startTime>a)h="待执行";else if(a!==null&&c.startTime<=a&&(c.endTime??c.startTime)>a)h=`${a-c.startTime}ms...`;else if(c.endTime&&c.endTime>=c.startTime){const f=c.endTime-c.startTime;h=f<1e3?`${f}ms`:`${(f/1e3).toFixed(2)}s`}else(c.status==="IN_PROGRESS"||c.status==="SCHEDULED")&&(h="运行中");return{mode:t,execution:c,isRunning:l,retryCount:p,durationText:h}};function ct(e,t){return e.length>t?e.slice(0,t)+"…":e}function Zt(e,t,r,n){if(r==="business")return t.task?.description?.trim()||n;if(r==="standard")return n;const s=t.task;if(!s)return n;const a=s.inputParameters||{};switch(e){case"HTTP":case"HTTP_POLL":{const i=s.httpRequest||a.http_request;if(!i)return n;const l=(i.method||"GET").toUpperCase(),c=i.uri?ct(String(i.uri),28):"";return c?`${l} ${c}`:l}case"SWITCH":{const i=s.caseExpression||a.expression,l=s.evaluatorType||a.evaluatorType;return i?ct(i,35):l||n}case"DECISION":return s.caseValueParam?`param: ${s.caseValueParam}`:n;case"SIMPLE":return s.name?`worker: ${ct(s.name,28)}`:n;case"INLINE":case"LAMBDA":{const i=s.evaluatorType||a.evaluatorType;return i?`${i} script`:n}case"SUB_WORKFLOW":{const i=s.subWorkflowParam;return i?`${i.name}${i.version?` v${i.version}`:""}`:n}case"DO_WHILE":{const i=s.loopCondition;return i?ct(i,35):n}case"JSON_JQ_TRANSFORM":{const i=a.queryExpression||a.query_expression;return i?ct(i,35):n}case"SET_VARIABLE":{const i=Object.keys(a);return i.length?`set: ${i.slice(0,2).join(", ")}${i.length>2?"…":""}`:n}case"EVENT":{const i=s.sink||a.sink;return i?`→ ${ct(i,32)}`:n}case"KAFKA_PUBLISH":{const i=a.topic||a.kafka_request?.topic;return i?`topic: ${ct(i,28)}`:n}case"START_WORKFLOW":{const i=s.startWorkflow?.name??a.startWorkflow?.name??a.start_workflow?.name;return i?`→ ${i}`:n}default:return n}}function Dt(e,t){if(t!=="business")return e;const r=Qe.find(n=>n.type===e);return r?r.label.replace(/\s*\([^)]+\)$/,""):e==="JOIN"?"汇聚":e==="EXCLUSIVE_JOIN"?"排他汇聚":e}const N0=({id:e,data:t,selected:r})=>{const n=t.taskType||"SIMPLE",{sourcePosition:s,targetPosition:a}=bt(t),{execution:i,isRunning:l,retryCount:c,durationText:u}=At(t.taskReferenceName),d=oe(C=>C.viewMode),p=oe(C=>C.mode),h=oe(C=>C.setInlineCopilotTaskRef),m=F.useStore(C=>C.transform[2])>=1.15,y=I.useMemo(()=>Qe.find(C=>C.type===n),[n]),v=y?.icon||Jg,g=n==="NOOP",x=t.isDynamicRuntime===!0,b=g?"var(--text-secondary)":"var(--color-accent)",k=I.useMemo(()=>{let C;return x?C=`Dynamic (${n})`:n==="SIMPLE"?C=t.label==="Worker Task"?"Execute on Worker":"Worker Task":n==="HTTP"?C="REST API Call":n==="JSON_JQ_TRANSFORM"?C="JQ Expression":n==="INLINE"||n==="LAMBDA"?C="Inline Script":n==="START_WORKFLOW"?C="Launch Workflow (no wait)":n==="DYNAMIC"?C="Dynamic Task Type":n==="HUMAN"?C="Human Approval":n==="NOOP"?C="No Operation":C=y?.label||n,Zt(n,t,d,C)},[n,y,t,d,x]),S=I.useMemo(()=>!m||!t.task?.inputParameters?[]:Object.entries(t.task.inputParameters).slice(0,2).map(([T,N])=>({key:T,val:typeof N=="object"?JSON.stringify(N).slice(0,28):String(N).slice(0,28)})),[m,t.task?.inputParameters]);return o.jsx(Xt,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:i?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{style:{borderRadius:"10px",background:g?"var(--bg-tertiary)":"transparent",opacity:g?.75:1,position:"relative",outline:x?"2px dashed var(--color-accent)":"none",outlineOffset:"-2px"},children:[o.jsx(Fr,{icon:v,header:Dt(n,d),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:k,duration:u,color:b,status:i?.status,isRunning:l}),S.length>0&&o.jsx("div",{style:{padding:"4px 10px 6px",borderTop:"1px dashed var(--border-primary)",fontSize:"9px",fontFamily:"monospace",color:"var(--text-secondary)",display:"flex",flexDirection:"column",gap:"2px"},children:S.map(C=>o.jsxs("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[o.jsx("span",{style:{color:"#38bdf8"},children:C.key}),": ",C.val]},C.key))}),r&&p==="edit"&&o.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),h(t.taskReferenceName)},title:"在此节点触发 ⌘K 画布内联 AI 指令",style:{position:"absolute",top:"-10px",right:"20px",padding:"1px 6px",borderRadius:"999px",border:"1px solid rgba(99, 102, 241, 0.6)",background:"linear-gradient(135deg, #6366f1, #38bdf8)",color:"#fff",fontSize:"9px",fontWeight:700,cursor:"pointer",zIndex:102,boxShadow:"0 2px 6px rgba(0,0,0,0.3)"},children:"⌘K"}),l&&c>0&&o.jsxs("div",{style:{position:"absolute",bottom:"4px",right:"4px",background:"var(--status-failed, #ef4444)",color:"#fff",borderRadius:"10px",fontSize:"10px",fontWeight:"700",padding:"1px 6px",zIndex:10,lineHeight:"1.4",pointerEvents:"none"},children:["×",c]}),x&&o.jsx("div",{style:{position:"absolute",top:"4px",right:"4px",background:"var(--color-accent)",color:"#fff",borderRadius:"4px",fontSize:"9px",fontWeight:"700",padding:"1px 5px",zIndex:10,pointerEvents:"none",opacity:.9},children:"动态"}),o.jsx(F.Handle,{type:"target",position:a,style:{background:"#fff"}}),o.jsx(F.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})},E0=I.memo(N0),Gg=({title:e,label:t,defaultValue:r="",placeholder:n="",confirmText:s="确定",cancelText:a="取消",onConfirm:i,onCancel:l})=>{const{theme:c,themeColor:u}=oe(ke(m=>({theme:m.theme,themeColor:m.themeColor}))),[d,p]=I.useState(r),h=I.useRef(null);I.useEffect(()=>{h.current&&(h.current.focus({preventScroll:!0}),h.current.select());const m=y=>{y.key==="Escape"&&(y.stopPropagation(),l())};return window.addEventListener("keydown",m,!0),()=>window.removeEventListener("keydown",m,!0)},[l]);const f=()=>{const m=d.trim();m&&i(m)};return Ge.createPortal(o.jsx("div",{"data-mode":c,"data-brand":u,onClick:l,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"rgba(0, 0, 0, 0.45)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e,onClick:m=>m.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"10px",padding:"24px 28px",maxWidth:"400px",width:"90%",boxShadow:"0 8px 32px rgba(0, 0, 0, 0.22)"},children:[o.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"var(--text-primary)",marginBottom:"16px"},children:e}),t&&o.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px"},children:t}),o.jsx("input",{ref:h,type:"text",value:d,placeholder:n,onChange:m=>p(m.target.value),onKeyDown:m=>{m.key==="Enter"&&(m.preventDefault(),f()),m.stopPropagation()},style:{width:"100%",padding:"9px 12px",borderRadius:"6px",border:"1px solid var(--border-primary)",background:"var(--bg-tertiary)",color:"var(--text-primary)",fontSize:"13px",outline:"none",boxSizing:"border-box",marginBottom:"20px",transition:"border-color 0.15s"},onFocus:m=>{m.currentTarget.style.borderColor="var(--color-accent)"},onBlur:m=>{m.currentTarget.style.borderColor="var(--border-primary)"}}),o.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[o.jsx("button",{onClick:l,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:a}),o.jsx("button",{onClick:f,disabled:!d.trim(),style:{padding:"7px 18px",backgroundColor:d.trim()?"var(--color-accent)":"var(--bg-tertiary)",border:"none",borderRadius:"6px",color:d.trim()?"#ffffff":"var(--text-secondary)",cursor:d.trim()?"pointer":"not-allowed",fontSize:"13px",fontWeight:600,transition:"background-color 0.15s, color 0.15s"},children:s})]})]})}),document.body)},R0=({id:e,data:t,selected:r})=>{const{layoutDirection:n}=bt(t),{mode:s,execution:a,isRunning:i,durationText:l}=At(t.taskReferenceName),{addDecisionBranch:c,removeDecisionBranch:u,renameDecisionBranch:d,viewMode:p}=oe(ke(j=>({addDecisionBranch:j.addDecisionBranch,removeDecisionBranch:j.removeDecisionBranch,renameDecisionBranch:j.renameDecisionBranch,viewMode:j.viewMode}))),[h,f]=I.useState(!1),[m,y]=I.useState({type:"none"}),v=n==="LR"?F.Position.Left:F.Position.Top,g=Object.keys(t.decisionCases||t.task?.decisionCases||{}),x=()=>{f(!1),y({type:"add"})},b=(j,P)=>{j.stopPropagation(),y({type:"delete",branch:P})},k=(j,P)=>{j.stopPropagation(),f(!1),y({type:"rename",branch:P})},S=j=>{j&&c(e,j),y({type:"none"})},C=j=>{m.type==="rename"&&(j&&j!==m.branch&&d(e,m.branch,j),y({type:"none"}))},T=()=>{m.type==="delete"&&(u(e,m.branch),y({type:"none"}))},N=()=>y({type:"none"}),_=i?(j=>j&&{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"}[j]||"")(a?.status):"";return o.jsxs(Xt,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isDecision:!0,isHighlighted:t.isHighlighted,executionStatus:a?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:[o.jsxs("div",{style:{position:"relative",width:"164px",height:"164px",display:"flex",alignItems:"center",justifyContent:"center"},children:[o.jsx(F.Handle,{type:"target",position:v,style:{background:"#fff",[n==="LR"?"left":"top"]:"-3px",zIndex:15}}),i&&a?.status&&o.jsx("div",{style:{position:"absolute",top:"12px",right:"12px",zIndex:20},children:o.jsx(cc,{status:a.status})}),o.jsx("div",{className:_,style:{width:"122px",height:"122px",boxSizing:"border-box",borderRadius:"10px",background:i&&a?.status?void 0:"var(--glass-bg)",backdropFilter:"var(--glass-blur)",WebkitBackdropFilter:"var(--glass-blur)",border:r?"2.5px solid var(--color-accent)":i&&a?.status?void 0:"2px solid rgba(var(--color-accent-rgb), 0.45)",transform:"rotate(45deg)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:r?"0 8px 26px rgba(0,0,0,0.35), 0 0 0 3px var(--node-glow-color)":i&&a?.status?void 0:"var(--node-shadow)",transition:"all 0.25s ease",cursor:"pointer",flexShrink:0},onClick:()=>s==="edit"&&f(!h),children:o.jsxs("div",{style:{transform:"rotate(-45deg)",color:"#fff",textAlign:"center",padding:"6px",width:"116px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[o.jsx("div",{style:{fontSize:"10px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.85,marginBottom:"2px",color:"var(--color-accent)"},children:Dt(t.taskType,p)}),o.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-primary)",lineHeight:1.25,maxWidth:"104px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t.taskReferenceName,children:t.taskReferenceName}),t.label&&t.label!==t.taskReferenceName&&o.jsx("div",{style:{fontSize:"10px",color:"var(--text-secondary)",maxWidth:"98px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"1px"},title:t.label,children:t.label}),s==="edit"&&o.jsx("div",{style:{width:"18px",height:"18px",fontSize:"12px",background:"color-mix(in srgb, var(--color-accent) 18%, transparent)",border:"1px solid rgba(var(--color-accent-rgb), 0.4)",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:"4px auto 0",color:"var(--color-accent)",fontWeight:700},title:"管理决策分支",children:"+"}),i&&l&&o.jsx("div",{style:{fontSize:"10px",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",background:"var(--bg-tertiary)",padding:"1px 5px",borderRadius:"4px",marginTop:"3px"},children:l})]})}),s==="edit"&&h&&o.jsxs("div",{className:"glass-panel",style:{position:"absolute",top:"170px",left:"50%",transform:"translateX(-50%)",backgroundColor:"var(--glass-surface)",border:"1px solid var(--glass-border)",borderRadius:"8px",padding:"8px",zIndex:1e3,minWidth:"200px",boxShadow:"0 10px 25px rgba(0,0,0,0.5)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",backdropFilter:"blur(12px)"},children:[o.jsx("div",{style:{padding:"4px 8px 6px",fontSize:"11px",color:"var(--text-secondary)",borderBottom:"1px solid var(--glass-border)",marginBottom:"4px",fontWeight:600,letterSpacing:"0.05em"},children:"分支管理"}),g.map(j=>o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"5px 6px",borderRadius:"4px",gap:"4px"},children:[o.jsx("span",{style:{flex:1,fontSize:"12px",color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:j}),o.jsx("button",{onClick:P=>k(P,j),style:{width:"22px",height:"22px",borderRadius:"4px",backgroundColor:"var(--color-accent)",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",padding:0,flexShrink:0,opacity:.85},title:`重命名分支 "${j}"`,children:"✏"}),o.jsx("button",{onClick:P=>b(P,j),style:{width:"22px",height:"22px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",padding:0,flexShrink:0,opacity:.9},title:`删除分支 "${j}"`,children:"×"})]},j)),o.jsx("button",{onClick:x,style:{width:"100%",marginTop:"6px",padding:"8px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"4px",color:"#fff",cursor:"pointer",fontSize:"12px",fontWeight:"bold"},children:"+ 添加新分支"})]}),p==="developer"&&(()=>{const j=t.task?.caseExpression||t.task?.inputParameters?.expression,P=t.task?.caseValueParam;return!j&&!P?null:o.jsx("div",{style:{position:"absolute",top:"166px",left:"50%",transform:"translateX(-50%)",textAlign:"center",fontSize:10,color:"var(--text-secondary)",maxWidth:150,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",fontFamily:"var(--font-mono, monospace)"},children:j?ct(j,22):`param: ${P}`})})(),n==="TB"?o.jsxs(o.Fragment,{children:[o.jsx(F.Handle,{type:"source",position:F.Position.Bottom,style:{background:"#fff",bottom:"-3px",zIndex:15}}),o.jsx(F.Handle,{type:"source",position:F.Position.Left,id:"left",style:{background:"#fff",left:"-3px",zIndex:15}}),o.jsx(F.Handle,{type:"source",position:F.Position.Right,id:"right",style:{background:"#fff",right:"-3px",zIndex:15}})]}):o.jsxs(o.Fragment,{children:[o.jsx(F.Handle,{type:"source",position:F.Position.Right,style:{background:"#fff",right:"-3px",zIndex:15}}),o.jsx(F.Handle,{type:"source",position:F.Position.Top,id:"top",style:{background:"#fff",top:"-3px",zIndex:15}}),o.jsx(F.Handle,{type:"source",position:F.Position.Bottom,id:"bottom",style:{background:"#fff",bottom:"-3px",zIndex:15}})]})]}),m.type==="add"&&o.jsx(Gg,{title:"添加新分支",label:"分支条件值(Case Value)",defaultValue:`case_${g.length+1}`,placeholder:"例如:approved、rejected、pending",confirmText:"添加",onConfirm:S,onCancel:N}),m.type==="rename"&&o.jsx(Gg,{title:"重命名分支",label:`当前名称:${m.branch}`,defaultValue:m.branch,placeholder:"输入新的分支条件值",confirmText:"重命名",onConfirm:C,onCancel:N}),m.type==="delete"&&o.jsx(xt,{message:`确定要删除分支 "${m.branch}" 及其下的所有任务吗?此操作不可撤销。`,onConfirm:T,onCancel:N})]})},P0=I.memo(R0),Yg="var(--color-accent)",Xg=I.memo(({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:s,targetPosition:a}=bt(t),{mode:i,execution:l,isRunning:c,durationText:u}=At(t.taskReferenceName),{addForkBranch:d}=oe(ke(g=>({addForkBranch:g.addForkBranch}))),p=F.useUpdateNodeInternals(),h=t.task?.forkTasks?.length||0;I.useEffect(()=>{p(e)},[h,e,p]);const f=t.isDynamic||t.taskType==="FORK_JOIN_DYNAMIC",m=oe(g=>g.viewMode),v=I.useMemo(()=>Qe.find(g=>g.type==="FORK_JOIN"),[])?.icon||qr;return o.jsx(Xt,{isHighlighted:t.isHighlighted,nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,executionStatus:l?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{className:`fork-node ${f?"dynamic":"static"}`,style:{borderRadius:"10px",background:"transparent",position:"relative"},children:[o.jsx(Fr,{icon:v,header:Dt(f?"FORK_JOIN_DYNAMIC":"FORK_JOIN",m),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:Zt(t.taskType,t,m,f?"Dynamic Parallel Execution":"Parallel Execution"),duration:u,color:Yg,status:l?.status,isRunning:c}),i==="edit"&&!f&&o.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(),d(e)},title:"添加分支",children:"+"}),o.jsx(F.Handle,{type:"target",position:a,style:{background:"#fff"}}),!f&&(t.task?.forkTasks||[]).map((g,x,b)=>{if(i!=="edit"&&(!g||g.length===0))return null;const k=i!=="edit"?b.filter(N=>N&&N.length>0):b,S=k.length,T=(k.indexOf(g)+1)/(S+1)*100;return o.jsx(F.Handle,{id:`branch_${x}`,type:"source",position:s,style:{background:"#fff",[n==="LR"?"top":"left"]:`${T}%`,[n==="LR"?"left":"top"]:void 0,[n==="LR"?"right":"bottom"]:"-4px",zIndex:10}},`branch_${x}`)}),!f&&(!t.task?.forkTasks||t.task.forkTasks.length===0)&&o.jsx(F.Handle,{type:"source",position:s,style:{background:"#fff"}}),f&&o.jsx(F.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})});Xg.displayName="ForkNode";const Zg=I.memo(({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:s,targetPosition:a}=bt(t),{execution:i,isRunning:l,durationText:c}=At(t.taskReferenceName),u=oe(h=>h.viewMode),p=I.useMemo(()=>Qe.find(h=>h.type==="JOIN"),[])?.icon||Wr;return o.jsx(Xt,{isHighlighted:t.isHighlighted,nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,executionStatus:i?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{style:{borderRadius:"10px",background:"transparent",position:"relative"},children:[o.jsx(Fr,{icon:p,header:Dt(t.taskType==="EXCLUSIVE_JOIN"?"EXCLUSIVE_JOIN":"JOIN",u),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:Zt(t.taskType,t,u,t.taskType==="EXCLUSIVE_JOIN"?"Wait for any task":"Wait for tasks"),duration:c,color:Yg,status:i?.status,isRunning:l}),o.jsx(F.Handle,{type:"target",position:a,style:{background:"#fff"}}),n==="TB"&&o.jsxs(o.Fragment,{children:[o.jsx(F.Handle,{type:"target",position:F.Position.Left,id:"left",style:{background:"#fff"}}),o.jsx(F.Handle,{type:"target",position:F.Position.Right,id:"right",style:{background:"#fff"}})]}),n==="LR"&&o.jsxs(o.Fragment,{children:[o.jsx(F.Handle,{type:"target",position:F.Position.Top,id:"top",style:{background:"#fff"}}),o.jsx(F.Handle,{type:"target",position:F.Position.Bottom,id:"bottom",style:{background:"#fff"}})]}),o.jsx(F.Handle,{type:"source",position:s,style:{background:"#fff"}})]})})});Zg.displayName="JoinNode";const Qg={ForkNode:Xg,JoinNode:Zg},O0=({id:e,data:t,selected:r})=>{const{sourcePosition:n,targetPosition:s}=bt(t),{execution:a,isRunning:i,durationText:l}=At(t.taskReferenceName),{executionData:c,selectTaskAction:u,mode:d,viewMode:p,removeNode:h,activeLoopIterations:f,setLoopIteration:m}=oe(ke(E=>({executionData:E.executionData,selectTaskAction:E.selectTaskAction,mode:E.mode,viewMode:E.viewMode,removeNode:E.removeNode,activeLoopIterations:E.activeLoopIterations,setLoopIteration:E.setLoopIteration}))),[y,v]=I.useState(!1),g=t.task,x=g?.loopOver||[],k=I.useMemo(()=>Qe.find(E=>E.type==="DO_WHILE"),[])?.icon||Kg,S=I.useMemo(()=>{if(!i||!c)return 0;let E=a?.iteration??0;return x.forEach(A=>{const L=c[A.taskReferenceName];L?.totalIterations?E=Math.max(E,L.totalIterations):L?.attempts.some(B=>(B.iteration??0)>0)&&(E=Math.max(E,L.attempts.length))}),E},[i,c,x,a?.iteration]),C=f[t.taskReferenceName]||S,T=t.loopCondition||g?.loopCondition||"",N=I.useMemo(()=>{const E=T?T.length>35?T.slice(0,35)+"…":T:"循环直到条件满足";return Zt("DO_WHILE",t,p,E)},[t,p,T]),w=a?.status==="COMPLETED"?"var(--status-completed)":a?.status==="FAILED"||a?.status==="FAILED_WITH_TERMINAL_ERROR"?"var(--status-failed)":a?.status==="IN_PROGRESS"||a?.status==="SCHEDULED"?"var(--status-in-progress)":"var(--color-accent)",_=r?`2px solid ${w}`:`1.5px dashed ${i&&a?.status?w:"var(--color-accent)"}`,j=d==="edit",P=p==="developer"&&T;return o.jsxs("div",{style:{width:"100%",height:"100%",border:_,borderRadius:"10px",background:"transparent",display:"flex",flexDirection:"column",position:"relative",overflow:"visible",boxSizing:"border-box",pointerEvents:"none"},children:[j&&o.jsx("button",{onClick:E=>{E.stopPropagation(),v(!0)},"aria-label":"删除循环任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",padding:0,pointerEvents:"auto"},title:"删除循环任务",children:"×"}),t.isError&&o.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#ef4444",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点配置有误",children:"❗"}),!t.isError&&t.hasWarning&&o.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"#f59e0b",color:"white",border:"2px solid white",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"0 2px 8px rgba(0,0,0,0.2)",pointerEvents:"auto"},title:"此节点有警告信息",children:"⚠️"}),t.proposalStatus&&o.jsx("div",{className:`node-proposal-badge node-proposal-badge-${t.proposalStatus}`,style:{pointerEvents:"auto"},children:t.proposalStatus==="added"?"+":t.proposalStatus==="modified"?"~":"−"}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:"var(--glass-surface)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",borderBottom:"1px solid var(--border-primary)",borderRadius:"8px 8px 0 0",flexShrink:0,minHeight:"44px",pointerEvents:"auto"},children:[o.jsx("div",{style:{color:"var(--color-accent)",display:"flex",alignItems:"center",flexShrink:0},children:o.jsx(k,{size:15})}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[o.jsx("span",{style:{fontSize:"9px",fontWeight:700,color:"var(--color-accent)",letterSpacing:"0.08em",textTransform:"uppercase"},children:Dt("DO_WHILE",p)}),o.jsxs("span",{style:{fontSize:"9px",color:"var(--text-muted)"},children:["↻ ",x.length," 个子任务"]})]}),o.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.taskReferenceName}),(p==="business"||p==="developer")&&N&&o.jsx("div",{style:{fontSize:"9px",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"1px",fontStyle:"italic"},children:N})]}),i&&l&&o.jsx("span",{style:{fontSize:"10px",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",background:"var(--bg-secondary)",padding:"1px 6px",borderRadius:"4px",flexShrink:0},children:l}),i&&S>0&&o.jsxs("div",{onClick:()=>u(g||null),style:{padding:"2px 8px",borderRadius:"12px",background:"var(--color-accent)",color:"#fff",fontSize:"10px",fontWeight:700,cursor:"pointer",flexShrink:0},title:`共执行 ${S} 次迭代`,children:["×",S]}),i&&a?.status&&o.jsx("div",{style:{position:"relative",width:20,height:20,flexShrink:0},children:o.jsx(cc,{status:a.status})})]}),i&&S>1&&o.jsxs("div",{onClick:E=>E.stopPropagation(),style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 10px",background:"rgba(15, 23, 42, 0.72)",borderBottom:"1px solid var(--border-primary)",flexShrink:0,pointerEvents:"auto",overflowX:"auto"},children:[o.jsx("span",{style:{fontSize:"9px",color:"#94a3b8",fontWeight:600,marginRight:"2px"},children:"切换轮次:"}),Array.from({length:S},(E,A)=>A+1).map(E=>{const A=C===E;return o.jsxs("button",{type:"button",onClick:L=>{L.stopPropagation(),m(t.taskReferenceName,E)},style:{fontSize:"9px",padding:"1px 7px",borderRadius:"999px",border:A?"1px solid #38bdf8":"1px solid rgba(148, 163, 184, 0.25)",background:A?"rgba(56, 189, 248, 0.22)":"rgba(30, 41, 59, 0.6)",color:A?"#38bdf8":"#cbd5e1",fontWeight:A?700:500,cursor:"pointer"},children:["#",E]},E)})]}),P&&o.jsxs("div",{style:{padding:"3px 12px",fontSize:"9px",color:"var(--text-secondary)",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:0,pointerEvents:"auto"},children:["until: ",T]}),o.jsx("div",{style:{flex:1,position:"relative",background:"var(--loop-body-bg, rgba(99,102,241,0.04))",borderRadius:"0 0 8px 8px",pointerEvents:"none"}}),o.jsx(F.Handle,{type:"target",position:s,style:{background:"var(--color-accent)",zIndex:10}}),o.jsx(F.Handle,{type:"source",position:n,style:{background:"var(--color-accent)",zIndex:10}}),y&&o.jsx(xt,{message:"确定要删除此循环任务吗?循环体内的任务也会一并删除。",onConfirm:()=>{h(e),v(!1)},onCancel:()=>v(!1)})]})},A0=I.memo(O0),D0="var(--color-accent)",L0=({id:e,data:t,selected:r})=>{const{sourcePosition:n,targetPosition:s}=bt(t),{execution:a,isRunning:i,durationText:l}=At(t.taskReferenceName),c=oe(f=>f.viewMode),d=I.useMemo(()=>Qe.find(f=>f.type==="SUB_WORKFLOW"),[])?.icon||Wr,p=t.task?.subWorkflowParam?.name||t.subWorkflowName||"Unknown",h=t.task?.subWorkflowParam?.version;return o.jsx(Xt,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:a?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{style:{borderRadius:"10px",background:"transparent",position:"relative"},children:[o.jsx(Fr,{icon:d,header:Dt("SUB_WORKFLOW",c),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:Zt("SUB_WORKFLOW",t,c,`Flow: ${p}${h!==void 0?` (v${h})`:""}`),duration:l,color:D0,status:a?.status,isRunning:i}),o.jsx(F.Handle,{type:"target",position:s,style:{background:"#fff"}}),o.jsx(F.Handle,{type:"source",position:n,style:{background:"#fff"}})]})})},M0=I.memo(L0),$0=({data:e})=>{const r=(e.layoutDirection||"TB")==="LR";return o.jsxs("div",{className:"plus-node-container",style:{width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"var(--bg-secondary, #1e293b)",border:"2px dashed var(--color-accent, #3b82f6)",color:"var(--color-accent, #3b82f6)",cursor:"pointer",transition:"all 0.2s ease",padding:e.label&&e.label!=="+"?"0 12px":"0",minWidth:e.label&&e.label!=="+"?"80px":"32px",gap:"4px"},children:[o.jsx(v0,{size:16}),e.label&&e.label!=="+"&&o.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:e.label}),o.jsx(F.Handle,{type:"target",position:r?F.Position.Left:F.Position.Top,style:{opacity:0}}),o.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
12
|
+
execute($.input);`};break;case"DYNAMIC":n.dynamicTaskNameParam="taskToExecute",n.inputParameters={taskToExecute:"${workflow.input.taskName}"};break;case"HUMAN":n.humanTaskDef={userFormTemplate:"",assignmentCompletionStrategy:"LEAVE_OPEN"};break;case"START_WORKFLOW":n.inputParameters={startWorkflow:{name:"",version:1,input:{},correlationId:""}};break;case"FORK_JOIN":n.forkTasks=[[],[]];break;case"FORK_JOIN_DYNAMIC":n.dynamicForkTasksParam="dynamicTasks",n.dynamicForkTasksInputParamName="dynamicTasksInput",n.inputParameters={dynamicTasks:"${workflow.input.dynamicTasks}",dynamicTasksInput:"${workflow.input.dynamicTasksInput}"};break}return n}function cu(e,t){let r=`${e.taskReferenceName}_join`;if(t){let s=2;for(;t.has(r);)r=`${e.taskReferenceName}_join_${s++}`}const n=e.type==="FORK_JOIN"?(e.forkTasks||[]).filter(s=>Array.isArray(s)&&s.length>0).map(s=>s[s.length-1].taskReferenceName):[];return{name:`${e.name}_join`,taskReferenceName:r,type:"JOIN",joinOn:n}}function vs(e,t,r){const n=(t??"").trim();return n?n===r?null:ij.test(n)?lj.has(n)?`"${n}" 是表达式保留字,不能作为引用名:请换一个名称`:n.startsWith("__")?"引用名不能以两个下划线开头(编辑器内部保留):请换一个名称":st(e?.tasks).has(n)?`引用名 "${n}" 已被其他任务使用:请换一个名称`:null:`引用名 "${n}" 含有不支持的字符:只能使用字母、数字和下划线`:"引用名不能为空:请输入由字母、数字或下划线组成的名称"}function bs(e,t,r){const n=(t??"").trim();return n?r!==void 0&&n===r?null:n==="default"?'"default" 是默认分支的保留名:请换一个分支名':e?.decisionCases&&Object.prototype.hasOwnProperty.call(e.decisionCases,n)?`分支 "${n}" 已存在:请换一个分支名`:null:"分支名不能为空:请输入分支条件值"}const du=e=>{const t=[];return e.decisionCases&&Object.values(e.decisionCases).forEach(r=>t.push(...r||[])),e.defaultCase&&t.push(...e.defaultCase),e.forkTasks&&e.forkTasks.forEach(r=>t.push(...r||[])),e.loopOver&&t.push(...e.loopOver),st(t).size};function uu(e,t){const r=e?.tasks,n=Qe(r,t);if(!n)return{message:`删除任务 "${t}"?可以用 ⌘Z 撤销。`,removedRefs:[t]};const s=zt(r,t)||[],a="可以用 ⌘Z 撤销。";if(n.type==="FORK_JOIN"||n.type==="FORK_JOIN_DYNAMIC"){const l=hs(s,t),c=du(n),d=[t,...l?[l]:[],...st((n.forkTasks||[]).flat())],u=[`删除并行任务 "${t}"`];return l&&u.push(`会同时删除配对的汇合任务 "${l}"`),c>0&&u.push(`${l?"和":"会同时删除"}分支中的 ${c} 个任务`),{message:`${u.join("")}。${a}`,removedRefs:d}}if(n.type==="JOIN"||n.type==="EXCLUSIVE_JOIN"){const l=au(s,t),c=l?Qe(r,l):null;if(c){const d=du(c),u=[t,c.taskReferenceName,...st((c.forkTasks||[]).flat())],p=d>0?`和分支中的 ${d} 个任务`:"";return{message:`删除汇合任务 "${t}" 会同时删除配对的并行任务 "${c.taskReferenceName}"${p}。${a}`,removedRefs:u}}}const i=du(n);if(i>0){const l=n.type==="DO_WHILE"?"循环体":"分支";return{message:`删除${n.type==="DO_WHILE"?"循环":n.type==="SWITCH"||n.type==="DECISION"?"条件分支":"任务"} "${t}" 会同时删除${l}中的 ${i} 个任务。${a}`,removedRefs:Array.from(st([n]))}}return{message:`删除任务 "${t}"?${a}`,removedRefs:[t]}}function cj(e,t,r){const n=new Set(t),s=Array.from(st([e])),a=[];s.forEach(d=>{let u=`${d}${r}`,p=2;for(;n.has(u)||s.includes(u);)u=`${d}${r}_${p++}`;n.add(u),a.push([d,u])});let i={name:"__paste__",tasks:[JSON.parse(JSON.stringify(e))]};a.sort((d,u)=>u[0].length-d[0].length).forEach(([d,u])=>{i=xs(i,d,u).updatedDef});const l=i.tasks[0];let c=null;return(l.type==="FORK_JOIN"||l.type==="FORK_JOIN_DYNAMIC")&&(l.type==="FORK_JOIN"&&!l.forkTasks&&(l.forkTasks=[[],[]]),c=cu(l,n)),{task:l,join:c}}const Rv=["timeoutSeconds","retryLogic","retryDelaySeconds","timeoutPolicy"];function ks(e,t){const r=e.taskDefinition;return r&&r[t]!==void 0?r[t]:e[t]}function dj(e,t,r,n){const s={...e.taskDefinition||{}};s.name||(s.name=e.name),!s.ownerEmail&&n&&(s.ownerEmail=n),Rv.forEach(l=>{s[l]===void 0&&e[l]!==void 0&&(s[l]=e[l])}),r===void 0||r===""?delete s[t]:s[t]=r;const a=s.timeoutSeconds;typeof a=="number"&&a>0&&(typeof s.responseTimeoutSeconds!="number"||s.responseTimeoutSeconds>a)&&(s.responseTimeoutSeconds=a);const i={taskDefinition:s};return Rv.forEach(l=>{e[l]!==void 0&&(i[l]=void 0)}),i}function Ov(e,t={}){const r=e.trim();if(!r)return t.allowEmpty?{ok:!0,value:{}}:{ok:!1,error:"内容为空:请填写 JSON,例如 {}"};try{const n=JSON.parse(r);return t.requireObject&&(n===null||typeof n!="object"||Array.isArray(n))?{ok:!1,error:'这里需要一个 JSON 对象:请用 { } 包起来,例如 {"key": "value"}'}:{ok:!0,value:n}}catch(n){return{ok:!1,error:`JSON 格式有误(${n?.message||"无法解析"}):修正后点击输入框外即可保存,未保存前画布保持原值`}}}const nt=e=>typeof e=="string"&&e.trim()!=="",uj=[{field:"name",type:"required",message:"工作流名称 (name) 必填"},{field:"tasks",type:"min_length",value:1,message:"工作流必须包含至少一个任务"}],Pv={common:[{field:"name",type:"required",message:"任务类型名称 (name) 必填"},{field:"taskReferenceName",type:"required",message:"引用名 (taskReferenceName) 必填"},{field:"taskReferenceName",type:"pattern",value:/^[a-zA-Z0-9_]+$/,message:"引用名仅允许字母、数字和下划线"},{field:"taskReferenceName",type:"unique",message:"引用名在工作流中必须唯一"}],types:{HTTP:[{field:"inputParameters.http_request.uri",type:"required",message:"HTTP 任务缺少请求地址 (uri) 配置"},{field:"inputParameters.http_request.method",type:"required",level:"warning",message:"HTTP 任务未指定 Method,建议配置"}],INLINE:[{field:"inputParameters.expression",type:"custom",validate:e=>nt(e),message:"INLINE 任务缺少脚本表达式 (expression)"},{field:"inputParameters.expression",type:"custom",validate:(e,t)=>nt(e)||!nt(t?.inputParameters?.scriptExpression),message:"INLINE 任务把脚本写在了 scriptExpression(LAMBDA 的字段),Conductor 不会执行:把它移到 inputParameters.expression"},{field:"inputParameters.evaluatorType",type:"required",level:"warning",message:"INLINE 任务未在 inputParameters 中指定 evaluatorType:Conductor 需要它来选择脚本引擎,建议填 graaljs"}],LAMBDA:[{field:"inputParameters.scriptExpression",type:"required",message:"LAMBDA 任务缺少脚本表达式 (scriptExpression)"}],JSON_JQ_TRANSFORM:[{field:"inputParameters.queryExpression",type:"required",message:"JQ 任务缺少查询表达式 (queryExpression)"}],SUB_WORKFLOW:[{field:"subWorkflowParam.name",type:"required",message:"子工作流任务缺少子流程名称 (name)"}],START_WORKFLOW:[{field:"inputParameters.startWorkflow.name",type:"custom",validate:(e,t)=>!!t?.inputParameters?.startWorkflow?.name,message:"START_WORKFLOW 任务缺少目标工作流名称"}],KAFKA_PUBLISH:[{field:"inputParameters.kafka_request.topic",type:"custom",validate:e=>nt(e),message:"KAFKA_PUBLISH 任务缺少主题:在 inputParameters.kafka_request.topic 填写要推送的 topic"},{field:"inputParameters.kafka_request.bootStrapServers",type:"custom",validate:e=>nt(e),message:"KAFKA_PUBLISH 任务缺少 Kafka 地址:在 inputParameters.kafka_request.bootStrapServers 填写,如 kafka-1:9092,kafka-2:9092"}],EVENT:[{field:"sink",type:"custom",validate:e=>nt(e),message:"EVENT 任务缺少 sink:填写事件发往哪里,如 conductor 或 kafka:topic_name"}],WAIT:[{field:"inputParameters.until",type:"custom",validate:(e,t)=>!(nt(e)&&nt(t?.inputParameters?.duration)),message:"WAIT 任务同时配置了 duration 和 until,Conductor 只允许二选一:等一段时间用 duration,等到某个时刻用 until"}],DYNAMIC:[{field:"dynamicTaskNameParam",type:"required",message:"DYNAMIC 任务缺少 dynamicTaskNameParam 配置"}],TERMINATE:[{field:"inputParameters.terminationStatus",type:"required",level:"warning",message:"终止任务未指定状态 (terminationStatus)"},{field:"inputParameters.terminationStatus",type:"enum",value:["COMPLETED","FAILED","TERMINATED"],message:"终止状态必须为 COMPLETED、FAILED 或 TERMINATED"}],DO_WHILE:[{field:"loopCondition",type:"custom",validate:(e,t)=>!!(t?.loopCondition||t?.inputParameters?.items),message:"循环任务需要配置退出条件 (loopCondition) 或列表 (items)"}],DECISION:[{field:"decisionCases",type:"custom",validate:e=>Object.keys(e||{}).length>0,message:"决策任务必须至少包含一个分支 (decisionCases)"},{field:"decisionCases",type:"custom",validate:e=>{const 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 任务必须至少包含一个分支"},{field:"expression",type:"custom",validate:(e,t)=>nt(e)||nt(t?.caseValueParam)||nt(t?.caseExpression),message:"SWITCH 任务缺少条件表达式 (expression):value-param 模式填 inputParameters 中的参数名,脚本模式填返回分支名的脚本"},{field:"expression",type:"custom",validate:(e,t)=>nt(e)||!(nt(t?.caseValueParam)||nt(t?.caseExpression)),message:"SWITCH 任务只配置了 caseValueParam / caseExpression(DECISION 的字段),Conductor 保存时会拒绝:把 caseValueParam 的值填到 expression 并选 value-param,或把 caseExpression 的脚本填到 expression 并选 javascript"},{field:"evaluatorType",type:"custom",validate:(e,t)=>nt(e)||!nt(t?.expression),message:"SWITCH 任务缺少评估模式 (evaluatorType):expression 是参数名时选 value-param,是脚本时选 javascript 或 graaljs"}],FORK_JOIN_DYNAMIC:[{field:"dynamicForkTasksParam",type:"custom",validate:(e,t)=>!!(t?.dynamicForkTasksParam||t?.inputParameters?.forkTaskType||t?.inputParameters?.forkTaskName||t?.inputParameters?.forkTaskWorkflow||t?.forkTaskType||t?.forkTaskWorkflow),message:"FORK_JOIN_DYNAMIC 任务需要配置 dynamicForkTasksParam 或 forkTaskType 或 forkTaskWorkflow",level:"warning"}]}};class pj{rules=[];setRules(t){this.rules=[...t]}getRules(){return this.rules}hasRules(){return this.rules.length>0}runAll(t){const r=[],n=[];for(const s of this.rules)try{const a=s.validate(t);for(const i of a)s.level==="warning"?n.push(i):r.push(i)}catch{r.push({type:"GLOBAL",ref:"",message:`自定义规则 "${s.id}" 执行异常`})}return{errors:r,warnings:n}}buildPromptSection(){return this.rules.length===0?null:`## 业务校验规则(必须遵守)
|
|
13
|
+
以下规则由集成方定义,生成工作流时必须满足:
|
|
14
|
+
${this.rules.map(r=>`- ${r.description}`).join(`
|
|
15
|
+
`)}`}}const pu=new pj,fj=(e,t)=>t.split(".").reduce((r,n)=>r&&r[n]!==void 0?r[n]:void 0,e),fu=(e,t,r,n)=>{const{errors:s,warnings:a}=n,i=e.taskReferenceName||"GLOBAL";t.forEach(l=>{const c=fj(e,l.field);let d=!0;switch(l.type){case"required":d=c!=null&&c!=="";break;case"min_length":d=Array.isArray(c)&&c.length>=l.value;break;case"pattern":d=l.value.test(c);break;case"enum":d=c==null||c===""||l.value.includes(c);break;case"unique":l.field==="taskReferenceName"&&c&&(r.taskRefs.has(c)?d=!1:r.taskRefs.add(c));break;case"custom":typeof l.validate=="function"&&(d=l.validate(c,e,r));break}if(!d){const u={type:e.taskReferenceName?"TASK":"GLOBAL",ref:i,message:l.message};l.level==="warning"?a.push(u):s.push(u)}})},Et=e=>{const t=[],r=[],n={taskRefs:new Set,taskMap:{}};if(!e)return{isValid:!1,errors:[{type:"GLOBAL",ref:"",message:"工作流定义为空"}],warnings:[]};if(fu(e,uj,n,{errors:t,warnings:r}),!e.tasks||e.tasks.length===0)return{isValid:!1,errors:t,warnings:r};const s=new Set,a=d=>{(d||[]).forEach(u=>{u&&(u.taskReferenceName&&s.add(u.taskReferenceName),u.decisionCases&&Object.values(u.decisionCases).forEach(a),a(u.defaultCase),(u.forkTasks||[]).forEach(a),a(u.loopOver))})};a(e.tasks);const i=d=>{d.forEach((u,p)=>{if(!u)return;if(u.type==="FORK_JOIN"||u.type==="FORK_JOIN_DYNAMIC"){const m=d[p+1];(!m||m.type!=="JOIN")&&t.push({type:"TASK",ref:u.taskReferenceName,message:`并行任务 "${u.taskReferenceName}" 后面必须紧跟一个 JOIN 任务:请在它之后添加 JOIN,或删除中间插入的任务`})}Array.isArray(u.joinOn)&&u.joinOn.forEach(m=>{s.has(m)||t.push({type:"TASK",ref:u.taskReferenceName,message:`JOIN 任务 "${u.taskReferenceName}" 的 joinOn 引用了不存在的任务 "${m}":请删除该项或改成分支中实际的任务引用名`})}),fu(u,Pv.common,n,{errors:t,warnings:r});const f=Pv.types[u.type];f&&fu(u,f,n,{errors:t,warnings:r}),u.decisionCases&&Object.keys(u.decisionCases).forEach(m=>{i(u.decisionCases[m])}),u.defaultCase&&i(u.defaultCase),u.forkTasks&&u.forkTasks.forEach(m=>i(m)),u.loopOver&&i(u.loopOver)})};i(e.tasks);const l=new Set;lu(e).diagnostics.forEach(d=>{if(d.issue!=="undefined_ref")return;const u=`${d.taskRef}|${d.expression}`;l.has(u)||(l.add(u),t.push({type:"TASK",ref:d.taskRef,message:`任务 "${d.taskRef}" 的表达式 ${d.expression} 引用了不存在的任务:请改成已有任务的引用名,或先添加该任务`}))});const c=mj(e.tasks);if(t.push(...c),pu.hasRules()){const d=pu.runAll(e);t.push(...d.errors),r.push(...d.warnings)}return{isValid:t.length===0,errors:t,warnings:r}},mj=e=>{const t=[],r=new Map,n=new Set,s=u=>{for(let p=0;p<u.length;p++){const f=u[p],m=f.taskReferenceName;if(n.add(m),r.has(m)||r.set(m,[]),p<u.length-1){const h=u[p+1].taskReferenceName;f.type!=="FORK_JOIN"&&f.type!=="FORK_JOIN_DYNAMIC"&&r.get(m).push(h)}if(f.decisionCases)for(const h of Object.values(f.decisionCases))h.length>0&&(r.get(m).push(h[0].taskReferenceName),s(h));if(f.defaultCase&&f.defaultCase.length>0&&(r.get(m).push(f.defaultCase[0].taskReferenceName),s(f.defaultCase)),f.forkTasks)for(const h of f.forkTasks)h.length>0&&(r.get(m).push(h[0].taskReferenceName),s(h));if(f.loopOver)for(const h of f.loopOver)n.add(h.taskReferenceName);if(f.joinOn)for(const h of f.joinOn)r.has(h)||r.set(h,[]),r.get(h).push(m)}};s(e);const a=0,i=1,l=2,c=new Map;for(const u of n)c.set(u,a);const d=u=>{c.set(u,i);const p=r.get(u)||[];for(const f of p)if(c.has(f)){if(c.get(f)===i)return t.push({type:"GLOBAL",ref:f,message:`检测到环路:任务 "${u}" → "${f}" 形成了循环依赖`}),!0;if(c.get(f)===a&&d(f))return!0}return c.set(u,l),!1};for(const u of n)c.get(u)===a&&d(u);return t};function hj(e,t){const r=new Set(e),n={};e.forEach(l=>n[l]=0),t.forEach(l=>{r.has(l.source)&&r.has(l.target)&&(n[l.target]=(n[l.target]??0)+1)});const s=[];let a=e.filter(l=>n[l]===0);const i={...n};for(;a.length>0;){s.push([...a]);const l=[];a.forEach(c=>{t.forEach(d=>{d.source===c&&r.has(d.target)&&(i[d.target]--,i[d.target]===0&&l.push(d.target))})}),a=l}return s}class xe extends Error{constructor(t){super(t),this.name="JqError"}}const yj=new Set(["if","then","elif","else","end","as","and","or","reduce","foreach","try","catch","def","label","import","include"]);function gj(e){const t=[];let r=0;const n=a=>/[A-Za-z_]/.test(a),s=a=>/[A-Za-z0-9_]/.test(a);for(;r<e.length;){const a=e[r];if(/\s/.test(a)){r++;continue}if(a==="#"){for(;r<e.length&&e[r]!==`
|
|
16
|
+
`;)r++;continue}if(/[0-9]/.test(a)||a==="."&&/[0-9]/.test(e[r+1]??"")){const l=/^(?:\d+\.?\d*|\.\d+)(?:[eE][+-]?\d+)?/.exec(e.slice(r));t.push({t:"num",v:Number(l[0])}),r+=l[0].length;continue}if(a==='"'){const[l,c]=xj(e,r+1);t.push({t:"str",parts:l}),r=c;continue}if(a==="$"){let l=r+1;if(e.startsWith("__loc__",l))throw new xe("不支持 $__loc__");for(;l<e.length&&s(e[l]);)l++;if(l===r+1)throw new xe(`第 ${r+1} 个字符:$ 后缺少变量名`);t.push({t:"var",v:e.slice(r+1,l)}),r=l;continue}if(a==="."&&n(e[r+1]??"")){let l=r+1;for(;l<e.length&&s(e[l]);)l++;t.push({t:"field",v:e.slice(r+1,l)}),r=l;continue}if(n(a)){let l=r;for(;l<e.length&&(s(e[l])||e[l]===":"&&e[l+1]===":");)l+=e[l]===":"?2:1;t.push({t:"id",v:e.slice(r,l)}),r=l;continue}const i=e.slice(r,r+2);if(["==","!=","<=",">=","//","..","?/","|=","+=","-=","*=","/=","%="].includes(i)){if(i==="?/")throw new xe("不支持 ?// 运算符");if(i.endsWith("=")&&i!=="=="&&i!=="!="&&i!=="<="&&i!==">=")throw new xe(`不支持赋值运算符 ${i}`);t.push({t:"op",v:i}),r+=2;continue}if(".|,()[]{}:;+-*/%<>?=".includes(a)){if(a==="=")throw new xe("不支持赋值运算符 =,比较请用 ==");t.push({t:"op",v:a}),r++;continue}throw a==="@"?new xe("不支持 @base64 / @csv 等格式化字符串"):new xe(`第 ${r+1} 个字符 "${a}" 无法识别`)}return t.push({t:"eof"}),t}function xj(e,t){const r=[];let n="",s=t;for(;s<e.length;){const a=e[s];if(a==='"')return(n||r.length===0)&&r.push(n),[r,s+1];if(a==="\\"){const i=e[s+1];if(i==="("){let c=1,d=s+2,u=!1;for(;d<e.length&&c>0;){const p=e[d];u?p==="\\"?d++:p==='"'&&(u=!1):p==='"'?u=!0:p==="("?c++:p===")"&&c--,d++}if(c!==0)throw new xe("字符串插值 \\( 缺少右括号");n&&r.push(n),n="",r.push(Av(e.slice(s+2,d-1))),s=d;continue}const l={n:`
|
|
17
|
+
`,t:" ",r:"\r",b:"\b",f:"\f",'"':'"',"\\":"\\","/":"/"};if(i==="u"){n+=String.fromCharCode(parseInt(e.slice(s+2,s+6),16)),s+=6;continue}if(!(i in l))throw new xe(`字符串里的转义 \\${i} 无效`);n+=l[i],s+=2;continue}n+=a,s++}throw new xe("字符串缺少结尾的引号")}function Av(e){const t=gj(e);let r=0;const n=()=>t[r],s=w=>n().t==="op"&&n().v===w,a=w=>n().t==="id"&&n().v===w,i=w=>{if(!s(w))throw new xe(`语法错误:这里应该是 "${w}"`);r++},l=w=>{if(!a(w))throw new xe(`语法错误:这里应该是 "${w}"`);r++};function c(){let w=u();if(a("as")){r++;const I=n();if(I.t!=="var")throw new xe("as 后面应是 $变量");return r++,i("|"),{k:"as",source:w,name:I.v,body:c()}}for(;s("|");)r++,w={k:"pipe",left:w,right:d()};return w}function d(){const w=u();if(a("as")){r++;const I=n();if(I.t!=="var")throw new xe("as 后面应是 $变量");return r++,i("|"),{k:"as",source:w,name:I.v,body:c()}}return w}function u(){let w=p();for(;s(",");)r++,w={k:"comma",left:w,right:p()};return w}function p(){let w=f();for(;s("//");)r++,w={k:"bin",op:"//",left:w,right:f()};return w}function f(){let w=m();for(;a("or");)r++,w={k:"bin",op:"or",left:w,right:m()};return w}function m(){let w=h();for(;a("and");)r++,w={k:"bin",op:"and",left:w,right:h()};return w}function h(){const w=y();for(const I of["==","!=","<=",">=","<",">"])if(s(I))return r++,{k:"bin",op:I,left:w,right:y()};return w}function y(){let w=x();for(;s("+")||s("-");)w={k:"bin",op:t[r++].v,left:w,right:x()};return w}function x(){let w=g();for(;s("*")||s("/")||s("%");)w={k:"bin",op:t[r++].v,left:w,right:g()};return w}function g(){return s("-")?(r++,{k:"neg",body:g()}):v(k())}function v(w){for(;;){const I=n();if(I.t==="field")r++,w={k:"index",target:w,key:{k:"lit",v:I.v}};else if(s(".")&&t[r+1].t==="str"){r++;const N=t[r++];w={k:"index",target:w,key:{k:"str",parts:N.parts}}}else if(s(".")&&t[r+1].t==="op"&&t[r+1].v==="[")r++;else if(s("["))if(r++,s("]"))r++,w={k:"iterate",target:w};else if(s(":")){r++;const N=c();i("]"),w={k:"slice",target:w,from:null,to:N}}else{const N=c();if(s(":")){r++;const C=s("]")?null:c();i("]"),w={k:"slice",target:w,from:N,to:C}}else i("]"),w={k:"index",target:w,key:N}}else if(s("?"))r++,w={k:"optional",body:w};else return w}}function k(){const w=n();if(w.t==="num")return r++,{k:"lit",v:w.v};if(w.t==="str")return r++,{k:"str",parts:w.parts};if(w.t==="var")return r++,{k:"var",name:w.v};if(w.t==="field")return r++,{k:"index",target:{k:"identity"},key:{k:"lit",v:w.v}};if(w.t==="op"){if(w.v==="."){if(r++,n().t==="str"){const I=t[r++];return{k:"index",target:{k:"identity"},key:{k:"str",parts:I.parts}}}return{k:"identity"}}if(w.v==="..")return r++,{k:"recurse"};if(w.v==="("){r++;const I=c();return i(")"),I}if(w.v==="["){if(r++,s("]"))return r++,{k:"array",body:null};const I=c();return i("]"),{k:"array",body:I}}if(w.v==="{")return r++,b()}if(w.t==="id"){if(w.v==="true"||w.v==="false"||w.v==="null")return r++,{k:"lit",v:w.v==="null"?null:w.v==="true"};if(w.v==="if")return S();if(w.v==="reduce")return j();if(yj.has(w.v))throw new xe(`不支持 ${w.v} 语法`);r++;const I=[];if(s("(")){for(r++,I.push(c());s(";");)r++,I.push(c());i(")")}return{k:"call",name:w.v,args:I}}throw w.t==="eof"?new xe("表达式不完整"):new xe(`语法错误:意外的 "${w.v??w.t}"`)}function b(){const w=[];for(;!s("}");){const I=n();let N,C=null;if(I.t==="id"||I.t==="field"){r++;const R=(I.t==="field",I.v);N={k:"lit",v:R},C={k:"index",target:{k:"identity"},key:{k:"lit",v:R}}}else if(I.t==="var")r++,N={k:"lit",v:I.v},C={k:"var",name:I.v};else if(I.t==="str")r++,N={k:"str",parts:I.parts},C={k:"index",target:{k:"identity"},key:N};else{if(I.t==="num")throw new xe("对象的键不能是数字");if(s("("))r++,N=c(),i(")");else throw new xe("对象构造语法错误")}let M=C;if(s(":"))r++,M=p();else if(!C)throw new xe('对象的计算键后面需要 ": 值"');if(w.push({key:N,value:M}),s(","))r++;else break}return i("}"),{k:"object",entries:w}}function S(){l("if");const w=c();l("then");const I=c(),N=[];for(;a("elif");){r++;const M=c();l("then"),N.push({cond:M,then:c()})}let C=null;return a("else")&&(r++,C=c()),l("end"),{k:"if",cond:w,then:I,elifs:N,else:C}}function j(){l("reduce");const w=v(k());l("as");const I=n();if(I.t!=="var")throw new xe("reduce ... as 后面应是 $变量");r++,i("(");const N=c();i(";");const C=c();return i(")"),{k:"reduce",source:w,name:I.v,init:N,update:C}}const _=c();if(n().t!=="eof")throw new xe("表达式在末尾有多余内容");return _}const qe=e=>e===null?"null":Array.isArray(e)?"array":typeof e=="object"?"object":typeof e=="number"?"number":typeof e=="string"?"string":"boolean",xt=e=>e!==null&&e!==!1&&e!==void 0,$v={null:0,boolean:1,number:2,string:3,array:4,object:5};function qt(e,t){const r=qe(e),n=qe(t);if(r!==n)return r==="boolean"&&n==="boolean"?0:$v[r]-$v[n];switch(r){case"null":return 0;case"boolean":return(e?1:0)-(t?1:0);case"number":return e-t;case"string":return e<t?-1:e>t?1:0;case"array":{const s=e,a=t;for(let i=0;i<Math.min(s.length,a.length);i++){const l=qt(s[i],a[i]);if(l)return l}return s.length-a.length}default:{const s=e,a=t,i=Object.keys(s).sort(),l=Object.keys(a).sort(),c=qt(i,l);if(c)return c;for(const d of i){const u=qt(s[d],a[d]);if(u)return u}return 0}}}const er=(e,t)=>qt(e,t)===0,Dv=e=>e===void 0?e:JSON.parse(JSON.stringify(e));function Lv(e,t){const r={...e};for(const[n,s]of Object.entries(t)){const a=r[n];r[n]=a&&s&&qe(a)==="object"&&qe(s)==="object"?Lv(a,s):s}return r}function Mv(e,t,r){const n=qe(t),s=qe(r);switch(e){case"+":if(t===null)return r;if(r===null)return t;if(n==="number"&&s==="number"||n==="string"&&s==="string")return t+r;if(n==="array"&&s==="array")return[...t,...r];if(n==="object"&&s==="object")return{...t,...r};break;case"-":if(n==="number"&&s==="number")return t-r;if(n==="array"&&s==="array")return t.filter(a=>!r.some(i=>er(a,i)));break;case"*":if(n==="number"&&s==="number")return t*r;if(n==="object"&&s==="object")return Lv(t,r);if(n==="string"&&s==="number")return r>0?t.repeat(Math.floor(r)):null;break;case"/":if(n==="number"&&s==="number"){if(r===0)throw new xe("除数为 0");return t/r}if(n==="string"&&s==="string")return t.split(r);break;case"%":if(n==="number"&&s==="number"){if(Math.trunc(r)===0)throw new xe("取模的除数为 0");return Math.trunc(t)%Math.trunc(r)}break}throw new xe(`${n} 和 ${s} 不能做 ${e} 运算`)}function ws(e,t){if(e===null)return null;if(typeof t=="string"){if(qe(e)!=="object")throw new xe(`不能用字符串 "${t}" 索引 ${qe(e)}`);const r=e[t];return r===void 0?null:r}if(typeof t=="number"){if(!Array.isArray(e))throw new xe(`不能用数字索引 ${qe(e)}`);const r=Math.floor(t)<0?e.length+Math.floor(t):Math.floor(t);return e[r]===void 0?null:e[r]}throw new xe(`不能用 ${qe(t)} 作为索引`)}function xr(e){if(Array.isArray(e))return e;if(e&&typeof e=="object")return Object.values(e);throw new xe(`不能遍历 ${qe(e)}(.[] 只能用于数组或对象)`)}function vj(e){switch(qe(e)){case"null":return 0;case"boolean":throw new xe("boolean 没有长度");case"number":return Math.abs(e);case"string":return[...e].length;case"array":return e.length;default:return Object.keys(e).length}}const sn=e=>typeof e=="string"?e:JSON.stringify(e);function Ss(e,t){const r=qe(e);if(r!==qe(t))throw new xe(`${r} 与 ${qe(t)} 不能做 contains`);return r==="string"?e.includes(t):r==="array"?t.every(n=>e.some(s=>Ss(s,n)||er(s,n))):r==="object"?Object.entries(t).every(([n,s])=>n in e&&Ss(e[n],s)):er(e,t)}function me(e,t,r){switch(e.k){case"identity":return[t];case"recurse":{const n=[],s=a=>{if(n.push(a),a&&typeof a=="object")for(const i of xr(a))s(i)};return s(t),n}case"lit":return[e.v];case"str":{let n=[""];for(const s of e.parts)if(typeof s=="string")n=n.map(a=>a+s);else{const a=me(s,t,r);n=n.flatMap(i=>a.map(l=>i+sn(l)))}return n}case"var":if(!(e.name in r))throw new xe(`变量 $${e.name} 未定义`);return[r[e.name]];case"index":return me(e.target,t,r).flatMap(n=>me(e.key,t,r).map(s=>ws(n,s)));case"slice":return me(e.target,t,r).map(n=>{if(n===null)return null;const s=e.from?me(e.from,t,r)[0]:0,a=e.to?me(e.to,t,r)[0]:void 0;if(typeof n=="string"||Array.isArray(n))return n.slice(s??0,a??void 0);throw new xe(`不能切片 ${qe(n)}`)});case"iterate":return me(e.target,t,r).flatMap(xr);case"optional":try{return me(e.body,t,r)}catch(n){if(n instanceof xe&&!String(n.message).startsWith("不支持"))return[];throw n}case"pipe":return me(e.left,t,r).flatMap(n=>me(e.right,n,r));case"comma":return[...me(e.left,t,r),...me(e.right,t,r)];case"neg":return me(e.body,t,r).map(n=>{if(typeof n!="number")throw new xe(`不能对 ${qe(n)} 取负`);return-n});case"bin":{if(e.op==="and"||e.op==="or")return me(e.left,t,r).flatMap(i=>e.op==="and"&&!xt(i)?[!1]:e.op==="or"&&xt(i)?[!0]:me(e.right,t,r).map(l=>xt(l)));if(e.op==="//"){let i=[];try{i=me(e.left,t,r).filter(xt)}catch(l){if(!(l instanceof xe))throw l}return i.length?i:me(e.right,t,r)}const n=me(e.right,t,r),s=me(e.left,t,r),a=[];for(const i of n)for(const l of s)switch(e.op){case"==":a.push(er(l,i));break;case"!=":a.push(!er(l,i));break;case"<":a.push(qt(l,i)<0);break;case"<=":a.push(qt(l,i)<=0);break;case">":a.push(qt(l,i)>0);break;case">=":a.push(qt(l,i)>=0);break;default:a.push(Mv(e.op,l,i))}return a}case"array":return[e.body?me(e.body,t,r):[]];case"object":{let n=[{}];for(const s of e.entries){const a=me(s.key,t,r),i=s.value?me(s.value,t,r):[],l=[];for(const c of n)for(const d of a){if(typeof d!="string")throw new xe(`对象的键必须是字符串,得到 ${qe(d)}`);for(const u of i)l.push({...c,[d]:u})}n=l}return n}case"if":return me(e.cond,t,r).flatMap(n=>{if(xt(n))return me(e.then,t,r);for(const s of e.elifs)if(me(s.cond,t,r).some(xt))return me(s.then,t,r);return e.else?me(e.else,t,r):[t]});case"as":return me(e.source,t,r).flatMap(n=>me(e.body,t,{...r,[e.name]:n}));case"reduce":{let n=me(e.init,t,r);for(const s of me(e.source,t,r))n=n.flatMap(a=>me(e.update,a,{...r,[e.name]:s}));return n}case"call":return _s(e.name,e.args,t,r)}}const Be=(e,t,r)=>{const n=me(e,t,r);if(n.length!==1)throw new xe("参数必须恰好产生一个值");return n[0]},Ge=(e,t,r)=>{if(qe(e)!==t)throw new xe(`${r} 需要 ${t},得到 ${qe(e)}`)};function an(e,t){return e.map((r,n)=>({v:r,k:t(r),i:n})).sort((r,n)=>qt(r.k,n.k)||r.i-n.i).map(r=>r.v)}function _s(e,t,r,n){const s=`${e}/${t.length}`,a=i=>(Ge(r,"array",i),r);switch(s){case"empty/0":return[];case"not/0":return[!xt(r)];case"error/0":throw new xe(sn(r));case"error/1":throw new xe(sn(Be(t[0],r,n)));case"length/0":return[vj(r)];case"type/0":return[qe(r)];case"keys/0":case"keys_unsorted/0":return Array.isArray(r)?[r.map((i,l)=>l)]:(Ge(r,"object",e),[e==="keys"?Object.keys(r).sort():Object.keys(r)]);case"values/0":return r===null?[]:[r];case"has/1":{const i=Be(t[0],r,n);return Array.isArray(r)?[typeof i=="number"&&i>=0&&i<r.length]:(Ge(r,"object","has"),[Object.prototype.hasOwnProperty.call(r,i)])}case"in/1":{const i=Be(t[0],r,n);return _s("has",[{k:"lit",v:r}],i,n)}case"map/1":return[a("map").flatMap(i=>me(t[0],i,n))];case"map_values/1":{if(Array.isArray(r))return[r.map(l=>me(t[0],l,n)[0]).filter(l=>l!==void 0)];Ge(r,"object","map_values");const i={};for(const[l,c]of Object.entries(r)){const d=me(t[0],c,n);d.length&&(i[l]=d[0])}return[i]}case"select/1":return me(t[0],r,n).some(xt)?[r]:[];case"recurse/0":return me({k:"recurse"},r,n);case"add/0":return[xr(r).reduce((l,c)=>l===void 0?c:Mv("+",l,c),void 0)??null];case"any/0":return[xr(r).some(xt)];case"all/0":return[xr(r).every(xt)];case"any/1":return[xr(r).some(i=>me(t[0],i,n).some(xt))];case"all/1":return[xr(r).every(i=>me(t[0],i,n).every(xt))];case"range/1":{const i=Be(t[0],r,n);return Array.from({length:Math.max(0,Math.ceil(i))},(l,c)=>c)}case"range/2":{const i=Be(t[0],r,n),l=Be(t[1],r,n),c=[];for(let d=i;d<l;d++)c.push(d);return c}case"floor/0":return Ge(r,"number","floor"),[Math.floor(r)];case"ceil/0":return Ge(r,"number","ceil"),[Math.ceil(r)];case"round/0":return Ge(r,"number","round"),[Math.round(r)];case"sqrt/0":return Ge(r,"number","sqrt"),[Math.sqrt(r)];case"fabs/0":case"abs/0":return Ge(r,"number",e),[Math.abs(r)];case"tostring/0":return[sn(r)];case"tonumber/0":{if(typeof r=="number")return[r];const i=Number(r);if(typeof r!="string"||r.trim()===""||Number.isNaN(i))throw new xe(`无法把 ${sn(r)} 转成数字`);return[i]}case"tojson/0":return[JSON.stringify(r)];case"fromjson/0":Ge(r,"string","fromjson");try{return[JSON.parse(r)]}catch{throw new xe(`fromjson 解析失败:${r}`)}case"ascii_downcase/0":return Ge(r,"string",e),[r.toLowerCase()];case"ascii_upcase/0":return Ge(r,"string",e),[r.toUpperCase()];case"ltrimstr/1":{const i=Be(t[0],r,n);return[typeof r=="string"&&typeof i=="string"&&r.startsWith(i)?r.slice(i.length):r]}case"rtrimstr/1":{const i=Be(t[0],r,n);return[typeof r=="string"&&typeof i=="string"&&i&&r.endsWith(i)?r.slice(0,-i.length):r]}case"trim/0":return Ge(r,"string","trim"),[r.trim()];case"startswith/1":return Ge(r,"string",e),[r.startsWith(Be(t[0],r,n))];case"endswith/1":return Ge(r,"string",e),[r.endsWith(Be(t[0],r,n))];case"split/1":return Ge(r,"string","split"),[r.split(Be(t[0],r,n))];case"join/1":{const i=Be(t[0],r,n);return[a("join").map(l=>l===null?"":typeof l=="object"?(()=>{throw new xe("join 只能连接字符串、数字与布尔值")})():String(l)).join(i)]}case"test/1":case"test/2":{Ge(r,"string","test");const i=Be(t[0],r,n),l=t[1]?Be(t[1],r,n).replace(/[^gimsuy]/g,""):"";return[new RegExp(i,l.replace("g","")).test(r)]}case"sub/2":case"gsub/2":{Ge(r,"string",e);const i=new RegExp(Be(t[0],r,n),e==="gsub"?"g":"");return[r.replace(i,Be(t[1],r,n))]}case"contains/1":return[Ss(r,Be(t[0],r,n))];case"inside/1":return[Ss(Be(t[0],r,n),r)];case"sort/0":return[an(a("sort"),i=>i)];case"sort_by/1":return[an(a("sort_by"),i=>me(t[0],i,n))];case"group_by/1":{const i=an(a("group_by"),d=>me(t[0],d,n)),l=[];let c;for(const d of i){const u=me(t[0],d,n);l.length&&er(u,c)?l[l.length-1].push(d):l.push([d]),c=u}return[l]}case"unique/0":case"unique_by/1":{const i=u=>t[0]?me(t[0],u,n):u,l=an(a(e),i),c=[];let d;for(const u of l){const p=i(u);(!c.length||!er(p,d))&&c.push(u),d=p}return[c]}case"min/0":case"max/0":case"min_by/1":case"max_by/1":{const i=a(e);if(!i.length)return[null];const c=an(i,d=>t[0]?me(t[0],d,n):d);return[e.startsWith("min")?c[0]:c[c.length-1]]}case"reverse/0":return typeof r=="string"?[[...r].reverse().join("")]:[r===null?[]:[...a("reverse")].reverse()];case"first/0":return[ws(r,0)];case"last/0":return[ws(r,-1)];case"first/1":return me(t[0],r,n).slice(0,1);case"last/1":return me(t[0],r,n).slice(-1);case"limit/2":{const i=Be(t[0],r,n);return i<=0?[]:me(t[1],r,n).slice(0,i)}case"nth/1":return[ws(r,Be(t[0],r,n))];case"flatten/0":case"flatten/1":{const i=t[0]?Be(t[0],r,n):1e9,l=(c,d)=>c.flatMap(u=>Array.isArray(u)&&d>0?l(u,d-1):[u]);return[l(a("flatten"),i)]}case"to_entries/0":return Ge(r,"object","to_entries"),[Object.entries(r).map(([i,l])=>({key:i,value:l}))];case"from_entries/0":{const i={};for(const l of a("from_entries")){const c=l.key??l.k??l.name??l.Name??l.Key??l.K;i[typeof c=="string"?c:JSON.stringify(c)]="value"in l?l.value:l.v??l.Value??null}return[i]}case"with_entries/1":{const l=_s("to_entries",[],r,n)[0].flatMap(c=>me(t[0],c,n));return _s("from_entries",[],l,n)}case"tostream/0":case"paths/0":case"getpath/1":case"setpath/2":case"del/1":case"path/1":case"env/0":case"input/0":case"inputs/0":case"now/0":throw new xe(`不支持 ${e}(沙箱只实现了常用的 jq 子集)`);case"isnull/0":return[r===null];case"arrays/0":return Array.isArray(r)?[r]:[];case"objects/0":return qe(r)==="object"?[r]:[];case"strings/0":return typeof r=="string"?[r]:[];case"numbers/0":return typeof r=="number"?[r]:[];case"booleans/0":return typeof r=="boolean"?[r]:[];case"nulls/0":return r===null?[r]:[];case"iterables/0":return Array.isArray(r)||qe(r)==="object"?[r]:[];case"scalars/0":return Array.isArray(r)||qe(r)==="object"?[]:[r];case"indices/1":case"index/1":case"rindex/1":{const i=Be(t[0],r,n);let l=[];if(typeof r=="string"&&typeof i=="string"&&i)for(let c=r.indexOf(i);c>=0;c=r.indexOf(i,c+1))l.push(c);else if(Array.isArray(r))l=r.map((c,d)=>er(c,i)?d:-1).filter(c=>c>=0);else if(r===null)return[null];return e==="indices"?[l]:l.length?[e==="index"?l[0]:l[l.length-1]]:[null]}}throw new xe(`不支持函数 ${e}${t.length?`/${t.length}`:""}(沙箱只实现了常用的 jq 子集)`)}function Wv(e,t){const r=Av(e);return me(r,Dv(t),{}).map(Dv)}const zv=2e3;function bj(){const e=self,t=["fetch","XMLHttpRequest","WebSocket","EventSource","importScripts","indexedDB","caches","BroadcastChannel","MessageChannel","Worker","SharedWorker","navigator","location","Request","Response","WebTransport","RTCPeerConnection","FileReaderSync"],r=e.postMessage.bind(e);for(const n of t)try{for(let s=e;s;s=Object.getPrototypeOf(s))Object.prototype.hasOwnProperty.call(s,n)&&Object.defineProperty(s,n,{value:void 0,configurable:!1,writable:!1})}catch{}e.onmessage=n=>{e.onmessage=null;const{expression:s,input:a}=n.data;try{const l=new Function("$","__src","return eval(__src);")(a,s);let c;try{c=l===void 0?null:JSON.parse(JSON.stringify(l))}catch{c=String(l)}r({ok:!0,value:c})}catch(i){r({ok:!1,error:i instanceof Error?`${i.name}: ${i.message}`:String(i)})}}}function kj(e){const t=window;let r=null,n=null;const s=()=>(n||(n=URL.createObjectURL(new Blob([e],{type:"text/javascript"}))),new Worker(n));t.addEventListener("message",a=>{a.source!==t.parent||!a.data||a.data.type!=="cm-script-sandbox-port"||r||(r=a.ports[0],r.onmessage=i=>{const{id:l,expression:c,input:d,timeoutMs:u}=i.data;let p=!1,f=null;const m=y=>{p||(p=!0,clearTimeout(h),f?.terminate(),r.postMessage({id:l,...y}))},h=setTimeout(()=>m({ok:!1,timedOut:!0}),u);try{f=s()}catch(y){m({ok:!1,notExecuted:!0,error:"页面不允许创建脚本沙箱(可能是 CSP 限制了 blob: Worker),脚本没有执行:"+(y instanceof Error?y.message:String(y))});return}f.onmessage=y=>{const x=y.data||{};x.ok===!0?m({ok:!0,value:x.value}):m({ok:!1,error:typeof x.error=="string"?x.error:"脚本执行失败"})},f.onerror=y=>{y.preventDefault(),m({ok:!1,error:y.message||"脚本沙箱异常"})},f.postMessage({expression:c,input:d})},r.postMessage({type:"ready"}))}),t.parent.postMessage({type:"cm-script-sandbox-loaded"},"*")}const wj="default-src 'none'; script-src 'unsafe-inline' 'unsafe-eval' blob:; worker-src blob:";function Sj(){const e=`(${bj.toString()})();`,t=`(${kj.toString()})(${JSON.stringify(e)});`.replace(/<\/script/gi,"<\\/script");return`<!doctype html><html><head><meta charset="utf-8"><meta http-equiv="Content-Security-Policy" content="${wj}"></head><body><script>${t}<\/script></body></html>`}function qv(e={}){const t=e.timeoutMs??zv,r=Math.max(3e3,t);let n=null,s=null,a=null,i=0;const l=new Map;let c=null;const d=()=>{for(const m of l.values())m({ok:!1,error:"脚本沙箱已关闭"});l.clear(),a&&window.removeEventListener("message",a),a=null,s?.then(m=>{typeof m!="string"&&m.close()}),s=null,n?.remove(),n=null},u=()=>{d(),c=null},p=()=>c?Promise.resolve(c):s||(typeof document>"u"||typeof window>"u"||typeof Worker>"u"||typeof Blob>"u"||typeof MessageChannel>"u"||!document.body?Promise.resolve("当前环境不支持 Web Worker,脚本没有执行"):(s=new Promise(m=>{const h=document.createElement("iframe");h.setAttribute("sandbox","allow-scripts"),h.setAttribute("aria-hidden","true"),h.setAttribute("tabindex","-1"),h.title="脚本沙箱",h.style.cssText="position:absolute;width:0;height:0;border:0;visibility:hidden;";const y=setTimeout(()=>{m("脚本沙箱没有启动(页面的 CSP 可能不允许内嵌 iframe 或 blob: Worker),脚本没有执行")},r);a=x=>{if(x.source!==h.contentWindow||!x.data||x.data.type!=="cm-script-sandbox-loaded")return;const g=new MessageChannel;g.port1.onmessage=v=>{const k=v.data;if(k.type==="ready"){clearTimeout(y),m(g.port1);return}if(typeof k.id!="number")return;const b=l.get(k.id);b&&(l.delete(k.id),k.ok===!0?b({ok:!0,value:k.value}):k.timedOut?b({ok:!1,error:`脚本运行超过 ${t} ms 被终止(可能存在死循环)`}):b({ok:!1,error:String(k.error??"脚本执行失败"),...k.notExecuted?{notExecuted:!0}:{}}))},h.contentWindow.postMessage({type:"cm-script-sandbox-port"},"*",[g.port2])},window.addEventListener("message",a),h.srcdoc=Sj(),document.body.appendChild(h),n=h}),s));return{evaluate:async(m,h)=>{const y=await p();if(typeof y=="string")return d(),c=y,{ok:!1,error:y,notExecuted:!0};let x;try{x=JSON.parse(JSON.stringify(h??{}))}catch{x={}}const g=++i;return new Promise(v=>{const k=setTimeout(()=>{l.has(g)&&(l.delete(g),d(),v({ok:!1,error:`脚本运行超过 ${t} ms 被终止(可能存在死循环)`}))},t+2e3);l.set(g,b=>{clearTimeout(k),v(b)}),y.postMessage({id:g,expression:m,input:x,timeoutMs:t})})},dispose:u}}const _j=()=>({ok:!1,notExecuted:!0,error:"同步接口不执行脚本;请改用 executeLocalSandboxDryRunAsync()"});function jj(e){return!e||typeof e!="object"?null:e.__isMockOverride||"outputData"in e||"forceCase"in e||"durationMs"in e||"status"in e&&(e.status==="COMPLETED"||e.status==="FAILED"||e.status==="TIMED_OUT"||e.status==="COMPLETED_WITH_ERRORS")&&Object.keys(e).every(t=>["__isMockOverride","status","durationMs","forceCase","outputData","reasonForIncompletion"].includes(t))?e:{__isMockOverride:!0,outputData:e}}function Tj(e){const t=[],r=/([^.[\]]+)|\[(\d+)\]|\['([^']*)'\]|\["([^"]*)"\]/g;let n;for(;(n=r.exec(e))!==null;)n[1]!==void 0?t.push(/^\d+$/.test(n[1])?Number(n[1]):n[1]):n[2]!==void 0?t.push(Number(n[2])):t.push(n[3]??n[4]??"");return t}function mu(e,t){if(e==null||!t)return;let r=e;for(const n of Tj(t)){if(r==null)return;r=r[n]}return r}function js(e,t,r){if(typeof e=="string"){const n=e.match(/^\$\{([^}]+)\}$/);if(n){const s=Fv(n[1].trim(),t);return s===void 0&&r?.push(n[1].trim()),s!==void 0?s:e}return e.replace(/\$\{([^}]+)\}/g,(s,a)=>{const i=Fv(a.trim(),t);return i===void 0?(r?.push(a.trim()),s):typeof i=="object"?JSON.stringify(i):String(i)})}if(Array.isArray(e))return e.map(n=>js(n,t,r));if(e&&typeof e=="object"){const n={};for(const[s,a]of Object.entries(e))n[s]=js(a,t,r);return n}return e}function Fv(e,t){if(e==="workflow.input")return t.workflowInput;if(e.startsWith("workflow.input.")||e.startsWith("workflow.input["))return mu(t.workflowInput,e.slice(14).replace(/^\./,""));if(e==="workflow.variables")return t.variables;if(e.startsWith("workflow.variables.")||e.startsWith("workflow.variables["))return mu(t.variables,e.slice(18).replace(/^\./,""));if(e==="workflow.workflowId")return"sandbox-dryrun-wf-001";if(e==="workflow.correlationId")return"corr-sandbox-9921";const r=/^([A-Za-z0-9_\-]+)\.(output|input)(.*)$/.exec(e);if(r){const[,n,s,a]=r,i=s==="output"?t.taskOutputs[n]:t.taskInputs[n];if(!i)return;if(!a)return i;if(a.startsWith(".")||a.startsWith("["))return mu(i,a.replace(/^\./,""))}}function Ts(e,t={},r){switch(e.type){case"HTTP":{const n=t.http_request||e.httpRequest||t;return{response:{statusCode:200,headers:{"content-type":"application/json","x-sandbox":"true"},body:{code:0,status:"SUCCESS",message:`Simulated HTTP ${n?.method||"GET"} response for ${e.name}`,requestEcho:n?.uri||"/api/v1/resource",data:{id:`res_${e.taskReferenceName}_${r||1}`,verified:!0,score:95,items:[{id:1,name:"item-alpha"},{id:2,name:"item-beta"}]}}}}}case"JSON_JQ_TRANSFORM":return{result:{},resultList:[{}]};case"SET_VARIABLE":return{variables:{...Object.keys(t).length?t:e.inputParameters||{}}};case"INLINE":case"LAMBDA":return{result:null};case"EVENT":return{event_produced:`conductor:event:${e.sink||e.name}`,payload:t};case"WAIT":return{waited:!0,duration:t.duration||"1s"};case"TERMINATE":return{terminationStatus:t.terminationStatus||"COMPLETED",terminationReason:t.terminationReason||"Terminated in sandbox dry-run",output:t.workflowOutput||{}};default:return{code:0,status:"OK",result:`Simulated output from ${e.name}`,processedAt:new Date().toISOString(),iteration:r??1,inputEcho:t,data:{id:`${e.taskReferenceName}_out_${r||1}`,approved:!0,amount:t.amount??100}}}}const Ij=e=>e!=null&&e!==!1&&e!==0&&e!=="";function*hu(e,t){return yield{expression:e,input:t}}function Nj(e,t,r){t.seqCounter+=1;const n=t.seqCounter,s=t.currentTimeMs,a=s+8+n%5*4;t.currentTimeMs=a;const i=[],l=js(e.inputParameters||{},t,i),c=r&&r>1?`${e.taskReferenceName}__${r}`:e.taskReferenceName,d=[...new Set(i)].map(u=>`引用 \${${u}} 没有取到值(上游未执行或路径不存在)`);return t.taskInputs[e.taskReferenceName]=l,{seq:n,scheduledTime:s,startTime:a,resolvedInput:l,execRefName:c,warnings:d}}function Rt(e,t,r,n,s){const a={taskId:`sandbox-task-${r.seq}`,taskType:t.type,taskDefName:t.name,referenceTaskName:r.execRefName,scheduledTime:r.scheduledTime,startTime:r.startTime,endTime:e.currentTimeMs,seq:r.seq,pollCount:1,retryCount:0,iteration:s,inputData:r.resolvedInput,workflowTask:t,...n};return r.warnings.length&&(a.sandboxWarnings=[...a.sandboxWarnings??[],...r.warnings]),e.tasks.push(a),a.outputData&&(e.taskOutputs[t.taskReferenceName]=a.outputData),a}const Bv=new Set(["FAILED","FAILED_WITH_TERMINAL_ERROR","TIMED_OUT"]),Cj=new Set(["FAILED","TIMED_OUT"]);function*on(e,t,r){for(const n of e){const s=t.tasks.length,a=yield*Rj(n,t,r);if(a==="FAILED"&&n.optional){const i=t.tasks.slice(s).find(l=>l.workflowTask===n&&Cj.has(l.status));if(i){i.status="COMPLETED_WITH_ERRORS",i.sandboxWarnings=[...i.sandboxWarnings??[],"可选任务(optional)失败,按 Conductor 记为带错完成,流程继续"];continue}}if(a==="FAILED"||a==="TERMINATED")return a}return"COMPLETED"}function*Ej(e,t,r){const n=e.type==="DECISION",s=n?e.caseExpression?"javascript":"value-param":e.evaluatorType||"value-param";if(s==="value-param"){const a=n?e.caseValueParam:e.expression||e.caseValueParam;return a?(a in t||r.push(`入参里没有 "${a}",走默认分支`),{value:t[a]}):(r.push("没有配置判断参数,走默认分支"),{value:void 0})}if(s==="javascript"||s==="graaljs"){const a=n?e.caseExpression:e.expression;if(!a)return r.push("没有配置判断表达式,走默认分支"),{value:void 0};const i=yield*hu(a,t);return i.ok?{value:i.value}:i.notExecuted?(r.push(`条件脚本未执行,走默认分支:${i.error}`),{value:void 0}):{value:void 0,error:`条件脚本执行失败:${i.error}`}}return{value:void 0,error:`沙箱不支持 ${s} 求值器`}}function*Rj(e,t,r){const n=Nj(e,t,r),{resolvedInput:s}=n,a=jj(t.taskMocks[e.taskReferenceName]),i=m=>{t.currentTimeMs+=typeof a?.durationMs=="number"&&a.durationMs>=0?a.durationMs:m};if(e.type==="SWITCH"||e.type==="DECISION"){const m=[];let h,y;if(a?.forceCase)h=a.forceCase,m.push(`按配置台强制走分支 ${h==="__default__"?"默认":h}`);else{const g=yield*Ej(e,s,m);if(g.error)return i(12),Rt(t,e,n,{status:"FAILED",reasonForIncompletion:g.error,outputData:{},sandboxExecution:"executed",sandboxWarnings:m},r),"FAILED";y=g.value;const v=y==null?"":String(y);h=e.decisionCases&&v in e.decisionCases?v:"__default__"}i(12);const x=h==="__default__"?e.defaultCase||[]:e.decisionCases?.[h]||e.defaultCase||[];return Rt(t,e,n,{status:"COMPLETED",inputData:{...s,case:h==="__default__"?"defaultCase":h},outputData:a?.outputData??{evaluationResult:[y===void 0?null:String(y)],selectedCase:h==="__default__"?"defaultCase":h},sandboxExecution:a?.forceCase?"mocked":"executed",sandboxWarnings:m},r),yield*on(x,t,r)}if(e.type==="FORK_JOIN"){i(10);const m=e.forkTasks||[];return Rt(t,e,n,{status:"COMPLETED",outputData:{},sandboxExecution:"executed"},r),yield*Hv(m,t,r)}if(e.type==="FORK_JOIN_DYNAMIC"){i(10);const m=[],h=Oj(e,s,m);return t.lastDynamicSpawn=h.map(y=>y.taskReferenceName),Rt(t,e,n,{status:"COMPLETED",outputData:{},sandboxExecution:"executed",sandboxWarnings:m},r),yield*Hv(h.map(y=>[y]),t,r)}if(e.type==="JOIN"||e.type==="EXCLUSIVE_JOIN"){let m=e.joinOn||[];!m.length&&t.lastDynamicSpawn&&(m=t.lastDynamicSpawn,t.lastDynamicSpawn=null);const h={};for(const y of m)t.taskOutputs[y]&&(h[y]=t.taskOutputs[y]);return i(15),Rt(t,e,n,{status:"COMPLETED",inputData:{joinOn:m},outputData:h,sandboxExecution:"executed"},r),"COMPLETED"}if(e.type==="DO_WHILE")return yield*Pj(e,t,n,r);if(["INLINE","LAMBDA","JSON_JQ_TRANSFORM","SET_VARIABLE","TERMINATE","WAIT","NOOP"].includes(e.type)&&(!a||Aj(a)))return yield*$j(e,t,n,r,a?.durationMs);const c=e.type==="HTTP"?145+n.seq%4*35:e.type==="SIMPLE"?85+n.seq%5*30:28+n.seq%3*12;i(c);let d;a?.outputData?d=structuredClone(a.outputData):(d=Ts(e,s,r),d.processedAt&&(d.processedAt=new Date(t.currentTimeMs).toISOString())),e.type==="SET_VARIABLE"&&Object.assign(t.variables,a?.outputData??s);const u=a?.status||"COMPLETED",p=Bv.has(u),f=e.type==="DYNAMIC"&&e.dynamicTaskNameParam&&typeof s[e.dynamicTaskNameParam]=="string"?s[e.dynamicTaskNameParam]:e.name;return Rt(t,e,n,{status:u,taskDefName:f,workerId:"browser-local-sandbox-worker",outputData:d,reasonForIncompletion:p?a?.reasonForIncompletion||`沙箱人工模拟任务异常 (${u})`:void 0,sandboxExecution:"mocked"},r),p?"FAILED":"COMPLETED"}function*Hv(e,t,r){const n=t.currentTimeMs;let s=n,a="COMPLETED";for(const i of e){t.currentTimeMs=n;const l=yield*on(i,t,r);s=Math.max(s,t.currentTimeMs),l!=="COMPLETED"&&a==="COMPLETED"&&(a=l)}return t.currentTimeMs=s,a}function Oj(e,t,r){const n=e.dynamicForkTasksParam;if(n){const i=t[n];if(!Array.isArray(i))return r.push(`入参 "${n}" 不是任务数组,没有生成并行任务`),[];const l=e.dynamicForkTasksInputParamName,c=l&&t[l]||{};return i.filter(d=>!!d&&typeof d=="object"&&typeof d.taskReferenceName=="string").map(d=>({...d,type:d.type||"SIMPLE",inputParameters:c[d.taskReferenceName]??d.inputParameters??{}}))}const s=t.forkTaskInputs,a=t.forkTaskName??t.forkTaskWorkflow;if(Array.isArray(s)&&a){const i=t.forkTaskType||(t.forkTaskWorkflow?"SUB_WORKFLOW":"SIMPLE");return s.map((l,c)=>({name:String(a),taskReferenceName:`${e.taskReferenceName}_${c}`,type:i,inputParameters:l&&typeof l=="object"?l:{input:l}}))}return r.push("没有找到动态任务列表(dynamicForkTasksParam 或 forkTaskName + forkTaskInputs),没有生成并行任务"),[]}function*Pj(e,t,r,n){const s=e.loopOver||[],a=Math.max(1,t.maxLoopIterations),i=[],l={},c=Rt(t,e,r,{status:"IN_PROGRESS",inputData:{...r.resolvedInput,loopCondition:e.loopCondition},outputData:{iteration:0},sandboxExecution:"executed"},n);c.sandboxWarnings=i;let d="COMPLETED",u="COMPLETED",p=0;for(;;){p+=1;const f=t.tasks.length,m=yield*on(s,t,p),h=new Set(t.tasks.slice(f).map(v=>v.workflowTask?.taskReferenceName).filter(v=>!!v&&v!==e.taskReferenceName)),y=Object.fromEntries([...h].filter(v=>t.taskOutputs[v]).map(v=>[v,t.taskOutputs[v]]));if(l[String(p)]=y,c.outputData={iteration:p,...l},t.taskOutputs[e.taskReferenceName]=c.outputData,m!=="COMPLETED"){d=m==="FAILED"?"FAILED":"COMPLETED",u=m;break}if(!e.loopCondition){i.push("没有配置循环条件,只运行一轮");break}if(!t.canRunScripts){if(p===1&&i.push(`循环条件未执行(同步接口不执行脚本),按上限运行 ${a} 轮`),p>=a)break;continue}const x={...r.resolvedInput,...y,[e.taskReferenceName]:c.outputData},g=yield*hu(e.loopCondition,x);if(!g.ok){if(g.notExecuted){i.push(`循环条件未执行:${g.error}`);break}d="FAILED",u="FAILED",c.reasonForIncompletion=`循环条件执行失败:${g.error}`;break}if(!Ij(g.value))break;if(p>=a){d="COMPLETED_WITH_ERRORS",c.reasonForIncompletion=`达到沙箱循环上限 ${a} 轮时条件仍为真,已停止(真实运行会继续循环)`;break}}return t.currentTimeMs+=10,c.status=d,c.endTime=t.currentTimeMs,c.iteration=p,u}function Aj(e){return!e.outputData&&!e.forceCase&&(!e.status||e.status==="COMPLETED")}function*$j(e,t,r,n,s){const a=r.resolvedInput,i=typeof s=="number"&&s>=0,l=i?[`按配置台把耗时设为 ${s} ms,任务仍真实执行`]:[],c=p=>{t.currentTimeMs+=i?s:p},d=(p,f={error:p},m=6)=>(c(m),Rt(t,e,r,{status:"FAILED",reasonForIncompletion:p,outputData:f,sandboxExecution:"executed",...l.length?{sandboxWarnings:l}:{}},n),"FAILED"),u=(p,f,m={})=>{c(f);const h=[...l,...m.sandboxWarnings??[]];return Rt(t,e,r,{status:"COMPLETED",outputData:p,sandboxExecution:"executed",...m,...h.length?{sandboxWarnings:h}:{}},n),"COMPLETED"};switch(e.type){case"INLINE":case"LAMBDA":{const p=e.type==="LAMBDA",f=p?a.scriptExpression:a.expression,m=p?"javascript":a.evaluatorType||e.evaluatorType||"javascript";if(typeof f!="string"||!f.trim())return d("没有配置脚本(inputParameters.expression)");if(m==="value-param")return u({result:a[f]??null},4);if(m!=="javascript"&&m!=="graaljs")return d(`沙箱不支持 ${m} 求值器`);const h=yield*hu(f,a);return h.ok?u({result:h.value},6):h.notExecuted?(t.currentTimeMs+=1,Rt(t,e,r,{status:"SKIPPED",reasonForIncompletion:h.error,outputData:{},sandboxExecution:"not_executed"},n),"COMPLETED"):d(`脚本执行失败:${h.error}`)}case"JSON_JQ_TRANSFORM":{const p=a.queryExpression;if(typeof p!="string"||!p.trim())return d("没有配置 jq 表达式(inputParameters.queryExpression)");try{const f=Wv(p,a);return u({result:f.length?f[0]:null,resultList:f},5)}catch(f){const m=f instanceof xe?f.message:String(f);return d(`jq 执行失败:${m}`)}}case"SET_VARIABLE":return Object.assign(t.variables,a),u({variables:{...a}},3);case"WAIT":return u({},4,{sandboxWarnings:["沙箱不实际等待,WAIT 立即完成"]});case"NOOP":return u({},1);case"TERMINATE":{const p=String(a.terminationStatus||"COMPLETED").toUpperCase();if(p!=="COMPLETED"&&p!=="FAILED"&&p!=="TERMINATED")return d(`terminationStatus 只能是 COMPLETED、FAILED 或 TERMINATED,当前是 ${a.terminationStatus}`);const f=p,m=a.workflowOutput&&typeof a.workflowOutput=="object"?a.workflowOutput:{},h={terminationStatus:f,terminationReason:a.terminationReason||"",output:m};return t.termination={status:f,reason:a.terminationReason||"",output:m},u(h,4),"TERMINATED"}}return d(`沙箱无法执行 ${e.type}`)}function Dj(e){switch(e.type){case"number":return 1;case"boolean":return!0;case"object":return{};case"array":return[];default:return`sample_${e.name}`}}function ln(e){const t={};for(const r of St(e.inputParameters,e)){if(!r.name||r.name in t)continue;const n=r.example??r.defaultValue;t[r.name]=n!==void 0&&n!==""?structuredClone(n):Dj(r)}try{const r=JSON.stringify(e.tasks||[]),n=/\$\{\s*workflow\.input\.([a-zA-Z0-9_]+)/g;let s;for(;(s=n.exec(r))!==null;){const a=s[1];a&&!(a in t)&&(t[a]=`mock_${a}`)}}catch{}return t}function Jv(e,t,r){const n=Date.now()-2e3;return{ctx:{workflowInput:{...structuredClone(e.inputTemplate??{}),...t.workflowInput||ln(e)},variables:structuredClone(e.variables??{}),taskOutputs:{},taskInputs:{},taskMocks:t.taskMocks||{},tasks:[],currentTimeMs:n,maxLoopIterations:t.maxLoopIterations??(r?20:2),canRunScripts:r,seqCounter:0,lastDynamicSpawn:null,termination:null},baseStartTime:n}}function Uv(e,t,r,n){const s={};if(t.termination)Object.assign(s,t.termination.output);else if(e.outputParameters&&Object.keys(e.outputParameters).length>0)Object.assign(s,js(e.outputParameters,t));else{const c=t.tasks[t.tasks.length-1];c?.outputData&&Object.assign(s,c.outputData)}const a=t.tasks.find(c=>Bv.has(c.status)),i=t.termination?t.termination.status:n==="FAILED"?"FAILED":"COMPLETED",l=t.termination?t.termination.status==="COMPLETED"?void 0:t.termination.reason||`TERMINATE 以 ${t.termination.status} 结束流程`:n==="FAILED"?a?.reasonForIncompletion:void 0;return{workflowId:`sandbox-dryrun-${Date.now().toString(36)}`,workflowName:e.name||"sandbox_workflow",workflowVersion:e.version||1,status:i,startTime:r,endTime:t.currentTimeMs,createTime:r,updateTime:t.currentTimeMs,input:t.workflowInput,output:s,variables:t.variables,tasks:t.tasks,reasonForIncompletion:l,workflowDefinition:structuredClone(e),isSandbox:!0}}async function cn(e,t={}){const{ctx:r,baseStartTime:n}=Jv(e,t,!0),s=t.scriptEvaluator?null:qv({timeoutMs:t.scriptTimeoutMs??zv}),a=t.scriptEvaluator??s.evaluate;try{const i=on(e.tasks||[],r);let l=i.next();for(;!l.done;){const c=await a(l.value.expression,l.value.input);l=i.next(c)}return Uv(e,r,n,l.value)}finally{s?.dispose()}}function Lj(e,t={}){const{ctx:r,baseStartTime:n}=Jv(e,t,!1),s=on(e.tasks||[],r);let a=s.next();for(;!a.done;)a=s.next(_j(a.value.expression));return Uv(e,r,n,a.value)}const yu=new Set,gu=new Set;function Vv(e,t){let r;if(e.forEach(n=>{r=n}),!!r)try{r(t)}catch(n){console.warn("[reactflow-ui] 埋点观察者出错,已忽略:",n)}}function Mj(e){return yu.add(e),()=>{yu.delete(e)}}function Kv(e){Vv(yu,e)}function Wj(e){return gu.add(e),()=>{gu.delete(e)}}function zj(e){Vv(gu,e)}const qj=/^(.+)__(\d+)$/;function Gv(e,t){if(t[e])return{baseRef:e};const r=e.match(qj);return r&&t[r[1]]?{baseRef:r[1],iteration:parseInt(r[2],10)}:{baseRef:e}}function Yv(e,t){return(e.iteration??0)-(t.iteration??0)||(e.retryCount??0)-(t.retryCount??0)||(e.seq??0)-(t.seq??0)||(e.startTime??0)-(t.startTime??0)}function xu(e){if(!e||e.length===0)return 0;const t=new Map;for(const n of e){const s=n.iteration??0,a=t.get(s);a?a.push(n):t.set(s,[n])}let r=0;for(const n of t.values()){const s=n.reduce((a,i)=>Math.max(a,i.retryCount??0),0);r+=Math.max(s,n.length-1)}return r}function Xv(e){return e?new Set(e.map(r=>r.iteration).filter(r=>typeof r=="number"&&r>0)).size:0}function Fj(e,t){const r=e.filter(n=>n.iteration===t);if(r.length!==0)return[...r].sort(Yv)[r.length-1]}function Bj(e,t){const r=(n,s)=>{if(Array.isArray(n))for(const a of n){if(!a)continue;if(a.taskReferenceName===t)return s;const i=[];a.decisionCases&&Object.values(a.decisionCases).forEach(l=>i.push([l,s])),a.defaultCase&&i.push([a.defaultCase,s]),Array.isArray(a.forkTasks)&&a.forkTasks.forEach(l=>i.push([l,s])),Array.isArray(a.loopOver)&&i.push([a.loopOver,a.taskReferenceName??s]);for(const[l,c]of i){const d=r(l,c);if(d!==void 0)return d}}};return r(e,null)??null}function Hj(e,t,r){if(!t)return e;const n=r[t];if(!n)return e;const s=Fj(e.attempts,n);return s?{...e,status:s.status,startTime:s.startTime,endTime:s.endTime,input:s.inputData,output:s.outputData,reasonForIncompletion:s.reasonForIncompletion,iteration:s.iteration??n}:e}function Jj(e,t,r){const n={};for(const{forkRef:s,joinRef:a}of t){let i=null;e.forEach((l,c)=>{const d=l?.referenceTaskName;if(!d)return;let u;if(d===s)u="";else if(d.startsWith(`${s}__`)&&/^\d+$/.test(d.slice(s.length+2)))u=d.slice(s.length);else return;const p=`${a}${u}`;let f=-1;for(let x=c+1;x<e.length;x++)if(e[x]?.referenceTaskName===p){f=x;break}if(f<0)return;const m=new Set,h=e.slice(c+1,f).filter(x=>{const g=x?.referenceTaskName;return!g||!x.taskId||r[g]||r[Gv(g,r).baseRef]||m.has(g)?!1:(m.add(g),!0)}),y=u?parseInt(u.slice(2),10):l.iteration??0;u&&(n[`${s}${u}`]=h),(!i||y>=i.iter)&&(i={iter:y,children:h})}),i&&(n[s]=i.children)}return n}function Uj(e,t){const r={};for(const n of e){const s=n?.referenceTaskName;if(!s)continue;const{baseRef:a,iteration:i}=Gv(s,t),l=i!==void 0&&n.iteration===void 0?{...n,iteration:i}:n;r[a]||(r[a]={taskReferenceName:a,status:l.status,attempts:[]}),r[a].attempts.push(l)}for(const n of Object.values(r)){n.attempts.sort(Yv),n.attempts.some(l=>l.iteration!==void 0&&l.iteration>0)&&(n.totalIterations=n.attempts.reduce((l,c)=>Math.max(l,c.iteration??0),0));const a=n.attempts[0],i=n.attempts[n.attempts.length-1];n.startTime=a?.startTime,n.status=i.status,n.endTime=i.endTime,n.output=i.outputData,n.input=i.inputData,n.reasonForIncompletion=i.reasonForIncompletion,n.iteration=i.iteration}return r}function dn(e,t=[]){return Array.isArray(e)&&e.forEach((r,n)=>{if(r){if(r.type==="FORK_JOIN_DYNAMIC"){for(let s=n+1;s<e.length;s++)if(e[s]?.type==="JOIN"||e[s]?.type==="EXCLUSIVE_JOIN"){t.push({forkRef:r.taskReferenceName,joinRef:e[s].taskReferenceName});break}}r.decisionCases&&Object.values(r.decisionCases).forEach(s=>dn(s,t)),r.defaultCase&&dn(r.defaultCase,t),Array.isArray(r.forkTasks)&&r.forkTasks.forEach(s=>dn(s,t)),Array.isArray(r.loopOver)&&dn(r.loopOver,t)}}),t}let Zv=null,vu=[];function Vj(e){return e===Zv||(Zv=e,vu=e.map(t=>Object.assign({},t,{selected:!1}))),vu}const Kj=100,Gj=1500;let vr=null;function un(){const e=te.temporal;return e?e.getState():null}function Yj(e,t){const r=un();if(!r){t();return}const n=Date.now(),s=r.pastStates[r.pastStates.length-1];if(!!e&&!!vr&&vr.key===e&&n-vr.at<Gj&&vr.anchor===s&&s!==void 0&&r.isTracking){r.pause();try{t()}finally{un()?.resume()}vr.at=n;return}if(t(),e){const i=un();vr={key:e,at:n,anchor:i?.pastStates[i.pastStates.length-1]}}else vr=null}function Xj(e,t,r,n){if(n||!t)return null;const s=[];return Object.keys(r).sort().forEach(a=>{const i=r[a],l=t[a];if(i&&l&&typeof i=="object"&&typeof l=="object"&&!Array.isArray(i)){const c=Array.from(new Set([...Object.keys(i),...Object.keys(l)])).filter(d=>JSON.stringify(i[d])!==JSON.stringify(l[d])).sort();s.push(`${a}.${c.join("+")}`)}else s.push(a)}),`${e}:${s.join(",")}`}function tr(e,t){const{nodes:r,edges:n,taskMap:s}=ht(e,t.layoutDirection,{hideEmptyBranches:t.mode!=="edit"}),a=pt(r,n,{direction:t.layoutDirection,mode:t.mode});return{workflowDef:e,nodes:a.nodes,edges:a.edges,taskMap:s,validationResults:Et(e)}}function Qv(e){const t=un();if(!t||!t.isTracking){e();return}t.pause();try{e()}finally{un()?.resume()}}function eb(e,t,r){const n=JSON.parse(JSON.stringify(e));Ar(n.tasks),at(n.tasks);const{nodes:s,edges:a,taskMap:i}=ht(n,t,{hideEmptyBranches:r.mode!=="edit"}),l=pt(s,a,{direction:t,mode:r.mode});return{workflowDef:n,nodes:l.nodes,edges:l.edges,taskMap:i,validationResults:Et(n),layoutDirection:t,workflowLoadKey:r.workflowLoadKey+1,graphStale:!1}}function Is(e,t){const r=e.selectedTask?.taskReferenceName;return r&&!t[r]?{selectedTask:null,isDetailPanelOpen:!1}:{}}function Zj(e,t){return!e||typeof e!="object"||(t<1&&e.edgeType==="default"&&(e.edgeType="smoothstep"),t<2&&delete e.copiedTask),e}function tb(e){const t=te.getState(),r=t.editWorkflowDefStash;if(!r){t.runWorkflowDef&&te.setState({runWorkflowDef:null});return}Qv(()=>{const n=tr(r,{layoutDirection:t.layoutDirection,mode:e});te.setState({...n,...Is(t,n.taskMap),graphStale:!1,runWorkflowDef:null,editWorkflowDefStash:null,workflowLoadKey:t.workflowLoadKey+1})})}try{globalThis.localStorage?.removeItem("conductor-clipboard")}catch{}const te=Gn()(Qp(C0((e,t)=>({mode:"view",workflowDef:null,workflowInstance:null,runWorkflowDef:null,editWorkflowDefStash:null,savedWorkflowJson:null,nodes:[],edges:[],taskMap:{},layoutDirection:"TB",selectedTask:null,selectedTaskInstance:null,isDetailPanelOpen:!1,executionData:null,dynamicRuntimeTasksByFork:{},validationResults:{isValid:!0,errors:[],warnings:[]},theme:"dark",themeColor:"blue",edgeType:"smoothstep",nodesLocked:!0,copiedTask:null,viewMode:"business",simState:{},isSimRunning:!1,workflowLoadKey:0,graphStale:!1,runState:"idle",pendingExecutionId:null,executionError:null,showRunPanel:!1,showAnalysisPanel:!1,focusedParamKey:null,showDataLineage:!1,lastRefactorNotice:null,sandboxRunning:!1,sandboxNotice:null,showWaterfallPanel:!1,timeTravelTimestamp:null,activeLoopIterations:{},inlineCopilotTaskRef:null,setWorkflow:(r,n)=>{e({...eb(r,n||t().layoutDirection,t()),runWorkflowDef:null,editWorkflowDefStash:null})},setWorkflowDefOnly:r=>{const n=JSON.parse(JSON.stringify(r));Ar(n.tasks),at(n.tasks),e({workflowDef:n,validationResults:Et(n),graphStale:!0})},refreshGraph:()=>{const{graphStale:r,workflowDef:n,layoutDirection:s,mode:a}=t();if(!r||!n)return;const{nodes:i,edges:l,taskMap:c}=ht(n,s,{hideEmptyBranches:a!=="edit"}),{nodes:d,edges:u}=pt(i,l,{direction:s,mode:a});e({nodes:d,edges:u,taskMap:c,graphStale:!1})},setMode:r=>{t().mode==="run"&&r!=="run"&&(e({executionData:null,workflowInstance:null,dynamicRuntimeTasksByFork:{},timeTravelTimestamp:null,showWaterfallPanel:!1,activeLoopIterations:{}}),tb(r)),e({mode:r});const{workflowDef:s,layoutDirection:a}=t();if(s){const{nodes:i,edges:l,taskMap:c}=ht(s,a,{hideEmptyBranches:r!=="edit"}),{nodes:d,edges:u}=pt(i,l,{direction:a,mode:r});e({nodes:d,edges:u,taskMap:c,graphStale:!1})}},setExecutionData:r=>e({executionData:r,dynamicRuntimeTasksByFork:r===null?{}:t().dynamicRuntimeTasksByFork}),updateTaskStatus:(r,n)=>{const{executionData:s}=t();if(!s)return;const a={...s};a[r]&&(a[r]={...a[r],status:n},e({executionData:a}))},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=[],s=null,a=t().workflowDef;if(Array.isArray(r.tasks)?(n=r.tasks,r.workflowId&&r.status&&(s=r,r.workflowDefinition&&(a=r.workflowDefinition))):Array.isArray(r)&&(n=r),n.length===0)return;const i=t().workflowDef;if(a&&JSON.stringify(a)!==JSON.stringify(i)){const p=t().editWorkflowDefStash??i;Qv(()=>{const f=eb(a,t().layoutDirection,t());e({...f,runWorkflowDef:f.workflowDef,editWorkflowDefStash:p})})}const l=t().taskMap,c=Uj(n,l),d=dn(t().workflowDef?.tasks||[]),u=Jj(n,d,l);e({executionData:c,dynamicRuntimeTasksByFork:u,workflowInstance:s,timeTravelTimestamp:null,activeLoopIterations:{}}),t().mode!=="run"&&t().setMode("run")},setSelectedTask:r=>e(n=>({selectedTask:r?{...r}:null,selectedTaskInstance:r&&n.selectedTask?.taskReferenceName===r.taskReferenceName?n.selectedTaskInstance: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:s,edges:a,taskMap:i}=ht(n,r,{hideEmptyBranches:t().mode!=="edit"}),{nodes:l,edges:c}=pt(s,a,{direction:r,mode:t().mode});e({nodes:l,edges:c,taskMap:i,layoutDirection:r})}else e({layoutDirection:r})},onNodesChange:r=>{const n=t().nodes,s=new Set(n.map(i=>i.id)),a=r.filter(i=>"id"in i&&s.has(i.id));a.length!==0&&e({nodes:J.applyNodeChanges(a,n)})},onEdgesChange:r=>{const n=t().edges,s=J.applyEdgeChanges(r,n);s!==n&&e({edges:s})},onConnect:r=>{},checkTaskRefUniqueness:(r,n)=>r===n?!0:!st(t().workflowDef?.tasks).has(r),updateTask:(r,n,s)=>{const{workflowDef:a,layoutDirection:i}=t();if(!a)return;let l=JSON.parse(JSON.stringify(a)),c=t().lastRefactorNotice;const d=typeof n=="object"?n:{[n]:s},u=Object.keys(d),p=d.taskReferenceName;let f=r;if(typeof p=="string"&&p.trim()!==r){const b=p.trim(),S=vs(l,b,r);if(S){console.warn(`[workflowStore] ${S}`);return}const j=xs(l,r,b);l=j.updatedDef,f=b,j.replacedCount>0&&(c={oldRef:r,newRef:b,replacedCount:j.replacedCount,affectedTasks:j.affectedTaskRefs,timestamp:Date.now()})}const m=JSON.parse(JSON.stringify(l.tasks)),h=Qe(a.tasks,r),y=Qe(l.tasks,f);if(!y)return;Object.assign(y,d,{taskReferenceName:f}),at(l.tasks,m);const x=Et(l),g=new Set(["taskReferenceName","type","decisionCases","defaultCase","forkTasks","loopOver","joinOn"]),v=u.some(b=>g.has(b)&&(b!=="taskReferenceName"||f!==r)),k=Xj(r,h,d,v);Yj(k,()=>{if(v){const{nodes:b,edges:S,taskMap:j}=ht(l,i,{hideEmptyBranches:t().mode!=="edit"}),{nodes:_,edges:w}=pt(b,S,{direction:i,mode:t().mode}),I=t().selectedTask?.taskReferenceName===r?y:t().selectedTask;e({workflowDef:l,nodes:_,edges:w,taskMap:j,selectedTask:I,validationResults:x,lastRefactorNotice:c})}else{const b=t().nodes.map(_=>_.data?.taskReferenceName===r?{..._,data:{..._.data,label:y.name||_.data.label,task:y,loopCondition:y.loopCondition??_.data.loopCondition,subWorkflowName:y.subWorkflowParam?.name??_.data.subWorkflowName}}:_),S={...t().taskMap,[r]:y},j=t().selectedTask?.taskReferenceName===r?y:t().selectedTask;e({workflowDef:l,nodes:b,taskMap:S,selectedTask:j,validationResults:x})}})},replaceTask:(r,n)=>{const{workflowDef:s}=t();if(!s)return"当前没有打开的工作流:请先加载或新建一个工作流";if(!n||typeof n!="object"||Array.isArray(n))return"任务 JSON 必须是一个对象:请检查最外层是否为 { ... }";let a=JSON.parse(JSON.stringify(s));const i=typeof n.taskReferenceName=="string"?n.taskReferenceName.trim():"";if(i!==r){const m=vs(a,i,r);if(m)return m;a=xs(a,r,i).updatedDef}const l=JSON.parse(JSON.stringify(a.tasks)),c=zt(a.tasks,i),d=c?c.findIndex(m=>m.taskReferenceName===i):-1;if(!c||d<0)return`没有找到任务 "${r}":它可能已被删除,请刷新后重试`;const u={...JSON.parse(JSON.stringify(n)),taskReferenceName:i};c[d]=u,at(a.tasks,l);const p=tr(a,t()),f=t().selectedTask;return e({...p,selectedTask:f?.taskReferenceName===r?u:f}),null},updateWorkflowProperties:r=>{const{workflowDef:n,layoutDirection:s}=t();if(!n)return;const a=JSON.parse(JSON.stringify(n));Object.assign(a,r),at(a.tasks,n.tasks);const i=Et(a);if("tasks"in r){const{nodes:l,edges:c,taskMap:d}=ht(a,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:u,edges:p}=pt(l,c,{direction:s,mode:t().mode});e({workflowDef:a,nodes:u,edges:p,taskMap:d,validationResults:i})}else e({workflowDef:a,validationResults:i})},addNode:(r,n,s,a,i={})=>{const{workflowDef:l}=t();if(!l)return;const c=JSON.parse(JSON.stringify(l));let d=n,u=i||{};u.exitOf?(d=u.exitOf,u={}):u.branchParentRef!==void 0&&u.forkIndex!==void 0&&(d=u.branchParentRef,u={forkIndex:u.forkIndex});const p=st(c.tasks);let f=r.data.taskReferenceName;if(p.has(f)){let v=2;for(;p.has(`${f}_${v}`);)v++;f=`${f}_${v}`}const m=Ev(r.data.taskType||"SIMPLE",r.data.label,f),y=m.type==="FORK_JOIN"||m.type==="FORK_JOIN_DYNAMIC"?cu(m,new Set([...p,f])):null,x=u.branchCase!==void 0||u.forkIndex!==void 0||u.isLoopAdd;if(!x&&!u.isWorkflowStart&&!u.isLoopBodyStart){const v=Qe(c.tasks,d);v&&(v.type==="FORK_JOIN"||v.type==="FORK_JOIN_DYNAMIC")&&(d=jv(c.tasks,d)??d)}let g=!1;if(u.isWorkflowStart)c.tasks.unshift(m),g=!0;else if(u.isLoopBodyStart){const v=Qe(c.tasks,d);v&&(v.loopOver||(v.loopOver=[]),v.loopOver.unshift(m),g=!0)}else x?g=rn(c.tasks,d,u,m):c.tasks.length===0?(c.tasks.push(m),g=!0):g=Qt(c.tasks,d,m);if(!g){console.warn(`[workflowStore] 未找到插入位置 "${d}",没有添加任务`);return}y&&Qt(c.tasks,m.taskReferenceName,y),at(c.tasks,l.tasks),e(tr(c,t())),zj("builtin")},removeNode:r=>{const{workflowDef:n}=t();if(!n)return;const s=JSON.parse(JSON.stringify(n)),a=zt(s.tasks,r);if(a){const l=a.find(c=>c.taskReferenceName===r)?.type;if(l==="FORK_JOIN"||l==="FORK_JOIN_DYNAMIC"){const c=hs(a,r);c&&Ct(s.tasks,c)}else if(l==="JOIN"||l==="EXCLUSIVE_JOIN"){const c=au(a,r);c&&Ct(s.tasks,c)}}if(!Ct(s.tasks,r))return;at(s.tasks,n.tasks);const i=tr(s,t());e({...i,...Is(t(),i.taskMap)})},addLoopTask:(r,n)=>{const{workflowDef:s,layoutDirection:a}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=Qe(i.tasks,r);if(l&&l.type==="DO_WHILE"){l.loopOver||(l.loopOver=[]);const c=Ev(n,`new_${n.toLowerCase()}`,`${r}_sub_${Date.now()}`);l.loopOver.push(c),(c.type==="FORK_JOIN"||c.type==="FORK_JOIN_DYNAMIC")&&l.loopOver.push(cu(c,st(i.tasks))),at(i.tasks,s.tasks);const{nodes:d,edges:u,taskMap:p}=ht(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:f,edges:m}=pt(d,u,{direction:a,mode:t().mode}),h=Et(i);e({workflowDef:i,nodes:f,edges:m,taskMap:p,validationResults:h})}},removeLoopTask:(r,n)=>{const{workflowDef:s}=t();if(!s)return;const a=JSON.parse(JSON.stringify(s)),i=Qe(a.tasks,r);if(i&&i.type==="DO_WHILE"&&i.loopOver){const l=zt(i.loopOver,n);if(l){const d=l.find(u=>u.taskReferenceName===n);if(d?.type==="FORK_JOIN"||d?.type==="FORK_JOIN_DYNAMIC"){const u=hs(l,n);u&&Ct(i.loopOver,u)}else if(d?.type==="JOIN"||d?.type==="EXCLUSIVE_JOIN"){const u=au(l,n);u&&Ct(i.loopOver,u)}}Ct(i.loopOver,n),at(a.tasks,s.tasks);const c=tr(a,t());e({...c,...Is(t(),c.taskMap)})}},addDecisionBranch:(r,n)=>{const{workflowDef:s,layoutDirection:a}=t();if(!s)return;const i=JSON.parse(JSON.stringify(s)),l=Qe(i.tasks,r);if(l&&(l.type==="DECISION"||l.type==="SWITCH")){if(n==="default")l.defaultCase||(l.defaultCase=[]);else{const h=bs(l,n);if(h){console.warn(`[workflowStore] ${h}`);return}l.decisionCases||(l.decisionCases={}),l.decisionCases[n.trim()]=[]}at(i.tasks,s.tasks);const{nodes:c,edges:d,taskMap:u}=ht(i,a,{hideEmptyBranches:t().mode!=="edit"}),{nodes:p,edges:f}=pt(c,d,{direction:a,mode:t().mode}),m=Et(i);e({workflowDef:i,nodes:p,edges:f,taskMap:u,validationResults:m})}},removeDecisionBranch:(r,n)=>{const{workflowDef:s}=t();if(!s)return;const a=JSON.parse(JSON.stringify(s)),i=Qe(a.tasks,r);if(i&&(i.type==="DECISION"||i.type==="SWITCH")){n==="default"?i.defaultCase=[]:i.decisionCases&&delete i.decisionCases[n],at(a.tasks,s.tasks);const l=tr(a,t());e({...l,...Is(t(),l.taskMap)})}},renameDecisionBranch:(r,n,s)=>{const{workflowDef:a}=t();if(!a)return!1;const i=JSON.parse(JSON.stringify(a)),l=Qe(i.tasks,r);if(!l||l.type!=="DECISION"&&l.type!=="SWITCH"||!l.decisionCases||!l.decisionCases[n])return!1;const c=(s??"").trim();if(c===n)return!0;const d=bs(l,c,n);if(d)return console.warn(`[workflowStore] ${d}`),!1;const u={};return Object.entries(l.decisionCases).forEach(([p,f])=>{u[p===n?c:p]=f}),l.decisionCases=u,at(i.tasks,a.tasks),e(tr(i,t())),!0},addForkBranch:r=>{const{workflowDef:n,layoutDirection:s}=t();if(!n)return;const a=JSON.parse(JSON.stringify(n)),i=Qe(a.tasks,r);if(i&&i.type==="FORK_JOIN"){i.forkTasks||(i.forkTasks=[]),i.forkTasks.push([]),at(a.tasks,n.tasks);const{nodes:l,edges:c,taskMap:d}=ht(a,s,{hideEmptyBranches:t().mode!=="edit"}),{nodes:u,edges:p}=pt(l,c,{direction:s,mode:t().mode}),f=Et(a);e({workflowDef:a,nodes:u,edges:p,taskMap:d,validationResults:f})}},copyTask:r=>e({copiedTask:r}),pasteTask:r=>{const{workflowDef:n,selectedTask:s}=t();if(!n||!r)return;const a=JSON.parse(JSON.stringify(n)),i=st(a.tasks),{task:l,join:c}=cj(r,i,`_copy_${Date.now()}`);let d=s&&i.has(s.taskReferenceName)?s.taskReferenceName:a.tasks.length>0?a.tasks[a.tasks.length-1].taskReferenceName:"start";const u=Qe(a.tasks,d);u&&(u.type==="FORK_JOIN"||u.type==="FORK_JOIN_DYNAMIC")&&(d=jv(a.tasks,d)??d),a.tasks.length===0?a.tasks.push(l):Qt(a.tasks,d,l)||a.tasks.push(l),c&&Qt(a.tasks,l.taskReferenceName,c),at(a.tasks,n.tasks),e(tr(a,t()))},flashNodes:r=>{if(r.length===0)return;const n=t().__flashTimeout;n&&clearTimeout(n);const s=new Set(r),a={};t().nodes.forEach(l=>{s.has(l.id)&&(a[l.id]=l.selected??!1)}),e(l=>({nodes:l.nodes.map(c=>s.has(c.id)?{...c,selected:!0}:c)}));const i=setTimeout(()=>{e(l=>({nodes:l.nodes.map(c=>s.has(c.id)?{...c,selected:a[c.id]??!1}:c)}))},2500);t().__flashTimeout=i},setTheme:r=>e({theme:r}),setThemeColor:r=>e({themeColor:r}),setEdgeType:r=>e({edgeType:r}),setNodesLocked:r=>e({nodesLocked:r}),setViewMode:r=>e({viewMode:r}),startSimulation:()=>{const{edges:r,nodes:n,isSimRunning:s}=t();if(s)return;const a=n.filter(p=>!["plusNode","dynamicPlaceholderNode"].includes(p.type??"")).map(p=>p.id),i=r.map(p=>({source:p.source,target:p.target})),l=hj(a,i);e({isSimRunning:!0,simState:{}});const c={timer:null};t().__simHandle=c;let d=0;const u=()=>{if(d>=l.length||!t().isSimRunning){e({isSimRunning:!1,simState:{}});return}const p=l[d];e(f=>{const m={...f.simState};return p.forEach(h=>m[h]="running"),{simState:m}}),c.timer=setTimeout(()=>{t().isSimRunning&&(e(f=>{const m={...f.simState};return p.forEach(h=>m[h]="done"),{simState:m}}),d++,c.timer=setTimeout(u,280))},700)};u()},stopSimulation:()=>{const r=t().__simHandle;r?.timer&&clearTimeout(r.timer),e({isSimRunning:!1,simState:{}})},createBlankWorkflow:r=>{const n={name:r||"new_workflow",description:"",tasks:[],version:1,schemaVersion:2};t().setWorkflow(n),e({mode:"edit",savedWorkflowJson:null})},applyAIGeneratedWorkflow:r=>{const{tasks:n,...s}=r,a={...s,name:r.name||"AI_Generated_Workflow",tasks:n||[],version:r.version||1,schemaVersion:2};t().setWorkflow(a)},setShowRunPanel:r=>e({showRunPanel:r}),setShowAnalysisPanel:r=>e({showAnalysisPanel:r}),setRunState:(r,n,s)=>{e({runState:r,pendingExecutionId:n!==void 0?n:t().pendingExecutionId,executionError:s!==void 0?s:t().executionError})},switchToEditAndFocusParam:(r,n)=>{t().mode==="run"&&tb("edit");const{workflowDef:s,layoutDirection:a,taskMap:i}=t();if(!s)return;e({mode:"edit",focusedParamKey:n??null});const{nodes:l,edges:c,taskMap:d}=ht(s,a,{hideEmptyBranches:!1}),{nodes:u,edges:p}=pt(l,c,{direction:a,mode:"edit"});e({nodes:u,edges:p,taskMap:d});const f=i[r]||d[r];f&&e({selectedTask:{...f},isDetailPanelOpen:!0,showAnalysisPanel:!1})},getEditingWorkflowDef:()=>t().editWorkflowDefStash??t().workflowDef,markWorkflowSaved:r=>{const n=r===void 0?t().editWorkflowDefStash??t().workflowDef:r;e({savedWorkflowJson:n?JSON.stringify(n):null})},hasUnsavedChanges:()=>{const{savedWorkflowJson:r}=t(),n=t().editWorkflowDefStash??t().workflowDef;return n?r===null||r!==JSON.stringify(n):!1},setShowDataLineage:r=>e({showDataLineage:r}),clearRefactorNotice:()=>e({lastRefactorNotice:null}),setShowWaterfallPanel:r=>e({showWaterfallPanel:r}),setTimeTravelTimestamp:r=>e({timeTravelTimestamp:r}),setLoopIteration:(r,n)=>e({activeLoopIterations:{...t().activeLoopIterations,[r]:n}}),clearSandboxNotice:()=>e({sandboxNotice:null}),runLocalSandboxDryRun:async(r,n,s)=>{const{workflowDef:a,sandboxRunning:i}=t();if(!a||i)return;if(!a.tasks?.length){e({sandboxNotice:{text:"流程里还没有步骤,先添加步骤再试运行",type:"error",timestamp:Date.now()}});return}e({sandboxRunning:!0,sandboxNotice:null});let l;try{l=await cn(a,{workflowInput:r,taskMocks:n,maxLoopIterations:s})}catch(c){const d=c instanceof Error?c.message:String(c);e({sandboxRunning:!1,sandboxNotice:{text:`沙箱试运行出错:${d}。检查流程定义和模拟数据后再试`,type:"error",timestamp:Date.now()}}),Kv("error");return}e({sandboxRunning:!1}),t().importExecutionJSON(l),e({showWaterfallPanel:!0}),Kv(String(l.status))},setInlineCopilotTaskRef:r=>e({inlineCopilotTaskRef:r})}),{partialize:e=>({workflowDef:e.workflowDef,nodes:Vj(e.nodes),edges:e.edges,taskMap:e.taskMap,graphStale:e.graphStale}),equality:(e,t)=>e.workflowDef===t.workflowDef?!0:JSON.stringify(e.workflowDef)===JSON.stringify(t.workflowDef),limit:Kj}),{name:"conductor-ui-prefs",version:2,storage:xa(()=>localStorage),migrate:Zj,partialize:e=>({theme:e.theme,themeColor:e.themeColor,layoutDirection:e.layoutDirection,edgeType:e.edgeType,nodesLocked:e.nodesLocked,viewMode:e.viewMode})}));let rb=null;te.subscribe(e=>{if(e.taskMap===rb||(rb=e.taskMap,e.mode!=="edit"||e.graphStale||!e.selectedTask))return;const t=e.taskMap[e.selectedTask.taskReferenceName];t?t!==e.selectedTask&&JSON.stringify(t)!==JSON.stringify(e.selectedTask)&&te.setState({selectedTask:{...t}}):te.setState({selectedTask:null,isDetailPanelOpen:!1})});const nb=e=>Symbol.iterator in e,sb=e=>"entries"in e,ab=(e,t)=>{const r=e instanceof Map?e:new Map(e.entries()),n=t instanceof Map?t:new Map(t.entries());if(r.size!==n.size)return!1;for(const[s,a]of r)if(!n.has(s)||!Object.is(a,n.get(s)))return!1;return!0},Qj=(e,t)=>{const r=e[Symbol.iterator](),n=t[Symbol.iterator]();let s=r.next(),a=n.next();for(;!s.done&&!a.done;){if(!Object.is(s.value,a.value))return!1;s=r.next(),a=n.next()}return!!s.done&&!!a.done};function eT(e,t){return Object.is(e,t)?!0:typeof e!="object"||e===null||typeof t!="object"||t===null||Object.getPrototypeOf(e)!==Object.getPrototypeOf(t)?!1:nb(e)&&nb(t)?sb(e)&&sb(t)?ab(e,t):Qj(e,t):ab({entries:()=>Object.entries(e)},{entries:()=>Object.entries(t)})}function Ae(e){const t=T.useRef(void 0);return r=>{const n=e(r);return eT(t.current,n)?t.current:t.current=n}}const tT=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),rT=e=>e.replace(/^([A-Z])|[\s-_]+(\w)/g,(t,r,n)=>n?n.toUpperCase():r.toLowerCase()),ob=e=>{const t=rT(e);return t.charAt(0).toUpperCase()+t.slice(1)},ib=(...e)=>e.filter((t,r,n)=>!!t&&t.trim()!==""&&n.indexOf(t)===r).join(" ").trim(),nT=e=>{for(const t in e)if(t.startsWith("aria-")||t==="role"||t==="title")return!0};var sT={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 aT=T.forwardRef(({color:e="currentColor",size:t=24,strokeWidth:r=2,absoluteStrokeWidth:n,className:s="",children:a,iconNode:i,...l},c)=>T.createElement("svg",{ref:c,...sT,width:t,height:t,stroke:e,strokeWidth:n?Number(r)*24/Number(t):r,className:ib("lucide",s),...!a&&!nT(l)&&{"aria-hidden":"true"},...l},[...i.map(([d,u])=>T.createElement(d,u)),...Array.isArray(a)?a:[a]]));const Y=(e,t)=>{const r=T.forwardRef(({className:n,...s},a)=>T.createElement(aT,{ref:a,iconNode:t,className:ib(`lucide-${tT(ob(e))}`,`lucide-${e}`,n),...s}));return r.displayName=ob(e),r};const bu=Y("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 oT=Y("arrow-down",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);const lb=Y("arrow-right",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]]);const iT=Y("arrow-up",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]);const ku=Y("ban",[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const lT=Y("bell-ring",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M22 8c0-2.3-.8-4.3-2-6",key:"5bb3ad"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}],["path",{d:"M4 2C2.8 3.7 2 5.7 2 8",key:"tap9e0"}]]);const cT=Y("bell",[["path",{d:"M10.268 21a2 2 0 0 0 3.464 0",key:"vwvbt9"}],["path",{d:"M3.262 15.326A1 1 0 0 0 4 17h16a1 1 0 0 0 .74-1.673C19.41 13.956 18 12.499 18 8A6 6 0 0 0 6 8c0 4.499-1.411 5.956-2.738 7.326",key:"11g9vi"}]]);const dT=Y("book-open",[["path",{d:"M12 7v14",key:"1akyts"}],["path",{d:"M3 18a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1h5a4 4 0 0 1 4 4 4 4 0 0 1 4-4h5a1 1 0 0 1 1 1v13a1 1 0 0 1-1 1h-6a3 3 0 0 0-3 3 3 3 0 0 0-3-3z",key:"ruj8y"}]]);const cb=Y("braces",[["path",{d:"M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1",key:"ezmyqa"}],["path",{d:"M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1",key:"e1hn23"}]]);const Ns=Y("chart-column",[["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]]);const uT=Y("chart-gantt",[["path",{d:"M10 6h8",key:"zvc2xc"}],["path",{d:"M12 16h6",key:"yi5mkt"}],["path",{d:"M3 3v16a2 2 0 0 0 2 2h16",key:"c24i48"}],["path",{d:"M8 11h7",key:"wz2hg0"}]]);const _t=Y("check",[["path",{d:"M20 6 9 17l-5-5",key:"1gmf2c"}]]);const wu=Y("chevron-down",[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]]);const pT=Y("chevron-right",[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]]);const jt=Y("circle-alert",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]]);const Cs=Y("circle-check",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const fT=Y("circle-question-mark",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const mT=Y("circle-slash",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]]);const Su=Y("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 _u=Y("circle-x",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m15 9-6 6",key:"1uzhvr"}],["path",{d:"m9 9 6 6",key:"z0biqf"}]]);const ju=Y("circle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const Tu=Y("clipboard-list",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"M12 11h4",key:"1jrz19"}],["path",{d:"M12 16h4",key:"n85exb"}],["path",{d:"M8 11h.01",key:"1dfujw"}],["path",{d:"M8 16h.01",key:"18s6g9"}]]);const Iu=Y("clock",[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const hT=Y("cloud",[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]]);const Nu=Y("code-xml",[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]]);const yT=Y("compass",[["path",{d:"m16.24 7.76-1.804 5.411a2 2 0 0 1-1.265 1.265L7.76 16.24l1.804-5.411a2 2 0 0 1 1.265-1.265z",key:"9ktpf1"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]]);const db=Y("copy",[["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]]);const gT=Y("corner-down-left",[["path",{d:"M20 4v7a4 4 0 0 1-4 4H4",key:"6o5b7l"}],["path",{d:"m9 10-5 5 5 5",key:"1kshq7"}]]);const xT=Y("corner-down-right",[["path",{d:"m15 10 5 5-5 5",key:"qqa56n"}],["path",{d:"M4 4v7a4 4 0 0 0 4 4h12",key:"z08zvw"}]]);const vT=Y("credit-card",[["rect",{width:"20",height:"14",x:"2",y:"5",rx:"2",key:"ynyp8z"}],["line",{x1:"2",x2:"22",y1:"10",y2:"10",key:"1b3vmo"}]]);const ub=Y("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 bT=Y("download",[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]]);const kT=Y("eraser",[["path",{d:"M21 21H8a2 2 0 0 1-1.42-.587l-3.994-3.999a2 2 0 0 1 0-2.828l10-10a2 2 0 0 1 2.829 0l5.999 6a2 2 0 0 1 0 2.828L12.834 21",key:"g5wo59"}],["path",{d:"m5.082 11.09 8.828 8.828",key:"1wx5vj"}]]);const Cu=Y("file-text",[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]]);const wT=Y("flag",[["path",{d:"M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528",key:"1jaruq"}]]);const Eu=Y("flame",[["path",{d:"M12 3q1 4 4 6.5t3 5.5a1 1 0 0 1-14 0 5 5 0 0 1 1-3 1 1 0 0 0 5 0c0-2-1.5-3-1.5-5q0-2 2.5-4",key:"1slcih"}]]);const Es=Y("flask-conical",[["path",{d:"M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2",key:"18mbvz"}],["path",{d:"M6.453 15h11.094",key:"3shlmq"}],["path",{d:"M8.5 2h7",key:"csnxdl"}]]);const pb=Y("folder-open",[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]]);const br=Y("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 pn=Y("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 Rs=Y("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 fb=Y("hammer",[["path",{d:"m15 12-9.373 9.373a1 1 0 0 1-3.001-3L12 9",key:"1hayfq"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172v-.344a2 2 0 0 0-.586-1.414l-1.657-1.657A6 6 0 0 0 12.516 3H9l1.243 1.243A6 6 0 0 1 12 8.485V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"15ts47"}]]);const ST=Y("hard-drive",[["line",{x1:"22",x2:"2",y1:"12",y2:"12",key:"1y58io"}],["path",{d:"M5.45 5.11 2 12v6a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-6l-3.45-6.89A2 2 0 0 0 16.76 4H7.24a2 2 0 0 0-1.79 1.11z",key:"oot6mr"}],["line",{x1:"6",x2:"6.01",y1:"16",y2:"16",key:"sgf278"}],["line",{x1:"10",x2:"10.01",y1:"16",y2:"16",key:"1l4acy"}]]);const _T=Y("history",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]);const Ru=Y("hourglass",[["path",{d:"M5 22h14",key:"ehvnwv"}],["path",{d:"M5 2h14",key:"pdyrp9"}],["path",{d:"M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22",key:"1d314k"}],["path",{d:"M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2",key:"1vvvr6"}]]);const mb=Y("info",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]]);const hb=Y("key",[["path",{d:"m15.5 7.5 2.3 2.3a1 1 0 0 0 1.4 0l2.1-2.1a1 1 0 0 0 0-1.4L19 4",key:"g0fldk"}],["path",{d:"m21 2-9.6 9.6",key:"1j0ho8"}],["circle",{cx:"7.5",cy:"15.5",r:"5.5",key:"yqb3hr"}]]);const jT=Y("layout-list",[["rect",{width:"7",height:"7",x:"3",y:"3",rx:"1",key:"1g98yp"}],["rect",{width:"7",height:"7",x:"3",y:"14",rx:"1",key:"1bb6yr"}],["path",{d:"M14 4h7",key:"3xa0d5"}],["path",{d:"M14 9h7",key:"1icrd9"}],["path",{d:"M14 15h7",key:"1mj8o2"}],["path",{d:"M14 20h7",key:"11slyb"}]]);const TT=Y("layout-template",[["rect",{width:"18",height:"7",x:"3",y:"3",rx:"1",key:"f1a2em"}],["rect",{width:"9",height:"7",x:"3",y:"14",rx:"1",key:"jqznyg"}],["rect",{width:"5",height:"7",x:"16",y:"14",rx:"1",key:"q5h2i8"}]]);const yb=Y("library",[["path",{d:"m16 6 4 14",key:"ji33uf"}],["path",{d:"M12 6v14",key:"1n7gus"}],["path",{d:"M8 8v12",key:"1gg7y9"}],["path",{d:"M4 4v16",key:"6qkkli"}]]);const Os=Y("lightbulb",[["path",{d:"M15 14c.2-1 .7-1.7 1.5-2.5 1-.9 1.5-2.2 1.5-3.5A6 6 0 0 0 6 8c0 1 .2 2.2 1.5 3.5.7.7 1.3 1.5 1.5 2.5",key:"1gvzjb"}],["path",{d:"M9 18h6",key:"x1upvd"}],["path",{d:"M10 22h4",key:"ceow96"}]]);const Ou=Y("link",[["path",{d:"M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71",key:"1cjeqo"}],["path",{d:"M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71",key:"19qd67"}]]);const Pu=Y("loader-circle",[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]]);const IT=Y("loader",[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]]);const NT=Y("lock",[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]]);const gb=Y("mail",[["path",{d:"m22 7-8.991 5.727a2 2 0 0 1-2.009 0L2 7",key:"132q7q"}],["rect",{x:"2",y:"4",width:"20",height:"16",rx:"2",key:"izxlao"}]]);const CT=Y("map",[["path",{d:"M14.106 5.553a2 2 0 0 0 1.788 0l3.659-1.83A1 1 0 0 1 21 4.619v12.764a1 1 0 0 1-.553.894l-4.553 2.277a2 2 0 0 1-1.788 0l-4.212-2.106a2 2 0 0 0-1.788 0l-3.659 1.83A1 1 0 0 1 3 19.381V6.618a1 1 0 0 1 .553-.894l4.553-2.277a2 2 0 0 1 1.788 0z",key:"169xi5"}],["path",{d:"M15 5.764v15",key:"1pn4in"}],["path",{d:"M9 3.236v15",key:"1uimfh"}]]);const xb=Y("maximize-2",[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]]);const ET=Y("megaphone",[["path",{d:"M11 6a13 13 0 0 0 8.4-2.8A1 1 0 0 1 21 4v12a1 1 0 0 1-1.6.8A13 13 0 0 0 11 14H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2z",key:"q8bfy3"}],["path",{d:"M6 14a12 12 0 0 0 2.4 7.2 2 2 0 0 0 3.2-2.4A8 8 0 0 1 10 14",key:"1853fq"}],["path",{d:"M8 6v8",key:"15ugcq"}]]);const vb=Y("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 bb=Y("minus",[["path",{d:"M5 12h14",key:"1ays0h"}]]);const RT=Y("monitor",[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]]);const OT=Y("moon",[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]]);const PT=Y("mouse-pointer-click",[["path",{d:"M14 4.1 12 6",key:"ita8i4"}],["path",{d:"m5.1 8-2.9-.8",key:"1go3kf"}],["path",{d:"m6 12-1.9 2",key:"mnht97"}],["path",{d:"M7.2 2.2 8 5.1",key:"1cfko1"}],["path",{d:"M9.037 9.69a.498.498 0 0 1 .653-.653l11 4.5a.5.5 0 0 1-.074.949l-4.349 1.041a1 1 0 0 0-.74.739l-1.04 4.35a.5.5 0 0 1-.95.074z",key:"s0h3yz"}]]);const AT=Y("network",[["rect",{x:"16",y:"16",width:"6",height:"6",rx:"1",key:"4q2zg0"}],["rect",{x:"2",y:"16",width:"6",height:"6",rx:"1",key:"8cvhb9"}],["rect",{x:"9",y:"2",width:"6",height:"6",rx:"1",key:"1egb70"}],["path",{d:"M5 16v-3a1 1 0 0 1 1-1h12a1 1 0 0 1 1 1v3",key:"1jsf9p"}],["path",{d:"M12 12V8",key:"2874zd"}]]);const kb=Y("package",[["path",{d:"M11 21.73a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73z",key:"1a0edw"}],["path",{d:"M12 22V12",key:"d0xqtd"}],["polyline",{points:"3.29 7 12 12 20.71 7",key:"ousv84"}],["path",{d:"m7.5 4.27 9 5.15",key:"1c824w"}]]);const Au=Y("pause",[["rect",{x:"14",y:"3",width:"5",height:"18",rx:"1",key:"kaeet6"}],["rect",{x:"5",y:"3",width:"5",height:"18",rx:"1",key:"1wsw3u"}]]);const fn=Y("pencil",[["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}],["path",{d:"m15 5 4 4",key:"1mk7zo"}]]);const Ot=Y("play",[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]]);const wb=Y("plug",[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M17 8a1 1 0 0 1 1 1v4a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V9a1 1 0 0 1 1-1z",key:"1xoxul"}],["path",{d:"M9 8V2",key:"14iosj"}]]);const rr=Y("plus",[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"M12 5v14",key:"s699le"}]]);const $T=Y("puzzle",[["path",{d:"M15.39 4.39a1 1 0 0 0 1.68-.474 2.5 2.5 0 1 1 3.014 3.015 1 1 0 0 0-.474 1.68l1.683 1.682a2.414 2.414 0 0 1 0 3.414L19.61 15.39a1 1 0 0 1-1.68-.474 2.5 2.5 0 1 0-3.014 3.015 1 1 0 0 1 .474 1.68l-1.683 1.682a2.414 2.414 0 0 1-3.414 0L8.61 19.61a1 1 0 0 0-1.68.474 2.5 2.5 0 1 1-3.014-3.015 1 1 0 0 0 .474-1.68l-1.683-1.682a2.414 2.414 0 0 1 0-3.414L4.39 8.61a1 1 0 0 1 1.68.474 2.5 2.5 0 1 0 3.014-3.015 1 1 0 0 1-.474-1.68l1.683-1.682a2.414 2.414 0 0 1 3.414 0z",key:"w46dr5"}]]);const DT=Y("radio",[["path",{d:"M16.247 7.761a6 6 0 0 1 0 8.478",key:"1fwjs5"}],["path",{d:"M19.075 4.933a10 10 0 0 1 0 14.134",key:"ehdyv1"}],["path",{d:"M4.925 19.067a10 10 0 0 1 0-14.134",key:"1q22gi"}],["path",{d:"M7.753 16.239a6 6 0 0 1 0-8.478",key:"r2q7qm"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);const LT=Y("redo-2",[["path",{d:"m15 14 5-5-5-5",key:"12vg1m"}],["path",{d:"M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13",key:"6uklza"}]]);const Ps=Y("refresh-cw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]]);const Lr=Y("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 mn=Y("rocket",[["path",{d:"M4.5 16.5c-1.5 1.26-2 5-2 5s3.74-.5 5-2c.71-.84.7-2.13-.09-2.91a2.18 2.18 0 0 0-2.91-.09z",key:"m3kijz"}],["path",{d:"m12 15-3-3a22 22 0 0 1 2-3.95A12.88 12.88 0 0 1 22 2c0 2.72-.78 7.5-6 11a22.35 22.35 0 0 1-4 2z",key:"1fmvmk"}],["path",{d:"M9 12H4s.55-3.03 2-4c1.62-1.08 5 0 5 0",key:"1f8sc4"}],["path",{d:"M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5",key:"qeys4"}]]);const $u=Y("rotate-ccw",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}]]);const Du=Y("rotate-cw",[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]]);const MT=Y("save",[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]]);const Lu=Y("scale",[["path",{d:"M12 3v18",key:"108xh3"}],["path",{d:"m19 8 3 8a5 5 0 0 1-6 0zV7",key:"zcdpyk"}],["path",{d:"M3 7h1a17 17 0 0 0 8-2 17 17 0 0 0 8 2h1",key:"1yorad"}],["path",{d:"m5 8 3 8a5 5 0 0 1-6 0zV7",key:"eua70x"}],["path",{d:"M7 21h10",key:"1b0cd5"}]]);const WT=Y("scroll-text",[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]]);const Mu=Y("search",[["path",{d:"m21 21-4.34-4.34",key:"14j7rj"}],["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}]]);const Sb=Y("send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]]);const zT=Y("server",[["rect",{width:"20",height:"8",x:"2",y:"2",rx:"2",ry:"2",key:"ngkwjq"}],["rect",{width:"20",height:"8",x:"2",y:"14",rx:"2",ry:"2",key:"iecqi9"}],["line",{x1:"6",x2:"6.01",y1:"6",y2:"6",key:"16zg32"}],["line",{x1:"6",x2:"6.01",y1:"18",y2:"18",key:"nzw8ys"}]]);const _b=Y("settings",[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]]);const qT=Y("settings-2",[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]]);const jb=Y("shield-check",[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]]);const Mr=Y("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 Wu=Y("skip-forward",[["path",{d:"M21 4v16",key:"7j8fe9"}],["path",{d:"M6.029 4.285A2 2 0 0 0 3 6v12a2 2 0 0 0 3.029 1.715l9.997-5.998a2 2 0 0 0 .003-3.432z",key:"zs4d6"}]]);const Tb=Y("sliders-horizontal",[["path",{d:"M10 5H3",key:"1qgfaw"}],["path",{d:"M12 19H3",key:"yhmn1j"}],["path",{d:"M14 3v4",key:"1sua03"}],["path",{d:"M16 17v4",key:"1q0r14"}],["path",{d:"M21 12h-9",key:"1o4lsq"}],["path",{d:"M21 19h-5",key:"1rlt1p"}],["path",{d:"M21 5h-7",key:"1oszz2"}],["path",{d:"M8 10v4",key:"tgpxqk"}],["path",{d:"M8 12H3",key:"a7s4jb"}]]);const FT=Y("smartphone",[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]]);const Pt=Y("sparkles",[["path",{d:"M11.017 2.814a1 1 0 0 1 1.966 0l1.051 5.558a2 2 0 0 0 1.594 1.594l5.558 1.051a1 1 0 0 1 0 1.966l-5.558 1.051a2 2 0 0 0-1.594 1.594l-1.051 5.558a1 1 0 0 1-1.966 0l-1.051-5.558a2 2 0 0 0-1.594-1.594l-5.558-1.051a1 1 0 0 1 0-1.966l5.558-1.051a2 2 0 0 0 1.594-1.594z",key:"1s2grr"}],["path",{d:"M20 2v4",key:"1rf3ol"}],["path",{d:"M22 4h-4",key:"gwowj6"}],["circle",{cx:"4",cy:"20",r:"2",key:"6kqj1y"}]]);const hn=Y("square",[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]]);const Ib=Y("stethoscope",[["path",{d:"M11 2v2",key:"1539x4"}],["path",{d:"M5 2v2",key:"1yf1q8"}],["path",{d:"M5 3H4a2 2 0 0 0-2 2v4a6 6 0 0 0 12 0V5a2 2 0 0 0-2-2h-1",key:"rb5t3r"}],["path",{d:"M8 15a6 6 0 0 0 12 0v-3",key:"x18d4x"}],["circle",{cx:"20",cy:"10",r:"2",key:"ts1r5v"}]]);const BT=Y("sunrise",[["path",{d:"M12 2v8",key:"1q4o3n"}],["path",{d:"m4.93 10.93 1.41 1.41",key:"2a7f42"}],["path",{d:"M2 18h2",key:"j10viu"}],["path",{d:"M20 18h2",key:"wocana"}],["path",{d:"m19.07 10.93-1.41 1.41",key:"15zs5n"}],["path",{d:"M22 22H2",key:"19qnx5"}],["path",{d:"m8 6 4-4 4 4",key:"ybng9g"}],["path",{d:"M16 18a4 4 0 0 0-8 0",key:"1lzouq"}]]);const As=Y("tag",[["path",{d:"M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z",key:"vktsd0"}],["circle",{cx:"7.5",cy:"7.5",r:".5",fill:"currentColor",key:"kqv944"}]]);const HT=Y("target",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["circle",{cx:"12",cy:"12",r:"6",key:"1vlfrh"}],["circle",{cx:"12",cy:"12",r:"2",key:"1c9p78"}]]);const Nb=Y("terminal",[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]]);const zu=Y("timer",[["line",{x1:"10",x2:"14",y1:"2",y2:"2",key:"14vaq8"}],["line",{x1:"12",x2:"15",y1:"14",y2:"11",key:"17fdiu"}],["circle",{cx:"12",cy:"14",r:"8",key:"1e1u0o"}]]);const $s=Y("trash-2",[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]]);const Ye=Y("triangle-alert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]]);const qu=Y("undo-2",[["path",{d:"M9 14 4 9l5-5",key:"102s5s"}],["path",{d:"M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11",key:"f3b9sd"}]]);const Cb=Y("upload",[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]]);const Fu=Y("user",[["path",{d:"M19 21v-2a4 4 0 0 0-4-4H9a4 4 0 0 0-4 4v2",key:"975kel"}],["circle",{cx:"12",cy:"7",r:"4",key:"17ys0d"}]]);const JT=Y("waves",[["path",{d:"M2 6c.6.5 1.2 1 2.5 1C7 7 7 5 9.5 5c2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"knzxuh"}],["path",{d:"M2 12c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"2jd2cc"}],["path",{d:"M2 18c.6.5 1.2 1 2.5 1 2.5 0 2.5-2 5-2 2.6 0 2.4 2 5 2 2.5 0 2.5-2 5-2 1.3 0 1.9.5 2.5 1",key:"rd2r6e"}]]);const UT=Y("waypoints",[["circle",{cx:"12",cy:"4.5",r:"2.5",key:"r5ysbb"}],["path",{d:"m10.2 6.3-3.9 3.9",key:"1nzqf6"}],["circle",{cx:"4.5",cy:"12",r:"2.5",key:"jydg6v"}],["path",{d:"M7 12h10",key:"b7w52i"}],["circle",{cx:"19.5",cy:"12",r:"2.5",key:"1piiel"}],["path",{d:"m13.8 17.7 3.9-3.9",key:"1wyg1y"}],["circle",{cx:"12",cy:"19.5",r:"2.5",key:"13o1pw"}]]);const VT=Y("workflow",[["rect",{width:"8",height:"8",x:"3",y:"3",rx:"2",key:"by2w9f"}],["path",{d:"M7 11v4a2 2 0 0 0 2 2h4",key:"xkn7yn"}],["rect",{width:"8",height:"8",x:"13",y:"13",rx:"2",key:"1cgmvn"}]]);const Eb=Y("wrench",[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]]);const $e=Y("x",[["path",{d:"M18 6 6 18",key:"1bl5f8"}],["path",{d:"m6 6 12 12",key:"d8bk6v"}]]);const At=Y("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"}]]),KT={business:["business"],standard:["business","control"],developer:["business","control","data"]},$t=[{type:"SIMPLE",label:"任务节点 (Worker)",description:"在远程 Worker 上执行的任务",category:"CORE",icon:bu,viewCategory:"business"},{type:"SUB_WORKFLOW",label:"子工作流 (Sub Workflow)",description:"调用并执行另一个工作流",category:"CORE",icon:pn,viewCategory:"business"},{type:"START_WORKFLOW",label:"启动工作流 (Start Workflow)",description:"启动另一个工作流(不等待结果)",category:"SYSTEM",icon:Ot,viewCategory:"business"},{type:"HTTP",label:"HTTP 请求",description:"发起 REST/HTTP 调用",category:"SYSTEM",icon:Rs,viewCategory:"business"},{type:"INLINE",label:"内联脚本 (Inline)",description:"执行内联脚本(JS/Python/GraalJS)",category:"SYSTEM",icon:Nu,viewCategory:"data"},{type:"JSON_JQ_TRANSFORM",label:"JSON 转换 (JQ)",description:"使用 JQ 表达式转换 JSON 数据",category:"SYSTEM",icon:Nb,viewCategory:"data"},{type:"KAFKA_PUBLISH",label:"Kafka 推送",description:"向 Kafka 主题推送消息",category:"SYSTEM",icon:vb,viewCategory:"data"},{type:"EVENT",label:"事件 (Event)",description:"向外部队列系统发布事件",category:"SYSTEM",icon:At,viewCategory:"data"},{type:"WAIT",label:"等待 (Wait)",description:"暂停流程,直到特定时间或时长",category:"SYSTEM",icon:Iu,viewCategory:"control"},{type:"SET_VARIABLE",label:"设置变量 (Set Variable)",description:"设置工作流上下文变量",category:"SYSTEM",icon:ub,viewCategory:"data"},{type:"TERMINATE",label:"终止 (Terminate)",description:"提前结束工作流执行",category:"SYSTEM",icon:Su,viewCategory:"control"},{type:"HUMAN",label:"人工审批 (Human)",description:"等待人工审核或表单提交",category:"SYSTEM",icon:Fu,viewCategory:"business"},{type:"DYNAMIC",label:"动态任务 (Dynamic)",description:"运行时动态决定任务类型",category:"SYSTEM",icon:Mr,viewCategory:"data"},{type:"NOOP",label:"空操作 (Noop)",description:"占位符任务,无实际操作",category:"SYSTEM",icon:bb,viewCategory:"data"},{type:"LAMBDA",label:"Lambda 脚本 (旧)",description:"已被 INLINE 取代",category:"SYSTEM",icon:Nu,hidden:!0,viewCategory:"data"},{type:"SWITCH",label:"条件分支 (Switch)",description:"基于条件的逻辑分支 (Switch/Case)",category:"FLOW",icon:Mr,viewCategory:"control"},{type:"DECISION",label:"判断 (Decision,旧)",description:"基于条件的逻辑分支(旧版,推荐改用 Switch)",category:"FLOW",icon:Mr,hidden:!0,viewCategory:"control"},{type:"FORK_JOIN",label:"静态并行 (Fork)",description:"并行执行多个预定义任务分支",category:"FLOW",icon:br,viewCategory:"control"},{type:"FORK_JOIN_DYNAMIC",label:"动态并行 (Dynamic Fork)",description:"运行时动态生成并行分支",category:"FLOW",icon:br,viewCategory:"control"},{type:"DO_WHILE",label:"循环 (Do-While)",description:"循环执行直到满足条件",category:"FLOW",icon:Lr,viewCategory:"control"},{type:"JOIN",label:"汇聚 (Join)",description:"等待所有并行分支执行完成",category:"FLOW",icon:pn,viewCategory:"control"}],GT=[{key:"CORE",label:"基础任务"},{key:"FLOW",label:"逻辑控制"},{key:"SYSTEM",label:"系统集成"}],Dt=({message:e,onConfirm:t,onCancel:r,confirmLabel:n="继续"})=>{const s=T.useRef(null),{theme:a,themeColor:i}=te(Ae(l=>({theme:l.theme,themeColor:l.themeColor})));return T.useEffect(()=>{s.current?.focus({preventScroll:!0});const l=c=>{c.key==="Escape"&&r()};return window.addEventListener("keydown",l),()=>window.removeEventListener("keydown",l)},[r]),bt.createPortal(o.jsx("div",{"data-mode":a,"data-brand":i,onClick:r,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"var(--cm-overlay)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"确认操作",onClick:l=>l.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"8px",padding:"24px 28px",maxWidth:"380px",width:"90%",boxShadow:"var(--cm-shadow-float)"},children:[o.jsx("div",{style:{fontSize:"14px",color:"var(--text-primary)",marginBottom:"24px",lineHeight:"1.6",whiteSpace:"pre-wrap",maxHeight:"50vh",overflowY:"auto"},children:e}),o.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[o.jsx("button",{ref:s,onClick:r,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:"取消"}),o.jsx("button",{onClick:t,style:{padding:"7px 18px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"6px",color:"var(--color-on-accent)",cursor:"pointer",fontSize:"13px",fontWeight:600},children:n})]})]})}),document.body)},yn=({children:e,nodeId:t,selected:r=!1,isStartOrEnd:n=!1,isError:s=!1,hasWarning:a=!1,isDecision:i=!1,isHighlighted:l=!1,executionStatus:c,simRunning:d=!1,simDone:u=!1,proposalStatus:p})=>{const{mode:f,removeNode:m}=te(Ae(S=>({mode:S.mode,removeNode:S.removeNode}))),[h,y]=T.useState(!1),x=S=>{S.stopPropagation(),y(!0)},g=f==="edit"&&!n,k=[i?"decision-node-wrapper":"node-wrapper-glass",r?"node-wrapper-selected":"",l?"node-wrapper-highlighted":"",d?"node-sim-running":"",u?"node-sim-done":"",p?`node-proposal-${p}`:""].filter(Boolean).join(" "),b=T.useMemo(()=>{if(f!=="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 color-mix(in srgb, var(--cm-status-failed) 50%, transparent), 0 0 24px color-mix(in srgb, var(--cm-status-failed) 20%, transparent)"};case"TIMED_OUT":return{borderColor:"var(--status-timed-out)",boxShadow:"0 0 8px color-mix(in srgb, var(--color-accent) 40%, transparent)"};case"IN_PROGRESS":case"SCHEDULED":return{borderColor:"var(--status-in-progress)",animation:"status-pulse 1.5s ease-in-out infinite"};case"COMPLETED":return{borderColor:"var(--status-completed)",opacity:.85};case"COMPLETED_WITH_ERRORS":return{borderColor:"var(--status-completed-with-errors)"};case"SKIPPED":case"CANCELED":return{opacity:.5};default:return{}}},[f,c]);return o.jsxs("div",{className:k,style:{position:"relative",...b},children:[g&&o.jsx("button",{onClick:x,"aria-label":"删除任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"var(--cm-status-failed)",color:"var(--cm-on-danger)",border:"2px solid var(--cm-surface-1)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"var(--cm-shadow-card)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},title:"删除任务",children:"×"}),s&&o.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"var(--cm-status-failed)",color:"var(--cm-on-danger)",border:"2px solid var(--cm-surface-1)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"var(--cm-shadow-card)"},title:"此节点配置有误",children:o.jsx(jt,{size:14,strokeWidth:2,"aria-hidden":"true"})}),!s&&a&&o.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"var(--cm-status-warning)",color:"var(--cm-on-danger)",border:"2px solid var(--cm-surface-1)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"var(--cm-shadow-card)"},title:"此节点有警告信息",children:o.jsx(Ye,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),p&&o.jsx("div",{className:`node-proposal-badge node-proposal-badge-${p}`,children:p==="added"?"+":p==="modified"?"~":"−"}),e,h&&o.jsx(Dt,{message:uu(te.getState().workflowDef,t).message,confirmLabel:"删除",onConfirm:()=>{m(t),y(!1)},onCancel:()=>y(!1)})]})},YT={pending:"var(--cm-status-pending)",running:"var(--cm-status-running)",success:"var(--cm-status-success)",warning:"var(--cm-status-warning)",failed:"var(--cm-status-failed)",skipped:"var(--cm-status-skipped)",muted:"var(--cm-text-muted)"};function ft(e,t,r,n,s){return{label:e,icon:t,iconName:r,tone:n,color:YT[n],terminal:s.terminal,isFailure:!!s.isFailure,isActive:!s.terminal}}const Rb={SCHEDULED:ft("等待中",ju,"circle","pending",{terminal:!1}),IN_PROGRESS:ft("运行中",Pu,"loader","running",{terminal:!1}),RUNNING:ft("运行中",Pu,"loader","running",{terminal:!1}),PAUSED:ft("已暂停",Au,"pause","warning",{terminal:!1}),COMPLETED:ft("成功",_t,"check","success",{terminal:!0}),COMPLETED_WITH_ERRORS:ft("带错完成",Ye,"alert","warning",{terminal:!0}),FAILED:ft("失败",$e,"x","failed",{terminal:!0,isFailure:!0}),FAILED_WITH_TERMINAL_ERROR:ft("失败(不可重试)",$e,"x","failed",{terminal:!0,isFailure:!0}),TIMED_OUT:ft("已超时",zu,"timer","warning",{terminal:!0,isFailure:!0}),SKIPPED:ft("已跳过",Wu,"skip","skipped",{terminal:!0}),CANCELED:ft("已取消",ku,"ban","muted",{terminal:!0}),TERMINATED:ft("已终止",Su,"stop","failed",{terminal:!0,isFailure:!0})},XT=ft("未知",fT,"help","muted",{terminal:!1});function He(e){const t=String(e??"").trim().toUpperCase();return{...Rb[t]??XT,status:t||"UNKNOWN",className:(Rb[t]?t:"UNKNOWN").toLowerCase().replace(/_/g,"-")}}function ZT(e){return He(e).label}const QT=({status:e})=>{const{icon:t,className:r,label:n}=He(e);return o.jsx("div",{className:`execution-status-badge ${r}`,title:`${n}(${e})`,role:"img","aria-label":`状态:${n}`,children:o.jsx("span",{className:"badge-icon",children:o.jsx(t,{size:12,strokeWidth:2.25,"aria-hidden":"true"})})})},Bu=T.memo(QT),eI=/[一-龥]/,tI=({icon:e,header:t,title:r,subTitle:n,meta:s,duration:a,color:i,status:l,isRunning:c,children:d,width:u="240px"})=>{const p=c&&l?l==="COMPLETED"?"var(--status-completed)":l==="FAILED"||l==="FAILED_WITH_TERMINAL_ERROR"?"var(--status-failed)":l==="IN_PROGRESS"||l==="SCHEDULED"?"var(--status-in-progress)":l==="TIMED_OUT"||l==="COMPLETED_WITH_ERRORS"?"var(--status-timed-out)":i:i,f=u==="240px"||u===240?"237px":u;return o.jsxs("div",{style:{display:"flex",flexDirection:"row",width:f,height:d?void 0:"81px",minHeight:"81px",boxSizing:"border-box",position:"relative",overflow:"hidden",borderRadius:"10px"},children:[o.jsx("div",{style:{width:"44px",display:"flex",alignItems:"center",justifyContent:"center",background:"color-mix(in srgb, var(--color-accent) 8%, transparent)",borderLeft:`3px solid ${p}`,borderRight:"1px solid var(--border-primary)",color:p,flexShrink:0},children:o.jsx(e,{size:18,strokeWidth:1.75})}),o.jsxs("div",{style:{flex:1,padding:"6px 12px",display:"flex",flexDirection:"column",justifyContent:"center",overflow:"hidden",minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",marginBottom:"2px",paddingRight:c&&l?"20px":0},children:[o.jsx("div",{style:{fontSize:"10px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",lineHeight:1.2,opacity:.85,color:i,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",...eI.test(t)&&{letterSpacing:"0.2px",fontSize:"11px"}},children:t}),c&&a&&o.jsx("span",{style:{fontSize:"10px",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",background:"var(--bg-tertiary)",padding:"1px 5px",borderRadius:"4px",flexShrink:0,lineHeight:1.2},children:a})]}),o.jsx("div",{style:{fontSize:"13.5px",fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.25,marginBottom:n||s?"1px":0},title:r,children:r}),n&&n!==r&&n!==s&&o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis",lineHeight:1.25},title:n,children:n}),s&&o.jsx("div",{style:{fontSize:"11px",color:"var(--text-muted)",lineHeight:1.25,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},title:s,children:s}),d&&o.jsx("div",{style:{marginTop:"6px"},children:d})]}),c&&l&&o.jsx("div",{style:{position:"absolute",top:"7px",right:"7px"},children:o.jsx(Bu,{status:l})})]})},Ds=T.memo(tI),kr=e=>{const t=e.layoutDirection||"TB",r=e.sourcePosition||(t==="LR"?J.Position.Right:J.Position.Bottom),n=e.targetPosition||(t==="LR"?J.Position.Left:J.Position.Top);return{layoutDirection:t,sourcePosition:r,targetPosition:n}},Wr=e=>{const{mode:t,executionData:r,workflowDef:n,activeLoopIterations:s,timeTravelTimestamp:a}=te(Ae(m=>({mode:m.mode,executionData:m.executionData,workflowDef:m.workflowDef,activeLoopIterations:m.activeLoopIterations,timeTravelTimestamp:m.timeTravelTimestamp}))),i=t==="run"?r?.[e]:null,l=t==="run";let c=i?{...i}:null;if(l&&c&&c.attempts.length>1&&n?.tasks){const m=Bj(n.tasks,e);c=Hj(c,m,s)}if(l&&c&&a!==null){const m=c.startTime??0,h=c.endTime??m;m>a?c={...c,status:"SCHEDULED"}:m<=a&&h>a&&(c={...c,status:"IN_PROGRESS"})}const d=c?.iteration,u=c?d!==void 0?c.attempts.filter(m=>m.iteration===d):c.attempts:[],p=xu(u);let f;if(l&&c?.startTime)if(a!==null&&c.startTime>a)f="待执行";else if(a!==null&&c.startTime<=a&&(c.endTime??c.startTime)>a)f=`${a-c.startTime}ms...`;else if(c.endTime&&c.endTime>=c.startTime){const m=c.endTime-c.startTime;f=m<1e3?`${m}ms`:`${(m/1e3).toFixed(2)}s`}else(c.status==="IN_PROGRESS"||c.status==="SCHEDULED")&&(f="运行中");return{mode:t,execution:c,isRunning:l,retryCount:p,durationText:f}};function nr(e,t){return e.length>t?e.slice(0,t)+"…":e}function gn(e,t,r,n){if(r==="business")return t.task?.description?.trim()||n;if(r==="standard")return n;const s=t.task;if(!s)return n;const a=s.inputParameters||{};switch(e){case"HTTP":case"HTTP_POLL":{const i=s.httpRequest||a.http_request;if(!i)return n;const l=(i.method||"GET").toUpperCase(),c=i.uri?nr(String(i.uri),28):"";return c?`${l} ${c}`:l}case"SWITCH":{const i=s.expression||s.caseExpression||a.expression,l=s.evaluatorType||a.evaluatorType;return i?nr(i,35):l||n}case"DECISION":return s.caseValueParam?`param: ${s.caseValueParam}`:n;case"SIMPLE":return s.name?`worker: ${nr(s.name,28)}`:n;case"INLINE":case"LAMBDA":{const i=a.evaluatorType||s.evaluatorType;return i?`${i} script`:n}case"SUB_WORKFLOW":{const i=s.subWorkflowParam;return i?`${i.name}${i.version?` v${i.version}`:""}`:n}case"DO_WHILE":{const i=s.loopCondition;return i?nr(i,35):n}case"JSON_JQ_TRANSFORM":{const i=a.queryExpression||a.query_expression;return i?nr(i,35):n}case"SET_VARIABLE":{const i=Object.keys(a);return i.length?`set: ${i.slice(0,2).join(", ")}${i.length>2?"…":""}`:n}case"EVENT":{const i=s.sink||a.sink;return i?`→ ${nr(i,32)}`:n}case"KAFKA_PUBLISH":{const i=a.topic||a.kafka_request?.topic;return i?`topic: ${nr(i,28)}`:n}case"START_WORKFLOW":{const i=s.startWorkflow?.name??a.startWorkflow?.name??a.start_workflow?.name;return i?`→ ${i}`:n}default:return n}}function zr(e,t){if(t!=="business")return e;const r=$t.find(n=>n.type===e);return r?r.label.replace(/\s*\([^)]+\)$/,""):e==="JOIN"?"汇聚":e==="EXCLUSIVE_JOIN"?"排他汇聚":e}const rI=({id:e,data:t,selected:r})=>{const n=t.taskType||"SIMPLE",{sourcePosition:s,targetPosition:a}=kr(t),{execution:i,isRunning:l,retryCount:c,durationText:d}=Wr(t.taskReferenceName),u=te(j=>j.viewMode),p=te(j=>j.mode),f=te(j=>j.setInlineCopilotTaskRef),h=J.useStore(j=>j.transform[2])>=1.15,y=T.useMemo(()=>$t.find(j=>j.type===n),[n]),x=y?.icon||bu,g=n==="NOOP",v=t.isDynamicRuntime===!0,k=g?"var(--text-secondary)":"var(--color-accent)",b=T.useMemo(()=>{let j;return v?j=`Dynamic (${n})`:n==="SIMPLE"?j=t.label==="Worker Task"?"Execute on Worker":"Worker Task":n==="HTTP"?j="REST API Call":n==="JSON_JQ_TRANSFORM"?j="JQ Expression":n==="INLINE"||n==="LAMBDA"?j="Inline Script":n==="START_WORKFLOW"?j="Launch Workflow (no wait)":n==="DYNAMIC"?j="Dynamic Task Type":n==="HUMAN"?j="Human Approval":n==="NOOP"?j="No Operation":j=y?.label||n,gn(n,t,u,j)},[n,y,t,u,v]),S=T.useMemo(()=>!h||!t.task?.inputParameters?[]:Object.entries(t.task.inputParameters).slice(0,2).map(([_,w])=>({key:_,val:typeof w=="object"?JSON.stringify(w).slice(0,28):String(w).slice(0,28)})),[h,t.task?.inputParameters]);return o.jsx(yn,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:i?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{style:{borderRadius:"10px",background:g?"var(--bg-tertiary)":"transparent",opacity:g?.75:1,position:"relative",outline:v?"2px dashed var(--color-accent)":"none",outlineOffset:"-2px"},children:[o.jsx(Ds,{icon:x,header:zr(n,u),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:b,duration:d,color:k,status:i?.status,isRunning:l}),S.length>0&&o.jsx("div",{style:{padding:"4px 10px 6px",borderTop:"1px dashed var(--border-primary)",fontSize:"9px",fontFamily:"monospace",color:"var(--text-secondary)",display:"flex",flexDirection:"column",gap:"2px"},children:S.map(j=>o.jsxs("div",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[o.jsx("span",{style:{color:"var(--cm-data)"},children:j.key}),": ",j.val]},j.key))}),r&&p==="edit"&&o.jsx("button",{type:"button",onClick:j=>{j.stopPropagation(),f(t.taskReferenceName)},title:"在此节点触发 ⌘K 画布内联 AI 指令",style:{position:"absolute",top:"-10px",right:"20px",padding:"1px 6px",borderRadius:"999px",border:"1px solid color-mix(in srgb, var(--cm-ai) 60%, transparent)",background:"linear-gradient(135deg, var(--cm-ai), var(--cm-data))",color:"var(--text-primary)",fontSize:"9px",fontWeight:700,cursor:"pointer",zIndex:102,boxShadow:"var(--cm-shadow-card)"},children:"⌘K"}),l&&c>0&&o.jsxs("div",{style:{position:"absolute",bottom:"4px",right:"4px",background:"var(--status-failed)",color:"var(--cm-on-danger)",borderRadius:"10px",fontSize:"10px",fontWeight:"700",padding:"1px 6px",zIndex:10,lineHeight:"1.4",pointerEvents:"none"},children:["×",c]}),v&&o.jsx("div",{style:{position:"absolute",top:"4px",right:"4px",background:"var(--color-accent)",color:"var(--color-on-accent)",borderRadius:"4px",fontSize:"9px",fontWeight:"700",padding:"1px 5px",zIndex:10,pointerEvents:"none",opacity:.9},children:"动态"}),o.jsx(J.Handle,{type:"target",position:a,style:{background:"var(--cm-surface-1)"}}),o.jsx(J.Handle,{type:"source",position:s,style:{background:"var(--cm-surface-1)"}})]})})},nI=T.memo(rI),Ob=({title:e,label:t,defaultValue:r="",placeholder:n="",confirmText:s="保存",cancelText:a="取消",onConfirm:i,onCancel:l,validate:c})=>{const{theme:d,themeColor:u}=te(Ae(g=>({theme:g.theme,themeColor:g.themeColor}))),[p,f]=T.useState(r),m=T.useRef(null);T.useEffect(()=>{m.current&&(m.current.focus({preventScroll:!0}),m.current.select());const g=v=>{v.key==="Escape"&&(v.stopPropagation(),l())};return window.addEventListener("keydown",g,!0),()=>window.removeEventListener("keydown",g,!0)},[l]);const h=c?c(p.trim()):null,y=!!p.trim()&&!h,x=()=>{const g=p.trim();g&&!h&&i(g)};return bt.createPortal(o.jsx("div",{"data-mode":d,"data-brand":u,onClick:l,style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"var(--cm-overlay)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3},children:o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":e,onClick:g=>g.stopPropagation(),style:{backgroundColor:"var(--bg-secondary)",border:"1px solid var(--border-primary)",borderRadius:"10px",padding:"24px 28px",maxWidth:"400px",width:"90%",boxShadow:"var(--cm-shadow-float)"},children:[o.jsx("div",{style:{fontSize:"15px",fontWeight:600,color:"var(--text-primary)",marginBottom:"16px"},children:e}),t&&o.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",marginBottom:"8px"},children:t}),o.jsx("input",{ref:m,type:"text",value:p,placeholder:n,onChange:g=>f(g.target.value),onKeyDown:g=>{g.key==="Enter"&&(g.preventDefault(),x()),g.stopPropagation()},style:{width:"100%",padding:"9px 12px",borderRadius:"6px",border:"1px solid var(--border-primary)",background:"var(--bg-tertiary)",color:"var(--text-primary)",fontSize:"13px",outline:"none",boxSizing:"border-box",marginBottom:h?"8px":"20px",transition:"border-color 0.15s"},onFocus:g=>{g.currentTarget.style.borderColor="var(--color-accent)"},onBlur:g=>{g.currentTarget.style.borderColor="var(--border-primary)"}}),h&&o.jsxs("div",{role:"alert",style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"12px",color:"var(--cm-status-failed)",marginBottom:"16px"},children:[o.jsx(jt,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),o.jsx("span",{children:h})]}),o.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"10px"},children:[o.jsx("button",{onClick:l,style:{padding:"7px 18px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"13px",fontWeight:500},children:a}),o.jsx("button",{onClick:x,disabled:!y,style:{padding:"7px 18px",backgroundColor:y?"var(--color-accent)":"var(--bg-tertiary)",border:"none",borderRadius:"6px",color:y?"var(--color-on-accent)":"var(--text-secondary)",cursor:y?"pointer":"not-allowed",fontSize:"13px",fontWeight:600,transition:"background-color 0.15s, color 0.15s"},children:s})]})]})}),document.body)},sI=({id:e,data:t,selected:r})=>{const{layoutDirection:n}=kr(t),{mode:s,execution:a,isRunning:i,durationText:l}=Wr(t.taskReferenceName),{addDecisionBranch:c,removeDecisionBranch:d,renameDecisionBranch:u,viewMode:p}=te(Ae(C=>({addDecisionBranch:C.addDecisionBranch,removeDecisionBranch:C.removeDecisionBranch,renameDecisionBranch:C.renameDecisionBranch,viewMode:C.viewMode}))),[f,m]=T.useState(!1),[h,y]=T.useState({type:"none"}),x=n==="LR"?J.Position.Left:J.Position.Top,g=Object.keys(t.decisionCases||t.task?.decisionCases||{}),v=()=>{m(!1),y({type:"add"})},k=(C,M)=>{C.stopPropagation(),y({type:"delete",branch:M})},b=(C,M)=>{C.stopPropagation(),m(!1),y({type:"rename",branch:M})},S=C=>{C&&c(e,C),y({type:"none"})},j=C=>{h.type==="rename"&&(C&&C!==h.branch&&u(e,h.branch,C),y({type:"none"}))},_=()=>{h.type==="delete"&&(d(e,h.branch),y({type:"none"}))},w=()=>y({type:"none"}),N=i?(C=>C&&{SCHEDULED:"execution-node-scheduled",IN_PROGRESS:"execution-node-in-progress",COMPLETED:"execution-node-completed",COMPLETED_WITH_ERRORS:"execution-node-completed-with-errors",FAILED:"execution-node-failed",FAILED_WITH_TERMINAL_ERROR:"execution-node-failed-terminal",TIMED_OUT:"execution-node-timed-out",SKIPPED:"execution-node-skipped",CANCELED:"execution-node-canceled"}[C]||"")(a?.status):"";return o.jsxs(yn,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isDecision:!0,isHighlighted:t.isHighlighted,executionStatus:a?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:[o.jsxs("div",{style:{position:"relative",width:"164px",height:"164px",display:"flex",alignItems:"center",justifyContent:"center"},children:[o.jsx(J.Handle,{type:"target",position:x,style:{background:"var(--cm-surface-1)",[n==="LR"?"left":"top"]:"-3px",zIndex:15}}),i&&a?.status&&o.jsx("div",{style:{position:"absolute",top:"12px",right:"12px",zIndex:20},children:o.jsx(Bu,{status:a.status})}),o.jsx("div",{className:N,style:{width:"122px",height:"122px",boxSizing:"border-box",borderRadius:"10px",background:i&&a?.status?void 0:"var(--glass-bg)",backdropFilter:"var(--glass-blur)",WebkitBackdropFilter:"var(--glass-blur)",border:r?"2.5px solid var(--color-accent)":i&&a?.status?void 0:"2px solid rgba(var(--color-accent-rgb), 0.45)",transform:"rotate(45deg)",display:"flex",alignItems:"center",justifyContent:"center",boxShadow:r?"var(--node-shadow-hover), 0 0 0 3px var(--node-glow-color)":i&&a?.status?void 0:"var(--node-shadow)",transition:"all 0.25s ease",cursor:"pointer",flexShrink:0},onClick:()=>s==="edit"&&m(!f),children:o.jsxs("div",{style:{transform:"rotate(-45deg)",color:"var(--text-primary)",textAlign:"center",padding:"6px",width:"116px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center"},children:[o.jsx("div",{style:{fontSize:"10px",fontWeight:700,textTransform:"uppercase",letterSpacing:"0.5px",opacity:.85,marginBottom:"2px",color:"var(--color-accent)"},children:zr(t.taskType,p)}),o.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-primary)",lineHeight:1.25,maxWidth:"104px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:t.taskReferenceName,children:t.taskReferenceName}),t.label&&t.label!==t.taskReferenceName&&o.jsx("div",{style:{fontSize:"10px",color:"var(--text-secondary)",maxWidth:"98px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"1px"},title:t.label,children:t.label}),s==="edit"&&o.jsx("div",{style:{width:"18px",height:"18px",fontSize:"12px",background:"color-mix(in srgb, var(--color-accent) 18%, transparent)",border:"1px solid rgba(var(--color-accent-rgb), 0.4)",borderRadius:"50%",display:"flex",alignItems:"center",justifyContent:"center",margin:"4px auto 0",color:"var(--color-accent)",fontWeight:700},title:"管理决策分支",children:"+"}),i&&l&&o.jsx("div",{style:{fontSize:"10px",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",background:"var(--bg-tertiary)",padding:"1px 5px",borderRadius:"4px",marginTop:"3px"},children:l})]})}),s==="edit"&&f&&o.jsxs("div",{className:"glass-panel",style:{position:"absolute",top:"170px",left:"50%",transform:"translateX(-50%)",backgroundColor:"var(--glass-surface)",border:"1px solid var(--glass-border)",borderRadius:"8px",padding:"8px",zIndex:1e3,minWidth:"200px",boxShadow:"var(--cm-shadow-float)",animation:"popIn 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",backdropFilter:"blur(12px)"},children:[o.jsx("div",{style:{padding:"4px 8px 6px",fontSize:"11px",color:"var(--text-secondary)",borderBottom:"1px solid var(--glass-border)",marginBottom:"4px",fontWeight:600,letterSpacing:"0.05em"},children:"分支管理"}),g.map(C=>o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"5px 6px",borderRadius:"4px",gap:"4px"},children:[o.jsx("span",{style:{flex:1,fontSize:"12px",color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},children:C}),o.jsx("button",{onClick:M=>b(M,C),style:{width:"22px",height:"22px",borderRadius:"4px",backgroundColor:"var(--color-accent)",color:"var(--color-on-accent)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"11px",padding:0,flexShrink:0,opacity:.85},title:`重命名分支 "${C}"`,children:o.jsx(fn,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsx("button",{onClick:M=>k(M,C),style:{width:"22px",height:"22px",borderRadius:"50%",backgroundColor:"var(--cm-status-failed)",color:"var(--cm-on-danger)",border:"none",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"13px",padding:0,flexShrink:0,opacity:.9},title:`删除分支 "${C}"`,children:"×"})]},C)),o.jsx("button",{onClick:v,style:{width:"100%",marginTop:"6px",padding:"8px",backgroundColor:"var(--color-accent)",border:"none",borderRadius:"4px",color:"var(--color-on-accent)",cursor:"pointer",fontSize:"12px",fontWeight:"bold"},children:"+ 添加新分支"})]}),p==="developer"&&(()=>{const C=(t.task?.type==="SWITCH"?t.task?.expression:void 0)||t.task?.caseExpression||t.task?.inputParameters?.expression,M=t.task?.caseValueParam;return!C&&!M?null:o.jsx("div",{style:{position:"absolute",top:"166px",left:"50%",transform:"translateX(-50%)",textAlign:"center",fontSize:10,color:"var(--text-secondary)",maxWidth:150,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",pointerEvents:"none",fontFamily:"var(--font-mono, monospace)"},children:C?nr(C,22):`param: ${M}`})})(),n==="TB"?o.jsxs(o.Fragment,{children:[o.jsx(J.Handle,{type:"source",position:J.Position.Bottom,style:{background:"var(--cm-surface-1)",bottom:"-3px",zIndex:15}}),o.jsx(J.Handle,{type:"source",position:J.Position.Left,id:"left",style:{background:"var(--cm-surface-1)",left:"-3px",zIndex:15}}),o.jsx(J.Handle,{type:"source",position:J.Position.Right,id:"right",style:{background:"var(--cm-surface-1)",right:"-3px",zIndex:15}})]}):o.jsxs(o.Fragment,{children:[o.jsx(J.Handle,{type:"source",position:J.Position.Right,style:{background:"var(--cm-surface-1)",right:"-3px",zIndex:15}}),o.jsx(J.Handle,{type:"source",position:J.Position.Top,id:"top",style:{background:"var(--cm-surface-1)",top:"-3px",zIndex:15}}),o.jsx(J.Handle,{type:"source",position:J.Position.Bottom,id:"bottom",style:{background:"var(--cm-surface-1)",bottom:"-3px",zIndex:15}})]})]}),h.type==="add"&&o.jsx(Ob,{title:"添加新分支",label:"分支条件值(Case Value)",defaultValue:`case_${g.length+1}`,placeholder:"例如:approved、rejected、pending",confirmText:"添加",validate:C=>bs(t.task,C),onConfirm:S,onCancel:w}),h.type==="rename"&&o.jsx(Ob,{title:"重命名分支",label:`当前名称:${h.branch}`,defaultValue:h.branch,placeholder:"输入新的分支条件值",confirmText:"重命名",validate:C=>bs(t.task,C,h.branch),onConfirm:j,onCancel:w}),h.type==="delete"&&o.jsx(Dt,{message:`确定要删除分支 "${h.branch}" 及其下的所有任务吗?此操作不可撤销。`,confirmLabel:"删除分支",onConfirm:_,onCancel:w})]})},aI=T.memo(sI),Pb="var(--color-accent)",Ab=T.memo(({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:s,targetPosition:a}=kr(t),{mode:i,execution:l,isRunning:c,durationText:d}=Wr(t.taskReferenceName),{addForkBranch:u}=te(Ae(g=>({addForkBranch:g.addForkBranch}))),p=J.useUpdateNodeInternals(),f=t.task?.forkTasks?.length||0;T.useEffect(()=>{p(e)},[f,e,p]);const m=t.isDynamic||t.taskType==="FORK_JOIN_DYNAMIC",h=te(g=>g.viewMode),x=T.useMemo(()=>$t.find(g=>g.type==="FORK_JOIN"),[])?.icon||br;return o.jsx(yn,{isHighlighted:t.isHighlighted,nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,executionStatus:l?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{className:`fork-node ${m?"dynamic":"static"}`,style:{borderRadius:"10px",background:"transparent",position:"relative"},children:[o.jsx(Ds,{icon:x,header:zr(m?"FORK_JOIN_DYNAMIC":"FORK_JOIN",h),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:gn(t.taskType,t,h,m?"Dynamic Parallel Execution":"Parallel Execution"),duration:d,color:Pb,status:l?.status,isRunning:c}),i==="edit"&&!m&&o.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:"var(--color-on-accent)",fontSize:"14px",display:"flex",alignItems:"center",justifyContent:"center",cursor:"pointer",zIndex:1e3,boxShadow:"var(--cm-shadow-card)",border:"2px solid var(--bg-primary)"},onClick:g=>{g.stopPropagation(),u(e)},title:"添加分支",children:"+"}),o.jsx(J.Handle,{type:"target",position:a,style:{background:"var(--cm-surface-1)"}}),!m&&(t.task?.forkTasks||[]).map((g,v,k)=>{if(i!=="edit"&&(!g||g.length===0))return null;const b=i!=="edit"?k.filter(w=>w&&w.length>0):k,S=b.length,_=(b.indexOf(g)+1)/(S+1)*100;return o.jsx(J.Handle,{id:`branch_${v}`,type:"source",position:s,style:{background:"var(--cm-surface-1)",[n==="LR"?"top":"left"]:`${_}%`,[n==="LR"?"left":"top"]:void 0,[n==="LR"?"right":"bottom"]:"-4px",zIndex:10}},`branch_${v}`)}),!m&&(!t.task?.forkTasks||t.task.forkTasks.length===0)&&o.jsx(J.Handle,{type:"source",position:s,style:{background:"var(--cm-surface-1)"}}),m&&o.jsx(J.Handle,{type:"source",position:s,style:{background:"var(--cm-surface-1)"}})]})})});Ab.displayName="ForkNode";const $b=T.memo(({id:e,data:t,selected:r})=>{const{layoutDirection:n,sourcePosition:s,targetPosition:a}=kr(t),{execution:i,isRunning:l,durationText:c}=Wr(t.taskReferenceName),d=te(f=>f.viewMode),p=T.useMemo(()=>$t.find(f=>f.type==="JOIN"),[])?.icon||pn;return o.jsx(yn,{isHighlighted:t.isHighlighted,nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,executionStatus:i?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{style:{borderRadius:"10px",background:"transparent",position:"relative"},children:[o.jsx(Ds,{icon:p,header:zr(t.taskType==="EXCLUSIVE_JOIN"?"EXCLUSIVE_JOIN":"JOIN",d),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:gn(t.taskType,t,d,t.taskType==="EXCLUSIVE_JOIN"?"Wait for any task":"Wait for tasks"),duration:c,color:Pb,status:i?.status,isRunning:l}),o.jsx(J.Handle,{type:"target",position:a,style:{background:"var(--cm-surface-1)"}}),n==="TB"&&o.jsxs(o.Fragment,{children:[o.jsx(J.Handle,{type:"target",position:J.Position.Left,id:"left",style:{background:"var(--cm-surface-1)"}}),o.jsx(J.Handle,{type:"target",position:J.Position.Right,id:"right",style:{background:"var(--cm-surface-1)"}})]}),n==="LR"&&o.jsxs(o.Fragment,{children:[o.jsx(J.Handle,{type:"target",position:J.Position.Top,id:"top",style:{background:"var(--cm-surface-1)"}}),o.jsx(J.Handle,{type:"target",position:J.Position.Bottom,id:"bottom",style:{background:"var(--cm-surface-1)"}})]}),o.jsx(J.Handle,{type:"source",position:s,style:{background:"var(--cm-surface-1)"}})]})})});$b.displayName="JoinNode";const Db={ForkNode:Ab,JoinNode:$b},oI=({id:e,data:t,selected:r})=>{const{sourcePosition:n,targetPosition:s}=kr(t),{execution:a,isRunning:i,durationText:l}=Wr(t.taskReferenceName),{executionData:c,selectTaskAction:d,mode:u,viewMode:p,removeNode:f,activeLoopIterations:m,setLoopIteration:h}=te(Ae(R=>({executionData:R.executionData,selectTaskAction:R.selectTaskAction,mode:R.mode,viewMode:R.viewMode,removeNode:R.removeNode,activeLoopIterations:R.activeLoopIterations,setLoopIteration:R.setLoopIteration}))),[y,x]=T.useState(!1),g=t.task,v=g?.loopOver||[],b=T.useMemo(()=>$t.find(R=>R.type==="DO_WHILE"),[])?.icon||Lr,S=T.useMemo(()=>{if(!i||!c)return 0;let R=a?.iteration??0;return v.forEach(O=>{const $=c[O.taskReferenceName];$?.totalIterations?R=Math.max(R,$.totalIterations):$?.attempts.some(B=>(B.iteration??0)>0)&&(R=Math.max(R,$.attempts.length))}),R},[i,c,v,a?.iteration]),j=m[t.taskReferenceName]||S,_=t.loopCondition||g?.loopCondition||"",w=T.useMemo(()=>{const R=_?_.length>35?_.slice(0,35)+"…":_:"循环直到条件满足";return gn("DO_WHILE",t,p,R)},[t,p,_]),I=a?.status==="COMPLETED"?"var(--status-completed)":a?.status==="FAILED"||a?.status==="FAILED_WITH_TERMINAL_ERROR"?"var(--status-failed)":a?.status==="IN_PROGRESS"||a?.status==="SCHEDULED"?"var(--status-in-progress)":"var(--color-accent)",N=r?`2px solid ${I}`:`1.5px dashed ${i&&a?.status?I:"var(--color-accent)"}`,C=u==="edit",M=p==="developer"&&_;return o.jsxs("div",{style:{width:"100%",height:"100%",border:N,borderRadius:"10px",background:"transparent",display:"flex",flexDirection:"column",position:"relative",overflow:"visible",boxSizing:"border-box",pointerEvents:"none"},children:[C&&o.jsx("button",{onClick:R=>{R.stopPropagation(),x(!0)},"aria-label":"删除循环任务",style:{position:"absolute",top:"-10px",right:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"var(--cm-status-failed)",color:"var(--cm-on-danger)",border:"2px solid var(--cm-surface-1)",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:100,boxShadow:"var(--cm-shadow-card)",padding:0,pointerEvents:"auto"},title:"删除循环任务",children:"×"}),t.isError&&o.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"var(--cm-status-failed)",color:"var(--cm-on-danger)",border:"2px solid var(--cm-surface-1)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"var(--cm-shadow-card)",pointerEvents:"auto"},title:"此节点配置有误",children:o.jsx(jt,{size:14,strokeWidth:2,"aria-hidden":"true"})}),!t.isError&&t.hasWarning&&o.jsx("div",{style:{position:"absolute",top:"-10px",left:"-10px",width:"24px",height:"24px",borderRadius:"50%",backgroundColor:"var(--cm-status-warning)",color:"var(--cm-on-danger)",border:"2px solid var(--cm-surface-1)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:"14px",zIndex:101,boxShadow:"var(--cm-shadow-card)",pointerEvents:"auto"},title:"此节点有警告信息",children:o.jsx(Ye,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),t.proposalStatus&&o.jsx("div",{className:`node-proposal-badge node-proposal-badge-${t.proposalStatus}`,style:{pointerEvents:"auto"},children:t.proposalStatus==="added"?"+":t.proposalStatus==="modified"?"~":"−"}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:"var(--glass-surface)",backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",borderBottom:"1px solid var(--border-primary)",borderRadius:"8px 8px 0 0",flexShrink:0,minHeight:"44px",pointerEvents:"auto"},children:[o.jsx("div",{style:{color:"var(--color-accent)",display:"flex",alignItems:"center",flexShrink:0},children:o.jsx(b,{size:15})}),o.jsxs("div",{style:{flex:1,minWidth:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[o.jsx("span",{style:{fontSize:"9px",fontWeight:700,color:"var(--color-accent)",letterSpacing:"0.08em",textTransform:"uppercase"},children:zr("DO_WHILE",p)}),o.jsxs("span",{style:{fontSize:"9px",color:"var(--text-muted)"},children:[o.jsx(Du,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),v.length," 个子任务"]})]}),o.jsx("div",{style:{fontSize:"12px",fontWeight:600,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:t.taskReferenceName}),(p==="business"||p==="developer")&&w&&o.jsx("div",{style:{fontSize:"9px",color:"var(--text-secondary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",marginTop:"1px",fontStyle:"italic"},children:w})]}),i&&l&&o.jsx("span",{style:{fontSize:"10px",fontFamily:"var(--font-mono, monospace)",color:"var(--text-secondary)",background:"var(--bg-secondary)",padding:"1px 6px",borderRadius:"4px",flexShrink:0},children:l}),i&&S>0&&o.jsxs("div",{onClick:()=>d(g||null),style:{padding:"2px 8px",borderRadius:"12px",background:"var(--color-accent)",color:"var(--color-on-accent)",fontSize:"10px",fontWeight:700,cursor:"pointer",flexShrink:0},title:`共执行 ${S} 次迭代`,children:["×",S]}),i&&a?.status&&o.jsx("div",{style:{position:"relative",width:20,height:20,flexShrink:0},children:o.jsx(Bu,{status:a.status})})]}),i&&S>1&&o.jsxs("div",{onClick:R=>R.stopPropagation(),style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 10px",background:"var(--cm-overlay)",borderBottom:"1px solid var(--border-primary)",flexShrink:0,pointerEvents:"auto",overflowX:"auto"},children:[o.jsx("span",{style:{fontSize:"9px",color:"var(--text-muted)",fontWeight:600,marginRight:"2px"},children:"切换轮次:"}),Array.from({length:S},(R,O)=>O+1).map(R=>{const O=j===R;return o.jsxs("button",{type:"button",onClick:$=>{$.stopPropagation(),h(t.taskReferenceName,R)},style:{fontSize:"9px",padding:"1px 7px",borderRadius:"999px",border:O?"1px solid var(--cm-data)":"1px solid var(--border-primary)",background:O?"color-mix(in srgb, var(--cm-data) 22%, transparent)":"var(--bg-tertiary)",color:O?"var(--cm-data)":"var(--text-secondary)",fontWeight:O?700:500,cursor:"pointer"},children:["#",R]},R)})]}),M&&o.jsxs("div",{style:{padding:"3px 12px",fontSize:"9px",color:"var(--text-secondary)",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:0,pointerEvents:"auto"},children:["until: ",_]}),o.jsx("div",{style:{flex:1,position:"relative",background:"var(--loop-body-bg, color-mix(in srgb, var(--cm-ai) 4%, transparent))",borderRadius:"0 0 8px 8px",pointerEvents:"none"}}),o.jsx(J.Handle,{type:"target",position:s,style:{background:"var(--color-accent)",zIndex:10}}),o.jsx(J.Handle,{type:"source",position:n,style:{background:"var(--color-accent)",zIndex:10}}),y&&o.jsx(Dt,{message:uu(te.getState().workflowDef,e).message,confirmLabel:"删除",onConfirm:()=>{f(e),x(!1)},onCancel:()=>x(!1)})]})},iI=T.memo(oI),lI="var(--color-accent)",cI=({id:e,data:t,selected:r})=>{const{sourcePosition:n,targetPosition:s}=kr(t),{execution:a,isRunning:i,durationText:l}=Wr(t.taskReferenceName),c=te(m=>m.viewMode),u=T.useMemo(()=>$t.find(m=>m.type==="SUB_WORKFLOW"),[])?.icon||pn,p=t.task?.subWorkflowParam?.name||t.subWorkflowName||"Unknown",f=t.task?.subWorkflowParam?.version;return o.jsx(yn,{nodeId:e,selected:r,isError:t.isError,hasWarning:t.hasWarning,isHighlighted:t.isHighlighted,executionStatus:a?.status,simRunning:t.simRunning,simDone:t.simDone,proposalStatus:t.proposalStatus,children:o.jsxs("div",{style:{borderRadius:"10px",background:"transparent",position:"relative"},children:[o.jsx(Ds,{icon:u,header:zr("SUB_WORKFLOW",c),title:t.taskReferenceName,subTitle:t.label&&t.label!==t.taskReferenceName?t.label:void 0,meta:gn("SUB_WORKFLOW",t,c,`Flow: ${p}${f!==void 0?` (v${f})`:""}`),duration:l,color:lI,status:a?.status,isRunning:i}),o.jsx(J.Handle,{type:"target",position:s,style:{background:"var(--cm-surface-1)"}}),o.jsx(J.Handle,{type:"source",position:n,style:{background:"var(--cm-surface-1)"}})]})})},dI=T.memo(cI),uI=({data:e})=>{const r=(e.layoutDirection||"TB")==="LR";return o.jsxs("div",{className:"plus-node-container",style:{width:"32px",height:"32px",display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",background:"var(--bg-secondary)",border:"2px dashed var(--color-accent)",color:"var(--color-accent)",cursor:"pointer",transition:"all 0.2s ease",padding:e.label&&e.label!=="+"?"0 12px":"0",minWidth:e.label&&e.label!=="+"?"80px":"32px",gap:"4px"},children:[o.jsx(rr,{size:16}),e.label&&e.label!=="+"&&o.jsx("span",{style:{fontSize:"12px",fontWeight:500},children:e.label}),o.jsx(J.Handle,{type:"target",position:r?J.Position.Left:J.Position.Top,style:{opacity:0}}),o.jsx(J.Handle,{type:"source",position:r?J.Position.Right:J.Position.Bottom,style:{opacity:0},isConnectable:!1}),o.jsx("style",{dangerouslySetInnerHTML:{__html:`
|
|
16
18
|
.plus-node-container:hover {
|
|
17
19
|
transform: scale(1.1);
|
|
18
20
|
background: var(--color-accent);
|
|
19
|
-
color:
|
|
21
|
+
color: var(--color-on-accent);
|
|
20
22
|
border-style: solid;
|
|
21
23
|
box-shadow: 0 0 10px var(--color-accent);
|
|
22
24
|
}
|
|
23
|
-
`}})]})},
|
|
25
|
+
`}})]})},pI=T.memo(uI),fI=({data:e})=>{const{sourcePosition:t,targetPosition:r}=kr(e);return o.jsxs("div",{style:{width:"220px",height:"70px",border:"2px dashed var(--color-accent)",borderRadius:"8px",background:"var(--bg-secondary)",opacity:.75,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"4px",cursor:"default",userSelect:"none"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px"},children:[o.jsx(br,{size:14,style:{color:"var(--color-accent)"}}),o.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--color-accent)"},children:"动态分支"})]}),o.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"运行时生成"}),o.jsx(J.Handle,{type:"target",position:r,style:{background:"var(--color-accent)",width:8,height:8}}),o.jsx(J.Handle,{type:"source",position:t,style:{background:"var(--color-accent)",width:8,height:8}})]})},mI=T.memo(fI),hI=({onSelect:e,onCancel:t})=>{const[r,n]=T.useState("CORE");T.useEffect(()=>{const a=i=>{i.key==="Escape"&&t()};return window.addEventListener("keydown",a),()=>window.removeEventListener("keydown",a)},[t]);const s=$t.filter(a=>a.category===r&&!a.hidden);return o.jsxs("div",{style:{position:"fixed",top:0,left:0,width:"100vw",height:"100vh",backgroundColor:"var(--cm-overlay)",display:"flex",alignItems:"center",justifyContent:"center",zIndex:2e3,backdropFilter:"blur(4px)",animation:"fadeIn 0.2s ease-out"},onClick:t,children:[o.jsxs("div",{className:"glass-panel",style:{backgroundColor:"var(--glass-surface)",borderRadius:"16px",padding:"0",width:"600px",height:"500px",boxShadow:"var(--cm-shadow-float)",border:"1px solid var(--glass-border)",display:"flex",flexDirection:"column",overflow:"hidden"},onClick:a=>a.stopPropagation(),children:[o.jsxs("div",{style:{padding:"20px 24px 0",borderBottom:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)"},children:[o.jsx("h3",{style:{marginTop:0,marginBottom:"16px",color:"var(--text-primary)",fontSize:"18px",fontWeight:"600"},children:"添加任务"}),o.jsx("div",{style:{display:"flex",gap:"24px"},children:GT.map(a=>o.jsx("button",{onClick:()=>n(a.key),style:{background:"none",border:"none",padding:"0 0 12px 0",fontSize:"14px",fontWeight:r===a.key?"600":"500",color:r===a.key?"var(--color-accent)":"var(--text-secondary)",borderBottom:r===a.key?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s"},children:a.label},a.key))})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",padding:"24px",backgroundColor:"var(--bg-primary)"},children:o.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:"12px"},children:s.map(a=>{const i=a.icon;return o.jsxs("button",{onClick:()=>e(a.type),style:{display:"flex",alignItems:"flex-start",gap:"16px",padding:"16px",backgroundColor:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",borderRadius:"12px",cursor:"pointer",textAlign:"left",transition:"all 0.2s",color:"var(--text-primary)",position:"relative",overflow:"hidden"},onMouseEnter:l=>{l.currentTarget.style.borderColor="var(--color-accent)",l.currentTarget.style.backgroundColor="var(--bg-highlight)",l.currentTarget.style.transform="translateY(-2px)",l.currentTarget.style.boxShadow="var(--cm-shadow-card)"},onMouseLeave:l=>{l.currentTarget.style.borderColor="var(--border-primary)",l.currentTarget.style.backgroundColor="var(--bg-tertiary)",l.currentTarget.style.transform="translateY(0)",l.currentTarget.style.boxShadow="none"},children:[o.jsx("div",{style:{padding:"10px",borderRadius:"8px",backgroundColor:"var(--bg-secondary)",color:"var(--color-accent)",display:"flex",alignItems:"center",justifyContent:"center"},children:o.jsx(i,{size:24,strokeWidth:1.5})}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:"600",fontSize:"14px",marginBottom:"4px"},children:a.label}),o.jsx("div",{style:{fontSize:"12px",color:"var(--text-secondary)",lineHeight:"1.4"},children:a.description})]})]},a.type)})})}),o.jsx("div",{style:{padding:"16px 24px",borderTop:"1px solid var(--border-primary)",backgroundColor:"var(--bg-secondary)",display:"flex",justifyContent:"flex-end"},children:o.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:a=>a.currentTarget.style.backgroundColor="var(--bg-tertiary)",onMouseLeave:a=>a.currentTarget.style.backgroundColor="transparent",children:"取消"})})]}),o.jsx("style",{children:`
|
|
24
26
|
@keyframes fadeIn {
|
|
25
27
|
from { opacity: 0; }
|
|
26
28
|
to { opacity: 1; }
|
|
27
29
|
}
|
|
28
|
-
`})]})},
|
|
30
|
+
`})]})},yI=()=>{const{executionData:e,loadSampleExecution:t,importExecutionJSON:r,workflowInstance:n,setSelectedTask:s,nodes:a,runState:i,executionError:l}=te(Ae(v=>({runState:v.runState,executionError:v.executionError,executionData:v.executionData,loadSampleExecution:v.loadSampleExecution,importExecutionJSON:v.importExecutionJSON,workflowInstance:v.workflowInstance,setSelectedTask:v.setSelectedTask,nodes:v.nodes}))),{fitView:c}=J.useReactFlow(),d=v=>{const k=v.target.files?.[0];if(k){const b=new FileReader;b.onload=S=>{try{const j=JSON.parse(S.target?.result);r(j)}catch(j){console.error("Failed to parse execution JSON:",j)}},b.readAsText(k)}},{completedCount:u,failedRefs:p,inProgressCount:f}=T.useMemo(()=>{const v=Object.values(e??{});return{completedCount:v.filter(k=>k.status==="COMPLETED").length,failedRefs:v.filter(k=>He(k.status).isFailure),inProgressCount:v.filter(k=>He(k.status).isActive).length}},[e]),m=p.length,h=T.useCallback(()=>{if(m===0)return;const v=new Set(p.map(b=>b.taskReferenceName)),k=a.filter(b=>v.has(b.data?.taskReferenceName)).map(b=>b.id);k.length>0&&c({nodes:k.map(b=>({id:b})),duration:500,padding:.3})},[p,a,c,m]),y=i==="error"&&l?o.jsxs("div",{className:"status-item",role:"alert",style:{color:"var(--cm-status-failed)",display:"inline-flex",alignItems:"center",gap:4,maxWidth:420},title:l,children:[o.jsx(jt,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),o.jsx("span",{style:{overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:l})]}):null;if(!e)return o.jsxs("div",{className:"execution-status-bar",children:[o.jsx("input",{type:"file",id:"execution-json-upload",accept:".json",onChange:d,style:{display:"none"}}),o.jsx("div",{className:"status-item",children:o.jsx("span",{className:"status-label",children:i==="polling"?"已发起运行,正在获取状态…":"准备就绪"})}),y,o.jsxs("div",{style:{display:"flex",gap:"8px"},children:[o.jsxs("button",{onClick:t,style:{background:"var(--color-accent)",color:"var(--color-on-accent)",border:"none",padding:"6px 14px",borderRadius:"8px",cursor:"pointer",fontSize:"13px",fontWeight:"600",boxShadow:"var(--cm-shadow-card)",transition:"all 0.2s ease"},children:[o.jsx(Ot,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"加载示例运行"]}),o.jsxs("button",{onClick:()=>document.getElementById("execution-json-upload")?.click(),title:"上传 Conductor 运行态 JSON",style:{background:"var(--bg-highlight)",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:[o.jsx(pb,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"导入执行 JSON"]})]})]});const x=He(n?.status??"RUNNING"),g=x.icon;return o.jsxs("div",{className:"execution-status-bar",children:[n&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"status-item",children:[o.jsx("span",{className:"status-label",children:"运行 ID:"}),o.jsx("span",{className:"status-value highlight",style:{color:"var(--text-primary)",opacity:.8},children:n.workflowId})]}),o.jsx("div",{className:"status-divider"})]}),o.jsxs("div",{className:"status-item",children:[o.jsx("span",{className:"status-label",children:"状态:"}),o.jsxs("span",{className:"status-value highlight",style:{color:x.color,display:"inline-flex",alignItems:"center",gap:4},title:n?.status,children:[o.jsx(g,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),x.label]})]}),o.jsx("div",{className:"status-divider"}),o.jsxs("div",{className:"status-item",children:[o.jsx("span",{className:"status-label",children:"已完成:"}),o.jsx("span",{className:"status-value",children:u})]}),o.jsxs("div",{className:"status-item",onClick:m>0?h:void 0,style:{cursor:m>0?"pointer":"default",borderRadius:"4px",padding:"2px 6px",transition:"background 0.2s",...m>0?{background:"color-mix(in srgb, var(--cm-status-failed) 10%, transparent)"}:{}},title:m>0?"点击聚焦失败节点":void 0,children:[o.jsx("span",{className:"status-label",style:{color:"var(--status-failed)"},children:"失败:"}),o.jsx("span",{className:"status-value",style:{color:"var(--status-failed)"},children:m})]}),o.jsxs("div",{className:"status-item",children:[o.jsx("span",{className:"status-label",style:{color:"var(--status-in-progress)"},children:"处理中:"}),o.jsx("span",{className:"status-value",style:{color:"var(--status-in-progress)"},children:f})]}),y,o.jsx("div",{className:"status-divider"}),o.jsx("div",{style:{display:"flex",gap:"8px"},children:o.jsxs("button",{onClick:()=>{s({name:"Workflow Global Data",taskReferenceName:"__workflow_global__",type:"SIMPLE"})},style:{background:"var(--bg-highlight)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",padding:"4px 10px",borderRadius:"6px",cursor:"pointer",fontSize:"11px",fontWeight:"600"},children:[o.jsx(Mu,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"全局 I/O"]})})]})},gI=({isOpen:e,onClose:t,theme:r="dark",onTaskSelect:n})=>{const{validationResults:s,setSelectedTask:a,taskMap:i}=te(Ae(h=>({validationResults:h.validationResults,setSelectedTask:h.setSelectedTask,taskMap:h.taskMap}))),{errors:l,warnings:c}=s||{errors:[],warnings:[]},d=h=>{if(h&&h!=="UNKNOWN"){const y=i[h];y&&(n?n(y):a(y))}},u="var(--glass-surface)",p="var(--text-primary)",f="var(--glass-border)",m="var(--text-secondary)";return e?o.jsxs("div",{style:{position:"absolute",top:"80px",right:"24px",width:"320px",maxHeight:"500px",backgroundColor:u,border:`1px solid ${f}`,borderRadius:"12px",boxShadow:"var(--cm-shadow-float)",zIndex:1100,display:"flex",flexDirection:"column",overflow:"hidden",animation:"fadeInSlide 0.2s ease-out"},children:[o.jsx("style",{children:`
|
|
29
31
|
@keyframes fadeInSlide {
|
|
30
32
|
from { opacity: 0; transform: translateY(-10px); }
|
|
31
33
|
to { opacity: 1; transform: translateY(0); }
|
|
32
34
|
}
|
|
33
35
|
.health-item:hover {
|
|
34
|
-
background-color: ${r==="light"?"
|
|
36
|
+
background-color: ${r==="light"?"var(--text-primary)":"var(--text-muted)"};
|
|
35
37
|
}
|
|
36
|
-
`}),o.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${h}`,display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"rgba(0,0,0,0.02)"},children:[o.jsxs("div",{style:{fontWeight:"bold",fontSize:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[o.jsx("span",{children:"🩺"})," 工作流体检报告"]}),o.jsx("button",{onClick:t,style:{background:"none",border:"none",color:f,cursor:"pointer",fontSize:"18px"},children:"✕"})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:l.length===0&&c.length===0?o.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"#10b981"},children:[o.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:"✅"}),o.jsx("div",{style:{fontWeight:"bold"},children:"未发现问题"}),o.jsx("div",{style:{fontSize:"12px",opacity:.7,marginTop:"4px"},children:"工作流逻辑看起来很完美"})]}):o.jsxs(o.Fragment,{children:[l.map((m,y)=>o.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:[o.jsxs("div",{style:{fontSize:"12px",color:"#ef4444",fontWeight:"bold",marginBottom:"2px"},children:["ERROR ",m.ref!=="UNKNOWN"&&`[${m.ref}]`]}),o.jsx("div",{style:{fontSize:"13px",color:p},children:m.message})]},`err-${y}`)),c.map((m,y)=>o.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:[o.jsxs("div",{style:{fontSize:"12px",color:"#f59e0b",fontWeight:"bold",marginBottom:"2px"},children:["WARNING ",m.ref!=="UNKNOWN"&&`[${m.ref}]`]}),o.jsx("div",{style:{fontSize:"13px",color:p},children:m.message})]},`warn-${y}`))]})}),o.jsxs("div",{style:{padding:"12px 16px",fontSize:"11px",color:f,borderTop:`1px solid ${h}`,backgroundColor:"rgba(0,0,0,0.02)",display:"flex",justifyContent:"space-between"},children:[o.jsxs("span",{children:["共 ",l.length," 个错误, ",c.length," 个警告"]}),l.length>0&&o.jsx("span",{style:{color:"#ef4444"},children:"无法保存/导出"})]})]}):null},U0=({id:e,source:t,target:r,sourceX:n,sourceY:s,targetX:a,targetY:i,sourcePosition:l,targetPosition:c,style:u={},markerEnd:d,data:p})=>{const[h,f]=I.useState(!1),m=I.useRef(null),y=()=>{const _=p?.edgeType||"default",j={sourceX:n,sourceY:s,sourcePosition:l,targetX:a,targetY:i,targetPosition:c};switch(_){case"step":case"smoothstep":return F.getSmoothStepPath(j);case"straight":return F.getStraightPath(j);default:return F.getBezierPath(j)}},[v,g,x]=y(),b=_=>{_.stopPropagation(),_.preventDefault();const j=new CustomEvent("edgeAddNode",{detail:{id:e,source:t,target:r,edgeData:p}});window.dispatchEvent(j)},k=()=>{m.current&&clearTimeout(m.current),f(!0)},S=()=>{m.current=setTimeout(()=>{f(!1)},100)},C=!!(p?.isAddable??p?.mode==="edit"),T=!!p?.label,N=typeof u?.strokeWidth=="number"?u.strokeWidth:2.2,w=typeof u?.opacity=="number"?u.opacity:1;return o.jsxs(o.Fragment,{children:[o.jsx(F.BaseEdge,{path:v,markerEnd:d,style:{...u,strokeWidth:C&&h?N+1.4:N,stroke:C&&h?"var(--color-accent)":u?.stroke,transition:"stroke 0.2s ease, stroke-width 0.2s ease, opacity 0.25s ease",pointerEvents:"none"}}),C&&o.jsx("path",{d:v,fill:"none",stroke:"transparent",strokeWidth:22,style:{cursor:"pointer",pointerEvents:"all"},onMouseEnter:k,onMouseLeave:S}),(T||C&&h)&&o.jsx(F.EdgeLabelRenderer,{children:o.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${g}px,${x}px)`,fontSize:12,pointerEvents:C?"all":"none",zIndex:h?2e3:10,display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",opacity:h?1:w,transition:"opacity 0.2s ease"},className:"nodrag nopan",onMouseEnter:C?k:void 0,onMouseLeave:C?S:void 0,children:[T&&o.jsx("div",{style:{background:"var(--glass-bg-accent)",backdropFilter:"var(--glass-blur)",WebkitBackdropFilter:"var(--glass-blur)",color:"var(--text-primary)",padding:"2px 8px",borderRadius:"999px",fontSize:"11px",fontWeight:600,border:`1px solid ${h?"var(--color-accent)":"var(--border-secondary)"}`,boxShadow:"0 2px 8px rgba(0, 0, 0, 0.22)",whiteSpace:"nowrap",letterSpacing:"0.3px",lineHeight:1.4},children:p.label}),C&&h&&o.jsx("button",{style:{width:"28px",height:"28px",backgroundColor:"var(--color-accent)",color:"#fff",border:"2px solid rgba(255,255,255,0.85)",borderRadius:"50%",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:"18px",lineHeight:1,boxShadow:"0 4px 14px rgba(var(--color-accent-rgb), 0.5)",transition:"all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275)",padding:0},className:"edge-add-button",onClick:b,onMouseDown:_=>_.stopPropagation(),title:"在此处添加任务",children:"+"})]})})]})},Le=({onClick:e,icon:t,label:r,title:n,disabled:s=!1,active:a=!1,variant:i="default",style:l})=>{let c="var(--bg-tertiary)",u="var(--text-primary)",d="1px solid var(--border-primary)";return i==="primary"?(c="var(--color-accent)",u="#fff",d="none"):i==="danger"?(c=s?"rgba(239, 68, 68, 0.1)":"var(--status-failed)",u=s?"var(--text-secondary)":"#fff",d="none"):a&&(c="var(--bg-secondary)",u="var(--color-accent)",d="1px solid var(--color-accent)"),o.jsxs("button",{onClick:e,disabled:s,title:n,"aria-label":n||r,"aria-pressed":a,"aria-disabled":s,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:r?"6px":"0",background:c,color:u,border:d,borderRadius:"7px",padding:r?"4px 10px":"6px",cursor:s?"not-allowed":"pointer",opacity:s?.45:1,fontSize:"12px",fontWeight:500,transition:"all 0.18s",minWidth:r?"auto":"30px",height:"30px",whiteSpace:"nowrap",boxShadow:i==="default"?"0 1px 2px rgba(0,0,0,0.05)":"none",...l},children:[t&&o.jsx("span",{style:{fontSize:"13px",display:"flex",alignItems:"center"},children:t}),r&&o.jsx("span",{children:r})]})},J0=()=>{const{zoomIn:e,zoomOut:t,fitView:r}=F.useReactFlow();return o.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px"},children:o.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:[o.jsx(Le,{icon:"➕",title:"放大",onClick:()=>e()}),o.jsx(Le,{icon:"➖",title:"缩小",onClick:()=>t()}),o.jsx(Le,{icon:"⤢",title:"适应屏幕",onClick:()=>r({duration:600})})]})})},ey={enabled:!1,status:"COMPLETED",durationMs:"",forceCase:"",reasonForIncompletion:"",outputJsonText:""},V0=({isOpen:e,onClose:t})=>{const{workflowDef:r,theme:n,themeColor:s,runLocalSandboxDryRun:a}=oe(ke(M=>({workflowDef:M.workflowDef,theme:M.theme,themeColor:M.themeColor,runLocalSandboxDryRun:M.runLocalSandboxDryRun}))),i=n==="light",[l,c]=I.useState("input"),[u,d]=I.useState(""),[p,h]=I.useState(null),[f,m]=I.useState({}),[y,v]=I.useState(""),[g,x]=I.useState(null),[b,k]=I.useState(2),S=I.useMemo(()=>r?.tasks?yt(r.tasks):[],[r]),C=I.useMemo(()=>`sandbox_mock_cfg_${r?.name||"default"}`,[r?.name]);I.useEffect(()=>{if(!e||!r)return;const M=Kt(r);let O=!1;try{const W=sessionStorage.getItem(C);if(W){const U=JSON.parse(W);U.inputJsonText?d(U.inputJsonText):d(JSON.stringify(M,null,2)),U.taskDrafts&&typeof U.taskDrafts=="object"&&m(U.taskDrafts),typeof U.maxLoopIterations=="number"&&k(U.maxLoopIterations),O=!0}}catch{}O||(d(JSON.stringify(M,null,2)),m({}),k(2)),h(null),x(null),S.length>0&&!y&&v(S[0].taskReferenceName)},[e,r,C]),I.useEffect(()=>{S.length>0&&!S.some(M=>M.taskReferenceName===y)&&v(S[0].taskReferenceName)},[S,y]);const T=I.useMemo(()=>{const M=[];for(const O of S)if(O.type==="SWITCH"||O.type==="DECISION"){const W=Object.keys(O.decisionCases||{});if(W.length===0)continue;const U=O.caseValueParam||"case_value",H=String(O.inputParameters?.[U]??O.expression??"").match(/\$\{\s*workflow\.input\.([a-zA-Z0-9_]+)\s*\}/);M.push({switchRef:O.taskReferenceName,switchName:O.name||O.taskReferenceName,inputField:H?H[1]:null,cases:W})}return M},[S]);if(!e||!r||typeof document>"u")return null;const N=S.find(M=>M.taskReferenceName===y)||S[0]||null,w=N&&f[N.taskReferenceName]||ey,_=M=>{if(!N)return;const O=N.taskReferenceName,U={...f[O]||{...ey,outputJsonText:JSON.stringify($r(N),null,2)},...M,enabled:M.enabled!==void 0?M.enabled:!0};m($=>({...$,[O]:U})),x(null)},j=Object.values(f).filter(M=>M.enabled).length,P=(M,O)=>{try{const W=JSON.parse(u||"{}");W[M]=O,d(JSON.stringify(W,null,2)),h(null)}catch{h("请先修复当前 JSON 语法错误后再点击快捷赋值")}},E=()=>{let M={};try{if(M=u.trim()?JSON.parse(u):{},typeof M!="object"||Array.isArray(M)||M===null){h("workflow.input 必须是一个 JSON 对象 {...}"),c("input");return}}catch(W){h(`JSON 语法错误: ${W?.message||"格式不合法"}`),c("input");return}const O={};for(const[W,U]of Object.entries(f)){if(!U.enabled)continue;let $;if(U.outputJsonText.trim())try{$=JSON.parse(U.outputJsonText)}catch(K){v(W),c("tasks"),x(`节点 [${W}] 的自定义输出 JSON 语法有误: ${K?.message||""}`);return}const H=U.durationMs.trim()!==""&&!Number.isNaN(Number(U.durationMs))?Number(U.durationMs):void 0;O[W]={__isMockOverride:!0,status:U.status,durationMs:H,forceCase:U.forceCase||void 0,reasonForIncompletion:U.reasonForIncompletion.trim()||void 0,outputData:$}}try{sessionStorage.setItem(C,JSON.stringify({inputJsonText:u,taskDrafts:f,maxLoopIterations:b}))}catch{}a(M,O,b),t()},A=i?"#ffffff":"#0f172a",L=i?"#f8fafc":"#1e293b",B=i?"#f1f5f9":"#020617",z=i?"#0f172a":"#f8fafc",R=i?"#64748b":"#94a3b8",q=i?"rgba(148, 163, 184, 0.3)":"rgba(148, 163, 184, 0.18)";return Ge.createPortal(o.jsx("div",{"data-mode":n,"data-brand":s,style:{position:"fixed",inset:0,zIndex:9500,background:"rgba(2, 6, 23, 0.65)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:20},onClick:t,children:o.jsxs("div",{style:{width:"min(920px, 96vw)",height:"min(660px, 90vh)",background:A,color:z,borderRadius:14,border:`1px solid ${q}`,boxShadow:"0 24px 64px rgba(0, 0, 0, 0.5)",display:"flex",flexDirection:"column",overflow:"hidden"},onClick:M=>M.stopPropagation(),children:[o.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${q}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:L},children:[o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:15,fontWeight:700},children:[o.jsx("span",{children:"🧪 本地沙箱试运行 · 人工模拟数据控制台"}),o.jsx("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:999,background:"rgba(16, 185, 129, 0.14)",color:"#10b981",fontWeight:600},children:"0ms 确定性求值"})]}),o.jsxs("div",{style:{fontSize:12,color:R,marginTop:4},children:["自定义工作流启动入参 (",o.jsx("code",{children:"workflow.input"}),")、指定任意节点的 Mock 输出、模拟节点异常中断或强制切换 ",o.jsx("code",{children:"SWITCH"})," 分支走向"]})]}),o.jsx("button",{type:"button",onClick:t,style:{background:"none",border:"none",color:R,fontSize:18,cursor:"pointer",padding:"4px 8px"},children:"✕"})]}),o.jsx("div",{style:{display:"flex",gap:8,padding:"10px 20px",borderBottom:`1px solid ${q}`,background:A},children:[{id:"input",label:"📥 1. 工作流启动入参 (workflow.input)"},{id:"tasks",label:`🎯 2. 节点级人工 Mock & 故障注入 ${j>0?`(${j} 个已启用)`:""}`},{id:"engine",label:`⚙️ 3. 循环轮次与引擎参数 (${b} 轮)`}].map(M=>{const O=l===M.id;return o.jsx("button",{type:"button",onClick:()=>c(M.id),style:{padding:"7px 14px",borderRadius:8,border:O?"1px solid #3b82f6":`1px solid ${q}`,background:O?"rgba(59, 130, 246, 0.14)":"transparent",color:O?"#3b82f6":R,fontSize:12,fontWeight:O?700:500,cursor:"pointer"},children:M.label},M.id)})}),o.jsxs("div",{style:{flex:1,minHeight:0,display:"flex",overflow:"hidden"},children:[l==="input"&&o.jsxs("div",{style:{flex:1,padding:20,display:"flex",flexDirection:"column",gap:12,overflowY:"auto"},children:[T.length>0&&o.jsxs("div",{style:{padding:"10px 14px",borderRadius:10,background:"rgba(59, 130, 246, 0.08)",border:"1px solid rgba(59, 130, 246, 0.25)",display:"flex",flexDirection:"column",gap:8},children:[o.jsx("div",{style:{fontSize:12,fontWeight:700,color:"#38bdf8"},children:"🧭 条件分支 (SWITCH) 快速路由切换器"}),T.map(M=>o.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,fontSize:12},children:[o.jsxs("span",{style:{color:R},children:["节点 ",o.jsx("b",{children:M.switchName})," (",o.jsx("code",{children:M.switchRef}),")",M.inputField?` 绑定入参字段 "${M.inputField}" — 点击一键切换分支:`:" 可选分支 (可在 Tab 2 强制指定):"]}),M.cases.map(O=>o.jsx("button",{type:"button",onClick:()=>{M.inputField?P(M.inputField,O):(v(M.switchRef),c("tasks"))},style:{padding:"2px 9px",borderRadius:999,border:"1px solid rgba(56, 189, 248, 0.45)",background:"rgba(56, 189, 248, 0.14)",color:"#38bdf8",fontSize:11,fontFamily:"monospace",fontWeight:600,cursor:"pointer"},children:M.inputField?`${M.inputField} = "${O}"`:`走分支: ${O}`},O))]},M.switchRef))]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("span",{style:{fontSize:12,fontWeight:600,color:R},children:["编辑 ",o.jsx("code",{children:"workflow.input"})," JSON(所有节点的 ",o.jsx("code",{children:"${workflow.input.*}"})," 将实时读取此处的值):"]}),o.jsx("button",{type:"button",onClick:()=>{const M=Kt(r);d(JSON.stringify(M,null,2)),h(null)},style:{fontSize:11,padding:"4px 10px",borderRadius:6,border:`1px solid ${q}`,background:L,color:R,cursor:"pointer"},children:"↺ 重置为默认推导值"})]}),p&&o.jsxs("div",{style:{padding:"8px 12px",borderRadius:8,background:"rgba(239, 68, 68, 0.14)",border:"1px solid rgba(239, 68, 68, 0.4)",color:"#f87171",fontSize:12},children:["⚠️ ",p]}),o.jsx("textarea",{value:u,onChange:M=>{d(M.target.value),h(null)},spellCheck:!1,style:{flex:1,minHeight:240,width:"100%",boxSizing:"border-box",padding:14,borderRadius:10,border:`1px solid ${p?"#ef4444":q}`,background:B,color:z,fontFamily:"monospace",fontSize:13,lineHeight:1.55,resize:"none",outline:"none"}})]}),l==="tasks"&&o.jsxs("div",{style:{flex:1,display:"grid",gridTemplateColumns:"260px 1fr",minHeight:0},children:[o.jsxs("div",{style:{borderRight:`1px solid ${q}`,overflowY:"auto",padding:"10px 8px",background:L,display:"flex",flexDirection:"column",gap:4},children:[o.jsxs("div",{style:{fontSize:11,fontWeight:700,color:R,padding:"4px 8px 8px",textTransform:"uppercase"},children:["选择要定制 Mock 的节点 (",S.length,")"]}),S.map(M=>{const O=M.taskReferenceName,W=N?.taskReferenceName===O,U=f[O],$=!!U?.enabled;return o.jsxs("div",{onClick:()=>{v(O),x(null)},style:{padding:"8px 10px",borderRadius:8,cursor:"pointer",background:W?"rgba(59, 130, 246, 0.16)":"transparent",border:W?"1px solid rgba(59, 130, 246, 0.45)":"1px solid transparent",display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[o.jsxs("div",{style:{minWidth:0},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:M.name||O}),o.jsxs("div",{style:{fontSize:10,color:R,fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[O," · ",M.type]})]}),$&&o.jsx("span",{style:{fontSize:10,padding:"2px 6px",borderRadius:999,background:U.status==="FAILED"||U.status==="TIMED_OUT"?"rgba(239, 68, 68, 0.2)":"rgba(16, 185, 129, 0.2)",color:U.status==="FAILED"||U.status==="TIMED_OUT"?"#f87171":"#34d399",fontWeight:700,flexShrink:0},children:U.status==="COMPLETED"?"已定制":U.status})]},O)})]}),N?o.jsxs("div",{style:{padding:18,overflowY:"auto",display:"flex",flexDirection:"column",gap:14},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:10,borderBottom:`1px solid ${q}`},children:[o.jsxs("div",{children:[o.jsxs("div",{style:{fontSize:14,fontWeight:700},children:[N.name||N.taskReferenceName," ",o.jsxs("code",{style:{fontSize:12,color:"#38bdf8",fontWeight:500},children:["(",N.taskReferenceName,")"]})]}),o.jsxs("div",{style:{fontSize:11,color:R,marginTop:2},children:["节点类型: ",o.jsx("b",{children:N.type})]})]}),o.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,fontWeight:700,cursor:"pointer",padding:"6px 12px",borderRadius:8,background:w.enabled?"rgba(16, 185, 129, 0.14)":L,border:`1px solid ${w.enabled?"#10b981":q}`,color:w.enabled?"#10b981":R},children:[o.jsx("input",{type:"checkbox",checked:w.enabled,onChange:M=>_({enabled:M.target.checked})}),"启用该节点人工 Mock"]})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 200px",gap:12},children:[o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:R,marginBottom:6},children:"模拟执行状态 (可注入异常以测试断路与错误诊断)"}),o.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[{id:"COMPLETED",label:"✅ 正常成功"},{id:"FAILED",label:"❌ 失败中断 (FAILED)"},{id:"TIMED_OUT",label:"⏱️ 超时中断 (TIMED_OUT)"},{id:"COMPLETED_WITH_ERRORS",label:"⚠️ 带错完成"}].map(M=>{const O=w.status===M.id;return o.jsx("button",{type:"button",onClick:()=>_({status:M.id}),style:{padding:"5px 10px",borderRadius:6,fontSize:11,fontWeight:O?700:500,cursor:"pointer",border:O?"1px solid #38bdf8":`1px solid ${q}`,background:O?"rgba(56, 189, 248, 0.16)":L,color:O?"#38bdf8":z},children:M.label},M.id)})})]}),o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:R,marginBottom:6},children:"模拟耗时 (ms,可制造并发瓶颈)"}),o.jsx("input",{type:"number",min:0,placeholder:"默认自动耗时 (如 120)",value:w.durationMs,onChange:M=>_({durationMs:M.target.value}),style:{width:"100%",boxSizing:"border-box",padding:"6px 10px",borderRadius:6,border:`1px solid ${q}`,background:B,color:z,fontSize:12}})]})]}),(w.status==="FAILED"||w.status==="TIMED_OUT")&&o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:"#f87171",marginBottom:6},children:"模拟异常原因 (reasonForIncompletion)"}),o.jsx("input",{type:"text",placeholder:"例如: Connection refused to upstream payment gateway (502)",value:w.reasonForIncompletion,onChange:M=>_({reasonForIncompletion:M.target.value}),style:{width:"100%",boxSizing:"border-box",padding:"7px 10px",borderRadius:6,border:"1px solid rgba(239, 68, 68, 0.45)",background:B,color:z,fontSize:12}})]}),(N.type==="SWITCH"||N.type==="DECISION")&&o.jsxs("div",{style:{padding:"10px 12px",borderRadius:8,background:"rgba(245, 158, 11, 0.1)",border:"1px solid rgba(245, 158, 11, 0.35)"},children:[o.jsx("label",{style:{display:"block",fontSize:11,fontWeight:700,color:"#fbbf24",marginBottom:6},children:"🔀 强制指定 SWITCH 路由分支 (无视入参表达式直接走指定分支)"}),o.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[o.jsx("button",{type:"button",onClick:()=>_({forceCase:""}),style:{padding:"4px 10px",borderRadius:6,fontSize:11,cursor:"pointer",border:w.forceCase?`1px solid ${q}`:"1px solid #fbbf24",background:w.forceCase?L:"rgba(245, 158, 11, 0.2)",color:w.forceCase?R:"#fbbf24",fontWeight:w.forceCase?500:700},children:"🔄 根据入参自动求值"}),Object.keys(N.decisionCases||{}).map(M=>{const O=w.forceCase===M;return o.jsxs("button",{type:"button",onClick:()=>_({forceCase:M}),style:{padding:"4px 10px",borderRadius:6,fontSize:11,fontFamily:"monospace",cursor:"pointer",border:O?"1px solid #fbbf24":`1px solid ${q}`,background:O?"rgba(245, 158, 11, 0.22)":L,color:O?"#fbbf24":z,fontWeight:O?700:500},children:["分支: ",M]},M)}),N.defaultCase&&o.jsx("button",{type:"button",onClick:()=>_({forceCase:"__default__"}),style:{padding:"4px 10px",borderRadius:6,fontSize:11,fontFamily:"monospace",cursor:"pointer",border:w.forceCase==="__default__"?"1px solid #fbbf24":`1px solid ${q}`,background:w.forceCase==="__default__"?"rgba(245, 158, 11, 0.22)":L,color:w.forceCase==="__default__"?"#fbbf24":z},children:"默认分支 (defaultCase)"})]})]}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("label",{style:{fontSize:11,fontWeight:600,color:R},children:["自定义节点输出数据 (",o.jsx("code",{children:`\${${N.taskReferenceName}.output.*}`})," 将读取此 JSON):"]}),o.jsx("button",{type:"button",onClick:()=>{const M=$r(N);_({outputJsonText:JSON.stringify(M,null,2)})},style:{fontSize:11,padding:"3px 9px",borderRadius:6,border:`1px solid ${q}`,background:L,color:"#38bdf8",cursor:"pointer",fontWeight:600},children:"📋 填入默认合成输出模板"})]}),g&&o.jsxs("div",{style:{padding:"6px 10px",borderRadius:6,background:"rgba(239, 68, 68, 0.14)",border:"1px solid rgba(239, 68, 68, 0.4)",color:"#f87171",fontSize:11},children:["⚠️ ",g]}),o.jsx("textarea",{value:w.outputJsonText,placeholder:`留空则自动按 ${N.type} 类型合成输出,或点击右上角「填入默认合成输出模板」进行修改...`,onChange:M=>_({outputJsonText:M.target.value}),spellCheck:!1,style:{flex:1,minHeight:160,width:"100%",boxSizing:"border-box",padding:12,borderRadius:8,border:`1px solid ${g?"#ef4444":q}`,background:B,color:z,fontFamily:"monospace",fontSize:12,lineHeight:1.5,resize:"vertical",outline:"none"}})]})]}):o.jsx("div",{style:{padding:32,color:R},children:"当前工作流暂无任务节点"})]}),l==="engine"&&o.jsx("div",{style:{flex:1,padding:24,display:"flex",flexDirection:"column",gap:18},children:o.jsxs("div",{style:{padding:16,borderRadius:10,border:`1px solid ${q}`,background:L,display:"flex",flexDirection:"column",gap:10},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{children:[o.jsx("div",{style:{fontSize:13,fontWeight:700},children:"🔄 DO_WHILE 循环容器最大模拟迭代轮次"}),o.jsxs("div",{style:{fontSize:12,color:R,marginTop:2},children:["控制沙箱遇到 ",o.jsx("code",{children:"DO_WHILE"})," 节点时自动展开执行的循环轮次数(可在画布循环容器头部切换查看每一轮的子任务状态)"]})]}),o.jsxs("span",{style:{fontSize:16,fontWeight:800,color:"#38bdf8",fontFamily:"monospace"},children:[b," 轮"]})]}),o.jsx("input",{type:"range",min:1,max:8,value:b,onChange:M=>k(Number(M.target.value)),style:{width:"100%",accentColor:"#38bdf8",cursor:"pointer"}}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:11,color:R},children:[o.jsx("span",{children:"1 轮 (单次验证)"}),o.jsx("span",{children:"2 轮 (默认推荐)"}),o.jsx("span",{children:"5 轮"}),o.jsx("span",{children:"8 轮 (压测多轮轨迹)"})]})]})})]}),o.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${q}`,background:L,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsx("button",{type:"button",onClick:()=>{m({});const M=Kt(r);d(JSON.stringify(M,null,2)),k(2),sessionStorage.removeItem(C)},style:{padding:"7px 12px",borderRadius:8,border:`1px solid ${q}`,background:"transparent",color:R,fontSize:12,cursor:"pointer"},children:"🧹 清空全部人工 Mock 配置"}),o.jsxs("div",{style:{display:"flex",gap:10},children:[o.jsx("button",{type:"button",onClick:t,style:{padding:"8px 16px",borderRadius:8,border:`1px solid ${q}`,background:"transparent",color:z,fontSize:12,fontWeight:600,cursor:"pointer"},children:"取消"}),o.jsx("button",{type:"button",onClick:E,style:{padding:"8px 20px",borderRadius:8,border:"none",background:"linear-gradient(135deg, #2563eb, #0284c7)",color:"#ffffff",fontSize:12,fontWeight:700,cursor:"pointer",boxShadow:"0 4px 14px rgba(37, 99, 235, 0.35)"},children:"⚡ 应用模拟数据并启动沙箱试运行"})]})]})]})}),document.body)},dc=()=>o.jsx("div",{style:{width:"1px",height:"18px",background:"var(--border-primary)",margin:"0 2px",alignSelf:"center",flexShrink:0}}),K0=({onShowHealthCheck:e,showHealthCheck:t,onShowSettings:r,executionActions:n})=>{const{mode:s,setMode:a,validationResults:i,workflowInstance:l,workflowDef:c,showDataLineage:u,setShowDataLineage:d,showWaterfallPanel:p,setShowWaterfallPanel:h,runLocalSandboxDryRun:f,inlineCopilotTaskRef:m,setInlineCopilotTaskRef:y,selectedTask:v}=oe(ke(M=>({mode:M.mode,setMode:M.setMode,validationResults:M.validationResults,workflowInstance:M.workflowInstance,workflowDef:M.workflowDef,showDataLineage:M.showDataLineage,setShowDataLineage:M.setShowDataLineage,showWaterfallPanel:M.showWaterfallPanel,setShowWaterfallPanel:M.setShowWaterfallPanel,runLocalSandboxDryRun:M.runLocalSandboxDryRun,inlineCopilotTaskRef:M.inlineCopilotTaskRef,setInlineCopilotTaskRef:M.setInlineCopilotTaskRef,selectedTask:M.selectedTask}))),g=oe.temporal,{undo:x,redo:b,pastStates:k,futureStates:S}=pn(g,M=>M),[C,T]=I.useState(!1),[N,w]=I.useState(!1),_=I.useRef(null);I.useEffect(()=>{if(!C)return;const M=O=>{_.current&&!_.current.contains(O.target)&&T(!1)};return document.addEventListener("mousedown",M),()=>document.removeEventListener("mousedown",M)},[C]);const j=(i?.errors?.length||0)>0,P=l?.status,E=l?.workflowId??"",A=P==="RUNNING",L=P==="PAUSED",B=P==="FAILED"||P==="TIMED_OUT"||P==="TERMINATED",z=P==="COMPLETED",R=c?.restartable===!0&&(B||z),q=n?.allowOperations!==!1;return o.jsxs("div",{className:"action-bar",style:{display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap",padding:"5px 8px",borderRadius:"10px",background:"var(--bg-secondary)",backdropFilter:"blur(14px)",border:"1px solid var(--border-primary)",boxShadow:"0 6px 24px rgba(0, 0, 0, 0.18)"},children:[c&&o.jsxs(o.Fragment,{children:[o.jsx(Le,{icon:"🔗",label:"数据血缘",title:"W-LSP 数据流血缘图谱 (Data Flow Graph)",onClick:()=>d(!u),active:u}),s==="edit"&&o.jsx(Le,{icon:"⌘K",label:"AI微调",title:"画布内联 AI 指令栏 (Cmd+K)",onClick:()=>y(m?null:v?.taskReferenceName||"__canvas_root__"),active:!!m})]}),s==="edit"&&o.jsxs(o.Fragment,{children:[o.jsx(dc,{}),o.jsxs("div",{style:{display:"inline-flex",gap:"3px",alignItems:"center"},children:[o.jsx(Le,{icon:"↺",title:"撤销 (Cmd+Z)",onClick:()=>x(),disabled:k.length===0}),o.jsx(Le,{icon:"↻",title:"重做 (Cmd+Shift+Z)",onClick:()=>b(),disabled:S.length===0})]}),o.jsx(Le,{icon:"🩺",label:j?`错误 (${i.errors.length})`:"诊断",title:"流程健康检查",onClick:e,active:t,variant:j?"danger":"secondary"}),o.jsx(Le,{icon:"⚙️",label:"配置",title:"工作流全局配置",onClick:()=>r?.()})]}),c&&s!=="run"&&o.jsxs(o.Fragment,{children:[o.jsx(dc,{}),o.jsxs("div",{style:{display:"inline-flex",alignItems:"center"},children:[o.jsx(Le,{icon:"⚡",label:"沙箱试运行",title:"一键启动浏览器本地确定性沙箱试运行 (0ms Dry-Run)",onClick:()=>f(),variant:"primary",style:{borderRadius:"7px 0 0 7px",borderRight:"1px solid rgba(255, 255, 255, 0.25)"}}),o.jsx(Le,{icon:"🧪",title:"人工模拟数据配置台 (自定义 workflow.input / 节点 Mock 输出 / 故障注入 / 分支路由)",onClick:()=>w(!0),variant:"primary",style:{borderRadius:"0 7px 7px 0",padding:"4px 7px",minWidth:"26px"}})]})]}),s==="run"&&o.jsxs(o.Fragment,{children:[o.jsx(dc,{}),o.jsx(Le,{icon:"🧪",label:"模拟数据重跑",title:"打开沙箱人工模拟数据配置台,调整入参、分支或注入节点故障后重跑",onClick:()=>w(!0)}),o.jsx(Le,{icon:"📊",label:"瀑布流回放",title:"并发甘特瀑布流与时间旅行调试器 (Time-Travel)",onClick:()=>h(!p),active:p}),o.jsx(Le,{icon:"✏️",label:"返回编辑",title:"退出试跑/运行态视图,返回工作流编排画布",onClick:()=>a("edit")})]}),o.jsx(V0,{isOpen:N,onClose:()=>w(!1)}),s==="run"&&l&&n&&o.jsxs(o.Fragment,{children:[L&&n.onResume&&o.jsx(Le,{icon:o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4 3l9 5-9 5z"})}),label:"继续",title:q?"继续执行工作流":"操作权限受限",onClick:()=>q&&n.onResume(E),disabled:!q,variant:"primary"}),A&&n.onPause&&o.jsx(Le,{icon:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:[o.jsx("rect",{x:"4",y:"3",width:"3",height:"10",rx:"1"}),o.jsx("rect",{x:"9",y:"3",width:"3",height:"10",rx:"1"})]}),label:"暂停",title:q?"暂停工作流执行":"操作权限受限",onClick:()=>q&&n.onPause(E),disabled:!q}),(A||L)&&n.onTerminate&&o.jsx(Le,{icon:o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("rect",{x:"3",y:"3",width:"10",height:"10",rx:"1"})}),label:"终止",title:q?"终止工作流执行":"操作权限受限",onClick:()=>q&&n.onTerminate(E),disabled:!q,variant:"danger"}),B&&n.onRetry&&o.jsx(Le,{icon:o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("path",{d:"M13 2v4h-4"}),o.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),label:"重试",title:q?"重试失败的工作流":"操作权限受限",onClick:()=>q&&n.onRetry(E),disabled:!q,variant:"primary"}),R&&n.onRestart&&o.jsxs("div",{ref:_,style:{position:"relative",display:"flex"},children:[o.jsxs("button",{disabled:!q,onClick:()=>q&&n.onRestart(E,{useLatestDef:!0}),title:q?"使用当前最新定义版本重新运行":"操作权限受限",style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--bg-tertiary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRight:"none",borderRadius:"6px 0 0 6px",padding:"6px 10px",cursor:q?"pointer":"not-allowed",opacity:q?1:.5,fontSize:"13px",fontWeight:500,height:"32px"},children:[o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("path",{d:"M3 14v-4h4"}),o.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"重启"]}),o.jsx("button",{disabled:!q,onClick:()=>q&&T(M=>!M),title:q?"展开重启版本选项":"操作权限受限",style:{display:"flex",alignItems:"center",justifyContent:"center",background:q&&C?"var(--bg-secondary)":"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border-primary)",borderRadius:"0 6px 6px 0",padding:"6px 6px",cursor:q?"pointer":"not-allowed",opacity:q?1:.5,height:"32px",width:"22px",fontSize:"10px"},children:o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",children:o.jsx("path",{d:"M1 3l4 4 4-4",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",fill:"none"})})}),C&&o.jsxs("div",{style:{position:"absolute",top:"36px",right:0,background:"var(--glass-surface)",backdropFilter:"blur(12px)",border:"1px solid var(--glass-border)",borderRadius:"10px",boxShadow:"0 8px 24px rgba(0,0,0,0.25)",zIndex:2e3,minWidth:"180px",overflow:"hidden"},children:[o.jsx("div",{style:{padding:"6px 12px 4px",fontSize:"11px",color:"var(--text-secondary)",fontWeight:600,letterSpacing:"0.5px",textTransform:"uppercase"},children:"选择版本"}),o.jsxs("button",{onClick:()=>{n.onRestart(E,{useLatestDef:!0}),T(!1)},style:ty,onMouseEnter:M=>M.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:M=>M.currentTarget.style.background="transparent",children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("circle",{cx:"8",cy:"8",r:"6"}),o.jsx("path",{d:"M8 5v3l2 1"})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"当前版本"}),o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用最新工作流定义"})]})]}),o.jsxs("button",{onClick:()=>{n.onRestart(E,{useLatestDef:!1}),T(!1)},style:ty,onMouseEnter:M=>M.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:M=>M.currentTarget.style.background="transparent",children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("rect",{x:"3",y:"2",width:"10",height:"12",rx:"1"}),o.jsx("path",{d:"M6 6h4M6 9h3"})]}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"执行版本"}),o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用本次运行时的定义"})]})]})]})]})]})]})},ty={display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"8px 12px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",transition:"background 0.15s"},G0=[{id:"basic",label:"基本信息"},{id:"timeout",label:"超时与容错"},{id:"params",label:"参数配置"},{id:"advanced",label:"高级设置"}],Y0=({isOpen:e,onClose:t})=>{const{workflowDef:r,updateWorkflowProperties:n,mode:s}=oe(ke(E=>({workflowDef:E.workflowDef,updateWorkflowProperties:E.updateWorkflowProperties,mode:E.mode}))),[a,i]=I.useState(r),[l,c]=I.useState("basic"),u=s!=="edit";I.useEffect(()=>{r&&i(r)},[r,e]);const d=I.useCallback(E=>{E.key==="Escape"&&t()},[t]);if(I.useEffect(()=>{if(e)return document.addEventListener("keydown",d),()=>document.removeEventListener("keydown",d)},[e,d]),!e||!a)return null;const p="var(--text-primary)",h="var(--glass-border)",f="var(--bg-tertiary)",m="var(--text-secondary)",y=(E,A)=>{if(!a||u)return;const L={...a,[E]:A};i(L),n({[E]:A})},v=(E,A,L)=>{if(!a||u)return;const z={...a[E]||{},[A]:L};i(R=>({...R,[E]:z})),n({[E]:z})},g=(E,A)=>{if(!(!a||u))try{const L=JSON.parse(A),B={...a,[E]:L};i(B),n({[E]:L})}catch{i(L=>({...L,[`_${E}_str`]:A}))}},x={width:"100%",padding:"10px 14px",borderRadius:"8px",border:`1px solid ${h}`,background:f,color:p,fontSize:"14px",outline:"none",boxSizing:"border-box"},b={display:"block",fontSize:"11px",color:m,marginBottom:"8px",fontWeight:600},k=(E,A,L="text",B)=>o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsx("label",{style:b,children:E.toUpperCase()}),o.jsx("input",{className:"wsp-input",type:L,value:a?.[A]??"",onChange:z=>y(A,L==="number"?z.target.value===""?0:parseInt(z.target.value):z.target.value),disabled:u||B?.readOnly,placeholder:B?.placeholder,style:{...x,opacity:u||B?.readOnly?.6:1}})]}),S=(E,A,L=!1,B=6)=>{const z=a?.[`_${A}_str`]!==void 0?a[`_${A}_str`]:typeof a?.[A]=="object"?JSON.stringify(a[A],null,2):a?.[A];return o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsxs("label",{style:b,children:[E.toUpperCase()," ",L&&"(JSON)"]}),o.jsx("textarea",{className:"wsp-input",value:z||"",onChange:R=>L?g(A,R.target.value):y(A,R.target.value),rows:B,disabled:u,style:{...x,fontSize:"13px",fontFamily:L?"var(--font-mono)":"inherit",resize:"vertical",opacity:u?.6:1}})]})},C=(E,A,L)=>o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsx("label",{style:b,children:E.toUpperCase()}),o.jsx("select",{className:"wsp-input",value:a?.[A]??L[0]?.value,onChange:B=>y(A,B.target.value),disabled:u,style:{...x,opacity:u?.6:1,cursor:u?"not-allowed":"pointer"},children:L.map(B=>o.jsx("option",{value:B.value,children:B.label},B.value))})]}),T=(E,A)=>{const L=!!a?.[A];return o.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsx("label",{style:{fontSize:"13px",color:p},children:E}),o.jsx("button",{type:"button",role:"switch","aria-checked":L,onClick:()=>!u&&y(A,!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:o.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)"}})})]})},N=()=>o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"3fr 1fr",gap:"20px"},children:[k("工作流名称","name"),k("版本号","version","number")]}),S("描述信息","description",!1,3),k("负责人邮箱","ownerEmail","text",{placeholder:"owner@example.com"}),k("Schema 版本","schemaVersion","number",{readOnly:!0})]}),w=()=>o.jsxs(o.Fragment,{children:[C("超时策略","timeoutPolicy",[{value:"ALERT_ONLY",label:"ALERT_ONLY — 仅告警"},{value:"TIME_OUT_WF",label:"TIME_OUT_WF — 超时终止"}]),o.jsxs("div",{children:[k("超时秒数","timeoutSeconds","number",{placeholder:"0 表示不超时"}),a?.timeoutPolicy==="ALERT_ONLY"&&o.jsx("p",{style:{fontSize:"11px",color:m,marginTop:"-12px",marginBottom:"20px"},children:"当前策略为 ALERT_ONLY,超时仅触发告警,不会终止工作流。"})]}),k("失败补偿工作流","failureWorkflow","text",{placeholder:"输入补偿工作流名称"}),T("允许重启 (restartable)","restartable")]}),_=()=>{const E=st(a?.inputParameters),A=q=>{u||y("inputParameters",q)},L=()=>{const q=[...E,{name:`param_${E.length+1}`,type:"string",required:!1}];A(q)},B=q=>{const M=E.filter((O,W)=>W!==q);A(M)},z=(q,M,O)=>{const W=E.map((U,$)=>$===q?{...U,[M]:O}:U);A(W)},R={padding:"6px 10px",borderRadius:"6px",border:`1px solid ${h}`,background:f,color:p,fontSize:"12px",outline:"none",fontFamily:"inherit"};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[o.jsx("label",{style:b,children:"入参声明 (INPUT PARAMETERS)"}),!u&&o.jsx("button",{onClick:L,style:{background:"var(--color-accent)",color:"var(--text-inverse)",border:"none",borderRadius:"6px",padding:"5px 12px",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"+ 添加参数"})]}),E.length===0?o.jsx("p",{style:{fontSize:"12px",color:m,margin:0,padding:"12px",background:"var(--bg-secondary)",borderRadius:"8px",border:`1px solid ${h}`},children:'暂无入参声明。点击"+ 添加参数"来定义工作流的输入参数,这些参数将在执行验证时作为表单字段展示。'}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:E.map((q,M)=>o.jsxs("div",{style:{background:"var(--bg-secondary)",border:`1px solid ${h}`,borderRadius:"10px",padding:"12px"},children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr auto auto",gap:"8px",alignItems:"center"},children:[o.jsx("input",{style:R,placeholder:"参数名",value:q.name,onChange:O=>z(M,"name",O.target.value),disabled:u}),o.jsx("select",{style:{...R,cursor:u?"not-allowed":"pointer"},value:q.type??"string",onChange:O=>z(M,"type",O.target.value),disabled:u,children:["string","number","boolean","object","array"].map(O=>o.jsx("option",{value:O,children:O},O))}),o.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:m,cursor:u?"not-allowed":"pointer",whiteSpace:"nowrap"},children:[o.jsx("input",{type:"checkbox",checked:!!q.required,onChange:O=>z(M,"required",O.target.checked),disabled:u,style:{accentColor:"var(--color-accent)"}}),"必填"]}),!u&&o.jsx("button",{onClick:()=>B(M),style:{background:"none",border:"none",color:"var(--status-failed)",cursor:"pointer",fontSize:"16px",padding:"0 4px",opacity:.7,lineHeight:1},children:"✕"})]}),o.jsxs("div",{style:{marginTop:"8px",display:"flex",flexDirection:"column",gap:"6px"},children:[o.jsx("input",{style:R,placeholder:"说明(可选)",value:q.description??"",onChange:O=>z(M,"description",O.target.value),disabled:u}),o.jsx("input",{style:R,placeholder:`示例值(如 ${q.type==="number"?"42":q.type==="boolean"?"true":'"value"'})`,value:q.example!==void 0?typeof q.example=="object"?JSON.stringify(q.example):String(q.example):"",onChange:O=>{let W=O.target.value;try{W=JSON.parse(O.target.value)}catch{}z(M,"example",W)},disabled:u})]})]},M))})]}),S("输出参数映射 (outputParameters)","outputParameters",!0),S("默认输入模板 (inputTemplate)","inputTemplate",!0),S("工作流级变量 (variables)","variables",!0)]})},j=()=>o.jsxs(o.Fragment,{children:[T("启用状态监听 (workflowStatusListenerEnabled)","workflowStatusListenerEnabled"),a?.workflowStatusListenerEnabled&&k("状态事件目标 (Listener Sink)","workflowStatusListenerSink","text",{placeholder:"conductor:workflow_status_event"}),o.jsxs("div",{style:{borderTop:`1px solid ${h}`,marginTop:"8px",paddingTop:"20px"},children:[T("强制 Schema 校验 (enforceSchema)","enforceSchema"),a?.enforceSchema&&o.jsxs(o.Fragment,{children:[S("输入 Schema (inputSchema)","inputSchema",!0,4),S("输出 Schema (outputSchema)","outputSchema",!0,4)]})]}),o.jsxs("div",{style:{borderTop:`1px solid ${h}`,marginTop:"8px",paddingTop:"20px"},children:[o.jsx("label",{style:{...b,marginBottom:"16px"},children:"并发限流 (RATE LIMIT)"}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"20px"},children:[o.jsxs("div",{children:[o.jsx("label",{style:b,children:"RATE LIMIT KEY"}),o.jsx("input",{className:"wsp-input",type:"text",value:a?.rateLimitConfig?.rateLimitKey??"",onChange:E=>v("rateLimitConfig","rateLimitKey",E.target.value),disabled:u,placeholder:"限流键",style:{...x,opacity:u?.6:1}})]}),o.jsxs("div",{children:[o.jsx("label",{style:b,children:"并发上限"}),o.jsx("input",{className:"wsp-input",type:"number",value:a?.rateLimitConfig?.concurrentExecLimit??"",onChange:E=>v("rateLimitConfig","concurrentExecLimit",E.target.value===""?0:parseInt(E.target.value)),disabled:u,placeholder:"0",style:{...x,opacity:u?.6:1}})]})]})]})]}),P=()=>{switch(l){case"basic":return N();case"timeout":return w();case"params":return _();case"advanced":return j()}};return o.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:o.jsxs("div",{onClick:E=>E.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 ${h}`,backdropFilter:"blur(20px)"},children:[o.jsxs("div",{style:{padding:"24px 32px 0 32px",background:"var(--bg-highlight)"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[o.jsxs("div",{children:[o.jsx("h2",{style:{margin:0,fontSize:"20px",color:p},children:"工作流全局配置"}),o.jsx("p",{style:{margin:"4px 0 0 0",fontSize:"12px",color:m},children:u?"当前为只读模式":"配置工作流级属性,所有更改将实时保存"})]}),o.jsx("button",{className:"wsp-close",onClick:t,"aria-label":"关闭",style:{background:"none",border:"none",color:p,fontSize:"24px",cursor:"pointer",opacity:.6},children:"✕"})]}),o.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${h}`},children:G0.map(E=>o.jsx("button",{className:"wsp-tab",onClick:()=>c(E.id),style:{padding:"10px 20px",fontSize:"13px",fontWeight:l===E.id?600:400,color:l===E.id?"var(--color-accent)":m,background:"none",border:"none",borderBottom:l===E.id?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s",marginBottom:"-1px"},children:E.label},E.id))})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",padding:"28px 32px"},children:P()}),o.jsx("div",{style:{padding:"20px 32px",borderTop:`1px solid ${h}`,background:"var(--bg-highlight)",display:"flex",justifyContent:"flex-end"},children:o.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:"完成并关闭"})})]})})},X0=({size:e=26,className:t,style:r})=>{const n=I.useId().replace(/:/g,"");return o.jsxs("svg",{width:e,height:e,viewBox:"0 0 32 32",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t,style:{flexShrink:0,display:"inline-block",verticalAlign:"middle",...r},"aria-label":"Conductor Workflow IDE Logo",children:[o.jsxs("defs",{children:[o.jsxs("linearGradient",{id:`bg-${n}`,x1:"0",y1:"0",x2:"32",y2:"32",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0%",stopColor:"#11172B"}),o.jsx("stop",{offset:"100%",stopColor:"#090D18"})]}),o.jsxs("linearGradient",{id:`bd-${n}`,x1:"0",y1:"0",x2:"32",y2:"32",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0%",stopColor:"#6366F1",stopOpacity:"0.8"}),o.jsx("stop",{offset:"100%",stopColor:"#06B6D4",stopOpacity:"0.5"})]}),o.jsxs("linearGradient",{id:`top-${n}`,x1:"9",y1:"16",x2:"23",y2:"10",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0%",stopColor:"#818CF8"}),o.jsx("stop",{offset:"100%",stopColor:"#22D3EE"})]}),o.jsxs("linearGradient",{id:`bot-${n}`,x1:"9",y1:"16",x2:"23",y2:"22",gradientUnits:"userSpaceOnUse",children:[o.jsx("stop",{offset:"0%",stopColor:"#6366F1"}),o.jsx("stop",{offset:"100%",stopColor:"#34D399"})]})]}),o.jsx("rect",{x:"1.25",y:"1.25",width:"29.5",height:"29.5",rx:"8",fill:`url(#bg-${n})`,stroke:`url(#bd-${n})`,strokeWidth:"1.5"}),o.jsx("path",{d:"M 9.5 16 C 15 16, 15.5 10, 22.5 10",stroke:`url(#top-${n})`,strokeWidth:"2.4",strokeLinecap:"round"}),o.jsx("path",{d:"M 9.5 16 C 15 16, 15.5 22, 22.5 22",stroke:`url(#bot-${n})`,strokeWidth:"2.4",strokeLinecap:"round"}),o.jsx("circle",{cx:"9.5",cy:"16",r:"3.4",fill:"#6366F1"}),o.jsx("circle",{cx:"9.5",cy:"16",r:"1.4",fill:"#F8FAFC"}),o.jsx("circle",{cx:"22.5",cy:"10",r:"2.7",fill:"#22D3EE"}),o.jsx("circle",{cx:"22.5",cy:"22",r:"2.7",fill:"#34D399"})]})},Z0=({onRequestImport:e})=>{const{createBlankWorkflow:t}=oe(ke(i=>({createBlankWorkflow:i.createBlankWorkflow}))),[r,n]=I.useState(""),s=()=>{t(r||void 0),oe.temporal.getState().clear()},a=()=>{t(r||void 0),oe.temporal.getState().clear(),window.dispatchEvent(new CustomEvent("open-ai-chat"))};return o.jsxs("div",{className:"empty-state-panel",children:[o.jsx("div",{style:{marginBottom:12},children:o.jsx(X0,{size:46})}),o.jsx("h2",{className:"empty-state-title",children:"创建新工作流"}),o.jsx("p",{className:"empty-state-subtitle",children:"从空白画布开始设计,或让 AI 帮你生成完整流程"}),o.jsx("input",{className:"empty-state-name-input",type:"text",placeholder:"工作流名称(可选)",value:r,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&s()}}),o.jsxs("div",{className:"empty-state-actions",children:[o.jsxs("button",{className:"empty-state-btn primary",onClick:s,children:[o.jsx("span",{className:"empty-state-btn-icon",children:"📄"}),"空白工作流"]}),o.jsxs("button",{className:"empty-state-btn",onClick:a,children:[o.jsx("span",{className:"empty-state-btn-icon",children:"✨"}),"AI 生成"]}),e&&o.jsxs("button",{className:"empty-state-btn",onClick:e,children:[o.jsx("span",{className:"empty-state-btn-icon",children:"📤"}),"导入 JSON"]})]})]})},Q0={success:{bg:"#10b981",text:"#fff"},error:{bg:"#ef4444",text:"#fff"},info:{bg:"var(--color-accent)",text:"#fff"}},eS=({messages:e,onDismiss:t})=>e.length===0?null:o.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=>o.jsx(tS,{message:r,onDismiss:t},r.id))}),tS=({message:e,onDismiss:t})=>{const r=Q0[e.type||"info"];return I.useEffect(()=>{const n=setTimeout(()=>t(e.id),2500);return()=>clearTimeout(n)},[e.id,t]),o.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})},ry=["shift","alt","meta","mod","ctrl","control"],rS={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 dt(e){return(rS[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function ny(e){return ry.includes(e)}function uc(e,t=","){return e.toLowerCase().split(t)}function pc(e,t="+",r=">",n=!1,s){let a=[],i=!1;e=e.trim(),e.includes(r)?(i=!0,a=e.toLocaleLowerCase().split(r).map(u=>dt(u))):a=e.toLocaleLowerCase().split(t).map(u=>dt(u));const l={alt:a.includes("alt"),ctrl:a.includes("ctrl")||a.includes("control"),shift:a.includes("shift"),meta:a.includes("meta"),mod:a.includes("mod"),useKey:n},c=a.filter(u=>!ry.includes(u));return{...l,keys:c,description:s,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&oy([dt(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&ay([dt(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{it.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{it.clear()},0)}));const it=new Set;function fc(e){return Array.isArray(e)}function nS(e,t=","){return(fc(e)?e:e.split(t)).every(r=>it.has(r.trim().toLowerCase()))}function oy(e){const t=Array.isArray(e)?e:[e];it.has("meta")&&it.forEach(r=>!ny(r)&&it.delete(r.toLowerCase())),t.forEach(r=>it.add(r.toLowerCase()))}function ay(e){const t=Array.isArray(e)?e:[e];e==="meta"?it.clear():t.forEach(r=>it.delete(r.toLowerCase()))}function oS(e,t,r){(typeof r=="function"&&r(e,t)||r===!0)&&e.preventDefault()}function aS(e,t,r){return typeof r=="function"?r(e,t):r===!0||r===void 0}const sS=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function iS(e){return sy(e,sS)}function sy(e,t=!1){const{target:r,composed:n}=e;let s,a;return lS(r)&&n?(s=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(s=r&&r.tagName,a=r&&r.role),fc(t)?!!(s&&t&&t.some(i=>i.toLowerCase()===s.toLowerCase()||i===a)):!!(s&&t&&t)}function lS(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function cS(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 dS=(e,t,r=!1)=>{const{alt:n,meta:s,mod:a,shift:i,ctrl:l,keys:c,useKey:u}=t,{code:d,key:p,ctrlKey:h,metaKey:f,shiftKey:m,altKey:y}=e,v=dt(d);if(u&&c?.length===1&&c.includes(p))return!0;if(!c?.includes(v)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(v))return!1;if(!r){if(n!==y&&v!=="alt"||i!==m&&v!=="shift")return!1;if(a){if(!f&&!h)return!1}else if(s!==f&&v!=="meta"&&v!=="os"||l!==h&&v!=="ctrl"&&v!=="control")return!1}return c&&c.length===1&&c.includes(v)?!0:c?nS(c):!c},uS=I.createContext(void 0),pS=()=>I.useContext(uS);function iy(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&&iy(e[n],t[n]),!0):e===t}const fS=I.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),hS=()=>I.useContext(fS);function mS(e){const t=I.useRef(void 0);return iy(t.current,e)||(t.current=e),t.current}const ly=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},gS=typeof window<"u"?I.useLayoutEffect:I.useEffect;function Lt(e,t,r,n){const s=I.useRef(null),a=I.useRef(!1),i=Array.isArray(r)?Array.isArray(n)?void 0:n:r,l=fc(e)?e.join(i?.delimiter):e,c=Array.isArray(r)?r:Array.isArray(n)?n:void 0,u=I.useCallback(t,c??[]),d=I.useRef(u);c?d.current=u:d.current=t;const p=mS(i),{activeScopes:h}=hS(),f=pS();return gS(()=>{if(p?.enabled===!1||!cS(h,p?.scopes))return;let m=[],y;const v=(k,S=!1)=>{if(!(iS(k)&&!sy(k,p?.enableOnFormTags))){if(s.current!==null){const C=s.current.getRootNode();if((C instanceof Document||C instanceof ShadowRoot)&&C.activeElement!==s.current&&!s.current.contains(C.activeElement)){ly(k);return}}k.target?.isContentEditable&&!p?.enableOnContentEditable||uc(l,p?.delimiter).forEach(C=>{if(C.includes(p?.splitKey??"+")&&C.includes(p?.sequenceSplitKey??">")){console.warn(`Hotkey ${C} contains both ${p?.splitKey??"+"} and ${p?.sequenceSplitKey??">"} which is not supported.`);return}const T=pc(C,p?.splitKey,p?.sequenceSplitKey,p?.useKey,p?.description);if(T.isSequence){y=setTimeout(()=>{m=[]},p?.sequenceTimeoutMs??1e3);const N=T.useKey?k.key:dt(k.code);if(ny(N.toLowerCase()))return;m.push(N);const w=T.keys?.[m.length-1];if(N!==w){m=[],y&&clearTimeout(y);return}m.length===T.keys?.length&&(d.current(k,T),y&&clearTimeout(y),m=[])}else if(dS(k,T,p?.ignoreModifiers)||T.keys?.includes("*")){if(p?.ignoreEventWhen?.(k)||S&&a.current)return;if(oS(k,T,p?.preventDefault),!aS(k,T,p?.enabled)){ly(k);return}d.current(k,T),S||(a.current=!0)}})}},g=k=>{k.code!==void 0&&(oy(dt(k.code)),(p?.keydown===void 0&&p?.keyup!==!0||p?.keydown)&&v(k))},x=k=>{k.code!==void 0&&(ay(dt(k.code)),a.current=!1,p?.keyup&&v(k,!0))},b=s.current||i?.document||document;return b.addEventListener("keyup",x,i?.eventListenerOptions),b.addEventListener("keydown",g,i?.eventListenerOptions),f&&uc(l,p?.delimiter).forEach(k=>f.addHotkey(pc(k,p?.splitKey,p?.sequenceSplitKey,p?.useKey,p?.description))),()=>{b.removeEventListener("keyup",x,i?.eventListenerOptions),b.removeEventListener("keydown",g,i?.eventListenerOptions),f&&uc(l,p?.delimiter).forEach(k=>f.removeHotkey(pc(k,p?.splitKey,p?.sequenceSplitKey,p?.useKey,p?.description))),m=[],y&&clearTimeout(y)}},[l,p,h]),s}const yS=e=>{const{mode:t,removeNode:r,selectedTask:n,pasteTask:s}=oe(ke(h=>({mode:h.mode,removeNode:h.removeNode,selectedTask:h.selectedTask,pasteTask:h.pasteTask}))),a=oe.temporal,{undo:i,redo:l}=pn(a,h=>h),c=e?.confirm||(h=>Promise.resolve(window.confirm(h))),u=e?.showToast,d=h=>{const f=h.target;return f.tagName==="INPUT"||f.tagName==="TEXTAREA"||f.isContentEditable},p=()=>{requestAnimationFrame(()=>{const h=oe.getState(),{nodes:f,edges:m}=Oe(h.nodes,h.edges,{direction:h.layoutDirection,mode:h.mode});oe.setState({nodes:f,edges:m})})};return Lt("mod+z",h=>{t==="edit"&&(d(h)||(h.preventDefault(),i(),p()))},[t,i]),Lt(["mod+shift+z","mod+y"],h=>{t==="edit"&&(d(h)||(h.preventDefault(),l(),p()))},[t,l]),Lt("delete, backspace",h=>{t!=="edit"||!n||d(h)||(h.preventDefault(),c("确定要删除此任务吗?").then(f=>{f&&r(n.taskReferenceName)}))},[t,n,r,c]),Lt("mod+c",h=>{if(!(t!=="edit"||!n)&&!d(h)){if(n.type==="JOIN"){u?.("JOIN 任务不能独立复制","error");return}h.preventDefault();try{localStorage.setItem("conductor-clipboard",JSON.stringify(n)),u?.("任务已复制","success")}catch{u?.("复制失败","error")}}},[t,n,u]),Lt("mod+v",h=>{if(t==="edit"&&!d(h)){h.preventDefault();try{const f=localStorage.getItem("conductor-clipboard");if(f){const m=JSON.parse(f);s(m),u?.("任务已粘贴","success")}}catch{u?.("粘贴失败","error")}}},[t,s,u]),Lt("mod+s",h=>{h.preventDefault();const f=oe.getState().workflowDef;f&&e?.onSave&&e.onSave(f)},[e?.onSave]),{}},Br=()=>{const[e,t]=I.useState(null),r=I.useCallback(a=>new Promise(i=>{t({message:a,resolve:i})}),[]),n=I.useCallback(()=>{e?.resolve(!0),t(null)},[e]),s=I.useCallback(()=>{e?.resolve(!1),t(null)},[e]);return{confirm:r,confirmState:e,handleConfirm:n,handleCancel:s}},xS=()=>{const[e,t]=I.useState([]),r=I.useCallback((s,a="info")=>{const i=Date.now().toString();t(l=>[...l,{id:i,text:s,type:a}])},[]),n=I.useCallback(s=>{t(a=>a.filter(i=>i.id!==s))},[]);return{toasts:e,showToast:r,dismissToast:n}},hc={id:"welcome",role:"assistant",content:`你好!我是 AI 工作流助手。
|
|
38
|
+
`}),o.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${f}`,display:"flex",justifyContent:"space-between",alignItems:"center",backgroundColor:"var(--cm-surface-0)"},children:[o.jsxs("div",{style:{fontWeight:"bold",fontSize:"14px",display:"flex",alignItems:"center",gap:"8px"},children:[o.jsx("span",{children:o.jsx(Ib,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})," 工作流体检报告"]}),o.jsx("button",{onClick:t,style:{background:"none",border:"none",color:m,cursor:"pointer",fontSize:"18px"},children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",padding:"8px"},children:l.length===0&&c.length===0?o.jsxs("div",{style:{padding:"32px 16px",textAlign:"center",color:"var(--cm-status-success)"},children:[o.jsx("div",{style:{fontSize:"32px",marginBottom:"12px"},children:o.jsx(Cs,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsx("div",{style:{fontWeight:"bold"},children:"未发现问题"}),o.jsx("div",{style:{fontSize:"12px",opacity:.7,marginTop:"4px"},children:"工作流逻辑看起来很完美"})]}):o.jsxs(o.Fragment,{children:[l.map((h,y)=>o.jsxs("div",{className:"health-item",role:"button",tabIndex:h.ref?0:void 0,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&d(h.ref)},onClick:()=>d(h.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:h.ref?"pointer":"default",borderLeft:"4px solid var(--cm-status-failed)",transition:"background 0.2s"},children:[o.jsxs("div",{style:{fontSize:"12px",color:"var(--cm-status-failed)",fontWeight:"bold",marginBottom:"2px"},children:["ERROR ",h.ref!=="UNKNOWN"&&`[${h.ref}]`]}),o.jsx("div",{style:{fontSize:"13px",color:p},children:h.message})]},`err-${y}`)),c.map((h,y)=>o.jsxs("div",{className:"health-item",role:"button",tabIndex:h.ref?0:void 0,onKeyDown:x=>{(x.key==="Enter"||x.key===" ")&&d(h.ref)},onClick:()=>d(h.ref),style:{padding:"12px",borderRadius:"8px",marginBottom:"4px",cursor:h.ref?"pointer":"default",borderLeft:"4px solid var(--cm-status-warning)",transition:"background 0.2s"},children:[o.jsxs("div",{style:{fontSize:"12px",color:"var(--cm-status-warning)",fontWeight:"bold",marginBottom:"2px"},children:["WARNING ",h.ref!=="UNKNOWN"&&`[${h.ref}]`]}),o.jsx("div",{style:{fontSize:"13px",color:p},children:h.message})]},`warn-${y}`))]})}),o.jsxs("div",{style:{padding:"12px 16px",fontSize:"11px",color:m,borderTop:`1px solid ${f}`,backgroundColor:"var(--cm-surface-0)",display:"flex",justifyContent:"space-between"},children:[o.jsxs("span",{children:["共 ",l.length," 个错误, ",c.length," 个警告"]}),l.length>0&&o.jsx("span",{style:{color:"var(--cm-status-failed)"},children:"无法保存/导出"})]})]}):null},xI=({id:e,source:t,target:r,sourceX:n,sourceY:s,targetX:a,targetY:i,sourcePosition:l,targetPosition:c,style:d={},markerEnd:u,data:p})=>{const[f,m]=T.useState(!1),h=T.useRef(null),y=()=>{const N=p?.edgeType||"default",C={sourceX:n,sourceY:s,sourcePosition:l,targetX:a,targetY:i,targetPosition:c};switch(N){case"step":case"smoothstep":return J.getSmoothStepPath(C);case"straight":return J.getStraightPath(C);default:return J.getBezierPath(C)}},[x,g,v]=y(),k=N=>{N.stopPropagation(),N.preventDefault();const C=new CustomEvent("edgeAddNode",{detail:{id:e,source:t,target:r,edgeData:p}});window.dispatchEvent(C)},b=()=>{h.current&&clearTimeout(h.current),m(!0)},S=()=>{h.current=setTimeout(()=>{m(!1)},100)},j=!!(p?.isAddable??p?.mode==="edit"),_=!!p?.label,w=typeof d?.strokeWidth=="number"?d.strokeWidth:2.2,I=typeof d?.opacity=="number"?d.opacity:1;return o.jsxs(o.Fragment,{children:[o.jsx(J.BaseEdge,{path:x,markerEnd:u,style:{...d,strokeWidth:j&&f?w+1.4:w,stroke:j&&f?"var(--color-accent)":d?.stroke,transition:"stroke 0.2s ease, stroke-width 0.2s ease, opacity 0.25s ease",pointerEvents:"none"}}),j&&o.jsx("path",{d:x,fill:"none",stroke:"transparent",strokeWidth:22,style:{cursor:"pointer",pointerEvents:"all"},onMouseEnter:b,onMouseLeave:S}),(_||j&&f)&&o.jsx(J.EdgeLabelRenderer,{children:o.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${g}px,${v}px)`,fontSize:12,pointerEvents:j?"all":"none",zIndex:f?2e3:10,display:"flex",flexDirection:"column",alignItems:"center",gap:"6px",opacity:f?1:I,transition:"opacity 0.2s ease"},className:"nodrag nopan",onMouseEnter:j?b:void 0,onMouseLeave:j?S:void 0,children:[_&&o.jsx("div",{style:{background:"var(--glass-bg-accent)",backdropFilter:"var(--glass-blur)",WebkitBackdropFilter:"var(--glass-blur)",color:"var(--text-primary)",padding:"2px 8px",borderRadius:"999px",fontSize:"11px",fontWeight:600,border:`1px solid ${f?"var(--color-accent)":"var(--border-secondary)"}`,boxShadow:"var(--cm-shadow-card)",whiteSpace:"nowrap",letterSpacing:"0.3px",lineHeight:1.4},children:p.label}),j&&f&&o.jsx("button",{style:{width:"28px",height:"28px",backgroundColor:"var(--color-accent)",color:"var(--color-on-accent)",border:"2px solid var(--border-primary)",borderRadius:"50%",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",fontWeight:700,fontSize:"18px",lineHeight:1,boxShadow:"0 4px 14px 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:k,onMouseDown:N=>N.stopPropagation(),title:"在此处添加任务",children:"+"})]})})]})},et=({onClick:e,icon:t,label:r,title:n,disabled:s=!1,active:a=!1,variant:i="default",style:l})=>{let c="var(--bg-tertiary)",d="var(--text-primary)",u="1px solid var(--border-primary)";return i==="primary"?(c="var(--color-accent)",d="var(--color-on-accent)",u="none"):i==="danger"?(c=s?"var(--cm-failed-tint)":"var(--status-failed)",d=s?"var(--text-secondary)":"var(--color-on-danger)",u="none"):a&&(c="var(--bg-secondary)",d="var(--color-accent)",u="1px solid var(--color-accent)"),o.jsxs("button",{onClick:e,disabled:s,title:n,"aria-label":n||r,"aria-pressed":a,"aria-disabled":s,style:{display:"flex",alignItems:"center",justifyContent:"center",gap:r?"6px":"0",background:c,color:d,border:u,borderRadius:"7px",padding:r?"4px 10px":"6px",cursor:s?"not-allowed":"pointer",opacity:s?.45:1,fontSize:"12px",fontWeight:500,transition:"all 0.18s",minWidth:r?"auto":"30px",height:"30px",whiteSpace:"nowrap",boxShadow:i==="default"?"var(--cm-shadow-card)":"none",...l},children:[t&&o.jsx("span",{style:{fontSize:"13px",display:"flex",alignItems:"center"},children:t}),r&&o.jsx("span",{children:r})]})},vI=()=>{const{zoomIn:e,zoomOut:t,fitView:r}=J.useReactFlow();return o.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"flex-start",gap:"10px"},children:o.jsxs("div",{style:{display:"flex",background:"var(--bg-tertiary)",padding:"4px",borderRadius:"8px",border:"1px solid var(--border-primary)",gap:"4px",boxShadow:"var(--cm-shadow-card)"},children:[o.jsx(et,{icon:o.jsx(rr,{size:15,strokeWidth:1.75,"aria-hidden":"true"}),title:"放大",onClick:()=>e()}),o.jsx(et,{icon:o.jsx(bb,{size:15,strokeWidth:1.75,"aria-hidden":"true"}),title:"缩小",onClick:()=>t()}),o.jsx(et,{icon:"⤢",title:"适应屏幕",onClick:()=>r({duration:600})})]})})};function bI(e){if(e.type!=="SWITCH"&&e.type!=="DECISION")return null;const t=Object.keys(e.decisionCases||{});if(t.length===0)return null;const r=e.type==="DECISION",n=r?e.caseExpression?"javascript":"value-param":e.evaluatorType||"value-param",s={switchRef:e.taskReferenceName,switchName:e.name||e.taskReferenceName,cases:t};if(n!=="value-param")return{...s,inputField:null,evaluator:"javascript"};const a=r?e.caseValueParam:e.expression||e.caseValueParam,i=a?e.inputParameters?.[a]:void 0,l=typeof i=="string"?i.match(/^\s*\$\{\s*workflow\.input\.([a-zA-Z0-9_]+)\s*\}\s*$/):null;return{...s,inputField:l?l[1]:null,evaluator:"value-param"}}const Ls=20,Lb={enabled:!1,status:"COMPLETED",durationMs:"",forceCase:"",reasonForIncompletion:"",outputJsonText:""},kI=({isOpen:e,onClose:t})=>{const{workflowDef:r,theme:n,themeColor:s,runLocalSandboxDryRun:a}=te(Ae(A=>({workflowDef:A.workflowDef,theme:A.theme,themeColor:A.themeColor,runLocalSandboxDryRun:A.runLocalSandboxDryRun}))),[i,l]=T.useState("input"),[c,d]=T.useState(""),[u,p]=T.useState(null),[f,m]=T.useState({}),[h,y]=T.useState(""),[x,g]=T.useState(null),[v,k]=T.useState(Ls),b=T.useMemo(()=>r?.tasks?gr(r.tasks):[],[r]),S=T.useMemo(()=>`sandbox_mock_cfg_${r?.name||"default"}`,[r?.name]);T.useEffect(()=>{if(!e||!r)return;const A=ln(r);let W=!1;try{const P=sessionStorage.getItem(S);if(P){const D=JSON.parse(P);D.inputJsonText?d(D.inputJsonText):d(JSON.stringify(A,null,2)),D.taskDrafts&&typeof D.taskDrafts=="object"&&m(D.taskDrafts),typeof D.loopSafetyLimit=="number"?k(D.loopSafetyLimit):k(Ls),W=!0}}catch{}W||(d(JSON.stringify(A,null,2)),m({}),k(Ls)),p(null),g(null),b.length>0&&!h&&y(b[0].taskReferenceName)},[e,r,S]),T.useEffect(()=>{b.length>0&&!b.some(A=>A.taskReferenceName===h)&&y(b[0].taskReferenceName)},[b,h]);const j=T.useMemo(()=>b.map(bI).filter(A=>A!==null),[b]);if(!e||!r||typeof document>"u")return null;const _=b.find(A=>A.taskReferenceName===h)||b[0]||null,w=_&&f[_.taskReferenceName]||Lb,I=A=>{if(!_)return;const W=_.taskReferenceName,D={...f[W]||{...Lb,outputJsonText:JSON.stringify(Ts(_),null,2)},...A,enabled:A.enabled!==void 0?A.enabled:!0};m(Z=>({...Z,[W]:D})),g(null)},N=Object.values(f).filter(A=>A.enabled).length,C=(A,W)=>{try{const P=JSON.parse(c||"{}");P[A]=W,d(JSON.stringify(P,null,2)),p(null)}catch{p("请先修复当前 JSON 语法错误后再点击快捷赋值")}},M=()=>{let A={};try{if(A=c.trim()?JSON.parse(c):{},typeof A!="object"||Array.isArray(A)||A===null){p("workflow.input 必须是一个 JSON 对象 {...}"),l("input");return}}catch(P){p(`JSON 语法错误: ${P?.message||"格式不合法"}`),l("input");return}const W={};for(const[P,D]of Object.entries(f)){if(!D.enabled)continue;let Z;if(D.outputJsonText.trim())try{Z=JSON.parse(D.outputJsonText)}catch(H){y(P),l("tasks"),g(`节点 [${P}] 的自定义输出 JSON 语法有误: ${H?.message||""}`);return}const L=D.durationMs.trim()!==""&&!Number.isNaN(Number(D.durationMs))?Number(D.durationMs):void 0;W[P]={__isMockOverride:!0,status:D.status,durationMs:L,forceCase:D.forceCase||void 0,reasonForIncompletion:D.reasonForIncompletion.trim()||void 0,outputData:Z}}try{sessionStorage.setItem(S,JSON.stringify({inputJsonText:c,taskDrafts:f,loopSafetyLimit:v}))}catch{}a(A,W,v),t()},R="var(--cm-surface-1)",O="var(--cm-surface-3)",$="var(--cm-surface-0)",B="var(--text-primary)",q="var(--text-muted)",F="var(--border-primary)";return bt.createPortal(o.jsx("div",{"data-mode":n,"data-brand":s,style:{position:"fixed",inset:0,zIndex:9500,background:"var(--cm-overlay)",backdropFilter:"blur(6px)",display:"flex",alignItems:"center",justifyContent:"center",padding:20},onClick:t,children:o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":"本地沙箱试运行配置台",style:{width:"min(920px, 96vw)",height:"min(660px, 90vh)",background:R,color:B,borderRadius:14,border:`1px solid ${F}`,boxShadow:"var(--cm-shadow-float)",display:"flex",flexDirection:"column",overflow:"hidden"},onClick:A=>A.stopPropagation(),children:[o.jsxs("div",{style:{padding:"16px 20px",borderBottom:`1px solid ${F}`,display:"flex",alignItems:"center",justifyContent:"space-between",background:O},children:[o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,fontSize:15,fontWeight:700},children:[o.jsxs("span",{children:[o.jsx(Es,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"本地沙箱试运行 · 人工模拟数据控制台"]}),o.jsx("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:999,background:"color-mix(in srgb, var(--cm-data) 14%, transparent)",color:"var(--cm-data)",fontWeight:600},children:"本地试运行"})]}),o.jsxs("div",{style:{fontSize:12,color:q,marginTop:4},children:["自定义工作流启动入参 (",o.jsx("code",{children:"workflow.input"}),")、指定任意节点的 Mock 输出、模拟节点异常中断或强制切换 ",o.jsx("code",{children:"SWITCH"})," 分支走向"]})]}),o.jsx("button",{type:"button",onClick:t,style:{background:"none",border:"none",color:q,fontSize:18,cursor:"pointer",padding:"4px 8px"},children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsx("div",{style:{display:"flex",gap:8,padding:"10px 20px",borderBottom:`1px solid ${F}`,background:R},children:[{id:"input",label:"1. 工作流启动入参 (workflow.input)"},{id:"tasks",label:`2. 节点级人工 Mock & 故障注入 ${N>0?`(${N} 个已启用)`:""}`},{id:"engine",label:`3. 循环上限 (${v} 轮)`}].map(A=>{const W=i===A.id;return o.jsx("button",{type:"button",onClick:()=>l(A.id),style:{padding:"7px 14px",borderRadius:8,border:W?"1px solid var(--color-accent)":`1px solid ${F}`,background:W?"color-mix(in srgb, var(--color-accent) 14%, transparent)":"transparent",color:W?"var(--color-accent)":q,fontSize:12,fontWeight:W?700:500,cursor:"pointer"},children:A.label},A.id)})}),o.jsxs("div",{style:{flex:1,minHeight:0,display:"flex",overflow:"hidden"},children:[i==="input"&&o.jsxs("div",{style:{flex:1,padding:20,display:"flex",flexDirection:"column",gap:12,overflowY:"auto"},children:[j.length>0&&o.jsxs("div",{style:{padding:"10px 14px",borderRadius:10,background:"color-mix(in srgb, var(--color-accent) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--color-accent) 25%, transparent)",display:"flex",flexDirection:"column",gap:8},children:[o.jsxs("div",{style:{fontSize:12,fontWeight:700,color:"var(--cm-data)"},children:[o.jsx(yT,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"条件分支 (SWITCH) 快速路由切换器"]}),j.map(A=>o.jsxs("div",{style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,fontSize:12},children:[o.jsxs("span",{style:{color:q},children:["节点 ",o.jsx("b",{children:A.switchName})," (",o.jsx("code",{children:A.switchRef}),")",A.inputField?` 按入参 "${A.inputField}" 选择分支,点击改入参切换:`:A.evaluator==="javascript"?" 按脚本判断,点击到「2. 节点级人工 Mock」里强制指定分支:":" 判断取值不直接来自入参,点击到「2. 节点级人工 Mock」里强制指定分支:"]}),A.cases.map(W=>o.jsx("button",{type:"button",onClick:()=>{A.inputField?C(A.inputField,W):(y(A.switchRef),l("tasks"))},style:{padding:"2px 9px",borderRadius:999,border:"1px solid color-mix(in srgb, var(--cm-data) 45%, transparent)",background:"color-mix(in srgb, var(--cm-data) 14%, transparent)",color:"var(--cm-data)",fontSize:11,fontFamily:"monospace",fontWeight:600,cursor:"pointer"},children:A.inputField?`${A.inputField} = "${W}"`:`走分支: ${W}`},W))]},A.switchRef))]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("span",{style:{fontSize:12,fontWeight:600,color:q},children:["编辑 ",o.jsx("code",{children:"workflow.input"})," JSON(所有节点的 ",o.jsx("code",{children:"${workflow.input.*}"})," 将实时读取此处的值):"]}),o.jsxs("button",{type:"button",onClick:()=>{const A=ln(r);d(JSON.stringify(A,null,2)),p(null)},style:{fontSize:11,padding:"4px 10px",borderRadius:6,border:`1px solid ${F}`,background:O,color:q,cursor:"pointer"},children:[o.jsx($u,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"重置为默认推导值"]})]}),u&&o.jsxs("div",{style:{padding:"8px 12px",borderRadius:8,background:"color-mix(in srgb, var(--cm-status-failed) 14%, transparent)",border:"1px solid color-mix(in srgb, var(--cm-status-failed) 40%, transparent)",color:"var(--cm-status-failed)",fontSize:12},children:[o.jsx(Ye,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),u]}),o.jsx("textarea",{value:c,onChange:A=>{d(A.target.value),p(null)},spellCheck:!1,style:{flex:1,minHeight:240,width:"100%",boxSizing:"border-box",padding:14,borderRadius:10,border:`1px solid ${u?"var(--cm-status-failed)":F}`,background:$,color:B,fontFamily:"monospace",fontSize:13,lineHeight:1.55,resize:"none",outline:"none"}})]}),i==="tasks"&&o.jsxs("div",{style:{flex:1,display:"grid",gridTemplateColumns:"260px 1fr",minHeight:0},children:[o.jsxs("div",{style:{borderRight:`1px solid ${F}`,overflowY:"auto",padding:"10px 8px",background:O,display:"flex",flexDirection:"column",gap:4},children:[o.jsxs("div",{style:{fontSize:11,fontWeight:700,color:q,padding:"4px 8px 8px",textTransform:"uppercase"},children:["选择要定制 Mock 的节点 (",b.length,")"]}),b.map(A=>{const W=A.taskReferenceName,P=_?.taskReferenceName===W,D=f[W],Z=!!D?.enabled;return o.jsxs("div",{onClick:()=>{y(W),g(null)},style:{padding:"8px 10px",borderRadius:8,cursor:"pointer",background:P?"color-mix(in srgb, var(--color-accent) 16%, transparent)":"transparent",border:P?"1px solid color-mix(in srgb, var(--color-accent) 45%, transparent)":"1px solid transparent",display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[o.jsxs("div",{style:{minWidth:0},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:A.name||W}),o.jsxs("div",{style:{fontSize:10,color:q,fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:[W," · ",A.type]})]}),Z&&(()=>{const L=He(D.status),H=L.icon;return o.jsxs("span",{"data-testid":"sandbox-mock-badge",style:{display:"inline-flex",alignItems:"center",gap:3,fontSize:10,padding:"2px 6px",borderRadius:999,background:`color-mix(in srgb, ${L.color} 20%, transparent)`,color:L.color,fontWeight:700,flexShrink:0},children:[o.jsx(H,{size:10,strokeWidth:1.75,"aria-hidden":"true"}),D.status==="COMPLETED"?"已定制":`模拟${L.label}`]})})()]},W)})]}),_?o.jsxs("div",{style:{padding:18,overflowY:"auto",display:"flex",flexDirection:"column",gap:14},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",paddingBottom:10,borderBottom:`1px solid ${F}`},children:[o.jsxs("div",{children:[o.jsxs("div",{style:{fontSize:14,fontWeight:700},children:[_.name||_.taskReferenceName," ",o.jsxs("code",{style:{fontSize:12,color:"var(--cm-data)",fontWeight:500},children:["(",_.taskReferenceName,")"]})]}),o.jsxs("div",{style:{fontSize:11,color:q,marginTop:2},children:["节点类型: ",o.jsx("b",{children:_.type})]})]}),o.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,fontSize:12,fontWeight:700,cursor:"pointer",padding:"6px 12px",borderRadius:8,background:w.enabled?"color-mix(in srgb, var(--cm-status-success) 14%, transparent)":O,border:`1px solid ${w.enabled?"var(--cm-status-success)":F}`,color:w.enabled?"var(--cm-status-success)":q},children:[o.jsx("input",{type:"checkbox",checked:w.enabled,onChange:A=>I({enabled:A.target.checked})}),"启用该节点人工 Mock"]})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 200px",gap:12},children:[o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:q,marginBottom:6},children:"模拟执行状态 (可注入异常以测试断路与错误诊断)"}),o.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[{id:"COMPLETED",label:"正常成功"},{id:"FAILED",label:"失败 (FAILED)"},{id:"TIMED_OUT",label:"超时 (TIMED_OUT)"},{id:"COMPLETED_WITH_ERRORS",label:"带错完成"}].map(A=>{const W=w.status===A.id;return o.jsx("button",{type:"button",onClick:()=>I({status:A.id}),style:{padding:"5px 10px",borderRadius:6,fontSize:11,fontWeight:W?700:500,cursor:"pointer",border:W?"1px solid var(--cm-data)":`1px solid ${F}`,background:W?"color-mix(in srgb, var(--cm-data) 16%, transparent)":O,color:W?"var(--cm-data)":B},children:A.label},A.id)})}),(w.status==="FAILED"||w.status==="TIMED_OUT")&&o.jsx("div",{style:{fontSize:11,color:q,marginTop:6},children:_.optional?"这是可选任务(optional):失败后按 Conductor 记为带错完成,流程继续。":"流程会在这里中断;要让流程继续,把任务设为可选(optional)。"})]}),o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:q,marginBottom:6},children:"模拟耗时 (ms,可制造并发瓶颈)"}),o.jsx("input",{type:"number",min:0,placeholder:"默认自动耗时 (如 120)",value:w.durationMs,onChange:A=>I({durationMs:A.target.value}),style:{width:"100%",boxSizing:"border-box",padding:"6px 10px",borderRadius:6,border:`1px solid ${F}`,background:$,color:B,fontSize:12}})]})]}),(w.status==="FAILED"||w.status==="TIMED_OUT")&&o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:11,fontWeight:600,color:"var(--cm-status-failed)",marginBottom:6},children:"模拟异常原因 (reasonForIncompletion)"}),o.jsx("input",{type:"text",placeholder:"例如: Connection refused to upstream payment gateway (502)",value:w.reasonForIncompletion,onChange:A=>I({reasonForIncompletion:A.target.value}),style:{width:"100%",boxSizing:"border-box",padding:"7px 10px",borderRadius:6,border:"1px solid color-mix(in srgb, var(--cm-status-failed) 45%, transparent)",background:$,color:B,fontSize:12}})]}),(_.type==="SWITCH"||_.type==="DECISION")&&o.jsxs("div",{style:{padding:"10px 12px",borderRadius:8,background:"color-mix(in srgb, var(--cm-status-warning) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--cm-status-warning) 35%, transparent)"},children:[o.jsxs("label",{style:{display:"block",fontSize:11,fontWeight:700,color:"var(--cm-status-warning)",marginBottom:6},children:[o.jsx(Mr,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"强制指定 SWITCH 路由分支 (无视入参表达式直接走指定分支)"]}),o.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:[o.jsxs("button",{type:"button",onClick:()=>I({forceCase:""}),style:{padding:"4px 10px",borderRadius:6,fontSize:11,cursor:"pointer",border:w.forceCase?`1px solid ${F}`:"1px solid var(--cm-status-warning)",background:w.forceCase?O:"color-mix(in srgb, var(--cm-status-warning) 20%, transparent)",color:w.forceCase?q:"var(--cm-status-warning)",fontWeight:w.forceCase?500:700},children:[o.jsx(Ps,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"根据入参自动求值"]}),Object.keys(_.decisionCases||{}).map(A=>{const W=w.forceCase===A;return o.jsxs("button",{type:"button",onClick:()=>I({forceCase:A}),style:{padding:"4px 10px",borderRadius:6,fontSize:11,fontFamily:"monospace",cursor:"pointer",border:W?"1px solid var(--cm-status-warning)":`1px solid ${F}`,background:W?"color-mix(in srgb, var(--cm-status-warning) 22%, transparent)":O,color:W?"var(--cm-status-warning)":B,fontWeight:W?700:500},children:["分支: ",A]},A)}),_.defaultCase&&o.jsx("button",{type:"button",onClick:()=>I({forceCase:"__default__"}),style:{padding:"4px 10px",borderRadius:6,fontSize:11,fontFamily:"monospace",cursor:"pointer",border:w.forceCase==="__default__"?"1px solid var(--cm-status-warning)":`1px solid ${F}`,background:w.forceCase==="__default__"?"color-mix(in srgb, var(--cm-status-warning) 22%, transparent)":O,color:w.forceCase==="__default__"?"var(--cm-status-warning)":B},children:"默认分支 (defaultCase)"})]})]}),o.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("label",{style:{fontSize:11,fontWeight:600,color:q},children:["自定义节点输出数据 (",o.jsx("code",{children:`\${${_.taskReferenceName}.output.*}`})," 将读取此 JSON):"]}),o.jsxs("button",{type:"button",onClick:()=>{const A=Ts(_);I({outputJsonText:JSON.stringify(A,null,2)})},style:{fontSize:11,padding:"3px 9px",borderRadius:6,border:`1px solid ${F}`,background:O,color:"var(--cm-data)",cursor:"pointer",fontWeight:600},children:[o.jsx(Tu,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"填入默认合成输出模板"]})]}),x&&o.jsxs("div",{style:{padding:"6px 10px",borderRadius:6,background:"color-mix(in srgb, var(--cm-status-failed) 14%, transparent)",border:"1px solid color-mix(in srgb, var(--cm-status-failed) 40%, transparent)",color:"var(--cm-status-failed)",fontSize:11},children:[o.jsx(Ye,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),x]}),o.jsx("textarea",{value:w.outputJsonText,placeholder:`留空则自动按 ${_.type} 类型合成输出,或点击右上角「填入默认合成输出模板」进行修改...`,onChange:A=>I({outputJsonText:A.target.value}),spellCheck:!1,style:{flex:1,minHeight:160,width:"100%",boxSizing:"border-box",padding:12,borderRadius:8,border:`1px solid ${x?"var(--cm-status-failed)":F}`,background:$,color:B,fontFamily:"monospace",fontSize:12,lineHeight:1.5,resize:"vertical",outline:"none"}})]})]}):o.jsx("div",{style:{padding:32,color:q},children:"当前工作流暂无任务节点"})]}),i==="engine"&&o.jsx("div",{style:{flex:1,padding:24,display:"flex",flexDirection:"column",gap:18},children:o.jsxs("div",{style:{padding:16,borderRadius:10,border:`1px solid ${F}`,background:O,display:"flex",flexDirection:"column",gap:10},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{children:[o.jsxs("div",{style:{fontSize:13,fontWeight:700},children:[o.jsx(Ps,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"DO_WHILE 循环安全上限"]}),o.jsxs("div",{style:{fontSize:12,color:q,marginTop:2},children:["循环何时结束由 ",o.jsx("code",{children:"loopCondition"})," 决定;到达上限时条件仍为真,沙箱停止循环并标记为部分完成,防止死循环(可在画布循环容器头部切换查看每一轮的子任务状态)"]})]}),o.jsxs("span",{style:{fontSize:16,fontWeight:800,color:"var(--cm-data)",fontFamily:"monospace"},children:[v," 轮"]})]}),o.jsx("input",{type:"range",min:1,max:50,value:v,onChange:A=>k(Number(A.target.value)),style:{width:"100%",accentColor:"var(--cm-data)",cursor:"pointer"}}),o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:11,color:q},children:[o.jsx("span",{children:"1 轮"}),o.jsx("span",{children:"20 轮(默认)"}),o.jsx("span",{children:"50 轮"})]})]})})]}),o.jsxs("div",{style:{padding:"12px 20px",borderTop:`1px solid ${F}`,background:O,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("button",{type:"button",onClick:()=>{m({});const A=ln(r);d(JSON.stringify(A,null,2)),k(Ls),sessionStorage.removeItem(S)},style:{padding:"7px 12px",borderRadius:8,border:`1px solid ${F}`,background:"transparent",color:q,fontSize:12,cursor:"pointer"},children:[o.jsx(kT,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"清空全部人工 Mock 配置"]}),o.jsxs("div",{style:{display:"flex",gap:10},children:[o.jsx("button",{type:"button",onClick:t,style:{padding:"8px 16px",borderRadius:8,border:`1px solid ${F}`,background:"transparent",color:B,fontSize:12,fontWeight:600,cursor:"pointer"},children:"取消"}),o.jsxs("button",{type:"button",onClick:M,style:{padding:"8px 20px",borderRadius:8,border:"none",background:"var(--color-accent)",color:"var(--color-on-accent)",fontSize:12,fontWeight:700,cursor:"pointer"},children:[o.jsx(At,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"应用模拟数据并启动沙箱试运行"]})]})]})]})}),document.body)},vt=({as:e})=>o.jsx(e,{size:15,strokeWidth:1.75,"aria-hidden":"true"}),Hu=()=>o.jsx("div",{style:{width:"1px",height:"18px",background:"var(--border-primary)",margin:"0 2px",alignSelf:"center",flexShrink:0}}),wI=({onShowHealthCheck:e,showHealthCheck:t,onShowSettings:r,executionActions:n})=>{const{mode:s,setMode:a,validationResults:i,workflowInstance:l,workflowDef:c,showDataLineage:d,setShowDataLineage:u,showWaterfallPanel:p,setShowWaterfallPanel:f,runLocalSandboxDryRun:m,sandboxRunning:h,inlineCopilotTaskRef:y,setInlineCopilotTaskRef:x,selectedTask:g}=te(Ae(D=>({mode:D.mode,setMode:D.setMode,validationResults:D.validationResults,workflowInstance:D.workflowInstance,workflowDef:D.workflowDef,showDataLineage:D.showDataLineage,setShowDataLineage:D.setShowDataLineage,showWaterfallPanel:D.showWaterfallPanel,setShowWaterfallPanel:D.setShowWaterfallPanel,runLocalSandboxDryRun:D.runLocalSandboxDryRun,sandboxRunning:D.sandboxRunning,inlineCopilotTaskRef:D.inlineCopilotTaskRef,setInlineCopilotTaskRef:D.setInlineCopilotTaskRef,selectedTask:D.selectedTask}))),v=te.temporal,{undo:k,redo:b,pastStates:S,futureStates:j}=ga(v,D=>D),[_,w]=T.useState(!1),[I,N]=T.useState(!1),C=T.useRef(null);T.useEffect(()=>{if(!_)return;const D=Z=>{C.current&&!C.current.contains(Z.target)&&w(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[_]);const M=(i?.errors?.length||0)>0,R=l?.status,O=l?.workflowId??"",$=R==="RUNNING",B=R==="PAUSED",q=R==="FAILED"||R==="TIMED_OUT"||R==="TERMINATED",F=R==="COMPLETED",A=l?.isSandbox===!0,W=c?.restartable===!0&&(q||F),P=n?.allowOperations!==!1;return o.jsxs("div",{className:"action-bar",style:{display:"flex",gap:"6px",alignItems:"center",flexWrap:"wrap",padding:"5px 8px",borderRadius:"10px",background:"var(--bg-secondary)",backdropFilter:"blur(14px)",border:"1px solid var(--border-primary)",boxShadow:"var(--cm-shadow-float)"},children:[c&&o.jsxs(o.Fragment,{children:[o.jsx(et,{icon:o.jsx(vt,{as:UT}),label:"数据血缘",title:"W-LSP 数据流血缘图谱 (Data Flow Graph)",onClick:()=>u(!d),active:d}),s==="edit"&&o.jsx(et,{icon:o.jsx(vt,{as:Pt}),label:"AI微调",title:"画布内联 AI 指令栏 (Cmd+K)",onClick:()=>x(y?null:g?.taskReferenceName||"__canvas_root__"),active:!!y})]}),s==="edit"&&o.jsxs(o.Fragment,{children:[o.jsx(Hu,{}),o.jsxs("div",{style:{display:"inline-flex",gap:"3px",alignItems:"center"},children:[o.jsx(et,{icon:o.jsx(vt,{as:qu}),title:"撤销 (Cmd+Z)",onClick:()=>k(),disabled:S.length===0}),o.jsx(et,{icon:o.jsx(vt,{as:LT}),title:"重做 (Cmd+Shift+Z)",onClick:()=>b(),disabled:j.length===0})]}),o.jsx(et,{icon:o.jsx(vt,{as:Ib}),label:M?`错误 (${i.errors.length})`:"诊断",title:"流程健康检查",onClick:e,active:t,variant:M?"danger":"secondary"}),o.jsx(et,{icon:o.jsx(vt,{as:qT}),label:"配置",title:"工作流全局配置",onClick:()=>r?.()})]}),c&&s!=="run"&&o.jsxs(o.Fragment,{children:[o.jsx(Hu,{}),o.jsxs("div",{style:{display:"inline-flex",alignItems:"center"},children:[o.jsx(et,{icon:o.jsx(vt,{as:Es}),label:h?"试运行中":"沙箱试运行",title:"在浏览器里试运行:INLINE、JQ、SWITCH、DO_WHILE 等任务真实执行,HTTP 等调用外部系统的任务使用模拟数据",onClick:()=>{m()},disabled:h,variant:"primary",style:{borderRadius:"7px 0 0 7px",borderRight:"1px solid color-mix(in srgb, var(--color-on-accent) 25%, transparent)"}}),o.jsx(et,{icon:o.jsx(vt,{as:Tb}),title:"人工模拟数据配置台 (自定义 workflow.input / 节点 Mock 输出 / 故障注入 / 分支路由)",onClick:()=>N(!0),variant:"primary",style:{borderRadius:"0 7px 7px 0",padding:"4px 7px",minWidth:"26px"}})]})]}),s==="run"&&o.jsxs(o.Fragment,{children:[o.jsx(Hu,{}),A&&o.jsxs("span",{role:"note",title:"这是浏览器沙箱的试运行结果,不是服务端的真实执行;调用外部系统的任务使用了模拟数据",style:{display:"inline-flex",alignItems:"center",gap:"6px",height:"28px",padding:"0 10px",borderRadius:"var(--cm-radius-sm)",border:"1px solid color-mix(in srgb, var(--cm-data) 45%, transparent)",background:"var(--cm-data-tint)",color:"var(--cm-data)",fontSize:"12px",fontWeight:600,whiteSpace:"nowrap"},children:[o.jsx(vt,{as:Es}),"沙箱试运行 · 模拟数据"]}),o.jsx(et,{icon:o.jsx(vt,{as:Tb}),label:"模拟数据重跑",title:"打开沙箱人工模拟数据配置台,调整入参、分支或注入节点故障后重跑",onClick:()=>N(!0)}),o.jsx(et,{icon:o.jsx(vt,{as:uT}),label:"瀑布流回放",title:"并发甘特瀑布流与时间旅行调试器 (Time-Travel)",onClick:()=>f(!p),active:p}),o.jsx(et,{icon:o.jsx(vt,{as:fn}),label:"返回编辑",title:"退出试跑/运行态视图,返回工作流编排画布",onClick:()=>a("edit")})]}),o.jsx(kI,{isOpen:I,onClose:()=>N(!1)}),s==="run"&&l&&n&&!A&&o.jsxs(o.Fragment,{children:[B&&n.onResume&&o.jsx(et,{icon:o.jsx(Ot,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),label:"继续",title:P?"继续执行工作流":"操作权限受限",onClick:()=>P&&n.onResume(O),disabled:!P,variant:"primary"}),$&&n.onPause&&o.jsx(et,{icon:o.jsx(Au,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),label:"暂停",title:P?"暂停工作流执行":"操作权限受限",onClick:()=>P&&n.onPause(O),disabled:!P}),($||B)&&n.onTerminate&&o.jsx(et,{icon:o.jsx(hn,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),label:"终止",title:P?"终止工作流执行":"操作权限受限",onClick:()=>P&&n.onTerminate(O),disabled:!P,variant:"danger"}),q&&n.onRetry&&o.jsx(et,{icon:o.jsx(Du,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),label:"重试",title:P?"重试失败的工作流":"操作权限受限",onClick:()=>P&&n.onRetry(O),disabled:!P,variant:"primary"}),W&&n.onRestart&&o.jsxs("div",{ref:C,style:{position:"relative",display:"flex"},children:[o.jsxs("button",{disabled:!P,onClick:()=>P&&n.onRestart(O,{useLatestDef:!0}),title:P?"使用当前最新定义版本重新运行":"操作权限受限",style:{display:"flex",alignItems:"center",gap:"6px",background:"var(--bg-tertiary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRight:"none",borderRadius:"6px 0 0 6px",padding:"6px 10px",cursor:P?"pointer":"not-allowed",opacity:P?1:.5,fontSize:"13px",fontWeight:500,height:"32px"},children:[o.jsx($u,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"重启"]}),o.jsx("button",{disabled:!P,onClick:()=>P&&w(D=>!D),title:P?"展开重启版本选项":"操作权限受限",style:{display:"flex",alignItems:"center",justifyContent:"center",background:P&&_?"var(--bg-secondary)":"var(--bg-tertiary)",color:"var(--text-secondary)",border:"1px solid var(--border-primary)",borderRadius:"0 6px 6px 0",padding:"6px 6px",cursor:P?"pointer":"not-allowed",opacity:P?1:.5,height:"32px",width:"22px",fontSize:"10px"},children:o.jsx(wu,{size:12,strokeWidth:1.75,"aria-hidden":"true"})}),_&&o.jsxs("div",{style:{position:"absolute",top:"36px",right:0,background:"var(--glass-surface)",backdropFilter:"blur(12px)",border:"1px solid var(--glass-border)",borderRadius:"10px",boxShadow:"var(--cm-shadow-float)",zIndex:2e3,minWidth:"180px",overflow:"hidden"},children:[o.jsx("div",{style:{padding:"6px 12px 4px",fontSize:"11px",color:"var(--text-secondary)",fontWeight:600,letterSpacing:"0.5px",textTransform:"uppercase"},children:"选择版本"}),o.jsxs("button",{onClick:()=>{n.onRestart(O,{useLatestDef:!0}),w(!1)},style:Mb,onMouseEnter:D=>D.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:D=>D.currentTarget.style.background="transparent",children:[o.jsx(Iu,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"当前版本"}),o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用最新工作流定义"})]})]}),o.jsxs("button",{onClick:()=>{n.onRestart(O,{useLatestDef:!1}),w(!1)},style:Mb,onMouseEnter:D=>D.currentTarget.style.background="var(--bg-secondary)",onMouseLeave:D=>D.currentTarget.style.background="transparent",children:[o.jsx(Cu,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:"13px"},children:"执行版本"}),o.jsx("div",{style:{fontSize:"11px",color:"var(--text-secondary)"},children:"使用本次运行时的定义"})]})]})]})]})]})]})},Mb={display:"flex",alignItems:"center",gap:"10px",width:"100%",padding:"8px 12px",background:"transparent",border:"none",cursor:"pointer",textAlign:"left",color:"var(--text-primary)",transition:"background 0.15s"},SI=[{id:"basic",label:"基本信息"},{id:"timeout",label:"超时与容错"},{id:"params",label:"参数配置"},{id:"advanced",label:"高级设置"}],_I=({isOpen:e,onClose:t})=>{const{workflowDef:r,updateWorkflowProperties:n,mode:s}=te(Ae(R=>({workflowDef:R.workflowDef,updateWorkflowProperties:R.updateWorkflowProperties,mode:R.mode}))),[a,i]=T.useState(r),[l,c]=T.useState("basic"),d=s!=="edit";T.useEffect(()=>{r&&i(r)},[r,e]);const u=T.useCallback(R=>{R.key==="Escape"&&t()},[t]);if(T.useEffect(()=>{if(e)return document.addEventListener("keydown",u),()=>document.removeEventListener("keydown",u)},[e,u]),!e||!a)return null;const p="var(--text-primary)",f="var(--glass-border)",m="var(--bg-tertiary)",h="var(--text-secondary)",y=(R,O)=>{if(!a||d)return;const $={...a,[R]:O};i($),n({[R]:O})},x=(R,O,$)=>{if(!a||d)return;const q={...a[R]||{},[O]:$};i(F=>({...F,[R]:q})),n({[R]:q})},g=(R,O)=>{if(!(!a||d))try{const $=JSON.parse(O),B={...a,[R]:$};i(B),n({[R]:$})}catch{i($=>({...$,[`_${R}_str`]:O}))}},v={width:"100%",padding:"10px 14px",borderRadius:"8px",border:`1px solid ${f}`,background:m,color:p,fontSize:"14px",outline:"none",boxSizing:"border-box"},k={display:"block",fontSize:"11px",color:h,marginBottom:"8px",fontWeight:600},b=(R,O,$="text",B)=>o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsx("label",{style:k,children:R.toUpperCase()}),o.jsx("input",{className:"wsp-input",type:$,value:a?.[O]??"",onChange:q=>y(O,$==="number"?q.target.value===""?0:parseInt(q.target.value):q.target.value),disabled:d||B?.readOnly,placeholder:B?.placeholder,style:{...v,opacity:d||B?.readOnly?.6:1}})]}),S=(R,O,$=!1,B=6)=>{const q=a?.[`_${O}_str`]!==void 0?a[`_${O}_str`]:typeof a?.[O]=="object"?JSON.stringify(a[O],null,2):a?.[O];return o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsxs("label",{style:k,children:[R.toUpperCase()," ",$&&"(JSON)"]}),o.jsx("textarea",{className:"wsp-input",value:q||"",onChange:F=>$?g(O,F.target.value):y(O,F.target.value),rows:B,disabled:d,style:{...v,fontSize:"13px",fontFamily:$?"var(--font-mono)":"inherit",resize:"vertical",opacity:d?.6:1}})]})},j=(R,O,$)=>o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsx("label",{style:k,children:R.toUpperCase()}),o.jsx("select",{className:"wsp-input",value:a?.[O]??$[0]?.value,onChange:B=>y(O,B.target.value),disabled:d,style:{...v,opacity:d?.6:1,cursor:d?"not-allowed":"pointer"},children:$.map(B=>o.jsx("option",{value:B.value,children:B.label},B.value))})]}),_=(R,O)=>{const $=!!a?.[O];return o.jsxs("div",{style:{marginBottom:"20px",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsx("label",{style:{fontSize:"13px",color:p},children:R}),o.jsx("button",{type:"button",role:"switch","aria-checked":$,onClick:()=>!d&&y(O,!$),disabled:d,style:{width:"44px",height:"24px",borderRadius:"12px",border:"none",background:$?"var(--color-accent)":"var(--border-primary)",position:"relative",cursor:d?"not-allowed":"pointer",transition:"background 0.2s",opacity:d?.6:1,flexShrink:0},children:o.jsx("span",{style:{position:"absolute",top:"2px",left:$?"22px":"2px",width:"20px",height:"20px",borderRadius:"50%",background:"var(--text-inverse)",transition:"left 0.2s",boxShadow:"var(--cm-shadow-card)"}})})]})},w=()=>o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"3fr 1fr",gap:"20px"},children:[b("工作流名称","name"),b("版本号","version","number")]}),S("描述信息","description",!1,3),b("负责人邮箱","ownerEmail","text",{placeholder:"owner@example.com"}),b("Schema 版本","schemaVersion","number",{readOnly:!0})]}),I=()=>o.jsxs(o.Fragment,{children:[j("超时策略","timeoutPolicy",[{value:"ALERT_ONLY",label:"ALERT_ONLY — 仅告警"},{value:"TIME_OUT_WF",label:"TIME_OUT_WF — 超时终止"}]),o.jsxs("div",{children:[b("超时秒数","timeoutSeconds","number",{placeholder:"0 表示不超时"}),a?.timeoutPolicy==="ALERT_ONLY"&&o.jsx("p",{style:{fontSize:"11px",color:h,marginTop:"-12px",marginBottom:"20px"},children:"当前策略为 ALERT_ONLY,超时仅触发告警,不会终止工作流。"})]}),b("失败补偿工作流","failureWorkflow","text",{placeholder:"输入补偿工作流名称"}),_("允许重启 (restartable)","restartable")]}),N=()=>{const R=St(a?.inputParameters,a),O=A=>{if(d||!a)return;const W=aj(A,a);i({...a,...W}),n(W)},$=()=>{const A=[...R,{name:`param_${R.length+1}`,type:"string",required:!1}];O(A)},B=A=>{const W=R.filter((P,D)=>D!==A);O(W)},q=(A,W,P)=>{const D=R.map((Z,L)=>L===A?{...Z,[W]:P}:Z);O(D)},F={padding:"6px 10px",borderRadius:"6px",border:`1px solid ${f}`,background:m,color:p,fontSize:"12px",outline:"none",fontFamily:"inherit"};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{marginBottom:"20px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[o.jsx("label",{style:k,children:"入参声明 (INPUT PARAMETERS)"}),!d&&o.jsx("button",{onClick:$,style:{background:"var(--color-accent)",color:"var(--text-inverse)",border:"none",borderRadius:"6px",padding:"5px 12px",fontSize:"12px",fontWeight:600,cursor:"pointer",fontFamily:"inherit"},children:"+ 添加参数"})]}),R.length===0?o.jsx("p",{style:{fontSize:"12px",color:h,margin:0,padding:"12px",background:"var(--bg-secondary)",borderRadius:"8px",border:`1px solid ${f}`},children:'暂无入参声明。点击"+ 添加参数"来定义工作流的输入参数,这些参数将在执行验证时作为表单字段展示。'}):o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"10px"},children:R.map((A,W)=>o.jsxs("div",{style:{background:"var(--bg-secondary)",border:`1px solid ${f}`,borderRadius:"10px",padding:"12px"},children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr auto auto",gap:"8px",alignItems:"center"},children:[o.jsx("input",{style:F,placeholder:"参数名",value:A.name,onChange:P=>q(W,"name",P.target.value),disabled:d}),o.jsx("select",{style:{...F,cursor:d?"not-allowed":"pointer"},value:A.type??"string",onChange:P=>q(W,"type",P.target.value),disabled:d,children:["string","number","boolean","object","array"].map(P=>o.jsx("option",{value:P,children:P},P))}),o.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"4px",fontSize:"12px",color:h,cursor:d?"not-allowed":"pointer",whiteSpace:"nowrap"},children:[o.jsx("input",{type:"checkbox",checked:!!A.required,onChange:P=>q(W,"required",P.target.checked),disabled:d,style:{accentColor:"var(--color-accent)"}}),"必填"]}),!d&&o.jsx("button",{onClick:()=>B(W),style:{background:"none",border:"none",color:"var(--status-failed)",cursor:"pointer",fontSize:"16px",padding:"0 4px",opacity:.7,lineHeight:1},children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsxs("div",{style:{marginTop:"8px",display:"flex",flexDirection:"column",gap:"6px"},children:[o.jsx("input",{style:F,placeholder:"说明(可选)",value:A.description??"",onChange:P=>q(W,"description",P.target.value),disabled:d}),o.jsx("input",{style:F,placeholder:`示例值(如 ${A.type==="number"?"42":A.type==="boolean"?"true":'"value"'})`,value:A.example!==void 0?typeof A.example=="object"?JSON.stringify(A.example):String(A.example):"",onChange:P=>{let D=P.target.value;try{D=JSON.parse(P.target.value)}catch{}q(W,"example",D)},disabled:d})]})]},W))})]}),S("输出参数映射 (outputParameters)","outputParameters",!0),S("默认输入模板 (inputTemplate)","inputTemplate",!0),S("工作流级变量 (variables)","variables",!0)]})},C=()=>o.jsxs(o.Fragment,{children:[_("启用状态监听 (workflowStatusListenerEnabled)","workflowStatusListenerEnabled"),a?.workflowStatusListenerEnabled&&b("状态事件目标 (Listener Sink)","workflowStatusListenerSink","text",{placeholder:"conductor:workflow_status_event"}),o.jsxs("div",{style:{borderTop:`1px solid ${f}`,marginTop:"8px",paddingTop:"20px"},children:[_("强制 Schema 校验 (enforceSchema)","enforceSchema"),a?.enforceSchema&&o.jsxs(o.Fragment,{children:[S("输入 Schema (inputSchema)","inputSchema",!0,4),S("输出 Schema (outputSchema)","outputSchema",!0,4)]})]}),o.jsxs("div",{style:{borderTop:`1px solid ${f}`,marginTop:"8px",paddingTop:"20px"},children:[o.jsx("label",{style:{...k,marginBottom:"16px"},children:"并发限流 (RATE LIMIT)"}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"2fr 1fr",gap:"20px"},children:[o.jsxs("div",{children:[o.jsx("label",{style:k,children:"RATE LIMIT KEY"}),o.jsx("input",{className:"wsp-input",type:"text",value:a?.rateLimitConfig?.rateLimitKey??"",onChange:R=>x("rateLimitConfig","rateLimitKey",R.target.value),disabled:d,placeholder:"限流键",style:{...v,opacity:d?.6:1}})]}),o.jsxs("div",{children:[o.jsx("label",{style:k,children:"并发上限"}),o.jsx("input",{className:"wsp-input",type:"number",value:a?.rateLimitConfig?.concurrentExecLimit??"",onChange:R=>x("rateLimitConfig","concurrentExecLimit",R.target.value===""?0:parseInt(R.target.value)),disabled:d,placeholder:"0",style:{...v,opacity:d?.6:1}})]})]})]})]}),M=()=>{switch(l){case"basic":return w();case"timeout":return I();case"params":return N();case"advanced":return C()}};return o.jsx("div",{role:"dialog","aria-modal":"true","aria-label":"工作流全局配置",onClick:t,style:{position:"fixed",left:0,top:0,width:"100vw",height:"100vh",backgroundColor:"var(--cm-overlay)",zIndex:1300,display:"flex",justifyContent:"center",alignItems:"center",backdropFilter:"blur(4px)",animation:"fadeIn 0.2s ease"},children:o.jsxs("div",{onClick:R=>R.stopPropagation(),style:{width:"680px",maxHeight:"85vh",background:"var(--glass-surface)",borderRadius:"16px",boxShadow:"var(--cm-shadow-float)",display:"flex",flexDirection:"column",overflow:"hidden",animation:"slideUp 0.3s cubic-bezier(0.16, 1, 0.3, 1)",border:`1px solid ${f}`,backdropFilter:"blur(20px)"},children:[o.jsxs("div",{style:{padding:"24px 32px 0 32px",background:"var(--bg-highlight)"},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"20px"},children:[o.jsxs("div",{children:[o.jsx("h2",{style:{margin:0,fontSize:"20px",color:p},children:"工作流全局配置"}),o.jsx("p",{style:{margin:"4px 0 0 0",fontSize:"12px",color:h},children:d?"当前为只读模式":"配置工作流级属性,所有更改将实时保存"})]}),o.jsx("button",{className:"wsp-close",onClick:t,"aria-label":"关闭",style:{background:"none",border:"none",color:p,fontSize:"24px",cursor:"pointer",opacity:.6},children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${f}`},children:SI.map(R=>o.jsx("button",{className:"wsp-tab",onClick:()=>c(R.id),style:{padding:"10px 20px",fontSize:"13px",fontWeight:l===R.id?600:400,color:l===R.id?"var(--color-accent)":h,background:"none",border:"none",borderBottom:l===R.id?"2px solid var(--color-accent)":"2px solid transparent",cursor:"pointer",transition:"all 0.2s",marginBottom:"-1px"},children:R.label},R.id))})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",padding:"28px 32px"},children:M()}),o.jsx("div",{style:{padding:"20px 32px",borderTop:`1px solid ${f}`,background:"var(--bg-highlight)",display:"flex",justifyContent:"flex-end"},children:o.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:"完成并关闭"})})]})})},Ms="#ff6a13",jI=({size:e=26,className:t,style:r})=>o.jsxs("svg",{width:e,height:e,viewBox:"0 0 100 100",xmlns:"http://www.w3.org/2000/svg",className:t,style:{flexShrink:0,display:"inline-block",verticalAlign:"middle",...r},role:"img","aria-label":"CMASTER",children:[o.jsxs("g",{stroke:Ms,strokeWidth:"3",opacity:"0.7",children:[o.jsx("line",{x1:"50",y1:"50",x2:"75.5",y2:"24.5"}),o.jsx("line",{x1:"50",y1:"50",x2:"14",y2:"50"}),o.jsx("line",{x1:"50",y1:"50",x2:"75.5",y2:"75.5"})]}),o.jsx("path",{d:"M75.46 24.54A36 36 0 1 0 75.46 75.46",fill:"none",stroke:Ms,strokeWidth:"9",strokeLinecap:"round"}),o.jsxs("g",{stroke:Ms,strokeWidth:"5",style:{fill:"var(--cm-surface-1)"},children:[o.jsx("circle",{cx:"75.46",cy:"24.54",r:"7"}),o.jsx("circle",{cx:"14",cy:"50",r:"7"}),o.jsx("circle",{cx:"75.46",cy:"75.46",r:"7"})]}),o.jsx("circle",{cx:"50",cy:"50",r:"10",fill:Ms})]}),TI=({onRequestImport:e})=>{const{createBlankWorkflow:t}=te(Ae(i=>({createBlankWorkflow:i.createBlankWorkflow}))),[r,n]=T.useState(""),s=()=>{t(r||void 0),te.temporal.getState().clear()},a=()=>{t(r||void 0),te.temporal.getState().clear(),window.dispatchEvent(new CustomEvent("open-ai-chat"))};return o.jsxs("div",{className:"empty-state-panel",children:[o.jsx("div",{style:{marginBottom:12},children:o.jsx(jI,{size:46})}),o.jsx("h2",{className:"empty-state-title",children:"创建新工作流"}),o.jsx("p",{className:"empty-state-subtitle",children:"从空白画布开始设计,或让 AI 帮你生成完整流程"}),o.jsx("input",{className:"empty-state-name-input",type:"text",placeholder:"工作流名称(可选)",value:r,onChange:i=>n(i.target.value),onKeyDown:i=>{i.key==="Enter"&&s()}}),o.jsxs("div",{className:"empty-state-actions",children:[o.jsxs("button",{className:"empty-state-btn primary",onClick:s,children:[o.jsx("span",{className:"empty-state-btn-icon",children:o.jsx(Cu,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),"空白工作流"]}),o.jsxs("button",{className:"empty-state-btn",onClick:a,children:[o.jsx("span",{className:"empty-state-btn-icon",children:o.jsx(Pt,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),"AI 生成"]}),e&&o.jsxs("button",{className:"empty-state-btn",onClick:e,children:[o.jsx("span",{className:"empty-state-btn-icon",children:o.jsx(Cb,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),"导入 JSON"]})]})]})},II={success:{color:"var(--cm-status-success)",Icon:Cs},error:{color:"var(--cm-status-failed)",Icon:_u},info:{color:"var(--cm-text-secondary)",Icon:mb}},Wb=({messages:e,onDismiss:t})=>e.length===0?null:o.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=>o.jsx(NI,{message:r,onDismiss:t},r.id))}),NI=({message:e,onDismiss:t})=>{const{color:r,Icon:n}=II[e.type||"info"];return T.useEffect(()=>{const s=setTimeout(()=>t(e.id),2500);return()=>clearTimeout(s)},[e.id,t]),o.jsxs("div",{role:"status","aria-live":"polite",style:{display:"flex",alignItems:"center",gap:8,backgroundColor:"var(--cm-surface-2)",color:"var(--text-primary)",border:`1px solid color-mix(in srgb, ${r} 55%, transparent)`,padding:"10px 16px",borderRadius:"8px",fontSize:"13px",fontWeight:500,boxShadow:"var(--cm-shadow-float)",animation:"toastSlideUp 0.3s ease-out",pointerEvents:"auto",cursor:"pointer",whiteSpace:"nowrap"},onClick:()=>t(e.id),children:[o.jsx(n,{size:16,strokeWidth:1.75,"aria-hidden":"true",style:{color:r,flexShrink:0}}),e.text]})},zb=["shift","alt","meta","mod","ctrl","control"],CI={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 sr(e){return(CI[e.trim()]||e.trim()).toLowerCase().replace(/key|digit|numpad/,"")}function qb(e){return zb.includes(e)}function Ju(e,t=","){return e.toLowerCase().split(t)}function Uu(e,t="+",r=">",n=!1,s){let a=[],i=!1;e=e.trim(),e.includes(r)?(i=!0,a=e.toLocaleLowerCase().split(r).map(d=>sr(d))):a=e.toLocaleLowerCase().split(t).map(d=>sr(d));const l={alt:a.includes("alt"),ctrl:a.includes("ctrl")||a.includes("control"),shift:a.includes("shift"),meta:a.includes("meta"),mod:a.includes("mod"),useKey:n},c=a.filter(d=>!zb.includes(d));return{...l,keys:c,description:s,isSequence:i,hotkey:e}}typeof document<"u"&&(document.addEventListener("keydown",e=>{e.code!==void 0&&Fb([sr(e.code)])}),document.addEventListener("keyup",e=>{e.code!==void 0&&Bb([sr(e.code)])})),typeof window<"u"&&(window.addEventListener("blur",()=>{Ft.clear()}),window.addEventListener("contextmenu",()=>{setTimeout(()=>{Ft.clear()},0)}));const Ft=new Set;function Vu(e){return Array.isArray(e)}function EI(e,t=","){return(Vu(e)?e:e.split(t)).every(r=>Ft.has(r.trim().toLowerCase()))}function Fb(e){const t=Array.isArray(e)?e:[e];Ft.has("meta")&&Ft.forEach(r=>!qb(r)&&Ft.delete(r.toLowerCase())),t.forEach(r=>Ft.add(r.toLowerCase()))}function Bb(e){const t=Array.isArray(e)?e:[e];e==="meta"?Ft.clear():t.forEach(r=>Ft.delete(r.toLowerCase()))}function RI(e,t,r){(typeof r=="function"&&r(e,t)||r===!0)&&e.preventDefault()}function OI(e,t,r){return typeof r=="function"?r(e,t):r===!0||r===void 0}const PI=["input","textarea","select","searchbox","slider","spinbutton","menuitem","menuitemcheckbox","menuitemradio","option","radio","textbox"];function AI(e){return Hb(e,PI)}function Hb(e,t=!1){const{target:r,composed:n}=e;let s,a;return $I(r)&&n?(s=e.composedPath()[0]&&e.composedPath()[0].tagName,a=e.composedPath()[0]&&e.composedPath()[0].role):(s=r&&r.tagName,a=r&&r.role),Vu(t)?!!(s&&t&&t.some(i=>i.toLowerCase()===s.toLowerCase()||i===a)):!!(s&&t&&t)}function $I(e){return!!e.tagName&&!e.tagName.startsWith("-")&&e.tagName.includes("-")}function DI(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 LI=(e,t,r=!1)=>{const{alt:n,meta:s,mod:a,shift:i,ctrl:l,keys:c,useKey:d}=t,{code:u,key:p,ctrlKey:f,metaKey:m,shiftKey:h,altKey:y}=e,x=sr(u);if(d&&c?.length===1&&c.includes(p))return!0;if(!c?.includes(x)&&!["ctrl","control","unknown","meta","alt","shift","os"].includes(x))return!1;if(!r){if(n!==y&&x!=="alt"||i!==h&&x!=="shift")return!1;if(a){if(!m&&!f)return!1}else if(s!==m&&x!=="meta"&&x!=="os"||l!==f&&x!=="ctrl"&&x!=="control")return!1}return c&&c.length===1&&c.includes(x)?!0:c?EI(c):!c},MI=T.createContext(void 0),WI=()=>T.useContext(MI);function Jb(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&&Jb(e[n],t[n]),!0):e===t}const zI=T.createContext({hotkeys:[],activeScopes:[],toggleScope:()=>{},enableScope:()=>{},disableScope:()=>{}}),qI=()=>T.useContext(zI);function FI(e){const t=T.useRef(void 0);return Jb(t.current,e)||(t.current=e),t.current}const Ub=e=>{e.stopPropagation(),e.preventDefault(),e.stopImmediatePropagation()},BI=typeof window<"u"?T.useLayoutEffect:T.useEffect;function qr(e,t,r,n){const s=T.useRef(null),a=T.useRef(!1),i=Array.isArray(r)?Array.isArray(n)?void 0:n:r,l=Vu(e)?e.join(i?.delimiter):e,c=Array.isArray(r)?r:Array.isArray(n)?n:void 0,d=T.useCallback(t,c??[]),u=T.useRef(d);c?u.current=d:u.current=t;const p=FI(i),{activeScopes:f}=qI(),m=WI();return BI(()=>{if(p?.enabled===!1||!DI(f,p?.scopes))return;let h=[],y;const x=(b,S=!1)=>{if(!(AI(b)&&!Hb(b,p?.enableOnFormTags))){if(s.current!==null){const j=s.current.getRootNode();if((j instanceof Document||j instanceof ShadowRoot)&&j.activeElement!==s.current&&!s.current.contains(j.activeElement)){Ub(b);return}}b.target?.isContentEditable&&!p?.enableOnContentEditable||Ju(l,p?.delimiter).forEach(j=>{if(j.includes(p?.splitKey??"+")&&j.includes(p?.sequenceSplitKey??">")){console.warn(`Hotkey ${j} contains both ${p?.splitKey??"+"} and ${p?.sequenceSplitKey??">"} which is not supported.`);return}const _=Uu(j,p?.splitKey,p?.sequenceSplitKey,p?.useKey,p?.description);if(_.isSequence){y=setTimeout(()=>{h=[]},p?.sequenceTimeoutMs??1e3);const w=_.useKey?b.key:sr(b.code);if(qb(w.toLowerCase()))return;h.push(w);const I=_.keys?.[h.length-1];if(w!==I){h=[],y&&clearTimeout(y);return}h.length===_.keys?.length&&(u.current(b,_),y&&clearTimeout(y),h=[])}else if(LI(b,_,p?.ignoreModifiers)||_.keys?.includes("*")){if(p?.ignoreEventWhen?.(b)||S&&a.current)return;if(RI(b,_,p?.preventDefault),!OI(b,_,p?.enabled)){Ub(b);return}u.current(b,_),S||(a.current=!0)}})}},g=b=>{b.code!==void 0&&(Fb(sr(b.code)),(p?.keydown===void 0&&p?.keyup!==!0||p?.keydown)&&x(b))},v=b=>{b.code!==void 0&&(Bb(sr(b.code)),a.current=!1,p?.keyup&&x(b,!0))},k=s.current||i?.document||document;return k.addEventListener("keyup",v,i?.eventListenerOptions),k.addEventListener("keydown",g,i?.eventListenerOptions),m&&Ju(l,p?.delimiter).forEach(b=>m.addHotkey(Uu(b,p?.splitKey,p?.sequenceSplitKey,p?.useKey,p?.description))),()=>{k.removeEventListener("keyup",v,i?.eventListenerOptions),k.removeEventListener("keydown",g,i?.eventListenerOptions),m&&Ju(l,p?.delimiter).forEach(b=>m.removeHotkey(Uu(b,p?.splitKey,p?.sequenceSplitKey,p?.useKey,p?.description))),h=[],y&&clearTimeout(y)}},[l,p,f]),s}const HI=e=>{const{mode:t,removeNode:r,selectedTask:n,pasteTask:s,copyTask:a}=te(Ae(m=>({mode:m.mode,removeNode:m.removeNode,selectedTask:m.selectedTask,pasteTask:m.pasteTask,copyTask:m.copyTask}))),i=te.temporal,{undo:l,redo:c}=ga(i,m=>m),d=e?.confirm||(m=>Promise.resolve(window.confirm(m))),u=e?.showToast,p=m=>{const h=m.target;return h.tagName==="INPUT"||h.tagName==="TEXTAREA"||h.isContentEditable},f=()=>{requestAnimationFrame(()=>{const m=te.getState(),{nodes:h,edges:y}=pt(m.nodes,m.edges,{direction:m.layoutDirection,mode:m.mode});te.setState({nodes:h,edges:y})})};return qr("mod+z",m=>{t==="edit"&&(p(m)||(m.preventDefault(),l(),f()))},[t,l]),qr(["mod+shift+z","mod+y"],m=>{t==="edit"&&(p(m)||(m.preventDefault(),c(),f()))},[t,c]),qr("delete, backspace",m=>{if(t!=="edit"||!n||p(m))return;m.preventDefault();const h=n.taskReferenceName,{message:y}=uu(te.getState().workflowDef,h);d(y,"删除").then(x=>{x&&r(h)})},[t,n,r,d]),qr("mod+c",m=>{if(!(t!=="edit"||!n)&&!p(m)){if(n.type==="JOIN"){u?.("JOIN 任务不能独立复制","error");return}m.preventDefault(),a(JSON.parse(JSON.stringify(n))),u?.("任务已复制","success")}},[t,n,a,u]),qr("mod+v",m=>{if(t!=="edit"||p(m))return;m.preventDefault();const h=te.getState().copiedTask;if(!h){u?.("剪贴板里没有任务:先选中一个任务按 ⌘C 复制","info");return}s(h),u?.("任务已粘贴","success")},[t,s,u]),qr("mod+s",m=>{m.preventDefault();const h=te.getState().getEditingWorkflowDef();if(!h){u?.("没有可保存的工作流:请先打开或新建一个工作流","info");return}if(!e?.onSave){u?.("当前页面没有接入保存(未提供 onSave):修改只保留在画布中,请导出 JSON 保存","info");return}try{e.onSave(h),u?.("已交给宿主保存","success")}catch(y){u?.(`保存失败:${y?.message||"宿主保存回调出错"},请稍后重试`,"error")}},{enableOnFormTags:!0,enableOnContentEditable:!0},[e?.onSave,u]),{}},xn=()=>{const[e,t]=T.useState(null),r=T.useCallback((a,i)=>new Promise(l=>{t({message:a,confirmLabel:i,resolve:l})}),[]),n=T.useCallback(()=>{e?.resolve(!0),t(null)},[e]),s=T.useCallback(()=>{e?.resolve(!1),t(null)},[e]);return{confirm:r,confirmState:e,handleConfirm:n,handleCancel:s}},Vb=()=>{const[e,t]=T.useState([]),r=T.useCallback((s,a="info")=>{const i=Date.now().toString();t(l=>[...l,{id:i,text:s,type:a}])},[]),n=T.useCallback(s=>{t(a=>a.filter(i=>i.id!==s))},[]);return{toasts:e,showToast:r,dismissToast:n}},Ku={id:"welcome",role:"assistant",content:`你好!我是 AI 工作流助手。
|
|
37
39
|
|
|
38
40
|
我可以帮你:
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
42
|
-
-
|
|
41
|
+
- **从零创建**工作流(描述业务场景即可)
|
|
42
|
+
- **添加 / 修改 / 删除**任务节点
|
|
43
|
+
- **重构拓扑**(如串行改并行)
|
|
44
|
+
- **诊断问题**和优化建议
|
|
45
|
+
|
|
46
|
+
直接告诉我你想做什么吧!`,timestamp:Date.now()},JI=()=>(e,t)=>({config:{provider:"auto",apiKey:""},messages:[Ku],isStreaming:!1,streamingText:"",chatPanelOpen:!0,pendingProposal:null,pendingPlan:null,pendingRepair:null,followUpChips:null,undoStack:[],pendingClarification:null,pendingRecommendation:null,pendingAutoSend:null,toolStatus:"",retryInput:null,retryModelText:null,timelineEntries:[],synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null,pendingSend:null,metrics:{totalProposals:0,acceptedProposals:0,rejectedProposals:0,totalPromptTokens:0,totalCompletionTokens:0},setConfig:r=>e(n=>({config:{...n.config,...r}})),addMessage:r=>{const n=`msg_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,s={...r,id:n,timestamp:Date.now()};return e(a=>({messages:[...a.messages,s]})),n},updateMessage:(r,n)=>e(s=>({messages:s.messages.map(a=>a.id===r?{...a,content:n}:a)})),setStreaming:r=>e({isStreaming:r}),setStreamingText:r=>e({streamingText:r}),appendStreamingText:r=>e(n=>({streamingText:n.streamingText+r})),clearMessages:()=>e({messages:[Ku],streamingText:"",isStreaming:!1,pendingProposal:null,pendingPlan:null,pendingRepair:null,followUpChips:null,pendingClarification:null,pendingRecommendation:null,pendingAutoSend:null,toolStatus:"",retryInput:null,retryModelText:null,timelineEntries:[],synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null,pendingSend:null}),setChatPanelOpen:r=>e({chatPanelOpen:r}),toggleChatPanel:()=>e(r=>({chatPanelOpen:!r.chatPanelOpen})),setProposal:r=>{const n=`prop_${Date.now()}`,s=te.getState().workflowDef,a=JSON.stringify(s);return e(i=>({pendingProposal:{...r,id:n,baselineHash:a},metrics:{...i.metrics,totalProposals:i.metrics.totalProposals+1}})),n},clearProposal:()=>e({pendingProposal:null}),recordAccept:()=>e(r=>({metrics:{...r.metrics,acceptedProposals:r.metrics.acceptedProposals+1},pendingProposal:null,synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null})),recordReject:()=>e(r=>({metrics:{...r.metrics,rejectedProposals:r.metrics.rejectedProposals+1},pendingProposal:null,synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null})),getMetrics:()=>t().metrics,recordUsage:r=>e(n=>({metrics:{...n.metrics,totalPromptTokens:n.metrics.totalPromptTokens+(r.promptTokens??0),totalCompletionTokens:n.metrics.totalCompletionTokens+(r.completionTokens??0)}})),setFollowUpChips:r=>e({followUpChips:r}),clearFollowUpChips:()=>e({followUpChips:null}),setPlan:r=>{const n=`plan_${Date.now()}`;return e({pendingPlan:{...r,id:n}}),n},clearPlan:()=>e({pendingPlan:null}),setRepair:r=>{const n=`repair_${Date.now()}`;return e({pendingRepair:{...r,id:n}}),n},clearRepair:()=>e({pendingRepair:null}),pushUndo:r=>e(n=>({undoStack:[...n.undoStack.slice(-4),r]})),popUndo:()=>{const r=t().undoStack;if(r.length===0)return null;const n=r[r.length-1];return e({undoStack:r.slice(0,-1)}),n},clearUndo:()=>e({undoStack:[]}),canUndo:()=>t().undoStack.length>0,setClarification:r=>{const n=`clarif_${Date.now()}`;return e({pendingClarification:{...r,id:n}}),n},clearClarification:()=>e({pendingClarification:null}),setRecommendation:r=>{const n=`rec_${Date.now()}`;return e({pendingRecommendation:{...r,id:n}}),n},clearRecommendation:()=>e({pendingRecommendation:null}),setPendingAutoSend:r=>e({pendingAutoSend:r}),setToolStatus:r=>e({toolStatus:r}),setRetryInput:(r,n=null)=>e({retryInput:r,retryModelText:r?n:null}),addTimelineEntry:(r,n="done")=>e(s=>({timelineEntries:[...s.timelineEntries,{id:`tl_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,label:r,icon:n}]})),clearTimeline:()=>e({timelineEntries:[]}),setSynthesisStage:(r,n)=>e(s=>({synthesisPhase:r,workingDraft:n!==void 0?n:s.workingDraft})),saveCheckpoint:r=>e({durableCheckpoint:r}),clearCheckpoint:()=>e({durableCheckpoint:null,synthesisPhase:"idle",workingDraft:null,pendingSend:null}),setPendingSend:r=>e({pendingSend:r}),hydrateFromDraft:(r,n,s)=>e({messages:r.length>0?r:[Ku],pendingProposal:n,durableCheckpoint:s?s.status==="running"?{...s,status:"paused"}:s:null,synthesisPhase:s?.phase??"idle",workingDraft:s?.workingDraft??null})});function Kb(e){const t={};return!e||typeof e!="object"||((e.provider==="openai"||e.provider==="anthropic"||e.provider==="auto")&&(t.provider=e.provider),typeof e.baseUrl=="string"&&e.baseUrl&&(t.baseUrl=e.baseUrl),typeof e.model=="string"&&e.model&&(t.model=e.model)),t}function UI(e,t){const r=e??{};return{...t,config:{...t.config,...Kb(r.config)},metrics:r.metrics?{...t.metrics,...r.metrics}:t.metrics}}function VI(e="ai-workflow-config"){const t=JI();return e===!1?Gn()(t):Gn()(Qp(t,{name:e,storage:xa(()=>localStorage),partialize:r=>({config:Kb(r.config),metrics:r.metrics}),merge:(r,n)=>UI(r,n)}))}const vn=VI(),KI=T.createContext(null);function Gb(){return T.useContext(KI)}const GI=()=>{const{mode:e,showWaterfallPanel:t,setShowWaterfallPanel:r,workflowInstance:n,executionData:s,taskMap:a,selectedTask:i,setSelectedTask:l,setSelectedTaskInstance:c,timeTravelTimestamp:d,setTimeTravelTimestamp:u}=te(Ae(v=>({mode:v.mode,showWaterfallPanel:v.showWaterfallPanel,setShowWaterfallPanel:v.setShowWaterfallPanel,workflowInstance:v.workflowInstance,executionData:v.executionData,taskMap:v.taskMap,selectedTask:v.selectedTask,setSelectedTask:v.setSelectedTask,setSelectedTaskInstance:v.setSelectedTaskInstance,timeTravelTimestamp:v.timeTravelTimestamp,setTimeTravelTimestamp:v.setTimeTravelTimestamp}))),p=T.useMemo(()=>{const v=n?.tasks?.length?n.tasks:s?Object.values(s).flatMap(N=>N.attempts):[];if(v.length===0)return null;const k=v.filter(N=>N.startTime||N.scheduledTime);if(k.length===0)return null;const b=Math.min(...k.map(N=>N.scheduledTime||N.startTime||Date.now())),S=Math.max(...k.map(N=>N.endTime||N.startTime||N.scheduledTime||b+100)),j=Math.max(S-b,50),_=k.filter(N=>!["FORK_JOIN","JOIN","DO_WHILE","SWITCH","DECISION"].includes(N.taskType)).map(N=>Math.max((N.endTime||S)-(N.startTime||N.scheduledTime||b),0)).sort((N,C)=>C-N),w=_.length>0?Math.max(_[Math.floor(_.length*.25)]||80,50):100,I=k.map((N,C)=>{const M=N.scheduledTime||N.startTime||b,R=N.startTime||M,O=N.endTime||S,$=Math.max(R-M,0),B=Math.max(O-R,1),q=!["FORK_JOIN","JOIN","DO_WHILE","SWITCH","DECISION"].includes(N.taskType)&&B>=w,F=(M-b)/j*100,A=$/j*100,W=(R-b)/j*100,P=Math.max(B/j*100,1.2);return{key:N.taskId||`${N.referenceTaskName}-${C}`,task:N,sched:M,start:R,end:O,queueMs:$,execMs:B,isCritical:q,queueLeftPct:F,queueWidthPct:A,execLeftPct:W,execWidthPct:P}});return{minTime:b,maxTime:S,totalSpanMs:j,rows:I}},[n,s]);if(e!=="run"||!t||!p)return null;const{minTime:f,totalSpanMs:m,rows:h}=p,y=d!==null?d-f:m,x=Math.min(Math.max(y/m*100,0),100),g=v=>He(v).color;return o.jsxs("div",{style:{position:"absolute",left:16,right:i?466:16,bottom:16,height:255,zIndex:1100,background:"color-mix(in srgb, var(--cm-surface-1) 95%, transparent)",backdropFilter:"blur(16px)",border:"1px solid color-mix(in srgb, var(--cm-data) 30%, transparent)",borderRadius:12,boxShadow:"var(--cm-shadow-float)",display:"flex",flexDirection:"column",overflow:"hidden",transition:"right 0.25s ease"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 14px",borderBottom:"1px solid var(--border-primary)",background:"var(--cm-overlay)",flexShrink:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsxs("span",{style:{fontSize:12,fontWeight:700,color:"var(--text-primary)"},children:[o.jsx(Ns,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"并发执行瀑布流 & 时间旅行调试器"]}),o.jsxs("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:999,background:"color-mix(in srgb, var(--cm-data) 14%, transparent)",color:"var(--cm-data)",fontFamily:"monospace",fontWeight:600},children:["总跨度 ",m,"ms · ",h.length," 个任务步"]}),o.jsxs("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:999,background:"color-mix(in srgb, var(--color-accent) 15%, transparent)",color:"var(--color-accent)",fontWeight:600},children:[o.jsx(Eu,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"关键路径耗时瓶颈高亮"]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1,maxWidth:420},children:[o.jsxs("span",{style:{fontSize:10,color:"var(--text-muted)",whiteSpace:"nowrap"},children:[o.jsx(_T,{size:12,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"时间旅行指针:"]}),o.jsx("input",{type:"range",min:0,max:m,value:y,onChange:v=>{const k=Number(v.target.value);k>=m?u(null):u(f+k)},style:{flex:1,cursor:"pointer",accentColor:"var(--cm-data)"}}),o.jsx("span",{style:{fontSize:11,fontFamily:"monospace",color:d!==null?"var(--cm-status-warning)":"var(--cm-status-success)",fontWeight:700,minWidth:74,textAlign:"right"},children:d!==null?`+${y}ms`:"最新态 (Live)"}),d!==null&&o.jsx("button",{type:"button",onClick:()=>u(null),style:{fontSize:10,padding:"2px 7px",borderRadius:4,border:"1px solid color-mix(in srgb, var(--cm-status-warning) 40%, transparent)",background:"color-mix(in srgb, var(--cm-status-warning) 12%, transparent)",color:"var(--cm-status-warning)",cursor:"pointer"},children:"重置"})]}),o.jsx("button",{type:"button",onClick:()=>r(!1),style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:15,padding:"2px 6px"},children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",position:"relative",padding:"6px 0"},children:h.map(v=>{const k=v.task.referenceTaskName.replace(/__\d+$/,""),b=i?.taskReferenceName===k,S=d!==null&&v.start>d,j=d!==null&&v.start<=d&&v.end>d;return o.jsxs("div",{onClick:()=>{const _=a[k]||v.task.workflowTask;_&&(l(_),c(v.task))},style:{display:"grid",gridTemplateColumns:"210px 1fr 90px",alignItems:"center",gap:8,padding:"4px 14px",cursor:"pointer",background:b?"color-mix(in srgb, var(--cm-data) 14%, transparent)":"transparent",opacity:S?.35:1,borderLeft:b?"3px solid var(--cm-data)":"3px solid transparent"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:[(()=>{const _=He(j?"IN_PROGRESS":v.task.status),w=_.icon;return o.jsx("span",{role:"img","aria-label":`状态:${_.label}`,title:_.label,style:{display:"inline-flex",color:_.color,flexShrink:0},children:o.jsx(w,{size:12,strokeWidth:1.75,"aria-hidden":"true"})})})(),o.jsx("span",{style:{fontSize:11,fontFamily:"monospace",color:"var(--text-primary)",fontWeight:b?700:500,overflow:"hidden",textOverflow:"ellipsis"},title:v.task.referenceTaskName,children:v.task.referenceTaskName}),v.isCritical&&o.jsxs("span",{title:"关键路径耗时瓶颈节点",style:{fontSize:9,padding:"1px 4px",borderRadius:4,background:"color-mix(in srgb, var(--color-accent) 20%, transparent)",color:"var(--color-accent)",fontWeight:700,flexShrink:0},children:[o.jsx(Eu,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"瓶颈"]})]}),o.jsxs("div",{style:{position:"relative",height:14,background:"var(--cm-overlay)",borderRadius:4,overflow:"hidden",border:"1px solid var(--border-primary)"},children:[v.queueWidthPct>.3&&o.jsx("div",{title:`排队等待: ${v.queueMs}ms`,style:{position:"absolute",left:`${v.queueLeftPct}%`,width:`${v.queueWidthPct}%`,top:3,bottom:3,background:"color-mix(in srgb, var(--cm-text-muted) 35%, transparent)",borderRadius:"2px 0 0 2px"}}),o.jsx("div",{title:`执行耗时: ${v.execMs}ms (排队 ${v.queueMs}ms)`,style:{position:"absolute",left:`${v.execLeftPct}%`,width:`${v.execWidthPct}%`,top:2,bottom:2,borderRadius:3,background:v.isCritical?"linear-gradient(90deg, var(--color-accent), var(--cm-status-failed))":g(v.task.status),boxShadow:j?"0 0 8px color-mix(in srgb, var(--cm-data) 80%, transparent)":void 0}}),d!==null&&o.jsx("div",{style:{position:"absolute",left:`${x}%`,top:0,bottom:0,width:2,background:"var(--cm-status-warning)",pointerEvents:"none"}})]}),o.jsxs("div",{style:{fontSize:10,fontFamily:"monospace",color:v.isCritical?"var(--color-accent)":"var(--text-muted)",textAlign:"right",fontWeight:v.isCritical?700:400},children:[v.task.status!=="COMPLETED"&&!j?o.jsx("span",{style:{color:g(v.task.status),marginRight:4},children:He(v.task.status).label}):null,v.execMs,"ms",v.queueMs>0?o.jsxs("span",{style:{opacity:.6,fontSize:9},children:[" (+",v.queueMs,"q)"]}):null]})]},v.key)})})]})};function YI(){return Gn(e=>({items:[],setLibrary:t=>e({items:t}),clearLibrary:()=>e({items:[]})}))}const XI=YI();function Gu(e){return(Array.isArray(e.type)?e.type.find(r=>r!=="null"):e.type)||"string"}function Yu(e){if(!e||e.type&&e.type!=="JSON")return null;const t=e.data;if(!t||typeof t!="object")return null;const r=t.properties;return!r||typeof r!="object"?null:{properties:r,required:Array.isArray(t.required)?t.required:[]}}function ZI(e,t,r,n){const s=Gu(t),a={key:e,label:t.title||e,type:"text",help:t.description,required:r,defaultValue:t.default!==void 0?t.default:n,placeholder:Array.isArray(t.examples)&&t.examples.length>0?String(t.examples[0]):void 0,acceptsPills:!0};return Array.isArray(t.enum)&&t.enum.length>0?{...a,type:"select",options:t.enum.map(i=>({label:String(i),value:i})),acceptsPills:!0}:s==="boolean"?{...a,type:"boolean",acceptsPills:!1}:s==="number"||s==="integer"?{...a,type:"number"}:s==="object"||s==="array"?{...a,type:"textarea",help:[t.description,"JSON 格式"].filter(Boolean).join(";")}:t.format==="textarea"||typeof t.maxLength=="number"&&t.maxLength>200?{...a,type:"textarea"}:a}function Ws(e,t,r){const n=Yu(e);return n?Object.entries(n.properties).map(([a,i])=>ZI(a,i||{},n.required.includes(a),r?.[a])):Array.from(new Set([...t,...Object.keys(r||{})])).map(a=>({key:a,label:a,type:"text",defaultValue:r?.[a],acceptsPills:!0}))}function QI(e){return Array.isArray(e)?"array":typeof e=="number"?"number":typeof e=="boolean"?"boolean":e&&typeof e=="object"?"object":"string"}function Xu(e){switch(e){case"number":return 0;case"boolean":return!0;case"array":return[];case"object":return{};default:return"sample"}}function bn(e,t,r){const n=Yu(e);return n?Object.entries(n.properties).map(([a,i])=>{const l=Gu(i||{}),c=l==="integer"?"number":["string","number","boolean","object","array"].includes(l)?l:"string";return{key:a,label:i?.title||a,type:c,description:i?.description,example:Array.isArray(i?.examples)&&i.examples.length>0?i.examples[0]:Xu(c)}}):Array.from(new Set([...t,...Object.keys(r||{})])).map(a=>{const i=r?.[a],l=typeof i=="string"&&i.includes("${"),c=l||i===void 0?"string":QI(i);return{key:a,label:a,type:c,example:l||i===void 0?Xu(c):i}})}function zs(e,t){return t?e.map(r=>t[r.key]?{...r,...t[r.key],key:r.key}:r):e}function Yb(e,t,r){const n={},s=new Set(t.map(a=>a.key));for(const[a,i]of Object.entries(e||{})){if(!s.has(a)||typeof i!="string"||i.includes("${")){n[a]=i;continue}const l=r[a];if(l==="number"||l==="integer")n[a]=i.trim()!==""&&!Number.isNaN(Number(i))?Number(i):i;else if(l==="object"||l==="array")try{n[a]=JSON.parse(i)}catch{n[a]=i}else n[a]=i}return n}function Xb(e){const t=Yu(e),r={};if(t)for(const[n,s]of Object.entries(t.properties))r[n]=Gu(s||{});return r}function Zb(e){const t={};for(const r of e)t[r.key]=r.example!==void 0?r.example:Xu(r.type);return t}function Zu(e,t={}){if(t.hidden)return null;const r=St(e.inputParameters).map(l=>l.name),n=zs(Ws(e.inputSchema,r,e.inputTemplate),t.fieldOverrides),s=zs(bn(e.outputSchema,[],e.outputParameters),t.outputOverrides),a=Xb(e.inputSchema),i=e.version??1;return{id:`wf.${e.name}`,name:t.label||e.name,category:t.category||"custom",icon:t.icon||"puzzle",description:t.description||e.description||"",connector:t.connector,kind:"workflow",workflowRef:{name:e.name,version:i},level:t.level,...t.domain?{domain:t.domain}:{},tags:t.tags,ownerEmail:e.ownerEmail,riskLevel:t.riskLevel||"safe",fields:n,outputs:s,compile:(l,c)=>{const d=c.libraryRef?.name===e.name?c.libraryRef.version:void 0;return{name:e.name,taskReferenceName:c.taskReferenceName,type:"SUB_WORKFLOW",description:t.label||e.description,inputParameters:Yb(l,n,a),subWorkflowParam:{name:e.name,...d!==void 0?{version:d}:{}}}},decompile:l=>l.type==="SUB_WORKFLOW"&&l.subWorkflowParam?.name===e.name?{...l.inputParameters||{}}:null,mockOutput:()=>Zb(s)}}function Qu(e,t={}){if(t.hidden)return null;const r=zs(Ws(e.inputSchema,e.inputKeys||[],e.inputTemplate),t.fieldOverrides),n=zs(bn(e.outputSchema,e.outputKeys||[]),t.outputOverrides),s=Xb(e.inputSchema);return{id:`task.${e.name}`,name:t.label||e.name,category:t.category||"custom",icon:t.icon||"settings",description:t.description||e.description||"",connector:t.connector,kind:"task",level:t.level,...t.domain?{domain:t.domain}:{},tags:t.tags,ownerEmail:e.ownerEmail,riskLevel:t.riskLevel||"safe",fields:r,outputs:n,compile:(a,i)=>({name:e.name,taskReferenceName:i.taskReferenceName,type:"SIMPLE",description:t.label||e.description,inputParameters:Yb(a,r,s)}),decompile:a=>a.type==="SIMPLE"&&a.name===e.name?{...a.inputParameters||{}}:null,mockOutput:()=>Zb(n)}}function eN(e){return e.map(t=>Zu(t.workflowDef,t.extension)).filter(t=>t!==null)}function tN(e){return e.map(t=>Qu(t.taskDef,t.extension)).filter(t=>t!==null)}const Qb={L1:1,L2:2,L3:3};function ek(e,t){return!e||!t?!0:Qb[t]<=Qb[e]}const rN=["compute","storage","network","monitor","notify","logic","human","custom"];function ep(e){if(!e)return{};const t=rN.includes(e.category)?e.category:void 0;return{...e.displayName?{label:e.displayName}:{},...t?{category:t}:{},...e.icon?{icon:e.icon}:{},...e.level?{level:e.level}:{},...e.domain?{domain:e.domain}:{},...e.tags?{tags:e.tags}:{},...e.action??{}}}function tk(e){const t=[];for(const r of e.entries()){if(r.source!=="provider")continue;const n={...r.record.def,version:r.version},s=Zu(n,{...r.level?{level:r.level}:{},...r.domain?{domain:r.domain}:{},...ep(r.record.extension)});s&&t.push(r.deprecated?{...s,deprecated:!0}:s)}for(const r of e.tasks()){const n=Qu(r.def,ep(r.extension));n&&t.push(n)}return t}function rk(e){if(!e||typeof e!="object")return"string";if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum.map(r=>String(r)).join("|");const t=Array.isArray(e.type)?e.type.find(r=>r!=="null"):e.type;return t==="array"?`${e.items&&typeof e.items=="object"?rk(e.items):"any"}[]`:t||"string"}function kn(e){if(!e||e.type&&e.type!=="JSON")return;const t=e.data&&typeof e.data=="object"?e.data.properties:void 0;if(!t||typeof t!="object")return;const r={};for(const[n,s]of Object.entries(t))r[n]=rk(s);return Object.keys(r).length>0?r:void 0}function qs(e){const t=Array.from(new Set(e));if(t.length!==0)return Object.fromEntries(t.map(r=>[r,"string"]))}function nN(e){const t=[];for(const s of e.tasks()){const a=s.def;t.push({taskName:a.name,taskType:"SIMPLE",description:a.description,inputSchema:kn(a.inputSchema)??qs([...a.inputKeys??[],...Object.keys(a.inputTemplate??{})]),outputSchema:kn(a.outputSchema)??qs(a.outputKeys??[])})}for(const s of e.entries()){if(s.source!=="provider"||s.deprecated)continue;const a=s.record.def;t.push({taskName:s.name,taskType:"SUB_WORKFLOW",description:a.description,inputSchema:kn(a.inputSchema)??qs(St(a.inputParameters).map(i=>i.name)),outputSchema:kn(a.outputSchema)??qs(Object.keys(a.outputParameters??{}))})}const r=new Set(t.map(s=>s.taskName));return[...e.staticTaskSchemas().filter(s=>!r.has(s.taskName)),...t]}function sN(e){return tp(e.entries())}function tp(e){return e.filter(t=>!t.deprecated).map(t=>({workflowName:t.name,workflowLevel:t.level??"L1",version:t.source==="static"?t.versionLabel??String(t.version):String(t.version),...t.domain?{domain:t.domain}:{},description:t.description??"",tags:t.tags}))}function nk(e,t={}){return e.filter(r=>!(r.deprecated||t.currentLevel&&r.kind==="workflow"&&!ek(t.currentLevel,r.level)))}const Fs="其他";function Bs(e){return e.domain?e.domain:e.kind==="workflow"?Fs:null}function sk(e){if(!e.some(n=>!!n.domain))return[];const t=[];let r=!1;for(const n of e){const s=Bs(n);s!==null&&(s===Fs?r=!0:t.includes(s)||t.push(s))}return r?[...t,Fs]:t}function aN(e){return e?.name==="AbortError"?"请求已取消":e instanceof TypeError?"无法连接 AI 代理服务,请检查网络或 endpoint 配置":e?.message||"请求失败"}async function*oN(e,t,r){let n;try{n=await fetch(e.url,{method:"POST",headers:{"Content-Type":"application/json",...e.headers??{}},body:JSON.stringify(t),signal:r})}catch(c){yield{type:"error",message:aN(c)},yield{type:"done"};return}if(!n.ok){const c=await n.text().catch(()=>"");let d=`HTTP ${n.status}`;try{const u=JSON.parse(c),p=u.error?.message||u.message;p&&(d=`${d}: ${p}`)}catch{}yield{type:"error",message:d},yield{type:"done"};return}const s=n.body?.getReader();if(!s){yield{type:"error",message:"ReadableStream not supported"},yield{type:"done"};return}const a=new TextDecoder;let i="";try{for(;;){const{done:c,value:d}=await s.read();if(c)break;i+=a.decode(d,{stream:!0});const u=i.split(`
|
|
47
|
+
|
|
48
|
+
`);i=u.pop()??"";for(const p of u){const f=p.trim();if(!f.startsWith("data:"))continue;const m=f.slice(5).trim();if(m)try{yield JSON.parse(m)}catch{}}}}finally{s.cancel().catch(()=>{})}const l=i.trim();if(l.startsWith("data:")){const c=l.slice(5).trim();if(c)try{yield JSON.parse(c)}catch{}}}const ak="DIRECT_FETCH_FAILED";function Hs(e,t={}){const r=e||"未知错误",n=r.toLowerCase(),a=(t.mode??"direct")==="direct";return/\b401\b/.test(r)||n.includes("unauthorized")||n.includes("invalid api key")||n.includes("incorrect api key")||n.includes("invalid x-api-key")||n.includes("authentication fail")||n.includes("authentication_error")||n.includes("invalid_api_key")?{display:a?"API Key 无效或已过期,AI 服务拒绝了请求。请在 AI 设置中检查 API Key 是否完整、是否属于当前服务商(Base URL),然后重试。":"AI 代理服务未通过鉴权。请联系管理员检查代理服务的登录状态或鉴权配置。",raw:r}:/\b402\b/.test(r)||n.includes("insufficient balance")||n.includes("insufficient_quota")||n.includes("exceeded your current quota")||n.includes("credit balance is too low")||n.includes("余额不足")?{display:a?"AI 服务账户余额或额度不足。请到服务商控制台充值或提高额度,或在 AI 设置中换一个可用的 API Key。":"AI 服务账户余额或额度不足。请联系管理员为代理服务使用的账户充值。",raw:r}:n.includes("model_not_found")||/model .*(does not exist|not found)/.test(n)||/the model .* does not exist/.test(n)||n.includes("not_found_error")&&n.includes("model")||/\bmodel:\s/.test(n)||n.includes("unknown model")||n.includes("model not exist")?{display:a?"找不到所配置的模型,或当前 API Key 无权使用它。请在 AI 设置中检查模型名称(留空则使用服务商默认模型)。":"代理服务找不到所配置的模型。请联系管理员检查代理服务的模型配置。",raw:r}:/\b404\b/.test(r)?{display:a?"AI 服务地址不存在(404)。请在 AI 设置中检查 Base URL 是否正确(OpenAI 兼容服务通常以 /v1 结尾)。":"AI 代理服务地址不存在(404)。请联系管理员检查 endpoint 配置。",raw:r}:n.includes("temperature")&&(n.includes("unsupported")||n.includes("not support")||n.includes("does not support"))?{display:"当前模型不支持自定义 temperature 参数。请在 AI 设置中换用其他模型;如使用代理服务,请让管理员在代理中去掉该参数。",raw:r}:/\b403\b/.test(r)||n.includes("forbidden")||n.includes("permission_error")?{display:a?"AI 服务拒绝了此次请求(没有权限)。请确认 API Key 有权访问该模型和地区,或在 AI 设置中更换 API Key。":"AI 代理服务拒绝了此次请求。请联系管理员检查你的使用权限。",raw:r}:/\b429\b/.test(r)||n.includes("rate limit")||n.includes("too many requests")||n.includes("rate_limit")?{display:"请求过于频繁,AI 服务暂时限流。请等待片刻后点击重试。",raw:r}:n.includes("timeout")||n.includes("timed out")?{display:"连接 AI 服务超时。请检查网络后重试。",raw:r}:r.startsWith(ak)?{display:"浏览器无法连接到 AI 服务:可能是网络不通、Base URL 填写有误,或该服务不允许浏览器直接访问(跨域 CORS 限制)。请检查 Base URL 与网络;若服务不支持浏览器直连,请改用集成方后端代理(transport: endpoint)。",raw:r}:n.includes("failed to fetch")||n.includes("networkerror")||n.includes("network error")||n.includes("无法连接")||n.includes("load failed")?{display:a?"无法连接 AI 服务:可能是网络不通,或该服务不允许浏览器直接访问(跨域 CORS 限制)。请检查网络和 Base URL 后重试。":"无法连接 AI 代理服务。请检查网络后重试;如持续出现,请联系管理员确认代理服务地址。",raw:r}:/\b5\d{2}\b/.test(r)||n.includes("internal server error")||n.includes("bad gateway")||n.includes("service unavailable")||n.includes("overloaded")?{display:"AI 服务暂时不可用。请稍后点击重试。",raw:r}:{display:"AI 服务返回了无法识别的错误。请点击重试;如持续出现,请联系管理员并提供错误时间。",raw:r}}const iN={openai:{baseUrl:"https://api.openai.com/v1",model:"gpt-4o"},anthropic:{baseUrl:"https://api.anthropic.com",model:"claude-sonnet-4-6"}};function rp(e){let t;!e.provider||e.provider==="auto"?t=e.baseUrl?.includes("anthropic")?"anthropic":"openai":t=e.provider;const r=iN[t];return{provider:t,apiKey:e.apiKey,baseUrl:e.baseUrl?.replace(/\/$/,"")||r.baseUrl,model:e.model||r.model,resolvedProvider:t}}function lN(e){return!/(^|\/)(o\d|gpt-5)/i.test(e.trim())}async function ok(e){const t=await e.text().catch(()=>"");let r="";try{const n=JSON.parse(t);r=n?.error?.message||n?.message||(typeof n?.error=="string"?n.error:"")||(n?.error?.type?String(n.error.type):"")}catch{r=t.slice(0,300)}return r||(r=e.statusText),`HTTP ${e.status}${r?`: ${r}`:""}`}async function ik(e,t){try{return await fetch(e,t)}catch(r){if(r?.name==="AbortError")throw r;return{failed:`${ak}: ${r?.message??String(r)}`}}}function cN(e){return e.map(t=>{if(t.role==="assistant"&&t.tool_calls?.length)return{role:"assistant",content:t.content||null,tool_calls:t.tool_calls.map(n=>({id:n.id,type:"function",function:{name:n.name,arguments:JSON.stringify(n.args)}}))};const r={role:t.role,content:t.content};return t.tool_call_id&&(r.tool_call_id=t.tool_call_id),r})}function dN(e){const t=e.filter(s=>s.role!=="system").map(s=>{if(s.role==="tool")return{_kind:"tool_result",tool_use_id:s.tool_call_id??"",content:s.content};if(s.role==="assistant"&&s.tool_calls?.length){const a=[];return s.content&&a.push({type:"text",text:s.content}),s.tool_calls.forEach(i=>a.push({type:"tool_use",id:i.id,name:i.name,input:i.args})),{_kind:"msg",role:"assistant",content:a}}return{_kind:"msg",role:s.role==="assistant"?"assistant":"user",content:s.content}}),r=[];let n=0;for(;n<t.length;){const s=t[n];if(s._kind==="tool_result"){const a=[{type:"tool_result",tool_use_id:s.tool_use_id,content:s.content}];for(;n+1<t.length&&t[n+1]._kind==="tool_result";){n++;const i=t[n];a.push({type:"tool_result",tool_use_id:i.tool_use_id,content:i.content})}r.push({role:"user",content:a})}else r.push({role:s.role,content:s.content});n++}return r}async function*uN(e,t,r,n){const s=rp(r),a={model:s.model,messages:cN(e),stream:!0,stream_options:{include_usage:!0}};lN(s.model)&&(a.temperature=.7),t.length>0&&(a.tools=t,a.tool_choice="auto");const i=await ik(`${s.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${s.apiKey}`},body:JSON.stringify(a),signal:n});if("failed"in i){yield{type:"error",message:i.failed};return}if(!i.ok){yield{type:"error",message:await ok(i)};return}const l=i.body?.getReader();if(!l){yield{type:"error",message:"ReadableStream not supported"};return}const c=new TextDecoder,d={};let u="";try{for(;;){const{done:p,value:f}=await l.read();if(p)break;const m=c.decode(f,{stream:!0}),h=(u+m).split(`
|
|
49
|
+
`);u=h.pop()??"";let y=!1;for(const x of h){const g=x.trim();if(!g.startsWith("data: "))continue;const v=g.slice(6);if(v==="[DONE]"){y=!0;break}try{const k=JSON.parse(v);k.usage&&(yield{type:"usage",promptTokens:k.usage.prompt_tokens,completionTokens:k.usage.completion_tokens});const b=k.choices?.[0]?.delta;if(!b)continue;if(b.content&&(yield{type:"text",content:b.content}),b.tool_calls)for(const S of b.tool_calls){const j=S.index??0;d[j]||(d[j]={id:S.id||"",name:"",args:""}),S.id&&(d[j].id=S.id),S.function?.name&&(d[j].name+=S.function.name),S.function?.arguments&&(d[j].args+=S.function.arguments)}}catch{}}if(y)break}}finally{l.cancel().catch(()=>{})}if(u.trim().startsWith("data: ")){const p=u.trim().slice(6);if(p&&p!=="[DONE]")try{const m=JSON.parse(p).choices?.[0]?.delta;if(m?.tool_calls)for(const h of m.tool_calls){const y=h.index??0;d[y]||(d[y]={id:h.id||"",name:"",args:""}),h.id&&(d[y].id=h.id),h.function?.name&&(d[y].name+=h.function.name),h.function?.arguments&&(d[y].args+=h.function.arguments)}}catch{}}for(const p of Object.values(d)){let f;try{f=JSON.parse(p.args||"{}")}catch{console.warn(`[streamOpenAI] truncated JSON for tool "${p.name}":`,p.args?.slice(0,200)),f={__truncated__:!0}}yield{type:"tool_call",id:p.id,name:p.name,args:f}}yield{type:"done"}}async function*pN(e,t,r,n){const s=rp(r),a=e.find(g=>g.role==="system"),i=dN(e),l=t.map(g=>({name:g.function.name,description:g.function.description,input_schema:g.function.parameters})),c={model:s.model,max_tokens:16e3,messages:i,stream:!0};a&&(c.system=a.content),l.length>0&&(c.tools=l);const d=await ik(`${s.baseUrl}/messages`,{method:"POST",headers:{"Content-Type":"application/json","x-api-key":s.apiKey,"anthropic-version":"2023-06-01","anthropic-dangerous-direct-browser-access":"true"},body:JSON.stringify(c),signal:n});if("failed"in d){yield{type:"error",message:d.failed};return}if(!d.ok){yield{type:"error",message:await ok(d)};return}const u=d.body?.getReader();if(!u){yield{type:"error",message:"ReadableStream not supported"};return}const p=new TextDecoder;let f="",m="",h="",y="",x;try{for(;;){const{done:g,value:v}=await u.read();if(g)break;const k=p.decode(v,{stream:!0}),b=(y+k).split(`
|
|
50
|
+
`);y=b.pop()??"";for(const S of b){const j=S.trim();if(j.startsWith("data: "))try{const _=JSON.parse(j.slice(6));switch(_.type){case"message_start":x=_.message?.usage?.input_tokens;break;case"message_delta":_.usage?.output_tokens!==void 0&&(yield{type:"usage",promptTokens:x,completionTokens:_.usage.output_tokens});break;case"content_block_start":_.content_block?.type==="tool_use"&&(f=_.content_block.id,m=_.content_block.name,h="");break;case"content_block_delta":_.delta?.type==="text_delta"?yield{type:"text",content:_.delta.text}:_.delta?.type==="input_json_delta"&&(h+=_.delta.partial_json);break;case"content_block_stop":if(m){let w;try{w=JSON.parse(h||"{}")}catch{console.warn(`[streamAnthropic] truncated JSON for tool "${m}":`,h?.slice(0,200)),w={__truncated__:!0}}yield{type:"tool_call",id:f,name:m,args:w},m="",f="",h=""}break}}catch{}}}}finally{u.cancel().catch(()=>{})}yield{type:"done"}}async function*lk(e,t,r,n){if(r.transport?.type==="endpoint"){yield*oN(r.transport,{messages:e,tools:t},n);return}if(r.transport?.type==="custom"){const a=n??new AbortController().signal;yield*r.transport.stream({messages:e,tools:t},a);return}if(!r.apiKey){yield{type:"error",message:"未配置 API Key。请在 AI 设置中填写 API Key 后重试。"},yield{type:"done"};return}rp(r).resolvedProvider==="anthropic"?yield*pN(e,t,r,n):yield*uN(e,t,r,n)}const ck=[{type:"function",function:{name:"init_workflow_blueprint",description:"【阶段 1/4:定义工作流蓝图与元信息】在创建或大范围重构复杂工作流时,首先调用此工具定义工作流名称、描述、版本、超时策略及工作流级输入/输出参数契约。调用后请继续调用 scaffold_workflow_topology 编排任务拓扑。",parameters:{type:"object",properties:{name:{type:"string",description:"工作流唯一英文标识名(如 order_fulfillment_flow)"},description:{type:"string",description:"工作流业务目标与场景描述(中文)"},version:{type:"number",description:"版本号,默认 1"},ownerEmail:{type:"string",description:"负责人邮箱(如 team@example.com)"},timeoutPolicy:{type:"string",enum:["TIME_OUT_WF","ALERT_ONLY"],description:"超时策略(默认 ALERT_ONLY)"},timeoutSeconds:{type:"number",description:"工作流整体超时时间(秒,默认 3600)"},failureWorkflow:{type:"string",description:"失败补偿子工作流名称(可选)"},inputParameters:{type:"array",items:{type:"string"},description:'工作流期望接收的输入参数字段名列表(如 ["orderId", "userId", "amount"])'},outputParameters:{type:"object",description:"工作流输出参数映射(可选,也可在阶段 3 补充)"}},required:["name","description"]}}},{type:"function",function:{name:"scaffold_workflow_topology",description:"【阶段 2/4:设计整体任务编排拓扑】在定义工作流蓝图后调用,构建完整的任务节点拓扑骨架(包含顺序节点、SWITCH 条件分支、FORK_JOIN 并行与 JOIN 汇合、DO_WHILE 循环等结构)。此阶段专注任务划分、唯一 taskReferenceName 和控制流拓扑正确性;详细参数可在阶段 3 补充。",parameters:{type:"object",properties:{tasks:{type:"array",description:"按执行顺序排列的顶层 TaskDef 数组(可包含嵌套的 decisionCases / defaultCase / forkTasks / loopOver)",items:{type:"object"}}},required:["tasks"]}}},{type:"function",function:{name:"configure_workflow_tasks",description:"【阶段 3/4:逐项或分批补充任务配置与数据流】对已编排好拓扑的任务补充具体配置(inputParameters 数据流引用 ${workflow.input.x} / ${upstream_ref.output.y}、HTTP 请求配置、SUB_WORKFLOW 引用、timeoutSeconds、retryCount 等)。支持一次配置全部或分多次按模块配置,完成后调用 commit_workflow_proposal 整体验证。",parameters:{type:"object",properties:{configurations:{type:"array",description:"每个任务的详细配置项列表",items:{type:"object",properties:{ref:{type:"string",description:"目标任务的 taskReferenceName(支持顶层或分支/循环内嵌套任务)"},name:{type:"string",description:"任务显示名称(可选更新)"},description:{type:"string",description:"任务业务说明"},inputParameters:{type:"object",description:'任务输入参数及上下游数据流引用(如 { "orderId": "${workflow.input.orderId}" })'},httpRequest:{type:"object",description:"[HTTP 任务] 请求配置 { uri, method, headers, body },会自动规范化到 inputParameters.http_request"},subWorkflowParam:{type:"object",description:"[SUB_WORKFLOW 任务] 子工作流配置 { name, version }"},timeoutSeconds:{type:"number",description:"任务超时秒数"},retryCount:{type:"number",description:"失败重试次数"},retryLogic:{type:"string",enum:["FIXED","EXPONENTIAL_BACKOFF","LINEAR_BACKOFF"],description:"重试退避策略"},optional:{type:"boolean",description:"是否为可选任务(失败不中断主流程)"},caseValueParam:{type:"string",description:"[SWITCH/DECISION] 分支判断参数名"},caseExpression:{type:"string",description:"[SWITCH] 分支评估表达式"},loopCondition:{type:"string",description:"[DO_WHILE] 循环继续条件表达式"},joinOn:{type:"array",items:{type:"string"},description:"[JOIN] 等待汇合的分支末尾 taskReferenceName 列表"}},required:["ref"]}},outputParameters:{type:"object",description:'工作流最终输出参数映射(如 { "result": "${final_task.output.data}" })'}},required:["configurations"]}}},{type:"function",function:{name:"commit_workflow_proposal",description:"【阶段 4/4:整体验证配置并提交方案】对当前工作流草稿执行全量语义、控制流与上下游数据流引用校验。校验通过后正式生成变更方案展示给用户;若发现问题将返回精确诊断供你修正。",parameters:{type:"object",properties:{summary:{type:"string",description:"本次工作流设计或重构的架构摘要说明(可选)"}}}}},{type:"function",function:{name:"replace_workflow",description:"用完整的工作流 JSON 替换当前画布。适用于:极简工作流(1-2 个节点)快速创建,或直接提交完整 WorkflowDef。对于 3 个及以上节点或含分支/并行的复杂流程,请优先使用四阶段渐进工具(init_workflow_blueprint -> scaffold_workflow_topology -> configure_workflow_tasks -> commit_workflow_proposal)。",parameters:{type:"object",properties:{workflow:{type:"object",description:"完整的 Conductor 工作流定义(包含 name, tasks[] 等字段)"}},required:["workflow"]}}},{type:"function",function:{name:"patch_workflow",description:"对当前工作流进行局部修改(增/改/删任务,修改工作流属性)。适用于小范围变更,比 replace_workflow 更精准。",parameters:{type:"object",properties:{ops:{type:"array",description:"操作列表,按顺序执行",items:{type:"object",properties:{op:{type:"string",enum:["add_task","update_task","remove_task","update_props","add_switch_branch","add_fork_branch"],description:"操作类型"},task:{type:"object",description:"[add_task] 完整的 TaskDef 对象(必须有 name, taskReferenceName, type)"},afterRef:{type:"string",description:"[add_task] 插入到哪个任务之后(支持顶层或嵌套分支内的 taskReferenceName)。不传则追加到末尾"},parentRef:{type:"string",description:"[add_task] 可选:插入到指定容器节点内部(SWITCH / FORK_JOIN / DO_WHILE 的 taskReferenceName)"},branchName:{type:"string",description:'[add_task] 可选:当 parentRef 为 SWITCH 时指定分支名(或 "default");当为 FORK_JOIN 时指定分支索引(如 "0", "1")'},ref:{type:"string",description:"[update_task / remove_task / add_switch_branch / add_fork_branch] 目标任务的 taskReferenceName"},changes:{type:"object",description:"[update_task] 要修改的字段(仅传入需要变更的字段)"},props:{type:"object",description:"[update_props] 工作流级别属性(name, description, timeoutSeconds, ownerEmail 等)"},caseName:{type:"string",description:'[add_switch_branch] 新分支名称(如 "approved", "rejected", "default")'}},required:["op"]}}},required:["ops"]}}},{type:"function",function:{name:"get_workflow_state",description:"获取当前工作流的完整状态(任务列表、拓扑、校验结果)。在需要了解当前流程再做决策时调用。",parameters:{type:"object",properties:{includeFull:{type:"boolean",description:"是否包含完整 JSON(默认 false,仅返回摘要)"}}}}},{type:"function",function:{name:"validate_workflow",description:"校验当前工作流的合法性,返回错误和警告详情。在提交前或排查问题时调用。",parameters:{type:"object",properties:{}}}},{type:"function",function:{name:"ask_clarification",description:"当用户意图模糊时,向用户提出澄清问题。提供 2-4 个可选选项帮助用户表达真实意图。调用后停止等待用户回复,不要继续执行其他操作。",parameters:{type:"object",properties:{question:{type:"string",description:"澄清问题,简洁明了(不超过 30 字)"},context:{type:"string",description:"你对用户需求的初步理解(1句话)"},options:{type:"array",description:"2-4 个选项",items:{type:"object",properties:{id:{type:"string"},label:{type:"string",description:"简短标签(≤12字)"},description:{type:"string",description:"一句话说明这个选项的含义"}},required:["id","label","description"]},minItems:2,maxItems:4}},required:["question","options"]}}},{type:"function",function:{name:"recommend_workflow",description:"在创建新工作流之前,向用户推荐库中已有的相似工作流。调用后等待用户选择,不要直接创建。只在库中有相关工作流时使用。",parameters:{type:"object",properties:{userIntent:{type:"string",description:"用户意图摘要"},recommendations:{type:"array",description:"推荐的工作流列表(1-3个)",items:{type:"object",properties:{workflowName:{type:"string"},matchReason:{type:"string",description:"为什么推荐这个"},matchScore:{type:"string",enum:["exact","partial","similar"]}},required:["workflowName","matchReason","matchScore"]},minItems:1,maxItems:3}},required:["userIntent","recommendations"]}}},{type:"function",function:{name:"propose_repair",description:"为运行态失败的任务提出修复方案(仅在运行模式下可用)。分析失败原因后,提供可直接执行的修复操作列表供用户选择。",parameters:{type:"object",properties:{diagnosis:{type:"string",description:"根本原因分析:用 2-3 句话说明为什么失败、数据问题还是配置问题还是依赖问题"},actions:{type:"array",description:"修复操作列表(按推荐优先级排序)",items:{type:"object",properties:{id:{type:"string",description:'操作唯一 ID(如 "rerun_1")'},label:{type:"string",description:'操作名称(如"从 send_email 重新运行")'},type:{type:"string",enum:["rerun_from","skip","retry_workflow","modify_def"],description:"rerun_from=从某任务重新运行,skip=跳过该任务,retry_workflow=重试整个工作流,modify_def=修改工作流定义"},taskRef:{type:"string",description:"[rerun_from/skip] 目标任务的 taskReferenceName"},risk:{type:"string",enum:["low","medium","high"],description:"操作风险等级"},description:{type:"string",description:"操作详细说明及预期结果"}},required:["id","label","type"]}}},required:["diagnosis","actions"]}}},{type:"function",function:{name:"propose_plan",description:'向用户展示即将执行的多步操作计划,在执行前获得确认。适用于:大范围重构、多工具联动操作、复杂拓扑变更。调用此工具后停止,等待用户点击"执行方案"再继续。',parameters:{type:"object",properties:{title:{type:"string",description:'计划标题,简洁描述目标(如"将串行流程重构为并行执行")'},steps:{type:"array",description:"执行步骤列表(按顺序),每步说明将调用的工具和操作内容",items:{type:"object",properties:{step:{type:"number",description:"步骤序号(从 1 开始)"},action:{type:"string",description:"该步骤的操作描述"},tool:{type:"string",description:"将使用的工具名称(如 patch_workflow、replace_workflow)"}},required:["step","action"]}},summary:{type:"string",description:"方案摘要,描述最终效果(可选)"}},required:["title","steps"]}}},{type:"function",function:{name:"search_workflow_library",description:"搜索已有的 L1/L2/L3 子工作流库。当 system prompt 中的库列表不完整,或需要根据业务描述精确匹配子工作流时调用。",parameters:{type:"object",properties:{query:{type:"string",description:"搜索关键词(业务描述、功能名称、标签等)。多个关键词用空格分开,任一命中即返回,按命中数排序"},level:{type:"string",enum:["L1","L2","L3"],description:"按层级过滤(不传则搜索全部层级)"},domain:{type:"string",description:"按业务域过滤(如「通知协助」,需与目录中显示的业务域完全一致;不传则不限业务域)"}},required:["query"]}}},{type:"function",function:{name:"load_library_workflow",description:'加载流程库中已有的工作流并生成变更方案(等待用户确认)。用户选择"直接使用"某个已有工作流时调用:mode=open 把该工作流的完整定义作为方案(替换当前画布内容);mode=reference 在当前流程末尾以 SUB_WORKFLOW 步骤引用它。',parameters:{type:"object",properties:{name:{type:"string",description:"流程库中的工作流名称(与目录完全一致)"},version:{type:"number",description:"版本号(不传则使用流程库当前版本)"},mode:{type:"string",enum:["open","reference"],description:"open=打开完整定义(缺省);reference=作为子流程步骤引用"}},required:["name"]}}}];function Bt(e=[]){const t=[],r=n=>{for(const s of n)if(s){if(t.push(s),s.decisionCases&&typeof s.decisionCases=="object")for(const a of Object.values(s.decisionCases))Array.isArray(a)&&r(a);if(Array.isArray(s.defaultCase)&&r(s.defaultCase),Array.isArray(s.forkTasks))for(const a of s.forkTasks)Array.isArray(a)&&r(a);Array.isArray(s.loopOver)&&r(s.loopOver)}};return r(e),t}function dk(e,t,r){const n={...e},s=r.resolveLatestVersion,a=!r.existingRefs?.has(n.taskReferenceName);if(n.subWorkflowParam?.name){if(s&&a&&n.subWorkflowParam.version===void 0){const i=s(n.subWorkflowParam.name);i!==void 0?(n.subWorkflowParam={...n.subWorkflowParam,version:i},t.push(`将子工作流任务「${n.taskReferenceName}」固定为流程库当前版本 v${i}`)):t.push(`子工作流「${n.subWorkflowParam.name}」不在流程库目录中,版本未能固定,请确认其是否存在`)}}else{const i=n.workflowName||n.inputParameters?.workflowName||n.inputParameters?.subWorkflowName;if(i){let l=n.subWorkflowParam?.version;if(l===void 0){const c=a?s?.(i):void 0;c!==void 0?(l=c,t.push(`将子工作流任务「${n.taskReferenceName}」固定为流程库当前版本 v${c}`)):(l=n.version??1,s&&a&&t.push(`子工作流「${i}」不在流程库目录中,版本未能固定(暂用 v${l}),请确认该版本是否存在`))}n.subWorkflowParam={name:i,version:l,...n.subWorkflowParam??{}},t.push(`将子工作流任务「${n.taskReferenceName}」的流程名规范化至 subWorkflowParam.name`)}}return n}function Fr(e,t=[],r={}){const n={...e},s=n.taskReferenceName||n.name||"unnamed_task";if(n.taskReferenceName||(n.taskReferenceName=String(s).replace(/[^a-zA-Z0-9_]/g,"_"),t.push(`为任务「${n.name||s}」自动生成引用名 ${n.taskReferenceName}`)),n.name||(n.name=n.taskReferenceName),n.type||(n.type="SIMPLE"),n.type==="HTTP"){const a={...n.inputParameters??{}};if(a.http_request)a.http_request.method||(a.http_request={...a.http_request,method:"GET"});else if(n.httpRequest&&typeof n.httpRequest=="object")a.http_request={method:"GET",...n.httpRequest},t.push(`将 HTTP 任务「${n.taskReferenceName}」的 httpRequest 规范化至 inputParameters.http_request`);else if(a.uri||a.url){const{uri:i,url:l,method:c,headers:d,body:u,...p}=a;a.http_request={uri:i||l,method:c||"GET",...d?{headers:d}:{},...u!==void 0?{body:u}:{}};for(const f of["uri","url","method","headers","body"])delete p[f];Object.assign(a,p),t.push(`将 HTTP 任务「${n.taskReferenceName}」的请求参数规范化至 inputParameters.http_request`)}n.inputParameters=a}if(n.type==="EVENT"&&!n.sink){const a=n.inputParameters?.sink;n.sink=typeof a=="string"&&a.trim()?a:"conductor",a!==void 0&&(n.inputParameters={...n.inputParameters},delete n.inputParameters.sink),t.push(`为事件任务「${n.taskReferenceName}」设置 sink:${n.sink}`)}if(n.type==="INLINE"&&n.inputParameters&&!n.inputParameters.expression&&n.inputParameters.scriptExpression){const{scriptExpression:a,...i}=n.inputParameters;n.inputParameters={...i,expression:a},t.push(`把脚本任务「${n.taskReferenceName}」的 scriptExpression 移到 expression`)}if(n.type==="SUB_WORKFLOW"&&Object.assign(n,dk(n,t,r)),n.type==="TERMINATE"){const a={...n.inputParameters??{}};a.terminationStatus||(a.terminationStatus=n.terminationStatus||"COMPLETED",n.inputParameters=a)}if(n.type==="SWITCH"||n.type==="DECISION"){(!n.decisionCases||typeof n.decisionCases!="object")&&(n.decisionCases={default_branch:[]});const a={};for(const[i,l]of Object.entries(n.decisionCases))a[i]=Array.isArray(l)?l.map(c=>Fr(c,t,r)):[];if(n.decisionCases=a,Array.isArray(n.defaultCase)&&(n.defaultCase=n.defaultCase.map(i=>Fr(i,t,r))),!n.caseValueParam&&!n.caseExpression&&!n.expression){const i=n.inputParameters?Object.keys(n.inputParameters)[0]:void 0;n.caseValueParam=i||"switchCaseValue",(!n.inputParameters||Object.keys(n.inputParameters).length===0)&&(n.inputParameters={[n.caseValueParam]:`\${workflow.input.${n.caseValueParam}}`})}n.type==="SWITCH"&&(n.expression||(n.caseExpression?(n.evaluatorType=n.evaluatorType&&n.evaluatorType!=="value-param"?n.evaluatorType:"javascript",n.expression=n.caseExpression):n.caseValueParam&&(n.evaluatorType="value-param",n.expression=n.caseValueParam),n.expression&&t.push(`把条件分支「${n.taskReferenceName}」的判断依据写入 evaluatorType + expression(Conductor 的 SWITCH 不读 caseValueParam / caseExpression)`)),n.evaluatorType||(n.evaluatorType="value-param"),delete n.caseValueParam,delete n.caseExpression)}return n.type==="FORK_JOIN"&&Array.isArray(n.forkTasks)&&(n.forkTasks=n.forkTasks.map(a=>Array.isArray(a)?a.map(i=>Fr(i,t,r)):[])),n.type==="DO_WHILE"&&Array.isArray(n.loopOver)&&(n.loopOver=n.loopOver.map(a=>Fr(a,t,r)),n.loopCondition||(n.loopCondition=`if ($.${n.taskReferenceName}['iteration'] < 3) { true; } else { false; }`,t.push(`为循环任务「${n.taskReferenceName}」补充默认退出条件 loopCondition`))),n}function wn(e,t,r={}){const n=[];for(let s=0;s<e.length;s++){const a=Fr(e[s],t,r);if(a.decisionCases){const i={};for(const[l,c]of Object.entries(a.decisionCases))i[l]=wn(c,t,r);a.decisionCases=i}if(a.defaultCase&&(a.defaultCase=wn(a.defaultCase,t,r)),a.forkTasks&&(a.forkTasks=a.forkTasks.map(i=>wn(i,t,r))),a.loopOver&&(a.loopOver=wn(a.loopOver,t,r)),n.push(a),a.type==="FORK_JOIN"&&Array.isArray(a.forkTasks)){const i=a.forkTasks.filter(c=>Array.isArray(c)&&c.length>0).map(c=>c[c.length-1].taskReferenceName),l=e[s+1];if(l&&(l.type==="JOIN"||l.type==="EXCLUSIVE_JOIN"))(Array.isArray(l.joinOn)?l.joinOn:[]).length===0&&i.length>0&&(e[s+1]={...l,joinOn:i},t.push(`为汇合节点「${l.taskReferenceName}」自动补全 joinOn: [${i.join(", ")}]`));else if(i.length>0){const c=`${a.taskReferenceName}_join`;n.push({name:c,taskReferenceName:c,type:"JOIN",joinOn:i}),t.push(`为并行节点「${a.taskReferenceName}」自动补充配对的 JOIN 节点「${c}」`)}}}return n}function np(e){const t=[],r=/\$\{([^}]+)\}/g,n=s=>{if(typeof s=="string"){let a;for(r.lastIndex=0;(a=r.exec(s))!==null;)t.push(a[1].trim())}else Array.isArray(s)?s.forEach(n):s&&typeof s=="object"&&Object.values(s).forEach(n)};return n(e),t}function sp(e,t={}){const r=[],n=wn(e.tasks??[],r,t),s=Array.isArray(e.inputParameters)?e.inputParameters:[],a=new Set(s.map(c=>typeof c=="string"?c:c.name).filter(Boolean)),i=Bt(n);for(const c of i){const d=np(c.inputParameters);for(const u of d)if(u.startsWith("workflow.input.")){const p=u.slice(15).split(".")[0];p&&!a.has(p)&&a.add(p)}}return{workflow:{...e,name:e.name||"untitled_workflow",version:e.version??1,schemaVersion:e.schemaVersion??2,timeoutPolicy:e.timeoutPolicy??"ALERT_ONLY",tasks:n,inputParameters:Array.from(a)},autoFixed:r}}function uk(e,t){const r=[],n=s=>s.map(a=>{let i=a;if(i.type==="SUB_WORKFLOW"&&(i=dk(i,r,t)),i.decisionCases){const l={};for(const[c,d]of Object.entries(i.decisionCases))l[c]=n(d);i={...i,decisionCases:l}}return i.defaultCase&&(i={...i,defaultCase:n(i.defaultCase)}),i.forkTasks&&(i={...i,forkTasks:i.forkTasks.map(n)}),i.loopOver&&(i={...i,loopOver:n(i.loopOver)}),i});return{workflow:{...e,tasks:n(e.tasks??[])},autoFixed:r}}function fN(e,t){return{name:t.name||e?.name||"new_workflow",description:t.description??e?.description??"",version:t.version??e?.version??1,schemaVersion:2,ownerEmail:t.ownerEmail??e?.ownerEmail,timeoutPolicy:t.timeoutPolicy??e?.timeoutPolicy??"ALERT_ONLY",timeoutSeconds:t.timeoutSeconds??e?.timeoutSeconds??3600,failureWorkflow:t.failureWorkflow??e?.failureWorkflow,inputParameters:t.inputParameters??e?.inputParameters??[],outputParameters:t.outputParameters??e?.outputParameters??{},tasks:e?.tasks??[]}}function mN(e,t,r={}){return sp({...e??{name:"new_workflow",version:1,schemaVersion:2,tasks:[]},tasks:t.tasks??[]},r)}function hN(e,t,r={}){const n=new Map;for(const f of t.configurations??[]){const m=f?.ref||f?.taskReferenceName;m&&n.set(m,{...f,ref:m})}const s=[],a=[],i=f=>f.map(m=>{let h={...m};const y=n.get(m.taskReferenceName);if(y&&(s.push(m.taskReferenceName),y.name!==void 0&&(h.name=y.name),y.description!==void 0&&(h.description=y.description),y.inputParameters!==void 0&&(h.inputParameters={...h.inputParameters??{},...y.inputParameters}),y.httpRequest!==void 0&&(h.httpRequest=y.httpRequest),y.subWorkflowParam!==void 0&&(h.subWorkflowParam={...h.subWorkflowParam??{name:""},...y.subWorkflowParam}),y.timeoutSeconds!==void 0&&(h.timeoutSeconds=y.timeoutSeconds),y.retryCount!==void 0&&(h.retryCount=y.retryCount),y.retryLogic!==void 0&&(h.retryLogic=y.retryLogic),y.retryDelaySeconds!==void 0&&(h.retryDelaySeconds=y.retryDelaySeconds),y.optional!==void 0&&(h.optional=y.optional),y.caseValueParam!==void 0&&(h.caseValueParam=y.caseValueParam),y.caseExpression!==void 0&&(h.caseExpression=y.caseExpression),y.loopCondition!==void 0&&(h.loopCondition=y.loopCondition),y.joinOn!==void 0&&(h.joinOn=y.joinOn),y.dynamicForkTasksParam!==void 0&&(h.dynamicForkTasksParam=y.dynamicForkTasksParam),y.dynamicForkTasksInputParamName!==void 0&&(h.dynamicForkTasksInputParamName=y.dynamicForkTasksInputParamName),h=Fr(h,a,r)),h.decisionCases){const x={};for(const[g,v]of Object.entries(h.decisionCases))x[g]=i(v);h.decisionCases=x}return h.defaultCase&&(h.defaultCase=i(h.defaultCase)),h.forkTasks&&(h.forkTasks=h.forkTasks.map(x=>i(x))),h.loopOver&&(h.loopOver=i(h.loopOver)),h}),l=i(e.tasks??[]),c=Array.from(n.keys()).filter(f=>!s.includes(f)),d=(e.inputParameters??[]).map(f=>typeof f=="string"?f:f.name),u={...e,tasks:l,...t.outputParameters?{outputParameters:{...e.outputParameters??{},...t.outputParameters}}:{},...t.inputParameters?{inputParameters:Array.from(new Set([...d,...t.inputParameters]))}:{}},p=sp(u);return{workflow:p.workflow,configuredRefs:s,missingRefs:c,autoFixed:[...a,...p.autoFixed]}}function ar(e,t=[]){const r=Et(e),n=[...r.errors],s=[...r.warnings],a=Bt(e.tasks??[]),i=new Set(a.map(u=>u.taskReferenceName)),l=new Set;let c=0,d=0;for(const u of a){const p=u.taskReferenceName,f=u.inputParameters&&Object.keys(u.inputParameters).length>0,m=u.type==="JOIN"||u.type==="EXCLUSIVE_JOIN"||u.type==="FORK_JOIN"||u.type==="SWITCH"||u.type==="DECISION"||u.type==="DO_WHILE"||u.type==="SUB_WORKFLOW";(f||m||u.timeoutSeconds||u.retryCount!==void 0)&&c++;const h=np(u.inputParameters);for(const y of h){if(d++,y.startsWith("workflow.input.")||y.startsWith("workflow."))continue;const x=y.split(".")[0];x&&(i.has(x)?x===p?n.push({type:"TASK",ref:p,message:`任务「${p}」的参数不能自引用自身输出(表达式: \${${y}})`}):l.has(x)||n.push({type:"TASK",ref:p,message:`任务「${p}」引用了下游尚未执行的任务 "${x}"(表达式: \${${y}})`}):n.push({type:"TASK",ref:p,message:`任务「${p}」的参数引用了不存在的任务 "${x}"(表达式: \${${y}})`}))}if((u.type==="JOIN"||u.type==="EXCLUSIVE_JOIN")&&Array.isArray(u.joinOn)){u.joinOn.length===0&&s.push({type:"TASK",ref:p,message:`汇合节点「${p}」未配置 joinOn 等待列表`});for(const y of u.joinOn)i.has(y)||n.push({type:"TASK",ref:p,message:`汇合节点「${p}」的 joinOn 引用了不存在的任务 "${y}"`})}l.add(p)}if(e.outputParameters){const u=np(e.outputParameters);for(const p of u){if(d++,p.startsWith("workflow."))continue;const f=p.split(".")[0];f&&!i.has(f)&&n.push({type:"GLOBAL",ref:"GLOBAL",message:`工作流 outputParameters 引用了不存在的任务 "${f}"(表达式: \${${p}})`})}}return{isValid:n.length===0,totalTasks:a.length,configuredTasks:c,dataFlowLinks:d,autoFixed:t,errors:n,warnings:s}}const pk=50;function Sn(e){return{resolveLatestVersion:e.resolveLatestVersion,existingRefs:new Set(Bt(e.workflowDef?.tasks??[]).map(t=>t.taskReferenceName))}}function Ht(e,t,r){const n=[];for(const s of e)if(t(s)){const a=r(s);a!==null&&n.push(a)}else{let a=s;if(s.forkTasks&&Array.isArray(s.forkTasks)&&(a={...a,forkTasks:s.forkTasks.map(i=>Ht(i,t,r))}),s.decisionCases&&typeof s.decisionCases=="object"){const i={};for(const[l,c]of Object.entries(s.decisionCases))i[l]=Ht(c,t,r);a={...a,decisionCases:i}}s.defaultCase&&Array.isArray(s.defaultCase)&&(a={...a,defaultCase:Ht(s.defaultCase,t,r)}),s.loopOver&&Array.isArray(s.loopOver)&&(a={...a,loopOver:Ht(s.loopOver,t,r)}),n.push(a)}return n}function _n(e,t,r){const n=e.findIndex(i=>i.taskReferenceName===t);if(n>=0)return{tasks:[...e.slice(0,n+1),r,...e.slice(n+1)],inserted:!0};let s=!1;return{tasks:e.map(i=>{if(s)return i;let l=i;if(i.decisionCases&&typeof i.decisionCases=="object"){const c={};for(const[d,u]of Object.entries(i.decisionCases))if(!s&&Array.isArray(u)){const p=_n(u,t,r);c[d]=p.tasks,p.inserted&&(s=!0)}else c[d]=u;s&&(l={...l,decisionCases:c})}if(!s&&Array.isArray(i.defaultCase)){const c=_n(i.defaultCase,t,r);c.inserted&&(s=!0,l={...l,defaultCase:c.tasks})}if(!s&&Array.isArray(i.forkTasks)){const c=i.forkTasks.map(d=>{if(s||!Array.isArray(d))return d;const u=_n(d,t,r);return u.inserted&&(s=!0),u.tasks});s&&(l={...l,forkTasks:c})}if(!s&&Array.isArray(i.loopOver)){const c=_n(i.loopOver,t,r);c.inserted&&(s=!0,l={...l,loopOver:c.tasks})}return l}),inserted:s}}function yN(e){switch(e.op){case"add_task":{const t=e.parentRef?`parentRef=${e.parentRef}`:e.afterRef?`afterRef=${e.afterRef}`:"";return`add_task(${e.task?.taskReferenceName??"?"}${t?`, ${t}`:""})`}case"update_task":return`update_task(${e.ref})`;case"remove_task":return`remove_task(${e.ref})`;case"add_switch_branch":return`add_switch_branch(${e.ref}, ${e.caseName})`;case"add_fork_branch":return`add_fork_branch(${e.ref})`;default:return String(e.op??"unknown")}}function fk(e,t){let r={...e,tasks:[...e.tasks??[]]};const n=[],s=(a,i)=>n.push(`${yN(a)}:${i}`);for(const a of t)switch(a.op){case"add_task":{const i=a.task;if(!i||typeof i!="object"){s(a,"缺少 task 定义");break}if(a.parentRef){let l=!1,c=!0;r.tasks=Ht(r.tasks,d=>d.taskReferenceName===a.parentRef,d=>{if(l=!0,d.type==="SWITCH"||d.type==="DECISION"){const u=a.branchName||Object.keys(d.decisionCases??{})[0]||"default";if(u==="default")return{...d,defaultCase:[...d.defaultCase??[],i]};const p={...d.decisionCases??{}};return p[u]=[...p[u]??[],i],{...d,decisionCases:p}}if(d.type==="FORK_JOIN"){const u=[...d.forkTasks??[]],p=a.branchName!==void 0?parseInt(a.branchName,10):0,f=Number.isNaN(p)?0:Math.max(0,p);for(;u.length<=f;)u.push([]);return u[f]=[...u[f],i],{...d,forkTasks:u}}return d.type==="DO_WHILE"?{...d,loopOver:[...d.loopOver??[],i]}:(c=!1,d)}),l?c||s(a,`父任务 ${a.parentRef} 不是 SWITCH / FORK_JOIN / DO_WHILE,不能放入子任务`):s(a,`找不到父任务 ${a.parentRef}`)}else if(a.afterRef){const l=_n(r.tasks,a.afterRef,i);l.inserted?r.tasks=l.tasks:s(a,`找不到 afterRef 指向的任务 ${a.afterRef}`)}else r.tasks=[...r.tasks,i];break}case"update_task":{let i=!1;r.tasks=Ht(r.tasks,l=>l.taskReferenceName===a.ref,l=>(i=!0,{...l,...a.changes})),i||s(a,`找不到任务 ${a.ref}`);break}case"remove_task":{let i=!1;r.tasks=Ht(r.tasks,l=>l.taskReferenceName===a.ref,()=>(i=!0,null)),i||s(a,`找不到任务 ${a.ref}`);break}case"update_props":{const{tasks:i,...l}=a.props??{};r={...r,...l};break}case"add_switch_branch":{let i=!1,l=!0;r.tasks=Ht(r.tasks,c=>c.taskReferenceName===a.ref,c=>{if(i=!0,c.type!=="SWITCH"&&c.type!=="DECISION")return l=!1,c;if(a.caseName==="default")return c.defaultCase?c:{...c,defaultCase:[]};const d={...c.decisionCases??{}};return d[a.caseName]?c:(d[a.caseName]=[],{...c,decisionCases:d})}),i?l||s(a,`任务 ${a.ref} 不是 SWITCH,不能添加分支`):s(a,`找不到 SWITCH 任务 ${a.ref}`);break}case"add_fork_branch":{let i=!1,l=!0;r.tasks=Ht(r.tasks,c=>c.taskReferenceName===a.ref,c=>{if(i=!0,c.type!=="FORK_JOIN")return l=!1,c;const d=c.forkTasks??[],u=`${a.ref}_branch_${d.length+1}`;return{...c,forkTasks:[...d,[{name:u,taskReferenceName:u,type:"SIMPLE"}]]}}),i?l||s(a,`任务 ${a.ref} 不是 FORK_JOIN,不能添加并行分支`):s(a,`找不到 FORK_JOIN 任务 ${a.ref}`);break}default:s(a,"不支持的操作类型")}return{workflow:r,unmatched:n}}function gN(e,t){return fk(e,t).workflow}function mk(e){if(!e)return"未设置";if(e<60)return`${e} 秒`;const t=Math.floor(e/60),r=e%60;return r>0?`${t} 分 ${r} 秒`:`${t} 分钟`}function xN(e,t){const r=[];if(e.name!==t.name&&r.push(`名称:「${e.name}」→「${t.name}」`),e.type!==t.type&&r.push(`类型:${e.type} → ${t.type}`),e.timeoutSeconds!==t.timeoutSeconds&&r.push(`超时:${mk(e.timeoutSeconds)} → ${mk(t.timeoutSeconds)}`),(e.retryCount??0)!==(t.retryCount??0)){const n=e.retryCount??0,s=t.retryCount??0;r.push(s>n?`新增失败重试(${s} 次)`:s===0?"移除了失败重试":`重试次数:${n} → ${s}`)}return JSON.stringify(e.inputParameters??{})!==JSON.stringify(t.inputParameters??{})&&r.push("输入参数已调整"),JSON.stringify(e.decisionCases)!==JSON.stringify(t.decisionCases)&&r.push("分支条件已调整"),JSON.stringify(e.forkTasks)!==JSON.stringify(t.forkTasks)&&r.push("并行分支已调整"),r.length===0&&r.push("配置已调整"),r}function hk(e){const t=n=>(n??[]).map(s=>s?.taskReferenceName),r={...e};return e.decisionCases&&typeof e.decisionCases=="object"&&(r.decisionCases=Object.fromEntries(Object.entries(e.decisionCases).map(([n,s])=>[n,t(s)]))),Array.isArray(e.defaultCase)&&(r.defaultCase=t(e.defaultCase)),Array.isArray(e.forkTasks)&&(r.forkTasks=e.forkTasks.map(n=>t(n))),Array.isArray(e.loopOver)&&(r.loopOver=t(e.loopOver)),r}function jn(e,t){const r=t.tasks??[],n=Bt(r);if(!e)return{added:n.map(g=>g.taskReferenceName),modified:[],removed:[],propsChanged:!1};const s=Bt(e.tasks??[]),a=new Map(s.map(g=>[g.taskReferenceName,g])),i=new Map(n.map(g=>[g.taskReferenceName,g])),l=[],c=[],d=[],u=[];for(const[g,v]of i)if(!a.has(g))l.push(g);else{const k=hk(a.get(g)),b=hk(v);JSON.stringify(b)!==JSON.stringify(k)&&(c.push(g),u.push({ref:g,changes:xN(k,b)}))}for(const g of a.keys())i.has(g)||d.push(g);const p=e.name!==t.name||e.description!==t.description||e.timeoutSeconds!==t.timeoutSeconds||e.version!==t.version||e.ownerEmail!==t.ownerEmail||e.failureWorkflow!==t.failureWorkflow||JSON.stringify(e.inputParameters)!==JSON.stringify(t.inputParameters)||JSON.stringify(e.outputParameters)!==JSON.stringify(t.outputParameters),f=new Set(r.map(g=>g.taskReferenceName)),m=new Set((e.tasks??[]).map(g=>g.taskReferenceName)),h=(e.tasks??[]).filter(g=>f.has(g.taskReferenceName)).map(g=>g.taskReferenceName),y=r.filter(g=>m.has(g.taskReferenceName)).map(g=>g.taskReferenceName),x=h.join(",")!==y.join(",");return{added:l,modified:c,removed:d,propsChanged:p,reordered:x,modifiedDetails:u}}function Tn(e,t){if(t.length===0)return{inferredLevel:null,violations:[]};const r=new Map(t.map(c=>[c.workflowName,c])),n=Bt(e.tasks??[]).filter(c=>c.type==="SUB_WORKFLOW");if(n.length===0)return{inferredLevel:"L1",violations:[]};const s=[];if(n.forEach(c=>{const d=c.subWorkflowParam?.name??c.workflowName;if(!d)return;const u=r.get(d);u&&s.push(u.workflowLevel)}),s.length===0)return{inferredLevel:null,violations:[]};const a={L1:1,L2:2,L3:3},i=s.reduce((c,d)=>a[d]>a[c]?d:c,"L1");return{inferredLevel:i==="L3"||i==="L2"?"L3":"L2",violations:[]}}function In(e,t,r){if(t.__truncated__)return{type:"error",text:"工具调用参数被截断(输出超出 token 限制)。请将工作流拆分为更小的步骤,或先创建骨架工作流再通过 patch_workflow 逐步完善。"};const n=r.workflowDef,s=r.workingDraft??n;switch(e){case"init_workflow_blueprint":{if(!t.name)return{type:"error",text:"init_workflow_blueprint 缺少必填的 name 字段"};const a=fN(s,{name:t.name,description:t.description,version:t.version,ownerEmail:t.ownerEmail,timeoutPolicy:t.timeoutPolicy,timeoutSeconds:t.timeoutSeconds,failureWorkflow:t.failureWorkflow,inputParameters:t.inputParameters,outputParameters:t.outputParameters}),i=a.inputParameters?.length??0,l=i>0?`(含 ${i} 项输入契约:${a.inputParameters.join(", ")})`:"";return{type:"stage",phase:"blueprint",workingDraft:a,timelineLabel:`阶段 1/4:已定义工作流「${a.name}」元信息${l}`,text:`✅ 阶段 1 完成:工作流「${a.name}」蓝图已初始化${l}。请继续调用 scaffold_workflow_topology 设计整体任务编排拓扑。`}}case"scaffold_workflow_topology":{if(!Array.isArray(t.tasks)||t.tasks.length===0)return{type:"error",text:"scaffold_workflow_topology 需要提供非空的 tasks 数组"};const{workflow:a,autoFixed:i}=mN(s,{tasks:t.tasks},Sn(r)),l=Bt(a.tasks),c=l.map(u=>`${u.taskReferenceName}(${u.type})`).join(" → "),d=i.length>0?`
|
|
51
|
+
自动规范化:${i.join(";")}`:"";return{type:"stage",phase:"topology",workingDraft:a,timelineLabel:`阶段 2/4:已编排任务拓扑 · 共 ${l.length} 个节点`,text:`✅ 阶段 2 完成:已编排 ${l.length} 个任务节点(${c})。${d}
|
|
52
|
+
请继续调用 configure_workflow_tasks 为各任务补充详细参数与上下游数据流引用。`}}case"configure_workflow_tasks":{if(!s||!s.tasks||s.tasks.length===0)return{type:"error",text:"当前尚未构建工作流任务拓扑,请先调用 init_workflow_blueprint 和 scaffold_workflow_topology。"};if(!Array.isArray(t.configurations)||t.configurations.length===0)return{type:"error",text:"configure_workflow_tasks 的 configurations 数组不能为空"};const{workflow:a,configuredRefs:i,missingRefs:l,autoFixed:c}=hN(s,{configurations:t.configurations,outputParameters:t.outputParameters,inputParameters:t.inputParameters},Sn(r)),d=Bt(a.tasks),u=l.length>0?`
|
|
53
|
+
⚠️ 以下 ref 未在拓扑中找到,请检查拼写:${l.join(", ")}`:"",p=c.length>0?`
|
|
54
|
+
自动规范化:${c.join(";")}`:"";return{type:"stage",phase:"configure",workingDraft:a,timelineLabel:`阶段 3/4:已补充 ${i.length}/${d.length} 个任务配置与数据流`,text:`✅ 阶段 3 进展:已更新 ${i.length} 个任务配置(${i.join(", ")})。${u}${p}
|
|
55
|
+
若所有关键任务均已配置完毕,请调用 commit_workflow_proposal 执行整体校验并提交方案。`}}case"commit_workflow_proposal":{if(!s||!s.tasks||s.tasks.length===0)return{type:"error",text:"当前没有可提交的工作流草稿,请先编排任务后再提交。"};const{workflow:a,autoFixed:i}=sp(s,Sn(r)),l=ar(a,i),c=jn(n,a),{inferredLevel:d}=Tn(a,r.libraryItems);return{type:"propose",proposed:a,diff:c,inferredLevel:d??void 0,verification:l}}case"replace_workflow":{let a=t.workflow;if(!a&&t.name&&Array.isArray(t.tasks)&&(a=t),!a)return{type:"error",text:'工具调用未包含 workflow 字段。请重新生成并确保参数结构为 { workflow: { name: "...", tasks: [...] } }'};if(!a.name)return{type:"error",text:"工作流定义缺少 name 字段,请补充后重新调用"};if(!Array.isArray(a.tasks))return{type:"error",text:"工作流定义缺少 tasks 数组,请提供包含 tasks 字段的完整工作流定义"};a.version===void 0&&(a={...a,version:1});const i=uk(a,Sn(r));a=i.workflow;const l=jn(n,a),{inferredLevel:c}=Tn(a,r.libraryItems),d=ar(a,i.autoFixed);return{type:"propose",proposed:a,diff:l,inferredLevel:c??void 0,verification:d}}case"patch_workflow":{const a=t.ops;if(!a?.length)return{type:"error",text:"操作列表为空"};const i=s??n;if(!i)return{type:"error",text:"当前没有加载工作流,请先创建或加载一个工作流"};const{workflow:l,unmatched:c}=fk(i,a);if(c.length>0)return{type:"error",text:`patch_workflow 有 ${c.length} 个操作没有生效,本次变更未提交:
|
|
56
|
+
`+c.map(h=>`- ${h}`).join(`
|
|
57
|
+
`)+`
|
|
58
|
+
请用 get_workflow_state 核对任务引用名(taskReferenceName)后,重新调用 patch_workflow 提交全部操作。`};const d=uk(l,Sn(r)),u=d.workflow,p=jn(n,u),{inferredLevel:f}=Tn(u,r.libraryItems),m=ar(u,d.autoFixed);return{type:"propose",proposed:u,diff:p,inferredLevel:f??void 0,verification:m}}case"get_workflow_state":{const a=s??n;if(!a)return{type:"info",text:"当前没有加载任何工作流,画布为空。"};if(t.includeFull)return{type:"info",text:`工作流「${a.name}」完整定义:
|
|
59
|
+
\`\`\`json
|
|
60
|
+
${JSON.stringify(a,null,2)}
|
|
61
|
+
\`\`\``};const i=a.tasks.map(c=>{const d=[`**${c.taskReferenceName}** (${c.type})`];return c.timeoutSeconds&&d.push(`超时: ${c.timeoutSeconds}s`),c.retryCount!==void 0&&d.push(`重试: ${c.retryCount}`),c.inputParameters&&Object.keys(c.inputParameters).length>0&&d.push(`inputParameters: ${JSON.stringify(c.inputParameters)}`),c.type==="HTTP"&&c.httpRequest&&d.push(`HTTP: ${c.httpRequest.method} ${c.httpRequest.uri}`),c.type==="SWITCH"&&(d.push(`caseValueParam: ${c.caseValueParam||c.caseExpression}`),d.push(`分支: ${Object.keys(c.decisionCases??{}).join(", ")}`)),d.join(" | ")}),l=r.validationResults.errors.length>0?`
|
|
62
|
+
|
|
63
|
+
校验错误:${r.validationResults.errors.map(c=>c.message).join(";")}`:"";return{type:"info",text:`工作流「${a.name}」各任务详情:
|
|
64
|
+
${i.join(`
|
|
65
|
+
`)}${l}`}}case"validate_workflow":{const a=s??n;if(!a)return{type:"info",text:"当前没有加载工作流,无法校验。"};const i=ar(a);if(i.isValid&&i.warnings.length===0)return{type:"info",text:`✅ 工作流校验通过(共 ${i.totalTasks} 个任务,${i.configuredTasks} 个已配置参数,${i.dataFlowLinks} 处数据流引用),没有错误或警告。`};const l=[];return i.errors.forEach(c=>l.push(`❌ [${c.ref||"GLOBAL"}] ${c.message}`)),i.warnings.forEach(c=>l.push(`⚠️ [${c.ref||"GLOBAL"}] ${c.message}`)),{type:"info",text:`校验结果:
|
|
66
|
+
${l.join(`
|
|
67
|
+
`)}`}}case"search_workflow_library":{const a=r.libraryItems,i=String(t.query??"").toLowerCase().split(/[\s,,、;;|/]+/).map(x=>x.trim()).filter(Boolean),l=t.level,c=typeof t.domain=="string"&&t.domain.trim()?t.domain.trim():void 0,d=r.librarySearchResults;if(!d&&a.length===0)return{type:"info",text:"当前没有配置工作流库,无法搜索。"};const u=x=>{if(i.length===0)return 1;const g=[x.workflowName.toLowerCase(),(x.description??"").toLowerCase(),...(x.tags??[]).map(v=>v.toLowerCase())];return i.filter(v=>g.some(k=>k.includes(v))).length},f=(d??a.filter(x=>!l||x.workflowLevel===l).filter(x=>!c||x.domain===c).map(x=>({item:x,hits:u(x)})).filter(x=>x.hits>0).sort((x,g)=>g.hits-x.hits).map(x=>x.item)).filter(x=>!c||x.domain===c);if(f.length===0)return{type:"info",text:`未找到与「${t.query}」相关的子工作流。`};const m=f.slice(0,pk),h={L3:[],L2:[],L1:[]};m.forEach(x=>h[x.workflowLevel].push(x));const y=[`找到 ${f.length} 个相关工作流:`];return["L3","L2","L1"].forEach(x=>{h[x].length!==0&&(y.push(`
|
|
68
|
+
**${x}**`),h[x].forEach(g=>{y.push(`- \`${g.workflowName}\` (v${g.version}): ${g.description??""} [${(g.tags??[]).join(", ")}]${g.domain?` [业务域: ${g.domain}]`:""}`)}))}),f.length>m.length&&y.push(`
|
|
69
|
+
(仅显示前 ${m.length} 个,请用更具体的关键词或指定层级缩小范围)`),{type:"info",text:y.join(`
|
|
70
|
+
`)}}case"load_library_workflow":return bN(t,r);default:return{type:"error",text:`未知工具: ${e}`}}}function vN(e,t){const r=e.replace(/[^a-zA-Z0-9_]/g,"_")||"sub_workflow";let n=`${r}_ref`,s=2;for(;t.has(n);)n=`${r}_ref_${s++}`;return n}function bN(e,t){const r=typeof e.name=="string"?e.name.trim():"";if(!r)return{type:"error",text:"load_library_workflow 缺少 name(流程库中的工作流名称)"};const n=t.libraryItems.find(x=>x.workflowName===r),s=t.libraryWorkflowDef&&Array.isArray(t.libraryWorkflowDef.tasks)&&t.libraryWorkflowDef.tasks.length>0?t.libraryWorkflowDef:null;if(!n&&!s)return{type:"error",text:`流程库中没有名为「${r}」的工作流。请先用 search_workflow_library 确认名称后重试。`};const a=e.mode==="reference"?"reference":"open",i=t.workflowDef;if(a==="open"){if(!s)return{type:"error",text:`流程库只提供了「${r}」的摘要,没有完整定义,无法直接打开。可改用 mode=reference 以子流程步骤引用它。`};const x={...s,tasks:[...s.tasks]},g=jn(i,x),{inferredLevel:v}=Tn(x,t.libraryItems),k=ar(x);return{type:"propose",proposed:x,diff:g,inferredLevel:n?.workflowLevel??v??void 0,verification:k}}const l=t.workingDraft??i??{name:"new_workflow",version:1,schemaVersion:2,tasks:[]},c=new Set(Bt(l.tasks??[]).map(x=>x.taskReferenceName)),d=n?parseInt(String(n.version),10):NaN,u=typeof e.version=="number"?e.version:t.resolveLatestVersion?.(r)??s?.version??(Number.isNaN(d)?void 0:d),p={name:n?.description||r,taskReferenceName:vN(r,c),type:"SUB_WORKFLOW",subWorkflowParam:{name:r,...u!==void 0?{version:u}:{}}},f=gN(l,[{op:"add_task",task:p}]),m=jn(i,f),{inferredLevel:h}=Tn(f,t.libraryItems),y=ar(f);return{type:"propose",proposed:f,diff:m,inferredLevel:h??void 0,verification:y}}function Nn(e){const t=[];return e.added.length>0&&t.push(`新增 ${e.added.length} 个任务(${e.added.join(", ")})`),e.modified.length>0&&t.push(`修改 ${e.modified.length} 个任务(${e.modified.join(", ")})`),e.removed.length>0&&t.push(`删除 ${e.removed.length} 个任务(${e.removed.join(", ")})`),e.reordered&&t.push("调整了任务顺序"),e.propsChanged&&t.push("修改了工作流属性"),t.length>0?t.join(","):"无实质性变更"}function kN(e,t){const r=e.workflowDef;if(!r)return{summary:"当前没有加载任何工作流。画布为空。",topology:"",tasks:[],validationIssues:[]};const n=r.tasks.map(y=>({ref:y.taskReferenceName,name:y.name,type:y.type})),s=e.edges,a={};s.forEach(y=>{a[y.source]||(a[y.source]=[]),a[y.source].push(y.target)});const i=[];s.forEach(y=>{const x=y.label?` [${y.label}]`:"";i.push(`${y.source} → ${y.target}${x}`)});const l=i.length>0?i.join(`
|
|
71
|
+
`):r.tasks.map(y=>y.taskReferenceName).join(" → "),c=new Map;r.tasks.forEach(y=>c.set(y.type,(c.get(y.type)||0)+1));const d=Array.from(c.entries()).map(([y,x])=>`${x}×${y}`).join(", "),u=`工作流「${r.name}」包含 ${r.tasks.length} 个任务 (${d})。`;let p;if(e.selectedTask){const y=e.selectedTask.taskReferenceName,x=s.filter(k=>k.target===y).map(k=>k.source),g=s.filter(k=>k.source===y).map(k=>k.target),v=e.executionData?.[y];p={task:{ref:y,name:e.selectedTask.name,type:e.selectedTask.type,inputParameters:e.selectedTask.inputParameters},upstreamRefs:x,downstreamRefs:g,executionStatus:v?.status,executionFailureReason:v?.reasonForIncompletion}}const f=[];e.validationResults.errors.forEach(y=>f.push(`❌ ${y.message}`)),e.validationResults.warnings.forEach(y=>f.push(`⚠️ ${y.message}`));let m;if(e.mode==="run"&&e.executionData){const y=e.executionData,x=Object.keys(y),g=x.filter(b=>y[b].status==="FAILED"||y[b].status==="FAILED_WITH_TERMINAL_ERROR"||y[b].status==="TIMED_OUT").map(b=>({ref:b,type:e.taskMap[b]?.type??"UNKNOWN",reason:y[b].reasonForIncompletion})),v=x.filter(b=>y[b].status==="IN_PROGRESS"||y[b].status==="SCHEDULED"),k=x.filter(b=>y[b].status==="COMPLETED"||y[b].status==="COMPLETED_WITH_ERRORS");m={instanceId:e.workflowInstance?.workflowId?.slice(0,16),workflowStatus:e.workflowInstance?.status,failedTasks:g,inProgressTasks:v,completedCount:k.length,totalCount:r.tasks.length}}const h={summary:u,topology:l,tasks:n,focusTask:p,validationIssues:f,execution:m};return t?.includeFull&&(h.fullDef=r),h}function wN(e){const t=[];if(t.push(`## 当前工作流状态(实时读取,以此为准)
|
|
72
|
+
> ⚠️ 以下数据直接从画布实时获取,若与对话历史中的工作流描述有冲突,**以此处为准**。
|
|
73
|
+
|
|
74
|
+
${e.summary}`),e.tasks.length>0&&t.push(`### 任务列表
|
|
75
|
+
${e.tasks.map(r=>`- ${r.ref} (${r.type}): ${r.name}`).join(`
|
|
76
|
+
`)}`),e.topology&&t.push(`### 拓扑关系
|
|
77
|
+
${e.topology}`),e.focusTask){const r=e.focusTask,n=r.executionStatus?`
|
|
78
|
+
- 执行状态: ${r.executionStatus}${r.executionFailureReason?`(原因: ${r.executionFailureReason})`:""}`:"";t.push(`### 当前选中任务
|
|
79
|
+
- 引用名: ${r.task.ref}
|
|
80
|
+
- 类型: ${r.task.type}
|
|
81
|
+
- 上游: ${r.upstreamRefs.join(", ")||"无"}
|
|
82
|
+
- 下游: ${r.downstreamRefs.join(", ")||"无"}`+n+(r.task.inputParameters?`
|
|
83
|
+
- 参数: ${JSON.stringify(r.task.inputParameters)}`:""))}if(e.validationIssues.length>0&&t.push(`### 当前校验问题
|
|
84
|
+
${e.validationIssues.join(`
|
|
85
|
+
`)}`),e.fullDef&&t.push(`### 画布工作流完整 JSON(以此为权威数据源,生成流程图或分析必须基于此)
|
|
86
|
+
\`\`\`json
|
|
87
|
+
${JSON.stringify(e.fullDef,null,2)}
|
|
88
|
+
\`\`\``),e.execution){const r=e.execution,n=r.workflowStatus?`工作流状态:**${r.workflowStatus}**`:"",s=`完成 ${r.completedCount}/${r.totalCount} 个任务`,a=r.failedTasks.length>0?`
|
|
89
|
+
**失败任务(${r.failedTasks.length}个):**
|
|
90
|
+
`+r.failedTasks.map(l=>`- ${l.ref} (${l.type})${l.reason?`:${l.reason}`:""}`).join(`
|
|
91
|
+
`):"",i=r.inProgressTasks.length>0?`
|
|
92
|
+
**进行中:** ${r.inProgressTasks.join(", ")}`:"";t.push(`## 运行态执行信息(实时)
|
|
93
|
+
`+[n,s].filter(Boolean).join(" ")+a+i)}return t.join(`
|
|
94
|
+
|
|
95
|
+
`)}const yk=[{intent:"CREATE",keywords:[],patterns:[/^(请)?(帮我)?(从零)?(创建|新建|设计|搭建|构建)/]},{intent:"VISUALIZE",keywords:["流程图","mermaid","图表","可视化","业务视图","展示流程","画图","画出"],patterns:[/流程图/,/mermaid/i,/可视化/,/展示.*业务/,/业务.*展示/,/画.*图/,/图.*展示/]},{intent:"DEBUG",keywords:["失败","错误","为什么","报错","异常","不工作","问题","修复","排查","诊断"],patterns:[/为什么.*失败/,/出[了]?错/,/报错/,/不[工作|运行]/,/怎么回事/,/修复/]},{intent:"REFACTOR",keywords:["重构","并行","串行","拆分","合并","改成并行","改成串行"],patterns:[/改成并行/,/改成串行/,/改为并行/,/改为串行/,/拆分/,/合并/,/重构/]},{intent:"DELETE",keywords:["删除","移除","去掉","删掉","干掉"],patterns:[/删[除掉]/,/移除/,/去掉/]},{intent:"ADD",keywords:["添加","加一个","新增","插入","追加"],patterns:[/加.*任务/,/添加.*节点/,/插入.*后面/,/增加/]},{intent:"MODIFY",keywords:["修改","更改","设置","把…改","调整","配置","设为","改为","改成"],patterns:[/[改设].*为/,/[改设].*成/,/修改/,/超时/,/重试/]},{intent:"CREATE",keywords:["创建","新建","设计","搭建","构建","组合"],patterns:[/创建.*流程/,/生成.*工作流/,/设计.*workflow/,/从零/]},{intent:"OPTIMIZE",keywords:["优化","改进","提升","性能","最佳实践","建议"],patterns:[/优化/,/改进/,/有什么建议/,/最佳实践/]},{intent:"EXPLAIN",keywords:["解释","解读","说明","什么意思","怎么理解","是什么","做什么","介绍","讲解","分析","描述","详细","字段","作用","干嘛","有哪些","告诉我","总结","摘要","报告","对比","查看","进度"],patterns:[/解释/,/什么意思/,/干什么/,/是什么/,/怎么[理解工作]/,/介绍.*[流程任务]/,/详细.*[介绍说明参数]/,/[参数字段].*[是什么有哪些]/,/这个.*[是干做]/,/有什么[参数字段属性]/,/对比/,/总结/,/摘要/]}],gk=["帮我","做一个","来个","弄个","需要一个"],xk=["流程","工作流","自动化"];function SN(e){const t=e.toLowerCase().trim();for(const s of yk)if(s.patterns){for(const a of s.patterns)if(a.test(t))return s.intent}for(const s of yk)for(const a of s.keywords)if(t.includes(a))return s.intent;if(t.length<12)return"VAGUE";if(gk.some(s=>t.includes(s))){const s=gk.reduce((i,l)=>i.replace(l,""),t).trim();if(xk.some(i=>s===i||s===i+"。"||s===i+"?")||s.length<=4)return"VAGUE"}return xk.some(s=>t===s||t===`一个${s}`||t===`个${s}`)?"VAGUE":"GENERAL"}function _N(e){switch(e){case"CREATE":return{includeFull:!1};case"REFACTOR":case"OPTIMIZE":case"DEBUG":case"VISUALIZE":return{includeFull:!0};case"VAGUE":return{includeFull:!1};default:return{includeFull:!1}}}const jN="你是 Netflix Conductor 工作流建模专家 AI 助手。帮助用户通过自然语言设计和编辑高可靠性的 Conductor JSON 工作流。\n\n## 核心工作流生成策略(自适应复杂度路由)\n\n### 策略 A:四阶段渐进式构建策略(适用于:从零创建工作流、3+ 节点流程、含分支/并行/循环或大范围重构)\n为了保证高准确性、数据流一致性与配置完整度,**请严格按以下 4 个阶段依次调用工具演进构建**(可在一次或连续多步工具调用中完成):\n1. **阶段 1 — 定义工作流蓝图 (`init_workflow_blueprint`)**:\n - 定义工作流 `name`(英文下划线)、中文 `description`、`timeoutPolicy`、`timeoutSeconds` 及工作流级 `inputParameters` 契约(如 `[\"orderId\", \"userId\", \"amount\"]`)。\n2. **阶段 2 — 设计整体任务编排拓扑 (`scaffold_workflow_topology`)**:\n - 专注整体任务编排逻辑与控制流(顺序、`SWITCH` 条件分支 `decisionCases`/`defaultCase`、`FORK_JOIN` 并行 `forkTasks` 与配对的 `JOIN` `joinOn`、`DO_WHILE` 循环 `loopOver`/`loopCondition`)。\n - 确保每个任务的 `taskReferenceName` 唯一、命名规范且拓扑闭环。\n3. **阶段 3 — 逐项/分批补充任务配置与数据流 (`configure_workflow_tasks`)**:\n - 为各任务补充详细的 `inputParameters`(严格对齐上下游数据流:`${workflow.input.xxx}` 或 `${upstream_ref.output.yyy}`)、HTTP 请求配置(`httpRequest`)、子工作流配置(`subWorkflowParam`)、超时(`timeoutSeconds`)与重试策略(`retryCount` / `retryLogic`),以及工作流 `outputParameters`。\n4. **阶段 4 — 整体验证配置并提交 (`commit_workflow_proposal`)**:\n - 触发全量结构、控制流与数据流引用校验。若校验报告指出引用错误或配置缺失,请用 `configure_workflow_tasks` 修正后再调用 `commit_workflow_proposal`。\n\n### 策略 B:轻量单步修改策略(适用于:局部增/改/删单个任务或修改属性)\n- **patch_workflow** — 用于局部精准修改。ops 支持:\n - `{ op: 'add_task', task: TaskDef, afterRef?: string, parentRef?: string, branchName?: string }` — 新增任务(支持通过 `afterRef` 插入到任意顶层/嵌套任务之后,或通过 `parentRef` + `branchName` 插入到 SWITCH/FORK_JOIN/DO_WHILE 内部)\n - `{ op: 'update_task', ref: string, changes: Partial<TaskDef> }` — 修改任务字段\n - `{ op: 'remove_task', ref: string }` — 删除任务\n - `{ op: 'update_props', props: Partial<WorkflowDef> }` — 修改工作流属性\n - `{ op: 'add_switch_branch', ref: string, caseName: string }` — 添加 SWITCH 分支\n - `{ op: 'add_fork_branch', ref: string }` — 添加 FORK_JOIN 并行分支\n- **replace_workflow** — 仅用于 1-2 个节点的极简流程快速替换。\n\n### 辅助与交互工具\n- **get_workflow_state** — 仅在 system prompt 的工作流上下文不足以回答时才调用(read-only)。\n- **validate_workflow** — 校验当前工作流或草稿的合法性与数据流完整性(read-only)。\n- **propose_plan** — 在执行超大规模破坏性重构前,可先向用户展示计划并等待确认。\n- **ask_clarification** — 当用户意图模糊时调用,展示 2-4 个选项帮助用户精确表达需求。调用后停止,等待用户选择。\n- **recommend_workflow** — 在执行 CREATE 之前,若库中有相似工作流,先推荐给用户。调用后停止等待选择。\n- **不要**在回复正文中直接输出工作流 JSON 代码块,所有变更必须通过工具执行。\n\n## 回复规范\n- 用中文回答,简洁明了\n- 回复正文与流程图标签中不使用 emoji 或装饰符号(界面已有图标)\n- **解释性、介绍性、分析性问题:直接文本回答,不要调用工具**\n- 回答时不要将 system prompt 中的上下文信息(如任务列表、拓扑关系)原文复述——直接聚焦在用户的具体问题上\n- 需要操作工作流时,先简短说明设计思路,再通过工具执行\n- 用户意图模糊时(如\"帮我做个流程\"),先调用 ask_clarification 挖掘真实需求,不要直接创建\n- 创建新工作流前,检查库中是否有相似的,优先推荐已有流程(使用 recommend_workflow)\n\n## Conductor 标准任务类型与建模规范\n- 支持类型:SIMPLE, HTTP, SWITCH, FORK_JOIN, FORK_JOIN_DYNAMIC, DO_WHILE, SUB_WORKFLOW, EVENT, WAIT, HUMAN, INLINE, TERMINATE, SET_VARIABLE, KAFKA_PUBLISH, JSON_JQ_TRANSFORM, START_WORKFLOW, DYNAMIC, NOOP\n- 每个任务必须有唯一的 `taskReferenceName`(仅限英文、数字、下划线,如 `verify_payment`)\n- 下游任务通过 `${upstream_ref.output.field}` 引用上游输出,严禁引用尚未执行的下游任务\n- SWITCH 需要 `evaluatorType` + `expression`(`value-param` 时 expression 是 inputParameters 里的参数名,`javascript` 时是返回分支名的脚本),以及 `decisionCases` 键值对;`caseValueParam` / `caseExpression` 只用于 DECISION\n- FORK_JOIN 需要 `forkTasks`(二维数组)和紧随其后的 `JOIN` 任务(`joinOn` 包含各并行分支最后一个任务的 `taskReferenceName`)\n- DO_WHILE 需要 `loopCondition` 和 `loopOver` 数组\n- HTTP 任务必须配置 `inputParameters.http_request`(含 `uri` 和 `method`),建议设置 `timeoutSeconds` 和 `retryCount`\n\n## 业务流程图(Mermaid)\n当用户要求展示流程图、可视化或 Mermaid 图时:\n- 必须基于 system prompt 注入的\"画布工作流完整 JSON\",不凭记忆生成\n- 输出 ```mermaid 代码块,不调用任何工具\n- 过滤纯技术节点(SET_VARIABLE、JSON_JQ_TRANSFORM、INLINE、NOOP),上下游直连\n- 节点标签用中文业务语言,禁止直接使用 taskReferenceName\n- SWITCH 用菱形 {},FORK_JOIN 用并行路径,HUMAN 标注「人工」";function TN(e,t,r,n){const{systemPrompt:s,systemPromptExtra:a,viewMode:i,pendingProposalDef:l,promptCatalogLimit:c,promptSchemaLimit:d}=n??{},u=SN(e),p=_N(u),f=kN(t,p),m=wN(f),h=[s??jN];l&&h.push(`## 待确认的变更方案
|
|
96
|
+
用户当前有一份尚未确认(未接受也未拒绝)的变更方案,画布上仍是旧版本。本轮的 patch_workflow、get_workflow_state、validate_workflow 等工具都以这份方案为起点(不是画布),新方案的差异仍相对画布计算,因此方案里已有的改动会保留。如果用户是在此方案基础上继续调整,用 patch_workflow 只提交新增的修改即可;只有用户提出全新需求时才用 replace_workflow 重新生成完整方案。
|
|
97
|
+
|
|
98
|
+
\`\`\`json
|
|
99
|
+
${JSON.stringify(l,null,2)}
|
|
100
|
+
\`\`\``);const y=pu.buildPromptSection();y&&h.push(y);const x=Tv.buildPromptSection(d!==void 0?{limit:d}:void 0);x&&h.push(x);const g=NN(r,c);if(g&&h.push(g),m&&h.push(m),!s){const v=EN(u);v&&h.push(`## 当前请求类型提示
|
|
101
|
+
${v}`)}if(!s){const v=CN(i);v&&h.push(v)}return a&&h.push(`## 补充说明
|
|
102
|
+
${a}`),h.join(`
|
|
103
|
+
|
|
104
|
+
`)}const IN=50;function NN(e,t=IN){if(e.length===0)return null;const r=Math.max(0,Math.floor(t));let n=e,s=0;if(e.length>r){const c={L3:0,L2:1,L1:2};n=e.map((d,u)=>({item:d,idx:u})).sort((d,u)=>c[d.item.workflowLevel]-c[u.item.workflowLevel]||d.idx-u.idx).slice(0,r).map(d=>d.item),s=e.length-n.length}const a={L3:n.filter(c=>c.workflowLevel==="L3"),L2:n.filter(c=>c.workflowLevel==="L2"),L1:n.filter(c=>c.workflowLevel==="L1")},i=c=>`- \`${c.workflowName}\` (v${c.version}): ${c.description}`+(c.domain?` [业务域: ${c.domain}]`:"")+(c.tags.length>0?` [${c.tags.join(", ")}]`:""),l=[];if(l.push(`## 可用子工作流库(优先复用,勿重复造轮子)
|
|
105
|
+
|
|
106
|
+
**分层调用规范**
|
|
107
|
+
- L3(端到端)可调用 L2/L1 及同层 L3
|
|
108
|
+
- L2(业务场景)可调用 L1 及同层 L2
|
|
109
|
+
- L1(原子操作)只能调用同层 L1
|
|
110
|
+
- 禁止反向跨层调用(L1 不可调用 L2/L3,L2 不可调用 L3)
|
|
111
|
+
|
|
112
|
+
**引用方式**:使用 SUB_WORKFLOW 任务,把下方名称填入 \`subWorkflowParam.name\`(如 \`"subWorkflowParam": { "name": "create_vm" }\`);版本号可省略,系统会固定为流程库当前版本。
|
|
113
|
+
|
|
114
|
+
**使用策略**
|
|
115
|
+
1. 用户需求完全匹配已有工作流时:直接推荐使用,无需新建
|
|
116
|
+
2. 部分匹配时:用 SUB_WORKFLOW 复用已有模块,仅新增差异部分
|
|
117
|
+
3. 确需新建时:最大化引用已有子工作流作为步骤,同时标注新工作流层级`),a.L3.length>0&&l.push(`### L3 端到端场景
|
|
118
|
+
${a.L3.map(i).join(`
|
|
119
|
+
`)}`),a.L2.length>0&&l.push(`### L2 业务场景
|
|
120
|
+
${a.L2.map(i).join(`
|
|
121
|
+
`)}`),a.L1.length>0)if(a.L1.length<=25)l.push(`### L1 原子操作
|
|
122
|
+
${a.L1.map(i).join(`
|
|
123
|
+
`)}`);else{const c=a.L1.slice(0,10).map(i).join(`
|
|
124
|
+
`);l.push(`### L1 原子操作(共 ${a.L1.length} 个,以下为部分示例)
|
|
125
|
+
${c}
|
|
126
|
+
...
|
|
127
|
+
(使用 search_workflow_library 工具搜索完整 L1 列表)`)}return s>0&&l.push(`另有 ${s} 个子工作流未在此列出,请调用 \`search_workflow_library\` 按关键词或层级检索后再引用。`),l.join(`
|
|
128
|
+
|
|
129
|
+
`)}function CN(e){return!e||e==="standard"?null:e==="business"?`## 语言风格(业务视图)
|
|
130
|
+
当前用户使用**业务视图**——他们可能不熟悉 Conductor 技术细节。请:
|
|
131
|
+
- 用业务语言描述变更,例如「在支付验证后增加了人工审批环节」而非「在 payment_verify 后新增了 taskReferenceName=manual_approve 的 HUMAN 任务」
|
|
132
|
+
- 避免在回复正文中提及 taskReferenceName、inputParameters、timeoutSeconds 等字段名,除非用户主动问到
|
|
133
|
+
- 把工作流步骤描述成"业务动作"(如"发送通知"、"等待审批"),而非"节点类型"
|
|
134
|
+
- 如需解释结构,用"流程分支"替代"SWITCH","并行步骤"替代"FORK_JOIN","人工步骤"替代"HUMAN"`:e==="developer"?`## 语言风格(开发者视图)
|
|
135
|
+
当前用户使用**开发者视图**——他们熟悉 Conductor 技术细节。请:
|
|
136
|
+
- 可直接使用 taskReferenceName、inputParameters、patch ops 等技术术语
|
|
137
|
+
- 解释类问题可提供实现细节,例如 inputParameters 引用格式、retryCount 配置等
|
|
138
|
+
- 涉及变更时可描述具体的 patch ops(如 add_task with afterRef)
|
|
139
|
+
- 如涉及数据流,可引用具体的 \${ref.output.field} 表达式`:null}function EN(e){switch(e){case"CREATE":return"用户要创建新工作流。对于 3 个及以上任务或含分支/并行的业务流程,请优先使用四阶段渐进式策略:1. init_workflow_blueprint 定义元信息与输入契约 -> 2. scaffold_workflow_topology 编排整体拓扑 -> 3. configure_workflow_tasks 补充任务参数与上下游数据流 -> 4. commit_workflow_proposal 整体验证并提交。";case"ADD":return"用户要添加任务。优先用 patch_workflow + add_task,指定正确的 afterRef(或 parentRef + branchName 插入到分支/循环内)。";case"MODIFY":return"用户要修改现有任务。用 patch_workflow + update_task,只传需要变更的字段。";case"DELETE":return"用户要删除任务。用 patch_workflow + remove_task。";case"REFACTOR":return"用户要重构拓扑。对于小幅调整可用 patch_workflow;对于大范围重构可依次通过 scaffold_workflow_topology 重排拓扑 -> configure_workflow_tasks 校准参数与数据流 -> commit_workflow_proposal 整体验证提交。";case"EXPLAIN":return"用户在提问/请求解释。直接文本回答,不要调用任何工具。不要重复任务列表——如需引用任务,只提名称和关键点,不要逐条列出。";case"DEBUG":return"用户在排查问题。先用 validate_workflow 和 get_workflow_state 了解现状,分析后给出诊断。";case"OPTIMIZE":return"用户要优化流程。先分析,再提出方案并执行。";case"VISUALIZE":return`用户要查看工作流的业务流程图。**必须严格基于 system prompt 中注入的"画布工作流完整 JSON"生成**,不允许凭记忆或对话历史构造节点。
|
|
43
140
|
|
|
44
|
-
直接告诉我你想做什么吧!`,timestamp:Date.now()},bS=()=>(e,t)=>({config:{provider:"auto",apiKey:""},messages:[hc],isStreaming:!1,streamingText:"",chatPanelOpen:!0,pendingProposal:null,pendingPlan:null,pendingRepair:null,followUpChips:null,undoStack:[],pendingClarification:null,pendingRecommendation:null,pendingAutoSend:null,toolStatus:"",retryInput:null,timelineEntries:[],synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null,metrics:{totalProposals:0,acceptedProposals:0,rejectedProposals:0,totalPromptTokens:0,totalCompletionTokens:0},setConfig:r=>e(n=>({config:{...n.config,...r}})),addMessage:r=>{const n=`msg_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,s={...r,id:n,timestamp:Date.now()};return e(a=>({messages:[...a.messages,s]})),n},updateMessage:(r,n)=>e(s=>({messages:s.messages.map(a=>a.id===r?{...a,content:n}:a)})),setStreaming:r=>e({isStreaming:r}),setStreamingText:r=>e({streamingText:r}),appendStreamingText:r=>e(n=>({streamingText:n.streamingText+r})),clearMessages:()=>e({messages:[hc],streamingText:"",isStreaming:!1,pendingProposal:null,pendingPlan:null,pendingRepair:null,followUpChips:null,pendingClarification:null,pendingRecommendation:null,pendingAutoSend:null,toolStatus:"",retryInput:null,timelineEntries:[],synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null}),setChatPanelOpen:r=>e({chatPanelOpen:r}),toggleChatPanel:()=>e(r=>({chatPanelOpen:!r.chatPanelOpen})),setProposal:r=>{const n=`prop_${Date.now()}`,s=oe.getState().workflowDef,a=JSON.stringify(s);return e(i=>({pendingProposal:{...r,id:n,baselineHash:a},metrics:{...i.metrics,totalProposals:i.metrics.totalProposals+1}})),n},clearProposal:()=>e({pendingProposal:null}),recordAccept:()=>e(r=>({metrics:{...r.metrics,acceptedProposals:r.metrics.acceptedProposals+1},pendingProposal:null,synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null})),recordReject:()=>e(r=>({metrics:{...r.metrics,rejectedProposals:r.metrics.rejectedProposals+1},pendingProposal:null,synthesisPhase:"idle",workingDraft:null,durableCheckpoint:null})),getMetrics:()=>t().metrics,recordUsage:r=>e(n=>({metrics:{...n.metrics,totalPromptTokens:n.metrics.totalPromptTokens+(r.promptTokens??0),totalCompletionTokens:n.metrics.totalCompletionTokens+(r.completionTokens??0)}})),setFollowUpChips:r=>e({followUpChips:r}),clearFollowUpChips:()=>e({followUpChips:null}),setPlan:r=>{const n=`plan_${Date.now()}`;return e({pendingPlan:{...r,id:n}}),n},clearPlan:()=>e({pendingPlan:null}),setRepair:r=>{const n=`repair_${Date.now()}`;return e({pendingRepair:{...r,id:n}}),n},clearRepair:()=>e({pendingRepair:null}),pushUndo:r=>e(n=>({undoStack:[...n.undoStack.slice(-4),r]})),popUndo:()=>{const r=t().undoStack;if(r.length===0)return null;const n=r[r.length-1];return e({undoStack:r.slice(0,-1)}),n},clearUndo:()=>e({undoStack:[]}),canUndo:()=>t().undoStack.length>0,setClarification:r=>{const n=`clarif_${Date.now()}`;return e({pendingClarification:{...r,id:n}}),n},clearClarification:()=>e({pendingClarification:null}),setRecommendation:r=>{const n=`rec_${Date.now()}`;return e({pendingRecommendation:{...r,id:n}}),n},clearRecommendation:()=>e({pendingRecommendation:null}),setPendingAutoSend:r=>e({pendingAutoSend:r}),setToolStatus:r=>e({toolStatus:r}),setRetryInput:r=>e({retryInput:r}),addTimelineEntry:(r,n="done")=>e(s=>({timelineEntries:[...s.timelineEntries,{id:`tl_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,label:r,icon:n}]})),clearTimeline:()=>e({timelineEntries:[]}),setSynthesisStage:(r,n)=>e(s=>({synthesisPhase:r,workingDraft:n!==void 0?n:s.workingDraft})),saveCheckpoint:r=>e({durableCheckpoint:r}),clearCheckpoint:()=>e({durableCheckpoint:null,synthesisPhase:"idle",workingDraft:null}),hydrateFromDraft:(r,n,s)=>e({messages:r.length>0?r:[hc],pendingProposal:n,durableCheckpoint:s??null,synthesisPhase:s?.phase??"idle",workingDraft:s?.workingDraft??null})});function vS(e="ai-workflow-config"){const t=bS();return e===!1?fn()(t):fn()(rd(t,{name:e,storage:hn(()=>localStorage),partialize:r=>({config:{...r.config,apiKey:""},metrics:r.metrics})}))}const cy=vS(),kS=I.createContext(null);function dy(){return I.useContext(kS)}const SS=()=>{const{mode:e,showWaterfallPanel:t,setShowWaterfallPanel:r,workflowInstance:n,executionData:s,taskMap:a,selectedTask:i,setSelectedTask:l,setSelectedTaskInstance:c,timeTravelTimestamp:u,setTimeTravelTimestamp:d}=oe(ke(x=>({mode:x.mode,showWaterfallPanel:x.showWaterfallPanel,setShowWaterfallPanel:x.setShowWaterfallPanel,workflowInstance:x.workflowInstance,executionData:x.executionData,taskMap:x.taskMap,selectedTask:x.selectedTask,setSelectedTask:x.setSelectedTask,setSelectedTaskInstance:x.setSelectedTaskInstance,timeTravelTimestamp:x.timeTravelTimestamp,setTimeTravelTimestamp:x.setTimeTravelTimestamp}))),p=I.useMemo(()=>{const x=n?.tasks?.length?n.tasks:s?Object.values(s).flatMap(_=>_.attempts):[];if(x.length===0)return null;const b=x.filter(_=>_.startTime||_.scheduledTime);if(b.length===0)return null;const k=Math.min(...b.map(_=>_.scheduledTime||_.startTime||Date.now())),S=Math.max(...b.map(_=>_.endTime||_.startTime||_.scheduledTime||k+100)),C=Math.max(S-k,50),T=b.filter(_=>!["FORK_JOIN","JOIN","DO_WHILE","SWITCH","DECISION"].includes(_.taskType)).map(_=>Math.max((_.endTime||S)-(_.startTime||_.scheduledTime||k),0)).sort((_,j)=>j-_),N=T.length>0?Math.max(T[Math.floor(T.length*.25)]||80,50):100,w=b.map((_,j)=>{const P=_.scheduledTime||_.startTime||k,E=_.startTime||P,A=_.endTime||S,L=Math.max(E-P,0),B=Math.max(A-E,1),z=!["FORK_JOIN","JOIN","DO_WHILE","SWITCH","DECISION"].includes(_.taskType)&&B>=N,R=(P-k)/C*100,q=L/C*100,M=(E-k)/C*100,O=Math.max(B/C*100,1.2);return{key:_.taskId||`${_.referenceTaskName}-${j}`,task:_,sched:P,start:E,end:A,queueMs:L,execMs:B,isCritical:z,queueLeftPct:R,queueWidthPct:q,execLeftPct:M,execWidthPct:O}});return{minTime:k,maxTime:S,totalSpanMs:C,rows:w}},[n,s]);if(e!=="run"||!t||!p)return null;const{minTime:h,totalSpanMs:f,rows:m}=p,y=u!==null?u-h:f,v=Math.min(Math.max(y/f*100,0),100),g=x=>{switch(x){case"COMPLETED":return"#10b981";case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":case"TIMED_OUT":return"#ef4444";case"IN_PROGRESS":return"#38bdf8";default:return"#94a3b8"}};return o.jsxs("div",{style:{position:"absolute",left:16,right:i?466:16,bottom:16,height:255,zIndex:1100,background:"rgba(15, 23, 42, 0.95)",backdropFilter:"blur(16px)",border:"1px solid rgba(56, 189, 248, 0.3)",borderRadius:12,boxShadow:"0 16px 40px rgba(0, 0, 0, 0.45)",display:"flex",flexDirection:"column",overflow:"hidden",transition:"right 0.25s ease"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,padding:"8px 14px",borderBottom:"1px solid rgba(148, 163, 184, 0.16)",background:"rgba(2, 6, 23, 0.55)",flexShrink:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{fontSize:12,fontWeight:700,color:"#f8fafc"},children:"📊 并发执行瀑布流 & 时间旅行调试器"}),o.jsxs("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:999,background:"rgba(56, 189, 248, 0.14)",color:"#38bdf8",fontFamily:"monospace",fontWeight:600},children:["总跨度 ",f,"ms · ",m.length," 个任务步"]}),o.jsx("span",{style:{fontSize:10,padding:"2px 7px",borderRadius:999,background:"rgba(249, 115, 22, 0.15)",color:"#fb923c",fontWeight:600},children:"🔥 关键路径耗时瓶颈高亮"})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flex:1,maxWidth:420},children:[o.jsx("span",{style:{fontSize:10,color:"#94a3b8",whiteSpace:"nowrap"},children:"⏪ 时间旅行指针:"}),o.jsx("input",{type:"range",min:0,max:f,value:y,onChange:x=>{const b=Number(x.target.value);b>=f?d(null):d(h+b)},style:{flex:1,cursor:"pointer",accentColor:"#38bdf8"}}),o.jsx("span",{style:{fontSize:11,fontFamily:"monospace",color:u!==null?"#fbbf24":"#34d399",fontWeight:700,minWidth:74,textAlign:"right"},children:u!==null?`+${y}ms`:"最新态 (Live)"}),u!==null&&o.jsx("button",{type:"button",onClick:()=>d(null),style:{fontSize:10,padding:"2px 7px",borderRadius:4,border:"1px solid rgba(251, 191, 36, 0.4)",background:"rgba(251, 191, 36, 0.12)",color:"#fbbf24",cursor:"pointer"},children:"重置"})]}),o.jsx("button",{type:"button",onClick:()=>r(!1),style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer",fontSize:15,padding:"2px 6px"},children:"✕"})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",position:"relative",padding:"6px 0"},children:m.map(x=>{const b=x.task.referenceTaskName.replace(/__\d+$/,""),k=i?.taskReferenceName===b,S=u!==null&&x.start>u,C=u!==null&&x.start<=u&&x.end>u;return o.jsxs("div",{onClick:()=>{const T=a[b]||x.task.workflowTask;T&&(l(T),c(x.task))},style:{display:"grid",gridTemplateColumns:"210px 1fr 90px",alignItems:"center",gap:8,padding:"4px 14px",cursor:"pointer",background:k?"rgba(56, 189, 248, 0.14)":"transparent",opacity:S?.35:1,borderLeft:k?"3px solid #38bdf8":"3px solid transparent"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,overflow:"hidden",whiteSpace:"nowrap",textOverflow:"ellipsis"},children:[o.jsx("span",{style:{width:7,height:7,borderRadius:"50%",background:C?"#38bdf8":g(x.task.status),flexShrink:0}}),o.jsx("span",{style:{fontSize:11,fontFamily:"monospace",color:"#e2e8f0",fontWeight:k?700:500,overflow:"hidden",textOverflow:"ellipsis"},title:x.task.referenceTaskName,children:x.task.referenceTaskName}),x.isCritical&&o.jsx("span",{title:"关键路径耗时瓶颈节点",style:{fontSize:9,padding:"1px 4px",borderRadius:4,background:"rgba(249, 115, 22, 0.2)",color:"#fb923c",fontWeight:700,flexShrink:0},children:"🔥瓶颈"})]}),o.jsxs("div",{style:{position:"relative",height:14,background:"rgba(15, 23, 42, 0.65)",borderRadius:4,overflow:"hidden",border:"1px solid rgba(148, 163, 184, 0.1)"},children:[x.queueWidthPct>.3&&o.jsx("div",{title:`排队等待: ${x.queueMs}ms`,style:{position:"absolute",left:`${x.queueLeftPct}%`,width:`${x.queueWidthPct}%`,top:3,bottom:3,background:"rgba(148, 163, 184, 0.35)",borderRadius:"2px 0 0 2px"}}),o.jsx("div",{title:`执行耗时: ${x.execMs}ms (排队 ${x.queueMs}ms)`,style:{position:"absolute",left:`${x.execLeftPct}%`,width:`${x.execWidthPct}%`,top:2,bottom:2,borderRadius:3,background:x.isCritical?"linear-gradient(90deg, #f97316, #ef4444)":g(x.task.status),boxShadow:C?"0 0 8px rgba(56, 189, 248, 0.8)":void 0}}),u!==null&&o.jsx("div",{style:{position:"absolute",left:`${v}%`,top:0,bottom:0,width:2,background:"#fbbf24",pointerEvents:"none"}})]}),o.jsxs("div",{style:{fontSize:10,fontFamily:"monospace",color:x.isCritical?"#fb923c":"#94a3b8",textAlign:"right",fontWeight:x.isCritical?700:400},children:[x.execMs,"ms",x.queueMs>0?o.jsxs("span",{style:{opacity:.6,fontSize:9},children:[" (+",x.queueMs,"q)"]}):null]})]},x.key)})})]})};function uy(e){if(!e)return"未设置";if(e<60)return`${e} 秒`;const t=Math.floor(e/60),r=e%60;return r>0?`${t} 分 ${r} 秒`:`${t} 分钟`}function wS(e,t){const r=[];if(e.name!==t.name&&r.push(`名称:「${e.name}」→「${t.name}」`),e.type!==t.type&&r.push(`类型:${e.type} → ${t.type}`),e.timeoutSeconds!==t.timeoutSeconds&&r.push(`超时:${uy(e.timeoutSeconds)} → ${uy(t.timeoutSeconds)}`),(e.retryCount??0)!==(t.retryCount??0)){const n=e.retryCount??0,s=t.retryCount??0;r.push(s>n?`新增失败重试(${s} 次)`:s===0?"移除了失败重试":`重试次数:${n} → ${s}`)}return JSON.stringify(e.inputParameters??{})!==JSON.stringify(t.inputParameters??{})&&r.push("输入参数已调整"),JSON.stringify(e.decisionCases)!==JSON.stringify(t.decisionCases)&&r.push("分支条件已调整"),JSON.stringify(e.forkTasks)!==JSON.stringify(t.forkTasks)&&r.push("并行分支已调整"),r.length===0&&r.push("配置已调整"),r}function _S(e,t){const r=t.tasks??[];if(!e)return{added:r.map(f=>f.taskReferenceName),modified:[],removed:[],propsChanged:!1};const n=new Map((e.tasks??[]).map(f=>[f.taskReferenceName,f])),s=new Map(r.map(f=>[f.taskReferenceName,f])),a=[],i=[],l=[],c=[];for(const[f,m]of s)if(!n.has(f))a.push(f);else{const y=n.get(f);JSON.stringify(m)!==JSON.stringify(y)&&(i.push(f),c.push({ref:f,changes:wS(y,m)}))}for(const f of n.keys())s.has(f)||l.push(f);const u=e.name!==t.name||e.description!==t.description||e.timeoutSeconds!==t.timeoutSeconds||e.version!==t.version||e.ownerEmail!==t.ownerEmail||e.failureWorkflow!==t.failureWorkflow||JSON.stringify(e.inputParameters)!==JSON.stringify(t.inputParameters)||JSON.stringify(e.outputParameters)!==JSON.stringify(t.outputParameters),d=(e.tasks??[]).filter(f=>s.has(f.taskReferenceName)).map(f=>f.taskReferenceName),p=r.filter(f=>n.has(f.taskReferenceName)).map(f=>f.taskReferenceName),h=d.join(",")!==p.join(",");return{added:a,modified:i,removed:l,propsChanged:u,reordered:h,modifiedDetails:c}}const py={apiKey:"",baseUrl:"https://api.openai.com/v1",model:"gpt-4o"},mc=async(e,t={},r)=>{const n={...py,...t};if(!n.apiKey)throw new Error("Please configure AI API Key in settings.");const s=await fetch(`${n.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${n.apiKey}`},body:JSON.stringify({model:n.model,messages:e,temperature:.7,stream:!1}),signal:r});if(!s.ok){const i=await s.json();throw new Error(i.error?.message||"AI request failed")}return(await s.json()).choices[0].message.content},jS=async(e,t={},r,n,s)=>{const a={...py,...t};if(!a.apiKey)throw new Error("Please configure AI API Key in settings.");const i=await fetch(`${a.baseUrl}/chat/completions`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${a.apiKey}`},body:JSON.stringify({model:a.model,messages:e,temperature:.7,stream:!0}),signal:s});if(!i.ok){const d=await i.json();throw new Error(d.error?.message||"AI request failed")}const l=i.body?.getReader();if(!l)throw new Error("ReadableStream not supported");const c=new TextDecoder;let u="";for(;;){const{done:d,value:p}=await l.read();if(d)break;const f=c.decode(p,{stream:!0}).split(`
|
|
45
|
-
|
|
141
|
+
数据来源要求:
|
|
142
|
+
- 所有节点和边必须来自注入的完整 JSON,不允许增加不存在的节点
|
|
143
|
+
- 不允许省略业务节点
|
|
144
|
+
|
|
145
|
+
业务节点过滤(核心规则):
|
|
146
|
+
- 保留(有业务含义):SIMPLE、HTTP、HUMAN、SUB_WORKFLOW、START_WORKFLOW、EVENT、WAIT、DO_WHILE、FORK_JOIN、SWITCH、DECISION
|
|
147
|
+
- 跳过(纯数据处理、无业务含义):SET_VARIABLE、JSON_JQ_TRANSFORM、INLINE、NOOP
|
|
148
|
+
- 跳过节点后,将其上游和下游直接相连,保持流程连通性
|
|
149
|
+
|
|
150
|
+
节点标签规则:
|
|
151
|
+
- 优先使用 task 的 name 字段;若 name 是技术命名则改写为中文业务语言
|
|
152
|
+
- HUMAN 节点:标签加「人工」
|
|
153
|
+
- SUB_WORKFLOW 节点:标签加「子流程」
|
|
154
|
+
- 禁止在节点标签中使用 taskReferenceName
|
|
155
|
+
|
|
156
|
+
控制流规则:
|
|
157
|
+
- SWITCH/DECISION:用菱形节点 {条件},用 decisionCases 的 key 作为各分支的边标签
|
|
158
|
+
- FORK_JOIN:并行分支用多条路径,对应 JOIN 节点用「汇合」标注
|
|
159
|
+
- DO_WHILE:画成循环,用 loopCondition 描述循环条件
|
|
160
|
+
|
|
161
|
+
输出格式:
|
|
162
|
+
- 输出 \`\`\`mermaid 代码块,步骤 ≤ 8 用 flowchart TD,否则用 LR
|
|
163
|
+
- 代码块前一句话描述流程主旨,代码块后可加简短解读
|
|
164
|
+
- 不要调用任何工具`;case"VAGUE":return"用户意图模糊。调用 ask_clarification 提出 2-4 个选项,帮助用户精确表达需求。不要直接创建工作流。";default:return null}}const RN=ck.filter(e=>["get_workflow_state","validate_workflow","search_workflow_library","propose_repair"].includes(e.function.name)),ON=new Set(["propose_repair"]),vk=6,bk=10,PN=2,AN={init_workflow_blueprint:"阶段 1/4:正在定义工作流元信息与参数契约…",scaffold_workflow_topology:"阶段 2/4:正在编排整体任务拓扑与控制流…",configure_workflow_tasks:"阶段 3/4:正在补充任务参数与上下游数据流…",commit_workflow_proposal:"阶段 4/4:正在执行整体语义与数据流校验…",get_workflow_state:"正在读取工作流状态…",search_workflow_library:"正在搜索工作流库…",validate_workflow:"正在校验工作流…",replace_workflow:"正在生成新工作流…",patch_workflow:"正在应用变更…",propose_plan:"正在生成执行计划…",load_library_workflow:"正在加载流程库中的工作流…"},$N={get_workflow_state:"已读取工作流状态",search_workflow_library:"已搜索工作流库",validate_workflow:"已校验工作流"};class DN extends Error{constructor(t){super(t),this.name="AiStreamError"}}const kk=e=>`${e.ref??""}|${e.message}`;function LN(){const e=te.getState();return{workflowDef:e.workflowDef,edges:e.edges,selectedTask:e.selectedTask,executionData:e.executionData,mode:e.mode,workflowInstance:e.workflowInstance,taskMap:e.taskMap,validationResults:e.validationResults}}class MN{constructor(t,r){this.getOptions=t,this.stores=r}controller=null;generation=0;abort(){this.controller?.abort()}reset(){this.generation++,this.controller?.abort(),this.controller=null}transportMode(){return this.stores.aiStore.getState().config.transport?.type??"direct"}toolExecutionContext(t){const r=te.getState();return{workflowDef:r.workflowDef,workingDraft:t??this.stores.aiStore.getState().workingDraft,validationResults:r.validationResults,libraryItems:this.stores.libraryStore.getState().items,resolveLatestVersion:this.latestVersionResolver()}}latestVersionResolver(){const t=this.stores.libraryCatalog;if(t)return r=>t.latest(r)?.version}buildHistory(t,r){const{systemPrompt:n,systemPromptExtra:s,promptCatalogLimit:a,promptSchemaLimit:i}=this.getOptions(),l=te.getState().viewMode,c=this.stores.aiStore.getState().pendingProposal?.proposedDef,u=[{role:"system",content:TN(t,LN(),this.stores.libraryStore.getState().items,{systemPrompt:n,systemPromptExtra:s,viewMode:l,pendingProposalDef:c,promptCatalogLimit:a,promptSchemaLimit:i})}],p=r.slice(-20);for(const f of p)f.id!=="welcome"&&u.push({role:f.role==="assistant"?"assistant":"user",content:f.content});return u.push({role:"user",content:t}),u}async serverLibrarySearch(t){const r=this.stores.libraryCatalog;if(r?.hasServerSearch())try{const n=await r.search(String(t.query??""),{level:t.level,domain:typeof t.domain=="string"&&t.domain.trim()?t.domain.trim():void 0,limit:pk},this.controller?.signal);return n?tp(n):void 0}catch{if(this.controller?.signal.aborted)return;this.stores.aiStore.getState().addTimelineEntry("服务端检索失败,已改用本地目录匹配","warning");return}}async fetchLibraryDefinition(t,r,n){const s=this.stores.libraryCatalog;if(!s||!t)return null;const a=r??s.latest(t)?.version;if(a===void 0)return null;try{return(await s.getVersion(t,a,n))?.def??null}catch{return null}}publishProposal(t,r){this.stores.aiStore.getState().setProposal({proposedDef:t.proposed,diff:t.diff,inferredLevel:t.inferredLevel,verification:t.verification,messageId:r}),this.getOptions().onAiEvent?.({type:"proposal:created",timestamp:Date.now(),diff:{added:t.diff.added.length,modified:t.diff.modified.length,removed:t.diff.removed.length},inferredLevel:t.inferredLevel})}async useLibraryWorkflow(t){const r=this.stores.aiStore;if(r.getState().isStreaming)return!1;const{aiPermissions:n}=this.getOptions();if(n?.canEdit===!1)return r.getState().addMessage({role:"assistant",content:"AI 当前处于只读模式,不能把流程库中的工作流加入画布。"}),!1;r.getState().addMessage({role:"user",content:`直接使用流程库中的「${t}」`});const s=await this.fetchLibraryDefinition(t),a={...this.toolExecutionContext(r.getState().pendingProposal?.proposedDef??null),libraryWorkflowDef:s};let i=In("load_library_workflow",{name:t,mode:"open"},a),l="open";if(i.type!=="propose"&&(i=In("load_library_workflow",{name:t,mode:"reference"},a),l="reference"),i.type==="propose"&&i.proposed&&i.diff){const c=l==="open"?`已打开流程库中的「${t}」作为变更方案:${Nn(i.diff)}。`:`流程库只提供了「${t}」的摘要,已在流程末尾以子流程步骤引用它:${Nn(i.diff)}。`,d=r.getState().addMessage({role:"assistant",content:`${c}
|
|
165
|
+
请在下方应用或拒绝此变更。`});return this.publishProposal({proposed:i.proposed,diff:i.diff,inferredLevel:i.inferredLevel,verification:i.verification},d),!0}return r.getState().addMessage({role:"assistant",content:i.text??`无法加载「${t}」。请在工作流库标签页确认它是否存在。`}),!1}commitDraftNow(){const t=this.stores.aiStore,r=t.getState().workingDraft??t.getState().durableCheckpoint?.workingDraft;if(!r||!Array.isArray(r.tasks)||r.tasks.length===0)return!1;const n=In("commit_workflow_proposal",{},this.toolExecutionContext(r));if(n.type==="propose"&&n.proposed&&n.diff){const a=[...t.getState().messages].reverse().find(i=>i.role==="assistant"&&i.id!=="welcome")?.id??t.getState().addMessage({role:"assistant",content:"已采用当前阶段的工作流草稿。"});return this.publishProposal({proposed:n.proposed,diff:n.diff,inferredLevel:n.inferredLevel,verification:n.verification},a),t.getState().saveCheckpoint(null),t.getState().setSynthesisStage("completed",null),!0}return!1}async resume(t){const r=this.stores.aiStore,n=r.getState(),s=n.durableCheckpoint;if(!s||n.isStreaming)return;const{onAiEvent:a}=this.getOptions();a?.({type:"session:resumed",timestamp:Date.now(),phase:s.phase});const i=[...s.agentHistory];let l=s.assistantMsgId;t&&t.trim()?(n.addMessage({role:"user",content:t.trim()}),i.push({role:"user",content:t.trim()}),l=n.addMessage({role:"assistant",content:""})):n.messages.some(c=>c.id===l)||(l=n.addMessage({role:"assistant",content:""})),n.setRetryInput(null),n.setPendingSend(null),await this.runDurableLoop({sessionId:s.sessionId,userPrompt:s.userPrompt,assistantMsgId:l,agentHistory:i,initialDraft:s.workingDraft,baseDraft:r.getState().pendingProposal?.proposedDef??null,initialPhase:s.phase,startStep:s.stepIndex,initialSelfHealCount:s.selfHealCount})}async send(t,r={}){const n=this.stores.aiStore,s=n.getState();if(!t.trim()||s.isStreaming)return;const a=r.modelText?.trim()?r.modelText:t,i=n.getState().config;if(!i.apiKey&&!i.transport){s.addMessage({role:"user",content:t}),s.addMessage({role:"assistant",content:"未配置 API Key。请点击对话面板右上角的设置按钮配置 AI 服务后重试。"});return}const l=s.durableCheckpoint;if(l&&l.status!=="completed"&&!r.discardCheckpoint){s.setPendingSend({text:t,...r.modelText?{modelText:r.modelText}:{}});return}s.setPendingSend(null);const c=s.messages;s.addMessage({role:"user",content:t}),s.setRetryInput(null),s.clearFollowUpChips(),s.setStreaming(!0),s.setStreamingText(""),s.setToolStatus(""),s.clearTimeline(),s.setSynthesisStage("idle",null),s.saveCheckpoint(null);const d=s.addMessage({role:"assistant",content:""}),u=this.buildHistory(a,c);await this.runDurableLoop({sessionId:`sess_${Date.now()}_${Math.random().toString(36).slice(2,6)}`,userPrompt:a,displayText:t,assistantMsgId:d,agentHistory:u,initialDraft:null,baseDraft:n.getState().pendingProposal?.proposedDef??null,initialPhase:"idle",startStep:0,initialSelfHealCount:0})}async runDurableLoop(t){const r=this.stores.aiStore,n=this.stores.toolRegistry,{aiPermissions:s,onAiEvent:a}=this.getOptions(),i=r.getState().config,l=this.transportMode();this.controller?.abort();const c=new AbortController;this.controller=c;const{signal:d}=c,u=this.generation,p=()=>u===this.generation;r.getState().setStreaming(!0),r.getState().setStreamingText(""),r.getState().setToolStatus("");const{sessionId:f,userPrompt:m,assistantMsgId:h,agentHistory:y}=t;let x=t.initialDraft??t.baseDraft,g=t.initialPhase,v=t.initialSelfHealCount,k=t.startStep,b=t.initialDraft!==null,S=!1,j=!1,_="",w="";const I=te.getState().workflowDef,N=new Set(I&&Array.isArray(I.tasks)&&I.tasks.length>0?ar(I).errors.map(kk):[]);(t.initialDraft||g!=="idle")&&r.getState().setSynthesisStage(g,x);const C=(O,$)=>{if(p()){if(O==="completed"){r.getState().saveCheckpoint(null);return}r.getState().saveCheckpoint({sessionId:f,userPrompt:m,assistantMsgId:h,phase:g,workingDraft:b?x:null,agentHistory:[...y],stepIndex:k,selfHealCount:v,status:O,lastError:$,updatedAt:Date.now()})}},M=()=>b||k>t.startStep||t.startStep>0,R=O=>{w+=(w?`
|
|
166
|
+
|
|
167
|
+
`:"")+O};try{const O=n.getDefinitions(),$=s?.canEdit!==!1,B=s?.canRepair!==!1,q=()=>{const D=te.getState().mode;let Z=D==="run"||!$?RN:[...ck.filter(L=>!ON.has(L.function.name)),...O];return B||(Z=Z.filter(L=>L.function.name!=="propose_repair")),{mode:D,activeDefs:Z,allowedToolNames:new Set(Z.map(L=>L.function.name))}},F=()=>te.getState().mode!=="run"&&$;w=r.getState().messages.find(D=>D.id===h)?.content??"";for(let D=t.startStep;;D++){const Z=b||g!=="idle"?bk:vk;if(d.aborted)break;if(D-t.startStep>=Z){j=!0;break}k=D,r.getState().setStreamingText(""),D>0&&g==="idle"&&r.getState().setToolStatus(`步骤 ${D+1}…`);const L=[];_="";const H=q();for await(const ne of lk(y,H.activeDefs,i,d)){if(d.aborted)break;switch(ne.type){case"text":_+=ne.content,r.getState().appendStreamingText(ne.content);break;case"tool_call":L.push({id:ne.id,name:ne.name,args:ne.args});break;case"error":throw new DN(ne.message);case"usage":r.getState().recordUsage({promptTokens:ne.promptTokens,completionTokens:ne.completionTokens});break}}const U=_;if(_="",U&&R(U),!L.length||d.aborted)break;y.push({role:"assistant",content:U,tool_calls:L});const K=[];let se=null,pe=null;const we=q();for(const ne of L){if(d.aborted)break;if(!H.allowedToolNames.has(ne.name)||!we.allowedToolNames.has(ne.name)){const X=we.mode==="run"?"运行态只能查看和诊断":$?"本轮没有提供这个工具":"当前没有编辑权限";K.push({role:"tool",content:`调用被拒绝:工具 ${ne.name} 不在本轮可用的工具列表里(${X})。不要再调用它,改用可用的工具,或直接回复用户。`,tool_call_id:ne.id}),r.getState().addTimelineEntry(`已拒绝调用 ${ne.name}:${X}`,"warning");continue}if(r.getState().setToolStatus(AN[ne.name]??`执行 ${ne.name}…`),a?.({type:"tool:called",timestamp:Date.now(),tool:ne.name}),ne.name==="propose_repair"){K.push({role:"tool",content:"修复方案已展示给用户,等待用户执行操作。",tool_call_id:ne.id}),r.getState().setRepair({diagnosis:ne.args.diagnosis??"未提供诊断信息",actions:ne.args.actions??[],messageId:h}),r.getState().addTimelineEntry("已生成修复方案"),a?.({type:"repair:proposed",timestamp:Date.now()});break}if(ne.name==="ask_clarification"){K.push({role:"tool",content:"澄清问题已展示给用户,等待用户回复。",tool_call_id:ne.id}),r.getState().setClarification({question:ne.args.question??"请告诉我更多详情",context:ne.args.context,options:ne.args.options??[],messageId:h}),r.getState().addTimelineEntry("准备澄清问题");break}if(ne.name==="recommend_workflow"){K.push({role:"tool",content:"已向用户展示相似工作流推荐,等待用户选择。",tool_call_id:ne.id}),r.getState().setRecommendation({userIntent:ne.args.userIntent??"",recommendations:ne.args.recommendations??[],messageId:h}),r.getState().addTimelineEntry("已匹配推荐工作流");break}if(ne.name==="propose_plan"){pe={title:ne.args.title??"执行计划",steps:ne.args.steps??[],summary:ne.args.summary},K.push({role:"tool",content:"计划已展示给用户,等待确认后执行。",tool_call_id:ne.id}),r.getState().addTimelineEntry("已生成执行计划");break}const Te=n.get(ne.name);if(Te){let X;try{X=await Promise.resolve(Te.execute(ne.args)),r.getState().addTimelineEntry(`已执行 ${ne.name}`)}catch(z){X=`工具执行失败:${z.message??"未知错误"}`,r.getState().addTimelineEntry(`${ne.name} 执行失败`,"warning")}K.push({role:"tool",content:X,tool_call_id:ne.id});continue}let le;try{const X=this.toolExecutionContext(x);ne.name==="search_workflow_library"&&(X.librarySearchResults=await this.serverLibrarySearch(ne.args)),ne.name==="load_library_workflow"&&(X.libraryWorkflowDef=await this.fetchLibraryDefinition(String(ne.args.name??""),typeof ne.args.version=="number"?ne.args.version:void 0,d)),le=In(ne.name,ne.args,X)}catch(X){K.push({role:"tool",content:`工具执行出错:${X?.message??"未知错误"}`,tool_call_id:ne.id}),r.getState().addTimelineEntry(`${ne.name} 执行出错`,"warning");continue}let V;if(le.type==="stage")le.workingDraft&&(x=le.workingDraft,b=!0),le.phase&&(g=le.phase),r.getState().setSynthesisStage(g,x),le.timelineLabel&&r.getState().addTimelineEntry(le.timelineLabel,"done"),a?.({type:"stage:completed",timestamp:Date.now(),phase:g}),V=le.text??"阶段已完成。";else if(le.type==="propose"&&le.proposed&&le.diff){const X=le.verification??ar(le.proposed),z=X.errors.filter(ve=>!N.has(kk(ve)));if(z.length>0&&v<PN){v++,x=le.proposed,b=!0,g="verify",r.getState().setSynthesisStage("verify",x);const ve=z.map(he=>`• [${he.ref||"GLOBAL"}] ${he.message}`).join(`
|
|
168
|
+
`);V=`工作流已生成,但整体校验发现 ${z.length} 个新引入的错误,请通过 configure_workflow_tasks、patch_workflow 或 replace_workflow 修复后重新提交:
|
|
169
|
+
${ve}`,r.getState().addTimelineEntry(`发现 ${z.length} 处校验问题,正在自动修正…`,"warning")}else{x=le.proposed,b=!0,g="completed",r.getState().setSynthesisStage("completed",x),se={proposed:le.proposed,diff:le.diff,inferredLevel:le.inferredLevel,verification:X};const ve=Nn(le.diff);V=`变更方案已生成${X.errors.length>0?`(含 ${X.errors.length} 个校验错误)`:""}:${ve}。等待用户确认。`;const _e=X.totalTasks||(le.proposed.tasks?.length??0);r.getState().addTimelineEntry(`已生成方案 · 共 ${_e} 个步骤`,X.errors.length>0?"warning":"done")}}else le.type==="info"?(V=le.text??"",r.getState().addTimelineEntry($N[ne.name]??`已执行 ${ne.name}`)):(V=`错误:${le.text??"未知错误"}`,r.getState().addTimelineEntry(`${ne.name} 执行出错`,"warning"));K.push({role:"tool",content:V,tool_call_id:ne.id})}const Ce=new Set(K.map(ne=>ne.tool_call_id));for(const ne of L)Ce.has(ne.id)||K.push({role:"tool",content:"操作已中止,等待用户确认后继续。",tool_call_id:ne.id});if(y.push(...K),k=D+1,C("running"),r.getState().pendingRepair?.messageId===h){R("我已诊断出故障原因并准备了修复方案,请查看下方修复卡片。");break}if(r.getState().pendingClarification?.messageId===h||r.getState().pendingRecommendation?.messageId===h)break;if(pe){r.getState().setPlan({title:pe.title,steps:pe.steps,summary:pe.summary,messageId:h}),a?.({type:"plan:created",timestamp:Date.now()}),R("我已为你准备了一个执行计划,请查看下方方案并决定是否执行。");break}if(se){this.publishProposal(se,h),S=!0;const ne=Nn(se.diff),Te=se.inferredLevel?` · ${se.inferredLevel}`:"";w+=`
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
**已生成变更方案${Te}**:${ne}
|
|
173
|
+
请在下方应用或拒绝此变更。`;break}}const W=r.getState(),P=W.pendingClarification?.messageId===h||W.pendingPlan?.messageId===h||W.pendingRecommendation?.messageId===h||W.pendingRepair?.messageId===h;if(p()&&F()&&!d.aborted&&!j&&!P&&!S&&b&&x&&Array.isArray(x.tasks)&&x.tasks.length>0){const D=In("commit_workflow_proposal",{},this.toolExecutionContext(x));if(D.type==="propose"&&D.proposed&&D.diff){g="completed",r.getState().setSynthesisStage("completed",D.proposed),r.getState().addTimelineEntry(`阶段 4/4:已完成整体校验并生成方案 · 共 ${D.verification?.totalTasks??D.proposed.tasks.length} 个步骤`,D.verification&&!D.verification.isValid?"warning":"done"),this.publishProposal({proposed:D.proposed,diff:D.diff,inferredLevel:D.inferredLevel,verification:D.verification},h),S=!0;const Z=Nn(D.diff),L=D.inferredLevel?` · ${D.inferredLevel}`:"";w+=`
|
|
174
|
+
|
|
175
|
+
---
|
|
176
|
+
**已生成变更方案${L}**:${Z}
|
|
177
|
+
请在下方应用或拒绝此变更。`}}if(!p())return;if(d.aborted)M()&&C("paused"),r.getState().updateMessage(h,this.abortedText(w,_));else if(j&&!S){const D=b||g!=="idle"?bk:vk;C("paused",`已达到单轮 ${D} 步上限`),r.getState().setToolStatus(""),R(`**已暂停**:本轮已用完 ${D} 步的上限,AI 停在这里,还没有生成变更方案。点击下方"从断点继续生成"让 AI 接着完成;或把需求拆成更小的步骤重新发送。`),r.getState().updateMessage(h,w.trim())}else C("completed"),r.getState().setToolStatus(""),r.getState().updateMessage(h,w.trim()||(P||S?"请查看下方卡片。":"AI 没有返回任何内容。请换个说法重新发送;如持续出现,请在 AI 设置中检查模型配置。"))}catch(O){if(!p())return;if(r.getState().setToolStatus(""),O?.name!=="AbortError"){const $=Hs(O?.message,{mode:l}),B=[w,_].filter(q=>q&&q.trim()).join(`
|
|
178
|
+
|
|
179
|
+
`).trim();if(r.getState().updateMessage(h,`${B?`${B}
|
|
180
|
+
|
|
181
|
+
`:""}**出错了**:${$.display}`),a?.({type:"ai:error",timestamp:Date.now(),rawMessage:$.raw}),M())C("failed",$.display);else{const q=t.displayText??m;r.getState().setRetryInput(q,q!==m?m:null)}}else M()&&C("paused"),r.getState().updateMessage(h,this.abortedText(w,_))}finally{p()&&(r.getState().setStreaming(!1),r.getState().setStreamingText(""),r.getState().setToolStatus(""))}}abortedText(t,r){const n=[t,r].filter(s=>s&&s.trim()).join(`
|
|
182
|
+
|
|
183
|
+
`).trim();return n?`${n}
|
|
184
|
+
|
|
185
|
+
(已中止)`:"(已中止)"}}class WN{tools=new Map;register(t){this.tools.set(t.definition.function.name,t)}unregister(t){this.tools.delete(t)}get(t){return this.tools.get(t)}getAll(){return Array.from(this.tools.values())}getDefinitions(){return this.getAll().map(t=>t.definition)}setTools(t){this.tools.clear();for(const r of t)this.tools.set(r.definition.function.name,r)}has(t){return this.tools.has(t)}}const zN=new WN,Cn="未配置 AI 服务。请先填写 API Key(集成方通过 aiConfig 传入,或在 AI 设置中填写)后重试。";function En(e){return!!(e?.transport||e?.apiKey?.trim())}async function wk(e,t,r,n){if(!En(t))throw new Error(Cn);const s={provider:"auto",...t,apiKey:t.apiKey??""},a=s.transport?.type??"direct";let i="";for await(const l of lk(e,[],s,n))if(l.type==="text")i+=l.content,r?.(l.content);else if(l.type==="error"){const c=new Error(Hs(l.message,{mode:a}).display);throw c.raw=l.message,c}return i}const Sk=async(e,t={},r)=>{try{return await wk(e,t,void 0,r)}catch(n){throw n?.name==="AbortError"||n?.message===Cn||n?.raw?n:new Error(Hs(n?.message,{mode:t.transport?.type??"direct"}).display)}},qN=async(e,t={},r,n,s)=>{try{const a=await wk(e,t,r,s);return n?.(),a}catch(a){throw a?.name==="AbortError"||a?.message===Cn||a?.raw?a:new Error(Hs(a?.message,{mode:t.transport?.type??"direct"}).display)}},FN=(e,t,r,n,s)=>`
|
|
46
186
|
You are a Netflix Conductor expert. Generate a complete "inputParameters" JSON object for the following task.
|
|
47
187
|
|
|
48
188
|
Task Type: ${e}
|
|
@@ -66,7 +206,7 @@ Rules:
|
|
|
66
206
|
6. Return ONLY the JSON object (no explanation, no markdown code block).
|
|
67
207
|
|
|
68
208
|
Return format: { "paramKey": "paramValue", ... }
|
|
69
|
-
`,
|
|
209
|
+
`,BN=async(e,t,r,n,s,a={})=>{const i=FN(e,t,r,n,s),c=(await Sk([{role:"system",content:"You are a Conductor expert. Return only valid JSON objects, no markdown."},{role:"user",content:i}],a)).replace(/```json\n?/g,"").replace(/```\n?/g,"").trim();try{return JSON.parse(c)}catch{throw new Error("AI 返回的内容不是有效的 JSON 参数。请重试,或在 AI 设置中换用更强的模型。")}},HN=`
|
|
70
210
|
You are an expert in Netflix Conductor Workflow modeling.
|
|
71
211
|
Your goal is to help users design JSON-based workflows.
|
|
72
212
|
|
|
@@ -78,12 +218,8 @@ CONSTRANTS:
|
|
|
78
218
|
5. For FORK_JOIN, ensure a corresponding JOIN task follows.
|
|
79
219
|
|
|
80
220
|
Provide clear, enterprise-grade logic with proper error handling paths.
|
|
81
|
-
|
|
82
|
-
Upstream tasks in scope: ${k.map(B=>B.taskReferenceName).join(", ")||"none"}.
|
|
83
|
-
Current workflow JSON:
|
|
84
|
-
${JSON.stringify(s,null,2)}
|
|
85
|
-
|
|
86
|
-
Return ONLY the updated full WorkflowDef JSON object (wrapped in \`\`\`json ... \`\`\`) that fulfills the user's instruction.`,A=await mc([{role:"system",content:E},{role:"user",content:N}],P),L=A.match(/```(?:json)?\s*([\s\S]*?)```/)||A.match(/(\{[\s\S]*\})/);if(L){const B=JSON.parse(L[1]);if(B&&Array.isArray(B.tasks)){const z=_S(s,B);d({proposedDef:B,diff:z,messageId:`inline-cmdk-${Date.now()}`}),h(""),r(null);return}}v("⚠️ 未能解析 AI 返回的工作流 JSON,请重试")}catch(_){v(`❌ 调用失败: ${_?.message||"未知错误"}`)}finally{m(!1)}};return o.jsxs("div",{style:{position:"absolute",top:68,left:"50%",transform:"translateX(-50%)",width:540,maxWidth:"calc(100vw - 40px)",zIndex:2200,background:"rgba(15, 23, 42, 0.96)",backdropFilter:"blur(20px)",border:"1px solid rgba(99, 102, 241, 0.45)",borderRadius:14,boxShadow:"0 24px 60px rgba(0, 0, 0, 0.55), 0 0 0 1px rgba(99, 102, 241, 0.15)",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:"linear-gradient(90deg, rgba(99, 102, 241, 0.18), rgba(56, 189, 248, 0.1))",borderBottom:"1px solid rgba(148, 163, 184, 0.15)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:5,background:"#6366f1",color:"#fff"},children:"⌘K 画布内联指令"}),o.jsxs("span",{style:{fontSize:11,color:"#cbd5e1",fontFamily:"monospace"},children:["锚点:"," ",o.jsx("strong",{style:{color:"#38bdf8"},children:b?`${b.name} (${b.taskReferenceName})`:"画布全局"})]}),k.length>0&&o.jsxs("span",{style:{fontSize:10,color:"#94a3b8"},children:["· 可见上游 ",k.length," 个节点"]})]}),o.jsx("button",{type:"button",onClick:()=>r(null),style:{background:"none",border:"none",color:"#94a3b8",cursor:"pointer",fontSize:13},children:"ESC ✕"})]}),o.jsxs("form",{onSubmit:C,style:{display:"flex",padding:"10px 14px",gap:8},children:[o.jsx("input",{ref:g,type:"text",value:p,onChange:T=>h(T.target.value),disabled:f,placeholder:"输入自然语言指令,如:在此节点后加一个风控 HTTP 校验并判断状态码...",style:{flex:1,padding:"9px 12px",borderRadius:8,border:"1px solid rgba(148, 163, 184, 0.25)",background:"rgba(2, 6, 23, 0.65)",color:"#f8fafc",fontSize:13,outline:"none"}}),o.jsx("button",{type:"submit",disabled:f||!p.trim(),style:{padding:"0 16px",borderRadius:8,border:"none",background:"linear-gradient(135deg, #6366f1, #38bdf8)",color:"#fff",fontSize:12,fontWeight:700,cursor:f||!p.trim()?"not-allowed":"pointer",opacity:f||!p.trim()?.6:1},children:f?"生成中...":"执行 ↵"})]}),b&&o.jsxs("div",{style:{padding:"6px 14px 12px",display:"flex",flexWrap:"wrap",gap:6},children:[NS.map(T=>o.jsx("button",{type:"button",onClick:()=>S(T),style:{fontSize:11,padding:"4px 10px",borderRadius:999,border:"1px solid rgba(148, 163, 184, 0.2)",background:"rgba(30, 41, 59, 0.65)",color:"#cbd5e1",cursor:"pointer"},children:T.label},T.label)),o.jsx("button",{type:"button",onClick:()=>{c(b,!0),r(null)},style:{fontSize:11,padding:"4px 10px",borderRadius:999,border:"1px solid rgba(56, 189, 248, 0.3)",background:"rgba(56, 189, 248, 0.1)",color:"#38bdf8",cursor:"pointer"},children:"⚙️ 打开属性抽屉"})]}),y&&o.jsx("div",{style:{padding:"6px 14px 10px",fontSize:11,color:"#38bdf8",borderTop:"1px solid rgba(148, 163, 184, 0.1)"},children:y})]})},RS={taskNode:E0,decisionNode:P0,forkNode:Qg.ForkNode,joinNode:Qg.JoinNode,loopNode:A0,subWorkflowNode:M0,plusNode:z0,dynamicPlaceholderNode:W0},PS={addableEdge:U0},OS=({onNodeClick:e,searchQuery:t="",onSave:r,onRequestImport:n,executionActions:s})=>{const{nodes:a,edges:i,onNodesChange:l,onEdgesChange:c,onConnect:u,mode:d,viewMode:p,selectedTask:h,setSelectedTask:f,selectTaskAction:m,theme:y,edgeType:v,addNode:g,nodesLocked:x,executionData:b,validationResults:k,isDetailPanelOpen:S,setIsDetailPanelOpen:C,workflowDef:T,setWorkflow:N,dynamicRuntimeTasksByFork:w,layoutDirection:_,simState:j,isSimRunning:P,workflowLoadKey:E,showDataLineage:A}=oe(ke(Z=>({nodes:Z.nodes,edges:Z.edges,onNodesChange:Z.onNodesChange,onEdgesChange:Z.onEdgesChange,onConnect:Z.onConnect,mode:Z.mode,viewMode:Z.viewMode,selectedTask:Z.selectedTask,setSelectedTask:Z.setSelectedTask,selectTaskAction:Z.selectTaskAction,theme:Z.theme,edgeType:Z.edgeType,addNode:Z.addNode,nodesLocked:Z.nodesLocked,executionData:Z.executionData,validationResults:Z.validationResults,isDetailPanelOpen:Z.isDetailPanelOpen,setIsDetailPanelOpen:Z.setIsDetailPanelOpen,workflowDef:Z.workflowDef,setWorkflow:Z.setWorkflow,dynamicRuntimeTasksByFork:Z.dynamicRuntimeTasksByFork,layoutDirection:Z.layoutDirection,simState:Z.simState,isSimRunning:Z.isSimRunning,workflowLoadKey:Z.workflowLoadKey,showDataLineage:Z.showDataLineage}))),L=I.useMemo(()=>{if(p==="developer")return new Set(a.map(ae=>ae.id));const Z=_0[p],ee=new Set;return a.forEach(ae=>{if(ae.type==="dynamicPlaceholderNode"){ee.add(ae.id);return}if(ae.type==="plusNode"){d==="edit"&&(!ae.data?.parentRef||ee.has(ae.data.parentRef))&&ee.add(ae.id);return}if(d==="run"&&b){const fe=b[ae.id]?.status;if(fe==="FAILED"||fe==="FAILED_WITH_TERMINAL_ERROR"||fe==="TIMED_OUT"||fe==="IN_PROGRESS"){ee.add(ae.id);return}}if(ae.parentId)return;const Q=Qe.find(fe=>fe.type===ae.data.taskType)?.viewCategory??"business";Z.includes(Q)&&ee.add(ae.id)}),a.forEach(ae=>{if(ae.parentId&&ee.has(ae.parentId)){if(ae.type==="plusNode"){d==="edit"&&ee.add(ae.id);return}const Q=Qe.find(fe=>fe.type===ae.data.taskType)?.viewCategory??"business";Z.includes(Q)&&ee.add(ae.id)}}),ee},[a,p,d,b]),B=I.useCallback(Z=>{if(L.size===a.length)return Z;const ee={};Z.forEach(Q=>{ee[Q.source]||(ee[Q.source]=[]),ee[Q.source].push(Q)});const ae=[],pe=new Set;return Z.forEach(Q=>{if(!L.has(Q.source))return;if(L.has(Q.target)){const Y=`${Q.source}->${Q.target}`;pe.has(Y)||(pe.add(Y),ae.push(Q));return}const fe=[{to:Q.target,label:Q.label}],D=new Set;for(;fe.length;){const Y=fe.shift();if(!D.has(Y.to)){if(D.add(Y.to),L.has(Y.to)){const ce=`${Q.source}->${Y.to}`;pe.has(ce)||(pe.add(ce),ae.push({...Q,id:ce,target:Y.to,label:Y.label??Q.label}));continue}(ee[Y.to]??[]).forEach(ce=>fe.push({to:ce.target,label:Y.label??ce.label}))}}}),ae},[L,a.length]),R=dy()?.aiStore??cy,q=R(Z=>Z.pendingProposal),M=R(Z=>Z.clearProposal),O=R(Z=>Z.recordAccept),W=R(Z=>Z.recordReject),U=R(Z=>Z.pushUndo),$=I.useMemo(()=>{if(!q)return null;try{const{nodes:Z,edges:ee}=Me(q.proposedDef,_,{hideEmptyBranches:!1}),{nodes:ae,edges:pe}=Oe(Z,ee,{direction:_,mode:"edit"}),Q=new Set(q.diff.added),fe=new Set(q.diff.modified),D=new Set(q.diff.removed),Y=new Map(a.map(re=>[re.data?.taskReferenceName,re])),ce=ae.filter(re=>re.type!=="plusNode").map(re=>{const ve=re.data?.taskReferenceName,X=Q.has(ve)?"added":fe.has(ve)?"modified":void 0;return{...re,draggable:!1,selectable:!1,data:{...re.data,proposalStatus:X,layoutDirection:_}}}),se=[...D].map(re=>Y.get(re)).filter(re=>re!=null).map(re=>({...re,draggable:!1,selectable:!1,data:{...re.data,proposalStatus:"removed"}}));return{nodes:[...ce,...se],edges:pe}}catch{return null}},[q,a,_]),{fitView:H}=F.useReactFlow(),[K,V]=I.useState(!1),[te,ue]=I.useState(null),[ye,_e]=I.useState(!1),[Ne,J]=I.useState(!1),{confirm:Se,confirmState:ne,handleConfirm:xe,handleCancel:ie}=Br(),{toasts:je,showToast:me,dismissToast:ge}=xS();yS({confirm:Se,showToast:me,onSave:r}),I.useEffect(()=>{if(h){const Z=a.find(ee=>ee.data.taskReferenceName===h.taskReferenceName);Z&&H({nodes:[Z],duration:800,padding:.5})}},[h?.taskReferenceName,H]),I.useEffect(()=>{const Z=()=>{H({duration:800})};return window.addEventListener("workflow-zoom-to-fit",Z),()=>window.removeEventListener("workflow-zoom-to-fit",Z)},[H]),I.useEffect(()=>{if(E===0)return;const Z=setTimeout(()=>{H({duration:600,padding:.12})},50);return()=>clearTimeout(Z)},[E,H]),I.useEffect(()=>{const Z=pe=>{e&&pe.detail&&pe.detail.task&&e(pe.detail.task)},ee=pe=>{if(d==="edit"){const{loopId:Q,afterRef:fe}=pe.detail;ue(fe?{sourceId:fe,edgeData:{}}:{sourceId:Q,edgeData:{isLoopAdd:!0}}),V(!0)}},ae=pe=>{d==="edit"&&(ue({sourceId:pe.detail.source,targetId:pe.detail.target,edgeId:pe.detail.id,edgeData:pe.detail.edgeData}),V(!0))};return document.addEventListener("miniTaskClick",Z),document.addEventListener("loopAddNodeRequested",ee),window.addEventListener("edgeAddNode",ae),()=>{document.removeEventListener("miniTaskClick",Z),document.removeEventListener("loopAddNodeRequested",ee),window.removeEventListener("edgeAddNode",ae)}},[d,e]);const Fe=I.useCallback(Z=>{if(te){const{sourceId:ee,targetId:ae,edgeId:pe,edgeData:Q}=te;g({data:{label:`New ${Z}`,taskReferenceName:`${Z.toLowerCase()}_${Date.now()}`,taskType:Z}},ee,ae,pe,Q)}V(!1),ue(null)},[te,g]),Te=I.useMemo(()=>{const Z={layoutedNodes:null,extraNodes:[],extraEdges:[],removedEdgeIds:new Set,removedNodeIds:new Set};if(d!=="run")return Z;const ee=a.filter(Y=>Y.type==="forkNode"&&Y.data.taskType==="FORK_JOIN_DYNAMIC");if(!ee.length)return Z;const ae=[],pe=[],Q=new Set,fe=new Set;for(const Y of ee){const ce=w[Y.id]||[],se=`${Y.id}_dynamic_placeholder`,re=i.find(de=>de.target===se),ve=i.find(de=>de.source===se);let X,le;if(ve)X=ve.target,le=a.find(de=>de.id===X);else{const de=a.indexOf(Y);if(le=a.slice(de).find(Ie=>Ie.type==="joinNode"),!le)continue;X=le.id}le&&(ve&&Q.add(ve.id),re&&Q.add(re.id),fe.add(se),ce.length&&ce.forEach(de=>{const Ie=`dynamic_rt_${de.referenceTaskName}`;ae.push({id:Ie,type:"taskNode",data:{label:de.taskDefName||de.referenceTaskName,task:{name:de.taskDefName||de.referenceTaskName,taskReferenceName:de.referenceTaskName,type:de.taskType||"SIMPLE"},taskReferenceName:de.referenceTaskName,taskType:de.taskType||"SIMPLE",isDynamicRuntime:!0,layoutDirection:_},position:{x:0,y:0}}),pe.push({id:`e-${Y.id}-${Ie}`,source:Y.id,target:Ie,style:{strokeDasharray:"4,4"}}),pe.push({id:`e-${Ie}-${X}`,source:Ie,target:X,style:{strokeDasharray:"4,4"}})}))}let D=null;if(ae.length>0){const Y=[...a.filter(re=>!fe.has(re.id)),...ae],ce=[...i.filter(re=>!Q.has(re.id)),...pe];D=Oe(Y,ce,{direction:_,mode:"run"}).nodes}return{layoutedNodes:D,extraNodes:ae,extraEdges:pe,removedEdgeIds:Q,removedNodeIds:fe}},[d,w,a,i,_]),be=I.useMemo(()=>{const ee=[...B(i.filter(Q=>!Te.removedEdgeIds.has(Q.id))),...Te.extraEdges],ae=P||Object.keys(j).length>0,pe=Q=>Q.startsWith("dynamic_rt_")?Q.slice(11):Q;return ee.map(Q=>{const fe=Q.id.includes("loop-back"),D=Q.source.startsWith("dynamic_rt_")||Q.target.startsWith("dynamic_rt_"),Y=y==="light"?"#64748b":"#94a3b8";let se={...{...Q.style,stroke:Y,strokeWidth:2.2,strokeDasharray:fe?"5,5":D?"4,4":void 0}},re=!1;if(d==="run"&&b){const de=pe(Q.source),Ie=pe(Q.target),we=b[de]?.status,Ae=b[Ie]?.status,Ke=we==="COMPLETED"||we==="COMPLETED_WITH_ERRORS";Ke&&(Ae==="COMPLETED"||Ae==="COMPLETED_WITH_ERRORS")?(se={...se,stroke:"var(--status-completed)",strokeWidth:3.2,opacity:1},re=!1):Ke&&(Ae==="IN_PROGRESS"||Ae==="SCHEDULED")?(se={...se,stroke:"var(--status-in-progress)",strokeWidth:3.5,opacity:1},re=!0):Ke&&(Ae==="FAILED"||Ae==="FAILED_WITH_TERMINAL_ERROR")?(se={...se,stroke:"var(--status-failed)",strokeWidth:3.5,opacity:1},re=!1):Ke&&Ae==="TIMED_OUT"?(se={...se,stroke:"var(--status-timed-out)",strokeWidth:3.5,opacity:1},re=!1):(se={...se,stroke:Y,strokeWidth:1.8,opacity:.28},re=!1)}else if(ae){const de=j[Q.source],Ie=j[Q.target];de==="done"&&Ie==="done"?(se={...se,stroke:"var(--status-completed)",strokeWidth:3.2},re=!1):de==="done"&&Ie==="running"&&(se={...se,stroke:"var(--status-in-progress)",strokeWidth:3.5},re=!0)}const ve=Q.source.endsWith("_dynamic_placeholder")||Q.target.endsWith("_dynamic_placeholder"),X=Q.source==="__workflow_start__"||Q.source.startsWith("__loop_start__")||Q.target.startsWith("__loop_end__")||Q.target.includes("_empty_"),le=d==="edit"&&!fe&&!ve&&!X;return{...Q,type:"addableEdge",data:{...Q.data,mode:d,isAddable:le,edgeType:v,label:Q.label},markerEnd:{type:F.MarkerType.ArrowClosed,width:18,height:18,color:String(se.stroke||Y)},style:se,animated:re}})},[i,v,y,d,b,Te,B,P,j]),Re=I.useMemo(()=>{if(!A||!T)return[];const Z=Ag(T),ee=h?.taskReferenceName,ae=[],pe=new Set;return Z.edges.forEach((Q,fe)=>{if(!L.has(Q.sourceRef)||!L.has(Q.targetRef)||ee&&Q.sourceRef!==ee&&Q.targetRef!==ee)return;const D=`${Q.sourceRef}->${Q.targetRef}:${Q.fieldPath}`;pe.has(D)||(pe.add(D),ae.push({id:`wlsp-dfg-${fe}-${D}`,source:Q.sourceRef,target:Q.targetRef,type:"addableEdge",animated:!0,label:`🔗 ${Q.fieldPath}`,data:{mode:"view",isAddable:!1,edgeType:"default",label:`🔗 ${Q.fieldPath}`},markerEnd:{type:F.MarkerType.ArrowClosed,width:16,height:16,color:"#38bdf8"},style:{stroke:"#38bdf8",strokeWidth:2.4,strokeDasharray:"6,4",opacity:.95}}))}),ae},[A,T,L,h?.taskReferenceName]),Ee="var(--bg-secondary)",nt=I.useMemo(()=>a.filter(Z=>Z.type!=="plusNode").length,[a]);return o.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",background:Ee},children:[o.jsxs(F,{nodes:I.useMemo(()=>{if($)return $.nodes;const Z=new Set(k.errors.filter(Q=>Q.type==="TASK").map(Q=>Q.ref)),ee=new Set(k.warnings.filter(Q=>Q.type==="TASK").map(Q=>Q.ref)),ae=t.toLowerCase();return(Te.layoutedNodes?Te.layoutedNodes.filter(Q=>Q.id.startsWith("dynamic_rt_")||L.has(Q.id)):a.filter(Q=>!Te.removedNodeIds.has(Q.id)&&L.has(Q.id)).concat(Te.extraNodes)).map(Q=>{const fe=Q.data.taskReferenceName,D=j[fe];return{...Q,selected:h?.taskReferenceName===fe,data:{...Q.data,isError:d==="edit"&&Z.has(fe),hasWarning:d==="edit"&&ee.has(fe),isHighlighted:t?(Q.data.label||"").toLowerCase().includes(ae)||(Q.data.taskReferenceName||"").toLowerCase().includes(ae):!1,simRunning:D==="running",simDone:D==="done"}}})},[a,k,t,h,Te,L,j,d,$]),edges:$?.edges??[...be,...Re],onNodesChange:l,onEdgesChange:c,onConnect:u,nodeTypes:RS,edgeTypes:PS,onNodeClick:(Z,ee)=>{if(ee.type==="plusNode"){ue({sourceId:ee.data.parentRef,edgeData:ee.data.edgeData||{}}),V(!0);return}if(ee.type==="loopNode"){const pe=ee.data.task||null;f(pe),e&&e(pe);return}const ae=ee.data.task||null;f(ae),e&&e(ae)},onPaneClick:()=>{f(null),d!=="run"&&C(!1)},fitView:!0,nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!0,minZoom:.2,maxZoom:2,children:[o.jsx(F.Background,{color:"var(--border-primary)",gap:20}),o.jsx(F.Panel,{position:"bottom-left",style:{marginBottom:"20px",marginLeft:"20px",zIndex:1e3},children:o.jsx(J0,{})}),nt>=5&&!S&&!ye&&o.jsx(F.MiniMap,{position:"bottom-right",pannable:!0,zoomable:!0,style:{marginBottom:20,marginRight:20,width:160,height:110,backgroundColor:"var(--glass-surface)"},maskColor:y==="light"?"rgba(241, 245, 249, 0.7)":"rgba(15, 23, 42, 0.7)",nodeColor:Z=>{if(Z.type==="plusNode")return"transparent";if(d==="run"&&b){const ee=Z.data?.taskReferenceName,ae=b[ee]?.status;return ae==="COMPLETED"?"#10b981":ae==="FAILED"||ae==="FAILED_WITH_TERMINAL_ERROR"?"#ef4444":ae==="IN_PROGRESS"||ae==="SCHEDULED"?"#3b82f6":ae==="TIMED_OUT"||ae==="COMPLETED_WITH_ERRORS"?"#f59e0b":"#64748b"}return Z.type==="decisionNode"?"#f59e0b":Z.type==="forkNode"||Z.type==="joinNode"?"#10b981":Z.type==="loopNode"?"#8b5cf6":"#3b82f6"}}),d==="run"&&o.jsx(F.Panel,{position:"bottom-center",children:o.jsx(B0,{})}),o.jsx(H0,{isOpen:ye,onClose:()=>_e(!1),theme:y,onTaskSelect:Z=>{m(Z,!0)}}),q&&o.jsx(F.Panel,{position:"top-left",style:{marginTop:"14px",marginLeft:"16px",zIndex:1500},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"8px 16px",borderRadius:"999px",background:"rgba(15, 23, 42, 0.94)",backdropFilter:"blur(16px)",border:"1px solid rgba(99, 102, 241, 0.45)",boxShadow:"0 12px 32px rgba(0, 0, 0, 0.4)",color:"#f8fafc",fontSize:"12px"},children:[o.jsx("span",{style:{fontWeight:700,color:"#a5b4fc"},children:"👻 Shadow Graph 架构变更预览"}),o.jsxs("div",{style:{display:"flex",gap:"8px",fontFamily:"monospace",fontSize:"11px"},children:[q.diff.added.length>0&&o.jsxs("span",{style:{color:"#34d399",fontWeight:700},children:["+",q.diff.added.length," 新增"]}),q.diff.modified.length>0&&o.jsxs("span",{style:{color:"#fbbf24",fontWeight:700},children:["~",q.diff.modified.length," 修改"]}),q.diff.removed.length>0&&o.jsxs("span",{style:{color:"#f87171",fontWeight:700},children:["-",q.diff.removed.length," 移除"]})]}),o.jsxs("div",{style:{display:"flex",gap:"6px"},children:[o.jsx("button",{type:"button",onClick:()=>{T&&U(T),N(q.proposedDef),O(),M()},style:{padding:"4px 12px",borderRadius:"999px",border:"none",background:"#10b981",color:"#fff",fontSize:"11px",fontWeight:700,cursor:"pointer"},children:"✓ 采纳上屏"}),o.jsx("button",{type:"button",onClick:()=>{W(),M()},style:{padding:"4px 10px",borderRadius:"999px",border:"1px solid rgba(248, 113, 113, 0.4)",background:"rgba(239, 68, 68, 0.14)",color:"#f87171",fontSize:"11px",fontWeight:600,cursor:"pointer"},children:"✕ 拒绝"})]})]})}),o.jsx("div",{style:{position:"absolute",top:14,right:16,zIndex:1e3},children:o.jsx(K0,{onShowHealthCheck:()=>_e(!ye),showHealthCheck:ye,onShowSettings:()=>J(!0),executionActions:s})})]}),o.jsx(SS,{}),o.jsx(ES,{}),!T&&!q&&o.jsx(Z0,{onRequestImport:n}),T&&a.length===0&&d==="edit"&&o.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:10,display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:o.jsxs("button",{className:"empty-state-btn primary",style:{padding:"12px 24px",borderRadius:"8px",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",fontSize:"16px",fontWeight:500,boxShadow:"0 4px 6px -1px rgba(0, 0, 0, 0.1)"},onClick:()=>{ue({sourceId:"start",targetId:"end",edgeId:"new",edgeData:{}}),V(!0)},children:[o.jsx("span",{style:{fontSize:"20px",lineHeight:1},children:"+"}),"添加第一个任务"]})}),K&&o.jsx(F0,{theme:y,onSelect:Fe,onCancel:()=>V(!1)}),o.jsx(Y0,{isOpen:Ne,onClose:()=>J(!1)}),ne&&o.jsx(xt,{message:ne.message,onConfirm:xe,onCancel:ie}),o.jsx(eS,{messages:je,onDismiss:ge})]})},AS=(e,t)=>{const r=t?`当前工作流(JSON):
|
|
221
|
+
`;function JN(e,t,r){if(!t)return`【⌘K 画布指令】${e}`;const n=r.length>0?`;可引用的上游任务:${r.join(", ")}`:"";return`【⌘K 画布指令 · 锚点任务 ${t.ref}${t.type?`(${t.type})`:""}${n}】${e}
|
|
222
|
+
请在锚点任务附近修改,并生成变更方案供我确认。`}const UN=[{label:"在下方插入 HTTP 请求",icon:Rs,type:"HTTP",name:"http_call_task"},{label:"在下方插入条件分支 (SWITCH)",icon:br,type:"SWITCH",name:"switch_router"},{label:"在下方插入 JQ 转换节点",icon:cb,type:"JSON_JQ_TRANSFORM",name:"jq_transform_task"},{label:"为当前节点开启自动重试与容错",icon:jb,action:"retry_hardening"}],_k={success:{icon:Cs,color:"var(--cm-status-success)"},warning:{icon:Ye,color:"var(--cm-status-warning)"},failed:{icon:_u,color:"var(--cm-status-failed)"},working:{icon:IT,color:"var(--cm-ai)"}},jk={size:14,strokeWidth:1.75,"aria-hidden":!0},Tk="var(--cm-surface-0)",VN=({aiConfig:e})=>{const{inlineCopilotTaskRef:t,setInlineCopilotTaskRef:r,selectedTask:n,workflowDef:s,taskMap:a,addNode:i,updateTask:l,selectTaskAction:c}=te(Ae(C=>({inlineCopilotTaskRef:C.inlineCopilotTaskRef,setInlineCopilotTaskRef:C.setInlineCopilotTaskRef,selectedTask:C.selectedTask,workflowDef:C.workflowDef,taskMap:C.taskMap,addNode:C.addNode,updateTask:C.updateTask,selectTaskAction:C.selectTaskAction}))),d=Gb(),u=d?.aiStore??vn,p=u(C=>C.config),f=u(C=>C.isStreaming),m=te(C=>C.mode),h=T.useRef(null);T.useEffect(()=>()=>{h.current?.abort()},[]);const[y,x]=T.useState(""),[g,v]=T.useState(!1),[k,b]=T.useState(null),S=T.useRef(null),j=t||n?.taskReferenceName||null,_=j?a[j]:null;if(T.useEffect(()=>{const C=M=>{if((M.metaKey||M.ctrlKey)&&M.key.toLowerCase()==="k"){M.preventDefault();const R=te.getState();if(R.inlineCopilotTaskRef)R.setInlineCopilotTaskRef(null);else{const O=R.selectedTask?.taskReferenceName||R.workflowDef?.tasks?.[R.workflowDef.tasks.length-1]?.taskReferenceName||"__canvas_root__";R.setInlineCopilotTaskRef(O)}}else M.key==="Escape"&&t&&r(null)};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[t,r]),T.useEffect(()=>{t&&(b(null),setTimeout(()=>S.current?.focus(),40))},[t]),!t)return null;const w=s&&j&&j!=="__canvas_root__"?ys(s,j):[],I=C=>{if(!(!j||j==="__canvas_root__")){if(m==="run"){b({tone:"warning",text:"运行视图下不能修改流程。请切换到编辑模式后再试。"});return}if(C.action==="retry_hardening"&&_){l(j,{retryCount:3,retryLogic:"EXPONENTIAL_BACKOFF",retryDelaySeconds:2,timeoutSeconds:60}),b({tone:"success",text:"已为当前节点开启指数退避重试(3 次)与 60s 超时保护"}),setTimeout(()=>r(null),900);return}if(C.type&&C.name){const M=$t.find(O=>O.type===C.type),R=`${C.name}_${Date.now().toString(36).slice(-4)}`;i({data:{label:M?.label||C.name,taskName:C.name,taskReferenceName:R,taskType:C.type}},j,"",`inline-cmdk-${R}`,{}),b({tone:"success",text:`已在 ${j} 后插入 ${C.type} 节点`}),setTimeout(()=>r(null),700)}}},N=async C=>{C.preventDefault();const M=y.trim();if(!M||!s)return;const R={...p,...e??{}};if(!En(R)){b({tone:"warning",text:d?"未配置 AI 服务。请点击 AI 对话面板右上角的设置按钮填写 API Key 后重试。":Cn});return}if(f){b({tone:"warning",text:"AI 正在处理上一条指令,请等它完成后再发送。"});return}const O=j&&j!=="__canvas_root__"?j:null,$=JN(M,O?{ref:O,name:_?.name,type:_?.type}:null,w.map(q=>q.taskReferenceName));if(d){d.aiStore.getState().setPendingAutoSend($),x(""),b({tone:"success",text:"已发送给 AI 助手。方案生成后会在画布上等待你确认,可在对话面板查看进度。"}),setTimeout(()=>r(null),1200);return}e&&u.getState().setConfig({...e});const B=h.current??new MN(()=>({aiPermissions:{canEdit:te.getState().mode!=="run"}}),{aiStore:vn,libraryStore:XI,toolRegistry:zN});h.current=B,v(!0),b({tone:"working",text:"正在基于当前节点上下文生成变更方案…"});try{const q=vn.getState().pendingProposal?.id;await B.send($);const F=vn.getState();if(F.pendingProposal&&F.pendingProposal.id!==q)x(""),b({tone:"success",text:"已生成变更方案,请在画布上方确认应用或放弃。"}),setTimeout(()=>r(null),1200);else{const W=([...F.messages].reverse().find(D=>D.role==="assistant")?.content??"").replace(/\*\*/g,"").trim(),P=W.includes("出错了");b({tone:P?"failed":"warning",text:W?W.slice(0,160):"AI 没有生成变更方案。请换个说法重试。"})}}finally{v(!1)}};return o.jsxs("div",{style:{position:"absolute",top:68,left:"50%",transform:"translateX(-50%)",width:540,maxWidth:"calc(100vw - 40px)",zIndex:2200,background:"color-mix(in srgb, var(--cm-surface-1) 96%, transparent)",backdropFilter:"blur(20px)",border:"1px solid color-mix(in srgb, var(--cm-ai) 45%, transparent)",borderRadius:14,boxShadow:"var(--cm-shadow-float), 0 0 0 1px color-mix(in srgb, var(--cm-ai) 15%, transparent)",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 14px",background:"linear-gradient(90deg, color-mix(in srgb, var(--cm-ai) 18%, transparent), transparent)",borderBottom:"1px solid var(--cm-border-subtle)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontSize:10,fontWeight:700,padding:"2px 7px",borderRadius:5,background:"var(--cm-ai)",color:Tk},children:"⌘K 画布内联指令"}),o.jsxs("span",{style:{fontSize:11,color:"var(--cm-text-secondary)",fontFamily:"var(--cm-font-mono)"},children:["锚点:"," ",o.jsx("strong",{style:{color:"var(--cm-data)"},children:_?`${_.name} (${_.taskReferenceName})`:"画布全局"})]}),w.length>0&&o.jsxs("span",{style:{fontSize:10,color:"var(--cm-text-muted)"},children:["· 可见上游 ",w.length," 个节点"]})]}),o.jsxs("button",{type:"button",onClick:()=>r(null),style:{background:"none",border:"none",color:"var(--cm-text-muted)",cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:4},"aria-label":"关闭内联指令(Esc)",children:["Esc ",o.jsx($e,{...jk})]})]}),o.jsxs("form",{onSubmit:N,style:{display:"flex",padding:"10px 14px",gap:8},children:[o.jsx("input",{ref:S,type:"text",value:y,onChange:C=>x(C.target.value),disabled:g,placeholder:"输入自然语言指令,如:在此节点后加一个风控 HTTP 校验并判断状态码...",style:{flex:1,padding:"9px 12px",borderRadius:8,border:"1px solid var(--cm-border-default)",background:"var(--cm-surface-0)",color:"var(--cm-text-primary)",fontSize:13,outline:"none"}}),o.jsx("button",{type:"submit",disabled:g||!y.trim(),style:{padding:"0 16px",borderRadius:8,border:"none",background:"var(--cm-ai)",color:Tk,display:"inline-flex",alignItems:"center",gap:4,fontSize:12,fontWeight:700,cursor:g||!y.trim()?"not-allowed":"pointer",opacity:g||!y.trim()?.6:1},children:g?"生成中…":o.jsxs(o.Fragment,{children:["运行 ",o.jsx(gT,{...jk})]})})]}),_&&o.jsxs("div",{style:{padding:"6px 14px 12px",display:"flex",flexWrap:"wrap",gap:6},children:[UN.map(C=>o.jsxs("button",{type:"button",onClick:()=>I(C),style:{fontSize:11,padding:"4px 10px",borderRadius:999,border:"1px solid var(--cm-border-default)",background:"var(--cm-surface-2)",color:"var(--cm-text-secondary)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4},children:[o.jsx(C.icon,{size:12,strokeWidth:1.75,"aria-hidden":"true"}),C.label]},C.label)),o.jsxs("button",{type:"button",onClick:()=>{c(_,!0),r(null)},style:{fontSize:11,padding:"4px 10px",borderRadius:999,border:"1px solid var(--cm-border-default)",background:"var(--cm-surface-2)",color:"var(--cm-text-secondary)",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4},children:[o.jsx(_b,{size:12,strokeWidth:1.75,"aria-hidden":"true"}),"打开属性抽屉"]})]}),k&&o.jsxs("div",{style:{padding:"6px 14px 10px",fontSize:11,color:_k[k.tone].color,borderTop:"1px solid var(--cm-border-subtle)",display:"flex",alignItems:"center",gap:6},role:"status",children:[T.createElement(_k[k.tone].icon,{size:12,strokeWidth:1.75,"aria-hidden":!0}),k.text]})]})},KN={taskNode:nI,decisionNode:aI,forkNode:Db.ForkNode,joinNode:Db.JoinNode,loopNode:iI,subWorkflowNode:dI,plusNode:pI,dynamicPlaceholderNode:mI},GN={addableEdge:xI},YN=({onNodeClick:e,searchQuery:t="",onSave:r,onRequestImport:n,executionActions:s})=>{const{nodes:a,edges:i,onNodesChange:l,onEdgesChange:c,mode:d,viewMode:u,selectedTask:p,setSelectedTask:f,selectTaskAction:m,theme:h,edgeType:y,addNode:x,nodesLocked:g,executionData:v,validationResults:k,isDetailPanelOpen:b,setIsDetailPanelOpen:S,workflowDef:j,setWorkflow:_,dynamicRuntimeTasksByFork:w,layoutDirection:I,simState:N,isSimRunning:C,workflowLoadKey:M,showDataLineage:R}=te(Ae(ee=>({nodes:ee.nodes,edges:ee.edges,onNodesChange:ee.onNodesChange,onEdgesChange:ee.onEdgesChange,mode:ee.mode,viewMode:ee.viewMode,selectedTask:ee.selectedTask,setSelectedTask:ee.setSelectedTask,selectTaskAction:ee.selectTaskAction,theme:ee.theme,edgeType:ee.edgeType,addNode:ee.addNode,nodesLocked:ee.nodesLocked,executionData:ee.executionData,validationResults:ee.validationResults,isDetailPanelOpen:ee.isDetailPanelOpen,setIsDetailPanelOpen:ee.setIsDetailPanelOpen,workflowDef:ee.workflowDef,setWorkflow:ee.setWorkflow,dynamicRuntimeTasksByFork:ee.dynamicRuntimeTasksByFork,layoutDirection:ee.layoutDirection,simState:ee.simState,isSimRunning:ee.isSimRunning,workflowLoadKey:ee.workflowLoadKey,showDataLineage:ee.showDataLineage}))),O=T.useMemo(()=>{if(u==="developer")return new Set(a.map(ie=>ie.id));const ee=KT[u],ue=new Set;return a.forEach(ie=>{if(ie.type==="dynamicPlaceholderNode"){ue.add(ie.id);return}if(ie.type==="plusNode"){d==="edit"&&(!ie.data?.parentRef||ue.has(ie.data.parentRef))&&ue.add(ie.id);return}if(d==="run"&&v){const Ie=v[ie.id]?.status;if(Ie==="FAILED"||Ie==="FAILED_WITH_TERMINAL_ERROR"||Ie==="TIMED_OUT"||Ie==="IN_PROGRESS"){ue.add(ie.id);return}}if(ie.parentId)return;const re=$t.find(Ie=>Ie.type===ie.data.taskType)?.viewCategory??"business";ee.includes(re)&&ue.add(ie.id)}),a.forEach(ie=>{if(ie.parentId&&ue.has(ie.parentId)){if(ie.type==="plusNode"){d==="edit"&&ue.add(ie.id);return}const re=$t.find(Ie=>Ie.type===ie.data.taskType)?.viewCategory??"business";ee.includes(re)&&ue.add(ie.id)}}),ue},[a,u,d,v]),$=T.useCallback(ee=>{if(O.size===a.length)return ee;const ue={};ee.forEach(re=>{ue[re.source]||(ue[re.source]=[]),ue[re.source].push(re)});const ie=[],ge=new Set;return ee.forEach(re=>{if(!O.has(re.source))return;if(O.has(re.target)){const ke=`${re.source}->${re.target}`;ge.has(ke)||(ge.add(ke),ie.push(re));return}const Ie=[{to:re.target,label:re.label}],Oe=new Set;for(;Ie.length;){const ke=Ie.shift();if(!Oe.has(ke.to)){if(Oe.add(ke.to),O.has(ke.to)){const Ne=`${re.source}->${ke.to}`;ge.has(Ne)||(ge.add(Ne),ie.push({...re,id:Ne,target:ke.to,label:ke.label??re.label}));continue}(ue[ke.to]??[]).forEach(Ne=>Ie.push({to:Ne.target,label:ke.label??Ne.label}))}}}),ie},[O,a.length]),q=Gb()?.aiStore??vn,F=q(ee=>ee.pendingProposal),A=q(ee=>ee.clearProposal),W=q(ee=>ee.recordAccept),P=q(ee=>ee.recordReject),D=q(ee=>ee.pushUndo),Z=T.useMemo(()=>{if(!F)return null;try{const{nodes:ee,edges:ue}=ht(F.proposedDef,I,{hideEmptyBranches:!1}),{nodes:ie,edges:ge}=pt(ee,ue,{direction:I,mode:"edit"}),re=new Set(F.diff.added),Ie=new Set(F.diff.modified),Oe=new Set(F.diff.removed),ke=new Map(a.map(je=>[je.data?.taskReferenceName,je])),Ne=ie.filter(je=>je.type!=="plusNode").map(je=>{const Le=je.data?.taskReferenceName,it=re.has(Le)?"added":Ie.has(Le)?"modified":void 0;return{...je,draggable:!1,selectable:!1,data:{...je.data,proposalStatus:it,layoutDirection:I}}}),Pe=[...Oe].map(je=>ke.get(je)).filter(je=>je!=null).map(je=>({...je,draggable:!1,selectable:!1,data:{...je.data,proposalStatus:"removed"}}));return{nodes:[...Ne,...Pe],edges:ge}}catch{return null}},[F,a,I]),{fitView:L}=J.useReactFlow(),[H,U]=T.useState(!1),[K,se]=T.useState(null),[pe,we]=T.useState(!1),[Ce,ne]=T.useState(!1),{confirm:Te,confirmState:le,handleConfirm:V,handleCancel:X}=xn(),{toasts:z,showToast:ve,dismissToast:he}=Vb();HI({confirm:Te,showToast:ve,onSave:r});const _e=te(ee=>ee.sandboxNotice);T.useEffect(()=>{_e&&(ve(_e.text,_e.type),te.getState().clearSandboxNotice())},[_e,ve]),T.useEffect(()=>{if(p){const ee=a.find(ue=>ue.data.taskReferenceName===p.taskReferenceName);ee&&L({nodes:[ee],duration:800,padding:.5})}},[p?.taskReferenceName,L]),T.useEffect(()=>{const ee=()=>{L({duration:800})};return window.addEventListener("workflow-zoom-to-fit",ee),()=>window.removeEventListener("workflow-zoom-to-fit",ee)},[L]),T.useEffect(()=>{if(M===0)return;const ee=setTimeout(()=>{L({duration:600,padding:.12})},50);return()=>clearTimeout(ee)},[M,L]),T.useEffect(()=>{const ee=ge=>{e&&ge.detail&&ge.detail.task&&e(ge.detail.task)},ue=ge=>{if(d==="edit"){const{loopId:re,afterRef:Ie}=ge.detail;se(Ie?{sourceId:Ie,edgeData:{}}:{sourceId:re,edgeData:{isLoopAdd:!0}}),U(!0)}},ie=ge=>{d==="edit"&&(se({sourceId:ge.detail.source,targetId:ge.detail.target,edgeId:ge.detail.id,edgeData:ge.detail.edgeData}),U(!0))};return document.addEventListener("miniTaskClick",ee),document.addEventListener("loopAddNodeRequested",ue),window.addEventListener("edgeAddNode",ie),()=>{document.removeEventListener("miniTaskClick",ee),document.removeEventListener("loopAddNodeRequested",ue),window.removeEventListener("edgeAddNode",ie)}},[d,e]);const Se=T.useCallback(ee=>{if(K){const{sourceId:ue,targetId:ie,edgeId:ge,edgeData:re}=K;x({data:{label:`New ${ee}`,taskReferenceName:`${ee.toLowerCase()}_${Date.now()}`,taskType:ee}},ue,ie,ge,re)}U(!1),se(null)},[K,x]),be=T.useMemo(()=>{const ee={layoutedNodes:null,extraNodes:[],extraEdges:[],removedEdgeIds:new Set,removedNodeIds:new Set};if(d!=="run")return ee;const ue=a.filter(ke=>ke.type==="forkNode"&&ke.data.taskType==="FORK_JOIN_DYNAMIC");if(!ue.length)return ee;const ie=[],ge=[],re=new Set,Ie=new Set;for(const ke of ue){const Ne=w[ke.id]||[],Pe=`${ke.id}_dynamic_placeholder`,je=i.find(fe=>fe.target===Pe),Le=i.find(fe=>fe.source===Pe);let it,lt;if(Le)it=Le.target,lt=a.find(fe=>fe.id===it);else{const fe=a.indexOf(ke);if(lt=a.slice(fe).find(Ke=>Ke.type==="joinNode"),!lt)continue;it=lt.id}lt&&(Le&&re.add(Le.id),je&&re.add(je.id),Ie.add(Pe),Ne.length&&Ne.forEach(fe=>{const Ke=`dynamic_rt_${fe.referenceTaskName}`;ie.push({id:Ke,type:"taskNode",data:{label:fe.taskDefName||fe.referenceTaskName,task:{name:fe.taskDefName||fe.referenceTaskName,taskReferenceName:fe.referenceTaskName,type:fe.taskType||"SIMPLE"},taskReferenceName:fe.referenceTaskName,taskType:fe.taskType||"SIMPLE",isDynamicRuntime:!0,layoutDirection:I},position:{x:0,y:0}}),ge.push({id:`e-${ke.id}-${Ke}`,source:ke.id,target:Ke,style:{strokeDasharray:"4,4"}}),ge.push({id:`e-${Ke}-${it}`,source:Ke,target:it,style:{strokeDasharray:"4,4"}})}))}let Oe=null;if(ie.length>0){const ke=[...a.filter(je=>!Ie.has(je.id)),...ie],Ne=[...i.filter(je=>!re.has(je.id)),...ge];Oe=pt(ke,Ne,{direction:I,mode:"run"}).nodes}return{layoutedNodes:Oe,extraNodes:ie,extraEdges:ge,removedEdgeIds:re,removedNodeIds:Ie}},[d,w,a,i,I]),ce=T.useMemo(()=>{const ue=[...$(i.filter(re=>!be.removedEdgeIds.has(re.id))),...be.extraEdges],ie=C||Object.keys(N).length>0,ge=re=>re.startsWith("dynamic_rt_")?re.slice(11):re;return ue.map(re=>{const Ie=re.id.includes("loop-back"),Oe=re.source.startsWith("dynamic_rt_")||re.target.startsWith("dynamic_rt_"),ke="var(--cm-edge-default)";let Pe={...{...re.style,stroke:ke,strokeWidth:2.2,strokeDasharray:Ie?"5,5":Oe?"4,4":void 0}},je=!1;if(d==="run"&&v){const fe=ge(re.source),Ke=ge(re.target),dr=v[fe]?.status,ct=v[Ke]?.status,dt=dr==="COMPLETED"||dr==="COMPLETED_WITH_ERRORS";dt&&(ct==="COMPLETED"||ct==="COMPLETED_WITH_ERRORS")?(Pe={...Pe,stroke:"var(--status-completed)",strokeWidth:3.2,opacity:1},je=!1):dt&&(ct==="IN_PROGRESS"||ct==="SCHEDULED")?(Pe={...Pe,stroke:"var(--status-in-progress)",strokeWidth:3.5,opacity:1},je=!0):dt&&(ct==="FAILED"||ct==="FAILED_WITH_TERMINAL_ERROR")?(Pe={...Pe,stroke:"var(--status-failed)",strokeWidth:3.5,opacity:1},je=!1):dt&&ct==="TIMED_OUT"?(Pe={...Pe,stroke:"var(--status-timed-out)",strokeWidth:3.5,opacity:1},je=!1):(Pe={...Pe,stroke:ke,strokeWidth:1.8,opacity:.28},je=!1)}else if(ie){const fe=N[re.source],Ke=N[re.target];fe==="done"&&Ke==="done"?(Pe={...Pe,stroke:"var(--status-completed)",strokeWidth:3.2},je=!1):fe==="done"&&Ke==="running"&&(Pe={...Pe,stroke:"var(--status-in-progress)",strokeWidth:3.5},je=!0)}const Le=re.source.endsWith("_dynamic_placeholder")||re.target.endsWith("_dynamic_placeholder"),it=re.source==="__workflow_start__"||re.source.startsWith("__loop_start__")||re.target.startsWith("__loop_end__")||re.target.includes("_empty_"),lt=d==="edit"&&!Ie&&!Le&&!it;return{...re,type:"addableEdge",data:{...re.data,mode:d,isAddable:lt,edgeType:y,label:re.label},markerEnd:{type:J.MarkerType.ArrowClosed,width:18,height:18,color:String(Pe.stroke||ke)},style:Pe,animated:je}})},[i,y,h,d,v,be,$,C,N]),Re=T.useMemo(()=>{if(!R||!j)return[];const ee=lu(j),ue=p?.taskReferenceName,ie=[],ge=new Set;return ee.edges.forEach((re,Ie)=>{if(!O.has(re.sourceRef)||!O.has(re.targetRef)||ue&&re.sourceRef!==ue&&re.targetRef!==ue)return;const Oe=`${re.sourceRef}->${re.targetRef}:${re.fieldPath}`;ge.has(Oe)||(ge.add(Oe),ie.push({id:`wlsp-dfg-${Ie}-${Oe}`,source:re.sourceRef,target:re.targetRef,type:"addableEdge",animated:!0,label:re.fieldPath,data:{mode:"view",isAddable:!1,edgeType:"default",label:re.fieldPath},markerEnd:{type:J.MarkerType.ArrowClosed,width:16,height:16,color:"var(--cm-data)"},style:{stroke:"var(--cm-data)",strokeWidth:2.4,strokeDasharray:"6,4",opacity:.95}}))}),ie},[R,j,O,p?.taskReferenceName]),De="var(--bg-secondary)",Je=T.useMemo(()=>a.filter(ee=>ee.type!=="plusNode").length,[a]);return o.jsxs("div",{style:{width:"100%",height:"100%",position:"relative",background:De},children:[o.jsxs(J,{nodes:T.useMemo(()=>{if(Z)return Z.nodes;const ee=new Set(k.errors.filter(re=>re.type==="TASK").map(re=>re.ref)),ue=new Set(k.warnings.filter(re=>re.type==="TASK").map(re=>re.ref)),ie=t.toLowerCase();return(be.layoutedNodes?be.layoutedNodes.filter(re=>re.id.startsWith("dynamic_rt_")||O.has(re.id)):a.filter(re=>!be.removedNodeIds.has(re.id)&&O.has(re.id)).concat(be.extraNodes)).map(re=>{const Ie=re.data.taskReferenceName,Oe=N[Ie];return{...re,selected:p?.taskReferenceName===Ie,data:{...re.data,isError:d==="edit"&&ee.has(Ie),hasWarning:d==="edit"&&ue.has(Ie),isHighlighted:t?(re.data.label||"").toLowerCase().includes(ie)||(re.data.taskReferenceName||"").toLowerCase().includes(ie):!1,simRunning:Oe==="running",simDone:Oe==="done"}}})},[a,k,t,p,be,O,N,d,Z]),edges:Z?.edges??[...ce,...Re],onNodesChange:l,onEdgesChange:c,nodeTypes:KN,edgeTypes:GN,onNodeClick:(ee,ue)=>{if(ue.type==="plusNode"){se({sourceId:ue.data.parentRef,edgeData:ue.data.edgeData||{}}),U(!0);return}if(ue.type==="loopNode"){const ge=ue.data.task||null;f(ge),e&&e(ge);return}const ie=ue.data.task||null;f(ie),e&&e(ie)},onPaneClick:()=>{f(null),d!=="run"&&S(!1)},fitView:!0,nodesDraggable:!g,nodesConnectable:!1,deleteKeyCode:null,elementsSelectable:!0,minZoom:.2,maxZoom:2,children:[o.jsx(J.Background,{color:"var(--border-primary)",gap:20}),o.jsx(J.Panel,{position:"bottom-left",style:{marginBottom:"20px",marginLeft:"20px",zIndex:1e3},children:o.jsx(vI,{})}),Je>=5&&!b&&!pe&&o.jsx(J.MiniMap,{position:"bottom-right",pannable:!0,zoomable:!0,style:{marginBottom:20,marginRight:20,width:160,height:110,backgroundColor:"var(--glass-surface)"},maskColor:"color-mix(in srgb, var(--cm-surface-0) 70%, transparent)",nodeColor:ee=>{if(ee.type==="plusNode")return"transparent";if(d==="run"&&v){const ue=ee.data?.taskReferenceName,ie=v[ue]?.status;return ie==="COMPLETED"?"var(--cm-status-success)":ie==="FAILED"||ie==="FAILED_WITH_TERMINAL_ERROR"?"var(--cm-status-failed)":ie==="IN_PROGRESS"||ie==="SCHEDULED"?"var(--cm-status-running)":ie==="TIMED_OUT"||ie==="COMPLETED_WITH_ERRORS"?"var(--cm-status-warning)":"var(--cm-status-pending)"}return ee.type==="decisionNode"?"var(--cm-status-warning)":ee.type==="forkNode"||ee.type==="joinNode"?"var(--cm-status-success)":ee.type==="loopNode"?"var(--cm-ai)":"var(--color-accent)"}}),d==="run"&&o.jsx(J.Panel,{position:"bottom-center",children:o.jsx(yI,{})}),o.jsx(gI,{isOpen:pe,onClose:()=>we(!1),theme:h,onTaskSelect:ee=>{m(ee,!0)}}),F&&o.jsx(J.Panel,{position:"top-left",style:{marginTop:"14px",marginLeft:"16px",zIndex:1500},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"8px 16px",borderRadius:"999px",background:"color-mix(in srgb, var(--cm-surface-1) 94%, transparent)",backdropFilter:"blur(16px)",border:"1px solid color-mix(in srgb, var(--cm-ai) 45%, transparent)",boxShadow:"var(--cm-shadow-float)",color:"var(--text-primary)",fontSize:"12px"},children:[o.jsxs("span",{style:{fontWeight:700,color:"var(--cm-ai)"},children:[o.jsx(Pt,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"AI 提案预览(Shadow Graph)"]}),o.jsxs("div",{style:{display:"flex",gap:"8px",fontFamily:"monospace",fontSize:"11px"},children:[F.diff.added.length>0&&o.jsxs("span",{style:{color:"var(--cm-diff-added)",fontWeight:700},children:["+",F.diff.added.length," 新增"]}),F.diff.modified.length>0&&o.jsxs("span",{style:{color:"var(--cm-diff-modified)",fontWeight:700},children:["~",F.diff.modified.length," 修改"]}),F.diff.removed.length>0&&o.jsxs("span",{style:{color:"var(--cm-diff-removed)",fontWeight:700},children:["-",F.diff.removed.length," 移除"]})]}),o.jsxs("div",{style:{display:"flex",gap:"6px"},children:[o.jsxs("button",{type:"button",onClick:()=>{j&&D(j),_(F.proposedDef),W(),A()},style:{padding:"4px 12px",borderRadius:"999px",border:"none",background:"var(--cm-status-success)",color:"var(--cm-on-danger)",fontSize:"11px",fontWeight:700,cursor:"pointer"},children:[o.jsx(_t,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"全部采纳"]}),o.jsxs("button",{type:"button",onClick:()=>{P(),A()},style:{padding:"4px 10px",borderRadius:"999px",border:"1px solid color-mix(in srgb, var(--cm-status-failed) 40%, transparent)",background:"color-mix(in srgb, var(--cm-status-failed) 14%, transparent)",color:"var(--cm-status-failed)",fontSize:"11px",fontWeight:600,cursor:"pointer"},children:[o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"放弃"]})]})]})}),o.jsx("div",{style:{position:"absolute",top:14,right:16,zIndex:1e3},children:o.jsx(wI,{onShowHealthCheck:()=>we(!pe),showHealthCheck:pe,onShowSettings:()=>ne(!0),executionActions:s})})]}),o.jsx(GI,{}),o.jsx(VN,{}),!j&&!F&&o.jsx(TI,{onRequestImport:n}),j&&a.length===0&&d==="edit"&&o.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",zIndex:10,display:"flex",flexDirection:"column",alignItems:"center",gap:"12px"},children:o.jsxs("button",{className:"empty-state-btn primary",style:{padding:"12px 24px",borderRadius:"8px",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px",fontSize:"16px",fontWeight:500,boxShadow:"var(--cm-shadow-card)"},onClick:()=>{se({sourceId:"start",targetId:"end",edgeId:"new",edgeData:{}}),U(!0)},children:[o.jsx("span",{style:{fontSize:"20px",lineHeight:1},children:"+"}),"添加第一个任务"]})}),H&&o.jsx(hI,{theme:h,onSelect:Se,onCancel:()=>U(!1)}),o.jsx(_I,{isOpen:Ce,onClose:()=>ne(!1)}),le&&o.jsx(Dt,{message:le.message,confirmLabel:le.confirmLabel,onConfirm:V,onCancel:X}),o.jsx(Wb,{messages:z,onDismiss:he})]})},XN=(e,t)=>{const r=t?`当前工作流(JSON):
|
|
87
223
|
${JSON.stringify({name:t.name,tasks:t.tasks.map(n=>({ref:n.taskReferenceName,type:n.type,name:n.name}))},null,2)}`:"当前工作流:尚未定义。";return`
|
|
88
224
|
用户请求:${e}
|
|
89
225
|
|
|
@@ -114,7 +250,7 @@ ${r}
|
|
|
114
250
|
|
|
115
251
|
如果是全量生成新工作流,使用 kind="replace" 并在 diff-json 中加入 "payload": {...完整工作流JSON...}。
|
|
116
252
|
如果不涉及工作流变更(仅解释/回答),则不需要输出 diff-json 块。
|
|
117
|
-
`},
|
|
253
|
+
`},ZN=(e,t)=>`
|
|
118
254
|
Context: I am configuring a Conductor task in a workflow.
|
|
119
255
|
Task Reference Name: ${e.taskReferenceName}
|
|
120
256
|
Task Type: ${e.type}
|
|
@@ -124,24 +260,30 @@ ${JSON.stringify(t,null,2)}
|
|
|
124
260
|
|
|
125
261
|
Requirement: Suggest 3 meaningful 'inputParameters' or JSONPath expressions for this task based on the workflow context.
|
|
126
262
|
Return the suggestions as a JSON array of objects with { label, value, description }.
|
|
127
|
-
`,
|
|
128
|
-
`).length," 行"]}),o.jsxs("span",{children:[c.length," 字符"]}),c!==t&&o.jsx("span",{style:{color:"#f59e0b",fontWeight:600},children:"● 未保存"})]})]}),document.body)},zS=[{label:"工作流输入",value:"${workflow.input.fieldName}",desc:"引用工作流启动时传入的参数"},{label:"上游任务输出",value:"${taskRef.output.result}",desc:"引用上游任务的输出字段"},{label:"工作流变量",value:"${workflow.variables.varName}",desc:"引用 SET_VARIABLE 设置的变量"},{label:"工作流 ID",value:"${workflow.workflowId}",desc:"当前工作流实例 ID"},{label:"关联 ID",value:"${workflow.correlationId}",desc:"工作流关联 ID"},{label:"工作流状态",value:"${workflow.status}",desc:"当前工作流状态"}],qS=({task:e,isOpen:t=!0,onClose:r,aiConfig:n})=>{const{mode:s,updateTask:a,checkTaskRefUniqueness:i,workflowDef:l,executionData:c,workflowInstance:u,lastRefactorNotice:d,clearRefactorNotice:p}=oe(ke(D=>({mode:D.mode,updateTask:D.updateTask,checkTaskRefUniqueness:D.checkTaskRefUniqueness,workflowDef:D.workflowDef,executionData:D.executionData,workflowInstance:D.workflowInstance,lastRefactorNotice:D.lastRefactorNotice,clearRefactorNotice:D.clearRefactorNotice}))),[h,f]=I.useState(e),[m,y]=I.useState(e?.taskReferenceName??null),[v,g]=I.useState(null),[x,b]=I.useState(!1),[k,S]=I.useState(null),[C,T]=I.useState(()=>e?.type==="WAIT"&&e.inputParameters?.until?"until":"duration"),[N,w]=I.useState(()=>e?.type==="DO_WHILE"&&e.inputParameters?.items?"items":"condition"),[_,j]=I.useState(()=>!e||e.type!=="FORK_JOIN_DYNAMIC"?"classic":e.forkTaskWorkflow?"workflow":e.forkTaskType?"task":"classic"),[P,E]=I.useState(!1),[A,L]=I.useState(),[B,z]=I.useState([]),[R,q]=I.useState(()=>()=>{}),M=e?.taskReferenceName||h?.taskReferenceName||"",O=I.useMemo(()=>!l||!M?[]:Og(l,M,c,u?.input),[l,M,c,u?.input]),[W,U]=I.useState(null),[$,H]=I.useState(!1),[K,V]=I.useState(null),te=(D,Y,ce,se)=>{U({title:D,value:Y,language:ce,onSave:se})},ue=[{label:"引用工作流输入",value:"${workflow.input.data}",description:"引用工作流启动时传入的原始数据"},{label:"引用前序任务输出",value:"${previous_task.output.result}",description:"引用上一个节点的计算结果"},{label:"环境变量",value:"${workflow.variables.api_key}",description:"引用工作流定义的全局变量"}],ye=async()=>{const D=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!D){alert("请先在设置中配置 AI API Key");return}if(Ne){H(!0);try{const{workflowDef:Y,taskMap:ce}=oe.getState(),se=st(Y?.inputParameters).map(le=>le.name),re=Object.values(ce).filter(le=>le.taskReferenceName!==Ne.taskReferenceName).map(le=>({ref:le.taskReferenceName,type:le.type,name:le.name})).slice(0,10),ve={apiKey:D};n?.baseUrl&&(ve.baseUrl=n.baseUrl),n?.model&&(ve.model=n.model);const X=await IS(Ne.type,Ne.taskReferenceName,se,re,Ne.inputParameters??{},ve);V({generated:X,original:Ne.inputParameters??{}})}catch(Y){alert(`AI 生成失败:${Y?.message||"未知错误"}`)}finally{H(!1)}}},_e=async(D,Y)=>{const ce=D.currentTarget.getBoundingClientRect();if(L(ce),q(()=>Y),E(!0),O.length>0)return;z([]);const se=n?.apiKey||localStorage.getItem("AI_API_KEY")||"";if(!se){z(ue);return}try{const re=n?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",ve=n?.model||localStorage.getItem("AI_MODEL")||"",X={apiKey:se};re&&(X.baseUrl=re),ve&&(X.model=ve);const{workflowDef:le}=oe.getState(),de=DS(Ne,le),we=(await mc([{role:"system",content:"You are a Conductor workflow expert. Return only valid JSON."},{role:"user",content:de}],X)).match(/\[[\s\S]*\]/);if(we){const Ae=JSON.parse(we[0]);z(Ae)}else z(ue)}catch{z(ue)}};if(I.useEffect(()=>{e&&(f(e),y(e.taskReferenceName),g(null),e.type==="WAIT"&&T(e.inputParameters?.until?"until":"duration"),e.type==="DO_WHILE"&&w(e.inputParameters?.items?"items":"condition"),e.type==="FORK_JOIN_DYNAMIC"&&(e.forkTaskWorkflow?j("workflow"):e.forkTaskType?j("task"):j("classic")))},[e]),!e&&!h)return null;const Ne=e||h,J=h&&e&&m===e.taskReferenceName?h:Ne,Se=t&&e?"panel-enter-active":"panel-exit",ne=s==="edit",xe="var(--text-primary)",ie="var(--glass-border)",je="var(--bg-tertiary)",me="var(--text-secondary)",ge=(D,Y)=>{const ce={...J,[D]:Y};f(ce),a(J.taskReferenceName,{[D]:Y})},Fe=(D,Y,ce)=>{const re={...J[D]||{},[Y]:ce},ve={...J,[D]:re};f(ve),a(J.taskReferenceName,{[D]:re})},Te=(D,Y)=>{const ce=J.inputParameters||{},re={...ce.http_request||J.httpRequest||{},[D]:Y},X={inputParameters:{...ce,http_request:re}};J.httpRequest&&(X.httpRequest=re);const le={...J,...X};f(le),a(J.taskReferenceName,X)},be=(D,Y)=>{const se={inputParameters:{...J.inputParameters,[D]:Y}},re={...J,...se};f(re),a(J.taskReferenceName,se)},Re=D=>{if(!k)return;const Y=k.selectionStart??0,ce=k.selectionEnd??0,se=k.value,re=se.substring(0,Y)+D+se.substring(ce),ve=k.getAttribute("data-field");ve&&ge(ve,re),b(!1)},Ee=(D,Y,ce,se)=>o.jsxs("div",{style:{marginBottom:"24px",padding:"16px",borderRadius:"12px",background:`${ce}10`,border:`1px solid ${ce}30`,boxShadow:"0 4px 12px rgba(0,0,0,0.05)"},children:[o.jsxs("div",{style:{fontSize:"12px",fontWeight:"bold",marginBottom:"16px",color:ce,display:"flex",alignItems:"center",gap:"8px"},children:[o.jsx("span",{children:Y})," ",D]}),se]}),nt=(D,Y,ce="text",se)=>{const re=Y==="taskReferenceName",ve=re&&v!==null?v:J[Y]??"",X=re&&!i(ve,J.taskReferenceName);return o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsxs("label",{style:{display:"block",fontSize:"11px",color:me,marginBottom:"6px",fontWeight:"600",textTransform:"uppercase"},children:[D,re&&X&&o.jsx("span",{style:{color:"#ef4444",marginLeft:"8px",textTransform:"none"},children:"⚠️ 已存在相同引用名"})]}),o.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[o.jsx("input",{type:ce,value:ve,placeholder:se,onChange:le=>{const de=le.target.value;if(re)g(de);else{ge(Y,ce==="number"?de===""?void 0:Number(de):de);const Ie=le.target.selectionStart??0;if(ce==="text"&&Ie>=2&&de.slice(Ie-2,Ie)==="${"){const we=le.target.getBoundingClientRect();L(we),q(()=>Ae=>{const Ke=de.slice(0,Ie-2),Yc=de.slice(Ie);ge(Y,Ke+Ae+Yc)}),E(!0)}}},onFocus:re?()=>{v===null&&g(J.taskReferenceName??"")}:void 0,onBlur:re?le=>{const de=le.target.value.trim();g(null),de&&de!==J.taskReferenceName&&ge("taskReferenceName",de)}:void 0,onKeyDown:re?le=>{le.key==="Enter"&&le.currentTarget.blur(),le.stopPropagation()}:void 0,disabled:!ne,style:{width:"100%",padding:`8px ${ne&&!re?"32px":"12px"} 8px 12px`,borderRadius:"6px",border:`1px solid ${X?"#ef4444":ie}`,background:je,color:xe,fontSize:"13px",outline:"none",opacity:ne?1:.8,fontFamily:re?"monospace":"inherit"}}),ne&&!re&&o.jsx("button",{className:"ai-hint-trigger",onClick:le=>_e(le,de=>ge(Y,de)),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:"✨"})]})]})},Z=(D,Y,ce,se={})=>{const{rows:re=5,language:ve="text",style:X,placeholder:le,"data-field":de}=se,Ie={width:"100%",padding:"12px",borderRadius:"8px",border:`1px solid ${ie}`,background:je,color:xe,fontSize:"12px",fontFamily:"monospace",lineHeight:"1.5",resize:"vertical",...X};return o.jsxs("div",{style:{marginBottom:"8px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"},children:[o.jsx("label",{style:{fontSize:"10px",color:me},children:D}),ne&&o.jsx("button",{onClick:()=>te(D,Y,ve,we=>{ce(we),U(null)}),title:"全屏编辑",style:{background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"2px 4px",color:"var(--text-secondary)",opacity:.7,lineHeight:1},children:"⛶"})]}),o.jsx("textarea",{value:Y,placeholder:le,onChange:we=>{const Ae=we.target.value;ce(Ae);const Ke=we.target.selectionStart??0;if(Ke>=2&&Ae.slice(Ke-2,Ke)==="${"){const Yc=we.target.getBoundingClientRect();L(Yc),q(()=>J_=>{const V_=Ae.slice(0,Ke-2),K_=Ae.slice(Ke);ce(V_+J_+K_)}),E(!0)}},disabled:!ne,rows:re,"data-field":de,onFocus:we=>S(we.currentTarget),style:Ie})]})},ee=(D,Y,ce,se="text",re)=>o.jsxs("div",{style:{marginBottom:"12px"},children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:me,marginBottom:"4px"},children:D}),o.jsx("input",{type:se,value:Y??"",placeholder:re,onChange:ve=>{const X=ve.target.value;ce(se==="number"?X===""?void 0:Number(X):X);const le=ve.target.selectionStart??0;if(se==="text"&&le>=2&&X.slice(le-2,le)==="${"){const de=ve.target.getBoundingClientRect();L(de),q(()=>Ie=>{const we=X.slice(0,le-2),Ae=X.slice(le);ce(we+Ie+Ae)}),E(!0)}},disabled:!ne,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${ie}`,background:je,color:xe,fontSize:"12px",outline:"none"}})]}),ae=(D,Y,ce,se)=>o.jsxs("div",{style:{marginBottom:"12px"},children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:me,marginBottom:"4px"},children:D}),o.jsx("select",{value:ce,onChange:re=>se(re.target.value),disabled:!ne,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${ie}`,background:je,color:xe,fontSize:"12px",outline:"none",cursor:"pointer"},children:Y.map(re=>o.jsx("option",{value:re,children:re},re))})]}),pe=(D,Y,ce)=>o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[o.jsx("span",{style:{fontSize:"11px",color:me},children:D}),o.jsx("button",{onClick:()=>ce(!Y),disabled:!ne,style:{width:"36px",height:"20px",borderRadius:"10px",border:"none",cursor:"pointer",background:Y?"var(--color-accent)":ie,position:"relative",transition:"background 0.2s"},children:o.jsx("span",{style:{position:"absolute",top:"2px",left:Y?"18px":"2px",width:"16px",height:"16px",borderRadius:"50%",background:"#fff",transition:"left 0.2s"}})})]}),Q=(D,Y,ce)=>o.jsx("div",{style:{display:"flex",gap:"6px",marginBottom:"12px"},children:D.map(se=>o.jsx("button",{onClick:()=>ce(se.key),disabled:!ne,style:{flex:1,padding:"6px",borderRadius:"6px",border:`1px solid ${ie}`,cursor:"pointer",fontSize:"11px",fontWeight:Y===se.key?"bold":"normal",background:Y===se.key?"var(--color-accent)":je,color:Y===se.key?"#fff":xe},children:se.label},se.key))}),fe=J.inputParameters?.http_request||J.httpRequest||{};return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`detail-panel-container ${Se}`,style:{position:"absolute",right:0,top:0,bottom:0,width:"450px",zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${ie}`,boxShadow:"-10px 0 30px rgba(0, 0, 0, 0.2)",overflowY:"hidden"},children:[o.jsxs("div",{style:{padding:"24px",borderBottom:`1px solid ${ie}`,background:"var(--bg-secondary)",flexShrink:0},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[o.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:"4px",fontSize:"10px",fontWeight:"bold",letterSpacing:"1px"},children:J.type||"TASK"}),o.jsx("button",{onClick:r,style:{background:"none",border:"none",color:xe,cursor:"pointer",fontSize:"20px"},children:"✕"})]}),ne?o.jsx("input",{value:J.name||"",onChange:D=>ge("name",D.target.value),placeholder:"任务名称",style:{display:"block",width:"100%",fontSize:"22px",fontWeight:"bold",background:"transparent",border:"none",color:xe,outline:"none",borderBottom:"2px dashed var(--color-accent)"}}):o.jsx("div",{style:{fontSize:"22px",fontWeight:"bold"},children:J.name}),o.jsxs("div",{style:{fontSize:"12px",color:me,marginTop:"8px",fontFamily:"monospace",opacity:.8},children:["REF: ",J.taskReferenceName]})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px",background:"var(--bg-primary)"},children:[J.type==="HTTP"&&Ee("HTTP 请求配置","🌐","var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"12px"},children:[o.jsx("select",{value:fe.method||"GET",onChange:D=>Te("method",D.target.value),disabled:!ne,style:{width:"90px",padding:"10px",borderRadius:"8px",background:je,color:xe,border:`1px solid ${ie}`,cursor:"pointer"},children:["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"].map(D=>o.jsx("option",{value:D,children:D},D))}),o.jsx("input",{placeholder:"URI (支持 ${workflow.input.uri})",value:fe.uri||"",onChange:D=>Te("uri",D.target.value),disabled:!ne,style:{flex:1,padding:"10px",borderRadius:"8px",background:je,color:xe,border:`1px solid ${ie}`}})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:me,marginBottom:"4px"},children:"CONTENT-TYPE"}),o.jsx("input",{placeholder:"application/json",value:fe.contentType||"",onChange:D=>Te("contentType",D.target.value),disabled:!ne,style:{width:"100%",padding:"8px",borderRadius:"6px",background:je,color:xe,border:`1px solid ${ie}`,fontSize:"12px"}})]}),o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:me,marginBottom:"4px"},children:"ACCEPT"}),o.jsx("input",{placeholder:"application/json",value:fe.accept||"",onChange:D=>Te("accept",D.target.value),disabled:!ne,style:{width:"100%",padding:"8px",borderRadius:"6px",background:je,color:xe,border:`1px solid ${ie}`,fontSize:"12px"}})]})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:me,marginBottom:"4px"},children:"连接超时 (ms)"}),o.jsx("input",{type:"number",placeholder:"3000",value:fe.connectionTimeOut??"",onChange:D=>Te("connectionTimeOut",D.target.value===""?void 0:Number(D.target.value)),disabled:!ne,style:{width:"100%",padding:"8px",borderRadius:"6px",background:je,color:xe,border:`1px solid ${ie}`,fontSize:"12px"}})]}),o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:me,marginBottom:"4px"},children:"读取超时 (ms)"}),o.jsx("input",{type:"number",placeholder:"3000",value:fe.readTimeOut??"",onChange:D=>Te("readTimeOut",D.target.value===""?void 0:Number(D.target.value)),disabled:!ne,style:{width:"100%",padding:"8px",borderRadius:"6px",background:je,color:xe,border:`1px solid ${ie}`,fontSize:"12px"}})]})]}),o.jsxs("div",{style:{marginBottom:"12px"},children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:me,marginBottom:"4px"},children:"HEADERS (JSON)"}),o.jsx("textarea",{value:typeof fe.headers=="object"?JSON.stringify(fe.headers,null,2):"{}",onChange:D=>{try{Te("headers",JSON.parse(D.target.value))}catch{}},disabled:!ne,rows:3,style:{width:"100%",padding:"8px",borderRadius:"8px",background:je,color:xe,border:`1px solid ${ie}`,fontSize:"11px",fontFamily:"monospace"}})]}),o.jsx("label",{style:{display:"block",fontSize:"10px",color:me,marginBottom:"4px"},children:"BODY (RAW/JSON)"}),o.jsx("textarea",{value:typeof fe.body=="object"?JSON.stringify(fe.body,null,2):fe.body||"",onChange:D=>{let Y=D.target.value;try{Y=JSON.parse(D.target.value)}catch{}Te("body",Y)},disabled:!ne,rows:4,style:{width:"100%",padding:"8px",borderRadius:"8px",background:je,color:xe,border:`1px solid ${ie}`,fontSize:"11px",fontFamily:"monospace"}})]})),(J.type==="INLINE"||J.type==="LAMBDA")&&Ee("内联脚本配置 (Inline)","📜","var(--color-accent)",o.jsxs(o.Fragment,{children:[ae("脚本引擎",["graaljs","javascript","value-param","python"],J.evaluatorType||"graaljs",D=>ge("evaluatorType",D)),Z(`EXPRESSION ${J.evaluatorType==="value-param"?"(值引用)":"(脚本)"}`,J.inputParameters?.expression||J.inputParameters?.scriptExpression||"",D=>{const Y=J.inputParameters?.scriptExpression!==void 0?"scriptExpression":"expression";be(Y,D)},{rows:10,language:J.evaluatorType||"javascript",style:{background:"#000",color:"var(--color-accent)",border:"1px solid var(--color-accent)"}}),o.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:me,fontStyle:"italic"},children:"提示: 使用 $.input.key 访问输入参数,返回值作为任务输出。"})]})),J.type==="JSON_JQ_TRANSFORM"&&Ee("JQ 数据转换","🔍","var(--color-accent)",o.jsxs(o.Fragment,{children:[Z("JQ QUERY EXPRESSION",J.inputParameters?.queryExpression||"",D=>be("queryExpression",D),{rows:6,language:"jq",style:{color:"var(--color-accent)"}}),o.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:me},children:"输出字段: result(首个结果)、resultList(完整列表)"})]})),J.type==="SUB_WORKFLOW"&&Ee("子工作流配置","🏗️","var(--color-accent)",o.jsxs(o.Fragment,{children:[ee("WORKFLOW NAME *",J.subWorkflowParam?.name||"",D=>Fe("subWorkflowParam","name",D),"text","e.g. my_workflow"),ee("VERSION",J.subWorkflowParam?.version??"",D=>Fe("subWorkflowParam","version",D?parseInt(D):void 0),"number","1"),Z("INPUT PARAMETERS MAPPING (JSON)",typeof J.inputParameters=="object"&&J.inputParameters!==null?JSON.stringify(J.inputParameters,null,2):"{}",D=>{try{ge("inputParameters",JSON.parse(D))}catch{}},{rows:5,language:"json"}),o.jsxs("div",{style:{fontSize:"10px",color:me,marginTop:"4px"},children:["传递给子工作流的参数,支持 ","${workflow.input.xxx}"," 表达式"]})]})),J.type==="START_WORKFLOW"&&Ee("启动工作流配置","▶️","var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"11px",color:me,marginBottom:"12px",padding:"8px",borderRadius:"6px",background:"rgba(255,165,0,0.1)",border:"1px solid rgba(255,165,0,0.3)"},children:["⚡ 注意:此任务启动目标工作流后立即继续,",o.jsx("b",{children:"不等待"}),"目标工作流完成。"]}),ee("WORKFLOW NAME *",J.inputParameters?.startWorkflow?.name||"",D=>{const Y={...J.inputParameters?.startWorkflow||{},name:D};be("startWorkflow",Y)},"text","e.g. target_workflow"),ee("VERSION",J.inputParameters?.startWorkflow?.version??"",D=>{const Y={...J.inputParameters?.startWorkflow||{},version:D?parseInt(D):void 0};be("startWorkflow",Y)},"number","1"),ee("CORRELATION ID",J.inputParameters?.startWorkflow?.correlationId||"",D=>{const Y={...J.inputParameters?.startWorkflow||{},correlationId:D};be("startWorkflow",Y)},"text","${workflow.correlationId}"),Z("WORKFLOW INPUT (JSON)",typeof J.inputParameters?.startWorkflow?.input=="object"?JSON.stringify(J.inputParameters.startWorkflow.input,null,2):"{}",D=>{try{const Y={...J.inputParameters?.startWorkflow||{},input:JSON.parse(D)};be("startWorkflow",Y)}catch{}},{rows:4,language:"json"})]})),J.type==="TERMINATE"&&Ee("终止状态配置","⏹️","var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:me,marginBottom:"4px"},children:"TERMINATION STATUS"}),o.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:["COMPLETED","FAILED"].map(D=>o.jsx("button",{onClick:()=>be("terminationStatus",D),disabled:!ne,style:{flex:1,padding:"8px",borderRadius:"6px",cursor:"pointer",background:(J.inputParameters?.terminationStatus||"COMPLETED")===D?"var(--color-accent)":je,color:(J.inputParameters?.terminationStatus||"COMPLETED")===D?"#fff":xe,border:`1px solid ${ie}`,fontWeight:"bold",fontSize:"11px"},children:D},D))}),ee("TERMINATION REASON",J.inputParameters?.terminationReason||"",D=>be("terminationReason",D),"text","终止原因..."),Z("WORKFLOW OUTPUT (JSON)",typeof J.inputParameters?.workflowOutput=="object"?JSON.stringify(J.inputParameters.workflowOutput,null,2):"{}",D=>{try{be("workflowOutput",JSON.parse(D))}catch{}},{rows:3,language:"json"})]})),J.type==="EVENT"&&Ee("事件发送配置","✉️","var(--color-accent)",o.jsxs(o.Fragment,{children:[ee("EVENT SINK *",J.sink||"",D=>ge("sink",D),"text","e.g. sqs:queue_name 或 conductor"),o.jsx("div",{style:{fontSize:"10px",color:me,marginTop:"4px",marginBottom:"8px"},children:"支持前缀: conductor | sqs | kafka | amqp | nats"}),pe("异步完成 (asyncComplete)",!!J.asyncComplete,D=>ge("asyncComplete",D))]})),J.type==="WAIT"&&Ee("等待状态配置","⏳","var(--color-accent)",o.jsxs(o.Fragment,{children:[Q([{key:"duration",label:"等待时长"},{key:"until",label:"等待到指定时间"}],C,D=>T(D)),C==="duration"?ee("DURATION",J.inputParameters?.duration||"",D=>be("duration",D),"text","e.g. 30s, 10m, 2 hours"):ee("UNTIL (时间点)",J.inputParameters?.until||"",D=>be("until",D),"text","e.g. 2025-06-15 09:00 GMT+00:00"),o.jsxs("div",{style:{fontSize:"11px",color:me,lineHeight:"1.6",marginTop:"8px"},children:["此任务会使工作流进入 ",o.jsx("b",{children:"IN_PROGRESS"})," 状态,直到时间满足或外部 API 触发完成。"]})]})),(J.type==="DECISION"||J.type==="SWITCH")&&Ee("条件分支配置","⚖️","var(--color-accent)",o.jsxs(o.Fragment,{children:[ae("评估模式 (evaluatorType)",["value-param","javascript"],J.evaluatorType||"value-param",D=>ge("evaluatorType",D)),(J.evaluatorType||"value-param")==="value-param"?ee("CASE VALUE PARAM (参数名)",J.caseValueParam||"",D=>ge("caseValueParam",D),"text","e.g. status"):o.jsx(o.Fragment,{children:Z("CASE EXPRESSION (JS)",J.caseExpression||"",D=>ge("caseExpression",D),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}})}),o.jsx("div",{style:{fontSize:"10px",color:me,marginTop:"8px"},children:'分支可在图中通过右键节点→"添加分支"进行管理'})]})),J.type==="DO_WHILE"&&Ee("循环逻辑配置","🔄","var(--color-accent)",o.jsxs(o.Fragment,{children:[Q([{key:"condition",label:"条件循环"},{key:"items",label:"列表迭代"}],N,D=>w(D)),N==="condition"?o.jsxs(o.Fragment,{children:[Z("LOOP CONDITION (JS) *",J.loopCondition||"",D=>ge("loopCondition",D),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}}),o.jsx("div",{style:{fontSize:"10px",color:me,marginTop:"4px"},children:"条件为 true 时继续循环,false 时退出"})]}):o.jsxs(o.Fragment,{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:me,marginBottom:"4px"},children:"ITEMS (列表表达式)"}),o.jsx("input",{value:J.inputParameters?.items||"",onChange:D=>be("items",D.target.value),disabled:!ne,placeholder:"${workflow.input.myList}",style:{width:"100%",padding:"8px",borderRadius:"6px",border:`1px solid ${ie}`,background:je,color:xe,fontSize:"12px",outline:"none"}}),o.jsx("div",{style:{fontSize:"10px",color:me,marginTop:"4px"},children:"引用一个数组,对每个元素执行一次循环体"})]}),o.jsx("div",{style:{marginTop:"12px"},children:ee("KEEP LAST N 次迭代",J.keepLastN??"",D=>ge("keepLastN",D?parseInt(D):void 0),"number","0 = 保留全部")})]})),J.type==="FORK_JOIN_DYNAMIC"&&Ee("动态并行配置","⚡","var(--color-accent)",o.jsxs(o.Fragment,{children:[Q([{key:"classic",label:"经典模式"},{key:"task",label:"任务简化"},{key:"workflow",label:"工作流简化"}],_,D=>j(D)),_==="classic"&&o.jsxs(o.Fragment,{children:[ee("DYNAMIC_FORK_TASKS_PARAM",J.dynamicForkTasksParam||"",D=>ge("dynamicForkTasksParam",D),"text","e.g. dynamic_tasks"),ee("DYNAMIC_FORK_TASKS_INPUT_PARAM",J.dynamicForkTasksInputParamName||"",D=>ge("dynamicForkTasksInputParamName",D),"text","e.g. input"),o.jsx("div",{style:{fontSize:"10px",color:me},children:"经典模式:通过 inputParameters 传入 dynamicTasks 数组和 dynamicTasksInput 映射"})]}),_==="task"&&o.jsxs(o.Fragment,{children:[ee("FORK TASK TYPE *",J.forkTaskType||"",D=>ge("forkTaskType",D),"text","e.g. HTTP"),ee("FORK TASK NAME (仅 SIMPLE 任务)",J.forkTaskName||"",D=>ge("forkTaskName",D),"text","e.g. my_task"),ee("FORK TASK INPUTS PARAM",J.forkTaskInputs||"",D=>ge("forkTaskInputs",D),"text","e.g. inputs"),o.jsx("div",{style:{fontSize:"10px",color:me},children:"所有分支执行相同任务类型,每个元素作为一个分支输入"})]}),_==="workflow"&&o.jsxs(o.Fragment,{children:[ee("FORK WORKFLOW NAME *",J.forkTaskWorkflow||"",D=>ge("forkTaskWorkflow",D),"text","e.g. sub_workflow"),ee("WORKFLOW VERSION",J.forkTaskWorkflowVersion||"",D=>ge("forkTaskWorkflowVersion",D),"text","1"),ee("FORK TASK INPUTS PARAM",J.forkTaskInputs||"",D=>ge("forkTaskInputs",D),"text","e.g. inputs"),o.jsx("div",{style:{fontSize:"10px",color:me},children:"所有分支执行相同子工作流,每个元素作为一个子工作流输入"})]})]})),J.type==="DYNAMIC"&&Ee("动态任务配置","🎯","var(--color-accent)",o.jsxs(o.Fragment,{children:[ee("DYNAMIC TASK NAME PARAM *",J.dynamicTaskNameParam||"",D=>ge("dynamicTaskNameParam",D),"text","e.g. taskToExecute"),o.jsx("div",{style:{fontSize:"10px",color:me,marginTop:"4px"},children:'运行时从 inputParameters 的指定键中读取实际任务类型名(如 "HTTP"、"SIMPLE")'})]})),J.type==="HUMAN"&&Ee("人工审批配置","👤","var(--color-accent)",o.jsxs(o.Fragment,{children:[ee("表单模板名 (userFormTemplate)",J.humanTaskDef?.userFormTemplate||"",D=>Fe("humanTaskDef","userFormTemplate",D),"text","e.g. approval_form"),ae("分配策略 (assignmentCompletionStrategy)",["LEAVE_OPEN","TERMINATE"],J.humanTaskDef?.assignmentCompletionStrategy||"LEAVE_OPEN",D=>Fe("humanTaskDef","assignmentCompletionStrategy",D)),ee("显示名称 (displayName)",J.humanTaskDef?.displayName||"",D=>Fe("humanTaskDef","displayName",D),"text","审批任务")]})),J.type==="KAFKA_PUBLISH"&&Ee("Kafka 推送配置","📨","var(--color-accent)",o.jsxs(o.Fragment,{children:[ee("BOOTSTRAP SERVERS *",J.inputParameters?.bootStrapServers||"",D=>be("bootStrapServers",D),"text","localhost:9092"),ee("TOPIC *",J.inputParameters?.topic||"",D=>be("topic",D),"text","my_topic"),ee("KEY (消息分区键)",J.inputParameters?.key||"",D=>be("key",D),"text",""),Z("VALUE (消息内容)",typeof J.inputParameters?.value=="object"?JSON.stringify(J.inputParameters.value,null,2):J.inputParameters?.value||"",D=>{let Y=D;try{Y=JSON.parse(D)}catch{}be("value",Y)},{rows:4,language:"json"}),Z("HEADERS (JSON)",typeof J.inputParameters?.headers=="object"?JSON.stringify(J.inputParameters.headers,null,2):"{}",D=>{try{be("headers",JSON.parse(D))}catch{}},{rows:3,language:"json"})]})),J.type==="SET_VARIABLE"&&Ee("变量配置","📦","var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"11px",color:me,marginBottom:"12px"},children:["在 inputParameters 中定义要设置的变量名和值,后续任务通过 ","${workflow.variables.varName}"," 访问。"]}),Z("VARIABLES (JSON)",typeof J.inputParameters=="object"&&J.inputParameters!==null?JSON.stringify(J.inputParameters,null,2):"{}",D=>{try{ge("inputParameters",JSON.parse(D))}catch{}},{rows:6,language:"json"})]})),o.jsxs("div",{style:{marginTop:"32px",borderTop:`1px solid ${ie}`,paddingTop:"24px"},children:[o.jsx("div",{style:{fontSize:"11px",fontWeight:"bold",marginBottom:"16px",opacity:.6,textTransform:"uppercase",letterSpacing:"1px"},children:"通用参数与属性"}),nt("任务唯一引用名 (Reference Name)","taskReferenceName"),d&&d.newRef===J.taskReferenceName&&o.jsxs("div",{style:{marginBottom:"16px",padding:"10px 12px",borderRadius:"8px",background:"rgba(16, 185, 129, 0.12)",border:"1px solid rgba(16, 185, 129, 0.35)",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[o.jsxs("div",{style:{fontSize:"11px",color:"#34d399",lineHeight:1.5},children:[o.jsx("b",{children:"🔗 W-LSP 全图级联重构已生效"}),o.jsx("br",{}),"引用名 ",o.jsx("code",{children:d.oldRef})," → ",o.jsx("code",{children:d.newRef}),",已自动同步 ",o.jsx("b",{children:d.replacedCount})," 处下游表达式(涉及节点:",d.affectedTasks.join(", "),")"]}),o.jsx("button",{onClick:p,style:{background:"none",border:"none",color:"#34d399",cursor:"pointer",fontSize:"12px",padding:"2px"},children:"✕"})]}),nt("任务描述","description"),o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px",gap:"6px"},children:[o.jsxs("label",{style:{fontSize:"11px",color:me,fontWeight:"600",textTransform:"uppercase",flex:1},children:["输入参数 (inputParameters) ",o.jsxs("span",{style:{opacity:.5,fontWeight:"normal"},children:["(JSON / 输入 $","{"," 自动补全)"]})]}),ne&&o.jsxs("div",{style:{display:"flex",gap:"6px"},children:[o.jsx("button",{onClick:D=>{const Y=D.currentTarget.getBoundingClientRect();L(Y),q(()=>ce=>{if(k)Re(ce);else{const se=typeof J.inputParameters=="object"&&J.inputParameters!==null?{...J.inputParameters}:{};se[`param_${Object.keys(se).length+1}`]=ce,ge("inputParameters",se)}}),E(!0)},title:"打开 W-LSP 上游变量与 Schema 零延迟补全器",style:{fontSize:"11px",background:"rgba(56, 189, 248, 0.14)",border:"1px solid rgba(56, 189, 248, 0.35)",borderRadius:"4px",padding:"2px 8px",cursor:"pointer",color:"#38bdf8",fontWeight:600,display:"flex",alignItems:"center",gap:"4px"},children:"⚡ 变量补全"}),o.jsxs("button",{onClick:ye,disabled:$,title:"AI 根据上下文自动生成 inputParameters",style:{fontSize:"11px",background:"linear-gradient(135deg, #6366f1, #8b5cf6)",border:"none",borderRadius:"4px",padding:"2px 8px",cursor:$?"not-allowed":"pointer",color:"#fff",fontWeight:600,display:"flex",alignItems:"center",gap:"4px",opacity:$?.7:1},children:[$?"⏳":"✨"," AI 填充"]}),o.jsxs("button",{onClick:()=>b(!x),title:"快捷表达式",style:{fontSize:"11px",background:x?"var(--color-accent)":"none",border:`1px solid ${ie}`,borderRadius:"4px",padding:"2px 6px",cursor:"pointer",color:x?"#fff":me},children:["{}"," 片段"]})]})]}),x&&o.jsx("div",{style:{marginBottom:"8px",padding:"8px",borderRadius:"6px",border:`1px solid ${ie}`,background:"var(--bg-secondary)",display:"flex",flexWrap:"wrap",gap:"6px"},children:zS.map(D=>o.jsx("button",{onClick:()=>Re(D.value),title:D.desc,style:{fontSize:"10px",padding:"3px 8px",borderRadius:"4px",border:`1px solid ${ie}`,background:je,color:xe,cursor:"pointer",fontFamily:"monospace"},children:D.label},D.value))}),K&&o.jsxs("div",{style:{marginBottom:"8px",borderRadius:"8px",border:"1px solid #6366f130",background:"#6366f108",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"8px 12px",background:"#6366f118",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsx("span",{style:{fontSize:"11px",fontWeight:700,color:"#6366f1"},children:"✨ AI 建议的 inputParameters"}),o.jsxs("div",{style:{display:"flex",gap:"6px"},children:[o.jsx("button",{onClick:()=>{ge("inputParameters",K.generated),V(null)},style:{fontSize:"11px",background:"#6366f1",color:"#fff",border:"none",borderRadius:"4px",padding:"3px 10px",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:"应用"}),o.jsx("button",{onClick:()=>V(null),style:{fontSize:"11px",background:"none",color:me,border:`1px solid ${ie}`,borderRadius:"4px",padding:"3px 8px",cursor:"pointer",fontFamily:"inherit"},children:"取消"})]})]}),o.jsx("pre",{style:{margin:0,padding:"10px 12px",fontSize:"12px",fontFamily:"var(--font-mono)",overflowX:"auto",color:xe,maxHeight:"180px",overflowY:"auto"},children:JSON.stringify(K.generated,null,2)})]}),Z("",typeof J.inputParameters=="object"&&J.inputParameters!==null?JSON.stringify(J.inputParameters,null,2):J.inputParameters??"",D=>{try{ge("inputParameters",JSON.parse(D))}catch{f(Y=>({...Y,inputParameters:D}))}},{rows:5,language:"json","data-field":"inputParameters",style:{outline:"none"}})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[nt("重试次数","retryCount","number"),nt("超时限制 (秒)","timeoutSeconds","number")]}),o.jsxs("details",{style:{marginTop:"16px"},children:[o.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",color:me,userSelect:"none",fontWeight:"600"},children:"▸ 执行控制(高级)"}),o.jsxs("div",{style:{marginTop:"12px"},children:[ae("重试策略 (retryLogic)",["FIXED","EXPONENTIAL_BACKOFF","LINEAR_BACKOFF"],J.retryLogic||"FIXED",D=>ge("retryLogic",D)),ee("重试延迟 (秒)",J.retryDelaySeconds??"",D=>ge("retryDelaySeconds",D?parseInt(D):void 0),"number","0"),ae("超时策略 (timeoutPolicy)",["TIME_OUT_WF","ALERT_ONLY","RETRY","FAIL_WORKFLOW"],J.timeoutPolicy||"TIME_OUT_WF",D=>ge("timeoutPolicy",D)),ee("启动延迟 (秒)",J.startDelay??"",D=>ge("startDelay",D?parseInt(D):void 0),"number","0"),pe("可选任务 (optional) — 失败不影响工作流",!!J.optional,D=>ge("optional",D)),pe("异步完成 (asyncComplete)",!!J.asyncComplete,D=>ge("asyncComplete",D))]})]})]}),o.jsx("div",{style:{marginTop:"48px",opacity:.6},children:o.jsxs("details",{children:[o.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",marginBottom:"8px"},children:"查看完整 JSON (只读)"}),o.jsx("pre",{style:{background:"rgba(0,0,0,0.2)",padding:"16px",borderRadius:"8px",fontSize:"10px",overflow:"auto",border:`1px solid ${ie}`,color:me},children:JSON.stringify(J,null,2)})]})})]}),ne&&o.jsxs("div",{style:{padding:"24px",borderTop:`1px solid ${ie}`,background:"var(--bg-secondary)",display:"flex",gap:"12px",flexShrink:0},children:[o.jsx("div",{style:{flex:1,fontSize:"11px",color:me,display:"flex",alignItems:"center"},children:"✅ 所有修改已实时同步"}),o.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:"完成退出"})]}),o.jsx(MS,{isOpen:P,onClose:()=>E(!1),onSelect:R,suggestions:B,wlspItems:O,anchorRect:A})]}),W&&o.jsx($S,{title:W.title,value:W.value,language:W.language,onSave:W.onSave,onClose:()=>U(null)})]})},WS=I.memo(qS),fy=({keyName:e,value:t,path:r,depth:n,defaultExpanded:s,forceExpandAll:a,searchQuery:i,onCopyExpr:l,copiedPath:c,buildExpr:u})=>{const d=t!==null&&typeof t=="object",p=Array.isArray(t),[h,f]=I.useState(s),m=a!==null?a:h,y=u(r);if(!I.useMemo(()=>{if(!i.trim())return!0;const S=i.toLowerCase();if(e!==void 0&&String(e).toLowerCase().includes(S))return!0;try{return JSON.stringify(t).toLowerCase().includes(S)}catch{return!1}},[e,t,i]))return null;if(!d){let S="#e2e8f0",C=String(t);return typeof t=="string"?(S="#34d399",C=`"${t}"`):typeof t=="number"?S="#fbbf24":typeof t=="boolean"?S="#f472b6":t==null&&(S="#94a3b8",C="null"),o.jsxs("div",{className:"sjson-row",style:{paddingLeft:`${n*14}px`,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",paddingTop:"2px",paddingBottom:"2px",borderRadius:"4px",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"},children:[o.jsxs("div",{style:{wordBreak:"break-all",lineHeight:1.45},children:[e!==void 0&&o.jsxs("span",{style:{color:"#93c5fd"},children:[typeof e=="number"?`[${e}]`:`"${e}"`,o.jsx("span",{style:{color:"#64748b"},children:": "})]}),o.jsx("span",{style:{color:S},children:C})]}),y&&o.jsx("button",{type:"button",onClick:T=>{T.stopPropagation(),l(y)},title:`复制表达式 ${y}`,style:{flexShrink:0,fontSize:"10px",padding:"1px 6px",borderRadius:"4px",border:"1px solid rgba(56, 189, 248, 0.3)",background:c===y?"rgba(16, 185, 129, 0.2)":"rgba(56, 189, 248, 0.08)",color:c===y?"#34d399":"#38bdf8",cursor:"pointer",opacity:.85,fontFamily:"inherit"},children:c===y?"✓ 已复制":"${} 引用"})]})}const g=p?t.map((S,C)=>[C,S]):Object.entries(t),x=p?"[":"{",b=p?"]":"}",k=p?`${g.length} items`:`${g.length} keys`;return o.jsxs("div",{children:[o.jsxs("div",{onClick:()=>f(!m),style:{paddingLeft:`${n*14}px`,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",paddingTop:"2px",paddingBottom:"2px",cursor:"pointer",userSelect:"none",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[o.jsx("span",{style:{fontSize:"9px",color:"#64748b",width:"10px",display:"inline-block"},children:m?"▼":"▶"}),e!==void 0&&o.jsxs("span",{style:{color:"#93c5fd"},children:[typeof e=="number"?`[${e}]`:`"${e}"`,o.jsx("span",{style:{color:"#64748b"},children:": "})]}),o.jsxs("span",{style:{color:"#94a3b8"},children:[x,!m&&o.jsx("span",{style:{fontSize:"10px",color:"#64748b",margin:"0 4px"},children:k}),!m&&b]})]}),y&&r&&o.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),l(y)},title:`复制对象引用 ${y}`,style:{flexShrink:0,fontSize:"10px",padding:"1px 6px",borderRadius:"4px",border:"1px solid rgba(56, 189, 248, 0.25)",background:c===y?"rgba(16, 185, 129, 0.2)":"rgba(56, 189, 248, 0.06)",color:c===y?"#34d399":"#38bdf8",cursor:"pointer",opacity:.75,fontFamily:"inherit"},children:c===y?"✓ 已复制":"${} 引用"})]}),m&&o.jsxs("div",{children:[g.map(([S,C])=>{const T=typeof S=="number"?`${r}[${S}]`:r?`${r}.${S}`:String(S);return o.jsx(fy,{keyName:S,value:C,path:T,depth:n+1,defaultExpanded:n<1,forceExpandAll:a,searchQuery:i,onCopyExpr:l,copiedPath:c,buildExpr:u},String(S))}),o.jsx("div",{style:{paddingLeft:`${n*14+14}px`,color:"#94a3b8",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"},children:b})]})]})},hy=({data:e,taskReferenceName:t,expressionScope:r="output",maxHeight:n="420px"})=>{const[s,a]=I.useState(""),[i,l]=I.useState(null),[c,u]=I.useState(null),[d,p]=I.useState(!1),h=y=>y?r==="workflow.input"?`\${workflow.input.${y}}`:t?`\${${t}.${r}.${y}}`:null:null,f=y=>{navigator.clipboard.writeText(y),u(y),setTimeout(()=>u(null),1600)};return e==null||typeof e=="object"&&Object.keys(e).length===0?o.jsx("div",{style:{padding:"20px",textAlign:"center",color:"var(--text-secondary)",fontSize:"12px",background:"rgba(15, 23, 42, 0.35)",borderRadius:"8px",border:"1px solid var(--border-primary)"},children:"暂无数据 (Empty Payload)"}):o.jsxs("div",{style:{borderRadius:"8px",border:"1px solid var(--border-primary)",background:"rgba(15, 23, 42, 0.55)",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 10px",borderBottom:"1px solid rgba(148, 163, 184, 0.14)",background:"rgba(15, 23, 42, 0.4)"},children:[o.jsx("input",{type:"text",value:s,onChange:y=>a(y.target.value),placeholder:"🔍 检索字段名或值...",style:{flex:1,padding:"4px 8px",borderRadius:"5px",border:"1px solid rgba(148, 163, 184, 0.2)",background:"rgba(2, 6, 23, 0.5)",color:"#f8fafc",fontSize:"11px",outline:"none"}}),o.jsx("button",{type:"button",onClick:()=>l(!0),style:{fontSize:"10px",padding:"3px 7px",borderRadius:"4px",border:"1px solid rgba(148, 163, 184, 0.2)",background:"transparent",color:"#cbd5e1",cursor:"pointer"},children:"全部展开"}),o.jsx("button",{type:"button",onClick:()=>l(!1),style:{fontSize:"10px",padding:"3px 7px",borderRadius:"4px",border:"1px solid rgba(148, 163, 184, 0.2)",background:"transparent",color:"#cbd5e1",cursor:"pointer"},children:"折叠"}),o.jsx("button",{type:"button",onClick:()=>p(!d),style:{fontSize:"10px",padding:"3px 7px",borderRadius:"4px",border:"1px solid rgba(148, 163, 184, 0.2)",background:d?"rgba(56, 189, 248, 0.18)":"transparent",color:d?"#38bdf8":"#cbd5e1",cursor:"pointer"},children:d?"树形视图":"RAW"})]}),o.jsx("div",{style:{padding:"10px 12px",maxHeight:n,overflowY:"auto",overflowX:"auto"},children:d?o.jsx("pre",{style:{margin:0,fontSize:"11px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace",color:"#e2e8f0",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(e,null,2)}):o.jsx(fy,{value:e,path:"",depth:0,defaultExpanded:!0,forceExpandAll:i,searchQuery:s,onCopyExpr:f,copiedPath:c,buildExpr:h})})]})},FS={COMPLETED:"var(--status-completed)",FAILED:"var(--status-failed)",FAILED_WITH_TERMINAL_ERROR:"var(--status-failed-terminal)",IN_PROGRESS:"var(--status-in-progress)",SCHEDULED:"var(--status-scheduled)",TIMED_OUT:"var(--status-timed-out)",CANCELED:"var(--status-canceled)",SKIPPED:"var(--status-skipped)"},Qt=e=>FS[e??""]??"var(--text-secondary)",BS=(e,t)=>{if(!e)return"-";const r=(t??Date.now())-e;return r<1e3?`${r}ms`:`${(r/1e3).toFixed(2)}s`},my=e=>e?new Date(e).toLocaleTimeString():"-",HS=({executionActions:e})=>{const{selectedTask:t,selectedTaskInstance:r,setSelectedTask:n,setSelectedTaskInstance:s,executionData:a,workflowInstance:i}=oe(ke(B=>({selectedTask:B.selectedTask,selectedTaskInstance:B.selectedTaskInstance,setSelectedTask:B.setSelectedTask,setSelectedTaskInstance:B.setSelectedTaskInstance,executionData:B.executionData,workflowInstance:B.workflowInstance}))),[l,c]=I.useState("summary"),u=I.useRef(null);I.useEffect(()=>{u.current?.scrollTo({top:0})},[l,t?.taskReferenceName]),I.useEffect(()=>{c("summary")},[t?.taskReferenceName]);const d=t?.taskReferenceName==="__workflow_global__",p=t?a?.[t.taskReferenceName]:null;if(!t||!p&&!d)return null;const h=p?.attempts??[],f=r??h[h.length-1],m=i?.workflowId??"",y=i?.status,v=p?.status,g=d?y:f?.status??v,x=d?i?.startTime:f?.startTime,b=d?i?.endTime:f?.endTime,k=d?i?.reasonForIncompletion:f?.reasonForIncompletion,S=d?i?.workflowId:f?.taskId,C=d?i?.input:f?.inputData,T=d?i?.output:f?.outputData,N=!d&&e?.onSkipTask&&(v==="SCHEDULED"||v==="IN_PROGRESS")&&(y==="RUNNING"||y==="PAUSED"),w=!d&&e?.onRerunFromTask&&(y==="FAILED"||y==="TERMINATED"||y==="COMPLETED"||y==="TIMED_OUT"),_=N||w,j=e?.allowOperations!==!1,P=()=>{n(null),s(null)},E="var(--glass-border)",A="var(--text-secondary)",L="var(--bg-tertiary)";return o.jsxs("div",{className:"detail-panel-container panel-enter-active",style:{position:"absolute",right:0,top:0,bottom:0,width:450,zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${E}`,boxShadow:"-10px 0 30px rgba(0,0,0,0.2)",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"20px 24px",borderBottom:`1px solid ${E}`,background:"var(--bg-secondary)",flexShrink:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[o.jsx("div",{style:{background:"var(--color-accent)",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:"bold",letterSpacing:"1px",flexShrink:0},children:d?"WORKFLOW":t.type||"TASK"}),g&&o.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,background:`${Qt(g)}18`,color:Qt(g),letterSpacing:"0.5px",flexShrink:0},children:["● ",g]}),o.jsx("div",{style:{flex:1}}),o.jsx("button",{onClick:P,style:{background:"none",border:"none",color:A,cursor:"pointer",fontSize:20,lineHeight:1,padding:4},children:"✕"})]}),o.jsx("div",{style:{fontSize:20,fontWeight:700,color:"var(--text-primary)",lineHeight:1.3},children:d?"工作流全局数据":t.name}),o.jsxs("div",{style:{fontSize:12,color:A,marginTop:6,fontFamily:"monospace",opacity:.8},children:["REF: ",t.taskReferenceName]})]}),h.length>1&&o.jsxs("div",{style:{padding:"12px 24px",borderBottom:`1px solid ${E}`,background:"var(--bg-secondary)",flexShrink:0},children:[o.jsxs("div",{style:{fontSize:11,fontWeight:600,color:A,marginBottom:8,textTransform:"uppercase",letterSpacing:"0.5px"},children:["执行记录(",h.length," 次",h.some(B=>B.iteration)?" / 迭代":"尝试",")"]}),o.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:h.map((B,z)=>{const R=f?.taskId===B.taskId;return o.jsx("button",{onClick:()=>s(B),style:{padding:"4px 12px",borderRadius:20,fontSize:12,cursor:"pointer",border:`1px solid ${R?"var(--color-accent)":E}`,background:R?"var(--color-accent)":"var(--bg-tertiary)",color:R?"#fff":"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},children:B.iteration?`迭代 ${B.iteration}`:`尝试 ${z+1}`},B.taskId)})})]}),o.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${E}`,background:"var(--bg-secondary)",flexShrink:0},children:["summary","input","output"].map(B=>{const z={summary:"概览",input:"输入 JSON",output:"输出 JSON"},R=l===B;return o.jsx("button",{onClick:()=>c(B),style:{padding:"10px 20px",background:"none",border:"none",borderBottom:`2px solid ${R?"var(--color-accent)":"transparent"}`,color:R?"var(--color-accent)":A,cursor:"pointer",fontSize:13,fontWeight:R?600:400,fontFamily:"inherit",transition:"all 0.15s"},children:z[B]},B)})}),o.jsxs("div",{ref:u,style:{flex:1,overflowY:"auto",padding:24,background:"var(--bg-primary)"},children:[l==="summary"&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:24},children:[{label:"总耗时",value:BS(x,b)},{label:"开始时间",value:my(x)},{label:"结束时间",value:my(b)},{label:d?"Workflow ID":"Task ID",value:o.jsx("span",{style:{fontSize:10,fontFamily:"monospace",opacity:.7,wordBreak:"break-all"},children:S??"-"})}].map(({label:B,value:z})=>o.jsxs("div",{style:{padding:"12px 14px",background:L,borderRadius:10,border:`1px solid ${E}`},children:[o.jsx("div",{style:{fontSize:10,color:A,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:6,fontWeight:600},children:B}),o.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:13},children:z})]},B))}),h.length>1&&o.jsxs("div",{style:{marginBottom:20,padding:"10px 14px",background:`${Qt(v)}10`,border:`1px solid ${Qt(v)}30`,borderRadius:8,fontSize:12,color:Qt(v),display:"flex",alignItems:"center",gap:8},children:[o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("path",{d:"M13 2v4h-4"}),o.jsx("path",{d:"M13 6A7 7 0 1 1 9.5 2.5"})]}),"已重试 ",h.length-1," 次,共 ",h.length," 次尝试"]}),!d&&f?.workerId&&o.jsxs("div",{style:{marginBottom:20},children:[o.jsx("div",{style:{fontSize:10,color:A,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:4,fontWeight:600},children:"Worker"}),o.jsx("div",{style:{fontSize:12,fontFamily:"monospace",color:"var(--text-primary)",opacity:.8},children:f.workerId})]}),k&&o.jsxs("div",{style:{padding:14,background:"rgba(239,68,68,0.08)",borderLeft:"3px solid var(--status-failed)",borderRadius:"0 8px 8px 0",fontSize:12,color:"var(--status-failed)",lineHeight:1.6},children:[o.jsx("strong",{children:"异常信息"}),o.jsx("div",{style:{marginTop:6,opacity:.9},children:k})]}),_&&o.jsxs("div",{style:{marginTop:24,paddingTop:20,borderTop:`1px solid ${E}`},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[o.jsx("div",{style:{fontSize:11,fontWeight:600,color:A,textTransform:"uppercase",letterSpacing:"0.5px"},children:"任务操作"}),!j&&o.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 7px",borderRadius:4,background:"rgba(239,68,68,0.08)",border:"1px solid rgba(239,68,68,0.25)",color:"var(--status-failed)",fontSize:10,fontWeight:600},children:[o.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:[o.jsx("circle",{cx:"8",cy:"8",r:"6"}),o.jsx("path",{d:"M8 5v3M8 11v.5"})]}),"操作权限受限"]})]}),o.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[w&&o.jsxs("button",{disabled:!j,onClick:()=>j&&e.onRerunFromTask(m,t.taskReferenceName,f?.taskId),title:j?`从任务 ${t.taskReferenceName} 处重新运行工作流`:"操作权限受限",style:j?vt:gy,onMouseEnter:B=>!j||Object.assign(B.currentTarget.style,US),onMouseLeave:B=>!j||Object.assign(B.currentTarget.style,vt),children:[o.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("path",{d:"M3 14v-4h4"}),o.jsx("path",{d:"M3 10A7 7 0 1 1 6.5 13.5"})]}),"从此处重新运行"]}),N&&o.jsxs("button",{disabled:!j,onClick:()=>j&&e.onSkipTask(m,t.taskReferenceName,f?.taskId),title:j?`跳过任务 ${t.taskReferenceName}`:"操作权限受限",style:j?vt:gy,onMouseEnter:B=>!j||Object.assign(B.currentTarget.style,JS),onMouseLeave:B=>!j||Object.assign(B.currentTarget.style,vt),children:[o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:o.jsx("path",{d:"M4 4l8 8M12 4l-8 8"})}),"跳过此任务"]})]})]})]}),l==="input"&&o.jsx(hy,{data:C,taskReferenceName:d?void 0:t.taskReferenceName,expressionScope:d?"workflow.input":"input",maxHeight:"calc(100vh - 280px)"}),l==="output"&&o.jsx(hy,{data:T,taskReferenceName:d?void 0:t.taskReferenceName,expressionScope:"output",maxHeight:"calc(100vh - 280px)"})]})]})},vt={display:"inline-flex",alignItems:"center",gap:6,padding:"7px 14px",borderRadius:8,fontSize:12,fontWeight:500,cursor:"pointer",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},US={...vt,borderColor:"var(--color-accent)",color:"var(--color-accent)",background:"var(--bg-primary)"},JS={...vt,borderColor:"var(--status-failed)",color:"var(--status-failed)",background:"rgba(239,68,68,0.08)"},gy={...vt,opacity:.45,cursor:"not-allowed",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-secondary)"},VS={add:"新增",mod:"修改",del:"删除",replace:"替换"},KS={add:"+",mod:"~",del:"−"};function GS({diff:e,applied:t,onApply:r,onUndo:n}){const s=e.kind==="replace"?"add":e.kind;return o.jsxs("div",{className:"diff-card",children:[o.jsxs("div",{className:"diff-head",children:[o.jsx("span",{className:`diff-badge ${s}`,children:VS[e.kind]??e.kind}),o.jsx("span",{className:"diff-summary",children:e.summary})]}),e.rows&&e.rows.length>0&&o.jsx("div",{className:"diff-list",children:e.rows.map((a,i)=>o.jsxs("div",{className:`diff-row ${a.kind}`,children:[o.jsx("div",{className:"diff-marker",children:KS[a.kind]??"·"}),o.jsx("div",{className:"diff-desc",children:a.desc})]},i))}),o.jsx("div",{className:"diff-actions",children:t?o.jsxs(o.Fragment,{children:[o.jsxs("button",{className:"diff-btn applied",disabled:!0,children:[o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"已应用"]}),o.jsxs("button",{className:"diff-btn undo",onClick:n,children:[o.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[o.jsx("path",{d:"M3.5 8a4.5 4.5 0 1 1 1.4 3.3",strokeLinecap:"round"}),o.jsx("path",{d:"M3 4.5L4.5 8L7 6.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),"撤销"]})]}):o.jsxs("button",{className:"diff-btn apply",onClick:r,children:[o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",children:o.jsx("path",{d:"M3 8l3.5 3.5L13 5",strokeLinecap:"round",strokeLinejoin:"round"})}),"应用更改"]})})]})}function yy(e,t){const r=JSON.parse(JSON.stringify(e));if(t.kind==="replace"&&t.payload)return{next:JSON.parse(JSON.stringify(t.payload)),inverse:{kind:"replace",summary:"撤销替换",rows:[],payload:e}};if(t.kind==="add"&&t.payload)return{next:JSON.parse(JSON.stringify(t.payload)),inverse:{kind:"replace",summary:"撤销生成",rows:[],payload:e}};if(!t.patch)return{next:r,inverse:{kind:t.kind,summary:"(无变更)",rows:[]}};const n=[],s=[];for(const a of t.patch)if(a.op==="patchTask"){const i=r.tasks.find(c=>c.taskReferenceName===a.ref);if(!i)continue;const l={};for(const c of Object.keys(a.set))l[c]=i[c];Object.assign(i,a.set),n.push({op:"patchTask",ref:a.ref,set:l}),s.push({kind:"mod",desc:`还原 ${a.ref} 属性`})}else if(a.op==="addEdge")r.edges=r.edges??[],r.edges.push({from:a.from,to:a.to,label:a.label}),n.push({op:"removeEdge",from:a.from,to:a.to}),s.push({kind:"del",desc:`移除边 ${a.from} → ${a.to}`});else if(a.op==="removeEdge")r.edges=(r.edges??[]).filter(i=>!(i.from===a.from&&i.to===a.to)),n.push({op:"addEdge",from:a.from,to:a.to}),s.push({kind:"add",desc:`恢复边 ${a.from} → ${a.to}`});else if(a.op==="addTask")r.tasks.push(a.task),r.edges=r.edges??[],a.removeEdges&&a.removeEdges.forEach(i=>{r.edges=r.edges.filter(l=>!(l.from===i.from&&l.to===i.to))}),a.extraEdges&&a.extraEdges.forEach(i=>r.edges.push(i)),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}`});else if(a.op==="removeTask"){const i=r.tasks.findIndex(u=>u.taskReferenceName===a.ref);if(i<0)continue;const[l]=r.tasks.splice(i,1),c=(r.edges??[]).filter(u=>u.from===a.ref||u.to===a.ref);r.edges=(r.edges??[]).filter(u=>u.from!==a.ref&&u.to!==a.ref),n.push({op:"addTask",task:l,extraEdges:c}),s.push({kind:"add",desc:`恢复 ${a.ref}`})}else if(a.op==="insertAfter"){r.tasks.push(a.task),r.edges=r.edges??[];const i=r.edges.findIndex(l=>l.from===a.after&&l.to===a.edgeTo);i>=0&&r.edges.splice(i,1),r.edges.push({from:a.after,to:a.task.taskReferenceName}),r.edges.push({from:a.task.taskReferenceName,to:a.edgeTo}),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复直连边)`})}else if(a.op==="insertBefore"){r.tasks.push(a.task),r.edges=r.edges??[];const i=r.edges.filter(l=>l.to===a.before);r.edges=r.edges.filter(l=>l.to!==a.before),i.forEach(l=>r.edges.push({from:l.from,to:a.task.taskReferenceName,label:l.label})),r.edges.push({from:a.task.taskReferenceName,to:a.before}),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复原有入边)`})}return{next:r,inverse:{kind:t.kind,summary:`撤销:${t.summary}`,rows:s,patch:n.reverse()}}}function YS(e){const t=e.match(/```diff-json\n([\s\S]*?)\n```/);if(!t)return null;try{const r=JSON.parse(t[1]);return!r.kind||!r.summary?null:r}catch{return null}}const xy={id:"1",role:"ai",content:"你好!我是您的流程助手。我可以帮你生成工作流框架、优化逻辑或提供参数配置建议。你想实现什么样的流程?"},by=e=>e.split(/(```[\s\S]*?```)/).map((r,n)=>{if(r.startsWith("```")&&r.endsWith("```")){const s=r.slice(3,-3),a=s.indexOf(`
|
|
129
|
-
`),i=a>=0?s.slice(a+1):s;return o.jsx("pre",{children:o.jsx("code",{children:i})},n)}return o.jsx("span",{children:
|
|
130
|
-
`&&t.push(o.jsx("br",{},s.index)),n=s.index+a.length}return n<e.length&&t.push(e.slice(n)),t},ZS=({aiConfig:e})=>{const{workflowDef:t,setWorkflow:r,mode:n}=oe(ke(A=>({workflowDef:A.workflowDef,setWorkflow:A.setWorkflow,mode:A.mode}))),[s,a]=I.useState(!1),[i,l]=I.useState(""),[c,u]=I.useState(!1),[d,p]=I.useState([xy]),[h,f]=I.useState(""),[m,y]=I.useState(null),v=I.useRef(null),g=I.useRef(null),x=I.useRef(null),b=I.useCallback(A=>{if(!A.diff||A.applied||!t)return;const{next:L,inverse:B}=yy(t,A.diff);r(L),p(z=>z.map(R=>R.id===A.id?{...R,applied:!0,inverse:B}:R))},[t,r]),k=I.useCallback(A=>{if(!A.inverse||!A.applied||!t)return;const{next:L}=yy(t,A.inverse);r(L),p(B=>B.map(z=>z.id===A.id?{...z,applied:!1,inverse:void 0}:z))},[t,r]),S=()=>{const A=g.current;A&&(A.style.height="auto",A.style.height=Math.min(A.scrollHeight,120)+"px")},C=()=>{const A=g.current;A&&(A.style.height="auto")};I.useEffect(()=>()=>{x.current?.abort()},[]),I.useEffect(()=>{const A=()=>a(!0);return window.addEventListener("open-ai-chat",A),()=>window.removeEventListener("open-ai-chat",A)},[]);const T=()=>{v.current?.scrollIntoView({behavior:"smooth"})};I.useEffect(()=>{s&&T()},[d,s,h]);const N=I.useCallback(A=>{const L=[{role:"system",content:CS}];for(const z of d)z.role==="user"&&z.content?L.push({role:"user",content:z.content}):z.role==="ai"&&z.content&&!z.thinking&&L.push({role:"assistant",content:z.content});const B=AS(A,t);return L.push({role:"user",content:B}),L},[d,t]),w=async A=>{const L=i.trim();if(!L||c)return;x.current?.abort();const B=new AbortController;x.current=B;const z={id:Date.now().toString(),role:"user",content:L};p(R=>[...R,z]),l(""),C(),u(!0),f("");try{const R=e?.apiKey||localStorage.getItem("AI_API_KEY")||"",q=e?.baseUrl||localStorage.getItem("AI_BASE_URL")||"",M=e?.model||localStorage.getItem("AI_MODEL")||"";if(!R){setTimeout(()=>{if(B.signal.aborted)return;const V={name:"demo_approval_workflow",description:"演示审批流程",tasks:[{name:"submit_request",taskReferenceName:"submit_request",type:"SIMPLE",inputParameters:{}},{name:"human_approval",taskReferenceName:"human_approval",type:"HUMAN",inputParameters:{}},{name:"process_result",taskReferenceName:"process_result",type:"SIMPLE",inputParameters:{}}]},te={id:(Date.now()+1).toString(),role:"ai",content:"**演示模式**:未检测到 API Key,以下是一个示例审批流程供体验。请在标题栏 🤖 按钮中配置真实 API Key 以启用 AI 功能。",diff:{kind:"replace",summary:"生成三步审批流程(演示)",rows:[{kind:"add",desc:"submit_request — 提交申请任务"},{kind:"add",desc:"human_approval — 人工审批任务"},{kind:"add",desc:"process_result — 处理审批结果"}],payload:V}};p(ue=>[...ue,te]),u(!1)},800);return}const O={apiKey:R};q&&(O.baseUrl=q),M&&(O.model=M);const W=N(L),U=await jS(W,O,V=>{f(te=>te+V)},()=>{},B.signal);let H=YS(U);if(!H){const V=U.match(/```json\n([\s\S]*?)\n```/);if(V)try{const te=JSON.parse(V[1]);H={kind:"replace",summary:"应用 AI 生成的工作流",rows:[{kind:"add",desc:"全量替换为 AI 生成的工作流定义"}],payload:te}}catch{}}const K={id:(Date.now()+1).toString(),role:"ai",content:U,diff:H??void 0,applied:!1};p(V=>[...V,K]),f("")}catch(R){if(R.name==="AbortError")f(q=>{if(q){const M={id:(Date.now()+1).toString(),role:"ai",content:q};p(O=>[...O,M])}return""});else{const q={id:Date.now().toString(),role:"ai",content:`抱歉,目前无法连接到 AI 服务: ${R.message}`};p(M=>[...M,q]),f("")}}finally{u(!1)}},_=()=>{x.current?.abort()},j=()=>{x.current?.abort(),p([xy]),f(""),u(!1)},P=A=>{navigator.clipboard.writeText(A.content??""),y(A.id),setTimeout(()=>y(null),1500)},E=A=>{A.nativeEvent.isComposing||A.keyCode===229||A.key==="Enter"&&!A.shiftKey&&(A.preventDefault(),w())};return n!=="edit"?null:s?o.jsxs("div",{className:"ai-chat-panel",children:[o.jsxs("div",{className:"ai-header",children:[o.jsxs("div",{className:"ai-title",children:[o.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]}),o.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[o.jsx("button",{className:"ai-close",onClick:j,title:"清空对话",children:"🗑"}),o.jsx("button",{className:"ai-close",onClick:()=>a(!1),children:"×"})]})]}),o.jsxs("div",{className:"ai-messages",children:[d.map(A=>o.jsxs("div",{className:`message ${A.role}`,children:[o.jsx("div",{className:"message-content",children:A.thinking?o.jsxs("div",{className:"thinking-skeleton",children:[o.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),o.jsx("div",{className:"skeleton-line",style:{width:"60%"}})]}):A.role==="ai"?by(A.content??""):A.content}),A.diff&&!A.thinking&&o.jsx(GS,{diff:A.diff,applied:A.applied??!1,onApply:()=>b(A),onUndo:()=>k(A)}),A.role==="ai"&&A.content&&o.jsx("button",{className:"copy-btn",onClick:()=>P(A),title:"复制",children:m===A.id?"✓":"📋"})]},A.id)),c&&h&&o.jsxs("div",{className:"message ai",style:{opacity:.9},children:[o.jsx("div",{className:"message-content",children:by(h)}),o.jsx("span",{className:"streaming-cursor",children:"▊"})]}),c&&!h&&o.jsxs("div",{className:"message ai thinking-skeleton",children:[o.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),o.jsx("div",{className:"skeleton-line",style:{width:"60%"}}),o.jsx("div",{className:"skeleton-line",style:{width:"70%"}})]}),o.jsx("div",{ref:v})]}),o.jsx("div",{className:"ai-input-area",children:o.jsxs("div",{className:"ai-input-container",children:[o.jsx("textarea",{ref:g,className:"ai-input",placeholder:c?"AI 正在响应...":"描述您的需求…(Shift+Enter 换行)",value:i,onChange:A=>l(A.target.value),onInput:S,onKeyDown:E,disabled:c,rows:2}),c?o.jsx("button",{className:"ai-send stop",onClick:_,title:"停止生成",children:"⏹"}):o.jsx("button",{className:"ai-send",onClick:()=>w(),title:"发送",children:"🚀"})]})})]}):o.jsx("div",{className:"ai-chat-panel collapsed",onClick:()=>a(!0),children:o.jsx("div",{className:"ai-header",style:{borderBottom:"none"},children:o.jsxs("div",{className:"ai-title",children:[o.jsx("span",{className:"ai-sparkles",children:"✨"}),"AI 助手"]})})})},QS=new Set(["COMPLETED","FAILED","TIMED_OUT","TERMINATED"]),ew=({onTriggerExecution:e,onPollExecution:t,executionPollInterval:r=3e3})=>{const{workflowDef:n,showRunPanel:s,setShowRunPanel:a,setRunState:i,importExecutionJSON:l,setMode:c}=oe(ke(j=>({workflowDef:j.workflowDef,showRunPanel:j.showRunPanel,setShowRunPanel:j.setShowRunPanel,setRunState:j.setRunState,importExecutionJSON:j.importExecutionJSON,setMode:j.setMode}))),[u,d]=I.useState("form"),[p,h]=I.useState({}),[f,m]=I.useState("{}"),[y,v]=I.useState(""),[g,x]=I.useState(!1),[b,k]=I.useState(""),S=st(n?.inputParameters);I.useEffect(()=>{s&&(h({}),m("{}"),v(""),k(""),x(!1))},[s]);const C=I.useCallback(()=>{try{const j={};S.forEach(P=>{const E=p[P.name];if(E!==void 0&&E!=="")if(P.type==="number")j[P.name]=Number(E);else if(P.type==="boolean")j[P.name]=E==="true";else if(P.type==="object"||P.type==="array")try{j[P.name]=JSON.parse(E)}catch{j[P.name]=E}else j[P.name]=E;else P.defaultValue!==void 0&&(j[P.name]=P.defaultValue)}),m(JSON.stringify(j,null,2))}catch{}d("json")},[p,S]),T=I.useCallback(()=>{try{const j=JSON.parse(f),P={};S.forEach(E=>{const A=j[E.name];A!==void 0&&(P[E.name]=typeof A=="object"?JSON.stringify(A,null,2):String(A))}),h(P),v("")}catch{v("JSON 格式有误,无法切换为表单模式")}d("form")},[f,S]),N=I.useCallback(()=>{if(u==="json")try{return JSON.parse(f)}catch{return v("JSON 格式有误,请检查后重试"),null}const j={};return S.forEach(P=>{const E=p[P.name]??(P.defaultValue!==void 0?String(P.defaultValue):"");if(!(E===""&&!P.required))if(P.type==="number")j[P.name]=Number(E);else if(P.type==="boolean")j[P.name]=E==="true";else if(P.type==="object"||P.type==="array")try{j[P.name]=JSON.parse(E)}catch{j[P.name]=E}else j[P.name]=E}),j},[u,f,p,S]),w=I.useCallback(async()=>{if(!e||!n)return;const j=N();if(j===null)return;const P=S.filter(E=>E.required&&(j[E.name]===void 0||j[E.name]===""));if(P.length>0){k(`必填参数未填写:${P.map(E=>E.name).join(", ")}`);return}x(!0),k(""),i("triggering");try{const{workflowId:E}=await e(n.name,n.version??1,j);if(i("polling",E),a(!1),c("run"),!t)return;let A=r;const L=15e3;let B;const z=async()=>{try{const R=await t(E);if(R&&(l(R),QS.has(R.status))){i("done",E);return}}catch{}A=Math.min(A*1.5,L),B=setTimeout(z,A)};B=setTimeout(z,A),oe.getState().__pollTimer=B}catch(E){const A=E?.message||"执行触发失败,请检查配置后重试";i("error",null,A),k(A),x(!1)}},[e,t,n,N,S,i,a,l,c,r]);if(!s||!n)return null;const _=S.length>0;return o.jsx("div",{className:"wrp-overlay",onClick:()=>a(!1),children:o.jsxs("div",{className:"wrp-panel",onClick:j=>j.stopPropagation(),children:[o.jsxs("div",{className:"wrp-header",children:[o.jsxs("div",{className:"wrp-header-title",children:[o.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"currentColor",style:{color:"var(--status-completed)"},children:o.jsx("path",{d:"M4 3l9 5-9 5z"})}),"执行验证"]}),o.jsxs("div",{className:"wrp-workflow-name",children:[n.name," ",o.jsxs("span",{className:"wrp-version",children:["v",n.version??1]})]}),o.jsx("button",{className:"wrp-close",onClick:()=>a(!1),children:"✕"})]}),o.jsxs("div",{className:"wrp-content",children:[o.jsxs("div",{className:"wrp-section-label",children:["工作流输入参数",_&&o.jsxs("div",{className:"wrp-mode-toggle",children:[o.jsx("button",{className:u==="form"?"active":"",onClick:u==="json"?T:void 0,children:"表单模式"}),o.jsx("button",{className:u==="json"?"active":"",onClick:u==="form"?C:void 0,children:"JSON 编辑器"})]})]}),!_&&u==="form"&&o.jsxs("p",{className:"wrp-hint",children:["该工作流未声明输入参数。你可以在 ",o.jsx("strong",{children:"工作流设置 → 参数配置"})," 中添加,也可以直接在 JSON 编辑器中手动填写。"]}),u==="form"?o.jsxs("div",{className:"wrp-form",children:[S.map(j=>o.jsxs("div",{className:"wrp-field",children:[o.jsxs("label",{className:"wrp-field-label",children:[j.name,j.required&&o.jsx("span",{className:"wrp-required",children:"*"}),j.type&&o.jsx("span",{className:"wrp-type",children:j.type})]}),j.description&&o.jsx("p",{className:"wrp-field-desc",children:j.description}),j.type==="object"||j.type==="array"?o.jsx("textarea",{className:"wrp-input",rows:3,placeholder:j.example?JSON.stringify(j.example,null,2):"{}",value:p[j.name]??"",onChange:P=>h(E=>({...E,[j.name]:P.target.value}))}):j.type==="boolean"?o.jsxs("select",{className:"wrp-input",value:p[j.name]??(j.defaultValue!==void 0?String(j.defaultValue):""),onChange:P=>h(E=>({...E,[j.name]:P.target.value})),children:[o.jsx("option",{value:"",children:"请选择"}),o.jsx("option",{value:"true",children:"true"}),o.jsx("option",{value:"false",children:"false"})]}):o.jsx("input",{className:"wrp-input",type:j.type==="number"?"number":"text",placeholder:j.example!==void 0?String(j.example):j.defaultValue!==void 0?String(j.defaultValue):"",value:p[j.name]??"",onChange:P=>h(E=>({...E,[j.name]:P.target.value}))})]},j.name)),!_&&o.jsx("button",{className:"wrp-switch-json",onClick:C,children:"切换为 JSON 编辑器手动填写"})]}):o.jsxs("div",{className:"wrp-json-editor",children:[o.jsx("textarea",{className:"wrp-input wrp-json",rows:12,value:f,onChange:j=>{m(j.target.value),v("")},spellCheck:!1,placeholder:'{\\n "key": "value"\\n}'}),y&&o.jsx("p",{className:"wrp-error",children:y})]}),b&&o.jsx("p",{className:"wrp-error wrp-submit-error",children:b})]}),o.jsxs("div",{className:"wrp-footer",children:[o.jsx("button",{className:"wrp-btn wrp-btn-cancel",onClick:()=>a(!1),children:"取消"}),e?o.jsx("button",{className:"wrp-btn wrp-btn-execute",onClick:w,disabled:g,children:g?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"wrp-spinner"}),"执行中..."]}):o.jsxs(o.Fragment,{children:[o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4 3l9 5-9 5z"})}),"发起执行"]})}):o.jsx("span",{className:"wrp-hint-inline",children:"未配置 onTriggerExecution 回调"})]})]})})},tw=[{pattern:/NullPointerException|null.*inputData|inputData.*null/i,category:"parameter",title:"参数引用为空",explanation:"某个 inputParameters 字段引用的上游任务输出为 null。请检查 JSONPath 表达式,确认前序任务确实返回了对应字段。",suggestEditParam:"inputParameters"},{pattern:/PathNotFoundException|No results for path|path not found/i,category:"parameter",title:"JSONPath 路径不存在",explanation:"参数中的 JSONPath 表达式(如 ${task.output.field})在实际执行数据中找不到对应路径。请核查前序任务的实际输出结构。",suggestEditParam:"inputParameters"},{pattern:/ClassCastException|cannot cast|type mismatch/i,category:"parameter",title:"参数类型不匹配",explanation:"输入参数的数据类型与任务期望不符(如将字符串传给了数字类型参数)。请检查参数值的类型。",suggestEditParam:"inputParameters"},{pattern:/Connection refused|connect.*timeout|SocketException/i,category:"network",title:"网络连接失败",explanation:"无法连接到目标服务器。请检查 HTTP 任务的 uri 是否正确,以及目标服务是否可访问。",suggestEditParam:"uri"},{pattern:/HTTP.*4\d\d|status.*4\d\d|4\d\d.*status/i,category:"network",title:"HTTP 客户端错误",explanation:"HTTP 请求返回 4xx 错误,通常由请求参数、认证或权限问题引起。请检查 uri、headers、body 配置。",suggestEditParam:"inputParameters"},{pattern:/HTTP.*5\d\d|status.*5\d\d|5\d\d.*status/i,category:"network",title:"HTTP 服务端错误",explanation:"目标服务返回 5xx 错误,服务端发生异常。可尝试重试,或检查传入的请求体是否符合服务端期望。",suggestEditParam:"inputParameters"},{pattern:/Unauthorized|401|authentication|auth.*failed/i,category:"auth",title:"认证失败",explanation:"请求被拒绝,认证信息无效或缺失。请检查 headers 中的 Authorization 或 token 参数配置。",suggestEditParam:"inputParameters"},{pattern:/timeout|timed.?out|TIMED_OUT/i,category:"timeout",title:"任务超时",explanation:"任务执行时间超过配置的超时阈值。可考虑增大 timeoutSeconds,或优化被调用服务的响应速度。",suggestEditParam:"timeoutSeconds"},{pattern:/loopCondition|loop.*condition|condition.*false/i,category:"logic",title:"循环条件配置问题",explanation:"DO_WHILE 的 loopCondition 表达式可能无法正常求值。请检查条件表达式引用的变量是否正确。",suggestEditParam:"loopCondition"},{pattern:/expression.*error|script.*error|evaluator.*failed/i,category:"logic",title:"脚本表达式错误",explanation:"INLINE/LAMBDA 任务的脚本表达式执行时出错。请检查 expression 或 scriptExpression 的语法和逻辑。",suggestEditParam:"inputParameters"}];function rw(e,t){const r=t[e];if(!r)return[];const n=r.reasonForIncompletion||"";if(!n)return[];const s=[];for(const a of tw)a.pattern.test(n)&&s.push({category:a.category,title:a.title,explanation:a.explanation,suggestEditParam:a.suggestEditParam});return s.length===0&&n.length>0&&s.push({category:"logic",title:"执行异常",explanation:`任务执行失败,原因:${n.slice(0,200)}${n.length>200?"...":""}`}),s}function nw(e,t){const r=Object.values(e).map(f=>{const m=f.startTime&&f.endTime?f.endTime-f.startTime:void 0,y=Math.max(0,(f.attempts?.length??1)-1);return{taskRef:f.taskReferenceName,status:f.status,startTime:f.startTime,endTime:f.endTime,durationMs:m,retryCount:y,reasonForIncompletion:f.reasonForIncompletion,diagnostics:rw(f.taskReferenceName,e)}}).sort((f,m)=>(f.startTime??0)-(m.startTime??0)),n=["FAILED","FAILED_WITH_TERMINAL_ERROR","TIMED_OUT"],s=r.filter(f=>f.status==="COMPLETED"||f.status==="COMPLETED_WITH_ERRORS").length,a=r.filter(f=>n.includes(f.status)).length,i=r.filter(f=>f.status==="SKIPPED").length,l=r.flatMap(f=>[f.startTime,f.endTime]).filter(f=>!!f),c=l.length?Math.min(...l):0,d=(l.length?Math.max(...l):0)-c,p=t?.status,h=p==="FAILED"||p==="TIMED_OUT"||p==="TERMINATED"||a>0;return{totalTasks:r.length,completedTasks:s,failedTasks:a,skippedTasks:i,totalDurationMs:d,steps:r,hasFailed:h}}function vy(e){return e===void 0||e<0?"-":e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`}function ow(e){return{parameter:"⚙️",timeout:"⏱️",auth:"🔐",network:"🌐",logic:"🔧"}[e]??"⚠️"}function aw(e){return{parameter:"#f59e0b",timeout:"#8b5cf6",auth:"#ef4444",network:"#3b82f6",logic:"#10b981"}[e]??"#6b7280"}const ut={CREDENTIAL_KEY:/(token|secret|password|passwd|authorization|apikey|api_key|webhook|access_key|private_key|auth)/i,PRIVATE_IP:/\b(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})\b/,PHONE:/\b1[3-9]\d{9}\b/,EMAIL:/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/,CLOUD_RESOURCE_ID:/\b(i|d|s|vpc|vsw|sg|disk|snap)-[a-z0-9]{8,24}\b/i};function Hr(e,t,r,n=[]){if(!e||typeof e!="object")return n;for(const[s,a]of Object.entries(e)){if(s==="_actionId"||s==="actionName")continue;const i=`${r}.${s}`;if(a!=null)if(typeof a=="string"){if(ut.CREDENTIAL_KEY.test(s)&&a.length>5){n.push({id:`finding_${n.length+1}`,kind:"credential",path:i,taskRef:t,keyName:s,rawValue:a,maskedValue:"",suggestedVarName:`${s}_凭证密钥`,action:"variable"});continue}if(ut.PRIVATE_IP.test(a)){n.push({id:`finding_${n.length+1}`,kind:"network",path:i,taskRef:t,keyName:s,rawValue:a,maskedValue:a.replace(ut.PRIVATE_IP,"172.16.0.42"),suggestedVarName:`${s}_内网IP`,action:"mask"});continue}if(ut.PHONE.test(a)){n.push({id:`finding_${n.length+1}`,kind:"pii",path:i,taskRef:t,keyName:s,rawValue:a,maskedValue:a.replace(ut.PHONE,"13800138000"),suggestedVarName:"通知联系手机",action:"mask"});continue}if(ut.EMAIL.test(a)){n.push({id:`finding_${n.length+1}`,kind:"pii",path:i,taskRef:t,keyName:s,rawValue:a,maskedValue:a.replace(ut.EMAIL,"ops-notify@example.com"),suggestedVarName:"接收人邮箱",action:"mask"});continue}if(ut.CLOUD_RESOURCE_ID.test(a)&&!a.includes("${")){n.push({id:`finding_${n.length+1}`,kind:"resourceId",path:i,taskRef:t,keyName:s,rawValue:a,maskedValue:"i-bp18a9z3j42m09a",suggestedVarName:`${s}_云资源ID`,action:"variable"});continue}}else typeof a=="object"&&Hr(a,t,i,n)}return n}function ky(e){const t=[];return(e.tasks||[]).forEach((r,n)=>{const s=`tasks[${n}].inputParameters`;r.inputParameters&&Hr(r.inputParameters,r.taskReferenceName,s,t),r.httpRequest&&Hr(r.httpRequest,r.taskReferenceName,`tasks[${n}].httpRequest`,t)}),t}const Sy=/(debug|fallback|compensate|retry|temporary|temp|log_dump|tracer)/i;function wy(e,t){const r=[],n=e.tasks||[];for(const s of n){if(Sy.test(s.name)||Sy.test(s.taskReferenceName)){r.push({taskReferenceName:s.taskReferenceName,taskName:s.name,taskType:s.type,reason:"检测到任务名称含调试/单次补偿/临时特征,建议从公共通用模板中剔除。",selected:!0});continue}if(t){const a=t.tasks.find(i=>i.referenceTaskName===s.taskReferenceName);a&&a.status==="SKIPPED"&&r.push({taskReferenceName:s.taskReferenceName,taskName:s.name,taskType:s.type,reason:"该任务在生产历史执行中被判定跳过 (SKIPPED),通常属于特殊条件下的低频补偿分支。",selected:!1})}}return r}function _y(e,t){const r=structuredClone(e);return r.tasks=(r.tasks||[]).filter(n=>!t.has(n.taskReferenceName)),r}function Ur(e){if(!e||typeof e!="object")return e;if(Array.isArray(e))return e.map(Ur);const t={};for(const[r,n]of Object.entries(e))typeof n=="string"?/(token|secret|password|authorization|apikey)/i.test(r)&&n.length>5?t[r]="":/\b1[3-9]\d{9}\b/.test(n)?t[r]=n.replace(/\b1[3-9]\d{9}\b/,"13800138000"):/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/.test(n)?t[r]=n.replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/,"ops-notify@example.com"):/\b(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})\b/.test(n)?t[r]=n.replace(/\b(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})\b/,"172.16.0.42"):t[r]=n:typeof n=="object"&&n!==null?t[r]=Ur(n):t[r]=n;return t}function jy(e){const{instance:t,title:r,category:n,valueProposition:s,author:a}=e,i=t.workflowDefinition?structuredClone(t.workflowDefinition):{name:t.workflowName||"extracted_workflow",tasks:t.tasks.map(k=>k.workflowTask||{name:k.taskDefName||k.referenceTaskName,taskReferenceName:k.referenceTaskName,type:k.taskType||"SIMPLE",inputParameters:k.inputData})},l=ky(i),c=wy(i,t),u=new Set(c.filter(k=>k.selected).map(k=>k.taskReferenceName)),d=_y(i,u),p=[],h=structuredClone(d);for(const k of l)if(k.action==="variable"){const S=`var_${k.keyName}_${Date.now().toString(36).slice(-3)}`;p.push({key:S,label:k.suggestedVarName||k.keyName,type:typeof k.rawValue=="number"?"number":"text",defaultValue:k.maskedValue||k.rawValue,required:!0,bindings:[k.path]})}const f={};for(const k of t.tasks)k.outputData&&!u.has(k.referenceTaskName)&&(f[k.referenceTaskName]=Ur(k.outputData));const m={name:"生产真实运行数据脱敏样本",description:`基于实例 ${t.workflowId} 真实执行产物自动生成的高保真无害化数据集`,workflowInput:Ur(t.input||{}),taskOutputs:f},y=`tpl_extracted_${Date.now().toString(36)}`,v=r||`${i.name||"业务流"} (实战萃取模板)`,g=n||"ops",x=s||`源于真实执行实例 ${t.workflowId},已完成自动化脱敏与参数提取。`;return{template:{id:y,version:"1.0.0",title:v,category:g,icon:"💎",valueProposition:x,description:i.description||"由管理员从高频成功的生产运行记录中提炼而成的标准化黄金模板。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:25,typicalRunsPerWeek:10,popularityCount:1},difficulty:"intermediate",variables:p,definition:h,mockDataset:{scenarios:[m]},provenance:{source:"extracted",author:a||"Platform Admin",publishedAt:new Date().toISOString(),extractedFromWorkflowId:t.workflowId}},findings:l,prunedTasks:c,report:{extractedAt:new Date().toISOString(),totalTasksScanned:i.tasks?.length??0,sensitiveItemsCount:l.length,credentialsRedactedCount:l.filter(k=>k.kind==="credential").length,variablesCreatedCount:p.length}}}const Ty=[{id:"tpl_ecs_auto_provision",version:"1.0.0",title:"云主机自动化交付与环境配置",category:"compute",icon:"🚀",valueProposition:"一键完成主机创建、运行时环境自动化部署、基线快照与交付群通知,单次节省 35 分钟手工操作。",description:"面向新业务系统上线场景,自动根据指定规格在云平台创建云主机,通过远程免密脚本自动安装 Docker 与运行时依赖,并在验证就绪后自动归档基线快照向运维协同群发送交付卡片。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:35,typicalRunsPerWeek:12,popularityCount:1420},difficulty:"starter",variables:[{key:"instanceName",label:"新主机名称",type:"text",defaultValue:"app-service-prod",required:!0,placeholder:"例如: app-service-prod",bindings:["tasks[0].inputParameters.instanceName"]},{key:"regionId",label:"目标地域",type:"select",defaultValue:"cn-hangzhou",required:!0,options:[{label:"华东 1 (杭州)",value:"cn-hangzhou"},{label:"华北 2 (北京)",value:"cn-beijing"},{label:"华南 1 (深圳)",value:"cn-shenzhen"}],bindings:["tasks[0].inputParameters.regionId"]},{key:"notifyChannel",label:"交付通知渠道",type:"select",defaultValue:"webhook_dingtalk",required:!0,options:[{label:"钉钉运维机器人 (DingTalk)",value:"webhook_dingtalk"},{label:"企业微信机器人 (WeCom)",value:"webhook_wecom"},{label:"飞书群机器人 (Feishu/Lark)",value:"webhook_feishu"}],bindings:["tasks[4].inputParameters.channel"]}],definition:{name:"ecs_auto_provision_flow",description:"云主机全自动交付与运行时环境部署",version:1,tasks:[{name:"ecs_create_instance",taskReferenceName:"create_node",type:"HTTP",description:"创建计算型云主机",inputParameters:{_actionId:"ecs.create_instance",instanceName:"app-service-prod",regionId:"cn-hangzhou",instanceType:"ecs.c7.xlarge",imageId:"image-alilinux-3",systemDiskSize:120}},{name:"wait_for_network",taskReferenceName:"wait_network_ready",type:"WAIT",description:"等待网络与底层系统完成自检",inputParameters:{_actionId:"control.wait",duration:"10s"}},{name:"ecs_run_command",taskReferenceName:"install_runtime",type:"HTTP",description:"免密下发初始化命令: 安装 Docker 与守护进程",inputParameters:{_actionId:"ecs.run_command",instanceId:"${create_node.output.instanceId}",commandContent:"yum update -y && systemctl start docker && docker info",commandType:"RunShellScript",timeoutSeconds:60}},{name:"ecs_create_snapshot",taskReferenceName:"create_baseline_snap",type:"HTTP",description:"创建系统盘基线快照",inputParameters:{_actionId:"ecs.create_snapshot",instanceId:"${create_node.output.instanceId}",snapshotName:"baseline-init-snapshot",retentionDays:30}},{name:"send_operation_notification",taskReferenceName:"notify_devops",type:"EVENT",description:"向运维协同群发送交付卡片",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【交付就绪】新云主机已部署完成",content:"云主机 ${create_node.output.instanceId} 已创建并完成 Docker 运行时初始化与安全基线快照,内网IP: ${create_node.output.privateIp}。"}}]},mockDataset:{scenarios:[{name:"标准交付场景",description:"模拟一次完整的 4C8G 主机自动交付与脚本安装过程",workflowInput:{},taskOutputs:{create_node:{instanceId:"i-bp18a9z3j42m09a",instanceName:"app-service-prod",privateIp:"172.16.0.42",status:"RUNNING",createdAt:"2026-10-20T14:00:00Z"},wait_network_ready:{waited:!0,duration:"10s"},install_runtime:{exitCode:0,status:"SUCCESS",output:"Docker version 24.0.5 installed and running"},create_baseline_snap:{snapshotId:"s-bp199042",status:"ACCOMPLISHED"},notify_devops:{messageId:"msg-9921",sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_daily_snapshot_backup",version:"1.0.0",title:"核心云主机每日定时快照备份",category:"security",icon:"💾",valueProposition:"每日自动化创建增量快照并自动清理超期备份,防勒索防误删,单次节省 15 分钟人工检查。",description:"自动对生产数据库或核心应用所在的云主机创建带时间戳的增量快照,保留 14 天自动循环轮转,并在完成备份后发送健康汇报。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:15,typicalRunsPerWeek:7,popularityCount:2310},difficulty:"starter",variables:[{key:"instanceId",label:"目标云主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,placeholder:"例如: i-bp18a9z3j42m09a",bindings:["tasks[0].inputParameters.instanceId","tasks[1].inputParameters.instanceId"]},{key:"retentionDays",label:"快照保留天数",type:"number",defaultValue:14,required:!0,bindings:["tasks[1].inputParameters.retentionDays"]}],definition:{name:"ecs_daily_snapshot_backup_flow",description:"核心云主机每日定时增量备份",version:1,tasks:[{name:"ecs_query_instance",taskReferenceName:"check_host",type:"HTTP",description:"检查主机运行健康状态",inputParameters:{_actionId:"ecs.query_instance",instanceId:"i-bp18a9z3j42m09a"}},{name:"ecs_create_snapshot",taskReferenceName:"create_daily_snap",type:"HTTP",description:"执行云盘增量备份快照",inputParameters:{_actionId:"ecs.create_snapshot",instanceId:"i-bp18a9z3j42m09a",snapshotName:"auto-daily-backup",retentionDays:14}},{name:"send_operation_notification",taskReferenceName:"notify_result",type:"EVENT",description:"发送备份执行简报",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【快照备份成功】每日例行备份完成",content:"云主机 ${check_host.output.instanceId} (${check_host.output.status}) 增量快照已生成,快照ID: ${create_daily_snap.output.snapshotId}。"}}]},mockDataset:{scenarios:[{name:"定时备份成功场景",workflowInput:{},taskOutputs:{check_host:{instanceId:"i-bp18a9z3j42m09a",status:"RUNNING",osName:"Alibaba Cloud Linux 3"},create_daily_snap:{snapshotId:"s-bp188201",snapshotName:"auto-daily-backup",status:"ACCOMPLISHED"},notify_result:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_high_load_autoscale",version:"1.0.0",title:"主机高负载告警与在线自动升配",category:"ops",icon:"⚡",valueProposition:"检测到 CPU 利用率超标时自动发起升配流程,内置人工审批安全网,秒级在线完成 4C8G -> 8C16G 弹性扩容。",description:"自动轮询主机性能指标,一旦触发瓶颈阈值,系统即刻生成规格变更提案并向架构师推送一键审批卡片,审批后自动在线变配,保障大促不卡顿。",connectors:["cloud_host","dingtalk","approval"],roi:{minutesSavedPerRun:40,typicalRunsPerWeek:5,popularityCount:980},difficulty:"intermediate",variables:[{key:"instanceId",label:"监控主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[2].inputParameters.instanceId"]},{key:"targetSpec",label:"目标扩容规格",type:"select",defaultValue:"ecs.c7.2xlarge",required:!0,options:[{label:"提升至 计算型 8C16G (ecs.c7.2xlarge)",value:"ecs.c7.2xlarge"},{label:"提升至 内存型 8C32G (ecs.r7.2xlarge)",value:"ecs.r7.2xlarge"}],bindings:["tasks[2].inputParameters.targetSpec"]}],definition:{name:"ecs_high_load_autoscale_flow",description:"云主机高负载自动熔断与在线变配",version:1,tasks:[{name:"ecs_get_monitor_metrics",taskReferenceName:"fetch_metrics",type:"HTTP",description:"采集 CPU 与内存利用率",inputParameters:{_actionId:"ecs.get_monitor_metrics",instanceId:"i-bp18a9z3j42m09a",periodSeconds:60}},{name:"human_operation_approval",taskReferenceName:"approve_spec_upgrade",type:"HUMAN",description:"高危硬件配置变更审批",inputParameters:{_actionId:"human.approval",assigneeRole:"architect",promptMessage:"云主机 ${fetch_metrics.output.instanceId} 当前 CPU 利用率达到 ${fetch_metrics.output.cpuUsagePercent}%,申请在线升配。",timeoutMinutes:30}},{name:"ecs_modify_spec",taskReferenceName:"apply_spec_change",type:"HTTP",description:"执行在线规格扩容变更",inputParameters:{_actionId:"ecs.modify_spec",instanceId:"i-bp18a9z3j42m09a",targetSpec:"ecs.c7.2xlarge"}},{name:"send_operation_notification",taskReferenceName:"notify_upgrade_done",type:"EVENT",description:"发送变配完成汇报",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【升配成功】云主机硬件规格已在线提升",content:"云主机 ${fetch_metrics.output.instanceId} 已成功从 ${apply_spec_change.output.oldSpec} 变更为 ${apply_spec_change.output.newSpec}。"}}]},mockDataset:{scenarios:[{name:"高负载升配成功场景",workflowInput:{},taskOutputs:{fetch_metrics:{instanceId:"i-bp18a9z3j42m09a",cpuUsagePercent:88.5,isOverloaded:!0},approve_spec_upgrade:{approved:!0,reviewer:"architect@internal.cloud"},apply_spec_change:{oldSpec:"ecs.c7.xlarge",newSpec:"ecs.c7.2xlarge",status:"SUCCESS"},notify_upgrade_done:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_vulnerability_patch",version:"1.0.0",title:"生产主机一键漏洞巡检与修复",category:"security",icon:"🛡️",valueProposition:"修补前自动创建保护快照,免密下发 OS 补丁脚本,带审批确认软重启,消除系统 CVE 高危隐患。",description:"解决企业 Linux 主机补丁升级流程繁琐、缺少回滚预案的问题。流程自动先对磁盘建立防护快照,执行补丁更新后通知责任人确认软重启。",connectors:["cloud_host","dingtalk","approval"],roi:{minutesSavedPerRun:45,typicalRunsPerWeek:4,popularityCount:760},difficulty:"intermediate",variables:[{key:"instanceId",label:"目标主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[1].inputParameters.instanceId","tasks[3].inputParameters.instanceId"]}],definition:{name:"ecs_vulnerability_patch_flow",description:"带快照防护的操作系统漏洞巡检与修复流程",version:1,tasks:[{name:"ecs_create_snapshot",taskReferenceName:"patch_safeguard_snap",type:"HTTP",description:"建立补丁前安全还原快照",inputParameters:{_actionId:"ecs.create_snapshot",instanceId:"i-bp18a9z3j42m09a",snapshotName:"pre-patch-safeguard",retentionDays:7}},{name:"ecs_run_command",taskReferenceName:"apply_cve_patches",type:"HTTP",description:"下发漏洞热补丁脚本",inputParameters:{_actionId:"ecs.run_command",instanceId:"i-bp18a9z3j42m09a",commandContent:"yum update-minimal --security -y",commandType:"RunShellScript",timeoutSeconds:120}},{name:"human_operation_approval",taskReferenceName:"confirm_soft_reboot",type:"HUMAN",description:"责任人确认重启",inputParameters:{_actionId:"human.approval",assigneeRole:"devops_lead",promptMessage:"补丁更新已完成,请确认是否即刻安排主机软重启以使内核生效。",timeoutMinutes:60}},{name:"ecs_restart_instance",taskReferenceName:"reboot_host",type:"HTTP",description:"软重启生效补丁",inputParameters:{_actionId:"ecs.restart_instance",instanceId:"i-bp18a9z3j42m09a",forceRestart:!1}},{name:"send_operation_notification",taskReferenceName:"report_patch_result",type:"EVENT",description:"发送合规汇报",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【补丁更新成功】系统漏洞修复完成",content:"云主机 ${patch_safeguard_snap.output.instanceId} 补丁更新完成,主机已完成重启并恢复在线。"}}]},mockDataset:{scenarios:[{name:"补丁升级全流程演示",workflowInput:{},taskOutputs:{patch_safeguard_snap:{snapshotId:"s-bp1904",status:"ACCOMPLISHED"},apply_cve_patches:{exitCode:0,output:"3 security packages updated",status:"SUCCESS"},confirm_soft_reboot:{approved:!0,reviewer:"devops_lead@internal.cloud"},reboot_host:{status:"RUNNING"},report_patch_result:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_night_idle_shutdown",version:"1.0.0",title:"非生产环境夜间定时关机降本",category:"cost",icon:"🌙",valueProposition:"工作日 21:00 自动停止闲置研发测试主机,次日晨自动开机,降低约 65% 计算资源账单。",description:"自动在夜间巡检开发测试集群,若无活跃计算任务,则下发优雅安全关机指令,并在协同群汇报当晚关机台数与预计节约的算力金额。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:20,typicalRunsPerWeek:5,popularityCount:3100},difficulty:"starter",variables:[{key:"instanceId",label:"测试环境主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[1].inputParameters.instanceId"]},{key:"forceStop",label:"超时是否强制关机",type:"boolean",defaultValue:!1,bindings:["tasks[1].inputParameters.forceStop"]}],definition:{name:"ecs_night_idle_shutdown_flow",description:"测试环境夜间自动关机降本",version:1,tasks:[{name:"ecs_get_monitor_metrics",taskReferenceName:"check_idle_state",type:"HTTP",description:"核实主机是否处于闲置低负载",inputParameters:{_actionId:"ecs.get_monitor_metrics",instanceId:"i-bp18a9z3j42m09a",periodSeconds:300}},{name:"ecs_stop_instance",taskReferenceName:"shutdown_host",type:"HTTP",description:"执行优雅关机",inputParameters:{_actionId:"ecs.stop_instance",instanceId:"i-bp18a9z3j42m09a",forceStop:!1}},{name:"send_operation_notification",taskReferenceName:"notify_cost_saving",type:"EVENT",description:"发送夜间节能降本简报",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【夜间节能】测试主机已自动进入休眠",content:"测试主机 ${check_idle_state.output.instanceId} (CPU ${check_idle_state.output.cpuUsagePercent}%) 已于 21:00 完成关机,预计今夜节约 11 小时按量费用。"}}]},mockDataset:{scenarios:[{name:"闲置关机场景",workflowInput:{},taskOutputs:{check_idle_state:{instanceId:"i-bp18a9z3j42m09a",cpuUsagePercent:2.1,isOverloaded:!1},shutdown_host:{status:"STOPPED"},notify_cost_saving:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_morning_boot",version:"1.0.0",title:"测试环境工作日早晨定时自动开机",category:"cost",icon:"🌅",valueProposition:"工作日 08:30 自动唤醒测试主机,自检网络并广播就绪通知,研发开工即可联调无需等待。",description:"与夜间关机模板形成完整的节能闭环,在工作日上班前 30 分钟定时批量启动主机,校验网络联通性后发送早报。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:15,typicalRunsPerWeek:5,popularityCount:2890},difficulty:"starter",variables:[{key:"instanceId",label:"测试环境主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[2].inputParameters.instanceId"]}],definition:{name:"ecs_morning_boot_flow",description:"测试环境早间自动唤醒开机",version:1,tasks:[{name:"ecs_start_instance",taskReferenceName:"boot_host",type:"HTTP",description:"执行主机开机启动",inputParameters:{_actionId:"ecs.start_instance",instanceId:"i-bp18a9z3j42m09a"}},{name:"wait_boot_ready",taskReferenceName:"wait_boot",type:"WAIT",description:"等待操作系统内核引导就绪",inputParameters:{_actionId:"control.wait",duration:"10s"}},{name:"ecs_query_instance",taskReferenceName:"verify_network",type:"HTTP",description:"核实网络与运行状态",inputParameters:{_actionId:"ecs.query_instance",instanceId:"i-bp18a9z3j42m09a"}},{name:"send_operation_notification",taskReferenceName:"notify_team_ready",type:"EVENT",description:"向研发测试群发送环境就绪广播",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【环境就绪】测试云主机已唤醒开机",content:"测试主机 ${verify_network.output.instanceId} 已启动 (${verify_network.output.status}),内网IP: ${verify_network.output.privateIp},开发人员可正常开始联调。"}}]},mockDataset:{scenarios:[{name:"晨间开机唤醒演示",workflowInput:{},taskOutputs:{boot_host:{instanceId:"i-bp18a9z3j42m09a",currentStatus:"STARTING"},wait_boot:{waited:!0},verify_network:{instanceId:"i-bp18a9z3j42m09a",status:"RUNNING",privateIp:"172.16.0.42"},notify_team_ready:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_disk_expansion",version:"1.0.0",title:"磁盘容量告警与在线自动扩容",category:"ops",icon:"💽",valueProposition:"磁盘利用率超 85% 自动快照并在线扩充云盘容量,免停机扩展文件系统,杜绝业务写爆宕机。",description:"自动对磁盘快满的主机执行保护性快照,随后免停机远程下发 growpart 与 resize2fs 脚本刷新空间,最后在运维群反馈扩容结果。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:30,typicalRunsPerWeek:6,popularityCount:1650},difficulty:"intermediate",variables:[{key:"instanceId",label:"目标主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[1].inputParameters.instanceId","tasks[2].inputParameters.instanceId"]}],definition:{name:"ecs_disk_expansion_flow",description:"云主机磁盘在线自动扩容与自愈",version:1,tasks:[{name:"ecs_get_monitor_metrics",taskReferenceName:"check_disk_usage",type:"HTTP",description:"检测磁盘利用率",inputParameters:{_actionId:"ecs.get_monitor_metrics",instanceId:"i-bp18a9z3j42m09a",periodSeconds:60}},{name:"ecs_create_snapshot",taskReferenceName:"pre_expand_snap",type:"HTTP",description:"扩容前创建磁盘保护快照",inputParameters:{_actionId:"ecs.create_snapshot",instanceId:"i-bp18a9z3j42m09a",snapshotName:"pre-disk-expansion",retentionDays:7}},{name:"ecs_run_command",taskReferenceName:"grow_filesystem",type:"HTTP",description:"在线扩展分区与文件系统",inputParameters:{_actionId:"ecs.run_command",instanceId:"i-bp18a9z3j42m09a",commandContent:"growpart /dev/vda 1 && resize2fs /dev/vda1 && df -h",commandType:"RunShellScript",timeoutSeconds:60}},{name:"send_operation_notification",taskReferenceName:"notify_expand_done",type:"EVENT",description:"发送扩容完成通知",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【自愈成功】云盘空间已在线扩容",content:"云主机 ${check_disk_usage.output.instanceId} 磁盘扩容完毕,当前文件系统状态正常。"}}]},mockDataset:{scenarios:[{name:"磁盘扩容自愈演示",workflowInput:{},taskOutputs:{check_disk_usage:{instanceId:"i-bp18a9z3j42m09a",diskUsagePercent:89.2},pre_expand_snap:{snapshotId:"s-bp1449",status:"ACCOMPLISHED"},grow_filesystem:{exitCode:0,output:"CHANGED: partition=1, size expanded to 200GB"},notify_expand_done:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_emergency_isolation",version:"1.0.0",title:"突发入侵应急响应与快照取证",category:"security",icon:"🚨",valueProposition:"发生高危网络入侵威胁时,秒级冻结证据快照并强制关机隔离,将安全暴露面降至最低。",description:"面对勒索病毒、WebShell 或异常爆破入侵时,自动对受害主机创建取证快照保存现场内存与日志,随后强制关机切断危害,并向 SecOps 安全小组发送紧急红色通知。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:60,typicalRunsPerWeek:1,popularityCount:890},difficulty:"advanced",variables:[{key:"instanceId",label:"受害云主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[1].inputParameters.instanceId"]}],definition:{name:"ecs_emergency_isolation_flow",description:"安全事件突发应急取证与快速隔离",version:1,tasks:[{name:"ecs_create_snapshot",taskReferenceName:"forensics_snapshot",type:"HTTP",description:"紧急创建现场取证快照",inputParameters:{_actionId:"ecs.create_snapshot",instanceId:"i-bp18a9z3j42m09a",snapshotName:"security-forensics-evidence",retentionDays:90}},{name:"ecs_stop_instance",taskReferenceName:"isolate_victim_node",type:"HTTP",description:"强制切断关机隔离",inputParameters:{_actionId:"ecs.stop_instance",instanceId:"i-bp18a9z3j42m09a",forceStop:!0}},{name:"send_operation_notification",taskReferenceName:"alert_secops_incident",type:"EVENT",description:"发送安全应急处置最高级别预警",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"🚨【紧急安全通报】入侵主机已隔离取证",content:"受害主机 ${forensics_snapshot.output.instanceId} 已完成现场留证快照 (${forensics_snapshot.output.snapshotId}) 并被强制关机隔离,请 SecOps 立即启动应急调查。"}}]},mockDataset:{scenarios:[{name:"应急阻断演示",workflowInput:{},taskOutputs:{forensics_snapshot:{snapshotId:"s-forensics-911",status:"ACCOMPLISHED"},isolate_victim_node:{status:"STOPPED",forceStop:!0},alert_secops_incident:{sentStatus:"DELIVERED"}}}]}}];class Iy{templates=new Map;constructor(t=[]){this.registerAll(t)}register(t){this.templates.set(t.id,t)}registerAll(t){for(const r of t)this.register(r)}getAllTemplates(){return Array.from(this.templates.values())}getTemplateById(t){return this.templates.get(t)}search(t,r="all"){let n=this.getAllTemplates();if(r&&r!=="all"&&(n=n.filter(s=>s.category===r)),t&&t.trim()){const s=t.toLowerCase().trim();n=n.filter(a=>a.title.toLowerCase().includes(s)||a.valueProposition.toLowerCase().includes(s)||a.description.toLowerCase().includes(s))}return n}}const gc=new Iy(Ty),Cy=({isOpen:e,instance:t,onClose:r,onPublished:n})=>{const{theme:s,themeColor:a}=oe(ke(N=>({theme:N.theme,themeColor:N.themeColor}))),i=I.useMemo(()=>jy({instance:t,title:`${t.workflowName||"云平台工作流"} (实战提炼)`,category:"ops",valueProposition:`基于实例 ${t.workflowId} 的成功运行萃取,已通过自动化脱敏与参数提取。`,author:"系统管理员"}),[t]),[l,c]=I.useState(i.template.title),[u,d]=I.useState(i.template.category),[p,h]=I.useState(i.template.valueProposition),[f,m]=I.useState(i.template.roi.minutesSavedPerRun),[y,v]=I.useState(()=>{const N={};for(const w of i.prunedTasks)N[w.taskReferenceName]=w.selected;return N}),[g,x]=I.useState(!1),[b,k]=I.useState(!1);if(!e||typeof document>"u")return null;const S=N=>{v(w=>({...w,[N]:!w[N]}))},C=()=>{x(!0);try{const N={...i.template,title:l,category:u,valueProposition:p,roi:{...i.template.roi,minutesSavedPerRun:f}};gc.register(N),n&&n(N),k(!0),setTimeout(()=>{r()},1500)}catch(N){alert(`发布模板出错: ${N.message}`)}finally{x(!1)}},T=i.findings;return Ge.createPortal(o.jsx("div",{"data-mode":s,"data-brand":a,style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0, 0, 0, 0.72)",backdropFilter:"blur(6px)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center",padding:24,fontFamily:"inherit"},onClick:r,children:o.jsxs("div",{onClick:N=>N.stopPropagation(),style:{width:980,maxWidth:"calc(100vw - 48px)",height:720,maxHeight:"calc(100vh - 48px)",background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",borderRadius:14,boxShadow:"0 28px 72px rgba(0, 0, 0, 0.5)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"14px 20px",borderBottom:"1px solid var(--border-primary, rgba(255, 255, 255, 0.1))",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bg-primary, #0f172a)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{fontSize:22},children:"🛠️"}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:15,color:"var(--text-primary, #f8fafc)"},children:"生产工作流一键提炼与脱敏工作台 (管理员)"}),o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted, #94a3b8)"},children:["基于执行实例 #",t.workflowId," 自动识别敏感信息并生成高保真模板"]})]})]}),o.jsx("button",{onClick:r,style:{background:"none",border:"none",color:"var(--text-muted, #94a3b8)",cursor:"pointer",fontSize:16},children:"✕"})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"18px 20px",display:"grid",gridTemplateColumns:"1fr 1.2fr 1fr",gap:16},children:[o.jsxs("div",{style:{background:"var(--bg-primary, #0f172a)",borderRadius:10,border:"1px solid var(--border-primary, rgba(255,255,255,0.1))",padding:14,display:"flex",flexDirection:"column",gap:10},children:[o.jsx("div",{style:{fontWeight:600,fontSize:13,color:"var(--text-primary, #f8fafc)"},children:"1. 骨架拓扑剪枝建议"}),o.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #94a3b8)"},children:"自动识别并建议剔除特定的临时调试、重试与低频孤立分支:"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,marginTop:4},children:i.template.definition.tasks?.map((N,w)=>{const _=!!y[N.taskReferenceName];return o.jsxs("div",{style:{padding:"8px 10px",borderRadius:6,background:_?"rgba(239, 68, 68, 0.08)":"rgba(255,255,255,0.03)",border:`1px solid ${_?"rgba(239, 68, 68, 0.25)":"rgba(255,255,255,0.08)"}`,display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:12,opacity:_?.6:1},children:[o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsxs("span",{style:{color:"var(--color-accent, #3b82f6)",fontWeight:600},children:["#",w+1]}),o.jsx("span",{style:{color:_?"#fca5a5":"var(--text-primary, #f8fafc)"},children:N.description||N.name})]}),o.jsx("div",{style:{fontSize:10,color:"var(--text-muted, #94a3b8)",fontFamily:"monospace"},children:N.taskReferenceName})]}),o.jsx("button",{onClick:()=>S(N.taskReferenceName),style:{padding:"2px 6px",borderRadius:4,background:_?"rgba(239, 68, 68, 0.2)":"rgba(255,255,255,0.08)",border:"none",color:_?"#f87171":"var(--text-muted, #94a3b8)",fontSize:11,cursor:"pointer"},children:_?"已剪枝剔除":"保留"})]},N.taskReferenceName)})})]}),o.jsxs("div",{style:{background:"var(--bg-primary, #0f172a)",borderRadius:10,border:"1px solid var(--border-primary, rgba(255,255,255,0.1))",padding:14,display:"flex",flexDirection:"column",gap:10},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsx("div",{style:{fontWeight:600,fontSize:13,color:"var(--text-primary, #f8fafc)"},children:"2. 敏感项扫描与变量提取"}),o.jsxs("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"rgba(16, 185, 129, 0.15)",color:"#34d399",fontWeight:600},children:["已扫描 ",T.length," 项"]})]}),o.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #94a3b8)"},children:"命中规则的生产密钥已强制置空,真实 IP/ID 推荐转为填空变量:"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,marginTop:4},children:T.length===0?o.jsx("div",{style:{padding:"24px 12px",textAlign:"center",color:"var(--text-muted, #94a3b8)",fontSize:12},children:"✓ 未发现任何硬编码的高危凭据或敏感信息"}):T.map(N=>o.jsxs("div",{style:{padding:"8px 10px",borderRadius:6,background:"rgba(255,255,255,0.03)",border:"1px solid var(--border-primary, rgba(255,255,255,0.08))",display:"flex",flexDirection:"column",gap:4,fontSize:11},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsx("span",{style:{padding:"1px 5px",borderRadius:3,fontSize:10,fontWeight:600,background:N.kind==="credential"?"rgba(239, 68, 68, 0.2)":N.kind==="network"?"rgba(59, 130, 246, 0.2)":"rgba(245, 158, 11, 0.2)",color:N.kind==="credential"?"#f87171":N.kind==="network"?"#60a5fa":"#fbbf24"},children:N.kind==="credential"?"🔑 密钥凭据":N.kind==="network"?"🌐 内网地址":N.kind==="pii"?"📱 个人隐私":"🖥️ 云资源ID"}),o.jsxs("span",{style:{color:"var(--text-muted, #94a3b8)"},children:["建议处理: ",N.action==="variable"?"提取为向导变量":"自动掩码脱敏"]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginTop:2},children:[o.jsx("span",{style:{color:"var(--text-secondary, #b0bec5)"},children:"字段:"}),o.jsx("span",{style:{color:"var(--text-primary, #f8fafc)",fontFamily:"monospace"},children:N.keyName})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[o.jsx("span",{style:{color:"var(--text-secondary, #b0bec5)"},children:"脱敏后:"}),o.jsx("span",{style:{color:"#34d399",fontFamily:"monospace"},children:N.maskedValue?String(N.maskedValue):"(强制置空并由用户填入)"})]})]},N.id))})]}),o.jsxs("div",{style:{background:"var(--bg-primary, #0f172a)",borderRadius:10,border:"1px solid var(--border-primary, rgba(255,255,255,0.1))",padding:14,display:"flex",flexDirection:"column",gap:12},children:[o.jsx("div",{style:{fontWeight:600,fontSize:13,color:"var(--text-primary, #f8fafc)"},children:"3. 模板货架信息配置"}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[o.jsx("label",{style:{fontSize:12,color:"var(--text-secondary, #b0bec5)"},children:"模板中文标题"}),o.jsx("input",{type:"text",value:l,onChange:N=>c(N.target.value),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary, #1e293b)",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-primary, #f8fafc)",fontSize:12,outline:"none"}})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[o.jsx("label",{style:{fontSize:12,color:"var(--text-secondary, #b0bec5)"},children:"业务分类"}),o.jsxs("select",{value:u,onChange:N=>d(N.target.value),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary, #1e293b)",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-primary, #f8fafc)",fontSize:12,outline:"none"},children:[o.jsx("option",{value:"compute",children:"🖥️ 交付与计算"}),o.jsx("option",{value:"security",children:"💾 安全与容灾"}),o.jsx("option",{value:"ops",children:"⚡ 运维与自愈"}),o.jsx("option",{value:"cost",children:"🌙 节能与降本"})]})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[o.jsx("label",{style:{fontSize:12,color:"var(--text-secondary, #b0bec5)"},children:"一句话业务价值"}),o.jsx("textarea",{rows:2,value:p,onChange:N=>h(N.target.value),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary, #1e293b)",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-primary, #f8fafc)",fontSize:12,outline:"none",resize:"none"}})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[o.jsx("label",{style:{fontSize:12,color:"var(--text-secondary, #b0bec5)"},children:"单次预估节省 (分钟)"}),o.jsx("input",{type:"number",value:f,onChange:N=>m(Number(N.target.value)),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary, #1e293b)",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-primary, #f8fafc)",fontSize:12,outline:"none"}})]}),o.jsx("div",{style:{marginTop:6,padding:"8px 10px",borderRadius:6,background:"rgba(16, 185, 129, 0.08)",border:"1px solid rgba(16, 185, 129, 0.2)",fontSize:11,color:"#34d399"},children:"✓ 已自动从该运行实例生成无害化保真沙盒数据集,上架后支持其他用户零授权一键试跑。"})]})]}),o.jsxs("div",{style:{padding:"12px 20px",borderTop:"1px solid var(--border-primary, rgba(255, 255, 255, 0.1))",background:"var(--bg-primary, #0f172a)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{fontSize:12,color:"var(--text-muted, #94a3b8)"},children:["审计报告: 扫描 ",i.report.totalTasksScanned," 个任务 · 脱敏凭证"," ",i.report.credentialsRedactedCount," 项 · 生成模板变量"," ",i.report.variablesCreatedCount," 项"]}),o.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[b&&o.jsx("span",{style:{fontSize:12,color:"#34d399",fontWeight:600},children:"✓ 已成功上架到模板中心!"}),o.jsx("button",{onClick:r,style:{padding:"6px 14px",borderRadius:6,background:"transparent",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-secondary, #b0bec5)",fontSize:12,cursor:"pointer"},children:"取消"}),o.jsxs("button",{onClick:C,disabled:g||b,style:{padding:"6px 18px",borderRadius:6,background:"var(--color-accent, #3b82f6)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:g||b?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[o.jsx("span",{children:"🚀"}),o.jsx("span",{children:g?"发布中...":"注册并发布到模板中心"})]})]})]})]})}),document.body)},Ny={COMPLETED:"完成",COMPLETED_WITH_ERRORS:"完成(含错误)",FAILED:"失败",FAILED_WITH_TERMINAL_ERROR:"终态失败",IN_PROGRESS:"执行中",SCHEDULED:"等待中",TIMED_OUT:"超时",SKIPPED:"跳过",CANCELED:"已取消"},Ey={COMPLETED:"var(--status-completed)",COMPLETED_WITH_ERRORS:"var(--status-completed)",FAILED:"var(--status-failed)",FAILED_WITH_TERMINAL_ERROR:"var(--status-failed)",IN_PROGRESS:"var(--status-running)",SCHEDULED:"var(--status-scheduled)",TIMED_OUT:"var(--status-failed)",SKIPPED:"var(--status-skipped, #6b7280)",CANCELED:"var(--status-failed)"},sw=()=>{const[e,t]=I.useState(!1),{executionData:r,workflowInstance:n,showAnalysisPanel:s,setShowAnalysisPanel:a,switchToEditAndFocusParam:i,selectTaskAction:l,taskMap:c}=oe(ke(b=>({executionData:b.executionData,workflowInstance:b.workflowInstance,showAnalysisPanel:b.showAnalysisPanel,setShowAnalysisPanel:b.setShowAnalysisPanel,switchToEditAndFocusParam:b.switchToEditAndFocusParam,selectTaskAction:b.selectTaskAction,taskMap:b.taskMap}))),u=I.useMemo(()=>r?nw(r,n??null):null,[r,n]);if(!s||!u)return null;const{totalTasks:d,completedTasks:p,failedTasks:h,skippedTasks:f,totalDurationMs:m,steps:y}=u,v=d>0?Math.round(p/d*100):0,g=n?.status,x=g?Ey[g]??"var(--text-secondary)":"var(--text-secondary)";return o.jsxs("div",{className:"esp-panel glass-panel",children:[o.jsxs("div",{className:"esp-header",children:[o.jsxs("div",{className:"esp-title",children:[o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),o.jsx("path",{d:"M5 8h6M5 5h3M5 11h4"})]}),"执行分析"]}),g&&o.jsx("span",{className:"esp-wf-status",style:{color:x},children:Ny[g]??g}),n&&o.jsxs("button",{onClick:()=>t(!0),style:{padding:"3px 8px",borderRadius:5,background:"color-mix(in srgb, var(--color-brand-blue) 18%, transparent)",border:"1px solid color-mix(in srgb, var(--color-brand-blue) 40%, transparent)",color:"var(--color-brand-blue)",fontSize:11,cursor:"pointer",fontWeight:600,display:"inline-flex",alignItems:"center",gap:4,marginLeft:"auto",marginRight:6},title:"将本次执行实例脱敏并提炼为公共标准化模板",children:[o.jsx("span",{children:"🛠️"}),o.jsx("span",{children:"提取为模板"})]}),o.jsx("button",{className:"esp-close",onClick:()=>a(!1),children:"✕"})]}),o.jsxs("div",{className:"esp-content",children:[o.jsxs("div",{className:"esp-overview",children:[o.jsxs("div",{className:"esp-card",children:[o.jsx("span",{className:"esp-card-value",children:d}),o.jsx("span",{className:"esp-card-label",children:"总任务数"})]}),o.jsxs("div",{className:"esp-card esp-card-success",children:[o.jsx("span",{className:"esp-card-value",style:{color:"var(--status-completed)"},children:p}),o.jsx("span",{className:"esp-card-label",children:"已完成"})]}),o.jsxs("div",{className:"esp-card esp-card-failed",children:[o.jsx("span",{className:"esp-card-value",style:{color:h>0?"var(--status-failed)":"var(--text-secondary)"},children:h}),o.jsx("span",{className:"esp-card-label",children:"失败"})]}),o.jsxs("div",{className:"esp-card",children:[o.jsx("span",{className:"esp-card-value",children:vy(m)}),o.jsx("span",{className:"esp-card-label",children:"总耗时"})]})]}),o.jsx("div",{className:"esp-progress-bar",children:o.jsx("div",{className:"esp-progress-fill",style:{width:`${v}%`,background:h>0?"var(--status-failed)":"var(--status-completed)"},title:`成功率 ${v}%`})}),o.jsxs("div",{className:"esp-progress-label",children:[v,"% 成功率",f>0?`,${f} 个任务已跳过`:""]}),y.filter(b=>b.diagnostics.length>0).map(b=>o.jsxs("div",{className:"esp-diagnostic-card",children:[o.jsxs("div",{className:"esp-diag-task-ref",children:[o.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"currentColor",style:{color:"var(--status-failed)",flexShrink:0},children:o.jsx("path",{d:"M8 1a7 7 0 100 14A7 7 0 008 1zm-.75 4a.75.75 0 011.5 0v3.5a.75.75 0 01-1.5 0V5zm.75 7a1 1 0 110-2 1 1 0 010 2z"})}),b.taskRef]}),b.diagnostics.map((k,S)=>o.jsxs("div",{className:"esp-diag-item",style:{borderLeftColor:aw(k.category)},children:[o.jsxs("div",{className:"esp-diag-title",children:[o.jsx("span",{children:ow(k.category)}),k.title]}),o.jsx("p",{className:"esp-diag-explanation",children:k.explanation}),o.jsxs("button",{className:"esp-fix-btn",onClick:()=>i(b.taskRef,k.suggestEditParam),children:["去修复",o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",children:o.jsx("path",{d:"M5 8h6M9 5l3 3-3 3"})})]})]},S))]},b.taskRef)),o.jsx("div",{className:"esp-section-label",children:"步骤执行时序"}),o.jsxs("div",{className:"esp-steps-table",children:[o.jsxs("div",{className:"esp-steps-header",children:[o.jsx("span",{children:"#"}),o.jsx("span",{children:"任务引用名"}),o.jsx("span",{children:"状态"}),o.jsx("span",{children:"耗时"}),o.jsx("span",{children:"重试"})]}),y.map((b,k)=>{const S=Ey[b.status]??"var(--text-secondary)",C=c[b.taskRef];return o.jsxs("button",{className:"esp-step-row",onClick:()=>C&&l(C,!0),title:b.reasonForIncompletion||b.taskRef,children:[o.jsx("span",{className:"esp-step-idx",children:k+1}),o.jsx("span",{className:"esp-step-ref",children:b.taskRef}),o.jsxs("span",{className:"esp-step-status",style:{color:S},children:[o.jsx("span",{className:"esp-status-dot",style:{background:S}}),Ny[b.status]??b.status]}),o.jsx("span",{className:"esp-step-duration",children:vy(b.durationMs)}),o.jsx("span",{className:"esp-step-retry",style:{color:b.retryCount>0?"var(--status-failed)":"var(--text-secondary)"},children:b.retryCount>0?`${b.retryCount}次`:"-"})]},b.taskRef)})]})]}),e&&n&&o.jsx(Cy,{isOpen:e,instance:n,onClose:()=>t(!1),onPublished:()=>{console.log("[ExecutionSummaryPanel] 模板已成功发布到场景中心")}})]})},Ry=[{id:"ecs.create_instance",name:"创建云主机",category:"compute",icon:"🖥️",description:"在指定可用区根据镜像与规格创建并初始化一台新的云主机实例",connector:"cloud_host",riskLevel:"safe",fields:[{key:"regionId",label:"所属地域",type:"select",required:!0,defaultValue:"cn-hangzhou",options:[{label:"华东 1 (杭州)",value:"cn-hangzhou"},{label:"华北 2 (北京)",value:"cn-beijing"},{label:"华南 1 (深圳)",value:"cn-shenzhen"},{label:"亚太东南 1 (新加坡)",value:"ap-southeast-1"}],acceptsPills:!0},{key:"instanceType",label:"计算规格",type:"select",required:!0,defaultValue:"ecs.c7.xlarge",options:[{label:"通用型 2C4G (ecs.g7.large)",value:"ecs.g7.large"},{label:"计算型 4C8G (ecs.c7.xlarge)",value:"ecs.c7.xlarge"},{label:"内存型 4C16G (ecs.r7.xlarge)",value:"ecs.r7.xlarge"},{label:"高性能 8C32G (ecs.c7.2xlarge)",value:"ecs.c7.2xlarge"}],acceptsPills:!0},{key:"imageId",label:"操作系统镜像",type:"select",required:!0,defaultValue:"image-alilinux-3",options:[{label:"Alibaba Cloud Linux 3.2104 LTS 64位",value:"image-alilinux-3"},{label:"Ubuntu 22.04 LTS 64位",value:"image-ubuntu-22"},{label:"CentOS 7.9 64位",value:"image-centos-7"},{label:"Debian 12 64位",value:"image-debian-12"}],acceptsPills:!0},{key:"instanceName",label:"主机名称",type:"text",placeholder:"例如: web-prod-01",required:!0,defaultValue:"app-server-node",acceptsPills:!0},{key:"systemDiskSize",label:"系统盘容量 (GB)",type:"number",defaultValue:100,required:!0,acceptsPills:!0}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"instanceName",label:"主机名称",type:"string",example:"app-server-node"},{key:"privateIp",label:"内网IP",type:"string",example:"172.16.0.42"},{key:"status",label:"实例状态",type:"string",example:"RUNNING"},{key:"createdAt",label:"创建时间",type:"string",example:"2026-10-20T14:00:00Z"}],compile:(e,t)=>({name:"ecs_create_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`创建云主机: ${e.instanceName||t.taskReferenceName}`,inputParameters:{_actionId:"ecs.create_instance",actionName:"创建云主机",regionId:e.regionId??"cn-hangzhou",instanceType:e.instanceType??"ecs.c7.xlarge",imageId:e.imageId??"image-alilinux-3",instanceName:e.instanceName??"app-node",systemDiskSize:Number(e.systemDiskSize??100),http_request:{uri:"https://ecs.internal.cloud/api/v2/instances",method:"POST",body:{regionId:e.regionId,instanceType:e.instanceType,imageId:e.imageId,instanceName:e.instanceName,systemDiskSize:e.systemDiskSize}}}}),decompile:e=>{if(e.inputParameters?._actionId==="ecs.create_instance"){const t=e.inputParameters;return{regionId:t.regionId??"cn-hangzhou",instanceType:t.instanceType??"ecs.c7.xlarge",imageId:t.imageId??"image-alilinux-3",instanceName:t.instanceName??e.taskReferenceName,systemDiskSize:t.systemDiskSize??100}}return null},mockOutput:e=>({instanceId:`i-bp1${Math.random().toString(36).substring(2,9)}`,instanceName:e.instanceName||"app-server-node",privateIp:"172.16.0."+Math.floor(10+Math.random()*200),status:"RUNNING",regionId:e.regionId||"cn-hangzhou",instanceType:e.instanceType||"ecs.c7.xlarge",createdAt:new Date().toISOString()})},{id:"ecs.query_instance",name:"查询云主机详情",category:"compute",icon:"🔍",description:"根据主机实例 ID 查询其实时运行状态、配置规格与网络 IP",connector:"cloud_host",riskLevel:"safe",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",placeholder:"例如: i-bp18a9z3j42m09a 或绑定上游胶囊",required:!0,acceptsPills:!0}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"status",label:"运行状态",type:"string",example:"RUNNING"},{key:"cpu",label:"CPU核心数",type:"number",example:4},{key:"memoryGb",label:"内存(GB)",type:"number",example:8},{key:"privateIp",label:"内网IP",type:"string",example:"172.16.0.42"},{key:"publicIp",label:"公网IP",type:"string",example:"47.98.112.23"},{key:"osName",label:"操作系统",type:"string",example:"Alibaba Cloud Linux 3"}],compile:(e,t)=>({name:"ecs_query_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`查询云主机状态: ${e.instanceId||""}`,inputParameters:{_actionId:"ecs.query_instance",actionName:"查询云主机详情",instanceId:e.instanceId,http_request:{uri:`https://ecs.internal.cloud/api/v2/instances/${e.instanceId||""}`,method:"GET"}}}),decompile:e=>e.inputParameters?._actionId==="ecs.query_instance"?{instanceId:e.inputParameters.instanceId??""}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",status:"RUNNING",cpu:4,memoryGb:8,privateIp:"172.16.0.42",publicIp:"47.98.112.23",osName:"Alibaba Cloud Linux 3.2104",uptimeHours:360})},{id:"ecs.start_instance",name:"启动云主机",category:"compute",icon:"▶️",description:"将处于关机/停止状态的云主机实例开机启动",connector:"cloud_host",riskLevel:"safe",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",placeholder:"选择或填入要开机的主机 ID",required:!0,acceptsPills:!0}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"previousStatus",label:"变更前状态",type:"string",example:"STOPPED"},{key:"currentStatus",label:"当前状态",type:"string",example:"STARTING"},{key:"startedAt",label:"开机时间",type:"string",example:"2026-10-20T14:15:00Z"}],compile:(e,t)=>({name:"ecs_start_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`开机启动云主机: ${e.instanceId||""}`,inputParameters:{_actionId:"ecs.start_instance",actionName:"启动云主机",instanceId:e.instanceId,http_request:{uri:`https://ecs.internal.cloud/api/v2/instances/${e.instanceId||""}/start`,method:"POST"}}}),decompile:e=>e.inputParameters?._actionId==="ecs.start_instance"?{instanceId:e.inputParameters.instanceId??""}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",previousStatus:"STOPPED",currentStatus:"RUNNING",startedAt:new Date().toISOString()})},{id:"ecs.stop_instance",name:"停止云主机",category:"compute",icon:"⏹️",description:"安全关机或强制关机运行中的云主机实例",connector:"cloud_host",riskLevel:"sensitive",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",placeholder:"选择或填入要关机的主机 ID",required:!0,acceptsPills:!0},{key:"forceStop",label:"是否强制关机",type:"boolean",defaultValue:!1,help:"默认安全优雅关机,开启后若超时将直接切断电源"}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"status",label:"当前状态",type:"string",example:"STOPPED"},{key:"stoppedAt",label:"关机完成时间",type:"string",example:"2026-10-20T14:20:00Z"}],compile:(e,t)=>({name:"ecs_stop_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`停止云主机: ${e.instanceId||""}`,inputParameters:{_actionId:"ecs.stop_instance",actionName:"停止云主机",instanceId:e.instanceId,forceStop:!!e.forceStop,http_request:{uri:`https://ecs.internal.cloud/api/v2/instances/${e.instanceId||""}/stop`,method:"POST",body:{forceStop:e.forceStop}}}}),decompile:e=>e.inputParameters?._actionId==="ecs.stop_instance"?{instanceId:e.inputParameters.instanceId??"",forceStop:!!e.inputParameters.forceStop}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",status:"STOPPED",forceStop:!!e.forceStop,stoppedAt:new Date().toISOString()})},{id:"ecs.restart_instance",name:"重启云主机",category:"compute",icon:"🔄",description:"重新启动运行中的云主机(支持软重启与强制硬重启)",connector:"cloud_host",riskLevel:"sensitive",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",placeholder:"例如: i-bp18a9z3j42m09a",required:!0,acceptsPills:!0},{key:"forceRestart",label:"强制重启 (硬重启)",type:"boolean",defaultValue:!1}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"status",label:"状态",type:"string",example:"REBOOTING"},{key:"restartedAt",label:"重启时间",type:"string",example:"2026-10-20T14:22:00Z"}],compile:(e,t)=>({name:"ecs_restart_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`重启云主机: ${e.instanceId||""}`,inputParameters:{_actionId:"ecs.restart_instance",actionName:"重启云主机",instanceId:e.instanceId,forceRestart:!!e.forceRestart}}),decompile:e=>e.inputParameters?._actionId==="ecs.restart_instance"?{instanceId:e.inputParameters.instanceId??"",forceRestart:!!e.inputParameters.forceRestart}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",status:"RUNNING",restartedAt:new Date().toISOString()})},{id:"ecs.modify_spec",name:"变更实例规格 (升降配)",category:"compute",icon:"⚡",description:"在线或离线升级/降低云主机 CPU 与内存硬件配置",connector:"cloud_host",riskLevel:"sensitive",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",required:!0,acceptsPills:!0},{key:"targetSpec",label:"目标规格配置",type:"select",required:!0,defaultValue:"ecs.c7.2xlarge",options:[{label:"提升至 计算型 8C16G (ecs.c7.2xlarge)",value:"ecs.c7.2xlarge"},{label:"提升至 内存型 8C32G (ecs.r7.2xlarge)",value:"ecs.r7.2xlarge"},{label:"降低至 通用型 2C4G (ecs.g7.large)",value:"ecs.g7.large"}],acceptsPills:!0}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"oldSpec",label:"变更前规格",type:"string",example:"ecs.c7.xlarge"},{key:"newSpec",label:"新规格",type:"string",example:"ecs.c7.2xlarge"},{key:"status",label:"变配状态",type:"string",example:"SUCCESS"}],compile:(e,t)=>({name:"ecs_modify_spec",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`云主机变配为 ${e.targetSpec||""}`,inputParameters:{_actionId:"ecs.modify_spec",actionName:"变更实例规格",instanceId:e.instanceId,targetSpec:e.targetSpec}}),decompile:e=>e.inputParameters?._actionId==="ecs.modify_spec"?{instanceId:e.inputParameters.instanceId??"",targetSpec:e.inputParameters.targetSpec??"ecs.c7.2xlarge"}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",oldSpec:"ecs.c7.xlarge",newSpec:e.targetSpec||"ecs.c7.2xlarge",status:"SUCCESS",effectiveImmediately:!0})},{id:"ecs.create_snapshot",name:"创建云盘快照",category:"storage",icon:"💾",description:"为云主机的系统盘或数据盘创建实时快照,用于容灾备份或回滚",connector:"cloud_host",riskLevel:"safe",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",required:!0,acceptsPills:!0},{key:"snapshotName",label:"快照名称/备注",type:"text",defaultValue:"backup-auto-snapshot",acceptsPills:!0},{key:"retentionDays",label:"自动保留天数",type:"number",defaultValue:7,help:"过期后自动清理释放,0 为永久保留"}],outputs:[{key:"snapshotId",label:"快照ID",type:"string",example:"s-bp14209938"},{key:"snapshotName",label:"快照名称",type:"string",example:"backup-auto-snapshot"},{key:"progress",label:"创建进度",type:"string",example:"100%"},{key:"status",label:"状态",type:"string",example:"ACCOMPLISHED"}],compile:(e,t)=>({name:"ecs_create_snapshot",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`创建快照: ${e.snapshotName||t.taskReferenceName}`,inputParameters:{_actionId:"ecs.create_snapshot",actionName:"创建云盘快照",instanceId:e.instanceId,snapshotName:e.snapshotName,retentionDays:Number(e.retentionDays??7)}}),decompile:e=>e.inputParameters?._actionId==="ecs.create_snapshot"?{instanceId:e.inputParameters.instanceId??"",snapshotName:e.inputParameters.snapshotName??"backup-auto-snapshot",retentionDays:e.inputParameters.retentionDays??7}:null,mockOutput:e=>({snapshotId:`s-bp1${Math.random().toString(36).substring(2,8)}`,snapshotName:e.snapshotName||"backup-auto-snapshot",progress:"100%",status:"ACCOMPLISHED",sizeGb:100})},{id:"ecs.run_command",name:"执行远程运维脚本",category:"compute",icon:"💻",description:"免登录直接在云主机内部运行 Shell/Python 脚本并捕获返回日志",connector:"cloud_host",riskLevel:"sensitive",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",required:!0,acceptsPills:!0},{key:"commandType",label:"脚本语言",type:"select",defaultValue:"RunShellScript",options:[{label:"Shell 脚本 (Linux)",value:"RunShellScript"},{label:"Python 脚本",value:"RunPythonScript"}]},{key:"commandContent",label:"执行脚本命令",type:"textarea",placeholder:"例如: df -h && free -m && systemctl status nginx",defaultValue:"uptime && free -m",required:!0,acceptsPills:!0},{key:"timeoutSeconds",label:"超时时间 (秒)",type:"number",defaultValue:60}],outputs:[{key:"commandId",label:"调用批次ID",type:"string",example:"cmd-0992384"},{key:"exitCode",label:"进程退出码",type:"number",example:0},{key:"output",label:"标准输出日志",type:"string",example:"Linux 5.10.134-13.al8.x86_64"},{key:"status",label:"执行状态",type:"string",example:"SUCCESS"}],compile:(e,t)=>({name:"ecs_run_command",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`主机下发命令: ${t.taskReferenceName}`,inputParameters:{_actionId:"ecs.run_command",actionName:"执行远程运维脚本",instanceId:e.instanceId,commandType:e.commandType??"RunShellScript",commandContent:e.commandContent,timeoutSeconds:Number(e.timeoutSeconds??60)}}),decompile:e=>e.inputParameters?._actionId==="ecs.run_command"?{instanceId:e.inputParameters.instanceId??"",commandType:e.inputParameters.commandType??"RunShellScript",commandContent:e.inputParameters.commandContent??"",timeoutSeconds:e.inputParameters.timeoutSeconds??60}:null,mockOutput:e=>({commandId:`cmd-${Date.now().toString(36)}`,exitCode:0,output:`[2026-10-20 22:30:00 UTC] Command executed on ${e.instanceId||"i-bp18a9z3j42m09a"}
|
|
263
|
+
`,QN={string:"var(--cm-data)",number:"var(--cm-ai)",boolean:"var(--cm-cat-human)",object:"var(--cm-status-warning)",array:"var(--cm-status-success)",any:"var(--text-muted)"},e2=({isOpen:e,onClose:t,onSelect:r,suggestions:n,wlspItems:s=[],anchorRect:a,onRequestAiHint:i,aiLoading:l=!1})=>{const c=te($=>$.theme),d=te($=>$.themeColor),[u,p]=T.useState("all"),[f,m]=T.useState(""),[h,y]=T.useState(0),x=T.useRef(null);T.useEffect(()=>{e&&(m(""),y(0),setTimeout(()=>x.current?.focus(),30))},[e]);const g=T.useMemo(()=>{const $=s.map(q=>({label:q.label,value:q.value,description:q.description,category:q.category,valueType:q.valueType,sourceLabel:q.sourceLabel,sampleValue:q.sampleValue,isConditional:q.isConditional})),B=new Set($.map(q=>q.value));for(const q of n)B.has(q.value)||(B.add(q.value),$.push({...q,category:q.category||"ai"}));return $},[s,n]),v=T.useMemo(()=>g.filter($=>{if(u!=="all"&&$.category!==u&&$.category!=="ai")return!1;if(!f.trim())return!0;const B=f.toLowerCase();return $.label.toLowerCase().includes(B)||$.value.toLowerCase().includes(B)||$.description.toLowerCase().includes(B)||$.sourceLabel&&$.sourceLabel.toLowerCase().includes(B)}),[g,u,f]);if(T.useEffect(()=>{y(0)},[u,f]),!e||!a||typeof document>"u")return null;const k=typeof window<"u"?window.innerHeight:800,b=typeof window<"u"?window.innerWidth:1280,S=Math.min(380,b-32),j=a.width>=160?a.left:a.right-S,_=Math.min(Math.max(16,j),b-S-16),w=k-a.bottom-16,I=a.top-16,N=w<260&&I>w,C=N?Math.min(400,Math.max(200,I)):Math.min(400,Math.max(200,w)),M=c==="light",R={position:"fixed",...N?{bottom:`${k-a.top+6}px`}:{top:`${a.bottom+6}px`},left:`${_}px`,width:`${S}px`,maxHeight:`${C}px`,zIndex:9999,background:"color-mix(in srgb, var(--cm-surface-1) 97%, transparent)",color:"var(--text-primary)",borderColor:"color-mix(in srgb, var(--cm-data) 28%, transparent)"},O=$=>{$.key==="ArrowDown"?($.preventDefault(),y(B=>v.length>0?(B+1)%v.length:0)):$.key==="ArrowUp"?($.preventDefault(),y(B=>v.length>0?(B-1+v.length)%v.length:0)):$.key==="Enter"&&v[h]?($.preventDefault(),r(v[h].value),t()):$.key==="Escape"&&($.preventDefault(),t())};return bt.createPortal(o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"suggester-overlay",onClick:t}),o.jsxs("div",{className:`parameter-suggester-popover glass-panel ${M?"theme-light":"theme-dark"}`,"data-mode":c,"data-brand":d,style:R,onKeyDown:O,children:[o.jsxs("div",{className:"suggester-header",children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsx("span",{className:"sparkle-icon",children:o.jsx(At,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsx("span",{children:"W-LSP 上下文变量补全"}),o.jsxs("span",{style:{fontSize:10,opacity:.65,fontWeight:500},children:["(",v.length,")"]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[i&&o.jsx("button",{type:"button",className:"suggester-ai-btn",onClick:i,disabled:l,title:"调用 AI 推理更多上下文表达式",children:l?"AI 思考中...":"AI 推荐"}),o.jsx("button",{type:"button",onClick:t,title:"关闭 (Esc)",style:{background:"none",border:"none",color:"inherit",opacity:.55,cursor:"pointer",padding:"2px 4px",fontSize:12,lineHeight:1},children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]})]}),o.jsx("div",{className:"suggester-search-bar",children:o.jsx("input",{ref:x,type:"text",className:"suggester-search-input",placeholder:"搜索上游任务、输出字段或输入参数 (↑↓选择, Enter插入)...",value:f,onChange:$=>m($.target.value)})}),o.jsx("div",{className:"suggester-tabs",children:[{id:"all",label:"全部"},{id:"upstream",label:"上游输出"},{id:"workflow_input",label:"工作流输入"},{id:"variable",label:"全局变量"},{id:"system",label:"系统"}].map($=>o.jsx("button",{type:"button",className:`suggester-tab ${u===$.id?"active":""}`,onClick:()=>p($.id),children:$.label},$.id))}),o.jsx("div",{className:"suggester-list",children:v.length===0?o.jsx("div",{className:"suggester-empty",children:"没有匹配的上下文变量"}):v.map(($,B)=>{const q=QN[$.valueType||"any"]||"var(--text-muted)";return o.jsxs("div",{className:`suggestion-item ${B===h?"active":""}`,onMouseEnter:()=>y(B),onClick:()=>{r($.value),t()},children:[o.jsxs("div",{className:"suggestion-top-row",children:[o.jsx("span",{className:"suggestion-label",children:$.label}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[$.isConditional&&o.jsx("span",{className:"suggestion-cond-badge",title:"来自条件分支,可能未执行",children:"条件分支"}),$.valueType&&o.jsx("span",{className:"suggestion-type-badge",style:{color:q,borderColor:`${q}44`,background:`${q}15`},children:$.valueType})]})]}),o.jsxs("div",{className:"suggestion-value-row",children:[o.jsx("code",{className:"suggestion-value",children:$.value}),$.sampleValue!==void 0&&o.jsxs("span",{className:"suggestion-sample",title:`真实样本值: ${$.sampleValue}`,children:["= ",$.sampleValue]})]}),o.jsxs("div",{className:"suggestion-desc",children:[$.sourceLabel?`[${$.sourceLabel}] `:"",$.description]})]},`${$.value}-${B}`)})})]})]}),document.body)},t2=({title:e,value:t,language:r="text",placeholder:n="",onSave:s,onClose:a})=>{const{theme:i,themeColor:l}=te(Ae(m=>({theme:m.theme,themeColor:m.themeColor}))),[c,d]=T.useState(t),u=T.useRef(null);T.useEffect(()=>{u.current?.focus();const m=h=>{h.key==="Escape"&&(h.stopPropagation(),a()),(h.ctrlKey||h.metaKey)&&h.key==="s"&&(h.preventDefault(),h.stopPropagation(),s(c))};return window.addEventListener("keydown",m,!0),()=>window.removeEventListener("keydown",m,!0)},[c,s,a]);const f={javascript:"var(--cm-status-warning)",js:"var(--cm-status-warning)",json:"var(--cm-data)",jq:"var(--cm-status-success)",groovy:"var(--cm-status-success)",python:"var(--cm-ai)",text:"var(--text-secondary)"}[r.toLowerCase()]??"var(--text-secondary)";return bt.createPortal(o.jsxs("div",{"data-mode":i,"data-brand":l,style:{position:"fixed",inset:0,zIndex:3e3,display:"flex",flexDirection:"column",background:"var(--bg-primary)"},onClick:m=>m.stopPropagation(),children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"12px",padding:"10px 20px",background:"var(--bg-secondary)",borderBottom:"1px solid var(--glass-border)",flexShrink:0},children:[o.jsx("span",{style:{fontSize:"11px",fontWeight:700,color:f,background:`${f}18`,border:`1px solid ${f}44`,padding:"2px 8px",borderRadius:"4px",fontFamily:"monospace",letterSpacing:"0.5px",textTransform:"uppercase",flexShrink:0},children:r}),o.jsx("span",{style:{fontSize:"13px",fontWeight:600,color:"var(--text-primary)",flex:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e}),o.jsx("span",{style:{fontSize:"11px",color:"var(--text-secondary)",flexShrink:0},children:"Ctrl+S 保存 · Esc 取消"}),o.jsx("button",{onClick:a,style:{padding:"6px 14px",background:"var(--bg-tertiary)",border:"1px solid var(--glass-border)",borderRadius:"6px",color:"var(--text-primary)",cursor:"pointer",fontSize:"12px",fontWeight:500,flexShrink:0},children:"取消"}),o.jsx("button",{onClick:()=>s(c),style:{padding:"6px 16px",background:"var(--color-accent)",border:"none",borderRadius:"6px",color:"var(--color-on-accent)",cursor:"pointer",fontSize:"12px",fontWeight:600,flexShrink:0},children:"应用"})]}),o.jsx("textarea",{ref:u,value:c,placeholder:n,onChange:m=>d(m.target.value),onKeyDown:m=>m.stopPropagation(),spellCheck:!1,style:{flex:1,width:"100%",padding:"20px 24px",background:"var(--bg-primary)",color:r==="javascript"||r==="js"||r==="groovy"?"var(--color-accent)":"var(--text-primary)",border:"none",outline:"none",resize:"none",fontFamily:'var(--font-mono, "Fira Code", "Cascadia Code", Consolas, monospace)',fontSize:"14px",lineHeight:"1.7",boxSizing:"border-box",caretColor:"var(--color-accent)"}}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"16px",padding:"5px 20px",background:"var(--bg-secondary)",borderTop:"1px solid var(--glass-border)",flexShrink:0,fontSize:"11px",color:"var(--text-secondary)"},children:[o.jsxs("span",{children:[c.split(`
|
|
264
|
+
`).length," 行"]}),o.jsxs("span",{children:[c.length," 字符"]}),c!==t&&o.jsx("span",{style:{color:"var(--cm-status-warning)",fontWeight:600},children:"● 未保存"})]})]}),document.body)},r2=({label:e,value:t,onCommit:r,editable:n,rows:s=5,placeholder:a,style:i,dataField:l,secondaryTextColor:c="var(--text-secondary)",onOpenFullscreen:d,onTextareaFocus:u,onTyping:p,registerApply:f})=>{const[m,h]=T.useState(t),[y,x]=T.useState(!1),[g,v]=T.useState(null);T.useEffect(()=>{!y&&!g&&h(t)},[t,y,g]);const k=S=>{if(S===t){v(null);return}v(r(S))},b=S=>{h(S),k(S)};return T.useEffect(()=>{if(f)return f(b),()=>f(null)}),o.jsxs("div",{style:{marginBottom:"8px"},children:[(e||n&&d)&&o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"},children:[o.jsx("label",{style:{fontSize:"10px",color:c},children:e}),n&&d&&o.jsx("button",{type:"button",onClick:()=>d(m,b),title:"全屏编辑",style:{background:"none",border:"none",cursor:"pointer",padding:"2px 4px",color:"var(--text-secondary)",opacity:.7,lineHeight:1},children:o.jsx(xb,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsx("textarea",{value:m,placeholder:a,disabled:!n,rows:s,"data-field":l,"aria-invalid":g?!0:void 0,onChange:S=>{const j=S.target.value;h(j),p?.(S.target,j,b)},onFocus:S=>{x(!0),u?.(S.currentTarget)},onBlur:S=>{x(!1),k(S.target.value)},style:{width:"100%",padding:"12px",borderRadius:"8px",border:`1px solid ${g?"var(--cm-status-failed)":"var(--glass-border)"}`,background:"var(--bg-tertiary)",color:"var(--text-primary)",fontSize:"12px",fontFamily:"var(--font-mono, monospace)",lineHeight:"1.5",resize:"vertical",...i,...g?{borderColor:"var(--cm-status-failed)"}:{}}}),g&&o.jsxs("div",{role:"alert",style:{display:"flex",alignItems:"flex-start",gap:"6px",marginTop:"4px",fontSize:"11px",color:"var(--cm-status-failed)",lineHeight:1.5},children:[o.jsx(jt,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{flexShrink:0,marginTop:1}}),o.jsx("span",{children:g})]})]})},n2=[{label:"工作流输入",value:"${workflow.input.fieldName}",desc:"引用工作流启动时传入的参数"},{label:"上游任务输出",value:"${taskRef.output.result}",desc:"引用上游任务的输出字段"},{label:"工作流变量",value:"${workflow.variables.varName}",desc:"引用 SET_VARIABLE 设置的变量"},{label:"工作流 ID",value:"${workflow.workflowId}",desc:"当前工作流实例 ID"},{label:"关联 ID",value:"${workflow.correlationId}",desc:"工作流关联 ID"},{label:"工作流状态",value:"${workflow.status}",desc:"当前工作流状态"}],Tt=(e,t)=>e?.inputParameters?.[t]??e?.[t];function Ik(e){return!e||e.type!=="FORK_JOIN_DYNAMIC"?"classic":Tt(e,"forkTaskWorkflow")?"workflow":Tt(e,"forkTaskType")||Tt(e,"forkTaskName")?"task":"classic"}const s2=({task:e,isOpen:t=!0,onClose:r,aiConfig:n})=>{const{mode:s,updateTask:a,workflowDef:i,executionData:l,workflowInstance:c,lastRefactorNotice:d,clearRefactorNotice:u}=te(Ae(E=>({mode:E.mode,updateTask:E.updateTask,workflowDef:E.workflowDef,executionData:E.executionData,workflowInstance:E.workflowInstance,lastRefactorNotice:E.lastRefactorNotice,clearRefactorNotice:E.clearRefactorNotice}))),[p,f]=T.useState(e),[m,h]=T.useState(e?.taskReferenceName??null),[y,x]=T.useState(null),[g,v]=T.useState(!1),[k,b]=T.useState(null),[S,j]=T.useState(()=>e?.type==="WAIT"&&e.inputParameters?.until?"until":"duration"),[_,w]=T.useState(()=>e?.type==="DO_WHILE"&&e.inputParameters?.items?"items":"condition"),[I,N]=T.useState(()=>Ik(e)),[C,M]=T.useState(!1),[R,O]=T.useState(),[$,B]=T.useState([]),[q,F]=T.useState(()=>()=>{}),A=e?.taskReferenceName||p?.taskReferenceName||"",W=T.useMemo(()=>!i||!A?[]:Cv(i,A,l,c?.input),[i,A,l,c?.input]),P=T.useRef({}),[D,Z]=T.useState(null),[L,H]=T.useState(null),[U,K]=T.useState(!1),[se,pe]=T.useState(null),[we,Ce]=T.useState(null),ne=(E,Q,ae,oe)=>{H({title:E,value:Q,language:ae,onSave:oe})},Te=E=>[{label:"示例 · 引用工作流输入",value:"${workflow.input.data}",description:`${E},以下为通用示例:引用工作流启动时传入的数据`},{label:"示例 · 引用前序任务输出",value:"${previous_task.output.result}",description:"通用示例:引用上一个节点的输出(请替换为实际任务引用名)"},{label:"示例 · 工作流变量",value:"${workflow.variables.api_key}",description:"通用示例:引用 SET_VARIABLE 设置的变量"}],le=async()=>{if(!En(n)){Ce(Cn);return}if(X){Ce(null),K(!0);try{const{workflowDef:E}=te.getState(),Q=St(E?.inputParameters,E).map(Ee=>Ee.name),ae=ys(E,X.taskReferenceName).map(Ee=>({ref:Ee.taskReferenceName,type:Ee.type,name:Ee.name})).slice(0,10),oe={...n},de=await BN(X.type,X.taskReferenceName,Q,ae,X.inputParameters??{},oe);pe({generated:de,original:X.inputParameters??{}})}catch(E){Ce(`AI 填充失败:${E?.message||"AI 服务返回了无法识别的错误,请重试"}`)}finally{K(!1)}}},V=async(E,Q)=>{const ae=E.currentTarget.getBoundingClientRect();if(O(ae),F(()=>Q),M(!0),!(W.length>0)){if(B([]),!En(n)){B(Te("未配置 AI 服务"));return}try{const oe={...n},{workflowDef:de}=te.getState(),Ee=ZN(X,de),tt=(await Sk([{role:"system",content:"You are a Conductor workflow expert. Return only valid JSON."},{role:"user",content:Ee}],oe)).match(/\[[\s\S]*\]/);if(tt){const Fe=JSON.parse(tt[0]);B(Fe)}else B(Te("AI 没有返回可用的建议"))}catch{B(Te("AI 建议获取失败"))}}};if(T.useEffect(()=>{e&&(f(e),h(e.taskReferenceName),x(null),Z(null),e.type==="WAIT"&&j(e.inputParameters?.until?"until":"duration"),e.type==="DO_WHILE"&&w(e.inputParameters?.items?"items":"condition"),e.type==="FORK_JOIN_DYNAMIC"&&N(Ik(e)))},[e]),!e&&!p)return null;const X=e||p,z=p&&e&&m===e.taskReferenceName?p:X,ve=t&&e?"panel-enter-active":"panel-exit",he=s==="edit",_e="var(--text-primary)",Se="var(--glass-border)",be="var(--bg-tertiary)",ce="var(--text-secondary)",Re=(E,Q)=>{const ae={...z,[E]:Q};f(ae),a(z.taskReferenceName,{[E]:Q})},De=(E,Q,ae)=>{const de={...z[E]||{},[Q]:ae},Ee={...z,[E]:de};f(Ee),a(z.taskReferenceName,{[E]:de})},Je=(E,Q)=>{const ae=z.inputParameters||{},de={...ae.http_request||z.httpRequest||{},[E]:Q},Me={inputParameters:{...ae,http_request:de}};z.httpRequest&&(Me.httpRequest=de);const tt={...z,...Me};f(tt),a(z.taskReferenceName,Me)},ee=(E,Q)=>{const oe={inputParameters:{...z.inputParameters,[E]:Q}},de={...z,...oe};f(de),a(z.taskReferenceName,oe)},ue=E=>{const Q={...z,...E};f(Q),a(z.taskReferenceName,E)},ie=(E,Q,ae)=>{const oe=z.inputParameters||{},de=oe[E]&&typeof oe[E]=="object"?oe[E]:{};ee(E,{...de,[Q]:ae})},ge=(E,Q)=>{const ae={...z.inputParameters||{},[E]:Q};(Q===void 0||Q==="")&&delete ae[E];const oe={inputParameters:ae};z[E]!==void 0&&(oe[E]=void 0),ue(oe)},re=(E,Q)=>{ue(dj(z,E,Q,i?.ownerEmail))},Ie=E=>{j(E);const Q={...z.inputParameters||{}},ae=E==="duration"?"until":"duration";Q[ae]!==void 0&&(delete Q[ae],ue({inputParameters:Q}))},Oe=(E,Q={allowEmpty:!0,requireObject:!0})=>ae=>{const oe=Ov(ae,Q);return oe.ok?(E(oe.value),null):oe.error},ke=E=>Q=>{const ae=Q.trim();if(ae.startsWith("{")||ae.startsWith("[")){const oe=Ov(ae,{allowEmpty:!0});return oe.ok?(E(oe.value),null):oe.error}return E(Q),null},Ne=(E,Q="{}")=>E==null?Q:typeof E=="object"?JSON.stringify(E,null,2):String(E),Pe=(E,Q,ae,oe,de={})=>o.jsx(r2,{label:E,value:ae,onCommit:oe,editable:he,rows:de.rows??5,placeholder:de.placeholder,style:de.style,dataField:de.dataField,secondaryTextColor:ce,onOpenFullscreen:(Ee,Me)=>ne(E||Q,Ee,de.language||"json",tt=>{Me(tt),H(null)}),onTextareaFocus:Ee=>b(Ee),registerApply:de.dataField?Ee=>{Ee?P.current[de.dataField]=Ee:delete P.current[de.dataField]}:void 0,onTyping:(Ee,Me,tt)=>{const Fe=Ee.selectionStart??0;Fe>=2&&Me.slice(Fe-2,Fe)==="${"&&(O(Ee.getBoundingClientRect()),F(()=>Ze=>{tt(Me.slice(0,Fe-2)+Ze+Me.slice(Fe))}),M(!0))}},`${z.taskReferenceName}:${Q}`),je=E=>{if(!k)return;const Q=k.selectionStart??0,ae=k.selectionEnd??0,oe=k.value,de=oe.substring(0,Q)+E+oe.substring(ae),Ee=k.getAttribute("data-field"),Me=Ee?P.current[Ee]:void 0;Me?Me(de):Ee&&Re(Ee,de),v(!1)},Le=(E,Q,ae,oe)=>o.jsxs("div",{style:{marginBottom:"24px",padding:"16px",borderRadius:"12px",background:`color-mix(in srgb, ${ae} 6%, transparent)`,border:`1px solid color-mix(in srgb, ${ae} 19%, transparent)`,boxShadow:"var(--cm-shadow-card)"},children:[o.jsxs("div",{style:{fontSize:"12px",fontWeight:"bold",marginBottom:"16px",color:ae,display:"flex",alignItems:"center",gap:"8px"},children:[o.jsx(Q,{size:14,strokeWidth:1.75,"aria-hidden":"true"})," ",E]}),oe]}),it=(E,Q,ae="text",oe)=>{const de=Q==="taskReferenceName",Ee=de&&y!==null?y:z[Q]??"",Me=de&&y!==null?vs(i,String(Ee),z.taskReferenceName):de?D:null,tt=!!Me;return o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsxs("label",{style:{display:"block",fontSize:"11px",color:ce,marginBottom:"6px",fontWeight:"600",textTransform:"uppercase"},children:[E,de&&Me&&o.jsxs("span",{role:"alert",style:{color:"var(--cm-status-failed)",marginLeft:"8px",textTransform:"none",display:"inline-block",fontWeight:"normal"},children:[o.jsx(Ye,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),Me]})]}),o.jsxs("div",{style:{position:"relative",display:"flex",alignItems:"center"},children:[o.jsx("input",{type:ae,value:Ee,placeholder:oe,onChange:Fe=>{const Ze=Fe.target.value;if(de)x(Ze);else{Re(Q,ae==="number"?Ze===""?void 0:Number(Ze):Ze);const rt=Fe.target.selectionStart??0;if(ae==="text"&&rt>=2&&Ze.slice(rt-2,rt)==="${"){const pr=Fe.target.getBoundingClientRect();O(pr),F(()=>Ir=>{const Jp=Ze.slice(0,rt-2),Up=Ze.slice(rt);Re(Q,Jp+Ir+Up)}),M(!0)}}},onFocus:de?()=>{y===null&&x(z.taskReferenceName??"")}:void 0,onBlur:de?Fe=>{const Ze=Fe.target.value.trim();if(Ze===z.taskReferenceName){x(null),Z(null);return}const rt=vs(i,Ze,z.taskReferenceName);if(rt){Z(rt);return}x(null),Z(null),Re("taskReferenceName",Ze)}:void 0,onKeyDown:de?Fe=>{Fe.key==="Enter"&&Fe.currentTarget.blur(),Fe.stopPropagation()}:void 0,disabled:!he,style:{width:"100%",padding:`8px ${he&&!de?"32px":"12px"} 8px 12px`,borderRadius:"6px",border:`1px solid ${tt?"var(--cm-status-failed)":Se}`,background:be,color:_e,fontSize:"13px",outline:"none",opacity:he?1:.8,fontFamily:de?"monospace":"inherit"}}),he&&!de&&o.jsx("button",{className:"ai-hint-trigger",onClick:Fe=>V(Fe,Ze=>Re(Q,Ze)),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:o.jsx(Pt,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]})]})},lt=(E,Q,ae,oe={})=>{const{rows:de=5,language:Ee="text",style:Me,placeholder:tt,"data-field":Fe}=oe,Ze={width:"100%",padding:"12px",borderRadius:"8px",border:`1px solid ${Se}`,background:be,color:_e,fontSize:"12px",fontFamily:"monospace",lineHeight:"1.5",resize:"vertical",...Me};return o.jsxs("div",{style:{marginBottom:"8px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"4px"},children:[o.jsx("label",{style:{fontSize:"10px",color:ce},children:E}),he&&o.jsx("button",{onClick:()=>ne(E,Q,Ee,rt=>{ae(rt),H(null)}),title:"全屏编辑",style:{background:"none",border:"none",cursor:"pointer",fontSize:"14px",padding:"2px 4px",color:"var(--text-secondary)",opacity:.7,lineHeight:1},children:o.jsx(xb,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsx("textarea",{value:Q,placeholder:tt,onChange:rt=>{const pr=rt.target.value;ae(pr);const Ir=rt.target.selectionStart??0;if(Ir>=2&&pr.slice(Ir-2,Ir)==="${"){const Jp=rt.target.getBoundingClientRect();O(Jp),F(()=>Up=>{const LE=pr.slice(0,Ir-2),ME=pr.slice(Ir);ae(LE+Up+ME)}),M(!0)}},disabled:!he,rows:de,"data-field":Fe,onFocus:rt=>b(rt.currentTarget),style:Ze})]})},fe=(E,Q,ae,oe="text",de)=>o.jsxs("div",{style:{marginBottom:"12px"},children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:E}),o.jsx("input",{type:oe,value:Q??"",placeholder:de,onChange:Ee=>{const Me=Ee.target.value;ae(oe==="number"?Me===""?void 0:Number(Me):Me);const tt=Ee.target.selectionStart??0;if(oe==="text"&&tt>=2&&Me.slice(tt-2,tt)==="${"){const Fe=Ee.target.getBoundingClientRect();O(Fe),F(()=>Ze=>{const rt=Me.slice(0,tt-2),pr=Me.slice(tt);ae(rt+Ze+pr)}),M(!0)}},disabled:!he,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${Se}`,background:be,color:_e,fontSize:"12px",outline:"none"}})]}),Ke=(E,Q,ae,oe)=>o.jsxs("div",{style:{marginBottom:"12px"},children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:E}),o.jsx("select",{value:ae,onChange:de=>oe(de.target.value),disabled:!he,style:{width:"100%",padding:"8px 10px",borderRadius:"6px",border:`1px solid ${Se}`,background:be,color:_e,fontSize:"12px",outline:"none",cursor:"pointer"},children:Q.map(de=>o.jsx("option",{value:de,children:de},de))})]}),dr=(E,Q,ae)=>o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"12px"},children:[o.jsx("span",{style:{fontSize:"11px",color:ce},children:E}),o.jsx("button",{onClick:()=>ae(!Q),disabled:!he,style:{width:"36px",height:"20px",borderRadius:"10px",border:"none",cursor:"pointer",background:Q?"var(--color-accent)":Se,position:"relative",transition:"background 0.2s"},children:o.jsx("span",{style:{position:"absolute",top:"2px",left:Q?"18px":"2px",width:"16px",height:"16px",borderRadius:"50%",background:"var(--cm-surface-1)",transition:"left 0.2s"}})})]}),ct=(E,Q,ae)=>o.jsx("div",{style:{display:"flex",gap:"6px",marginBottom:"12px"},children:E.map(oe=>o.jsx("button",{onClick:()=>ae(oe.key),disabled:!he,style:{flex:1,padding:"6px",borderRadius:"6px",border:`1px solid ${Se}`,cursor:"pointer",fontSize:"11px",fontWeight:Q===oe.key?"bold":"normal",background:Q===oe.key?"var(--color-accent)":be,color:Q===oe.key?"var(--color-on-accent)":_e},children:oe.label},oe.key))}),dt=z.inputParameters?.http_request||z.httpRequest||{},Un=z.inputParameters?.evaluatorType||z.evaluatorType||"graaljs",ma=z.inputParameters?.kafka_request||{},ur=E=>ma[E]??z.inputParameters?.[E],Xt=z.evaluatorType||"value-param",ha=z.expression??(Xt==="value-param"?z.caseValueParam:z.caseExpression)??"",ya=E=>({expression:E,...z.caseValueParam!==void 0&&Xt==="value-param"?{caseValueParam:E}:{},...z.caseExpression!==void 0?{caseExpression:void 0}:{}});return o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`detail-panel-container ${ve}`,style:{position:"absolute",right:0,top:0,bottom:0,width:"450px",zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${Se}`,boxShadow:"var(--cm-shadow-float)",overflowY:"hidden"},children:[o.jsxs("div",{style:{padding:"24px",borderBottom:`1px solid ${Se}`,background:"var(--bg-secondary)",flexShrink:0},children:[o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:"12px"},children:[o.jsx("div",{style:{background:"var(--color-accent)",color:"var(--color-on-accent)",padding:"2px 8px",borderRadius:"4px",fontSize:"10px",fontWeight:"bold",letterSpacing:"1px"},children:z.type||"TASK"}),o.jsx("button",{onClick:r,style:{background:"none",border:"none",color:_e,cursor:"pointer",fontSize:"20px"},children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),he?o.jsx("input",{value:z.name||"",onChange:E=>Re("name",E.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)"}}):o.jsx("div",{style:{fontSize:"22px",fontWeight:"bold"},children:z.name}),o.jsxs("div",{style:{fontSize:"12px",color:ce,marginTop:"8px",fontFamily:"monospace",opacity:.8},children:["REF: ",z.taskReferenceName]})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"24px",background:"var(--bg-primary)"},children:[z.type==="HTTP"&&Le("HTTP 请求配置",Rs,"var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{display:"flex",gap:"8px",marginBottom:"12px"},children:[o.jsx("select",{value:dt.method||"GET",onChange:E=>Je("method",E.target.value),disabled:!he,style:{width:"90px",padding:"10px",borderRadius:"8px",background:be,color:_e,border:`1px solid ${Se}`,cursor:"pointer"},children:["GET","POST","PUT","DELETE","PATCH","HEAD","OPTIONS"].map(E=>o.jsx("option",{value:E,children:E},E))}),o.jsx("input",{placeholder:"URI (支持 ${workflow.input.uri})",value:dt.uri||"",onChange:E=>Je("uri",E.target.value),disabled:!he,style:{flex:1,padding:"10px",borderRadius:"8px",background:be,color:_e,border:`1px solid ${Se}`}})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"CONTENT-TYPE"}),o.jsx("input",{placeholder:"application/json",value:dt.contentType||"",onChange:E=>Je("contentType",E.target.value),disabled:!he,style:{width:"100%",padding:"8px",borderRadius:"6px",background:be,color:_e,border:`1px solid ${Se}`,fontSize:"12px"}})]}),o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"ACCEPT"}),o.jsx("input",{placeholder:"application/json",value:dt.accept||"",onChange:E=>Je("accept",E.target.value),disabled:!he,style:{width:"100%",padding:"8px",borderRadius:"6px",background:be,color:_e,border:`1px solid ${Se}`,fontSize:"12px"}})]})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"8px",marginBottom:"12px"},children:[o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"连接超时 (ms)"}),o.jsx("input",{type:"number",placeholder:"3000",value:dt.connectionTimeOut??"",onChange:E=>Je("connectionTimeOut",E.target.value===""?void 0:Number(E.target.value)),disabled:!he,style:{width:"100%",padding:"8px",borderRadius:"6px",background:be,color:_e,border:`1px solid ${Se}`,fontSize:"12px"}})]}),o.jsxs("div",{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"读取超时 (ms)"}),o.jsx("input",{type:"number",placeholder:"3000",value:dt.readTimeOut??"",onChange:E=>Je("readTimeOut",E.target.value===""?void 0:Number(E.target.value)),disabled:!he,style:{width:"100%",padding:"8px",borderRadius:"6px",background:be,color:_e,border:`1px solid ${Se}`,fontSize:"12px"}})]})]}),Pe("HEADERS (JSON)","http_headers",Ne(dt.headers),Oe(E=>Je("headers",E)),{rows:3}),Pe("BODY (RAW/JSON)","http_body",Ne(dt.body,""),ke(E=>Je("body",E===""?void 0:E)),{rows:4})]})),(z.type==="INLINE"||z.type==="LAMBDA")&&Le("内联脚本配置 (Inline)",WT,"var(--color-accent)",o.jsxs(o.Fragment,{children:[z.type==="INLINE"&&Ke("脚本引擎 (inputParameters.evaluatorType)",["graaljs","javascript","value-param","python"],Un,E=>ge("evaluatorType",E)),lt(`EXPRESSION ${Un==="value-param"?"(值引用)":"(脚本)"}`,z.inputParameters?.expression||z.inputParameters?.scriptExpression||"",E=>{const Q=z.inputParameters?.scriptExpression!==void 0?"scriptExpression":"expression";ee(Q,E)},{rows:10,language:Un==="value-param"?"text":"javascript",style:{background:"var(--cm-overlay)",color:"var(--color-accent)",border:"1px solid var(--color-accent)"}}),o.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:ce,fontStyle:"italic"},children:"提示: 使用 $.input.key 访问输入参数,返回值作为任务输出。"})]})),z.type==="JSON_JQ_TRANSFORM"&&Le("JQ 数据转换",Mu,"var(--color-accent)",o.jsxs(o.Fragment,{children:[lt("JQ QUERY EXPRESSION",z.inputParameters?.queryExpression||"",E=>ee("queryExpression",E),{rows:6,language:"jq",style:{color:"var(--color-accent)"}}),o.jsx("div",{style:{marginTop:"8px",fontSize:"10px",color:ce},children:"输出字段: result(首个结果)、resultList(完整列表)"})]})),z.type==="SUB_WORKFLOW"&&Le("子工作流配置",VT,"var(--color-accent)",o.jsxs(o.Fragment,{children:[fe("WORKFLOW NAME *",z.subWorkflowParam?.name||"",E=>De("subWorkflowParam","name",E),"text","e.g. my_workflow"),fe("VERSION",z.subWorkflowParam?.version??"",E=>De("subWorkflowParam","version",E?parseInt(E):void 0),"number","1"),Pe("INPUT PARAMETERS MAPPING (JSON)","sub_inputs",Ne(z.inputParameters),Oe(E=>Re("inputParameters",E)),{rows:5}),o.jsxs("div",{style:{fontSize:"10px",color:ce,marginTop:"4px"},children:["传递给子工作流的参数,支持 ","${workflow.input.xxx}"," 表达式"]})]})),z.type==="START_WORKFLOW"&&Le("启动工作流配置",Ot,"var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"11px",color:ce,marginBottom:"12px",padding:"8px",borderRadius:"6px",background:"var(--cm-warning-tint)",border:"1px solid color-mix(in srgb, var(--cm-status-warning) 35%, transparent)"},children:[o.jsx(At,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"注意:此任务启动目标工作流后立即继续,",o.jsx("b",{children:"不等待"}),"目标工作流完成。"]}),fe("WORKFLOW NAME *",z.inputParameters?.startWorkflow?.name||"",E=>{const Q={...z.inputParameters?.startWorkflow||{},name:E};ee("startWorkflow",Q)},"text","e.g. target_workflow"),fe("VERSION",z.inputParameters?.startWorkflow?.version??"",E=>{const Q={...z.inputParameters?.startWorkflow||{},version:E?parseInt(E):void 0};ee("startWorkflow",Q)},"number","1"),fe("CORRELATION ID",z.inputParameters?.startWorkflow?.correlationId||"",E=>{const Q={...z.inputParameters?.startWorkflow||{},correlationId:E};ee("startWorkflow",Q)},"text","${workflow.correlationId}"),Pe("WORKFLOW INPUT (JSON)","start_input",Ne(z.inputParameters?.startWorkflow?.input),Oe(E=>ee("startWorkflow",{...z.inputParameters?.startWorkflow||{},input:E})),{rows:4})]})),z.type==="TERMINATE"&&Le("终止状态配置",hn,"var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"TERMINATION STATUS"}),o.jsx("div",{style:{display:"flex",gap:"8px",marginBottom:"16px"},children:["COMPLETED","FAILED","TERMINATED"].map(E=>o.jsx("button",{onClick:()=>ee("terminationStatus",E),disabled:!he,style:{flex:1,padding:"8px",borderRadius:"6px",cursor:"pointer",background:(z.inputParameters?.terminationStatus||"COMPLETED")===E?"var(--color-accent)":be,color:(z.inputParameters?.terminationStatus||"COMPLETED")===E?"var(--color-on-accent)":_e,border:`1px solid ${Se}`,fontWeight:"bold",fontSize:"11px"},children:E},E))}),fe("TERMINATION REASON",z.inputParameters?.terminationReason||"",E=>ee("terminationReason",E),"text","终止原因..."),Pe("WORKFLOW OUTPUT (JSON)","terminate_output",Ne(z.inputParameters?.workflowOutput),Oe(E=>ee("workflowOutput",E)),{rows:3})]})),z.type==="EVENT"&&Le("事件发送配置",gb,"var(--color-accent)",o.jsxs(o.Fragment,{children:[fe("EVENT SINK *",z.sink||"",E=>Re("sink",E),"text","e.g. sqs:queue_name 或 conductor"),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"4px",marginBottom:"8px"},children:"支持前缀: conductor | sqs | kafka | amqp | nats"}),dr("异步完成 (asyncComplete)",!!z.asyncComplete,E=>Re("asyncComplete",E))]})),z.type==="WAIT"&&Le("等待状态配置",Ru,"var(--color-accent)",o.jsxs(o.Fragment,{children:[ct([{key:"duration",label:"等待时长"},{key:"until",label:"等待到指定时间"}],S,E=>Ie(E)),S==="duration"?fe("DURATION",z.inputParameters?.duration||"",E=>ee("duration",E),"text","e.g. 30s, 10m, 2 hours"):fe("UNTIL (时间点)",z.inputParameters?.until||"",E=>ee("until",E),"text","e.g. 2025-06-15 09:00 GMT+00:00"),o.jsxs("div",{style:{fontSize:"11px",color:ce,lineHeight:"1.6",marginTop:"8px"},children:["此任务会使工作流进入 ",o.jsx("b",{children:"IN_PROGRESS"})," 状态,直到时间满足或外部 API 触发完成。"]})]})),z.type==="SWITCH"&&Le("条件分支配置",Lu,"var(--color-accent)",o.jsxs(o.Fragment,{children:[Ke("评估模式 (evaluatorType)",["value-param","javascript","graaljs"],Xt,E=>Re("evaluatorType",E)),Xt==="value-param"?o.jsxs(o.Fragment,{children:[fe("EXPRESSION (inputParameters 中的参数名) *",ha,E=>ue(ya(E)),"text","e.g. switchCaseValue"),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"-4px",marginBottom:"8px"},children:"运行时取 inputParameters 中该参数的值,与分支名匹配"})]}):lt("EXPRESSION (脚本) *",ha,E=>ue(ya(E)),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}}),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"8px"},children:'分支可在图中通过右键节点→"添加分支"进行管理'})]})),z.type==="DECISION"&&Le("条件分支配置(DECISION)",Lu,"var(--color-accent)",o.jsxs(o.Fragment,{children:[fe("CASE VALUE PARAM (参数名)",z.caseValueParam||"",E=>Re("caseValueParam",E),"text","e.g. status"),lt("CASE EXPRESSION (JS,可选)",z.caseExpression||"",E=>Re("caseExpression",E),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}}),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"8px"},children:'分支可在图中通过右键节点→"添加分支"进行管理'})]})),z.type==="DO_WHILE"&&Le("循环逻辑配置",Lr,"var(--color-accent)",o.jsxs(o.Fragment,{children:[ct([{key:"condition",label:"条件循环"},{key:"items",label:"列表迭代"}],_,E=>w(E)),_==="condition"?o.jsxs(o.Fragment,{children:[lt("LOOP CONDITION (JS) *",z.loopCondition||"",E=>Re("loopCondition",E),{rows:4,language:"javascript",style:{color:"var(--color-accent)"}}),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"4px"},children:"条件为 true 时继续循环,false 时退出"})]}):o.jsxs(o.Fragment,{children:[o.jsx("label",{style:{display:"block",fontSize:"10px",color:ce,marginBottom:"4px"},children:"ITEMS (列表表达式)"}),o.jsx("input",{value:z.inputParameters?.items||"",onChange:E=>ee("items",E.target.value),disabled:!he,placeholder:"${workflow.input.myList}",style:{width:"100%",padding:"8px",borderRadius:"6px",border:`1px solid ${Se}`,background:be,color:_e,fontSize:"12px",outline:"none"}}),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"4px"},children:"引用一个数组,对每个元素执行一次循环体"})]}),o.jsx("div",{style:{marginTop:"12px"},children:fe("KEEP LAST N 次迭代",z.keepLastN??"",E=>Re("keepLastN",E?parseInt(E):void 0),"number","0 = 保留全部")})]})),z.type==="FORK_JOIN_DYNAMIC"&&Le("动态并行配置",At,"var(--color-accent)",o.jsxs(o.Fragment,{children:[ct([{key:"classic",label:"经典模式"},{key:"task",label:"任务简化"},{key:"workflow",label:"工作流简化"}],I,E=>N(E)),I==="classic"&&o.jsxs(o.Fragment,{children:[fe("DYNAMIC_FORK_TASKS_PARAM",z.dynamicForkTasksParam||"",E=>Re("dynamicForkTasksParam",E),"text","e.g. dynamic_tasks"),fe("DYNAMIC_FORK_TASKS_INPUT_PARAM",z.dynamicForkTasksInputParamName||"",E=>Re("dynamicForkTasksInputParamName",E),"text","e.g. input"),o.jsx("div",{style:{fontSize:"10px",color:ce},children:"经典模式:通过 inputParameters 传入 dynamicTasks 数组和 dynamicTasksInput 映射"})]}),I==="task"&&o.jsxs(o.Fragment,{children:[fe("FORK TASK TYPE *",Tt(z,"forkTaskType")||"",E=>ge("forkTaskType",E),"text","e.g. HTTP"),fe("FORK TASK NAME (仅 SIMPLE 任务)",Tt(z,"forkTaskName")||"",E=>ge("forkTaskName",E),"text","e.g. my_task"),fe("FORK TASK INPUTS",typeof Tt(z,"forkTaskInputs")=="string"?Tt(z,"forkTaskInputs"):"",E=>ge("forkTaskInputs",E),"text","${workflow.input.items}"),o.jsx("div",{style:{fontSize:"10px",color:ce},children:"所有分支执行相同任务类型,每个元素作为一个分支输入;以上字段写入 inputParameters"})]}),I==="workflow"&&o.jsxs(o.Fragment,{children:[fe("FORK WORKFLOW NAME *",Tt(z,"forkTaskWorkflow")||"",E=>ge("forkTaskWorkflow",E),"text","e.g. sub_workflow"),fe("WORKFLOW VERSION",Tt(z,"forkTaskWorkflowVersion")??"",E=>ge("forkTaskWorkflowVersion",E),"text","1"),fe("FORK TASK INPUTS",typeof Tt(z,"forkTaskInputs")=="string"?Tt(z,"forkTaskInputs"):"",E=>ge("forkTaskInputs",E),"text","${workflow.input.items}"),o.jsx("div",{style:{fontSize:"10px",color:ce},children:"所有分支执行相同子工作流,每个元素作为一个子工作流输入;以上字段写入 inputParameters"})]})]})),z.type==="DYNAMIC"&&Le("动态任务配置",HT,"var(--color-accent)",o.jsxs(o.Fragment,{children:[fe("DYNAMIC TASK NAME PARAM *",z.dynamicTaskNameParam||"",E=>Re("dynamicTaskNameParam",E),"text","e.g. taskToExecute"),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"4px"},children:'运行时从 inputParameters 的指定键中读取实际任务类型名(如 "HTTP"、"SIMPLE")'})]})),z.type==="HUMAN"&&Le("人工审批配置",Fu,"var(--color-accent)",o.jsxs(o.Fragment,{children:[fe("表单模板名 (userFormTemplate)",z.humanTaskDef?.userFormTemplate||"",E=>De("humanTaskDef","userFormTemplate",E),"text","e.g. approval_form"),Ke("分配策略 (assignmentCompletionStrategy)",["LEAVE_OPEN","TERMINATE"],z.humanTaskDef?.assignmentCompletionStrategy||"LEAVE_OPEN",E=>De("humanTaskDef","assignmentCompletionStrategy",E)),fe("显示名称 (displayName)",z.humanTaskDef?.displayName||"",E=>De("humanTaskDef","displayName",E),"text","审批任务")]})),z.type==="KAFKA_PUBLISH"&&Le("Kafka 推送配置",Sb,"var(--color-accent)",o.jsxs(o.Fragment,{children:[fe("BOOTSTRAP SERVERS *",ur("bootStrapServers")||"",E=>ie("kafka_request","bootStrapServers",E),"text","localhost:9092"),fe("TOPIC *",ur("topic")||"",E=>ie("kafka_request","topic",E),"text","my_topic"),fe("KEY (消息分区键)",ur("key")||"",E=>ie("kafka_request","key",E),"text",""),Pe("VALUE (消息内容)","kafka_value",Ne(ur("value"),""),ke(E=>ie("kafka_request","value",E)),{rows:4}),Pe("HEADERS (JSON)","kafka_headers",Ne(ur("headers")),Oe(E=>ie("kafka_request","headers",E)),{rows:3}),o.jsx("div",{style:{fontSize:"10px",color:ce,marginTop:"4px"},children:"以上字段写入 inputParameters.kafka_request"})]})),z.type==="SET_VARIABLE"&&Le("变量配置",kb,"var(--color-accent)",o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{fontSize:"11px",color:ce,marginBottom:"12px"},children:["在 inputParameters 中定义要设置的变量名和值,后续任务通过 ","${workflow.variables.varName}"," 访问。"]}),Pe("VARIABLES (JSON)","set_variables",Ne(z.inputParameters),Oe(E=>Re("inputParameters",E)),{rows:6})]})),o.jsxs("div",{style:{marginTop:"32px",borderTop:`1px solid ${Se}`,paddingTop:"24px"},children:[o.jsx("div",{style:{fontSize:"11px",fontWeight:"bold",marginBottom:"16px",opacity:.6,textTransform:"uppercase",letterSpacing:"1px"},children:"通用参数与属性"}),it("任务唯一引用名 (Reference Name)","taskReferenceName"),d&&d.newRef===z.taskReferenceName&&o.jsxs("div",{style:{marginBottom:"16px",padding:"10px 12px",borderRadius:"8px",background:"color-mix(in srgb, var(--cm-status-success) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--cm-status-success) 35%, transparent)",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[o.jsxs("div",{style:{fontSize:"11px",color:"var(--cm-status-success)",lineHeight:1.5},children:[o.jsxs("b",{children:[o.jsx(Ou,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"W-LSP 全图级联重构已生效"]}),o.jsx("br",{}),"引用名 ",o.jsx("code",{children:d.oldRef})," → ",o.jsx("code",{children:d.newRef}),",已自动同步 ",o.jsx("b",{children:d.replacedCount})," 处下游表达式(涉及节点:",d.affectedTasks.join(", "),")"]}),o.jsx("button",{onClick:u,style:{background:"none",border:"none",color:"var(--cm-status-success)",cursor:"pointer",fontSize:"12px",padding:"2px"},children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),it("任务描述","description"),o.jsxs("div",{style:{marginBottom:"16px"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:"6px",gap:"6px"},children:[o.jsxs("label",{style:{fontSize:"11px",color:ce,fontWeight:"600",textTransform:"uppercase",flex:1},children:["输入参数 (inputParameters) ",o.jsxs("span",{style:{opacity:.5,fontWeight:"normal"},children:["(JSON / 输入 $","{"," 自动补全)"]})]}),he&&o.jsxs("div",{style:{display:"flex",gap:"6px"},children:[o.jsxs("button",{onClick:E=>{const Q=E.currentTarget.getBoundingClientRect();O(Q),F(()=>ae=>{if(k)je(ae);else{const oe=typeof z.inputParameters=="object"&&z.inputParameters!==null?{...z.inputParameters}:{};oe[`param_${Object.keys(oe).length+1}`]=ae,Re("inputParameters",oe)}}),M(!0)},title:"打开 W-LSP 上游变量与 Schema 零延迟补全器",style:{fontSize:"11px",background:"color-mix(in srgb, var(--cm-data) 14%, transparent)",border:"1px solid color-mix(in srgb, var(--cm-data) 35%, transparent)",borderRadius:"4px",padding:"2px 8px",cursor:"pointer",color:"var(--cm-data)",fontWeight:600,display:"flex",alignItems:"center",gap:"4px"},children:[o.jsx(At,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"变量补全"]}),o.jsxs("button",{onClick:le,disabled:U,title:"AI 根据上下文自动生成 inputParameters",style:{fontSize:"11px",background:"var(--cm-ai)",border:"none",borderRadius:"4px",padding:"2px 8px",cursor:U?"not-allowed":"pointer",color:"var(--cm-surface-0)",fontWeight:600,display:"flex",alignItems:"center",gap:"4px",opacity:U?.7:1},children:[U?o.jsx(Ru,{size:12,strokeWidth:1.75,"aria-hidden":"true"}):o.jsx(Pt,{size:12,strokeWidth:1.75,"aria-hidden":"true"})," AI 填充"]}),o.jsxs("button",{onClick:()=>v(!g),title:"快捷表达式",style:{fontSize:"11px",background:g?"var(--color-accent)":"none",border:`1px solid ${Se}`,borderRadius:"4px",padding:"2px 6px",cursor:"pointer",color:g?"var(--color-on-accent)":ce},children:["{}"," 片段"]})]})]}),g&&o.jsx("div",{style:{marginBottom:"8px",padding:"8px",borderRadius:"6px",border:`1px solid ${Se}`,background:"var(--bg-secondary)",display:"flex",flexWrap:"wrap",gap:"6px"},children:n2.map(E=>o.jsx("button",{onClick:()=>je(E.value),title:E.desc,style:{fontSize:"10px",padding:"3px 8px",borderRadius:"4px",border:`1px solid ${Se}`,background:be,color:_e,cursor:"pointer",fontFamily:"monospace"},children:E.label},E.value))}),we&&o.jsxs("div",{role:"alert",style:{marginBottom:"8px",padding:"6px 10px",borderRadius:"6px",fontSize:"11px",lineHeight:1.5,display:"flex",alignItems:"flex-start",gap:"6px",color:"var(--text-secondary)",border:"1px solid color-mix(in srgb, var(--cm-status-warning) 35%, transparent)",background:"color-mix(in srgb, var(--cm-status-warning) 8%, transparent)"},children:[o.jsx(Ye,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{flexShrink:0,marginTop:1,color:"var(--cm-status-warning)"}}),o.jsx("span",{style:{flex:1},children:we}),o.jsx("button",{onClick:()=>Ce(null),"aria-label":"关闭提示",style:{background:"none",border:"none",cursor:"pointer",color:"var(--text-muted)",padding:0},children:o.jsx($e,{size:12,strokeWidth:1.75,"aria-hidden":"true"})})]}),se&&o.jsxs("div",{style:{marginBottom:"8px",borderRadius:"8px",border:"1px solid color-mix(in srgb, var(--cm-ai) 19%, transparent)",background:"color-mix(in srgb, var(--cm-ai) 3%, transparent)",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"8px 12px",background:"color-mix(in srgb, var(--cm-ai) 9%, transparent)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("span",{style:{fontSize:"11px",fontWeight:700,color:"var(--cm-ai)"},children:[o.jsx(Pt,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"AI 建议的 inputParameters"]}),o.jsxs("div",{style:{display:"flex",gap:"6px"},children:[o.jsx("button",{onClick:()=>{Re("inputParameters",se.generated),pe(null)},style:{fontSize:"11px",background:"var(--cm-ai)",color:"var(--cm-surface-0)",border:"none",borderRadius:"4px",padding:"3px 10px",cursor:"pointer",fontWeight:600,fontFamily:"inherit"},children:"应用"}),o.jsx("button",{onClick:()=>pe(null),style:{fontSize:"11px",background:"none",color:ce,border:`1px solid ${Se}`,borderRadius:"4px",padding:"3px 8px",cursor:"pointer",fontFamily:"inherit"},children:"取消"})]})]}),o.jsx("pre",{style:{margin:0,padding:"10px 12px",fontSize:"12px",fontFamily:"var(--font-mono)",overflowX:"auto",color:_e,maxHeight:"180px",overflowY:"auto"},children:JSON.stringify(se.generated,null,2)})]}),Pe("","inputParameters",Ne(z.inputParameters),Oe(E=>Re("inputParameters",E)),{rows:5,dataField:"inputParameters",style:{outline:"none"}})]}),o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:"12px"},children:[it("重试次数","retryCount","number"),fe("超时限制 (秒,taskDefinition)",ks(z,"timeoutSeconds")??"",E=>re("timeoutSeconds",E),"number","0 表示不限制")]}),o.jsxs("details",{style:{marginTop:"16px"},children:[o.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",color:ce,userSelect:"none",fontWeight:"600"},children:"▸ 执行控制(高级)"}),o.jsxs("div",{style:{marginTop:"12px"},children:[o.jsxs("div",{style:{fontSize:"11px",color:ce,marginBottom:"12px",padding:"8px",borderRadius:"6px",background:"var(--cm-warning-tint)",border:"1px solid color-mix(in srgb, var(--cm-status-warning) 35%, transparent)",lineHeight:1.6},children:[o.jsx(Ye,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"超时、重试策略、重试延迟写入任务内嵌定义 ",o.jsx("code",{children:"taskDefinition"}),"。设置后 Conductor 会用这份内嵌定义代替同名的已注册任务定义;如需沿用注册中心的配置,请在任务定义中修改。"]}),Ke("重试策略 (taskDefinition.retryLogic)",["FIXED","EXPONENTIAL_BACKOFF","LINEAR_BACKOFF"],ks(z,"retryLogic")||"FIXED",E=>re("retryLogic",E)),fe("重试延迟 (秒,taskDefinition)",ks(z,"retryDelaySeconds")??"",E=>re("retryDelaySeconds",E),"number","0"),Ke("超时策略 (taskDefinition.timeoutPolicy)",["TIME_OUT_WF","ALERT_ONLY","RETRY"],ks(z,"timeoutPolicy")||"TIME_OUT_WF",E=>re("timeoutPolicy",E)),fe("启动延迟 (秒)",z.startDelay??"",E=>Re("startDelay",E?parseInt(E):void 0),"number","0"),dr("可选任务 (optional) — 失败不影响工作流",!!z.optional,E=>Re("optional",E)),dr("异步完成 (asyncComplete)",!!z.asyncComplete,E=>Re("asyncComplete",E))]})]})]}),o.jsx("div",{style:{marginTop:"48px",opacity:.6},children:o.jsxs("details",{children:[o.jsx("summary",{style:{fontSize:"11px",cursor:"pointer",marginBottom:"8px"},children:"查看完整 JSON (只读)"}),o.jsx("pre",{style:{background:"var(--cm-surface-0)",padding:"16px",borderRadius:"8px",fontSize:"10px",overflow:"auto",border:`1px solid ${Se}`,color:ce},children:JSON.stringify(z,null,2)})]})})]}),he&&o.jsxs("div",{style:{padding:"24px",borderTop:`1px solid ${Se}`,background:"var(--bg-secondary)",display:"flex",gap:"12px",flexShrink:0},children:[o.jsxs("div",{style:{flex:1,fontSize:"11px",color:ce,display:"flex",alignItems:"center"},children:[o.jsx(Cs,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"所有修改已实时同步"]}),o.jsx("button",{onClick:r,style:{padding:"10px 24px",background:"var(--color-accent)",color:"var(--color-on-accent)",border:"none",borderRadius:"8px",fontWeight:"bold",cursor:"pointer",boxShadow:"0 4px 12px var(--color-accent-bg)"},children:"完成退出"})]}),o.jsx(e2,{isOpen:C,onClose:()=>M(!1),onSelect:q,suggestions:$,wlspItems:W,anchorRect:R})]}),L&&o.jsx(t2,{title:L.title,value:L.value,language:L.language,onSave:L.onSave,onClose:()=>H(null)})]})},a2=T.memo(s2),Nk=({keyName:e,value:t,path:r,depth:n,defaultExpanded:s,forceExpandAll:a,searchQuery:i,onCopyExpr:l,copiedPath:c,buildExpr:d})=>{const u=t!==null&&typeof t=="object",p=Array.isArray(t),[f,m]=T.useState(s),h=a!==null?a:f,y=d(r);if(!T.useMemo(()=>{if(!i.trim())return!0;const S=i.toLowerCase();if(e!==void 0&&String(e).toLowerCase().includes(S))return!0;try{return JSON.stringify(t).toLowerCase().includes(S)}catch{return!1}},[e,t,i]))return null;if(!u){let S="var(--text-primary)",j=String(t);return typeof t=="string"?(S="var(--cm-status-success)",j=`"${t}"`):typeof t=="number"?S="var(--cm-status-warning)":typeof t=="boolean"?S="var(--cm-cat-human)":t==null&&(S="var(--text-muted)",j="null"),o.jsxs("div",{className:"sjson-row",style:{paddingLeft:`${n*14}px`,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",paddingTop:"2px",paddingBottom:"2px",borderRadius:"4px",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"},children:[o.jsxs("div",{style:{wordBreak:"break-all",lineHeight:1.45},children:[e!==void 0&&o.jsxs("span",{style:{color:"var(--color-accent)"},children:[typeof e=="number"?`[${e}]`:`"${e}"`,o.jsx("span",{style:{color:"var(--text-muted)"},children:": "})]}),o.jsx("span",{style:{color:S},children:j})]}),y&&o.jsx("button",{type:"button",onClick:_=>{_.stopPropagation(),l(y)},title:`复制表达式 ${y}`,style:{flexShrink:0,fontSize:"10px",padding:"1px 6px",borderRadius:"4px",border:"1px solid color-mix(in srgb, var(--cm-data) 30%, transparent)",background:c===y?"color-mix(in srgb, var(--cm-status-success) 20%, transparent)":"color-mix(in srgb, var(--cm-data) 8%, transparent)",color:c===y?"var(--cm-status-success)":"var(--cm-data)",cursor:"pointer",opacity:.85,fontFamily:"inherit"},children:c===y?"已复制":"${} 引用"})]})}const g=p?t.map((S,j)=>[j,S]):Object.entries(t),v=p?"[":"{",k=p?"]":"}",b=p?`${g.length} items`:`${g.length} keys`;return o.jsxs("div",{children:[o.jsxs("div",{onClick:()=>m(!h),style:{paddingLeft:`${n*14}px`,display:"flex",alignItems:"center",justifyContent:"space-between",gap:"6px",paddingTop:"2px",paddingBottom:"2px",cursor:"pointer",userSelect:"none",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[o.jsx("span",{style:{color:"var(--text-muted)",width:"10px",display:"inline-flex"},children:h?o.jsx(wu,{size:10,strokeWidth:1.75,"aria-hidden":"true"}):o.jsx(pT,{size:10,strokeWidth:1.75,"aria-hidden":"true"})}),e!==void 0&&o.jsxs("span",{style:{color:"var(--color-accent)"},children:[typeof e=="number"?`[${e}]`:`"${e}"`,o.jsx("span",{style:{color:"var(--text-muted)"},children:": "})]}),o.jsxs("span",{style:{color:"var(--text-muted)"},children:[v,!h&&o.jsx("span",{style:{fontSize:"10px",color:"var(--text-muted)",margin:"0 4px"},children:b}),!h&&k]})]}),y&&r&&o.jsx("button",{type:"button",onClick:S=>{S.stopPropagation(),l(y)},title:`复制对象引用 ${y}`,style:{flexShrink:0,fontSize:"10px",padding:"1px 6px",borderRadius:"4px",border:"1px solid color-mix(in srgb, var(--cm-data) 25%, transparent)",background:c===y?"color-mix(in srgb, var(--cm-status-success) 20%, transparent)":"color-mix(in srgb, var(--cm-data) 6%, transparent)",color:c===y?"var(--cm-status-success)":"var(--cm-data)",cursor:"pointer",opacity:.75,fontFamily:"inherit"},children:c===y?"已复制":"${} 引用"})]}),h&&o.jsxs("div",{children:[g.map(([S,j])=>{const _=typeof S=="number"?`${r}[${S}]`:r?`${r}.${S}`:String(S);return o.jsx(Nk,{keyName:S,value:j,path:_,depth:n+1,defaultExpanded:n<1,forceExpandAll:a,searchQuery:i,onCopyExpr:l,copiedPath:c,buildExpr:d},String(S))}),o.jsx("div",{style:{paddingLeft:`${n*14+14}px`,color:"var(--text-muted)",fontSize:"12px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace"},children:k})]})]})},Ck=({data:e,taskReferenceName:t,expressionScope:r="output",maxHeight:n="420px"})=>{const[s,a]=T.useState(""),[i,l]=T.useState(null),[c,d]=T.useState(null),[u,p]=T.useState(!1),f=y=>y?r==="workflow.input"?`\${workflow.input.${y}}`:t?`\${${t}.${r}.${y}}`:null:null,m=y=>{navigator.clipboard.writeText(y),d(y),setTimeout(()=>d(null),1600)};return e==null||typeof e=="object"&&Object.keys(e).length===0?o.jsx("div",{style:{padding:"20px",textAlign:"center",color:"var(--text-secondary)",fontSize:"12px",background:"color-mix(in srgb, var(--cm-surface-1) 35%, transparent)",borderRadius:"8px",border:"1px solid var(--border-primary)"},children:"暂无数据 (Empty Payload)"}):o.jsxs("div",{style:{borderRadius:"8px",border:"1px solid var(--border-primary)",background:"var(--cm-overlay)",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",padding:"6px 10px",borderBottom:"1px solid var(--border-primary)",background:"var(--cm-overlay)"},children:[o.jsx("input",{type:"text",value:s,onChange:y=>a(y.target.value),placeholder:"检索字段名或值...",style:{flex:1,padding:"4px 8px",borderRadius:"5px",border:"1px solid var(--border-primary)",background:"var(--cm-overlay)",color:"var(--text-primary)",fontSize:"11px",outline:"none"}}),o.jsx("button",{type:"button",onClick:()=>l(!0),style:{fontSize:"10px",padding:"3px 7px",borderRadius:"4px",border:"1px solid var(--border-primary)",background:"transparent",color:"var(--text-secondary)",cursor:"pointer"},children:"全部展开"}),o.jsx("button",{type:"button",onClick:()=>l(!1),style:{fontSize:"10px",padding:"3px 7px",borderRadius:"4px",border:"1px solid var(--border-primary)",background:"transparent",color:"var(--text-secondary)",cursor:"pointer"},children:"折叠"}),o.jsx("button",{type:"button",onClick:()=>p(!u),style:{fontSize:"10px",padding:"3px 7px",borderRadius:"4px",border:"1px solid var(--border-primary)",background:u?"color-mix(in srgb, var(--cm-data) 18%, transparent)":"transparent",color:u?"var(--cm-data)":"var(--text-secondary)",cursor:"pointer"},children:u?"树形视图":"RAW"})]}),o.jsx("div",{style:{padding:"10px 12px",maxHeight:n,overflowY:"auto",overflowX:"auto"},children:u?o.jsx("pre",{style:{margin:0,fontSize:"11px",fontFamily:"'JetBrains Mono', 'Fira Code', monospace",color:"var(--text-primary)",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:JSON.stringify(e,null,2)}):o.jsx(Nk,{value:e,path:"",depth:0,defaultExpanded:!0,forceExpandAll:i,searchQuery:s,onCopyExpr:m,copiedPath:c,buildExpr:f})})]})},Rn=e=>e?He(e).color:"var(--text-secondary)",ap=(e,t)=>`color-mix(in srgb, ${e} ${t}%, transparent)`,o2=(e,t)=>{if(!e)return"-";const r=(t??Date.now())-e;return r<1e3?`${r}ms`:`${(r/1e3).toFixed(2)}s`},Ek=e=>e?new Date(e).toLocaleTimeString():"-",i2=({executionActions:e})=>{const{selectedTask:t,selectedTaskInstance:r,setSelectedTask:n,setSelectedTaskInstance:s,executionData:a,workflowInstance:i}=te(Ae(L=>({selectedTask:L.selectedTask,selectedTaskInstance:L.selectedTaskInstance,setSelectedTask:L.setSelectedTask,setSelectedTaskInstance:L.setSelectedTaskInstance,executionData:L.executionData,workflowInstance:L.workflowInstance}))),[l,c]=T.useState("summary"),d=T.useRef(null);T.useEffect(()=>{d.current?.scrollTo({top:0})},[l,t?.taskReferenceName]),T.useEffect(()=>{c("summary")},[t?.taskReferenceName]);const u=t?.taskReferenceName==="__workflow_global__",p=t?a?.[t.taskReferenceName]:null;if(!t||!p&&!u)return null;const f=p?.attempts??[],m=(r&&f.some(L=>L.taskId===r.taskId)?r:void 0)??f[f.length-1],h=xu(f),y=Xv(f),x=i?.workflowId??"",g=i?.status,v=p?.status,k=u?g:m?.status??v,b=k?He(k):null,S=b?.icon,j=u?i?.startTime:m?.startTime,_=u?i?.endTime:m?.endTime,w=u?i?.reasonForIncompletion:m?.reasonForIncompletion,I=u?i?.workflowId:m?.taskId,N=u?i?.input:m?.inputData,C=u?i?.output:m?.outputData,M=i?.isSandbox===!0,R={executed:"真实执行",mocked:"模拟数据",not_executed:"未执行"},O=u?void 0:m?.sandboxExecution,$=u?[]:m?.sandboxWarnings??[],B=!u&&!M&&e?.onSkipTask&&(v==="SCHEDULED"||v==="IN_PROGRESS")&&(g==="RUNNING"||g==="PAUSED"),q=!u&&!M&&e?.onRerunFromTask&&(g==="FAILED"||g==="TERMINATED"||g==="COMPLETED"||g==="TIMED_OUT"),F=B||q,A=e?.allowOperations!==!1,W=()=>{n(null),s(null)},P="var(--glass-border)",D="var(--text-secondary)",Z="var(--bg-tertiary)";return o.jsxs("div",{className:"detail-panel-container panel-enter-active",style:{position:"absolute",right:0,top:0,bottom:0,width:450,zIndex:1200,display:"flex",flexDirection:"column",background:"var(--bg-primary)",borderLeft:`1px solid ${P}`,boxShadow:"var(--cm-shadow-float)",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"20px 24px",borderBottom:`1px solid ${P}`,background:"var(--bg-secondary)",flexShrink:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[o.jsx("div",{style:{background:"var(--color-accent)",color:"var(--color-on-accent)",padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:"bold",letterSpacing:"1px",flexShrink:0},children:u?"WORKFLOW":t.type||"TASK"}),k&&b&&S&&o.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:4,fontSize:10,fontWeight:700,background:ap(Rn(k),10),color:Rn(k),letterSpacing:"0.5px",flexShrink:0},children:[o.jsx(S,{size:12,strokeWidth:1.75,"aria-hidden":"true"}),o.jsx("span",{title:k,children:b?.label})]}),o.jsx("div",{style:{flex:1}}),o.jsx("button",{onClick:W,style:{background:"none",border:"none",color:D,cursor:"pointer",fontSize:20,lineHeight:1,padding:4},children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsx("div",{style:{fontSize:20,fontWeight:700,color:"var(--text-primary)",lineHeight:1.3},children:u?"工作流全局数据":t.name}),o.jsxs("div",{style:{fontSize:12,color:D,marginTop:6,fontFamily:"monospace",opacity:.8},children:["REF: ",t.taskReferenceName]}),M&&O&&o.jsxs("div",{style:{marginTop:10,display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("span",{title:O==="executed"?"在浏览器沙箱里按 Conductor 语义真实执行":O==="mocked"?"调用外部系统的任务,返回的是模拟数据(可在模拟数据配置台修改)":"同步接口不执行脚本,本任务没有运行",style:{alignSelf:"flex-start",display:"inline-flex",alignItems:"center",gap:5,padding:"2px 8px",borderRadius:"var(--cm-radius-sm)",fontSize:11,fontWeight:600,color:O==="executed"?"var(--cm-data)":"var(--text-secondary)",background:O==="executed"?"var(--cm-data-tint)":"var(--bg-tertiary)",border:`1px solid ${P}`},children:[O==="executed"?o.jsx(Ot,{size:12,strokeWidth:1.75,"aria-hidden":"true"}):O==="mocked"?o.jsx(Es,{size:12,strokeWidth:1.75,"aria-hidden":"true"}):o.jsx(mT,{size:12,strokeWidth:1.75,"aria-hidden":"true"}),"沙箱 · ",R[O]]}),$.map((L,H)=>o.jsxs("div",{style:{display:"flex",gap:6,alignItems:"flex-start",fontSize:12,color:"var(--cm-status-warning)",lineHeight:1.5},children:[o.jsx(Ye,{size:13,strokeWidth:1.75,"aria-hidden":"true",style:{flexShrink:0,marginTop:2}}),o.jsx("span",{style:{color:"var(--text-secondary)"},children:L})]},H))]})]}),f.length>1&&o.jsxs("div",{style:{padding:"12px 24px",borderBottom:`1px solid ${P}`,background:"var(--bg-secondary)",flexShrink:0},children:[o.jsxs("div",{style:{fontSize:11,fontWeight:600,color:D,marginBottom:8,textTransform:"uppercase",letterSpacing:"0.5px"},children:["执行记录(",f.length," 次",y>0?`,${y} 轮迭代`:"尝试",h>0?`,重试 ${h} 次`:"",")"]}),o.jsx("div",{style:{display:"flex",gap:6,flexWrap:"wrap"},children:f.map((L,H)=>{const U=m?.taskId===L.taskId;return o.jsx("button",{onClick:()=>s(L),style:{padding:"4px 12px",borderRadius:20,fontSize:12,cursor:"pointer",border:`1px solid ${U?"var(--color-accent)":P}`,background:U?"var(--color-accent)":"var(--bg-tertiary)",color:U?"var(--color-on-accent)":"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},children:L.iteration?`迭代 ${L.iteration}${L.retryCount?` · 重试 ${L.retryCount}`:""}`:`尝试 ${H+1}`},L.taskId)})})]}),o.jsx("div",{style:{display:"flex",borderBottom:`1px solid ${P}`,background:"var(--bg-secondary)",flexShrink:0},children:["summary","input","output"].map(L=>{const H={summary:"概览",input:"输入 JSON",output:"输出 JSON"},U=l===L;return o.jsx("button",{onClick:()=>c(L),style:{padding:"10px 20px",background:"none",border:"none",borderBottom:`2px solid ${U?"var(--color-accent)":"transparent"}`,color:U?"var(--color-accent)":D,cursor:"pointer",fontSize:13,fontWeight:U?600:400,fontFamily:"inherit",transition:"all 0.15s"},children:H[L]},L)})}),o.jsxs("div",{ref:d,style:{flex:1,overflowY:"auto",padding:24,background:"var(--bg-primary)"},children:[l==="summary"&&o.jsxs(o.Fragment,{children:[o.jsx("div",{style:{display:"grid",gridTemplateColumns:"1fr 1fr",gap:16,marginBottom:24},children:[{label:"总耗时",value:o2(j,_)},{label:"开始时间",value:Ek(j)},{label:"结束时间",value:Ek(_)},{label:u?"Workflow ID":"Task ID",value:o.jsx("span",{style:{fontSize:10,fontFamily:"monospace",opacity:.7,wordBreak:"break-all"},children:I??"-"})}].map(({label:L,value:H})=>o.jsxs("div",{style:{padding:"12px 14px",background:Z,borderRadius:10,border:`1px solid ${P}`},children:[o.jsx("div",{style:{fontSize:10,color:D,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:6,fontWeight:600},children:L}),o.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:13},children:H})]},L))}),h>0&&o.jsxs("div",{style:{marginBottom:20,padding:"10px 14px",background:ap(Rn(v),6),border:`1px solid ${ap(Rn(v),20)}`,borderRadius:8,fontSize:12,color:Rn(v),display:"flex",alignItems:"center",gap:8},children:[o.jsx(Du,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"已重试 ",h," 次,共 ",f.length," 次尝试",y>0?`(${y} 轮迭代)`:""]}),!u&&m?.workerId&&o.jsxs("div",{style:{marginBottom:20},children:[o.jsx("div",{style:{fontSize:10,color:D,textTransform:"uppercase",letterSpacing:"0.5px",marginBottom:4,fontWeight:600},children:"Worker"}),o.jsx("div",{style:{fontSize:12,fontFamily:"monospace",color:"var(--text-primary)",opacity:.8},children:m.workerId})]}),w&&o.jsxs("div",{style:{padding:14,background:"color-mix(in srgb, var(--cm-status-failed) 8%, transparent)",borderLeft:"3px solid var(--status-failed)",borderRadius:"0 8px 8px 0",fontSize:12,color:"var(--status-failed)",lineHeight:1.6},children:[o.jsx("strong",{children:"异常信息"}),o.jsx("div",{style:{marginTop:6,opacity:.9},children:w})]}),F&&o.jsxs("div",{style:{marginTop:24,paddingTop:20,borderTop:`1px solid ${P}`},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginBottom:12},children:[o.jsx("div",{style:{fontSize:11,fontWeight:600,color:D,textTransform:"uppercase",letterSpacing:"0.5px"},children:"任务操作"}),!A&&o.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4,padding:"2px 7px",borderRadius:4,background:"color-mix(in srgb, var(--cm-status-failed) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--cm-status-failed) 25%, transparent)",color:"var(--status-failed)",fontSize:10,fontWeight:600},children:[o.jsx(jt,{size:12,strokeWidth:1.75,"aria-hidden":"true"}),"操作权限受限"]})]}),o.jsxs("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[q&&o.jsxs("button",{disabled:!A,onClick:()=>A&&e.onRerunFromTask(x,t.taskReferenceName,m?.taskId),title:A?`从任务 ${t.taskReferenceName} 处重新运行工作流`:"操作权限受限",style:A?wr:Rk,onMouseEnter:L=>!A||Object.assign(L.currentTarget.style,l2),onMouseLeave:L=>!A||Object.assign(L.currentTarget.style,wr),children:[o.jsx($u,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"从此处重新运行"]}),B&&o.jsxs("button",{disabled:!A,onClick:()=>A&&e.onSkipTask(x,t.taskReferenceName,m?.taskId),title:A?`跳过任务 ${t.taskReferenceName}`:"操作权限受限",style:A?wr:Rk,onMouseEnter:L=>!A||Object.assign(L.currentTarget.style,c2),onMouseLeave:L=>!A||Object.assign(L.currentTarget.style,wr),children:[o.jsx(Wu,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"跳过此任务"]})]})]})]}),l==="input"&&o.jsx(Ck,{data:N,taskReferenceName:u?void 0:t.taskReferenceName,expressionScope:u?"workflow.input":"input",maxHeight:"calc(100vh - 280px)"}),l==="output"&&o.jsx(Ck,{data:C,taskReferenceName:u?void 0:t.taskReferenceName,expressionScope:"output",maxHeight:"calc(100vh - 280px)"})]})]})},wr={display:"inline-flex",alignItems:"center",gap:6,padding:"7px 14px",borderRadius:8,fontSize:12,fontWeight:500,cursor:"pointer",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontFamily:"inherit",transition:"all 0.15s"},l2={...wr,borderColor:"var(--color-accent)",color:"var(--color-accent)",background:"var(--bg-primary)"},c2={...wr,borderColor:"var(--status-failed)",color:"var(--status-failed)",background:"color-mix(in srgb, var(--cm-status-failed) 8%, transparent)"},Rk={...wr,opacity:.45,cursor:"not-allowed",border:"1px solid var(--border-primary)",background:"var(--bg-secondary)",color:"var(--text-secondary)"},d2={add:"新增",mod:"修改",del:"删除",replace:"替换"},u2={add:"+",mod:"~",del:"−"};function p2({diff:e,applied:t,onApply:r,onUndo:n}){const s=e.kind==="replace"?"add":e.kind;return o.jsxs("div",{className:"diff-card",children:[o.jsxs("div",{className:"diff-head",children:[o.jsx("span",{className:`diff-badge ${s}`,children:d2[e.kind]??e.kind}),o.jsx("span",{className:"diff-summary",children:e.summary})]}),e.rows&&e.rows.length>0&&o.jsx("div",{className:"diff-list",children:e.rows.map((a,i)=>o.jsxs("div",{className:`diff-row ${a.kind}`,children:[o.jsx("div",{className:"diff-marker",children:u2[a.kind]??"·"}),o.jsx("div",{className:"diff-desc",children:a.desc})]},i))}),o.jsx("div",{className:"diff-actions",children:t?o.jsxs(o.Fragment,{children:[o.jsxs("button",{className:"diff-btn applied",disabled:!0,children:[o.jsx(_t,{size:12,strokeWidth:1.75,"aria-hidden":"true"}),"已应用"]}),o.jsxs("button",{className:"diff-btn undo",onClick:n,children:[o.jsx(qu,{size:12,strokeWidth:1.75,"aria-hidden":"true"}),"撤销"]})]}):o.jsxs("button",{className:"diff-btn apply",onClick:r,children:[o.jsx(_t,{size:12,strokeWidth:1.75,"aria-hidden":"true"}),"应用更改"]})})]})}function Ok(e,t){const r=JSON.parse(JSON.stringify(e));if(t.kind==="replace"&&t.payload)return{next:JSON.parse(JSON.stringify(t.payload)),inverse:{kind:"replace",summary:"撤销替换",rows:[],payload:e}};if(t.kind==="add"&&t.payload)return{next:JSON.parse(JSON.stringify(t.payload)),inverse:{kind:"replace",summary:"撤销生成",rows:[],payload:e}};if(!t.patch)return{next:r,inverse:{kind:t.kind,summary:"(无变更)",rows:[]}};const n=[],s=[];for(const a of t.patch)if(a.op==="patchTask"){const i=r.tasks.find(c=>c.taskReferenceName===a.ref);if(!i)continue;const l={};for(const c of Object.keys(a.set))l[c]=i[c];Object.assign(i,a.set),n.push({op:"patchTask",ref:a.ref,set:l}),s.push({kind:"mod",desc:`还原 ${a.ref} 属性`})}else if(a.op==="addEdge")r.edges=r.edges??[],r.edges.push({from:a.from,to:a.to,label:a.label}),n.push({op:"removeEdge",from:a.from,to:a.to}),s.push({kind:"del",desc:`移除边 ${a.from} → ${a.to}`});else if(a.op==="removeEdge")r.edges=(r.edges??[]).filter(i=>!(i.from===a.from&&i.to===a.to)),n.push({op:"addEdge",from:a.from,to:a.to}),s.push({kind:"add",desc:`恢复边 ${a.from} → ${a.to}`});else if(a.op==="addTask")r.tasks.push(a.task),r.edges=r.edges??[],a.removeEdges&&a.removeEdges.forEach(i=>{r.edges=r.edges.filter(l=>!(l.from===i.from&&l.to===i.to))}),a.extraEdges&&a.extraEdges.forEach(i=>r.edges.push(i)),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}`});else if(a.op==="removeTask"){const i=r.tasks.findIndex(d=>d.taskReferenceName===a.ref);if(i<0)continue;const[l]=r.tasks.splice(i,1),c=(r.edges??[]).filter(d=>d.from===a.ref||d.to===a.ref);r.edges=(r.edges??[]).filter(d=>d.from!==a.ref&&d.to!==a.ref),n.push({op:"addTask",task:l,extraEdges:c}),s.push({kind:"add",desc:`恢复 ${a.ref}`})}else if(a.op==="insertAfter"){r.tasks.push(a.task),r.edges=r.edges??[];const i=r.edges.findIndex(l=>l.from===a.after&&l.to===a.edgeTo);i>=0&&r.edges.splice(i,1),r.edges.push({from:a.after,to:a.task.taskReferenceName}),r.edges.push({from:a.task.taskReferenceName,to:a.edgeTo}),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复直连边)`})}else if(a.op==="insertBefore"){r.tasks.push(a.task),r.edges=r.edges??[];const i=r.edges.filter(l=>l.to===a.before);r.edges=r.edges.filter(l=>l.to!==a.before),i.forEach(l=>r.edges.push({from:l.from,to:a.task.taskReferenceName,label:l.label})),r.edges.push({from:a.task.taskReferenceName,to:a.before}),n.push({op:"removeTask",ref:a.task.taskReferenceName}),s.push({kind:"del",desc:`移除 ${a.task.taskReferenceName}(恢复原有入边)`})}return{next:r,inverse:{kind:t.kind,summary:`撤销:${t.summary}`,rows:s,patch:n.reverse()}}}function f2(e){const t=e.match(/```diff-json\n([\s\S]*?)\n```/);if(!t)return null;try{const r=JSON.parse(t[1]);return!r.kind||!r.summary?null:r}catch{return null}}const Pk={id:"1",role:"ai",content:"你好!我是您的流程助手。我可以帮你生成工作流框架、优化逻辑或提供参数配置建议。你想实现什么样的流程?"},Ak=e=>e.split(/(```[\s\S]*?```)/).map((r,n)=>{if(r.startsWith("```")&&r.endsWith("```")){const s=r.slice(3,-3),a=s.indexOf(`
|
|
265
|
+
`),i=a>=0?s.slice(a+1):s;return o.jsx("pre",{children:o.jsx("code",{children:i})},n)}return o.jsx("span",{children:m2(r)},n)}),m2=e=>{const t=[],r=/(\*\*[^*]+\*\*|`[^`]+`|\n)/g;let n=0,s;for(;(s=r.exec(e))!==null;){s.index>n&&t.push(e.slice(n,s.index));const a=s[0];a.startsWith("**")&&a.endsWith("**")?t.push(o.jsx("strong",{children:a.slice(2,-2)},s.index)):a.startsWith("`")&&a.endsWith("`")?t.push(o.jsx("code",{children:a.slice(1,-1)},s.index)):a===`
|
|
266
|
+
`&&t.push(o.jsx("br",{},s.index)),n=s.index+a.length}return n<e.length&&t.push(e.slice(n)),t},h2=({aiConfig:e})=>{const{workflowDef:t,setWorkflow:r,mode:n}=te(Ae(O=>({workflowDef:O.workflowDef,setWorkflow:O.setWorkflow,mode:O.mode}))),[s,a]=T.useState(!1),[i,l]=T.useState(""),[c,d]=T.useState(!1),[u,p]=T.useState([Pk]),[f,m]=T.useState(""),[h,y]=T.useState(null),x=T.useRef(null),g=T.useRef(null),v=T.useRef(null),k=T.useCallback(O=>{if(!O.diff||O.applied||!t)return;const{next:$,inverse:B}=Ok(t,O.diff);r($),p(q=>q.map(F=>F.id===O.id?{...F,applied:!0,inverse:B}:F))},[t,r]),b=T.useCallback(O=>{if(!O.inverse||!O.applied||!t)return;const{next:$}=Ok(t,O.inverse);r($),p(B=>B.map(q=>q.id===O.id?{...q,applied:!1,inverse:void 0}:q))},[t,r]),S=()=>{const O=g.current;O&&(O.style.height="auto",O.style.height=Math.min(O.scrollHeight,120)+"px")},j=()=>{const O=g.current;O&&(O.style.height="auto")};T.useEffect(()=>()=>{v.current?.abort()},[]),T.useEffect(()=>{const O=()=>a(!0);return window.addEventListener("open-ai-chat",O),()=>window.removeEventListener("open-ai-chat",O)},[]);const _=()=>{x.current?.scrollIntoView({behavior:"smooth"})};T.useEffect(()=>{s&&_()},[u,s,f]);const w=T.useCallback(O=>{const $=[{role:"system",content:HN}];for(const q of u)q.role==="user"&&q.content?$.push({role:"user",content:q.content}):q.role==="ai"&&q.content&&!q.thinking&&$.push({role:"assistant",content:q.content});const B=XN(O,t);return $.push({role:"user",content:B}),$},[u,t]),I=async O=>{const $=i.trim();if(!$||c)return;v.current?.abort();const B=new AbortController;v.current=B;const q={id:Date.now().toString(),role:"user",content:$};p(F=>[...F,q]),l(""),j(),d(!0),m("");try{const F={...e??{}};if(!En(F)){setTimeout(()=>{if(B.signal.aborted)return;const L=!t||(t.tasks??[]).length===0,H={name:"demo_approval_workflow",description:"演示审批流程",tasks:[{name:"submit_request",taskReferenceName:"submit_request",type:"SIMPLE",inputParameters:{}},{name:"human_approval",taskReferenceName:"human_approval",type:"HUMAN",inputParameters:{}},{name:"process_result",taskReferenceName:"process_result",type:"SIMPLE",inputParameters:{}}]},U="未配置 AI 服务,AI 助手暂时只能演示。请由集成方通过 `aiConfig` 传入 API Key 或代理服务(演示站点可点击标题栏的「AI 配置」按钮填写)后重试。",K=L?{id:(Date.now()+1).toString(),role:"ai",content:`**演示模式**:${U}
|
|
267
|
+
|
|
268
|
+
下面是一个示例审批流程,可应用到空白画布上体验。`,diff:{kind:"replace",summary:"生成三步审批流程(演示)",rows:[{kind:"add",desc:"submit_request — 提交申请任务"},{kind:"add",desc:"human_approval — 人工审批任务"},{kind:"add",desc:"process_result — 处理审批结果"}],payload:H}}:{id:(Date.now()+1).toString(),role:"ai",content:`**演示模式**:${U}
|
|
269
|
+
|
|
270
|
+
当前画布已有工作流,演示模式不会改动它。`};p(se=>[...se,K]),d(!1)},800);return}const A=w($),W=await qN(A,F,L=>{m(H=>H+L)},()=>{},B.signal);let D=f2(W);if(!D){const L=W.match(/```json\n([\s\S]*?)\n```/);if(L)try{const H=JSON.parse(L[1]);D={kind:"replace",summary:"应用 AI 生成的工作流",rows:[{kind:"add",desc:"全量替换为 AI 生成的工作流定义"}],payload:H}}catch{}}const Z={id:(Date.now()+1).toString(),role:"ai",content:W,diff:D??void 0,applied:!1};p(L=>[...L,Z]),m("")}catch(F){if(F.name==="AbortError")m(A=>{if(A){const W={id:(Date.now()+1).toString(),role:"ai",content:A};p(P=>[...P,W])}return""});else{const A={id:Date.now().toString(),role:"ai",content:`**出错了**:${F?.message||"AI 服务返回了无法识别的错误。请重试;如持续出现,请联系管理员。"}`};p(W=>[...W,A]),m("")}}finally{d(!1)}},N=()=>{v.current?.abort()},C=()=>{v.current?.abort(),p([Pk]),m(""),d(!1)},M=O=>{navigator.clipboard.writeText(O.content??""),y(O.id),setTimeout(()=>y(null),1500)},R=O=>{O.nativeEvent.isComposing||O.keyCode===229||O.key==="Enter"&&!O.shiftKey&&(O.preventDefault(),I())};return n!=="edit"?null:s?o.jsxs("div",{className:"ai-chat-panel",children:[o.jsxs("div",{className:"ai-header",children:[o.jsxs("div",{className:"ai-title",children:[o.jsx("span",{className:"ai-sparkles",children:o.jsx(Pt,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),"AI 助手"]}),o.jsxs("div",{style:{display:"flex",gap:"4px",alignItems:"center"},children:[o.jsx("button",{className:"ai-close",onClick:C,title:"清空对话",children:o.jsx($s,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsx("button",{className:"ai-close",onClick:()=>a(!1),children:"×"})]})]}),o.jsxs("div",{className:"ai-messages",children:[u.map(O=>o.jsxs("div",{className:`message ${O.role}`,children:[o.jsx("div",{className:"message-content",children:O.thinking?o.jsxs("div",{className:"thinking-skeleton",children:[o.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),o.jsx("div",{className:"skeleton-line",style:{width:"60%"}})]}):O.role==="ai"?Ak(O.content??""):O.content}),O.diff&&!O.thinking&&o.jsx(p2,{diff:O.diff,applied:O.applied??!1,onApply:()=>k(O),onUndo:()=>b(O)}),O.role==="ai"&&O.content&&o.jsx("button",{className:"copy-btn",onClick:()=>M(O),title:"复制",children:h===O.id?o.jsx(_t,{size:14,strokeWidth:1.75,"aria-hidden":"true"}):o.jsx(db,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]},O.id)),c&&f&&o.jsxs("div",{className:"message ai",style:{opacity:.9},children:[o.jsx("div",{className:"message-content",children:Ak(f)}),o.jsx("span",{className:"streaming-cursor",children:"▊"})]}),c&&!f&&o.jsxs("div",{className:"message ai thinking-skeleton",children:[o.jsx("div",{className:"skeleton-line",style:{width:"80%"}}),o.jsx("div",{className:"skeleton-line",style:{width:"60%"}}),o.jsx("div",{className:"skeleton-line",style:{width:"70%"}})]}),o.jsx("div",{ref:x})]}),o.jsx("div",{className:"ai-input-area",children:o.jsxs("div",{className:"ai-input-container",children:[o.jsx("textarea",{ref:g,className:"ai-input",placeholder:c?"AI 正在响应...":"描述您的需求…(Shift+Enter 换行)",value:i,onChange:O=>l(O.target.value),onInput:S,onKeyDown:R,disabled:c,rows:2}),c?o.jsx("button",{className:"ai-send stop",onClick:N,title:"停止生成","aria-label":"停止生成",children:o.jsx(hn,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}):o.jsx("button",{className:"ai-send",onClick:()=>I(),title:"发送",children:o.jsx(mn,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]})})]}):o.jsx("div",{className:"ai-chat-panel collapsed",onClick:()=>a(!0),children:o.jsx("div",{className:"ai-header",style:{borderBottom:"none"},children:o.jsxs("div",{className:"ai-title",children:[o.jsx("span",{className:"ai-sparkles",children:o.jsx(Pt,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),"AI 助手"]})})})},y2=({workflowName:e,version:t,className:r})=>o.jsxs("p",{className:`cm-unsaved-run-notice${r?` ${r}`:""}`,role:"status","data-testid":"unsaved-run-notice",children:[o.jsx(Ye,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),o.jsxs("span",{children:["画布有未保存的修改。将运行已保存的版本(",o.jsx("code",{children:e})," v",t??1,"), 这些修改不会参与本次执行;要验证修改,先保存再执行。"]})]}),g2=new Set(["true","1","yes","y","是"]),x2=new Set(["false","0","no","n","否"]);function v2(e,t){const r={},n={};for(const s of e){const a=(t[s.name]??"").trim();if(a===""){s.defaultValue!==void 0?r[s.name]=s.defaultValue:s.required===!0&&(n[s.name]=`请填写「${s.name}」,它是必填参数`);continue}switch(s.type){case"number":{const i=Number(a);Number.isFinite(i)?r[s.name]=i:n[s.name]=`「${s.name}」需要数字,例如 10 或 3.5`;break}case"boolean":{const i=a.toLowerCase();g2.has(i)?r[s.name]=!0:x2.has(i)?r[s.name]=!1:n[s.name]=`「${s.name}」需要 true 或 false`;break}case"object":case"array":{try{const i=JSON.parse(a);(s.type==="array"?Array.isArray(i):i!==null&&typeof i=="object"&&!Array.isArray(i))?r[s.name]=i:n[s.name]=s.type==="array"?`「${s.name}」需要 JSON 数组,例如 ["a", "b"]`:`「${s.name}」需要 JSON 对象,例如 {"key": "value"}`}catch{n[s.name]=s.type==="array"?`「${s.name}」不是有效的 JSON 数组,例如 ["a", "b"]`:`「${s.name}」不是有效的 JSON 对象,例如 {"key": "value"}`}break}case"string":r[s.name]=t[s.name];break;default:{if(a.startsWith("{")&&a.endsWith("}")||a.startsWith("[")&&a.endsWith("]"))try{r[s.name]=JSON.parse(a);break}catch{}r[s.name]=t[s.name]}}}return{input:r,errors:n}}const b2=new Set(["COMPLETED","FAILED","TIMED_OUT","TERMINATED"]);function k2(e){const{workflowId:t,poll:r,onInstance:n,onDone:s,onGiveUp:a,shouldContinue:i=()=>!0,maxInterval:l=15e3,maxFailures:c=5,setTimer:d=(b,S)=>setTimeout(b,S),clearTimer:u=b=>clearTimeout(b)}=e;let p=e.interval??3e3,f=0,m=null,h=!1;const y=new AbortController,x=()=>{h||(h=!0,m!==null&&u(m),m=null,y.abort())};e.signal&&(e.signal.aborted?x():e.signal.addEventListener("abort",x,{once:!0}));const g=()=>{h||(m=d(k,p),p=Math.min(p*1.5,l))},v=b=>{if(f+=1,f>=c){x(),a?.(`连续 ${f} 次没有拿到运行 ${t} 的状态(${b}),已停止刷新。请检查 Conductor 服务与网络后重新运行,或在 Conductor 控制台查看这次运行。`);return}g()};async function k(){if(m=null,h)return;if(!i()){x();return}let b;try{b=await r(t,y.signal)}catch(S){if(h)return;v(S instanceof Error&&S.message?S.message:"请求失败");return}if(!h){if(!i()){x();return}if(!b){v("接口返回为空");return}if(f=0,n(b),b2.has(b.status)){x(),s?.(b);return}g()}}return g(),{cancel:x,get cancelled(){return h}}}const w2=({onTriggerExecution:e,onPollExecution:t,executionPollInterval:r=3e3})=>{const{workflowDef:n,showRunPanel:s,setShowRunPanel:a,setRunState:i,importExecutionJSON:l,setMode:c,hasUnsavedChanges:d}=te(Ae(R=>({workflowDef:R.workflowDef,hasUnsavedChanges:R.showRunPanel&&R.workflowDef!==null&&R.hasUnsavedChanges(),showRunPanel:R.showRunPanel,setShowRunPanel:R.setShowRunPanel,setRunState:R.setRunState,importExecutionJSON:R.importExecutionJSON,setMode:R.setMode}))),[u,p]=T.useState("form"),[f,m]=T.useState({}),[h,y]=T.useState("{}"),[x,g]=T.useState(""),[v,k]=T.useState(!1),[b,S]=T.useState(""),j=St(n?.inputParameters,n),_=T.useRef(null);T.useEffect(()=>{const R=te.subscribe((O,$)=>{$.mode==="run"&&O.mode!=="run"&&_.current&&(_.current.cancel(),_.current=null,O.runState==="polling"&&O.setRunState("idle"))});return()=>{R(),_.current?.cancel(),_.current=null}},[]),T.useEffect(()=>{s&&(m({}),y("{}"),g(""),S(""),k(!1))},[s]);const w=T.useCallback(()=>{try{const R={};j.forEach(O=>{const $=f[O.name];if($!==void 0&&$!=="")if(O.type==="number")R[O.name]=Number($);else if(O.type==="boolean")R[O.name]=$==="true";else if(O.type==="object"||O.type==="array")try{R[O.name]=JSON.parse($)}catch{R[O.name]=$}else R[O.name]=$;else O.defaultValue!==void 0&&(R[O.name]=O.defaultValue)}),y(JSON.stringify(R,null,2))}catch{}p("json")},[f,j]),I=T.useCallback(()=>{try{const R=JSON.parse(h),O={};j.forEach($=>{const B=R[$.name];B!==void 0&&(O[$.name]=typeof B=="object"?JSON.stringify(B,null,2):String(B))}),m(O),g("")}catch{g("JSON 格式有误,无法切换为表单模式")}p("form")},[h,j]),N=T.useCallback(()=>{if(u==="json")try{return JSON.parse(h)}catch{return g("JSON 格式有误,请检查后重试"),null}const{input:R,errors:O}=v2(j,f),$=Object.values(O);return $.length>0?(S($.join(";")),null):R},[u,h,f,j]),C=T.useCallback(async()=>{if(!e||!n)return;const R=N();if(R===null)return;const O=j.filter($=>$.required&&(R[$.name]===void 0||R[$.name]===""));if(O.length>0){S(`必填参数未填写:${O.map($=>$.name).join(", ")}`);return}k(!0),S(""),i("triggering",null,null);try{const{workflowId:$}=await e(n.name,n.version??1,R);if(i("polling",$),a(!1),c("run"),!t)return;_.current?.cancel(),_.current=k2({workflowId:$,poll:B=>t(B),interval:r,maxInterval:15e3,maxFailures:5,shouldContinue:()=>te.getState().mode==="run",onInstance:B=>l(B),onDone:()=>i("done",$,null),onGiveUp:B=>i("error",$,B)})}catch($){const B=$?.message||"执行触发失败,请检查配置后重试";i("error",null,B),S(B),k(!1)}},[e,t,n,N,j,i,a,l,c,r]);if(!s||!n)return null;const M=j.length>0;return o.jsx("div",{className:"wrp-overlay",onClick:()=>a(!1),children:o.jsxs("div",{className:"wrp-panel",onClick:R=>R.stopPropagation(),children:[o.jsxs("div",{className:"wrp-header",children:[o.jsxs("div",{className:"wrp-header-title",children:[o.jsx(Ot,{size:16,strokeWidth:1.75,"aria-hidden":"true",style:{color:"var(--status-completed)"}}),"执行验证"]}),o.jsxs("div",{className:"wrp-workflow-name",children:[n.name," ",o.jsxs("span",{className:"wrp-version",children:["v",n.version??1]})]}),o.jsx("button",{className:"wrp-close",onClick:()=>a(!1),children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsxs("div",{className:"wrp-content",children:[o.jsxs("div",{className:"wrp-section-label",children:["工作流输入参数",M&&o.jsxs("div",{className:"wrp-mode-toggle",children:[o.jsx("button",{className:u==="form"?"active":"",onClick:u==="json"?I:void 0,children:"表单模式"}),o.jsx("button",{className:u==="json"?"active":"",onClick:u==="form"?w:void 0,children:"JSON 编辑器"})]})]}),!M&&u==="form"&&o.jsxs("p",{className:"wrp-hint",children:["该工作流未声明输入参数。你可以在 ",o.jsx("strong",{children:"工作流设置 → 参数配置"})," 中添加,也可以直接在 JSON 编辑器中手动填写。"]}),u==="form"?o.jsxs("div",{className:"wrp-form",children:[j.map(R=>o.jsxs("div",{className:"wrp-field",children:[o.jsxs("label",{className:"wrp-field-label",children:[R.name,R.required&&o.jsx("span",{className:"wrp-required",children:"*"}),R.type&&o.jsx("span",{className:"wrp-type",children:R.type})]}),R.description&&o.jsx("p",{className:"wrp-field-desc",children:R.description}),R.type==="object"||R.type==="array"?o.jsx("textarea",{className:"wrp-input",rows:3,placeholder:R.example?JSON.stringify(R.example,null,2):"{}",value:f[R.name]??"",onChange:O=>m($=>({...$,[R.name]:O.target.value}))}):R.type==="boolean"?o.jsxs("select",{className:"wrp-input",value:f[R.name]??(R.defaultValue!==void 0?String(R.defaultValue):""),onChange:O=>m($=>({...$,[R.name]:O.target.value})),children:[o.jsx("option",{value:"",children:"请选择"}),o.jsx("option",{value:"true",children:"true"}),o.jsx("option",{value:"false",children:"false"})]}):o.jsx("input",{className:"wrp-input",type:R.type==="number"?"number":"text",placeholder:R.example!==void 0?String(R.example):R.defaultValue!==void 0?String(R.defaultValue):"",value:f[R.name]??"",onChange:O=>m($=>({...$,[R.name]:O.target.value}))})]},R.name)),!M&&o.jsx("button",{className:"wrp-switch-json",onClick:w,children:"切换为 JSON 编辑器手动填写"})]}):o.jsxs("div",{className:"wrp-json-editor",children:[o.jsx("textarea",{className:"wrp-input wrp-json",rows:12,value:h,onChange:R=>{y(R.target.value),g("")},spellCheck:!1,placeholder:'{\\n "key": "value"\\n}'}),x&&o.jsx("p",{className:"wrp-error",children:x})]}),b&&o.jsx("p",{className:"wrp-error wrp-submit-error",children:b}),d&&e&&o.jsx(y2,{workflowName:n.name,version:n.version})]}),o.jsxs("div",{className:"wrp-footer",children:[o.jsx("button",{className:"wrp-btn wrp-btn-cancel",onClick:()=>a(!1),children:"取消"}),e?o.jsx("button",{className:"wrp-btn wrp-btn-execute",onClick:C,disabled:v,children:v?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"wrp-spinner"}),"执行中..."]}):o.jsxs(o.Fragment,{children:[o.jsx(Ot,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"发起执行"]})}):o.jsx("span",{className:"wrp-hint-inline",children:"未配置 onTriggerExecution 回调"})]})]})})},$k={activity:bu,alert:Ye,book:dT,flag:wT,flame:Eu,library:yb,lightbulb:Os,lock:NT,map:CT,pause:Au,undo:qu,wrench:Eb,approval:_t,clipboard:Tu,mail:gb,pointer:PT,x:$e,ban:ku,bell:cT,"bell-ring":lT,braces:cb,chart:Ns,circle:ju,clock:Iu,cloud:hT,code:Nu,database:ub,"file-text":Cu,folder:pb,branch:br,merge:pn,globe:Rs,"hard-drive":ST,hourglass:Ru,key:hb,megaphone:ET,message:vb,monitor:RT,moon:OT,package:kb,pencil:fn,play:Ot,plug:wb,puzzle:$T,radio:DT,refresh:Ps,repeat:Lr,rocket:mn,save:MT,scale:Lu,search:Mu,send:Sb,server:zT,settings:_b,shield:jb,shuffle:Mr,smartphone:FT,sparkles:Pt,stop:hn,"stop-circle":Su,sunrise:BT,terminal:Nb,trash:$s,upload:Cb,user:Fu,zap:At},S2={"📢":"megaphone","📣":"megaphone","👤":"user","⏳":"hourglass","⌛":"hourglass","🔀":"shuffle","⚡":"zap","🔁":"repeat","🔄":"refresh","🖥":"server","💻":"terminal","🔍":"search","🔎":"search","▶":"play","⏹":"stop","💾":"save","📊":"chart","📈":"chart","🗑":"trash","🚀":"rocket","🛡":"shield","🌙":"moon","🌅":"sunrise","💽":"hard-drive","🚨":"bell-ring","⚙":"settings","🌐":"globe","📦":"package","📡":"radio","🛑":"stop-circle","📝":"pencil","📨":"send","🔗":"merge","🧩":"puzzle","📱":"smartphone","💬":"message","📸":"save","⚖":"scale","🗂":"folder","🔑":"key","📤":"upload","🔢":"braces","✅":"approval","🔌":"plug","📁":"folder","☁":"cloud","🗄":"database","📄":"file-text","🔔":"bell","✨":"sparkles","🤖":"sparkles","🧪":"sparkles","⏰":"clock","🕐":"clock","📧":"mail","✉":"mail","📋":"clipboard","👆":"pointer","⚠":"alert","❌":"x","✓":"approval","✔":"approval","🎉":"sparkles","✦":"sparkles","🔥":"flame","💡":"lightbulb","📖":"book","🏁":"flag","🔒":"lock","⏸":"pause","↩":"undo","🔧":"wrench","📚":"library","🗺":"map","✏":"pencil","🔴":"x","🔵":"activity"};function _2(e){if(!e)return null;const t=e.trim();return t in $k?t:S2[t.replace(/️/g,"")]??null}function We({name:e,size:t=16,fallback:r="settings",style:n,className:s}){const a=$k[_2(e)??r];return o.jsx(a,{size:t,strokeWidth:1.75,"aria-hidden":"true",style:n,className:s})}const j2=[{pattern:/NullPointerException|null.*inputData|inputData.*null/i,category:"parameter",title:"参数引用为空",explanation:"某个 inputParameters 字段引用的上游任务输出为 null。请检查 JSONPath 表达式,确认前序任务确实返回了对应字段。",suggestEditParam:"inputParameters"},{pattern:/PathNotFoundException|No results for path|path not found/i,category:"parameter",title:"JSONPath 路径不存在",explanation:"参数中的 JSONPath 表达式(如 ${task.output.field})在实际执行数据中找不到对应路径。请核查前序任务的实际输出结构。",suggestEditParam:"inputParameters"},{pattern:/ClassCastException|cannot cast|type mismatch/i,category:"parameter",title:"参数类型不匹配",explanation:"输入参数的数据类型与任务期望不符(如将字符串传给了数字类型参数)。请检查参数值的类型。",suggestEditParam:"inputParameters"},{pattern:/Connection refused|connect.*timeout|SocketException/i,category:"network",title:"网络连接失败",explanation:"无法连接到目标服务器。请检查 HTTP 任务的 uri 是否正确,以及目标服务是否可访问。",suggestEditParam:"uri"},{pattern:/HTTP.*4\d\d|status.*4\d\d|4\d\d.*status/i,category:"network",title:"HTTP 客户端错误",explanation:"HTTP 请求返回 4xx 错误,通常由请求参数、认证或权限问题引起。请检查 uri、headers、body 配置。",suggestEditParam:"inputParameters"},{pattern:/HTTP.*5\d\d|status.*5\d\d|5\d\d.*status/i,category:"network",title:"HTTP 服务端错误",explanation:"目标服务返回 5xx 错误,服务端发生异常。可尝试重试,或检查传入的请求体是否符合服务端期望。",suggestEditParam:"inputParameters"},{pattern:/Unauthorized|401|authentication|auth.*failed/i,category:"auth",title:"认证失败",explanation:"请求被拒绝,认证信息无效或缺失。请检查 headers 中的 Authorization 或 token 参数配置。",suggestEditParam:"inputParameters"},{pattern:/timeout|timed.?out|TIMED_OUT/i,category:"timeout",title:"任务超时",explanation:"任务执行时间超过配置的超时阈值。可考虑增大 timeoutSeconds,或优化被调用服务的响应速度。",suggestEditParam:"timeoutSeconds"},{pattern:/loopCondition|loop.*condition|condition.*false/i,category:"logic",title:"循环条件配置问题",explanation:"DO_WHILE 的 loopCondition 表达式可能无法正常求值。请检查条件表达式引用的变量是否正确。",suggestEditParam:"loopCondition"},{pattern:/expression.*error|script.*error|evaluator.*failed/i,category:"logic",title:"脚本表达式错误",explanation:"INLINE/LAMBDA 任务的脚本表达式执行时出错。请检查 expression 或 scriptExpression 的语法和逻辑。",suggestEditParam:"inputParameters"}];function T2(e,t){const r=t[e];if(!r)return[];const n=r.reasonForIncompletion||"";if(!n)return[];const s=[];for(const a of j2)a.pattern.test(n)&&s.push({category:a.category,title:a.title,explanation:a.explanation,suggestEditParam:a.suggestEditParam});return s.length===0&&n.length>0&&s.push({category:"logic",title:"执行异常",explanation:`任务执行失败,原因:${n.slice(0,200)}${n.length>200?"...":""}`}),s}function I2(e,t){const r=Object.values(e).map(f=>{const m=f.startTime&&f.endTime?f.endTime-f.startTime:void 0,h=xu(f.attempts),y=Xv(f.attempts);return{taskRef:f.taskReferenceName,status:f.status,startTime:f.startTime,endTime:f.endTime,durationMs:m,retryCount:h,iterationCount:y,reasonForIncompletion:f.reasonForIncompletion,diagnostics:T2(f.taskReferenceName,e)}}).sort((f,m)=>(f.startTime??0)-(m.startTime??0)),n=r.filter(f=>f.status==="COMPLETED"||f.status==="COMPLETED_WITH_ERRORS").length,s=r.filter(f=>He(f.status).isFailure).length,a=r.filter(f=>f.status==="SKIPPED").length,i=r.flatMap(f=>[f.startTime,f.endTime]).filter(f=>!!f),l=i.length?Math.min(...i):0,d=(i.length?Math.max(...i):0)-l,u=t?.status,p=u==="FAILED"||u==="TIMED_OUT"||u==="TERMINATED"||s>0;return{totalTasks:r.length,completedTasks:n,failedTasks:s,skippedTasks:a,totalDurationMs:d,steps:r,hasFailed:p}}function Dk(e){return e===void 0||e<0?"-":e<1e3?`${e}ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`}function N2(e){return{parameter:"settings",timeout:"clock",auth:"lock",network:"globe",logic:"wrench"}[e]??"alert"}function C2(e){return{parameter:"var(--cm-status-warning)",timeout:"var(--cm-status-warning)",auth:"var(--cm-status-failed)",network:"var(--cm-status-failed)",logic:"var(--cm-status-failed)"}[e]??"var(--cm-status-warning)"}const or={CREDENTIAL_KEY:/(token|secret|password|passwd|authorization|apikey|api_key|webhook|access_key|private_key|auth)/i,PRIVATE_IP:/\b(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})\b/,PHONE:/\b1[3-9]\d{9}\b/,EMAIL:/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/,CLOUD_RESOURCE_ID:/\b(i|d|s|vpc|vsw|sg|disk|snap)-[a-z0-9]{8,24}\b/i};function Js(e,t,r,n=[]){if(!e||typeof e!="object")return n;for(const[s,a]of Object.entries(e)){if(s==="_actionId"||s==="actionName")continue;const i=`${r}.${s}`;if(a!=null)if(typeof a=="string"){if(or.CREDENTIAL_KEY.test(s)&&a.length>5){n.push({id:`finding_${n.length+1}`,kind:"credential",path:i,taskRef:t,keyName:s,rawValue:a,maskedValue:"",suggestedVarName:`${s}_凭证密钥`,action:"variable"});continue}if(or.PRIVATE_IP.test(a)){n.push({id:`finding_${n.length+1}`,kind:"network",path:i,taskRef:t,keyName:s,rawValue:a,maskedValue:a.replace(or.PRIVATE_IP,"172.16.0.42"),suggestedVarName:`${s}_内网IP`,action:"mask"});continue}if(or.PHONE.test(a)){n.push({id:`finding_${n.length+1}`,kind:"pii",path:i,taskRef:t,keyName:s,rawValue:a,maskedValue:a.replace(or.PHONE,"13800138000"),suggestedVarName:"通知联系手机",action:"mask"});continue}if(or.EMAIL.test(a)){n.push({id:`finding_${n.length+1}`,kind:"pii",path:i,taskRef:t,keyName:s,rawValue:a,maskedValue:a.replace(or.EMAIL,"ops-notify@example.com"),suggestedVarName:"接收人邮箱",action:"mask"});continue}if(or.CLOUD_RESOURCE_ID.test(a)&&!a.includes("${")){n.push({id:`finding_${n.length+1}`,kind:"resourceId",path:i,taskRef:t,keyName:s,rawValue:a,maskedValue:"i-bp18a9z3j42m09a",suggestedVarName:`${s}_云资源ID`,action:"variable"});continue}}else typeof a=="object"&&Js(a,t,i,n)}return n}function Lk(e){const t=[];return(e.tasks||[]).forEach((r,n)=>{const s=`tasks[${n}].inputParameters`;r.inputParameters&&Js(r.inputParameters,r.taskReferenceName,s,t),r.httpRequest&&Js(r.httpRequest,r.taskReferenceName,`tasks[${n}].httpRequest`,t)}),t}const Mk=/(debug|fallback|compensate|retry|temporary|temp|log_dump|tracer)/i;function Wk(e,t){const r=[],n=e.tasks||[];for(const s of n){if(Mk.test(s.name)||Mk.test(s.taskReferenceName)){r.push({taskReferenceName:s.taskReferenceName,taskName:s.name,taskType:s.type,reason:"检测到任务名称含调试/单次补偿/临时特征,建议从公共通用模板中剔除。",selected:!0});continue}if(t){const a=t.tasks.find(i=>i.referenceTaskName===s.taskReferenceName);a&&a.status==="SKIPPED"&&r.push({taskReferenceName:s.taskReferenceName,taskName:s.name,taskType:s.type,reason:"该任务在生产历史执行中被判定跳过 (SKIPPED),通常属于特殊条件下的低频补偿分支。",selected:!1})}}return r}function zk(e,t){const r=structuredClone(e);return r.tasks=(r.tasks||[]).filter(n=>!t.has(n.taskReferenceName)),r}function Us(e){if(!e||typeof e!="object")return e;if(Array.isArray(e))return e.map(Us);const t={};for(const[r,n]of Object.entries(e))typeof n=="string"?/(token|secret|password|authorization|apikey)/i.test(r)&&n.length>5?t[r]="":/\b1[3-9]\d{9}\b/.test(n)?t[r]=n.replace(/\b1[3-9]\d{9}\b/,"13800138000"):/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/.test(n)?t[r]=n.replace(/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}\b/,"ops-notify@example.com"):/\b(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})\b/.test(n)?t[r]=n.replace(/\b(10\.\d{1,3}\.\d{1,3}\.\d{1,3}|172\.(1[6-9]|2\d|3[01])\.\d{1,3}\.\d{1,3}|192\.168\.\d{1,3}\.\d{1,3})\b/,"172.16.0.42"):t[r]=n:typeof n=="object"&&n!==null?t[r]=Us(n):t[r]=n;return t}function qk(e){const{instance:t,title:r,category:n,valueProposition:s,author:a}=e,i=t.workflowDefinition?structuredClone(t.workflowDefinition):{name:t.workflowName||"extracted_workflow",tasks:t.tasks.map(b=>b.workflowTask||{name:b.taskDefName||b.referenceTaskName,taskReferenceName:b.referenceTaskName,type:b.taskType||"SIMPLE",inputParameters:b.inputData})},l=Lk(i),c=Wk(i,t),d=new Set(c.filter(b=>b.selected).map(b=>b.taskReferenceName)),u=zk(i,d),p=[],f=structuredClone(u);for(const b of l)if(b.action==="variable"){const S=`var_${b.keyName}_${Date.now().toString(36).slice(-3)}`;p.push({key:S,label:b.suggestedVarName||b.keyName,type:typeof b.rawValue=="number"?"number":"text",defaultValue:b.maskedValue||b.rawValue,required:!0,bindings:[b.path]})}const m={};for(const b of t.tasks)b.outputData&&!d.has(b.referenceTaskName)&&(m[b.referenceTaskName]=Us(b.outputData));const h={name:"生产真实运行数据脱敏样本",description:`基于实例 ${t.workflowId} 真实执行产物自动生成的高保真无害化数据集`,workflowInput:Us(t.input||{}),taskOutputs:m},y=`tpl_extracted_${Date.now().toString(36)}`,x=r||`${i.name||"业务流"} (实战萃取模板)`,g=n||"ops",v=s||`源于真实执行实例 ${t.workflowId},已完成自动化脱敏与参数提取。`;return{template:{id:y,version:"1.0.0",title:x,category:g,icon:"package",valueProposition:v,description:i.description||"由管理员从高频成功的生产运行记录中提炼而成的标准化黄金模板。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:25,typicalRunsPerWeek:10,popularityCount:1},difficulty:"intermediate",variables:p,definition:f,mockDataset:{scenarios:[h]},provenance:{source:"extracted",author:a||"Platform Admin",publishedAt:new Date().toISOString(),extractedFromWorkflowId:t.workflowId}},findings:l,prunedTasks:c,report:{extractedAt:new Date().toISOString(),totalTasksScanned:i.tasks?.length??0,sensitiveItemsCount:l.length,credentialsRedactedCount:l.filter(b=>b.kind==="credential").length,variablesCreatedCount:p.length}}}const Fk=[{id:"tpl_ecs_auto_provision",version:"1.0.0",title:"云主机自动化交付与环境配置",category:"compute",icon:"rocket",valueProposition:"一键完成主机创建、运行时环境自动化部署、基线快照与交付群通知,单次节省 35 分钟手工操作。",description:"面向新业务系统上线场景,自动根据指定规格在云平台创建云主机,通过远程免密脚本自动安装 Docker 与运行时依赖,并在验证就绪后自动归档基线快照向运维协同群发送交付卡片。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:35,typicalRunsPerWeek:12},difficulty:"starter",variables:[{key:"instanceName",label:"新主机名称",type:"text",defaultValue:"app-service-prod",required:!0,placeholder:"例如: app-service-prod",bindings:["tasks[0].inputParameters.instanceName"]},{key:"regionId",label:"目标地域",type:"select",defaultValue:"cn-hangzhou",required:!0,options:[{label:"华东 1 (杭州)",value:"cn-hangzhou"},{label:"华北 2 (北京)",value:"cn-beijing"},{label:"华南 1 (深圳)",value:"cn-shenzhen"}],bindings:["tasks[0].inputParameters.regionId"]},{key:"notifyChannel",label:"交付通知渠道",type:"select",defaultValue:"webhook_dingtalk",required:!0,options:[{label:"钉钉运维机器人 (DingTalk)",value:"webhook_dingtalk"},{label:"企业微信机器人 (WeCom)",value:"webhook_wecom"},{label:"飞书群机器人 (Feishu/Lark)",value:"webhook_feishu"}],bindings:["tasks[4].inputParameters.channel"]}],definition:{name:"ecs_auto_provision_flow",description:"云主机全自动交付与运行时环境部署",version:1,tasks:[{name:"ecs_create_instance",taskReferenceName:"create_node",type:"HTTP",description:"创建计算型云主机",inputParameters:{_actionId:"ecs.create_instance",instanceName:"app-service-prod",regionId:"cn-hangzhou",instanceType:"ecs.c7.xlarge",imageId:"image-alilinux-3",systemDiskSize:120}},{name:"wait_for_network",taskReferenceName:"wait_network_ready",type:"WAIT",description:"等待网络与底层系统完成自检",inputParameters:{_actionId:"control.wait",duration:"10s"}},{name:"ecs_run_command",taskReferenceName:"install_runtime",type:"HTTP",description:"免密下发初始化命令: 安装 Docker 与守护进程",inputParameters:{_actionId:"ecs.run_command",instanceId:"${create_node.output.instanceId}",commandContent:"yum update -y && systemctl start docker && docker info",commandType:"RunShellScript",timeoutSeconds:60}},{name:"ecs_create_snapshot",taskReferenceName:"create_baseline_snap",type:"HTTP",description:"创建系统盘基线快照",inputParameters:{_actionId:"ecs.create_snapshot",instanceId:"${create_node.output.instanceId}",snapshotName:"baseline-init-snapshot",retentionDays:30}},{name:"send_operation_notification",taskReferenceName:"notify_devops",type:"EVENT",sink:"conductor",description:"向运维协同群发送交付卡片",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【交付就绪】新云主机已部署完成",content:"云主机 ${create_node.output.instanceId} 已创建并完成 Docker 运行时初始化与安全基线快照,内网IP: ${create_node.output.privateIp}。"}}]},mockDataset:{scenarios:[{name:"标准交付场景",description:"模拟一次完整的 4C8G 主机自动交付与脚本安装过程",workflowInput:{},taskOutputs:{create_node:{instanceId:"i-bp18a9z3j42m09a",instanceName:"app-service-prod",privateIp:"172.16.0.42",status:"RUNNING",createdAt:"2026-10-20T14:00:00Z"},wait_network_ready:{waited:!0,duration:"10s"},install_runtime:{exitCode:0,status:"SUCCESS",output:"Docker version 24.0.5 installed and running"},create_baseline_snap:{snapshotId:"s-bp199042",status:"ACCOMPLISHED"},notify_devops:{messageId:"msg-9921",sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_daily_snapshot_backup",version:"1.0.0",title:"核心云主机每日定时快照备份",category:"security",icon:"save",valueProposition:"每日自动化创建增量快照并自动清理超期备份,防勒索防误删,单次节省 15 分钟人工检查。",description:"自动对生产数据库或核心应用所在的云主机创建带时间戳的增量快照,保留 14 天自动循环轮转,并在完成备份后发送健康汇报。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:15,typicalRunsPerWeek:7},difficulty:"starter",variables:[{key:"instanceId",label:"目标云主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,placeholder:"例如: i-bp18a9z3j42m09a",bindings:["tasks[0].inputParameters.instanceId","tasks[1].inputParameters.instanceId"]},{key:"retentionDays",label:"快照保留天数",type:"number",defaultValue:14,required:!0,bindings:["tasks[1].inputParameters.retentionDays"]}],definition:{name:"ecs_daily_snapshot_backup_flow",description:"核心云主机每日定时增量备份",version:1,tasks:[{name:"ecs_query_instance",taskReferenceName:"check_host",type:"HTTP",description:"检查主机运行健康状态",inputParameters:{_actionId:"ecs.query_instance",instanceId:"i-bp18a9z3j42m09a"}},{name:"ecs_create_snapshot",taskReferenceName:"create_daily_snap",type:"HTTP",description:"执行云盘增量备份快照",inputParameters:{_actionId:"ecs.create_snapshot",instanceId:"i-bp18a9z3j42m09a",snapshotName:"auto-daily-backup",retentionDays:14}},{name:"send_operation_notification",taskReferenceName:"notify_result",type:"EVENT",sink:"conductor",description:"发送备份执行简报",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【快照备份成功】每日例行备份完成",content:"云主机 ${check_host.output.instanceId} (${check_host.output.status}) 增量快照已生成,快照ID: ${create_daily_snap.output.snapshotId}。"}}]},mockDataset:{scenarios:[{name:"定时备份成功场景",workflowInput:{},taskOutputs:{check_host:{instanceId:"i-bp18a9z3j42m09a",status:"RUNNING",osName:"Alibaba Cloud Linux 3"},create_daily_snap:{snapshotId:"s-bp188201",snapshotName:"auto-daily-backup",status:"ACCOMPLISHED"},notify_result:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_high_load_autoscale",version:"1.0.0",title:"主机高负载告警与在线自动升配",category:"ops",icon:"zap",valueProposition:"检测到 CPU 利用率超标时自动发起升配流程,内置人工审批安全网,秒级在线完成 4C8G -> 8C16G 弹性扩容。",description:"自动轮询主机性能指标,一旦触发瓶颈阈值,系统即刻生成规格变更提案并向架构师推送一键审批卡片,审批后自动在线变配,保障大促不卡顿。",connectors:["cloud_host","dingtalk","approval"],roi:{minutesSavedPerRun:40,typicalRunsPerWeek:5},difficulty:"intermediate",variables:[{key:"instanceId",label:"监控主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[2].inputParameters.instanceId"]},{key:"targetSpec",label:"目标扩容规格",type:"select",defaultValue:"ecs.c7.2xlarge",required:!0,options:[{label:"提升至 计算型 8C16G (ecs.c7.2xlarge)",value:"ecs.c7.2xlarge"},{label:"提升至 内存型 8C32G (ecs.r7.2xlarge)",value:"ecs.r7.2xlarge"}],bindings:["tasks[2].inputParameters.targetSpec"]}],definition:{name:"ecs_high_load_autoscale_flow",description:"云主机高负载自动熔断与在线变配",version:1,tasks:[{name:"ecs_get_monitor_metrics",taskReferenceName:"fetch_metrics",type:"HTTP",description:"采集 CPU 与内存利用率",inputParameters:{_actionId:"ecs.get_monitor_metrics",instanceId:"i-bp18a9z3j42m09a",periodSeconds:60}},{name:"human_operation_approval",taskReferenceName:"approve_spec_upgrade",type:"HUMAN",description:"高危硬件配置变更审批",inputParameters:{_actionId:"human.approval",assigneeRole:"architect",promptMessage:"云主机 ${fetch_metrics.output.instanceId} 当前 CPU 利用率达到 ${fetch_metrics.output.cpuUsagePercent}%,申请在线升配。",timeoutMinutes:30}},{name:"ecs_modify_spec",taskReferenceName:"apply_spec_change",type:"HTTP",description:"执行在线规格扩容变更",inputParameters:{_actionId:"ecs.modify_spec",instanceId:"i-bp18a9z3j42m09a",targetSpec:"ecs.c7.2xlarge"}},{name:"send_operation_notification",taskReferenceName:"notify_upgrade_done",type:"EVENT",sink:"conductor",description:"发送变配完成汇报",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【升配成功】云主机硬件规格已在线提升",content:"云主机 ${fetch_metrics.output.instanceId} 已成功从 ${apply_spec_change.output.oldSpec} 变更为 ${apply_spec_change.output.newSpec}。"}}]},mockDataset:{scenarios:[{name:"高负载升配成功场景",workflowInput:{},taskOutputs:{fetch_metrics:{instanceId:"i-bp18a9z3j42m09a",cpuUsagePercent:88.5,isOverloaded:!0},approve_spec_upgrade:{approved:!0,reviewer:"architect@internal.cloud"},apply_spec_change:{oldSpec:"ecs.c7.xlarge",newSpec:"ecs.c7.2xlarge",status:"SUCCESS"},notify_upgrade_done:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_vulnerability_patch",version:"1.0.0",title:"生产主机一键漏洞巡检与修复",category:"security",icon:"shield",valueProposition:"修补前自动创建保护快照,免密下发 OS 补丁脚本,带审批确认软重启,消除系统 CVE 高危隐患。",description:"解决企业 Linux 主机补丁升级流程繁琐、缺少回滚预案的问题。流程自动先对磁盘建立防护快照,执行补丁更新后通知责任人确认软重启。",connectors:["cloud_host","dingtalk","approval"],roi:{minutesSavedPerRun:45,typicalRunsPerWeek:4},difficulty:"intermediate",variables:[{key:"instanceId",label:"目标主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[1].inputParameters.instanceId","tasks[3].inputParameters.instanceId"]}],definition:{name:"ecs_vulnerability_patch_flow",description:"带快照防护的操作系统漏洞巡检与修复流程",version:1,tasks:[{name:"ecs_create_snapshot",taskReferenceName:"patch_safeguard_snap",type:"HTTP",description:"建立补丁前安全还原快照",inputParameters:{_actionId:"ecs.create_snapshot",instanceId:"i-bp18a9z3j42m09a",snapshotName:"pre-patch-safeguard",retentionDays:7}},{name:"ecs_run_command",taskReferenceName:"apply_cve_patches",type:"HTTP",description:"下发漏洞热补丁脚本",inputParameters:{_actionId:"ecs.run_command",instanceId:"i-bp18a9z3j42m09a",commandContent:"yum update-minimal --security -y",commandType:"RunShellScript",timeoutSeconds:120}},{name:"human_operation_approval",taskReferenceName:"confirm_soft_reboot",type:"HUMAN",description:"责任人确认重启",inputParameters:{_actionId:"human.approval",assigneeRole:"devops_lead",promptMessage:"补丁更新已完成,请确认是否即刻安排主机软重启以使内核生效。",timeoutMinutes:60}},{name:"ecs_restart_instance",taskReferenceName:"reboot_host",type:"HTTP",description:"软重启生效补丁",inputParameters:{_actionId:"ecs.restart_instance",instanceId:"i-bp18a9z3j42m09a",forceRestart:!1}},{name:"send_operation_notification",taskReferenceName:"report_patch_result",type:"EVENT",sink:"conductor",description:"发送合规汇报",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【补丁更新成功】系统漏洞修复完成",content:"云主机 ${patch_safeguard_snap.output.instanceId} 补丁更新完成,主机已完成重启并恢复在线。"}}]},mockDataset:{scenarios:[{name:"补丁升级全流程演示",workflowInput:{},taskOutputs:{patch_safeguard_snap:{snapshotId:"s-bp1904",status:"ACCOMPLISHED"},apply_cve_patches:{exitCode:0,output:"3 security packages updated",status:"SUCCESS"},confirm_soft_reboot:{approved:!0,reviewer:"devops_lead@internal.cloud"},reboot_host:{status:"RUNNING"},report_patch_result:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_night_idle_shutdown",version:"1.0.0",title:"非生产环境夜间定时关机降本",category:"cost",icon:"moon",valueProposition:"工作日 21:00 自动停止闲置研发测试主机,次日晨自动开机,降低约 65% 计算资源账单。",description:"自动在夜间巡检开发测试集群,若无活跃计算任务,则下发优雅安全关机指令,并在协同群汇报当晚关机台数与预计节约的算力金额。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:20,typicalRunsPerWeek:5},difficulty:"starter",variables:[{key:"instanceId",label:"测试环境主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[1].inputParameters.instanceId"]},{key:"forceStop",label:"超时是否强制关机",type:"boolean",defaultValue:!1,bindings:["tasks[1].inputParameters.forceStop"]}],definition:{name:"ecs_night_idle_shutdown_flow",description:"测试环境夜间自动关机降本",version:1,tasks:[{name:"ecs_get_monitor_metrics",taskReferenceName:"check_idle_state",type:"HTTP",description:"核实主机是否处于闲置低负载",inputParameters:{_actionId:"ecs.get_monitor_metrics",instanceId:"i-bp18a9z3j42m09a",periodSeconds:300}},{name:"ecs_stop_instance",taskReferenceName:"shutdown_host",type:"HTTP",description:"执行优雅关机",inputParameters:{_actionId:"ecs.stop_instance",instanceId:"i-bp18a9z3j42m09a",forceStop:!1}},{name:"send_operation_notification",taskReferenceName:"notify_cost_saving",type:"EVENT",sink:"conductor",description:"发送夜间节能降本简报",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【夜间节能】测试主机已自动进入休眠",content:"测试主机 ${check_idle_state.output.instanceId} (CPU ${check_idle_state.output.cpuUsagePercent}%) 已于 21:00 完成关机,预计今夜节约 11 小时按量费用。"}}]},mockDataset:{scenarios:[{name:"闲置关机场景",workflowInput:{},taskOutputs:{check_idle_state:{instanceId:"i-bp18a9z3j42m09a",cpuUsagePercent:2.1,isOverloaded:!1},shutdown_host:{status:"STOPPED"},notify_cost_saving:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_morning_boot",version:"1.0.0",title:"测试环境工作日早晨定时自动开机",category:"cost",icon:"sunrise",valueProposition:"工作日 08:30 自动唤醒测试主机,自检网络并广播就绪通知,研发开工即可联调无需等待。",description:"与夜间关机模板形成完整的节能闭环,在工作日上班前 30 分钟定时批量启动主机,校验网络联通性后发送早报。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:15,typicalRunsPerWeek:5},difficulty:"starter",variables:[{key:"instanceId",label:"测试环境主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[2].inputParameters.instanceId"]}],definition:{name:"ecs_morning_boot_flow",description:"测试环境早间自动唤醒开机",version:1,tasks:[{name:"ecs_start_instance",taskReferenceName:"boot_host",type:"HTTP",description:"执行主机开机启动",inputParameters:{_actionId:"ecs.start_instance",instanceId:"i-bp18a9z3j42m09a"}},{name:"wait_boot_ready",taskReferenceName:"wait_boot",type:"WAIT",description:"等待操作系统内核引导就绪",inputParameters:{_actionId:"control.wait",duration:"10s"}},{name:"ecs_query_instance",taskReferenceName:"verify_network",type:"HTTP",description:"核实网络与运行状态",inputParameters:{_actionId:"ecs.query_instance",instanceId:"i-bp18a9z3j42m09a"}},{name:"send_operation_notification",taskReferenceName:"notify_team_ready",type:"EVENT",sink:"conductor",description:"向研发测试群发送环境就绪广播",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【环境就绪】测试云主机已唤醒开机",content:"测试主机 ${verify_network.output.instanceId} 已启动 (${verify_network.output.status}),内网IP: ${verify_network.output.privateIp},开发人员可正常开始联调。"}}]},mockDataset:{scenarios:[{name:"晨间开机唤醒演示",workflowInput:{},taskOutputs:{boot_host:{instanceId:"i-bp18a9z3j42m09a",currentStatus:"STARTING"},wait_boot:{waited:!0},verify_network:{instanceId:"i-bp18a9z3j42m09a",status:"RUNNING",privateIp:"172.16.0.42"},notify_team_ready:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_disk_expansion",version:"1.0.0",title:"磁盘容量告警与在线自动扩容",category:"ops",icon:"hard-drive",valueProposition:"磁盘利用率超 85% 自动快照并在线扩充云盘容量,免停机扩展文件系统,杜绝业务写爆宕机。",description:"自动对磁盘快满的主机执行保护性快照,随后免停机远程下发 growpart 与 resize2fs 脚本刷新空间,最后在运维群反馈扩容结果。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:30,typicalRunsPerWeek:6},difficulty:"intermediate",variables:[{key:"instanceId",label:"目标主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[1].inputParameters.instanceId","tasks[2].inputParameters.instanceId"]}],definition:{name:"ecs_disk_expansion_flow",description:"云主机磁盘在线自动扩容与自愈",version:1,tasks:[{name:"ecs_get_monitor_metrics",taskReferenceName:"check_disk_usage",type:"HTTP",description:"检测磁盘利用率",inputParameters:{_actionId:"ecs.get_monitor_metrics",instanceId:"i-bp18a9z3j42m09a",periodSeconds:60}},{name:"ecs_create_snapshot",taskReferenceName:"pre_expand_snap",type:"HTTP",description:"扩容前创建磁盘保护快照",inputParameters:{_actionId:"ecs.create_snapshot",instanceId:"i-bp18a9z3j42m09a",snapshotName:"pre-disk-expansion",retentionDays:7}},{name:"ecs_run_command",taskReferenceName:"grow_filesystem",type:"HTTP",description:"在线扩展分区与文件系统",inputParameters:{_actionId:"ecs.run_command",instanceId:"i-bp18a9z3j42m09a",commandContent:"growpart /dev/vda 1 && resize2fs /dev/vda1 && df -h",commandType:"RunShellScript",timeoutSeconds:60}},{name:"send_operation_notification",taskReferenceName:"notify_expand_done",type:"EVENT",sink:"conductor",description:"发送扩容完成通知",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【自愈成功】云盘空间已在线扩容",content:"云主机 ${check_disk_usage.output.instanceId} 磁盘扩容完毕,当前文件系统状态正常。"}}]},mockDataset:{scenarios:[{name:"磁盘扩容自愈演示",workflowInput:{},taskOutputs:{check_disk_usage:{instanceId:"i-bp18a9z3j42m09a",diskUsagePercent:89.2},pre_expand_snap:{snapshotId:"s-bp1449",status:"ACCOMPLISHED"},grow_filesystem:{exitCode:0,output:"CHANGED: partition=1, size expanded to 200GB"},notify_expand_done:{sentStatus:"DELIVERED"}}}]}},{id:"tpl_ecs_emergency_isolation",version:"1.0.0",title:"突发入侵应急响应与快照取证",category:"security",icon:"bell-ring",valueProposition:"发生高危网络入侵威胁时,秒级冻结证据快照并强制关机隔离,将安全暴露面降至最低。",description:"面对勒索病毒、WebShell 或异常爆破入侵时,自动对受害主机创建取证快照保存现场内存与日志,随后强制关机切断危害,并向 SecOps 安全小组发送紧急红色通知。",connectors:["cloud_host","dingtalk"],roi:{minutesSavedPerRun:60,typicalRunsPerWeek:1},difficulty:"advanced",variables:[{key:"instanceId",label:"受害云主机 ID",type:"text",defaultValue:"i-bp18a9z3j42m09a",required:!0,bindings:["tasks[0].inputParameters.instanceId","tasks[1].inputParameters.instanceId"]}],definition:{name:"ecs_emergency_isolation_flow",description:"安全事件突发应急取证与快速隔离",version:1,tasks:[{name:"ecs_create_snapshot",taskReferenceName:"forensics_snapshot",type:"HTTP",description:"紧急创建现场取证快照",inputParameters:{_actionId:"ecs.create_snapshot",instanceId:"i-bp18a9z3j42m09a",snapshotName:"security-forensics-evidence",retentionDays:90}},{name:"ecs_stop_instance",taskReferenceName:"isolate_victim_node",type:"HTTP",description:"强制切断关机隔离",inputParameters:{_actionId:"ecs.stop_instance",instanceId:"i-bp18a9z3j42m09a",forceStop:!0}},{name:"send_operation_notification",taskReferenceName:"alert_secops_incident",type:"EVENT",sink:"conductor",description:"发送安全应急处置最高级别预警",inputParameters:{_actionId:"notify.send_message",channel:"webhook_dingtalk",title:"【紧急安全通报】入侵主机已隔离取证",content:"受害主机 ${forensics_snapshot.output.instanceId} 已完成现场留证快照 (${forensics_snapshot.output.snapshotId}) 并被强制关机隔离,请 SecOps 立即启动应急调查。"}}]},mockDataset:{scenarios:[{name:"应急阻断演示",workflowInput:{},taskOutputs:{forensics_snapshot:{snapshotId:"s-forensics-911",status:"ACCOMPLISHED"},isolate_victim_node:{status:"STOPPED",forceStop:!0},alert_secops_incident:{sentStatus:"DELIVERED"}}}]}}];class Bk{templates=new Map;version=0;listeners=new Set;constructor(t=[]){this.registerAll(t)}register(t){this.templates.set(t.id,t),this.version+=1,this.listeners.forEach(r=>r())}getVersion=()=>this.version;subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});registerAll(t){for(const r of t)this.register(r)}getAllTemplates(){return Array.from(this.templates.values())}getTemplateById(t){return this.templates.get(t)}search(t,r="all"){let n=this.getAllTemplates();if(r&&r!=="all"&&(n=n.filter(s=>s.category===r)),t&&t.trim()){const s=t.toLowerCase().trim();n=n.filter(a=>a.title.toLowerCase().includes(s)||a.valueProposition.toLowerCase().includes(s)||a.description.toLowerCase().includes(s))}return n}}const op=new Bk(Fk),Hk=({isOpen:e,instance:t,onClose:r,onPublished:n})=>{const{theme:s,themeColor:a}=te(Ae(w=>({theme:w.theme,themeColor:w.themeColor}))),i=T.useMemo(()=>qk({instance:t,title:`${t.workflowName||"云平台工作流"} (实战提炼)`,category:"ops",valueProposition:`基于实例 ${t.workflowId} 的成功运行萃取,已通过自动化脱敏与参数提取。`,author:"系统管理员"}),[t]),[l,c]=T.useState(i.template.title),[d,u]=T.useState(i.template.category),[p,f]=T.useState(i.template.valueProposition),[m,h]=T.useState(i.template.roi.minutesSavedPerRun),[y,x]=T.useState(()=>{const w={};for(const I of i.prunedTasks)w[I.taskReferenceName]=I.selected;return w}),[g,v]=T.useState(!1),[k,b]=T.useState(!1);if(!e||typeof document>"u")return null;const S=w=>{x(I=>({...I,[w]:!I[w]}))},j=()=>{v(!0);try{const w={...i.template,title:l,category:d,valueProposition:p,roi:{...i.template.roi,minutesSavedPerRun:m}};op.register(w),n&&n(w),b(!0),setTimeout(()=>{r()},1500)}catch(w){alert(`发布模板出错: ${w.message}`)}finally{v(!1)}},_=i.findings;return bt.createPortal(o.jsx("div",{"data-mode":s,"data-brand":a,style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"var(--cm-overlay)",backdropFilter:"blur(6px)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center",padding:24,fontFamily:"inherit"},onClick:r,children:o.jsxs("div",{onClick:w=>w.stopPropagation(),style:{width:980,maxWidth:"calc(100vw - 48px)",height:720,maxHeight:"calc(100vh - 48px)",background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",borderRadius:14,boxShadow:"var(--cm-shadow-float)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"14px 20px",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bg-primary)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{fontSize:22},children:o.jsx(fb,{size:22,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:15,color:"var(--text-primary)"},children:"生产工作流一键提炼与脱敏工作台 (管理员)"}),o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)"},children:["基于执行实例 #",t.workflowId," 自动识别敏感信息并生成高保真模板"]})]})]}),o.jsx("button",{onClick:r,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:16},children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"18px 20px",display:"grid",gridTemplateColumns:"1fr 1.2fr 1fr",gap:16},children:[o.jsxs("div",{style:{background:"var(--bg-primary)",borderRadius:10,border:"1px solid var(--border-primary)",padding:14,display:"flex",flexDirection:"column",gap:10},children:[o.jsx("div",{style:{fontWeight:600,fontSize:13,color:"var(--text-primary)"},children:"1. 骨架拓扑剪枝建议"}),o.jsx("div",{style:{fontSize:11,color:"var(--text-muted)"},children:"自动识别并建议剔除特定的临时调试、重试与低频孤立分支:"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,marginTop:4},children:i.template.definition.tasks?.map((w,I)=>{const N=!!y[w.taskReferenceName];return o.jsxs("div",{style:{padding:"8px 10px",borderRadius:6,background:N?"color-mix(in srgb, var(--cm-status-failed) 8%, transparent)":"var(--bg-highlight)",border:`1px solid ${N?"color-mix(in srgb, var(--cm-status-failed) 25%, transparent)":"var(--cm-border-subtle)"}`,display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:12,opacity:N?.6:1},children:[o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsxs("span",{style:{color:"var(--color-accent)",fontWeight:600},children:["#",I+1]}),o.jsx("span",{style:{color:N?"var(--cm-status-failed)":"var(--text-primary)"},children:w.description||w.name})]}),o.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"monospace"},children:w.taskReferenceName})]}),o.jsx("button",{onClick:()=>S(w.taskReferenceName),style:{padding:"2px 6px",borderRadius:4,background:N?"color-mix(in srgb, var(--cm-status-failed) 20%, transparent)":"var(--bg-highlight)",border:"none",color:N?"var(--cm-status-failed)":"var(--text-muted)",fontSize:11,cursor:"pointer"},children:N?"已剪枝剔除":"保留"})]},w.taskReferenceName)})})]}),o.jsxs("div",{style:{background:"var(--bg-primary)",borderRadius:10,border:"1px solid var(--border-primary)",padding:14,display:"flex",flexDirection:"column",gap:10},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsx("div",{style:{fontWeight:600,fontSize:13,color:"var(--text-primary)"},children:"2. 敏感项扫描与变量提取"}),o.jsxs("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"color-mix(in srgb, var(--cm-status-success) 15%, transparent)",color:"var(--cm-status-success)",fontWeight:600},children:["已扫描 ",_.length," 项"]})]}),o.jsx("div",{style:{fontSize:11,color:"var(--text-muted)"},children:"命中规则的生产密钥已强制置空,真实 IP/ID 推荐转为填空变量:"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8,marginTop:4},children:_.length===0?o.jsxs("div",{style:{padding:"24px 12px",textAlign:"center",color:"var(--text-muted)",fontSize:12},children:[o.jsx(_t,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"未发现任何硬编码的高危凭据或敏感信息"]}):_.map(w=>o.jsxs("div",{style:{padding:"8px 10px",borderRadius:6,background:"var(--bg-highlight)",border:"1px solid var(--border-primary)",display:"flex",flexDirection:"column",gap:4,fontSize:11},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsx("span",{style:{padding:"1px 5px",borderRadius:3,fontSize:10,fontWeight:600,background:w.kind==="credential"?"color-mix(in srgb, var(--cm-status-failed) 20%, transparent)":w.kind==="network"?"color-mix(in srgb, var(--color-accent) 20%, transparent)":"color-mix(in srgb, var(--cm-status-warning) 20%, transparent)",color:w.kind==="credential"?"var(--cm-status-failed)":w.kind==="network"?"var(--color-accent)":"var(--cm-status-warning)"},children:w.kind==="credential"?"密钥凭据":w.kind==="network"?"内网地址":w.kind==="pii"?"个人隐私":"云资源ID"}),o.jsxs("span",{style:{color:"var(--text-muted)"},children:["建议处理: ",w.action==="variable"?"提取为向导变量":"自动掩码脱敏"]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4,marginTop:2},children:[o.jsx("span",{style:{color:"var(--text-secondary)"},children:"字段:"}),o.jsx("span",{style:{color:"var(--text-primary)",fontFamily:"monospace"},children:w.keyName})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[o.jsx("span",{style:{color:"var(--text-secondary)"},children:"脱敏后:"}),o.jsx("span",{style:{color:"var(--cm-status-success)",fontFamily:"monospace"},children:w.maskedValue?String(w.maskedValue):"(强制置空并由用户填入)"})]})]},w.id))})]}),o.jsxs("div",{style:{background:"var(--bg-primary)",borderRadius:10,border:"1px solid var(--border-primary)",padding:14,display:"flex",flexDirection:"column",gap:12},children:[o.jsx("div",{style:{fontWeight:600,fontSize:13,color:"var(--text-primary)"},children:"3. 模板货架信息配置"}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[o.jsx("label",{style:{fontSize:12,color:"var(--text-secondary)"},children:"模板中文标题"}),o.jsx("input",{type:"text",value:l,onChange:w=>c(w.target.value),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:12,outline:"none"}})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[o.jsx("label",{style:{fontSize:12,color:"var(--text-secondary)"},children:"业务分类"}),o.jsxs("select",{value:d,onChange:w=>u(w.target.value),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:12,outline:"none"},children:[o.jsx("option",{value:"compute",children:"交付与计算"}),o.jsx("option",{value:"security",children:"安全与容灾"}),o.jsx("option",{value:"ops",children:"运维与自愈"}),o.jsx("option",{value:"cost",children:"节能与降本"})]})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[o.jsx("label",{style:{fontSize:12,color:"var(--text-secondary)"},children:"一句话业务价值"}),o.jsx("textarea",{rows:2,value:p,onChange:w=>f(w.target.value),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:12,outline:"none",resize:"none"}})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[o.jsx("label",{style:{fontSize:12,color:"var(--text-secondary)"},children:"单次预估节省 (分钟)"}),o.jsx("input",{type:"number",value:m,onChange:w=>h(Number(w.target.value)),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:12,outline:"none"}})]}),o.jsxs("div",{style:{marginTop:6,padding:"8px 10px",borderRadius:6,background:"color-mix(in srgb, var(--cm-status-success) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--cm-status-success) 20%, transparent)",fontSize:11,color:"var(--cm-status-success)"},children:[o.jsx(_t,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"已从这次运行生成脱敏后的试跑数据。发布后可在本页的模板中心一键试跑;模板只保存在当前页面,刷新后不保留,如需给其他人使用,请联系管理员接入模板库。"]})]})]}),o.jsxs("div",{style:{padding:"12px 20px",borderTop:"1px solid var(--border-primary)",background:"var(--bg-primary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)"},children:["审计报告: 扫描 ",i.report.totalTasksScanned," 个任务 · 脱敏凭证"," ",i.report.credentialsRedactedCount," 项 · 生成模板变量"," ",i.report.variablesCreatedCount," 项"]}),o.jsxs("div",{style:{display:"flex",gap:10,alignItems:"center"},children:[k&&o.jsxs("span",{style:{fontSize:12,color:"var(--cm-status-success)",fontWeight:600},children:[o.jsx(_t,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"已发布到本页模板中心"]}),o.jsx("button",{onClick:r,style:{padding:"6px 14px",borderRadius:6,background:"transparent",border:"1px solid var(--border-secondary)",color:"var(--text-secondary)",fontSize:12,cursor:"pointer"},children:"取消"}),o.jsxs("button",{onClick:j,disabled:g||k,style:{padding:"6px 18px",borderRadius:6,background:"var(--color-accent)",color:"var(--color-on-accent)",border:"none",fontSize:12,fontWeight:600,cursor:g||k?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[o.jsx("span",{children:o.jsx(mn,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsx("span",{children:g?"发布中…":"发布到本页模板中心"})]})]})]})]})}),document.body)},E2=e=>!!e&&e.startsWith("sandbox-dryrun-"),R2=()=>{const[e,t]=T.useState(!1),{executionData:r,workflowInstance:n,showAnalysisPanel:s,setShowAnalysisPanel:a,switchToEditAndFocusParam:i,selectTaskAction:l,taskMap:c}=te(Ae(b=>({executionData:b.executionData,workflowInstance:b.workflowInstance,showAnalysisPanel:b.showAnalysisPanel,setShowAnalysisPanel:b.setShowAnalysisPanel,switchToEditAndFocusParam:b.switchToEditAndFocusParam,selectTaskAction:b.selectTaskAction,taskMap:b.taskMap}))),d=T.useMemo(()=>r?I2(r,n??null):null,[r,n]);if(!s||!d)return null;const{totalTasks:u,completedTasks:p,failedTasks:f,skippedTasks:m,totalDurationMs:h,steps:y}=d,x=u>0?Math.round(p/u*100):0,g=n?.status,v=g?He(g):null,k=v?.icon;return o.jsxs("div",{className:"esp-panel glass-panel",children:[o.jsxs("div",{className:"esp-header",children:[o.jsxs("div",{className:"esp-title",children:[o.jsx(Ns,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"执行分析"]}),v&&k&&o.jsxs("span",{className:"esp-wf-status",style:{color:v.color,display:"inline-flex",alignItems:"center",gap:4},title:g,children:[o.jsx(k,{size:12,strokeWidth:1.75,"aria-hidden":"true"}),v.label]}),n&&!E2(n.workflowId)&&o.jsxs("button",{onClick:()=>t(!0),style:{padding:"3px 8px",borderRadius:5,background:"color-mix(in srgb, var(--color-brand-blue) 18%, transparent)",border:"1px solid color-mix(in srgb, var(--color-brand-blue) 40%, transparent)",color:"var(--color-brand-blue)",fontSize:11,cursor:"pointer",fontWeight:600,display:"inline-flex",alignItems:"center",gap:4,marginLeft:"auto",marginRight:6},title:"将本次执行实例脱敏并提炼为公共标准化模板",children:[o.jsx("span",{children:o.jsx(fb,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsx("span",{children:"提取为模板"})]}),o.jsx("button",{className:"esp-close",onClick:()=>a(!1),children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsxs("div",{className:"esp-content",children:[o.jsxs("div",{className:"esp-overview",children:[o.jsxs("div",{className:"esp-card",children:[o.jsx("span",{className:"esp-card-value",children:u}),o.jsx("span",{className:"esp-card-label",children:"总任务数"})]}),o.jsxs("div",{className:"esp-card esp-card-success",children:[o.jsx("span",{className:"esp-card-value",style:{color:"var(--status-completed)"},children:p}),o.jsx("span",{className:"esp-card-label",children:"已完成"})]}),o.jsxs("div",{className:"esp-card esp-card-failed",children:[o.jsx("span",{className:"esp-card-value",style:{color:f>0?"var(--status-failed)":"var(--text-secondary)"},children:f}),o.jsx("span",{className:"esp-card-label",children:"失败"})]}),o.jsxs("div",{className:"esp-card",children:[o.jsx("span",{className:"esp-card-value",children:Dk(h)}),o.jsx("span",{className:"esp-card-label",children:"总耗时"})]})]}),o.jsx("div",{className:"esp-progress-bar",children:o.jsx("div",{className:"esp-progress-fill",style:{width:`${x}%`,background:f>0?"var(--status-failed)":"var(--status-completed)"},title:`成功率 ${x}%`})}),o.jsxs("div",{className:"esp-progress-label",children:[x,"% 成功率",m>0?`,${m} 个任务已跳过`:""]}),y.filter(b=>b.diagnostics.length>0).map(b=>o.jsxs("div",{className:"esp-diagnostic-card",children:[o.jsxs("div",{className:"esp-diag-task-ref",children:[o.jsx(jt,{size:12,strokeWidth:1.75,"aria-hidden":"true",style:{color:"var(--status-failed)",flexShrink:0}}),b.taskRef]}),b.diagnostics.map((S,j)=>o.jsxs("div",{className:"esp-diag-item",style:{borderLeftColor:C2(S.category)},children:[o.jsxs("div",{className:"esp-diag-title",children:[o.jsx("span",{style:{display:"inline-flex"},children:o.jsx(We,{name:N2(S.category),size:14})}),S.title]}),o.jsx("p",{className:"esp-diag-explanation",children:S.explanation}),o.jsxs("button",{className:"esp-fix-btn",onClick:()=>i(b.taskRef,S.suggestEditParam),children:["去修复",o.jsx(lb,{size:12,strokeWidth:1.75,"aria-hidden":"true"})]})]},j))]},b.taskRef)),o.jsx("div",{className:"esp-section-label",children:"步骤执行时序"}),o.jsxs("div",{className:"esp-steps-table",children:[o.jsxs("div",{className:"esp-steps-header",children:[o.jsx("span",{children:"#"}),o.jsx("span",{children:"任务引用名"}),o.jsx("span",{children:"状态"}),o.jsx("span",{children:"耗时"}),o.jsx("span",{children:"重试"})]}),y.map((b,S)=>{const j=He(b.status),_=j.icon,w=c[b.taskRef];return o.jsxs("button",{className:"esp-step-row",onClick:()=>w&&l(w,!0),title:b.reasonForIncompletion||b.taskRef,children:[o.jsx("span",{className:"esp-step-idx",children:S+1}),o.jsx("span",{className:"esp-step-ref",children:b.taskRef}),o.jsxs("span",{className:"esp-step-status",style:{color:j.color},title:b.status,children:[o.jsx(_,{size:12,strokeWidth:1.75,"aria-hidden":"true"}),j.label]}),o.jsx("span",{className:"esp-step-duration",children:Dk(b.durationMs)}),o.jsx("span",{className:"esp-step-retry",style:{color:b.retryCount>0?"var(--status-failed)":"var(--text-secondary)"},title:b.iterationCount>0?`${b.iterationCount} 轮迭代`:void 0,children:b.retryCount>0?`${b.retryCount} 次`:"-"})]},b.taskRef)})]})]}),e&&n&&o.jsx(Hk,{isOpen:e,instance:n,onClose:()=>t(!1),onPublished:()=>{console.log("[ExecutionSummaryPanel] 模板已发布到本页模板中心")}})]})},O2=e=>typeof e=="string"&&e.includes("${");function Jt(e,t){if(e==null||e==="")return t;if(typeof e=="number")return Number.isFinite(e)?e:t;if(typeof e=="string"){if(O2(e))return e;const r=Number(e.trim());return e.trim()!==""&&Number.isFinite(r)?r:e}return t}const Jk=[{id:"ecs.create_instance",name:"创建云主机",category:"compute",icon:"server",description:"在指定可用区根据镜像与规格创建并初始化一台新的云主机实例",connector:"cloud_host",riskLevel:"safe",fields:[{key:"regionId",label:"所属地域",type:"select",required:!0,defaultValue:"cn-hangzhou",options:[{label:"华东 1 (杭州)",value:"cn-hangzhou"},{label:"华北 2 (北京)",value:"cn-beijing"},{label:"华南 1 (深圳)",value:"cn-shenzhen"},{label:"亚太东南 1 (新加坡)",value:"ap-southeast-1"}],acceptsPills:!0},{key:"instanceType",label:"计算规格",type:"select",required:!0,defaultValue:"ecs.c7.xlarge",options:[{label:"通用型 2C4G (ecs.g7.large)",value:"ecs.g7.large"},{label:"计算型 4C8G (ecs.c7.xlarge)",value:"ecs.c7.xlarge"},{label:"内存型 4C16G (ecs.r7.xlarge)",value:"ecs.r7.xlarge"},{label:"高性能 8C32G (ecs.c7.2xlarge)",value:"ecs.c7.2xlarge"}],acceptsPills:!0},{key:"imageId",label:"操作系统镜像",type:"select",required:!0,defaultValue:"image-alilinux-3",options:[{label:"Alibaba Cloud Linux 3.2104 LTS 64位",value:"image-alilinux-3"},{label:"Ubuntu 22.04 LTS 64位",value:"image-ubuntu-22"},{label:"CentOS 7.9 64位",value:"image-centos-7"},{label:"Debian 12 64位",value:"image-debian-12"}],acceptsPills:!0},{key:"instanceName",label:"主机名称",type:"text",placeholder:"例如: web-prod-01",required:!0,defaultValue:"app-server-node",acceptsPills:!0},{key:"systemDiskSize",label:"系统盘容量 (GB)",type:"number",defaultValue:100,required:!0,acceptsPills:!0}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"instanceName",label:"主机名称",type:"string",example:"app-server-node"},{key:"privateIp",label:"内网IP",type:"string",example:"172.16.0.42"},{key:"status",label:"实例状态",type:"string",example:"RUNNING"},{key:"createdAt",label:"创建时间",type:"string",example:"2026-10-20T14:00:00Z"}],compile:(e,t)=>({name:"ecs_create_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`创建云主机: ${e.instanceName||t.taskReferenceName}`,inputParameters:{_actionId:"ecs.create_instance",actionName:"创建云主机",regionId:e.regionId??"cn-hangzhou",instanceType:e.instanceType??"ecs.c7.xlarge",imageId:e.imageId??"image-alilinux-3",instanceName:e.instanceName??"app-node",systemDiskSize:Jt(e.systemDiskSize,100),http_request:{uri:"https://ecs.internal.cloud/api/v2/instances",method:"POST",body:{regionId:e.regionId,instanceType:e.instanceType,imageId:e.imageId,instanceName:e.instanceName,systemDiskSize:Jt(e.systemDiskSize,100)}}}}),decompile:e=>{if(e.inputParameters?._actionId==="ecs.create_instance"){const t=e.inputParameters;return{regionId:t.regionId??"cn-hangzhou",instanceType:t.instanceType??"ecs.c7.xlarge",imageId:t.imageId??"image-alilinux-3",instanceName:t.instanceName??e.taskReferenceName,systemDiskSize:t.systemDiskSize??100}}return null},mockOutput:e=>({instanceId:`i-bp1${Math.random().toString(36).substring(2,9)}`,instanceName:e.instanceName||"app-server-node",privateIp:"172.16.0."+Math.floor(10+Math.random()*200),status:"RUNNING",regionId:e.regionId||"cn-hangzhou",instanceType:e.instanceType||"ecs.c7.xlarge",createdAt:new Date().toISOString()})},{id:"ecs.query_instance",name:"查询云主机详情",category:"compute",icon:"search",description:"根据主机实例 ID 查询其实时运行状态、配置规格与网络 IP",connector:"cloud_host",riskLevel:"safe",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",placeholder:"例如: i-bp18a9z3j42m09a 或绑定上游胶囊",required:!0,acceptsPills:!0}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"status",label:"运行状态",type:"string",example:"RUNNING"},{key:"cpu",label:"CPU核心数",type:"number",example:4},{key:"memoryGb",label:"内存(GB)",type:"number",example:8},{key:"privateIp",label:"内网IP",type:"string",example:"172.16.0.42"},{key:"publicIp",label:"公网IP",type:"string",example:"47.98.112.23"},{key:"osName",label:"操作系统",type:"string",example:"Alibaba Cloud Linux 3"}],compile:(e,t)=>({name:"ecs_query_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`查询云主机状态: ${e.instanceId||""}`,inputParameters:{_actionId:"ecs.query_instance",actionName:"查询云主机详情",instanceId:e.instanceId,http_request:{uri:`https://ecs.internal.cloud/api/v2/instances/${e.instanceId||""}`,method:"GET"}}}),decompile:e=>e.inputParameters?._actionId==="ecs.query_instance"?{instanceId:e.inputParameters.instanceId??""}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",status:"RUNNING",cpu:4,memoryGb:8,privateIp:"172.16.0.42",publicIp:"47.98.112.23",osName:"Alibaba Cloud Linux 3.2104",uptimeHours:360})},{id:"ecs.start_instance",name:"启动云主机",category:"compute",icon:"play",description:"将处于关机/停止状态的云主机实例开机启动",connector:"cloud_host",riskLevel:"safe",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",placeholder:"选择或填入要开机的主机 ID",required:!0,acceptsPills:!0}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"previousStatus",label:"变更前状态",type:"string",example:"STOPPED"},{key:"currentStatus",label:"当前状态",type:"string",example:"STARTING"},{key:"startedAt",label:"开机时间",type:"string",example:"2026-10-20T14:15:00Z"}],compile:(e,t)=>({name:"ecs_start_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`开机启动云主机: ${e.instanceId||""}`,inputParameters:{_actionId:"ecs.start_instance",actionName:"启动云主机",instanceId:e.instanceId,http_request:{uri:`https://ecs.internal.cloud/api/v2/instances/${e.instanceId||""}/start`,method:"POST"}}}),decompile:e=>e.inputParameters?._actionId==="ecs.start_instance"?{instanceId:e.inputParameters.instanceId??""}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",previousStatus:"STOPPED",currentStatus:"RUNNING",startedAt:new Date().toISOString()})},{id:"ecs.stop_instance",name:"停止云主机",category:"compute",icon:"stop",description:"安全关机或强制关机运行中的云主机实例",connector:"cloud_host",riskLevel:"sensitive",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",placeholder:"选择或填入要关机的主机 ID",required:!0,acceptsPills:!0},{key:"forceStop",label:"是否强制关机",type:"boolean",defaultValue:!1,help:"默认安全优雅关机,开启后若超时将直接切断电源"}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"status",label:"当前状态",type:"string",example:"STOPPED"},{key:"stoppedAt",label:"关机完成时间",type:"string",example:"2026-10-20T14:20:00Z"}],compile:(e,t)=>({name:"ecs_stop_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`停止云主机: ${e.instanceId||""}`,inputParameters:{_actionId:"ecs.stop_instance",actionName:"停止云主机",instanceId:e.instanceId,forceStop:!!e.forceStop,http_request:{uri:`https://ecs.internal.cloud/api/v2/instances/${e.instanceId||""}/stop`,method:"POST",body:{forceStop:e.forceStop}}}}),decompile:e=>e.inputParameters?._actionId==="ecs.stop_instance"?{instanceId:e.inputParameters.instanceId??"",forceStop:!!e.inputParameters.forceStop}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",status:"STOPPED",forceStop:!!e.forceStop,stoppedAt:new Date().toISOString()})},{id:"ecs.restart_instance",name:"重启云主机",category:"compute",icon:"refresh",description:"重新启动运行中的云主机(支持软重启与强制硬重启)",connector:"cloud_host",riskLevel:"sensitive",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",placeholder:"例如: i-bp18a9z3j42m09a",required:!0,acceptsPills:!0},{key:"forceRestart",label:"强制重启 (硬重启)",type:"boolean",defaultValue:!1}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"status",label:"状态",type:"string",example:"REBOOTING"},{key:"restartedAt",label:"重启时间",type:"string",example:"2026-10-20T14:22:00Z"}],compile:(e,t)=>({name:"ecs_restart_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`重启云主机: ${e.instanceId||""}`,inputParameters:{_actionId:"ecs.restart_instance",actionName:"重启云主机",instanceId:e.instanceId,forceRestart:!!e.forceRestart,http_request:{uri:`https://ecs.internal.cloud/api/v2/instances/${e.instanceId||""}/restart`,method:"POST",body:{forceRestart:!!e.forceRestart}}}}),decompile:e=>e.inputParameters?._actionId==="ecs.restart_instance"?{instanceId:e.inputParameters.instanceId??"",forceRestart:!!e.inputParameters.forceRestart}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",status:"RUNNING",restartedAt:new Date().toISOString()})},{id:"ecs.modify_spec",name:"变更实例规格 (升降配)",category:"compute",icon:"zap",description:"在线或离线升级/降低云主机 CPU 与内存硬件配置",connector:"cloud_host",riskLevel:"sensitive",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",required:!0,acceptsPills:!0},{key:"targetSpec",label:"目标规格配置",type:"select",required:!0,defaultValue:"ecs.c7.2xlarge",options:[{label:"提升至 计算型 8C16G (ecs.c7.2xlarge)",value:"ecs.c7.2xlarge"},{label:"提升至 内存型 8C32G (ecs.r7.2xlarge)",value:"ecs.r7.2xlarge"},{label:"降低至 通用型 2C4G (ecs.g7.large)",value:"ecs.g7.large"}],acceptsPills:!0}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"oldSpec",label:"变更前规格",type:"string",example:"ecs.c7.xlarge"},{key:"newSpec",label:"新规格",type:"string",example:"ecs.c7.2xlarge"},{key:"status",label:"变配状态",type:"string",example:"SUCCESS"}],compile:(e,t)=>({name:"ecs_modify_spec",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`云主机变配为 ${e.targetSpec||""}`,inputParameters:{_actionId:"ecs.modify_spec",actionName:"变更实例规格",instanceId:e.instanceId,targetSpec:e.targetSpec,http_request:{uri:`https://ecs.internal.cloud/api/v2/instances/${e.instanceId||""}/spec`,method:"PUT",body:{instanceType:e.targetSpec}}}}),decompile:e=>e.inputParameters?._actionId==="ecs.modify_spec"?{instanceId:e.inputParameters.instanceId??"",targetSpec:e.inputParameters.targetSpec??"ecs.c7.2xlarge"}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",oldSpec:"ecs.c7.xlarge",newSpec:e.targetSpec||"ecs.c7.2xlarge",status:"SUCCESS",effectiveImmediately:!0})},{id:"ecs.create_snapshot",name:"创建云盘快照",category:"storage",icon:"save",description:"为云主机的系统盘或数据盘创建实时快照,用于容灾备份或回滚",connector:"cloud_host",riskLevel:"safe",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",required:!0,acceptsPills:!0},{key:"snapshotName",label:"快照名称/备注",type:"text",defaultValue:"backup-auto-snapshot",acceptsPills:!0},{key:"retentionDays",label:"自动保留天数",type:"number",defaultValue:7,help:"过期后自动清理释放,0 为永久保留"}],outputs:[{key:"snapshotId",label:"快照ID",type:"string",example:"s-bp14209938"},{key:"snapshotName",label:"快照名称",type:"string",example:"backup-auto-snapshot"},{key:"progress",label:"创建进度",type:"string",example:"100%"},{key:"status",label:"状态",type:"string",example:"ACCOMPLISHED"}],compile:(e,t)=>({name:"ecs_create_snapshot",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`创建快照: ${e.snapshotName||t.taskReferenceName}`,inputParameters:{_actionId:"ecs.create_snapshot",actionName:"创建云盘快照",instanceId:e.instanceId,snapshotName:e.snapshotName,retentionDays:Jt(e.retentionDays,7),http_request:{uri:`https://ecs.internal.cloud/api/v2/instances/${e.instanceId||""}/snapshots`,method:"POST",body:{snapshotName:e.snapshotName,retentionDays:Jt(e.retentionDays,7)}}}}),decompile:e=>e.inputParameters?._actionId==="ecs.create_snapshot"?{instanceId:e.inputParameters.instanceId??"",snapshotName:e.inputParameters.snapshotName??"backup-auto-snapshot",retentionDays:e.inputParameters.retentionDays??7}:null,mockOutput:e=>({snapshotId:`s-bp1${Math.random().toString(36).substring(2,8)}`,snapshotName:e.snapshotName||"backup-auto-snapshot",progress:"100%",status:"ACCOMPLISHED",sizeGb:100})},{id:"ecs.run_command",name:"执行远程运维脚本",category:"compute",icon:"terminal",description:"免登录直接在云主机内部运行 Shell/Python 脚本并捕获返回日志",connector:"cloud_host",riskLevel:"sensitive",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",required:!0,acceptsPills:!0},{key:"commandType",label:"脚本语言",type:"select",defaultValue:"RunShellScript",options:[{label:"Shell 脚本 (Linux)",value:"RunShellScript"},{label:"Python 脚本",value:"RunPythonScript"}]},{key:"commandContent",label:"执行脚本命令",type:"textarea",placeholder:"例如: df -h && free -m && systemctl status nginx",defaultValue:"uptime && free -m",required:!0,acceptsPills:!0},{key:"timeoutSeconds",label:"超时时间 (秒)",type:"number",defaultValue:60}],outputs:[{key:"commandId",label:"调用批次ID",type:"string",example:"cmd-0992384"},{key:"exitCode",label:"进程退出码",type:"number",example:0},{key:"output",label:"标准输出日志",type:"string",example:"Linux 5.10.134-13.al8.x86_64"},{key:"status",label:"执行状态",type:"string",example:"SUCCESS"}],compile:(e,t)=>({name:"ecs_run_command",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`主机下发命令: ${t.taskReferenceName}`,inputParameters:{_actionId:"ecs.run_command",actionName:"执行远程运维脚本",instanceId:e.instanceId,commandType:e.commandType??"RunShellScript",commandContent:e.commandContent,timeoutSeconds:Jt(e.timeoutSeconds,60),http_request:{uri:`https://ecs.internal.cloud/api/v2/instances/${e.instanceId||""}/commands`,method:"POST",body:{commandType:e.commandType??"RunShellScript",commandContent:e.commandContent,timeoutSeconds:Jt(e.timeoutSeconds,60)}}}}),decompile:e=>e.inputParameters?._actionId==="ecs.run_command"?{instanceId:e.inputParameters.instanceId??"",commandType:e.inputParameters.commandType??"RunShellScript",commandContent:e.inputParameters.commandContent??"",timeoutSeconds:e.inputParameters.timeoutSeconds??60}:null,mockOutput:e=>({commandId:`cmd-${Date.now().toString(36)}`,exitCode:0,output:`[2026-10-20 22:30:00 UTC] Command executed on ${e.instanceId||"i-bp18a9z3j42m09a"}
|
|
131
271
|
Total Memory: 8192 MB, Free: 5410 MB
|
|
132
272
|
Load Average: 0.12, 0.08, 0.05
|
|
133
|
-
Result: OK`,status:"SUCCESS"})},{id:"ecs.get_monitor_metrics",name:"获取运行监控指标",category:"monitor",icon:"📊",description:"采集云主机的实时 CPU 利用率、内存消耗与磁盘使用率",connector:"cloud_host",riskLevel:"safe",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",required:!0,acceptsPills:!0},{key:"periodSeconds",label:"聚合统计周期",type:"select",defaultValue:60,options:[{label:"最近 1 分钟平均",value:60},{label:"最近 5 分钟平均",value:300},{label:"最近 15 分钟平均",value:900}]}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"cpuUsagePercent",label:"CPU使用率(%)",type:"number",example:45.2},{key:"memoryUsagePercent",label:"内存使用率(%)",type:"number",example:62.8},{key:"diskUsagePercent",label:"磁盘使用率(%)",type:"number",example:38.5},{key:"isOverloaded",label:"是否高负载告警",type:"boolean",example:!1}],compile:(e,t)=>({name:"ecs_get_monitor_metrics",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`采集监控指标: ${e.instanceId||t.taskReferenceName}`,inputParameters:{_actionId:"ecs.get_monitor_metrics",actionName:"获取运行监控指标",instanceId:e.instanceId,periodSeconds:Number(e.periodSeconds??60)}}),decompile:e=>e.inputParameters?._actionId==="ecs.get_monitor_metrics"?{instanceId:e.inputParameters.instanceId??"",periodSeconds:e.inputParameters.periodSeconds??60}:null,mockOutput:e=>{const t=32.4+Math.round(Math.random()*40*10)/10;return{instanceId:e.instanceId||"i-bp18a9z3j42m09a",cpuUsagePercent:t,memoryUsagePercent:58.6,diskUsagePercent:42.1,isOverloaded:t>80,collectedAt:new Date().toISOString()}}},{id:"ecs.release_instance",name:"释放下线云主机",category:"compute",icon:"🗑️",description:"彻底销毁并下线按量付费云主机,不可恢复",connector:"cloud_host",riskLevel:"sensitive",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",required:!0,acceptsPills:!0},{key:"forceRelease",label:"是否强制释放 (即刻关机并清理)",type:"boolean",defaultValue:!1}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"status",label:"最终状态",type:"string",example:"RELEASED"},{key:"releasedAt",label:"释放时间",type:"string",example:"2026-10-20T14:30:00Z"}],compile:(e,t)=>({name:"ecs_release_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`释放云主机: ${e.instanceId||""}`,inputParameters:{_actionId:"ecs.release_instance",actionName:"释放下线云主机",instanceId:e.instanceId,forceRelease:!!e.forceRelease}}),decompile:e=>e.inputParameters?._actionId==="ecs.release_instance"?{instanceId:e.inputParameters.instanceId??"",forceRelease:!!e.inputParameters.forceRelease}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",status:"RELEASED",releasedAt:new Date().toISOString()})}],Py=[{id:"notify.send_message",name:"发送运维通知",category:"notify",icon:"📢",description:"向指定运维协同群(钉钉/企微/飞书)或负责人发送通知卡片",riskLevel:"safe",fields:[{key:"channel",label:"通知渠道",type:"select",required:!0,defaultValue:"webhook_dingtalk",options:[{label:"钉钉运维机器人 (DingTalk)",value:"webhook_dingtalk"},{label:"企业微信机器人 (WeCom)",value:"webhook_wecom"},{label:"飞书群机器人 (Lark/Feishu)",value:"webhook_feishu"},{label:"运维邮件 (Email)",value:"email"}]},{key:"title",label:"通知标题",type:"text",placeholder:"例如: 【生产告警】云主机 CPU 负载过高",defaultValue:"【云平台通知】运维自动化工作流执行汇报",required:!0,acceptsPills:!0},{key:"content",label:"消息正文内容",type:"textarea",placeholder:"支持输入文字,或键入 @ 插入上游实例 ID / IP 等数据胶囊",defaultValue:"主机实例已成功处理完成,请相关人员知悉。",required:!0,acceptsPills:!0}],outputs:[{key:"messageId",label:"消息追踪ID",type:"string",example:"msg_994200"},{key:"sentStatus",label:"发送状态",type:"string",example:"DELIVERED"},{key:"sentAt",label:"送达时间",type:"string",example:"2026-10-20T14:35:00Z"}],compile:(e,t)=>({name:"send_operation_notification",taskReferenceName:t.taskReferenceName,type:"EVENT",description:`发送通知: ${e.title||t.taskReferenceName}`,inputParameters:{_actionId:"notify.send_message",actionName:"发送运维通知",channel:e.channel??"webhook_dingtalk",title:e.title,content:e.content}}),decompile:e=>e.inputParameters?._actionId==="notify.send_message"?{channel:e.inputParameters.channel??"webhook_dingtalk",title:e.inputParameters.title??"",content:e.inputParameters.content??""}:null,mockOutput:e=>({messageId:`msg-${Date.now().toString(36)}`,channel:e.channel,sentStatus:"DELIVERED",sentAt:new Date().toISOString()})},{id:"human.approval",name:"人工确认 / 审批",category:"human",icon:"👤",description:"在执行高危变动或财务扣费前,暂停流程并等待指定责任人点击确认",riskLevel:"safe",fields:[{key:"assigneeRole",label:"审批责任角色",type:"select",required:!0,defaultValue:"devops_lead",options:[{label:"运维负责人 (DevOps Lead)",value:"devops_lead"},{label:"架构师 (Architect)",value:"architect"},{label:"安全管理员 (SecOps)",value:"secops"},{label:"项目经理 (PM)",value:"pm"}]},{key:"promptMessage",label:"审批确认说明",type:"textarea",placeholder:"请输入需要审批人重点核对的信息(支持 @ 插入参数)",defaultValue:"请核实即将执行的高危变更操作,确认无误后点击批准。",required:!0,acceptsPills:!0},{key:"timeoutMinutes",label:"超时自动处理",type:"select",defaultValue:60,options:[{label:"30 分钟无响应自动拒绝",value:30},{label:"60 分钟无响应自动拒绝",value:60},{label:"24 小时等待",value:1440}]}],outputs:[{key:"approved",label:"审批结果",type:"boolean",example:!0},{key:"reviewer",label:"审批人",type:"string",example:"zhangsan@cloud.com"},{key:"comment",label:"审批意见",type:"string",example:"已核实变更方案,同意执行"},{key:"decisionTime",label:"审批时间",type:"string",example:"2026-10-20T14:40:00Z"}],compile:(e,t)=>({name:"human_operation_approval",taskReferenceName:t.taskReferenceName,type:"HUMAN",description:`人工审批: ${e.promptMessage||t.taskReferenceName}`,inputParameters:{_actionId:"human.approval",actionName:"人工确认 / 审批",assigneeRole:e.assigneeRole??"devops_lead",promptMessage:e.promptMessage,timeoutMinutes:Number(e.timeoutMinutes??60)}}),decompile:e=>e.inputParameters?._actionId==="human.approval"?{assigneeRole:e.inputParameters.assigneeRole??"devops_lead",promptMessage:e.inputParameters.promptMessage??"",timeoutMinutes:e.inputParameters.timeoutMinutes??60}:null,mockOutput:e=>({approved:!0,reviewer:"devops_lead@internal.cloud",comment:"沙盒模拟快速通过",decisionTime:new Date().toISOString()})},{id:"control.wait",name:"等待缓冲",category:"logic",icon:"⏳",description:"在两个步骤之间暂停等待一段时间(等待系统自检、镜像就绪等)",riskLevel:"safe",fields:[{key:"duration",label:"等待时长",type:"select",required:!0,defaultValue:"10s",options:[{label:"等待 5 秒 (5s)",value:"5s"},{label:"等待 10 秒 (10s)",value:"10s"},{label:"等待 30 秒 (30s)",value:"30s"},{label:"等待 1 分钟 (1m)",value:"1m"},{label:"等待 5 分钟 (5m)",value:"5m"}]}],outputs:[{key:"waited",label:"是否已就绪",type:"boolean",example:!0},{key:"duration",label:"实际等待时长",type:"string",example:"10s"}],compile:(e,t)=>({name:"wait_step",taskReferenceName:t.taskReferenceName,type:"WAIT",description:`等待 ${e.duration||"10s"}`,inputParameters:{_actionId:"control.wait",actionName:"等待缓冲",duration:e.duration??"10s"}}),decompile:e=>e.inputParameters?._actionId==="control.wait"?{duration:e.inputParameters.duration??"10s"}:e.type==="WAIT"?{duration:e.inputParameters?.duration??"10s"}:null,mockOutput:e=>({waited:!0,duration:e.duration||"10s"})},{id:"control.decision",name:"条件分支",category:"logic",icon:"🔀",description:"根据输入参数或上下文表达式,精准分流执行不同业务分支",riskLevel:"safe",fields:[{key:"caseParam",label:"分支判断参数",type:"text",required:!0,defaultValue:"status",placeholder:"例如 status 或 userType",acceptsPills:!0}],outputs:[{key:"selectedCase",label:"命中的分支名称",type:"string",example:"premium"}],compile:(e,t)=>({name:"decision_router",taskReferenceName:t.taskReferenceName,type:"DECISION",caseValueParam:e.caseParam||"status",decisionCases:{},defaultCase:[],inputParameters:{_actionId:"control.decision",actionName:"条件分支",[e.caseParam||"status"]:e[e.caseParam||"status"]??"${workflow.input.status}"}}),decompile:e=>e.type==="DECISION"||e.type==="SWITCH"?{caseParam:e.caseValueParam||"status"}:null,mockOutput:()=>({selectedCase:"SUCCESS"})},{id:"control.fork",name:"并行并发组",category:"logic",icon:"⚡",description:"同时并发执行多条独立业务泳道,并在全部完成后汇聚向下流转",riskLevel:"safe",fields:[],outputs:[{key:"lanesCompleted",label:"已完成泳道数",type:"number",example:2}],compile:(e,t)=>({name:"fork_parallel",taskReferenceName:t.taskReferenceName,type:"FORK_JOIN",forkTasks:[],inputParameters:{_actionId:"control.fork",actionName:"并行并发组"}}),decompile:e=>e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC"?{}:null,mockOutput:()=>({lanesCompleted:2})},{id:"control.loop",name:"循环迭代",category:"logic",icon:"🔁",description:"重复循环执行内部步骤,直到满足退出条件或达到最大轮次",riskLevel:"safe",fields:[{key:"loopCondition",label:"循环继续条件表达式",type:"text",required:!0,defaultValue:'$.status == "PENDING"',placeholder:'例如 $.status == "PENDING"',acceptsPills:!0}],outputs:[{key:"iterationCount",label:"实际迭代轮次",type:"number",example:3}],compile:(e,t)=>({name:"do_while_loop",taskReferenceName:t.taskReferenceName,type:"DO_WHILE",loopCondition:e.loopCondition||"false",loopOver:[],inputParameters:{_actionId:"control.loop",actionName:"循环迭代",loopCondition:e.loopCondition||"false"}}),decompile:e=>e.type==="DO_WHILE"?{loopCondition:e.loopCondition||""}:null,mockOutput:()=>({iterationCount:3})}];class Jr{actions=new Map;constructor(t=[]){this.registerAll(t)}register(t){this.actions.set(t.id,t)}registerAll(t){for(const r of t)this.register(r)}unregister(t){this.actions.delete(t)}getAction(t){return this.actions.get(t)}getAllActions(){return Array.from(this.actions.values())}getActionsByCategory(t){const r=this.getAllActions();return t?r.filter(n=>n.category===t):r}findActionForTask(t){const r=t.inputParameters?._actionId;if(r&&typeof r=="string"){const n=this.getAction(r);if(n&&n.decompile){const s=n.decompile(t);if(s)return{action:n,values:s}}}for(const n of this.actions.values())if(n.decompile){const s=n.decompile(t);if(s)return{action:n,values:s}}return null}}const De=new Jr([...Ry,...Py]);function er(e){if(e==null||e==="")return{version:1,lossy:!1};if(typeof e=="number"){if(Number.isInteger(e))return{version:e,lossy:!1};const s=Math.floor(e);return{version:Number.isFinite(s)&&s>0?s:1,label:String(e),lossy:!0}}const t=String(e).trim();if(/^\d+$/.test(t))return{version:parseInt(t,10),label:t,lossy:!1};const r=t.match(/\d+/),n=r?parseInt(r[0],10):NaN;return{version:Number.isNaN(n)?1:n,label:t,lossy:!0}}const Vr=["std","proxy","tmp","custom"],Oy=["L1","L2","L3"];function Kr(e){if(typeof e!="string")return null;const t=e.split("-");if(t.length<5)return null;const r=t[0],n=t[1];return!Vr.includes(r)||!Oy.includes(n)?null:{type:r,level:n,domain:t[2],product:t[3],func:t.slice(4).join("-")}}function Ay(e,t){const r=[];if(typeof e!="string"||e.trim()==="")return["流程名称不能为空"];const n=e.split("-");return n.length<5&&r.push("流程名称需为「类型-层级-业务域-产品-功能」5 段,以 - 分隔"),Vr.includes(n[0])||r.push(`类型「${n[0]}」不合法,应为 ${Vr.join(" / ")} 之一`),n.length>1&&!Oy.includes(n[1])&&r.push(`层级「${n[1]}」不合法,应为 L1 / L2 / L3 之一`),n.length>=5&&(n[2]===""?r.push("业务域不能为空"):t&&!t.includes(n[2])&&r.push(`业务域「${n[2]}」不在允许的列表中(${t.join("、")})`),n[3]===""&&r.push("产品不能为空"),n.slice(4).join("-")===""&&r.push("功能不能为空")),r}function Gr(e,t,r){const n=er(e.def.version),s=e.versionLabel??n.label;n.lossy&&r&&r(e.def.name,n.label??String(e.def.version));const a=Kr(e.def.name),i=e.extension?.domain||a?.domain||void 0;return{name:e.def.name,version:n.version,versionLabel:s,description:e.def.description,level:e.extension?.level??a?.level,...i?{domain:i}:{},tags:e.extension?.tags??[],deprecated:e.deprecated??e.extension?.deprecated??!1,record:e,source:t}}function iw(e){const t=er(e.version);return{record:{def:{name:e.workflowName,description:e.description,version:t.version,tasks:[]},extension:{level:e.workflowLevel,tags:e.tags??[],...e.domain?{domain:e.domain}:{}},versionLabel:t.label},lossyLabel:t.lossy?t.label:void 0}}function yc(e){const t=new Map;for(const r of e){const n=t.get(r.name);(!n||r.version>=n.version)&&t.set(r.name,r)}return Array.from(t.values())}class Dy{provider;staticItems=[];staticSchemas=[];providerEntries=[];providerTasks=[];merged=new Map;versionCache=new Map;warned=new Set;listeners=new Set;generation=0;controller=null;snapshot={status:"idle",revision:0};constructor(t,r={}){this.provider=t,this.staticItems=r.staticItems??[],this.staticSchemas=r.staticTaskSchemas??[],this.rebuild()}setProvider(t){t!==this.provider&&(this.provider=t,this.generation++,this.controller?.abort(),this.controller=null,this.providerEntries=[],this.providerTasks=[],this.versionCache.clear(),this.rebuild(),this.setState({status:"idle",error:void 0}))}setStatic(t){t.staticItems!==void 0&&(this.staticItems=t.staticItems),t.staticTaskSchemas!==void 0&&(this.staticSchemas=t.staticTaskSchemas),this.rebuild(),this.setState({})}hasProvider(){return!!this.provider}hasServerSearch(){return typeof this.provider?.search=="function"}async load(t){const r=this.provider;if(!r)return;const n=++this.generation;this.controller?.abort();const s=new AbortController;this.controller=s;const a=()=>s.abort();t&&(t.aborted?s.abort():t.addEventListener("abort",a,{once:!0})),this.setState({status:"loading",error:void 0});try{const i=await r.list(s.signal);if(n!==this.generation)return;if(s.signal.aborted){this.setState({status:"idle"});return}this.providerEntries=yc(i.workflows.map(l=>Gr(l,"provider",this.warnLossy))),this.providerTasks=i.tasks??[],this.rebuild(),this.setState({status:"ready",error:void 0})}catch(i){if(n!==this.generation)return;if(s.signal.aborted){this.setState({status:"idle"});return}this.setState({status:"error",error:i instanceof Error?i:new Error(String(i))})}finally{t?.removeEventListener("abort",a),this.controller===s&&(this.controller=null)}}reload(){return this.load()}abort(){this.controller&&(this.generation++,this.controller.abort(),this.controller=null,this.snapshot.status==="loading"&&this.setState({status:"idle"}))}latest(t){return this.merged.get(t)}entries(){return Array.from(this.merged.values())}tasks(){return this.providerTasks}staticTaskSchemas(){return this.staticSchemas}async getVersion(t,r,n){const s=`${t}@${r}`,a=this.versionCache.get(s);if(a)return a;const i=this.merged.get(t);if(i?.source==="static"&&i.version===r)return i.record;const l=this.provider;if(!l)return null;const c=this.generation,u=await l.get(t,r,n);return u&&c===this.generation&&this.versionCache.set(s,u),u}async search(t,r,n){const s=this.provider;if(!s?.search)return null;const a=await s.search(t,r,n);return yc(a.map(i=>Gr(i,"provider",this.warnLossy)))}getSnapshot=()=>this.snapshot;subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});warnLossy=(t,r)=>{const n=`${t}@${r}`;this.warned.has(n)||(this.warned.add(n),console.warn(`[LibraryCatalog] 流程库「${t}」的版本号「${r}」不是整数,已按主版本号规范化。`))};rebuild(){const t=new Map;for(const n of this.providerEntries)t.set(n.name,n);const r=yc(this.staticItems.map(n=>{const{record:s,lossyLabel:a}=iw(n);return a&&this.warnLossy(n.workflowName,a),Gr(s,"static")}));for(const n of r)t.has(n.name)||t.set(n.name,n);this.merged=t}setState(t){this.snapshot={...this.snapshot,...t,revision:this.snapshot.revision+1};for(const r of Array.from(this.listeners))r()}}function xc(e){return(Array.isArray(e.type)?e.type.find(r=>r!=="null"):e.type)||"string"}function bc(e){if(!e||e.type&&e.type!=="JSON")return null;const t=e.data;if(!t||typeof t!="object")return null;const r=t.properties;return!r||typeof r!="object"?null:{properties:r,required:Array.isArray(t.required)?t.required:[]}}function lw(e,t,r,n){const s=xc(t),a={key:e,label:t.title||e,type:"text",help:t.description,required:r,defaultValue:t.default!==void 0?t.default:n,placeholder:Array.isArray(t.examples)&&t.examples.length>0?String(t.examples[0]):void 0,acceptsPills:!0};return Array.isArray(t.enum)&&t.enum.length>0?{...a,type:"select",options:t.enum.map(i=>({label:String(i),value:i})),acceptsPills:!0}:s==="boolean"?{...a,type:"boolean",acceptsPills:!1}:s==="number"||s==="integer"?{...a,type:"number"}:s==="object"||s==="array"?{...a,type:"textarea",help:[t.description,"JSON 格式"].filter(Boolean).join(";")}:t.format==="textarea"||typeof t.maxLength=="number"&&t.maxLength>200?{...a,type:"textarea"}:a}function Yr(e,t,r){const n=bc(e);return n?Object.entries(n.properties).map(([a,i])=>lw(a,i||{},n.required.includes(a),r?.[a])):Array.from(new Set([...t,...Object.keys(r||{})])).map(a=>({key:a,label:a,type:"text",defaultValue:r?.[a],acceptsPills:!0}))}function cw(e){return Array.isArray(e)?"array":typeof e=="number"?"number":typeof e=="boolean"?"boolean":e&&typeof e=="object"?"object":"string"}function vc(e){switch(e){case"number":return 0;case"boolean":return!0;case"array":return[];case"object":return{};default:return"sample"}}function tr(e,t,r){const n=bc(e);return n?Object.entries(n.properties).map(([a,i])=>{const l=xc(i||{}),c=l==="integer"?"number":["string","number","boolean","object","array"].includes(l)?l:"string";return{key:a,label:i?.title||a,type:c,description:i?.description,example:Array.isArray(i?.examples)&&i.examples.length>0?i.examples[0]:vc(c)}}):Array.from(new Set([...t,...Object.keys(r||{})])).map(a=>{const i=r?.[a],l=typeof i=="string"&&i.includes("${"),c=l||i===void 0?"string":cw(i);return{key:a,label:a,type:c,example:l||i===void 0?vc(c):i}})}function Xr(e,t){return t?e.map(r=>t[r.key]?{...r,...t[r.key],key:r.key}:r):e}function Ly(e,t,r){const n={},s=new Set(t.map(a=>a.key));for(const[a,i]of Object.entries(e||{})){if(!s.has(a)||typeof i!="string"||i.includes("${")){n[a]=i;continue}const l=r[a];if(l==="number"||l==="integer")n[a]=i.trim()!==""&&!Number.isNaN(Number(i))?Number(i):i;else if(l==="object"||l==="array")try{n[a]=JSON.parse(i)}catch{n[a]=i}else n[a]=i}return n}function My(e){const t=bc(e),r={};if(t)for(const[n,s]of Object.entries(t.properties))r[n]=xc(s||{});return r}function $y(e){const t={};for(const r of e)t[r.key]=r.example!==void 0?r.example:vc(r.type);return t}function kc(e,t={}){if(t.hidden)return null;const r=st(e.inputParameters).map(l=>l.name),n=Xr(Yr(e.inputSchema,r,e.inputTemplate),t.fieldOverrides),s=Xr(tr(e.outputSchema,[],e.outputParameters),t.outputOverrides),a=My(e.inputSchema),i=e.version??1;return{id:`wf.${e.name}`,name:t.label||e.name,category:t.category||"custom",icon:t.icon||"🧩",description:t.description||e.description||"",connector:t.connector,kind:"workflow",workflowRef:{name:e.name,version:i},level:t.level,...t.domain?{domain:t.domain}:{},tags:t.tags,ownerEmail:e.ownerEmail,riskLevel:t.riskLevel||"safe",fields:n,outputs:s,compile:(l,c)=>{const u=c.libraryRef?.name===e.name?c.libraryRef.version:void 0;return{name:e.name,taskReferenceName:c.taskReferenceName,type:"SUB_WORKFLOW",description:t.label||e.description,inputParameters:Ly(l,n,a),subWorkflowParam:{name:e.name,...u!==void 0?{version:u}:{}}}},decompile:l=>l.type==="SUB_WORKFLOW"&&l.subWorkflowParam?.name===e.name?{...l.inputParameters||{}}:null,mockOutput:()=>$y(s)}}function Sc(e,t={}){if(t.hidden)return null;const r=Xr(Yr(e.inputSchema,e.inputKeys||[],e.inputTemplate),t.fieldOverrides),n=Xr(tr(e.outputSchema,e.outputKeys||[]),t.outputOverrides),s=My(e.inputSchema);return{id:`task.${e.name}`,name:t.label||e.name,category:t.category||"custom",icon:t.icon||"⚙️",description:t.description||e.description||"",connector:t.connector,kind:"task",level:t.level,...t.domain?{domain:t.domain}:{},tags:t.tags,ownerEmail:e.ownerEmail,riskLevel:t.riskLevel||"safe",fields:r,outputs:n,compile:(a,i)=>({name:e.name,taskReferenceName:i.taskReferenceName,type:"SIMPLE",description:t.label||e.description,inputParameters:Ly(a,r,s)}),decompile:a=>a.type==="SIMPLE"&&a.name===e.name?{...a.inputParameters||{}}:null,mockOutput:()=>$y(n)}}function dw(e){return e.map(t=>kc(t.workflowDef,t.extension)).filter(t=>t!==null)}function uw(e){return e.map(t=>Sc(t.taskDef,t.extension)).filter(t=>t!==null)}const zy={L1:1,L2:2,L3:3};function qy(e,t){return!e||!t?!0:zy[t]<=zy[e]}const pw=["compute","storage","network","monitor","notify","logic","human","custom"];function wc(e){if(!e)return{};const t=pw.includes(e.category)?e.category:void 0;return{...e.displayName?{label:e.displayName}:{},...t?{category:t}:{},...e.icon?{icon:e.icon}:{},...e.level?{level:e.level}:{},...e.domain?{domain:e.domain}:{},...e.tags?{tags:e.tags}:{},...e.action??{}}}function Wy(e){const t=[];for(const r of e.entries()){if(r.source!=="provider")continue;const n={...r.record.def,version:r.version},s=kc(n,{...r.level?{level:r.level}:{},...r.domain?{domain:r.domain}:{},...wc(r.record.extension)});s&&t.push(r.deprecated?{...s,deprecated:!0}:s)}for(const r of e.tasks()){const n=Sc(r.def,wc(r.extension));n&&t.push(n)}return t}function Fy(e){if(!e||typeof e!="object")return"string";if(Array.isArray(e.enum)&&e.enum.length>0)return e.enum.map(r=>String(r)).join("|");const t=Array.isArray(e.type)?e.type.find(r=>r!=="null"):e.type;return t==="array"?`${e.items&&typeof e.items=="object"?Fy(e.items):"any"}[]`:t||"string"}function rr(e){if(!e||e.type&&e.type!=="JSON")return;const t=e.data&&typeof e.data=="object"?e.data.properties:void 0;if(!t||typeof t!="object")return;const r={};for(const[n,s]of Object.entries(t))r[n]=Fy(s);return Object.keys(r).length>0?r:void 0}function Zr(e){const t=Array.from(new Set(e));if(t.length!==0)return Object.fromEntries(t.map(r=>[r,"string"]))}function fw(e){const t=[];for(const s of e.tasks()){const a=s.def;t.push({taskName:a.name,taskType:"SIMPLE",description:a.description,inputSchema:rr(a.inputSchema)??Zr([...a.inputKeys??[],...Object.keys(a.inputTemplate??{})]),outputSchema:rr(a.outputSchema)??Zr(a.outputKeys??[])})}for(const s of e.entries()){if(s.source!=="provider"||s.deprecated)continue;const a=s.record.def;t.push({taskName:s.name,taskType:"SUB_WORKFLOW",description:a.description,inputSchema:rr(a.inputSchema)??Zr(st(a.inputParameters).map(i=>i.name)),outputSchema:rr(a.outputSchema)??Zr(Object.keys(a.outputParameters??{}))})}const r=new Set(t.map(s=>s.taskName));return[...e.staticTaskSchemas().filter(s=>!r.has(s.taskName)),...t]}function hw(e){return By(e.entries())}function By(e){return e.filter(t=>!t.deprecated).map(t=>({workflowName:t.name,workflowLevel:t.level??"L1",version:t.source==="static"?t.versionLabel??String(t.version):String(t.version),...t.domain?{domain:t.domain}:{},description:t.description??"",tags:t.tags}))}function Hy(e,t={}){return e.filter(r=>!(r.deprecated||t.currentLevel&&r.kind==="workflow"&&!qy(t.currentLevel,r.level)))}const Qr="其他";function en(e){return e.domain?e.domain:e.kind==="workflow"?Qr:null}function Uy(e){if(!e.some(n=>!!n.domain))return[];const t=[];let r=!1;for(const n of e){const s=en(n);s!==null&&(s===Qr?r=!0:t.includes(s)||t.push(s))}return r?[...t,Qr]:t}const mw=()=>{},Jy={status:"idle",revision:0};function tn(e){return I.useSyncExternalStore(e?e.subscribe:()=>mw,e?e.getSnapshot:()=>Jy,e?e.getSnapshot:()=>Jy)}function Vy(e,t){I.useEffect(()=>(e.setProvider(t),t&&e.load(),()=>{e.abort()}),[e,t])}const Ky=["library","onboarding","telemetry"];function _c(e={}){const t=[e.override,e.component,e.context],r={};for(const n of Ky)for(const s of t){const a=s?.[n];if(a!=null){r[n]=a;break}}return r}function Gy(e,t){return e&&Ky.every(r=>e[r]===t[r])?e:t}const gw=Object.freeze({}),jc=I.createContext(gw);function Yy(e){const t=I.useRef(void 0),r=Gy(t.current,e);return t.current=r,r}function yw({providers:e,children:t}){const r=Yy(_c({component:e}));return o.jsx(jc.Provider,{value:r,children:t})}function xw(){return I.useContext(jc)}function bw(e,t){const r=I.useContext(jc);return Yy(_c({override:t,component:e,context:r}))}const vw=5e3,kw=20,Sw={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function Xy(e,t={}){if(!e)return{push(){},flush(){},dispose(){}};const r=t.flushIntervalMs??vw,n=Math.max(1,t.maxBatchSize??kw),s=t.timers??Sw,a=t.document!==void 0?t.document:typeof document<"u"?document:null,i=t.window!==void 0?t.window:typeof window<"u"?window:null;let l=[],c=null,u=!1,d=!1;const p=v=>{d||(d=!0,console.warn("[reactflow-ui] 埋点 sink 调用失败,已忽略(后续同类错误不再提示):",v))},h=()=>{c!==null&&(s.clear(c),c=null)},f=()=>{if(h(),l.length===0)return;const v=l;l=[];try{const g=e.track(v);g&&typeof g.then=="function"&&g.then(void 0,p)}catch(g){p(g)}},m=()=>{a&&a.visibilityState==="hidden"&&f()},y=()=>f();try{a?.addEventListener("visibilitychange",m),i?.addEventListener("pagehide",y)}catch(v){p(v)}return{push(v){u||(l.push(v),l.length>=n?f():c===null&&(c=s.set(f,r)))},flush:f,dispose(){if(!u){f(),u=!0;try{a?.removeEventListener("visibilitychange",m),i?.removeEventListener("pagehide",y)}catch{}}}}}function ww(e){if(!e||typeof e!="object")return;const t={};let r=0;for(const n of Object.keys(e)){const s=e[n];(typeof s=="string"||typeof s=="boolean"||typeof s=="number"&&Number.isFinite(s))&&(t[n]=s,r++)}return r>0?t:void 0}function _w(e){const t=e.now??Date.now;return(r,n)=>{try{const s={name:r,at:t(),ide:e.ide},a=e.getWorkflowName();a&&(s.workflowName=a);const i=ww(n);i&&(s.props=i),e.push(s)}catch(s){console.warn("[reactflow-ui] 埋点失败,已忽略:",s)}}}function jw(){let e=!1;return{take(){return e?!1:(e=!0,!0)}}}function Tw(e,t){const r=I.useRef(null);return I.useEffect(()=>{const n=Xy(t);return r.current=n,()=>{n.dispose(),r.current===n&&(r.current=null)}},[t]),I.useMemo(()=>_w({ide:e,getWorkflowName:()=>oe.getState().workflowDef?.name||void 0,push:n=>r.current?.push(n)}),[e])}function Iw(e){const t=I.useRef(null);t.current===null&&(t.current=jw()),I.useEffect(()=>{t.current?.take()&&e("ide_opened")},[e])}function Cw(e){I.useEffect(()=>{const t=r0(n=>e("sandbox_run",{result:n,entry:"pro"})),r=n0(n=>e("step_added",{source:n}));return()=>{t(),r()}},[e])}function Tc(e,t,r,n=De){if(e.controlType==="decision"){const a=e.rawTaskDef?structuredClone(e.rawTaskDef):{},i={};let l;for(const c of e.branches||[])c.caseKey==="__default__"?l=nr(c.steps,r,n):i[c.caseKey]=nr(c.steps,r,n);return{...a,name:e.name||a.name||e.taskReferenceName,taskReferenceName:e.taskReferenceName,type:a.type==="SWITCH"?"SWITCH":"DECISION",description:e.description??a.description,caseValueParam:e.caseParam||a.caseValueParam,caseExpression:e.caseExpression||a.caseExpression,decisionCases:i,defaultCase:l||a.defaultCase||[],inputParameters:{...a.inputParameters||{},...e.values||{}}}}if(e.controlType==="fork"){const a=e.rawTaskDef?structuredClone(e.rawTaskDef):{},i=(e.forkLanes||[]).map(l=>nr(l.steps,r,n));return{...a,name:e.name||a.name||e.taskReferenceName,taskReferenceName:e.taskReferenceName,type:a.type==="FORK_JOIN_DYNAMIC"?"FORK_JOIN_DYNAMIC":"FORK_JOIN",description:e.description??a.description,forkTasks:i,inputParameters:{...a.inputParameters||{},...e.values||{}}}}if(e.controlType==="loop"){const a=e.rawTaskDef?structuredClone(e.rawTaskDef):{},i=nr(e.loopSteps||[],r,n);return{...a,name:e.name||a.name||e.taskReferenceName,taskReferenceName:e.taskReferenceName,type:"DO_WHILE",description:e.description??a.description,loopCondition:e.loopCondition||a.loopCondition||"false",loopOver:i,inputParameters:{...a.inputParameters||{},...e.values||{}}}}if(e.isProFallback&&e.rawTaskDef)return{...e.rawTaskDef,taskReferenceName:e.taskReferenceName||e.rawTaskDef.taskReferenceName,name:e.name||e.rawTaskDef.name,description:e.description??e.rawTaskDef.description};const s=n.getAction(e.actionId);return s?s.compile(e.values,{taskReferenceName:e.taskReferenceName,stepIndex:t,workflowName:r,libraryRef:e.libraryRef}):{name:e.name||e.taskReferenceName,taskReferenceName:e.taskReferenceName,type:"SIMPLE",description:e.description,inputParameters:{_actionId:e.actionId,...e.values}}}function nr(e,t,r=De){const n=[];for(let s=0;s<e.length;s++){const a=e[s],i=Tc(a,s,t,r);if(n.push(i),a.controlType==="fork"){const l=a.pairedJoinTaskRef||`join_${a.taskReferenceName}`,c=[];if(i.forkTasks)for(const u of i.forkTasks)u&&u.length>0&&c.push(u[u.length-1].taskReferenceName);n.push({name:`${a.taskReferenceName}_join`,taskReferenceName:l,type:"JOIN",description:`Join task for ${a.taskReferenceName}`,joinOn:c.length>0?c:void 0})}}return n}function Zy(e,t=De){const r=e.rawWorkflowDef?structuredClone(e.rawWorkflowDef):{},n=nr(e.steps,e.name,t);return{...r,name:e.name||"cloud_host_automation",description:e.description||"云平台自动化工作流",version:e.version??1,schemaVersion:2,tasks:n,inputParameters:e.inputParameters||r.inputParameters}}function Qy(e,t,r=De){const n=`step_${e.taskReferenceName||`idx${t}`}`;if(e.type==="DECISION"||e.type==="SWITCH"){const a=[];if(e.decisionCases)for(const[i,l]of Object.entries(e.decisionCases))a.push({caseKey:i,caseLabel:`分支: ${i}`,steps:or(l||[],r)});return e.defaultCase&&e.defaultCase.length>0&&a.push({caseKey:"__default__",caseLabel:"默认分支 (Default)",steps:or(e.defaultCase,r)}),{id:n,actionId:"control_decision",taskReferenceName:e.taskReferenceName,name:e.description||e.name||"条件分支路由 (Decision / Switch)",description:e.description||`根据 ${e.caseValueParam||e.caseExpression||"条件"} 进行分支路由`,values:e.inputParameters||{},isProFallback:!1,rawTaskDef:structuredClone(e),controlType:"decision",caseParam:e.caseValueParam,caseExpression:e.caseExpression,branches:a}}if(e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC"){const a=(e.forkTasks||[]).map((i,l)=>({laneId:`lane_${l}`,laneLabel:`并发泳道 #${l+1}`,steps:or(i||[],r)}));return{id:n,actionId:"control_fork",taskReferenceName:e.taskReferenceName,name:e.description||e.name||"并行并发任务组 (Fork / Join)",description:e.description||`同时并发执行 ${a.length} 条独立业务泳道`,values:e.inputParameters||{},isProFallback:!1,rawTaskDef:structuredClone(e),controlType:"fork",forkLanes:a}}if(e.type==="DO_WHILE"){const a=or(e.loopOver||[],r);return{id:n,actionId:"control_loop",taskReferenceName:e.taskReferenceName,name:e.description||e.name||"循环迭代处理 (Do-While Loop)",description:e.description||`循环执行内部步骤,跳出条件: ${e.loopCondition||""}`,values:e.inputParameters||{},isProFallback:!1,rawTaskDef:structuredClone(e),controlType:"loop",loopCondition:e.loopCondition,loopSteps:a}}const s=r.findActionForTask(e);return s?{id:n,actionId:s.action.id,taskReferenceName:e.taskReferenceName,name:s.action.name,description:e.description,values:s.values,isProFallback:!1,...e.type==="SUB_WORKFLOW"&&e.subWorkflowParam?.name?{libraryRef:{name:e.subWorkflowParam.name,version:e.subWorkflowParam.version}}:{}}:{id:n,actionId:"pro_custom_task",taskReferenceName:e.taskReferenceName,name:e.name||e.taskReferenceName,description:e.description||`底层 ${e.type} 技术任务`,values:e.inputParameters||{},isProFallback:!0,rawTaskDef:structuredClone(e)}}function or(e,t=De){const r=new Set;for(let s=0;s<e.length;s++)if(e[s].type==="FORK_JOIN"){for(let a=s+1;a<e.length;a++)if(e[a].type==="JOIN"){r.add(e[a].taskReferenceName);break}}const n=[];for(let s=0;s<e.length;s++){const a=e[s];if(a.type==="JOIN"&&r.has(a.taskReferenceName))continue;const i=Qy(a,s,t);if(i.controlType==="fork"){for(let l=s+1;l<e.length;l++)if(e[l].type==="JOIN"){i.pairedJoinTaskRef=e[l].taskReferenceName;break}}n.push(i)}return n}function ex(e,t=De){if(!e)return{name:"new_cloud_automation",description:"新建云平台运维自动化流程",version:1,steps:[]};const r=or(e.tasks||[],t);return{name:e.name||"unnamed_workflow",description:e.description||"",version:e.version||1,steps:r,inputParameters:e.inputParameters,rawWorkflowDef:structuredClone(e)}}const Nw=({upstreamSteps:e,onSelect:t,onClose:r,registry:n=De,workflowInputParams:s})=>{const[a,i]=I.useState(""),l=I.useMemo(()=>{const u=[];s&&s.length>0&&u.push({stepTitle:"工作流全局入参",stepIcon:"🌐",stepRef:"workflow.input",items:s.map(d=>{const p=typeof d=="string"?d:d.name;return{rawRef:`workflow.input.${p}`,label:typeof d=="object"&&d.description?d.description:p,type:typeof d=="object"&&d.type?d.type:"string",example:typeof d=="object"?d.example??d.defaultValue:void 0,stepLabel:"全局入参"}})});for(let d=0;d<e.length;d++){const p=e[d],h=n.getAction(p.actionId),f=`#${d+1} ${p.name||h?.name||p.taskReferenceName}`,m=h?.icon||"⚙️",y=[];if(h&&h.outputs.length>0)for(const v of h.outputs)y.push({rawRef:`${p.taskReferenceName}.output.${v.key}`,label:v.label,type:v.type,example:v.example,stepLabel:p.name||h.name});else y.push({rawRef:`${p.taskReferenceName}.output`,label:"完整输出对象",type:"object",example:"{ ... }",stepLabel:p.name});u.push({stepTitle:f,stepIcon:m,stepRef:p.taskReferenceName,items:y})}return u},[e,n,s]),c=I.useMemo(()=>{if(!a.trim())return l;const u=a.toLowerCase();return l.map(d=>({...d,items:d.items.filter(p=>p.label.toLowerCase().includes(u)||p.rawRef.toLowerCase().includes(u))})).filter(d=>d.items.length>0)},[l,a]);return o.jsxs("div",{style:{position:"absolute",top:"100%",left:0,zIndex:1100,width:340,maxHeight:380,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",borderRadius:8,boxShadow:"0 12px 32px rgba(0,0,0,0.35)",display:"flex",flexDirection:"column",overflow:"hidden",marginTop:4,fontFamily:"inherit"},children:[o.jsxs("div",{style:{padding:"8px 10px",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",gap:8,background:"var(--bg-tertiary)"},children:[o.jsx("span",{style:{fontSize:13},children:"🏷️"}),o.jsx("input",{autoFocus:!0,type:"text",placeholder:"搜索上游输出字段...",value:a,onChange:u=>i(u.target.value),style:{flex:1,background:"transparent",border:"none",outline:"none",color:"var(--text-primary)",fontSize:12}}),o.jsx("button",{onClick:r,style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:14,padding:"2px 4px"},title:"关闭",children:"✕"})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",padding:"6px 4px"},children:c.length===0?o.jsx("div",{style:{padding:"24px 12px",textAlign:"center",color:"var(--text-muted, #94a3b8)",fontSize:12},children:e.length===0?"当前步骤是第 1 步,前面暂无可引用的上游步骤输出":"未找到匹配的字段"}):c.map(u=>o.jsxs("div",{style:{marginBottom:8},children:[o.jsxs("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted, #94a3b8)",padding:"4px 8px",display:"flex",alignItems:"center",gap:6},children:[o.jsx("span",{children:u.stepIcon}),o.jsx("span",{children:u.stepTitle})]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2},children:u.items.map(d=>o.jsxs("div",{onClick:()=>{t({rawRef:d.rawRef,label:d.label,stepLabel:d.stepLabel}),r()},style:{padding:"6px 10px",borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background 0.15s ease",fontSize:12},onMouseEnter:p=>{p.currentTarget.style.background="var(--bg-highlight)"},onMouseLeave:p=>{p.currentTarget.style.background="transparent"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,overflow:"hidden"},children:[o.jsx("span",{style:{fontWeight:500,color:"var(--text-primary)",whiteSpace:"nowrap"},children:d.label}),o.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:d.rawRef})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[d.example!==void 0&&o.jsx("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:4,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.12))",color:"var(--color-accent-text, #1e40af)",fontFamily:"monospace",maxWidth:90,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:`样例值: ${String(d.example)}`,children:String(d.example)}),o.jsx("span",{style:{fontSize:10,padding:"1px 4px",borderRadius:3,background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:d.type})]})]},d.rawRef))})]},u.stepRef))}),o.jsx("div",{style:{padding:"4px 8px",background:"var(--bg-tertiary)",borderTop:"1px solid var(--border-primary)",fontSize:10,color:"var(--text-muted)",textAlign:"right"},children:"点击将变量以数据胶囊形式插入"})]})},Ic=({value:e,onChange:t,placeholder:r,multiline:n=!1,upstreamSteps:s,registry:a=De,workflowInputParams:i,disabled:l=!1,defaultShowPicker:c=!1})=>{const[u,d]=I.useState(c),p=I.useRef(null),h=I.useRef(null),f=e!=null?String(e):"",m=I.useMemo(()=>{const g=f.matchAll(/\$\{([^}]+)\}/g),x=[];for(const b of g){const k=b[0],S=b[1].trim();let C=S;for(const T of s)if(S.startsWith(`${T.taskReferenceName}.output`)){const N=a.getAction(T.actionId),w=S.replace(`${T.taskReferenceName}.output.`,""),_=N?.outputs.find(j=>j.key===w);_?C=`${T.name||N?.name||T.taskReferenceName} · ${_.label}`:C=`${T.name||T.taskReferenceName} 输出`;break}S.startsWith("workflow.input.")&&(C=`全局入参 · ${S.slice(15)}`),x.push({raw:k,ref:S,label:C})}return x},[f,s,a]),y=g=>{const x=`\${${g.rawRef}}`,b=h.current;if(b){const k=b.selectionStart??f.length,S=b.selectionEnd??f.length,C=f.substring(0,k)+x+f.substring(S);t(C),setTimeout(()=>{b.focus(),b.setSelectionRange(k+x.length,k+x.length)},0)}else t(f?`${f} ${x}`:x)},v=g=>{g.key==="@"&&d(!0)};return o.jsxs("div",{ref:p,style:{position:"relative",display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[o.jsxs("div",{style:{display:"flex",alignItems:n?"flex-start":"center",gap:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",borderRadius:6,padding:"4px 8px",transition:"border-color 0.15s ease"},children:[n?o.jsx("textarea",{ref:h,disabled:l,value:f,placeholder:r||"输入内容,或按 @ 插入上游数据胶囊...",rows:3,onChange:g=>t(g.target.value),onKeyDown:v,style:{flex:1,background:"transparent",border:"none",outline:"none",color:"var(--text-primary)",fontSize:13,fontFamily:"inherit",resize:"vertical",lineHeight:1.5}}):o.jsx("input",{ref:h,type:"text",disabled:l,value:f,placeholder:r||"输入内容,或按 @ 插入数据胶囊...",onChange:g=>t(g.target.value),onKeyDown:v,style:{flex:1,background:"transparent",border:"none",outline:"none",color:"var(--text-primary)",fontSize:13,fontFamily:"inherit"}}),o.jsxs("button",{type:"button",disabled:l,onClick:()=>d(!u),title:"点击选择并插入上游数据胶囊 (@)",style:{background:u?"var(--color-accent-bg, rgba(59, 130, 246, 0.15))":"var(--bg-tertiary)",color:u?"var(--color-accent, #3b82f6)":"var(--text-secondary)",border:`1px solid ${u?"var(--color-accent, #3b82f6)":"var(--border-primary)"}`,borderRadius:4,padding:"2px 8px",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,flexShrink:0,transition:"all 0.15s ease"},children:[o.jsx("span",{children:"🏷️"}),o.jsx("span",{children:"插入数据"})]})]}),m.length>0&&o.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,alignItems:"center",padding:"2px 2px"},children:[o.jsx("span",{style:{fontSize:10,color:"var(--text-muted)"},children:"已引用胶囊:"}),m.map((g,x)=>o.jsxs("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:12,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.12))",color:"var(--color-accent-text, #1e40af)",border:"1px solid color-mix(in srgb, var(--color-accent, #3b82f6) 35%, transparent)",display:"inline-flex",alignItems:"center",gap:4,fontWeight:500},title:`原始引用表达式: ${g.raw}`,children:[o.jsx("span",{children:"🔗"}),o.jsx("span",{children:g.label})]},`${g.ref}_${x}`))]}),u&&o.jsx(Nw,{upstreamSteps:s,workflowInputParams:i,registry:a,onSelect:y,onClose:()=>d(!1)})]})},Cc=({step:e,upstreamSteps:t,workflowInputParams:r,registry:n=De,onChange:s,disabled:a=!1})=>{const i=n.getAction(e.actionId);if(e.isProFallback||!i)return o.jsxs("div",{style:{padding:16,background:"rgba(255, 255, 255, 0.03)",borderRadius:8,border:"1px dashed var(--border-secondary, rgba(255, 255, 255, 0.2))",display:"flex",flexDirection:"column",gap:12},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontSize:20},children:"🔧"}),o.jsxs("div",{children:[o.jsxs("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:14},children:[e.name||e.taskReferenceName," (底层技术步骤)"]}),o.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)"},children:["任务类型: ",e.rawTaskDef?.type||"CUSTOM"]})]})]}),o.jsx("p",{style:{fontSize:12,color:"var(--text-secondary)",lineHeight:1.6,margin:0},children:"该步骤属于底层控制流或未映射的 Conductor 任务。在业务模式下已为您无损保留其参数与依赖关系。如需深度修改其底层 JQ 脚本或 JSON Schema,请切换至右上方「全景画布模式」。"})]});const l=(c,u)=>{const d={...e.values,[c]:u};s({...e,values:d})};return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[i.riskLevel==="sensitive"&&o.jsxs("div",{style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--color-error) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--color-error) 25%, transparent)",fontSize:12,color:"var(--color-error)",lineHeight:1.5},children:["💡 ",o.jsx("strong",{children:"操作安全网"}),":此步骤会直接影响真实云主机的运行状态(关机、重启、变配或下线)。建议在流程设计中,于本步骤之前放置一个「人工确认/审批」步骤,确保生产稳定性。"]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:i.fields.map(c=>{const u=e.values[c.key]??c.defaultValue;return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("label",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"center",gap:4},children:[c.label,c.required&&o.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),c.help&&o.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:c.help})]}),c.type==="select"?o.jsx(Ew,{value:u,options:c.options??[],allowDynamic:c.acceptsPills!==!1,disabled:a,placeholder:c.placeholder,upstreamSteps:t,workflowInputParams:r,registry:n,onChange:d=>l(c.key,d)}):c.type==="boolean"?o.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13,color:"var(--text-secondary)"},children:[o.jsx("input",{type:"checkbox",disabled:a,checked:!!u,onChange:d=>l(c.key,d.target.checked),style:{width:16,height:16,cursor:"pointer"}}),o.jsx("span",{children:"开启 / 启用"})]}):c.acceptsPills?o.jsx(Ic,{disabled:a,value:u,placeholder:c.placeholder,multiline:c.type==="textarea",upstreamSteps:t,workflowInputParams:r,registry:n,onChange:d=>l(c.key,d)}):c.type==="textarea"?o.jsx("textarea",{disabled:a,rows:3,value:u??"",placeholder:c.placeholder,onChange:d=>l(c.key,d.target.value),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:13,outline:"none",fontFamily:"inherit"}}):o.jsx("input",{disabled:a,type:c.type==="number"?"number":"text",value:u??"",placeholder:c.placeholder,onChange:d=>l(c.key,c.type==="number"?Number(d.target.value):d.target.value),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:13,outline:"none",fontFamily:"inherit"}})]},c.key)})}),i.outputs.length>0&&o.jsxs("div",{style:{marginTop:8,padding:"10px 12px",background:"var(--bg-tertiary)",borderRadius:6,border:"1px solid var(--border-primary)"},children:[o.jsx("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",marginBottom:6},children:"📋 本步骤产生的数据(可被后续步骤引用):"}),o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:i.outputs.map(c=>o.jsxs("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:4,background:"var(--bg-secondary)",color:"var(--text-secondary)",border:"1px solid var(--border-primary)",display:"inline-flex",alignItems:"center",gap:4},children:[o.jsx("span",{children:"🏷️"}),o.jsx("span",{children:c.label}),o.jsxs("span",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"monospace"},children:["(",c.key,")"]})]},c.key))})]})]})},rn=e=>typeof e=="string"&&e.includes("${"),Ew=({value:e,options:t,allowDynamic:r,disabled:n,placeholder:s,upstreamSteps:a,workflowInputParams:i,registry:l,onChange:c})=>{const[u,d]=I.useState(()=>rn(e)),[p,h]=I.useState(!1),f={flexShrink:0,background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-primary)",borderRadius:4,padding:"2px 8px",fontSize:11,cursor:n?"not-allowed":"pointer",whiteSpace:"nowrap"};return r&&u?o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[o.jsx(Ic,{disabled:n,value:rn(e)?e:"",placeholder:s||"插入上游数据,运行时取值",upstreamSteps:a,workflowInputParams:i,registry:l,defaultShowPicker:p,onChange:c}),o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[o.jsxs("span",{style:{fontSize:11,color:"var(--text-muted)"},children:["动态取值:运行时的值需为可选项之一(",t.map(m=>m.label).join(" / "),")"]}),o.jsx("button",{type:"button",disabled:n,style:f,onClick:()=>{d(!1),h(!1),rn(e)&&c(t[0]?.value??"")},children:"改为选择"})]})]}):o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("select",{disabled:n,value:rn(e)?"":e??"",onChange:m=>c(m.target.value),style:{flex:1,minWidth:0,padding:"7px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:13,outline:"none",cursor:"pointer"},children:t.map(m=>o.jsx("option",{value:m.value,children:m.label},String(m.value)))}),r&&o.jsx("button",{type:"button",disabled:n,title:"改为引用上游步骤输出或全局入参,运行时取值",style:f,onClick:()=>{d(!0),h(!0)},children:"🏷️ 插入数据"})]})};function kt(e){const t=`${Date.now().toString(36).slice(-4)}${Math.random().toString(36).slice(2,4)}`,r=`${e.id.replace(/\./g,"_")}_${t}`;if(e.id==="control.decision")return{id:`step_${r}`,actionId:"control_decision",taskReferenceName:r,name:"条件分支路由",description:"根据输入参数或上下文表达式分流执行",values:{caseParam:"status"},controlType:"decision",caseParam:"status",branches:[{caseKey:"SUCCESS",caseLabel:"分支: SUCCESS",steps:[]},{caseKey:"__default__",caseLabel:"默认分支 (Default)",steps:[]}],isProFallback:!1};if(e.id==="control.fork")return{id:`step_${r}`,actionId:"control_fork",taskReferenceName:r,name:"并行并发组",description:"同时并发执行多条独立业务泳道",values:{},controlType:"fork",forkLanes:[{laneId:"lane_0",laneLabel:"并发泳道 #1",steps:[]},{laneId:"lane_1",laneLabel:"并发泳道 #2",steps:[]}],isProFallback:!1};if(e.id==="control.loop")return{id:`step_${r}`,actionId:"control_loop",taskReferenceName:r,name:"循环迭代处理",description:"重复循环执行内部步骤,直到满足退出条件",values:{loopCondition:'$.status == "PENDING"'},controlType:"loop",loopCondition:'$.status == "PENDING"',loopSteps:[],isProFallback:!1};const n={};for(const s of e.fields)s.defaultValue!==void 0&&(n[s.key]=s.defaultValue);return{id:`step_${r}`,actionId:e.id,taskReferenceName:r,name:e.name,description:e.description,values:n,isProFallback:!1,...e.kind==="workflow"&&e.workflowRef?{libraryRef:{name:e.workflowRef.name,version:e.workflowRef.version}}:{}}}function tx(e){return e!=null&&e!==""}function rx(e){let t;switch(e.type){case"select":t=`可选值 ${(e.options??[]).map(r=>String(r.value)).join("|")}`;break;case"number":t="数字";break;case"boolean":t="布尔";break;default:t="文本"}return e.required?`${t},必填`:t}function nx(e){const t=st(e.inputParameters).map(r=>r.name);return Yr(e.inputSchema,t,e.inputTemplate)}function ox(e){return tr(e.outputSchema,[],e.outputParameters).map(t=>t.key)}function ax(e,t,r={},n={}){const s=new Map(nx(e).map(m=>[m.key,m])),a=new Map(nx(t).map(m=>[m.key,m])),i=[],l=[],c=[];for(const[m,y]of a){const v=s.get(m);if(!v){i.push(y);continue}const g=rx(v),x=rx(y);g!==x&&c.push({key:m,from:g,to:x,valueFilled:tx(r[m])})}for(const[m,y]of s)a.has(m)||l.push(y);const u=ox(e),d=ox(t),p=d.filter(m=>!u.includes(m)),h=u.filter(m=>!d.includes(m)),f=new Set(n.referencedOutputs??[]);return{addedInputs:i,removedInputs:l,changedInputs:c,addedOutputs:p,removedOutputs:h,lostValueKeys:l.filter(m=>tx(r[m.key])).map(m=>m.key),brokenOutputRefs:h.filter(m=>f.has(m))}}function sx(e){return e.addedInputs.length===0&&e.removedInputs.length===0&&e.changedInputs.length===0&&e.addedOutputs.length===0&&e.removedOutputs.length===0}function ix(e,t){const r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp(`\\$\\{\\s*${r}\\.output\\.([^.\\s}\\[\\]]+)`,"g"),s=new Set,a=new Set,i=l=>{if(typeof l=="string"){n.lastIndex=0;let c;for(;(c=n.exec(l))!==null;)s.add(c[1]);return}if(!(!l||typeof l!="object"||a.has(l))){a.add(l);for(const c of Array.isArray(l)?l:Object.values(l))i(c)}};for(const l of t)i(l);return s}function nn(e){return e.label&&e.label!==e.key?`${e.label}(${e.key})`:e.key}function lx(e){const t=[],r=[];for(const n of e.removedInputs)e.lostValueKeys.includes(n.key)?t.push(`入参「${nn(n)}」已删除,已填写的值将丢失`):r.push(`入参「${nn(n)}」已删除`);for(const n of e.removedOutputs)e.brokenOutputRefs.includes(n)?t.push(`出参「${n}」已删除,下游步骤对它的引用将失效`):r.push(`出参「${n}」已删除`);for(const n of e.changedInputs){const s=`入参「${n.key}」由「${n.from}」变为「${n.to}」`;n.valueFilled?t.push(`${s},已填写的值可能不再有效`):r.push(s)}for(const n of e.addedInputs)n.required?t.push(`新增必填入参「${nn(n)}」,需要补充填写`):r.push(`新增入参「${nn(n)}」`);for(const n of e.addedOutputs)r.push(`新增出参「${n}」`);return{impacts:t,changes:r}}function cx(e,t,r,n){const s=`流程库「${e}」已有新版本 v${r}(当前引用 v${t??"?"})。`;if(sx(n))return`${s}
|
|
134
|
-
|
|
135
|
-
`)}function dx(e,t){const r={...e};for(const n of t.removedInputs)delete r[n.key];for(const n of t.addedInputs)n.defaultValue!==void 0&&r[n.key]===void 0&&(r[n.key]=n.defaultValue);return r}function ux(e){const{pinned:t,catalogStatus:r,latest:n,pinnedExists:s}=e;return t===void 0?{kind:"unpinned"}:r===void 0?n&&n.version>t?{kind:"upgradable",pinned:t,latest:n.version}:{kind:"pinned",pinned:t}:r!=="ready"?{kind:"pinned",pinned:t}:n?n.deprecated?{kind:"unavailable",pinned:t,reason:"deprecated"}:t>n.version?{kind:"unavailable",pinned:t,reason:"missing-version"}:t<n.version?s===!1?{kind:"unavailable",pinned:t,reason:"missing-version"}:{kind:"upgradable",pinned:t,latest:n.version}:s===!1?{kind:"unavailable",pinned:t,reason:"missing-version"}:{kind:"pinned",pinned:t}:{kind:"unavailable",pinned:t,reason:"removed"}}function px(e,t,r){switch(r){case"deprecated":return`流程库「${e}」已下线 / 不建议新引用。本步骤仍按固定的 v${t} 编译,不会自动改变版本。`;case"removed":return`流程库中已找不到「${e}」。本步骤仍按固定的 v${t} 编译,不会自动改变版本,请确认运行环境中该版本是否仍可用。`;default:return`流程库中不存在「${e}」的 v${t}。本步骤仍按固定版本编译,不会自动改变版本,请确认运行环境中该版本是否仍可用。`}}const Rw=({step:e,action:t,disabled:r,catalog:n,getReferencedOutputs:s,onUpgrade:a})=>{const{confirm:i,confirmState:l,handleConfirm:c,handleCancel:u}=Br(),d=tn(n),[p,h]=I.useState(!1),[f,m]=I.useState(void 0),y=e.libraryRef,v=y?.version,g=y?n?.latest(y.name):void 0,x=t?.workflowRef?.version,b=!!n&&(g!==void 0||x===void 0),k=g?{version:g.version,deprecated:g.deprecated}:x!==void 0?{version:x,deprecated:!1}:void 0,S=b&&d.status==="ready"&&v!==void 0&&!!g&&g.version>v,C=y?.name;if(I.useEffect(()=>{if(!S||!n||!C||v===void 0){m(void 0);return}const w=new AbortController;return n.getVersion(C,v,w.signal).then(_=>{w.signal.aborted||m(_!==null)}).catch(()=>{w.signal.aborted||m(void 0)}),()=>w.abort()},[S,n,C,v]),!y)return null;const T=ux({pinned:v,catalogStatus:b?d.status:void 0,latest:k,pinnedExists:S?f:void 0}),N=async w=>{if(w.stopPropagation(),T.kind!=="upgradable")return;const{pinned:_,latest:j}=T;let P;if(n&&g&&g.source==="provider"){h(!0);try{const[L,B]=await Promise.all([n.getVersion(y.name,_),n.getVersion(y.name,j)]);L&&B&&(P=ax(L.def,B.def,e.values,{referencedOutputs:s?.()}))}catch{P=void 0}finally{h(!1)}}const E=P?cx(y.name,_,j,P):`流程库「${y.name}」已有新版本 v${j}(当前引用 v${_})。升级后入参、出参可能发生变化,请升级后检查本步骤配置。确定升级吗?`;await i(E)&&a(j,P)};return o.jsxs(o.Fragment,{children:[o.jsxs("span",{title:v!==void 0?`引用流程库「${y.name}」,已固定版本 v${v},库升级后不会自动变化`:`引用流程库「${y.name}」,未固定版本,沿用原定义`,style:{fontSize:10,padding:"1px 5px",borderRadius:4,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.12))",color:"var(--color-accent-text, #1e40af)",fontWeight:600},children:["📚 流程库",v!==void 0?` v${v}`:""]}),T.kind==="upgradable"&&!r&&o.jsx("button",{onClick:N,disabled:p,title:"查看升级差异并升级到库中最新版本",style:{fontSize:10,padding:"1px 6px",borderRadius:4,border:"1px solid #f59e0b",background:"rgba(245, 158, 11, 0.12)",color:"#f59e0b",fontWeight:600,cursor:p?"wait":"pointer"},children:p?"正在比较版本…":`⬆ 有新版本 v${T.latest}`}),T.kind==="unavailable"&&o.jsx("span",{title:px(y.name,T.pinned,T.reason),style:{fontSize:10,padding:"1px 6px",borderRadius:4,border:"1px solid #ef4444",background:"rgba(239, 68, 68, 0.12)",color:"#ef4444",fontWeight:600},children:"⚠ 版本不可用"}),l&&o.jsx("span",{onClick:w=>w.stopPropagation(),children:o.jsx(xt,{message:l.message,onConfirm:c,onCancel:u})})]})},Pw=200,Ow=({registry:e,stepNumber:t,onClose:r,onSelect:n,currentWorkflowLevel:s,libraryCatalog:a})=>{const i=tn(a),{theme:l,themeColor:c}=oe(ke(S=>({theme:S.theme,themeColor:S.themeColor}))),[u,d]=I.useState("all"),[p,h]=I.useState(null),[f,m]=I.useState(""),y=I.useMemo(()=>Hy(e.getAllActions(),{currentLevel:s}),[e,s]),v=I.useMemo(()=>Uy(y),[y]),g=v.length>0,x=I.useMemo(()=>{const S=f.trim().toLowerCase();return y.filter(C=>{const T=g?en(C):null;let N;p!==null?N=T===p:u==="all"?N=!0:N=T===null&&C.category===u;const w=!S||C.name.toLowerCase().includes(S)||C.description.toLowerCase().includes(S);return N&&w})},[y,g,u,p,f]),b=I.useMemo(()=>x.slice(0,Pw),[x]);if(typeof document>"u")return null;const k=[{id:"all",label:"全部"},{id:"compute",label:"🖥️ 计算与主机"},{id:"storage",label:"💾 存储快照"},{id:"monitor",label:"📊 监控指标"},{id:"notify",label:"📢 通知消息"},{id:"human",label:"👤 人工审批"},{id:"logic",label:"⏳ 流程控制"},{id:"custom",label:g?"🧩 自定义":"🧩 流程库 / 自定义"}];return Ge.createPortal(o.jsx("div",{"data-mode":l,"data-brand":c,style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(2px)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center",padding:24,fontFamily:"inherit",colorScheme:l==="light"?"light":"dark"},onClick:r,children:o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":`选择要插入的业务动作(第 ${t} 步)`,onClick:S=>S.stopPropagation(),style:{width:760,maxWidth:"calc(100vw - 48px)",height:"min(640px, 84vh)",background:"var(--bg-primary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRadius:12,boxShadow:"0 20px 48px rgba(0, 0, 0, 0.35)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"14px 18px",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",gap:12},children:[o.jsxs("div",{style:{fontWeight:600,fontSize:15,flex:1,whiteSpace:"nowrap"},children:["选择业务动作",o.jsxs("span",{style:{marginLeft:8,fontSize:12,fontWeight:400,color:"var(--text-muted)"},children:["第 ",t," 步"]})]}),o.jsx("input",{type:"text",autoFocus:!0,placeholder:"搜索动作名称或描述…",value:f,onChange:S=>m(S.target.value),style:{width:240,padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:12,outline:"none"}}),o.jsx("button",{onClick:r,"aria-label":"关闭",style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:16,padding:4,lineHeight:1},children:"✕"})]}),o.jsxs("div",{style:{padding:"10px 18px",borderBottom:"1px solid var(--border-primary)",background:"var(--bg-secondary)",display:"flex",flexDirection:"column",gap:8},children:[o.jsx(fx,{label:"分类",children:k.map(S=>o.jsx(hx,{active:p===null&&u===S.id,onClick:()=>{d(S.id),h(null)},children:S.label},S.id))}),g&&o.jsx(fx,{label:"业务域",children:v.map(S=>o.jsx(hx,{active:p===S,onClick:()=>h(S),children:S},`domain:${S}`))})]}),i.status==="loading"&&o.jsx("div",{style:{padding:"6px 18px",fontSize:12,color:"var(--text-muted)",background:"var(--bg-secondary)"},children:"正在加载流程库…"}),i.status==="error"&&o.jsxs("div",{style:{padding:"6px 18px",fontSize:12,color:"var(--color-error)",background:"var(--bg-secondary)",display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{title:i.error?.message,children:"流程库加载失败,其它动作仍可使用"}),o.jsx("button",{onClick:()=>{a?.reload()},style:{background:"none",border:"1px solid currentColor",borderRadius:4,color:"inherit",cursor:"pointer",fontSize:11,padding:"1px 8px"},children:"点击重试"})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:16,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:10,alignContent:"start"},children:[b.map(S=>{const C=[S.level,en(S)??void 0].filter(Boolean).join(" · ");return o.jsxs("button",{type:"button",onClick:()=>n(S),onMouseEnter:T=>{T.currentTarget.style.borderColor="var(--color-accent)",T.currentTarget.style.background="var(--bg-tertiary)"},onMouseLeave:T=>{T.currentTarget.style.borderColor="var(--border-primary)",T.currentTarget.style.background="var(--bg-secondary)"},style:{textAlign:"left",font:"inherit",padding:"10px 12px",borderRadius:8,background:"var(--bg-secondary)",border:"1px solid var(--border-primary)",color:"var(--text-primary)",cursor:"pointer",display:"flex",flexDirection:"column",gap:4,transition:"border-color 0.15s ease, background 0.15s ease"},children:[o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:8,width:"100%"},children:[o.jsx("span",{style:{fontSize:18,lineHeight:1},children:S.icon}),o.jsx("span",{style:{fontWeight:600,fontSize:13,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:S.name}),S.riskLevel==="sensitive"&&o.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"color-mix(in srgb, var(--color-warning) 16%, transparent)",color:"var(--color-warning)",fontWeight:600,flexShrink:0},children:"敏感"})]}),C&&o.jsx("span",{style:{fontSize:10,color:"var(--color-accent-text)"},children:C}),o.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)",lineHeight:1.45},children:S.description})]},S.id)}),b.length===0&&o.jsxs("div",{style:{gridColumn:"1 / -1",textAlign:"center",padding:"32px 0",fontSize:12,color:"var(--text-muted)"},children:["没有符合条件的动作",f?",换个关键词试试":""]}),x.length>b.length&&o.jsxs("div",{style:{gridColumn:"1 / -1",textAlign:"center",fontSize:12,color:"var(--text-muted)"},children:["共 ",x.length," 项,仅显示前 ",b.length," 项,请用搜索缩小范围"]})]})]})}),document.body)},fx=({label:e,children:t})=>o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[o.jsx("span",{style:{flexShrink:0,width:40,paddingTop:4,fontSize:12,color:"var(--text-muted)"},children:e}),o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,flex:1},children:t})]}),hx=({active:e,onClick:t,children:r})=>o.jsx("button",{type:"button",onClick:t,"aria-pressed":e,style:{padding:"3px 10px",borderRadius:999,fontSize:12,lineHeight:"18px",cursor:"pointer",fontWeight:e?600:400,background:e?"var(--color-accent-bg)":"transparent",color:e?"var(--color-accent-text)":"var(--text-secondary)",border:`1px solid ${e?"var(--color-accent)":"var(--border-secondary)"}`},children:r}),Nc=({step:e,upstreamSteps:t,registry:r=De,disabled:n=!1,onChange:s,onOpenInsertModal:a,depth:i=0})=>{const l=e.forkLanes||[],{confirm:c,confirmState:u,handleConfirm:d,handleCancel:p}=Br(),[h,f]=I.useState(l[0]?.laneId||"lane_0"),m=(b,k)=>{const S=l.map(C=>C.laneId===b?{...C,steps:k}:C);s({...e,forkLanes:S})},y=()=>{const b=l.length,k={laneId:`lane_${b}_${Date.now().toString(36).slice(-4)}`,laneLabel:`并发泳道 #${b+1}`,steps:[]},S=[...l,k];s({...e,forkLanes:S}),f(k.laneId)},v=async(b,k)=>{if(k.stopPropagation(),l.length<=1||!await c("确定要删除此条并行泳道及其内部步骤吗?"))return;const S=l.filter(C=>C.laneId!==b);s({...e,forkLanes:S}),h===b&&f(S[0]?.laneId||"")},g=b=>{const k=l.find(S=>S.laneId===b);k&&a(S=>{const C=kt(S);m(b,[...k.steps,C])})},x=l.reduce((b,k)=>b+(k.steps?.length||0),0);return o.jsxs("div",{style:{borderRadius:12,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.08)",overflow:"hidden",transition:"all 0.2s ease"},children:[o.jsxs("div",{style:{padding:"12px 16px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"rgba(59, 130, 246, 0.15)",color:"var(--color-accent, #3b82f6)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,fontWeight:700},children:"⚡"}),o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary)"},children:e.name||"并行并发任务组"}),o.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.12))",color:"var(--color-accent-text, #1e40af)",fontWeight:600,border:"1px solid color-mix(in srgb, var(--color-accent, #3b82f6) 30%, transparent)"},children:"⚡ 并行并发 (Fork / Join)"})]}),o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:["同时并发执行 ",l.length," 条独立业务泳道 · 涵盖 ",x," 个并发步骤"]})]})]}),!n&&o.jsxs("button",{onClick:y,style:{padding:"4px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px dashed var(--border-secondary)",color:"var(--text-primary)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4},children:[o.jsx("span",{children:"+"}),o.jsx("span",{children:"新增并发泳道"})]})]}),o.jsx("div",{style:{padding:"14px 16px",background:"var(--bg-primary)",display:"grid",gridTemplateColumns:l.length>1?`repeat(${Math.min(l.length,3)}, minmax(240px, 1fr))`:"1fr",gap:12,overflowX:"auto"},children:l.map((b,k)=>o.jsxs("div",{style:{borderRadius:8,background:"var(--bg-secondary)",border:"1px solid var(--border-primary)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"8px 12px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsx("span",{style:{fontSize:13},children:"🏊"}),o.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:b.laneLabel||`泳道 #${k+1}`}),o.jsxs("span",{style:{fontSize:10,padding:"0 5px",borderRadius:8,background:"var(--bg-secondary)",color:"var(--text-muted)"},children:[b.steps.length," 步"]})]}),!n&&l.length>1&&o.jsx("button",{onClick:S=>v(b.laneId,S),title:"删除此泳道",style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11,padding:"2px 4px"},children:"✕"})]}),o.jsxs("div",{style:{padding:10,flex:1,display:"flex",flexDirection:"column",gap:8,minHeight:80},children:[b.steps.length===0?o.jsx("div",{style:{padding:"16px 8px",textAlign:"center",color:"var(--text-muted)",fontSize:11,border:"1px dashed var(--border-secondary)",borderRadius:6},children:"此泳道暂无步骤"}):o.jsx(Rc,{steps:b.steps,onStepsChange:S=>m(b.laneId,S),upstreamSteps:t,registry:r,disabled:n,depth:i,onOpenInsertModal:a,variant:"compact",rowTone:"primary"}),!n&&o.jsx("button",{onClick:()=>g(b.laneId),style:{padding:"4px 8px",borderRadius:4,background:"transparent",border:"1px dashed var(--border-secondary)",color:"var(--text-muted)",fontSize:11,cursor:"pointer",marginTop:2},children:"+ 追加并发步骤"})]})]},b.laneId))}),o.jsxs("div",{style:{padding:"8px 16px",background:"var(--bg-tertiary)",borderTop:"1px solid var(--border-primary)",fontSize:11,color:"var(--text-secondary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsx("span",{children:"🔗"}),o.jsxs("span",{children:[o.jsx("strong",{children:"汇聚同步点 (Join)"}),":所有 ",l.length," 条并行泳道内步骤全部执行完毕后,在同步节点汇聚并继续向下执行。"]})]}),e.pairedJoinTaskRef&&o.jsx("code",{style:{fontSize:10,color:"var(--text-muted)",background:"var(--bg-secondary)",padding:"1px 6px",borderRadius:4},children:e.pairedJoinTaskRef})]}),u&&o.jsx(xt,{message:u.message,onConfirm:d,onCancel:p})]})},Ec=({step:e,upstreamSteps:t,registry:r=De,disabled:n=!1,onChange:s,onOpenInsertModal:a,depth:i=0})=>{const l=e.loopSteps||[],c=d=>{s({...e,loopSteps:d})},u=()=>{a(d=>{const p=kt(d);c([...l,p])})};return o.jsxs("div",{style:{borderRadius:12,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.08)",overflow:"hidden",transition:"all 0.2s ease"},children:[o.jsxs("div",{style:{padding:"12px 16px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.15))",color:"var(--color-accent, #3b82f6)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,fontWeight:700},children:"🔁"}),o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary)"},children:e.name||"循环迭代处理"}),o.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.12))",color:"var(--color-accent-text, #1e40af)",fontWeight:600,border:"1px solid color-mix(in srgb, var(--color-accent, #3b82f6) 30%, transparent)"},children:"🔁 循环迭代 (Do-While Loop)"})]}),o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:["循环体包含 ",l.length," 个步骤 · 每次迭代执行完将重新评估跳出条件"]})]})]}),!n&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:"循环继续条件:"}),o.jsx("input",{type:"text",value:e.loopCondition||"",placeholder:"如 $.status == 'PENDING'",onChange:d=>s({...e,loopCondition:d.target.value}),style:{width:200,padding:"4px 8px",borderRadius:4,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:11,fontFamily:"monospace"}})]})]}),o.jsx("div",{style:{padding:"14px 16px",background:"var(--bg-primary)"},children:o.jsxs("div",{style:{borderRadius:8,border:"2px dashed color-mix(in srgb, var(--color-accent, #3b82f6) 45%, var(--border-secondary))",background:"var(--bg-secondary)",padding:12},children:[o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginBottom:10,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsx("span",{children:"🔄"}),o.jsxs("span",{children:[o.jsx("strong",{children:"循环体内部任务序列"})," (每轮迭代将依次执行以下 ",l.length," 个步骤):"]})]}),!n&&o.jsxs("button",{onClick:u,style:{padding:"3px 8px",borderRadius:4,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.1))",border:"1px solid color-mix(in srgb, var(--color-accent, #3b82f6) 40%, transparent)",color:"var(--color-accent-text, #1e40af)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,fontWeight:500},children:[o.jsx("span",{children:"+"}),o.jsx("span",{children:"追加循环步骤"})]})]}),l.length===0?o.jsx("div",{style:{padding:"20px 12px",textAlign:"center",color:"var(--text-muted)",fontSize:11},children:"循环体内暂无任务,请点击右上角「+ 追加循环步骤」添加轮询或重复执行动作"}):o.jsx(Rc,{steps:l,onStepsChange:c,upstreamSteps:t,registry:r,disabled:n,depth:i,onOpenInsertModal:a,rowTone:"primary",indexPrefix:"轮内 ",accentIndexBadge:!0})]})}),o.jsxs("div",{style:{padding:"8px 16px",background:"var(--bg-tertiary)",borderTop:"1px solid var(--border-primary)",fontSize:11,color:"var(--text-secondary)",display:"flex",alignItems:"center",gap:6},children:[o.jsx("span",{children:"🛑"}),o.jsxs("span",{children:[o.jsx("strong",{children:"跳出与安全保护"}),":当条件表达式评估为 false 时自动跳出循环向下继续;引擎内置循环熔断保护,防止生产环境死循环。"]})]})]})},mx={decision:"#8b5cf6",fork:"#3b82f6",loop:"#10b981"},Aw=({step:e,index:t,depth:r=1,upstreamSteps:n,registry:s=De,disabled:a=!1,onChange:i,onDelete:l,onOpenInsertModal:c})=>{const u=mx[e.controlType||"decision"]||mx.decision,d=e.controlType==="fork"?"嵌套并行":e.controlType==="loop"?"嵌套循环":"嵌套分支",p={step:e,upstreamSteps:n,registry:s,disabled:a,onChange:i,onOpenInsertModal:c};return o.jsxs("div",{style:{borderLeft:`3px solid ${u}`,paddingLeft:10,marginLeft:Math.min(r-1,3)*2,display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("span",{style:{fontSize:11,fontWeight:700,color:`color-mix(in srgb, ${u} 80%, var(--text-primary))`},children:["#",t+1," ",d,"(第 ",r," 层)"]}),!a&&o.jsx("button",{onClick:l,title:"删除此嵌套控制流及其内部所有步骤",style:{background:"none",border:"none",color:"#ef4444",cursor:"pointer",fontSize:12,padding:"2px 4px"},children:"🗑️"})]}),e.controlType==="fork"?o.jsx(Nc,{...p,depth:r}):e.controlType==="loop"?o.jsx(Ec,{...p,depth:r}):o.jsx(Pc,{...p,depth:r})]})},Rc=({steps:e,onStepsChange:t,upstreamSteps:r,registry:n=De,disabled:s=!1,depth:a,onOpenInsertModal:i,variant:l="regular",rowTone:c="primary",indexPrefix:u="",accentIndexBadge:d=!1})=>{const[p,h]=I.useState(null),f=l==="compact",m=c==="secondary"?"var(--bg-secondary)":"var(--bg-primary)",y=c==="secondary"?"var(--bg-primary)":"var(--bg-secondary)",v=(x,b)=>{const k=[...e];k[x]=b,t(k)},g=x=>t(e.filter((b,k)=>k!==x));return o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:e.map((x,b)=>{const k=[...r,...e.slice(0,b)];if(x.controlType)return o.jsx(Aw,{step:x,index:b,depth:a+1,upstreamSteps:k,registry:n,disabled:s,onChange:N=>v(b,N),onDelete:()=>g(b),onOpenInsertModal:i},x.id);const S=n.getAction(x.actionId),C=p===x.id,T=()=>h(C?null:x.id);return o.jsxs("div",{style:{borderRadius:f?6:8,background:m,border:C?"1px solid var(--color-accent, #3b82f6)":"1px solid var(--border-primary)",overflow:"hidden",transition:f?void 0:"all 0.15s ease"},children:[o.jsxs("div",{onClick:T,style:{padding:f?"6px 8px":"8px 12px",display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:f?6:8,overflow:"hidden"},children:[!f&&o.jsxs("span",{style:{fontSize:10,fontWeight:700,padding:"1px 5px",borderRadius:4,background:d?"var(--color-accent-bg, rgba(59, 130, 246, 0.12))":"var(--bg-tertiary)",color:"var(--color-accent-text, #1e40af)"},children:[u,"#",b+1]}),o.jsx("span",{style:{fontSize:f?14:16},children:S?.icon||"⚙️"}),f?o.jsx("span",{style:{fontSize:11,fontWeight:600,color:"var(--text-primary)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:x.name||S?.name}):o.jsxs("div",{children:[o.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:x.name||S?.name||x.taskReferenceName}),o.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"monospace"},children:x.taskReferenceName})]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:f?4:6},onClick:N=>N.stopPropagation(),children:[!s&&o.jsx("button",{onClick:()=>g(b),title:"删除此步骤",style:{background:"none",border:"none",color:"#ef4444",cursor:"pointer",fontSize:f?11:12,padding:f?"1px 3px":"2px 4px"},children:"🗑️"}),o.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",transform:C?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.15s ease",cursor:"pointer"},onClick:T,children:"▼"})]})]}),C&&o.jsx("div",{style:{padding:f?10:"12px 14px",borderTop:"1px solid var(--border-primary)",background:y},children:o.jsx(Cc,{step:x,upstreamSteps:k,registry:n,disabled:s,onChange:N=>v(b,N)})})]},x.id)})})},Pc=({step:e,upstreamSteps:t,registry:r=De,disabled:n=!1,onChange:s,onOpenInsertModal:a,depth:i=0})=>{const l=e.branches||[],[c,u]=I.useState(l[0]?.caseKey||"__default__"),[d,p]=I.useState(""),[h,f]=I.useState(!1),[m,y]=I.useState(""),{confirm:v,confirmState:g,handleConfirm:x,handleCancel:b}=Br(),k=l.find(_=>_.caseKey===c)||l[0],S=(_,j)=>{const P=l.map(E=>E.caseKey===_?{...E,steps:j}:E);s({...e,branches:P})},C=()=>{const _=d.trim();if(!_)return;if(l.some(P=>P.caseKey===_)){y(`分支 "${_}" 已存在`);return}const j=[...l,{caseKey:_,caseLabel:`分支: ${_}`,steps:[]}];s({...e,branches:j}),u(_),p(""),y(""),f(!1)},T=async(_,j)=>{j.stopPropagation();const P=_==="__default__"?"确定要删除默认分支吗?":`确定要删除分支 "${_}" 及其内部所有步骤吗?`;if(!await v(P))return;const E=l.filter(A=>A.caseKey!==_);s({...e,branches:E}),c===_&&u(E[0]?.caseKey||"")},N=()=>{k&&a(_=>{const j=kt(_);S(k.caseKey,[...k.steps,j])})},w=l.reduce((_,j)=>_+(j.steps?.length||0),0);return o.jsxs("div",{style:{borderRadius:12,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",boxShadow:"0 4px 16px rgba(0, 0, 0, 0.08)",overflow:"hidden",transition:"all 0.2s ease"},children:[o.jsxs("div",{style:{padding:"12px 16px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"rgba(139, 92, 246, 0.15)",color:"color-mix(in srgb, #8b5cf6 85%, var(--text-primary))",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,fontWeight:700},children:"🔀"}),o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary)"},children:e.name||"条件分支路由"}),o.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"rgba(139, 92, 246, 0.12)",color:"color-mix(in srgb, #8b5cf6 85%, var(--text-primary))",fontWeight:600,border:"1px solid rgba(139, 92, 246, 0.3)"},children:"🔀 条件路由 (Decision / Switch)"})]}),o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:["判断参数:"," ",o.jsx("code",{style:{color:"var(--color-accent-text, #1e40af)",background:"var(--bg-secondary)",padding:"1px 4px",borderRadius:4},children:e.caseParam||e.caseExpression||"未指定参数"})," ","· 共包含 ",l.length," 个分支,共 ",w," 个分支内业务步骤"]})]})]}),!n&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:"判断字段:"}),o.jsx("input",{type:"text",value:e.caseParam||e.caseExpression||"",placeholder:"如 userType 或 $.status",onChange:_=>s({...e,caseParam:_.target.value}),style:{width:140,padding:"4px 8px",borderRadius:4,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:11}})]})]}),o.jsx("div",{style:{padding:"8px 16px",background:"var(--bg-primary)",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between",flexWrap:"wrap",gap:8},children:o.jsxs("div",{style:{display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[o.jsx("span",{style:{fontSize:11,color:"var(--text-muted)",marginRight:4},children:"分支列表:"}),l.map(_=>{const j=_.caseKey===c,P=_.caseKey==="__default__";return o.jsxs("div",{onClick:()=>u(_.caseKey),style:{padding:"4px 10px",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:j?600:400,background:j?"var(--color-accent-bg, rgba(59, 130, 246, 0.15))":"var(--bg-secondary)",color:j?"var(--color-accent-text, #1e40af)":"var(--text-secondary)",border:`1px solid ${j?"var(--color-accent, #3b82f6)":"var(--border-primary)"}`,display:"inline-flex",alignItems:"center",gap:6,transition:"all 0.15s ease"},children:[o.jsx("span",{children:P?"🍂":"🌿"}),o.jsx("span",{children:P?"默认分支 (Default)":_.caseKey}),o.jsx("span",{style:{fontSize:10,padding:"0 4px",borderRadius:8,background:j?"var(--color-accent, #3b82f6)":"var(--bg-tertiary)",color:j?"#fff":"var(--text-muted)"},children:_.steps?.length||0}),!n&&l.length>1&&o.jsx("span",{onClick:E=>T(_.caseKey,E),title:"删除此分支",style:{fontSize:11,color:"var(--text-muted)",marginLeft:2,cursor:"pointer"},children:"✕"})]},_.caseKey)}),!n&&!h&&o.jsx("button",{onClick:()=>f(!0),style:{padding:"4px 8px",borderRadius:6,background:"transparent",border:"1px dashed var(--border-secondary)",color:"var(--text-muted)",fontSize:11,cursor:"pointer"},children:"+ 新增分支"}),!n&&h&&o.jsxs("div",{style:{display:"inline-flex",alignItems:"center",gap:4},children:[o.jsx("input",{autoFocus:!0,type:"text",value:d,placeholder:"分支标识,如 VIP",onChange:_=>{p(_.target.value),m&&y("")},onKeyDown:_=>_.key==="Enter"&&C(),style:{padding:"3px 6px",borderRadius:4,border:"1px solid var(--color-accent, #3b82f6)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontSize:11,width:110}}),m&&o.jsx("span",{style:{fontSize:11,color:"#ef4444"},children:m}),o.jsx("button",{onClick:C,style:{padding:"3px 8px",borderRadius:4,background:"var(--color-accent, #3b82f6)",color:"#fff",border:"none",fontSize:11,cursor:"pointer"},children:"确认"}),o.jsx("button",{onClick:()=>{f(!1),p(""),y("")},style:{padding:"3px 6px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11},children:"取消"})]})]})}),o.jsx("div",{style:{padding:"14px 16px",background:"var(--bg-primary)"},children:k?o.jsxs("div",{children:[o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginBottom:10,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("span",{children:["👉 当判断命中 ",o.jsx("strong",{children:k.caseKey})," 时,将依次串行执行以下步骤:"]}),!n&&o.jsxs("button",{onClick:N,style:{padding:"3px 8px",borderRadius:4,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.12))",border:"1px solid var(--color-accent, #3b82f6)",color:"var(--color-accent-text, #1e40af)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,fontWeight:500},children:[o.jsx("span",{children:"+"}),o.jsx("span",{children:"追加分支步骤"})]})]}),k.steps.length===0?o.jsx("div",{style:{padding:"24px 16px",borderRadius:8,border:"1px dashed var(--border-secondary)",textAlign:"center",color:"var(--text-muted)",fontSize:12,background:"var(--bg-secondary)"},children:"当前分支暂无步骤,点击右上方「+ 追加分支步骤」配置分支业务逻辑"}):o.jsx(Rc,{steps:k.steps,onStepsChange:_=>S(k.caseKey,_),upstreamSteps:t,registry:r,disabled:n,depth:i,onOpenInsertModal:a,rowTone:"secondary"})]}):o.jsx("div",{style:{textAlign:"center",color:"var(--text-muted)",fontSize:12},children:"请选择或新增一个分支进行配置"})}),o.jsxs("div",{style:{padding:"6px 14px",background:"var(--bg-tertiary)",borderTop:"1px solid var(--border-primary)",fontSize:10,color:"var(--text-muted)",display:"flex",alignItems:"center",gap:4},children:[o.jsx("span",{children:"💡"}),o.jsx("span",{children:"分支执行逻辑:运行时仅会精准执行匹配的分支路径,未命中的分支步骤将安全跳过。"})]}),g&&o.jsx(xt,{message:g.message,onConfirm:x,onCancel:b})]})};function gx(e,t,r){const n=(e||"").toLowerCase();return t===401||t===403||n.includes("401")||n.includes("403")||n.includes("unauthorized")||n.includes("forbidden")||n.includes("token expired")||n.includes("invalid api key")||n.includes("signature does not match")?{type:"auth",title:"云平台账号授权已失效或权限受限",explanation:`在调用【${r||"云服务"}】时未通过安全身份核验。通常是因为配置的账号密钥 (AccessKey/Token) 已过期失效,或该账号缺乏对应资源的操作授权。`,suggestion:"建议检查账号授权状态,重新填入有效密钥或联系企业管理员为该账号分配权限。",actionLabel:"重新授权密钥",actionKey:"reauth"}:t===504||n.includes("timeout")||n.includes("timed out")||n.includes("etimedout")||n.includes("deadline")||n.includes("connection refused")?{type:"timeout",title:"目标云主机响应超时",explanation:`向【${r||"主机"}】发送指令后,在约定的时间内未收到回应。可能是云主机刚开机系统服务尚未就绪,或所在子网的安全组策略拦截了通信端口。`,suggestion:"云服务正在进行底层引导,通常稍等片刻自动重试即可恢复。",actionLabel:"稍后自动重试",actionKey:"retry"}:n.includes("exit code")||n.includes("command failed")||n.includes("command not found")||n.includes("syntax error")?{type:"script_fail",title:"主机内部脚本执行异常退出",explanation:"下发到云主机内部的 Shell/Python 脚本在运行过程中遇到错误并提前中断。通常是因为目标环境中缺少前置依赖库,或指定的文件路径不存在。",suggestion:"可展开下方查看脚本的标准输出日志排查具体报错,修正脚本后重新执行。",actionLabel:"查看脚本输出日志",actionKey:"inspect_upstream"}:n.includes("nullpointer")||n.includes("cannot read property")||n.includes("undefined")||n.includes("field not found")||n.includes("parameter not found")||n.includes("missing required parameter")?{type:"missing_data",title:"缺少必要的上游输入数据",explanation:"本步骤引用的上游步骤没有返回预期的数据内容(例如没有获取到有效的「主机实例ID」或「内网IP」),导致后续步骤无法继续执行。",suggestion:"请点击检查上游步骤的输出结果,确认上游任务是否正常产生了所需的数据胶囊。",actionLabel:"查看上游步骤数据",actionKey:"inspect_upstream"}:n.includes("quota")||n.includes("limit exceeded")||n.includes("insufficient")||n.includes("out of stock")||n.includes("balance")?{type:"quota",title:"可用区资源库存不足或配额受限",explanation:"当前所选可用区该型号的云主机规格暂时售罄,或云平台租户的配额上限已满。",suggestion:"建议在流程中更换目标规格(如选择通用型或计算型同等配置),或申请提升账号配额。",actionLabel:"更换规格/可用区",actionKey:"change_spec"}:n.includes("network")||n.includes("dns")||n.includes("unreachable")||n.includes("failed to fetch")?{type:"network",title:"网络通信中断或无法解析",explanation:"调度服务与目标云服务之间的网络连接不稳定,或专有网络 VPC 路由未打通。",suggestion:"请检查网络连通性配置,或联系网络运维人员协助排查。",actionLabel:"重新尝试连接",actionKey:"retry"}:{type:"unknown",title:"步骤执行未达预期",explanation:e||"执行过程中底层服务报告了非成功状态,请查阅详细日志。",suggestion:"可点击重试此步骤,或将此诊断报告反馈给技术支持排查。",actionLabel:"重试此任务",actionKey:"retry"}}const yx=({rawError:e,statusCode:t,taskName:r,onActionClick:n})=>{const[s,a]=I.useState(!1),i=gx(e,t,r);return o.jsxs("div",{style:{borderRadius:10,background:"rgba(239, 68, 68, 0.08)",border:"1px solid rgba(239, 68, 68, 0.3)",padding:"14px 16px",display:"flex",flexDirection:"column",gap:10,fontFamily:"inherit"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontSize:18},children:i.type==="auth"?"🔑":i.type==="timeout"?"⏱️":i.type==="missing_data"?"⚠️":i.type==="quota"?"💳":"❌"}),o.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--status-failed, #ef4444)"},children:i.title})]}),i.actionLabel&&o.jsxs("button",{onClick:()=>n?.(i.actionKey),style:{padding:"4px 10px",borderRadius:6,background:"color-mix(in srgb, var(--status-failed, #ef4444) 15%, transparent)",border:"1px solid color-mix(in srgb, var(--status-failed, #ef4444) 30%, transparent)",color:"var(--status-failed, #ef4444)",fontSize:11,fontWeight:600,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4},children:[o.jsx("span",{children:"⚡"}),o.jsx("span",{children:i.actionLabel})]})]}),o.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",lineHeight:1.6},children:i.explanation}),o.jsxs("div",{style:{padding:"8px 12px",borderRadius:6,background:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",fontSize:11,color:"var(--color-warning, #d97706)",lineHeight:1.5},children:["💡 ",o.jsx("strong",{children:"建议做法"}),":",i.suggestion]}),e&&o.jsxs("div",{style:{marginTop:2},children:[o.jsx("button",{onClick:()=>a(!s),style:{background:"none",border:"none",color:"var(--text-muted, #94a3b8)",fontSize:10,cursor:"pointer",padding:0,display:"inline-flex",alignItems:"center",gap:4},children:o.jsx("span",{children:s?"▾ 折叠底层技术报错":"▸ 展开底层技术报错 (供研发/技术支持排查)"})}),s&&o.jsx("div",{style:{marginTop:6,padding:"8px 10px",borderRadius:4,background:"rgba(0, 0, 0, 0.35)",color:"var(--text-muted, #94a3b8)",fontFamily:"monospace",fontSize:10,lineHeight:1.4,maxHeight:120,overflowY:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:e})]})]})};function Dw(e,t){const r=e.outputData||{},n=e.workflowTask?.inputParameters?._actionId,s=n?t.getAction(n):void 0;if(e.status==="FAILED"||e.status==="FAILED_WITH_TERMINAL_ERROR")return"执行中断于此步骤,已触发异常诊断自愈建议。";if(n==="ecs.create_instance"){const a=r.privateIp?` · 分配内网 IP: ${r.privateIp}`:"";return`成功在可用区初始化并启动云主机${r.instanceId?` · 实例 ID: ${r.instanceId}`:""}${a}。`}return n==="ecs.query_instance"?`已查询获取主机实时状态 (${r.status||"RUNNING"}),公网 IP: ${r.publicIp||"未绑定"}。`:n==="ecs.run_command"?`远程运维脚本已成功在主机内执行完毕,命令批次: ${r.commandId||"cmd-ok"}。`:n==="ecs.create_snapshot"?`系统盘安全增量快照已成功归档,快照 ID: ${r.snapshotId||"s-done"}。`:n==="ecs.stop_instance"?"云主机已安全关闭电源,当前状态: STOPPED。":n==="ecs.start_instance"?"云主机已开机并启动系统服务,当前状态: RUNNING。":n==="ecs.modify_spec"?`云主机硬件规格已在线变更生效 (${r.oldSpec||""} → ${r.newSpec||""})。`:n==="ecs.get_monitor_metrics"?`采集到实时负载:CPU 利用率 ${r.cpuUsagePercent??20}%,系统运行平稳。`:n==="notify.send_message"?"运维协同卡片已成功推送至指定协同通知群,状态: DELIVERED。":n==="control.wait"||e.taskType==="WAIT"?"系统安全缓冲等待完成,底层服务就绪。":n==="human.approval"||e.taskType==="HUMAN"?`责任人 (${r.reviewer||"devops_lead"}) 已完成审核批准。`:e.taskType==="DECISION"||e.taskType==="SWITCH"?`条件分支路由完成:评估参数命中分支 [${r.selectedCase||r.case||r.output||""||"主干分支"}],正向下分流执行。`:e.taskType==="FORK_JOIN"||e.taskType==="FORK_JOIN_DYNAMIC"?"并行并发已触发:多条独立业务泳道同时展开并发执行。":e.taskType==="JOIN"?"并行汇聚同步完成:所有并发泳道已全部成功执行完毕,工作流汇合向下推进。":e.taskType==="DO_WHILE"?`循环迭代处理完成:已执行 ${e.iteration||r.iteration||1} 轮循环,评估跳出条件已满足。`:`${s?.name||e.taskDefName||e.referenceTaskName} 执行完毕。`}const xx=({instance:e,registry:t=De,onInspectStep:r})=>{const[n,s]=I.useState({}),a=d=>{s(p=>({...p,[d]:!p[d]}))},i=e.tasks||[],l=e.status==="FAILED"||e.status==="TIMED_OUT",u=((e.endTime&&e.startTime?e.endTime-e.startTime:0)/1e3).toFixed(1);return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16,padding:"16px 20px",background:"var(--bg-primary)",height:"100%",overflowY:"auto",fontFamily:"inherit"},children:[o.jsxs("div",{style:{padding:"12px 18px",borderRadius:10,background:l?"rgba(239, 68, 68, 0.1)":"rgba(16, 185, 129, 0.1)",border:`1px solid ${l?"rgba(239, 68, 68, 0.3)":"rgba(16, 185, 129, 0.3)"}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{fontSize:24},children:l?"❌":"🎉"}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:700,fontSize:14,color:l?"var(--status-failed, #ef4444)":"var(--status-completed, #10b981)"},children:l?"工作流执行中断":"工作流全部步骤顺利执行完毕"}),o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:["执行 ID: ",e.workflowId," · 共执行 ",i.length," 个步骤 · 总耗时约 ",u," 秒"]})]})]}),o.jsx("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:4,fontWeight:600,background:l?"rgba(239, 68, 68, 0.15)":"rgba(16, 185, 129, 0.15)",color:l?"var(--status-failed, #ef4444)":"var(--status-completed, #10b981)"},children:e.status})]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:i.map((d,p)=>{const h=d.workflowTask?.inputParameters?._actionId,f=h?t.getAction(h):void 0,m=f?.icon||(d.taskType==="DECISION"||d.taskType==="SWITCH"?"🔀":d.taskType==="FORK_JOIN"||d.taskType==="FORK_JOIN_DYNAMIC"?"⚡":d.taskType==="JOIN"?"🔗":d.taskType==="DO_WHILE"?"🔁":d.taskType==="WAIT"?"⏳":d.taskType==="HUMAN"?"👤":"⚙️"),y=d.status==="FAILED"||d.status==="FAILED_WITH_TERMINAL_ERROR",v=!!n[d.referenceTaskName],g=Dw(d,t),x=d.startTime?new Date(d.startTime).toLocaleTimeString():"--:--:--",b=d.endTime&&d.startTime?`${((d.endTime-d.startTime)/1e3).toFixed(2)}s`:"";return o.jsxs("div",{style:{borderRadius:10,background:"var(--bg-secondary)",border:y?"1px solid var(--status-failed, #ef4444)":"1px solid var(--border-primary)",boxShadow:y?"0 4px 16px rgba(239, 68, 68, 0.12)":"none",padding:"12px 16px",display:"flex",flexDirection:"column",gap:8},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{fontSize:18},children:y?"❌":m}),o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsxs("span",{style:{fontWeight:600,fontSize:13,color:"var(--text-primary)"},children:["步骤 #",p+1,": ",f?.name||d.taskDefName||d.referenceTaskName]}),o.jsx("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,background:y?"rgba(239, 68, 68, 0.15)":"rgba(16, 185, 129, 0.15)",color:y?"var(--status-failed, #ef4444)":"var(--status-completed, #10b981)",fontWeight:600},children:y?"执行失败":"执行完成"})]}),o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:[x," ",b&&`· 耗时 ${b}`]})]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[r&&o.jsx("button",{onClick:()=>r(d.referenceTaskName),style:{padding:"2px 8px",borderRadius:4,background:"transparent",border:"1px solid var(--border-secondary)",color:"var(--text-secondary)",fontSize:11,cursor:"pointer"},children:"定位步骤"}),o.jsx("button",{onClick:()=>a(d.referenceTaskName),style:{background:"none",border:"none",color:"var(--text-muted)",fontSize:11,cursor:"pointer"},children:v?"收起数据 ▴":"查看数据 ▾"})]})]}),o.jsx("div",{style:{fontSize:12,color:y?"var(--status-failed, #ef4444)":"var(--text-secondary)",lineHeight:1.5,padding:"4px 0"},children:g}),y&&o.jsx("div",{style:{marginTop:4},children:o.jsx(yx,{rawError:d.reasonForIncompletion||"底层任务状态异常终止",taskName:f?.name||d.referenceTaskName})}),v&&d.outputData&&o.jsx("div",{style:{marginTop:8,padding:"10px 12px",borderRadius:8,background:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",display:"flex",flexWrap:"wrap",gap:8},children:Object.entries(d.outputData).map(([k,S])=>typeof S=="object"&&S!==null?null:o.jsxs("span",{style:{fontSize:11,padding:"3px 8px",borderRadius:6,background:"var(--color-accent-bg, rgba(59, 130, 246, 0.12))",border:"1px solid color-mix(in srgb, var(--color-accent, #3b82f6) 30%, transparent)",display:"inline-flex",alignItems:"center",gap:6,fontFamily:"monospace"},children:[o.jsxs("span",{style:{color:"var(--text-muted)"},children:[k,":"]}),o.jsx("span",{style:{color:"var(--color-accent-text, #1e40af)",fontWeight:600},children:String(S)})]},k))})]},d.taskId||d.referenceTaskName||p)})})]})},bx=({workflowDef:e,onChange:t,registry:r=De,readOnly:n=!1,workflowExecution:s,libraryCatalog:a,currentWorkflowLevel:i,onAskAi:l,onStepAdded:c,onSandboxRun:u})=>{const d=I.useMemo(()=>ex(e,r),[e,r]),[p,h]=I.useState(null),[f,m]=I.useState(null),[y,v]=I.useState(null),[g,x]=I.useState(!1),[b,k]=I.useState(null),[S,C]=I.useState(s||null),[T,N]=I.useState(s?"story":"steps");I.useEffect(()=>{s&&(C(s),N("story"))},[s]);const w=d.steps,_=z=>{const R={...d,steps:z},q=Zy(R,r);t(q)},j=(z,R)=>{const q=[...w];q[z]=R,_(q)},P=z=>{if(n)return;const R=w.filter((q,M)=>M!==z);p===w[z]?.id&&h(null),_(R)},E=(z,R)=>{if(n||R<0||R>=w.length)return;const q=[...w],[M]=q.splice(z,1);q.splice(R,0,M),_(q)},A=z=>{v(()=>z),m(0)},L=(z,R)=>{if(c?.({source:z.kind==="workflow"?"library":"builtin"}),y){y(z),v(null),m(null);return}const q=kt(z),M=[...w];M.splice(R,0,q),m(null),h(q.id),_(M)},B=()=>{if(e){x(!0);try{const z={},R=O=>{for(const W of O){const U=r.getAction(W.actionId);U&&U.mockOutput&&(z[W.taskReferenceName]=U.mockOutput(W.values));for(const $ of W.branches||[])R($.steps);for(const $ of W.forkLanes||[])R($.steps);R(W.loopSteps||[])}};R(w);const q=Gt(e,{taskMocks:z});C(q),N("story");const M={};for(const O of q.tasks)M[O.referenceTaskName]={status:O.status,output:O.outputData};k(M),u?.(String(q.status))}catch(z){console.error("[StepFlowEditor] Dry run error:",z),u?.("error")}finally{x(!1)}}};return o.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",background:"var(--bg-primary, #0f172a)",overflowY:"auto",fontFamily:"inherit"},children:[o.jsxs("div",{style:{padding:"12px 20px",borderBottom:"1px solid var(--border-primary, rgba(255,255,255,0.1))",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bg-secondary, #1e293b)",flexShrink:0},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{fontSize:18},children:"📋"}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary, #f8fafc)"},children:d.name||"云平台业务流程"}),o.jsxs("div",{style:{fontSize:12,color:"var(--text-muted, #94a3b8)"},children:["共 ",w.length," 个业务执行步骤 · 普通用户零代码模式"]})]})]}),S&&o.jsxs("div",{style:{display:"inline-flex",background:"rgba(255, 255, 255, 0.06)",borderRadius:6,padding:2,border:"1px solid var(--border-secondary, rgba(255, 255, 255, 0.15))"},children:[o.jsx("button",{onClick:()=>N("steps"),style:{padding:"4px 10px",borderRadius:4,border:"none",background:T==="steps"?"var(--color-accent, #3b82f6)":"transparent",color:T==="steps"?"#fff":"var(--text-secondary, #b0bec5)",fontSize:11,fontWeight:600,cursor:"pointer"},children:"📋 步骤配置"}),o.jsxs("button",{onClick:()=>N("story"),style:{padding:"4px 10px",borderRadius:4,border:"none",background:T==="story"?"var(--color-accent, #3b82f6)":"transparent",color:T==="story"?"#fff":"var(--text-secondary, #b0bec5)",fontSize:11,fontWeight:600,cursor:"pointer"},children:["📖 运行故事线 (",S.tasks.length,"步)"]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[b&&o.jsx("button",{onClick:()=>k(null),style:{padding:"5px 10px",borderRadius:6,background:"transparent",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-muted, #94a3b8)",fontSize:12,cursor:"pointer"},children:"清除试跑结果"}),o.jsx("button",{onClick:B,disabled:g||w.length===0,style:{padding:"6px 14px",borderRadius:6,background:"color-mix(in srgb, var(--color-success, #10b981) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--color-success, #10b981) 45%, transparent)",color:"var(--color-success, #10b981)",fontSize:12,fontWeight:600,cursor:g||w.length===0?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:6,transition:"all 0.15s ease"},children:o.jsx("span",{children:g?"⏳ 模拟中...":"▶ 浏览器本地试跑 (零风险)"})})]})]}),T==="story"&&S?o.jsx("div",{style:{flex:1,overflowY:"auto"},children:o.jsx(xx,{instance:S,registry:r,onInspectStep:z=>{N("steps");const R=w.find(q=>q.taskReferenceName===z);R&&h(R.id)}})}):o.jsxs("div",{style:{flex:1,maxWidth:820,width:"100%",margin:"0 auto",padding:"24px 20px",display:"flex",flexDirection:"column",gap:16},children:[w.length===0&&o.jsxs("div",{style:{textAlign:"center",padding:"60px 20px",background:"var(--bg-secondary, #1e293b)",borderRadius:12,border:"1px dashed var(--border-secondary, rgba(255,255,255,0.2))",display:"flex",flexDirection:"column",alignItems:"center",gap:14},children:[o.jsx("span",{style:{fontSize:42},children:"⚡"}),o.jsx("div",{style:{fontWeight:600,fontSize:16,color:"var(--text-primary, #f8fafc)"},children:"尚未添加任何业务动作"}),o.jsx("p",{style:{fontSize:13,color:"var(--text-secondary, #b0bec5)",maxWidth:420,margin:0},children:"无需编写代码或配置复杂的 JSON,点击下方按钮选择第一个云主机业务动作,即可开始自动化编排。"}),o.jsxs("button",{disabled:n,onClick:()=>m(0),style:{marginTop:8,padding:"8px 18px",borderRadius:8,background:"var(--color-accent, #3b82f6)",color:"#fff",border:"none",fontWeight:600,fontSize:13,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[o.jsx("span",{children:"+"}),o.jsx("span",{children:"添加第一个业务动作"})]})]}),w.length>0&&!n&&o.jsx("div",{style:{display:"flex",justifyContent:"center"},children:o.jsxs("button",{onClick:()=>m(0),style:{padding:"4px 12px",borderRadius:20,background:"rgba(255,255,255,0.04)",border:"1px dashed var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-muted, #94a3b8)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4},children:[o.jsx("span",{children:"+"}),o.jsx("span",{children:"在最前插入步骤"})]})}),w.map((z,R)=>{const q=r.getAction(z.actionId),M=p===z.id,O=w.slice(0,R),W=b?.[z.taskReferenceName];return z.controlType==="decision"?o.jsxs(I.Fragment,{children:[o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px"},children:[o.jsxs("span",{style:{fontSize:12,fontWeight:700,color:"color-mix(in srgb, #8b5cf6 75%, var(--text-primary))"},children:["#",R+1," 控制流分支"]}),!n&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[o.jsx("button",{disabled:R===0,onClick:()=>E(R,R-1),title:"上移",style:{background:"none",border:"none",color:R===0?"rgba(255,255,255,0.2)":"var(--text-secondary)",cursor:R===0?"default":"pointer",fontSize:13,padding:"2px 4px"},children:"↑"}),o.jsx("button",{disabled:R===w.length-1,onClick:()=>E(R,R+1),title:"下移",style:{background:"none",border:"none",color:R===w.length-1?"rgba(255,255,255,0.2)":"var(--text-secondary)",cursor:R===w.length-1?"default":"pointer",fontSize:13,padding:"2px 4px"},children:"↓"}),o.jsx("button",{onClick:()=>P(R),title:"删除步骤",style:{background:"none",border:"none",color:"#ef4444",cursor:"pointer",fontSize:13,padding:"2px 4px"},children:"🗑️"})]})]}),o.jsx(Pc,{step:z,upstreamSteps:O,registry:r,disabled:n,onChange:U=>j(R,U),onOpenInsertModal:A})]}),!n&&o.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"-4px 0"},children:o.jsxs("button",{onClick:()=>m(R+1),style:{padding:"4px 12px",borderRadius:16,background:"var(--bg-tertiary)",border:"1px dashed var(--border-secondary)",color:"var(--text-muted)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,transition:"all 0.15s ease"},onMouseEnter:U=>{U.currentTarget.style.borderColor="var(--color-accent, #3b82f6)",U.currentTarget.style.color="var(--color-accent, #3b82f6)"},onMouseLeave:U=>{U.currentTarget.style.borderColor="var(--border-secondary)",U.currentTarget.style.color="var(--text-muted)"},children:[o.jsx("span",{children:"+"}),o.jsx("span",{children:"插入业务动作"})]})})]},z.id):z.controlType==="fork"?o.jsxs(I.Fragment,{children:[o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px"},children:[o.jsxs("span",{style:{fontSize:12,fontWeight:700,color:"var(--color-accent, #3b82f6)"},children:["#",R+1," 并发泳道组"]}),!n&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[o.jsx("button",{disabled:R===0,onClick:()=>E(R,R-1),title:"上移",style:{background:"none",border:"none",color:R===0?"rgba(255,255,255,0.2)":"var(--text-secondary)",cursor:R===0?"default":"pointer",fontSize:13,padding:"2px 4px"},children:"↑"}),o.jsx("button",{disabled:R===w.length-1,onClick:()=>E(R,R+1),title:"下移",style:{background:"none",border:"none",color:R===w.length-1?"rgba(255,255,255,0.2)":"var(--text-secondary)",cursor:R===w.length-1?"default":"pointer",fontSize:13,padding:"2px 4px"},children:"↓"}),o.jsx("button",{onClick:()=>P(R),title:"删除步骤",style:{background:"none",border:"none",color:"#ef4444",cursor:"pointer",fontSize:13,padding:"2px 4px"},children:"🗑️"})]})]}),o.jsx(Nc,{step:z,upstreamSteps:O,registry:r,disabled:n,onChange:U=>j(R,U),onOpenInsertModal:A})]}),!n&&o.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"-4px 0"},children:o.jsxs("button",{onClick:()=>m(R+1),style:{padding:"4px 12px",borderRadius:16,background:"var(--bg-tertiary)",border:"1px dashed var(--border-secondary)",color:"var(--text-muted)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,transition:"all 0.15s ease"},onMouseEnter:U=>{U.currentTarget.style.borderColor="var(--color-accent, #3b82f6)",U.currentTarget.style.color="var(--color-accent, #3b82f6)"},onMouseLeave:U=>{U.currentTarget.style.borderColor="var(--border-secondary)",U.currentTarget.style.color="var(--text-muted)"},children:[o.jsx("span",{children:"+"}),o.jsx("span",{children:"插入业务动作"})]})})]},z.id):z.controlType==="loop"?o.jsxs(I.Fragment,{children:[o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px"},children:[o.jsxs("span",{style:{fontSize:12,fontWeight:700,color:"var(--color-accent, #3b82f6)"},children:["#",R+1," 循环迭代体"]}),!n&&o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:4},children:[o.jsx("button",{disabled:R===0,onClick:()=>E(R,R-1),title:"上移",style:{background:"none",border:"none",color:R===0?"rgba(255,255,255,0.2)":"var(--text-secondary)",cursor:R===0?"default":"pointer",fontSize:13,padding:"2px 4px"},children:"↑"}),o.jsx("button",{disabled:R===w.length-1,onClick:()=>E(R,R+1),title:"下移",style:{background:"none",border:"none",color:R===w.length-1?"rgba(255,255,255,0.2)":"var(--text-secondary)",cursor:R===w.length-1?"default":"pointer",fontSize:13,padding:"2px 4px"},children:"↓"}),o.jsx("button",{onClick:()=>P(R),title:"删除步骤",style:{background:"none",border:"none",color:"#ef4444",cursor:"pointer",fontSize:13,padding:"2px 4px"},children:"🗑️"})]})]}),o.jsx(Ec,{step:z,upstreamSteps:O,registry:r,disabled:n,onChange:U=>j(R,U),onOpenInsertModal:A})]}),!n&&o.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"-4px 0"},children:o.jsxs("button",{onClick:()=>m(R+1),style:{padding:"4px 12px",borderRadius:16,background:"var(--bg-tertiary)",border:"1px dashed var(--border-secondary)",color:"var(--text-muted)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,transition:"all 0.15s ease"},onMouseEnter:U=>{U.currentTarget.style.borderColor="var(--color-accent, #3b82f6)",U.currentTarget.style.color="var(--color-accent, #3b82f6)"},onMouseLeave:U=>{U.currentTarget.style.borderColor="var(--border-secondary)",U.currentTarget.style.color="var(--text-muted)"},children:[o.jsx("span",{children:"+"}),o.jsx("span",{children:"插入业务动作"})]})})]},z.id):o.jsxs(I.Fragment,{children:[o.jsxs("div",{style:{background:"var(--bg-secondary, #1e293b)",borderRadius:10,border:M?"1px solid var(--color-accent, #3b82f6)":"1px solid var(--border-primary, rgba(255,255,255,0.12))",boxShadow:M?"0 8px 24px rgba(59, 130, 246, 0.15)":"0 4px 12px rgba(0,0,0,0.15)",overflow:"hidden",transition:"all 0.2s ease"},children:[o.jsxs("div",{onClick:()=>h(M?null:z.id),style:{padding:"12px 16px",display:"flex",alignItems:"center",justifyContent:"space-between",cursor:"pointer",userSelect:"none",background:M?"rgba(59, 130, 246, 0.05)":"transparent"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12,flex:1,overflow:"hidden"},children:[o.jsxs("div",{style:{width:28,height:28,borderRadius:6,background:"var(--bg-primary, #0f172a)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:12,fontWeight:700,color:"var(--color-accent, #3b82f6)",border:"1px solid var(--border-primary, rgba(255,255,255,0.1))"},children:["#",R+1]}),o.jsx("span",{style:{fontSize:20},children:q?.icon||"⚙️"}),o.jsxs("div",{style:{overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary, #f8fafc)"},children:z.name||q?.name||z.taskReferenceName}),q?.riskLevel==="sensitive"&&o.jsx("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:4,background:"rgba(239, 68, 68, 0.15)",color:"#f87171",fontWeight:600},children:"⚠️ 敏感"}),o.jsx(Rw,{step:z,action:q,disabled:n,catalog:a,getReferencedOutputs:()=>ix(z.taskReferenceName,w.filter(U=>U.id!==z.id)),onUpgrade:(U,$)=>j(R,{...z,libraryRef:{name:z.libraryRef.name,version:U},...$?{values:dx(z.values,$)}:{}})}),W&&o.jsx("span",{style:{fontSize:11,padding:"1px 6px",borderRadius:4,background:"rgba(16, 185, 129, 0.2)",color:"#34d399",fontWeight:600},children:"✓ 试跑成功"})]}),o.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #94a3b8)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:q?.description||z.description||z.taskReferenceName})]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},onClick:U=>U.stopPropagation(),children:[l&&o.jsx("button",{onClick:()=>l(z),title:"让 AI 介绍这个步骤的作用与配置建议",style:{background:"none",border:"none",color:"var(--text-secondary)",cursor:"pointer",fontSize:14,padding:"4px"},children:"🤖"}),!n&&o.jsxs(o.Fragment,{children:[o.jsx("button",{disabled:R===0,onClick:()=>E(R,R-1),title:"上移",style:{background:"none",border:"none",color:R===0?"rgba(255,255,255,0.2)":"var(--text-secondary, #b0bec5)",cursor:R===0?"default":"pointer",fontSize:14,padding:"4px"},children:"↑"}),o.jsx("button",{disabled:R===w.length-1,onClick:()=>E(R,R+1),title:"下移",style:{background:"none",border:"none",color:R===w.length-1?"rgba(255,255,255,0.2)":"var(--text-secondary, #b0bec5)",cursor:R===w.length-1?"default":"pointer",fontSize:14,padding:"4px"},children:"↓"}),o.jsx("button",{onClick:()=>P(R),title:"删除步骤",style:{background:"none",border:"none",color:"#ef4444",cursor:"pointer",fontSize:14,padding:"4px"},children:"🗑️"})]}),o.jsx("span",{style:{fontSize:12,color:"var(--text-muted, #94a3b8)",transform:M?"rotate(180deg)":"rotate(0deg)",transition:"transform 0.2s ease"},children:"▼"})]})]}),M&&o.jsx("div",{style:{padding:"14px 16px",borderTop:"1px solid var(--border-primary)",background:"var(--bg-primary)"},children:o.jsx(Cc,{step:z,upstreamSteps:O,registry:r,disabled:n,onChange:U=>j(R,U)})})]}),!n&&o.jsx("div",{style:{display:"flex",justifyContent:"center",margin:"-4px 0"},children:o.jsxs("button",{onClick:()=>m(R+1),style:{padding:"4px 12px",borderRadius:16,background:"var(--bg-tertiary)",border:"1px dashed var(--border-secondary)",color:"var(--text-muted)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,transition:"all 0.15s ease"},onMouseEnter:U=>{U.currentTarget.style.borderColor="var(--color-accent, #3b82f6)",U.currentTarget.style.color="var(--color-accent, #3b82f6)"},onMouseLeave:U=>{U.currentTarget.style.borderColor="var(--border-secondary)",U.currentTarget.style.color="var(--text-muted)"},children:[o.jsx("span",{children:"+"}),o.jsx("span",{children:"插入业务动作"})]})})]},z.id)})]}),f!==null&&o.jsx(Ow,{registry:r,stepNumber:f+1,onClose:()=>m(null),onSelect:z=>L(z,f),currentWorkflowLevel:i,libraryCatalog:a})]})};function Lw(e,t,r){if(!e||!t)return;const n=t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let s=e;for(let i=0;i<n.length-1;i++){const l=n[i];if(s[l]===void 0||s[l]===null){const c=n[i+1];s[l]=/^\d+$/.test(c)?[]:{}}s=s[l]}const a=n[n.length-1];s[a]=r}function Oc(e,t){const r=structuredClone(e.definition);for(const n of e.variables){const s=t[n.key]??n.defaultValue;if(s!==void 0)for(const a of n.bindings)Lw(r,a,s)}return r}const vx=({template:e,onApply:t,onClose:r,onSandboxRun:n})=>{const{theme:s,themeColor:a}=oe(ke(g=>({theme:g.theme,themeColor:g.themeColor}))),[i,l]=I.useState(1),[c,u]=I.useState(()=>{const g={};for(const x of e.variables)x.defaultValue!==void 0&&(g[x.key]=x.defaultValue);return g}),[d,p]=I.useState(!1),[h,f]=I.useState(null),m=(g,x)=>{u(b=>({...b,[g]:x}))},y=()=>{p(!0);try{const g=Oc(e,c),x=e.mockDataset.scenarios[0],b=Gt(g,{workflowInput:x?.workflowInput||{},taskMocks:x?.taskOutputs||{}});n?.(String(b.status)),b.status==="COMPLETED"?f(`全部 ${b.tasks.length} 个步骤在浏览器本地顺利模拟通过,各上游数据与通知已正确串联。`):f(`模拟运行结束,状态为: ${b.status}`)}catch(g){n?.("error"),f(`模拟试跑出错: ${g.message}`)}finally{p(!1)}},v=()=>{const g=Oc(e,c);t(g),r()};return typeof document>"u"?null:Ge.createPortal(o.jsx("div",{"data-mode":s,"data-brand":a,style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0, 0, 0, 0.72)",backdropFilter:"blur(5px)",zIndex:1300,display:"flex",alignItems:"center",justifyContent:"center",padding:20,fontFamily:"inherit"},onClick:r,children:o.jsxs("div",{onClick:g=>g.stopPropagation(),style:{width:680,maxHeight:"85vh",background:"var(--bg-secondary, #1e293b)",border:"1px solid var(--border-secondary, rgba(255, 255, 255, 0.2))",borderRadius:14,boxShadow:"0 24px 64px rgba(0, 0, 0, 0.6)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"14px 20px",borderBottom:"1px solid var(--border-primary, rgba(255, 255, 255, 0.1))",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bg-primary, #0f172a)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{fontSize:22},children:e.icon}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:15,color:"var(--text-primary, #f8fafc)"},children:e.title}),o.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #94a3b8)"},children:"3 步填空式模板快速启用向导"})]})]}),o.jsx("button",{onClick:r,style:{background:"none",border:"none",color:"var(--text-muted, #94a3b8)",cursor:"pointer",fontSize:16},children:"✕"})]}),o.jsx("div",{style:{padding:"10px 20px",background:"rgba(0,0,0,0.15)",borderBottom:"1px solid var(--border-primary, rgba(255, 255, 255, 0.08))",display:"flex",alignItems:"center",justifyContent:"center",gap:24},children:[{step:1,label:"1. 了解方案"},{step:2,label:"2. 参数填空"},{step:3,label:"3. 试跑验证与激活"}].map(g=>{const x=i===g.step,b=i>g.step;return o.jsxs("div",{onClick:()=>b&&l(g.step),style:{display:"flex",alignItems:"center",gap:6,cursor:b?"pointer":"default",opacity:x||b?1:.5},children:[o.jsx("div",{style:{width:22,height:22,borderRadius:11,background:b?"var(--color-success, #10b981)":x?"var(--color-accent, #3b82f6)":"rgba(255,255,255,0.1)",color:"#fff",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700},children:b?"✓":g.step}),o.jsx("span",{style:{fontSize:12,fontWeight:x?600:400,color:x?"var(--text-primary, #f8fafc)":"var(--text-secondary, #b0bec5)"},children:g.label})]},g.step)})}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px"},children:[i===1&&o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(3, 1fr)",gap:12},children:[o.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"rgba(16, 185, 129, 0.1)",border:"1px solid rgba(16, 185, 129, 0.25)"},children:[o.jsx("div",{style:{fontSize:11,color:"#34d399"},children:"⚡ 预期单次节省人工"}),o.jsxs("div",{style:{fontSize:20,fontWeight:700,color:"#10b981",marginTop:4},children:["约 ",e.roi.minutesSavedPerRun," 分钟"]})]}),o.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"rgba(59, 130, 246, 0.1)",border:"1px solid rgba(59, 130, 246, 0.25)"},children:[o.jsx("div",{style:{fontSize:11,color:"#60a5fa"},children:"🔄 典型每周频次"}),o.jsxs("div",{style:{fontSize:20,fontWeight:700,color:"#3b82f6",marginTop:4},children:["约 ",e.roi.typicalRunsPerWeek," 次 / 周"]})]}),o.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"rgba(245, 158, 11, 0.1)",border:"1px solid rgba(245, 158, 11, 0.25)"},children:[o.jsx("div",{style:{fontSize:11,color:"#fbbf24"},children:"🔥 累计被采用"}),o.jsxs("div",{style:{fontSize:20,fontWeight:700,color:"#f59e0b",marginTop:4},children:[e.roi.popularityCount??1200," 次"]})]})]}),o.jsxs("div",{style:{padding:"12px 16px",borderRadius:8,background:"var(--bg-primary, #0f172a)",border:"1px solid var(--border-primary, rgba(255,255,255,0.1))",lineHeight:1.6},children:[o.jsx("div",{style:{fontWeight:600,color:"var(--text-primary, #f8fafc)",fontSize:13,marginBottom:4},children:"💡 解决的痛点"}),o.jsx("div",{style:{fontSize:13,color:"var(--text-secondary, #b0bec5)"},children:e.valueProposition}),o.jsx("p",{style:{fontSize:12,color:"var(--text-muted, #94a3b8)",margin:"8px 0 0 0"},children:e.description})]}),o.jsxs("div",{children:[o.jsxs("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted, #94a3b8)",marginBottom:8},children:["包含的标准步骤流程 (",e.definition.tasks?.length??0," 个步骤):"]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.definition.tasks?.map((g,x)=>o.jsxs("div",{style:{padding:"8px 12px",borderRadius:6,background:"rgba(255,255,255,0.03)",border:"1px solid var(--border-primary, rgba(255,255,255,0.08))",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:12},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsxs("span",{style:{color:"var(--color-accent, #3b82f6)",fontWeight:600},children:["#",x+1]}),o.jsx("span",{style:{color:"var(--text-primary, #f8fafc)"},children:g.description||g.name})]}),o.jsx("span",{style:{fontSize:10,color:"var(--text-muted, #94a3b8)",fontFamily:"monospace"},children:g.taskReferenceName})]},g.taskReferenceName))})]})]}),i===2&&o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[o.jsxs("div",{style:{padding:"8px 12px",borderRadius:6,background:"rgba(59, 130, 246, 0.08)",border:"1px solid rgba(59, 130, 246, 0.25)",fontSize:12,color:"#93c5fd"},children:["✏️ ",o.jsx("strong",{children:"开箱即用填空"}),":无需修改复杂的流程连线与 JSON,仅需确认以下几个业务变量即可:"]}),e.variables.map(g=>{const x=c[g.key]??g.defaultValue;return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("label",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary, #f8fafc)",display:"flex",alignItems:"center",gap:4},children:[g.label,g.required&&o.jsx("span",{style:{color:"#ef4444"},children:"*"})]}),g.type==="select"?o.jsx("select",{value:x??"",onChange:b=>m(g.key,b.target.value),style:{padding:"8px 10px",borderRadius:6,background:"var(--bg-primary, #0f172a)",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-primary, #f8fafc)",fontSize:13,outline:"none"},children:g.options?.map(b=>o.jsx("option",{value:b.value,children:b.label},b.value))}):g.type==="boolean"?o.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13,color:"var(--text-secondary, #b0bec5)"},children:[o.jsx("input",{type:"checkbox",checked:!!x,onChange:b=>m(g.key,b.target.checked),style:{width:16,height:16}}),o.jsx("span",{children:"开启启用"})]}):o.jsx("input",{type:g.type==="number"?"number":"text",value:x??"",placeholder:g.placeholder,onChange:b=>m(g.key,g.type==="number"?Number(b.target.value):b.target.value),style:{padding:"8px 10px",borderRadius:6,background:"var(--bg-primary, #0f172a)",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-primary, #f8fafc)",fontSize:13,outline:"none"}}),g.help&&o.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #94a3b8)"},children:g.help})]},g.key)})]}),i===3&&o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[o.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"var(--bg-primary, #0f172a)",border:"1px solid var(--border-primary, rgba(255,255,255,0.1))",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,color:"var(--text-primary, #f8fafc)",fontSize:13},children:"零风险浏览器沙盒试跑"}),o.jsx("div",{style:{fontSize:11,color:"var(--text-muted, #94a3b8)",marginTop:2},children:"使用内置的保真云主机 Mock 数据,无需真实生产权限即可预览完整数据流转"})]}),o.jsx("button",{onClick:y,disabled:d,style:{padding:"6px 14px",borderRadius:6,background:"var(--color-accent, #3b82f6)",color:"#fff",border:"none",fontWeight:600,fontSize:12,cursor:d?"not-allowed":"pointer"},children:d?"⏳ 模拟试跑中...":"▶ 立即试跑验证"})]}),h&&o.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"rgba(16, 185, 129, 0.1)",border:"1px solid rgba(16, 185, 129, 0.3)",color:"#34d399",fontSize:12,lineHeight:1.5},children:["🎉 ",o.jsx("strong",{children:"试跑通过"}),": ",h]}),o.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"rgba(255,255,255,0.03)",border:"1px solid var(--border-primary, rgba(255,255,255,0.08))"},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted, #94a3b8)",marginBottom:8},children:"已配置的业务变量参数清单:"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.variables.map(g=>o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12,padding:"4px 0",borderBottom:"1px dashed rgba(255,255,255,0.06)"},children:[o.jsxs("span",{style:{color:"var(--text-secondary, #b0bec5)"},children:[g.label,":"]}),o.jsx("span",{style:{color:"var(--color-accent, #3b82f6)",fontWeight:600},children:String(c[g.key]??g.defaultValue)})]},g.key))})]})]})]}),o.jsxs("div",{style:{padding:"12px 20px",borderTop:"1px solid var(--border-primary, rgba(255, 255, 255, 0.1))",background:"var(--bg-primary, #0f172a)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[i>1?o.jsx("button",{onClick:()=>l(g=>g-1),style:{padding:"6px 14px",borderRadius:6,background:"transparent",border:"1px solid var(--border-secondary, rgba(255,255,255,0.2))",color:"var(--text-secondary, #b0bec5)",fontSize:12,cursor:"pointer"},children:"← 上一步"}):o.jsx("div",{}),o.jsx("div",{style:{display:"flex",gap:10},children:i<3?o.jsx("button",{onClick:()=>l(g=>g+1),style:{padding:"6px 16px",borderRadius:6,background:"var(--color-accent, #3b82f6)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:"下一步 →"}):o.jsxs("button",{onClick:v,style:{padding:"6px 18px",borderRadius:6,background:"var(--color-success, #10b981)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[o.jsx("span",{children:"⚡"}),o.jsx("span",{children:"注入参数并进入流程编辑器"})]})})]})]})}),document.body)},kx=({isOpen:e,onClose:t,onSelectTemplate:r,templateStore:n=gc,onSandboxRun:s})=>{const{theme:a,themeColor:i}=oe(ke(g=>({theme:g.theme,themeColor:g.themeColor}))),[l,c]=I.useState("all"),[u,d]=I.useState(""),[p,h]=I.useState(null),[f,m]=I.useState(null),y=I.useMemo(()=>n.search(u,l),[n,u,l]);if(!e||typeof document>"u")return null;const v=g=>{try{const x=g.mockDataset.scenarios[0],b=Gt(g.definition,{workflowInput:x?.workflowInput||{},taskMocks:x?.taskOutputs||{}});s?.(String(b.status)),m(`《${g.title}》在本地沙盒试跑通过!共执行 ${b.tasks.length} 个任务节点,状态: ${b.status}。点击「使用模板」即可完成填空并上屏编辑。`)}catch(x){s?.("error"),m(`试跑出错: ${x.message}`)}};return Ge.createPortal(o.jsxs("div",{"data-mode":a,"data-brand":i,style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"rgba(0, 0, 0, 0.72)",backdropFilter:"blur(5px)",zIndex:1250,display:"flex",alignItems:"center",justifyContent:"center",padding:24,fontFamily:"inherit"},onClick:t,children:[o.jsxs("div",{onClick:g=>g.stopPropagation(),style:{width:980,maxWidth:"92vw",height:"84vh",background:"var(--bg-secondary, #1e293b)",border:"1px solid var(--border-secondary, rgba(255, 255, 255, 0.2))",borderRadius:16,boxShadow:"0 28px 72px rgba(0, 0, 0, 0.65)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"16px 24px",borderBottom:"1px solid var(--border-primary, rgba(255, 255, 255, 0.1))",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bg-primary, #0f172a)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[o.jsx("span",{style:{fontSize:24},children:"📁"}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:700,fontSize:16,color:"var(--text-primary, #f8fafc)"},children:"场景化工作流模板中心"}),o.jsx("div",{style:{fontSize:12,color:"var(--text-muted, #94a3b8)"},children:"源于真实云平台高价值运维实战萃取 · 拒绝空白画布 · 开箱即用"})]})]}),o.jsx("button",{onClick:t,style:{background:"none",border:"none",color:"var(--text-muted, #94a3b8)",cursor:"pointer",fontSize:18,padding:"4px"},children:"✕"})]}),o.jsxs("div",{style:{padding:"10px 24px",borderBottom:"1px solid var(--border-primary, rgba(255, 255, 255, 0.08))",display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,background:"rgba(0, 0, 0, 0.15)"},children:[o.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[{id:"all",label:"全部场景 (8)"},{id:"compute",label:"🖥️ 交付与计算"},{id:"security",label:"💾 安全与容灾"},{id:"ops",label:"⚡ 运维与自愈"},{id:"cost",label:"🌙 节能与降本"}].map(g=>o.jsx("button",{onClick:()=>c(g.id),style:{padding:"5px 12px",borderRadius:6,background:l===g.id?"var(--color-accent, #3b82f6)":"transparent",color:l===g.id?"#fff":"var(--text-secondary, #b0bec5)",border:"none",fontSize:12,cursor:"pointer",fontWeight:l===g.id?600:400,transition:"all 0.15s ease"},children:g.label},g.id))}),o.jsx("input",{type:"text",placeholder:"搜索模板名称、痛点或场景...",value:u,onChange:g=>d(g.target.value),style:{width:220,padding:"6px 12px",borderRadius:6,background:"var(--bg-primary, #0f172a)",border:"1px solid var(--border-secondary, rgba(255, 255, 255, 0.2))",color:"var(--text-primary, #f8fafc)",fontSize:12,outline:"none"}})]}),f&&o.jsxs("div",{style:{margin:"12px 24px 0 24px",padding:"10px 14px",borderRadius:8,background:"rgba(16, 185, 129, 0.12)",border:"1px solid rgba(16, 185, 129, 0.35)",color:"#34d399",fontSize:12,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{children:["✨ ",f]}),o.jsx("button",{onClick:()=>m(null),style:{background:"none",border:"none",color:"#34d399",cursor:"pointer",fontSize:12},children:"关闭"})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16},children:y.map(g=>o.jsxs("div",{style:{borderRadius:12,background:"var(--bg-primary, #0f172a)",border:"1px solid var(--border-primary, rgba(255, 255, 255, 0.12))",padding:"16px 18px",display:"flex",flexDirection:"column",justifyContent:"space-between",gap:12,transition:"all 0.2s ease"},onMouseEnter:x=>{x.currentTarget.style.borderColor="var(--color-accent, #3b82f6)",x.currentTarget.style.transform="translateY(-2px)",x.currentTarget.style.boxShadow="0 8px 24px rgba(0, 0, 0, 0.3)"},onMouseLeave:x=>{x.currentTarget.style.borderColor="rgba(255, 255, 255, 0.12)",x.currentTarget.style.transform="translateY(0)",x.currentTarget.style.boxShadow="none"},children:[o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{fontSize:26},children:g.icon}),o.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary, #f8fafc)"},children:g.title})]}),o.jsx("span",{style:{fontSize:10,padding:"2px 6px",borderRadius:4,background:"rgba(255, 255, 255, 0.08)",color:"var(--text-muted, #94a3b8)",fontWeight:500},children:g.difficulty==="starter"?"入门":g.difficulty==="intermediate"?"进阶":"专业"})]}),o.jsx("div",{style:{fontSize:12,color:"var(--text-secondary, #b0bec5)",lineHeight:1.5},children:g.valueProposition})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[o.jsxs("span",{style:{fontSize:11,padding:"2px 7px",borderRadius:4,background:"rgba(16, 185, 129, 0.15)",color:"#34d399",fontWeight:600},children:["⚡ 单次约省 ",g.roi.minutesSavedPerRun," 分钟"]}),o.jsxs("span",{style:{fontSize:11,padding:"2px 7px",borderRadius:4,background:"rgba(59, 130, 246, 0.15)",color:"#60a5fa"},children:["🔥 已使用 ",g.roi.popularityCount??1e3," 次"]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[o.jsxs("button",{onClick:()=>v(g),style:{flex:1,padding:"6px 10px",borderRadius:6,background:"rgba(255, 255, 255, 0.05)",border:"1px solid var(--border-secondary, rgba(255, 255, 255, 0.15))",color:"var(--text-secondary, #b0bec5)",fontSize:12,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4},children:[o.jsx("span",{children:"▶"}),o.jsx("span",{children:"试跑演示"})]}),o.jsxs("button",{onClick:()=>h(g),style:{flex:1.2,padding:"6px 12px",borderRadius:6,background:"var(--color-accent, #3b82f6)",color:"#fff",border:"none",fontSize:12,fontWeight:600,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4},children:[o.jsx("span",{children:"⚡"}),o.jsx("span",{children:"使用此模板"})]})]})]})]},g.id))})]}),p&&o.jsx(vx,{template:p,onSandboxRun:s,onClose:()=>h(null),onApply:g=>{h(null),r(g),t()}})]}),document.body)},Mw="YAML 请先转为 JSON 后再导入",$w=["get","post","put","delete","patch","head","options"];function he(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Ac(e){return String(e??"").replace(/^/,"").trim()}function on(e,t=48){return(e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^A-Za-z0-9]+/g,"_").replace(/^_+|_+$/g,"").toLowerCase()||"api").slice(0,t).replace(/_+$/g,"")||"api"}function zw(e){const t=e.split(/[^A-Za-z0-9]+/).filter(Boolean);if(t.length===0)return"value";const r=t.map((n,s)=>{const a=n===n.toUpperCase()?n.toLowerCase():n;return s===0?a.charAt(0).toLowerCase()+a.slice(1):a.charAt(0).toUpperCase()+a.slice(1)}).join("");return/^[0-9]/.test(r)?`v${r}`:r}function an(e,t){let r=e,n=2;for(;t.has(r);)r=`${e}_${n}`,n+=1;return t.add(r),r}function ar(e,t=0){if(e==null)return{type:"string"};if(Array.isArray(e))return t>=4||e.length===0?{type:"array"}:{type:"array",items:ar(e[0],t+1)};switch(typeof e){case"number":return{type:Number.isInteger(e)?"integer":"number"};case"boolean":return{type:"boolean"};case"object":{if(t>=4)return{type:"object"};const r={};for(const[n,s]of Object.entries(e))r[n]=ar(s,t+1);return{type:"object",properties:r}}default:return{type:"string"}}}function St(e){if(!e)return"string";const t=Array.isArray(e.type)?e.type.find(r=>r!=="null"):e.type;return t||(e.properties?"object":e.items?"array":"string")}function Sx(e){let t=e.trim();const r=t.indexOf("#");r>=0&&(t=t.slice(0,r));let n="";const s=t.indexOf("?");s>=0&&(n=t.slice(s+1),t=t.slice(0,s));let a="";const i=/^([a-z][a-z0-9+.-]*:\/\/[^/]*)/i.exec(t)||/^(\$\{[^}]*\})/.exec(t);return i&&(a=i[1],t=t.slice(i[1].length)),{baseUrl:a,path:t||"/",query:n}}function Dc(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return e}}const qw=/^(authorization|cookie|set-cookie|proxy-authorization|x-api-key)$/i,wx=/token|secret|api[-_]?key|passw(or)?d/i;function _x(e){return qw.test(e.trim())||wx.test(e)}function Lc(e){return wx.test(e)}function Ue(e){return"${workflow.input."+zw(e)+"}"}function Ww(e){return`请求头 ${e} 含敏感信息,已替换为 ${Ue(e)};请在流程入参中提供(值需包含完整头内容,如 Bearer xxx),或改用凭据管理,不会写入流程定义`}function Mc(e){const t={},r=[];for(const[n,s]of Object.entries(e))_x(n)&&!String(s).includes("${")?(t[n]=Ue(n),r.push(Ww(n))):t[n]=s;return{headers:t,warnings:r}}function $c(e){const{headers:t,warnings:r}=Mc(e.headers);return{...e,headers:t,warnings:Array.from(new Set([...e.warnings,...r]))}}function Fw(e){return`${e.method} ${e.path}`}function zc(e,t=[]){const r=[...t],n=new Set(r);for(const s of e)for(const a of s.warnings){const i=`${Fw(s)}:${a}`;n.has(i)||(n.add(i),r.push(i))}return r}function jx(e,t){const r=ar(e);if(he(e)&&r.properties)for(const[n,s]of Object.entries(e))Lc(n)&&typeof s=="string"?(r.properties[n].default=Ue(n),t.push(`请求体字段 ${n} 疑似敏感信息,默认值已替换为 ${Ue(n)}`)):r.properties[n].default=s;return r}function qc(e,t){const r=[];if(!e)return r;for(const n of e.split("&")){if(!n)continue;const s=n.indexOf("="),a=Dc(s>=0?n.slice(0,s):n),i=s>=0?Dc(n.slice(s+1)):"";if(!a)continue;let l=i;Lc(a)&&!i.includes("${")&&(l=Ue(a),t.push(`查询参数 ${a} 疑似敏感信息,默认值已替换为 ${l},请在流程入参中提供`)),r.push({name:a,in:"query",required:!1,schema:{type:"string"},defaultValue:l||void 0})}return r}function Wc(e){const t={};for(const[r,n]of Object.entries(e))/^(content-type|accept)$/i.test(r)||(t[r]=n);return t}function Fc(e,t){const r=Object.keys(e).find(n=>n.toLowerCase()===t.toLowerCase());return r===void 0?void 0:e[r]}const Bw=6;function Tx(e,t){if(!t.startsWith("#/"))return;let r=e;for(const n of t.slice(2).split("/")){const s=decodeURIComponent(n).replace(/~1/g,"/").replace(/~0/g,"~");if(r===null||typeof r!="object")return;r=r[s]}return r}function sr(e,t){let r=e;for(let n=0;n<10&&(he(r)&&typeof r.$ref=="string");n++)r=Tx(t,r.$ref);return he(r)&&typeof r.$ref!="string"?r:void 0}const Ix=["type","title","description","enum","default","format","example","examples","maxLength","minLength","minimum","maximum","pattern","nullable"];function sn(e,t,r=[],n=Bw){let s=!1;const a=(i,l,c)=>{if(!he(i))return{};if(typeof i.$ref=="string"){const f=i.$ref,m=f.split("/").pop()||f;if(c.includes(f))return s||(s=!0,r.push(`存在循环引用(${m}),循环处已截断`)),{type:"object",description:`循环引用:${m}`};const y=Tx(t,f);return y===void 0?(r.push(`无法解析引用 ${f},已忽略`),{}):a(y,l,[...c,f])}if(l>n)return{type:St(i),...typeof i.description=="string"?{description:i.description}:{}};const u={};for(const f of Ix)i[f]!==void 0&&(u[f]=i[f]);const d=[];Array.isArray(i.allOf)&&d.push(...i.allOf);for(const f of["oneOf","anyOf"]){const m=i[f];if(Array.isArray(m)&&m.length>0){const y=m.find(v=>!(he(v)&&v.type==="null"))??m[0];d.push(y)}}let p,h=Array.isArray(i.required)?[...i.required]:[];for(const f of d){const m=a(f,l,c);for(const y of Ix)u[y]===void 0&&m[y]!==void 0&&(u[y]=m[y]);m.properties&&(p={...p||{},...m.properties}),Array.isArray(m.required)&&(h=h.concat(m.required)),m.items&&!u.items&&(u.items=m.items)}if(he(i.properties)){p={...p||{}};for(const[f,m]of Object.entries(i.properties))p[f]=a(m,l+1,c)}return p&&(u.properties=p,u.type||(u.type="object")),h.length>0&&(u.required=Array.from(new Set(h))),i.items!==void 0&&(u.items=a(i.items,l+1,c)),u};return a(e,0,[])}const Hw=/^(content-type|accept)$/i;function Bc(e){return/json/i.test(e)}function Uw(e,t){if(!Array.isArray(e)||!he(e[0])||typeof e[0].url!="string")return t.push("文档未声明 servers,URL 仅含路径,请在步骤里补充完整服务地址"),"";const r=e[0],n=he(r.variables)?r.variables:{},a=r.url.replace(/\{([^}]+)\}/g,(i,l)=>{const c=n[l];if(he(c)){if(c.default!==void 0)return String(c.default);if(Array.isArray(c.enum)&&c.enum.length>0)return String(c.enum[0])}return t.push(`服务地址变量 {${l}} 没有默认值,请手动替换`),i}).replace(/\/+$/,"");return a&&!/^[a-z][a-z0-9+.-]*:\/\//i.test(a)&&!a.startsWith("${")&&t.push(`服务地址 ${a} 是相对路径,请在步骤里补充完整地址`),a}function Jw(e,t){const r=typeof e.basePath=="string"?e.basePath.replace(/\/+$/,""):"";return typeof e.host!="string"||!e.host?(t.push("文档未声明 host,URL 仅含路径,请在步骤里补充完整服务地址"),r):`${Array.isArray(e.schemes)&&typeof e.schemes[0]=="string"?e.schemes[0]:"https"}://${e.host}${r}`}function Vw(e){const t={};for(const r of["type","format","enum","default","items","minimum","maximum","maxLength","pattern"])e[r]!==void 0&&(t[r]=e[r]);return t.type||(t.type="string"),t}function Cx(e){if(!he(e))return;const t=Object.keys(e),r=t.find(n=>n.toLowerCase()==="application/json")??t.find(Bc);return r&&he(e[r])?{type:r,media:e[r]}:void 0}function Nx(e,t,r){let n=sn(e.schema,t,r);if(Object.keys(n).length===0){const s=e.example??(he(e.examples)?Object.values(e.examples).map(a=>he(a)?a.value:void 0).find(a=>a!==void 0):void 0);s!==void 0&&(n=ar(s))}return n}function Kw(e,t,r,n){const s=he(e.responses)?e.responses:{},a=Object.keys(s),l=a.filter(d=>/^2\d\d$/.test(d)).sort()[0]??a.find(d=>/^2xx$/i.test(d))??(a.includes("default")?"default":void 0);if(!l)return;const c=sr(s[l],t);if(!c)return;let u;if(r===3){const d=Cx(c.content);d&&(u=Nx(d.media,t,n))}else c.schema!==void 0&&(u=sn(c.schema,t,n));return u&&Object.keys(u).length>0?u:void 0}function Gw(e,t,r,n){const s={headers:{},queryParams:[]};if(!Array.isArray(e)||!he(e[0])||!he(t))return s;for(const a of Object.keys(e[0])){const i=sr(t[a],r);if(!i)continue;const l=String(i.type||"");if(l==="apiKey"){const c=typeof i.name=="string"?i.name:"X-Api-Key";i.in==="header"?s.headers[c]="":i.in==="query"?(s.queryParams.push({name:c,in:"query",required:!0,schema:{type:"string"},description:`认证参数(${a})`,defaultValue:Ue(c)}),n.push(`查询参数 ${c} 是认证密钥,已默认取自 ${Ue(c)},请在流程入参中提供`)):n.push(`认证方式 ${a}(${String(i.in)})暂不支持,已忽略`)}else(l==="http"||l==="basic"||l==="oauth2"||l==="openIdConnect")&&(s.headers.Authorization="")}return s}function Ex(e,t){const r=t===3?"openapi3":"swagger2";if(!he(e.paths))return{ok:!1,format:r,error:"缺少 paths 字段,找不到接口定义"};const n=[],s=t===2?Jw(e,n):"",a=t===3?e.components?.securitySchemes:e.securityDefinitions,i=new Set,l=[],c=new Map;for(const[u,d]of Object.entries(e.paths)){const p=sr(d,e);if(p)for(const h of $w){const f=p[h];if(!he(f))continue;const m=[];let y;if(t===3){const T=f.servers??p.servers??e.servers;let N=c.get(T);if(!N){const w=[];N={url:Uw(T,w),warnings:w},c.set(T,N),n.push(...w)}y=N.url}else y=s;const v=[],g={},x=new Map;for(const T of[...Array.isArray(p.parameters)?p.parameters:[],...Array.isArray(f.parameters)?f.parameters:[]]){const N=sr(T,e);N&&typeof N.name=="string"&&typeof N.in=="string"&&x.set(`${N.in}:${N.name}`,N)}let b;for(const T of x.values()){const N=T.in;if(N==="path"||N==="query"||N==="header"){if(N==="header"&&Hw.test(T.name))continue;if(N==="header"&&_x(T.name)){g[T.name]="";continue}const w=sn(t===3?T.schema??{type:"string"}:Vw(T),e,m);w.default===void 0&&T.example!==void 0&&t===3&&(w.default=T.example),v.push({name:T.name,in:N,required:N==="path"?!0:T.required===!0,schema:Object.keys(w).length>0?w:{type:"string"},description:typeof T.description=="string"?T.description:void 0})}else if(N==="body"&&t===2){const w=f.consumes??e.consumes,_=Array.isArray(w)&&w.length>0?String(w.find(j=>Bc(String(j)))??w[0]):"application/json";Bc(_)?b={contentType:_,schema:sn(T.schema,e,m)}:m.push(`请求体类型 ${_} 暂不支持,已忽略(仅支持 JSON)`)}else N==="formData"?m.push("表单(formData)参数暂不支持,已忽略"):N==="cookie"&&m.push(`Cookie 参数 ${T.name} 暂不支持,已忽略`)}if(t===3&&f.requestBody!==void 0){const T=sr(f.requestBody,e),N=T?Cx(T.content):void 0;N?b={contentType:N.type,schema:Nx(N.media,e,m)}:T&&he(T.content)&&Object.keys(T.content).length>0&&m.push(`请求体类型 ${Object.keys(T.content)[0]} 暂不支持,已忽略(仅支持 JSON)`)}const k=Gw(f.security??e.security,a,e,m);for(const T of Object.keys(k.headers))T in g||(g[T]="");for(const T of k.queryParams)v.some(N=>N.in==="query"&&N.name===T.name)||v.push(T);const S=typeof f.operationId=="string"&&f.operationId?on(f.operationId):on(u.replace(/[{}]/g,"")),C=an(`${h}_${S}`,i);l.push($c({id:C,method:h.toUpperCase(),baseUrl:y,path:u,summary:typeof f.summary=="string"&&f.summary.trim()?f.summary.trim():void 0,description:typeof f.description=="string"?f.description:void 0,operationId:typeof f.operationId=="string"?f.operationId:void 0,tags:Array.isArray(f.tags)?f.tags.filter(T=>typeof T=="string"):[],params:v,headers:g,body:b,responseSchema:Kw(f,e,t,m),warnings:m}))}}return l.length===0?{ok:!1,format:r,error:"paths 中没有找到任何接口(get / post / put / delete / patch …)"}:{ok:!0,format:r,operations:l,warnings:zc(l,n)}}function Rx(e){if(!he(e))return{ok:!1,format:"openapi3",error:"OpenAPI 文档必须是 JSON 对象"};try{return Ex(e,3)}catch(t){return{ok:!1,format:"openapi3",error:`OpenAPI 解析失败:${t instanceof Error?t.message:String(t)}`}}}function Px(e){if(!he(e))return{ok:!1,format:"swagger2",error:"Swagger 文档必须是 JSON 对象"};try{return Ex(e,2)}catch(t){return{ok:!1,format:"swagger2",error:`Swagger 解析失败:${t instanceof Error?t.message:String(t)}`}}}function ir(e,t){return e.replace(/\{\{\s*([^{}\s]+)\s*\}\}/g,(r,n)=>{const s=n.replace(/[^\w]/g,"_");return t?.add(s),"${workflow.input."+s+"}"})}function Yw(e){if(typeof e.raw=="string"&&e.raw)return e.raw;const t=Array.isArray(e.host)?e.host.join("."):typeof e.host=="string"?e.host:"",r=Array.isArray(e.path)?e.path.join("/"):typeof e.path=="string"?e.path:"",n=typeof e.protocol=="string"&&e.protocol?`${e.protocol}://`:"",s=e.port?`:${e.port}`:"",a=Array.isArray(e.query)?e.query.filter(i=>he(i)&&!i.disabled&&i.key).map(i=>`${i.key}=${i.value??""}`).join("&"):"";return`${n}${t}${s}/${r}${a?`?${a}`:""}`}function Xw(e){if(typeof e=="string")return e;if(he(e)&&typeof e.content=="string")return e.content}function Zw(e,t,r,n){if(!(!e||typeof e.type!="string"||e.type==="noauth"))if(e.type==="apikey"){const s=Array.isArray(e.apikey)?e.apikey:[],a=String(s.find(l=>l?.key==="key")?.value||"X-Api-Key");String(s.find(l=>l?.key==="in")?.value||"header")==="query"?(r.some(l=>l.in==="query"&&l.name===a)||r.push({name:a,in:"query",required:!0,schema:{type:"string"},defaultValue:Ue(a)}),n.push(`查询参数 ${a} 是认证密钥,已默认取自 ${Ue(a)},请在流程入参中提供`)):t[a]=""}else["bearer","basic","oauth2","digest","hawk","awsv4","ntlm","oauth1"].includes(e.type)&&(t.Authorization="")}function Ox(e,t,r,n){if(Array.isArray(e))for(const s of e){if(!he(s))continue;const a=he(s.auth)?s.auth:n;if(Array.isArray(s.item)){const c=typeof s.name=="string"&&s.name?[...r,s.name]:r;Ox(s.item,t,c,a);continue}const i=s.request;if(!he(i)&&typeof i!="string")continue;const l=Qw(s,he(i)?i:{method:"GET",url:i},t,r,a);l&&t.ops.push(l)}}function Qw(e,t,r,n,s){const a=[],i=typeof t.url=="string"?t.url:he(t.url)?Yw(t.url):"";if(!i)return;const{baseUrl:l,path:c,query:u}=Sx(ir(i,r.vars)),d=c.replace(/\/:([A-Za-z_]\w*)/g,"/{$1}"),p=[],h={};if(he(t.url)&&Array.isArray(t.url.variable))for(const k of t.url.variable)he(k)&&typeof k.key=="string"&&typeof k.value=="string"&&k.value&&(h[k.key]=ir(k.value,r.vars));for(const k of d.matchAll(/\{([^}/]+)\}/g))p.push({name:k[1],in:"path",required:!0,schema:{type:"string"},defaultValue:h[k[1]]});p.push(...qc(u,a));const f={};if(Array.isArray(t.header))for(const k of t.header)he(k)&&!k.disabled&&typeof k.key=="string"&&k.key&&(f[k.key]=ir(String(k.value??""),r.vars));Zw(he(t.auth)?t.auth:s,f,p,a);let m;const y=t.body;if(he(y)&&typeof y.mode=="string")if(y.mode==="raw"){const k=ir(String(y.raw??""),r.vars),S=he(y.options)&&he(y.options.raw)?String(y.options.raw.language||""):"",C=Object.keys(f).find(N=>N.toLowerCase()==="content-type"),T=S==="json"||C&&/json/i.test(f[C])||/^[[{]/.test(k.trim());if(k.trim()){let N,w=!1;if(T)try{N=JSON.parse(k),w=!0}catch{w=!1}w?m={contentType:"application/json",schema:jx(N,a)}:(m={contentType:C?f[C]:"text/plain",schema:{type:"string",default:k}},T&&a.push("请求体不是合法 JSON(可能含未加引号的变量),已作为文本整体导入"))}}else y.mode!=="none"&&a.push(`请求体类型 ${y.mode} 暂不支持,已忽略(仅支持 JSON / 文本)`);let v;if(Array.isArray(e.response))for(const k of e.response){if(!he(k)||typeof k.body!="string")continue;const S=Number(k.code);if(S>=200&&S<300)try{const C=JSON.parse(ir(k.body,r.vars));if(C!==null&&typeof C=="object"){v=ar(C);break}}catch{}}const g=typeof e.name=="string"?e.name.trim():"",x=String(t.method||"GET").toUpperCase(),b=an(`${x.toLowerCase()}_${on(d.replace(/[{}]/g,""))}`,r.used);return $c({id:b,method:x,baseUrl:l,path:d,summary:g||void 0,description:Xw(t.description),tags:[...n],params:p,headers:Wc(f),body:m,responseSchema:v,warnings:a})}function Ax(e){if(!he(e)||!Array.isArray(e.item))return{ok:!1,format:"postman21",error:"Postman Collection 缺少 item 列表"};try{const t={used:new Set,vars:new Set,ops:[]},r=[];return Ox(e.item,t,[],he(e.auth)?e.auth:void 0),t.ops.length===0?{ok:!1,format:"postman21",error:"Collection 中没有找到任何请求"}:(t.vars.size>0&&r.push(`用到了 Postman 变量:${Array.from(t.vars).join("、")},已转为 \${workflow.input.xxx},请在流程入参中提供`),{ok:!0,format:"postman21",operations:t.ops,warnings:zc(t.ops,r)})}catch(t){return{ok:!1,format:"postman21",error:`Postman 解析失败:${t instanceof Error?t.message:String(t)}`}}}function e_(e){const t=e.replace(/\\\r?\n/g," "),r=[];let n="",s=!1,a=0;const i=()=>{s&&r.push(n),n="",s=!1};for(;a<t.length;){const l=t[a];if(/\s/.test(l))i(),a++;else if(l==="'"){s=!0;const c=t.indexOf("'",a+1),u=c<0?t.length:c;n+=t.slice(a+1,u),a=u+1}else if(l==="$"&&t[a+1]==="'"){for(s=!0,a+=2;a<t.length&&t[a]!=="'";)if(t[a]==="\\"&&a+1<t.length){const c=t[a+1],u={n:`
|
|
136
|
-
|
|
273
|
+
Result: OK`,status:"SUCCESS"})},{id:"ecs.get_monitor_metrics",name:"获取运行监控指标",category:"monitor",icon:"chart",description:"采集云主机的实时 CPU 利用率、内存消耗与磁盘使用率",connector:"cloud_host",riskLevel:"safe",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",required:!0,acceptsPills:!0},{key:"periodSeconds",label:"聚合统计周期",type:"select",defaultValue:60,options:[{label:"最近 1 分钟平均",value:60},{label:"最近 5 分钟平均",value:300},{label:"最近 15 分钟平均",value:900}]}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"cpuUsagePercent",label:"CPU使用率(%)",type:"number",example:45.2},{key:"memoryUsagePercent",label:"内存使用率(%)",type:"number",example:62.8},{key:"diskUsagePercent",label:"磁盘使用率(%)",type:"number",example:38.5},{key:"isOverloaded",label:"是否高负载告警",type:"boolean",example:!1}],compile:(e,t)=>({name:"ecs_get_monitor_metrics",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`采集监控指标: ${e.instanceId||t.taskReferenceName}`,inputParameters:{_actionId:"ecs.get_monitor_metrics",actionName:"获取运行监控指标",instanceId:e.instanceId,periodSeconds:Jt(e.periodSeconds,60),http_request:{uri:`https://ecs.internal.cloud/api/v2/instances/${e.instanceId||""}/metrics?period=${Jt(e.periodSeconds,60)}`,method:"GET"}}}),decompile:e=>e.inputParameters?._actionId==="ecs.get_monitor_metrics"?{instanceId:e.inputParameters.instanceId??"",periodSeconds:e.inputParameters.periodSeconds??60}:null,mockOutput:e=>{const t=32.4+Math.round(Math.random()*40*10)/10;return{instanceId:e.instanceId||"i-bp18a9z3j42m09a",cpuUsagePercent:t,memoryUsagePercent:58.6,diskUsagePercent:42.1,isOverloaded:t>80,collectedAt:new Date().toISOString()}}},{id:"ecs.release_instance",name:"释放下线云主机",category:"compute",icon:"trash",description:"彻底销毁并下线按量付费云主机,不可恢复",connector:"cloud_host",riskLevel:"sensitive",fields:[{key:"instanceId",label:"云主机实例 ID",type:"text",required:!0,acceptsPills:!0},{key:"forceRelease",label:"是否强制释放 (即刻关机并清理)",type:"boolean",defaultValue:!1}],outputs:[{key:"instanceId",label:"实例ID",type:"string",example:"i-bp18a9z3j42m09a"},{key:"status",label:"最终状态",type:"string",example:"RELEASED"},{key:"releasedAt",label:"释放时间",type:"string",example:"2026-10-20T14:30:00Z"}],compile:(e,t)=>({name:"ecs_release_instance",taskReferenceName:t.taskReferenceName,type:"HTTP",description:`释放云主机: ${e.instanceId||""}`,inputParameters:{_actionId:"ecs.release_instance",actionName:"释放下线云主机",instanceId:e.instanceId,forceRelease:!!e.forceRelease,http_request:{uri:`https://ecs.internal.cloud/api/v2/instances/${e.instanceId||""}${e.forceRelease?"?force=true":""}`,method:"DELETE"}}}),decompile:e=>e.inputParameters?._actionId==="ecs.release_instance"?{instanceId:e.inputParameters.instanceId??"",forceRelease:!!e.inputParameters.forceRelease}:null,mockOutput:e=>({instanceId:e.instanceId||"i-bp18a9z3j42m09a",status:"RELEASED",releasedAt:new Date().toISOString()})}],Uk=[{id:"notify.send_message",name:"发送运维通知",category:"notify",icon:"megaphone",description:"向指定运维协同群(钉钉/企微/飞书)或负责人发送通知卡片",riskLevel:"safe",fields:[{key:"channel",label:"通知渠道",type:"select",required:!0,defaultValue:"webhook_dingtalk",options:[{label:"钉钉运维机器人 (DingTalk)",value:"webhook_dingtalk"},{label:"企业微信机器人 (WeCom)",value:"webhook_wecom"},{label:"飞书群机器人 (Lark/Feishu)",value:"webhook_feishu"},{label:"运维邮件 (Email)",value:"email"}]},{key:"title",label:"通知标题",type:"text",placeholder:"例如: 【生产告警】云主机 CPU 负载过高",defaultValue:"【云平台通知】运维自动化工作流执行汇报",required:!0,acceptsPills:!0},{key:"content",label:"消息正文内容",type:"textarea",placeholder:"支持输入文字,或键入 @ 插入上游实例 ID / IP 等数据胶囊",defaultValue:"主机实例已成功处理完成,请相关人员知悉。",required:!0,acceptsPills:!0}],outputs:[{key:"messageId",label:"消息追踪ID",type:"string",example:"msg_994200"},{key:"sentStatus",label:"发送状态",type:"string",example:"DELIVERED"},{key:"sentAt",label:"送达时间",type:"string",example:"2026-10-20T14:35:00Z"}],compile:(e,t)=>({name:"send_operation_notification",taskReferenceName:t.taskReferenceName,type:"EVENT",sink:"conductor",description:`发送通知: ${e.title||t.taskReferenceName}`,inputParameters:{_actionId:"notify.send_message",actionName:"发送运维通知",channel:e.channel??"webhook_dingtalk",title:e.title,content:e.content}}),decompile:e=>e.inputParameters?._actionId==="notify.send_message"?{channel:e.inputParameters.channel??"webhook_dingtalk",title:e.inputParameters.title??"",content:e.inputParameters.content??""}:null,mockOutput:e=>({messageId:`msg-${Date.now().toString(36)}`,channel:e.channel,sentStatus:"DELIVERED",sentAt:new Date().toISOString()})},{id:"human.approval",name:"人工确认 / 审批",category:"human",icon:"user",description:"在执行高危变动或财务扣费前,暂停流程并等待指定责任人点击确认",riskLevel:"safe",fields:[{key:"assigneeRole",label:"审批责任角色",type:"select",required:!0,defaultValue:"devops_lead",options:[{label:"运维负责人 (DevOps Lead)",value:"devops_lead"},{label:"架构师 (Architect)",value:"architect"},{label:"安全管理员 (SecOps)",value:"secops"},{label:"项目经理 (PM)",value:"pm"}]},{key:"promptMessage",label:"审批确认说明",type:"textarea",placeholder:"请输入需要审批人重点核对的信息(支持 @ 插入参数)",defaultValue:"请核实即将执行的高危变更操作,确认无误后点击批准。",required:!0,acceptsPills:!0},{key:"timeoutMinutes",label:"无人审批时",type:"select",defaultValue:60,help:'超时后流程以"已超时"结束,不会继续执行后续步骤',options:[{label:"30 分钟后超时结束流程",value:30},{label:"60 分钟后超时结束流程",value:60},{label:"24 小时后超时结束流程",value:1440}]}],outputs:[{key:"approved",label:"审批结果",type:"boolean",example:!0},{key:"reviewer",label:"审批人",type:"string",example:"zhangsan@cloud.com"},{key:"comment",label:"审批意见",type:"string",example:"已核实变更方案,同意执行"},{key:"decisionTime",label:"审批时间",type:"string",example:"2026-10-20T14:40:00Z"}],compile:(e,t)=>{const r=Jt(e.timeoutMinutes,60);return{name:"human_operation_approval",taskReferenceName:t.taskReferenceName,type:"HUMAN",description:`人工审批: ${e.promptMessage||t.taskReferenceName}`,...typeof r=="number"&&r>0?{timeoutSeconds:r*60,timeoutPolicy:"TIME_OUT_WF"}:{},inputParameters:{_actionId:"human.approval",actionName:"人工确认 / 审批",assigneeRole:e.assigneeRole??"devops_lead",promptMessage:e.promptMessage,timeoutMinutes:r}}},decompile:e=>e.inputParameters?._actionId==="human.approval"?{assigneeRole:e.inputParameters.assigneeRole??"devops_lead",promptMessage:e.inputParameters.promptMessage??"",timeoutMinutes:e.inputParameters.timeoutMinutes??60}:null,mockOutput:e=>({approved:!0,reviewer:"devops_lead@internal.cloud",comment:"沙盒模拟快速通过",decisionTime:new Date().toISOString()})},{id:"control.wait",name:"等待缓冲",category:"logic",icon:"hourglass",description:"在两个步骤之间暂停等待一段时间(等待系统自检、镜像就绪等)",riskLevel:"safe",fields:[{key:"duration",label:"等待时长",type:"select",required:!0,defaultValue:"10s",options:[{label:"等待 5 秒 (5s)",value:"5s"},{label:"等待 10 秒 (10s)",value:"10s"},{label:"等待 30 秒 (30s)",value:"30s"},{label:"等待 1 分钟 (1m)",value:"1m"},{label:"等待 5 分钟 (5m)",value:"5m"}]}],outputs:[{key:"waited",label:"是否已就绪",type:"boolean",example:!0},{key:"duration",label:"实际等待时长",type:"string",example:"10s"}],compile:(e,t)=>({name:"wait_step",taskReferenceName:t.taskReferenceName,type:"WAIT",description:`等待 ${e.duration||"10s"}`,inputParameters:{_actionId:"control.wait",actionName:"等待缓冲",duration:e.duration??"10s"}}),decompile:e=>{if(e.inputParameters?._actionId==="control.wait")return{duration:e.inputParameters.duration??"10s"};if(e.type==="WAIT"){const t=Object.keys(e.inputParameters||{}),r=e.inputParameters?.duration;if(t.length===1&&t[0]==="duration"&&typeof r=="string"&&r.trim()!=="")return{duration:r}}return null},mockOutput:e=>({waited:!0,duration:e.duration||"10s"})},{id:"control.decision",name:"条件分支",category:"logic",icon:"shuffle",description:"根据输入参数或上下文表达式,精准分流执行不同业务分支",riskLevel:"safe",fields:[{key:"caseParam",label:"分支判断参数",type:"text",required:!0,defaultValue:"status",placeholder:"例如 status 或 userType",acceptsPills:!0}],outputs:[{key:"selectedCase",label:"命中的分支名称",type:"string",example:"premium"}],compile:(e,t)=>({name:"decision_router",taskReferenceName:t.taskReferenceName,type:"DECISION",caseValueParam:e.caseParam||"status",decisionCases:{},defaultCase:[],inputParameters:{_actionId:"control.decision",actionName:"条件分支",[e.caseParam||"status"]:e[e.caseParam||"status"]??"${workflow.input.status}"}}),decompile:e=>e.type==="DECISION"||e.type==="SWITCH"?{caseParam:e.caseValueParam||"status"}:null,mockOutput:()=>({selectedCase:"SUCCESS"})},{id:"control.fork",name:"并行并发组",category:"logic",icon:"zap",description:"同时并发执行多条独立业务泳道,并在全部完成后汇聚向下流转",riskLevel:"safe",fields:[],outputs:[{key:"lanesCompleted",label:"已完成泳道数",type:"number",example:2}],compile:(e,t)=>({name:"fork_parallel",taskReferenceName:t.taskReferenceName,type:"FORK_JOIN",forkTasks:[],inputParameters:{_actionId:"control.fork",actionName:"并行并发组"}}),decompile:e=>e.type==="FORK_JOIN"||e.type==="FORK_JOIN_DYNAMIC"?{}:null,mockOutput:()=>({lanesCompleted:2})},{id:"control.loop",name:"循环迭代",category:"logic",icon:"repeat",description:"重复循环执行内部步骤,直到满足退出条件或达到最大轮次",riskLevel:"safe",fields:[{key:"loopCondition",label:"循环继续条件表达式",type:"text",required:!0,defaultValue:"if ($.loop_ref['iteration'] < 3) { true; } else { false; }",placeholder:"例如 if ($.loop_ref['iteration'] < 3) { true; } else { false; }",acceptsPills:!0}],outputs:[{key:"iterationCount",label:"实际迭代轮次",type:"number",example:3}],compile:(e,t)=>({name:"do_while_loop",taskReferenceName:t.taskReferenceName,type:"DO_WHILE",loopCondition:e.loopCondition||"false",loopOver:[],inputParameters:{_actionId:"control.loop",actionName:"循环迭代",loopCondition:e.loopCondition||"false"}}),decompile:e=>e.type==="DO_WHILE"?{loopCondition:e.loopCondition||""}:null,mockOutput:()=>({iterationCount:3})}];class Vs{actions=new Map;constructor(t=[]){this.registerAll(t)}register(t){this.actions.set(t.id,t)}registerAll(t){for(const r of t)this.register(r)}unregister(t){this.actions.delete(t)}getAction(t){return this.actions.get(t)}getAllActions(){return Array.from(this.actions.values())}getActionsByCategory(t){const r=this.getAllActions();return t?r.filter(n=>n.category===t):r}findActionForTask(t){const r=t.inputParameters?._actionId;if(r&&typeof r=="string"){const n=this.getAction(r);if(n&&n.decompile){const s=n.decompile(t);if(s)return{action:n,values:s}}}for(const n of this.actions.values())if(n.decompile){const s=n.decompile(t);if(s)return{action:n,values:s}}return null}}const Xe=new Vs([...Jk,...Uk]);function On(e){if(e==null||e==="")return{version:1,lossy:!1};if(typeof e=="number"){if(Number.isInteger(e))return{version:e,lossy:!1};const s=Math.floor(e);return{version:Number.isFinite(s)&&s>0?s:1,label:String(e),lossy:!0}}const t=String(e).trim();if(/^\d+$/.test(t))return{version:parseInt(t,10),label:t,lossy:!1};const r=t.match(/\d+/),n=r?parseInt(r[0],10):NaN;return{version:Number.isNaN(n)?1:n,label:t,lossy:!0}}const Ks=["std","proxy","tmp","custom"],Vk=["L1","L2","L3"];function Gs(e){if(typeof e!="string")return null;const t=e.split("-");if(t.length<5)return null;const r=t[0],n=t[1];return!Ks.includes(r)||!Vk.includes(n)?null:{type:r,level:n,domain:t[2],product:t[3],func:t.slice(4).join("-")}}function ip(e,t){const r=[];if(typeof e!="string"||e.trim()==="")return["流程名称不能为空"];const n=e.split("-");return n.length<5&&r.push("流程名称需为「类型-层级-业务域-产品-功能」5 段,以 - 分隔"),Ks.includes(n[0])||r.push(`类型「${n[0]}」不合法,应为 ${Ks.join(" / ")} 之一`),n.length>1&&!Vk.includes(n[1])&&r.push(`层级「${n[1]}」不合法,应为 L1 / L2 / L3 之一`),n.length>=5&&(n[2]===""?r.push("业务域不能为空"):t&&!t.includes(n[2])&&r.push(`业务域「${n[2]}」不在允许的列表中(${t.join("、")})`),n[3]===""&&r.push("产品不能为空"),n.slice(4).join("-")===""&&r.push("功能不能为空")),r}function Ys(e,t,r){const n=On(e.def.version),s=e.versionLabel??n.label;n.lossy&&r&&r(e.def.name,n.label??String(e.def.version));const a=Gs(e.def.name),i=e.extension?.domain||a?.domain||void 0;return{name:e.def.name,version:n.version,versionLabel:s,description:e.def.description,level:e.extension?.level??a?.level,...i?{domain:i}:{},tags:e.extension?.tags??[],deprecated:e.deprecated??e.extension?.deprecated??!1,record:e,source:t}}function P2(e){const t=On(e.version);return{record:{def:{name:e.workflowName,description:e.description,version:t.version,tasks:[]},extension:{level:e.workflowLevel,tags:e.tags??[],...e.domain?{domain:e.domain}:{}},versionLabel:t.label},lossyLabel:t.lossy?t.label:void 0}}function lp(e){const t=new Map;for(const r of e){const n=t.get(r.name);(!n||r.version>=n.version)&&t.set(r.name,r)}return Array.from(t.values())}class Kk{provider;staticItems=[];staticSchemas=[];providerEntries=[];providerTasks=[];merged=new Map;versionCache=new Map;warned=new Set;listeners=new Set;generation=0;controller=null;snapshot={status:"idle",revision:0};constructor(t,r={}){this.provider=t,this.staticItems=r.staticItems??[],this.staticSchemas=r.staticTaskSchemas??[],this.rebuild()}setProvider(t){t!==this.provider&&(this.provider=t,this.generation++,this.controller?.abort(),this.controller=null,this.providerEntries=[],this.providerTasks=[],this.versionCache.clear(),this.rebuild(),this.setState({status:"idle",error:void 0}))}setStatic(t){t.staticItems!==void 0&&(this.staticItems=t.staticItems),t.staticTaskSchemas!==void 0&&(this.staticSchemas=t.staticTaskSchemas),this.rebuild(),this.setState({})}hasProvider(){return!!this.provider}hasServerSearch(){return typeof this.provider?.search=="function"}async load(t){const r=this.provider;if(!r)return;const n=++this.generation;this.controller?.abort();const s=new AbortController;this.controller=s;const a=()=>s.abort();t&&(t.aborted?s.abort():t.addEventListener("abort",a,{once:!0})),this.setState({status:"loading",error:void 0});try{const i=await r.list(s.signal);if(n!==this.generation)return;if(s.signal.aborted){this.setState({status:"idle"});return}this.providerEntries=lp(i.workflows.map(l=>Ys(l,"provider",this.warnLossy))),this.providerTasks=i.tasks??[],this.rebuild(),this.setState({status:"ready",error:void 0})}catch(i){if(n!==this.generation)return;if(s.signal.aborted){this.setState({status:"idle"});return}this.setState({status:"error",error:i instanceof Error?i:new Error(String(i))})}finally{t?.removeEventListener("abort",a),this.controller===s&&(this.controller=null)}}reload(){return this.load()}abort(){this.controller&&(this.generation++,this.controller.abort(),this.controller=null,this.snapshot.status==="loading"&&this.setState({status:"idle"}))}latest(t){return this.merged.get(t)}entries(){return Array.from(this.merged.values())}tasks(){return this.providerTasks}staticTaskSchemas(){return this.staticSchemas}async getVersion(t,r,n){const s=`${t}@${r}`,a=this.versionCache.get(s);if(a)return a;const i=this.merged.get(t);if(i?.source==="static"&&i.version===r)return i.record;const l=this.provider;if(!l)return null;const c=this.generation,d=await l.get(t,r,n);return d&&c===this.generation&&this.versionCache.set(s,d),d}async search(t,r,n){const s=this.provider;if(!s?.search)return null;const a=await s.search(t,r,n);return lp(a.map(i=>Ys(i,"provider",this.warnLossy)))}getSnapshot=()=>this.snapshot;subscribe=t=>(this.listeners.add(t),()=>{this.listeners.delete(t)});warnLossy=(t,r)=>{const n=`${t}@${r}`;this.warned.has(n)||(this.warned.add(n),console.warn(`[LibraryCatalog] 流程库「${t}」的版本号「${r}」不是整数,已按主版本号规范化。`))};rebuild(){const t=new Map;for(const n of this.providerEntries)t.set(n.name,n);const r=lp(this.staticItems.map(n=>{const{record:s,lossyLabel:a}=P2(n);return a&&this.warnLossy(n.workflowName,a),Ys(s,"static")}));for(const n of r)t.has(n.name)||t.set(n.name,n);this.merged=t}setState(t){this.snapshot={...this.snapshot,...t,revision:this.snapshot.revision+1};for(const r of Array.from(this.listeners))r()}}const A2=()=>{},Gk={status:"idle",revision:0};function Xs(e){return T.useSyncExternalStore(e?e.subscribe:()=>A2,e?e.getSnapshot:()=>Gk,e?e.getSnapshot:()=>Gk)}function Yk(e,t){T.useEffect(()=>(e.setProvider(t),t&&e.load(),()=>{e.abort()}),[e,t])}const Xk=["library","onboarding","telemetry"];function cp(e={}){const t=[e.override,e.component,e.context],r={};for(const n of Xk)for(const s of t){const a=s?.[n];if(a!=null){r[n]=a;break}}return r}function Zk(e,t){return e&&Xk.every(r=>e[r]===t[r])?e:t}const $2=Object.freeze({}),dp=T.createContext($2);function Qk(e){const t=T.useRef(void 0),r=Zk(t.current,e);return t.current=r,r}function D2({providers:e,children:t}){const r=Qk(cp({component:e}));return o.jsx(dp.Provider,{value:r,children:t})}function L2(){return T.useContext(dp)}function M2(e,t){const r=T.useContext(dp);return Qk(cp({override:t,component:e,context:r}))}const W2=5e3,z2=20,q2={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e)};function e1(e,t={}){if(!e)return{push(){},flush(){},dispose(){}};const r=t.flushIntervalMs??W2,n=Math.max(1,t.maxBatchSize??z2),s=t.timers??q2,a=t.document!==void 0?t.document:typeof document<"u"?document:null,i=t.window!==void 0?t.window:typeof window<"u"?window:null;let l=[],c=null,d=!1,u=!1;const p=x=>{u||(u=!0,console.warn("[reactflow-ui] 埋点 sink 调用失败,已忽略(后续同类错误不再提示):",x))},f=()=>{c!==null&&(s.clear(c),c=null)},m=()=>{if(f(),l.length===0)return;const x=l;l=[];try{const g=e.track(x);g&&typeof g.then=="function"&&g.then(void 0,p)}catch(g){p(g)}},h=()=>{a&&a.visibilityState==="hidden"&&m()},y=()=>m();try{a?.addEventListener("visibilitychange",h),i?.addEventListener("pagehide",y)}catch(x){p(x)}return{push(x){d||(l.push(x),l.length>=n?m():c===null&&(c=s.set(m,r)))},flush:m,dispose(){if(!d){m(),d=!0;try{a?.removeEventListener("visibilitychange",h),i?.removeEventListener("pagehide",y)}catch{}}}}}function F2(e){if(!e||typeof e!="object")return;const t={};let r=0;for(const n of Object.keys(e)){const s=e[n];(typeof s=="string"||typeof s=="boolean"||typeof s=="number"&&Number.isFinite(s))&&(t[n]=s,r++)}return r>0?t:void 0}function B2(e){const t=e.now??Date.now;return(r,n)=>{try{const s={name:r,at:t(),ide:e.ide},a=e.getWorkflowName();a&&(s.workflowName=a);const i=F2(n);i&&(s.props=i),e.push(s)}catch(s){console.warn("[reactflow-ui] 埋点失败,已忽略:",s)}}}function H2(){let e=!1;return{take(){return e?!1:(e=!0,!0)}}}function J2(e,t){const r=T.useRef(null);return T.useEffect(()=>{const n=e1(t);return r.current=n,()=>{n.dispose(),r.current===n&&(r.current=null)}},[t]),T.useMemo(()=>B2({ide:e,getWorkflowName:()=>te.getState().workflowDef?.name||void 0,push:n=>r.current?.push(n)}),[e])}function U2(e){const t=T.useRef(null);t.current===null&&(t.current=H2()),T.useEffect(()=>{t.current?.take()&&e("ide_opened")},[e])}function V2(e){T.useEffect(()=>{const t=Mj(n=>e("sandbox_run",{result:n,entry:"pro"})),r=Wj(n=>e("step_added",{source:n}));return()=>{t(),r()}},[e])}const t1=e=>e!==null&&typeof e=="object"&&!Array.isArray(e);function Ut(e){for(const t of Object.keys(e))e[t]===void 0&&delete e[t];return e}function up(e){const t=e.rawTaskDef?structuredClone(e.rawTaskDef):{};t.name=e.name||t.name||e.taskReferenceName,t.taskReferenceName=e.taskReferenceName,e.description!==void 0&&(t.description=e.description||void 0);const r=e.values||{};return Object.keys(r).length>0||e.rawTaskDef?.inputParameters!==void 0||!e.rawTaskDef?t.inputParameters={...r}:delete t.inputParameters,t}function K2(e,t,r){const n=up(e),s={};let a=[];for(const l of e.branches||[])l.caseKey==="__default__"?a=Pn(l.steps,t,r):s[l.caseKey]=Pn(l.steps,t,r);const i=e.caseExpression!==void 0;return n.type==="SWITCH"?i?(n.evaluatorType=n.evaluatorType&&n.evaluatorType!=="value-param"?n.evaluatorType:"javascript",n.expression=e.caseExpression):(n.evaluatorType="value-param",n.expression=e.caseParam??""):(n.type="DECISION",i?(n.caseExpression=e.caseExpression,delete n.caseValueParam):(n.caseValueParam=e.caseParam??"",delete n.caseExpression)),n.decisionCases=s,n.defaultCase=a,Ut(n)}function G2(e,t,r){const n=up(e);return n.type="FORK_JOIN",n.forkTasks=(e.forkLanes||[]).map(s=>Pn(s.steps,t,r)),Ut(n)}function Y2(e,t,r){const n=up(e);return n.type="DO_WHILE",n.loopCondition=e.loopCondition??n.loopCondition??"false",n.loopOver=Pn(e.loopSteps||[],t,r),Ut(n)}function X2(e,t,r,n){const s=t.compile(e.values,{taskReferenceName:e.taskReferenceName,stepIndex:r,workflowName:n,libraryRef:e.libraryRef}),a=e.rawTaskDef?structuredClone(e.rawTaskDef):{},i=new Set(t.fields.map(f=>f.key)),l=a.inputParameters||{},c=s.inputParameters||{},d={...l};for(const[f,m]of Object.entries(c))d[f]=!i.has(f)&&t1(m)&&t1(l[f])?{...l[f],...m}:m;for(const f of i)f in l&&!(f in c)&&delete d[f];const u={...a,...s,name:a.name||s.name,taskReferenceName:e.taskReferenceName,inputParameters:d};(a.subWorkflowParam||s.subWorkflowParam)&&(u.subWorkflowParam={...a.subWorkflowParam||{},...s.subWorkflowParam||{}});const p=e.name&&e.name!==t.name?e.name:void 0;return u.description=p??a.description??s.description,Ut(u)}function pp(e,t,r,n=Xe){if(e.controlType==="decision")return K2(e,r,n);if(e.controlType==="fork")return G2(e,r,n);if(e.controlType==="loop")return Y2(e,r,n);if(e.isProFallback&&e.rawTaskDef)return Ut({...e.rawTaskDef,taskReferenceName:e.taskReferenceName||e.rawTaskDef.taskReferenceName,name:e.name||e.rawTaskDef.name,description:e.description??e.rawTaskDef.description});const s=n.getAction(e.actionId);return s?X2(e,s,t,r):e.rawTaskDef?Ut({...e.rawTaskDef,taskReferenceName:e.taskReferenceName,inputParameters:{...e.rawTaskDef.inputParameters||{},...e.values}}):Ut({name:e.name||e.taskReferenceName,taskReferenceName:e.taskReferenceName,type:"SIMPLE",description:e.description,inputParameters:{_actionId:e.actionId,...e.values}})}function Z2(e,t){const r=e.pairedJoinTaskRef||`join_${e.taskReferenceName}`,n=e.pairedJoinTaskDef?structuredClone(e.pairedJoinTaskDef):{};if(t.type==="FORK_JOIN_DYNAMIC")return Ut({name:`${e.taskReferenceName}_join`,...n,taskReferenceName:r,type:"JOIN"});const s=Array.isArray(n.joinOn)&&n.joinOn.length>0?[...n.joinOn]:null,a=s??[];if(!s)for(const i of t.forkTasks||[])i&&i.length>0&&a.push(i[i.length-1].taskReferenceName);return Ut({name:`${e.taskReferenceName}_join`,...e.pairedJoinTaskDef?{}:{description:`Join task for ${e.taskReferenceName}`},...n,taskReferenceName:r,type:"JOIN",joinOn:a.length>0?a:void 0})}function Pn(e,t,r=Xe){const n=[];for(let s=0;s<e.length;s++){const a=e[s],i=pp(a,s,t,r);n.push(i);const l=a.isProFallback&&i.type==="FORK_JOIN_DYNAMIC"&&!!a.pairedJoinTaskRef;(a.controlType==="fork"||l)&&n.push(Z2(a,i))}return n}function r1(e,t=Xe){const r=e.rawWorkflowDef?structuredClone(e.rawWorkflowDef):{},n=Pn(e.steps,e.name,t);at(n,e.rawWorkflowDef?.tasks??null);const s=e.rawWorkflowDef,a={...r,name:e.name||"cloud_host_automation",description:s?e.description:e.description||"云平台自动化工作流",version:s?e.version:e.version??1,schemaVersion:s&&s.schemaVersion===void 0?void 0:2,tasks:n,inputParameters:e.inputParameters||r.inputParameters};for(const i of["description","version","schemaVersion","inputParameters"])a[i]===void 0&&delete a[i];return a}function n1(e,t,r=Xe){const n=`step_${e.taskReferenceName||`idx${t}`}`;if(e.type==="DECISION"||e.type==="SWITCH"){const a=[];if(e.decisionCases)for(const[c,d]of Object.entries(e.decisionCases))a.push({caseKey:c,caseLabel:`分支: ${c}`,steps:An(d||[],r)});a.push({caseKey:"__default__",caseLabel:"默认分支 (Default)",steps:An(e.defaultCase||[],r)});let i,l;return e.type==="SWITCH"?!e.evaluatorType||e.evaluatorType==="value-param"?i=e.expression??"":l=e.expression??"":e.caseExpression!==void 0&&!e.caseValueParam?l=e.caseExpression:i=e.caseValueParam??"",{id:n,actionId:"control_decision",taskReferenceName:e.taskReferenceName,name:e.name||e.taskReferenceName,description:e.description,values:{...e.inputParameters||{}},isProFallback:!1,rawTaskDef:structuredClone(e),controlType:"decision",caseParam:i,caseExpression:l,branches:a}}if(e.type==="FORK_JOIN"){const a=(e.forkTasks||[]).map((i,l)=>({laneId:`lane_${l}`,laneLabel:`并发泳道 #${l+1}`,steps:An(i||[],r)}));return{id:n,actionId:"control_fork",taskReferenceName:e.taskReferenceName,name:e.name||e.taskReferenceName,description:e.description,values:{...e.inputParameters||{}},isProFallback:!1,rawTaskDef:structuredClone(e),controlType:"fork",forkLanes:a}}if(e.type==="DO_WHILE"){const a=An(e.loopOver||[],r);return{id:n,actionId:"control_loop",taskReferenceName:e.taskReferenceName,name:e.name||e.taskReferenceName,description:e.description,values:{...e.inputParameters||{}},isProFallback:!1,rawTaskDef:structuredClone(e),controlType:"loop",loopCondition:e.loopCondition??"",loopSteps:a}}const s=e.type==="FORK_JOIN_DYNAMIC"?null:r.findActionForTask(e);if(s){let a;try{a=s.action.compile(s.values,{taskReferenceName:e.taskReferenceName,stepIndex:t}).description}catch{a=void 0}const i=e.description&&e.description!==a?e.description:void 0;return{id:n,actionId:s.action.id,taskReferenceName:e.taskReferenceName,name:i??s.action.name,description:e.description,values:s.values,isProFallback:!1,rawTaskDef:structuredClone(e),...e.type==="SUB_WORKFLOW"&&e.subWorkflowParam?.name?{libraryRef:{name:e.subWorkflowParam.name,version:e.subWorkflowParam.version}}:{}}}return{id:n,actionId:"pro_custom_task",taskReferenceName:e.taskReferenceName,name:e.name||e.taskReferenceName,description:e.description,values:e.inputParameters||{},isProFallback:!0,rawTaskDef:structuredClone(e)}}function An(e,t=Xe){const r=i=>i.type==="FORK_JOIN"||i.type==="FORK_JOIN_DYNAMIC",n=new Map,s=new Set;for(let i=0;i<e.length;i++)if(r(e[i])){for(let l=i+1;l<e.length;l++)if(e[l].type==="JOIN"&&!s.has(l)){n.set(i,l),s.add(l);break}}const a=[];for(let i=0;i<e.length;i++){const l=e[i];if(s.has(i))continue;const c=n1(l,i,t),d=n.get(i);d!==void 0&&(c.pairedJoinTaskRef=e[d].taskReferenceName,c.pairedJoinTaskDef=structuredClone(e[d])),a.push(c)}return a}function s1(e,t=Xe){if(!e)return{name:"new_cloud_automation",description:"新建云平台运维自动化流程",version:1,steps:[]};const r=An(e.tasks||[],t);return{name:e.name||"unnamed_workflow",description:e.description,version:e.version,steps:r,inputParameters:e.inputParameters,rawWorkflowDef:structuredClone(e)}}const Br=e=>e==null||typeof e=="string"&&e.trim()==="",Q2=e=>typeof e=="string"&&e.includes("${");function Vt(e,t,r){(e[t]||=[]).push(r)}function Sr(e,t,r={}){for(const n of e){const s=n.taskReferenceName;if(n.controlType==="decision"){n.caseExpression!==void 0?Br(n.caseExpression)&&Vt(r,s,{level:"error",message:"判断表达式为空:请填写用于选择分支的表达式"}):Br(n.caseParam)?Vt(r,s,{level:"error",message:"判断参数名为空:请填写参数名并绑定判断取值"}):Br(n.values?.[n.caseParam])&&Vt(r,s,{field:n.caseParam,level:"error",message:"判断取值未绑定:请插入用于判断的数据,否则运行时总是走默认分支"}),(n.branches||[]).some(i=>i.caseKey!=="__default__")||Vt(r,s,{level:"warning",message:"还没有条件分支:所有情况都会走默认分支,请新增分支"});for(const i of n.branches||[])Sr(i.steps,t,r);continue}if(n.controlType==="fork"){(n.forkLanes||[]).forEach((i,l)=>{i.steps.length===0&&Vt(r,s,{level:"error",message:`泳道 ${l+1} 没有步骤:请添加步骤或删除该泳道`}),Sr(i.steps,t,r)});continue}if(n.controlType==="loop"){Br(n.loopCondition)&&Vt(r,s,{level:"error",message:"循环继续条件为空:请填写何时继续下一轮"}),(n.loopSteps||[]).length===0&&Vt(r,s,{level:"warning",message:"循环体内没有步骤:请添加需要重复执行的步骤"}),Sr(n.loopSteps||[],t,r);continue}if(n.isProFallback)continue;const a=t.getAction(n.actionId);if(a)for(const i of a.fields){const l=n.values?.[i.key]??i.defaultValue;if(i.required&&Br(l)){Vt(r,s,{field:i.key,level:"error",message:`「${i.label}」为必填项:请填写或插入数据`});continue}i.type==="number"&&!Br(l)&&!Q2(l)&&!Number.isFinite(Number(l))&&Vt(r,s,{field:i.key,level:"error",message:`「${i.label}」需要填写数字`})}}return r}function eC(e,t){if(!t)return e;const r=(n,s)=>{for(const a of n||[]){if(a.type!=="TASK"||!a.ref)continue;const i=e[a.ref]||=[];i.some(l=>l.message===a.message)||i.push({level:s,message:a.message})}};return r(t.errors,"error"),r(t.warnings,"warning"),e}function Zs(e,t){const r=[...t[e.taskReferenceName]||[]],n=[...(e.branches||[]).flatMap(s=>s.steps),...(e.forkLanes||[]).flatMap(s=>s.steps),...e.loopSteps||[]];for(const s of n)r.push(...Zs(s,t));return r}const fp=e=>e.pairedJoinTaskRef||`join_${e.taskReferenceName}`;function a1(e,t,r){const n=[],s=(r||[]).map(i=>typeof i=="string"?{name:i}:i).filter(i=>!!i&&typeof i.name=="string"&&i.name!=="");s.length>0&&n.push({key:"workflow.input",title:"工作流全局入参",icon:"globe",items:s.map(i=>({rawRef:`workflow.input.${i.name}`,label:i.description||i.name,type:i.type||"string",example:i.example??i.defaultValue,stepLabel:"全局入参"}))});const a=(i,l,c)=>{const d=t.getAction(i.actionId),u=i.name||d?.name||i.taskReferenceName;if(i.controlType==="decision"){for(const f of i.branches||[]){const m=f.caseKey==="__default__"?"默认分支":`分支 ${f.caseKey}`;for(const h of f.steps)a(h,`${u} › ${m} › ${h.name||h.taskReferenceName}`,`仅在${m}被执行时有值`)}return}if(i.controlType==="fork"){n.push({key:fp(i),title:`${l}(并行汇聚)`,icon:"zap",note:c,items:[{rawRef:`${fp(i)}.output`,label:"各泳道最后一步的输出",type:"object",stepLabel:u}]}),(i.forkLanes||[]).forEach((f,m)=>{for(const h of f.steps)a(h,`${u} › 泳道 ${m+1} › ${h.name||h.taskReferenceName}`,c)});return}if(i.controlType==="loop"){n.push({key:i.taskReferenceName,title:l,icon:"repeat",note:c,items:[{rawRef:`${i.taskReferenceName}.output.iteration`,label:"已执行轮次",type:"number",stepLabel:u}]});for(const f of i.loopSteps||[])a(f,`${u} › 循环体 › ${f.name||f.taskReferenceName}`,"循环体内的步骤,取最后一轮的值");return}const p=d&&d.outputs.length>0?d.outputs.map(f=>({rawRef:`${i.taskReferenceName}.output.${f.key}`,label:f.label,type:f.type,example:f.example,stepLabel:u})):[{rawRef:`${i.taskReferenceName}.output`,label:"完整输出对象",type:"object",stepLabel:u}];n.push({key:i.taskReferenceName,title:l,icon:d?.icon||"settings",note:c,items:p})};return e.forEach((i,l)=>{const c=t.getAction(i.actionId);a(i,`#${l+1} ${i.name||c?.name||i.taskReferenceName}`)}),n}function tC(e,t){for(const r of t){const n=r.items.find(s=>s.rawRef===e);if(n)return r.key==="workflow.input"?`全局入参 · ${n.label}`:`${n.stepLabel} · ${n.label}`}if(e.startsWith("workflow.input."))return`全局入参 · ${e.slice(15)}`;for(const r of t){const n=r.items[0],s=n?.rawRef.split(".output")[0];if(n&&s&&e.startsWith(`${s}.output`))return`${n.stepLabel} 输出`}return e}const rC=({upstreamSteps:e,onSelect:t,onClose:r,registry:n=Xe,workflowInputParams:s})=>{const[a,i]=T.useState(""),l=T.useRef(null),c=T.useMemo(()=>a1(e,n,s),[e,n,s]);T.useEffect(()=>{const u=l.current;if(!u)return;const p=f=>{f.key==="Escape"&&(f.stopPropagation(),r())};return u.addEventListener("keydown",p),()=>u.removeEventListener("keydown",p)},[r]);const d=T.useMemo(()=>{if(!a.trim())return c;const u=a.toLowerCase();return c.map(p=>({...p,items:p.items.filter(f=>f.label.toLowerCase().includes(u)||f.rawRef.toLowerCase().includes(u))})).filter(p=>p.items.length>0)},[c,a]);return o.jsxs("div",{ref:l,role:"dialog","aria-label":"插入数据",style:{position:"absolute",top:"100%",left:0,zIndex:1100,width:340,maxHeight:380,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",borderRadius:8,boxShadow:"var(--cm-shadow-float)",display:"flex",flexDirection:"column",overflow:"hidden",marginTop:4,fontFamily:"inherit"},children:[o.jsxs("div",{style:{padding:"8px 10px",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",gap:8,background:"var(--bg-tertiary)"},children:[o.jsx("span",{style:{fontSize:13},children:o.jsx(As,{size:13,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsx("input",{autoFocus:!0,type:"text","aria-label":"搜索可插入的数据",placeholder:"搜索上游输出或全局入参…",value:a,onChange:u=>i(u.target.value),style:{flex:1,background:"transparent",border:"none",outline:"none",color:"var(--text-primary)",fontSize:12}}),o.jsx("button",{type:"button",onClick:r,"aria-label":"关闭",style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:14,padding:"2px 4px"},title:"关闭",children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsx("div",{style:{flex:1,overflowY:"auto",padding:"6px 4px"},children:d.length===0?o.jsx("div",{style:{padding:"24px 12px",textAlign:"center",color:"var(--text-muted)",fontSize:12},children:c.length===0?"前面还没有可引用的步骤输出,也没有声明工作流全局入参":"没有匹配的字段,换个关键字试试"}):d.map(u=>o.jsxs("div",{role:"group","aria-label":u.title,style:{marginBottom:8},children:[o.jsxs("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",padding:"4px 8px",display:"flex",alignItems:"center",gap:6},children:[o.jsx("span",{style:{display:"inline-flex"},children:o.jsx(We,{name:u.icon,size:13})}),o.jsx("span",{children:u.title})]}),u.note&&o.jsx("div",{style:{fontSize:10,color:"var(--text-muted)",padding:"0 8px 2px 27px"},children:u.note}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:2},children:u.items.map(p=>o.jsxs("button",{type:"button",onClick:()=>{t({rawRef:p.rawRef,label:p.label,stepLabel:p.stepLabel}),r()},style:{width:"100%",border:"none",background:"transparent",color:"inherit",fontFamily:"inherit",textAlign:"left",padding:"6px 10px",borderRadius:6,cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between",transition:"background 0.15s ease",fontSize:12},onMouseEnter:f=>{f.currentTarget.style.background="var(--bg-highlight)"},onMouseLeave:f=>{f.currentTarget.style.background="transparent"},onFocus:f=>{f.currentTarget.style.background="var(--bg-highlight)"},onBlur:f=>{f.currentTarget.style.background="transparent"},children:[o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6,overflow:"hidden"},children:[o.jsx("span",{style:{fontWeight:500,color:"var(--text-primary)",whiteSpace:"nowrap"},children:p.label}),o.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"monospace",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:p.rawRef})]}),o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:6},children:[p.example!==void 0&&o.jsx("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:4,background:"var(--cm-data-tint)",color:"var(--cm-data)",fontFamily:"monospace",maxWidth:90,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:`样例值: ${String(p.example)}`,children:String(p.example)}),o.jsx("span",{style:{fontSize:10,padding:"1px 4px",borderRadius:3,background:"var(--bg-tertiary)",color:"var(--text-muted)"},children:p.type})]})]},p.rawRef))})]},u.key))}),o.jsx("div",{style:{padding:"4px 8px",background:"var(--bg-tertiary)",borderTop:"1px solid var(--border-primary)",fontSize:10,color:"var(--text-muted)",textAlign:"right"},children:"选择一项,以数据胶囊插入到光标处;Esc 关闭"})]})},o1=T.createContext({issues:{},allSteps:[]}),_r=()=>T.useContext(o1),ir=e=>`cm-step-${e}`;function $n(e,t){return e.some(r=>r.taskReferenceName===t||$n(r.loopSteps||[],t)||(r.branches||[]).some(n=>$n(n.steps,t))||(r.forkLanes||[]).some(n=>$n(n.steps,t)))}const Qs=e=>e!==null&&typeof e=="object";function i1(e){try{return{ok:!0,value:JSON.parse(e)}}catch(t){return{ok:!1,error:t instanceof Error?t.message:String(t)}}}const ea=({value:e,onChange:t,placeholder:r,multiline:n=!1,upstreamSteps:s,registry:a=Xe,workflowInputParams:i,disabled:l=!1,defaultShowPicker:c=!1,id:d,ariaLabel:u,invalid:p=!1,describedBy:f,mono:m=!1})=>{const h=_r(),y=i??h.workflowInputParams,[x,g]=T.useState(c),v=T.useRef(null),[k]=T.useState(()=>Qs(e)),[b,S]=T.useState(()=>Qs(e)?JSON.stringify(e,null,2):""),[j,_]=T.useState(null);T.useEffect(()=>{if(!k)return;const F=i1(b),A=F.ok?F.value:b;JSON.stringify(A)!==JSON.stringify(e)&&(S(Qs(e)?JSON.stringify(e,null,2):String(e??"")),_(null))},[e,k]);const w=k?b:e!=null?String(e):"",I=F=>{if(!k){t(F);return}S(F);const A=i1(F);A.ok&&Qs(A.value)?(_(null),t(A.value)):(_(A.ok?"需要是 JSON 对象或数组":A.error),t(F))},N=T.useMemo(()=>a1(s,a,y),[s,a,y]),C=T.useMemo(()=>{const F=[];for(const A of w.matchAll(/\$\{([^}]+)\}/g)){const W=A[1].trim();F.push({raw:A[0],ref:W,label:tC(W,N)})}return F},[w,N]),M=F=>{const A=`\${${F.rawRef}}`,W=v.current;if(W){const P=W.selectionStart??w.length,D=W.selectionEnd??w.length;I(w.substring(0,P)+A+w.substring(D)),setTimeout(()=>{W.focus(),W.setSelectionRange(P+A.length,P+A.length)},0)}else I(w?`${w} ${A}`:A)},R=F=>{F.key==="@"&&!l&&(F.preventDefault(),g(!0))},O=d?`${d}-json-error`:void 0,$=[f,j?O:void 0].filter(Boolean).join(" ")||void 0,B={flex:1,minWidth:0,background:"transparent",border:"none",outline:"none",color:"var(--text-primary)",fontSize:13,fontFamily:m||k?"var(--cm-font-mono, monospace)":"inherit"},q=n||k;return o.jsxs("div",{style:{position:"relative",display:"flex",flexDirection:"column",gap:4,width:"100%"},children:[o.jsxs("div",{style:{display:"flex",alignItems:q?"flex-start":"center",gap:6,background:"var(--bg-secondary)",border:`1px solid ${p||j?"var(--cm-status-failed)":"var(--border-secondary)"}`,borderRadius:6,padding:"4px 8px",transition:"border-color 0.15s ease"},children:[q?o.jsx("textarea",{ref:v,id:d,"aria-label":u,"aria-invalid":p||!!j||void 0,"aria-describedby":$,disabled:l,value:w,placeholder:r||"输入内容,或按 @ 插入上游数据胶囊…",rows:k?Math.min(8,Math.max(3,w.split(`
|
|
274
|
+
`).length)):3,onChange:F=>I(F.target.value),onKeyDown:R,style:{...B,resize:"vertical",lineHeight:1.5}}):o.jsx("input",{ref:v,id:d,"aria-label":u,"aria-invalid":p||void 0,"aria-describedby":$,type:"text",disabled:l,value:w,placeholder:r||"输入内容,或按 @ 插入数据胶囊…",onChange:F=>I(F.target.value),onKeyDown:R,style:B}),o.jsxs("button",{type:"button",disabled:l,onClick:()=>g(!x),"aria-expanded":x,title:"选择并插入上游数据胶囊(也可按 @)",style:{background:x?"var(--cm-data-tint)":"var(--bg-tertiary)",color:x?"var(--cm-data)":"var(--text-secondary)",border:`1px solid ${x?"var(--cm-data)":"var(--border-primary)"}`,borderRadius:4,padding:"2px 8px",fontSize:11,cursor:l?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:4,flexShrink:0,transition:"all 0.15s ease"},children:[o.jsx(As,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),o.jsx("span",{children:"插入数据"})]})]}),j&&o.jsxs("div",{id:O,style:{fontSize:11,color:"var(--cm-status-failed)",display:"flex",alignItems:"center",gap:4},children:[o.jsx(jt,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"JSON 格式有误(",j,"):修正后按对象保存,否则按文本保存"]}),C.length>0&&o.jsxs("div",{style:{display:"flex",flexWrap:"wrap",gap:4,alignItems:"center",padding:"2px 2px"},children:[o.jsx("span",{style:{fontSize:10,color:"var(--text-muted)"},children:"已引用数据:"}),C.map((F,A)=>o.jsxs("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:12,background:"var(--cm-data-tint)",color:"var(--cm-data)",border:"1px solid color-mix(in srgb, var(--cm-data) 35%, transparent)",display:"inline-flex",alignItems:"center",gap:4,fontWeight:500},title:`原始引用表达式: ${F.raw}`,children:[o.jsx(Ou,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),o.jsx("span",{children:F.label})]},`${F.ref}_${A}`))]}),x&&o.jsx(rC,{upstreamSteps:s,workflowInputParams:y,registry:a,onSelect:M,onClose:()=>{g(!1),v.current?.focus()}})]})},nC={COMPLETED:{label:"成功",color:"var(--cm-status-success)",icon:"check"},COMPLETED_WITH_ERRORS:{label:"带错完成",color:"var(--cm-status-warning)",icon:"alert"},FAILED:{label:"失败",color:"var(--cm-status-failed)",icon:"x"},FAILED_WITH_TERMINAL_ERROR:{label:"失败",color:"var(--cm-status-failed)",icon:"x"},TIMED_OUT:{label:"已超时",color:"var(--cm-status-failed)",icon:"timer"},SKIPPED:{label:"已跳过",color:"var(--cm-status-skipped)",icon:"skip"},IN_PROGRESS:{label:"运行中",color:"var(--cm-status-running)",icon:"loader"},SCHEDULED:{label:"等待中",color:"var(--cm-status-pending)",icon:"circle"},CANCELED:{label:"已取消",color:"var(--cm-status-skipped)",icon:"ban"}};function sC(e){return e&&nC[e]||{label:"等待中",color:"var(--cm-status-pending)",icon:"circle"}}const Lt={size:14,strokeWidth:1.75,"aria-hidden":!0},aC={check:_t,x:$e,timer:zu,skip:Wu,loader:Pu,circle:ju,ban:ku,alert:Ye},mp=e=>({fontSize:11,padding:"1px 6px",borderRadius:4,background:`color-mix(in srgb, ${e} 15%, transparent)`,color:e,fontWeight:600,display:"inline-flex",alignItems:"center",gap:4,whiteSpace:"nowrap"}),Dn=({issues:e})=>{if(e.length===0)return null;const t=e.filter(a=>a.level==="error").length,r=t>0?"var(--cm-status-failed)":"var(--cm-status-warning)",n=t>0?jt:Ye,s=t>0?`${t} 项待修正`:`${e.length} 项提醒`;return o.jsxs("span",{style:mp(r),title:e.map(a=>a.message).join(`
|
|
275
|
+
`),children:[o.jsx(n,{...Lt}),s]})},hp=({status:e})=>{if(!e)return null;const t=sC(e),r=aC[t.icon];return o.jsxs("span",{style:mp(t.color),title:`试跑结果:${t.label}(${e})`,children:[o.jsx(r,{...Lt}),"试跑",t.label]})},l1=()=>o.jsxs("span",{style:{...mp("var(--cm-status-failed)"),fontSize:10},title:"此步骤会直接改动真实资源",children:[o.jsx(We,{name:"alert",size:14}),"敏感"]}),ta=({issues:e})=>e.length===0?null:o.jsx("ul",{role:"list",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:4},children:e.map((t,r)=>{const n=t.level==="error"?"var(--cm-status-failed)":"var(--cm-status-warning)",s=t.level==="error"?jt:Ye;return o.jsxs("li",{style:{fontSize:11,color:n,display:"flex",alignItems:"flex-start",gap:4,lineHeight:1.5},children:[o.jsx(s,{...Lt,style:{flexShrink:0,marginTop:2}}),o.jsx("span",{children:t.message})]},r)})}),Kt=({label:e,onClick:t,disabled:r,danger:n,children:s})=>o.jsx("button",{type:"button","aria-label":e,title:e,disabled:r,onClick:a=>{a.stopPropagation(),t()},style:{background:"none",border:"none",borderRadius:4,color:r?"var(--cm-text-disabled)":n?"var(--cm-status-failed)":"var(--text-secondary)",cursor:r?"default":"pointer",padding:4,display:"inline-flex",alignItems:"center"},children:s}),ra=({index:e,count:t,onMove:r,onDelete:n})=>o.jsxs(o.Fragment,{children:[o.jsx(Kt,{label:"上移",disabled:e===0,onClick:()=>r(e-1),children:o.jsx(iT,{...Lt})}),o.jsx(Kt,{label:"下移",disabled:e>=t-1,onClick:()=>r(e+1),children:o.jsx(oT,{...Lt})}),o.jsx(Kt,{label:"删除步骤",danger:!0,onClick:n,children:o.jsx($s,{...Lt})})]}),yp=({onClick:e,label:t="插入步骤",compact:r})=>o.jsx("div",{style:{display:"flex",justifyContent:"center",margin:r?"-2px 0":"-4px 0"},children:o.jsxs("button",{type:"button",onClick:e,style:{padding:r?"1px 8px":"4px 12px",borderRadius:16,background:"var(--bg-tertiary)",border:"1px dashed var(--border-secondary)",color:"var(--text-muted)",fontSize:r?10:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4},onMouseEnter:n=>{n.currentTarget.style.borderColor="var(--color-accent)",n.currentTarget.style.color="var(--color-accent)"},onMouseLeave:n=>{n.currentTarget.style.borderColor="var(--border-secondary)",n.currentTarget.style.color="var(--text-muted)"},children:[o.jsx(rr,{...Lt,size:r?12:14}),o.jsx("span",{children:t})]})}),c1=({initial:e,fallback:t,onDone:r,fontSize:n})=>{const[s,a]=T.useState(e),i=l=>r(l?s.trim()||t:null);return o.jsx("input",{autoFocus:!0,"aria-label":"步骤名称",value:s,placeholder:t,onChange:l=>a(l.target.value),onClick:l=>l.stopPropagation(),onKeyDown:l=>{l.stopPropagation(),l.key==="Enter"&&i(!0),l.key==="Escape"&&i(!1)},onBlur:()=>i(!0),style:{flex:1,minWidth:120,padding:"3px 8px",borderRadius:4,border:"1px solid var(--color-accent)",background:"var(--bg-secondary)",color:"var(--text-primary)",fontSize:n,fontWeight:600,outline:"none",fontFamily:"inherit"}})},gp=({value:e,fallback:t,disabled:r,onRename:n,fontSize:s=14})=>{const[a,i]=T.useState(!1);return a?o.jsx(c1,{initial:e,fallback:t,fontSize:s,onDone:l=>{i(!1),l!==null&&l!==e&&n(l)}}):o.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2,minWidth:0},children:[o.jsx("span",{style:{fontWeight:600,fontSize:s,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e||t}),!r&&o.jsx(Kt,{label:"重命名步骤",onClick:()=>i(!0),children:o.jsx(fn,{...Lt,size:12})})]})},d1=({bodyId:e,indexLabel:t,icon:r,title:n,subtitle:s,defaultTitle:a,expanded:i,onToggle:l,disabled:c,compact:d,accentIndex:u,onRename:p,badges:f,actions:m})=>{const[h,y]=T.useState(!1),x=d?11:14;return o.jsxs("div",{style:{padding:d?"4px 6px":"8px 12px",display:"flex",alignItems:"center",gap:d?4:8,background:i?"color-mix(in srgb, var(--color-accent) 5%, transparent)":"transparent",flexWrap:d?"wrap":"nowrap"},children:[h?o.jsx(c1,{initial:n,fallback:a,fontSize:x,onDone:g=>{y(!1),g!==null&&g!==n&&p?.(g)}}):o.jsxs("button",{type:"button","aria-expanded":i,"aria-controls":e,onClick:l,style:{flex:1,minWidth:0,display:"flex",alignItems:"center",gap:d?6:10,background:"none",border:"none",padding:d?"2px 0":"4px 0",cursor:"pointer",textAlign:"left",color:"inherit",fontFamily:"inherit"},children:[!d&&o.jsx("span",{style:{minWidth:28,height:24,padding:"0 6px",borderRadius:6,background:u?"color-mix(in srgb, var(--color-accent) 12%, transparent)":"var(--bg-primary)",display:"inline-flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700,color:"var(--color-accent-text)",border:"1px solid var(--border-primary)",flexShrink:0},children:t}),o.jsx(We,{name:r,size:d?14:18}),o.jsxs("span",{style:{minWidth:0,display:"flex",flexDirection:"column"},children:[o.jsx("span",{style:{fontWeight:600,fontSize:x,color:"var(--text-primary)",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:n}),s&&!d&&o.jsx("span",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:s})]}),o.jsx(wu,{...Lt,size:d?12:14,style:{marginLeft:"auto",flexShrink:0,color:"var(--text-muted)",transform:i?"rotate(180deg)":"none",transition:"transform 0.15s ease"}})]}),f&&o.jsx("span",{style:{display:"inline-flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:f}),o.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:2,flexShrink:0},children:[!c&&p&&!h&&o.jsx(Kt,{label:"重命名步骤",onClick:()=>y(!0),children:o.jsx(fn,{...Lt})}),m]})]})},xp=({step:e,upstreamSteps:t,workflowInputParams:r,registry:n=Xe,onChange:s,disabled:a=!1})=>{const i=n.getAction(e.actionId),l=_r(),c=r??l.workflowInputParams,d=T.useMemo(()=>Sr([e],n)[e.taskReferenceName]||[],[e,n]),u=(l.issues[e.taskReferenceName]||[]).filter(f=>!f.field&&!d.some(m=>m.message===f.message));if(e.isProFallback||!i)return o.jsxs("div",{style:{padding:16,background:"var(--bg-highlight)",borderRadius:8,border:"1px dashed var(--border-secondary)",display:"flex",flexDirection:"column",gap:12},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{fontSize:20},children:o.jsx(Eb,{size:20,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsxs("div",{children:[o.jsxs("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:14},children:[e.name||e.taskReferenceName," (底层技术步骤)"]}),o.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)"},children:["任务类型: ",e.rawTaskDef?.type||"CUSTOM"]})]})]}),o.jsx("p",{style:{fontSize:12,color:"var(--text-secondary)",lineHeight:1.6,margin:0},children:"该步骤属于底层控制流或未映射的 Conductor 任务。在业务模式下已为您无损保留其参数与依赖关系。如需深度修改其底层 JQ 脚本或 JSON Schema,请切换至右上方「全景画布模式」。"}),o.jsx(ta,{issues:u})]});const p=(f,m)=>{const h={...e.values,[f]:m};s({...e,values:h})};return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[i.riskLevel==="sensitive"&&o.jsxs("div",{style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--color-error) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--color-error) 25%, transparent)",fontSize:12,color:"var(--color-error)",lineHeight:1.5},children:[o.jsx(Os,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),o.jsx("strong",{children:"操作安全网"}),":此步骤会直接影响真实云主机的运行状态(关机、重启、变配或下线)。建议在流程设计中,于本步骤之前放置一个「人工确认/审批」步骤,确保生产稳定性。"]}),o.jsx(ta,{issues:u}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:14},children:i.fields.map(f=>{const m=e.values[f.key]??f.defaultValue,h=`cm-field-${e.taskReferenceName}-${f.key}`,y=d.find(b=>b.field===f.key),x=y?`${h}-error`:void 0,g=f.help?`${h}-help`:void 0,v=[x,g].filter(Boolean).join(" ")||void 0,k=y?"1px solid var(--cm-status-failed)":"1px solid var(--border-secondary)";return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("label",{htmlFor:f.type==="boolean"?void 0:h,id:`${h}-label`,style:{fontSize:12,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"center",gap:4},children:[f.label,f.required&&o.jsx("span",{style:{color:"var(--cm-status-failed)"},"aria-label":"必填",children:"*"})]}),f.help&&o.jsx("span",{id:g,style:{fontSize:11,color:"var(--text-muted)"},children:f.help})]}),f.type==="select"?o.jsx(oC,{id:h,invalid:!!y,describedBy:v,value:m,options:f.options??[],allowDynamic:f.acceptsPills!==!1,disabled:a,placeholder:f.placeholder,upstreamSteps:t,workflowInputParams:c,registry:n,onChange:b=>p(f.key,b)}):f.type==="boolean"?o.jsxs("label",{style:{display:"inline-flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13,color:"var(--text-secondary)"},children:[o.jsx("input",{type:"checkbox","aria-labelledby":`${h}-label`,disabled:a,checked:!!m,onChange:b=>p(f.key,b.target.checked),style:{width:16,height:16,cursor:"pointer"}}),o.jsx("span",{children:"开启 / 启用"})]}):f.acceptsPills||m!==null&&typeof m=="object"?o.jsx(ea,{id:h,invalid:!!y,describedBy:v,disabled:a,value:m,placeholder:f.placeholder,multiline:f.type==="textarea",upstreamSteps:t,workflowInputParams:c,registry:n,onChange:b=>p(f.key,b)}):f.type==="textarea"?o.jsx("textarea",{id:h,"aria-invalid":!!y||void 0,"aria-describedby":v,disabled:a,rows:3,value:m??"",placeholder:f.placeholder,onChange:b=>p(f.key,b.target.value),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary)",border:k,color:"var(--text-primary)",fontSize:13,outline:"none",fontFamily:"inherit"}}):o.jsx("input",{id:h,"aria-invalid":!!y||void 0,"aria-describedby":v,disabled:a,type:f.type==="number"?"number":"text",value:m??"",placeholder:f.placeholder,onChange:b=>p(f.key,f.type==="number"?b.target.value===""?"":Number(b.target.value):b.target.value),style:{padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary)",border:k,color:"var(--text-primary)",fontSize:13,outline:"none",fontFamily:"inherit"}}),y&&o.jsxs("div",{id:x,style:{fontSize:11,color:"var(--cm-status-failed)",display:"flex",alignItems:"center",gap:4},children:[o.jsx(jt,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),y.message]})]},f.key)})}),i.outputs.length>0&&o.jsxs("div",{style:{marginTop:8,padding:"10px 12px",background:"var(--bg-tertiary)",borderRadius:6,border:"1px solid var(--border-primary)"},children:[o.jsxs("div",{style:{fontSize:11,fontWeight:600,color:"var(--text-muted)",marginBottom:6},children:[o.jsx(Tu,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"本步骤产生的数据(可被后续步骤引用):"]}),o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:i.outputs.map(f=>o.jsxs("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:4,background:"var(--bg-secondary)",color:"var(--text-secondary)",border:"1px solid var(--border-primary)",display:"inline-flex",alignItems:"center",gap:4},children:[o.jsx("span",{children:o.jsx(As,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsx("span",{children:f.label}),o.jsxs("span",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"monospace"},children:["(",f.key,")"]})]},f.key))})]})]})},vp=e=>typeof e=="string"&&e.includes("${"),oC=({id:e,invalid:t,describedBy:r,value:n,options:s,allowDynamic:a,disabled:i,placeholder:l,upstreamSteps:c,workflowInputParams:d,registry:u,onChange:p})=>{const[f,m]=T.useState(()=>vp(n)),[h,y]=T.useState(!1),x={flexShrink:0,background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-primary)",borderRadius:4,padding:"2px 8px",fontSize:11,cursor:i?"not-allowed":"pointer",whiteSpace:"nowrap"};if(a&&f)return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[o.jsx(ea,{id:e,invalid:t,describedBy:r,disabled:i,value:vp(n)?n:"",placeholder:l||"插入上游数据,运行时取值",upstreamSteps:c,workflowInputParams:d,registry:u,defaultShowPicker:h,onChange:p}),o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[o.jsxs("span",{style:{fontSize:11,color:"var(--text-muted)"},children:["动态取值:运行时的值需为可选项之一(",s.map(b=>b.label).join(" / "),")"]}),o.jsx("button",{type:"button",disabled:i,style:x,onClick:()=>{m(!1),y(!1),vp(n)&&p(s[0]?.value??"")},children:"改为选择"})]})]});const g=n!=null&&n!=="",v=s.some(b=>String(b.value)===String(n)),k=g?String(n):"";return o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsxs("select",{id:e,"aria-invalid":t||void 0,"aria-describedby":r,disabled:i,value:k,onChange:b=>{const S=s.find(j=>String(j.value)===b.target.value);p(S?S.value:b.target.value)},style:{flex:1,minWidth:0,padding:"7px 10px",borderRadius:6,background:"var(--bg-secondary)",border:t?"1px solid var(--cm-status-failed)":"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:13,outline:"none",cursor:"pointer"},children:[!g&&o.jsx("option",{value:"",disabled:!0,children:"请选择"}),g&&!v&&o.jsxs("option",{value:k,children:["当前值:",k]}),s.map(b=>o.jsx("option",{value:String(b.value),children:b.label},String(b.value)))]}),a&&o.jsxs("button",{type:"button",disabled:i,title:"改为引用上游步骤输出或全局入参,运行时取值",style:x,onClick:()=>{m(!0),y(!0)},children:[o.jsx(As,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"插入数据"]})]})},bp="caseValue",iC=3;function kp(e,t=iC){return`if ($.${e}['iteration'] < ${t}) { true; } else { false; }`}function lr(e){const t=`${Date.now().toString(36).slice(-4)}${Math.random().toString(36).slice(2,4)}`,r=`${e.id.replace(/\./g,"_")}_${t}`;if(e.id==="control.decision")return{id:`step_${r}`,actionId:"control_decision",taskReferenceName:r,name:"条件分支路由",values:{[bp]:""},controlType:"decision",caseParam:bp,branches:[{caseKey:"SUCCESS",caseLabel:"分支: SUCCESS",steps:[]},{caseKey:"__default__",caseLabel:"默认分支 (Default)",steps:[]}],isProFallback:!1};if(e.id==="control.fork")return{id:`step_${r}`,actionId:"control_fork",taskReferenceName:r,name:"并行并发组",values:{},controlType:"fork",forkLanes:[{laneId:"lane_0",laneLabel:"并发泳道 #1",steps:[]},{laneId:"lane_1",laneLabel:"并发泳道 #2",steps:[]}],isProFallback:!1};if(e.id==="control.loop")return{id:`step_${r}`,actionId:"control_loop",taskReferenceName:r,name:"循环迭代处理",values:{},controlType:"loop",loopCondition:kp(r),loopSteps:[],isProFallback:!1};const n={};for(const s of e.fields)s.defaultValue!==void 0&&(n[s.key]=s.defaultValue);return{id:`step_${r}`,actionId:e.id,taskReferenceName:r,name:e.name,description:e.description,values:n,isProFallback:!1,...e.kind==="workflow"&&e.workflowRef?{libraryRef:{name:e.workflowRef.name,version:e.workflowRef.version}}:{}}}function u1(e){return e!=null&&e!==""}function p1(e){let t;switch(e.type){case"select":t=`可选值 ${(e.options??[]).map(r=>String(r.value)).join("|")}`;break;case"number":t="数字";break;case"boolean":t="布尔";break;default:t="文本"}return e.required?`${t},必填`:t}function f1(e){const t=St(e.inputParameters).map(r=>r.name);return Ws(e.inputSchema,t,e.inputTemplate)}function m1(e){return bn(e.outputSchema,[],e.outputParameters).map(t=>t.key)}function h1(e,t,r={},n={}){const s=new Map(f1(e).map(h=>[h.key,h])),a=new Map(f1(t).map(h=>[h.key,h])),i=[],l=[],c=[];for(const[h,y]of a){const x=s.get(h);if(!x){i.push(y);continue}const g=p1(x),v=p1(y);g!==v&&c.push({key:h,from:g,to:v,valueFilled:u1(r[h])})}for(const[h,y]of s)a.has(h)||l.push(y);const d=m1(e),u=m1(t),p=u.filter(h=>!d.includes(h)),f=d.filter(h=>!u.includes(h)),m=new Set(n.referencedOutputs??[]);return{addedInputs:i,removedInputs:l,changedInputs:c,addedOutputs:p,removedOutputs:f,lostValueKeys:l.filter(h=>u1(r[h.key])).map(h=>h.key),brokenOutputRefs:f.filter(h=>m.has(h))}}function y1(e){return e.addedInputs.length===0&&e.removedInputs.length===0&&e.changedInputs.length===0&&e.addedOutputs.length===0&&e.removedOutputs.length===0}function wp(e,t){const r=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),n=new RegExp(`\\$\\{\\s*${r}\\.output\\.([^.\\s}\\[\\]]+)`,"g"),s=new Set,a=new Set,i=l=>{if(typeof l=="string"){n.lastIndex=0;let c;for(;(c=n.exec(l))!==null;)s.add(c[1]);return}if(!(!l||typeof l!="object"||a.has(l))){a.add(l);for(const c of Array.isArray(l)?l:Object.values(l))i(c)}};for(const l of t)i(l);return s}function na(e){return e.label&&e.label!==e.key?`${e.label}(${e.key})`:e.key}function g1(e){const t=[],r=[];for(const n of e.removedInputs)e.lostValueKeys.includes(n.key)?t.push(`入参「${na(n)}」已删除,已填写的值将丢失`):r.push(`入参「${na(n)}」已删除`);for(const n of e.removedOutputs)e.brokenOutputRefs.includes(n)?t.push(`出参「${n}」已删除,下游步骤对它的引用将失效`):r.push(`出参「${n}」已删除`);for(const n of e.changedInputs){const s=`入参「${n.key}」由「${n.from}」变为「${n.to}」`;n.valueFilled?t.push(`${s},已填写的值可能不再有效`):r.push(s)}for(const n of e.addedInputs)n.required?t.push(`新增必填入参「${na(n)}」,需要补充填写`):r.push(`新增入参「${na(n)}」`);for(const n of e.addedOutputs)r.push(`新增出参「${n}」`);return{impacts:t,changes:r}}function x1(e,t,r,n){const s=`流程库「${e}」已有新版本 v${r}(当前引用 v${t??"?"})。`;if(y1(n))return`${s}
|
|
276
|
+
入参出参未变化。确定升级吗?`;const{impacts:a,changes:i}=g1(n),l=[s,"升级差异:"];return a.length>0&&l.push("【会影响已填内容】",...a.map(c=>`· ${c}`)),i.length>0&&l.push("【其它变化】",...i.map(c=>`· ${c}`)),l.push("确定升级吗?"),l.join(`
|
|
277
|
+
`)}function Sp(e,t){const r={...e};for(const n of t.removedInputs)delete r[n.key];for(const n of t.addedInputs)n.defaultValue!==void 0&&r[n.key]===void 0&&(r[n.key]=n.defaultValue);return r}function v1(e){const{pinned:t,catalogStatus:r,latest:n,pinnedExists:s}=e;return t===void 0?{kind:"unpinned"}:r===void 0?n&&n.version>t?{kind:"upgradable",pinned:t,latest:n.version}:{kind:"pinned",pinned:t}:r!=="ready"?{kind:"pinned",pinned:t}:n?n.deprecated?{kind:"unavailable",pinned:t,reason:"deprecated"}:t>n.version?{kind:"unavailable",pinned:t,reason:"missing-version"}:t<n.version?s===!1?{kind:"unavailable",pinned:t,reason:"missing-version"}:{kind:"upgradable",pinned:t,latest:n.version}:s===!1?{kind:"unavailable",pinned:t,reason:"missing-version"}:{kind:"pinned",pinned:t}:{kind:"unavailable",pinned:t,reason:"removed"}}function b1(e,t,r){switch(r){case"deprecated":return`流程库「${e}」已下线 / 不建议新引用。本步骤仍按固定的 v${t} 编译,不会自动改变版本。`;case"removed":return`流程库中已找不到「${e}」。本步骤仍按固定的 v${t} 编译,不会自动改变版本,请确认运行环境中该版本是否仍可用。`;default:return`流程库中不存在「${e}」的 v${t}。本步骤仍按固定版本编译,不会自动改变版本,请确认运行环境中该版本是否仍可用。`}}const k1=({step:e,action:t,disabled:r,catalog:n,getReferencedOutputs:s,onUpgrade:a})=>{const{confirm:i,confirmState:l,handleConfirm:c,handleCancel:d}=xn(),u=Xs(n),[p,f]=T.useState(!1),[m,h]=T.useState(void 0),y=e.libraryRef,x=y?.version,g=y?n?.latest(y.name):void 0,v=t?.workflowRef?.version,k=!!n&&(g!==void 0||v===void 0),b=g?{version:g.version,deprecated:g.deprecated}:v!==void 0?{version:v,deprecated:!1}:void 0,S=k&&u.status==="ready"&&x!==void 0&&!!g&&g.version>x,j=y?.name;if(T.useEffect(()=>{if(!S||!n||!j||x===void 0){h(void 0);return}const I=new AbortController;return n.getVersion(j,x,I.signal).then(N=>{I.signal.aborted||h(N!==null)}).catch(()=>{I.signal.aborted||h(void 0)}),()=>I.abort()},[S,n,j,x]),!y)return null;const _=v1({pinned:x,catalogStatus:k?u.status:void 0,latest:b,pinnedExists:S?m:void 0}),w=async I=>{if(I.stopPropagation(),_.kind!=="upgradable")return;const{pinned:N,latest:C}=_;let M;if(n&&g&&g.source==="provider"){f(!0);try{const[$,B]=await Promise.all([n.getVersion(y.name,N),n.getVersion(y.name,C)]);$&&B&&(M=h1($.def,B.def,e.values,{referencedOutputs:s?.()}))}catch{M=void 0}finally{f(!1)}}const R=M?x1(y.name,N,C,M):`流程库「${y.name}」已有新版本 v${C}(当前引用 v${N})。升级后入参、出参可能发生变化,请升级后检查本步骤配置。确定升级吗?`;await i(R,`升级到 v${C}`)&&a(C,M)};return o.jsxs(o.Fragment,{children:[o.jsxs("span",{title:x!==void 0?`引用流程库「${y.name}」,已固定版本 v${x},库升级后不会自动变化`:`引用流程库「${y.name}」,未固定版本,沿用原定义`,style:{fontSize:10,padding:"1px 5px",borderRadius:4,background:"var(--color-accent-bg, color-mix(in srgb, var(--color-accent) 12%, transparent))",color:"var(--color-accent-text)",fontWeight:600},children:[o.jsx(yb,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"流程库",x!==void 0?` v${x}`:""]}),_.kind==="upgradable"&&!r&&o.jsx("button",{onClick:w,disabled:p,title:"查看升级差异并升级到库中最新版本",style:{fontSize:10,padding:"1px 6px",borderRadius:4,border:"1px solid var(--cm-status-warning)",background:"color-mix(in srgb, var(--cm-status-warning) 12%, transparent)",color:"var(--cm-status-warning)",fontWeight:600,cursor:p?"wait":"pointer"},children:p?"正在比较版本…":`有新版本 v${_.latest}`}),_.kind==="unavailable"&&o.jsxs("span",{title:b1(y.name,_.pinned,_.reason),style:{fontSize:10,padding:"1px 6px",borderRadius:4,border:"1px solid var(--cm-status-failed)",background:"color-mix(in srgb, var(--cm-status-failed) 12%, transparent)",color:"var(--cm-status-failed)",fontWeight:600},children:[o.jsx(Ye,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"版本不可用"]}),l&&o.jsx("span",{onClick:I=>I.stopPropagation(),children:o.jsx(Dt,{message:l.message,confirmLabel:l.confirmLabel,onConfirm:c,onCancel:d})})]})},lC=200,cC=({registry:e,stepNumber:t,positionLabel:r,onClose:n,onSelect:s,currentWorkflowLevel:a,libraryCatalog:i})=>{const l=Xs(i),{theme:c,themeColor:d}=te(Ae(_=>({theme:_.theme,themeColor:_.themeColor}))),[u,p]=T.useState("all"),[f,m]=T.useState(null),[h,y]=T.useState(""),x=T.useMemo(()=>nk(e.getAllActions(),{currentLevel:a}),[e,a]),g=T.useMemo(()=>sk(x),[x]),v=g.length>0,k=T.useMemo(()=>{const _=h.trim().toLowerCase();return x.filter(w=>{const I=v?Bs(w):null;let N;f!==null?N=I===f:u==="all"?N=!0:N=I===null&&w.category===u;const C=!_||w.name.toLowerCase().includes(_)||w.description.toLowerCase().includes(_);return N&&C})},[x,v,u,f,h]),b=T.useMemo(()=>k.slice(0,lC),[k]);T.useEffect(()=>{const _=w=>{w.key==="Escape"&&(w.stopPropagation(),n())};return window.addEventListener("keydown",_),()=>window.removeEventListener("keydown",_)},[n]);const S=r||`第 ${t} 步`;if(typeof document>"u")return null;const j=[{id:"all",label:"全部"},{id:"compute",label:"计算与主机"},{id:"storage",label:"存储快照"},{id:"monitor",label:"监控指标"},{id:"notify",label:"通知消息"},{id:"human",label:"人工审批"},{id:"logic",label:"流程控制"},{id:"custom",label:v?"自定义":"流程库 / 自定义"}];return bt.createPortal(o.jsx("div",{"data-mode":c,"data-brand":d,style:{position:"fixed",inset:0,background:"var(--cm-overlay)",backdropFilter:"blur(2px)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center",padding:24,fontFamily:"inherit",colorScheme:c==="light"?"light":"dark"},onClick:n,children:o.jsxs("div",{role:"dialog","aria-modal":"true","aria-label":`选择要插入的业务动作(${S})`,onClick:_=>_.stopPropagation(),style:{width:760,maxWidth:"calc(100vw - 48px)",height:"min(640px, 84vh)",background:"var(--bg-primary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRadius:12,boxShadow:"var(--cm-shadow-float)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"14px 18px",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",gap:12},children:[o.jsxs("div",{style:{fontWeight:600,fontSize:15,flex:1,whiteSpace:"nowrap"},children:["选择业务动作",o.jsx("span",{style:{marginLeft:8,fontSize:12,fontWeight:400,color:"var(--text-muted)"},children:S})]}),o.jsx("input",{type:"text",autoFocus:!0,placeholder:"搜索动作名称或描述…",value:h,onChange:_=>y(_.target.value),style:{width:240,padding:"6px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:12,outline:"none"}}),o.jsx("button",{onClick:n,"aria-label":"关闭",style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:16,padding:4,lineHeight:1},children:o.jsx($e,{size:16,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsxs("div",{style:{padding:"10px 18px",borderBottom:"1px solid var(--border-primary)",background:"var(--bg-secondary)",display:"flex",flexDirection:"column",gap:8},children:[o.jsx(w1,{label:"分类",children:j.map(_=>o.jsx(S1,{active:f===null&&u===_.id,onClick:()=>{p(_.id),m(null)},children:_.label},_.id))}),v&&o.jsx(w1,{label:"业务域",children:g.map(_=>o.jsx(S1,{active:f===_,onClick:()=>m(_),children:_},`domain:${_}`))})]}),l.status==="loading"&&o.jsx("div",{style:{padding:"6px 18px",fontSize:12,color:"var(--text-muted)",background:"var(--bg-secondary)"},children:"正在加载流程库…"}),l.status==="error"&&o.jsxs("div",{style:{padding:"6px 18px",fontSize:12,color:"var(--color-error)",background:"var(--bg-secondary)",display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{title:l.error?.message,children:"流程库加载失败,其它动作仍可使用"}),o.jsx("button",{onClick:()=>{i?.reload()},style:{background:"none",border:"1px solid currentColor",borderRadius:4,color:"inherit",cursor:"pointer",fontSize:11,padding:"1px 8px"},children:"点击重试"})]}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:16,display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(300px, 1fr))",gap:10,alignContent:"start"},children:[b.map(_=>{const w=[_.level,Bs(_)??void 0].filter(Boolean).join(" · ");return o.jsxs("button",{type:"button",onClick:()=>s(_),onMouseEnter:I=>{I.currentTarget.style.borderColor="var(--color-accent)",I.currentTarget.style.background="var(--bg-tertiary)"},onMouseLeave:I=>{I.currentTarget.style.borderColor="var(--border-primary)",I.currentTarget.style.background="var(--bg-secondary)"},style:{textAlign:"left",font:"inherit",padding:"10px 12px",borderRadius:8,background:"var(--bg-secondary)",border:"1px solid var(--border-primary)",color:"var(--text-primary)",cursor:"pointer",display:"flex",flexDirection:"column",gap:4,transition:"border-color 0.15s ease, background 0.15s ease"},children:[o.jsxs("span",{style:{display:"flex",alignItems:"center",gap:8,width:"100%"},children:[o.jsx(We,{name:_.icon,size:18}),o.jsx("span",{style:{fontWeight:600,fontSize:13,flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:_.name}),_.riskLevel==="sensitive"&&o.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"color-mix(in srgb, var(--color-warning) 16%, transparent)",color:"var(--color-warning)",fontWeight:600,flexShrink:0},children:"敏感"})]}),w&&o.jsx("span",{style:{fontSize:10,color:"var(--color-accent-text)"},children:w}),o.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)",lineHeight:1.45},children:_.description})]},_.id)}),b.length===0&&o.jsxs("div",{style:{gridColumn:"1 / -1",textAlign:"center",padding:"32px 0",fontSize:12,color:"var(--text-muted)"},children:["没有符合条件的动作",h?",换个关键词试试":""]}),k.length>b.length&&o.jsxs("div",{style:{gridColumn:"1 / -1",textAlign:"center",fontSize:12,color:"var(--text-muted)"},children:["共 ",k.length," 项,仅显示前 ",b.length," 项,请用搜索缩小范围"]})]})]})}),document.body)},w1=({label:e,children:t})=>o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:10},children:[o.jsx("span",{style:{flexShrink:0,width:40,paddingTop:4,fontSize:12,color:"var(--text-muted)"},children:e}),o.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:6,flex:1},children:t})]}),S1=({active:e,onClick:t,children:r})=>o.jsx("button",{type:"button",onClick:t,"aria-pressed":e,style:{padding:"3px 10px",borderRadius:999,fontSize:12,lineHeight:"18px",cursor:"pointer",fontWeight:e?600:400,background:e?"var(--color-accent-bg)":"transparent",color:e?"var(--color-accent-text)":"var(--text-secondary)",border:`1px solid ${e?"var(--color-accent)":"var(--border-secondary)"}`},children:r});function sa(e){return[...(e.branches||[]).flatMap(r=>r.steps),...(e.forkLanes||[]).flatMap(r=>r.steps),...e.loopSteps||[]].reduce((r,n)=>r+1+sa(n),0)}function _1(e,t){const r=e.name||t.getAction(e.actionId)?.name||e.taskReferenceName,n=sa(e),s=n>0?`,连同其中的 ${n} 个步骤`:"";return`删除步骤「${r}」${s}?删除后可按 Ctrl+Z(Mac 为 Cmd+Z)撤销。`}const _p=({step:e,upstreamSteps:t,registry:r=Xe,disabled:n=!1,onChange:s,onOpenInsertModal:a,depth:i=0})=>{const l=e.forkLanes||[],c=_r(),{confirm:d,confirmState:u,handleConfirm:p,handleCancel:f}=xn(),m=c.confirm??d,[h,y]=T.useState(l[0]?.laneId||"lane_0"),x=(S,j)=>{const _=l.map(w=>w.laneId===S?{...w,steps:j}:w);s({...e,forkLanes:_})},g=()=>{const S=l.length,j={laneId:`lane_${S}_${Date.now().toString(36).slice(-4)}`,laneLabel:`并发泳道 #${S+1}`,steps:[]},_=[...l,j];s({...e,forkLanes:_}),y(j.laneId)},v=async S=>{if(l.length<=1)return;const j=l.findIndex(C=>C.laneId===S),_=l[j],w=_?_.steps.reduce((C,M)=>C+1+sa(M),0):0,I=`删除泳道 ${j+1}${w>0?`及其中的 ${w} 个步骤`:""}?删除后可按 Ctrl+Z 撤销。`;if(!await m(I,"删除泳道"))return;const N=l.filter(C=>C.laneId!==S);s({...e,forkLanes:N}),h===S&&y(N[0]?.laneId||"")},k=S=>{const j=l.find(w=>w.laneId===S);if(!j)return;const _=l.findIndex(w=>w.laneId===S)+1;a(w=>{const I=lr(w);x(S,[...j.steps,I])},{label:`泳道 ${_} · 第 ${j.steps.length+1} 步`})},b=l.reduce((S,j)=>S+(j.steps?.length||0),0);return o.jsxs("div",{style:{borderRadius:12,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",boxShadow:"var(--cm-shadow-float)",overflow:"hidden",transition:"all 0.2s ease"},children:[o.jsxs("div",{style:{padding:"12px 16px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"color-mix(in srgb, var(--color-accent) 15%, transparent)",color:"var(--color-accent)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,fontWeight:700},children:o.jsx(At,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx(gp,{value:e.name,fallback:"并行并发组",disabled:n,onRename:S=>s({...e,name:S})}),o.jsxs("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"var(--color-accent-bg, color-mix(in srgb, var(--color-accent) 12%, transparent))",color:"var(--color-accent-text)",fontWeight:600,border:"1px solid color-mix(in srgb, var(--color-accent) 30%, transparent)"},children:[o.jsx(At,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"并行并发 (Fork / Join)"]})]}),o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:["同时并发执行 ",l.length," 条独立业务泳道 · 涵盖 ",b," 个并发步骤"]})]})]}),!n&&o.jsxs("button",{type:"button",onClick:g,style:{padding:"4px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px dashed var(--border-secondary)",color:"var(--text-primary)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4},children:[o.jsx(rr,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),o.jsx("span",{children:"新增并发泳道"})]})]}),o.jsx("div",{style:{padding:"14px 16px",background:"var(--bg-primary)",display:"grid",gridTemplateColumns:l.length>1?`repeat(${Math.min(l.length,3)}, minmax(240px, 1fr))`:"1fr",gap:12,overflowX:"auto"},children:l.map((S,j)=>o.jsxs("div",{style:{borderRadius:8,background:"var(--bg-secondary)",border:"1px solid var(--border-primary)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"8px 12px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsx("span",{style:{fontSize:13},children:o.jsx(JT,{size:13,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:S.laneLabel||`泳道 #${j+1}`}),o.jsxs("span",{style:{fontSize:10,padding:"0 5px",borderRadius:8,background:"var(--bg-secondary)",color:"var(--text-muted)"},children:[S.steps.length," 步"]})]}),!n&&l.length>1&&o.jsx(Kt,{label:`删除泳道 ${j+1}`,onClick:()=>v(S.laneId),children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsxs("div",{style:{padding:10,flex:1,display:"flex",flexDirection:"column",gap:8,minHeight:80},children:[S.steps.length===0?o.jsx("div",{style:{padding:"16px 8px",textAlign:"center",color:"var(--text-muted)",fontSize:11,border:"1px dashed var(--border-secondary)",borderRadius:6},children:"此泳道暂无步骤"}):o.jsx(Tp,{steps:S.steps,onStepsChange:_=>x(S.laneId,_),upstreamSteps:t,registry:r,disabled:n,depth:i,onOpenInsertModal:a,variant:"compact",rowTone:"primary",insertLabel:`泳道 ${j+1}`}),!n&&o.jsxs("button",{type:"button",onClick:()=>k(S.laneId),style:{padding:"4px 8px",borderRadius:4,background:"transparent",border:"1px dashed var(--border-secondary)",color:"var(--text-muted)",fontSize:11,cursor:"pointer",marginTop:2},children:[o.jsx(rr,{size:12,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:2}}),"追加并发步骤"]})]})]},S.laneId))}),o.jsxs("div",{style:{padding:"8px 16px",background:"var(--bg-tertiary)",borderTop:"1px solid var(--border-primary)",fontSize:11,color:"var(--text-secondary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsx("span",{children:o.jsx(Ou,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsxs("span",{children:[o.jsx("strong",{children:"汇聚同步点 (Join)"}),":所有 ",l.length," 条泳道执行完毕后再继续向下;后续步骤可通过「插入数据」引用汇聚结果或泳道内步骤的输出。"]})]}),o.jsx("code",{style:{fontSize:10,color:"var(--text-muted)",background:"var(--bg-secondary)",padding:"1px 6px",borderRadius:4},children:fp(e)})]}),u&&o.jsx(Dt,{message:u.message,confirmLabel:u.confirmLabel,onConfirm:p,onCancel:f})]})},jp=({step:e,upstreamSteps:t,registry:r=Xe,disabled:n=!1,onChange:s,onOpenInsertModal:a,depth:i=0})=>{const l=e.loopSteps||[],c=_r(),d=`cm-loop-${e.taskReferenceName}-condition`,u=T.useMemo(()=>{const m=Sr([{...e,loopSteps:[]}],r)[e.taskReferenceName]||[],h=l.length>0?m.filter(x=>!x.message.startsWith("循环体内没有步骤")):m,y=(c.issues[e.taskReferenceName]||[]).filter(x=>!h.some(g=>g.message===x.message));return[...h,...y]},[e,l.length,r,c.issues]),p=m=>{s({...e,loopSteps:m})},f=()=>{a(m=>{const h=lr(m);p([...l,h])},{label:`循环体 · 第 ${l.length+1} 步`})};return o.jsxs("div",{style:{borderRadius:12,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",boxShadow:"var(--cm-shadow-float)",overflow:"hidden",transition:"all 0.2s ease"},children:[o.jsx("div",{style:{padding:"12px 16px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"var(--color-accent-bg, color-mix(in srgb, var(--color-accent) 15%, transparent))",color:"var(--color-accent)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:16,fontWeight:700},children:o.jsx(Lr,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx(gp,{value:e.name,fallback:"循环迭代处理",disabled:n,onRename:m=>s({...e,name:m})}),o.jsxs("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"var(--color-accent-bg, color-mix(in srgb, var(--color-accent) 12%, transparent))",color:"var(--color-accent-text)",fontWeight:600,border:"1px solid color-mix(in srgb, var(--color-accent) 30%, transparent)"},children:[o.jsx(Lr,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),"循环迭代 (Do-While Loop)"]})]}),o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:["循环体包含 ",l.length," 个步骤 · 每次迭代执行完将重新评估跳出条件"]})]})]})}),o.jsxs("div",{style:{padding:"10px 16px",background:"var(--bg-primary)",borderBottom:"1px solid var(--border-primary)",display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[o.jsx("label",{htmlFor:d,style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:"循环继续条件"}),o.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:"JavaScript,每轮结束后计算,为 true 继续下一轮,为 false 结束循环"}),!n&&o.jsx("button",{type:"button",onClick:()=>s({...e,loopCondition:kp(e.taskReferenceName)}),style:{marginLeft:"auto",padding:"2px 8px",borderRadius:4,background:"transparent",border:"1px solid var(--border-primary)",color:"var(--text-secondary)",fontSize:11,cursor:"pointer"},children:"改为最多执行 3 轮"})]}),o.jsx("div",{children:o.jsx("input",{id:d,type:"text",disabled:n,value:e.loopCondition??"",placeholder:kp(e.taskReferenceName),onChange:m=>s({...e,loopCondition:m.target.value}),style:{width:"100%",boxSizing:"border-box",padding:"4px 8px",borderRadius:4,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:11,fontFamily:"var(--cm-font-mono, monospace)"}})}),o.jsx(ta,{issues:u})]}),o.jsx("div",{style:{padding:"14px 16px",background:"var(--bg-primary)"},children:o.jsxs("div",{style:{borderRadius:8,border:"2px dashed color-mix(in srgb, var(--color-accent) 45%, var(--border-secondary))",background:"var(--bg-secondary)",padding:12},children:[o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginBottom:10,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[o.jsx("span",{children:o.jsx(Ps,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsxs("span",{children:[o.jsx("strong",{children:"循环体内部任务序列"})," (每轮迭代将依次执行以下 ",l.length," 个步骤):"]})]}),!n&&o.jsxs("button",{type:"button",onClick:f,style:{padding:"3px 8px",borderRadius:4,background:"var(--color-accent-bg, color-mix(in srgb, var(--color-accent) 10%, transparent))",border:"1px solid color-mix(in srgb, var(--color-accent) 40%, transparent)",color:"var(--color-accent-text)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,fontWeight:500},children:[o.jsx(rr,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),o.jsx("span",{children:"追加循环步骤"})]})]}),l.length===0?o.jsx("div",{style:{padding:"20px 12px",textAlign:"center",color:"var(--text-muted)",fontSize:11},children:"循环体内暂无步骤,点击「追加循环步骤」添加需要重复执行的动作"}):o.jsx(Tp,{steps:l,onStepsChange:p,upstreamSteps:t,registry:r,disabled:n,depth:i,onOpenInsertModal:a,rowTone:"primary",indexPrefix:"轮内 ",accentIndexBadge:!0,insertLabel:"循环体"})]})}),o.jsxs("div",{style:{padding:"8px 16px",background:"var(--bg-tertiary)",borderTop:"1px solid var(--border-primary)",fontSize:11,color:"var(--text-secondary)",display:"flex",alignItems:"center",gap:6},children:[o.jsx(mb,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),o.jsx("span",{children:"循环至少执行一轮;条件为 false 时结束并继续向下。请确保条件最终会变为 false,例如用已执行轮次限定最大轮数。"})]})]})},j1={decision:"var(--cm-ai)",fork:"var(--color-accent)",loop:"var(--cm-status-success)"},dC=({step:e,index:t,count:r=1,depth:n=1,upstreamSteps:s,registry:a=Xe,disabled:i=!1,onChange:l,onDelete:c,onMove:d,onOpenInsertModal:u})=>{const p=_r(),f=j1[e.controlType||"decision"]||j1.decision,m=e.controlType==="fork"?"嵌套并行":e.controlType==="loop"?"嵌套循环":"嵌套分支",h={step:e,upstreamSteps:s,registry:a,disabled:i,onChange:l,onOpenInsertModal:u};return o.jsxs("div",{id:ir(e.taskReferenceName),style:{borderLeft:`3px solid ${f}`,paddingLeft:10,marginLeft:Math.min(n-1,3)*2,display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:6},children:[o.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:6},children:[o.jsxs("span",{style:{fontSize:11,fontWeight:700,color:`color-mix(in srgb, ${f} 80%, var(--text-primary))`},children:["#",t+1," ",m,"(第 ",n," 层)"]}),o.jsx(Dn,{issues:Zs(e,p.issues)})]}),!i&&o.jsx("span",{style:{display:"inline-flex",alignItems:"center"},children:d?o.jsx(ra,{index:t,count:r,onMove:d,onDelete:c}):o.jsx(Kt,{label:"删除此嵌套控制流及其内部所有步骤",danger:!0,onClick:c,children:o.jsx($s,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})})]}),e.controlType==="fork"?o.jsx(_p,{...h,depth:n}):e.controlType==="loop"?o.jsx(jp,{...h,depth:n}):o.jsx(Np,{...h,depth:n})]})},Tp=({steps:e,onStepsChange:t,upstreamSteps:r,registry:n=Xe,disabled:s=!1,depth:a,onOpenInsertModal:i,variant:l="regular",rowTone:c="primary",indexPrefix:d="",accentIndexBadge:u=!1,insertLabel:p})=>{const f=_r(),[m,h]=T.useState(null),y=l==="compact",x=c==="secondary"?"var(--bg-secondary)":"var(--bg-primary)",g=c==="secondary"?"var(--bg-primary)":"var(--bg-secondary)",v=f.focusRequest;T.useEffect(()=>{if(!v)return;const _=e.find(w=>w.taskReferenceName===v.ref&&!w.controlType);_&&(h(_.id),requestAnimationFrame(()=>document.getElementById(ir(_.taskReferenceName))?.scrollIntoView({behavior:"smooth",block:"center"})))},[v?.nonce]);const k=(_,w)=>{const I=[...e];I[_]=w,t(I)},b=async _=>{const w=e[_];(!f.confirm||await f.confirm(_1(w,n),"删除"))&&(m===w.id&&h(null),t(e.filter((N,C)=>C!==_)))},S=(_,w)=>{if(w<0||w>=e.length)return;const I=[...e],[N]=I.splice(_,1);I.splice(w,0,N),t(I)},j=_=>i(w=>{const I=lr(w),N=[...e];N.splice(_,0,I),t(N),I.controlType||h(I.id)},{label:`${p?`${p} · `:""}第 ${_+1} 步`});return o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:e.map((_,w)=>{const I=[...r,...e.slice(0,w)],N=!s&&w>0&&o.jsx(yp,{compact:!0,onClick:()=>j(w),label:"在此插入"});if(_.controlType)return o.jsxs(T.Fragment,{children:[N,o.jsx(dC,{step:_,index:w,count:e.length,depth:a+1,upstreamSteps:I,registry:n,disabled:s,onChange:F=>k(w,F),onDelete:()=>b(w),onMove:F=>S(w,F),onOpenInsertModal:i})]},_.id);const C=n.getAction(_.actionId),M=m===_.id,R=()=>h(M?null:_.id),O=`${ir(_.taskReferenceName)}-body`,$=C?.name||_.taskReferenceName,B=_.name||$,q=!!C&&B!==C.name;return o.jsxs(T.Fragment,{children:[N,o.jsxs("div",{id:ir(_.taskReferenceName),style:{borderRadius:y?6:8,background:x,border:M?"1px solid var(--color-accent)":"1px solid var(--border-primary)",overflow:"hidden",transition:y?void 0:"all 0.15s ease"},children:[o.jsx(d1,{bodyId:O,indexLabel:`${d}#${w+1}`,icon:C?.icon,title:B,subtitle:q?C?.name:_.taskReferenceName,defaultTitle:$,expanded:M,onToggle:R,disabled:s,compact:y,accentIndex:u,onRename:_.isProFallback?void 0:F=>k(w,{..._,name:F}),badges:o.jsxs(o.Fragment,{children:[C?.riskLevel==="sensitive"&&o.jsx(l1,{}),o.jsx(k1,{step:_,action:C,disabled:s,catalog:f.libraryCatalog,getReferencedOutputs:()=>wp(_.taskReferenceName,f.allSteps),onUpgrade:(F,A)=>k(w,{..._,libraryRef:{name:_.libraryRef.name,version:F},...A?{values:Sp(_.values,A)}:{}})}),o.jsx(Dn,{issues:Zs(_,f.issues)}),o.jsx(hp,{status:f.runStatus?.[_.taskReferenceName]})]}),actions:!s&&o.jsx(ra,{index:w,count:e.length,onMove:F=>S(w,F),onDelete:()=>b(w)})}),M&&o.jsx("div",{id:O,style:{padding:y?10:"12px 14px",borderTop:"1px solid var(--border-primary)",background:g},children:o.jsx(xp,{step:_,upstreamSteps:I,registry:n,disabled:s,onChange:F=>k(w,F)})})]})]},_.id)})})},Gt="__default__",T1=e=>e===Gt?"默认分支":`分支 ${e}`,Ip={padding:"4px 8px",borderRadius:4,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:12,fontFamily:"var(--cm-font-mono, monospace)",outline:"none"},Np=({step:e,upstreamSteps:t,registry:r=Xe,disabled:n=!1,onChange:s,onOpenInsertModal:a,depth:i=0})=>{const l=_r(),c=e.branches||[],[d,u]=T.useState(c[0]?.caseKey||Gt),[p,f]=T.useState(""),[m,h]=T.useState(!1),[y,x]=T.useState(""),g=xn(),v=l.confirm??g.confirm,k=c.find(W=>W.caseKey===d)||c[0],b=e.rawTaskDef?.type==="SWITCH",S=e.caseExpression!==void 0,j=e.caseParam??"",_=`cm-decision-${e.taskReferenceName}`,w=T.useMemo(()=>{const W=Sr([{...e,branches:c.map(D=>({...D,steps:[]}))}],r)[e.taskReferenceName]||[],P=(l.issues[e.taskReferenceName]||[]).filter(D=>!W.some(Z=>Z.message===D.message));return[...W,...P]},[e,c,r,l.issues]),I=w.find(W=>W.field&&W.field===j),N=l.focusRequest;T.useEffect(()=>{if(!N)return;const W=c.find(P=>$n(P.steps,N.ref));W&&u(W.caseKey)},[N?.nonce]);const C=(W,P)=>{s({...e,branches:c.map(D=>D.caseKey===W?{...D,steps:P}:D)})},M=()=>{const W=p.trim();if(!W){x("请填写分支标识,例如 VIP");return}if(W===Gt||c.some(Z=>Z.caseKey===W)){x(`分支「${W}」已存在,请换一个标识`);return}const P=c.filter(Z=>Z.caseKey!==Gt),D=c.filter(Z=>Z.caseKey===Gt);s({...e,branches:[...P,{caseKey:W,caseLabel:`分支: ${W}`,steps:[]},...D]}),u(W),f(""),x(""),h(!1)},R=()=>{h(!1),f(""),x("")},O=async W=>{const P=W.steps.reduce((L,H)=>L+1+sa(H),0),D=`删除分支「${W.caseKey}」${P>0?`及其中的 ${P} 个步骤`:""}?删除后可按 Ctrl+Z 撤销。`;if(!await v(D,"删除分支"))return;const Z=c.filter(L=>L.caseKey!==W.caseKey);s({...e,branches:Z}),d===W.caseKey&&u(Z[0]?.caseKey||Gt)},$=()=>{if(!k)return;const W=k;a(P=>C(W.caseKey,[...W.steps,lr(P)]),{label:`${T1(W.caseKey)} · 第 ${W.steps.length+1} 步`})},B=W=>{if(W==="expression"&&!S)s({...e,caseExpression:""});else if(W==="param"&&S){const P=e.caseParam||bp;s({...e,caseExpression:void 0,caseParam:P,values:{[P]:"",...e.values}})}},q=W=>{const P={...e.values},D=j?P[j]:void 0;j&&delete P[j],W&&(P[W]=D??""),s({...e,caseParam:W,values:P})},F=c.reduce((W,P)=>W+(P.steps?.length||0),0),A=(W,P)=>{const D=W==="expression"===S;return o.jsx("button",{type:"button","aria-pressed":D,disabled:n,onClick:()=>B(W),style:{padding:"3px 10px",borderRadius:4,border:"none",background:D?"var(--color-accent)":"transparent",color:D?"var(--color-on-accent)":"var(--text-secondary)",fontSize:11,fontWeight:600,cursor:n?"default":"pointer"},children:P})};return o.jsxs("div",{style:{borderRadius:12,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",boxShadow:"var(--cm-shadow-float)",overflow:"hidden",transition:"all 0.2s ease"},children:[o.jsxs("div",{style:{padding:"12px 16px",background:"var(--bg-tertiary)",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",gap:10},children:[o.jsx("div",{style:{width:32,height:32,borderRadius:8,background:"color-mix(in srgb, var(--cm-ai) 15%, transparent)",color:"color-mix(in srgb, var(--cm-ai) 85%, var(--text-primary))",display:"flex",alignItems:"center",justifyContent:"center",flexShrink:0},children:o.jsx(Mr,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsxs("div",{style:{minWidth:0,flex:1},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[o.jsx(gp,{value:e.name,fallback:"条件分支路由",disabled:n,onRename:W=>s({...e,name:W})}),o.jsx("span",{style:{fontSize:10,padding:"1px 6px",borderRadius:4,background:"color-mix(in srgb, var(--cm-ai) 12%, transparent)",color:"color-mix(in srgb, var(--cm-ai) 85%, var(--text-primary))",fontWeight:600,border:"1px solid color-mix(in srgb, var(--cm-ai) 30%, transparent)",fontFamily:"var(--cm-font-mono, monospace)"},children:b?"SWITCH":"DECISION"})]}),o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:["共 ",c.length," 个分支(含默认分支),分支内共 ",F," 个步骤"]})]})]}),o.jsxs("div",{style:{padding:"10px 16px",background:"var(--bg-primary)",borderBottom:"1px solid var(--border-primary)",display:"flex",flexDirection:"column",gap:8},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[o.jsx("span",{style:{fontSize:12,fontWeight:600,color:"var(--text-primary)"},children:"判断依据"}),o.jsxs("span",{role:"group","aria-label":"判断方式",style:{display:"inline-flex",background:"var(--bg-highlight)",borderRadius:6,padding:2,border:"1px solid var(--border-secondary)"},children:[A("param","按数据取值"),A("expression","按表达式")]})]}),S?o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[o.jsx("label",{htmlFor:`${_}-expr`,style:{fontSize:11,color:"var(--text-muted)"},children:"判断表达式(JavaScript,结果与各分支标识比较,相同则执行该分支)"}),o.jsx("textarea",{id:`${_}-expr`,disabled:n,rows:2,value:e.caseExpression??"",placeholder:b?'例如 $.amount > 100 ? "big" : "small"':'例如 $.env == "prod" ? "prod" : "test"',onChange:W=>s({...e,caseExpression:W.target.value}),style:{...Ip,resize:"vertical",width:"100%",boxSizing:"border-box"}})]}):o.jsxs("div",{style:{display:"flex",gap:10,alignItems:"flex-start",flexWrap:"wrap"},children:[o.jsxs("div",{style:{flex:1,minWidth:220,display:"flex",flexDirection:"column",gap:4},children:[o.jsx("label",{htmlFor:`${_}-value`,style:{fontSize:11,color:"var(--text-muted)"},children:"判断取值(运行时与各分支标识比较,都不相同时执行默认分支)"}),o.jsx(ea,{id:`${_}-value`,disabled:n||!j,invalid:!!I,value:j?e.values?.[j]??"":"",placeholder:"插入要判断的数据,例如上游步骤的状态或全局入参",upstreamSteps:t,registry:r,onChange:W=>s({...e,values:{...e.values,[j]:W}})})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:4},children:[o.jsx("label",{htmlFor:`${_}-param`,style:{fontSize:11,color:"var(--text-muted)"},children:"参数名"}),o.jsx("input",{id:`${_}-param`,type:"text",disabled:n,value:j,placeholder:"如 userType",onChange:W=>q(W.target.value.trim()),style:{...Ip,width:120}})]})]}),o.jsx(ta,{issues:w})]}),o.jsxs("div",{style:{padding:"8px 16px",background:"var(--bg-primary)",borderBottom:"1px solid var(--border-primary)",display:"flex",gap:6,flexWrap:"wrap",alignItems:"center"},children:[o.jsx("span",{style:{fontSize:11,color:"var(--text-muted)",marginRight:4},children:"分支列表:"}),c.map(W=>{const P=W.caseKey===d,D=W.caseKey===Gt;return o.jsxs("span",{style:{borderRadius:6,background:P?"var(--color-accent-bg, color-mix(in srgb, var(--color-accent) 15%, transparent))":"var(--bg-secondary)",border:`1px solid ${P?"var(--color-accent)":"var(--border-primary)"}`,display:"inline-flex",alignItems:"center"},children:[o.jsxs("button",{type:"button","aria-pressed":P,onClick:()=>u(W.caseKey),style:{padding:"4px 10px",background:"none",border:"none",cursor:"pointer",fontSize:12,fontWeight:P?600:400,color:P?"var(--color-accent-text)":"var(--text-secondary)",display:"inline-flex",alignItems:"center",gap:6,fontFamily:"inherit"},children:[D?o.jsx(xT,{size:14,strokeWidth:1.75,"aria-hidden":"true"}):o.jsx(br,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),o.jsx("span",{children:D?"默认分支":W.caseKey}),o.jsx("span",{style:{fontSize:10,padding:"0 4px",borderRadius:8,background:P?"var(--color-accent)":"var(--bg-tertiary)",color:P?"var(--color-on-accent)":"var(--text-muted)"},"aria-label":`${W.steps?.length||0} 个步骤`,children:W.steps?.length||0})]}),!n&&!D&&o.jsx(Kt,{label:`删除分支 ${W.caseKey}`,onClick:()=>O(W),children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]},W.caseKey)}),!n&&!m&&o.jsxs("button",{type:"button",onClick:()=>h(!0),style:{padding:"4px 8px",borderRadius:6,background:"transparent",border:"1px dashed var(--border-secondary)",color:"var(--text-muted)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4},children:[o.jsx(rr,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"新增分支"]}),!n&&m&&o.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:4,flexWrap:"wrap"},children:[o.jsx("input",{autoFocus:!0,type:"text","aria-label":"分支标识",value:p,placeholder:"分支标识,如 VIP",onChange:W=>{f(W.target.value),y&&x("")},onKeyDown:W=>{W.key==="Enter"&&M(),W.key==="Escape"&&R()},style:{...Ip,border:"1px solid var(--color-accent)",width:120}}),o.jsx("button",{type:"button",onClick:M,style:{padding:"3px 8px",borderRadius:4,background:"var(--color-accent)",color:"var(--color-on-accent)",border:"none",fontSize:11,cursor:"pointer"},children:"添加分支"}),o.jsx("button",{type:"button",onClick:R,style:{padding:"3px 6px",background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:11},children:"取消"}),y&&o.jsx("span",{role:"alert",style:{fontSize:11,color:"var(--cm-status-failed)"},children:y})]})]}),o.jsx("div",{style:{padding:"14px 16px",background:"var(--bg-primary)"},children:k?o.jsxs("div",{children:[o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginBottom:10,display:"flex",alignItems:"center",justifyContent:"space-between",gap:8},children:[o.jsxs("span",{children:[o.jsx(lb,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),k.caseKey===Gt?o.jsx(o.Fragment,{children:"判断取值与所有分支标识都不相同时,依次执行以下步骤:"}):o.jsxs(o.Fragment,{children:["判断结果为 ",o.jsx("strong",{children:k.caseKey})," 时,依次执行以下步骤:"]})]}),!n&&o.jsxs("button",{type:"button",onClick:$,style:{padding:"3px 8px",borderRadius:4,background:"var(--color-accent-bg, color-mix(in srgb, var(--color-accent) 12%, transparent))",border:"1px solid var(--color-accent)",color:"var(--color-accent-text)",fontSize:11,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4,fontWeight:500,flexShrink:0},children:[o.jsx(rr,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),o.jsx("span",{children:"追加分支步骤"})]})]}),k.steps.length===0?o.jsx("div",{style:{padding:"24px 16px",borderRadius:8,border:"1px dashed var(--border-secondary)",textAlign:"center",color:"var(--text-muted)",fontSize:12,background:"var(--bg-secondary)"},children:k.caseKey===Gt?"默认分支暂无步骤:未命中任何分支时直接跳过,继续执行后续步骤":"当前分支暂无步骤,点击「追加分支步骤」配置"}):o.jsx(Tp,{steps:k.steps,onStepsChange:W=>C(k.caseKey,W),upstreamSteps:t,registry:r,disabled:n,depth:i,onOpenInsertModal:a,rowTone:"secondary",insertLabel:T1(k.caseKey)})]}):o.jsx("div",{style:{textAlign:"center",color:"var(--text-muted)",fontSize:12},children:"请选择或新增一个分支进行配置"})}),o.jsxs("div",{style:{padding:"6px 14px",background:"var(--bg-tertiary)",borderTop:"1px solid var(--border-primary)",fontSize:10,color:"var(--text-muted)",display:"flex",alignItems:"center",gap:4},children:[o.jsx(Os,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),o.jsx("span",{children:"运行时只执行命中的一个分支,其余分支的步骤会被跳过。"})]}),g.confirmState&&o.jsx(Dt,{message:g.confirmState.message,confirmLabel:g.confirmState.confirmLabel,onConfirm:g.handleConfirm,onCancel:g.handleCancel})]})};function Cp(e,t,r){const n=(e||"").toLowerCase();return t===401||t===403||n.includes("401")||n.includes("403")||n.includes("unauthorized")||n.includes("forbidden")||n.includes("token expired")||n.includes("invalid api key")||n.includes("signature does not match")?{type:"auth",title:"云平台账号授权已失效或权限受限",explanation:`在调用【${r||"云服务"}】时未通过安全身份核验。通常是因为配置的账号密钥 (AccessKey/Token) 已过期失效,或该账号缺乏对应资源的操作授权。`,suggestion:"建议检查账号授权状态,重新填入有效密钥或联系企业管理员为该账号分配权限。",actionLabel:"重新授权密钥",actionKey:"reauth"}:t===504||n.includes("timeout")||n.includes("timed out")||n.includes("etimedout")||n.includes("deadline")||n.includes("connection refused")?{type:"timeout",title:"目标云主机响应超时",explanation:`向【${r||"主机"}】发送指令后,在约定的时间内未收到回应。可能是云主机刚开机系统服务尚未就绪,或所在子网的安全组策略拦截了通信端口。`,suggestion:"云服务正在进行底层引导,通常稍等片刻自动重试即可恢复。",actionLabel:"稍后自动重试",actionKey:"retry"}:n.includes("exit code")||n.includes("command failed")||n.includes("command not found")||n.includes("syntax error")?{type:"script_fail",title:"主机内部脚本执行异常退出",explanation:"下发到云主机内部的 Shell/Python 脚本在运行过程中遇到错误并提前中断。通常是因为目标环境中缺少前置依赖库,或指定的文件路径不存在。",suggestion:"可展开下方查看脚本的标准输出日志排查具体报错,修正脚本后重新执行。",actionLabel:"查看脚本输出日志",actionKey:"inspect_upstream"}:n.includes("nullpointer")||n.includes("cannot read property")||n.includes("undefined")||n.includes("field not found")||n.includes("parameter not found")||n.includes("missing required parameter")?{type:"missing_data",title:"缺少必要的上游输入数据",explanation:"本步骤引用的上游步骤没有返回预期的数据内容(例如没有获取到有效的「主机实例ID」或「内网IP」),导致后续步骤无法继续执行。",suggestion:"请点击检查上游步骤的输出结果,确认上游任务是否正常产生了所需的数据胶囊。",actionLabel:"查看上游步骤数据",actionKey:"inspect_upstream"}:n.includes("quota")||n.includes("limit exceeded")||n.includes("insufficient")||n.includes("out of stock")||n.includes("balance")?{type:"quota",title:"可用区资源库存不足或配额受限",explanation:"当前所选可用区该型号的云主机规格暂时售罄,或云平台租户的配额上限已满。",suggestion:"建议在流程中更换目标规格(如选择通用型或计算型同等配置),或申请提升账号配额。",actionLabel:"更换规格/可用区",actionKey:"change_spec"}:n.includes("network")||n.includes("dns")||n.includes("unreachable")||n.includes("failed to fetch")?{type:"network",title:"网络通信中断或无法解析",explanation:"调度服务与目标云服务之间的网络连接不稳定,或专有网络 VPC 路由未打通。",suggestion:"请检查网络连通性配置,或联系网络运维人员协助排查。",actionLabel:"重新尝试连接",actionKey:"retry"}:{type:"unknown",title:"步骤执行未达预期",explanation:e||"执行过程中底层服务报告了非成功状态,请查阅详细日志。",suggestion:"可点击重试此步骤,或将此诊断报告反馈给技术支持排查。",actionLabel:"重试此任务",actionKey:"retry"}}const I1=({rawError:e,statusCode:t,taskName:r,onActionClick:n})=>{const[s,a]=T.useState(!1),i=Cp(e,t,r);return o.jsxs("div",{style:{borderRadius:10,background:"color-mix(in srgb, var(--cm-status-failed) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--cm-status-failed) 30%, transparent)",padding:"14px 16px",display:"flex",flexDirection:"column",gap:10,fontFamily:"inherit"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{display:"inline-flex",color:"var(--status-failed)"},children:T.createElement(i.type==="auth"?hb:i.type==="timeout"?zu:i.type==="missing_data"?Ye:i.type==="quota"?vT:_u,{size:18,strokeWidth:1.75,"aria-hidden":!0})}),o.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--status-failed)"},children:i.title})]}),i.actionLabel&&n&&o.jsxs("button",{onClick:()=>n(i.actionKey),style:{padding:"4px 10px",borderRadius:6,background:"color-mix(in srgb, var(--status-failed) 15%, transparent)",border:"1px solid color-mix(in srgb, var(--status-failed) 30%, transparent)",color:"var(--status-failed)",fontSize:11,fontWeight:600,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:4},children:[o.jsx("span",{children:o.jsx(At,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsx("span",{children:i.actionLabel})]})]}),o.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",lineHeight:1.6},children:i.explanation}),o.jsxs("div",{style:{padding:"8px 12px",borderRadius:6,background:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",fontSize:11,color:"var(--color-warning)",lineHeight:1.5},children:[o.jsx(Os,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginRight:4}}),o.jsx("strong",{children:"建议做法"}),":",i.suggestion]}),e&&o.jsxs("div",{style:{marginTop:2},children:[o.jsx("button",{onClick:()=>a(!s),style:{background:"none",border:"none",color:"var(--text-muted)",fontSize:10,cursor:"pointer",padding:0,display:"inline-flex",alignItems:"center",gap:4},children:o.jsx("span",{children:s?"▾ 折叠底层技术报错":"▸ 展开底层技术报错 (供研发/技术支持排查)"})}),s&&o.jsx("div",{style:{marginTop:6,padding:"8px 10px",borderRadius:4,background:"var(--cm-surface-0)",color:"var(--text-muted)",fontFamily:"monospace",fontSize:10,lineHeight:1.4,maxHeight:120,overflowY:"auto",whiteSpace:"pre-wrap",wordBreak:"break-all"},children:e})]})]})},Yt=e=>e!=null&&e!=="",Ve=e=>typeof e=="object"?JSON.stringify(e):String(e);function uC(e){switch(e){case"COMPLETED":return null;case"COMPLETED_WITH_ERRORS":return"已完成,但有部分错误,请查看数据。";case"FAILED":case"FAILED_WITH_TERMINAL_ERROR":return"运行在此步骤中断,原因见下方诊断。";case"TIMED_OUT":return"此步骤已超时,原因见下方诊断。";case"IN_PROGRESS":return"正在执行。";case"SCHEDULED":return"等待执行。";case"SKIPPED":return"已跳过此步骤。";case"CANCELED":return"此步骤已取消。";default:return`状态:${He(e).label}。`}}function pC(e,t){const r=e.inputData?.joinOn;if(!Array.isArray(r)||r.length===0)return"并行分支已汇合。";const n=d=>{const u=t.filter(p=>p.referenceTaskName===d);return u[u.length-1]},a=r.map(d=>n(d)?.status).filter(d=>!!d),i=a.filter(d=>He(d).isFailure).length,l=a.filter(d=>d==="COMPLETED").length;let c="";return a.length===r.length&&l===r.length?c=",全部成功":i>0?c=`,其中 ${i} 个失败`:a.length<r.length&&(c=`,${r.length-a.length} 个没有运行记录`),`${r.length} 个并行分支已汇合${c}。`}function fC(e,t={}){const r=uC(e.status);if(r)return r;const n=e.outputData??{},{actionId:s}=t,a=t.actionName||e.taskDefName||e.referenceTaskName,i=(l,c)=>l+c.filter(([d])=>Yt(d)).map(([d,u])=>u(d)).join("")+"。";switch(s){case"ecs.create_instance":return i("已创建云主机",[[n.instanceId,l=>`,实例 ID ${Ve(l)}`],[n.privateIp,l=>`,内网 IP ${Ve(l)}`]]);case"ecs.query_instance":return i("已查询主机状态",[[n.status,l=>`:${Ve(l)}`],[n.publicIp,l=>`,公网 IP ${Ve(l)}`]]);case"ecs.run_command":{const l=n.exitCode;return i("远程命令已执行",[[n.commandId,c=>`,命令批次 ${Ve(c)}`],[l,c=>Number(c)===0?",退出码 0":`,退出码 ${Ve(c)}(非 0,请查看输出)`]])}case"ecs.create_snapshot":return i("已创建快照",[[n.snapshotId,l=>`,快照 ID ${Ve(l)}`]]);case"ecs.stop_instance":return i("已关闭云主机",[[n.status,l=>`,当前状态 ${Ve(l)}`]]);case"ecs.start_instance":return i("已启动云主机",[[n.status,l=>`,当前状态 ${Ve(l)}`]]);case"ecs.modify_spec":return Yt(n.oldSpec)&&Yt(n.newSpec)?`已变更规格(${Ve(n.oldSpec)} → ${Ve(n.newSpec)})。`:i("已变更规格",[[n.newSpec,l=>`为 ${Ve(l)}`]]);case"ecs.get_monitor_metrics":{const c=[[n.cpuUsagePercent,d=>`CPU 利用率 ${Ve(d)}%`],[n.memoryUsagePercent,d=>`内存利用率 ${Ve(d)}%`]].filter(([d])=>Yt(d)).map(([d,u])=>u(d));return c.length?`采集到负载:${c.join(",")}。`:"已采集监控指标。"}case"notify.send_message":return i("已发送通知",[[n.status,l=>`,状态 ${Ve(l)}`]])}if(s==="control.wait"||e.taskType==="WAIT")return"等待结束。";if(s==="human.approval"||e.taskType==="HUMAN"){const l=Yt(n.reviewer)?`${Ve(n.reviewer)} `:"";return n.approved===!1?`${l}已驳回${Yt(n.comment)?`:${Ve(n.comment)}`:""}。`:n.approved===!0?`${l}已批准${Yt(n.comment)?`:${Ve(n.comment)}`:""}。`:`${l?`${l}已处理`:"人工步骤已完成"}。`}if(e.taskType==="DECISION"||e.taskType==="SWITCH"){const l=Array.isArray(n.evaluationResult)?n.evaluationResult[0]:void 0,c=n.selectedCase??l??n.caseOutput??n.case;return Yt(c)?`条件判断命中分支 ${Ve(c)}。`:"已完成条件判断。"}if(e.taskType==="FORK_JOIN"||e.taskType==="FORK_JOIN_DYNAMIC"||e.taskType==="FORK"){const l=e.inputData?.forkedTasks,c=Array.isArray(l)?l.length:void 0;return c?`已启动 ${c} 个并行分支。`:"已启动并行分支。"}if(e.taskType==="JOIN")return pC(e,t.allTasks??[]);if(e.taskType==="DO_WHILE"){const l=e.iteration??n.iteration;return Yt(l)?`循环结束,共执行 ${Ve(l)} 轮。`:"循环已结束。"}return`${a} 已完成。`}function mC(e){const t=He(e.status),r={COMPLETED:"全部步骤已完成",FAILED:"运行失败",TIMED_OUT:"运行已超时",TERMINATED:"运行已终止",RUNNING:"正在运行",PAUSED:"运行已暂停"},n=e.startTime,s=e.endTime;return{title:r[t.status]??`运行状态:${t.label}`,tone:t.tone,durationSec:n&&s&&s>=n?((s-n)/1e3).toFixed(1):void 0}}const N1=({instance:e,registry:t=Xe,onInspectStep:r,onErrorAction:n})=>{const[s,a]=T.useState({}),i=f=>{a(m=>({...m,[f]:!m[f]}))},l=e.tasks||[],c=mC(e),d=He(e.status),u=d.color,p=(f,m,h)=>{if(h){if(h==="inspect_upstream"){const y=l.slice(0,m).reverse().find(x=>x.referenceTaskName);return!r||!y?void 0:()=>r(y.referenceTaskName)}if(n)return()=>n(h,f.referenceTaskName)}};return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16,padding:"16px 20px",background:"var(--bg-primary)",height:"100%",overflowY:"auto",fontFamily:"inherit"},children:[o.jsxs("div",{style:{padding:"12px 18px",borderRadius:10,background:`color-mix(in srgb, ${u} 10%, transparent)`,border:`1px solid color-mix(in srgb, ${u} 30%, transparent)`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[T.createElement(d.icon,{size:22,strokeWidth:1.75,"aria-hidden":!0,style:{color:u}}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:700,fontSize:14,color:u},children:c.title}),o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:["执行 ID: ",o.jsx("span",{style:{fontFamily:"var(--cm-font-mono)"},children:e.workflowId})," · 共 ",l.length," 个步骤",c.durationSec!==void 0&&` · 总耗时约 ${c.durationSec} 秒`]})]})]}),o.jsx("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:4,fontWeight:600,background:`color-mix(in srgb, ${u} 15%, transparent)`,color:u},title:e.status,children:d.label})]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:12},children:l.map((f,m)=>{const h=f.workflowTask?.inputParameters?._actionId,y=h?t.getAction(h):void 0,x=y?.icon||(f.taskType==="DECISION"||f.taskType==="SWITCH"?"shuffle":f.taskType==="FORK_JOIN"||f.taskType==="FORK_JOIN_DYNAMIC"?"zap":f.taskType==="JOIN"?"merge":f.taskType==="DO_WHILE"?"repeat":f.taskType==="WAIT"?"hourglass":f.taskType==="HUMAN"?"user":"settings"),g=He(f.status),v=g.isFailure,k=!!s[f.referenceTaskName],b=y?.name||f.taskDefName||f.referenceTaskName,S=fC(f,{actionId:h,actionName:y?.name,allTasks:l}),j=f.reasonForIncompletion||(v?`步骤状态为 ${f.status},没有返回失败原因`:void 0),_=v?Cp(j,void 0,b).actionKey:void 0,w=p(f,m,_),I=f.startTime?new Date(f.startTime).toLocaleTimeString():"--:--:--",N=f.endTime&&f.startTime?`${((f.endTime-f.startTime)/1e3).toFixed(2)}s`:"";return o.jsxs("div",{style:{borderRadius:10,background:"var(--bg-secondary)",border:v?"1px solid var(--status-failed)":"1px solid var(--border-primary)",boxShadow:v?"0 4px 16px color-mix(in srgb, var(--cm-status-failed) 12%, transparent)":"none",padding:"12px 16px",display:"flex",flexDirection:"column",gap:8},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[g.status==="COMPLETED"?o.jsx(We,{name:x,size:18}):T.createElement(g.icon,{size:18,strokeWidth:1.75,"aria-hidden":!0,style:{color:g.color}}),o.jsxs("div",{children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsxs("span",{style:{fontWeight:600,fontSize:13,color:"var(--text-primary)"},children:["步骤 #",m+1,": ",b]}),o.jsxs("span",{style:{fontSize:10,padding:"1px 5px",borderRadius:3,background:`color-mix(in srgb, ${g.color} 15%, transparent)`,color:g.color,fontWeight:600,display:"inline-flex",alignItems:"center",gap:3},title:f.status,children:[T.createElement(g.icon,{size:10,strokeWidth:1.75,"aria-hidden":!0}),g.label]})]}),o.jsxs("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:[I," ",N&&`· 耗时 ${N}`]})]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[r&&o.jsx("button",{onClick:()=>r(f.referenceTaskName),style:{padding:"2px 8px",borderRadius:4,background:"transparent",border:"1px solid var(--border-secondary)",color:"var(--text-secondary)",fontSize:11,cursor:"pointer"},children:"定位步骤"}),o.jsx("button",{onClick:()=>i(f.referenceTaskName),style:{background:"none",border:"none",color:"var(--text-muted)",fontSize:11,cursor:"pointer"},children:k?"收起数据 ▴":"查看数据 ▾"})]})]}),o.jsx("div",{style:{fontSize:12,color:v?"var(--status-failed)":"var(--text-secondary)",lineHeight:1.5,padding:"4px 0"},children:S}),v&&o.jsx("div",{style:{marginTop:4},children:o.jsx(I1,{rawError:j,taskName:b,onActionClick:w})}),k&&f.outputData&&o.jsx("div",{style:{marginTop:8,padding:"10px 12px",borderRadius:8,background:"var(--bg-tertiary)",border:"1px solid var(--border-primary)",display:"flex",flexWrap:"wrap",gap:8},children:Object.entries(f.outputData).map(([C,M])=>typeof M=="object"&&M!==null?null:o.jsxs("span",{style:{fontSize:11,padding:"3px 8px",borderRadius:6,background:"var(--color-accent-bg, color-mix(in srgb, var(--color-accent) 12%, transparent))",border:"1px solid color-mix(in srgb, var(--color-accent) 30%, transparent)",display:"inline-flex",alignItems:"center",gap:6,fontFamily:"monospace"},children:[o.jsxs("span",{style:{color:"var(--text-muted)"},children:[C,":"]}),o.jsx("span",{style:{color:"var(--color-accent-text)",fontWeight:600},children:String(M)})]},C))})]},f.taskId||f.referenceTaskName||m)})})]})},hC=100,yC=e=>{const t=e;return!!t&&(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.tagName==="SELECT"||t.isContentEditable)},C1={decision:{text:"控制流分支",color:"color-mix(in srgb, var(--cm-ai) 75%, var(--text-primary))"},fork:{text:"并发泳道组",color:"var(--color-accent-text)"},loop:{text:"循环迭代体",color:"var(--color-accent-text)"}},E1=({workflowDef:e,onChange:t,registry:r=Xe,readOnly:n=!1,workflowExecution:s,libraryCatalog:a,currentWorkflowLevel:i,onAskAi:l,onStepAdded:c,onSandboxRun:d,onSave:u,onUndo:p,onRedo:f,validationResults:m})=>{const h=T.useMemo(()=>s1(e,r),[e,r]),[y,x]=T.useState(null),[g,v]=T.useState(null),[k,b]=T.useState(null),{confirm:S,confirmState:j,handleConfirm:_,handleCancel:w}=xn(),[I,N]=T.useState(!1),[C,M]=T.useState(null),[R,O]=T.useState(s||null),[$,B]=T.useState(s?"story":"steps");T.useEffect(()=>{s&&(O(s),B("story"))},[s]);const q=h.steps,F=T.useMemo(()=>{const V=Sr(q,r);return eC(V,m??(e?Et(e):null))},[q,r,m,e]),A=T.useMemo(()=>{if(!C)return;const V={};for(const[X,z]of Object.entries(C))V[X]=z.status;return V},[C]),W=T.useRef({past:[],future:[]}),P=V=>{if(e){const X=W.current;X.past.push(e),X.past.length>hC&&X.past.shift(),X.future=[]}t(V)},D=T.useCallback(()=>{if(p)return p();const V=W.current,X=V.past.pop();X&&(e&&V.future.push(e),t(X))},[p,t,e]),Z=T.useCallback(()=>{if(f)return f();const V=W.current,X=V.future.pop();X&&(e&&V.past.push(e),t(X))},[f,t,e]);T.useEffect(()=>{const V=X=>{if(!(X.metaKey||X.ctrlKey))return;const ve=X.key.toLowerCase();if(ve==="s"){if(!u||!e)return;X.preventDefault(),u(e);return}n||yC(X.target)||g||j||(ve==="z"&&!X.shiftKey?(X.preventDefault(),D()):(ve==="z"&&X.shiftKey||ve==="y")&&(X.preventDefault(),Z()))};return window.addEventListener("keydown",V),()=>window.removeEventListener("keydown",V)},[u,e,n,D,Z,g,j]);const L=V=>{P(r1({...h,steps:V},r))},H=(V,X)=>{const z=[...q];z[V]=X,L(z)},U=async V=>{if(n)return;const X=q[V];X&&await S(_1(X,r),"删除")&&(y===X.id&&x(null),L(q.filter((z,ve)=>ve!==V)))},K=(V,X)=>{if(n||X<0||X>=q.length)return;const z=[...q],[ve]=z.splice(V,1);z.splice(X,0,ve),L(z)},se=(V,X)=>{v({index:0,label:X?.label,callback:V})},pe=V=>{if(!g)return;c?.({source:V.kind==="workflow"?"library":"builtin"});const{callback:X,index:z}=g;if(v(null),X){X(V);return}const ve=lr(V),he=[...q];he.splice(z,0,ve),x(ve.id),L(he)},we=V=>{B("steps");const X=q.find(z=>z.taskReferenceName===V);if(X)X.controlType||x(X.id);else if(!q.some(z=>$n([z],V)))return;b(z=>({ref:V,nonce:(z?.nonce??0)+1})),requestAnimationFrame(()=>document.getElementById(ir(V))?.scrollIntoView({behavior:"smooth",block:"center"}))},Ce=async()=>{if(e){N(!0);try{const V={},X=he=>{for(const _e of he){const Se=r.getAction(_e.actionId);Se&&Se.mockOutput&&(V[_e.taskReferenceName]=Se.mockOutput(_e.values));for(const be of _e.branches||[])X(be.steps);for(const be of _e.forkLanes||[])X(be.steps);X(_e.loopSteps||[])}};X(q);const z=await cn(e,{taskMocks:V});O(z),B("story");const ve={};for(const he of z.tasks)ve[he.referenceTaskName]={status:he.status,output:he.outputData};M(ve),d?.(String(z.status))}catch(V){console.error("[StepFlowEditor] Dry run error:",V),d?.("error")}finally{N(!1)}}},ne={workflowInputParams:h.inputParameters,issues:F,runStatus:A,confirm:S,libraryCatalog:a,allSteps:q,focusRequest:k},Te=Object.values(F).flat().filter(V=>V.level==="error").length,le=V=>!n&&o.jsx(yp,{onClick:()=>v({index:V}),label:"插入业务动作"});return o.jsx(o1.Provider,{value:ne,children:o.jsxs("div",{style:{display:"flex",flexDirection:"column",height:"100%",width:"100%",background:"var(--bg-primary)",overflowY:"auto",fontFamily:"inherit"},children:[o.jsxs("div",{style:{padding:"12px 20px",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bg-secondary)",flexShrink:0,gap:10,flexWrap:"wrap"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{fontSize:18},children:o.jsx(We,{name:"clipboard",size:16})}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary)"},children:h.name||"云平台业务流程"}),o.jsxs("div",{style:{fontSize:12,color:"var(--text-muted)",display:"flex",alignItems:"center",gap:8},children:[o.jsxs("span",{children:["共 ",q.length," 个业务执行步骤 · 普通用户零代码模式"]}),Te>0&&o.jsx(Dn,{issues:Object.values(F).flat()})]})]})]}),R&&o.jsxs("div",{role:"group","aria-label":"视图",style:{display:"inline-flex",background:"var(--bg-highlight)",borderRadius:6,padding:2,border:"1px solid var(--border-secondary)"},children:[o.jsxs("button",{type:"button","aria-pressed":$==="steps",onClick:()=>B("steps"),style:{padding:"4px 10px",borderRadius:4,border:"none",background:$==="steps"?"var(--color-accent)":"transparent",color:$==="steps"?"var(--color-on-accent)":"var(--text-secondary)",fontSize:11,fontWeight:600,cursor:"pointer"},children:[o.jsx(We,{name:"clipboard",size:14,style:{verticalAlign:-2,marginRight:4}}),"步骤配置"]}),o.jsxs("button",{type:"button","aria-pressed":$==="story",onClick:()=>B("story"),style:{padding:"4px 10px",borderRadius:4,border:"none",background:$==="story"?"var(--color-accent)":"transparent",color:$==="story"?"var(--color-on-accent)":"var(--text-secondary)",fontSize:11,fontWeight:600,cursor:"pointer"},children:[o.jsx(We,{name:"book",size:14,style:{verticalAlign:-2,marginRight:4}}),"运行故事线 (",R.tasks.length," 步)"]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[C&&o.jsx("button",{type:"button",onClick:()=>M(null),style:{padding:"5px 10px",borderRadius:6,background:"transparent",border:"1px solid var(--border-secondary)",color:"var(--text-muted)",fontSize:12,cursor:"pointer"},children:"清除试跑结果"}),o.jsx("button",{type:"button",onClick:()=>{Ce()},disabled:I||q.length===0,title:Te>0?`还有 ${Te} 项待修正,试跑结果可能与真实运行不同`:void 0,style:{padding:"6px 14px",borderRadius:6,background:"color-mix(in srgb, var(--color-success) 20%, transparent)",border:"1px solid color-mix(in srgb, var(--color-success) 45%, transparent)",color:"var(--color-success)",fontSize:12,fontWeight:600,cursor:I||q.length===0?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:6,transition:"all 0.15s ease"},children:o.jsx("span",{children:I?"模拟中...":"浏览器本地试跑 (零风险)"})})]})]}),$==="story"&&R?o.jsx("div",{style:{flex:1,overflowY:"auto"},children:o.jsx(N1,{instance:R,registry:r,onInspectStep:we})}):o.jsxs("div",{style:{flex:1,maxWidth:820,width:"100%",margin:"0 auto",padding:"24px 20px",display:"flex",flexDirection:"column",gap:16,boxSizing:"border-box"},children:[q.length===0&&o.jsxs("div",{style:{textAlign:"center",padding:"60px 20px",background:"var(--bg-secondary)",borderRadius:12,border:"1px dashed var(--border-secondary)",display:"flex",flexDirection:"column",alignItems:"center",gap:14},children:[o.jsx("span",{style:{display:"inline-flex",color:"var(--color-accent)"},children:o.jsx(We,{name:"zap",size:36})}),o.jsx("div",{style:{fontWeight:600,fontSize:16,color:"var(--text-primary)"},children:"尚未添加任何业务动作"}),o.jsx("p",{style:{fontSize:13,color:"var(--text-secondary)",maxWidth:420,margin:0},children:"无需编写代码或配置复杂的 JSON,点击下方按钮选择第一个云主机业务动作,即可开始自动化编排。"}),o.jsxs("button",{type:"button",disabled:n,onClick:()=>v({index:0}),style:{marginTop:8,padding:"8px 18px",borderRadius:8,background:"var(--color-accent)",color:"var(--color-on-accent)",border:"none",fontWeight:600,fontSize:13,cursor:n?"not-allowed":"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[o.jsx("span",{children:"+"}),o.jsx("span",{children:"添加第一个业务动作"})]})]}),q.length>0&&!n&&o.jsx(yp,{onClick:()=>v({index:0}),label:"在最前插入步骤"}),q.map((V,X)=>{const z=r.getAction(V.actionId),ve=y===V.id,he=q.slice(0,X),_e=Zs(V,F);if(V.controlType){const De=C1[V.controlType]??C1.decision,Je={step:V,upstreamSteps:he,registry:r,disabled:n,onChange:ee=>H(X,ee),onOpenInsertModal:se};return o.jsxs(T.Fragment,{children:[o.jsxs("div",{id:ir(V.taskReferenceName),style:{display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 4px",gap:8},children:[o.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:8},children:[o.jsxs("span",{style:{fontSize:12,fontWeight:700,color:De.color},children:["#",X+1," ",De.text]}),o.jsx(Dn,{issues:_e}),o.jsx(hp,{status:A?.[V.taskReferenceName]})]}),!n&&o.jsx("span",{style:{display:"inline-flex",alignItems:"center"},children:o.jsx(ra,{index:X,count:q.length,onMove:ee=>K(X,ee),onDelete:()=>U(X)})})]}),V.controlType==="fork"?o.jsx(_p,{...Je}):V.controlType==="loop"?o.jsx(jp,{...Je}):o.jsx(Np,{...Je})]}),le(X+1)]},V.id)}const Se=`${ir(V.taskReferenceName)}-body`,be=z?.name||V.taskReferenceName,ce=V.name||be,Re=!!z&&ce!==z.name;return o.jsxs(T.Fragment,{children:[o.jsxs("div",{id:ir(V.taskReferenceName),style:{background:"var(--bg-secondary)",borderRadius:10,border:ve?"1px solid var(--color-accent)":"1px solid var(--border-primary)",boxShadow:ve?"0 8px 24px color-mix(in srgb, var(--color-accent) 15%, transparent)":"var(--cm-shadow-card)",overflow:"hidden",transition:"all 0.2s ease"},children:[o.jsx(d1,{bodyId:Se,indexLabel:`#${X+1}`,icon:z?.icon,title:ce,subtitle:Re?z?.name:z?.description||V.description||V.taskReferenceName,defaultTitle:be,expanded:ve,onToggle:()=>x(ve?null:V.id),disabled:n,onRename:V.isProFallback?void 0:De=>H(X,{...V,name:De}),badges:o.jsxs(o.Fragment,{children:[z?.riskLevel==="sensitive"&&o.jsx(l1,{}),o.jsx(k1,{step:V,action:z,disabled:n,catalog:a,getReferencedOutputs:()=>wp(V.taskReferenceName,q.filter(De=>De.id!==V.id)),onUpgrade:(De,Je)=>H(X,{...V,libraryRef:{name:V.libraryRef.name,version:De},...Je?{values:Sp(V.values,Je)}:{}})}),o.jsx(Dn,{issues:_e}),o.jsx(hp,{status:A?.[V.taskReferenceName]})]}),actions:o.jsxs(o.Fragment,{children:[l&&o.jsx(Kt,{label:"让 AI 介绍这个步骤的作用与配置建议",onClick:()=>l(V),children:o.jsx(Pt,{size:16,strokeWidth:1.75,"aria-hidden":"true"})}),!n&&o.jsx(ra,{index:X,count:q.length,onMove:De=>K(X,De),onDelete:()=>U(X)})]})}),ve&&o.jsx("div",{id:Se,style:{padding:"14px 16px",borderTop:"1px solid var(--border-primary)",background:"var(--bg-primary)"},children:o.jsx(xp,{step:V,upstreamSteps:he,workflowInputParams:h.inputParameters,registry:r,disabled:n,onChange:De=>H(X,De)})})]}),le(X+1)]},V.id)})]}),g&&o.jsx(cC,{registry:r,stepNumber:g.index+1,positionLabel:g.label,onClose:()=>v(null),onSelect:pe,currentWorkflowLevel:i,libraryCatalog:a}),j&&o.jsx(Dt,{message:j.message,confirmLabel:j.confirmLabel,onConfirm:_,onCancel:w})]})})};function gC(e,t,r){if(!e||!t)return;const n=t.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let s=e;for(let i=0;i<n.length-1;i++){const l=n[i];if(s[l]===void 0||s[l]===null){const c=n[i+1];s[l]=/^\d+$/.test(c)?[]:{}}s=s[l]}const a=n[n.length-1];s[a]=r}function Ep(e,t){const r=structuredClone(e.definition);for(const n of e.variables){const s=t[n.key]??n.defaultValue;if(s!==void 0)for(const a of n.bindings)gC(r,a,s)}return r}const R1=({template:e,onApply:t,onClose:r,onSandboxRun:n})=>{const{theme:s,themeColor:a}=te(Ae(g=>({theme:g.theme,themeColor:g.themeColor}))),[i,l]=T.useState(1),[c,d]=T.useState(()=>{const g={};for(const v of e.variables)v.defaultValue!==void 0&&(g[v.key]=v.defaultValue);return g}),[u,p]=T.useState(!1),[f,m]=T.useState(null),h=(g,v)=>{d(k=>({...k,[g]:v}))},y=async()=>{p(!0);try{const g=Ep(e,c),v=e.mockDataset.scenarios[0],k=await cn(g,{workflowInput:v?.workflowInput||{},taskMocks:v?.taskOutputs||{}});n?.(String(k.status)),k.status==="COMPLETED"?m(`全部 ${k.tasks.length} 个步骤在浏览器本地顺利模拟通过,各上游数据与通知已正确串联。`):m(`沙箱试运行结束,状态:${ZT(k.status)}`)}catch(g){n?.("error"),m(`模拟试跑出错: ${g.message}`)}finally{p(!1)}},x=()=>{const g=Ep(e,c);t(g),r()};return typeof document>"u"?null:bt.createPortal(o.jsx("div",{"data-mode":s,"data-brand":a,style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"var(--cm-overlay)",backdropFilter:"blur(5px)",zIndex:1300,display:"flex",alignItems:"center",justifyContent:"center",padding:20,fontFamily:"inherit"},onClick:r,children:o.jsxs("div",{onClick:g=>g.stopPropagation(),style:{width:680,maxHeight:"85vh",background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",borderRadius:14,boxShadow:"var(--cm-shadow-float)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"14px 20px",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bg-primary)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx(We,{name:e.icon,size:20}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,fontSize:15,color:"var(--text-primary)"},children:e.title}),o.jsx("div",{style:{fontSize:11,color:"var(--text-muted)"},children:"3 步填空式模板快速启用向导"})]})]}),o.jsx("button",{onClick:r,"aria-label":"关闭",style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:16},children:o.jsx($e,{size:16,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsx("div",{style:{padding:"10px 20px",background:"var(--cm-surface-0)",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"center",gap:24},children:[{step:1,label:"1. 了解方案"},{step:2,label:"2. 参数填空"},{step:3,label:"3. 试跑验证与激活"}].map(g=>{const v=i===g.step,k=i>g.step;return o.jsxs("div",{onClick:()=>k&&l(g.step),style:{display:"flex",alignItems:"center",gap:6,cursor:k?"pointer":"default",opacity:v||k?1:.5},children:[o.jsx("div",{style:{width:22,height:22,borderRadius:11,background:k?"var(--color-success)":v?"var(--color-accent)":"var(--bg-tertiary)",color:k?"var(--cm-on-danger)":v?"var(--color-on-accent)":"var(--text-muted)",display:"flex",alignItems:"center",justifyContent:"center",fontSize:11,fontWeight:700},children:k?o.jsx(We,{name:"approval",size:12}):g.step}),o.jsx("span",{style:{fontSize:12,fontWeight:v?600:400,color:v?"var(--text-primary)":"var(--text-secondary)"},children:g.label})]},g.step)})}),o.jsxs("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px"},children:[i===1&&o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:`repeat(${e.roi.popularityCount!==void 0?3:2}, 1fr)`,gap:12},children:[o.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"color-mix(in srgb, var(--cm-status-success) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--cm-status-success) 25%, transparent)"},children:[o.jsxs("div",{style:{fontSize:11,color:"var(--cm-status-success)"},children:[o.jsx(We,{name:"zap",size:14,style:{verticalAlign:-2,marginRight:4}}),"预期单次节省人工"]}),o.jsxs("div",{style:{fontSize:20,fontWeight:700,color:"var(--cm-status-success)",marginTop:4},children:["约 ",e.roi.minutesSavedPerRun," 分钟"]})]}),o.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"color-mix(in srgb, var(--color-accent) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--color-accent) 25%, transparent)"},children:[o.jsxs("div",{style:{fontSize:11,color:"var(--color-accent)"},children:[o.jsx(We,{name:"refresh",size:14,style:{verticalAlign:-2,marginRight:4}}),"典型每周频次"]}),o.jsxs("div",{style:{fontSize:20,fontWeight:700,color:"var(--color-accent)",marginTop:4},children:["约 ",e.roi.typicalRunsPerWeek," 次 / 周"]})]}),e.roi.popularityCount!==void 0&&o.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"color-mix(in srgb, var(--cm-status-warning) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--cm-status-warning) 25%, transparent)"},children:[o.jsxs("div",{style:{fontSize:11,color:"var(--cm-status-warning)"},children:[o.jsx(We,{name:"flame",size:14,style:{verticalAlign:-2,marginRight:4}}),"累计被采用"]}),o.jsxs("div",{style:{fontSize:20,fontWeight:700,color:"var(--cm-status-warning)",marginTop:4},children:[e.roi.popularityCount," 次"]})]})]}),o.jsxs("div",{style:{padding:"12px 16px",borderRadius:8,background:"var(--bg-primary)",border:"1px solid var(--border-primary)",lineHeight:1.6},children:[o.jsxs("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:13,marginBottom:4},children:[o.jsx(We,{name:"lightbulb",size:14,style:{verticalAlign:-2,marginRight:4}}),"解决的痛点"]}),o.jsx("div",{style:{fontSize:13,color:"var(--text-secondary)"},children:e.valueProposition}),o.jsx("p",{style:{fontSize:12,color:"var(--text-muted)",margin:"8px 0 0 0"},children:e.description})]}),o.jsxs("div",{children:[o.jsxs("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",marginBottom:8},children:["包含的标准步骤流程 (",e.definition.tasks?.length??0," 个步骤):"]}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.definition.tasks?.map((g,v)=>o.jsxs("div",{style:{padding:"8px 12px",borderRadius:6,background:"var(--bg-highlight)",border:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between",fontSize:12},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[o.jsxs("span",{style:{color:"var(--color-accent)",fontWeight:600},children:["#",v+1]}),o.jsx("span",{style:{color:"var(--text-primary)"},children:g.description||g.name})]}),o.jsx("span",{style:{fontSize:10,color:"var(--text-muted)",fontFamily:"monospace"},children:g.taskReferenceName})]},g.taskReferenceName))})]})]}),i===2&&o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[o.jsxs("div",{style:{padding:"8px 12px",borderRadius:6,background:"color-mix(in srgb, var(--color-accent) 8%, transparent)",border:"1px solid color-mix(in srgb, var(--color-accent) 25%, transparent)",fontSize:12,color:"var(--color-accent)"},children:[o.jsx(We,{name:"pencil",size:14,style:{verticalAlign:-2,marginRight:4}}),o.jsx("strong",{children:"开箱即用填空"}),":无需修改复杂的流程连线与 JSON,仅需确认以下几个业务变量即可:"]}),e.variables.map(g=>{const v=c[g.key]??g.defaultValue;return o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:6},children:[o.jsxs("label",{style:{fontSize:13,fontWeight:600,color:"var(--text-primary)",display:"flex",alignItems:"center",gap:4},children:[g.label,g.required&&o.jsx("span",{style:{color:"var(--cm-status-failed)"},children:"*"})]}),g.type==="select"?o.jsx("select",{value:v??"",onChange:k=>h(g.key,k.target.value),style:{padding:"8px 10px",borderRadius:6,background:"var(--bg-primary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:13,outline:"none"},children:g.options?.map(k=>o.jsx("option",{value:k.value,children:k.label},k.value))}):g.type==="boolean"?o.jsxs("label",{style:{display:"flex",alignItems:"center",gap:8,cursor:"pointer",fontSize:13,color:"var(--text-secondary)"},children:[o.jsx("input",{type:"checkbox",checked:!!v,onChange:k=>h(g.key,k.target.checked),style:{width:16,height:16}}),o.jsx("span",{children:"开启启用"})]}):o.jsx("input",{type:g.type==="number"?"number":"text",value:v??"",placeholder:g.placeholder,onChange:k=>h(g.key,g.type==="number"?Number(k.target.value):k.target.value),style:{padding:"8px 10px",borderRadius:6,background:"var(--bg-primary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:13,outline:"none"}}),g.help&&o.jsx("div",{style:{fontSize:11,color:"var(--text-muted)"},children:g.help})]},g.key)})]}),i===3&&o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:16},children:[o.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"var(--bg-primary)",border:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:600,color:"var(--text-primary)",fontSize:13},children:"零风险浏览器沙盒试跑"}),o.jsx("div",{style:{fontSize:11,color:"var(--text-muted)",marginTop:2},children:"使用内置的保真云主机 Mock 数据,无需真实生产权限即可预览完整数据流转"})]}),o.jsx("button",{onClick:()=>{y()},disabled:u,style:{padding:"6px 14px",borderRadius:6,background:"var(--color-accent)",color:"var(--color-on-accent)",border:"none",fontWeight:600,fontSize:12,cursor:u?"not-allowed":"pointer"},children:u?"模拟试跑中...":"立即试跑验证"})]}),f&&o.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"color-mix(in srgb, var(--cm-status-success) 10%, transparent)",border:"1px solid color-mix(in srgb, var(--cm-status-success) 30%, transparent)",color:"var(--cm-status-success)",fontSize:12,lineHeight:1.5},children:[o.jsx(We,{name:"sparkles",size:14,style:{verticalAlign:-2,marginRight:4}}),o.jsx("strong",{children:"试跑通过"}),": ",f]}),o.jsxs("div",{style:{padding:"12px 14px",borderRadius:8,background:"var(--bg-highlight)",border:"1px solid var(--border-primary)"},children:[o.jsx("div",{style:{fontSize:12,fontWeight:600,color:"var(--text-muted)",marginBottom:8},children:"已配置的业务变量参数清单:"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:6},children:e.variables.map(g=>o.jsxs("div",{style:{display:"flex",justifyContent:"space-between",fontSize:12,padding:"4px 0",borderBottom:"1px dashed var(--cm-border-subtle)"},children:[o.jsxs("span",{style:{color:"var(--text-secondary)"},children:[g.label,":"]}),o.jsx("span",{style:{color:"var(--color-accent)",fontWeight:600},children:String(c[g.key]??g.defaultValue)})]},g.key))})]})]})]}),o.jsxs("div",{style:{padding:"12px 20px",borderTop:"1px solid var(--border-primary)",background:"var(--bg-primary)",display:"flex",alignItems:"center",justifyContent:"space-between"},children:[i>1?o.jsx("button",{onClick:()=>l(g=>g-1),style:{padding:"6px 14px",borderRadius:6,background:"transparent",border:"1px solid var(--border-secondary)",color:"var(--text-secondary)",fontSize:12,cursor:"pointer"},children:"← 上一步"}):o.jsx("div",{}),o.jsx("div",{style:{display:"flex",gap:10},children:i<3?o.jsx("button",{onClick:()=>l(g=>g+1),style:{padding:"6px 16px",borderRadius:6,background:"var(--color-accent)",color:"var(--color-on-accent)",border:"none",fontSize:12,fontWeight:600,cursor:"pointer"},children:"下一步 →"}):o.jsxs("button",{onClick:x,style:{padding:"6px 18px",borderRadius:6,background:"var(--color-success)",color:"var(--cm-on-danger)",border:"none",fontSize:12,fontWeight:600,cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},children:[o.jsx("span",{children:o.jsx(We,{name:"zap",size:16})}),o.jsx("span",{children:"注入参数并进入流程编辑器"})]})})]})]})}),document.body)},xC=new Set(["FAILED","FAILED_WITH_TERMINAL_ERROR","TIMED_OUT","TERMINATED"]);function vC(e,t){const r=He(t.status).label,n=t.tasks?.length??0;if(t.status==="COMPLETED")return{status:"COMPLETED",text:`《${e}》本地试跑${r}:共执行 ${n} 个任务。点击「使用此模板」填空后开始编辑。`};const s=(t.tasks??[]).find(l=>xC.has(String(l.status))),a=s?.reasonForIncompletion||t.reasonForIncompletion,i=s?`任务「${s.referenceTaskName}」${He(s.status).label}`:`流程${r}`;return{status:String(t.status),text:`《${e}》本地试跑${r}:${i}${a?`,原因:${a}`:""}。可以在「使用此模板」的向导里调整参数后再试。`}}function bC(e,t){const r=t instanceof Error?t.message:String(t);return{status:"FAILED",text:`《${e}》试跑出错:${r}。检查模板定义后重试。`}}const kC=()=>()=>{},wC=()=>0,O1=({isOpen:e,onClose:t,onSelectTemplate:r,templateStore:n=op,onSandboxRun:s})=>{const{theme:a,themeColor:i}=te(Ae(S=>({theme:S.theme,themeColor:S.themeColor}))),[l,c]=T.useState("all"),[d,u]=T.useState(""),[p,f]=T.useState(null),[m,h]=T.useState(null),y=n.subscribe??kC,x=n.getVersion??wC,g=T.useSyncExternalStore(y,x,x),v=T.useMemo(()=>n.search(d,l),[n,d,l,g]),k=T.useMemo(()=>n.search("","all").length,[n,g]);if(!e||typeof document>"u")return null;const b=async S=>{try{const j=S.mockDataset.scenarios[0],_=await cn(S.definition,{workflowInput:j?.workflowInput||{},taskMocks:j?.taskOutputs||{}});s?.(String(_.status)),h(vC(S.title,_))}catch(j){s?.("error"),h(bC(S.title,j))}};return bt.createPortal(o.jsxs("div",{"data-mode":a,"data-brand":i,style:{position:"fixed",top:0,left:0,right:0,bottom:0,background:"var(--cm-overlay)",backdropFilter:"blur(5px)",zIndex:1250,display:"flex",alignItems:"center",justifyContent:"center",padding:24,fontFamily:"inherit"},onClick:t,children:[o.jsxs("div",{onClick:S=>S.stopPropagation(),style:{width:980,maxWidth:"92vw",height:"84vh",background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",borderRadius:16,boxShadow:"var(--cm-shadow-float)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"16px 24px",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between",background:"var(--bg-primary)"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:12},children:[o.jsx("span",{style:{display:"inline-flex"},children:o.jsx(We,{name:"folder",size:22})}),o.jsxs("div",{children:[o.jsx("div",{style:{fontWeight:700,fontSize:16,color:"var(--text-primary)"},children:"场景化工作流模板中心"}),o.jsx("div",{style:{fontSize:12,color:"var(--text-muted)"},children:"源于真实云平台高价值运维实战萃取 · 拒绝空白画布 · 开箱即用"})]})]}),o.jsx("button",{onClick:t,"aria-label":"关闭",style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:18,padding:"4px"},children:o.jsx($e,{size:16,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsxs("div",{style:{padding:"10px 24px",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",justifyContent:"space-between",gap:16,background:"var(--cm-surface-0)"},children:[o.jsx("div",{style:{display:"flex",gap:8,flexWrap:"wrap"},children:[{id:"all",label:`全部场景 (${k})`},{id:"compute",label:"交付与计算"},{id:"security",label:"安全与容灾"},{id:"ops",label:"运维与自愈"},{id:"cost",label:"节能与降本"}].map(S=>o.jsx("button",{onClick:()=>c(S.id),style:{padding:"5px 12px",borderRadius:6,background:l===S.id?"var(--color-accent)":"transparent",color:l===S.id?"var(--color-on-accent)":"var(--text-secondary)",border:"none",fontSize:12,cursor:"pointer",fontWeight:l===S.id?600:400,transition:"all 0.15s ease"},children:S.label},S.id))}),o.jsx("input",{type:"text",placeholder:"搜索模板名称、痛点或场景...",value:d,onChange:S=>u(S.target.value),style:{width:220,padding:"6px 12px",borderRadius:6,background:"var(--bg-primary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:12,outline:"none"}})]}),m&&(()=>{const S=He(m.status),j=S.icon;return o.jsxs("div",{role:"status","data-testid":"template-quick-run-notice",style:{margin:"12px 24px 0 24px",padding:"10px 14px",borderRadius:8,background:`color-mix(in srgb, ${S.color} 12%, transparent)`,border:`1px solid color-mix(in srgb, ${S.color} 35%, transparent)`,color:S.color,fontSize:12,display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[o.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:6},children:[o.jsx(j,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{flexShrink:0,marginTop:2}}),o.jsx("span",{children:m.text})]}),o.jsx("button",{onClick:()=>h(null),style:{background:"none",border:"none",color:S.color,cursor:"pointer",fontSize:12,flexShrink:0},children:"关闭"})]})})(),o.jsx("div",{style:{flex:1,overflowY:"auto",padding:"20px 24px",display:"grid",gridTemplateColumns:"repeat(2, 1fr)",gap:16},children:v.map(S=>o.jsxs("div",{style:{borderRadius:12,background:"var(--bg-primary)",border:"1px solid var(--border-primary)",padding:"16px 18px",display:"flex",flexDirection:"column",justifyContent:"space-between",gap:12,transition:"all 0.2s ease"},onMouseEnter:j=>{j.currentTarget.style.borderColor="var(--color-accent)",j.currentTarget.style.transform="translateY(-2px)",j.currentTarget.style.boxShadow="var(--cm-shadow-float)"},onMouseLeave:j=>{j.currentTarget.style.borderColor="var(--border-primary)",j.currentTarget.style.transform="translateY(0)",j.currentTarget.style.boxShadow="none"},children:[o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10},children:[o.jsx(We,{name:S.icon,size:24}),o.jsx("span",{style:{fontWeight:600,fontSize:14,color:"var(--text-primary)"},children:S.title})]}),o.jsx("span",{style:{fontSize:10,padding:"2px 6px",borderRadius:4,background:"var(--bg-highlight)",color:"var(--text-muted)",fontWeight:500},children:S.difficulty==="starter"?"入门":S.difficulty==="intermediate"?"进阶":"专业"})]}),o.jsx("div",{style:{fontSize:12,color:"var(--text-secondary)",lineHeight:1.5},children:S.valueProposition})]}),o.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:10},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,flexWrap:"wrap"},children:[o.jsxs("span",{style:{fontSize:11,padding:"2px 7px",borderRadius:4,background:"color-mix(in srgb, var(--cm-status-success) 15%, transparent)",color:"var(--cm-status-success)",fontWeight:600},children:[o.jsx(We,{name:"zap",size:14,style:{verticalAlign:-2,marginRight:4}}),"单次约省 ",S.roi.minutesSavedPerRun," 分钟"]}),S.roi.popularityCount!==void 0&&o.jsxs("span",{style:{fontSize:11,padding:"2px 7px",borderRadius:4,background:"color-mix(in srgb, var(--color-accent) 15%, transparent)",color:"var(--color-accent)"},children:[o.jsx(We,{name:"flame",size:14,style:{verticalAlign:-2,marginRight:4}}),"已使用 ",S.roi.popularityCount," 次"]})]}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,marginTop:4},children:[o.jsxs("button",{onClick:()=>{b(S)},style:{flex:1,padding:"6px 10px",borderRadius:6,background:"var(--bg-highlight)",border:"1px solid var(--border-secondary)",color:"var(--text-secondary)",fontSize:12,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4},children:[o.jsx("span",{children:o.jsx(We,{name:"play",size:16})}),o.jsx("span",{children:"试跑演示"})]}),o.jsxs("button",{onClick:()=>f(S),style:{flex:1.2,padding:"6px 12px",borderRadius:6,background:"var(--color-accent)",color:"var(--color-on-accent)",border:"none",fontSize:12,fontWeight:600,cursor:"pointer",display:"inline-flex",alignItems:"center",justifyContent:"center",gap:4},children:[o.jsx("span",{children:o.jsx(We,{name:"zap",size:16})}),o.jsx("span",{children:"使用此模板"})]})]})]})]},S.id))})]}),p&&o.jsx(R1,{template:p,onSandboxRun:s,onClose:()=>f(null),onApply:S=>{f(null),r(S),t()}})]}),document.body)},SC="YAML 请先转为 JSON 后再导入",_C=["get","post","put","delete","patch","head","options"];function ye(e){return!!e&&typeof e=="object"&&!Array.isArray(e)}function Rp(e){return String(e??"").replace(/^/,"").trim()}function aa(e,t=48){return(e.replace(/([a-z0-9])([A-Z])/g,"$1_$2").replace(/[^A-Za-z0-9]+/g,"_").replace(/^_+|_+$/g,"").toLowerCase()||"api").slice(0,t).replace(/_+$/g,"")||"api"}function jC(e){const t=e.split(/[^A-Za-z0-9]+/).filter(Boolean);if(t.length===0)return"value";const r=t.map((n,s)=>{const a=n===n.toUpperCase()?n.toLowerCase():n;return s===0?a.charAt(0).toLowerCase()+a.slice(1):a.charAt(0).toUpperCase()+a.slice(1)}).join("");return/^[0-9]/.test(r)?`v${r}`:r}function oa(e,t){let r=e,n=2;for(;t.has(r);)r=`${e}_${n}`,n+=1;return t.add(r),r}function Ln(e,t=0){if(e==null)return{type:"string"};if(Array.isArray(e))return t>=4||e.length===0?{type:"array"}:{type:"array",items:Ln(e[0],t+1)};switch(typeof e){case"number":return{type:Number.isInteger(e)?"integer":"number"};case"boolean":return{type:"boolean"};case"object":{if(t>=4)return{type:"object"};const r={};for(const[n,s]of Object.entries(e))r[n]=Ln(s,t+1);return{type:"object",properties:r}}default:return{type:"string"}}}function jr(e){if(!e)return"string";const t=Array.isArray(e.type)?e.type.find(r=>r!=="null"):e.type;return t||(e.properties?"object":e.items?"array":"string")}function P1(e){let t=e.trim();const r=t.indexOf("#");r>=0&&(t=t.slice(0,r));let n="";const s=t.indexOf("?");s>=0&&(n=t.slice(s+1),t=t.slice(0,s));let a="";const i=/^([a-z][a-z0-9+.-]*:\/\/[^/]*)/i.exec(t)||/^(\$\{[^}]*\})/.exec(t);return i&&(a=i[1],t=t.slice(i[1].length)),{baseUrl:a,path:t||"/",query:n}}function Op(e){try{return decodeURIComponent(e.replace(/\+/g," "))}catch{return e}}const TC=/^(authorization|cookie|set-cookie|proxy-authorization|x-api-key)$/i,A1=/token|secret|api[-_]?key|passw(or)?d|access[-_]?key|signature|subscription[-_]?key|credential|session(?:[-_]?(?:id|token|key))?$/i;function $1(e){return TC.test(e.trim())||A1.test(e)}function Mn(e){return A1.test(e)}function mt(e){return"${workflow.input."+jC(e)+"}"}function IC(e){return`请求头 ${e} 含敏感信息,已替换为 ${mt(e)};请在流程入参中提供(值需包含完整头内容,如 Bearer xxx),或改用凭据管理,不会写入流程定义`}function Pp(e){const t={},r=[];for(const[n,s]of Object.entries(e))$1(n)&&!String(s).includes("${")?(t[n]=mt(n),r.push(IC(n))):t[n]=s;return{headers:t,warnings:r}}function Ap(e){const{headers:t,warnings:r}=Pp(e.headers);return{...e,headers:t,warnings:Array.from(new Set([...e.warnings,...r]))}}function NC(e){return`${e.method} ${e.path}`}function $p(e,t=[]){const r=[...t],n=new Set(r);for(const s of e)for(const a of s.warnings){const i=`${NC(s)}:${a}`;n.has(i)||(n.add(i),r.push(i))}return r}function D1(e,t){const r=Ln(e);if(ye(e)&&r.properties)for(const[n,s]of Object.entries(e))r.properties[n].default=Dp(s,[n],Mn(n),t);return r}function Dp(e,t,r,n){const s=t[t.length-1]??"",a=r||Mn(s);if(Array.isArray(e))return e.map((i,l)=>Dp(i,[...t,String(l)],a,n));if(ye(e)){const i={};for(const[l,c]of Object.entries(e))i[l]=Dp(c,[...t,l],a,n);return i}if(a&&(typeof e=="string"||typeof e=="number")&&!String(e).includes("${")){const i=t.filter(c=>!/^\d+$/.test(c)).join("_"),l=mt(i);return n.push(`请求体字段 ${t.join(".")} 疑似敏感信息,默认值已替换为 ${l}`),l}return e}function Lp(e,t){const r=[];if(!e)return r;for(const n of e.split("&")){if(!n)continue;const s=n.indexOf("="),a=Op(s>=0?n.slice(0,s):n),i=s>=0?Op(n.slice(s+1)):"";if(!a)continue;let l=i;Mn(a)&&!i.includes("${")&&(l=mt(a),t.push(`查询参数 ${a} 疑似敏感信息,默认值已替换为 ${l},请在流程入参中提供`)),r.push({name:a,in:"query",required:!1,schema:{type:"string"},defaultValue:l||void 0})}return r}function Mp(e){const t={};for(const[r,n]of Object.entries(e))/^(content-type|accept)$/i.test(r)||(t[r]=n);return t}function ia(e,t){const r=Object.keys(e).find(n=>n.toLowerCase()===t.toLowerCase());return r===void 0?void 0:e[r]}const CC=6;function L1(e,t){if(!t.startsWith("#/"))return;let r=e;for(const n of t.slice(2).split("/")){const s=decodeURIComponent(n).replace(/~1/g,"/").replace(/~0/g,"~");if(r===null||typeof r!="object")return;r=r[s]}return r}function Wn(e,t){let r=e;for(let n=0;n<10&&(ye(r)&&typeof r.$ref=="string");n++)r=L1(t,r.$ref);return ye(r)&&typeof r.$ref!="string"?r:void 0}const M1=["type","title","description","enum","default","format","example","examples","maxLength","minLength","minimum","maximum","pattern","nullable"];function la(e,t,r=[],n=CC){let s=!1;const a=(i,l,c)=>{if(!ye(i))return{};if(typeof i.$ref=="string"){const m=i.$ref,h=m.split("/").pop()||m;if(c.includes(m))return s||(s=!0,r.push(`存在循环引用(${h}),循环处已截断`)),{type:"object",description:`循环引用:${h}`};const y=L1(t,m);return y===void 0?(r.push(`无法解析引用 ${m},已忽略`),{}):a(y,l,[...c,m])}if(l>n)return{type:jr(i),...typeof i.description=="string"?{description:i.description}:{}};const d={};for(const m of M1)i[m]!==void 0&&(d[m]=i[m]);const u=[];Array.isArray(i.allOf)&&u.push(...i.allOf);for(const m of["oneOf","anyOf"]){const h=i[m];if(Array.isArray(h)&&h.length>0){const y=h.find(x=>!(ye(x)&&x.type==="null"))??h[0];u.push(y)}}let p,f=Array.isArray(i.required)?[...i.required]:[];for(const m of u){const h=a(m,l,c);for(const y of M1)d[y]===void 0&&h[y]!==void 0&&(d[y]=h[y]);h.properties&&(p={...p||{},...h.properties}),Array.isArray(h.required)&&(f=f.concat(h.required)),h.items&&!d.items&&(d.items=h.items)}if(ye(i.properties)){p={...p||{}};for(const[m,h]of Object.entries(i.properties))p[m]=a(h,l+1,c)}return p&&(d.properties=p,d.type||(d.type="object")),f.length>0&&(d.required=Array.from(new Set(f))),i.items!==void 0&&(d.items=a(i.items,l+1,c)),d};return a(e,0,[])}const EC=/^(content-type|accept)$/i;function Wp(e){return/json/i.test(e)}function RC(e,t){if(!Array.isArray(e)||!ye(e[0])||typeof e[0].url!="string")return t.push("文档未声明 servers,URL 仅含路径,请在步骤里补充完整服务地址"),"";const r=e[0],n=e.slice(1).filter(l=>ye(l)&&typeof l.url=="string");if(n.length>0){const l=c=>typeof c.description=="string"&&c.description.trim()?`${c.url}(${c.description.trim()})`:c.url;t.push(`文档声明了 ${n.length+1} 个服务地址,已使用第一个 ${l(r)};其他地址:${n.map(l).join("、")}。如需换用,请在步骤里修改服务地址`)}const s=ye(r.variables)?r.variables:{},i=r.url.replace(/\{([^}]+)\}/g,(l,c)=>{const d=s[c];if(ye(d)){if(d.default!==void 0)return String(d.default);if(Array.isArray(d.enum)&&d.enum.length>0)return String(d.enum[0])}return t.push(`服务地址变量 {${c}} 没有默认值,请手动替换`),l}).replace(/\/+$/,"");return i&&!/^[a-z][a-z0-9+.-]*:\/\//i.test(i)&&!i.startsWith("${")&&t.push(`服务地址 ${i} 是相对路径,请在步骤里补充完整地址`),i}function OC(e,t){const r=typeof e.basePath=="string"?e.basePath.replace(/\/+$/,""):"";return typeof e.host!="string"||!e.host?(t.push("文档未声明 host,URL 仅含路径,请在步骤里补充完整服务地址"),r):`${Array.isArray(e.schemes)&&typeof e.schemes[0]=="string"?e.schemes[0]:"https"}://${e.host}${r}`}function PC(e){const t={};for(const r of["type","format","enum","default","items","minimum","maximum","maxLength","pattern"])e[r]!==void 0&&(t[r]=e[r]);return t.type||(t.type="string"),t}function W1(e){if(!ye(e))return;const t=Object.keys(e),r=t.find(n=>n.toLowerCase()==="application/json")??t.find(Wp);return r&&ye(e[r])?{type:r,media:e[r]}:void 0}function z1(e,t,r){let n=la(e.schema,t,r);if(Object.keys(n).length===0){const s=e.example??(ye(e.examples)?Object.values(e.examples).map(a=>ye(a)?a.value:void 0).find(a=>a!==void 0):void 0);s!==void 0&&(n=Ln(s))}return n}function AC(e,t,r,n){const s=ye(e.responses)?e.responses:{},a=Object.keys(s),l=a.filter(u=>/^2\d\d$/.test(u)).sort()[0]??a.find(u=>/^2xx$/i.test(u))??(a.includes("default")?"default":void 0);if(!l)return;const c=Wn(s[l],t);if(!c)return;let d;if(r===3){const u=W1(c.content);u&&(d=z1(u.media,t,n))}else c.schema!==void 0&&(d=la(c.schema,t,n));return d&&Object.keys(d).length>0?d:void 0}function $C(e,t,r,n){const s={headers:{},queryParams:[]};if(!Array.isArray(e)||!ye(e[0])||!ye(t))return s;for(const a of Object.keys(e[0])){const i=Wn(t[a],r);if(!i)continue;const l=String(i.type||"");if(l==="apiKey"){const c=typeof i.name=="string"?i.name:"X-Api-Key";i.in==="header"?s.headers[c]="":i.in==="query"?(s.queryParams.push({name:c,in:"query",required:!0,schema:{type:"string"},description:`认证参数(${a})`,defaultValue:mt(c)}),n.push(`查询参数 ${c} 是认证密钥,已默认取自 ${mt(c)},请在流程入参中提供`)):n.push(`认证方式 ${a}(${String(i.in)})暂不支持,已忽略`)}else(l==="http"||l==="basic"||l==="oauth2"||l==="openIdConnect")&&(s.headers.Authorization="")}return s}function q1(e,t){const r=t===3?"openapi3":"swagger2";if(!ye(e.paths))return{ok:!1,format:r,error:"缺少 paths 字段,找不到接口定义"};const n=[],s=t===2?OC(e,n):"",a=t===3?e.components?.securitySchemes:e.securityDefinitions,i=new Set,l=[],c=new Map;for(const[d,u]of Object.entries(e.paths)){const p=Wn(u,e);if(p)for(const f of _C){const m=p[f];if(!ye(m))continue;const h=[];let y;if(t===3){const w=m.servers??p.servers??e.servers;let I=c.get(w);if(!I){const N=[];I={url:RC(w,N),warnings:N},c.set(w,I),n.push(...N)}y=I.url}else y=s;const x=[],g={},v=new Map;for(const w of[...Array.isArray(p.parameters)?p.parameters:[],...Array.isArray(m.parameters)?m.parameters:[]]){const I=Wn(w,e);I&&typeof I.name=="string"&&typeof I.in=="string"&&v.set(`${I.in}:${I.name}`,I)}let k;for(const w of v.values()){const I=w.in;if(I==="path"||I==="query"||I==="header"){if(I==="header"&&EC.test(w.name))continue;if(I==="header"&&$1(w.name)){g[w.name]="";continue}const N=la(t===3?w.schema??{type:"string"}:PC(w),e,h),C=Mn(w.name);let M;C?(N.default!==void 0&&!String(N.default).includes("${")&&delete N.default,M=mt(w.name),h.push(`参数 ${w.name} 疑似敏感信息,不使用文档示例值,已默认取自 ${M},请在流程入参中提供`)):N.default===void 0&&w.example!==void 0&&t===3&&(N.default=w.example),x.push({name:w.name,in:I,required:I==="path"?!0:w.required===!0,schema:Object.keys(N).length>0?N:{type:"string"},description:typeof w.description=="string"?w.description:void 0,...M!==void 0?{defaultValue:M}:{}})}else if(I==="body"&&t===2){const N=m.consumes??e.consumes,C=Array.isArray(N)&&N.length>0?String(N.find(M=>Wp(String(M)))??N[0]):"application/json";Wp(C)?k={contentType:C,schema:la(w.schema,e,h)}:h.push(`请求体类型 ${C} 暂不支持,已忽略(仅支持 JSON)`)}else I==="formData"?h.push("表单(formData)参数暂不支持,已忽略"):I==="cookie"&&h.push(`Cookie 参数 ${w.name} 暂不支持,已忽略`)}if(t===3&&m.requestBody!==void 0){const w=Wn(m.requestBody,e),I=w?W1(w.content):void 0;I?k={contentType:I.type,schema:z1(I.media,e,h)}:w&&ye(w.content)&&Object.keys(w.content).length>0&&h.push(`请求体类型 ${Object.keys(w.content)[0]} 暂不支持,已忽略(仅支持 JSON)`)}const b=$C(m.security??e.security,a,e,h);for(const w of Object.keys(b.headers))w in g||(g[w]="");for(const w of b.queryParams)x.some(I=>I.in==="query"&&I.name===w.name)||x.push(w);const S=typeof m.operationId=="string"&&m.operationId?aa(m.operationId):aa(d.replace(/[{}]/g,"")),j=S.startsWith(`${f}_`)&&S.length>f.length+1?S.slice(f.length+1):S,_=oa(`${f}_${j}`,i);l.push(Ap({id:_,method:f.toUpperCase(),baseUrl:y,path:d,summary:typeof m.summary=="string"&&m.summary.trim()?m.summary.trim():void 0,description:typeof m.description=="string"?m.description:void 0,operationId:typeof m.operationId=="string"?m.operationId:void 0,tags:Array.isArray(m.tags)?m.tags.filter(w=>typeof w=="string"):[],params:x,headers:g,body:k,responseSchema:AC(m,e,t,h),warnings:h}))}}return l.length===0?{ok:!1,format:r,error:"paths 中没有找到任何接口(get / post / put / delete / patch …)"}:{ok:!0,format:r,operations:l,warnings:$p(l,n)}}function F1(e){if(!ye(e))return{ok:!1,format:"openapi3",error:"OpenAPI 文档必须是 JSON 对象"};try{return q1(e,3)}catch(t){return{ok:!1,format:"openapi3",error:`OpenAPI 解析失败:${t instanceof Error?t.message:String(t)}`}}}function B1(e){if(!ye(e))return{ok:!1,format:"swagger2",error:"Swagger 文档必须是 JSON 对象"};try{return q1(e,2)}catch(t){return{ok:!1,format:"swagger2",error:`Swagger 解析失败:${t instanceof Error?t.message:String(t)}`}}}function zn(e,t){return e.replace(/\{\{\s*([^{}\s]+)\s*\}\}/g,(r,n)=>{const s=n.replace(/[^\w]/g,"_");return t?.add(s),"${workflow.input."+s+"}"})}function DC(e){if(typeof e.raw=="string"&&e.raw)return e.raw;const t=Array.isArray(e.host)?e.host.join("."):typeof e.host=="string"?e.host:"",r=Array.isArray(e.path)?e.path.join("/"):typeof e.path=="string"?e.path:"",n=typeof e.protocol=="string"&&e.protocol?`${e.protocol}://`:"",s=e.port?`:${e.port}`:"",a=Array.isArray(e.query)?e.query.filter(i=>ye(i)&&!i.disabled&&i.key).map(i=>`${i.key}=${i.value??""}`).join("&"):"";return`${n}${t}${s}/${r}${a?`?${a}`:""}`}function LC(e){if(typeof e=="string")return e;if(ye(e)&&typeof e.content=="string")return e.content}function MC(e,t,r,n){if(!(!e||typeof e.type!="string"||e.type==="noauth"))if(e.type==="apikey"){const s=Array.isArray(e.apikey)?e.apikey:[],a=String(s.find(l=>l?.key==="key")?.value||"X-Api-Key");String(s.find(l=>l?.key==="in")?.value||"header")==="query"?(r.some(l=>l.in==="query"&&l.name===a)||r.push({name:a,in:"query",required:!0,schema:{type:"string"},defaultValue:mt(a)}),n.push(`查询参数 ${a} 是认证密钥,已默认取自 ${mt(a)},请在流程入参中提供`)):t[a]=""}else["bearer","basic","oauth2","digest","hawk","awsv4","ntlm","oauth1"].includes(e.type)&&(t.Authorization="")}function H1(e,t,r,n){if(Array.isArray(e))for(const s of e){if(!ye(s))continue;const a=ye(s.auth)?s.auth:n;if(Array.isArray(s.item)){const c=typeof s.name=="string"&&s.name?[...r,s.name]:r;H1(s.item,t,c,a);continue}const i=s.request;if(!ye(i)&&typeof i!="string")continue;const l=WC(s,ye(i)?i:{method:"GET",url:i},t,r,a);l&&t.ops.push(l)}}function WC(e,t,r,n,s){const a=[],i=typeof t.url=="string"?t.url:ye(t.url)?DC(t.url):"";if(!i)return;const{baseUrl:l,path:c,query:d}=P1(zn(i,r.vars)),u=c.replace(/\/:([A-Za-z_]\w*)/g,"/{$1}"),p=[],f={};if(ye(t.url)&&Array.isArray(t.url.variable))for(const b of t.url.variable)ye(b)&&typeof b.key=="string"&&typeof b.value=="string"&&b.value&&(f[b.key]=zn(b.value,r.vars));for(const b of u.matchAll(/\{([^}/]+)\}/g))p.push({name:b[1],in:"path",required:!0,schema:{type:"string"},defaultValue:f[b[1]]});p.push(...Lp(d,a));const m={};if(Array.isArray(t.header))for(const b of t.header)ye(b)&&!b.disabled&&typeof b.key=="string"&&b.key&&(m[b.key]=zn(String(b.value??""),r.vars));MC(ye(t.auth)?t.auth:s,m,p,a);let h;const y=t.body;if(ye(y)&&typeof y.mode=="string")if(y.mode==="raw"){const b=zn(String(y.raw??""),r.vars),S=ye(y.options)&&ye(y.options.raw)?String(y.options.raw.language||""):"",j=Object.keys(m).find(w=>w.toLowerCase()==="content-type"),_=S==="json"||j&&/json/i.test(m[j])||/^[[{]/.test(b.trim());if(b.trim()){let w,I=!1;if(_)try{w=JSON.parse(b),I=!0}catch{I=!1}I?h={contentType:"application/json",schema:D1(w,a)}:(h={contentType:j?m[j]:"text/plain",schema:{type:"string",default:b}},_&&a.push("请求体不是合法 JSON(可能含未加引号的变量),已作为文本整体导入"))}}else y.mode!=="none"&&a.push(`请求体类型 ${y.mode} 暂不支持,已忽略(仅支持 JSON / 文本)`);let x;if(Array.isArray(e.response))for(const b of e.response){if(!ye(b)||typeof b.body!="string")continue;const S=Number(b.code);if(S>=200&&S<300)try{const j=JSON.parse(zn(b.body,r.vars));if(j!==null&&typeof j=="object"){x=Ln(j);break}}catch{}}const g=typeof e.name=="string"?e.name.trim():"",v=String(t.method||"GET").toUpperCase(),k=oa(`${v.toLowerCase()}_${aa(u.replace(/[{}]/g,""))}`,r.used);return Ap({id:k,method:v,baseUrl:l,path:u,summary:g||void 0,description:LC(t.description),tags:[...n],params:p,headers:Mp(m),body:h,responseSchema:x,warnings:a})}function J1(e){if(!ye(e)||!Array.isArray(e.item))return{ok:!1,format:"postman21",error:"Postman Collection 缺少 item 列表"};try{const t={used:new Set,vars:new Set,ops:[]},r=[];return H1(e.item,t,[],ye(e.auth)?e.auth:void 0),t.ops.length===0?{ok:!1,format:"postman21",error:"Collection 中没有找到任何请求"}:(t.vars.size>0&&r.push(`用到了 Postman 变量:${Array.from(t.vars).join("、")},已转为 \${workflow.input.xxx},请在流程入参中提供`),{ok:!0,format:"postman21",operations:t.ops,warnings:$p(t.ops,r)})}catch(t){return{ok:!1,format:"postman21",error:`Postman 解析失败:${t instanceof Error?t.message:String(t)}`}}}function zC(e){const t=e.replace(/\\\r?\n/g," "),r=[];let n="",s=!1,a=0;const i=()=>{s&&r.push(n),n="",s=!1};for(;a<t.length;){const l=t[a];if(/\s/.test(l))i(),a++;else if(l==="'"){s=!0;const c=t.indexOf("'",a+1),d=c<0?t.length:c;n+=t.slice(a+1,d),a=d+1}else if(l==="$"&&t[a+1]==="'"){for(s=!0,a+=2;a<t.length&&t[a]!=="'";)if(t[a]==="\\"&&a+1<t.length){const c=t[a+1],d={n:`
|
|
278
|
+
`,t:" ",r:"\r","\\":"\\","'":"'",'"':'"'};if(c==="u"&&/^[0-9a-fA-F]{4}$/.test(t.slice(a+2,a+6))){n+=String.fromCharCode(parseInt(t.slice(a+2,a+6),16)),a+=6;continue}if(c==="x"&&/^[0-9a-fA-F]{2}$/.test(t.slice(a+2,a+4))){n+=String.fromCharCode(parseInt(t.slice(a+2,a+4),16)),a+=4;continue}n+=d[c]??c,a+=2}else n+=t[a],a++;a++}else if(l==='"'){for(s=!0,a++;a<t.length&&t[a]!=='"';)t[a]==="\\"&&a+1<t.length&&'"\\$`'.includes(t[a+1])?(n+=t[a+1],a+=2):(n+=t[a],a++);a++}else l==="\\"&&a+1<t.length?(s=!0,n+=t[a+1],a+=2):(s=!0,n+=l,a++)}return i(),r}const qC=new Set(["--request","--header","--data","--data-raw","--data-binary","--data-ascii","--data-urlencode","--json","--user","--url","--cookie","--user-agent","--output","--max-time","--connect-timeout","--referer","--proxy","--form","--cert","--key","--cacert","--retry","--write-out","--upload-file","--resolve","--cookie-jar","--dump-header","--range","--config","--proxy-user","--limit-rate","--max-filesize","--interface","--retry-delay","--retry-max-time","--cert-type","--key-type","--pass","--oauth2-bearer","--aws-sigv4","--unix-socket","--abstract-unix-socket","--form-string","--continue-at","--speed-limit","--speed-time","--time-cond","--local-port","--keepalive-time","--capath","--ciphers","--connect-to","--expect100-timeout","--variable","--proto","--proto-redir","--request-target","--max-redirs"]),FC=new Set(["X","H","d","u","b","A","e","F","o","m","x","w","E","T","c","D","r","C","K","U","Y","y","z","t","P","Q"]),BC=`curl -X POST 'https://api.example.com/v1/tickets' \\
|
|
137
279
|
-H 'Content-Type: application/json' \\
|
|
138
280
|
-H 'Authorization: Bearer <token>' \\
|
|
139
|
-
-d '{"title":"磁盘告警","priority":"high"}'`;function
|
|
140
|
-
`)[0]??"")||/^\s*(openapi|swagger)\s*:/m.test(e)?!0:/^[A-Za-z_][\w-]*\s*:(\s|$)/.test(e)}function
|
|
141
|
-
`)[0].trim();return{id:a,name:i,category:"network",icon:"
|
|
281
|
+
-d '{"title":"磁盘告警","priority":"high"}'`;function U1(e){try{let t=zC(String(e??""));for(;t.length>0&&(t[0]==="$"||t[0]==="sudo");)t=t.slice(1);if(t.length===0||t[0]!=="curl")return{ok:!1,format:"curl",error:"不是 curl 命令(应以 curl 开头)"};const r=[],n={},s=[],a={method:void 0,url:void 0,useGet:!1,head:!1,basicAuth:!1,bearer:!1,cookie:!1,unsupportedBody:void 0},i=(x,g)=>{if(g==="--data-urlencode"){a.unsupportedBody="--data-urlencode";return}if(x.startsWith("@")){a.unsupportedBody=`${g} ${x}(读取本地文件)`;return}s.push(x)},l=(x,g)=>{switch(x){case"-X":case"--request":g&&(a.method=g.toUpperCase());break;case"-H":case"--header":{if(!g)break;const v=g.indexOf(":");v>0&&(n[g.slice(0,v).trim()]=g.slice(v+1).trim());break}case"-d":case"--data":case"--data-raw":case"--data-binary":case"--data-ascii":case"--data-urlencode":g!==void 0&&i(g,x.length===2?"-d":x);break;case"--json":g!==void 0&&i(g,"--json"),ia(n,"content-type")||(n["Content-Type"]="application/json");break;case"-u":case"--user":a.basicAuth=!0;break;case"--oauth2-bearer":a.bearer=!0;break;case"-b":case"--cookie":a.cookie=!0;break;case"--url":g&&(a.url=g);break;case"-F":case"--form":a.unsupportedBody="表单上传(-F)";break;default:break}};for(let x=1;x<t.length;x++){const g=t[x];if(g==="-G"||g==="--get")a.useGet=!0;else if(g==="-I"||g==="--head")a.head=!0;else if(g.startsWith("--")){const v=g.indexOf("="),k=v>0?g.slice(0,v):g;if(qC.has(k)){const b=v>0?g.slice(v+1):t[++x];l(k,b)}}else if(g.startsWith("-")&&g.length>1)for(let v=1;v<g.length;v++){const k=g[v];if(FC.has(k)){const b=g.slice(v+1),S=b.length>0?b:t[++x];l(`-${k}`,S);break}k==="G"?a.useGet=!0:k==="I"&&(a.head=!0)}else a.url===void 0&&(a.url=g)}let c=a.url;if(!c)return{ok:!1,format:"curl",error:"curl 命令里没有找到 URL"};!/^[a-z][a-z0-9+.-]*:\/\//i.test(c)&&!c.startsWith("${")&&(c=`http://${c}`,r.push("URL 没有协议,已按 http:// 处理,请核对"));const d=/^([a-z][a-z0-9+.-]*:\/\/)([^/@\s]*)@/i.exec(c);d&&(c=c.replace(d[0],d[1]),a.basicAuth=!0),(a.basicAuth||a.bearer&&!ia(n,"authorization"))&&(n.Authorization=""),a.cookie&&!ia(n,"cookie")&&(n.Cookie="");const u=P1(c),p=Lp(u.query,r);let f;const m=s.join("&");if(a.unsupportedBody&&r.push(`${a.unsupportedBody} 暂不支持,请求体已忽略`),a.useGet&&m)p.push(...Lp(m,r));else if(m.trim()){const x=ia(n,"content-type");let g,v=!1;try{g=JSON.parse(m),v=g!==null&&typeof g=="object"}catch{v=!1}if(v)f={contentType:x||"application/json",schema:D1(g,r)};else{const k=x||"application/x-www-form-urlencoded";f={contentType:k,schema:{type:"string",default:HC(m,k,r)}}}}const h=a.method??(a.head?"HEAD":f&&!a.useGet?"POST":"GET"),y=Ap({id:`${h.toLowerCase()}_${aa(u.path)}`,method:h,baseUrl:u.baseUrl,path:u.path,tags:[],params:p,headers:Mp(n),body:f,warnings:r});return{ok:!0,format:"curl",operations:[y],warnings:$p([y])}}catch(t){return{ok:!1,format:"curl",error:`curl 解析失败:${t instanceof Error?t.message:String(t)}`}}}function HC(e,t,r){return/x-www-form-urlencoded/i.test(t)?e.split("&").map(n=>{const s=n.indexOf("=");if(s<=0)return n;const a=Op(n.slice(0,s));return Mn(a)&&!n.slice(s+1).includes("${")?(r.push(`请求体字段 ${a} 疑似敏感信息,已替换为 ${mt(a)}`),`${n.slice(0,s)}=${mt(a)}`):n}).join("&"):e}function JC(e){return/^---\s*$/m.test(e.split(`
|
|
282
|
+
`)[0]??"")||/^\s*(openapi|swagger)\s*:/m.test(e)?!0:/^[A-Za-z_][\w-]*\s*:(\s|$)/.test(e)}function V1(e){const t=Rp(e);if(!t)return{format:"unknown"};if(/^(\$\s+)?curl(\s|$)/i.test(t))return{format:"curl"};if(t.startsWith("{")||t.startsWith("[")){let r;try{r=JSON.parse(t)}catch(n){return{format:"unknown",error:`JSON 格式不正确:${n instanceof Error?n.message:String(n)}`}}if(ye(r)){if(typeof r.openapi=="string"&&/^3\./.test(r.openapi))return{format:"openapi3",doc:r};if(typeof r.swagger=="string"&&/^2\./.test(r.swagger))return{format:"swagger2",doc:r};const n=ye(r.info)?String(r.info.schema??""):"";if(Array.isArray(r.item)&&ye(r.info)&&(/collection\/v2/.test(n)||r.info._postman_id))return{format:"postman21",doc:r}}return{format:"unknown",doc:r}}return JC(t)?{format:"yaml"}:{format:"unknown"}}function UC(e){return V1(e).format}const VC="无法识别的格式:支持 OpenAPI 3 / Swagger 2 / Postman Collection v2.1(JSON)和 curl 命令";function K1(e){try{const t=V1(e);switch(t.format){case"openapi3":return F1(t.doc);case"swagger2":return B1(t.doc);case"postman21":return J1(t.doc);case"curl":return U1(Rp(e));case"yaml":return{ok:!1,format:"yaml",error:SC};default:return{ok:!1,format:"unknown",error:t.error??(Rp(e)?VC:"请粘贴接口文档或 curl 命令")}}}catch(t){return{ok:!1,error:`解析失败:${t instanceof Error?t.message:String(t)}`}}}const KC=["_actionId","actionName","http_request"];function qn(e){return e==null||e===""}function ca(e,t={}){const r={...e};return!r.description&&t.description&&(r.description=t.description),t.defaultValue!==void 0&&(r.default=t.defaultValue),r.example!==void 0&&r.examples===void 0&&(r.examples=[typeof r.example=="object"?JSON.stringify(r.example):r.example]),delete r.example,r}function zp(e,t){if(!qn(e)){if(typeof e!="string")return e;if(t==="object"||t==="array")try{return JSON.parse(e)}catch{return e}if(e.includes("${"))return e;if(t==="number"||t==="integer")return e.trim()!==""&&!Number.isNaN(Number(e))?Number(e):e;if(t==="boolean"){if(e==="true")return!0;if(e==="false")return!1}return e}}function GC(e){return e.includes("${")?e:encodeURIComponent(e)}function YC(e,t,r){const n=t.split(".");let s=e;for(let i=0;i<n.length-1;i++)ye(s[n[i]])||(s[n[i]]={}),s=s[n[i]];const a=n[n.length-1];ye(s[a])&&ye(r)||(s[a]=r)}function XC(e){const t=jr(e);return t==="integer"||t==="number"?"number":t==="boolean"||t==="array"||t==="object"?t:"string"}function G1(e){const t={};for(const[r,n]of Object.entries(e))t[r]=ca(n);return t}function ZC(e){if(e&&jr(e)==="object"&&ye(e.properties)&&Object.keys(e.properties).length>0){const n=e.properties,s=bn({type:"JSON",data:{type:"object",properties:G1(n)}},[]),a=[];for(const i of s){a.push({...i,key:`response.body.${i.key}`});const l=n[i.key];if(l&&jr(l)==="object"&&ye(l.properties)&&Object.keys(l.properties).length>0){const c=bn({type:"JSON",data:{type:"object",properties:G1(l.properties)}},[]);for(const d of c)a.push({...d,key:`response.body.${i.key}.${d.key}`,label:`${i.label}.${d.label}`})}}return a}const t=e?XC(e):"object";return[{key:"response.body",label:"响应体",type:t,example:t==="array"?[]:t==="object"?{}:t==="number"?0:t==="boolean"?!0:"sample"}]}function QC(e){const t=(e.summary||"").trim();return t?t.length>40?`${t.slice(0,40)}…`:t:`${e.method} ${e.path}`}function Y1(e,t={}){const r=t.idPrefix||"import",n=new Set(t.existingIds||[]),s=oa(e.id,new Set(Array.from(n).filter(I=>I.startsWith(`${r}.`)).map(I=>I.slice(r.length+1)))),a=`${r}.${s}`,i=QC(e),l=new Set(KC),c=(I,N)=>{let C=I;return l.has(C)&&(C=`${I}_${N}`),oa(C,l)},d=[],u={},p=[],f=new Set(e.params.filter(I=>I.in==="path").map(I=>I.name)),m=e.params.filter(I=>I.in==="path");for(const I of e.path.matchAll(/\{([^}/]+)\}/g))f.has(I[1])||(f.add(I[1]),m.push({name:I[1],in:"path",required:!0,schema:{type:"string"}}));const h=[...m,...e.params.filter(I=>I.in==="query"),...e.params.filter(I=>I.in==="header")];for(const I of h){const N=c(I.name,I.in),C=jr(I.schema);d.push({key:N,name:I.name,source:I.in,type:C});const M=I.defaultValue!==void 0?I.defaultValue:I.in==="path"&&I.schema.default===void 0?mt(I.name):void 0;u[N]=ca(I.schema,{description:I.description,defaultValue:M}),(I.required||I.in==="path")&&p.push(N)}let y="none",x="object";if(e.body){const I=e.body.schema;if(x=jr(I),x==="object"&&ye(I.properties)&&Object.keys(I.properties).length>0){y="props";const N=Array.isArray(I.required)?I.required:[];for(const[C,M]of Object.entries(I.properties)){const R=c(C,"body");d.push({key:R,name:C,source:"body",type:jr(M)}),u[R]=ca(M),N.includes(C)&&p.push(R)}}else{y="whole";const N=c("body","body");d.push({key:N,name:"body",source:"body",type:x}),u[N]=ca({...I,title:I.title||"请求体"})}}const g=Ws({type:"JSON",data:{type:"object",properties:u,required:p}},[]).map(I=>I.defaultValue!==void 0&&I.defaultValue!==null&&typeof I.defaultValue=="object"?{...I,defaultValue:JSON.stringify(I.defaultValue)}:I),v=[{key:"response.statusCode",label:"HTTP 状态码",type:"number",example:200},...ZC(e.responseSchema)],k=Mp(Pp(e.headers).headers),b=e.baseUrl.replace(/\/+$/,""),S=e.path.startsWith("/")?e.path:`/${e.path}`,j=I=>d.filter(N=>N.source===I),_=(I,N)=>{const C=I||{},M=S.replace(/\{([^}/]+)\}/g,(F,A)=>{const W=j("path").find(Z=>Z.name===A),P=W?C[W.key]:void 0,D=qn(P)?mt(A):String(P);return D.includes("${")?D:encodeURIComponent(D)}),R=[];for(const F of j("query")){const A=zp(C[F.key],F.type);if(A===void 0)continue;const W=Array.isArray(A)?A:[A];for(const P of W)R.push(`${encodeURIComponent(F.name)}=${GC(typeof P=="object"?JSON.stringify(P):String(P))}`)}const O=`${b}${M}${R.length>0?`${M.includes("?")?"&":"?"}${R.join("&")}`:""}`,$={...k};for(const F of j("header"))qn(C[F.key])||($[F.name]=String(C[F.key]));let B;if(y==="props"){const F={};for(const A of j("body")){const W=zp(C[A.key],A.type);W!==void 0&&(F[A.name]=W)}B=F}else if(y==="whole"){const F=j("body")[0];B=F?x==="object"||x==="array"?zp(C[F.key],x):qn(C[F.key])?void 0:String(C[F.key]):void 0}const q={};for(const F of g)qn(C[F.key])||(q[F.key]=C[F.key]);return{name:`http_${e.id}`,taskReferenceName:N.taskReferenceName,type:"HTTP",description:`调用接口:${i}`,inputParameters:{_actionId:a,actionName:i,...q,http_request:{uri:O,method:e.method,...Object.keys($).length>0?{headers:$}:{},accept:"application/json",...e.body&&B!==void 0?{contentType:e.body.contentType,body:B}:{}}}}},w=(e.description||e.summary||"").split(`
|
|
283
|
+
`)[0].trim();return{id:a,name:i,category:"network",icon:"plug",description:`${e.method} ${b}${S}${w?`:${w.slice(0,80)}`:""}`,kind:"task",tags:["导入",...e.tags],riskLevel:["GET","HEAD","OPTIONS"].includes(e.method)?"safe":"sensitive",fields:g,outputs:v,compile:_,decompile:I=>{if(I.type!=="HTTP"||I.inputParameters?._actionId!==a)return null;const N={};for(const C of g){const M=I.inputParameters[C.key];M!==void 0&&(N[C.key]=M)}return N},mockOutput:()=>{const I={};for(const N of v)YC(I,N.key,N.example);return I}}}function eE(e,t){return new Set(e.length<=t?e.map(r=>r.id):[])}function tE(e,t){const r=e.slice(0,t);return{visible:r,hiddenCount:e.length-r.length}}function rE(e,t,r){const n=new Set(e);for(const s of t)r?n.add(s.id):n.delete(s.id);return n}const X1=200,Z1=5*1024*1024,nE={openapi3:"OpenAPI 3",swagger2:"Swagger 2",postman21:"Postman Collection",curl:"curl 命令"},sE=`粘贴 OpenAPI 3 / Swagger 2 / Postman Collection v2.1(JSON)或 curl 命令,也可点击右侧「选择文件」。
|
|
142
284
|
|
|
143
285
|
示例 curl:
|
|
144
|
-
${
|
|
286
|
+
${BC}
|
|
145
287
|
|
|
146
|
-
注意:仅支持 JSON,YAML 请先转为 JSON 后再导入。`;function
|
|
147
|
-
`),"aria-label":`${R.warnings.length} 条提示`,style:{color:"var(--color-warning)",fontSize:12,flexShrink:0},children:"⚠"})]})},R.id)}),T.length===0&&o.jsx("li",{style:{textAlign:"center",padding:"28px 0",fontSize:12,color:"var(--text-muted)"},children:"没有符合条件的接口"}),T.length>N.length&&o.jsxs("li",{style:{textAlign:"center",padding:"8px 0",fontSize:12,color:"var(--text-muted)"},children:["共 ",T.length," 项,仅显示前 ",N.length," 项,请用搜索缩小范围"]})]})]}):o.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24,textAlign:"center",fontSize:12,lineHeight:1.7,color:"var(--text-muted)"},children:k?"":"粘贴内容后会在这里列出可导入的接口"})}),o.jsxs("div",{style:{padding:"12px 18px",borderTop:"1px solid var(--border-primary)",display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{fontSize:12,color:"var(--text-muted)",flex:1},children:"认证信息不会写入流程定义;导入结果仅保存在当前流程与本次会话的动作库中"}),o.jsx("button",{type:"button",style:z,onClick:e,children:"取消"}),o.jsxs("button",{type:"button",disabled:w===0,onClick:E,style:{...z,border:"1px solid var(--color-accent)",background:"var(--color-accent)",color:"var(--text-inverse)",fontWeight:600,opacity:w===0?.5:1,cursor:w===0?"not-allowed":"pointer"},children:["插入 ",w," 个步骤"]})]})]})}),document.body)};function b_(e="imported_api_workflow"){return{name:e,description:"由接口导入生成",version:1,schemaVersion:2,tasks:[],inputParameters:[]}}function cr(e,t){for(const r of e){r.taskReferenceName&&t.add(r.taskReferenceName);for(const n of r.forkTasks||[])cr(n,t);for(const n of Object.values(r.decisionCases||{}))cr(n,t);r.defaultCase&&cr(r.defaultCase,t),r.loopOver&&cr(r.loopOver,t)}}function v_(e){const t=new Set,r=JSON.stringify(e);for(const n of r.matchAll(/\$\{workflow\.input\.([A-Za-z_][\w-]*)/g))t.add(n[1]);return Array.from(t)}function Bx(e,t){const r=e??b_(),n=new Jr(t),s=new Set;cr(r.tasks||[],s);const a=[],i=(r.tasks||[]).length;t.forEach((d,p)=>{let h=kt(d);for(;s.has(h.taskReferenceName);)h=kt(d);s.add(h.taskReferenceName),a.push(Tc(h,i+p,r.name,n))});const l=st(r.inputParameters).map(d=>d.name),c=v_(a).filter(d=>!l.includes(d));let u=r.inputParameters;if(c.length>0)if(Array.isArray(u)&&u.length>0&&typeof u[0]=="string")u=[...u,...c];else{const d=c.map(p=>({name:p,type:"string",description:"接口导入引入的入参"}));u=[...u||[],...d]}return{...r,tasks:[...r.tasks||[],...a],...u?{inputParameters:u}:{}}}function Hx(e){return(e??"").replace(/-/g,"").trim()}function dr(e){return[e.type,e.level,Hx(e.domain),Hx(e.product),(e.func??"").trim()].join("-")}function Uc(e,t){return Ay(dr(e),t)}const k_=/[㐀-鿿]/;function Ux(e){const t=(e??"").trim();return t?k_.test(t)?t.replace(/-/g,"").replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,""):t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""):""}function Jx(e,t){if(!Kr(e))return null;const n=e.indexOf("-");return`${t}${e.slice(n)}`}function Vx(e){return e?Kr(e)?.type==="tmp":!1}function Kx(e){const t={name:e.name,description:(e.description??"").trim(),version:1,schemaVersion:2,tasks:[],inputParameters:[],outputParameters:{}};return e.ownerEmail&&(t.ownerEmail=e.ownerEmail),t}const wt=["product","naming","start"],S_={product:"产品",naming:"命名",start:"起点"};function w_(e,t="L2"){const r=e.products[0];return{productMode:r?"existing":"new",productName:r?.name??"",domain:r?.domain??"",systemCode:"",type:e.trial?"tmp":"custom",level:t,func:"",description:"",source:"blank"}}function __(e){const t=(e??"").trim();return t?/-/.test(t)?"产品名称不能包含「-」":/\s/.test(t)?"产品名称不能包含空白字符":null:"请填写产品名称"}function Gx(e,t,r){if(e.productMode==="existing")return t.products.some(s=>s.name===e.productName)?null:"请选择一个所属产品";if(!t.trial)return"当前环境不开放自助试用,请选择已有产品";const n=__(e.productName);return n||(e.domain?r.length>0&&r.indexOf(e.domain)<0?`业务域「${e.domain}」不在允许的列表中`:null:"请选择业务域")}function cn(e,t){return{type:t?"tmp":e.type,level:e.level,domain:e.domain,product:e.productName,func:e.func}}function j_(e,t,r){return Uc(cn(e,t),r.length>0?r:void 0)}function T_(e,t,r,n){return e==="product"?Gx(t,r,n)===null:e==="naming"?j_(t,r.trial,n).length===0:!0}function I_(e){const t=wt.indexOf(e);return wt[Math.min(t+1,wt.length-1)]}function C_(e){const t=wt.indexOf(e);return wt[Math.max(t-1,0)]}function N_(e){const t=["blank"];return e.hasTemplate&&t.push("template"),e.hasImport&&t.push("import"),t}const Yx='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function Xx({titleId:e,title:t,onClose:r,children:n,footer:s,width:a=560}){const{theme:i,themeColor:l}=oe(ke(d=>({theme:d.theme,themeColor:d.themeColor}))),c=I.useRef(null),u=I.useRef(r);return u.current=r,I.useEffect(()=>{const d=document.activeElement,p=c.current;p&&(p.querySelector(Yx)??p).focus({preventScroll:!0});const h=f=>{if(f.key==="Escape"){f.stopPropagation(),u.current();return}if(f.key!=="Tab"||!c.current)return;const m=Array.from(c.current.querySelectorAll(Yx));if(m.length===0)return;const y=m[0],v=m[m.length-1],g=document.activeElement;f.shiftKey&&(g===y||!c.current.contains(g))?(f.preventDefault(),v.focus()):!f.shiftKey&&(g===v||!c.current.contains(g))&&(f.preventDefault(),y.focus())};return window.addEventListener("keydown",h),()=>{window.removeEventListener("keydown",h),d&&typeof d.focus=="function"&&document.contains(d)&&d.focus({preventScroll:!0})}},[]),typeof document>"u"?null:Ge.createPortal(o.jsx("div",{"data-mode":i,"data-brand":l,onClick:r,style:{position:"fixed",inset:0,background:"rgba(0, 0, 0, 0.5)",backdropFilter:"blur(2px)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center",padding:24,fontFamily:"inherit",colorScheme:i==="light"?"light":"dark"},children:o.jsxs("div",{ref:c,role:"dialog","aria-modal":"true","aria-labelledby":e,tabIndex:-1,onClick:d=>d.stopPropagation(),style:{width:a,maxWidth:"100%",maxHeight:"100%",display:"flex",flexDirection:"column",background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRadius:10,boxShadow:"0 12px 40px rgba(0, 0, 0, 0.28)",outline:"none"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"14px 18px",borderBottom:"1px solid var(--border-primary)"},children:[o.jsx("h2",{id:e,style:{margin:0,flex:1,fontSize:15,fontWeight:700,color:"var(--text-primary)"},children:t}),o.jsx("button",{type:"button",onClick:r,"aria-label":"关闭",title:"关闭 (Esc)",style:{background:"transparent",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:16,lineHeight:1,padding:4},children:"✕"})]}),o.jsx("div",{style:{padding:18,overflowY:"auto",flex:1},children:n}),s&&o.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,justifyContent:"flex-end",padding:"12px 18px",borderTop:"1px solid var(--border-primary)"},children:s})]})}),document.body)}const qe={display:"block",fontSize:12,fontWeight:600,color:"var(--text-secondary)",marginBottom:4},et={width:"100%",boxSizing:"border-box",height:32,padding:"0 8px",background:"var(--bg-primary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRadius:6,fontSize:13,fontFamily:"inherit"},pt={fontSize:11,color:"var(--text-muted)",marginTop:4},Jc={fontSize:12,color:"var(--color-error)",margin:"4px 0 0"},Zx={height:32,padding:"0 14px",borderRadius:6,fontSize:13,fontWeight:600,fontFamily:"inherit",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},ur={...Zx,background:"var(--color-accent)",color:"var(--color-accent-text)",border:"1px solid var(--color-accent)"},Mt={...Zx,background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-primary)"};function pr(e,t){return t?{...e,opacity:.5,cursor:"not-allowed"}:e}const dn=e=>({padding:"8px 10px",borderRadius:6,fontSize:12,lineHeight:1.5,color:"var(--text-primary)",background:"var(--bg-primary)",border:`1px solid var(--color-${e})`}),E_=["L1","L2","L3"],R_={L1:"L1 最上层,可调用 L2 / L3",L2:"L2 中间层,可调用 L3",L3:"L3 最底层,原子能力"},P_=["custom","std"];function Qx({products:e,domains:t,trial:r,value:n,onChange:s,disabled:a}){const i=I.useId(),[l,c]=I.useState(!1),u=I.useMemo(()=>({...n,type:r?"tmp":n.type==="std"?"std":"custom"}),[n,r]),d=dr(u),h=I.useMemo(()=>Uc(u,t&&t.length>0?t:void 0),[u,t]).filter(b=>l||n.func.trim()!==""||b.indexOf("功能不能为空")<0),f=Ux(n.func),m=n.func.trim()!==""&&f!==""&&f!==n.func.trim(),y=b=>s({...u,...b}),v=e.find(b=>b.name===n.product),g=b=>`${i}-${b}`,x={minWidth:0};return o.jsxs("div",{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:12},children:[o.jsxs("div",{style:x,children:[o.jsx("label",{htmlFor:g("type"),style:qe,children:"类型"}),r?o.jsx("select",{id:g("type"),value:"tmp",disabled:!0,style:{...et,opacity:.7},"aria-describedby":g("type-hint"),children:o.jsx("option",{value:"tmp",children:"tmp(临时)"})}):o.jsx("select",{id:g("type"),value:u.type,disabled:a,onChange:b=>y({type:b.target.value}),style:et,"aria-describedby":g("type-hint"),children:P_.map(b=>o.jsx("option",{value:b,children:b==="custom"?"custom(自定义)":"std(通用)"},b))}),o.jsx("div",{id:g("type-hint"),style:pt,children:r?"试用环境固定为临时流程,会被定期清理":"生产环境可选自定义或通用"})]}),o.jsxs("div",{style:x,children:[o.jsx("label",{htmlFor:g("level"),style:qe,children:"层级"}),o.jsx("select",{id:g("level"),value:u.level,disabled:a,onChange:b=>y({level:b.target.value}),style:et,"aria-describedby":g("level-hint"),children:E_.map(b=>o.jsx("option",{value:b,children:b},b))}),o.jsx("div",{id:g("level-hint"),style:pt,children:R_[u.level]})]}),o.jsxs("div",{style:x,children:[o.jsx("label",{htmlFor:g("product"),style:qe,children:"产品"}),o.jsxs("select",{id:g("product"),value:v?v.name:"",disabled:a||e.length===0,onChange:b=>{const k=e.find(S=>S.name===b.target.value);y({product:k?.name??"",domain:k?.domain??""})},style:et,"aria-describedby":g("product-hint"),children:[o.jsx("option",{value:"",children:e.length===0?"暂无产品":"请选择产品"}),e.map(b=>o.jsxs("option",{value:b.name,children:[b.name,b.status==="PENDING"?"(待生效)":""]},b.name))]}),o.jsx("div",{id:g("product-hint"),style:pt,children:"来自「我的产品」"})]}),o.jsxs("div",{style:x,children:[o.jsx("label",{htmlFor:g("domain"),style:qe,children:"业务域"}),o.jsx("input",{id:g("domain"),value:v?v.domain:n.domain,readOnly:!0,style:{...et,opacity:.8},placeholder:"随产品带出","aria-describedby":g("domain-hint")}),o.jsx("div",{id:g("domain-hint"),style:pt,children:"由所选产品决定"})]}),o.jsxs("div",{style:{...x,gridColumn:"1 / -1"},children:[o.jsx("label",{htmlFor:g("func"),style:qe,children:"功能"}),o.jsx("input",{id:g("func"),value:n.func,disabled:a,onChange:b=>y({func:b.target.value}),onBlur:()=>c(!0),placeholder:"例如 create_vm(推荐小写 snake_case)",style:et,"aria-describedby":g("func-hint"),"aria-invalid":l&&n.func.trim()===""}),o.jsxs("div",{id:g("func-hint"),style:pt,children:["说明这个流程做什么,用 snake_case 更易检索",m&&o.jsxs(o.Fragment,{children:[" · 建议:",o.jsx("button",{type:"button",disabled:a,onClick:()=>y({func:f}),style:{background:"none",border:"none",padding:0,color:"var(--color-accent)",cursor:"pointer",fontSize:11,fontFamily:"inherit",textDecoration:"underline"},children:f})]})]})]})]}),o.jsxs("div",{style:{marginTop:14},children:[o.jsx("div",{style:qe,children:"完整名称预览"}),o.jsx("code",{"aria-live":"polite","data-testid":"name-preview",style:{display:"block",padding:"8px 10px",borderRadius:6,background:"var(--bg-primary)",border:"1px solid var(--border-primary)",color:"var(--text-primary)",fontSize:13,wordBreak:"break-all"},children:d}),h.length>0&&o.jsx("ul",{role:"alert",style:{margin:"6px 0 0",paddingLeft:18},children:h.map(b=>o.jsx("li",{style:Jc,children:b},b))})]})]})}const eb={blank:{title:"空白流程",desc:"从一个空画布开始,自己添加步骤"},template:{title:"从模板中心开始",desc:"选择场景模板,按向导填空即可得到可用流程"},import:{title:"从接口导入",desc:"粘贴 OpenAPI / Postman / curl,把已有接口变成步骤"}};function O_(e){return e instanceof Error&&e.message?e.message:"请求失败,请稍后重试"}function tb({provider:e,trialEnabled:t,products:r,domains:n,defaultLevel:s="L2",ownerEmail:a,onClose:i,onCreate:l,onTrialStarted:c,onPickTemplate:u,onImportApi:d}){const p=I.useId(),h=I.useId(),[f,m]=I.useState("product"),[y,v]=I.useState([]),g=I.useMemo(()=>{const W=y.filter(U=>!r.some($=>$.name===U.name));return[...r,...W]},[r,y]),x=I.useMemo(()=>({trial:t,products:g}),[t,g]),[b,k]=I.useState(()=>w_({trial:t,products:r},s)),[S,C]=I.useState(!1),[T,N]=I.useState(null),[w,_]=I.useState(null),j=I.useCallback(W=>{k(U=>({...U,...W})),N(null),_(null)},[]),P=N_({hasTemplate:!!u,hasImport:!!d}),E=Gx(b,x,n),A=T_(f,b,x,n),L=wt.indexOf(f),B=I.useCallback(async()=>{if(b.productMode==="existing"){m("naming");return}C(!0),N(null),_(null);try{const W=await e.startTrial({productName:b.productName.trim(),domain:b.domain,systemCode:b.systemCode.trim()||void 0});if(W.status==="conflict"){_(W.owners);return}v(U=>[...U.filter($=>$.name!==W.product.name),W.product]),k(U=>({...U,productMode:"existing",productName:W.product.name,domain:W.product.domain})),c?.(W.product),m("naming")}catch(W){N(O_(W))}finally{C(!1)}},[b.productMode,b.productName,b.domain,b.systemCode,e,c]),z=I.useCallback(()=>{const W=dr(cn(b,t)),U=Kx({name:W,description:b.description,ownerEmail:a});l({def:U,level:b.level,source:b.source}),i(),b.source==="template"?u?.():b.source==="import"&&d?.()},[b,t,a,l,i,u,d]),R=()=>{S||!A||(f==="product"?B():m(I_(f)))},q=f==="start",M=f==="product"&&b.productMode==="new"?"登记并继续":"下一步",O=o.jsxs(o.Fragment,{children:[L>0&&o.jsx("button",{type:"button",style:pr(Mt,S),disabled:S,onClick:()=>m(C_(f)),children:"上一步"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{type:"button",style:Mt,onClick:i,children:"取消"}),q?o.jsx("button",{type:"button",style:ur,onClick:z,children:"创建流程"}):o.jsx("button",{type:"button",style:pr(ur,S||!A),disabled:S||!A,onClick:R,children:S?"处理中…":M})]});return o.jsxs(Xx,{titleId:p,title:"新建流程",onClose:i,footer:O,width:600,children:[o.jsx("ol",{"aria-label":"步骤",style:{display:"flex",gap:8,listStyle:"none",padding:0,margin:"0 0 16px"},children:wt.map((W,U)=>{const $=W===f,H=U<L;return o.jsxs("li",{"aria-current":$?"step":void 0,style:{flex:1,textAlign:"center",padding:"6px 0",fontSize:12,fontWeight:$?700:500,borderRadius:6,color:$?"var(--color-accent-text)":H?"var(--color-success)":"var(--text-muted)",background:$?"var(--color-accent)":"var(--bg-primary)",border:"1px solid var(--border-primary)"},children:[U+1,". ",S_[W],H?" ✓":""]},W)})}),f==="product"&&o.jsxs("div",{children:[o.jsxs("div",{style:{marginBottom:12},children:[o.jsx("label",{htmlFor:`${h}-pm`,style:qe,children:"所属产品"}),o.jsxs("select",{id:`${h}-pm`,value:b.productMode==="new"?"__new__":b.productName,disabled:S,onChange:W=>{const U=W.target.value;if(U==="__new__")j({productMode:"new",productName:"",domain:""});else{const $=g.find(H=>H.name===U);j({productMode:"existing",productName:U,domain:$?.domain??""})}},style:et,children:[g.length===0&&b.productMode==="existing"&&o.jsx("option",{value:"",children:"暂无产品"}),g.map(W=>o.jsxs("option",{value:W.name,children:[W.name,"(",W.domain,")"]},W.name)),t&&o.jsx("option",{value:"__new__",children:"+ 登记新产品(开始试用)"})]}),!t&&g.length===0&&o.jsx("p",{style:{...Jc,marginTop:6},children:"当前环境不开放自助试用,且你还没有所属产品,请联系平台管理员。"})]}),b.productMode==="new"&&o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12},children:[o.jsxs("div",{children:[o.jsx("label",{htmlFor:`${h}-pn`,style:qe,children:"产品名称"}),o.jsx("input",{id:`${h}-pn`,value:b.productName,disabled:S,onChange:W=>j({productName:W.target.value}),placeholder:"例如 ecs(不含 -)",style:et})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:`${h}-pd`,style:qe,children:"业务域"}),o.jsxs("select",{id:`${h}-pd`,value:b.domain,disabled:S,onChange:W=>j({domain:W.target.value}),style:et,children:[o.jsx("option",{value:"",children:"请选择业务域"}),n.map(W=>o.jsx("option",{value:W,children:W},W))]})]}),o.jsxs("div",{style:{gridColumn:"1 / -1"},children:[o.jsx("label",{htmlFor:`${h}-ps`,style:qe,children:"系统编码(可选)"}),o.jsx("input",{id:`${h}-ps`,value:b.systemCode,disabled:S,onChange:W=>j({systemCode:W.target.value}),style:et}),o.jsx("div",{style:pt,children:"登记后你自动成为该产品的负责人,可以马上开始试用。"})]})]}),b.productMode==="new"&&b.productName!==""&&E&&o.jsx("p",{style:Jc,children:E}),w&&o.jsxs("div",{role:"alert",style:{...dn("warning"),marginTop:12},children:["产品「",b.productName.trim(),"」已存在,请联系负责人把你加入该产品:",o.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18},children:w.map(W=>o.jsx("li",{children:W.name},W.id))})]})]}),f==="naming"&&o.jsxs("div",{children:[o.jsx(Qx,{products:g,domains:n,trial:t,value:cn(b,t),onChange:W=>j({type:W.type,level:W.level,domain:W.domain,productName:W.product,func:W.func})}),o.jsxs("div",{style:{marginTop:14},children:[o.jsx("label",{htmlFor:`${h}-desc`,style:qe,children:"流程说明(可选)"}),o.jsx("textarea",{id:`${h}-desc`,value:b.description,onChange:W=>j({description:W.target.value}),rows:3,placeholder:"一句话说明这个流程做什么,会写入流程描述",style:{...et,height:"auto",padding:8,resize:"vertical"}})]})]}),f==="start"&&o.jsxs("fieldset",{style:{border:"none",padding:0,margin:0},children:[o.jsx("legend",{style:qe,children:"选择起点"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:P.map(W=>{const U=b.source===W;return o.jsxs("label",{style:{display:"flex",gap:10,alignItems:"flex-start",padding:"10px 12px",borderRadius:8,cursor:"pointer",background:U?"var(--color-accent-bg)":"var(--bg-primary)",border:`1px solid ${U?"var(--color-accent)":"var(--border-primary)"}`},children:[o.jsx("input",{type:"radio",name:`${h}-src`,checked:U,onChange:()=>j({source:W}),style:{marginTop:3}}),o.jsxs("span",{children:[o.jsx("span",{style:{display:"block",fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:eb[W].title}),o.jsx("span",{style:{display:"block",fontSize:12,color:"var(--text-secondary)"},children:eb[W].desc})]})]},W)})}),o.jsxs("div",{style:{marginTop:12,fontSize:12,color:"var(--text-secondary)"},children:["将创建:",o.jsx("code",{style:{color:"var(--text-primary)"},children:dr(cn(b,t))})]})]}),T&&o.jsxs("div",{role:"alert",style:{...dn("error"),marginTop:12,display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{flex:1},children:T}),o.jsx("button",{type:"button",style:pr(Mt,S),disabled:S,onClick:R,children:"重试"})]})]})}const A_=2e3,D_=3e4;function rb(e){const t=Number.isFinite(e)&&e>0?Math.floor(e):0;return Math.min(D_,A_*Math.pow(2,Math.min(t,10)))}function Vc(e){return e==="APPROVED"||e==="REJECTED"||e==="SYNCED"}const nb={SUBMITTED:"已提交",REVIEWING:"审批中",APPROVED:"审批通过",REJECTED:"已驳回",SYNCED:"已同步到生产"};function L_(e){return nb[e]}function ob(e){const t=e==="REJECTED"?["SUBMITTED","REVIEWING","REJECTED"]:["SUBMITTED","REVIEWING","APPROVED","SYNCED"],r=e?t.indexOf(e):-1;return t.map((n,s)=>{let a;return n==="REJECTED"&&e==="REJECTED"?a="failed":r===s?a=Vc(n)?"done":"current":s<r?a="done":a="pending",{state:n,label:nb[n],status:a}})}function un(){const e=new Error("已取消");return e.name="AbortError",e}function ab(e){return!!e&&typeof e=="object"&&e.name==="AbortError"}function M_(e,t){return t?.aborted?Promise.reject(un()):new Promise((r,n)=>{const s=()=>{clearTimeout(a),n(un())},a=setTimeout(()=>{t?.removeEventListener("abort",s),r()},e);t?.addEventListener("abort",s,{once:!0})})}async function sb(e){const t=e.sleep??M_;let r=0;for(;;){if(e.signal?.aborted)throw un();const n=await e.provider.getPromotion(e.requestId,e.signal);if(e.signal?.aborted)throw un();if(e.onUpdate?.(n),Vc(n.state))return n;await t(rb(r),e.signal),r+=1}}const $_=[{value:"custom",title:"custom(自定义)",desc:"仅本产品使用的流程"},{value:"std",title:"std(通用)",desc:"面向多个产品复用的通用能力,审批更严格"}];function ib(e){return e instanceof Error&&e.message?e.message:"请求失败,请稍后重试"}const lb={done:"var(--color-success)",current:"var(--color-accent)",failed:"var(--color-error)",pending:"var(--text-muted)"};function cb({provider:e,workflowName:t,version:r,onClose:n,onRequested:s,onStateChange:a}){const i=I.useId(),[l,c]=I.useState("custom"),[u,d]=I.useState(null),[p,h]=I.useState(null),[f,m]=I.useState(!1),[y,v]=I.useState(!1),[g,x]=I.useState(null),b=I.useRef(null),k=I.useRef(null),S=I.useRef({onRequested:s,onStateChange:a});S.current={onRequested:s,onStateChange:a};const C=Jx(t,l);I.useEffect(()=>()=>b.current?.abort(),[]);const T=I.useCallback(async P=>{b.current?.abort();const E=new AbortController;b.current=E,v(!0),x(null);try{await sb({provider:e,requestId:P,signal:E.signal,onUpdate:A=>{h(A),k.current!==A.state&&(k.current=A.state,S.current.onStateChange?.(A.state))}})}catch(A){ab(A)||x(ib(A))}finally{b.current===E&&v(!1)}},[e]),N=async()=>{if(!(f||!C)){m(!0),x(null);try{const{requestId:P}=await e.requestPromotion({workflowName:t,version:r,targetType:l});d(P),S.current.onRequested?.(l),T(P)}catch(P){x(ib(P))}finally{m(!1)}}},w=u!==null,_=ob(p?p.state:w?"SUBMITTED":null),j=w?o.jsx("button",{type:"button",style:ur,onClick:n,children:"关闭"}):o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",style:Mt,onClick:n,children:"取消"}),o.jsx("button",{type:"button",style:pr(ur,f||!C),disabled:f||!C,onClick:()=>{N()},children:f?"提交中…":"提交申请"})]});return o.jsxs(Xx,{titleId:i,title:"申请上线",onClose:n,footer:j,width:520,children:[o.jsxs("div",{style:{fontSize:12,color:"var(--text-secondary)",marginBottom:12},children:["当前流程:",o.jsx("code",{style:{color:"var(--text-primary)"},children:t}),"(版本 ",r,")"]}),!w&&o.jsxs("fieldset",{style:{border:"none",padding:0,margin:0},children:[o.jsx("legend",{style:qe,children:"上线为"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:$_.map(P=>{const E=l===P.value;return o.jsxs("label",{style:{display:"flex",gap:10,alignItems:"flex-start",padding:"10px 12px",borderRadius:8,cursor:"pointer",background:E?"var(--color-accent-bg)":"var(--bg-primary)",border:`1px solid ${E?"var(--color-accent)":"var(--border-primary)"}`},children:[o.jsx("input",{type:"radio",name:"promotion-target",checked:E,onChange:()=>c(P.value),style:{marginTop:3}}),o.jsxs("span",{children:[o.jsx("span",{style:{display:"block",fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:P.title}),o.jsx("span",{style:{display:"block",fontSize:12,color:"var(--text-secondary)"},children:P.desc})]})]},P.value)})})]}),o.jsxs("div",{style:{marginTop:14},children:[o.jsx("div",{style:qe,children:"正式名称预览"}),o.jsx("code",{style:{display:"block",padding:"8px 10px",borderRadius:6,background:"var(--bg-primary)",border:"1px solid var(--border-primary)",color:"var(--text-primary)",fontSize:13,wordBreak:"break-all"},children:p?.targetName??C??"(流程名称不符合规范,无法申请)"}),!w&&o.jsx("div",{style:pt,children:"审批通过后,临时流程会以正式名称同步到生产环境。"})]}),w&&o.jsxs("div",{style:{marginTop:16},children:[o.jsx("div",{style:qe,children:"审批进度"}),o.jsx("ol",{"aria-label":"审批进度",style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:8},children:_.map(P=>o.jsxs("li",{"aria-current":P.status==="current"?"step":void 0,style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:P.status==="pending"?"var(--text-muted)":"var(--text-primary)"},children:[o.jsx("span",{"aria-hidden":"true",style:{width:10,height:10,borderRadius:"50%",background:P.status==="pending"?"transparent":lb[P.status],border:`2px solid ${lb[P.status]}`,flexShrink:0}}),o.jsx("span",{children:P.label}),P.status==="current"&&y&&o.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:"进行中…"}),P.status==="failed"&&o.jsx("span",{style:{fontSize:11,color:"var(--color-error)"},children:"未通过"})]},P.state))}),p?.comment&&o.jsxs("div",{role:"status",style:{...dn(p.state==="REJECTED"?"error":"success"),marginTop:12},children:["审批意见:",p.comment]}),p?.state==="REJECTED"&&o.jsx("div",{style:pt,children:"修改流程后可重新申请上线。"})]}),g&&o.jsxs("div",{role:"alert",style:{...dn("error"),marginTop:12,display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{flex:1},children:g}),o.jsx("button",{type:"button",style:pr(Mt,f||y),disabled:f||y,onClick:()=>u?void T(u):void N(),children:"重试"})]})]})}function db({onStart:e,onDismiss:t}){return o.jsxs("div",{role:"region","aria-label":"开始试用引导",style:{maxWidth:420,padding:"24px 28px",textAlign:"center",background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRadius:12,boxShadow:"0 8px 28px rgba(0, 0, 0, 0.18)"},children:[o.jsx("div",{"aria-hidden":"true",style:{fontSize:32,marginBottom:8},children:"🚀"}),o.jsx("h3",{style:{margin:"0 0 6px",fontSize:16,fontWeight:700},children:"开始试用编排平台"}),o.jsx("p",{style:{margin:"0 0 16px",fontSize:13,lineHeight:1.6,color:"var(--text-secondary)"},children:"登记你的产品、按规范命名,几分钟内就能在测试环境建出第一个流程,试跑通过后再申请上线。"}),o.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"center"},children:[o.jsx("button",{type:"button",style:ur,onClick:e,children:"开始试用"}),t&&o.jsx("button",{type:"button",style:Mt,onClick:t,children:"暂不使用"})]})]})}function z_(e){const[t,r]=I.useState({status:"idle",context:null,domains:[],products:[],error:null}),[n,s]=I.useState(0);I.useEffect(()=>{if(!e){r({status:"idle",context:null,domains:[],products:[],error:null});return}const l=new AbortController;return r(c=>({...c,status:"loading",error:null})),Promise.all([e.getContext(l.signal),e.listDomains(l.signal),e.listMyProducts(l.signal)]).then(([c,u,d])=>{l.signal.aborted||r({status:"ready",context:c,domains:u,products:d,error:null})},c=>{l.signal.aborted||ab(c)||r(u=>({...u,status:"error",error:c instanceof Error&&c.message?c.message:"加载自助接入信息失败"}))}),()=>l.abort()},[e,n]);const a=I.useCallback(()=>s(l=>l+1),[]),i=I.useCallback(l=>{r(c=>c.products.some(u=>u.name===l.name)?c:{...c,products:[...c.products,l]})},[]);return{...t,reload:a,addProduct:i}}function q_(e){const{provider:t,track:r,disabled:n,onPickTemplate:s,onImportApi:a,ownerEmail:i}=e,l=z_(t),{addProduct:c}=l,[u,d]=I.useState(!1),[p,h]=I.useState(!1),[f,m]=I.useState(void 0),[y,v]=I.useState(!1),g=I.useRef(null),x=oe(w=>w.workflowDef?.name),b=oe(w=>!!w.workflowDef);I.useEffect(()=>{d(!1),h(!1),m(void 0),v(!1),g.current=null},[t]);const k=!!t&&!n,S=I.useCallback(w=>{const _=oe.getState();_.setWorkflow(w.def),_.setMode("edit"),oe.temporal.getState().clear(),m(w.level),g.current=w.source==="blank"?null:{name:w.def.name,description:w.def.description??"",ownerEmail:w.def.ownerEmail},r("workflow_created",{level:w.level,source:w.source})},[r]),C=I.useCallback(w=>{c(w),r("trial_started",{domain:w.domain})},[c,r]),T=l.context?.trialEnabled===!0,N=k&&l.status==="ready"&&T&&l.products.length===0&&!b&&!y&&!u;return{enabled:k,data:l,level:f,wizardOpen:u,promoOpen:p,openWizard:()=>{g.current=null,d(!0)},openPromotion:()=>h(!0),canPromote:k&&b&&Vx(x),showGuide:N,dismissGuide:()=>v(!0),takePendingIdentity:()=>{const w=g.current;return g.current=null,w},provider:t,close:()=>{d(!1),h(!1)},handleCreate:S,handleTrialStarted:C,onPickTemplate:s,onImportApi:a,ownerEmail:i,track:r}}const Kc=(e,t)=>({height:28,padding:"0 10px",background:e?"var(--color-accent-bg)":"transparent",color:e?"var(--color-accent)":"var(--text-secondary)",border:`1px solid ${e?"var(--color-accent)":"var(--border-primary)"}`,borderRadius:6,cursor:t?"not-allowed":"pointer",opacity:t?.55:1,fontSize:12,fontWeight:600,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"});function W_({c:e}){if(!e.enabled)return null;const{status:t}=e.data,r=t==="ready";return o.jsxs(o.Fragment,{children:[t==="error"&&o.jsx("button",{type:"button",style:Kc(!1,!1),onClick:e.data.reload,title:e.data.error??"加载自助接入信息失败",children:"自助接入加载失败 · 重试"}),o.jsxs("button",{type:"button",style:Kc(!0,!r),disabled:!r,onClick:e.openWizard,title:r?"按命名规范新建流程(选择产品 → 命名 → 起点)":t==="loading"?"正在加载自助接入信息…":"自助接入暂不可用",children:[o.jsx("span",{"aria-hidden":"true",children:"+"}),o.jsx("span",{children:"新建流程"})]}),o.jsxs("button",{type:"button",style:Kc(!1,!e.canPromote),disabled:!e.canPromote,onClick:e.openPromotion,title:e.canPromote?"把当前临时流程申请上线到生产":"仅类型为 tmp 的临时流程可以申请上线",children:[o.jsx("span",{"aria-hidden":"true",children:"🚀"}),o.jsx("span",{children:"申请上线"})]})]})}function F_({c:e}){const t=oe(a=>a.workflowDef?.name),r=oe(a=>a.workflowDef?.version),{provider:n,data:s}=e;return!n||!e.enabled?null:o.jsxs(o.Fragment,{children:[e.wizardOpen&&s.context&&o.jsx(tb,{provider:n,trialEnabled:s.context.trialEnabled,products:s.products,domains:s.domains,defaultLevel:e.level,ownerEmail:e.ownerEmail,onClose:e.close,onCreate:e.handleCreate,onTrialStarted:e.handleTrialStarted,onPickTemplate:e.onPickTemplate,onImportApi:e.onImportApi}),e.promoOpen&&t&&o.jsx(cb,{provider:n,workflowName:t,version:r??1,onClose:e.close,onRequested:a=>e.track("promotion_requested",{targetType:a}),onStateChange:a=>e.track("promotion_state",{state:a})})]})}function B_({c:e}){return e.showGuide?o.jsx("div",{style:{position:"absolute",inset:0,zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",padding:24,pointerEvents:"none",background:"color-mix(in srgb, var(--bg-primary) 82%, transparent)"},children:o.jsx("div",{style:{pointerEvents:"auto"},children:o.jsx(db,{onStart:e.openWizard,onDismiss:e.dismissGuide})})}):null}const ub=I.forwardRef(({workflowDef:e,readOnly:t=!1,theme:r="dark",themeColor:n="blue",layoutDirection:s="LR",searchQuery:a="",workflowExecution:i,onRequestImport:l,executionActions:c,aiConfig:u,viewMode:d="developer",uiMode:p="pro",actions:h,libraryProvider:f,providers:m,currentWorkflowLevel:y,onSave:v,onWorkflowChange:g,height:x="100%",onTriggerExecution:b,onPollExecution:k,executionPollInterval:S=3e3},C)=>{const T=bw(m,{library:f}),N=T.library,w=Tw("workflow",T.telemetry);Iw(w),Cw(w);const _=I.useMemo(()=>{if(v)return X=>{w("workflow_saved"),v(X)}},[v,w]),j=I.useCallback(X=>{w("step_added",{source:X.source})},[w]),P=I.useCallback(X=>{w("sandbox_run",{result:X,entry:"business"})},[w]),E=I.useCallback(X=>{w("sandbox_run",{result:X,entry:"template"})},[w]),[A,L]=I.useState("card"),[B,z]=I.useState(!1),[R,q]=I.useState(!1),[M,O]=I.useState([]),W=q_({provider:T.onboarding,track:w,disabled:t||!!i,onPickTemplate:()=>z(!0),onImportApi:()=>q(!0)}),U=y??W.level,[$]=I.useState(()=>new Dy);Vy($,N);const H=tn($),K=I.useMemo(()=>{const X=N?Wy($):[];if((!h||h.length===0)&&X.length===0&&M.length===0)return De;const le=new Jr(De.getAllActions());h&&le.registerAll(h),le.registerAll(M);for(const de of X)le.unregister(de.id),le.register(de);return le},[h,M,N,$,H.revision]),{setWorkflow:V,setWorkflowDefOnly:te,refreshGraph:ue,graphStale:ye,setTheme:_e,setThemeColor:Ne,setLayoutDirection:J,setNodesLocked:Se,selectedTask:ne,setSelectedTask:xe,edgeType:ie,importExecutionJSON:je,setMode:me,setViewMode:ge,isDetailPanelOpen:Fe,setIsDetailPanelOpen:Te,selectTaskAction:be,workflowDef:Re,isSimRunning:Ee,startSimulation:nt,stopSimulation:Z,mode:ee,setShowRunPanel:ae,showAnalysisPanel:pe,setShowAnalysisPanel:Q,executionData:fe,workflowInstance:D}=oe(ke(X=>({setWorkflow:X.setWorkflow,setWorkflowDefOnly:X.setWorkflowDefOnly,refreshGraph:X.refreshGraph,graphStale:X.graphStale,setTheme:X.setTheme,setThemeColor:X.setThemeColor,setLayoutDirection:X.setLayoutDirection,setNodesLocked:X.setNodesLocked,selectedTask:X.selectedTask,setSelectedTask:X.setSelectedTask,edgeType:X.edgeType,importExecutionJSON:X.importExecutionJSON,setMode:X.setMode,setViewMode:X.setViewMode,isDetailPanelOpen:X.isDetailPanelOpen,setIsDetailPanelOpen:X.setIsDetailPanelOpen,selectTaskAction:X.selectTaskAction,workflowDef:X.workflowDef,isSimRunning:X.isSimRunning,startSimulation:X.startSimulation,stopSimulation:X.stopSimulation,mode:X.mode,setShowRunPanel:X.setShowRunPanel,showAnalysisPanel:X.showAnalysisPanel,setShowAnalysisPanel:X.setShowAnalysisPanel,executionData:X.executionData,workflowInstance:X.workflowInstance}))),Y=I.useCallback(()=>{if(!Re)return;const X=new Blob([JSON.stringify(Re,null,2)],{type:"application/json"}),le=URL.createObjectURL(X),de=document.createElement("a");de.href=le,de.download=`${Re.name||"workflow"}.json`,de.click(),URL.revokeObjectURL(le)},[Re]),ce=I.useCallback(()=>{Re&&navigator.clipboard.writeText(JSON.stringify(Re,null,2))},[Re]);I.useEffect(()=>{_e(r),Ne(n),J(s),Se(t||!!i)},[r,n,s,t,i,_e,Ne,J,Se]),I.useEffect(()=>{ge(i?"developer":d)},[d,i,ge]),I.useEffect(()=>{e&&(V(e,s),oe.temporal.getState().clear())},[e,V,s]),I.useEffect(()=>{i?je(i):me(t?"view":"edit")},[i,je,me,t]),I.useImperativeHandle(C,()=>({getWorkflowDef:()=>oe.getState().workflowDef,getValidationResults:()=>oe.getState().validationResults,save:()=>{const X=oe.getState().workflowDef;X&&_&&_(X)},createBlankWorkflow:X=>{oe.getState().createBlankWorkflow(X),oe.temporal.getState().clear()},openApiImport:()=>q(!0)}),[_]),I.useEffect(()=>{if(!g)return;let X=!0,le=oe.getState().workflowDef;return oe.subscribe(Ie=>{const we=Ie.workflowDef;if(we!==le){if(le=we,X){X=!1;return}we&&g(we)}})},[g]);const se=p==="business"&&A==="card";I.useEffect(()=>{!se&&ye&&ue()},[se,ye,ue]);const re=I.useCallback((X,le)=>{if(X.length===0)return;const de=new Set(X.map(we=>we.id));O(we=>[...we.filter(Ae=>!de.has(Ae.id)),...X]);const Ie=Bx(oe.getState().workflowDef,X);se?te(Ie):V(Ie,s),w("api_imported",{format:le.format,count:le.count});for(let we=0;we<X.length;we++)w("step_added",{source:"import"})},[se,te,V,s,w]),ve=X=>{ee!=="run"&&!i?be(X,!0):xe(X)};return o.jsxs("div",{className:`workflow-ide ${r==="light"?"light-theme":""}`,"data-mode":r,"data-brand":n,style:{width:"100%",height:x,display:"flex",flexDirection:"column",position:"relative",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderBottom:"1px solid var(--border)",background:"var(--bg-primary)",flexShrink:0,flexWrap:"wrap"},children:[p==="business"&&ee!=="run"&&o.jsxs("div",{style:{display:"inline-flex",background:"rgba(255, 255, 255, 0.06)",borderRadius:6,padding:2,border:"1px solid var(--border-secondary)"},children:[o.jsx("button",{onClick:()=>L("card"),style:{height:24,padding:"0 8px",borderRadius:4,border:"none",background:A==="card"?"var(--color-accent)":"transparent",color:A==="card"?"#fff":"var(--text-secondary)",cursor:"pointer",fontSize:11,fontWeight:500,display:"inline-flex",alignItems:"center",gap:4},children:"📋 业务卡片流"}),o.jsx("button",{onClick:()=>L("canvas"),style:{height:24,padding:"0 8px",borderRadius:4,border:"none",background:A==="canvas"?"var(--color-accent)":"transparent",color:A==="canvas"?"#fff":"var(--text-secondary)",cursor:"pointer",fontSize:11,fontWeight:500,display:"inline-flex",alignItems:"center",gap:4},children:"🕸️ 全景画布"})]}),o.jsx("div",{style:{flex:1}}),ee==="edit"&&!t&&o.jsxs("button",{onClick:()=>q(!0),style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-secondary)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"从 OpenAPI / Swagger / Postman / curl 导入接口,生成 HTTP 步骤",children:[o.jsx("span",{children:"🔌"}),o.jsx("span",{children:"导入接口"})]}),ee!=="run"&&o.jsx(W_,{c:W}),ee!=="run"&&o.jsxs("button",{onClick:()=>z(!0),style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--color-brand-blue) 15%, transparent)",color:"var(--color-brand-blue)",border:"1px solid color-mix(in srgb, var(--color-brand-blue) 40%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:600,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"打开场景化工作流模板中心",children:[o.jsx("span",{children:"📁"}),o.jsx("span",{children:"模板中心"})]}),ee==="edit"&&Re&&o.jsxs("button",{onClick:()=>ae(!0),style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--color-accent) 15%, transparent)",color:"var(--color-accent)",border:"1px solid color-mix(in srgb, var(--color-accent) 40%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:600,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"填写工作流入参并触发真实执行",children:[o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4 3l9 5-9 5z"})}),"执行验证"]}),ee==="run"&&fe&&o.jsxs("button",{onClick:()=>Q(!pe),style:{height:28,padding:"0 10px",background:pe?"color-mix(in srgb, var(--color-accent) 20%, transparent)":"transparent",color:pe?"var(--color-accent)":"var(--text-secondary)",border:`1px solid ${pe?"color-mix(in srgb, var(--color-accent) 40%, transparent)":"var(--border-strong)"}`,borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"查看执行概览与异常分析",children:[o.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",children:[o.jsx("rect",{x:"2",y:"2",width:"12",height:"12",rx:"2"}),o.jsx("path",{d:"M5 8h6M5 5h3M5 11h4"})]}),"分析"]}),ee!=="run"&&Re&&(Ee?o.jsxs("button",{onClick:Z,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-failed) 15%, transparent)",color:"var(--status-failed)",border:"1px solid color-mix(in srgb, var(--status-failed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"停止模拟",children:[o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("rect",{x:"4",y:"4",width:"8",height:"8",rx:"1"})}),"停止"]}):o.jsxs("button",{onClick:nt,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-completed) 15%, transparent)",color:"var(--status-completed)",border:"1px solid color-mix(in srgb, var(--status-completed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"模拟执行工作流",children:[o.jsx("svg",{width:"10",height:"10",viewBox:"0 0 16 16",fill:"currentColor",children:o.jsx("path",{d:"M4 3l9 5-9 5z"})}),"模拟运行"]})),Re&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:Y,style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-secondary)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"导出工作流 JSON 文件",children:[o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:o.jsx("path",{d:"M3 10v2.5a.5.5 0 0 0 .5.5h9a.5.5 0 0 0 .5-.5V10M5 7l3 3 3-3M8 2v8",strokeLinecap:"round",strokeLinejoin:"round"})}),"导出 JSON"]}),o.jsxs("button",{onClick:ce,style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-secondary)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"复制 Conductor DSL 到剪贴板",children:[o.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5",children:[o.jsx("rect",{x:"4",y:"4",width:"9",height:"10",rx:"1"}),o.jsx("path",{d:"M2 10V3a1 1 0 0 1 1-1h7",strokeLinecap:"round"})]}),"复制 DSL"]})]})]}),p==="business"&&A==="card"?o.jsx("div",{style:{flex:1,position:"relative",overflow:"hidden"},children:o.jsx(bx,{workflowDef:Re,workflowExecution:D??void 0,registry:K,libraryCatalog:N?$:void 0,currentWorkflowLevel:U,onStepAdded:j,onSandboxRun:P,readOnly:t||ee==="run",onChange:X=>{te(X)}})}):o.jsx("div",{className:"workflow-viewer",style:{flex:1,position:"relative",overflow:"hidden"},children:o.jsx(F.ReactFlowProvider,{children:o.jsx(OS,{onNodeClick:ve,edgeType:ie,theme:r,nodesLocked:t||ee==="run"||!!i,searchQuery:a,onSave:_,onRequestImport:l,executionActions:c})})}),o.jsx(WS,{task:ne,isOpen:Fe&&ee!=="run",onClose:()=>Te(!1),theme:r,aiConfig:u}),(i||ee==="run")&&o.jsx(HS,{executionActions:c}),o.jsx(ZS,{aiConfig:u}),o.jsx(ew,{onTriggerExecution:b,onPollExecution:k,executionPollInterval:S}),ee==="run"&&o.jsx(sw,{}),o.jsx(Fx,{open:R,onClose:()=>q(!1),onInsert:re,existingActionIds:R?K.getAllActions().map(X=>X.id):void 0}),o.jsx(kx,{isOpen:B,onClose:()=>{z(!1),W.takePendingIdentity()},onSandboxRun:E,onSelectTemplate:X=>{for(let de=0;de<(X.tasks?.length??0);de++)w("step_added",{source:"template"});const le=W.takePendingIdentity();V(le?{...X,name:le.name,description:le.description||X.description}:X,s)}}),o.jsx(F_,{c:W}),o.jsx(B_,{c:W})]})});ub.displayName="WorkflowIDE";const H_={workflows:"/metadata/workflow",workflow:"/metadata/workflow",taskDefs:"/metadata/taskdefs"};function Gc(e,t){return`${e.replace(/\/+$/,"")}/${t.replace(/^\/+/,"")}`}function U_(e){const t={...H_,...e.paths??{}},r=(i,l)=>{const c=e.fetch??(typeof fetch=="function"?fetch:void 0);return c?c(i,l):Promise.reject(new Error("当前环境没有 fetch,请通过 options.fetch 传入"))};async function n(i,l){const c=e.headers?await e.headers():{};return r(i,{method:"GET",headers:{Accept:"application/json",...c},signal:l})}function s(i){const l=e.resolveExtension?.(i);return{def:i,...l?{extension:l}:{},...l?.deprecated?{deprecated:!0}:{}}}function a(i,l){const c=encodeURIComponent(i),u=t.workflow.includes("{name}")?t.workflow.replace("{name}",c):`${t.workflow.replace(/\/+$/,"")}/${c}`,d=Gc(e.baseUrl,u);return l!==void 0?`${d}?version=${encodeURIComponent(String(l))}`:d}return{async list(i){const l=Gc(e.baseUrl,t.workflows),c=await n(l,i);if(!c.ok)throw new Error(`获取流程库列表失败:HTTP ${c.status}(${l})`);const u=await c.json();if(!Array.isArray(u))throw new Error(`流程库列表返回格式不正确(期望数组):${l}`);const d=new Map;for(const h of u){if(!h||typeof h.name!="string"||e.filter&&!e.filter(h))continue;const f=d.get(h.name);(!f||er(h.version).version>=er(f.version).version)&&d.set(h.name,h)}const p={workflows:Array.from(d.values()).map(s)};if(e.includeTaskDefs){const h=Gc(e.baseUrl,t.taskDefs),f=await n(h,i);if(!f.ok)throw new Error(`获取任务定义失败:HTTP ${f.status}(${h})`);const m=await f.json();if(!Array.isArray(m))throw new Error(`任务定义返回格式不正确(期望数组):${h}`);p.tasks=m.filter(y=>y&&typeof y.name=="string").map(y=>{const v=e.resolveTaskExtension?.(y);return{def:y,...v?{extension:v}:{}}})}return p},async get(i,l,c){const u=a(i,l),d=await n(u,c);if(d.status===404)return null;if(!d.ok)throw new Error(`获取流程库工作流「${i}」失败:HTTP ${d.status}(${u})`);const p=await d.json();return!p||typeof p.name!="string"||e.filter&&!e.filter(p)?null:s(p)}}}G.ActionForm=Cc,G.ActionRegistry=Jr,G.ApiImportDialog=Fx,G.BUILTIN_COMMON_ACTIONS=Py,G.BUILTIN_ECS_ACTIONS=Ry,G.BUILTIN_WORKFLOW_TEMPLATES=Ty,G.DataPillInput=Ic,G.DecisionBranchCard=Pc,G.ForkJoinCard=Nc,G.FriendlyErrorCard=yx,G.LibraryCatalog=Dy,G.LoopDoWhileCard=Ec,G.OTHER_DOMAIN=Qr,G.OnboardingGuideCard=db,G.OnboardingWizard=tb,G.PromotionPanel=cb,G.RunStoryTimeline=xx,G.StepFlowEditor=bx,G.TemplateExtractor=Cy,G.TemplateGallery=kx,G.TemplateSetupWizard=vx,G.TemplateStore=Iy,G.WORKFLOW_NAME_TYPES=Vr,G.WorkflowIDE=ub,G.WorkflowIdeProvider=yw,G.WorkflowNameBuilder=Qx,G.analyzeTasksForPruning=wy,G.appendImportedActions=Bx,G.applyTaskPruning=_y,G.applyTemplateVariables=Oc,G.applyUpgradeToValues=dx,G.buildActionFromTaskDef=Sc,G.buildActionFromWorkflowDef=kc,G.buildActionsFromLibrary=dw,G.buildActionsFromTaskDefs=uw,G.buildDataFlowGraph=Ag,G.buildDefaultWorkflowMockInput=Kt,G.buildHttpAction=zx,G.buildPromotionTimeline=ob,G.buildSkeletonWorkflow=Kx,G.buildUpgradeConfirmMessage=cx,G.buildWorkflowName=dr,G.canCallLevel=qy,G.collectLibraryDomains=Uy,G.collectReferencedOutputKeys=ix,G.compileStepModelToWorkflowDef=Zy,G.compileStepToTaskDef=Tc,G.createConductorLibraryProvider=U_,G.createStepFromAction=kt,G.createTelemetryBuffer=Xy,G.decompileTaskDefToStep=Qy,G.decompileWorkflowDefToStepModel=ex,G.defaultActionRegistry=De,G.defaultTemplateStore=gc,G.describeUnavailable=px,G.detectFormat=s_,G.diffWorkflowVersions=ax,G.entriesToLibraryItems=By,G.entryFromRecord=Gr,G.executeLocalSandboxDryRun=Gt,G.extractTemplateFromInstance=jy,G.filterPickableActions=Hy,G.generateDefaultTaskOutputPreview=$r,G.getCompletionItems=Og,G.getUpstreamAncestors=rc,G.inferTaskOutputSchema=Pg,G.isDiffEmpty=sx,G.isPromotableName=Vx,G.isTerminalPromotionState=Vc,G.libraryDomainOf=en,G.nextPollDelay=rb,G.normalizeVersion=er,G.parseApiText=Mx,G.parseCurl=Dx,G.parseOpenApi3=Rx,G.parsePostman21=Ax,G.parseSwagger2=Px,G.parseWorkflowInputParams=st,G.parseWorkflowName=Kr,G.pollPromotion=sb,G.promotionStateLabel=L_,G.promotionTargetName=Jx,G.refactorTaskReferenceName=Dg,G.resolveLibraryBadgeState=ux,G.resolveProviders=_c,G.sanitizeHeaders=Mc,G.scanObjectForSensitiveFindings=Hr,G.scanWorkflowDef=ky,G.schemaToTypeStrings=rr,G.stabilizeProviders=Gy,G.suggestFuncSlug=Ux,G.summarizeDiff=lx,G.toActionExtension=wc,G.toActions=Wy,G.toLibraryItems=hw,G.toTaskSchemas=fw,G.translateTechnicalError=gx,G.useIdeProviders=xw,G.useLibraryCatalogLoader=Vy,G.useLibraryCatalogSnapshot=tn,G.validateNameParts=Uc,G.validateWorkflowName=Ay,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})}));
|
|
288
|
+
注意:仅支持 JSON,YAML 请先转为 JSON 后再导入。`;function Q1(e){switch(e){case"GET":return"var(--color-info)";case"POST":return"var(--color-success)";case"PUT":case"PATCH":return"var(--color-warning)";case"DELETE":return"var(--color-error)";default:return"var(--text-secondary)"}}const aE='button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [href], [tabindex]:not([tabindex="-1"])',e0=e=>!e.open||typeof document>"u"?null:o.jsx(oE,{...e}),oE=({onClose:e,onInsert:t,existingActionIds:r})=>{const{theme:n,themeColor:s}=te(Ae(A=>({theme:A.theme,themeColor:A.themeColor}))),[a,i]=T.useState(""),[l,c]=T.useState(null),[d,u]=T.useState(null),[p,f]=T.useState(""),[m,h]=T.useState(new Set),[y,x]=T.useState(!1),g=T.useRef(null),v=T.useRef(null),k=T.useRef(null),b=T.useMemo(()=>a.trim()?K1(a):null,[a]),S=T.useMemo(()=>b&&b.ok?b.operations:[],[b]);T.useEffect(()=>{h(eE(S,X1)),f(""),x(!1)},[S]),T.useEffect(()=>{const A=document.activeElement;return v.current?.focus(),()=>{A&&typeof A.focus=="function"&&A.focus()}},[]);const j=p.trim().toLowerCase(),_=T.useMemo(()=>S.filter(A=>!j||`${A.method} ${A.path} ${A.summary||""} ${A.operationId||""} ${A.tags.join(" ")}`.toLowerCase().includes(j)),[S,j]),{visible:w,hiddenCount:I}=tE(_,X1),N=S.filter(A=>m.has(A.id)).length,C=A=>h(W=>{const P=new Set(W);return P.has(A)?P.delete(A):P.add(A),P}),M=A=>h(W=>rE(W,w,A)),R=async A=>{if(A){if(u(null),A.size>Z1){u(`文件超过 ${Z1/1024/1024} MB,请精简后再导入`);return}try{const W=await A.text();c(A.name),i(W)}catch{u("读取文件失败,请重试或直接粘贴内容")}}},O=()=>{if(!b||!b.ok||N===0)return;const A=new Set(r||[]),W=[];for(const P of S){if(!m.has(P.id))continue;const D=Y1(P,{existingIds:A});A.add(D.id),W.push(D)}t(W,{format:b.format,count:W.length,warnings:b.warnings}),e()},$=A=>{if(A.key==="Escape"){A.stopPropagation(),e();return}if(A.key==="Tab"&&g.current){const W=Array.from(g.current.querySelectorAll(aE));if(W.length===0)return;const P=W[0],D=W[W.length-1],Z=document.activeElement;A.shiftKey&&Z===P?(A.preventDefault(),D.focus()):!A.shiftKey&&Z===D&&(A.preventDefault(),P.focus())}},B=b&&b.ok?b.warnings:[],q=y?B:B.slice(0,5),F={height:28,padding:"0 12px",borderRadius:6,fontSize:12,fontFamily:"inherit",cursor:"pointer",border:"1px solid var(--border-secondary)",background:"transparent",color:"var(--text-secondary)"};return bt.createPortal(o.jsx("div",{"data-mode":n,"data-brand":s,style:{position:"fixed",inset:0,background:"var(--cm-overlay)",backdropFilter:"blur(2px)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center",padding:24,fontFamily:"inherit",colorScheme:n==="light"?"light":"dark"},onClick:e,children:o.jsxs("div",{ref:g,role:"dialog","aria-modal":"true","aria-labelledby":"api-import-title",onClick:A=>A.stopPropagation(),onKeyDown:$,style:{width:820,maxWidth:"calc(100vw - 48px)",height:"min(700px, 90vh)",background:"var(--bg-primary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRadius:12,boxShadow:"var(--cm-shadow-float)",display:"flex",flexDirection:"column",overflow:"hidden"},children:[o.jsxs("div",{style:{padding:"14px 18px",borderBottom:"1px solid var(--border-primary)",display:"flex",alignItems:"center",gap:12},children:[o.jsxs("div",{id:"api-import-title",style:{fontWeight:600,fontSize:15,flex:1},children:["导入接口",o.jsx("span",{style:{marginLeft:8,fontSize:12,fontWeight:400,color:"var(--text-muted)"},children:"把已有接口变成可复用的 HTTP 步骤"})]}),o.jsx("button",{type:"button",onClick:e,"aria-label":"关闭",style:{background:"none",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:16,padding:4,lineHeight:1},children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsxs("div",{style:{padding:"12px 18px",borderBottom:"1px solid var(--border-primary)",background:"var(--bg-secondary)",display:"flex",flexDirection:"column",gap:8},children:[o.jsx("textarea",{ref:v,"aria-label":"接口文档或 curl 命令",value:a,onChange:A=>{i(A.target.value),c(null)},placeholder:sE,spellCheck:!1,style:{width:"100%",boxSizing:"border-box",height:S.length>0?72:150,resize:"vertical",padding:"8px 10px",borderRadius:6,background:"var(--bg-primary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontFamily:"var(--font-mono)",fontSize:12,lineHeight:1.5,outline:"none"}}),o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:10,minHeight:28},children:[o.jsx("input",{ref:k,type:"file",accept:".json,.txt,.curl,.sh,application/json,text/plain","aria-label":"选择接口文档文件",style:{display:"none"},onChange:A=>{R(A.target.files?.[0]),A.target.value=""}}),o.jsx("button",{type:"button",style:F,onClick:()=>k.current?.click(),children:"选择文件"}),l&&o.jsx("span",{style:{fontSize:12,color:"var(--text-muted)"},children:l}),o.jsx("div",{style:{flex:1}}),b&&b.ok&&o.jsxs("span",{style:{fontSize:11,padding:"2px 8px",borderRadius:999,background:"var(--color-accent-bg)",color:"var(--color-accent-text)",border:"1px solid var(--color-accent)"},children:["已识别:",nE[b.format]," · ",S.length," 个接口"]})]}),d&&o.jsx("div",{role:"alert",style:{fontSize:12,color:"var(--color-error)"},children:d}),b&&!b.ok&&o.jsx("div",{role:"alert",style:{fontSize:12,lineHeight:1.5,padding:"6px 10px",borderRadius:6,color:b.format==="yaml"?"var(--color-warning)":"var(--color-error)",background:`color-mix(in srgb, ${b.format==="yaml"?"var(--color-warning)":"var(--color-error)"} 12%, transparent)`},children:b.error}),B.length>0&&o.jsxs("div",{role:"status",style:{fontSize:12,lineHeight:1.5,padding:"6px 10px",borderRadius:6,color:"var(--text-primary)",background:"color-mix(in srgb, var(--color-warning) 12%, transparent)",border:"1px solid color-mix(in srgb, var(--color-warning) 40%, transparent)",maxHeight:y?120:void 0,overflowY:y?"auto":void 0},children:[o.jsxs("div",{style:{fontWeight:600,color:"var(--color-warning)"},children:["提示(",B.length,")"]}),o.jsx("ul",{style:{margin:"2px 0 0",paddingLeft:18},children:q.map(A=>o.jsx("li",{children:A},A))}),B.length>5&&o.jsx("button",{type:"button",onClick:()=>x(A=>!A),style:{background:"none",border:"none",padding:0,marginTop:2,color:"var(--color-accent-text)",cursor:"pointer",fontSize:12},children:y?"收起":`展开全部 ${B.length} 条`})]})]}),o.jsx("div",{style:{flex:1,minHeight:0,display:"flex",flexDirection:"column"},children:S.length>0?o.jsxs(o.Fragment,{children:[o.jsxs("div",{style:{padding:"8px 18px",display:"flex",alignItems:"center",gap:10,borderBottom:"1px solid var(--border-primary)"},children:[o.jsx("input",{type:"search","aria-label":"搜索接口",placeholder:"搜索方法、路径、摘要、标签…",value:p,onChange:A=>f(A.target.value),style:{flex:1,padding:"5px 10px",borderRadius:6,background:"var(--bg-secondary)",border:"1px solid var(--border-secondary)",color:"var(--text-primary)",fontSize:12,outline:"none"}}),o.jsx("button",{type:"button",style:F,onClick:()=>M(!0),children:I>0?`全选显示的 ${w.length} 项`:`全选${j?"结果":""}`}),o.jsx("button",{type:"button",style:F,onClick:()=>M(!1),children:"全不选"})]}),o.jsxs("ul",{style:{flex:1,overflowY:"auto",listStyle:"none",margin:0,padding:"6px 12px"},"aria-label":"接口列表",children:[w.map(A=>{const W=m.has(A.id);return o.jsx("li",{children:o.jsxs("label",{style:{display:"flex",alignItems:"center",gap:10,padding:"7px 8px",borderRadius:6,cursor:"pointer",background:W?"var(--color-accent-bg)":"transparent"},children:[o.jsx("input",{type:"checkbox",checked:W,onChange:()=>C(A.id),style:{accentColor:"var(--color-accent)"}}),o.jsx("span",{style:{flexShrink:0,minWidth:52,textAlign:"center",fontSize:11,fontWeight:700,padding:"1px 6px",borderRadius:4,color:Q1(A.method),background:`color-mix(in srgb, ${Q1(A.method)} 15%, transparent)`},children:A.method}),o.jsx("span",{style:{fontFamily:"var(--font-mono)",fontSize:12,flexShrink:0,maxWidth:"45%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:A.path,children:A.path}),o.jsx("span",{style:{fontSize:12,color:"var(--text-secondary)",flex:1,minWidth:0,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},title:A.summary||"",children:A.summary||""}),A.warnings.length>0&&o.jsx("span",{title:A.warnings.join(`
|
|
289
|
+
`),"aria-label":`${A.warnings.length} 条提示`,style:{color:"var(--color-warning)",fontSize:12,flexShrink:0},children:o.jsx(Ye,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]})},A.id)}),_.length===0&&o.jsx("li",{style:{textAlign:"center",padding:"28px 0",fontSize:12,color:"var(--text-muted)"},children:"没有符合条件的接口"}),I>0&&o.jsxs("li",{style:{textAlign:"center",padding:"8px 0",fontSize:12,color:"var(--text-muted)"},children:["另有 ",I," 个未显示,请用搜索缩小范围"]})]})]}):o.jsx("div",{style:{flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:24,textAlign:"center",fontSize:12,lineHeight:1.7,color:"var(--text-muted)"},children:b?"":"粘贴内容后会在这里列出可导入的接口"})}),o.jsxs("div",{style:{padding:"12px 18px",borderTop:"1px solid var(--border-primary)",display:"flex",alignItems:"center",gap:10},children:[o.jsx("span",{style:{fontSize:12,color:"var(--text-muted)",flex:1},children:"认证信息不会写入流程定义;导入结果仅保存在当前流程与本次会话的动作库中"}),o.jsx("button",{type:"button",style:F,onClick:e,children:"取消"}),o.jsxs("button",{type:"button",disabled:N===0,onClick:O,style:{...F,border:"1px solid var(--color-accent)",background:"var(--color-accent)",color:"var(--text-inverse)",fontWeight:600,opacity:N===0?.5:1,cursor:N===0?"not-allowed":"pointer"},children:["插入 ",N," 个步骤"]})]})]})}),document.body)};function iE(e="imported_api_workflow"){return{name:e,description:"由接口导入生成",version:1,schemaVersion:2,tasks:[],inputParameters:[]}}function Fn(e,t){for(const r of e){r.taskReferenceName&&t.add(r.taskReferenceName);for(const n of r.forkTasks||[])Fn(n,t);for(const n of Object.values(r.decisionCases||{}))Fn(n,t);r.defaultCase&&Fn(r.defaultCase,t),r.loopOver&&Fn(r.loopOver,t)}}function lE(e){const t=new Set,r=JSON.stringify(e);for(const n of r.matchAll(/\$\{workflow\.input\.([A-Za-z_][\w-]*)/g))t.add(n[1]);return Array.from(t)}function t0(e,t){const r=e??iE(),n=new Vs(t),s=new Set;Fn(r.tasks||[],s);const a=[],i=(r.tasks||[]).length;t.forEach((u,p)=>{let f=lr(u);for(;s.has(f.taskReferenceName);)f=lr(u);s.add(f.taskReferenceName),a.push(pp(f,i+p,r.name,n))});const l=St(r.inputParameters).map(u=>u.name),c=lE(a).filter(u=>!l.includes(u));let d=r.inputParameters;if(c.length>0)if(Array.isArray(d)&&d.length>0&&typeof d[0]=="string")d=[...d,...c];else{const u=c.map(p=>({name:p,type:"string",description:"接口导入引入的入参"}));d=[...d||[],...u]}return{...r,tasks:[...r.tasks||[],...a],...d?{inputParameters:d}:{}}}function r0(e){return(e??"").replace(/-/g,"").trim()}function Bn(e){return[e.type,e.level,r0(e.domain),r0(e.product),(e.func??"").trim()].join("-")}function qp(e,t){return ip(Bn(e),t)}const cE=/[㐀-鿿]/;function n0(e){const t=(e??"").trim();return t?cE.test(t)?t.replace(/-/g,"").replace(/\s+/g,"_").replace(/_+/g,"_").replace(/^_+|_+$/g,""):t.replace(/([a-z0-9])([A-Z])/g,"$1_$2").toLowerCase().replace(/[^a-z0-9]+/g,"_").replace(/^_+|_+$/g,""):""}function s0(e,t){if(!Gs(e))return null;const n=e.indexOf("-");return`${t}${e.slice(n)}`}function a0(e){return e?Gs(e)?.type==="tmp":!1}function o0(e){const t={name:e.name,description:(e.description??"").trim(),version:1,schemaVersion:2,tasks:[],inputParameters:[],outputParameters:{}};return e.ownerEmail&&(t.ownerEmail=e.ownerEmail),t}function dE(e,t){const r=ip(e??"",t&&t.length>0?t:void 0);return r.length===0?null:`已保存。${e&&e.trim()?`流程名称「${e}」`:"流程名称"}不符合命名规范:${r.join(";")}。申请上线前请在流程设置里改名。`}const Tr=["product","naming","start"],uE={product:"产品",naming:"命名",start:"起点"};function pE(e,t="L2"){const r=e.products[0];return{productMode:r?"existing":"new",productName:r?.name??"",domain:r?.domain??"",systemCode:"",type:e.trial?"tmp":"custom",level:t,func:"",description:"",source:"blank"}}function fE(e){const t=(e??"").trim();return t?/-/.test(t)?"产品名称不能包含「-」":/\s/.test(t)?"产品名称不能包含空白字符":null:"请填写产品名称"}function i0(e,t,r){if(e.productMode==="existing")return t.products.some(s=>s.name===e.productName)?null:"请选择一个所属产品";if(!t.trial)return"当前环境不开放自助试用,请选择已有产品";const n=fE(e.productName);return n||(e.domain?r.length>0&&r.indexOf(e.domain)<0?`业务域「${e.domain}」不在允许的列表中`:null:"请选择业务域")}function da(e,t){return{type:t?"tmp":e.type,level:e.level,domain:e.domain,product:e.productName,func:e.func}}function mE(e,t,r){return qp(da(e,t),r.length>0?r:void 0)}function hE(e,t,r,n){return e==="product"?i0(t,r,n)===null:e==="naming"?mE(t,r.trial,n).length===0:!0}function yE(e){const t=Tr.indexOf(e);return Tr[Math.min(t+1,Tr.length-1)]}function gE(e){const t=Tr.indexOf(e);return Tr[Math.max(t-1,0)]}function xE(e){const t=["blank"];return e.hasTemplate&&t.push("template"),e.hasImport&&t.push("import"),t}const l0='button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';function c0({titleId:e,title:t,onClose:r,children:n,footer:s,width:a=560}){const{theme:i,themeColor:l}=te(Ae(u=>({theme:u.theme,themeColor:u.themeColor}))),c=T.useRef(null),d=T.useRef(r);return d.current=r,T.useEffect(()=>{const u=document.activeElement,p=c.current;p&&(p.querySelector(l0)??p).focus({preventScroll:!0});const f=m=>{if(m.key==="Escape"){m.stopPropagation(),d.current();return}if(m.key!=="Tab"||!c.current)return;const h=Array.from(c.current.querySelectorAll(l0));if(h.length===0)return;const y=h[0],x=h[h.length-1],g=document.activeElement;m.shiftKey&&(g===y||!c.current.contains(g))?(m.preventDefault(),x.focus()):!m.shiftKey&&(g===x||!c.current.contains(g))&&(m.preventDefault(),y.focus())};return window.addEventListener("keydown",f),()=>{window.removeEventListener("keydown",f),u&&typeof u.focus=="function"&&document.contains(u)&&u.focus({preventScroll:!0})}},[]),typeof document>"u"?null:bt.createPortal(o.jsx("div",{"data-mode":i,"data-brand":l,onClick:r,style:{position:"fixed",inset:0,background:"var(--cm-overlay)",backdropFilter:"blur(2px)",zIndex:2e3,display:"flex",alignItems:"center",justifyContent:"center",padding:24,fontFamily:"inherit",colorScheme:i==="light"?"light":"dark"},children:o.jsxs("div",{ref:c,role:"dialog","aria-modal":"true","aria-labelledby":e,tabIndex:-1,onClick:u=>u.stopPropagation(),style:{width:a,maxWidth:"100%",maxHeight:"100%",display:"flex",flexDirection:"column",background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRadius:10,boxShadow:"var(--cm-shadow-float)",outline:"none"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"14px 18px",borderBottom:"1px solid var(--border-primary)"},children:[o.jsx("h2",{id:e,style:{margin:0,flex:1,fontSize:15,fontWeight:700,color:"var(--text-primary)"},children:t}),o.jsx("button",{type:"button",onClick:r,"aria-label":"关闭",title:"关闭 (Esc)",style:{background:"transparent",border:"none",color:"var(--text-muted)",cursor:"pointer",fontSize:16,lineHeight:1,padding:4},children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),o.jsx("div",{style:{padding:18,overflowY:"auto",flex:1},children:n}),s&&o.jsx("div",{style:{display:"flex",alignItems:"center",gap:8,justifyContent:"flex-end",padding:"12px 18px",borderTop:"1px solid var(--border-primary)"},children:s})]})}),document.body)}const ot={display:"block",fontSize:12,fontWeight:600,color:"var(--text-secondary)",marginBottom:4},It={width:"100%",boxSizing:"border-box",height:32,padding:"0 8px",background:"var(--bg-primary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRadius:6,fontSize:13,fontFamily:"inherit"},cr={fontSize:11,color:"var(--text-muted)",marginTop:4},Fp={fontSize:12,color:"var(--color-error)",margin:"4px 0 0"},d0={height:32,padding:"0 14px",borderRadius:6,fontSize:13,fontWeight:600,fontFamily:"inherit",cursor:"pointer",display:"inline-flex",alignItems:"center",gap:6},Hn={...d0,background:"var(--color-accent)",color:"var(--color-accent-text)",border:"1px solid var(--color-accent)"},Hr={...d0,background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-primary)"};function Jn(e,t){return t?{...e,opacity:.5,cursor:"not-allowed"}:e}const ua=e=>({padding:"8px 10px",borderRadius:6,fontSize:12,lineHeight:1.5,color:"var(--text-primary)",background:"var(--bg-primary)",border:`1px solid var(--color-${e})`}),vE=["L1","L2","L3"],bE={L1:"L1 最上层,可调用 L2 / L3",L2:"L2 中间层,可调用 L3",L3:"L3 最底层,原子能力"},kE=["custom","std"];function u0({products:e,domains:t,trial:r,value:n,onChange:s,disabled:a}){const i=T.useId(),[l,c]=T.useState(!1),d=T.useMemo(()=>({...n,type:r?"tmp":n.type==="std"?"std":"custom"}),[n,r]),u=Bn(d),f=T.useMemo(()=>qp(d,t&&t.length>0?t:void 0),[d,t]).filter(k=>l||n.func.trim()!==""||k.indexOf("功能不能为空")<0),m=n0(n.func),h=n.func.trim()!==""&&m!==""&&m!==n.func.trim(),y=k=>s({...d,...k}),x=e.find(k=>k.name===n.product),g=k=>`${i}-${k}`,v={minWidth:0};return o.jsxs("div",{children:[o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(150px, 1fr))",gap:12},children:[o.jsxs("div",{style:v,children:[o.jsx("label",{htmlFor:g("type"),style:ot,children:"类型"}),r?o.jsx("select",{id:g("type"),value:"tmp",disabled:!0,style:{...It,opacity:.7},"aria-describedby":g("type-hint"),children:o.jsx("option",{value:"tmp",children:"tmp(临时)"})}):o.jsx("select",{id:g("type"),value:d.type,disabled:a,onChange:k=>y({type:k.target.value}),style:It,"aria-describedby":g("type-hint"),children:kE.map(k=>o.jsx("option",{value:k,children:k==="custom"?"custom(自定义)":"std(通用)"},k))}),o.jsx("div",{id:g("type-hint"),style:cr,children:r?"试用环境固定为临时流程,会被定期清理":"生产环境可选自定义或通用"})]}),o.jsxs("div",{style:v,children:[o.jsx("label",{htmlFor:g("level"),style:ot,children:"层级"}),o.jsx("select",{id:g("level"),value:d.level,disabled:a,onChange:k=>y({level:k.target.value}),style:It,"aria-describedby":g("level-hint"),children:vE.map(k=>o.jsx("option",{value:k,children:k},k))}),o.jsx("div",{id:g("level-hint"),style:cr,children:bE[d.level]})]}),o.jsxs("div",{style:v,children:[o.jsx("label",{htmlFor:g("product"),style:ot,children:"产品"}),o.jsxs("select",{id:g("product"),value:x?x.name:"",disabled:a||e.length===0,onChange:k=>{const b=e.find(S=>S.name===k.target.value);y({product:b?.name??"",domain:b?.domain??""})},style:It,"aria-describedby":g("product-hint"),children:[o.jsx("option",{value:"",children:e.length===0?"暂无产品":"请选择产品"}),e.map(k=>o.jsxs("option",{value:k.name,children:[k.name,k.status==="PENDING"?"(待生效)":""]},k.name))]}),o.jsx("div",{id:g("product-hint"),style:cr,children:"来自「我的产品」"})]}),o.jsxs("div",{style:v,children:[o.jsx("label",{htmlFor:g("domain"),style:ot,children:"业务域"}),o.jsx("input",{id:g("domain"),value:x?x.domain:n.domain,readOnly:!0,style:{...It,opacity:.8},placeholder:"随产品带出","aria-describedby":g("domain-hint")}),o.jsx("div",{id:g("domain-hint"),style:cr,children:"由所选产品决定"})]}),o.jsxs("div",{style:{...v,gridColumn:"1 / -1"},children:[o.jsx("label",{htmlFor:g("func"),style:ot,children:"功能"}),o.jsx("input",{id:g("func"),value:n.func,disabled:a,onChange:k=>y({func:k.target.value}),onBlur:()=>c(!0),placeholder:"例如 create_vm(推荐小写 snake_case)",style:It,"aria-describedby":g("func-hint"),"aria-invalid":l&&n.func.trim()===""}),o.jsxs("div",{id:g("func-hint"),style:cr,children:["说明这个流程做什么,用 snake_case 更易检索",h&&o.jsxs(o.Fragment,{children:[" · 建议:",o.jsx("button",{type:"button",disabled:a,onClick:()=>y({func:m}),style:{background:"none",border:"none",padding:0,color:"var(--color-accent)",cursor:"pointer",fontSize:11,fontFamily:"inherit",textDecoration:"underline"},children:m})]})]})]})]}),o.jsxs("div",{style:{marginTop:14},children:[o.jsx("div",{style:ot,children:"完整名称预览"}),o.jsx("code",{"aria-live":"polite","data-testid":"name-preview",style:{display:"block",padding:"8px 10px",borderRadius:6,background:"var(--bg-primary)",border:"1px solid var(--border-primary)",color:"var(--text-primary)",fontSize:13,wordBreak:"break-all"},children:u}),f.length>0&&o.jsx("ul",{role:"alert",style:{margin:"6px 0 0",paddingLeft:18},children:f.map(k=>o.jsx("li",{style:Fp,children:k},k))})]})]})}const p0={blank:{title:"空白流程",desc:"从一个空画布开始,自己添加步骤"},template:{title:"从模板中心开始",desc:"选择场景模板,按向导填空即可得到可用流程"},import:{title:"从接口导入",desc:"粘贴 OpenAPI / Postman / curl,把已有接口变成步骤"}};function wE(e){return e instanceof Error&&e.message?e.message:"请求失败,请稍后重试"}function f0({provider:e,trialEnabled:t,products:r,domains:n,defaultLevel:s="L2",ownerEmail:a,onClose:i,onCreate:l,onTrialStarted:c,onPickTemplate:d,onImportApi:u}){const p=T.useId(),f=T.useId(),[m,h]=T.useState("product"),[y,x]=T.useState([]),g=T.useMemo(()=>{const D=y.filter(Z=>!r.some(L=>L.name===Z.name));return[...r,...D]},[r,y]),v=T.useMemo(()=>({trial:t,products:g}),[t,g]),[k,b]=T.useState(()=>pE({trial:t,products:r},s)),[S,j]=T.useState(!1),[_,w]=T.useState(null),[I,N]=T.useState(null),C=T.useCallback(D=>{b(Z=>({...Z,...D})),w(null),N(null)},[]),M=xE({hasTemplate:!!d,hasImport:!!u}),R=i0(k,v,n),O=hE(m,k,v,n),$=Tr.indexOf(m),B=T.useCallback(async()=>{if(k.productMode==="existing"){h("naming");return}j(!0),w(null),N(null);try{const D=await e.startTrial({productName:k.productName.trim(),domain:k.domain,systemCode:k.systemCode.trim()||void 0});if(D.status==="conflict"){N(D.owners);return}x(Z=>[...Z.filter(L=>L.name!==D.product.name),D.product]),b(Z=>({...Z,productMode:"existing",productName:D.product.name,domain:D.product.domain})),c?.(D.product),h("naming")}catch(D){w(wE(D))}finally{j(!1)}},[k.productMode,k.productName,k.domain,k.systemCode,e,c]),q=T.useCallback(()=>{const D=Bn(da(k,t)),Z=o0({name:D,description:k.description,ownerEmail:a});l({def:Z,level:k.level,source:k.source}),i(),k.source==="template"?d?.():k.source==="import"&&u?.()},[k,t,a,l,i,d,u]),F=()=>{S||!O||(m==="product"?B():h(yE(m)))},A=m==="start",W=m==="product"&&k.productMode==="new"?"登记并继续":"下一步",P=o.jsxs(o.Fragment,{children:[$>0&&o.jsx("button",{type:"button",style:Jn(Hr,S),disabled:S,onClick:()=>h(gE(m)),children:"上一步"}),o.jsx("span",{style:{flex:1}}),o.jsx("button",{type:"button",style:Hr,onClick:i,children:"取消"}),A?o.jsx("button",{type:"button",style:Hn,onClick:q,children:"创建流程"}):o.jsx("button",{type:"button",style:Jn(Hn,S||!O),disabled:S||!O,onClick:F,children:S?"处理中…":W})]});return o.jsxs(c0,{titleId:p,title:"新建流程",onClose:i,footer:P,width:600,children:[o.jsx("ol",{"aria-label":"步骤",style:{display:"flex",gap:8,listStyle:"none",padding:0,margin:"0 0 16px"},children:Tr.map((D,Z)=>{const L=D===m,H=Z<$;return o.jsxs("li",{"aria-current":L?"step":void 0,style:{flex:1,textAlign:"center",padding:"6px 0",fontSize:12,fontWeight:L?700:500,borderRadius:6,color:L?"var(--color-accent-text)":H?"var(--color-success)":"var(--text-muted)",background:L?"var(--color-accent)":"var(--bg-primary)",border:"1px solid var(--border-primary)"},children:[Z+1,". ",uE[D],H?o.jsx(_t,{size:12,strokeWidth:1.75,"aria-hidden":"true",style:{verticalAlign:-2,marginLeft:4}}):null]},D)})}),m==="product"&&o.jsxs("div",{children:[o.jsxs("div",{style:{marginBottom:12},children:[o.jsx("label",{htmlFor:`${f}-pm`,style:ot,children:"所属产品"}),o.jsxs("select",{id:`${f}-pm`,value:k.productMode==="new"?"__new__":k.productName,disabled:S,onChange:D=>{const Z=D.target.value;if(Z==="__new__")C({productMode:"new",productName:"",domain:""});else{const L=g.find(H=>H.name===Z);C({productMode:"existing",productName:Z,domain:L?.domain??""})}},style:It,children:[g.length===0&&k.productMode==="existing"&&o.jsx("option",{value:"",children:"暂无产品"}),g.map(D=>o.jsxs("option",{value:D.name,children:[D.name,"(",D.domain,")"]},D.name)),t&&o.jsx("option",{value:"__new__",children:"+ 登记新产品(开始试用)"})]}),!t&&g.length===0&&o.jsx("p",{style:{...Fp,marginTop:6},children:"当前环境不开放自助试用,且你还没有所属产品,请联系平台管理员。"})]}),k.productMode==="new"&&o.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(180px, 1fr))",gap:12},children:[o.jsxs("div",{children:[o.jsx("label",{htmlFor:`${f}-pn`,style:ot,children:"产品名称"}),o.jsx("input",{id:`${f}-pn`,value:k.productName,disabled:S,onChange:D=>C({productName:D.target.value}),placeholder:"例如 ecs(不含 -)",style:It})]}),o.jsxs("div",{children:[o.jsx("label",{htmlFor:`${f}-pd`,style:ot,children:"业务域"}),o.jsxs("select",{id:`${f}-pd`,value:k.domain,disabled:S,onChange:D=>C({domain:D.target.value}),style:It,children:[o.jsx("option",{value:"",children:"请选择业务域"}),n.map(D=>o.jsx("option",{value:D,children:D},D))]})]}),o.jsxs("div",{style:{gridColumn:"1 / -1"},children:[o.jsx("label",{htmlFor:`${f}-ps`,style:ot,children:"系统编码(可选)"}),o.jsx("input",{id:`${f}-ps`,value:k.systemCode,disabled:S,onChange:D=>C({systemCode:D.target.value}),style:It}),o.jsx("div",{style:cr,children:"登记后你自动成为该产品的负责人,可以马上开始试用。"})]})]}),k.productMode==="new"&&k.productName!==""&&R&&o.jsx("p",{style:Fp,children:R}),I&&o.jsxs("div",{role:"alert",style:{...ua("warning"),marginTop:12},children:["产品「",k.productName.trim(),"」已存在,请联系负责人把你加入该产品:",o.jsx("ul",{style:{margin:"4px 0 0",paddingLeft:18},children:I.map(D=>o.jsx("li",{children:D.name},D.id))})]})]}),m==="naming"&&o.jsxs("div",{children:[o.jsx(u0,{products:g,domains:n,trial:t,value:da(k,t),onChange:D=>C({type:D.type,level:D.level,domain:D.domain,productName:D.product,func:D.func})}),o.jsxs("div",{style:{marginTop:14},children:[o.jsx("label",{htmlFor:`${f}-desc`,style:ot,children:"流程说明(可选)"}),o.jsx("textarea",{id:`${f}-desc`,value:k.description,onChange:D=>C({description:D.target.value}),rows:3,placeholder:"一句话说明这个流程做什么,会写入流程描述",style:{...It,height:"auto",padding:8,resize:"vertical"}})]})]}),m==="start"&&o.jsxs("fieldset",{style:{border:"none",padding:0,margin:0},children:[o.jsx("legend",{style:ot,children:"选择起点"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:M.map(D=>{const Z=k.source===D;return o.jsxs("label",{style:{display:"flex",gap:10,alignItems:"flex-start",padding:"10px 12px",borderRadius:8,cursor:"pointer",background:Z?"var(--color-accent-bg)":"var(--bg-primary)",border:`1px solid ${Z?"var(--color-accent)":"var(--border-primary)"}`},children:[o.jsx("input",{type:"radio",name:`${f}-src`,checked:Z,onChange:()=>C({source:D}),style:{marginTop:3}}),o.jsxs("span",{children:[o.jsx("span",{style:{display:"block",fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:p0[D].title}),o.jsx("span",{style:{display:"block",fontSize:12,color:"var(--text-secondary)"},children:p0[D].desc})]})]},D)})}),o.jsxs("div",{style:{marginTop:12,fontSize:12,color:"var(--text-secondary)"},children:["将创建:",o.jsx("code",{style:{color:"var(--text-primary)"},children:Bn(da(k,t))})]})]}),_&&o.jsxs("div",{role:"alert",style:{...ua("error"),marginTop:12,display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{flex:1},children:_}),o.jsx("button",{type:"button",style:Jn(Hr,S),disabled:S,onClick:F,children:"重试"})]})]})}const SE=2e3,_E=3e4;function m0(e){const t=Number.isFinite(e)&&e>0?Math.floor(e):0;return Math.min(_E,SE*Math.pow(2,Math.min(t,10)))}function pa(e){return e==="REJECTED"||e==="SYNCED"}const h0={SUBMITTED:"已提交",REVIEWING:"审批中",APPROVED:"审批通过",REJECTED:"已驳回",SYNCED:"已同步到生产"};function jE(e){return h0[e]}function y0(e){const t=e==="REJECTED"?["SUBMITTED","REVIEWING","REJECTED"]:["SUBMITTED","REVIEWING","APPROVED","SYNCED"],r=e?t.indexOf(e):-1;return t.map((n,s)=>{let a;return n==="REJECTED"&&e==="REJECTED"?a="failed":r===s?a=pa(n)||n==="APPROVED"?"done":"current":e==="APPROVED"&&n==="SYNCED"?a="current":s<r?a="done":a="pending",{state:n,label:h0[n],status:a}})}function fa(){const e=new Error("已取消");return e.name="AbortError",e}function g0(e){return!!e&&typeof e=="object"&&e.name==="AbortError"}function TE(e,t){return t?.aborted?Promise.reject(fa()):new Promise((r,n)=>{const s=()=>{clearTimeout(a),n(fa())},a=setTimeout(()=>{t?.removeEventListener("abort",s),r()},e);t?.addEventListener("abort",s,{once:!0})})}async function x0(e){const t=e.sleep??TE;let r=0;for(;;){if(e.signal?.aborted)throw fa();const n=await e.provider.getPromotion(e.requestId,e.signal);if(e.signal?.aborted)throw fa();if(e.onUpdate?.(n),pa(n.state))return n;await t(m0(r),e.signal),r+=1}}const IE=[{value:"custom",title:"custom(自定义)",desc:"仅本产品使用的流程"},{value:"std",title:"std(通用)",desc:"面向多个产品复用的通用能力,审批更严格"}];function v0(e){return e instanceof Error&&e.message?e.message:"请求失败,请稍后重试"}const b0={done:"var(--color-success)",current:"var(--color-accent)",failed:"var(--color-error)",pending:"var(--text-muted)"};function k0({provider:e,workflowName:t,version:r,onClose:n,onRequested:s,onStateChange:a,resumeRequest:i,onRequestChange:l}){const c=T.useId(),[d,u]=T.useState(i?.targetType??"custom"),[p,f]=T.useState(i?.requestId??null),[m,h]=T.useState(null),[y,x]=T.useState(!1),[g,v]=T.useState(!1),[k,b]=T.useState(null),S=T.useRef(null),j=T.useRef(null),_=T.useRef({onRequested:s,onStateChange:a,onRequestChange:l});_.current={onRequested:s,onStateChange:a,onRequestChange:l};const w=s0(t,d);T.useEffect(()=>()=>S.current?.abort(),[]);const I=T.useCallback(async $=>{S.current?.abort();const B=new AbortController;S.current=B,v(!0),b(null);try{await x0({provider:e,requestId:$,signal:B.signal,onUpdate:q=>{h(q),j.current!==q.state&&(j.current=q.state,_.current.onStateChange?.(q.state)),pa(q.state)&&_.current.onRequestChange?.(null)}})}catch(q){g0(q)||b(v0(q))}finally{S.current===B&&v(!1)}},[e]),N=async()=>{if(!(y||!w)){x(!0),b(null);try{const{requestId:$}=await e.requestPromotion({workflowName:t,version:r,targetType:d});f($),_.current.onRequestChange?.({requestId:$,targetType:d}),_.current.onRequested?.(d),I($)}catch($){b(v0($))}finally{x(!1)}}},C=T.useRef(i?.requestId??null);T.useEffect(()=>{C.current&&I(C.current)},[I]);const M=p!==null,R=y0(m?m.state:M?"SUBMITTED":null),O=M?o.jsx("button",{type:"button",style:Hn,onClick:n,children:"关闭"}):o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",style:Hr,onClick:n,children:"取消"}),o.jsx("button",{type:"button",style:Jn(Hn,y||!w),disabled:y||!w,onClick:()=>{N()},children:y?"提交中…":"提交申请"})]});return o.jsxs(c0,{titleId:c,title:"申请上线",onClose:n,footer:O,width:520,children:[o.jsxs("div",{style:{fontSize:12,color:"var(--text-secondary)",marginBottom:12},children:["当前流程:",o.jsx("code",{style:{color:"var(--text-primary)"},children:t}),"(版本 ",r,")"]}),!M&&o.jsxs("fieldset",{style:{border:"none",padding:0,margin:0},children:[o.jsx("legend",{style:ot,children:"上线为"}),o.jsx("div",{style:{display:"flex",flexDirection:"column",gap:8},children:IE.map($=>{const B=d===$.value;return o.jsxs("label",{style:{display:"flex",gap:10,alignItems:"flex-start",padding:"10px 12px",borderRadius:8,cursor:"pointer",background:B?"var(--color-accent-bg)":"var(--bg-primary)",border:`1px solid ${B?"var(--color-accent)":"var(--border-primary)"}`},children:[o.jsx("input",{type:"radio",name:"promotion-target",checked:B,onChange:()=>u($.value),style:{marginTop:3}}),o.jsxs("span",{children:[o.jsx("span",{style:{display:"block",fontSize:13,fontWeight:600,color:"var(--text-primary)"},children:$.title}),o.jsx("span",{style:{display:"block",fontSize:12,color:"var(--text-secondary)"},children:$.desc})]})]},$.value)})})]}),o.jsxs("div",{style:{marginTop:14},children:[o.jsx("div",{style:ot,children:"正式名称预览"}),o.jsx("code",{style:{display:"block",padding:"8px 10px",borderRadius:6,background:"var(--bg-primary)",border:"1px solid var(--border-primary)",color:"var(--text-primary)",fontSize:13,wordBreak:"break-all"},children:m?.targetName??w??"(流程名称不符合规范,无法申请)"}),!M&&o.jsx("div",{style:cr,children:"审批通过后,临时流程会以正式名称同步到生产环境。"})]}),M&&o.jsxs("div",{style:{marginTop:16},children:[o.jsx("div",{style:ot,children:"审批进度"}),o.jsx("ol",{"aria-label":"审批进度",style:{listStyle:"none",margin:0,padding:0,display:"flex",flexDirection:"column",gap:8},children:R.map($=>o.jsxs("li",{"aria-current":$.status==="current"?"step":void 0,style:{display:"flex",alignItems:"center",gap:8,fontSize:13,color:$.status==="pending"?"var(--text-muted)":"var(--text-primary)"},children:[o.jsx("span",{"aria-hidden":"true",style:{width:10,height:10,borderRadius:"50%",background:$.status==="pending"?"transparent":b0[$.status],border:`2px solid ${b0[$.status]}`,flexShrink:0}}),o.jsx("span",{children:$.label}),$.status==="current"&&g&&o.jsx("span",{style:{fontSize:11,color:"var(--text-muted)"},children:"进行中…"}),$.status==="failed"&&o.jsx("span",{style:{fontSize:11,color:"var(--color-error)"},children:"未通过"})]},$.state))}),m?.comment&&o.jsxs("div",{role:"status",style:{...ua(m.state==="REJECTED"?"error":"success"),marginTop:12},children:["审批意见:",m.comment]}),m?.state==="REJECTED"&&o.jsx("div",{style:cr,children:"修改流程后可重新申请上线。"})]}),k&&o.jsxs("div",{role:"alert",style:{...ua("error"),marginTop:12,display:"flex",alignItems:"center",gap:8},children:[o.jsx("span",{style:{flex:1},children:k}),o.jsx("button",{type:"button",style:Jn(Hr,y||g),disabled:y||g,onClick:()=>p?void I(p):void N(),children:"重试"})]})]})}function w0({onStart:e,onDismiss:t}){return o.jsxs("div",{role:"region","aria-label":"开始试用引导",style:{maxWidth:420,padding:"24px 28px",textAlign:"center",background:"var(--bg-secondary)",color:"var(--text-primary)",border:"1px solid var(--border-primary)",borderRadius:12,boxShadow:"var(--cm-shadow-float)"},children:[o.jsx("div",{"aria-hidden":"true",style:{fontSize:32,marginBottom:8},children:o.jsx(mn,{size:32,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsx("h3",{style:{margin:"0 0 6px",fontSize:16,fontWeight:700},children:"开始试用编排平台"}),o.jsx("p",{style:{margin:"0 0 16px",fontSize:13,lineHeight:1.6,color:"var(--text-secondary)"},children:"登记你的产品、按规范命名,几分钟内就能在测试环境建出第一个流程,试跑通过后再申请上线。"}),o.jsxs("div",{style:{display:"flex",gap:8,justifyContent:"center"},children:[o.jsx("button",{type:"button",style:Hn,onClick:e,children:"开始试用"}),t&&o.jsx("button",{type:"button",style:Hr,onClick:t,children:"暂不使用"})]})]})}function NE(e){const[t,r]=T.useState({status:"idle",context:null,domains:[],products:[],error:null}),[n,s]=T.useState(0);T.useEffect(()=>{if(!e){r({status:"idle",context:null,domains:[],products:[],error:null});return}const l=new AbortController;return r(c=>({...c,status:"loading",error:null})),Promise.all([e.getContext(l.signal),e.listDomains(l.signal),e.listMyProducts(l.signal)]).then(([c,d,u])=>{l.signal.aborted||r({status:"ready",context:c,domains:d,products:u,error:null})},c=>{l.signal.aborted||g0(c)||r(d=>({...d,status:"error",error:c instanceof Error&&c.message?c.message:"加载自助接入信息失败"}))}),()=>l.abort()},[e,n]);const a=T.useCallback(()=>s(l=>l+1),[]),i=T.useCallback(l=>{r(c=>c.products.some(d=>d.name===l.name)?c:{...c,products:[...c.products,l]})},[]);return{...t,reload:a,addProduct:i}}function CE(e){const{provider:t,track:r,disabled:n,onPickTemplate:s,onImportApi:a,ownerEmail:i}=e,l=NE(t),{addProduct:c}=l,[d,u]=T.useState(!1),[p,f]=T.useState(!1),[m,h]=T.useState(void 0),[y,x]=T.useState(!1),[g,v]=T.useState(!1),k=T.useRef(null),b=T.useRef({}),S=te(R=>R.workflowDef?.name),j=te(R=>!!R.workflowDef);T.useEffect(()=>{u(!1),f(!1),h(void 0),x(!1),k.current=null,b.current={}},[t]);const _=!!t&&!n,w=i??l.context?.user?.email,I=T.useCallback(R=>{const O=te.getState(),$=(O.workflowDef?.tasks?.length??0)>0;O.setWorkflow(R.def),O.setMode("edit"),$||te.temporal.getState().clear(),h(R.level),k.current=R.source==="blank"?null:{name:R.def.name,description:R.def.description??"",ownerEmail:R.def.ownerEmail},r("workflow_created",{level:R.level,source:R.source})},[r]),N=T.useCallback(R=>{c(R),r("trial_started",{domain:R.domain})},[c,r]),C=l.context?.trialEnabled===!0,M=_&&l.status==="ready"&&C&&l.products.length===0&&!j&&!y&&!d;return{enabled:_,data:l,level:m,wizardOpen:d,promoOpen:p,openWizard:()=>{if((te.getState().workflowDef?.tasks?.length??0)>0){v(!0);return}k.current=null,u(!0)},confirmReplace:g,resolveConfirmReplace:R=>{v(!1),R&&(k.current=null,u(!0))},openPromotion:()=>f(!0),canPromote:_&&j&&a0(S),showGuide:M,dismissGuide:()=>x(!0),takePendingIdentity:()=>{const R=k.current;return k.current=null,R},provider:t,close:()=>{u(!1),f(!1)},handleCreate:I,handleTrialStarted:N,onPickTemplate:s,onImportApi:a,ownerEmail:w,track:r,getPendingPromotion:(R,O)=>b.current[`${R}@${O}`]??null,setPendingPromotion:(R,O,$)=>{const B=`${R}@${O}`;$?b.current[B]=$:delete b.current[B]}}}const Bp=(e,t)=>({height:28,padding:"0 10px",background:e?"var(--color-accent-bg)":"transparent",color:e?"var(--color-accent)":"var(--text-secondary)",border:`1px solid ${e?"var(--color-accent)":"var(--border-primary)"}`,borderRadius:6,cursor:t?"not-allowed":"pointer",opacity:t?.55:1,fontSize:12,fontWeight:600,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"});function EE({c:e}){if(!e.enabled)return null;const{status:t}=e.data,r=t==="ready";return o.jsxs(o.Fragment,{children:[t==="error"&&o.jsx("button",{type:"button",style:Bp(!1,!1),onClick:e.data.reload,title:e.data.error??"加载自助接入信息失败",children:"自助接入加载失败 · 重试"}),o.jsxs("button",{type:"button",style:Bp(!0,!r),disabled:!r,onClick:e.openWizard,title:r?"按命名规范新建流程(选择产品 → 命名 → 起点)":t==="loading"?"正在加载自助接入信息…":"自助接入暂不可用",children:[o.jsx("span",{"aria-hidden":"true",children:"+"}),o.jsx("span",{children:"新建流程"})]}),o.jsxs("button",{type:"button",style:Bp(!1,!e.canPromote),disabled:!e.canPromote,onClick:e.openPromotion,title:e.canPromote?"把当前临时流程申请上线到生产":"仅类型为 tmp 的临时流程可以申请上线",children:[o.jsx("span",{"aria-hidden":"true",children:o.jsx(mn,{size:14,strokeWidth:1.75,"aria-hidden":"true"})}),o.jsx("span",{children:"申请上线"})]})]})}function RE({c:e}){const t=te(a=>a.workflowDef?.name),r=te(a=>a.workflowDef?.version),{provider:n,data:s}=e;return!n||!e.enabled?null:o.jsxs(o.Fragment,{children:[e.confirmReplace&&o.jsx(Dt,{message:"新建流程会替换当前画布上的流程。替换后可以用撤销(⌘Z / Ctrl+Z)找回。继续新建吗?",confirmLabel:"继续新建",onConfirm:()=>e.resolveConfirmReplace(!0),onCancel:()=>e.resolveConfirmReplace(!1)}),e.wizardOpen&&s.context&&o.jsx(f0,{provider:n,trialEnabled:s.context.trialEnabled,products:s.products,domains:s.domains,defaultLevel:e.level,ownerEmail:e.ownerEmail,onClose:e.close,onCreate:e.handleCreate,onTrialStarted:e.handleTrialStarted,onPickTemplate:e.onPickTemplate,onImportApi:e.onImportApi}),e.promoOpen&&t&&o.jsx(k0,{provider:n,workflowName:t,version:r??1,onClose:e.close,onRequested:a=>e.track("promotion_requested",{targetType:a}),onStateChange:a=>e.track("promotion_state",{state:a}),resumeRequest:e.getPendingPromotion(t,r??1),onRequestChange:a=>e.setPendingPromotion(t,r??1,a)})]})}function OE({c:e}){return e.showGuide?o.jsx("div",{style:{position:"absolute",inset:0,zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",padding:24,pointerEvents:"none",background:"color-mix(in srgb, var(--bg-primary) 82%, transparent)"},children:o.jsx("div",{style:{pointerEvents:"auto"},children:o.jsx(w0,{onStart:e.openWizard,onDismiss:e.dismissGuide})})}):null}function PE(e,t){const r=e(t),n=()=>te.getState().markWorkflowSaved(t);if(r&&typeof r.then=="function"){Promise.resolve(r).then(n);return}n()}function AE(e,t){if(!e||!t)return!1;if(e===t)return!0;try{return JSON.stringify(e)===JSON.stringify(t)}catch{return!1}}const S0=T.forwardRef(({workflowDef:e,workflowDefSaved:t=!0,readOnly:r=!1,theme:n="dark",themeColor:s="blue",layoutDirection:a="LR",searchQuery:i="",workflowExecution:l,onRequestImport:c,executionActions:d,aiConfig:u,viewMode:p="developer",uiMode:f="pro",actions:m,libraryProvider:h,providers:y,currentWorkflowLevel:x,onSave:g,onWorkflowChange:v,height:k="100%",onTriggerExecution:b,onPollExecution:S,executionPollInterval:j=3e3},_)=>{const w=M2(y,{library:h}),I=w.library,N=J2("workflow",w.telemetry);U2(N),V2(N);const C=T.useCallback(E=>{N("step_added",{source:E.source})},[N]),M=T.useCallback(E=>{N("sandbox_run",{result:E,entry:"business"})},[N]),R=T.useCallback(E=>{N("sandbox_run",{result:E,entry:"template"})},[N]),[O,$]=T.useState("card"),[B,q]=T.useState(!1),[F,A]=T.useState(null),[W,P]=T.useState(!1),[D,Z]=T.useState([]),L=CE({provider:w.onboarding,track:N,disabled:r||!!l,onPickTemplate:()=>q(!0),onImportApi:()=>P(!0)}),[H,U]=T.useState(null),K=!!w.onboarding,se=L.data.domains,pe=T.useMemo(()=>{if(g)return E=>{U(K?dE(E.name,se):null),N("workflow_saved");const Q=te.getState().editWorkflowDefStash??E;PE(g,Q)}},[g,N,K,se]),we=x??L.level,[Ce]=T.useState(()=>new Kk);Yk(Ce,I);const ne=Xs(Ce),Te=T.useMemo(()=>{const E=I?tk(Ce):[];if((!m||m.length===0)&&E.length===0&&D.length===0)return Xe;const Q=new Vs(Xe.getAllActions());m&&Q.registerAll(m),Q.registerAll(D);for(const ae of E)Q.unregister(ae.id),Q.register(ae);return Q},[m,D,I,Ce,ne.revision]),{setWorkflow:le,setWorkflowDefOnly:V,refreshGraph:X,graphStale:z,setTheme:ve,setThemeColor:he,setLayoutDirection:_e,setNodesLocked:Se,selectedTask:be,setSelectedTask:ce,edgeType:Re,importExecutionJSON:De,setMode:Je,setViewMode:ee,isDetailPanelOpen:ue,setIsDetailPanelOpen:ie,selectTaskAction:ge,workflowDef:re,isSimRunning:Ie,startSimulation:Oe,stopSimulation:ke,mode:Ne,setShowRunPanel:Pe,showAnalysisPanel:je,setShowAnalysisPanel:Le,executionData:it,workflowInstance:lt}=te(Ae(E=>({setWorkflow:E.setWorkflow,setWorkflowDefOnly:E.setWorkflowDefOnly,refreshGraph:E.refreshGraph,graphStale:E.graphStale,setTheme:E.setTheme,setThemeColor:E.setThemeColor,setLayoutDirection:E.setLayoutDirection,setNodesLocked:E.setNodesLocked,selectedTask:E.selectedTask,setSelectedTask:E.setSelectedTask,edgeType:E.edgeType,importExecutionJSON:E.importExecutionJSON,setMode:E.setMode,setViewMode:E.setViewMode,isDetailPanelOpen:E.isDetailPanelOpen,setIsDetailPanelOpen:E.setIsDetailPanelOpen,selectTaskAction:E.selectTaskAction,workflowDef:E.workflowDef,isSimRunning:E.isSimRunning,startSimulation:E.startSimulation,stopSimulation:E.stopSimulation,mode:E.mode,setShowRunPanel:E.setShowRunPanel,showAnalysisPanel:E.showAnalysisPanel,setShowAnalysisPanel:E.setShowAnalysisPanel,executionData:E.executionData,workflowInstance:E.workflowInstance}))),fe=T.useCallback(E=>{for(let Q=0;Q<(E.tasks?.length??0);Q++)N("step_added",{source:"template"});le(E,a)},[N,le,a]),Ke=T.useCallback(()=>{const E=te.getState().getEditingWorkflowDef();if(!E)return;const Q=new Blob([JSON.stringify(E,null,2)],{type:"application/json"}),ae=URL.createObjectURL(Q),oe=document.createElement("a");oe.href=ae,oe.download=`${E.name||"workflow"}.json`,oe.click(),URL.revokeObjectURL(ae)},[]),{toasts:dr,showToast:ct,dismissToast:dt}=Vb(),Un=T.useCallback(async()=>{const E=te.getState().getEditingWorkflowDef();if(E)try{if(!navigator.clipboard?.writeText)throw new Error("当前浏览器不支持写入剪贴板");await navigator.clipboard.writeText(JSON.stringify(E,null,2)),ct(`已复制「${E.name||"未命名流程"}」的 Conductor DSL(JSON)`,"success")}catch(Q){const ae=Q instanceof Error&&Q.name==="NotAllowedError"?"浏览器没有授予剪贴板权限(页面需要在 HTTPS 下并处于焦点)":Q instanceof Error?Q.message:String(Q);ct(`复制失败:${ae}。可以改用「导出 JSON」下载文件`,"error")}},[ct]);T.useEffect(()=>{ve(n),he(s),_e(a),Se(r||!!l)},[n,s,a,r,l,ve,he,_e,Se]),T.useEffect(()=>{ee(l?"developer":p)},[p,l,ee]);const ma=T.useRef(t);ma.current=t;const ur=T.useRef(a);ur.current=a,T.useEffect(()=>{if(!e)return;const E=te.getState().getEditingWorkflowDef();if(AE(E,e))return;const Q=!E||E.name!==e.name;le(e,ur.current),te.getState().markWorkflowSaved(ma.current?void 0:null),Q&&te.temporal.getState().clear()},[e,le]),T.useEffect(()=>{l?De(l):Je(r?"view":"edit")},[l,De,Je,r]),T.useImperativeHandle(_,()=>({getWorkflowDef:()=>te.getState().getEditingWorkflowDef(),getValidationResults:()=>te.getState().validationResults,save:()=>{const E=te.getState().getEditingWorkflowDef();E&&pe&&pe(E)},createBlankWorkflow:E=>{te.getState().createBlankWorkflow(E),te.temporal.getState().clear()},openApiImport:()=>P(!0),markSaved:E=>te.getState().markWorkflowSaved(E)}),[pe]),T.useEffect(()=>{if(!v)return;let E=!0,Q=te.getState().workflowDef;return te.subscribe(oe=>{const de=oe.workflowDef;if(de!==Q){if(Q=de,E){E=!1;return}oe.editWorkflowDefStash||oe.mode==="run"||de&&v(de)}})},[v]);const Xt=f==="business"&&O==="card";T.useEffect(()=>{!Xt&&z&&X()},[Xt,z,X]);const ha=T.useCallback((E,Q)=>{if(E.length===0)return;const ae=new Set(E.map(de=>de.id));Z(de=>[...de.filter(Ee=>!ae.has(Ee.id)),...E]);const oe=t0(te.getState().workflowDef,E);Xt?V(oe):le(oe,a),N("api_imported",{format:Q.format,count:Q.count});for(let de=0;de<E.length;de++)N("step_added",{source:"import"})},[Xt,V,le,a,N]),ya=E=>{Ne!=="run"&&!l?ge(E,!0):ce(E)};return o.jsxs("div",{className:`workflow-ide ${n==="light"?"light-theme":""}`,"data-mode":n,"data-brand":s,style:{width:"100%",height:k,display:"flex",flexDirection:"column",position:"relative",overflow:"hidden"},children:[o.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",borderBottom:"1px solid var(--border)",background:"var(--bg-primary)",flexShrink:0,flexWrap:"wrap"},children:[f==="business"&&Ne!=="run"&&o.jsxs("div",{style:{display:"inline-flex",background:"var(--bg-highlight)",borderRadius:6,padding:2,border:"1px solid var(--border-secondary)"},children:[o.jsxs("button",{onClick:()=>$("card"),style:{height:24,padding:"0 8px",borderRadius:4,border:"none",background:O==="card"?"var(--color-accent)":"transparent",color:O==="card"?"var(--color-on-accent)":"var(--text-secondary)",cursor:"pointer",fontSize:11,fontWeight:500,display:"inline-flex",alignItems:"center",gap:4},children:[o.jsx(jT,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"业务卡片流"]}),o.jsxs("button",{onClick:()=>$("canvas"),style:{height:24,padding:"0 8px",borderRadius:4,border:"none",background:O==="canvas"?"var(--color-accent)":"transparent",color:O==="canvas"?"var(--color-on-accent)":"var(--text-secondary)",cursor:"pointer",fontSize:11,fontWeight:500,display:"inline-flex",alignItems:"center",gap:4},children:[o.jsx(AT,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"全景画布"]})]}),o.jsx("div",{style:{flex:1}}),Ne==="edit"&&!r&&o.jsxs("button",{onClick:()=>P(!0),style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-secondary)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"从 OpenAPI / Swagger / Postman / curl 导入接口,生成 HTTP 步骤",children:[o.jsx(wb,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),o.jsx("span",{children:"导入接口"})]}),Ne!=="run"&&o.jsx(EE,{c:L}),Ne!=="run"&&o.jsxs("button",{onClick:()=>q(!0),style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-secondary)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:600,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"打开场景化工作流模板中心",children:[o.jsx(TT,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),o.jsx("span",{children:"模板中心"})]}),Ne==="edit"&&re&&b&&o.jsxs("button",{onClick:()=>Pe(!0),style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--color-accent) 15%, transparent)",color:"var(--color-accent)",border:"1px solid color-mix(in srgb, var(--color-accent) 40%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:600,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"填写工作流入参并触发真实执行",children:[o.jsx(Ot,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"执行验证"]}),Ne==="run"&&it&&o.jsxs("button",{onClick:()=>Le(!je),style:{height:28,padding:"0 10px",background:je?"color-mix(in srgb, var(--color-accent) 20%, transparent)":"transparent",color:je?"var(--color-accent)":"var(--text-secondary)",border:`1px solid ${je?"color-mix(in srgb, var(--color-accent) 40%, transparent)":"var(--border-strong)"}`,borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"查看执行概览与异常分析",children:[o.jsx(Ns,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"分析"]}),Ne!=="run"&&re&&(Ie?o.jsxs("button",{onClick:ke,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-failed) 15%, transparent)",color:"var(--status-failed)",border:"1px solid color-mix(in srgb, var(--status-failed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"停止流转预览",children:[o.jsx(hn,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"停止"]}):o.jsxs("button",{onClick:Oe,style:{height:28,padding:"0 10px",background:"color-mix(in srgb, var(--status-completed) 15%, transparent)",color:"var(--status-completed)",border:"1px solid color-mix(in srgb, var(--status-completed) 30%, transparent)",borderRadius:6,cursor:"pointer",fontSize:12,fontWeight:500,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"按连线顺序播放步骤流转动画(不执行任何步骤)",children:[o.jsx(Ot,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"流转预览"]})),re&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{onClick:Ke,style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-secondary)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"导出工作流 JSON 文件",children:[o.jsx(bT,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"导出 JSON"]}),o.jsxs("button",{onClick:()=>{Un()},style:{height:28,padding:"0 10px",background:"transparent",color:"var(--text-secondary)",border:"1px solid var(--border-secondary)",borderRadius:6,cursor:"pointer",fontSize:12,display:"inline-flex",alignItems:"center",gap:5,fontFamily:"inherit"},title:"复制 Conductor DSL 到剪贴板",children:[o.jsx(db,{size:14,strokeWidth:1.75,"aria-hidden":"true"}),"复制 DSL"]})]})]}),o.jsx(Wb,{messages:dr,onDismiss:dt}),H&&o.jsxs("div",{role:"status",style:{display:"flex",alignItems:"center",gap:8,padding:"6px 12px",fontSize:12,color:"var(--cm-status-warning)",background:"var(--cm-warning-tint)",borderBottom:"1px solid var(--border)",flexShrink:0},children:[o.jsx(Ye,{size:14,strokeWidth:1.75,"aria-hidden":"true",style:{flexShrink:0}}),o.jsx("span",{style:{flex:1,color:"var(--text-primary)"},children:H}),o.jsx("button",{type:"button",onClick:()=>U(null),"aria-label":"关闭命名提示",style:{background:"none",border:"none",color:"var(--text-secondary)",cursor:"pointer",padding:2,display:"inline-flex"},children:o.jsx($e,{size:14,strokeWidth:1.75,"aria-hidden":"true"})})]}),f==="business"&&O==="card"?o.jsx("div",{style:{flex:1,position:"relative",overflow:"hidden"},children:o.jsx(E1,{workflowDef:re,workflowExecution:lt??void 0,registry:Te,libraryCatalog:I?Ce:void 0,currentWorkflowLevel:we,onStepAdded:C,onSandboxRun:M,readOnly:r||Ne==="run",onSave:pe,onUndo:()=>te.temporal.getState().undo(),onRedo:()=>te.temporal.getState().redo(),onChange:E=>{V(E)}})}):o.jsx("div",{className:"workflow-viewer",style:{flex:1,position:"relative",overflow:"hidden"},children:o.jsx(J.ReactFlowProvider,{children:o.jsx(YN,{onNodeClick:ya,edgeType:Re,theme:n,nodesLocked:r||Ne==="run"||!!l,searchQuery:i,onSave:pe,onRequestImport:c,executionActions:d})})}),o.jsx(a2,{task:be,isOpen:ue&&Ne!=="run",onClose:()=>ie(!1),theme:n,aiConfig:u}),(l||Ne==="run")&&o.jsx(i2,{executionActions:d}),o.jsx(h2,{aiConfig:u}),o.jsx(w2,{onTriggerExecution:b,onPollExecution:S,executionPollInterval:j}),Ne==="run"&&o.jsx(R2,{}),o.jsx(e0,{open:W,onClose:()=>P(!1),onInsert:ha,existingActionIds:W?Te.getAllActions().map(E=>E.id):void 0}),o.jsx(O1,{isOpen:B,onClose:()=>{q(!1),L.takePendingIdentity()},onSandboxRun:R,onSelectTemplate:E=>{const Q=L.takePendingIdentity(),ae=Q?{...E,name:Q.name,description:Q.description||E.description,...Q.ownerEmail?{ownerEmail:Q.ownerEmail}:{}}:E,oe=te.getState().getEditingWorkflowDef();if((oe?.tasks?.length??0)>0){A({def:ae,replacing:oe?.name||"未命名流程"});return}fe(ae)}}),F&&o.jsx(Dt,{message:`用模板创建的「${F.def.name}」会替换当前画布上的「${F.replacing}」。替换后可以用撤销(⌘Z / Ctrl+Z)找回。`,confirmLabel:"替换当前流程",onConfirm:()=>{const{def:E}=F;A(null),fe(E)},onCancel:()=>A(null)}),o.jsx(RE,{c:L}),o.jsx(OE,{c:L})]})});S0.displayName="WorkflowIDE";const $E={workflows:"/metadata/workflow",workflow:"/metadata/workflow",taskDefs:"/metadata/taskdefs"};function Hp(e,t){return`${e.replace(/\/+$/,"")}/${t.replace(/^\/+/,"")}`}function DE(e){const t={...$E,...e.paths??{}},r=(i,l)=>{const c=e.fetch??(typeof fetch=="function"?fetch:void 0);return c?c(i,l):Promise.reject(new Error("当前环境没有 fetch,请通过 options.fetch 传入"))};async function n(i,l){const c=e.headers?await e.headers():{};return r(i,{method:"GET",headers:{Accept:"application/json",...c},signal:l})}function s(i){const l=e.resolveExtension?.(i);return{def:i,...l?{extension:l}:{},...l?.deprecated?{deprecated:!0}:{}}}function a(i,l){const c=encodeURIComponent(i),d=t.workflow.includes("{name}")?t.workflow.replace("{name}",c):`${t.workflow.replace(/\/+$/,"")}/${c}`,u=Hp(e.baseUrl,d);return l!==void 0?`${u}?version=${encodeURIComponent(String(l))}`:u}return{async list(i){const l=Hp(e.baseUrl,t.workflows),c=await n(l,i);if(!c.ok)throw new Error(`获取流程库列表失败:HTTP ${c.status}(${l})`);const d=await c.json();if(!Array.isArray(d))throw new Error(`流程库列表返回格式不正确(期望数组):${l}`);const u=new Map;for(const f of d){if(!f||typeof f.name!="string"||e.filter&&!e.filter(f))continue;const m=u.get(f.name);(!m||On(f.version).version>=On(m.version).version)&&u.set(f.name,f)}const p={workflows:Array.from(u.values()).map(s)};if(e.includeTaskDefs){const f=Hp(e.baseUrl,t.taskDefs),m=await n(f,i);if(!m.ok)throw new Error(`获取任务定义失败:HTTP ${m.status}(${f})`);const h=await m.json();if(!Array.isArray(h))throw new Error(`任务定义返回格式不正确(期望数组):${f}`);p.tasks=h.filter(y=>y&&typeof y.name=="string").map(y=>{const x=e.resolveTaskExtension?.(y);return{def:y,...x?{extension:x}:{}}})}return p},async get(i,l,c){const d=a(i,l),u=await n(d,c);if(u.status===404)return null;if(!u.ok)throw new Error(`获取流程库工作流「${i}」失败:HTTP ${u.status}(${d})`);const p=await u.json();return!p||typeof p.name!="string"||e.filter&&!e.filter(p)?null:s(p)}}}G.ActionForm=xp,G.ActionRegistry=Vs,G.ApiImportDialog=e0,G.BUILTIN_COMMON_ACTIONS=Uk,G.BUILTIN_ECS_ACTIONS=Jk,G.BUILTIN_WORKFLOW_TEMPLATES=Fk,G.DataPillInput=ea,G.DecisionBranchCard=Np,G.ForkJoinCard=_p,G.FriendlyErrorCard=I1,G.JqError=xe,G.LibraryCatalog=Kk,G.LoopDoWhileCard=jp,G.OTHER_DOMAIN=Fs,G.OnboardingGuideCard=w0,G.OnboardingWizard=f0,G.PromotionPanel=k0,G.RunStoryTimeline=N1,G.StepFlowEditor=E1,G.TemplateExtractor=Hk,G.TemplateGallery=O1,G.TemplateSetupWizard=R1,G.TemplateStore=Bk,G.WORKFLOW_NAME_TYPES=Ks,G.WorkflowIDE=S0,G.WorkflowIdeProvider=D2,G.WorkflowNameBuilder=u0,G.analyzeTasksForPruning=Wk,G.appendImportedActions=t0,G.applyTaskPruning=zk,G.applyTemplateVariables=Ep,G.applyUpgradeToValues=Sp,G.buildActionFromTaskDef=Qu,G.buildActionFromWorkflowDef=Zu,G.buildActionsFromLibrary=eN,G.buildActionsFromTaskDefs=tN,G.buildDataFlowGraph=lu,G.buildDefaultWorkflowMockInput=ln,G.buildHttpAction=Y1,G.buildPromotionTimeline=y0,G.buildSkeletonWorkflow=o0,G.buildUpgradeConfirmMessage=x1,G.buildWorkflowName=Bn,G.canCallLevel=ek,G.collectLibraryDomains=sk,G.collectReferencedOutputKeys=wp,G.compileStepModelToWorkflowDef=r1,G.compileStepToTaskDef=pp,G.createConductorLibraryProvider=DE,G.createStepFromAction=lr,G.createTelemetryBuffer=e1,G.createWorkerScriptEvaluator=qv,G.decompileTaskDefToStep=n1,G.decompileWorkflowDefToStepModel=s1,G.defaultActionRegistry=Xe,G.defaultTemplateStore=op,G.describeUnavailable=b1,G.detectFormat=UC,G.diffWorkflowVersions=h1,G.entriesToLibraryItems=tp,G.entryFromRecord=Ys,G.executeLocalSandboxDryRun=Lj,G.executeLocalSandboxDryRunAsync=cn,G.extractTemplateFromInstance=qk,G.filterPickableActions=nk,G.generateDefaultTaskOutputPreview=Ts,G.getCompletionItems=Cv,G.getUpstreamAncestors=ys,G.inferTaskOutputSchema=Nv,G.isDiffEmpty=y1,G.isPromotableName=a0,G.isTerminalPromotionState=pa,G.libraryDomainOf=Bs,G.nextPollDelay=m0,G.normalizeVersion=On,G.parseApiText=K1,G.parseCurl=U1,G.parseOpenApi3=F1,G.parsePostman21=J1,G.parseSwagger2=B1,G.parseWorkflowInputParams=St,G.parseWorkflowName=Gs,G.pollPromotion=x0,G.promotionStateLabel=jE,G.promotionTargetName=s0,G.refactorTaskReferenceName=xs,G.resolveLibraryBadgeState=v1,G.resolveProviders=cp,G.runJq=Wv,G.sanitizeHeaders=Pp,G.scanObjectForSensitiveFindings=Js,G.scanWorkflowDef=Lk,G.schemaToTypeStrings=kn,G.stabilizeProviders=Zk,G.suggestFuncSlug=n0,G.summarizeDiff=g1,G.toActionExtension=ep,G.toActions=tk,G.toLibraryItems=sN,G.toTaskSchemas=nN,G.translateTechnicalError=Cp,G.useIdeProviders=L2,G.useLibraryCatalogLoader=Yk,G.useLibraryCatalogSnapshot=Xs,G.validateNameParts=qp,G.validateWorkflowName=ip,Object.defineProperty(G,Symbol.toStringTag,{value:"Module"})}));
|