@digitalsee-ai/rcs 2.0.0-pre2 → 2.0.0-pre4
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/dist/components/digitalsee/workflow/NodesConfig/ActionNodeConfig/index.d.ts +0 -1
- package/dist/components/digitalsee/workflow/NodesConfig/components/FormFieldRenderer/index.d.ts +0 -1
- package/dist/{index-CxelobfJ.mjs → index-BqkisUDR.mjs} +1468 -1468
- package/dist/{index-Apyd0VKQ.mjs → index-DNV524HS.mjs} +2 -2
- package/dist/rcs.css +1 -1
- package/dist/rcs.es.js +1 -1
- package/dist/rcs.umd.js +3 -3
- package/package.json +1 -1
package/dist/rcs.umd.js
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
Copyright (c) 2018 Jed Watson.
|
|
11
11
|
Licensed under the MIT License (MIT), see
|
|
12
12
|
http://jedwatson.github.io/classnames
|
|
13
|
-
*/var I0;function FP(){return I0||(I0=1,(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var i="",s=0;s<arguments.length;s++){var a=arguments[s];a&&(i=o(i,r(a)))}return i}function r(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return n.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var s="";for(var a in i)e.call(i,a)&&i[a]&&(s=o(s,a));return s}function o(i,s){return s?i?i+" "+s:i+s:i}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(ph)),ph.exports}var MP=FP();const ar=Un(MP),P0=({type:t,id:e,nodeId:n,position:r=ne.Position.Right,style:o={},isValidConnection:i,onConnect:s,label:a,status:l,nodeStatus:c=me.IDLE,category:u="main",protocol:d,shape:f="rhombus",connectionLimit:p=1/0,index:m})=>{const{getHandleConnections:v,handleStatus:b}=EP(),{getEdges:w,getNode:g}=ne.useReactFlow(),{getNodes:C}=aa(),k=Ot(),_=$t(),{openNodeSelector:S,nodeSelectorVisible:E}=dc(),x=q=>q.inProgress,B=v(n,e,(q=>q==="source"?nh.OUTPUT:nh.INPUT)(t)).length>=p,I=ne.useConnection(x),F=ne.useConnection(q=>NP({connection:q,nodeId:n,handleId:e},w())),N=B&&!F,P=OP({type:t,handleId:e,isFull:B,connectionInProgress:I,canEdit:k}),M=TP(t,k),z=b(n,e),H=l||z&&z||"default",R=y.useCallback(q=>{const J=mc(C(),q);return J.valid||console.warn(J.code,J.message),J.valid},[C]),Y=y.useCallback(()=>{var ue,ve;const q=g(n);if(!q)return{x:0,y:0};const J=((ue=q.measured)==null?void 0:ue.width)||240,re=((ve=q.measured)==null?void 0:ve.height)||240;let Z={x:0,y:0};switch(r){case ne.Position.Right:Z={x:q.position.x+J+100,y:q.position.y};break;case ne.Position.Left:Z={x:q.position.x-J-100,y:q.position.y};break;case ne.Position.Bottom:Z={x:q.position.x,y:q.position.y+re+100};break;case ne.Position.Top:Z={x:q.position.x,y:q.position.y-100};break}return Z},[n,r,g]),te=q=>{var we;q.stopPropagation();const J=t==="target"&&fh(e);if(t!=="source"&&!J)return;const re=C(),Z=(we=_.canvas.limits)==null?void 0:we.maxNodes;if(typeof Z=="number"&&re.length>=Z){D.message.warning("已达到画布允许的最大节点数");return}const ue=g(n),ve=Y();S(BP({type:t,nodeId:n,handleId:e,position:ve,protocol:J?void 0:d,anchorNode:ue,refresh:E}))},$=Qo.main,j=()=>{switch(H){case"connected":return Qo.connected;case"connecting":return Qo.connecting;case"error":return Qo.error;default:return{}}},U=()=>Object.hasOwn(Qo.nodeStatus,c)?Qo.nodeStatus[c]:{},ee={...$,...j(),...U(),...o},ie=ar("workflow-handle",`workflow-${t}-handle`,"nodrag nopan",`workflow-handle-${H}`,`workflow-handle-${u}`,{"workflow-handle-with-label":!!a,"workflow-handle-main":u==="main","workflow-handle-full":N,"workflow-handle-success":c===me.SUCCESS||c===me.RUNNABLE,"workflow-handle-running":c===me.RUNNING,"workflow-handle-failed":c===me.FAILED,"workflow-handle-invalid":c===me.INVALID},`workflow-handle-target-${r}`,`workflow-handle-shape-${f}`),be=()=>{let q={position:"absolute",zIndex:5,pointerEvents:"all"},J={...rr.line,width:"100%",height:"100%"},re={position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",zIndex:6,...rr.button};const[Z=0,ue=1,ve]=m??[0,1,1];switch(r){case ne.Position.Right:q={...q,left:"100%",top:"50%",transform:"translateY(-50%)",width:rr.horizontal.width,height:rr.horizontal.height},re={...re,left:"calc(100% - 10px)",top:"50%",transform:"translate(50%, -50%)",marginRight:-7},J={...J};break;case ne.Position.Left:q={...q,right:"100%",top:"50%",transform:"translateY(-50%)",width:rr.horizontal.width,height:rr.horizontal.height},re={...re,left:0,top:"50%",transform:"translate(-50%, -50%)"},J={...J,left:0};break;case ne.Position.Bottom:q={...q,top:"100%",left:`${20+60/(ve+1)*(Z+1)}%`,width:rr.vertical.width,height:rr.vertical.height},J={...J,left:0},re={...re,left:"50%",top:"100%",transform:"translate(-50%, -50%)"};break;case ne.Position.Top:q={...q,bottom:"100%",left:"50%",transform:"translateX(-50%)",width:rr.vertical.width,height:rr.vertical.height},re={...re,left:"50%",top:0,transform:"translate(-50%, -50%)"};break}return{containerStyle:q,extenderStyle:J,btnStyle:re}},W=()=>{if(!P)return null;const q=be();return h.jsxs("div",{className:"workflow-handle-extender-container nodrag nopan",style:q.containerStyle,children:[h.jsx("div",{className:"workflow-handle-extender",style:q.extenderStyle}),h.jsx("div",{className:"workflow-handle-extender-btn",style:q.btnStyle,onMouseDown:J=>J.stopPropagation(),onClick:te,children:h.jsx(RB.AiOutlinePlusCircle,{})})]})},X=()=>{if(!a)return null;let q;switch(r){case ne.Position.Left:q={left:-8,textAlign:"right"};break;case ne.Position.Right:q={right:-48,top:-3,position:"absolute",zIndex:1e3,textAlign:"center"};break;case ne.Position.Top:q={position:"absolute",top:-25,left:"-150%",textAlign:"center"};break;case ne.Position.Bottom:q={position:"absolute",bottom:-18,left:"-150%",textAlign:"center"};break;default:q={right:-8}}return h.jsx("span",{className:"workflow-handle-label",style:q,children:a})};return h.jsxs(ne.Handle,{type:t,position:r,id:e,isConnectableStart:M.isConnectableStart,isConnectableEnd:M.isConnectableEnd,isConnectable:!N,isValidConnection:R,onConnect:s,className:ie,style:{...ee,overflow:"visible"},children:[a&&k&&(m&&m.length===3?m[1]>1:!0)&&X(),W()]})},{Text:L0}=D.Typography,{TextArea:IP}=D.Input,PP=({title:t,description:e,note:n,nodeId:r,statusIcon:o,className:i="",onNoteChange:s})=>{const[a,l]=y.useState(!1),[c,u]=y.useState(""),[d,f]=y.useState(!1),p=Ot();if(y.useEffect(()=>{u(n||e||"")},[n,e]),!t&&!e&&!n)return null;const m=C=>{C.stopPropagation(),l(!0)},v=C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),C.stopPropagation(),l(!0))},b=async()=>{if(!r){D.message.error("节点ID不能为空"),l(!1);return}if(c===(n||e||"")){l(!1);return}f(!0);try{await Vy(r,c),D.message.success(K("link.flow.remark_modification_success")),s==null||s(c),l(!1)}catch(C){D.message.error("备注保存失败"),console.error("保存备注失败:",C),u(n||e||"")}finally{f(!1)}},w=()=>{u(n||e||""),l(!1)},g=C=>{C.key==="Enter"&&(C.ctrlKey||C.metaKey)?b():C.key==="Escape"&&w()};return h.jsxs("div",{className:`workflow-node-description-container ${i}`,children:[t&&h.jsxs("div",{className:"workflow-node-title-row",children:[h.jsx("span",{className:"workflow-node-title-text",children:t}),o&&h.jsx("span",{className:"workflow-node-status-slot",children:o})]}),h.jsx("div",{className:"workflow-node-description-wrapper",children:a?h.jsx(D.Spin,{spinning:d,children:h.jsx(IP,{size:"small",value:c,onDoubleClick:C=>C.stopPropagation(),onDragStart:C=>C.stopPropagation(),onDrag:C=>C.stopPropagation(),onChange:C=>u(C.target.value),onBlur:b,onKeyDown:g,placeholder:"请输入备注...",autoSize:{minRows:1,maxRows:4},autoFocus:!0,className:"workflow-node-note-editor nodrag",style:{borderStyle:"dashed",fontSize:9,minHeight:"auto",paddingInline:3}})}):p?h.jsxs("div",{className:"workflow-node-note-display is-editable",onClick:m,onKeyDown:v,children:[h.jsx(L0,{className:`workflow-node-description ${c?"":"workflow-node-description-placeholder"}`,children:c||"点击添加备注..."}),h.jsx(se.EditOutlined,{className:"workflow-node-edit-icon"})]}):h.jsx("div",{className:"workflow-node-note-display",children:h.jsx(L0,{className:"workflow-node-description",children:c})})})]})};var $0=Symbol.for("immer-nothing"),z0=Symbol.for("immer-draftable"),hn=Symbol.for("immer-state");function lr(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Tn=Object,qi=Tn.getPrototypeOf,wc="constructor",bc="prototype",mh="configurable",vc="enumerable",yc="writable",la="value",ho=t=>!!t&&!!t[hn];function Wr(t){var e;return t?V0(t)||Sc(t)||!!t[z0]||!!((e=t[wc])!=null&&e[z0])||Ec(t)||xc(t):!1}var LP=Tn[bc][wc].toString(),H0=new WeakMap;function V0(t){if(!t||!wh(t))return!1;const e=qi(t);if(e===null||e===Tn[bc])return!0;const n=Tn.hasOwnProperty.call(e,wc)&&e[wc];if(n===Object)return!0;if(!Gi(n))return!1;let r=H0.get(n);return r===void 0&&(r=Function.toString.call(n),H0.set(n,r)),r===LP}function Cc(t,e,n=!0){ca(t)===0?(n?Reflect.ownKeys(t):Tn.keys(t)).forEach(o=>{e(o,t[o],t)}):t.forEach((r,o)=>e(o,r,t))}function ca(t){const e=t[hn];return e?e.type_:Sc(t)?1:Ec(t)?2:xc(t)?3:0}var j0=(t,e,n=ca(t))=>n===2?t.has(e):Tn[bc].hasOwnProperty.call(t,e),gh=(t,e,n=ca(t))=>n===2?t.get(e):t[e],kc=(t,e,n,r=ca(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function $P(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var Sc=Array.isArray,Ec=t=>t instanceof Map,xc=t=>t instanceof Set,wh=t=>typeof t=="object",Gi=t=>typeof t=="function",bh=t=>typeof t=="boolean";function zP(t){const e=+t;return Number.isInteger(e)&&String(e)===t}var Ur=t=>t.copy_||t.base_,vh=t=>t.modified_?t.copy_:t.base_;function yh(t,e){if(Ec(t))return new Map(t);if(xc(t))return new Set(t);if(Sc(t))return Array[bc].slice.call(t);const n=V0(t);if(e===!0||e==="class_only"&&!n){const r=Tn.getOwnPropertyDescriptors(t);delete r[hn];let o=Reflect.ownKeys(r);for(let i=0;i<o.length;i++){const s=o[i],a=r[s];a[yc]===!1&&(a[yc]=!0,a[mh]=!0),(a.get||a.set)&&(r[s]={[mh]:!0,[yc]:!0,[vc]:a[vc],[la]:t[s]})}return Tn.create(qi(t),r)}else{const r=qi(t);if(r!==null&&n)return{...t};const o=Tn.create(r);return Tn.assign(o,t)}}function Ch(t,e=!1){return _c(t)||ho(t)||!Wr(t)||(ca(t)>1&&Tn.defineProperties(t,{set:Dc,add:Dc,clear:Dc,delete:Dc}),Tn.freeze(t),e&&Cc(t,(n,r)=>{Ch(r,!0)},!1)),t}function HP(){lr(2)}var Dc={[la]:HP};function _c(t){return t===null||!wh(t)?!0:Tn.isFrozen(t)}var Ac="MapSet",kh="Patches",W0="ArrayMethods",U0={};function ei(t){const e=U0[t];return e||lr(0,t),e}var q0=t=>!!U0[t],ua,G0=()=>ua,VP=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:q0(Ac)?ei(Ac):void 0,arrayMethodsPlugin_:q0(W0)?ei(W0):void 0});function R0(t,e){e&&(t.patchPlugin_=ei(kh),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Sh(t){Eh(t),t.drafts_.forEach(jP),t.drafts_=null}function Eh(t){t===ua&&(ua=t.parent_)}var K0=t=>ua=VP(ua,t);function jP(t){const e=t[hn];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Y0(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[hn].modified_&&(Sh(e),lr(4)),Wr(t)&&(t=X0(e,t));const{patchPlugin_:o}=e;o&&o.generateReplacementPatches_(n[hn].base_,t,e)}else t=X0(e,n);return WP(e,t,!0),Sh(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==$0?t:void 0}function X0(t,e){if(_c(e))return e;const n=e[hn];if(!n)return Tc(e,t.handledSet_,t);if(!Oc(n,t))return e;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(t);Z0(n,t)}return n.copy_}function WP(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&Ch(e,n)}function J0(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var Oc=(t,e)=>t.scope_===e,UP=[];function Q0(t,e,n,r){const o=Ur(t),i=t.type_;if(r!==void 0&&gh(o,r,i)===e){kc(o,r,n,i);return}if(!t.draftLocations_){const a=t.draftLocations_=new Map;Cc(o,(l,c)=>{if(ho(c)){const u=a.get(c)||[];u.push(l),a.set(c,u)}})}const s=t.draftLocations_.get(e)??UP;for(const a of s)kc(o,a,n,i)}function qP(t,e,n){t.callbacks_.push(function(o){var a;const i=e;if(!i||!Oc(i,o))return;(a=o.mapSetPlugin_)==null||a.fixSetContents(i);const s=vh(i);Q0(t,i.draft_??i,s,n),Z0(i,o)})}function Z0(t,e){var r;if(t.modified_&&!t.finalized_&&(t.type_===3||t.type_===1&&t.allIndicesReassigned_||(((r=t.assigned_)==null?void 0:r.size)??0)>0)){const{patchPlugin_:o}=e;if(o){const i=o.getPath(t);i&&o.generatePatches_(t,i,e)}J0(t)}}function GP(t,e,n){const{scope_:r}=t;if(ho(n)){const o=n[hn];Oc(o,r)&&o.callbacks_.push(function(){Bc(t);const s=vh(o);Q0(t,n,s,e)})}else Wr(n)&&t.callbacks_.push(function(){const i=Ur(t);t.type_===3?i.has(n)&&Tc(n,r.handledSet_,r):gh(i,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&Tc(gh(t.copy_,e,t.type_),r.handledSet_,r)})}function Tc(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||ho(t)||e.has(t)||!Wr(t)||_c(t)||(e.add(t),Cc(t,(r,o)=>{if(ho(o)){const i=o[hn];if(Oc(i,n)){const s=vh(i);kc(t,r,s,t.type_),J0(i)}}else Wr(o)&&Tc(o,e,n)})),t}function RP(t,e){const n=Sc(t),r={type_:n?1:0,scope_:e?e.scope_:G0(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let o=r,i=Nc;n&&(o=[r],i=da);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,[a,r]}var Nc={get(t,e){if(e===hn)return t;let n=t.scope_.arrayMethodsPlugin_;const r=t.type_===1&&typeof e=="string";if(r&&n!=null&&n.isArrayOperationMethod(e))return n.createMethodInterceptor(t,e);const o=Ur(t);if(!j0(o,e,t.type_))return KP(t,o,e);const i=o[e];if(t.finalized_||!Wr(i)||r&&t.operationMethod&&(n!=null&&n.isMutatingArrayMethod(t.operationMethod))&&zP(e))return i;if(i===xh(t.base_,e)){Bc(t);const s=t.type_===1?+e:e,a=_h(t.scope_,i,t,s);return t.copy_[s]=a}return i},has(t,e){return e in Ur(t)},ownKeys(t){return Reflect.ownKeys(Ur(t))},set(t,e,n){const r=eC(Ur(t),e);if(r!=null&&r.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const o=xh(Ur(t),e),i=o==null?void 0:o[hn];if(i&&i.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if($P(n,o)&&(n!==void 0||j0(t.base_,e,t.type_)))return!0;Bc(t),Dh(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_.set(e,!0),GP(t,e,n)),!0},deleteProperty(t,e){return Bc(t),xh(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),Dh(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Ur(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[yc]:!0,[mh]:t.type_!==1||e!=="length",[vc]:r[vc],[la]:n[e]}},defineProperty(){lr(11)},getPrototypeOf(t){return qi(t.base_)},setPrototypeOf(){lr(12)}},da={};for(let t in Nc){let e=Nc[t];da[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}}da.deleteProperty=function(t,e){return da.set.call(this,t,e,void 0)},da.set=function(t,e,n){return Nc.set.call(this,t[0],e,n,t[0])};function xh(t,e){const n=t[hn];return(n?Ur(n):t)[e]}function KP(t,e,n){var o;const r=eC(e,n);return r?la in r?r[la]:(o=r.get)==null?void 0:o.call(t.draft_):void 0}function eC(t,e){if(!(e in t))return;let n=qi(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=qi(n)}}function Dh(t){t.modified_||(t.modified_=!0,t.parent_&&Dh(t.parent_))}function Bc(t){t.copy_||(t.assigned_=new Map,t.copy_=yh(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var YP=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,n,r)=>{if(Gi(e)&&!Gi(n)){const i=n;n=e;const s=this;return function(l=i,...c){return s.produce(l,u=>n.call(this,u,...c))}}Gi(n)||lr(6),r!==void 0&&!Gi(r)&&lr(7);let o;if(Wr(e)){const i=K0(this),s=_h(i,e,void 0);let a=!0;try{o=n(s),a=!1}finally{a?Sh(i):Eh(i)}return R0(i,r),Y0(o,i)}else if(!e||!wh(e)){if(o=n(e),o===void 0&&(o=e),o===$0&&(o=void 0),this.autoFreeze_&&Ch(o,!0),r){const i=[],s=[];ei(kh).generateReplacementPatches_(e,o,{patches_:i,inversePatches_:s}),r(i,s)}return o}else lr(1,e)},this.produceWithPatches=(e,n)=>{if(Gi(e))return(s,...a)=>this.produceWithPatches(s,l=>e(l,...a));let r,o;return[this.produce(e,n,(s,a)=>{r=s,o=a}),r,o]},bh(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),bh(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),bh(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){Wr(t)||lr(8),ho(t)&&(t=XP(t));const e=K0(this),n=_h(e,t,void 0);return n[hn].isManual_=!0,Eh(e),n}finishDraft(t,e){const n=t&&t[hn];(!n||!n.isManual_)&&lr(9);const{scope_:r}=n;return R0(r,e),Y0(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const o=e[n];if(o.path.length===0&&o.op==="replace"){t=o.value;break}}n>-1&&(e=e.slice(n+1));const r=ei(kh).applyPatches_;return ho(t)?r(t,e):this.produce(t,o=>r(o,e))}};function _h(t,e,n,r){const[o,i]=Ec(e)?ei(Ac).proxyMap_(e,n):xc(e)?ei(Ac).proxySet_(e,n):RP(e,n);return((n==null?void 0:n.scope_)??G0()).drafts_.push(o),i.callbacks_=(n==null?void 0:n.callbacks_)??[],i.key_=r,n&&r!==void 0?qP(n,i,r):i.callbacks_.push(function(l){var u;(u=l.mapSetPlugin_)==null||u.fixSetContents(i);const{patchPlugin_:c}=l;i.modified_&&c&&c.generatePatches_(i,[],l)}),o}function XP(t){return ho(t)||lr(10,t),tC(t)}function tC(t){if(!Wr(t)||_c(t))return t;const e=t[hn];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=yh(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=yh(t,!0);return Cc(n,(o,i)=>{kc(n,o,tC(i))},r),e&&(e.finalized_=!1),n}var JP=new YP,fa=JP.produce;const Ri=()=>{const t=ne.useStoreApi(),{setNodes:e}=ne.useReactFlow(),n=$t();return{handleNodeDataUpdate:y.useCallback(({id:o,data:i,sync:s})=>{const{nodes:a}=t.getState(),l=fa(a,c=>{const u=c.find(d=>d.id===o);u&&(u.data={...u.data,...i}),s&&rc(o,{flow_id:n.flowId,properties:u.data.config_schema})});e(l)},[t])}},QP=new Set(["properties","params","account_id","proxy_id","mcp_tool_description"]);function qr(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}function po(t={}){const e=t==null?void 0:t.action_id,n=typeof e=="number"?e:parseInt(`${e??""}`,10);return!Number.isFinite(n)||n<=0}function ha(t){if(!qr(t))return{};const e=t.properties,n=t.params,r=qr(e)?e:qr(n)?n:void 0;if(!r)return t;const i=Object.keys(t).every(a=>QP.has(a)),s=["account_id","proxy_id","mcp_tool_description","isNodePackage"].some(a=>Object.hasOwn(t,a));return i||s?r:t}function ZP(t){if(!qr(t))return{};const e=qr(t.properties)?t.properties:qr(t.params)?t.params:t;return ha(e)}function e2(t){return qr(t)?Object.hasOwn(t,"account_id")?t.account_id??null:qr(t.properties)&&Object.hasOwn(t.properties,"account_id")?t.properties.account_id??null:qr(t.params)&&Object.hasOwn(t.params,"account_id")?t.params.account_id??null:null:null}const t2=t=>t.mode??t.configMode??"edit",n2=(t,e)=>t!=="preview"&&!e,Ah=t=>t==="preview",Oh=t=>{var n,r,o;if(!t)return!1;if(((n=t.data)==null?void 0:n.action_key)==="dip.core.trigger.mcp-server"||t.type===pe.TRIGGER)return!0;const e=t.data;if(!e)return!1;if(typeof e.is_trigger<"u")return e.is_trigger===!0||e.is_trigger===1||e.is_trigger==="1";if(/@/.test(t.type)&&((r=t.data)!=null&&r.action_key)&&((o=t.data)!=null&&o.action_ver)){const i=_P(t.data.action_key,t.data.action_ver);if(i&&i.is_trigger!=null)return i.is_trigger}return!1},r2=t=>({label:t.action_name,description:t.connector_name,config_schema:t.config_schema||t.properties,...Object.entries(t).reduce((e,[n,r])=>(n!=="name"&&(e[n]=r),e),{})}),Th={color:"#3883f6"},o2=[pe.TRIGGER,pe.AI_SUB_NODE],i2=[pe.TRIGGER,pe.AI_SUB_NODE],s2=({nodeId:t,isDisabled:e=!1,handleViewConfig:n,onDelete:r,className:o,type:i})=>{const{handleNodeDataUpdate:s}=Ri(),{addNodes:a,getNodes:l}=aa(),c=$t(),u=ne.useInternalNode(t),d=Ot(),f=na(),p=Oh(u),[m,v]=y.useState(!1),b=y.useMemo(()=>{var I;const O=c.nodeTypes;if(!u)return;const A=O.types[u.type];if(A)return A;const T=(I=u.data)==null?void 0:I.category;return T?Object.values(O.types).find(F=>F.category===T):void 0},[c.nodeTypes,u]),w=y.useMemo(()=>((b==null?void 0:b.operations)||[]).reduce((A,T)=>(A[T.id]=T.enabled,A),{}),[b]),g=y.useMemo(()=>{var T,B;if(!u)return!1;const O=((T=c.canvas.fixedNodes)==null?void 0:T.triggerIds)||[],A=((B=c.nodeTypes.fixed)==null?void 0:B.triggers)||[];return O.includes(u.id)||A.includes(u.type)},[c.canvas.fixedNodes,c.nodeTypes.fixed,u]),C=y.useMemo(()=>{if(p)return!1;const O=!o2.includes(i),A=w.copy===void 0?!0:w.copy;return O&&A&&d},[i,w,d,p]),k=y.useMemo(()=>{if(p)return!1;const O=!i2.includes(i),A=w.disable===void 0?!0:w.disable;return O&&A&&d},[i,w,d,p]),_=()=>{jy(t,e?"on":"off").then(O=>{s({id:t,data:{closed:O.closed,status:O.status}})})},S=y.useMemo(()=>!Ah(f)&&!d,[f,d]);y.useMemo(()=>d&&!g&&c.canvas.allowRemoveTrigger,[d,g,c.canvas.allowRemoveTrigger]);const E=()=>{r&&r(t)},x=async()=>{var B;if(m)return;const O=l(),A=O.find(I=>I.id===t);if(!A){D.message.error("获取当前节点信息失败");return}const T=(B=c.canvas.limits)==null?void 0:B.maxNodes;if(typeof T=="number"&&O.length>=T){D.message.warning("已达到画布允许的最大节点数");return}v(!0);try{const I=await eh(t);if(I){const N=po(I)?ia(I.action_key,I.action_ver):I.node_type,P=Ni.createNode(N,I.id,{...r2(I),saveType:I.node_type},{x:A.position.x,y:A.position.y+100});a([P]),D.message.success("节点复制成功")}}catch(I){D.message.error("节点复制失败"),console.error("复制节点失败:",I)}finally{v(!1)}};return h.jsxs("div",{className:ar("node-operations",o),children:[C&&h.jsx(D.Tooltip,{title:"复制节点",children:h.jsx(D.Button,{type:"text",icon:h.jsx(Af.IoCopyOutline,{style:Th}),onClick:x,loading:m,disabled:m,className:ar("operation-button")})}),k&&h.jsx(D.Tooltip,{title:e?"激活节点":"禁用节点",children:h.jsx(D.Button,{type:"text",icon:e?h.jsx(Af.IoPlayOutline,{style:Th}):h.jsx(Af.IoBanOutline,{style:Th}),onClick:_,className:ar("operation-button",{disabled:e})})}),d&&h.jsx(D.Popconfirm,{title:"确定要删除此节点吗?",description:"删除后无法恢复,请谨慎操作",onConfirm:E,okText:"确定",cancelText:"取消",placement:"top",children:h.jsx(D.Tooltip,{title:"删除节点",children:h.jsx(D.Button,{type:"text",icon:h.jsx(KB.RiDeleteBin5Line,{style:{color:"red"}}),className:"operation-button delete-button"})})}),S&&h.jsx(D.Tooltip,{title:"查看配置",children:h.jsx(D.Button,{type:"link",onClick:n,icon:h.jsx(se.EyeOutlined,{}),className:ar("operation-button")})})]})},Nh={[me.INVALID]:{label:"未调试",tone:"warning",icon:h.jsx(se.WarningOutlined,{})},[me.IDLE]:{label:"空闲",tone:"idle",icon:h.jsx(se.ClockCircleOutlined,{})},[me.RUNNING]:{label:"运行中",tone:"running",icon:h.jsx(se.LoadingOutlined,{spin:!0})},[me.FAILED]:{label:"失败",tone:"failed",icon:h.jsx(se.CloseCircleFilled,{})},[me.SUCCESS]:{label:"成功",tone:"success",icon:h.jsx(se.CheckCircleFilled,{})},[me.RUNNABLE]:{label:"线上运行",tone:"runnable",icon:h.jsx(se.CheckCircleFilled,{})},[me.ACTIVE]:{label:"已激活",tone:"runnable",icon:h.jsx(se.CheckCircleFilled,{})},[me.DEACTIVATED]:{label:"已禁用",tone:"disabled",icon:h.jsx(se.PauseCircleFilled,{})},[me.WARNING]:{label:"警告",tone:"warning",icon:h.jsx(se.WarningFilled,{})}},nC=({status:t,disabled:e=!1})=>{const n=e?Nh[me.DEACTIVATED]:Nh[t]||Nh[me.IDLE];return h.jsxs("span",{className:`workflow-node-status-badge is-${n.tone}`,role:"status","aria-label":`节点状态:${n.label}`,title:`节点状态:${n.label}`,children:[h.jsx("span",{className:"workflow-node-status-symbol","aria-hidden":"true",children:n.icon}),h.jsx("span",{children:n.label})]})},Bh=y.createContext(null),pa=y.createContext(null),rC=({children:t,variables:e=[],variablePrefix:n="{{",variableSuffix:r="}}",onValidateVariable:o})=>{const[i,s]=y.useState(null),[a,l]=y.useState(!1),[c,u]=y.useState(e),d=y.useRef(new Map),f=y.useRef(null),p=y.useRef(o),m=y.useRef(c);f.current=i,p.current=o,m.current=c;const v=y.useCallback(A=>{d.current.set(A.id,A)},[]),b=y.useCallback(A=>{d.current.delete(A),s(T=>T===A?null:T)},[]),w=y.useCallback(A=>{s(T=>T===A?T:A),l(T=>T||!0)},[]),g=y.useCallback(()=>{s(A=>A===null?A:null)},[]),C=y.useCallback(A=>A.startsWith(n)&&A.endsWith(r)?A:`${n}${A}${r}`,[n,r]),k=y.useCallback(A=>A.startsWith(n)&&A.endsWith(r)?A.slice(n.length,-r.length):null,[n,r]),_=y.useCallback(A=>{if(p.current)return p.current(A);const T=k(A)||A;return m.current.some(B=>B.path===T)},[k]),S=y.useCallback((A,T=!0)=>{const B=f.current;if(!B)return;const I=d.current.get(B);if(!I)return;const F=T?C(A):A;I.insertVariable(F,T)},[C]),E=y.useCallback(()=>f.current,[]),x=y.useMemo(()=>({registerField:v,unregisterField:b,activateField:w,deactivateField:g,setSelectorVisible:l,insertVariableToActiveField:S,setAvailableVariables:u,validateVariable:_,formatVariable:C,extractVariable:k,getActiveFieldId:E}),[v,b,w,g,S,_,C,k,E]),O=y.useMemo(()=>({activeFieldId:i,selectorVisible:a,availableVariables:c}),[i,a,c]);return h.jsx(pa.Provider,{value:x,children:h.jsx(Bh.Provider,{value:O,children:t})})},a2=()=>{const t=y.useContext(Bh),e=y.useContext(pa);if(!t||!e)throw new Error("useVariableSelector must be used within a VariableSelectorProvider");return y.useMemo(()=>({...t,...e}),[t,e])},oC=(t,e,n)=>{const r=y.useContext(pa),o=vt.useRef(e),i=vt.useRef(n),s=vt.useRef(r);return o.current=e,i.current=n,s.current=r,vt.useEffect(()=>{const a=s.current;if(!a)return;const l={id:t,insertVariable:(c,u)=>o.current(c,u),focus:()=>i.current()};return a.registerField(l),()=>{a.unregisterField(t)}},[t]),{activate:()=>{var a;(a=s.current)==null||a.activateField(t)},deactivate:()=>{var a;return(a=s.current)==null?void 0:a.deactivateField()}}},Fh=()=>y.useContext(pa),Mh=()=>{const t=y.useContext(Bh),e=y.useContext(pa);return y.useMemo(()=>!t||!e?null:{...t,...e},[t,e])},Fc={nestedModal:1200,nestedPopover:1250,fullscreenWorkspace:1400},Gr={accountModal:"_accountModal_b0w5m_1",formLayout:"_formLayout_b0w5m_17",formContent:"_formContent_b0w5m_23",formActions:"_formActions_b0w5m_31",rdbmsTestAction:"_rdbmsTestAction_b0w5m_40"},Ih={meta:{name:"ant-design-5x-full-theme",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#1677ff",colorInfo:"#1677ff",colorSuccess:"#52c41a",colorWarning:"#faad14",colorError:"#ff4d4f",colorTextBase:"#000000",colorBgBase:"#ffffff",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.5714285714285714,borderRadius:6,borderRadiusSM:4,borderRadiusLG:8,lineWidth:1,lineType:"solid",controlHeight:32,controlHeightSM:24,controlHeightLG:40,sizeUnit:4,sizeStep:4,padding:16,paddingXS:8,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:8,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05)",boxShadowSecondary:"0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05)",boxShadowTertiary:"0 1px 2px 0 rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px 0 rgba(0, 0, 0, 0.02)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:8},Anchor:{linkPaddingInlineStart:16},AutoComplete:{},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:6,borderRadiusSM:4,borderRadiusLG:8,controlHeight:32,controlHeightSM:24,controlHeightLG:40,paddingInline:15,paddingInlineLG:15,paddingInlineSM:7,contentFontSize:14,contentFontSizeLG:16,contentFontSizeSM:14,primaryShadow:"0 2px 0 rgba(5, 145, 255, 0.1)",dangerShadow:"0 2px 0 rgba(255, 38, 5, 0.06)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:4},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:40,controlHeightLG:48,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:32,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:32,controlHeightSM:24,controlHeightLG:40,paddingInline:11,paddingInlineSM:7,paddingInlineLG:11,paddingBlock:4,paddingBlockSM:0,paddingBlockLG:6,borderRadius:6},InputNumber:{controlHeight:32,controlHeightSM:24,controlHeightLG:40},Layout:{headerBg:"#001529",headerHeight:64,headerPadding:"0 50px",bodyBg:"#f5f5f5",siderBg:"#001529",triggerBg:"#002140"},List:{itemPadding:"12px 0"},Mentions:{},Menu:{itemHeight:40,iconSize:14,collapsedIconSize:16,horizontalItemBorderRadius:6,itemBorderRadius:6},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16},Notification:{},Pagination:{itemSize:32,itemSizeSM:24},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{buttonSolidCheckedBg:"#1677ff"},Rate:{},Result:{},Segmented:{controlHeight:32},Select:{controlHeight:32,controlHeightSM:24,controlHeightLG:40,multipleItemHeight:24,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:22,trackMinWidth:44,handleSize:18},Table:{headerBg:"#fafafa",headerSortActiveBg:"#f0f0f0",headerSortHoverBg:"#f5f5f5",rowHoverBg:"#fafafa",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:4,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 16px"},Tag:{borderRadiusSM:4},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:32,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}},l2="",iC=({children:t,customTheme:e,locale:n=hv,prefixCls:r=l2})=>{const o=vt.useMemo(()=>({...e,cssVar:(e==null?void 0:e.cssVar)??{prefix:r},algorithm:(e==null?void 0:e.algorithm)??D.theme.defaultAlgorithm,token:{...Ih.token,...e==null?void 0:e.token},components:{...Ih.components,...e==null?void 0:e.components}}),[r,e]);return h.jsx(D.ConfigProvider,{prefixCls:r,locale:n,theme:o,getPopupContainer:i=>(i==null?void 0:i.parentElement)||document.body,children:t})};function qn(t,e){if(t==null||e==="")return;const n=e.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let r=t;for(const o of n){if(r==null)return;const i=Number(o);!Number.isNaN(i)&&Array.isArray(r)?r=r[i]:r=r[o]}return r}const c2=t=>!t||t.length===0,sC=(t,e)=>t==null?!1:Array.isArray(t)?Array.isArray(e)?e.some(n=>t.includes(n)):t.includes(e):typeof t=="string"?Array.isArray(e)?e.some(n=>t.includes(String(n))):t.includes(String(e)):!1,aC=t=>t==null?!0:typeof t=="string"?t.trim().length===0:Array.isArray(t)?t.length===0:typeof t=="object"?Object.keys(t).length===0:!1,lC=(t,e)=>Array.isArray(e)?e.includes(t):!1,u2=(t,e,n)=>{switch(t){case"EQ":return e===n;case"NOT":return e!==n;case"GT":return Number(e)>Number(n);case"LT":return Number(e)<Number(n);case"GE":return Number(e)>=Number(n);case"LE":return Number(e)<=Number(n);case"ISEVEN":return Number(e)%2===0;case"ISODD":return Math.abs(Number(e))%2===1;case"IC":return sC(e,n);case"NIC":return!sC(e,n);case"IN":return lC(e,n);case"NIN":case"NOT_IN":return!lC(e,n);case"EXISTS":return e!=null;case"EMPTY":return aC(e);case"NOT_EMPTY":return!aC(e);default:return!1}},ti=(t,e)=>{if(!t)return!0;const{AND:n,OR:r,key:o,keyword:i,value:s}=t,a=Array.isArray(n),l=Array.isArray(r);if(a||l){const u=n??[],d=r??[];let f=!0,p=c2(d);for(const m of u){if(!f)break;f=ti(m,e)}for(const m of d){if(p)break;p=ti(m,e)}return f&&p}if(!o||!i)return!0;const c=qn(e,o);return u2(i,c,s)};function d2(t,e){const{eventPayload:n,formValues:r}=e;if(t.startsWith("payload.")){const o=t.slice(8);return qn(n.payload||{},o)}if(t.startsWith("formValues.")){const o=t.slice(11);return qn(r,o)}return t in n?n[t]:n.payload&&t in n.payload?n.payload[t]:qn(r,t)}function f2(t,e){const{form:n}=e,{targets:r}=t;for(const o of r)n.setFieldValue(o,void 0);e.executionDepth===1&&console.log("[ActionExecutor] 清空字段:",r)}function h2(t,e){const{form:n}=e,{target:r,value:o,valueFrom:i}=t;let s;i?s=d2(i,e):s=o,n.setFieldValue(r,s),e.executionDepth===1&&console.log(`[ActionExecutor] 设置字段值: ${r} =`,s)}function p2(t,e){const{target:n,disabled:r}=t;e.executionDepth===1&&(console.log(`[ActionExecutor] 设置字段禁用状态: ${n} = ${r}`),console.warn("[ActionExecutor] setFieldDisabled 需要外部状态管理支持,当前仅记录日志"))}async function m2(t,e){const{form:n}=e,{targets:r}=t;try{r&&r.length>0?await n.validateFields(r):await n.validateFields(),e.executionDepth===1&&console.log("[ActionExecutor] 触发验证:",r||"所有字段")}catch(o){e.executionDepth===1&&console.log("[ActionExecutor] 验证失败:",o)}}async function g2(t,e){const{optionsLoader:n,form:r}=e,{action:o,params:i,resultTo:s}=t;if(!n){console.warn("[ActionExecutor] 未提供 optionsLoader,无法执行 callDataLoader 动作");return}try{const a=await n(o,i||{},{values:e.formValues});s&&(r.setFieldValue(s,a),e.executionDepth===1&&console.log(`[ActionExecutor] 数据加载完成,结果设置到: ${s}`,a))}catch(a){console.error("[ActionExecutor] 数据加载失败:",a)}}async function w2(t,e){const{customHandlers:n}=e,{handler:r,params:o}=t;if(!n||!n[r]){console.warn(`[ActionExecutor] 未找到自定义处理器: ${r}`);return}try{await n[r](e,o),e.executionDepth===1&&console.log(`[ActionExecutor] 执行自定义动作: ${r}`)}catch(i){console.error(`[ActionExecutor] 自定义动作执行失败: ${r}`,i)}}async function b2(t,e){switch(t.type){case"clearFields":f2(t,e);break;case"setFieldValue":h2(t,e);break;case"setFieldDisabled":p2(t,e);break;case"triggerValidation":await m2(t,e);break;case"callDataLoader":await g2(t,e);break;case"custom":await w2(t,e);break;default:console.warn("[ActionExecutor] 未知的动作类型:",t.type)}}async function v2(t,e){for(const n of t)await b2(n,e)}function y2(t){const{events:e,form:n,optionsLoader:r,customHandlers:o,maxExecutionDepth:i=10,debug:s=!1}=t,a=y.useRef(0),l=y.useRef(new Map),c=y.useCallback(async(b,w)=>{if(a.current+=1,a.current>i){console.error(`[EventEngine] 执行深度超过限制 (${i}),可能存在无限循环`,b.id||b.trigger),a.current=0;return}try{const g=n.getFieldsValue();if(b.conditions&&!ti(b.conditions,g)){s&&console.log("[EventEngine] 条件不满足,跳过执行:",b.id);return}const C={form:n,formValues:g,eventPayload:w,optionsLoader:r,customHandlers:o,executionDepth:a.current};await v2(b.actions,C),s&&console.log("[EventEngine] 事件处理完成:",b.id||b.trigger)}finally{a.current-=1}},[n,r,o,i,s]),u=y.useCallback(b=>{const w=e.filter(g=>{const{trigger:C}=g;return C.type!==b.type?!1:(C.type==="fieldChange"||C.type==="fieldBlur"||C.type==="fieldFocus")&&"field"in C?C.field===b.field:C.type==="custom"&&"eventName"in C?C.eventName===b.eventName:C.type==="formMount"});for(const g of w)if(g.debounce&&g.debounce>0){const C=`${g.id||JSON.stringify(g.trigger)}`,k=l.current.get(C);k&&clearTimeout(k);const _=setTimeout(()=>{c(g,b),l.current.delete(C)},g.debounce);l.current.set(C,_)}else c(g,b)},[e,c]),d=y.useCallback((b,w,g)=>{const C={type:"fieldChange",field:b,oldValue:g,newValue:w,timestamp:Date.now()};u(C),s&&console.log("[EventEngine] 字段变化事件:",{fieldPath:b,oldValue:g,newValue:w})},[u,s]),f=y.useCallback(b=>{const w={type:"fieldBlur",field:b,timestamp:Date.now()};u(w),s&&console.log("[EventEngine] 字段失焦事件:",{fieldPath:b})},[u,s]),p=y.useCallback(b=>{const w={type:"fieldFocus",field:b,timestamp:Date.now()};u(w),s&&console.log("[EventEngine] 字段聚焦事件:",{fieldPath:b})},[u,s]);y.useEffect(()=>{const b={type:"formMount",timestamp:Date.now()};u(b)},[]),y.useEffect(()=>()=>{for(const b of l.current.values())clearTimeout(b);l.current.clear()},[]);const m=y.useCallback((b,w)=>{const g={type:"custom",eventName:b,payload:w,timestamp:Date.now()};u(g)},[u]);return{triggerFieldChange:d,fieldEventHandlers:{onBlur:f,onFocus:p,dispatch:m}}}const Ph=y.createContext({}),cC=({value:t,children:e})=>h.jsx(Ph.Provider,{value:t,children:e}),uC=()=>y.useContext(Ph);class Mc{constructor(){lt(this,"registry",new Map)}register(e,n,r={}){const{override:o=!1}=r;if(this.registry.has(e)&&!o){console.warn(`[FieldRegistry] 字段类型 "${e}" 已注册。使用 { override: true } 来覆盖。`);return}this.registry.set(e,n)}unregister(e){this.registry.delete(e)}get(e){return this.registry.get(e)}has(e){return this.registry.has(e)}getRegisteredTypes(){return Array.from(this.registry.keys())}clone(){const e=new Mc;return this.registry.forEach((n,r)=>{e.register(r,n)}),e}}const Ic=new Mc;function C2(){return new Mc}const dC=y.createContext(Ic),fC=({registry:t,additionalRegistrations:e,children:n})=>{const r=y.useMemo(()=>{const o=t||Ic.clone();if(e!=null&&e.length)for(const{type:i,definition:s}of e)o.register(i,s,{override:!0});return o},[t,e]);return h.jsx(dC.Provider,{value:r,children:n})},Pc=()=>y.useContext(dC),hC=y.createContext(null);function pC(){return y.useContext(hC)}const mC=({policy:t,mode:e,onModeChange:n,children:r})=>{const o=y.useMemo(()=>({policy:t,mode:e,onModeChange:n,suppressNestedSwitch:!0}),[e,n,t]);return h.jsx(hC.Provider,{value:o,children:r})},gC=["normal","expression"],k2={TEXT:{availableModes:["normal"],defaultMode:"normal"},EXPRESSION:{availableModes:["expression"],defaultMode:"expression"},BOTH:{availableModes:["normal","expression"],defaultMode:"normal"}};function Lh(t){return k2[t]}function wC(t){return t==="EXPRESSION"||t==="BOTH"}const Lc={normal:{label:"文本",icon:h.jsx(se.FontSizeOutlined,{}),description:"普通文本输入"},expression:{label:"表达式",icon:h.jsx(se.FunctionOutlined,{}),description:"按 JavaScript 表达式求值"},code:{label:"代码",icon:h.jsx(se.CodeOutlined,{}),description:"JavaScript 代码模式"}},$h=({valueModePolicy:t,mode:e,onModeChange:n,disabled:r=!1,readOnly:o=!1,modeSwitchPosition:i="top-right"})=>{const{availableModes:s}=Lh(t),a=s.filter(c=>Lc[c]),l=a.length>1;return a.length===0?null:h.jsx("div",{className:`value-mode-switch ${i}`,children:h.jsx(D.Radio.Group,{value:e,onChange:l?c=>n==null?void 0:n(c.target.value):void 0,size:"small",disabled:r||o,optionType:"button",buttonStyle:"solid",children:a.map(c=>h.jsxs(D.Radio.Button,{value:c,title:Lc[c].description,children:[Lc[c].icon,h.jsx("span",{className:"mode-label",children:Lc[c].label})]},c))})})},S2=y.lazy(()=>Promise.resolve().then(()=>qte)),bC=t=>{const e=Et.useReactive({editorVisible:!1}),n=()=>{e.editorVisible=!0};y.useEffect(()=>{t.openEditorNumber&&n()},[t.openEditorNumber]);const r=o=>{t.onFinish(o),e.editorVisible=!1};return t.canEditInEditor?h.jsxs(y.Fragment,{children:[h.jsx("div",{style:{display:"flex",flexDirection:"column"},children:t.children}),e.editorVisible&&h.jsx(y.Suspense,{fallback:null,children:h.jsx(S2,{open:!0,initialValue:t.value,nodeId:t.nodeId??"",language:t.language,showVariableSidebar:t.showVariableSidebar,onCancel:()=>{e.editorVisible=!1},onFinish:r})})]}):t.children},E2={magenta:{textColor:"#c41d7f",backgroundColor:"#fff0f6",borderColor:"#ffadd2"},red:{textColor:"#cf1322",backgroundColor:"#fff1f0",borderColor:"#ffa39e"},volcano:{textColor:"#d4380d",backgroundColor:"#fff2e8",borderColor:"#ffbb96"},orange:{textColor:"#d46b08",backgroundColor:"#fff7e6",borderColor:"#ffd591"},gold:{textColor:"#d48806",backgroundColor:"#fffbe6",borderColor:"#ffe58f"},lime:{textColor:"#7cb305",backgroundColor:"#fcffe6",borderColor:"#eaff8f"},green:{textColor:"#389e0d",backgroundColor:"#f6ffed",borderColor:"#b7eb8f"},cyan:{textColor:"#08979c",backgroundColor:"#edf2f7",borderColor:"#c6dbf0"},blue:{textColor:"rgba(0, 0, 0, 0.5)",backgroundColor:"#edf2f7",borderColor:"#91caff"},geekblue:{textColor:"#1d39c4",backgroundColor:"#f0f5ff",borderColor:"#adc6ff"},purple:{textColor:"#531dab",backgroundColor:"#f9f0ff",borderColor:"#d3adf7"}},vC=1024;let x2=0,zh=class{constructor(e,n){this.from=e,this.to=n}};class Je{constructor(e={}){this.id=x2++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Cn.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}Je.closedBy=new Je({deserialize:t=>t.split(" ")}),Je.openedBy=new Je({deserialize:t=>t.split(" ")}),Je.group=new Je({deserialize:t=>t.split(" ")}),Je.isolate=new Je({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),Je.contextHash=new Je({perNode:!0}),Je.lookAhead=new Je({perNode:!0}),Je.mounted=new Je({perNode:!0});class ma{constructor(e,n,r,o=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=o}static get(e){return e&&e.props&&e.props[Je.mounted.id]}}const D2=Object.create(null);class Cn{constructor(e,n,r,o=0){this.name=e,this.props=n,this.id=r,this.flags=o}static define(e){let n=e.props&&e.props.length?Object.create(null):D2,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),o=new Cn(e.name||"",n,e.id,r);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(o)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[i[0].id]=i[1]}}return o}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Je.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let o of r.split(" "))n[o]=e[r];return r=>{for(let o=r.prop(Je.group),i=-1;i<(o?o.length:0);i++){let s=n[i<0?r.name:o[i]];if(s)return s}}}}Cn.none=new Cn("",Object.create(null),0,8);class Hh{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let r of this.types){let o=null;for(let i of e){let s=i(r);if(s){o||(o=Object.assign({},r.props));let a=s[1],l=s[0];l.combine&&l.id in o&&(a=l.combine(o[l.id],a)),o[l.id]=a}}n.push(o?new Cn(r.name,o,r.id,r.flags):r)}return new Hh(n)}}const $c=new WeakMap,yC=new WeakMap;var Ct;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Ct||(Ct={}));class Dt{constructor(e,n,r,o,i){if(this.type=e,this.children=n,this.positions=r,this.length=o,this.props=null,i&&i.length){this.props=Object.create(null);for(let[s,a]of i)this.props[typeof s=="number"?s:s.id]=a}}toString(){let e=ma.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let o=r.toString();o&&(n&&(n+=","),n+=o)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new Wh(this.topNode,e)}cursorAt(e,n=0,r=0){let o=$c.get(this)||this.topNode,i=new Wh(o);return i.moveTo(e,n),$c.set(this,i._tree),i}get topNode(){return new Gn(this,0,0,null)}resolve(e,n=0){let r=ga($c.get(this)||this.topNode,e,n,!1);return $c.set(this,r),r}resolveInner(e,n=0){let r=ga(yC.get(this)||this.topNode,e,n,!0);return yC.set(this,r),r}resolveStack(e,n=0){return O2(this,e,n)}iterate(e){let{enter:n,leave:r,from:o=0,to:i=this.length}=e,s=e.mode||0,a=(s&Ct.IncludeAnonymous)>0;for(let l=this.cursor(s|Ct.IncludeAnonymous);;){let c=!1;if(l.from<=i&&l.to>=o&&(!a&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(a||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:qh(Cn.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,o)=>new Dt(this.type,n,r,o,this.propValues),e.makeTree||((n,r,o)=>new Dt(Cn.none,n,r,o)))}static build(e){return T2(e)}}Dt.empty=new Dt(Cn.none,[],[],0);class Vh{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Vh(this.buffer,this.index)}}class mo{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return Cn.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],r=this.buffer[e+3],o=this.set.types[n],i=o.name;if(/\W/.test(i)&&!o.isError&&(i=JSON.stringify(i)),e+=4,r==e)return i;let s=[];for(;e<r;)s.push(this.childString(e)),e=this.buffer[e+3];return i+"("+s.join(",")+")"}findChild(e,n,r,o,i){let{buffer:s}=this,a=-1;for(let l=e;l!=n&&!(CC(i,o,s[l+1],s[l+2])&&(a=l,r>0));l=s[l+3]);return a}slice(e,n,r){let o=this.buffer,i=new Uint16Array(n-e),s=0;for(let a=e,l=0;a<n;){i[l++]=o[a++],i[l++]=o[a++]-r;let c=i[l++]=o[a++]-r;i[l++]=o[a++]-e,s=Math.max(s,c)}return new mo(i,s,this.set)}}function CC(t,e,n,r){switch(t){case-2:return n<e;case-1:return r>=e&&n<e;case 0:return n<e&&r>e;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function ga(t,e,n,r){for(var o;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let s=!r&&t instanceof Gn&&t.index<0?null:t.parent;if(!s)return t;t=s}let i=r?0:Ct.IgnoreOverlays;if(r)for(let s=t,a=s.parent;a;s=a,a=s.parent)s instanceof Gn&&s.index<0&&((o=a.enter(e,n,i))===null||o===void 0?void 0:o.from)!=s.from&&(t=a);for(;;){let s=t.enter(e,n,i);if(!s)return t;t=s}}class kC{cursor(e=0){return new Wh(this,e)}getChild(e,n=null,r=null){let o=SC(this,e,n,r);return o.length?o[0]:null}getChildren(e,n=null,r=null){return SC(this,e,n,r)}resolve(e,n=0){return ga(this,e,n,!1)}resolveInner(e,n=0){return ga(this,e,n,!0)}matchContext(e){return jh(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),r=this;for(;n;){let o=n.lastChild;if(!o||o.to!=n.to)break;o.type.isError&&o.from==o.to?(r=n,n=o.prevSibling):n=o}return r}get node(){return this}get next(){return this.parent}}class Gn extends kC{constructor(e,n,r,o){super(),this._tree=e,this.from=n,this.index=r,this._parent=o}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,r,o,i=0){var s;for(let a=this;;){for(let{children:l,positions:c}=a._tree,u=n>0?l.length:-1;e!=u;e+=n){let d=l[e],f=c[e]+a.from;if(!(!(i&Ct.EnterBracketed&&d instanceof Dt&&((s=ma.get(d))===null||s===void 0?void 0:s.overlay)===null&&(f>=r||f+d.length<=r))&&!CC(o,r,f,f+d.length))){if(d instanceof mo){if(i&Ct.ExcludeBuffers)continue;let p=d.findChild(0,d.buffer.length,n,r-f,o);if(p>-1)return new go(new _2(a,d,e,f),null,p)}else if(i&Ct.IncludeAnonymous||!d.type.isAnonymous||Uh(d)){let p;if(!(i&Ct.IgnoreMounts)&&(p=ma.get(d))&&!p.overlay)return new Gn(p.tree,f,e,a);let m=new Gn(d,f,e,a);return i&Ct.IncludeAnonymous||!m.type.isAnonymous?m:m.nextChild(n<0?d.children.length-1:0,n,r,o,i)}}}if(i&Ct.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+n:e=n<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let o;if(!(r&Ct.IgnoreOverlays)&&(o=ma.get(this._tree))&&o.overlay){let i=e-this.from,s=r&Ct.EnterBracketed&&o.bracketed;for(let{from:a,to:l}of o.overlay)if((n>0||s?a<=i:a<i)&&(n<0||s?l>=i:l>i))return new Gn(o.tree,o.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function SC(t,e,n,r){let o=t.cursor(),i=[];if(!o.firstChild())return i;if(n!=null){for(let s=!1;!s;)if(s=o.type.is(n),!o.nextSibling())return i}for(;;){if(r!=null&&o.type.is(r))return i;if(o.type.is(e)&&i.push(o.node),!o.nextSibling())return r==null?i:[]}}function jh(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class _2{constructor(e,n,r,o){this.parent=e,this.buffer=n,this.index=r,this.start=o}}class go extends kC{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:o}=this.context,i=o.findChild(this.index+4,o.buffer[this.index+3],e,n-this.context.start,r);return i<0?null:new go(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Ct.ExcludeBuffers)return null;let{buffer:o}=this.context,i=o.findChild(this.index+4,o.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return i<0?null:new go(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new go(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new go(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,o=this.index+4,i=r.buffer[this.index+3];if(i>o){let s=r.buffer[this.index+1];e.push(r.slice(o,i,s)),n.push(0)}return new Dt(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function EC(t){if(!t.length)return null;let e=0,n=t[0];for(let i=1;i<t.length;i++){let s=t[i];(s.from>n.from||s.to<n.to)&&(n=s,e=i)}let r=n instanceof Gn&&n.index<0?null:n.parent,o=t.slice();return r?o[e]=r:o.splice(e,1),new A2(o,n)}class A2{constructor(e,n){this.heads=e,this.node=n}get next(){return EC(this.heads)}}function O2(t,e,n){let r=t.resolveInner(e,n),o=null;for(let i=r instanceof Gn?r:r.context.parent;i;i=i.parent)if(i.index<0){let s=i.parent;(o||(o=[r])).push(s.resolve(e,n)),i=s}else{let s=ma.get(i.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let a=new Gn(s.tree,s.overlay[0].from+i.from,-1,i);(o||(o=[r])).push(ga(a,e,n,!1))}}return o?EC(o):r}class Wh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Ct.EnterBracketed,e instanceof Gn)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:o}=this.buffer;return this.type=n||o.set.types[o.buffer[e]],this.from=r+o.buffer[e+1],this.to=r+o.buffer[e+2],!0}yield(e){return e?e instanceof Gn?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:o}=this.buffer,i=o.findChild(this.index+4,o.buffer[this.index+3],e,n-this.buffer.start,r);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&Ct.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Ct.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Ct.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let o=r<0?0:this.stack[r]+4;if(this.index!=o)return this.yieldBuf(n.findChild(o,this.index,-1,0,4))}else{let o=n.buffer[this.index+3];if(o<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(o)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:o}=this;if(o){if(e>0){if(this.index<o.buffer.buffer.length)return!1}else for(let i=0;i<this.index;i++)if(o.buffer.buffer[i+3]<this.index)return!1;({index:n,parent:r}=o)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let i=n+e,s=e<0?-1:r._tree.children.length;i!=s;i+=e){let a=r._tree.children[i];if(this.mode&Ct.IncludeAnonymous||a instanceof mo||!a.type.isAnonymous||Uh(a))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,r=0;if(e&&e.context==this.buffer)e:for(let o=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==o){if(o==this.index)return s;n=s,r=i+1;break e}o=this.stack[--i]}for(let o=r;o<this.stack.length;o++)n=new go(this.buffer,n,this.stack[o]);return this.bufferNode=new go(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let r=0;;){let o=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(o=!0)}for(;;){if(o&&n&&n(this),o=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,o=!0}}}matchContext(e){if(!this.buffer)return jh(this.node.parent,e);let{buffer:n}=this.buffer,{types:r}=n.set;for(let o=e.length-1,i=this.stack.length-1;o>=0;i--){if(i<0)return jh(this._tree,e,o);let s=r[n.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[o]&&e[o]!=s.name)return!1;o--}}return!0}}function Uh(t){return t.children.some(e=>e instanceof mo||!e.type.isAnonymous||Uh(e))}function T2(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:o=vC,reused:i=[],minRepeatType:s=r.types.length}=t,a=Array.isArray(n)?new Vh(n,n.length):n,l=r.types,c=0,u=0;function d(_,S,E,x,O,A){let{id:T,start:B,end:I,size:F}=a,N=u,P=c;if(F<0)if(a.next(),F==-1){let Y=i[T];E.push(Y),x.push(B-_);return}else if(F==-3){c=T;return}else if(F==-4){u=T;return}else throw new RangeError(`Unrecognized record size: ${F}`);let M=l[T],z,H,R=B-_;if(I-B<=o&&(H=b(a.pos-S,O))){let Y=new Uint16Array(H.size-H.skip),te=a.pos-H.size,$=Y.length;for(;a.pos>te;)$=w(H.start,Y,$);z=new mo(Y,I-H.start,r),R=H.start-_}else{let Y=a.pos-F;a.next();let te=[],$=[],j=T>=s?T:-1,U=0,ee=I;for(;a.pos>Y;)j>=0&&a.id==j&&a.size>=0?(a.end<=ee-o&&(m(te,$,B,U,a.end,ee,j,N,P),U=te.length,ee=a.end),a.next()):A>2500?f(B,Y,te,$):d(B,Y,te,$,j,A+1);if(j>=0&&U>0&&U<te.length&&m(te,$,B,U,B,ee,j,N,P),te.reverse(),$.reverse(),j>-1&&U>0){let ie=p(M,P);z=qh(M,te,$,0,te.length,0,I-B,ie,ie)}else z=v(M,te,$,I-B,N-I,P)}E.push(z),x.push(R)}function f(_,S,E,x){let O=[],A=0,T=-1;for(;a.pos>S;){let{id:B,start:I,end:F,size:N}=a;if(N>4)a.next();else{if(T>-1&&I<T)break;T<0&&(T=F-o),O.push(B,I,F),A++,a.next()}}if(A){let B=new Uint16Array(A*4),I=O[O.length-2];for(let F=O.length-3,N=0;F>=0;F-=3)B[N++]=O[F],B[N++]=O[F+1]-I,B[N++]=O[F+2]-I,B[N++]=N;E.push(new mo(B,O[2]-I,r)),x.push(I-_)}}function p(_,S){return(E,x,O)=>{let A=0,T=E.length-1,B,I;if(T>=0&&(B=E[T])instanceof Dt){if(!T&&B.type==_&&B.length==O)return B;(I=B.prop(Je.lookAhead))&&(A=x[T]+B.length+I)}return v(_,E,x,O,A,S)}}function m(_,S,E,x,O,A,T,B,I){let F=[],N=[];for(;_.length>x;)F.push(_.pop()),N.push(S.pop()+E-O);_.push(v(r.types[T],F,N,A-O,B-A,I)),S.push(O-E)}function v(_,S,E,x,O,A,T){if(A){let B=[Je.contextHash,A];T=T?[B].concat(T):[B]}if(O>25){let B=[Je.lookAhead,O];T=T?[B].concat(T):[B]}return new Dt(_,S,E,x,T)}function b(_,S){let E=a.fork(),x=0,O=0,A=0,T=E.end-o,B={size:0,start:0,skip:0};e:for(let I=E.pos-_;E.pos>I;){let F=E.size;if(E.id==S&&F>=0){B.size=x,B.start=O,B.skip=A,A+=4,x+=4,E.next();continue}let N=E.pos-F;if(F<0||N<I||E.start<T)break;let P=E.id>=s?4:0,M=E.start;for(E.next();E.pos>N;){if(E.size<0)if(E.size==-3||E.size==-4)P+=4;else break e;else E.id>=s&&(P+=4);E.next()}O=M,x+=F,A+=P}return(S<0||x==_)&&(B.size=x,B.start=O,B.skip=A),B.size>4?B:void 0}function w(_,S,E){let{id:x,start:O,end:A,size:T}=a;if(a.next(),T>=0&&x<s){let B=E;if(T>4){let I=a.pos-(T-4);for(;a.pos>I;)E=w(_,S,E)}S[--E]=B,S[--E]=A-_,S[--E]=O-_,S[--E]=x}else T==-3?c=x:T==-4&&(u=x);return E}let g=[],C=[];for(;a.pos>0;)d(t.start||0,t.bufferStart||0,g,C,-1,0);let k=(e=t.length)!==null&&e!==void 0?e:g.length?C[0]+g[0].length:0;return new Dt(l[t.topID],g.reverse(),C.reverse(),k)}const xC=new WeakMap;function zc(t,e){if(!t.isAnonymous||e instanceof mo||e.type!=t)return 1;let n=xC.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Dt)){n=1;break}n+=zc(t,r)}xC.set(e,n)}return n}function qh(t,e,n,r,o,i,s,a,l){let c=0;for(let m=r;m<o;m++)c+=zc(t,e[m]);let u=Math.ceil(c*1.5/8),d=[],f=[];function p(m,v,b,w,g){for(let C=b;C<w;){let k=C,_=v[C],S=zc(t,m[C]);for(C++;C<w;C++){let E=zc(t,m[C]);if(S+E>=u)break;S+=E}if(C==k+1){if(S>u){let E=m[k];p(E.children,E.positions,0,E.children.length,v[k]+g);continue}d.push(m[k])}else{let E=v[C-1]+m[C-1].length-_;d.push(qh(t,m,v,k,C,_,E,null,l))}f.push(_+g-i)}}return p(e,n,r,o,0),(a||l)(d,f,s)}class ni{constructor(e,n,r,o,i=!1,s=!1){this.from=e,this.to=n,this.tree=r,this.offset=o,this.open=(i?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let o=[new ni(0,e.length,e,0,!1,r)];for(let i of n)i.to>e.length&&o.push(i);return o}static applyChanges(e,n,r=128){if(!n.length)return e;let o=[],i=1,s=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<n.length?n[a]:null,d=u?u.fromA:1e9;if(d-l>=r)for(;s&&s.from<d;){let f=s;if(l>=f.from||d<=f.to||c){let p=Math.max(f.from,l)-c,m=Math.min(f.to,d)-c;f=p>=m?null:new ni(p,m,f.tree,f.offset+c,a>0,!!u)}if(f&&o.push(f),s.to>d)break;s=i<e.length?e[i++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return o}}class DC{startParse(e,n,r){return typeof e=="string"&&(e=new N2(e)),r=r?r.length?r.map(o=>new zh(o.from,o.to)):[new zh(0,0)]:[new zh(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let o=this.startParse(e,n,r);for(;;){let i=o.advance();if(i)return i}}}class N2{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Je({perNode:!0});let B2=0;class Rn{constructor(e,n,r,o){this.name=e,this.set=n,this.base=r,this.modified=o,this.id=B2++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof Rn&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let o=new Rn(r,[],null,[]);if(o.set.push(o),n)for(let i of n.set)o.set.push(i);return o}static defineModifier(e){let n=new Hc(e);return r=>r.modified.indexOf(n)>-1?r:Hc.get(r.base||r,r.modified.concat(n).sort((o,i)=>o.id-i.id))}}let F2=0;class Hc{constructor(e){this.name=e,this.instances=[],this.id=F2++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(a=>a.base==e&&M2(n,a.modified));if(r)return r;let o=[],i=new Rn(e.name,o,e,n);for(let a of n)a.instances.push(i);let s=I2(n);for(let a of e.set)if(!a.modified.length)for(let l of s)o.push(Hc.get(a,l));return i}}function M2(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function I2(t){let e=[[]];for(let n=0;n<t.length;n++)for(let r=0,o=e.length;r<o;r++)e.push(e[r].concat(t[n]));return e.sort((n,r)=>r.length-n.length)}function _C(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let o of n.split(" "))if(o){let i=[],s=2,a=o;for(let d=0;;){if(a=="..."&&d>0&&d+3==o.length){s=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!f)throw new RangeError("Invalid path: "+o);if(i.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),d+=f[0].length,d==o.length)break;let p=o[d++];if(d==o.length&&p=="!"){s=0;break}if(p!="/")throw new RangeError("Invalid path: "+o);a=o.slice(d)}let l=i.length-1,c=i[l];if(!c)throw new RangeError("Invalid path: "+o);let u=new wa(r,s,l>0?i.slice(0,l):null);e[c]=u.sort(e[c])}}return AC.add(e)}const AC=new Je({combine(t,e){let n,r,o;for(;t||e;){if(!t||e&&t.depth>=e.depth?(o=e,e=e.next):(o=t,t=t.next),n&&n.mode==o.mode&&!o.context&&!n.context)continue;let i=new wa(o.tags,o.mode,o.context);n?n.next=i:r=i,n=i}return r}});class wa{constructor(e,n,r,o){this.tags=e,this.mode=n,this.context=r,this.next=o}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}wa.empty=new wa([],2,null);function OC(t,e){let n=Object.create(null);for(let i of t)if(!Array.isArray(i.tag))n[i.tag.id]=i.class;else for(let s of i.tag)n[s.id]=i.class;let{scope:r,all:o=null}=e||{};return{style:i=>{let s=o;for(let a of i)for(let l of a.set){let c=n[l.id];if(c){s=s?s+" "+c:c;break}}return s},scope:r}}function P2(t,e){let n=null;for(let r of t){let o=r.style(e);o&&(n=n?n+" "+o:o)}return n}function L2(t,e,n,r=0,o=t.length){let i=new $2(r,Array.isArray(e)?e:[e],n);i.highlightRange(t.cursor(),r,o,"",i.highlighters),i.flush(o)}class $2{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,o,i){let{type:s,from:a,to:l}=e;if(a>=r||l<=n)return;s.isTop&&(i=this.highlighters.filter(p=>!p.scope||p.scope(s)));let c=o,u=z2(e)||wa.empty,d=P2(i,u.tags);if(d&&(c&&(c+=" "),c+=d,u.mode==1&&(o+=(o?" ":"")+d)),this.startSpan(Math.max(n,a),c),u.opaque)return;let f=e.tree&&e.tree.prop(Je.mounted);if(f&&f.overlay){let p=e.node.enter(f.overlay[0].from+a,1),m=this.highlighters.filter(b=>!b.scope||b.scope(f.tree.type)),v=e.firstChild();for(let b=0,w=a;;b++){let g=b<f.overlay.length?f.overlay[b]:null,C=g?g.from+a:l,k=Math.max(n,w),_=Math.min(r,C);if(k<_&&v)for(;e.from<_&&(this.highlightRange(e,k,_,o,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=C||!e.nextSibling())););if(!g||C>r)break;w=g.to+a,w>n&&(this.highlightRange(p.cursor(),Math.max(n,g.from+a),Math.min(r,w),"",m),this.startSpan(Math.min(r,w),c))}v&&e.parent()}else if(e.firstChild()){f&&(o="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,o,i),this.startSpan(Math.min(r,e.to),c)}while(e.nextSibling());e.parent()}}}function z2(t){let e=t.type.prop(AC);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const _e=Rn.define,Vc=_e(),wo=_e(),TC=_e(wo),NC=_e(wo),bo=_e(),jc=_e(bo),Gh=_e(bo),Er=_e(),ri=_e(Er),xr=_e(),Dr=_e(),Rh=_e(),ba=_e(Rh),Wc=_e(),V={comment:Vc,lineComment:_e(Vc),blockComment:_e(Vc),docComment:_e(Vc),name:wo,variableName:_e(wo),typeName:TC,tagName:_e(TC),propertyName:NC,attributeName:_e(NC),className:_e(wo),labelName:_e(wo),namespace:_e(wo),macroName:_e(wo),literal:bo,string:jc,docString:_e(jc),character:_e(jc),attributeValue:_e(jc),number:Gh,integer:_e(Gh),float:_e(Gh),bool:_e(bo),regexp:_e(bo),escape:_e(bo),color:_e(bo),url:_e(bo),keyword:xr,self:_e(xr),null:_e(xr),atom:_e(xr),unit:_e(xr),modifier:_e(xr),operatorKeyword:_e(xr),controlKeyword:_e(xr),definitionKeyword:_e(xr),moduleKeyword:_e(xr),operator:Dr,derefOperator:_e(Dr),arithmeticOperator:_e(Dr),logicOperator:_e(Dr),bitwiseOperator:_e(Dr),compareOperator:_e(Dr),updateOperator:_e(Dr),definitionOperator:_e(Dr),typeOperator:_e(Dr),controlOperator:_e(Dr),punctuation:Rh,separator:_e(Rh),bracket:ba,angleBracket:_e(ba),squareBracket:_e(ba),paren:_e(ba),brace:_e(ba),content:Er,heading:ri,heading1:_e(ri),heading2:_e(ri),heading3:_e(ri),heading4:_e(ri),heading5:_e(ri),heading6:_e(ri),contentSeparator:_e(Er),list:_e(Er),quote:_e(Er),emphasis:_e(Er),strong:_e(Er),link:_e(Er),monospace:_e(Er),strikethrough:_e(Er),inserted:_e(),deleted:_e(),changed:_e(),invalid:_e(),meta:Wc,documentMeta:_e(Wc),annotation:_e(Wc),processingInstruction:_e(Wc),definition:Rn.defineModifier("definition"),constant:Rn.defineModifier("constant"),function:Rn.defineModifier("function"),standard:Rn.defineModifier("standard"),local:Rn.defineModifier("local"),special:Rn.defineModifier("special")};for(let t in V){let e=V[t];e instanceof Rn&&(e.name=t)}OC([{tag:V.link,class:"tok-link"},{tag:V.heading,class:"tok-heading"},{tag:V.emphasis,class:"tok-emphasis"},{tag:V.strong,class:"tok-strong"},{tag:V.keyword,class:"tok-keyword"},{tag:V.atom,class:"tok-atom"},{tag:V.bool,class:"tok-bool"},{tag:V.url,class:"tok-url"},{tag:V.labelName,class:"tok-labelName"},{tag:V.inserted,class:"tok-inserted"},{tag:V.deleted,class:"tok-deleted"},{tag:V.literal,class:"tok-literal"},{tag:V.string,class:"tok-string"},{tag:V.number,class:"tok-number"},{tag:[V.regexp,V.escape,V.special(V.string)],class:"tok-string2"},{tag:V.variableName,class:"tok-variableName"},{tag:V.local(V.variableName),class:"tok-variableName tok-local"},{tag:V.definition(V.variableName),class:"tok-variableName tok-definition"},{tag:V.special(V.variableName),class:"tok-variableName2"},{tag:V.definition(V.propertyName),class:"tok-propertyName tok-definition"},{tag:V.typeName,class:"tok-typeName"},{tag:V.namespace,class:"tok-namespace"},{tag:V.className,class:"tok-className"},{tag:V.macroName,class:"tok-macroName"},{tag:V.propertyName,class:"tok-propertyName"},{tag:V.operator,class:"tok-operator"},{tag:V.comment,class:"tok-comment"},{tag:V.meta,class:"tok-meta"},{tag:V.invalid,class:"tok-invalid"},{tag:V.punctuation,class:"tok-punctuation"}]);let Kh=[],BC=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?BC:Kh).push(n=n+t[e])})();function H2(t){if(t<768)return!1;for(let e=0,n=Kh.length;;){let r=e+n>>1;if(t<Kh[r])n=r;else if(t>=BC[r])e=r+1;else return!0;if(e==n)return!1}}function FC(t){return t>=127462&&t<=127487}const MC=8205;function V2(t,e,n=!0,r=!0){return(n?IC:j2)(t,e,r)}function IC(t,e,n){if(e==t.length)return e;e&&PC(t.charCodeAt(e))&&LC(t.charCodeAt(e-1))&&e--;let r=Yh(t,e);for(e+=$C(r);e<t.length;){let o=Yh(t,e);if(r==MC||o==MC||n&&H2(o))e+=$C(o),r=o;else if(FC(o)){let i=0,s=e-2;for(;s>=0&&FC(Yh(t,s));)i++,s-=2;if(i%2==0)break;e+=2}else break}return e}function j2(t,e,n){for(;e>0;){let r=IC(t,e-2,n);if(r<e)return r;e--}return 0}function Yh(t,e){let n=t.charCodeAt(e);if(!LC(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return PC(r)?(n-55296<<10)+(r-56320)+65536:n}function PC(t){return t>=56320&&t<57344}function LC(t){return t>=55296&&t<56320}function $C(t){return t<65536?1:2}let st=class UB{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Ki(this,e,n);let o=[];return this.decompose(0,e,o,2),r.length&&r.decompose(0,r.length,o,3),this.decompose(n,this.length,o,1),_r.from(o,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Ki(this,e,n);let r=[];return this.decompose(e,n,r,0),_r.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),o=new va(this),i=new va(e);for(let s=n,a=n;;){if(o.next(s),i.next(s),s=0,o.lineBreak!=i.lineBreak||o.done!=i.done||o.value!=i.value)return!1;if(a+=o.value.length,o.done||a>=r)return!0}}iter(e=1){return new va(this,e)}iterRange(e,n=this.length){return new HC(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let o=this.line(e).from;r=this.iterRange(o,Math.max(o,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new VC(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?UB.empty:e.length<=32?new _t(e):_r.from(_t.split(e,[]))}};class _t extends st{constructor(e,n=W2(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,o){for(let i=0;;i++){let s=this.text[i],a=o+s.length;if((n?r:a)>=e)return new U2(o,a,r,s);o=a+1,r++}}decompose(e,n,r,o){let i=e<=0&&n>=this.length?this:new _t(zC(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(o&1){let s=r.pop(),a=Uc(i.text,s.text.slice(),0,i.length);if(a.length<=32)r.push(new _t(a,s.length+i.length));else{let l=a.length>>1;r.push(new _t(a.slice(0,l)),new _t(a.slice(l)))}}else r.push(i)}replace(e,n,r){if(!(r instanceof _t))return super.replace(e,n,r);[e,n]=Ki(this,e,n);let o=Uc(this.text,Uc(r.text,zC(this.text,0,e)),n),i=this.length+r.length-(n-e);return o.length<=32?new _t(o,i):_r.from(_t.split(o,[]),i)}sliceString(e,n=this.length,r=`
|
|
13
|
+
*/var I0;function FP(){return I0||(I0=1,(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var i="",s=0;s<arguments.length;s++){var a=arguments[s];a&&(i=o(i,r(a)))}return i}function r(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return n.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var s="";for(var a in i)e.call(i,a)&&i[a]&&(s=o(s,a));return s}function o(i,s){return s?i?i+" "+s:i+s:i}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(ph)),ph.exports}var MP=FP();const ar=Un(MP),P0=({type:t,id:e,nodeId:n,position:r=ne.Position.Right,style:o={},isValidConnection:i,onConnect:s,label:a,status:l,nodeStatus:c=me.IDLE,category:u="main",protocol:d,shape:f="rhombus",connectionLimit:p=1/0,index:m})=>{const{getHandleConnections:v,handleStatus:b}=EP(),{getEdges:w,getNode:g}=ne.useReactFlow(),{getNodes:C}=aa(),k=Ot(),_=$t(),{openNodeSelector:S,nodeSelectorVisible:E}=dc(),x=q=>q.inProgress,B=v(n,e,(q=>q==="source"?nh.OUTPUT:nh.INPUT)(t)).length>=p,I=ne.useConnection(x),F=ne.useConnection(q=>NP({connection:q,nodeId:n,handleId:e},w())),N=B&&!F,P=OP({type:t,handleId:e,isFull:B,connectionInProgress:I,canEdit:k}),M=TP(t,k),z=b(n,e),H=l||z&&z||"default",R=y.useCallback(q=>{const J=mc(C(),q);return J.valid||console.warn(J.code,J.message),J.valid},[C]),Y=y.useCallback(()=>{var ue,ve;const q=g(n);if(!q)return{x:0,y:0};const J=((ue=q.measured)==null?void 0:ue.width)||240,re=((ve=q.measured)==null?void 0:ve.height)||240;let Z={x:0,y:0};switch(r){case ne.Position.Right:Z={x:q.position.x+J+100,y:q.position.y};break;case ne.Position.Left:Z={x:q.position.x-J-100,y:q.position.y};break;case ne.Position.Bottom:Z={x:q.position.x,y:q.position.y+re+100};break;case ne.Position.Top:Z={x:q.position.x,y:q.position.y-100};break}return Z},[n,r,g]),te=q=>{var we;q.stopPropagation();const J=t==="target"&&fh(e);if(t!=="source"&&!J)return;const re=C(),Z=(we=_.canvas.limits)==null?void 0:we.maxNodes;if(typeof Z=="number"&&re.length>=Z){D.message.warning("已达到画布允许的最大节点数");return}const ue=g(n),ve=Y();S(BP({type:t,nodeId:n,handleId:e,position:ve,protocol:J?void 0:d,anchorNode:ue,refresh:E}))},$=Qo.main,j=()=>{switch(H){case"connected":return Qo.connected;case"connecting":return Qo.connecting;case"error":return Qo.error;default:return{}}},U=()=>Object.hasOwn(Qo.nodeStatus,c)?Qo.nodeStatus[c]:{},ee={...$,...j(),...U(),...o},ie=ar("workflow-handle",`workflow-${t}-handle`,"nodrag nopan",`workflow-handle-${H}`,`workflow-handle-${u}`,{"workflow-handle-with-label":!!a,"workflow-handle-main":u==="main","workflow-handle-full":N,"workflow-handle-success":c===me.SUCCESS||c===me.RUNNABLE,"workflow-handle-running":c===me.RUNNING,"workflow-handle-failed":c===me.FAILED,"workflow-handle-invalid":c===me.INVALID},`workflow-handle-target-${r}`,`workflow-handle-shape-${f}`),be=()=>{let q={position:"absolute",zIndex:5,pointerEvents:"all"},J={...rr.line,width:"100%",height:"100%"},re={position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",zIndex:6,...rr.button};const[Z=0,ue=1,ve]=m??[0,1,1];switch(r){case ne.Position.Right:q={...q,left:"100%",top:"50%",transform:"translateY(-50%)",width:rr.horizontal.width,height:rr.horizontal.height},re={...re,left:"calc(100% - 10px)",top:"50%",transform:"translate(50%, -50%)",marginRight:-7},J={...J};break;case ne.Position.Left:q={...q,right:"100%",top:"50%",transform:"translateY(-50%)",width:rr.horizontal.width,height:rr.horizontal.height},re={...re,left:0,top:"50%",transform:"translate(-50%, -50%)"},J={...J,left:0};break;case ne.Position.Bottom:q={...q,top:"100%",left:`${20+60/(ve+1)*(Z+1)}%`,width:rr.vertical.width,height:rr.vertical.height},J={...J,left:0},re={...re,left:"50%",top:"100%",transform:"translate(-50%, -50%)"};break;case ne.Position.Top:q={...q,bottom:"100%",left:"50%",transform:"translateX(-50%)",width:rr.vertical.width,height:rr.vertical.height},re={...re,left:"50%",top:0,transform:"translate(-50%, -50%)"};break}return{containerStyle:q,extenderStyle:J,btnStyle:re}},W=()=>{if(!P)return null;const q=be();return h.jsxs("div",{className:"workflow-handle-extender-container nodrag nopan",style:q.containerStyle,children:[h.jsx("div",{className:"workflow-handle-extender",style:q.extenderStyle}),h.jsx("div",{className:"workflow-handle-extender-btn",style:q.btnStyle,onMouseDown:J=>J.stopPropagation(),onClick:te,children:h.jsx(RB.AiOutlinePlusCircle,{})})]})},X=()=>{if(!a)return null;let q;switch(r){case ne.Position.Left:q={left:-8,textAlign:"right"};break;case ne.Position.Right:q={right:-48,top:-3,position:"absolute",zIndex:1e3,textAlign:"center"};break;case ne.Position.Top:q={position:"absolute",top:-25,left:"-150%",textAlign:"center"};break;case ne.Position.Bottom:q={position:"absolute",bottom:-18,left:"-150%",textAlign:"center"};break;default:q={right:-8}}return h.jsx("span",{className:"workflow-handle-label",style:q,children:a})};return h.jsxs(ne.Handle,{type:t,position:r,id:e,isConnectableStart:M.isConnectableStart,isConnectableEnd:M.isConnectableEnd,isConnectable:!N,isValidConnection:R,onConnect:s,className:ie,style:{...ee,overflow:"visible"},children:[a&&k&&(m&&m.length===3?m[1]>1:!0)&&X(),W()]})},{Text:L0}=D.Typography,{TextArea:IP}=D.Input,PP=({title:t,description:e,note:n,nodeId:r,statusIcon:o,className:i="",onNoteChange:s})=>{const[a,l]=y.useState(!1),[c,u]=y.useState(""),[d,f]=y.useState(!1),p=Ot();if(y.useEffect(()=>{u(n||e||"")},[n,e]),!t&&!e&&!n)return null;const m=C=>{C.stopPropagation(),l(!0)},v=C=>{(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),C.stopPropagation(),l(!0))},b=async()=>{if(!r){D.message.error("节点ID不能为空"),l(!1);return}if(c===(n||e||"")){l(!1);return}f(!0);try{await Vy(r,c),D.message.success(K("link.flow.remark_modification_success")),s==null||s(c),l(!1)}catch(C){D.message.error("备注保存失败"),console.error("保存备注失败:",C),u(n||e||"")}finally{f(!1)}},w=()=>{u(n||e||""),l(!1)},g=C=>{C.key==="Enter"&&(C.ctrlKey||C.metaKey)?b():C.key==="Escape"&&w()};return h.jsxs("div",{className:`workflow-node-description-container ${i}`,children:[t&&h.jsxs("div",{className:"workflow-node-title-row",children:[h.jsx("span",{className:"workflow-node-title-text",children:t}),o&&h.jsx("span",{className:"workflow-node-status-slot",children:o})]}),h.jsx("div",{className:"workflow-node-description-wrapper",children:a?h.jsx(D.Spin,{spinning:d,children:h.jsx(IP,{size:"small",value:c,onDoubleClick:C=>C.stopPropagation(),onDragStart:C=>C.stopPropagation(),onDrag:C=>C.stopPropagation(),onChange:C=>u(C.target.value),onBlur:b,onKeyDown:g,placeholder:"请输入备注...",autoSize:{minRows:1,maxRows:4},autoFocus:!0,className:"workflow-node-note-editor nodrag",style:{borderStyle:"dashed",fontSize:9,minHeight:"auto",paddingInline:3}})}):p?h.jsxs("div",{className:"workflow-node-note-display is-editable",onClick:m,onKeyDown:v,children:[h.jsx(L0,{className:`workflow-node-description ${c?"":"workflow-node-description-placeholder"}`,children:c||"点击添加备注..."}),h.jsx(se.EditOutlined,{className:"workflow-node-edit-icon"})]}):h.jsx("div",{className:"workflow-node-note-display",children:h.jsx(L0,{className:"workflow-node-description",children:c})})})]})};var $0=Symbol.for("immer-nothing"),z0=Symbol.for("immer-draftable"),hn=Symbol.for("immer-state");function lr(t,...e){throw new Error(`[Immer] minified error nr: ${t}. Full error at: https://bit.ly/3cXEKWf`)}var Tn=Object,qi=Tn.getPrototypeOf,wc="constructor",bc="prototype",mh="configurable",vc="enumerable",yc="writable",la="value",ho=t=>!!t&&!!t[hn];function Wr(t){var e;return t?V0(t)||Sc(t)||!!t[z0]||!!((e=t[wc])!=null&&e[z0])||Ec(t)||xc(t):!1}var LP=Tn[bc][wc].toString(),H0=new WeakMap;function V0(t){if(!t||!wh(t))return!1;const e=qi(t);if(e===null||e===Tn[bc])return!0;const n=Tn.hasOwnProperty.call(e,wc)&&e[wc];if(n===Object)return!0;if(!Gi(n))return!1;let r=H0.get(n);return r===void 0&&(r=Function.toString.call(n),H0.set(n,r)),r===LP}function Cc(t,e,n=!0){ca(t)===0?(n?Reflect.ownKeys(t):Tn.keys(t)).forEach(o=>{e(o,t[o],t)}):t.forEach((r,o)=>e(o,r,t))}function ca(t){const e=t[hn];return e?e.type_:Sc(t)?1:Ec(t)?2:xc(t)?3:0}var j0=(t,e,n=ca(t))=>n===2?t.has(e):Tn[bc].hasOwnProperty.call(t,e),gh=(t,e,n=ca(t))=>n===2?t.get(e):t[e],kc=(t,e,n,r=ca(t))=>{r===2?t.set(e,n):r===3?t.add(n):t[e]=n};function $P(t,e){return t===e?t!==0||1/t===1/e:t!==t&&e!==e}var Sc=Array.isArray,Ec=t=>t instanceof Map,xc=t=>t instanceof Set,wh=t=>typeof t=="object",Gi=t=>typeof t=="function",bh=t=>typeof t=="boolean";function zP(t){const e=+t;return Number.isInteger(e)&&String(e)===t}var Ur=t=>t.copy_||t.base_,vh=t=>t.modified_?t.copy_:t.base_;function yh(t,e){if(Ec(t))return new Map(t);if(xc(t))return new Set(t);if(Sc(t))return Array[bc].slice.call(t);const n=V0(t);if(e===!0||e==="class_only"&&!n){const r=Tn.getOwnPropertyDescriptors(t);delete r[hn];let o=Reflect.ownKeys(r);for(let i=0;i<o.length;i++){const s=o[i],a=r[s];a[yc]===!1&&(a[yc]=!0,a[mh]=!0),(a.get||a.set)&&(r[s]={[mh]:!0,[yc]:!0,[vc]:a[vc],[la]:t[s]})}return Tn.create(qi(t),r)}else{const r=qi(t);if(r!==null&&n)return{...t};const o=Tn.create(r);return Tn.assign(o,t)}}function Ch(t,e=!1){return _c(t)||ho(t)||!Wr(t)||(ca(t)>1&&Tn.defineProperties(t,{set:Dc,add:Dc,clear:Dc,delete:Dc}),Tn.freeze(t),e&&Cc(t,(n,r)=>{Ch(r,!0)},!1)),t}function HP(){lr(2)}var Dc={[la]:HP};function _c(t){return t===null||!wh(t)?!0:Tn.isFrozen(t)}var Ac="MapSet",kh="Patches",W0="ArrayMethods",U0={};function ei(t){const e=U0[t];return e||lr(0,t),e}var q0=t=>!!U0[t],ua,G0=()=>ua,VP=(t,e)=>({drafts_:[],parent_:t,immer_:e,canAutoFreeze_:!0,unfinalizedDrafts_:0,handledSet_:new Set,processedForPatches_:new Set,mapSetPlugin_:q0(Ac)?ei(Ac):void 0,arrayMethodsPlugin_:q0(W0)?ei(W0):void 0});function R0(t,e){e&&(t.patchPlugin_=ei(kh),t.patches_=[],t.inversePatches_=[],t.patchListener_=e)}function Sh(t){Eh(t),t.drafts_.forEach(jP),t.drafts_=null}function Eh(t){t===ua&&(ua=t.parent_)}var K0=t=>ua=VP(ua,t);function jP(t){const e=t[hn];e.type_===0||e.type_===1?e.revoke_():e.revoked_=!0}function Y0(t,e){e.unfinalizedDrafts_=e.drafts_.length;const n=e.drafts_[0];if(t!==void 0&&t!==n){n[hn].modified_&&(Sh(e),lr(4)),Wr(t)&&(t=X0(e,t));const{patchPlugin_:o}=e;o&&o.generateReplacementPatches_(n[hn].base_,t,e)}else t=X0(e,n);return WP(e,t,!0),Sh(e),e.patches_&&e.patchListener_(e.patches_,e.inversePatches_),t!==$0?t:void 0}function X0(t,e){if(_c(e))return e;const n=e[hn];if(!n)return Tc(e,t.handledSet_,t);if(!Oc(n,t))return e;if(!n.modified_)return n.base_;if(!n.finalized_){const{callbacks_:r}=n;if(r)for(;r.length>0;)r.pop()(t);Z0(n,t)}return n.copy_}function WP(t,e,n=!1){!t.parent_&&t.immer_.autoFreeze_&&t.canAutoFreeze_&&Ch(e,n)}function J0(t){t.finalized_=!0,t.scope_.unfinalizedDrafts_--}var Oc=(t,e)=>t.scope_===e,UP=[];function Q0(t,e,n,r){const o=Ur(t),i=t.type_;if(r!==void 0&&gh(o,r,i)===e){kc(o,r,n,i);return}if(!t.draftLocations_){const a=t.draftLocations_=new Map;Cc(o,(l,c)=>{if(ho(c)){const u=a.get(c)||[];u.push(l),a.set(c,u)}})}const s=t.draftLocations_.get(e)??UP;for(const a of s)kc(o,a,n,i)}function qP(t,e,n){t.callbacks_.push(function(o){var a;const i=e;if(!i||!Oc(i,o))return;(a=o.mapSetPlugin_)==null||a.fixSetContents(i);const s=vh(i);Q0(t,i.draft_??i,s,n),Z0(i,o)})}function Z0(t,e){var r;if(t.modified_&&!t.finalized_&&(t.type_===3||t.type_===1&&t.allIndicesReassigned_||(((r=t.assigned_)==null?void 0:r.size)??0)>0)){const{patchPlugin_:o}=e;if(o){const i=o.getPath(t);i&&o.generatePatches_(t,i,e)}J0(t)}}function GP(t,e,n){const{scope_:r}=t;if(ho(n)){const o=n[hn];Oc(o,r)&&o.callbacks_.push(function(){Bc(t);const s=vh(o);Q0(t,n,s,e)})}else Wr(n)&&t.callbacks_.push(function(){const i=Ur(t);t.type_===3?i.has(n)&&Tc(n,r.handledSet_,r):gh(i,e,t.type_)===n&&r.drafts_.length>1&&(t.assigned_.get(e)??!1)===!0&&t.copy_&&Tc(gh(t.copy_,e,t.type_),r.handledSet_,r)})}function Tc(t,e,n){return!n.immer_.autoFreeze_&&n.unfinalizedDrafts_<1||ho(t)||e.has(t)||!Wr(t)||_c(t)||(e.add(t),Cc(t,(r,o)=>{if(ho(o)){const i=o[hn];if(Oc(i,n)){const s=vh(i);kc(t,r,s,t.type_),J0(i)}}else Wr(o)&&Tc(o,e,n)})),t}function RP(t,e){const n=Sc(t),r={type_:n?1:0,scope_:e?e.scope_:G0(),modified_:!1,finalized_:!1,assigned_:void 0,parent_:e,base_:t,draft_:null,copy_:null,revoke_:null,isManual_:!1,callbacks_:void 0};let o=r,i=Nc;n&&(o=[r],i=da);const{revoke:s,proxy:a}=Proxy.revocable(o,i);return r.draft_=a,r.revoke_=s,[a,r]}var Nc={get(t,e){if(e===hn)return t;let n=t.scope_.arrayMethodsPlugin_;const r=t.type_===1&&typeof e=="string";if(r&&n!=null&&n.isArrayOperationMethod(e))return n.createMethodInterceptor(t,e);const o=Ur(t);if(!j0(o,e,t.type_))return KP(t,o,e);const i=o[e];if(t.finalized_||!Wr(i)||r&&t.operationMethod&&(n!=null&&n.isMutatingArrayMethod(t.operationMethod))&&zP(e))return i;if(i===xh(t.base_,e)){Bc(t);const s=t.type_===1?+e:e,a=_h(t.scope_,i,t,s);return t.copy_[s]=a}return i},has(t,e){return e in Ur(t)},ownKeys(t){return Reflect.ownKeys(Ur(t))},set(t,e,n){const r=eC(Ur(t),e);if(r!=null&&r.set)return r.set.call(t.draft_,n),!0;if(!t.modified_){const o=xh(Ur(t),e),i=o==null?void 0:o[hn];if(i&&i.base_===n)return t.copy_[e]=n,t.assigned_.set(e,!1),!0;if($P(n,o)&&(n!==void 0||j0(t.base_,e,t.type_)))return!0;Bc(t),Dh(t)}return t.copy_[e]===n&&(n!==void 0||e in t.copy_)||Number.isNaN(n)&&Number.isNaN(t.copy_[e])||(t.copy_[e]=n,t.assigned_.set(e,!0),GP(t,e,n)),!0},deleteProperty(t,e){return Bc(t),xh(t.base_,e)!==void 0||e in t.base_?(t.assigned_.set(e,!1),Dh(t)):t.assigned_.delete(e),t.copy_&&delete t.copy_[e],!0},getOwnPropertyDescriptor(t,e){const n=Ur(t),r=Reflect.getOwnPropertyDescriptor(n,e);return r&&{[yc]:!0,[mh]:t.type_!==1||e!=="length",[vc]:r[vc],[la]:n[e]}},defineProperty(){lr(11)},getPrototypeOf(t){return qi(t.base_)},setPrototypeOf(){lr(12)}},da={};for(let t in Nc){let e=Nc[t];da[t]=function(){const n=arguments;return n[0]=n[0][0],e.apply(this,n)}}da.deleteProperty=function(t,e){return da.set.call(this,t,e,void 0)},da.set=function(t,e,n){return Nc.set.call(this,t[0],e,n,t[0])};function xh(t,e){const n=t[hn];return(n?Ur(n):t)[e]}function KP(t,e,n){var o;const r=eC(e,n);return r?la in r?r[la]:(o=r.get)==null?void 0:o.call(t.draft_):void 0}function eC(t,e){if(!(e in t))return;let n=qi(t);for(;n;){const r=Object.getOwnPropertyDescriptor(n,e);if(r)return r;n=qi(n)}}function Dh(t){t.modified_||(t.modified_=!0,t.parent_&&Dh(t.parent_))}function Bc(t){t.copy_||(t.assigned_=new Map,t.copy_=yh(t.base_,t.scope_.immer_.useStrictShallowCopy_))}var YP=class{constructor(t){this.autoFreeze_=!0,this.useStrictShallowCopy_=!1,this.useStrictIteration_=!1,this.produce=(e,n,r)=>{if(Gi(e)&&!Gi(n)){const i=n;n=e;const s=this;return function(l=i,...c){return s.produce(l,u=>n.call(this,u,...c))}}Gi(n)||lr(6),r!==void 0&&!Gi(r)&&lr(7);let o;if(Wr(e)){const i=K0(this),s=_h(i,e,void 0);let a=!0;try{o=n(s),a=!1}finally{a?Sh(i):Eh(i)}return R0(i,r),Y0(o,i)}else if(!e||!wh(e)){if(o=n(e),o===void 0&&(o=e),o===$0&&(o=void 0),this.autoFreeze_&&Ch(o,!0),r){const i=[],s=[];ei(kh).generateReplacementPatches_(e,o,{patches_:i,inversePatches_:s}),r(i,s)}return o}else lr(1,e)},this.produceWithPatches=(e,n)=>{if(Gi(e))return(s,...a)=>this.produceWithPatches(s,l=>e(l,...a));let r,o;return[this.produce(e,n,(s,a)=>{r=s,o=a}),r,o]},bh(t==null?void 0:t.autoFreeze)&&this.setAutoFreeze(t.autoFreeze),bh(t==null?void 0:t.useStrictShallowCopy)&&this.setUseStrictShallowCopy(t.useStrictShallowCopy),bh(t==null?void 0:t.useStrictIteration)&&this.setUseStrictIteration(t.useStrictIteration)}createDraft(t){Wr(t)||lr(8),ho(t)&&(t=XP(t));const e=K0(this),n=_h(e,t,void 0);return n[hn].isManual_=!0,Eh(e),n}finishDraft(t,e){const n=t&&t[hn];(!n||!n.isManual_)&&lr(9);const{scope_:r}=n;return R0(r,e),Y0(void 0,r)}setAutoFreeze(t){this.autoFreeze_=t}setUseStrictShallowCopy(t){this.useStrictShallowCopy_=t}setUseStrictIteration(t){this.useStrictIteration_=t}shouldUseStrictIteration(){return this.useStrictIteration_}applyPatches(t,e){let n;for(n=e.length-1;n>=0;n--){const o=e[n];if(o.path.length===0&&o.op==="replace"){t=o.value;break}}n>-1&&(e=e.slice(n+1));const r=ei(kh).applyPatches_;return ho(t)?r(t,e):this.produce(t,o=>r(o,e))}};function _h(t,e,n,r){const[o,i]=Ec(e)?ei(Ac).proxyMap_(e,n):xc(e)?ei(Ac).proxySet_(e,n):RP(e,n);return((n==null?void 0:n.scope_)??G0()).drafts_.push(o),i.callbacks_=(n==null?void 0:n.callbacks_)??[],i.key_=r,n&&r!==void 0?qP(n,i,r):i.callbacks_.push(function(l){var u;(u=l.mapSetPlugin_)==null||u.fixSetContents(i);const{patchPlugin_:c}=l;i.modified_&&c&&c.generatePatches_(i,[],l)}),o}function XP(t){return ho(t)||lr(10,t),tC(t)}function tC(t){if(!Wr(t)||_c(t))return t;const e=t[hn];let n,r=!0;if(e){if(!e.modified_)return e.base_;e.finalized_=!0,n=yh(t,e.scope_.immer_.useStrictShallowCopy_),r=e.scope_.immer_.shouldUseStrictIteration()}else n=yh(t,!0);return Cc(n,(o,i)=>{kc(n,o,tC(i))},r),e&&(e.finalized_=!1),n}var JP=new YP,fa=JP.produce;const Ri=()=>{const t=ne.useStoreApi(),{setNodes:e}=ne.useReactFlow(),n=$t();return{handleNodeDataUpdate:y.useCallback(({id:o,data:i,sync:s})=>{const{nodes:a}=t.getState(),l=fa(a,c=>{const u=c.find(d=>d.id===o);u&&(u.data={...u.data,...i}),s&&rc(o,{flow_id:n.flowId,properties:u.data.config_schema})});e(l)},[t])}},QP=new Set(["properties","params","account_id","proxy_id","mcp_tool_description"]);function qr(t){return!!(t&&typeof t=="object"&&!Array.isArray(t))}function po(t={}){const e=t==null?void 0:t.action_id,n=typeof e=="number"?e:parseInt(`${e??""}`,10);return!Number.isFinite(n)||n<=0}function ha(t){if(!qr(t))return{};const e=t.properties,n=t.params,r=qr(e)?e:qr(n)?n:void 0;if(!r)return t;const i=Object.keys(t).every(a=>QP.has(a)),s=["account_id","proxy_id","mcp_tool_description","isNodePackage"].some(a=>Object.hasOwn(t,a));return i||s?r:t}function ZP(t){if(!qr(t))return{};const e=qr(t.properties)?t.properties:qr(t.params)?t.params:t;return ha(e)}function e2(t){return qr(t)?Object.hasOwn(t,"account_id")?t.account_id??null:qr(t.properties)&&Object.hasOwn(t.properties,"account_id")?t.properties.account_id??null:qr(t.params)&&Object.hasOwn(t.params,"account_id")?t.params.account_id??null:null:null}const t2=t=>t.mode??t.configMode??"edit",n2=(t,e)=>t!=="preview"&&!e,Ah=t=>t==="preview",Oh=t=>{var n,r,o;if(!t)return!1;if(((n=t.data)==null?void 0:n.action_key)==="dip.core.trigger.mcp-server"||t.type===pe.TRIGGER)return!0;const e=t.data;if(!e)return!1;if(typeof e.is_trigger<"u")return e.is_trigger===!0||e.is_trigger===1||e.is_trigger==="1";if(/@/.test(t.type)&&((r=t.data)!=null&&r.action_key)&&((o=t.data)!=null&&o.action_ver)){const i=_P(t.data.action_key,t.data.action_ver);if(i&&i.is_trigger!=null)return i.is_trigger}return!1},r2=t=>({label:t.action_name,description:t.connector_name,config_schema:t.config_schema||t.properties,...Object.entries(t).reduce((e,[n,r])=>(n!=="name"&&(e[n]=r),e),{})}),Th={color:"#3883f6"},o2=[pe.TRIGGER,pe.AI_SUB_NODE],i2=[pe.TRIGGER,pe.AI_SUB_NODE],s2=({nodeId:t,isDisabled:e=!1,handleViewConfig:n,onDelete:r,className:o,type:i})=>{const{handleNodeDataUpdate:s}=Ri(),{addNodes:a,getNodes:l}=aa(),c=$t(),u=ne.useInternalNode(t),d=Ot(),f=na(),p=Oh(u),[m,v]=y.useState(!1),b=y.useMemo(()=>{var I;const O=c.nodeTypes;if(!u)return;const A=O.types[u.type];if(A)return A;const T=(I=u.data)==null?void 0:I.category;return T?Object.values(O.types).find(F=>F.category===T):void 0},[c.nodeTypes,u]),w=y.useMemo(()=>((b==null?void 0:b.operations)||[]).reduce((A,T)=>(A[T.id]=T.enabled,A),{}),[b]),g=y.useMemo(()=>{var T,B;if(!u)return!1;const O=((T=c.canvas.fixedNodes)==null?void 0:T.triggerIds)||[],A=((B=c.nodeTypes.fixed)==null?void 0:B.triggers)||[];return O.includes(u.id)||A.includes(u.type)},[c.canvas.fixedNodes,c.nodeTypes.fixed,u]),C=y.useMemo(()=>{if(p)return!1;const O=!o2.includes(i),A=w.copy===void 0?!0:w.copy;return O&&A&&d},[i,w,d,p]),k=y.useMemo(()=>{if(p)return!1;const O=!i2.includes(i),A=w.disable===void 0?!0:w.disable;return O&&A&&d},[i,w,d,p]),_=()=>{jy(t,e?"on":"off").then(O=>{s({id:t,data:{closed:O.closed,status:O.status}})})},S=y.useMemo(()=>!Ah(f)&&!d,[f,d]);y.useMemo(()=>d&&!g&&c.canvas.allowRemoveTrigger,[d,g,c.canvas.allowRemoveTrigger]);const E=()=>{r&&r(t)},x=async()=>{var B;if(m)return;const O=l(),A=O.find(I=>I.id===t);if(!A){D.message.error("获取当前节点信息失败");return}const T=(B=c.canvas.limits)==null?void 0:B.maxNodes;if(typeof T=="number"&&O.length>=T){D.message.warning("已达到画布允许的最大节点数");return}v(!0);try{const I=await eh(t);if(I){const N=po(I)?ia(I.action_key,I.action_ver):I.node_type,P=r2(I),M=Ni.createNode(N,I.id,{...P,saveType:I.node_type,icon:A.data.icon??P.icon},{x:A.position.x,y:A.position.y+100});a([M]),D.message.success("节点复制成功")}}catch(I){D.message.error("节点复制失败"),console.error("复制节点失败:",I)}finally{v(!1)}};return h.jsxs("div",{className:ar("node-operations",o),children:[C&&h.jsx(D.Tooltip,{title:"复制节点",children:h.jsx(D.Button,{type:"text",icon:h.jsx(Af.IoCopyOutline,{style:Th}),onClick:x,loading:m,disabled:m,className:ar("operation-button")})}),k&&h.jsx(D.Tooltip,{title:e?"激活节点":"禁用节点",children:h.jsx(D.Button,{type:"text",icon:e?h.jsx(Af.IoPlayOutline,{style:Th}):h.jsx(Af.IoBanOutline,{style:Th}),onClick:_,className:ar("operation-button",{disabled:e})})}),d&&h.jsx(D.Popconfirm,{title:"确定要删除此节点吗?",description:"删除后无法恢复,请谨慎操作",onConfirm:E,okText:"确定",cancelText:"取消",placement:"top",children:h.jsx(D.Tooltip,{title:"删除节点",children:h.jsx(D.Button,{type:"text",icon:h.jsx(KB.RiDeleteBin5Line,{style:{color:"red"}}),className:"operation-button delete-button"})})}),S&&h.jsx(D.Tooltip,{title:"查看配置",children:h.jsx(D.Button,{type:"link",onClick:n,icon:h.jsx(se.EyeOutlined,{}),className:ar("operation-button")})})]})},Nh={[me.INVALID]:{label:"未调试",tone:"warning",icon:h.jsx(se.WarningOutlined,{})},[me.IDLE]:{label:"空闲",tone:"idle",icon:h.jsx(se.ClockCircleOutlined,{})},[me.RUNNING]:{label:"运行中",tone:"running",icon:h.jsx(se.LoadingOutlined,{spin:!0})},[me.FAILED]:{label:"失败",tone:"failed",icon:h.jsx(se.CloseCircleFilled,{})},[me.SUCCESS]:{label:"成功",tone:"success",icon:h.jsx(se.CheckCircleFilled,{})},[me.RUNNABLE]:{label:"线上运行",tone:"runnable",icon:h.jsx(se.CheckCircleFilled,{})},[me.ACTIVE]:{label:"已激活",tone:"runnable",icon:h.jsx(se.CheckCircleFilled,{})},[me.DEACTIVATED]:{label:"已禁用",tone:"disabled",icon:h.jsx(se.PauseCircleFilled,{})},[me.WARNING]:{label:"警告",tone:"warning",icon:h.jsx(se.WarningFilled,{})}},nC=({status:t,disabled:e=!1})=>{const n=e?Nh[me.DEACTIVATED]:Nh[t]||Nh[me.IDLE];return h.jsxs("span",{className:`workflow-node-status-badge is-${n.tone}`,role:"status","aria-label":`节点状态:${n.label}`,title:`节点状态:${n.label}`,children:[h.jsx("span",{className:"workflow-node-status-symbol","aria-hidden":"true",children:n.icon}),h.jsx("span",{children:n.label})]})},Bh=y.createContext(null),pa=y.createContext(null),rC=({children:t,variables:e=[],variablePrefix:n="{{",variableSuffix:r="}}",onValidateVariable:o})=>{const[i,s]=y.useState(null),[a,l]=y.useState(!1),[c,u]=y.useState(e),d=y.useRef(new Map),f=y.useRef(null),p=y.useRef(o),m=y.useRef(c);f.current=i,p.current=o,m.current=c;const v=y.useCallback(A=>{d.current.set(A.id,A)},[]),b=y.useCallback(A=>{d.current.delete(A),s(T=>T===A?null:T)},[]),w=y.useCallback(A=>{s(T=>T===A?T:A),l(T=>T||!0)},[]),g=y.useCallback(()=>{s(A=>A===null?A:null)},[]),C=y.useCallback(A=>A.startsWith(n)&&A.endsWith(r)?A:`${n}${A}${r}`,[n,r]),k=y.useCallback(A=>A.startsWith(n)&&A.endsWith(r)?A.slice(n.length,-r.length):null,[n,r]),_=y.useCallback(A=>{if(p.current)return p.current(A);const T=k(A)||A;return m.current.some(B=>B.path===T)},[k]),S=y.useCallback((A,T=!0)=>{const B=f.current;if(!B)return;const I=d.current.get(B);if(!I)return;const F=T?C(A):A;I.insertVariable(F,T)},[C]),E=y.useCallback(()=>f.current,[]),x=y.useMemo(()=>({registerField:v,unregisterField:b,activateField:w,deactivateField:g,setSelectorVisible:l,insertVariableToActiveField:S,setAvailableVariables:u,validateVariable:_,formatVariable:C,extractVariable:k,getActiveFieldId:E}),[v,b,w,g,S,_,C,k,E]),O=y.useMemo(()=>({activeFieldId:i,selectorVisible:a,availableVariables:c}),[i,a,c]);return h.jsx(pa.Provider,{value:x,children:h.jsx(Bh.Provider,{value:O,children:t})})},a2=()=>{const t=y.useContext(Bh),e=y.useContext(pa);if(!t||!e)throw new Error("useVariableSelector must be used within a VariableSelectorProvider");return y.useMemo(()=>({...t,...e}),[t,e])},oC=(t,e,n)=>{const r=y.useContext(pa),o=vt.useRef(e),i=vt.useRef(n),s=vt.useRef(r);return o.current=e,i.current=n,s.current=r,vt.useEffect(()=>{const a=s.current;if(!a)return;const l={id:t,insertVariable:(c,u)=>o.current(c,u),focus:()=>i.current()};return a.registerField(l),()=>{a.unregisterField(t)}},[t]),{activate:()=>{var a;(a=s.current)==null||a.activateField(t)},deactivate:()=>{var a;return(a=s.current)==null?void 0:a.deactivateField()}}},Fh=()=>y.useContext(pa),Mh=()=>{const t=y.useContext(Bh),e=y.useContext(pa);return y.useMemo(()=>!t||!e?null:{...t,...e},[t,e])},Fc={nestedModal:1200,nestedPopover:1250,fullscreenWorkspace:1400},Gr={accountModal:"_accountModal_b0w5m_1",formLayout:"_formLayout_b0w5m_17",formContent:"_formContent_b0w5m_23",formActions:"_formActions_b0w5m_31",rdbmsTestAction:"_rdbmsTestAction_b0w5m_40"},Ih={meta:{name:"ant-design-5x-full-theme",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#1677ff",colorInfo:"#1677ff",colorSuccess:"#52c41a",colorWarning:"#faad14",colorError:"#ff4d4f",colorTextBase:"#000000",colorBgBase:"#ffffff",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.5714285714285714,borderRadius:6,borderRadiusSM:4,borderRadiusLG:8,lineWidth:1,lineType:"solid",controlHeight:32,controlHeightSM:24,controlHeightLG:40,sizeUnit:4,sizeStep:4,padding:16,paddingXS:8,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:8,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05)",boxShadowSecondary:"0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05)",boxShadowTertiary:"0 1px 2px 0 rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px 0 rgba(0, 0, 0, 0.02)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:8},Anchor:{linkPaddingInlineStart:16},AutoComplete:{},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:6,borderRadiusSM:4,borderRadiusLG:8,controlHeight:32,controlHeightSM:24,controlHeightLG:40,paddingInline:15,paddingInlineLG:15,paddingInlineSM:7,contentFontSize:14,contentFontSizeLG:16,contentFontSizeSM:14,primaryShadow:"0 2px 0 rgba(5, 145, 255, 0.1)",dangerShadow:"0 2px 0 rgba(255, 38, 5, 0.06)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:4},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:40,controlHeightLG:48,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:32,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:32,controlHeightSM:24,controlHeightLG:40,paddingInline:11,paddingInlineSM:7,paddingInlineLG:11,paddingBlock:4,paddingBlockSM:0,paddingBlockLG:6,borderRadius:6},InputNumber:{controlHeight:32,controlHeightSM:24,controlHeightLG:40},Layout:{headerBg:"#001529",headerHeight:64,headerPadding:"0 50px",bodyBg:"#f5f5f5",siderBg:"#001529",triggerBg:"#002140"},List:{itemPadding:"12px 0"},Mentions:{},Menu:{itemHeight:40,iconSize:14,collapsedIconSize:16,horizontalItemBorderRadius:6,itemBorderRadius:6},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16},Notification:{},Pagination:{itemSize:32,itemSizeSM:24},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{buttonSolidCheckedBg:"#1677ff"},Rate:{},Result:{},Segmented:{controlHeight:32},Select:{controlHeight:32,controlHeightSM:24,controlHeightLG:40,multipleItemHeight:24,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:22,trackMinWidth:44,handleSize:18},Table:{headerBg:"#fafafa",headerSortActiveBg:"#f0f0f0",headerSortHoverBg:"#f5f5f5",rowHoverBg:"#fafafa",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:4,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 16px"},Tag:{borderRadiusSM:4},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:32,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}},l2="",iC=({children:t,customTheme:e,locale:n=hv,prefixCls:r=l2})=>{const o=vt.useMemo(()=>({...e,cssVar:(e==null?void 0:e.cssVar)??{prefix:r},algorithm:(e==null?void 0:e.algorithm)??D.theme.defaultAlgorithm,token:{...Ih.token,...e==null?void 0:e.token},components:{...Ih.components,...e==null?void 0:e.components}}),[r,e]);return h.jsx(D.ConfigProvider,{prefixCls:r,locale:n,theme:o,getPopupContainer:i=>(i==null?void 0:i.parentElement)||document.body,children:t})};function qn(t,e){if(t==null||e==="")return;const n=e.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let r=t;for(const o of n){if(r==null)return;const i=Number(o);!Number.isNaN(i)&&Array.isArray(r)?r=r[i]:r=r[o]}return r}const c2=t=>!t||t.length===0,sC=(t,e)=>t==null?!1:Array.isArray(t)?Array.isArray(e)?e.some(n=>t.includes(n)):t.includes(e):typeof t=="string"?Array.isArray(e)?e.some(n=>t.includes(String(n))):t.includes(String(e)):!1,aC=t=>t==null?!0:typeof t=="string"?t.trim().length===0:Array.isArray(t)?t.length===0:typeof t=="object"?Object.keys(t).length===0:!1,lC=(t,e)=>Array.isArray(e)?e.includes(t):!1,u2=(t,e,n)=>{switch(t){case"EQ":return e===n;case"NOT":return e!==n;case"GT":return Number(e)>Number(n);case"LT":return Number(e)<Number(n);case"GE":return Number(e)>=Number(n);case"LE":return Number(e)<=Number(n);case"ISEVEN":return Number(e)%2===0;case"ISODD":return Math.abs(Number(e))%2===1;case"IC":return sC(e,n);case"NIC":return!sC(e,n);case"IN":return lC(e,n);case"NIN":case"NOT_IN":return!lC(e,n);case"EXISTS":return e!=null;case"EMPTY":return aC(e);case"NOT_EMPTY":return!aC(e);default:return!1}},ti=(t,e)=>{if(!t)return!0;const{AND:n,OR:r,key:o,keyword:i,value:s}=t,a=Array.isArray(n),l=Array.isArray(r);if(a||l){const u=n??[],d=r??[];let f=!0,p=c2(d);for(const m of u){if(!f)break;f=ti(m,e)}for(const m of d){if(p)break;p=ti(m,e)}return f&&p}if(!o||!i)return!0;const c=qn(e,o);return u2(i,c,s)};function d2(t,e){const{eventPayload:n,formValues:r}=e;if(t.startsWith("payload.")){const o=t.slice(8);return qn(n.payload||{},o)}if(t.startsWith("formValues.")){const o=t.slice(11);return qn(r,o)}return t in n?n[t]:n.payload&&t in n.payload?n.payload[t]:qn(r,t)}function f2(t,e){const{form:n}=e,{targets:r}=t;for(const o of r)n.setFieldValue(o,void 0);e.executionDepth===1&&console.log("[ActionExecutor] 清空字段:",r)}function h2(t,e){const{form:n}=e,{target:r,value:o,valueFrom:i}=t;let s;i?s=d2(i,e):s=o,n.setFieldValue(r,s),e.executionDepth===1&&console.log(`[ActionExecutor] 设置字段值: ${r} =`,s)}function p2(t,e){const{target:n,disabled:r}=t;e.executionDepth===1&&(console.log(`[ActionExecutor] 设置字段禁用状态: ${n} = ${r}`),console.warn("[ActionExecutor] setFieldDisabled 需要外部状态管理支持,当前仅记录日志"))}async function m2(t,e){const{form:n}=e,{targets:r}=t;try{r&&r.length>0?await n.validateFields(r):await n.validateFields(),e.executionDepth===1&&console.log("[ActionExecutor] 触发验证:",r||"所有字段")}catch(o){e.executionDepth===1&&console.log("[ActionExecutor] 验证失败:",o)}}async function g2(t,e){const{optionsLoader:n,form:r}=e,{action:o,params:i,resultTo:s}=t;if(!n){console.warn("[ActionExecutor] 未提供 optionsLoader,无法执行 callDataLoader 动作");return}try{const a=await n(o,i||{},{values:e.formValues});s&&(r.setFieldValue(s,a),e.executionDepth===1&&console.log(`[ActionExecutor] 数据加载完成,结果设置到: ${s}`,a))}catch(a){console.error("[ActionExecutor] 数据加载失败:",a)}}async function w2(t,e){const{customHandlers:n}=e,{handler:r,params:o}=t;if(!n||!n[r]){console.warn(`[ActionExecutor] 未找到自定义处理器: ${r}`);return}try{await n[r](e,o),e.executionDepth===1&&console.log(`[ActionExecutor] 执行自定义动作: ${r}`)}catch(i){console.error(`[ActionExecutor] 自定义动作执行失败: ${r}`,i)}}async function b2(t,e){switch(t.type){case"clearFields":f2(t,e);break;case"setFieldValue":h2(t,e);break;case"setFieldDisabled":p2(t,e);break;case"triggerValidation":await m2(t,e);break;case"callDataLoader":await g2(t,e);break;case"custom":await w2(t,e);break;default:console.warn("[ActionExecutor] 未知的动作类型:",t.type)}}async function v2(t,e){for(const n of t)await b2(n,e)}function y2(t){const{events:e,form:n,optionsLoader:r,customHandlers:o,maxExecutionDepth:i=10,debug:s=!1}=t,a=y.useRef(0),l=y.useRef(new Map),c=y.useCallback(async(b,w)=>{if(a.current+=1,a.current>i){console.error(`[EventEngine] 执行深度超过限制 (${i}),可能存在无限循环`,b.id||b.trigger),a.current=0;return}try{const g=n.getFieldsValue();if(b.conditions&&!ti(b.conditions,g)){s&&console.log("[EventEngine] 条件不满足,跳过执行:",b.id);return}const C={form:n,formValues:g,eventPayload:w,optionsLoader:r,customHandlers:o,executionDepth:a.current};await v2(b.actions,C),s&&console.log("[EventEngine] 事件处理完成:",b.id||b.trigger)}finally{a.current-=1}},[n,r,o,i,s]),u=y.useCallback(b=>{const w=e.filter(g=>{const{trigger:C}=g;return C.type!==b.type?!1:(C.type==="fieldChange"||C.type==="fieldBlur"||C.type==="fieldFocus")&&"field"in C?C.field===b.field:C.type==="custom"&&"eventName"in C?C.eventName===b.eventName:C.type==="formMount"});for(const g of w)if(g.debounce&&g.debounce>0){const C=`${g.id||JSON.stringify(g.trigger)}`,k=l.current.get(C);k&&clearTimeout(k);const _=setTimeout(()=>{c(g,b),l.current.delete(C)},g.debounce);l.current.set(C,_)}else c(g,b)},[e,c]),d=y.useCallback((b,w,g)=>{const C={type:"fieldChange",field:b,oldValue:g,newValue:w,timestamp:Date.now()};u(C),s&&console.log("[EventEngine] 字段变化事件:",{fieldPath:b,oldValue:g,newValue:w})},[u,s]),f=y.useCallback(b=>{const w={type:"fieldBlur",field:b,timestamp:Date.now()};u(w),s&&console.log("[EventEngine] 字段失焦事件:",{fieldPath:b})},[u,s]),p=y.useCallback(b=>{const w={type:"fieldFocus",field:b,timestamp:Date.now()};u(w),s&&console.log("[EventEngine] 字段聚焦事件:",{fieldPath:b})},[u,s]);y.useEffect(()=>{const b={type:"formMount",timestamp:Date.now()};u(b)},[]),y.useEffect(()=>()=>{for(const b of l.current.values())clearTimeout(b);l.current.clear()},[]);const m=y.useCallback((b,w)=>{const g={type:"custom",eventName:b,payload:w,timestamp:Date.now()};u(g)},[u]);return{triggerFieldChange:d,fieldEventHandlers:{onBlur:f,onFocus:p,dispatch:m}}}const Ph=y.createContext({}),cC=({value:t,children:e})=>h.jsx(Ph.Provider,{value:t,children:e}),uC=()=>y.useContext(Ph);class Mc{constructor(){lt(this,"registry",new Map)}register(e,n,r={}){const{override:o=!1}=r;if(this.registry.has(e)&&!o){console.warn(`[FieldRegistry] 字段类型 "${e}" 已注册。使用 { override: true } 来覆盖。`);return}this.registry.set(e,n)}unregister(e){this.registry.delete(e)}get(e){return this.registry.get(e)}has(e){return this.registry.has(e)}getRegisteredTypes(){return Array.from(this.registry.keys())}clone(){const e=new Mc;return this.registry.forEach((n,r)=>{e.register(r,n)}),e}}const Ic=new Mc;function C2(){return new Mc}const dC=y.createContext(Ic),fC=({registry:t,additionalRegistrations:e,children:n})=>{const r=y.useMemo(()=>{const o=t||Ic.clone();if(e!=null&&e.length)for(const{type:i,definition:s}of e)o.register(i,s,{override:!0});return o},[t,e]);return h.jsx(dC.Provider,{value:r,children:n})},Pc=()=>y.useContext(dC),hC=y.createContext(null);function pC(){return y.useContext(hC)}const mC=({policy:t,mode:e,onModeChange:n,children:r})=>{const o=y.useMemo(()=>({policy:t,mode:e,onModeChange:n,suppressNestedSwitch:!0}),[e,n,t]);return h.jsx(hC.Provider,{value:o,children:r})},gC=["normal","expression"],k2={TEXT:{availableModes:["normal"],defaultMode:"normal"},EXPRESSION:{availableModes:["expression"],defaultMode:"expression"},BOTH:{availableModes:["normal","expression"],defaultMode:"normal"}};function Lh(t){return k2[t]}function wC(t){return t==="EXPRESSION"||t==="BOTH"}const Lc={normal:{label:"文本",icon:h.jsx(se.FontSizeOutlined,{}),description:"普通文本输入"},expression:{label:"表达式",icon:h.jsx(se.FunctionOutlined,{}),description:"按 JavaScript 表达式求值"},code:{label:"代码",icon:h.jsx(se.CodeOutlined,{}),description:"JavaScript 代码模式"}},$h=({valueModePolicy:t,mode:e,onModeChange:n,disabled:r=!1,readOnly:o=!1,modeSwitchPosition:i="top-right"})=>{const{availableModes:s}=Lh(t),a=s.filter(c=>Lc[c]),l=a.length>1;return a.length===0?null:h.jsx("div",{className:`value-mode-switch ${i}`,children:h.jsx(D.Radio.Group,{value:e,onChange:l?c=>n==null?void 0:n(c.target.value):void 0,size:"small",disabled:r||o,optionType:"button",buttonStyle:"solid",children:a.map(c=>h.jsxs(D.Radio.Button,{value:c,title:Lc[c].description,children:[Lc[c].icon,h.jsx("span",{className:"mode-label",children:Lc[c].label})]},c))})})},S2=y.lazy(()=>Promise.resolve().then(()=>qte)),bC=t=>{const e=Et.useReactive({editorVisible:!1}),n=()=>{e.editorVisible=!0};y.useEffect(()=>{t.openEditorNumber&&n()},[t.openEditorNumber]);const r=o=>{t.onFinish(o),e.editorVisible=!1};return t.canEditInEditor?h.jsxs(y.Fragment,{children:[h.jsx("div",{style:{display:"flex",flexDirection:"column"},children:t.children}),e.editorVisible&&h.jsx(y.Suspense,{fallback:null,children:h.jsx(S2,{open:!0,initialValue:t.value,nodeId:t.nodeId??"",language:t.language,showVariableSidebar:t.showVariableSidebar,onCancel:()=>{e.editorVisible=!1},onFinish:r})})]}):t.children},E2={magenta:{textColor:"#c41d7f",backgroundColor:"#fff0f6",borderColor:"#ffadd2"},red:{textColor:"#cf1322",backgroundColor:"#fff1f0",borderColor:"#ffa39e"},volcano:{textColor:"#d4380d",backgroundColor:"#fff2e8",borderColor:"#ffbb96"},orange:{textColor:"#d46b08",backgroundColor:"#fff7e6",borderColor:"#ffd591"},gold:{textColor:"#d48806",backgroundColor:"#fffbe6",borderColor:"#ffe58f"},lime:{textColor:"#7cb305",backgroundColor:"#fcffe6",borderColor:"#eaff8f"},green:{textColor:"#389e0d",backgroundColor:"#f6ffed",borderColor:"#b7eb8f"},cyan:{textColor:"#08979c",backgroundColor:"#edf2f7",borderColor:"#c6dbf0"},blue:{textColor:"rgba(0, 0, 0, 0.5)",backgroundColor:"#edf2f7",borderColor:"#91caff"},geekblue:{textColor:"#1d39c4",backgroundColor:"#f0f5ff",borderColor:"#adc6ff"},purple:{textColor:"#531dab",backgroundColor:"#f9f0ff",borderColor:"#d3adf7"}},vC=1024;let x2=0,zh=class{constructor(e,n){this.from=e,this.to=n}};class Je{constructor(e={}){this.id=x2++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Cn.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}Je.closedBy=new Je({deserialize:t=>t.split(" ")}),Je.openedBy=new Je({deserialize:t=>t.split(" ")}),Je.group=new Je({deserialize:t=>t.split(" ")}),Je.isolate=new Je({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),Je.contextHash=new Je({perNode:!0}),Je.lookAhead=new Je({perNode:!0}),Je.mounted=new Je({perNode:!0});class ma{constructor(e,n,r,o=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=o}static get(e){return e&&e.props&&e.props[Je.mounted.id]}}const D2=Object.create(null);class Cn{constructor(e,n,r,o=0){this.name=e,this.props=n,this.id=r,this.flags=o}static define(e){let n=e.props&&e.props.length?Object.create(null):D2,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),o=new Cn(e.name||"",n,e.id,r);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(o)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[i[0].id]=i[1]}}return o}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Je.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let o of r.split(" "))n[o]=e[r];return r=>{for(let o=r.prop(Je.group),i=-1;i<(o?o.length:0);i++){let s=n[i<0?r.name:o[i]];if(s)return s}}}}Cn.none=new Cn("",Object.create(null),0,8);class Hh{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let r of this.types){let o=null;for(let i of e){let s=i(r);if(s){o||(o=Object.assign({},r.props));let a=s[1],l=s[0];l.combine&&l.id in o&&(a=l.combine(o[l.id],a)),o[l.id]=a}}n.push(o?new Cn(r.name,o,r.id,r.flags):r)}return new Hh(n)}}const $c=new WeakMap,yC=new WeakMap;var Ct;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Ct||(Ct={}));class Dt{constructor(e,n,r,o,i){if(this.type=e,this.children=n,this.positions=r,this.length=o,this.props=null,i&&i.length){this.props=Object.create(null);for(let[s,a]of i)this.props[typeof s=="number"?s:s.id]=a}}toString(){let e=ma.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let o=r.toString();o&&(n&&(n+=","),n+=o)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new Wh(this.topNode,e)}cursorAt(e,n=0,r=0){let o=$c.get(this)||this.topNode,i=new Wh(o);return i.moveTo(e,n),$c.set(this,i._tree),i}get topNode(){return new Gn(this,0,0,null)}resolve(e,n=0){let r=ga($c.get(this)||this.topNode,e,n,!1);return $c.set(this,r),r}resolveInner(e,n=0){let r=ga(yC.get(this)||this.topNode,e,n,!0);return yC.set(this,r),r}resolveStack(e,n=0){return O2(this,e,n)}iterate(e){let{enter:n,leave:r,from:o=0,to:i=this.length}=e,s=e.mode||0,a=(s&Ct.IncludeAnonymous)>0;for(let l=this.cursor(s|Ct.IncludeAnonymous);;){let c=!1;if(l.from<=i&&l.to>=o&&(!a&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(a||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:qh(Cn.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,o)=>new Dt(this.type,n,r,o,this.propValues),e.makeTree||((n,r,o)=>new Dt(Cn.none,n,r,o)))}static build(e){return T2(e)}}Dt.empty=new Dt(Cn.none,[],[],0);class Vh{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new Vh(this.buffer,this.index)}}class mo{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return Cn.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],r=this.buffer[e+3],o=this.set.types[n],i=o.name;if(/\W/.test(i)&&!o.isError&&(i=JSON.stringify(i)),e+=4,r==e)return i;let s=[];for(;e<r;)s.push(this.childString(e)),e=this.buffer[e+3];return i+"("+s.join(",")+")"}findChild(e,n,r,o,i){let{buffer:s}=this,a=-1;for(let l=e;l!=n&&!(CC(i,o,s[l+1],s[l+2])&&(a=l,r>0));l=s[l+3]);return a}slice(e,n,r){let o=this.buffer,i=new Uint16Array(n-e),s=0;for(let a=e,l=0;a<n;){i[l++]=o[a++],i[l++]=o[a++]-r;let c=i[l++]=o[a++]-r;i[l++]=o[a++]-e,s=Math.max(s,c)}return new mo(i,s,this.set)}}function CC(t,e,n,r){switch(t){case-2:return n<e;case-1:return r>=e&&n<e;case 0:return n<e&&r>e;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function ga(t,e,n,r){for(var o;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let s=!r&&t instanceof Gn&&t.index<0?null:t.parent;if(!s)return t;t=s}let i=r?0:Ct.IgnoreOverlays;if(r)for(let s=t,a=s.parent;a;s=a,a=s.parent)s instanceof Gn&&s.index<0&&((o=a.enter(e,n,i))===null||o===void 0?void 0:o.from)!=s.from&&(t=a);for(;;){let s=t.enter(e,n,i);if(!s)return t;t=s}}class kC{cursor(e=0){return new Wh(this,e)}getChild(e,n=null,r=null){let o=SC(this,e,n,r);return o.length?o[0]:null}getChildren(e,n=null,r=null){return SC(this,e,n,r)}resolve(e,n=0){return ga(this,e,n,!1)}resolveInner(e,n=0){return ga(this,e,n,!0)}matchContext(e){return jh(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),r=this;for(;n;){let o=n.lastChild;if(!o||o.to!=n.to)break;o.type.isError&&o.from==o.to?(r=n,n=o.prevSibling):n=o}return r}get node(){return this}get next(){return this.parent}}class Gn extends kC{constructor(e,n,r,o){super(),this._tree=e,this.from=n,this.index=r,this._parent=o}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,r,o,i=0){var s;for(let a=this;;){for(let{children:l,positions:c}=a._tree,u=n>0?l.length:-1;e!=u;e+=n){let d=l[e],f=c[e]+a.from;if(!(!(i&Ct.EnterBracketed&&d instanceof Dt&&((s=ma.get(d))===null||s===void 0?void 0:s.overlay)===null&&(f>=r||f+d.length<=r))&&!CC(o,r,f,f+d.length))){if(d instanceof mo){if(i&Ct.ExcludeBuffers)continue;let p=d.findChild(0,d.buffer.length,n,r-f,o);if(p>-1)return new go(new _2(a,d,e,f),null,p)}else if(i&Ct.IncludeAnonymous||!d.type.isAnonymous||Uh(d)){let p;if(!(i&Ct.IgnoreMounts)&&(p=ma.get(d))&&!p.overlay)return new Gn(p.tree,f,e,a);let m=new Gn(d,f,e,a);return i&Ct.IncludeAnonymous||!m.type.isAnonymous?m:m.nextChild(n<0?d.children.length-1:0,n,r,o,i)}}}if(i&Ct.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+n:e=n<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let o;if(!(r&Ct.IgnoreOverlays)&&(o=ma.get(this._tree))&&o.overlay){let i=e-this.from,s=r&Ct.EnterBracketed&&o.bracketed;for(let{from:a,to:l}of o.overlay)if((n>0||s?a<=i:a<i)&&(n<0||s?l>=i:l>i))return new Gn(o.tree,o.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function SC(t,e,n,r){let o=t.cursor(),i=[];if(!o.firstChild())return i;if(n!=null){for(let s=!1;!s;)if(s=o.type.is(n),!o.nextSibling())return i}for(;;){if(r!=null&&o.type.is(r))return i;if(o.type.is(e)&&i.push(o.node),!o.nextSibling())return r==null?i:[]}}function jh(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class _2{constructor(e,n,r,o){this.parent=e,this.buffer=n,this.index=r,this.start=o}}class go extends kC{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:o}=this.context,i=o.findChild(this.index+4,o.buffer[this.index+3],e,n-this.context.start,r);return i<0?null:new go(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Ct.ExcludeBuffers)return null;let{buffer:o}=this.context,i=o.findChild(this.index+4,o.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return i<0?null:new go(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new go(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new go(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,o=this.index+4,i=r.buffer[this.index+3];if(i>o){let s=r.buffer[this.index+1];e.push(r.slice(o,i,s)),n.push(0)}return new Dt(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function EC(t){if(!t.length)return null;let e=0,n=t[0];for(let i=1;i<t.length;i++){let s=t[i];(s.from>n.from||s.to<n.to)&&(n=s,e=i)}let r=n instanceof Gn&&n.index<0?null:n.parent,o=t.slice();return r?o[e]=r:o.splice(e,1),new A2(o,n)}class A2{constructor(e,n){this.heads=e,this.node=n}get next(){return EC(this.heads)}}function O2(t,e,n){let r=t.resolveInner(e,n),o=null;for(let i=r instanceof Gn?r:r.context.parent;i;i=i.parent)if(i.index<0){let s=i.parent;(o||(o=[r])).push(s.resolve(e,n)),i=s}else{let s=ma.get(i.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let a=new Gn(s.tree,s.overlay[0].from+i.from,-1,i);(o||(o=[r])).push(ga(a,e,n,!1))}}return o?EC(o):r}class Wh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Ct.EnterBracketed,e instanceof Gn)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:o}=this.buffer;return this.type=n||o.set.types[o.buffer[e]],this.from=r+o.buffer[e+1],this.to=r+o.buffer[e+2],!0}yield(e){return e?e instanceof Gn?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:o}=this.buffer,i=o.findChild(this.index+4,o.buffer[this.index+3],e,n-this.buffer.start,r);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&Ct.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Ct.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Ct.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let o=r<0?0:this.stack[r]+4;if(this.index!=o)return this.yieldBuf(n.findChild(o,this.index,-1,0,4))}else{let o=n.buffer[this.index+3];if(o<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(o)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:o}=this;if(o){if(e>0){if(this.index<o.buffer.buffer.length)return!1}else for(let i=0;i<this.index;i++)if(o.buffer.buffer[i+3]<this.index)return!1;({index:n,parent:r}=o)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let i=n+e,s=e<0?-1:r._tree.children.length;i!=s;i+=e){let a=r._tree.children[i];if(this.mode&Ct.IncludeAnonymous||a instanceof mo||!a.type.isAnonymous||Uh(a))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,r=0;if(e&&e.context==this.buffer)e:for(let o=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==o){if(o==this.index)return s;n=s,r=i+1;break e}o=this.stack[--i]}for(let o=r;o<this.stack.length;o++)n=new go(this.buffer,n,this.stack[o]);return this.bufferNode=new go(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let r=0;;){let o=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(o=!0)}for(;;){if(o&&n&&n(this),o=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,o=!0}}}matchContext(e){if(!this.buffer)return jh(this.node.parent,e);let{buffer:n}=this.buffer,{types:r}=n.set;for(let o=e.length-1,i=this.stack.length-1;o>=0;i--){if(i<0)return jh(this._tree,e,o);let s=r[n.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[o]&&e[o]!=s.name)return!1;o--}}return!0}}function Uh(t){return t.children.some(e=>e instanceof mo||!e.type.isAnonymous||Uh(e))}function T2(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:o=vC,reused:i=[],minRepeatType:s=r.types.length}=t,a=Array.isArray(n)?new Vh(n,n.length):n,l=r.types,c=0,u=0;function d(_,S,E,x,O,A){let{id:T,start:B,end:I,size:F}=a,N=u,P=c;if(F<0)if(a.next(),F==-1){let Y=i[T];E.push(Y),x.push(B-_);return}else if(F==-3){c=T;return}else if(F==-4){u=T;return}else throw new RangeError(`Unrecognized record size: ${F}`);let M=l[T],z,H,R=B-_;if(I-B<=o&&(H=b(a.pos-S,O))){let Y=new Uint16Array(H.size-H.skip),te=a.pos-H.size,$=Y.length;for(;a.pos>te;)$=w(H.start,Y,$);z=new mo(Y,I-H.start,r),R=H.start-_}else{let Y=a.pos-F;a.next();let te=[],$=[],j=T>=s?T:-1,U=0,ee=I;for(;a.pos>Y;)j>=0&&a.id==j&&a.size>=0?(a.end<=ee-o&&(m(te,$,B,U,a.end,ee,j,N,P),U=te.length,ee=a.end),a.next()):A>2500?f(B,Y,te,$):d(B,Y,te,$,j,A+1);if(j>=0&&U>0&&U<te.length&&m(te,$,B,U,B,ee,j,N,P),te.reverse(),$.reverse(),j>-1&&U>0){let ie=p(M,P);z=qh(M,te,$,0,te.length,0,I-B,ie,ie)}else z=v(M,te,$,I-B,N-I,P)}E.push(z),x.push(R)}function f(_,S,E,x){let O=[],A=0,T=-1;for(;a.pos>S;){let{id:B,start:I,end:F,size:N}=a;if(N>4)a.next();else{if(T>-1&&I<T)break;T<0&&(T=F-o),O.push(B,I,F),A++,a.next()}}if(A){let B=new Uint16Array(A*4),I=O[O.length-2];for(let F=O.length-3,N=0;F>=0;F-=3)B[N++]=O[F],B[N++]=O[F+1]-I,B[N++]=O[F+2]-I,B[N++]=N;E.push(new mo(B,O[2]-I,r)),x.push(I-_)}}function p(_,S){return(E,x,O)=>{let A=0,T=E.length-1,B,I;if(T>=0&&(B=E[T])instanceof Dt){if(!T&&B.type==_&&B.length==O)return B;(I=B.prop(Je.lookAhead))&&(A=x[T]+B.length+I)}return v(_,E,x,O,A,S)}}function m(_,S,E,x,O,A,T,B,I){let F=[],N=[];for(;_.length>x;)F.push(_.pop()),N.push(S.pop()+E-O);_.push(v(r.types[T],F,N,A-O,B-A,I)),S.push(O-E)}function v(_,S,E,x,O,A,T){if(A){let B=[Je.contextHash,A];T=T?[B].concat(T):[B]}if(O>25){let B=[Je.lookAhead,O];T=T?[B].concat(T):[B]}return new Dt(_,S,E,x,T)}function b(_,S){let E=a.fork(),x=0,O=0,A=0,T=E.end-o,B={size:0,start:0,skip:0};e:for(let I=E.pos-_;E.pos>I;){let F=E.size;if(E.id==S&&F>=0){B.size=x,B.start=O,B.skip=A,A+=4,x+=4,E.next();continue}let N=E.pos-F;if(F<0||N<I||E.start<T)break;let P=E.id>=s?4:0,M=E.start;for(E.next();E.pos>N;){if(E.size<0)if(E.size==-3||E.size==-4)P+=4;else break e;else E.id>=s&&(P+=4);E.next()}O=M,x+=F,A+=P}return(S<0||x==_)&&(B.size=x,B.start=O,B.skip=A),B.size>4?B:void 0}function w(_,S,E){let{id:x,start:O,end:A,size:T}=a;if(a.next(),T>=0&&x<s){let B=E;if(T>4){let I=a.pos-(T-4);for(;a.pos>I;)E=w(_,S,E)}S[--E]=B,S[--E]=A-_,S[--E]=O-_,S[--E]=x}else T==-3?c=x:T==-4&&(u=x);return E}let g=[],C=[];for(;a.pos>0;)d(t.start||0,t.bufferStart||0,g,C,-1,0);let k=(e=t.length)!==null&&e!==void 0?e:g.length?C[0]+g[0].length:0;return new Dt(l[t.topID],g.reverse(),C.reverse(),k)}const xC=new WeakMap;function zc(t,e){if(!t.isAnonymous||e instanceof mo||e.type!=t)return 1;let n=xC.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof Dt)){n=1;break}n+=zc(t,r)}xC.set(e,n)}return n}function qh(t,e,n,r,o,i,s,a,l){let c=0;for(let m=r;m<o;m++)c+=zc(t,e[m]);let u=Math.ceil(c*1.5/8),d=[],f=[];function p(m,v,b,w,g){for(let C=b;C<w;){let k=C,_=v[C],S=zc(t,m[C]);for(C++;C<w;C++){let E=zc(t,m[C]);if(S+E>=u)break;S+=E}if(C==k+1){if(S>u){let E=m[k];p(E.children,E.positions,0,E.children.length,v[k]+g);continue}d.push(m[k])}else{let E=v[C-1]+m[C-1].length-_;d.push(qh(t,m,v,k,C,_,E,null,l))}f.push(_+g-i)}}return p(e,n,r,o,0),(a||l)(d,f,s)}class ni{constructor(e,n,r,o,i=!1,s=!1){this.from=e,this.to=n,this.tree=r,this.offset=o,this.open=(i?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let o=[new ni(0,e.length,e,0,!1,r)];for(let i of n)i.to>e.length&&o.push(i);return o}static applyChanges(e,n,r=128){if(!n.length)return e;let o=[],i=1,s=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<n.length?n[a]:null,d=u?u.fromA:1e9;if(d-l>=r)for(;s&&s.from<d;){let f=s;if(l>=f.from||d<=f.to||c){let p=Math.max(f.from,l)-c,m=Math.min(f.to,d)-c;f=p>=m?null:new ni(p,m,f.tree,f.offset+c,a>0,!!u)}if(f&&o.push(f),s.to>d)break;s=i<e.length?e[i++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return o}}class DC{startParse(e,n,r){return typeof e=="string"&&(e=new N2(e)),r=r?r.length?r.map(o=>new zh(o.from,o.to)):[new zh(0,0)]:[new zh(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let o=this.startParse(e,n,r);for(;;){let i=o.advance();if(i)return i}}}class N2{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Je({perNode:!0});let B2=0;class Rn{constructor(e,n,r,o){this.name=e,this.set=n,this.base=r,this.modified=o,this.id=B2++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof Rn&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let o=new Rn(r,[],null,[]);if(o.set.push(o),n)for(let i of n.set)o.set.push(i);return o}static defineModifier(e){let n=new Hc(e);return r=>r.modified.indexOf(n)>-1?r:Hc.get(r.base||r,r.modified.concat(n).sort((o,i)=>o.id-i.id))}}let F2=0;class Hc{constructor(e){this.name=e,this.instances=[],this.id=F2++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(a=>a.base==e&&M2(n,a.modified));if(r)return r;let o=[],i=new Rn(e.name,o,e,n);for(let a of n)a.instances.push(i);let s=I2(n);for(let a of e.set)if(!a.modified.length)for(let l of s)o.push(Hc.get(a,l));return i}}function M2(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function I2(t){let e=[[]];for(let n=0;n<t.length;n++)for(let r=0,o=e.length;r<o;r++)e.push(e[r].concat(t[n]));return e.sort((n,r)=>r.length-n.length)}function _C(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let o of n.split(" "))if(o){let i=[],s=2,a=o;for(let d=0;;){if(a=="..."&&d>0&&d+3==o.length){s=1;break}let f=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!f)throw new RangeError("Invalid path: "+o);if(i.push(f[0]=="*"?"":f[0][0]=='"'?JSON.parse(f[0]):f[0]),d+=f[0].length,d==o.length)break;let p=o[d++];if(d==o.length&&p=="!"){s=0;break}if(p!="/")throw new RangeError("Invalid path: "+o);a=o.slice(d)}let l=i.length-1,c=i[l];if(!c)throw new RangeError("Invalid path: "+o);let u=new wa(r,s,l>0?i.slice(0,l):null);e[c]=u.sort(e[c])}}return AC.add(e)}const AC=new Je({combine(t,e){let n,r,o;for(;t||e;){if(!t||e&&t.depth>=e.depth?(o=e,e=e.next):(o=t,t=t.next),n&&n.mode==o.mode&&!o.context&&!n.context)continue;let i=new wa(o.tags,o.mode,o.context);n?n.next=i:r=i,n=i}return r}});class wa{constructor(e,n,r,o){this.tags=e,this.mode=n,this.context=r,this.next=o}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}wa.empty=new wa([],2,null);function OC(t,e){let n=Object.create(null);for(let i of t)if(!Array.isArray(i.tag))n[i.tag.id]=i.class;else for(let s of i.tag)n[s.id]=i.class;let{scope:r,all:o=null}=e||{};return{style:i=>{let s=o;for(let a of i)for(let l of a.set){let c=n[l.id];if(c){s=s?s+" "+c:c;break}}return s},scope:r}}function P2(t,e){let n=null;for(let r of t){let o=r.style(e);o&&(n=n?n+" "+o:o)}return n}function L2(t,e,n,r=0,o=t.length){let i=new $2(r,Array.isArray(e)?e:[e],n);i.highlightRange(t.cursor(),r,o,"",i.highlighters),i.flush(o)}class $2{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,o,i){let{type:s,from:a,to:l}=e;if(a>=r||l<=n)return;s.isTop&&(i=this.highlighters.filter(p=>!p.scope||p.scope(s)));let c=o,u=z2(e)||wa.empty,d=P2(i,u.tags);if(d&&(c&&(c+=" "),c+=d,u.mode==1&&(o+=(o?" ":"")+d)),this.startSpan(Math.max(n,a),c),u.opaque)return;let f=e.tree&&e.tree.prop(Je.mounted);if(f&&f.overlay){let p=e.node.enter(f.overlay[0].from+a,1),m=this.highlighters.filter(b=>!b.scope||b.scope(f.tree.type)),v=e.firstChild();for(let b=0,w=a;;b++){let g=b<f.overlay.length?f.overlay[b]:null,C=g?g.from+a:l,k=Math.max(n,w),_=Math.min(r,C);if(k<_&&v)for(;e.from<_&&(this.highlightRange(e,k,_,o,i),this.startSpan(Math.min(_,e.to),c),!(e.to>=C||!e.nextSibling())););if(!g||C>r)break;w=g.to+a,w>n&&(this.highlightRange(p.cursor(),Math.max(n,g.from+a),Math.min(r,w),"",m),this.startSpan(Math.min(r,w),c))}v&&e.parent()}else if(e.firstChild()){f&&(o="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,o,i),this.startSpan(Math.min(r,e.to),c)}while(e.nextSibling());e.parent()}}}function z2(t){let e=t.type.prop(AC);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const _e=Rn.define,Vc=_e(),wo=_e(),TC=_e(wo),NC=_e(wo),bo=_e(),jc=_e(bo),Gh=_e(bo),Er=_e(),ri=_e(Er),xr=_e(),Dr=_e(),Rh=_e(),ba=_e(Rh),Wc=_e(),V={comment:Vc,lineComment:_e(Vc),blockComment:_e(Vc),docComment:_e(Vc),name:wo,variableName:_e(wo),typeName:TC,tagName:_e(TC),propertyName:NC,attributeName:_e(NC),className:_e(wo),labelName:_e(wo),namespace:_e(wo),macroName:_e(wo),literal:bo,string:jc,docString:_e(jc),character:_e(jc),attributeValue:_e(jc),number:Gh,integer:_e(Gh),float:_e(Gh),bool:_e(bo),regexp:_e(bo),escape:_e(bo),color:_e(bo),url:_e(bo),keyword:xr,self:_e(xr),null:_e(xr),atom:_e(xr),unit:_e(xr),modifier:_e(xr),operatorKeyword:_e(xr),controlKeyword:_e(xr),definitionKeyword:_e(xr),moduleKeyword:_e(xr),operator:Dr,derefOperator:_e(Dr),arithmeticOperator:_e(Dr),logicOperator:_e(Dr),bitwiseOperator:_e(Dr),compareOperator:_e(Dr),updateOperator:_e(Dr),definitionOperator:_e(Dr),typeOperator:_e(Dr),controlOperator:_e(Dr),punctuation:Rh,separator:_e(Rh),bracket:ba,angleBracket:_e(ba),squareBracket:_e(ba),paren:_e(ba),brace:_e(ba),content:Er,heading:ri,heading1:_e(ri),heading2:_e(ri),heading3:_e(ri),heading4:_e(ri),heading5:_e(ri),heading6:_e(ri),contentSeparator:_e(Er),list:_e(Er),quote:_e(Er),emphasis:_e(Er),strong:_e(Er),link:_e(Er),monospace:_e(Er),strikethrough:_e(Er),inserted:_e(),deleted:_e(),changed:_e(),invalid:_e(),meta:Wc,documentMeta:_e(Wc),annotation:_e(Wc),processingInstruction:_e(Wc),definition:Rn.defineModifier("definition"),constant:Rn.defineModifier("constant"),function:Rn.defineModifier("function"),standard:Rn.defineModifier("standard"),local:Rn.defineModifier("local"),special:Rn.defineModifier("special")};for(let t in V){let e=V[t];e instanceof Rn&&(e.name=t)}OC([{tag:V.link,class:"tok-link"},{tag:V.heading,class:"tok-heading"},{tag:V.emphasis,class:"tok-emphasis"},{tag:V.strong,class:"tok-strong"},{tag:V.keyword,class:"tok-keyword"},{tag:V.atom,class:"tok-atom"},{tag:V.bool,class:"tok-bool"},{tag:V.url,class:"tok-url"},{tag:V.labelName,class:"tok-labelName"},{tag:V.inserted,class:"tok-inserted"},{tag:V.deleted,class:"tok-deleted"},{tag:V.literal,class:"tok-literal"},{tag:V.string,class:"tok-string"},{tag:V.number,class:"tok-number"},{tag:[V.regexp,V.escape,V.special(V.string)],class:"tok-string2"},{tag:V.variableName,class:"tok-variableName"},{tag:V.local(V.variableName),class:"tok-variableName tok-local"},{tag:V.definition(V.variableName),class:"tok-variableName tok-definition"},{tag:V.special(V.variableName),class:"tok-variableName2"},{tag:V.definition(V.propertyName),class:"tok-propertyName tok-definition"},{tag:V.typeName,class:"tok-typeName"},{tag:V.namespace,class:"tok-namespace"},{tag:V.className,class:"tok-className"},{tag:V.macroName,class:"tok-macroName"},{tag:V.propertyName,class:"tok-propertyName"},{tag:V.operator,class:"tok-operator"},{tag:V.comment,class:"tok-comment"},{tag:V.meta,class:"tok-meta"},{tag:V.invalid,class:"tok-invalid"},{tag:V.punctuation,class:"tok-punctuation"}]);let Kh=[],BC=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?BC:Kh).push(n=n+t[e])})();function H2(t){if(t<768)return!1;for(let e=0,n=Kh.length;;){let r=e+n>>1;if(t<Kh[r])n=r;else if(t>=BC[r])e=r+1;else return!0;if(e==n)return!1}}function FC(t){return t>=127462&&t<=127487}const MC=8205;function V2(t,e,n=!0,r=!0){return(n?IC:j2)(t,e,r)}function IC(t,e,n){if(e==t.length)return e;e&&PC(t.charCodeAt(e))&&LC(t.charCodeAt(e-1))&&e--;let r=Yh(t,e);for(e+=$C(r);e<t.length;){let o=Yh(t,e);if(r==MC||o==MC||n&&H2(o))e+=$C(o),r=o;else if(FC(o)){let i=0,s=e-2;for(;s>=0&&FC(Yh(t,s));)i++,s-=2;if(i%2==0)break;e+=2}else break}return e}function j2(t,e,n){for(;e>0;){let r=IC(t,e-2,n);if(r<e)return r;e--}return 0}function Yh(t,e){let n=t.charCodeAt(e);if(!LC(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return PC(r)?(n-55296<<10)+(r-56320)+65536:n}function PC(t){return t>=56320&&t<57344}function LC(t){return t>=55296&&t<56320}function $C(t){return t<65536?1:2}let st=class UB{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Ki(this,e,n);let o=[];return this.decompose(0,e,o,2),r.length&&r.decompose(0,r.length,o,3),this.decompose(n,this.length,o,1),_r.from(o,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Ki(this,e,n);let r=[];return this.decompose(e,n,r,0),_r.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),o=new va(this),i=new va(e);for(let s=n,a=n;;){if(o.next(s),i.next(s),s=0,o.lineBreak!=i.lineBreak||o.done!=i.done||o.value!=i.value)return!1;if(a+=o.value.length,o.done||a>=r)return!0}}iter(e=1){return new va(this,e)}iterRange(e,n=this.length){return new HC(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let o=this.line(e).from;r=this.iterRange(o,Math.max(o,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new VC(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?UB.empty:e.length<=32?new _t(e):_r.from(_t.split(e,[]))}};class _t extends st{constructor(e,n=W2(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,o){for(let i=0;;i++){let s=this.text[i],a=o+s.length;if((n?r:a)>=e)return new U2(o,a,r,s);o=a+1,r++}}decompose(e,n,r,o){let i=e<=0&&n>=this.length?this:new _t(zC(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(o&1){let s=r.pop(),a=Uc(i.text,s.text.slice(),0,i.length);if(a.length<=32)r.push(new _t(a,s.length+i.length));else{let l=a.length>>1;r.push(new _t(a.slice(0,l)),new _t(a.slice(l)))}}else r.push(i)}replace(e,n,r){if(!(r instanceof _t))return super.replace(e,n,r);[e,n]=Ki(this,e,n);let o=Uc(this.text,Uc(r.text,zC(this.text,0,e)),n),i=this.length+r.length-(n-e);return o.length<=32?new _t(o,i):_r.from(_t.split(o,[]),i)}sliceString(e,n=this.length,r=`
|
|
14
14
|
`){[e,n]=Ki(this,e,n);let o="";for(let i=0,s=0;i<=n&&s<this.text.length;s++){let a=this.text[s],l=i+a.length;i>e&&s&&(o+=r),e<l&&n>i&&(o+=a.slice(Math.max(0,e-i),n-i)),i=l+1}return o}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],o=-1;for(let i of e)r.push(i),o+=i.length+1,r.length==32&&(n.push(new _t(r,o)),r=[],o=-1);return o>-1&&n.push(new _t(r,o)),n}}class _r extends st{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,o){for(let i=0;;i++){let s=this.children[i],a=o+s.length,l=r+s.lines-1;if((n?l:a)>=e)return s.lineInner(e,n,r,o);o=a+1,r=l+1}}decompose(e,n,r,o){for(let i=0,s=0;s<=n&&i<this.children.length;i++){let a=this.children[i],l=s+a.length;if(e<=l&&n>=s){let c=o&((s<=e?1:0)|(l>=n?2:0));s>=e&&l<=n&&!c?r.push(a):a.decompose(e-s,n-s,r,c)}s=l+1}}replace(e,n,r){if([e,n]=Ki(this,e,n),r.lines<this.lines)for(let o=0,i=0;o<this.children.length;o++){let s=this.children[o],a=i+s.length;if(e>=i&&n<=a){let l=s.replace(e-i,n-i,r),c=this.lines-s.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let u=this.children.slice();return u[o]=l,new _r(u,this.length-(n-e)+r.length)}return super.replace(i,a,l)}i=a+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=`
|
|
15
15
|
`){[e,n]=Ki(this,e,n);let o="";for(let i=0,s=0;i<this.children.length&&s<=n;i++){let a=this.children[i],l=s+a.length;s>e&&i&&(o+=r),e<l&&n>s&&(o+=a.sliceString(e-s,n-s,r)),s=l+1}return o}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof _r))return 0;let r=0,[o,i,s,a]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;o+=n,i+=n){if(o==s||i==a)return r;let l=this.children[o],c=e.children[i];if(l!=c)return r+l.scanIdentical(c,n);r+=l.length+1}}static from(e,n=e.reduce((r,o)=>r+o.length+1,-1)){let r=0;for(let p of e)r+=p.lines;if(r<32){let p=[];for(let m of e)m.flatten(p);return new _t(p,n)}let o=Math.max(32,r>>5),i=o<<1,s=o>>1,a=[],l=0,c=-1,u=[];function d(p){let m;if(p.lines>i&&p instanceof _r)for(let v of p.children)d(v);else p.lines>s&&(l>s||!l)?(f(),a.push(p)):p instanceof _t&&l&&(m=u[u.length-1])instanceof _t&&p.lines+m.lines<=32?(l+=p.lines,c+=p.length+1,u[u.length-1]=new _t(m.text.concat(p.text),m.length+1+p.length)):(l+p.lines>o&&f(),l+=p.lines,c+=p.length+1,u.push(p))}function f(){l!=0&&(a.push(u.length==1?u[0]:_r.from(u,c)),c=-1,l=u.length=0)}for(let p of e)d(p);return f(),a.length==1?a[0]:new _r(a,n)}}st.empty=new _t([""],0);function W2(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Uc(t,e,n=0,r=1e9){for(let o=0,i=0,s=!0;i<t.length&&o<=r;i++){let a=t[i],l=o+a.length;l>=n&&(l>r&&(a=a.slice(0,r-o)),o<n&&(a=a.slice(n-o)),s?(e[e.length-1]+=a,s=!1):e.push(a)),o=l+1}return e}function zC(t,e,n){return Uc(t,[""],e,n)}class va{constructor(e,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[n>0?1:(e instanceof _t?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,o=this.nodes[r],i=this.offsets[r],s=i>>1,a=o instanceof _t?o.text.length:o.children.length;if(s==(n>0?a:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=`
|
|
16
16
|
`,this;e--}else if(o instanceof _t){let l=o.text[s+(n<0?-1:0)];if(this.offsets[r]+=n,l.length>Math.max(0,e))return this.value=e==0?l:n>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=o.children[s+(n<0?-1:0)];e>l.length?(e-=l.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(l),this.offsets.push(n>0?1:(l instanceof _t?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class HC{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new va(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:o}=this.cursor.next(e);return this.pos+=(o.length+e)*n,this.value=o.length<=r?o:n<0?o.slice(o.length-r):o.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class VC{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:o}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=o,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(st.prototype[Symbol.iterator]=function(){return this.iter()},va.prototype[Symbol.iterator]=HC.prototype[Symbol.iterator]=VC.prototype[Symbol.iterator]=function(){return this});class U2{constructor(e,n,r,o){this.from=e,this.to=n,this.number=r,this.text=o}get length(){return this.to-this.from}}function Ki(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function zt(t,e,n=!0,r=!0){return V2(t,e,n,r)}function q2(t){return t>=56320&&t<57344}function G2(t){return t>=55296&&t<56320}function kn(t,e){let n=t.charCodeAt(e);if(!G2(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return q2(r)?(n-55296<<10)+(r-56320)+65536:n}function Xh(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function Ar(t){return t<65536?1:2}const Jh=/\r\n?|\n/;var Yt=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Yt||(Yt={}));class Or{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;n<this.sections.length;n+=2)e+=this.sections[n];return e}get newLength(){let e=0;for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n+1];e+=r<0?this.sections[n]:r}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let n=0,r=0,o=0;n<this.sections.length;){let i=this.sections[n++],s=this.sections[n++];s<0?(e(r,o,i),o+=i):o+=s,r+=i}}iterChangedRanges(e,n=!1){Qh(this,e,n)}get invertedDesc(){let e=[];for(let n=0;n<this.sections.length;){let r=this.sections[n++],o=this.sections[n++];o<0?e.push(r,o):e.push(o,r)}return new Or(e)}composeDesc(e){return this.empty?e:e.empty?this:jC(this,e)}mapDesc(e,n=!1){return e.empty?this:Zh(this,e,n)}mapPos(e,n=-1,r=Yt.Simple){let o=0,i=0;for(let s=0;s<this.sections.length;){let a=this.sections[s++],l=this.sections[s++],c=o+a;if(l<0){if(c>e)return i+(e-o);i+=a}else{if(r!=Yt.Simple&&c>=e&&(r==Yt.TrackDel&&o<e&&c>e||r==Yt.TrackBefore&&o<e||r==Yt.TrackAfter&&c>e))return null;if(c>e||c==e&&n<0&&!a)return e==o||n<0?i:i+l;i+=l}o=c}if(e>o)throw new RangeError(`Position ${e} is out of range for changeset of length ${o}`);return i}touchesRange(e,n=e){for(let r=0,o=0;r<this.sections.length&&o<=n;){let i=this.sections[r++],s=this.sections[r++],a=o+i;if(s>=0&&o<=n&&a>=e)return o<e&&a>n?"cover":!0;o=a}return!1}toString(){let e="";for(let n=0;n<this.sections.length;){let r=this.sections[n++],o=this.sections[n++];e+=(e?" ":"")+r+(o>=0?":"+o:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Or(e)}static create(e){return new Or(e)}}class Ht extends Or{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Qh(this,(n,r,o,i,s)=>e=e.replace(o,o+(r-n),s),!1),e}mapDesc(e,n=!1){return Zh(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let o=0,i=0;o<n.length;o+=2){let s=n[o],a=n[o+1];if(a>=0){n[o]=a,n[o+1]=s;let l=o>>1;for(;r.length<l;)r.push(st.empty);r.push(s?e.slice(i,i+s):st.empty)}i+=s}return new Ht(n,r)}compose(e){return this.empty?e:e.empty?this:jC(this,e,!0)}map(e,n=!1){return e.empty?this:Zh(this,e,n,!0)}iterChanges(e,n=!1){Qh(this,e,n)}get desc(){return Or.create(this.sections)}filter(e){let n=[],r=[],o=[],i=new ya(this);e:for(let s=0,a=0;;){let l=s==e.length?1e9:e[s++];for(;a<l||a==l&&i.len==0;){if(i.done)break e;let u=Math.min(i.len,l-a);rn(o,u,-1);let d=i.ins==-1?-1:i.off==0?i.ins:0;rn(n,u,d),d>0&&vo(r,n,i.text),i.forward(u),a+=u}let c=e[s++];for(;a<c;){if(i.done)break e;let u=Math.min(i.len,c-a);rn(n,u,-1),rn(o,u,i.ins==-1?-1:i.off==0?i.ins:0),i.forward(u),a+=u}}return{changes:new Ht(n,r),filtered:Or.create(o)}}toJSON(){let e=[];for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n],o=this.sections[n+1];o<0?e.push(r):o==0?e.push([r]):e.push([r].concat(this.inserted[n>>1].toJSON()))}return e}static of(e,n,r){let o=[],i=[],s=0,a=null;function l(u=!1){if(!u&&!o.length)return;s<n&&rn(o,n-s,-1);let d=new Ht(o,i);a=a?a.compose(d.map(a)):d,o=[],i=[],s=0}function c(u){if(Array.isArray(u))for(let d of u)c(d);else if(u instanceof Ht){if(u.length!=n)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${n})`);l(),a=a?a.compose(u.map(a)):u}else{let{from:d,to:f=d,insert:p}=u;if(d>f||d<0||f>n)throw new RangeError(`Invalid change range ${d} to ${f} (in doc of length ${n})`);let m=p?typeof p=="string"?st.of(p.split(r||Jh)):p:st.empty,v=m.length;if(d==f&&v==0)return;d<s&&l(),d>s&&rn(o,d-s,-1),rn(o,f-d,v),vo(i,o,m),s=f}}return c(e),l(!a),a}static empty(e){return new Ht(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let o=0;o<e.length;o++){let i=e[o];if(typeof i=="number")n.push(i,-1);else{if(!Array.isArray(i)||typeof i[0]!="number"||i.some((s,a)=>a&&typeof s!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(i.length==1)n.push(i[0],0);else{for(;r.length<o;)r.push(st.empty);r[o]=st.of(i.slice(1)),n.push(i[0],r[o].length)}}}return new Ht(n,r)}static createSet(e,n){return new Ht(e,n)}}function rn(t,e,n,r=!1){if(e==0&&n<=0)return;let o=t.length-2;o>=0&&n<=0&&n==t[o+1]?t[o]+=e:o>=0&&e==0&&t[o]==0?t[o+1]+=n:r?(t[o]+=e,t[o+1]+=n):t.push(e,n)}function vo(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<r;)t.push(st.empty);t.push(n)}}function Qh(t,e,n){let r=t.inserted;for(let o=0,i=0,s=0;s<t.sections.length;){let a=t.sections[s++],l=t.sections[s++];if(l<0)o+=a,i+=a;else{let c=o,u=i,d=st.empty;for(;c+=a,u+=l,l&&r&&(d=d.append(r[s-2>>1])),!(n||s==t.sections.length||t.sections[s+1]<0);)a=t.sections[s++],l=t.sections[s++];e(o,c,i,u,d),o=c,i=u}}}function Zh(t,e,n,r=!1){let o=[],i=r?[]:null,s=new ya(t),a=new ya(e);for(let l=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(s.ins==-1&&a.ins==-1){let c=Math.min(s.len,a.len);rn(o,c,-1),s.forward(c),a.forward(c)}else if(a.ins>=0&&(s.ins<0||l==s.i||s.off==0&&(a.len<s.len||a.len==s.len&&!n))){let c=a.len;for(rn(o,a.ins,-1);c;){let u=Math.min(s.len,c);s.ins>=0&&l<s.i&&s.len<=u&&(rn(o,0,s.ins),i&&vo(i,o,s.text),l=s.i),s.forward(u),c-=u}a.next()}else if(s.ins>=0){let c=0,u=s.len;for(;u;)if(a.ins==-1){let d=Math.min(u,a.len);c+=d,u-=d,a.forward(d)}else if(a.ins==0&&a.len<u)u-=a.len,a.next();else break;rn(o,c,l<s.i?s.ins:0),i&&l<s.i&&vo(i,o,s.text),l=s.i,s.forward(s.len-u)}else{if(s.done&&a.done)return i?Ht.createSet(o,i):Or.create(o);throw new Error("Mismatched change set lengths")}}}function jC(t,e,n=!1){let r=[],o=n?[]:null,i=new ya(t),s=new ya(e);for(let a=!1;;){if(i.done&&s.done)return o?Ht.createSet(r,o):Or.create(r);if(i.ins==0)rn(r,i.len,0,a),i.next();else if(s.len==0&&!s.done)rn(r,0,s.ins,a),o&&vo(o,r,s.text),s.next();else{if(i.done||s.done)throw new Error("Mismatched change set lengths");{let l=Math.min(i.len2,s.len),c=r.length;if(i.ins==-1){let u=s.ins==-1?-1:s.off?0:s.ins;rn(r,l,u,a),o&&u&&vo(o,r,s.text)}else s.ins==-1?(rn(r,i.off?0:i.len,l,a),o&&vo(o,r,i.textBit(l))):(rn(r,i.off?0:i.len,s.off?0:s.ins,a),o&&!s.off&&vo(o,r,s.text));a=(i.ins>l||s.ins>=0&&s.len>l)&&(a||r.length>c),i.forward2(l),s.forward(l)}}}}class ya{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length?st.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?st.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class oi{constructor(e,n,r){this.from=e,this.to=n,this.flags=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,n=-1){let r,o;return this.empty?r=o=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),o=e.mapPos(this.to,-1)),r==this.from&&o==this.to?this:new oi(r,o,this.flags)}extend(e,n=e){if(e<=this.anchor&&n>=this.anchor)return ae.range(e,n);let r=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ae.range(this.anchor,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ae.range(e.anchor,e.head)}static create(e,n,r){return new oi(e,n,r)}}class ae{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ae.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;r<this.ranges.length;r++)if(!this.ranges[r].eq(e.ranges[r],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new ae([this.main],0)}addRange(e,n=!0){return ae.create([e].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(e,n=this.mainIndex){let r=this.ranges.slice();return r[n]=e,ae.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ae(e.ranges.map(n=>oi.fromJSON(n)),e.main)}static single(e,n=e){return new ae([ae.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,o=0;o<e.length;o++){let i=e[o];if(i.empty?i.from<=r:i.from<r)return ae.normalized(e.slice(),n);r=i.to}return new ae(e,n)}static cursor(e,n=0,r,o){return oi.create(e,e,(n==0?0:n<0?8:16)|(r==null?7:Math.min(6,r))|(o??16777215)<<6)}static range(e,n,r,o){let i=(r??16777215)<<6|(o==null?7:Math.min(6,o));return n<e?oi.create(n,e,48|i):oi.create(e,n,(n>e?8:0)|i)}static normalized(e,n=0){let r=e[n];e.sort((o,i)=>o.from-i.from),n=e.indexOf(r);for(let o=1;o<e.length;o++){let i=e[o],s=e[o-1];if(i.empty?i.from<=s.to:i.from<s.to){let a=s.from,l=Math.max(i.to,s.to);o<=n&&n--,e.splice(--o,2,i.anchor>i.head?ae.range(l,a):ae.range(a,l))}}return new ae(e,n)}}function WC(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let ep=0;class Ne{constructor(e,n,r,o,i){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=o,this.id=ep++,this.default=e([]),this.extensions=typeof i=="function"?i(this):i}get reader(){return this}static define(e={}){return new Ne(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:tp),!!e.static,e.enables)}of(e){return new qc([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new qc(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new qc(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function tp(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class qc{constructor(e,n,r,o){this.dependencies=e,this.facet=n,this.type=r,this.value=o,this.id=ep++}dynamicSlot(e){var n;let r=this.value,o=this.facet.compareInput,i=this.id,s=e[i]>>1,a=this.type==2,l=!1,c=!1,u=[];for(let d of this.dependencies)d=="doc"?l=!0:d=="selection"?c=!0:(((n=e[d.id])!==null&&n!==void 0?n:1)&1)==0&&u.push(e[d.id]);return{create(d){return d.values[s]=r(d),1},update(d,f){if(l&&f.docChanged||c&&(f.docChanged||f.selection)||np(d,u)){let p=r(d);if(a?!UC(p,d.values[s],o):!o(p,d.values[s]))return d.values[s]=p,1}return 0},reconfigure:(d,f)=>{let p,m=f.config.address[i];if(m!=null){let v=Yc(f,m);if(this.dependencies.every(b=>b instanceof Ne?f.facet(b)===d.facet(b):b instanceof qt?f.field(b,!1)==d.field(b,!1):!0)||(a?UC(p=r(d),v,o):o(p=r(d),v)))return d.values[s]=v,0}else p=r(d);return d.values[s]=p,1}}}}function UC(t,e,n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!n(t[r],e[r]))return!1;return!0}function np(t,e){let n=!1;for(let r of e)ka(t,r)&1&&(n=!0);return n}function R2(t,e,n){let r=n.map(l=>t[l.id]),o=n.map(l=>l.type),i=r.filter(l=>!(l&1)),s=t[e.id]>>1;function a(l){let c=[];for(let u=0;u<r.length;u++){let d=Yc(l,r[u]);if(o[u]==2)for(let f of d)c.push(f);else c.push(d)}return e.combine(c)}return{create(l){for(let c of r)ka(l,c);return l.values[s]=a(l),1},update(l,c){if(!np(l,i))return 0;let u=a(l);return e.compare(u,l.values[s])?0:(l.values[s]=u,1)},reconfigure(l,c){let u=np(l,r),d=c.config.facets[e.id],f=c.facet(e);if(d&&!u&&tp(n,d))return l.values[s]=f,0;let p=a(l);return e.compare(p,f)?(l.values[s]=f,0):(l.values[s]=p,1)}}}const Gc=Ne.define({static:!0});class qt{constructor(e,n,r,o,i){this.id=e,this.createF=n,this.updateF=r,this.compareF=o,this.spec=i,this.provides=void 0}static define(e){let n=new qt(ep++,e.create,e.update,e.compare||((r,o)=>r===o),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Gc).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,o)=>{let i=r.values[n],s=this.updateF(i,o);return this.compareF(i,s)?0:(r.values[n]=s,1)},reconfigure:(r,o)=>{let i=r.facet(Gc),s=o.facet(Gc),a;return(a=i.find(l=>l.field==this))&&a!=s.find(l=>l.field==this)?(r.values[n]=a.create(r),1):o.config.address[this.id]!=null?(r.values[n]=o.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Gc.of({field:this,create:e})]}get extension(){return this}}const ii={lowest:4,low:3,default:2,high:1,highest:0};function Ca(t){return e=>new qC(e,t)}const yo={highest:Ca(ii.highest),high:Ca(ii.high),default:Ca(ii.default),low:Ca(ii.low),lowest:Ca(ii.lowest)};class qC{constructor(e,n){this.inner=e,this.prec=n}}class Rc{of(e){return new rp(this,e)}reconfigure(e){return Rc.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class rp{constructor(e,n){this.compartment=e,this.inner=n}}class Kc{constructor(e,n,r,o,i,s){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=o,this.staticValues=i,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(e){let n=this.address[e.id];return n==null?e.default:this.staticValues[n>>1]}static resolve(e,n,r){let o=[],i=Object.create(null),s=new Map;for(let f of K2(e,n,s))f instanceof qt?o.push(f):(i[f.facet.id]||(i[f.facet.id]=[])).push(f);let a=Object.create(null),l=[],c=[];for(let f of o)a[f.id]=c.length<<1,c.push(p=>f.slot(p));let u=r==null?void 0:r.config.facets;for(let f in i){let p=i[f],m=p[0].facet,v=u&&u[f]||[];if(p.every(b=>b.type==0))if(a[m.id]=l.length<<1|1,tp(v,p))l.push(r.facet(m));else{let b=m.combine(p.map(w=>w.value));l.push(r&&m.compare(b,r.facet(m))?r.facet(m):b)}else{for(let b of p)b.type==0?(a[b.id]=l.length<<1|1,l.push(b.value)):(a[b.id]=c.length<<1,c.push(w=>b.dynamicSlot(w)));a[m.id]=c.length<<1,c.push(b=>R2(b,m,p))}}let d=c.map(f=>f(a));return new Kc(e,s,d,a,l,i)}}function K2(t,e,n){let r=[[],[],[],[],[]],o=new Map;function i(s,a){let l=o.get(s);if(l!=null){if(l<=a)return;let c=r[l].indexOf(s);c>-1&&r[l].splice(c,1),s instanceof rp&&n.delete(s.compartment)}if(o.set(s,a),Array.isArray(s))for(let c of s)i(c,a);else if(s instanceof rp){if(n.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(s.compartment)||s.inner;n.set(s.compartment,c),i(c,a)}else if(s instanceof qC)i(s.inner,s.prec);else if(s instanceof qt)r[a].push(s),s.provides&&i(s.provides,a);else if(s instanceof qc)r[a].push(s),s.facet.extensions&&i(s.facet.extensions,ii.default);else{let c=s.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);i(c,a)}}return i(t,ii.default),r.reduce((s,a)=>s.concat(a))}function ka(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let o=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|o}function Yc(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const GC=Ne.define(),op=Ne.define({combine:t=>t.some(e=>e),static:!0}),RC=Ne.define({combine:t=>t.length?t[0]:void 0,static:!0}),KC=Ne.define(),YC=Ne.define(),XC=Ne.define(),JC=Ne.define({combine:t=>t.length?t[0]:!1});class Tr{constructor(e,n){this.type=e,this.value=n}static define(){return new Y2}}class Y2{of(e){return new Tr(this,e)}}class X2{constructor(e){this.map=e}of(e){return new qe(this,e)}}class qe{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new qe(this.type,n)}is(e){return this.type==e}static define(e={}){return new X2(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let o of e){let i=o.map(n);i&&r.push(i)}return r}}qe.reconfigure=qe.define(),qe.appendConfig=qe.define();class Nt{constructor(e,n,r,o,i,s){this.startState=e,this.changes=n,this.selection=r,this.effects=o,this.annotations=i,this.scrollIntoView=s,this._doc=null,this._state=null,r&&WC(r,n.newLength),i.some(a=>a.type==Nt.time)||(this.annotations=i.concat(Nt.time.of(Date.now())))}static create(e,n,r,o,i,s){return new Nt(e,n,r,o,i,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(Nt.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Nt.time=Tr.define(),Nt.userEvent=Tr.define(),Nt.addToHistory=Tr.define(),Nt.remote=Tr.define();function J2(t,e){let n=[];for(let r=0,o=0;;){let i,s;if(r<t.length&&(o==e.length||e[o]>=t[r]))i=t[r++],s=t[r++];else if(o<e.length)i=e[o++],s=e[o++];else return n;!n.length||n[n.length-1]<i?n.push(i,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function QC(t,e,n){var r;let o,i,s;return n?(o=e.changes,i=Ht.empty(e.changes.length),s=t.changes.compose(e.changes)):(o=e.changes.map(t.changes),i=t.changes.mapDesc(e.changes,!0),s=t.changes.compose(o)),{changes:s,selection:e.selection?e.selection.map(i):(r=t.selection)===null||r===void 0?void 0:r.map(o),effects:qe.mapEffects(t.effects,o).concat(qe.mapEffects(e.effects,i)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function ip(t,e,n){let r=e.selection,o=Yi(e.annotations);return e.userEvent&&(o=o.concat(Nt.userEvent.of(e.userEvent))),{changes:e.changes instanceof Ht?e.changes:Ht.of(e.changes||[],n,t.facet(RC)),selection:r&&(r instanceof ae?r:ae.single(r.anchor,r.head)),effects:Yi(e.effects),annotations:o,scrollIntoView:!!e.scrollIntoView}}function ZC(t,e,n){let r=ip(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(n=!1);for(let i=1;i<e.length;i++){e[i].filter===!1&&(n=!1);let s=!!e[i].sequential;r=QC(r,ip(t,e[i],s?r.changes.newLength:t.doc.length),s)}let o=Nt.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return Z2(n?Q2(o):o)}function Q2(t){let e=t.startState,n=!0;for(let o of e.facet(KC)){let i=o(t);if(i===!1){n=!1;break}Array.isArray(i)&&(n=n===!0?i:J2(n,i))}if(n!==!0){let o,i;if(n===!1)i=t.changes.invertedDesc,o=Ht.empty(e.doc.length);else{let s=t.changes.filter(n);o=s.changes,i=s.filtered.mapDesc(s.changes).invertedDesc}t=Nt.create(e,o,t.selection&&t.selection.map(i),qe.mapEffects(t.effects,i),t.annotations,t.scrollIntoView)}let r=e.facet(YC);for(let o=r.length-1;o>=0;o--){let i=r[o](t);i instanceof Nt?t=i:Array.isArray(i)&&i.length==1&&i[0]instanceof Nt?t=i[0]:t=ZC(e,Yi(i),!1)}return t}function Z2(t){let e=t.startState,n=e.facet(XC),r=t;for(let o=n.length-1;o>=0;o--){let i=n[o](t);i&&Object.keys(i).length&&(r=QC(r,ip(e,i,t.changes.newLength),!0))}return r==t?t:Nt.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const eL=[];function Yi(t){return t==null?eL:Array.isArray(t)?t:[t]}var pt=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(pt||(pt={}));const tL=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let sp;try{sp=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function nL(t){if(sp)return sp.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||tL.test(n)))return!0}return!1}function rL(t){return e=>{if(!/\S/.test(e))return pt.Space;if(nL(e))return pt.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return pt.Word;return pt.Other}}class tt{constructor(e,n,r,o,i,s){this.config=e,this.doc=n,this.selection=r,this.values=o,this.status=e.statusTemplate.slice(),this.computeSlot=i,s&&(s._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)ka(this,a<<1);this.computeSlot=null}field(e,n=!0){let r=this.config.address[e.id];if(r==null){if(n)throw new RangeError("Field is not present in this state");return}return ka(this,r),Yc(this,r)}update(...e){return ZC(this,e,!0)}applyTransaction(e){let n=this.config,{base:r,compartments:o}=n;for(let a of e.effects)a.is(Rc.reconfigure)?(n&&(o=new Map,n.compartments.forEach((l,c)=>o.set(c,l)),n=null),o.set(a.value.compartment,a.value.extension)):a.is(qe.reconfigure)?(n=null,r=a.value):a.is(qe.appendConfig)&&(n=null,r=Yi(r).concat(a.value));let i;n?i=e.startState.values.slice():(n=Kc.resolve(r,o,this),i=new tt(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let s=e.startState.facet(op)?e.newSelection:e.newSelection.asSingle();new tt(n,e.newDoc,s,i,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ae.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),o=this.changes(r.changes),i=[r.range],s=Yi(r.effects);for(let a=1;a<n.ranges.length;a++){let l=e(n.ranges[a]),c=this.changes(l.changes),u=c.map(o);for(let f=0;f<a;f++)i[f]=i[f].map(u);let d=o.mapDesc(c,!0);i.push(l.range.map(d)),o=o.compose(u),s=qe.mapEffects(s,u).concat(qe.mapEffects(Yi(l.effects),d))}return{changes:o,selection:ae.create(i,n.mainIndex),effects:s}}changes(e=[]){return e instanceof Ht?e:Ht.of(e,this.doc.length,this.facet(tt.lineSeparator))}toText(e){return st.of(e.split(this.facet(tt.lineSeparator)||Jh))}sliceDoc(e=0,n=this.doc.length){return this.doc.sliceString(e,n,this.lineBreak)}facet(e){let n=this.config.address[e.id];return n==null?e.default:(ka(this,n),Yc(this,n))}toJSON(e){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let r in e){let o=e[r];o instanceof qt&&this.config.address[o.id]!=null&&(n[r]=o.spec.toJSON(this.field(e[r]),this))}return n}static fromJSON(e,n={},r){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let o=[];if(r){for(let i in r)if(Object.prototype.hasOwnProperty.call(e,i)){let s=r[i],a=e[i];o.push(s.init(l=>s.spec.fromJSON(a,l)))}}return tt.create({doc:e.doc,selection:ae.fromJSON(e.selection),extensions:n.extensions?o.concat([n.extensions]):o})}static create(e={}){let n=Kc.resolve(e.extensions||[],new Map),r=e.doc instanceof st?e.doc:st.of((e.doc||"").split(n.staticFacet(tt.lineSeparator)||Jh)),o=e.selection?e.selection instanceof ae?e.selection:ae.single(e.selection.anchor,e.selection.head):ae.single(0);return WC(o,r.length),n.staticFacet(op)||(o=o.asSingle()),new tt(n,r,o,n.dynamicSlots.map(()=>null),(i,s)=>s.create(i),null)}get tabSize(){return this.facet(tt.tabSize)}get lineBreak(){return this.facet(tt.lineSeparator)||`
|
|
@@ -114,7 +114,7 @@ The error may be correlated with this previous error:
|
|
|
114
114
|
0% { box-shadow: 0 0 0 0 rgba(0, 212, 255, 0.6); }
|
|
115
115
|
100% { box-shadow: 0 0 0 6px rgba(0, 212, 255, 0); }
|
|
116
116
|
}
|
|
117
|
-
`})]}):y.isValidElement(t)?y.cloneElement(t,{value:e,onChange:n,...t.props}):t;return h.jsxs(h.Fragment,{children:[!r&&h.jsx("div",{style:{marginBottom:6,textAlign:"right"},children:h.jsxs(D.Button,{size:"small",type:"primary",onClick:i,style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",border:"none",borderRadius:"14px",padding:"0 10px",height:"24px",fontSize:"11px",fontWeight:"500",boxShadow:"0 2px 8px rgba(102, 126, 234, 0.3)",transition:"all 0.2s ease",display:"flex",alignItems:"center",gap:"4px",lineHeight:1},onMouseEnter:a=>{a.currentTarget.style.transform="translateY(-1px)",a.currentTarget.style.boxShadow="0 4px 12px rgba(102, 126, 234, 0.5)"},onMouseLeave:a=>{a.currentTarget.style.transform="translateY(0)",a.currentTarget.style.boxShadow="0 2px 8px rgba(102, 126, 234, 0.3)"},children:[h.jsx(se.RobotOutlined,{style:{fontSize:"11px"}}),"由AI生成"]})}),s()]})},eG=t=>{var n;const e=In();return h.jsx(D.Select,{id:e,style:{borderRadius:6},...t,getPopupContainer:r=>r.parentNode,children:(n=t==null?void 0:t.options)==null?void 0:n.map(r=>h.jsx(D.Select.Option,{label:r.label,value:r.value,children:r.label},r.value))})},tG=t=>h.jsx(D.DatePicker,{style:{width:"100%"},picker:"date",value:t.value?jt(t.value):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD")))}}),nG=t=>h.jsx(y.Fragment,{children:h.jsx(D.DatePicker,{style:{width:"100%"},picker:"date",showTime:!0,value:t.value?jt(t.value):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD hh:mm:ss")))}})}),rG=({value:t=[],onChange:e,selectType:n="KNOWLEDGE_BASE",placeholder:r="请选择"})=>{const o=Et.useReactive({items:[]}),[i,s]=y.useState([]),[a,l]=y.useState(!1);y.useEffect(()=>{n&&(l(!0),Uy(n).then(p=>{p&&Array.isArray(p)&&s(p)}).catch(p=>{console.error("获取选项失败:",p),s([])}).finally(()=>{l(!1)}))},[n]),y.useEffect(()=>{const p=Array.isArray(t)?t:[];o.items=p.map(m=>({...m,id:m.id??In()}))},[t]);const c=Ot(),u=p=>{const m=o.items.filter(v=>v.id!==p);e==null||e(m)},d=()=>{e([...o.items,{value:"",id:In()}])},f=(p,m)=>{e(o.items.map((v,b)=>b===p?{...v,value:m}:v))};return h.jsxs("div",{children:[o.items.length?o.items.map((p,m)=>h.jsxs(D.Space,{size:"small",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[h.jsx(D.Select,{value:p.value||void 0,onChange:v=>f(m,v),placeholder:r,style:{width:300},disabled:!c||a,loading:a,options:i,showSearch:!0,filterOption:(v,b)=>((b==null?void 0:b.label)??"").toLowerCase().includes(v.toLowerCase()),getPopupContainer:v=>v.parentNode}),c&&h.jsx(D.Button,{icon:h.jsx(Di,{size:16}),onClick:()=>{u(p.id)}})]},p.id)):null,c&&h.jsx(D.Button,{type:"default",onClick:d,block:!0,icon:h.jsx(br,{size:16}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})})]})},oG=({value:t=[],onChange:e,valueType:n})=>{const r=u=>{let d=[...o.items];d=d.filter(f=>f.id!==u),e==null||e(d)},o=Et.useReactive({items:[]}),i=u=>{const d=u.which||u.keyCode;(d===37||d===229)&&u.preventDefault()};y.useEffect(()=>{const u=Array.isArray(t)?t:[];o.items=u.map(d=>({...d,id:d.id??In()}))},[t]);const s=()=>{e==null||e([...o.items,{key:"",value:"",id:In()}])},a=(u,d)=>{e==null||e(o.items.map(f=>f.id===u?{...f,key:d}:f))},l=(u,d)=>{e==null||e(o.items.map(f=>f.id===u?{...f,value:d}:f))},c=Ot();return h.jsxs("div",{className:"workflow-extend-object",children:[o.items.length?o.items.map((u,d)=>h.jsxs(D.Space,{size:"small",className:"workflow-extend-object__row",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[h.jsx(D.Input,{defaultValue:u.key,onKeyDown:i,onChange:f=>{var p;a(u.id,(p=f.target.value)==null?void 0:p.replace(/'/g,""))},placeholder:"Key"}),h.jsx("span",{className:"workflow-extend-object__value",style:{display:"inline-block",transform:"translateY(2px)",width:300},children:h.jsx(Pn,{borrow:!0,disableIDE:!0,placeholder:"Value",style:{width:300},value:u.value,onChange:f=>l(u.id,f),valueType:n,nodeId:""})}),c&&h.jsx(D.Button,{icon:h.jsx(Di,{size:16}),onClick:()=>{r(u.id)}})]},u.id)):null,h.jsxs(D.Button,{type:"default",onClick:s,block:!0,children:[h.jsx(br,{size:16})," ",h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})]})]})},iG=t=>null,sG=t=>h.jsx(D.TimePicker,{style:{width:"100%"},use12Hours:!1,format:"HH:mm",value:t.value?jt(t.value,"HH:mm"):null,onChange:e=>{const n=jt(e).format("HH:mm:00");t.onChange&&(t==null||t.onChange(n))}}),{Text:aG}=D.Typography,YA=t=>h.jsx("div",{className:"ce-tag_input label-field",children:h.jsx("p",{children:h.jsx(D.Tooltip,{title:t.value,color:"cyan",placement:"topLeft",children:h.jsx(aG,{ellipsis:!0,copyable:{text:t.value},children:t.value})})})}),lG=({value:t=[],onChange:e,...n})=>{const[r,o]=y.useState([]);y.useEffect(()=>{const f=Array.isArray(t)?t:[];o(f.map(p=>({...p,id:p.id??In()})))},[t]);const i=Ot(),s=f=>{const p=r.filter(m=>m.id!==f);o(p),e==null||e(p)},a=()=>{const f={field:"",dataType:"string",desc:"",required:!1,id:In()},p=[...r,f];o(p),e(p)},l=(f,p)=>{const m=r.map(v=>v.id===f?{...v,field:p}:v);o(m),e(m)},c=(f,p)=>{const m=r.map(v=>v.id===f?{...v,dataType:p}:v);o(m),e(m)},u=(f,p)=>{const m=r.map(v=>v.id===f?{...v,desc:p}:v);o(m),e(m)},d=(f,p)=>{const m=r.map(v=>v.id===f?{...v,required:p}:v);o(m),e(m)};return h.jsxs("div",{className:"workflow-multi-row-extract",children:[r.length?r.map(f=>h.jsxs(D.Space,{size:"small",className:"workflow-multi-row-extract__row",style:{display:"flex",marginBottom:8,width:"100%"},align:"start",children:[h.jsx(D.Input,{value:f.field,onChange:p=>l(f.id,p.target.value),placeholder:"字段名称",status:"",style:{width:130},disabled:!i}),h.jsx(D.Select,{value:f.dataType,onChange:p=>c(f.id,p),placeholder:"数据类型",style:{width:100},disabled:!i,options:[{label:"字符串",value:"string"},{label:"数字",value:"number"},{label:"日期",value:"date"},{label:"布尔",value:"boolean"}]}),h.jsx(D.Input,{value:f.desc,onChange:p=>u(f.id,p.target.value),placeholder:"字段描述",status:"",style:{width:200},disabled:!i}),h.jsx(D.Select,{value:f.required,onChange:p=>d(f.id,p),placeholder:"是否必填",style:{width:100},disabled:!i,options:[{label:"是",value:!0},{label:"否",value:!1}]}),i&&h.jsx(D.Button,{icon:h.jsx(Di,{size:16}),onClick:()=>{s(f.id)}})]},f.id)):null,i&&h.jsx(D.Button,{type:"default",onClick:a,block:!0,icon:h.jsx(br,{size:16}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})})]})},cG=t=>{const e=y.useMemo(()=>In(),[]),{event$:n}=y.useContext(Qr),r=Qm(e),[o,i]=y.useState("");n.useSubscription(a=>{var l;if(a.type==="insert"&&a.currentInputId===e){const c=(o??"")+(t.valueType==="FIX_VALUE"?a.expression.slice(2,-2):a.expression);i(c),(l=t.onChange)==null||l.call(t,c)}}),y.useEffect(()=>{i(t.value)},[t.value]);const s=a=>{var l;i(a.target.value),(l=t.onChange)==null||l.call(t,a.target.value)};return h.jsxs(D.Space.Compact,{block:!0,className:`workflow-password-field${r?` ${od}`:""}`,children:[h.jsx("span",{className:"workflow-password-field__prefix",children:K("link.flow.cipherText")}),h.jsx(D.Input.Password,{id:e,onFocus:()=>{(t.valueType==="JS_EXP"||t.valueType==="FIX_VALUE"||t.valueType==="PLAIN_TEXT"||t.valueType==="PLAIN_CODE")&&(n.emit({type:"visible",visible:!0}),n.emit({type:"setCurrentInputId",currentInputId:e}))},value:o,onChange:s})]})},uG=t=>{var o;const e=In(),{multiple:n,...r}=t;return h.jsx(D.Select,{id:e,style:{borderRadius:6},mode:n?"multiple":void 0,...r,getPopupContainer:i=>i.parentNode,children:(o=t==null?void 0:t.options)==null?void 0:o.map(i=>h.jsx(D.Select.Option,{label:i.label,value:i.value,children:i.label},i.value))})},dG=t=>h.jsx(D.TimePicker,{style:{width:"100%"},value:t.value?jt(t.value,"HH:mm:ss"):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("HH:mm:ss")))}}),El=()=>$t().flowId,fG=["sample","test","payload","body"],hG=["测试","样本","sample","test","payload","body"],XA=t=>{var n,r,o;return[xe.JSON,xe.TEXTAREA,xe.FIXED_OBJ].includes(t.page_control)?!0:((o=(r=(n=t.value_type)==null?void 0:n.toLowerCase)==null?void 0:r.call(n))==null?void 0:o.includes("json"))??!1},JA=(t,e)=>{if(!t)return!1;const n=t.toLowerCase();return e.some(r=>n.includes(r))},pG=t=>{if(t==null)return;const e=(t==null?void 0:t.data)!==void 0?t.data:t;if(typeof e=="string")try{const n=JSON.parse(e);return JSON.stringify(n,null,2)}catch{return e}try{return JSON.stringify(e,null,2)}catch{return}},mG=t=>{const{form:e,configList:n=[],disabled:r,...o}=t;a0();const[i,s]=y.useState(!1),[a,l]=y.useState(0),c=y.useRef(void 0),u=El(),d=y.useMemo(()=>{const m=n.find(v=>XA(v)&&(JA(v.name,fG)||JA(v.display_name,hG)));return m||n.find(v=>XA(v))},[n]),f=y.useCallback(()=>{c.current&&(clearInterval(c.current),c.current=void 0)},[]);y.useEffect(()=>()=>{f()},[f]);const p=y.useCallback(async()=>{if(!u){D.message.warning("缺少连接流ID,无法监听Webhook");return}if(!(d!=null&&d.name)){D.message.warning("未找到测试数据字段,无法填充监听结果");return}if(!i){s(!0),l(10),c.current=setInterval(()=>{l(m=>m<=1?(f(),0):m-1)},1e3);try{const m=await Fy(u,{timeout_seconds:10}),v=pG(m);v?(e.setFieldsValue({[d.name]:v}),D.message.success("已捕获Webhook推送数据并填充测试样例")):D.message.info("监听结束,暂无新的推送数据")}catch(m){console.error("监听Webhook失败:",m),D.message.error("监听失败,请稍后重试")}finally{f(),s(!1),l(0)}}},[u,e,i,d==null?void 0:d.name,f]);return h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},className:"web-hook",children:[h.jsx("div",{style:{flex:1},className:"web-hook-input",children:h.jsx(YA,{...o})}),h.jsx(D.Button,{size:"small",type:"primary",ghost:!0,onClick:p,disabled:r||!(d!=null&&d.name),loading:i,style:{height:32,minWidth:110,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:i?`监听中${a?`(${a}s)`:""}`:"监听"})]})},gG={configFormContainer:"_configFormContainer_1frpl_1"};function wG(t){return Lq(t==null?void 0:t.credentials)}const bG=t=>String(t.type).toUpperCase();function QA(t){var e,n;return(n=(e=t==null?void 0:t.input_fields)==null?void 0:e.find(r=>bG(r)==="PROXY"))==null?void 0:n.key}function ZA(t){return t==null||t===""?"0":String(t)}function vG(t,e,n){const r=QA(e);return r?{...t,[r]:ZA(n??t[r])}:t}function yG(t,e){const n=QA(e);if(!n)return{properties:t};const r={...t},o=ZA(r[n]);return delete r[n],{properties:r,proxyId:o}}const eO=({field:t,disabled:e,readOnly:n,context:r,value:o="",onChange:i,id:s,allowVariableInsert:a,hasModeSwitch:l})=>{const c=uC(),u=y.useId(),d=s||`workflow-code-${u}`,f=y.useRef(null),[p,m]=y.useState(0),v=!e&&!n,b=y.useCallback(_=>{var x;if(!a)return;const S=(x=f.current)==null?void 0:x.view,E=S==null?void 0:S.state.selection.main;if(!S||!E){i==null||i(`${o}${_}`);return}S.dispatch({changes:{from:E.from,to:E.to,insert:_},selection:{anchor:E.from+_.length}}),S.focus()},[a,i,o]),w=oC(d,_=>b(_),()=>{var _,S;return(S=(_=f.current)==null?void 0:_.view)==null?void 0:S.focus()}),g=Mh(),C=(g==null?void 0:g.activeFieldId)===d,k=y.useCallback(()=>{if(v)try{i==null||i(JSON.stringify(JSON.parse(o),null,2))}catch{D.message.warning(K("link.flow.format_json_failed"))}},[v,i,o]);return h.jsx(bC,{id:d,canEditInEditor:v,openEditorNumber:p,nodeId:c.nodeId||r.nodeId||"",value:o,language:"json",showVariableSidebar:a,onFinish:i,children:h.jsxs("div",{style:{position:"relative"},className:C?od:void 0,children:[h.jsx(nd,{id:d,ref:f,value:o,readOnly:!v,height:"220px",placeholder:t.placeholder,theme:Cm,extensions:[$A()],onFocus:()=>{v&&a&&w.activate()},onChange:i}),v?h.jsxs(D.Space,{size:4,style:{position:"absolute",right:8,top:6,zIndex:2},children:[h.jsx(D.Tooltip,{title:K("link.flow.format_json"),children:h.jsx(D.Button,{type:"text",size:"small","aria-label":K("link.flow.format_json"),icon:h.jsx(se.FormatPainterOutlined,{}),onClick:k,style:{color:"#fff"}})}),h.jsx(D.Tooltip,{title:K("link.flow.open_code_editor"),children:h.jsx(D.Button,{type:"text",size:"small","aria-label":K("link.flow.open_code_editor"),icon:h.jsx(se.FullscreenOutlined,{}),onClick:()=>m(_=>_+1),style:{color:"#fff"}})})]}):null]})})};eO.displayName="WorkflowCodeEditor";const tO=({field:t,disabled:e,readOnly:n,context:r,value:o,onChange:i,id:s})=>{const a=typeof o=="string"?o:o==null?"":JSON.stringify(o)??"",l=!!t.valueModePolicy,c=t.valueModePolicy==="EXPRESSION"||t.valueModePolicy==="BOTH",u=d=>h.jsx(eO,{...d,field:t,context:r,id:s,allowVariableInsert:c,hasModeSwitch:l});return t.valueModePolicy?h.jsx(ki,{value:a,onChange:d=>i==null?void 0:i(d),valueModePolicy:t.valueModePolicy,disabled:e,readOnly:n,placeholder:t.placeholder,renderNormalMode:u,renderExpressionMode:u,modeSwitchPosition:"top-right",encodeExpressionValue:!0}):u({value:a,onChange:d=>i==null?void 0:i(d),disabled:e,readOnly:n,placeholder:t.placeholder})};tO.displayName="WorkflowCodeFieldControl";const CG=dt(tO,{needsFormItemName:!0,supportsVariableInsert:!0}),nO=({disabled:t,readOnly:e,value:n,onChange:r,id:o})=>{const[i,s]=y.useState([]),[a,l]=y.useState(!1);y.useEffect(()=>{let d=!1;return l(!0),Kf().then(f=>{d||s(Array.isArray(f)?f:[])}).catch(()=>{d||D.message.error(K("link.flow.request_failed"))}).finally(()=>{d||l(!1)}),()=>{d=!0}},[]);const c=y.useMemo(()=>[{value:"0",label:h.jsx(Te.FormattedMessage,{id:"link.flow.do_not_use"})},...i.map(d=>({value:String(d.id),label:d.group_name||String(d.id)}))],[i]),u=n==null||n===""?"0":String(n);return h.jsx(D.Select,{id:o,className:"proxy_id_select",value:u,options:c,loading:a,disabled:t||e,dropdownStyle:{zIndex:99999999999},onChange:d=>r==null?void 0:r(String(d)),style:{width:"100%"}})};nO.displayName="WorkflowProxyFieldControl";const kG=dt(nO,{needsFormItemName:!0,supportsVariableInsert:!0}),SG=[{type:ge.CODE,definition:CG},{type:ge.PROXY,definition:kG}];function EG({children:t}){return h.jsx(fC,{additionalRegistrations:SG,children:t})}function xl(){const{event$:t}=y.useContext(Qr),e=Fh();return y.useCallback(n=>{var o;const r=document.activeElement;if(r&&r!==document.body&&r.contains(n.target)){const i=n.target;if(!["INPUT","TEXTAREA","SELECT"].includes((i==null?void 0:i.tagName)??""))return}(o=t==null?void 0:t.emit)==null||o.call(t,{type:"setCurrentInputId",currentInputId:""}),e==null||e.deactivateField()},[t,e])}const xG=[xe.TEXT,xe.PASSWORD,xe.SELECT,xe.EXTEND_OBJ,xe.DATE,xe.TIME,xe.DATETIME,xe.TEXTAREA,xe.FIXED_OBJ,xe.JSON],DG="[workflow:schema-render]",_G=/^\{\{([^.{}]+)\.(.+)\}\}$/,AG=t=>{switch(t.page_control){case xe.SELECT:case xe.API_SELECT:return t.multi_valued?[]:null;case xe.EXTEND_OBJ:return{};case xe.HIDDEN:return"";case xe.TEXT:return"";case xe.PASSWORD:return"";case xe.LABEL:return"";case xe.DATE:return null;case xe.TIME:return null;case xe.DATETIME:return null;case xe.TEXTAREA:return"";case xe.FIXED_OBJ:return{};case xe.MultiRowAIExtractConfig:return[];case xe.JSON:return""}},rO=(t,e,n,r,o)=>{const i=t.display_name,s=()=>{var a,l,c;switch(t.page_control){case xe.SELECT:return h.jsx(uG,{options:Zg(t.option_value_objects??t.option_values),multiple:t.multi_valued});case xe.API_SELECT:return h.jsx(eG,{options:Zg(t.option_value_objects??t.option_values)});case xe.EXTEND_OBJ:return h.jsx(oG,{valueType:t.value_type});case xe.HIDDEN:return h.jsx(iG,{});case xe.TEXT:return h.jsx(Pn,{valueType:t.value_type,nodeId:e});case xe.PASSWORD:return h.jsx(cG,{valueType:t.value_type});case xe.LABEL:return(a=r==null?void 0:r.webhookField)!=null&&a.enabled&&t.name==="hookUrl"&&r.webhookField.form?h.jsx(mG,{form:r.webhookField.form,configList:r.webhookField.configList,disabled:r.webhookField.disabled}):h.jsx(YA,{});case xe.DATE:return h.jsx(tG,{});case xe.TIME:return h.jsx(dG,{});case xe.DATETIME:return h.jsx(nG,{});case xe.TEXTAREA:return h.jsx(Pn,{valueType:t.value_type,textAreaMode:!0,nodeId:e});case xe.FIXED_OBJ:return h.jsx(D.Input.TextArea,{});case xe.JSON:return h.jsx(Pn,{valueType:t.value_type,nodeId:e});case xe.MultiRowAIExtractConfig:return h.jsx(lG,{valueType:t.value_type});case xe.MULTI_SELECT_LIST:return h.jsx(rG,{selectType:"KNOWLEDGE_BASE"});case xe.SYNC_HOUR_MINUTE:return h.jsx(sG,{});case xe.AUTH_TOKEN:return h.jsx(Rq,{disabled:(l=r==null?void 0:r.webhookField)==null?void 0:l.disabled});case xe.SECRET_KEY:return h.jsx(Yq,{});case xe.SELECT_CLIENT:return h.jsx(Qq,{});default:{const u=(c=o==null?void 0:o.form)==null?void 0:c.find(d=>d.name===t.page_control);return u?h.jsx(u.component,{config:t,configList:r==null?void 0:r.configList,disabled:r==null?void 0:r.disabled,form:r==null?void 0:r.form,mcpMode:n,nodeId:e}):(console.warn(`unknown form item: page_control:${t.page_control}`),null)}}};return n&&xG.includes(t.page_control)?h.jsx("div",{children:h.jsx(D.Form.Item,{required:t.required,rules:[{required:t.required,message:t.page_control===xe.SELECT?K("link.flow.please_select")+t.display_name:K("link.flow.please_enter")+t.display_name}],label:i,name:t.name,children:h.jsx(Zq,{children:s()})})},t.ui_id):h.jsx(D.Form.Item,{required:t.required,style:t.page_control===xe.HIDDEN?{display:"none"}:{},rules:[{required:t.required,message:t.page_control===xe.SELECT?K("link.flow.please_select")+t.display_name:K("link.flow.please_enter")+t.display_name},{validator(a,l,c){if(t.page_control===xe.MultiRowAIExtractConfig)if(Array.isArray(l)&&t.required){const u=l.some(d=>!d.field||!d.dataType||!d.desc||d.required==null);c(u?"请填写完整配置":void 0)}else c(void 0);else c(void 0)}}],label:i,name:t.name,children:s()},t.ui_id)},OG=t=>(t.child_conditions??[]).map(e=>e.left).filter(e=>!!e),TG=(t,e)=>{if(!t.is_child)return!0;const n=t.child_conditions??[];return n.length?n.some(({left:r,operator:o,right:i})=>{const s=e==null?void 0:e[r];return o==="EQUALS"?s===i:s!==i}):!0},NG=y.forwardRef((t,e)=>{var we,fe;const{action:n,connector:r,nodeId:o,account_id:i,mcpMode:s,nodeType:a}=t,l=$t(),c=ne.useStoreApi(),u=xl(),d=Et.useReactive({proxyId:"0"}),{config_schema:f,proxy_id:p,protocol:m,account_schema_id:v}=n;a??n.node_type??n.type;const b=n.action_key||n.nodeKey,w=n.action_ver??n.nodeVersion,g=Array.isArray(f==null?void 0:f.sub_params),C=po(n),k=y.useMemo(()=>!C||!b?null:`${b}@${w??"latest"}`,[C,b,w]),_=k?`${o}:${k}`:o,S=n.account_id??i,E=y.useMemo(()=>k?Wi(b,w):null,[k,b,w]),[x,O]=y.useState(()=>k&&E?{identity:k,schema:E,loading:!1,finished:!0}:null),A=(x==null?void 0:x.identity)===k?x:null,T=(A==null?void 0:A.schema)??null,B=rw((T==null?void 0:T.credentials)??[]),I=!!(C&&b&&!T&&((A==null?void 0:A.loading)??!(A!=null&&A.finished))),F=wG(T);y.useEffect(()=>{!x||x.identity},[k,x,o,b,w]),y.useEffect(()=>{p&&(d.proxyId=p)},[p,d]);const[N]=D.Form.useForm(),[P,M]=y.useState(S);y.useEffect(()=>{M(S)},[_,S,M]);const z=y.useMemo(()=>{var le;return g?(le=f.sub_params)==null?void 0:le.reduce((Se,ce)=>{let Fe=ce.value;return ce.page_control===xe.EXTEND_OBJ&&(Fe=_q(Fe)),Se[ce.name]=Fe??AG(ce),Se},{}):{}},[f==null?void 0:f.sub_params,g]);y.useEffect(()=>{g&&(N.resetFields(),N.setFieldsValue({...z}))},[z,N,g,o]);const H=y.useRef(null),R=y.useRef(null);y.useEffect(()=>{if(!k||!b){O(null);return}const le=Wi(b,w);if(le){O({identity:k,schema:le,loading:!1,finished:!0});return}let Se=!1;return O({identity:k,schema:null,loading:!0,finished:!1}),pc(b,w).then(ce=>{Se||O({identity:k,schema:ce,loading:!1,finished:!0})}).catch(ce=>{Se||(O({identity:k,schema:null,loading:!1,finished:!0}),console.error(`${DG} classic renderer next schema load failed`,{nodeId:o,nodeKey:b,nodeVersion:w,err:ce}))}),()=>{Se=!0}},[k,o,b,w]);const Y=y.useMemo(()=>{var le;return(le=T==null?void 0:T.input_fields)!=null&&le.length?KI(WA(T.input_fields),T.key):null},[T]),te=!!(C&&(Y||F||T)),$=y.useMemo(()=>{const le=n.properties?ha(n.properties):f&&C?ha(f):n.params?ha(n.params):{},Se=vG(le,T,p);return uc(b)?ra(Se).properties:Se},[n,f,C,T,b,p]),j=y.useMemo(()=>JSON.stringify($??{}),[$]);y.useEffect(()=>{!C||!te||(N.resetFields(),N.setFieldsValue($))},[_,N,C,$,j,te]);const U=y.useRef(null);y.useEffect(()=>{U.current=null},[_]),y.useEffect(()=>{uc(b)&&(U.current=JSON.stringify(ra($).branches.map(le=>[le.id,le.name])))},[$,b]);const ee=y.useCallback(le=>{const Se=le.trim().match(_G);if(!Se)return null;const ce=Se[1],Fe=Se[2];if(ce==="global")return null;const Ve=ce.startsWith("N")?ce.slice(1):ce,je=c.getState().nodes.find(We=>We.id===Ve);return je?{fieldPath:Fe,node:je,variableNodeId:ce}:null},[c]),ie=y.useCallback(le=>{var Se;return((Se=ee(le))==null?void 0:Se.fieldPath)??le.replace(/^\{\{|\}\}$/g,"")},[ee]),be=y.useCallback(le=>{var je;const Se=ee(le);if(!Se)return le;const ce=(je=Se.node)==null?void 0:je.data,Fe=(ce==null?void 0:ce.label)||(ce==null?void 0:ce.name)||(ce==null?void 0:ce.action_name)||Se.variableNodeId,Ve=ce!=null&&ce.note?` (${ce.note})`:"";return`${Fe}${Ve}.${Se.fieldPath}`},[ee]),[W,X]=y.useState(!1),q=(le,Se)=>(X(!0),N.validateFields().then(async ce=>{var Ve,je,We,ht,Ee;if(te){Se&&((je=(Ve=H==null?void 0:H.current)==null?void 0:Ve.onIgnoreNodeStart)==null||je.call(Ve));const{properties:Ce,proxyId:Le}=yG(ce,T);return t.onSubmit({properties:Ce,account_id:P,proxy_id:Le},le)}const Fe=Pt.cloneDeep(n.config_schema);return Fe.sub_params.forEach(Ce=>{let Le=ce[Ce.name];Ce.page_control===xe.EXTEND_OBJ&&Le!=="{{$fromAI}}"&&(Le=ew(Le)),Ce.value=Le??null}),Se&&((ht=(We=H==null?void 0:H.current)==null?void 0:We.onIgnoreNodeStart)==null||ht.call(We)),!i&&m==="HTTP"&&(r==null?void 0:r.deployment_type)!=="SaasApp"&&(Fe.proxy_id=(Ee=R.current)==null?void 0:Ee.getProxyId()),t.onSubmit(Fe,le)}).catch(ce=>(console.log("err",ce),D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>X(!1)));y.useImperativeHandle(e,()=>({saveConfig:le=>q(le,!1)}));const J=Ot(),re={form:N,configList:(f==null?void 0:f.sub_params)??[],disabled:!J,...m==="WEBHOOK"?{webhookField:{enabled:!0,form:N,configList:(f==null?void 0:f.sub_params)??[],disabled:!J}}:{}},Z=le=>{const Se=le.page_control!==xe.HIDDEN?h.jsx("p",{className:"field-desc",children:le.description}):null;if(!le.is_child)return h.jsxs("div",{children:[rO(le,o,s,re,l.canvas.registerComponents),Se]},le.ui_id);const ce=OG(le);return h.jsx(D.Form.Item,{noStyle:!0,shouldUpdate:(Fe={},Ve={})=>le.is_child?ce.length?ce.some(je=>(Fe==null?void 0:Fe[je])!==(Ve==null?void 0:Ve[je])):!0:!1,children:()=>{const Fe=N.getFieldsValue(!0);return TG(le,Fe)?h.jsxs("div",{children:[rO(le,o,s,re,l.canvas.registerComponents),Se]}):null}},le.ui_id)};if(C&&I)return h.jsx("div",{style:{textAlign:"center",padding:40},children:h.jsx(D.Spin,{})});const ue=!t.preRender&&(((we=n.config_schema)==null?void 0:we.sub_params)??[]).length<1,ve=h.jsx("div",{style:{padding:16,color:"#999",textAlign:"center"},children:"该节点暂无配置项"});if(te){const le=h.jsxs(h.Fragment,{children:[t.preRender&&t.preRender,F?h.jsx(RA,{credentialRequirements:B,value:P,onChange:M,linkApp:r,disabled:!J}):null]});return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:u,children:[h.jsx("div",{className:"workflow-node-form-scroll",children:Y?h.jsx(EG,{children:h.jsx(Xg,{schema:Y,form:N,initialValues:$,showSubmit:!1,showReset:!1,nodeId:o,mcpMode:s,renderVariableTag:ie,renderVariableTooltip:be,customTheme:sc,preRender:le},_)}):ve}),h.jsx("div",{className:"workflow-node-form-footer",children:J&&h.jsx(D.Button,{type:"primary",disabled:!J,loading:W,className:"workflow-node-form-save",onClick:()=>q(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:u,children:[h.jsxs(D.Form,{form:N,disabled:!J,layout:"vertical",className:`${gG.configFormContainer} workflow-config-form workflow-node-form-scroll`,children:[t.preRender&&t.preRender,(r==null?void 0:r.id)&&n.config_schema&&((fe=f==null?void 0:f.sub_params)==null?void 0:fe.map(le=>Z(le))),!i&&m==="HTTP"&&(r==null?void 0:r.deployment_type)!=="SaasApp"?h.jsx(Jg,{proxyId:d.proxyId,ref:R}):null,ue&&ve]}),h.jsx("div",{className:"workflow-node-form-footer",children:J&&h.jsx(D.Button,{type:"primary",disabled:!J,loading:W,className:"workflow-node-form-save",onClick:()=>q(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),BG=y.memo(y.forwardRef((t,e)=>{const{nodeId:n,data:r}=t,{account_id:o,account_schema_id:i}=r,s=Et.useReactive({account_id:o}),a=y.useRef(null);y.useImperativeHandle(e,()=>({saveConfig:p=>{var m;return(m=a.current)==null?void 0:m.saveConfig(p)}}));const l=y.useMemo(()=>({id:t.data.connector_id,name:t.data.connector_name,deployment_type:t.data.deployment_type}),[t.data.connector_id,t.data.connector_name,t.data.deployment_type]),c=po(t.data),u=(p,m)=>{if(c){const v=ha(p),w=Object.hasOwn(p??{},"account_id")?p.account_id??null:s.account_id;return t.onSubmit({properties:v,account_id:w,proxy_id:(p==null?void 0:p.proxy_id)??(v==null?void 0:v.proxy_id)},m)}return t.onSubmit({properties:p,account_id:s.account_id,proxy_id:p.proxy_id},m)},d=y.useCallback(p=>{s.account_id=p??null},[]);let f=null;return i&&!c&&(f=h.jsx(RA,{onChange:d,actionAccountSchemaId:i,value:s.account_id,linkApp:l})),h.jsx("div",{className:"workflow-action-node-config",children:h.jsx(NG,{ref:a,action:t.data,nodeType:t.nodeType||t.data.node_type||t.data.type,connector:l,account_id:o,nodeId:n,onSubmit:u,onNodePackageValuesChange:t.onNodePackageValuesChange,preRender:f})})}),(t,e)=>t.nodeId===e.nodeId&&t.nodeType===e.nodeType&&Pt.isEqual(Pt.omit(t.data,["isHovered"]),Pt.omit(e.data,["isHovered"])));var $n=(t=>(t.IDLE="idle",t.SAVING="saving",t.SAVED="saved",t.ERROR="error",t))($n||{}),Wd=(t=>(t.SELECTION="selection",t.ALL="all",t))(Wd||{}),er=(t=>(t.UNPUBLISHED="UNPUBLISHED",t.ONLINE="ONLINE",t.OFFLINE="OFFLINE",t.ON_WARN="ON_WARN",t.OFF_WARN="OFF_WARN",t.ONLINE_ING="ONLINE_ING",t))(er||{}),nt=(t=>(t.eq="eq",t.ne="ne",t.sw="sw",t.nsw="nsw",t.ew="ew",t.ewn="ewn",t.gt="gt",t.ge="ge",t.lt="lt",t.le="le",t.co="co",t.nco="nco",t.in="in",t.nin="nin",t.is_null="is_null",t.is_not_null="is_not_null",t))(nt||{});const oO=[{operator:nt.eq,label:K("common.eq")},{operator:nt.ne,label:K("common.ne")},{operator:nt.sw,label:K("common.sw")},{operator:nt.nsw,label:K("common.nsw")},{operator:nt.ew,label:K("common.ew")},{operator:nt.ewn,label:K("common.ewn")},{operator:nt.gt,label:K("common.gt")},{operator:nt.ge,label:K("common.ge")},{operator:nt.lt,label:K("common.lt")},{operator:nt.le,label:K("common.le")},{operator:nt.co,label:K("common.co")},{operator:nt.nco,label:K("common.nco")},{operator:nt.in,label:K("common.in")},{operator:nt.nin,label:K("common.nin")},{operator:nt.is_null,label:K("common.is_null")},{operator:nt.is_not_null,label:K("common.is_not_null")}];nt.eq+"",K("common.eq"),nt.ne+"",K("common.ne"),nt.sw+"",K("common.sw"),nt.nsw+"",K("common.nsw"),nt.ew+"",K("common.ew"),nt.ewn+"",K("common.ewn"),nt.gt+"",K("common.gt"),nt.lt+"",K("common.lt"),nt.ge+"",K("common.ge"),nt.co+"",K("common.co"),nt.nco+"",K("common.nco"),nt.le+"",K("common.le"),nt.in+"",K("common.in"),nt.nin+"",K("common.nin"),nt.is_null+"",K("common.is_null"),nt.is_not_null+"",K("common.is_not_null");const iw=t=>t===nt.is_null||t===nt.is_not_null,FG=(t,e="")=>iw(t)?"":e,{Option:MG}=D.Select,IG=y.forwardRef((t,e)=>{const{config_schema:n}=t,[r]=D.Form.useForm(),o=xl(),s=(d=>d!=null&&d.or_list?{or_list:d.or_list.map(p=>({and_list:p.and_list.map(m=>({query:m.query||"",operator:m.operator||"",value:m.value||""}))}))}:{or_list:[{and_list:[{query:"",operator:"",value:""}]}]})(n),[a,l]=y.useState(!1),c=(d,f,p="")=>(l(!0),r.validateFields().then(async m=>t.onSubmit({properties:m},d)).catch(()=>(D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>l(!1)));y.useImperativeHandle(e,()=>({saveConfig:d=>c(d)}));const u=Ot();return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:o,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsx(D.Form,{disabled:!u,form:r,initialValues:s,layout:"vertical",autoComplete:"off",children:h.jsx(D.Form.List,{name:"or_list",children:(d,{add:f,remove:p})=>h.jsxs(h.Fragment,{children:[d.map((m,v)=>h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"form-block",children:h.jsxs("div",{style:{padding:12,width:"100%",boxSizing:"border-box"},children:[v>0&&u&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsx(D.Button,{type:"link",style:{color:"red"},icon:h.jsx(se.MinusCircleOutlined,{style:{color:"red"}}),onClick:()=>p(m.name),children:h.jsx(Te.FormattedMessage,{id:"link.flow.remove"})})}),h.jsx(D.Form.List,{name:[m.name,"and_list"],children:(b,{add:w,remove:g})=>h.jsx(h.Fragment,{children:b.map((C,k)=>h.jsxs(D.Space,{direction:"vertical",style:{width:"100%",rowGap:0},children:[h.jsxs(D.Space,{align:"center",className:`form-item-row ${k>0?"opt":""}`,children:[h.jsx(D.Form.Item,{style:{minWidth:150},name:[C.name,"query"],label:K("app.common.word.variable-name"),rules:[{required:!0,message:K("link.flow.please_enter_variable_name")}],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),h.jsx(D.Form.Item,{name:[C.name,"operator"],label:K("app.common.word.condition"),rules:[{required:!0,message:K("link.flow.please_select_condition")}],children:h.jsx(D.Select,{style:{minWidth:140},placeholder:K("link.flow.select_condition"),getPopupContainer:_=>_.parentNode,children:oO.map(_=>h.jsx(MG,{value:_.operator,children:_.label},_.operator))})}),h.jsx(D.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const _=r.getFieldValue(["or_list",m.name,"and_list",C.name,"operator"]);return iw(_)?null:h.jsx(D.Form.Item,{style:{minWidth:150},name:[C.name,"value"],label:K("app.common.word.value"),rules:[],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),k>0&&h.jsx(D.Button,{type:"link",icon:h.jsx(se.MinusCircleOutlined,{}),onClick:()=>g(C.name)})]}),k<b.length-1&&h.jsx(D.Divider,{plain:!0,children:h.jsx(D.Tag,{color:"#999999",children:h.jsx(Te.FormattedMessage,{id:"link.flow.and"})})}),k===b.length-1&&h.jsx(D.Button,{type:"link",disabled:!u,icon:h.jsx(br,{size:16}),className:"small",onClick:()=>w({query:"",operator:"",value:""}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-new-and"})})]},C.key))})})]})},m.key),v<d.length-1&&h.jsxs("div",{className:"test",style:{textAlign:"center"},children:[" ",h.jsx(D.Divider,{style:{color:"orange"},dashed:!0,children:h.jsx(D.Tag,{color:"#1890ff",children:h.jsx(Te.FormattedMessage,{id:"link.flow.or"})})})]})]})),h.jsx(D.Form.Item,{style:{display:"flex",justifyContent:"flex-end",marginBlock:10},children:h.jsx(D.Button,{type:"default",icon:h.jsx(br,{size:16}),disabled:!u,onClick:()=>f({and_list:[{query:"",operator:"",value:""}]}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-or"})})})]})})})}),h.jsx("div",{className:"workflow-node-form-footer",children:u&&h.jsx(D.Button,{type:"primary",disabled:!u,loading:a,className:"workflow-node-form-save",onClick:()=>c(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),PG={copy:"Copy JSON",copySuccess:"JSON copied to clipboard",download:"Download JSON",invalidJson:"Invalid JSON data"},LG={copy:"复制JSON",copySuccess:"JSON已复制到剪贴板",download:"下载JSON",invalidJson:"无效的JSON数据"},{Text:$G}=D.Typography,zG=({data:t,height:e=400,enableCopy:n=!0,theme:r="light",className:o="",locale:i="zh",maxHeight:s})=>{const[a,l]=y.useState(r),c=y.useRef(null),u=i==="zh"?LG:PG,d=y.useMemo(()=>{if(!t)return null;try{return typeof t=="string"?JSON.parse(t):t}catch(w){return console.error("JSON解析失败:",w),null}},[t]),f=y.useMemo(()=>{if(!d)return[];const w=(g,C=[],k=0)=>{const _=[];if(g===null)return[{key:C.join("."),value:null,type:"null",path:C,level:k}];if(Array.isArray(g)){const S={key:C.join("."),value:g,type:"array",path:C,level:k,children:[]};g.forEach((E,x)=>{var T;const O=[...C,x.toString()],A=w(E,O,k+1);(T=S.children)==null||T.push(...A)}),_.push(S)}else if(typeof g=="object"){const S={key:C.join("."),value:g,type:"object",path:C,level:k,children:[]};Object.entries(g).forEach(([E,x])=>{var T;const O=[...C,E],A=w(x,O,k+1);(T=S.children)==null||T.push(...A)}),_.push(S)}else{const S=typeof g;_.push({key:C.join("."),value:g,type:S,path:C,level:k})}return _};return w(d)},[d]),p=y.useCallback(()=>{const w=JSON.stringify(d,null,2);navigator.clipboard.writeText(w).then(()=>{D.message.success(u.copySuccess)})},[d,u]),m=y.useCallback(()=>{const w=JSON.stringify(d,null,2),g=new Blob([w],{type:"application/json"}),C=URL.createObjectURL(g),k=document.createElement("a");k.href=C,k.download="data.json",k.click(),URL.revokeObjectURL(C)},[d]),v=y.useCallback(w=>{switch(w.type){case"string":return h.jsxs("span",{className:"json-string",children:['"',String(w.value),'"']});case"number":return h.jsx("span",{className:"json-number",children:String(w.value)});case"boolean":return h.jsx("span",{className:"json-boolean",children:String(w.value)});case"null":return h.jsx("span",{className:"json-null",children:"null"});default:return null}},[]),b=y.useCallback((w,g)=>{var _;const C=w.children&&w.children.length>0,k=w.path[w.path.length-1];return w.type==="object"||w.type==="array"?h.jsxs("div",{className:"json-node",children:[h.jsxs("div",{className:"json-line",style:{paddingLeft:`${w.level*16}px`},children:[k&&h.jsxs("span",{className:"json-key",children:['"',k,'": ']}),h.jsx("span",{className:"json-bracket",children:w.type==="array"?"[":"{"}),!C&&h.jsx("span",{className:"json-bracket",children:w.type==="array"?"]":"}"})]}),C&&h.jsxs(h.Fragment,{children:[(_=w.children)==null?void 0:_.map((S,E)=>b(S,g+E+1)),h.jsx("div",{className:"json-line",style:{paddingLeft:`${w.level*16}px`},children:h.jsx("span",{className:"json-bracket",children:w.type==="array"?"]":"}"})})]})]},w.key):h.jsx("div",{className:"json-node",children:h.jsxs("div",{className:"json-line",style:{paddingLeft:`${w.level*16}px`},children:[k&&h.jsxs("span",{className:"json-key",children:['"',k,'": ']}),v(w)]})},w.key)},[v]);return y.useCallback(()=>{l(a==="dark"?"light":"dark")},[a]),d?h.jsxs("div",{className:`json-renderer ${a} ${o}`,children:[h.jsx("div",{className:"json-toolbar",children:h.jsxs(D.Space,{children:[n&&h.jsx(D.Tooltip,{title:u.copy,children:h.jsx(D.Button,{icon:h.jsx(se.CopyOutlined,{}),size:"small",onClick:p})}),h.jsx(D.Tooltip,{title:u.download,children:h.jsx(D.Button,{icon:h.jsx(se.DownloadOutlined,{}),size:"small",onClick:m})})]})}),h.jsx("div",{ref:c,className:"json-content",style:{height:`${e}px`,maxHeight:s?`${s}px`:void 0},children:f.map((w,g)=>b(w,g))})]}):h.jsx("div",{className:`json-renderer error ${a} ${o}`,children:h.jsx("div",{className:"error-message",children:h.jsx($G,{type:"secondary",children:u.invalidJson})})})},{TextArea:HG}=D.Input,{Title:VG}=D.Typography,iO=({status:t,result:e="",progress:n=60,runningAction:r="run",showAlert:o=!0,canEdit:i=!0,disabledReason:s="当前节点不支持手动测试",editing:a=!1,editableValue:l="",onEditableValueChange:c,onRun:u,onIgnore:d,onReset:f,onToggleEdit:p,onDismissAlert:m,className:v,onClose:b,onExpandPanel:w})=>{const g=t==="running",C=t==="failure",k=t==="ignored",_=t==="success"||k,S=t==="disabled",[E,x]=y.useState(!1);return h.jsxs("section",{className:["node-test-container","ai-flow-node-test-panel",v].filter(Boolean).join(" "),"aria-label":"AI FLOW 节点测试",children:[h.jsx("div",{className:"node-test-header",children:h.jsxs("div",{className:"header-title",children:[h.jsx("span",{className:"common-icon title-icon"}),h.jsx(VG,{level:4,children:"节点测试"}),h.jsx(D.Button,{ghost:!0,className:"close-btn",onClick:b,children:h.jsx(Di,{size:16})})]})}),h.jsxs("div",{className:"test-content",children:[i&&!S?h.jsxs("div",{className:"action-buttons",children:[h.jsx(D.Button,{type:"primary",disabled:S,onClick:u,loading:g&&r==="run",className:"test-button",children:g?"测试中...":"开始测试"}),h.jsx(D.Button,{type:"default",disabled:S||g&&r==="run",onClick:d,loading:g&&r==="ignore",className:"ignore-button",children:"忽略调试"})]}):null,i&&e?h.jsx("div",{className:"action-buttons",children:h.jsx(D.Button,{onClick:f,className:"reset-button",children:"重置"})}):null,g?h.jsxs(h.Fragment,{children:[h.jsx(D.Progress,{percent:n,status:"active",className:"test-progress"}),h.jsx(D.Skeleton,{active:!0,className:"result-skeleton"})]}):h.jsxs(h.Fragment,{children:[C&&o?h.jsx(D.Alert,{className:"error-alert small",showIcon:!0,message:"测试未通过",description:"请检查节点配置和接口返回后重试",type:"error",closable:!1,onClose:m}):null,_&&o?h.jsx(D.Alert,{className:"success-alert small",showIcon:!0,message:k?"忽略调试成功":"测试成功",description:k?"已将样本数据设为当前节点输出":"节点运行正常,可在下方查看返回结果",type:"success",closable:!1,onClose:m}):null,e?h.jsx(D.Card,{styles:{body:{padding:0}},title:h.jsxs("div",{className:"result-header",children:[h.jsx("div",{className:"result-title",children:C?h.jsxs(h.Fragment,{children:[h.jsx(se.CloseCircleFilled,{className:"error-icon"})," 错误数据"]}):h.jsxs(h.Fragment,{children:[k?h.jsx(se.ExperimentFilled,{className:"success-icon"}):h.jsx(se.CheckCircleFilled,{className:"success-icon"}),k?"样本数据":"测试结果"]})}),h.jsxs("div",{style:{display:"inline-flex",gap:8},children:[i&&p?h.jsx(D.Button,{size:"small",type:"default",variant:"solid",onClick:p,className:"edit-button",children:a?"完成":"编辑"}):null,w&&h.jsx(D.Button,{size:"small",type:E?"primary":"default",variant:"solid",className:"edit-button",onClick:()=>{const O=!E;w(O),x(O)},children:E?h.jsx(SW,{size:16}):h.jsx(kW,{size:16})})]})]}),variant:"borderless",className:`result-card ${C?"error-result":"success-result"}`,children:a?h.jsx(HG,{rows:E?20:10,value:l,onChange:O=>c==null?void 0:c(O.target.value),className:"result-editor"}):h.jsx(zG,{data:e,height:E?600:300,enableCopy:!0,theme:"dark"},e)}):h.jsx(D.Card,{variant:"borderless",className:"empty-result",children:h.jsx(D.Result,{icon:h.jsx("span",{className:"common-icon"}),title:S?"不可测试":"等待测试",subTitle:S?s:"点击“开始测试”按钮运行当前节点"})})]})]})]})},jG=new Set([$e.AI_LANGUAGE_MODEL,$e.AI_MEMORY,$e.BUILTIN_MCP,$e.MCP_SERVER]),WG=new Set([]),UG=({canEdit:t,nodeType:e,protocol:n})=>t?n&&jG.has(n)?{disabled:!0,reason:"当前协议节点由所属 AI 或 MCP 运行上下文统一测试"}:e&&WG.has(e)?{disabled:!0,reason:"当前节点类型不支持独立手动测试"}:{disabled:!1}:{disabled:!0,reason:"只读或预览模式下不能执行节点测试"},qG=t=>typeof t=="string"?t.trim().length>0:t!=null,GG=t=>typeof t=="string"&&t.trim().toLowerCase()==="success",RG=t=>{if(!t||typeof t!="object")return!1;const e=t;return e.result===!0?!1:e.result===!1?!0:e.error==="0"&&qG(e.error_description)&&!GG(e.error_description)},KG=t=>RG(t)?me.FAILED:me.SUCCESS,YG=t=>{if(typeof t=="object")return JSON.stringify(t,null,2);if(typeof t=="string")try{const e=JSON.parse(t);return JSON.stringify(e,null,2)}catch{return t}return String(t)};JSON.stringify({result:"示例数据",data:{id:"123",name:"示例"}},null,2);const XG=y.forwardRef((t,e)=>{var O,A,T,B;const{nodeId:n,beforeHook:r,onClose:o,onExpandPanel:i}=t,s=$t(),{handleNodeDataUpdate:a}=Ri(),l=(A=(O=s.nodeConfigPanel)==null?void 0:O.testArea)==null?void 0:A.defaultTestResult,[c,u]=y.useState(()=>{if(l==null)return"";if(typeof l=="string")return l;try{return JSON.stringify(l,null,2)}catch{return String(l)}}),d=ne.useInternalNode(n),f=Et.useReactive({testProgress:0,sampleText:"",isError:!1,showErrorAlert:!1,testing:!1,successShown:!1,sampleMode:!1,sampleSaving:!1,sampleError:"",isIgnoreSuccess:!1,ignoring:!1,editable:!1}),{refreshFlow:p}=ao();(T=d==null?void 0:d.data)==null||T.outputSource,y.useEffect(()=>{if(d!=null&&d.data.output&&(d.data.status===me.SUCCESS||d.data.status===me.RUNNABLE)){const I=typeof d.data.output=="string"?d.data.output:JSON.stringify(d.data.output,null,2);u(I),f.successShown=!0,f.isError=!1,f.showErrorAlert=!1}else if(d!=null&&d.data.output&&d.data.status===me.FAILED){const I=typeof d.data.output=="string"?d.data.output:JSON.stringify(d.data.output,null,2);u(I),f.isError=!0,f.showErrorAlert=!0,f.successShown=!1}},[d,f]);const m=y.useCallback(()=>{if(!n){console.error("节点ID不能为空");return}f.testing=!0,f.testProgress=60,f.successShown=!1,f.isError=!1,f.showErrorAlert=!1,f.sampleMode=!1,By(n).then(I=>{const F=I,N=KG(F),P=N===me.FAILED;f.isError=P,f.successShown=!P,f.showErrorAlert=f.isError;let M="";try{M=YG(F)}catch(z){console.error("格式化测试结果出错:",z),M=`测试结果格式化失败: ${String(z)}`}f.testProgress=100,u(M),a({id:n,data:{status:N,output:M,outputSource:"test"}})}).catch(I=>{var P;console.error("测试失败:",I),f.testProgress=0,f.isError=!0,f.showErrorAlert=!0,f.successShown=!1;let F="测试执行失败";(P=I==null?void 0:I.response)!=null&&P.data?F=JSON.stringify(I.response.data,null,2):I!=null&&I.message&&(F=I.message);const N=JSON.stringify({error:F},null,2);u(N),a({id:n,data:{status:me.FAILED,output:N,outputSource:"test"}})}).finally(()=>{setTimeout(()=>{f.testProgress=0,f.testing=!1},500)})},[a,n,f]),v=()=>{f.testProgress=0,f.testing=!1,f.sampleSaving=!1,f.sampleMode=!1,f.successShown=!0,f.isError=!1,f.showErrorAlert=!1},b=()=>{r&&(f.testing=!0,f.ignoring=!0,f.testProgress=60,r(!0,!0,f.sampleText))},w=()=>{f.sampleSaving=!1,f.ignoring=!1,f.successShown=!0,f.isError=!1,f.showErrorAlert=!1,f.isIgnoreSuccess=!0},g=()=>{f.testProgress=0,f.testing=!1,f.ignoring=!1,f.isIgnoreSuccess=!0};y.useImperativeHandle(e,()=>({onTestNode:m,finishSampleTest:v,abortSampleTest:w,finishNodeTest:g}));const C=()=>{f.sampleMode=!1,r?r(!0):m()},k=()=>{u(""),f.sampleText="",f.sampleMode=!1,f.sampleError="",f.successShown=!1},_=Ot(),S=y.useMemo(()=>{var I;return UG({canEdit:_,nodeType:d==null?void 0:d.type,protocol:(I=d==null?void 0:d.data)==null?void 0:I.protocol})},[_,(B=d==null?void 0:d.data)==null?void 0:B.protocol,d==null?void 0:d.type]),E=S.disabled?"disabled":f.testing?"running":f.isError?"failure":f.successShown?f.isIgnoreSuccess?"ignored":"success":"waiting",x=()=>{if(f.editable){f.editable=!1;try{const I=JSON.parse(f.sampleText),F=JSON.stringify(I,null,2);u(F),a({id:n,data:{output:F}})}catch{u(f.sampleText)}return}f.sampleText=c,f.editable=!0};return h.jsx(iO,{status:E,result:c,progress:f.testProgress||60,runningAction:f.ignoring?"ignore":"run",showAlert:f.isError?f.showErrorAlert:f.successShown,canEdit:_,disabledReason:S.reason,editing:f.editable,editableValue:f.sampleText,onEditableValueChange:I=>{f.sampleText=I},onRun:C,onIgnore:b,onReset:k,onToggleEdit:x,onDismissAlert:()=>{f.showErrorAlert=!1,f.successShown=!1},onClose:o,onExpandPanel:i})});var tr=(t=>(t.Array="ARRAY",t.Boolean="BOOLEAN",t.Null="NULL",t.Number="NUMBER",t.Object="OBJECT",t.String="STRING",t))(tr||{});const sw={ARRAY:"purple",BOOLEAN:"green",NULL:"default",NUMBER:"blue",OBJECT:"cyan",STRING:"orange"},JG={ARRAY:"Arr",BOOLEAN:"Bool",NULL:"Null",NUMBER:"Num",OBJECT:"Obj",STRING:"Str"},aw=(t,e=!1)=>{const n=String(t||"STRING").toUpperCase(),r=JG[n]||n.slice(0,4);return e?`${r}[]`:r},sO=t=>{t!=null&&t.length&&t.forEach(e=>{e.label||(e.label=e.name),Array.isArray(e.sub_params)?sO(e.sub_params):e.sub_params=[]})},QG=t=>{const e=t==null?void 0:t.map(r=>(r.output.label=`${r.seq}-${r.connector_name} : ${r.action_name}`,r.note&&(r.output.label+=`(${r.note})`),{...r,label:`${r.connector_name}-${r.action_name}`,sub_params:[r.output]})),n=Pt.cloneDeep(e);return sO(n),n};var aO=(t=>(t.TEXT="TEXT",t.NUMBER="NUMBER",t.JSON="JSON",t))(aO||{});const ZG=t=>({TEXT:"STRING",NUMBER:"NUMBER",JSON:"OBJECT"})[t]||"STRING",eR=t=>{const{nodeId:e,flowId:n,enabled:r=!0,includeGlobalVariables:o=!0}=t,i=ne.useStoreApi(),[s,a]=y.useState([]),[l,c]=y.useState([]),[u,d]=y.useState(!1),[f,p]=y.useState(null),[m,v]=y.useState(0),[b,w]=y.useState(!1),[g,C]=y.useState(null),[k,_]=y.useState(0),S=y.useCallback(()=>{v(T=>T+1)},[]),E=y.useCallback(()=>{_(T=>T+1)},[]),x=y.useCallback(()=>{v(T=>T+1),_(T=>T+1)},[]);return y.useEffect(()=>{if(!r||!o){o||a([]),d(!1),p(null);return}let T=!1;return(async()=>{d(!0),p(null);try{const I=await Py();if(T)return;const F=((I==null?void 0:I.items)||[]).map(N=>({...N,mappedType:ZG(N.var_type)}));a(N=>Pt.isEqual(N,F)?N:F)}catch(I){console.error("Failed to fetch global variables:",I),T||p(I instanceof Error?I:new Error("无法获取全局变量数据"))}finally{T||d(!1)}})(),()=>{T=!0}},[r,o,m]),y.useEffect(()=>{if(!r||!n){w(!1),C(null);return}let T=!1;return(async()=>{w(!0),C(null);try{const{edges:I,nodes:F}=i.getState(),N=await Iy(n,{nodeId:e,edges:I});if(T)return;const P=new Map(F.map(H=>[H.id,H])),z=(QG(N)||[]).map(H=>{var $,j;const R=($=H.node_id)!=null&&$.startsWith("N")?H.node_id.slice(1):H.node_id,Y=R?P.get(R):void 0,te=typeof((j=Y==null?void 0:Y.data)==null?void 0:j.icon)=="string"?Y.data.icon:void 0;return{...H,nodeIcon:te,isValid:!!Y}});c(H=>Pt.isEqual(H,z)?H:z)}catch(I){console.error("Failed to fetch node variables:",I),T||C(I instanceof Error?I:new Error("无法获取节点变量数据"))}finally{T||w(!1)}})(),()=>{T=!0}},[n,e,r,k,i]),{globalVariables:s,nodeVariables:l,isLoading:u||b,isGlobalLoading:u,isNodeLoading:b,error:f||g,globalError:f,nodeError:g,refresh:x,refreshGlobal:S,refreshNode:E}},it={container:"_container_1f6qh_5",header:"_header_1f6qh_29",headerIcon:"_headerIcon_1f6qh_37",headerTitle:"_headerTitle_1f6qh_41",body:"_body_1f6qh_46",section:"_section_1f6qh_61",sectionLabel:"_sectionLabel_1f6qh_65",sectionIcon:"_sectionIcon_1f6qh_79",typeTag:"_typeTag_1f6qh_88",varItem:"_varItem_1f6qh_97",varName:"_varName_1f6qh_115",varValue:"_varValue_1f6qh_121",nodeTitle:"_nodeTitle_1f6qh_129",nodeIcon:"_nodeIcon_1f6qh_134",nodeLabelFirst:"_nodeLabelFirst_1f6qh_139",nodeLabel:"_nodeLabel_1f6qh_139",leafTitle:"_leafTitle_1f6qh_151",leafLabel:"_leafLabel_1f6qh_156",leafValue:"_leafValue_1f6qh_162",empty:"_empty_1f6qh_168",loadingState:"_loadingState_1f6qh_172",errorState:"_errorState_1f6qh_181",invalidVariable:"_invalidVariable_1f6qh_185",nodeIconWrapper:"_nodeIconWrapper_1f6qh_194",defaultNodeIcon:"_defaultNodeIcon_1f6qh_207"},lw={VariableModalTitle:h.jsx(Te.FormattedMessage,{id:"app.common.word.select-variable"}),NoTestDataDesc:h.jsx(Te.FormattedMessage,{id:"common.no-process-variables-yet"})},tR=t=>{if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="object")try{return JSON.stringify(t)}catch{return String(t)}return String(t)},nR=(t,e)=>{const n=t.trim(),r=n.startsWith("N")?n:`N${n}`,o=e.slice(1).join(".");return o?`{{${r}.${o}}}`:`{{${r}}}`},lO=y.forwardRef((t,e)=>{const n=El(),{nodeId:r,showGlobalVariables:o=!0}=t,{event$:i}=y.useContext(Qr),{globalVariables:s,nodeVariables:a,isGlobalLoading:l,isNodeLoading:c,globalError:u,nodeError:d,refreshGlobal:f,refreshNode:p}=eR({nodeId:r,flowId:n,enabled:t.open,includeGlobalVariables:o}),m=Et.useReactive({currentInputId:"",visible:!0});i.useSubscription(w=>{switch(w.type){case"visible":m.visible||(f(),p()),m.visible=w.visible;break;case"setCurrentInputId":m.currentInputId=w.currentInputId;break}}),y.useImperativeHandle(e,()=>({loadVariables:()=>{f(),p()}}));const v=w=>{try{const g=typeof w=="string"?JSON.parse(w):w,C=(_,S)=>{if(_==null)return{name:S,type:tr.Null,label:S,multi_valued:!1,sub_params:[],value:String(_)};if(typeof _=="object"&&!Array.isArray(_)){const x=_;return{name:S,type:tr.Object,label:S,multi_valued:!1,sub_params:Object.keys(x).map(O=>C(x[O],O)),value:null}}if(Array.isArray(_)){const x=_[0],O=x&&typeof x=="object"?tr.Object:typeof x=="number"?tr.Number:typeof x=="boolean"?tr.Boolean:x==null?tr.Array:tr.String;return{name:S,type:O,label:S,multi_valued:!0,sub_params:[],value:JSON.stringify(_)}}const E=typeof _=="number"?tr.Number:typeof _=="boolean"?tr.Boolean:tr.String;return{name:S,type:E,label:S,multi_valued:!1,sub_params:[],value:String(_)}},k=g&&typeof g=="object"&&!Array.isArray(g)?g:{};return Object.keys(k).map(_=>C(k[_],_))}catch{return[]}},b=(w,g,C,k,_,S=[],E="0")=>(w??[]).map((x,O)=>{var I;const A=[...S,x.name],T=`${E}-${O}`;return(I=x.sub_params)!=null&&I.length?{key:T,variablePath:A,title:h.jsxs("span",{className:`${it.nodeTitle}${k===!1?` ${it.invalidVariable}`:""}`,children:[g?_==="api"?h.jsx(se.ApiOutlined,{className:it.nodeIcon}):h.jsx("span",{className:it.nodeIconWrapper,children:C?h.jsx("img",{src:C,alt:""}):h.jsx("span",{className:it.defaultNodeIcon,children:"N"})}):h.jsx(D.Tag,{color:sw[x.type]||"gray",className:`${it.typeTag} workflow-variable-panel__type`,children:aw(x.type,x.multi_valued)}),h.jsx("span",{className:`${g?it.nodeLabelFirst:it.nodeLabel} workflow-variable-panel__label`,children:x.label})]}),children:b(x.sub_params,!1,C,k,_,A,T)}:{key:T,variablePath:A,title:h.jsxs("span",{className:`${it.leafTitle}${k===!1?` ${it.invalidVariable}`:""}`,children:[h.jsx(D.Tag,{color:sw[x.type]||"gray",className:`${it.typeTag} workflow-variable-panel__type`,children:aw(x.type,x.multi_valued)}),h.jsx("span",{className:`${it.leafLabel} workflow-variable-panel__label`,children:x.label}),x.value?h.jsx("span",{className:it.leafValue,children:x.value}):null]})}});return h.jsxs("div",{className:`${it.container} workflow-variable-panel`,children:[h.jsxs("div",{className:`${it.header} workflow-variable-panel__header`,children:[h.jsx(CW,{size:16,className:`${it.headerIcon} workflow-variable-panel__header-icon`}),h.jsx("span",{className:`${it.headerTitle} workflow-variable-panel__title`,children:lw.VariableModalTitle})]}),h.jsxs("div",{className:`${it.body} workflow-variable-panel__body`,children:[o?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:`${it.sectionLabel} workflow-variable-panel__section-label`,children:[h.jsx(se.GlobalOutlined,{className:it.sectionIcon,size:32}),h.jsx("span",{children:"全局变量"})]}),h.jsx("div",{className:`variable-panel-group ${!l&&!u&&s.length<1?"empty":""}`,children:h.jsxs("div",{className:it.section,children:[s.map(w=>{if(w.var_type===aO.JSON){const k=v(w.var_value??{}),_=[{name:w.name,type:tr.Object,label:w.display_name||w.name,multi_valued:!1,sub_params:k,value:null}],S=b(_,!0,void 0,!0,"api");return h.jsx(D.Tree,{defaultExpandAll:!0,showLine:!0,onSelect:(E,x)=>{const O=x.node.variablePath;i.emit({type:"insert",currentInputId:m.currentInputId,expression:`{{global.${O.join(".")}}}`})},switcherIcon:h.jsx(se.CaretDownOutlined,{}),treeData:S},w.id)}const g=tR(w.var_value),C=g.length>28?`${g.substring(0,28)}...`:g;return h.jsxs("button",{type:"button",className:`${it.varItem} workflow-variable-panel__item`,onClick:()=>{i.emit({type:"insert",currentInputId:m.currentInputId,expression:`{{global.${w.name}}}`})},children:[h.jsx(D.Tag,{color:sw[w.mappedType],className:`${it.typeTag} workflow-variable-panel__type`,children:aw(w.mappedType)}),h.jsx("span",{className:`${it.varName} workflow-variable-panel__label`,children:w.display_name||w.name}),C?h.jsx("span",{className:it.varValue,children:C}):null]},w.id)}),!l&&!u&&s.length<1&&h.jsx(D.Empty,{image:D.Empty.PRESENTED_IMAGE_SIMPLE,description:lw.NoTestDataDesc,className:it.empty}),l?h.jsxs("div",{className:it.loadingState,children:[h.jsx(D.Spin,{size:"small"}),h.jsx("span",{children:"正在加载全局变量"})]}):u?h.jsx(D.Alert,{className:it.errorState,type:"error",showIcon:!0,message:"全局变量加载失败",description:u.message,action:h.jsx(D.Button,{size:"small",onClick:f,children:"重试"})}):null]})})]}):null,h.jsxs("div",{className:`${it.sectionLabel} workflow-variable-panel__section-label`,children:[h.jsx(se.ApiOutlined,{className:it.sectionIcon}),h.jsx("span",{children:"节点变量"})]}),h.jsx("div",{className:`variable-panel-group ${!c&&!d&&a.length<1?"empty":""}`,children:h.jsxs("div",{className:it.section,children:[a.map(w=>h.jsx("div",{children:h.jsx(D.Tree,{defaultExpandAll:!0,showLine:!0,onSelect:(g,C)=>{const k=C.node.variablePath;if(k.length<=1)return!1;i.emit({type:"insert",currentInputId:m.currentInputId,expression:nR(w.node_id,k)})},switcherIcon:h.jsx(se.CaretDownOutlined,{}),treeData:b(w.sub_params,!0,w.nodeIcon,w.isValid,"node")})},`${w.node_id}-${w.seq}`)),!c&&!d&&a.length<1&&h.jsx(D.Empty,{image:D.Empty.PRESENTED_IMAGE_SIMPLE,description:lw.NoTestDataDesc,className:it.empty}),c?h.jsxs("div",{className:it.loadingState,children:[h.jsx(D.Spin,{size:"small"}),h.jsx("span",{children:"正在加载节点变量"})]}):d?h.jsx(D.Alert,{className:it.errorState,type:"error",showIcon:!0,message:"节点变量加载失败",description:d.message,action:h.jsx(D.Button,{size:"small",onClick:p,children:"重试"})}):null]})})]})]})}),{Option:Po}=D.Select,rR=y.forwardRef(({onSubmit:t,config_schema:e,nodeId:n},r)=>{const[o]=D.Form.useForm(),i=xl(),s=D.Form.useWatch("type",o);Et.useMount(()=>{e&&Object.hasOwn(e,"asc")&&o.setFieldsValue(e)});const[a,l]=y.useState(!1),c=(d,f,p="")=>(l(!0),o.validateFields().then(async m=>s&&s==="NUMBER"&&m.start>m.end?D.message.warning(K("link.flow.loop_start_end_check")):t({properties:m},d)).catch(()=>(D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>l(!1)));y.useImperativeHandle(r,()=>({saveConfig:d=>c(d)}));const u=Ot();return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:i,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsxs(D.Form,{disabled:!u,form:o,layout:"vertical",children:[h.jsxs(D.Row,{children:[h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{name:"type",label:K("app.common.word.loop-data-type"),rules:[{required:!0,message:K("link.flow.please_select_data_type")}],children:h.jsxs(D.Select,{children:[h.jsx(Po,{value:"ARRAY",children:h.jsx(Te.FormattedMessage,{id:"link.flow.array"})}),h.jsx(Po,{value:"NUMBER",children:h.jsx(Te.FormattedMessage,{id:"common.number"})}),h.jsx(Po,{value:"CONDITION",children:h.jsx(Te.FormattedMessage,{id:"link.flow.condition_expression"})})]})})}),s&&s==="NUMBER"&&h.jsx(D.Col,{sm:24,lg:12,children:h.jsxs(D.Form.Item,{required:!0,label:K("link.flow.loop_start_end"),style:{display:"flex"},children:[h.jsx(D.Form.Item,{name:"start",noStyle:!0,rules:[{required:!0,message:K("link.flow.please_select_data_type")}],children:h.jsx(D.InputNumber,{min:1,style:{marginRight:20}})}),h.jsx(D.Form.Item,{name:"end",noStyle:!0,rules:[{required:!0,message:K("link.flow.please_select_data_type")}],children:h.jsx(D.InputNumber,{min:1})})]})}),s&&s!=="NUMBER"&&h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{rules:[{required:!0,message:K("link.flow.please_enter_loop_expression")}],label:K("link.flow.loop_expression"),name:"expression",children:h.jsx(Pn,{nodeId:n,borrow:!0,valueType:"JS_EXP",placeholder:K("link.flow.please_enter_loop_expression")})})}),!s&&h.jsx(D.Col,{})]}),h.jsxs(D.Row,{children:[h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{name:"asc",label:K("app.common.word.circulation-direction"),rules:[{required:!0,message:K("link.flow.please_select_loop_direction")}],children:h.jsxs(D.Select,{children:[h.jsx(Po,{value:!0,children:h.jsx(Te.FormattedMessage,{id:"link.flow.loop_head_to_tail"})}),h.jsx(Po,{value:!1,children:h.jsx(Te.FormattedMessage,{id:"link.flow.loop_tail_to_head"})})]})})}),h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{name:"errorExec",label:K("link.flow.loop_processing"),rules:[{required:!0,message:K("link.flow.please_select_loop_processing")}],children:h.jsxs(D.Select,{children:[h.jsx(Po,{value:"END",children:h.jsx(Te.FormattedMessage,{id:"link.flow.terminate_process"})}),h.jsx(Po,{value:"CONTINUE",children:h.jsx(Te.FormattedMessage,{id:"link.flow.continue_loop"})}),h.jsx(Po,{value:"BREAK",children:h.jsx(Te.FormattedMessage,{id:"link.flow.break_loop"})})]})})})]})]})}),h.jsx("div",{className:"workflow-node-form-footer",children:u&&h.jsx(D.Button,{type:"primary",disabled:!u,loading:a,className:"workflow-node-form-save",onClick:()=>c(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),Ud=()=>`branch_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,{Option:oR}=D.Select,iR=y.forwardRef((t,e)=>{const{config_schema:n,nodeId:r}=t,[o]=D.Form.useForm(),i=xl(),{handleNodeDataUpdate:s}=Ri(),[a,l]=y.useState(null),[c,u]=y.useState(""),f=(E=>!(E!=null&&E.branches)||E.branches.length===0?{branches:[{id:Ud(),name:K("link.flow.switch.condition_one"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]},{id:Ud(),name:K("link.flow.switch.condition_two"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]}]}:{branches:E.branches.map((O,A)=>{var T;return{id:O.id||Ud(),name:O.name||K("link.flow.switch.condition_n",{n:A+1}),or_list:((T=O.or_list)==null?void 0:T.map(B=>{var I;return{and_list:((I=B.and_list)==null?void 0:I.map(F=>({query:F.query||"",operator:F.operator||"",value:F.value||""})))||[{query:"",operator:"",value:""}]}}))||[{and_list:[{query:"",operator:"",value:""}]}]}})})(n),p=()=>{const E=o.getFieldValue("branches")||[];s({id:r,data:{config_schema:{branches:E}}})},m=(E,x)=>{l(E),u(x)},v=()=>{l(null),u("")},b=E=>{const x=Pt.cloneDeep(o.getFieldValue("branches"))||[],O=c.trim();if(!O){D.message.error(K("link.flow.switch.branch_name_cannot_be_empty"));return}if(x.some((T,B)=>B!==E&&T.name===O)){D.message.error(K("link.flow.switch.branch_name_duplicate"));return}x[E].name=O,o.setFieldValue("branches",x),l(null),u(""),p()},w=(E,x)=>{const O=o.getFieldValue("branches")||[];if(x<0||x>=O.length)return;const A=[...O],[T]=A.splice(E,1);A.splice(x,0,T),o.setFieldValue("branches",A),p()},[g,C]=y.useState(!1),k=E=>(C(!0),o.validateFields().then(async x=>{if(!x.branches.some(T=>T.or_list.some(B=>B.and_list.some(I=>I.query&&I.operator)))){D.message.error(K("link.flow.switch.at_least_one_valid_branch"));return}const A=Pt.cloneDeep(x);return A.branches.forEach(T=>{T.or_list.forEach(B=>{B.and_list.forEach(I=>{I.value=FG(I.operator,I.value)})})}),t.onSubmit({properties:A},E)}).catch(()=>(D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>C(!1)));y.useImperativeHandle(e,()=>({saveConfig:E=>k(E)}));const _=Ot(),S=(E,x,O,A)=>{const B=(o.getFieldValue("branches")||[])[x],I=a===x;return h.jsxs(D.Card,{style:{marginBottom:20,borderRadius:8,border:"1px solid #d9d9d9"},styles:{body:{padding:10}},children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:12},children:[h.jsx("div",{style:{display:"flex",alignItems:"center",flex:1},children:I?h.jsxs(D.Space,{children:[h.jsx(D.Input,{value:c,onChange:F=>u(F.target.value),style:{width:200},placeholder:K("link.flow.switch.enter_branch_name"),onPressEnter:()=>b(x)}),h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.CheckOutlined,{style:{color:"#52c41a"}}),onClick:()=>b(x)}),h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.CloseOutlined,{}),onClick:v})]}):h.jsxs(D.Space,{children:[h.jsx("span",{style:{fontSize:13,fontWeight:400},children:(B==null?void 0:B.name)||K("link.flow.switch.condition_n",{n:x+1})}),_&&h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.EditOutlined,{}),onClick:()=>m(x,(B==null?void 0:B.name)||"")})]})}),_&&h.jsxs(D.Space,{className:"actions",children:[h.jsx(D.Tooltip,{title:K("link.flow.switch.move_to_top"),children:h.jsx(D.Button,{type:"text",size:"small",disabled:x===0,onClick:()=>w(x,0),children:"置顶"})}),h.jsx(D.Tooltip,{title:K("link.flow.switch.move_up"),children:h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.ArrowUpOutlined,{}),disabled:x===0,onClick:()=>w(x,x-1)})}),h.jsx(D.Tooltip,{title:K("link.flow.switch.move_down"),children:h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.ArrowDownOutlined,{}),disabled:x===O-1,onClick:()=>w(x,x+1)})}),h.jsx(D.Tooltip,{title:K("link.flow.switch.move_to_bottom"),children:h.jsx(D.Button,{type:"text",size:"small",disabled:x===O-1,onClick:()=>w(x,O-1),children:"置底"})}),h.jsx(D.Tooltip,{title:K("common.delete"),children:h.jsx(D.Button,{type:"text",size:"small",disabled:O<=1,onClick:()=>{if(O<=1){D.message.warning(K("link.flow.switch.at_least_one_branch"));return}A(E.name),setTimeout(()=>{p()},0)},children:"删除"})})]})]}),h.jsx(D.Form.Item,{name:[E.name,"name"],hidden:!0,children:h.jsx(D.Input,{})}),h.jsx(D.Form.List,{name:[E.name,"or_list"],children:(F,{add:N,remove:P})=>h.jsx(h.Fragment,{children:F.map((M,z)=>{const H=z===F.length-1;return h.jsx(h.Fragment,{children:h.jsxs("div",{className:"switch-rule",children:[F.length>1&&_&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsxs(D.Button,{type:"link",icon:h.jsx(se.MinusCircleOutlined,{}),onClick:()=>P(M.name),children:[h.jsx(Te.FormattedMessage,{id:"link.flow.remove"})," OR"]})}),h.jsx(D.Form.List,{name:[M.name,"and_list"],children:(R,{add:Y,remove:te})=>h.jsx(h.Fragment,{children:R.map(($,j)=>{const U=j===R.length-1;return h.jsxs(D.Space,{direction:"vertical",style:{width:"100%"},children:[h.jsxs(D.Space,{align:"center",className:"switch-rule-item",children:[h.jsx(D.Form.Item,{style:{minWidth:150,marginBottom:0},name:[$.name,"query"],label:K("app.common.word.variable-name"),rules:[{required:!0,message:K("link.flow.please_enter_variable_name")}],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),h.jsx(D.Form.Item,{style:{marginBottom:0},name:[$.name,"operator"],label:K("app.common.word.condition"),rules:[{required:!0,message:K("link.flow.please_select_condition")}],children:h.jsx(D.Select,{style:{minWidth:140},placeholder:K("link.flow.select_condition"),getPopupContainer:()=>document.body,children:oO.map(ee=>h.jsx(oR,{value:ee.operator,children:ee.label},ee.operator))})}),h.jsx(D.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const ee=o.getFieldValue(["branches",E.name,"or_list",M.name,"and_list",$.name,"operator"]);return iw(ee)?null:h.jsx(D.Form.Item,{style:{minWidth:150,marginBottom:0},name:[$.name,"value"],label:K("app.common.word.value"),rules:[],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),j===0&&h.jsx("div",{style:{width:30}}),j>0&&_&&h.jsx(D.Button,{type:"link",icon:h.jsx(se.MinusCircleOutlined,{}),onClick:()=>te($.name)})]}),j<R.length-1&&h.jsx(D.Divider,{plain:!0,style:{margin:"8px 0"},children:h.jsx(D.Tag,{color:"#999999",children:h.jsx(Te.FormattedMessage,{id:"link.flow.and"})})}),h.jsxs("div",{className:`rule-opt-actions ${U?"last-and-rule":""}`,children:[j===R.length-1&&h.jsx(D.Button,{type:"link",disabled:!_,icon:h.jsx(br,{size:14}),onClick:()=>Y({query:"",operator:"",value:""}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-new-and"})}),H&&h.jsx(D.Button,{type:"link",icon:h.jsx(br,{size:14}),disabled:!_,onClick:()=>N({and_list:[{query:"",operator:"",value:""}]}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-or"})})]})]},$.key)})})}),!H&&h.jsx("div",{style:{textAlign:"center"},children:h.jsx(D.Divider,{style:{color:"orange"},dashed:!0,children:h.jsx(D.Tag,{color:"#1890ff",children:h.jsx(Te.FormattedMessage,{id:"link.flow.or"})})})})]},M.key)})})})})]},E.key)};return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:i,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsx(D.Form,{disabled:!_,form:o,initialValues:f,layout:"vertical",autoComplete:"off",children:h.jsx(D.Form.List,{name:"branches",children:(E,{add:x,remove:O})=>h.jsxs(h.Fragment,{children:[E.map((A,T)=>S(A,T,E.length,O)),E.length<10&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end",width:"100%"},children:h.jsx(D.Button,{type:"default",icon:h.jsx(br,{size:14}),disabled:!_,onClick:()=>{const A=E.length+1;x({id:Ud(),name:K("link.flow.switch.condition_n",{n:A}),or_list:[{and_list:[{query:"",operator:"",value:""}]}]}),setTimeout(()=>{p()},0)},children:h.jsx(Te.FormattedMessage,{id:"link.flow.switch.add_branch"})})}),E.length>=10&&h.jsx("div",{style:{textAlign:"center",color:"#999",marginBottom:20},children:h.jsx(Te.FormattedMessage,{id:"link.flow.switch.max_branches_reached"})})]})})})}),h.jsx("div",{className:"workflow-node-form-footer",children:_&&h.jsx(D.Button,{type:"primary",disabled:!_,loading:g,className:"workflow-node-form-save",onClick:()=>k(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),sR=({nodeId:t,onSubmit:e,data:n})=>{const[r]=D.Form.useForm(),o=xl(),i=Ot(),{refreshFlow:s}=ao(),{setNodes:a}=ne.useReactFlow(),l=y.useCallback((u,d)=>{a(f=>f.map(p=>!d&&p.id!==t?p:{...p,data:{...p.data,error_handler:u}}))},[t,a]);y.useEffect(()=>{const u=(n==null?void 0:n.error_handler)||{};r.setFieldsValue({retryEnabled:u.retry||!1,retryCount:u.retry_times||3,retryInterval:u.retry_interval||5,stepFactor:u.step_factor||1.5,maxRetryInterval:u.max_retry_interval||60,alertEnabled:u.warn_type===1,webhookUrl:u.notify_url||"",errorHandling:u.process_type===2?"ignore":"interrupt",applyToAllNodes:!!u.apply_all})},[t,r,n==null?void 0:n.error_handler]);const c=async u=>{try{const d={retry:u.retryEnabled,retry_times:u.retryEnabled?u.retryCount:void 0,retry_interval:u.retryEnabled?u.retryInterval:void 0,step_factor:u.retryEnabled?u.stepFactor:void 0,max_retry_interval:u.retryEnabled?u.maxRetryInterval:void 0,warn_type:u.alertEnabled?1:0,notify_url:u.alertEnabled?u.webhookUrl:void 0,process_type:u.errorHandling==="interrupt"?1:2,apply_all:u.applyToAllNodes};await rc(t,{error_handler:d}),l(d,u.applyToAllNodes),u.applyToAllNodes&&s(),e()}catch{D.message.error(K("common.save_failed"))}};return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:o,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsxs(jn.ProForm,{form:r,layout:"vertical",disabled:!i,submitter:!1,onFinish:c,children:[h.jsx(jn.ProFormSwitch,{name:"retryEnabled",label:K("app.common.word.enable-retry")}),h.jsx(jn.ProFormDependency,{name:["retryEnabled"],children:({retryEnabled:u})=>u?h.jsxs(h.Fragment,{children:[h.jsx(jn.ProFormDigit,{name:"retryCount",label:K("app.common.word.retry-count"),tooltip:K("app.common.word.retry-count-tooltip"),width:"xl",fieldProps:{min:1,max:10,precision:0,style:{width:"100%"}},rules:[{required:u,message:K("app.common.word.please-enter-retry-count")}]}),h.jsx(jn.ProFormDigit,{name:"retryInterval",label:K("app.common.word.retry-interval"),tooltip:K("app.common.word.retry-interval-tooltip"),fieldProps:{min:1,max:60,precision:0,style:{width:"100%"},addonAfter:"s"},rules:[{required:u,message:K("app.common.word.please-enter-retry-interval")}]}),h.jsx(jn.ProFormDigit,{name:"stepFactor",label:K("app.common.word.step-factor"),tooltip:K("app.common.word.step-factor-tooltip"),width:"xl",fieldProps:{min:1,max:5,precision:1,style:{width:"100%"}},rules:[{required:u,message:K("app.common.word.please-enter-step-factor")}]}),h.jsx(jn.ProFormDigit,{name:"maxRetryInterval",label:K("app.common.word.max-retry-interval"),tooltip:K("app.common.word.max-retry-interval-tooltip"),width:"xl",fieldProps:{min:1,max:300,precision:0,style:{width:"100%"},addonAfter:"s"},rules:[{required:u,message:K("app.common.word.please-enter-max-retry-interval")}]})]}):null}),h.jsx(jn.ProFormSwitch,{name:"alertEnabled",label:K("app.common.word.enable-alert")}),h.jsx(jn.ProFormDependency,{name:["alertEnabled"],children:({alertEnabled:u})=>u?h.jsx(jn.ProFormText,{name:"webhookUrl",label:K("app.common.word.webhook-url"),placeholder:K("app.common.word.enter-webhook-url"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:u,message:K("app.common.word.enter-webhook-url")}]}):null}),h.jsx(jn.ProFormSelect,{name:"errorHandling",label:K("app.common.word.error-handling"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:!0,message:K("app.common.word.select-error-handling")}],options:[{label:K("app.common.word.interrupt-flow"),value:"interrupt"},{label:K("app.common.word.ignore-error"),value:"ignore"}]}),h.jsx(jn.ProFormSwitch,{name:"applyToAllNodes",label:K("app.common.word.apply-to-all-nodes")})]})}),h.jsx("div",{className:"workflow-node-form-footer",children:h.jsx(D.Button,{type:"primary",disabled:!i,onClick:()=>r.submit(),className:"workflow-node-form-save",children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})},cO="[workflow:schema-render]",aR=()=>{const{event$:t}=y.useContext(Qr),e=Fh();return t.useSubscription(n=>{var r;n.type==="insert"&&n.expression&&(r=e==null?void 0:e.getActiveFieldId)!=null&&r.call(e)&&e.insertVariableToActiveField(n.expression,!1)}),null},lR=({children:t})=>{const{event$:e}=y.useContext(Qr),n=Mh(),[r,o]=y.useState("");e.useSubscription(a=>{a.type==="setCurrentInputId"&&o(a.currentInputId??"")});const i=(n==null?void 0:n.activeFieldId)??r,s=y.useMemo(()=>({activeInputId:i}),[i]);return h.jsx(cx.Provider,{value:s,children:t})},cR=t=>{const{icon:e,fallbackIcon:n}=t;return h.jsxs("div",{className:"node-config-title",style:{display:"flex",alignItems:"center"},children:[h.jsx("div",{className:"node-config-icon",style:{backgroundImage:`url(${n?"none":e??"https://digitalsee-image.digitalsee.cn/flow/0.png"})`},children:n&&n}),h.jsxs("div",{className:"node-config-meta",children:[h.jsx("div",{className:"node-config-title-name",style:{fontSize:16,fontWeight:600,marginLeft:10},children:t.name}),h.jsx("div",{className:"node-config-title-description",style:{fontSize:12,color:"gray",marginLeft:10},children:t.description})]})]})},uR=y.memo(({visible:t,onClose:e,data:n,nodeType:r=pe.ACTION,nodeId:o=""})=>{var B,I;const i=Et.useEventEmitter();ne.useInternalNode(o);const{setNodeConfigVisible:s,refreshFlow:a}=ao(),l=y.useRef(null),c=y.useRef(null),u=y.useRef(null),d=y.useRef(null),f=y.useRef(null);y.useRef(null);const p=y.useRef(null),m=ne.useStoreApi(),v=$t(),b=((I=(B=v.nodeConfigPanel)==null?void 0:B.testArea)==null?void 0:I.allowManualTest)!==!1,w=Et.useReactive({output:"",ignore:!1,expandTestPanel:!1}),g=y.useMemo(()=>v.nodeConfigPanel.showSettings&&![pe.TRIGGER,pe.AI_SUB_NODE].includes(r),[r,v.nodeConfigPanel.showSettings]),C=(n==null?void 0:n.action_id)??(n==null?void 0:n.id),k=C!==null&&typeof C<"u"&&C!==""&&Number.isFinite(Number(C))?C:null,_=po(n),S=n==null?void 0:n.nodeKey,E=(n==null?void 0:n.nodeVersion)??(n==null?void 0:n.action_ver),{handleNodeDataUpdate:x}=Ri();y.useEffect(()=>{var N,P;if(!t)return;const F=k!==null&&Number(k)<=0;S&&F&&!_&&!((N=n==null?void 0:n.config_schema)!=null&&N.sub_params)&&!((P=n==null?void 0:n.properties)!=null&&P.sub_params)&&console.warn(`${cO} possible nodepackage schema route mismatch`,{nodeId:o,nodeType:r,actionId:k,nodePackageKey:S,nodePackageVersion:E,reason:"keyed node with non-positive action_id and no classic sub_params was rejected by the nodePackage-compatible node check"})},[k,n==null?void 0:n.config_schema,n==null?void 0:n.properties,n==null?void 0:n.params,n==null?void 0:n.action_key,n==null?void 0:n.action_ver,n==null?void 0:n.nodeKey,n==null?void 0:n.nodeVersion,_,S,E,o,r,t]);const O=y.useCallback(async(F,N)=>{var M,z,H;const P=v.flowId;try{const R=m.getState().nodes.find(U=>U.id===o),Y=_?ZP(F):F.properties,te=_?e2(F):F.account_id??null,$=_?{flow_id:P,properties:Y,position:R==null?void 0:R.position,action_id:k,account_id:te,proxy_id:F.proxy_id,mcp_tool_description:F.mcp_tool_description,action_key:S,action_ver:E}:{flow_id:P,...F,position:R==null?void 0:R.position,action_id:k};console.info(`${cO} save node config`,{nodeId:o,nodeType:r,actionId:k,isNodepackageNode:_,nodePackageKey:S,nodePackageVersion:E,valueKeys:Object.keys(F||{}),paramsKeys:Object.keys((F==null?void 0:F.params)||{}),propertiesKeys:Object.keys((F==null?void 0:F.properties)||{}),ignoreDebugResult:w.ignore});const j=w.ignore?await My(o,"","","",Y,w.output):await rc(o,$);if(j)if(w.ignore)(M=p.current)==null||M.finishSampleTest(),x({id:o,data:{status:me.SUCCESS,output:w.output,outputSource:"sample"}}),D.message.success("已使用样本数据完成调试");else{D.message.success("节点配置已保存");const U={params:void 0,properties:Y,account_id:te,mcp_tool_description:F.mcp_tool_description,action_key:S,action_ver:E,nodeKey:S,nodeVersion:E,isNodePackage:_};x({id:o,data:{config_schema:Y,account_id:F.account_id,...U,position:R==null?void 0:R.position,status:j.status}})}N&&!w.ignore&&((z=p.current)==null||z.onTestNode()),w.ignore=!1,w.output=""}catch{w.ignore&&((H=p.current)==null||H.abortSampleTest(),x({id:o,data:{status:me.FAILED}}))}},[k,v.flowId,n==null?void 0:n.action_key,n==null?void 0:n.action_ver,n==null?void 0:n.nodeKey,n==null?void 0:n.nodeVersion,x,_,S,E,o,r,w,m]);y.useCallback(F=>{!_||r!==pe.SWITCH||x({id:o,data:{config_schema:F,properties:F}})},[x,_,o,r]);const A=F=>{var N,P,M,z,H;return _?(N=c.current)==null?void 0:N.saveConfig(F):r===pe.LOOP?(P=f.current)==null?void 0:P.saveConfig(F):r===pe.CONDITION?(M=u.current)==null?void 0:M.saveConfig(F):r===pe.SWITCH?(z=d.current)==null?void 0:z.saveConfig(F):(H=c.current)==null?void 0:H.saveConfig(F)},T=async(F,N,P)=>{var M;if(N){w.ignore=!0,w.output=P||"",await A(F),(M=p.current)==null||M.finishNodeTest();return}if(F)try{D.message.loading("正在保存节点配置...",0),await A(F),D.message.success("节点配置已保存"),D.message.destroy()}catch(z){D.message.destroy(),console.error("节点配置保存失败:",z),D.message.error("节点配置保存失败,无法执行测试")}};return h.jsx(D.Modal,{open:t,footer:null,closeIcon:null,maskClosable:!0,onCancel:()=>{s(null)},centered:!0,width:"min(1440px, calc(100vw - 32px))",className:"nodes-config-modal",styles:{mask:{backgroundColor:"rgba(0, 0, 0, 0.45)"},content:{padding:0,overflow:"hidden"}},children:h.jsx(Qr.Provider,{value:{event$:i},children:h.jsxs(rC,{children:[h.jsx(aR,{}),h.jsx(lR,{children:h.jsx("div",{className:"nodes-config-container",children:h.jsx("div",{className:"nodes-config-content",children:h.jsxs("div",{className:"config-row",children:[h.jsx("div",{className:"left-section",children:h.jsx("div",{className:"variables-section",children:h.jsx(lO,{ref:l,nodeId:o,onInsert:()=>{},open:t})})}),h.jsx("div",{className:"middle-section",children:h.jsxs("div",{className:"config-container",children:[h.jsx(cR,{icon:n==null?void 0:n.icon,fallbackIcon:n==null?void 0:n.fallbackIcon,name:(n==null?void 0:n.action_name)||(n==null?void 0:n.label),description:n==null?void 0:n.description}),h.jsx(D.Tabs,{style:{height:"100%"},items:[{key:"property",label:"参数配置",children:h.jsxs(h.Fragment,{children:[_||![pe.CONDITION,pe.SWITCH,pe.LOOP].includes(r)?h.jsx(BG,{ref:c,nodeId:o,nodeType:r,data:n,onSubmit:O}):null,r===pe.CONDITION&&!_?h.jsx(IG,{ref:u,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null,r===pe.SWITCH&&!_?h.jsx(iR,{ref:d,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null,r===pe.LOOP&&!_?h.jsx(rR,{ref:f,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null]})},{key:"setting",label:"设置",children:h.jsx(sR,{data:n,nodeId:o,onSubmit:()=>{D.message.success("保存成功")}})}].slice(0,g?2:1)})]})}),h.jsx("div",{className:`right-section ${w.expandTestPanel?"expand":""}`,children:b&&h.jsx("div",{className:"test-section",children:h.jsx(XG,{ref:p,nodeId:o,beforeHook:T,onClose:e,onExpandPanel:F=>{w.expandTestPanel=F}})})})]})})})})]})})})},(t,e)=>Pt.isEqual(Pt.omit(t,["isHovered"]),Pt.omit(e,["isHovered"]))),uO=[],dR=(t,e)=>{if(uO.length===0)return[];const n=new Set(e);return t.some(o=>n.has(o.id)&&Oh(o)&&uO.some(i=>{var s;return((s=o.data)==null?void 0:s.action_key)===i}))?t.filter(o=>!n.has(o.id)).map(o=>o.id):[]},fR=[pe.AGENT,pe.BROWSER],cw=()=>{const t=ne.useStoreApi(),[e,n]=y.useState(0),r=y.useCallback((l,c)=>{const{nodes:u,setNodes:d}=t.getState(),f=fa(u,p=>{const m=p.find(v=>v.id===c.id);m.data?m.data.isHovered=!0:m.data={isHovered:!0}});d(f)},[]),o=y.useCallback((l,c)=>{const{nodes:u,setNodes:d}=t.getState(),f=fa(u,p=>{const m=p.find(v=>v.id===c.id);m.data?m.data.isHovered=!1:m.data={isHovered:!1}});d(f)},[]),i=y.useCallback(l=>{const{nodes:c,setNodes:u}=t.getState(),d=fa(c,f=>{l.forEach(p=>{p.type==="select"&&(f.find(m=>m.id===p.id).selected=p.selected)})});u(d)},[t]),s=y.useCallback((l,c,u=new Set)=>(c.filter(f=>f.source===l?f.sourceHandle!==He.OUTPUT&&f.sourceHandle!==He.DONE&&f.sourceHandle!==He.LOOP&&f.sourceHandle!==He.TRUE&&f.sourceHandle!==He.FALSE:f.target===l&&fh(f.targetHandle)).forEach(f=>{const p=f.source===l?f.target:f.source;u.has(p)||(u.add(p),s(p,c,u))}),u),[]),a=y.useCallback((l,c)=>{const{nodes:u,edges:d,setNodes:f,setEdges:p,onNodesChange:m,onEdgesChange:v}=t.getState(),b=new Set(l);fR.includes(c)&&l.forEach(C=>{s(C,d).forEach(_=>{b.add(_)})}),dR(u,l).forEach(C=>b.add(C));const w=Array.from(b),g=d.filter(C=>b.has(C.source)||b.has(C.target)).map(C=>C.id);if(m){const C=w.map(k=>({type:"remove",id:k}));m(C)}else f(u.filter(C=>!w.includes(C.id)));if(g.length)if(v){const C=g.map(k=>({type:"remove",id:k}));v(C)}else p(d.filter(C=>!g.includes(C.id)))},[t,s]);return{autoSaveNum:e,onNodeMouseEnter:r,onNodeMouseLeave:o,handleNodesChange:i,handleNodesDelete:a}};function hR(t){const{color:e,visible:n}=t;return h.jsx("div",{style:{display:n?"inline-flex":"none",justifyContent:"center",alignItems:"center",position:"absolute",zIndex:1e3,top:"calc(50% - 8px)",left:-10,padding:1,borderRadius:"100%",background:"#FFFFFF",width:20,height:20},children:h.jsx("span",{style:{width:16,height:16,borderRadius:10,backgroundColor:e,border:`1px solid ${e}`,display:"inline-flex",justifyContent:"center",alignItems:"center"},children:h.jsx(DW,{size:8,color:"#FFFFFF"})})})}const Lo={info:{normal:"#007FFF",lighter:"rgba(0, 127, 255, 0.48)"},success:{normal:"#98D7A9",lighter:"rgba(0, 176, 66, 0.48)"},warning:{normal:"#F7CD8F",lighter:"rgba(255, 146, 0, 0.48)"},error:{normal:"#F3B096",lighter:"rgba(255, 82, 25, 0.48)"},disabled:{normal:"#C7CCD1",lighter:"rgba(199, 204, 209, 0.48)"}},dO=({id:t,type:e=pe.ACTION,selected:n=!1,fallbackIcon:r,iconUri:o,inputs:i=[],outputs:s=[],showToolbar:a=!0,width:l,height:c,className:u="",status:d=me.IDLE,onTestNode:f,data:p,contentRender:m,showNodeDescription:v=!0,onToggleNodeDisabled:b})=>{const{currentNodeConfigVisibleId:w,setNodeConfigVisible:g}=ao(),{handleNodeDataUpdate:C}=Ri(),{handleNodesDelete:k}=cw(),_=$t(),S=na(),E=$=>{C({id:t,data:{note:$}})},x=y.useCallback(()=>{g(null)},[]),O=(p==null?void 0:p.isHovered)||!1,A=y.useMemo(()=>e===pe.TRIGGER,[e]),T=()=>{g(t)},B=y.useMemo(()=>(p==null?void 0:p.closed)==="1",[p==null?void 0:p.closed,e]),I=y.useMemo(()=>typeof l=="number"&&l>0?l:"auto",[l]),F=($="node")=>{if(B)return`workflow-${$}-disabled`;switch(d){case me.INVALID:return`workflow-${$}-warning`;case me.FAILED:return`workflow-${$}-failed`;case me.SUCCESS:case me.RUNNABLE:case me.ACTIVE:return`workflow-${$}-success`;case me.RUNNING:return`workflow-${$}-running`;case me.WARNING:return`workflow-${$}-warning`;case me.DEACTIVATED:return`workflow-${$}-disabled`;case me.IDLE:return`workflow-${$}-idle`;default:return""}},N=()=>{if(B)return Lo.disabled;switch(d){case me.INVALID:return Lo.warning;case me.FAILED:return Lo.error;case me.SUCCESS:case me.RUNNABLE:case me.ACTIVE:return Lo.success;case me.RUNNING:return Lo.info;case me.WARNING:return Lo.warning;case me.DEACTIVATED:return Lo.disabled;default:return Lo.info}},P=($="normal")=>N()[$],M=()=>{const $=i.length,j=new Map;return i.forEach(U=>{const ee=U.position,ie=j.has(ee)?j.get(ee)+1:1;j.set(ee,ie)}),i.map((U,ee)=>h.jsx(P0,{nodeId:t,id:U.id,position:U.position,type:U.type||fn.TARGET,category:U.category,connectionLimit:U.maxConnections,label:U.label,nodeStatus:d,protocol:U.protocol,portSchema:U.portSchema,shape:U.shape,style:U.style,index:[ee,$,j.get(U.position)]},`${t}-${U.id}`))},z=async()=>{var U,ee;const $=((U=_.canvas.fixedNodes)==null?void 0:U.triggerIds)||[],j=((ee=_.nodeTypes.fixed)==null?void 0:ee.triggers)||[];if($.includes(t)||j.includes(e)){D.message.warning("当前触发节点已被配置为不可删除");return}await Xf(t),k([t],e)},H=y.useMemo(()=>{const $=s.length,j=new Map;return s.forEach(U=>{const ee=U.position,ie=j.has(ee)?j.get(ee)+1:1;j.set(ee,ie)}),s.map((U,ee)=>h.jsx(P0,{nodeId:t,connectionLimit:U.maxConnections,id:U.id,style:U.style,position:U.position,protocol:U.protocol,portSchema:U.portSchema,type:U.type,label:U.label,shape:U.shape,nodeStatus:d,index:[ee,$,j.get(U.position)]},`${t}-${U.id}`))},[t,s,d]),R=()=>h.jsx(nC,{status:d,disabled:B}),Y=()=>{switch(d){case me.INVALID:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-warning-icon",children:h.jsx(se.WarningFilled,{style:{color:P()},size:12})});case me.FAILED:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-failed-icon",children:h.jsx(se.CloseCircleFilled,{style:{color:P()},size:12})});case me.SUCCESS:case me.RUNNABLE:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-success-icon",children:h.jsx(se.CheckCircleFilled,{style:{color:P()},size:12})});case me.RUNNING:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-running-icon",children:h.jsx(se.LoadingOutlined,{style:{color:P()},size:12})});default:return null}},te=()=>h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"workflow-node-icon-wrapper",children:h.jsx("div",{className:"workflow-node-icon",style:{backgroundImage:`url(${r?"none":o??"https://digitalsee-image.digitalsee.cn/flow/0.png"})`},children:r&&r})}),v&&h.jsx(PP,{title:p==null?void 0:p.connector_name,nodeId:t,note:(p==null?void 0:p.note)||"",statusIcon:Y(),onNoteChange:E,description:p.action_name,className:"workflow-node-text"})]});return h.jsxs(y.Fragment,{children:[h.jsxs("div",{style:{width:I,height:c||"auto"},onDoubleClick:T,className:`${u}
|
|
117
|
+
`})]}):y.isValidElement(t)?y.cloneElement(t,{value:e,onChange:n,...t.props}):t;return h.jsxs(h.Fragment,{children:[!r&&h.jsx("div",{style:{marginBottom:6,textAlign:"right"},children:h.jsxs(D.Button,{size:"small",type:"primary",onClick:i,style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",border:"none",borderRadius:"14px",padding:"0 10px",height:"24px",fontSize:"11px",fontWeight:"500",boxShadow:"0 2px 8px rgba(102, 126, 234, 0.3)",transition:"all 0.2s ease",display:"flex",alignItems:"center",gap:"4px",lineHeight:1},onMouseEnter:a=>{a.currentTarget.style.transform="translateY(-1px)",a.currentTarget.style.boxShadow="0 4px 12px rgba(102, 126, 234, 0.5)"},onMouseLeave:a=>{a.currentTarget.style.transform="translateY(0)",a.currentTarget.style.boxShadow="0 2px 8px rgba(102, 126, 234, 0.3)"},children:[h.jsx(se.RobotOutlined,{style:{fontSize:"11px"}}),"由AI生成"]})}),s()]})},eG=t=>{var n;const e=In();return h.jsx(D.Select,{id:e,style:{borderRadius:6},...t,getPopupContainer:r=>r.parentNode,children:(n=t==null?void 0:t.options)==null?void 0:n.map(r=>h.jsx(D.Select.Option,{label:r.label,value:r.value,children:r.label},r.value))})},tG=t=>h.jsx(D.DatePicker,{style:{width:"100%"},picker:"date",value:t.value?jt(t.value):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD")))}}),nG=t=>h.jsx(y.Fragment,{children:h.jsx(D.DatePicker,{style:{width:"100%"},picker:"date",showTime:!0,value:t.value?jt(t.value):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD hh:mm:ss")))}})}),rG=({value:t=[],onChange:e,selectType:n="KNOWLEDGE_BASE",placeholder:r="请选择"})=>{const o=Et.useReactive({items:[]}),[i,s]=y.useState([]),[a,l]=y.useState(!1);y.useEffect(()=>{n&&(l(!0),Uy(n).then(p=>{p&&Array.isArray(p)&&s(p)}).catch(p=>{console.error("获取选项失败:",p),s([])}).finally(()=>{l(!1)}))},[n]),y.useEffect(()=>{const p=Array.isArray(t)?t:[];o.items=p.map(m=>({...m,id:m.id??In()}))},[t]);const c=Ot(),u=p=>{const m=o.items.filter(v=>v.id!==p);e==null||e(m)},d=()=>{e([...o.items,{value:"",id:In()}])},f=(p,m)=>{e(o.items.map((v,b)=>b===p?{...v,value:m}:v))};return h.jsxs("div",{children:[o.items.length?o.items.map((p,m)=>h.jsxs(D.Space,{size:"small",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[h.jsx(D.Select,{value:p.value||void 0,onChange:v=>f(m,v),placeholder:r,style:{width:300},disabled:!c||a,loading:a,options:i,showSearch:!0,filterOption:(v,b)=>((b==null?void 0:b.label)??"").toLowerCase().includes(v.toLowerCase()),getPopupContainer:v=>v.parentNode}),c&&h.jsx(D.Button,{icon:h.jsx(Di,{size:16}),onClick:()=>{u(p.id)}})]},p.id)):null,c&&h.jsx(D.Button,{type:"default",onClick:d,block:!0,icon:h.jsx(br,{size:16}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})})]})},oG=({value:t=[],onChange:e,valueType:n})=>{const r=u=>{let d=[...o.items];d=d.filter(f=>f.id!==u),e==null||e(d)},o=Et.useReactive({items:[]}),i=u=>{const d=u.which||u.keyCode;(d===37||d===229)&&u.preventDefault()};y.useEffect(()=>{const u=Array.isArray(t)?t:[];o.items=u.map(d=>({...d,id:d.id??In()}))},[t]);const s=()=>{e==null||e([...o.items,{key:"",value:"",id:In()}])},a=(u,d)=>{e==null||e(o.items.map(f=>f.id===u?{...f,key:d}:f))},l=(u,d)=>{e==null||e(o.items.map(f=>f.id===u?{...f,value:d}:f))},c=Ot();return h.jsxs("div",{className:"workflow-extend-object",children:[o.items.length?o.items.map((u,d)=>h.jsxs(D.Space,{size:"small",className:"workflow-extend-object__row",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[h.jsx(D.Input,{defaultValue:u.key,onKeyDown:i,onChange:f=>{var p;a(u.id,(p=f.target.value)==null?void 0:p.replace(/'/g,""))},placeholder:"Key"}),h.jsx("span",{className:"workflow-extend-object__value",style:{display:"inline-block",transform:"translateY(2px)",width:300},children:h.jsx(Pn,{borrow:!0,disableIDE:!0,placeholder:"Value",style:{width:300},value:u.value,onChange:f=>l(u.id,f),valueType:n,nodeId:""})}),c&&h.jsx(D.Button,{icon:h.jsx(Di,{size:16}),onClick:()=>{r(u.id)}})]},u.id)):null,h.jsxs(D.Button,{type:"default",onClick:s,block:!0,children:[h.jsx(br,{size:16})," ",h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})]})]})},iG=t=>null,sG=t=>h.jsx(D.TimePicker,{style:{width:"100%"},use12Hours:!1,format:"HH:mm",value:t.value?jt(t.value,"HH:mm"):null,onChange:e=>{const n=jt(e).format("HH:mm:00");t.onChange&&(t==null||t.onChange(n))}}),{Text:aG}=D.Typography,YA=t=>h.jsx("div",{className:"ce-tag_input label-field",children:h.jsx("p",{children:h.jsx(D.Tooltip,{title:t.value,color:"cyan",placement:"topLeft",children:h.jsx(aG,{ellipsis:!0,copyable:{text:t.value},children:t.value})})})}),lG=({value:t=[],onChange:e,...n})=>{const[r,o]=y.useState([]);y.useEffect(()=>{const f=Array.isArray(t)?t:[];o(f.map(p=>({...p,id:p.id??In()})))},[t]);const i=Ot(),s=f=>{const p=r.filter(m=>m.id!==f);o(p),e==null||e(p)},a=()=>{const f={field:"",dataType:"string",desc:"",required:!1,id:In()},p=[...r,f];o(p),e(p)},l=(f,p)=>{const m=r.map(v=>v.id===f?{...v,field:p}:v);o(m),e(m)},c=(f,p)=>{const m=r.map(v=>v.id===f?{...v,dataType:p}:v);o(m),e(m)},u=(f,p)=>{const m=r.map(v=>v.id===f?{...v,desc:p}:v);o(m),e(m)},d=(f,p)=>{const m=r.map(v=>v.id===f?{...v,required:p}:v);o(m),e(m)};return h.jsxs("div",{className:"workflow-multi-row-extract",children:[r.length?r.map(f=>h.jsxs(D.Space,{size:"small",className:"workflow-multi-row-extract__row",style:{display:"flex",marginBottom:8,width:"100%"},align:"start",children:[h.jsx(D.Input,{value:f.field,onChange:p=>l(f.id,p.target.value),placeholder:"字段名称",status:"",style:{width:130},disabled:!i}),h.jsx(D.Select,{value:f.dataType,onChange:p=>c(f.id,p),placeholder:"数据类型",style:{width:100},disabled:!i,options:[{label:"字符串",value:"string"},{label:"数字",value:"number"},{label:"日期",value:"date"},{label:"布尔",value:"boolean"}]}),h.jsx(D.Input,{value:f.desc,onChange:p=>u(f.id,p.target.value),placeholder:"字段描述",status:"",style:{width:200},disabled:!i}),h.jsx(D.Select,{value:f.required,onChange:p=>d(f.id,p),placeholder:"是否必填",style:{width:100},disabled:!i,options:[{label:"是",value:!0},{label:"否",value:!1}]}),i&&h.jsx(D.Button,{icon:h.jsx(Di,{size:16}),onClick:()=>{s(f.id)}})]},f.id)):null,i&&h.jsx(D.Button,{type:"default",onClick:a,block:!0,icon:h.jsx(br,{size:16}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})})]})},cG=t=>{const e=y.useMemo(()=>In(),[]),{event$:n}=y.useContext(Qr),r=Qm(e),[o,i]=y.useState("");n.useSubscription(a=>{var l;if(a.type==="insert"&&a.currentInputId===e){const c=(o??"")+(t.valueType==="FIX_VALUE"?a.expression.slice(2,-2):a.expression);i(c),(l=t.onChange)==null||l.call(t,c)}}),y.useEffect(()=>{i(t.value)},[t.value]);const s=a=>{var l;i(a.target.value),(l=t.onChange)==null||l.call(t,a.target.value)};return h.jsxs(D.Space.Compact,{block:!0,className:`workflow-password-field${r?` ${od}`:""}`,children:[h.jsx("span",{className:"workflow-password-field__prefix",children:K("link.flow.cipherText")}),h.jsx(D.Input.Password,{id:e,onFocus:()=>{(t.valueType==="JS_EXP"||t.valueType==="FIX_VALUE"||t.valueType==="PLAIN_TEXT"||t.valueType==="PLAIN_CODE")&&(n.emit({type:"visible",visible:!0}),n.emit({type:"setCurrentInputId",currentInputId:e}))},value:o,onChange:s})]})},uG=t=>{var o;const e=In(),{multiple:n,...r}=t;return h.jsx(D.Select,{id:e,style:{borderRadius:6},mode:n?"multiple":void 0,...r,getPopupContainer:i=>i.parentNode,children:(o=t==null?void 0:t.options)==null?void 0:o.map(i=>h.jsx(D.Select.Option,{label:i.label,value:i.value,children:i.label},i.value))})},dG=t=>h.jsx(D.TimePicker,{style:{width:"100%"},value:t.value?jt(t.value,"HH:mm:ss"):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("HH:mm:ss")))}}),El=()=>$t().flowId,fG=["sample","test","payload","body"],hG=["测试","样本","sample","test","payload","body"],XA=t=>{var n,r,o;return[xe.JSON,xe.TEXTAREA,xe.FIXED_OBJ].includes(t.page_control)?!0:((o=(r=(n=t.value_type)==null?void 0:n.toLowerCase)==null?void 0:r.call(n))==null?void 0:o.includes("json"))??!1},JA=(t,e)=>{if(!t)return!1;const n=t.toLowerCase();return e.some(r=>n.includes(r))},pG=t=>{if(t==null)return;const e=(t==null?void 0:t.data)!==void 0?t.data:t;if(typeof e=="string")try{const n=JSON.parse(e);return JSON.stringify(n,null,2)}catch{return e}try{return JSON.stringify(e,null,2)}catch{return}},mG=t=>{const{form:e,configList:n=[],disabled:r,...o}=t;a0();const[i,s]=y.useState(!1),[a,l]=y.useState(0),c=y.useRef(void 0),u=El(),d=y.useMemo(()=>{const m=n.find(v=>XA(v)&&(JA(v.name,fG)||JA(v.display_name,hG)));return m||n.find(v=>XA(v))},[n]),f=y.useCallback(()=>{c.current&&(clearInterval(c.current),c.current=void 0)},[]);y.useEffect(()=>()=>{f()},[f]);const p=y.useCallback(async()=>{if(!u){D.message.warning("缺少连接流ID,无法监听Webhook");return}if(!(d!=null&&d.name)){D.message.warning("未找到测试数据字段,无法填充监听结果");return}if(!i){s(!0),l(10),c.current=setInterval(()=>{l(m=>m<=1?(f(),0):m-1)},1e3);try{const m=await Fy(u,{timeout_seconds:10}),v=pG(m);v?(e.setFieldsValue({[d.name]:v}),D.message.success("已捕获Webhook推送数据并填充测试样例")):D.message.info("监听结束,暂无新的推送数据")}catch(m){console.error("监听Webhook失败:",m),D.message.error("监听失败,请稍后重试")}finally{f(),s(!1),l(0)}}},[u,e,i,d==null?void 0:d.name,f]);return h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},className:"web-hook",children:[h.jsx("div",{style:{flex:1},className:"web-hook-input",children:h.jsx(YA,{...o})}),h.jsx(D.Button,{size:"small",type:"primary",ghost:!0,onClick:p,disabled:r||!(d!=null&&d.name),loading:i,style:{height:32,minWidth:110,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:i?`监听中${a?`(${a}s)`:""}`:"监听"})]})},gG={configFormContainer:"_configFormContainer_1frpl_1"};function wG(t){return Lq(t==null?void 0:t.credentials)}const bG=t=>String(t.type).toUpperCase();function QA(t){var e,n;return(n=(e=t==null?void 0:t.input_fields)==null?void 0:e.find(r=>bG(r)==="PROXY"))==null?void 0:n.key}function ZA(t){return t==null||t===""?"0":String(t)}function vG(t,e,n){const r=QA(e);return r?{...t,[r]:ZA(n??t[r])}:t}function yG(t,e){const n=QA(e);if(!n)return{properties:t};const r={...t},o=ZA(r[n]);return delete r[n],{properties:r,proxyId:o}}const eO=({field:t,disabled:e,readOnly:n,context:r,value:o="",onChange:i,id:s,allowVariableInsert:a,hasModeSwitch:l})=>{const c=uC(),u=y.useId(),d=s||`workflow-code-${u}`,f=y.useRef(null),[p,m]=y.useState(0),v=!e&&!n,b=y.useCallback(_=>{var x;if(!a)return;const S=(x=f.current)==null?void 0:x.view,E=S==null?void 0:S.state.selection.main;if(!S||!E){i==null||i(`${o}${_}`);return}S.dispatch({changes:{from:E.from,to:E.to,insert:_},selection:{anchor:E.from+_.length}}),S.focus()},[a,i,o]),w=oC(d,_=>b(_),()=>{var _,S;return(S=(_=f.current)==null?void 0:_.view)==null?void 0:S.focus()}),g=Mh(),C=(g==null?void 0:g.activeFieldId)===d,k=y.useCallback(()=>{if(v)try{i==null||i(JSON.stringify(JSON.parse(o),null,2))}catch{D.message.warning(K("link.flow.format_json_failed"))}},[v,i,o]);return h.jsx(bC,{id:d,canEditInEditor:v,openEditorNumber:p,nodeId:c.nodeId||r.nodeId||"",value:o,language:"json",showVariableSidebar:a,onFinish:i,children:h.jsxs("div",{style:{position:"relative"},className:C?od:void 0,children:[h.jsx(nd,{id:d,ref:f,value:o,readOnly:!v,height:"220px",placeholder:t.placeholder,theme:Cm,extensions:[$A()],onFocus:()=>{v&&a&&w.activate()},onChange:i}),v?h.jsxs(D.Space,{size:4,style:{position:"absolute",right:8,top:6,zIndex:2},children:[h.jsx(D.Tooltip,{title:K("link.flow.format_json"),children:h.jsx(D.Button,{type:"text",size:"small","aria-label":K("link.flow.format_json"),icon:h.jsx(se.FormatPainterOutlined,{}),onClick:k,style:{color:"#fff"}})}),h.jsx(D.Tooltip,{title:K("link.flow.open_code_editor"),children:h.jsx(D.Button,{type:"text",size:"small","aria-label":K("link.flow.open_code_editor"),icon:h.jsx(se.FullscreenOutlined,{}),onClick:()=>m(_=>_+1),style:{color:"#fff"}})})]}):null]})})};eO.displayName="WorkflowCodeEditor";const tO=({field:t,disabled:e,readOnly:n,context:r,value:o,onChange:i,id:s})=>{const a=typeof o=="string"?o:o==null?"":JSON.stringify(o)??"",l=!!t.valueModePolicy,c=t.valueModePolicy==="EXPRESSION"||t.valueModePolicy==="BOTH",u=d=>h.jsx(eO,{...d,field:t,context:r,id:s,allowVariableInsert:c,hasModeSwitch:l});return t.valueModePolicy?h.jsx(ki,{value:a,onChange:d=>i==null?void 0:i(d),valueModePolicy:t.valueModePolicy,disabled:e,readOnly:n,placeholder:t.placeholder,renderNormalMode:u,renderExpressionMode:u,modeSwitchPosition:"top-right",encodeExpressionValue:!0}):u({value:a,onChange:d=>i==null?void 0:i(d),disabled:e,readOnly:n,placeholder:t.placeholder})};tO.displayName="WorkflowCodeFieldControl";const CG=dt(tO,{needsFormItemName:!0,supportsVariableInsert:!0}),nO=({disabled:t,readOnly:e,value:n,onChange:r,id:o})=>{const[i,s]=y.useState([]),[a,l]=y.useState(!1);y.useEffect(()=>{let d=!1;return l(!0),Kf().then(f=>{d||s(Array.isArray(f)?f:[])}).catch(()=>{d||D.message.error(K("link.flow.request_failed"))}).finally(()=>{d||l(!1)}),()=>{d=!0}},[]);const c=y.useMemo(()=>[{value:"0",label:h.jsx(Te.FormattedMessage,{id:"link.flow.do_not_use"})},...i.map(d=>({value:String(d.id),label:d.group_name||String(d.id)}))],[i]),u=n==null||n===""?"0":String(n);return h.jsx(D.Select,{id:o,className:"proxy_id_select",value:u,options:c,loading:a,disabled:t||e,dropdownStyle:{zIndex:99999999999},onChange:d=>r==null?void 0:r(String(d)),style:{width:"100%"}})};nO.displayName="WorkflowProxyFieldControl";const kG=dt(nO,{needsFormItemName:!0,supportsVariableInsert:!0}),SG=[{type:ge.CODE,definition:CG},{type:ge.PROXY,definition:kG}];function EG({children:t}){return h.jsx(fC,{additionalRegistrations:SG,children:t})}function xl(){const{event$:t}=y.useContext(Qr),e=Fh();return y.useCallback(n=>{var o;const r=document.activeElement;if(r&&r!==document.body&&r.contains(n.target)){const i=n.target;if(!["INPUT","TEXTAREA","SELECT"].includes((i==null?void 0:i.tagName)??""))return}(o=t==null?void 0:t.emit)==null||o.call(t,{type:"setCurrentInputId",currentInputId:""}),e==null||e.deactivateField()},[t,e])}const xG=[xe.TEXT,xe.PASSWORD,xe.SELECT,xe.EXTEND_OBJ,xe.DATE,xe.TIME,xe.DATETIME,xe.TEXTAREA,xe.FIXED_OBJ,xe.JSON],DG="[workflow:schema-render]",_G=/^\{\{([^.{}]+)\.(.+)\}\}$/,AG=t=>{switch(t.page_control){case xe.SELECT:case xe.API_SELECT:return t.multi_valued?[]:null;case xe.EXTEND_OBJ:return{};case xe.HIDDEN:return"";case xe.TEXT:return"";case xe.PASSWORD:return"";case xe.LABEL:return"";case xe.DATE:return null;case xe.TIME:return null;case xe.DATETIME:return null;case xe.TEXTAREA:return"";case xe.FIXED_OBJ:return{};case xe.MultiRowAIExtractConfig:return[];case xe.JSON:return""}},rO=(t,e,n,r,o)=>{const i=t.display_name,s=()=>{var a,l,c;switch(t.page_control){case xe.SELECT:return h.jsx(uG,{options:Zg(t.option_value_objects??t.option_values),multiple:t.multi_valued});case xe.API_SELECT:return h.jsx(eG,{options:Zg(t.option_value_objects??t.option_values)});case xe.EXTEND_OBJ:return h.jsx(oG,{valueType:t.value_type});case xe.HIDDEN:return h.jsx(iG,{});case xe.TEXT:return h.jsx(Pn,{valueType:t.value_type,nodeId:e});case xe.PASSWORD:return h.jsx(cG,{valueType:t.value_type});case xe.LABEL:return(a=r==null?void 0:r.webhookField)!=null&&a.enabled&&t.name==="hookUrl"&&r.webhookField.form?h.jsx(mG,{form:r.webhookField.form,configList:r.webhookField.configList,disabled:r.webhookField.disabled}):h.jsx(YA,{});case xe.DATE:return h.jsx(tG,{});case xe.TIME:return h.jsx(dG,{});case xe.DATETIME:return h.jsx(nG,{});case xe.TEXTAREA:return h.jsx(Pn,{valueType:t.value_type,textAreaMode:!0,nodeId:e});case xe.FIXED_OBJ:return h.jsx(D.Input.TextArea,{});case xe.JSON:return h.jsx(Pn,{valueType:t.value_type,nodeId:e});case xe.MultiRowAIExtractConfig:return h.jsx(lG,{valueType:t.value_type});case xe.MULTI_SELECT_LIST:return h.jsx(rG,{selectType:"KNOWLEDGE_BASE"});case xe.SYNC_HOUR_MINUTE:return h.jsx(sG,{});case xe.AUTH_TOKEN:return h.jsx(Rq,{disabled:(l=r==null?void 0:r.webhookField)==null?void 0:l.disabled});case xe.SECRET_KEY:return h.jsx(Yq,{});case xe.SELECT_CLIENT:return h.jsx(Qq,{});default:{const u=(c=o==null?void 0:o.form)==null?void 0:c.find(d=>d.name===t.page_control);return u?h.jsx(u.component,{config:t,configList:r==null?void 0:r.configList,disabled:r==null?void 0:r.disabled,form:r==null?void 0:r.form,mcpMode:n,nodeId:e}):(console.warn(`unknown form item: page_control:${t.page_control}`),null)}}};return n&&xG.includes(t.page_control)?h.jsx("div",{children:h.jsx(D.Form.Item,{required:t.required,rules:[{required:t.required,message:t.page_control===xe.SELECT?K("link.flow.please_select")+t.display_name:K("link.flow.please_enter")+t.display_name}],label:i,name:t.name,children:h.jsx(Zq,{children:s()})})},t.ui_id):h.jsx(D.Form.Item,{required:t.required,style:t.page_control===xe.HIDDEN?{display:"none"}:{},rules:[{required:t.required,message:t.page_control===xe.SELECT?K("link.flow.please_select")+t.display_name:K("link.flow.please_enter")+t.display_name},{validator(a,l,c){if(t.page_control===xe.MultiRowAIExtractConfig)if(Array.isArray(l)&&t.required){const u=l.some(d=>!d.field||!d.dataType||!d.desc||d.required==null);c(u?"请填写完整配置":void 0)}else c(void 0);else c(void 0)}}],label:i,name:t.name,children:s()},t.ui_id)},OG=t=>(t.child_conditions??[]).map(e=>e.left).filter(e=>!!e),TG=(t,e)=>{if(!t.is_child)return!0;const n=t.child_conditions??[];return n.length?n.some(({left:r,operator:o,right:i})=>{const s=e==null?void 0:e[r];return o==="EQUALS"?s===i:s!==i}):!0},NG=y.forwardRef((t,e)=>{var we,fe;const{action:n,connector:r,nodeId:o,account_id:i,mcpMode:s,nodeType:a}=t,l=$t(),c=ne.useStoreApi(),u=xl(),d=Et.useReactive({proxyId:"0"}),{config_schema:f,proxy_id:p,protocol:m,account_schema_id:v}=n;a??n.node_type??n.type;const b=n.action_key||n.nodeKey,w=n.action_ver??n.nodeVersion,g=Array.isArray(f==null?void 0:f.sub_params),C=po(n),k=y.useMemo(()=>!C||!b?null:`${b}@${w??"latest"}`,[C,b,w]),_=k?`${o}:${k}`:o,S=n.account_id??i,E=y.useMemo(()=>k?Wi(b,w):null,[k,b,w]),[x,O]=y.useState(()=>k&&E?{identity:k,schema:E,loading:!1,finished:!0}:null),A=(x==null?void 0:x.identity)===k?x:null,T=(A==null?void 0:A.schema)??null,B=rw((T==null?void 0:T.credentials)??[]),I=!!(C&&b&&!T&&((A==null?void 0:A.loading)??!(A!=null&&A.finished))),F=wG(T);y.useEffect(()=>{!x||x.identity},[k,x,o,b,w]),y.useEffect(()=>{p&&(d.proxyId=p)},[p,d]);const[N]=D.Form.useForm(),[P,M]=y.useState(S);y.useEffect(()=>{M(S)},[_,S,M]);const z=y.useMemo(()=>{var le;return g?(le=f.sub_params)==null?void 0:le.reduce((Se,ce)=>{let Fe=ce.value;return ce.page_control===xe.EXTEND_OBJ&&(Fe=_q(Fe)),Se[ce.name]=Fe??AG(ce),Se},{}):{}},[f==null?void 0:f.sub_params,g]);y.useEffect(()=>{g&&(N.resetFields(),N.setFieldsValue({...z}))},[z,N,g,o]);const H=y.useRef(null),R=y.useRef(null);y.useEffect(()=>{if(!k||!b){O(null);return}const le=Wi(b,w);if(le){O({identity:k,schema:le,loading:!1,finished:!0});return}let Se=!1;return O({identity:k,schema:null,loading:!0,finished:!1}),pc(b,w).then(ce=>{Se||O({identity:k,schema:ce,loading:!1,finished:!0})}).catch(ce=>{Se||(O({identity:k,schema:null,loading:!1,finished:!0}),console.error(`${DG} classic renderer next schema load failed`,{nodeId:o,nodeKey:b,nodeVersion:w,err:ce}))}),()=>{Se=!0}},[k,o,b,w]);const Y=y.useMemo(()=>{var le;return(le=T==null?void 0:T.input_fields)!=null&&le.length?KI(WA(T.input_fields),T.key):null},[T]),te=!!(C&&(Y||F||T)),$=y.useMemo(()=>{const le=n.properties?ha(n.properties):f&&C?ha(f):n.params?ha(n.params):{},Se=vG(le,T,p);return uc(b)?ra(Se).properties:Se},[n,f,C,T,b,p]),j=y.useMemo(()=>JSON.stringify($??{}),[$]);y.useEffect(()=>{!C||!te||(N.resetFields(),N.setFieldsValue($))},[_,N,C,$,j,te]);const U=y.useRef(null);y.useEffect(()=>{U.current=null},[_]),y.useEffect(()=>{uc(b)&&(U.current=JSON.stringify(ra($).branches.map(le=>[le.id,le.name])))},[$,b]);const ee=y.useCallback(le=>{const Se=le.trim().match(_G);if(!Se)return null;const ce=Se[1],Fe=Se[2];if(ce==="global")return null;const Ve=ce.startsWith("N")?ce.slice(1):ce,je=c.getState().nodes.find(We=>We.id===Ve);return je?{fieldPath:Fe,node:je,variableNodeId:ce}:null},[c]),ie=y.useCallback(le=>{var Se;return((Se=ee(le))==null?void 0:Se.fieldPath)??le.replace(/^\{\{|\}\}$/g,"")},[ee]),be=y.useCallback(le=>{var je;const Se=ee(le);if(!Se)return le;const ce=(je=Se.node)==null?void 0:je.data,Fe=(ce==null?void 0:ce.label)||(ce==null?void 0:ce.name)||(ce==null?void 0:ce.action_name)||Se.variableNodeId,Ve=ce!=null&&ce.note?` (${ce.note})`:"";return`${Fe}${Ve}.${Se.fieldPath}`},[ee]),[W,X]=y.useState(!1),q=(le,Se)=>(X(!0),N.validateFields().then(async ce=>{var Ve,je,We,ht,Ee;if(te){Se&&((je=(Ve=H==null?void 0:H.current)==null?void 0:Ve.onIgnoreNodeStart)==null||je.call(Ve));const{properties:Ce,proxyId:Le}=yG(ce,T);return t.onSubmit({properties:Ce,account_id:P,proxy_id:Le},le)}const Fe=Pt.cloneDeep(n.config_schema);return Fe.sub_params.forEach(Ce=>{let Le=ce[Ce.name];Ce.page_control===xe.EXTEND_OBJ&&Le!=="{{$fromAI}}"&&(Le=ew(Le)),Ce.value=Le??null}),Se&&((ht=(We=H==null?void 0:H.current)==null?void 0:We.onIgnoreNodeStart)==null||ht.call(We)),!i&&m==="HTTP"&&(r==null?void 0:r.deployment_type)!=="SaasApp"&&(Fe.proxy_id=(Ee=R.current)==null?void 0:Ee.getProxyId()),t.onSubmit(Fe,le)}).catch(ce=>(console.log("err",ce),D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>X(!1)));y.useImperativeHandle(e,()=>({saveConfig:le=>q(le,!1)}));const J=Ot(),re={form:N,configList:(f==null?void 0:f.sub_params)??[],disabled:!J,...m==="WEBHOOK"?{webhookField:{enabled:!0,form:N,configList:(f==null?void 0:f.sub_params)??[],disabled:!J}}:{}},Z=le=>{const Se=le.page_control!==xe.HIDDEN?h.jsx("p",{className:"field-desc",children:le.description}):null;if(!le.is_child)return h.jsxs("div",{children:[rO(le,o,s,re,l.canvas.registerComponents),Se]},le.ui_id);const ce=OG(le);return h.jsx(D.Form.Item,{noStyle:!0,shouldUpdate:(Fe={},Ve={})=>le.is_child?ce.length?ce.some(je=>(Fe==null?void 0:Fe[je])!==(Ve==null?void 0:Ve[je])):!0:!1,children:()=>{const Fe=N.getFieldsValue(!0);return TG(le,Fe)?h.jsxs("div",{children:[rO(le,o,s,re,l.canvas.registerComponents),Se]}):null}},le.ui_id)};if(C&&I)return h.jsx("div",{style:{textAlign:"center",padding:40},children:h.jsx(D.Spin,{})});const ue=!t.preRender&&(((we=n.config_schema)==null?void 0:we.sub_params)??[]).length<1,ve=h.jsx("div",{style:{padding:16,color:"#999",textAlign:"center"},children:"该节点暂无配置项"});if(te){const le=h.jsxs(h.Fragment,{children:[t.preRender&&t.preRender,F?h.jsx(RA,{credentialRequirements:B,value:P,onChange:M,linkApp:r,disabled:!J}):null]});return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:u,children:[h.jsx("div",{className:"workflow-node-form-scroll",children:Y?h.jsx(EG,{children:h.jsx(Xg,{schema:Y,form:N,initialValues:$,showSubmit:!1,showReset:!1,nodeId:o,mcpMode:s,renderVariableTag:ie,renderVariableTooltip:be,customTheme:sc,preRender:le},_)}):ve}),h.jsx("div",{className:"workflow-node-form-footer",children:J&&h.jsx(D.Button,{type:"primary",disabled:!J,loading:W,className:"workflow-node-form-save",onClick:()=>q(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:u,children:[h.jsxs(D.Form,{form:N,disabled:!J,layout:"vertical",className:`${gG.configFormContainer} workflow-config-form workflow-node-form-scroll`,children:[t.preRender&&t.preRender,(r==null?void 0:r.id)&&n.config_schema&&((fe=f==null?void 0:f.sub_params)==null?void 0:fe.map(le=>Z(le))),!i&&m==="HTTP"&&(r==null?void 0:r.deployment_type)!=="SaasApp"?h.jsx(Jg,{proxyId:d.proxyId,ref:R}):null,ue&&ve]}),h.jsx("div",{className:"workflow-node-form-footer",children:J&&h.jsx(D.Button,{type:"primary",disabled:!J,loading:W,className:"workflow-node-form-save",onClick:()=>q(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),BG=y.memo(y.forwardRef((t,e)=>{const{nodeId:n,data:r}=t,{account_id:o,account_schema_id:i}=r,s=Et.useReactive({account_id:o}),a=y.useRef(null);y.useImperativeHandle(e,()=>({saveConfig:p=>{var m;return(m=a.current)==null?void 0:m.saveConfig(p)}}));const l=y.useMemo(()=>({id:t.data.connector_id,name:t.data.connector_name,deployment_type:t.data.deployment_type}),[t.data.connector_id,t.data.connector_name,t.data.deployment_type]),c=po(t.data),u=(p,m)=>{if(c){const v=ha(p),w=Object.hasOwn(p??{},"account_id")?p.account_id??null:s.account_id;return t.onSubmit({properties:v,account_id:w,proxy_id:(p==null?void 0:p.proxy_id)??(v==null?void 0:v.proxy_id)},m)}return t.onSubmit({properties:p,account_id:s.account_id,proxy_id:p.proxy_id},m)},d=y.useCallback(p=>{s.account_id=p??null},[]);let f=null;return i&&!c&&(f=h.jsx(RA,{onChange:d,actionAccountSchemaId:i,value:s.account_id,linkApp:l})),h.jsx("div",{className:"workflow-action-node-config",children:h.jsx(NG,{ref:a,action:t.data,nodeType:t.nodeType||t.data.node_type||t.data.type,connector:l,account_id:o,nodeId:n,onSubmit:u,preRender:f})})}),(t,e)=>t.nodeId===e.nodeId&&t.nodeType===e.nodeType&&Pt.isEqual(Pt.omit(t.data,["isHovered"]),Pt.omit(e.data,["isHovered"])));var $n=(t=>(t.IDLE="idle",t.SAVING="saving",t.SAVED="saved",t.ERROR="error",t))($n||{}),Wd=(t=>(t.SELECTION="selection",t.ALL="all",t))(Wd||{}),er=(t=>(t.UNPUBLISHED="UNPUBLISHED",t.ONLINE="ONLINE",t.OFFLINE="OFFLINE",t.ON_WARN="ON_WARN",t.OFF_WARN="OFF_WARN",t.ONLINE_ING="ONLINE_ING",t))(er||{}),nt=(t=>(t.eq="eq",t.ne="ne",t.sw="sw",t.nsw="nsw",t.ew="ew",t.ewn="ewn",t.gt="gt",t.ge="ge",t.lt="lt",t.le="le",t.co="co",t.nco="nco",t.in="in",t.nin="nin",t.is_null="is_null",t.is_not_null="is_not_null",t))(nt||{});const oO=[{operator:nt.eq,label:K("common.eq")},{operator:nt.ne,label:K("common.ne")},{operator:nt.sw,label:K("common.sw")},{operator:nt.nsw,label:K("common.nsw")},{operator:nt.ew,label:K("common.ew")},{operator:nt.ewn,label:K("common.ewn")},{operator:nt.gt,label:K("common.gt")},{operator:nt.ge,label:K("common.ge")},{operator:nt.lt,label:K("common.lt")},{operator:nt.le,label:K("common.le")},{operator:nt.co,label:K("common.co")},{operator:nt.nco,label:K("common.nco")},{operator:nt.in,label:K("common.in")},{operator:nt.nin,label:K("common.nin")},{operator:nt.is_null,label:K("common.is_null")},{operator:nt.is_not_null,label:K("common.is_not_null")}];nt.eq+"",K("common.eq"),nt.ne+"",K("common.ne"),nt.sw+"",K("common.sw"),nt.nsw+"",K("common.nsw"),nt.ew+"",K("common.ew"),nt.ewn+"",K("common.ewn"),nt.gt+"",K("common.gt"),nt.lt+"",K("common.lt"),nt.ge+"",K("common.ge"),nt.co+"",K("common.co"),nt.nco+"",K("common.nco"),nt.le+"",K("common.le"),nt.in+"",K("common.in"),nt.nin+"",K("common.nin"),nt.is_null+"",K("common.is_null"),nt.is_not_null+"",K("common.is_not_null");const iw=t=>t===nt.is_null||t===nt.is_not_null,FG=(t,e="")=>iw(t)?"":e,{Option:MG}=D.Select,IG=y.forwardRef((t,e)=>{const{config_schema:n}=t,[r]=D.Form.useForm(),o=xl(),s=(d=>d!=null&&d.or_list?{or_list:d.or_list.map(p=>({and_list:p.and_list.map(m=>({query:m.query||"",operator:m.operator||"",value:m.value||""}))}))}:{or_list:[{and_list:[{query:"",operator:"",value:""}]}]})(n),[a,l]=y.useState(!1),c=(d,f,p="")=>(l(!0),r.validateFields().then(async m=>t.onSubmit({properties:m},d)).catch(()=>(D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>l(!1)));y.useImperativeHandle(e,()=>({saveConfig:d=>c(d)}));const u=Ot();return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:o,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsx(D.Form,{disabled:!u,form:r,initialValues:s,layout:"vertical",autoComplete:"off",children:h.jsx(D.Form.List,{name:"or_list",children:(d,{add:f,remove:p})=>h.jsxs(h.Fragment,{children:[d.map((m,v)=>h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"form-block",children:h.jsxs("div",{style:{padding:12,width:"100%",boxSizing:"border-box"},children:[v>0&&u&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsx(D.Button,{type:"link",style:{color:"red"},icon:h.jsx(se.MinusCircleOutlined,{style:{color:"red"}}),onClick:()=>p(m.name),children:h.jsx(Te.FormattedMessage,{id:"link.flow.remove"})})}),h.jsx(D.Form.List,{name:[m.name,"and_list"],children:(b,{add:w,remove:g})=>h.jsx(h.Fragment,{children:b.map((C,k)=>h.jsxs(D.Space,{direction:"vertical",style:{width:"100%",rowGap:0},children:[h.jsxs(D.Space,{align:"center",className:`form-item-row ${k>0?"opt":""}`,children:[h.jsx(D.Form.Item,{style:{minWidth:150},name:[C.name,"query"],label:K("app.common.word.variable-name"),rules:[{required:!0,message:K("link.flow.please_enter_variable_name")}],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),h.jsx(D.Form.Item,{name:[C.name,"operator"],label:K("app.common.word.condition"),rules:[{required:!0,message:K("link.flow.please_select_condition")}],children:h.jsx(D.Select,{style:{minWidth:140},placeholder:K("link.flow.select_condition"),getPopupContainer:_=>_.parentNode,children:oO.map(_=>h.jsx(MG,{value:_.operator,children:_.label},_.operator))})}),h.jsx(D.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const _=r.getFieldValue(["or_list",m.name,"and_list",C.name,"operator"]);return iw(_)?null:h.jsx(D.Form.Item,{style:{minWidth:150},name:[C.name,"value"],label:K("app.common.word.value"),rules:[],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),k>0&&h.jsx(D.Button,{type:"link",icon:h.jsx(se.MinusCircleOutlined,{}),onClick:()=>g(C.name)})]}),k<b.length-1&&h.jsx(D.Divider,{plain:!0,children:h.jsx(D.Tag,{color:"#999999",children:h.jsx(Te.FormattedMessage,{id:"link.flow.and"})})}),k===b.length-1&&h.jsx(D.Button,{type:"link",disabled:!u,icon:h.jsx(br,{size:16}),className:"small",onClick:()=>w({query:"",operator:"",value:""}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-new-and"})})]},C.key))})})]})},m.key),v<d.length-1&&h.jsxs("div",{className:"test",style:{textAlign:"center"},children:[" ",h.jsx(D.Divider,{style:{color:"orange"},dashed:!0,children:h.jsx(D.Tag,{color:"#1890ff",children:h.jsx(Te.FormattedMessage,{id:"link.flow.or"})})})]})]})),h.jsx(D.Form.Item,{style:{display:"flex",justifyContent:"flex-end",marginBlock:10},children:h.jsx(D.Button,{type:"default",icon:h.jsx(br,{size:16}),disabled:!u,onClick:()=>f({and_list:[{query:"",operator:"",value:""}]}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-or"})})})]})})})}),h.jsx("div",{className:"workflow-node-form-footer",children:u&&h.jsx(D.Button,{type:"primary",disabled:!u,loading:a,className:"workflow-node-form-save",onClick:()=>c(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),PG={copy:"Copy JSON",copySuccess:"JSON copied to clipboard",download:"Download JSON",invalidJson:"Invalid JSON data"},LG={copy:"复制JSON",copySuccess:"JSON已复制到剪贴板",download:"下载JSON",invalidJson:"无效的JSON数据"},{Text:$G}=D.Typography,zG=({data:t,height:e=400,enableCopy:n=!0,theme:r="light",className:o="",locale:i="zh",maxHeight:s})=>{const[a,l]=y.useState(r),c=y.useRef(null),u=i==="zh"?LG:PG,d=y.useMemo(()=>{if(!t)return null;try{return typeof t=="string"?JSON.parse(t):t}catch(w){return console.error("JSON解析失败:",w),null}},[t]),f=y.useMemo(()=>{if(!d)return[];const w=(g,C=[],k=0)=>{const _=[];if(g===null)return[{key:C.join("."),value:null,type:"null",path:C,level:k}];if(Array.isArray(g)){const S={key:C.join("."),value:g,type:"array",path:C,level:k,children:[]};g.forEach((E,x)=>{var T;const O=[...C,x.toString()],A=w(E,O,k+1);(T=S.children)==null||T.push(...A)}),_.push(S)}else if(typeof g=="object"){const S={key:C.join("."),value:g,type:"object",path:C,level:k,children:[]};Object.entries(g).forEach(([E,x])=>{var T;const O=[...C,E],A=w(x,O,k+1);(T=S.children)==null||T.push(...A)}),_.push(S)}else{const S=typeof g;_.push({key:C.join("."),value:g,type:S,path:C,level:k})}return _};return w(d)},[d]),p=y.useCallback(()=>{const w=JSON.stringify(d,null,2);navigator.clipboard.writeText(w).then(()=>{D.message.success(u.copySuccess)})},[d,u]),m=y.useCallback(()=>{const w=JSON.stringify(d,null,2),g=new Blob([w],{type:"application/json"}),C=URL.createObjectURL(g),k=document.createElement("a");k.href=C,k.download="data.json",k.click(),URL.revokeObjectURL(C)},[d]),v=y.useCallback(w=>{switch(w.type){case"string":return h.jsxs("span",{className:"json-string",children:['"',String(w.value),'"']});case"number":return h.jsx("span",{className:"json-number",children:String(w.value)});case"boolean":return h.jsx("span",{className:"json-boolean",children:String(w.value)});case"null":return h.jsx("span",{className:"json-null",children:"null"});default:return null}},[]),b=y.useCallback((w,g)=>{var _;const C=w.children&&w.children.length>0,k=w.path[w.path.length-1];return w.type==="object"||w.type==="array"?h.jsxs("div",{className:"json-node",children:[h.jsxs("div",{className:"json-line",style:{paddingLeft:`${w.level*16}px`},children:[k&&h.jsxs("span",{className:"json-key",children:['"',k,'": ']}),h.jsx("span",{className:"json-bracket",children:w.type==="array"?"[":"{"}),!C&&h.jsx("span",{className:"json-bracket",children:w.type==="array"?"]":"}"})]}),C&&h.jsxs(h.Fragment,{children:[(_=w.children)==null?void 0:_.map((S,E)=>b(S,g+E+1)),h.jsx("div",{className:"json-line",style:{paddingLeft:`${w.level*16}px`},children:h.jsx("span",{className:"json-bracket",children:w.type==="array"?"]":"}"})})]})]},w.key):h.jsx("div",{className:"json-node",children:h.jsxs("div",{className:"json-line",style:{paddingLeft:`${w.level*16}px`},children:[k&&h.jsxs("span",{className:"json-key",children:['"',k,'": ']}),v(w)]})},w.key)},[v]);return y.useCallback(()=>{l(a==="dark"?"light":"dark")},[a]),d?h.jsxs("div",{className:`json-renderer ${a} ${o}`,children:[h.jsx("div",{className:"json-toolbar",children:h.jsxs(D.Space,{children:[n&&h.jsx(D.Tooltip,{title:u.copy,children:h.jsx(D.Button,{icon:h.jsx(se.CopyOutlined,{}),size:"small",onClick:p})}),h.jsx(D.Tooltip,{title:u.download,children:h.jsx(D.Button,{icon:h.jsx(se.DownloadOutlined,{}),size:"small",onClick:m})})]})}),h.jsx("div",{ref:c,className:"json-content",style:{height:`${e}px`,maxHeight:s?`${s}px`:void 0},children:f.map((w,g)=>b(w,g))})]}):h.jsx("div",{className:`json-renderer error ${a} ${o}`,children:h.jsx("div",{className:"error-message",children:h.jsx($G,{type:"secondary",children:u.invalidJson})})})},{TextArea:HG}=D.Input,{Title:VG}=D.Typography,iO=({status:t,result:e="",progress:n=60,runningAction:r="run",showAlert:o=!0,canEdit:i=!0,disabledReason:s="当前节点不支持手动测试",editing:a=!1,editableValue:l="",onEditableValueChange:c,onRun:u,onIgnore:d,onReset:f,onToggleEdit:p,onDismissAlert:m,className:v,onClose:b,onExpandPanel:w})=>{const g=t==="running",C=t==="failure",k=t==="ignored",_=t==="success"||k,S=t==="disabled",[E,x]=y.useState(!1);return h.jsxs("section",{className:["node-test-container","ai-flow-node-test-panel",v].filter(Boolean).join(" "),"aria-label":"AI FLOW 节点测试",children:[h.jsx("div",{className:"node-test-header",children:h.jsxs("div",{className:"header-title",children:[h.jsx("span",{className:"common-icon title-icon"}),h.jsx(VG,{level:4,children:"节点测试"}),h.jsx(D.Button,{ghost:!0,className:"close-btn",onClick:b,children:h.jsx(Di,{size:16})})]})}),h.jsxs("div",{className:"test-content",children:[i&&!S?h.jsxs("div",{className:"action-buttons",children:[h.jsx(D.Button,{type:"primary",disabled:S,onClick:u,loading:g&&r==="run",className:"test-button",children:g?"测试中...":"开始测试"}),h.jsx(D.Button,{type:"default",disabled:S||g&&r==="run",onClick:d,loading:g&&r==="ignore",className:"ignore-button",children:"忽略调试"})]}):null,i&&e?h.jsx("div",{className:"action-buttons",children:h.jsx(D.Button,{onClick:f,className:"reset-button",children:"重置"})}):null,g?h.jsxs(h.Fragment,{children:[h.jsx(D.Progress,{percent:n,status:"active",className:"test-progress"}),h.jsx(D.Skeleton,{active:!0,className:"result-skeleton"})]}):h.jsxs(h.Fragment,{children:[C&&o?h.jsx(D.Alert,{className:"error-alert small",showIcon:!0,message:"测试未通过",description:"请检查节点配置和接口返回后重试",type:"error",closable:!1,onClose:m}):null,_&&o?h.jsx(D.Alert,{className:"success-alert small",showIcon:!0,message:k?"忽略调试成功":"测试成功",description:k?"已将样本数据设为当前节点输出":"节点运行正常,可在下方查看返回结果",type:"success",closable:!1,onClose:m}):null,e?h.jsx(D.Card,{styles:{body:{padding:0}},title:h.jsxs("div",{className:"result-header",children:[h.jsx("div",{className:"result-title",children:C?h.jsxs(h.Fragment,{children:[h.jsx(se.CloseCircleFilled,{className:"error-icon"})," 错误数据"]}):h.jsxs(h.Fragment,{children:[k?h.jsx(se.ExperimentFilled,{className:"success-icon"}):h.jsx(se.CheckCircleFilled,{className:"success-icon"}),k?"样本数据":"测试结果"]})}),h.jsxs("div",{style:{display:"inline-flex",gap:8},children:[i&&p?h.jsx(D.Button,{size:"small",type:"default",variant:"solid",onClick:p,className:"edit-button",children:a?"完成":"编辑"}):null,w&&h.jsx(D.Button,{size:"small",type:E?"primary":"default",variant:"solid",className:"edit-button",onClick:()=>{const O=!E;w(O),x(O)},children:E?h.jsx(SW,{size:16}):h.jsx(kW,{size:16})})]})]}),variant:"borderless",className:`result-card ${C?"error-result":"success-result"}`,children:a?h.jsx(HG,{rows:E?20:10,value:l,onChange:O=>c==null?void 0:c(O.target.value),className:"result-editor"}):h.jsx(zG,{data:e,height:E?600:300,enableCopy:!0,theme:"dark"},e)}):h.jsx(D.Card,{variant:"borderless",className:"empty-result",children:h.jsx(D.Result,{icon:h.jsx("span",{className:"common-icon"}),title:S?"不可测试":"等待测试",subTitle:S?s:"点击“开始测试”按钮运行当前节点"})})]})]})]})},jG=new Set([$e.AI_LANGUAGE_MODEL,$e.AI_MEMORY,$e.BUILTIN_MCP,$e.MCP_SERVER]),WG=new Set([]),UG=({canEdit:t,nodeType:e,protocol:n})=>t?n&&jG.has(n)?{disabled:!0,reason:"当前协议节点由所属 AI 或 MCP 运行上下文统一测试"}:e&&WG.has(e)?{disabled:!0,reason:"当前节点类型不支持独立手动测试"}:{disabled:!1}:{disabled:!0,reason:"只读或预览模式下不能执行节点测试"},qG=t=>typeof t=="string"?t.trim().length>0:t!=null,GG=t=>typeof t=="string"&&t.trim().toLowerCase()==="success",RG=t=>{if(!t||typeof t!="object")return!1;const e=t;return e.result===!0?!1:e.result===!1?!0:e.error==="0"&&qG(e.error_description)&&!GG(e.error_description)},KG=t=>RG(t)?me.FAILED:me.SUCCESS,YG=t=>{if(typeof t=="object")return JSON.stringify(t,null,2);if(typeof t=="string")try{const e=JSON.parse(t);return JSON.stringify(e,null,2)}catch{return t}return String(t)};JSON.stringify({result:"示例数据",data:{id:"123",name:"示例"}},null,2);const XG=y.forwardRef((t,e)=>{var O,A,T,B;const{nodeId:n,beforeHook:r,onClose:o,onExpandPanel:i}=t,s=$t(),{handleNodeDataUpdate:a}=Ri(),l=(A=(O=s.nodeConfigPanel)==null?void 0:O.testArea)==null?void 0:A.defaultTestResult,[c,u]=y.useState(()=>{if(l==null)return"";if(typeof l=="string")return l;try{return JSON.stringify(l,null,2)}catch{return String(l)}}),d=ne.useInternalNode(n),f=Et.useReactive({testProgress:0,sampleText:"",isError:!1,showErrorAlert:!1,testing:!1,successShown:!1,sampleMode:!1,sampleSaving:!1,sampleError:"",isIgnoreSuccess:!1,ignoring:!1,editable:!1}),{refreshFlow:p}=ao();(T=d==null?void 0:d.data)==null||T.outputSource,y.useEffect(()=>{if(d!=null&&d.data.output&&(d.data.status===me.SUCCESS||d.data.status===me.RUNNABLE)){const I=typeof d.data.output=="string"?d.data.output:JSON.stringify(d.data.output,null,2);u(I),f.successShown=!0,f.isError=!1,f.showErrorAlert=!1}else if(d!=null&&d.data.output&&d.data.status===me.FAILED){const I=typeof d.data.output=="string"?d.data.output:JSON.stringify(d.data.output,null,2);u(I),f.isError=!0,f.showErrorAlert=!0,f.successShown=!1}},[d,f]);const m=y.useCallback(()=>{if(!n){console.error("节点ID不能为空");return}f.testing=!0,f.testProgress=60,f.successShown=!1,f.isError=!1,f.showErrorAlert=!1,f.sampleMode=!1,By(n).then(I=>{const F=I,N=KG(F),P=N===me.FAILED;f.isError=P,f.successShown=!P,f.showErrorAlert=f.isError;let M="";try{M=YG(F)}catch(z){console.error("格式化测试结果出错:",z),M=`测试结果格式化失败: ${String(z)}`}f.testProgress=100,u(M),a({id:n,data:{status:N,output:M,outputSource:"test"}})}).catch(I=>{var P;console.error("测试失败:",I),f.testProgress=0,f.isError=!0,f.showErrorAlert=!0,f.successShown=!1;let F="测试执行失败";(P=I==null?void 0:I.response)!=null&&P.data?F=JSON.stringify(I.response.data,null,2):I!=null&&I.message&&(F=I.message);const N=JSON.stringify({error:F},null,2);u(N),a({id:n,data:{status:me.FAILED,output:N,outputSource:"test"}})}).finally(()=>{setTimeout(()=>{f.testProgress=0,f.testing=!1},500)})},[a,n,f]),v=()=>{f.testProgress=0,f.testing=!1,f.sampleSaving=!1,f.sampleMode=!1,f.successShown=!0,f.isError=!1,f.showErrorAlert=!1},b=()=>{r&&(f.testing=!0,f.ignoring=!0,f.testProgress=60,r(!0,!0,f.sampleText))},w=()=>{f.sampleSaving=!1,f.ignoring=!1,f.successShown=!0,f.isError=!1,f.showErrorAlert=!1,f.isIgnoreSuccess=!0},g=()=>{f.testProgress=0,f.testing=!1,f.ignoring=!1,f.isIgnoreSuccess=!0};y.useImperativeHandle(e,()=>({onTestNode:m,finishSampleTest:v,abortSampleTest:w,finishNodeTest:g}));const C=()=>{f.sampleMode=!1,r?r(!0):m()},k=()=>{u(""),f.sampleText="",f.sampleMode=!1,f.sampleError="",f.successShown=!1},_=Ot(),S=y.useMemo(()=>{var I;return UG({canEdit:_,nodeType:d==null?void 0:d.type,protocol:(I=d==null?void 0:d.data)==null?void 0:I.protocol})},[_,(B=d==null?void 0:d.data)==null?void 0:B.protocol,d==null?void 0:d.type]),E=S.disabled?"disabled":f.testing?"running":f.isError?"failure":f.successShown?f.isIgnoreSuccess?"ignored":"success":"waiting",x=()=>{if(f.editable){f.editable=!1;try{const I=JSON.parse(f.sampleText),F=JSON.stringify(I,null,2);u(F),a({id:n,data:{output:F}})}catch{u(f.sampleText)}return}f.sampleText=c,f.editable=!0};return h.jsx(iO,{status:E,result:c,progress:f.testProgress||60,runningAction:f.ignoring?"ignore":"run",showAlert:f.isError?f.showErrorAlert:f.successShown,canEdit:_,disabledReason:S.reason,editing:f.editable,editableValue:f.sampleText,onEditableValueChange:I=>{f.sampleText=I},onRun:C,onIgnore:b,onReset:k,onToggleEdit:x,onDismissAlert:()=>{f.showErrorAlert=!1,f.successShown=!1},onClose:o,onExpandPanel:i})});var tr=(t=>(t.Array="ARRAY",t.Boolean="BOOLEAN",t.Null="NULL",t.Number="NUMBER",t.Object="OBJECT",t.String="STRING",t))(tr||{});const sw={ARRAY:"purple",BOOLEAN:"green",NULL:"default",NUMBER:"blue",OBJECT:"cyan",STRING:"orange"},JG={ARRAY:"Arr",BOOLEAN:"Bool",NULL:"Null",NUMBER:"Num",OBJECT:"Obj",STRING:"Str"},aw=(t,e=!1)=>{const n=String(t||"STRING").toUpperCase(),r=JG[n]||n.slice(0,4);return e?`${r}[]`:r},sO=t=>{t!=null&&t.length&&t.forEach(e=>{e.label||(e.label=e.name),Array.isArray(e.sub_params)?sO(e.sub_params):e.sub_params=[]})},QG=t=>{const e=t==null?void 0:t.map(r=>(r.output.label=`${r.seq}-${r.connector_name} : ${r.action_name}`,r.note&&(r.output.label+=`(${r.note})`),{...r,label:`${r.connector_name}-${r.action_name}`,sub_params:[r.output]})),n=Pt.cloneDeep(e);return sO(n),n};var aO=(t=>(t.TEXT="TEXT",t.NUMBER="NUMBER",t.JSON="JSON",t))(aO||{});const ZG=t=>({TEXT:"STRING",NUMBER:"NUMBER",JSON:"OBJECT"})[t]||"STRING",eR=t=>{const{nodeId:e,flowId:n,enabled:r=!0,includeGlobalVariables:o=!0}=t,i=ne.useStoreApi(),[s,a]=y.useState([]),[l,c]=y.useState([]),[u,d]=y.useState(!1),[f,p]=y.useState(null),[m,v]=y.useState(0),[b,w]=y.useState(!1),[g,C]=y.useState(null),[k,_]=y.useState(0),S=y.useCallback(()=>{v(T=>T+1)},[]),E=y.useCallback(()=>{_(T=>T+1)},[]),x=y.useCallback(()=>{v(T=>T+1),_(T=>T+1)},[]);return y.useEffect(()=>{if(!r||!o){o||a([]),d(!1),p(null);return}let T=!1;return(async()=>{d(!0),p(null);try{const I=await Py();if(T)return;const F=((I==null?void 0:I.items)||[]).map(N=>({...N,mappedType:ZG(N.var_type)}));a(N=>Pt.isEqual(N,F)?N:F)}catch(I){console.error("Failed to fetch global variables:",I),T||p(I instanceof Error?I:new Error("无法获取全局变量数据"))}finally{T||d(!1)}})(),()=>{T=!0}},[r,o,m]),y.useEffect(()=>{if(!r||!n){w(!1),C(null);return}let T=!1;return(async()=>{w(!0),C(null);try{const{edges:I,nodes:F}=i.getState(),N=await Iy(n,{nodeId:e,edges:I});if(T)return;const P=new Map(F.map(H=>[H.id,H])),z=(QG(N)||[]).map(H=>{var $,j;const R=($=H.node_id)!=null&&$.startsWith("N")?H.node_id.slice(1):H.node_id,Y=R?P.get(R):void 0,te=typeof((j=Y==null?void 0:Y.data)==null?void 0:j.icon)=="string"?Y.data.icon:void 0;return{...H,nodeIcon:te,isValid:!!Y}});c(H=>Pt.isEqual(H,z)?H:z)}catch(I){console.error("Failed to fetch node variables:",I),T||C(I instanceof Error?I:new Error("无法获取节点变量数据"))}finally{T||w(!1)}})(),()=>{T=!0}},[n,e,r,k,i]),{globalVariables:s,nodeVariables:l,isLoading:u||b,isGlobalLoading:u,isNodeLoading:b,error:f||g,globalError:f,nodeError:g,refresh:x,refreshGlobal:S,refreshNode:E}},it={container:"_container_70r0s_5",header:"_header_70r0s_29",headerIcon:"_headerIcon_70r0s_37",headerTitle:"_headerTitle_70r0s_41",body:"_body_70r0s_46",section:"_section_70r0s_61",sectionLabel:"_sectionLabel_70r0s_65",sectionIcon:"_sectionIcon_70r0s_79",typeTag:"_typeTag_70r0s_88",varItem:"_varItem_70r0s_97",varName:"_varName_70r0s_115",varValue:"_varValue_70r0s_121",nodeTitle:"_nodeTitle_70r0s_129",nodeIcon:"_nodeIcon_70r0s_134",nodeLabelFirst:"_nodeLabelFirst_70r0s_139",nodeLabel:"_nodeLabel_70r0s_139",leafTitle:"_leafTitle_70r0s_151",leafLabel:"_leafLabel_70r0s_156",leafValue:"_leafValue_70r0s_162",empty:"_empty_70r0s_168",loadingState:"_loadingState_70r0s_171",errorState:"_errorState_70r0s_180",invalidVariable:"_invalidVariable_70r0s_184",nodeIconWrapper:"_nodeIconWrapper_70r0s_193",defaultNodeIcon:"_defaultNodeIcon_70r0s_206"},lw={VariableModalTitle:h.jsx(Te.FormattedMessage,{id:"app.common.word.select-variable"}),NoTestDataDesc:h.jsx(Te.FormattedMessage,{id:"common.no-process-variables-yet"})},tR=t=>{if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="object")try{return JSON.stringify(t)}catch{return String(t)}return String(t)},nR=(t,e)=>{const n=t.trim(),r=n.startsWith("N")?n:`N${n}`,o=e.slice(1).join(".");return o?`{{${r}.${o}}}`:`{{${r}}}`},lO=y.forwardRef((t,e)=>{const n=El(),{nodeId:r,showGlobalVariables:o=!0}=t,{event$:i}=y.useContext(Qr),{globalVariables:s,nodeVariables:a,isGlobalLoading:l,isNodeLoading:c,globalError:u,nodeError:d,refreshGlobal:f,refreshNode:p}=eR({nodeId:r,flowId:n,enabled:t.open,includeGlobalVariables:o}),m=Et.useReactive({currentInputId:"",visible:!0});i.useSubscription(w=>{switch(w.type){case"visible":m.visible||(f(),p()),m.visible=w.visible;break;case"setCurrentInputId":m.currentInputId=w.currentInputId;break}}),y.useImperativeHandle(e,()=>({loadVariables:()=>{f(),p()}}));const v=w=>{try{const g=typeof w=="string"?JSON.parse(w):w,C=(_,S)=>{if(_==null)return{name:S,type:tr.Null,label:S,multi_valued:!1,sub_params:[],value:String(_)};if(typeof _=="object"&&!Array.isArray(_)){const x=_;return{name:S,type:tr.Object,label:S,multi_valued:!1,sub_params:Object.keys(x).map(O=>C(x[O],O)),value:null}}if(Array.isArray(_)){const x=_[0],O=x&&typeof x=="object"?tr.Object:typeof x=="number"?tr.Number:typeof x=="boolean"?tr.Boolean:x==null?tr.Array:tr.String;return{name:S,type:O,label:S,multi_valued:!0,sub_params:[],value:JSON.stringify(_)}}const E=typeof _=="number"?tr.Number:typeof _=="boolean"?tr.Boolean:tr.String;return{name:S,type:E,label:S,multi_valued:!1,sub_params:[],value:String(_)}},k=g&&typeof g=="object"&&!Array.isArray(g)?g:{};return Object.keys(k).map(_=>C(k[_],_))}catch{return[]}},b=(w,g,C,k,_,S=[],E="0")=>(w??[]).map((x,O)=>{var I;const A=[...S,x.name],T=`${E}-${O}`;return(I=x.sub_params)!=null&&I.length?{key:T,variablePath:A,title:h.jsxs("span",{className:`${it.nodeTitle}${k===!1?` ${it.invalidVariable}`:""}`,children:[g?_==="api"?h.jsx(se.ApiOutlined,{className:it.nodeIcon}):h.jsx("span",{className:it.nodeIconWrapper,children:C?h.jsx("img",{src:C,alt:""}):h.jsx("span",{className:it.defaultNodeIcon,children:"N"})}):h.jsx(D.Tag,{color:sw[x.type]||"gray",className:`${it.typeTag} workflow-variable-panel__type`,children:aw(x.type,x.multi_valued)}),h.jsx("span",{className:`${g?it.nodeLabelFirst:it.nodeLabel} workflow-variable-panel__label`,children:x.label})]}),children:b(x.sub_params,!1,C,k,_,A,T)}:{key:T,variablePath:A,title:h.jsxs("span",{className:`${it.leafTitle}${k===!1?` ${it.invalidVariable}`:""}`,children:[h.jsx(D.Tag,{color:sw[x.type]||"gray",className:`${it.typeTag} workflow-variable-panel__type`,children:aw(x.type,x.multi_valued)}),h.jsx("span",{className:`${it.leafLabel} workflow-variable-panel__label`,children:x.label}),x.value?h.jsx("span",{className:it.leafValue,children:x.value}):null]})}});return h.jsxs("div",{className:`${it.container} workflow-variable-panel`,children:[h.jsxs("div",{className:`${it.header} workflow-variable-panel__header`,children:[h.jsx(CW,{size:16,className:`${it.headerIcon} workflow-variable-panel__header-icon`}),h.jsx("span",{className:`${it.headerTitle} workflow-variable-panel__title`,children:lw.VariableModalTitle})]}),h.jsxs("div",{className:`${it.body} workflow-variable-panel__body`,children:[o?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:`${it.sectionLabel} workflow-variable-panel__section-label`,children:[h.jsx(se.GlobalOutlined,{className:it.sectionIcon,size:32}),h.jsx("span",{children:"全局变量"})]}),h.jsx("div",{className:`variable-panel-group ${!l&&!u&&s.length<1?"empty":""}`,children:h.jsxs("div",{className:it.section,children:[s.map(w=>{if(w.var_type===aO.JSON){const k=v(w.var_value??{}),_=[{name:w.name,type:tr.Object,label:w.display_name||w.name,multi_valued:!1,sub_params:k,value:null}],S=b(_,!0,void 0,!0,"api");return h.jsx(D.Tree,{defaultExpandAll:!0,showLine:!0,onSelect:(E,x)=>{const O=x.node.variablePath;i.emit({type:"insert",currentInputId:m.currentInputId,expression:`{{global.${O.join(".")}}}`})},switcherIcon:h.jsx(se.CaretDownOutlined,{}),treeData:S},w.id)}const g=tR(w.var_value),C=g.length>28?`${g.substring(0,28)}...`:g;return h.jsxs("button",{type:"button",className:`${it.varItem} workflow-variable-panel__item`,onClick:()=>{i.emit({type:"insert",currentInputId:m.currentInputId,expression:`{{global.${w.name}}}`})},children:[h.jsx(D.Tag,{color:sw[w.mappedType],className:`${it.typeTag} workflow-variable-panel__type`,children:aw(w.mappedType)}),h.jsx("span",{className:`${it.varName} workflow-variable-panel__label`,children:w.display_name||w.name}),C?h.jsx("span",{className:it.varValue,children:C}):null]},w.id)}),!l&&!u&&s.length<1&&h.jsx(D.Empty,{image:D.Empty.PRESENTED_IMAGE_SIMPLE,description:lw.NoTestDataDesc,className:it.empty}),l?h.jsxs("div",{className:it.loadingState,children:[h.jsx(D.Spin,{size:"small"}),h.jsx("span",{children:"正在加载全局变量"})]}):u?h.jsx(D.Alert,{className:it.errorState,type:"error",showIcon:!0,message:"全局变量加载失败",description:u.message,action:h.jsx(D.Button,{size:"small",onClick:f,children:"重试"})}):null]})})]}):null,h.jsxs("div",{className:`${it.sectionLabel} workflow-variable-panel__section-label`,children:[h.jsx(se.ApiOutlined,{className:it.sectionIcon}),h.jsx("span",{children:"节点变量"})]}),h.jsx("div",{className:`variable-panel-group ${!c&&!d&&a.length<1?"empty":""}`,children:h.jsxs("div",{className:it.section,children:[a.map(w=>h.jsx("div",{children:h.jsx(D.Tree,{defaultExpandAll:!0,showLine:!0,onSelect:(g,C)=>{const k=C.node.variablePath;if(k.length<=1)return!1;i.emit({type:"insert",currentInputId:m.currentInputId,expression:nR(w.node_id,k)})},switcherIcon:h.jsx(se.CaretDownOutlined,{}),treeData:b(w.sub_params,!0,w.nodeIcon,w.isValid,"node")})},`${w.node_id}-${w.seq}`)),!c&&!d&&a.length<1&&h.jsx(D.Empty,{image:D.Empty.PRESENTED_IMAGE_SIMPLE,description:lw.NoTestDataDesc,className:it.empty}),c?h.jsxs("div",{className:it.loadingState,children:[h.jsx(D.Spin,{size:"small"}),h.jsx("span",{children:"正在加载节点变量"})]}):d?h.jsx(D.Alert,{className:it.errorState,type:"error",showIcon:!0,message:"节点变量加载失败",description:d.message,action:h.jsx(D.Button,{size:"small",onClick:p,children:"重试"})}):null]})})]})]})}),{Option:Po}=D.Select,rR=y.forwardRef(({onSubmit:t,config_schema:e,nodeId:n},r)=>{const[o]=D.Form.useForm(),i=xl(),s=D.Form.useWatch("type",o);Et.useMount(()=>{e&&Object.hasOwn(e,"asc")&&o.setFieldsValue(e)});const[a,l]=y.useState(!1),c=(d,f,p="")=>(l(!0),o.validateFields().then(async m=>s&&s==="NUMBER"&&m.start>m.end?D.message.warning(K("link.flow.loop_start_end_check")):t({properties:m},d)).catch(()=>(D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>l(!1)));y.useImperativeHandle(r,()=>({saveConfig:d=>c(d)}));const u=Ot();return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:i,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsxs(D.Form,{disabled:!u,form:o,layout:"vertical",children:[h.jsxs(D.Row,{children:[h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{name:"type",label:K("app.common.word.loop-data-type"),rules:[{required:!0,message:K("link.flow.please_select_data_type")}],children:h.jsxs(D.Select,{children:[h.jsx(Po,{value:"ARRAY",children:h.jsx(Te.FormattedMessage,{id:"link.flow.array"})}),h.jsx(Po,{value:"NUMBER",children:h.jsx(Te.FormattedMessage,{id:"common.number"})}),h.jsx(Po,{value:"CONDITION",children:h.jsx(Te.FormattedMessage,{id:"link.flow.condition_expression"})})]})})}),s&&s==="NUMBER"&&h.jsx(D.Col,{sm:24,lg:12,children:h.jsxs(D.Form.Item,{required:!0,label:K("link.flow.loop_start_end"),style:{display:"flex"},children:[h.jsx(D.Form.Item,{name:"start",noStyle:!0,rules:[{required:!0,message:K("link.flow.please_select_data_type")}],children:h.jsx(D.InputNumber,{min:1,style:{marginRight:20}})}),h.jsx(D.Form.Item,{name:"end",noStyle:!0,rules:[{required:!0,message:K("link.flow.please_select_data_type")}],children:h.jsx(D.InputNumber,{min:1})})]})}),s&&s!=="NUMBER"&&h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{rules:[{required:!0,message:K("link.flow.please_enter_loop_expression")}],label:K("link.flow.loop_expression"),name:"expression",children:h.jsx(Pn,{nodeId:n,borrow:!0,valueType:"JS_EXP",placeholder:K("link.flow.please_enter_loop_expression")})})}),!s&&h.jsx(D.Col,{})]}),h.jsxs(D.Row,{children:[h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{name:"asc",label:K("app.common.word.circulation-direction"),rules:[{required:!0,message:K("link.flow.please_select_loop_direction")}],children:h.jsxs(D.Select,{children:[h.jsx(Po,{value:!0,children:h.jsx(Te.FormattedMessage,{id:"link.flow.loop_head_to_tail"})}),h.jsx(Po,{value:!1,children:h.jsx(Te.FormattedMessage,{id:"link.flow.loop_tail_to_head"})})]})})}),h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{name:"errorExec",label:K("link.flow.loop_processing"),rules:[{required:!0,message:K("link.flow.please_select_loop_processing")}],children:h.jsxs(D.Select,{children:[h.jsx(Po,{value:"END",children:h.jsx(Te.FormattedMessage,{id:"link.flow.terminate_process"})}),h.jsx(Po,{value:"CONTINUE",children:h.jsx(Te.FormattedMessage,{id:"link.flow.continue_loop"})}),h.jsx(Po,{value:"BREAK",children:h.jsx(Te.FormattedMessage,{id:"link.flow.break_loop"})})]})})})]})]})}),h.jsx("div",{className:"workflow-node-form-footer",children:u&&h.jsx(D.Button,{type:"primary",disabled:!u,loading:a,className:"workflow-node-form-save",onClick:()=>c(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),Ud=()=>`branch_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,{Option:oR}=D.Select,iR=y.forwardRef((t,e)=>{const{config_schema:n,nodeId:r}=t,[o]=D.Form.useForm(),i=xl(),{handleNodeDataUpdate:s}=Ri(),[a,l]=y.useState(null),[c,u]=y.useState(""),f=(E=>!(E!=null&&E.branches)||E.branches.length===0?{branches:[{id:Ud(),name:K("link.flow.switch.condition_one"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]},{id:Ud(),name:K("link.flow.switch.condition_two"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]}]}:{branches:E.branches.map((O,A)=>{var T;return{id:O.id||Ud(),name:O.name||K("link.flow.switch.condition_n",{n:A+1}),or_list:((T=O.or_list)==null?void 0:T.map(B=>{var I;return{and_list:((I=B.and_list)==null?void 0:I.map(F=>({query:F.query||"",operator:F.operator||"",value:F.value||""})))||[{query:"",operator:"",value:""}]}}))||[{and_list:[{query:"",operator:"",value:""}]}]}})})(n),p=()=>{const E=o.getFieldValue("branches")||[];s({id:r,data:{config_schema:{branches:E}}})},m=(E,x)=>{l(E),u(x)},v=()=>{l(null),u("")},b=E=>{const x=Pt.cloneDeep(o.getFieldValue("branches"))||[],O=c.trim();if(!O){D.message.error(K("link.flow.switch.branch_name_cannot_be_empty"));return}if(x.some((T,B)=>B!==E&&T.name===O)){D.message.error(K("link.flow.switch.branch_name_duplicate"));return}x[E].name=O,o.setFieldValue("branches",x),l(null),u(""),p()},w=(E,x)=>{const O=o.getFieldValue("branches")||[];if(x<0||x>=O.length)return;const A=[...O],[T]=A.splice(E,1);A.splice(x,0,T),o.setFieldValue("branches",A),p()},[g,C]=y.useState(!1),k=E=>(C(!0),o.validateFields().then(async x=>{if(!x.branches.some(T=>T.or_list.some(B=>B.and_list.some(I=>I.query&&I.operator)))){D.message.error(K("link.flow.switch.at_least_one_valid_branch"));return}const A=Pt.cloneDeep(x);return A.branches.forEach(T=>{T.or_list.forEach(B=>{B.and_list.forEach(I=>{I.value=FG(I.operator,I.value)})})}),t.onSubmit({properties:A},E)}).catch(()=>(D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>C(!1)));y.useImperativeHandle(e,()=>({saveConfig:E=>k(E)}));const _=Ot(),S=(E,x,O,A)=>{const B=(o.getFieldValue("branches")||[])[x],I=a===x;return h.jsxs(D.Card,{style:{marginBottom:20,borderRadius:8,border:"1px solid #d9d9d9"},styles:{body:{padding:10}},children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:12},children:[h.jsx("div",{style:{display:"flex",alignItems:"center",flex:1},children:I?h.jsxs(D.Space,{children:[h.jsx(D.Input,{value:c,onChange:F=>u(F.target.value),style:{width:200},placeholder:K("link.flow.switch.enter_branch_name"),onPressEnter:()=>b(x)}),h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.CheckOutlined,{style:{color:"#52c41a"}}),onClick:()=>b(x)}),h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.CloseOutlined,{}),onClick:v})]}):h.jsxs(D.Space,{children:[h.jsx("span",{style:{fontSize:13,fontWeight:400},children:(B==null?void 0:B.name)||K("link.flow.switch.condition_n",{n:x+1})}),_&&h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.EditOutlined,{}),onClick:()=>m(x,(B==null?void 0:B.name)||"")})]})}),_&&h.jsxs(D.Space,{className:"actions",children:[h.jsx(D.Tooltip,{title:K("link.flow.switch.move_to_top"),children:h.jsx(D.Button,{type:"text",size:"small",disabled:x===0,onClick:()=>w(x,0),children:"置顶"})}),h.jsx(D.Tooltip,{title:K("link.flow.switch.move_up"),children:h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.ArrowUpOutlined,{}),disabled:x===0,onClick:()=>w(x,x-1)})}),h.jsx(D.Tooltip,{title:K("link.flow.switch.move_down"),children:h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.ArrowDownOutlined,{}),disabled:x===O-1,onClick:()=>w(x,x+1)})}),h.jsx(D.Tooltip,{title:K("link.flow.switch.move_to_bottom"),children:h.jsx(D.Button,{type:"text",size:"small",disabled:x===O-1,onClick:()=>w(x,O-1),children:"置底"})}),h.jsx(D.Tooltip,{title:K("common.delete"),children:h.jsx(D.Button,{type:"text",size:"small",disabled:O<=1,onClick:()=>{if(O<=1){D.message.warning(K("link.flow.switch.at_least_one_branch"));return}A(E.name),setTimeout(()=>{p()},0)},children:"删除"})})]})]}),h.jsx(D.Form.Item,{name:[E.name,"name"],hidden:!0,children:h.jsx(D.Input,{})}),h.jsx(D.Form.List,{name:[E.name,"or_list"],children:(F,{add:N,remove:P})=>h.jsx(h.Fragment,{children:F.map((M,z)=>{const H=z===F.length-1;return h.jsx(h.Fragment,{children:h.jsxs("div",{className:"switch-rule",children:[F.length>1&&_&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsxs(D.Button,{type:"link",icon:h.jsx(se.MinusCircleOutlined,{}),onClick:()=>P(M.name),children:[h.jsx(Te.FormattedMessage,{id:"link.flow.remove"})," OR"]})}),h.jsx(D.Form.List,{name:[M.name,"and_list"],children:(R,{add:Y,remove:te})=>h.jsx(h.Fragment,{children:R.map(($,j)=>{const U=j===R.length-1;return h.jsxs(D.Space,{direction:"vertical",style:{width:"100%"},children:[h.jsxs(D.Space,{align:"center",className:"switch-rule-item",children:[h.jsx(D.Form.Item,{style:{minWidth:150,marginBottom:0},name:[$.name,"query"],label:K("app.common.word.variable-name"),rules:[{required:!0,message:K("link.flow.please_enter_variable_name")}],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),h.jsx(D.Form.Item,{style:{marginBottom:0},name:[$.name,"operator"],label:K("app.common.word.condition"),rules:[{required:!0,message:K("link.flow.please_select_condition")}],children:h.jsx(D.Select,{style:{minWidth:140},placeholder:K("link.flow.select_condition"),getPopupContainer:()=>document.body,children:oO.map(ee=>h.jsx(oR,{value:ee.operator,children:ee.label},ee.operator))})}),h.jsx(D.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const ee=o.getFieldValue(["branches",E.name,"or_list",M.name,"and_list",$.name,"operator"]);return iw(ee)?null:h.jsx(D.Form.Item,{style:{minWidth:150,marginBottom:0},name:[$.name,"value"],label:K("app.common.word.value"),rules:[],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),j===0&&h.jsx("div",{style:{width:30}}),j>0&&_&&h.jsx(D.Button,{type:"link",icon:h.jsx(se.MinusCircleOutlined,{}),onClick:()=>te($.name)})]}),j<R.length-1&&h.jsx(D.Divider,{plain:!0,style:{margin:"8px 0"},children:h.jsx(D.Tag,{color:"#999999",children:h.jsx(Te.FormattedMessage,{id:"link.flow.and"})})}),h.jsxs("div",{className:`rule-opt-actions ${U?"last-and-rule":""}`,children:[j===R.length-1&&h.jsx(D.Button,{type:"link",disabled:!_,icon:h.jsx(br,{size:14}),onClick:()=>Y({query:"",operator:"",value:""}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-new-and"})}),H&&h.jsx(D.Button,{type:"link",icon:h.jsx(br,{size:14}),disabled:!_,onClick:()=>N({and_list:[{query:"",operator:"",value:""}]}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-or"})})]})]},$.key)})})}),!H&&h.jsx("div",{style:{textAlign:"center"},children:h.jsx(D.Divider,{style:{color:"orange"},dashed:!0,children:h.jsx(D.Tag,{color:"#1890ff",children:h.jsx(Te.FormattedMessage,{id:"link.flow.or"})})})})]},M.key)})})})})]},E.key)};return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:i,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsx(D.Form,{disabled:!_,form:o,initialValues:f,layout:"vertical",autoComplete:"off",children:h.jsx(D.Form.List,{name:"branches",children:(E,{add:x,remove:O})=>h.jsxs(h.Fragment,{children:[E.map((A,T)=>S(A,T,E.length,O)),E.length<10&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end",width:"100%"},children:h.jsx(D.Button,{type:"default",icon:h.jsx(br,{size:14}),disabled:!_,onClick:()=>{const A=E.length+1;x({id:Ud(),name:K("link.flow.switch.condition_n",{n:A}),or_list:[{and_list:[{query:"",operator:"",value:""}]}]}),setTimeout(()=>{p()},0)},children:h.jsx(Te.FormattedMessage,{id:"link.flow.switch.add_branch"})})}),E.length>=10&&h.jsx("div",{style:{textAlign:"center",color:"#999",marginBottom:20},children:h.jsx(Te.FormattedMessage,{id:"link.flow.switch.max_branches_reached"})})]})})})}),h.jsx("div",{className:"workflow-node-form-footer",children:_&&h.jsx(D.Button,{type:"primary",disabled:!_,loading:g,className:"workflow-node-form-save",onClick:()=>k(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),sR=({nodeId:t,onSubmit:e,data:n})=>{const[r]=D.Form.useForm(),o=xl(),i=Ot(),{refreshFlow:s}=ao(),{setNodes:a}=ne.useReactFlow(),l=y.useCallback((u,d)=>{a(f=>f.map(p=>!d&&p.id!==t?p:{...p,data:{...p.data,error_handler:u}}))},[t,a]);y.useEffect(()=>{const u=(n==null?void 0:n.error_handler)||{};r.setFieldsValue({retryEnabled:u.retry||!1,retryCount:u.retry_times||3,retryInterval:u.retry_interval||5,stepFactor:u.step_factor||1.5,maxRetryInterval:u.max_retry_interval||60,alertEnabled:u.warn_type===1,webhookUrl:u.notify_url||"",errorHandling:u.process_type===2?"ignore":"interrupt",applyToAllNodes:!!u.apply_all})},[t,r,n==null?void 0:n.error_handler]);const c=async u=>{try{const d={retry:u.retryEnabled,retry_times:u.retryEnabled?u.retryCount:void 0,retry_interval:u.retryEnabled?u.retryInterval:void 0,step_factor:u.retryEnabled?u.stepFactor:void 0,max_retry_interval:u.retryEnabled?u.maxRetryInterval:void 0,warn_type:u.alertEnabled?1:0,notify_url:u.alertEnabled?u.webhookUrl:void 0,process_type:u.errorHandling==="interrupt"?1:2,apply_all:u.applyToAllNodes};await rc(t,{error_handler:d}),l(d,u.applyToAllNodes),u.applyToAllNodes&&s(),e()}catch{D.message.error(K("common.save_failed"))}};return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:o,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsxs(jn.ProForm,{form:r,layout:"vertical",disabled:!i,submitter:!1,onFinish:c,children:[h.jsx(jn.ProFormSwitch,{name:"retryEnabled",label:K("app.common.word.enable-retry")}),h.jsx(jn.ProFormDependency,{name:["retryEnabled"],children:({retryEnabled:u})=>u?h.jsxs(h.Fragment,{children:[h.jsx(jn.ProFormDigit,{name:"retryCount",label:K("app.common.word.retry-count"),tooltip:K("app.common.word.retry-count-tooltip"),width:"xl",fieldProps:{min:1,max:10,precision:0,style:{width:"100%"}},rules:[{required:u,message:K("app.common.word.please-enter-retry-count")}]}),h.jsx(jn.ProFormDigit,{name:"retryInterval",label:K("app.common.word.retry-interval"),tooltip:K("app.common.word.retry-interval-tooltip"),fieldProps:{min:1,max:60,precision:0,style:{width:"100%"},addonAfter:"s"},rules:[{required:u,message:K("app.common.word.please-enter-retry-interval")}]}),h.jsx(jn.ProFormDigit,{name:"stepFactor",label:K("app.common.word.step-factor"),tooltip:K("app.common.word.step-factor-tooltip"),width:"xl",fieldProps:{min:1,max:5,precision:1,style:{width:"100%"}},rules:[{required:u,message:K("app.common.word.please-enter-step-factor")}]}),h.jsx(jn.ProFormDigit,{name:"maxRetryInterval",label:K("app.common.word.max-retry-interval"),tooltip:K("app.common.word.max-retry-interval-tooltip"),width:"xl",fieldProps:{min:1,max:300,precision:0,style:{width:"100%"},addonAfter:"s"},rules:[{required:u,message:K("app.common.word.please-enter-max-retry-interval")}]})]}):null}),h.jsx(jn.ProFormSwitch,{name:"alertEnabled",label:K("app.common.word.enable-alert")}),h.jsx(jn.ProFormDependency,{name:["alertEnabled"],children:({alertEnabled:u})=>u?h.jsx(jn.ProFormText,{name:"webhookUrl",label:K("app.common.word.webhook-url"),placeholder:K("app.common.word.enter-webhook-url"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:u,message:K("app.common.word.enter-webhook-url")}]}):null}),h.jsx(jn.ProFormSelect,{name:"errorHandling",label:K("app.common.word.error-handling"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:!0,message:K("app.common.word.select-error-handling")}],options:[{label:K("app.common.word.interrupt-flow"),value:"interrupt"},{label:K("app.common.word.ignore-error"),value:"ignore"}]}),h.jsx(jn.ProFormSwitch,{name:"applyToAllNodes",label:K("app.common.word.apply-to-all-nodes")})]})}),h.jsx("div",{className:"workflow-node-form-footer",children:h.jsx(D.Button,{type:"primary",disabled:!i,onClick:()=>r.submit(),className:"workflow-node-form-save",children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})},cO="[workflow:schema-render]",aR=()=>{const{event$:t}=y.useContext(Qr),e=Fh();return t.useSubscription(n=>{var r;n.type==="insert"&&n.expression&&(r=e==null?void 0:e.getActiveFieldId)!=null&&r.call(e)&&e.insertVariableToActiveField(n.expression,!1)}),null},lR=({children:t})=>{const{event$:e}=y.useContext(Qr),n=Mh(),[r,o]=y.useState("");e.useSubscription(a=>{a.type==="setCurrentInputId"&&o(a.currentInputId??"")});const i=(n==null?void 0:n.activeFieldId)??r,s=y.useMemo(()=>({activeInputId:i}),[i]);return h.jsx(cx.Provider,{value:s,children:t})},cR=t=>{const{icon:e,fallbackIcon:n}=t;return h.jsxs("div",{className:"node-config-title",style:{display:"flex",alignItems:"center"},children:[h.jsx("div",{className:"node-config-icon",style:{backgroundImage:`url(${n?"none":e??"https://digitalsee-image.digitalsee.cn/flow/0.png"})`},children:n&&n}),h.jsxs("div",{className:"node-config-meta",children:[h.jsx("div",{className:"node-config-title-name",style:{fontSize:16,fontWeight:600,marginLeft:10},children:t.name}),h.jsx("div",{className:"node-config-title-description",style:{fontSize:12,color:"gray",marginLeft:10},children:t.description})]})]})},uR=y.memo(({visible:t,onClose:e,data:n,nodeType:r=pe.ACTION,nodeId:o=""})=>{var B,I;const i=Et.useEventEmitter();ne.useInternalNode(o);const{setNodeConfigVisible:s,refreshFlow:a}=ao(),l=y.useRef(null),c=y.useRef(null),u=y.useRef(null),d=y.useRef(null),f=y.useRef(null);y.useRef(null);const p=y.useRef(null),m=ne.useStoreApi(),v=$t(),b=((I=(B=v.nodeConfigPanel)==null?void 0:B.testArea)==null?void 0:I.allowManualTest)!==!1,w=Et.useReactive({output:"",ignore:!1,expandTestPanel:!1}),g=y.useMemo(()=>v.nodeConfigPanel.showSettings&&![pe.TRIGGER,pe.AI_SUB_NODE].includes(r),[r,v.nodeConfigPanel.showSettings]),C=(n==null?void 0:n.action_id)??(n==null?void 0:n.id),k=C!==null&&typeof C<"u"&&C!==""&&Number.isFinite(Number(C))?C:null,_=po(n),S=n==null?void 0:n.nodeKey,E=(n==null?void 0:n.nodeVersion)??(n==null?void 0:n.action_ver),{handleNodeDataUpdate:x}=Ri();y.useEffect(()=>{var N,P;if(!t)return;const F=k!==null&&Number(k)<=0;S&&F&&!_&&!((N=n==null?void 0:n.config_schema)!=null&&N.sub_params)&&!((P=n==null?void 0:n.properties)!=null&&P.sub_params)&&console.warn(`${cO} possible nodepackage schema route mismatch`,{nodeId:o,nodeType:r,actionId:k,nodePackageKey:S,nodePackageVersion:E,reason:"keyed node with non-positive action_id and no classic sub_params was rejected by the nodePackage-compatible node check"})},[k,n==null?void 0:n.config_schema,n==null?void 0:n.properties,n==null?void 0:n.params,n==null?void 0:n.action_key,n==null?void 0:n.action_ver,n==null?void 0:n.nodeKey,n==null?void 0:n.nodeVersion,_,S,E,o,r,t]);const O=y.useCallback(async(F,N)=>{var M,z,H;const P=v.flowId;try{const R=m.getState().nodes.find(U=>U.id===o),Y=_?ZP(F):F.properties,te=_?e2(F):F.account_id??null,$=_?{flow_id:P,properties:Y,position:R==null?void 0:R.position,action_id:k,account_id:te,proxy_id:F.proxy_id,mcp_tool_description:F.mcp_tool_description,action_key:S,action_ver:E}:{flow_id:P,...F,position:R==null?void 0:R.position,action_id:k};console.info(`${cO} save node config`,{nodeId:o,nodeType:r,actionId:k,isNodepackageNode:_,nodePackageKey:S,nodePackageVersion:E,valueKeys:Object.keys(F||{}),paramsKeys:Object.keys((F==null?void 0:F.params)||{}),propertiesKeys:Object.keys((F==null?void 0:F.properties)||{}),ignoreDebugResult:w.ignore});const j=w.ignore?await My(o,"","","",Y,w.output):await rc(o,$);if(j)if(w.ignore)(M=p.current)==null||M.finishSampleTest(),x({id:o,data:{status:me.SUCCESS,output:w.output,outputSource:"sample"}}),D.message.success("已使用样本数据完成调试");else{D.message.success("节点配置已保存");const U={params:void 0,properties:Y,account_id:te,mcp_tool_description:F.mcp_tool_description,action_key:S,action_ver:E,nodeKey:S,nodeVersion:E,isNodePackage:_};x({id:o,data:{config_schema:Y,account_id:F.account_id,...U,position:R==null?void 0:R.position,status:j.status}})}N&&!w.ignore&&((z=p.current)==null||z.onTestNode()),w.ignore=!1,w.output=""}catch{w.ignore&&((H=p.current)==null||H.abortSampleTest(),x({id:o,data:{status:me.FAILED}}))}},[k,v.flowId,n==null?void 0:n.action_key,n==null?void 0:n.action_ver,n==null?void 0:n.nodeKey,n==null?void 0:n.nodeVersion,x,_,S,E,o,r,w,m]);y.useCallback(F=>{!_||r!==pe.SWITCH||x({id:o,data:{config_schema:F,properties:F}})},[x,_,o,r]);const A=F=>{var N,P,M,z,H;return _?(N=c.current)==null?void 0:N.saveConfig(F):r===pe.LOOP?(P=f.current)==null?void 0:P.saveConfig(F):r===pe.CONDITION?(M=u.current)==null?void 0:M.saveConfig(F):r===pe.SWITCH?(z=d.current)==null?void 0:z.saveConfig(F):(H=c.current)==null?void 0:H.saveConfig(F)},T=async(F,N,P)=>{var M;if(N){w.ignore=!0,w.output=P||"",await A(F),(M=p.current)==null||M.finishNodeTest();return}if(F)try{D.message.loading("正在保存节点配置...",0),await A(F),D.message.success("节点配置已保存"),D.message.destroy()}catch(z){D.message.destroy(),console.error("节点配置保存失败:",z),D.message.error("节点配置保存失败,无法执行测试")}};return h.jsx(D.Modal,{open:t,footer:null,closeIcon:null,maskClosable:!0,onCancel:()=>{s(null)},centered:!0,width:"min(1440px, calc(100vw - 32px))",className:"nodes-config-modal",styles:{mask:{backgroundColor:"rgba(0, 0, 0, 0.45)"},content:{padding:0,overflow:"hidden"}},children:h.jsx(Qr.Provider,{value:{event$:i},children:h.jsxs(rC,{children:[h.jsx(aR,{}),h.jsx(lR,{children:h.jsx("div",{className:"nodes-config-container",children:h.jsx("div",{className:"nodes-config-content",children:h.jsxs("div",{className:"config-row",children:[h.jsx("div",{className:"left-section",children:h.jsx("div",{className:"variables-section",children:h.jsx(lO,{ref:l,nodeId:o,onInsert:()=>{},open:t})})}),h.jsx("div",{className:"middle-section",children:h.jsxs("div",{className:"config-container",children:[h.jsx(cR,{icon:n==null?void 0:n.icon,fallbackIcon:n==null?void 0:n.fallbackIcon,name:(n==null?void 0:n.action_name)||(n==null?void 0:n.label),description:n==null?void 0:n.description}),h.jsx(D.Tabs,{style:{height:"100%"},items:[{key:"property",label:"参数配置",children:h.jsxs(h.Fragment,{children:[_||![pe.CONDITION,pe.SWITCH,pe.LOOP].includes(r)?h.jsx(BG,{ref:c,nodeId:o,nodeType:r,data:n,onSubmit:O}):null,r===pe.CONDITION&&!_?h.jsx(IG,{ref:u,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null,r===pe.SWITCH&&!_?h.jsx(iR,{ref:d,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null,r===pe.LOOP&&!_?h.jsx(rR,{ref:f,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null]})},{key:"setting",label:"设置",children:h.jsx(sR,{data:n,nodeId:o,onSubmit:()=>{D.message.success("保存成功")}})}].slice(0,g?2:1)})]})}),h.jsx("div",{className:`right-section ${w.expandTestPanel?"expand":""}`,children:b&&h.jsx("div",{className:"test-section",children:h.jsx(XG,{ref:p,nodeId:o,beforeHook:T,onClose:e,onExpandPanel:F=>{w.expandTestPanel=F}})})})]})})})})]})})})},(t,e)=>Pt.isEqual(Pt.omit(t,["data","isHovered"]),Pt.omit(e,["data","isHovered"]))),uO=[],dR=(t,e)=>{if(uO.length===0)return[];const n=new Set(e);return t.some(o=>n.has(o.id)&&Oh(o)&&uO.some(i=>{var s;return((s=o.data)==null?void 0:s.action_key)===i}))?t.filter(o=>!n.has(o.id)).map(o=>o.id):[]},fR=[pe.AGENT,pe.BROWSER],cw=()=>{const t=ne.useStoreApi(),[e,n]=y.useState(0),r=y.useCallback((l,c)=>{const{nodes:u,setNodes:d}=t.getState(),f=fa(u,p=>{const m=p.find(v=>v.id===c.id);m.data?m.data.isHovered=!0:m.data={isHovered:!0}});d(f)},[]),o=y.useCallback((l,c)=>{const{nodes:u,setNodes:d}=t.getState(),f=fa(u,p=>{const m=p.find(v=>v.id===c.id);m.data?m.data.isHovered=!1:m.data={isHovered:!1}});d(f)},[]),i=y.useCallback(l=>{const{nodes:c,setNodes:u}=t.getState(),d=fa(c,f=>{l.forEach(p=>{p.type==="select"&&(f.find(m=>m.id===p.id).selected=p.selected)})});u(d)},[t]),s=y.useCallback((l,c,u=new Set)=>(c.filter(f=>f.source===l?f.sourceHandle!==He.OUTPUT&&f.sourceHandle!==He.DONE&&f.sourceHandle!==He.LOOP&&f.sourceHandle!==He.TRUE&&f.sourceHandle!==He.FALSE:f.target===l&&fh(f.targetHandle)).forEach(f=>{const p=f.source===l?f.target:f.source;u.has(p)||(u.add(p),s(p,c,u))}),u),[]),a=y.useCallback((l,c)=>{const{nodes:u,edges:d,setNodes:f,setEdges:p,onNodesChange:m,onEdgesChange:v}=t.getState(),b=new Set(l);fR.includes(c)&&l.forEach(C=>{s(C,d).forEach(_=>{b.add(_)})}),dR(u,l).forEach(C=>b.add(C));const w=Array.from(b),g=d.filter(C=>b.has(C.source)||b.has(C.target)).map(C=>C.id);if(m){const C=w.map(k=>({type:"remove",id:k}));m(C)}else f(u.filter(C=>!w.includes(C.id)));if(g.length)if(v){const C=g.map(k=>({type:"remove",id:k}));v(C)}else p(d.filter(C=>!g.includes(C.id)))},[t,s]);return{autoSaveNum:e,onNodeMouseEnter:r,onNodeMouseLeave:o,handleNodesChange:i,handleNodesDelete:a}};function hR(t){const{color:e,visible:n}=t;return h.jsx("div",{style:{display:n?"inline-flex":"none",justifyContent:"center",alignItems:"center",position:"absolute",zIndex:1e3,top:"calc(50% - 8px)",left:-10,padding:1,borderRadius:"100%",background:"#FFFFFF",width:20,height:20},children:h.jsx("span",{style:{width:16,height:16,borderRadius:10,backgroundColor:e,border:`1px solid ${e}`,display:"inline-flex",justifyContent:"center",alignItems:"center"},children:h.jsx(DW,{size:8,color:"#FFFFFF"})})})}const Lo={info:{normal:"#007FFF",lighter:"rgba(0, 127, 255, 0.48)"},success:{normal:"#98D7A9",lighter:"rgba(0, 176, 66, 0.48)"},warning:{normal:"#F7CD8F",lighter:"rgba(255, 146, 0, 0.48)"},error:{normal:"#F3B096",lighter:"rgba(255, 82, 25, 0.48)"},disabled:{normal:"#C7CCD1",lighter:"rgba(199, 204, 209, 0.48)"}},dO=({id:t,type:e=pe.ACTION,selected:n=!1,fallbackIcon:r,iconUri:o,inputs:i=[],outputs:s=[],showToolbar:a=!0,width:l,height:c,className:u="",status:d=me.IDLE,onTestNode:f,data:p,contentRender:m,showNodeDescription:v=!0,onToggleNodeDisabled:b})=>{const{currentNodeConfigVisibleId:w,setNodeConfigVisible:g}=ao(),{handleNodeDataUpdate:C}=Ri(),{handleNodesDelete:k}=cw(),_=$t(),S=na(),E=$=>{C({id:t,data:{note:$}})},x=y.useCallback(()=>{g(null)},[]),O=(p==null?void 0:p.isHovered)||!1,A=y.useMemo(()=>e===pe.TRIGGER,[e]),T=()=>{g(t)},B=y.useMemo(()=>(p==null?void 0:p.closed)==="1",[p==null?void 0:p.closed,e]),I=y.useMemo(()=>typeof l=="number"&&l>0?l:"auto",[l]),F=($="node")=>{if(B)return`workflow-${$}-disabled`;switch(d){case me.INVALID:return`workflow-${$}-warning`;case me.FAILED:return`workflow-${$}-failed`;case me.SUCCESS:case me.RUNNABLE:case me.ACTIVE:return`workflow-${$}-success`;case me.RUNNING:return`workflow-${$}-running`;case me.WARNING:return`workflow-${$}-warning`;case me.DEACTIVATED:return`workflow-${$}-disabled`;case me.IDLE:return`workflow-${$}-idle`;default:return""}},N=()=>{if(B)return Lo.disabled;switch(d){case me.INVALID:return Lo.warning;case me.FAILED:return Lo.error;case me.SUCCESS:case me.RUNNABLE:case me.ACTIVE:return Lo.success;case me.RUNNING:return Lo.info;case me.WARNING:return Lo.warning;case me.DEACTIVATED:return Lo.disabled;default:return Lo.info}},P=($="normal")=>N()[$],M=()=>{const $=i.length,j=new Map;return i.forEach(U=>{const ee=U.position,ie=j.has(ee)?j.get(ee)+1:1;j.set(ee,ie)}),i.map((U,ee)=>h.jsx(P0,{nodeId:t,id:U.id,position:U.position,type:U.type||fn.TARGET,category:U.category,connectionLimit:U.maxConnections,label:U.label,nodeStatus:d,protocol:U.protocol,portSchema:U.portSchema,shape:U.shape,style:U.style,index:[ee,$,j.get(U.position)]},`${t}-${U.id}`))},z=async()=>{var U,ee;const $=((U=_.canvas.fixedNodes)==null?void 0:U.triggerIds)||[],j=((ee=_.nodeTypes.fixed)==null?void 0:ee.triggers)||[];if($.includes(t)||j.includes(e)){D.message.warning("当前触发节点已被配置为不可删除");return}await Xf(t),k([t],e)},H=y.useMemo(()=>{const $=s.length,j=new Map;return s.forEach(U=>{const ee=U.position,ie=j.has(ee)?j.get(ee)+1:1;j.set(ee,ie)}),s.map((U,ee)=>h.jsx(P0,{nodeId:t,connectionLimit:U.maxConnections,id:U.id,style:U.style,position:U.position,protocol:U.protocol,portSchema:U.portSchema,type:U.type,label:U.label,shape:U.shape,nodeStatus:d,index:[ee,$,j.get(U.position)]},`${t}-${U.id}`))},[t,s,d]),R=()=>h.jsx(nC,{status:d,disabled:B}),Y=()=>{switch(d){case me.INVALID:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-warning-icon",children:h.jsx(se.WarningFilled,{style:{color:P()},size:12})});case me.FAILED:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-failed-icon",children:h.jsx(se.CloseCircleFilled,{style:{color:P()},size:12})});case me.SUCCESS:case me.RUNNABLE:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-success-icon",children:h.jsx(se.CheckCircleFilled,{style:{color:P()},size:12})});case me.RUNNING:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-running-icon",children:h.jsx(se.LoadingOutlined,{style:{color:P()},size:12})});default:return null}},te=()=>h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"workflow-node-icon-wrapper",children:h.jsx("div",{className:"workflow-node-icon",style:{backgroundImage:`url(${r?"none":o??"https://digitalsee-image.digitalsee.cn/flow/0.png"})`},children:r&&r})}),v&&h.jsx(PP,{title:p==null?void 0:p.connector_name,nodeId:t,note:(p==null?void 0:p.note)||"",statusIcon:Y(),onNoteChange:E,description:p.action_name,className:"workflow-node-text"})]});return h.jsxs(y.Fragment,{children:[h.jsxs("div",{style:{width:I,height:c||"auto"},onDoubleClick:T,className:`${u}
|
|
118
118
|
${F("container")}`,children:[h.jsx(hR,{color:P("lighter"),visible:A}),h.jsxs("div",{className:`workflow-node ${n?"workflow-node-selected":""}`,style:{"--status-color":P(),"--status-color-tint":P("lighter"),...B?{opacity:.4}:{}},children:[B&&h.jsx("div",{className:"workflow-node-deactivated-line"}),h.jsx("div",{className:"workflow-node-toolbar",style:{display:a&&!Ah(S)&&O?"block":"none"},children:h.jsx(s2,{nodeId:t,type:e,isDisabled:B,handleViewConfig:T,onTest:f,onToggleDisabled:b,onDelete:z})}),m?m(p,R()):h.jsx("div",{className:"workflow-node-content",children:te()}),M(),H]})]}),t===w&&h.jsx(uR,{visible:!0,onClose:x,nodeType:e,data:p,nodeId:t})]})},uw="main",pR=["action_key","actionKey","nodeKey","node_key"],qd=t=>Array.isArray(t)?t.filter(e=>typeof e=="string"&&!!e.trim()):void 0,dw=t=>({...t,displayName:t.displayName??t.display_name,type:typeof t.type=="string"&&t.type.trim()?t.type.trim():uw,maxConnections:Object.hasOwn(t,"maxConnections")?t.maxConnections:t.max_connections,allowedSourceNodeKeys:qd(t.allowedSourceNodeKeys??t.allowed_source_node_keys),allowedTargetNodeKeys:qd(t.allowedTargetNodeKeys??t.allowed_target_node_keys),deniedSourceNodeKeys:qd(t.deniedSourceNodeKeys??t.denied_source_node_keys),deniedTargetNodeKeys:qd(t.deniedTargetNodeKeys??t.denied_target_node_keys),position:t.position}),fO=t=>{var e;for(const n of pR){const r=(e=t==null?void 0:t.data)==null?void 0:e[n];if(typeof r=="string"&&r.trim())return r.trim()}return null},zn=(t,e,n,r,o)=>({valid:t,code:e,reason:n,sourcePort:r,targetPort:o}),fw=(t,e,n)=>t?n!=null&&n.allowLegacyMainHandleAliases&&(e==="source"&&t==="output"||e==="target"&&t==="input")?uw:t:null,hO=(t,e,n,r)=>{const o=fw(e,n,r);if(!o)return null;const i=t==null?void 0:t.find(s=>s.name===o);return i?dw(i):null},hw=(t,e)=>!!(e&&(t!=null&&t.includes(e))),pO=(t,e)=>!!(t!=null&&t.length&&!hw(t,e)),mO=(t,e,n,r,o)=>t.filter(i=>r==="source"?i.source===e&&fw(i.sourceHandle,"source",o)===n:i.target===e&&fw(i.targetHandle,"target",o)===n&&i.source!==i.target).length,gO=(t,e)=>{if(t.maxConnections==null||!Number.isFinite(t.maxConnections))return!1;const n=Math.max(0,Math.trunc(t.maxConnections));return e>=n},wO=t=>t||"(未指定)",mR=({sourceNode:t,targetNode:e,sourceHandle:n,targetHandle:r,sourcePorts:o,targetPorts:i,edges:s=[],options:a})=>{if(!t)return zn(!1,"SOURCE_NODE_NOT_FOUND","源节点不存在",null,null);if(!e)return zn(!1,"TARGET_NODE_NOT_FOUND","目标节点不存在",null,null);const l=hO(o,n,"source",a);if(!l)return zn(!1,"SOURCE_PORT_NOT_FOUND",`源节点不存在输出端口 ${wO(n)}`,null,null);const c=hO(i,r,"target",a);if(!c)return zn(!1,"TARGET_PORT_NOT_FOUND",`目标节点不存在输入端口 ${wO(r)}`,l,null);if(l.type!==c.type)return zn(!1,"PORT_TYPE_MISMATCH",`端口类型不匹配:${l.type} 输出不能连接到 ${c.type} 输入`,l,c);const u=fO(t),d=fO(e);if(hw(c.deniedSourceNodeKeys,u))return zn(!1,"SOURCE_NODE_DENIED",`目标输入端口禁止源节点 ${u}`,l,c);if(hw(l.deniedTargetNodeKeys,d))return zn(!1,"TARGET_NODE_DENIED",`源输出端口禁止目标节点 ${d}`,l,c);if(pO(c.allowedSourceNodeKeys,u))return zn(!1,"SOURCE_NODE_NOT_ALLOWED",`源节点 ${u||"(未声明 node key)"} 不在目标输入端口白名单中`,l,c);if(pO(l.allowedTargetNodeKeys,d))return zn(!1,"TARGET_NODE_NOT_ALLOWED",`目标节点 ${d||"(未声明 node key)"} 不在源输出端口白名单中`,l,c);const f=s??[],p=mO(f,t.id,l.name,"source",a);if(gO(l,p))return zn(!1,"SOURCE_MAX_CONNECTIONS_REACHED",`源输出端口 ${l.name} 最多只能连接 ${l.maxConnections} 个节点`,l,c);const m=mO(f,e.id,c.name,"target",a);return gO(c,m)?zn(!1,"TARGET_MAX_CONNECTIONS_REACHED",`目标输入端口 ${c.name} 最多只能连接 ${c.maxConnections} 个节点`,l,c):t.id===e.id?zn(!1,"SELF_CONNECTION_NOT_ALLOWED","节点不能连接到自身",l,c):zn(!0,"VALID","",l,c)},pw=72,mw=6,gw=12,bO=24,gR=16,wR=320,vO="main";function bR(t){const e=Math.max(0,Math.floor(t));if(e<=mw)return{height:pw,compact:!1};if(e<=gw)return{height:pw+(e-mw)*bO,compact:!1};const n=pw+(gw-mw)*bO;return{height:Math.min(n+(e-gw)*gR,wR),compact:!0}}function vR(t){const e=t.inputs??[],n=t.outputs??[],{height:r,compact:o}=bR(Math.max(e.length,n.length));return{inputs:e.map((i,s)=>yO(i,s,e.length,fn.TARGET,o)),outputs:n.map((i,s)=>yO(i,s,n.length,fn.SOURCE,o)),height:r,compact:o}}function yO(t,e,n,r,o){const i=dw(t),s=i.type||vO,a=i.displayName||i.name,l=yR(i.position)??(r===fn.TARGET?ne.Position.Left:ne.Position.Right);return{id:i.name,position:l,type:r,isMain:i.name===vO,label:a?h.jsx(kR,{compact:o,label:a}):void 0,maxConnections:typeof i.maxConnections=="number"?i.maxConnections:void 0,connectionType:s,portSchema:i,style:CR(e,n)}}function yR(t){if(t)switch(t){case"left":return ne.Position.Left;case"top":return ne.Position.Top;case"right":return ne.Position.Right;case"bottom":return ne.Position.Bottom;default:return}}function CR(t,e){return{top:`${(t+1)/(e+1)*100}%`}}function kR({compact:t,label:e}){return h.jsx(D.Tooltip,{title:e,children:h.jsx("span",{"data-nodepackage-port-label":!0,title:e,style:{display:"inline-block",maxWidth:t?72:112,overflow:"hidden",textOverflow:"ellipsis",verticalAlign:"middle",whiteSpace:"nowrap"},children:e})})}function SR({nodeType:t,data:e,legacyInputs:n,legacyOutputs:r,resolvePortSchema:o,overrideNodeKey:i,overrideNodeVersion:s}){var C,k;const a=$t(),l=i??ER(t,e),c=s!==void 0?s:xR(e),u=l?Wi(l,c):null,d=((k=(C=a.nodeSelector)==null?void 0:C.connectable)==null?void 0:k.enabled)===!0&&po(e),f=`${l}@${c??"latest"}`,[p,m]=y.useState(null);y.useEffect(()=>{if(!d||!l)return;if(u){m({identity:f,schema:u,failed:!1});return}let _=!1;return pc(l,c).then(S=>{_||m({identity:f,schema:S,failed:!S})}).catch(()=>{_||m({identity:f,schema:null,failed:!0})}),()=>{_=!0}},[u,f,d,l,c]);const v=(p==null?void 0:p.identity)===f?p.schema:null,b=d?u??v:null,w=y.useMemo(()=>b&&o?o(b):b,[o,b]),g=y.useMemo(()=>w?vR(w):null,[w]);return d?g?{inputs:g.inputs,outputs:g.outputs,height:g.height,status:"ready",isNodePackage:!0,schema:b}:!l||(p==null?void 0:p.identity)===f&&p.failed?{inputs:[],outputs:[],height:72,status:"error",isNodePackage:!0,schema:null}:{inputs:[],outputs:[],height:72,status:"loading",isNodePackage:!0,schema:null}:{inputs:n,outputs:r,status:"legacy",isNodePackage:!1,schema:null}}function ER(t,e){const n=e.nodeKey??e.action_key;return typeof n=="string"?n:""}function xR(t){const e=t.nodeVersion??t.action_ver;if(e==null||e==="")return;const n=Number(e);return Number.isFinite(n)?n:void 0}const ww="MCP_TRIGGER",CO="mcp_trigger",kO=200,DR=10;$e.MCP_SERVER;const Gd="dip.core.trigger.mcp-server";function Rd(t){return t===ne.Position.Left?ne.Position.Top:t===ne.Position.Right?ne.Position.Bottom:t}function SO(t){for(const e of t){const n=typeof e.type=="string"?e.type:"",r=e.data&&typeof e.data.action_key=="string"?e.data.action_key:"";if(n.startsWith(`${Gd}@`)||r===Gd)return!0}return!1}const _R=["action_key","actionKey","nodeKey","node_key"],AR=["action_ver","nodeVersion","node_version"],OR=new Set(["left","top","right","bottom"]);function TR(t){if(!t)return"";for(const e of _R){const n=t[e];if(typeof n=="string"&&n.trim())return n.trim()}return""}function NR(t){if(t)for(const e of AR){const n=t[e];if(n==null||n==="")continue;const r=Number(n);if(Number.isFinite(r)&&r>=0)return r}}function BR(t){if(t)switch(t){case"left":return ne.Position.Left;case"top":return ne.Position.Top;case"right":return ne.Position.Right;case"bottom":return ne.Position.Bottom;default:return OR.has(t),void 0}}function EO(t){return!t||t.length===0?[]:t.map(e=>e.position)}function FR(t){const e=TR(t.data);if(!e)return Ui(t.type)?Wi(t.type):null;const n=NR(t.data);return Wi(e,n)}function MR(t){if(!t)return{sources:[],targets:[]};const e=[];for(const r of t.outputs??[])e.push(xO(r,ne.Position.Right));const n=[];for(const r of t.inputs??[])n.push(xO(r,ne.Position.Left));return{sources:e,targets:n}}function xO(t,e){const n=dw(t);return BR(n.position)??e}function IR(t){try{const e=ji(t.type,t.data??void 0);return{sources:EO(e.outputs),targets:EO(e.inputs)}}catch{return null}}function DO(t,e){return e?{sources:t.sources.map(Rd),targets:t.targets.map(Rd)}:t}function Ns(t,e){if(!t)return{sources:[],targets:[]};const n=t.data,r=po(n??null)||Ui(t.type),o=(e==null?void 0:e.isMcpServerCanvas)===!0;if(r){const s=FR(t),a=MR(s);if(a.sources.length>0||a.targets.length>0)return DO(a,o)}const i=IR(t);return i&&(i.sources.length>0||i.targets.length>0)?DO(i,o):{sources:[],targets:[]}}function Dl(t){return t===ne.Position.Top||t===ne.Position.Bottom}function bw(t){return t===ne.Position.Left||t===ne.Position.Right}function PR(t,e){const n=Ns(t,e);return n.sources.some(Dl)||n.targets.some(Dl)}function LR(t,e){const n=Ns(t,e);return n.sources.some(bw)||n.targets.some(bw)}function $R(t,e,n,r){if(n){const o=Ns(n,r),i=_O(o.targets,t.targetHandle,n,"target",r);if(i)return Dl(i)?"vertical":"horizontal"}if(e){const o=Ns(e,r),i=_O(o.sources,t.sourceHandle,e,"source",r);if(i)return Dl(i)?"vertical":"horizontal"}return null}function _O(t,e,n,r,o){if(!e)return t[0];const s=(r==="source"?zR(n):HR(n)).find(a=>a.id===e);return s?o!=null&&o.isMcpServerCanvas?Rd(s.position):s.position:t[0]}function zR(t){try{return ji(t.type,t.data??void 0).outputs}catch{return[]}}function HR(t){try{return ji(t.type,t.data??void 0).inputs}catch{return[]}}function VR(t,e){return Ns(t,e).sources.includes(ne.Position.Top)}function AO(t){if(SO(t))return"vertical";let n=0,r=0;for(const o of t){const i=Ns(o);i.sources.some(Dl)&&(n+=1),i.sources.some(bw)&&(r+=1)}return n===0&&r===0?"horizontal":n>r?"vertical":"horizontal"}const OO=30,vw=72,TO=2;function NO(t){const e=Rd(t.position);if(e===t.position)return t;const n=t.style;if(!n||typeof n!="object")return{...t,position:e};const r={...n},o=t.position===ne.Position.Left||t.position===ne.Position.Right,i=e===ne.Position.Top||e===ne.Position.Bottom;return o&&i&&r.top!==void 0&&(r.left=r.top,delete r.top),{...t,position:e,style:r}}function jR(t){if(!t||typeof t!="string"||!t.includes("@"))return{baseNodeType:t};const e=t.split("@");if(e.length===2){const[n,r]=e;return r?{baseNodeType:n,nodeKey:r}:{baseNodeType:t}}if(e.length===3){const[n,r,o]=e,i=Number(o);return Number.isFinite(i)?{baseNodeType:n,nodeKey:r,nodeVersion:i}:(console.warn("[workflow:node-types] malformed descriptor version, falling back to base type",{type:t}),{baseNodeType:t})}return console.warn("[workflow:node-types] malformed descriptor key, falling back to base type",{type:t}),{baseNodeType:t}}const BO=y.memo(t=>{const{id:e,data:n,selected:r,type:o}=t,i=n,{isMcpServerCanvas:s}=lc(),a=y.useMemo(()=>jR(o),[o]),l=a.baseNodeType,c=uh(o),u=ne.useInternalNode(e),d=(u==null?void 0:u.data)??n,f=ji(o,d),p=f.inputs,m=c.type===pe.SWITCH?CP(d):f.outputs,v=y.useCallback(()=>A0(d),[d]),b=SR({nodeType:l,data:d,legacyInputs:p,legacyOutputs:m,...a.nodeKey?{overrideNodeKey:a.nodeKey}:{},...a.nodeVersion!==void 0?{overrideNodeVersion:a.nodeVersion}:{},...c.useNodePackagePorts&&c.type===pe.SWITCH?{resolvePortSchema:x=>oh(x,v())}:{}}),w=c.useNodePackagePorts?b.outputs:m,g=c.useNodePackagePorts?b.inputs:p,C=s?w.map(NO):w,k=s?g.map(NO):g,_=c.type===pe.SWITCH?Math.max(b.height??0,C.length>TO?C.length*OO:vw):b.height,S=i.status??me.IDLE,E=i!=null&&i.icon?void 0:c.fallbackIcon;return h.jsx(dO,{id:e,data:n,selected:r,type:l,status:S,className:c.className,iconUri:i.icon,fallbackIcon:E,inputs:k,outputs:C,height:_})});BO.displayName="DeclaredNode";function WR(t){if(t)switch(t){case"left":return ne.Position.Left;case"top":return ne.Position.Top;case"right":return ne.Position.Right;case"bottom":return ne.Position.Bottom;default:return}}function UR(t){return t===ne.Position.Top||t===ne.Position.Bottom}function FO(t,e,n){let r;n?r=e===fn.TARGET?ne.Position.Top:ne.Position.Bottom:r=WR(t)??(e===fn.TARGET?ne.Position.Left:ne.Position.Right);const o=UR(r)?ne.Position.Left:ne.Position.Top;return{position:r,styleAxis:o}}const yw=y.memo(t=>{const{id:e,data:n,selected:r,type:o}=t,{isMcpServerCanvas:i}=lc(),s=n,a=T0(o),l=s.node_type==="SwitchNode",c=l&&a?oh(a,A0(s)):a,u=((c==null?void 0:c.inputs)||[]).length,d=((c==null?void 0:c.inputs)||[]).map((g,C)=>{const{display_name:k,name:_,type:S,max_connections:E}=g,{position:x,styleAxis:O}=FO(g.position,fn.TARGET,i);return{id:_,label:k,position:x,type:fn.TARGET,protocol:S,maxConnections:E,isMain:S==="main",style:{[O]:`${10+80/(u+1)*(C+1)}%`}}}),f=((c==null?void 0:c.outputs)||[]).length,p=((c==null?void 0:c.outputs)||[]).map((g,C)=>{const{display_name:k,name:_,type:S,max_connections:E}=g,{position:x,styleAxis:O}=FO(g.position,fn.SOURCE,i);return{id:_,label:k,position:x,type:fn.SOURCE,protocol:S,maxConnections:E,isMain:S==="main",style:{[O]:`${10+80/(f+1)*(C+1)}%`}}}),m=uh(o),v=s.status??me.IDLE,b=s!=null&&s.icon?void 0:m.fallbackIcon,w=l?Math.max(vw,p.length>TO?p.length*OO:vw):void 0;return h.jsx(dO,{id:e,data:n,selected:r,type:pe.DYNAMIC,status:v,className:m.className,iconUri:s.icon,fallbackIcon:b,inputs:d,outputs:p,height:w})});yw.displayName="NodePackageNode";function MO(t,e){const n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let r=0,o=n.indexOf(e);for(;o!==-1;)r++,o=n.indexOf(e,o+e.length);return r}function Wre(){}const _l=Yd(/[A-Za-z]/),Cw=Yd(/[\dA-Za-z]/);function qR(t){return t!==null&&(t<32||t===127)}function Bs(t){return t!==null&&t<-2}function An(t){return t!==null&&(t<0||t===32)}function oo(t){return t===-2||t===-1||t===32}const Kd=Yd(new RegExp("\\p{P}|\\p{S}","u")),Oi=Yd(/\s/);function Yd(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function GR(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const Xd=(function(t){if(t==null)return XR;if(typeof t=="function")return Jd(t);if(typeof t=="object")return Array.isArray(t)?RR(t):KR(t);if(typeof t=="string")return YR(t);throw new Error("Expected function, string, or object as test")});function RR(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=Xd(t[n]);return Jd(r);function r(...o){let i=-1;for(;++i<e.length;)if(e[i].apply(this,o))return!0;return!1}}function KR(t){const e=t;return Jd(n);function n(r){const o=r;let i;for(i in t)if(o[i]!==e[i])return!1;return!0}}function YR(t){return Jd(e);function e(n){return n&&n.type===t}}function Jd(t){return e;function e(n,r,o){return!!(JR(n)&&t.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function XR(){return!0}function JR(t){return t!==null&&typeof t=="object"&&"type"in t}function Ure(t){return t}const IO=[],QR=!0,kw=!1,ZR="skip";function PO(t,e,n,r){let o;typeof e=="function"&&typeof n!="function"?(r=n,n=e):o=e;const i=Xd(o),s=r?-1:1;a(t,void 0,[])();function a(l,c,u){const d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){const p=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return f;function f(){let p=IO,m,v,b;if((!e||i(l,c,u[u.length-1]||void 0))&&(p=eK(n(l,u)),p[0]===kw))return p;if("children"in l&&l.children){const w=l;if(w.children&&p[0]!==ZR)for(v=(r?w.children.length:-1)+s,b=u.concat(w);v>-1&&v<w.children.length;){const g=w.children[v];if(m=a(g,v,b)(),m[0]===kw)return m;v=typeof m[1]=="number"?m[1]:v+s}}return p}}}function eK(t){return Array.isArray(t)?t:typeof t=="number"?[QR,t]:t==null?IO:[t]}function tK(t,e,n){const o=Xd((n||{}).ignore||[]),i=nK(e);let s=-1;for(;++s<i.length;)PO(t,"text",a);function a(c,u){let d=-1,f;for(;++d<u.length;){const p=u[d],m=f?f.children:void 0;if(o(p,m?m.indexOf(p):void 0,f))return;f=p}if(f)return l(c,u)}function l(c,u){const d=u[u.length-1],f=i[s][0],p=i[s][1];let m=0;const b=d.children.indexOf(c);let w=!1,g=[];f.lastIndex=0;let C=f.exec(c.value);for(;C;){const k=C.index,_={index:C.index,input:C.input,stack:[...u,c]};let S=p(...C,_);if(typeof S=="string"&&(S=S.length>0?{type:"text",value:S}:void 0),S===!1?f.lastIndex=k+1:(m!==k&&g.push({type:"text",value:c.value.slice(m,k)}),Array.isArray(S)?g.push(...S):S&&g.push(S),m=k+C[0].length,w=!0),!f.global)break;C=f.exec(c.value)}return w?(m<c.value.length&&g.push({type:"text",value:c.value.slice(m)}),d.children.splice(b,1,...g)):g=[c],b+g.length}}function nK(t){const e=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!t[0]||Array.isArray(t[0])?t:[t];let r=-1;for(;++r<n.length;){const o=n[r];e.push([rK(o[0]),oK(o[1])])}return e}function rK(t){return typeof t=="string"?new RegExp(GR(t),"g"):t}function oK(t){return typeof t=="function"?t:function(){return t}}const Sw="phrasing",Ew=["autolink","link","image","label"];function iK(){return{transforms:[fK],enter:{literalAutolink:aK,literalAutolinkEmail:xw,literalAutolinkHttp:xw,literalAutolinkWww:xw},exit:{literalAutolink:dK,literalAutolinkEmail:uK,literalAutolinkHttp:lK,literalAutolinkWww:cK}}}function sK(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Sw,notInConstruct:Ew},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Sw,notInConstruct:Ew},{character:":",before:"[ps]",after:"\\/",inConstruct:Sw,notInConstruct:Ew}]}}function aK(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function xw(t){this.config.enter.autolinkProtocol.call(this,t)}function lK(t){this.config.exit.autolinkProtocol.call(this,t)}function cK(t){this.config.exit.data.call(this,t);const e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(t)}function uK(t){this.config.exit.autolinkEmail.call(this,t)}function dK(t){this.exit(t)}function fK(t){tK(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,hK],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),pK]],{ignore:["link","linkReference"]})}function hK(t,e,n,r,o){let i="";if(!LO(o)||(/^w/i.test(e)&&(n=e+n,e="",i="http://"),!mK(n)))return!1;const s=gK(n+r);if(!s[0])return!1;const a={type:"link",title:null,url:i+e+s[0],children:[{type:"text",value:e+s[0]}]};return s[1]?[a,{type:"text",value:s[1]}]:a}function pK(t,e,n,r){return!LO(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+n,children:[{type:"text",value:e+"@"+n}]}}function mK(t){const e=t.split(".");return!(e.length<2||e[e.length-1]&&(/_/.test(e[e.length-1])||!/[a-zA-Z\d]/.test(e[e.length-1]))||e[e.length-2]&&(/_/.test(e[e.length-2])||!/[a-zA-Z\d]/.test(e[e.length-2])))}function gK(t){const e=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!e)return[t,void 0];t=t.slice(0,e.index);let n=e[0],r=n.indexOf(")");const o=MO(t,"(");let i=MO(t,")");for(;r!==-1&&o>i;)t+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),i++;return[t,n]}function LO(t,e){const n=t.input.charCodeAt(t.index-1);return(t.index===0||Oi(n)||Kd(n))&&(!e||n!==47)}function Al(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}$O.peek=xK;function wK(){this.buffer()}function bK(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function vK(){this.buffer()}function yK(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function CK(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Al(this.sliceSerialize(t)).toLowerCase(),n.label=e}function kK(t){this.exit(t)}function SK(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Al(this.sliceSerialize(t)).toLowerCase(),n.label=e}function EK(t){this.exit(t)}function xK(){return"["}function $O(t,e,n,r){const o=n.createTracker(r);let i=o.move("[^");const s=n.enter("footnoteReference"),a=n.enter("reference");return i+=o.move(n.safe(n.associationId(t),{after:"]",before:i})),a(),s(),i+=o.move("]"),i}function DK(){return{enter:{gfmFootnoteCallString:wK,gfmFootnoteCall:bK,gfmFootnoteDefinitionLabelString:vK,gfmFootnoteDefinition:yK},exit:{gfmFootnoteCallString:CK,gfmFootnoteCall:kK,gfmFootnoteDefinitionLabelString:SK,gfmFootnoteDefinition:EK}}}function _K(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:n,footnoteReference:$O},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,o,i,s){const a=i.createTracker(s);let l=a.move("[^");const c=i.enter("footnoteDefinition"),u=i.enter("label");return l+=a.move(i.safe(i.associationId(r),{before:l,after:"]"})),u(),l+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),l+=a.move((e?`
|
|
119
119
|
`:" ")+i.indentLines(i.containerFlow(r,a.current()),e?zO:AK))),c(),l}}function AK(t,e,n){return e===0?t:zO(t,e,n)}function zO(t,e,n){return(n?"":" ")+t}const OK=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];HO.peek=MK;function TK(){return{canContainEols:["delete"],enter:{strikethrough:BK},exit:{strikethrough:FK}}}function NK(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:OK}],handlers:{delete:HO}}}function BK(t){this.enter({type:"delete",children:[]},t)}function FK(t){this.exit(t)}function HO(t,e,n,r){const o=n.createTracker(r),i=n.enter("strikethrough");let s=o.move("~~");return s+=n.containerPhrasing(t,{...o.current(),before:s,after:"~"}),s+=o.move("~~"),i(),s}function MK(){return"~"}function IK(t){return t.length}function PK(t,e){const n=e||{},r=(n.align||[]).concat(),o=n.stringLength||IK,i=[],s=[],a=[],l=[];let c=0,u=-1;for(;++u<t.length;){const v=[],b=[];let w=-1;for(t[u].length>c&&(c=t[u].length);++w<t[u].length;){const g=LK(t[u][w]);if(n.alignDelimiters!==!1){const C=o(g);b[w]=C,(l[w]===void 0||C>l[w])&&(l[w]=C)}v.push(g)}s[u]=v,a[u]=b}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<c;)i[d]=VO(r[d]);else{const v=VO(r);for(;++d<c;)i[d]=v}d=-1;const f=[],p=[];for(;++d<c;){const v=i[d];let b="",w="";v===99?(b=":",w=":"):v===108?b=":":v===114&&(w=":");let g=n.alignDelimiters===!1?1:Math.max(1,l[d]-b.length-w.length);const C=b+"-".repeat(g)+w;n.alignDelimiters!==!1&&(g=b.length+g+w.length,g>l[d]&&(l[d]=g),p[d]=g),f[d]=C}s.splice(1,0,f),a.splice(1,0,p),u=-1;const m=[];for(;++u<s.length;){const v=s[u],b=a[u];d=-1;const w=[];for(;++d<c;){const g=v[d]||"";let C="",k="";if(n.alignDelimiters!==!1){const _=l[d]-(b[d]||0),S=i[d];S===114?C=" ".repeat(_):S===99?_%2?(C=" ".repeat(_/2+.5),k=" ".repeat(_/2-.5)):(C=" ".repeat(_/2),k=C):k=" ".repeat(_)}n.delimiterStart!==!1&&!d&&w.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&g==="")&&(n.delimiterStart!==!1||d)&&w.push(" "),n.alignDelimiters!==!1&&w.push(C),w.push(g),n.alignDelimiters!==!1&&w.push(k),n.padding!==!1&&w.push(" "),(n.delimiterEnd!==!1||d!==c-1)&&w.push("|")}m.push(n.delimiterEnd===!1?w.join("").replace(/ +$/,""):w.join(""))}return m.join(`
|
|
120
120
|
`)}function LK(t){return t==null?"":String(t)}function VO(t){const e=typeof t=="string"?t.codePointAt(0):0;return e===67||e===99?99:e===76||e===108?108:e===82||e===114?114:0}function $K(t,e,n,r){const o=n.enter("blockquote"),i=n.createTracker(r);i.move("> "),i.shift(2);const s=n.indentLines(n.containerFlow(t,i.current()),zK);return o(),s}function zK(t,e,n){return">"+(n?"":" ")+t}function HK(t,e){return jO(t,e.inConstruct,!0)&&!jO(t,e.notInConstruct,!1)}function jO(t,e,n){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return n;let r=-1;for(;++r<e.length;)if(t.includes(e[r]))return!0;return!1}function WO(t,e,n,r){let o=-1;for(;++o<n.unsafe.length;)if(n.unsafe[o].character===`
|
|
@@ -135,7 +135,7 @@ The error may be correlated with this previous error:
|
|
|
135
135
|
`,Bw={content:gT,color:Nw[0]},yX=({id:t,data:e,selected:n,width:r,height:o})=>{const{config_schema:i}=e||{},s=y.useRef(null),a=y.useMemo(()=>{if(i!=null&&i.value)try{const P=JSON.parse(i.value);return{...Bw,...P}}catch{return Bw}return Bw},[i==null?void 0:i.value]),{handleNodeDataUpdate:l}=Ri(),[c,u]=y.useState(!1),[d,f]=y.useState(a.content),[p,m]=y.useState(a.content),[v,b]=y.useState(a.color),{addNodes:w,getNodes:g}=aa(),{handleNodesDelete:C}=cw(),k=$t(),_=Ot();y.useEffect(()=>{f(a.content),b(a.color)},[a.content,a.color]);const S=P=>({content:d,color:v,width:r,height:o,...P}),E=()=>{if(s.current){const P=s.current.getBoundingClientRect();return{width:Math.round(P.width),height:Math.round(P.height)}}return{width:r,height:o}},x=P=>{var z;const M={config_schema:{value:JSON.stringify(P)}};l({id:t,sync:!0,data:M}),(z=e==null?void 0:e.onChange)==null||z.call(e,t,P)},O=()=>{m(d),u(!0)},A=y.useCallback(()=>{const P=p||gT;f(P);const M=E(),z=S({content:P,color:v,width:M.width,height:M.height});x(z),u(!1)},[p,v,r,o]),T=()=>{u(!1)},B=y.useCallback(()=>{setTimeout(()=>{const P=E(),M=S({width:P.width,height:P.height});x(M)},50)},[d,v,r,o]),I=P=>{b(P);const M=E(),z=S({color:P,width:M.width,height:M.height});x(z)},F=async()=>{try{await Xf(t),C([t],pe.STICKY),D.message.success("便签删除成功")}catch(P){D.message.error("便签删除失败"),console.error("删除便签失败:",P)}},N=async()=>{var M;const P=g();try{const z=P.find(Y=>Y.id===t);if(!z){D.message.error("获取当前节点信息失败");return}const H=(M=k.canvas.limits)==null?void 0:M.maxNodes;if(typeof H=="number"&&P.length>=H){D.message.warning("已达到画布允许的最大节点数");return}const R=await eh(t);R&&w([{id:R.id,type:R.node_type,position:{x:z.position.x,y:z.position.y+100}}]),D.message.success("便签复制成功")}catch(z){D.message.error("便签复制失败"),console.error("复制便签失败:",z)}};return h.jsxs(y.Fragment,{children:[h.jsx(ne.NodeResizer,{isVisible:n&&_,lineStyle:{borderColor:"transparent",borderWidth:15},handleStyle:{background:"transparent"},onResizeEnd:B,minWidth:140,minHeight:94}),n&&_&&h.jsx(ne.NodeToolbar,{children:h.jsxs("div",{className:"workflow-sticky-toolbar",children:[h.jsx("button",{type:"button",className:"sticky-toolbar-button","aria-label":"编辑便签",onClick:O,children:h.jsx(se.EditOutlined,{})}),h.jsx("button",{type:"button",className:"sticky-toolbar-button","aria-label":"复制便签",onClick:N,children:h.jsx(se.CopyOutlined,{})}),h.jsx("button",{type:"button",className:"sticky-toolbar-button sticky-toolbar-button-danger","aria-label":"删除便签",onClick:F,children:h.jsx(se.DeleteOutlined,{})}),h.jsx("div",{className:"sticky-color-palette",children:Nw.map(P=>h.jsx("button",{type:"button","aria-label":`设置便签颜色 ${Nw.indexOf(P)+1}`,"aria-pressed":P===v,className:ar("sticky-color-item",{"sticky-color-item-active":P===v}),style:{backgroundColor:P},onClick:()=>I(P)},P))})]})}),h.jsx("div",{ref:s,style:{width:"100%",height:"100%"},children:h.jsx(D.Card,{className:ar("workflow-sticky-note",{"workflow-sticky-note-selected":n}),style:{width:"100%",height:"100%",padding:0,borderColor:vX(v)},styles:{body:{width:"100%",height:"100%",backgroundColor:v,padding:8,overflow:"auto"}},onDoubleClick:_?O:void 0,children:h.jsx("div",{className:"workflow-sticky-md",children:h.jsx(XB,{remarkPlugins:[wX],children:d})})})}),h.jsx(D.Modal,{title:"编辑便签",open:c,onOk:A,onCancel:T,okText:"确定",cancelText:"取消",width:520,children:h.jsx(bX,{value:p,onChange:P=>m(P.target.value),autoSize:{minRows:6,maxRows:12},placeholder:"支持 Markdown 语法,在此编辑便签内容"})})]})};function CX(t){const e=y.memo(n=>y.createElement(yw,n));return e.displayName=`VersionedNode(${t})`,e}class Ni{static getNodeTypes(){const e={...Object.fromEntries(Object.values(pe).map(n=>[n,BO])),[pe.STICKY]:yX,[pe.DYNAMIC]:yw};for(const n of E0())e[n]=CX(n);return e}static mapTypeToBackendType(e){switch(e){case pe.ACTION:return"ActionNode";case pe.CONDITION:return"ConditionNode";case pe.LOOP:return"LoopNode";case pe.SELF_LOOP:return"SelfLoopNode";case pe.AGENT:return"AgentNode";case pe.TRIGGER:return"StartEventNode";case pe.AI_SUB_NODE:return"AISubNode";case pe.SWITCH:return"SwitchNode";case pe.STICKY:return"StickyNoteNode";default:return"UnknownNode"}}static createNode(e,n,r,o={x:0,y:0}){let i={};switch(e){case pe.CONDITION:r.branches||(r.branches=[{id:"true",label:"是",condition:"value === true"},{id:"false",label:"否",condition:"value === false"}]);break;case pe.LOOP:r.loopType||(r.loopType="for",r.config={initialValue:0,finalValue:10,step:1});break;case pe.TRIGGER:i={};break}return{id:n,type:e,data:r,position:o,...i}}static toBackendFormat(e){const n=e.data.node_type,r=e.data.action_id||e.data.id||"";return{node_type:n,connector_id:e.data.connector_id||"",n_id:e.data.n_id||e.id,action_id:r,account_id:e.data.account_id||null,position:e.position,properties:Ni.extractNodeProperties(e.data)}}static extractNodeProperties(e){if(!e)return{};const n={...e};return["node_type","connector_id","n_id","action_id","account_id","label","description","isHovered","category"].forEach(o=>{o in n&&delete n[o]}),n}}function kX(t){const[e,n]=y.useReducer(r=>r+1,0);return y.useEffect(()=>bP(()=>n()),[]),y.useMemo(()=>{const r=Ni.getNodeTypes();if(t)for(const[o,i]of Object.entries(t))i&&!(o in r)&&(r[o]=i);return r},[t,e])}async function wT(t){const e=t.action_key??t.nodeKey,n=t.node_type??t.type;if(!e)return console.warn("[workflow:node-types] ensure skipped, missing action_key",{hasNodeKey:!!e,baseNodeType:n,action_ver:t.action_ver}),null;if(typeof e!="string"||!e)return console.warn("[workflow:node-types] ensure skipped, non-string action_key",{action_key:t.action_key,nodeKey:t.nodeKey}),null;const r=t.action_ver??t.nodeVersion,o=r==null||r===""?void 0:Number(r);if(o!==void 0&&!Number.isFinite(o))return console.warn("[workflow:node-types] ensure skipped, non-numeric action_ver",{nodeKey:e,rawVersion:r}),null;const i=ia(e,o);if(!i)return null;if(E0().includes(i))return i;const s=o&&o>0?o:1;(!o||o===0)&&console.warn("[workflow:node-types] fallback schema fetch version",{nodeKey:e,originalVersion:o,fallbackVersion:1});try{await SX(e,s,t)}catch(a){console.error("[workflow:node-types] schema fetch failed for registration",{nodeKey:e,version:o,err:a})}return wP({baseNodeType:pe.DYNAMIC,nodeKey:e,nodeVersion:o})}async function SX(t,e,n){return pc(t,e)}const Fw=[],EX={nodes:Fw,edges:[],selectedNodes:[],selectedEdges:[],workflowName:"",refreshWorkFlowNum:0,autoSaveWatchNum:0,currentNodeConfigVisibleId:null,isLocked:!1,executionControl:null,flowMetadata:{}},bT=_f.createSlice({name:"workflow",initialState:EX,reducers:{setWorkflowId:(t,e)=>{t.workflowId=e.payload},executeAutoSave:t=>{t.autoSaveWatchNum+=1},setWorkflowName:(t,e)=>{t.workflowName=e.payload},applyNodesChanges:(t,e)=>{const n=ne.applyNodeChanges(e.payload,t.nodes);t.nodes=n.length>0?n:Fw},applyEdgesChanges:(t,e)=>{t.edges=ne.applyEdgeChanges(e.payload,t.edges)},refreshFlow:t=>{t.refreshWorkFlowNum+=1},addConnection:(t,e)=>{const n={id:eg(),source:e.payload.source,type:"main",sourceHandle:e.payload.sourceHandle,target:e.payload.target,targetHandle:e.payload.targetHandle};t.edges.push(n)},addNode:(t,e)=>{const{type:n,position:r,data:o}=e.payload,i=Ni.createNode(n,eg(),o,r);t.nodes.push(i)},addEdges:(t,e)=>{t.edges.push(...e.payload)},resetFlow:t=>{t.nodes=[],t.edges=[],t.workflowName="",t.workflowId="",t.refreshWorkFlowNum=0,t.currentNodeConfigVisibleId=null,t.isLocked=!1,t.executionControl=null,t.flowMetadata={}},removeNodes:(t,e)=>{const n=e.payload;n.forEach(r=>{const o=t.nodes.findIndex(i=>i.id===r);o!==-1&&t.nodes.splice(o,1)}),t.edges=t.edges.filter(r=>!n.includes(r.source)&&!n.includes(r.target))},removeEdges:(t,e)=>{const n=e.payload;t.edges=t.edges.filter(r=>!n.includes(r.id))},setSelection:(t,e)=>{t.selectedNodes=e.payload.nodes,t.selectedEdges=e.payload.edges},updateEdge:(t,e)=>{const{oldEdge:n,newConnection:r}=e.payload,o=t.edges.findIndex(i=>i.id===n.id);if(o!==-1){const i={...n,source:r.source,sourceHandle:r.sourceHandle,target:r.target,targetHandle:r.targetHandle};t.edges[o]=i}},setNodes:(t,e)=>{t.nodes=e.payload.length>0?e.payload:Fw},setEdges:(t,e)=>{t.edges=e.payload},setFlowOpStatus:(t,e)=>{t.op_status=e.payload},updateNode:(t,e)=>{const{id:n,data:r}=e.payload,o=t.nodes.findIndex(i=>i.id===n);o!==-1&&(t.nodes[o]={...t.nodes[o],data:{...t.nodes[o].data,...r}})},setCurrentNodeConfigVisibleId:(t,e)=>{t.currentNodeConfigVisibleId=e.payload},setLocked:(t,e)=>{t.isLocked=e.payload},setExecutionControl:(t,e)=>{t.executionControl=e.payload},setFlowMetadata:(t,e)=>{t.flowMetadata=e.payload},setFlowVersionMeta:(t,e)=>{t.flowMetadata={...t.flowMetadata,...e.payload}}}}),{setWorkflowId:xX,setWorkflowName:Tl,applyNodesChanges:DX,applyEdgesChanges:_X,addConnection:AX,addNode:qre,addEdges:OX,removeNodes:TX,removeEdges:NX,setSelection:Gre,updateEdge:BX,setNodes:FX,setEdges:MX,updateNode:IX,setFlowOpStatus:vT,refreshFlow:yT,setCurrentNodeConfigVisibleId:PX,setLocked:LX,setExecutionControl:CT,setFlowMetadata:$X,resetFlow:Mw,executeAutoSave:zX,setFlowVersionMeta:HX}=bT.actions,VX=bT.reducer,Iw=_f.configureStore({reducer:{workflow:VX,panel:$I},middleware:t=>t({serializableCheck:{ignoredActions:["panel/setNodeAddCallback"],ignoredPaths:["panel.nodeAddCallback"]}})}),Ms=()=>Of.useDispatch(),Is=Of.useSelector;function ao(t){const[e]=a0(),[n,r]=y.useState(t||e.get("id")),o=Ms(),{nodes:i,edges:s,selectedNodes:a,selectedEdges:l,currentNodeConfigVisibleId:c,op_status:u,isLocked:d,flowMetadata:f}=Is(B=>B.workflow);y.useEffect(()=>{n&&(r(n),o(xX(n)))},[n,o]);const p=y.useCallback(B=>{o(vT(B))},[o]),m=y.useCallback(()=>{o(zX())},[o]),v=y.useCallback(B=>{o(DX(B))},[]),b=y.useCallback(B=>{o(_X(B))},[o]),w=y.useCallback(B=>{o(AX(B))},[o]),g=y.useCallback((B,I)=>{o(BX({oldEdge:B,newConnection:I}))},[o]),C=y.useCallback(B=>{o(OX(B))},[o]),k=y.useCallback(B=>{o(TX(B))},[o]),_=y.useCallback(B=>{o(NX(B))},[o]),S=y.useCallback(B=>{o(FX(B))},[o]),E=y.useCallback(B=>{o(MX(B))},[o]),x=y.useCallback((B,I)=>{o(IX({id:B,data:I}))},[o]),O=y.useCallback(()=>{o(yT())},[o]),A=y.useCallback(B=>{o(PX(B))},[o]),T=y.useCallback(B=>{o(LX(B))},[o]);return{nodes:i,edges:s,op_status:u,selectedNodes:a,selectedEdges:l,currentNodeConfigVisibleId:c,onNodesChange:v,onEdgesChange:b,onConnect:w,onEdgeUpdate:g,addEdges:C,removeNodes:k,removeEdges:_,setNodes:S,setEdges:E,updateNode:x,refreshFlow:O,setFlowOpStatusAction:p,workflowId:n,setNodeConfigVisible:A,isLocked:d,setLocked:T,autoSaveFlow:m,flowMetadata:f}}const Ot=()=>{const{isLocked:t}=ao(),e=na();return y.useMemo(()=>n2(e,t),[e,t])},jX=()=>{const{flowMetadata:t}=ao();return t},Pw=()=>{const t=ne.useStoreApi(),e=ne.useReactFlow(),n=y.useCallback((a,l)=>{e.updateEdgeData(l.id,{...l.data,isHovered:!0})},[e]),r=y.useCallback((a,l)=>{e.updateEdgeData(l.id,{...l.data,isHovered:!1})},[e]),o=y.useCallback(a=>{const{edges:l,setEdges:c}=t.getState();c(ne.applyEdgeChanges(a,l))},[t]),i=y.useCallback(a=>{const{edges:l}=t.getState();e.deleteElements({edges:l.filter(c=>a.includes(c.id))})},[t,e]),s=y.useCallback(a=>{const l=$o.createEdge(fo.MAIN,`${a.source}-${a.target}-${Date.now()}`,a.source,a.target,{sourceHandle:a.sourceHandle,targetHandle:a.targetHandle,data:{renderType:a.sourceHandle,connectionType:a.sourceHandle}});e.addEdges(l)},[e]);return{onEdgeMouseEnter:n,removeEdges:i,onConnect:s,setEdges:t.getState().setEdges,onEdgeMouseLeave:r,handleEdgesChange:o}},WX=t=>{switch(t){case me.INVALID:return"workflow-edge-warning";case me.FAILED:return"workflow-edge-failed";case me.SUCCESS:return"workflow-edge-success";case me.RUNNING:return"workflow-edge-running";case me.IDLE:default:return""}},{EDGE_BORDER_RADIUS:Lw}=th,{undeletableEdgeTargetTypes:UX,unAddableTargetTypes:qX}=Jy,nf=1,GX=30;function kT(t){var o,i,s;if(!t)return null;const e=(o=t.internals)==null?void 0:o.positionAbsolute,n=(i=t.measured)==null?void 0:i.width,r=(s=t.measured)==null?void 0:s.height;return!e||n==null||r==null?null:{x1:e.x,x2:e.x+n,y1:e.y,y2:e.y+r}}const RX=({id:t,sourceX:e,sourceY:n,targetX:r,targetY:o,sourcePosition:i,targetPosition:s,data:a,source:l,sourceHandleId:c,target:u,targetHandleId:d,style:f={},animated:p=!1,className:m="workflow-main-edge"})=>{const v=El(),{removeEdges:b}=Pw(),{getNodes:w}=aa(),{openNodeSelector:g}=dc();ne.useStoreApi();const C=ne.useInternalNode(l),k=C==null?void 0:C.data,_=(k==null?void 0:k.status)||me.IDLE,S=Ot(),E=ne.useInternalNode(u);E==null||E.data;const x=EI(i),O=$t(),A=O.edgeRules,T=y.useMemo(()=>s===ne.Position.Left?r+nf:s===ne.Position.Right?r-nf:r,[r,s]),B=y.useMemo(()=>s===ne.Position.Top?o+nf:s===ne.Position.Bottom?o-nf:o,[o,s]),I=kT(C),F=kT(E),N=I!==null&&F!==null?I.y2<F.y1:n<o,P=I!==null&&F!==null?I.x2<=F.x1:e<=T,M=ne.useStore(re=>re.edges),z=l===u,H=z||dh(l,u,M),R=I!==null&&F!==null?I.y1<F.y2&&F.y1<I.y2:!0,Y=UX.includes(E==null?void 0:E.type),$=!qX.includes(E==null?void 0:E.type)&&(!A||A.allowAddNodeOnEdge!==!1),j=!Y&&(!A||A.allowDeleteEdge!==!1),{edgePath:U,labelX:ee,labelY:ie}=y.useMemo(()=>{if(!z&&DI({sourcePosition:i,targetPosition:s,sourceAboveTarget:N,sourceLeftOfTarget:P})){const[re,Z,ue]=ne.getBezierPath({sourceX:e,sourceY:n,sourcePosition:i,targetX:T,targetY:B,targetPosition:s});return{edgePath:re,labelX:Z,labelY:ue}}else{if(z)return _I({sourceX:e,sourceY:n,sourcePosition:i,targetX:T,targetY:B,targetPosition:s,borderRadius:Lw});if(H&&R)return OI({sourceX:e,sourceY:n,sourcePosition:i,targetX:T,targetY:B,targetPosition:s,borderRadius:Lw});{const[re,Z,ue]=ne.getSmoothStepPath({sourceX:e,sourceY:n,sourcePosition:i,targetX:T,targetY:B,targetPosition:s,borderRadius:Lw,offset:GX});return{edgePath:re,labelX:Z,labelY:ue}}}},[e,n,T,B,i,s,N,P,z,H,R]),be={...xI({isVerticalEdge:x,isLoopEdge:H,isHovered:!!(a!=null&&a.isHovered)}),...f},W=`workflow-edge ${p?"workflow-edge-animated":""}
|
|
136
136
|
${H?"workflow-loop-edge":""}
|
|
137
137
|
${a!=null&&a.isHovered?"edge-hovered":""}
|
|
138
|
-
${WX(_)} ${m} ${(a==null?void 0:a.renderType)??""}`.replace(/\s+/g," ").trim(),X=re=>{var fe,le;if(re.stopPropagation(),A&&A.allowAddNodeOnEdge===!1)return;const Z=w(),ue=(fe=O.canvas.limits)==null?void 0:fe.maxNodes;if(typeof ue=="number"&&Z.length>=ue){D.message.warning("已达到画布允许的最大节点数");return}const ve={x:(e+T)/2,y:(n+B)/2};g({position:ve,edge:{id:t,source:l,sourceHandleId:c,target:u,targetHandleId:d,data:a},targetNode:Pt.cloneDeep(E),sourceNode:Pt.cloneDeep(C),protocol:`${((le=C.data)==null?void 0:le.protocol)??""}`})},q=re=>{re.stopPropagation(),j&&(b([t]),Wy(v,[t]))},J=[h.jsx("path",{id:t,className:W,d:U,style:be,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",markerEnd:"url(#workflow-arrow)"},`${t}-path`),S&&($||j)?h.jsx(ne.EdgeLabelRenderer,{children:h.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${ee}px,${ie}px)`,padding:"4px",borderRadius:"8px",opacity:a!=null&&a.isHovered?1:0,gap:"8px",zIndex:1e3,pointerEvents:"all"},className:"nodrag nopan workflow-edge-buttons",children:[$&&h.jsx("button",{type:"button",onClick:X,style:{...ta.default,...ta.add},className:"workflow-edge-button",title:"添加节点","aria-label":"添加节点",children:h.jsx(se.PlusOutlined,{style:{fontSize:"12px"}})}),j&&h.jsx("button",{type:"button",onClick:q,style:{...ta.default,...ta.delete},className:"workflow-edge-button",title:"删除连线","aria-label":"删除连线",children:h.jsx(se.CloseOutlined,{style:{fontSize:"12px"}})})]})},`${t}-buttons`):null];return a!=null&&a.label&&J.push(h.jsx(ne.EdgeLabelRenderer,{children:h.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${ee}px,${ie+(z?20:0)}px)`,...Xy.edge},children:a.label})},`${t}-label`)),J};class $o{static getEdgeTypes(){return{[fo.MAIN]:RX}}static getEdgeComponent(e){const n=$o.getEdgeTypes();return n[e]||n[fo.MAIN]}static createEdge(e,n,r,o,i){let s={},a,l,c;if(i&&typeof i=="object"&&("sourceHandle"in i||"targetHandle"in i||"onAddNode"in i)){const u=i;a=u.sourceHandle,l=u.targetHandle,c=u.onAddNode,s=u.data||{}}return{id:n,type:e,source:r,target:o,sourceHandle:a,targetHandle:l,data:{...s,className:"workflow-main-edge",onAddNode:c},markerEnd:{type:ne.MarkerType.ArrowClosed,width:20,height:20,color:"#7e8186"},style:{stroke:"#7e8186",strokeWidth:1},className:"workflow-main-edge"}}}const KX=new Set(["type","action_type","action_id","action_key","action_ver","nodeKey","nodeVersion","node_type","label","action_name","name","description","icon","connector_name","connector_id","deployment_type","nodeIcon","category","config_schema","properties","params","status","protocol","closed","disabled","note","connector_id","n_id","account_id","account_schema_id","backendData","isHovered","output","outputSource","isAction","saveType"]),YX=t=>{const e={};for(const[n,r]of Object.entries(t))KX.has(n)&&(e[n]=r);return{label:t.action_name,description:t.connector_name,...t.action_key?{nodeKey:t.action_key}:{},...t.action_ver!==void 0?{nodeVersion:t.action_ver}:{},...e}},XX=$o.getEdgeTypes(),JX={"--edge-marker-size":"14px","--edge-stroke-width":"1px"},QX={x:0,y:0,zoom:1},ZX={x:0,y:0,zoom:.8},eJ={type:fo.MAIN,markerEnd:{type:ne.MarkerType.ArrowClosed,width:20,height:20,color:"#7e8186"}},tJ="944";function nJ(t,e,n=""){const r=t.map(o=>{const{config_schema:i,config:s,params:a,node_schema:l,nodeSchema:c,...u}=o.data??{},{id:d,position:f,type:p}=o;return{...u,id:d,node_type:p,position:f,connector_id:u.connector_id||"",action_id:u.action_id||u.id||"",account_id:u.account_id||null,properties:i||s||{},action_name:u.label||"",description:u.description||""}});return{name:n,connections:e,nodes:r}}const rJ=({nodes:t,edges:e,workflowName:n,workflowId:r,executionControl:o,metadata:i={}})=>{const s=nJ(t,e,n),{nodes:a,connections:l,version_no:c,...u}=i;return{...u,...s,id:r,...o?{execution_control:o}:{}}};class ST extends Error{constructor(e,n){super(n||e||"连接流加载失败"),this.code=e,this.description=n,this.name="FlowLoadError"}}const oJ=({onOpenNodeSelector:t,onAddNoteNode:e,onTidyCanvas:n,panelStyle:r={},buttonStyle:o={},dangerButtonStyle:i={},showTidyButton:s=!0,buttons:a})=>{const l=[{key:"add-node",title:"添加节点",icon:h.jsx(se.PlusOutlined,{}),onClick:p=>{p.stopPropagation(),t==null||t()},visible:!0,danger:!1,type:"default"},{key:"add-note",title:"添加便签",icon:h.jsx(se.BookOutlined,{}),onClick:e,visible:!0,danger:!1,type:"default"}],c=a||l,u={background:"transparent",boxShadow:"none",...r},d={width:"auto",height:29,fontSize:11,...o},f={...d,...i};return h.jsx(ne.Panel,{position:"top-right",style:u,children:h.jsx(D.Space,{direction:"horizontal",children:c.map(p=>p.visible===!1?null:h.jsx(D.Button,{onClick:p.onClick,"aria-label":p.title,type:p.type,color:p.color,style:p.danger?f:d,size:"small",danger:p.danger,icon:p.icon,children:p.title},p.key))})})},iJ=y.memo(({loading:t,error:e,onRetry:n})=>!t&&!e?null:h.jsx("div",{className:`workflow-fullscreen-loading${e?" is-error":""}`,role:e?"alert":"status","aria-live":"polite",children:h.jsxs("div",{className:"workflow-fullscreen-loading__card",children:[e?h.jsx(se.WarningOutlined,{className:"workflow-fullscreen-loading__error-icon"}):h.jsx(D.Spin,{}),h.jsxs("div",{className:"workflow-fullscreen-loading__copy",children:[h.jsx("strong",{children:e?"连接流加载失败":"正在同步工作流"}),h.jsx("span",{children:e?e.description||"无法获取连接流数据,请检查网络或稍后重试。":"正在获取节点、连线与运行配置,请稍候。"}),e!=null&&e.code?h.jsxs("span",{className:"workflow-fullscreen-loading__error-code",children:["错误码:",e.code]}):null]}),e&&n?h.jsx(D.Button,{icon:h.jsx(se.ReloadOutlined,{}),onClick:n,children:"重新加载"}):null]})})),sJ=y.memo(()=>h.jsx("svg",{style:{position:"absolute",width:0,height:0},children:h.jsx("defs",{children:h.jsx("marker",{id:"workflow-arrow",viewBox:"-10 -10 20 20",refX:"3",refY:"0",markerWidth:"12.5",markerHeight:"12.5",markerUnits:"strokeWidth",orient:"auto-start-reverse",children:h.jsx("polyline",{strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4",strokeWidth:"3",stroke:"context-stroke",fill:"context-stroke"})})})})),aJ={width:"100%",height:"100%",position:"absolute",zIndex:10,pointerEvents:"none"},lJ=t=>({width:t.width,height:t.height,transform:t.transform});function cJ({horizontal:t,vertical:e}){const{width:n,height:r,transform:o}=ne.useStore(lJ),i=y.useRef(null);return y.useEffect(()=>{const s=i.current,a=s==null?void 0:s.getContext("2d");if(!a||!s)return;const l=window.devicePixelRatio;s.width=n*l,s.height=r*l,a.scale(l,l),a.clearRect(0,0,n,r),a.strokeStyle="#0041d0",typeof e=="number"&&(a.moveTo(e*o[2]+o[0],0),a.lineTo(e*o[2]+o[0],r),a.stroke()),typeof t=="number"&&(a.moveTo(0,t*o[2]+o[1]),a.lineTo(n,t*o[2]+o[1]),a.stroke())},[n,r,o,t,e]),h.jsx("canvas",{ref:i,className:"react-flow__canvas",style:aJ})}const uJ=y.memo(cJ);function dJ(t){return t.map(e=>{const{node_type:n,id:r,position:o,icon:i,action_name:s,connector_name:a,description:l,action_id:c,connector_id:u,properties:d,account_schema_id:f,account_id:p,action_key:m,action_ver:v,node_schema:b,nodeSchema:w,...g}=e;let C,k;if(n===pe.STICKY)try{const S=JSON.parse(d.value);C=S.width,k=S.height}catch{}const _={type:n,id:r,position:o,data:{icon:i,label:s,action_name:s,description:l,connector_name:a,connector_id:u,account_id:p,account_schema_id:f,action_id:c,action_key:m,action_ver:v,node_type:n,nodeKey:m||g.nodeKey,nodeVersion:v??g.nodeVersion,params:g.params||d,config_schema:d,...g}};if(typeof C=="number"||typeof k=="number"){const S=_.style||{};_.style={...S,...typeof C=="number"?{width:C}:{},...typeof k=="number"?{height:k}:{}}}return _})}function ET(t){if(!t)return console.error("API返回数据格式错误: 缺少data字段"),{workflowId:"",workflowName:"",nodes:[],edges:[]};const e=dJ(t.nodes||[]),n=e.map(o=>o.id),r=(t.connections||[]).map(o=>({...o,type:o.type||"main"})).filter(o=>n.includes(o.target)&&o.source&&o.sourceHandle&&o.targetHandle);return{workflowId:t.id||"",workflowName:t.name||"",nodes:e,edges:r}}const xT=1;async function fJ(t){const e=[],n=new Set,r=t.filter(o=>o.data&&!(parseInt(`${o.data.action_id}`,10)>0));for(const o of r){const i=o.data??{},s=typeof i.action_key=="string"?i.action_key:typeof i.nodeKey=="string"?i.nodeKey:"";if(!s)continue;const a=i.action_ver??i.nodeVersion,c=a==null||a===""?xT:Number(a),u=Number.isFinite(c)?c:xT,d=`${s}@${u}`;n.has(d)||(n.add(d),e.push(pc(s,u).catch(()=>null)))}e.length!==0&&await Promise.all(e)}async function hJ(t){const n=t.filter(r=>(r==null?void 0:r.data)&&!(parseInt(`${r.data.action_id}`,10)>0)).map(r=>{const o=r.data??{};return wT({...o,node_type:r.type})});await Promise.all(n)}function pJ(t){const{nodes:e,edges:n,workflowName:r}=ET(t);return{nodes:e,edges:n,name:r||"",opStatus:t==null?void 0:t.op_status,executionControl:(t==null?void 0:t.execution_control)??null,metadata:t}}function mJ(t){const{workflowId:e,strategy:n,setNodes:r,setEdges:o,fitView:i,setLoading:s,dispatch:a,setFlowOpStatusAction:l,refreshWorkFlowNum:c,onLoad:u}=t,[d,f]=y.useState(null),[p,m]=y.useState(0),v=y.useCallback(()=>{m(w=>w+1)},[]),b=y.useRef(u);return b.current=u,y.useEffect(()=>{if(!e)return;let w=!1;return s(!0),f(null),(async()=>{var g;try{const k=await(b.current?b.current(e).then(pJ):n.loadFlow(e));if(w)return;a(Tl(k.name)),a(CT(k.executionControl??null)),a($X(k.metadata??{})),k.opStatus&&l(k.opStatus);const{nodes:_,edges:S}=k,E=_.map(T=>{var B,I;if((B=T==null?void 0:T.data)!=null&&B.action_id&&parseInt(`${(I=T==null?void 0:T.data)==null?void 0:I.action_id}`,10)<1){const F=ia(T.data.action_key,T.data.action_ver);return{...T,type:F,data:{...T.data,saveType:T.type,isNodePackage:!0}}}return T});n.requiresTriggerNode&&i({minZoom:.3,maxZoom:1});const O=S.filter(T=>T.sourceHandle==="loop").map(T=>T.id),A=S.map(T=>O.includes(T.id)?{...T,data:{...T.data,renderType:"loop",connectionType:T.type}}:T);if(await fJ(E),await hJ(E),w)return;r(E),o(A)}catch(C){if(w)return;if((g=C==null?void 0:C.response)!=null&&g.data){const k=C.response.data;f({code:(k==null?void 0:k.error)??"",description:(k==null?void 0:k.error_description)??""})}else C instanceof ST?f({code:C.code,description:C.description}):f({description:C instanceof Error&&C.message?C.message:"无法获取连接流数据,请检查网络或稍后重试。"});r([]),o([])}finally{w||s(!1)}})(),()=>{w=!0}},[e,n,a,i,o,r,l,s,c,p]),{loadError:d,retry:v}}function gJ(t){const e=t.backendActionId??t.action_id??t.id;return String(e)}const $w="[workflow:node-add]";function wJ({workflowId:t,strategy:e,store:n,addNodes:r,addEdges:o,removeEdges:i,updateEdge:s,setNodeAddCallback:a,handleEdgeAddNode:l,setNodeConfigVisible:c,setNodeFitHumanView:u,validateConnectionAgainstSnapshot:d,saveFlow:f}){var k,_,S,E;const p=$t(),m=Te.useIntl(),v=((_=(k=p.nodeSelector)==null?void 0:k.connectable)==null?void 0:_.enabled)===!0,b=((E=(S=p.nodeSelector)==null?void 0:S.connectable)==null?void 0:E.debug)===!0,w=y.useCallback((x,O)=>{D.message.warning(m.formatMessage({id:x}))},[m]),g=y.useCallback(x=>{!b||Number(x.compatibleCount)<=1},[b]),C=y.useCallback(async(x,O)=>{var X,q,J,re,Z,ue,ve;if(!t)return;let A=null;const{nodes:T}=n.getState(),B=e.convertNodeData??YX,I=O.action_key||O.nodeKey,F=O.action_ver??O.nodeVersion,N=gJ(O),P=po(O),M=O.type===pe.STICKY,z=P&&!M?ia(O.action_key,O.action_ver):x.trigger?pe.TRIGGER:O.action_type,H=x.trigger?pe.TRIGGER:O.action_type;let R=null;if(x.edge&&x.sourceNode){const we=x.sourceNode.position;R={x:we.x+(((q=(X=x.sourceNode)==null?void 0:X.measured)==null?void 0:q.width)||220)+60,y:we.y}}const Y=(R||x.position)??{x:100,y:250},{nodeId:te,nodeData:$}=await e.createNode({workflowId:t,nodeType:H,actionId:N,actionKey:I,actionVer:F,configSchema:O.config_schema||{},position:Y,icon:O.icon,name:O.name||O.action_name,connectorName:O.connector_name,nodeVersion:O.nodeVersion,existingNodes:T});A=te,P&&await wT({...O,...$,node_type:z,action_key:I??O.action_key,action_ver:F??O.action_ver});const j=B({...O,...$,node_type:z,saveType:H}),U=Ni.createNode(z,te,j,Y);r([U]),u(te);const{nodes:ee}=n.getState(),ie=ee.some(we=>we.id===U.id)?ee:[...ee,U];if(M){await f();return}const be=AP(U);be.length>0&&o(be);const W=!!x.sourceHandle;if(x.edge){const we=x.edge,fe=we.sourceHandle??we.sourceHandleId??"",le=we.targetHandle??we.targetHandleId??"",Se=T.find(je=>je.id===we.source)??x.sourceNode,ce=T.find(je=>je.id===we.target)??x.targetNode,Fe=[],Ve=Se?sa(Se,fe):null;if(!Ve)console.error("未找到连线的源节点或 handle,保留原线",we);else{const je=hh(U,Ve.protocol,!0,Ve.name);if(!je)console.log("新节点没有协议兼容的输入端口,保留原线");else{const We=mc(ie,{source:we.source,sourceHandle:fe||void 0,target:U.id,targetHandle:je.name});if(!We.valid)console.warn(`${$w} 插入改写旧线校验未通过,保留原线`,{edgeId:we.id,code:We.code,message:We.message});else{const ht=ce?(J=sa(ce,le))==null?void 0:J.protocol:null,Ee=ht?hh(U,ht,!1,le??void 0):null;if(s(we.id,{target:U.id,targetHandle:je.name}),Ee){const Ce=mc(ie,{source:U.id,sourceHandle:Ee.name,target:we.target,targetHandle:le||void 0});Ce.valid?Fe.push($o.createEdge(fo.MAIN,`${U.id}-${we.target}-${Date.now()}`,U.id,we.target,{sourceHandle:Ee.name,targetHandle:le||void 0,onAddNode:l,data:{renderType:Ee.name}})):console.warn(`${$w} 第二段连线校验未通过,仅改写旧线 target`,{edgeId:we.id,code:Ce.code,message:Ce.message})}else console.log("新节点没有可接回原 target 的 output,仅改写旧线 target",we.id)}}}Fe.length>0&&o(Fe)}else{const we=sa(x.targetNode??x.sourceNode,x.targetHandle??x.sourceHandle);if(we!==null){const fe=hh(U,we.protocol,W,x.targetHandle??x.sourceHandle??void 0);if(fe){const le=fe.name,[Se,ce,Fe,Ve]=W?[((re=x.targetNode)==null?void 0:re.id)||((Z=x.sourceNode)==null?void 0:Z.id),U.id,x.targetHandle||x.sourceHandle,le]:[U.id,((ue=x.targetNode)==null?void 0:ue.id)||((ve=x.sourceNode)==null?void 0:ve.id),le,x.targetHandle||x.sourceHandle],je=mc(ie,{source:Se,target:ce,sourceHandle:Fe,targetHandle:Ve});if(je.valid){const We=$o.createEdge(fo.MAIN,`${Se}-${ce}-${Date.now()}`,Se,ce,{sourceHandle:Fe,targetHandle:Ve,onAddNode:l,data:{renderType:W?Fe:Ve}});o([We])}else console.warn(`${$w} 锚点连线校验未通过,跳过连线`,{code:je.code,message:je.message,source:Se,sourceHandle:Fe,target:ce,targetHandle:Ve})}else console.log("新节点没有协议兼容的端口,不能连接",we.protocol)}else x.trigger||console.error("未找到 handle",x)}u(A),c(A),setTimeout(f,0)},[o,r,v,l,i,g,w,f,c,u,n,e,s,d,t]);y.useEffect(()=>(a(C),()=>{a(()=>{})}),[C,a])}const bJ=t=>async()=>{await t()},vJ=t=>y.useMemo(()=>bJ(t),[t]);function yJ({workflowId:t,dispatch:e,reactFlow:n,setEdges:r,setNodes:o,store:i,setNodeConfigVisible:s,saveFlowRef:a}){const l=y.useRef(new Map);return{canvasApi:y.useMemo(()=>({init(){},destroy(){e(Mw()),r([]),o([]),l.current.clear()},refresh(){e(yT())},setFlowOpStatus(u){e(vT(u))},getData(){const{nodes:u,edges:d}=i.getState();return{nodes:u.map(f=>{var p;return{id:f.id,type:f.type||"",position:f.position,data:f.data,disabled:((p=f.data)==null?void 0:p.closed)==="1"}}),edges:d.map(f=>({id:f.id,source:f.source,target:f.target,data:f.data}))}},setData(u){const d=u.nodes.map(p=>({id:p.id,type:p.type,position:p.position,data:p.data})),f=u.edges.map(p=>({id:p.id,source:p.source,target:p.target,data:p.data}));o(d),r(f)},exportJSON(){return JSON.stringify(this.getData())},importJSON(u){try{const d=typeof u=="string"?JSON.parse(u):u;this.setData(d)}catch(d){console.error("导入 JSON 失败",d)}},zoomIn(){n.zoomIn()},zoomOut(){n.zoomOut()},zoomTo(u){n.zoomTo(u)},fitView(){n.fitView()},center(){n.fitView({padding:.2})},addNode(u){const d=u.id||`${Date.now()}`,f={id:d,type:u.type,position:u.position,data:u.data};return o(p=>[...p,f]),d},updateNode(u,d){o(f=>f.map(p=>p.id===u?{...p,...d,position:d.position||p.position,data:d.data?{...p.data,...d.data}:p.data}:p))},deleteNode(u){o(d=>d.filter(f=>f.id!==u)),r(d=>d.filter(f=>f.source!==u&&f.target!==u))},getNode(u){var p;const{nodes:d}=i.getState(),f=d.find(m=>m.id===u);return f?{id:f.id,type:f.type||"",position:f.position,data:f.data,disabled:((p=f.data)==null?void 0:p.closed)==="1"}:null},selectNode(){},clearSelection(){n.setNodes(u=>u.map(d=>({...d,selected:!1})))},moveNode(u,d){this.updateNode(u,{position:d})},enableNode(u){this.updateNode(u,{disabled:!1})},disableNode(u){this.updateNode(u,{disabled:!0})},addEdge(u){const d=u.id||`${u.source}-${u.target}-${Date.now()}`,f={id:d,source:u.source,target:u.target,data:u.data};return r(p=>[...p,f]),d},deleteEdge(u){r(d=>d.filter(f=>f.id!==u))},deleteEdgesBetween(u,d){r(f=>f.filter(p=>p.source!==u||p.target!==d))},openNodePanel(u){s(u)},closeNodePanel(){s(null)},isPanelOpen(){const{currentNodeConfigVisibleId:u}=i.getState();return!!u},async runNodeTest(){return Promise.resolve(null)},async saveFlow(){return a.current()},on(u,d){return l.current.has(u)||l.current.set(u,new Set),l.current.get(u).add(d),()=>{this.off(u,d)}},off(u,d){const f=l.current.get(u);f&&(d?f.delete(d):f.clear(),f.size===0&&l.current.delete(u))},emit(u,d){const f=l.current.get(u);f&&f.forEach(p=>{try{p(d)}catch(m){console.error(`事件 "${u}" 的处理器执行出错:`,m)}})},once(u,d){const f=p=>{d(p),this.off(u,f)};this.on(u,f)},async refreshFlowVersionStatus(){if(t)try{const u=await qy(t);e(HX(u))}catch(u){console.error("[canvasApi] refreshFlowVersionStatus failed:",u)}}}),[e,n,r,o,i,s,t]),eventListenersRef:l}}function DT(t,e){var o,i;const n=((o=t.measured)==null?void 0:o.width)??0,r=((i=t.measured)==null?void 0:i.height)??0;return{left:e.x,right:e.x+n,top:e.y,bottom:e.y+r,width:n,height:r}}function _T(t,e,n){let r=t;for(const{edge:o,offset:i}of e)for(const s of n){const a={distance:Math.abs(o-s),line:s,snapPosition:s-i};(!r||a.distance<r.distance)&&(r=a)}return r}function CJ(t,e,n=20){const r={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},o=e.find(l=>l.id===t.id);if(!o||!t.position)return r;const i=DT(o,t.position);let s,a;for(const l of e){if(l.id===o.id)continue;const c=DT(l,l.position);s=_T(s,[{edge:i.left,offset:0},{edge:i.right,offset:i.width}],[c.left,c.right]),a=_T(a,[{edge:i.top,offset:0},{edge:i.bottom,offset:i.height}],[c.top,c.bottom])}return{vertical:s==null?void 0:s.line,horizontal:a==null?void 0:a.line,snapPosition:{x:s&&s.distance<n?s.snapPosition:void 0,y:a&&a.distance<n?a.snapPosition:void 0}}}const kJ=({enabled:t=!0,message:e="您有未保存的更改,确定要离开吗?"})=>{y.useEffect(()=>{if(!t)return;let n;return(()=>{n=ac.block(o=>{t?window.confirm(e)&&(n==null||n(),o.retry()):(n==null||n(),o.retry())})})(),()=>{n==null||n()}},[t,e]),y.useEffect(()=>{if(!t)return;const n=r=>{if(t)return r.preventDefault(),r.returnValue=e,e};return window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n)},[t,e])};var zw,AT;function Hw(){if(AT)return zw;AT=1;var t="\0",e="\0",n="";class r{constructor(u){lt(this,"_isDirected",!0);lt(this,"_isMultigraph",!1);lt(this,"_isCompound",!1);lt(this,"_label");lt(this,"_defaultNodeLabelFn",()=>{});lt(this,"_defaultEdgeLabelFn",()=>{});lt(this,"_nodes",{});lt(this,"_in",{});lt(this,"_preds",{});lt(this,"_out",{});lt(this,"_sucs",{});lt(this,"_edgeObjs",{});lt(this,"_edgeLabels",{});lt(this,"_nodeCount",0);lt(this,"_edgeCount",0);lt(this,"_parent");lt(this,"_children");u&&(this._isDirected=Object.hasOwn(u,"directed")?u.directed:!0,this._isMultigraph=Object.hasOwn(u,"multigraph")?u.multigraph:!1,this._isCompound=Object.hasOwn(u,"compound")?u.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[e]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(u){return this._label=u,this}graph(){return this._label}setDefaultNodeLabel(u){return this._defaultNodeLabelFn=u,typeof u!="function"&&(this._defaultNodeLabelFn=()=>u),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var u=this;return this.nodes().filter(d=>Object.keys(u._in[d]).length===0)}sinks(){var u=this;return this.nodes().filter(d=>Object.keys(u._out[d]).length===0)}setNodes(u,d){var f=arguments,p=this;return u.forEach(function(m){f.length>1?p.setNode(m,d):p.setNode(m)}),this}setNode(u,d){return Object.hasOwn(this._nodes,u)?(arguments.length>1&&(this._nodes[u]=d),this):(this._nodes[u]=arguments.length>1?d:this._defaultNodeLabelFn(u),this._isCompound&&(this._parent[u]=e,this._children[u]={},this._children[e][u]=!0),this._in[u]={},this._preds[u]={},this._out[u]={},this._sucs[u]={},++this._nodeCount,this)}node(u){return this._nodes[u]}hasNode(u){return Object.hasOwn(this._nodes,u)}removeNode(u){var d=this;if(Object.hasOwn(this._nodes,u)){var f=p=>d.removeEdge(d._edgeObjs[p]);delete this._nodes[u],this._isCompound&&(this._removeFromParentsChildList(u),delete this._parent[u],this.children(u).forEach(function(p){d.setParent(p)}),delete this._children[u]),Object.keys(this._in[u]).forEach(f),delete this._in[u],delete this._preds[u],Object.keys(this._out[u]).forEach(f),delete this._out[u],delete this._sucs[u],--this._nodeCount}return this}setParent(u,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(d===void 0)d=e;else{d+="";for(var f=d;f!==void 0;f=this.parent(f))if(f===u)throw new Error("Setting "+d+" as parent of "+u+" would create a cycle");this.setNode(d)}return this.setNode(u),this._removeFromParentsChildList(u),this._parent[u]=d,this._children[d][u]=!0,this}_removeFromParentsChildList(u){delete this._children[this._parent[u]][u]}parent(u){if(this._isCompound){var d=this._parent[u];if(d!==e)return d}}children(u=e){if(this._isCompound){var d=this._children[u];if(d)return Object.keys(d)}else{if(u===e)return this.nodes();if(this.hasNode(u))return[]}}predecessors(u){var d=this._preds[u];if(d)return Object.keys(d)}successors(u){var d=this._sucs[u];if(d)return Object.keys(d)}neighbors(u){var d=this.predecessors(u);if(d){const p=new Set(d);for(var f of this.successors(u))p.add(f);return Array.from(p.values())}}isLeaf(u){var d;return this.isDirected()?d=this.successors(u):d=this.neighbors(u),d.length===0}filterNodes(u){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var f=this;Object.entries(this._nodes).forEach(function([v,b]){u(v)&&d.setNode(v,b)}),Object.values(this._edgeObjs).forEach(function(v){d.hasNode(v.v)&&d.hasNode(v.w)&&d.setEdge(v,f.edge(v))});var p={};function m(v){var b=f.parent(v);return b===void 0||d.hasNode(b)?(p[v]=b,b):b in p?p[b]:m(b)}return this._isCompound&&d.nodes().forEach(v=>d.setParent(v,m(v))),d}setDefaultEdgeLabel(u){return this._defaultEdgeLabelFn=u,typeof u!="function"&&(this._defaultEdgeLabelFn=()=>u),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(u,d){var f=this,p=arguments;return u.reduce(function(m,v){return p.length>1?f.setEdge(m,v,d):f.setEdge(m,v),v}),this}setEdge(){var u,d,f,p,m=!1,v=arguments[0];typeof v=="object"&&v!==null&&"v"in v?(u=v.v,d=v.w,f=v.name,arguments.length===2&&(p=arguments[1],m=!0)):(u=v,d=arguments[1],f=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),u=""+u,d=""+d,f!==void 0&&(f=""+f);var b=s(this._isDirected,u,d,f);if(Object.hasOwn(this._edgeLabels,b))return m&&(this._edgeLabels[b]=p),this;if(f!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(u),this.setNode(d),this._edgeLabels[b]=m?p:this._defaultEdgeLabelFn(u,d,f);var w=a(this._isDirected,u,d,f);return u=w.v,d=w.w,Object.freeze(w),this._edgeObjs[b]=w,o(this._preds[d],u),o(this._sucs[u],d),this._in[d][b]=w,this._out[u][b]=w,this._edgeCount++,this}edge(u,d,f){var p=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,f);return this._edgeLabels[p]}edgeAsObj(){const u=this.edge(...arguments);return typeof u!="object"?{label:u}:u}hasEdge(u,d,f){var p=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,f);return Object.hasOwn(this._edgeLabels,p)}removeEdge(u,d,f){var p=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,f),m=this._edgeObjs[p];return m&&(u=m.v,d=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],i(this._preds[d],u),i(this._sucs[u],d),delete this._in[d][p],delete this._out[u][p],this._edgeCount--),this}inEdges(u,d){var f=this._in[u];if(f){var p=Object.values(f);return d?p.filter(m=>m.v===d):p}}outEdges(u,d){var f=this._out[u];if(f){var p=Object.values(f);return d?p.filter(m=>m.w===d):p}}nodeEdges(u,d){var f=this.inEdges(u,d);if(f)return f.concat(this.outEdges(u,d))}}function o(c,u){c[u]?c[u]++:c[u]=1}function i(c,u){--c[u]||delete c[u]}function s(c,u,d,f){var p=""+u,m=""+d;if(!c&&p>m){var v=p;p=m,m=v}return p+n+m+n+(f===void 0?t:f)}function a(c,u,d,f){var p=""+u,m=""+d;if(!c&&p>m){var v=p;p=m,m=v}var b={v:p,w:m};return f&&(b.name=f),b}function l(c,u){return s(c,u.v,u.w,u.name)}return zw=r,zw}var Vw,OT;function SJ(){return OT||(OT=1,Vw="2.2.4"),Vw}var jw,TT;function EJ(){return TT||(TT=1,jw={Graph:Hw(),version:SJ()}),jw}var Ww,NT;function xJ(){if(NT)return Ww;NT=1;var t=Hw();Ww={write:e,read:o};function e(i){var s={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:n(i),edges:r(i)};return i.graph()!==void 0&&(s.value=structuredClone(i.graph())),s}function n(i){return i.nodes().map(function(s){var a=i.node(s),l=i.parent(s),c={v:s};return a!==void 0&&(c.value=a),l!==void 0&&(c.parent=l),c})}function r(i){return i.edges().map(function(s){var a=i.edge(s),l={v:s.v,w:s.w};return s.name!==void 0&&(l.name=s.name),a!==void 0&&(l.value=a),l})}function o(i){var s=new t(i.options).setGraph(i.value);return i.nodes.forEach(function(a){s.setNode(a.v,a.value),a.parent&&s.setParent(a.v,a.parent)}),i.edges.forEach(function(a){s.setEdge({v:a.v,w:a.w,name:a.name},a.value)}),s}return Ww}var Uw,BT;function DJ(){if(BT)return Uw;BT=1,Uw=t;function t(e){var n={},r=[],o;function i(s){Object.hasOwn(n,s)||(n[s]=!0,o.push(s),e.successors(s).forEach(i),e.predecessors(s).forEach(i))}return e.nodes().forEach(function(s){o=[],i(s),o.length&&r.push(o)}),r}return Uw}var qw,FT;function MT(){if(FT)return qw;FT=1;class t{constructor(){lt(this,"_arr",[]);lt(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,r){var o=this._keyIndices;if(n=String(n),!Object.hasOwn(o,n)){var i=this._arr,s=i.length;return o[n]=s,i.push({key:n,priority:r}),this._decrease(s),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,r){var o=this._keyIndices[n];if(r>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[o].priority+" New: "+r);this._arr[o].priority=r,this._decrease(o)}_heapify(n){var r=this._arr,o=2*n,i=o+1,s=n;o<r.length&&(s=r[o].priority<r[s].priority?o:s,i<r.length&&(s=r[i].priority<r[s].priority?i:s),s!==n&&(this._swap(n,s),this._heapify(s)))}_decrease(n){for(var r=this._arr,o=r[n].priority,i;n!==0&&(i=n>>1,!(r[i].priority<o));)this._swap(n,i),n=i}_swap(n,r){var o=this._arr,i=this._keyIndices,s=o[n],a=o[r];o[n]=a,o[r]=s,i[a.key]=n,i[s.key]=r}}return qw=t,qw}var Gw,IT;function PT(){if(IT)return Gw;IT=1;var t=MT();Gw=n;var e=()=>1;function n(o,i,s,a){return r(o,String(i),s||e,a||function(l){return o.outEdges(l)})}function r(o,i,s,a){var l={},c=new t,u,d,f=function(p){var m=p.v!==u?p.v:p.w,v=l[m],b=s(p),w=d.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+p+" Weight: "+b);w<v.distance&&(v.distance=w,v.predecessor=u,c.decrease(m,w))};for(o.nodes().forEach(function(p){var m=p===i?0:Number.POSITIVE_INFINITY;l[p]={distance:m},c.add(p,m)});c.size()>0&&(u=c.removeMin(),d=l[u],d.distance!==Number.POSITIVE_INFINITY);)a(u).forEach(f);return l}return Gw}var Rw,LT;function _J(){if(LT)return Rw;LT=1;var t=PT();Rw=e;function e(n,r,o){return n.nodes().reduce(function(i,s){return i[s]=t(n,s,r,o),i},{})}return Rw}var Kw,$T;function zT(){if($T)return Kw;$T=1,Kw=t;function t(e){var n=0,r=[],o={},i=[];function s(a){var l=o[a]={onStack:!0,lowlink:n,index:n++};if(r.push(a),e.successors(a).forEach(function(d){Object.hasOwn(o,d)?o[d].onStack&&(l.lowlink=Math.min(l.lowlink,o[d].index)):(s(d),l.lowlink=Math.min(l.lowlink,o[d].lowlink))}),l.lowlink===l.index){var c=[],u;do u=r.pop(),o[u].onStack=!1,c.push(u);while(a!==u);i.push(c)}}return e.nodes().forEach(function(a){Object.hasOwn(o,a)||s(a)}),i}return Kw}var Yw,HT;function AJ(){if(HT)return Yw;HT=1;var t=zT();Yw=e;function e(n){return t(n).filter(function(r){return r.length>1||r.length===1&&n.hasEdge(r[0],r[0])})}return Yw}var Xw,VT;function OJ(){if(VT)return Xw;VT=1,Xw=e;var t=()=>1;function e(r,o,i){return n(r,o||t,i||function(s){return r.outEdges(s)})}function n(r,o,i){var s={},a=r.nodes();return a.forEach(function(l){s[l]={},s[l][l]={distance:0},a.forEach(function(c){l!==c&&(s[l][c]={distance:Number.POSITIVE_INFINITY})}),i(l).forEach(function(c){var u=c.v===l?c.w:c.v,d=o(c);s[l][u]={distance:d,predecessor:l}})}),a.forEach(function(l){var c=s[l];a.forEach(function(u){var d=s[u];a.forEach(function(f){var p=d[l],m=c[f],v=d[f],b=p.distance+m.distance;b<v.distance&&(v.distance=b,v.predecessor=m.predecessor)})})}),s}return Xw}var Jw,jT;function WT(){if(jT)return Jw;jT=1;function t(n){var r={},o={},i=[];function s(a){if(Object.hasOwn(o,a))throw new e;Object.hasOwn(r,a)||(o[a]=!0,r[a]=!0,n.predecessors(a).forEach(s),delete o[a],i.push(a))}if(n.sinks().forEach(s),Object.keys(r).length!==n.nodeCount())throw new e;return i}class e extends Error{constructor(){super(...arguments)}}return Jw=t,t.CycleException=e,Jw}var Qw,UT;function TJ(){if(UT)return Qw;UT=1;var t=WT();Qw=e;function e(n){try{t(n)}catch(r){if(r instanceof t.CycleException)return!1;throw r}return!0}return Qw}var Zw,qT;function GT(){if(qT)return Zw;qT=1,Zw=t;function t(o,i,s){Array.isArray(i)||(i=[i]);var a=o.isDirected()?d=>o.successors(d):d=>o.neighbors(d),l=s==="post"?e:n,c=[],u={};return i.forEach(d=>{if(!o.hasNode(d))throw new Error("Graph does not have node: "+d);l(d,a,u,c)}),c}function e(o,i,s,a){for(var l=[[o,!1]];l.length>0;){var c=l.pop();c[1]?a.push(c[0]):Object.hasOwn(s,c[0])||(s[c[0]]=!0,l.push([c[0],!0]),r(i(c[0]),u=>l.push([u,!1])))}}function n(o,i,s,a){for(var l=[o];l.length>0;){var c=l.pop();Object.hasOwn(s,c)||(s[c]=!0,a.push(c),r(i(c),u=>l.push(u)))}}function r(o,i){for(var s=o.length;s--;)i(o[s],s,o);return o}return Zw}var eb,RT;function NJ(){if(RT)return eb;RT=1;var t=GT();eb=e;function e(n,r){return t(n,r,"post")}return eb}var tb,KT;function BJ(){if(KT)return tb;KT=1;var t=GT();tb=e;function e(n,r){return t(n,r,"pre")}return tb}var nb,YT;function FJ(){if(YT)return nb;YT=1;var t=Hw(),e=MT();nb=n;function n(r,o){var i=new t,s={},a=new e,l;function c(d){var f=d.v===l?d.w:d.v,p=a.priority(f);if(p!==void 0){var m=o(d);m<p&&(s[f]=l,a.decrease(f,m))}}if(r.nodeCount()===0)return i;r.nodes().forEach(function(d){a.add(d,Number.POSITIVE_INFINITY),i.setNode(d)}),a.decrease(r.nodes()[0],0);for(var u=!1;a.size()>0;){if(l=a.removeMin(),Object.hasOwn(s,l))i.setEdge(l,s[l]);else{if(u)throw new Error("Input graph is not connected: "+r);u=!0}r.nodeEdges(l).forEach(c)}return i}return nb}var rb,XT;function MJ(){return XT||(XT=1,rb={components:DJ(),dijkstra:PT(),dijkstraAll:_J(),findCycles:AJ(),floydWarshall:OJ(),isAcyclic:TJ(),postorder:NJ(),preorder:BJ(),prim:FJ(),tarjan:zT(),topsort:WT()}),rb}var ob,JT;function vr(){if(JT)return ob;JT=1;var t=EJ();return ob={Graph:t.Graph,json:xJ(),alg:MJ(),version:t.version},ob}var ib,QT;function IJ(){if(QT)return ib;QT=1;class t{constructor(){let o={};o._next=o._prev=o,this._sentinel=o}dequeue(){let o=this._sentinel,i=o._prev;if(i!==o)return e(i),i}enqueue(o){let i=this._sentinel;o._prev&&o._next&&e(o),o._next=i._next,i._next._prev=o,i._next=o,o._prev=i}toString(){let o=[],i=this._sentinel,s=i._prev;for(;s!==i;)o.push(JSON.stringify(s,n)),s=s._prev;return"["+o.join(", ")+"]"}}function e(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,o){if(r!=="_next"&&r!=="_prev")return o}return ib=t,ib}var sb,ZT;function PJ(){if(ZT)return sb;ZT=1;let t=vr().Graph,e=IJ();sb=r;let n=()=>1;function r(c,u){if(c.nodeCount()<=1)return[];let d=s(c,u||n);return o(d.graph,d.buckets,d.zeroIdx).flatMap(p=>c.outEdges(p.v,p.w))}function o(c,u,d){let f=[],p=u[u.length-1],m=u[0],v;for(;c.nodeCount();){for(;v=m.dequeue();)i(c,u,d,v);for(;v=p.dequeue();)i(c,u,d,v);if(c.nodeCount()){for(let b=u.length-2;b>0;--b)if(v=u[b].dequeue(),v){f=f.concat(i(c,u,d,v,!0));break}}}return f}function i(c,u,d,f,p){let m=p?[]:void 0;return c.inEdges(f.v).forEach(v=>{let b=c.edge(v),w=c.node(v.v);p&&m.push({v:v.v,w:v.w}),w.out-=b,a(u,d,w)}),c.outEdges(f.v).forEach(v=>{let b=c.edge(v),w=v.w,g=c.node(w);g.in-=b,a(u,d,g)}),c.removeNode(f.v),m}function s(c,u){let d=new t,f=0,p=0;c.nodes().forEach(b=>{d.setNode(b,{v:b,in:0,out:0})}),c.edges().forEach(b=>{let w=d.edge(b.v,b.w)||0,g=u(b),C=w+g;d.setEdge(b.v,b.w,C),p=Math.max(p,d.node(b.v).out+=g),f=Math.max(f,d.node(b.w).in+=g)});let m=l(p+f+3).map(()=>new e),v=f+1;return d.nodes().forEach(b=>{a(m,v,d.node(b))}),{graph:d,buckets:m,zeroIdx:v}}function a(c,u,d){d.out?d.in?c[d.out-d.in+u].enqueue(d):c[c.length-1].enqueue(d):c[0].enqueue(d)}function l(c){const u=[];for(let d=0;d<c;d++)u.push(d);return u}return sb}var ab,eN;function Ft(){if(eN)return ab;eN=1;let t=vr().Graph;ab={addBorderNode:u,addDummyNode:e,applyWithChunking:p,asNonCompoundGraph:r,buildLayerMatrix:a,intersectRect:s,mapValues:S,maxRank:m,normalizeRanks:l,notime:w,partition:v,pick:_,predecessorWeights:i,range:k,removeEmptyRanks:c,simplify:n,successorWeights:o,time:b,uniqueId:C,zipObject:E};function e(x,O,A,T){for(var B=T;x.hasNode(B);)B=C(T);return A.dummy=O,x.setNode(B,A),B}function n(x){let O=new t().setGraph(x.graph());return x.nodes().forEach(A=>O.setNode(A,x.node(A))),x.edges().forEach(A=>{let T=O.edge(A.v,A.w)||{weight:0,minlen:1},B=x.edge(A);O.setEdge(A.v,A.w,{weight:T.weight+B.weight,minlen:Math.max(T.minlen,B.minlen)})}),O}function r(x){let O=new t({multigraph:x.isMultigraph()}).setGraph(x.graph());return x.nodes().forEach(A=>{x.children(A).length||O.setNode(A,x.node(A))}),x.edges().forEach(A=>{O.setEdge(A,x.edge(A))}),O}function o(x){let O=x.nodes().map(A=>{let T={};return x.outEdges(A).forEach(B=>{T[B.w]=(T[B.w]||0)+x.edge(B).weight}),T});return E(x.nodes(),O)}function i(x){let O=x.nodes().map(A=>{let T={};return x.inEdges(A).forEach(B=>{T[B.v]=(T[B.v]||0)+x.edge(B).weight}),T});return E(x.nodes(),O)}function s(x,O){let A=x.x,T=x.y,B=O.x-A,I=O.y-T,F=x.width/2,N=x.height/2;if(!B&&!I)throw new Error("Not possible to find intersection inside of the rectangle");let P,M;return Math.abs(I)*F>Math.abs(B)*N?(I<0&&(N=-N),P=N*B/I,M=N):(B<0&&(F=-F),P=F,M=F*I/B),{x:A+P,y:T+M}}function a(x){let O=k(m(x)+1).map(()=>[]);return x.nodes().forEach(A=>{let T=x.node(A),B=T.rank;B!==void 0&&(O[B][T.order]=A)}),O}function l(x){let O=x.nodes().map(T=>{let B=x.node(T).rank;return B===void 0?Number.MAX_VALUE:B}),A=p(Math.min,O);x.nodes().forEach(T=>{let B=x.node(T);Object.hasOwn(B,"rank")&&(B.rank-=A)})}function c(x){let O=x.nodes().map(F=>x.node(F).rank),A=p(Math.min,O),T=[];x.nodes().forEach(F=>{let N=x.node(F).rank-A;T[N]||(T[N]=[]),T[N].push(F)});let B=0,I=x.graph().nodeRankFactor;Array.from(T).forEach((F,N)=>{F===void 0&&N%I!==0?--B:F!==void 0&&B&&F.forEach(P=>x.node(P).rank+=B)})}function u(x,O,A,T){let B={width:0,height:0};return arguments.length>=4&&(B.rank=A,B.order=T),e(x,"border",B,O)}function d(x,O=f){const A=[];for(let T=0;T<x.length;T+=O){const B=x.slice(T,T+O);A.push(B)}return A}const f=65535;function p(x,O){if(O.length>f){const A=d(O);return x.apply(null,A.map(T=>x.apply(null,T)))}else return x.apply(null,O)}function m(x){const A=x.nodes().map(T=>{let B=x.node(T).rank;return B===void 0?Number.MIN_VALUE:B});return p(Math.max,A)}function v(x,O){let A={lhs:[],rhs:[]};return x.forEach(T=>{O(T)?A.lhs.push(T):A.rhs.push(T)}),A}function b(x,O){let A=Date.now();try{return O()}finally{console.log(x+" time: "+(Date.now()-A)+"ms")}}function w(x,O){return O()}let g=0;function C(x){var O=++g;return x+(""+O)}function k(x,O,A=1){O==null&&(O=x,x=0);let T=I=>I<O;A<0&&(T=I=>O<I);const B=[];for(let I=x;T(I);I+=A)B.push(I);return B}function _(x,O){const A={};for(const T of O)x[T]!==void 0&&(A[T]=x[T]);return A}function S(x,O){let A=O;return typeof O=="string"&&(A=T=>T[O]),Object.entries(x).reduce((T,[B,I])=>(T[B]=A(I,B),T),{})}function E(x,O){return x.reduce((A,T,B)=>(A[T]=O[B],A),{})}return ab}var lb,tN;function LJ(){if(tN)return lb;tN=1;let t=PJ(),e=Ft().uniqueId;lb={run:n,undo:o};function n(i){(i.graph().acyclicer==="greedy"?t(i,a(i)):r(i)).forEach(l=>{let c=i.edge(l);i.removeEdge(l),c.forwardName=l.name,c.reversed=!0,i.setEdge(l.w,l.v,c,e("rev"))});function a(l){return c=>l.edge(c).weight}}function r(i){let s=[],a={},l={};function c(u){Object.hasOwn(l,u)||(l[u]=!0,a[u]=!0,i.outEdges(u).forEach(d=>{Object.hasOwn(a,d.w)?s.push(d):c(d.w)}),delete a[u])}return i.nodes().forEach(c),s}function o(i){i.edges().forEach(s=>{let a=i.edge(s);if(a.reversed){i.removeEdge(s);let l=a.forwardName;delete a.reversed,delete a.forwardName,i.setEdge(s.w,s.v,a,l)}})}return lb}var cb,nN;function $J(){if(nN)return cb;nN=1;let t=Ft();cb={run:e,undo:r};function e(o){o.graph().dummyChains=[],o.edges().forEach(i=>n(o,i))}function n(o,i){let s=i.v,a=o.node(s).rank,l=i.w,c=o.node(l).rank,u=i.name,d=o.edge(i),f=d.labelRank;if(c===a+1)return;o.removeEdge(i);let p,m,v;for(v=0,++a;a<c;++v,++a)d.points=[],m={width:0,height:0,edgeLabel:d,edgeObj:i,rank:a},p=t.addDummyNode(o,"edge",m,"_d"),a===f&&(m.width=d.width,m.height=d.height,m.dummy="edge-label",m.labelpos=d.labelpos),o.setEdge(s,p,{weight:d.weight},u),v===0&&o.graph().dummyChains.push(p),s=p;o.setEdge(s,l,{weight:d.weight},u)}function r(o){o.graph().dummyChains.forEach(i=>{let s=o.node(i),a=s.edgeLabel,l;for(o.setEdge(s.edgeObj,a);s.dummy;)l=o.successors(i)[0],o.removeNode(i),a.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(a.x=s.x,a.y=s.y,a.width=s.width,a.height=s.height),i=l,s=o.node(i)})}return cb}var ub,rN;function rf(){if(rN)return ub;rN=1;const{applyWithChunking:t}=Ft();ub={longestPath:e,slack:n};function e(r){var o={};function i(s){var a=r.node(s);if(Object.hasOwn(o,s))return a.rank;o[s]=!0;let l=r.outEdges(s).map(u=>u==null?Number.POSITIVE_INFINITY:i(u.w)-r.edge(u).minlen);var c=t(Math.min,l);return c===Number.POSITIVE_INFINITY&&(c=0),a.rank=c}r.sources().forEach(i)}function n(r,o){return r.node(o.w).rank-r.node(o.v).rank-r.edge(o).minlen}return ub}var db,oN;function iN(){if(oN)return db;oN=1;var t=vr().Graph,e=rf().slack;db=n;function n(s){var a=new t({directed:!1}),l=s.nodes()[0],c=s.nodeCount();a.setNode(l,{});for(var u,d;r(a,s)<c;)u=o(a,s),d=a.hasNode(u.v)?e(s,u):-e(s,u),i(a,s,d);return a}function r(s,a){function l(c){a.nodeEdges(c).forEach(u=>{var d=u.v,f=c===d?u.w:d;!s.hasNode(f)&&!e(a,u)&&(s.setNode(f,{}),s.setEdge(c,f,{}),l(f))})}return s.nodes().forEach(l),s.nodeCount()}function o(s,a){return a.edges().reduce((c,u)=>{let d=Number.POSITIVE_INFINITY;return s.hasNode(u.v)!==s.hasNode(u.w)&&(d=e(a,u)),d<c[0]?[d,u]:c},[Number.POSITIVE_INFINITY,null])[1]}function i(s,a,l){s.nodes().forEach(c=>a.node(c).rank+=l)}return db}var fb,sN;function zJ(){if(sN)return fb;sN=1;var t=iN(),e=rf().slack,n=rf().longestPath,r=vr().alg.preorder,o=vr().alg.postorder,i=Ft().simplify;fb=s,s.initLowLimValues=u,s.initCutValues=a,s.calcCutValue=c,s.leaveEdge=f,s.enterEdge=p,s.exchangeEdges=m;function s(g){g=i(g),n(g);var C=t(g);u(C),a(C,g);for(var k,_;k=f(C);)_=p(C,g,k),m(C,g,k,_)}function a(g,C){var k=o(g,g.nodes());k=k.slice(0,k.length-1),k.forEach(_=>l(g,C,_))}function l(g,C,k){var _=g.node(k),S=_.parent;g.edge(k,S).cutvalue=c(g,C,k)}function c(g,C,k){var _=g.node(k),S=_.parent,E=!0,x=C.edge(k,S),O=0;return x||(E=!1,x=C.edge(S,k)),O=x.weight,C.nodeEdges(k).forEach(A=>{var T=A.v===k,B=T?A.w:A.v;if(B!==S){var I=T===E,F=C.edge(A).weight;if(O+=I?F:-F,b(g,k,B)){var N=g.edge(k,B).cutvalue;O+=I?-N:N}}}),O}function u(g,C){arguments.length<2&&(C=g.nodes()[0]),d(g,{},1,C)}function d(g,C,k,_,S){var E=k,x=g.node(_);return C[_]=!0,g.neighbors(_).forEach(O=>{Object.hasOwn(C,O)||(k=d(g,C,k,O,_))}),x.low=E,x.lim=k++,S?x.parent=S:delete x.parent,k}function f(g){return g.edges().find(C=>g.edge(C).cutvalue<0)}function p(g,C,k){var _=k.v,S=k.w;C.hasEdge(_,S)||(_=k.w,S=k.v);var E=g.node(_),x=g.node(S),O=E,A=!1;E.lim>x.lim&&(O=x,A=!0);var T=C.edges().filter(B=>A===w(g,g.node(B.v),O)&&A!==w(g,g.node(B.w),O));return T.reduce((B,I)=>e(C,I)<e(C,B)?I:B)}function m(g,C,k,_){var S=k.v,E=k.w;g.removeEdge(S,E),g.setEdge(_.v,_.w,{}),u(g),a(g,C),v(g,C)}function v(g,C){var k=g.nodes().find(S=>!C.node(S).parent),_=r(g,k);_=_.slice(1),_.forEach(S=>{var E=g.node(S).parent,x=C.edge(S,E),O=!1;x||(x=C.edge(E,S),O=!0),C.node(S).rank=C.node(E).rank+(O?x.minlen:-x.minlen)})}function b(g,C,k){return g.hasEdge(C,k)}function w(g,C,k){return k.low<=C.lim&&C.lim<=k.lim}return fb}var hb,aN;function HJ(){if(aN)return hb;aN=1;var t=rf(),e=t.longestPath,n=iN(),r=zJ();hb=o;function o(l){var c=l.graph().ranker;if(c instanceof Function)return c(l);switch(l.graph().ranker){case"network-simplex":a(l);break;case"tight-tree":s(l);break;case"longest-path":i(l);break;case"none":break;default:a(l)}}var i=e;function s(l){e(l),n(l)}function a(l){r(l)}return hb}var pb,lN;function VJ(){if(lN)return pb;lN=1,pb=t;function t(r){let o=n(r);r.graph().dummyChains.forEach(i=>{let s=r.node(i),a=s.edgeObj,l=e(r,o,a.v,a.w),c=l.path,u=l.lca,d=0,f=c[d],p=!0;for(;i!==a.w;){if(s=r.node(i),p){for(;(f=c[d])!==u&&r.node(f).maxRank<s.rank;)d++;f===u&&(p=!1)}if(!p){for(;d<c.length-1&&r.node(f=c[d+1]).minRank<=s.rank;)d++;f=c[d]}r.setParent(i,f),i=r.successors(i)[0]}})}function e(r,o,i,s){let a=[],l=[],c=Math.min(o[i].low,o[s].low),u=Math.max(o[i].lim,o[s].lim),d,f;d=i;do d=r.parent(d),a.push(d);while(d&&(o[d].low>c||u>o[d].lim));for(f=d,d=s;(d=r.parent(d))!==f;)l.push(d);return{path:a.concat(l.reverse()),lca:f}}function n(r){let o={},i=0;function s(a){let l=i;r.children(a).forEach(s),o[a]={low:l,lim:i++}}return r.children().forEach(s),o}return pb}var mb,cN;function jJ(){if(cN)return mb;cN=1;let t=Ft();mb={run:e,cleanup:i};function e(s){let a=t.addDummyNode(s,"root",{},"_root"),l=r(s),c=Object.values(l),u=t.applyWithChunking(Math.max,c)-1,d=2*u+1;s.graph().nestingRoot=a,s.edges().forEach(p=>s.edge(p).minlen*=d);let f=o(s)+1;s.children().forEach(p=>n(s,a,d,f,u,l,p)),s.graph().nodeRankFactor=d}function n(s,a,l,c,u,d,f){let p=s.children(f);if(!p.length){f!==a&&s.setEdge(a,f,{weight:0,minlen:l});return}let m=t.addBorderNode(s,"_bt"),v=t.addBorderNode(s,"_bb"),b=s.node(f);s.setParent(m,f),b.borderTop=m,s.setParent(v,f),b.borderBottom=v,p.forEach(w=>{n(s,a,l,c,u,d,w);let g=s.node(w),C=g.borderTop?g.borderTop:w,k=g.borderBottom?g.borderBottom:w,_=g.borderTop?c:2*c,S=C!==k?1:u-d[f]+1;s.setEdge(m,C,{weight:_,minlen:S,nestingEdge:!0}),s.setEdge(k,v,{weight:_,minlen:S,nestingEdge:!0})}),s.parent(f)||s.setEdge(a,m,{weight:0,minlen:u+d[f]})}function r(s){var a={};function l(c,u){var d=s.children(c);d&&d.length&&d.forEach(f=>l(f,u+1)),a[c]=u}return s.children().forEach(c=>l(c,1)),a}function o(s){return s.edges().reduce((a,l)=>a+s.edge(l).weight,0)}function i(s){var a=s.graph();s.removeNode(a.nestingRoot),delete a.nestingRoot,s.edges().forEach(l=>{var c=s.edge(l);c.nestingEdge&&s.removeEdge(l)})}return mb}var gb,uN;function WJ(){if(uN)return gb;uN=1;let t=Ft();gb=e;function e(r){function o(i){let s=r.children(i),a=r.node(i);if(s.length&&s.forEach(o),Object.hasOwn(a,"minRank")){a.borderLeft=[],a.borderRight=[];for(let l=a.minRank,c=a.maxRank+1;l<c;++l)n(r,"borderLeft","_bl",i,a,l),n(r,"borderRight","_br",i,a,l)}}r.children().forEach(o)}function n(r,o,i,s,a,l){let c={width:0,height:0,rank:l,borderType:o},u=a[o][l-1],d=t.addDummyNode(r,"border",c,i);a[o][l]=d,r.setParent(d,s),u&&r.setEdge(u,d,{weight:1})}return gb}var wb,dN;function UJ(){if(dN)return wb;dN=1,wb={adjust:t,undo:e};function t(l){let c=l.graph().rankdir.toLowerCase();(c==="lr"||c==="rl")&&n(l)}function e(l){let c=l.graph().rankdir.toLowerCase();(c==="bt"||c==="rl")&&o(l),(c==="lr"||c==="rl")&&(s(l),n(l))}function n(l){l.nodes().forEach(c=>r(l.node(c))),l.edges().forEach(c=>r(l.edge(c)))}function r(l){let c=l.width;l.width=l.height,l.height=c}function o(l){l.nodes().forEach(c=>i(l.node(c))),l.edges().forEach(c=>{let u=l.edge(c);u.points.forEach(i),Object.hasOwn(u,"y")&&i(u)})}function i(l){l.y=-l.y}function s(l){l.nodes().forEach(c=>a(l.node(c))),l.edges().forEach(c=>{let u=l.edge(c);u.points.forEach(a),Object.hasOwn(u,"x")&&a(u)})}function a(l){let c=l.x;l.x=l.y,l.y=c}return wb}var bb,fN;function qJ(){if(fN)return bb;fN=1;let t=Ft();bb=e;function e(n){let r={},o=n.nodes().filter(u=>!n.children(u).length),i=o.map(u=>n.node(u).rank),s=t.applyWithChunking(Math.max,i),a=t.range(s+1).map(()=>[]);function l(u){if(r[u])return;r[u]=!0;let d=n.node(u);a[d.rank].push(u),n.successors(u).forEach(l)}return o.sort((u,d)=>n.node(u).rank-n.node(d).rank).forEach(l),a}return bb}var vb,hN;function GJ(){if(hN)return vb;hN=1;let t=Ft().zipObject;vb=e;function e(r,o){let i=0;for(let s=1;s<o.length;++s)i+=n(r,o[s-1],o[s]);return i}function n(r,o,i){let s=t(i,i.map((f,p)=>p)),a=o.flatMap(f=>r.outEdges(f).map(p=>({pos:s[p.w],weight:r.edge(p).weight})).sort((p,m)=>p.pos-m.pos)),l=1;for(;l<i.length;)l<<=1;let c=2*l-1;l-=1;let u=new Array(c).fill(0),d=0;return a.forEach(f=>{let p=f.pos+l;u[p]+=f.weight;let m=0;for(;p>0;)p%2&&(m+=u[p+1]),p=p-1>>1,u[p]+=f.weight;d+=f.weight*m}),d}return vb}var yb,pN;function RJ(){if(pN)return yb;pN=1,yb=t;function t(e,n=[]){return n.map(r=>{let o=e.inEdges(r);if(o.length){let i=o.reduce((s,a)=>{let l=e.edge(a),c=e.node(a.v);return{sum:s.sum+l.weight*c.order,weight:s.weight+l.weight}},{sum:0,weight:0});return{v:r,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:r}})}return yb}var Cb,mN;function KJ(){if(mN)return Cb;mN=1;let t=Ft();Cb=e;function e(o,i){let s={};o.forEach((l,c)=>{let u=s[l.v]={indegree:0,in:[],out:[],vs:[l.v],i:c};l.barycenter!==void 0&&(u.barycenter=l.barycenter,u.weight=l.weight)}),i.edges().forEach(l=>{let c=s[l.v],u=s[l.w];c!==void 0&&u!==void 0&&(u.indegree++,c.out.push(s[l.w]))});let a=Object.values(s).filter(l=>!l.indegree);return n(a)}function n(o){let i=[];function s(l){return c=>{c.merged||(c.barycenter===void 0||l.barycenter===void 0||c.barycenter>=l.barycenter)&&r(l,c)}}function a(l){return c=>{c.in.push(l),--c.indegree===0&&o.push(c)}}for(;o.length;){let l=o.pop();i.push(l),l.in.reverse().forEach(s(l)),l.out.forEach(a(l))}return i.filter(l=>!l.merged).map(l=>t.pick(l,["vs","i","barycenter","weight"]))}function r(o,i){let s=0,a=0;o.weight&&(s+=o.barycenter*o.weight,a+=o.weight),i.weight&&(s+=i.barycenter*i.weight,a+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=s/a,o.weight=a,o.i=Math.min(i.i,o.i),i.merged=!0}return Cb}var kb,gN;function YJ(){if(gN)return kb;gN=1;let t=Ft();kb=e;function e(o,i){let s=t.partition(o,m=>Object.hasOwn(m,"barycenter")),a=s.lhs,l=s.rhs.sort((m,v)=>v.i-m.i),c=[],u=0,d=0,f=0;a.sort(r(!!i)),f=n(c,l,f),a.forEach(m=>{f+=m.vs.length,c.push(m.vs),u+=m.barycenter*m.weight,d+=m.weight,f=n(c,l,f)});let p={vs:c.flat(!0)};return d&&(p.barycenter=u/d,p.weight=d),p}function n(o,i,s){let a;for(;i.length&&(a=i[i.length-1]).i<=s;)i.pop(),o.push(a.vs),s++;return s}function r(o){return(i,s)=>i.barycenter<s.barycenter?-1:i.barycenter>s.barycenter?1:o?s.i-i.i:i.i-s.i}return kb}var Sb,wN;function XJ(){if(wN)return Sb;wN=1;let t=RJ(),e=KJ(),n=YJ();Sb=r;function r(s,a,l,c){let u=s.children(a),d=s.node(a),f=d?d.borderLeft:void 0,p=d?d.borderRight:void 0,m={};f&&(u=u.filter(g=>g!==f&&g!==p));let v=t(s,u);v.forEach(g=>{if(s.children(g.v).length){let C=r(s,g.v,l,c);m[g.v]=C,Object.hasOwn(C,"barycenter")&&i(g,C)}});let b=e(v,l);o(b,m);let w=n(b,c);if(f&&(w.vs=[f,w.vs,p].flat(!0),s.predecessors(f).length)){let g=s.node(s.predecessors(f)[0]),C=s.node(s.predecessors(p)[0]);Object.hasOwn(w,"barycenter")||(w.barycenter=0,w.weight=0),w.barycenter=(w.barycenter*w.weight+g.order+C.order)/(w.weight+2),w.weight+=2}return w}function o(s,a){s.forEach(l=>{l.vs=l.vs.flatMap(c=>a[c]?a[c].vs:c)})}function i(s,a){s.barycenter!==void 0?(s.barycenter=(s.barycenter*s.weight+a.barycenter*a.weight)/(s.weight+a.weight),s.weight+=a.weight):(s.barycenter=a.barycenter,s.weight=a.weight)}return Sb}var Eb,bN;function JJ(){if(bN)return Eb;bN=1;let t=vr().Graph,e=Ft();Eb=n;function n(o,i,s,a){a||(a=o.nodes());let l=r(o),c=new t({compound:!0}).setGraph({root:l}).setDefaultNodeLabel(u=>o.node(u));return a.forEach(u=>{let d=o.node(u),f=o.parent(u);(d.rank===i||d.minRank<=i&&i<=d.maxRank)&&(c.setNode(u),c.setParent(u,f||l),o[s](u).forEach(p=>{let m=p.v===u?p.w:p.v,v=c.edge(m,u),b=v!==void 0?v.weight:0;c.setEdge(m,u,{weight:o.edge(p).weight+b})}),Object.hasOwn(d,"minRank")&&c.setNode(u,{borderLeft:d.borderLeft[i],borderRight:d.borderRight[i]}))}),c}function r(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return Eb}var xb,vN;function QJ(){if(vN)return xb;vN=1,xb=t;function t(e,n,r){let o={},i;r.forEach(s=>{let a=e.parent(s),l,c;for(;a;){if(l=e.parent(a),l?(c=o[l],o[l]=a):(c=i,i=a),c&&c!==a){n.setEdge(c,a);return}a=l}})}return xb}var Db,yN;function ZJ(){if(yN)return Db;yN=1;let t=qJ(),e=GJ(),n=XJ(),r=JJ(),o=QJ(),i=vr().Graph,s=Ft();Db=a;function a(d,f){if(f&&typeof f.customOrder=="function"){f.customOrder(d,a);return}let p=s.maxRank(d),m=l(d,s.range(1,p+1),"inEdges"),v=l(d,s.range(p-1,-1,-1),"outEdges"),b=t(d);if(u(d,b),f&&f.disableOptimalOrderHeuristic)return;let w=Number.POSITIVE_INFINITY,g;for(let C=0,k=0;k<4;++C,++k){c(C%2?m:v,C%4>=2),b=s.buildLayerMatrix(d);let _=e(d,b);_<w&&(k=0,g=Object.assign({},b),w=_)}u(d,g)}function l(d,f,p){const m=new Map,v=(b,w)=>{m.has(b)||m.set(b,[]),m.get(b).push(w)};for(const b of d.nodes()){const w=d.node(b);if(typeof w.rank=="number"&&v(w.rank,b),typeof w.minRank=="number"&&typeof w.maxRank=="number")for(let g=w.minRank;g<=w.maxRank;g++)g!==w.rank&&v(g,b)}return f.map(function(b){return r(d,b,p,m.get(b)||[])})}function c(d,f){let p=new i;d.forEach(function(m){let v=m.graph().root,b=n(m,v,p,f);b.vs.forEach((w,g)=>m.node(w).order=g),o(m,p,b.vs)})}function u(d,f){Object.values(f).forEach(p=>p.forEach((m,v)=>d.node(m).order=v))}return Db}var _b,CN;function eQ(){if(CN)return _b;CN=1;let t=vr().Graph,e=Ft();_b={positionX:p,findType1Conflicts:n,findType2Conflicts:r,addConflict:i,hasConflict:s,verticalAlignment:a,horizontalCompaction:l,alignCoordinates:d,findSmallestWidthAlignment:u,balance:f};function n(b,w){let g={};function C(k,_){let S=0,E=0,x=k.length,O=_[_.length-1];return _.forEach((A,T)=>{let B=o(b,A),I=B?b.node(B).order:x;(B||A===O)&&(_.slice(E,T+1).forEach(F=>{b.predecessors(F).forEach(N=>{let P=b.node(N),M=P.order;(M<S||I<M)&&!(P.dummy&&b.node(F).dummy)&&i(g,N,F)})}),E=T+1,S=I)}),_}return w.length&&w.reduce(C),g}function r(b,w){let g={};function C(_,S,E,x,O){let A;e.range(S,E).forEach(T=>{A=_[T],b.node(A).dummy&&b.predecessors(A).forEach(B=>{let I=b.node(B);I.dummy&&(I.order<x||I.order>O)&&i(g,B,A)})})}function k(_,S){let E=-1,x,O=0;return S.forEach((A,T)=>{if(b.node(A).dummy==="border"){let B=b.predecessors(A);B.length&&(x=b.node(B[0]).order,C(S,O,T,E,x),O=T,E=x)}C(S,O,S.length,x,_.length)}),S}return w.length&&w.reduce(k),g}function o(b,w){if(b.node(w).dummy)return b.predecessors(w).find(g=>b.node(g).dummy)}function i(b,w,g){if(w>g){let k=w;w=g,g=k}let C=b[w];C||(b[w]=C={}),C[g]=!0}function s(b,w,g){if(w>g){let C=w;w=g,g=C}return!!b[w]&&Object.hasOwn(b[w],g)}function a(b,w,g,C){let k={},_={},S={};return w.forEach(E=>{E.forEach((x,O)=>{k[x]=x,_[x]=x,S[x]=O})}),w.forEach(E=>{let x=-1;E.forEach(O=>{let A=C(O);if(A.length){A=A.sort((B,I)=>S[B]-S[I]);let T=(A.length-1)/2;for(let B=Math.floor(T),I=Math.ceil(T);B<=I;++B){let F=A[B];_[O]===O&&x<S[F]&&!s(g,O,F)&&(_[F]=O,_[O]=k[O]=k[F],x=S[F])}}})}),{root:k,align:_}}function l(b,w,g,C,k){let _={},S=c(b,w,g,k),E=k?"borderLeft":"borderRight";function x(T,B){let I=S.nodes(),F=I.pop(),N={};for(;F;)N[F]?T(F):(N[F]=!0,I.push(F),I=I.concat(B(F))),F=I.pop()}function O(T){_[T]=S.inEdges(T).reduce((B,I)=>Math.max(B,_[I.v]+S.edge(I)),0)}function A(T){let B=S.outEdges(T).reduce((F,N)=>Math.min(F,_[N.w]-S.edge(N)),Number.POSITIVE_INFINITY),I=b.node(T);B!==Number.POSITIVE_INFINITY&&I.borderType!==E&&(_[T]=Math.max(_[T],B))}return x(O,S.predecessors.bind(S)),x(A,S.successors.bind(S)),Object.keys(C).forEach(T=>_[T]=_[g[T]]),_}function c(b,w,g,C){let k=new t,_=b.graph(),S=m(_.nodesep,_.edgesep,C);return w.forEach(E=>{let x;E.forEach(O=>{let A=g[O];if(k.setNode(A),x){var T=g[x],B=k.edge(T,A);k.setEdge(T,A,Math.max(S(b,O,x),B||0))}x=O})}),k}function u(b,w){return Object.values(w).reduce((g,C)=>{let k=Number.NEGATIVE_INFINITY,_=Number.POSITIVE_INFINITY;Object.entries(C).forEach(([E,x])=>{let O=v(b,E)/2;k=Math.max(x+O,k),_=Math.min(x-O,_)});const S=k-_;return S<g[0]&&(g=[S,C]),g},[Number.POSITIVE_INFINITY,null])[1]}function d(b,w){let g=Object.values(w),C=e.applyWithChunking(Math.min,g),k=e.applyWithChunking(Math.max,g);["u","d"].forEach(_=>{["l","r"].forEach(S=>{let E=_+S,x=b[E];if(x===w)return;let O=Object.values(x),A=C-e.applyWithChunking(Math.min,O);S!=="l"&&(A=k-e.applyWithChunking(Math.max,O)),A&&(b[E]=e.mapValues(x,T=>T+A))})})}function f(b,w){return e.mapValues(b.ul,(g,C)=>{if(w)return b[w.toLowerCase()][C];{let k=Object.values(b).map(_=>_[C]).sort((_,S)=>_-S);return(k[1]+k[2])/2}})}function p(b){let w=e.buildLayerMatrix(b),g=Object.assign(n(b,w),r(b,w)),C={},k;["u","d"].forEach(S=>{k=S==="u"?w:Object.values(w).reverse(),["l","r"].forEach(E=>{E==="r"&&(k=k.map(T=>Object.values(T).reverse()));let x=(S==="u"?b.predecessors:b.successors).bind(b),O=a(b,k,g,x),A=l(b,k,O.root,O.align,E==="r");E==="r"&&(A=e.mapValues(A,T=>-T)),C[S+E]=A})});let _=u(b,C);return d(C,_),f(C,b.graph().align)}function m(b,w,g){return(C,k,_)=>{let S=C.node(k),E=C.node(_),x=0,O;if(x+=S.width/2,Object.hasOwn(S,"labelpos"))switch(S.labelpos.toLowerCase()){case"l":O=-S.width/2;break;case"r":O=S.width/2;break}if(O&&(x+=g?O:-O),O=0,x+=(S.dummy?w:b)/2,x+=(E.dummy?w:b)/2,x+=E.width/2,Object.hasOwn(E,"labelpos"))switch(E.labelpos.toLowerCase()){case"l":O=E.width/2;break;case"r":O=-E.width/2;break}return O&&(x+=g?O:-O),O=0,x}}function v(b,w){return b.node(w).width}return _b}var Ab,kN;function tQ(){if(kN)return Ab;kN=1;let t=Ft(),e=eQ().positionX;Ab=n;function n(o){o=t.asNonCompoundGraph(o),r(o),Object.entries(e(o)).forEach(([i,s])=>o.node(i).x=s)}function r(o){let i=t.buildLayerMatrix(o),s=o.graph().ranksep,a=0;i.forEach(l=>{const c=l.reduce((u,d)=>{const f=o.node(d).height;return u>f?u:f},0);l.forEach(u=>o.node(u).y=a+c/2),a+=c+s})}return Ab}var Ob,SN;function nQ(){if(SN)return Ob;SN=1;let t=LJ(),e=$J(),n=HJ(),r=Ft().normalizeRanks,o=VJ(),i=Ft().removeEmptyRanks,s=jJ(),a=WJ(),l=UJ(),c=ZJ(),u=tQ(),d=Ft(),f=vr().Graph;Ob=p;function p($,j){let U=j&&j.debugTiming?d.time:d.notime;U("layout",()=>{let ee=U(" buildLayoutGraph",()=>x($));U(" runLayout",()=>m(ee,U,j)),U(" updateInputGraph",()=>v($,ee))})}function m($,j,U){j(" makeSpaceForEdgeLabels",()=>O($)),j(" removeSelfEdges",()=>z($)),j(" acyclic",()=>t.run($)),j(" nestingGraph.run",()=>s.run($)),j(" rank",()=>n(d.asNonCompoundGraph($))),j(" injectEdgeLabelProxies",()=>A($)),j(" removeEmptyRanks",()=>i($)),j(" nestingGraph.cleanup",()=>s.cleanup($)),j(" normalizeRanks",()=>r($)),j(" assignRankMinMax",()=>T($)),j(" removeEdgeLabelProxies",()=>B($)),j(" normalize.run",()=>e.run($)),j(" parentDummyChains",()=>o($)),j(" addBorderSegments",()=>a($)),j(" order",()=>c($,U)),j(" insertSelfEdges",()=>H($)),j(" adjustCoordinateSystem",()=>l.adjust($)),j(" position",()=>u($)),j(" positionSelfEdges",()=>R($)),j(" removeBorderNodes",()=>M($)),j(" normalize.undo",()=>e.undo($)),j(" fixupEdgeLabelCoords",()=>N($)),j(" undoCoordinateSystem",()=>l.undo($)),j(" translateGraph",()=>I($)),j(" assignNodeIntersects",()=>F($)),j(" reversePoints",()=>P($)),j(" acyclic.undo",()=>t.undo($))}function v($,j){$.nodes().forEach(U=>{let ee=$.node(U),ie=j.node(U);ee&&(ee.x=ie.x,ee.y=ie.y,ee.rank=ie.rank,j.children(U).length&&(ee.width=ie.width,ee.height=ie.height))}),$.edges().forEach(U=>{let ee=$.edge(U),ie=j.edge(U);ee.points=ie.points,Object.hasOwn(ie,"x")&&(ee.x=ie.x,ee.y=ie.y)}),$.graph().width=j.graph().width,$.graph().height=j.graph().height}let b=["nodesep","edgesep","ranksep","marginx","marginy"],w={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},g=["acyclicer","ranker","rankdir","align"],C=["width","height","rank"],k={width:0,height:0},_=["minlen","weight","width","height","labeloffset"],S={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},E=["labelpos"];function x($){let j=new f({multigraph:!0,compound:!0}),U=te($.graph());return j.setGraph(Object.assign({},w,Y(U,b),d.pick(U,g))),$.nodes().forEach(ee=>{let ie=te($.node(ee));const be=Y(ie,C);Object.keys(k).forEach(W=>{be[W]===void 0&&(be[W]=k[W])}),j.setNode(ee,be),j.setParent(ee,$.parent(ee))}),$.edges().forEach(ee=>{let ie=te($.edge(ee));j.setEdge(ee,Object.assign({},S,Y(ie,_),d.pick(ie,E)))}),j}function O($){let j=$.graph();j.ranksep/=2,$.edges().forEach(U=>{let ee=$.edge(U);ee.minlen*=2,ee.labelpos.toLowerCase()!=="c"&&(j.rankdir==="TB"||j.rankdir==="BT"?ee.width+=ee.labeloffset:ee.height+=ee.labeloffset)})}function A($){$.edges().forEach(j=>{let U=$.edge(j);if(U.width&&U.height){let ee=$.node(j.v),be={rank:($.node(j.w).rank-ee.rank)/2+ee.rank,e:j};d.addDummyNode($,"edge-proxy",be,"_ep")}})}function T($){let j=0;$.nodes().forEach(U=>{let ee=$.node(U);ee.borderTop&&(ee.minRank=$.node(ee.borderTop).rank,ee.maxRank=$.node(ee.borderBottom).rank,j=Math.max(j,ee.maxRank))}),$.graph().maxRank=j}function B($){$.nodes().forEach(j=>{let U=$.node(j);U.dummy==="edge-proxy"&&($.edge(U.e).labelRank=U.rank,$.removeNode(j))})}function I($){let j=Number.POSITIVE_INFINITY,U=0,ee=Number.POSITIVE_INFINITY,ie=0,be=$.graph(),W=be.marginx||0,X=be.marginy||0;function q(J){let re=J.x,Z=J.y,ue=J.width,ve=J.height;j=Math.min(j,re-ue/2),U=Math.max(U,re+ue/2),ee=Math.min(ee,Z-ve/2),ie=Math.max(ie,Z+ve/2)}$.nodes().forEach(J=>q($.node(J))),$.edges().forEach(J=>{let re=$.edge(J);Object.hasOwn(re,"x")&&q(re)}),j-=W,ee-=X,$.nodes().forEach(J=>{let re=$.node(J);re.x-=j,re.y-=ee}),$.edges().forEach(J=>{let re=$.edge(J);re.points.forEach(Z=>{Z.x-=j,Z.y-=ee}),Object.hasOwn(re,"x")&&(re.x-=j),Object.hasOwn(re,"y")&&(re.y-=ee)}),be.width=U-j+W,be.height=ie-ee+X}function F($){$.edges().forEach(j=>{let U=$.edge(j),ee=$.node(j.v),ie=$.node(j.w),be,W;U.points?(be=U.points[0],W=U.points[U.points.length-1]):(U.points=[],be=ie,W=ee),U.points.unshift(d.intersectRect(ee,be)),U.points.push(d.intersectRect(ie,W))})}function N($){$.edges().forEach(j=>{let U=$.edge(j);if(Object.hasOwn(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 P($){$.edges().forEach(j=>{let U=$.edge(j);U.reversed&&U.points.reverse()})}function M($){$.nodes().forEach(j=>{if($.children(j).length){let U=$.node(j),ee=$.node(U.borderTop),ie=$.node(U.borderBottom),be=$.node(U.borderLeft[U.borderLeft.length-1]),W=$.node(U.borderRight[U.borderRight.length-1]);U.width=Math.abs(W.x-be.x),U.height=Math.abs(ie.y-ee.y),U.x=be.x+U.width/2,U.y=ee.y+U.height/2}}),$.nodes().forEach(j=>{$.node(j).dummy==="border"&&$.removeNode(j)})}function z($){$.edges().forEach(j=>{if(j.v===j.w){var U=$.node(j.v);U.selfEdges||(U.selfEdges=[]),U.selfEdges.push({e:j,label:$.edge(j)}),$.removeEdge(j)}})}function H($){var j=d.buildLayerMatrix($);j.forEach(U=>{var ee=0;U.forEach((ie,be)=>{var W=$.node(ie);W.order=be+ee,(W.selfEdges||[]).forEach(X=>{d.addDummyNode($,"selfedge",{width:X.label.width,height:X.label.height,rank:W.rank,order:be+ ++ee,e:X.e,label:X.label},"_se")}),delete W.selfEdges})})}function R($){$.nodes().forEach(j=>{var U=$.node(j);if(U.dummy==="selfedge"){var ee=$.node(U.e.v),ie=ee.x+ee.width/2,be=ee.y,W=U.x-ie,X=ee.height/2;$.setEdge(U.e,U.label),$.removeNode(j),U.label.points=[{x:ie+2*W/3,y:be-X},{x:ie+5*W/6,y:be-X},{x:ie+W,y:be},{x:ie+5*W/6,y:be+X},{x:ie+2*W/3,y:be+X}],U.label.x=U.x,U.label.y=U.y}})}function Y($,j){return d.mapValues(d.pick($,j),Number)}function te($){var j={};return $&&Object.entries($).forEach(([U,ee])=>{typeof U=="string"&&(U=U.toLowerCase()),j[U]=ee}),j}return Ob}var Tb,EN;function rQ(){if(EN)return Tb;EN=1;let t=Ft(),e=vr().Graph;Tb={debugOrdering:n};function n(r){let o=t.buildLayerMatrix(r),i=new e({compound:!0,multigraph:!0}).setGraph({});return r.nodes().forEach(s=>{i.setNode(s,{label:s}),i.setParent(s,"layer"+r.node(s).rank)}),r.edges().forEach(s=>i.setEdge(s.v,s.w,{},s.name)),o.forEach((s,a)=>{let l="layer"+a;i.setNode(l,{rank:"same"}),s.reduce((c,u)=>(i.setEdge(c,u,{style:"invis"}),u))}),i}return Tb}var Nb,xN;function oQ(){return xN||(xN=1,Nb="1.1.8"),Nb}var Bb,DN;function iQ(){return DN||(DN=1,Bb={graphlib:vr(),layout:nQ(),debug:rQ(),util:{time:Ft().time,notime:Ft().notime},version:oQ()}),Bb}var sQ=iQ();const _N=Un(sQ),Fb=20,Ze=222,zo=Fb*15,of=Fb*10,Ps=Fb*3;function aQ(t,e){return PR(t,e)}function lQ(t,e){return LR(t,e)}function AN(t,e,n,r,o,i){const s=new Map(n.map(c=>[c.id,c])),a=e.filter(c=>c.source===t||c.target===t);return a.map(c=>{const u=c.source===t?c.target:c.source;return s.get(u)}).filter(c=>c!==void 0).filter(c=>!o.has(c.id)).filter(c=>{const u=a.find(f=>f.source===t&&f.target===c.id||f.target===t&&f.source===c.id);return u?$R(u,s.get(u.source),s.get(u.target),i)===r:!1})}function cQ(t,e){const n=[t,...e],r=Ze,o=Ze,i=n.length*o+(n.length-1)*Ps,s=r,a=t.position.y,c={x:t.position.x,y:a,width:s,height:i};return{parentId:t.id,childIds:e.map(u=>u.id),boundingBox:c}}function uQ(t,e){const n=Ze,r=Ze,o=Math.max(n,e.length*n+(e.length-1)*zo),i=r+Ps+r,s=t.position.y,l={x:t.position.x,y:s,width:o,height:i};return{parentId:t.id,childIds:e.map(c=>c.id),boundingBox:l}}function dQ(t,e,n){if(t.length===0)return{boundingBox:{x:0,y:0,width:0,height:0},nodes:[]};const r=fQ(t),i=AO(t)==="vertical",s={isMcpServerCanvas:SO(t)},a=[],l=[],c=new Set;t.forEach(S=>{if(aQ(S,s)&&!c.has(S.id)){const E=AN(S.id,e,t,"vertical",c,s);if(E.length>0){const x=cQ(S,E);a.push(x),c.add(S.id),E.forEach(O=>c.add(O.id))}}if(lQ(S,s)&&!c.has(S.id)){const E=AN(S.id,e,t,"horizontal",c,s);if(E.length>0){const x=uQ(S,E);l.push(x),c.add(S.id),E.forEach(O=>c.add(O.id))}}});const u=t.filter(S=>!c.has(S.id)),d=new _N.graphlib.Graph;d.setGraph({rankdir:i?"TB":"LR",edgesep:i?zo:of,nodesep:i?zo:of,ranksep:i?of:zo}),d.setDefaultEdgeLabel(()=>({})),u.forEach(S=>{const E=S.width||Ze,x=S.height||Ze;d.setNode(S.id,{width:E,height:x,x:S.position.x,y:S.position.y})}),a.forEach(S=>{const E=Ze+S.childIds.length*(Ze+Ps);d.setNode(S.parentId,{width:Ze,height:E})}),l.forEach(S=>{const E=Math.max(Ze,S.childIds.length*Ze+(S.childIds.length-1)*zo),x=Ze+Ps+Ze;d.setNode(S.parentId,{width:E,height:x})}),e.forEach(S=>{const E=[...a,...l],x=E.some(F=>F.parentId===S.source||F.childIds.includes(S.source)),O=E.some(F=>F.parentId===S.target||F.childIds.includes(S.target));if(x&&O){const F=E.find(P=>P.parentId===S.source||P.childIds.includes(S.source)),N=E.find(P=>P.parentId===S.target||P.childIds.includes(S.target));if(F===N)return}let A=S.source,T=S.target;const B=E.find(F=>F.childIds.includes(S.source));B&&(A=B.parentId);const I=E.find(F=>F.childIds.includes(S.target));I&&(T=I.parentId),d.hasNode(A)&&d.hasNode(T)&&d.setEdge(A,T)}),_N.layout(d);const f=[],p=[],m=[],v=[];u.forEach(S=>{if(d.hasNode(S.id)){const E=d.node(S.id);if(!E||typeof E.x!="number"||typeof E.y!="number"){console.warn(`Invalid layout data for regular node ${S.id}:`,E);return}const x={x:E.x-(E.width||Ze)/2,y:E.y-(E.height||Ze)/2,width:E.width||Ze,height:E.height||Ze};p.push({id:S.id,boundingBox:x}),m.push(x.y),v.push(x.x),f.push({id:S.id,x:x.x,y:x.y,width:x.width,height:x.height})}}),a.forEach(S=>{if(d.hasNode(S.parentId)){const E=d.node(S.parentId);if(!E||typeof E.x!="number"||typeof E.y!="number"){console.warn(`Invalid layout data for vertical group ${S.parentId}:`,E);return}const x=E.x,O=E.y,A=E.width||Ze,T=E.height||Ze,B=t.find(M=>M.id===S.parentId),I=t.filter(M=>S.childIds.includes(M.id));if(!B)return;const F=x-A/2,N=O-T/2,P={x:F,y:N,width:Ze,height:Ze};p.push({id:S.parentId,boundingBox:P}),m.push(P.y),v.push(P.x),f.push({id:S.parentId,x:P.x,y:P.y,width:P.width,height:P.height}),I.forEach((M,z)=>{const H=P.y+(z+1)*(Ze+Ps),R={x:P.x,y:H,width:Ze,height:Ze};p.push({id:M.id,boundingBox:R}),m.push(R.y),v.push(R.x),f.push({id:M.id,x:R.x,y:R.y,width:R.width,height:R.height})})}}),l.forEach(S=>{if(d.hasNode(S.parentId)){const E=d.node(S.parentId);if(!E||typeof E.x!="number"||typeof E.y!="number"){console.warn(`Invalid layout data for horizontal group ${S.parentId}:`,E);return}const x=E.x,O=E.y,A=E.width||Ze,T=E.height||Ze,B=t.find(R=>R.id===S.parentId),I=t.filter(R=>S.childIds.includes(R.id));if(!B)return;const F=x-A/2,N=O-T/2,P={x:F+(A-Ze)/2,y:N,width:Ze,height:Ze};p.push({id:S.parentId,boundingBox:P}),m.push(P.y),v.push(P.x),f.push({id:S.parentId,x:P.x,y:P.y,width:P.width,height:P.height});const M=P.y+Ze+Ps,z=I.length*Ze+(I.length-1)*zo,H=F+(A-z)/2;I.forEach((R,Y)=>{const $={x:H+Y*(Ze+zo),y:M,width:Ze,height:Ze};p.push({id:R.id,boundingBox:$}),m.push($.y),v.push($.x),f.push({id:R.id,x:$.x,y:$.y,width:$.width,height:$.height})})}});const b=20;function w(S,E){return Math.round(S/E)*E}[...new Set(m.map(S=>w(S,b)))].sort((S,E)=>S-E),[...new Set(v.map(S=>w(S,b)))].sort((S,E)=>S-E);const g=f.map(S=>{const E=a.some(O=>O.childIds.includes(S.id)),x=l.some(O=>O.childIds.includes(S.id));if(E){const O=a.find(T=>T.childIds.includes(S.id)),A=f.find(T=>T.id===(O==null?void 0:O.parentId));if(A)return{...S,x:w(A.x,b),y:w(S.y,b)}}return x?{...S,x:w(S.x,b),y:w(S.y,b)}:{...S,x:w(S.x,b),y:w(S.y,b)}}),C=p.length>0?ON(p.map(S=>S.boundingBox)):{x:0,y:0,width:0,height:0},k={x:C.x-r.x,y:C.y-r.y},_=g.map(S=>({...S,x:S.x-k.x,y:S.y-k.y}));return{boundingBox:C,nodes:_}}function fQ(t){if(t.length===0)return{x:0,y:0,width:0,height:0};const e=t.map(n=>({x:n.position.x,y:n.position.y,width:n.width||Ze,height:n.height||Ze}));return ON(e)}function ON(t){if(t.length===0)return{x:0,y:0,width:0,height:0};const{minX:e,minY:n,maxX:r,maxY:o}=t.reduce((i,s)=>{const{x:a,y:l,width:c,height:u}=s;return{minX:Math.min(i.minX,a),maxX:Math.max(i.maxX,a+c),minY:Math.min(i.minY,l),maxY:Math.max(i.maxY,l+u)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return{x:e,y:n,width:r-e,height:o-n}}const TN=t=>{const{getNodes:e,getEdges:n,fitView:r,setNodes:o}=ne.useReactFlow(),i=y.useCallback((l=Wd.ALL,c=!1)=>{const u=e(),d=n(),f=l==="selection"?u.filter(v=>v.selected):u;if(f.length===0)return console.log("没有节点需要布局"),{boundingBox:{x:0,y:0,width:0,height:0},nodes:[]};const p=dQ(f,d),m=u.map(v=>{const b=p.nodes.find(w=>w.id===v.id);return b?{...v,position:{x:b.x,y:b.y}}:v});return o(m),c&&setTimeout(()=>{r({padding:.1,includeHiddenNodes:!1,duration:200})},10),p},[e,n,o,r]),s=y.useCallback((l=!1)=>i(Wd.ALL,l),[i]),a=y.useCallback((l=!1)=>i(Wd.SELECTION,l),[i]);return{layout:i,autoLayout:s,layoutSelection:a}},hQ={HORIZONTAL_GAP:zo+100,VERTICAL_SPACING:of,INITIAL_X:100,MAIN_NODE_Y:300,X_PROXIMITY_THRESHOLD:50};function NN(t,e=hQ){const o=AO(t)==="vertical",i=t.filter(u=>!VR(u));if(o){const u=i.length>0?Math.max(...i.map(m=>m.position.y)):0,d=i[i.length-1],f=(d==null?void 0:d.position.x)??e.INITIAL_X,p=u+e.HORIZONTAL_GAP+Ze;return[f,p]}let s;i.length>0?s=Math.max(...i.map(d=>d.position.x))+e.HORIZONTAL_GAP:s=e.INITIAL_X;const a=e.MAIN_NODE_Y,c=t.filter(u=>Math.abs(u.position.x-s)<e.X_PROXIMITY_THRESHOLD).length*e.VERTICAL_SPACING;return[s,a+c]}const BN=()=>new Date().toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",second:"2-digit"});function pQ(t){if(t==null||t==="")return;const e=Number(t);return Number.isFinite(e)?e:void 0}function Mb(t){const e=t==null?void 0:t.data;if(!e)return null;const n=e.action_key??e.actionKey??e.nodeKey??e.node_key;if(typeof n!="string"||!n.trim())return null;const r=pQ(e.action_ver??e.nodeVersion??e.node_version),o=Wi(n.trim(),r);return o?RI(o,e):null}function Nl(t){return!!(t&&po(t.data))}function FN({sourceNode:t,targetNode:e,sourceHandle:n,targetHandle:r,edges:o=[]}){const i=Nl(t),s=Nl(e);if(!i&&!s)return{applicable:!1,valid:!0,code:"NOT_APPLICABLE",reason:""};const a=i?Mb(t):null,l=s?Mb(e):null;if(i&&!a||s&&!l)return{applicable:!0,valid:!1,code:"SCHEMA_NOT_READY",reason:"节点端口 Schema 尚未就绪,请稍后重试",missingSchemaNodeIds:[i&&!a?t==null?void 0:t.id:null,s&&!l?e==null?void 0:e.id:null].filter(d=>!!d)};const c=mR({sourceNode:t,targetNode:e,sourceHandle:n,targetHandle:r,sourcePorts:(a==null?void 0:a.outputs)??(n?[{name:n,type:"main",protocol:"main"}]:[]),targetPorts:(l==null?void 0:l.inputs)??(r?[{name:r,type:"main",protocol:"main"}]:[]),edges:o});return{applicable:!0,valid:c.valid,code:c.code,reason:c.reason}}function mQ({edge:t,nodes:e,edges:n,connectable:r,validators:o=[],nativeIsValidConnection:i}){const s=e.find(c=>c.id===t.source),a=e.find(c=>c.id===t.target);if((r==null?void 0:r.enabled)===!0){const c=FN({sourceNode:s,targetNode:a,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle,edges:n});if(c.applicable&&!c.valid)return r.debug&&console.warn("[workflow:connectable] reject canvas connection",{edge:t,code:c.code,reason:c.reason}),!1}const l={nodes:e.reduce((c,u)=>{var d;return c[u.id]={id:u.id,type:u.type||"",position:u.position,data:u.data,disabled:((d=u.data)==null?void 0:d.closed)==="1"},c},{}),edges:n.map(c=>({id:c.id,source:c.source,target:c.target,sourceHandle:c.sourceHandle,targetHandle:c.targetHandle,data:c.data}))};try{return!(!o.every(c=>c(t,l))||i&&!i(t))}catch(c){return console.error("边校验函数执行异常",c),!1}}function gQ(t,e){var kr,vn,un,Hn;const{workflowId:n,onInit:r}=t,o=Ms(),{setLocked:i,op_status:s}=ao(),a=Ot(),[l,c]=y.useState(!1),[u,d]=y.useState(!1),f=$t(),p=ne.useReactFlow(),{autoLayout:m}=TN(),[v,b]=y.useState(!0),w=Ah(na()),g=s===er.ONLINE||s===er.ON_WARN,C=y.useMemo(()=>!w&&f.canvas.miniMap,[w,f.canvas.miniMap]),k=y.useMemo(()=>!w&&f.canvas.controls,[w,f.canvas.controls]),_=y.useMemo(()=>!w&&f.canvas.header,[f.canvas.header,w]),S=y.useMemo(()=>{var Oe;return(Oe=f.canvas.grid)==null?void 0:Oe.enabled},[(kr=f.canvas.grid)==null?void 0:kr.enabled]),E=y.useMemo(()=>a&&!w&&f.canvas.fastOperationButtons,[a,w,f.canvas.fastOperationButtons]);kJ({enabled:!w&&l});const x=w||v||!a,O=y.useCallback(Oe=>{requestAnimationFrame(()=>{const Me=p.getNode(Oe);Me&&p.fitView({nodes:[Me],padding:.4,duration:300,maxZoom:1})})},[p]),[A,T]=y.useState($n.IDLE),[B,I]=y.useState(""),{setFlowOpStatusAction:F,setNodeConfigVisible:N}=ao(n),{addNodes:P,addEdges:M}=aa(),{removeEdges:z,onConnect:H,handleEdgesChange:R}=Pw(),Y=ne.useStoreApi(),te=Is(Oe=>Oe.workflow.refreshWorkFlowNum),[$,j]=ne.useNodesState([]),[U,ee]=ne.useEdgesState([]),[ie,be]=y.useState(null),W=y.useCallback(Oe=>{var Ye;let Me=null;for(const Xe of Oe)if(Oh(Xe)){Me={id:Xe.id,isMcpServer:Xe.type.startsWith(`${Gd}@`)||((Ye=Xe.data)==null?void 0:Ye.action_key)===Gd};break}be(Xe=>(Xe==null?void 0:Xe.id)===(Me==null?void 0:Me.id)&&(Xe==null?void 0:Xe.isMcpServer)===(Me==null?void 0:Me.isMcpServer)?Xe:Me)},[]),X=y.useCallback(Oe=>{if(typeof Oe=="function"){j(Me=>{const Ye=Oe(Me);return W(Ye),Ye});return}j(Oe),W(Oe)},[j,W]),[q,J]=y.useState(void 0),[re,Z]=y.useState(void 0),ue=y.useCallback(Oe=>{var Sr,Uo;if(!Oe)return!0;const Me=(Sr=f.canvas)==null?void 0:Sr.selectable;if(!Me)return!0;const{includeNodeIds:Ye,includeCategories:Xe}=Me;if((!Ye||Ye.length===0)&&(!Xe||Xe.length===0))return!0;const Vn=Y.getState().nodes.find(Ul=>Ul.id===Oe);if(!Vn)return!0;const Wo=(Uo=Vn.data)==null?void 0:Uo.category;return!!(Ye&&Ye.includes(Oe)||Xe&&Wo&&Xe.includes(Wo))},[(vn=f.canvas)==null?void 0:vn.selectable,Y]),ve=y.useCallback((Oe,Me)=>{if(J(void 0),Z(void 0),Oe.length===1&&Oe[0].type==="position"&&Oe[0].dragging&&Oe[0].position){const Ye=CJ(Oe[0],Me);Oe[0].position.x=Ye.snapPosition.x??Oe[0].position.x,Oe[0].position.y=Ye.snapPosition.y??Oe[0].position.y,J(Ye.horizontal),Z(Ye.vertical)}return Oe},[]),we=y.useCallback(Oe=>{R(Oe),Oe.some(Ye=>!["select","replace"].includes(Ye.type))&&c(!0)},[R]),fe=y.useCallback(Oe=>{const Me=Y.getState().nodes,Ye=Oe.map(et=>et.type==="position"&&!ue(et.id)?null:et.type==="select"&&!ue(et.id)?{...et,selected:!1}:et).filter(et=>et!==null);ve(Ye,Me);const Xe=fa(Me,et=>{const Vn=ne.applyNodeChanges(Ye,et);et.splice(0,Vn.length,...Vn),et.splice(Vn.length)});X(Xe),Ye.some(et=>(et==null?void 0:et.type)==="dimensions"&&et.resizing?!0:!["select","replace","dimensions"].includes(et==null?void 0:et.type))&&c(!0)},[ue,X,Y,ve]),{onEdgeMouseEnter:le,onEdgeMouseLeave:Se}=Pw(),{onNodeMouseEnter:ce,onNodeMouseLeave:Fe,autoSaveNum:Ve}=cw(),je=y.useCallback((Oe,Me)=>{T(Oe),Oe===$n.SAVED?I(BN()):Oe===$n.ERROR&&Me&&console.error("保存失败:",Me)},[]),{setNodeAddCallback:We,openNodeSelector:ht,handleManualAdd:Ee}=dc();Et.useUnmount(()=>{o(Mw()),ee([]),X([])});const Ce=y.useRef(async()=>{}),Le=y.useCallback(Oe=>{var Xe;if(Oe.defaultPrevented)return;const Me=Oe.target,Ye=(Xe=Me==null?void 0:Me.tagName)==null?void 0:Xe.toLowerCase();Ye==="input"||Ye==="textarea"||Me!=null&&Me.isContentEditable||Oe.altKey&&Oe.shiftKey&&Oe.code==="KeyD"&&(Oe.preventDefault(),d(et=>!et))},[]);y.useEffect(()=>(window.addEventListener("keydown",Le),()=>{window.removeEventListener("keydown",Le)}),[Le]);const Mt=f.canvas.nativeProps||{},{isValidConnection:St,onNodeContextMenu:jr,onPaneContextMenu:lo,...Ws}=Mt,co=y.useCallback((Oe,Me,Ye)=>{var Xe,et;return mQ({edge:Oe,nodes:Me,edges:Ye,connectable:(Xe=f.nodeSelector)==null?void 0:Xe.connectable,validators:(et=f.edgeRules)==null?void 0:et.validators,nativeIsValidConnection:St})},[(un=f.edgeRules)==null?void 0:un.validators,(Hn=f.nodeSelector)==null?void 0:Hn.connectable,St]),jo=y.useCallback(Oe=>{const{nodes:Me,edges:Ye}=Y.getState();return co(Oe,Me,Ye)},[Y,co]),Us=y.useCallback(Oe=>{!Oe.source||!Oe.target||(H(Oe),c(!0))},[H,Y]),Df=y.useCallback((Oe,Me)=>{f.edgeRules&&f.edgeRules.allowAddNodeOnEdge===!1||ht({position:Oe,edge:Me})},[ht,f.edgeRules]),uv=y.useCallback(Oe=>{const{protocol:Me}=Oe||{},{nodes:Ye}=Y.getState();if(ie){const Xe=NN(Ye);ht({position:{x:Xe[0],y:Xe[1]},protocol:Me})}else ht({trigger:!0,protocol:Me})},[ht,Y,ie]),dv=y.useCallback(()=>{const{nodes:Oe}=Y.getState();let Me;const Ye=Oe.find(Xe=>Xe.selected&&Xe.type!==pe.STICKY);Ye?Me=[Ye.position.x,Ye.position.y-80]:Me=NN(Oe),Ee({position:{x:Me[0],y:Me[1]}},{action_type:pe.STICKY,type:pe.STICKY,id:e,nodeId:e,name:"便签",action_name:"便签",connector_name:"",description:""})},[Ee,e,Y]),fv=y.useCallback(()=>{m()},[m]),{canvasApi:It}=yJ({workflowId:n,dispatch:o,reactFlow:p,setEdges:ee,setNodes:X,store:Y,setNodeConfigVisible:N,saveFlowRef:Ce});y.useEffect(()=>{r&&r(It)},[r,It]);const wn=y.useCallback((Oe,Me)=>{Oe.ctrlKey&&Oe.preventDefault(),jr==null||jr(Oe,Me)},[jr]),bn=y.useCallback(Oe=>{Oe.ctrlKey&&Oe.preventDefault(),lo==null||lo(Oe)},[lo]);return{nodes:$,edges:U,setNodes:X,setEdges:ee,unSave:l,setUnSave:c,triggerNode:ie,hasTriggerNode:ie!==null,isMcpServerCanvas:(ie==null?void 0:ie.isMcpServer)??!1,loading:v,setLoading:b,debugVisible:u,setDebugVisible:d,autoSaveStatus:A,lastSavedTime:B,helperLineHorizontal:q,helperLineVertical:re,isPreviewMode:w,isInteractionDisabled:x,isOnline:g,showMiniMap:C,showControls:k,showCanvasHeader:_,showBackground:S,showFastOperationButtons:E,onNodesChange:fe,handleEdgesChange:we,handleConnect:Us,isValidConnection:jo,validateConnectionAgainstSnapshot:co,handleEdgeAddNode:Df,handleOpenNodeSelector:uv,handleAddNoteNode:dv,handleTidy:fv,onEdgeMouseEnter:le,onEdgeMouseLeave:Se,onNodeMouseEnter:ce,onNodeMouseLeave:Fe,onNodeContextMenu:wn,onPaneContextMenu:bn,updateSaveStatus:je,setNodeFitHumanView:O,canvasApi:It,reactFlow:p,dispatch:o,store:Y,refreshWorkFlowNum:te,addNodes:P,addEdges:M,removeEdges:z,setNodeAddCallback:We,setNodeConfigVisible:N,setFlowOpStatusAction:F,autoSaveNum:Ve,setLocked:i,openNodeSelector:ht,handleManualAdd:Ee,restNativeProps:Ws,saveFlowRef:Ce}}const wQ=(t,e="normal")=>{var o;if(t.type===pe.STICKY)return e==="lighter"?"rgba(0,0,0,.5)":"rgb(206, 226, 164)";switch((o=t.data)==null?void 0:o.status){case me.INVALID:return e==="lighter"?"#F2C000":"#FDF6D5";case me.FAILED:return e==="lighter"?"#FA170A":"#FF918B";case me.SUCCESS:case me.RUNNABLE:return e==="lighter"?"#2EC04F":"#8CDF3A";case me.RUNNING:return e==="lighter"?"#007AFF":"#D9EBFF";default:return e==="lighter"?"#51A4F6":"#00c3ff"}};function bQ(t){const e=n=>wQ(n);return h.jsx(ne.MiniMap,{style:{display:"flex",flexDirection:"row"},nodeStrokeColor:e,nodeStrokeWidth:3,pannable:!0,zoomable:!0,nodeColor:e,nodeBorderRadius:3,...t})}const vQ=200,sf=150,Bl=44,MN=t=>{try{return JSON.stringify(t)}catch(e){return String(e)}},Ib=t=>({id:t.id,type:t.type,position:t.position,data:t.data}),Pb=t=>({id:t.id,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle,data:t.data}),Bi=t=>{if(!t)return"";const e=t.data,n=(e==null?void 0:e.backendData)||void 0,r=(n==null?void 0:n.properties)||void 0;return(r==null?void 0:r.display_name)||(e==null?void 0:e.label)||(e==null?void 0:e.action_name)||(e==null?void 0:e.name)||t.id},yQ=t=>t.replace(/[^a-zA-Z0-9_]/g,"_"),CQ=(t,e,n,r)=>{const o=new Map;t.forEach((l,c)=>{const u=yQ(l.id||`node_${c}`);o.set(l.id,u)});const i=["flowchart LR"];t.forEach(l=>{const c=o.get(l.id);if(!c)return;const u=`${l.id} ${Bi(l)}`.replace(/"/g,"'");i.push(` ${c}["${u}"]`)});const s=[];let a=0;return e.forEach(l=>{const c=o.get(l.source),u=o.get(l.target);!c||!u||(i.push(` ${c} --> ${u}`),r.has(l.id)&&s.push(a),a+=1)}),s.forEach(l=>{i.push(` linkStyle ${l} stroke:#cf1322,stroke-width:2px`)}),i.join(`
|
|
138
|
+
${WX(_)} ${m} ${(a==null?void 0:a.renderType)??""}`.replace(/\s+/g," ").trim(),X=re=>{var fe,le;if(re.stopPropagation(),A&&A.allowAddNodeOnEdge===!1)return;const Z=w(),ue=(fe=O.canvas.limits)==null?void 0:fe.maxNodes;if(typeof ue=="number"&&Z.length>=ue){D.message.warning("已达到画布允许的最大节点数");return}const ve={x:(e+T)/2,y:(n+B)/2};g({position:ve,edge:{id:t,source:l,sourceHandleId:c,target:u,targetHandleId:d,data:a},targetNode:Pt.cloneDeep(E),sourceNode:Pt.cloneDeep(C),protocol:`${((le=C.data)==null?void 0:le.protocol)??""}`})},q=re=>{re.stopPropagation(),j&&(b([t]),Wy(v,[t]))},J=[h.jsx("path",{id:t,className:W,d:U,style:be,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",markerEnd:"url(#workflow-arrow)"},`${t}-path`),S&&($||j)?h.jsx(ne.EdgeLabelRenderer,{children:h.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${ee}px,${ie}px)`,padding:"4px",borderRadius:"8px",opacity:a!=null&&a.isHovered?1:0,gap:"8px",zIndex:1e3,pointerEvents:"all"},className:"nodrag nopan workflow-edge-buttons",children:[$&&h.jsx("button",{type:"button",onClick:X,style:{...ta.default,...ta.add},className:"workflow-edge-button",title:"添加节点","aria-label":"添加节点",children:h.jsx(se.PlusOutlined,{style:{fontSize:"12px"}})}),j&&h.jsx("button",{type:"button",onClick:q,style:{...ta.default,...ta.delete},className:"workflow-edge-button",title:"删除连线","aria-label":"删除连线",children:h.jsx(se.CloseOutlined,{style:{fontSize:"12px"}})})]})},`${t}-buttons`):null];return a!=null&&a.label&&J.push(h.jsx(ne.EdgeLabelRenderer,{children:h.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${ee}px,${ie+(z?20:0)}px)`,...Xy.edge},children:a.label})},`${t}-label`)),J};class $o{static getEdgeTypes(){return{[fo.MAIN]:RX}}static getEdgeComponent(e){const n=$o.getEdgeTypes();return n[e]||n[fo.MAIN]}static createEdge(e,n,r,o,i){let s={},a,l,c;if(i&&typeof i=="object"&&("sourceHandle"in i||"targetHandle"in i||"onAddNode"in i)){const u=i;a=u.sourceHandle,l=u.targetHandle,c=u.onAddNode,s=u.data||{}}return{id:n,type:e,source:r,target:o,sourceHandle:a,targetHandle:l,data:{...s,className:"workflow-main-edge",onAddNode:c},markerEnd:{type:ne.MarkerType.ArrowClosed,width:20,height:20,color:"#7e8186"},style:{stroke:"#7e8186",strokeWidth:1},className:"workflow-main-edge"}}}const KX=new Set(["type","action_type","action_id","action_key","action_ver","nodeKey","nodeVersion","node_type","label","action_name","name","description","icon","connector_name","connector_id","deployment_type","nodeIcon","category","config_schema","properties","params","status","protocol","closed","disabled","note","connector_id","n_id","account_id","account_schema_id","backendData","isHovered","output","outputSource","isAction","saveType"]),YX=t=>{const e={};for(const[n,r]of Object.entries(t))KX.has(n)&&(e[n]=r);return{label:t.action_name,description:t.connector_name,...t.action_key?{nodeKey:t.action_key}:{},...t.action_ver!==void 0?{nodeVersion:t.action_ver}:{},...e}},XX=$o.getEdgeTypes(),JX={"--edge-marker-size":"14px","--edge-stroke-width":"1px"},QX={x:0,y:0,zoom:1},ZX={x:0,y:0,zoom:.8},eJ={type:fo.MAIN,markerEnd:{type:ne.MarkerType.ArrowClosed,width:20,height:20,color:"#7e8186"}},tJ="944";function nJ(t,e,n=""){const r=t.map(o=>{const{config_schema:i,config:s,params:a,node_schema:l,nodeSchema:c,...u}=o.data??{},{id:d,position:f,type:p}=o;return{...u,id:d,node_type:p,position:f,connector_id:u.connector_id||"",action_id:u.action_id||u.id||"",account_id:u.account_id||null,properties:i||s||{},action_name:u.label||"",description:u.description||""}});return{name:n,connections:e,nodes:r}}const rJ=({nodes:t,edges:e,workflowName:n,workflowId:r,executionControl:o,metadata:i={}})=>{const s=nJ(t,e,n),{nodes:a,connections:l,version_no:c,...u}=i;return{...u,...s,id:r,...o?{execution_control:o}:{}}};class ST extends Error{constructor(e,n){super(n||e||"连接流加载失败"),this.code=e,this.description=n,this.name="FlowLoadError"}}const oJ=({onOpenNodeSelector:t,onAddNoteNode:e,onTidyCanvas:n,panelStyle:r={},buttonStyle:o={},dangerButtonStyle:i={},showTidyButton:s=!0,buttons:a})=>{const l=[{key:"add-node",title:"添加节点",icon:h.jsx(se.PlusOutlined,{}),onClick:p=>{p.stopPropagation(),t==null||t()},visible:!0,danger:!1,type:"default"},{key:"add-note",title:"添加便签",icon:h.jsx(se.BookOutlined,{}),onClick:e,visible:!0,danger:!1,type:"default"}],c=a||l,u={background:"transparent",boxShadow:"none",...r},d={width:"auto",height:29,fontSize:11,...o},f={...d,...i};return h.jsx(ne.Panel,{position:"top-right",style:u,children:h.jsx(D.Space,{direction:"horizontal",children:c.map(p=>p.visible===!1?null:h.jsx(D.Button,{onClick:p.onClick,"aria-label":p.title,type:p.type,color:p.color,style:p.danger?f:d,size:"small",danger:p.danger,icon:p.icon,children:p.title},p.key))})})},iJ=y.memo(({loading:t,error:e,onRetry:n})=>!t&&!e?null:h.jsx("div",{className:`workflow-fullscreen-loading${e?" is-error":""}`,role:e?"alert":"status","aria-live":"polite",children:h.jsxs("div",{className:"workflow-fullscreen-loading__card",children:[e?h.jsx(se.WarningOutlined,{className:"workflow-fullscreen-loading__error-icon"}):h.jsx(D.Spin,{}),h.jsxs("div",{className:"workflow-fullscreen-loading__copy",children:[h.jsx("strong",{children:e?"连接流加载失败":"正在同步工作流"}),h.jsx("span",{children:e?e.description||"无法获取连接流数据,请检查网络或稍后重试。":"正在获取节点、连线与运行配置,请稍候。"}),e!=null&&e.code?h.jsxs("span",{className:"workflow-fullscreen-loading__error-code",children:["错误码:",e.code]}):null]}),e&&n?h.jsx(D.Button,{icon:h.jsx(se.ReloadOutlined,{}),onClick:n,children:"重新加载"}):null]})})),sJ=y.memo(()=>h.jsx("svg",{style:{position:"absolute",width:0,height:0},children:h.jsx("defs",{children:h.jsx("marker",{id:"workflow-arrow",viewBox:"-10 -10 20 20",refX:"3",refY:"0",markerWidth:"12.5",markerHeight:"12.5",markerUnits:"strokeWidth",orient:"auto-start-reverse",children:h.jsx("polyline",{strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4",strokeWidth:"3",stroke:"context-stroke",fill:"context-stroke"})})})})),aJ={width:"100%",height:"100%",position:"absolute",zIndex:10,pointerEvents:"none"},lJ=t=>({width:t.width,height:t.height,transform:t.transform});function cJ({horizontal:t,vertical:e}){const{width:n,height:r,transform:o}=ne.useStore(lJ),i=y.useRef(null);return y.useEffect(()=>{const s=i.current,a=s==null?void 0:s.getContext("2d");if(!a||!s)return;const l=window.devicePixelRatio;s.width=n*l,s.height=r*l,a.scale(l,l),a.clearRect(0,0,n,r),a.strokeStyle="#0041d0",typeof e=="number"&&(a.moveTo(e*o[2]+o[0],0),a.lineTo(e*o[2]+o[0],r),a.stroke()),typeof t=="number"&&(a.moveTo(0,t*o[2]+o[1]),a.lineTo(n,t*o[2]+o[1]),a.stroke())},[n,r,o,t,e]),h.jsx("canvas",{ref:i,className:"react-flow__canvas",style:aJ})}const uJ=y.memo(cJ);function dJ(t){return t.map(e=>{const{node_type:n,id:r,position:o,icon:i,action_name:s,connector_name:a,description:l,action_id:c,connector_id:u,properties:d,account_schema_id:f,account_id:p,action_key:m,action_ver:v,node_schema:b,nodeSchema:w,...g}=e;let C,k;if(n===pe.STICKY)try{const S=JSON.parse(d.value);C=S.width,k=S.height}catch{}const _={type:n,id:r,position:o,data:{icon:i,label:s,action_name:s,description:l,connector_name:a,connector_id:u,account_id:p,account_schema_id:f,action_id:c,action_key:m,action_ver:v,node_type:n,nodeKey:m||g.nodeKey,nodeVersion:v??g.nodeVersion,params:g.params||d,config_schema:d,...g}};if(typeof C=="number"||typeof k=="number"){const S=_.style||{};_.style={...S,...typeof C=="number"?{width:C}:{},...typeof k=="number"?{height:k}:{}}}return _})}function ET(t){if(!t)return console.error("API返回数据格式错误: 缺少data字段"),{workflowId:"",workflowName:"",nodes:[],edges:[]};const e=dJ(t.nodes||[]),n=e.map(o=>o.id),r=(t.connections||[]).map(o=>({...o,type:o.type||"main"})).filter(o=>n.includes(o.target)&&o.source&&o.sourceHandle&&o.targetHandle);return{workflowId:t.id||"",workflowName:t.name||"",nodes:e,edges:r}}const xT=1;async function fJ(t){const e=[],n=new Set,r=t.filter(o=>o.data&&!(parseInt(`${o.data.action_id}`,10)>0));for(const o of r){const i=o.data??{},s=typeof i.action_key=="string"?i.action_key:typeof i.nodeKey=="string"?i.nodeKey:"";if(!s)continue;const a=i.action_ver??i.nodeVersion,c=a==null||a===""?xT:Number(a),u=Number.isFinite(c)?c:xT,d=`${s}@${u}`;n.has(d)||(n.add(d),e.push(pc(s,u).catch(()=>null)))}e.length!==0&&await Promise.all(e)}async function hJ(t){const n=t.filter(r=>(r==null?void 0:r.data)&&!(parseInt(`${r.data.action_id}`,10)>0)).map(r=>{const o=r.data??{};return wT({...o,node_type:r.type})});await Promise.all(n)}function pJ(t){const{nodes:e,edges:n,workflowName:r}=ET(t);return{nodes:e,edges:n,name:r||"",opStatus:t==null?void 0:t.op_status,executionControl:(t==null?void 0:t.execution_control)??null,metadata:t}}function mJ(t){const{workflowId:e,strategy:n,setNodes:r,setEdges:o,fitView:i,setLoading:s,dispatch:a,setFlowOpStatusAction:l,refreshWorkFlowNum:c,onLoad:u}=t,[d,f]=y.useState(null),[p,m]=y.useState(0),v=y.useCallback(()=>{m(w=>w+1)},[]),b=y.useRef(u);return b.current=u,y.useEffect(()=>{if(!e)return;let w=!1;return s(!0),f(null),(async()=>{var g;try{const k=await(b.current?b.current(e).then(pJ):n.loadFlow(e));if(w)return;a(Tl(k.name)),a(CT(k.executionControl??null)),a($X(k.metadata??{})),k.opStatus&&l(k.opStatus);const{nodes:_,edges:S}=k,E=_.map(T=>{var B,I;if((B=T==null?void 0:T.data)!=null&&B.action_id&&parseInt(`${(I=T==null?void 0:T.data)==null?void 0:I.action_id}`,10)<1){const F=ia(T.data.action_key,T.data.action_ver);return{...T,type:F,data:{...T.data,saveType:T.type,isNodePackage:!0}}}return T});n.requiresTriggerNode&&i({minZoom:.3,maxZoom:1});const O=S.filter(T=>T.sourceHandle==="loop").map(T=>T.id),A=S.map(T=>O.includes(T.id)?{...T,data:{...T.data,renderType:"loop",connectionType:T.type}}:T);if(await fJ(E),await hJ(E),w)return;r(E),o(A)}catch(C){if(w)return;if((g=C==null?void 0:C.response)!=null&&g.data){const k=C.response.data;f({code:(k==null?void 0:k.error)??"",description:(k==null?void 0:k.error_description)??""})}else C instanceof ST?f({code:C.code,description:C.description}):f({description:C instanceof Error&&C.message?C.message:"无法获取连接流数据,请检查网络或稍后重试。"});r([]),o([])}finally{w||s(!1)}})(),()=>{w=!0}},[e,n,a,i,o,r,l,s,c,p]),{loadError:d,retry:v}}function gJ(t){const e=t.backendActionId??t.action_id??t.id;return String(e)}const $w="[workflow:node-add]";function wJ({workflowId:t,strategy:e,store:n,addNodes:r,addEdges:o,removeEdges:i,updateEdge:s,setNodeAddCallback:a,handleEdgeAddNode:l,setNodeConfigVisible:c,setNodeFitHumanView:u,validateConnectionAgainstSnapshot:d,saveFlow:f}){var k,_,S,E;const p=$t(),m=Te.useIntl(),v=((_=(k=p.nodeSelector)==null?void 0:k.connectable)==null?void 0:_.enabled)===!0,b=((E=(S=p.nodeSelector)==null?void 0:S.connectable)==null?void 0:E.debug)===!0,w=y.useCallback((x,O)=>{D.message.warning(m.formatMessage({id:x}))},[m]),g=y.useCallback(x=>{!b||Number(x.compatibleCount)<=1},[b]),C=y.useCallback(async(x,O)=>{var X,q,J,re,Z,ue,ve;if(!t)return;let A=null;const{nodes:T}=n.getState(),B=e.convertNodeData??YX,I=O.action_key||O.nodeKey,F=O.action_ver??O.nodeVersion,N=gJ(O),P=po(O),M=O.type===pe.STICKY,z=P&&!M?ia(O.action_key,O.action_ver):x.trigger?pe.TRIGGER:O.action_type,H=x.trigger?pe.TRIGGER:O.action_type;let R=null;if(x.edge&&x.sourceNode){const we=x.sourceNode.position;R={x:we.x+(((q=(X=x.sourceNode)==null?void 0:X.measured)==null?void 0:q.width)||220)+60,y:we.y}}const Y=(R||x.position)??{x:100,y:250},{nodeId:te,nodeData:$}=await e.createNode({workflowId:t,nodeType:H,actionId:N,actionKey:I,actionVer:F,configSchema:O.config_schema||{},position:Y,icon:O.icon,name:O.name||O.action_name,connectorName:O.connector_name,nodeVersion:O.nodeVersion,existingNodes:T});A=te,P&&await wT({...O,...$,node_type:z,action_key:I??O.action_key,action_ver:F??O.action_ver});const j=B({...O,...$,node_type:H,saveType:H}),U=Ni.createNode(z,te,j,Y);r([U]),u(te);const{nodes:ee}=n.getState(),ie=ee.some(we=>we.id===U.id)?ee:[...ee,U];if(M){await f();return}const be=AP(U);be.length>0&&o(be);const W=!!x.sourceHandle;if(x.edge){const we=x.edge,fe=we.sourceHandle??we.sourceHandleId??"",le=we.targetHandle??we.targetHandleId??"",Se=T.find(je=>je.id===we.source)??x.sourceNode,ce=T.find(je=>je.id===we.target)??x.targetNode,Fe=[],Ve=Se?sa(Se,fe):null;if(!Ve)console.error("未找到连线的源节点或 handle,保留原线",we);else{const je=hh(U,Ve.protocol,!0,Ve.name);if(!je)console.log("新节点没有协议兼容的输入端口,保留原线");else{const We=mc(ie,{source:we.source,sourceHandle:fe||void 0,target:U.id,targetHandle:je.name});if(!We.valid)console.warn(`${$w} 插入改写旧线校验未通过,保留原线`,{edgeId:we.id,code:We.code,message:We.message});else{const ht=ce?(J=sa(ce,le))==null?void 0:J.protocol:null,Ee=ht?hh(U,ht,!1,le??void 0):null;if(s(we.id,{target:U.id,targetHandle:je.name}),Ee){const Ce=mc(ie,{source:U.id,sourceHandle:Ee.name,target:we.target,targetHandle:le||void 0});Ce.valid?Fe.push($o.createEdge(fo.MAIN,`${U.id}-${we.target}-${Date.now()}`,U.id,we.target,{sourceHandle:Ee.name,targetHandle:le||void 0,onAddNode:l,data:{renderType:Ee.name}})):console.warn(`${$w} 第二段连线校验未通过,仅改写旧线 target`,{edgeId:we.id,code:Ce.code,message:Ce.message})}else console.log("新节点没有可接回原 target 的 output,仅改写旧线 target",we.id)}}}Fe.length>0&&o(Fe)}else{const we=sa(x.targetNode??x.sourceNode,x.targetHandle??x.sourceHandle);if(we!==null){const fe=hh(U,we.protocol,W,x.targetHandle??x.sourceHandle??void 0);if(fe){const le=fe.name,[Se,ce,Fe,Ve]=W?[((re=x.targetNode)==null?void 0:re.id)||((Z=x.sourceNode)==null?void 0:Z.id),U.id,x.targetHandle||x.sourceHandle,le]:[U.id,((ue=x.targetNode)==null?void 0:ue.id)||((ve=x.sourceNode)==null?void 0:ve.id),le,x.targetHandle||x.sourceHandle],je=mc(ie,{source:Se,target:ce,sourceHandle:Fe,targetHandle:Ve});if(je.valid){const We=$o.createEdge(fo.MAIN,`${Se}-${ce}-${Date.now()}`,Se,ce,{sourceHandle:Fe,targetHandle:Ve,onAddNode:l,data:{renderType:W?Fe:Ve}});o([We])}else console.warn(`${$w} 锚点连线校验未通过,跳过连线`,{code:je.code,message:je.message,source:Se,sourceHandle:Fe,target:ce,targetHandle:Ve})}else console.log("新节点没有协议兼容的端口,不能连接",we.protocol)}else x.trigger||console.error("未找到 handle",x)}u(A),c(A),setTimeout(f,0)},[o,r,v,l,i,g,w,f,c,u,n,e,s,d,t]);y.useEffect(()=>(a(C),()=>{a(()=>{})}),[C,a])}const bJ=t=>async()=>{await t()},vJ=t=>y.useMemo(()=>bJ(t),[t]);function yJ({workflowId:t,dispatch:e,reactFlow:n,setEdges:r,setNodes:o,store:i,setNodeConfigVisible:s,saveFlowRef:a}){const l=y.useRef(new Map);return{canvasApi:y.useMemo(()=>({init(){},destroy(){e(Mw()),r([]),o([]),l.current.clear()},refresh(){e(yT())},setFlowOpStatus(u){e(vT(u))},getData(){const{nodes:u,edges:d}=i.getState();return{nodes:u.map(f=>{var p;return{id:f.id,type:f.type||"",position:f.position,data:f.data,disabled:((p=f.data)==null?void 0:p.closed)==="1"}}),edges:d.map(f=>({id:f.id,source:f.source,target:f.target,data:f.data}))}},setData(u){const d=u.nodes.map(p=>({id:p.id,type:p.type,position:p.position,data:p.data})),f=u.edges.map(p=>({id:p.id,source:p.source,target:p.target,data:p.data}));o(d),r(f)},exportJSON(){return JSON.stringify(this.getData())},importJSON(u){try{const d=typeof u=="string"?JSON.parse(u):u;this.setData(d)}catch(d){console.error("导入 JSON 失败",d)}},zoomIn(){n.zoomIn()},zoomOut(){n.zoomOut()},zoomTo(u){n.zoomTo(u)},fitView(){n.fitView()},center(){n.fitView({padding:.2})},addNode(u){const d=u.id||`${Date.now()}`,f={id:d,type:u.type,position:u.position,data:u.data};return o(p=>[...p,f]),d},updateNode(u,d){o(f=>f.map(p=>p.id===u?{...p,...d,position:d.position||p.position,data:d.data?{...p.data,...d.data}:p.data}:p))},deleteNode(u){o(d=>d.filter(f=>f.id!==u)),r(d=>d.filter(f=>f.source!==u&&f.target!==u))},getNode(u){var p;const{nodes:d}=i.getState(),f=d.find(m=>m.id===u);return f?{id:f.id,type:f.type||"",position:f.position,data:f.data,disabled:((p=f.data)==null?void 0:p.closed)==="1"}:null},selectNode(){},clearSelection(){n.setNodes(u=>u.map(d=>({...d,selected:!1})))},moveNode(u,d){this.updateNode(u,{position:d})},enableNode(u){this.updateNode(u,{disabled:!1})},disableNode(u){this.updateNode(u,{disabled:!0})},addEdge(u){const d=u.id||`${u.source}-${u.target}-${Date.now()}`,f={id:d,source:u.source,target:u.target,data:u.data};return r(p=>[...p,f]),d},deleteEdge(u){r(d=>d.filter(f=>f.id!==u))},deleteEdgesBetween(u,d){r(f=>f.filter(p=>p.source!==u||p.target!==d))},openNodePanel(u){s(u)},closeNodePanel(){s(null)},isPanelOpen(){const{currentNodeConfigVisibleId:u}=i.getState();return!!u},async runNodeTest(){return Promise.resolve(null)},async saveFlow(){return a.current()},on(u,d){return l.current.has(u)||l.current.set(u,new Set),l.current.get(u).add(d),()=>{this.off(u,d)}},off(u,d){const f=l.current.get(u);f&&(d?f.delete(d):f.clear(),f.size===0&&l.current.delete(u))},emit(u,d){const f=l.current.get(u);f&&f.forEach(p=>{try{p(d)}catch(m){console.error(`事件 "${u}" 的处理器执行出错:`,m)}})},once(u,d){const f=p=>{d(p),this.off(u,f)};this.on(u,f)},async refreshFlowVersionStatus(){if(t)try{const u=await qy(t);e(HX(u))}catch(u){console.error("[canvasApi] refreshFlowVersionStatus failed:",u)}}}),[e,n,r,o,i,s,t]),eventListenersRef:l}}function DT(t,e){var o,i;const n=((o=t.measured)==null?void 0:o.width)??0,r=((i=t.measured)==null?void 0:i.height)??0;return{left:e.x,right:e.x+n,top:e.y,bottom:e.y+r,width:n,height:r}}function _T(t,e,n){let r=t;for(const{edge:o,offset:i}of e)for(const s of n){const a={distance:Math.abs(o-s),line:s,snapPosition:s-i};(!r||a.distance<r.distance)&&(r=a)}return r}function CJ(t,e,n=20){const r={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},o=e.find(l=>l.id===t.id);if(!o||!t.position)return r;const i=DT(o,t.position);let s,a;for(const l of e){if(l.id===o.id)continue;const c=DT(l,l.position);s=_T(s,[{edge:i.left,offset:0},{edge:i.right,offset:i.width}],[c.left,c.right]),a=_T(a,[{edge:i.top,offset:0},{edge:i.bottom,offset:i.height}],[c.top,c.bottom])}return{vertical:s==null?void 0:s.line,horizontal:a==null?void 0:a.line,snapPosition:{x:s&&s.distance<n?s.snapPosition:void 0,y:a&&a.distance<n?a.snapPosition:void 0}}}const kJ=({enabled:t=!0,message:e="您有未保存的更改,确定要离开吗?"})=>{y.useEffect(()=>{if(!t)return;let n;return(()=>{n=ac.block(o=>{t?window.confirm(e)&&(n==null||n(),o.retry()):(n==null||n(),o.retry())})})(),()=>{n==null||n()}},[t,e]),y.useEffect(()=>{if(!t)return;const n=r=>{if(t)return r.preventDefault(),r.returnValue=e,e};return window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n)},[t,e])};var zw,AT;function Hw(){if(AT)return zw;AT=1;var t="\0",e="\0",n="";class r{constructor(u){lt(this,"_isDirected",!0);lt(this,"_isMultigraph",!1);lt(this,"_isCompound",!1);lt(this,"_label");lt(this,"_defaultNodeLabelFn",()=>{});lt(this,"_defaultEdgeLabelFn",()=>{});lt(this,"_nodes",{});lt(this,"_in",{});lt(this,"_preds",{});lt(this,"_out",{});lt(this,"_sucs",{});lt(this,"_edgeObjs",{});lt(this,"_edgeLabels",{});lt(this,"_nodeCount",0);lt(this,"_edgeCount",0);lt(this,"_parent");lt(this,"_children");u&&(this._isDirected=Object.hasOwn(u,"directed")?u.directed:!0,this._isMultigraph=Object.hasOwn(u,"multigraph")?u.multigraph:!1,this._isCompound=Object.hasOwn(u,"compound")?u.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[e]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(u){return this._label=u,this}graph(){return this._label}setDefaultNodeLabel(u){return this._defaultNodeLabelFn=u,typeof u!="function"&&(this._defaultNodeLabelFn=()=>u),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var u=this;return this.nodes().filter(d=>Object.keys(u._in[d]).length===0)}sinks(){var u=this;return this.nodes().filter(d=>Object.keys(u._out[d]).length===0)}setNodes(u,d){var f=arguments,p=this;return u.forEach(function(m){f.length>1?p.setNode(m,d):p.setNode(m)}),this}setNode(u,d){return Object.hasOwn(this._nodes,u)?(arguments.length>1&&(this._nodes[u]=d),this):(this._nodes[u]=arguments.length>1?d:this._defaultNodeLabelFn(u),this._isCompound&&(this._parent[u]=e,this._children[u]={},this._children[e][u]=!0),this._in[u]={},this._preds[u]={},this._out[u]={},this._sucs[u]={},++this._nodeCount,this)}node(u){return this._nodes[u]}hasNode(u){return Object.hasOwn(this._nodes,u)}removeNode(u){var d=this;if(Object.hasOwn(this._nodes,u)){var f=p=>d.removeEdge(d._edgeObjs[p]);delete this._nodes[u],this._isCompound&&(this._removeFromParentsChildList(u),delete this._parent[u],this.children(u).forEach(function(p){d.setParent(p)}),delete this._children[u]),Object.keys(this._in[u]).forEach(f),delete this._in[u],delete this._preds[u],Object.keys(this._out[u]).forEach(f),delete this._out[u],delete this._sucs[u],--this._nodeCount}return this}setParent(u,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(d===void 0)d=e;else{d+="";for(var f=d;f!==void 0;f=this.parent(f))if(f===u)throw new Error("Setting "+d+" as parent of "+u+" would create a cycle");this.setNode(d)}return this.setNode(u),this._removeFromParentsChildList(u),this._parent[u]=d,this._children[d][u]=!0,this}_removeFromParentsChildList(u){delete this._children[this._parent[u]][u]}parent(u){if(this._isCompound){var d=this._parent[u];if(d!==e)return d}}children(u=e){if(this._isCompound){var d=this._children[u];if(d)return Object.keys(d)}else{if(u===e)return this.nodes();if(this.hasNode(u))return[]}}predecessors(u){var d=this._preds[u];if(d)return Object.keys(d)}successors(u){var d=this._sucs[u];if(d)return Object.keys(d)}neighbors(u){var d=this.predecessors(u);if(d){const p=new Set(d);for(var f of this.successors(u))p.add(f);return Array.from(p.values())}}isLeaf(u){var d;return this.isDirected()?d=this.successors(u):d=this.neighbors(u),d.length===0}filterNodes(u){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var f=this;Object.entries(this._nodes).forEach(function([v,b]){u(v)&&d.setNode(v,b)}),Object.values(this._edgeObjs).forEach(function(v){d.hasNode(v.v)&&d.hasNode(v.w)&&d.setEdge(v,f.edge(v))});var p={};function m(v){var b=f.parent(v);return b===void 0||d.hasNode(b)?(p[v]=b,b):b in p?p[b]:m(b)}return this._isCompound&&d.nodes().forEach(v=>d.setParent(v,m(v))),d}setDefaultEdgeLabel(u){return this._defaultEdgeLabelFn=u,typeof u!="function"&&(this._defaultEdgeLabelFn=()=>u),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(u,d){var f=this,p=arguments;return u.reduce(function(m,v){return p.length>1?f.setEdge(m,v,d):f.setEdge(m,v),v}),this}setEdge(){var u,d,f,p,m=!1,v=arguments[0];typeof v=="object"&&v!==null&&"v"in v?(u=v.v,d=v.w,f=v.name,arguments.length===2&&(p=arguments[1],m=!0)):(u=v,d=arguments[1],f=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),u=""+u,d=""+d,f!==void 0&&(f=""+f);var b=s(this._isDirected,u,d,f);if(Object.hasOwn(this._edgeLabels,b))return m&&(this._edgeLabels[b]=p),this;if(f!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(u),this.setNode(d),this._edgeLabels[b]=m?p:this._defaultEdgeLabelFn(u,d,f);var w=a(this._isDirected,u,d,f);return u=w.v,d=w.w,Object.freeze(w),this._edgeObjs[b]=w,o(this._preds[d],u),o(this._sucs[u],d),this._in[d][b]=w,this._out[u][b]=w,this._edgeCount++,this}edge(u,d,f){var p=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,f);return this._edgeLabels[p]}edgeAsObj(){const u=this.edge(...arguments);return typeof u!="object"?{label:u}:u}hasEdge(u,d,f){var p=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,f);return Object.hasOwn(this._edgeLabels,p)}removeEdge(u,d,f){var p=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,f),m=this._edgeObjs[p];return m&&(u=m.v,d=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],i(this._preds[d],u),i(this._sucs[u],d),delete this._in[d][p],delete this._out[u][p],this._edgeCount--),this}inEdges(u,d){var f=this._in[u];if(f){var p=Object.values(f);return d?p.filter(m=>m.v===d):p}}outEdges(u,d){var f=this._out[u];if(f){var p=Object.values(f);return d?p.filter(m=>m.w===d):p}}nodeEdges(u,d){var f=this.inEdges(u,d);if(f)return f.concat(this.outEdges(u,d))}}function o(c,u){c[u]?c[u]++:c[u]=1}function i(c,u){--c[u]||delete c[u]}function s(c,u,d,f){var p=""+u,m=""+d;if(!c&&p>m){var v=p;p=m,m=v}return p+n+m+n+(f===void 0?t:f)}function a(c,u,d,f){var p=""+u,m=""+d;if(!c&&p>m){var v=p;p=m,m=v}var b={v:p,w:m};return f&&(b.name=f),b}function l(c,u){return s(c,u.v,u.w,u.name)}return zw=r,zw}var Vw,OT;function SJ(){return OT||(OT=1,Vw="2.2.4"),Vw}var jw,TT;function EJ(){return TT||(TT=1,jw={Graph:Hw(),version:SJ()}),jw}var Ww,NT;function xJ(){if(NT)return Ww;NT=1;var t=Hw();Ww={write:e,read:o};function e(i){var s={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:n(i),edges:r(i)};return i.graph()!==void 0&&(s.value=structuredClone(i.graph())),s}function n(i){return i.nodes().map(function(s){var a=i.node(s),l=i.parent(s),c={v:s};return a!==void 0&&(c.value=a),l!==void 0&&(c.parent=l),c})}function r(i){return i.edges().map(function(s){var a=i.edge(s),l={v:s.v,w:s.w};return s.name!==void 0&&(l.name=s.name),a!==void 0&&(l.value=a),l})}function o(i){var s=new t(i.options).setGraph(i.value);return i.nodes.forEach(function(a){s.setNode(a.v,a.value),a.parent&&s.setParent(a.v,a.parent)}),i.edges.forEach(function(a){s.setEdge({v:a.v,w:a.w,name:a.name},a.value)}),s}return Ww}var Uw,BT;function DJ(){if(BT)return Uw;BT=1,Uw=t;function t(e){var n={},r=[],o;function i(s){Object.hasOwn(n,s)||(n[s]=!0,o.push(s),e.successors(s).forEach(i),e.predecessors(s).forEach(i))}return e.nodes().forEach(function(s){o=[],i(s),o.length&&r.push(o)}),r}return Uw}var qw,FT;function MT(){if(FT)return qw;FT=1;class t{constructor(){lt(this,"_arr",[]);lt(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,r){var o=this._keyIndices;if(n=String(n),!Object.hasOwn(o,n)){var i=this._arr,s=i.length;return o[n]=s,i.push({key:n,priority:r}),this._decrease(s),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,r){var o=this._keyIndices[n];if(r>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[o].priority+" New: "+r);this._arr[o].priority=r,this._decrease(o)}_heapify(n){var r=this._arr,o=2*n,i=o+1,s=n;o<r.length&&(s=r[o].priority<r[s].priority?o:s,i<r.length&&(s=r[i].priority<r[s].priority?i:s),s!==n&&(this._swap(n,s),this._heapify(s)))}_decrease(n){for(var r=this._arr,o=r[n].priority,i;n!==0&&(i=n>>1,!(r[i].priority<o));)this._swap(n,i),n=i}_swap(n,r){var o=this._arr,i=this._keyIndices,s=o[n],a=o[r];o[n]=a,o[r]=s,i[a.key]=n,i[s.key]=r}}return qw=t,qw}var Gw,IT;function PT(){if(IT)return Gw;IT=1;var t=MT();Gw=n;var e=()=>1;function n(o,i,s,a){return r(o,String(i),s||e,a||function(l){return o.outEdges(l)})}function r(o,i,s,a){var l={},c=new t,u,d,f=function(p){var m=p.v!==u?p.v:p.w,v=l[m],b=s(p),w=d.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+p+" Weight: "+b);w<v.distance&&(v.distance=w,v.predecessor=u,c.decrease(m,w))};for(o.nodes().forEach(function(p){var m=p===i?0:Number.POSITIVE_INFINITY;l[p]={distance:m},c.add(p,m)});c.size()>0&&(u=c.removeMin(),d=l[u],d.distance!==Number.POSITIVE_INFINITY);)a(u).forEach(f);return l}return Gw}var Rw,LT;function _J(){if(LT)return Rw;LT=1;var t=PT();Rw=e;function e(n,r,o){return n.nodes().reduce(function(i,s){return i[s]=t(n,s,r,o),i},{})}return Rw}var Kw,$T;function zT(){if($T)return Kw;$T=1,Kw=t;function t(e){var n=0,r=[],o={},i=[];function s(a){var l=o[a]={onStack:!0,lowlink:n,index:n++};if(r.push(a),e.successors(a).forEach(function(d){Object.hasOwn(o,d)?o[d].onStack&&(l.lowlink=Math.min(l.lowlink,o[d].index)):(s(d),l.lowlink=Math.min(l.lowlink,o[d].lowlink))}),l.lowlink===l.index){var c=[],u;do u=r.pop(),o[u].onStack=!1,c.push(u);while(a!==u);i.push(c)}}return e.nodes().forEach(function(a){Object.hasOwn(o,a)||s(a)}),i}return Kw}var Yw,HT;function AJ(){if(HT)return Yw;HT=1;var t=zT();Yw=e;function e(n){return t(n).filter(function(r){return r.length>1||r.length===1&&n.hasEdge(r[0],r[0])})}return Yw}var Xw,VT;function OJ(){if(VT)return Xw;VT=1,Xw=e;var t=()=>1;function e(r,o,i){return n(r,o||t,i||function(s){return r.outEdges(s)})}function n(r,o,i){var s={},a=r.nodes();return a.forEach(function(l){s[l]={},s[l][l]={distance:0},a.forEach(function(c){l!==c&&(s[l][c]={distance:Number.POSITIVE_INFINITY})}),i(l).forEach(function(c){var u=c.v===l?c.w:c.v,d=o(c);s[l][u]={distance:d,predecessor:l}})}),a.forEach(function(l){var c=s[l];a.forEach(function(u){var d=s[u];a.forEach(function(f){var p=d[l],m=c[f],v=d[f],b=p.distance+m.distance;b<v.distance&&(v.distance=b,v.predecessor=m.predecessor)})})}),s}return Xw}var Jw,jT;function WT(){if(jT)return Jw;jT=1;function t(n){var r={},o={},i=[];function s(a){if(Object.hasOwn(o,a))throw new e;Object.hasOwn(r,a)||(o[a]=!0,r[a]=!0,n.predecessors(a).forEach(s),delete o[a],i.push(a))}if(n.sinks().forEach(s),Object.keys(r).length!==n.nodeCount())throw new e;return i}class e extends Error{constructor(){super(...arguments)}}return Jw=t,t.CycleException=e,Jw}var Qw,UT;function TJ(){if(UT)return Qw;UT=1;var t=WT();Qw=e;function e(n){try{t(n)}catch(r){if(r instanceof t.CycleException)return!1;throw r}return!0}return Qw}var Zw,qT;function GT(){if(qT)return Zw;qT=1,Zw=t;function t(o,i,s){Array.isArray(i)||(i=[i]);var a=o.isDirected()?d=>o.successors(d):d=>o.neighbors(d),l=s==="post"?e:n,c=[],u={};return i.forEach(d=>{if(!o.hasNode(d))throw new Error("Graph does not have node: "+d);l(d,a,u,c)}),c}function e(o,i,s,a){for(var l=[[o,!1]];l.length>0;){var c=l.pop();c[1]?a.push(c[0]):Object.hasOwn(s,c[0])||(s[c[0]]=!0,l.push([c[0],!0]),r(i(c[0]),u=>l.push([u,!1])))}}function n(o,i,s,a){for(var l=[o];l.length>0;){var c=l.pop();Object.hasOwn(s,c)||(s[c]=!0,a.push(c),r(i(c),u=>l.push(u)))}}function r(o,i){for(var s=o.length;s--;)i(o[s],s,o);return o}return Zw}var eb,RT;function NJ(){if(RT)return eb;RT=1;var t=GT();eb=e;function e(n,r){return t(n,r,"post")}return eb}var tb,KT;function BJ(){if(KT)return tb;KT=1;var t=GT();tb=e;function e(n,r){return t(n,r,"pre")}return tb}var nb,YT;function FJ(){if(YT)return nb;YT=1;var t=Hw(),e=MT();nb=n;function n(r,o){var i=new t,s={},a=new e,l;function c(d){var f=d.v===l?d.w:d.v,p=a.priority(f);if(p!==void 0){var m=o(d);m<p&&(s[f]=l,a.decrease(f,m))}}if(r.nodeCount()===0)return i;r.nodes().forEach(function(d){a.add(d,Number.POSITIVE_INFINITY),i.setNode(d)}),a.decrease(r.nodes()[0],0);for(var u=!1;a.size()>0;){if(l=a.removeMin(),Object.hasOwn(s,l))i.setEdge(l,s[l]);else{if(u)throw new Error("Input graph is not connected: "+r);u=!0}r.nodeEdges(l).forEach(c)}return i}return nb}var rb,XT;function MJ(){return XT||(XT=1,rb={components:DJ(),dijkstra:PT(),dijkstraAll:_J(),findCycles:AJ(),floydWarshall:OJ(),isAcyclic:TJ(),postorder:NJ(),preorder:BJ(),prim:FJ(),tarjan:zT(),topsort:WT()}),rb}var ob,JT;function vr(){if(JT)return ob;JT=1;var t=EJ();return ob={Graph:t.Graph,json:xJ(),alg:MJ(),version:t.version},ob}var ib,QT;function IJ(){if(QT)return ib;QT=1;class t{constructor(){let o={};o._next=o._prev=o,this._sentinel=o}dequeue(){let o=this._sentinel,i=o._prev;if(i!==o)return e(i),i}enqueue(o){let i=this._sentinel;o._prev&&o._next&&e(o),o._next=i._next,i._next._prev=o,i._next=o,o._prev=i}toString(){let o=[],i=this._sentinel,s=i._prev;for(;s!==i;)o.push(JSON.stringify(s,n)),s=s._prev;return"["+o.join(", ")+"]"}}function e(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,o){if(r!=="_next"&&r!=="_prev")return o}return ib=t,ib}var sb,ZT;function PJ(){if(ZT)return sb;ZT=1;let t=vr().Graph,e=IJ();sb=r;let n=()=>1;function r(c,u){if(c.nodeCount()<=1)return[];let d=s(c,u||n);return o(d.graph,d.buckets,d.zeroIdx).flatMap(p=>c.outEdges(p.v,p.w))}function o(c,u,d){let f=[],p=u[u.length-1],m=u[0],v;for(;c.nodeCount();){for(;v=m.dequeue();)i(c,u,d,v);for(;v=p.dequeue();)i(c,u,d,v);if(c.nodeCount()){for(let b=u.length-2;b>0;--b)if(v=u[b].dequeue(),v){f=f.concat(i(c,u,d,v,!0));break}}}return f}function i(c,u,d,f,p){let m=p?[]:void 0;return c.inEdges(f.v).forEach(v=>{let b=c.edge(v),w=c.node(v.v);p&&m.push({v:v.v,w:v.w}),w.out-=b,a(u,d,w)}),c.outEdges(f.v).forEach(v=>{let b=c.edge(v),w=v.w,g=c.node(w);g.in-=b,a(u,d,g)}),c.removeNode(f.v),m}function s(c,u){let d=new t,f=0,p=0;c.nodes().forEach(b=>{d.setNode(b,{v:b,in:0,out:0})}),c.edges().forEach(b=>{let w=d.edge(b.v,b.w)||0,g=u(b),C=w+g;d.setEdge(b.v,b.w,C),p=Math.max(p,d.node(b.v).out+=g),f=Math.max(f,d.node(b.w).in+=g)});let m=l(p+f+3).map(()=>new e),v=f+1;return d.nodes().forEach(b=>{a(m,v,d.node(b))}),{graph:d,buckets:m,zeroIdx:v}}function a(c,u,d){d.out?d.in?c[d.out-d.in+u].enqueue(d):c[c.length-1].enqueue(d):c[0].enqueue(d)}function l(c){const u=[];for(let d=0;d<c;d++)u.push(d);return u}return sb}var ab,eN;function Ft(){if(eN)return ab;eN=1;let t=vr().Graph;ab={addBorderNode:u,addDummyNode:e,applyWithChunking:p,asNonCompoundGraph:r,buildLayerMatrix:a,intersectRect:s,mapValues:S,maxRank:m,normalizeRanks:l,notime:w,partition:v,pick:_,predecessorWeights:i,range:k,removeEmptyRanks:c,simplify:n,successorWeights:o,time:b,uniqueId:C,zipObject:E};function e(x,O,A,T){for(var B=T;x.hasNode(B);)B=C(T);return A.dummy=O,x.setNode(B,A),B}function n(x){let O=new t().setGraph(x.graph());return x.nodes().forEach(A=>O.setNode(A,x.node(A))),x.edges().forEach(A=>{let T=O.edge(A.v,A.w)||{weight:0,minlen:1},B=x.edge(A);O.setEdge(A.v,A.w,{weight:T.weight+B.weight,minlen:Math.max(T.minlen,B.minlen)})}),O}function r(x){let O=new t({multigraph:x.isMultigraph()}).setGraph(x.graph());return x.nodes().forEach(A=>{x.children(A).length||O.setNode(A,x.node(A))}),x.edges().forEach(A=>{O.setEdge(A,x.edge(A))}),O}function o(x){let O=x.nodes().map(A=>{let T={};return x.outEdges(A).forEach(B=>{T[B.w]=(T[B.w]||0)+x.edge(B).weight}),T});return E(x.nodes(),O)}function i(x){let O=x.nodes().map(A=>{let T={};return x.inEdges(A).forEach(B=>{T[B.v]=(T[B.v]||0)+x.edge(B).weight}),T});return E(x.nodes(),O)}function s(x,O){let A=x.x,T=x.y,B=O.x-A,I=O.y-T,F=x.width/2,N=x.height/2;if(!B&&!I)throw new Error("Not possible to find intersection inside of the rectangle");let P,M;return Math.abs(I)*F>Math.abs(B)*N?(I<0&&(N=-N),P=N*B/I,M=N):(B<0&&(F=-F),P=F,M=F*I/B),{x:A+P,y:T+M}}function a(x){let O=k(m(x)+1).map(()=>[]);return x.nodes().forEach(A=>{let T=x.node(A),B=T.rank;B!==void 0&&(O[B][T.order]=A)}),O}function l(x){let O=x.nodes().map(T=>{let B=x.node(T).rank;return B===void 0?Number.MAX_VALUE:B}),A=p(Math.min,O);x.nodes().forEach(T=>{let B=x.node(T);Object.hasOwn(B,"rank")&&(B.rank-=A)})}function c(x){let O=x.nodes().map(F=>x.node(F).rank),A=p(Math.min,O),T=[];x.nodes().forEach(F=>{let N=x.node(F).rank-A;T[N]||(T[N]=[]),T[N].push(F)});let B=0,I=x.graph().nodeRankFactor;Array.from(T).forEach((F,N)=>{F===void 0&&N%I!==0?--B:F!==void 0&&B&&F.forEach(P=>x.node(P).rank+=B)})}function u(x,O,A,T){let B={width:0,height:0};return arguments.length>=4&&(B.rank=A,B.order=T),e(x,"border",B,O)}function d(x,O=f){const A=[];for(let T=0;T<x.length;T+=O){const B=x.slice(T,T+O);A.push(B)}return A}const f=65535;function p(x,O){if(O.length>f){const A=d(O);return x.apply(null,A.map(T=>x.apply(null,T)))}else return x.apply(null,O)}function m(x){const A=x.nodes().map(T=>{let B=x.node(T).rank;return B===void 0?Number.MIN_VALUE:B});return p(Math.max,A)}function v(x,O){let A={lhs:[],rhs:[]};return x.forEach(T=>{O(T)?A.lhs.push(T):A.rhs.push(T)}),A}function b(x,O){let A=Date.now();try{return O()}finally{console.log(x+" time: "+(Date.now()-A)+"ms")}}function w(x,O){return O()}let g=0;function C(x){var O=++g;return x+(""+O)}function k(x,O,A=1){O==null&&(O=x,x=0);let T=I=>I<O;A<0&&(T=I=>O<I);const B=[];for(let I=x;T(I);I+=A)B.push(I);return B}function _(x,O){const A={};for(const T of O)x[T]!==void 0&&(A[T]=x[T]);return A}function S(x,O){let A=O;return typeof O=="string"&&(A=T=>T[O]),Object.entries(x).reduce((T,[B,I])=>(T[B]=A(I,B),T),{})}function E(x,O){return x.reduce((A,T,B)=>(A[T]=O[B],A),{})}return ab}var lb,tN;function LJ(){if(tN)return lb;tN=1;let t=PJ(),e=Ft().uniqueId;lb={run:n,undo:o};function n(i){(i.graph().acyclicer==="greedy"?t(i,a(i)):r(i)).forEach(l=>{let c=i.edge(l);i.removeEdge(l),c.forwardName=l.name,c.reversed=!0,i.setEdge(l.w,l.v,c,e("rev"))});function a(l){return c=>l.edge(c).weight}}function r(i){let s=[],a={},l={};function c(u){Object.hasOwn(l,u)||(l[u]=!0,a[u]=!0,i.outEdges(u).forEach(d=>{Object.hasOwn(a,d.w)?s.push(d):c(d.w)}),delete a[u])}return i.nodes().forEach(c),s}function o(i){i.edges().forEach(s=>{let a=i.edge(s);if(a.reversed){i.removeEdge(s);let l=a.forwardName;delete a.reversed,delete a.forwardName,i.setEdge(s.w,s.v,a,l)}})}return lb}var cb,nN;function $J(){if(nN)return cb;nN=1;let t=Ft();cb={run:e,undo:r};function e(o){o.graph().dummyChains=[],o.edges().forEach(i=>n(o,i))}function n(o,i){let s=i.v,a=o.node(s).rank,l=i.w,c=o.node(l).rank,u=i.name,d=o.edge(i),f=d.labelRank;if(c===a+1)return;o.removeEdge(i);let p,m,v;for(v=0,++a;a<c;++v,++a)d.points=[],m={width:0,height:0,edgeLabel:d,edgeObj:i,rank:a},p=t.addDummyNode(o,"edge",m,"_d"),a===f&&(m.width=d.width,m.height=d.height,m.dummy="edge-label",m.labelpos=d.labelpos),o.setEdge(s,p,{weight:d.weight},u),v===0&&o.graph().dummyChains.push(p),s=p;o.setEdge(s,l,{weight:d.weight},u)}function r(o){o.graph().dummyChains.forEach(i=>{let s=o.node(i),a=s.edgeLabel,l;for(o.setEdge(s.edgeObj,a);s.dummy;)l=o.successors(i)[0],o.removeNode(i),a.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(a.x=s.x,a.y=s.y,a.width=s.width,a.height=s.height),i=l,s=o.node(i)})}return cb}var ub,rN;function rf(){if(rN)return ub;rN=1;const{applyWithChunking:t}=Ft();ub={longestPath:e,slack:n};function e(r){var o={};function i(s){var a=r.node(s);if(Object.hasOwn(o,s))return a.rank;o[s]=!0;let l=r.outEdges(s).map(u=>u==null?Number.POSITIVE_INFINITY:i(u.w)-r.edge(u).minlen);var c=t(Math.min,l);return c===Number.POSITIVE_INFINITY&&(c=0),a.rank=c}r.sources().forEach(i)}function n(r,o){return r.node(o.w).rank-r.node(o.v).rank-r.edge(o).minlen}return ub}var db,oN;function iN(){if(oN)return db;oN=1;var t=vr().Graph,e=rf().slack;db=n;function n(s){var a=new t({directed:!1}),l=s.nodes()[0],c=s.nodeCount();a.setNode(l,{});for(var u,d;r(a,s)<c;)u=o(a,s),d=a.hasNode(u.v)?e(s,u):-e(s,u),i(a,s,d);return a}function r(s,a){function l(c){a.nodeEdges(c).forEach(u=>{var d=u.v,f=c===d?u.w:d;!s.hasNode(f)&&!e(a,u)&&(s.setNode(f,{}),s.setEdge(c,f,{}),l(f))})}return s.nodes().forEach(l),s.nodeCount()}function o(s,a){return a.edges().reduce((c,u)=>{let d=Number.POSITIVE_INFINITY;return s.hasNode(u.v)!==s.hasNode(u.w)&&(d=e(a,u)),d<c[0]?[d,u]:c},[Number.POSITIVE_INFINITY,null])[1]}function i(s,a,l){s.nodes().forEach(c=>a.node(c).rank+=l)}return db}var fb,sN;function zJ(){if(sN)return fb;sN=1;var t=iN(),e=rf().slack,n=rf().longestPath,r=vr().alg.preorder,o=vr().alg.postorder,i=Ft().simplify;fb=s,s.initLowLimValues=u,s.initCutValues=a,s.calcCutValue=c,s.leaveEdge=f,s.enterEdge=p,s.exchangeEdges=m;function s(g){g=i(g),n(g);var C=t(g);u(C),a(C,g);for(var k,_;k=f(C);)_=p(C,g,k),m(C,g,k,_)}function a(g,C){var k=o(g,g.nodes());k=k.slice(0,k.length-1),k.forEach(_=>l(g,C,_))}function l(g,C,k){var _=g.node(k),S=_.parent;g.edge(k,S).cutvalue=c(g,C,k)}function c(g,C,k){var _=g.node(k),S=_.parent,E=!0,x=C.edge(k,S),O=0;return x||(E=!1,x=C.edge(S,k)),O=x.weight,C.nodeEdges(k).forEach(A=>{var T=A.v===k,B=T?A.w:A.v;if(B!==S){var I=T===E,F=C.edge(A).weight;if(O+=I?F:-F,b(g,k,B)){var N=g.edge(k,B).cutvalue;O+=I?-N:N}}}),O}function u(g,C){arguments.length<2&&(C=g.nodes()[0]),d(g,{},1,C)}function d(g,C,k,_,S){var E=k,x=g.node(_);return C[_]=!0,g.neighbors(_).forEach(O=>{Object.hasOwn(C,O)||(k=d(g,C,k,O,_))}),x.low=E,x.lim=k++,S?x.parent=S:delete x.parent,k}function f(g){return g.edges().find(C=>g.edge(C).cutvalue<0)}function p(g,C,k){var _=k.v,S=k.w;C.hasEdge(_,S)||(_=k.w,S=k.v);var E=g.node(_),x=g.node(S),O=E,A=!1;E.lim>x.lim&&(O=x,A=!0);var T=C.edges().filter(B=>A===w(g,g.node(B.v),O)&&A!==w(g,g.node(B.w),O));return T.reduce((B,I)=>e(C,I)<e(C,B)?I:B)}function m(g,C,k,_){var S=k.v,E=k.w;g.removeEdge(S,E),g.setEdge(_.v,_.w,{}),u(g),a(g,C),v(g,C)}function v(g,C){var k=g.nodes().find(S=>!C.node(S).parent),_=r(g,k);_=_.slice(1),_.forEach(S=>{var E=g.node(S).parent,x=C.edge(S,E),O=!1;x||(x=C.edge(E,S),O=!0),C.node(S).rank=C.node(E).rank+(O?x.minlen:-x.minlen)})}function b(g,C,k){return g.hasEdge(C,k)}function w(g,C,k){return k.low<=C.lim&&C.lim<=k.lim}return fb}var hb,aN;function HJ(){if(aN)return hb;aN=1;var t=rf(),e=t.longestPath,n=iN(),r=zJ();hb=o;function o(l){var c=l.graph().ranker;if(c instanceof Function)return c(l);switch(l.graph().ranker){case"network-simplex":a(l);break;case"tight-tree":s(l);break;case"longest-path":i(l);break;case"none":break;default:a(l)}}var i=e;function s(l){e(l),n(l)}function a(l){r(l)}return hb}var pb,lN;function VJ(){if(lN)return pb;lN=1,pb=t;function t(r){let o=n(r);r.graph().dummyChains.forEach(i=>{let s=r.node(i),a=s.edgeObj,l=e(r,o,a.v,a.w),c=l.path,u=l.lca,d=0,f=c[d],p=!0;for(;i!==a.w;){if(s=r.node(i),p){for(;(f=c[d])!==u&&r.node(f).maxRank<s.rank;)d++;f===u&&(p=!1)}if(!p){for(;d<c.length-1&&r.node(f=c[d+1]).minRank<=s.rank;)d++;f=c[d]}r.setParent(i,f),i=r.successors(i)[0]}})}function e(r,o,i,s){let a=[],l=[],c=Math.min(o[i].low,o[s].low),u=Math.max(o[i].lim,o[s].lim),d,f;d=i;do d=r.parent(d),a.push(d);while(d&&(o[d].low>c||u>o[d].lim));for(f=d,d=s;(d=r.parent(d))!==f;)l.push(d);return{path:a.concat(l.reverse()),lca:f}}function n(r){let o={},i=0;function s(a){let l=i;r.children(a).forEach(s),o[a]={low:l,lim:i++}}return r.children().forEach(s),o}return pb}var mb,cN;function jJ(){if(cN)return mb;cN=1;let t=Ft();mb={run:e,cleanup:i};function e(s){let a=t.addDummyNode(s,"root",{},"_root"),l=r(s),c=Object.values(l),u=t.applyWithChunking(Math.max,c)-1,d=2*u+1;s.graph().nestingRoot=a,s.edges().forEach(p=>s.edge(p).minlen*=d);let f=o(s)+1;s.children().forEach(p=>n(s,a,d,f,u,l,p)),s.graph().nodeRankFactor=d}function n(s,a,l,c,u,d,f){let p=s.children(f);if(!p.length){f!==a&&s.setEdge(a,f,{weight:0,minlen:l});return}let m=t.addBorderNode(s,"_bt"),v=t.addBorderNode(s,"_bb"),b=s.node(f);s.setParent(m,f),b.borderTop=m,s.setParent(v,f),b.borderBottom=v,p.forEach(w=>{n(s,a,l,c,u,d,w);let g=s.node(w),C=g.borderTop?g.borderTop:w,k=g.borderBottom?g.borderBottom:w,_=g.borderTop?c:2*c,S=C!==k?1:u-d[f]+1;s.setEdge(m,C,{weight:_,minlen:S,nestingEdge:!0}),s.setEdge(k,v,{weight:_,minlen:S,nestingEdge:!0})}),s.parent(f)||s.setEdge(a,m,{weight:0,minlen:u+d[f]})}function r(s){var a={};function l(c,u){var d=s.children(c);d&&d.length&&d.forEach(f=>l(f,u+1)),a[c]=u}return s.children().forEach(c=>l(c,1)),a}function o(s){return s.edges().reduce((a,l)=>a+s.edge(l).weight,0)}function i(s){var a=s.graph();s.removeNode(a.nestingRoot),delete a.nestingRoot,s.edges().forEach(l=>{var c=s.edge(l);c.nestingEdge&&s.removeEdge(l)})}return mb}var gb,uN;function WJ(){if(uN)return gb;uN=1;let t=Ft();gb=e;function e(r){function o(i){let s=r.children(i),a=r.node(i);if(s.length&&s.forEach(o),Object.hasOwn(a,"minRank")){a.borderLeft=[],a.borderRight=[];for(let l=a.minRank,c=a.maxRank+1;l<c;++l)n(r,"borderLeft","_bl",i,a,l),n(r,"borderRight","_br",i,a,l)}}r.children().forEach(o)}function n(r,o,i,s,a,l){let c={width:0,height:0,rank:l,borderType:o},u=a[o][l-1],d=t.addDummyNode(r,"border",c,i);a[o][l]=d,r.setParent(d,s),u&&r.setEdge(u,d,{weight:1})}return gb}var wb,dN;function UJ(){if(dN)return wb;dN=1,wb={adjust:t,undo:e};function t(l){let c=l.graph().rankdir.toLowerCase();(c==="lr"||c==="rl")&&n(l)}function e(l){let c=l.graph().rankdir.toLowerCase();(c==="bt"||c==="rl")&&o(l),(c==="lr"||c==="rl")&&(s(l),n(l))}function n(l){l.nodes().forEach(c=>r(l.node(c))),l.edges().forEach(c=>r(l.edge(c)))}function r(l){let c=l.width;l.width=l.height,l.height=c}function o(l){l.nodes().forEach(c=>i(l.node(c))),l.edges().forEach(c=>{let u=l.edge(c);u.points.forEach(i),Object.hasOwn(u,"y")&&i(u)})}function i(l){l.y=-l.y}function s(l){l.nodes().forEach(c=>a(l.node(c))),l.edges().forEach(c=>{let u=l.edge(c);u.points.forEach(a),Object.hasOwn(u,"x")&&a(u)})}function a(l){let c=l.x;l.x=l.y,l.y=c}return wb}var bb,fN;function qJ(){if(fN)return bb;fN=1;let t=Ft();bb=e;function e(n){let r={},o=n.nodes().filter(u=>!n.children(u).length),i=o.map(u=>n.node(u).rank),s=t.applyWithChunking(Math.max,i),a=t.range(s+1).map(()=>[]);function l(u){if(r[u])return;r[u]=!0;let d=n.node(u);a[d.rank].push(u),n.successors(u).forEach(l)}return o.sort((u,d)=>n.node(u).rank-n.node(d).rank).forEach(l),a}return bb}var vb,hN;function GJ(){if(hN)return vb;hN=1;let t=Ft().zipObject;vb=e;function e(r,o){let i=0;for(let s=1;s<o.length;++s)i+=n(r,o[s-1],o[s]);return i}function n(r,o,i){let s=t(i,i.map((f,p)=>p)),a=o.flatMap(f=>r.outEdges(f).map(p=>({pos:s[p.w],weight:r.edge(p).weight})).sort((p,m)=>p.pos-m.pos)),l=1;for(;l<i.length;)l<<=1;let c=2*l-1;l-=1;let u=new Array(c).fill(0),d=0;return a.forEach(f=>{let p=f.pos+l;u[p]+=f.weight;let m=0;for(;p>0;)p%2&&(m+=u[p+1]),p=p-1>>1,u[p]+=f.weight;d+=f.weight*m}),d}return vb}var yb,pN;function RJ(){if(pN)return yb;pN=1,yb=t;function t(e,n=[]){return n.map(r=>{let o=e.inEdges(r);if(o.length){let i=o.reduce((s,a)=>{let l=e.edge(a),c=e.node(a.v);return{sum:s.sum+l.weight*c.order,weight:s.weight+l.weight}},{sum:0,weight:0});return{v:r,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:r}})}return yb}var Cb,mN;function KJ(){if(mN)return Cb;mN=1;let t=Ft();Cb=e;function e(o,i){let s={};o.forEach((l,c)=>{let u=s[l.v]={indegree:0,in:[],out:[],vs:[l.v],i:c};l.barycenter!==void 0&&(u.barycenter=l.barycenter,u.weight=l.weight)}),i.edges().forEach(l=>{let c=s[l.v],u=s[l.w];c!==void 0&&u!==void 0&&(u.indegree++,c.out.push(s[l.w]))});let a=Object.values(s).filter(l=>!l.indegree);return n(a)}function n(o){let i=[];function s(l){return c=>{c.merged||(c.barycenter===void 0||l.barycenter===void 0||c.barycenter>=l.barycenter)&&r(l,c)}}function a(l){return c=>{c.in.push(l),--c.indegree===0&&o.push(c)}}for(;o.length;){let l=o.pop();i.push(l),l.in.reverse().forEach(s(l)),l.out.forEach(a(l))}return i.filter(l=>!l.merged).map(l=>t.pick(l,["vs","i","barycenter","weight"]))}function r(o,i){let s=0,a=0;o.weight&&(s+=o.barycenter*o.weight,a+=o.weight),i.weight&&(s+=i.barycenter*i.weight,a+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=s/a,o.weight=a,o.i=Math.min(i.i,o.i),i.merged=!0}return Cb}var kb,gN;function YJ(){if(gN)return kb;gN=1;let t=Ft();kb=e;function e(o,i){let s=t.partition(o,m=>Object.hasOwn(m,"barycenter")),a=s.lhs,l=s.rhs.sort((m,v)=>v.i-m.i),c=[],u=0,d=0,f=0;a.sort(r(!!i)),f=n(c,l,f),a.forEach(m=>{f+=m.vs.length,c.push(m.vs),u+=m.barycenter*m.weight,d+=m.weight,f=n(c,l,f)});let p={vs:c.flat(!0)};return d&&(p.barycenter=u/d,p.weight=d),p}function n(o,i,s){let a;for(;i.length&&(a=i[i.length-1]).i<=s;)i.pop(),o.push(a.vs),s++;return s}function r(o){return(i,s)=>i.barycenter<s.barycenter?-1:i.barycenter>s.barycenter?1:o?s.i-i.i:i.i-s.i}return kb}var Sb,wN;function XJ(){if(wN)return Sb;wN=1;let t=RJ(),e=KJ(),n=YJ();Sb=r;function r(s,a,l,c){let u=s.children(a),d=s.node(a),f=d?d.borderLeft:void 0,p=d?d.borderRight:void 0,m={};f&&(u=u.filter(g=>g!==f&&g!==p));let v=t(s,u);v.forEach(g=>{if(s.children(g.v).length){let C=r(s,g.v,l,c);m[g.v]=C,Object.hasOwn(C,"barycenter")&&i(g,C)}});let b=e(v,l);o(b,m);let w=n(b,c);if(f&&(w.vs=[f,w.vs,p].flat(!0),s.predecessors(f).length)){let g=s.node(s.predecessors(f)[0]),C=s.node(s.predecessors(p)[0]);Object.hasOwn(w,"barycenter")||(w.barycenter=0,w.weight=0),w.barycenter=(w.barycenter*w.weight+g.order+C.order)/(w.weight+2),w.weight+=2}return w}function o(s,a){s.forEach(l=>{l.vs=l.vs.flatMap(c=>a[c]?a[c].vs:c)})}function i(s,a){s.barycenter!==void 0?(s.barycenter=(s.barycenter*s.weight+a.barycenter*a.weight)/(s.weight+a.weight),s.weight+=a.weight):(s.barycenter=a.barycenter,s.weight=a.weight)}return Sb}var Eb,bN;function JJ(){if(bN)return Eb;bN=1;let t=vr().Graph,e=Ft();Eb=n;function n(o,i,s,a){a||(a=o.nodes());let l=r(o),c=new t({compound:!0}).setGraph({root:l}).setDefaultNodeLabel(u=>o.node(u));return a.forEach(u=>{let d=o.node(u),f=o.parent(u);(d.rank===i||d.minRank<=i&&i<=d.maxRank)&&(c.setNode(u),c.setParent(u,f||l),o[s](u).forEach(p=>{let m=p.v===u?p.w:p.v,v=c.edge(m,u),b=v!==void 0?v.weight:0;c.setEdge(m,u,{weight:o.edge(p).weight+b})}),Object.hasOwn(d,"minRank")&&c.setNode(u,{borderLeft:d.borderLeft[i],borderRight:d.borderRight[i]}))}),c}function r(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return Eb}var xb,vN;function QJ(){if(vN)return xb;vN=1,xb=t;function t(e,n,r){let o={},i;r.forEach(s=>{let a=e.parent(s),l,c;for(;a;){if(l=e.parent(a),l?(c=o[l],o[l]=a):(c=i,i=a),c&&c!==a){n.setEdge(c,a);return}a=l}})}return xb}var Db,yN;function ZJ(){if(yN)return Db;yN=1;let t=qJ(),e=GJ(),n=XJ(),r=JJ(),o=QJ(),i=vr().Graph,s=Ft();Db=a;function a(d,f){if(f&&typeof f.customOrder=="function"){f.customOrder(d,a);return}let p=s.maxRank(d),m=l(d,s.range(1,p+1),"inEdges"),v=l(d,s.range(p-1,-1,-1),"outEdges"),b=t(d);if(u(d,b),f&&f.disableOptimalOrderHeuristic)return;let w=Number.POSITIVE_INFINITY,g;for(let C=0,k=0;k<4;++C,++k){c(C%2?m:v,C%4>=2),b=s.buildLayerMatrix(d);let _=e(d,b);_<w&&(k=0,g=Object.assign({},b),w=_)}u(d,g)}function l(d,f,p){const m=new Map,v=(b,w)=>{m.has(b)||m.set(b,[]),m.get(b).push(w)};for(const b of d.nodes()){const w=d.node(b);if(typeof w.rank=="number"&&v(w.rank,b),typeof w.minRank=="number"&&typeof w.maxRank=="number")for(let g=w.minRank;g<=w.maxRank;g++)g!==w.rank&&v(g,b)}return f.map(function(b){return r(d,b,p,m.get(b)||[])})}function c(d,f){let p=new i;d.forEach(function(m){let v=m.graph().root,b=n(m,v,p,f);b.vs.forEach((w,g)=>m.node(w).order=g),o(m,p,b.vs)})}function u(d,f){Object.values(f).forEach(p=>p.forEach((m,v)=>d.node(m).order=v))}return Db}var _b,CN;function eQ(){if(CN)return _b;CN=1;let t=vr().Graph,e=Ft();_b={positionX:p,findType1Conflicts:n,findType2Conflicts:r,addConflict:i,hasConflict:s,verticalAlignment:a,horizontalCompaction:l,alignCoordinates:d,findSmallestWidthAlignment:u,balance:f};function n(b,w){let g={};function C(k,_){let S=0,E=0,x=k.length,O=_[_.length-1];return _.forEach((A,T)=>{let B=o(b,A),I=B?b.node(B).order:x;(B||A===O)&&(_.slice(E,T+1).forEach(F=>{b.predecessors(F).forEach(N=>{let P=b.node(N),M=P.order;(M<S||I<M)&&!(P.dummy&&b.node(F).dummy)&&i(g,N,F)})}),E=T+1,S=I)}),_}return w.length&&w.reduce(C),g}function r(b,w){let g={};function C(_,S,E,x,O){let A;e.range(S,E).forEach(T=>{A=_[T],b.node(A).dummy&&b.predecessors(A).forEach(B=>{let I=b.node(B);I.dummy&&(I.order<x||I.order>O)&&i(g,B,A)})})}function k(_,S){let E=-1,x,O=0;return S.forEach((A,T)=>{if(b.node(A).dummy==="border"){let B=b.predecessors(A);B.length&&(x=b.node(B[0]).order,C(S,O,T,E,x),O=T,E=x)}C(S,O,S.length,x,_.length)}),S}return w.length&&w.reduce(k),g}function o(b,w){if(b.node(w).dummy)return b.predecessors(w).find(g=>b.node(g).dummy)}function i(b,w,g){if(w>g){let k=w;w=g,g=k}let C=b[w];C||(b[w]=C={}),C[g]=!0}function s(b,w,g){if(w>g){let C=w;w=g,g=C}return!!b[w]&&Object.hasOwn(b[w],g)}function a(b,w,g,C){let k={},_={},S={};return w.forEach(E=>{E.forEach((x,O)=>{k[x]=x,_[x]=x,S[x]=O})}),w.forEach(E=>{let x=-1;E.forEach(O=>{let A=C(O);if(A.length){A=A.sort((B,I)=>S[B]-S[I]);let T=(A.length-1)/2;for(let B=Math.floor(T),I=Math.ceil(T);B<=I;++B){let F=A[B];_[O]===O&&x<S[F]&&!s(g,O,F)&&(_[F]=O,_[O]=k[O]=k[F],x=S[F])}}})}),{root:k,align:_}}function l(b,w,g,C,k){let _={},S=c(b,w,g,k),E=k?"borderLeft":"borderRight";function x(T,B){let I=S.nodes(),F=I.pop(),N={};for(;F;)N[F]?T(F):(N[F]=!0,I.push(F),I=I.concat(B(F))),F=I.pop()}function O(T){_[T]=S.inEdges(T).reduce((B,I)=>Math.max(B,_[I.v]+S.edge(I)),0)}function A(T){let B=S.outEdges(T).reduce((F,N)=>Math.min(F,_[N.w]-S.edge(N)),Number.POSITIVE_INFINITY),I=b.node(T);B!==Number.POSITIVE_INFINITY&&I.borderType!==E&&(_[T]=Math.max(_[T],B))}return x(O,S.predecessors.bind(S)),x(A,S.successors.bind(S)),Object.keys(C).forEach(T=>_[T]=_[g[T]]),_}function c(b,w,g,C){let k=new t,_=b.graph(),S=m(_.nodesep,_.edgesep,C);return w.forEach(E=>{let x;E.forEach(O=>{let A=g[O];if(k.setNode(A),x){var T=g[x],B=k.edge(T,A);k.setEdge(T,A,Math.max(S(b,O,x),B||0))}x=O})}),k}function u(b,w){return Object.values(w).reduce((g,C)=>{let k=Number.NEGATIVE_INFINITY,_=Number.POSITIVE_INFINITY;Object.entries(C).forEach(([E,x])=>{let O=v(b,E)/2;k=Math.max(x+O,k),_=Math.min(x-O,_)});const S=k-_;return S<g[0]&&(g=[S,C]),g},[Number.POSITIVE_INFINITY,null])[1]}function d(b,w){let g=Object.values(w),C=e.applyWithChunking(Math.min,g),k=e.applyWithChunking(Math.max,g);["u","d"].forEach(_=>{["l","r"].forEach(S=>{let E=_+S,x=b[E];if(x===w)return;let O=Object.values(x),A=C-e.applyWithChunking(Math.min,O);S!=="l"&&(A=k-e.applyWithChunking(Math.max,O)),A&&(b[E]=e.mapValues(x,T=>T+A))})})}function f(b,w){return e.mapValues(b.ul,(g,C)=>{if(w)return b[w.toLowerCase()][C];{let k=Object.values(b).map(_=>_[C]).sort((_,S)=>_-S);return(k[1]+k[2])/2}})}function p(b){let w=e.buildLayerMatrix(b),g=Object.assign(n(b,w),r(b,w)),C={},k;["u","d"].forEach(S=>{k=S==="u"?w:Object.values(w).reverse(),["l","r"].forEach(E=>{E==="r"&&(k=k.map(T=>Object.values(T).reverse()));let x=(S==="u"?b.predecessors:b.successors).bind(b),O=a(b,k,g,x),A=l(b,k,O.root,O.align,E==="r");E==="r"&&(A=e.mapValues(A,T=>-T)),C[S+E]=A})});let _=u(b,C);return d(C,_),f(C,b.graph().align)}function m(b,w,g){return(C,k,_)=>{let S=C.node(k),E=C.node(_),x=0,O;if(x+=S.width/2,Object.hasOwn(S,"labelpos"))switch(S.labelpos.toLowerCase()){case"l":O=-S.width/2;break;case"r":O=S.width/2;break}if(O&&(x+=g?O:-O),O=0,x+=(S.dummy?w:b)/2,x+=(E.dummy?w:b)/2,x+=E.width/2,Object.hasOwn(E,"labelpos"))switch(E.labelpos.toLowerCase()){case"l":O=E.width/2;break;case"r":O=-E.width/2;break}return O&&(x+=g?O:-O),O=0,x}}function v(b,w){return b.node(w).width}return _b}var Ab,kN;function tQ(){if(kN)return Ab;kN=1;let t=Ft(),e=eQ().positionX;Ab=n;function n(o){o=t.asNonCompoundGraph(o),r(o),Object.entries(e(o)).forEach(([i,s])=>o.node(i).x=s)}function r(o){let i=t.buildLayerMatrix(o),s=o.graph().ranksep,a=0;i.forEach(l=>{const c=l.reduce((u,d)=>{const f=o.node(d).height;return u>f?u:f},0);l.forEach(u=>o.node(u).y=a+c/2),a+=c+s})}return Ab}var Ob,SN;function nQ(){if(SN)return Ob;SN=1;let t=LJ(),e=$J(),n=HJ(),r=Ft().normalizeRanks,o=VJ(),i=Ft().removeEmptyRanks,s=jJ(),a=WJ(),l=UJ(),c=ZJ(),u=tQ(),d=Ft(),f=vr().Graph;Ob=p;function p($,j){let U=j&&j.debugTiming?d.time:d.notime;U("layout",()=>{let ee=U(" buildLayoutGraph",()=>x($));U(" runLayout",()=>m(ee,U,j)),U(" updateInputGraph",()=>v($,ee))})}function m($,j,U){j(" makeSpaceForEdgeLabels",()=>O($)),j(" removeSelfEdges",()=>z($)),j(" acyclic",()=>t.run($)),j(" nestingGraph.run",()=>s.run($)),j(" rank",()=>n(d.asNonCompoundGraph($))),j(" injectEdgeLabelProxies",()=>A($)),j(" removeEmptyRanks",()=>i($)),j(" nestingGraph.cleanup",()=>s.cleanup($)),j(" normalizeRanks",()=>r($)),j(" assignRankMinMax",()=>T($)),j(" removeEdgeLabelProxies",()=>B($)),j(" normalize.run",()=>e.run($)),j(" parentDummyChains",()=>o($)),j(" addBorderSegments",()=>a($)),j(" order",()=>c($,U)),j(" insertSelfEdges",()=>H($)),j(" adjustCoordinateSystem",()=>l.adjust($)),j(" position",()=>u($)),j(" positionSelfEdges",()=>R($)),j(" removeBorderNodes",()=>M($)),j(" normalize.undo",()=>e.undo($)),j(" fixupEdgeLabelCoords",()=>N($)),j(" undoCoordinateSystem",()=>l.undo($)),j(" translateGraph",()=>I($)),j(" assignNodeIntersects",()=>F($)),j(" reversePoints",()=>P($)),j(" acyclic.undo",()=>t.undo($))}function v($,j){$.nodes().forEach(U=>{let ee=$.node(U),ie=j.node(U);ee&&(ee.x=ie.x,ee.y=ie.y,ee.rank=ie.rank,j.children(U).length&&(ee.width=ie.width,ee.height=ie.height))}),$.edges().forEach(U=>{let ee=$.edge(U),ie=j.edge(U);ee.points=ie.points,Object.hasOwn(ie,"x")&&(ee.x=ie.x,ee.y=ie.y)}),$.graph().width=j.graph().width,$.graph().height=j.graph().height}let b=["nodesep","edgesep","ranksep","marginx","marginy"],w={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},g=["acyclicer","ranker","rankdir","align"],C=["width","height","rank"],k={width:0,height:0},_=["minlen","weight","width","height","labeloffset"],S={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},E=["labelpos"];function x($){let j=new f({multigraph:!0,compound:!0}),U=te($.graph());return j.setGraph(Object.assign({},w,Y(U,b),d.pick(U,g))),$.nodes().forEach(ee=>{let ie=te($.node(ee));const be=Y(ie,C);Object.keys(k).forEach(W=>{be[W]===void 0&&(be[W]=k[W])}),j.setNode(ee,be),j.setParent(ee,$.parent(ee))}),$.edges().forEach(ee=>{let ie=te($.edge(ee));j.setEdge(ee,Object.assign({},S,Y(ie,_),d.pick(ie,E)))}),j}function O($){let j=$.graph();j.ranksep/=2,$.edges().forEach(U=>{let ee=$.edge(U);ee.minlen*=2,ee.labelpos.toLowerCase()!=="c"&&(j.rankdir==="TB"||j.rankdir==="BT"?ee.width+=ee.labeloffset:ee.height+=ee.labeloffset)})}function A($){$.edges().forEach(j=>{let U=$.edge(j);if(U.width&&U.height){let ee=$.node(j.v),be={rank:($.node(j.w).rank-ee.rank)/2+ee.rank,e:j};d.addDummyNode($,"edge-proxy",be,"_ep")}})}function T($){let j=0;$.nodes().forEach(U=>{let ee=$.node(U);ee.borderTop&&(ee.minRank=$.node(ee.borderTop).rank,ee.maxRank=$.node(ee.borderBottom).rank,j=Math.max(j,ee.maxRank))}),$.graph().maxRank=j}function B($){$.nodes().forEach(j=>{let U=$.node(j);U.dummy==="edge-proxy"&&($.edge(U.e).labelRank=U.rank,$.removeNode(j))})}function I($){let j=Number.POSITIVE_INFINITY,U=0,ee=Number.POSITIVE_INFINITY,ie=0,be=$.graph(),W=be.marginx||0,X=be.marginy||0;function q(J){let re=J.x,Z=J.y,ue=J.width,ve=J.height;j=Math.min(j,re-ue/2),U=Math.max(U,re+ue/2),ee=Math.min(ee,Z-ve/2),ie=Math.max(ie,Z+ve/2)}$.nodes().forEach(J=>q($.node(J))),$.edges().forEach(J=>{let re=$.edge(J);Object.hasOwn(re,"x")&&q(re)}),j-=W,ee-=X,$.nodes().forEach(J=>{let re=$.node(J);re.x-=j,re.y-=ee}),$.edges().forEach(J=>{let re=$.edge(J);re.points.forEach(Z=>{Z.x-=j,Z.y-=ee}),Object.hasOwn(re,"x")&&(re.x-=j),Object.hasOwn(re,"y")&&(re.y-=ee)}),be.width=U-j+W,be.height=ie-ee+X}function F($){$.edges().forEach(j=>{let U=$.edge(j),ee=$.node(j.v),ie=$.node(j.w),be,W;U.points?(be=U.points[0],W=U.points[U.points.length-1]):(U.points=[],be=ie,W=ee),U.points.unshift(d.intersectRect(ee,be)),U.points.push(d.intersectRect(ie,W))})}function N($){$.edges().forEach(j=>{let U=$.edge(j);if(Object.hasOwn(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 P($){$.edges().forEach(j=>{let U=$.edge(j);U.reversed&&U.points.reverse()})}function M($){$.nodes().forEach(j=>{if($.children(j).length){let U=$.node(j),ee=$.node(U.borderTop),ie=$.node(U.borderBottom),be=$.node(U.borderLeft[U.borderLeft.length-1]),W=$.node(U.borderRight[U.borderRight.length-1]);U.width=Math.abs(W.x-be.x),U.height=Math.abs(ie.y-ee.y),U.x=be.x+U.width/2,U.y=ee.y+U.height/2}}),$.nodes().forEach(j=>{$.node(j).dummy==="border"&&$.removeNode(j)})}function z($){$.edges().forEach(j=>{if(j.v===j.w){var U=$.node(j.v);U.selfEdges||(U.selfEdges=[]),U.selfEdges.push({e:j,label:$.edge(j)}),$.removeEdge(j)}})}function H($){var j=d.buildLayerMatrix($);j.forEach(U=>{var ee=0;U.forEach((ie,be)=>{var W=$.node(ie);W.order=be+ee,(W.selfEdges||[]).forEach(X=>{d.addDummyNode($,"selfedge",{width:X.label.width,height:X.label.height,rank:W.rank,order:be+ ++ee,e:X.e,label:X.label},"_se")}),delete W.selfEdges})})}function R($){$.nodes().forEach(j=>{var U=$.node(j);if(U.dummy==="selfedge"){var ee=$.node(U.e.v),ie=ee.x+ee.width/2,be=ee.y,W=U.x-ie,X=ee.height/2;$.setEdge(U.e,U.label),$.removeNode(j),U.label.points=[{x:ie+2*W/3,y:be-X},{x:ie+5*W/6,y:be-X},{x:ie+W,y:be},{x:ie+5*W/6,y:be+X},{x:ie+2*W/3,y:be+X}],U.label.x=U.x,U.label.y=U.y}})}function Y($,j){return d.mapValues(d.pick($,j),Number)}function te($){var j={};return $&&Object.entries($).forEach(([U,ee])=>{typeof U=="string"&&(U=U.toLowerCase()),j[U]=ee}),j}return Ob}var Tb,EN;function rQ(){if(EN)return Tb;EN=1;let t=Ft(),e=vr().Graph;Tb={debugOrdering:n};function n(r){let o=t.buildLayerMatrix(r),i=new e({compound:!0,multigraph:!0}).setGraph({});return r.nodes().forEach(s=>{i.setNode(s,{label:s}),i.setParent(s,"layer"+r.node(s).rank)}),r.edges().forEach(s=>i.setEdge(s.v,s.w,{},s.name)),o.forEach((s,a)=>{let l="layer"+a;i.setNode(l,{rank:"same"}),s.reduce((c,u)=>(i.setEdge(c,u,{style:"invis"}),u))}),i}return Tb}var Nb,xN;function oQ(){return xN||(xN=1,Nb="1.1.8"),Nb}var Bb,DN;function iQ(){return DN||(DN=1,Bb={graphlib:vr(),layout:nQ(),debug:rQ(),util:{time:Ft().time,notime:Ft().notime},version:oQ()}),Bb}var sQ=iQ();const _N=Un(sQ),Fb=20,Ze=222,zo=Fb*15,of=Fb*10,Ps=Fb*3;function aQ(t,e){return PR(t,e)}function lQ(t,e){return LR(t,e)}function AN(t,e,n,r,o,i){const s=new Map(n.map(c=>[c.id,c])),a=e.filter(c=>c.source===t||c.target===t);return a.map(c=>{const u=c.source===t?c.target:c.source;return s.get(u)}).filter(c=>c!==void 0).filter(c=>!o.has(c.id)).filter(c=>{const u=a.find(f=>f.source===t&&f.target===c.id||f.target===t&&f.source===c.id);return u?$R(u,s.get(u.source),s.get(u.target),i)===r:!1})}function cQ(t,e){const n=[t,...e],r=Ze,o=Ze,i=n.length*o+(n.length-1)*Ps,s=r,a=t.position.y,c={x:t.position.x,y:a,width:s,height:i};return{parentId:t.id,childIds:e.map(u=>u.id),boundingBox:c}}function uQ(t,e){const n=Ze,r=Ze,o=Math.max(n,e.length*n+(e.length-1)*zo),i=r+Ps+r,s=t.position.y,l={x:t.position.x,y:s,width:o,height:i};return{parentId:t.id,childIds:e.map(c=>c.id),boundingBox:l}}function dQ(t,e,n){if(t.length===0)return{boundingBox:{x:0,y:0,width:0,height:0},nodes:[]};const r=fQ(t),i=AO(t)==="vertical",s={isMcpServerCanvas:SO(t)},a=[],l=[],c=new Set;t.forEach(S=>{if(aQ(S,s)&&!c.has(S.id)){const E=AN(S.id,e,t,"vertical",c,s);if(E.length>0){const x=cQ(S,E);a.push(x),c.add(S.id),E.forEach(O=>c.add(O.id))}}if(lQ(S,s)&&!c.has(S.id)){const E=AN(S.id,e,t,"horizontal",c,s);if(E.length>0){const x=uQ(S,E);l.push(x),c.add(S.id),E.forEach(O=>c.add(O.id))}}});const u=t.filter(S=>!c.has(S.id)),d=new _N.graphlib.Graph;d.setGraph({rankdir:i?"TB":"LR",edgesep:i?zo:of,nodesep:i?zo:of,ranksep:i?of:zo}),d.setDefaultEdgeLabel(()=>({})),u.forEach(S=>{const E=S.width||Ze,x=S.height||Ze;d.setNode(S.id,{width:E,height:x,x:S.position.x,y:S.position.y})}),a.forEach(S=>{const E=Ze+S.childIds.length*(Ze+Ps);d.setNode(S.parentId,{width:Ze,height:E})}),l.forEach(S=>{const E=Math.max(Ze,S.childIds.length*Ze+(S.childIds.length-1)*zo),x=Ze+Ps+Ze;d.setNode(S.parentId,{width:E,height:x})}),e.forEach(S=>{const E=[...a,...l],x=E.some(F=>F.parentId===S.source||F.childIds.includes(S.source)),O=E.some(F=>F.parentId===S.target||F.childIds.includes(S.target));if(x&&O){const F=E.find(P=>P.parentId===S.source||P.childIds.includes(S.source)),N=E.find(P=>P.parentId===S.target||P.childIds.includes(S.target));if(F===N)return}let A=S.source,T=S.target;const B=E.find(F=>F.childIds.includes(S.source));B&&(A=B.parentId);const I=E.find(F=>F.childIds.includes(S.target));I&&(T=I.parentId),d.hasNode(A)&&d.hasNode(T)&&d.setEdge(A,T)}),_N.layout(d);const f=[],p=[],m=[],v=[];u.forEach(S=>{if(d.hasNode(S.id)){const E=d.node(S.id);if(!E||typeof E.x!="number"||typeof E.y!="number"){console.warn(`Invalid layout data for regular node ${S.id}:`,E);return}const x={x:E.x-(E.width||Ze)/2,y:E.y-(E.height||Ze)/2,width:E.width||Ze,height:E.height||Ze};p.push({id:S.id,boundingBox:x}),m.push(x.y),v.push(x.x),f.push({id:S.id,x:x.x,y:x.y,width:x.width,height:x.height})}}),a.forEach(S=>{if(d.hasNode(S.parentId)){const E=d.node(S.parentId);if(!E||typeof E.x!="number"||typeof E.y!="number"){console.warn(`Invalid layout data for vertical group ${S.parentId}:`,E);return}const x=E.x,O=E.y,A=E.width||Ze,T=E.height||Ze,B=t.find(M=>M.id===S.parentId),I=t.filter(M=>S.childIds.includes(M.id));if(!B)return;const F=x-A/2,N=O-T/2,P={x:F,y:N,width:Ze,height:Ze};p.push({id:S.parentId,boundingBox:P}),m.push(P.y),v.push(P.x),f.push({id:S.parentId,x:P.x,y:P.y,width:P.width,height:P.height}),I.forEach((M,z)=>{const H=P.y+(z+1)*(Ze+Ps),R={x:P.x,y:H,width:Ze,height:Ze};p.push({id:M.id,boundingBox:R}),m.push(R.y),v.push(R.x),f.push({id:M.id,x:R.x,y:R.y,width:R.width,height:R.height})})}}),l.forEach(S=>{if(d.hasNode(S.parentId)){const E=d.node(S.parentId);if(!E||typeof E.x!="number"||typeof E.y!="number"){console.warn(`Invalid layout data for horizontal group ${S.parentId}:`,E);return}const x=E.x,O=E.y,A=E.width||Ze,T=E.height||Ze,B=t.find(R=>R.id===S.parentId),I=t.filter(R=>S.childIds.includes(R.id));if(!B)return;const F=x-A/2,N=O-T/2,P={x:F+(A-Ze)/2,y:N,width:Ze,height:Ze};p.push({id:S.parentId,boundingBox:P}),m.push(P.y),v.push(P.x),f.push({id:S.parentId,x:P.x,y:P.y,width:P.width,height:P.height});const M=P.y+Ze+Ps,z=I.length*Ze+(I.length-1)*zo,H=F+(A-z)/2;I.forEach((R,Y)=>{const $={x:H+Y*(Ze+zo),y:M,width:Ze,height:Ze};p.push({id:R.id,boundingBox:$}),m.push($.y),v.push($.x),f.push({id:R.id,x:$.x,y:$.y,width:$.width,height:$.height})})}});const b=20;function w(S,E){return Math.round(S/E)*E}[...new Set(m.map(S=>w(S,b)))].sort((S,E)=>S-E),[...new Set(v.map(S=>w(S,b)))].sort((S,E)=>S-E);const g=f.map(S=>{const E=a.some(O=>O.childIds.includes(S.id)),x=l.some(O=>O.childIds.includes(S.id));if(E){const O=a.find(T=>T.childIds.includes(S.id)),A=f.find(T=>T.id===(O==null?void 0:O.parentId));if(A)return{...S,x:w(A.x,b),y:w(S.y,b)}}return x?{...S,x:w(S.x,b),y:w(S.y,b)}:{...S,x:w(S.x,b),y:w(S.y,b)}}),C=p.length>0?ON(p.map(S=>S.boundingBox)):{x:0,y:0,width:0,height:0},k={x:C.x-r.x,y:C.y-r.y},_=g.map(S=>({...S,x:S.x-k.x,y:S.y-k.y}));return{boundingBox:C,nodes:_}}function fQ(t){if(t.length===0)return{x:0,y:0,width:0,height:0};const e=t.map(n=>({x:n.position.x,y:n.position.y,width:n.width||Ze,height:n.height||Ze}));return ON(e)}function ON(t){if(t.length===0)return{x:0,y:0,width:0,height:0};const{minX:e,minY:n,maxX:r,maxY:o}=t.reduce((i,s)=>{const{x:a,y:l,width:c,height:u}=s;return{minX:Math.min(i.minX,a),maxX:Math.max(i.maxX,a+c),minY:Math.min(i.minY,l),maxY:Math.max(i.maxY,l+u)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return{x:e,y:n,width:r-e,height:o-n}}const TN=t=>{const{getNodes:e,getEdges:n,fitView:r,setNodes:o}=ne.useReactFlow(),i=y.useCallback((l=Wd.ALL,c=!1)=>{const u=e(),d=n(),f=l==="selection"?u.filter(v=>v.selected):u;if(f.length===0)return console.log("没有节点需要布局"),{boundingBox:{x:0,y:0,width:0,height:0},nodes:[]};const p=dQ(f,d),m=u.map(v=>{const b=p.nodes.find(w=>w.id===v.id);return b?{...v,position:{x:b.x,y:b.y}}:v});return o(m),c&&setTimeout(()=>{r({padding:.1,includeHiddenNodes:!1,duration:200})},10),p},[e,n,o,r]),s=y.useCallback((l=!1)=>i(Wd.ALL,l),[i]),a=y.useCallback((l=!1)=>i(Wd.SELECTION,l),[i]);return{layout:i,autoLayout:s,layoutSelection:a}},hQ={HORIZONTAL_GAP:zo+100,VERTICAL_SPACING:of,INITIAL_X:100,MAIN_NODE_Y:300,X_PROXIMITY_THRESHOLD:50};function NN(t,e=hQ){const o=AO(t)==="vertical",i=t.filter(u=>!VR(u));if(o){const u=i.length>0?Math.max(...i.map(m=>m.position.y)):0,d=i[i.length-1],f=(d==null?void 0:d.position.x)??e.INITIAL_X,p=u+e.HORIZONTAL_GAP+Ze;return[f,p]}let s;i.length>0?s=Math.max(...i.map(d=>d.position.x))+e.HORIZONTAL_GAP:s=e.INITIAL_X;const a=e.MAIN_NODE_Y,c=t.filter(u=>Math.abs(u.position.x-s)<e.X_PROXIMITY_THRESHOLD).length*e.VERTICAL_SPACING;return[s,a+c]}const BN=()=>new Date().toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",second:"2-digit"});function pQ(t){if(t==null||t==="")return;const e=Number(t);return Number.isFinite(e)?e:void 0}function Mb(t){const e=t==null?void 0:t.data;if(!e)return null;const n=e.action_key??e.actionKey??e.nodeKey??e.node_key;if(typeof n!="string"||!n.trim())return null;const r=pQ(e.action_ver??e.nodeVersion??e.node_version),o=Wi(n.trim(),r);return o?RI(o,e):null}function Nl(t){return!!(t&&po(t.data))}function FN({sourceNode:t,targetNode:e,sourceHandle:n,targetHandle:r,edges:o=[]}){const i=Nl(t),s=Nl(e);if(!i&&!s)return{applicable:!1,valid:!0,code:"NOT_APPLICABLE",reason:""};const a=i?Mb(t):null,l=s?Mb(e):null;if(i&&!a||s&&!l)return{applicable:!0,valid:!1,code:"SCHEMA_NOT_READY",reason:"节点端口 Schema 尚未就绪,请稍后重试",missingSchemaNodeIds:[i&&!a?t==null?void 0:t.id:null,s&&!l?e==null?void 0:e.id:null].filter(d=>!!d)};const c=mR({sourceNode:t,targetNode:e,sourceHandle:n,targetHandle:r,sourcePorts:(a==null?void 0:a.outputs)??(n?[{name:n,type:"main",protocol:"main"}]:[]),targetPorts:(l==null?void 0:l.inputs)??(r?[{name:r,type:"main",protocol:"main"}]:[]),edges:o});return{applicable:!0,valid:c.valid,code:c.code,reason:c.reason}}function mQ({edge:t,nodes:e,edges:n,connectable:r,validators:o=[],nativeIsValidConnection:i}){const s=e.find(c=>c.id===t.source),a=e.find(c=>c.id===t.target);if((r==null?void 0:r.enabled)===!0){const c=FN({sourceNode:s,targetNode:a,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle,edges:n});if(c.applicable&&!c.valid)return r.debug&&console.warn("[workflow:connectable] reject canvas connection",{edge:t,code:c.code,reason:c.reason}),!1}const l={nodes:e.reduce((c,u)=>{var d;return c[u.id]={id:u.id,type:u.type||"",position:u.position,data:u.data,disabled:((d=u.data)==null?void 0:d.closed)==="1"},c},{}),edges:n.map(c=>({id:c.id,source:c.source,target:c.target,sourceHandle:c.sourceHandle,targetHandle:c.targetHandle,data:c.data}))};try{return!(!o.every(c=>c(t,l))||i&&!i(t))}catch(c){return console.error("边校验函数执行异常",c),!1}}function gQ(t,e){var kr,vn,un,Hn;const{workflowId:n,onInit:r}=t,o=Ms(),{setLocked:i,op_status:s}=ao(),a=Ot(),[l,c]=y.useState(!1),[u,d]=y.useState(!1),f=$t(),p=ne.useReactFlow(),{autoLayout:m}=TN(),[v,b]=y.useState(!0),w=Ah(na()),g=s===er.ONLINE||s===er.ON_WARN,C=y.useMemo(()=>!w&&f.canvas.miniMap,[w,f.canvas.miniMap]),k=y.useMemo(()=>!w&&f.canvas.controls,[w,f.canvas.controls]),_=y.useMemo(()=>!w&&f.canvas.header,[f.canvas.header,w]),S=y.useMemo(()=>{var Oe;return(Oe=f.canvas.grid)==null?void 0:Oe.enabled},[(kr=f.canvas.grid)==null?void 0:kr.enabled]),E=y.useMemo(()=>a&&!w&&f.canvas.fastOperationButtons,[a,w,f.canvas.fastOperationButtons]);kJ({enabled:!w&&l});const x=w||v||!a,O=y.useCallback(Oe=>{requestAnimationFrame(()=>{const Me=p.getNode(Oe);Me&&p.fitView({nodes:[Me],padding:.4,duration:300,maxZoom:1})})},[p]),[A,T]=y.useState($n.IDLE),[B,I]=y.useState(""),{setFlowOpStatusAction:F,setNodeConfigVisible:N}=ao(n),{addNodes:P,addEdges:M}=aa(),{removeEdges:z,onConnect:H,handleEdgesChange:R}=Pw(),Y=ne.useStoreApi(),te=Is(Oe=>Oe.workflow.refreshWorkFlowNum),[$,j]=ne.useNodesState([]),[U,ee]=ne.useEdgesState([]),[ie,be]=y.useState(null),W=y.useCallback(Oe=>{var Ye;let Me=null;for(const Xe of Oe)if(Oh(Xe)){Me={id:Xe.id,isMcpServer:Xe.type.startsWith(`${Gd}@`)||((Ye=Xe.data)==null?void 0:Ye.action_key)===Gd};break}be(Xe=>(Xe==null?void 0:Xe.id)===(Me==null?void 0:Me.id)&&(Xe==null?void 0:Xe.isMcpServer)===(Me==null?void 0:Me.isMcpServer)?Xe:Me)},[]),X=y.useCallback(Oe=>{if(typeof Oe=="function"){j(Me=>{const Ye=Oe(Me);return W(Ye),Ye});return}j(Oe),W(Oe)},[j,W]),[q,J]=y.useState(void 0),[re,Z]=y.useState(void 0),ue=y.useCallback(Oe=>{var Sr,Uo;if(!Oe)return!0;const Me=(Sr=f.canvas)==null?void 0:Sr.selectable;if(!Me)return!0;const{includeNodeIds:Ye,includeCategories:Xe}=Me;if((!Ye||Ye.length===0)&&(!Xe||Xe.length===0))return!0;const Vn=Y.getState().nodes.find(Ul=>Ul.id===Oe);if(!Vn)return!0;const Wo=(Uo=Vn.data)==null?void 0:Uo.category;return!!(Ye&&Ye.includes(Oe)||Xe&&Wo&&Xe.includes(Wo))},[(vn=f.canvas)==null?void 0:vn.selectable,Y]),ve=y.useCallback((Oe,Me)=>{if(J(void 0),Z(void 0),Oe.length===1&&Oe[0].type==="position"&&Oe[0].dragging&&Oe[0].position){const Ye=CJ(Oe[0],Me);Oe[0].position.x=Ye.snapPosition.x??Oe[0].position.x,Oe[0].position.y=Ye.snapPosition.y??Oe[0].position.y,J(Ye.horizontal),Z(Ye.vertical)}return Oe},[]),we=y.useCallback(Oe=>{R(Oe),Oe.some(Ye=>!["select","replace"].includes(Ye.type))&&c(!0)},[R]),fe=y.useCallback(Oe=>{const Me=Y.getState().nodes,Ye=Oe.map(et=>et.type==="position"&&!ue(et.id)?null:et.type==="select"&&!ue(et.id)?{...et,selected:!1}:et).filter(et=>et!==null);ve(Ye,Me);const Xe=fa(Me,et=>{const Vn=ne.applyNodeChanges(Ye,et);et.splice(0,Vn.length,...Vn),et.splice(Vn.length)});X(Xe),Ye.some(et=>(et==null?void 0:et.type)==="dimensions"&&et.resizing?!0:!["select","replace","dimensions"].includes(et==null?void 0:et.type))&&c(!0)},[ue,X,Y,ve]),{onEdgeMouseEnter:le,onEdgeMouseLeave:Se}=Pw(),{onNodeMouseEnter:ce,onNodeMouseLeave:Fe,autoSaveNum:Ve}=cw(),je=y.useCallback((Oe,Me)=>{T(Oe),Oe===$n.SAVED?I(BN()):Oe===$n.ERROR&&Me&&console.error("保存失败:",Me)},[]),{setNodeAddCallback:We,openNodeSelector:ht,handleManualAdd:Ee}=dc();Et.useUnmount(()=>{o(Mw()),ee([]),X([])});const Ce=y.useRef(async()=>{}),Le=y.useCallback(Oe=>{var Xe;if(Oe.defaultPrevented)return;const Me=Oe.target,Ye=(Xe=Me==null?void 0:Me.tagName)==null?void 0:Xe.toLowerCase();Ye==="input"||Ye==="textarea"||Me!=null&&Me.isContentEditable||Oe.altKey&&Oe.shiftKey&&Oe.code==="KeyD"&&(Oe.preventDefault(),d(et=>!et))},[]);y.useEffect(()=>(window.addEventListener("keydown",Le),()=>{window.removeEventListener("keydown",Le)}),[Le]);const Mt=f.canvas.nativeProps||{},{isValidConnection:St,onNodeContextMenu:jr,onPaneContextMenu:lo,...Ws}=Mt,co=y.useCallback((Oe,Me,Ye)=>{var Xe,et;return mQ({edge:Oe,nodes:Me,edges:Ye,connectable:(Xe=f.nodeSelector)==null?void 0:Xe.connectable,validators:(et=f.edgeRules)==null?void 0:et.validators,nativeIsValidConnection:St})},[(un=f.edgeRules)==null?void 0:un.validators,(Hn=f.nodeSelector)==null?void 0:Hn.connectable,St]),jo=y.useCallback(Oe=>{const{nodes:Me,edges:Ye}=Y.getState();return co(Oe,Me,Ye)},[Y,co]),Us=y.useCallback(Oe=>{!Oe.source||!Oe.target||(H(Oe),c(!0))},[H,Y]),Df=y.useCallback((Oe,Me)=>{f.edgeRules&&f.edgeRules.allowAddNodeOnEdge===!1||ht({position:Oe,edge:Me})},[ht,f.edgeRules]),uv=y.useCallback(Oe=>{const{protocol:Me}=Oe||{},{nodes:Ye}=Y.getState();if(ie){const Xe=NN(Ye);ht({position:{x:Xe[0],y:Xe[1]},protocol:Me})}else ht({trigger:!0,protocol:Me})},[ht,Y,ie]),dv=y.useCallback(()=>{const{nodes:Oe}=Y.getState();let Me;const Ye=Oe.find(Xe=>Xe.selected&&Xe.type!==pe.STICKY);Ye?Me=[Ye.position.x,Ye.position.y-80]:Me=NN(Oe),Ee({position:{x:Me[0],y:Me[1]}},{action_type:pe.STICKY,type:pe.STICKY,id:e,nodeId:e,name:"便签",action_name:"便签",connector_name:"",description:""})},[Ee,e,Y]),fv=y.useCallback(()=>{m()},[m]),{canvasApi:It}=yJ({workflowId:n,dispatch:o,reactFlow:p,setEdges:ee,setNodes:X,store:Y,setNodeConfigVisible:N,saveFlowRef:Ce});y.useEffect(()=>{r&&r(It)},[r,It]);const wn=y.useCallback((Oe,Me)=>{Oe.ctrlKey&&Oe.preventDefault(),jr==null||jr(Oe,Me)},[jr]),bn=y.useCallback(Oe=>{Oe.ctrlKey&&Oe.preventDefault(),lo==null||lo(Oe)},[lo]);return{nodes:$,edges:U,setNodes:X,setEdges:ee,unSave:l,setUnSave:c,triggerNode:ie,hasTriggerNode:ie!==null,isMcpServerCanvas:(ie==null?void 0:ie.isMcpServer)??!1,loading:v,setLoading:b,debugVisible:u,setDebugVisible:d,autoSaveStatus:A,lastSavedTime:B,helperLineHorizontal:q,helperLineVertical:re,isPreviewMode:w,isInteractionDisabled:x,isOnline:g,showMiniMap:C,showControls:k,showCanvasHeader:_,showBackground:S,showFastOperationButtons:E,onNodesChange:fe,handleEdgesChange:we,handleConnect:Us,isValidConnection:jo,validateConnectionAgainstSnapshot:co,handleEdgeAddNode:Df,handleOpenNodeSelector:uv,handleAddNoteNode:dv,handleTidy:fv,onEdgeMouseEnter:le,onEdgeMouseLeave:Se,onNodeMouseEnter:ce,onNodeMouseLeave:Fe,onNodeContextMenu:wn,onPaneContextMenu:bn,updateSaveStatus:je,setNodeFitHumanView:O,canvasApi:It,reactFlow:p,dispatch:o,store:Y,refreshWorkFlowNum:te,addNodes:P,addEdges:M,removeEdges:z,setNodeAddCallback:We,setNodeConfigVisible:N,setFlowOpStatusAction:F,autoSaveNum:Ve,setLocked:i,openNodeSelector:ht,handleManualAdd:Ee,restNativeProps:Ws,saveFlowRef:Ce}}const wQ=(t,e="normal")=>{var o;if(t.type===pe.STICKY)return e==="lighter"?"rgba(0,0,0,.5)":"rgb(206, 226, 164)";switch((o=t.data)==null?void 0:o.status){case me.INVALID:return e==="lighter"?"#F2C000":"#FDF6D5";case me.FAILED:return e==="lighter"?"#FA170A":"#FF918B";case me.SUCCESS:case me.RUNNABLE:return e==="lighter"?"#2EC04F":"#8CDF3A";case me.RUNNING:return e==="lighter"?"#007AFF":"#D9EBFF";default:return e==="lighter"?"#51A4F6":"#00c3ff"}};function bQ(t){const e=n=>wQ(n);return h.jsx(ne.MiniMap,{style:{display:"flex",flexDirection:"row"},nodeStrokeColor:e,nodeStrokeWidth:3,pannable:!0,zoomable:!0,nodeColor:e,nodeBorderRadius:3,...t})}const vQ=200,sf=150,Bl=44,MN=t=>{try{return JSON.stringify(t)}catch(e){return String(e)}},Ib=t=>({id:t.id,type:t.type,position:t.position,data:t.data}),Pb=t=>({id:t.id,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle,data:t.data}),Bi=t=>{if(!t)return"";const e=t.data,n=(e==null?void 0:e.backendData)||void 0,r=(n==null?void 0:n.properties)||void 0;return(r==null?void 0:r.display_name)||(e==null?void 0:e.label)||(e==null?void 0:e.action_name)||(e==null?void 0:e.name)||t.id},yQ=t=>t.replace(/[^a-zA-Z0-9_]/g,"_"),CQ=(t,e,n,r)=>{const o=new Map;t.forEach((l,c)=>{const u=yQ(l.id||`node_${c}`);o.set(l.id,u)});const i=["flowchart LR"];t.forEach(l=>{const c=o.get(l.id);if(!c)return;const u=`${l.id} ${Bi(l)}`.replace(/"/g,"'");i.push(` ${c}["${u}"]`)});const s=[];let a=0;return e.forEach(l=>{const c=o.get(l.source),u=o.get(l.target);!c||!u||(i.push(` ${c} --> ${u}`),r.has(l.id)&&s.push(a),a+=1)}),s.forEach(l=>{i.push(` linkStyle ${l} stroke:#cf1322,stroke-width:2px`)}),i.join(`
|
|
139
139
|
`)},kQ=t=>`${t.source}__${t.target}__${t.sourceHandle||""}__${t.targetHandle||""}`,IN=(t,e)=>t.map(n=>{const r=e.get(n.source)||n.source,o=e.get(n.target)||n.target;return`${n.source}(${r}) -> ${n.target}(${o})`}),PN=(t,e)=>{const n=new Map;t.forEach(o=>{const i=kQ(o),s=n.get(i)||[];s.push(o),n.set(i,s)});const r=[];return n.forEach((o,i)=>{if(o.length<=1)return;const s=o[0],a=e.get(s.source)||s.source,l=e.get(s.target)||s.target;r.push({key:i,relation:`${s.source}(${a}) -> ${s.target}(${l})`,edgeIds:o.map(c=>c.id)})}),r},LN=(t,e)=>{if(!t.length)return{levels:[],unvisited:[]};const n=new Map(t.map(f=>[f.id,f])),r=new Map,o=new Map;t.forEach(f=>{r.set(f.id,[]),o.set(f.id,0)}),e.forEach(f=>{var p;!n.has(f.source)||!n.has(f.target)||((p=r.get(f.source))==null||p.push(f.target),o.set(f.target,(o.get(f.target)||0)+1))});const i=t.filter(f=>f.type==="TRIGGER"||(o.get(f.id)||0)===0),s=[],a=new Map;if(i.length)i.forEach(f=>{s.push({id:f.id,level:0}),a.set(f.id,0)});else{const f=t[0];s.push({id:f.id,level:0}),a.set(f.id,0)}const l=new Set;for(;s.length;){const f=s.shift();if(!f)break;if(l.has(f.id))continue;l.add(f.id),(r.get(f.id)||[]).forEach(m=>{a.has(m)||a.set(m,f.level+1),s.push({id:m,level:f.level+1})})}const c=new Map;a.forEach((f,p)=>{const m=n.get(p);if(!m)return;const v=c.get(f)||[];v.push(m),c.set(f,v)});const u=Array.from(c.entries()).sort((f,p)=>f[0]-p[0]).map(([f,p])=>({level:f,nodes:p})),d=t.filter(f=>!l.has(f.id));return{levels:u,unvisited:d}},SQ=(t,e)=>{const{levels:n,unvisited:r}=LN(t,e),o=sf,i=Bl,s=200,a=90,l=[],c=e.map(m=>({id:m.id,source:m.source,target:m.target})).filter(m=>t.some(v=>v.id===m.source)&&t.some(v=>v.id===m.target));let u=-1;n.forEach(m=>{m.level>u&&(u=m.level)});const d=[...n];r.length&&d.push({level:u+1,nodes:r}),d.forEach(m=>{const v=m.level*s;m.nodes.forEach((b,w)=>{const g=w*(i+a),C=`${b.id} (${Bi(b)})`;l.push({id:b.id,label:C,x:v,y:g})})});const f=Math.max(...l.map(m=>m.x),0),p=Math.max(...l.map(m=>m.y),0);return{nodes:l,edges:c,width:f+o+s,height:p+i+a}},$N=t=>t.length?t.map(e=>{const n=e.detail?JSON.stringify(e.detail,null,2):"";return`[${e.time}] ${e.message}${n?`
|
|
140
140
|
${n}`:""}`}).join(`
|
|
141
141
|
|