@digitalsee-ai/rcs 2.0.0-beta11 → 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.
@@ -109,12 +109,12 @@ The error may be correlated with this previous error:
109
109
  *
110
110
  * This source code is licensed under the ISC license.
111
111
  * See the LICENSE file in the root directory of this source tree.
112
- */const vW=Io("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),yW=/\{\{.*\}\}/;function U_(t){return typeof t=="string"&&yW.test(t)?"expression":"normal"}const q_=({field:t,disabled:e,readOnly:n,context:r})=>{const{renderVariableTag:o,renderVariableTooltip:i,validateVariable:s}=r,a=CW(t),l=t.keyPlaceholder||"Key",c=t.valuePlaceholder||"Value",u=0;return h.jsx(_.Form.List,{name:t.name,rules:a,children:(d,{add:f,remove:p},{errors:m})=>h.jsxs(_.Space,{direction:"vertical",style:{width:"100%"},children:[d.map(b=>h.jsx(G_,{field:t,listField:b,disabled:e,readOnly:n,canRemove:!(e||t.minItems!==void 0&&d.length<=t.minItems),keyPlaceholder:l,valuePlaceholder:c,valueModeSwitchOffset:u,onRemove:p,validateVariable:s,renderVariableTag:o,renderVariableTooltip:i},b.key)),h.jsx(_.Button,{block:!0,icon:h.jsx(br,{size:16}),onClick:()=>f(),disabled:e||t.maxItems!==void 0&&d.length>=t.maxItems,children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})}),h.jsx(_.Form.ErrorList,{errors:m})]})})};q_.displayName="KeyValueFieldControl";const G_=({field:t,listField:e,disabled:n,readOnly:r,canRemove:o,keyPlaceholder:i,valuePlaceholder:s,valueModeSwitchOffset:a,onRemove:l,validateVariable:c,renderVariableTag:u,renderVariableTooltip:d})=>{const f=t.valueModePolicy,p=_.Form.useFormInstance(),[m,b]=y.useState(()=>{if(f){if(f==="BOTH"||f==="EXPRESSION")return"expression";if(f==="TEXT")return"normal"}const w=p.getFieldValue([t.name,e.name]),g=U_(w==null?void 0:w.key);return g==="expression"?g:U_(w==null?void 0:w.value)}),v=f==="TEXT"?["normal"]:["normal","expression"];return h.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[h.jsx(_.Form.Item,{style:{flex:1,marginBottom:0,marginTop:a},name:[e.name,"key"],rules:[{required:!0,message:"请输入Key"}],children:h.jsx(Ci,{availableModes:v,mode:m,hideModeSwitch:!0,disabled:n,readOnly:r,placeholder:i,validateVariable:c,renderVariableTag:u,renderVariableTooltip:d})}),h.jsx(_.Form.Item,{style:{flex:1,marginBottom:0},name:[e.name,"value"],children:h.jsx(Ci,{availableModes:v,mode:m,onModeChange:b,disabled:n,readOnly:r,placeholder:s,validateVariable:c,renderVariableTag:u,renderVariableTooltip:d,modeSwitchPosition:"top-right",compact:!0})}),h.jsx(_.Button,{icon:h.jsx(xi,{size:16}),onClick:()=>l(e.name),disabled:!o})]})};G_.displayName="KeyValueRow";function CW(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)||"此项为必填")}})}if(t.minItems!==void 0){const r=t.minItems;e.push({validator:async(o,i)=>{if(!i||i.length<r)throw new Error(`至少需要 ${r} 项`)}})}if(t.maxItems!==void 0){const r=t.maxItems;e.push({validator:async(o,i)=>{if(i&&i.length>r)throw new Error(`最多允许 ${r} 项`)}})}return e}const kW=Mo(q_,{isComplexField:!0,supportsVariableInsert:!0,needsFormItemName:!1});function SW(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.name=="string"&&e.name.trim()!==""&&typeof e.type=="string"}function EW(t){return!t||typeof t!="object"||Array.isArray(t)?[]:Object.values(t).filter(SW)}const R_=({field:t,disabled:e,readOnly:n,context:r})=>{const o=_.Form.useFormInstance(),s=xW(t.name),[a,l]=vt.useState(null);vt.useEffect(()=>{Promise.resolve().then(()=>_U).then(g=>{l(()=>g.FieldRenderer)})},[]);const{renderVariableTag:c,renderVariableTooltip:u,validateVariable:d,values:f,optionsLoader:p}=r,m=vt.useMemo(()=>EW(t.properties),[t.properties]),b=o.getFieldValue(s)??qn(f,s.join("."))??{},v=h.jsx(_.Space,{direction:"vertical",style:{width:"100%"},children:m.map(g=>{const C=jg(g,t.valueModePolicy),S=[...s,g.name];return yl(C,b)&&a?h.jsx(a,{field:{...C,name:S},values:f,optionsLoader:p,disabled:e,renderVariableTag:c,renderVariableTooltip:u,validateVariable:d},S.join(".")):null})}),w=h.jsx(Wg,{policy:t.valueModePolicy,disabled:e,readOnly:n,children:v});return t.collapsible?h.jsx(_.Collapse,{defaultActiveKey:t.defaultCollapsed?[]:["main"],items:[{key:"main",label:t.label||t.name,children:w}]}):h.jsx(_.Card,{size:"small",title:t.label,children:w})};R_.displayName="ObjectFieldControl";function xW(t){return Array.isArray(t)?t:[t]}const DW=Mo(R_,{isComplexField:!0,supportsVariableInsert:!0,needsFormItemName:!1});var Od={exports:{}},_W=Od.exports,K_;function AW(){return K_||(K_=1,(function(t,e){(function(n,r){t.exports=r()})(_W,(function(){var n=1e3,r=6e4,o=36e5,i="millisecond",s="second",a="minute",l="hour",c="day",u="week",d="month",f="quarter",p="year",m="date",b="Invalid Date",v=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,w=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(F){var N=["th","st","nd","rd"],P=F%100;return"["+F+(N[(P-20)%10]||N[P]||N[0])+"]"}},C=function(F,N,P){var I=String(F);return!I||I.length>=N?F:""+Array(N+1-I.length).join(P)+F},S={s:C,z:function(F){var N=-F.utcOffset(),P=Math.abs(N),I=Math.floor(P/60),z=P%60;return(N<=0?"+":"-")+C(I,2,"0")+":"+C(z,2,"0")},m:function F(N,P){if(N.date()<P.date())return-F(P,N);var I=12*(P.year()-N.year())+(P.month()-N.month()),z=N.clone().add(I,d),H=P-z<0,J=N.clone().add(I+(H?-1:1),d);return+(-(I+(P-z)/(H?z-J:J-z))||0)},a:function(F){return F<0?Math.ceil(F)||0:Math.floor(F)},p:function(F){return{M:d,y:p,w:u,d:c,D:m,h:l,m:a,s,ms:i,Q:f}[F]||String(F||"").toLowerCase().replace(/s$/,"")},u:function(F){return F===void 0}},k="en",x={};x[k]=g;var D="$isDayjsObject",E=function(F){return F instanceof B||!(!F||!F[D])},O=function F(N,P,I){var z;if(!N)return k;if(typeof N=="string"){var H=N.toLowerCase();x[H]&&(z=H),P&&(x[H]=P,z=H);var J=N.split("-");if(!z&&J.length>1)return F(J[0])}else{var K=N.name;x[K]=N,z=K}return!I&&z&&(k=z),z||!I&&k},A=function(F,N){if(E(F))return F.clone();var P=typeof N=="object"?N:{};return P.date=F,P.args=arguments,new B(P)},T=S;T.l=O,T.i=E,T.w=function(F,N){return A(F,{locale:N.$L,utc:N.$u,x:N.$x,$offset:N.$offset})};var B=(function(){function F(P){this.$L=O(P.locale,null,!0),this.parse(P),this.$x=this.$x||P.x||{},this[D]=!0}var N=F.prototype;return N.parse=function(P){this.$d=(function(I){var z=I.date,H=I.utc;if(z===null)return new Date(NaN);if(T.u(z))return new Date;if(z instanceof Date)return new Date(z);if(typeof z=="string"&&!/Z$/i.test(z)){var J=z.match(v);if(J){var K=J[2]-1||0,ee=(J[7]||"0").substring(0,3);return H?new Date(Date.UTC(J[1],K,J[3]||1,J[4]||0,J[5]||0,J[6]||0,ee)):new Date(J[1],K,J[3]||1,J[4]||0,J[5]||0,J[6]||0,ee)}}return new Date(z)})(P),this.init()},N.init=function(){var P=this.$d;this.$y=P.getFullYear(),this.$M=P.getMonth(),this.$D=P.getDate(),this.$W=P.getDay(),this.$H=P.getHours(),this.$m=P.getMinutes(),this.$s=P.getSeconds(),this.$ms=P.getMilliseconds()},N.$utils=function(){return T},N.isValid=function(){return this.$d.toString()!==b},N.isSame=function(P,I){var z=A(P);return this.startOf(I)<=z&&z<=this.endOf(I)},N.isAfter=function(P,I){return A(P)<this.startOf(I)},N.isBefore=function(P,I){return this.endOf(I)<A(P)},N.$g=function(P,I,z){return T.u(P)?this[I]:this.set(z,P)},N.unix=function(){return Math.floor(this.valueOf()/1e3)},N.valueOf=function(){return this.$d.getTime()},N.startOf=function(P,I){var z=this,H=!!T.u(I)||I,J=T.p(P),K=function(j,Y){var W=T.w(z.$u?Date.UTC(z.$y,Y,j):new Date(z.$y,Y,j),z);return H?W:W.endOf(c)},ee=function(j,Y){return T.w(z.toDate()[j].apply(z.toDate("s"),(H?[0,0,0,0]:[23,59,59,999]).slice(Y)),z)},$=this.$W,U=this.$M,R=this.$D,te="set"+(this.$u?"UTC":"");switch(J){case p:return H?K(1,0):K(31,11);case d:return H?K(1,U):K(0,U+1);case u:var se=this.$locale().weekStart||0,be=($<se?$+7:$)-se;return K(H?R-be:R+(6-be),U);case c:case m:return ee(te+"Hours",0);case l:return ee(te+"Minutes",1);case a:return ee(te+"Seconds",2);case s:return ee(te+"Milliseconds",3);default:return this.clone()}},N.endOf=function(P){return this.startOf(P,!1)},N.$set=function(P,I){var z,H=T.p(P),J="set"+(this.$u?"UTC":""),K=(z={},z[c]=J+"Date",z[m]=J+"Date",z[d]=J+"Month",z[p]=J+"FullYear",z[l]=J+"Hours",z[a]=J+"Minutes",z[s]=J+"Seconds",z[i]=J+"Milliseconds",z)[H],ee=H===c?this.$D+(I-this.$W):I;if(H===d||H===p){var $=this.clone().set(m,1);$.$d[K](ee),$.init(),this.$d=$.set(m,Math.min(this.$D,$.daysInMonth())).$d}else K&&this.$d[K](ee);return this.init(),this},N.set=function(P,I){return this.clone().$set(P,I)},N.get=function(P){return this[T.p(P)]()},N.add=function(P,I){var z,H=this;P=Number(P);var J=T.p(I),K=function(U){var R=A(H);return T.w(R.date(R.date()+Math.round(U*P)),H)};if(J===d)return this.set(d,this.$M+P);if(J===p)return this.set(p,this.$y+P);if(J===c)return K(1);if(J===u)return K(7);var ee=(z={},z[a]=r,z[l]=o,z[s]=n,z)[J]||1,$=this.$d.getTime()+P*ee;return T.w($,this)},N.subtract=function(P,I){return this.add(-1*P,I)},N.format=function(P){var I=this,z=this.$locale();if(!this.isValid())return z.invalidDate||b;var H=P||"YYYY-MM-DDTHH:mm:ssZ",J=T.z(this),K=this.$H,ee=this.$m,$=this.$M,U=z.weekdays,R=z.months,te=z.meridiem,se=function(Y,W,X,re){return Y&&(Y[W]||Y(I,H))||X[W].slice(0,re)},be=function(Y){return T.s(K%12||12,Y,"0")},j=te||function(Y,W,X){var re=Y<12?"AM":"PM";return X?re.toLowerCase():re};return H.replace(w,(function(Y,W){return W||(function(X){switch(X){case"YY":return String(I.$y).slice(-2);case"YYYY":return T.s(I.$y,4,"0");case"M":return $+1;case"MM":return T.s($+1,2,"0");case"MMM":return se(z.monthsShort,$,R,3);case"MMMM":return se(R,$);case"D":return I.$D;case"DD":return T.s(I.$D,2,"0");case"d":return String(I.$W);case"dd":return se(z.weekdaysMin,I.$W,U,2);case"ddd":return se(z.weekdaysShort,I.$W,U,3);case"dddd":return U[I.$W];case"H":return String(K);case"HH":return T.s(K,2,"0");case"h":return be(1);case"hh":return be(2);case"a":return j(K,ee,!0);case"A":return j(K,ee,!1);case"m":return String(ee);case"mm":return T.s(ee,2,"0");case"s":return String(I.$s);case"ss":return T.s(I.$s,2,"0");case"SSS":return T.s(I.$ms,3,"0");case"Z":return J}return null})(Y)||J.replace(":","")}))},N.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},N.diff=function(P,I,z){var H,J=this,K=T.p(I),ee=A(P),$=(ee.utcOffset()-this.utcOffset())*r,U=this-ee,R=function(){return T.m(J,ee)};switch(K){case p:H=R()/12;break;case d:H=R();break;case f:H=R()/3;break;case u:H=(U-$)/6048e5;break;case c:H=(U-$)/864e5;break;case l:H=U/o;break;case a:H=U/r;break;case s:H=U/n;break;default:H=U}return z?H:T.a(H)},N.daysInMonth=function(){return this.endOf(d).$D},N.$locale=function(){return x[this.$L]},N.locale=function(P,I){if(!P)return this.$L;var z=this.clone(),H=O(P,I,!0);return H&&(z.$L=H),z},N.clone=function(){return T.w(this.$d,this)},N.toDate=function(){return new Date(this.valueOf())},N.toJSON=function(){return this.isValid()?this.toISOString():null},N.toISOString=function(){return this.$d.toISOString()},N.toString=function(){return this.$d.toUTCString()},F})(),M=B.prototype;return A.prototype=M,[["$ms",i],["$s",s],["$m",a],["$H",l],["$W",c],["$M",d],["$y",p],["$D",m]].forEach((function(F){M[F[1]]=function(N){return this.$g(N,F[0],F[1])}})),A.extend=function(F,N){return F.$i||(F(N,B,A),F.$i=!0),A},A.locale=O,A.isDayjs=E,A.unix=function(F){return A(1e3*F)},A.en=x[k],A.Ls=x,A.p={},A}))})(Od)),Od.exports}var OW=AW();const Ht=Un(OW);var Td={exports:{}},TW=Td.exports,Y_;function NW(){return Y_||(Y_=1,(function(t,e){(function(n,r){t.exports=r()})(TW,(function(){return function(n,r){var o=r.prototype,i=o.format;o.format=function(s){var a=this,l=this.$locale();if(!this.isValid())return i.bind(this)(s);var c=this.$utils(),u=(s||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,(function(d){switch(d){case"Q":return Math.ceil((a.$M+1)/3);case"Do":return l.ordinal(a.$D);case"gggg":return a.weekYear();case"GGGG":return a.isoWeekYear();case"wo":return l.ordinal(a.week(),"W");case"w":case"ww":return c.s(a.week(),d==="w"?1:2,"0");case"W":case"WW":return c.s(a.isoWeek(),d==="W"?1:2,"0");case"k":case"kk":return c.s(String(a.$H===0?24:a.$H),d==="k"?1:2,"0");case"X":return Math.floor(a.$d.getTime()/1e3);case"x":return a.$d.getTime();case"z":return"["+a.offsetName()+"]";case"zzz":return"["+a.offsetName("long")+"]";default:return d}}));return i.bind(this)(u)}}}))})(Td)),Td.exports}var BW=NW();const FW=Un(BW);var Nd={exports:{}},MW=Nd.exports,X_;function IW(){return X_||(X_=1,(function(t,e){(function(n,r){t.exports=r()})(MW,(function(){var n={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},r=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,o=/\d/,i=/\d\d/,s=/\d\d?/,a=/\d*[^-_:/,()\s\d]+/,l={},c=function(v){return(v=+v)+(v>68?1900:2e3)},u=function(v){return function(w){this[v]=+w}},d=[/[+-]\d\d:?(\d\d)?|Z/,function(v){(this.zone||(this.zone={})).offset=(function(w){if(!w||w==="Z")return 0;var g=w.match(/([+-]|\d\d)/g),C=60*g[1]+(+g[2]||0);return C===0?0:g[0]==="+"?-C:C})(v)}],f=function(v){var w=l[v];return w&&(w.indexOf?w:w.s.concat(w.f))},p=function(v,w){var g,C=l.meridiem;if(C){for(var S=1;S<=24;S+=1)if(v.indexOf(C(S,0,w))>-1){g=S>12;break}}else g=v===(w?"pm":"PM");return g},m={A:[a,function(v){this.afternoon=p(v,!1)}],a:[a,function(v){this.afternoon=p(v,!0)}],Q:[o,function(v){this.month=3*(v-1)+1}],S:[o,function(v){this.milliseconds=100*+v}],SS:[i,function(v){this.milliseconds=10*+v}],SSS:[/\d{3}/,function(v){this.milliseconds=+v}],s:[s,u("seconds")],ss:[s,u("seconds")],m:[s,u("minutes")],mm:[s,u("minutes")],H:[s,u("hours")],h:[s,u("hours")],HH:[s,u("hours")],hh:[s,u("hours")],D:[s,u("day")],DD:[i,u("day")],Do:[a,function(v){var w=l.ordinal,g=v.match(/\d+/);if(this.day=g[0],w)for(var C=1;C<=31;C+=1)w(C).replace(/\[|\]/g,"")===v&&(this.day=C)}],w:[s,u("week")],ww:[i,u("week")],M:[s,u("month")],MM:[i,u("month")],MMM:[a,function(v){var w=f("months"),g=(f("monthsShort")||w.map((function(C){return C.slice(0,3)}))).indexOf(v)+1;if(g<1)throw new Error;this.month=g%12||g}],MMMM:[a,function(v){var w=f("months").indexOf(v)+1;if(w<1)throw new Error;this.month=w%12||w}],Y:[/[+-]?\d+/,u("year")],YY:[i,function(v){this.year=c(v)}],YYYY:[/\d{4}/,u("year")],Z:d,ZZ:d};function b(v){var w,g;w=v,g=l&&l.formats;for(var C=(v=w.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(A,T,B){var M=B&&B.toUpperCase();return T||g[B]||n[B]||g[M].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(F,N,P){return N||P.slice(1)}))}))).match(r),S=C.length,k=0;k<S;k+=1){var x=C[k],D=m[x],E=D&&D[0],O=D&&D[1];C[k]=O?{regex:E,parser:O}:x.replace(/^\[|\]$/g,"")}return function(A){for(var T={},B=0,M=0;B<S;B+=1){var F=C[B];if(typeof F=="string")M+=F.length;else{var N=F.regex,P=F.parser,I=A.slice(M),z=N.exec(I)[0];P.call(T,z),A=A.replace(z,"")}}return(function(H){var J=H.afternoon;if(J!==void 0){var K=H.hours;J?K<12&&(H.hours+=12):K===12&&(H.hours=0),delete H.afternoon}})(T),T}}return function(v,w,g){g.p.customParseFormat=!0,v&&v.parseTwoDigitYear&&(c=v.parseTwoDigitYear);var C=w.prototype,S=C.parse;C.parse=function(k){var x=k.date,D=k.utc,E=k.args;this.$u=D;var O=E[1];if(typeof O=="string"){var A=E[2]===!0,T=E[3]===!0,B=A||T,M=E[2];T&&(M=E[2]),l=this.$locale(),!A&&M&&(l=g.Ls[M]),this.$d=(function(I,z,H,J){try{if(["x","X"].indexOf(z)>-1)return new Date((z==="X"?1e3:1)*I);var K=b(z)(I),ee=K.year,$=K.month,U=K.day,R=K.hours,te=K.minutes,se=K.seconds,be=K.milliseconds,j=K.zone,Y=K.week,W=new Date,X=U||(ee||$?1:W.getDate()),re=ee||W.getFullYear(),Z=0;ee&&!$||(Z=$>0?$-1:W.getMonth());var de,ve=R||0,we=te||0,fe=se||0,le=be||0;return j?new Date(Date.UTC(re,Z,X,ve,we,fe,le+60*j.offset*1e3)):H?new Date(Date.UTC(re,Z,X,ve,we,fe,le)):(de=new Date(re,Z,X,ve,we,fe,le),Y&&(de=J(de).week(Y).toDate()),de)}catch{return new Date("")}})(x,O,D,g),this.init(),M&&M!==!0&&(this.$L=this.locale(M).$L),B&&x!=this.format(O)&&(this.$d=new Date("")),l={}}else if(O instanceof Array)for(var F=O.length,N=1;N<=F;N+=1){E[1]=O[N-1];var P=g.apply(this,E);if(P.isValid()){this.$d=P.$d,this.$L=P.$L,this.init();break}N===F&&(this.$d=new Date(""))}else S.call(this,k)}}}))})(Nd)),Nd.exports}var PW=IW();const LW=Un(PW);var Bd={exports:{}},$W=Bd.exports,J_;function zW(){return J_||(J_=1,(function(t,e){(function(n,r){t.exports=r()})($W,(function(){return function(n,r,o){var i=r.prototype,s=function(d){return d&&(d.indexOf?d:d.s)},a=function(d,f,p,m,b){var v=d.name?d:d.$locale(),w=s(v[f]),g=s(v[p]),C=w||g.map((function(k){return k.slice(0,m)}));if(!b)return C;var S=v.weekStart;return C.map((function(k,x){return C[(x+(S||0))%7]}))},l=function(){return o.Ls[o.locale()]},c=function(d,f){return d.formats[f]||(function(p){return p.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(m,b,v){return b||v.slice(1)}))})(d.formats[f.toUpperCase()])},u=function(){var d=this;return{months:function(f){return f?f.format("MMMM"):a(d,"months")},monthsShort:function(f){return f?f.format("MMM"):a(d,"monthsShort","months",3)},firstDayOfWeek:function(){return d.$locale().weekStart||0},weekdays:function(f){return f?f.format("dddd"):a(d,"weekdays")},weekdaysMin:function(f){return f?f.format("dd"):a(d,"weekdaysMin","weekdays",2)},weekdaysShort:function(f){return f?f.format("ddd"):a(d,"weekdaysShort","weekdays",3)},longDateFormat:function(f){return c(d.$locale(),f)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};i.localeData=function(){return u.bind(this)()},o.localeData=function(){var d=l();return{firstDayOfWeek:function(){return d.weekStart||0},weekdays:function(){return o.weekdays()},weekdaysShort:function(){return o.weekdaysShort()},weekdaysMin:function(){return o.weekdaysMin()},months:function(){return o.months()},monthsShort:function(){return o.monthsShort()},longDateFormat:function(f){return c(d,f)},meridiem:d.meridiem,ordinal:d.ordinal}},o.months=function(){return a(l(),"months")},o.monthsShort=function(){return a(l(),"monthsShort","months",3)},o.weekdays=function(d){return a(l(),"weekdays",null,null,d)},o.weekdaysShort=function(d){return a(l(),"weekdaysShort","weekdays",3,d)},o.weekdaysMin=function(d){return a(l(),"weekdaysMin","weekdays",2,d)}}}))})(Bd)),Bd.exports}var HW=zW();const VW=Un(HW);var Fd={exports:{}},jW=Fd.exports,Q_;function WW(){return Q_||(Q_=1,(function(t,e){(function(n,r){t.exports=r()})(jW,(function(){return function(n,r){r.prototype.weekday=function(o){var i=this.$locale().weekStart||0,s=this.$W,a=(s<i?s+7:s)-i;return this.$utils().u(o)?a:this.subtract(a,"day").add(o,"day")}}}))})(Fd)),Fd.exports}var UW=WW();const qW=Un(UW);var Md={exports:{}},GW=Md.exports,Z_;function RW(){return Z_||(Z_=1,(function(t,e){(function(n,r){t.exports=r()})(GW,(function(){var n="week",r="year";return function(o,i,s){var a=i.prototype;a.week=function(l){if(l===void 0&&(l=null),l!==null)return this.add(7*(l-this.week()),"day");var c=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var u=s(this).startOf(r).add(1,r).date(c),d=s(this).endOf(n);if(u.isBefore(d))return 1}var f=s(this).startOf(r).date(c).startOf(n).subtract(1,"millisecond"),p=this.diff(f,n,!0);return p<0?s(this).startOf("week").week():Math.ceil(p)},a.weeks=function(l){return l===void 0&&(l=null),this.week(l)}}}))})(Md)),Md.exports}var KW=RW();const YW=Un(KW);var Id={exports:{}},XW=Id.exports,eA;function JW(){return eA||(eA=1,(function(t,e){(function(n,r){t.exports=r()})(XW,(function(){return function(n,r){r.prototype.weekYear=function(){var o=this.month(),i=this.week(),s=this.year();return i===1&&o===11?s+1:o===0&&i>=52?s-1:s}}}))})(Id)),Id.exports}var QW=JW();const ZW=Un(QW);Ht.extend(LW),Ht.extend(FW),Ht.extend(qW),Ht.extend(VW),Ht.extend(YW),Ht.extend(ZW);function Cl(t,e){if(t==null||t==="")return null;if(Ht.isDayjs(t))return t.isValid()?t:null;const n=e?Ht(t,e):Ht(t);if(n.isValid())return n;const r=Ht(t);return r.isValid()?r:null}function tA(t,e){if(!Array.isArray(t))return null;const n=Cl(t[0],e),r=Cl(t[1],e);return n||r?[n,r]:null}function kl(t,e,n){if(t)return e==="timestamp"?t.valueOf():e==="string"?t.format(n):t}function nA(t,e,n){if(t)return[kl(t[0],e,n),kl(t[1],e,n)]}const eU="YYYY-MM-DD",rA=({field:t,disabled:e,value:n,onChange:r,id:o})=>{const i=t.format||eU,s=Cl(n,i);return h.jsx(_.DatePicker,{disabled:e,placeholder:t.placeholder,picker:t.picker,format:i,style:{width:"100%"},value:s,onChange:a=>r==null?void 0:r(kl(a,t.outputFormat,i)),id:o})};rA.displayName="DateFieldControl";const tU=ft(rA,{needsFormItemName:!0}),nU="YYYY-MM-DD",oA=({field:t,disabled:e,value:n,onChange:r,id:o})=>{const i=t.format||nU,s=tA(n,i);return h.jsx(_.DatePicker.RangePicker,{disabled:e,picker:t.picker,showTime:t.showTime,format:i,style:{width:"100%"},value:s,onChange:a=>r==null?void 0:r(nA(a,t.outputFormat,i)),id:o})};oA.displayName="DateRangeFieldControl";const rU=ft(oA,{needsFormItemName:!0}),oU="YYYY-MM-DD HH:mm:ss",iA=({field:t,disabled:e,value:n,onChange:r,id:o})=>{const i=t.format||oU,s=Cl(n,i);return h.jsx(_.DatePicker,{disabled:e,placeholder:t.placeholder,showTime:t.showTime??!0,format:i,style:{width:"100%"},value:s,onChange:a=>r==null?void 0:r(kl(a,t.outputFormat,i)),id:o})};iA.displayName="DateTimeFieldControl";const iU=ft(iA,{needsFormItemName:!0}),sU="HH:mm:ss",sA=({field:t,disabled:e,value:n,onChange:r,id:o})=>{const i=t.format||sU,s=Cl(n,i);return h.jsx(_.TimePicker,{disabled:e,placeholder:t.placeholder,format:i,style:{width:"100%"},value:s,onChange:a=>r==null?void 0:r(kl(a,t.outputFormat,i)),id:o})};sA.displayName="TimeFieldControl";const aU=ft(sA,{needsFormItemName:!0}),lU="HH:mm:ss",aA=({field:t,disabled:e,value:n,onChange:r,id:o})=>{const i=t.format||lU,s=tA(n,i);return h.jsx(_.TimePicker.RangePicker,{disabled:e,format:i,style:{width:"100%"},value:s,onChange:a=>r==null?void 0:r(nA(a,t.outputFormat,i)),id:o})};aA.displayName="TimeRangeFieldControl";const cU=ft(aA,{needsFormItemName:!0}),lA=({field:t})=>h.jsx(_.Divider,{children:t.label});lA.displayName="DividerFieldControl";const uU=Mo(lA,{isDisplayOnly:!0,needsFormItemName:!1}),cA=({value:t,onChange:e,id:n})=>h.jsx(_.Input,{type:"hidden",value:t,onChange:r=>e==null?void 0:e(r.target.value),id:n});cA.displayName="HiddenFieldControl";const dU=Mo(cA,{needsFormItemName:!0,isHidden:!0}),uA=({field:t})=>h.jsx(_.Alert,{message:t.label,description:t.description||t.placeholder,type:t.status||"info",showIcon:t.showIcon,closable:t.closable});uA.displayName="InfoCardFieldControl";const fU=Mo(uA,{isDisplayOnly:!0,needsFormItemName:!1}),dA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Input.TextArea,{disabled:e,placeholder:t.placeholder,rows:6,value:n,onChange:i=>r==null?void 0:r(i.target.value),id:o});dA.displayName="JsonFieldControl";const hU=ft(dA,{needsFormItemName:!0}),fA=({field:t,value:e})=>h.jsx("span",{children:e||t.placeholder||t.defaultValue});fA.displayName="LabelFieldControl";const pU=ft(fA,{needsFormItemName:!0}),hA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Cascader,{disabled:e,placeholder:t.placeholder,options:t.options,changeOnSelect:t.changeOnSelect,multiple:t.multiple||void 0,showSearch:t.showSearch,value:n,onChange:(i,s)=>r==null?void 0:r(i),id:o});hA.displayName="CascaderFieldControl";const mU=ft(hA,{needsFormItemName:!0}),pA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Checkbox,{disabled:e,checked:n,onChange:i=>r==null?void 0:r(i.target.checked),id:o,children:t.placeholder});pA.displayName="CheckboxFieldControl";const gU=ft(pA,{needsFormItemName:!0,valuePropName:"checked"}),mA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Checkbox.Group,{disabled:e,options:t.options,value:n,onChange:i=>r==null?void 0:r(i)});mA.displayName="CheckboxGroupFieldControl";const wU=ft(mA,{needsFormItemName:!0}),gA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Radio.Group,{disabled:e,options:t.options,optionType:t.optionType,buttonStyle:t.buttonStyle,value:n,onChange:i=>r==null?void 0:r(i.target.value),id:o});gA.displayName="RadioFieldControl";const bU=ft(gA,{needsFormItemName:!0}),wA=({field:t,disabled:e,context:n,value:r,onChange:o,id:i})=>{const{values:s,optionsLoader:a}=n,[l,c]=y.useState(bA(t)),[u,d]=y.useState(!1),f=t.type===ge.MULTI_SELECT||t.mode==="multiple",p=w=>!w||w.kind==="static"?[]:w.deps||[],m=y.useMemo(()=>{const g=p(t.optionsSource).map(C=>qn(s,C));return JSON.stringify(g)},[t.optionsSource,s]);y.useEffect(()=>{if(!t.optionsSource||t.optionsSource.kind==="static"){c(bA(t));return}const w=t.optionsSource;if(!a){c(w.fallbackOptions||t.options||[]);return}const C=p(w).reduce((x,D)=>(x[D]=qn(s,D),x),{}),S={...w.params||{},deps:C};d(!0);let k=!1;return a(w.action,S,{values:s}).then(x=>{k||c(x)}).catch(()=>{k||c(w.fallbackOptions||t.options||[])}).finally(()=>{k||d(!1)}),()=>{k=!0}},[m,t.optionsSource,t.options]);const b=()=>{var w;(w=n.eventHandlers)==null||w.onBlur(t.name)},v=()=>{var w;(w=n.eventHandlers)==null||w.onFocus(t.name)};return h.jsx(_.Select,{disabled:e,placeholder:t.placeholder,options:l,mode:f?"multiple":t.mode,showSearch:t.showSearch,allowClear:t.allowClear,maxTagCount:t.maxTagCount,loading:u,value:r,onChange:o,onBlur:b,onFocus:v,id:i})};wA.displayName="SelectFieldControl";function bA(t){var n;if((n=t.options)!=null&&n.length)return t.options;const e=t.optionsSource;return e?e.kind==="static"?e.items||[]:e.fallbackOptions||[]:[]}const vA=ft(wA,{supportsVariableInsert:!1,needsFormItemName:!0}),yA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Switch,{disabled:e,checkedChildren:t.checkedChildren,unCheckedChildren:t.unCheckedChildren,checked:n,onChange:r,id:o});yA.displayName="SwitchFieldControl";const vU=ft(yA,{needsFormItemName:!0,valuePropName:"checked"}),CA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.TreeSelect,{disabled:e,placeholder:t.placeholder,treeData:t.options,multiple:t.multiple,showSearch:t.showSearch,allowClear:t.allowClear,treeCheckable:t.treeCheckable,value:n,onChange:r,id:o});CA.displayName="TreeSelectFieldControl";const yU=ft(CA,{needsFormItemName:!0}),kA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.AutoComplete,{disabled:e,placeholder:t.placeholder,options:t.options,allowClear:t.allowClear,value:n,onChange:r,id:o});kA.displayName="AutoCompleteFieldControl";const CU=ft(kA,{needsFormItemName:!0}),SA=({disabled:t,value:e,onChange:n})=>h.jsx(_.ColorPicker,{disabled:t,value:e,onChange:(r,o)=>n==null?void 0:n(o)});SA.displayName="ColorPickerFieldControl";const kU=ft(SA,{needsFormItemName:!0}),EA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Mentions,{disabled:e,placeholder:t.placeholder,value:n,onChange:r,id:o});EA.displayName="MentionsFieldControl";const SU=ft(EA,{needsFormItemName:!0}),xA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Rate,{disabled:e,count:t.count,allowHalf:t.allowHalf,value:n,onChange:r,id:o});xA.displayName="RateFieldControl";const EU=ft(xA,{needsFormItemName:!0}),DA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Slider,{disabled:e,min:t.min,max:t.max,step:t.step,marks:t.marks,range:t.range,value:n,onChange:i=>r==null?void 0:r(i),id:o});DA.displayName="SliderFieldControl";const xU=ft(DA,{needsFormItemName:!0}),_A=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Upload,{disabled:e,accept:t.accept,maxCount:t.maxCount,listType:t.listType||"text",action:t.action,multiple:t.multiple,fileList:n,onChange:r,id:o,children:h.jsx(_.Button,{icon:h.jsx(ie.UploadOutlined,{}),disabled:e,children:"上传文件"})});_A.displayName="UploadFieldControl";const DU=ft(_A,{needsFormItemName:!0});function AA(t=Mc){t.register(ge.TEXT,q7),t.register(ge.TEXTAREA,U7),t.register(ge.NUMBER,j7),t.register(ge.PASSWORD,W7),t.register(ge.SELECT,vA),t.register(ge.MULTI_SELECT,vA),t.register(ge.RADIO,bU),t.register(ge.CHECKBOX,gU),t.register(ge.CHECKBOX_GROUP,wU),t.register(ge.SWITCH,vU),t.register(ge.CASCADER,mU),t.register(ge.TREE_SELECT,yU),t.register(ge.DATE,tU),t.register(ge.DATETIME,iU),t.register(ge.DATE_RANGE,rU),t.register(ge.TIME,aU),t.register(ge.TIME_RANGE,cU),t.register(ge.UPLOAD,DU),t.register(ge.RATE,EU),t.register(ge.SLIDER,xU),t.register(ge.COLOR_PICKER,kU),t.register(ge.MENTIONS,SU),t.register(ge.AUTO_COMPLETE,CU),t.register(ge.LABEL,pU),t.register(ge.HIDDEN,dU),t.register(ge.JSON,hU),t.register(ge.DIVIDER,uU),t.register(ge.INFO_CARD,fU),t.register(ge.ARRAY,R7),t.register(ge.OBJECT,DW),t.register(ge.KEY_VALUE,kW),t.register(ge.ARRAY_OBJECT,lW)}AA();const Gg=({field:t,disabled:e,required:n,readOnly:r,rules:o,values:i,optionsLoader:s,validateVariable:a,renderVariableTag:l,renderVariableTooltip:c,eventHandlers:u})=>{const d=Ic(),f=e??As(t.disabled,i,!1),p=n??As(t.required,i,!1),m=r??As(t.readOnly,i,!1),b=o??Ei(t.rules||[],i,t.type),v={values:i,optionsLoader:s,validateVariable:a,renderVariableTag:l,renderVariableTooltip:c,eventHandlers:u},w=d.get(t.type);if(!w)return h.jsxs("span",{children:["不支持的字段类型: ",t.type]});const{component:g,meta:C}=w;return C.isDisplayOnly?h.jsx(g,{field:t,disabled:f,readOnly:m,context:v}):C.isComplexField?h.jsx(_.Form.Item,{label:t.label,tooltip:t.tooltip,extra:t.helpText||t.extra||t.description,required:p,labelCol:t.labelCol,wrapperCol:t.wrapperCol,colon:t.colon,children:h.jsx(g,{field:t,disabled:f,readOnly:m,context:v})}):C.isHidden?h.jsx(_.Form.Item,{name:C.needsFormItemName!==!1?t.name:void 0,hidden:!0,rules:b,valuePropName:C.valuePropName,validateTrigger:t.validateTrigger,children:h.jsx(g,{field:t,disabled:f,readOnly:m,context:v})}):h.jsx(_.Form.Item,{name:C.needsFormItemName!==!1?t.name:void 0,label:t.label,tooltip:t.tooltip,extra:t.helpText||t.extra||t.description,required:p,rules:b,labelCol:t.labelCol,wrapperCol:t.wrapperCol,colon:t.colon,valuePropName:C.valuePropName,validateTrigger:t.validateTrigger,children:h.jsx(g,{field:t,disabled:f,readOnly:m,context:v})})},_U=Object.freeze(Object.defineProperty({__proto__:null,FieldRenderer:Gg},Symbol.toStringTag,{value:"Module"})),AU={meta:{name:"antd-5x-apple-pixel-aligned-full",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#007AFF",colorInfo:"#007AFF",colorSuccess:"#34C759",colorWarning:"#FF9F0A",colorError:"#FF3B30",colorTextBase:"#0B0B0F",colorBgBase:"#FFFFFF",colorBorder:"#D1D1D6",colorBorderSecondary:"#E5E5EA",colorPrimaryBorder:"#007AFF",colorPrimaryBorderHover:"#007AFF",colorPrimaryHover:"#0066D6",colorPrimaryActive:"#0056B3",controlOutlineWidth:2,controlOutline:"rgba(0, 122, 255, 0.25)",fontFamily:'"SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.6,borderRadius:10,borderRadiusSM:8,borderRadiusLG:12,lineWidth:1,lineType:"solid",controlHeight:44,controlHeightSM:36,controlHeightLG:52,sizeUnit:4,sizeStep:4,padding:16,paddingXS:10,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:10,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 10px 24px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08)",boxShadowSecondary:"0 6px 16px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06)",boxShadowTertiary:"0 2px 8px rgba(0,0,0,0.08)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:12},Anchor:{linkPaddingInlineStart:16},AutoComplete:{controlHeight:44,controlHeightSM:36,controlHeightLG:52},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:999,borderRadiusSM:999,borderRadiusLG:999,controlHeight:44,controlHeightSM:36,controlHeightLG:52,paddingInline:18,paddingInlineLG:20,paddingInlineSM:14,contentFontSize:14,contentFontSizeLG:16,contentFontSizeSM:14,primaryShadow:"0 2px 0 rgba(0,122,255,0.14)",dangerShadow:"0 2px 0 rgba(255,59,48,0.12)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24,borderRadiusLG:14},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:6},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:52,activeBorderColor:"#007AFF",activeShadow:"0 0 0 2px rgba(0, 122, 255, 0.25)"},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:44,controlHeightLG:52,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:44,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:44,controlHeightSM:36,controlHeightLG:52,paddingInline:14,paddingInlineSM:12,paddingInlineLG:14,paddingBlock:10,paddingBlockSM:8,paddingBlockLG:12,borderRadius:10,hoverBorderColor:"#C7C7CC",activeBorderColor:"#007AFF",activeShadow:"0 0 0 2px rgba(0, 122, 255, 0.25)"},InputNumber:{controlHeight:44,controlHeightSM:36,controlHeightLG:52},Layout:{headerBg:"#FFFFFF",headerHeight:64,headerPadding:"0 50px",bodyBg:"#F2F2F7",siderBg:"#FFFFFF",triggerBg:"#F2F2F7"},List:{itemPadding:"12px 0"},Mentions:{controlHeight:44,controlHeightSM:36,controlHeightLG:52},Menu:{itemHeight:44,iconSize:16,collapsedIconSize:18,horizontalItemBorderRadius:10,itemBorderRadius:10},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16,borderRadiusLG:14},Notification:{},Pagination:{itemSize:44,itemSizeSM:36},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{buttonSolidCheckedBg:"#007AFF"},Rate:{},Result:{},Segmented:{controlHeight:36},Select:{controlHeight:44,controlHeightSM:36,controlHeightLG:52,multipleItemHeight:28,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:24,trackMinWidth:44,handleSize:20},Table:{headerBg:"#F2F2F7",headerSortActiveBg:"#EDEDF2",headerSortHoverBg:"#F2F2F7",rowHoverBg:"#F2F2F7",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:4,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 16px"},Tag:{borderRadiusSM:8},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:52,activeBorderColor:"#007AFF",activeShadow:"0 0 0 2px rgba(0, 122, 255, 0.25)"},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:36,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}},OU={meta:{name:"antd-5x-google-material3-aligned-full",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#1A73E8",colorInfo:"#1A73E8",colorSuccess:"#34A853",colorWarning:"#FBBC04",colorError:"#EA4335",colorTextBase:"#202124",colorBgBase:"#FFFFFF",colorBorder:"#DADCE0",colorBorderSecondary:"#E0E3E7",colorPrimaryBorder:"#1A73E8",colorPrimaryBorderHover:"#1A73E8",colorPrimaryHover:"#1967D2",colorPrimaryActive:"#174EA6",controlOutlineWidth:2,controlOutline:"rgba(26, 115, 232, 0.24)",fontFamily:'"Google Sans", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.5714285714285714,borderRadius:8,borderRadiusSM:4,borderRadiusLG:12,lineWidth:1,lineType:"solid",controlHeight:56,controlHeightSM:40,controlHeightLG:64,sizeUnit:4,sizeStep:4,padding:16,paddingXS:8,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:8,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 1px 2px rgba(60,64,67,0.16), 0 2px 6px rgba(60,64,67,0.12)",boxShadowSecondary:"0 2px 8px rgba(60,64,67,0.14)",boxShadowTertiary:"0 1px 3px rgba(60,64,67,0.12)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:12},Anchor:{linkPaddingInlineStart:16},AutoComplete:{controlHeight:56,controlHeightSM:40,controlHeightLG:64},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:999,borderRadiusSM:999,borderRadiusLG:999,controlHeight:40,controlHeightSM:32,controlHeightLG:48,paddingInline:24,paddingInlineLG:24,paddingInlineSM:16,contentFontSize:14,contentFontSizeLG:14,contentFontSizeSM:14,primaryShadow:"0 1px 0 rgba(26,115,232,0.20)",dangerShadow:"0 1px 0 rgba(234,67,53,0.18)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24,borderRadiusLG:12},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:4},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:56,controlHeightSM:40,controlHeightLG:64,activeBorderColor:"#1A73E8",activeShadow:"0 0 0 2px rgba(26, 115, 232, 0.24)"},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:40,controlHeightLG:48,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:40,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:56,controlHeightSM:40,controlHeightLG:64,paddingInline:16,paddingInlineSM:12,paddingInlineLG:16,paddingBlock:14,paddingBlockSM:8,paddingBlockLG:16,borderRadius:4,hoverBorderColor:"#BDC1C6",activeBorderColor:"#1A73E8",activeShadow:"0 0 0 2px rgba(26, 115, 232, 0.24)"},InputNumber:{controlHeight:56,controlHeightSM:40,controlHeightLG:64},Layout:{headerBg:"#202124",headerHeight:64,headerPadding:"0 50px",bodyBg:"#F8F9FA",siderBg:"#202124",triggerBg:"#303134"},List:{itemPadding:"12px 0"},Mentions:{controlHeight:56,controlHeightSM:40,controlHeightLG:64},Menu:{itemHeight:40,iconSize:14,collapsedIconSize:16,horizontalItemBorderRadius:12,itemBorderRadius:12},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16,borderRadiusLG:16},Notification:{},Pagination:{itemSize:40,itemSizeSM:32},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{buttonSolidCheckedBg:"#1A73E8"},Rate:{},Result:{},Segmented:{controlHeight:40},Select:{controlHeight:56,controlHeightSM:40,controlHeightLG:64,multipleItemHeight:28,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:24,trackMinWidth:44,handleSize:20},Table:{headerBg:"#F8F9FA",headerSortActiveBg:"#F1F3F4",headerSortHoverBg:"#F3F5F6",rowHoverBg:"#F8F9FA",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:4,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 18px"},Tag:{borderRadiusSM:8},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:56,controlHeightSM:40,controlHeightLG:64,activeBorderColor:"#1A73E8",activeShadow:"0 0 0 2px rgba(26, 115, 232, 0.24)"},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:32,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}},TU={meta:{name:"antd-5x-preline-pixel-aligned-full",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#2563EB",colorInfo:"#2563EB",colorSuccess:"#16A34A",colorWarning:"#F59E0B",colorError:"#EF4444",colorTextBase:"#0F172A",colorBgBase:"#FFFFFF",colorBorder:"#E5E7EB",colorBorderSecondary:"#E5E7EB",colorPrimaryBorder:"#3B82F6",colorPrimaryBorderHover:"#3B82F6",colorPrimaryHover:"#1D4ED8",colorPrimaryActive:"#1E40AF",controlOutlineWidth:1,controlOutline:"rgba(59, 130, 246, 0.45)",fontFamily:'Graphik, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.6,borderRadius:8,borderRadiusSM:6,borderRadiusLG:12,lineWidth:1,lineType:"solid",controlHeight:44,controlHeightSM:36,controlHeightLG:48,sizeUnit:4,sizeStep:4,padding:16,paddingXS:8,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:8,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 1px 2px rgba(15,23,42,0.06), 0 6px 18px rgba(15,23,42,0.08)",boxShadowSecondary:"0 1px 2px rgba(15,23,42,0.05), 0 10px 24px rgba(15,23,42,0.10)",boxShadowTertiary:"0 1px 2px rgba(15,23,42,0.06)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:12},Anchor:{linkPaddingInlineStart:16},AutoComplete:{controlHeight:44,controlHeightSM:36,controlHeightLG:48},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:8,borderRadiusSM:8,borderRadiusLG:10,controlHeight:44,controlHeightSM:36,controlHeightLG:48,paddingInline:16,paddingInlineLG:18,paddingInlineSM:12,contentFontSize:14,contentFontSizeLG:14,contentFontSizeSM:14,primaryShadow:"0 1px 0 rgba(37,99,235,0.18)",dangerShadow:"0 1px 0 rgba(239,68,68,0.16)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24,borderRadiusLG:12},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:6},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:48,activeBorderColor:"#3B82F6",activeShadow:"0 0 0 1px rgba(59, 130, 246, 0.45)"},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:40,controlHeightLG:48,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:36,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:44,controlHeightSM:36,controlHeightLG:48,paddingInline:16,paddingInlineSM:12,paddingInlineLG:16,paddingBlock:10,paddingBlockSM:8,paddingBlockLG:10,borderRadius:8,hoverBorderColor:"#D1D5DB",activeBorderColor:"#3B82F6",activeShadow:"0 0 0 1px rgba(59, 130, 246, 0.45)"},InputNumber:{controlHeight:44,controlHeightSM:36,controlHeightLG:48},Layout:{headerBg:"#0B1220",headerHeight:64,headerPadding:"0 50px",bodyBg:"#F8FAFC",siderBg:"#0B1220",triggerBg:"#0F1A2E"},List:{itemPadding:"12px 0"},Mentions:{controlHeight:44,controlHeightSM:36,controlHeightLG:48},Menu:{itemHeight:40,iconSize:14,collapsedIconSize:16,horizontalItemBorderRadius:8,itemBorderRadius:8},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16,borderRadiusLG:12},Notification:{},Pagination:{itemSize:36,itemSizeSM:32},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{},Rate:{},Result:{},Segmented:{controlHeight:36},Select:{controlHeight:44,controlHeightSM:36,controlHeightLG:48,multipleItemHeight:28,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:22,trackMinWidth:44,handleSize:18},Table:{headerBg:"#F8FAFC",headerSortActiveBg:"#F1F5F9",headerSortHoverBg:"#F3F6FB",rowHoverBg:"#F8FAFC",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:6,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 16px"},Tag:{borderRadiusSM:6},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:48,activeBorderColor:"#3B82F6",activeShadow:"0 0 0 1px rgba(59, 130, 246, 0.45)"},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:32,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}};function NU(t){return"optionsSource"in t&&t.optionsSource&&t.optionsSource.kind!=="static"?t.optionsSource.deps||[]:[]}function BU(t){const e=[];for(const n of t.fields){const r=NU(n);if(r.length>0)for(const o of r)e.push({id:`auto-clear-${n.name}-on-${o}-change`,trigger:{type:"fieldChange",field:o},actions:[{type:"clearFields",targets:[n.name]}]})}return e}function FU(t,e,n=!0){return[...n?BU(t):[],...e||[]]}const MU={default:Bh,apple:AU,google:OU,preline:TU};function Rg({schema:t,disabled:e=!1,initialValues:n,onSubmit:r,onChange:o,onValuesObserved:i,submitLabel:s="提交",showReset:a=!1,resetLabel:l="重置",onReset:c,form:u,showSubmit:d=!0,optionsLoader:f,nodeId:p,mcpMode:m,validateVariable:b,renderVariableTag:v,renderVariableTooltip:w,availableVariables:g,theme:C,customTheme:S,locale:k,prefixCls:x,events:D,customHandlers:E,maxExecutionDepth:O,debugEvents:A,preRender:T}){var Y;const[B]=_.Form.useForm(),M=u||B,F=vt.useMemo(()=>{const W={};for(const X of t.fields)X.defaultValue!==void 0&&(W[X.name]=X.defaultValue);return{...W,...n||{}}},[t.fields,n]),N=vt.useMemo(()=>{const W=t.enableAutoEvents!==!1,X=t.events||[],re=D||[];return FU(t,[...X,...re],W)},[t,D]),P=h2({events:N,form:M,optionsLoader:f,customHandlers:E,maxExecutionDepth:O,debug:A}),I=vt.useRef({}),z=vt.useMemo(()=>{if(S)return S;if(C)return MU[C]},[S,C]),H=_.Form.useWatch([],M),J=vt.useMemo(()=>JSON.stringify({...F||{},...H||{}}),[F,H]),K=vt.useMemo(()=>({...F||{},...H||{}}),[J]),ee=vt.useRef(J);vt.useEffect(()=>{!i||ee.current===J||(ee.current=J,i(K))},[i,K,J]);const[$,U]=vt.useState({}),R=vt.useRef({});vt.useEffect(()=>{var X;const W={};for(const re of t.fields){const Z=yl(re,K);if(W[re.name]=Z,R.current[re.name]===!0&&Z===!1){const ve=$7(re),we=((X=re.visibleWhen)==null?void 0:X.clearOnHide)??!0;ve==="unregister"&&M.setFieldValue(re.name,we?void 0:M.getFieldValue(re.name))}}R.current=W,U(re=>{const Z=Object.keys(re),de=Object.keys(W);return Z.length===de.length&&de.every(ve=>re[ve]===W[ve])?re:W})},[t.fields,M,K]);const te=async W=>{const X=t.pruneInvisibleOnSubmit===!1?W:H7(t,W,$);await(r==null?void 0:r(X))},se=(W,X)=>{if(o==null||o(W,X),P.triggerFieldChange&&W){const re=I.current;for(const Z in W){const de=qn(re,Z),ve=W[Z];P.triggerFieldChange(Z,ve,de)}}I.current={...X}},be=d||a,j=vt.useMemo(()=>({nodeId:p,mcpMode:m,validateVariable:b,renderVariableTag:v,renderVariableTooltip:w,availableVariables:g}),[p,m,b,v,w,g]);return h.jsx(oC,{customTheme:z,locale:k,prefixCls:x,children:h.jsx(lC,{value:j,children:h.jsxs(_.Form,{form:M,disabled:e,autoComplete:"off",layout:t.layout||"vertical",labelCol:t.labelCol,wrapperCol:t.wrapperCol,colon:t.colon,size:t.size,initialValues:F,onFinish:te,onValuesChange:se,className:"workflow-config-form",children:[T&&T,t.fields.map(W=>{if(!yl(W,K))return null;const re=e||As(W.disabled,K,!1),Z=As(W.required,K,!1),de=Ei(W.rules||[],K,W.type),ve=(W.rules||[]).some(fe=>fe.type==="required"),we=Z&&!ve?[qg(`${W.label||W.name}为必填项`),...de]:de;return h.jsx(Gg,{field:W,disabled:re,required:Z,rules:we,values:K,optionsLoader:f,validateVariable:b,renderVariableTag:v,renderVariableTooltip:w,eventHandlers:P.fieldEventHandlers},W.name)}),be&&h.jsx(_.Form.Item,{wrapperCol:{offset:((Y=t.labelCol)==null?void 0:Y.span)||0},children:h.jsxs(_.Space,{children:[a&&h.jsx(_.Button,{disabled:e,onClick:()=>{M.resetFields(),c==null||c()},children:l}),d&&h.jsx(_.Button,{type:"primary",htmlType:"submit",children:s})]})})]})})})}const Sl=()=>{const t=Pt();return y.useCallback((e,n=!1)=>{if(/^https?:\/\//i.test(e)){window.open(e,"_blank");return}if(t.onNavigate){t.onNavigate(e,n);return}n?window.open(e,"_blank"):ac.push(e)},[t.onNavigate])},Kg=y.forwardRef((t,e)=>{const n=Sl(),[r,o]=y.useState([]),[i,s]=y.useState("");y.useEffect(()=>{s(t.proxyId)},[t.proxyId]),y.useEffect(()=>{qf().then(c=>{o(c??[])})},[]);const a=()=>i;y.useImperativeHandle(e,()=>({getProxyId:a}));const l=c=>{s(c)};return h.jsxs(WB,{label:G("link.flow.use_proxy_gateway"),children:[h.jsxs(_.Select,{className:"proxy_id_select",value:i,dropdownStyle:{zIndex:Bc.nestedPopover},onChange:l,style:{width:"100%"},children:[h.jsx(_.Select.Option,{value:"0",children:h.jsx(Te.FormattedMessage,{id:"link.flow.do_not_use"})}),r.map(c=>h.jsx(_.Select.Option,{value:c.id,children:c.group_name},c.id))]}),h.jsxs("p",{className:"field-desc",children:[h.jsx(Te.FormattedMessage,{id:"link.flow.private_network_deployment"}),h.jsx("span",{style:{margin:"0 2px"},onClick:()=>{n("/setting/gateway")},children:h.jsx(Te.FormattedMessage,{id:"link.flow.proxy_gateway"})}),h.jsx(Te.FormattedMessage,{id:"link.flow.secure_connection"})]})]})}),IU="RDBMS_ACCOUNT",PU=t=>t===IU,OA=({formSchema:t,initialValues:e,connector:n,proxy_id:r,authType:o,onCancel:i,onSubmit:s})=>{const[a]=_.Form.useForm(),l=y.useRef(null),c=(n==null?void 0:n.deployment_type)!=="SaasApp",u=PU(o);y.useEffect(()=>{e&&a.setFieldsValue(e)},[a,e]);const d=async f=>{var m;const p=await a.validateFields();c&&(p.proxy_id=(m=l.current)==null?void 0:m.getProxyId()),s(p,f)};return h.jsxs("div",{className:Gr.formLayout,children:[h.jsxs("div",{className:Gr.formContent,children:[h.jsx(Rg,{schema:t,form:a,initialValues:e,showSubmit:!1,showReset:!1,customTheme:sc}),c?h.jsx(Kg,{proxyId:r||"0",ref:l}):null]}),h.jsx("div",{className:Gr.formActions,children:h.jsxs(_.Space,{children:[h.jsx(_.Button,{onClick:i,children:"取消"}),u?h.jsx(_.Button,{onClick:()=>d(!0),children:"测试连接"}):null,h.jsx(_.Button,{type:"primary",onClick:()=>d(!1),children:"保存"})]})})]})},LU=t=>h.jsx(_.DatePicker,{style:{width:"100%"},picker:"date",value:Ht(t.value?t.value:new Date),onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD")))}}),$U=t=>h.jsx(_.DatePicker,{style:{width:"100%"},picker:"date",showTime:!0,value:Ht(t.value?t.value:new Date),onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD hh:mm:ss")))}}),zU=({value:t=[],onChange:e,valueType:n})=>{const r=a=>{const l=[...t];l.splice(a,1),e==null||e(l)},o=()=>{e==null||e([...t,{key:"",value:""}])},i=(a,l)=>{e==null||e(t.map((c,u)=>u===a?{...c,key:l}:c))},s=(a,l)=>{e==null||e(t.map((c,u)=>u===a?{...c,value:l}:c))};return h.jsxs("div",{children:[t.map((a,l)=>h.jsxs(_.Space,{size:"small",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[h.jsx(_.Input,{value:a.key,onChange:c=>i(l,c.target.value),placeholder:"Key"}),h.jsx(_.Input,{placeholder:"Value",style:{width:300},value:a.value,onChange:c=>s(l,c.target.value)}),h.jsx(_.Button,{icon:h.jsx(xi,{size:16}),onClick:()=>{r(l)}})]},a.key)),h.jsxs(_.Button,{type:"default",onClick:o,block:!0,children:[h.jsx(br,{size:16})," ",h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})]})]})},HU=t=>null;class Pd{constructor(e,n,r,o,i,s,a,l,c,u=0,d){this.p=e,this.stack=n,this.state=r,this.reducePos=o,this.pos=i,this.score=s,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=d}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let o=e.parser.context;return new Pd(e,[],n,r,r,0,[],0,o?new TA(o,o.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,o=e&65535,{parser:i}=this.p,s=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=i.dynamicPrecedence(o);if(a&&(this.score+=a),r==0){this.pushState(i.getGoto(this.state,o,!0),this.reducePos),o<i.minRepeatTerm&&this.storeNode(o,this.reducePos,this.reducePos,s?8:4,!0),this.reduceContext(o,this.reducePos);return}let l=this.stack.length-(r-1)*3-(e&262144?6:0),c=l?this.stack[l-2]:this.p.ranges[0].from,u=this.reducePos-c;u>=2e3&&!(!((n=this.p.parser.nodeSet.types[o])===null||n===void 0)&&n.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=u));let d=l?this.stack[l-1]:0,f=this.bufferBase+this.buffer.length-d;if(o<i.minRepeatTerm||e&131072){let p=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(o,c,p,f+4,!0)}if(e&262144)this.state=this.stack[l];else{let p=this.stack[l-3];this.state=i.getGoto(p,o,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(o,c)}storeNode(e,n,r,o=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this,a=this.buffer.length;if(a==0&&s.parent&&(a=s.bufferBase-s.parent.bufferBase,s=s.parent),a>0&&s.buffer[a-4]==0&&s.buffer[a-1]>-1){if(n==r)return;if(s.buffer[a-2]>=n){s.buffer[a-2]=r;return}}}if(!i||this.pos==r)this.buffer.push(e,n,r,o);else{let s=this.buffer.length;if(s>0&&(this.buffer[s-4]!=0||this.buffer[s-1]<0)){let a=!1;for(let l=s;l>0&&this.buffer[l-2]>r;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;s>0&&this.buffer[s-2]>r;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,o>4&&(o-=4)}this.buffer[s]=e,this.buffer[s+1]=n,this.buffer[s+2]=r,this.buffer[s+3]=o}}shift(e,n,r,o){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let i=e,{parser:s}=this.p;this.pos=o,!s.stateFlag(i,1)&&(o>r||n<=s.maxNode)&&(this.reducePos=o),this.pushState(i,Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=s.maxNode&&this.buffer.push(n,r,o,4)}else this.pos=o,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,o,4)}apply(e,n,r,o){e&65536?this.reduce(e):this.shift(e,n,r,o)}useNode(e,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let o=this.pos;this.reducePos=this.pos=o+e.length,this.pushState(n,o),this.buffer.push(r,o,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),o=e.bufferBase+n;for(;e&&o==e.bufferBase;)e=e.parent;return new Pd(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,o,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new VU(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if((r&65536)==0)return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let o=[];for(let i=0,s;i<n.length;i+=2)(s=n[i+1])!=this.state&&this.p.parser.hasAction(s,e)&&o.push(n[i],s);if(this.stack.length<120)for(let i=0;o.length<8&&i<n.length;i+=2){let s=n[i+1];o.some((a,l)=>l&1&&a==s)||o.push(n[i],s)}n=o}let r=[];for(let o=0;o<n.length&&r.length<4;o+=2){let i=n[o+1];if(i==this.state)continue;let s=this.split();s.pushState(i,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(n[o],this.pos),s.reducePos=this.pos,s.score-=200,r.push(s)}return r}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if((n&65536)==0)return!1;if(!e.validAction(this.state,n)){let r=n>>19,o=n&65535,i=this.stack.length-r*3;if(i<0||e.getGoto(this.stack[i],o,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;n=s}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(o,i)=>{if(!n.includes(o))return n.push(o),e.allActions(o,s=>{if(!(s&393216))if(s&65536){let a=(s>>19)-i;if(a>1){let l=s&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=r(s,i+1);if(a!=null)return a}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let n=new TA(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class TA{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class VU{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let o=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=o}}class Ld{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new Ld(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Ld(this.stack,this.pos,this.index)}}function $d(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,o=0;r<t.length;){let i=0;for(;;){let s=t.charCodeAt(r++),a=!1;if(s==126){i=65535;break}s>=92&&s--,s>=34&&s--;let l=s-32;if(l>=46&&(l-=46,a=!0),i+=l,a)break;i*=46}n?n[o++]=i:n=new e(i)}return n}class zd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const NA=new zd;class jU{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=NA,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,o=this.rangeIndex,i=this.pos+e;for(;i<r.from;){if(!o)return null;let s=this.ranges[--o];i-=r.from-s.to,r=s}for(;n<0?i>r.to:i>=r.to;){if(o==this.ranges.length-1)return null;let s=this.ranges[++o];i+=s.from-r.to,r=s}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,o;if(n>=0&&n<this.chunk.length)r=this.pos+e,o=this.chunk.charCodeAt(n);else{let i=this.resolveOffset(e,1);if(i==null)return-1;if(r=i,r>=this.chunk2Pos&&r<this.chunk2Pos+this.chunk2.length)o=this.chunk2.charCodeAt(r-this.chunk2Pos);else{let s=this.rangeIndex,a=this.range;for(;a.to<=r;)a=this.ranges[++s];this.chunk2=this.input.chunk(this.chunk2Pos=r),r+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-r)),o=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),o}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=r}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=NA,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let o of this.ranges){if(o.from>=n)break;o.to>e&&(r+=this.input.read(Math.max(o.from,e),Math.min(o.to,n)))}return r}}class Os{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;WU(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}Os.prototype.contextual=Os.prototype.fallback=Os.prototype.extend=!1,Os.prototype.fallback=Os.prototype.extend=!1;function WU(t,e,n,r,o,i){let s=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;(a&t[s])!=0;){let c=t[s+1];for(let p=s+3;p<c;p+=2)if((t[p+1]&a)>0){let m=t[p];if(l.allows(m)&&(e.token.value==-1||e.token.value==m||UU(m,e.token.value,o,i))){e.acceptToken(m);break}}let u=e.next,d=0,f=t[s+2];if(e.next<0&&f>d&&t[c+f*3-3]==65535){s=t[c+f*3-1];continue e}for(;d<f;){let p=d+f>>1,m=c+p+(p<<1),b=t[m],v=t[m+1]||65536;if(u<b)f=p;else if(u>=v)d=p+1;else{s=t[m+2],e.advance();continue e}}break}}function BA(t,e,n){for(let r=e,o;(o=t[r])!=65535;r++)if(o==n)return r-e;return-1}function UU(t,e,n,r){let o=BA(n,r,e);return o<0||BA(n,r,t)<o}const Pn=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG);let Yg=null;function FA(t,e,n){let r=t.cursor(Ct.IncludeAnonymous);for(r.moveTo(e);;)if(!(n<0?r.childBefore(e):r.childAfter(e)))for(;;){if((n<0?r.to<e:r.from>e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class qU{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?FA(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?FA(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let r=this.trees[n],o=this.index[n];if(o==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=r.children[o],s=this.start[n]+r.positions[o];if(s>e)return this.nextStart=s,null;if(i instanceof xt){if(s==e){if(s<this.safeFrom)return null;let a=s+i.length;if(a<=this.safeTo){let l=i.prop(Qe.lookAhead);if(!l||a+l<this.fragment.to)return i}}this.index[n]++,s+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(s),this.index.push(0))}else this.index[n]++,this.nextStart=s+i.length}}}class GU{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new zd)}getActions(e){let n=0,r=null,{parser:o}=e.p,{tokenizers:i}=o,s=o.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;c<i.length;c++){if((1<<c&s)==0)continue;let u=i[c],d=this.tokens[c];if(!(r&&!u.fallback)&&((u.contextual||d.start!=e.pos||d.mask!=s||d.context!=a)&&(this.updateCachedToken(d,u,e),d.mask=s,d.context=a),d.lookAhead>d.end+25&&(l=Math.max(d.lookAhead,l)),d.value!=0)){let f=n;if(d.extended>-1&&(n=this.addActions(e,d.extended,d.end,n)),n=this.addActions(e,d.value,d.end,n),!u.extend&&(r=d,n>f))break}}for(;this.actions.length>n;)this.actions.pop();return l&&e.setLookAhead(l),!r&&e.pos==this.stream.end&&(r=new zd,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new zd,{pos:r,p:o}=e;return n.start=r,n.end=Math.min(r+1,o.stream.end),n.value=r==o.stream.end?o.parser.eofTerm:0,n}updateCachedToken(e,n,r){let o=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(o,e),r),e.value>-1){let{parser:i}=r.p;for(let s=0;s<i.specialized.length;s++)if(i.specialized[s]==e.value){let a=i.specializers[s](this.stream.read(e.start,e.end),r);if(a>=0&&r.p.parser.dialect.allows(a>>1)){(a&1)==0?e.value=a>>1:e.extended=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(o+1)}putAction(e,n,r,o){for(let i=0;i<o;i+=3)if(this.actions[i]==e)return o;return this.actions[o++]=e,this.actions[o++]=n,this.actions[o++]=r,o}addActions(e,n,r,o){let{state:i}=e,{parser:s}=e.p,{data:a}=s;for(let l=0;l<2;l++)for(let c=s.stateSlot(i,l?2:1);;c+=3){if(a[c]==65535)if(a[c+1]==1)c=ro(a,c+2);else{o==0&&a[c+1]==2&&(o=this.putAction(ro(a,c+2),n,r,o));break}a[c]==n&&(o=this.putAction(ro(a,c+1),n,r,o))}return o}}class RU{constructor(e,n,r,o){this.parser=e,this.input=n,this.ranges=o,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new jU(n,o),this.tokens=new GU(e,this.stream),this.topTerm=e.top[1];let{from:i}=o[0];this.stacks=[Pd.start(this,e.top[0],i)],this.fragments=r.length&&this.stream.end-i>e.bufferLength*4?new qU(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,r=this.stacks=[],o,i;if(this.bigReductionCount>300&&e.length==1){let[s]=e;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<e.length;s++){let a=e[s];for(;;){if(this.tokens.mainToken=null,a.pos>n)r.push(a);else{if(this.advanceStack(a,r,e))continue;{o||(o=[],i=[]),o.push(a);let l=this.tokens.getMainToken(a);i.push(l.value,l.end)}}break}}if(!r.length){let s=o&&YU(o);if(s)return Pn&&console.log("Finish with "+this.stackID(s)),this.stackToTree(s);if(this.parser.strict)throw Pn&&o&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&o){let s=this.stoppedAt!=null&&o[0].pos>this.stoppedAt?o[0]:this.runRecovery(o,i,r);if(s)return Pn&&console.log("Force-finish "+this.stackID(s)),this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(r.length>s)for(r.sort((a,l)=>l.score-a.score);r.length>s;)r.pop();r.some(a=>a.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let s=0;s<r.length-1;s++){let a=r[s];for(let l=s+1;l<r.length;l++){let c=r[l];if(a.sameState(c)||a.buffer.length>500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)r.splice(l--,1);else{r.splice(s--,1);continue e}}}r.length>12&&(r.sort((s,a)=>a.score-s.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let s=1;s<r.length;s++)r[s].pos<this.minStackPos&&(this.minStackPos=r[s].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,r){let o=e.pos,{parser:i}=this,s=Pn?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&o>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let d=this.fragments.nodeAt(o);d;){let f=this.parser.nodeSet.types[d.type.id]==d.type?i.getGoto(e.state,d.type.id):-1;if(f>-1&&d.length&&(!c||(d.prop(Qe.contextHash)||0)==u))return e.useNode(d,f),Pn&&console.log(s+this.stackID(e)+` (via reuse of ${i.getName(d.type.id)})`),!0;if(!(d instanceof xt)||d.children.length==0||d.positions[0]>0)break;let p=d.children[0];if(p instanceof xt&&d.positions[0]==0)d=p;else break}}let a=i.stateSlot(e.state,4);if(a>0)return e.reduce(a),Pn&&console.log(s+this.stackID(e)+` (via always-reduce ${i.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;c<l.length;){let u=l[c++],d=l[c++],f=l[c++],p=c==l.length||!r,m=p?e:e.split(),b=this.tokens.mainToken;if(m.apply(u,d,b?b.start:m.pos,f),Pn&&console.log(s+this.stackID(m)+` (via ${(u&65536)==0?"shift":`reduce of ${i.getName(u&65535)}`} for ${i.getName(d)} @ ${o}${m==e?"":", split"})`),p)return!0;m.pos>o?n.push(m):r.push(m)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return MA(e,n),!0}}runRecovery(e,n,r){let o=null,i=!1;for(let s=0;s<e.length;s++){let a=e[s],l=n[s<<1],c=n[(s<<1)+1],u=Pn?this.stackID(a)+" -> ":"";if(a.deadEnd&&(i||(i=!0,a.restart(),Pn&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,r))))continue;let d=a.split(),f=u;for(let p=0;p<10&&d.forceReduce()&&(Pn&&console.log(f+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,r));p++)Pn&&(f=this.stackID(d)+" -> ");for(let p of a.recoverByInsert(l))Pn&&console.log(u+this.stackID(p)+" (via recover-insert)"),this.advanceFully(p,r);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),Pn&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),MA(a,r)):(!o||o.score<d.score)&&(o=d)}return o}stackToTree(e){return e.close(),xt.build({buffer:Ld.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let n=(Yg||(Yg=new WeakMap)).get(e);return n||Yg.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function MA(t,e){for(let n=0;n<e.length;n++){let r=e[n];if(r.pos==t.pos&&r.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class KU{constructor(e,n,r){this.source=e,this.flags=n,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}}class Hd extends EC{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let a=0;a<e.repeatNodeCount;a++)n.push("");let r=Object.keys(e.topRules).map(a=>e.topRules[a][1]),o=[];for(let a=0;a<n.length;a++)o.push([]);function i(a,l,c){o[a].push([l,l.deserialize(String(c))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=Qe[l]);for(let c=1;c<a.length;){let u=a[c++];if(u>=0)i(u,l,a[c++]);else{let d=a[c+-u];for(let f=-u;f>0;f--)i(a[c++],l,d);c++}}}this.nodeSet=new Lh(n.map((a,l)=>vn.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:o[l],top:r.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=wC;let s=$d(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(IA),this.states=$d(e.states,Uint32Array),this.data=$d(e.stateData),this.goto=$d(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Os(s,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let o=new RU(this,e,n,r);for(let i of this.wrappers)o=i(o,e,n,r);return o}getGoto(e,n,r=!1){let o=this.goto;if(n>=o[0])return-1;for(let i=o[n+1];;){let s=o[i++],a=s&1,l=o[i++];if(a&&r)return l;for(let c=i+(s>>1);i<c;i++)if(o[i]==e)return l;if(a)return-1}}hasAction(e,n){let r=this.data;for(let o=0;o<2;o++)for(let i=this.stateSlot(e,o?2:1),s;;i+=3){if((s=r[i])==65535)if(r[i+1]==1)s=r[i=ro(r,i+2)];else{if(r[i+1]==2)return ro(r,i+2);break}if(s==n||s==0)return ro(r,i+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),o=r?n(r):void 0;for(let i=this.stateSlot(e,1);o==null;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=ro(this.data,i+2);else break;o=n(ro(this.data,i+1))}return o}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=ro(this.data,r+2);else break;if((this.data[r+2]&1)==0){let o=this.data[r+1];n.some((i,s)=>s&1&&i==o)||n.push(this.data[r],o)}}return n}configure(e){let n=Object.assign(Object.create(Hd.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let o=e.tokenizers.find(i=>i.from==r);return o?o.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,o)=>{let i=e.specializers.find(a=>a.from==r.external);if(!i)return r;let s=Object.assign(Object.assign({},r),{external:i.to});return n.specializers[o]=IA(s),s})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let i of e.split(" ")){let s=n.indexOf(i);s>=0&&(r[s]=!0)}let o=null;for(let i=0;i<n.length;i++)if(!r[i])for(let s=this.dialects[n[i]],a;(a=this.data[s++])!=65535;)(o||(o=new Uint8Array(this.maxTerm+1)))[a]=1;return new KU(e,r,o)}static deserialize(e){return new Hd(e)}}function ro(t,e){return t[e]|t[e+1]<<16}function YU(t){let e=null;for(let n of t){let r=n.p.stoppedAt;(n.pos==n.p.stream.end||r!=null&&n.pos>r)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function IA(t){if(t.external){let e=t.extend?1:0;return(n,r)=>t.external(n,r)<<1|e}return t.get}const XU=xC({String:V.string,Number:V.number,"True False":V.bool,PropertyName:V.propertyName,Null:V.null,", :":V.separator,"[ ]":V.squareBracket,"{ }":V.brace}),JU=Hd.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[XU],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),QU=Au.define({name:"json",parser:JU.configure({props:[rS.add({Object:iS({except:/^\s*\}/}),Array:iS({except:/^\s*\]/})}),sS.add({"Object Array":o8})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function PA(){return new G3(QU)}const ZU=t=>h.jsx(td,{height:"300px",style:{borderRadius:4,overflow:"hidden"},theme:bm,extensions:[PA()],...t}),{Text:eq}=_.Typography,tq=t=>h.jsx("div",{style:{padding:6,paddingRight:0,border:"1px solid #b0b5cb",borderRadius:4},children:h.jsx(_.Tooltip,{title:t.value,color:"cyan",placement:"topLeft",styles:{body:{width:500}},children:h.jsx(eq,{style:{color:"#b0b5cb"},ellipsis:!0,copyable:{text:t.value},children:t.value})})}),nq=t=>h.jsx(_.Input.Password,{addonBefore:G("link.flow.cipherText"),value:t.value,onChange:e=>{var n;return(n=t.onChange)==null?void 0:n.call(t,e.target.value)}}),rq=t=>{var r;const{multiple:e,...n}=t;return h.jsx(_.Select,{style:{borderRadius:6},mode:e?"multiple":void 0,...n,getPopupContainer:o=>o.parentNode,children:(r=t==null?void 0:t.options)==null?void 0:r.map(o=>h.jsx(_.Select.Option,{label:o.label,value:o.value,children:o.label},o.value))})},{TextArea:oq}=_.Input,iq=t=>h.jsx(oq,{value:t.value,onChange:e=>{var n;return(n=t.onChange)==null?void 0:n.call(t,e.target.value)}}),sq=t=>h.jsx(_.Input,{addonBefore:G("link.flow.text"),value:t.value,onChange:e=>{var n;return(n=t.onChange)==null?void 0:n.call(t,e.target.value)}}),aq=t=>h.jsx(_.TimePicker,{style:{width:"100%"},value:Ht(t.value??"00:00:00","HH:mm:ss"),onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("HH:mm:ss")))}}),lq={configFormContainer:"_configFormContainer_s061b_1"},cq=t=>t?Object.keys(t).map(e=>({key:e,value:t[e]})):[],Xg=t=>Array.isArray(t)?t.map(e=>{if(typeof e=="string"){const s=e.trim();return s?{label:s,value:s}:null}const n=(e==null?void 0:e.value)??(e==null?void 0:e.label)??"",r=n==null?"":String(n).trim();if(!r)return null;const o=(e==null?void 0:e.label)??"";return{label:o==null?r:String(o).trim()||r,value:r}}).filter(Boolean):[],uq=t=>{const e=t.display_name;switch(t.page_control){case Ee.SELECT:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_select")+t.display_name}],label:e,name:t.name,children:h.jsx(rq,{options:Xg(t.option_value_objects??t.option_values),multiple:t.multi_valued})},t.ui_id);case Ee.EXTEND_OBJ:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(zU,{valueType:t.value_type})},t.ui_id);case Ee.HIDDEN:return h.jsx(_.Form.Item,{style:{display:"none"},required:t.required,label:e,name:t.name,children:h.jsx(HU,{})},t.ui_id);case Ee.TEXT:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(sq,{})},t.ui_id);case Ee.PASSWORD:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(nq,{})},t.ui_id);case Ee.LABEL:return h.jsx(_.Form.Item,{required:t.required,label:e,name:t.name,children:h.jsx(tq,{})},t.ui_id);case Ee.DATE:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(LU,{})},t.ui_id);case Ee.TIME:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(aq,{})},t.ui_id);case Ee.DATETIME:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx($U,{})},t.ui_id);case Ee.TEXTAREA:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(iq,{})},t.ui_id);case Ee.FIXED_OBJ:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(_.Input.TextArea,{})},t.ui_id);case Ee.JSON:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(ZU,{})},t.ui_id)}},dq=t=>{switch(t.page_control){case Ee.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.JSON:return JSON.stringify({})}},LA=y.memo(t=>{var c;const{config:e,proxy_id:n,connector:r}=t,[o]=_.Form.useForm(),i=y.useRef(null),s=St.useReactive({proxyId:"0"});y.useEffect(()=>{var u;(u=e==null?void 0:e.sub_params)!=null&&u.length&&o.setFieldsValue({...e.sub_params.reduce((d,f)=>{let p=f.value;return f.page_control===Ee.EXTEND_OBJ&&(p=cq(p)),d[f.name]=p??dq(f),d},{})})},[e,o]),y.useEffect(()=>{n&&(s.proxyId=n)},[n]);const a=()=>{o.validateFields().then(async u=>{var d;u.proxy_id=(d=i.current)==null?void 0:d.getProxyId(),t.onSubmit(u)})},l=()=>{o.validateFields().then(async u=>{var d;u.proxy_id=(d=i.current)==null?void 0:d.getProxyId(),t.onSubmit(u,!0)})};return h.jsxs("div",{className:Gr.formLayout,style:{position:"relative"},onClick:u=>{u.stopPropagation(),u.preventDefault()},children:[h.jsx("div",{className:Gr.formContent,children:h.jsxs(_.Form,{form:o,layout:"vertical",className:`${lq.configFormContainer} workflow-credential-form`,children:[(c=e==null?void 0:e.sub_params)==null?void 0:c.map(u=>h.jsxs("div",{children:[uq(u),u.page_control!==Ee.HIDDEN&&h.jsx("p",{className:"field-desc",children:u.description})]},u.ui_id)),r.deployment_type!=="SaasApp"?h.jsx(Kg,{proxyId:s.proxyId,ref:i}):null]})}),t.auth_type==="RDBMS_ACCOUNT"&&h.jsx("div",{className:Gr.rdbmsTestAction,children:h.jsx(_.Button,{type:"primary",style:{width:"100%"},onClick:l,children:h.jsx(Te.FormattedMessage,{id:"app.common.word.connection-test"})})}),h.jsxs("div",{className:Gr.formActions,children:[h.jsx(_.Button,{icon:h.jsx(ie.RollbackOutlined,{}),style:{width:90,borderRadius:4,marginRight:10},onClick:t.onCancel,children:h.jsx(Te.FormattedMessage,{id:"app.common.word.cancel"})}),h.jsx(_.Button,{type:"primary",icon:h.jsx(ie.CloudUploadOutlined,{}),style:{width:90,borderRadius:4},onClick:()=>a(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})]})]})}),fq={overflow:"hidden"},hq=72,pq=16,mq=t=>{const{visible:e,connector:n,config:r,formSchema:o,onCancel:i,onSubmit:s,auth_type:a,inAI:l}=t;return h.jsx(_.Modal,{title:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-account"}),style:{marginTop:0,paddingBottom:0,position:"absolute",top:hq,bottom:pq,left:12,right:12,maxWidth:"calc(100% - 24px)",marginInline:"auto"},className:Gr.accountModal,mask:!1,getContainer:()=>document.getElementById("flow-designer-container"),zIndex:Bc.nestedModal,width:560,styles:{body:fq},footer:null,maskClosable:!l,open:e,onCancel:i,children:o?h.jsx(OA,{formSchema:o,connector:n,authType:a,onCancel:i,onSubmit:s}):h.jsx(LA,{config:r,connector:n,nodeId:"",auth_type:a,onCancel:i,onSubmit:s})})},gq={overflow:"hidden"},wq=72,bq=16,vq=t=>{const{visible:e,connector:n,config:r,formSchema:o,initialValues:i,onCancel:s,onSubmit:a,auth_type:l,proxy_id:c,inAI:u}=t;return h.jsx(_.Modal,{title:G("link.flow.edit_account"),mask:!1,style:{marginTop:0,paddingBottom:0,position:"absolute",top:wq,bottom:bq,left:12,right:12,maxWidth:"calc(100% - 24px)",marginInline:"auto"},className:Gr.accountModal,getContainer:()=>document.getElementById("flow-designer-container"),zIndex:Bc.nestedModal,width:560,footer:null,styles:{body:gq},open:e,maskClosable:!u,onCancel:s,children:o?h.jsx(OA,{formSchema:o,initialValues:i,connector:n,proxy_id:c,authType:l,onCancel:s,onSubmit:a}):h.jsx(LA,{config:r,proxy_id:c,connector:n,nodeId:"",auth_type:l,onCancel:s,onSubmit:a})})},Di={accountOption:"_accountOption_4vdjt_14",accountName:"_accountName_4vdjt_21",nameEditIcon:"_nameEditIcon_4vdjt_34",editInputWrapper:"_editInputWrapper_4vdjt_44",nameEditInput:"_nameEditInput_4vdjt_48",accountActions:"_accountActions_4vdjt_53",updateTime:"_updateTime_4vdjt_58"},yq=t=>t?Object.keys(t).map(e=>({key:e,value:t[e]})):[],Jg=(t=[])=>{const e={};return t.forEach(n=>{e[n.key]=n.value}),e},Cq={eq:"EQ",ne:"NOT",in:"IN",notin:"NOT_IN",not_in:"NOT_IN",gt:"GT",lt:"LT",gte:"GE",lte:"LE"};function kq(t){if(!(t!=null&&t.field)||!t.operator)return;const e=Cq[String(t.operator).toLowerCase()];if(e)return{deps:[t.field],conditions:{key:t.field,keyword:e,value:t.value}}}function Sq(t){return an(t.visible_when)??kq(t.display_condition)}const $A={STRING:ge.TEXT,TEXTAREA:ge.TEXTAREA,PASSWORD:ge.PASSWORD,HIDDEN:ge.HIDDEN,NUMBER:ge.NUMBER,BOOLEAN:ge.SWITCH,SELECT:ge.SELECT,DATETIME:ge.DATETIME,CODE:ge.CODE,PROXY:ge.PROXY,OBJECT:ge.OBJECT,ARRAY:ge.ARRAY,DYNAMIC_ARRAY:ge.ARRAY,KEYVALUE:ge.KEY_VALUE},zA=t=>String(t.type??"").toUpperCase(),Eq=t=>t.item_schema??[],HA=t=>String(t.item_type??"").toUpperCase(),an=t=>t??void 0,xq=t=>Object.fromEntries((t??[]).map(e=>[e.key,Zg(e)])),Dq=t=>{const e=String(t.picker_mode??"DATETIME").toUpperCase();return e==="DATE"?ge.DATE:e==="TIME"?ge.TIME:ge.DATETIME},Qg=t=>{const e=String(t.picker_mode??"DATETIME").toUpperCase();return e==="DATE"?"YYYY-MM-DD":e==="TIME"?"HH:mm:ss":"YYYY-MM-DD HH:mm:ss"},_q=t=>({type:$A[HA(t)]||ge.TEXT,name:"item",label:t.item_label||"项"}),Aq=t=>t.some(e=>e.name==="name")?"name":void 0;function Oq(t){if(!t)return[];const e=[],n=t.minLength??t.min_length,r=t.maxLength??t.max_length;return n!=null&&e.push({type:"min",value:n,message:`最少 ${n} 个字符`}),r!=null&&e.push({type:"max",value:r,message:`最多 ${r} 个字符`}),t.pattern&&e.push({type:"pattern",value:t.pattern,message:"格式不正确"}),t.min!=null&&e.push({type:"min",value:t.min,message:`最小值 ${t.min}`}),t.max!=null&&e.push({type:"max",value:t.max,message:`最大值 ${t.max}`}),e}function Zg(t){var r,o,i;const e=zA(t)==="DATETIME"?Dq(t):$A[zA(t)]||ge.TEXT,n={type:e,name:t.key,label:t.label||t.key,placeholder:an(t.placeholder),helpText:an(t.help_text),defaultValue:an(t.default_value),required:an(t.required),disabled:an(t.disabled),visibleWhen:Sq(t),rules:Oq(t.validation),valueModePolicy:an(t.value_mode_policy)};switch(e){case ge.SELECT:return{...n,type:ge.SELECT,options:(r=t.options)==null?void 0:r.map(s=>({label:s.label,value:s.value})),showSearch:!0,allowClear:!0};case ge.NUMBER:return{...n,type:ge.NUMBER,min:an((o=t.validation)==null?void 0:o.min),max:an((i=t.validation)==null?void 0:i.max)};case ge.DATETIME:return{...n,type:ge.DATETIME,showTime:!0,format:Qg(t),outputFormat:"string"};case ge.DATE:return{...n,type:ge.DATE,format:Qg(t),outputFormat:"string"};case ge.TIME:return{...n,type:ge.TIME,format:Qg(t),outputFormat:"string"};case ge.OBJECT:return{...n,type:ge.OBJECT,properties:xq(t.properties)};case ge.ARRAY:if(HA(t)==="OBJECT"){const s=Eq(t).map(Zg);return{...n,type:ge.ARRAY_OBJECT,columns:s,minItems:an(t.min_items),maxItems:an(t.max_items),columnLayout:s.length>1?"grid":"vertical",titleFieldName:Aq(s)}}return{...n,type:ge.ARRAY,itemSchema:_q(t),minItems:an(t.min_items),maxItems:an(t.max_items),itemLabel:an(t.item_label)};case ge.KEY_VALUE:return{...n,type:ge.KEY_VALUE,keyPlaceholder:an(t.key_placeholder),valuePlaceholder:an(t.value_placeholder)};default:return n}}function VA(t){return{fields:t.map(Zg),layout:"vertical"}}const jA=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim())return e.trim()};function Tq(t){if(!t)return null;const e=jA(t.key,t.credentialKey,t.name);return e?{key:e,label:jA(t.displayName,t.label,t.name,e)??e,required:t.required===!0}:null}function ew(t){if(!Array.isArray(t))return[];const e=[],n=new Set;for(const r of t){const o=Tq(r);!o||n.has(o.key)||(n.add(o.key),e.push(o))}return e}function Nq(t){var n,r;const e=ew(t);return((n=e.find(o=>o.required))==null?void 0:n.key)??((r=e[0])==null?void 0:r.key)}const Bq=_.Form.Item,{Option:Fq}=_.Select,{Text:Mq,Title:dre}=_.Typography,Ts="[workflow:account-debug]",Iq=t=>!!(t&&/^\d+$/.test(t)),_i=t=>t&&typeof t=="object"&&!Array.isArray(t)?Object.keys(t):[],Pq=t=>Array.isArray(t)?t.map(e=>e==null?void 0:e.key).filter(Boolean):[],Lq=t=>!!(t&&typeof t=="object"&&Array.isArray(t.sub_params)),$q=t=>[t==null?void 0:t.auth_schema,t==null?void 0:t.config_schema,t==null?void 0:t.schema,t].find(Lq)??{},WA=t=>{var o,i,s,a,l;const e=(o=t==null?void 0:t.credential_schema)==null?void 0:o.fields,n=(i=t==null?void 0:t.auth_schema)==null?void 0:i.sub_params,r=((s=t==null?void 0:t.config_schema)==null?void 0:s.sub_params)??(t==null?void 0:t.sub_params);return{type:Array.isArray(t)?"array":t===null?"null":typeof t,keys:_i(t),id:t==null?void 0:t.id,auth_type:t==null?void 0:t.auth_type,account_key:(t==null?void 0:t.account_key)??((a=t==null?void 0:t.credential_schema)==null?void 0:a.key),account_ver:(t==null?void 0:t.account_ver)??((l=t==null?void 0:t.credential_schema)==null?void 0:l.version),credentialSchemaKeys:_i(t==null?void 0:t.credential_schema),credentialFieldCount:Array.isArray(e)?e.length:void 0,credentialFieldKeys:Pq(e),authSchemaKeys:_i(t==null?void 0:t.auth_schema),authSchemaSubParamCount:Array.isArray(n)?n.length:void 0,authSchemaSubParamNames:Array.isArray(n)?n.map(c=>c==null?void 0:c.name).filter(Boolean):void 0,configSchemaKeys:_i(t==null?void 0:t.config_schema),configSubParamCount:Array.isArray(r)?r.length:void 0}},tw=t=>({keys:_i(t),subParamCount:Array.isArray(t==null?void 0:t.sub_params)?t.sub_params.length:0,subParamNames:Array.isArray(t==null?void 0:t.sub_params)?t.sub_params.map(e=>e==null?void 0:e.name).filter(Boolean):[],subParamControls:Array.isArray(t==null?void 0:t.sub_params)?t.sub_params.map(e=>e==null?void 0:e.page_control).filter(Boolean):[]}),Vd=(t,e)=>{var n,r;return{account_key:(t==null?void 0:t.account_key)??((n=t==null?void 0:t.credential_schema)==null?void 0:n.key)??e??null,account_ver:(t==null?void 0:t.account_ver)??((r=t==null?void 0:t.credential_schema)==null?void 0:r.version)??null}},UA=t=>{const e=t==null?void 0:t.credential_schema,n=e==null?void 0:e.fields;return(!Array.isArray(n)||!n.length)&&console.warn(`${Ts} credential_schema.fields missing or empty`,{model:WA(t)}),Array.isArray(n)&&n.length?VA(n):null},zq=({value:t,onChange:e,linkApp:n,actionAccountSchemaId:r,selectTitle:o="授权配置",disabled:i=!1,placeholder:s="请选择账号"})=>{const[a,l]=y.useState([]),[c,u]=y.useState(!1),[d,f]=y.useState(!1),[p,m]=y.useState(!1),b=y.useRef(null),v=y.useRef(null),w=_.Form.useFormInstance(),g=y.useMemo(()=>r?`_account_${r}`:"_account",[r]);y.useEffect(()=>{w&&w.validateFields([g]).catch(()=>{})},[t,w,g]);const C=St.useReactive({createModalVisible:!1,modifyModalVisible:!1,configModel:{},credentialFormSchema:null,credentialInitialValues:{},schemaMeta:{},account_scheme_id:"",name:"",auth_type:"",modifyId:"",proxy_id:"",editId:"",editValue:"",createLoading:!1,createRequestLock:!1,isEditing:!1}),S=r==null?void 0:String(r),k=async()=>{if(!(!(n!=null&&n.id)&&!S)){u(!0);try{const I=Iq(S)?n==null?void 0:n.id:void 0,z=await Gy(I,S);z?l(z.items||[]):_.message.error("获取账号列表失败")}catch(I){console.error(`${Ts} 获取账号列表失败:`,I),_.message.error("获取账号列表失败")}finally{u(!1)}}};y.useEffect(()=>{k()},[n==null?void 0:n.id,S]),y.useEffect(()=>{C.editId&&b.current&&setTimeout(()=>{var I;(I=b.current)==null||I.focus()},100)},[C.editId]);const x=I=>{if(p){f(!0);return}f(I)},D=()=>{if(!C.editId||!C.editValue){C.editId="",C.isEditing=!1,m(!1);return}Hy(C.editId,C.editValue).then(()=>{k(),C.editId="",C.editValue="",C.isEditing=!1,m(!1),_.message.success(G("link.flow.modification_success"))}).catch(()=>{C.editId="",C.isEditing=!1,m(!1)})},E=(I,z,H)=>{I.stopPropagation(),I.preventDefault(),C.isEditing=!0,m(!0),f(!0),C.editId=z,C.editValue=H,setTimeout(()=>{v.current&&v.current.focus()},0)},O=I=>{I.stopPropagation(),I.preventDefault(),m(!0)},A=I=>{C.isEditing||e&&e(I)},T=()=>{if(!S){_.message.error("未配置账号模式");return}C.createLoading=!0,Kf(S).then(I=>{var K;const z=UA(I),H=Vd(I,S),J=z?{}:$q(I);z||console.warn(`${Ts} create modal will use legacy DynamicAccountForm`,{reason:"credentialFormSchema is null",model:WA(I),configModel:tw(J)}),C.credentialFormSchema=z,C.credentialInitialValues={},C.schemaMeta=H,C.configModel=J,C.account_scheme_id=I.id,C.name=I.name,C.auth_type=I.auth_type??((K=I.credential_schema)==null?void 0:K.type),C.createModalVisible=!0}).catch(I=>{console.error(`${Ts} account model load failed for create`,{schemaId:S,error:I})}).finally(()=>{C.createLoading=!1})},B=I=>{Ly(I).then(async z=>{var R;const H=z.account_schema_id,J=z.account_key,K=z.account_ver,ee=J??H??S;let $=null;if(ee)try{$=await Kf(String(ee),K)}catch(te){console.error("获取账号模型失败:",te)}const U=UA($);C.credentialFormSchema=U,C.credentialInitialValues=U?z.config??{}:{},C.schemaMeta={...Vd($,J??S),account_key:J??Vd($,S).account_key,account_ver:K??Vd($).account_ver},C.configModel=U?{}:z.config,C.account_scheme_id=H??($==null?void 0:$.id)??z.id,C.name=z.name,C.proxy_id=z.proxy_id,C.auth_type=z.auth_type??($==null?void 0:$.auth_type)??((R=$==null?void 0:$.credential_schema)==null?void 0:R.type)??"",C.modifyId=I,C.modifyModalVisible=!0})},M=y.useCallback((I,z)=>{if(C.createRequestLock)return;let H=I;if(!C.credentialFormSchema){if(H=Mt.cloneDeep(C.configModel),!Array.isArray(H==null?void 0:H.sub_params)){console.error(`${Ts} create account legacy config has no sub_params`,{configModel:tw(C.configModel),valueKeys:_i(I)}),_.message.error("账号模型配置为空,无法保存");return}H.sub_params.forEach(K=>{let ee=I[K.name];K.page_control===Ee.EXTEND_OBJ&&(ee=Jg(ee)),K.value=ee})}const J=I.proxy_id;delete I.proxy_id,C.createRequestLock=!0,z?Xf((n==null?void 0:n.id)??null,C.account_scheme_id,C.auth_type,C.name,H,C.modifyId,J,C.schemaMeta).then(K=>{K&&_.message.success("测试连接成功!")}).finally(()=>{C.createRequestLock=!1}):$y((n==null?void 0:n.id)??null,C.account_scheme_id,C.auth_type,C.name,H,J,C.schemaMeta).then(()=>{_.message.success(G("link.flow.creation_success")),k(),C.createModalVisible=!1}).finally(()=>{C.createRequestLock=!1})},[]),F=y.useCallback(()=>{C.createModalVisible=!1},[]),N=(I,z)=>{let H=I;if(!C.credentialFormSchema){if(H=Mt.cloneDeep(C.configModel),!Array.isArray(H==null?void 0:H.sub_params)){console.error(`${Ts} modify account legacy config has no sub_params`,{configModel:tw(C.configModel),valueKeys:_i(I)}),_.message.error("账号模型配置为空,无法保存");return}H.sub_params.forEach(K=>{let ee=I[K.name];K.page_control===Ee.EXTEND_OBJ&&(ee=Jg(ee)),K.value=ee})}const J=I.proxy_id;delete I.proxy_id,z?Xf((n==null?void 0:n.id)??null,C.account_scheme_id,C.auth_type,C.name,H,C.modifyId,J,C.schemaMeta).then(K=>{K&&_.message.success("测试连接成功!")}):zy(C.modifyId,null,null,null,null,H,J,C.schemaMeta).then(()=>{_.message.success(G("link.flow.modification_success")),k(),C.modifyModalVisible=!1,C.modifyId=""})},P=I=>h.jsxs("div",{children:[I,h.jsx(_.Divider,{style:{margin:"4px 0"}}),h.jsx("div",{style:{padding:"4px",textAlign:"center"},children:h.jsx(_.Button,{icon:h.jsx(ie.UserAddOutlined,{}),onClick:T,loading:C.createLoading,type:"link",block:!0,children:"创建新账号"})})]});return h.jsxs(h.Fragment,{children:[h.jsx(Bq,{label:o,layout:"vertical",required:!0,name:g,rules:[{validator:()=>t?Promise.resolve():Promise.reject(new Error(s||"请选择账号"))}],children:h.jsx(_.Select,{ref:v,value:t,onChange:A,style:{width:"100%"},placeholder:s,disabled:i,loading:c,allowClear:!0,popupRender:P,classNames:{popup:{root:"workflow-account-select__popup"}},listHeight:320,open:d,onOpenChange:x,children:a.map(I=>h.jsx(Fq,{value:I.id,children:h.jsxs("div",{className:Di.accountOption,onClick:z=>{C.isEditing&&z.stopPropagation()},children:[h.jsx("div",{className:`${Di.accountName} workflow-account-select__name`,children:C.editId!==I.id?h.jsxs(y.Fragment,{children:[h.jsx("span",{children:I.name}),h.jsx(ie.EditOutlined,{className:`${Di.nameEditIcon} workflow-account-select__edit`,onClick:z=>E(z,I.id,I.name)})]}):h.jsx("div",{className:Di.editInputWrapper,onClick:O,children:h.jsx(_.Input,{ref:b,defaultValue:I.name,className:Di.nameEditInput,onClick:O,onMouseDown:z=>{z.stopPropagation(),z.preventDefault()},onFocus:z=>{z.stopPropagation(),m(!0)},onPressEnter:z=>{z.stopPropagation(),z.preventDefault(),D()},onBlur:()=>{D()},onChange:z=>{C.editValue=z.target.value}})})}),h.jsxs("div",{className:Di.accountActions,children:[h.jsx(Mq,{type:"secondary",className:Di.updateTime,children:Ht(Number(I.update_time)*1e3).format("YYYY-MM-DD HH:mm:ss")}),h.jsx(_.Button,{type:"link",icon:h.jsx(ie.FileSearchOutlined,{}),size:"small",onClick:z=>{z.stopPropagation(),B(I.id)},children:"编辑"})]})]})},I.id))})}),h.jsx(mq,{onSubmit:M,onCancel:F,inAI:!0,auth_type:C.auth_type,config:C.configModel,formSchema:C.credentialFormSchema,visible:C.createModalVisible,connector:n}),h.jsx(vq,{onSubmit:N,inAI:!0,onCancel:()=>{C.modifyModalVisible=!1},proxy_id:C.proxy_id,auth_type:C.auth_type,config:C.configModel,formSchema:C.credentialFormSchema,initialValues:C.credentialInitialValues,visible:C.modifyModalVisible,connector:n})]})},qA=({credentialRequirements:t,actionAccountSchemaId:e,value:n,onChange:r,...o})=>{var l;const i=y.useMemo(()=>{const c=e?[{key:String(e)}]:[];return ew(t!=null&&t.length?t:c)},[e,t]),[s,a]=y.useState(n?(l=i[0])==null?void 0:l.key:void 0);return y.useEffect(()=>{var c;if(!n){a(void 0);return}!s&&((c=i[0])!=null&&c.key)&&a(i[0].key)},[s,i,n]),i.length===0?null:h.jsx(y.Fragment,{children:i.map(c=>h.jsx(zq,{...o,actionAccountSchemaId:c.key,selectTitle:i.length>1?c.label:"授权配置",value:s===c.key?n:void 0,onChange:u=>{a(u?c.key:void 0),r==null||r(u)}},c.key))})},Hq=(t=32)=>{const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=new Uint8Array(t);return crypto.getRandomValues(n),Array.from(n,r=>e[r%e.length]).join("")},Vq=t=>{const{value:e,onChange:n,disabled:r}=t,[o,i]=y.useState(e||""),[s,a]=y.useState(!1);y.useEffect(()=>{e!==void 0&&e!==o&&i(e)},[e,o]);const l=()=>{const f=Hq();i(f),a(!0),n==null||n(f)},c=()=>{l()},u=async()=>{if(!o){_.message.warning(G("components.authTokenField.emptyTokenWarning"));return}try{await navigator.clipboard.writeText(o),_.message.success(G("components.authTokenField.copySuccess"))}catch{_.message.error(G("components.authTokenField.copyFailed"))}},d=()=>{a(f=>!f)};return h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[h.jsx(_.Input,{style:{flex:1},value:o,readOnly:!0,type:s?"text":"password",placeholder:G("components.authTokenField.placeholder")}),h.jsx(_.Tooltip,{title:G("components.authTokenField.copy"),children:h.jsx(_.Button,{icon:h.jsx(ie.CopyOutlined,{}),onClick:u,disabled:r||!o})}),h.jsx(_.Tooltip,{title:G(s?"components.authTokenField.hideToken":"components.authTokenField.showToken"),children:h.jsx(_.Button,{icon:s?h.jsx(ie.EyeInvisibleOutlined,{}):h.jsx(ie.EyeOutlined,{}),onClick:d,disabled:r||!o})}),h.jsx(_.Tooltip,{title:G(o?"components.authTokenField.regenerate":"components.authTokenField.generate"),children:h.jsx(_.Button,{icon:h.jsx(ie.SyncOutlined,{}),onClick:c,disabled:r,type:"primary",ghost:!0})})]})},jq=(t=32)=>{const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=new Uint8Array(t);return crypto.getRandomValues(n),Array.from(n,r=>e[r%e.length]).join("")},Wq=t=>{const{value:e,onChange:n,disabled:r}=t,[o,i]=y.useState(e||""),[s,a]=y.useState(!1);y.useEffect(()=>{e!==void 0&&e!==o&&i(e)},[e,o]);const l=()=>{const f=jq();i(f),a(!0),n==null||n(f)},c=()=>{if(!o){l();return}_.Modal.confirm({title:G("common.info"),content:G("components.authTokenField.regenerateConfirm"),okText:G("app.common.word.confirm"),cancelText:G("app.common.word.cancel"),onOk:l})},u=async()=>{if(!o){_.message.warning(G("components.authTokenField.emptyTokenWarning"));return}try{await navigator.clipboard.writeText(o),_.message.success(G("components.authTokenField.copySuccess"))}catch{_.message.error(G("components.authTokenField.copyFailed"))}},d=()=>{a(f=>!f)};return h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[h.jsx(_.Input,{style:{flex:1},value:o,readOnly:!0,type:s?"text":"password",placeholder:G("components.authTokenField.placeholder")}),h.jsx(_.Tooltip,{title:G("components.authTokenField.copy"),children:h.jsx(_.Button,{icon:h.jsx(ie.CopyOutlined,{}),onClick:u,disabled:r||!o})}),h.jsx(_.Tooltip,{title:G(s?"components.authTokenField.hideToken":"components.authTokenField.showToken"),children:h.jsx(_.Button,{icon:s?h.jsx(ie.EyeInvisibleOutlined,{}):h.jsx(ie.EyeOutlined,{}),onClick:d,disabled:r||!o})}),h.jsx(_.Tooltip,{title:G(o?"components.authTokenField.regenerate":"components.authTokenField.generate"),children:h.jsx(_.Button,{icon:h.jsx(ie.SyncOutlined,{}),onClick:c,disabled:r,type:"primary",ghost:!0})})]})},GA=10,Uq=["OAUTH","OAUTH2","OIDC"],qq=t=>{const e=new Set([...t.support_protocol??[],...t.auth_protocol?[t.auth_protocol]:[]]);return Array.from(e).some(n=>Uq.includes(n))},Gq=t=>{const{value:e,onChange:n,disabled:r}=t,o=Sl(),[i,s]=y.useState([]),[a,l]=y.useState(!1),[c,u]=y.useState(!1),[d,f]=y.useState(""),[p,m]=y.useState(1),[b,v]=y.useState(!1),w=y.useRef(0),g=y.useMemo(()=>`${window.location.origin}/iam/token`,[]),C=async(O=1,A=!1,T="")=>{const B=w.current+1;w.current=B,A?u(!0):l(!0);try{const M=await Ry({current:O,pageSize:GA},{filter:T});if(w.current!==B)return;const F=(M.items??[]).filter(qq),P=(A?[...i,...F]:F).filter((I,z,H)=>H.findIndex(J=>J.client_id===I.client_id)===z);s(P),m(O),v((M.total??0)>O*GA)}catch{w.current===B&&_.message.error(G("components.selectOAuth2ClientField.fetchFailed"))}finally{w.current===B&&(l(!1),u(!1))}};let S=null;y.useEffect(()=>{S&&(clearTimeout(S),S=null),S=window.setTimeout(()=>{C(1,!1,d.trim())},300)},[d]);const k=async()=>{!b||a||c||await C(p+1,!0,d.trim())},x=async()=>{try{await navigator.clipboard.writeText(g),_.message.success(G("components.selectOAuth2ClientField.copySuccess"))}catch{_.message.error(G("components.selectOAuth2ClientField.copyFailed"))}},D=()=>{o("/apps/manage",!0)},E=()=>{o("https://1in15q85qd.apifox.cn/8698545m0",!0)};return h.jsxs(_.Space,{direction:"vertical",size:12,style:{width:"100%"},children:[h.jsxs("div",{children:[h.jsx(_.Select,{value:e,onChange:n,disabled:r,loading:a,showSearch:!0,filterOption:!1,optionLabelProp:"label",placeholder:G("components.selectOAuth2ClientField.placeholder"),onSearch:f,notFoundContent:a?h.jsx(_.Spin,{size:"small"}):null,getPopupContainer:O=>O.parentNode,popupRender:O=>h.jsxs("div",{children:[O,!a&&i.length===0?h.jsx("div",{style:{padding:"16px 12px"},children:h.jsx(_.Empty,{image:_.Empty.PRESENTED_IMAGE_SIMPLE,description:h.jsxs(_.Space,{direction:"vertical",size:4,children:[h.jsx(_.Typography.Text,{type:"secondary",children:G("components.selectOAuth2ClientField.emptyTitle")}),h.jsx(_.Typography.Text,{type:"secondary",style:{fontSize:12},children:G("components.selectOAuth2ClientField.emptyDescription")})]}),children:h.jsx(_.Button,{type:"primary",ghost:!0,icon:h.jsx(ie.LinkOutlined,{}),onClick:D,children:G("components.selectOAuth2ClientField.goToAppManage")})})}):null,i.length>0?h.jsx("div",{style:{padding:"8px 12px",textAlign:"center",borderTop:"1px solid #f0f0f0"},children:h.jsx(_.Button,{type:"link",icon:h.jsx(ie.ReloadOutlined,{}),onClick:k,loading:c,disabled:!b,children:G(b?"components.selectOAuth2ClientField.loadMore":"components.selectOAuth2ClientField.loadedAll")})}):null]}),options:i.map(O=>({label:O.client_name,value:O.client_id}))}),h.jsxs(_.Typography.Text,{type:"secondary",style:{display:"block",marginTop:8,fontSize:12},children:[G("components.selectOAuth2ClientField.selectDescriptionPrefix"),h.jsx(_.Button,{style:{padding:0},type:"link",onClick:D,children:G("components.selectOAuth2ClientField.goToAppManage")}),G("components.selectOAuth2ClientField.selectDescriptionSuffix")]})]}),h.jsxs("div",{children:[h.jsx(_.Typography.Text,{strong:!0,style:{display:"block",marginBottom:8},children:G("components.selectOAuth2ClientField.tokenEndpoint")}),h.jsxs(_.Space.Compact,{block:!0,className:"workflow-oauth-token-endpoint",children:[h.jsx(_.Input,{value:g,readOnly:!0}),h.jsx(_.Button,{icon:h.jsx(ie.CopyOutlined,{}),onClick:x,disabled:r,children:G("components.selectOAuth2ClientField.copy")})]}),h.jsxs(_.Typography.Text,{type:"secondary",style:{display:"block",marginTop:8,fontSize:12},children:[G("components.selectOAuth2ClientField.tokenDescriptionPrefix"),h.jsx(_.Button,{style:{padding:0},type:"link",onClick:E,children:G("components.selectOAuth2ClientField.documentation")})]})]})]})},Rq=({children:t,value:e,onChange:n})=>{const[r,o]=y.useState(e==="{{$fromAI}}"),i=()=>{const a=!r;o(a),a?n==null||n("{{$fromAI}}"):n==null||n("")},s=()=>r?h.jsxs("div",{style:{position:"relative"},children:[h.jsx(_.Input,{value:"由AI生成 ",readOnly:!0,style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",border:"1px solid transparent",borderImage:"linear-gradient(45deg, #00d4ff, #9b59b6, #e74c3c) 1",color:"#ffffff",fontWeight:"500",textShadow:"0 1px 2px rgba(0,0,0,0.3)",borderRadius:"6px",fontSize:"13px",paddingLeft:"32px",paddingRight:"28px",height:"32px",boxShadow:"0 2px 8px rgba(102, 126, 234, 0.3)"},prefix:h.jsx("div",{style:{background:"linear-gradient(45deg, #00d4ff, #1e3c72)",borderRadius:"50%",width:"16px",height:"16px",display:"flex",alignItems:"center",justifyContent:"center",marginRight:"4px",animation:"pulse 2s ease-in-out infinite alternate"},children:h.jsx("span",{style:{color:"#fff",fontSize:"8px"},children:"AI"})}),suffix:h.jsx(_.Button,{type:"text",size:"small",onClick:i,style:{color:"#ffffff",border:"none",background:"rgba(255,255,255,0.2)",borderRadius:"50%",width:"18px",height:"18px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",minWidth:"18px",padding:0},onMouseEnter:a=>{a.currentTarget.style.background="rgba(255,255,255,0.3)",a.currentTarget.style.transform="scale(1.1)"},onMouseLeave:a=>{a.currentTarget.style.background="rgba(255,255,255,0.2)",a.currentTarget.style.transform="scale(1)"},children:h.jsx(ie.CloseOutlined,{style:{fontSize:"10px"}})})}),h.jsx("style",{children:`
112
+ */const vW=Io("zap",[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]]),yW=/\{\{.*\}\}/;function U_(t){return typeof t=="string"&&yW.test(t)?"expression":"normal"}const q_=({field:t,disabled:e,readOnly:n,context:r})=>{const{renderVariableTag:o,renderVariableTooltip:i,validateVariable:s}=r,a=CW(t),l=t.keyPlaceholder||"Key",c=t.valuePlaceholder||"Value",u=0;return h.jsx(_.Form.List,{name:t.name,rules:a,children:(d,{add:f,remove:p},{errors:m})=>h.jsxs(_.Space,{direction:"vertical",style:{width:"100%"},children:[d.map(b=>h.jsx(G_,{field:t,listField:b,disabled:e,readOnly:n,canRemove:!(e||t.minItems!==void 0&&d.length<=t.minItems),keyPlaceholder:l,valuePlaceholder:c,valueModeSwitchOffset:u,onRemove:p,validateVariable:s,renderVariableTag:o,renderVariableTooltip:i},b.key)),h.jsx(_.Button,{block:!0,icon:h.jsx(br,{size:16}),onClick:()=>f(),disabled:e||t.maxItems!==void 0&&d.length>=t.maxItems,children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})}),h.jsx(_.Form.ErrorList,{errors:m})]})})};q_.displayName="KeyValueFieldControl";const G_=({field:t,listField:e,disabled:n,readOnly:r,canRemove:o,keyPlaceholder:i,valuePlaceholder:s,valueModeSwitchOffset:a,onRemove:l,validateVariable:c,renderVariableTag:u,renderVariableTooltip:d})=>{const f=t.valueModePolicy,p=_.Form.useFormInstance(),[m,b]=y.useState(()=>{if(f){if(f==="BOTH"||f==="EXPRESSION")return"expression";if(f==="TEXT")return"normal"}const w=p.getFieldValue([t.name,e.name]),g=U_(w==null?void 0:w.key);return g==="expression"?g:U_(w==null?void 0:w.value)}),v=f==="TEXT"?["normal"]:["normal","expression"];return h.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[h.jsx(_.Form.Item,{style:{flex:1,marginBottom:0,marginTop:a},name:[e.name,"key"],rules:[{required:!0,message:"请输入Key"}],children:h.jsx(Ci,{availableModes:v,mode:m,hideModeSwitch:!0,disabled:n,readOnly:r,placeholder:i,validateVariable:c,renderVariableTag:u,renderVariableTooltip:d})}),h.jsx(_.Form.Item,{style:{flex:1,marginBottom:0},name:[e.name,"value"],children:h.jsx(Ci,{availableModes:v,mode:m,onModeChange:b,disabled:n,readOnly:r,placeholder:s,validateVariable:c,renderVariableTag:u,renderVariableTooltip:d,modeSwitchPosition:"top-right",compact:!0})}),h.jsx(_.Button,{icon:h.jsx(xi,{size:16}),onClick:()=>l(e.name),disabled:!o})]})};G_.displayName="KeyValueRow";function CW(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)||"此项为必填")}})}if(t.minItems!==void 0){const r=t.minItems;e.push({validator:async(o,i)=>{if(!i||i.length<r)throw new Error(`至少需要 ${r} 项`)}})}if(t.maxItems!==void 0){const r=t.maxItems;e.push({validator:async(o,i)=>{if(i&&i.length>r)throw new Error(`最多允许 ${r} 项`)}})}return e}const kW=Mo(q_,{isComplexField:!0,supportsVariableInsert:!0,needsFormItemName:!1});function SW(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.name=="string"&&e.name.trim()!==""&&typeof e.type=="string"}function EW(t){return!t||typeof t!="object"||Array.isArray(t)?[]:Object.values(t).filter(SW)}const R_=({field:t,disabled:e,readOnly:n,context:r})=>{const o=_.Form.useFormInstance(),s=xW(t.name),[a,l]=vt.useState(null);vt.useEffect(()=>{Promise.resolve().then(()=>_U).then(g=>{l(()=>g.FieldRenderer)})},[]);const{renderVariableTag:c,renderVariableTooltip:u,validateVariable:d,values:f,optionsLoader:p}=r,m=vt.useMemo(()=>EW(t.properties),[t.properties]),b=o.getFieldValue(s)??qn(f,s.join("."))??{},v=h.jsx(_.Space,{direction:"vertical",style:{width:"100%"},children:m.map(g=>{const C=jg(g,t.valueModePolicy),S=[...s,g.name];return yl(C,b)&&a?h.jsx(a,{field:{...C,name:S},values:f,optionsLoader:p,disabled:e,renderVariableTag:c,renderVariableTooltip:u,validateVariable:d},S.join(".")):null})}),w=h.jsx(Wg,{policy:t.valueModePolicy,disabled:e,readOnly:n,children:v});return t.collapsible?h.jsx(_.Collapse,{defaultActiveKey:t.defaultCollapsed?[]:["main"],items:[{key:"main",label:t.label||t.name,children:w}]}):h.jsx(_.Card,{size:"small",title:t.label,children:w})};R_.displayName="ObjectFieldControl";function xW(t){return Array.isArray(t)?t:[t]}const DW=Mo(R_,{isComplexField:!0,supportsVariableInsert:!0,needsFormItemName:!1});var Od={exports:{}},_W=Od.exports,K_;function AW(){return K_||(K_=1,(function(t,e){(function(n,r){t.exports=r()})(_W,(function(){var n=1e3,r=6e4,o=36e5,i="millisecond",s="second",a="minute",l="hour",c="day",u="week",d="month",f="quarter",p="year",m="date",b="Invalid Date",v=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,w=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(F){var N=["th","st","nd","rd"],P=F%100;return"["+F+(N[(P-20)%10]||N[P]||N[0])+"]"}},C=function(F,N,P){var I=String(F);return!I||I.length>=N?F:""+Array(N+1-I.length).join(P)+F},S={s:C,z:function(F){var N=-F.utcOffset(),P=Math.abs(N),I=Math.floor(P/60),z=P%60;return(N<=0?"+":"-")+C(I,2,"0")+":"+C(z,2,"0")},m:function F(N,P){if(N.date()<P.date())return-F(P,N);var I=12*(P.year()-N.year())+(P.month()-N.month()),z=N.clone().add(I,d),H=P-z<0,J=N.clone().add(I+(H?-1:1),d);return+(-(I+(P-z)/(H?z-J:J-z))||0)},a:function(F){return F<0?Math.ceil(F)||0:Math.floor(F)},p:function(F){return{M:d,y:p,w:u,d:c,D:m,h:l,m:a,s,ms:i,Q:f}[F]||String(F||"").toLowerCase().replace(/s$/,"")},u:function(F){return F===void 0}},k="en",x={};x[k]=g;var D="$isDayjsObject",E=function(F){return F instanceof B||!(!F||!F[D])},O=function F(N,P,I){var z;if(!N)return k;if(typeof N=="string"){var H=N.toLowerCase();x[H]&&(z=H),P&&(x[H]=P,z=H);var J=N.split("-");if(!z&&J.length>1)return F(J[0])}else{var K=N.name;x[K]=N,z=K}return!I&&z&&(k=z),z||!I&&k},A=function(F,N){if(E(F))return F.clone();var P=typeof N=="object"?N:{};return P.date=F,P.args=arguments,new B(P)},T=S;T.l=O,T.i=E,T.w=function(F,N){return A(F,{locale:N.$L,utc:N.$u,x:N.$x,$offset:N.$offset})};var B=(function(){function F(P){this.$L=O(P.locale,null,!0),this.parse(P),this.$x=this.$x||P.x||{},this[D]=!0}var N=F.prototype;return N.parse=function(P){this.$d=(function(I){var z=I.date,H=I.utc;if(z===null)return new Date(NaN);if(T.u(z))return new Date;if(z instanceof Date)return new Date(z);if(typeof z=="string"&&!/Z$/i.test(z)){var J=z.match(v);if(J){var K=J[2]-1||0,ee=(J[7]||"0").substring(0,3);return H?new Date(Date.UTC(J[1],K,J[3]||1,J[4]||0,J[5]||0,J[6]||0,ee)):new Date(J[1],K,J[3]||1,J[4]||0,J[5]||0,J[6]||0,ee)}}return new Date(z)})(P),this.init()},N.init=function(){var P=this.$d;this.$y=P.getFullYear(),this.$M=P.getMonth(),this.$D=P.getDate(),this.$W=P.getDay(),this.$H=P.getHours(),this.$m=P.getMinutes(),this.$s=P.getSeconds(),this.$ms=P.getMilliseconds()},N.$utils=function(){return T},N.isValid=function(){return this.$d.toString()!==b},N.isSame=function(P,I){var z=A(P);return this.startOf(I)<=z&&z<=this.endOf(I)},N.isAfter=function(P,I){return A(P)<this.startOf(I)},N.isBefore=function(P,I){return this.endOf(I)<A(P)},N.$g=function(P,I,z){return T.u(P)?this[I]:this.set(z,P)},N.unix=function(){return Math.floor(this.valueOf()/1e3)},N.valueOf=function(){return this.$d.getTime()},N.startOf=function(P,I){var z=this,H=!!T.u(I)||I,J=T.p(P),K=function(j,Y){var W=T.w(z.$u?Date.UTC(z.$y,Y,j):new Date(z.$y,Y,j),z);return H?W:W.endOf(c)},ee=function(j,Y){return T.w(z.toDate()[j].apply(z.toDate("s"),(H?[0,0,0,0]:[23,59,59,999]).slice(Y)),z)},$=this.$W,U=this.$M,R=this.$D,te="set"+(this.$u?"UTC":"");switch(J){case p:return H?K(1,0):K(31,11);case d:return H?K(1,U):K(0,U+1);case u:var se=this.$locale().weekStart||0,be=($<se?$+7:$)-se;return K(H?R-be:R+(6-be),U);case c:case m:return ee(te+"Hours",0);case l:return ee(te+"Minutes",1);case a:return ee(te+"Seconds",2);case s:return ee(te+"Milliseconds",3);default:return this.clone()}},N.endOf=function(P){return this.startOf(P,!1)},N.$set=function(P,I){var z,H=T.p(P),J="set"+(this.$u?"UTC":""),K=(z={},z[c]=J+"Date",z[m]=J+"Date",z[d]=J+"Month",z[p]=J+"FullYear",z[l]=J+"Hours",z[a]=J+"Minutes",z[s]=J+"Seconds",z[i]=J+"Milliseconds",z)[H],ee=H===c?this.$D+(I-this.$W):I;if(H===d||H===p){var $=this.clone().set(m,1);$.$d[K](ee),$.init(),this.$d=$.set(m,Math.min(this.$D,$.daysInMonth())).$d}else K&&this.$d[K](ee);return this.init(),this},N.set=function(P,I){return this.clone().$set(P,I)},N.get=function(P){return this[T.p(P)]()},N.add=function(P,I){var z,H=this;P=Number(P);var J=T.p(I),K=function(U){var R=A(H);return T.w(R.date(R.date()+Math.round(U*P)),H)};if(J===d)return this.set(d,this.$M+P);if(J===p)return this.set(p,this.$y+P);if(J===c)return K(1);if(J===u)return K(7);var ee=(z={},z[a]=r,z[l]=o,z[s]=n,z)[J]||1,$=this.$d.getTime()+P*ee;return T.w($,this)},N.subtract=function(P,I){return this.add(-1*P,I)},N.format=function(P){var I=this,z=this.$locale();if(!this.isValid())return z.invalidDate||b;var H=P||"YYYY-MM-DDTHH:mm:ssZ",J=T.z(this),K=this.$H,ee=this.$m,$=this.$M,U=z.weekdays,R=z.months,te=z.meridiem,se=function(Y,W,X,re){return Y&&(Y[W]||Y(I,H))||X[W].slice(0,re)},be=function(Y){return T.s(K%12||12,Y,"0")},j=te||function(Y,W,X){var re=Y<12?"AM":"PM";return X?re.toLowerCase():re};return H.replace(w,(function(Y,W){return W||(function(X){switch(X){case"YY":return String(I.$y).slice(-2);case"YYYY":return T.s(I.$y,4,"0");case"M":return $+1;case"MM":return T.s($+1,2,"0");case"MMM":return se(z.monthsShort,$,R,3);case"MMMM":return se(R,$);case"D":return I.$D;case"DD":return T.s(I.$D,2,"0");case"d":return String(I.$W);case"dd":return se(z.weekdaysMin,I.$W,U,2);case"ddd":return se(z.weekdaysShort,I.$W,U,3);case"dddd":return U[I.$W];case"H":return String(K);case"HH":return T.s(K,2,"0");case"h":return be(1);case"hh":return be(2);case"a":return j(K,ee,!0);case"A":return j(K,ee,!1);case"m":return String(ee);case"mm":return T.s(ee,2,"0");case"s":return String(I.$s);case"ss":return T.s(I.$s,2,"0");case"SSS":return T.s(I.$ms,3,"0");case"Z":return J}return null})(Y)||J.replace(":","")}))},N.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},N.diff=function(P,I,z){var H,J=this,K=T.p(I),ee=A(P),$=(ee.utcOffset()-this.utcOffset())*r,U=this-ee,R=function(){return T.m(J,ee)};switch(K){case p:H=R()/12;break;case d:H=R();break;case f:H=R()/3;break;case u:H=(U-$)/6048e5;break;case c:H=(U-$)/864e5;break;case l:H=U/o;break;case a:H=U/r;break;case s:H=U/n;break;default:H=U}return z?H:T.a(H)},N.daysInMonth=function(){return this.endOf(d).$D},N.$locale=function(){return x[this.$L]},N.locale=function(P,I){if(!P)return this.$L;var z=this.clone(),H=O(P,I,!0);return H&&(z.$L=H),z},N.clone=function(){return T.w(this.$d,this)},N.toDate=function(){return new Date(this.valueOf())},N.toJSON=function(){return this.isValid()?this.toISOString():null},N.toISOString=function(){return this.$d.toISOString()},N.toString=function(){return this.$d.toUTCString()},F})(),M=B.prototype;return A.prototype=M,[["$ms",i],["$s",s],["$m",a],["$H",l],["$W",c],["$M",d],["$y",p],["$D",m]].forEach((function(F){M[F[1]]=function(N){return this.$g(N,F[0],F[1])}})),A.extend=function(F,N){return F.$i||(F(N,B,A),F.$i=!0),A},A.locale=O,A.isDayjs=E,A.unix=function(F){return A(1e3*F)},A.en=x[k],A.Ls=x,A.p={},A}))})(Od)),Od.exports}var OW=AW();const Ht=Un(OW);var Td={exports:{}},TW=Td.exports,Y_;function NW(){return Y_||(Y_=1,(function(t,e){(function(n,r){t.exports=r()})(TW,(function(){return function(n,r){var o=r.prototype,i=o.format;o.format=function(s){var a=this,l=this.$locale();if(!this.isValid())return i.bind(this)(s);var c=this.$utils(),u=(s||"YYYY-MM-DDTHH:mm:ssZ").replace(/\[([^\]]+)]|Q|wo|ww|w|WW|W|zzz|z|gggg|GGGG|Do|X|x|k{1,2}|S/g,(function(d){switch(d){case"Q":return Math.ceil((a.$M+1)/3);case"Do":return l.ordinal(a.$D);case"gggg":return a.weekYear();case"GGGG":return a.isoWeekYear();case"wo":return l.ordinal(a.week(),"W");case"w":case"ww":return c.s(a.week(),d==="w"?1:2,"0");case"W":case"WW":return c.s(a.isoWeek(),d==="W"?1:2,"0");case"k":case"kk":return c.s(String(a.$H===0?24:a.$H),d==="k"?1:2,"0");case"X":return Math.floor(a.$d.getTime()/1e3);case"x":return a.$d.getTime();case"z":return"["+a.offsetName()+"]";case"zzz":return"["+a.offsetName("long")+"]";default:return d}}));return i.bind(this)(u)}}}))})(Td)),Td.exports}var BW=NW();const FW=Un(BW);var Nd={exports:{}},MW=Nd.exports,X_;function IW(){return X_||(X_=1,(function(t,e){(function(n,r){t.exports=r()})(MW,(function(){var n={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},r=/(\[[^[]*\])|([-_:/.,()\s]+)|(A|a|Q|YYYY|YY?|ww?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,o=/\d/,i=/\d\d/,s=/\d\d?/,a=/\d*[^-_:/,()\s\d]+/,l={},c=function(v){return(v=+v)+(v>68?1900:2e3)},u=function(v){return function(w){this[v]=+w}},d=[/[+-]\d\d:?(\d\d)?|Z/,function(v){(this.zone||(this.zone={})).offset=(function(w){if(!w||w==="Z")return 0;var g=w.match(/([+-]|\d\d)/g),C=60*g[1]+(+g[2]||0);return C===0?0:g[0]==="+"?-C:C})(v)}],f=function(v){var w=l[v];return w&&(w.indexOf?w:w.s.concat(w.f))},p=function(v,w){var g,C=l.meridiem;if(C){for(var S=1;S<=24;S+=1)if(v.indexOf(C(S,0,w))>-1){g=S>12;break}}else g=v===(w?"pm":"PM");return g},m={A:[a,function(v){this.afternoon=p(v,!1)}],a:[a,function(v){this.afternoon=p(v,!0)}],Q:[o,function(v){this.month=3*(v-1)+1}],S:[o,function(v){this.milliseconds=100*+v}],SS:[i,function(v){this.milliseconds=10*+v}],SSS:[/\d{3}/,function(v){this.milliseconds=+v}],s:[s,u("seconds")],ss:[s,u("seconds")],m:[s,u("minutes")],mm:[s,u("minutes")],H:[s,u("hours")],h:[s,u("hours")],HH:[s,u("hours")],hh:[s,u("hours")],D:[s,u("day")],DD:[i,u("day")],Do:[a,function(v){var w=l.ordinal,g=v.match(/\d+/);if(this.day=g[0],w)for(var C=1;C<=31;C+=1)w(C).replace(/\[|\]/g,"")===v&&(this.day=C)}],w:[s,u("week")],ww:[i,u("week")],M:[s,u("month")],MM:[i,u("month")],MMM:[a,function(v){var w=f("months"),g=(f("monthsShort")||w.map((function(C){return C.slice(0,3)}))).indexOf(v)+1;if(g<1)throw new Error;this.month=g%12||g}],MMMM:[a,function(v){var w=f("months").indexOf(v)+1;if(w<1)throw new Error;this.month=w%12||w}],Y:[/[+-]?\d+/,u("year")],YY:[i,function(v){this.year=c(v)}],YYYY:[/\d{4}/,u("year")],Z:d,ZZ:d};function b(v){var w,g;w=v,g=l&&l.formats;for(var C=(v=w.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,(function(A,T,B){var M=B&&B.toUpperCase();return T||g[B]||n[B]||g[M].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(F,N,P){return N||P.slice(1)}))}))).match(r),S=C.length,k=0;k<S;k+=1){var x=C[k],D=m[x],E=D&&D[0],O=D&&D[1];C[k]=O?{regex:E,parser:O}:x.replace(/^\[|\]$/g,"")}return function(A){for(var T={},B=0,M=0;B<S;B+=1){var F=C[B];if(typeof F=="string")M+=F.length;else{var N=F.regex,P=F.parser,I=A.slice(M),z=N.exec(I)[0];P.call(T,z),A=A.replace(z,"")}}return(function(H){var J=H.afternoon;if(J!==void 0){var K=H.hours;J?K<12&&(H.hours+=12):K===12&&(H.hours=0),delete H.afternoon}})(T),T}}return function(v,w,g){g.p.customParseFormat=!0,v&&v.parseTwoDigitYear&&(c=v.parseTwoDigitYear);var C=w.prototype,S=C.parse;C.parse=function(k){var x=k.date,D=k.utc,E=k.args;this.$u=D;var O=E[1];if(typeof O=="string"){var A=E[2]===!0,T=E[3]===!0,B=A||T,M=E[2];T&&(M=E[2]),l=this.$locale(),!A&&M&&(l=g.Ls[M]),this.$d=(function(I,z,H,J){try{if(["x","X"].indexOf(z)>-1)return new Date((z==="X"?1e3:1)*I);var K=b(z)(I),ee=K.year,$=K.month,U=K.day,R=K.hours,te=K.minutes,se=K.seconds,be=K.milliseconds,j=K.zone,Y=K.week,W=new Date,X=U||(ee||$?1:W.getDate()),re=ee||W.getFullYear(),Z=0;ee&&!$||(Z=$>0?$-1:W.getMonth());var de,ve=R||0,we=te||0,fe=se||0,le=be||0;return j?new Date(Date.UTC(re,Z,X,ve,we,fe,le+60*j.offset*1e3)):H?new Date(Date.UTC(re,Z,X,ve,we,fe,le)):(de=new Date(re,Z,X,ve,we,fe,le),Y&&(de=J(de).week(Y).toDate()),de)}catch{return new Date("")}})(x,O,D,g),this.init(),M&&M!==!0&&(this.$L=this.locale(M).$L),B&&x!=this.format(O)&&(this.$d=new Date("")),l={}}else if(O instanceof Array)for(var F=O.length,N=1;N<=F;N+=1){E[1]=O[N-1];var P=g.apply(this,E);if(P.isValid()){this.$d=P.$d,this.$L=P.$L,this.init();break}N===F&&(this.$d=new Date(""))}else S.call(this,k)}}}))})(Nd)),Nd.exports}var PW=IW();const LW=Un(PW);var Bd={exports:{}},$W=Bd.exports,J_;function zW(){return J_||(J_=1,(function(t,e){(function(n,r){t.exports=r()})($W,(function(){return function(n,r,o){var i=r.prototype,s=function(d){return d&&(d.indexOf?d:d.s)},a=function(d,f,p,m,b){var v=d.name?d:d.$locale(),w=s(v[f]),g=s(v[p]),C=w||g.map((function(k){return k.slice(0,m)}));if(!b)return C;var S=v.weekStart;return C.map((function(k,x){return C[(x+(S||0))%7]}))},l=function(){return o.Ls[o.locale()]},c=function(d,f){return d.formats[f]||(function(p){return p.replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,(function(m,b,v){return b||v.slice(1)}))})(d.formats[f.toUpperCase()])},u=function(){var d=this;return{months:function(f){return f?f.format("MMMM"):a(d,"months")},monthsShort:function(f){return f?f.format("MMM"):a(d,"monthsShort","months",3)},firstDayOfWeek:function(){return d.$locale().weekStart||0},weekdays:function(f){return f?f.format("dddd"):a(d,"weekdays")},weekdaysMin:function(f){return f?f.format("dd"):a(d,"weekdaysMin","weekdays",2)},weekdaysShort:function(f){return f?f.format("ddd"):a(d,"weekdaysShort","weekdays",3)},longDateFormat:function(f){return c(d.$locale(),f)},meridiem:this.$locale().meridiem,ordinal:this.$locale().ordinal}};i.localeData=function(){return u.bind(this)()},o.localeData=function(){var d=l();return{firstDayOfWeek:function(){return d.weekStart||0},weekdays:function(){return o.weekdays()},weekdaysShort:function(){return o.weekdaysShort()},weekdaysMin:function(){return o.weekdaysMin()},months:function(){return o.months()},monthsShort:function(){return o.monthsShort()},longDateFormat:function(f){return c(d,f)},meridiem:d.meridiem,ordinal:d.ordinal}},o.months=function(){return a(l(),"months")},o.monthsShort=function(){return a(l(),"monthsShort","months",3)},o.weekdays=function(d){return a(l(),"weekdays",null,null,d)},o.weekdaysShort=function(d){return a(l(),"weekdaysShort","weekdays",3,d)},o.weekdaysMin=function(d){return a(l(),"weekdaysMin","weekdays",2,d)}}}))})(Bd)),Bd.exports}var HW=zW();const VW=Un(HW);var Fd={exports:{}},jW=Fd.exports,Q_;function WW(){return Q_||(Q_=1,(function(t,e){(function(n,r){t.exports=r()})(jW,(function(){return function(n,r){r.prototype.weekday=function(o){var i=this.$locale().weekStart||0,s=this.$W,a=(s<i?s+7:s)-i;return this.$utils().u(o)?a:this.subtract(a,"day").add(o,"day")}}}))})(Fd)),Fd.exports}var UW=WW();const qW=Un(UW);var Md={exports:{}},GW=Md.exports,Z_;function RW(){return Z_||(Z_=1,(function(t,e){(function(n,r){t.exports=r()})(GW,(function(){var n="week",r="year";return function(o,i,s){var a=i.prototype;a.week=function(l){if(l===void 0&&(l=null),l!==null)return this.add(7*(l-this.week()),"day");var c=this.$locale().yearStart||1;if(this.month()===11&&this.date()>25){var u=s(this).startOf(r).add(1,r).date(c),d=s(this).endOf(n);if(u.isBefore(d))return 1}var f=s(this).startOf(r).date(c).startOf(n).subtract(1,"millisecond"),p=this.diff(f,n,!0);return p<0?s(this).startOf("week").week():Math.ceil(p)},a.weeks=function(l){return l===void 0&&(l=null),this.week(l)}}}))})(Md)),Md.exports}var KW=RW();const YW=Un(KW);var Id={exports:{}},XW=Id.exports,eA;function JW(){return eA||(eA=1,(function(t,e){(function(n,r){t.exports=r()})(XW,(function(){return function(n,r){r.prototype.weekYear=function(){var o=this.month(),i=this.week(),s=this.year();return i===1&&o===11?s+1:o===0&&i>=52?s-1:s}}}))})(Id)),Id.exports}var QW=JW();const ZW=Un(QW);Ht.extend(LW),Ht.extend(FW),Ht.extend(qW),Ht.extend(VW),Ht.extend(YW),Ht.extend(ZW);function Cl(t,e){if(t==null||t==="")return null;if(Ht.isDayjs(t))return t.isValid()?t:null;const n=e?Ht(t,e):Ht(t);if(n.isValid())return n;const r=Ht(t);return r.isValid()?r:null}function tA(t,e){if(!Array.isArray(t))return null;const n=Cl(t[0],e),r=Cl(t[1],e);return n||r?[n,r]:null}function kl(t,e,n){if(t)return e==="timestamp"?t.valueOf():e==="string"?t.format(n):t}function nA(t,e,n){if(t)return[kl(t[0],e,n),kl(t[1],e,n)]}const eU="YYYY-MM-DD",rA=({field:t,disabled:e,value:n,onChange:r,id:o})=>{const i=t.format||eU,s=Cl(n,i);return h.jsx(_.DatePicker,{disabled:e,placeholder:t.placeholder,picker:t.picker,format:i,style:{width:"100%"},value:s,onChange:a=>r==null?void 0:r(kl(a,t.outputFormat,i)),id:o})};rA.displayName="DateFieldControl";const tU=ft(rA,{needsFormItemName:!0}),nU="YYYY-MM-DD",oA=({field:t,disabled:e,value:n,onChange:r,id:o})=>{const i=t.format||nU,s=tA(n,i);return h.jsx(_.DatePicker.RangePicker,{disabled:e,picker:t.picker,showTime:t.showTime,format:i,style:{width:"100%"},value:s,onChange:a=>r==null?void 0:r(nA(a,t.outputFormat,i)),id:o})};oA.displayName="DateRangeFieldControl";const rU=ft(oA,{needsFormItemName:!0}),oU="YYYY-MM-DD HH:mm:ss",iA=({field:t,disabled:e,value:n,onChange:r,id:o})=>{const i=t.format||oU,s=Cl(n,i);return h.jsx(_.DatePicker,{disabled:e,placeholder:t.placeholder,showTime:t.showTime??!0,format:i,style:{width:"100%"},value:s,onChange:a=>r==null?void 0:r(kl(a,t.outputFormat,i)),id:o})};iA.displayName="DateTimeFieldControl";const iU=ft(iA,{needsFormItemName:!0}),sU="HH:mm:ss",sA=({field:t,disabled:e,value:n,onChange:r,id:o})=>{const i=t.format||sU,s=Cl(n,i);return h.jsx(_.TimePicker,{disabled:e,placeholder:t.placeholder,format:i,style:{width:"100%"},value:s,onChange:a=>r==null?void 0:r(kl(a,t.outputFormat,i)),id:o})};sA.displayName="TimeFieldControl";const aU=ft(sA,{needsFormItemName:!0}),lU="HH:mm:ss",aA=({field:t,disabled:e,value:n,onChange:r,id:o})=>{const i=t.format||lU,s=tA(n,i);return h.jsx(_.TimePicker.RangePicker,{disabled:e,format:i,style:{width:"100%"},value:s,onChange:a=>r==null?void 0:r(nA(a,t.outputFormat,i)),id:o})};aA.displayName="TimeRangeFieldControl";const cU=ft(aA,{needsFormItemName:!0}),lA=({field:t})=>h.jsx(_.Divider,{children:t.label});lA.displayName="DividerFieldControl";const uU=Mo(lA,{isDisplayOnly:!0,needsFormItemName:!1}),cA=({value:t,onChange:e,id:n})=>h.jsx(_.Input,{type:"hidden",value:t,onChange:r=>e==null?void 0:e(r.target.value),id:n});cA.displayName="HiddenFieldControl";const dU=Mo(cA,{needsFormItemName:!0,isHidden:!0}),uA=({field:t})=>h.jsx(_.Alert,{message:t.label,description:t.description||t.placeholder,type:t.status||"info",showIcon:t.showIcon,closable:t.closable});uA.displayName="InfoCardFieldControl";const fU=Mo(uA,{isDisplayOnly:!0,needsFormItemName:!1}),dA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Input.TextArea,{disabled:e,placeholder:t.placeholder,rows:6,value:n,onChange:i=>r==null?void 0:r(i.target.value),id:o});dA.displayName="JsonFieldControl";const hU=ft(dA,{needsFormItemName:!0}),fA=({field:t,value:e})=>h.jsx("span",{children:e||t.placeholder||t.defaultValue});fA.displayName="LabelFieldControl";const pU=ft(fA,{needsFormItemName:!0}),hA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Cascader,{disabled:e,placeholder:t.placeholder,options:t.options,changeOnSelect:t.changeOnSelect,multiple:t.multiple||void 0,showSearch:t.showSearch,value:n,onChange:(i,s)=>r==null?void 0:r(i),id:o});hA.displayName="CascaderFieldControl";const mU=ft(hA,{needsFormItemName:!0}),pA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Checkbox,{disabled:e,checked:n,onChange:i=>r==null?void 0:r(i.target.checked),id:o,children:t.placeholder});pA.displayName="CheckboxFieldControl";const gU=ft(pA,{needsFormItemName:!0,valuePropName:"checked"}),mA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Checkbox.Group,{disabled:e,options:t.options,value:n,onChange:i=>r==null?void 0:r(i)});mA.displayName="CheckboxGroupFieldControl";const wU=ft(mA,{needsFormItemName:!0}),gA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Radio.Group,{disabled:e,options:t.options,optionType:t.optionType,buttonStyle:t.buttonStyle,value:n,onChange:i=>r==null?void 0:r(i.target.value),id:o});gA.displayName="RadioFieldControl";const bU=ft(gA,{needsFormItemName:!0}),wA=({field:t,disabled:e,context:n,value:r,onChange:o,id:i})=>{const{values:s,optionsLoader:a}=n,[l,c]=y.useState(bA(t)),[u,d]=y.useState(!1),f=t.type===ge.MULTI_SELECT||t.mode==="multiple",p=w=>!w||w.kind==="static"?[]:w.deps||[],m=y.useMemo(()=>{const g=p(t.optionsSource).map(C=>qn(s,C));return JSON.stringify(g)},[t.optionsSource,s]);y.useEffect(()=>{if(!t.optionsSource||t.optionsSource.kind==="static"){c(bA(t));return}const w=t.optionsSource;if(!a){c(w.fallbackOptions||t.options||[]);return}const C=p(w).reduce((x,D)=>(x[D]=qn(s,D),x),{}),S={...w.params||{},deps:C};d(!0);let k=!1;return a(w.action,S,{values:s}).then(x=>{k||c(x)}).catch(()=>{k||c(w.fallbackOptions||t.options||[])}).finally(()=>{k||d(!1)}),()=>{k=!0}},[m,t.optionsSource,t.options]);const b=()=>{var w;(w=n.eventHandlers)==null||w.onBlur(t.name)},v=()=>{var w;(w=n.eventHandlers)==null||w.onFocus(t.name)};return h.jsx(_.Select,{disabled:e,placeholder:t.placeholder,options:l,mode:f?"multiple":t.mode,showSearch:t.showSearch,allowClear:t.allowClear,maxTagCount:t.maxTagCount,loading:u,value:r,onChange:o,onBlur:b,onFocus:v,id:i})};wA.displayName="SelectFieldControl";function bA(t){var n;if((n=t.options)!=null&&n.length)return t.options;const e=t.optionsSource;return e?e.kind==="static"?e.items||[]:e.fallbackOptions||[]:[]}const vA=ft(wA,{supportsVariableInsert:!1,needsFormItemName:!0}),yA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Switch,{disabled:e,checkedChildren:t.checkedChildren,unCheckedChildren:t.unCheckedChildren,checked:n,onChange:r,id:o});yA.displayName="SwitchFieldControl";const vU=ft(yA,{needsFormItemName:!0,valuePropName:"checked"}),CA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.TreeSelect,{disabled:e,placeholder:t.placeholder,treeData:t.options,multiple:t.multiple,showSearch:t.showSearch,allowClear:t.allowClear,treeCheckable:t.treeCheckable,value:n,onChange:r,id:o});CA.displayName="TreeSelectFieldControl";const yU=ft(CA,{needsFormItemName:!0}),kA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.AutoComplete,{disabled:e,placeholder:t.placeholder,options:t.options,allowClear:t.allowClear,value:n,onChange:r,id:o});kA.displayName="AutoCompleteFieldControl";const CU=ft(kA,{needsFormItemName:!0}),SA=({disabled:t,value:e,onChange:n})=>h.jsx(_.ColorPicker,{disabled:t,value:e,onChange:(r,o)=>n==null?void 0:n(o)});SA.displayName="ColorPickerFieldControl";const kU=ft(SA,{needsFormItemName:!0}),EA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Mentions,{disabled:e,placeholder:t.placeholder,value:n,onChange:r,id:o});EA.displayName="MentionsFieldControl";const SU=ft(EA,{needsFormItemName:!0}),xA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Rate,{disabled:e,count:t.count,allowHalf:t.allowHalf,value:n,onChange:r,id:o});xA.displayName="RateFieldControl";const EU=ft(xA,{needsFormItemName:!0}),DA=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Slider,{disabled:e,min:t.min,max:t.max,step:t.step,marks:t.marks,range:t.range,value:n,onChange:i=>r==null?void 0:r(i),id:o});DA.displayName="SliderFieldControl";const xU=ft(DA,{needsFormItemName:!0}),_A=({field:t,disabled:e,value:n,onChange:r,id:o})=>h.jsx(_.Upload,{disabled:e,accept:t.accept,maxCount:t.maxCount,listType:t.listType||"text",action:t.action,multiple:t.multiple,fileList:n,onChange:r,id:o,children:h.jsx(_.Button,{icon:h.jsx(ie.UploadOutlined,{}),disabled:e,children:"上传文件"})});_A.displayName="UploadFieldControl";const DU=ft(_A,{needsFormItemName:!0});function AA(t=Mc){t.register(ge.TEXT,q7),t.register(ge.TEXTAREA,U7),t.register(ge.NUMBER,j7),t.register(ge.PASSWORD,W7),t.register(ge.SELECT,vA),t.register(ge.MULTI_SELECT,vA),t.register(ge.RADIO,bU),t.register(ge.CHECKBOX,gU),t.register(ge.CHECKBOX_GROUP,wU),t.register(ge.SWITCH,vU),t.register(ge.CASCADER,mU),t.register(ge.TREE_SELECT,yU),t.register(ge.DATE,tU),t.register(ge.DATETIME,iU),t.register(ge.DATE_RANGE,rU),t.register(ge.TIME,aU),t.register(ge.TIME_RANGE,cU),t.register(ge.UPLOAD,DU),t.register(ge.RATE,EU),t.register(ge.SLIDER,xU),t.register(ge.COLOR_PICKER,kU),t.register(ge.MENTIONS,SU),t.register(ge.AUTO_COMPLETE,CU),t.register(ge.LABEL,pU),t.register(ge.HIDDEN,dU),t.register(ge.JSON,hU),t.register(ge.DIVIDER,uU),t.register(ge.INFO_CARD,fU),t.register(ge.ARRAY,R7),t.register(ge.OBJECT,DW),t.register(ge.KEY_VALUE,kW),t.register(ge.ARRAY_OBJECT,lW)}AA();const Gg=({field:t,disabled:e,required:n,readOnly:r,rules:o,values:i,optionsLoader:s,validateVariable:a,renderVariableTag:l,renderVariableTooltip:c,eventHandlers:u})=>{const d=Ic(),f=e??As(t.disabled,i,!1),p=n??As(t.required,i,!1),m=r??As(t.readOnly,i,!1),b=o??Ei(t.rules||[],i,t.type),v={values:i,optionsLoader:s,validateVariable:a,renderVariableTag:l,renderVariableTooltip:c,eventHandlers:u},w=d.get(t.type);if(!w)return h.jsxs("span",{children:["不支持的字段类型: ",t.type]});const{component:g,meta:C}=w;return C.isDisplayOnly?h.jsx(g,{field:t,disabled:f,readOnly:m,context:v}):C.isComplexField?h.jsx(_.Form.Item,{label:t.label,tooltip:t.tooltip,extra:t.helpText||t.extra||t.description,required:p,labelCol:t.labelCol,wrapperCol:t.wrapperCol,colon:t.colon,children:h.jsx(g,{field:t,disabled:f,readOnly:m,context:v})}):C.isHidden?h.jsx(_.Form.Item,{name:C.needsFormItemName!==!1?t.name:void 0,hidden:!0,rules:b,valuePropName:C.valuePropName,validateTrigger:t.validateTrigger,children:h.jsx(g,{field:t,disabled:f,readOnly:m,context:v})}):h.jsx(_.Form.Item,{name:C.needsFormItemName!==!1?t.name:void 0,label:t.label,tooltip:t.tooltip,extra:t.helpText||t.extra||t.description,required:p,rules:b,labelCol:t.labelCol,wrapperCol:t.wrapperCol,colon:t.colon,valuePropName:C.valuePropName,validateTrigger:t.validateTrigger,children:h.jsx(g,{field:t,disabled:f,readOnly:m,context:v})})},_U=Object.freeze(Object.defineProperty({__proto__:null,FieldRenderer:Gg},Symbol.toStringTag,{value:"Module"})),AU={meta:{name:"antd-5x-apple-pixel-aligned-full",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#007AFF",colorInfo:"#007AFF",colorSuccess:"#34C759",colorWarning:"#FF9F0A",colorError:"#FF3B30",colorTextBase:"#0B0B0F",colorBgBase:"#FFFFFF",colorBorder:"#D1D1D6",colorBorderSecondary:"#E5E5EA",colorPrimaryBorder:"#007AFF",colorPrimaryBorderHover:"#007AFF",colorPrimaryHover:"#0066D6",colorPrimaryActive:"#0056B3",controlOutlineWidth:2,controlOutline:"rgba(0, 122, 255, 0.25)",fontFamily:'"SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.6,borderRadius:10,borderRadiusSM:8,borderRadiusLG:12,lineWidth:1,lineType:"solid",controlHeight:44,controlHeightSM:36,controlHeightLG:52,sizeUnit:4,sizeStep:4,padding:16,paddingXS:10,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:10,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 10px 24px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08)",boxShadowSecondary:"0 6px 16px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06)",boxShadowTertiary:"0 2px 8px rgba(0,0,0,0.08)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:12},Anchor:{linkPaddingInlineStart:16},AutoComplete:{controlHeight:44,controlHeightSM:36,controlHeightLG:52},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:999,borderRadiusSM:999,borderRadiusLG:999,controlHeight:44,controlHeightSM:36,controlHeightLG:52,paddingInline:18,paddingInlineLG:20,paddingInlineSM:14,contentFontSize:14,contentFontSizeLG:16,contentFontSizeSM:14,primaryShadow:"0 2px 0 rgba(0,122,255,0.14)",dangerShadow:"0 2px 0 rgba(255,59,48,0.12)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24,borderRadiusLG:14},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:6},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:52,activeBorderColor:"#007AFF",activeShadow:"0 0 0 2px rgba(0, 122, 255, 0.25)"},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:44,controlHeightLG:52,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:44,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:44,controlHeightSM:36,controlHeightLG:52,paddingInline:14,paddingInlineSM:12,paddingInlineLG:14,paddingBlock:10,paddingBlockSM:8,paddingBlockLG:12,borderRadius:10,hoverBorderColor:"#C7C7CC",activeBorderColor:"#007AFF",activeShadow:"0 0 0 2px rgba(0, 122, 255, 0.25)"},InputNumber:{controlHeight:44,controlHeightSM:36,controlHeightLG:52},Layout:{headerBg:"#FFFFFF",headerHeight:64,headerPadding:"0 50px",bodyBg:"#F2F2F7",siderBg:"#FFFFFF",triggerBg:"#F2F2F7"},List:{itemPadding:"12px 0"},Mentions:{controlHeight:44,controlHeightSM:36,controlHeightLG:52},Menu:{itemHeight:44,iconSize:16,collapsedIconSize:18,horizontalItemBorderRadius:10,itemBorderRadius:10},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16,borderRadiusLG:14},Notification:{},Pagination:{itemSize:44,itemSizeSM:36},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{buttonSolidCheckedBg:"#007AFF"},Rate:{},Result:{},Segmented:{controlHeight:36},Select:{controlHeight:44,controlHeightSM:36,controlHeightLG:52,multipleItemHeight:28,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:24,trackMinWidth:44,handleSize:20},Table:{headerBg:"#F2F2F7",headerSortActiveBg:"#EDEDF2",headerSortHoverBg:"#F2F2F7",rowHoverBg:"#F2F2F7",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:4,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 16px"},Tag:{borderRadiusSM:8},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:52,activeBorderColor:"#007AFF",activeShadow:"0 0 0 2px rgba(0, 122, 255, 0.25)"},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:36,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}},OU={meta:{name:"antd-5x-google-material3-aligned-full",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#1A73E8",colorInfo:"#1A73E8",colorSuccess:"#34A853",colorWarning:"#FBBC04",colorError:"#EA4335",colorTextBase:"#202124",colorBgBase:"#FFFFFF",colorBorder:"#DADCE0",colorBorderSecondary:"#E0E3E7",colorPrimaryBorder:"#1A73E8",colorPrimaryBorderHover:"#1A73E8",colorPrimaryHover:"#1967D2",colorPrimaryActive:"#174EA6",controlOutlineWidth:2,controlOutline:"rgba(26, 115, 232, 0.24)",fontFamily:'"Google Sans", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.5714285714285714,borderRadius:8,borderRadiusSM:4,borderRadiusLG:12,lineWidth:1,lineType:"solid",controlHeight:56,controlHeightSM:40,controlHeightLG:64,sizeUnit:4,sizeStep:4,padding:16,paddingXS:8,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:8,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 1px 2px rgba(60,64,67,0.16), 0 2px 6px rgba(60,64,67,0.12)",boxShadowSecondary:"0 2px 8px rgba(60,64,67,0.14)",boxShadowTertiary:"0 1px 3px rgba(60,64,67,0.12)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:12},Anchor:{linkPaddingInlineStart:16},AutoComplete:{controlHeight:56,controlHeightSM:40,controlHeightLG:64},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:999,borderRadiusSM:999,borderRadiusLG:999,controlHeight:40,controlHeightSM:32,controlHeightLG:48,paddingInline:24,paddingInlineLG:24,paddingInlineSM:16,contentFontSize:14,contentFontSizeLG:14,contentFontSizeSM:14,primaryShadow:"0 1px 0 rgba(26,115,232,0.20)",dangerShadow:"0 1px 0 rgba(234,67,53,0.18)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24,borderRadiusLG:12},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:4},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:56,controlHeightSM:40,controlHeightLG:64,activeBorderColor:"#1A73E8",activeShadow:"0 0 0 2px rgba(26, 115, 232, 0.24)"},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:40,controlHeightLG:48,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:40,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:56,controlHeightSM:40,controlHeightLG:64,paddingInline:16,paddingInlineSM:12,paddingInlineLG:16,paddingBlock:14,paddingBlockSM:8,paddingBlockLG:16,borderRadius:4,hoverBorderColor:"#BDC1C6",activeBorderColor:"#1A73E8",activeShadow:"0 0 0 2px rgba(26, 115, 232, 0.24)"},InputNumber:{controlHeight:56,controlHeightSM:40,controlHeightLG:64},Layout:{headerBg:"#202124",headerHeight:64,headerPadding:"0 50px",bodyBg:"#F8F9FA",siderBg:"#202124",triggerBg:"#303134"},List:{itemPadding:"12px 0"},Mentions:{controlHeight:56,controlHeightSM:40,controlHeightLG:64},Menu:{itemHeight:40,iconSize:14,collapsedIconSize:16,horizontalItemBorderRadius:12,itemBorderRadius:12},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16,borderRadiusLG:16},Notification:{},Pagination:{itemSize:40,itemSizeSM:32},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{buttonSolidCheckedBg:"#1A73E8"},Rate:{},Result:{},Segmented:{controlHeight:40},Select:{controlHeight:56,controlHeightSM:40,controlHeightLG:64,multipleItemHeight:28,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:24,trackMinWidth:44,handleSize:20},Table:{headerBg:"#F8F9FA",headerSortActiveBg:"#F1F3F4",headerSortHoverBg:"#F3F5F6",rowHoverBg:"#F8F9FA",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:4,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 18px"},Tag:{borderRadiusSM:8},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:56,controlHeightSM:40,controlHeightLG:64,activeBorderColor:"#1A73E8",activeShadow:"0 0 0 2px rgba(26, 115, 232, 0.24)"},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:32,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}},TU={meta:{name:"antd-5x-preline-pixel-aligned-full",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#2563EB",colorInfo:"#2563EB",colorSuccess:"#16A34A",colorWarning:"#F59E0B",colorError:"#EF4444",colorTextBase:"#0F172A",colorBgBase:"#FFFFFF",colorBorder:"#E5E7EB",colorBorderSecondary:"#E5E7EB",colorPrimaryBorder:"#3B82F6",colorPrimaryBorderHover:"#3B82F6",colorPrimaryHover:"#1D4ED8",colorPrimaryActive:"#1E40AF",controlOutlineWidth:1,controlOutline:"rgba(59, 130, 246, 0.45)",fontFamily:'Graphik, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.6,borderRadius:8,borderRadiusSM:6,borderRadiusLG:12,lineWidth:1,lineType:"solid",controlHeight:44,controlHeightSM:36,controlHeightLG:48,sizeUnit:4,sizeStep:4,padding:16,paddingXS:8,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:8,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 1px 2px rgba(15,23,42,0.06), 0 6px 18px rgba(15,23,42,0.08)",boxShadowSecondary:"0 1px 2px rgba(15,23,42,0.05), 0 10px 24px rgba(15,23,42,0.10)",boxShadowTertiary:"0 1px 2px rgba(15,23,42,0.06)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:12},Anchor:{linkPaddingInlineStart:16},AutoComplete:{controlHeight:44,controlHeightSM:36,controlHeightLG:48},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:8,borderRadiusSM:8,borderRadiusLG:10,controlHeight:44,controlHeightSM:36,controlHeightLG:48,paddingInline:16,paddingInlineLG:18,paddingInlineSM:12,contentFontSize:14,contentFontSizeLG:14,contentFontSizeSM:14,primaryShadow:"0 1px 0 rgba(37,99,235,0.18)",dangerShadow:"0 1px 0 rgba(239,68,68,0.16)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24,borderRadiusLG:12},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:6},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:48,activeBorderColor:"#3B82F6",activeShadow:"0 0 0 1px rgba(59, 130, 246, 0.45)"},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:40,controlHeightLG:48,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:36,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:44,controlHeightSM:36,controlHeightLG:48,paddingInline:16,paddingInlineSM:12,paddingInlineLG:16,paddingBlock:10,paddingBlockSM:8,paddingBlockLG:10,borderRadius:8,hoverBorderColor:"#D1D5DB",activeBorderColor:"#3B82F6",activeShadow:"0 0 0 1px rgba(59, 130, 246, 0.45)"},InputNumber:{controlHeight:44,controlHeightSM:36,controlHeightLG:48},Layout:{headerBg:"#0B1220",headerHeight:64,headerPadding:"0 50px",bodyBg:"#F8FAFC",siderBg:"#0B1220",triggerBg:"#0F1A2E"},List:{itemPadding:"12px 0"},Mentions:{controlHeight:44,controlHeightSM:36,controlHeightLG:48},Menu:{itemHeight:40,iconSize:14,collapsedIconSize:16,horizontalItemBorderRadius:8,itemBorderRadius:8},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16,borderRadiusLG:12},Notification:{},Pagination:{itemSize:36,itemSizeSM:32},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{},Rate:{},Result:{},Segmented:{controlHeight:36},Select:{controlHeight:44,controlHeightSM:36,controlHeightLG:48,multipleItemHeight:28,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:22,trackMinWidth:44,handleSize:18},Table:{headerBg:"#F8FAFC",headerSortActiveBg:"#F1F5F9",headerSortHoverBg:"#F3F6FB",rowHoverBg:"#F8FAFC",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:6,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 16px"},Tag:{borderRadiusSM:6},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:48,activeBorderColor:"#3B82F6",activeShadow:"0 0 0 1px rgba(59, 130, 246, 0.45)"},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:32,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}};function NU(t){return"optionsSource"in t&&t.optionsSource&&t.optionsSource.kind!=="static"?t.optionsSource.deps||[]:[]}function BU(t){const e=[];for(const n of t.fields){const r=NU(n);if(r.length>0)for(const o of r)e.push({id:`auto-clear-${n.name}-on-${o}-change`,trigger:{type:"fieldChange",field:o},actions:[{type:"clearFields",targets:[n.name]}]})}return e}function FU(t,e,n=!0){return[...n?BU(t):[],...e||[]]}const MU={default:Bh,apple:AU,google:OU,preline:TU};function Rg({schema:t,disabled:e=!1,initialValues:n,onSubmit:r,onChange:o,onValuesObserved:i,submitLabel:s="提交",showReset:a=!1,resetLabel:l="重置",onReset:c,form:u,showSubmit:d=!0,optionsLoader:f,nodeId:p,mcpMode:m,validateVariable:b,renderVariableTag:v,renderVariableTooltip:w,availableVariables:g,theme:C,customTheme:S,locale:k,prefixCls:x,events:D,customHandlers:E,maxExecutionDepth:O,debugEvents:A,preRender:T}){var Y;const[B]=_.Form.useForm(),M=u||B,F=vt.useMemo(()=>{const W={};for(const X of t.fields)X.defaultValue!==void 0&&(W[X.name]=X.defaultValue);return{...W,...n||{}}},[t.fields,n]),N=vt.useMemo(()=>{const W=t.enableAutoEvents!==!1,X=t.events||[],re=D||[];return FU(t,[...X,...re],W)},[t,D]),P=h2({events:N,form:M,optionsLoader:f,customHandlers:E,maxExecutionDepth:O,debug:A}),I=vt.useRef({}),z=vt.useMemo(()=>{if(S)return S;if(C)return MU[C]},[S,C]),H=_.Form.useWatch([],M),J=vt.useMemo(()=>JSON.stringify({...F||{},...H||{}}),[F,H]),K=vt.useMemo(()=>({...F||{},...H||{}}),[J]),ee=vt.useRef(J);vt.useEffect(()=>{!i||ee.current===J||(ee.current=J,i(K))},[i,K,J]);const[$,U]=vt.useState({}),R=vt.useRef({});vt.useEffect(()=>{var X;const W={};for(const re of t.fields){const Z=yl(re,K);if(W[re.name]=Z,R.current[re.name]===!0&&Z===!1){const ve=$7(re),we=((X=re.visibleWhen)==null?void 0:X.clearOnHide)??!0;ve==="unregister"&&M.setFieldValue(re.name,we?void 0:M.getFieldValue(re.name))}}R.current=W,U(re=>{const Z=Object.keys(re),de=Object.keys(W);return Z.length===de.length&&de.every(ve=>re[ve]===W[ve])?re:W})},[t.fields,M,K]);const te=async W=>{const X=t.pruneInvisibleOnSubmit===!1?W:H7(t,W,$);await(r==null?void 0:r(X))},se=(W,X)=>{if(o==null||o(W,X),P.triggerFieldChange&&W){const re=I.current;for(const Z in W){const de=qn(re,Z),ve=W[Z];P.triggerFieldChange(Z,ve,de)}}I.current={...X}},be=d||a,j=vt.useMemo(()=>({nodeId:p,mcpMode:m,validateVariable:b,renderVariableTag:v,renderVariableTooltip:w,availableVariables:g}),[p,m,b,v,w,g]);return h.jsx(oC,{customTheme:z,locale:k,prefixCls:x,children:h.jsx(lC,{value:j,children:h.jsxs(_.Form,{form:M,disabled:e,autoComplete:"off",layout:t.layout||"vertical",labelCol:t.labelCol,wrapperCol:t.wrapperCol,colon:t.colon,size:t.size,initialValues:F,onFinish:te,onValuesChange:se,className:"workflow-config-form",children:[T&&T,t.fields.map(W=>{if(!yl(W,K))return null;const re=e||As(W.disabled,K,!1),Z=As(W.required,K,!1),de=Ei(W.rules||[],K,W.type),ve=(W.rules||[]).some(fe=>fe.type==="required"),we=Z&&!ve?[qg(`${W.label||W.name}为必填项`),...de]:de;return h.jsx(Gg,{field:W,disabled:re,required:Z,rules:we,values:K,optionsLoader:f,validateVariable:b,renderVariableTag:v,renderVariableTooltip:w,eventHandlers:P.fieldEventHandlers},W.name)}),be&&h.jsx(_.Form.Item,{wrapperCol:{offset:((Y=t.labelCol)==null?void 0:Y.span)||0},children:h.jsxs(_.Space,{children:[a&&h.jsx(_.Button,{disabled:e,onClick:()=>{M.resetFields(),c==null||c()},children:l}),d&&h.jsx(_.Button,{type:"primary",htmlType:"submit",children:s})]})})]})})})}const Sl=()=>{const t=Pt();return y.useCallback((e,n=!1)=>{if(/^https?:\/\//i.test(e)){window.open(e,"_blank");return}if(t.onNavigate){t.onNavigate(e,n);return}n?window.open(e,"_blank"):ac.push(e)},[t.onNavigate])},Kg=y.forwardRef((t,e)=>{const n=Sl(),[r,o]=y.useState([]),[i,s]=y.useState("");y.useEffect(()=>{s(t.proxyId)},[t.proxyId]),y.useEffect(()=>{qf().then(c=>{o(c??[])})},[]);const a=()=>i;y.useImperativeHandle(e,()=>({getProxyId:a}));const l=c=>{s(c)};return h.jsxs(WB,{label:G("link.flow.use_proxy_gateway"),children:[h.jsxs(_.Select,{className:"proxy_id_select",value:i,dropdownStyle:{zIndex:Bc.nestedPopover},onChange:l,style:{width:"100%"},children:[h.jsx(_.Select.Option,{value:"0",children:h.jsx(Te.FormattedMessage,{id:"link.flow.do_not_use"})}),r.map(c=>h.jsx(_.Select.Option,{value:c.id,children:c.group_name},c.id))]}),h.jsxs("p",{className:"field-desc",children:[h.jsx(Te.FormattedMessage,{id:"link.flow.private_network_deployment"}),h.jsx("span",{style:{margin:"0 2px"},onClick:()=>{n("/setting/gateway")},children:h.jsx(Te.FormattedMessage,{id:"link.flow.proxy_gateway"})}),h.jsx(Te.FormattedMessage,{id:"link.flow.secure_connection"})]})]})}),IU="RDBMS_ACCOUNT",PU=t=>t===IU,OA=({formSchema:t,initialValues:e,connector:n,proxy_id:r,authType:o,onCancel:i,onSubmit:s})=>{const[a]=_.Form.useForm(),l=y.useRef(null),c=(n==null?void 0:n.deployment_type)!=="SaasApp",u=PU(o);y.useEffect(()=>{e&&a.setFieldsValue(e)},[a,e]);const d=async f=>{var m;const p=await a.validateFields();c&&(p.proxy_id=(m=l.current)==null?void 0:m.getProxyId()),s(p,f)};return h.jsxs("div",{className:Gr.formLayout,children:[h.jsxs("div",{className:Gr.formContent,children:[h.jsx(Rg,{schema:t,form:a,initialValues:e,showSubmit:!1,showReset:!1,customTheme:sc}),c?h.jsx(Kg,{proxyId:r||"0",ref:l}):null]}),h.jsx("div",{className:Gr.formActions,children:h.jsxs(_.Space,{children:[h.jsx(_.Button,{onClick:i,children:"取消"}),u?h.jsx(_.Button,{onClick:()=>d(!0),children:"测试连接"}):null,h.jsx(_.Button,{type:"primary",onClick:()=>d(!1),children:"保存"})]})})]})},LU=t=>h.jsx(_.DatePicker,{style:{width:"100%"},picker:"date",value:Ht(t.value?t.value:new Date),onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD")))}}),$U=t=>h.jsx(_.DatePicker,{style:{width:"100%"},picker:"date",showTime:!0,value:Ht(t.value?t.value:new Date),onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD hh:mm:ss")))}}),zU=({value:t=[],onChange:e,valueType:n})=>{const r=a=>{const l=[...t];l.splice(a,1),e==null||e(l)},o=()=>{e==null||e([...t,{key:"",value:""}])},i=(a,l)=>{e==null||e(t.map((c,u)=>u===a?{...c,key:l}:c))},s=(a,l)=>{e==null||e(t.map((c,u)=>u===a?{...c,value:l}:c))};return h.jsxs("div",{children:[t.map((a,l)=>h.jsxs(_.Space,{size:"small",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[h.jsx(_.Input,{value:a.key,onChange:c=>i(l,c.target.value),placeholder:"Key"}),h.jsx(_.Input,{placeholder:"Value",style:{width:300},value:a.value,onChange:c=>s(l,c.target.value)}),h.jsx(_.Button,{icon:h.jsx(xi,{size:16}),onClick:()=>{r(l)}})]},a.key)),h.jsxs(_.Button,{type:"default",onClick:o,block:!0,children:[h.jsx(br,{size:16})," ",h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})]})]})},HU=t=>null;class Pd{constructor(e,n,r,o,i,s,a,l,c,u=0,d){this.p=e,this.stack=n,this.state=r,this.reducePos=o,this.pos=i,this.score=s,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=d}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let o=e.parser.context;return new Pd(e,[],n,r,r,0,[],0,o?new TA(o,o.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,o=e&65535,{parser:i}=this.p,s=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=i.dynamicPrecedence(o);if(a&&(this.score+=a),r==0){this.pushState(i.getGoto(this.state,o,!0),this.reducePos),o<i.minRepeatTerm&&this.storeNode(o,this.reducePos,this.reducePos,s?8:4,!0),this.reduceContext(o,this.reducePos);return}let l=this.stack.length-(r-1)*3-(e&262144?6:0),c=l?this.stack[l-2]:this.p.ranges[0].from,u=this.reducePos-c;u>=2e3&&!(!((n=this.p.parser.nodeSet.types[o])===null||n===void 0)&&n.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=u));let d=l?this.stack[l-1]:0,f=this.bufferBase+this.buffer.length-d;if(o<i.minRepeatTerm||e&131072){let p=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(o,c,p,f+4,!0)}if(e&262144)this.state=this.stack[l];else{let p=this.stack[l-3];this.state=i.getGoto(p,o,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(o,c)}storeNode(e,n,r,o=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this,a=this.buffer.length;if(a==0&&s.parent&&(a=s.bufferBase-s.parent.bufferBase,s=s.parent),a>0&&s.buffer[a-4]==0&&s.buffer[a-1]>-1){if(n==r)return;if(s.buffer[a-2]>=n){s.buffer[a-2]=r;return}}}if(!i||this.pos==r)this.buffer.push(e,n,r,o);else{let s=this.buffer.length;if(s>0&&(this.buffer[s-4]!=0||this.buffer[s-1]<0)){let a=!1;for(let l=s;l>0&&this.buffer[l-2]>r;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;s>0&&this.buffer[s-2]>r;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,o>4&&(o-=4)}this.buffer[s]=e,this.buffer[s+1]=n,this.buffer[s+2]=r,this.buffer[s+3]=o}}shift(e,n,r,o){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let i=e,{parser:s}=this.p;this.pos=o,!s.stateFlag(i,1)&&(o>r||n<=s.maxNode)&&(this.reducePos=o),this.pushState(i,Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=s.maxNode&&this.buffer.push(n,r,o,4)}else this.pos=o,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,o,4)}apply(e,n,r,o){e&65536?this.reduce(e):this.shift(e,n,r,o)}useNode(e,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let o=this.pos;this.reducePos=this.pos=o+e.length,this.pushState(n,o),this.buffer.push(r,o,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),o=e.bufferBase+n;for(;e&&o==e.bufferBase;)e=e.parent;return new Pd(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,o,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new VU(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if((r&65536)==0)return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let o=[];for(let i=0,s;i<n.length;i+=2)(s=n[i+1])!=this.state&&this.p.parser.hasAction(s,e)&&o.push(n[i],s);if(this.stack.length<120)for(let i=0;o.length<8&&i<n.length;i+=2){let s=n[i+1];o.some((a,l)=>l&1&&a==s)||o.push(n[i],s)}n=o}let r=[];for(let o=0;o<n.length&&r.length<4;o+=2){let i=n[o+1];if(i==this.state)continue;let s=this.split();s.pushState(i,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(n[o],this.pos),s.reducePos=this.pos,s.score-=200,r.push(s)}return r}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if((n&65536)==0)return!1;if(!e.validAction(this.state,n)){let r=n>>19,o=n&65535,i=this.stack.length-r*3;if(i<0||e.getGoto(this.stack[i],o,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;n=s}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(o,i)=>{if(!n.includes(o))return n.push(o),e.allActions(o,s=>{if(!(s&393216))if(s&65536){let a=(s>>19)-i;if(a>1){let l=s&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=r(s,i+1);if(a!=null)return a}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let n=new TA(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class TA{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class VU{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let o=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=o}}class Ld{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new Ld(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Ld(this.stack,this.pos,this.index)}}function $d(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,o=0;r<t.length;){let i=0;for(;;){let s=t.charCodeAt(r++),a=!1;if(s==126){i=65535;break}s>=92&&s--,s>=34&&s--;let l=s-32;if(l>=46&&(l-=46,a=!0),i+=l,a)break;i*=46}n?n[o++]=i:n=new e(i)}return n}class zd{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const NA=new zd;class jU{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=NA,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,o=this.rangeIndex,i=this.pos+e;for(;i<r.from;){if(!o)return null;let s=this.ranges[--o];i-=r.from-s.to,r=s}for(;n<0?i>r.to:i>=r.to;){if(o==this.ranges.length-1)return null;let s=this.ranges[++o];i+=s.from-r.to,r=s}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,o;if(n>=0&&n<this.chunk.length)r=this.pos+e,o=this.chunk.charCodeAt(n);else{let i=this.resolveOffset(e,1);if(i==null)return-1;if(r=i,r>=this.chunk2Pos&&r<this.chunk2Pos+this.chunk2.length)o=this.chunk2.charCodeAt(r-this.chunk2Pos);else{let s=this.rangeIndex,a=this.range;for(;a.to<=r;)a=this.ranges[++s];this.chunk2=this.input.chunk(this.chunk2Pos=r),r+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-r)),o=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),o}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=r}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=NA,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let o of this.ranges){if(o.from>=n)break;o.to>e&&(r+=this.input.read(Math.max(o.from,e),Math.min(o.to,n)))}return r}}class Os{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;WU(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}Os.prototype.contextual=Os.prototype.fallback=Os.prototype.extend=!1,Os.prototype.fallback=Os.prototype.extend=!1;function WU(t,e,n,r,o,i){let s=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;(a&t[s])!=0;){let c=t[s+1];for(let p=s+3;p<c;p+=2)if((t[p+1]&a)>0){let m=t[p];if(l.allows(m)&&(e.token.value==-1||e.token.value==m||UU(m,e.token.value,o,i))){e.acceptToken(m);break}}let u=e.next,d=0,f=t[s+2];if(e.next<0&&f>d&&t[c+f*3-3]==65535){s=t[c+f*3-1];continue e}for(;d<f;){let p=d+f>>1,m=c+p+(p<<1),b=t[m],v=t[m+1]||65536;if(u<b)f=p;else if(u>=v)d=p+1;else{s=t[m+2],e.advance();continue e}}break}}function BA(t,e,n){for(let r=e,o;(o=t[r])!=65535;r++)if(o==n)return r-e;return-1}function UU(t,e,n,r){let o=BA(n,r,e);return o<0||BA(n,r,t)<o}const Pn=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG);let Yg=null;function FA(t,e,n){let r=t.cursor(Ct.IncludeAnonymous);for(r.moveTo(e);;)if(!(n<0?r.childBefore(e):r.childAfter(e)))for(;;){if((n<0?r.to<e:r.from>e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class qU{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?FA(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?FA(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let r=this.trees[n],o=this.index[n];if(o==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=r.children[o],s=this.start[n]+r.positions[o];if(s>e)return this.nextStart=s,null;if(i instanceof xt){if(s==e){if(s<this.safeFrom)return null;let a=s+i.length;if(a<=this.safeTo){let l=i.prop(Qe.lookAhead);if(!l||a+l<this.fragment.to)return i}}this.index[n]++,s+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(s),this.index.push(0))}else this.index[n]++,this.nextStart=s+i.length}}}class GU{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new zd)}getActions(e){let n=0,r=null,{parser:o}=e.p,{tokenizers:i}=o,s=o.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;c<i.length;c++){if((1<<c&s)==0)continue;let u=i[c],d=this.tokens[c];if(!(r&&!u.fallback)&&((u.contextual||d.start!=e.pos||d.mask!=s||d.context!=a)&&(this.updateCachedToken(d,u,e),d.mask=s,d.context=a),d.lookAhead>d.end+25&&(l=Math.max(d.lookAhead,l)),d.value!=0)){let f=n;if(d.extended>-1&&(n=this.addActions(e,d.extended,d.end,n)),n=this.addActions(e,d.value,d.end,n),!u.extend&&(r=d,n>f))break}}for(;this.actions.length>n;)this.actions.pop();return l&&e.setLookAhead(l),!r&&e.pos==this.stream.end&&(r=new zd,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new zd,{pos:r,p:o}=e;return n.start=r,n.end=Math.min(r+1,o.stream.end),n.value=r==o.stream.end?o.parser.eofTerm:0,n}updateCachedToken(e,n,r){let o=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(o,e),r),e.value>-1){let{parser:i}=r.p;for(let s=0;s<i.specialized.length;s++)if(i.specialized[s]==e.value){let a=i.specializers[s](this.stream.read(e.start,e.end),r);if(a>=0&&r.p.parser.dialect.allows(a>>1)){(a&1)==0?e.value=a>>1:e.extended=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(o+1)}putAction(e,n,r,o){for(let i=0;i<o;i+=3)if(this.actions[i]==e)return o;return this.actions[o++]=e,this.actions[o++]=n,this.actions[o++]=r,o}addActions(e,n,r,o){let{state:i}=e,{parser:s}=e.p,{data:a}=s;for(let l=0;l<2;l++)for(let c=s.stateSlot(i,l?2:1);;c+=3){if(a[c]==65535)if(a[c+1]==1)c=ro(a,c+2);else{o==0&&a[c+1]==2&&(o=this.putAction(ro(a,c+2),n,r,o));break}a[c]==n&&(o=this.putAction(ro(a,c+1),n,r,o))}return o}}class RU{constructor(e,n,r,o){this.parser=e,this.input=n,this.ranges=o,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new jU(n,o),this.tokens=new GU(e,this.stream),this.topTerm=e.top[1];let{from:i}=o[0];this.stacks=[Pd.start(this,e.top[0],i)],this.fragments=r.length&&this.stream.end-i>e.bufferLength*4?new qU(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,r=this.stacks=[],o,i;if(this.bigReductionCount>300&&e.length==1){let[s]=e;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<e.length;s++){let a=e[s];for(;;){if(this.tokens.mainToken=null,a.pos>n)r.push(a);else{if(this.advanceStack(a,r,e))continue;{o||(o=[],i=[]),o.push(a);let l=this.tokens.getMainToken(a);i.push(l.value,l.end)}}break}}if(!r.length){let s=o&&YU(o);if(s)return Pn&&console.log("Finish with "+this.stackID(s)),this.stackToTree(s);if(this.parser.strict)throw Pn&&o&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&o){let s=this.stoppedAt!=null&&o[0].pos>this.stoppedAt?o[0]:this.runRecovery(o,i,r);if(s)return Pn&&console.log("Force-finish "+this.stackID(s)),this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(r.length>s)for(r.sort((a,l)=>l.score-a.score);r.length>s;)r.pop();r.some(a=>a.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let s=0;s<r.length-1;s++){let a=r[s];for(let l=s+1;l<r.length;l++){let c=r[l];if(a.sameState(c)||a.buffer.length>500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)r.splice(l--,1);else{r.splice(s--,1);continue e}}}r.length>12&&(r.sort((s,a)=>a.score-s.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let s=1;s<r.length;s++)r[s].pos<this.minStackPos&&(this.minStackPos=r[s].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,r){let o=e.pos,{parser:i}=this,s=Pn?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&o>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let d=this.fragments.nodeAt(o);d;){let f=this.parser.nodeSet.types[d.type.id]==d.type?i.getGoto(e.state,d.type.id):-1;if(f>-1&&d.length&&(!c||(d.prop(Qe.contextHash)||0)==u))return e.useNode(d,f),Pn&&console.log(s+this.stackID(e)+` (via reuse of ${i.getName(d.type.id)})`),!0;if(!(d instanceof xt)||d.children.length==0||d.positions[0]>0)break;let p=d.children[0];if(p instanceof xt&&d.positions[0]==0)d=p;else break}}let a=i.stateSlot(e.state,4);if(a>0)return e.reduce(a),Pn&&console.log(s+this.stackID(e)+` (via always-reduce ${i.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;c<l.length;){let u=l[c++],d=l[c++],f=l[c++],p=c==l.length||!r,m=p?e:e.split(),b=this.tokens.mainToken;if(m.apply(u,d,b?b.start:m.pos,f),Pn&&console.log(s+this.stackID(m)+` (via ${(u&65536)==0?"shift":`reduce of ${i.getName(u&65535)}`} for ${i.getName(d)} @ ${o}${m==e?"":", split"})`),p)return!0;m.pos>o?n.push(m):r.push(m)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return MA(e,n),!0}}runRecovery(e,n,r){let o=null,i=!1;for(let s=0;s<e.length;s++){let a=e[s],l=n[s<<1],c=n[(s<<1)+1],u=Pn?this.stackID(a)+" -> ":"";if(a.deadEnd&&(i||(i=!0,a.restart(),Pn&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,r))))continue;let d=a.split(),f=u;for(let p=0;p<10&&d.forceReduce()&&(Pn&&console.log(f+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,r));p++)Pn&&(f=this.stackID(d)+" -> ");for(let p of a.recoverByInsert(l))Pn&&console.log(u+this.stackID(p)+" (via recover-insert)"),this.advanceFully(p,r);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),Pn&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),MA(a,r)):(!o||o.score<d.score)&&(o=d)}return o}stackToTree(e){return e.close(),xt.build({buffer:Ld.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let n=(Yg||(Yg=new WeakMap)).get(e);return n||Yg.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function MA(t,e){for(let n=0;n<e.length;n++){let r=e[n];if(r.pos==t.pos&&r.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class KU{constructor(e,n,r){this.source=e,this.flags=n,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}}class Hd extends EC{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let a=0;a<e.repeatNodeCount;a++)n.push("");let r=Object.keys(e.topRules).map(a=>e.topRules[a][1]),o=[];for(let a=0;a<n.length;a++)o.push([]);function i(a,l,c){o[a].push([l,l.deserialize(String(c))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=Qe[l]);for(let c=1;c<a.length;){let u=a[c++];if(u>=0)i(u,l,a[c++]);else{let d=a[c+-u];for(let f=-u;f>0;f--)i(a[c++],l,d);c++}}}this.nodeSet=new Lh(n.map((a,l)=>vn.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:o[l],top:r.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=wC;let s=$d(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(IA),this.states=$d(e.states,Uint32Array),this.data=$d(e.stateData),this.goto=$d(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Os(s,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let o=new RU(this,e,n,r);for(let i of this.wrappers)o=i(o,e,n,r);return o}getGoto(e,n,r=!1){let o=this.goto;if(n>=o[0])return-1;for(let i=o[n+1];;){let s=o[i++],a=s&1,l=o[i++];if(a&&r)return l;for(let c=i+(s>>1);i<c;i++)if(o[i]==e)return l;if(a)return-1}}hasAction(e,n){let r=this.data;for(let o=0;o<2;o++)for(let i=this.stateSlot(e,o?2:1),s;;i+=3){if((s=r[i])==65535)if(r[i+1]==1)s=r[i=ro(r,i+2)];else{if(r[i+1]==2)return ro(r,i+2);break}if(s==n||s==0)return ro(r,i+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),o=r?n(r):void 0;for(let i=this.stateSlot(e,1);o==null;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=ro(this.data,i+2);else break;o=n(ro(this.data,i+1))}return o}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=ro(this.data,r+2);else break;if((this.data[r+2]&1)==0){let o=this.data[r+1];n.some((i,s)=>s&1&&i==o)||n.push(this.data[r],o)}}return n}configure(e){let n=Object.assign(Object.create(Hd.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let o=e.tokenizers.find(i=>i.from==r);return o?o.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,o)=>{let i=e.specializers.find(a=>a.from==r.external);if(!i)return r;let s=Object.assign(Object.assign({},r),{external:i.to});return n.specializers[o]=IA(s),s})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let i of e.split(" ")){let s=n.indexOf(i);s>=0&&(r[s]=!0)}let o=null;for(let i=0;i<n.length;i++)if(!r[i])for(let s=this.dialects[n[i]],a;(a=this.data[s++])!=65535;)(o||(o=new Uint8Array(this.maxTerm+1)))[a]=1;return new KU(e,r,o)}static deserialize(e){return new Hd(e)}}function ro(t,e){return t[e]|t[e+1]<<16}function YU(t){let e=null;for(let n of t){let r=n.p.stoppedAt;(n.pos==n.p.stream.end||r!=null&&n.pos>r)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function IA(t){if(t.external){let e=t.extend?1:0;return(n,r)=>t.external(n,r)<<1|e}return t.get}const XU=xC({String:V.string,Number:V.number,"True False":V.bool,PropertyName:V.propertyName,Null:V.null,", :":V.separator,"[ ]":V.squareBracket,"{ }":V.brace}),JU=Hd.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[XU],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0}),QU=Au.define({name:"json",parser:JU.configure({props:[rS.add({Object:iS({except:/^\s*\}/}),Array:iS({except:/^\s*\]/})}),sS.add({"Object Array":o8})]}),languageData:{closeBrackets:{brackets:["[","{",'"']},indentOnInput:/^\s*[\}\]]$/}});function PA(){return new G3(QU)}const ZU=t=>h.jsx(td,{height:"300px",style:{borderRadius:4,overflow:"hidden"},theme:bm,extensions:[PA()],...t}),{Text:eq}=_.Typography,tq=t=>h.jsx("div",{style:{padding:6,paddingRight:0,border:"1px solid #b0b5cb",borderRadius:4},children:h.jsx(_.Tooltip,{title:t.value,color:"cyan",placement:"topLeft",styles:{body:{width:500}},children:h.jsx(eq,{style:{color:"#b0b5cb"},ellipsis:!0,copyable:{text:t.value},children:t.value})})}),nq=t=>h.jsx(_.Input.Password,{addonBefore:G("link.flow.cipherText"),value:t.value,onChange:e=>{var n;return(n=t.onChange)==null?void 0:n.call(t,e.target.value)}}),rq=t=>{var r;const{multiple:e,...n}=t;return h.jsx(_.Select,{style:{borderRadius:6},mode:e?"multiple":void 0,...n,getPopupContainer:o=>o.parentNode,children:(r=t==null?void 0:t.options)==null?void 0:r.map(o=>h.jsx(_.Select.Option,{label:o.label,value:o.value,children:o.label},o.value))})},{TextArea:oq}=_.Input,iq=t=>h.jsx(oq,{value:t.value,onChange:e=>{var n;return(n=t.onChange)==null?void 0:n.call(t,e.target.value)}}),sq=t=>h.jsx(_.Input,{addonBefore:G("link.flow.text"),value:t.value,onChange:e=>{var n;return(n=t.onChange)==null?void 0:n.call(t,e.target.value)}}),aq=t=>h.jsx(_.TimePicker,{style:{width:"100%"},value:Ht(t.value??"00:00:00","HH:mm:ss"),onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("HH:mm:ss")))}}),lq={configFormContainer:"_configFormContainer_s061b_1"},cq=t=>t?Object.keys(t).map(e=>({key:e,value:t[e]})):[],Xg=t=>Array.isArray(t)?t.map(e=>{if(typeof e=="string"){const s=e.trim();return s?{label:s,value:s}:null}const n=(e==null?void 0:e.value)??(e==null?void 0:e.label)??"",r=n==null?"":String(n).trim();if(!r)return null;const o=(e==null?void 0:e.label)??"";return{label:o==null?r:String(o).trim()||r,value:r}}).filter(Boolean):[],uq=t=>{const e=t.display_name;switch(t.page_control){case Ee.SELECT:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_select")+t.display_name}],label:e,name:t.name,children:h.jsx(rq,{options:Xg(t.option_value_objects??t.option_values),multiple:t.multi_valued})},t.ui_id);case Ee.EXTEND_OBJ:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(zU,{valueType:t.value_type})},t.ui_id);case Ee.HIDDEN:return h.jsx(_.Form.Item,{style:{display:"none"},required:t.required,label:e,name:t.name,children:h.jsx(HU,{})},t.ui_id);case Ee.TEXT:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(sq,{})},t.ui_id);case Ee.PASSWORD:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(nq,{})},t.ui_id);case Ee.LABEL:return h.jsx(_.Form.Item,{required:t.required,label:e,name:t.name,children:h.jsx(tq,{})},t.ui_id);case Ee.DATE:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(LU,{})},t.ui_id);case Ee.TIME:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(aq,{})},t.ui_id);case Ee.DATETIME:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx($U,{})},t.ui_id);case Ee.TEXTAREA:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(iq,{})},t.ui_id);case Ee.FIXED_OBJ:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(_.Input.TextArea,{})},t.ui_id);case Ee.JSON:return h.jsx(_.Form.Item,{required:t.required,rules:[{required:t.required,message:G("link.flow.please_enter")+t.display_name}],label:e,name:t.name,children:h.jsx(ZU,{})},t.ui_id)}},dq=t=>{switch(t.page_control){case Ee.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.JSON:return JSON.stringify({})}},LA=y.memo(t=>{var c;const{config:e,proxy_id:n,connector:r}=t,[o]=_.Form.useForm(),i=y.useRef(null),s=St.useReactive({proxyId:"0"});y.useEffect(()=>{var u;(u=e==null?void 0:e.sub_params)!=null&&u.length&&o.setFieldsValue({...e.sub_params.reduce((d,f)=>{let p=f.value;return f.page_control===Ee.EXTEND_OBJ&&(p=cq(p)),d[f.name]=p??dq(f),d},{})})},[e,o]),y.useEffect(()=>{n&&(s.proxyId=n)},[n]);const a=()=>{o.validateFields().then(async u=>{var d;u.proxy_id=(d=i.current)==null?void 0:d.getProxyId(),t.onSubmit(u)})},l=()=>{o.validateFields().then(async u=>{var d;u.proxy_id=(d=i.current)==null?void 0:d.getProxyId(),t.onSubmit(u,!0)})};return h.jsxs("div",{className:Gr.formLayout,style:{position:"relative"},onClick:u=>{u.stopPropagation(),u.preventDefault()},children:[h.jsx("div",{className:Gr.formContent,children:h.jsxs(_.Form,{form:o,layout:"vertical",className:`${lq.configFormContainer} workflow-credential-form`,children:[(c=e==null?void 0:e.sub_params)==null?void 0:c.map(u=>h.jsxs("div",{children:[uq(u),u.page_control!==Ee.HIDDEN&&h.jsx("p",{className:"field-desc",children:u.description})]},u.ui_id)),r.deployment_type!=="SaasApp"?h.jsx(Kg,{proxyId:s.proxyId,ref:i}):null]})}),t.auth_type==="RDBMS_ACCOUNT"&&h.jsx("div",{className:Gr.rdbmsTestAction,children:h.jsx(_.Button,{type:"primary",style:{width:"100%"},onClick:l,children:h.jsx(Te.FormattedMessage,{id:"app.common.word.connection-test"})})}),h.jsxs("div",{className:Gr.formActions,children:[h.jsx(_.Button,{icon:h.jsx(ie.RollbackOutlined,{}),style:{width:90,borderRadius:4,marginRight:10},onClick:t.onCancel,children:h.jsx(Te.FormattedMessage,{id:"app.common.word.cancel"})}),h.jsx(_.Button,{type:"primary",icon:h.jsx(ie.CloudUploadOutlined,{}),style:{width:90,borderRadius:4},onClick:()=>a(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})]})]})}),fq={overflow:"hidden"},hq=72,pq=16,mq=t=>{const{visible:e,connector:n,config:r,formSchema:o,onCancel:i,onSubmit:s,auth_type:a,inAI:l}=t;return h.jsx(_.Modal,{title:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-account"}),style:{marginTop:0,paddingBottom:0,position:"absolute",top:hq,bottom:pq,left:12,right:12,maxWidth:"calc(100% - 24px)",marginInline:"auto"},className:Gr.accountModal,mask:!1,getContainer:()=>document.getElementById("flow-designer-container"),zIndex:Bc.nestedModal,width:560,styles:{body:fq},footer:null,maskClosable:!l,open:e,onCancel:i,children:o?h.jsx(OA,{formSchema:o,connector:n,authType:a,onCancel:i,onSubmit:s}):h.jsx(LA,{config:r,connector:n,nodeId:"",auth_type:a,onCancel:i,onSubmit:s})})},gq={overflow:"hidden"},wq=72,bq=16,vq=t=>{const{visible:e,connector:n,config:r,formSchema:o,initialValues:i,onCancel:s,onSubmit:a,auth_type:l,proxy_id:c,inAI:u}=t;return h.jsx(_.Modal,{title:G("link.flow.edit_account"),mask:!1,style:{marginTop:0,paddingBottom:0,position:"absolute",top:wq,bottom:bq,left:12,right:12,maxWidth:"calc(100% - 24px)",marginInline:"auto"},className:Gr.accountModal,getContainer:()=>document.getElementById("flow-designer-container"),zIndex:Bc.nestedModal,width:560,footer:null,styles:{body:gq},open:e,maskClosable:!u,onCancel:s,children:o?h.jsx(OA,{formSchema:o,initialValues:i,connector:n,proxy_id:c,authType:l,onCancel:s,onSubmit:a}):h.jsx(LA,{config:r,proxy_id:c,connector:n,nodeId:"",auth_type:l,onCancel:s,onSubmit:a})})},Di={accountOption:"_accountOption_4vdjt_14",accountName:"_accountName_4vdjt_21",nameEditIcon:"_nameEditIcon_4vdjt_34",editInputWrapper:"_editInputWrapper_4vdjt_44",nameEditInput:"_nameEditInput_4vdjt_48",accountActions:"_accountActions_4vdjt_53",updateTime:"_updateTime_4vdjt_58"},yq=t=>t?Object.keys(t).map(e=>({key:e,value:t[e]})):[],Jg=(t=[])=>{const e={};return t.forEach(n=>{e[n.key]=n.value}),e},Cq={eq:"EQ",ne:"NOT",in:"IN",notin:"NOT_IN",not_in:"NOT_IN",gt:"GT",lt:"LT",gte:"GE",lte:"LE"};function kq(t){if(!(t!=null&&t.field)||!t.operator)return;const e=Cq[String(t.operator).toLowerCase()];if(e)return{deps:[t.field],conditions:{key:t.field,keyword:e,value:t.value}}}function Sq(t){return an(t.visible_when)??kq(t.display_condition)}const $A={STRING:ge.TEXT,TEXTAREA:ge.TEXTAREA,PASSWORD:ge.PASSWORD,HIDDEN:ge.HIDDEN,NUMBER:ge.NUMBER,BOOLEAN:ge.SWITCH,SELECT:ge.SELECT,DATETIME:ge.DATETIME,CODE:ge.CODE,PROXY:ge.PROXY,OBJECT:ge.OBJECT,ARRAY:ge.ARRAY,DYNAMIC_ARRAY:ge.ARRAY,KEYVALUE:ge.KEY_VALUE},zA=t=>String(t.type??"").toUpperCase(),Eq=t=>t.item_schema??[],HA=t=>String(t.item_type??"").toUpperCase(),an=t=>t??void 0,xq=t=>Object.fromEntries((t??[]).map(e=>[e.key,Zg(e)])),Dq=t=>{const e=String(t.picker_mode??"DATETIME").toUpperCase();return e==="DATE"?ge.DATE:e==="TIME"?ge.TIME:ge.DATETIME},Qg=t=>{const e=String(t.picker_mode??"DATETIME").toUpperCase();return e==="DATE"?"YYYY-MM-DD":e==="TIME"?"HH:mm:ss":"YYYY-MM-DD HH:mm:ss"},_q=t=>({type:$A[HA(t)]||ge.TEXT,name:"item",label:t.item_label||"项"}),Aq=t=>t.some(e=>e.name==="name")?"name":void 0;function Oq(t){if(!t)return[];const e=[],n=t.minLength??t.min_length,r=t.maxLength??t.max_length;return n!=null&&e.push({type:"min",value:n,message:`最少 ${n} 个字符`}),r!=null&&e.push({type:"max",value:r,message:`最多 ${r} 个字符`}),t.pattern&&e.push({type:"pattern",value:t.pattern,message:"格式不正确"}),t.min!=null&&e.push({type:"min",value:t.min,message:`最小值 ${t.min}`}),t.max!=null&&e.push({type:"max",value:t.max,message:`最大值 ${t.max}`}),e}function Zg(t){var r,o,i;const e=zA(t)==="DATETIME"?Dq(t):$A[zA(t)]||ge.TEXT,n={type:e,name:t.key,label:t.label||t.key,placeholder:an(t.placeholder),helpText:an(t.help_text),defaultValue:an(t.default_value),required:an(t.required),disabled:an(t.disabled),visibleWhen:Sq(t),rules:Oq(t.validation),valueModePolicy:an(t.value_mode_policy)};switch(e){case ge.SELECT:return{...n,type:ge.SELECT,options:(r=t.options)==null?void 0:r.map(s=>({label:s.label,value:s.value})),showSearch:!0,allowClear:!0};case ge.NUMBER:return{...n,type:ge.NUMBER,min:an((o=t.validation)==null?void 0:o.min),max:an((i=t.validation)==null?void 0:i.max)};case ge.DATETIME:return{...n,type:ge.DATETIME,showTime:!0,format:Qg(t),outputFormat:"string"};case ge.DATE:return{...n,type:ge.DATE,format:Qg(t),outputFormat:"string"};case ge.TIME:return{...n,type:ge.TIME,format:Qg(t),outputFormat:"string"};case ge.OBJECT:return{...n,type:ge.OBJECT,properties:xq(t.properties)};case ge.ARRAY:if(HA(t)==="OBJECT"){const s=Eq(t).map(Zg);return{...n,type:ge.ARRAY_OBJECT,columns:s,minItems:an(t.min_items),maxItems:an(t.max_items),columnLayout:s.length>1?"grid":"vertical",titleFieldName:Aq(s)}}return{...n,type:ge.ARRAY,itemSchema:_q(t),minItems:an(t.min_items),maxItems:an(t.max_items),itemLabel:an(t.item_label)};case ge.KEY_VALUE:return{...n,type:ge.KEY_VALUE,keyPlaceholder:an(t.key_placeholder),valuePlaceholder:an(t.value_placeholder)};default:return n}}function VA(t){return{fields:t.map(Zg),layout:"vertical"}}const jA=(...t)=>{for(const e of t)if(typeof e=="string"&&e.trim())return e.trim()};function Tq(t){if(!t)return null;const e=jA(t.key,t.credentialKey,t.name);return e?{key:e,label:jA(t.displayName,t.label,t.name,e)??e,required:t.required===!0}:null}function ew(t){if(!Array.isArray(t))return[];const e=[],n=new Set;for(const r of t){const o=Tq(r);!o||n.has(o.key)||(n.add(o.key),e.push(o))}return e}function Nq(t){var n,r;const e=ew(t);return((n=e.find(o=>o.required))==null?void 0:n.key)??((r=e[0])==null?void 0:r.key)}const Bq=_.Form.Item,{Option:Fq}=_.Select,{Text:Mq,Title:dre}=_.Typography,Ts="[workflow:account-debug]",Iq=t=>!!(t&&/^\d+$/.test(t)),_i=t=>t&&typeof t=="object"&&!Array.isArray(t)?Object.keys(t):[],Pq=t=>Array.isArray(t)?t.map(e=>e==null?void 0:e.key).filter(Boolean):[],Lq=t=>!!(t&&typeof t=="object"&&Array.isArray(t.sub_params)),$q=t=>[t==null?void 0:t.auth_schema,t==null?void 0:t.config_schema,t==null?void 0:t.schema,t].find(Lq)??{},WA=t=>{var o,i,s,a,l;const e=(o=t==null?void 0:t.credential_schema)==null?void 0:o.fields,n=(i=t==null?void 0:t.auth_schema)==null?void 0:i.sub_params,r=((s=t==null?void 0:t.config_schema)==null?void 0:s.sub_params)??(t==null?void 0:t.sub_params);return{type:Array.isArray(t)?"array":t===null?"null":typeof t,keys:_i(t),id:t==null?void 0:t.id,auth_type:t==null?void 0:t.auth_type,account_key:(t==null?void 0:t.account_key)??((a=t==null?void 0:t.credential_schema)==null?void 0:a.key),account_ver:(t==null?void 0:t.account_ver)??((l=t==null?void 0:t.credential_schema)==null?void 0:l.version),credentialSchemaKeys:_i(t==null?void 0:t.credential_schema),credentialFieldCount:Array.isArray(e)?e.length:void 0,credentialFieldKeys:Pq(e),authSchemaKeys:_i(t==null?void 0:t.auth_schema),authSchemaSubParamCount:Array.isArray(n)?n.length:void 0,authSchemaSubParamNames:Array.isArray(n)?n.map(c=>c==null?void 0:c.name).filter(Boolean):void 0,configSchemaKeys:_i(t==null?void 0:t.config_schema),configSubParamCount:Array.isArray(r)?r.length:void 0}},tw=t=>({keys:_i(t),subParamCount:Array.isArray(t==null?void 0:t.sub_params)?t.sub_params.length:0,subParamNames:Array.isArray(t==null?void 0:t.sub_params)?t.sub_params.map(e=>e==null?void 0:e.name).filter(Boolean):[],subParamControls:Array.isArray(t==null?void 0:t.sub_params)?t.sub_params.map(e=>e==null?void 0:e.page_control).filter(Boolean):[]}),Vd=(t,e)=>{var n,r;return{account_key:(t==null?void 0:t.account_key)??((n=t==null?void 0:t.credential_schema)==null?void 0:n.key)??e??null,account_ver:(t==null?void 0:t.account_ver)??((r=t==null?void 0:t.credential_schema)==null?void 0:r.version)??null}},UA=t=>{const e=t==null?void 0:t.credential_schema,n=e==null?void 0:e.fields;return(!Array.isArray(n)||!n.length)&&console.warn(`${Ts} credential_schema.fields missing or empty`,{model:WA(t)}),Array.isArray(n)&&n.length?VA(n):null},zq=({value:t,onChange:e,linkApp:n,actionAccountSchemaId:r,selectTitle:o="授权配置",disabled:i=!1,placeholder:s="请选择账号"})=>{const[a,l]=y.useState([]),[c,u]=y.useState(!1),[d,f]=y.useState(!1),[p,m]=y.useState(!1),b=y.useRef(null),v=y.useRef(null),w=_.Form.useFormInstance(),g=y.useMemo(()=>r?`_account_${r}`:"_account",[r]);y.useEffect(()=>{w&&w.validateFields([g]).catch(()=>{})},[t,w,g]);const C=St.useReactive({createModalVisible:!1,modifyModalVisible:!1,configModel:{},credentialFormSchema:null,credentialInitialValues:{},schemaMeta:{},account_scheme_id:"",name:"",auth_type:"",modifyId:"",proxy_id:"",editId:"",editValue:"",createLoading:!1,createRequestLock:!1,isEditing:!1}),S=r==null?void 0:String(r),k=async()=>{if(!(!(n!=null&&n.id)&&!S)){u(!0);try{const I=Iq(S)?n==null?void 0:n.id:void 0,z=await Gy(I,S);z?l(z.items||[]):_.message.error("获取账号列表失败")}catch(I){console.error(`${Ts} 获取账号列表失败:`,I),_.message.error("获取账号列表失败")}finally{u(!1)}}};y.useEffect(()=>{k()},[n==null?void 0:n.id,S]),y.useEffect(()=>{C.editId&&b.current&&setTimeout(()=>{var I;(I=b.current)==null||I.focus()},100)},[C.editId]);const x=I=>{if(p){f(!0);return}f(I)},D=()=>{if(!C.editId||!C.editValue){C.editId="",C.isEditing=!1,m(!1);return}Hy(C.editId,C.editValue).then(()=>{k(),C.editId="",C.editValue="",C.isEditing=!1,m(!1),_.message.success(G("link.flow.modification_success"))}).catch(()=>{C.editId="",C.isEditing=!1,m(!1)})},E=(I,z,H)=>{I.stopPropagation(),I.preventDefault(),C.isEditing=!0,m(!0),f(!0),C.editId=z,C.editValue=H,setTimeout(()=>{v.current&&v.current.focus()},0)},O=I=>{I.stopPropagation(),I.preventDefault(),m(!0)},A=I=>{C.isEditing||e&&e(I)},T=()=>{if(!S){_.message.error("未配置账号模式");return}C.createLoading=!0,Kf(S).then(I=>{var K;const z=UA(I),H=Vd(I,S),J=z?{}:$q(I);z||console.warn(`${Ts} create modal will use legacy DynamicAccountForm`,{reason:"credentialFormSchema is null",model:WA(I),configModel:tw(J)}),C.credentialFormSchema=z,C.credentialInitialValues={},C.schemaMeta=H,C.configModel=J,C.account_scheme_id=I.id,C.name=I.name,C.auth_type=I.auth_type??((K=I.credential_schema)==null?void 0:K.type),C.createModalVisible=!0}).catch(I=>{console.error(`${Ts} account model load failed for create`,{schemaId:S,error:I})}).finally(()=>{C.createLoading=!1})},B=I=>{Ly(I).then(async z=>{var R;const H=z.account_schema_id,J=z.account_key,K=z.account_ver,ee=J??H??S;let $=null;if(ee)try{$=await Kf(String(ee),K)}catch(te){console.error("获取账号模型失败:",te)}const U=UA($);C.credentialFormSchema=U,C.credentialInitialValues=U?z.config??{}:{},C.schemaMeta={...Vd($,J??S),account_key:J??Vd($,S).account_key,account_ver:K??Vd($).account_ver},C.configModel=U?{}:z.config,C.account_scheme_id=H??($==null?void 0:$.id)??z.id,C.name=z.name,C.proxy_id=z.proxy_id,C.auth_type=z.auth_type??($==null?void 0:$.auth_type)??((R=$==null?void 0:$.credential_schema)==null?void 0:R.type)??"",C.modifyId=I,C.modifyModalVisible=!0})},M=y.useCallback((I,z)=>{if(C.createRequestLock)return;let H=I;if(!C.credentialFormSchema){if(H=Mt.cloneDeep(C.configModel),!Array.isArray(H==null?void 0:H.sub_params)){console.error(`${Ts} create account legacy config has no sub_params`,{configModel:tw(C.configModel),valueKeys:_i(I)}),_.message.error("账号模型配置为空,无法保存");return}H.sub_params.forEach(K=>{let ee=I[K.name];K.page_control===Ee.EXTEND_OBJ&&(ee=Jg(ee)),K.value=ee})}const J=I.proxy_id;delete I.proxy_id,C.createRequestLock=!0,z?Xf((n==null?void 0:n.id)??null,C.account_scheme_id,C.auth_type,C.name,H,C.modifyId,J,C.schemaMeta).then(K=>{K&&_.message.success("测试连接成功!")}).finally(()=>{C.createRequestLock=!1}):$y((n==null?void 0:n.id)??null,C.account_scheme_id,C.auth_type,C.name,H,J,C.schemaMeta).then(()=>{_.message.success(G("link.flow.creation_success")),k(),C.createModalVisible=!1}).finally(()=>{C.createRequestLock=!1})},[]),F=y.useCallback(()=>{C.createModalVisible=!1},[]),N=(I,z)=>{let H=I;if(!C.credentialFormSchema){if(H=Mt.cloneDeep(C.configModel),!Array.isArray(H==null?void 0:H.sub_params)){console.error(`${Ts} modify account legacy config has no sub_params`,{configModel:tw(C.configModel),valueKeys:_i(I)}),_.message.error("账号模型配置为空,无法保存");return}H.sub_params.forEach(K=>{let ee=I[K.name];K.page_control===Ee.EXTEND_OBJ&&(ee=Jg(ee)),K.value=ee})}const J=I.proxy_id;delete I.proxy_id,z?Xf((n==null?void 0:n.id)??null,C.account_scheme_id,C.auth_type,C.name,H,C.modifyId,J,C.schemaMeta).then(K=>{K&&_.message.success("测试连接成功!")}):zy(C.modifyId,null,null,null,null,H,J,C.schemaMeta).then(()=>{_.message.success(G("link.flow.modification_success")),k(),C.modifyModalVisible=!1,C.modifyId=""})},P=I=>h.jsxs("div",{children:[I,h.jsx(_.Divider,{style:{margin:"4px 0"}}),h.jsx("div",{style:{padding:"4px",textAlign:"center"},children:h.jsx(_.Button,{icon:h.jsx(ie.UserAddOutlined,{}),onClick:T,loading:C.createLoading,type:"link",block:!0,children:"创建新账号"})})]});return h.jsxs(h.Fragment,{children:[h.jsx(Bq,{label:o,layout:"vertical",required:!0,name:g,initialValue:t,rules:[{validator:()=>t?Promise.resolve():Promise.reject(new Error(s||"请选择账号"))}],children:h.jsx(_.Select,{ref:v,value:t,onChange:A,style:{width:"100%"},placeholder:s,disabled:i,loading:c,allowClear:!0,popupRender:P,classNames:{popup:{root:"workflow-account-select__popup"}},listHeight:320,open:d,onOpenChange:x,children:a.map(I=>h.jsx(Fq,{value:I.id,children:h.jsxs("div",{className:Di.accountOption,onClick:z=>{C.isEditing&&z.stopPropagation()},children:[h.jsx("div",{className:`${Di.accountName} workflow-account-select__name`,children:C.editId!==I.id?h.jsxs(y.Fragment,{children:[h.jsx("span",{children:I.name}),h.jsx(ie.EditOutlined,{className:`${Di.nameEditIcon} workflow-account-select__edit`,onClick:z=>E(z,I.id,I.name)})]}):h.jsx("div",{className:Di.editInputWrapper,onClick:O,children:h.jsx(_.Input,{ref:b,defaultValue:I.name,className:Di.nameEditInput,onClick:O,onMouseDown:z=>{z.stopPropagation(),z.preventDefault()},onFocus:z=>{z.stopPropagation(),m(!0)},onPressEnter:z=>{z.stopPropagation(),z.preventDefault(),D()},onBlur:()=>{D()},onChange:z=>{C.editValue=z.target.value}})})}),h.jsxs("div",{className:Di.accountActions,children:[h.jsx(Mq,{type:"secondary",className:Di.updateTime,children:Ht(Number(I.update_time)*1e3).format("YYYY-MM-DD HH:mm:ss")}),h.jsx(_.Button,{type:"link",icon:h.jsx(ie.FileSearchOutlined,{}),size:"small",onClick:z=>{z.stopPropagation(),B(I.id)},children:"编辑"})]})]})},I.id))})}),h.jsx(mq,{onSubmit:M,onCancel:F,inAI:!0,auth_type:C.auth_type,config:C.configModel,formSchema:C.credentialFormSchema,visible:C.createModalVisible,connector:n}),h.jsx(vq,{onSubmit:N,inAI:!0,onCancel:()=>{C.modifyModalVisible=!1},proxy_id:C.proxy_id,auth_type:C.auth_type,config:C.configModel,formSchema:C.credentialFormSchema,initialValues:C.credentialInitialValues,visible:C.modifyModalVisible,connector:n})]})},qA=({credentialRequirements:t,actionAccountSchemaId:e,value:n,onChange:r,...o})=>{var l;const i=y.useMemo(()=>{const c=e?[{key:String(e)}]:[];return ew(t!=null&&t.length?t:c)},[e,t]),[s,a]=y.useState(n?(l=i[0])==null?void 0:l.key:void 0);return y.useEffect(()=>{var c;if(!n){a(void 0);return}!s&&((c=i[0])!=null&&c.key)&&a(i[0].key)},[s,i,n]),i.length===0?null:h.jsx(y.Fragment,{children:i.map(c=>h.jsx(zq,{...o,actionAccountSchemaId:c.key,selectTitle:i.length>1?c.label:"授权配置",value:s===c.key?n:void 0,onChange:u=>{a(u?c.key:void 0),r==null||r(u)}},c.key))})},Hq=(t=32)=>{const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=new Uint8Array(t);return crypto.getRandomValues(n),Array.from(n,r=>e[r%e.length]).join("")},Vq=t=>{const{value:e,onChange:n,disabled:r}=t,[o,i]=y.useState(e||""),[s,a]=y.useState(!1);y.useEffect(()=>{e!==void 0&&e!==o&&i(e)},[e,o]);const l=()=>{const f=Hq();i(f),a(!0),n==null||n(f)},c=()=>{l()},u=async()=>{if(!o){_.message.warning(G("components.authTokenField.emptyTokenWarning"));return}try{await navigator.clipboard.writeText(o),_.message.success(G("components.authTokenField.copySuccess"))}catch{_.message.error(G("components.authTokenField.copyFailed"))}},d=()=>{a(f=>!f)};return h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[h.jsx(_.Input,{style:{flex:1},value:o,readOnly:!0,type:s?"text":"password",placeholder:G("components.authTokenField.placeholder")}),h.jsx(_.Tooltip,{title:G("components.authTokenField.copy"),children:h.jsx(_.Button,{icon:h.jsx(ie.CopyOutlined,{}),onClick:u,disabled:r||!o})}),h.jsx(_.Tooltip,{title:G(s?"components.authTokenField.hideToken":"components.authTokenField.showToken"),children:h.jsx(_.Button,{icon:s?h.jsx(ie.EyeInvisibleOutlined,{}):h.jsx(ie.EyeOutlined,{}),onClick:d,disabled:r||!o})}),h.jsx(_.Tooltip,{title:G(o?"components.authTokenField.regenerate":"components.authTokenField.generate"),children:h.jsx(_.Button,{icon:h.jsx(ie.SyncOutlined,{}),onClick:c,disabled:r,type:"primary",ghost:!0})})]})},jq=(t=32)=>{const e="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",n=new Uint8Array(t);return crypto.getRandomValues(n),Array.from(n,r=>e[r%e.length]).join("")},Wq=t=>{const{value:e,onChange:n,disabled:r}=t,[o,i]=y.useState(e||""),[s,a]=y.useState(!1);y.useEffect(()=>{e!==void 0&&e!==o&&i(e)},[e,o]);const l=()=>{const f=jq();i(f),a(!0),n==null||n(f)},c=()=>{if(!o){l();return}_.Modal.confirm({title:G("common.info"),content:G("components.authTokenField.regenerateConfirm"),okText:G("app.common.word.confirm"),cancelText:G("app.common.word.cancel"),onOk:l})},u=async()=>{if(!o){_.message.warning(G("components.authTokenField.emptyTokenWarning"));return}try{await navigator.clipboard.writeText(o),_.message.success(G("components.authTokenField.copySuccess"))}catch{_.message.error(G("components.authTokenField.copyFailed"))}},d=()=>{a(f=>!f)};return h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[h.jsx(_.Input,{style:{flex:1},value:o,readOnly:!0,type:s?"text":"password",placeholder:G("components.authTokenField.placeholder")}),h.jsx(_.Tooltip,{title:G("components.authTokenField.copy"),children:h.jsx(_.Button,{icon:h.jsx(ie.CopyOutlined,{}),onClick:u,disabled:r||!o})}),h.jsx(_.Tooltip,{title:G(s?"components.authTokenField.hideToken":"components.authTokenField.showToken"),children:h.jsx(_.Button,{icon:s?h.jsx(ie.EyeInvisibleOutlined,{}):h.jsx(ie.EyeOutlined,{}),onClick:d,disabled:r||!o})}),h.jsx(_.Tooltip,{title:G(o?"components.authTokenField.regenerate":"components.authTokenField.generate"),children:h.jsx(_.Button,{icon:h.jsx(ie.SyncOutlined,{}),onClick:c,disabled:r,type:"primary",ghost:!0})})]})},GA=10,Uq=["OAUTH","OAUTH2","OIDC"],qq=t=>{const e=new Set([...t.support_protocol??[],...t.auth_protocol?[t.auth_protocol]:[]]);return Array.from(e).some(n=>Uq.includes(n))},Gq=t=>{const{value:e,onChange:n,disabled:r}=t,o=Sl(),[i,s]=y.useState([]),[a,l]=y.useState(!1),[c,u]=y.useState(!1),[d,f]=y.useState(""),[p,m]=y.useState(1),[b,v]=y.useState(!1),w=y.useRef(0),g=y.useMemo(()=>`${window.location.origin}/iam/token`,[]),C=async(O=1,A=!1,T="")=>{const B=w.current+1;w.current=B,A?u(!0):l(!0);try{const M=await Ry({current:O,pageSize:GA},{filter:T});if(w.current!==B)return;const F=(M.items??[]).filter(qq),P=(A?[...i,...F]:F).filter((I,z,H)=>H.findIndex(J=>J.client_id===I.client_id)===z);s(P),m(O),v((M.total??0)>O*GA)}catch{w.current===B&&_.message.error(G("components.selectOAuth2ClientField.fetchFailed"))}finally{w.current===B&&(l(!1),u(!1))}};let S=null;y.useEffect(()=>{S&&(clearTimeout(S),S=null),S=window.setTimeout(()=>{C(1,!1,d.trim())},300)},[d]);const k=async()=>{!b||a||c||await C(p+1,!0,d.trim())},x=async()=>{try{await navigator.clipboard.writeText(g),_.message.success(G("components.selectOAuth2ClientField.copySuccess"))}catch{_.message.error(G("components.selectOAuth2ClientField.copyFailed"))}},D=()=>{o("/apps/manage",!0)},E=()=>{o("https://1in15q85qd.apifox.cn/8698545m0",!0)};return h.jsxs(_.Space,{direction:"vertical",size:12,style:{width:"100%"},children:[h.jsxs("div",{children:[h.jsx(_.Select,{value:e,onChange:n,disabled:r,loading:a,showSearch:!0,filterOption:!1,optionLabelProp:"label",placeholder:G("components.selectOAuth2ClientField.placeholder"),onSearch:f,notFoundContent:a?h.jsx(_.Spin,{size:"small"}):null,getPopupContainer:O=>O.parentNode,popupRender:O=>h.jsxs("div",{children:[O,!a&&i.length===0?h.jsx("div",{style:{padding:"16px 12px"},children:h.jsx(_.Empty,{image:_.Empty.PRESENTED_IMAGE_SIMPLE,description:h.jsxs(_.Space,{direction:"vertical",size:4,children:[h.jsx(_.Typography.Text,{type:"secondary",children:G("components.selectOAuth2ClientField.emptyTitle")}),h.jsx(_.Typography.Text,{type:"secondary",style:{fontSize:12},children:G("components.selectOAuth2ClientField.emptyDescription")})]}),children:h.jsx(_.Button,{type:"primary",ghost:!0,icon:h.jsx(ie.LinkOutlined,{}),onClick:D,children:G("components.selectOAuth2ClientField.goToAppManage")})})}):null,i.length>0?h.jsx("div",{style:{padding:"8px 12px",textAlign:"center",borderTop:"1px solid #f0f0f0"},children:h.jsx(_.Button,{type:"link",icon:h.jsx(ie.ReloadOutlined,{}),onClick:k,loading:c,disabled:!b,children:G(b?"components.selectOAuth2ClientField.loadMore":"components.selectOAuth2ClientField.loadedAll")})}):null]}),options:i.map(O=>({label:O.client_name,value:O.client_id}))}),h.jsxs(_.Typography.Text,{type:"secondary",style:{display:"block",marginTop:8,fontSize:12},children:[G("components.selectOAuth2ClientField.selectDescriptionPrefix"),h.jsx(_.Button,{style:{padding:0},type:"link",onClick:D,children:G("components.selectOAuth2ClientField.goToAppManage")}),G("components.selectOAuth2ClientField.selectDescriptionSuffix")]})]}),h.jsxs("div",{children:[h.jsx(_.Typography.Text,{strong:!0,style:{display:"block",marginBottom:8},children:G("components.selectOAuth2ClientField.tokenEndpoint")}),h.jsxs(_.Space.Compact,{block:!0,className:"workflow-oauth-token-endpoint",children:[h.jsx(_.Input,{value:g,readOnly:!0}),h.jsx(_.Button,{icon:h.jsx(ie.CopyOutlined,{}),onClick:x,disabled:r,children:G("components.selectOAuth2ClientField.copy")})]}),h.jsxs(_.Typography.Text,{type:"secondary",style:{display:"block",marginTop:8,fontSize:12},children:[G("components.selectOAuth2ClientField.tokenDescriptionPrefix"),h.jsx(_.Button,{style:{padding:0},type:"link",onClick:E,children:G("components.selectOAuth2ClientField.documentation")})]})]})]})},Rq=({children:t,value:e,onChange:n})=>{const[r,o]=y.useState(e==="{{$fromAI}}"),i=()=>{const a=!r;o(a),a?n==null||n("{{$fromAI}}"):n==null||n("")},s=()=>r?h.jsxs("div",{style:{position:"relative"},children:[h.jsx(_.Input,{value:"由AI生成 ",readOnly:!0,style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",border:"1px solid transparent",borderImage:"linear-gradient(45deg, #00d4ff, #9b59b6, #e74c3c) 1",color:"#ffffff",fontWeight:"500",textShadow:"0 1px 2px rgba(0,0,0,0.3)",borderRadius:"6px",fontSize:"13px",paddingLeft:"32px",paddingRight:"28px",height:"32px",boxShadow:"0 2px 8px rgba(102, 126, 234, 0.3)"},prefix:h.jsx("div",{style:{background:"linear-gradient(45deg, #00d4ff, #1e3c72)",borderRadius:"50%",width:"16px",height:"16px",display:"flex",alignItems:"center",justifyContent:"center",marginRight:"4px",animation:"pulse 2s ease-in-out infinite alternate"},children:h.jsx("span",{style:{color:"#fff",fontSize:"8px"},children:"AI"})}),suffix:h.jsx(_.Button,{type:"text",size:"small",onClick:i,style:{color:"#ffffff",border:"none",background:"rgba(255,255,255,0.2)",borderRadius:"50%",width:"18px",height:"18px",display:"flex",alignItems:"center",justifyContent:"center",transition:"all 0.2s ease",minWidth:"18px",padding:0},onMouseEnter:a=>{a.currentTarget.style.background="rgba(255,255,255,0.3)",a.currentTarget.style.transform="scale(1.1)"},onMouseLeave:a=>{a.currentTarget.style.background="rgba(255,255,255,0.2)",a.currentTarget.style.transform="scale(1)"},children:h.jsx(ie.CloseOutlined,{style:{fontSize:"10px"}})})}),h.jsx("style",{children:`
113
113
  @keyframes pulse {
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===`
@@ -142,7 +142,7 @@ ${n}`:""}`}).join(`
142
142
  `):"暂无日志",rf=async t=>{var e;try{if((e=navigator==null?void 0:navigator.clipboard)!=null&&e.writeText)return await navigator.clipboard.writeText(t),!0}catch{}try{const n=document.createElement("textarea");n.value=t,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}},NN=(t,e,n)=>{const r=new Map(t.map(l=>[l.id,l])),o=new Map(e.map(l=>[l.id,l])),i=[],s=[],a=[];return o.forEach((l,c)=>{if(!r.has(c)){i.push(c);return}const u=DN(n(r.get(c))),d=DN(n(l));u!==d&&a.push(c)}),r.forEach((l,c)=>{o.has(c)||s.push(c)}),{added:i,removed:s,changed:a}},bQ=({visible:t,nodes:e,edges:n,onClose:r})=>{const[o,i]=y.useState([]),[s,a]=y.useState(!1),[l,c]=y.useState(!1),[u,d]=y.useState(),[f,p]=y.useState(),m=y.useRef({nodes:[],edges:[]});y.useEffect(()=>{const N=m.current;if(m.current={nodes:e,edges:n},!t)return;const P=NN(N.nodes,e,Ib),I=NN(N.edges,n,Pb),z=P.added.length+P.removed.length+P.changed.length>0,H=I.added.length+I.removed.length+I.changed.length>0;if(!z&&!H)return;const J=new Map(e.map(se=>[se.id,Ni(se)])),K=Object.fromEntries(J.entries()),ee=_N(n,J),$=AN(n,J),U={nodeDiff:P,edgeDiff:I,nodeCount:{prev:N.nodes.length,next:e.length},edgeCount:{prev:N.edges.length,next:n.length},edgeRelations:ee,nodeNameMap:K,duplicateEdges:$},R=[];z&&R.push(`节点 +${P.added.length} -${P.removed.length} ~${P.changed.length}`),H&&R.push(`连线 +${I.added.length} -${I.removed.length} ~${I.changed.length}`);const te={id:`${Date.now()}-${Math.random()}`,time:EN(),message:R.join(" | "),nodeSummary:z?{added:P.added.length,removed:P.removed.length,changed:P.changed.length}:void 0,edgeSummary:H?{added:I.added.length,removed:I.removed.length,changed:I.changed.length}:void 0,edgeRelations:ee,duplicateEdges:$,detail:U,expanded:!1};i(se=>[te,...se].slice(0,hQ)),console.log("[WorkflowDebugPanel]",te.message,U)},[n,e,t]);const b=y.useMemo(()=>e.map(N=>({label:`${N.id} (${Ni(N)})`,value:N.id})),[e]),v=y.useMemo(()=>n.map(N=>({label:`${N.id} (${N.source} -> ${N.target})`,value:N.id})),[n]),w=e.find(N=>N.id===u),g=n.find(N=>N.id===f),C=y.useMemo(()=>{const N=new Map;return e.forEach(P=>{N.set(P.id,Ni(P))}),N},[e]),S=y.useMemo(()=>AN(n,C),[n,C]),k=y.useMemo(()=>{const N=new Set;return S==null||S.forEach(P=>{P.edgeIds.forEach(I=>N.add(I))}),N},[S]),x=y.useMemo(()=>n.map(N=>{const P=C.get(N.source)||N.source,I=C.get(N.target)||N.target;return{id:N.id,text:`${N.source}(${P}) -> ${N.target}(${I})`,isDuplicate:k.has(N.id)}}),[k,n,C]),D=y.useMemo(()=>mQ(e,n,C,k),[k,n,C,e]),E=y.useMemo(()=>wQ(e,n),[n,e]),O=y.useMemo(()=>new Map(E.nodes.map(N=>[N.id,N])),[E.nodes]),A=Math.max(E.width,400),T=Math.max(E.height,180),B=y.useMemo(()=>{const{levels:N,unvisited:P}=ON(e,n),I=N.map(z=>{const H=z.nodes.map(J=>`${J.id}(${Ni(J)})`).join(" | ");return`L${z.level}: ${H}`});return P.length&&I.push(`循环/未连接: ${P.map(z=>`${z.id}(${Ni(z)})`).join(" | ")}`),I.length?I.join(`
143
143
  `):"暂无结构"},[n,e]),M=y.useMemo(()=>s&&l?o.filter(N=>N.nodeSummary||N.edgeSummary):s?o.filter(N=>N.nodeSummary):l?o.filter(N=>N.edgeSummary):o,[o,l,s]),F=y.useMemo(()=>{const N={nodes:e.map(Ib),edges:n.map(Pb),edgeRelations:_N(n,C),duplicateEdges:S,mermaidSource:D};return JSON.stringify(N,null,2)},[S,n,D,C,e]);return t?h.jsxs(ne.Panel,{position:"bottom-right",className:"workflow-debug-panel",children:[h.jsxs("div",{className:"workflow-debug-panel__header",children:[h.jsx("span",{children:"画布调试"}),h.jsx(_.Button,{size:"small",onClick:r,children:"关闭"})]}),h.jsxs("div",{className:"workflow-debug-panel__section",children:[h.jsxs("div",{className:"workflow-debug-panel__log-header",children:[h.jsx("span",{children:"变更日志"}),h.jsxs(_.Space,{size:6,children:[h.jsx(_.Button,{size:"small",onClick:async()=>{const N=TN(M);await rf(N)?_.message.success("日志已复制"):_.message.error("复制失败")},children:"复制日志"}),h.jsx(_.Button,{size:"small",onClick:async()=>{const N=M[0],P=N?TN([N]):"暂无日志";await rf(P)?_.message.success("最新日志已复制"):_.message.error("复制失败")},children:"复制最新"}),h.jsx(_.Button,{size:"small",onClick:async()=>{await rf(F)?_.message.success("快照已复制"):_.message.error("复制失败")},children:"复制快照"})]})]}),h.jsx("div",{className:"workflow-debug-panel__toolbar",children:h.jsxs(_.Space,{size:6,wrap:!0,children:[h.jsx(_.Button,{size:"small",onClick:()=>a(N=>!N),children:s?"显示全部":"仅节点"}),h.jsx(_.Button,{size:"small",onClick:()=>c(N=>!N),children:l?"显示全部":"仅连线"}),h.jsx(_.Button,{size:"small",onClick:()=>i(N=>N.map(P=>({...P,expanded:!0}))),children:"全部展开"}),h.jsx(_.Button,{size:"small",onClick:()=>i(N=>N.map(P=>({...P,expanded:!1}))),children:"全部收起"}),h.jsx(_.Button,{size:"small",onClick:()=>i([]),children:"清空"})]})}),h.jsxs("div",{className:"workflow-debug-panel__log-list",children:[M.length===0&&h.jsx("div",{className:"workflow-debug-panel__log-empty",children:"暂无日志"}),M.map(N=>h.jsxs("div",{className:"workflow-debug-panel__log-item",children:[h.jsxs("div",{className:"workflow-debug-panel__log-title",children:[h.jsx("span",{className:"workflow-debug-panel__log-time",children:N.time}),h.jsx("span",{children:N.message})]}),h.jsxs("div",{className:"workflow-debug-panel__log-tags",children:[N.nodeSummary&&h.jsxs("span",{className:"workflow-debug-panel__tag workflow-debug-panel__tag-node",children:["节点 +",N.nodeSummary.added," -",N.nodeSummary.removed," ~",N.nodeSummary.changed]}),N.edgeSummary&&h.jsxs("span",{className:"workflow-debug-panel__tag workflow-debug-panel__tag-edge",children:["连线 +",N.edgeSummary.added," -",N.edgeSummary.removed," ~",N.edgeSummary.changed]})]}),h.jsx("div",{className:"workflow-debug-panel__log-actions",children:h.jsx(_.Button,{size:"small",onClick:()=>i(P=>P.map(I=>I.id===N.id?{...I,expanded:!I.expanded}:I)),children:N.expanded?"收起详情":"展开详情"})}),N.expanded&&h.jsxs("div",{className:"workflow-debug-panel__log-detail",children:[N.edgeRelations&&h.jsxs("div",{className:"workflow-debug-panel__log-detail-block",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"连线关系"}),h.jsx("pre",{children:N.edgeRelations.join(`
144
144
  `)})]}),N.duplicateEdges&&N.duplicateEdges.length>0&&h.jsxs("div",{className:"workflow-debug-panel__log-detail-block",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"重复连线"}),h.jsx("pre",{children:N.duplicateEdges.map(P=>`${P.relation} [${P.edgeIds.join(", ")}]`).join(`
145
- `)})]}),N.detail&&h.jsxs("div",{className:"workflow-debug-panel__log-detail-block",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"详细信息"}),h.jsx("pre",{children:JSON.stringify(N.detail,null,2)})]})]})]},N.id))]})]}),h.jsxs("div",{className:"workflow-debug-panel__section",children:[h.jsxs("div",{className:"workflow-debug-panel__summary",children:[h.jsxs("span",{children:["节点数: ",e.length]}),h.jsxs("span",{children:["连线数: ",n.length]})]}),h.jsxs("div",{className:"workflow-debug-panel__detail",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"结构图预览"}),h.jsx("div",{className:"workflow-debug-panel__graph",children:h.jsxs("svg",{className:"workflow-debug-panel__graph-canvas",width:"100%",height:T,viewBox:`0 0 ${A} ${T}`,preserveAspectRatio:"xMinYMin meet",children:[h.jsxs("defs",{children:[h.jsx("marker",{id:"workflow-debug-arrow",markerWidth:"10",markerHeight:"10",refX:"8",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:h.jsx("path",{d:"M0,0 L0,6 L9,3 z",fill:"#8c8c8c"})}),h.jsx("marker",{id:"workflow-debug-arrow-dup",markerWidth:"10",markerHeight:"10",refX:"8",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:h.jsx("path",{d:"M0,0 L0,6 L9,3 z",fill:"#cf1322"})})]}),E.edges.map(N=>{const P=O.get(N.source),I=O.get(N.target);if(!P||!I)return null;const z=k.has(N.id),H=P.x+nf,J=P.y+Bl/2,K=I.x,ee=I.y+Bl/2;return h.jsx("line",{x1:H,y1:J,x2:K,y2:ee,stroke:z?"#cf1322":"#8c8c8c",strokeWidth:z?2.2:1.4,markerEnd:z?"url(#workflow-debug-arrow-dup)":"url(#workflow-debug-arrow)"},N.id)}),E.nodes.map(N=>h.jsxs("g",{transform:`translate(${N.x}, ${N.y})`,children:[h.jsx("rect",{width:nf,height:Bl,rx:6,fill:"#ffffff",stroke:"#91caff",strokeWidth:1.4}),h.jsx("text",{x:nf/2,y:Bl/2+4,textAnchor:"middle",fontSize:"11",fill:"#1f1f1f",children:N.label})]},N.id))]})})]}),h.jsxs("div",{className:"workflow-debug-panel__detail",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"Mermaid 图"}),h.jsx("div",{className:"workflow-debug-panel__mermaid-actions",children:h.jsx(_.Button,{size:"small",onClick:async()=>{await rf(D)?_.message.success("Mermaid 已复制"):_.message.error("复制失败")},children:"复制 Mermaid"})}),h.jsx("pre",{children:D})]}),h.jsxs("div",{className:"workflow-debug-panel__detail",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"结构布局"}),h.jsx("pre",{children:B})]}),h.jsxs("div",{className:"workflow-debug-panel__detail",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"连线关系"}),h.jsxs("div",{className:"workflow-debug-panel__edge-list",children:[x.length===0&&h.jsx("div",{className:"workflow-debug-panel__log-empty",children:"暂无连线"}),x.map(N=>h.jsxs("div",{className:`workflow-debug-panel__edge-line${N.isDuplicate?" workflow-debug-panel__edge-line--duplicate":""}`,children:[h.jsx("span",{children:N.text}),N.isDuplicate&&h.jsx("span",{className:"workflow-debug-panel__edge-flag",children:"重复"})]},N.id))]})]}),S&&S.length>0&&h.jsxs("div",{className:"workflow-debug-panel__detail",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"重复连线"}),h.jsx("div",{className:"workflow-debug-panel__edge-list",children:S.map(N=>h.jsxs("div",{className:"workflow-debug-panel__edge-line--duplicate",children:[h.jsx("span",{children:N.relation}),h.jsx("span",{className:"workflow-debug-panel__edge-flag",children:N.edgeIds.join(", ")})]},N.key))})]}),h.jsxs(_.Space,{direction:"vertical",size:8,style:{width:"100%"},children:[h.jsx(_.Select,{value:u,placeholder:"选择节点查看详情",options:b,onChange:N=>d(N),allowClear:!0,size:"small"}),h.jsx(_.Select,{value:f,placeholder:"选择连线查看详情",options:v,onChange:N=>p(N),allowClear:!0,size:"small"})]}),h.jsxs("div",{className:"workflow-debug-panel__detail",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"节点详情"}),h.jsx("pre",{children:w?JSON.stringify(Ib(w),null,2):"未选择节点"})]}),h.jsxs("div",{className:"workflow-debug-panel__detail",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"连线详情"}),h.jsx("pre",{children:g?JSON.stringify({...Pb(g),sourceName:C.get(g.source),targetName:C.get(g.target),isDuplicate:k.has(g.id)},null,2):"未选择连线"})]})]})]}):null},BN=y.createContext(null),vQ=({api:t,children:e})=>h.jsx(BN.Provider,{value:t,children:e}),Lb=()=>{const t=y.useContext(BN);if(!t)throw new Error("useCanvasApi must be used within a CanvasApiProvider");return t},FN=y.createContext(null),yQ=({value:t,children:e})=>h.jsx(FN.Provider,{value:t,children:e}),MN=()=>y.useContext(FN)??{hasTriggerNode:!1,isMcpServerCanvas:!1};function CQ({nodes:t,edges:e}){const n=new Map(t.map(a=>[a.id,a])),r=new Map,o=[],i=[];for(const a of t){if(!Nl(a))continue;const l=Mb(a);if(!l){o.push(a.id),i.push({code:"SCHEMA_NOT_READY",reason:"节点端口 Schema 尚未就绪,保存时交由后端继续校验",blocking:!1,nodeId:a.id});continue}r.set(a.id,l);for(const c of l.inputs??[]){if(!c.required)continue;e.some(d=>d.target===a.id&&d.targetHandle===c.name)||i.push({code:"REQUIRED_INPUT_MISSING",reason:`必需输入端口 ${c.displayName||c.name} 尚未连接`,blocking:!0,nodeId:a.id,portName:c.name})}}for(const a of e){const l=n.get(a.source),c=n.get(a.target),u=Nl(l),d=Nl(c);if(!u&&!d||u&&!r.has(a.source)||d&&!r.has(a.target))continue;const f=e.filter(m=>m!==a&&(!a.id||m.id!==a.id)),p=xN({sourceNode:l,targetNode:c,sourceHandle:a.sourceHandle,targetHandle:a.targetHandle,edges:f});p.applicable&&!p.valid&&p.code!=="SCHEMA_NOT_READY"&&p.code!=="NOT_APPLICABLE"&&i.push({code:p.code,reason:p.reason,blocking:!0,edgeId:a.id,sourceNodeId:a.source,targetNodeId:a.target})}const s=i.filter(a=>a.blocking);return{valid:s.length===0,issues:i,blockingIssues:s,missingSchemaNodeIds:o}}const of={categoryUnavailable:"link.flow.connectable.category_unavailable",connectorUnavailable:"link.flow.connectable.connector_unavailable",actionUnavailable:"link.flow.connectable.action_unavailable",loadFailed:"link.flow.connectable.load_failed",noCompatibleNodes:"link.flow.connectable.no_compatible_nodes",noCompatibleInput:"link.flow.connectable.no_compatible_input",noCompatibleOutput:"link.flow.connectable.no_compatible_output",noBidirectionalCompatiblePort:"link.flow.connectable.no_bidirectional_compatible_port",schemaUnavailable:"link.flow.connectable.schema_unavailable",existingEdgeInvalid:"link.flow.connectable.existing_edge_invalid"},kQ=({onOpenNodeSelector:t})=>h.jsx(ne.Panel,{position:"top-center",style:{background:"transparent",boxShadow:"none",border:"0 none",width:"100%",height:"100%",display:"flex",flexFlow:"column",justifyContent:"center"},children:h.jsxs("div",{className:"setup-panel",children:[h.jsx("h4",{children:" 选择一个开始节点 "}),h.jsx("div",{className:"desc",children:"入口类型决定画布定义"}),h.jsx("div",{className:"start-node-placeholder",children:h.jsxs("div",{className:"start-node-select",children:[h.jsxs("button",{type:"button",onClick:()=>t(),className:"nodrag nopan start-node trigger","aria-label":"添加触发节点",children:[h.jsx("div",{className:"start-node-icon",children:"TR"}),h.jsxs("div",{className:"start-node-text",children:[h.jsx("h3",{className:"start-node-text-title",children:"自动化触发器"}),h.jsx("p",{className:"start-node-text-desc",children:"由触发器启动业务流程"})]}),h.jsx("div",{className:"node-footer",children:"选择触发方式 ›"})]}),h.jsxs("button",{type:"button",onClick:()=>{t({protocol:$e.MCP_SERVER})},className:"nodrag nopan start-node mcp","aria-label":"添加 MCP 节点",children:[h.jsx("div",{className:"start-node-icon",children:"MCP"}),h.jsxs("div",{className:"start-node-text",children:[h.jsx("h3",{className:"start-node-text-title",children:"MCP 网关"}),h.jsx("p",{className:"start-node-text-desc",children:"基于画布编排快速构建 MCP SERVER"})]}),h.jsx("div",{className:"node-footer",children:"开始配置 ›"})]})]})})]})}),SQ=t=>{var A,T,B;const{workflowId:e,strategy:n,onOffline:r,nodeTypes:o}=t,i=Pt(),s=Te.useIntl(),a=y.useRef(""),l=uQ(t,n.stickyNodeKey),{setUnSave:c,store:u,updateSaveStatus:d}=l,f=((T=(A=i.nodeSelector)==null?void 0:A.connectable)==null?void 0:T.enabled)===!0,p=At(),{hasTriggerNode:m,isMcpServerCanvas:b}=l,v=y.useCallback(()=>{if(!e||!n.buildFlowPayload)throw new Error("当前画布不支持生成 ACM 草稿数据");const{nodes:M,edges:F}=u.getState(),N=M.map(z=>z.id),P=F.filter(z=>N.includes(z.target)&&z.source&&z.sourceHandle&&z.targetHandle),I=Iw.getState().workflow;return n.buildFlowPayload({nodes:M,edges:P,workflowName:I.workflowName,workflowId:e,executionControl:I.executionControl,metadata:I.flowMetadata})},[u,n,e]),w=y.useCallback(async()=>{var M;if(!e)throw new Error("缺少工作流 ID");try{d(Ln.SAVING);const{nodes:F,edges:N}=u.getState();if(f){const K=CQ({nodes:F,edges:N});if(K.missingSchemaNodeIds.length>0){const ee=[...K.missingSchemaNodeIds].sort().join(",");a.current!==ee&&(a.current=ee,_.message.warning(s.formatMessage({id:of.schemaUnavailable}))),console.warn("[workflow:connectable] save with unavailable schemas",{nodeIds:K.missingSchemaNodeIds})}else a.current="";if(!K.valid){const ee=s.formatMessage({id:of.existingEdgeInvalid});_.message.error(ee),console.warn("[workflow:connectable] block save for invalid graph",{issueCount:K.blockingIssues.length,issues:K.blockingIssues.map($=>({code:$.code,nodeId:$.nodeId,portName:$.portName,edgeId:$.edgeId,sourceNodeId:$.sourceNodeId,targetNodeId:$.targetNodeId}))}),d(Ln.ERROR,new Error(ee));return}}const P=F.map(K=>K.id),I=N.filter(K=>P.includes(K.target)&&K.source&&K.sourceHandle&&K.targetHandle),z=Iw.getState().workflow,H=n.buildFlowPayload?v():void 0,J={...H,nodes:H.nodes.map(K=>K.saveType?{...K,node_type:K.saveType}:K)};return await n.saveFlow({nodes:J.nodes,edges:I,workflowName:z.workflowName,workflowId:e,executionControl:z.executionControl,metadata:z.flowMetadata,payload:J}),c(!1),d(Ln.SAVED),J&&await((M=t.onSave)==null?void 0:M.call(t,J)),J}catch(F){throw d(Ln.ERROR,F),F}},[f,v,s,t.onSave,c,u,n,d,e]);l.saveFlowRef.current=w;const g=hJ(w),{loadError:C,retry:S}=cJ({workflowId:e,strategy:n,setNodes:l.setNodes,setEdges:l.setEdges,fitView:l.reactFlow.fitView,setLoading:l.setLoading,dispatch:l.dispatch,setFlowOpStatusAction:l.setFlowOpStatusAction,refreshWorkFlowNum:l.refreshWorkFlowNum,onLoad:t.onLoad});dJ({workflowId:e,strategy:n,store:l.store,addNodes:l.addNodes,addEdges:l.addEdges,removeEdges:l.removeEdges,updateEdge:l.reactFlow.updateEdge,setNodeAddCallback:l.setNodeAddCallback,handleEdgeAddNode:l.handleEdgeAddNode,setNodeConfigVisible:l.setNodeConfigVisible,setNodeFitHumanView:l.setNodeFitHumanView,validateConnectionAgainstSnapshot:l.validateConnectionAgainstSnapshot,saveFlow:g});const k=n.HeaderComponent,x=n.PanelComponent,D=n.ConfigModalComponent,E=p&&!m&&!b,O=y.useMemo(()=>({hasTriggerNode:m,isMcpServerCanvas:b}),[m,b]);return h.jsx(vQ,{api:l.canvasApi,children:h.jsxs(yQ,{value:O,children:[h.jsxs("div",{className:l.isPreviewMode?"workflow-canvas-container workflow-canvas-container-preview":"workflow-canvas-container",style:{height:i.canvas.height?`${i.canvas.height}`:void 0},children:[l.showCanvasHeader&&h.jsx(k,{loading:l.loading||!!C,onSave:w,getFlowPayload:v,autoSaveStatus:l.autoSaveStatus,unSave:l.unSave,lastSavedTime:l.lastSavedTime,onOffline:r}),h.jsxs("div",{className:"workflow-canvas",children:[h.jsx(ZX,{loading:l.loading,error:C,onRetry:S}),h.jsx(eJ,{}),h.jsxs(ne.ReactFlow,{nodes:l.nodes,edges:l.edges,onNodesChange:l.onNodesChange,onEdgesChange:l.handleEdgesChange,onConnect:l.handleConnect,multiSelectionKeyCode:null,nodeTypes:o,edgeTypes:UX,connectionLineType:ne.ConnectionLineType.Bezier,connectionMode:ne.ConnectionMode.Loose,onNodeMouseEnter:l.onNodeMouseEnter,onNodeMouseLeave:l.onNodeMouseLeave,onEdgeMouseEnter:l.onEdgeMouseEnter,onEdgeMouseLeave:l.onEdgeMouseLeave,onNodeContextMenu:l.onNodeContextMenu,onPaneContextMenu:l.onPaneContextMenu,defaultEdgeOptions:KX,style:qX,defaultViewport:l.isPreviewMode?RX:GX,minZoom:.1,maxZoom:2,fitView:!1,snapToGrid:!0,snapGrid:[20,20],deleteKeyCode:null,nodesDraggable:!l.isInteractionDisabled,nodesConnectable:!l.isInteractionDisabled,elementsSelectable:!l.isInteractionDisabled,className:"react-flow-canvas-container",...l.restNativeProps,isValidConnection:l.isValidConnection,children:[l.showBackground&&h.jsx(ne.Background,{gap:(B=i.canvas.grid)==null?void 0:B.size,color:"#eee",variant:ne.BackgroundVariant.Lines}),l.showFastOperationButtons&&!E&&h.jsx(QX,{onOpenNodeSelector:l.handleOpenNodeSelector,onAddNoteNode:l.handleAddNoteNode,onTidyCanvas:l.handleTidy}),!l.loading&&!C&&E&&h.jsx(kQ,{onOpenNodeSelector:l.handleOpenNodeSelector}),l.showControls&&h.jsx(ne.Controls,{onInteractiveChange:M=>{l.setLocked(!M)}}),!l.loading&&l.showMiniMap&&h.jsx(fQ,{}),h.jsx(x,{}),h.jsx(oJ,{horizontal:l.helperLineHorizontal,vertical:l.helperLineVertical}),h.jsx(bQ,{visible:l.debugVisible,nodes:l.nodes,edges:l.edges,onClose:()=>l.setDebugVisible(!1)})]})]})]}),D&&h.jsx(D,{})]})})};var yr=(t=>(t.SECOND="second",t.MINUTE="minute",t.HOUR="hour",t))(yr||{});function EQ(t){return{[yr.SECOND]:"SECONDS",[yr.MINUTE]:"MINUTES",[yr.HOUR]:"HOURS"}[t]}function xQ(t){return{SECONDS:yr.SECOND,MINUTES:yr.MINUTE,HOURS:yr.HOUR}[t]}function DQ(){return{enableControl:!1,timeoutValue:30,timeoutUnit:yr.MINUTE,maxNodeExecutions:1e4,webhookUrl:""}}function _Q(t){return{enabled:t.enableControl,timeout_value:t.timeoutValue,timeout_unit:EQ(t.timeoutUnit),max_node_executions:t.maxNodeExecutions,webhook_url:t.webhookUrl||void 0}}function AQ(t){return{enableControl:t.enabled,timeoutValue:t.timeout_value,timeoutUnit:xQ(t.timeout_unit),maxNodeExecutions:t.max_node_executions,webhookUrl:t.webhook_url||""}}function OQ(t){if(!t)return!0;try{return new URL(t),!0}catch{return!1}}const{Text:$b}=_.Typography,TQ=y.forwardRef((t,e)=>{const[n,r]=y.useState(!1),[o,i]=y.useState(!1),[s]=_.Form.useForm(),a=_.Form.useWatch("enableControl",s),l=Ms(),c=Is(b=>b.workflow.executionControl),u=Lb(),d=()=>{r(!0),s.setFieldsValue(c?AQ(c):DQ())},f=()=>{r(!1)};y.useImperativeHandle(e,()=>({open:d,close:f}),[d,f]);const p=async()=>{try{const b=await s.validateFields();i(!0),l(mT(_Q(b))),await u.saveFlow(),_.message.success(G("common.save_success")),r(!1)}catch(b){_.message.error(G("common.save_failed")),console.error(b)}finally{i(!1)}},m=(b,v)=>!v||OQ(v)?Promise.resolve():Promise.reject(new Error(G("app.workflow.global_config.url_invalid")));return h.jsx(_.Drawer,{title:G("app.workflow.canvas.header.settings_label"),placement:"right",width:480,open:n,onClose:f,footer:h.jsxs(_.Space,{style:{float:"right"},children:[h.jsx(_.Button,{onClick:f,children:G("app.common.word.cancel")}),h.jsx(_.Button,{type:"primary",onClick:p,loading:o,children:G("app.common.word.save")})]}),children:h.jsxs(_.Form,{form:s,layout:"vertical",autoComplete:"off",children:[h.jsx(_.Form.Item,{label:G("app.workflow.global_config.enable_control"),name:"enableControl",valuePropName:"checked",children:h.jsx(_.Switch,{})}),a&&h.jsxs(h.Fragment,{children:[h.jsxs(_.Form.Item,{label:G("app.workflow.global_config.timeout_label"),required:!0,style:{marginBottom:8},children:[h.jsxs(_.Space.Compact,{style:{width:"100%"},children:[h.jsx(_.Form.Item,{name:"timeoutValue",noStyle:!0,rules:[{required:!0,message:G("app.workflow.global_config.timeout_required")},{type:"number",min:1,message:G("app.workflow.global_config.timeout_min")}],children:h.jsx(_.InputNumber,{style:{width:"70%"},placeholder:G("app.workflow.global_config.please_input"),min:1})}),h.jsx(_.Form.Item,{name:"timeoutUnit",noStyle:!0,rules:[{required:!0}],children:h.jsxs(_.Select,{style:{width:"30%"},children:[h.jsx(_.Select.Option,{value:yr.SECOND,children:G("app.workflow.global_config.unit_second")}),h.jsx(_.Select.Option,{value:yr.MINUTE,children:G("common.minute")}),h.jsx(_.Select.Option,{value:yr.HOUR,children:G("common.hour")})]})})]}),h.jsx($b,{type:"secondary",style:{fontSize:12},children:G("app.workflow.global_config.timeout_help")})]}),h.jsx(_.Form.Item,{label:G("app.workflow.global_config.max_node_label"),name:"maxNodeExecutions",rules:[{required:!0,message:G("app.workflow.global_config.max_node_required")},{type:"number",min:1,message:G("app.workflow.global_config.max_node_min")}],children:h.jsx(_.InputNumber,{style:{width:"100%"},placeholder:G("app.workflow.global_config.please_input"),min:1,precision:0})}),h.jsx($b,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-16,marginBottom:16},children:G("app.workflow.global_config.max_node_help")}),h.jsx(_.Form.Item,{label:G("app.workflow.global_config.webhook_label"),name:"webhookUrl",rules:[{validator:m}],children:h.jsx(_.Input,{placeholder:G("app.workflow.global_config.webhook_placeholder")})}),h.jsx($b,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-16},children:G("app.workflow.global_config.webhook_help")})]})]})})}),NQ=t=>t==="category"?"分类":"标签",IN=({value:t=[],onChange:e,placeholder:n,templateId:r,optionItems:o,type:i,onCreate:s,onUpdate:a,onDelete:l,onAddRelation:c,onRemoveRelation:u})=>{const[d,f]=y.useState(!1),[p,m]=y.useState(null),[b,v]=y.useState(""),[w,g]=y.useState(!1),[C,S]=y.useState(""),[k,x]=y.useState(!1),D=NQ(i),E=I=>{var z;return(z=o.find(H=>H.name===I))==null?void 0:z.id},O=async I=>{const z=E(I);if(!z)return;const H=t.includes(I);try{x(!0),H?(await u(r,z),e==null||e(t.filter(J=>J!==I))):(await c(r,z),e==null||e([...t,I]))}finally{x(!1)}},A=(I,z)=>{z.stopPropagation();const H=E(I);H&&u(r,H).then(()=>{e==null||e(t.filter(J=>J!==I))}).catch(()=>{_.message.error("移除失败")})},T=(I,z)=>{z.stopPropagation(),m(I),v(I)},B=async()=>{const I=b.trim();if(!I||!p)return;if(I.length>8){_.message.error("名称长度不能超过8个字符");return}const z=E(p);if(z)try{x(!0),await a(z,I),e==null||e(t.map(H=>H===p?I:H)),_.message.success("修改成功")}catch{_.message.error("修改失败")}finally{x(!1),m(null),v("")}},M=()=>{m(null),v("")},F=async I=>{const z=E(I);if(z)try{x(!0),await l(z),e==null||e(t.filter(H=>H!==I)),_.message.success("删除成功")}catch{_.message.error("删除失败")}finally{x(!1)}},N=async()=>{const I=C.trim();if(I){if(I.length>8){_.message.error("名称长度不能超过8个字符");return}try{x(!0),await s(I),g(!1),S(""),_.message.success("创建成功")}catch{_.message.error("创建失败")}finally{x(!1)}}},P=()=>{g(!1),S("")};return h.jsxs("div",{className:"template-editable-select",children:[h.jsxs("div",{className:"template-editable-select-input",role:"combobox",tabIndex:0,"aria-expanded":d,"aria-haspopup":"listbox","aria-label":`选择或管理${D}`,onClick:()=>f(!d),onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),f(z=>!z)),I.key==="Escape"&&f(!1)},children:[h.jsx("div",{className:"template-editable-select-tags",children:t.length===0?h.jsx("span",{className:"template-editable-select-placeholder",children:n}):t.map(I=>h.jsx(_.Tag,{closable:!0,onClose:z=>A(I,z),style:{marginRight:4,marginBottom:4},children:I},I))}),h.jsx("div",{className:`template-editable-select-arrow ${d?"template-editable-select-arrow-open":""}`,children:h.jsx(ie.DownOutlined,{})})]}),d&&h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button","aria-label":`关闭${D}选择器`,className:"template-editable-select-dropdown-overlay",onClick:()=>f(!1)}),h.jsx("div",{className:"template-editable-select-dropdown-container",role:"listbox","aria-label":`${D}选项`,onClick:I=>I.stopPropagation(),children:h.jsxs("div",{className:"template-editable-select-dropdown",children:[o.map(I=>h.jsx("div",{className:"template-editable-select-dropdown-item",children:p===I.name?h.jsx("div",{className:"template-editable-select-edit-container",children:h.jsx(_.Input,{autoFocus:!0,className:"template-editable-select-edit-input",disabled:k,maxLength:8,onChange:z=>v(z.target.value),onPressEnter:B,placeholder:`输入新${D}名称(8个字符以内)`,size:"small",suffix:h.jsxs("div",{className:"template-editable-select-edit-actions",children:[h.jsx(_.Button,{className:"template-editable-select-confirm-btn",icon:h.jsx(ie.CheckOutlined,{}),loading:k,onClick:B,size:"small",type:"text"}),h.jsx(_.Button,{className:"template-editable-select-cancel-btn",disabled:k,icon:h.jsx(ie.CloseOutlined,{}),onClick:M,size:"small",type:"text"})]}),value:b})}):h.jsxs(h.Fragment,{children:[h.jsxs("button",{type:"button",role:"option","aria-selected":t.includes(I.name),className:"template-editable-select-item-content",onClick:()=>O(I.name),children:[h.jsx("div",{className:"template-editable-select-check",children:t.includes(I.name)&&h.jsx(ie.CheckOutlined,{style:{color:"#1890ff"}})}),h.jsx("span",{className:"template-editable-select-name",children:I.name})]}),h.jsxs("div",{className:"template-editable-select-actions",children:[h.jsx(_.Button,{className:"template-editable-select-action-btn",disabled:k,icon:h.jsx(ie.EditOutlined,{}),onClick:z=>T(I.name,z),size:"small",type:"text"}),h.jsx(_.Popconfirm,{cancelText:"取消",okText:"确定",onConfirm:()=>F(I.name),title:`确定删除${D}"${I.name}"吗?`,children:h.jsx(_.Button,{className:"template-editable-select-action-btn",danger:!0,disabled:k,icon:h.jsx(ie.DeleteOutlined,{}),onClick:z=>z.stopPropagation(),size:"small",type:"text"})})]})]})},I.id)),w?h.jsx("div",{className:"template-editable-select-dropdown-item",children:h.jsx("div",{className:"template-editable-select-edit-container",children:h.jsx(_.Input,{autoFocus:!0,className:"template-editable-select-edit-input",disabled:k,maxLength:8,onChange:I=>S(I.target.value),onPressEnter:N,placeholder:`输入新${D}名称(8个字符以内)`,size:"small",suffix:h.jsxs("div",{className:"template-editable-select-edit-actions",children:[h.jsx(_.Button,{className:"template-editable-select-confirm-btn",icon:h.jsx(ie.CheckOutlined,{}),loading:k,onClick:N,size:"small",type:"text"}),h.jsx(_.Button,{className:"template-editable-select-cancel-btn",disabled:k,icon:h.jsx(ie.CloseOutlined,{}),onClick:P,size:"small",type:"text"})]}),value:C})})}):h.jsxs("button",{type:"button",className:"template-editable-select-add-item",onClick:()=>g(!0),children:[h.jsx(ie.PlusOutlined,{style:{color:"#1890ff",marginRight:4}}),h.jsx("span",{children:"添加选项"})]})]})})]})]})},{TextArea:BQ}=_.Input,{Text:zb,Title:sf}=_.Typography,PN=t=>Array.isArray(t)?t.map(e=>e.name).filter(Boolean):[],FQ=({open:t,workflowId:e,workflowName:n,onOpenChange:r,onSuccess:o})=>{const[i]=_.Form.useForm(),s=Ms(),[a,l]=y.useState(!1),[c,u]=y.useState(!1),[d,f]=y.useState([]),[p,m]=y.useState([]),[b,v]=y.useState([]),[w,g]=y.useState([]),C=y.useCallback(async()=>{const P=await yy();return f(P||[]),P},[]),S=y.useCallback(async()=>{const P=await Dy();return m(P||[]),P},[]),k=y.useCallback(async()=>{if(e){u(!0);try{let P;try{P=await by(e)}catch{P=await Gf(e)}const I=PN(P==null?void 0:P.categories),z=PN(P==null?void 0:P.tags);v(I),g(z),i.setFieldsValue({name:(P==null?void 0:P.name)||n||"",description:(P==null?void 0:P.description)||"",category:I,tags:z})}catch{_.message.error("获取模板设置失败"),v([]),g([]),i.setFieldsValue({name:n||"",description:"",category:[],tags:[]})}finally{u(!1)}}},[i,e,n]);y.useEffect(()=>{t&&(k(),C().catch(()=>{_.message.error("获取分类列表失败")}),S().catch(()=>{_.message.error("获取标签列表失败")}))},[C,S,k,t]);const x=async P=>{const I=await Cy({name:P});return await C(),I},D=async(P,I)=>{const z=await ky(P,{name:I});return await C(),z},E=async P=>{const I=await Sy(P);return await C(),I},O=async P=>{const I=await _y({name:P});return await S(),I},A=async(P,I)=>{const z=await Ay(P,{name:I});return await S(),z},T=async P=>{const I=await Oy(P);return await S(),I},B=async()=>{try{const P=await i.validateFields();l(!0);const I={description:P.description,ai_flow:1,id:e};P.name&&(I.name=P.name);try{await vy(e,I)}catch{await oc(e,I)}P.name&&s(Tl(P.name)),_.message.success("模板设置已保存"),r(!1),o==null||o()}catch(P){if(P!=null&&P.errorFields)return;_.message.error("保存失败,请重试")}finally{l(!1)}},M=()=>{r(!1)},F=P=>{v(P),i.setFieldValue("category",P)},N=P=>{g(P),i.setFieldValue("tags",P)};return h.jsx(_.Modal,{cancelText:"取消",confirmLoading:a,okText:"保存设置",onCancel:M,onOk:B,open:t,title:h.jsxs(_.Space,{children:[h.jsx(ie.SettingOutlined,{}),h.jsx("span",{children:"模板设置"})]}),width:600,children:c?h.jsx(_.Skeleton,{active:!0,paragraph:{rows:8}}):h.jsxs("div",{className:"workflow-template-settings-modal",children:[h.jsx("div",{className:"workflow-template-settings-hint",children:h.jsx(zb,{type:"secondary",children:"设置模板的基本信息,包括描述和分类标签,便于更好地组织和管理模板。"})}),h.jsxs(_.Form,{form:i,layout:"vertical",preserve:!1,requiredMark:!1,children:[h.jsxs(_.Card,{styles:{body:{padding:16}},className:"workflow-template-settings-card",size:"small",children:[h.jsxs(_.Space,{className:"workflow-template-settings-section-title",children:[h.jsx(ie.FileTextOutlined,{style:{color:"#1890ff"}}),h.jsx(sf,{level:5,children:"模板名称"})]}),h.jsx(_.Form.Item,{name:"name",rules:[{max:50,message:"最多50个字符"}],children:h.jsx(_.Input,{placeholder:"请输入模板名称",size:"large"})})]}),h.jsxs(_.Card,{styles:{body:{padding:16}},className:"workflow-template-settings-card",size:"small",children:[h.jsxs(_.Space,{className:"workflow-template-settings-section-title",children:[h.jsx(ie.FileTextOutlined,{style:{color:"#1890ff"}}),h.jsx(sf,{level:5,children:"模板描述"})]}),h.jsx(_.Form.Item,{name:"description",rules:[{max:500,message:"最多500个字符"}],children:h.jsx(BQ,{maxLength:500,placeholder:"请输入模板描述,描述该模板的功能和使用场景...",rows:4,showCount:!0})})]}),h.jsxs(_.Card,{styles:{body:{padding:16}},className:"workflow-template-settings-card",size:"small",children:[h.jsxs(_.Space,{className:"workflow-template-settings-section-title",children:[h.jsx(ie.TagsOutlined,{style:{color:"#1890ff"}}),h.jsx(sf,{level:5,children:"模板分类"}),h.jsx(zb,{className:"workflow-template-settings-subtitle",type:"secondary",children:"(可多选)"})]}),h.jsx(_.Form.Item,{name:"category",rules:[{required:!0,message:"请选择模板分类"}],children:h.jsx(IN,{onAddRelation:Ey,onChange:F,onCreate:x,onDelete:E,onRemoveRelation:xy,onUpdate:D,optionItems:d,placeholder:"请选择模板分类",templateId:e,type:"category",value:b})})]}),h.jsxs(_.Card,{styles:{body:{padding:16}},className:"workflow-template-settings-card workflow-template-settings-card-last",size:"small",children:[h.jsxs(_.Space,{className:"workflow-template-settings-section-title",children:[h.jsx(ie.TagsOutlined,{style:{color:"#52c41a"}}),h.jsx(sf,{level:5,children:"模板标签"}),h.jsx(zb,{className:"workflow-template-settings-subtitle",type:"secondary",children:"(可多选)"})]}),h.jsx(_.Form.Item,{name:"tags",children:h.jsx(IN,{onAddRelation:Ty,onChange:N,onCreate:O,onDelete:T,onRemoveRelation:Ny,onUpdate:A,optionItems:p,placeholder:"请选择模板标签",templateId:e,type:"tag",value:w})})]})]})]})})},{Title:MQ}=_.Typography,Hb="[workflow:online-validation]",IQ=({metadata:t})=>{const e=Sl(),n=t.op_status,r=t.id,i=t&&t.effective_version_no!=null&&t.effective_version_no!==""?h.jsx("span",{style:{marginLeft:4},children:h.jsx(Te.FormattedMessage,{id:"app.workflow.version.tag",values:{version:t.effective_version_no}})}):null;return{[er.UNPUBLISHED]:h.jsxs(_.Tag,{bordered:!1,color:"orange",children:[h.jsx(Te.FormattedMessage,{id:"app.common.word.not-published"}),i]}),[er.ONLINE]:h.jsxs(_.Tag,{bordered:!1,color:"green",children:[h.jsx(Te.FormattedMessage,{id:"app.common.word.already-online"}),i]}),[er.OFFLINE]:h.jsxs(_.Tag,{bordered:!1,color:"default",children:[h.jsx(Te.FormattedMessage,{id:"app.common.word.already-offline"}),i]}),[er.ONLINE_ING]:h.jsxs(_.Tag,{bordered:!1,color:"processing",children:[h.jsx(Te.FormattedMessage,{id:"app.common.word.going-online"}),i]}),[er.ON_WARN]:h.jsxs(_.Tag,{bordered:!1,color:"#faad14",onClick:()=>{e(`/link/log?warnId=${r}`)},children:[h.jsx(Te.FormattedMessage,{id:"common.warning"}),i]}),[er.OFF_WARN]:h.jsxs(_.Tag,{bordered:!1,color:"#faad14",onClick:()=>{e(`/link/log?warnId=${r}`)},children:[h.jsx(Te.FormattedMessage,{id:"common.warning"}),i]})}[n??""]??null},PQ=({loading:t=!1,onSave:e,getFlowPayload:n,autoSaveStatus:r=Ln.IDLE,lastSavedTime:o,unSave:i,onOffline:s})=>{var X,re;const a=Lb(),l=Sl(),c=Ms(),u=At(),d=na(),f=Is(Z=>Z.workflow.workflowName),p=Is(Z=>{var de;return(de=Z.workflow.flowMetadata)==null?void 0:de.op_status}),[m,b]=y.useState(!1),[v,w]=y.useState(f),[g,C]=y.useState(!1),[S,k]=y.useState(!1),x=y.useRef(null),{getNodes:D}=ne.useReactFlow(),O=Pt().toolbar,A=O==null?void 0:O.versionManagement,T=!!(A!=null&&A.onShowHistory),B=!!(A!=null&&A.onConfirmPublish),M=O==null?void 0:O.templateSettings,{isMcpServerCanvas:F}=MN(),N=p===er.ONLINE||p===er.ON_WARN,P=y.useRef(null),I=PX(),z=I.id;y.useEffect(()=>{w(f)},[f]),y.useEffect(()=>{m&&x.current&&x.current.focus()},[m]),y.useCallback(()=>{const de=D().filter(ve=>ve.data.status!==me.SUCCESS&&ve.data.status!==me.RUNNABLE);return de.length&&console.warn(`${Hb} node status check failed`,{unhealthyNodes:de.map(ve=>({id:ve.id,name:ve.data.name,type:ve.type,status:ve.data.status}))}),de.length===0},[D]),y.useCallback(()=>{var ve,we;const Z=D(),de=(fe,le,Se)=>(console.warn(`${Hb} required config check failed`,{node:{id:fe.id,name:fe.data.name,type:fe.type,status:fe.data.status},reason:le,details:Se,configSchema:fe.data.config_schema}),!1);for(const fe of Z){const{data:le,type:Se}=fe,{config_schema:ce}=le;if(Se===pe.LOOP){if(!(ce!=null&&ce.asc))return de(fe,"loop config is missing asc");const Fe=Object.keys(ce??{});if(Fe.length===0)return de(fe,"loop config schema is empty");if(Fe.some(Ve=>typeof ce[Ve]>"u"))return de(fe,"loop config contains undefined values",{undefinedKeys:Fe.filter(Ve=>typeof ce[Ve]>"u")})}else if(Se===pe.CONDITION){if(!((ve=ce==null?void 0:ce.or_list)!=null&&ve.length))return de(fe,"condition config is missing or_list");if(!ce.or_list.every(Ve=>Ve.and_list.every(je=>je.query&&je.operator)))return de(fe,"condition config contains incomplete rules")}else if(Se===pe.SWITCH){if(!((we=ce==null?void 0:ce.branches)!=null&&we.length))return de(fe,"switch config is missing branches");if(!ce.branches.every(Ve=>Ve.or_list.every(je=>je.and_list.every(We=>We.query&&We.operator))))return de(fe,"switch config contains incomplete branch rules")}else if(Se!==pe.STICKY){if(!Ui(fe.type)){const Fe=ce==null?void 0:ce.sub_params;if(!Array.isArray(Fe))return de(fe,"config_schema.sub_params is missing or invalid");const Ve=Fe.every(We=>We.required&&!We.is_child?typeof We.value<"u"&&We.value!==null?!0:(console.warn(`${Hb} required param missing`,{key:We.key,name:We.name,displayName:We.display_name,item:We}),!1):!0);if(!Ve)return de(fe,"required parameters are missing",{missingParams:Fe.filter(We=>We.required&&!We.is_child&&(typeof We.value>"u"||We.value===null)).map(We=>({key:We.key,name:We.name,label:We.label}))});const je=ce!=null&&ce.account_schema_id?!!ce.account_id:!0;if(!Ve||!je)return de(fe,"account is required but account_id is missing",{accountSchemaId:ce==null?void 0:ce.account_schema_id,accountId:ce==null?void 0:ce.account_id})}}}return!0},[D]);const H=async()=>{try{await(e==null?void 0:e()),_.message.success(G("workflow.version.save_success"))}catch{_.message.error(G("workflow.version.save_failed"))}},J=Z=>{w(Z.target.value)};St.useUnmount(()=>{c(Mw()),Tl("")});const K=y.useCallback(()=>{const Z=f,de=v.trim(),ve=de||G("app.workflow.canvas.header.workflow_name_unnamed");c(Tl(ve)),oc(z,{name:ve}).then(()=>{}).catch(()=>{c(Tl(Z))}),b(!1)},[c,v,f,z]),ee=()=>{K()},$=()=>{K()},U=()=>{var Z;t||d==="edit"&&((Z=O==null?void 0:O.flowName)==null?void 0:Z.editable)!==!1&&b(!0)},R=()=>{if(!i)switch(r){case Ln.SAVING:return h.jsxs("div",{className:"save-state saving",children:[h.jsx("div",{className:"status-icon"}),"保存中"]});case Ln.SAVED:return h.jsx(_.Tooltip,{title:`已自动保存 (${o})`,children:h.jsx("div",{style:{display:"flex",alignItems:"center"},children:h.jsxs(_.Tag,{bordered:!1,color:"green",children:["已保存"," ",h.jsx("span",{style:{fontSize:10,marginLeft:4,color:"#999"},children:o})]})})});case Ln.ERROR:return h.jsx(_.Tooltip,{title:"自动保存失败",children:h.jsx(_.Badge,{status:"error",text:h.jsx("span",{children:"保存失败"})})});default:return null}},[te,se]=_.Modal.useModal(),be=async()=>{var de;const Z=()=>{var ve,we;if((ve=O==null?void 0:O.nav)!=null&&ve.onBack){O.nav.onBack();return}if((we=O==null?void 0:O.nav)!=null&&we.backTo){ac.push(O.nav.backTo);return}ac.back()};if(!N&&((de=O==null?void 0:O.nav)!=null&&de.confirmOnBackWhenOffline)&&i){await te.confirm({title:G("user.common.operation_title"),content:O.nav.backConfirmMessage||"当前流程未保存,是否确认返回?"})&&Z();return}Z()},j=()=>{var de;const Z=[];return I!=null&&I.id&&Z.push(h.jsxs(_.Space,{size:8,children:[h.jsx(_.Tag,{bordered:!1,color:"blue",icon:h.jsx(ie.EditOutlined,{}),children:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.draft_editing_tag"})}),F&&h.jsx(_.Tag,{bordered:!1,color:"blue",children:"MCP Server"}),h.jsx("span",{style:(de=O==null?void 0:O.flowStatusTag)==null?void 0:de.style,children:h.jsx(IQ,{metadata:I})}),i&&h.jsx(_.Tag,{bordered:!1,color:"orange",icon:h.jsx(ie.WarningOutlined,{}),children:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.unsaved_tag"})})]},"online-area")),Z},Y=y.useMemo(()=>{const Z=[];return T&&Z.push({size:"small",key:"history",icon:h.jsx(ie.HistoryOutlined,{}),label:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.history_versions"}),onClick:()=>{var de;(de=A==null?void 0:A.onShowHistory)==null||de.call(A)}}),Z.push({size:"small",key:"help",icon:h.jsx(ie.QuestionCircleOutlined,{}),label:(O==null?void 0:O.helpDocText)||h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.help_doc_default"}),onClick:()=>{l((O==null?void 0:O.helpDocUrl)||"https://1in15q85qd.apifox.cn/8698531m0",!0)}}),Z.push({size:"small",key:"settings",icon:h.jsx(ie.SettingOutlined,{}),label:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.settings_label"}),onClick:()=>{var de;(de=P.current)==null||de.open()}}),u&&(M!=null&&M.enabled)&&z&&Z.push({size:"small",key:"templateSettings",label:M.buttonText||h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.template_settings_default"}),icon:h.jsx(ie.FileDoneOutlined,{}),onClick:()=>k(!0)}),Z},[T,u,l,M==null?void 0:M.enabled,z,O==null?void 0:O.helpDocText,O==null?void 0:O.helpDocUrl,M.buttonText,A==null?void 0:A.onShowHistory]),W=d==="edit";return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"workflow-canvas-header",children:[h.jsxs("div",{className:"workflow-header-left-area",children:[((X=O.nav)==null?void 0:X.showBack)&&h.jsx(_.Button,{type:"default",size:"small",icon:h.jsx(ie.LeftOutlined,{className:"workflow-back-icon"}),onClick:be,style:{width:29}},"back"),h.jsx("div",{className:"workflow-name-icon",children:`${f??""}`.length>2?f.substring(0,2):f}),m?h.jsx(_.Input,{size:"small",ref:x,value:v,onChange:J,onPressEnter:ee,onBlur:$,maxLength:30,className:"workflow-name-input",placeholder:"请输入工作流名称"},"name-input"):h.jsx("div",{className:"workflow-name",onClick:U,children:f?h.jsxs("div",{className:"workflow-name-container",children:[h.jsx(MQ,{level:4,className:"workflow-name-text",children:f}),W&&h.jsx("div",{className:"workflow-name-desc",children:"点击名称可编辑,最多 30 字"})]}):h.jsx(_.Skeleton.Input,{active:!0,size:"small"})},"name-display"),j()]}),h.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[u&&R(),h.jsxs(_.Space,{style:{marginLeft:16},children:[(re=O==null?void 0:O.buttons)==null?void 0:re.map(Z=>h.jsx(_.Button,{size:"small",style:Z.style,icon:Z.icon,type:Z.type??"default",disabled:t,onClick:()=>{Z.onClick&&a&&Z.onClick(a)},children:Z.label},Z.id)),h.jsx(_.Button,{size:"small",icon:h.jsx(ie.SaveOutlined,{}),loading:r===Ln.SAVING,disabled:t,onClick:H,children:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.save_draft"})}),N&&s&&h.jsx(_.Button,{size:"small",icon:h.jsx(wW,{size:16}),loading:g,disabled:!z||t,onClick:async()=>{C(!0);try{await s(z)&&(_.message.success(G("workflow.version.offline_success")),await(a==null?void 0:a.refreshFlowVersionStatus()))}catch{console.error("call offline error")}finally{C(!1)}},children:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.offline_flow"})}),h.jsx(_.Dropdown,{trigger:["click"],disabled:t,menu:{items:Y},overlayClassName:"small",children:h.jsx(_.Button,{icon:h.jsx(ie.DownOutlined,{}),iconPosition:"end",size:"small",children:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.more"})})}),B&&h.jsx(_.Button,{size:"small",icon:h.jsx(ie.ToTopOutlined,{}),type:"primary",disabled:t,onClick:async()=>{var Z;i&&await H(),(Z=A==null?void 0:A.onConfirmPublish)==null||Z.call(A,n==null?void 0:n())},children:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.publish_enable"})}),h.jsx(TQ,{ref:P})]})]})]}),se,(M==null?void 0:M.enabled)&&z&&h.jsx(FQ,{onOpenChange:k,open:S,workflowId:z,workflowName:f})]})},LQ=({categories:t,activeId:e,loading:n,onChange:r})=>{const o=Te.useIntl(),i=s=>{const a=s.currentTarget,l=a.scrollWidth-a.clientWidth;if(l<=0||Math.abs(s.deltaY)<=Math.abs(s.deltaX))return;const c=Math.min(Math.max(a.scrollLeft+s.deltaY,0),l);c!==a.scrollLeft&&(s.preventDefault(),a.scrollLeft=c)};return n?h.jsx("div",{className:"category-tabs-wrapper loading","aria-busy":"true","aria-live":"polite",children:h.jsx("div",{className:"category-tabs",children:[0,1,2,3,4].map(s=>h.jsx("div",{className:"category-tab-skeleton",style:{animationDelay:`${s*80}ms`}},`category-skeleton-${s}`))})}):h.jsxs("div",{className:"category-tabs-wrapper",children:[h.jsx("div",{className:"category-tabs",onWheel:i,children:t.map(s=>h.jsx("div",{className:ar("category-tab",{active:e===s.id,disabled:s.filterable===!1}),title:s.filterable===!1?o.formatMessage({id:of.categoryUnavailable}):void 0,onClick:()=>{if(s.filterable===!1){_.message.warning(o.formatMessage({id:of.categoryUnavailable}));return}r(s)},children:s.name},s.id))}),h.jsx("div",{className:"category-tabs-mask left"}),h.jsx("div",{className:"category-tabs-mask right"})]})},$Q=({action:t,parentNode:e,onSelect:n})=>{const r=t.status===0||t.disabled===!0,o=()=>{r||(parseInt(`${t.id}`,10)<1?n(e,{...t,type:`${t.action_key}@${t.action_ver}`,saveType:t.action_type}):n(e,t))};return h.jsxs("button",{type:"button",className:`action-item${r?" is-disabled":""}`,onClick:o,disabled:r,"aria-label":`选择动作 ${t.name}`,title:r?"后续版本支持":void 0,children:[h.jsx("div",{className:"item-icon","data-category":e.category.split("-")[0]||"action",children:t.icon?h.jsx("img",{src:t.icon,alt:t.name,style:{width:32,height:32}}):h.jsx("div",{children:t.name.charAt(0).toUpperCase()})}),h.jsxs("div",{className:"item-content",children:[h.jsx("div",{className:"item-title",children:t.name}),t.description&&h.jsx("div",{className:"item-description",children:t.description})]})]})},zQ=({node:t,expanded:e,actions:n,loading:r,hasPartialActions:o,onToggle:i,onActionSelect:s,onLoadAllActions:a})=>{const l=()=>{i(t)},c=u=>{u.stopPropagation(),a==null||a(t)};return h.jsxs("div",{className:ar("node-card",{expanded:e}),children:[h.jsxs("button",{type:"button",className:"node-card-header","aria-expanded":e,"aria-label":`${e?"收起":"展开"} ${t.name}`,onClick:l,children:[h.jsx("div",{className:"node-card-icon",children:t.icon?h.jsx("img",{src:t.icon,alt:t.name}):h.jsx("span",{children:t.name.charAt(0).toUpperCase()})}),h.jsxs("div",{className:"node-card-info",children:[h.jsx("div",{className:"node-card-title",children:t.name}),t.description&&h.jsx("div",{className:"node-card-desc",children:t.description})]}),h.jsx(ie.CaretDownOutlined,{className:ar("node-card-arrow",{expanded:e})})]}),e&&h.jsxs("div",{className:"node-card-body",children:[r?h.jsx("div",{className:"node-card-state",children:"动作加载中..."}):n.length===0?h.jsx("div",{className:"node-card-state",children:"暂无可用动作"}):h.jsx("div",{className:"node-card-actions",children:n.map(u=>h.jsx("div",{className:"node-card-action-wrapper",children:h.jsx($Q,{action:u,parentNode:t,onSelect:s})},u.id))}),o&&!r&&h.jsx("button",{type:"button",className:"node-card-more",onClick:c,children:"查看该节点全部动作"})]})]})},HQ=({currentCategory:t,categoryPath:e,selectedNode:n,onBack:r,onClose:o,title:i,subTitle:s,showBackButton:a})=>{const l=()=>n?n.name:t?t.name:"节点选择器",c=()=>n?"选择动作":e.length>0?e.slice(0,-1).map(p=>p.name).join(" / "):"",u=i||l(),d=s??c(),f=typeof a=="boolean"?a:!!(n||e.length>0);return h.jsxs("div",{className:"panel-header",children:[h.jsxs("div",{className:"header-left",children:[f&&r&&h.jsx("button",{type:"button",className:"back-button","aria-label":"返回上一级",onClick:r,children:h.jsx(ie.ArrowLeftOutlined,{})}),h.jsxs("div",{className:"title",children:[u,d&&h.jsx("div",{className:"category-path",children:d})]})]}),h.jsx("button",{type:"button",className:"close-button","aria-label":"关闭节点选择器",onClick:o,children:h.jsx(ie.CloseOutlined,{})})]})},VQ=[],jQ=new Set(Object.values(pe)),WQ=t=>{if(t)return jQ.has(t)?t:void 0},UQ=({nodeSelectorVisible:t,nodeAddInfo:e})=>{const[n,r]=y.useState(!1),o=El();return{isLoadingActions:n,fetchNodeActions:async(s,a)=>{a!=null&&a.suppressLoading||r(!0);try{const l=t&&e&&e.trigger===!0,c=(e==null?void 0:e.protocol)===$e.MCP_SERVER||(e==null?void 0:e.protocol)===$e.BUILTIN_MCP,u=e==null?void 0:e.protocol,d={linkId:s.id,flowId:o},f=WQ(s.type);f&&(d.actionType=f),c&&(d.page=(a==null?void 0:a.page)??1,d.size=(a==null?void 0:a.size)??iR),u&&(d.protocol=u),l&&(d.trigger=!0);const p=await py(d);return p&&p.items&&Array.isArray(p.items)?p.items.map(b=>{var w;const v=b.action_ver??((w=b.node_schema)==null?void 0:w.version);return b.action_key&&b.node_schema&&A0(b.action_key,v,b.node_schema),{...b,id:b.id,action_key:b.action_key,action_ver:v,nodeKey:b.action_key,nodeVersion:v,name:b.name||"未命名动作",description:b.description||"",connector_name:s.name,nodeId:s.id,nodeIcon:s.icon}}):[]}catch(l){return console.error("获取动作列表失败:",l),[]}finally{a!=null&&a.suppressLoading||r(!1)}}}},qQ=({onFetchCategories:t,restrictToCategory:e,nodeSelectorVisible:n,nodeAddInfo:r,fallbackCategories:o=[],requestContextKey:i,useConnectableDataSource:s=!1})=>{const[a,l]=y.useState(o),[c,u]=y.useState(!1),[d,f]=y.useState(null),p=y.useRef(0);return y.useEffect(()=>{if(!n){p.current+=1,u(!1),f(null);return}return(async()=>{const b=++p.current;u(!0),f(null);try{let v="action";const w=n&&r&&r.trigger,g=r==null?void 0:r.protocol;w?v="trigger":g===$e.MCP_SERVER||g===$e.BUILTIN_MCP?v=lO:g===$e.AI_TOOL?v="mcp":g===$e.AI_LANGUAGE_MODEL?v="model":g===$e.AI_MEMORY&&(v="memory");const C=await t(v);if(b!==p.current)return;const k=e?C.filter(D=>D.id===e):v===lO&&!s?C.filter(D=>D.id===sw):w?C:C.filter(D=>D.id!=="TRIGGER"),x=e?null:{id:"ALL",name:"全部",description:"全部分类",icon:void 0};l(x?[x,...k]:k),f(i)}catch(v){if(b!==p.current)return;console.error("Failed to fetch categories:",v),l(o),f(i)}finally{b===p.current&&u(!1)}})(),()=>{p.current+=1}},[o,r==null?void 0:r.protocol,r==null?void 0:r.trigger,n,t,i,e,s]),{categories:a,categoriesReady:n&&d===i,isLoadingCategories:c,setCategories:l}};async function GQ({node:t,query:e,fetchConnectablePage:n,filterPage:r=o=>o}){var s;if(!e)return[];const o=r(await n(e)),i=o.nodes.find(a=>a.id===t.id);return(i==null?void 0:i.matchedActions)??((s=o.nodes[0])==null?void 0:s.matchedActions)??[]}function RQ(t,e,n=!1){return n||e===$e.BUILTIN_MCP||e===$e.MCP_SERVER?"mcp":t}const LN=/^[1-9]\d*$/,Vb=t=>{if(typeof t=="number")return Number.isSafeInteger(t)&&t>0?t:void 0;const e=t.trim();if(LN.test(e))return e},Hr=t=>{const e=t==null?void 0:t.trim();return e||void 0},$N=t=>{if(t==null)return;if(typeof t=="number")return Number.isSafeInteger(t)&&t>0?t:void 0;const e=t.trim();if(!LN.test(e))return;const n=Number(e);return Number.isSafeInteger(n)?n:void 0},KQ=t=>{const e=t.scene.trim();if(!e)return null;const n=Hr(t.categoryName),r=Hr(t.flowId),o=$N(t.page),i=$N(t.size);return{scene:e,trigger:t.trigger,...n===void 0?{}:{categoryName:n},...Hr(t.linkId)===void 0?{}:{linkId:Hr(t.linkId)},...Hr(t.keyword)===void 0?{}:{keyword:Hr(t.keyword)},...r===void 0?{}:{flowId:r},...o===void 0?{}:{page:o},...i===void 0?{}:{size:i}}},YQ=(t,e)=>{const n=KQ(e);if(!n)return null;switch(t.mode){case"independent":return{...n,mode:"independent"};case"source":{const r=Vb(t.sourceId),o=Hr(t.sourceHandle);return r===void 0||o===void 0?null:{...n,mode:"source",sourceId:r,sourceHandle:o}}case"target":{const r=Vb(t.targetId),o=Hr(t.targetHandle);return r===void 0||o===void 0?null:{...n,mode:"target",targetId:r,targetHandle:o}}case"edge-insert":{const r=Vb(t.sourceId),o=Hr(t.sourceHandle),i=Hr(t.targetHandle);return r===void 0||o===void 0||i===void 0?null:{...n,mode:"source",sourceId:r,sourceHandle:o}}}},zN="[workflow:connectable]",Bi=t=>!!t&&typeof t=="object"&&!Array.isArray(t),jb=(t,e)=>Object.hasOwn(t,e),qt=(t,e)=>{for(const n of e)if(jb(t,n)&&t[n]!==void 0&&t[n]!==null)return t[n]},Bt=(t,e)=>{for(const n of e){const r=t[n];if(typeof r=="string"&&r.trim())return r.trim()}},Fl=t=>{if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(typeof t=="string"&&t.trim()){const e=Number(t);return Number.isFinite(e)?e:void 0}},Wb=(t,e=!1)=>typeof t=="boolean"?t:t===1||t==="1"||t==="true"?!0:t===0||t==="0"||t==="false"?!1:e,XQ=t=>Array.isArray(t)?t.filter(e=>typeof e=="string"):[],HN=t=>{let e=t,n=0;for(;n<4&&Bi(e)&&jb(e,"data")&&!jb(e,"items");)e=e.data,n+=1;return e},JQ=t=>{const e=HN(t);return Array.isArray(e)?e.filter(Bi).map(n=>{const r=Bt(n,["name","categoryName","category_name"]),o=Bt(n,["label","name"])??"";return r||console.warn(`${zN} category has no filter name`,{name:o,availableKeys:Object.keys(n).sort()}),{id:r||o,categoryName:r,name:o,description:Bt(n,["desc","description"])??"",icon:Bt(n,["icon"]),searchAction:Wb(qt(n,["searchAction","search_action"])),filterable:!!r}}):[]},VN=t=>{if(typeof t=="number")return Number.isSafeInteger(t)&&t>0?String(t):void 0;if(typeof t!="string")return;const e=t.trim();if(e){if(/^-?\d+$/.test(e)){const n=e.startsWith("-")?e.slice(1):e;if(e.startsWith("-")||/^0+$/.test(n))return}return e}},QQ=t=>{if(typeof t=="number")return Number.isSafeInteger(t)?String(t):void 0;if(typeof t!="string")return;const e=t.trim();return/^-?\d+$/.test(e)?e:void 0},jN=(t,e)=>{for(const n of e){const r=VN(t[n]);if(r!==void 0)return{value:r,source:n}}},WN=(t,e)=>{console.warn(`${zN} ${t} has no stable identifier`,{name:Bt(e,["name","label","actionName","action_name"]),availableKeys:Object.keys(e).sort()})},ZQ=t=>{const e=Bi(t)?t:{},n=jN(e,["id","linkId","link_id","appPackage","app_package","connectorId","connector_id"]);return n||WN("connector",e),{...e,id:(n==null?void 0:n.value)??"",selectable:!!n,identifierSource:n==null?void 0:n.source,name:Bt(e,["name","displayName","display_name"])??"",description:Bt(e,["description","desc"])??null,build_type:Bt(e,["buildType","build_type"]),app_domain_category:XQ(qt(e,["appDomainCategory","app_domain_category"])),app_action_category:qt(e,["appActionCategory","app_action_category"]),deployment_type:Bt(e,["deploymentType","deployment_type"]),app_package:Bt(e,["appPackage","app_package"]),ver_name:Bt(e,["verName","ver_name"]),ver_number:Fl(qt(e,["verNumber","ver_number"])),ver_type:Bt(e,["verType","ver_type"]),icon:Bt(e,["icon"])}},eZ=t=>{const e=Bi(t)?t:{},n=jN(e,["actionKey","action_key","nodeKey","node_key"]),r=qt(e,["nodeSchema","node_schema"]),o=Bi(r)?r:null,i=o?Bt(o,["key"]):void 0,s=o?Fl(qt(o,["version"])):void 0,a=QQ(qt(e,["id","actionId","action_id"]))??(i?"0":void 0),l=n??(i?{value:i,source:"nodeSchema.key"}:void 0);l||WN("action",e);const c=Bt(e,["actionKey","action_key","nodeKey","node_key"])??i,u=VN(qt(e,["connectorId","connector_id"]));return{...e,id:(l==null?void 0:l.value)??"",backendActionId:a,action_id:a,selectable:!!l,identifierSource:l==null?void 0:l.source,action_key:c,action_ver:Fl(qt(e,["actionVer","action_ver","nodeVersion","node_version","version"]))??s,is_trigger:Fl(qt(e,["isTrigger","is_trigger"]))??(Wb(qt(e,["isTrigger","is_trigger"]))?1:0),name:Bt(e,["name","actionName","action_name"])??"",description:Bt(e,["description","desc"])??null,connector_id:u??null,status:l?1:0,protocol:Bt(e,["protocol"])??"",config_schema:qt(e,["configSchema","config_schema"])??{},sample_output:qt(e,["sampleOutput","sample_output"]),node_struct:Bt(e,["nodeStruct","node_struct"])??"",action_type:Bt(e,["actionType","action_type"])??null}},tZ=t=>{if(typeof t!="string"||!t.trim())return;const e=t.trim().toUpperCase();switch(e){case"CONNECTOR_ONL":return"CONNECTOR_ONLY";case"ACTION_MATCHED":return"ACTION_ONLY";case"BOTH":return"BOTH_MATCHED";default:return e}},af=(t,e,n)=>Fl(qt(t,e))??n,nZ=t=>{const e=HN(t),n=Bi(e)?e:{},r=qt(n,["items","records"]),o=Array.isArray(r)?r.filter(Bi).map(i=>{const s=ZQ(i.connector),a=qt(i,["matchedActions","matched_actions"]),l=Array.isArray(a)?a.map(c=>eZ(c)):[];return{connector:s,matched_actions:l,default_expanded:Wb(qt(i,["defaultExpanded","default_expanded"])),match_type:tZ(qt(i,["matchType","match_type"]))}}):[];return{items:o,total:af(n,["total"],o.length),size:af(n,["size"],o.length),page:af(n,["page","current"],1),pages:af(n,["pages"],0)}},rZ=(t,e)=>{var a;const n=t.action_type||t.node_struct||pe.ACTION,r=t.action_ver??((a=t.node_schema)==null?void 0:a.version);t.action_key&&t.node_schema&&A0(t.action_key,r,t.node_schema);const{node_schema:o,nodeSchema:i,...s}=t;return{...s,id:t.id,type:n,action_type:n,action_key:t.action_key,action_ver:r,nodeKey:t.action_key,nodeVersion:r,action_name:t.name||e.name,name:t.name||e.name,description:t.description||e.description||"",connector_name:e.name,nodeId:e.id,nodeIcon:e.icon}},oZ=(t,e)=>{if(typeof e=="boolean")return e;if(!t)return!1;const n=t.toUpperCase();return n==="ACTION_ONLY"||n==="BOTH_MATCHED"},iZ=(t,e)=>{const{matchedActions:n,defaultExpanded:r,matchType:o}=e||{};return{id:t.id||t.name,selectable:"selectable"in t&&typeof t.selectable=="boolean"?t.selectable:!0,identifierSource:"identifierSource"in t&&typeof t.identifierSource=="string"?t.identifierSource:void 0,type:t.build_type||pe.ACTION,name:t.name,description:t.description||"",category:t.app_domain_category&&t.app_domain_category[0]||"unknown",icon:t.icon||void 0,app_domain_category:t.app_domain_category||[],actionCategories:t.app_action_category||[],deployment_type:t.deployment_type,build_type:t.build_type,matchedActions:n,defaultExpanded:oZ(o,r),matchType:o,connector:t}},sZ=t=>JQ(t).map(e=>({id:e.id,categoryName:e.categoryName,filterable:e.filterable,name:e.name,description:e.description,icon:e.icon,search_action:e.searchAction,nodes:[]})),aZ=t=>{const e=nZ(t);return{nodes:e.items.map(({connector:r,matched_actions:o,default_expanded:i,match_type:s})=>{const a=o.map(l=>rZ(l,r));return iZ(r,{matchedActions:a,defaultExpanded:i,matchType:s})}),total:e.total,page:e.page,size:e.size,pages:e.pages}},lZ=async t=>{const{apiQueryConnectableNodePackageCategories:e}=await Promise.resolve().then(()=>Yy),n=await e(t);return sZ(n)},UN=async t=>{const{apiQueryConnectableNodePackagePlugins:e}=await Promise.resolve().then(()=>Yy),n=await e(t);return aZ(n)},lf=t=>(t==null?void 0:t.trim())||void 0,cZ=t=>{const e=t==null?void 0:t.edge;if(e){const s=lf(e.sourceHandle??e.sourceHandleId),a=lf(e.targetHandle??e.targetHandleId);return e.source===void 0||e.target===void 0||!s||!a?null:String(e.source)===String(e.target)&&s===He.LOOP?{mode:"source",sourceId:e.source,sourceHandle:s}:{mode:"edge-insert",sourceId:e.source,sourceHandle:s,targetId:e.target,targetHandle:a}}const n=lf(t==null?void 0:t.sourceHandle),r=lf(t==null?void 0:t.targetHandle),o=(t==null?void 0:t.sourceNodeId)!==void 0||n!==void 0,i=(t==null?void 0:t.targetNodeId)!==void 0||r!==void 0;return o&&i?null:o?t!=null&&t.sourceNodeId&&n?{mode:"source",sourceId:t.sourceNodeId,sourceHandle:n}:null:i?t!=null&&t.targetNodeId&&r?{mode:"target",targetId:t.targetNodeId,targetHandle:r}:null:{mode:"independent"}};function uZ({nodeSelectorVisible:t,effectiveNodeAddInfo:e,workflowId:n,onSearch:r,onFetchCategories:o,onFetchNodesByCategory:i}){var b;const s=Pt(),{isMcpServerCanvas:a}=MN(),l=RQ(a?"mcp":s.scene??"",e==null?void 0:e.protocol,a),c=y.useMemo(()=>cZ(e),[e]),u=y.useMemo(()=>{var v;return JSON.stringify({visible:t,protocol:e==null?void 0:e.protocol,trigger:!!(e!=null&&e.trigger),edgeId:(v=e==null?void 0:e.edge)==null?void 0:v.id,connectableContext:c,workflowId:n})},[c,(b=e==null?void 0:e.edge)==null?void 0:b.id,e==null?void 0:e.protocol,e==null?void 0:e.trigger,t,n]),d=y.useCallback((v={})=>c?YQ(c,{scene:l,trigger:!!(e!=null&&e.trigger),categoryName:v.categoryName,keyword:v.keyword??v.name,linkId:v.linkId,flowId:v.flow_id??n,page:v.page,size:v.size}):null,[c,e==null?void 0:e.trigger,l,n]),f=y.useCallback(async()=>{const v=d();return v?lZ(v):[]},[d]),p=y.useCallback(async(v={})=>{const w=d(v);return w?await UN(w):{nodes:[],total:0,page:v.page||1,size:v.size||20,pages:0}},[d]),m=y.useCallback(async(v,w)=>{const g=d({linkId:v.id});return GQ({node:v,query:g,fetchConnectablePage:UN})},[d]);return{actionRequestContextKey:u,connectableContext:c,onSearch:r||p,onFetchCategories:o||f,onFetchNodesByCategory:i||p,fetchNodeActions:m}}const dZ=({categories:t,categoriesReady:e,initialCategory:n,nodeSelectorVisible:r,nodeAddInfo:o,onFetchNodesByCategory:i,defaultPageSize:s=20,flowId:a,useConnectableDataSource:l=!1})=>{const[c,u]=y.useState(n||"ALL"),[d,f]=y.useState([]),[p,m]=y.useState(!1),[b,v]=y.useState({page:1,size:s,total:0,hasMore:!0}),w=y.useRef(0),g=r&&o&&o.trigger===!0,C=r&&o&&o.protocol===$e.AI_TOOL,S=r&&o&&o.protocol===$e.BUILTIN_MCP,k=y.useMemo(()=>o==null?void 0:o.protocol,[o==null?void 0:o.protocol]),x=y.useMemo(()=>{const N=o==null?void 0:o.protocol;if(N===$e.AI_TOOL)return"tool";if(N===$e.AI_LANGUAGE_MODEL)return"model";if(N===$e.AI_MEMORY)return"memory"},[o==null?void 0:o.protocol]),E=((o==null?void 0:o.protocol)===$e.MCP_SERVER||(o==null?void 0:o.protocol)===$e.BUILTIN_MCP)&&!l,O=y.useMemo(()=>c==="ALL"?null:t.find(N=>N.id===c)||null,[c,t]),A=y.useCallback((N,P=1)=>{var I;return{app_domain_category:l?void 0:E?sw:N&&N!=="ALL"?N:void 0,categoryName:(I=t.find(z=>z.id===N))==null?void 0:I.categoryName,page:P,size:E?cO:s,trigger:!!g,type:x,protocol:k,flow_id:a}},[s,t,E,g,x,k,a,l]),T=y.useCallback(async(N,P=1,I=!1)=>{if(!r)return;const z=++w.current;m(!0);try{const H=A(N,P),{nodes:J,total:K,size:ee}=await i(H);if(z!==w.current)return;f($=>I?[...$,...J]:J),v({page:P,size:ee,total:K,hasMore:P*ee<K})}catch(H){if(z!==w.current)return;console.error("Failed to fetch category data:",H),I||f([])}finally{z===w.current&&m(!1)}},[A,r,i]),B=y.useCallback(async N=>{u(N),await T(N,1,!1)},[T]),M=y.useCallback(async()=>{p||!b.hasMore||await T(c||"ALL",b.page+1,!0)},[T,p,b,c]),F=y.useCallback(()=>{w.current+=1,m(!1),u(n||"ALL"),f([]),v({page:1,size:s,total:0,hasMore:!0})},[n,s]);return y.useEffect(()=>{var P,I;if(!r||!e){F();return}const N=n&&((P=t.find(z=>z.id===n))==null?void 0:P.id)||((I=t[0])==null?void 0:I.id)||"ALL";u(N),T(N,1,!1)},[t,e,T,n,r,F]),{categoryNodes:d,currentCategory:O,isLoadingNodes:p,isRealTriggerMode:g,isAIToolMode:C,isBuiltinMCPMode:S,navigateToCategory:B,loadMoreNodes:M,resetNavigation:F,pagination:b,activeCategoryId:c,setActiveCategoryId:u}},fZ=({onSearch:t})=>{const[e,n]=y.useState(""),[r,o]=y.useState([]),[i,s]=y.useState(!1),[a,l]=y.useState({total:0,page:1,size:20}),c=y.useRef(0),u=y.useCallback(async(f,p={})=>{if(n(f),!f.trim()){c.current+=1,s(!1),o([]),l({total:0,page:1,size:p.size||20});return}s(!0);const m=++c.current;try{const{nodes:b,total:v,page:w,size:g}=await t({...p,name:f});if(m!==c.current)return;o(b),l({total:v,page:w,size:g})}catch(b){if(m!==c.current)return;console.error("Search failed:",b),o([]),l({total:0,page:1,size:p.size||20})}finally{m===c.current&&s(!1)}},[t]),d=y.useCallback(()=>{c.current+=1,s(!1),n(""),o([]),l({total:0,page:1,size:20})},[]);return{searchText:e,searchResults:r,isSearching:i,searchMeta:a,handleSearch:u,clearSearch:d,setSearchText:n}},qN={async loadFlow(t){const n=await Gf(t),r=n;if(r&&typeof r=="object"&&r.result===!1)throw new wT(typeof r.error=="string"?r.error:void 0,typeof r.error_description=="string"?r.error_description:void 0);const{nodes:o,edges:i,workflowName:s}=bT(n);return{nodes:o,edges:i,name:s||n.name||"",opStatus:n.op_status,executionControl:n.execution_control??null,metadata:n}},async saveFlow({workflowId:t,payload:e}){if(!e)throw new Error("缺少工作流草稿数据");await oc(t,e)},buildFlowPayload:JX,async createNode({workflowId:t,nodeType:e,actionId:n,actionKey:r,actionVer:o,configSchema:i,position:s}){const l=await wy({flow_id:t,node_type:e,action_id:n,...r?{action_key:r,action_ver:o}:{},properties:i||{},position:s});return l?{nodeId:l.id,nodeData:{action_name:l.action_name,connector_name:l.connector_name,status:l.status,icon:l.icon,protocol:l.protocol,...r?{action_key:r,action_ver:o,nodeKey:r,nodeVersion:o}:{},...mI(n,l)}}:(console.error("创建失败",l),null)},stickyNodeKey:YX,HeaderComponent:PQ,PanelComponent:({availableCategories:t=VQ,initialCategory:e,onSearch:n,onFetchCategories:r,onFetchNodesByCategory:o,restrictToCategory:i})=>{const s=y.useRef(null),a=y.useRef(null),[l,c]=y.useState([]),[u,d]=y.useState({}),{nodeSelectorVisible:f,closeNodeSelector:p,handleNodeSelect:m,nodeAddInfo:b}=uc(),v=El(),w=b;UQ({nodeSelectorVisible:f,nodeAddInfo:w});const{actionRequestContextKey:g,onSearch:C,onFetchCategories:S,onFetchNodesByCategory:k,fetchNodeActions:x}=uZ({nodeSelectorVisible:f,effectiveNodeAddInfo:w,workflowId:v,onSearch:n,onFetchCategories:r,onFetchNodesByCategory:o}),{categories:D,categoriesReady:E,isLoadingCategories:O}=qQ({onFetchCategories:S,restrictToCategory:i,nodeSelectorVisible:f,nodeAddInfo:w,fallbackCategories:t,requestContextKey:g}),{searchText:A,searchResults:T,isSearching:B,handleSearch:M,clearSearch:F,setSearchText:N}=fZ({onSearch:C}),P=y.useRef(A),{categoryNodes:I,isLoadingNodes:z,isRealTriggerMode:H,navigateToCategory:J,loadMoreNodes:K,resetNavigation:ee,pagination:$,activeCategoryId:U,currentCategory:R}=dZ({categories:D,categoriesReady:E,initialCategory:e,nodeSelectorVisible:f,nodeAddInfo:w,onFetchNodesByCategory:k,flowId:v}),te=y.useMemo(()=>(w==null?void 0:w.protocol)===$e.MCP_SERVER?"选择 MCP Server 入口":(w==null?void 0:w.protocol)===$e.BUILTIN_MCP?"选择 MCP 工具":(w==null?void 0:w.protocol)===$e.AI_LANGUAGE_MODEL?"选择模型":"选择动作",[w==null?void 0:w.protocol]),se=y.useMemo(()=>(w==null?void 0:w.protocol)===$e.AI_LANGUAGE_MODEL||(w==null?void 0:w.protocol)===$e.AI_MEMORY?"按模型名称搜索":(w==null?void 0:w.protocol)===$e.MCP_SERVER?"按 MCP Server 入口名称搜索":(w==null?void 0:w.protocol)===$e.BUILTIN_MCP?"按 MCP 工具名称搜索":"按节点/动作名称搜索",[w==null?void 0:w.protocol]),be=A,j=y.useMemo(()=>w==null?void 0:w.protocol,[w==null?void 0:w.protocol]),Y=y.useMemo(()=>{const Ce=w==null?void 0:w.protocol;if(Ce===$e.AI_TOOL)return"tool";if(Ce===$e.AI_LANGUAGE_MODEL)return"model";if(Ce===$e.AI_MEMORY)return"memory"},[w==null?void 0:w.protocol]),W=(w==null?void 0:w.protocol)===$e.MCP_SERVER||(w==null?void 0:w.protocol)===$e.BUILTIN_MCP,X=(w==null?void 0:w.protocol)===$e.MCP_SERVER,re=y.useMemo(()=>A?T:I,[I,T,A]),Z=y.useCallback(()=>({app_domain_category:W?sw:U&&U!=="ALL"?U:void 0,trigger:!!H,type:Y,protocol:j,flow_id:v,...W?{page:1,size:cO}:{}}),[U,W,H,Y,j,v]),{run:de,cancel:ve}=St.useDebounceFn(Ce=>{const Oe=Ce.trim();if(!Oe){F(),c([]);return}M(Oe,Z())},{wait:300}),we=y.useCallback(async Ce=>{if(X&&Ce.matchedActions.length){d(Pe=>({...Pe,[Ce.id]:{actions:Ce.matchedActions||[],loading:!1,source:"full"}}));return}d(Pe=>{var qe,zn;return{...Pe,[Ce.id]:{actions:((qe=Pe[Ce.id])==null?void 0:qe.actions)||[],loading:!0,source:(zn=Pe[Ce.id])==null?void 0:zn.source}}});const Oe=await x(Ce,{suppressLoading:!0});d(Pe=>({...Pe,[Ce.id]:{actions:Oe,loading:!1,source:"full"}}))},[x,X]),fe=async Ce=>{if(l.includes(Ce.id)){c(qe=>qe.filter(zn=>zn!==Ce.id));return}c(qe=>[...qe,Ce.id]);const Pe=u[Ce.id];(!Pe||Pe.actions.length===0||Pe.source==="search-partial")&&await we(Ce)},le=async Ce=>{await we(Ce)},Se=(Ce,Oe)=>{const Pe={id:Oe.id??Oe.action_id,action_id:Oe.action_id??Oe.id,action_type:Oe.action_type,type:Oe.action_type,action_key:Oe.action_key,action_ver:Oe.action_ver,action_name:Oe.action_name,name:Ce.name,description:Oe.name||Oe.description,connector_name:(Ce==null?void 0:Ce.name)??Oe.connector_name,connector_id:Oe.connector_id,account_schema_id:Oe.account_schema_id,protocol:Oe.protocol,deployment_type:Ce.deployment_type,icon:Ce.icon??Oe.icon,nodeId:Oe.nodeId,config_schema:Oe.config_schema,category:Ce==null?void 0:Ce.category,nodeKey:Oe.nodeKey,nodeVersion:Oe.nodeVersion,isAction:!0};m(Pe)},ce=async Ce=>{c([]),F(),await J(Ce.id)},Fe=Ce=>{N(Ce),de(Ce)},Ve=Ce=>{if(A||!$.hasMore||z)return;const{scrollTop:Oe,scrollHeight:Pe,clientHeight:qe}=Ce.currentTarget;Pe-Oe-qe<120&&K()};y.useEffect(()=>{if(!f){const Ce=setTimeout(()=>{F(),ee(),c([]),d({})},200);return()=>clearTimeout(Ce)}return()=>ve()},[f,F,ee,ve]),y.useEffect(()=>{if(P.current=A,A){const Ce=T.filter(Oe=>Oe.defaultExpanded).map(Oe=>Oe.id);c(Ce)}},[T,A]),y.useEffect(()=>{A||c([])},[U,A]),y.useEffect(()=>{P.current&&M(P.current,Z())},[U,Z,M]),y.useEffect(()=>{d(Ce=>{const Oe={};return re.forEach(Pe=>{Pe.matchedActions&&Pe.matchedActions.length>0?Oe[Pe.id]={actions:Pe.matchedActions,loading:!1,source:"search-partial"}:Ce[Pe.id]?Oe[Pe.id]=Ce[Pe.id]:Oe[Pe.id]={actions:[],loading:!1}}),Oe})},[re]),St.useClickAway(Ce=>{if(f){const Oe=Ce.target;if(/start-node/.test(Oe.className))return;p()}},s);const je=!E||O||!A&&z,We=()=>B||re.length===0&&je||z?h.jsx("div",{className:"node-card-list","aria-busy":"true","aria-live":"polite",children:[0,1,2,3,4,5,6,7,8,9].map(Ce=>h.jsxs("div",{className:"node-card-skeleton",style:{animationDelay:`${Ce*80}ms`},children:[h.jsx("div",{className:"node-card-skeleton-icon"}),h.jsxs("div",{className:"node-card-skeleton-content",children:[h.jsx("div",{className:"node-card-skeleton-title"}),h.jsx("div",{className:"node-card-skeleton-desc"})]}),h.jsx("div",{className:"node-card-skeleton-arrow"})]},`skeleton-${Ce}`))}):re.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("div",{className:"empty-text",children:"暂无符合条件的节点"})}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"node-card-list",children:re.map(Ce=>{var Oe,Pe,qe;return h.jsx(zQ,{node:Ce,expanded:l.includes(Ce.id),actions:((Oe=u[Ce.id])==null?void 0:Oe.actions)||[],loading:((Pe=u[Ce.id])==null?void 0:Pe.loading)||!1,hasPartialActions:((qe=u[Ce.id])==null?void 0:qe.source)==="search-partial",onToggle:fe,onActionSelect:Se,onLoadAllActions:le},Ce.id)})}),!A&&z&&re.length>0&&h.jsx("div",{className:"list-loading",children:h.jsx("span",{children:"正在加载更多"})}),!A&&!$.hasMore&&!z&&re.length>0&&h.jsx("div",{className:"list-footer",children:"已加载全部"})]});return f?h.jsxs("div",{className:ar("modern-node-selector",{visible:f}),ref:s,children:[h.jsx(HQ,{currentCategory:R,categoryPath:[],selectedNode:null,onClose:p,title:te,showBackButton:!1}),h.jsx("div",{className:"search-container",children:h.jsx(_.Input,{placeholder:se,prefix:h.jsx(bW,{size:16}),allowClear:!0,value:be,onChange:Ce=>Fe(Ce.target.value)})}),h.jsx(LQ,{categories:D,activeId:U||"ALL",loading:O,onChange:ce}),h.jsx("div",{className:"panel-content-box",children:h.jsx("div",{className:"panel-content",ref:a,onClick:Ce=>Ce.stopPropagation(),onScroll:Ve,children:We()})})]}):null},requiresTriggerNode:!0},hZ=t=>{const e=gX(qN.nodeTypes);return h.jsx(SQ,{strategy:qN,nodeTypes:e,...t})},kt={"configSubflow-container":"_configSubflow-container_1ocqs_1","configSubflow-selectSection":"_configSubflow-selectSection_1ocqs_4","configSubflow-selectWrapper":"_configSubflow-selectWrapper_1ocqs_19","configSubflow-select":"_configSubflow-select_1ocqs_4","configSubflow-optionContent":"_configSubflow-optionContent_1ocqs_28","configSubflow-optionName":"_configSubflow-optionName_1ocqs_34","configSubflow-optionLink":"_configSubflow-optionLink_1ocqs_41","configSubflow-paramsSection":"_configSubflow-paramsSection_1ocqs_66","configSubflow-paramsTitle":"_configSubflow-paramsTitle_1ocqs_71","configSubflow-paramsList":"_configSubflow-paramsList_1ocqs_83","configSubflow-paramItem":"_configSubflow-paramItem_1ocqs_88",hasError:"_hasError_1ocqs_101","configSubflow-paramKey":"_configSubflow-paramKey_1ocqs_105","configSubflow-paramKeyLabel":"_configSubflow-paramKeyLabel_1ocqs_110","configSubflow-paramValue":"_configSubflow-paramValue_1ocqs_130","configSubflow-hintMessage":"_configSubflow-hintMessage_1ocqs_156",warning:"_warning_1ocqs_170",info:"_info_1ocqs_175","configSubflow-errorText":"_configSubflow-errorText_1ocqs_185","configSubflow-loading":"_configSubflow-loading_1ocqs_191"},pZ=(t,e={})=>!(t!=null&&t.params)||Object.keys(t.params).length===0?[]:Object.entries(t.params).map(([n,r],o)=>({id:`${n}_${o}`,key:n,value:e[n]!==void 0?e[n]:r,exampleValue:r})),mZ=t=>!!(t!=null&&t.params&&Object.keys(t.params).length>0),GN=y.forwardRef(({value:t,onChange:e,disabled:n=!1,nodeId:r=""},o)=>{const[i,s]=y.useState(t==null?void 0:t.flowId),[a,l]=y.useState([]),[c,u]=y.useState([]),d=At(),f=Sl(),p=n||!d,{data:m=[],loading:b,run:v}=St.useRequest(Ky,{debounceWait:300}),w=m||[],g=y.useMemo(()=>w.find(F=>F.id===i),[w,i]);y.useEffect(()=>{(t==null?void 0:t.flowId)!==i&&s(t==null?void 0:t.flowId)},[t==null?void 0:t.flowId]),y.useEffect(()=>{if(g){const F=pZ(g,t==null?void 0:t.input);l(F)}else l([])},[g,t==null?void 0:t.input]);const C=y.useCallback((F,N)=>{if(!F){e==null||e(void 0);return}e==null||e({flowId:F,input:N})},[e]),S=y.useCallback(F=>{s(F),u([]);const N=w.find(I=>I.id===F),P={};N!=null&&N.params&&Object.entries(N.params).forEach(([I,z])=>{P[I]=z}),C(F,P)},[w,C]),k=y.useCallback((F,N)=>{const P={...(t==null?void 0:t.input)||{}};P[F]=N,C(i,P),u(I=>I.filter(z=>!(z.type==="param"&&z.paramKey===F)))},[i,t==null?void 0:t.input,C]),x=y.useCallback((F,N)=>{N.stopPropagation(),N.preventDefault(),f(`/link/ai-flow/edit?id=${F}`,!0)},[f]),D=y.useCallback(()=>{const F=[];return i||F.push({type:"flow",message:"请选择子流程"}),g!=null&&g.params&&Object.keys(g.params).forEach(N=>{var I;const P=(I=t==null?void 0:t.input)==null?void 0:I[N];(P==null||P==="")&&F.push({type:"param",paramKey:N,message:`参数 "${N}" 不能为空`})}),u(F),F.length===0},[i,g,t==null?void 0:t.input]),E=y.useCallback(()=>{u([])},[]);y.useImperativeHandle(o,()=>({validate:D,clearErrors:E}),[D,E]);const O=()=>{var F;return(F=c.find(N=>N.type==="flow"))==null?void 0:F.message},A=F=>{var N;return(N=c.find(P=>P.type==="param"&&P.paramKey===F))==null?void 0:N.message},T=F=>h.jsxs("div",{className:kt["configSubflow-optionContent"],children:[h.jsx("span",{className:kt["configSubflow-optionName"],children:F.name}),h.jsx(_.Tooltip,{title:"在新标签页中打开子流程",children:h.jsx("button",{type:"button",className:kt["configSubflow-optionLink"],"aria-label":`在新标签页打开子流程:${F.name}`,onClick:N=>x(F.id,N),children:h.jsx(ie.ExportOutlined,{})})})]}),B=()=>i?b?h.jsxs("div",{className:kt["configSubflow-loading"],children:[h.jsx(_.Spin,{size:"small"}),h.jsx("span",{style:{marginLeft:8},children:"加载中..."})]}):mZ(g)?h.jsx("div",{className:kt["configSubflow-paramsList"],children:a.map(F=>{const N=A(F.key);return h.jsxs("div",{className:`${kt["configSubflow-paramItem"]} workflow-config-subflow__param ${N?kt.hasError:""}`,children:[h.jsx("div",{className:kt["configSubflow-paramKey"],children:h.jsx(_.Tooltip,{title:`示例值: ${F.exampleValue}`,children:h.jsx("div",{className:kt["configSubflow-paramKeyLabel"],children:F.key})})}),h.jsxs("div",{className:kt["configSubflow-paramValue"],children:[h.jsx(In,{value:F.value,onChange:P=>k(F.key,P),placeholder:`示例: ${F.exampleValue}`,disabled:p,borrow:!0,nodeId:r,valueType:"ADAPTOR"}),N&&h.jsx("div",{className:kt["configSubflow-errorText"],children:N})]})]},F.id)})}):h.jsxs("div",{className:`${kt["configSubflow-hintMessage"]} ${kt.info}`,children:[h.jsx(ie.InfoCircleOutlined,{}),h.jsx("span",{children:"该流程无需进行参数配置"})]}):h.jsxs("div",{className:`${kt["configSubflow-hintMessage"]} ${kt.warning}`,children:[h.jsx(ie.InfoCircleOutlined,{}),h.jsx("span",{children:"请先选择子流程"})]}),M=O();return h.jsxs("div",{className:kt["configSubflow-container"],children:[h.jsxs("div",{className:kt["configSubflow-selectSection"],children:[h.jsx("div",{className:kt["configSubflow-selectWrapper"],children:h.jsx(_.Select,{className:kt["configSubflow-select"],value:i,onChange:S,placeholder:"请选择子流程",disabled:p,loading:b,showSearch:!0,filterOption:!1,onSearch:v,notFoundContent:b?h.jsx(_.Spin,{size:"small"}):"暂无数据",allowClear:!0,status:M?"error":void 0,options:w.map(F=>({value:F.id,label:T(F)}))})}),M&&h.jsx("div",{className:kt["configSubflow-errorText"],children:M})]}),h.jsxs("div",{className:kt["configSubflow-paramsSection"],children:[h.jsxs("div",{className:kt["configSubflow-paramsTitle"],children:[h.jsx(ie.SettingOutlined,{}),h.jsx("span",{children:"参数配置"})]}),B()]})]})});GN.displayName="ConfigSubflow";function gZ(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return y.useMemo(()=>r=>{e.forEach(o=>o(r))},e)}const cf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ls(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Ub(t){return"nodeType"in t}function _n(t){var e,n;return t?Ls(t)?t:Ub(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function qb(t){const{Document:e}=_n(t);return t instanceof e}function Ml(t){return Ls(t)?!1:t instanceof _n(t).HTMLElement}function RN(t){return t instanceof _n(t).SVGElement}function $s(t){return t?Ls(t)?t.document:Ub(t)?qb(t)?t:Ml(t)||RN(t)?t.ownerDocument:document:document:document}const Vr=cf?y.useLayoutEffect:y.useEffect;function Gb(t){const e=y.useRef(t);return Vr(()=>{e.current=t}),y.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e.current==null?void 0:e.current(...r)},[])}function wZ(){const t=y.useRef(null),e=y.useCallback((r,o)=>{t.current=setInterval(r,o)},[]),n=y.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function Il(t,e){e===void 0&&(e=[t]);const n=y.useRef(t);return Vr(()=>{n.current!==t&&(n.current=t)},e),n}function Pl(t,e){const n=y.useRef();return y.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function uf(t){const e=Gb(t),n=y.useRef(null),r=y.useCallback(o=>{o!==n.current&&(e==null||e(o,n.current)),n.current=o},[]);return[n,r]}function Rb(t){const e=y.useRef();return y.useEffect(()=>{e.current=t},[t]),e.current}let Kb={};function Ll(t,e){return y.useMemo(()=>{if(e)return e;const n=Kb[t]==null?0:Kb[t]+1;return Kb[t]=n,t+"-"+n},[t,e])}function KN(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,s)=>{const a=Object.entries(s);for(const[l,c]of a){const u=i[l];u!=null&&(i[l]=u+t*c)}return i},{...e})}}const zs=KN(1),$l=KN(-1);function bZ(t){return"clientX"in t&&"clientY"in t}function Yb(t){if(!t)return!1;const{KeyboardEvent:e}=_n(t.target);return e&&t instanceof e}function vZ(t){if(!t)return!1;const{TouchEvent:e}=_n(t.target);return e&&t instanceof e}function Xb(t){if(vZ(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:n}=t.touches[0];return{x:e,y:n}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:n}=t.changedTouches[0];return{x:e,y:n}}}return bZ(t)?{x:t.clientX,y:t.clientY}:null}const zl=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[zl.Translate.toString(t),zl.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),YN="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function yZ(t){return t.matches(YN)?t:t.querySelector(YN)}const CZ={display:"none"};function kZ(t){let{id:e,value:n}=t;return y.createElement("div",{id:e,style:CZ},n)}function SZ(t){let{id:e,announcement:n,ariaLiveType:r="assertive"}=t;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return y.createElement("div",{id:e,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function EZ(){const[t,e]=y.useState("");return{announce:y.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const XN=y.createContext(null);function xZ(t){const e=y.useContext(XN);y.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function DZ(){const[t]=y.useState(()=>new Set),e=y.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[y.useCallback(r=>{let{type:o,event:i}=r;t.forEach(s=>{var a;return(a=s[o])==null?void 0:a.call(s,i)})},[t]),e]}const _Z={draggable:`
145
+ `)})]}),N.detail&&h.jsxs("div",{className:"workflow-debug-panel__log-detail-block",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"详细信息"}),h.jsx("pre",{children:JSON.stringify(N.detail,null,2)})]})]})]},N.id))]})]}),h.jsxs("div",{className:"workflow-debug-panel__section",children:[h.jsxs("div",{className:"workflow-debug-panel__summary",children:[h.jsxs("span",{children:["节点数: ",e.length]}),h.jsxs("span",{children:["连线数: ",n.length]})]}),h.jsxs("div",{className:"workflow-debug-panel__detail",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"结构图预览"}),h.jsx("div",{className:"workflow-debug-panel__graph",children:h.jsxs("svg",{className:"workflow-debug-panel__graph-canvas",width:"100%",height:T,viewBox:`0 0 ${A} ${T}`,preserveAspectRatio:"xMinYMin meet",children:[h.jsxs("defs",{children:[h.jsx("marker",{id:"workflow-debug-arrow",markerWidth:"10",markerHeight:"10",refX:"8",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:h.jsx("path",{d:"M0,0 L0,6 L9,3 z",fill:"#8c8c8c"})}),h.jsx("marker",{id:"workflow-debug-arrow-dup",markerWidth:"10",markerHeight:"10",refX:"8",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:h.jsx("path",{d:"M0,0 L0,6 L9,3 z",fill:"#cf1322"})})]}),E.edges.map(N=>{const P=O.get(N.source),I=O.get(N.target);if(!P||!I)return null;const z=k.has(N.id),H=P.x+nf,J=P.y+Bl/2,K=I.x,ee=I.y+Bl/2;return h.jsx("line",{x1:H,y1:J,x2:K,y2:ee,stroke:z?"#cf1322":"#8c8c8c",strokeWidth:z?2.2:1.4,markerEnd:z?"url(#workflow-debug-arrow-dup)":"url(#workflow-debug-arrow)"},N.id)}),E.nodes.map(N=>h.jsxs("g",{transform:`translate(${N.x}, ${N.y})`,children:[h.jsx("rect",{width:nf,height:Bl,rx:6,fill:"#ffffff",stroke:"#91caff",strokeWidth:1.4}),h.jsx("text",{x:nf/2,y:Bl/2+4,textAnchor:"middle",fontSize:"11",fill:"#1f1f1f",children:N.label})]},N.id))]})})]}),h.jsxs("div",{className:"workflow-debug-panel__detail",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"Mermaid 图"}),h.jsx("div",{className:"workflow-debug-panel__mermaid-actions",children:h.jsx(_.Button,{size:"small",onClick:async()=>{await rf(D)?_.message.success("Mermaid 已复制"):_.message.error("复制失败")},children:"复制 Mermaid"})}),h.jsx("pre",{children:D})]}),h.jsxs("div",{className:"workflow-debug-panel__detail",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"结构布局"}),h.jsx("pre",{children:B})]}),h.jsxs("div",{className:"workflow-debug-panel__detail",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"连线关系"}),h.jsxs("div",{className:"workflow-debug-panel__edge-list",children:[x.length===0&&h.jsx("div",{className:"workflow-debug-panel__log-empty",children:"暂无连线"}),x.map(N=>h.jsxs("div",{className:`workflow-debug-panel__edge-line${N.isDuplicate?" workflow-debug-panel__edge-line--duplicate":""}`,children:[h.jsx("span",{children:N.text}),N.isDuplicate&&h.jsx("span",{className:"workflow-debug-panel__edge-flag",children:"重复"})]},N.id))]})]}),S&&S.length>0&&h.jsxs("div",{className:"workflow-debug-panel__detail",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"重复连线"}),h.jsx("div",{className:"workflow-debug-panel__edge-list",children:S.map(N=>h.jsxs("div",{className:"workflow-debug-panel__edge-line--duplicate",children:[h.jsx("span",{children:N.relation}),h.jsx("span",{className:"workflow-debug-panel__edge-flag",children:N.edgeIds.join(", ")})]},N.key))})]}),h.jsxs(_.Space,{direction:"vertical",size:8,style:{width:"100%"},children:[h.jsx(_.Select,{value:u,placeholder:"选择节点查看详情",options:b,onChange:N=>d(N),allowClear:!0,size:"small"}),h.jsx(_.Select,{value:f,placeholder:"选择连线查看详情",options:v,onChange:N=>p(N),allowClear:!0,size:"small"})]}),h.jsxs("div",{className:"workflow-debug-panel__detail",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"节点详情"}),h.jsx("pre",{children:w?JSON.stringify(Ib(w),null,2):"未选择节点"})]}),h.jsxs("div",{className:"workflow-debug-panel__detail",children:[h.jsx("div",{className:"workflow-debug-panel__detail-title",children:"连线详情"}),h.jsx("pre",{children:g?JSON.stringify({...Pb(g),sourceName:C.get(g.source),targetName:C.get(g.target),isDuplicate:k.has(g.id)},null,2):"未选择连线"})]})]})]}):null},BN=y.createContext(null),vQ=({api:t,children:e})=>h.jsx(BN.Provider,{value:t,children:e}),Lb=()=>{const t=y.useContext(BN);if(!t)throw new Error("useCanvasApi must be used within a CanvasApiProvider");return t},FN=y.createContext(null),yQ=({value:t,children:e})=>h.jsx(FN.Provider,{value:t,children:e}),MN=()=>y.useContext(FN)??{hasTriggerNode:!1,isMcpServerCanvas:!1};function CQ({nodes:t,edges:e}){const n=new Map(t.map(a=>[a.id,a])),r=new Map,o=[],i=[];for(const a of t){if(!Nl(a))continue;const l=Mb(a);if(!l){o.push(a.id),i.push({code:"SCHEMA_NOT_READY",reason:"节点端口 Schema 尚未就绪,保存时交由后端继续校验",blocking:!1,nodeId:a.id});continue}r.set(a.id,l);for(const c of l.inputs??[]){if(!c.required)continue;e.some(d=>d.target===a.id&&d.targetHandle===c.name)||i.push({code:"REQUIRED_INPUT_MISSING",reason:`必需输入端口 ${c.displayName||c.name} 尚未连接`,blocking:!0,nodeId:a.id,portName:c.name})}}for(const a of e){const l=n.get(a.source),c=n.get(a.target),u=Nl(l),d=Nl(c);if(!u&&!d||u&&!r.has(a.source)||d&&!r.has(a.target))continue;const f=e.filter(m=>m!==a&&(!a.id||m.id!==a.id)),p=xN({sourceNode:l,targetNode:c,sourceHandle:a.sourceHandle,targetHandle:a.targetHandle,edges:f});p.applicable&&!p.valid&&p.code!=="SCHEMA_NOT_READY"&&p.code!=="NOT_APPLICABLE"&&i.push({code:p.code,reason:p.reason,blocking:!0,edgeId:a.id,sourceNodeId:a.source,targetNodeId:a.target})}const s=i.filter(a=>a.blocking);return{valid:s.length===0,issues:i,blockingIssues:s,missingSchemaNodeIds:o}}const of={categoryUnavailable:"link.flow.connectable.category_unavailable",connectorUnavailable:"link.flow.connectable.connector_unavailable",actionUnavailable:"link.flow.connectable.action_unavailable",loadFailed:"link.flow.connectable.load_failed",noCompatibleNodes:"link.flow.connectable.no_compatible_nodes",noCompatibleInput:"link.flow.connectable.no_compatible_input",noCompatibleOutput:"link.flow.connectable.no_compatible_output",noBidirectionalCompatiblePort:"link.flow.connectable.no_bidirectional_compatible_port",schemaUnavailable:"link.flow.connectable.schema_unavailable",existingEdgeInvalid:"link.flow.connectable.existing_edge_invalid"},kQ=({onOpenNodeSelector:t})=>h.jsx(ne.Panel,{position:"top-center",style:{background:"transparent",boxShadow:"none",border:"0 none",width:"100%",height:"100%",display:"flex",flexFlow:"column",justifyContent:"center"},children:h.jsxs("div",{className:"setup-panel",children:[h.jsx("h4",{children:" 选择一个开始节点 "}),h.jsx("div",{className:"desc",children:"入口类型决定画布定义"}),h.jsx("div",{className:"start-node-placeholder",children:h.jsxs("div",{className:"start-node-select",children:[h.jsxs("button",{type:"button",onClick:()=>t(),className:"nodrag nopan start-node trigger","aria-label":"添加触发节点",children:[h.jsx("div",{className:"start-node-icon",children:"TR"}),h.jsxs("div",{className:"start-node-text",children:[h.jsx("h3",{className:"start-node-text-title",children:"自动化触发器"}),h.jsx("p",{className:"start-node-text-desc",children:"由触发器启动业务流程"})]}),h.jsx("div",{className:"node-footer",children:"选择触发方式 ›"})]}),h.jsxs("button",{type:"button",onClick:()=>{t({protocol:$e.MCP_SERVER})},className:"nodrag nopan start-node mcp","aria-label":"添加 MCP 节点",children:[h.jsx("div",{className:"start-node-icon",children:"MCP"}),h.jsxs("div",{className:"start-node-text",children:[h.jsx("h3",{className:"start-node-text-title",children:"MCP 网关"}),h.jsx("p",{className:"start-node-text-desc",children:"基于画布编排快速构建 MCP SERVER"})]}),h.jsx("div",{className:"node-footer",children:"开始配置 ›"})]})]})})]})}),SQ=t=>{var A,T,B;const{workflowId:e,strategy:n,onOffline:r,nodeTypes:o}=t,i=Pt(),s=Te.useIntl(),a=y.useRef(""),l=uQ(t,n.stickyNodeKey),{setUnSave:c,store:u,updateSaveStatus:d}=l,f=((T=(A=i.nodeSelector)==null?void 0:A.connectable)==null?void 0:T.enabled)===!0,p=At(),{hasTriggerNode:m,isMcpServerCanvas:b}=l,v=y.useCallback(()=>{if(!e||!n.buildFlowPayload)throw new Error("当前画布不支持生成 ACM 草稿数据");const{nodes:M,edges:F}=u.getState(),N=M.map(z=>z.id),P=F.filter(z=>N.includes(z.target)&&z.source&&z.sourceHandle&&z.targetHandle),I=Iw.getState().workflow;return n.buildFlowPayload({nodes:M,edges:P,workflowName:I.workflowName,workflowId:e,executionControl:I.executionControl,metadata:I.flowMetadata})},[u,n,e]),w=y.useCallback(async()=>{var M;if(!e)throw new Error("缺少工作流 ID");try{d(Ln.SAVING);const{nodes:F,edges:N}=u.getState();if(f){const K=CQ({nodes:F,edges:N});if(K.missingSchemaNodeIds.length>0){const ee=[...K.missingSchemaNodeIds].sort().join(",");a.current!==ee&&(a.current=ee,_.message.warning(s.formatMessage({id:of.schemaUnavailable}))),console.warn("[workflow:connectable] save with unavailable schemas",{nodeIds:K.missingSchemaNodeIds})}else a.current="";if(!K.valid){const ee=s.formatMessage({id:of.existingEdgeInvalid});_.message.error(ee),console.warn("[workflow:connectable] block save for invalid graph",{issueCount:K.blockingIssues.length,issues:K.blockingIssues.map($=>({code:$.code,nodeId:$.nodeId,portName:$.portName,edgeId:$.edgeId,sourceNodeId:$.sourceNodeId,targetNodeId:$.targetNodeId}))}),d(Ln.ERROR,new Error(ee));return}}const P=F.map(K=>K.id),I=N.filter(K=>P.includes(K.target)&&K.source&&K.sourceHandle&&K.targetHandle),z=Iw.getState().workflow,H=n.buildFlowPayload?v():void 0,J={...H,nodes:H.nodes.map(K=>K.saveType?{...K,node_type:K.saveType}:K)};return await n.saveFlow({nodes:J.nodes,edges:I,workflowName:z.workflowName,workflowId:e,executionControl:z.executionControl,metadata:z.flowMetadata,payload:J}),c(!1),d(Ln.SAVED),J&&await((M=t.onSave)==null?void 0:M.call(t,J)),J}catch(F){throw d(Ln.ERROR,F),F}},[f,v,s,t.onSave,c,u,n,d,e]);l.saveFlowRef.current=w;const g=hJ(w),{loadError:C,retry:S}=cJ({workflowId:e,strategy:n,setNodes:l.setNodes,setEdges:l.setEdges,fitView:l.reactFlow.fitView,setLoading:l.setLoading,dispatch:l.dispatch,setFlowOpStatusAction:l.setFlowOpStatusAction,refreshWorkFlowNum:l.refreshWorkFlowNum,onLoad:t.onLoad});dJ({workflowId:e,strategy:n,store:l.store,addNodes:l.addNodes,addEdges:l.addEdges,removeEdges:l.removeEdges,updateEdge:l.reactFlow.updateEdge,setNodeAddCallback:l.setNodeAddCallback,handleEdgeAddNode:l.handleEdgeAddNode,setNodeConfigVisible:l.setNodeConfigVisible,setNodeFitHumanView:l.setNodeFitHumanView,validateConnectionAgainstSnapshot:l.validateConnectionAgainstSnapshot,saveFlow:g});const k=n.HeaderComponent,x=n.PanelComponent,D=n.ConfigModalComponent,E=p&&!m&&!b,O=y.useMemo(()=>({hasTriggerNode:m,isMcpServerCanvas:b}),[m,b]);return h.jsx(vQ,{api:l.canvasApi,children:h.jsxs(yQ,{value:O,children:[h.jsxs("div",{className:l.isPreviewMode?"workflow-canvas-container workflow-canvas-container-preview":"workflow-canvas-container",style:{height:i.canvas.height?`${i.canvas.height}`:void 0},children:[l.showCanvasHeader&&h.jsx(k,{loading:l.loading||!!C,onSave:w,getFlowPayload:v,autoSaveStatus:l.autoSaveStatus,unSave:l.unSave,lastSavedTime:l.lastSavedTime,onOffline:r}),h.jsxs("div",{className:"workflow-canvas",children:[h.jsx(ZX,{loading:l.loading,error:C,onRetry:S}),h.jsx(eJ,{}),h.jsxs(ne.ReactFlow,{nodes:l.nodes,edges:l.edges,onNodesChange:l.onNodesChange,onEdgesChange:l.handleEdgesChange,onConnect:l.handleConnect,multiSelectionKeyCode:null,nodeTypes:o,edgeTypes:UX,connectionLineType:ne.ConnectionLineType.Bezier,connectionMode:ne.ConnectionMode.Loose,onNodeMouseEnter:l.onNodeMouseEnter,onNodeMouseLeave:l.onNodeMouseLeave,onEdgeMouseEnter:l.onEdgeMouseEnter,onEdgeMouseLeave:l.onEdgeMouseLeave,onNodeContextMenu:l.onNodeContextMenu,onPaneContextMenu:l.onPaneContextMenu,defaultEdgeOptions:KX,style:qX,defaultViewport:l.isPreviewMode?RX:GX,minZoom:.1,maxZoom:2,fitView:!1,snapToGrid:!0,snapGrid:[20,20],deleteKeyCode:null,nodesDraggable:!l.isInteractionDisabled,nodesConnectable:!l.isInteractionDisabled,elementsSelectable:!l.isInteractionDisabled,className:"react-flow-canvas-container",...l.restNativeProps,isValidConnection:l.isValidConnection,children:[l.showBackground&&h.jsx(ne.Background,{gap:(B=i.canvas.grid)==null?void 0:B.size,color:"#eee",variant:ne.BackgroundVariant.Lines}),l.showFastOperationButtons&&!E&&h.jsx(QX,{onOpenNodeSelector:l.handleOpenNodeSelector,onAddNoteNode:l.handleAddNoteNode,onTidyCanvas:l.handleTidy}),!l.loading&&!C&&E&&h.jsx(kQ,{onOpenNodeSelector:l.handleOpenNodeSelector}),l.showControls&&h.jsx(ne.Controls,{onInteractiveChange:M=>{l.setLocked(!M)}}),!l.loading&&l.showMiniMap&&h.jsx(fQ,{}),h.jsx(x,{}),h.jsx(oJ,{horizontal:l.helperLineHorizontal,vertical:l.helperLineVertical}),h.jsx(bQ,{visible:l.debugVisible,nodes:l.nodes,edges:l.edges,onClose:()=>l.setDebugVisible(!1)})]})]})]}),D&&h.jsx(D,{})]})})};var yr=(t=>(t.SECOND="second",t.MINUTE="minute",t.HOUR="hour",t))(yr||{});function EQ(t){return{[yr.SECOND]:"SECONDS",[yr.MINUTE]:"MINUTES",[yr.HOUR]:"HOURS"}[t]}function xQ(t){return{SECONDS:yr.SECOND,MINUTES:yr.MINUTE,HOURS:yr.HOUR}[t]}function DQ(){return{enableControl:!1,timeoutValue:30,timeoutUnit:yr.MINUTE,maxNodeExecutions:1e4,webhookUrl:""}}function _Q(t){return{enabled:t.enableControl,timeout_value:t.timeoutValue,timeout_unit:EQ(t.timeoutUnit),max_node_executions:t.maxNodeExecutions,webhook_url:t.webhookUrl||void 0}}function AQ(t){return{enableControl:t.enabled,timeoutValue:t.timeout_value,timeoutUnit:xQ(t.timeout_unit),maxNodeExecutions:t.max_node_executions,webhookUrl:t.webhook_url||""}}function OQ(t){if(!t)return!0;try{return new URL(t),!0}catch{return!1}}const{Text:$b}=_.Typography,TQ=y.forwardRef((t,e)=>{const[n,r]=y.useState(!1),[o,i]=y.useState(!1),[s]=_.Form.useForm(),a=_.Form.useWatch("enableControl",s),l=Ms(),c=Is(b=>b.workflow.executionControl),u=Lb(),d=()=>{r(!0),s.setFieldsValue(c?AQ(c):DQ())},f=()=>{r(!1)};y.useImperativeHandle(e,()=>({open:d,close:f}),[d,f]);const p=async()=>{try{const b=await s.validateFields();i(!0),l(mT(_Q(b))),await u.saveFlow(),_.message.success(G("common.save_success")),r(!1)}catch(b){_.message.error(G("common.save_failed")),console.error(b)}finally{i(!1)}},m=(b,v)=>!v||OQ(v)?Promise.resolve():Promise.reject(new Error(G("app.workflow.global_config.url_invalid")));return h.jsx(_.Drawer,{title:G("app.workflow.canvas.header.settings_label"),placement:"right",width:480,open:n,onClose:f,footer:h.jsxs(_.Space,{style:{float:"right"},children:[h.jsx(_.Button,{onClick:f,children:G("app.common.word.cancel")}),h.jsx(_.Button,{type:"primary",onClick:p,loading:o,children:G("app.common.word.save")})]}),children:h.jsxs(_.Form,{form:s,layout:"vertical",autoComplete:"off",children:[h.jsx(_.Form.Item,{label:G("app.workflow.global_config.enable_control"),name:"enableControl",valuePropName:"checked",children:h.jsx(_.Switch,{})}),a&&h.jsxs(h.Fragment,{children:[h.jsxs(_.Form.Item,{label:G("app.workflow.global_config.timeout_label"),required:!0,style:{marginBottom:8},children:[h.jsxs(_.Space.Compact,{style:{width:"100%"},children:[h.jsx(_.Form.Item,{name:"timeoutValue",noStyle:!0,rules:[{required:!0,message:G("app.workflow.global_config.timeout_required")},{type:"number",min:1,message:G("app.workflow.global_config.timeout_min")}],children:h.jsx(_.InputNumber,{style:{width:"70%"},placeholder:G("app.workflow.global_config.please_input"),min:1})}),h.jsx(_.Form.Item,{name:"timeoutUnit",noStyle:!0,rules:[{required:!0}],children:h.jsxs(_.Select,{style:{width:"30%"},children:[h.jsx(_.Select.Option,{value:yr.SECOND,children:G("app.workflow.global_config.unit_second")}),h.jsx(_.Select.Option,{value:yr.MINUTE,children:G("common.minute")}),h.jsx(_.Select.Option,{value:yr.HOUR,children:G("common.hour")})]})})]}),h.jsx($b,{type:"secondary",style:{fontSize:12},children:G("app.workflow.global_config.timeout_help")})]}),h.jsx(_.Form.Item,{label:G("app.workflow.global_config.max_node_label"),name:"maxNodeExecutions",rules:[{required:!0,message:G("app.workflow.global_config.max_node_required")},{type:"number",min:1,message:G("app.workflow.global_config.max_node_min")}],children:h.jsx(_.InputNumber,{style:{width:"100%"},placeholder:G("app.workflow.global_config.please_input"),min:1,precision:0})}),h.jsx($b,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-16,marginBottom:16},children:G("app.workflow.global_config.max_node_help")}),h.jsx(_.Form.Item,{label:G("app.workflow.global_config.webhook_label"),name:"webhookUrl",rules:[{validator:m}],children:h.jsx(_.Input,{placeholder:G("app.workflow.global_config.webhook_placeholder")})}),h.jsx($b,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-16},children:G("app.workflow.global_config.webhook_help")})]})]})})}),NQ=t=>t==="category"?"分类":"标签",IN=({value:t=[],onChange:e,placeholder:n,templateId:r,optionItems:o,type:i,onCreate:s,onUpdate:a,onDelete:l,onAddRelation:c,onRemoveRelation:u})=>{const[d,f]=y.useState(!1),[p,m]=y.useState(null),[b,v]=y.useState(""),[w,g]=y.useState(!1),[C,S]=y.useState(""),[k,x]=y.useState(!1),D=NQ(i),E=I=>{var z;return(z=o.find(H=>H.name===I))==null?void 0:z.id},O=async I=>{const z=E(I);if(!z)return;const H=t.includes(I);try{x(!0),H?(await u(r,z),e==null||e(t.filter(J=>J!==I))):(await c(r,z),e==null||e([...t,I]))}finally{x(!1)}},A=(I,z)=>{z.stopPropagation();const H=E(I);H&&u(r,H).then(()=>{e==null||e(t.filter(J=>J!==I))}).catch(()=>{_.message.error("移除失败")})},T=(I,z)=>{z.stopPropagation(),m(I),v(I)},B=async()=>{const I=b.trim();if(!I||!p)return;if(I.length>8){_.message.error("名称长度不能超过8个字符");return}const z=E(p);if(z)try{x(!0),await a(z,I),e==null||e(t.map(H=>H===p?I:H)),_.message.success("修改成功")}catch{_.message.error("修改失败")}finally{x(!1),m(null),v("")}},M=()=>{m(null),v("")},F=async I=>{const z=E(I);if(z)try{x(!0),await l(z),e==null||e(t.filter(H=>H!==I)),_.message.success("删除成功")}catch{_.message.error("删除失败")}finally{x(!1)}},N=async()=>{const I=C.trim();if(I){if(I.length>8){_.message.error("名称长度不能超过8个字符");return}try{x(!0),await s(I),g(!1),S(""),_.message.success("创建成功")}catch{_.message.error("创建失败")}finally{x(!1)}}},P=()=>{g(!1),S("")};return h.jsxs("div",{className:"template-editable-select",children:[h.jsxs("div",{className:"template-editable-select-input",role:"combobox",tabIndex:0,"aria-expanded":d,"aria-haspopup":"listbox","aria-label":`选择或管理${D}`,onClick:()=>f(!d),onKeyDown:I=>{(I.key==="Enter"||I.key===" ")&&(I.preventDefault(),f(z=>!z)),I.key==="Escape"&&f(!1)},children:[h.jsx("div",{className:"template-editable-select-tags",children:t.length===0?h.jsx("span",{className:"template-editable-select-placeholder",children:n}):t.map(I=>h.jsx(_.Tag,{closable:!0,onClose:z=>A(I,z),style:{marginRight:4,marginBottom:4},children:I},I))}),h.jsx("div",{className:`template-editable-select-arrow ${d?"template-editable-select-arrow-open":""}`,children:h.jsx(ie.DownOutlined,{})})]}),d&&h.jsxs(h.Fragment,{children:[h.jsx("button",{type:"button","aria-label":`关闭${D}选择器`,className:"template-editable-select-dropdown-overlay",onClick:()=>f(!1)}),h.jsx("div",{className:"template-editable-select-dropdown-container",role:"listbox","aria-label":`${D}选项`,onClick:I=>I.stopPropagation(),children:h.jsxs("div",{className:"template-editable-select-dropdown",children:[o.map(I=>h.jsx("div",{className:"template-editable-select-dropdown-item",children:p===I.name?h.jsx("div",{className:"template-editable-select-edit-container",children:h.jsx(_.Input,{autoFocus:!0,className:"template-editable-select-edit-input",disabled:k,maxLength:8,onChange:z=>v(z.target.value),onPressEnter:B,placeholder:`输入新${D}名称(8个字符以内)`,size:"small",suffix:h.jsxs("div",{className:"template-editable-select-edit-actions",children:[h.jsx(_.Button,{className:"template-editable-select-confirm-btn",icon:h.jsx(ie.CheckOutlined,{}),loading:k,onClick:B,size:"small",type:"text"}),h.jsx(_.Button,{className:"template-editable-select-cancel-btn",disabled:k,icon:h.jsx(ie.CloseOutlined,{}),onClick:M,size:"small",type:"text"})]}),value:b})}):h.jsxs(h.Fragment,{children:[h.jsxs("button",{type:"button",role:"option","aria-selected":t.includes(I.name),className:"template-editable-select-item-content",onClick:()=>O(I.name),children:[h.jsx("div",{className:"template-editable-select-check",children:t.includes(I.name)&&h.jsx(ie.CheckOutlined,{style:{color:"#1890ff"}})}),h.jsx("span",{className:"template-editable-select-name",children:I.name})]}),h.jsxs("div",{className:"template-editable-select-actions",children:[h.jsx(_.Button,{className:"template-editable-select-action-btn",disabled:k,icon:h.jsx(ie.EditOutlined,{}),onClick:z=>T(I.name,z),size:"small",type:"text"}),h.jsx(_.Popconfirm,{cancelText:"取消",okText:"确定",onConfirm:()=>F(I.name),title:`确定删除${D}"${I.name}"吗?`,children:h.jsx(_.Button,{className:"template-editable-select-action-btn",danger:!0,disabled:k,icon:h.jsx(ie.DeleteOutlined,{}),onClick:z=>z.stopPropagation(),size:"small",type:"text"})})]})]})},I.id)),w?h.jsx("div",{className:"template-editable-select-dropdown-item",children:h.jsx("div",{className:"template-editable-select-edit-container",children:h.jsx(_.Input,{autoFocus:!0,className:"template-editable-select-edit-input",disabled:k,maxLength:8,onChange:I=>S(I.target.value),onPressEnter:N,placeholder:`输入新${D}名称(8个字符以内)`,size:"small",suffix:h.jsxs("div",{className:"template-editable-select-edit-actions",children:[h.jsx(_.Button,{className:"template-editable-select-confirm-btn",icon:h.jsx(ie.CheckOutlined,{}),loading:k,onClick:N,size:"small",type:"text"}),h.jsx(_.Button,{className:"template-editable-select-cancel-btn",disabled:k,icon:h.jsx(ie.CloseOutlined,{}),onClick:P,size:"small",type:"text"})]}),value:C})})}):h.jsxs("button",{type:"button",className:"template-editable-select-add-item",onClick:()=>g(!0),children:[h.jsx(ie.PlusOutlined,{style:{color:"#1890ff",marginRight:4}}),h.jsx("span",{children:"添加选项"})]})]})})]})]})},{TextArea:BQ}=_.Input,{Text:zb,Title:sf}=_.Typography,PN=t=>Array.isArray(t)?t.map(e=>e.name).filter(Boolean):[],FQ=({open:t,workflowId:e,workflowName:n,onOpenChange:r,onSuccess:o})=>{const[i]=_.Form.useForm(),s=Ms(),[a,l]=y.useState(!1),[c,u]=y.useState(!1),[d,f]=y.useState([]),[p,m]=y.useState([]),[b,v]=y.useState([]),[w,g]=y.useState([]),C=y.useCallback(async()=>{const P=await yy();return f(P||[]),P},[]),S=y.useCallback(async()=>{const P=await Dy();return m(P||[]),P},[]),k=y.useCallback(async()=>{if(e){u(!0);try{let P;try{P=await by(e)}catch{P=await Gf(e)}const I=PN(P==null?void 0:P.categories),z=PN(P==null?void 0:P.tags);v(I),g(z),i.setFieldsValue({name:(P==null?void 0:P.name)||n||"",description:(P==null?void 0:P.description)||"",category:I,tags:z})}catch{_.message.error("获取模板设置失败"),v([]),g([]),i.setFieldsValue({name:n||"",description:"",category:[],tags:[]})}finally{u(!1)}}},[i,e,n]);y.useEffect(()=>{t&&(k(),C().catch(()=>{_.message.error("获取分类列表失败")}),S().catch(()=>{_.message.error("获取标签列表失败")}))},[C,S,k,t]);const x=async P=>{const I=await Cy({name:P});return await C(),I},D=async(P,I)=>{const z=await ky(P,{name:I});return await C(),z},E=async P=>{const I=await Sy(P);return await C(),I},O=async P=>{const I=await _y({name:P});return await S(),I},A=async(P,I)=>{const z=await Ay(P,{name:I});return await S(),z},T=async P=>{const I=await Oy(P);return await S(),I},B=async()=>{try{const P=await i.validateFields();l(!0);const I={description:P.description,ai_flow:1,id:e};P.name&&(I.name=P.name);try{await vy(e,I)}catch{await oc(e,I)}P.name&&s(Tl(P.name)),_.message.success("模板设置已保存"),r(!1),o==null||o()}catch(P){if(P!=null&&P.errorFields)return;_.message.error("保存失败,请重试")}finally{l(!1)}},M=()=>{r(!1)},F=P=>{v(P),i.setFieldValue("category",P)},N=P=>{g(P),i.setFieldValue("tags",P)};return h.jsx(_.Modal,{cancelText:"取消",confirmLoading:a,okText:"保存设置",onCancel:M,onOk:B,open:t,title:h.jsxs(_.Space,{children:[h.jsx(ie.SettingOutlined,{}),h.jsx("span",{children:"模板设置"})]}),width:600,children:c?h.jsx(_.Skeleton,{active:!0,paragraph:{rows:8}}):h.jsxs("div",{className:"workflow-template-settings-modal",children:[h.jsx("div",{className:"workflow-template-settings-hint",children:h.jsx(zb,{type:"secondary",children:"设置模板的基本信息,包括描述和分类标签,便于更好地组织和管理模板。"})}),h.jsxs(_.Form,{form:i,layout:"vertical",preserve:!1,requiredMark:!1,children:[h.jsxs(_.Card,{styles:{body:{padding:16}},className:"workflow-template-settings-card",size:"small",children:[h.jsxs(_.Space,{className:"workflow-template-settings-section-title",children:[h.jsx(ie.FileTextOutlined,{style:{color:"#1890ff"}}),h.jsx(sf,{level:5,children:"模板名称"})]}),h.jsx(_.Form.Item,{name:"name",rules:[{max:50,message:"最多50个字符"}],children:h.jsx(_.Input,{placeholder:"请输入模板名称",size:"large"})})]}),h.jsxs(_.Card,{styles:{body:{padding:16}},className:"workflow-template-settings-card",size:"small",children:[h.jsxs(_.Space,{className:"workflow-template-settings-section-title",children:[h.jsx(ie.FileTextOutlined,{style:{color:"#1890ff"}}),h.jsx(sf,{level:5,children:"模板描述"})]}),h.jsx(_.Form.Item,{name:"description",rules:[{max:500,message:"最多500个字符"}],children:h.jsx(BQ,{maxLength:500,placeholder:"请输入模板描述,描述该模板的功能和使用场景...",rows:4,showCount:!0})})]}),h.jsxs(_.Card,{styles:{body:{padding:16}},className:"workflow-template-settings-card",size:"small",children:[h.jsxs(_.Space,{className:"workflow-template-settings-section-title",children:[h.jsx(ie.TagsOutlined,{style:{color:"#1890ff"}}),h.jsx(sf,{level:5,children:"模板分类"}),h.jsx(zb,{className:"workflow-template-settings-subtitle",type:"secondary",children:"(可多选)"})]}),h.jsx(_.Form.Item,{name:"category",rules:[{required:!0,message:"请选择模板分类"}],children:h.jsx(IN,{onAddRelation:Ey,onChange:F,onCreate:x,onDelete:E,onRemoveRelation:xy,onUpdate:D,optionItems:d,placeholder:"请选择模板分类",templateId:e,type:"category",value:b})})]}),h.jsxs(_.Card,{styles:{body:{padding:16}},className:"workflow-template-settings-card workflow-template-settings-card-last",size:"small",children:[h.jsxs(_.Space,{className:"workflow-template-settings-section-title",children:[h.jsx(ie.TagsOutlined,{style:{color:"#52c41a"}}),h.jsx(sf,{level:5,children:"模板标签"}),h.jsx(zb,{className:"workflow-template-settings-subtitle",type:"secondary",children:"(可多选)"})]}),h.jsx(_.Form.Item,{name:"tags",children:h.jsx(IN,{onAddRelation:Ty,onChange:N,onCreate:O,onDelete:T,onRemoveRelation:Ny,onUpdate:A,optionItems:p,placeholder:"请选择模板标签",templateId:e,type:"tag",value:w})})]})]})]})})},{Title:MQ}=_.Typography,Hb="[workflow:online-validation]",IQ=({metadata:t})=>{const e=Sl(),n=t.op_status,r=t.id,i=t&&t.effective_version_no!=null&&t.effective_version_no!==""?h.jsx("span",{style:{marginLeft:4},children:h.jsx(Te.FormattedMessage,{id:"app.workflow.version.tag",values:{version:t.effective_version_no}})}):null;return{[er.UNPUBLISHED]:h.jsxs(_.Tag,{bordered:!1,color:"orange",children:[h.jsx(Te.FormattedMessage,{id:"app.common.word.not-published"}),i]}),[er.ONLINE]:h.jsxs(_.Tag,{bordered:!1,color:"green",children:[h.jsx(Te.FormattedMessage,{id:"app.common.word.already-online"}),i]}),[er.OFFLINE]:h.jsxs(_.Tag,{bordered:!1,color:"default",children:[h.jsx(Te.FormattedMessage,{id:"app.common.word.already-offline"}),i]}),[er.ONLINE_ING]:h.jsxs(_.Tag,{bordered:!1,color:"processing",children:[h.jsx(Te.FormattedMessage,{id:"app.common.word.going-online"}),i]}),[er.ON_WARN]:h.jsxs(_.Tag,{bordered:!1,color:"#faad14",onClick:()=>{e(`/link/log?warnId=${r}`)},children:[h.jsx(Te.FormattedMessage,{id:"common.warning"}),i]}),[er.OFF_WARN]:h.jsxs(_.Tag,{bordered:!1,color:"#faad14",onClick:()=>{e(`/link/log?warnId=${r}`)},children:[h.jsx(Te.FormattedMessage,{id:"common.warning"}),i]})}[n??""]??null},PQ=({loading:t=!1,onSave:e,getFlowPayload:n,autoSaveStatus:r=Ln.IDLE,lastSavedTime:o,unSave:i,onOffline:s})=>{var X,re;const a=Lb(),l=Sl(),c=Ms(),u=At(),d=na(),f=Is(Z=>Z.workflow.workflowName),p=Is(Z=>{var de;return(de=Z.workflow.flowMetadata)==null?void 0:de.op_status}),[m,b]=y.useState(!1),[v,w]=y.useState(f),[g,C]=y.useState(!1),[S,k]=y.useState(!1),x=y.useRef(null),{getNodes:D}=ne.useReactFlow(),O=Pt().toolbar,A=O==null?void 0:O.versionManagement,T=!!(A!=null&&A.onShowHistory),B=!!(A!=null&&A.onConfirmPublish),M=O==null?void 0:O.templateSettings,{isMcpServerCanvas:F}=MN(),N=p===er.ONLINE||p===er.ON_WARN,P=y.useRef(null),I=PX(),z=I.id;y.useEffect(()=>{w(f)},[f]),y.useEffect(()=>{m&&x.current&&x.current.focus()},[m]),y.useCallback(()=>{const de=D().filter(ve=>ve.data.status!==me.SUCCESS&&ve.data.status!==me.RUNNABLE);return de.length&&console.warn(`${Hb} node status check failed`,{unhealthyNodes:de.map(ve=>({id:ve.id,name:ve.data.name,type:ve.type,status:ve.data.status}))}),de.length===0},[D]),y.useCallback(()=>{var ve,we;const Z=D(),de=(fe,le,Se)=>(console.warn(`${Hb} required config check failed`,{node:{id:fe.id,name:fe.data.name,type:fe.type,status:fe.data.status},reason:le,details:Se,configSchema:fe.data.config_schema}),!1);for(const fe of Z){const{data:le,type:Se}=fe,{config_schema:ce}=le;if(Se===pe.LOOP){if(!(ce!=null&&ce.asc))return de(fe,"loop config is missing asc");const Fe=Object.keys(ce??{});if(Fe.length===0)return de(fe,"loop config schema is empty");if(Fe.some(Ve=>typeof ce[Ve]>"u"))return de(fe,"loop config contains undefined values",{undefinedKeys:Fe.filter(Ve=>typeof ce[Ve]>"u")})}else if(Se===pe.CONDITION){if(!((ve=ce==null?void 0:ce.or_list)!=null&&ve.length))return de(fe,"condition config is missing or_list");if(!ce.or_list.every(Ve=>Ve.and_list.every(je=>je.query&&je.operator)))return de(fe,"condition config contains incomplete rules")}else if(Se===pe.SWITCH){if(!((we=ce==null?void 0:ce.branches)!=null&&we.length))return de(fe,"switch config is missing branches");if(!ce.branches.every(Ve=>Ve.or_list.every(je=>je.and_list.every(We=>We.query&&We.operator))))return de(fe,"switch config contains incomplete branch rules")}else if(Se!==pe.STICKY){if(!Ui(fe.type)){const Fe=ce==null?void 0:ce.sub_params;if(!Array.isArray(Fe))return de(fe,"config_schema.sub_params is missing or invalid");const Ve=Fe.every(We=>We.required&&!We.is_child?typeof We.value<"u"&&We.value!==null?!0:(console.warn(`${Hb} required param missing`,{key:We.key,name:We.name,displayName:We.display_name,item:We}),!1):!0);if(!Ve)return de(fe,"required parameters are missing",{missingParams:Fe.filter(We=>We.required&&!We.is_child&&(typeof We.value>"u"||We.value===null)).map(We=>({key:We.key,name:We.name,label:We.label}))});const je=ce!=null&&ce.account_schema_id?!!ce.account_id:!0;if(!Ve||!je)return de(fe,"account is required but account_id is missing",{accountSchemaId:ce==null?void 0:ce.account_schema_id,accountId:ce==null?void 0:ce.account_id})}}}return!0},[D]);const H=async()=>{try{await(e==null?void 0:e()),_.message.success(G("workflow.version.save_success"))}catch{_.message.error(G("workflow.version.save_failed"))}},J=Z=>{w(Z.target.value)};St.useUnmount(()=>{c(Mw()),Tl("")});const K=y.useCallback(()=>{const Z=f,de=v.trim(),ve=de||G("app.workflow.canvas.header.workflow_name_unnamed");c(Tl(ve)),oc(z,{name:ve}).then(()=>{}).catch(()=>{c(Tl(Z))}),b(!1)},[c,v,f,z]),ee=()=>{K()},$=()=>{K()},U=()=>{var Z;t||d==="edit"&&((Z=O==null?void 0:O.flowName)==null?void 0:Z.editable)!==!1&&b(!0)},R=()=>{if(!i)switch(r){case Ln.SAVING:return h.jsxs("div",{className:"save-state saving",children:[h.jsx("div",{className:"status-icon"}),"保存中"]});case Ln.SAVED:return h.jsx(_.Tooltip,{title:`已自动保存 (${o})`,children:h.jsx("div",{style:{display:"flex",alignItems:"center"},children:h.jsxs(_.Tag,{bordered:!1,color:"green",children:["已保存"," ",h.jsx("span",{style:{fontSize:10,marginLeft:4,color:"#999"},children:o})]})})});case Ln.ERROR:return h.jsx(_.Tooltip,{title:"自动保存失败",children:h.jsx(_.Badge,{status:"error",text:h.jsx("span",{children:"保存失败"})})});default:return null}},[te,se]=_.Modal.useModal(),be=async()=>{var de;const Z=()=>{var ve,we;if((ve=O==null?void 0:O.nav)!=null&&ve.onBack){O.nav.onBack();return}if((we=O==null?void 0:O.nav)!=null&&we.backTo){ac.push(O.nav.backTo);return}ac.back()};if(!N&&((de=O==null?void 0:O.nav)!=null&&de.confirmOnBackWhenOffline)&&i){await te.confirm({title:G("user.common.operation_title"),content:O.nav.backConfirmMessage||"当前流程未保存,是否确认返回?"})&&Z();return}Z()},j=()=>{var de;const Z=[];return I!=null&&I.id&&Z.push(h.jsxs(_.Space,{size:8,children:[h.jsx(_.Tag,{bordered:!1,color:"blue",icon:h.jsx(ie.EditOutlined,{}),children:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.draft_editing_tag"})}),F&&h.jsx(_.Tag,{bordered:!1,color:"blue",children:"MCP Server"}),h.jsx("span",{style:(de=O==null?void 0:O.flowStatusTag)==null?void 0:de.style,children:h.jsx(IQ,{metadata:I})}),i&&h.jsx(_.Tag,{bordered:!1,color:"orange",icon:h.jsx(ie.WarningOutlined,{}),children:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.unsaved_tag"})})]},"online-area")),Z},Y=y.useMemo(()=>{const Z=[];return T&&Z.push({size:"small",key:"history",icon:h.jsx(ie.HistoryOutlined,{}),label:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.history_versions"}),onClick:()=>{var de;(de=A==null?void 0:A.onShowHistory)==null||de.call(A)}}),Z.push({size:"small",key:"help",icon:h.jsx(ie.QuestionCircleOutlined,{}),label:(O==null?void 0:O.helpDocText)||h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.help_doc_default"}),onClick:()=>{l((O==null?void 0:O.helpDocUrl)||"https://1in15q85qd.apifox.cn/8698531m0",!0)}}),Z.push({size:"small",key:"settings",icon:h.jsx(ie.SettingOutlined,{}),label:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.settings_label"}),onClick:()=>{var de;(de=P.current)==null||de.open()}}),u&&(M!=null&&M.enabled)&&z&&Z.push({size:"small",key:"templateSettings",label:M.buttonText||h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.template_settings_default"}),icon:h.jsx(ie.FileDoneOutlined,{}),onClick:()=>k(!0)}),Z},[T,u,l,M==null?void 0:M.enabled,z,O==null?void 0:O.helpDocText,O==null?void 0:O.helpDocUrl,M.buttonText,A==null?void 0:A.onShowHistory]),W=d==="edit";return h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:"workflow-canvas-header",children:[h.jsxs("div",{className:"workflow-header-left-area",children:[((X=O.nav)==null?void 0:X.showBack)&&h.jsx(_.Button,{type:"default",size:"small",icon:h.jsx(ie.LeftOutlined,{className:"workflow-back-icon"}),onClick:be,style:{width:29}},"back"),h.jsx("div",{className:"workflow-name-icon",children:`${f??""}`.length>2?f.substring(0,2):f}),m?h.jsx(_.Input,{size:"small",ref:x,value:v,onChange:J,onPressEnter:ee,onBlur:$,maxLength:30,className:"workflow-name-input",placeholder:"请输入工作流名称"},"name-input"):h.jsx("div",{className:"workflow-name",onClick:U,children:f?h.jsxs("div",{className:"workflow-name-container",children:[h.jsx(MQ,{level:4,className:"workflow-name-text",children:f}),W&&h.jsx("div",{className:"workflow-name-desc",children:"点击名称可编辑,最多 30 字"})]}):h.jsx(_.Skeleton.Input,{active:!0,size:"small"})},"name-display"),j()]}),h.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[u&&R(),h.jsxs(_.Space,{style:{marginLeft:16},children:[(re=O==null?void 0:O.buttons)==null?void 0:re.map(Z=>h.jsx(_.Button,{size:"small",style:Z.style,icon:Z.icon,type:Z.type??"default",disabled:t,onClick:()=>{Z.onClick&&a&&Z.onClick(a)},children:Z.label},Z.id)),h.jsx(_.Button,{size:"small",icon:h.jsx(ie.SaveOutlined,{}),loading:r===Ln.SAVING,disabled:t,onClick:H,children:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.save_draft"})}),N&&s&&h.jsx(_.Button,{size:"small",icon:h.jsx(wW,{size:16}),loading:g,disabled:!z||t,onClick:async()=>{C(!0);try{await s(z)&&(_.message.success(G("workflow.version.offline_success")),await(a==null?void 0:a.refreshFlowVersionStatus()))}catch{console.error("call offline error")}finally{C(!1)}},children:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.offline_flow"})}),h.jsx(_.Dropdown,{trigger:["click"],disabled:t,menu:{items:Y},overlayClassName:"small",children:h.jsx(_.Button,{icon:h.jsx(ie.DownOutlined,{}),iconPosition:"end",size:"small",children:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.more"})})}),B&&h.jsx(_.Button,{size:"small",icon:h.jsx(ie.ToTopOutlined,{}),type:"primary",disabled:t,onClick:async()=>{var Z;i&&await H(),(Z=A==null?void 0:A.onConfirmPublish)==null||Z.call(A,n==null?void 0:n())},children:h.jsx(Te.FormattedMessage,{id:"app.workflow.canvas.header.publish_enable"})}),h.jsx(TQ,{ref:P})]})]})]}),se,(M==null?void 0:M.enabled)&&z&&h.jsx(FQ,{onOpenChange:k,open:S,workflowId:z,workflowName:f})]})},LQ=({categories:t,activeId:e,loading:n,onChange:r})=>{const o=Te.useIntl(),i=s=>{const a=s.currentTarget,l=a.scrollWidth-a.clientWidth;if(l<=0||Math.abs(s.deltaY)<=Math.abs(s.deltaX))return;const c=Math.min(Math.max(a.scrollLeft+s.deltaY,0),l);c!==a.scrollLeft&&(s.preventDefault(),a.scrollLeft=c)};return n?h.jsx("div",{className:"category-tabs-wrapper loading","aria-busy":"true","aria-live":"polite",children:h.jsx("div",{className:"category-tabs",children:[0,1,2,3,4].map(s=>h.jsx("div",{className:"category-tab-skeleton",style:{animationDelay:`${s*80}ms`}},`category-skeleton-${s}`))})}):h.jsxs("div",{className:"category-tabs-wrapper",children:[h.jsx("div",{className:"category-tabs",onWheel:i,children:t.map(s=>h.jsx("div",{className:ar("category-tab",{active:e===s.id,disabled:s.filterable===!1}),title:s.filterable===!1?o.formatMessage({id:of.categoryUnavailable}):void 0,onClick:()=>{if(s.filterable===!1){_.message.warning(o.formatMessage({id:of.categoryUnavailable}));return}r(s)},children:s.name},s.id))}),h.jsx("div",{className:"category-tabs-mask left"}),h.jsx("div",{className:"category-tabs-mask right"})]})},$Q=({action:t,parentNode:e,onSelect:n})=>{const r=t.status===0||t.disabled===!0,o=()=>{r||(parseInt(`${t.id}`,10)<1?n(e,{...t,type:`${t.action_key}@${t.action_ver}`,saveType:t.action_type}):n(e,t))};return h.jsxs("button",{type:"button",className:`action-item${r?" is-disabled":""}`,onClick:o,disabled:r,"aria-label":`选择动作 ${t.name}`,title:r?"后续版本支持":void 0,children:[h.jsx("div",{className:"item-icon","data-category":e.category.split("-")[0]||"action",children:t.icon?h.jsx("img",{src:t.icon,alt:t.name,style:{width:32,height:32}}):h.jsx("div",{children:t.name.charAt(0).toUpperCase()})}),h.jsxs("div",{className:"item-content",children:[h.jsx("div",{className:"item-title",children:t.name}),t.description&&h.jsx("div",{className:"item-description",children:t.description})]})]})},zQ=({node:t,expanded:e,actions:n,loading:r,hasPartialActions:o,onToggle:i,onActionSelect:s,onLoadAllActions:a})=>{const l=()=>{i(t)},c=u=>{u.stopPropagation(),a==null||a(t)};return h.jsxs("div",{className:ar("node-card",{expanded:e}),children:[h.jsxs("button",{type:"button",className:"node-card-header","aria-expanded":e,"aria-label":`${e?"收起":"展开"} ${t.name}`,onClick:l,children:[h.jsx("div",{className:"node-card-icon",children:t.icon?h.jsx("img",{src:t.icon,alt:t.name}):h.jsx("span",{children:t.name.charAt(0).toUpperCase()})}),h.jsxs("div",{className:"node-card-info",children:[h.jsx("div",{className:"node-card-title",children:t.name}),t.description&&h.jsx("div",{className:"node-card-desc",children:t.description})]}),h.jsx(ie.CaretDownOutlined,{className:ar("node-card-arrow",{expanded:e})})]}),e&&h.jsxs("div",{className:"node-card-body",children:[r?h.jsx("div",{className:"node-card-state",children:"动作加载中..."}):n.length===0?h.jsx("div",{className:"node-card-state",children:"暂无可用动作"}):h.jsx("div",{className:"node-card-actions",children:n.map(u=>h.jsx("div",{className:"node-card-action-wrapper",children:h.jsx($Q,{action:u,parentNode:t,onSelect:s})},u.id))}),o&&!r&&h.jsx("button",{type:"button",className:"node-card-more",onClick:c,children:"查看该节点全部动作"})]})]})},HQ=({currentCategory:t,categoryPath:e,selectedNode:n,onBack:r,onClose:o,title:i,subTitle:s,showBackButton:a})=>{const l=()=>n?n.name:t?t.name:"节点选择器",c=()=>n?"选择动作":e.length>0?e.slice(0,-1).map(p=>p.name).join(" / "):"",u=i||l(),d=s??c(),f=typeof a=="boolean"?a:!!(n||e.length>0);return h.jsxs("div",{className:"panel-header",children:[h.jsxs("div",{className:"header-left",children:[f&&r&&h.jsx("button",{type:"button",className:"back-button","aria-label":"返回上一级",onClick:r,children:h.jsx(ie.ArrowLeftOutlined,{})}),h.jsxs("div",{className:"title",children:[u,d&&h.jsx("div",{className:"category-path",children:d})]})]}),h.jsx("button",{type:"button",className:"close-button","aria-label":"关闭节点选择器",onClick:o,children:h.jsx(ie.CloseOutlined,{})})]})},VQ=[],jQ=new Set(Object.values(pe)),WQ=t=>{if(t)return jQ.has(t)?t:void 0},UQ=({nodeSelectorVisible:t,nodeAddInfo:e})=>{const[n,r]=y.useState(!1),o=El();return{isLoadingActions:n,fetchNodeActions:async(s,a)=>{a!=null&&a.suppressLoading||r(!0);try{const l=t&&e&&e.trigger===!0,c=(e==null?void 0:e.protocol)===$e.MCP_SERVER||(e==null?void 0:e.protocol)===$e.BUILTIN_MCP,u=e==null?void 0:e.protocol,d={linkId:s.id,flowId:o},f=WQ(s.type);f&&(d.actionType=f),c&&(d.page=(a==null?void 0:a.page)??1,d.size=(a==null?void 0:a.size)??iR),u&&(d.protocol=u),l&&(d.trigger=!0);const p=await py(d);return p&&p.items&&Array.isArray(p.items)?p.items.map(b=>{var w;const v=b.action_ver??((w=b.node_schema)==null?void 0:w.version);return b.action_key&&b.node_schema&&A0(b.action_key,v,b.node_schema),{...b,id:b.id,action_key:b.action_key,action_ver:v,nodeKey:b.action_key,nodeVersion:v,name:b.name||"未命名动作",description:b.description||"",connector_name:s.name,nodeId:s.id,nodeIcon:s.icon}}):[]}catch(l){return console.error("获取动作列表失败:",l),[]}finally{a!=null&&a.suppressLoading||r(!1)}}}},qQ=({onFetchCategories:t,restrictToCategory:e,nodeSelectorVisible:n,nodeAddInfo:r,fallbackCategories:o=[],requestContextKey:i,useConnectableDataSource:s=!1})=>{const[a,l]=y.useState(o),[c,u]=y.useState(!1),[d,f]=y.useState(null),p=y.useRef(0);return y.useEffect(()=>{if(!n){p.current+=1,u(!1),f(null);return}return(async()=>{const b=++p.current;u(!0),f(null);try{let v="action";const w=n&&r&&r.trigger,g=r==null?void 0:r.protocol;w?v="trigger":g===$e.MCP_SERVER||g===$e.BUILTIN_MCP?v=lO:g===$e.AI_TOOL?v="mcp":g===$e.AI_LANGUAGE_MODEL?v="model":g===$e.AI_MEMORY&&(v="memory");const C=await t(v);if(b!==p.current)return;const k=e?C.filter(D=>D.id===e):v===lO&&!s?C.filter(D=>D.id===sw):w?C:C.filter(D=>D.id!=="TRIGGER"),x=e?null:{id:"ALL",name:"全部",description:"全部分类",icon:void 0};l(x?[x,...k]:k),f(i)}catch(v){if(b!==p.current)return;console.error("Failed to fetch categories:",v),l(o),f(i)}finally{b===p.current&&u(!1)}})(),()=>{p.current+=1}},[o,r==null?void 0:r.protocol,r==null?void 0:r.trigger,n,t,i,e,s]),{categories:a,categoriesReady:n&&d===i,isLoadingCategories:c,setCategories:l}};async function GQ({node:t,query:e,fetchConnectablePage:n,filterPage:r=o=>o}){var s;if(!e)return[];const o=r(await n(e)),i=o.nodes.find(a=>a.id===t.id);return(i==null?void 0:i.matchedActions)??((s=o.nodes[0])==null?void 0:s.matchedActions)??[]}function RQ(t,e,n=!1){return n||e===$e.BUILTIN_MCP||e===$e.MCP_SERVER?"mcp":t}const LN=/^[1-9]\d*$/,Vb=t=>{if(typeof t=="number")return Number.isSafeInteger(t)&&t>0?t:void 0;const e=t.trim();if(LN.test(e))return e},Hr=t=>{const e=t==null?void 0:t.trim();return e||void 0},$N=t=>{if(t==null)return;if(typeof t=="number")return Number.isSafeInteger(t)&&t>0?t:void 0;const e=t.trim();if(!LN.test(e))return;const n=Number(e);return Number.isSafeInteger(n)?n:void 0},KQ=t=>{const e=t.scene.trim(),n=Hr(t.categoryName),r=Hr(t.flowId),o=$N(t.page),i=$N(t.size);return{scene:e,trigger:t.trigger,...n===void 0?{}:{categoryName:n},...Hr(t.linkId)===void 0?{}:{linkId:Hr(t.linkId)},...Hr(t.keyword)===void 0?{}:{keyword:Hr(t.keyword)},...r===void 0?{}:{flowId:r},...o===void 0?{}:{page:o},...i===void 0?{}:{size:i}}},YQ=(t,e)=>{const n=KQ(e);switch(t.mode){case"independent":return{...n,mode:"independent"};case"source":{const r=Vb(t.sourceId),o=Hr(t.sourceHandle);return r===void 0||o===void 0?null:{...n,mode:"source",sourceId:r,sourceHandle:o}}case"target":{const r=Vb(t.targetId),o=Hr(t.targetHandle);return r===void 0||o===void 0?null:{...n,mode:"target",targetId:r,targetHandle:o}}case"edge-insert":{const r=Vb(t.sourceId),o=Hr(t.sourceHandle),i=Hr(t.targetHandle);return r===void 0||o===void 0||i===void 0?null:{...n,mode:"source",sourceId:r,sourceHandle:o}}}},zN="[workflow:connectable]",Bi=t=>!!t&&typeof t=="object"&&!Array.isArray(t),jb=(t,e)=>Object.hasOwn(t,e),qt=(t,e)=>{for(const n of e)if(jb(t,n)&&t[n]!==void 0&&t[n]!==null)return t[n]},Bt=(t,e)=>{for(const n of e){const r=t[n];if(typeof r=="string"&&r.trim())return r.trim()}},Fl=t=>{if(typeof t=="number")return Number.isFinite(t)?t:void 0;if(typeof t=="string"&&t.trim()){const e=Number(t);return Number.isFinite(e)?e:void 0}},Wb=(t,e=!1)=>typeof t=="boolean"?t:t===1||t==="1"||t==="true"?!0:t===0||t==="0"||t==="false"?!1:e,XQ=t=>Array.isArray(t)?t.filter(e=>typeof e=="string"):[],HN=t=>{let e=t,n=0;for(;n<4&&Bi(e)&&jb(e,"data")&&!jb(e,"items");)e=e.data,n+=1;return e},JQ=t=>{const e=HN(t);return Array.isArray(e)?e.filter(Bi).map(n=>{const r=Bt(n,["name","categoryName","category_name"]),o=Bt(n,["label","name"])??"";return r||console.warn(`${zN} category has no filter name`,{name:o,availableKeys:Object.keys(n).sort()}),{id:r||o,categoryName:r,name:o,description:Bt(n,["desc","description"])??"",icon:Bt(n,["icon"]),searchAction:Wb(qt(n,["searchAction","search_action"])),filterable:!!r}}):[]},VN=t=>{if(typeof t=="number")return Number.isSafeInteger(t)&&t>0?String(t):void 0;if(typeof t!="string")return;const e=t.trim();if(e){if(/^-?\d+$/.test(e)){const n=e.startsWith("-")?e.slice(1):e;if(e.startsWith("-")||/^0+$/.test(n))return}return e}},QQ=t=>{if(typeof t=="number")return Number.isSafeInteger(t)?String(t):void 0;if(typeof t!="string")return;const e=t.trim();return/^-?\d+$/.test(e)?e:void 0},jN=(t,e)=>{for(const n of e){const r=VN(t[n]);if(r!==void 0)return{value:r,source:n}}},WN=(t,e)=>{console.warn(`${zN} ${t} has no stable identifier`,{name:Bt(e,["name","label","actionName","action_name"]),availableKeys:Object.keys(e).sort()})},ZQ=t=>{const e=Bi(t)?t:{},n=jN(e,["id","linkId","link_id","appPackage","app_package","connectorId","connector_id"]);return n||WN("connector",e),{...e,id:(n==null?void 0:n.value)??"",selectable:!!n,identifierSource:n==null?void 0:n.source,name:Bt(e,["name","displayName","display_name"])??"",description:Bt(e,["description","desc"])??null,build_type:Bt(e,["buildType","build_type"]),app_domain_category:XQ(qt(e,["appDomainCategory","app_domain_category"])),app_action_category:qt(e,["appActionCategory","app_action_category"]),deployment_type:Bt(e,["deploymentType","deployment_type"]),app_package:Bt(e,["appPackage","app_package"]),ver_name:Bt(e,["verName","ver_name"]),ver_number:Fl(qt(e,["verNumber","ver_number"])),ver_type:Bt(e,["verType","ver_type"]),icon:Bt(e,["icon"])}},eZ=t=>{const e=Bi(t)?t:{},n=jN(e,["actionKey","action_key","nodeKey","node_key"]),r=qt(e,["nodeSchema","node_schema"]),o=Bi(r)?r:null,i=o?Bt(o,["key"]):void 0,s=o?Fl(qt(o,["version"])):void 0,a=QQ(qt(e,["id","actionId","action_id"]))??(i?"0":void 0),l=n??(i?{value:i,source:"nodeSchema.key"}:void 0);l||WN("action",e);const c=Bt(e,["actionKey","action_key","nodeKey","node_key"])??i,u=VN(qt(e,["connectorId","connector_id"]));return{...e,id:(l==null?void 0:l.value)??"",backendActionId:a,action_id:a,selectable:!!l,identifierSource:l==null?void 0:l.source,action_key:c,action_ver:Fl(qt(e,["actionVer","action_ver","nodeVersion","node_version","version"]))??s,is_trigger:Fl(qt(e,["isTrigger","is_trigger"]))??(Wb(qt(e,["isTrigger","is_trigger"]))?1:0),name:Bt(e,["name","actionName","action_name"])??"",description:Bt(e,["description","desc"])??null,connector_id:u??null,status:l?1:0,protocol:Bt(e,["protocol"])??"",config_schema:qt(e,["configSchema","config_schema"])??{},sample_output:qt(e,["sampleOutput","sample_output"]),node_struct:Bt(e,["nodeStruct","node_struct"])??"",action_type:Bt(e,["actionType","action_type"])??null}},tZ=t=>{if(typeof t!="string"||!t.trim())return;const e=t.trim().toUpperCase();switch(e){case"CONNECTOR_ONL":return"CONNECTOR_ONLY";case"ACTION_MATCHED":return"ACTION_ONLY";case"BOTH":return"BOTH_MATCHED";default:return e}},af=(t,e,n)=>Fl(qt(t,e))??n,nZ=t=>{const e=HN(t),n=Bi(e)?e:{},r=qt(n,["items","records"]),o=Array.isArray(r)?r.filter(Bi).map(i=>{const s=ZQ(i.connector),a=qt(i,["matchedActions","matched_actions"]),l=Array.isArray(a)?a.map(c=>eZ(c)):[];return{connector:s,matched_actions:l,default_expanded:Wb(qt(i,["defaultExpanded","default_expanded"])),match_type:tZ(qt(i,["matchType","match_type"]))}}):[];return{items:o,total:af(n,["total"],o.length),size:af(n,["size"],o.length),page:af(n,["page","current"],1),pages:af(n,["pages"],0)}},rZ=(t,e)=>{var a;const n=t.action_type||t.node_struct||pe.ACTION,r=t.action_ver??((a=t.node_schema)==null?void 0:a.version);t.action_key&&t.node_schema&&A0(t.action_key,r,t.node_schema);const{node_schema:o,nodeSchema:i,...s}=t;return{...s,id:t.id,type:n,action_type:n,action_key:t.action_key,action_ver:r,nodeKey:t.action_key,nodeVersion:r,action_name:t.name||e.name,name:t.name||e.name,description:t.description||e.description||"",connector_name:e.name,nodeId:e.id,nodeIcon:e.icon}},oZ=(t,e)=>{if(typeof e=="boolean")return e;if(!t)return!1;const n=t.toUpperCase();return n==="ACTION_ONLY"||n==="BOTH_MATCHED"},iZ=(t,e)=>{const{matchedActions:n,defaultExpanded:r,matchType:o}=e||{};return{id:t.id||t.name,selectable:"selectable"in t&&typeof t.selectable=="boolean"?t.selectable:!0,identifierSource:"identifierSource"in t&&typeof t.identifierSource=="string"?t.identifierSource:void 0,type:t.build_type||pe.ACTION,name:t.name,description:t.description||"",category:t.app_domain_category&&t.app_domain_category[0]||"unknown",icon:t.icon||void 0,app_domain_category:t.app_domain_category||[],actionCategories:t.app_action_category||[],deployment_type:t.deployment_type,build_type:t.build_type,matchedActions:n,defaultExpanded:oZ(o,r),matchType:o,connector:t}},sZ=t=>JQ(t).map(e=>({id:e.id,categoryName:e.categoryName,filterable:e.filterable,name:e.name,description:e.description,icon:e.icon,search_action:e.searchAction,nodes:[]})),aZ=t=>{const e=nZ(t);return{nodes:e.items.map(({connector:r,matched_actions:o,default_expanded:i,match_type:s})=>{const a=o.map(l=>rZ(l,r));return iZ(r,{matchedActions:a,defaultExpanded:i,matchType:s})}),total:e.total,page:e.page,size:e.size,pages:e.pages}},lZ=async t=>{const{apiQueryConnectableNodePackageCategories:e}=await Promise.resolve().then(()=>Yy),n=await e(t);return sZ(n)},UN=async t=>{const{apiQueryConnectableNodePackagePlugins:e}=await Promise.resolve().then(()=>Yy),n=await e(t);return aZ(n)},lf=t=>(t==null?void 0:t.trim())||void 0,cZ=t=>{const e=t==null?void 0:t.edge;if(e){const s=lf(e.sourceHandle??e.sourceHandleId),a=lf(e.targetHandle??e.targetHandleId);return e.source===void 0||e.target===void 0||!s||!a?null:String(e.source)===String(e.target)&&s===He.LOOP?{mode:"source",sourceId:e.source,sourceHandle:s}:{mode:"edge-insert",sourceId:e.source,sourceHandle:s,targetId:e.target,targetHandle:a}}const n=lf(t==null?void 0:t.sourceHandle),r=lf(t==null?void 0:t.targetHandle),o=(t==null?void 0:t.sourceNodeId)!==void 0||n!==void 0,i=(t==null?void 0:t.targetNodeId)!==void 0||r!==void 0;return o&&i?null:o?t!=null&&t.sourceNodeId&&n?{mode:"source",sourceId:t.sourceNodeId,sourceHandle:n}:null:i?t!=null&&t.targetNodeId&&r?{mode:"target",targetId:t.targetNodeId,targetHandle:r}:null:{mode:"independent"}};function uZ({nodeSelectorVisible:t,effectiveNodeAddInfo:e,workflowId:n,onSearch:r,onFetchCategories:o,onFetchNodesByCategory:i}){var b;const s=Pt(),{isMcpServerCanvas:a}=MN(),l=RQ(a?"mcp":s.scene??"",e==null?void 0:e.protocol,a),c=y.useMemo(()=>cZ(e),[e]),u=y.useMemo(()=>{var v;return JSON.stringify({visible:t,protocol:e==null?void 0:e.protocol,trigger:!!(e!=null&&e.trigger),edgeId:(v=e==null?void 0:e.edge)==null?void 0:v.id,connectableContext:c,workflowId:n})},[c,(b=e==null?void 0:e.edge)==null?void 0:b.id,e==null?void 0:e.protocol,e==null?void 0:e.trigger,t,n]),d=y.useCallback((v={})=>c?YQ(c,{scene:l,trigger:!!(e!=null&&e.trigger),categoryName:v.categoryName,keyword:v.keyword??v.name,linkId:v.linkId,flowId:v.flow_id??n,page:v.page,size:v.size}):null,[c,e==null?void 0:e.trigger,l,n]),f=y.useCallback(async()=>{const v=d();return v?lZ(v):[]},[d]),p=y.useCallback(async(v={})=>{const w=d(v);return w?await UN(w):{nodes:[],total:0,page:v.page||1,size:v.size||20,pages:0}},[d]),m=y.useCallback(async(v,w)=>{const g=d({linkId:v.id});return GQ({node:v,query:g,fetchConnectablePage:UN})},[d]);return{actionRequestContextKey:u,connectableContext:c,onSearch:r||p,onFetchCategories:o||f,onFetchNodesByCategory:i||p,fetchNodeActions:m}}const dZ=({categories:t,categoriesReady:e,initialCategory:n,nodeSelectorVisible:r,nodeAddInfo:o,onFetchNodesByCategory:i,defaultPageSize:s=20,flowId:a,useConnectableDataSource:l=!1})=>{const[c,u]=y.useState(n||"ALL"),[d,f]=y.useState([]),[p,m]=y.useState(!1),[b,v]=y.useState({page:1,size:s,total:0,hasMore:!0}),w=y.useRef(0),g=r&&o&&o.trigger===!0,C=r&&o&&o.protocol===$e.AI_TOOL,S=r&&o&&o.protocol===$e.BUILTIN_MCP,k=y.useMemo(()=>o==null?void 0:o.protocol,[o==null?void 0:o.protocol]),x=y.useMemo(()=>{const N=o==null?void 0:o.protocol;if(N===$e.AI_TOOL)return"tool";if(N===$e.AI_LANGUAGE_MODEL)return"model";if(N===$e.AI_MEMORY)return"memory"},[o==null?void 0:o.protocol]),E=((o==null?void 0:o.protocol)===$e.MCP_SERVER||(o==null?void 0:o.protocol)===$e.BUILTIN_MCP)&&!l,O=y.useMemo(()=>c==="ALL"?null:t.find(N=>N.id===c)||null,[c,t]),A=y.useCallback((N,P=1)=>{var I;return{app_domain_category:l?void 0:E?sw:N&&N!=="ALL"?N:void 0,categoryName:(I=t.find(z=>z.id===N))==null?void 0:I.categoryName,page:P,size:E?cO:s,trigger:!!g,type:x,protocol:k,flow_id:a}},[s,t,E,g,x,k,a,l]),T=y.useCallback(async(N,P=1,I=!1)=>{if(!r)return;const z=++w.current;m(!0);try{const H=A(N,P),{nodes:J,total:K,size:ee}=await i(H);if(z!==w.current)return;f($=>I?[...$,...J]:J),v({page:P,size:ee,total:K,hasMore:P*ee<K})}catch(H){if(z!==w.current)return;console.error("Failed to fetch category data:",H),I||f([])}finally{z===w.current&&m(!1)}},[A,r,i]),B=y.useCallback(async N=>{u(N),await T(N,1,!1)},[T]),M=y.useCallback(async()=>{p||!b.hasMore||await T(c||"ALL",b.page+1,!0)},[T,p,b,c]),F=y.useCallback(()=>{w.current+=1,m(!1),u(n||"ALL"),f([]),v({page:1,size:s,total:0,hasMore:!0})},[n,s]);return y.useEffect(()=>{var P,I;if(!r||!e){F();return}const N=n&&((P=t.find(z=>z.id===n))==null?void 0:P.id)||((I=t[0])==null?void 0:I.id)||"ALL";u(N),T(N,1,!1)},[t,e,T,n,r,F]),{categoryNodes:d,currentCategory:O,isLoadingNodes:p,isRealTriggerMode:g,isAIToolMode:C,isBuiltinMCPMode:S,navigateToCategory:B,loadMoreNodes:M,resetNavigation:F,pagination:b,activeCategoryId:c,setActiveCategoryId:u}},fZ=({onSearch:t})=>{const[e,n]=y.useState(""),[r,o]=y.useState([]),[i,s]=y.useState(!1),[a,l]=y.useState({total:0,page:1,size:20}),c=y.useRef(0),u=y.useCallback(async(f,p={})=>{if(n(f),!f.trim()){c.current+=1,s(!1),o([]),l({total:0,page:1,size:p.size||20});return}s(!0);const m=++c.current;try{const{nodes:b,total:v,page:w,size:g}=await t({...p,name:f});if(m!==c.current)return;o(b),l({total:v,page:w,size:g})}catch(b){if(m!==c.current)return;console.error("Search failed:",b),o([]),l({total:0,page:1,size:p.size||20})}finally{m===c.current&&s(!1)}},[t]),d=y.useCallback(()=>{c.current+=1,s(!1),n(""),o([]),l({total:0,page:1,size:20})},[]);return{searchText:e,searchResults:r,isSearching:i,searchMeta:a,handleSearch:u,clearSearch:d,setSearchText:n}},qN={async loadFlow(t){const n=await Gf(t),r=n;if(r&&typeof r=="object"&&r.result===!1)throw new wT(typeof r.error=="string"?r.error:void 0,typeof r.error_description=="string"?r.error_description:void 0);const{nodes:o,edges:i,workflowName:s}=bT(n);return{nodes:o,edges:i,name:s||n.name||"",opStatus:n.op_status,executionControl:n.execution_control??null,metadata:n}},async saveFlow({workflowId:t,payload:e}){if(!e)throw new Error("缺少工作流草稿数据");await oc(t,e)},buildFlowPayload:JX,async createNode({workflowId:t,nodeType:e,actionId:n,actionKey:r,actionVer:o,configSchema:i,position:s}){const l=await wy({flow_id:t,node_type:e,action_id:n,...r?{action_key:r,action_ver:o}:{},properties:i||{},position:s});return l?{nodeId:l.id,nodeData:{action_name:l.action_name,connector_name:l.connector_name,status:l.status,icon:l.icon,protocol:l.protocol,...r?{action_key:r,action_ver:o,nodeKey:r,nodeVersion:o}:{},...mI(n,l)}}:(console.error("创建失败",l),null)},stickyNodeKey:YX,HeaderComponent:PQ,PanelComponent:({availableCategories:t=VQ,initialCategory:e,onSearch:n,onFetchCategories:r,onFetchNodesByCategory:o,restrictToCategory:i})=>{const s=y.useRef(null),a=y.useRef(null),[l,c]=y.useState([]),[u,d]=y.useState({}),{nodeSelectorVisible:f,closeNodeSelector:p,handleNodeSelect:m,nodeAddInfo:b}=uc(),v=El(),w=b;UQ({nodeSelectorVisible:f,nodeAddInfo:w});const{actionRequestContextKey:g,onSearch:C,onFetchCategories:S,onFetchNodesByCategory:k,fetchNodeActions:x}=uZ({nodeSelectorVisible:f,effectiveNodeAddInfo:w,workflowId:v,onSearch:n,onFetchCategories:r,onFetchNodesByCategory:o}),{categories:D,categoriesReady:E,isLoadingCategories:O}=qQ({onFetchCategories:S,restrictToCategory:i,nodeSelectorVisible:f,nodeAddInfo:w,fallbackCategories:t,requestContextKey:g}),{searchText:A,searchResults:T,isSearching:B,handleSearch:M,clearSearch:F,setSearchText:N}=fZ({onSearch:C}),P=y.useRef(A),{categoryNodes:I,isLoadingNodes:z,isRealTriggerMode:H,navigateToCategory:J,loadMoreNodes:K,resetNavigation:ee,pagination:$,activeCategoryId:U,currentCategory:R}=dZ({categories:D,categoriesReady:E,initialCategory:e,nodeSelectorVisible:f,nodeAddInfo:w,onFetchNodesByCategory:k,flowId:v}),te=y.useMemo(()=>(w==null?void 0:w.protocol)===$e.MCP_SERVER?"选择 MCP Server 入口":(w==null?void 0:w.protocol)===$e.BUILTIN_MCP?"选择 MCP 工具":(w==null?void 0:w.protocol)===$e.AI_LANGUAGE_MODEL?"选择模型":"选择动作",[w==null?void 0:w.protocol]),se=y.useMemo(()=>(w==null?void 0:w.protocol)===$e.AI_LANGUAGE_MODEL||(w==null?void 0:w.protocol)===$e.AI_MEMORY?"按模型名称搜索":(w==null?void 0:w.protocol)===$e.MCP_SERVER?"按 MCP Server 入口名称搜索":(w==null?void 0:w.protocol)===$e.BUILTIN_MCP?"按 MCP 工具名称搜索":"按节点/动作名称搜索",[w==null?void 0:w.protocol]),be=A,j=y.useMemo(()=>w==null?void 0:w.protocol,[w==null?void 0:w.protocol]),Y=y.useMemo(()=>{const Ce=w==null?void 0:w.protocol;if(Ce===$e.AI_TOOL)return"tool";if(Ce===$e.AI_LANGUAGE_MODEL)return"model";if(Ce===$e.AI_MEMORY)return"memory"},[w==null?void 0:w.protocol]),W=(w==null?void 0:w.protocol)===$e.MCP_SERVER||(w==null?void 0:w.protocol)===$e.BUILTIN_MCP,X=(w==null?void 0:w.protocol)===$e.MCP_SERVER,re=y.useMemo(()=>A?T:I,[I,T,A]),Z=y.useCallback(()=>({app_domain_category:W?sw:U&&U!=="ALL"?U:void 0,trigger:!!H,type:Y,protocol:j,flow_id:v,...W?{page:1,size:cO}:{}}),[U,W,H,Y,j,v]),{run:de,cancel:ve}=St.useDebounceFn(Ce=>{const Oe=Ce.trim();if(!Oe){F(),c([]);return}M(Oe,Z())},{wait:300}),we=y.useCallback(async Ce=>{if(X&&Ce.matchedActions.length){d(Pe=>({...Pe,[Ce.id]:{actions:Ce.matchedActions||[],loading:!1,source:"full"}}));return}d(Pe=>{var qe,zn;return{...Pe,[Ce.id]:{actions:((qe=Pe[Ce.id])==null?void 0:qe.actions)||[],loading:!0,source:(zn=Pe[Ce.id])==null?void 0:zn.source}}});const Oe=await x(Ce,{suppressLoading:!0});d(Pe=>({...Pe,[Ce.id]:{actions:Oe,loading:!1,source:"full"}}))},[x,X]),fe=async Ce=>{if(l.includes(Ce.id)){c(qe=>qe.filter(zn=>zn!==Ce.id));return}c(qe=>[...qe,Ce.id]);const Pe=u[Ce.id];(!Pe||Pe.actions.length===0||Pe.source==="search-partial")&&await we(Ce)},le=async Ce=>{await we(Ce)},Se=(Ce,Oe)=>{const Pe={id:Oe.id??Oe.action_id,action_id:Oe.action_id??Oe.id,action_type:Oe.action_type,type:Oe.action_type,action_key:Oe.action_key,action_ver:Oe.action_ver,action_name:Oe.action_name,name:Ce.name,description:Oe.name||Oe.description,connector_name:(Ce==null?void 0:Ce.name)??Oe.connector_name,connector_id:Oe.connector_id,account_schema_id:Oe.account_schema_id,protocol:Oe.protocol,deployment_type:Ce.deployment_type,icon:Ce.icon??Oe.icon,nodeId:Oe.nodeId,config_schema:Oe.config_schema,category:Ce==null?void 0:Ce.category,nodeKey:Oe.nodeKey,nodeVersion:Oe.nodeVersion,isAction:!0};m(Pe)},ce=async Ce=>{c([]),F(),await J(Ce.id)},Fe=Ce=>{N(Ce),de(Ce)},Ve=Ce=>{if(A||!$.hasMore||z)return;const{scrollTop:Oe,scrollHeight:Pe,clientHeight:qe}=Ce.currentTarget;Pe-Oe-qe<120&&K()};y.useEffect(()=>{if(!f){const Ce=setTimeout(()=>{F(),ee(),c([]),d({})},200);return()=>clearTimeout(Ce)}return()=>ve()},[f,F,ee,ve]),y.useEffect(()=>{if(P.current=A,A){const Ce=T.filter(Oe=>Oe.defaultExpanded).map(Oe=>Oe.id);c(Ce)}},[T,A]),y.useEffect(()=>{A||c([])},[U,A]),y.useEffect(()=>{P.current&&M(P.current,Z())},[U,Z,M]),y.useEffect(()=>{d(Ce=>{const Oe={};return re.forEach(Pe=>{Pe.matchedActions&&Pe.matchedActions.length>0?Oe[Pe.id]={actions:Pe.matchedActions,loading:!1,source:"search-partial"}:Ce[Pe.id]?Oe[Pe.id]=Ce[Pe.id]:Oe[Pe.id]={actions:[],loading:!1}}),Oe})},[re]),St.useClickAway(Ce=>{if(f){const Oe=Ce.target;if(/start-node/.test(Oe.className))return;p()}},s);const je=!E||O||!A&&z,We=()=>B||re.length===0&&je||z?h.jsx("div",{className:"node-card-list","aria-busy":"true","aria-live":"polite",children:[0,1,2,3,4,5,6,7,8,9].map(Ce=>h.jsxs("div",{className:"node-card-skeleton",style:{animationDelay:`${Ce*80}ms`},children:[h.jsx("div",{className:"node-card-skeleton-icon"}),h.jsxs("div",{className:"node-card-skeleton-content",children:[h.jsx("div",{className:"node-card-skeleton-title"}),h.jsx("div",{className:"node-card-skeleton-desc"})]}),h.jsx("div",{className:"node-card-skeleton-arrow"})]},`skeleton-${Ce}`))}):re.length===0?h.jsx("div",{className:"empty-state",children:h.jsx("div",{className:"empty-text",children:"暂无符合条件的节点"})}):h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"node-card-list",children:re.map(Ce=>{var Oe,Pe,qe;return h.jsx(zQ,{node:Ce,expanded:l.includes(Ce.id),actions:((Oe=u[Ce.id])==null?void 0:Oe.actions)||[],loading:((Pe=u[Ce.id])==null?void 0:Pe.loading)||!1,hasPartialActions:((qe=u[Ce.id])==null?void 0:qe.source)==="search-partial",onToggle:fe,onActionSelect:Se,onLoadAllActions:le},Ce.id)})}),!A&&z&&re.length>0&&h.jsx("div",{className:"list-loading",children:h.jsx("span",{children:"正在加载更多"})}),!A&&!$.hasMore&&!z&&re.length>0&&h.jsx("div",{className:"list-footer",children:"已加载全部"})]});return f?h.jsxs("div",{className:ar("modern-node-selector",{visible:f}),ref:s,children:[h.jsx(HQ,{currentCategory:R,categoryPath:[],selectedNode:null,onClose:p,title:te,showBackButton:!1}),h.jsx("div",{className:"search-container",children:h.jsx(_.Input,{placeholder:se,prefix:h.jsx(bW,{size:16}),allowClear:!0,value:be,onChange:Ce=>Fe(Ce.target.value)})}),h.jsx(LQ,{categories:D,activeId:U||"ALL",loading:O,onChange:ce}),h.jsx("div",{className:"panel-content-box",children:h.jsx("div",{className:"panel-content",ref:a,onClick:Ce=>Ce.stopPropagation(),onScroll:Ve,children:We()})})]}):null},requiresTriggerNode:!0},hZ=t=>{const e=gX(qN.nodeTypes);return h.jsx(SQ,{strategy:qN,nodeTypes:e,...t})},kt={"configSubflow-container":"_configSubflow-container_1ocqs_1","configSubflow-selectSection":"_configSubflow-selectSection_1ocqs_4","configSubflow-selectWrapper":"_configSubflow-selectWrapper_1ocqs_19","configSubflow-select":"_configSubflow-select_1ocqs_4","configSubflow-optionContent":"_configSubflow-optionContent_1ocqs_28","configSubflow-optionName":"_configSubflow-optionName_1ocqs_34","configSubflow-optionLink":"_configSubflow-optionLink_1ocqs_41","configSubflow-paramsSection":"_configSubflow-paramsSection_1ocqs_66","configSubflow-paramsTitle":"_configSubflow-paramsTitle_1ocqs_71","configSubflow-paramsList":"_configSubflow-paramsList_1ocqs_83","configSubflow-paramItem":"_configSubflow-paramItem_1ocqs_88",hasError:"_hasError_1ocqs_101","configSubflow-paramKey":"_configSubflow-paramKey_1ocqs_105","configSubflow-paramKeyLabel":"_configSubflow-paramKeyLabel_1ocqs_110","configSubflow-paramValue":"_configSubflow-paramValue_1ocqs_130","configSubflow-hintMessage":"_configSubflow-hintMessage_1ocqs_156",warning:"_warning_1ocqs_170",info:"_info_1ocqs_175","configSubflow-errorText":"_configSubflow-errorText_1ocqs_185","configSubflow-loading":"_configSubflow-loading_1ocqs_191"},pZ=(t,e={})=>!(t!=null&&t.params)||Object.keys(t.params).length===0?[]:Object.entries(t.params).map(([n,r],o)=>({id:`${n}_${o}`,key:n,value:e[n]!==void 0?e[n]:r,exampleValue:r})),mZ=t=>!!(t!=null&&t.params&&Object.keys(t.params).length>0),GN=y.forwardRef(({value:t,onChange:e,disabled:n=!1,nodeId:r=""},o)=>{const[i,s]=y.useState(t==null?void 0:t.flowId),[a,l]=y.useState([]),[c,u]=y.useState([]),d=At(),f=Sl(),p=n||!d,{data:m=[],loading:b,run:v}=St.useRequest(Ky,{debounceWait:300}),w=m||[],g=y.useMemo(()=>w.find(F=>F.id===i),[w,i]);y.useEffect(()=>{(t==null?void 0:t.flowId)!==i&&s(t==null?void 0:t.flowId)},[t==null?void 0:t.flowId]),y.useEffect(()=>{if(g){const F=pZ(g,t==null?void 0:t.input);l(F)}else l([])},[g,t==null?void 0:t.input]);const C=y.useCallback((F,N)=>{if(!F){e==null||e(void 0);return}e==null||e({flowId:F,input:N})},[e]),S=y.useCallback(F=>{s(F),u([]);const N=w.find(I=>I.id===F),P={};N!=null&&N.params&&Object.entries(N.params).forEach(([I,z])=>{P[I]=z}),C(F,P)},[w,C]),k=y.useCallback((F,N)=>{const P={...(t==null?void 0:t.input)||{}};P[F]=N,C(i,P),u(I=>I.filter(z=>!(z.type==="param"&&z.paramKey===F)))},[i,t==null?void 0:t.input,C]),x=y.useCallback((F,N)=>{N.stopPropagation(),N.preventDefault(),f(`/link/ai-flow/edit?id=${F}`,!0)},[f]),D=y.useCallback(()=>{const F=[];return i||F.push({type:"flow",message:"请选择子流程"}),g!=null&&g.params&&Object.keys(g.params).forEach(N=>{var I;const P=(I=t==null?void 0:t.input)==null?void 0:I[N];(P==null||P==="")&&F.push({type:"param",paramKey:N,message:`参数 "${N}" 不能为空`})}),u(F),F.length===0},[i,g,t==null?void 0:t.input]),E=y.useCallback(()=>{u([])},[]);y.useImperativeHandle(o,()=>({validate:D,clearErrors:E}),[D,E]);const O=()=>{var F;return(F=c.find(N=>N.type==="flow"))==null?void 0:F.message},A=F=>{var N;return(N=c.find(P=>P.type==="param"&&P.paramKey===F))==null?void 0:N.message},T=F=>h.jsxs("div",{className:kt["configSubflow-optionContent"],children:[h.jsx("span",{className:kt["configSubflow-optionName"],children:F.name}),h.jsx(_.Tooltip,{title:"在新标签页中打开子流程",children:h.jsx("button",{type:"button",className:kt["configSubflow-optionLink"],"aria-label":`在新标签页打开子流程:${F.name}`,onClick:N=>x(F.id,N),children:h.jsx(ie.ExportOutlined,{})})})]}),B=()=>i?b?h.jsxs("div",{className:kt["configSubflow-loading"],children:[h.jsx(_.Spin,{size:"small"}),h.jsx("span",{style:{marginLeft:8},children:"加载中..."})]}):mZ(g)?h.jsx("div",{className:kt["configSubflow-paramsList"],children:a.map(F=>{const N=A(F.key);return h.jsxs("div",{className:`${kt["configSubflow-paramItem"]} workflow-config-subflow__param ${N?kt.hasError:""}`,children:[h.jsx("div",{className:kt["configSubflow-paramKey"],children:h.jsx(_.Tooltip,{title:`示例值: ${F.exampleValue}`,children:h.jsx("div",{className:kt["configSubflow-paramKeyLabel"],children:F.key})})}),h.jsxs("div",{className:kt["configSubflow-paramValue"],children:[h.jsx(In,{value:F.value,onChange:P=>k(F.key,P),placeholder:`示例: ${F.exampleValue}`,disabled:p,borrow:!0,nodeId:r,valueType:"ADAPTOR"}),N&&h.jsx("div",{className:kt["configSubflow-errorText"],children:N})]})]},F.id)})}):h.jsxs("div",{className:`${kt["configSubflow-hintMessage"]} ${kt.info}`,children:[h.jsx(ie.InfoCircleOutlined,{}),h.jsx("span",{children:"该流程无需进行参数配置"})]}):h.jsxs("div",{className:`${kt["configSubflow-hintMessage"]} ${kt.warning}`,children:[h.jsx(ie.InfoCircleOutlined,{}),h.jsx("span",{children:"请先选择子流程"})]}),M=O();return h.jsxs("div",{className:kt["configSubflow-container"],children:[h.jsxs("div",{className:kt["configSubflow-selectSection"],children:[h.jsx("div",{className:kt["configSubflow-selectWrapper"],children:h.jsx(_.Select,{className:kt["configSubflow-select"],value:i,onChange:S,placeholder:"请选择子流程",disabled:p,loading:b,showSearch:!0,filterOption:!1,onSearch:v,notFoundContent:b?h.jsx(_.Spin,{size:"small"}):"暂无数据",allowClear:!0,status:M?"error":void 0,options:w.map(F=>({value:F.id,label:T(F)}))})}),M&&h.jsx("div",{className:kt["configSubflow-errorText"],children:M})]}),h.jsxs("div",{className:kt["configSubflow-paramsSection"],children:[h.jsxs("div",{className:kt["configSubflow-paramsTitle"],children:[h.jsx(ie.SettingOutlined,{}),h.jsx("span",{children:"参数配置"})]}),B()]})]})});GN.displayName="ConfigSubflow";function gZ(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return y.useMemo(()=>r=>{e.forEach(o=>o(r))},e)}const cf=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Ls(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function Ub(t){return"nodeType"in t}function _n(t){var e,n;return t?Ls(t)?t:Ub(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function qb(t){const{Document:e}=_n(t);return t instanceof e}function Ml(t){return Ls(t)?!1:t instanceof _n(t).HTMLElement}function RN(t){return t instanceof _n(t).SVGElement}function $s(t){return t?Ls(t)?t.document:Ub(t)?qb(t)?t:Ml(t)||RN(t)?t.ownerDocument:document:document:document}const Vr=cf?y.useLayoutEffect:y.useEffect;function Gb(t){const e=y.useRef(t);return Vr(()=>{e.current=t}),y.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e.current==null?void 0:e.current(...r)},[])}function wZ(){const t=y.useRef(null),e=y.useCallback((r,o)=>{t.current=setInterval(r,o)},[]),n=y.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function Il(t,e){e===void 0&&(e=[t]);const n=y.useRef(t);return Vr(()=>{n.current!==t&&(n.current=t)},e),n}function Pl(t,e){const n=y.useRef();return y.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function uf(t){const e=Gb(t),n=y.useRef(null),r=y.useCallback(o=>{o!==n.current&&(e==null||e(o,n.current)),n.current=o},[]);return[n,r]}function Rb(t){const e=y.useRef();return y.useEffect(()=>{e.current=t},[t]),e.current}let Kb={};function Ll(t,e){return y.useMemo(()=>{if(e)return e;const n=Kb[t]==null?0:Kb[t]+1;return Kb[t]=n,t+"-"+n},[t,e])}function KN(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,s)=>{const a=Object.entries(s);for(const[l,c]of a){const u=i[l];u!=null&&(i[l]=u+t*c)}return i},{...e})}}const zs=KN(1),$l=KN(-1);function bZ(t){return"clientX"in t&&"clientY"in t}function Yb(t){if(!t)return!1;const{KeyboardEvent:e}=_n(t.target);return e&&t instanceof e}function vZ(t){if(!t)return!1;const{TouchEvent:e}=_n(t.target);return e&&t instanceof e}function Xb(t){if(vZ(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:n}=t.touches[0];return{x:e,y:n}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:n}=t.changedTouches[0];return{x:e,y:n}}}return bZ(t)?{x:t.clientX,y:t.clientY}:null}const zl=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[zl.Translate.toString(t),zl.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),YN="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function yZ(t){return t.matches(YN)?t:t.querySelector(YN)}const CZ={display:"none"};function kZ(t){let{id:e,value:n}=t;return y.createElement("div",{id:e,style:CZ},n)}function SZ(t){let{id:e,announcement:n,ariaLiveType:r="assertive"}=t;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return y.createElement("div",{id:e,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function EZ(){const[t,e]=y.useState("");return{announce:y.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const XN=y.createContext(null);function xZ(t){const e=y.useContext(XN);y.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function DZ(){const[t]=y.useState(()=>new Set),e=y.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[y.useCallback(r=>{let{type:o,event:i}=r;t.forEach(s=>{var a;return(a=s[o])==null?void 0:a.call(s,i)})},[t]),e]}const _Z={draggable:`
146
146
  To pick up a draggable item, press the space bar.
147
147
  While dragging, use the arrow keys to move the item.
148
148
  Press space again to drop the item in its new position, or press escape to cancel.