@digitalsee-ai/rcs 2.0.0-beta12 → 2.0.0-beta13
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/rcs.umd.js
CHANGED
|
@@ -49,7 +49,7 @@ The error may be correlated with this previous error:
|
|
|
49
49
|
`.concat(r.current.stack,`
|
|
50
50
|
|
|
51
51
|
`)),c}o.current=t,i.current=s,r.current=void 0;var l=y.useCallback(()=>{try{var c=o.current();if(e(i.current,c))return;i.current=c}catch(u){u instanceof Error?r.current=u:r.current=new Error(String(u))}n()},[]);return[s,l]}function Pj(t){return t instanceof Error}var c_=y.createContext({}),u_=(t,e)=>{var n=wr(),{decorate:r,addEventListener:o}=y.useContext(c_),i=()=>{var c=ye.findPath(n,t);return r([t,c])},s=Le.isText(t)?zD:Mg,[a,l]=l_(i,s);return Lr(()=>{var c=o(l);return l(),c},[o,l]),y.useMemo(()=>[...a,...e],[a,e])},Lj=t=>{var e=y.useRef(new Set),n=y.useRef(t);Lr(()=>{n.current=t,e.current.forEach(i=>i())},[t]);var r=y.useCallback(i=>n.current(i),[]),o=y.useCallback(i=>(e.current.add(i),()=>{e.current.delete(i)}),[]);return y.useMemo(()=>({decorate:r,addEventListener:o}),[r,o])};function d_(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function f_(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?d_(Object(n),!0).forEach(function(r){bt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):d_(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var $j=t=>y.createElement(Hj,f_({},t)),zj=t=>{for(var{decorations:e,isLast:n,parent:r,renderPlaceholder:o,renderLeaf:i,renderText:s=$j,text:a}=t,l=wr(),c=y.useRef(null),u=u_(a,e),d=Le.decorations(a,u),f=ye.findKey(l,a),p=[],m=0;m<d.length;m++){var{leaf:b,position:v}=d[m];p.push(y.createElement(Mj,{isLast:n&&m===d.length-1,key:"".concat(f.id,"-").concat(m),renderPlaceholder:o,leaf:b,leafPosition:v,text:a,parent:r,renderLeaf:i}))}var w=y.useCallback(C=>{var S=gd.get(l);C?(S==null||S.set(f,C),wi.set(a,C),pl.set(C,a)):(S==null||S.delete(f),wi.delete(a),c.current&&pl.delete(c.current)),c.current=C},[c,l,f,a]),g={"data-slate-node":"text",ref:w};return s({text:a,children:p,attributes:g})},h_=y.memo(zj,(t,e)=>e.parent===t.parent&&e.isLast===t.isLast&&e.renderText===t.renderText&&e.renderLeaf===t.renderLeaf&&e.renderPlaceholder===t.renderPlaceholder&&e.text===t.text&&zD(e.decorations,t.decorations)),Hj=t=>{var{attributes:e,children:n}=t;return y.createElement("span",f_({},e),n)};function p_(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Vg(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?p_(Object(n),!0).forEach(function(r){bt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):p_(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var Vj=t=>y.createElement(Uj,Vg({},t)),jj=t=>{var{decorations:e,element:n,renderElement:r=Vj,renderChunk:o,renderPlaceholder:i,renderLeaf:s,renderText:a}=t,l=wr(),c=e7(),u=l.isInline(n),d=u_(n,e),f=ye.findKey(l,n),p=y.useCallback(S=>{var k=gd.get(l);S?(k==null||k.set(f,S),wi.set(n,S),pl.set(S,n)):(k==null||k.delete(f),wi.delete(n))},[l,f,n]),m=y_({decorations:d,node:n,renderElement:r,renderChunk:o,renderPlaceholder:i,renderLeaf:s,renderText:a}),b={"data-slate-node":"element",ref:p};if(u&&(b["data-slate-inline"]=!0),!u&&L.hasInlines(l,n)){var v=ke.string(n),w=Gx(v);w==="rtl"&&(b.dir=w)}if(L.isVoid(l,n)){b["data-slate-void"]=!0,!c&&u&&(b.contentEditable=!1);var g=u?"span":"div",[[C]]=ke.texts(n);m=y.createElement(g,{"data-slate-spacer":!0,style:{height:"0",color:"transparent",outline:"none",position:"absolute"}},y.createElement(h_,{renderPlaceholder:i,decorations:[],isLast:!1,parent:n,text:C})),Ss.set(C,0),fl.set(C,n)}return r({attributes:b,children:m,element:n})},Wj=y.memo(jj,(t,e)=>t.element===e.element&&t.renderElement===e.renderElement&&t.renderChunk===e.renderChunk&&t.renderText===e.renderText&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&Mg(t.decorations,e.decorations)),Uj=t=>{var{attributes:e,children:n,element:r}=t,o=wr(),i=o.isInline(r)?"span":"div";return y.createElement(i,Vg(Vg({},e),{},{style:{position:"relative"}}),n)};class qj{constructor(e,n){var{chunkSize:r,debug:o}=n;bt(this,"root",void 0),bt(this,"chunkSize",void 0),bt(this,"debug",void 0),bt(this,"reachedEnd",void 0),bt(this,"pointerChunk",void 0),bt(this,"pointerIndex",void 0),bt(this,"pointerIndexStack",void 0),bt(this,"cachedPointerNode",void 0),this.root=e,this.chunkSize=r,this.debug=o??!1,this.pointerChunk=e,this.pointerIndex=-1,this.pointerIndexStack=[],this.reachedEnd=!1,this.validateState()}readLeaf(){if(this.reachedEnd)return null;for(;;)if(this.pointerIndex+1<this.pointerSiblings.length){this.pointerIndex++,this.cachedPointerNode=void 0;break}else{if(this.pointerChunk.type==="root")return this.reachedEnd=!0,null;this.exitChunk()}return this.validateState(),this.enterChunkUntilLeaf(!1),this.pointerNode}returnToPreviousLeaf(){if(this.reachedEnd){this.reachedEnd=!1,this.enterChunkUntilLeaf(!0);return}for(;;)if(this.pointerIndex>=1){this.pointerIndex--,this.cachedPointerNode=void 0;break}else if(this.pointerChunk.type==="root"){this.pointerIndex=-1;return}else this.exitChunk();this.validateState(),this.enterChunkUntilLeaf(!0)}insertBefore(e){this.returnToPreviousLeaf(),this.insertAfter(e),this.readLeaf()}insertAfter(e){if(e.length!==0){for(var n=0,r=0;this.pointerChunk.type==="chunk"&&this.pointerIndex===this.pointerSiblings.length-1;){var o=this.chunkSize-this.pointerSiblings.length,i=Math.min(o,e.length);if(i>0){var s=e.splice(0,i);this.rawInsertAfter(s,n)}this.exitChunk(),n++}if(e.length!==0){var a=this.savePointer(),l=null;if(this.readLeaf())for(;this.pointerChunk.type==="chunk"&&this.pointerIndex===0;){var c=this.chunkSize-this.pointerSiblings.length,u=Math.min(c,e.length);if(u>0){var d=e.splice(-u,u);this.pointerIndex=-1,this.cachedPointerNode=void 0,this.rawInsertAfter(d,r),l||(l=this.savePointer())}this.exitChunk(),r++}this.restorePointer(a);var f=Math.max(n,r);this.rawInsertAfter(e,f),l&&this.restorePointer(l),this.validateState()}}}remove(){this.pointerSiblings.splice(this.pointerIndex--,1),this.cachedPointerNode=void 0,this.pointerSiblings.length===0&&this.pointerChunk.type==="chunk"?(this.exitChunk(),this.remove()):this.invalidateChunk(),this.validateState()}invalidateChunk(){for(var e=this.pointerChunk;e.type==="chunk";e=e.parent)this.root.modifiedChunks.add(e)}get atStart(){return this.pointerChunk.type==="root"&&this.pointerIndex===-1}get pointerSiblings(){return this.pointerChunk.children}getPointerNode(){return this.reachedEnd||this.pointerIndex===-1?null:this.pointerSiblings[this.pointerIndex]}get pointerNode(){if(this.cachedPointerNode!==void 0)return this.cachedPointerNode;var e=this.getPointerNode();return this.cachedPointerNode=e,e}getChunkPath(e){for(var n=[],r=e;r.type==="chunk";r=r.parent){var o=r.parent.children.indexOf(r);if(o===-1)return null;n.unshift(o)}return n}savePointer(){if(this.atStart)return"start";if(!this.pointerNode)throw new Error("Cannot save pointer when pointerNode is null");return{chunk:this.pointerChunk,node:this.pointerNode}}restorePointer(e){if(e==="start"){this.pointerChunk=this.root,this.pointerIndex=-1,this.pointerIndexStack=[],this.reachedEnd=!1,this.cachedPointerNode=void 0;return}var{chunk:n,node:r}=e,o=n.children.indexOf(r);if(o===-1)throw new Error("Cannot restore point because saved node is no longer in saved chunk");var i=this.getChunkPath(n);if(!i)throw new Error("Cannot restore point because saved chunk is no longer connected to root");this.pointerChunk=n,this.pointerIndex=o,this.pointerIndexStack=i,this.reachedEnd=!1,this.cachedPointerNode=r,this.validateState()}enterChunk(e){var n;if(((n=this.pointerNode)===null||n===void 0?void 0:n.type)!=="chunk")throw new Error("Cannot enter non-chunk");if(this.pointerIndexStack.push(this.pointerIndex),this.pointerChunk=this.pointerNode,this.pointerIndex=e?this.pointerSiblings.length-1:0,this.cachedPointerNode=void 0,this.validateState(),this.pointerChunk.children.length===0)throw new Error("Cannot enter empty chunk")}enterChunkUntilLeaf(e){for(;((n=this.pointerNode)===null||n===void 0?void 0:n.type)==="chunk";){var n;this.enterChunk(e)}}exitChunk(){if(this.pointerChunk.type==="root")throw new Error("Cannot exit root");var e=this.pointerChunk;this.pointerChunk=e.parent,this.pointerIndex=this.pointerIndexStack.pop(),this.cachedPointerNode=void 0,this.validateState()}rawInsertAfter(e,n){if(e.length!==0){for(var r=(u,d,f)=>{if(f===1)return u;for(var p=[],m=0;m<this.chunkSize;m++){var b=u.slice(m*f,(m+1)*f);if(b.length===0)break;var v={type:"chunk",key:new SD,parent:d,children:[]};v.children=r(b,v,f/this.chunkSize),p.push(v)}return p},o=this.pointerSiblings.length+e.length,i=0,s=this.chunkSize;s<o;s*=this.chunkSize)i++;var a=Math.max(i,n),l=Math.pow(this.chunkSize,a),c=r(e,this.pointerChunk,l);this.pointerSiblings.splice(this.pointerIndex+1,0,...c),this.pointerIndex+=c.length,this.cachedPointerNode=void 0,this.invalidateChunk(),this.validateState()}}validateState(){if(this.debug){var e=r=>{if(r.type==="chunk"){var{parent:o,children:i}=r;if(!o.children.includes(r))throw new Error("Debug: Chunk ".concat(r.key.id," has an incorrect parent property"));i.forEach(e)}};if(this.root.children.forEach(e),this.cachedPointerNode!==void 0&&this.cachedPointerNode!==this.getPointerNode())throw new Error("Debug: The cached pointer is incorrect and has not been invalidated");var n=this.getChunkPath(this.pointerChunk);if(!n)throw new Error("Debug: The pointer chunk is not connected to the root");if(!q.equals(this.pointerIndexStack,n))throw new Error("Debug: The cached index stack [".concat(this.pointerIndexStack.join(", "),"] does not match the path of the pointer chunk [").concat(n.join(", "),"]"))}}}class Gj{constructor(e,n){bt(this,"editor",void 0),bt(this,"children",void 0),bt(this,"cachedKeys",void 0),bt(this,"pointerIndex",void 0),this.editor=e,this.children=n,this.cachedKeys=new Array(n.length),this.pointerIndex=0}read(e){if(e===1)return[this.children[this.pointerIndex++]];var n=this.remaining(e);return this.pointerIndex+=e,n}remaining(e){return e===void 0?this.children.slice(this.pointerIndex):this.children.slice(this.pointerIndex,this.pointerIndex+e)}get reachedEnd(){return this.pointerIndex>=this.children.length}lookAhead(e,n){var r=this.children.indexOf(e,this.pointerIndex);if(r>-1)return r-this.pointerIndex;for(var o=this.pointerIndex;o<this.children.length;o++){var i=this.children[o],s=this.findKey(i,o);if(s===n)return o-this.pointerIndex}return-1}toChunkLeaves(e,n){return e.map((r,o)=>({type:"leaf",node:r,key:this.findKey(r,n+o),index:n+o}))}findKey(e,n){var r=this.cachedKeys[n];if(r)return r;var o=ye.findKey(this.editor,e);return this.cachedKeys[n]=o,o}}var Rj=(t,e)=>{var{chunkTree:n,children:r,chunkSize:o,rerenderChildren:i=[],onInsert:s,onUpdate:a,onIndexChange:l,debug:c}=e;n.modifiedChunks.clear();for(var u=new qj(n,{chunkSize:o,debug:c}),d=new Gj(t,r),f,p=function(){var w=d.lookAhead(f.node,f.key),g=w>0&&n.movedNodeKeys.has(f.key);if(w===-1||g)return u.remove(),1;var C=d.pointerIndex,S=d.read(w+1),k=S.pop();if(S.length){var x=d.toChunkLeaves(S,C);u.insertBefore(x),S.forEach((E,O)=>{s==null||s(E,C+O)})}var D=d.pointerIndex-1;f.node!==k&&(f.node=k,u.invalidateChunk(),a==null||a(k,D)),f.index!==D&&(f.index=D,l==null||l(k,D)),i.includes(D)&&u.invalidateChunk()};f=u.readLeaf();)p();if(!d.reachedEnd){var m=d.remaining(),b=d.toChunkLeaves(m,d.pointerIndex);u.returnToPreviousLeaf(),u.insertAfter(b),m.forEach((v,w)=>{s==null||s(v,d.pointerIndex+w)})}n.movedNodeKeys.clear()};function m_(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Kj(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?m_(Object(n),!0).forEach(function(r){bt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):m_(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var g_=new WeakMap,w_=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=ye.findKey(e,n),i=g_.get(o);return i||(i={type:"root",movedNodeKeys:new Set,modifiedChunks:new Set,children:[]},g_.set(o,i)),r.reconcile&&Rj(e,Kj({chunkTree:i,children:n.children},r.reconcile)),i},Yj=t=>{var{children:e}=t;return e},b_=t=>{var{root:e,ancestor:n,renderElement:r,renderChunk:o=Yj}=t;return n.children.map(i=>{if(i.type==="chunk"){var s=i.key.id,a=o({highest:n===e,lowest:i.children.some(c=>c.type==="leaf"),attributes:{"data-slate-chunk":!0},children:y.createElement(Jj,{root:e,ancestor:i,renderElement:r,renderChunk:o})});return y.createElement(y.Fragment,{key:s},a)}var l=i.node;return r(l,i.index,i.key)})},Xj=b_,Jj=y.memo(b_,(t,e)=>t.root===e.root&&t.renderElement===e.renderElement&&t.renderChunk===e.renderChunk&&!e.root.modifiedChunks.has(e.ancestor)),v_=y.createContext(null),Qj=()=>y.useContext(v_),y_=t=>{var{decorations:e,node:n,renderElement:r,renderChunk:o,renderPlaceholder:i,renderText:s,renderLeaf:a}=t,l=wr();ks.set(l,!1);var c=L.isEditor(n),u=!c&&ze.isElement(n)&&!l.isInline(n),d=u&&L.hasInlines(l,n),f=d?null:l.getChunkSize(n),p=!!f,{decorationsByChild:m,childrenToRedecorate:b}=Zj(l,n,e);p||n.children.forEach((C,S)=>{Ss.set(C,S),fl.set(C,n)});var v=y.useCallback((C,S,k)=>{var x=k??ye.findKey(l,C);return y.createElement(v_.Provider,{key:"provider-".concat(x.id),value:C},y.createElement(Wj,{decorations:m[S],element:C,key:x.id,renderElement:r,renderChunk:o,renderPlaceholder:i,renderLeaf:a,renderText:s}))},[l,m,r,o,i,a,s]),w=(C,S)=>{var k=ye.findKey(l,C);return y.createElement(h_,{decorations:m[S],key:k.id,isLast:S===n.children.length-1,parent:n,renderPlaceholder:i,renderLeaf:a,renderText:s,text:C})};if(!p)return n.children.map((C,S)=>Le.isText(C)?w(C,S):v(C,S));var g=w_(l,n,{reconcile:{chunkSize:f,rerenderChildren:b,onInsert:(C,S)=>{Ss.set(C,S),fl.set(C,n)},onUpdate:(C,S)=>{Ss.set(C,S),fl.set(C,n)},onIndexChange:(C,S)=>{Ss.set(C,S)}}});return y.createElement(Xj,{root:g,ancestor:g,renderElement:v,renderChunk:o})},Zj=(t,e,n)=>{var r=q9(t,e,n),o=y.useRef(r).current,i=[];o.length=r.length;for(var s=0;s<r.length;s++){var a,l=r[s],c=(a=o[s])!==null&&a!==void 0?a:null;Mg(c,l)||(o[s]=l,i.push(s))}return{decorationsByChild:o,childrenToRedecorate:i}},C_=y.createContext(!1),e7=()=>y.useContext(C_),Sd=y.createContext({}),t7=(t,e)=>t===e;function n7(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:t7,{deferred:n}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=y.useContext(Sd);if(!r)throw new Error("The `useSlateSelector` hook must be used inside the <Slate> component's context.");var{addEventListener:o}=r,i=wr(),s=y.useCallback(()=>t(i),[i,t]),[a,l]=l_(s,e);return Lr(()=>{var c=o(l,{deferred:n});return l(),c},[o,l,n]),a}function r7(){var t=y.useRef(new Set),e=y.useRef(new Set),n=y.useCallback(()=>{t.current.forEach(s=>s())},[]),r=y.useCallback(()=>{e.current.forEach(s=>s()),e.current.clear()},[]),o=y.useCallback(function(s){var{deferred:a=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=a?()=>e.current.add(s):s;return t.current.add(l),()=>{t.current.delete(l)}},[]),i=y.useMemo(()=>({addEventListener:o,flushDeferred:r}),[o,r]);return{selectorContext:i,onChange:n}}function o7(){var{flushDeferred:t}=y.useContext(Sd);Lr(t)}var i7=()=>{var{addEventListener:t}=y.useContext(Sd),[,e]=y.useReducer(n=>n+1,0);if(!t)throw new Error("The `useSlate` hook must be used inside the <Slate> component's context.");return Lr(()=>t(e),[t]),wr()};function s7(){var t=wr(),e=y.useRef(!1),n=y.useRef(0),r=y.useCallback(()=>{if(!e.current){e.current=!0;var o=ye.getWindow(t);o.cancelAnimationFrame(n.current),n.current=o.requestAnimationFrame(()=>{e.current=!1})}},[t]);return y.useEffect(()=>()=>cancelAnimationFrame(n.current),[]),{receivedUserInput:e,onUserInput:r}}var a7=(t,e)=>{var n=[],r=()=>{n=[]},o=s=>{if(e.current){var a=s.filter(l=>Sg(t,l,s));n.push(...a)}};function i(){n.length>0&&(n.reverse().forEach(s=>{s.type!=="characterData"&&(s.removedNodes.forEach(a=>{s.target.insertBefore(a,s.nextSibling)}),s.addedNodes.forEach(a=>{s.target.removeChild(a)}))}),r())}return{registerMutations:o,restoreDOM:i,clear:r}},l7={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0};class k_ extends y.Component{constructor(){super(...arguments),bt(this,"context",null),bt(this,"manager",null),bt(this,"mutationObserver",null)}observe(){var e,{node:n}=this.props;if(!n.current)throw new Error("Failed to attach MutationObserver, `node` is undefined");(e=this.mutationObserver)===null||e===void 0||e.observe(n.current,l7)}componentDidMount(){var{receivedUserInput:e}=this.props,n=this.context;this.manager=a7(n,e),this.mutationObserver=new MutationObserver(this.manager.registerMutations),this.observe()}getSnapshotBeforeUpdate(){var e,n,r,o=(e=this.mutationObserver)===null||e===void 0?void 0:e.takeRecords();if(o!=null&&o.length){var i;(i=this.manager)===null||i===void 0||i.registerMutations(o)}return(n=this.mutationObserver)===null||n===void 0||n.disconnect(),(r=this.manager)===null||r===void 0||r.restoreDOM(),null}componentDidUpdate(){var e;(e=this.manager)===null||e===void 0||e.clear(),this.observe()}componentWillUnmount(){var e;(e=this.mutationObserver)===null||e===void 0||e.disconnect()}render(){return this.props.children}}bt(k_,"contextType",zg);var c7=sn?k_:t=>{var{children:e}=t;return y.createElement(y.Fragment,null,e)},u7=y.createContext(!1),d7=["autoFocus","decorate","onDOMBeforeInput","placeholder","readOnly","renderElement","renderChunk","renderLeaf","renderText","renderPlaceholder","scrollSelectionIntoView","style","as","disableDefaultStyles"],f7=["text"];function S_(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function $r(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?S_(Object(n),!0).forEach(function(r){bt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):S_(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var h7=t=>y.createElement(y.Fragment,null,y_(t)),p7=y.forwardRef((t,e)=>{var n=y.useCallback(j=>y.createElement(m7,$r({},j)),[]),{autoFocus:r,decorate:o=g7,onDOMBeforeInput:i,placeholder:s,readOnly:a=!1,renderElement:l,renderChunk:c,renderLeaf:u,renderText:d,renderPlaceholder:f=n,scrollSelectionIntoView:p=w7,style:m={},as:b="div",disableDefaultStyles:v=!1}=t,w=Cd(t,d7),g=i7(),[C,S]=y.useState(!1),k=y.useRef(null),x=y.useRef([]),[D,E]=y.useState(),O=y.useRef(!1),{onUserInput:A,receivedUserInput:T}=s7(),[,B]=y.useReducer(j=>j+1,0);xD.set(g,B),Og.set(g,a);var M=y.useMemo(()=>({isDraggingInternally:!1,isUpdatingSelection:!1,latestElement:null,hasMarkPlaceholder:!1}),[]);y.useEffect(()=>{k.current&&r&&k.current.focus()},[r]);var F=y.useRef(),N=y.useMemo(()=>i9(()=>{if(ks.get(g)){N();return}var j=ye.toDOMNode(g,g),Y=j.getRootNode();if(!O.current&&gi&&Y instanceof ShadowRoot){O.current=!0;var W=b9();W?document.execCommand("indent"):ue.deselect(g),O.current=!1;return}var X=F.current;if((sn||!ye.isComposing(g))&&(!M.isUpdatingSelection||X!=null&&X.isFlushing())&&!M.isDraggingInternally){var re=ye.findDocumentOrShadowRoot(g),{activeElement:Z}=re,de=ye.toDOMNode(g,g),ve=ul(re);if(Z===de?(M.latestElement=Z,Bo.set(g,!0)):Bo.delete(g),!ve)return ue.deselect(g);var{anchorNode:we,focusNode:fe}=ve,le=ye.hasEditableTarget(g,we)||ye.isTargetInsideNonReadonlyVoid(g,we),Se=ye.hasTarget(g,fe);if(le&&Se){var ce=ye.toSlateRange(g,ve,{exactMatch:!1,suppressThrow:!0});ce&&(!ye.isComposing(g)&&!(X!=null&&X.hasPendingChanges())&&!(X!=null&&X.isFlushing())?ue.select(g,ce):X==null||X.handleUserSelect(ce))}a&&(!le||!Se)&&ue.deselect(g)}},100),[g,a,M]),P=y.useMemo(()=>n9(N,0),[N]);F.current=Dj({node:k,onDOMSelectionChange:N,scheduleOnDOMSelectionChange:P}),Lr(()=>{var j,Y,W;k.current&&(W=Cg(k.current))?(ED.set(g,W),hl.set(g,k.current),wi.set(g,k.current),pl.set(k.current,g)):wi.delete(g);var{selection:X}=g,re=ye.findDocumentOrShadowRoot(g),Z=ul(re);if(!(!Z||!ye.isFocused(g)||(j=F.current)!==null&&j!==void 0&&j.hasPendingAction())){var de=le=>{var Se=Z.type!=="None";if(!(!X&&!Se)){var ce=Z.focusNode,Fe;if(Cs&&Z.rangeCount>1){var Ve=Z.getRangeAt(0),je=Z.getRangeAt(Z.rangeCount-1);Ve.startContainer===ce?Fe=je.endContainer:Fe=Ve.startContainer}else Fe=Z.anchorNode;var We=hl.get(g),Ce=!1;if(mi(We,Fe)&&mi(We,ce)&&(Ce=!0),Se&&Ce&&X&&!le){var Oe=ye.toSlateRange(g,Z,{exactMatch:!0,suppressThrow:!0});if(Oe&&oe.equals(Oe,X)){var Pe;if(!M.hasMarkPlaceholder||(Pe=Fe)!==null&&Pe!==void 0&&(Pe=Pe.parentElement)!==null&&Pe!==void 0&&Pe.hasAttribute("data-slate-mark-placeholder"))return}}if(X&&!ye.hasRange(g,X)){g.selection=ye.toSlateRange(g,Z,{exactMatch:!1,suppressThrow:!0});return}M.isUpdatingSelection=!0;var qe=null;try{qe=X&&ye.toDOMRange(g,X)}catch{}return qe?(ye.isComposing(g)&&!sn?Z.collapseToEnd():oe.isBackward(X)?Z.setBaseAndExtent(qe.endContainer,qe.endOffset,qe.startContainer,qe.startOffset):Z.setBaseAndExtent(qe.startContainer,qe.startOffset,qe.endContainer,qe.endOffset),p(g,qe)):Z.removeAllRanges(),qe}};Z.rangeCount<=1&&de();var ve=((Y=F.current)===null||Y===void 0?void 0:Y.isFlushing())==="action";if(!sn||!ve){setTimeout(()=>{M.isUpdatingSelection=!1});return}var we=null,fe=requestAnimationFrame(()=>{if(ve){var le=Se=>{try{var ce=ye.toDOMNode(g,g);ce.focus(),de(Se)}catch{}};le(),we=setTimeout(()=>{le(!0),M.isUpdatingSelection=!1})}});return()=>{cancelAnimationFrame(fe),we&&clearTimeout(we)}}});var I=y.useCallback(j=>{E_(g,j);var Y=ye.toDOMNode(g,g),W=Y.getRootNode();if(O!=null&&O.current&&gi&&W instanceof ShadowRoot){var X=j.getTargetRanges(),re=X[0],Z=new window.Range;Z.setStart(re.startContainer,re.startOffset),Z.setEnd(re.endContainer,re.endOffset);var de=ye.toSlateRange(g,Z,{exactMatch:!1,suppressThrow:!1});ue.select(g,de),j.preventDefault(),j.stopImmediatePropagation();return}if(A(),!a&&ye.hasEditableTarget(g,j.target)&&!b7(j,i)){var ve;if(F.current)return F.current.handleDOMBeforeInput(j);P.flush(),N.flush();var{selection:we}=g,{inputType:fe}=j,le=j.dataTransfer||j.data||void 0,Se=fe==="insertCompositionText"||fe==="deleteCompositionText";if(Se&&ye.isComposing(g))return;var ce=!1;if(fe==="insertText"&&we&&oe.isCollapsed(we)&&j.data&&j.data.length===1&&/[a-z ]/i.test(j.data)&&we.anchor.offset!==0&&(ce=!0,g.marks&&(ce=!1),!ks.get(g))){var Fe,Ve,{anchor:je}=we,[We,Ce]=ye.toDOMPoint(g,je),Oe=(Fe=We.parentElement)===null||Fe===void 0?void 0:Fe.closest("a"),Pe=ye.getWindow(g);if(ce&&Oe&&ye.hasDOMNode(g,Oe)){var qe,zn=Pe==null?void 0:Pe.document.createTreeWalker(Oe,NodeFilter.SHOW_TEXT).lastChild();zn===We&&((qe=zn.textContent)===null||qe===void 0?void 0:qe.length)===Ce&&(ce=!1)}if(ce&&We.parentElement&&(Pe==null||(Ve=Pe.getComputedStyle(We.parentElement))===null||Ve===void 0?void 0:Ve.whiteSpace)==="pre"){var An=L.above(g,{at:je.path,match:Us=>ze.isElement(Us)&&L.isBlock(g,Us)});An&&ke.string(An[0]).includes(" ")&&(ce=!1)}}if((!fe.startsWith("delete")||fe.startsWith("deleteBy"))&&!ks.get(g)){var[jr]=j.getTargetRanges();if(jr){var lo=ye.toSlateRange(g,jr,{exactMatch:!1,suppressThrow:!1});if(!we||!oe.equals(we,lo)){ce=!1;var Ws=!Se&&g.selection&&L.rangeRef(g,g.selection);ue.select(g,lo),Ws&&ml.set(g,Ws)}}}if(Se)return;if(ce||j.preventDefault(),we&&oe.isExpanded(we)&&fe.startsWith("delete")){var co=fe.endsWith("Backward")?"backward":"forward";L.deleteFragment(g,{direction:co});return}switch(fe){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":{L.deleteFragment(g);break}case"deleteContent":case"deleteContentForward":{L.deleteForward(g);break}case"deleteContentBackward":{L.deleteBackward(g);break}case"deleteEntireSoftLine":{L.deleteBackward(g,{unit:"line"}),L.deleteForward(g,{unit:"line"});break}case"deleteHardLineBackward":{L.deleteBackward(g,{unit:"block"});break}case"deleteSoftLineBackward":{L.deleteBackward(g,{unit:"line"});break}case"deleteHardLineForward":{L.deleteForward(g,{unit:"block"});break}case"deleteSoftLineForward":{L.deleteForward(g,{unit:"line"});break}case"deleteWordBackward":{L.deleteBackward(g,{unit:"word"});break}case"deleteWordForward":{L.deleteForward(g,{unit:"word"});break}case"insertLineBreak":L.insertSoftBreak(g);break;case"insertParagraph":{L.insertBreak(g);break}case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":{fe==="insertFromComposition"&&ye.isComposing(g)&&(S(!1),bi.set(g,!1)),(le==null?void 0:le.constructor.name)==="DataTransfer"?ye.insertData(g,le):typeof le=="string"&&(ce?x.current.push(()=>L.insertText(g,le)):L.insertText(g,le));break}}var Vo=(ve=ml.get(g))===null||ve===void 0?void 0:ve.unref();ml.delete(g),Vo&&(!g.selection||!oe.equals(g.selection,Vo))&&ue.select(g,Vo)}},[g,N,A,i,a,P]),z=y.useCallback(j=>{j==null?(N.cancel(),P.cancel(),hl.delete(g),wi.delete(g),k.current&&No&&k.current.removeEventListener("beforeinput",I)):No&&j.addEventListener("beforeinput",I),k.current=j,typeof e=="function"?e(j):e&&(e.current=j)},[N,P,g,I,e]);Lr(()=>{var j=ye.getWindow(g),Y=X=>{var{target:re}=X,Z=re instanceof HTMLElement?re:null,de=Z==null?void 0:Z.tagName;de==="INPUT"||de==="TEXTAREA"||P()};j.document.addEventListener("selectionchange",Y);var W=()=>{M.isDraggingInternally=!1};return j.document.addEventListener("dragend",W),j.document.addEventListener("drop",W),()=>{j.document.removeEventListener("selectionchange",Y),j.document.removeEventListener("dragend",W),j.document.removeEventListener("drop",W)}},[P,M]);var H=o([g,[]]),J=Lj(o),K=s&&g.children.length===1&&Array.from(ke.texts(g)).length===1&&ke.string(g)===""&&!C,ee=y.useCallback(j=>{if(j&&K){var Y;E((Y=j.getBoundingClientRect())===null||Y===void 0?void 0:Y.height)}else E(void 0)},[K]);if(K){var $=L.start(g,[]);H.push({[Es]:!0,placeholder:s,onPlaceholderResize:ee,anchor:$,focus:$})}var{marks:U}=g;if(M.hasMarkPlaceholder=!1,g.selection&&oe.isCollapsed(g.selection)&&U){var{anchor:R}=g.selection,te=ke.leaf(g,R.path),se=Cd(te,f7);if(!Le.equals(te,U,{loose:!0})){M.hasMarkPlaceholder=!0;var be=Object.fromEntries(Object.keys(se).map(j=>[j,null]));H.push($r($r($r({[DD]:!0},be),U),{},{anchor:R,focus:R}))}}return y.useEffect(()=>{setTimeout(()=>{var{selection:j}=g;if(j){var{anchor:Y}=j,W=ke.leaf(g,Y.path);if(U&&!Le.equals(W,U,{loose:!0})){gr.set(g,U);return}}gr.delete(g)})}),o7(),y.createElement(C_.Provider,{value:a},y.createElement(u7.Provider,{value:C},y.createElement(c_.Provider,{value:J},y.createElement(c7,{node:k,receivedUserInput:T},y.createElement(b,$r($r({role:a?void 0:"textbox","aria-multiline":a?void 0:!0,translate:"no"},w),{},{spellCheck:No||!pd?w.spellCheck:!1,autoCorrect:No||!pd?w.autoCorrect:"false",autoCapitalize:No||!pd?w.autoCapitalize:"false","data-slate-editor":!0,"data-slate-node":"value",contentEditable:!a,zindex:-1,suppressContentEditableWarning:!0,ref:z,style:$r($r({},v?{}:$r({position:"relative",whiteSpace:"pre-wrap",wordWrap:"break-word"},D?{minHeight:D}:{})),m),onBeforeInput:y.useCallback(j=>{if(!No&&!a&&!pn(j,w.onBeforeInput)&&ye.hasSelectableTarget(g,j.target)&&(j.preventDefault(),!ye.isComposing(g))){var Y=j.data;L.insertText(g,Y)}},[w.onBeforeInput,g,a]),onInput:y.useCallback(j=>{if(!pn(j,w.onInput)){if(F.current){F.current.handleInput();return}for(var Y of x.current)Y();x.current=[],ye.isFocused(g)||E_(g,j.nativeEvent)}},[w.onInput,g]),onBlur:y.useCallback(j=>{if(!(a||M.isUpdatingSelection||!ye.hasSelectableTarget(g,j.target)||pn(j,w.onBlur))){var Y=ye.findDocumentOrShadowRoot(g);if(M.latestElement!==Y.activeElement){var{relatedTarget:W}=j,X=ye.toDOMNode(g,g);if(W!==X&&!(Zn(W)&&W.hasAttribute("data-slate-spacer"))){if(W!=null&&To(W)&&ye.hasDOMNode(g,W)){var re=ye.toSlateNode(g,W);if(ze.isElement(re)&&!g.isVoid(re))return}if(gi){var Z=ul(Y);Z==null||Z.removeAllRanges()}Bo.delete(g)}}}},[a,M.isUpdatingSelection,M.latestElement,g,w.onBlur]),onClick:y.useCallback(j=>{if(ye.hasTarget(g,j.target)&&!pn(j,w.onClick)&&To(j.target)){var Y=ye.toSlateNode(g,j.target),W=ye.findPath(g,Y);if(!L.hasPath(g,W)||ke.get(g,W)!==Y)return;if(j.detail===L9&&W.length>=1){var X=W;if(!(ze.isElement(Y)&&L.isBlock(g,Y))){var re,Z=L.above(g,{match:ce=>ze.isElement(ce)&&L.isBlock(g,ce),at:W});X=(re=Z==null?void 0:Z[1])!==null&&re!==void 0?re:W.slice(0,1)}var de=L.range(g,X);ue.select(g,de);return}if(a)return;var ve=L.start(g,W),we=L.end(g,W),fe=L.void(g,{at:ve}),le=L.void(g,{at:we});if(fe&&le&&q.equals(fe[1],le[1])){var Se=L.range(g,ve);ue.select(g,Se)}}},[g,w.onClick,a]),onCompositionEnd:y.useCallback(j=>{if(!vl(j)&&ye.hasSelectableTarget(g,j.target)){var Y;if(ye.isComposing(g)&&Promise.resolve().then(()=>{S(!1),bi.set(g,!1)}),(Y=F.current)===null||Y===void 0||Y.handleCompositionEnd(j),pn(j,w.onCompositionEnd)||sn)return;if(!gi&&!S9&&!y9&&!x9&&!E9&&j.data){var W=gr.get(g);gr.delete(g),W!==void 0&&(to.set(g,g.marks),g.marks=W),L.insertText(g,j.data);var X=to.get(g);to.delete(g),X!==void 0&&(g.marks=X)}}},[w.onCompositionEnd,g]),onCompositionUpdate:y.useCallback(j=>{ye.hasSelectableTarget(g,j.target)&&!pn(j,w.onCompositionUpdate)&&!vl(j)&&(ye.isComposing(g)||(S(!0),bi.set(g,!0)))},[w.onCompositionUpdate,g]),onCompositionStart:y.useCallback(j=>{if(!vl(j)&&ye.hasSelectableTarget(g,j.target)){var Y;if((Y=F.current)===null||Y===void 0||Y.handleCompositionStart(j),pn(j,w.onCompositionStart)||sn)return;S(!0);var{selection:W}=g;if(W&&oe.isExpanded(W)){L.deleteFragment(g);return}}},[w.onCompositionStart,g]),onCopy:y.useCallback(j=>{ye.hasSelectableTarget(g,j.target)&&!pn(j,w.onCopy)&&!vl(j)&&(j.preventDefault(),ye.setFragmentData(g,j.clipboardData,"copy"))},[w.onCopy,g]),onCut:y.useCallback(j=>{if(!a&&ye.hasSelectableTarget(g,j.target)&&!pn(j,w.onCut)&&!vl(j)){j.preventDefault(),ye.setFragmentData(g,j.clipboardData,"cut");var{selection:Y}=g;if(Y)if(oe.isExpanded(Y))L.deleteFragment(g);else{var W=ke.parent(g,Y.anchor.path);L.isVoid(g,W)&&ue.delete(g)}}},[a,g,w.onCut]),onDragOver:y.useCallback(j=>{if(ye.hasTarget(g,j.target)&&!pn(j,w.onDragOver)){var Y=ye.toSlateNode(g,j.target);ze.isElement(Y)&&L.isVoid(g,Y)&&j.preventDefault()}},[w.onDragOver,g]),onDragStart:y.useCallback(j=>{if(!a&&ye.hasTarget(g,j.target)&&!pn(j,w.onDragStart)){var Y=ye.toSlateNode(g,j.target),W=ye.findPath(g,Y),X=ze.isElement(Y)&&L.isVoid(g,Y)||L.void(g,{at:W,voids:!0});if(X){var re=L.range(g,W);ue.select(g,re)}M.isDraggingInternally=!0,ye.setFragmentData(g,j.dataTransfer,"drag")}},[a,g,w.onDragStart,M]),onDrop:y.useCallback(j=>{if(!a&&ye.hasTarget(g,j.target)&&!pn(j,w.onDrop)){j.preventDefault();var Y=g.selection,W=ye.findEventRange(g,j),X=j.dataTransfer;ue.select(g,W),M.isDraggingInternally&&Y&&!oe.equals(Y,W)&&!L.void(g,{at:W,voids:!0})&&ue.delete(g,{at:Y}),ye.insertData(g,X),ye.isFocused(g)||ye.focus(g)}},[a,g,w.onDrop,M]),onDragEnd:y.useCallback(j=>{!a&&M.isDraggingInternally&&w.onDragEnd&&ye.hasTarget(g,j.target)&&w.onDragEnd(j)},[a,M,w,g]),onFocus:y.useCallback(j=>{if(!a&&!M.isUpdatingSelection&&ye.hasEditableTarget(g,j.target)&&!pn(j,w.onFocus)){var Y=ye.toDOMNode(g,g),W=ye.findDocumentOrShadowRoot(g);if(M.latestElement=W.activeElement,Cs&&j.target!==Y){Y.focus();return}Bo.set(g,!0)}},[a,M,g,w.onFocus]),onKeyDown:y.useCallback(j=>{if(!a&&ye.hasEditableTarget(g,j.target)){var Y;(Y=F.current)===null||Y===void 0||Y.handleKeyDown(j);var{nativeEvent:W}=j;if(ye.isComposing(g)&&W.isComposing===!1&&(bi.set(g,!1),S(!1)),pn(j,w.onKeyDown)||ye.isComposing(g))return;var{selection:X}=g,re=g.children[X!==null?X.focus.path[0]:0],Z=Gx(ke.string(re))==="rtl";if(yt.isRedo(W)){j.preventDefault();var de=g;typeof de.redo=="function"&&de.redo();return}if(yt.isUndo(W)){j.preventDefault();var ve=g;typeof ve.undo=="function"&&ve.undo();return}if(yt.isMoveLineBackward(W)){j.preventDefault(),ue.move(g,{unit:"line",reverse:!0});return}if(yt.isMoveLineForward(W)){j.preventDefault(),ue.move(g,{unit:"line"});return}if(yt.isExtendLineBackward(W)){j.preventDefault(),ue.move(g,{unit:"line",edge:"focus",reverse:!0});return}if(yt.isExtendLineForward(W)){j.preventDefault(),ue.move(g,{unit:"line",edge:"focus"});return}if(yt.isMoveBackward(W)){j.preventDefault(),X&&oe.isCollapsed(X)?ue.move(g,{reverse:!Z}):ue.collapse(g,{edge:Z?"end":"start"});return}if(yt.isMoveForward(W)){j.preventDefault(),X&&oe.isCollapsed(X)?ue.move(g,{reverse:Z}):ue.collapse(g,{edge:Z?"start":"end"});return}if(yt.isMoveWordBackward(W)){j.preventDefault(),X&&oe.isExpanded(X)&&ue.collapse(g,{edge:"focus"}),ue.move(g,{unit:"word",reverse:!Z});return}if(yt.isMoveWordForward(W)){j.preventDefault(),X&&oe.isExpanded(X)&&ue.collapse(g,{edge:"focus"}),ue.move(g,{unit:"word",reverse:Z});return}if(No){if((Dg||gi)&&X&&(yt.isDeleteBackward(W)||yt.isDeleteForward(W))&&oe.isCollapsed(X)){var we=ke.parent(g,X.anchor.path);if(ze.isElement(we)&&L.isVoid(g,we)&&(L.isInline(g,we)||L.isBlock(g,we))){j.preventDefault(),L.deleteBackward(g,{unit:"block"});return}}}else{if(yt.isBold(W)||yt.isItalic(W)||yt.isTransposeCharacter(W)){j.preventDefault();return}if(yt.isSoftBreak(W)){j.preventDefault(),L.insertSoftBreak(g);return}if(yt.isSplitBlock(W)){j.preventDefault(),L.insertBreak(g);return}if(yt.isDeleteBackward(W)){j.preventDefault(),X&&oe.isExpanded(X)?L.deleteFragment(g,{direction:"backward"}):L.deleteBackward(g);return}if(yt.isDeleteForward(W)){j.preventDefault(),X&&oe.isExpanded(X)?L.deleteFragment(g,{direction:"forward"}):L.deleteForward(g);return}if(yt.isDeleteLineBackward(W)){j.preventDefault(),X&&oe.isExpanded(X)?L.deleteFragment(g,{direction:"backward"}):L.deleteBackward(g,{unit:"line"});return}if(yt.isDeleteLineForward(W)){j.preventDefault(),X&&oe.isExpanded(X)?L.deleteFragment(g,{direction:"forward"}):L.deleteForward(g,{unit:"line"});return}if(yt.isDeleteWordBackward(W)){j.preventDefault(),X&&oe.isExpanded(X)?L.deleteFragment(g,{direction:"backward"}):L.deleteBackward(g,{unit:"word"});return}if(yt.isDeleteWordForward(W)){j.preventDefault(),X&&oe.isExpanded(X)?L.deleteFragment(g,{direction:"forward"}):L.deleteForward(g,{unit:"word"});return}}}},[a,g,w.onKeyDown]),onPaste:y.useCallback(j=>{!a&&ye.hasEditableTarget(g,j.target)&&!pn(j,w.onPaste)&&(!No||f9(j.nativeEvent)||gi)&&(j.preventDefault(),ye.insertData(g,j.clipboardData))},[a,g,w.onPaste])}),y.createElement(h7,{decorations:H,node:g,renderElement:l,renderChunk:c,renderPlaceholder:f,renderLeaf:u,renderText:d}))))))}),m7=t=>{var{attributes:e,children:n}=t;return y.createElement("span",$r({},e),n,sn&&y.createElement("br",null))},g7=()=>[],w7=(t,e)=>{var n=!!t.selection&&oe.isBackward(t.selection),r=e.cloneRange();if(r.collapse(n),r.getBoundingClientRect){var o=r.startContainer.parentElement,i=r.getBoundingClientRect(),s=i.width===0&&i.height===0&&i.x===0&&i.y===0;if(s){var a=o.getBoundingClientRect(),l=a.width>0||a.height>0;if(l)return}o.getBoundingClientRect=r.getBoundingClientRect.bind(r),l9(o,{scrollMode:"if-needed"}),delete o.getBoundingClientRect}},pn=(t,e)=>{if(!e)return!1;var n=e(t);return n??(t.isDefaultPrevented()||t.isPropagationStopped())},vl=t=>To(t.target)&&(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement),b7=(t,e)=>{if(!e)return!1;var n=e(t);return n??t.defaultPrevented},E_=(t,e)=>{var n=t;if(e.inputType==="historyUndo"&&typeof n.undo=="function"){n.undo();return}if(e.inputType==="historyRedo"&&typeof n.redo=="function"){n.redo();return}},x_=y.createContext(!1),v7=()=>y.useContext(x_),D_=parseInt(y.version.split(".")[0],10),y7=["editor","children","onChange","onSelectionChange","onValueChange","initialValue"],C7=t=>{var{editor:e,children:n,onChange:r,onSelectionChange:o,onValueChange:i,initialValue:s}=t,a=Cd(t,y7);y.useState(()=>{if(!ke.isNodeList(s))throw new Error("[Slate] initialValue is invalid! Expected a list of elements but got: ".concat(zt.stringify(s)));if(!L.isEditor(e))throw new Error("[Slate] editor is invalid! You passed: ".concat(zt.stringify(e)));e.children=s,Object.assign(e,a)});var{selectorContext:l,onChange:c}=r7(),u=y.useCallback(()=>{r&&r(e.children),o&&e.operations.find(p=>p.type==="set_selection")&&o(e.selection),i&&e.operations.find(p=>p.type!=="set_selection")&&i(e.children),c()},[e,c,r,o,i]);y.useEffect(()=>(Tg.set(e,u),()=>{Tg.set(e,()=>{})}),[e,u]);var[d,f]=y.useState(ye.isFocused(e));return y.useEffect(()=>{f(ye.isFocused(e))},[e]),Lr(()=>{var p=()=>f(ye.isFocused(e));return D_>=17?(document.addEventListener("focusin",p),document.addEventListener("focusout",p),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",p)}):(document.addEventListener("focus",p,!0),document.addEventListener("blur",p,!0),()=>{document.removeEventListener("focus",p,!0),document.removeEventListener("blur",p,!0)})},[]),y.createElement(Sd.Provider,{value:l},y.createElement(zg.Provider,{value:e},y.createElement(x_.Provider,{value:d},n)))},k7=()=>{var t=Qj();if(!t)return!1;var e=y.useCallback(n=>{if(!n.selection)return!1;var r=ye.findPath(n,t),o=L.range(n,r);return!!oe.intersection(o,n.selection)},[t]);return n7(e,void 0,{deferred:!0})},S7=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"x-slate-fragment",r=e;r=P9(r,n);var{onChange:o,apply:i,insertText:s}=r;return r.getChunkSize=()=>null,sn&&(r.insertText=(a,l)=>(no.delete(r),s(a,l))),r.onChange=a=>{var l=D_<18?Uo.unstable_batchedUpdates:c=>c();l(()=>{o(a)})},r.apply=a=>{if(a.type==="move_node"){var l=ke.parent(r,a.path),c=!!r.getChunkSize(l);if(c){var u=ke.get(r,a.path),d=w_(r,l),f=ye.findKey(r,u);d.movedNodeKeys.add(f)}}i(a)},r};const E7=t=>{const e=ne.useReactFlow();return y.useMemo(()=>{const n=t.split("."),r=n[0],o=`{{${t}}}`;if(r==="global")return{exists:!0,type:"global",tooltip:n.slice(1).join("."),fullPath:o,backgroundColor:"#ECFDF5",borderColor:"#10B981",textColor:"#065F46",iconColor:"#10B981"};if(Mt.includes(["sys_tenant_id","response"],r))return{exists:!0,type:"builtin",tooltip:il.getBuiltinVariableTips(r),fullPath:o,backgroundColor:"#F3E8FF",borderColor:"#A855F7",textColor:"#6B21A8",iconColor:"#A855F7"};const i=r==null?void 0:r.slice(1),a=e.getNodes().find(f=>f.id===i);if(!a)return{exists:!1,type:"node",tooltip:G("link.flow.cannot_find_variable_output_node"),fullPath:o,backgroundColor:"#FEF2F2",borderColor:"#EF4444",textColor:"#991B1B",iconColor:"#EF4444"};const l=a.data??{},c=String(l.label||l.name||i),u=l.note;return{exists:!0,type:"node",icon:typeof l.icon=="string"?l.icon:il.getNodeIcon(i)??void 0,tooltip:c+(u?` (${u})`:""),fullPath:o,backgroundColor:"#EBF5FF",borderColor:"#3B82F6",textColor:"#1E40AF",iconColor:"#3B82F6"}},[t,e])},x7=(t,e)=>{const n=e.exec(t);if(!n)return null;const o=t.slice(-2)==="}}";return{tagContent:n[1].trimStart(),tagLength:n[0].length,tagStartIndex:n.index,isTagLastItem:o}},__=(t,e,n)=>{const r=[{type:"tag",value:e,children:[{text:e}]},{text:""}];ue.insertNodes(t,r,n)},D7=(t,e)=>[...t.slice(0,-1),t[t.length-1]+e],_7=({attributes:t,element:e,children:n})=>h.jsx("p",{...t,children:n}),A7=({attributes:t,element:e,children:n,removeTagButton:r,transformInputText:o,transformInputElement:i})=>{const s=k7(),a=v7(),l=E7((e==null?void 0:e.value)||""),c=y.useRef(null);return h.jsx(_.Tooltip,{defaultOpen:!l.exists,classNames:{root:"variable-tag-tooltip"},placement:"top",getPopupContainer:()=>{var d;return((d=c.current)==null?void 0:d.closest(".nodes-config-content"))??document.body},title:h.jsxs("div",{className:"tag-tooltip-content",children:[h.jsx("div",{className:"tag-tooltip-header",children:h.jsxs("span",{className:"tag-tooltip-type",children:[l.type==="node"&&"节点变量",l.type==="global"&&"全局变量",l.type==="builtin"&&"系统变量"]})}),h.jsx("div",{className:"tag-tooltip-name",children:l.tooltip}),h.jsx("div",{className:"tag-tooltip-path",children:l.fullPath}),l.value&&h.jsxs("div",{className:"tag-tooltip-value",children:[h.jsx("span",{className:"tag-tooltip-value-label",children:"当前值:"}),h.jsx("span",{className:"tag-tooltip-value-text",children:l.value})]})]}),arrow:{pointAtCenter:!0},children:h.jsx("span",{ref:c,...t,className:`tag-wrapper ${l.exists?"":"tag-invalid"} ${s?"selected":""} ${a?"focused":""}`,children:h.jsxs("span",{className:`tag-text ${r?"tag-text-right-padding":""}`,children:[n,o?h.jsx("span",{children:o(e==null?void 0:e.value)}):i?i(e==null?void 0:e.value):h.jsx("span",{children:e==null?void 0:e.value})]})})})},O7=({attributes:t,element:e,children:n})=>h.jsx("p",{...t,children:n}),T7=(t,e)=>{const{isInline:n,isVoid:r,normalizeNode:o}=t;return t.isInline=i=>i.type==="tag"?!0:n(i),t.isVoid=i=>i.type==="tag"?!0:r(i),t.normalizeNode=([i,s])=>{if(!(i!=null&&i.text)){o([i,s]);return}const a=ke.string(i),l=x7(a,e);if(l){const{tagContent:c,tagLength:u,tagStartIndex:d,isTagLastItem:f}=l,p={path:s,offset:d};ue.delete(t,{at:p,distance:u,unit:"character"}),__(t,c,{at:p}),f&&ue.select(t,{path:D7(s,1),offset:0})}o([i,s])},t},N7=t=>{var n;const e=(n=t==null?void 0:t.children)==null?void 0:n.map(r=>r.type==="tag"?`{{${r.value}}}`:r.text);return Array.isArray(e)?e.join(""):""},B7=t=>(t??[]).map(n=>N7(n)).join(`
|
|
52
|
-
`),F7=y.forwardRef(({onValueChange:t=d=>{},removeTagButton:e=!1,initValue:n,onFocus:r,onBlur:o,addImageElement:i,transformInputText:s,transformInputElement:a,textAreaMode:l,capturePattern:c=yz},u)=>{const d=y.useRef(null),f=y.useMemo(()=>T7(S7(jV()),c),[]),[p,m]=y.useState(od(n,c));let b=n;const v=y.useCallback(({element:k,children:x,attributes:D})=>{switch(k.type){case"paragraph":return h.jsx(O7,{attributes:D,element:k,children:x});case"tag":return h.jsx(A7,{attributes:D,element:k,removeTagButton:e,addImageElement:i,transformInputText:s,transformInputElement:a,children:x});default:return h.jsx(_7,{attributes:D,element:k,children:x})}},[]);y.useEffect(()=>{m(od(n,c))},[n]);const w=y.useCallback(k=>{d.current=f.selection;const x=B7(k);x!==b&&(b=k,m(k),t(x))},[]),g=k=>{ue.delete(f,{at:[0]});const x=od(k,c);f.children=od("",c),ue.insertNodes(f,x,{at:[0]})},C=k=>{var x;__(f,k,{at:(x=d.current)==null?void 0:x.focus}),ue.move(f,{distance:p.length-1})};y.useImperativeHandle(u,()=>({insertTag:C,setValueByParent:g}));const S=At();return h.jsx(C7,{editor:f,initialValue:p,onChange:w,children:h.jsx(p7,{style:l?{minHeight:60,maxHeight:200}:{maxHeight:150},onFocus:r,onBlur:o,readOnly:!S,spellCheck:!1,className:"ce-tag_input",renderElement:v})})}),A_=t=>h.jsx("div",{style:{display:t.show?"block":"none",height:"100%",width:"100%",...t.style??{}},children:t.children}),In=t=>{const e=At(),n=y.useMemo(()=>Mn(),[]),{event$:r}=y.useContext(Qr),o=Ym(n),i=y.useRef(null),[s,a]=y.useState(""),l=St.useReactive({innerValueType:"",radioType:"",openEditorNumber:0});y.useEffect(()=>{l.radioType=t.valueType},[t.valueType,l]),r.useSubscription(f=>{var p,m,b;if(f.type==="insert"&&f.currentInputId===n){(m=i==null?void 0:(p=i.current).insertTag)==null||m.call(p,f.expression.slice(2,-2));const v=(s??"")+(t.valueType==="FIX_VALUE"?f.expression.slice(2,-2):f.expression);a(v),(b=t.onChange)==null||b.call(t,v)}});const c=y.useMemo(()=>!t.borrow&&["JS_EXP","ADAPTOR"].includes(t.valueType),[t.borrow,t.valueType]);y.useEffect(()=>{a(t.value)},[t.value]);const u=f=>{var p;(p=t.onChange)==null||p.call(t,f)},d=f=>{var p;a(f),(p=t.onChange)==null||p.call(t,f)};return h.jsxs(gC,{id:n,canEditInEditor:e&&!t.disableIDE,openEditorNumber:l.openEditorNumber,nodeId:t.nodeId,value:t.value,onFinish:f=>{i.current.setValueByParent(f)},children:[c&&h.jsx("div",{style:{textAlign:"right",position:"absolute",top:-34,right:2},children:h.jsxs(_.Radio.Group,{value:l.radioType,onChange:f=>{l.radioType=f.target.value,l.radioType==="ADAPTOR"&&i.current.setValueByParent(s)},size:"small",style:{marginTop:16},children:[h.jsx(_.Radio.Button,{style:{height:18,fontSize:10,display:"inline-flex",alignItems:"center"},value:"ADAPTOR",children:h.jsx(Te.FormattedMessage,{id:"link.flow.string"})}),h.jsx(_.Radio.Button,{style:{height:18,fontSize:10,display:"inline-flex",alignItems:"center"},value:"JS_EXP",children:h.jsx(Te.FormattedMessage,{id:"link.flow.script"})})]})}),h.jsx(A_,{show:l.radioType==="ADAPTOR"||!c&&l.radioType!=="PLAIN_CODE",children:h.jsx("div",{className:o?rd:void 0,children:h.jsx(F7,{id:n,ref:i,disabled:t.disabled,textAreaMode:t.textAreaMode,initValue:t.value,onFocus:()=>{["JS_EXP","FIX_VALUE","ADAPTOR","PLAIN_TEXT","PLAIN_CODE"].includes(t.valueType)&&(r.emit({type:"visible",visible:!0}),r.emit({type:"setCurrentInputId",currentInputId:n})),t.onFocus&&t.onFocus()},onBlur:()=>{t.onBlur&&t.onBlur()},removeTagButton:!1,onValueChange:u,addImageElement:f=>{const m=(f==null?void 0:f.split(".")[0]).slice(1),b=il.getConfig().icons.get(m);return b?h.jsx("img",{src:b,alt:m,onError:v=>{v.target.src="/uc/images/default_connector.png"}}):h.jsx(ie.ThunderboltOutlined,{})},transformInputText:f=>Mt.includes(["sys_tenant_id","response"],f)?f:f.split(".").slice(1).join("."),transformInputElement:f=>h.jsx("span",{style:{color:"blue"},children:f})})})}),h.jsxs(A_,{show:(l.radioType==="JS_EXP"||l.radioType==="PLAIN_CODE")&&(l.radioType==="PLAIN_CODE"||c),style:{position:"relative"},children:[h.jsx("div",{children:h.jsx(vz,{...t,onValueChange:d})}),h.jsx("button",{type:"button","aria-label":"在在线 IDE 中编辑",title:"在在线 IDE 中编辑",className:"workflow-online-ide-trigger",disabled:!e,onClick:()=>{l.openEditorNumber++},children:h.jsx(ie.FullscreenOutlined,{})})]})]})};function jg(t,e){return e?{...t,valueModePolicy:e}:t}const Wg=({policy:t,disabled:e,readOnly:n,children:r})=>{const[o,i]=y.useState(()=>t?Mh(t).defaultMode:"normal"),s=y.useCallback(a=>{i(a)},[]);return t?h.jsx(pC,{policy:t,mode:o,onModeChange:s,children:h.jsxs("div",{className:"value-mode-wrapper",children:[h.jsx(Ih,{valueModePolicy:t,mode:o,onModeChange:s,disabled:e,readOnly:n,modeSwitchPosition:"top-right"}),h.jsx("div",{className:"value-mode-content",children:r})]})}):h.jsx(h.Fragment,{children:r})},Ed="${",xd="}",O_="\\$";function Dd(t){return typeof t=="string"&&t.startsWith(Ed)&&t.endsWith(xd)&&t.length>=Ed.length+xd.length}function Ug(t){if(typeof t=="string")return t;if(t==null)return"";try{return typeof t=="object"?JSON.stringify(t)??"":String(t)}catch{return""}}function _d(t,e,n){const r=Ug(t);return n?e==="expression"?`${Ed}${r}${xd}`:e==="normal"&&r.startsWith("$")?`${O_}${r.slice(1)}`:r:r}function _s(t,e,n){const r=Ug(t);return n?e==="expression"&&Dd(r)?r.slice(Ed.length,-xd.length):e==="normal"&&r.startsWith(O_)?r.slice(1):r:r}function T_(t,e,n,r=mC){return n?r.includes("expression")&&Dd(t)?"expression":e:r.includes("expression")&&typeof t=="string"&&/\{\{.*\}\}/.test(t)?"expression":e}const Ci=({value:t="",onChange:e,valueModePolicy:n,availableModes:r=mC,defaultMode:o="normal",mode:i,onModeChange:s,disabled:a=!1,readOnly:l=!1,id:c,placeholder:u,multiline:d=!1,rows:f=4,textModeSupportsVariables:p=!1,encodeExpressionValue:m=!1,onFocus:b,onBlur:v,renderNormalMode:w,renderExpressionMode:g,children:C,hideModeSwitch:S=!1,modeSwitchPosition:k="top-left",compact:x=!1})=>{const D=hC(),E=n??(D==null?void 0:D.policy),O=S||!!(D!=null&&D.suppressNestedSwitch),A=i??(D!=null&&D.suppressNestedSwitch?D.mode:void 0),T=s??(D!=null&&D.suppressNestedSwitch?D.onModeChange:void 0),B=E?Mh(E):void 0,M=(B==null?void 0:B.availableModes)??r,F=(B==null?void 0:B.defaultMode)??o,N=M.length===1?M[0]:void 0,P=Ug(t),I=y.useRef(P),z=y.useRef(void 0),H=y.useRef(e);H.current=e;const J=()=>T_(P,F,m,M),[K,ee]=y.useState(J),$=N??A??K,U=y.useMemo(()=>_s(P,$,m),[P,$,m]);y.useEffect(()=>{A!==void 0&&ee(A)},[A]),y.useEffect(()=>{var X;if(!m||A===void 0){z.current=$;return}const Y=z.current;if(z.current=$,Y===void 0||Y===$)return;const W=_d(_s(P,Y,!0),$,!0);W!==P&&(I.current=W,(X=H.current)==null||X.call(H,W))},[$,m,A,P]),y.useEffect(()=>{!m||A!==void 0||I.current!==P&&(I.current=P,ee(T_(P,F,!0,M)))},[M,A,F,m,P]),y.useEffect(()=>{var W;if(!m||!N||!P.trim())return;const Y=_d(_s(P,N,!0),N,!0);Y===P||I.current===Y||(I.current=Y,(W=H.current)==null||W.call(H,Y))},[m,N,P]);const R=y.useCallback(Y=>{if(ee(Y),T==null||T(Y),m){const W=_d(U,Y,!0);I.current=W,z.current=Y,e==null||e(W)}},[U,m,e,T]),te=y.useCallback(Y=>{const W=_d(Y,$,m);I.current=W,e==null||e(W)},[$,m,e]),se=()=>O||!E?null:h.jsx(Ih,{valueModePolicy:E,mode:$,onModeChange:R,disabled:a,readOnly:l,modeSwitchPosition:k}),be=Y=>h.jsx(In,{valueType:"FIX_VALUE",value:U,onChange:te,placeholder:u,disabled:a,onFocus:b,onBlur:v}),j=()=>{switch($){case"normal":return p?be():C?vt.cloneElement(C,{value:U,onChange:te,disabled:a,readOnly:l}):w?w({value:U,onChange:te,disabled:a,readOnly:l,placeholder:u}):d?h.jsx(_.Input.TextArea,{id:c,value:U,onChange:Y=>te(Y.target.value),disabled:a,readOnly:l,placeholder:u,rows:f,onFocus:b,onBlur:v}):h.jsx(_.Input,{id:c,value:U,onChange:Y=>te(Y.target.value),disabled:a,readOnly:l,placeholder:u,onFocus:b,onBlur:v});case"expression":return g?g({value:U,onChange:te,disabled:a,readOnly:l,placeholder:u}):be();case"code":return h.jsx(_.Input.TextArea,{id:c,value:U,onChange:Y=>te(Y.target.value),disabled:a,readOnly:l,placeholder:u||"// 输入 JavaScript 代码",rows:f,className:"code-mode-textarea",style:{fontFamily:"monospace"},onFocus:b,onBlur:v});default:return null}};return h.jsxs("div",{className:`value-mode-wrapper${x?" compact":""}`,children:[se(),h.jsx("div",{className:"value-mode-content",children:j()})]})};function M7(t){switch(t){case ge.NUMBER:case ge.SLIDER:case ge.RATE:return"number";case ge.CHECKBOX:case ge.SWITCH:return"boolean";case ge.MULTI_SELECT:case ge.CHECKBOX_GROUP:case ge.DATE_RANGE:case ge.TIME_RANGE:case ge.ARRAY:case ge.ARRAY_OBJECT:return"array";case ge.DATE:case ge.DATETIME:case ge.TIME:return"object";case ge.OBJECT:case ge.KEY_VALUE:return"object";default:return}}function ki(t){return Dd(t)}function Si(t){return ki(t)?null:_s(t,"normal",!0)}function I7(t){return t==null?!0:Array.isArray(t)?t.length===0:Dd(t)?_s(t,"expression",!0).trim()==="":typeof t=="string"?_s(t,"normal",!0).trim()==="":!1}function qg(t){return{message:t,validator:async(e,n)=>{if(I7(n))throw new Error(t||"此项为必填")}}}function Ei(t,e,n){const r=[],o=n?M7(n):void 0;for(const i of t){if(i.type==="when"){ei(i.conditions,e)&&r.push(...Ei(i.rules,e,n));continue}const s=P7(i,o);s&&r.push(s)}return r}function P7(t,e){const n={message:t.message,warningOnly:t.warningOnly};switch(t.type){case"required":return qg(t.message);case"type":return{...n,validator:async(r,o)=>{if(o==null||o===""||ki(o))return;const i=Si(o);if(i!=null){if(t.value==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i))throw new Error(t.message||"类型不正确");if(t.value==="url")try{new URL(i)}catch{throw new Error(t.message||"类型不正确")}if(t.value==="string"&&typeof o!="string"&&i==="")throw new Error(t.message||"类型不正确");if((t.value==="number"||t.value==="float"||t.value==="integer")&&Number.isNaN(Number(i)))throw new Error(t.message||"类型不正确");if(t.value==="integer"&&!Number.isInteger(Number(i)))throw new Error(t.message||"类型不正确");if(t.value==="boolean"&&typeof o!="boolean")throw new Error(t.message||"类型不正确");if(t.value==="array"&&!Array.isArray(o))throw new Error(t.message||"类型不正确");if(t.value==="object"&&(typeof o!="object"||o==null||Array.isArray(o)))throw new Error(t.message||"类型不正确")}}};case"min":return{...n,validator:async(r,o)=>{if(o==null||o===""||ki(o))return;if(e==="number"||typeof o=="number"){if(Number(o)<t.value)throw new Error(t.message||`最小值 ${t.value}`);return}if(e==="array"||Array.isArray(o)){if(!Array.isArray(o)||o.length<t.value)throw new Error(t.message||`至少 ${t.value} 项`);return}const i=Si(o);if(i!=null&&i.length<t.value)throw new Error(t.message||`最少 ${t.value} 个字符`)}};case"max":return{...n,validator:async(r,o)=>{if(o==null||o===""||ki(o))return;if(e==="number"||typeof o=="number"){if(Number(o)>t.value)throw new Error(t.message||`最大值 ${t.value}`);return}if(e==="array"||Array.isArray(o)){if(Array.isArray(o)&&o.length>t.value)throw new Error(t.message||`最多 ${t.value} 项`);return}const i=Si(o);if(i!=null&&i.length>t.value)throw new Error(t.message||`最多 ${t.value} 个字符`)}};case"len":return{...n,validator:async(r,o)=>{if(o==null||o===""||ki(o))return;if(Array.isArray(o)){if(o.length!==t.value)throw new Error(t.message||`长度须为 ${t.value}`);return}const i=Si(o);if(i!=null&&i.length!==t.value)throw new Error(t.message||`长度须为 ${t.value}`)}};case"pattern":{const r=new RegExp(t.value,t.flags);return{...n,validator:async(o,i)=>{if(i==null||i==="")return;const s=Si(i);if(s!=null&&!r.test(s))throw new Error(t.message||"格式不正确")}}}case"enum":return{...n,validator:async(r,o)=>{if(o==null||o===""||ki(o))return;const s=Si(o)??o;if(!t.value.includes(s))throw new Error(t.message||"不在可选范围内")}};case"whitespace":return{...n,validator:async(r,o)=>{if(o==null||o===""||ki(o))return;const i=Si(o);if(i!=null&&i.length>0&&i.trim()==="")throw new Error(t.message||"不能只包含空白字符")}};default:return null}}const L7=t=>!t||typeof t!="object"?!1:"AND"in t||"OR"in t?!0:"keyword"in t&&"key"in t;function yl(t,e){return t.visibleWhen&&t.visibleWhen.conditions?ei(t.visibleWhen.conditions,e):!0}function $7(t){var e;return((e=t.visibleWhen)==null?void 0:e.hideStrategy)||"unregister"}function As(t,e,n=!1){return typeof t=="boolean"?t:L7(t)?ei(t,e):n}const z7=(t,e)=>{const n=e.split(".");let r=t;for(let i=0;i<n.length-1;i+=1){const s=n[i],a=r==null?void 0:r[s];if(typeof a!="object"||a===null)return;r=a}const o=n[n.length-1];if(Array.isArray(r)){const i=Number(o);Number.isNaN(i)||r.splice(i,1)}else r&&delete r[o]};function H7(t,e,n){const r=structuredClone(e);for(const o of t.fields)n[o.name]===!1&&z7(r,o.name);return r}const Ad="{{$fromAI}}",N_=({value:t,onChange:e,children:n,aiFillable:r=!0,disabled:o=!1})=>{const[i,s]=y.useState(t===Ad),[a,l]=y.useState(void 0);if(y.useEffect(()=>{s(t===Ad)},[t]),!r)return y.cloneElement(n,{value:t,onChange:e});const c=()=>{l(t),s(!0),e==null||e(Ad)},u=()=>{s(!1),e==null||e(a)};return i?h.jsx("div",{className:"ai-field-wrapper ai-mode",children:h.jsxs("div",{className:"ai-field-display",children:[h.jsx(_.Input,{readOnly:!0,value:"由 AI 生成",className:"ai-field-input",prefix:h.jsx(ie.RobotOutlined,{className:"ai-icon"})}),!o&&h.jsx(_.Button,{type:"text",size:"small",icon:h.jsx(ie.CloseOutlined,{}),onClick:u,className:"ai-field-close"})]})}):h.jsxs("div",{className:"ai-field-wrapper normal-mode",children:[h.jsx("div",{className:"ai-field-content",children:y.cloneElement(n,{value:t,onChange:e})}),!o&&h.jsx(_.Button,{type:"link",size:"small",icon:h.jsx(ie.RobotOutlined,{}),onClick:c,className:"ai-enable-button",children:"由 AI 生成"})]})},V7=new Set([ge.NUMBER,ge.SWITCH,ge.PASSWORD]);function ft(t,e={}){const n={needsFormItemName:!0,supportsVariableInsert:!1,supportsAiFillable:!1,...e};if(n.supportsVariableInsert&&n.supportsAiFillable)return{component:t,meta:n};const r=o=>{const{field:i,disabled:s,readOnly:a,context:l,value:c,onChange:u}=o,d=n.valuePropName?o[n.valuePropName]??c:c;let f=h.jsx(t,{...o,value:d});return i.valueModePolicy&&!n.supportsVariableInsert&&!V7.has(i.type)&&(f=h.jsx(Ci,{valueModePolicy:i.valueModePolicy,disabled:s,readOnly:a,placeholder:i.placeholder,validateVariable:l.validateVariable,renderVariableTag:l.renderVariableTag,renderVariableTooltip:l.renderVariableTooltip,modeSwitchPosition:"top-right",value:d,onChange:u,encodeExpressionValue:i.valueModePolicy!=="TEXT",children:f})),i.aiFillable&&!n.supportsAiFillable&&(f=h.jsx(N_,{aiFillable:!0,disabled:s,value:d,onChange:u,children:f})),f};return r.displayName=`FieldComponent(${t.displayName||t.name||"Anonymous"})`,{component:r,meta:n}}function Mo(t,e={}){return{component:t,meta:e}}const B_=({children:t})=>h.jsx(_.Button,{disabled:!0,style:{pointerEvents:"none"},children:t}),F_=({field:t,disabled:e,value:n,onChange:r,id:o})=>{const i=t.showThousandsSeparator?l=>`${l}`.replace(/\B(?=(\d{3})+(?!\d))/g,","):void 0,s=t.showThousandsSeparator?l=>l==null?void 0:l.replace(/\$\s?|(,*)/g,""):void 0,a=h.jsx(_.InputNumber,{disabled:e,placeholder:t.placeholder,min:t.min,max:t.max,step:t.step,precision:t.precision,controls:t.controls,formatter:i,parser:s,style:{width:"100%"},value:n,onChange:r,id:o});return!t.addonBefore&&!t.addonAfter?a:h.jsxs(_.Space.Compact,{style:{width:"100%"},children:[t.addonBefore?h.jsx(B_,{children:t.addonBefore}):null,a,t.addonAfter?h.jsx(B_,{children:t.addonAfter}):null]})};F_.displayName="NumberFieldControl";const j7=ft(F_,{needsFormItemName:!0}),M_=({field:t,disabled:e,readOnly:n,value:r,onChange:o,id:i})=>h.jsx(_.Input.Password,{autoComplete:"new-password",disabled:e,readOnly:n,placeholder:t.placeholder,value:r,onChange:s=>o==null?void 0:o(s.target.value),id:i});M_.displayName="PasswordFieldControl";const W7=ft(M_,{needsFormItemName:!0}),I_=({field:t,disabled:e,readOnly:n,context:r,value:o,onChange:i,id:s})=>{t.autoSize??((t.minRows||t.maxRows)&&(t.minRows,t.maxRows));const a=t.minRows||4,l=()=>{var u;(u=r.eventHandlers)==null||u.onBlur(t.name)},c=()=>{var u;(u=r.eventHandlers)==null||u.onFocus(t.name)};return h.jsx(Ci,{valueModePolicy:t.valueModePolicy,disabled:e,readOnly:n,id:s,placeholder:t.placeholder,multiline:!0,rows:a,validateVariable:r.validateVariable,renderVariableTag:r.renderVariableTag,renderVariableTooltip:r.renderVariableTooltip,modeSwitchPosition:"top-right",value:o,onChange:i,onFocus:c,onBlur:l,textModeSupportsVariables:!0,encodeExpressionValue:t.valueModePolicy!=="TEXT"})};I_.displayName="TextareaFieldControl";const U7=ft(I_,{supportsVariableInsert:!0,needsFormItemName:!0}),P_=({field:t,disabled:e,readOnly:n,value:r,onChange:o,id:i,context:s})=>{const a=()=>{var c;(c=s.eventHandlers)==null||c.onBlur(t.name)},l=()=>{var c;(c=s.eventHandlers)==null||c.onFocus(t.name)};return t.valueModePolicy?h.jsx(Ci,{valueModePolicy:t.valueModePolicy,disabled:e,readOnly:n,id:i,placeholder:t.placeholder,validateVariable:s.validateVariable,renderVariableTag:s.renderVariableTag,renderVariableTooltip:s.renderVariableTooltip,modeSwitchPosition:"top-right",value:r,onChange:o,onFocus:l,onBlur:a,textModeSupportsVariables:!0,encodeExpressionValue:t.valueModePolicy!=="TEXT"}):h.jsx(_.Input,{disabled:e,readOnly:n,placeholder:t.placeholder,value:r,onChange:c=>o==null?void 0:o(c.target.value),onBlur:a,onFocus:l,id:i})};P_.displayName="TextFieldControl";const q7=ft(P_,{supportsVariableInsert:!0,needsFormItemName:!0}),L_=({field:t,disabled:e,readOnly:n,context:r})=>{const o=Ic(),{renderVariableTag:i,renderVariableTooltip:s,validateVariable:a,values:l,optionsLoader:c}=r,u=jg(t.itemSchema,t.valueModePolicy),d=G7(t),f=o.get(u.type),p=f==null?void 0:f.component;return h.jsx(Wg,{policy:t.valueModePolicy,disabled:e,readOnly:n,children:h.jsx(_.Form.List,{name:t.name,rules:d,children:(m,{add:b,remove:v},{errors:w})=>h.jsxs(_.Space,{direction:"vertical",style:{width:"100%"},children:[m.map((g,C)=>h.jsxs(_.Card,{size:"small",title:t.itemLabel||`Item ${C+1}`,children:[h.jsx(_.Form.Item,{name:[g.name,u.name],label:u.label,rules:Ei(u.rules||[],l,u.type),children:p&&h.jsx(p,{field:u,disabled:e,readOnly:!1,context:{values:l,optionsLoader:c,renderVariableTag:i,renderVariableTooltip:s,validateVariable:a}})}),h.jsxs("div",{style:{textAlign:"right"},children:[h.jsx(_.Button,{type:"link",danger:!0,onClick:()=>v(g.name),disabled:e||t.minItems!==void 0&&m.length<=t.minItems,children:"移除"}),t.allowCopy&&h.jsx(_.Button,{type:"link",onClick:()=>{const S=qn(l,`${t.name}.${g.name}`);b(S,C+1)},disabled:e,children:"复制"})]})]},g.key)),h.jsx(_.Button,{type:"dashed",block:!0,onClick:()=>b(u.defaultValue),disabled:e||t.maxItems!==void 0&&m.length>=t.maxItems,children:"添加"}),h.jsx(_.Form.ErrorList,{errors:w})]})})})};L_.displayName="ArrayFieldControl";function G7(t){var n;const e=[];if((n=t.rules)!=null&&n.some(r=>r.type==="required")){const r=t.rules.find(o=>o.type==="required");e.push({validator:async(o,i)=>{if(!i||i.length===0)throw new Error((r==null?void 0:r.message)||"此项为必填")}})}return t.minItems!==void 0&&e.push({validator:async(r,o)=>{if(!o||o.length<t.minItems)throw new Error(`至少需要 ${t.minItems} 项`)}}),t.maxItems!==void 0&&e.push({validator:async(r,o)=>{if(o&&o.length>t.maxItems)throw new Error(`最多允许 ${t.maxItems} 项`)}}),e}const R7=Mo(L_,{isComplexField:!0,supportsVariableInsert:!0,needsFormItemName:!1}),$_=({field:t,disabled:e,context:n})=>{const r=Ic(),o=_.Form.useFormInstance(),{renderVariableTag:i,renderVariableTooltip:s,validateVariable:a,values:l,optionsLoader:c}=n,u=t,d=Y7(u),f=u.__arrayObjectDepth??0,p=u.__arrayObjectLevelBackgroundColors??t.levelBackgroundColors,m=oW(t,f,p),b=aW(t);return h.jsx(_.Form.List,{name:u.name,rules:b,children:(v,{add:w,remove:g,move:C},{errors:S})=>h.jsxs(_.Space,{direction:"vertical",style:{width:"100%"},children:[v.map((k,x)=>h.jsx(_.Card,{size:"small",style:iW(m),styles:{body:sW(m)},title:h.jsx(z_,{field:t,index:x,titlePath:X7(t,d,k.name),disabled:e}),extra:h.jsxs(_.Space,{children:[t.allowCopy&&h.jsx(_.Tooltip,{title:"复制",children:h.jsx(_.Button,{"aria-label":"复制",type:"text",size:"small",icon:h.jsx(ie.CopyOutlined,{}),onClick:()=>{const D=[...d,k.name],E=o.getFieldValue(D)??V_(l,D);w(E,x+1)},disabled:e||t.maxItems!==void 0&&v.length>=t.maxItems})}),h.jsx(_.Tooltip,{title:"置顶",children:h.jsx(_.Button,{"aria-label":"置顶",type:"text",size:"small",icon:h.jsx(ie.VerticalAlignTopOutlined,{}),disabled:e||x===0,onClick:()=>C(x,0)})}),h.jsx(_.Tooltip,{title:"向上",children:h.jsx(_.Button,{"aria-label":"向上",type:"text",size:"small",icon:h.jsx(ie.ArrowUpOutlined,{}),disabled:e||x===0,onClick:()=>C(x,x-1)})}),h.jsx(_.Tooltip,{title:"向下",children:h.jsx(_.Button,{"aria-label":"向下",type:"text",size:"small",icon:h.jsx(ie.ArrowDownOutlined,{}),disabled:e||x===v.length-1,onClick:()=>C(x,x+1)})}),h.jsx(_.Tooltip,{title:"置底",children:h.jsx(_.Button,{"aria-label":"置底",type:"text",size:"small",icon:h.jsx(ie.VerticalAlignBottomOutlined,{}),disabled:e||x===v.length-1,onClick:()=>C(x,v.length-1)})}),h.jsx(_.Tooltip,{title:"删除",children:h.jsx(_.Button,{"aria-label":"删除",type:"text",size:"small",danger:!0,icon:h.jsx(ie.DeleteOutlined,{}),onClick:()=>g(k.name),disabled:e||t.minItems!==void 0&&v.length<=t.minItems})})]}),children:h.jsx("div",{style:tW(t),children:t.columns.map(D=>{const E=r.get(D.type),O=E==null?void 0:E.component,A=[k.name,D.name],T=[...d,k.name,D.name];return h.jsx(_.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const B=o.getFieldValue([...d,k.name])??V_(l,[...d,k.name])??{};return yl(D,B)?E!=null&&E.meta.isHidden?h.jsx(_.Form.Item,{name:A,hidden:!0,rules:Ei(D.rules||[],B,D.type),valuePropName:E.meta.valuePropName,validateTrigger:D.validateTrigger,children:O&&h.jsx(O,{field:D,disabled:e,readOnly:!1,context:{values:l,optionsLoader:c,renderVariableTag:i,renderVariableTooltip:s,validateVariable:a}})}):E!=null&&E.meta.isComplexField?h.jsx(_.Form.Item,{label:D.label,tooltip:D.tooltip,extra:D.helpText||D.extra||D.description,children:O&&h.jsx(O,{field:K7(D,A,T,f+1,p),disabled:e,readOnly:!1,context:{values:l,optionsLoader:c,renderVariableTag:i,renderVariableTooltip:s,validateVariable:a}})}):h.jsx(_.Form.Item,{name:A,label:D.label,tooltip:D.tooltip,extra:D.helpText||D.extra||D.description,rules:Ei(D.rules||[],B,D.type),children:O&&h.jsx(O,{field:D,disabled:e,readOnly:!1,context:{values:l,optionsLoader:c,renderVariableTag:i,renderVariableTooltip:s,validateVariable:a}})}):null}},D.name)})})},k.key)),h.jsx(_.Button,{type:"dashed",block:!0,icon:h.jsx(ie.PlusOutlined,{}),onClick:()=>w(),disabled:e||t.maxItems!==void 0&&v.length>=t.maxItems,children:eW(t)}),h.jsx(_.Form.ErrorList,{errors:S})]})})};$_.displayName="ArrayObjectFieldControl";const z_=({field:t,index:e,titlePath:n,disabled:r})=>{const o=_.Form.useFormInstance(),i=_.Form.useWatch(n,o),[s,a]=vt.useState(!1),[l,c]=vt.useState(""),u=Z7(t,e),d=Q7(i,u),f=()=>{c(d),a(!0)},p=()=>{c(""),a(!1)},m=()=>{if(n){const b=l.trim()||void 0;o.setFieldValue(n,b)}a(!1),c("")};return n?s?h.jsxs(_.Space,{children:[h.jsx(_.Input,{size:"small",value:l,onChange:b=>c(b.target.value),onPressEnter:m,style:{width:200},placeholder:"请输入标题"}),h.jsx(_.Button,{"aria-label":"保存标题",type:"text",size:"small",icon:h.jsx(ie.CheckOutlined,{style:{color:"#52c41a"}}),onClick:m}),h.jsx(_.Button,{"aria-label":"取消标题编辑",type:"text",size:"small",icon:h.jsx(ie.CloseOutlined,{}),onClick:p})]}):h.jsxs(_.Space,{children:[h.jsx("span",{children:d}),h.jsx(_.Button,{"aria-label":"编辑标题",type:"text",size:"small",icon:h.jsx(ie.EditOutlined,{}),disabled:r,onClick:f})]}):h.jsx("span",{children:d})};z_.displayName="ArrayObjectRowTitle";function K7(t,e,n,r,o){return{...t,name:e,__arrayObjectRootNamePath:n,__arrayObjectDepth:r,__arrayObjectLevelBackgroundColors:o}}function H_(t){return Array.isArray(t)?t:[t]}function Y7(t){return t.__arrayObjectRootNamePath??H_(t.name)}function V_(t,e){return qn(t,H_(e).join("."))}function X7(t,e,n){const r=J7(t);return r?[...e,n,r]:void 0}function J7(t){return t.titleFieldName?t.titleFieldName:t.titleEditable?"title":void 0}function Q7(t,e){return typeof t=="string"&&t.trim()?t:e}function Z7(t,e){return t.label?`${t.label} #${e+1}`:`Item ${e+1}`}function eW(t){return t.label?`添加${t.label}`:"添加行"}function tW(t){return t.columnLayout!=="grid"?{display:"flex",flexDirection:"column",width:"100%",gap:0}:{display:"grid",gridTemplateColumns:`repeat(${nW(t)}, minmax(0, 1fr))`,columnGap:16,rowGap:0,width:"100%",alignItems:"start"}}function nW(t){const e=t.columns.filter(r=>!rW(r)).length,n=typeof t.columnCount=="number"&&Number.isFinite(t.columnCount)?Math.floor(t.columnCount):3;return Math.max(1,Math.min(n,Math.max(e,1)))}function rW(t){return t.type===ge.HIDDEN}function oW(t,e,n){if(t.backgroundColor)return t.backgroundColor;if(n!=null&&n.length)return n[e%n.length]}function iW(t){if(t)return{backgroundColor:t}}function sW(t){if(t)return{backgroundColor:t}}function aW(t){var n;const e=[];if((n=t.rules)!=null&&n.some(r=>r.type==="required")){const r=t.rules.find(o=>o.type==="required");e.push({validator:async(o,i)=>{if(!i||i.length===0)throw new Error((r==null?void 0:r.message)||"此项为必填")}})}return t.minItems!==void 0&&e.push({validator:async(r,o)=>{if(!o||o.length<t.minItems)throw new Error(`至少需要 ${t.minItems} 项`)}}),t.maxItems!==void 0&&e.push({validator:async(r,o)=>{if(o&&o.length>t.maxItems)throw new Error(`最多允许 ${t.maxItems} 项`)}}),e}const lW=Mo($_,{isComplexField:!0,needsFormItemName:!1});/**
|
|
52
|
+
`),F7=y.forwardRef(({onValueChange:t=f=>{},removeTagButton:e=!1,initValue:n,onFocus:r,onBlur:o,addImageElement:i,transformInputText:s,transformInputElement:a,textAreaMode:l,capturePattern:c=yz,disabled:u},d)=>{const f=y.useRef(null),p=y.useMemo(()=>T7(S7(jV()),c),[]),[m,b]=y.useState(od(n,c));let v=n;const w=y.useCallback(({element:x,children:D,attributes:E})=>{switch(x.type){case"paragraph":return h.jsx(O7,{attributes:E,element:x,children:D});case"tag":return h.jsx(A7,{attributes:E,element:x,removeTagButton:e,addImageElement:i,transformInputText:s,transformInputElement:a,children:D});default:return h.jsx(_7,{attributes:E,element:x,children:D})}},[]);y.useEffect(()=>{b(od(n,c))},[n]);const g=y.useCallback(x=>{f.current=p.selection;const D=B7(x);D!==v&&(v=x,b(x),t(D))},[]),C=x=>{ue.delete(p,{at:[0]});const D=od(x,c);p.children=od("",c),ue.insertNodes(p,D,{at:[0]})},S=x=>{var D;__(p,x,{at:(D=f.current)==null?void 0:D.focus}),ue.move(p,{distance:m.length-1})};y.useImperativeHandle(d,()=>({insertTag:S,setValueByParent:C}));const k=At();return h.jsx(C7,{editor:p,initialValue:m,onChange:g,children:h.jsx(p7,{style:l?{minHeight:60,maxHeight:200}:{maxHeight:150},onFocus:r,onBlur:o,readOnly:!k||u,spellCheck:!1,className:"ce-tag_input",renderElement:w})})}),A_=t=>h.jsx("div",{style:{display:t.show?"block":"none",height:"100%",width:"100%",...t.style??{}},children:t.children}),In=t=>{const e=At(),n=y.useMemo(()=>Mn(),[]),{event$:r}=y.useContext(Qr),o=Ym(n),i=y.useRef(null),[s,a]=y.useState(""),l=St.useReactive({innerValueType:"",radioType:"",openEditorNumber:0});y.useEffect(()=>{l.radioType=t.valueType},[t.valueType,l]),r.useSubscription(f=>{var p,m,b;if(f.type==="insert"&&f.currentInputId===n){(m=i==null?void 0:(p=i.current).insertTag)==null||m.call(p,f.expression.slice(2,-2));const v=(s??"")+(t.valueType==="FIX_VALUE"?f.expression.slice(2,-2):f.expression);a(v),(b=t.onChange)==null||b.call(t,v)}});const c=y.useMemo(()=>!t.borrow&&["JS_EXP","ADAPTOR"].includes(t.valueType),[t.borrow,t.valueType]);y.useEffect(()=>{a(t.value)},[t.value]);const u=f=>{var p;(p=t.onChange)==null||p.call(t,f)},d=f=>{var p;a(f),(p=t.onChange)==null||p.call(t,f)};return h.jsxs(gC,{id:n,canEditInEditor:e&&!t.disableIDE,openEditorNumber:l.openEditorNumber,nodeId:t.nodeId,value:t.value,onFinish:f=>{i.current.setValueByParent(f)},children:[c&&h.jsx("div",{style:{textAlign:"right",position:"absolute",top:-34,right:2},children:h.jsxs(_.Radio.Group,{value:l.radioType,onChange:f=>{l.radioType=f.target.value,l.radioType==="ADAPTOR"&&i.current.setValueByParent(s)},size:"small",style:{marginTop:16},children:[h.jsx(_.Radio.Button,{style:{height:18,fontSize:10,display:"inline-flex",alignItems:"center"},value:"ADAPTOR",children:h.jsx(Te.FormattedMessage,{id:"link.flow.string"})}),h.jsx(_.Radio.Button,{style:{height:18,fontSize:10,display:"inline-flex",alignItems:"center"},value:"JS_EXP",children:h.jsx(Te.FormattedMessage,{id:"link.flow.script"})})]})}),h.jsx(A_,{show:l.radioType==="ADAPTOR"||!c&&l.radioType!=="PLAIN_CODE",children:h.jsx("div",{className:o?rd:void 0,children:h.jsx(F7,{id:n,ref:i,disabled:t.disabled,textAreaMode:t.textAreaMode,initValue:t.value,onFocus:()=>{["JS_EXP","FIX_VALUE","ADAPTOR","PLAIN_TEXT","PLAIN_CODE"].includes(t.valueType)&&(r.emit({type:"visible",visible:!0}),r.emit({type:"setCurrentInputId",currentInputId:n})),t.onFocus&&t.onFocus()},onBlur:()=>{t.onBlur&&t.onBlur()},removeTagButton:!1,onValueChange:u,addImageElement:f=>{const m=(f==null?void 0:f.split(".")[0]).slice(1),b=il.getConfig().icons.get(m);return b?h.jsx("img",{src:b,alt:m,onError:v=>{v.target.src="/uc/images/default_connector.png"}}):h.jsx(ie.ThunderboltOutlined,{})},transformInputText:f=>Mt.includes(["sys_tenant_id","response"],f)?f:f.split(".").slice(1).join("."),transformInputElement:f=>h.jsx("span",{style:{color:"blue"},children:f})})})}),h.jsxs(A_,{show:(l.radioType==="JS_EXP"||l.radioType==="PLAIN_CODE")&&(l.radioType==="PLAIN_CODE"||c),style:{position:"relative"},children:[h.jsx("div",{children:h.jsx(vz,{...t,onValueChange:d})}),h.jsx("button",{type:"button","aria-label":"在在线 IDE 中编辑",title:"在在线 IDE 中编辑",className:"workflow-online-ide-trigger",disabled:!e,onClick:()=>{l.openEditorNumber++},children:h.jsx(ie.FullscreenOutlined,{})})]})]})};function jg(t,e){return e?{...t,valueModePolicy:e}:t}const Wg=({policy:t,disabled:e,readOnly:n,children:r})=>{const[o,i]=y.useState(()=>t?Mh(t).defaultMode:"normal"),s=y.useCallback(a=>{i(a)},[]);return t?h.jsx(pC,{policy:t,mode:o,onModeChange:s,children:h.jsxs("div",{className:"value-mode-wrapper",children:[h.jsx(Ih,{valueModePolicy:t,mode:o,onModeChange:s,disabled:e,readOnly:n,modeSwitchPosition:"top-right"}),h.jsx("div",{className:"value-mode-content",children:r})]})}):h.jsx(h.Fragment,{children:r})},Ed="${",xd="}",O_="\\$";function Dd(t){return typeof t=="string"&&t.startsWith(Ed)&&t.endsWith(xd)&&t.length>=Ed.length+xd.length}function Ug(t){if(typeof t=="string")return t;if(t==null)return"";try{return typeof t=="object"?JSON.stringify(t)??"":String(t)}catch{return""}}function _d(t,e,n){const r=Ug(t);return n?e==="expression"?`${Ed}${r}${xd}`:e==="normal"&&r.startsWith("$")?`${O_}${r.slice(1)}`:r:r}function _s(t,e,n){const r=Ug(t);return n?e==="expression"&&Dd(r)?r.slice(Ed.length,-xd.length):e==="normal"&&r.startsWith(O_)?r.slice(1):r:r}function T_(t,e,n,r=mC){return n?r.includes("expression")&&Dd(t)?"expression":e:r.includes("expression")&&typeof t=="string"&&/\{\{.*\}\}/.test(t)?"expression":e}const Ci=({value:t="",onChange:e,valueModePolicy:n,availableModes:r=mC,defaultMode:o="normal",mode:i,onModeChange:s,disabled:a=!1,readOnly:l=!1,id:c,placeholder:u,multiline:d=!1,rows:f=4,textModeSupportsVariables:p=!1,encodeExpressionValue:m=!1,onFocus:b,onBlur:v,renderNormalMode:w,renderExpressionMode:g,children:C,hideModeSwitch:S=!1,modeSwitchPosition:k="top-left",compact:x=!1})=>{const D=hC(),E=n??(D==null?void 0:D.policy),O=S||!!(D!=null&&D.suppressNestedSwitch),A=i??(D!=null&&D.suppressNestedSwitch?D.mode:void 0),T=s??(D!=null&&D.suppressNestedSwitch?D.onModeChange:void 0),B=E?Mh(E):void 0,M=(B==null?void 0:B.availableModes)??r,F=(B==null?void 0:B.defaultMode)??o,N=M.length===1?M[0]:void 0,P=Ug(t),I=y.useRef(P),z=y.useRef(void 0),H=y.useRef(e);H.current=e;const J=()=>T_(P,F,m,M),[K,ee]=y.useState(J),$=N??A??K,U=y.useMemo(()=>_s(P,$,m),[P,$,m]);y.useEffect(()=>{A!==void 0&&ee(A)},[A]),y.useEffect(()=>{var X;if(!m||A===void 0){z.current=$;return}const Y=z.current;if(z.current=$,Y===void 0||Y===$)return;const W=_d(_s(P,Y,!0),$,!0);W!==P&&(I.current=W,(X=H.current)==null||X.call(H,W))},[$,m,A,P]),y.useEffect(()=>{!m||A!==void 0||I.current!==P&&(I.current=P,ee(T_(P,F,!0,M)))},[M,A,F,m,P]),y.useEffect(()=>{var W;if(!m||!N||!P.trim())return;const Y=_d(_s(P,N,!0),N,!0);Y===P||I.current===Y||(I.current=Y,(W=H.current)==null||W.call(H,Y))},[m,N,P]);const R=y.useCallback(Y=>{if(ee(Y),T==null||T(Y),m){const W=_d(U,Y,!0);I.current=W,z.current=Y,e==null||e(W)}},[U,m,e,T]),te=y.useCallback(Y=>{const W=_d(Y,$,m);I.current=W,e==null||e(W)},[$,m,e]),se=()=>O||!E?null:h.jsx(Ih,{valueModePolicy:E,mode:$,onModeChange:R,disabled:a,readOnly:l,modeSwitchPosition:k}),be=Y=>h.jsx(In,{valueType:"FIX_VALUE",value:U,onChange:te,placeholder:u,disabled:a,onFocus:b,onBlur:v}),j=()=>{switch($){case"normal":return p?be():C?vt.cloneElement(C,{value:U,onChange:te,disabled:a,readOnly:l}):w?w({value:U,onChange:te,disabled:a,readOnly:l,placeholder:u}):d?h.jsx(_.Input.TextArea,{id:c,value:U,onChange:Y=>te(Y.target.value),disabled:a,readOnly:l,placeholder:u,rows:f,onFocus:b,onBlur:v}):h.jsx(_.Input,{id:c,value:U,onChange:Y=>te(Y.target.value),disabled:a,readOnly:l,placeholder:u,onFocus:b,onBlur:v});case"expression":return g?g({value:U,onChange:te,disabled:a,readOnly:l,placeholder:u}):be();case"code":return h.jsx(_.Input.TextArea,{id:c,value:U,onChange:Y=>te(Y.target.value),disabled:a,readOnly:l,placeholder:u||"// 输入 JavaScript 代码",rows:f,className:"code-mode-textarea",style:{fontFamily:"monospace"},onFocus:b,onBlur:v});default:return null}};return h.jsxs("div",{className:`value-mode-wrapper${x?" compact":""}`,children:[se(),h.jsx("div",{className:"value-mode-content",children:j()})]})};function M7(t){switch(t){case ge.NUMBER:case ge.SLIDER:case ge.RATE:return"number";case ge.CHECKBOX:case ge.SWITCH:return"boolean";case ge.MULTI_SELECT:case ge.CHECKBOX_GROUP:case ge.DATE_RANGE:case ge.TIME_RANGE:case ge.ARRAY:case ge.ARRAY_OBJECT:return"array";case ge.DATE:case ge.DATETIME:case ge.TIME:return"object";case ge.OBJECT:case ge.KEY_VALUE:return"object";default:return}}function ki(t){return Dd(t)}function Si(t){return ki(t)?null:_s(t,"normal",!0)}function I7(t){return t==null?!0:Array.isArray(t)?t.length===0:Dd(t)?_s(t,"expression",!0).trim()==="":typeof t=="string"?_s(t,"normal",!0).trim()==="":!1}function qg(t){return{message:t,validator:async(e,n)=>{if(I7(n))throw new Error(t||"此项为必填")}}}function Ei(t,e,n){const r=[],o=n?M7(n):void 0;for(const i of t){if(i.type==="when"){ei(i.conditions,e)&&r.push(...Ei(i.rules,e,n));continue}const s=P7(i,o);s&&r.push(s)}return r}function P7(t,e){const n={message:t.message,warningOnly:t.warningOnly};switch(t.type){case"required":return qg(t.message);case"type":return{...n,validator:async(r,o)=>{if(o==null||o===""||ki(o))return;const i=Si(o);if(i!=null){if(t.value==="email"&&!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(i))throw new Error(t.message||"类型不正确");if(t.value==="url")try{new URL(i)}catch{throw new Error(t.message||"类型不正确")}if(t.value==="string"&&typeof o!="string"&&i==="")throw new Error(t.message||"类型不正确");if((t.value==="number"||t.value==="float"||t.value==="integer")&&Number.isNaN(Number(i)))throw new Error(t.message||"类型不正确");if(t.value==="integer"&&!Number.isInteger(Number(i)))throw new Error(t.message||"类型不正确");if(t.value==="boolean"&&typeof o!="boolean")throw new Error(t.message||"类型不正确");if(t.value==="array"&&!Array.isArray(o))throw new Error(t.message||"类型不正确");if(t.value==="object"&&(typeof o!="object"||o==null||Array.isArray(o)))throw new Error(t.message||"类型不正确")}}};case"min":return{...n,validator:async(r,o)=>{if(o==null||o===""||ki(o))return;if(e==="number"||typeof o=="number"){if(Number(o)<t.value)throw new Error(t.message||`最小值 ${t.value}`);return}if(e==="array"||Array.isArray(o)){if(!Array.isArray(o)||o.length<t.value)throw new Error(t.message||`至少 ${t.value} 项`);return}const i=Si(o);if(i!=null&&i.length<t.value)throw new Error(t.message||`最少 ${t.value} 个字符`)}};case"max":return{...n,validator:async(r,o)=>{if(o==null||o===""||ki(o))return;if(e==="number"||typeof o=="number"){if(Number(o)>t.value)throw new Error(t.message||`最大值 ${t.value}`);return}if(e==="array"||Array.isArray(o)){if(Array.isArray(o)&&o.length>t.value)throw new Error(t.message||`最多 ${t.value} 项`);return}const i=Si(o);if(i!=null&&i.length>t.value)throw new Error(t.message||`最多 ${t.value} 个字符`)}};case"len":return{...n,validator:async(r,o)=>{if(o==null||o===""||ki(o))return;if(Array.isArray(o)){if(o.length!==t.value)throw new Error(t.message||`长度须为 ${t.value}`);return}const i=Si(o);if(i!=null&&i.length!==t.value)throw new Error(t.message||`长度须为 ${t.value}`)}};case"pattern":{const r=new RegExp(t.value,t.flags);return{...n,validator:async(o,i)=>{if(i==null||i==="")return;const s=Si(i);if(s!=null&&!r.test(s))throw new Error(t.message||"格式不正确")}}}case"enum":return{...n,validator:async(r,o)=>{if(o==null||o===""||ki(o))return;const s=Si(o)??o;if(!t.value.includes(s))throw new Error(t.message||"不在可选范围内")}};case"whitespace":return{...n,validator:async(r,o)=>{if(o==null||o===""||ki(o))return;const i=Si(o);if(i!=null&&i.length>0&&i.trim()==="")throw new Error(t.message||"不能只包含空白字符")}};default:return null}}const L7=t=>!t||typeof t!="object"?!1:"AND"in t||"OR"in t?!0:"keyword"in t&&"key"in t;function yl(t,e){return t.visibleWhen&&t.visibleWhen.conditions?ei(t.visibleWhen.conditions,e):!0}function $7(t){var e;return((e=t.visibleWhen)==null?void 0:e.hideStrategy)||"unregister"}function As(t,e,n=!1){return typeof t=="boolean"?t:L7(t)?ei(t,e):n}const z7=(t,e)=>{const n=e.split(".");let r=t;for(let i=0;i<n.length-1;i+=1){const s=n[i],a=r==null?void 0:r[s];if(typeof a!="object"||a===null)return;r=a}const o=n[n.length-1];if(Array.isArray(r)){const i=Number(o);Number.isNaN(i)||r.splice(i,1)}else r&&delete r[o]};function H7(t,e,n){const r=structuredClone(e);for(const o of t.fields)n[o.name]===!1&&z7(r,o.name);return r}const Ad="{{$fromAI}}",N_=({value:t,onChange:e,children:n,aiFillable:r=!0,disabled:o=!1})=>{const[i,s]=y.useState(t===Ad),[a,l]=y.useState(void 0);if(y.useEffect(()=>{s(t===Ad)},[t]),!r)return y.cloneElement(n,{value:t,onChange:e});const c=()=>{l(t),s(!0),e==null||e(Ad)},u=()=>{s(!1),e==null||e(a)};return i?h.jsx("div",{className:"ai-field-wrapper ai-mode",children:h.jsxs("div",{className:"ai-field-display",children:[h.jsx(_.Input,{readOnly:!0,value:"由 AI 生成",className:"ai-field-input",prefix:h.jsx(ie.RobotOutlined,{className:"ai-icon"})}),!o&&h.jsx(_.Button,{type:"text",size:"small",icon:h.jsx(ie.CloseOutlined,{}),onClick:u,className:"ai-field-close"})]})}):h.jsxs("div",{className:"ai-field-wrapper normal-mode",children:[h.jsx("div",{className:"ai-field-content",children:y.cloneElement(n,{value:t,onChange:e})}),!o&&h.jsx(_.Button,{type:"link",size:"small",icon:h.jsx(ie.RobotOutlined,{}),onClick:c,className:"ai-enable-button",children:"由 AI 生成"})]})},V7=new Set([ge.NUMBER,ge.SWITCH,ge.PASSWORD]);function ft(t,e={}){const n={needsFormItemName:!0,supportsVariableInsert:!1,supportsAiFillable:!1,...e};if(n.supportsVariableInsert&&n.supportsAiFillable)return{component:t,meta:n};const r=o=>{const{field:i,disabled:s,readOnly:a,context:l,value:c,onChange:u}=o,d=n.valuePropName?o[n.valuePropName]??c:c;let f=h.jsx(t,{...o,value:d});return i.valueModePolicy&&!n.supportsVariableInsert&&!V7.has(i.type)&&(f=h.jsx(Ci,{valueModePolicy:i.valueModePolicy,disabled:s,readOnly:a,placeholder:i.placeholder,validateVariable:l.validateVariable,renderVariableTag:l.renderVariableTag,renderVariableTooltip:l.renderVariableTooltip,modeSwitchPosition:"top-right",value:d,onChange:u,encodeExpressionValue:i.valueModePolicy!=="TEXT",children:f})),i.aiFillable&&!n.supportsAiFillable&&(f=h.jsx(N_,{aiFillable:!0,disabled:s,value:d,onChange:u,children:f})),f};return r.displayName=`FieldComponent(${t.displayName||t.name||"Anonymous"})`,{component:r,meta:n}}function Mo(t,e={}){return{component:t,meta:e}}const B_=({children:t})=>h.jsx(_.Button,{disabled:!0,style:{pointerEvents:"none"},children:t}),F_=({field:t,disabled:e,value:n,onChange:r,id:o})=>{const i=t.showThousandsSeparator?l=>`${l}`.replace(/\B(?=(\d{3})+(?!\d))/g,","):void 0,s=t.showThousandsSeparator?l=>l==null?void 0:l.replace(/\$\s?|(,*)/g,""):void 0,a=h.jsx(_.InputNumber,{disabled:e,placeholder:t.placeholder,min:t.min,max:t.max,step:t.step,precision:t.precision,controls:t.controls,formatter:i,parser:s,style:{width:"100%"},value:n,onChange:r,id:o});return!t.addonBefore&&!t.addonAfter?a:h.jsxs(_.Space.Compact,{style:{width:"100%"},children:[t.addonBefore?h.jsx(B_,{children:t.addonBefore}):null,a,t.addonAfter?h.jsx(B_,{children:t.addonAfter}):null]})};F_.displayName="NumberFieldControl";const j7=ft(F_,{needsFormItemName:!0}),M_=({field:t,disabled:e,readOnly:n,value:r,onChange:o,id:i})=>h.jsx(_.Input.Password,{autoComplete:"new-password",disabled:e,readOnly:n,placeholder:t.placeholder,value:r,onChange:s=>o==null?void 0:o(s.target.value),id:i});M_.displayName="PasswordFieldControl";const W7=ft(M_,{needsFormItemName:!0}),I_=({field:t,disabled:e,readOnly:n,context:r,value:o,onChange:i,id:s})=>{t.autoSize??((t.minRows||t.maxRows)&&(t.minRows,t.maxRows));const a=t.minRows||4,l=()=>{var u;(u=r.eventHandlers)==null||u.onBlur(t.name)},c=()=>{var u;(u=r.eventHandlers)==null||u.onFocus(t.name)};return h.jsx(Ci,{valueModePolicy:t.valueModePolicy,disabled:e,readOnly:n,id:s,placeholder:t.placeholder,multiline:!0,rows:a,validateVariable:r.validateVariable,renderVariableTag:r.renderVariableTag,renderVariableTooltip:r.renderVariableTooltip,modeSwitchPosition:"top-right",value:o,onChange:i,onFocus:c,onBlur:l,textModeSupportsVariables:!0,encodeExpressionValue:t.valueModePolicy!=="TEXT"})};I_.displayName="TextareaFieldControl";const U7=ft(I_,{supportsVariableInsert:!0,needsFormItemName:!0}),P_=({field:t,disabled:e,readOnly:n,value:r,onChange:o,id:i,context:s})=>{const a=()=>{var c;(c=s.eventHandlers)==null||c.onBlur(t.name)},l=()=>{var c;(c=s.eventHandlers)==null||c.onFocus(t.name)};return t.valueModePolicy?h.jsx(Ci,{valueModePolicy:t.valueModePolicy,disabled:e,readOnly:n,id:i,placeholder:t.placeholder,validateVariable:s.validateVariable,renderVariableTag:s.renderVariableTag,renderVariableTooltip:s.renderVariableTooltip,modeSwitchPosition:"top-right",value:r,onChange:o,onFocus:l,onBlur:a,textModeSupportsVariables:!0,encodeExpressionValue:t.valueModePolicy!=="TEXT"}):h.jsx(_.Input,{disabled:e,readOnly:n,placeholder:t.placeholder,value:r,onChange:c=>o==null?void 0:o(c.target.value),onBlur:a,onFocus:l,id:i})};P_.displayName="TextFieldControl";const q7=ft(P_,{supportsVariableInsert:!0,needsFormItemName:!0}),L_=({field:t,disabled:e,readOnly:n,context:r})=>{const o=Ic(),{renderVariableTag:i,renderVariableTooltip:s,validateVariable:a,values:l,optionsLoader:c}=r,u=jg(t.itemSchema,t.valueModePolicy),d=G7(t),f=o.get(u.type),p=f==null?void 0:f.component;return h.jsx(Wg,{policy:t.valueModePolicy,disabled:e,readOnly:n,children:h.jsx(_.Form.List,{name:t.name,rules:d,children:(m,{add:b,remove:v},{errors:w})=>h.jsxs(_.Space,{direction:"vertical",style:{width:"100%"},children:[m.map((g,C)=>h.jsxs(_.Card,{size:"small",title:t.itemLabel||`Item ${C+1}`,children:[h.jsx(_.Form.Item,{name:[g.name,u.name],label:u.label,rules:Ei(u.rules||[],l,u.type),children:p&&h.jsx(p,{field:u,disabled:e,readOnly:!1,context:{values:l,optionsLoader:c,renderVariableTag:i,renderVariableTooltip:s,validateVariable:a}})}),h.jsxs("div",{style:{textAlign:"right"},children:[h.jsx(_.Button,{type:"link",danger:!0,onClick:()=>v(g.name),disabled:e||t.minItems!==void 0&&m.length<=t.minItems,children:"移除"}),t.allowCopy&&h.jsx(_.Button,{type:"link",onClick:()=>{const S=qn(l,`${t.name}.${g.name}`);b(S,C+1)},disabled:e,children:"复制"})]})]},g.key)),h.jsx(_.Button,{type:"dashed",block:!0,onClick:()=>b(u.defaultValue),disabled:e||t.maxItems!==void 0&&m.length>=t.maxItems,children:"添加"}),h.jsx(_.Form.ErrorList,{errors:w})]})})})};L_.displayName="ArrayFieldControl";function G7(t){var n;const e=[];if((n=t.rules)!=null&&n.some(r=>r.type==="required")){const r=t.rules.find(o=>o.type==="required");e.push({validator:async(o,i)=>{if(!i||i.length===0)throw new Error((r==null?void 0:r.message)||"此项为必填")}})}return t.minItems!==void 0&&e.push({validator:async(r,o)=>{if(!o||o.length<t.minItems)throw new Error(`至少需要 ${t.minItems} 项`)}}),t.maxItems!==void 0&&e.push({validator:async(r,o)=>{if(o&&o.length>t.maxItems)throw new Error(`最多允许 ${t.maxItems} 项`)}}),e}const R7=Mo(L_,{isComplexField:!0,supportsVariableInsert:!0,needsFormItemName:!1}),$_=({field:t,disabled:e,context:n})=>{const r=Ic(),o=_.Form.useFormInstance(),{renderVariableTag:i,renderVariableTooltip:s,validateVariable:a,values:l,optionsLoader:c}=n,u=t,d=Y7(u),f=u.__arrayObjectDepth??0,p=u.__arrayObjectLevelBackgroundColors??t.levelBackgroundColors,m=oW(t,f,p),b=aW(t);return h.jsx(_.Form.List,{name:u.name,rules:b,children:(v,{add:w,remove:g,move:C},{errors:S})=>h.jsxs(_.Space,{direction:"vertical",style:{width:"100%"},children:[v.map((k,x)=>h.jsx(_.Card,{size:"small",style:iW(m),styles:{body:sW(m)},title:h.jsx(z_,{field:t,index:x,titlePath:X7(t,d,k.name),disabled:e}),extra:h.jsxs(_.Space,{children:[t.allowCopy&&h.jsx(_.Tooltip,{title:"复制",children:h.jsx(_.Button,{"aria-label":"复制",type:"text",size:"small",icon:h.jsx(ie.CopyOutlined,{}),onClick:()=>{const D=[...d,k.name],E=o.getFieldValue(D)??V_(l,D);w(E,x+1)},disabled:e||t.maxItems!==void 0&&v.length>=t.maxItems})}),h.jsx(_.Tooltip,{title:"置顶",children:h.jsx(_.Button,{"aria-label":"置顶",type:"text",size:"small",icon:h.jsx(ie.VerticalAlignTopOutlined,{}),disabled:e||x===0,onClick:()=>C(x,0)})}),h.jsx(_.Tooltip,{title:"向上",children:h.jsx(_.Button,{"aria-label":"向上",type:"text",size:"small",icon:h.jsx(ie.ArrowUpOutlined,{}),disabled:e||x===0,onClick:()=>C(x,x-1)})}),h.jsx(_.Tooltip,{title:"向下",children:h.jsx(_.Button,{"aria-label":"向下",type:"text",size:"small",icon:h.jsx(ie.ArrowDownOutlined,{}),disabled:e||x===v.length-1,onClick:()=>C(x,x+1)})}),h.jsx(_.Tooltip,{title:"置底",children:h.jsx(_.Button,{"aria-label":"置底",type:"text",size:"small",icon:h.jsx(ie.VerticalAlignBottomOutlined,{}),disabled:e||x===v.length-1,onClick:()=>C(x,v.length-1)})}),h.jsx(_.Tooltip,{title:"删除",children:h.jsx(_.Button,{"aria-label":"删除",type:"text",size:"small",danger:!0,icon:h.jsx(ie.DeleteOutlined,{}),onClick:()=>g(k.name),disabled:e||t.minItems!==void 0&&v.length<=t.minItems})})]}),children:h.jsx("div",{style:tW(t),children:t.columns.map(D=>{const E=r.get(D.type),O=E==null?void 0:E.component,A=[k.name,D.name],T=[...d,k.name,D.name];return h.jsx(_.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const B=o.getFieldValue([...d,k.name])??V_(l,[...d,k.name])??{};return yl(D,B)?E!=null&&E.meta.isHidden?h.jsx(_.Form.Item,{name:A,hidden:!0,rules:Ei(D.rules||[],B,D.type),valuePropName:E.meta.valuePropName,validateTrigger:D.validateTrigger,children:O&&h.jsx(O,{field:D,disabled:e,readOnly:!1,context:{values:l,optionsLoader:c,renderVariableTag:i,renderVariableTooltip:s,validateVariable:a}})}):E!=null&&E.meta.isComplexField?h.jsx(_.Form.Item,{label:D.label,tooltip:D.tooltip,extra:D.helpText||D.extra||D.description,children:O&&h.jsx(O,{field:K7(D,A,T,f+1,p),disabled:e,readOnly:!1,context:{values:l,optionsLoader:c,renderVariableTag:i,renderVariableTooltip:s,validateVariable:a}})}):h.jsx(_.Form.Item,{name:A,label:D.label,tooltip:D.tooltip,extra:D.helpText||D.extra||D.description,rules:Ei(D.rules||[],B,D.type),children:O&&h.jsx(O,{field:D,disabled:e,readOnly:!1,context:{values:l,optionsLoader:c,renderVariableTag:i,renderVariableTooltip:s,validateVariable:a}})}):null}},D.name)})})},k.key)),h.jsx(_.Button,{type:"dashed",block:!0,icon:h.jsx(ie.PlusOutlined,{}),onClick:()=>w(),disabled:e||t.maxItems!==void 0&&v.length>=t.maxItems,children:eW(t)}),h.jsx(_.Form.ErrorList,{errors:S})]})})};$_.displayName="ArrayObjectFieldControl";const z_=({field:t,index:e,titlePath:n,disabled:r})=>{const o=_.Form.useFormInstance(),i=_.Form.useWatch(n,o),[s,a]=vt.useState(!1),[l,c]=vt.useState(""),u=Z7(t,e),d=Q7(i,u),f=()=>{c(d),a(!0)},p=()=>{c(""),a(!1)},m=()=>{if(n){const b=l.trim()||void 0;o.setFieldValue(n,b)}a(!1),c("")};return n?s?h.jsxs(_.Space,{children:[h.jsx(_.Input,{size:"small",value:l,onChange:b=>c(b.target.value),onPressEnter:m,style:{width:200},placeholder:"请输入标题"}),h.jsx(_.Button,{"aria-label":"保存标题",type:"text",size:"small",icon:h.jsx(ie.CheckOutlined,{style:{color:"#52c41a"}}),onClick:m}),h.jsx(_.Button,{"aria-label":"取消标题编辑",type:"text",size:"small",icon:h.jsx(ie.CloseOutlined,{}),onClick:p})]}):h.jsxs(_.Space,{children:[h.jsx("span",{children:d}),h.jsx(_.Button,{"aria-label":"编辑标题",type:"text",size:"small",icon:h.jsx(ie.EditOutlined,{}),disabled:r,onClick:f})]}):h.jsx("span",{children:d})};z_.displayName="ArrayObjectRowTitle";function K7(t,e,n,r,o){return{...t,name:e,__arrayObjectRootNamePath:n,__arrayObjectDepth:r,__arrayObjectLevelBackgroundColors:o}}function H_(t){return Array.isArray(t)?t:[t]}function Y7(t){return t.__arrayObjectRootNamePath??H_(t.name)}function V_(t,e){return qn(t,H_(e).join("."))}function X7(t,e,n){const r=J7(t);return r?[...e,n,r]:void 0}function J7(t){return t.titleFieldName?t.titleFieldName:t.titleEditable?"title":void 0}function Q7(t,e){return typeof t=="string"&&t.trim()?t:e}function Z7(t,e){return t.label?`${t.label} #${e+1}`:`Item ${e+1}`}function eW(t){return t.label?`添加${t.label}`:"添加行"}function tW(t){return t.columnLayout!=="grid"?{display:"flex",flexDirection:"column",width:"100%",gap:0}:{display:"grid",gridTemplateColumns:`repeat(${nW(t)}, minmax(0, 1fr))`,columnGap:16,rowGap:0,width:"100%",alignItems:"start"}}function nW(t){const e=t.columns.filter(r=>!rW(r)).length,n=typeof t.columnCount=="number"&&Number.isFinite(t.columnCount)?Math.floor(t.columnCount):3;return Math.max(1,Math.min(n,Math.max(e,1)))}function rW(t){return t.type===ge.HIDDEN}function oW(t,e,n){if(t.backgroundColor)return t.backgroundColor;if(n!=null&&n.length)return n[e%n.length]}function iW(t){if(t)return{backgroundColor:t}}function sW(t){if(t)return{backgroundColor:t}}function aW(t){var n;const e=[];if((n=t.rules)!=null&&n.some(r=>r.type==="required")){const r=t.rules.find(o=>o.type==="required");e.push({validator:async(o,i)=>{if(!i||i.length===0)throw new Error((r==null?void 0:r.message)||"此项为必填")}})}return t.minItems!==void 0&&e.push({validator:async(r,o)=>{if(!o||o.length<t.minItems)throw new Error(`至少需要 ${t.minItems} 项`)}}),t.maxItems!==void 0&&e.push({validator:async(r,o)=>{if(o&&o.length>t.maxItems)throw new Error(`最多允许 ${t.maxItems} 项`)}}),e}const lW=Mo($_,{isComplexField:!0,needsFormItemName:!1});/**
|
|
53
53
|
* @license lucide-react v0.562.0 - ISC
|
|
54
54
|
*
|
|
55
55
|
* This source code is licensed under the ISC license.
|
|
@@ -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(_.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(ie.RobotOutlined,{style:{fontSize:"11px"}}),"由AI生成"]})}),s()]})},Kq=t=>{var n;const e=Mn();return h.jsx(_.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(_.Select.Option,{label:r.label,value:r.value,children:r.label},r.value))})},Yq=t=>h.jsx(_.DatePicker,{style:{width:"100%"},picker:"date",value:t.value?Ht(t.value):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD")))}}),Xq=t=>h.jsx(y.Fragment,{children:h.jsx(_.DatePicker,{style:{width:"100%"},picker:"date",showTime:!0,value:t.value?Ht(t.value):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD hh:mm:ss")))}})}),Jq=({value:t=[],onChange:e,selectType:n="KNOWLEDGE_BASE",placeholder:r="请选择"})=>{const o=St.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??Mn()}))},[t]);const c=At(),u=p=>{const m=o.items.filter(b=>b.id!==p);e==null||e(m)},d=()=>{e([...o.items,{value:"",id:Mn()}])},f=(p,m)=>{e(o.items.map((b,v)=>v===p?{...b,value:m}:b))};return h.jsxs("div",{children:[o.items.length?o.items.map((p,m)=>h.jsxs(_.Space,{size:"small",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[h.jsx(_.Select,{value:p.value||void 0,onChange:b=>f(m,b),placeholder:r,style:{width:300},disabled:!c||a,loading:a,options:i,showSearch:!0,filterOption:(b,v)=>((v==null?void 0:v.label)??"").toLowerCase().includes(b.toLowerCase()),getPopupContainer:b=>b.parentNode}),c&&h.jsx(_.Button,{icon:h.jsx(xi,{size:16}),onClick:()=>{u(p.id)}})]},p.id)):null,c&&h.jsx(_.Button,{type:"default",onClick:d,block:!0,icon:h.jsx(br,{size:16}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})})]})},Qq=({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=St.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??Mn()}))},[t]);const s=()=>{e==null||e([...o.items,{key:"",value:"",id:Mn()}])},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=At();return h.jsxs("div",{className:"workflow-extend-object",children:[o.items.length?o.items.map((u,d)=>h.jsxs(_.Space,{size:"small",className:"workflow-extend-object__row",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[h.jsx(_.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(In,{borrow:!0,disableIDE:!0,placeholder:"Value",style:{width:300},value:u.value,onChange:f=>l(u.id,f),valueType:n,nodeId:""})}),c&&h.jsx(_.Button,{icon:h.jsx(xi,{size:16}),onClick:()=>{r(u.id)}})]},u.id)):null,h.jsxs(_.Button,{type:"default",onClick:s,block:!0,children:[h.jsx(br,{size:16})," ",h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})]})]})},Zq=t=>null,eG=t=>h.jsx(_.TimePicker,{style:{width:"100%"},use12Hours:!1,format:"HH:mm",value:t.value?Ht(t.value,"HH:mm"):null,onChange:e=>{const n=Ht(e).format("HH:mm:00");t.onChange&&(t==null||t.onChange(n))}}),{Text:tG}=_.Typography,RA=t=>h.jsx("div",{className:"ce-tag_input",children:h.jsx("p",{children:h.jsx(_.Tooltip,{title:t.value,color:"cyan",placement:"topLeft",children:h.jsx(tG,{ellipsis:!0,copyable:{text:t.value},children:t.value})})})}),nG=({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??Mn()})))},[t]);const i=At(),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:Mn()},p=[...r,f];o(p),e(p)},l=(f,p)=>{const m=r.map(b=>b.id===f?{...b,field:p}:b);o(m),e(m)},c=(f,p)=>{const m=r.map(b=>b.id===f?{...b,dataType:p}:b);o(m),e(m)},u=(f,p)=>{const m=r.map(b=>b.id===f?{...b,desc:p}:b);o(m),e(m)},d=(f,p)=>{const m=r.map(b=>b.id===f?{...b,required:p}:b);o(m),e(m)};return h.jsxs("div",{className:"workflow-multi-row-extract",children:[r.length?r.map(f=>h.jsxs(_.Space,{size:"small",className:"workflow-multi-row-extract__row",style:{display:"flex",marginBottom:8,width:"100%"},align:"start",children:[h.jsx(_.Input,{value:f.field,onChange:p=>l(f.id,p.target.value),placeholder:"字段名称",status:"",style:{width:130},disabled:!i}),h.jsx(_.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(_.Input,{value:f.desc,onChange:p=>u(f.id,p.target.value),placeholder:"字段描述",status:"",style:{width:200},disabled:!i}),h.jsx(_.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(_.Button,{icon:h.jsx(xi,{size:16}),onClick:()=>{s(f.id)}})]},f.id)):null,i&&h.jsx(_.Button,{type:"default",onClick:a,block:!0,icon:h.jsx(br,{size:16}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})})]})},rG=t=>{const e=y.useMemo(()=>Mn(),[]),{event$:n}=y.useContext(Qr),r=Ym(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(_.Space.Compact,{block:!0,className:`workflow-password-field${r?` ${rd}`:""}`,children:[h.jsx("span",{className:"workflow-password-field__prefix",children:G("link.flow.cipherText")}),h.jsx(_.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})]})},oG=t=>{var o;const e=Mn(),{multiple:n,...r}=t;return h.jsx(_.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(_.Select.Option,{label:i.label,value:i.value,children:i.label},i.value))})},iG=t=>h.jsx(_.TimePicker,{style:{width:"100%"},value:t.value?Ht(t.value,"HH:mm:ss"):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("HH:mm:ss")))}}),El=()=>Pt().flowId,sG=["sample","test","payload","body"],aG=["测试","样本","sample","test","payload","body"],KA=t=>{var n,r,o;return[Ee.JSON,Ee.TEXTAREA,Ee.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},YA=(t,e)=>{if(!t)return!1;const n=t.toLowerCase();return e.some(r=>n.includes(r))},lG=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}},cG=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(b=>KA(b)&&(YA(b.name,sG)||YA(b.display_name,aG)));return m||n.find(b=>KA(b))},[n]),f=y.useCallback(()=>{c.current&&(clearInterval(c.current),c.current=void 0)},[]);y.useEffect(()=>()=>{f()},[f]);const p=y.useCallback(async()=>{if(!u){_.message.warning("缺少连接流ID,无法监听Webhook");return}if(!(d!=null&&d.name)){_.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}),b=lG(m);b?(e.setFieldsValue({[d.name]:b}),_.message.success("已捕获Webhook推送数据并填充测试样例")):_.message.info("监听结束,暂无新的推送数据")}catch(m){console.error("监听Webhook失败:",m),_.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(RA,{...o})}),h.jsx(_.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)`:""}`:"监听"})]})},uG={configFormContainer:"_configFormContainer_1frpl_1"};function dG(t){return Nq(t==null?void 0:t.credentials)}const fG=t=>String(t.type).toUpperCase();function XA(t){var e,n;return(n=(e=t==null?void 0:t.input_fields)==null?void 0:e.find(r=>fG(r)==="PROXY"))==null?void 0:n.key}function JA(t){return t==null||t===""?"0":String(t)}function hG(t,e,n){const r=XA(e);return r?{...t,[r]:JA(n??t[r])}:t}function pG(t,e){const n=XA(e);if(!n)return{properties:t};const r={...t},o=JA(r[n]);return delete r[n],{properties:r,proxyId:o}}const QA=({field:t,disabled:e,readOnly:n,context:r,value:o="",onChange:i,id:s,allowVariableInsert:a,hasModeSwitch:l})=>{const c=cC(),u=y.useId(),d=s||`workflow-code-${u}`,f=y.useRef(null),[p,m]=y.useState(0),b=!e&&!n,v=y.useCallback(k=>{var E;if(!a)return;const x=(E=f.current)==null?void 0:E.view,D=x==null?void 0:x.state.selection.main;if(!x||!D){i==null||i(`${o}${k}`);return}x.dispatch({changes:{from:D.from,to:D.to,insert:k},selection:{anchor:D.from+k.length}}),x.focus()},[a,i,o]),w=rC(d,k=>v(k),()=>{var k,x;return(x=(k=f.current)==null?void 0:k.view)==null?void 0:x.focus()}),g=Nh(),C=(g==null?void 0:g.activeFieldId)===d,S=y.useCallback(()=>{if(b)try{i==null||i(JSON.stringify(JSON.parse(o),null,2))}catch{_.message.warning(G("link.flow.format_json_failed"))}},[b,i,o]);return h.jsx(gC,{id:d,canEditInEditor:b,openEditorNumber:p,nodeId:c.nodeId||r.nodeId||"",value:o,language:"json",showVariableSidebar:a,onFinish:i,children:h.jsxs("div",{style:{position:"relative"},className:C?rd:void 0,children:[h.jsx(td,{id:d,ref:f,value:o,readOnly:!b,height:"220px",placeholder:t.placeholder,theme:bm,extensions:[PA()],onFocus:()=>{b&&a&&w.activate()},onChange:i}),b?h.jsxs(_.Space,{size:4,style:{position:"absolute",right:l?148:8,top:6,zIndex:2},children:[h.jsx(_.Tooltip,{title:G("link.flow.format_json"),children:h.jsx(_.Button,{type:"text",size:"small","aria-label":G("link.flow.format_json"),icon:h.jsx(ie.FormatPainterOutlined,{}),onClick:S,style:{color:"#fff"}})}),h.jsx(_.Tooltip,{title:G("link.flow.open_code_editor"),children:h.jsx(_.Button,{type:"text",size:"small","aria-label":G("link.flow.open_code_editor"),icon:h.jsx(ie.FullscreenOutlined,{}),onClick:()=>m(k=>k+1),style:{color:"#fff"}})})]}):null]})})};QA.displayName="WorkflowCodeEditor";const ZA=({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(QA,{...d,field:t,context:r,id:s,allowVariableInsert:c,hasModeSwitch:l});return t.valueModePolicy?h.jsx(Ci,{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})};ZA.displayName="WorkflowCodeFieldControl";const mG=ft(ZA,{needsFormItemName:!0,supportsVariableInsert:!0}),eO=({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),qf().then(f=>{d||s(Array.isArray(f)?f:[])}).catch(()=>{d||_.message.error(G("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(_.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%"}})};eO.displayName="WorkflowProxyFieldControl";const gG=ft(eO,{needsFormItemName:!0,supportsVariableInsert:!0}),wG=[{type:ge.CODE,definition:mG},{type:ge.PROXY,definition:gG}];function bG({children:t}){return h.jsx(dC,{additionalRegistrations:wG,children:t})}function xl(){const{event$:t}=y.useContext(Qr),e=Th();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 vG=[Ee.TEXT,Ee.PASSWORD,Ee.SELECT,Ee.EXTEND_OBJ,Ee.DATE,Ee.TIME,Ee.DATETIME,Ee.TEXTAREA,Ee.FIXED_OBJ,Ee.JSON],yG="[workflow:schema-render]",CG=/^\{\{([^.{}]+)\.(.+)\}\}$/,kG=t=>{switch(t.page_control){case Ee.SELECT:case Ee.API_SELECT:return t.multi_valued?[]:null;case Ee.EXTEND_OBJ:return{};case Ee.HIDDEN:return"";case Ee.TEXT:return"";case Ee.PASSWORD:return"";case Ee.LABEL:return"";case Ee.DATE:return null;case Ee.TIME:return null;case Ee.DATETIME:return null;case Ee.TEXTAREA:return"";case Ee.FIXED_OBJ:return{};case Ee.MultiRowAIExtractConfig:return[];case Ee.JSON:return""}},tO=(t,e,n,r,o)=>{const i=t.display_name,s=()=>{var a,l,c;switch(t.page_control){case Ee.SELECT:return h.jsx(oG,{options:Xg(t.option_value_objects??t.option_values),multiple:t.multi_valued});case Ee.API_SELECT:return h.jsx(Kq,{options:Xg(t.option_value_objects??t.option_values)});case Ee.EXTEND_OBJ:return h.jsx(Qq,{valueType:t.value_type});case Ee.HIDDEN:return h.jsx(Zq,{});case Ee.TEXT:return h.jsx(In,{valueType:t.value_type,nodeId:e});case Ee.PASSWORD:return h.jsx(rG,{valueType:t.value_type});case Ee.LABEL:return(a=r==null?void 0:r.webhookField)!=null&&a.enabled&&t.name==="hookUrl"&&r.webhookField.form?h.jsx(cG,{form:r.webhookField.form,configList:r.webhookField.configList,disabled:r.webhookField.disabled}):h.jsx(RA,{});case Ee.DATE:return h.jsx(Yq,{});case Ee.TIME:return h.jsx(iG,{});case Ee.DATETIME:return h.jsx(Xq,{});case Ee.TEXTAREA:return h.jsx(In,{valueType:t.value_type,textAreaMode:!0,nodeId:e});case Ee.FIXED_OBJ:return h.jsx(_.Input.TextArea,{});case Ee.JSON:return h.jsx(In,{valueType:t.value_type,nodeId:e});case Ee.MultiRowAIExtractConfig:return h.jsx(nG,{valueType:t.value_type});case Ee.MULTI_SELECT_LIST:return h.jsx(Jq,{selectType:"KNOWLEDGE_BASE"});case Ee.SYNC_HOUR_MINUTE:return h.jsx(eG,{});case Ee.AUTH_TOKEN:return h.jsx(Vq,{disabled:(l=r==null?void 0:r.webhookField)==null?void 0:l.disabled});case Ee.SECRET_KEY:return h.jsx(Wq,{});case Ee.SELECT_CLIENT:return h.jsx(Gq,{});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&&vG.includes(t.page_control)?h.jsx("div",{children:h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:t.page_control===Ee.SELECT?G("link.flow.please_select")+t.display_name:G("link.flow.please_enter")+t.display_name}],label:i,name:t.name,children:h.jsx(Rq,{children:s()})})},t.ui_id):h.jsx(_.Form.Item,{required:t.required,style:t.page_control===Ee.HIDDEN?{display:"none"}:{},rules:[{required:t.required,message:t.page_control===Ee.SELECT?G("link.flow.please_select")+t.display_name:G("link.flow.please_enter")+t.display_name},{validator(a,l,c){if(t.page_control===Ee.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)},SG=t=>(t.child_conditions??[]).map(e=>e.left).filter(e=>!!e),EG=(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},xG=y.forwardRef((t,e)=>{var we,fe;const{action:n,connector:r,nodeId:o,account_id:i,mcpMode:s,nodeType:a}=t,l=Pt(),c=ne.useStoreApi(),u=xl(),d=St.useReactive({proxyId:"0"}),{config_schema:f,proxy_id:p,protocol:m,account_schema_id:b}=n;a??n.node_type??n.type;const v=n.action_key||n.nodeKey,w=n.action_ver??n.nodeVersion,g=Array.isArray(f==null?void 0:f.sub_params),C=po(n),S=y.useMemo(()=>!C||!v?null:`${v}@${w??"latest"}`,[C,v,w]),k=S?`${o}:${S}`:o,x=n.account_id??i,D=y.useMemo(()=>S?Wi(v,w):null,[S,v,w]),[E,O]=y.useState(()=>S&&D?{identity:S,schema:D,loading:!1,finished:!0}:null),A=(E==null?void 0:E.identity)===S?E:null,T=(A==null?void 0:A.schema)??null,B=ew((T==null?void 0:T.credentials)??[]),M=!!(C&&v&&!T&&((A==null?void 0:A.loading)??!(A!=null&&A.finished))),F=dG(T);y.useEffect(()=>{!E||E.identity},[S,E,o,v,w]),y.useEffect(()=>{p&&(d.proxyId=p)},[p,d]);const[N]=_.Form.useForm(),[P,I]=y.useState(x);y.useEffect(()=>{I(x)},[k,x,I]);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===Ee.EXTEND_OBJ&&(Fe=yq(Fe)),Se[ce.name]=Fe??kG(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),J=y.useRef(null);y.useEffect(()=>{if(!S||!v){O(null);return}const le=Wi(v,w);if(le){O({identity:S,schema:le,loading:!1,finished:!0});return}let Se=!1;return O({identity:S,schema:null,loading:!0,finished:!1}),hc(v,w).then(ce=>{Se||O({identity:S,schema:ce,loading:!1,finished:!0})}).catch(ce=>{Se||(O({identity:S,schema:null,loading:!1,finished:!0}),console.error(`${yG} classic renderer next schema load failed`,{nodeId:o,nodeKey:v,nodeVersion:w,err:ce}))}),()=>{Se=!0}},[S,o,v,w]);const K=y.useMemo(()=>{var le;return(le=T==null?void 0:T.input_fields)!=null&&le.length?VI(VA(T.input_fields),T.key):null},[T]),ee=!!(C&&(K||F||T)),$=y.useMemo(()=>{const le=n.properties?ha(n.properties):f&&C?ha(f):n.params?ha(n.params):{},Se=hG(le,T,p);return cc(v)?ra(Se).properties:Se},[n,f,C,T,v,p]),U=y.useMemo(()=>JSON.stringify($??{}),[$]);y.useEffect(()=>{!C||!ee||(N.resetFields(),N.setFieldsValue($))},[k,N,C,$,U,ee]);const R=y.useRef(null);y.useEffect(()=>{R.current=null},[k]),y.useEffect(()=>{cc(v)&&(R.current=JSON.stringify(ra($).branches.map(le=>[le.id,le.name])))},[$,v]);const te=y.useCallback(le=>{const Se=le.trim().match(CG);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]),se=y.useCallback(le=>{var Se;return((Se=te(le))==null?void 0:Se.fieldPath)??le.replace(/^\{\{|\}\}$/g,"")},[te]),be=y.useCallback(le=>{var je;const Se=te(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}`},[te]),[j,Y]=y.useState(!1),W=(le,Se)=>(Y(!0),N.validateFields().then(async ce=>{var Ve,je,We,Ce,Oe;if(ee){Se&&((je=(Ve=H==null?void 0:H.current)==null?void 0:Ve.onIgnoreNodeStart)==null||je.call(Ve));const{properties:Pe,proxyId:qe}=pG(ce,T);return t.onSubmit({properties:Pe,account_id:P,proxy_id:qe},le)}const Fe=Mt.cloneDeep(n.config_schema);return Fe.sub_params.forEach(Pe=>{let qe=ce[Pe.name];Pe.page_control===Ee.EXTEND_OBJ&&qe!=="{{$fromAI}}"&&(qe=Jg(qe)),Pe.value=qe??null}),Se&&((Ce=(We=H==null?void 0:H.current)==null?void 0:We.onIgnoreNodeStart)==null||Ce.call(We)),!i&&m==="HTTP"&&(r==null?void 0:r.deployment_type)!=="SaasApp"&&(Fe.proxy_id=(Oe=J.current)==null?void 0:Oe.getProxyId()),t.onSubmit(Fe,le)}).catch(ce=>(console.log("err",ce),_.message.warning(G("link.flow.missing_configuration")),!1)).finally(()=>Y(!1)));y.useImperativeHandle(e,()=>({saveConfig:le=>W(le,!1)}));const X=At(),re={form:N,configList:(f==null?void 0:f.sub_params)??[],disabled:!X,...m==="WEBHOOK"?{webhookField:{enabled:!0,form:N,configList:(f==null?void 0:f.sub_params)??[],disabled:!X}}:{}},Z=le=>{const Se=le.page_control!==Ee.HIDDEN?h.jsx("p",{className:"field-desc",children:le.description}):null;if(!le.is_child)return h.jsxs("div",{children:[tO(le,o,s,re,l.canvas.registerComponents),Se]},le.ui_id);const ce=SG(le);return h.jsx(_.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 EG(le,Fe)?h.jsxs("div",{children:[tO(le,o,s,re,l.canvas.registerComponents),Se]}):null}},le.ui_id)};if(C&&M)return h.jsx("div",{style:{textAlign:"center",padding:40},children:h.jsx(_.Spin,{})});const de=!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(ee){const le=h.jsxs(h.Fragment,{children:[t.preRender&&t.preRender,F?h.jsx(qA,{credentialRequirements:B,value:P,onChange:I,linkApp:r,disabled:!X}):null]});return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:u,children:[h.jsx("div",{className:"workflow-node-form-scroll",children:K?h.jsx(bG,{children:h.jsx(Rg,{schema:K,form:N,initialValues:$,showSubmit:!1,showReset:!1,nodeId:o,mcpMode:s,renderVariableTag:se,renderVariableTooltip:be,customTheme:sc,preRender:le},k)}):ve}),h.jsx("div",{className:"workflow-node-form-footer",children:X&&h.jsx(_.Button,{type:"primary",disabled:!X,loading:j,className:"workflow-node-form-save",onClick:()=>W(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:u,children:[h.jsxs(_.Form,{form:N,disabled:!X,layout:"vertical",className:`${uG.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(Kg,{proxyId:d.proxyId,ref:J}):null,de&&ve]}),h.jsx("div",{className:"workflow-node-form-footer",children:X&&h.jsx(_.Button,{type:"primary",disabled:!X,loading:j,className:"workflow-node-form-save",onClick:()=>W(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),DG=y.memo(y.forwardRef((t,e)=>{const{nodeId:n,data:r}=t,{account_id:o,account_schema_id:i}=r,s=St.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 b=ha(p),w=Object.hasOwn(p??{},"account_id")?p.account_id??null:s.account_id;return t.onSubmit({properties:b,account_id:w,proxy_id:(p==null?void 0:p.proxy_id)??(b==null?void 0:b.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(qA,{onChange:d,actionAccountSchemaId:i,value:s.account_id,linkApp:l})),h.jsx("div",{className:"workflow-action-node-config",children:h.jsx(xG,{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&&Mt.isEqual(Mt.omit(t.data,["isHovered"]),Mt.omit(e.data,["isHovered"])));var Ln=(t=>(t.IDLE="idle",t.SAVING="saving",t.SAVED="saved",t.ERROR="error",t))(Ln||{}),jd=(t=>(t.SELECTION="selection",t.ALL="all",t))(jd||{}),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||{}),rt=(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))(rt||{});const nO=[{operator:rt.eq,label:G("common.eq")},{operator:rt.ne,label:G("common.ne")},{operator:rt.sw,label:G("common.sw")},{operator:rt.nsw,label:G("common.nsw")},{operator:rt.ew,label:G("common.ew")},{operator:rt.ewn,label:G("common.ewn")},{operator:rt.gt,label:G("common.gt")},{operator:rt.ge,label:G("common.ge")},{operator:rt.lt,label:G("common.lt")},{operator:rt.le,label:G("common.le")},{operator:rt.co,label:G("common.co")},{operator:rt.nco,label:G("common.nco")},{operator:rt.in,label:G("common.in")},{operator:rt.nin,label:G("common.nin")},{operator:rt.is_null,label:G("common.is_null")},{operator:rt.is_not_null,label:G("common.is_not_null")}];rt.eq+"",G("common.eq"),rt.ne+"",G("common.ne"),rt.sw+"",G("common.sw"),rt.nsw+"",G("common.nsw"),rt.ew+"",G("common.ew"),rt.ewn+"",G("common.ewn"),rt.gt+"",G("common.gt"),rt.lt+"",G("common.lt"),rt.ge+"",G("common.ge"),rt.co+"",G("common.co"),rt.nco+"",G("common.nco"),rt.le+"",G("common.le"),rt.in+"",G("common.in"),rt.nin+"",G("common.nin"),rt.is_null+"",G("common.is_null"),rt.is_not_null+"",G("common.is_not_null");const nw=t=>t===rt.is_null||t===rt.is_not_null,_G=(t,e="")=>nw(t)?"":e,{Option:AG}=_.Select,OG=y.forwardRef((t,e)=>{const{config_schema:n}=t,[r]=_.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(()=>(_.message.warning(G("link.flow.missing_configuration")),!1)).finally(()=>l(!1)));y.useImperativeHandle(e,()=>({saveConfig:d=>c(d)}));const u=At();return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:o,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsx(_.Form,{disabled:!u,form:r,initialValues:s,layout:"vertical",autoComplete:"off",children:h.jsx(_.Form.List,{name:"or_list",children:(d,{add:f,remove:p})=>h.jsxs(h.Fragment,{children:[d.map((m,b)=>h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"form-block",children:h.jsxs("div",{style:{padding:12,width:"100%",boxSizing:"border-box"},children:[b>0&&u&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsx(_.Button,{type:"link",style:{color:"red"},icon:h.jsx(ie.MinusCircleOutlined,{style:{color:"red"}}),onClick:()=>p(m.name),children:h.jsx(Te.FormattedMessage,{id:"link.flow.remove"})})}),h.jsx(_.Form.List,{name:[m.name,"and_list"],children:(v,{add:w,remove:g})=>h.jsx(h.Fragment,{children:v.map((C,S)=>h.jsxs(_.Space,{direction:"vertical",style:{width:"100%",rowGap:0},children:[h.jsxs(_.Space,{align:"center",className:`form-item-row ${S>0?"opt":""}`,children:[h.jsx(_.Form.Item,{style:{minWidth:150},name:[C.name,"query"],label:G("app.common.word.variable-name"),rules:[{required:!0,message:G("link.flow.please_enter_variable_name")}],children:h.jsx(In,{nodeId:t.nodeId,placeholder:G("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),h.jsx(_.Form.Item,{name:[C.name,"operator"],label:G("app.common.word.condition"),rules:[{required:!0,message:G("link.flow.please_select_condition")}],children:h.jsx(_.Select,{style:{minWidth:140},placeholder:G("link.flow.select_condition"),getPopupContainer:k=>k.parentNode,children:nO.map(k=>h.jsx(AG,{value:k.operator,children:k.label},k.operator))})}),h.jsx(_.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const k=r.getFieldValue(["or_list",m.name,"and_list",C.name,"operator"]);return nw(k)?null:h.jsx(_.Form.Item,{style:{minWidth:150},name:[C.name,"value"],label:G("app.common.word.value"),rules:[],children:h.jsx(In,{nodeId:t.nodeId,placeholder:G("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),S>0&&h.jsx(_.Button,{type:"link",icon:h.jsx(ie.MinusCircleOutlined,{}),onClick:()=>g(C.name)})]}),S<v.length-1&&h.jsx(_.Divider,{plain:!0,children:h.jsx(_.Tag,{color:"#999999",children:h.jsx(Te.FormattedMessage,{id:"link.flow.and"})})}),S===v.length-1&&h.jsx(_.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),b<d.length-1&&h.jsxs("div",{className:"test",style:{textAlign:"center"},children:[" ",h.jsx(_.Divider,{style:{color:"orange"},dashed:!0,children:h.jsx(_.Tag,{color:"#1890ff",children:h.jsx(Te.FormattedMessage,{id:"link.flow.or"})})})]})]})),h.jsx(_.Form.Item,{style:{display:"flex",justifyContent:"flex-end",marginBlock:10},children:h.jsx(_.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(_.Button,{type:"primary",disabled:!u,loading:a,className:"workflow-node-form-save",onClick:()=>c(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),TG={copy:"Copy JSON",copySuccess:"JSON copied to clipboard",download:"Download JSON",invalidJson:"Invalid JSON data"},NG={copy:"复制JSON",copySuccess:"JSON已复制到剪贴板",download:"下载JSON",invalidJson:"无效的JSON数据"},{Text:BG}=_.Typography,FG=({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"?NG:TG,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=[],S=0)=>{const k=[];if(g===null)return[{key:C.join("."),value:null,type:"null",path:C,level:S}];if(Array.isArray(g)){const x={key:C.join("."),value:g,type:"array",path:C,level:S,children:[]};g.forEach((D,E)=>{var T;const O=[...C,E.toString()],A=w(D,O,S+1);(T=x.children)==null||T.push(...A)}),k.push(x)}else if(typeof g=="object"){const x={key:C.join("."),value:g,type:"object",path:C,level:S,children:[]};Object.entries(g).forEach(([D,E])=>{var T;const O=[...C,D],A=w(E,O,S+1);(T=x.children)==null||T.push(...A)}),k.push(x)}else{const x=typeof g;k.push({key:C.join("."),value:g,type:x,path:C,level:S})}return k};return w(d)},[d]),p=y.useCallback(()=>{const w=JSON.stringify(d,null,2);navigator.clipboard.writeText(w).then(()=>{_.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),S=document.createElement("a");S.href=C,S.download="data.json",S.click(),URL.revokeObjectURL(C)},[d]),b=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}},[]),v=y.useCallback((w,g)=>{var k;const C=w.children&&w.children.length>0,S=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:[S&&h.jsxs("span",{className:"json-key",children:['"',S,'": ']}),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:[(k=w.children)==null?void 0:k.map((x,D)=>v(x,g+D+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:[S&&h.jsxs("span",{className:"json-key",children:['"',S,'": ']}),b(w)]})},w.key)},[b]);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(_.Space,{children:[n&&h.jsx(_.Tooltip,{title:u.copy,children:h.jsx(_.Button,{icon:h.jsx(ie.CopyOutlined,{}),size:"small",onClick:p})}),h.jsx(_.Tooltip,{title:u.download,children:h.jsx(_.Button,{icon:h.jsx(ie.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)=>v(w,g))})]}):h.jsx("div",{className:`json-renderer error ${a} ${o}`,children:h.jsx("div",{className:"error-message",children:h.jsx(BG,{type:"secondary",children:u.invalidJson})})})},{TextArea:MG}=_.Input,{Title:IG}=_.Typography,rO=({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:b,onClose:v,onExpandPanel:w})=>{const g=t==="running",C=t==="failure",S=t==="ignored",k=t==="success"||S,x=t==="disabled",[D,E]=y.useState(!1);return h.jsxs("section",{className:["node-test-container","ai-flow-node-test-panel",b].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(IG,{level:4,children:"节点测试"}),h.jsx(_.Button,{ghost:!0,className:"close-btn",onClick:v,children:h.jsx(xi,{size:16})})]})}),h.jsxs("div",{className:"test-content",children:[i&&!x?h.jsxs("div",{className:"action-buttons",children:[h.jsx(_.Button,{type:"primary",disabled:x,onClick:u,loading:g&&r==="run",className:"test-button",children:g?"测试中...":"开始测试"}),h.jsx(_.Button,{type:"default",disabled:x||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(_.Button,{onClick:f,className:"reset-button",children:"重置"})}):null,g?h.jsxs(h.Fragment,{children:[h.jsx(_.Progress,{percent:n,status:"active",className:"test-progress"}),h.jsx(_.Skeleton,{active:!0,className:"result-skeleton"})]}):h.jsxs(h.Fragment,{children:[C&&o?h.jsx(_.Alert,{className:"error-alert small",showIcon:!0,message:"测试未通过",description:"请检查节点配置和接口返回后重试",type:"error",closable:!1,onClose:m}):null,k&&o?h.jsx(_.Alert,{className:"success-alert small",showIcon:!0,message:S?"忽略调试成功":"测试成功",description:S?"已将样本数据设为当前节点输出":"节点运行正常,可在下方查看返回结果",type:"success",closable:!1,onClose:m}):null,e?h.jsx(_.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(ie.CloseCircleFilled,{className:"error-icon"})," 错误数据"]}):h.jsxs(h.Fragment,{children:[S?h.jsx(ie.ExperimentFilled,{className:"success-icon"}):h.jsx(ie.CheckCircleFilled,{className:"success-icon"}),S?"样本数据":"测试结果"]})}),h.jsxs("div",{style:{display:"inline-flex",gap:8},children:[i&&p?h.jsx(_.Button,{size:"small",type:"default",variant:"solid",onClick:p,className:"edit-button",children:a?"完成":"编辑"}):null,w&&h.jsx(_.Button,{size:"small",type:D?"primary":"default",variant:"solid",className:"edit-button",onClick:()=>{const O=!D;w(O),E(O)},children:D?h.jsx(gW,{size:16}):h.jsx(mW,{size:16})})]})]}),variant:"borderless",className:`result-card ${C?"error-result":"success-result"}`,children:a?h.jsx(MG,{rows:D?20:10,value:l,onChange:O=>c==null?void 0:c(O.target.value),className:"result-editor"}):h.jsx(FG,{data:e,height:D?600:300,enableCopy:!0,theme:"dark"},e)}):h.jsx(_.Card,{variant:"borderless",className:"empty-result",children:h.jsx(_.Result,{icon:h.jsx("span",{className:"common-icon"}),title:x?"不可测试":"等待测试",subTitle:x?s:"点击“开始测试”按钮运行当前节点"})})]})]})]})},PG=new Set([$e.AI_LANGUAGE_MODEL,$e.AI_MEMORY,$e.BUILTIN_MCP,$e.MCP_SERVER]),LG=new Set([]),$G=({canEdit:t,nodeType:e,protocol:n})=>t?n&&PG.has(n)?{disabled:!0,reason:"当前协议节点由所属 AI 或 MCP 运行上下文统一测试"}:e&&LG.has(e)?{disabled:!0,reason:"当前节点类型不支持独立手动测试"}:{disabled:!1}:{disabled:!0,reason:"只读或预览模式下不能执行节点测试"},zG=t=>typeof t=="string"?t.trim().length>0:t!=null,HG=t=>typeof t=="string"&&t.trim().toLowerCase()==="success",VG=t=>{if(!t||typeof t!="object")return!1;const e=t;return e.result===!0?!1:e.result===!1?!0:e.error==="0"&&zG(e.error_description)&&!HG(e.error_description)},jG=t=>VG(t)?me.FAILED:me.SUCCESS,WG=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 UG=y.forwardRef((t,e)=>{var O,A,T,B;const{nodeId:n,beforeHook:r,onClose:o,onExpandPanel:i}=t,s=Pt(),{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=St.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 M=typeof d.data.output=="string"?d.data.output:JSON.stringify(d.data.output,null,2);u(M),f.successShown=!0,f.isError=!1,f.showErrorAlert=!1}else if(d!=null&&d.data.output&&d.data.status===me.FAILED){const M=typeof d.data.output=="string"?d.data.output:JSON.stringify(d.data.output,null,2);u(M),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(M=>{const F=M,N=jG(F),P=N===me.FAILED;f.isError=P,f.successShown=!P,f.showErrorAlert=f.isError;let I="";try{I=WG(F)}catch(z){console.error("格式化测试结果出错:",z),I=`测试结果格式化失败: ${String(z)}`}f.testProgress=100,u(I),a({id:n,data:{status:N,output:I,outputSource:"test"}})}).catch(M=>{var P;console.error("测试失败:",M),f.testProgress=0,f.isError=!0,f.showErrorAlert=!0,f.successShown=!1;let F="测试执行失败";(P=M==null?void 0:M.response)!=null&&P.data?F=JSON.stringify(M.response.data,null,2):M!=null&&M.message&&(F=M.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]),b=()=>{f.testProgress=0,f.testing=!1,f.sampleSaving=!1,f.sampleMode=!1,f.successShown=!0,f.isError=!1,f.showErrorAlert=!1},v=()=>{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:b,abortSampleTest:w,finishNodeTest:g}));const C=()=>{f.sampleMode=!1,r?r(!0):m()},S=()=>{u(""),f.sampleText="",f.sampleMode=!1,f.sampleError="",f.successShown=!1},k=At(),x=y.useMemo(()=>{var M;return $G({canEdit:k,nodeType:d==null?void 0:d.type,protocol:(M=d==null?void 0:d.data)==null?void 0:M.protocol})},[k,(B=d==null?void 0:d.data)==null?void 0:B.protocol,d==null?void 0:d.type]),D=x.disabled?"disabled":f.testing?"running":f.isError?"failure":f.successShown?f.isIgnoreSuccess?"ignored":"success":"waiting",E=()=>{if(f.editable){f.editable=!1;try{const M=JSON.parse(f.sampleText),F=JSON.stringify(M,null,2);u(F),a({id:n,data:{output:F}})}catch{u(f.sampleText)}return}f.sampleText=c,f.editable=!0};return h.jsx(rO,{status:D,result:c,progress:f.testProgress||60,runningAction:f.ignoring?"ignore":"run",showAlert:f.isError?f.showErrorAlert:f.successShown,canEdit:k,disabledReason:x.reason,editing:f.editable,editableValue:f.sampleText,onEditableValueChange:M=>{f.sampleText=M},onRun:C,onIgnore:v,onReset:S,onToggleEdit:E,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 rw={ARRAY:"purple",BOOLEAN:"green",NULL:"default",NUMBER:"blue",OBJECT:"cyan",STRING:"orange"},qG={ARRAY:"Arr",BOOLEAN:"Bool",NULL:"Null",NUMBER:"Num",OBJECT:"Obj",STRING:"Str"},ow=(t,e=!1)=>{const n=String(t||"STRING").toUpperCase(),r=qG[n]||n.slice(0,4);return e?`${r}[]`:r},oO=t=>{t!=null&&t.length&&t.forEach(e=>{e.label||(e.label=e.name),Array.isArray(e.sub_params)?oO(e.sub_params):e.sub_params=[]})},GG=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=Mt.cloneDeep(e);return oO(n),n};var iO=(t=>(t.TEXT="TEXT",t.NUMBER="NUMBER",t.JSON="JSON",t))(iO||{});const RG=t=>({TEXT:"STRING",NUMBER:"NUMBER",JSON:"OBJECT"})[t]||"STRING",KG=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,b]=y.useState(0),[v,w]=y.useState(!1),[g,C]=y.useState(null),[S,k]=y.useState(0),x=y.useCallback(()=>{b(T=>T+1)},[]),D=y.useCallback(()=>{k(T=>T+1)},[]),E=y.useCallback(()=>{b(T=>T+1),k(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 M=await Py();if(T)return;const F=((M==null?void 0:M.items)||[]).map(N=>({...N,mappedType:RG(N.var_type)}));a(N=>Mt.isEqual(N,F)?N:F)}catch(M){console.error("Failed to fetch global variables:",M),T||p(M instanceof Error?M: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:M,nodes:F}=i.getState(),N=await Iy(n,{nodeId:e,edges:M});if(T)return;const P=new Map(F.map(H=>[H.id,H])),z=(GG(N)||[]).map(H=>{var $,U;const J=($=H.node_id)!=null&&$.startsWith("N")?H.node_id.slice(1):H.node_id,K=J?P.get(J):void 0,ee=typeof((U=K==null?void 0:K.data)==null?void 0:U.icon)=="string"?K.data.icon:void 0;return{...H,nodeIcon:ee,isValid:!!K}});c(H=>Mt.isEqual(H,z)?H:z)}catch(M){console.error("Failed to fetch node variables:",M),T||C(M instanceof Error?M:new Error("无法获取节点变量数据"))}finally{T||w(!1)}})(),()=>{T=!0}},[n,e,r,S,i]),{globalVariables:s,nodeVariables:l,isLoading:u||v,isGlobalLoading:u,isNodeLoading:v,error:f||g,globalError:f,nodeError:g,refresh:E,refreshGlobal:x,refreshNode:D}},st={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"},iw={VariableModalTitle:h.jsx(Te.FormattedMessage,{id:"app.common.word.select-variable"}),NoTestDataDesc:h.jsx(Te.FormattedMessage,{id:"common.no-process-variables-yet"})},YG=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)},XG=(t,e)=>{const n=t.trim(),r=n.startsWith("N")?n:`N${n}`,o=e.slice(1).join(".");return o?`{{${r}.${o}}}`:`{{${r}}}`},sO=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}=KG({nodeId:r,flowId:n,enabled:t.open,includeGlobalVariables:o}),m=St.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 b=w=>{try{const g=typeof w=="string"?JSON.parse(w):w,C=(k,x)=>{if(k==null)return{name:x,type:tr.Null,label:x,multi_valued:!1,sub_params:[],value:String(k)};if(typeof k=="object"&&!Array.isArray(k)){const E=k;return{name:x,type:tr.Object,label:x,multi_valued:!1,sub_params:Object.keys(E).map(O=>C(E[O],O)),value:null}}if(Array.isArray(k)){const E=k[0],O=E&&typeof E=="object"?tr.Object:typeof E=="number"?tr.Number:typeof E=="boolean"?tr.Boolean:E==null?tr.Array:tr.String;return{name:x,type:O,label:x,multi_valued:!0,sub_params:[],value:JSON.stringify(k)}}const D=typeof k=="number"?tr.Number:typeof k=="boolean"?tr.Boolean:tr.String;return{name:x,type:D,label:x,multi_valued:!1,sub_params:[],value:String(k)}},S=g&&typeof g=="object"&&!Array.isArray(g)?g:{};return Object.keys(S).map(k=>C(S[k],k))}catch{return[]}},v=(w,g,C,S,k,x=[],D="0")=>(w??[]).map((E,O)=>{var M;const A=[...x,E.name],T=`${D}-${O}`;return(M=E.sub_params)!=null&&M.length?{key:T,variablePath:A,title:h.jsxs("span",{className:`${st.nodeTitle}${S===!1?` ${st.invalidVariable}`:""}`,children:[g?k==="api"?h.jsx(ie.ApiOutlined,{className:st.nodeIcon}):h.jsx("span",{className:st.nodeIconWrapper,children:C?h.jsx("img",{src:C,alt:""}):h.jsx("span",{className:st.defaultNodeIcon,children:"N"})}):h.jsx(_.Tag,{color:rw[E.type]||"gray",className:`${st.typeTag} workflow-variable-panel__type`,children:ow(E.type,E.multi_valued)}),h.jsx("span",{className:`${g?st.nodeLabelFirst:st.nodeLabel} workflow-variable-panel__label`,children:E.label})]}),children:v(E.sub_params,!1,C,S,k,A,T)}:{key:T,variablePath:A,title:h.jsxs("span",{className:`${st.leafTitle}${S===!1?` ${st.invalidVariable}`:""}`,children:[h.jsx(_.Tag,{color:rw[E.type]||"gray",className:`${st.typeTag} workflow-variable-panel__type`,children:ow(E.type,E.multi_valued)}),h.jsx("span",{className:`${st.leafLabel} workflow-variable-panel__label`,children:E.label}),E.value?h.jsx("span",{className:st.leafValue,children:E.value}):null]})}});return h.jsxs("div",{className:`${st.container} workflow-variable-panel`,children:[h.jsxs("div",{className:`${st.header} workflow-variable-panel__header`,children:[h.jsx(pW,{size:16,className:`${st.headerIcon} workflow-variable-panel__header-icon`}),h.jsx("span",{className:`${st.headerTitle} workflow-variable-panel__title`,children:iw.VariableModalTitle})]}),h.jsxs("div",{className:`${st.body} workflow-variable-panel__body`,children:[o?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:`${st.sectionLabel} workflow-variable-panel__section-label`,children:[h.jsx(ie.GlobalOutlined,{className:st.sectionIcon,size:32}),h.jsx("span",{children:"全局变量"})]}),h.jsx("div",{className:"variable-panel-group",children:h.jsxs("div",{className:st.section,children:[s.map(w=>{if(w.var_type===iO.JSON){const S=b(w.var_value??{}),k=[{name:w.name,type:tr.Object,label:w.display_name||w.name,multi_valued:!1,sub_params:S,value:null}],x=v(k,!0,void 0,!0,"api");return h.jsx(_.Tree,{defaultExpandAll:!0,showLine:!0,onSelect:(D,E)=>{const O=E.node.variablePath;i.emit({type:"insert",currentInputId:m.currentInputId,expression:`{{global.${O.join(".")}}}`})},switcherIcon:h.jsx(ie.CaretDownOutlined,{}),treeData:x},w.id)}const g=YG(w.var_value),C=g.length>28?`${g.substring(0,28)}...`:g;return h.jsxs("button",{type:"button",className:`${st.varItem} workflow-variable-panel__item`,onClick:()=>{i.emit({type:"insert",currentInputId:m.currentInputId,expression:`{{global.${w.name}}}`})},children:[h.jsx(_.Tag,{color:rw[w.mappedType],className:`${st.typeTag} workflow-variable-panel__type`,children:ow(w.mappedType)}),h.jsx("span",{className:`${st.varName} workflow-variable-panel__label`,children:w.display_name||w.name}),C?h.jsx("span",{className:st.varValue,children:C}):null]},w.id)}),!l&&!u&&s.length<1&&h.jsx(_.Empty,{image:_.Empty.PRESENTED_IMAGE_SIMPLE,description:iw.NoTestDataDesc,className:st.empty}),l?h.jsxs("div",{className:st.loadingState,children:[h.jsx(_.Spin,{size:"small"}),h.jsx("span",{children:"正在加载全局变量"})]}):u?h.jsx(_.Alert,{className:st.errorState,type:"error",showIcon:!0,message:"全局变量加载失败",description:u.message,action:h.jsx(_.Button,{size:"small",onClick:f,children:"重试"})}):null]})})]}):null,h.jsxs("div",{className:`${st.sectionLabel} workflow-variable-panel__section-label`,children:[h.jsx(ie.ApiOutlined,{className:st.sectionIcon}),h.jsx("span",{children:"节点变量"})]}),h.jsx("div",{className:"variable-panel-group",children:h.jsxs("div",{className:st.section,children:[a.map(w=>h.jsx("div",{children:h.jsx(_.Tree,{defaultExpandAll:!0,showLine:!0,onSelect:(g,C)=>{const S=C.node.variablePath;if(S.length<=1)return!1;i.emit({type:"insert",currentInputId:m.currentInputId,expression:XG(w.node_id,S)})},switcherIcon:h.jsx(ie.CaretDownOutlined,{}),treeData:v(w.sub_params,!0,w.nodeIcon,w.isValid,"node")})},`${w.node_id}-${w.seq}`)),!c&&!d&&a.length<1&&h.jsx(_.Empty,{image:_.Empty.PRESENTED_IMAGE_SIMPLE,description:iw.NoTestDataDesc,className:st.empty}),c?h.jsxs("div",{className:st.loadingState,children:[h.jsx(_.Spin,{size:"small"}),h.jsx("span",{children:"正在加载节点变量"})]}):d?h.jsx(_.Alert,{className:st.errorState,type:"error",showIcon:!0,message:"节点变量加载失败",description:d.message,action:h.jsx(_.Button,{size:"small",onClick:p,children:"重试"})}):null]})})]})]})}),{Option:Po}=_.Select,JG=y.forwardRef(({onSubmit:t,config_schema:e,nodeId:n},r)=>{const[o]=_.Form.useForm(),i=xl(),s=_.Form.useWatch("type",o);St.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?_.message.warning(G("link.flow.loop_start_end_check")):t({properties:m},d)).catch(()=>(_.message.warning(G("link.flow.missing_configuration")),!1)).finally(()=>l(!1)));y.useImperativeHandle(r,()=>({saveConfig:d=>c(d)}));const u=At();return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:i,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsxs(_.Form,{disabled:!u,form:o,layout:"vertical",children:[h.jsxs(_.Row,{children:[h.jsx(_.Col,{sm:24,lg:12,children:h.jsx(_.Form.Item,{name:"type",label:G("app.common.word.loop-data-type"),rules:[{required:!0,message:G("link.flow.please_select_data_type")}],children:h.jsxs(_.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(_.Col,{sm:24,lg:12,children:h.jsxs(_.Form.Item,{required:!0,label:G("link.flow.loop_start_end"),style:{display:"flex"},children:[h.jsx(_.Form.Item,{name:"start",noStyle:!0,rules:[{required:!0,message:G("link.flow.please_select_data_type")}],children:h.jsx(_.InputNumber,{min:1,style:{marginRight:20}})}),h.jsx(_.Form.Item,{name:"end",noStyle:!0,rules:[{required:!0,message:G("link.flow.please_select_data_type")}],children:h.jsx(_.InputNumber,{min:1})})]})}),s&&s!=="NUMBER"&&h.jsx(_.Col,{sm:24,lg:12,children:h.jsx(_.Form.Item,{rules:[{required:!0,message:G("link.flow.please_enter_loop_expression")}],label:G("link.flow.loop_expression"),name:"expression",children:h.jsx(In,{nodeId:n,borrow:!0,valueType:"JS_EXP",placeholder:G("link.flow.please_enter_loop_expression")})})}),!s&&h.jsx(_.Col,{})]}),h.jsxs(_.Row,{children:[h.jsx(_.Col,{sm:24,lg:12,children:h.jsx(_.Form.Item,{name:"asc",label:G("app.common.word.circulation-direction"),rules:[{required:!0,message:G("link.flow.please_select_loop_direction")}],children:h.jsxs(_.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(_.Col,{sm:24,lg:12,children:h.jsx(_.Form.Item,{name:"errorExec",label:G("link.flow.loop_processing"),rules:[{required:!0,message:G("link.flow.please_select_loop_processing")}],children:h.jsxs(_.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(_.Button,{type:"primary",disabled:!u,loading:a,className:"workflow-node-form-save",onClick:()=>c(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),Wd=()=>`branch_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,{Option:QG}=_.Select,ZG=y.forwardRef((t,e)=>{const{config_schema:n,nodeId:r}=t,[o]=_.Form.useForm(),i=xl(),{handleNodeDataUpdate:s}=Ri(),[a,l]=y.useState(null),[c,u]=y.useState(""),f=(D=>!(D!=null&&D.branches)||D.branches.length===0?{branches:[{id:Wd(),name:G("link.flow.switch.condition_one"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]},{id:Wd(),name:G("link.flow.switch.condition_two"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]}]}:{branches:D.branches.map((O,A)=>{var T;return{id:O.id||Wd(),name:O.name||G("link.flow.switch.condition_n",{n:A+1}),or_list:((T=O.or_list)==null?void 0:T.map(B=>{var M;return{and_list:((M=B.and_list)==null?void 0:M.map(F=>({query:F.query||"",operator:F.operator||"",value:F.value||""})))||[{query:"",operator:"",value:""}]}}))||[{and_list:[{query:"",operator:"",value:""}]}]}})})(n),p=()=>{const D=o.getFieldValue("branches")||[];s({id:r,data:{config_schema:{branches:D}}})},m=(D,E)=>{l(D),u(E)},b=()=>{l(null),u("")},v=D=>{const E=Mt.cloneDeep(o.getFieldValue("branches"))||[],O=c.trim();if(!O){_.message.error(G("link.flow.switch.branch_name_cannot_be_empty"));return}if(E.some((T,B)=>B!==D&&T.name===O)){_.message.error(G("link.flow.switch.branch_name_duplicate"));return}E[D].name=O,o.setFieldValue("branches",E),l(null),u(""),p()},w=(D,E)=>{const O=o.getFieldValue("branches")||[];if(E<0||E>=O.length)return;const A=[...O],[T]=A.splice(D,1);A.splice(E,0,T),o.setFieldValue("branches",A),p()},[g,C]=y.useState(!1),S=D=>(C(!0),o.validateFields().then(async E=>{if(!E.branches.some(T=>T.or_list.some(B=>B.and_list.some(M=>M.query&&M.operator)))){_.message.error(G("link.flow.switch.at_least_one_valid_branch"));return}const A=Mt.cloneDeep(E);return A.branches.forEach(T=>{T.or_list.forEach(B=>{B.and_list.forEach(M=>{M.value=_G(M.operator,M.value)})})}),t.onSubmit({properties:A},D)}).catch(()=>(_.message.warning(G("link.flow.missing_configuration")),!1)).finally(()=>C(!1)));y.useImperativeHandle(e,()=>({saveConfig:D=>S(D)}));const k=At(),x=(D,E,O,A)=>{const B=(o.getFieldValue("branches")||[])[E],M=a===E;return h.jsxs(_.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:M?h.jsxs(_.Space,{children:[h.jsx(_.Input,{value:c,onChange:F=>u(F.target.value),style:{width:200},placeholder:G("link.flow.switch.enter_branch_name"),onPressEnter:()=>v(E)}),h.jsx(_.Button,{type:"text",size:"small",icon:h.jsx(ie.CheckOutlined,{style:{color:"#52c41a"}}),onClick:()=>v(E)}),h.jsx(_.Button,{type:"text",size:"small",icon:h.jsx(ie.CloseOutlined,{}),onClick:b})]}):h.jsxs(_.Space,{children:[h.jsx("span",{style:{fontSize:13,fontWeight:400},children:(B==null?void 0:B.name)||G("link.flow.switch.condition_n",{n:E+1})}),k&&h.jsx(_.Button,{type:"text",size:"small",icon:h.jsx(ie.EditOutlined,{}),onClick:()=>m(E,(B==null?void 0:B.name)||"")})]})}),k&&h.jsxs(_.Space,{className:"actions",children:[h.jsx(_.Tooltip,{title:G("link.flow.switch.move_to_top"),children:h.jsx(_.Button,{type:"text",size:"small",disabled:E===0,onClick:()=>w(E,0),children:"置顶"})}),h.jsx(_.Tooltip,{title:G("link.flow.switch.move_up"),children:h.jsx(_.Button,{type:"text",size:"small",icon:h.jsx(ie.ArrowUpOutlined,{}),disabled:E===0,onClick:()=>w(E,E-1)})}),h.jsx(_.Tooltip,{title:G("link.flow.switch.move_down"),children:h.jsx(_.Button,{type:"text",size:"small",icon:h.jsx(ie.ArrowDownOutlined,{}),disabled:E===O-1,onClick:()=>w(E,E+1)})}),h.jsx(_.Tooltip,{title:G("link.flow.switch.move_to_bottom"),children:h.jsx(_.Button,{type:"text",size:"small",disabled:E===O-1,onClick:()=>w(E,O-1),children:"置底"})}),h.jsx(_.Tooltip,{title:G("common.delete"),children:h.jsx(_.Button,{type:"text",size:"small",disabled:O<=1,onClick:()=>{if(O<=1){_.message.warning(G("link.flow.switch.at_least_one_branch"));return}A(D.name),setTimeout(()=>{p()},0)},children:"删除"})})]})]}),h.jsx(_.Form.Item,{name:[D.name,"name"],hidden:!0,children:h.jsx(_.Input,{})}),h.jsx(_.Form.List,{name:[D.name,"or_list"],children:(F,{add:N,remove:P})=>h.jsx(h.Fragment,{children:F.map((I,z)=>{const H=z===F.length-1;return h.jsx(h.Fragment,{children:h.jsxs("div",{className:"switch-rule",children:[F.length>1&&k&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsxs(_.Button,{type:"link",icon:h.jsx(ie.MinusCircleOutlined,{}),onClick:()=>P(I.name),children:[h.jsx(Te.FormattedMessage,{id:"link.flow.remove"})," OR"]})}),h.jsx(_.Form.List,{name:[I.name,"and_list"],children:(J,{add:K,remove:ee})=>h.jsx(h.Fragment,{children:J.map(($,U)=>{const R=U===J.length-1;return h.jsxs(_.Space,{direction:"vertical",style:{width:"100%"},children:[h.jsxs(_.Space,{align:"center",className:"switch-rule-item",children:[h.jsx(_.Form.Item,{style:{minWidth:150,marginBottom:0},name:[$.name,"query"],label:G("app.common.word.variable-name"),rules:[{required:!0,message:G("link.flow.please_enter_variable_name")}],children:h.jsx(In,{nodeId:t.nodeId,placeholder:G("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),h.jsx(_.Form.Item,{style:{marginBottom:0},name:[$.name,"operator"],label:G("app.common.word.condition"),rules:[{required:!0,message:G("link.flow.please_select_condition")}],children:h.jsx(_.Select,{style:{minWidth:140},placeholder:G("link.flow.select_condition"),getPopupContainer:()=>document.body,children:nO.map(te=>h.jsx(QG,{value:te.operator,children:te.label},te.operator))})}),h.jsx(_.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const te=o.getFieldValue(["branches",D.name,"or_list",I.name,"and_list",$.name,"operator"]);return nw(te)?null:h.jsx(_.Form.Item,{style:{minWidth:150,marginBottom:0},name:[$.name,"value"],label:G("app.common.word.value"),rules:[],children:h.jsx(In,{nodeId:t.nodeId,placeholder:G("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),U===0&&h.jsx("div",{style:{width:30}}),U>0&&k&&h.jsx(_.Button,{type:"link",icon:h.jsx(ie.MinusCircleOutlined,{}),onClick:()=>ee($.name)})]}),U<J.length-1&&h.jsx(_.Divider,{plain:!0,style:{margin:"8px 0"},children:h.jsx(_.Tag,{color:"#999999",children:h.jsx(Te.FormattedMessage,{id:"link.flow.and"})})}),h.jsxs("div",{className:`rule-opt-actions ${R?"last-and-rule":""}`,children:[U===J.length-1&&h.jsx(_.Button,{type:"link",disabled:!k,icon:h.jsx(br,{size:14}),onClick:()=>K({query:"",operator:"",value:""}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-new-and"})}),H&&h.jsx(_.Button,{type:"link",icon:h.jsx(br,{size:14}),disabled:!k,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(_.Divider,{style:{color:"orange"},dashed:!0,children:h.jsx(_.Tag,{color:"#1890ff",children:h.jsx(Te.FormattedMessage,{id:"link.flow.or"})})})})]},I.key)})})})})]},D.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(_.Form,{disabled:!k,form:o,initialValues:f,layout:"vertical",autoComplete:"off",children:h.jsx(_.Form.List,{name:"branches",children:(D,{add:E,remove:O})=>h.jsxs(h.Fragment,{children:[D.map((A,T)=>x(A,T,D.length,O)),D.length<10&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end",width:"100%"},children:h.jsx(_.Button,{type:"default",icon:h.jsx(br,{size:14}),disabled:!k,onClick:()=>{const A=D.length+1;E({id:Wd(),name:G("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"})})}),D.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:k&&h.jsx(_.Button,{type:"primary",disabled:!k,loading:g,className:"workflow-node-form-save",onClick:()=>S(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),eR=({nodeId:t,onSubmit:e,data:n})=>{const[r]=_.Form.useForm(),o=xl(),i=At(),{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{_.message.error(G("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:G("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:G("app.common.word.retry-count"),tooltip:G("app.common.word.retry-count-tooltip"),width:"xl",fieldProps:{min:1,max:10,precision:0,style:{width:"100%"}},rules:[{required:u,message:G("app.common.word.please-enter-retry-count")}]}),h.jsx(jn.ProFormDigit,{name:"retryInterval",label:G("app.common.word.retry-interval"),tooltip:G("app.common.word.retry-interval-tooltip"),fieldProps:{min:1,max:60,precision:0,style:{width:"100%"},addonAfter:"s"},rules:[{required:u,message:G("app.common.word.please-enter-retry-interval")}]}),h.jsx(jn.ProFormDigit,{name:"stepFactor",label:G("app.common.word.step-factor"),tooltip:G("app.common.word.step-factor-tooltip"),width:"xl",fieldProps:{min:1,max:5,precision:1,style:{width:"100%"}},rules:[{required:u,message:G("app.common.word.please-enter-step-factor")}]}),h.jsx(jn.ProFormDigit,{name:"maxRetryInterval",label:G("app.common.word.max-retry-interval"),tooltip:G("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:G("app.common.word.please-enter-max-retry-interval")}]})]}):null}),h.jsx(jn.ProFormSwitch,{name:"alertEnabled",label:G("app.common.word.enable-alert")}),h.jsx(jn.ProFormDependency,{name:["alertEnabled"],children:({alertEnabled:u})=>u?h.jsx(jn.ProFormText,{name:"webhookUrl",label:G("app.common.word.webhook-url"),placeholder:G("app.common.word.enter-webhook-url"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:u,message:G("app.common.word.enter-webhook-url")}]}):null}),h.jsx(jn.ProFormSelect,{name:"errorHandling",label:G("app.common.word.error-handling"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:!0,message:G("app.common.word.select-error-handling")}],options:[{label:G("app.common.word.interrupt-flow"),value:"interrupt"},{label:G("app.common.word.ignore-error"),value:"ignore"}]}),h.jsx(jn.ProFormSwitch,{name:"applyToAllNodes",label:G("app.common.word.apply-to-all-nodes")})]})}),h.jsx("div",{className:"workflow-node-form-footer",children:h.jsx(_.Button,{type:"primary",disabled:!i,onClick:()=>r.submit(),className:"workflow-node-form-save",children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})},aO="[workflow:schema-render]",tR=()=>{const{event$:t}=y.useContext(Qr),e=Th();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},nR=({children:t})=>{const{event$:e}=y.useContext(Qr),n=Nh(),[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(ax.Provider,{value:s,children:t})},rR=t=>h.jsxs("div",{className:"node-config-title",style:{display:"flex",alignItems:"center"},children:[h.jsx("div",{className:"node-config-icon",style:{backgroundImage:`url(${t.icon})`},children:t.icon?"":t.name}),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})]})]}),oR=y.memo(({visible:t,onClose:e,data:n,nodeType:r=pe.ACTION,nodeId:o=""})=>{var B,M;const i=St.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(),b=Pt(),v=((M=(B=b.nodeConfigPanel)==null?void 0:B.testArea)==null?void 0:M.allowManualTest)!==!1,w=St.useReactive({output:"",ignore:!1,expandTestPanel:!1}),g=y.useMemo(()=>b.nodeConfigPanel.showSettings&&![pe.TRIGGER,pe.AI_SUB_NODE].includes(r),[r,b.nodeConfigPanel.showSettings]),C=(n==null?void 0:n.action_id)??(n==null?void 0:n.id),S=C!==null&&typeof C<"u"&&C!==""&&Number.isFinite(Number(C))?C:null,k=po(n),x=n==null?void 0:n.nodeKey,D=(n==null?void 0:n.nodeVersion)??(n==null?void 0:n.action_ver),{handleNodeDataUpdate:E}=Ri();y.useEffect(()=>{var N,P;if(!t)return;const F=S!==null&&Number(S)<=0;x&&F&&!k&&!((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(`${aO} possible nodepackage schema route mismatch`,{nodeId:o,nodeType:r,actionId:S,nodePackageKey:x,nodePackageVersion:D,reason:"keyed node with non-positive action_id and no classic sub_params was rejected by the nodePackage-compatible node check"})},[S,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,k,x,D,o,r,t]);const O=y.useCallback(async(F,N)=>{var I,z,H;const P=b.flowId;try{const J=m.getState().nodes.find(R=>R.id===o),K=k?GP(F):F.properties,ee=k?RP(F):F.account_id??null,$=k?{flow_id:P,properties:K,position:J==null?void 0:J.position,action_id:S,account_id:ee,proxy_id:F.proxy_id,mcp_tool_description:F.mcp_tool_description,action_key:x,action_ver:D}:{flow_id:P,...F,position:J==null?void 0:J.position,action_id:S};console.info(`${aO} save node config`,{nodeId:o,nodeType:r,actionId:S,isNodepackageNode:k,nodePackageKey:x,nodePackageVersion:D,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 U=w.ignore?await My(o,"","","",K,w.output):await rc(o,$);if(U)if(w.ignore)(I=p.current)==null||I.finishSampleTest(),E({id:o,data:{status:me.SUCCESS,output:w.output,outputSource:"sample"}}),_.message.success("已使用样本数据完成调试");else{_.message.success("节点配置已保存");const R={params:void 0,properties:K,account_id:ee,mcp_tool_description:F.mcp_tool_description,action_key:x,action_ver:D,nodeKey:x,nodeVersion:D,isNodePackage:k};E({id:o,data:{config_schema:K,account_id:F.account_id,...R,position:J==null?void 0:J.position,status:U.status}})}N&&!w.ignore&&((z=p.current)==null||z.onTestNode()),w.ignore=!1,w.output=""}catch{w.ignore&&((H=p.current)==null||H.abortSampleTest(),E({id:o,data:{status:me.FAILED}}))}},[S,b.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,E,k,x,D,o,r,w,m]);y.useCallback(F=>{!k||r!==pe.SWITCH||E({id:o,data:{config_schema:F,properties:F}})},[E,k,o,r]);const A=F=>{var N,P,I,z,H;return k?(N=c.current)==null?void 0:N.saveConfig(F):r===pe.LOOP?(P=f.current)==null?void 0:P.saveConfig(F):r===pe.CONDITION?(I=u.current)==null?void 0:I.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 I;if(N){w.ignore=!0,w.output=P||"",await A(F),(I=p.current)==null||I.finishNodeTest();return}if(F)try{_.message.loading("正在保存节点配置...",0),await A(F),_.message.success("节点配置已保存"),_.message.destroy()}catch(z){_.message.destroy(),console.error("节点配置保存失败:",z),_.message.error("节点配置保存失败,无法执行测试")}};return h.jsx(_.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(nC,{children:[h.jsx(tR,{}),h.jsx(nR,{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(sO,{ref:l,nodeId:o,onInsert:()=>{},open:t})})}),h.jsx("div",{className:"middle-section",children:h.jsxs("div",{className:"config-container",children:[h.jsx(rR,{icon:n==null?void 0:n.icon,name:(n==null?void 0:n.action_name)||(n==null?void 0:n.label),description:n==null?void 0:n.description}),h.jsx(_.Tabs,{style:{height:"100%"},items:[{key:"property",label:"参数配置",children:h.jsxs(h.Fragment,{children:[k||![pe.CONDITION,pe.SWITCH,pe.LOOP].includes(r)?h.jsx(DG,{ref:c,nodeId:o,nodeType:r,data:n,onSubmit:O}):null,r===pe.CONDITION&&!k?h.jsx(OG,{ref:u,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null,r===pe.SWITCH&&!k?h.jsx(ZG,{ref:d,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null,r===pe.LOOP&&!k?h.jsx(JG,{ref:f,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null]})},{key:"setting",label:"设置",children:h.jsx(eR,{data:n,nodeId:o,onSubmit:()=>{_.message.success("保存成功")}})}].slice(0,g?2:1)})]})}),h.jsx("div",{className:`right-section ${w.expandTestPanel?"expand":""}`,children:v&&h.jsx("div",{className:"test-section",children:h.jsx(UG,{ref:p,nodeId:o,beforeHook:T,onClose:e,onExpandPanel:F=>{w.expandTestPanel=F}})})})]})})})})]})})})},(t,e)=>Mt.isEqual(Mt.omit(t,["isHovered"]),Mt.omit(e,["isHovered"]))),sw="MCP_TRIGGER",lO="mcp_trigger",cO=200,iR=10;$e.MCP_SERVER;const aw="dip.core.trigger.mcp-server",sR=[aw],aR=(t,e)=>{const n=new Set(e);return t.some(o=>n.has(o.id)&&Dh(o)&&sR.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):[]},lR=[pe.AGENT,pe.BROWSER],lw=()=>{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(b=>b.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(b=>b.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&&ch(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:b}=t.getState(),v=new Set(l);lR.includes(c)&&l.forEach(C=>{s(C,d).forEach(k=>{v.add(k)})}),aR(u,l).forEach(C=>v.add(C));const w=Array.from(v),g=d.filter(C=>v.has(C.source)||v.has(C.target)).map(C=>C.id);if(m){const C=w.map(S=>({type:"remove",id:S}));m(C)}else f(u.filter(C=>!w.includes(C.id)));if(g.length)if(b){const C=g.map(S=>({type:"remove",id:S}));b(C)}else p(d.filter(C=>!g.includes(C.id)))},[t,s]);return{autoSaveNum:e,onNodeMouseEnter:r,onNodeMouseLeave:o,handleNodesChange:i,handleNodesDelete:a}};function cR(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(vW,{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)"}},uO=({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:b=!0,onToggleNodeDisabled:v})=>{const{currentNodeConfigVisibleId:w,setNodeConfigVisible:g}=ao(),{handleNodeDataUpdate:C}=Ri(),{handleNodesDelete:S}=lw(),k=Pt(),x=na(),D=$=>{C({id:t,data:{note:$}})},E=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]),M=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()[$],I=()=>i.map($=>h.jsx(I0,{nodeId:t,id:$.id,position:$.position,type:$.type||un.TARGET,category:$.category,connectionLimit:$.maxConnections,label:$.label,nodeStatus:d,protocol:$.protocol,portSchema:$.portSchema,shape:$.shape,style:$.style},`${t}-${$.id}`)),z=async()=>{var R,te;const $=((R=k.canvas.fixedNodes)==null?void 0:R.triggerIds)||[],U=((te=k.nodeTypes.fixed)==null?void 0:te.triggers)||[];if($.includes(t)||U.includes(e)){_.message.warning("当前触发节点已被配置为不可删除");return}await Rf(t),S([t],e)},H=y.useMemo(()=>{const $=s.length,U=new Map;return s.forEach(R=>{const te=R.position,se=U.has(te)?U.get(te)+1:1;U.set(te,se)}),s.map((R,te)=>h.jsx(I0,{nodeId:t,connectionLimit:R.maxConnections,id:R.id,style:R.style,position:R.position,protocol:R.protocol,portSchema:R.portSchema,type:R.type,label:R.label,shape:R.shape,nodeStatus:d,index:[te,$,U.get(R.position)]},`${t}-${R.id}`))},[t,s,d]),J=()=>h.jsx(tC,{status:d,disabled:B}),K=()=>{switch(d){case me.INVALID:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-warning-icon",children:h.jsx(ie.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(ie.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(ie.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(ie.LoadingOutlined,{style:{color:P()},size:12})});default:return null}},ee=()=>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})}),b&&h.jsx(OP,{title:p==null?void 0:p.connector_name,nodeId:t,note:(p==null?void 0:p.note)||"",statusIcon:K(),onNoteChange:D,description:p.action_name,className:"workflow-node-text"})]});return h.jsxs(y.Fragment,{children:[h.jsxs("div",{style:{width:M,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(_.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(ie.RobotOutlined,{style:{fontSize:"11px"}}),"由AI生成"]})}),s()]})},Kq=t=>{var n;const e=Mn();return h.jsx(_.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(_.Select.Option,{label:r.label,value:r.value,children:r.label},r.value))})},Yq=t=>h.jsx(_.DatePicker,{style:{width:"100%"},picker:"date",value:t.value?Ht(t.value):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD")))}}),Xq=t=>h.jsx(y.Fragment,{children:h.jsx(_.DatePicker,{style:{width:"100%"},picker:"date",showTime:!0,value:t.value?Ht(t.value):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD hh:mm:ss")))}})}),Jq=({value:t=[],onChange:e,selectType:n="KNOWLEDGE_BASE",placeholder:r="请选择"})=>{const o=St.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??Mn()}))},[t]);const c=At(),u=p=>{const m=o.items.filter(b=>b.id!==p);e==null||e(m)},d=()=>{e([...o.items,{value:"",id:Mn()}])},f=(p,m)=>{e(o.items.map((b,v)=>v===p?{...b,value:m}:b))};return h.jsxs("div",{children:[o.items.length?o.items.map((p,m)=>h.jsxs(_.Space,{size:"small",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[h.jsx(_.Select,{value:p.value||void 0,onChange:b=>f(m,b),placeholder:r,style:{width:300},disabled:!c||a,loading:a,options:i,showSearch:!0,filterOption:(b,v)=>((v==null?void 0:v.label)??"").toLowerCase().includes(b.toLowerCase()),getPopupContainer:b=>b.parentNode}),c&&h.jsx(_.Button,{icon:h.jsx(xi,{size:16}),onClick:()=>{u(p.id)}})]},p.id)):null,c&&h.jsx(_.Button,{type:"default",onClick:d,block:!0,icon:h.jsx(br,{size:16}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})})]})},Qq=({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=St.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??Mn()}))},[t]);const s=()=>{e==null||e([...o.items,{key:"",value:"",id:Mn()}])},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=At();return h.jsxs("div",{className:"workflow-extend-object",children:[o.items.length?o.items.map((u,d)=>h.jsxs(_.Space,{size:"small",className:"workflow-extend-object__row",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[h.jsx(_.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(In,{borrow:!0,disableIDE:!0,placeholder:"Value",style:{width:300},value:u.value,onChange:f=>l(u.id,f),valueType:n,nodeId:""})}),c&&h.jsx(_.Button,{icon:h.jsx(xi,{size:16}),onClick:()=>{r(u.id)}})]},u.id)):null,h.jsxs(_.Button,{type:"default",onClick:s,block:!0,children:[h.jsx(br,{size:16})," ",h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})]})]})},Zq=t=>null,eG=t=>h.jsx(_.TimePicker,{style:{width:"100%"},use12Hours:!1,format:"HH:mm",value:t.value?Ht(t.value,"HH:mm"):null,onChange:e=>{const n=Ht(e).format("HH:mm:00");t.onChange&&(t==null||t.onChange(n))}}),{Text:tG}=_.Typography,RA=t=>h.jsx("div",{className:"ce-tag_input",children:h.jsx("p",{children:h.jsx(_.Tooltip,{title:t.value,color:"cyan",placement:"topLeft",children:h.jsx(tG,{ellipsis:!0,copyable:{text:t.value},children:t.value})})})}),nG=({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??Mn()})))},[t]);const i=At(),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:Mn()},p=[...r,f];o(p),e(p)},l=(f,p)=>{const m=r.map(b=>b.id===f?{...b,field:p}:b);o(m),e(m)},c=(f,p)=>{const m=r.map(b=>b.id===f?{...b,dataType:p}:b);o(m),e(m)},u=(f,p)=>{const m=r.map(b=>b.id===f?{...b,desc:p}:b);o(m),e(m)},d=(f,p)=>{const m=r.map(b=>b.id===f?{...b,required:p}:b);o(m),e(m)};return h.jsxs("div",{className:"workflow-multi-row-extract",children:[r.length?r.map(f=>h.jsxs(_.Space,{size:"small",className:"workflow-multi-row-extract__row",style:{display:"flex",marginBottom:8,width:"100%"},align:"start",children:[h.jsx(_.Input,{value:f.field,onChange:p=>l(f.id,p.target.value),placeholder:"字段名称",status:"",style:{width:130},disabled:!i}),h.jsx(_.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(_.Input,{value:f.desc,onChange:p=>u(f.id,p.target.value),placeholder:"字段描述",status:"",style:{width:200},disabled:!i}),h.jsx(_.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(_.Button,{icon:h.jsx(xi,{size:16}),onClick:()=>{s(f.id)}})]},f.id)):null,i&&h.jsx(_.Button,{type:"default",onClick:a,block:!0,icon:h.jsx(br,{size:16}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})})]})},rG=t=>{const e=y.useMemo(()=>Mn(),[]),{event$:n}=y.useContext(Qr),r=Ym(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(_.Space.Compact,{block:!0,className:`workflow-password-field${r?` ${rd}`:""}`,children:[h.jsx("span",{className:"workflow-password-field__prefix",children:G("link.flow.cipherText")}),h.jsx(_.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})]})},oG=t=>{var o;const e=Mn(),{multiple:n,...r}=t;return h.jsx(_.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(_.Select.Option,{label:i.label,value:i.value,children:i.label},i.value))})},iG=t=>h.jsx(_.TimePicker,{style:{width:"100%"},value:t.value?Ht(t.value,"HH:mm:ss"):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("HH:mm:ss")))}}),El=()=>Pt().flowId,sG=["sample","test","payload","body"],aG=["测试","样本","sample","test","payload","body"],KA=t=>{var n,r,o;return[Ee.JSON,Ee.TEXTAREA,Ee.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},YA=(t,e)=>{if(!t)return!1;const n=t.toLowerCase();return e.some(r=>n.includes(r))},lG=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}},cG=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(b=>KA(b)&&(YA(b.name,sG)||YA(b.display_name,aG)));return m||n.find(b=>KA(b))},[n]),f=y.useCallback(()=>{c.current&&(clearInterval(c.current),c.current=void 0)},[]);y.useEffect(()=>()=>{f()},[f]);const p=y.useCallback(async()=>{if(!u){_.message.warning("缺少连接流ID,无法监听Webhook");return}if(!(d!=null&&d.name)){_.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}),b=lG(m);b?(e.setFieldsValue({[d.name]:b}),_.message.success("已捕获Webhook推送数据并填充测试样例")):_.message.info("监听结束,暂无新的推送数据")}catch(m){console.error("监听Webhook失败:",m),_.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(RA,{...o})}),h.jsx(_.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)`:""}`:"监听"})]})},uG={configFormContainer:"_configFormContainer_1frpl_1"};function dG(t){return Nq(t==null?void 0:t.credentials)}const fG=t=>String(t.type).toUpperCase();function XA(t){var e,n;return(n=(e=t==null?void 0:t.input_fields)==null?void 0:e.find(r=>fG(r)==="PROXY"))==null?void 0:n.key}function JA(t){return t==null||t===""?"0":String(t)}function hG(t,e,n){const r=XA(e);return r?{...t,[r]:JA(n??t[r])}:t}function pG(t,e){const n=XA(e);if(!n)return{properties:t};const r={...t},o=JA(r[n]);return delete r[n],{properties:r,proxyId:o}}const QA=({field:t,disabled:e,readOnly:n,context:r,value:o="",onChange:i,id:s,allowVariableInsert:a,hasModeSwitch:l})=>{const c=cC(),u=y.useId(),d=s||`workflow-code-${u}`,f=y.useRef(null),[p,m]=y.useState(0),b=!e&&!n,v=y.useCallback(k=>{var E;if(!a)return;const x=(E=f.current)==null?void 0:E.view,D=x==null?void 0:x.state.selection.main;if(!x||!D){i==null||i(`${o}${k}`);return}x.dispatch({changes:{from:D.from,to:D.to,insert:k},selection:{anchor:D.from+k.length}}),x.focus()},[a,i,o]),w=rC(d,k=>v(k),()=>{var k,x;return(x=(k=f.current)==null?void 0:k.view)==null?void 0:x.focus()}),g=Nh(),C=(g==null?void 0:g.activeFieldId)===d,S=y.useCallback(()=>{if(b)try{i==null||i(JSON.stringify(JSON.parse(o),null,2))}catch{_.message.warning(G("link.flow.format_json_failed"))}},[b,i,o]);return h.jsx(gC,{id:d,canEditInEditor:b,openEditorNumber:p,nodeId:c.nodeId||r.nodeId||"",value:o,language:"json",showVariableSidebar:a,onFinish:i,children:h.jsxs("div",{style:{position:"relative"},className:C?rd:void 0,children:[h.jsx(td,{id:d,ref:f,value:o,readOnly:!b,height:"220px",placeholder:t.placeholder,theme:bm,extensions:[PA()],onFocus:()=>{b&&a&&w.activate()},onChange:i}),b?h.jsxs(_.Space,{size:4,style:{position:"absolute",right:l?148:8,top:6,zIndex:2},children:[h.jsx(_.Tooltip,{title:G("link.flow.format_json"),children:h.jsx(_.Button,{type:"text",size:"small","aria-label":G("link.flow.format_json"),icon:h.jsx(ie.FormatPainterOutlined,{}),onClick:S,style:{color:"#fff"}})}),h.jsx(_.Tooltip,{title:G("link.flow.open_code_editor"),children:h.jsx(_.Button,{type:"text",size:"small","aria-label":G("link.flow.open_code_editor"),icon:h.jsx(ie.FullscreenOutlined,{}),onClick:()=>m(k=>k+1),style:{color:"#fff"}})})]}):null]})})};QA.displayName="WorkflowCodeEditor";const ZA=({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(QA,{...d,field:t,context:r,id:s,allowVariableInsert:c,hasModeSwitch:l});return t.valueModePolicy?h.jsx(Ci,{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})};ZA.displayName="WorkflowCodeFieldControl";const mG=ft(ZA,{needsFormItemName:!0,supportsVariableInsert:!0}),eO=({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),qf().then(f=>{d||s(Array.isArray(f)?f:[])}).catch(()=>{d||_.message.error(G("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(_.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%"}})};eO.displayName="WorkflowProxyFieldControl";const gG=ft(eO,{needsFormItemName:!0,supportsVariableInsert:!0}),wG=[{type:ge.CODE,definition:mG},{type:ge.PROXY,definition:gG}];function bG({children:t}){return h.jsx(dC,{additionalRegistrations:wG,children:t})}function xl(){const{event$:t}=y.useContext(Qr),e=Th();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 vG=[Ee.TEXT,Ee.PASSWORD,Ee.SELECT,Ee.EXTEND_OBJ,Ee.DATE,Ee.TIME,Ee.DATETIME,Ee.TEXTAREA,Ee.FIXED_OBJ,Ee.JSON],yG="[workflow:schema-render]",CG=/^\{\{([^.{}]+)\.(.+)\}\}$/,kG=t=>{switch(t.page_control){case Ee.SELECT:case Ee.API_SELECT:return t.multi_valued?[]:null;case Ee.EXTEND_OBJ:return{};case Ee.HIDDEN:return"";case Ee.TEXT:return"";case Ee.PASSWORD:return"";case Ee.LABEL:return"";case Ee.DATE:return null;case Ee.TIME:return null;case Ee.DATETIME:return null;case Ee.TEXTAREA:return"";case Ee.FIXED_OBJ:return{};case Ee.MultiRowAIExtractConfig:return[];case Ee.JSON:return""}},tO=(t,e,n,r,o)=>{const i=t.display_name,s=()=>{var a,l,c;switch(t.page_control){case Ee.SELECT:return h.jsx(oG,{options:Xg(t.option_value_objects??t.option_values),multiple:t.multi_valued});case Ee.API_SELECT:return h.jsx(Kq,{options:Xg(t.option_value_objects??t.option_values)});case Ee.EXTEND_OBJ:return h.jsx(Qq,{valueType:t.value_type});case Ee.HIDDEN:return h.jsx(Zq,{});case Ee.TEXT:return h.jsx(In,{valueType:t.value_type,nodeId:e});case Ee.PASSWORD:return h.jsx(rG,{valueType:t.value_type});case Ee.LABEL:return(a=r==null?void 0:r.webhookField)!=null&&a.enabled&&t.name==="hookUrl"&&r.webhookField.form?h.jsx(cG,{form:r.webhookField.form,configList:r.webhookField.configList,disabled:r.webhookField.disabled}):h.jsx(RA,{});case Ee.DATE:return h.jsx(Yq,{});case Ee.TIME:return h.jsx(iG,{});case Ee.DATETIME:return h.jsx(Xq,{});case Ee.TEXTAREA:return h.jsx(In,{valueType:t.value_type,textAreaMode:!0,nodeId:e});case Ee.FIXED_OBJ:return h.jsx(_.Input.TextArea,{});case Ee.JSON:return h.jsx(In,{valueType:t.value_type,nodeId:e});case Ee.MultiRowAIExtractConfig:return h.jsx(nG,{valueType:t.value_type});case Ee.MULTI_SELECT_LIST:return h.jsx(Jq,{selectType:"KNOWLEDGE_BASE"});case Ee.SYNC_HOUR_MINUTE:return h.jsx(eG,{});case Ee.AUTH_TOKEN:return h.jsx(Vq,{disabled:(l=r==null?void 0:r.webhookField)==null?void 0:l.disabled});case Ee.SECRET_KEY:return h.jsx(Wq,{});case Ee.SELECT_CLIENT:return h.jsx(Gq,{});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&&vG.includes(t.page_control)?h.jsx("div",{children:h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:t.page_control===Ee.SELECT?G("link.flow.please_select")+t.display_name:G("link.flow.please_enter")+t.display_name}],label:i,name:t.name,children:h.jsx(Rq,{children:s()})})},t.ui_id):h.jsx(_.Form.Item,{required:t.required,style:t.page_control===Ee.HIDDEN?{display:"none"}:{},rules:[{required:t.required,message:t.page_control===Ee.SELECT?G("link.flow.please_select")+t.display_name:G("link.flow.please_enter")+t.display_name},{validator(a,l,c){if(t.page_control===Ee.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)},SG=t=>(t.child_conditions??[]).map(e=>e.left).filter(e=>!!e),EG=(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},xG=y.forwardRef((t,e)=>{var we,fe;const{action:n,connector:r,nodeId:o,account_id:i,mcpMode:s,nodeType:a}=t,l=Pt(),c=ne.useStoreApi(),u=xl(),d=St.useReactive({proxyId:"0"}),{config_schema:f,proxy_id:p,protocol:m,account_schema_id:b}=n;a??n.node_type??n.type;const v=n.action_key||n.nodeKey,w=n.action_ver??n.nodeVersion,g=Array.isArray(f==null?void 0:f.sub_params),C=po(n),S=y.useMemo(()=>!C||!v?null:`${v}@${w??"latest"}`,[C,v,w]),k=S?`${o}:${S}`:o,x=n.account_id??i,D=y.useMemo(()=>S?Wi(v,w):null,[S,v,w]),[E,O]=y.useState(()=>S&&D?{identity:S,schema:D,loading:!1,finished:!0}:null),A=(E==null?void 0:E.identity)===S?E:null,T=(A==null?void 0:A.schema)??null,B=ew((T==null?void 0:T.credentials)??[]),M=!!(C&&v&&!T&&((A==null?void 0:A.loading)??!(A!=null&&A.finished))),F=dG(T);y.useEffect(()=>{!E||E.identity},[S,E,o,v,w]),y.useEffect(()=>{p&&(d.proxyId=p)},[p,d]);const[N]=_.Form.useForm(),[P,I]=y.useState(x);y.useEffect(()=>{I(x)},[k,x,I]);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===Ee.EXTEND_OBJ&&(Fe=yq(Fe)),Se[ce.name]=Fe??kG(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),J=y.useRef(null);y.useEffect(()=>{if(!S||!v){O(null);return}const le=Wi(v,w);if(le){O({identity:S,schema:le,loading:!1,finished:!0});return}let Se=!1;return O({identity:S,schema:null,loading:!0,finished:!1}),hc(v,w).then(ce=>{Se||O({identity:S,schema:ce,loading:!1,finished:!0})}).catch(ce=>{Se||(O({identity:S,schema:null,loading:!1,finished:!0}),console.error(`${yG} classic renderer next schema load failed`,{nodeId:o,nodeKey:v,nodeVersion:w,err:ce}))}),()=>{Se=!0}},[S,o,v,w]);const K=y.useMemo(()=>{var le;return(le=T==null?void 0:T.input_fields)!=null&&le.length?VI(VA(T.input_fields),T.key):null},[T]),ee=!!(C&&(K||F||T)),$=y.useMemo(()=>{const le=n.properties?ha(n.properties):f&&C?ha(f):n.params?ha(n.params):{},Se=hG(le,T,p);return cc(v)?ra(Se).properties:Se},[n,f,C,T,v,p]),U=y.useMemo(()=>JSON.stringify($??{}),[$]);y.useEffect(()=>{!C||!ee||(N.resetFields(),N.setFieldsValue($))},[k,N,C,$,U,ee]);const R=y.useRef(null);y.useEffect(()=>{R.current=null},[k]),y.useEffect(()=>{cc(v)&&(R.current=JSON.stringify(ra($).branches.map(le=>[le.id,le.name])))},[$,v]);const te=y.useCallback(le=>{const Se=le.trim().match(CG);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]),se=y.useCallback(le=>{var Se;return((Se=te(le))==null?void 0:Se.fieldPath)??le.replace(/^\{\{|\}\}$/g,"")},[te]),be=y.useCallback(le=>{var je;const Se=te(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}`},[te]),[j,Y]=y.useState(!1),W=(le,Se)=>(Y(!0),N.validateFields().then(async ce=>{var Ve,je,We,Ce,Oe;if(ee){Se&&((je=(Ve=H==null?void 0:H.current)==null?void 0:Ve.onIgnoreNodeStart)==null||je.call(Ve));const{properties:Pe,proxyId:qe}=pG(ce,T);return t.onSubmit({properties:Pe,account_id:P,proxy_id:qe},le)}const Fe=Mt.cloneDeep(n.config_schema);return Fe.sub_params.forEach(Pe=>{let qe=ce[Pe.name];Pe.page_control===Ee.EXTEND_OBJ&&qe!=="{{$fromAI}}"&&(qe=Jg(qe)),Pe.value=qe??null}),Se&&((Ce=(We=H==null?void 0:H.current)==null?void 0:We.onIgnoreNodeStart)==null||Ce.call(We)),!i&&m==="HTTP"&&(r==null?void 0:r.deployment_type)!=="SaasApp"&&(Fe.proxy_id=(Oe=J.current)==null?void 0:Oe.getProxyId()),t.onSubmit(Fe,le)}).catch(ce=>(console.log("err",ce),_.message.warning(G("link.flow.missing_configuration")),!1)).finally(()=>Y(!1)));y.useImperativeHandle(e,()=>({saveConfig:le=>W(le,!1)}));const X=At(),re={form:N,configList:(f==null?void 0:f.sub_params)??[],disabled:!X,...m==="WEBHOOK"?{webhookField:{enabled:!0,form:N,configList:(f==null?void 0:f.sub_params)??[],disabled:!X}}:{}},Z=le=>{const Se=le.page_control!==Ee.HIDDEN?h.jsx("p",{className:"field-desc",children:le.description}):null;if(!le.is_child)return h.jsxs("div",{children:[tO(le,o,s,re,l.canvas.registerComponents),Se]},le.ui_id);const ce=SG(le);return h.jsx(_.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 EG(le,Fe)?h.jsxs("div",{children:[tO(le,o,s,re,l.canvas.registerComponents),Se]}):null}},le.ui_id)};if(C&&M)return h.jsx("div",{style:{textAlign:"center",padding:40},children:h.jsx(_.Spin,{})});const de=!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(ee){const le=h.jsxs(h.Fragment,{children:[t.preRender&&t.preRender,F?h.jsx(qA,{credentialRequirements:B,value:P,onChange:I,linkApp:r,disabled:!X}):null]});return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:u,children:[h.jsx("div",{className:"workflow-node-form-scroll",children:K?h.jsx(bG,{children:h.jsx(Rg,{schema:K,form:N,initialValues:$,showSubmit:!1,showReset:!1,nodeId:o,mcpMode:s,renderVariableTag:se,renderVariableTooltip:be,customTheme:sc,preRender:le},k)}):ve}),h.jsx("div",{className:"workflow-node-form-footer",children:X&&h.jsx(_.Button,{type:"primary",disabled:!X,loading:j,className:"workflow-node-form-save",onClick:()=>W(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:u,children:[h.jsxs(_.Form,{form:N,disabled:!X,layout:"vertical",className:`${uG.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(Kg,{proxyId:d.proxyId,ref:J}):null,de&&ve]}),h.jsx("div",{className:"workflow-node-form-footer",children:X&&h.jsx(_.Button,{type:"primary",disabled:!X,loading:j,className:"workflow-node-form-save",onClick:()=>W(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),DG=y.memo(y.forwardRef((t,e)=>{const{nodeId:n,data:r}=t,{account_id:o,account_schema_id:i}=r,s=St.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 b=ha(p),w=Object.hasOwn(p??{},"account_id")?p.account_id??null:s.account_id;return t.onSubmit({properties:b,account_id:w,proxy_id:(p==null?void 0:p.proxy_id)??(b==null?void 0:b.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(qA,{onChange:d,actionAccountSchemaId:i,value:s.account_id,linkApp:l})),h.jsx("div",{className:"workflow-action-node-config",children:h.jsx(xG,{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&&Mt.isEqual(Mt.omit(t.data,["isHovered"]),Mt.omit(e.data,["isHovered"])));var Ln=(t=>(t.IDLE="idle",t.SAVING="saving",t.SAVED="saved",t.ERROR="error",t))(Ln||{}),jd=(t=>(t.SELECTION="selection",t.ALL="all",t))(jd||{}),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||{}),rt=(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))(rt||{});const nO=[{operator:rt.eq,label:G("common.eq")},{operator:rt.ne,label:G("common.ne")},{operator:rt.sw,label:G("common.sw")},{operator:rt.nsw,label:G("common.nsw")},{operator:rt.ew,label:G("common.ew")},{operator:rt.ewn,label:G("common.ewn")},{operator:rt.gt,label:G("common.gt")},{operator:rt.ge,label:G("common.ge")},{operator:rt.lt,label:G("common.lt")},{operator:rt.le,label:G("common.le")},{operator:rt.co,label:G("common.co")},{operator:rt.nco,label:G("common.nco")},{operator:rt.in,label:G("common.in")},{operator:rt.nin,label:G("common.nin")},{operator:rt.is_null,label:G("common.is_null")},{operator:rt.is_not_null,label:G("common.is_not_null")}];rt.eq+"",G("common.eq"),rt.ne+"",G("common.ne"),rt.sw+"",G("common.sw"),rt.nsw+"",G("common.nsw"),rt.ew+"",G("common.ew"),rt.ewn+"",G("common.ewn"),rt.gt+"",G("common.gt"),rt.lt+"",G("common.lt"),rt.ge+"",G("common.ge"),rt.co+"",G("common.co"),rt.nco+"",G("common.nco"),rt.le+"",G("common.le"),rt.in+"",G("common.in"),rt.nin+"",G("common.nin"),rt.is_null+"",G("common.is_null"),rt.is_not_null+"",G("common.is_not_null");const nw=t=>t===rt.is_null||t===rt.is_not_null,_G=(t,e="")=>nw(t)?"":e,{Option:AG}=_.Select,OG=y.forwardRef((t,e)=>{const{config_schema:n}=t,[r]=_.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(()=>(_.message.warning(G("link.flow.missing_configuration")),!1)).finally(()=>l(!1)));y.useImperativeHandle(e,()=>({saveConfig:d=>c(d)}));const u=At();return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:o,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsx(_.Form,{disabled:!u,form:r,initialValues:s,layout:"vertical",autoComplete:"off",children:h.jsx(_.Form.List,{name:"or_list",children:(d,{add:f,remove:p})=>h.jsxs(h.Fragment,{children:[d.map((m,b)=>h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"form-block",children:h.jsxs("div",{style:{padding:12,width:"100%",boxSizing:"border-box"},children:[b>0&&u&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsx(_.Button,{type:"link",style:{color:"red"},icon:h.jsx(ie.MinusCircleOutlined,{style:{color:"red"}}),onClick:()=>p(m.name),children:h.jsx(Te.FormattedMessage,{id:"link.flow.remove"})})}),h.jsx(_.Form.List,{name:[m.name,"and_list"],children:(v,{add:w,remove:g})=>h.jsx(h.Fragment,{children:v.map((C,S)=>h.jsxs(_.Space,{direction:"vertical",style:{width:"100%",rowGap:0},children:[h.jsxs(_.Space,{align:"center",className:`form-item-row ${S>0?"opt":""}`,children:[h.jsx(_.Form.Item,{style:{minWidth:150},name:[C.name,"query"],label:G("app.common.word.variable-name"),rules:[{required:!0,message:G("link.flow.please_enter_variable_name")}],children:h.jsx(In,{nodeId:t.nodeId,placeholder:G("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),h.jsx(_.Form.Item,{name:[C.name,"operator"],label:G("app.common.word.condition"),rules:[{required:!0,message:G("link.flow.please_select_condition")}],children:h.jsx(_.Select,{style:{minWidth:140},placeholder:G("link.flow.select_condition"),getPopupContainer:k=>k.parentNode,children:nO.map(k=>h.jsx(AG,{value:k.operator,children:k.label},k.operator))})}),h.jsx(_.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const k=r.getFieldValue(["or_list",m.name,"and_list",C.name,"operator"]);return nw(k)?null:h.jsx(_.Form.Item,{style:{minWidth:150},name:[C.name,"value"],label:G("app.common.word.value"),rules:[],children:h.jsx(In,{nodeId:t.nodeId,placeholder:G("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),S>0&&h.jsx(_.Button,{type:"link",icon:h.jsx(ie.MinusCircleOutlined,{}),onClick:()=>g(C.name)})]}),S<v.length-1&&h.jsx(_.Divider,{plain:!0,children:h.jsx(_.Tag,{color:"#999999",children:h.jsx(Te.FormattedMessage,{id:"link.flow.and"})})}),S===v.length-1&&h.jsx(_.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),b<d.length-1&&h.jsxs("div",{className:"test",style:{textAlign:"center"},children:[" ",h.jsx(_.Divider,{style:{color:"orange"},dashed:!0,children:h.jsx(_.Tag,{color:"#1890ff",children:h.jsx(Te.FormattedMessage,{id:"link.flow.or"})})})]})]})),h.jsx(_.Form.Item,{style:{display:"flex",justifyContent:"flex-end",marginBlock:10},children:h.jsx(_.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(_.Button,{type:"primary",disabled:!u,loading:a,className:"workflow-node-form-save",onClick:()=>c(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),TG={copy:"Copy JSON",copySuccess:"JSON copied to clipboard",download:"Download JSON",invalidJson:"Invalid JSON data"},NG={copy:"复制JSON",copySuccess:"JSON已复制到剪贴板",download:"下载JSON",invalidJson:"无效的JSON数据"},{Text:BG}=_.Typography,FG=({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"?NG:TG,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=[],S=0)=>{const k=[];if(g===null)return[{key:C.join("."),value:null,type:"null",path:C,level:S}];if(Array.isArray(g)){const x={key:C.join("."),value:g,type:"array",path:C,level:S,children:[]};g.forEach((D,E)=>{var T;const O=[...C,E.toString()],A=w(D,O,S+1);(T=x.children)==null||T.push(...A)}),k.push(x)}else if(typeof g=="object"){const x={key:C.join("."),value:g,type:"object",path:C,level:S,children:[]};Object.entries(g).forEach(([D,E])=>{var T;const O=[...C,D],A=w(E,O,S+1);(T=x.children)==null||T.push(...A)}),k.push(x)}else{const x=typeof g;k.push({key:C.join("."),value:g,type:x,path:C,level:S})}return k};return w(d)},[d]),p=y.useCallback(()=>{const w=JSON.stringify(d,null,2);navigator.clipboard.writeText(w).then(()=>{_.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),S=document.createElement("a");S.href=C,S.download="data.json",S.click(),URL.revokeObjectURL(C)},[d]),b=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}},[]),v=y.useCallback((w,g)=>{var k;const C=w.children&&w.children.length>0,S=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:[S&&h.jsxs("span",{className:"json-key",children:['"',S,'": ']}),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:[(k=w.children)==null?void 0:k.map((x,D)=>v(x,g+D+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:[S&&h.jsxs("span",{className:"json-key",children:['"',S,'": ']}),b(w)]})},w.key)},[b]);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(_.Space,{children:[n&&h.jsx(_.Tooltip,{title:u.copy,children:h.jsx(_.Button,{icon:h.jsx(ie.CopyOutlined,{}),size:"small",onClick:p})}),h.jsx(_.Tooltip,{title:u.download,children:h.jsx(_.Button,{icon:h.jsx(ie.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)=>v(w,g))})]}):h.jsx("div",{className:`json-renderer error ${a} ${o}`,children:h.jsx("div",{className:"error-message",children:h.jsx(BG,{type:"secondary",children:u.invalidJson})})})},{TextArea:MG}=_.Input,{Title:IG}=_.Typography,rO=({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:b,onClose:v,onExpandPanel:w})=>{const g=t==="running",C=t==="failure",S=t==="ignored",k=t==="success"||S,x=t==="disabled",[D,E]=y.useState(!1);return h.jsxs("section",{className:["node-test-container","ai-flow-node-test-panel",b].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(IG,{level:4,children:"节点测试"}),h.jsx(_.Button,{ghost:!0,className:"close-btn",onClick:v,children:h.jsx(xi,{size:16})})]})}),h.jsxs("div",{className:"test-content",children:[i&&!x?h.jsxs("div",{className:"action-buttons",children:[h.jsx(_.Button,{type:"primary",disabled:x,onClick:u,loading:g&&r==="run",className:"test-button",children:g?"测试中...":"开始测试"}),h.jsx(_.Button,{type:"default",disabled:x||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(_.Button,{onClick:f,className:"reset-button",children:"重置"})}):null,g?h.jsxs(h.Fragment,{children:[h.jsx(_.Progress,{percent:n,status:"active",className:"test-progress"}),h.jsx(_.Skeleton,{active:!0,className:"result-skeleton"})]}):h.jsxs(h.Fragment,{children:[C&&o?h.jsx(_.Alert,{className:"error-alert small",showIcon:!0,message:"测试未通过",description:"请检查节点配置和接口返回后重试",type:"error",closable:!1,onClose:m}):null,k&&o?h.jsx(_.Alert,{className:"success-alert small",showIcon:!0,message:S?"忽略调试成功":"测试成功",description:S?"已将样本数据设为当前节点输出":"节点运行正常,可在下方查看返回结果",type:"success",closable:!1,onClose:m}):null,e?h.jsx(_.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(ie.CloseCircleFilled,{className:"error-icon"})," 错误数据"]}):h.jsxs(h.Fragment,{children:[S?h.jsx(ie.ExperimentFilled,{className:"success-icon"}):h.jsx(ie.CheckCircleFilled,{className:"success-icon"}),S?"样本数据":"测试结果"]})}),h.jsxs("div",{style:{display:"inline-flex",gap:8},children:[i&&p?h.jsx(_.Button,{size:"small",type:"default",variant:"solid",onClick:p,className:"edit-button",children:a?"完成":"编辑"}):null,w&&h.jsx(_.Button,{size:"small",type:D?"primary":"default",variant:"solid",className:"edit-button",onClick:()=>{const O=!D;w(O),E(O)},children:D?h.jsx(gW,{size:16}):h.jsx(mW,{size:16})})]})]}),variant:"borderless",className:`result-card ${C?"error-result":"success-result"}`,children:a?h.jsx(MG,{rows:D?20:10,value:l,onChange:O=>c==null?void 0:c(O.target.value),className:"result-editor"}):h.jsx(FG,{data:e,height:D?600:300,enableCopy:!0,theme:"dark"},e)}):h.jsx(_.Card,{variant:"borderless",className:"empty-result",children:h.jsx(_.Result,{icon:h.jsx("span",{className:"common-icon"}),title:x?"不可测试":"等待测试",subTitle:x?s:"点击“开始测试”按钮运行当前节点"})})]})]})]})},PG=new Set([$e.AI_LANGUAGE_MODEL,$e.AI_MEMORY,$e.BUILTIN_MCP,$e.MCP_SERVER]),LG=new Set([]),$G=({canEdit:t,nodeType:e,protocol:n})=>t?n&&PG.has(n)?{disabled:!0,reason:"当前协议节点由所属 AI 或 MCP 运行上下文统一测试"}:e&&LG.has(e)?{disabled:!0,reason:"当前节点类型不支持独立手动测试"}:{disabled:!1}:{disabled:!0,reason:"只读或预览模式下不能执行节点测试"},zG=t=>typeof t=="string"?t.trim().length>0:t!=null,HG=t=>typeof t=="string"&&t.trim().toLowerCase()==="success",VG=t=>{if(!t||typeof t!="object")return!1;const e=t;return e.result===!0?!1:e.result===!1?!0:e.error==="0"&&zG(e.error_description)&&!HG(e.error_description)},jG=t=>VG(t)?me.FAILED:me.SUCCESS,WG=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 UG=y.forwardRef((t,e)=>{var O,A,T,B;const{nodeId:n,beforeHook:r,onClose:o,onExpandPanel:i}=t,s=Pt(),{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=St.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 M=typeof d.data.output=="string"?d.data.output:JSON.stringify(d.data.output,null,2);u(M),f.successShown=!0,f.isError=!1,f.showErrorAlert=!1}else if(d!=null&&d.data.output&&d.data.status===me.FAILED){const M=typeof d.data.output=="string"?d.data.output:JSON.stringify(d.data.output,null,2);u(M),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(M=>{const F=M,N=jG(F),P=N===me.FAILED;f.isError=P,f.successShown=!P,f.showErrorAlert=f.isError;let I="";try{I=WG(F)}catch(z){console.error("格式化测试结果出错:",z),I=`测试结果格式化失败: ${String(z)}`}f.testProgress=100,u(I),a({id:n,data:{status:N,output:I,outputSource:"test"}})}).catch(M=>{var P;console.error("测试失败:",M),f.testProgress=0,f.isError=!0,f.showErrorAlert=!0,f.successShown=!1;let F="测试执行失败";(P=M==null?void 0:M.response)!=null&&P.data?F=JSON.stringify(M.response.data,null,2):M!=null&&M.message&&(F=M.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]),b=()=>{f.testProgress=0,f.testing=!1,f.sampleSaving=!1,f.sampleMode=!1,f.successShown=!0,f.isError=!1,f.showErrorAlert=!1},v=()=>{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:b,abortSampleTest:w,finishNodeTest:g}));const C=()=>{f.sampleMode=!1,r?r(!0):m()},S=()=>{u(""),f.sampleText="",f.sampleMode=!1,f.sampleError="",f.successShown=!1},k=At(),x=y.useMemo(()=>{var M;return $G({canEdit:k,nodeType:d==null?void 0:d.type,protocol:(M=d==null?void 0:d.data)==null?void 0:M.protocol})},[k,(B=d==null?void 0:d.data)==null?void 0:B.protocol,d==null?void 0:d.type]),D=x.disabled?"disabled":f.testing?"running":f.isError?"failure":f.successShown?f.isIgnoreSuccess?"ignored":"success":"waiting",E=()=>{if(f.editable){f.editable=!1;try{const M=JSON.parse(f.sampleText),F=JSON.stringify(M,null,2);u(F),a({id:n,data:{output:F}})}catch{u(f.sampleText)}return}f.sampleText=c,f.editable=!0};return h.jsx(rO,{status:D,result:c,progress:f.testProgress||60,runningAction:f.ignoring?"ignore":"run",showAlert:f.isError?f.showErrorAlert:f.successShown,canEdit:k,disabledReason:x.reason,editing:f.editable,editableValue:f.sampleText,onEditableValueChange:M=>{f.sampleText=M},onRun:C,onIgnore:v,onReset:S,onToggleEdit:E,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 rw={ARRAY:"purple",BOOLEAN:"green",NULL:"default",NUMBER:"blue",OBJECT:"cyan",STRING:"orange"},qG={ARRAY:"Arr",BOOLEAN:"Bool",NULL:"Null",NUMBER:"Num",OBJECT:"Obj",STRING:"Str"},ow=(t,e=!1)=>{const n=String(t||"STRING").toUpperCase(),r=qG[n]||n.slice(0,4);return e?`${r}[]`:r},oO=t=>{t!=null&&t.length&&t.forEach(e=>{e.label||(e.label=e.name),Array.isArray(e.sub_params)?oO(e.sub_params):e.sub_params=[]})},GG=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=Mt.cloneDeep(e);return oO(n),n};var iO=(t=>(t.TEXT="TEXT",t.NUMBER="NUMBER",t.JSON="JSON",t))(iO||{});const RG=t=>({TEXT:"STRING",NUMBER:"NUMBER",JSON:"OBJECT"})[t]||"STRING",KG=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,b]=y.useState(0),[v,w]=y.useState(!1),[g,C]=y.useState(null),[S,k]=y.useState(0),x=y.useCallback(()=>{b(T=>T+1)},[]),D=y.useCallback(()=>{k(T=>T+1)},[]),E=y.useCallback(()=>{b(T=>T+1),k(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 M=await Py();if(T)return;const F=((M==null?void 0:M.items)||[]).map(N=>({...N,mappedType:RG(N.var_type)}));a(N=>Mt.isEqual(N,F)?N:F)}catch(M){console.error("Failed to fetch global variables:",M),T||p(M instanceof Error?M: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:M,nodes:F}=i.getState(),N=await Iy(n,{nodeId:e,edges:M});if(T)return;const P=new Map(F.map(H=>[H.id,H])),z=(GG(N)||[]).map(H=>{var $,U;const J=($=H.node_id)!=null&&$.startsWith("N")?H.node_id.slice(1):H.node_id,K=J?P.get(J):void 0,ee=typeof((U=K==null?void 0:K.data)==null?void 0:U.icon)=="string"?K.data.icon:void 0;return{...H,nodeIcon:ee,isValid:!!K}});c(H=>Mt.isEqual(H,z)?H:z)}catch(M){console.error("Failed to fetch node variables:",M),T||C(M instanceof Error?M:new Error("无法获取节点变量数据"))}finally{T||w(!1)}})(),()=>{T=!0}},[n,e,r,S,i]),{globalVariables:s,nodeVariables:l,isLoading:u||v,isGlobalLoading:u,isNodeLoading:v,error:f||g,globalError:f,nodeError:g,refresh:E,refreshGlobal:x,refreshNode:D}},st={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"},iw={VariableModalTitle:h.jsx(Te.FormattedMessage,{id:"app.common.word.select-variable"}),NoTestDataDesc:h.jsx(Te.FormattedMessage,{id:"common.no-process-variables-yet"})},YG=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)},XG=(t,e)=>{const n=t.trim(),r=n.startsWith("N")?n:`N${n}`,o=e.slice(1).join(".");return o?`{{${r}.${o}}}`:`{{${r}}}`},sO=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}=KG({nodeId:r,flowId:n,enabled:t.open,includeGlobalVariables:o}),m=St.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 b=w=>{try{const g=typeof w=="string"?JSON.parse(w):w,C=(k,x)=>{if(k==null)return{name:x,type:tr.Null,label:x,multi_valued:!1,sub_params:[],value:String(k)};if(typeof k=="object"&&!Array.isArray(k)){const E=k;return{name:x,type:tr.Object,label:x,multi_valued:!1,sub_params:Object.keys(E).map(O=>C(E[O],O)),value:null}}if(Array.isArray(k)){const E=k[0],O=E&&typeof E=="object"?tr.Object:typeof E=="number"?tr.Number:typeof E=="boolean"?tr.Boolean:E==null?tr.Array:tr.String;return{name:x,type:O,label:x,multi_valued:!0,sub_params:[],value:JSON.stringify(k)}}const D=typeof k=="number"?tr.Number:typeof k=="boolean"?tr.Boolean:tr.String;return{name:x,type:D,label:x,multi_valued:!1,sub_params:[],value:String(k)}},S=g&&typeof g=="object"&&!Array.isArray(g)?g:{};return Object.keys(S).map(k=>C(S[k],k))}catch{return[]}},v=(w,g,C,S,k,x=[],D="0")=>(w??[]).map((E,O)=>{var M;const A=[...x,E.name],T=`${D}-${O}`;return(M=E.sub_params)!=null&&M.length?{key:T,variablePath:A,title:h.jsxs("span",{className:`${st.nodeTitle}${S===!1?` ${st.invalidVariable}`:""}`,children:[g?k==="api"?h.jsx(ie.ApiOutlined,{className:st.nodeIcon}):h.jsx("span",{className:st.nodeIconWrapper,children:C?h.jsx("img",{src:C,alt:""}):h.jsx("span",{className:st.defaultNodeIcon,children:"N"})}):h.jsx(_.Tag,{color:rw[E.type]||"gray",className:`${st.typeTag} workflow-variable-panel__type`,children:ow(E.type,E.multi_valued)}),h.jsx("span",{className:`${g?st.nodeLabelFirst:st.nodeLabel} workflow-variable-panel__label`,children:E.label})]}),children:v(E.sub_params,!1,C,S,k,A,T)}:{key:T,variablePath:A,title:h.jsxs("span",{className:`${st.leafTitle}${S===!1?` ${st.invalidVariable}`:""}`,children:[h.jsx(_.Tag,{color:rw[E.type]||"gray",className:`${st.typeTag} workflow-variable-panel__type`,children:ow(E.type,E.multi_valued)}),h.jsx("span",{className:`${st.leafLabel} workflow-variable-panel__label`,children:E.label}),E.value?h.jsx("span",{className:st.leafValue,children:E.value}):null]})}});return h.jsxs("div",{className:`${st.container} workflow-variable-panel`,children:[h.jsxs("div",{className:`${st.header} workflow-variable-panel__header`,children:[h.jsx(pW,{size:16,className:`${st.headerIcon} workflow-variable-panel__header-icon`}),h.jsx("span",{className:`${st.headerTitle} workflow-variable-panel__title`,children:iw.VariableModalTitle})]}),h.jsxs("div",{className:`${st.body} workflow-variable-panel__body`,children:[o?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:`${st.sectionLabel} workflow-variable-panel__section-label`,children:[h.jsx(ie.GlobalOutlined,{className:st.sectionIcon,size:32}),h.jsx("span",{children:"全局变量"})]}),h.jsx("div",{className:"variable-panel-group",children:h.jsxs("div",{className:st.section,children:[s.map(w=>{if(w.var_type===iO.JSON){const S=b(w.var_value??{}),k=[{name:w.name,type:tr.Object,label:w.display_name||w.name,multi_valued:!1,sub_params:S,value:null}],x=v(k,!0,void 0,!0,"api");return h.jsx(_.Tree,{defaultExpandAll:!0,showLine:!0,onSelect:(D,E)=>{const O=E.node.variablePath;i.emit({type:"insert",currentInputId:m.currentInputId,expression:`{{global.${O.join(".")}}}`})},switcherIcon:h.jsx(ie.CaretDownOutlined,{}),treeData:x},w.id)}const g=YG(w.var_value),C=g.length>28?`${g.substring(0,28)}...`:g;return h.jsxs("button",{type:"button",className:`${st.varItem} workflow-variable-panel__item`,onClick:()=>{i.emit({type:"insert",currentInputId:m.currentInputId,expression:`{{global.${w.name}}}`})},children:[h.jsx(_.Tag,{color:rw[w.mappedType],className:`${st.typeTag} workflow-variable-panel__type`,children:ow(w.mappedType)}),h.jsx("span",{className:`${st.varName} workflow-variable-panel__label`,children:w.display_name||w.name}),C?h.jsx("span",{className:st.varValue,children:C}):null]},w.id)}),!l&&!u&&s.length<1&&h.jsx(_.Empty,{image:_.Empty.PRESENTED_IMAGE_SIMPLE,description:iw.NoTestDataDesc,className:st.empty}),l?h.jsxs("div",{className:st.loadingState,children:[h.jsx(_.Spin,{size:"small"}),h.jsx("span",{children:"正在加载全局变量"})]}):u?h.jsx(_.Alert,{className:st.errorState,type:"error",showIcon:!0,message:"全局变量加载失败",description:u.message,action:h.jsx(_.Button,{size:"small",onClick:f,children:"重试"})}):null]})})]}):null,h.jsxs("div",{className:`${st.sectionLabel} workflow-variable-panel__section-label`,children:[h.jsx(ie.ApiOutlined,{className:st.sectionIcon}),h.jsx("span",{children:"节点变量"})]}),h.jsx("div",{className:"variable-panel-group",children:h.jsxs("div",{className:st.section,children:[a.map(w=>h.jsx("div",{children:h.jsx(_.Tree,{defaultExpandAll:!0,showLine:!0,onSelect:(g,C)=>{const S=C.node.variablePath;if(S.length<=1)return!1;i.emit({type:"insert",currentInputId:m.currentInputId,expression:XG(w.node_id,S)})},switcherIcon:h.jsx(ie.CaretDownOutlined,{}),treeData:v(w.sub_params,!0,w.nodeIcon,w.isValid,"node")})},`${w.node_id}-${w.seq}`)),!c&&!d&&a.length<1&&h.jsx(_.Empty,{image:_.Empty.PRESENTED_IMAGE_SIMPLE,description:iw.NoTestDataDesc,className:st.empty}),c?h.jsxs("div",{className:st.loadingState,children:[h.jsx(_.Spin,{size:"small"}),h.jsx("span",{children:"正在加载节点变量"})]}):d?h.jsx(_.Alert,{className:st.errorState,type:"error",showIcon:!0,message:"节点变量加载失败",description:d.message,action:h.jsx(_.Button,{size:"small",onClick:p,children:"重试"})}):null]})})]})]})}),{Option:Po}=_.Select,JG=y.forwardRef(({onSubmit:t,config_schema:e,nodeId:n},r)=>{const[o]=_.Form.useForm(),i=xl(),s=_.Form.useWatch("type",o);St.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?_.message.warning(G("link.flow.loop_start_end_check")):t({properties:m},d)).catch(()=>(_.message.warning(G("link.flow.missing_configuration")),!1)).finally(()=>l(!1)));y.useImperativeHandle(r,()=>({saveConfig:d=>c(d)}));const u=At();return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:i,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsxs(_.Form,{disabled:!u,form:o,layout:"vertical",children:[h.jsxs(_.Row,{children:[h.jsx(_.Col,{sm:24,lg:12,children:h.jsx(_.Form.Item,{name:"type",label:G("app.common.word.loop-data-type"),rules:[{required:!0,message:G("link.flow.please_select_data_type")}],children:h.jsxs(_.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(_.Col,{sm:24,lg:12,children:h.jsxs(_.Form.Item,{required:!0,label:G("link.flow.loop_start_end"),style:{display:"flex"},children:[h.jsx(_.Form.Item,{name:"start",noStyle:!0,rules:[{required:!0,message:G("link.flow.please_select_data_type")}],children:h.jsx(_.InputNumber,{min:1,style:{marginRight:20}})}),h.jsx(_.Form.Item,{name:"end",noStyle:!0,rules:[{required:!0,message:G("link.flow.please_select_data_type")}],children:h.jsx(_.InputNumber,{min:1})})]})}),s&&s!=="NUMBER"&&h.jsx(_.Col,{sm:24,lg:12,children:h.jsx(_.Form.Item,{rules:[{required:!0,message:G("link.flow.please_enter_loop_expression")}],label:G("link.flow.loop_expression"),name:"expression",children:h.jsx(In,{nodeId:n,borrow:!0,valueType:"JS_EXP",placeholder:G("link.flow.please_enter_loop_expression")})})}),!s&&h.jsx(_.Col,{})]}),h.jsxs(_.Row,{children:[h.jsx(_.Col,{sm:24,lg:12,children:h.jsx(_.Form.Item,{name:"asc",label:G("app.common.word.circulation-direction"),rules:[{required:!0,message:G("link.flow.please_select_loop_direction")}],children:h.jsxs(_.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(_.Col,{sm:24,lg:12,children:h.jsx(_.Form.Item,{name:"errorExec",label:G("link.flow.loop_processing"),rules:[{required:!0,message:G("link.flow.please_select_loop_processing")}],children:h.jsxs(_.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(_.Button,{type:"primary",disabled:!u,loading:a,className:"workflow-node-form-save",onClick:()=>c(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),Wd=()=>`branch_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,{Option:QG}=_.Select,ZG=y.forwardRef((t,e)=>{const{config_schema:n,nodeId:r}=t,[o]=_.Form.useForm(),i=xl(),{handleNodeDataUpdate:s}=Ri(),[a,l]=y.useState(null),[c,u]=y.useState(""),f=(D=>!(D!=null&&D.branches)||D.branches.length===0?{branches:[{id:Wd(),name:G("link.flow.switch.condition_one"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]},{id:Wd(),name:G("link.flow.switch.condition_two"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]}]}:{branches:D.branches.map((O,A)=>{var T;return{id:O.id||Wd(),name:O.name||G("link.flow.switch.condition_n",{n:A+1}),or_list:((T=O.or_list)==null?void 0:T.map(B=>{var M;return{and_list:((M=B.and_list)==null?void 0:M.map(F=>({query:F.query||"",operator:F.operator||"",value:F.value||""})))||[{query:"",operator:"",value:""}]}}))||[{and_list:[{query:"",operator:"",value:""}]}]}})})(n),p=()=>{const D=o.getFieldValue("branches")||[];s({id:r,data:{config_schema:{branches:D}}})},m=(D,E)=>{l(D),u(E)},b=()=>{l(null),u("")},v=D=>{const E=Mt.cloneDeep(o.getFieldValue("branches"))||[],O=c.trim();if(!O){_.message.error(G("link.flow.switch.branch_name_cannot_be_empty"));return}if(E.some((T,B)=>B!==D&&T.name===O)){_.message.error(G("link.flow.switch.branch_name_duplicate"));return}E[D].name=O,o.setFieldValue("branches",E),l(null),u(""),p()},w=(D,E)=>{const O=o.getFieldValue("branches")||[];if(E<0||E>=O.length)return;const A=[...O],[T]=A.splice(D,1);A.splice(E,0,T),o.setFieldValue("branches",A),p()},[g,C]=y.useState(!1),S=D=>(C(!0),o.validateFields().then(async E=>{if(!E.branches.some(T=>T.or_list.some(B=>B.and_list.some(M=>M.query&&M.operator)))){_.message.error(G("link.flow.switch.at_least_one_valid_branch"));return}const A=Mt.cloneDeep(E);return A.branches.forEach(T=>{T.or_list.forEach(B=>{B.and_list.forEach(M=>{M.value=_G(M.operator,M.value)})})}),t.onSubmit({properties:A},D)}).catch(()=>(_.message.warning(G("link.flow.missing_configuration")),!1)).finally(()=>C(!1)));y.useImperativeHandle(e,()=>({saveConfig:D=>S(D)}));const k=At(),x=(D,E,O,A)=>{const B=(o.getFieldValue("branches")||[])[E],M=a===E;return h.jsxs(_.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:M?h.jsxs(_.Space,{children:[h.jsx(_.Input,{value:c,onChange:F=>u(F.target.value),style:{width:200},placeholder:G("link.flow.switch.enter_branch_name"),onPressEnter:()=>v(E)}),h.jsx(_.Button,{type:"text",size:"small",icon:h.jsx(ie.CheckOutlined,{style:{color:"#52c41a"}}),onClick:()=>v(E)}),h.jsx(_.Button,{type:"text",size:"small",icon:h.jsx(ie.CloseOutlined,{}),onClick:b})]}):h.jsxs(_.Space,{children:[h.jsx("span",{style:{fontSize:13,fontWeight:400},children:(B==null?void 0:B.name)||G("link.flow.switch.condition_n",{n:E+1})}),k&&h.jsx(_.Button,{type:"text",size:"small",icon:h.jsx(ie.EditOutlined,{}),onClick:()=>m(E,(B==null?void 0:B.name)||"")})]})}),k&&h.jsxs(_.Space,{className:"actions",children:[h.jsx(_.Tooltip,{title:G("link.flow.switch.move_to_top"),children:h.jsx(_.Button,{type:"text",size:"small",disabled:E===0,onClick:()=>w(E,0),children:"置顶"})}),h.jsx(_.Tooltip,{title:G("link.flow.switch.move_up"),children:h.jsx(_.Button,{type:"text",size:"small",icon:h.jsx(ie.ArrowUpOutlined,{}),disabled:E===0,onClick:()=>w(E,E-1)})}),h.jsx(_.Tooltip,{title:G("link.flow.switch.move_down"),children:h.jsx(_.Button,{type:"text",size:"small",icon:h.jsx(ie.ArrowDownOutlined,{}),disabled:E===O-1,onClick:()=>w(E,E+1)})}),h.jsx(_.Tooltip,{title:G("link.flow.switch.move_to_bottom"),children:h.jsx(_.Button,{type:"text",size:"small",disabled:E===O-1,onClick:()=>w(E,O-1),children:"置底"})}),h.jsx(_.Tooltip,{title:G("common.delete"),children:h.jsx(_.Button,{type:"text",size:"small",disabled:O<=1,onClick:()=>{if(O<=1){_.message.warning(G("link.flow.switch.at_least_one_branch"));return}A(D.name),setTimeout(()=>{p()},0)},children:"删除"})})]})]}),h.jsx(_.Form.Item,{name:[D.name,"name"],hidden:!0,children:h.jsx(_.Input,{})}),h.jsx(_.Form.List,{name:[D.name,"or_list"],children:(F,{add:N,remove:P})=>h.jsx(h.Fragment,{children:F.map((I,z)=>{const H=z===F.length-1;return h.jsx(h.Fragment,{children:h.jsxs("div",{className:"switch-rule",children:[F.length>1&&k&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsxs(_.Button,{type:"link",icon:h.jsx(ie.MinusCircleOutlined,{}),onClick:()=>P(I.name),children:[h.jsx(Te.FormattedMessage,{id:"link.flow.remove"})," OR"]})}),h.jsx(_.Form.List,{name:[I.name,"and_list"],children:(J,{add:K,remove:ee})=>h.jsx(h.Fragment,{children:J.map(($,U)=>{const R=U===J.length-1;return h.jsxs(_.Space,{direction:"vertical",style:{width:"100%"},children:[h.jsxs(_.Space,{align:"center",className:"switch-rule-item",children:[h.jsx(_.Form.Item,{style:{minWidth:150,marginBottom:0},name:[$.name,"query"],label:G("app.common.word.variable-name"),rules:[{required:!0,message:G("link.flow.please_enter_variable_name")}],children:h.jsx(In,{nodeId:t.nodeId,placeholder:G("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),h.jsx(_.Form.Item,{style:{marginBottom:0},name:[$.name,"operator"],label:G("app.common.word.condition"),rules:[{required:!0,message:G("link.flow.please_select_condition")}],children:h.jsx(_.Select,{style:{minWidth:140},placeholder:G("link.flow.select_condition"),getPopupContainer:()=>document.body,children:nO.map(te=>h.jsx(QG,{value:te.operator,children:te.label},te.operator))})}),h.jsx(_.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const te=o.getFieldValue(["branches",D.name,"or_list",I.name,"and_list",$.name,"operator"]);return nw(te)?null:h.jsx(_.Form.Item,{style:{minWidth:150,marginBottom:0},name:[$.name,"value"],label:G("app.common.word.value"),rules:[],children:h.jsx(In,{nodeId:t.nodeId,placeholder:G("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),U===0&&h.jsx("div",{style:{width:30}}),U>0&&k&&h.jsx(_.Button,{type:"link",icon:h.jsx(ie.MinusCircleOutlined,{}),onClick:()=>ee($.name)})]}),U<J.length-1&&h.jsx(_.Divider,{plain:!0,style:{margin:"8px 0"},children:h.jsx(_.Tag,{color:"#999999",children:h.jsx(Te.FormattedMessage,{id:"link.flow.and"})})}),h.jsxs("div",{className:`rule-opt-actions ${R?"last-and-rule":""}`,children:[U===J.length-1&&h.jsx(_.Button,{type:"link",disabled:!k,icon:h.jsx(br,{size:14}),onClick:()=>K({query:"",operator:"",value:""}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-new-and"})}),H&&h.jsx(_.Button,{type:"link",icon:h.jsx(br,{size:14}),disabled:!k,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(_.Divider,{style:{color:"orange"},dashed:!0,children:h.jsx(_.Tag,{color:"#1890ff",children:h.jsx(Te.FormattedMessage,{id:"link.flow.or"})})})})]},I.key)})})})})]},D.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(_.Form,{disabled:!k,form:o,initialValues:f,layout:"vertical",autoComplete:"off",children:h.jsx(_.Form.List,{name:"branches",children:(D,{add:E,remove:O})=>h.jsxs(h.Fragment,{children:[D.map((A,T)=>x(A,T,D.length,O)),D.length<10&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end",width:"100%"},children:h.jsx(_.Button,{type:"default",icon:h.jsx(br,{size:14}),disabled:!k,onClick:()=>{const A=D.length+1;E({id:Wd(),name:G("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"})})}),D.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:k&&h.jsx(_.Button,{type:"primary",disabled:!k,loading:g,className:"workflow-node-form-save",onClick:()=>S(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),eR=({nodeId:t,onSubmit:e,data:n})=>{const[r]=_.Form.useForm(),o=xl(),i=At(),{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{_.message.error(G("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:G("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:G("app.common.word.retry-count"),tooltip:G("app.common.word.retry-count-tooltip"),width:"xl",fieldProps:{min:1,max:10,precision:0,style:{width:"100%"}},rules:[{required:u,message:G("app.common.word.please-enter-retry-count")}]}),h.jsx(jn.ProFormDigit,{name:"retryInterval",label:G("app.common.word.retry-interval"),tooltip:G("app.common.word.retry-interval-tooltip"),fieldProps:{min:1,max:60,precision:0,style:{width:"100%"},addonAfter:"s"},rules:[{required:u,message:G("app.common.word.please-enter-retry-interval")}]}),h.jsx(jn.ProFormDigit,{name:"stepFactor",label:G("app.common.word.step-factor"),tooltip:G("app.common.word.step-factor-tooltip"),width:"xl",fieldProps:{min:1,max:5,precision:1,style:{width:"100%"}},rules:[{required:u,message:G("app.common.word.please-enter-step-factor")}]}),h.jsx(jn.ProFormDigit,{name:"maxRetryInterval",label:G("app.common.word.max-retry-interval"),tooltip:G("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:G("app.common.word.please-enter-max-retry-interval")}]})]}):null}),h.jsx(jn.ProFormSwitch,{name:"alertEnabled",label:G("app.common.word.enable-alert")}),h.jsx(jn.ProFormDependency,{name:["alertEnabled"],children:({alertEnabled:u})=>u?h.jsx(jn.ProFormText,{name:"webhookUrl",label:G("app.common.word.webhook-url"),placeholder:G("app.common.word.enter-webhook-url"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:u,message:G("app.common.word.enter-webhook-url")}]}):null}),h.jsx(jn.ProFormSelect,{name:"errorHandling",label:G("app.common.word.error-handling"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:!0,message:G("app.common.word.select-error-handling")}],options:[{label:G("app.common.word.interrupt-flow"),value:"interrupt"},{label:G("app.common.word.ignore-error"),value:"ignore"}]}),h.jsx(jn.ProFormSwitch,{name:"applyToAllNodes",label:G("app.common.word.apply-to-all-nodes")})]})}),h.jsx("div",{className:"workflow-node-form-footer",children:h.jsx(_.Button,{type:"primary",disabled:!i,onClick:()=>r.submit(),className:"workflow-node-form-save",children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})},aO="[workflow:schema-render]",tR=()=>{const{event$:t}=y.useContext(Qr),e=Th();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},nR=({children:t})=>{const{event$:e}=y.useContext(Qr),n=Nh(),[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(ax.Provider,{value:s,children:t})},rR=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})]})]})},oR=y.memo(({visible:t,onClose:e,data:n,nodeType:r=pe.ACTION,nodeId:o=""})=>{var B,M;const i=St.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(),b=Pt(),v=((M=(B=b.nodeConfigPanel)==null?void 0:B.testArea)==null?void 0:M.allowManualTest)!==!1,w=St.useReactive({output:"",ignore:!1,expandTestPanel:!1}),g=y.useMemo(()=>b.nodeConfigPanel.showSettings&&![pe.TRIGGER,pe.AI_SUB_NODE].includes(r),[r,b.nodeConfigPanel.showSettings]),C=(n==null?void 0:n.action_id)??(n==null?void 0:n.id),S=C!==null&&typeof C<"u"&&C!==""&&Number.isFinite(Number(C))?C:null,k=po(n),x=n==null?void 0:n.nodeKey,D=(n==null?void 0:n.nodeVersion)??(n==null?void 0:n.action_ver),{handleNodeDataUpdate:E}=Ri();y.useEffect(()=>{var N,P;if(!t)return;const F=S!==null&&Number(S)<=0;x&&F&&!k&&!((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(`${aO} possible nodepackage schema route mismatch`,{nodeId:o,nodeType:r,actionId:S,nodePackageKey:x,nodePackageVersion:D,reason:"keyed node with non-positive action_id and no classic sub_params was rejected by the nodePackage-compatible node check"})},[S,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,k,x,D,o,r,t]);const O=y.useCallback(async(F,N)=>{var I,z,H;const P=b.flowId;try{const J=m.getState().nodes.find(R=>R.id===o),K=k?GP(F):F.properties,ee=k?RP(F):F.account_id??null,$=k?{flow_id:P,properties:K,position:J==null?void 0:J.position,action_id:S,account_id:ee,proxy_id:F.proxy_id,mcp_tool_description:F.mcp_tool_description,action_key:x,action_ver:D}:{flow_id:P,...F,position:J==null?void 0:J.position,action_id:S};console.info(`${aO} save node config`,{nodeId:o,nodeType:r,actionId:S,isNodepackageNode:k,nodePackageKey:x,nodePackageVersion:D,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 U=w.ignore?await My(o,"","","",K,w.output):await rc(o,$);if(U)if(w.ignore)(I=p.current)==null||I.finishSampleTest(),E({id:o,data:{status:me.SUCCESS,output:w.output,outputSource:"sample"}}),_.message.success("已使用样本数据完成调试");else{_.message.success("节点配置已保存");const R={params:void 0,properties:K,account_id:ee,mcp_tool_description:F.mcp_tool_description,action_key:x,action_ver:D,nodeKey:x,nodeVersion:D,isNodePackage:k};E({id:o,data:{config_schema:K,account_id:F.account_id,...R,position:J==null?void 0:J.position,status:U.status}})}N&&!w.ignore&&((z=p.current)==null||z.onTestNode()),w.ignore=!1,w.output=""}catch{w.ignore&&((H=p.current)==null||H.abortSampleTest(),E({id:o,data:{status:me.FAILED}}))}},[S,b.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,E,k,x,D,o,r,w,m]);y.useCallback(F=>{!k||r!==pe.SWITCH||E({id:o,data:{config_schema:F,properties:F}})},[E,k,o,r]);const A=F=>{var N,P,I,z,H;return k?(N=c.current)==null?void 0:N.saveConfig(F):r===pe.LOOP?(P=f.current)==null?void 0:P.saveConfig(F):r===pe.CONDITION?(I=u.current)==null?void 0:I.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 I;if(N){w.ignore=!0,w.output=P||"",await A(F),(I=p.current)==null||I.finishNodeTest();return}if(F)try{_.message.loading("正在保存节点配置...",0),await A(F),_.message.success("节点配置已保存"),_.message.destroy()}catch(z){_.message.destroy(),console.error("节点配置保存失败:",z),_.message.error("节点配置保存失败,无法执行测试")}};return h.jsx(_.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(nC,{children:[h.jsx(tR,{}),h.jsx(nR,{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(sO,{ref:l,nodeId:o,onInsert:()=>{},open:t})})}),h.jsx("div",{className:"middle-section",children:h.jsxs("div",{className:"config-container",children:[h.jsx(rR,{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(_.Tabs,{style:{height:"100%"},items:[{key:"property",label:"参数配置",children:h.jsxs(h.Fragment,{children:[k||![pe.CONDITION,pe.SWITCH,pe.LOOP].includes(r)?h.jsx(DG,{ref:c,nodeId:o,nodeType:r,data:n,onSubmit:O}):null,r===pe.CONDITION&&!k?h.jsx(OG,{ref:u,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null,r===pe.SWITCH&&!k?h.jsx(ZG,{ref:d,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null,r===pe.LOOP&&!k?h.jsx(JG,{ref:f,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null]})},{key:"setting",label:"设置",children:h.jsx(eR,{data:n,nodeId:o,onSubmit:()=>{_.message.success("保存成功")}})}].slice(0,g?2:1)})]})}),h.jsx("div",{className:`right-section ${w.expandTestPanel?"expand":""}`,children:v&&h.jsx("div",{className:"test-section",children:h.jsx(UG,{ref:p,nodeId:o,beforeHook:T,onClose:e,onExpandPanel:F=>{w.expandTestPanel=F}})})})]})})})})]})})})},(t,e)=>Mt.isEqual(Mt.omit(t,["isHovered"]),Mt.omit(e,["isHovered"]))),sw="MCP_TRIGGER",lO="mcp_trigger",cO=200,iR=10;$e.MCP_SERVER;const aw="dip.core.trigger.mcp-server",sR=[aw],aR=(t,e)=>{const n=new Set(e);return t.some(o=>n.has(o.id)&&Dh(o)&&sR.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):[]},lR=[pe.AGENT,pe.BROWSER],lw=()=>{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(b=>b.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(b=>b.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&&ch(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:b}=t.getState(),v=new Set(l);lR.includes(c)&&l.forEach(C=>{s(C,d).forEach(k=>{v.add(k)})}),aR(u,l).forEach(C=>v.add(C));const w=Array.from(v),g=d.filter(C=>v.has(C.source)||v.has(C.target)).map(C=>C.id);if(m){const C=w.map(S=>({type:"remove",id:S}));m(C)}else f(u.filter(C=>!w.includes(C.id)));if(g.length)if(b){const C=g.map(S=>({type:"remove",id:S}));b(C)}else p(d.filter(C=>!g.includes(C.id)))},[t,s]);return{autoSaveNum:e,onNodeMouseEnter:r,onNodeMouseLeave:o,handleNodesChange:i,handleNodesDelete:a}};function cR(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(vW,{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)"}},uO=({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:b=!0,onToggleNodeDisabled:v})=>{const{currentNodeConfigVisibleId:w,setNodeConfigVisible:g}=ao(),{handleNodeDataUpdate:C}=Ri(),{handleNodesDelete:S}=lw(),k=Pt(),x=na(),D=$=>{C({id:t,data:{note:$}})},E=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]),M=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()[$],I=()=>i.map($=>h.jsx(I0,{nodeId:t,id:$.id,position:$.position,type:$.type||un.TARGET,category:$.category,connectionLimit:$.maxConnections,label:$.label,nodeStatus:d,protocol:$.protocol,portSchema:$.portSchema,shape:$.shape,style:$.style},`${t}-${$.id}`)),z=async()=>{var R,te;const $=((R=k.canvas.fixedNodes)==null?void 0:R.triggerIds)||[],U=((te=k.nodeTypes.fixed)==null?void 0:te.triggers)||[];if($.includes(t)||U.includes(e)){_.message.warning("当前触发节点已被配置为不可删除");return}await Rf(t),S([t],e)},H=y.useMemo(()=>{const $=s.length,U=new Map;return s.forEach(R=>{const te=R.position,se=U.has(te)?U.get(te)+1:1;U.set(te,se)}),s.map((R,te)=>h.jsx(I0,{nodeId:t,connectionLimit:R.maxConnections,id:R.id,style:R.style,position:R.position,protocol:R.protocol,portSchema:R.portSchema,type:R.type,label:R.label,shape:R.shape,nodeStatus:d,index:[te,$,U.get(R.position)]},`${t}-${R.id}`))},[t,s,d]),J=()=>h.jsx(tC,{status:d,disabled:B}),K=()=>{switch(d){case me.INVALID:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-warning-icon",children:h.jsx(ie.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(ie.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(ie.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(ie.LoadingOutlined,{style:{color:P()},size:12})});default:return null}},ee=()=>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})}),b&&h.jsx(OP,{title:p==null?void 0:p.connector_name,nodeId:t,note:(p==null?void 0:p.note)||"",statusIcon:K(),onNoteChange:D,description:p.action_name,className:"workflow-node-text"})]});return h.jsxs(y.Fragment,{children:[h.jsxs("div",{style:{width:M,height:c||"auto"},onDoubleClick:T,className:`${u}
|
|
118
118
|
${F("container")}`,children:[h.jsx(cR,{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&&!xh(x)&&O?"block":"none"},children:h.jsx(ZP,{nodeId:t,type:e,isDisabled:B,handleViewConfig:T,onTest:f,onToggleDisabled:v,onDelete:z})}),m?m(p,J()):h.jsx("div",{className:"workflow-node-content",children:ee()}),I(),H]})]}),t===w&&h.jsx(oR,{visible:!0,onClose:E,nodeType:e,data:p,nodeId:t})]})},cw="main",uR=["action_key","actionKey","nodeKey","node_key"],Ud=t=>Array.isArray(t)?t.filter(e=>typeof e=="string"&&!!e.trim()):void 0,uw=t=>({...t,displayName:t.displayName??t.display_name,type:typeof t.type=="string"&&t.type.trim()?t.type.trim():cw,maxConnections:Object.hasOwn(t,"maxConnections")?t.maxConnections:t.max_connections,allowedSourceNodeKeys:Ud(t.allowedSourceNodeKeys??t.allowed_source_node_keys),allowedTargetNodeKeys:Ud(t.allowedTargetNodeKeys??t.allowed_target_node_keys),deniedSourceNodeKeys:Ud(t.deniedSourceNodeKeys??t.denied_source_node_keys),deniedTargetNodeKeys:Ud(t.deniedTargetNodeKeys??t.denied_target_node_keys),position:t.position}),dO=t=>{var e;for(const n of uR){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},$n=(t,e,n,r,o)=>({valid:t,code:e,reason:n,sourcePort:r,targetPort:o}),dw=(t,e,n)=>t?n!=null&&n.allowLegacyMainHandleAliases&&(e==="source"&&t==="output"||e==="target"&&t==="input")?cw:t:null,fO=(t,e,n,r)=>{const o=dw(e,n,r);if(!o)return null;const i=t==null?void 0:t.find(s=>s.name===o);return i?uw(i):null},fw=(t,e)=>!!(e&&(t!=null&&t.includes(e))),hO=(t,e)=>!!(t!=null&&t.length&&!fw(t,e)),pO=(t,e,n,r,o)=>t.filter(i=>r==="source"?i.source===e&&dw(i.sourceHandle,"source",o)===n:i.target===e&&dw(i.targetHandle,"target",o)===n&&i.source!==i.target).length,mO=(t,e)=>{if(t.maxConnections==null||!Number.isFinite(t.maxConnections))return!1;const n=Math.max(0,Math.trunc(t.maxConnections));return e>=n},gO=t=>t||"(未指定)",dR=({sourceNode:t,targetNode:e,sourceHandle:n,targetHandle:r,sourcePorts:o,targetPorts:i,edges:s=[],options:a})=>{if(!t)return $n(!1,"SOURCE_NODE_NOT_FOUND","源节点不存在",null,null);if(!e)return $n(!1,"TARGET_NODE_NOT_FOUND","目标节点不存在",null,null);const l=fO(o,n,"source",a);if(!l)return $n(!1,"SOURCE_PORT_NOT_FOUND",`源节点不存在输出端口 ${gO(n)}`,null,null);const c=fO(i,r,"target",a);if(!c)return $n(!1,"TARGET_PORT_NOT_FOUND",`目标节点不存在输入端口 ${gO(r)}`,l,null);if(l.type!==c.type)return $n(!1,"PORT_TYPE_MISMATCH",`端口类型不匹配:${l.type} 输出不能连接到 ${c.type} 输入`,l,c);const u=dO(t),d=dO(e);if(fw(c.deniedSourceNodeKeys,u))return $n(!1,"SOURCE_NODE_DENIED",`目标输入端口禁止源节点 ${u}`,l,c);if(fw(l.deniedTargetNodeKeys,d))return $n(!1,"TARGET_NODE_DENIED",`源输出端口禁止目标节点 ${d}`,l,c);if(hO(c.allowedSourceNodeKeys,u))return $n(!1,"SOURCE_NODE_NOT_ALLOWED",`源节点 ${u||"(未声明 node key)"} 不在目标输入端口白名单中`,l,c);if(hO(l.allowedTargetNodeKeys,d))return $n(!1,"TARGET_NODE_NOT_ALLOWED",`目标节点 ${d||"(未声明 node key)"} 不在源输出端口白名单中`,l,c);const f=s??[],p=pO(f,t.id,l.name,"source",a);if(mO(l,p))return $n(!1,"SOURCE_MAX_CONNECTIONS_REACHED",`源输出端口 ${l.name} 最多只能连接 ${l.maxConnections} 个节点`,l,c);const m=pO(f,e.id,c.name,"target",a);return mO(c,m)?$n(!1,"TARGET_MAX_CONNECTIONS_REACHED",`目标输入端口 ${c.name} 最多只能连接 ${c.maxConnections} 个节点`,l,c):t.id===e.id?$n(!1,"SELF_CONNECTION_NOT_ALLOWED","节点不能连接到自身",l,c):$n(!0,"VALID","",l,c)},hw=72,pw=6,mw=12,wO=24,fR=16,hR=320,bO="main";function pR(t){const e=Math.max(0,Math.floor(t));if(e<=pw)return{height:hw,compact:!1};if(e<=mw)return{height:hw+(e-pw)*wO,compact:!1};const n=hw+(mw-pw)*wO;return{height:Math.min(n+(e-mw)*fR,hR),compact:!0}}function mR(t){const e=t.inputs??[],n=t.outputs??[],{height:r,compact:o}=pR(Math.max(e.length,n.length));return{inputs:e.map((i,s)=>vO(i,s,e.length,un.TARGET,o)),outputs:n.map((i,s)=>vO(i,s,n.length,un.SOURCE,o)),height:r,compact:o}}function vO(t,e,n,r,o){const i=uw(t),s=i.type||bO,a=i.displayName||i.name,l=gR(i.position)??(r===un.TARGET?ne.Position.Left:ne.Position.Right);return{id:i.name,position:l,type:r,isMain:i.name===bO,label:a?h.jsx(bR,{compact:o,label:a}):void 0,maxConnections:typeof i.maxConnections=="number"?i.maxConnections:void 0,connectionType:s,portSchema:i,style:wR(e,n)}}function gR(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 wR(t,e){return{top:`${(t+1)/(e+1)*100}%`}}function bR({compact:t,label:e}){return h.jsx(_.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 vR({nodeType:t,data:e,legacyInputs:n,legacyOutputs:r,resolvePortSchema:o,overrideNodeKey:i,overrideNodeVersion:s}){var C,S;const a=Pt(),l=i??yR(t,e),c=s!==void 0?s:CR(e),u=l?Wi(l,c):null,d=((S=(C=a.nodeSelector)==null?void 0:C.connectable)==null?void 0:S.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 k=!1;return hc(l,c).then(x=>{k||m({identity:f,schema:x,failed:!x})}).catch(()=>{k||m({identity:f,schema:null,failed:!0})}),()=>{k=!0}},[u,f,d,l,c]);const b=(p==null?void 0:p.identity)===f?p.schema:null,v=d?u??b:null,w=y.useMemo(()=>v&&o?o(v):v,[o,v]),g=y.useMemo(()=>w?mR(w):null,[w]);return d?g?{inputs:g.inputs,outputs:g.outputs,height:g.height,status:"ready",isNodePackage:!0,schema:v}:!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 yR(t,e){const n=e.nodeKey??e.action_key;return typeof n=="string"?n:""}function CR(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 yO=30,gw=72,CO=2;function kR(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 kO=y.memo(t=>{const{id:e,data:n,selected:r,type:o}=t,i=n,s=y.useMemo(()=>kR(o),[o]),a=s.baseNodeType,l=ah(o),c=ne.useInternalNode(e),u=(c==null?void 0:c.data)??n,d=ji(o,u),f=d.inputs,p=l.type===pe.SWITCH?pP(u):d.outputs,m=y.useCallback(()=>_0(u),[u]),b=vR({nodeType:a,data:u,legacyInputs:f,legacyOutputs:p,...s.nodeKey?{overrideNodeKey:s.nodeKey}:{},...s.nodeVersion!==void 0?{overrideNodeVersion:s.nodeVersion}:{},...l.useNodePackagePorts&&l.type===pe.SWITCH?{resolvePortSchema:k=>th(k,m())}:{}}),v=l.useNodePackagePorts?b.outputs:p,w=l.useNodePackagePorts?b.inputs:f,g=l.type===pe.SWITCH?Math.max(b.height??0,v.length>CO?v.length*yO:gw):b.height,C=i.status??me.IDLE,S=i!=null&&i.icon?void 0:l.fallbackIcon;return h.jsx(uO,{id:e,data:n,selected:r,type:a,status:C,className:l.className,iconUri:i.icon,fallbackIcon:S,inputs:w,outputs:v,height:g})});kO.displayName="DeclaredNode";const ww={"dip.core.trigger.mcp-server":{source:ne.Position.Bottom,target:ne.Position.Top},"dip.core.trigger.mcp-tool":{source:ne.Position.Bottom,target:ne.Position.Top},"dip.core.mcp.return-variable":{source:ne.Position.Bottom,target:ne.Position.Top}},SR=["action_key","actionKey","nodeKey","node_key"],ER=["action_ver","nodeVersion","node_version"],xR=new Set(["left","top","right","bottom"]);function bw(t){if(!t)return"";for(const e of SR){const n=t[e];if(typeof n=="string"&&n.trim())return n.trim()}return""}function DR(t){if(t)for(const e of ER){const n=t[e];if(n==null||n==="")continue;const r=Number(n);if(Number.isFinite(r)&&r>=0)return r}}function _R(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 xR.has(t),void 0}}function SO(t){return!t||t.length===0?[]:t.map(e=>e.position)}function AR(t){const e=bw(t.data);if(!e)return Ui(t.type)?Wi(t.type):null;const n=DR(t.data);return Wi(e,n)}function OR(t,e){if(!t)return{sources:[],targets:[]};const n=(e==null?void 0:e.source)??ne.Position.Right,r=(e==null?void 0:e.target)??ne.Position.Left,o=[];for(const s of t.outputs??[])o.push(EO(s,n));const i=[];for(const s of t.inputs??[])i.push(EO(s,r));return{sources:o,targets:i}}function EO(t,e){const n=uw(t);return _R(n.position)??e}function TR(t){try{const e=ji(t.type,t.data??void 0);return{sources:SO(e.outputs),targets:SO(e.inputs)}}catch{return null}}function Ns(t){if(!t)return{sources:[],targets:[]};const e=t.data;if(po(e??null)||Ui(t.type)){const i=AR(t),s=bw(e),a=s?ww[s]??null:null,l=OR(i,a);if(l.sources.length>0||l.targets.length>0)return l;if(a)return{sources:[a.source],targets:[a.target]}}const r=TR(t);if(r&&(r.sources.length>0||r.targets.length>0))return r;const o=bw(e);if(o){const i=ww[o];if(i)return{sources:[i.source],targets:[i.target]}}return{sources:[],targets:[]}}function Dl(t){return t===ne.Position.Top||t===ne.Position.Bottom}function vw(t){return t===ne.Position.Left||t===ne.Position.Right}function NR(t){const e=Ns(t);return e.sources.some(Dl)||e.targets.some(Dl)}function BR(t){const e=Ns(t);return e.sources.some(vw)||e.targets.some(vw)}function FR(t,e,n){if(n){const r=Ns(n),o=xO(r.targets,t.targetHandle,n,"target");if(o)return Dl(o)?"vertical":"horizontal"}if(e){const r=Ns(e),o=xO(r.sources,t.sourceHandle,e,"source");if(o)return Dl(o)?"vertical":"horizontal"}return null}function xO(t,e,n,r){if(!e)return t[0];const i=(r==="source"?MR(n):IR(n)).find(s=>s.id===e);return(i==null?void 0:i.position)??t[0]}function MR(t){try{return ji(t.type,t.data??void 0).outputs}catch{return[]}}function IR(t){try{return ji(t.type,t.data??void 0).inputs}catch{return[]}}function PR(t){return Ns(t).sources.includes(ne.Position.Top)}function DO(t){let e=0,n=0;for(const r of t){const o=Ns(r);o.sources.some(Dl)&&(e+=1),o.sources.some(vw)&&(n+=1)}return e===0&&n===0?"horizontal":e>n?"vertical":"horizontal"}function LR(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 $R(t){return t===ne.Position.Top||t===ne.Position.Bottom}function _O(t,e,n){const r=LR(t),o=e?ww[e]:void 0;let i;r?i=r:o?i=n===un.TARGET?o.target:o.source:i=n===un.TARGET?ne.Position.Left:ne.Position.Right;const s=$R(i)?ne.Position.Left:ne.Position.Top;return{position:i,styleAxis:s}}const yw=y.memo(t=>{const{id:e,data:n,selected:r,type:o}=t,i=n,s=O0(o),a=i.node_type==="SwitchNode",l=a&&s?th(s,_0(i)):s,c=((l==null?void 0:l.inputs)||[]).length,u=typeof i.action_key=="string"?i.action_key:typeof i.nodeKey=="string"?i.nodeKey:void 0,d=((l==null?void 0:l.inputs)||[]).map((g,C)=>{const{display_name:S,name:k,type:x,max_connections:D}=g,{position:E,styleAxis:O}=_O(g.position,u,un.TARGET);return{id:k,label:S,position:E,type:un.TARGET,protocol:x,maxConnections:D,isMain:x==="main",style:{[O]:`${10+80/(c+1)*(C+1)}%`}}}),f=((l==null?void 0:l.outputs)||[]).length,p=((l==null?void 0:l.outputs)||[]).map((g,C)=>{const{display_name:S,name:k,type:x,max_connections:D}=g,{position:E,styleAxis:O}=_O(g.position,u,un.SOURCE);return{id:k,label:S,position:E,type:un.SOURCE,protocol:x,maxConnections:D,isMain:x==="main",style:{[O]:`${10+80/(f+1)*(C+1)}%`}}}),m=ah(o),b=i.status??me.IDLE,v=i!=null&&i.icon?void 0:m.fallbackIcon,w=a?Math.max(gw,p.length>CO?p.length*yO:gw):void 0;return h.jsx(uO,{id:e,data:n,selected:r,type:pe.DYNAMIC,status:b,className:m.className,iconUri:i.icon,fallbackIcon:v,inputs:d,outputs:p,height:w})});yw.displayName="NodePackageNode";function AO(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 $re(){}const _l=Gd(/[A-Za-z]/),Cw=Gd(/[\dA-Za-z]/);function zR(t){return t!==null&&(t<32||t===127)}function Bs(t){return t!==null&&t<-2}function Dn(t){return t!==null&&(t<0||t===32)}function oo(t){return t===-2||t===-1||t===32}const qd=Gd(new RegExp("\\p{P}|\\p{S}","u")),Ai=Gd(/\s/);function Gd(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function HR(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const Rd=(function(t){if(t==null)return UR;if(typeof t=="function")return Kd(t);if(typeof t=="object")return Array.isArray(t)?VR(t):jR(t);if(typeof t=="string")return WR(t);throw new Error("Expected function, string, or object as test")});function VR(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=Rd(t[n]);return Kd(r);function r(...o){let i=-1;for(;++i<e.length;)if(e[i].apply(this,o))return!0;return!1}}function jR(t){const e=t;return Kd(n);function n(r){const o=r;let i;for(i in t)if(o[i]!==e[i])return!1;return!0}}function WR(t){return Kd(e);function e(n){return n&&n.type===t}}function Kd(t){return e;function e(n,r,o){return!!(qR(n)&&t.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function UR(){return!0}function qR(t){return t!==null&&typeof t=="object"&&"type"in t}function zre(t){return t}const OO=[],GR=!0,kw=!1,RR="skip";function TO(t,e,n,r){let o;typeof e=="function"&&typeof n!="function"?(r=n,n=e):o=e;const i=Rd(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=OO,m,b,v;if((!e||i(l,c,u[u.length-1]||void 0))&&(p=KR(n(l,u)),p[0]===kw))return p;if("children"in l&&l.children){const w=l;if(w.children&&p[0]!==RR)for(b=(r?w.children.length:-1)+s,v=u.concat(w);b>-1&&b<w.children.length;){const g=w.children[b];if(m=a(g,b,v)(),m[0]===kw)return m;b=typeof m[1]=="number"?m[1]:b+s}}return p}}}function KR(t){return Array.isArray(t)?t:typeof t=="number"?[GR,t]:t==null?OO:[t]}function YR(t,e,n){const o=Rd((n||{}).ignore||[]),i=XR(e);let s=-1;for(;++s<i.length;)TO(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 v=d.children.indexOf(c);let w=!1,g=[];f.lastIndex=0;let C=f.exec(c.value);for(;C;){const S=C.index,k={index:C.index,input:C.input,stack:[...u,c]};let x=p(...C,k);if(typeof x=="string"&&(x=x.length>0?{type:"text",value:x}:void 0),x===!1?f.lastIndex=S+1:(m!==S&&g.push({type:"text",value:c.value.slice(m,S)}),Array.isArray(x)?g.push(...x):x&&g.push(x),m=S+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(v,1,...g)):g=[c],v+g.length}}function XR(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([JR(o[0]),QR(o[1])])}return e}function JR(t){return typeof t=="string"?new RegExp(HR(t),"g"):t}function QR(t){return typeof t=="function"?t:function(){return t}}const Sw="phrasing",Ew=["autolink","link","image","label"];function ZR(){return{transforms:[sK],enter:{literalAutolink:tK,literalAutolinkEmail:xw,literalAutolinkHttp:xw,literalAutolinkWww:xw},exit:{literalAutolink:iK,literalAutolinkEmail:oK,literalAutolinkHttp:nK,literalAutolinkWww:rK}}}function eK(){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 tK(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function xw(t){this.config.enter.autolinkProtocol.call(this,t)}function nK(t){this.config.exit.autolinkProtocol.call(this,t)}function rK(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 oK(t){this.config.exit.autolinkEmail.call(this,t)}function iK(t){this.exit(t)}function sK(t){YR(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,aK],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),lK]],{ignore:["link","linkReference"]})}function aK(t,e,n,r,o){let i="";if(!NO(o)||(/^w/i.test(e)&&(n=e+n,e="",i="http://"),!cK(n)))return!1;const s=uK(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 lK(t,e,n,r){return!NO(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+n,children:[{type:"text",value:e+"@"+n}]}}function cK(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 uK(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=AO(t,"(");let i=AO(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 NO(t,e){const n=t.input.charCodeAt(t.index-1);return(t.index===0||Ai(n)||qd(n))&&(!e||n!==47)}function Al(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}BO.peek=vK;function dK(){this.buffer()}function fK(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function hK(){this.buffer()}function pK(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function mK(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 gK(t){this.exit(t)}function wK(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 bK(t){this.exit(t)}function vK(){return"["}function BO(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 yK(){return{enter:{gfmFootnoteCallString:dK,gfmFootnoteCall:fK,gfmFootnoteDefinitionLabelString:hK,gfmFootnoteDefinition:pK},exit:{gfmFootnoteCallString:mK,gfmFootnoteCall:gK,gfmFootnoteDefinitionLabelString:wK,gfmFootnoteDefinition:bK}}}function CK(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:n,footnoteReference:BO},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?FO:kK))),c(),l}}function kK(t,e,n){return e===0?t:FO(t,e,n)}function FO(t,e,n){return(n?"":" ")+t}const SK=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];MO.peek=AK;function EK(){return{canContainEols:["delete"],enter:{strikethrough:DK},exit:{strikethrough:_K}}}function xK(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:SK}],handlers:{delete:MO}}}function DK(t){this.enter({type:"delete",children:[]},t)}function _K(t){this.exit(t)}function MO(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 AK(){return"~"}function OK(t){return t.length}function TK(t,e){const n=e||{},r=(n.align||[]).concat(),o=n.stringLength||OK,i=[],s=[],a=[],l=[];let c=0,u=-1;for(;++u<t.length;){const b=[],v=[];let w=-1;for(t[u].length>c&&(c=t[u].length);++w<t[u].length;){const g=NK(t[u][w]);if(n.alignDelimiters!==!1){const C=o(g);v[w]=C,(l[w]===void 0||C>l[w])&&(l[w]=C)}b.push(g)}s[u]=b,a[u]=v}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<c;)i[d]=IO(r[d]);else{const b=IO(r);for(;++d<c;)i[d]=b}d=-1;const f=[],p=[];for(;++d<c;){const b=i[d];let v="",w="";b===99?(v=":",w=":"):b===108?v=":":b===114&&(w=":");let g=n.alignDelimiters===!1?1:Math.max(1,l[d]-v.length-w.length);const C=v+"-".repeat(g)+w;n.alignDelimiters!==!1&&(g=v.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 b=s[u],v=a[u];d=-1;const w=[];for(;++d<c;){const g=b[d]||"";let C="",S="";if(n.alignDelimiters!==!1){const k=l[d]-(v[d]||0),x=i[d];x===114?C=" ".repeat(k):x===99?k%2?(C=" ".repeat(k/2+.5),S=" ".repeat(k/2-.5)):(C=" ".repeat(k/2),S=C):S=" ".repeat(k)}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(S),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 NK(t){return t==null?"":String(t)}function IO(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 BK(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()),FK);return o(),s}function FK(t,e,n){return">"+(n?"":" ")+t}function MK(t,e){return PO(t,e.inConstruct,!0)&&!PO(t,e.notInConstruct,!1)}function PO(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 LO(t,e,n,r){let o=-1;for(;++o<n.unsafe.length;)if(n.unsafe[o].character===`
|