@digitalsee-ai/rcs 2.0.0-pre2 → 2.0.0-pre3
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.es.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { A as s, a as o, b as l, N as i, c as r, g as t, h as n, j as d, k as u, l as F, m as c, n as y, E as g, F as S, o as m, H as p, p as C, q as V, r as f, s as w, u as A, v as b, w as R, x as v, W as T, y as W, z as P, B as k, C as D, G as I, I as M, J as N, K as h, L as E, M as L, O, P as _, Q as x, R as B, S as G, T as U, U as j, X as q, Y as H, Z as Y, _ as z, $ as J, a0 as K, a1 as Q, a2 as X, a3 as Z, a4 as $, a5 as aa, a6 as ea, a7 as sa, a8 as oa, a9 as la, aa as ia, ab as ra, ac as ta, ad as na, ae as da, af as ua, ag as Fa, ah as ca, ai as ya } from "./index-
|
|
1
|
+
import { A as s, a as o, b as l, N as i, c as r, g as t, h as n, j as d, k as u, l as F, m as c, n as y, E as g, F as S, o as m, H as p, p as C, q as V, r as f, s as w, u as A, v as b, w as R, x as v, W as T, y as W, z as P, B as k, C as D, G as I, I as M, J as N, K as h, L as E, M as L, O, P as _, Q as x, R as B, S as G, T as U, U as j, X as q, Y as H, Z as Y, _ as z, $ as J, a0 as K, a1 as Q, a2 as X, a3 as Z, a4 as $, a5 as aa, a6 as ea, a7 as sa, a8 as oa, a9 as la, aa as ia, ab as ra, ac as ta, ad as na, ae as da, af as ua, ag as Fa, ah as ca, ai as ya } from "./index-DO2xJ071.mjs";
|
|
2
2
|
export {
|
|
3
3
|
s as AIFieldWrapper,
|
|
4
4
|
o as AI_FILL_VALUE,
|
package/dist/rcs.umd.js
CHANGED
|
@@ -114,7 +114,7 @@ The error may be correlated with this previous error:
|
|
|
114
114
|
0% { box-shadow: 0 0 0 0 rgba(0, 212, 255, 0.6); }
|
|
115
115
|
100% { box-shadow: 0 0 0 6px rgba(0, 212, 255, 0); }
|
|
116
116
|
}
|
|
117
|
-
`})]}):y.isValidElement(t)?y.cloneElement(t,{value:e,onChange:n,...t.props}):t;return h.jsxs(h.Fragment,{children:[!r&&h.jsx("div",{style:{marginBottom:6,textAlign:"right"},children:h.jsxs(D.Button,{size:"small",type:"primary",onClick:i,style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",border:"none",borderRadius:"14px",padding:"0 10px",height:"24px",fontSize:"11px",fontWeight:"500",boxShadow:"0 2px 8px rgba(102, 126, 234, 0.3)",transition:"all 0.2s ease",display:"flex",alignItems:"center",gap:"4px",lineHeight:1},onMouseEnter:a=>{a.currentTarget.style.transform="translateY(-1px)",a.currentTarget.style.boxShadow="0 4px 12px rgba(102, 126, 234, 0.5)"},onMouseLeave:a=>{a.currentTarget.style.transform="translateY(0)",a.currentTarget.style.boxShadow="0 2px 8px rgba(102, 126, 234, 0.3)"},children:[h.jsx(se.RobotOutlined,{style:{fontSize:"11px"}}),"由AI生成"]})}),s()]})},eG=t=>{var n;const e=In();return h.jsx(D.Select,{id:e,style:{borderRadius:6},...t,getPopupContainer:r=>r.parentNode,children:(n=t==null?void 0:t.options)==null?void 0:n.map(r=>h.jsx(D.Select.Option,{label:r.label,value:r.value,children:r.label},r.value))})},tG=t=>h.jsx(D.DatePicker,{style:{width:"100%"},picker:"date",value:t.value?jt(t.value):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD")))}}),nG=t=>h.jsx(y.Fragment,{children:h.jsx(D.DatePicker,{style:{width:"100%"},picker:"date",showTime:!0,value:t.value?jt(t.value):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD hh:mm:ss")))}})}),rG=({value:t=[],onChange:e,selectType:n="KNOWLEDGE_BASE",placeholder:r="请选择"})=>{const o=Et.useReactive({items:[]}),[i,s]=y.useState([]),[a,l]=y.useState(!1);y.useEffect(()=>{n&&(l(!0),Uy(n).then(p=>{p&&Array.isArray(p)&&s(p)}).catch(p=>{console.error("获取选项失败:",p),s([])}).finally(()=>{l(!1)}))},[n]),y.useEffect(()=>{const p=Array.isArray(t)?t:[];o.items=p.map(m=>({...m,id:m.id??In()}))},[t]);const c=Ot(),u=p=>{const m=o.items.filter(v=>v.id!==p);e==null||e(m)},d=()=>{e([...o.items,{value:"",id:In()}])},f=(p,m)=>{e(o.items.map((v,b)=>b===p?{...v,value:m}:v))};return h.jsxs("div",{children:[o.items.length?o.items.map((p,m)=>h.jsxs(D.Space,{size:"small",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[h.jsx(D.Select,{value:p.value||void 0,onChange:v=>f(m,v),placeholder:r,style:{width:300},disabled:!c||a,loading:a,options:i,showSearch:!0,filterOption:(v,b)=>((b==null?void 0:b.label)??"").toLowerCase().includes(v.toLowerCase()),getPopupContainer:v=>v.parentNode}),c&&h.jsx(D.Button,{icon:h.jsx(Di,{size:16}),onClick:()=>{u(p.id)}})]},p.id)):null,c&&h.jsx(D.Button,{type:"default",onClick:d,block:!0,icon:h.jsx(br,{size:16}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})})]})},oG=({value:t=[],onChange:e,valueType:n})=>{const r=u=>{let d=[...o.items];d=d.filter(f=>f.id!==u),e==null||e(d)},o=Et.useReactive({items:[]}),i=u=>{const d=u.which||u.keyCode;(d===37||d===229)&&u.preventDefault()};y.useEffect(()=>{const u=Array.isArray(t)?t:[];o.items=u.map(d=>({...d,id:d.id??In()}))},[t]);const s=()=>{e==null||e([...o.items,{key:"",value:"",id:In()}])},a=(u,d)=>{e==null||e(o.items.map(f=>f.id===u?{...f,key:d}:f))},l=(u,d)=>{e==null||e(o.items.map(f=>f.id===u?{...f,value:d}:f))},c=Ot();return h.jsxs("div",{className:"workflow-extend-object",children:[o.items.length?o.items.map((u,d)=>h.jsxs(D.Space,{size:"small",className:"workflow-extend-object__row",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[h.jsx(D.Input,{defaultValue:u.key,onKeyDown:i,onChange:f=>{var p;a(u.id,(p=f.target.value)==null?void 0:p.replace(/'/g,""))},placeholder:"Key"}),h.jsx("span",{className:"workflow-extend-object__value",style:{display:"inline-block",transform:"translateY(2px)",width:300},children:h.jsx(Pn,{borrow:!0,disableIDE:!0,placeholder:"Value",style:{width:300},value:u.value,onChange:f=>l(u.id,f),valueType:n,nodeId:""})}),c&&h.jsx(D.Button,{icon:h.jsx(Di,{size:16}),onClick:()=>{r(u.id)}})]},u.id)):null,h.jsxs(D.Button,{type:"default",onClick:s,block:!0,children:[h.jsx(br,{size:16})," ",h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})]})]})},iG=t=>null,sG=t=>h.jsx(D.TimePicker,{style:{width:"100%"},use12Hours:!1,format:"HH:mm",value:t.value?jt(t.value,"HH:mm"):null,onChange:e=>{const n=jt(e).format("HH:mm:00");t.onChange&&(t==null||t.onChange(n))}}),{Text:aG}=D.Typography,YA=t=>h.jsx("div",{className:"ce-tag_input label-field",children:h.jsx("p",{children:h.jsx(D.Tooltip,{title:t.value,color:"cyan",placement:"topLeft",children:h.jsx(aG,{ellipsis:!0,copyable:{text:t.value},children:t.value})})})}),lG=({value:t=[],onChange:e,...n})=>{const[r,o]=y.useState([]);y.useEffect(()=>{const f=Array.isArray(t)?t:[];o(f.map(p=>({...p,id:p.id??In()})))},[t]);const i=Ot(),s=f=>{const p=r.filter(m=>m.id!==f);o(p),e==null||e(p)},a=()=>{const f={field:"",dataType:"string",desc:"",required:!1,id:In()},p=[...r,f];o(p),e(p)},l=(f,p)=>{const m=r.map(v=>v.id===f?{...v,field:p}:v);o(m),e(m)},c=(f,p)=>{const m=r.map(v=>v.id===f?{...v,dataType:p}:v);o(m),e(m)},u=(f,p)=>{const m=r.map(v=>v.id===f?{...v,desc:p}:v);o(m),e(m)},d=(f,p)=>{const m=r.map(v=>v.id===f?{...v,required:p}:v);o(m),e(m)};return h.jsxs("div",{className:"workflow-multi-row-extract",children:[r.length?r.map(f=>h.jsxs(D.Space,{size:"small",className:"workflow-multi-row-extract__row",style:{display:"flex",marginBottom:8,width:"100%"},align:"start",children:[h.jsx(D.Input,{value:f.field,onChange:p=>l(f.id,p.target.value),placeholder:"字段名称",status:"",style:{width:130},disabled:!i}),h.jsx(D.Select,{value:f.dataType,onChange:p=>c(f.id,p),placeholder:"数据类型",style:{width:100},disabled:!i,options:[{label:"字符串",value:"string"},{label:"数字",value:"number"},{label:"日期",value:"date"},{label:"布尔",value:"boolean"}]}),h.jsx(D.Input,{value:f.desc,onChange:p=>u(f.id,p.target.value),placeholder:"字段描述",status:"",style:{width:200},disabled:!i}),h.jsx(D.Select,{value:f.required,onChange:p=>d(f.id,p),placeholder:"是否必填",style:{width:100},disabled:!i,options:[{label:"是",value:!0},{label:"否",value:!1}]}),i&&h.jsx(D.Button,{icon:h.jsx(Di,{size:16}),onClick:()=>{s(f.id)}})]},f.id)):null,i&&h.jsx(D.Button,{type:"default",onClick:a,block:!0,icon:h.jsx(br,{size:16}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})})]})},cG=t=>{const e=y.useMemo(()=>In(),[]),{event$:n}=y.useContext(Qr),r=Qm(e),[o,i]=y.useState("");n.useSubscription(a=>{var l;if(a.type==="insert"&&a.currentInputId===e){const c=(o??"")+(t.valueType==="FIX_VALUE"?a.expression.slice(2,-2):a.expression);i(c),(l=t.onChange)==null||l.call(t,c)}}),y.useEffect(()=>{i(t.value)},[t.value]);const s=a=>{var l;i(a.target.value),(l=t.onChange)==null||l.call(t,a.target.value)};return h.jsxs(D.Space.Compact,{block:!0,className:`workflow-password-field${r?` ${od}`:""}`,children:[h.jsx("span",{className:"workflow-password-field__prefix",children:K("link.flow.cipherText")}),h.jsx(D.Input.Password,{id:e,onFocus:()=>{(t.valueType==="JS_EXP"||t.valueType==="FIX_VALUE"||t.valueType==="PLAIN_TEXT"||t.valueType==="PLAIN_CODE")&&(n.emit({type:"visible",visible:!0}),n.emit({type:"setCurrentInputId",currentInputId:e}))},value:o,onChange:s})]})},uG=t=>{var o;const e=In(),{multiple:n,...r}=t;return h.jsx(D.Select,{id:e,style:{borderRadius:6},mode:n?"multiple":void 0,...r,getPopupContainer:i=>i.parentNode,children:(o=t==null?void 0:t.options)==null?void 0:o.map(i=>h.jsx(D.Select.Option,{label:i.label,value:i.value,children:i.label},i.value))})},dG=t=>h.jsx(D.TimePicker,{style:{width:"100%"},value:t.value?jt(t.value,"HH:mm:ss"):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("HH:mm:ss")))}}),El=()=>$t().flowId,fG=["sample","test","payload","body"],hG=["测试","样本","sample","test","payload","body"],XA=t=>{var n,r,o;return[xe.JSON,xe.TEXTAREA,xe.FIXED_OBJ].includes(t.page_control)?!0:((o=(r=(n=t.value_type)==null?void 0:n.toLowerCase)==null?void 0:r.call(n))==null?void 0:o.includes("json"))??!1},JA=(t,e)=>{if(!t)return!1;const n=t.toLowerCase();return e.some(r=>n.includes(r))},pG=t=>{if(t==null)return;const e=(t==null?void 0:t.data)!==void 0?t.data:t;if(typeof e=="string")try{const n=JSON.parse(e);return JSON.stringify(n,null,2)}catch{return e}try{return JSON.stringify(e,null,2)}catch{return}},mG=t=>{const{form:e,configList:n=[],disabled:r,...o}=t;a0();const[i,s]=y.useState(!1),[a,l]=y.useState(0),c=y.useRef(void 0),u=El(),d=y.useMemo(()=>{const m=n.find(v=>XA(v)&&(JA(v.name,fG)||JA(v.display_name,hG)));return m||n.find(v=>XA(v))},[n]),f=y.useCallback(()=>{c.current&&(clearInterval(c.current),c.current=void 0)},[]);y.useEffect(()=>()=>{f()},[f]);const p=y.useCallback(async()=>{if(!u){D.message.warning("缺少连接流ID,无法监听Webhook");return}if(!(d!=null&&d.name)){D.message.warning("未找到测试数据字段,无法填充监听结果");return}if(!i){s(!0),l(10),c.current=setInterval(()=>{l(m=>m<=1?(f(),0):m-1)},1e3);try{const m=await Fy(u,{timeout_seconds:10}),v=pG(m);v?(e.setFieldsValue({[d.name]:v}),D.message.success("已捕获Webhook推送数据并填充测试样例")):D.message.info("监听结束,暂无新的推送数据")}catch(m){console.error("监听Webhook失败:",m),D.message.error("监听失败,请稍后重试")}finally{f(),s(!1),l(0)}}},[u,e,i,d==null?void 0:d.name,f]);return h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},className:"web-hook",children:[h.jsx("div",{style:{flex:1},className:"web-hook-input",children:h.jsx(YA,{...o})}),h.jsx(D.Button,{size:"small",type:"primary",ghost:!0,onClick:p,disabled:r||!(d!=null&&d.name),loading:i,style:{height:32,minWidth:110,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:i?`监听中${a?`(${a}s)`:""}`:"监听"})]})},gG={configFormContainer:"_configFormContainer_1frpl_1"};function wG(t){return Lq(t==null?void 0:t.credentials)}const bG=t=>String(t.type).toUpperCase();function QA(t){var e,n;return(n=(e=t==null?void 0:t.input_fields)==null?void 0:e.find(r=>bG(r)==="PROXY"))==null?void 0:n.key}function ZA(t){return t==null||t===""?"0":String(t)}function vG(t,e,n){const r=QA(e);return r?{...t,[r]:ZA(n??t[r])}:t}function yG(t,e){const n=QA(e);if(!n)return{properties:t};const r={...t},o=ZA(r[n]);return delete r[n],{properties:r,proxyId:o}}const eO=({field:t,disabled:e,readOnly:n,context:r,value:o="",onChange:i,id:s,allowVariableInsert:a,hasModeSwitch:l})=>{const c=uC(),u=y.useId(),d=s||`workflow-code-${u}`,f=y.useRef(null),[p,m]=y.useState(0),v=!e&&!n,b=y.useCallback(_=>{var x;if(!a)return;const S=(x=f.current)==null?void 0:x.view,E=S==null?void 0:S.state.selection.main;if(!S||!E){i==null||i(`${o}${_}`);return}S.dispatch({changes:{from:E.from,to:E.to,insert:_},selection:{anchor:E.from+_.length}}),S.focus()},[a,i,o]),w=oC(d,_=>b(_),()=>{var _,S;return(S=(_=f.current)==null?void 0:_.view)==null?void 0:S.focus()}),g=Mh(),C=(g==null?void 0:g.activeFieldId)===d,k=y.useCallback(()=>{if(v)try{i==null||i(JSON.stringify(JSON.parse(o),null,2))}catch{D.message.warning(K("link.flow.format_json_failed"))}},[v,i,o]);return h.jsx(bC,{id:d,canEditInEditor:v,openEditorNumber:p,nodeId:c.nodeId||r.nodeId||"",value:o,language:"json",showVariableSidebar:a,onFinish:i,children:h.jsxs("div",{style:{position:"relative"},className:C?od:void 0,children:[h.jsx(nd,{id:d,ref:f,value:o,readOnly:!v,height:"220px",placeholder:t.placeholder,theme:Cm,extensions:[$A()],onFocus:()=>{v&&a&&w.activate()},onChange:i}),v?h.jsxs(D.Space,{size:4,style:{position:"absolute",right:8,top:6,zIndex:2},children:[h.jsx(D.Tooltip,{title:K("link.flow.format_json"),children:h.jsx(D.Button,{type:"text",size:"small","aria-label":K("link.flow.format_json"),icon:h.jsx(se.FormatPainterOutlined,{}),onClick:k,style:{color:"#fff"}})}),h.jsx(D.Tooltip,{title:K("link.flow.open_code_editor"),children:h.jsx(D.Button,{type:"text",size:"small","aria-label":K("link.flow.open_code_editor"),icon:h.jsx(se.FullscreenOutlined,{}),onClick:()=>m(_=>_+1),style:{color:"#fff"}})})]}):null]})})};eO.displayName="WorkflowCodeEditor";const tO=({field:t,disabled:e,readOnly:n,context:r,value:o,onChange:i,id:s})=>{const a=typeof o=="string"?o:o==null?"":JSON.stringify(o)??"",l=!!t.valueModePolicy,c=t.valueModePolicy==="EXPRESSION"||t.valueModePolicy==="BOTH",u=d=>h.jsx(eO,{...d,field:t,context:r,id:s,allowVariableInsert:c,hasModeSwitch:l});return t.valueModePolicy?h.jsx(ki,{value:a,onChange:d=>i==null?void 0:i(d),valueModePolicy:t.valueModePolicy,disabled:e,readOnly:n,placeholder:t.placeholder,renderNormalMode:u,renderExpressionMode:u,modeSwitchPosition:"top-right",encodeExpressionValue:!0}):u({value:a,onChange:d=>i==null?void 0:i(d),disabled:e,readOnly:n,placeholder:t.placeholder})};tO.displayName="WorkflowCodeFieldControl";const CG=dt(tO,{needsFormItemName:!0,supportsVariableInsert:!0}),nO=({disabled:t,readOnly:e,value:n,onChange:r,id:o})=>{const[i,s]=y.useState([]),[a,l]=y.useState(!1);y.useEffect(()=>{let d=!1;return l(!0),Kf().then(f=>{d||s(Array.isArray(f)?f:[])}).catch(()=>{d||D.message.error(K("link.flow.request_failed"))}).finally(()=>{d||l(!1)}),()=>{d=!0}},[]);const c=y.useMemo(()=>[{value:"0",label:h.jsx(Te.FormattedMessage,{id:"link.flow.do_not_use"})},...i.map(d=>({value:String(d.id),label:d.group_name||String(d.id)}))],[i]),u=n==null||n===""?"0":String(n);return h.jsx(D.Select,{id:o,className:"proxy_id_select",value:u,options:c,loading:a,disabled:t||e,dropdownStyle:{zIndex:99999999999},onChange:d=>r==null?void 0:r(String(d)),style:{width:"100%"}})};nO.displayName="WorkflowProxyFieldControl";const kG=dt(nO,{needsFormItemName:!0,supportsVariableInsert:!0}),SG=[{type:ge.CODE,definition:CG},{type:ge.PROXY,definition:kG}];function EG({children:t}){return h.jsx(fC,{additionalRegistrations:SG,children:t})}function xl(){const{event$:t}=y.useContext(Qr),e=Fh();return y.useCallback(n=>{var o;const r=document.activeElement;if(r&&r!==document.body&&r.contains(n.target)){const i=n.target;if(!["INPUT","TEXTAREA","SELECT"].includes((i==null?void 0:i.tagName)??""))return}(o=t==null?void 0:t.emit)==null||o.call(t,{type:"setCurrentInputId",currentInputId:""}),e==null||e.deactivateField()},[t,e])}const xG=[xe.TEXT,xe.PASSWORD,xe.SELECT,xe.EXTEND_OBJ,xe.DATE,xe.TIME,xe.DATETIME,xe.TEXTAREA,xe.FIXED_OBJ,xe.JSON],DG="[workflow:schema-render]",_G=/^\{\{([^.{}]+)\.(.+)\}\}$/,AG=t=>{switch(t.page_control){case xe.SELECT:case xe.API_SELECT:return t.multi_valued?[]:null;case xe.EXTEND_OBJ:return{};case xe.HIDDEN:return"";case xe.TEXT:return"";case xe.PASSWORD:return"";case xe.LABEL:return"";case xe.DATE:return null;case xe.TIME:return null;case xe.DATETIME:return null;case xe.TEXTAREA:return"";case xe.FIXED_OBJ:return{};case xe.MultiRowAIExtractConfig:return[];case xe.JSON:return""}},rO=(t,e,n,r,o)=>{const i=t.display_name,s=()=>{var a,l,c;switch(t.page_control){case xe.SELECT:return h.jsx(uG,{options:Zg(t.option_value_objects??t.option_values),multiple:t.multi_valued});case xe.API_SELECT:return h.jsx(eG,{options:Zg(t.option_value_objects??t.option_values)});case xe.EXTEND_OBJ:return h.jsx(oG,{valueType:t.value_type});case xe.HIDDEN:return h.jsx(iG,{});case xe.TEXT:return h.jsx(Pn,{valueType:t.value_type,nodeId:e});case xe.PASSWORD:return h.jsx(cG,{valueType:t.value_type});case xe.LABEL:return(a=r==null?void 0:r.webhookField)!=null&&a.enabled&&t.name==="hookUrl"&&r.webhookField.form?h.jsx(mG,{form:r.webhookField.form,configList:r.webhookField.configList,disabled:r.webhookField.disabled}):h.jsx(YA,{});case xe.DATE:return h.jsx(tG,{});case xe.TIME:return h.jsx(dG,{});case xe.DATETIME:return h.jsx(nG,{});case xe.TEXTAREA:return h.jsx(Pn,{valueType:t.value_type,textAreaMode:!0,nodeId:e});case xe.FIXED_OBJ:return h.jsx(D.Input.TextArea,{});case xe.JSON:return h.jsx(Pn,{valueType:t.value_type,nodeId:e});case xe.MultiRowAIExtractConfig:return h.jsx(lG,{valueType:t.value_type});case xe.MULTI_SELECT_LIST:return h.jsx(rG,{selectType:"KNOWLEDGE_BASE"});case xe.SYNC_HOUR_MINUTE:return h.jsx(sG,{});case xe.AUTH_TOKEN:return h.jsx(Rq,{disabled:(l=r==null?void 0:r.webhookField)==null?void 0:l.disabled});case xe.SECRET_KEY:return h.jsx(Yq,{});case xe.SELECT_CLIENT:return h.jsx(Qq,{});default:{const u=(c=o==null?void 0:o.form)==null?void 0:c.find(d=>d.name===t.page_control);return u?h.jsx(u.component,{config:t,configList:r==null?void 0:r.configList,disabled:r==null?void 0:r.disabled,form:r==null?void 0:r.form,mcpMode:n,nodeId:e}):(console.warn(`unknown form item: page_control:${t.page_control}`),null)}}};return n&&xG.includes(t.page_control)?h.jsx("div",{children:h.jsx(D.Form.Item,{required:t.required,rules:[{required:t.required,message:t.page_control===xe.SELECT?K("link.flow.please_select")+t.display_name:K("link.flow.please_enter")+t.display_name}],label:i,name:t.name,children:h.jsx(Zq,{children:s()})})},t.ui_id):h.jsx(D.Form.Item,{required:t.required,style:t.page_control===xe.HIDDEN?{display:"none"}:{},rules:[{required:t.required,message:t.page_control===xe.SELECT?K("link.flow.please_select")+t.display_name:K("link.flow.please_enter")+t.display_name},{validator(a,l,c){if(t.page_control===xe.MultiRowAIExtractConfig)if(Array.isArray(l)&&t.required){const u=l.some(d=>!d.field||!d.dataType||!d.desc||d.required==null);c(u?"请填写完整配置":void 0)}else c(void 0);else c(void 0)}}],label:i,name:t.name,children:s()},t.ui_id)},OG=t=>(t.child_conditions??[]).map(e=>e.left).filter(e=>!!e),TG=(t,e)=>{if(!t.is_child)return!0;const n=t.child_conditions??[];return n.length?n.some(({left:r,operator:o,right:i})=>{const s=e==null?void 0:e[r];return o==="EQUALS"?s===i:s!==i}):!0},NG=y.forwardRef((t,e)=>{var we,fe;const{action:n,connector:r,nodeId:o,account_id:i,mcpMode:s,nodeType:a}=t,l=$t(),c=ne.useStoreApi(),u=xl(),d=Et.useReactive({proxyId:"0"}),{config_schema:f,proxy_id:p,protocol:m,account_schema_id:v}=n;a??n.node_type??n.type;const b=n.action_key||n.nodeKey,w=n.action_ver??n.nodeVersion,g=Array.isArray(f==null?void 0:f.sub_params),C=po(n),k=y.useMemo(()=>!C||!b?null:`${b}@${w??"latest"}`,[C,b,w]),_=k?`${o}:${k}`:o,S=n.account_id??i,E=y.useMemo(()=>k?Wi(b,w):null,[k,b,w]),[x,O]=y.useState(()=>k&&E?{identity:k,schema:E,loading:!1,finished:!0}:null),A=(x==null?void 0:x.identity)===k?x:null,T=(A==null?void 0:A.schema)??null,B=rw((T==null?void 0:T.credentials)??[]),I=!!(C&&b&&!T&&((A==null?void 0:A.loading)??!(A!=null&&A.finished))),F=wG(T);y.useEffect(()=>{!x||x.identity},[k,x,o,b,w]),y.useEffect(()=>{p&&(d.proxyId=p)},[p,d]);const[N]=D.Form.useForm(),[P,M]=y.useState(S);y.useEffect(()=>{M(S)},[_,S,M]);const z=y.useMemo(()=>{var le;return g?(le=f.sub_params)==null?void 0:le.reduce((Se,ce)=>{let Fe=ce.value;return ce.page_control===xe.EXTEND_OBJ&&(Fe=_q(Fe)),Se[ce.name]=Fe??AG(ce),Se},{}):{}},[f==null?void 0:f.sub_params,g]);y.useEffect(()=>{g&&(N.resetFields(),N.setFieldsValue({...z}))},[z,N,g,o]);const H=y.useRef(null),R=y.useRef(null);y.useEffect(()=>{if(!k||!b){O(null);return}const le=Wi(b,w);if(le){O({identity:k,schema:le,loading:!1,finished:!0});return}let Se=!1;return O({identity:k,schema:null,loading:!0,finished:!1}),pc(b,w).then(ce=>{Se||O({identity:k,schema:ce,loading:!1,finished:!0})}).catch(ce=>{Se||(O({identity:k,schema:null,loading:!1,finished:!0}),console.error(`${DG} classic renderer next schema load failed`,{nodeId:o,nodeKey:b,nodeVersion:w,err:ce}))}),()=>{Se=!0}},[k,o,b,w]);const Y=y.useMemo(()=>{var le;return(le=T==null?void 0:T.input_fields)!=null&&le.length?KI(WA(T.input_fields),T.key):null},[T]),te=!!(C&&(Y||F||T)),$=y.useMemo(()=>{const le=n.properties?ha(n.properties):f&&C?ha(f):n.params?ha(n.params):{},Se=vG(le,T,p);return uc(b)?ra(Se).properties:Se},[n,f,C,T,b,p]),j=y.useMemo(()=>JSON.stringify($??{}),[$]);y.useEffect(()=>{!C||!te||(N.resetFields(),N.setFieldsValue($))},[_,N,C,$,j,te]);const U=y.useRef(null);y.useEffect(()=>{U.current=null},[_]),y.useEffect(()=>{uc(b)&&(U.current=JSON.stringify(ra($).branches.map(le=>[le.id,le.name])))},[$,b]);const ee=y.useCallback(le=>{const Se=le.trim().match(_G);if(!Se)return null;const ce=Se[1],Fe=Se[2];if(ce==="global")return null;const Ve=ce.startsWith("N")?ce.slice(1):ce,je=c.getState().nodes.find(We=>We.id===Ve);return je?{fieldPath:Fe,node:je,variableNodeId:ce}:null},[c]),ie=y.useCallback(le=>{var Se;return((Se=ee(le))==null?void 0:Se.fieldPath)??le.replace(/^\{\{|\}\}$/g,"")},[ee]),be=y.useCallback(le=>{var je;const Se=ee(le);if(!Se)return le;const ce=(je=Se.node)==null?void 0:je.data,Fe=(ce==null?void 0:ce.label)||(ce==null?void 0:ce.name)||(ce==null?void 0:ce.action_name)||Se.variableNodeId,Ve=ce!=null&&ce.note?` (${ce.note})`:"";return`${Fe}${Ve}.${Se.fieldPath}`},[ee]),[W,X]=y.useState(!1),q=(le,Se)=>(X(!0),N.validateFields().then(async ce=>{var Ve,je,We,ht,Ee;if(te){Se&&((je=(Ve=H==null?void 0:H.current)==null?void 0:Ve.onIgnoreNodeStart)==null||je.call(Ve));const{properties:Ce,proxyId:Le}=yG(ce,T);return t.onSubmit({properties:Ce,account_id:P,proxy_id:Le},le)}const Fe=Pt.cloneDeep(n.config_schema);return Fe.sub_params.forEach(Ce=>{let Le=ce[Ce.name];Ce.page_control===xe.EXTEND_OBJ&&Le!=="{{$fromAI}}"&&(Le=ew(Le)),Ce.value=Le??null}),Se&&((ht=(We=H==null?void 0:H.current)==null?void 0:We.onIgnoreNodeStart)==null||ht.call(We)),!i&&m==="HTTP"&&(r==null?void 0:r.deployment_type)!=="SaasApp"&&(Fe.proxy_id=(Ee=R.current)==null?void 0:Ee.getProxyId()),t.onSubmit(Fe,le)}).catch(ce=>(console.log("err",ce),D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>X(!1)));y.useImperativeHandle(e,()=>({saveConfig:le=>q(le,!1)}));const J=Ot(),re={form:N,configList:(f==null?void 0:f.sub_params)??[],disabled:!J,...m==="WEBHOOK"?{webhookField:{enabled:!0,form:N,configList:(f==null?void 0:f.sub_params)??[],disabled:!J}}:{}},Z=le=>{const Se=le.page_control!==xe.HIDDEN?h.jsx("p",{className:"field-desc",children:le.description}):null;if(!le.is_child)return h.jsxs("div",{children:[rO(le,o,s,re,l.canvas.registerComponents),Se]},le.ui_id);const ce=OG(le);return h.jsx(D.Form.Item,{noStyle:!0,shouldUpdate:(Fe={},Ve={})=>le.is_child?ce.length?ce.some(je=>(Fe==null?void 0:Fe[je])!==(Ve==null?void 0:Ve[je])):!0:!1,children:()=>{const Fe=N.getFieldsValue(!0);return TG(le,Fe)?h.jsxs("div",{children:[rO(le,o,s,re,l.canvas.registerComponents),Se]}):null}},le.ui_id)};if(C&&I)return h.jsx("div",{style:{textAlign:"center",padding:40},children:h.jsx(D.Spin,{})});const ue=!t.preRender&&(((we=n.config_schema)==null?void 0:we.sub_params)??[]).length<1,ve=h.jsx("div",{style:{padding:16,color:"#999",textAlign:"center"},children:"该节点暂无配置项"});if(te){const le=h.jsxs(h.Fragment,{children:[t.preRender&&t.preRender,F?h.jsx(RA,{credentialRequirements:B,value:P,onChange:M,linkApp:r,disabled:!J}):null]});return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:u,children:[h.jsx("div",{className:"workflow-node-form-scroll",children:Y?h.jsx(EG,{children:h.jsx(Xg,{schema:Y,form:N,initialValues:$,showSubmit:!1,showReset:!1,nodeId:o,mcpMode:s,renderVariableTag:ie,renderVariableTooltip:be,customTheme:sc,preRender:le},_)}):ve}),h.jsx("div",{className:"workflow-node-form-footer",children:J&&h.jsx(D.Button,{type:"primary",disabled:!J,loading:W,className:"workflow-node-form-save",onClick:()=>q(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:u,children:[h.jsxs(D.Form,{form:N,disabled:!J,layout:"vertical",className:`${gG.configFormContainer} workflow-config-form workflow-node-form-scroll`,children:[t.preRender&&t.preRender,(r==null?void 0:r.id)&&n.config_schema&&((fe=f==null?void 0:f.sub_params)==null?void 0:fe.map(le=>Z(le))),!i&&m==="HTTP"&&(r==null?void 0:r.deployment_type)!=="SaasApp"?h.jsx(Jg,{proxyId:d.proxyId,ref:R}):null,ue&&ve]}),h.jsx("div",{className:"workflow-node-form-footer",children:J&&h.jsx(D.Button,{type:"primary",disabled:!J,loading:W,className:"workflow-node-form-save",onClick:()=>q(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),BG=y.memo(y.forwardRef((t,e)=>{const{nodeId:n,data:r}=t,{account_id:o,account_schema_id:i}=r,s=Et.useReactive({account_id:o}),a=y.useRef(null);y.useImperativeHandle(e,()=>({saveConfig:p=>{var m;return(m=a.current)==null?void 0:m.saveConfig(p)}}));const l=y.useMemo(()=>({id:t.data.connector_id,name:t.data.connector_name,deployment_type:t.data.deployment_type}),[t.data.connector_id,t.data.connector_name,t.data.deployment_type]),c=po(t.data),u=(p,m)=>{if(c){const v=ha(p),w=Object.hasOwn(p??{},"account_id")?p.account_id??null:s.account_id;return t.onSubmit({properties:v,account_id:w,proxy_id:(p==null?void 0:p.proxy_id)??(v==null?void 0:v.proxy_id)},m)}return t.onSubmit({properties:p,account_id:s.account_id,proxy_id:p.proxy_id},m)},d=y.useCallback(p=>{s.account_id=p??null},[]);let f=null;return i&&!c&&(f=h.jsx(RA,{onChange:d,actionAccountSchemaId:i,value:s.account_id,linkApp:l})),h.jsx("div",{className:"workflow-action-node-config",children:h.jsx(NG,{ref:a,action:t.data,nodeType:t.nodeType||t.data.node_type||t.data.type,connector:l,account_id:o,nodeId:n,onSubmit:u,onNodePackageValuesChange:t.onNodePackageValuesChange,preRender:f})})}),(t,e)=>t.nodeId===e.nodeId&&t.nodeType===e.nodeType&&Pt.isEqual(Pt.omit(t.data,["isHovered"]),Pt.omit(e.data,["isHovered"])));var $n=(t=>(t.IDLE="idle",t.SAVING="saving",t.SAVED="saved",t.ERROR="error",t))($n||{}),Wd=(t=>(t.SELECTION="selection",t.ALL="all",t))(Wd||{}),er=(t=>(t.UNPUBLISHED="UNPUBLISHED",t.ONLINE="ONLINE",t.OFFLINE="OFFLINE",t.ON_WARN="ON_WARN",t.OFF_WARN="OFF_WARN",t.ONLINE_ING="ONLINE_ING",t))(er||{}),nt=(t=>(t.eq="eq",t.ne="ne",t.sw="sw",t.nsw="nsw",t.ew="ew",t.ewn="ewn",t.gt="gt",t.ge="ge",t.lt="lt",t.le="le",t.co="co",t.nco="nco",t.in="in",t.nin="nin",t.is_null="is_null",t.is_not_null="is_not_null",t))(nt||{});const oO=[{operator:nt.eq,label:K("common.eq")},{operator:nt.ne,label:K("common.ne")},{operator:nt.sw,label:K("common.sw")},{operator:nt.nsw,label:K("common.nsw")},{operator:nt.ew,label:K("common.ew")},{operator:nt.ewn,label:K("common.ewn")},{operator:nt.gt,label:K("common.gt")},{operator:nt.ge,label:K("common.ge")},{operator:nt.lt,label:K("common.lt")},{operator:nt.le,label:K("common.le")},{operator:nt.co,label:K("common.co")},{operator:nt.nco,label:K("common.nco")},{operator:nt.in,label:K("common.in")},{operator:nt.nin,label:K("common.nin")},{operator:nt.is_null,label:K("common.is_null")},{operator:nt.is_not_null,label:K("common.is_not_null")}];nt.eq+"",K("common.eq"),nt.ne+"",K("common.ne"),nt.sw+"",K("common.sw"),nt.nsw+"",K("common.nsw"),nt.ew+"",K("common.ew"),nt.ewn+"",K("common.ewn"),nt.gt+"",K("common.gt"),nt.lt+"",K("common.lt"),nt.ge+"",K("common.ge"),nt.co+"",K("common.co"),nt.nco+"",K("common.nco"),nt.le+"",K("common.le"),nt.in+"",K("common.in"),nt.nin+"",K("common.nin"),nt.is_null+"",K("common.is_null"),nt.is_not_null+"",K("common.is_not_null");const iw=t=>t===nt.is_null||t===nt.is_not_null,FG=(t,e="")=>iw(t)?"":e,{Option:MG}=D.Select,IG=y.forwardRef((t,e)=>{const{config_schema:n}=t,[r]=D.Form.useForm(),o=xl(),s=(d=>d!=null&&d.or_list?{or_list:d.or_list.map(p=>({and_list:p.and_list.map(m=>({query:m.query||"",operator:m.operator||"",value:m.value||""}))}))}:{or_list:[{and_list:[{query:"",operator:"",value:""}]}]})(n),[a,l]=y.useState(!1),c=(d,f,p="")=>(l(!0),r.validateFields().then(async m=>t.onSubmit({properties:m},d)).catch(()=>(D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>l(!1)));y.useImperativeHandle(e,()=>({saveConfig:d=>c(d)}));const u=Ot();return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:o,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsx(D.Form,{disabled:!u,form:r,initialValues:s,layout:"vertical",autoComplete:"off",children:h.jsx(D.Form.List,{name:"or_list",children:(d,{add:f,remove:p})=>h.jsxs(h.Fragment,{children:[d.map((m,v)=>h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"form-block",children:h.jsxs("div",{style:{padding:12,width:"100%",boxSizing:"border-box"},children:[v>0&&u&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsx(D.Button,{type:"link",style:{color:"red"},icon:h.jsx(se.MinusCircleOutlined,{style:{color:"red"}}),onClick:()=>p(m.name),children:h.jsx(Te.FormattedMessage,{id:"link.flow.remove"})})}),h.jsx(D.Form.List,{name:[m.name,"and_list"],children:(b,{add:w,remove:g})=>h.jsx(h.Fragment,{children:b.map((C,k)=>h.jsxs(D.Space,{direction:"vertical",style:{width:"100%",rowGap:0},children:[h.jsxs(D.Space,{align:"center",className:`form-item-row ${k>0?"opt":""}`,children:[h.jsx(D.Form.Item,{style:{minWidth:150},name:[C.name,"query"],label:K("app.common.word.variable-name"),rules:[{required:!0,message:K("link.flow.please_enter_variable_name")}],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),h.jsx(D.Form.Item,{name:[C.name,"operator"],label:K("app.common.word.condition"),rules:[{required:!0,message:K("link.flow.please_select_condition")}],children:h.jsx(D.Select,{style:{minWidth:140},placeholder:K("link.flow.select_condition"),getPopupContainer:_=>_.parentNode,children:oO.map(_=>h.jsx(MG,{value:_.operator,children:_.label},_.operator))})}),h.jsx(D.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const _=r.getFieldValue(["or_list",m.name,"and_list",C.name,"operator"]);return iw(_)?null:h.jsx(D.Form.Item,{style:{minWidth:150},name:[C.name,"value"],label:K("app.common.word.value"),rules:[],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),k>0&&h.jsx(D.Button,{type:"link",icon:h.jsx(se.MinusCircleOutlined,{}),onClick:()=>g(C.name)})]}),k<b.length-1&&h.jsx(D.Divider,{plain:!0,children:h.jsx(D.Tag,{color:"#999999",children:h.jsx(Te.FormattedMessage,{id:"link.flow.and"})})}),k===b.length-1&&h.jsx(D.Button,{type:"link",disabled:!u,icon:h.jsx(br,{size:16}),className:"small",onClick:()=>w({query:"",operator:"",value:""}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-new-and"})})]},C.key))})})]})},m.key),v<d.length-1&&h.jsxs("div",{className:"test",style:{textAlign:"center"},children:[" ",h.jsx(D.Divider,{style:{color:"orange"},dashed:!0,children:h.jsx(D.Tag,{color:"#1890ff",children:h.jsx(Te.FormattedMessage,{id:"link.flow.or"})})})]})]})),h.jsx(D.Form.Item,{style:{display:"flex",justifyContent:"flex-end",marginBlock:10},children:h.jsx(D.Button,{type:"default",icon:h.jsx(br,{size:16}),disabled:!u,onClick:()=>f({and_list:[{query:"",operator:"",value:""}]}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-or"})})})]})})})}),h.jsx("div",{className:"workflow-node-form-footer",children:u&&h.jsx(D.Button,{type:"primary",disabled:!u,loading:a,className:"workflow-node-form-save",onClick:()=>c(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),PG={copy:"Copy JSON",copySuccess:"JSON copied to clipboard",download:"Download JSON",invalidJson:"Invalid JSON data"},LG={copy:"复制JSON",copySuccess:"JSON已复制到剪贴板",download:"下载JSON",invalidJson:"无效的JSON数据"},{Text:$G}=D.Typography,zG=({data:t,height:e=400,enableCopy:n=!0,theme:r="light",className:o="",locale:i="zh",maxHeight:s})=>{const[a,l]=y.useState(r),c=y.useRef(null),u=i==="zh"?LG:PG,d=y.useMemo(()=>{if(!t)return null;try{return typeof t=="string"?JSON.parse(t):t}catch(w){return console.error("JSON解析失败:",w),null}},[t]),f=y.useMemo(()=>{if(!d)return[];const w=(g,C=[],k=0)=>{const _=[];if(g===null)return[{key:C.join("."),value:null,type:"null",path:C,level:k}];if(Array.isArray(g)){const S={key:C.join("."),value:g,type:"array",path:C,level:k,children:[]};g.forEach((E,x)=>{var T;const O=[...C,x.toString()],A=w(E,O,k+1);(T=S.children)==null||T.push(...A)}),_.push(S)}else if(typeof g=="object"){const S={key:C.join("."),value:g,type:"object",path:C,level:k,children:[]};Object.entries(g).forEach(([E,x])=>{var T;const O=[...C,E],A=w(x,O,k+1);(T=S.children)==null||T.push(...A)}),_.push(S)}else{const S=typeof g;_.push({key:C.join("."),value:g,type:S,path:C,level:k})}return _};return w(d)},[d]),p=y.useCallback(()=>{const w=JSON.stringify(d,null,2);navigator.clipboard.writeText(w).then(()=>{D.message.success(u.copySuccess)})},[d,u]),m=y.useCallback(()=>{const w=JSON.stringify(d,null,2),g=new Blob([w],{type:"application/json"}),C=URL.createObjectURL(g),k=document.createElement("a");k.href=C,k.download="data.json",k.click(),URL.revokeObjectURL(C)},[d]),v=y.useCallback(w=>{switch(w.type){case"string":return h.jsxs("span",{className:"json-string",children:['"',String(w.value),'"']});case"number":return h.jsx("span",{className:"json-number",children:String(w.value)});case"boolean":return h.jsx("span",{className:"json-boolean",children:String(w.value)});case"null":return h.jsx("span",{className:"json-null",children:"null"});default:return null}},[]),b=y.useCallback((w,g)=>{var _;const C=w.children&&w.children.length>0,k=w.path[w.path.length-1];return w.type==="object"||w.type==="array"?h.jsxs("div",{className:"json-node",children:[h.jsxs("div",{className:"json-line",style:{paddingLeft:`${w.level*16}px`},children:[k&&h.jsxs("span",{className:"json-key",children:['"',k,'": ']}),h.jsx("span",{className:"json-bracket",children:w.type==="array"?"[":"{"}),!C&&h.jsx("span",{className:"json-bracket",children:w.type==="array"?"]":"}"})]}),C&&h.jsxs(h.Fragment,{children:[(_=w.children)==null?void 0:_.map((S,E)=>b(S,g+E+1)),h.jsx("div",{className:"json-line",style:{paddingLeft:`${w.level*16}px`},children:h.jsx("span",{className:"json-bracket",children:w.type==="array"?"]":"}"})})]})]},w.key):h.jsx("div",{className:"json-node",children:h.jsxs("div",{className:"json-line",style:{paddingLeft:`${w.level*16}px`},children:[k&&h.jsxs("span",{className:"json-key",children:['"',k,'": ']}),v(w)]})},w.key)},[v]);return y.useCallback(()=>{l(a==="dark"?"light":"dark")},[a]),d?h.jsxs("div",{className:`json-renderer ${a} ${o}`,children:[h.jsx("div",{className:"json-toolbar",children:h.jsxs(D.Space,{children:[n&&h.jsx(D.Tooltip,{title:u.copy,children:h.jsx(D.Button,{icon:h.jsx(se.CopyOutlined,{}),size:"small",onClick:p})}),h.jsx(D.Tooltip,{title:u.download,children:h.jsx(D.Button,{icon:h.jsx(se.DownloadOutlined,{}),size:"small",onClick:m})})]})}),h.jsx("div",{ref:c,className:"json-content",style:{height:`${e}px`,maxHeight:s?`${s}px`:void 0},children:f.map((w,g)=>b(w,g))})]}):h.jsx("div",{className:`json-renderer error ${a} ${o}`,children:h.jsx("div",{className:"error-message",children:h.jsx($G,{type:"secondary",children:u.invalidJson})})})},{TextArea:HG}=D.Input,{Title:VG}=D.Typography,iO=({status:t,result:e="",progress:n=60,runningAction:r="run",showAlert:o=!0,canEdit:i=!0,disabledReason:s="当前节点不支持手动测试",editing:a=!1,editableValue:l="",onEditableValueChange:c,onRun:u,onIgnore:d,onReset:f,onToggleEdit:p,onDismissAlert:m,className:v,onClose:b,onExpandPanel:w})=>{const g=t==="running",C=t==="failure",k=t==="ignored",_=t==="success"||k,S=t==="disabled",[E,x]=y.useState(!1);return h.jsxs("section",{className:["node-test-container","ai-flow-node-test-panel",v].filter(Boolean).join(" "),"aria-label":"AI FLOW 节点测试",children:[h.jsx("div",{className:"node-test-header",children:h.jsxs("div",{className:"header-title",children:[h.jsx("span",{className:"common-icon title-icon"}),h.jsx(VG,{level:4,children:"节点测试"}),h.jsx(D.Button,{ghost:!0,className:"close-btn",onClick:b,children:h.jsx(Di,{size:16})})]})}),h.jsxs("div",{className:"test-content",children:[i&&!S?h.jsxs("div",{className:"action-buttons",children:[h.jsx(D.Button,{type:"primary",disabled:S,onClick:u,loading:g&&r==="run",className:"test-button",children:g?"测试中...":"开始测试"}),h.jsx(D.Button,{type:"default",disabled:S||g&&r==="run",onClick:d,loading:g&&r==="ignore",className:"ignore-button",children:"忽略调试"})]}):null,i&&e?h.jsx("div",{className:"action-buttons",children:h.jsx(D.Button,{onClick:f,className:"reset-button",children:"重置"})}):null,g?h.jsxs(h.Fragment,{children:[h.jsx(D.Progress,{percent:n,status:"active",className:"test-progress"}),h.jsx(D.Skeleton,{active:!0,className:"result-skeleton"})]}):h.jsxs(h.Fragment,{children:[C&&o?h.jsx(D.Alert,{className:"error-alert small",showIcon:!0,message:"测试未通过",description:"请检查节点配置和接口返回后重试",type:"error",closable:!1,onClose:m}):null,_&&o?h.jsx(D.Alert,{className:"success-alert small",showIcon:!0,message:k?"忽略调试成功":"测试成功",description:k?"已将样本数据设为当前节点输出":"节点运行正常,可在下方查看返回结果",type:"success",closable:!1,onClose:m}):null,e?h.jsx(D.Card,{styles:{body:{padding:0}},title:h.jsxs("div",{className:"result-header",children:[h.jsx("div",{className:"result-title",children:C?h.jsxs(h.Fragment,{children:[h.jsx(se.CloseCircleFilled,{className:"error-icon"})," 错误数据"]}):h.jsxs(h.Fragment,{children:[k?h.jsx(se.ExperimentFilled,{className:"success-icon"}):h.jsx(se.CheckCircleFilled,{className:"success-icon"}),k?"样本数据":"测试结果"]})}),h.jsxs("div",{style:{display:"inline-flex",gap:8},children:[i&&p?h.jsx(D.Button,{size:"small",type:"default",variant:"solid",onClick:p,className:"edit-button",children:a?"完成":"编辑"}):null,w&&h.jsx(D.Button,{size:"small",type:E?"primary":"default",variant:"solid",className:"edit-button",onClick:()=>{const O=!E;w(O),x(O)},children:E?h.jsx(SW,{size:16}):h.jsx(kW,{size:16})})]})]}),variant:"borderless",className:`result-card ${C?"error-result":"success-result"}`,children:a?h.jsx(HG,{rows:E?20:10,value:l,onChange:O=>c==null?void 0:c(O.target.value),className:"result-editor"}):h.jsx(zG,{data:e,height:E?600:300,enableCopy:!0,theme:"dark"},e)}):h.jsx(D.Card,{variant:"borderless",className:"empty-result",children:h.jsx(D.Result,{icon:h.jsx("span",{className:"common-icon"}),title:S?"不可测试":"等待测试",subTitle:S?s:"点击“开始测试”按钮运行当前节点"})})]})]})]})},jG=new Set([$e.AI_LANGUAGE_MODEL,$e.AI_MEMORY,$e.BUILTIN_MCP,$e.MCP_SERVER]),WG=new Set([]),UG=({canEdit:t,nodeType:e,protocol:n})=>t?n&&jG.has(n)?{disabled:!0,reason:"当前协议节点由所属 AI 或 MCP 运行上下文统一测试"}:e&&WG.has(e)?{disabled:!0,reason:"当前节点类型不支持独立手动测试"}:{disabled:!1}:{disabled:!0,reason:"只读或预览模式下不能执行节点测试"},qG=t=>typeof t=="string"?t.trim().length>0:t!=null,GG=t=>typeof t=="string"&&t.trim().toLowerCase()==="success",RG=t=>{if(!t||typeof t!="object")return!1;const e=t;return e.result===!0?!1:e.result===!1?!0:e.error==="0"&&qG(e.error_description)&&!GG(e.error_description)},KG=t=>RG(t)?me.FAILED:me.SUCCESS,YG=t=>{if(typeof t=="object")return JSON.stringify(t,null,2);if(typeof t=="string")try{const e=JSON.parse(t);return JSON.stringify(e,null,2)}catch{return t}return String(t)};JSON.stringify({result:"示例数据",data:{id:"123",name:"示例"}},null,2);const XG=y.forwardRef((t,e)=>{var O,A,T,B;const{nodeId:n,beforeHook:r,onClose:o,onExpandPanel:i}=t,s=$t(),{handleNodeDataUpdate:a}=Ri(),l=(A=(O=s.nodeConfigPanel)==null?void 0:O.testArea)==null?void 0:A.defaultTestResult,[c,u]=y.useState(()=>{if(l==null)return"";if(typeof l=="string")return l;try{return JSON.stringify(l,null,2)}catch{return String(l)}}),d=ne.useInternalNode(n),f=Et.useReactive({testProgress:0,sampleText:"",isError:!1,showErrorAlert:!1,testing:!1,successShown:!1,sampleMode:!1,sampleSaving:!1,sampleError:"",isIgnoreSuccess:!1,ignoring:!1,editable:!1}),{refreshFlow:p}=ao();(T=d==null?void 0:d.data)==null||T.outputSource,y.useEffect(()=>{if(d!=null&&d.data.output&&(d.data.status===me.SUCCESS||d.data.status===me.RUNNABLE)){const I=typeof d.data.output=="string"?d.data.output:JSON.stringify(d.data.output,null,2);u(I),f.successShown=!0,f.isError=!1,f.showErrorAlert=!1}else if(d!=null&&d.data.output&&d.data.status===me.FAILED){const I=typeof d.data.output=="string"?d.data.output:JSON.stringify(d.data.output,null,2);u(I),f.isError=!0,f.showErrorAlert=!0,f.successShown=!1}},[d,f]);const m=y.useCallback(()=>{if(!n){console.error("节点ID不能为空");return}f.testing=!0,f.testProgress=60,f.successShown=!1,f.isError=!1,f.showErrorAlert=!1,f.sampleMode=!1,By(n).then(I=>{const F=I,N=KG(F),P=N===me.FAILED;f.isError=P,f.successShown=!P,f.showErrorAlert=f.isError;let M="";try{M=YG(F)}catch(z){console.error("格式化测试结果出错:",z),M=`测试结果格式化失败: ${String(z)}`}f.testProgress=100,u(M),a({id:n,data:{status:N,output:M,outputSource:"test"}})}).catch(I=>{var P;console.error("测试失败:",I),f.testProgress=0,f.isError=!0,f.showErrorAlert=!0,f.successShown=!1;let F="测试执行失败";(P=I==null?void 0:I.response)!=null&&P.data?F=JSON.stringify(I.response.data,null,2):I!=null&&I.message&&(F=I.message);const N=JSON.stringify({error:F},null,2);u(N),a({id:n,data:{status:me.FAILED,output:N,outputSource:"test"}})}).finally(()=>{setTimeout(()=>{f.testProgress=0,f.testing=!1},500)})},[a,n,f]),v=()=>{f.testProgress=0,f.testing=!1,f.sampleSaving=!1,f.sampleMode=!1,f.successShown=!0,f.isError=!1,f.showErrorAlert=!1},b=()=>{r&&(f.testing=!0,f.ignoring=!0,f.testProgress=60,r(!0,!0,f.sampleText))},w=()=>{f.sampleSaving=!1,f.ignoring=!1,f.successShown=!0,f.isError=!1,f.showErrorAlert=!1,f.isIgnoreSuccess=!0},g=()=>{f.testProgress=0,f.testing=!1,f.ignoring=!1,f.isIgnoreSuccess=!0};y.useImperativeHandle(e,()=>({onTestNode:m,finishSampleTest:v,abortSampleTest:w,finishNodeTest:g}));const C=()=>{f.sampleMode=!1,r?r(!0):m()},k=()=>{u(""),f.sampleText="",f.sampleMode=!1,f.sampleError="",f.successShown=!1},_=Ot(),S=y.useMemo(()=>{var I;return UG({canEdit:_,nodeType:d==null?void 0:d.type,protocol:(I=d==null?void 0:d.data)==null?void 0:I.protocol})},[_,(B=d==null?void 0:d.data)==null?void 0:B.protocol,d==null?void 0:d.type]),E=S.disabled?"disabled":f.testing?"running":f.isError?"failure":f.successShown?f.isIgnoreSuccess?"ignored":"success":"waiting",x=()=>{if(f.editable){f.editable=!1;try{const I=JSON.parse(f.sampleText),F=JSON.stringify(I,null,2);u(F),a({id:n,data:{output:F}})}catch{u(f.sampleText)}return}f.sampleText=c,f.editable=!0};return h.jsx(iO,{status:E,result:c,progress:f.testProgress||60,runningAction:f.ignoring?"ignore":"run",showAlert:f.isError?f.showErrorAlert:f.successShown,canEdit:_,disabledReason:S.reason,editing:f.editable,editableValue:f.sampleText,onEditableValueChange:I=>{f.sampleText=I},onRun:C,onIgnore:b,onReset:k,onToggleEdit:x,onDismissAlert:()=>{f.showErrorAlert=!1,f.successShown=!1},onClose:o,onExpandPanel:i})});var tr=(t=>(t.Array="ARRAY",t.Boolean="BOOLEAN",t.Null="NULL",t.Number="NUMBER",t.Object="OBJECT",t.String="STRING",t))(tr||{});const sw={ARRAY:"purple",BOOLEAN:"green",NULL:"default",NUMBER:"blue",OBJECT:"cyan",STRING:"orange"},JG={ARRAY:"Arr",BOOLEAN:"Bool",NULL:"Null",NUMBER:"Num",OBJECT:"Obj",STRING:"Str"},aw=(t,e=!1)=>{const n=String(t||"STRING").toUpperCase(),r=JG[n]||n.slice(0,4);return e?`${r}[]`:r},sO=t=>{t!=null&&t.length&&t.forEach(e=>{e.label||(e.label=e.name),Array.isArray(e.sub_params)?sO(e.sub_params):e.sub_params=[]})},QG=t=>{const e=t==null?void 0:t.map(r=>(r.output.label=`${r.seq}-${r.connector_name} : ${r.action_name}`,r.note&&(r.output.label+=`(${r.note})`),{...r,label:`${r.connector_name}-${r.action_name}`,sub_params:[r.output]})),n=Pt.cloneDeep(e);return sO(n),n};var aO=(t=>(t.TEXT="TEXT",t.NUMBER="NUMBER",t.JSON="JSON",t))(aO||{});const ZG=t=>({TEXT:"STRING",NUMBER:"NUMBER",JSON:"OBJECT"})[t]||"STRING",eR=t=>{const{nodeId:e,flowId:n,enabled:r=!0,includeGlobalVariables:o=!0}=t,i=ne.useStoreApi(),[s,a]=y.useState([]),[l,c]=y.useState([]),[u,d]=y.useState(!1),[f,p]=y.useState(null),[m,v]=y.useState(0),[b,w]=y.useState(!1),[g,C]=y.useState(null),[k,_]=y.useState(0),S=y.useCallback(()=>{v(T=>T+1)},[]),E=y.useCallback(()=>{_(T=>T+1)},[]),x=y.useCallback(()=>{v(T=>T+1),_(T=>T+1)},[]);return y.useEffect(()=>{if(!r||!o){o||a([]),d(!1),p(null);return}let T=!1;return(async()=>{d(!0),p(null);try{const I=await Py();if(T)return;const F=((I==null?void 0:I.items)||[]).map(N=>({...N,mappedType:ZG(N.var_type)}));a(N=>Pt.isEqual(N,F)?N:F)}catch(I){console.error("Failed to fetch global variables:",I),T||p(I instanceof Error?I:new Error("无法获取全局变量数据"))}finally{T||d(!1)}})(),()=>{T=!0}},[r,o,m]),y.useEffect(()=>{if(!r||!n){w(!1),C(null);return}let T=!1;return(async()=>{w(!0),C(null);try{const{edges:I,nodes:F}=i.getState(),N=await Iy(n,{nodeId:e,edges:I});if(T)return;const P=new Map(F.map(H=>[H.id,H])),z=(QG(N)||[]).map(H=>{var $,j;const R=($=H.node_id)!=null&&$.startsWith("N")?H.node_id.slice(1):H.node_id,Y=R?P.get(R):void 0,te=typeof((j=Y==null?void 0:Y.data)==null?void 0:j.icon)=="string"?Y.data.icon:void 0;return{...H,nodeIcon:te,isValid:!!Y}});c(H=>Pt.isEqual(H,z)?H:z)}catch(I){console.error("Failed to fetch node variables:",I),T||C(I instanceof Error?I:new Error("无法获取节点变量数据"))}finally{T||w(!1)}})(),()=>{T=!0}},[n,e,r,k,i]),{globalVariables:s,nodeVariables:l,isLoading:u||b,isGlobalLoading:u,isNodeLoading:b,error:f||g,globalError:f,nodeError:g,refresh:x,refreshGlobal:S,refreshNode:E}},it={container:"_container_1f6qh_5",header:"_header_1f6qh_29",headerIcon:"_headerIcon_1f6qh_37",headerTitle:"_headerTitle_1f6qh_41",body:"_body_1f6qh_46",section:"_section_1f6qh_61",sectionLabel:"_sectionLabel_1f6qh_65",sectionIcon:"_sectionIcon_1f6qh_79",typeTag:"_typeTag_1f6qh_88",varItem:"_varItem_1f6qh_97",varName:"_varName_1f6qh_115",varValue:"_varValue_1f6qh_121",nodeTitle:"_nodeTitle_1f6qh_129",nodeIcon:"_nodeIcon_1f6qh_134",nodeLabelFirst:"_nodeLabelFirst_1f6qh_139",nodeLabel:"_nodeLabel_1f6qh_139",leafTitle:"_leafTitle_1f6qh_151",leafLabel:"_leafLabel_1f6qh_156",leafValue:"_leafValue_1f6qh_162",empty:"_empty_1f6qh_168",loadingState:"_loadingState_1f6qh_172",errorState:"_errorState_1f6qh_181",invalidVariable:"_invalidVariable_1f6qh_185",nodeIconWrapper:"_nodeIconWrapper_1f6qh_194",defaultNodeIcon:"_defaultNodeIcon_1f6qh_207"},lw={VariableModalTitle:h.jsx(Te.FormattedMessage,{id:"app.common.word.select-variable"}),NoTestDataDesc:h.jsx(Te.FormattedMessage,{id:"common.no-process-variables-yet"})},tR=t=>{if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="object")try{return JSON.stringify(t)}catch{return String(t)}return String(t)},nR=(t,e)=>{const n=t.trim(),r=n.startsWith("N")?n:`N${n}`,o=e.slice(1).join(".");return o?`{{${r}.${o}}}`:`{{${r}}}`},lO=y.forwardRef((t,e)=>{const n=El(),{nodeId:r,showGlobalVariables:o=!0}=t,{event$:i}=y.useContext(Qr),{globalVariables:s,nodeVariables:a,isGlobalLoading:l,isNodeLoading:c,globalError:u,nodeError:d,refreshGlobal:f,refreshNode:p}=eR({nodeId:r,flowId:n,enabled:t.open,includeGlobalVariables:o}),m=Et.useReactive({currentInputId:"",visible:!0});i.useSubscription(w=>{switch(w.type){case"visible":m.visible||(f(),p()),m.visible=w.visible;break;case"setCurrentInputId":m.currentInputId=w.currentInputId;break}}),y.useImperativeHandle(e,()=>({loadVariables:()=>{f(),p()}}));const v=w=>{try{const g=typeof w=="string"?JSON.parse(w):w,C=(_,S)=>{if(_==null)return{name:S,type:tr.Null,label:S,multi_valued:!1,sub_params:[],value:String(_)};if(typeof _=="object"&&!Array.isArray(_)){const x=_;return{name:S,type:tr.Object,label:S,multi_valued:!1,sub_params:Object.keys(x).map(O=>C(x[O],O)),value:null}}if(Array.isArray(_)){const x=_[0],O=x&&typeof x=="object"?tr.Object:typeof x=="number"?tr.Number:typeof x=="boolean"?tr.Boolean:x==null?tr.Array:tr.String;return{name:S,type:O,label:S,multi_valued:!0,sub_params:[],value:JSON.stringify(_)}}const E=typeof _=="number"?tr.Number:typeof _=="boolean"?tr.Boolean:tr.String;return{name:S,type:E,label:S,multi_valued:!1,sub_params:[],value:String(_)}},k=g&&typeof g=="object"&&!Array.isArray(g)?g:{};return Object.keys(k).map(_=>C(k[_],_))}catch{return[]}},b=(w,g,C,k,_,S=[],E="0")=>(w??[]).map((x,O)=>{var I;const A=[...S,x.name],T=`${E}-${O}`;return(I=x.sub_params)!=null&&I.length?{key:T,variablePath:A,title:h.jsxs("span",{className:`${it.nodeTitle}${k===!1?` ${it.invalidVariable}`:""}`,children:[g?_==="api"?h.jsx(se.ApiOutlined,{className:it.nodeIcon}):h.jsx("span",{className:it.nodeIconWrapper,children:C?h.jsx("img",{src:C,alt:""}):h.jsx("span",{className:it.defaultNodeIcon,children:"N"})}):h.jsx(D.Tag,{color:sw[x.type]||"gray",className:`${it.typeTag} workflow-variable-panel__type`,children:aw(x.type,x.multi_valued)}),h.jsx("span",{className:`${g?it.nodeLabelFirst:it.nodeLabel} workflow-variable-panel__label`,children:x.label})]}),children:b(x.sub_params,!1,C,k,_,A,T)}:{key:T,variablePath:A,title:h.jsxs("span",{className:`${it.leafTitle}${k===!1?` ${it.invalidVariable}`:""}`,children:[h.jsx(D.Tag,{color:sw[x.type]||"gray",className:`${it.typeTag} workflow-variable-panel__type`,children:aw(x.type,x.multi_valued)}),h.jsx("span",{className:`${it.leafLabel} workflow-variable-panel__label`,children:x.label}),x.value?h.jsx("span",{className:it.leafValue,children:x.value}):null]})}});return h.jsxs("div",{className:`${it.container} workflow-variable-panel`,children:[h.jsxs("div",{className:`${it.header} workflow-variable-panel__header`,children:[h.jsx(CW,{size:16,className:`${it.headerIcon} workflow-variable-panel__header-icon`}),h.jsx("span",{className:`${it.headerTitle} workflow-variable-panel__title`,children:lw.VariableModalTitle})]}),h.jsxs("div",{className:`${it.body} workflow-variable-panel__body`,children:[o?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:`${it.sectionLabel} workflow-variable-panel__section-label`,children:[h.jsx(se.GlobalOutlined,{className:it.sectionIcon,size:32}),h.jsx("span",{children:"全局变量"})]}),h.jsx("div",{className:`variable-panel-group ${!l&&!u&&s.length<1?"empty":""}`,children:h.jsxs("div",{className:it.section,children:[s.map(w=>{if(w.var_type===aO.JSON){const k=v(w.var_value??{}),_=[{name:w.name,type:tr.Object,label:w.display_name||w.name,multi_valued:!1,sub_params:k,value:null}],S=b(_,!0,void 0,!0,"api");return h.jsx(D.Tree,{defaultExpandAll:!0,showLine:!0,onSelect:(E,x)=>{const O=x.node.variablePath;i.emit({type:"insert",currentInputId:m.currentInputId,expression:`{{global.${O.join(".")}}}`})},switcherIcon:h.jsx(se.CaretDownOutlined,{}),treeData:S},w.id)}const g=tR(w.var_value),C=g.length>28?`${g.substring(0,28)}...`:g;return h.jsxs("button",{type:"button",className:`${it.varItem} workflow-variable-panel__item`,onClick:()=>{i.emit({type:"insert",currentInputId:m.currentInputId,expression:`{{global.${w.name}}}`})},children:[h.jsx(D.Tag,{color:sw[w.mappedType],className:`${it.typeTag} workflow-variable-panel__type`,children:aw(w.mappedType)}),h.jsx("span",{className:`${it.varName} workflow-variable-panel__label`,children:w.display_name||w.name}),C?h.jsx("span",{className:it.varValue,children:C}):null]},w.id)}),!l&&!u&&s.length<1&&h.jsx(D.Empty,{image:D.Empty.PRESENTED_IMAGE_SIMPLE,description:lw.NoTestDataDesc,className:it.empty}),l?h.jsxs("div",{className:it.loadingState,children:[h.jsx(D.Spin,{size:"small"}),h.jsx("span",{children:"正在加载全局变量"})]}):u?h.jsx(D.Alert,{className:it.errorState,type:"error",showIcon:!0,message:"全局变量加载失败",description:u.message,action:h.jsx(D.Button,{size:"small",onClick:f,children:"重试"})}):null]})})]}):null,h.jsxs("div",{className:`${it.sectionLabel} workflow-variable-panel__section-label`,children:[h.jsx(se.ApiOutlined,{className:it.sectionIcon}),h.jsx("span",{children:"节点变量"})]}),h.jsx("div",{className:`variable-panel-group ${!c&&!d&&a.length<1?"empty":""}`,children:h.jsxs("div",{className:it.section,children:[a.map(w=>h.jsx("div",{children:h.jsx(D.Tree,{defaultExpandAll:!0,showLine:!0,onSelect:(g,C)=>{const k=C.node.variablePath;if(k.length<=1)return!1;i.emit({type:"insert",currentInputId:m.currentInputId,expression:nR(w.node_id,k)})},switcherIcon:h.jsx(se.CaretDownOutlined,{}),treeData:b(w.sub_params,!0,w.nodeIcon,w.isValid,"node")})},`${w.node_id}-${w.seq}`)),!c&&!d&&a.length<1&&h.jsx(D.Empty,{image:D.Empty.PRESENTED_IMAGE_SIMPLE,description:lw.NoTestDataDesc,className:it.empty}),c?h.jsxs("div",{className:it.loadingState,children:[h.jsx(D.Spin,{size:"small"}),h.jsx("span",{children:"正在加载节点变量"})]}):d?h.jsx(D.Alert,{className:it.errorState,type:"error",showIcon:!0,message:"节点变量加载失败",description:d.message,action:h.jsx(D.Button,{size:"small",onClick:p,children:"重试"})}):null]})})]})]})}),{Option:Po}=D.Select,rR=y.forwardRef(({onSubmit:t,config_schema:e,nodeId:n},r)=>{const[o]=D.Form.useForm(),i=xl(),s=D.Form.useWatch("type",o);Et.useMount(()=>{e&&Object.hasOwn(e,"asc")&&o.setFieldsValue(e)});const[a,l]=y.useState(!1),c=(d,f,p="")=>(l(!0),o.validateFields().then(async m=>s&&s==="NUMBER"&&m.start>m.end?D.message.warning(K("link.flow.loop_start_end_check")):t({properties:m},d)).catch(()=>(D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>l(!1)));y.useImperativeHandle(r,()=>({saveConfig:d=>c(d)}));const u=Ot();return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:i,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsxs(D.Form,{disabled:!u,form:o,layout:"vertical",children:[h.jsxs(D.Row,{children:[h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{name:"type",label:K("app.common.word.loop-data-type"),rules:[{required:!0,message:K("link.flow.please_select_data_type")}],children:h.jsxs(D.Select,{children:[h.jsx(Po,{value:"ARRAY",children:h.jsx(Te.FormattedMessage,{id:"link.flow.array"})}),h.jsx(Po,{value:"NUMBER",children:h.jsx(Te.FormattedMessage,{id:"common.number"})}),h.jsx(Po,{value:"CONDITION",children:h.jsx(Te.FormattedMessage,{id:"link.flow.condition_expression"})})]})})}),s&&s==="NUMBER"&&h.jsx(D.Col,{sm:24,lg:12,children:h.jsxs(D.Form.Item,{required:!0,label:K("link.flow.loop_start_end"),style:{display:"flex"},children:[h.jsx(D.Form.Item,{name:"start",noStyle:!0,rules:[{required:!0,message:K("link.flow.please_select_data_type")}],children:h.jsx(D.InputNumber,{min:1,style:{marginRight:20}})}),h.jsx(D.Form.Item,{name:"end",noStyle:!0,rules:[{required:!0,message:K("link.flow.please_select_data_type")}],children:h.jsx(D.InputNumber,{min:1})})]})}),s&&s!=="NUMBER"&&h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{rules:[{required:!0,message:K("link.flow.please_enter_loop_expression")}],label:K("link.flow.loop_expression"),name:"expression",children:h.jsx(Pn,{nodeId:n,borrow:!0,valueType:"JS_EXP",placeholder:K("link.flow.please_enter_loop_expression")})})}),!s&&h.jsx(D.Col,{})]}),h.jsxs(D.Row,{children:[h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{name:"asc",label:K("app.common.word.circulation-direction"),rules:[{required:!0,message:K("link.flow.please_select_loop_direction")}],children:h.jsxs(D.Select,{children:[h.jsx(Po,{value:!0,children:h.jsx(Te.FormattedMessage,{id:"link.flow.loop_head_to_tail"})}),h.jsx(Po,{value:!1,children:h.jsx(Te.FormattedMessage,{id:"link.flow.loop_tail_to_head"})})]})})}),h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{name:"errorExec",label:K("link.flow.loop_processing"),rules:[{required:!0,message:K("link.flow.please_select_loop_processing")}],children:h.jsxs(D.Select,{children:[h.jsx(Po,{value:"END",children:h.jsx(Te.FormattedMessage,{id:"link.flow.terminate_process"})}),h.jsx(Po,{value:"CONTINUE",children:h.jsx(Te.FormattedMessage,{id:"link.flow.continue_loop"})}),h.jsx(Po,{value:"BREAK",children:h.jsx(Te.FormattedMessage,{id:"link.flow.break_loop"})})]})})})]})]})}),h.jsx("div",{className:"workflow-node-form-footer",children:u&&h.jsx(D.Button,{type:"primary",disabled:!u,loading:a,className:"workflow-node-form-save",onClick:()=>c(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),Ud=()=>`branch_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,{Option:oR}=D.Select,iR=y.forwardRef((t,e)=>{const{config_schema:n,nodeId:r}=t,[o]=D.Form.useForm(),i=xl(),{handleNodeDataUpdate:s}=Ri(),[a,l]=y.useState(null),[c,u]=y.useState(""),f=(E=>!(E!=null&&E.branches)||E.branches.length===0?{branches:[{id:Ud(),name:K("link.flow.switch.condition_one"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]},{id:Ud(),name:K("link.flow.switch.condition_two"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]}]}:{branches:E.branches.map((O,A)=>{var T;return{id:O.id||Ud(),name:O.name||K("link.flow.switch.condition_n",{n:A+1}),or_list:((T=O.or_list)==null?void 0:T.map(B=>{var I;return{and_list:((I=B.and_list)==null?void 0:I.map(F=>({query:F.query||"",operator:F.operator||"",value:F.value||""})))||[{query:"",operator:"",value:""}]}}))||[{and_list:[{query:"",operator:"",value:""}]}]}})})(n),p=()=>{const E=o.getFieldValue("branches")||[];s({id:r,data:{config_schema:{branches:E}}})},m=(E,x)=>{l(E),u(x)},v=()=>{l(null),u("")},b=E=>{const x=Pt.cloneDeep(o.getFieldValue("branches"))||[],O=c.trim();if(!O){D.message.error(K("link.flow.switch.branch_name_cannot_be_empty"));return}if(x.some((T,B)=>B!==E&&T.name===O)){D.message.error(K("link.flow.switch.branch_name_duplicate"));return}x[E].name=O,o.setFieldValue("branches",x),l(null),u(""),p()},w=(E,x)=>{const O=o.getFieldValue("branches")||[];if(x<0||x>=O.length)return;const A=[...O],[T]=A.splice(E,1);A.splice(x,0,T),o.setFieldValue("branches",A),p()},[g,C]=y.useState(!1),k=E=>(C(!0),o.validateFields().then(async x=>{if(!x.branches.some(T=>T.or_list.some(B=>B.and_list.some(I=>I.query&&I.operator)))){D.message.error(K("link.flow.switch.at_least_one_valid_branch"));return}const A=Pt.cloneDeep(x);return A.branches.forEach(T=>{T.or_list.forEach(B=>{B.and_list.forEach(I=>{I.value=FG(I.operator,I.value)})})}),t.onSubmit({properties:A},E)}).catch(()=>(D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>C(!1)));y.useImperativeHandle(e,()=>({saveConfig:E=>k(E)}));const _=Ot(),S=(E,x,O,A)=>{const B=(o.getFieldValue("branches")||[])[x],I=a===x;return h.jsxs(D.Card,{style:{marginBottom:20,borderRadius:8,border:"1px solid #d9d9d9"},styles:{body:{padding:10}},children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:12},children:[h.jsx("div",{style:{display:"flex",alignItems:"center",flex:1},children:I?h.jsxs(D.Space,{children:[h.jsx(D.Input,{value:c,onChange:F=>u(F.target.value),style:{width:200},placeholder:K("link.flow.switch.enter_branch_name"),onPressEnter:()=>b(x)}),h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.CheckOutlined,{style:{color:"#52c41a"}}),onClick:()=>b(x)}),h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.CloseOutlined,{}),onClick:v})]}):h.jsxs(D.Space,{children:[h.jsx("span",{style:{fontSize:13,fontWeight:400},children:(B==null?void 0:B.name)||K("link.flow.switch.condition_n",{n:x+1})}),_&&h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.EditOutlined,{}),onClick:()=>m(x,(B==null?void 0:B.name)||"")})]})}),_&&h.jsxs(D.Space,{className:"actions",children:[h.jsx(D.Tooltip,{title:K("link.flow.switch.move_to_top"),children:h.jsx(D.Button,{type:"text",size:"small",disabled:x===0,onClick:()=>w(x,0),children:"置顶"})}),h.jsx(D.Tooltip,{title:K("link.flow.switch.move_up"),children:h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.ArrowUpOutlined,{}),disabled:x===0,onClick:()=>w(x,x-1)})}),h.jsx(D.Tooltip,{title:K("link.flow.switch.move_down"),children:h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.ArrowDownOutlined,{}),disabled:x===O-1,onClick:()=>w(x,x+1)})}),h.jsx(D.Tooltip,{title:K("link.flow.switch.move_to_bottom"),children:h.jsx(D.Button,{type:"text",size:"small",disabled:x===O-1,onClick:()=>w(x,O-1),children:"置底"})}),h.jsx(D.Tooltip,{title:K("common.delete"),children:h.jsx(D.Button,{type:"text",size:"small",disabled:O<=1,onClick:()=>{if(O<=1){D.message.warning(K("link.flow.switch.at_least_one_branch"));return}A(E.name),setTimeout(()=>{p()},0)},children:"删除"})})]})]}),h.jsx(D.Form.Item,{name:[E.name,"name"],hidden:!0,children:h.jsx(D.Input,{})}),h.jsx(D.Form.List,{name:[E.name,"or_list"],children:(F,{add:N,remove:P})=>h.jsx(h.Fragment,{children:F.map((M,z)=>{const H=z===F.length-1;return h.jsx(h.Fragment,{children:h.jsxs("div",{className:"switch-rule",children:[F.length>1&&_&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsxs(D.Button,{type:"link",icon:h.jsx(se.MinusCircleOutlined,{}),onClick:()=>P(M.name),children:[h.jsx(Te.FormattedMessage,{id:"link.flow.remove"})," OR"]})}),h.jsx(D.Form.List,{name:[M.name,"and_list"],children:(R,{add:Y,remove:te})=>h.jsx(h.Fragment,{children:R.map(($,j)=>{const U=j===R.length-1;return h.jsxs(D.Space,{direction:"vertical",style:{width:"100%"},children:[h.jsxs(D.Space,{align:"center",className:"switch-rule-item",children:[h.jsx(D.Form.Item,{style:{minWidth:150,marginBottom:0},name:[$.name,"query"],label:K("app.common.word.variable-name"),rules:[{required:!0,message:K("link.flow.please_enter_variable_name")}],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),h.jsx(D.Form.Item,{style:{marginBottom:0},name:[$.name,"operator"],label:K("app.common.word.condition"),rules:[{required:!0,message:K("link.flow.please_select_condition")}],children:h.jsx(D.Select,{style:{minWidth:140},placeholder:K("link.flow.select_condition"),getPopupContainer:()=>document.body,children:oO.map(ee=>h.jsx(oR,{value:ee.operator,children:ee.label},ee.operator))})}),h.jsx(D.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const ee=o.getFieldValue(["branches",E.name,"or_list",M.name,"and_list",$.name,"operator"]);return iw(ee)?null:h.jsx(D.Form.Item,{style:{minWidth:150,marginBottom:0},name:[$.name,"value"],label:K("app.common.word.value"),rules:[],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),j===0&&h.jsx("div",{style:{width:30}}),j>0&&_&&h.jsx(D.Button,{type:"link",icon:h.jsx(se.MinusCircleOutlined,{}),onClick:()=>te($.name)})]}),j<R.length-1&&h.jsx(D.Divider,{plain:!0,style:{margin:"8px 0"},children:h.jsx(D.Tag,{color:"#999999",children:h.jsx(Te.FormattedMessage,{id:"link.flow.and"})})}),h.jsxs("div",{className:`rule-opt-actions ${U?"last-and-rule":""}`,children:[j===R.length-1&&h.jsx(D.Button,{type:"link",disabled:!_,icon:h.jsx(br,{size:14}),onClick:()=>Y({query:"",operator:"",value:""}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-new-and"})}),H&&h.jsx(D.Button,{type:"link",icon:h.jsx(br,{size:14}),disabled:!_,onClick:()=>N({and_list:[{query:"",operator:"",value:""}]}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-or"})})]})]},$.key)})})}),!H&&h.jsx("div",{style:{textAlign:"center"},children:h.jsx(D.Divider,{style:{color:"orange"},dashed:!0,children:h.jsx(D.Tag,{color:"#1890ff",children:h.jsx(Te.FormattedMessage,{id:"link.flow.or"})})})})]},M.key)})})})})]},E.key)};return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:i,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsx(D.Form,{disabled:!_,form:o,initialValues:f,layout:"vertical",autoComplete:"off",children:h.jsx(D.Form.List,{name:"branches",children:(E,{add:x,remove:O})=>h.jsxs(h.Fragment,{children:[E.map((A,T)=>S(A,T,E.length,O)),E.length<10&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end",width:"100%"},children:h.jsx(D.Button,{type:"default",icon:h.jsx(br,{size:14}),disabled:!_,onClick:()=>{const A=E.length+1;x({id:Ud(),name:K("link.flow.switch.condition_n",{n:A}),or_list:[{and_list:[{query:"",operator:"",value:""}]}]}),setTimeout(()=>{p()},0)},children:h.jsx(Te.FormattedMessage,{id:"link.flow.switch.add_branch"})})}),E.length>=10&&h.jsx("div",{style:{textAlign:"center",color:"#999",marginBottom:20},children:h.jsx(Te.FormattedMessage,{id:"link.flow.switch.max_branches_reached"})})]})})})}),h.jsx("div",{className:"workflow-node-form-footer",children:_&&h.jsx(D.Button,{type:"primary",disabled:!_,loading:g,className:"workflow-node-form-save",onClick:()=>k(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),sR=({nodeId:t,onSubmit:e,data:n})=>{const[r]=D.Form.useForm(),o=xl(),i=Ot(),{refreshFlow:s}=ao(),{setNodes:a}=ne.useReactFlow(),l=y.useCallback((u,d)=>{a(f=>f.map(p=>!d&&p.id!==t?p:{...p,data:{...p.data,error_handler:u}}))},[t,a]);y.useEffect(()=>{const u=(n==null?void 0:n.error_handler)||{};r.setFieldsValue({retryEnabled:u.retry||!1,retryCount:u.retry_times||3,retryInterval:u.retry_interval||5,stepFactor:u.step_factor||1.5,maxRetryInterval:u.max_retry_interval||60,alertEnabled:u.warn_type===1,webhookUrl:u.notify_url||"",errorHandling:u.process_type===2?"ignore":"interrupt",applyToAllNodes:!!u.apply_all})},[t,r,n==null?void 0:n.error_handler]);const c=async u=>{try{const d={retry:u.retryEnabled,retry_times:u.retryEnabled?u.retryCount:void 0,retry_interval:u.retryEnabled?u.retryInterval:void 0,step_factor:u.retryEnabled?u.stepFactor:void 0,max_retry_interval:u.retryEnabled?u.maxRetryInterval:void 0,warn_type:u.alertEnabled?1:0,notify_url:u.alertEnabled?u.webhookUrl:void 0,process_type:u.errorHandling==="interrupt"?1:2,apply_all:u.applyToAllNodes};await rc(t,{error_handler:d}),l(d,u.applyToAllNodes),u.applyToAllNodes&&s(),e()}catch{D.message.error(K("common.save_failed"))}};return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:o,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsxs(jn.ProForm,{form:r,layout:"vertical",disabled:!i,submitter:!1,onFinish:c,children:[h.jsx(jn.ProFormSwitch,{name:"retryEnabled",label:K("app.common.word.enable-retry")}),h.jsx(jn.ProFormDependency,{name:["retryEnabled"],children:({retryEnabled:u})=>u?h.jsxs(h.Fragment,{children:[h.jsx(jn.ProFormDigit,{name:"retryCount",label:K("app.common.word.retry-count"),tooltip:K("app.common.word.retry-count-tooltip"),width:"xl",fieldProps:{min:1,max:10,precision:0,style:{width:"100%"}},rules:[{required:u,message:K("app.common.word.please-enter-retry-count")}]}),h.jsx(jn.ProFormDigit,{name:"retryInterval",label:K("app.common.word.retry-interval"),tooltip:K("app.common.word.retry-interval-tooltip"),fieldProps:{min:1,max:60,precision:0,style:{width:"100%"},addonAfter:"s"},rules:[{required:u,message:K("app.common.word.please-enter-retry-interval")}]}),h.jsx(jn.ProFormDigit,{name:"stepFactor",label:K("app.common.word.step-factor"),tooltip:K("app.common.word.step-factor-tooltip"),width:"xl",fieldProps:{min:1,max:5,precision:1,style:{width:"100%"}},rules:[{required:u,message:K("app.common.word.please-enter-step-factor")}]}),h.jsx(jn.ProFormDigit,{name:"maxRetryInterval",label:K("app.common.word.max-retry-interval"),tooltip:K("app.common.word.max-retry-interval-tooltip"),width:"xl",fieldProps:{min:1,max:300,precision:0,style:{width:"100%"},addonAfter:"s"},rules:[{required:u,message:K("app.common.word.please-enter-max-retry-interval")}]})]}):null}),h.jsx(jn.ProFormSwitch,{name:"alertEnabled",label:K("app.common.word.enable-alert")}),h.jsx(jn.ProFormDependency,{name:["alertEnabled"],children:({alertEnabled:u})=>u?h.jsx(jn.ProFormText,{name:"webhookUrl",label:K("app.common.word.webhook-url"),placeholder:K("app.common.word.enter-webhook-url"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:u,message:K("app.common.word.enter-webhook-url")}]}):null}),h.jsx(jn.ProFormSelect,{name:"errorHandling",label:K("app.common.word.error-handling"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:!0,message:K("app.common.word.select-error-handling")}],options:[{label:K("app.common.word.interrupt-flow"),value:"interrupt"},{label:K("app.common.word.ignore-error"),value:"ignore"}]}),h.jsx(jn.ProFormSwitch,{name:"applyToAllNodes",label:K("app.common.word.apply-to-all-nodes")})]})}),h.jsx("div",{className:"workflow-node-form-footer",children:h.jsx(D.Button,{type:"primary",disabled:!i,onClick:()=>r.submit(),className:"workflow-node-form-save",children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})},cO="[workflow:schema-render]",aR=()=>{const{event$:t}=y.useContext(Qr),e=Fh();return t.useSubscription(n=>{var r;n.type==="insert"&&n.expression&&(r=e==null?void 0:e.getActiveFieldId)!=null&&r.call(e)&&e.insertVariableToActiveField(n.expression,!1)}),null},lR=({children:t})=>{const{event$:e}=y.useContext(Qr),n=Mh(),[r,o]=y.useState("");e.useSubscription(a=>{a.type==="setCurrentInputId"&&o(a.currentInputId??"")});const i=(n==null?void 0:n.activeFieldId)??r,s=y.useMemo(()=>({activeInputId:i}),[i]);return h.jsx(cx.Provider,{value:s,children:t})},cR=t=>{const{icon:e,fallbackIcon:n}=t;return h.jsxs("div",{className:"node-config-title",style:{display:"flex",alignItems:"center"},children:[h.jsx("div",{className:"node-config-icon",style:{backgroundImage:`url(${n?"none":e??"https://digitalsee-image.digitalsee.cn/flow/0.png"})`},children:n&&n}),h.jsxs("div",{className:"node-config-meta",children:[h.jsx("div",{className:"node-config-title-name",style:{fontSize:16,fontWeight:600,marginLeft:10},children:t.name}),h.jsx("div",{className:"node-config-title-description",style:{fontSize:12,color:"gray",marginLeft:10},children:t.description})]})]})},uR=y.memo(({visible:t,onClose:e,data:n,nodeType:r=pe.ACTION,nodeId:o=""})=>{var B,I;const i=Et.useEventEmitter();ne.useInternalNode(o);const{setNodeConfigVisible:s,refreshFlow:a}=ao(),l=y.useRef(null),c=y.useRef(null),u=y.useRef(null),d=y.useRef(null),f=y.useRef(null);y.useRef(null);const p=y.useRef(null),m=ne.useStoreApi(),v=$t(),b=((I=(B=v.nodeConfigPanel)==null?void 0:B.testArea)==null?void 0:I.allowManualTest)!==!1,w=Et.useReactive({output:"",ignore:!1,expandTestPanel:!1}),g=y.useMemo(()=>v.nodeConfigPanel.showSettings&&![pe.TRIGGER,pe.AI_SUB_NODE].includes(r),[r,v.nodeConfigPanel.showSettings]),C=(n==null?void 0:n.action_id)??(n==null?void 0:n.id),k=C!==null&&typeof C<"u"&&C!==""&&Number.isFinite(Number(C))?C:null,_=po(n),S=n==null?void 0:n.nodeKey,E=(n==null?void 0:n.nodeVersion)??(n==null?void 0:n.action_ver),{handleNodeDataUpdate:x}=Ri();y.useEffect(()=>{var N,P;if(!t)return;const F=k!==null&&Number(k)<=0;S&&F&&!_&&!((N=n==null?void 0:n.config_schema)!=null&&N.sub_params)&&!((P=n==null?void 0:n.properties)!=null&&P.sub_params)&&console.warn(`${cO} possible nodepackage schema route mismatch`,{nodeId:o,nodeType:r,actionId:k,nodePackageKey:S,nodePackageVersion:E,reason:"keyed node with non-positive action_id and no classic sub_params was rejected by the nodePackage-compatible node check"})},[k,n==null?void 0:n.config_schema,n==null?void 0:n.properties,n==null?void 0:n.params,n==null?void 0:n.action_key,n==null?void 0:n.action_ver,n==null?void 0:n.nodeKey,n==null?void 0:n.nodeVersion,_,S,E,o,r,t]);const O=y.useCallback(async(F,N)=>{var M,z,H;const P=v.flowId;try{const R=m.getState().nodes.find(U=>U.id===o),Y=_?ZP(F):F.properties,te=_?e2(F):F.account_id??null,$=_?{flow_id:P,properties:Y,position:R==null?void 0:R.position,action_id:k,account_id:te,proxy_id:F.proxy_id,mcp_tool_description:F.mcp_tool_description,action_key:S,action_ver:E}:{flow_id:P,...F,position:R==null?void 0:R.position,action_id:k};console.info(`${cO} save node config`,{nodeId:o,nodeType:r,actionId:k,isNodepackageNode:_,nodePackageKey:S,nodePackageVersion:E,valueKeys:Object.keys(F||{}),paramsKeys:Object.keys((F==null?void 0:F.params)||{}),propertiesKeys:Object.keys((F==null?void 0:F.properties)||{}),ignoreDebugResult:w.ignore});const j=w.ignore?await My(o,"","","",Y,w.output):await rc(o,$);if(j)if(w.ignore)(M=p.current)==null||M.finishSampleTest(),x({id:o,data:{status:me.SUCCESS,output:w.output,outputSource:"sample"}}),D.message.success("已使用样本数据完成调试");else{D.message.success("节点配置已保存");const U={params:void 0,properties:Y,account_id:te,mcp_tool_description:F.mcp_tool_description,action_key:S,action_ver:E,nodeKey:S,nodeVersion:E,isNodePackage:_};x({id:o,data:{config_schema:Y,account_id:F.account_id,...U,position:R==null?void 0:R.position,status:j.status}})}N&&!w.ignore&&((z=p.current)==null||z.onTestNode()),w.ignore=!1,w.output=""}catch{w.ignore&&((H=p.current)==null||H.abortSampleTest(),x({id:o,data:{status:me.FAILED}}))}},[k,v.flowId,n==null?void 0:n.action_key,n==null?void 0:n.action_ver,n==null?void 0:n.nodeKey,n==null?void 0:n.nodeVersion,x,_,S,E,o,r,w,m]);y.useCallback(F=>{!_||r!==pe.SWITCH||x({id:o,data:{config_schema:F,properties:F}})},[x,_,o,r]);const A=F=>{var N,P,M,z,H;return _?(N=c.current)==null?void 0:N.saveConfig(F):r===pe.LOOP?(P=f.current)==null?void 0:P.saveConfig(F):r===pe.CONDITION?(M=u.current)==null?void 0:M.saveConfig(F):r===pe.SWITCH?(z=d.current)==null?void 0:z.saveConfig(F):(H=c.current)==null?void 0:H.saveConfig(F)},T=async(F,N,P)=>{var M;if(N){w.ignore=!0,w.output=P||"",await A(F),(M=p.current)==null||M.finishNodeTest();return}if(F)try{D.message.loading("正在保存节点配置...",0),await A(F),D.message.success("节点配置已保存"),D.message.destroy()}catch(z){D.message.destroy(),console.error("节点配置保存失败:",z),D.message.error("节点配置保存失败,无法执行测试")}};return h.jsx(D.Modal,{open:t,footer:null,closeIcon:null,maskClosable:!0,onCancel:()=>{s(null)},centered:!0,width:"min(1440px, calc(100vw - 32px))",className:"nodes-config-modal",styles:{mask:{backgroundColor:"rgba(0, 0, 0, 0.45)"},content:{padding:0,overflow:"hidden"}},children:h.jsx(Qr.Provider,{value:{event$:i},children:h.jsxs(rC,{children:[h.jsx(aR,{}),h.jsx(lR,{children:h.jsx("div",{className:"nodes-config-container",children:h.jsx("div",{className:"nodes-config-content",children:h.jsxs("div",{className:"config-row",children:[h.jsx("div",{className:"left-section",children:h.jsx("div",{className:"variables-section",children:h.jsx(lO,{ref:l,nodeId:o,onInsert:()=>{},open:t})})}),h.jsx("div",{className:"middle-section",children:h.jsxs("div",{className:"config-container",children:[h.jsx(cR,{icon:n==null?void 0:n.icon,fallbackIcon:n==null?void 0:n.fallbackIcon,name:(n==null?void 0:n.action_name)||(n==null?void 0:n.label),description:n==null?void 0:n.description}),h.jsx(D.Tabs,{style:{height:"100%"},items:[{key:"property",label:"参数配置",children:h.jsxs(h.Fragment,{children:[_||![pe.CONDITION,pe.SWITCH,pe.LOOP].includes(r)?h.jsx(BG,{ref:c,nodeId:o,nodeType:r,data:n,onSubmit:O}):null,r===pe.CONDITION&&!_?h.jsx(IG,{ref:u,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null,r===pe.SWITCH&&!_?h.jsx(iR,{ref:d,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null,r===pe.LOOP&&!_?h.jsx(rR,{ref:f,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null]})},{key:"setting",label:"设置",children:h.jsx(sR,{data:n,nodeId:o,onSubmit:()=>{D.message.success("保存成功")}})}].slice(0,g?2:1)})]})}),h.jsx("div",{className:`right-section ${w.expandTestPanel?"expand":""}`,children:b&&h.jsx("div",{className:"test-section",children:h.jsx(XG,{ref:p,nodeId:o,beforeHook:T,onClose:e,onExpandPanel:F=>{w.expandTestPanel=F}})})})]})})})})]})})})},(t,e)=>Pt.isEqual(Pt.omit(t,["isHovered"]),Pt.omit(e,["isHovered"]))),uO=[],dR=(t,e)=>{if(uO.length===0)return[];const n=new Set(e);return t.some(o=>n.has(o.id)&&Oh(o)&&uO.some(i=>{var s;return((s=o.data)==null?void 0:s.action_key)===i}))?t.filter(o=>!n.has(o.id)).map(o=>o.id):[]},fR=[pe.AGENT,pe.BROWSER],cw=()=>{const t=ne.useStoreApi(),[e,n]=y.useState(0),r=y.useCallback((l,c)=>{const{nodes:u,setNodes:d}=t.getState(),f=fa(u,p=>{const m=p.find(v=>v.id===c.id);m.data?m.data.isHovered=!0:m.data={isHovered:!0}});d(f)},[]),o=y.useCallback((l,c)=>{const{nodes:u,setNodes:d}=t.getState(),f=fa(u,p=>{const m=p.find(v=>v.id===c.id);m.data?m.data.isHovered=!1:m.data={isHovered:!1}});d(f)},[]),i=y.useCallback(l=>{const{nodes:c,setNodes:u}=t.getState(),d=fa(c,f=>{l.forEach(p=>{p.type==="select"&&(f.find(m=>m.id===p.id).selected=p.selected)})});u(d)},[t]),s=y.useCallback((l,c,u=new Set)=>(c.filter(f=>f.source===l?f.sourceHandle!==He.OUTPUT&&f.sourceHandle!==He.DONE&&f.sourceHandle!==He.LOOP&&f.sourceHandle!==He.TRUE&&f.sourceHandle!==He.FALSE:f.target===l&&fh(f.targetHandle)).forEach(f=>{const p=f.source===l?f.target:f.source;u.has(p)||(u.add(p),s(p,c,u))}),u),[]),a=y.useCallback((l,c)=>{const{nodes:u,edges:d,setNodes:f,setEdges:p,onNodesChange:m,onEdgesChange:v}=t.getState(),b=new Set(l);fR.includes(c)&&l.forEach(C=>{s(C,d).forEach(_=>{b.add(_)})}),dR(u,l).forEach(C=>b.add(C));const w=Array.from(b),g=d.filter(C=>b.has(C.source)||b.has(C.target)).map(C=>C.id);if(m){const C=w.map(k=>({type:"remove",id:k}));m(C)}else f(u.filter(C=>!w.includes(C.id)));if(g.length)if(v){const C=g.map(k=>({type:"remove",id:k}));v(C)}else p(d.filter(C=>!g.includes(C.id)))},[t,s]);return{autoSaveNum:e,onNodeMouseEnter:r,onNodeMouseLeave:o,handleNodesChange:i,handleNodesDelete:a}};function hR(t){const{color:e,visible:n}=t;return h.jsx("div",{style:{display:n?"inline-flex":"none",justifyContent:"center",alignItems:"center",position:"absolute",zIndex:1e3,top:"calc(50% - 8px)",left:-10,padding:1,borderRadius:"100%",background:"#FFFFFF",width:20,height:20},children:h.jsx("span",{style:{width:16,height:16,borderRadius:10,backgroundColor:e,border:`1px solid ${e}`,display:"inline-flex",justifyContent:"center",alignItems:"center"},children:h.jsx(DW,{size:8,color:"#FFFFFF"})})})}const Lo={info:{normal:"#007FFF",lighter:"rgba(0, 127, 255, 0.48)"},success:{normal:"#98D7A9",lighter:"rgba(0, 176, 66, 0.48)"},warning:{normal:"#F7CD8F",lighter:"rgba(255, 146, 0, 0.48)"},error:{normal:"#F3B096",lighter:"rgba(255, 82, 25, 0.48)"},disabled:{normal:"#C7CCD1",lighter:"rgba(199, 204, 209, 0.48)"}},dO=({id:t,type:e=pe.ACTION,selected:n=!1,fallbackIcon:r,iconUri:o,inputs:i=[],outputs:s=[],showToolbar:a=!0,width:l,height:c,className:u="",status:d=me.IDLE,onTestNode:f,data:p,contentRender:m,showNodeDescription:v=!0,onToggleNodeDisabled:b})=>{const{currentNodeConfigVisibleId:w,setNodeConfigVisible:g}=ao(),{handleNodeDataUpdate:C}=Ri(),{handleNodesDelete:k}=cw(),_=$t(),S=na(),E=$=>{C({id:t,data:{note:$}})},x=y.useCallback(()=>{g(null)},[]),O=(p==null?void 0:p.isHovered)||!1,A=y.useMemo(()=>e===pe.TRIGGER,[e]),T=()=>{g(t)},B=y.useMemo(()=>(p==null?void 0:p.closed)==="1",[p==null?void 0:p.closed,e]),I=y.useMemo(()=>typeof l=="number"&&l>0?l:"auto",[l]),F=($="node")=>{if(B)return`workflow-${$}-disabled`;switch(d){case me.INVALID:return`workflow-${$}-warning`;case me.FAILED:return`workflow-${$}-failed`;case me.SUCCESS:case me.RUNNABLE:case me.ACTIVE:return`workflow-${$}-success`;case me.RUNNING:return`workflow-${$}-running`;case me.WARNING:return`workflow-${$}-warning`;case me.DEACTIVATED:return`workflow-${$}-disabled`;case me.IDLE:return`workflow-${$}-idle`;default:return""}},N=()=>{if(B)return Lo.disabled;switch(d){case me.INVALID:return Lo.warning;case me.FAILED:return Lo.error;case me.SUCCESS:case me.RUNNABLE:case me.ACTIVE:return Lo.success;case me.RUNNING:return Lo.info;case me.WARNING:return Lo.warning;case me.DEACTIVATED:return Lo.disabled;default:return Lo.info}},P=($="normal")=>N()[$],M=()=>{const $=i.length,j=new Map;return i.forEach(U=>{const ee=U.position,ie=j.has(ee)?j.get(ee)+1:1;j.set(ee,ie)}),i.map((U,ee)=>h.jsx(P0,{nodeId:t,id:U.id,position:U.position,type:U.type||fn.TARGET,category:U.category,connectionLimit:U.maxConnections,label:U.label,nodeStatus:d,protocol:U.protocol,portSchema:U.portSchema,shape:U.shape,style:U.style,index:[ee,$,j.get(U.position)]},`${t}-${U.id}`))},z=async()=>{var U,ee;const $=((U=_.canvas.fixedNodes)==null?void 0:U.triggerIds)||[],j=((ee=_.nodeTypes.fixed)==null?void 0:ee.triggers)||[];if($.includes(t)||j.includes(e)){D.message.warning("当前触发节点已被配置为不可删除");return}await Xf(t),k([t],e)},H=y.useMemo(()=>{const $=s.length,j=new Map;return s.forEach(U=>{const ee=U.position,ie=j.has(ee)?j.get(ee)+1:1;j.set(ee,ie)}),s.map((U,ee)=>h.jsx(P0,{nodeId:t,connectionLimit:U.maxConnections,id:U.id,style:U.style,position:U.position,protocol:U.protocol,portSchema:U.portSchema,type:U.type,label:U.label,shape:U.shape,nodeStatus:d,index:[ee,$,j.get(U.position)]},`${t}-${U.id}`))},[t,s,d]),R=()=>h.jsx(nC,{status:d,disabled:B}),Y=()=>{switch(d){case me.INVALID:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-warning-icon",children:h.jsx(se.WarningFilled,{style:{color:P()},size:12})});case me.FAILED:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-failed-icon",children:h.jsx(se.CloseCircleFilled,{style:{color:P()},size:12})});case me.SUCCESS:case me.RUNNABLE:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-success-icon",children:h.jsx(se.CheckCircleFilled,{style:{color:P()},size:12})});case me.RUNNING:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-running-icon",children:h.jsx(se.LoadingOutlined,{style:{color:P()},size:12})});default:return null}},te=()=>h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"workflow-node-icon-wrapper",children:h.jsx("div",{className:"workflow-node-icon",style:{backgroundImage:`url(${r?"none":o??"https://digitalsee-image.digitalsee.cn/flow/0.png"})`},children:r&&r})}),v&&h.jsx(PP,{title:p==null?void 0:p.connector_name,nodeId:t,note:(p==null?void 0:p.note)||"",statusIcon:Y(),onNoteChange:E,description:p.action_name,className:"workflow-node-text"})]});return h.jsxs(y.Fragment,{children:[h.jsxs("div",{style:{width:I,height:c||"auto"},onDoubleClick:T,className:`${u}
|
|
117
|
+
`})]}):y.isValidElement(t)?y.cloneElement(t,{value:e,onChange:n,...t.props}):t;return h.jsxs(h.Fragment,{children:[!r&&h.jsx("div",{style:{marginBottom:6,textAlign:"right"},children:h.jsxs(D.Button,{size:"small",type:"primary",onClick:i,style:{background:"linear-gradient(135deg, #667eea 0%, #764ba2 100%)",border:"none",borderRadius:"14px",padding:"0 10px",height:"24px",fontSize:"11px",fontWeight:"500",boxShadow:"0 2px 8px rgba(102, 126, 234, 0.3)",transition:"all 0.2s ease",display:"flex",alignItems:"center",gap:"4px",lineHeight:1},onMouseEnter:a=>{a.currentTarget.style.transform="translateY(-1px)",a.currentTarget.style.boxShadow="0 4px 12px rgba(102, 126, 234, 0.5)"},onMouseLeave:a=>{a.currentTarget.style.transform="translateY(0)",a.currentTarget.style.boxShadow="0 2px 8px rgba(102, 126, 234, 0.3)"},children:[h.jsx(se.RobotOutlined,{style:{fontSize:"11px"}}),"由AI生成"]})}),s()]})},eG=t=>{var n;const e=In();return h.jsx(D.Select,{id:e,style:{borderRadius:6},...t,getPopupContainer:r=>r.parentNode,children:(n=t==null?void 0:t.options)==null?void 0:n.map(r=>h.jsx(D.Select.Option,{label:r.label,value:r.value,children:r.label},r.value))})},tG=t=>h.jsx(D.DatePicker,{style:{width:"100%"},picker:"date",value:t.value?jt(t.value):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD")))}}),nG=t=>h.jsx(y.Fragment,{children:h.jsx(D.DatePicker,{style:{width:"100%"},picker:"date",showTime:!0,value:t.value?jt(t.value):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD hh:mm:ss")))}})}),rG=({value:t=[],onChange:e,selectType:n="KNOWLEDGE_BASE",placeholder:r="请选择"})=>{const o=Et.useReactive({items:[]}),[i,s]=y.useState([]),[a,l]=y.useState(!1);y.useEffect(()=>{n&&(l(!0),Uy(n).then(p=>{p&&Array.isArray(p)&&s(p)}).catch(p=>{console.error("获取选项失败:",p),s([])}).finally(()=>{l(!1)}))},[n]),y.useEffect(()=>{const p=Array.isArray(t)?t:[];o.items=p.map(m=>({...m,id:m.id??In()}))},[t]);const c=Ot(),u=p=>{const m=o.items.filter(v=>v.id!==p);e==null||e(m)},d=()=>{e([...o.items,{value:"",id:In()}])},f=(p,m)=>{e(o.items.map((v,b)=>b===p?{...v,value:m}:v))};return h.jsxs("div",{children:[o.items.length?o.items.map((p,m)=>h.jsxs(D.Space,{size:"small",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[h.jsx(D.Select,{value:p.value||void 0,onChange:v=>f(m,v),placeholder:r,style:{width:300},disabled:!c||a,loading:a,options:i,showSearch:!0,filterOption:(v,b)=>((b==null?void 0:b.label)??"").toLowerCase().includes(v.toLowerCase()),getPopupContainer:v=>v.parentNode}),c&&h.jsx(D.Button,{icon:h.jsx(Di,{size:16}),onClick:()=>{u(p.id)}})]},p.id)):null,c&&h.jsx(D.Button,{type:"default",onClick:d,block:!0,icon:h.jsx(br,{size:16}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})})]})},oG=({value:t=[],onChange:e,valueType:n})=>{const r=u=>{let d=[...o.items];d=d.filter(f=>f.id!==u),e==null||e(d)},o=Et.useReactive({items:[]}),i=u=>{const d=u.which||u.keyCode;(d===37||d===229)&&u.preventDefault()};y.useEffect(()=>{const u=Array.isArray(t)?t:[];o.items=u.map(d=>({...d,id:d.id??In()}))},[t]);const s=()=>{e==null||e([...o.items,{key:"",value:"",id:In()}])},a=(u,d)=>{e==null||e(o.items.map(f=>f.id===u?{...f,key:d}:f))},l=(u,d)=>{e==null||e(o.items.map(f=>f.id===u?{...f,value:d}:f))},c=Ot();return h.jsxs("div",{className:"workflow-extend-object",children:[o.items.length?o.items.map((u,d)=>h.jsxs(D.Space,{size:"small",className:"workflow-extend-object__row",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[h.jsx(D.Input,{defaultValue:u.key,onKeyDown:i,onChange:f=>{var p;a(u.id,(p=f.target.value)==null?void 0:p.replace(/'/g,""))},placeholder:"Key"}),h.jsx("span",{className:"workflow-extend-object__value",style:{display:"inline-block",transform:"translateY(2px)",width:300},children:h.jsx(Pn,{borrow:!0,disableIDE:!0,placeholder:"Value",style:{width:300},value:u.value,onChange:f=>l(u.id,f),valueType:n,nodeId:""})}),c&&h.jsx(D.Button,{icon:h.jsx(Di,{size:16}),onClick:()=>{r(u.id)}})]},u.id)):null,h.jsxs(D.Button,{type:"default",onClick:s,block:!0,children:[h.jsx(br,{size:16})," ",h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})]})]})},iG=t=>null,sG=t=>h.jsx(D.TimePicker,{style:{width:"100%"},use12Hours:!1,format:"HH:mm",value:t.value?jt(t.value,"HH:mm"):null,onChange:e=>{const n=jt(e).format("HH:mm:00");t.onChange&&(t==null||t.onChange(n))}}),{Text:aG}=D.Typography,YA=t=>h.jsx("div",{className:"ce-tag_input label-field",children:h.jsx("p",{children:h.jsx(D.Tooltip,{title:t.value,color:"cyan",placement:"topLeft",children:h.jsx(aG,{ellipsis:!0,copyable:{text:t.value},children:t.value})})})}),lG=({value:t=[],onChange:e,...n})=>{const[r,o]=y.useState([]);y.useEffect(()=>{const f=Array.isArray(t)?t:[];o(f.map(p=>({...p,id:p.id??In()})))},[t]);const i=Ot(),s=f=>{const p=r.filter(m=>m.id!==f);o(p),e==null||e(p)},a=()=>{const f={field:"",dataType:"string",desc:"",required:!1,id:In()},p=[...r,f];o(p),e(p)},l=(f,p)=>{const m=r.map(v=>v.id===f?{...v,field:p}:v);o(m),e(m)},c=(f,p)=>{const m=r.map(v=>v.id===f?{...v,dataType:p}:v);o(m),e(m)},u=(f,p)=>{const m=r.map(v=>v.id===f?{...v,desc:p}:v);o(m),e(m)},d=(f,p)=>{const m=r.map(v=>v.id===f?{...v,required:p}:v);o(m),e(m)};return h.jsxs("div",{className:"workflow-multi-row-extract",children:[r.length?r.map(f=>h.jsxs(D.Space,{size:"small",className:"workflow-multi-row-extract__row",style:{display:"flex",marginBottom:8,width:"100%"},align:"start",children:[h.jsx(D.Input,{value:f.field,onChange:p=>l(f.id,p.target.value),placeholder:"字段名称",status:"",style:{width:130},disabled:!i}),h.jsx(D.Select,{value:f.dataType,onChange:p=>c(f.id,p),placeholder:"数据类型",style:{width:100},disabled:!i,options:[{label:"字符串",value:"string"},{label:"数字",value:"number"},{label:"日期",value:"date"},{label:"布尔",value:"boolean"}]}),h.jsx(D.Input,{value:f.desc,onChange:p=>u(f.id,p.target.value),placeholder:"字段描述",status:"",style:{width:200},disabled:!i}),h.jsx(D.Select,{value:f.required,onChange:p=>d(f.id,p),placeholder:"是否必填",style:{width:100},disabled:!i,options:[{label:"是",value:!0},{label:"否",value:!1}]}),i&&h.jsx(D.Button,{icon:h.jsx(Di,{size:16}),onClick:()=>{s(f.id)}})]},f.id)):null,i&&h.jsx(D.Button,{type:"default",onClick:a,block:!0,icon:h.jsx(br,{size:16}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-field"})})]})},cG=t=>{const e=y.useMemo(()=>In(),[]),{event$:n}=y.useContext(Qr),r=Qm(e),[o,i]=y.useState("");n.useSubscription(a=>{var l;if(a.type==="insert"&&a.currentInputId===e){const c=(o??"")+(t.valueType==="FIX_VALUE"?a.expression.slice(2,-2):a.expression);i(c),(l=t.onChange)==null||l.call(t,c)}}),y.useEffect(()=>{i(t.value)},[t.value]);const s=a=>{var l;i(a.target.value),(l=t.onChange)==null||l.call(t,a.target.value)};return h.jsxs(D.Space.Compact,{block:!0,className:`workflow-password-field${r?` ${od}`:""}`,children:[h.jsx("span",{className:"workflow-password-field__prefix",children:K("link.flow.cipherText")}),h.jsx(D.Input.Password,{id:e,onFocus:()=>{(t.valueType==="JS_EXP"||t.valueType==="FIX_VALUE"||t.valueType==="PLAIN_TEXT"||t.valueType==="PLAIN_CODE")&&(n.emit({type:"visible",visible:!0}),n.emit({type:"setCurrentInputId",currentInputId:e}))},value:o,onChange:s})]})},uG=t=>{var o;const e=In(),{multiple:n,...r}=t;return h.jsx(D.Select,{id:e,style:{borderRadius:6},mode:n?"multiple":void 0,...r,getPopupContainer:i=>i.parentNode,children:(o=t==null?void 0:t.options)==null?void 0:o.map(i=>h.jsx(D.Select.Option,{label:i.label,value:i.value,children:i.label},i.value))})},dG=t=>h.jsx(D.TimePicker,{style:{width:"100%"},value:t.value?jt(t.value,"HH:mm:ss"):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("HH:mm:ss")))}}),El=()=>$t().flowId,fG=["sample","test","payload","body"],hG=["测试","样本","sample","test","payload","body"],XA=t=>{var n,r,o;return[xe.JSON,xe.TEXTAREA,xe.FIXED_OBJ].includes(t.page_control)?!0:((o=(r=(n=t.value_type)==null?void 0:n.toLowerCase)==null?void 0:r.call(n))==null?void 0:o.includes("json"))??!1},JA=(t,e)=>{if(!t)return!1;const n=t.toLowerCase();return e.some(r=>n.includes(r))},pG=t=>{if(t==null)return;const e=(t==null?void 0:t.data)!==void 0?t.data:t;if(typeof e=="string")try{const n=JSON.parse(e);return JSON.stringify(n,null,2)}catch{return e}try{return JSON.stringify(e,null,2)}catch{return}},mG=t=>{const{form:e,configList:n=[],disabled:r,...o}=t;a0();const[i,s]=y.useState(!1),[a,l]=y.useState(0),c=y.useRef(void 0),u=El(),d=y.useMemo(()=>{const m=n.find(v=>XA(v)&&(JA(v.name,fG)||JA(v.display_name,hG)));return m||n.find(v=>XA(v))},[n]),f=y.useCallback(()=>{c.current&&(clearInterval(c.current),c.current=void 0)},[]);y.useEffect(()=>()=>{f()},[f]);const p=y.useCallback(async()=>{if(!u){D.message.warning("缺少连接流ID,无法监听Webhook");return}if(!(d!=null&&d.name)){D.message.warning("未找到测试数据字段,无法填充监听结果");return}if(!i){s(!0),l(10),c.current=setInterval(()=>{l(m=>m<=1?(f(),0):m-1)},1e3);try{const m=await Fy(u,{timeout_seconds:10}),v=pG(m);v?(e.setFieldsValue({[d.name]:v}),D.message.success("已捕获Webhook推送数据并填充测试样例")):D.message.info("监听结束,暂无新的推送数据")}catch(m){console.error("监听Webhook失败:",m),D.message.error("监听失败,请稍后重试")}finally{f(),s(!1),l(0)}}},[u,e,i,d==null?void 0:d.name,f]);return h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},className:"web-hook",children:[h.jsx("div",{style:{flex:1},className:"web-hook-input",children:h.jsx(YA,{...o})}),h.jsx(D.Button,{size:"small",type:"primary",ghost:!0,onClick:p,disabled:r||!(d!=null&&d.name),loading:i,style:{height:32,minWidth:110,display:"inline-flex",alignItems:"center",justifyContent:"center"},children:i?`监听中${a?`(${a}s)`:""}`:"监听"})]})},gG={configFormContainer:"_configFormContainer_1frpl_1"};function wG(t){return Lq(t==null?void 0:t.credentials)}const bG=t=>String(t.type).toUpperCase();function QA(t){var e,n;return(n=(e=t==null?void 0:t.input_fields)==null?void 0:e.find(r=>bG(r)==="PROXY"))==null?void 0:n.key}function ZA(t){return t==null||t===""?"0":String(t)}function vG(t,e,n){const r=QA(e);return r?{...t,[r]:ZA(n??t[r])}:t}function yG(t,e){const n=QA(e);if(!n)return{properties:t};const r={...t},o=ZA(r[n]);return delete r[n],{properties:r,proxyId:o}}const eO=({field:t,disabled:e,readOnly:n,context:r,value:o="",onChange:i,id:s,allowVariableInsert:a,hasModeSwitch:l})=>{const c=uC(),u=y.useId(),d=s||`workflow-code-${u}`,f=y.useRef(null),[p,m]=y.useState(0),v=!e&&!n,b=y.useCallback(_=>{var x;if(!a)return;const S=(x=f.current)==null?void 0:x.view,E=S==null?void 0:S.state.selection.main;if(!S||!E){i==null||i(`${o}${_}`);return}S.dispatch({changes:{from:E.from,to:E.to,insert:_},selection:{anchor:E.from+_.length}}),S.focus()},[a,i,o]),w=oC(d,_=>b(_),()=>{var _,S;return(S=(_=f.current)==null?void 0:_.view)==null?void 0:S.focus()}),g=Mh(),C=(g==null?void 0:g.activeFieldId)===d,k=y.useCallback(()=>{if(v)try{i==null||i(JSON.stringify(JSON.parse(o),null,2))}catch{D.message.warning(K("link.flow.format_json_failed"))}},[v,i,o]);return h.jsx(bC,{id:d,canEditInEditor:v,openEditorNumber:p,nodeId:c.nodeId||r.nodeId||"",value:o,language:"json",showVariableSidebar:a,onFinish:i,children:h.jsxs("div",{style:{position:"relative"},className:C?od:void 0,children:[h.jsx(nd,{id:d,ref:f,value:o,readOnly:!v,height:"220px",placeholder:t.placeholder,theme:Cm,extensions:[$A()],onFocus:()=>{v&&a&&w.activate()},onChange:i}),v?h.jsxs(D.Space,{size:4,style:{position:"absolute",right:8,top:6,zIndex:2},children:[h.jsx(D.Tooltip,{title:K("link.flow.format_json"),children:h.jsx(D.Button,{type:"text",size:"small","aria-label":K("link.flow.format_json"),icon:h.jsx(se.FormatPainterOutlined,{}),onClick:k,style:{color:"#fff"}})}),h.jsx(D.Tooltip,{title:K("link.flow.open_code_editor"),children:h.jsx(D.Button,{type:"text",size:"small","aria-label":K("link.flow.open_code_editor"),icon:h.jsx(se.FullscreenOutlined,{}),onClick:()=>m(_=>_+1),style:{color:"#fff"}})})]}):null]})})};eO.displayName="WorkflowCodeEditor";const tO=({field:t,disabled:e,readOnly:n,context:r,value:o,onChange:i,id:s})=>{const a=typeof o=="string"?o:o==null?"":JSON.stringify(o)??"",l=!!t.valueModePolicy,c=t.valueModePolicy==="EXPRESSION"||t.valueModePolicy==="BOTH",u=d=>h.jsx(eO,{...d,field:t,context:r,id:s,allowVariableInsert:c,hasModeSwitch:l});return t.valueModePolicy?h.jsx(ki,{value:a,onChange:d=>i==null?void 0:i(d),valueModePolicy:t.valueModePolicy,disabled:e,readOnly:n,placeholder:t.placeholder,renderNormalMode:u,renderExpressionMode:u,modeSwitchPosition:"top-right",encodeExpressionValue:!0}):u({value:a,onChange:d=>i==null?void 0:i(d),disabled:e,readOnly:n,placeholder:t.placeholder})};tO.displayName="WorkflowCodeFieldControl";const CG=dt(tO,{needsFormItemName:!0,supportsVariableInsert:!0}),nO=({disabled:t,readOnly:e,value:n,onChange:r,id:o})=>{const[i,s]=y.useState([]),[a,l]=y.useState(!1);y.useEffect(()=>{let d=!1;return l(!0),Kf().then(f=>{d||s(Array.isArray(f)?f:[])}).catch(()=>{d||D.message.error(K("link.flow.request_failed"))}).finally(()=>{d||l(!1)}),()=>{d=!0}},[]);const c=y.useMemo(()=>[{value:"0",label:h.jsx(Te.FormattedMessage,{id:"link.flow.do_not_use"})},...i.map(d=>({value:String(d.id),label:d.group_name||String(d.id)}))],[i]),u=n==null||n===""?"0":String(n);return h.jsx(D.Select,{id:o,className:"proxy_id_select",value:u,options:c,loading:a,disabled:t||e,dropdownStyle:{zIndex:99999999999},onChange:d=>r==null?void 0:r(String(d)),style:{width:"100%"}})};nO.displayName="WorkflowProxyFieldControl";const kG=dt(nO,{needsFormItemName:!0,supportsVariableInsert:!0}),SG=[{type:ge.CODE,definition:CG},{type:ge.PROXY,definition:kG}];function EG({children:t}){return h.jsx(fC,{additionalRegistrations:SG,children:t})}function xl(){const{event$:t}=y.useContext(Qr),e=Fh();return y.useCallback(n=>{var o;const r=document.activeElement;if(r&&r!==document.body&&r.contains(n.target)){const i=n.target;if(!["INPUT","TEXTAREA","SELECT"].includes((i==null?void 0:i.tagName)??""))return}(o=t==null?void 0:t.emit)==null||o.call(t,{type:"setCurrentInputId",currentInputId:""}),e==null||e.deactivateField()},[t,e])}const xG=[xe.TEXT,xe.PASSWORD,xe.SELECT,xe.EXTEND_OBJ,xe.DATE,xe.TIME,xe.DATETIME,xe.TEXTAREA,xe.FIXED_OBJ,xe.JSON],DG="[workflow:schema-render]",_G=/^\{\{([^.{}]+)\.(.+)\}\}$/,AG=t=>{switch(t.page_control){case xe.SELECT:case xe.API_SELECT:return t.multi_valued?[]:null;case xe.EXTEND_OBJ:return{};case xe.HIDDEN:return"";case xe.TEXT:return"";case xe.PASSWORD:return"";case xe.LABEL:return"";case xe.DATE:return null;case xe.TIME:return null;case xe.DATETIME:return null;case xe.TEXTAREA:return"";case xe.FIXED_OBJ:return{};case xe.MultiRowAIExtractConfig:return[];case xe.JSON:return""}},rO=(t,e,n,r,o)=>{const i=t.display_name,s=()=>{var a,l,c;switch(t.page_control){case xe.SELECT:return h.jsx(uG,{options:Zg(t.option_value_objects??t.option_values),multiple:t.multi_valued});case xe.API_SELECT:return h.jsx(eG,{options:Zg(t.option_value_objects??t.option_values)});case xe.EXTEND_OBJ:return h.jsx(oG,{valueType:t.value_type});case xe.HIDDEN:return h.jsx(iG,{});case xe.TEXT:return h.jsx(Pn,{valueType:t.value_type,nodeId:e});case xe.PASSWORD:return h.jsx(cG,{valueType:t.value_type});case xe.LABEL:return(a=r==null?void 0:r.webhookField)!=null&&a.enabled&&t.name==="hookUrl"&&r.webhookField.form?h.jsx(mG,{form:r.webhookField.form,configList:r.webhookField.configList,disabled:r.webhookField.disabled}):h.jsx(YA,{});case xe.DATE:return h.jsx(tG,{});case xe.TIME:return h.jsx(dG,{});case xe.DATETIME:return h.jsx(nG,{});case xe.TEXTAREA:return h.jsx(Pn,{valueType:t.value_type,textAreaMode:!0,nodeId:e});case xe.FIXED_OBJ:return h.jsx(D.Input.TextArea,{});case xe.JSON:return h.jsx(Pn,{valueType:t.value_type,nodeId:e});case xe.MultiRowAIExtractConfig:return h.jsx(lG,{valueType:t.value_type});case xe.MULTI_SELECT_LIST:return h.jsx(rG,{selectType:"KNOWLEDGE_BASE"});case xe.SYNC_HOUR_MINUTE:return h.jsx(sG,{});case xe.AUTH_TOKEN:return h.jsx(Rq,{disabled:(l=r==null?void 0:r.webhookField)==null?void 0:l.disabled});case xe.SECRET_KEY:return h.jsx(Yq,{});case xe.SELECT_CLIENT:return h.jsx(Qq,{});default:{const u=(c=o==null?void 0:o.form)==null?void 0:c.find(d=>d.name===t.page_control);return u?h.jsx(u.component,{config:t,configList:r==null?void 0:r.configList,disabled:r==null?void 0:r.disabled,form:r==null?void 0:r.form,mcpMode:n,nodeId:e}):(console.warn(`unknown form item: page_control:${t.page_control}`),null)}}};return n&&xG.includes(t.page_control)?h.jsx("div",{children:h.jsx(D.Form.Item,{required:t.required,rules:[{required:t.required,message:t.page_control===xe.SELECT?K("link.flow.please_select")+t.display_name:K("link.flow.please_enter")+t.display_name}],label:i,name:t.name,children:h.jsx(Zq,{children:s()})})},t.ui_id):h.jsx(D.Form.Item,{required:t.required,style:t.page_control===xe.HIDDEN?{display:"none"}:{},rules:[{required:t.required,message:t.page_control===xe.SELECT?K("link.flow.please_select")+t.display_name:K("link.flow.please_enter")+t.display_name},{validator(a,l,c){if(t.page_control===xe.MultiRowAIExtractConfig)if(Array.isArray(l)&&t.required){const u=l.some(d=>!d.field||!d.dataType||!d.desc||d.required==null);c(u?"请填写完整配置":void 0)}else c(void 0);else c(void 0)}}],label:i,name:t.name,children:s()},t.ui_id)},OG=t=>(t.child_conditions??[]).map(e=>e.left).filter(e=>!!e),TG=(t,e)=>{if(!t.is_child)return!0;const n=t.child_conditions??[];return n.length?n.some(({left:r,operator:o,right:i})=>{const s=e==null?void 0:e[r];return o==="EQUALS"?s===i:s!==i}):!0},NG=y.forwardRef((t,e)=>{var we,fe;const{action:n,connector:r,nodeId:o,account_id:i,mcpMode:s,nodeType:a}=t,l=$t(),c=ne.useStoreApi(),u=xl(),d=Et.useReactive({proxyId:"0"}),{config_schema:f,proxy_id:p,protocol:m,account_schema_id:v}=n;a??n.node_type??n.type;const b=n.action_key||n.nodeKey,w=n.action_ver??n.nodeVersion,g=Array.isArray(f==null?void 0:f.sub_params),C=po(n),k=y.useMemo(()=>!C||!b?null:`${b}@${w??"latest"}`,[C,b,w]),_=k?`${o}:${k}`:o,S=n.account_id??i,E=y.useMemo(()=>k?Wi(b,w):null,[k,b,w]),[x,O]=y.useState(()=>k&&E?{identity:k,schema:E,loading:!1,finished:!0}:null),A=(x==null?void 0:x.identity)===k?x:null,T=(A==null?void 0:A.schema)??null,B=rw((T==null?void 0:T.credentials)??[]),I=!!(C&&b&&!T&&((A==null?void 0:A.loading)??!(A!=null&&A.finished))),F=wG(T);y.useEffect(()=>{!x||x.identity},[k,x,o,b,w]),y.useEffect(()=>{p&&(d.proxyId=p)},[p,d]);const[N]=D.Form.useForm(),[P,M]=y.useState(S);y.useEffect(()=>{M(S)},[_,S,M]);const z=y.useMemo(()=>{var le;return g?(le=f.sub_params)==null?void 0:le.reduce((Se,ce)=>{let Fe=ce.value;return ce.page_control===xe.EXTEND_OBJ&&(Fe=_q(Fe)),Se[ce.name]=Fe??AG(ce),Se},{}):{}},[f==null?void 0:f.sub_params,g]);y.useEffect(()=>{g&&(N.resetFields(),N.setFieldsValue({...z}))},[z,N,g,o]);const H=y.useRef(null),R=y.useRef(null);y.useEffect(()=>{if(!k||!b){O(null);return}const le=Wi(b,w);if(le){O({identity:k,schema:le,loading:!1,finished:!0});return}let Se=!1;return O({identity:k,schema:null,loading:!0,finished:!1}),pc(b,w).then(ce=>{Se||O({identity:k,schema:ce,loading:!1,finished:!0})}).catch(ce=>{Se||(O({identity:k,schema:null,loading:!1,finished:!0}),console.error(`${DG} classic renderer next schema load failed`,{nodeId:o,nodeKey:b,nodeVersion:w,err:ce}))}),()=>{Se=!0}},[k,o,b,w]);const Y=y.useMemo(()=>{var le;return(le=T==null?void 0:T.input_fields)!=null&&le.length?KI(WA(T.input_fields),T.key):null},[T]),te=!!(C&&(Y||F||T)),$=y.useMemo(()=>{const le=n.properties?ha(n.properties):f&&C?ha(f):n.params?ha(n.params):{},Se=vG(le,T,p);return uc(b)?ra(Se).properties:Se},[n,f,C,T,b,p]),j=y.useMemo(()=>JSON.stringify($??{}),[$]);y.useEffect(()=>{!C||!te||(N.resetFields(),N.setFieldsValue($))},[_,N,C,$,j,te]);const U=y.useRef(null);y.useEffect(()=>{U.current=null},[_]),y.useEffect(()=>{uc(b)&&(U.current=JSON.stringify(ra($).branches.map(le=>[le.id,le.name])))},[$,b]);const ee=y.useCallback(le=>{const Se=le.trim().match(_G);if(!Se)return null;const ce=Se[1],Fe=Se[2];if(ce==="global")return null;const Ve=ce.startsWith("N")?ce.slice(1):ce,je=c.getState().nodes.find(We=>We.id===Ve);return je?{fieldPath:Fe,node:je,variableNodeId:ce}:null},[c]),ie=y.useCallback(le=>{var Se;return((Se=ee(le))==null?void 0:Se.fieldPath)??le.replace(/^\{\{|\}\}$/g,"")},[ee]),be=y.useCallback(le=>{var je;const Se=ee(le);if(!Se)return le;const ce=(je=Se.node)==null?void 0:je.data,Fe=(ce==null?void 0:ce.label)||(ce==null?void 0:ce.name)||(ce==null?void 0:ce.action_name)||Se.variableNodeId,Ve=ce!=null&&ce.note?` (${ce.note})`:"";return`${Fe}${Ve}.${Se.fieldPath}`},[ee]),[W,X]=y.useState(!1),q=(le,Se)=>(X(!0),N.validateFields().then(async ce=>{var Ve,je,We,ht,Ee;if(te){Se&&((je=(Ve=H==null?void 0:H.current)==null?void 0:Ve.onIgnoreNodeStart)==null||je.call(Ve));const{properties:Ce,proxyId:Le}=yG(ce,T);return t.onSubmit({properties:Ce,account_id:P,proxy_id:Le},le)}const Fe=Pt.cloneDeep(n.config_schema);return Fe.sub_params.forEach(Ce=>{let Le=ce[Ce.name];Ce.page_control===xe.EXTEND_OBJ&&Le!=="{{$fromAI}}"&&(Le=ew(Le)),Ce.value=Le??null}),Se&&((ht=(We=H==null?void 0:H.current)==null?void 0:We.onIgnoreNodeStart)==null||ht.call(We)),!i&&m==="HTTP"&&(r==null?void 0:r.deployment_type)!=="SaasApp"&&(Fe.proxy_id=(Ee=R.current)==null?void 0:Ee.getProxyId()),t.onSubmit(Fe,le)}).catch(ce=>(console.log("err",ce),D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>X(!1)));y.useImperativeHandle(e,()=>({saveConfig:le=>q(le,!1)}));const J=Ot(),re={form:N,configList:(f==null?void 0:f.sub_params)??[],disabled:!J,...m==="WEBHOOK"?{webhookField:{enabled:!0,form:N,configList:(f==null?void 0:f.sub_params)??[],disabled:!J}}:{}},Z=le=>{const Se=le.page_control!==xe.HIDDEN?h.jsx("p",{className:"field-desc",children:le.description}):null;if(!le.is_child)return h.jsxs("div",{children:[rO(le,o,s,re,l.canvas.registerComponents),Se]},le.ui_id);const ce=OG(le);return h.jsx(D.Form.Item,{noStyle:!0,shouldUpdate:(Fe={},Ve={})=>le.is_child?ce.length?ce.some(je=>(Fe==null?void 0:Fe[je])!==(Ve==null?void 0:Ve[je])):!0:!1,children:()=>{const Fe=N.getFieldsValue(!0);return TG(le,Fe)?h.jsxs("div",{children:[rO(le,o,s,re,l.canvas.registerComponents),Se]}):null}},le.ui_id)};if(C&&I)return h.jsx("div",{style:{textAlign:"center",padding:40},children:h.jsx(D.Spin,{})});const ue=!t.preRender&&(((we=n.config_schema)==null?void 0:we.sub_params)??[]).length<1,ve=h.jsx("div",{style:{padding:16,color:"#999",textAlign:"center"},children:"该节点暂无配置项"});if(te){const le=h.jsxs(h.Fragment,{children:[t.preRender&&t.preRender,F?h.jsx(RA,{credentialRequirements:B,value:P,onChange:M,linkApp:r,disabled:!J}):null]});return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:u,children:[h.jsx("div",{className:"workflow-node-form-scroll",children:Y?h.jsx(EG,{children:h.jsx(Xg,{schema:Y,form:N,initialValues:$,showSubmit:!1,showReset:!1,nodeId:o,mcpMode:s,renderVariableTag:ie,renderVariableTooltip:be,customTheme:sc,preRender:le},_)}):ve}),h.jsx("div",{className:"workflow-node-form-footer",children:J&&h.jsx(D.Button,{type:"primary",disabled:!J,loading:W,className:"workflow-node-form-save",onClick:()=>q(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:u,children:[h.jsxs(D.Form,{form:N,disabled:!J,layout:"vertical",className:`${gG.configFormContainer} workflow-config-form workflow-node-form-scroll`,children:[t.preRender&&t.preRender,(r==null?void 0:r.id)&&n.config_schema&&((fe=f==null?void 0:f.sub_params)==null?void 0:fe.map(le=>Z(le))),!i&&m==="HTTP"&&(r==null?void 0:r.deployment_type)!=="SaasApp"?h.jsx(Jg,{proxyId:d.proxyId,ref:R}):null,ue&&ve]}),h.jsx("div",{className:"workflow-node-form-footer",children:J&&h.jsx(D.Button,{type:"primary",disabled:!J,loading:W,className:"workflow-node-form-save",onClick:()=>q(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),BG=y.memo(y.forwardRef((t,e)=>{const{nodeId:n,data:r}=t,{account_id:o,account_schema_id:i}=r,s=Et.useReactive({account_id:o}),a=y.useRef(null);y.useImperativeHandle(e,()=>({saveConfig:p=>{var m;return(m=a.current)==null?void 0:m.saveConfig(p)}}));const l=y.useMemo(()=>({id:t.data.connector_id,name:t.data.connector_name,deployment_type:t.data.deployment_type}),[t.data.connector_id,t.data.connector_name,t.data.deployment_type]),c=po(t.data),u=(p,m)=>{if(c){const v=ha(p),w=Object.hasOwn(p??{},"account_id")?p.account_id??null:s.account_id;return t.onSubmit({properties:v,account_id:w,proxy_id:(p==null?void 0:p.proxy_id)??(v==null?void 0:v.proxy_id)},m)}return t.onSubmit({properties:p,account_id:s.account_id,proxy_id:p.proxy_id},m)},d=y.useCallback(p=>{s.account_id=p??null},[]);let f=null;return i&&!c&&(f=h.jsx(RA,{onChange:d,actionAccountSchemaId:i,value:s.account_id,linkApp:l})),h.jsx("div",{className:"workflow-action-node-config",children:h.jsx(NG,{ref:a,action:t.data,nodeType:t.nodeType||t.data.node_type||t.data.type,connector:l,account_id:o,nodeId:n,onSubmit:u,onNodePackageValuesChange:t.onNodePackageValuesChange,preRender:f})})}),(t,e)=>t.nodeId===e.nodeId&&t.nodeType===e.nodeType&&Pt.isEqual(Pt.omit(t.data,["isHovered"]),Pt.omit(e.data,["isHovered"])));var $n=(t=>(t.IDLE="idle",t.SAVING="saving",t.SAVED="saved",t.ERROR="error",t))($n||{}),Wd=(t=>(t.SELECTION="selection",t.ALL="all",t))(Wd||{}),er=(t=>(t.UNPUBLISHED="UNPUBLISHED",t.ONLINE="ONLINE",t.OFFLINE="OFFLINE",t.ON_WARN="ON_WARN",t.OFF_WARN="OFF_WARN",t.ONLINE_ING="ONLINE_ING",t))(er||{}),nt=(t=>(t.eq="eq",t.ne="ne",t.sw="sw",t.nsw="nsw",t.ew="ew",t.ewn="ewn",t.gt="gt",t.ge="ge",t.lt="lt",t.le="le",t.co="co",t.nco="nco",t.in="in",t.nin="nin",t.is_null="is_null",t.is_not_null="is_not_null",t))(nt||{});const oO=[{operator:nt.eq,label:K("common.eq")},{operator:nt.ne,label:K("common.ne")},{operator:nt.sw,label:K("common.sw")},{operator:nt.nsw,label:K("common.nsw")},{operator:nt.ew,label:K("common.ew")},{operator:nt.ewn,label:K("common.ewn")},{operator:nt.gt,label:K("common.gt")},{operator:nt.ge,label:K("common.ge")},{operator:nt.lt,label:K("common.lt")},{operator:nt.le,label:K("common.le")},{operator:nt.co,label:K("common.co")},{operator:nt.nco,label:K("common.nco")},{operator:nt.in,label:K("common.in")},{operator:nt.nin,label:K("common.nin")},{operator:nt.is_null,label:K("common.is_null")},{operator:nt.is_not_null,label:K("common.is_not_null")}];nt.eq+"",K("common.eq"),nt.ne+"",K("common.ne"),nt.sw+"",K("common.sw"),nt.nsw+"",K("common.nsw"),nt.ew+"",K("common.ew"),nt.ewn+"",K("common.ewn"),nt.gt+"",K("common.gt"),nt.lt+"",K("common.lt"),nt.ge+"",K("common.ge"),nt.co+"",K("common.co"),nt.nco+"",K("common.nco"),nt.le+"",K("common.le"),nt.in+"",K("common.in"),nt.nin+"",K("common.nin"),nt.is_null+"",K("common.is_null"),nt.is_not_null+"",K("common.is_not_null");const iw=t=>t===nt.is_null||t===nt.is_not_null,FG=(t,e="")=>iw(t)?"":e,{Option:MG}=D.Select,IG=y.forwardRef((t,e)=>{const{config_schema:n}=t,[r]=D.Form.useForm(),o=xl(),s=(d=>d!=null&&d.or_list?{or_list:d.or_list.map(p=>({and_list:p.and_list.map(m=>({query:m.query||"",operator:m.operator||"",value:m.value||""}))}))}:{or_list:[{and_list:[{query:"",operator:"",value:""}]}]})(n),[a,l]=y.useState(!1),c=(d,f,p="")=>(l(!0),r.validateFields().then(async m=>t.onSubmit({properties:m},d)).catch(()=>(D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>l(!1)));y.useImperativeHandle(e,()=>({saveConfig:d=>c(d)}));const u=Ot();return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:o,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsx(D.Form,{disabled:!u,form:r,initialValues:s,layout:"vertical",autoComplete:"off",children:h.jsx(D.Form.List,{name:"or_list",children:(d,{add:f,remove:p})=>h.jsxs(h.Fragment,{children:[d.map((m,v)=>h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"form-block",children:h.jsxs("div",{style:{padding:12,width:"100%",boxSizing:"border-box"},children:[v>0&&u&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsx(D.Button,{type:"link",style:{color:"red"},icon:h.jsx(se.MinusCircleOutlined,{style:{color:"red"}}),onClick:()=>p(m.name),children:h.jsx(Te.FormattedMessage,{id:"link.flow.remove"})})}),h.jsx(D.Form.List,{name:[m.name,"and_list"],children:(b,{add:w,remove:g})=>h.jsx(h.Fragment,{children:b.map((C,k)=>h.jsxs(D.Space,{direction:"vertical",style:{width:"100%",rowGap:0},children:[h.jsxs(D.Space,{align:"center",className:`form-item-row ${k>0?"opt":""}`,children:[h.jsx(D.Form.Item,{style:{minWidth:150},name:[C.name,"query"],label:K("app.common.word.variable-name"),rules:[{required:!0,message:K("link.flow.please_enter_variable_name")}],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),h.jsx(D.Form.Item,{name:[C.name,"operator"],label:K("app.common.word.condition"),rules:[{required:!0,message:K("link.flow.please_select_condition")}],children:h.jsx(D.Select,{style:{minWidth:140},placeholder:K("link.flow.select_condition"),getPopupContainer:_=>_.parentNode,children:oO.map(_=>h.jsx(MG,{value:_.operator,children:_.label},_.operator))})}),h.jsx(D.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const _=r.getFieldValue(["or_list",m.name,"and_list",C.name,"operator"]);return iw(_)?null:h.jsx(D.Form.Item,{style:{minWidth:150},name:[C.name,"value"],label:K("app.common.word.value"),rules:[],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),k>0&&h.jsx(D.Button,{type:"link",icon:h.jsx(se.MinusCircleOutlined,{}),onClick:()=>g(C.name)})]}),k<b.length-1&&h.jsx(D.Divider,{plain:!0,children:h.jsx(D.Tag,{color:"#999999",children:h.jsx(Te.FormattedMessage,{id:"link.flow.and"})})}),k===b.length-1&&h.jsx(D.Button,{type:"link",disabled:!u,icon:h.jsx(br,{size:16}),className:"small",onClick:()=>w({query:"",operator:"",value:""}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-new-and"})})]},C.key))})})]})},m.key),v<d.length-1&&h.jsxs("div",{className:"test",style:{textAlign:"center"},children:[" ",h.jsx(D.Divider,{style:{color:"orange"},dashed:!0,children:h.jsx(D.Tag,{color:"#1890ff",children:h.jsx(Te.FormattedMessage,{id:"link.flow.or"})})})]})]})),h.jsx(D.Form.Item,{style:{display:"flex",justifyContent:"flex-end",marginBlock:10},children:h.jsx(D.Button,{type:"default",icon:h.jsx(br,{size:16}),disabled:!u,onClick:()=>f({and_list:[{query:"",operator:"",value:""}]}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-or"})})})]})})})}),h.jsx("div",{className:"workflow-node-form-footer",children:u&&h.jsx(D.Button,{type:"primary",disabled:!u,loading:a,className:"workflow-node-form-save",onClick:()=>c(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),PG={copy:"Copy JSON",copySuccess:"JSON copied to clipboard",download:"Download JSON",invalidJson:"Invalid JSON data"},LG={copy:"复制JSON",copySuccess:"JSON已复制到剪贴板",download:"下载JSON",invalidJson:"无效的JSON数据"},{Text:$G}=D.Typography,zG=({data:t,height:e=400,enableCopy:n=!0,theme:r="light",className:o="",locale:i="zh",maxHeight:s})=>{const[a,l]=y.useState(r),c=y.useRef(null),u=i==="zh"?LG:PG,d=y.useMemo(()=>{if(!t)return null;try{return typeof t=="string"?JSON.parse(t):t}catch(w){return console.error("JSON解析失败:",w),null}},[t]),f=y.useMemo(()=>{if(!d)return[];const w=(g,C=[],k=0)=>{const _=[];if(g===null)return[{key:C.join("."),value:null,type:"null",path:C,level:k}];if(Array.isArray(g)){const S={key:C.join("."),value:g,type:"array",path:C,level:k,children:[]};g.forEach((E,x)=>{var T;const O=[...C,x.toString()],A=w(E,O,k+1);(T=S.children)==null||T.push(...A)}),_.push(S)}else if(typeof g=="object"){const S={key:C.join("."),value:g,type:"object",path:C,level:k,children:[]};Object.entries(g).forEach(([E,x])=>{var T;const O=[...C,E],A=w(x,O,k+1);(T=S.children)==null||T.push(...A)}),_.push(S)}else{const S=typeof g;_.push({key:C.join("."),value:g,type:S,path:C,level:k})}return _};return w(d)},[d]),p=y.useCallback(()=>{const w=JSON.stringify(d,null,2);navigator.clipboard.writeText(w).then(()=>{D.message.success(u.copySuccess)})},[d,u]),m=y.useCallback(()=>{const w=JSON.stringify(d,null,2),g=new Blob([w],{type:"application/json"}),C=URL.createObjectURL(g),k=document.createElement("a");k.href=C,k.download="data.json",k.click(),URL.revokeObjectURL(C)},[d]),v=y.useCallback(w=>{switch(w.type){case"string":return h.jsxs("span",{className:"json-string",children:['"',String(w.value),'"']});case"number":return h.jsx("span",{className:"json-number",children:String(w.value)});case"boolean":return h.jsx("span",{className:"json-boolean",children:String(w.value)});case"null":return h.jsx("span",{className:"json-null",children:"null"});default:return null}},[]),b=y.useCallback((w,g)=>{var _;const C=w.children&&w.children.length>0,k=w.path[w.path.length-1];return w.type==="object"||w.type==="array"?h.jsxs("div",{className:"json-node",children:[h.jsxs("div",{className:"json-line",style:{paddingLeft:`${w.level*16}px`},children:[k&&h.jsxs("span",{className:"json-key",children:['"',k,'": ']}),h.jsx("span",{className:"json-bracket",children:w.type==="array"?"[":"{"}),!C&&h.jsx("span",{className:"json-bracket",children:w.type==="array"?"]":"}"})]}),C&&h.jsxs(h.Fragment,{children:[(_=w.children)==null?void 0:_.map((S,E)=>b(S,g+E+1)),h.jsx("div",{className:"json-line",style:{paddingLeft:`${w.level*16}px`},children:h.jsx("span",{className:"json-bracket",children:w.type==="array"?"]":"}"})})]})]},w.key):h.jsx("div",{className:"json-node",children:h.jsxs("div",{className:"json-line",style:{paddingLeft:`${w.level*16}px`},children:[k&&h.jsxs("span",{className:"json-key",children:['"',k,'": ']}),v(w)]})},w.key)},[v]);return y.useCallback(()=>{l(a==="dark"?"light":"dark")},[a]),d?h.jsxs("div",{className:`json-renderer ${a} ${o}`,children:[h.jsx("div",{className:"json-toolbar",children:h.jsxs(D.Space,{children:[n&&h.jsx(D.Tooltip,{title:u.copy,children:h.jsx(D.Button,{icon:h.jsx(se.CopyOutlined,{}),size:"small",onClick:p})}),h.jsx(D.Tooltip,{title:u.download,children:h.jsx(D.Button,{icon:h.jsx(se.DownloadOutlined,{}),size:"small",onClick:m})})]})}),h.jsx("div",{ref:c,className:"json-content",style:{height:`${e}px`,maxHeight:s?`${s}px`:void 0},children:f.map((w,g)=>b(w,g))})]}):h.jsx("div",{className:`json-renderer error ${a} ${o}`,children:h.jsx("div",{className:"error-message",children:h.jsx($G,{type:"secondary",children:u.invalidJson})})})},{TextArea:HG}=D.Input,{Title:VG}=D.Typography,iO=({status:t,result:e="",progress:n=60,runningAction:r="run",showAlert:o=!0,canEdit:i=!0,disabledReason:s="当前节点不支持手动测试",editing:a=!1,editableValue:l="",onEditableValueChange:c,onRun:u,onIgnore:d,onReset:f,onToggleEdit:p,onDismissAlert:m,className:v,onClose:b,onExpandPanel:w})=>{const g=t==="running",C=t==="failure",k=t==="ignored",_=t==="success"||k,S=t==="disabled",[E,x]=y.useState(!1);return h.jsxs("section",{className:["node-test-container","ai-flow-node-test-panel",v].filter(Boolean).join(" "),"aria-label":"AI FLOW 节点测试",children:[h.jsx("div",{className:"node-test-header",children:h.jsxs("div",{className:"header-title",children:[h.jsx("span",{className:"common-icon title-icon"}),h.jsx(VG,{level:4,children:"节点测试"}),h.jsx(D.Button,{ghost:!0,className:"close-btn",onClick:b,children:h.jsx(Di,{size:16})})]})}),h.jsxs("div",{className:"test-content",children:[i&&!S?h.jsxs("div",{className:"action-buttons",children:[h.jsx(D.Button,{type:"primary",disabled:S,onClick:u,loading:g&&r==="run",className:"test-button",children:g?"测试中...":"开始测试"}),h.jsx(D.Button,{type:"default",disabled:S||g&&r==="run",onClick:d,loading:g&&r==="ignore",className:"ignore-button",children:"忽略调试"})]}):null,i&&e?h.jsx("div",{className:"action-buttons",children:h.jsx(D.Button,{onClick:f,className:"reset-button",children:"重置"})}):null,g?h.jsxs(h.Fragment,{children:[h.jsx(D.Progress,{percent:n,status:"active",className:"test-progress"}),h.jsx(D.Skeleton,{active:!0,className:"result-skeleton"})]}):h.jsxs(h.Fragment,{children:[C&&o?h.jsx(D.Alert,{className:"error-alert small",showIcon:!0,message:"测试未通过",description:"请检查节点配置和接口返回后重试",type:"error",closable:!1,onClose:m}):null,_&&o?h.jsx(D.Alert,{className:"success-alert small",showIcon:!0,message:k?"忽略调试成功":"测试成功",description:k?"已将样本数据设为当前节点输出":"节点运行正常,可在下方查看返回结果",type:"success",closable:!1,onClose:m}):null,e?h.jsx(D.Card,{styles:{body:{padding:0}},title:h.jsxs("div",{className:"result-header",children:[h.jsx("div",{className:"result-title",children:C?h.jsxs(h.Fragment,{children:[h.jsx(se.CloseCircleFilled,{className:"error-icon"})," 错误数据"]}):h.jsxs(h.Fragment,{children:[k?h.jsx(se.ExperimentFilled,{className:"success-icon"}):h.jsx(se.CheckCircleFilled,{className:"success-icon"}),k?"样本数据":"测试结果"]})}),h.jsxs("div",{style:{display:"inline-flex",gap:8},children:[i&&p?h.jsx(D.Button,{size:"small",type:"default",variant:"solid",onClick:p,className:"edit-button",children:a?"完成":"编辑"}):null,w&&h.jsx(D.Button,{size:"small",type:E?"primary":"default",variant:"solid",className:"edit-button",onClick:()=>{const O=!E;w(O),x(O)},children:E?h.jsx(SW,{size:16}):h.jsx(kW,{size:16})})]})]}),variant:"borderless",className:`result-card ${C?"error-result":"success-result"}`,children:a?h.jsx(HG,{rows:E?20:10,value:l,onChange:O=>c==null?void 0:c(O.target.value),className:"result-editor"}):h.jsx(zG,{data:e,height:E?600:300,enableCopy:!0,theme:"dark"},e)}):h.jsx(D.Card,{variant:"borderless",className:"empty-result",children:h.jsx(D.Result,{icon:h.jsx("span",{className:"common-icon"}),title:S?"不可测试":"等待测试",subTitle:S?s:"点击“开始测试”按钮运行当前节点"})})]})]})]})},jG=new Set([$e.AI_LANGUAGE_MODEL,$e.AI_MEMORY,$e.BUILTIN_MCP,$e.MCP_SERVER]),WG=new Set([]),UG=({canEdit:t,nodeType:e,protocol:n})=>t?n&&jG.has(n)?{disabled:!0,reason:"当前协议节点由所属 AI 或 MCP 运行上下文统一测试"}:e&&WG.has(e)?{disabled:!0,reason:"当前节点类型不支持独立手动测试"}:{disabled:!1}:{disabled:!0,reason:"只读或预览模式下不能执行节点测试"},qG=t=>typeof t=="string"?t.trim().length>0:t!=null,GG=t=>typeof t=="string"&&t.trim().toLowerCase()==="success",RG=t=>{if(!t||typeof t!="object")return!1;const e=t;return e.result===!0?!1:e.result===!1?!0:e.error==="0"&&qG(e.error_description)&&!GG(e.error_description)},KG=t=>RG(t)?me.FAILED:me.SUCCESS,YG=t=>{if(typeof t=="object")return JSON.stringify(t,null,2);if(typeof t=="string")try{const e=JSON.parse(t);return JSON.stringify(e,null,2)}catch{return t}return String(t)};JSON.stringify({result:"示例数据",data:{id:"123",name:"示例"}},null,2);const XG=y.forwardRef((t,e)=>{var O,A,T,B;const{nodeId:n,beforeHook:r,onClose:o,onExpandPanel:i}=t,s=$t(),{handleNodeDataUpdate:a}=Ri(),l=(A=(O=s.nodeConfigPanel)==null?void 0:O.testArea)==null?void 0:A.defaultTestResult,[c,u]=y.useState(()=>{if(l==null)return"";if(typeof l=="string")return l;try{return JSON.stringify(l,null,2)}catch{return String(l)}}),d=ne.useInternalNode(n),f=Et.useReactive({testProgress:0,sampleText:"",isError:!1,showErrorAlert:!1,testing:!1,successShown:!1,sampleMode:!1,sampleSaving:!1,sampleError:"",isIgnoreSuccess:!1,ignoring:!1,editable:!1}),{refreshFlow:p}=ao();(T=d==null?void 0:d.data)==null||T.outputSource,y.useEffect(()=>{if(d!=null&&d.data.output&&(d.data.status===me.SUCCESS||d.data.status===me.RUNNABLE)){const I=typeof d.data.output=="string"?d.data.output:JSON.stringify(d.data.output,null,2);u(I),f.successShown=!0,f.isError=!1,f.showErrorAlert=!1}else if(d!=null&&d.data.output&&d.data.status===me.FAILED){const I=typeof d.data.output=="string"?d.data.output:JSON.stringify(d.data.output,null,2);u(I),f.isError=!0,f.showErrorAlert=!0,f.successShown=!1}},[d,f]);const m=y.useCallback(()=>{if(!n){console.error("节点ID不能为空");return}f.testing=!0,f.testProgress=60,f.successShown=!1,f.isError=!1,f.showErrorAlert=!1,f.sampleMode=!1,By(n).then(I=>{const F=I,N=KG(F),P=N===me.FAILED;f.isError=P,f.successShown=!P,f.showErrorAlert=f.isError;let M="";try{M=YG(F)}catch(z){console.error("格式化测试结果出错:",z),M=`测试结果格式化失败: ${String(z)}`}f.testProgress=100,u(M),a({id:n,data:{status:N,output:M,outputSource:"test"}})}).catch(I=>{var P;console.error("测试失败:",I),f.testProgress=0,f.isError=!0,f.showErrorAlert=!0,f.successShown=!1;let F="测试执行失败";(P=I==null?void 0:I.response)!=null&&P.data?F=JSON.stringify(I.response.data,null,2):I!=null&&I.message&&(F=I.message);const N=JSON.stringify({error:F},null,2);u(N),a({id:n,data:{status:me.FAILED,output:N,outputSource:"test"}})}).finally(()=>{setTimeout(()=>{f.testProgress=0,f.testing=!1},500)})},[a,n,f]),v=()=>{f.testProgress=0,f.testing=!1,f.sampleSaving=!1,f.sampleMode=!1,f.successShown=!0,f.isError=!1,f.showErrorAlert=!1},b=()=>{r&&(f.testing=!0,f.ignoring=!0,f.testProgress=60,r(!0,!0,f.sampleText))},w=()=>{f.sampleSaving=!1,f.ignoring=!1,f.successShown=!0,f.isError=!1,f.showErrorAlert=!1,f.isIgnoreSuccess=!0},g=()=>{f.testProgress=0,f.testing=!1,f.ignoring=!1,f.isIgnoreSuccess=!0};y.useImperativeHandle(e,()=>({onTestNode:m,finishSampleTest:v,abortSampleTest:w,finishNodeTest:g}));const C=()=>{f.sampleMode=!1,r?r(!0):m()},k=()=>{u(""),f.sampleText="",f.sampleMode=!1,f.sampleError="",f.successShown=!1},_=Ot(),S=y.useMemo(()=>{var I;return UG({canEdit:_,nodeType:d==null?void 0:d.type,protocol:(I=d==null?void 0:d.data)==null?void 0:I.protocol})},[_,(B=d==null?void 0:d.data)==null?void 0:B.protocol,d==null?void 0:d.type]),E=S.disabled?"disabled":f.testing?"running":f.isError?"failure":f.successShown?f.isIgnoreSuccess?"ignored":"success":"waiting",x=()=>{if(f.editable){f.editable=!1;try{const I=JSON.parse(f.sampleText),F=JSON.stringify(I,null,2);u(F),a({id:n,data:{output:F}})}catch{u(f.sampleText)}return}f.sampleText=c,f.editable=!0};return h.jsx(iO,{status:E,result:c,progress:f.testProgress||60,runningAction:f.ignoring?"ignore":"run",showAlert:f.isError?f.showErrorAlert:f.successShown,canEdit:_,disabledReason:S.reason,editing:f.editable,editableValue:f.sampleText,onEditableValueChange:I=>{f.sampleText=I},onRun:C,onIgnore:b,onReset:k,onToggleEdit:x,onDismissAlert:()=>{f.showErrorAlert=!1,f.successShown=!1},onClose:o,onExpandPanel:i})});var tr=(t=>(t.Array="ARRAY",t.Boolean="BOOLEAN",t.Null="NULL",t.Number="NUMBER",t.Object="OBJECT",t.String="STRING",t))(tr||{});const sw={ARRAY:"purple",BOOLEAN:"green",NULL:"default",NUMBER:"blue",OBJECT:"cyan",STRING:"orange"},JG={ARRAY:"Arr",BOOLEAN:"Bool",NULL:"Null",NUMBER:"Num",OBJECT:"Obj",STRING:"Str"},aw=(t,e=!1)=>{const n=String(t||"STRING").toUpperCase(),r=JG[n]||n.slice(0,4);return e?`${r}[]`:r},sO=t=>{t!=null&&t.length&&t.forEach(e=>{e.label||(e.label=e.name),Array.isArray(e.sub_params)?sO(e.sub_params):e.sub_params=[]})},QG=t=>{const e=t==null?void 0:t.map(r=>(r.output.label=`${r.seq}-${r.connector_name} : ${r.action_name}`,r.note&&(r.output.label+=`(${r.note})`),{...r,label:`${r.connector_name}-${r.action_name}`,sub_params:[r.output]})),n=Pt.cloneDeep(e);return sO(n),n};var aO=(t=>(t.TEXT="TEXT",t.NUMBER="NUMBER",t.JSON="JSON",t))(aO||{});const ZG=t=>({TEXT:"STRING",NUMBER:"NUMBER",JSON:"OBJECT"})[t]||"STRING",eR=t=>{const{nodeId:e,flowId:n,enabled:r=!0,includeGlobalVariables:o=!0}=t,i=ne.useStoreApi(),[s,a]=y.useState([]),[l,c]=y.useState([]),[u,d]=y.useState(!1),[f,p]=y.useState(null),[m,v]=y.useState(0),[b,w]=y.useState(!1),[g,C]=y.useState(null),[k,_]=y.useState(0),S=y.useCallback(()=>{v(T=>T+1)},[]),E=y.useCallback(()=>{_(T=>T+1)},[]),x=y.useCallback(()=>{v(T=>T+1),_(T=>T+1)},[]);return y.useEffect(()=>{if(!r||!o){o||a([]),d(!1),p(null);return}let T=!1;return(async()=>{d(!0),p(null);try{const I=await Py();if(T)return;const F=((I==null?void 0:I.items)||[]).map(N=>({...N,mappedType:ZG(N.var_type)}));a(N=>Pt.isEqual(N,F)?N:F)}catch(I){console.error("Failed to fetch global variables:",I),T||p(I instanceof Error?I:new Error("无法获取全局变量数据"))}finally{T||d(!1)}})(),()=>{T=!0}},[r,o,m]),y.useEffect(()=>{if(!r||!n){w(!1),C(null);return}let T=!1;return(async()=>{w(!0),C(null);try{const{edges:I,nodes:F}=i.getState(),N=await Iy(n,{nodeId:e,edges:I});if(T)return;const P=new Map(F.map(H=>[H.id,H])),z=(QG(N)||[]).map(H=>{var $,j;const R=($=H.node_id)!=null&&$.startsWith("N")?H.node_id.slice(1):H.node_id,Y=R?P.get(R):void 0,te=typeof((j=Y==null?void 0:Y.data)==null?void 0:j.icon)=="string"?Y.data.icon:void 0;return{...H,nodeIcon:te,isValid:!!Y}});c(H=>Pt.isEqual(H,z)?H:z)}catch(I){console.error("Failed to fetch node variables:",I),T||C(I instanceof Error?I:new Error("无法获取节点变量数据"))}finally{T||w(!1)}})(),()=>{T=!0}},[n,e,r,k,i]),{globalVariables:s,nodeVariables:l,isLoading:u||b,isGlobalLoading:u,isNodeLoading:b,error:f||g,globalError:f,nodeError:g,refresh:x,refreshGlobal:S,refreshNode:E}},it={container:"_container_70r0s_5",header:"_header_70r0s_29",headerIcon:"_headerIcon_70r0s_37",headerTitle:"_headerTitle_70r0s_41",body:"_body_70r0s_46",section:"_section_70r0s_61",sectionLabel:"_sectionLabel_70r0s_65",sectionIcon:"_sectionIcon_70r0s_79",typeTag:"_typeTag_70r0s_88",varItem:"_varItem_70r0s_97",varName:"_varName_70r0s_115",varValue:"_varValue_70r0s_121",nodeTitle:"_nodeTitle_70r0s_129",nodeIcon:"_nodeIcon_70r0s_134",nodeLabelFirst:"_nodeLabelFirst_70r0s_139",nodeLabel:"_nodeLabel_70r0s_139",leafTitle:"_leafTitle_70r0s_151",leafLabel:"_leafLabel_70r0s_156",leafValue:"_leafValue_70r0s_162",empty:"_empty_70r0s_168",loadingState:"_loadingState_70r0s_171",errorState:"_errorState_70r0s_180",invalidVariable:"_invalidVariable_70r0s_184",nodeIconWrapper:"_nodeIconWrapper_70r0s_193",defaultNodeIcon:"_defaultNodeIcon_70r0s_206"},lw={VariableModalTitle:h.jsx(Te.FormattedMessage,{id:"app.common.word.select-variable"}),NoTestDataDesc:h.jsx(Te.FormattedMessage,{id:"common.no-process-variables-yet"})},tR=t=>{if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="object")try{return JSON.stringify(t)}catch{return String(t)}return String(t)},nR=(t,e)=>{const n=t.trim(),r=n.startsWith("N")?n:`N${n}`,o=e.slice(1).join(".");return o?`{{${r}.${o}}}`:`{{${r}}}`},lO=y.forwardRef((t,e)=>{const n=El(),{nodeId:r,showGlobalVariables:o=!0}=t,{event$:i}=y.useContext(Qr),{globalVariables:s,nodeVariables:a,isGlobalLoading:l,isNodeLoading:c,globalError:u,nodeError:d,refreshGlobal:f,refreshNode:p}=eR({nodeId:r,flowId:n,enabled:t.open,includeGlobalVariables:o}),m=Et.useReactive({currentInputId:"",visible:!0});i.useSubscription(w=>{switch(w.type){case"visible":m.visible||(f(),p()),m.visible=w.visible;break;case"setCurrentInputId":m.currentInputId=w.currentInputId;break}}),y.useImperativeHandle(e,()=>({loadVariables:()=>{f(),p()}}));const v=w=>{try{const g=typeof w=="string"?JSON.parse(w):w,C=(_,S)=>{if(_==null)return{name:S,type:tr.Null,label:S,multi_valued:!1,sub_params:[],value:String(_)};if(typeof _=="object"&&!Array.isArray(_)){const x=_;return{name:S,type:tr.Object,label:S,multi_valued:!1,sub_params:Object.keys(x).map(O=>C(x[O],O)),value:null}}if(Array.isArray(_)){const x=_[0],O=x&&typeof x=="object"?tr.Object:typeof x=="number"?tr.Number:typeof x=="boolean"?tr.Boolean:x==null?tr.Array:tr.String;return{name:S,type:O,label:S,multi_valued:!0,sub_params:[],value:JSON.stringify(_)}}const E=typeof _=="number"?tr.Number:typeof _=="boolean"?tr.Boolean:tr.String;return{name:S,type:E,label:S,multi_valued:!1,sub_params:[],value:String(_)}},k=g&&typeof g=="object"&&!Array.isArray(g)?g:{};return Object.keys(k).map(_=>C(k[_],_))}catch{return[]}},b=(w,g,C,k,_,S=[],E="0")=>(w??[]).map((x,O)=>{var I;const A=[...S,x.name],T=`${E}-${O}`;return(I=x.sub_params)!=null&&I.length?{key:T,variablePath:A,title:h.jsxs("span",{className:`${it.nodeTitle}${k===!1?` ${it.invalidVariable}`:""}`,children:[g?_==="api"?h.jsx(se.ApiOutlined,{className:it.nodeIcon}):h.jsx("span",{className:it.nodeIconWrapper,children:C?h.jsx("img",{src:C,alt:""}):h.jsx("span",{className:it.defaultNodeIcon,children:"N"})}):h.jsx(D.Tag,{color:sw[x.type]||"gray",className:`${it.typeTag} workflow-variable-panel__type`,children:aw(x.type,x.multi_valued)}),h.jsx("span",{className:`${g?it.nodeLabelFirst:it.nodeLabel} workflow-variable-panel__label`,children:x.label})]}),children:b(x.sub_params,!1,C,k,_,A,T)}:{key:T,variablePath:A,title:h.jsxs("span",{className:`${it.leafTitle}${k===!1?` ${it.invalidVariable}`:""}`,children:[h.jsx(D.Tag,{color:sw[x.type]||"gray",className:`${it.typeTag} workflow-variable-panel__type`,children:aw(x.type,x.multi_valued)}),h.jsx("span",{className:`${it.leafLabel} workflow-variable-panel__label`,children:x.label}),x.value?h.jsx("span",{className:it.leafValue,children:x.value}):null]})}});return h.jsxs("div",{className:`${it.container} workflow-variable-panel`,children:[h.jsxs("div",{className:`${it.header} workflow-variable-panel__header`,children:[h.jsx(CW,{size:16,className:`${it.headerIcon} workflow-variable-panel__header-icon`}),h.jsx("span",{className:`${it.headerTitle} workflow-variable-panel__title`,children:lw.VariableModalTitle})]}),h.jsxs("div",{className:`${it.body} workflow-variable-panel__body`,children:[o?h.jsxs(h.Fragment,{children:[h.jsxs("div",{className:`${it.sectionLabel} workflow-variable-panel__section-label`,children:[h.jsx(se.GlobalOutlined,{className:it.sectionIcon,size:32}),h.jsx("span",{children:"全局变量"})]}),h.jsx("div",{className:`variable-panel-group ${!l&&!u&&s.length<1?"empty":""}`,children:h.jsxs("div",{className:it.section,children:[s.map(w=>{if(w.var_type===aO.JSON){const k=v(w.var_value??{}),_=[{name:w.name,type:tr.Object,label:w.display_name||w.name,multi_valued:!1,sub_params:k,value:null}],S=b(_,!0,void 0,!0,"api");return h.jsx(D.Tree,{defaultExpandAll:!0,showLine:!0,onSelect:(E,x)=>{const O=x.node.variablePath;i.emit({type:"insert",currentInputId:m.currentInputId,expression:`{{global.${O.join(".")}}}`})},switcherIcon:h.jsx(se.CaretDownOutlined,{}),treeData:S},w.id)}const g=tR(w.var_value),C=g.length>28?`${g.substring(0,28)}...`:g;return h.jsxs("button",{type:"button",className:`${it.varItem} workflow-variable-panel__item`,onClick:()=>{i.emit({type:"insert",currentInputId:m.currentInputId,expression:`{{global.${w.name}}}`})},children:[h.jsx(D.Tag,{color:sw[w.mappedType],className:`${it.typeTag} workflow-variable-panel__type`,children:aw(w.mappedType)}),h.jsx("span",{className:`${it.varName} workflow-variable-panel__label`,children:w.display_name||w.name}),C?h.jsx("span",{className:it.varValue,children:C}):null]},w.id)}),!l&&!u&&s.length<1&&h.jsx(D.Empty,{image:D.Empty.PRESENTED_IMAGE_SIMPLE,description:lw.NoTestDataDesc,className:it.empty}),l?h.jsxs("div",{className:it.loadingState,children:[h.jsx(D.Spin,{size:"small"}),h.jsx("span",{children:"正在加载全局变量"})]}):u?h.jsx(D.Alert,{className:it.errorState,type:"error",showIcon:!0,message:"全局变量加载失败",description:u.message,action:h.jsx(D.Button,{size:"small",onClick:f,children:"重试"})}):null]})})]}):null,h.jsxs("div",{className:`${it.sectionLabel} workflow-variable-panel__section-label`,children:[h.jsx(se.ApiOutlined,{className:it.sectionIcon}),h.jsx("span",{children:"节点变量"})]}),h.jsx("div",{className:`variable-panel-group ${!c&&!d&&a.length<1?"empty":""}`,children:h.jsxs("div",{className:it.section,children:[a.map(w=>h.jsx("div",{children:h.jsx(D.Tree,{defaultExpandAll:!0,showLine:!0,onSelect:(g,C)=>{const k=C.node.variablePath;if(k.length<=1)return!1;i.emit({type:"insert",currentInputId:m.currentInputId,expression:nR(w.node_id,k)})},switcherIcon:h.jsx(se.CaretDownOutlined,{}),treeData:b(w.sub_params,!0,w.nodeIcon,w.isValid,"node")})},`${w.node_id}-${w.seq}`)),!c&&!d&&a.length<1&&h.jsx(D.Empty,{image:D.Empty.PRESENTED_IMAGE_SIMPLE,description:lw.NoTestDataDesc,className:it.empty}),c?h.jsxs("div",{className:it.loadingState,children:[h.jsx(D.Spin,{size:"small"}),h.jsx("span",{children:"正在加载节点变量"})]}):d?h.jsx(D.Alert,{className:it.errorState,type:"error",showIcon:!0,message:"节点变量加载失败",description:d.message,action:h.jsx(D.Button,{size:"small",onClick:p,children:"重试"})}):null]})})]})]})}),{Option:Po}=D.Select,rR=y.forwardRef(({onSubmit:t,config_schema:e,nodeId:n},r)=>{const[o]=D.Form.useForm(),i=xl(),s=D.Form.useWatch("type",o);Et.useMount(()=>{e&&Object.hasOwn(e,"asc")&&o.setFieldsValue(e)});const[a,l]=y.useState(!1),c=(d,f,p="")=>(l(!0),o.validateFields().then(async m=>s&&s==="NUMBER"&&m.start>m.end?D.message.warning(K("link.flow.loop_start_end_check")):t({properties:m},d)).catch(()=>(D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>l(!1)));y.useImperativeHandle(r,()=>({saveConfig:d=>c(d)}));const u=Ot();return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:i,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsxs(D.Form,{disabled:!u,form:o,layout:"vertical",children:[h.jsxs(D.Row,{children:[h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{name:"type",label:K("app.common.word.loop-data-type"),rules:[{required:!0,message:K("link.flow.please_select_data_type")}],children:h.jsxs(D.Select,{children:[h.jsx(Po,{value:"ARRAY",children:h.jsx(Te.FormattedMessage,{id:"link.flow.array"})}),h.jsx(Po,{value:"NUMBER",children:h.jsx(Te.FormattedMessage,{id:"common.number"})}),h.jsx(Po,{value:"CONDITION",children:h.jsx(Te.FormattedMessage,{id:"link.flow.condition_expression"})})]})})}),s&&s==="NUMBER"&&h.jsx(D.Col,{sm:24,lg:12,children:h.jsxs(D.Form.Item,{required:!0,label:K("link.flow.loop_start_end"),style:{display:"flex"},children:[h.jsx(D.Form.Item,{name:"start",noStyle:!0,rules:[{required:!0,message:K("link.flow.please_select_data_type")}],children:h.jsx(D.InputNumber,{min:1,style:{marginRight:20}})}),h.jsx(D.Form.Item,{name:"end",noStyle:!0,rules:[{required:!0,message:K("link.flow.please_select_data_type")}],children:h.jsx(D.InputNumber,{min:1})})]})}),s&&s!=="NUMBER"&&h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{rules:[{required:!0,message:K("link.flow.please_enter_loop_expression")}],label:K("link.flow.loop_expression"),name:"expression",children:h.jsx(Pn,{nodeId:n,borrow:!0,valueType:"JS_EXP",placeholder:K("link.flow.please_enter_loop_expression")})})}),!s&&h.jsx(D.Col,{})]}),h.jsxs(D.Row,{children:[h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{name:"asc",label:K("app.common.word.circulation-direction"),rules:[{required:!0,message:K("link.flow.please_select_loop_direction")}],children:h.jsxs(D.Select,{children:[h.jsx(Po,{value:!0,children:h.jsx(Te.FormattedMessage,{id:"link.flow.loop_head_to_tail"})}),h.jsx(Po,{value:!1,children:h.jsx(Te.FormattedMessage,{id:"link.flow.loop_tail_to_head"})})]})})}),h.jsx(D.Col,{sm:24,lg:12,children:h.jsx(D.Form.Item,{name:"errorExec",label:K("link.flow.loop_processing"),rules:[{required:!0,message:K("link.flow.please_select_loop_processing")}],children:h.jsxs(D.Select,{children:[h.jsx(Po,{value:"END",children:h.jsx(Te.FormattedMessage,{id:"link.flow.terminate_process"})}),h.jsx(Po,{value:"CONTINUE",children:h.jsx(Te.FormattedMessage,{id:"link.flow.continue_loop"})}),h.jsx(Po,{value:"BREAK",children:h.jsx(Te.FormattedMessage,{id:"link.flow.break_loop"})})]})})})]})]})}),h.jsx("div",{className:"workflow-node-form-footer",children:u&&h.jsx(D.Button,{type:"primary",disabled:!u,loading:a,className:"workflow-node-form-save",onClick:()=>c(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),Ud=()=>`branch_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,{Option:oR}=D.Select,iR=y.forwardRef((t,e)=>{const{config_schema:n,nodeId:r}=t,[o]=D.Form.useForm(),i=xl(),{handleNodeDataUpdate:s}=Ri(),[a,l]=y.useState(null),[c,u]=y.useState(""),f=(E=>!(E!=null&&E.branches)||E.branches.length===0?{branches:[{id:Ud(),name:K("link.flow.switch.condition_one"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]},{id:Ud(),name:K("link.flow.switch.condition_two"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]}]}:{branches:E.branches.map((O,A)=>{var T;return{id:O.id||Ud(),name:O.name||K("link.flow.switch.condition_n",{n:A+1}),or_list:((T=O.or_list)==null?void 0:T.map(B=>{var I;return{and_list:((I=B.and_list)==null?void 0:I.map(F=>({query:F.query||"",operator:F.operator||"",value:F.value||""})))||[{query:"",operator:"",value:""}]}}))||[{and_list:[{query:"",operator:"",value:""}]}]}})})(n),p=()=>{const E=o.getFieldValue("branches")||[];s({id:r,data:{config_schema:{branches:E}}})},m=(E,x)=>{l(E),u(x)},v=()=>{l(null),u("")},b=E=>{const x=Pt.cloneDeep(o.getFieldValue("branches"))||[],O=c.trim();if(!O){D.message.error(K("link.flow.switch.branch_name_cannot_be_empty"));return}if(x.some((T,B)=>B!==E&&T.name===O)){D.message.error(K("link.flow.switch.branch_name_duplicate"));return}x[E].name=O,o.setFieldValue("branches",x),l(null),u(""),p()},w=(E,x)=>{const O=o.getFieldValue("branches")||[];if(x<0||x>=O.length)return;const A=[...O],[T]=A.splice(E,1);A.splice(x,0,T),o.setFieldValue("branches",A),p()},[g,C]=y.useState(!1),k=E=>(C(!0),o.validateFields().then(async x=>{if(!x.branches.some(T=>T.or_list.some(B=>B.and_list.some(I=>I.query&&I.operator)))){D.message.error(K("link.flow.switch.at_least_one_valid_branch"));return}const A=Pt.cloneDeep(x);return A.branches.forEach(T=>{T.or_list.forEach(B=>{B.and_list.forEach(I=>{I.value=FG(I.operator,I.value)})})}),t.onSubmit({properties:A},E)}).catch(()=>(D.message.warning(K("link.flow.missing_configuration")),!1)).finally(()=>C(!1)));y.useImperativeHandle(e,()=>({saveConfig:E=>k(E)}));const _=Ot(),S=(E,x,O,A)=>{const B=(o.getFieldValue("branches")||[])[x],I=a===x;return h.jsxs(D.Card,{style:{marginBottom:20,borderRadius:8,border:"1px solid #d9d9d9"},styles:{body:{padding:10}},children:[h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:12},children:[h.jsx("div",{style:{display:"flex",alignItems:"center",flex:1},children:I?h.jsxs(D.Space,{children:[h.jsx(D.Input,{value:c,onChange:F=>u(F.target.value),style:{width:200},placeholder:K("link.flow.switch.enter_branch_name"),onPressEnter:()=>b(x)}),h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.CheckOutlined,{style:{color:"#52c41a"}}),onClick:()=>b(x)}),h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.CloseOutlined,{}),onClick:v})]}):h.jsxs(D.Space,{children:[h.jsx("span",{style:{fontSize:13,fontWeight:400},children:(B==null?void 0:B.name)||K("link.flow.switch.condition_n",{n:x+1})}),_&&h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.EditOutlined,{}),onClick:()=>m(x,(B==null?void 0:B.name)||"")})]})}),_&&h.jsxs(D.Space,{className:"actions",children:[h.jsx(D.Tooltip,{title:K("link.flow.switch.move_to_top"),children:h.jsx(D.Button,{type:"text",size:"small",disabled:x===0,onClick:()=>w(x,0),children:"置顶"})}),h.jsx(D.Tooltip,{title:K("link.flow.switch.move_up"),children:h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.ArrowUpOutlined,{}),disabled:x===0,onClick:()=>w(x,x-1)})}),h.jsx(D.Tooltip,{title:K("link.flow.switch.move_down"),children:h.jsx(D.Button,{type:"text",size:"small",icon:h.jsx(se.ArrowDownOutlined,{}),disabled:x===O-1,onClick:()=>w(x,x+1)})}),h.jsx(D.Tooltip,{title:K("link.flow.switch.move_to_bottom"),children:h.jsx(D.Button,{type:"text",size:"small",disabled:x===O-1,onClick:()=>w(x,O-1),children:"置底"})}),h.jsx(D.Tooltip,{title:K("common.delete"),children:h.jsx(D.Button,{type:"text",size:"small",disabled:O<=1,onClick:()=>{if(O<=1){D.message.warning(K("link.flow.switch.at_least_one_branch"));return}A(E.name),setTimeout(()=>{p()},0)},children:"删除"})})]})]}),h.jsx(D.Form.Item,{name:[E.name,"name"],hidden:!0,children:h.jsx(D.Input,{})}),h.jsx(D.Form.List,{name:[E.name,"or_list"],children:(F,{add:N,remove:P})=>h.jsx(h.Fragment,{children:F.map((M,z)=>{const H=z===F.length-1;return h.jsx(h.Fragment,{children:h.jsxs("div",{className:"switch-rule",children:[F.length>1&&_&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:h.jsxs(D.Button,{type:"link",icon:h.jsx(se.MinusCircleOutlined,{}),onClick:()=>P(M.name),children:[h.jsx(Te.FormattedMessage,{id:"link.flow.remove"})," OR"]})}),h.jsx(D.Form.List,{name:[M.name,"and_list"],children:(R,{add:Y,remove:te})=>h.jsx(h.Fragment,{children:R.map(($,j)=>{const U=j===R.length-1;return h.jsxs(D.Space,{direction:"vertical",style:{width:"100%"},children:[h.jsxs(D.Space,{align:"center",className:"switch-rule-item",children:[h.jsx(D.Form.Item,{style:{minWidth:150,marginBottom:0},name:[$.name,"query"],label:K("app.common.word.variable-name"),rules:[{required:!0,message:K("link.flow.please_enter_variable_name")}],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),h.jsx(D.Form.Item,{style:{marginBottom:0},name:[$.name,"operator"],label:K("app.common.word.condition"),rules:[{required:!0,message:K("link.flow.please_select_condition")}],children:h.jsx(D.Select,{style:{minWidth:140},placeholder:K("link.flow.select_condition"),getPopupContainer:()=>document.body,children:oO.map(ee=>h.jsx(oR,{value:ee.operator,children:ee.label},ee.operator))})}),h.jsx(D.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const ee=o.getFieldValue(["branches",E.name,"or_list",M.name,"and_list",$.name,"operator"]);return iw(ee)?null:h.jsx(D.Form.Item,{style:{minWidth:150,marginBottom:0},name:[$.name,"value"],label:K("app.common.word.value"),rules:[],children:h.jsx(Pn,{nodeId:t.nodeId,placeholder:K("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),j===0&&h.jsx("div",{style:{width:30}}),j>0&&_&&h.jsx(D.Button,{type:"link",icon:h.jsx(se.MinusCircleOutlined,{}),onClick:()=>te($.name)})]}),j<R.length-1&&h.jsx(D.Divider,{plain:!0,style:{margin:"8px 0"},children:h.jsx(D.Tag,{color:"#999999",children:h.jsx(Te.FormattedMessage,{id:"link.flow.and"})})}),h.jsxs("div",{className:`rule-opt-actions ${U?"last-and-rule":""}`,children:[j===R.length-1&&h.jsx(D.Button,{type:"link",disabled:!_,icon:h.jsx(br,{size:14}),onClick:()=>Y({query:"",operator:"",value:""}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-new-and"})}),H&&h.jsx(D.Button,{type:"link",icon:h.jsx(br,{size:14}),disabled:!_,onClick:()=>N({and_list:[{query:"",operator:"",value:""}]}),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.add-or"})})]})]},$.key)})})}),!H&&h.jsx("div",{style:{textAlign:"center"},children:h.jsx(D.Divider,{style:{color:"orange"},dashed:!0,children:h.jsx(D.Tag,{color:"#1890ff",children:h.jsx(Te.FormattedMessage,{id:"link.flow.or"})})})})]},M.key)})})})})]},E.key)};return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:i,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsx(D.Form,{disabled:!_,form:o,initialValues:f,layout:"vertical",autoComplete:"off",children:h.jsx(D.Form.List,{name:"branches",children:(E,{add:x,remove:O})=>h.jsxs(h.Fragment,{children:[E.map((A,T)=>S(A,T,E.length,O)),E.length<10&&h.jsx("div",{style:{display:"flex",justifyContent:"flex-end",width:"100%"},children:h.jsx(D.Button,{type:"default",icon:h.jsx(br,{size:14}),disabled:!_,onClick:()=>{const A=E.length+1;x({id:Ud(),name:K("link.flow.switch.condition_n",{n:A}),or_list:[{and_list:[{query:"",operator:"",value:""}]}]}),setTimeout(()=>{p()},0)},children:h.jsx(Te.FormattedMessage,{id:"link.flow.switch.add_branch"})})}),E.length>=10&&h.jsx("div",{style:{textAlign:"center",color:"#999",marginBottom:20},children:h.jsx(Te.FormattedMessage,{id:"link.flow.switch.max_branches_reached"})})]})})})}),h.jsx("div",{className:"workflow-node-form-footer",children:_&&h.jsx(D.Button,{type:"primary",disabled:!_,loading:g,className:"workflow-node-form-save",onClick:()=>k(),children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})}),sR=({nodeId:t,onSubmit:e,data:n})=>{const[r]=D.Form.useForm(),o=xl(),i=Ot(),{refreshFlow:s}=ao(),{setNodes:a}=ne.useReactFlow(),l=y.useCallback((u,d)=>{a(f=>f.map(p=>!d&&p.id!==t?p:{...p,data:{...p.data,error_handler:u}}))},[t,a]);y.useEffect(()=>{const u=(n==null?void 0:n.error_handler)||{};r.setFieldsValue({retryEnabled:u.retry||!1,retryCount:u.retry_times||3,retryInterval:u.retry_interval||5,stepFactor:u.step_factor||1.5,maxRetryInterval:u.max_retry_interval||60,alertEnabled:u.warn_type===1,webhookUrl:u.notify_url||"",errorHandling:u.process_type===2?"ignore":"interrupt",applyToAllNodes:!!u.apply_all})},[t,r,n==null?void 0:n.error_handler]);const c=async u=>{try{const d={retry:u.retryEnabled,retry_times:u.retryEnabled?u.retryCount:void 0,retry_interval:u.retryEnabled?u.retryInterval:void 0,step_factor:u.retryEnabled?u.stepFactor:void 0,max_retry_interval:u.retryEnabled?u.maxRetryInterval:void 0,warn_type:u.alertEnabled?1:0,notify_url:u.alertEnabled?u.webhookUrl:void 0,process_type:u.errorHandling==="interrupt"?1:2,apply_all:u.applyToAllNodes};await rc(t,{error_handler:d}),l(d,u.applyToAllNodes),u.applyToAllNodes&&s(),e()}catch{D.message.error(K("common.save_failed"))}};return h.jsxs("div",{className:"workflow-node-form-shell",onMouseDownCapture:o,children:[h.jsx("div",{className:"workflow-node-form-scroll grayBeautifyScrollbar",children:h.jsxs(jn.ProForm,{form:r,layout:"vertical",disabled:!i,submitter:!1,onFinish:c,children:[h.jsx(jn.ProFormSwitch,{name:"retryEnabled",label:K("app.common.word.enable-retry")}),h.jsx(jn.ProFormDependency,{name:["retryEnabled"],children:({retryEnabled:u})=>u?h.jsxs(h.Fragment,{children:[h.jsx(jn.ProFormDigit,{name:"retryCount",label:K("app.common.word.retry-count"),tooltip:K("app.common.word.retry-count-tooltip"),width:"xl",fieldProps:{min:1,max:10,precision:0,style:{width:"100%"}},rules:[{required:u,message:K("app.common.word.please-enter-retry-count")}]}),h.jsx(jn.ProFormDigit,{name:"retryInterval",label:K("app.common.word.retry-interval"),tooltip:K("app.common.word.retry-interval-tooltip"),fieldProps:{min:1,max:60,precision:0,style:{width:"100%"},addonAfter:"s"},rules:[{required:u,message:K("app.common.word.please-enter-retry-interval")}]}),h.jsx(jn.ProFormDigit,{name:"stepFactor",label:K("app.common.word.step-factor"),tooltip:K("app.common.word.step-factor-tooltip"),width:"xl",fieldProps:{min:1,max:5,precision:1,style:{width:"100%"}},rules:[{required:u,message:K("app.common.word.please-enter-step-factor")}]}),h.jsx(jn.ProFormDigit,{name:"maxRetryInterval",label:K("app.common.word.max-retry-interval"),tooltip:K("app.common.word.max-retry-interval-tooltip"),width:"xl",fieldProps:{min:1,max:300,precision:0,style:{width:"100%"},addonAfter:"s"},rules:[{required:u,message:K("app.common.word.please-enter-max-retry-interval")}]})]}):null}),h.jsx(jn.ProFormSwitch,{name:"alertEnabled",label:K("app.common.word.enable-alert")}),h.jsx(jn.ProFormDependency,{name:["alertEnabled"],children:({alertEnabled:u})=>u?h.jsx(jn.ProFormText,{name:"webhookUrl",label:K("app.common.word.webhook-url"),placeholder:K("app.common.word.enter-webhook-url"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:u,message:K("app.common.word.enter-webhook-url")}]}):null}),h.jsx(jn.ProFormSelect,{name:"errorHandling",label:K("app.common.word.error-handling"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:!0,message:K("app.common.word.select-error-handling")}],options:[{label:K("app.common.word.interrupt-flow"),value:"interrupt"},{label:K("app.common.word.ignore-error"),value:"ignore"}]}),h.jsx(jn.ProFormSwitch,{name:"applyToAllNodes",label:K("app.common.word.apply-to-all-nodes")})]})}),h.jsx("div",{className:"workflow-node-form-footer",children:h.jsx(D.Button,{type:"primary",disabled:!i,onClick:()=>r.submit(),className:"workflow-node-form-save",children:h.jsx(Te.FormattedMessage,{id:"app.common.word.save"})})})]})},cO="[workflow:schema-render]",aR=()=>{const{event$:t}=y.useContext(Qr),e=Fh();return t.useSubscription(n=>{var r;n.type==="insert"&&n.expression&&(r=e==null?void 0:e.getActiveFieldId)!=null&&r.call(e)&&e.insertVariableToActiveField(n.expression,!1)}),null},lR=({children:t})=>{const{event$:e}=y.useContext(Qr),n=Mh(),[r,o]=y.useState("");e.useSubscription(a=>{a.type==="setCurrentInputId"&&o(a.currentInputId??"")});const i=(n==null?void 0:n.activeFieldId)??r,s=y.useMemo(()=>({activeInputId:i}),[i]);return h.jsx(cx.Provider,{value:s,children:t})},cR=t=>{const{icon:e,fallbackIcon:n}=t;return h.jsxs("div",{className:"node-config-title",style:{display:"flex",alignItems:"center"},children:[h.jsx("div",{className:"node-config-icon",style:{backgroundImage:`url(${n?"none":e??"https://digitalsee-image.digitalsee.cn/flow/0.png"})`},children:n&&n}),h.jsxs("div",{className:"node-config-meta",children:[h.jsx("div",{className:"node-config-title-name",style:{fontSize:16,fontWeight:600,marginLeft:10},children:t.name}),h.jsx("div",{className:"node-config-title-description",style:{fontSize:12,color:"gray",marginLeft:10},children:t.description})]})]})},uR=y.memo(({visible:t,onClose:e,data:n,nodeType:r=pe.ACTION,nodeId:o=""})=>{var B,I;const i=Et.useEventEmitter();ne.useInternalNode(o);const{setNodeConfigVisible:s,refreshFlow:a}=ao(),l=y.useRef(null),c=y.useRef(null),u=y.useRef(null),d=y.useRef(null),f=y.useRef(null);y.useRef(null);const p=y.useRef(null),m=ne.useStoreApi(),v=$t(),b=((I=(B=v.nodeConfigPanel)==null?void 0:B.testArea)==null?void 0:I.allowManualTest)!==!1,w=Et.useReactive({output:"",ignore:!1,expandTestPanel:!1}),g=y.useMemo(()=>v.nodeConfigPanel.showSettings&&![pe.TRIGGER,pe.AI_SUB_NODE].includes(r),[r,v.nodeConfigPanel.showSettings]),C=(n==null?void 0:n.action_id)??(n==null?void 0:n.id),k=C!==null&&typeof C<"u"&&C!==""&&Number.isFinite(Number(C))?C:null,_=po(n),S=n==null?void 0:n.nodeKey,E=(n==null?void 0:n.nodeVersion)??(n==null?void 0:n.action_ver),{handleNodeDataUpdate:x}=Ri();y.useEffect(()=>{var N,P;if(!t)return;const F=k!==null&&Number(k)<=0;S&&F&&!_&&!((N=n==null?void 0:n.config_schema)!=null&&N.sub_params)&&!((P=n==null?void 0:n.properties)!=null&&P.sub_params)&&console.warn(`${cO} possible nodepackage schema route mismatch`,{nodeId:o,nodeType:r,actionId:k,nodePackageKey:S,nodePackageVersion:E,reason:"keyed node with non-positive action_id and no classic sub_params was rejected by the nodePackage-compatible node check"})},[k,n==null?void 0:n.config_schema,n==null?void 0:n.properties,n==null?void 0:n.params,n==null?void 0:n.action_key,n==null?void 0:n.action_ver,n==null?void 0:n.nodeKey,n==null?void 0:n.nodeVersion,_,S,E,o,r,t]);const O=y.useCallback(async(F,N)=>{var M,z,H;const P=v.flowId;try{const R=m.getState().nodes.find(U=>U.id===o),Y=_?ZP(F):F.properties,te=_?e2(F):F.account_id??null,$=_?{flow_id:P,properties:Y,position:R==null?void 0:R.position,action_id:k,account_id:te,proxy_id:F.proxy_id,mcp_tool_description:F.mcp_tool_description,action_key:S,action_ver:E}:{flow_id:P,...F,position:R==null?void 0:R.position,action_id:k};console.info(`${cO} save node config`,{nodeId:o,nodeType:r,actionId:k,isNodepackageNode:_,nodePackageKey:S,nodePackageVersion:E,valueKeys:Object.keys(F||{}),paramsKeys:Object.keys((F==null?void 0:F.params)||{}),propertiesKeys:Object.keys((F==null?void 0:F.properties)||{}),ignoreDebugResult:w.ignore});const j=w.ignore?await My(o,"","","",Y,w.output):await rc(o,$);if(j)if(w.ignore)(M=p.current)==null||M.finishSampleTest(),x({id:o,data:{status:me.SUCCESS,output:w.output,outputSource:"sample"}}),D.message.success("已使用样本数据完成调试");else{D.message.success("节点配置已保存");const U={params:void 0,properties:Y,account_id:te,mcp_tool_description:F.mcp_tool_description,action_key:S,action_ver:E,nodeKey:S,nodeVersion:E,isNodePackage:_};x({id:o,data:{config_schema:Y,account_id:F.account_id,...U,position:R==null?void 0:R.position,status:j.status}})}N&&!w.ignore&&((z=p.current)==null||z.onTestNode()),w.ignore=!1,w.output=""}catch{w.ignore&&((H=p.current)==null||H.abortSampleTest(),x({id:o,data:{status:me.FAILED}}))}},[k,v.flowId,n==null?void 0:n.action_key,n==null?void 0:n.action_ver,n==null?void 0:n.nodeKey,n==null?void 0:n.nodeVersion,x,_,S,E,o,r,w,m]);y.useCallback(F=>{!_||r!==pe.SWITCH||x({id:o,data:{config_schema:F,properties:F}})},[x,_,o,r]);const A=F=>{var N,P,M,z,H;return _?(N=c.current)==null?void 0:N.saveConfig(F):r===pe.LOOP?(P=f.current)==null?void 0:P.saveConfig(F):r===pe.CONDITION?(M=u.current)==null?void 0:M.saveConfig(F):r===pe.SWITCH?(z=d.current)==null?void 0:z.saveConfig(F):(H=c.current)==null?void 0:H.saveConfig(F)},T=async(F,N,P)=>{var M;if(N){w.ignore=!0,w.output=P||"",await A(F),(M=p.current)==null||M.finishNodeTest();return}if(F)try{D.message.loading("正在保存节点配置...",0),await A(F),D.message.success("节点配置已保存"),D.message.destroy()}catch(z){D.message.destroy(),console.error("节点配置保存失败:",z),D.message.error("节点配置保存失败,无法执行测试")}};return h.jsx(D.Modal,{open:t,footer:null,closeIcon:null,maskClosable:!0,onCancel:()=>{s(null)},centered:!0,width:"min(1440px, calc(100vw - 32px))",className:"nodes-config-modal",styles:{mask:{backgroundColor:"rgba(0, 0, 0, 0.45)"},content:{padding:0,overflow:"hidden"}},children:h.jsx(Qr.Provider,{value:{event$:i},children:h.jsxs(rC,{children:[h.jsx(aR,{}),h.jsx(lR,{children:h.jsx("div",{className:"nodes-config-container",children:h.jsx("div",{className:"nodes-config-content",children:h.jsxs("div",{className:"config-row",children:[h.jsx("div",{className:"left-section",children:h.jsx("div",{className:"variables-section",children:h.jsx(lO,{ref:l,nodeId:o,onInsert:()=>{},open:t})})}),h.jsx("div",{className:"middle-section",children:h.jsxs("div",{className:"config-container",children:[h.jsx(cR,{icon:n==null?void 0:n.icon,fallbackIcon:n==null?void 0:n.fallbackIcon,name:(n==null?void 0:n.action_name)||(n==null?void 0:n.label),description:n==null?void 0:n.description}),h.jsx(D.Tabs,{style:{height:"100%"},items:[{key:"property",label:"参数配置",children:h.jsxs(h.Fragment,{children:[_||![pe.CONDITION,pe.SWITCH,pe.LOOP].includes(r)?h.jsx(BG,{ref:c,nodeId:o,nodeType:r,data:n,onSubmit:O}):null,r===pe.CONDITION&&!_?h.jsx(IG,{ref:u,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null,r===pe.SWITCH&&!_?h.jsx(iR,{ref:d,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null,r===pe.LOOP&&!_?h.jsx(rR,{ref:f,nodeId:o,config_schema:n.config_schema,onSubmit:O}):null]})},{key:"setting",label:"设置",children:h.jsx(sR,{data:n,nodeId:o,onSubmit:()=>{D.message.success("保存成功")}})}].slice(0,g?2:1)})]})}),h.jsx("div",{className:`right-section ${w.expandTestPanel?"expand":""}`,children:b&&h.jsx("div",{className:"test-section",children:h.jsx(XG,{ref:p,nodeId:o,beforeHook:T,onClose:e,onExpandPanel:F=>{w.expandTestPanel=F}})})})]})})})})]})})})},(t,e)=>Pt.isEqual(Pt.omit(t,["data","isHovered"]),Pt.omit(e,["data","isHovered"]))),uO=[],dR=(t,e)=>{if(uO.length===0)return[];const n=new Set(e);return t.some(o=>n.has(o.id)&&Oh(o)&&uO.some(i=>{var s;return((s=o.data)==null?void 0:s.action_key)===i}))?t.filter(o=>!n.has(o.id)).map(o=>o.id):[]},fR=[pe.AGENT,pe.BROWSER],cw=()=>{const t=ne.useStoreApi(),[e,n]=y.useState(0),r=y.useCallback((l,c)=>{const{nodes:u,setNodes:d}=t.getState(),f=fa(u,p=>{const m=p.find(v=>v.id===c.id);m.data?m.data.isHovered=!0:m.data={isHovered:!0}});d(f)},[]),o=y.useCallback((l,c)=>{const{nodes:u,setNodes:d}=t.getState(),f=fa(u,p=>{const m=p.find(v=>v.id===c.id);m.data?m.data.isHovered=!1:m.data={isHovered:!1}});d(f)},[]),i=y.useCallback(l=>{const{nodes:c,setNodes:u}=t.getState(),d=fa(c,f=>{l.forEach(p=>{p.type==="select"&&(f.find(m=>m.id===p.id).selected=p.selected)})});u(d)},[t]),s=y.useCallback((l,c,u=new Set)=>(c.filter(f=>f.source===l?f.sourceHandle!==He.OUTPUT&&f.sourceHandle!==He.DONE&&f.sourceHandle!==He.LOOP&&f.sourceHandle!==He.TRUE&&f.sourceHandle!==He.FALSE:f.target===l&&fh(f.targetHandle)).forEach(f=>{const p=f.source===l?f.target:f.source;u.has(p)||(u.add(p),s(p,c,u))}),u),[]),a=y.useCallback((l,c)=>{const{nodes:u,edges:d,setNodes:f,setEdges:p,onNodesChange:m,onEdgesChange:v}=t.getState(),b=new Set(l);fR.includes(c)&&l.forEach(C=>{s(C,d).forEach(_=>{b.add(_)})}),dR(u,l).forEach(C=>b.add(C));const w=Array.from(b),g=d.filter(C=>b.has(C.source)||b.has(C.target)).map(C=>C.id);if(m){const C=w.map(k=>({type:"remove",id:k}));m(C)}else f(u.filter(C=>!w.includes(C.id)));if(g.length)if(v){const C=g.map(k=>({type:"remove",id:k}));v(C)}else p(d.filter(C=>!g.includes(C.id)))},[t,s]);return{autoSaveNum:e,onNodeMouseEnter:r,onNodeMouseLeave:o,handleNodesChange:i,handleNodesDelete:a}};function hR(t){const{color:e,visible:n}=t;return h.jsx("div",{style:{display:n?"inline-flex":"none",justifyContent:"center",alignItems:"center",position:"absolute",zIndex:1e3,top:"calc(50% - 8px)",left:-10,padding:1,borderRadius:"100%",background:"#FFFFFF",width:20,height:20},children:h.jsx("span",{style:{width:16,height:16,borderRadius:10,backgroundColor:e,border:`1px solid ${e}`,display:"inline-flex",justifyContent:"center",alignItems:"center"},children:h.jsx(DW,{size:8,color:"#FFFFFF"})})})}const Lo={info:{normal:"#007FFF",lighter:"rgba(0, 127, 255, 0.48)"},success:{normal:"#98D7A9",lighter:"rgba(0, 176, 66, 0.48)"},warning:{normal:"#F7CD8F",lighter:"rgba(255, 146, 0, 0.48)"},error:{normal:"#F3B096",lighter:"rgba(255, 82, 25, 0.48)"},disabled:{normal:"#C7CCD1",lighter:"rgba(199, 204, 209, 0.48)"}},dO=({id:t,type:e=pe.ACTION,selected:n=!1,fallbackIcon:r,iconUri:o,inputs:i=[],outputs:s=[],showToolbar:a=!0,width:l,height:c,className:u="",status:d=me.IDLE,onTestNode:f,data:p,contentRender:m,showNodeDescription:v=!0,onToggleNodeDisabled:b})=>{const{currentNodeConfigVisibleId:w,setNodeConfigVisible:g}=ao(),{handleNodeDataUpdate:C}=Ri(),{handleNodesDelete:k}=cw(),_=$t(),S=na(),E=$=>{C({id:t,data:{note:$}})},x=y.useCallback(()=>{g(null)},[]),O=(p==null?void 0:p.isHovered)||!1,A=y.useMemo(()=>e===pe.TRIGGER,[e]),T=()=>{g(t)},B=y.useMemo(()=>(p==null?void 0:p.closed)==="1",[p==null?void 0:p.closed,e]),I=y.useMemo(()=>typeof l=="number"&&l>0?l:"auto",[l]),F=($="node")=>{if(B)return`workflow-${$}-disabled`;switch(d){case me.INVALID:return`workflow-${$}-warning`;case me.FAILED:return`workflow-${$}-failed`;case me.SUCCESS:case me.RUNNABLE:case me.ACTIVE:return`workflow-${$}-success`;case me.RUNNING:return`workflow-${$}-running`;case me.WARNING:return`workflow-${$}-warning`;case me.DEACTIVATED:return`workflow-${$}-disabled`;case me.IDLE:return`workflow-${$}-idle`;default:return""}},N=()=>{if(B)return Lo.disabled;switch(d){case me.INVALID:return Lo.warning;case me.FAILED:return Lo.error;case me.SUCCESS:case me.RUNNABLE:case me.ACTIVE:return Lo.success;case me.RUNNING:return Lo.info;case me.WARNING:return Lo.warning;case me.DEACTIVATED:return Lo.disabled;default:return Lo.info}},P=($="normal")=>N()[$],M=()=>{const $=i.length,j=new Map;return i.forEach(U=>{const ee=U.position,ie=j.has(ee)?j.get(ee)+1:1;j.set(ee,ie)}),i.map((U,ee)=>h.jsx(P0,{nodeId:t,id:U.id,position:U.position,type:U.type||fn.TARGET,category:U.category,connectionLimit:U.maxConnections,label:U.label,nodeStatus:d,protocol:U.protocol,portSchema:U.portSchema,shape:U.shape,style:U.style,index:[ee,$,j.get(U.position)]},`${t}-${U.id}`))},z=async()=>{var U,ee;const $=((U=_.canvas.fixedNodes)==null?void 0:U.triggerIds)||[],j=((ee=_.nodeTypes.fixed)==null?void 0:ee.triggers)||[];if($.includes(t)||j.includes(e)){D.message.warning("当前触发节点已被配置为不可删除");return}await Xf(t),k([t],e)},H=y.useMemo(()=>{const $=s.length,j=new Map;return s.forEach(U=>{const ee=U.position,ie=j.has(ee)?j.get(ee)+1:1;j.set(ee,ie)}),s.map((U,ee)=>h.jsx(P0,{nodeId:t,connectionLimit:U.maxConnections,id:U.id,style:U.style,position:U.position,protocol:U.protocol,portSchema:U.portSchema,type:U.type,label:U.label,shape:U.shape,nodeStatus:d,index:[ee,$,j.get(U.position)]},`${t}-${U.id}`))},[t,s,d]),R=()=>h.jsx(nC,{status:d,disabled:B}),Y=()=>{switch(d){case me.INVALID:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-warning-icon",children:h.jsx(se.WarningFilled,{style:{color:P()},size:12})});case me.FAILED:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-failed-icon",children:h.jsx(se.CloseCircleFilled,{style:{color:P()},size:12})});case me.SUCCESS:case me.RUNNABLE:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-success-icon",children:h.jsx(se.CheckCircleFilled,{style:{color:P()},size:12})});case me.RUNNING:return h.jsx("div",{className:"workflow-node-status-icon workflow-node-running-icon",children:h.jsx(se.LoadingOutlined,{style:{color:P()},size:12})});default:return null}},te=()=>h.jsxs(h.Fragment,{children:[h.jsx("div",{className:"workflow-node-icon-wrapper",children:h.jsx("div",{className:"workflow-node-icon",style:{backgroundImage:`url(${r?"none":o??"https://digitalsee-image.digitalsee.cn/flow/0.png"})`},children:r&&r})}),v&&h.jsx(PP,{title:p==null?void 0:p.connector_name,nodeId:t,note:(p==null?void 0:p.note)||"",statusIcon:Y(),onNoteChange:E,description:p.action_name,className:"workflow-node-text"})]});return h.jsxs(y.Fragment,{children:[h.jsxs("div",{style:{width:I,height:c||"auto"},onDoubleClick:T,className:`${u}
|
|
118
118
|
${F("container")}`,children:[h.jsx(hR,{color:P("lighter"),visible:A}),h.jsxs("div",{className:`workflow-node ${n?"workflow-node-selected":""}`,style:{"--status-color":P(),"--status-color-tint":P("lighter"),...B?{opacity:.4}:{}},children:[B&&h.jsx("div",{className:"workflow-node-deactivated-line"}),h.jsx("div",{className:"workflow-node-toolbar",style:{display:a&&!Ah(S)&&O?"block":"none"},children:h.jsx(s2,{nodeId:t,type:e,isDisabled:B,handleViewConfig:T,onTest:f,onToggleDisabled:b,onDelete:z})}),m?m(p,R()):h.jsx("div",{className:"workflow-node-content",children:te()}),M(),H]})]}),t===w&&h.jsx(uR,{visible:!0,onClose:x,nodeType:e,data:p,nodeId:t})]})},uw="main",pR=["action_key","actionKey","nodeKey","node_key"],qd=t=>Array.isArray(t)?t.filter(e=>typeof e=="string"&&!!e.trim()):void 0,dw=t=>({...t,displayName:t.displayName??t.display_name,type:typeof t.type=="string"&&t.type.trim()?t.type.trim():uw,maxConnections:Object.hasOwn(t,"maxConnections")?t.maxConnections:t.max_connections,allowedSourceNodeKeys:qd(t.allowedSourceNodeKeys??t.allowed_source_node_keys),allowedTargetNodeKeys:qd(t.allowedTargetNodeKeys??t.allowed_target_node_keys),deniedSourceNodeKeys:qd(t.deniedSourceNodeKeys??t.denied_source_node_keys),deniedTargetNodeKeys:qd(t.deniedTargetNodeKeys??t.denied_target_node_keys),position:t.position}),fO=t=>{var e;for(const n of pR){const r=(e=t==null?void 0:t.data)==null?void 0:e[n];if(typeof r=="string"&&r.trim())return r.trim()}return null},zn=(t,e,n,r,o)=>({valid:t,code:e,reason:n,sourcePort:r,targetPort:o}),fw=(t,e,n)=>t?n!=null&&n.allowLegacyMainHandleAliases&&(e==="source"&&t==="output"||e==="target"&&t==="input")?uw:t:null,hO=(t,e,n,r)=>{const o=fw(e,n,r);if(!o)return null;const i=t==null?void 0:t.find(s=>s.name===o);return i?dw(i):null},hw=(t,e)=>!!(e&&(t!=null&&t.includes(e))),pO=(t,e)=>!!(t!=null&&t.length&&!hw(t,e)),mO=(t,e,n,r,o)=>t.filter(i=>r==="source"?i.source===e&&fw(i.sourceHandle,"source",o)===n:i.target===e&&fw(i.targetHandle,"target",o)===n&&i.source!==i.target).length,gO=(t,e)=>{if(t.maxConnections==null||!Number.isFinite(t.maxConnections))return!1;const n=Math.max(0,Math.trunc(t.maxConnections));return e>=n},wO=t=>t||"(未指定)",mR=({sourceNode:t,targetNode:e,sourceHandle:n,targetHandle:r,sourcePorts:o,targetPorts:i,edges:s=[],options:a})=>{if(!t)return zn(!1,"SOURCE_NODE_NOT_FOUND","源节点不存在",null,null);if(!e)return zn(!1,"TARGET_NODE_NOT_FOUND","目标节点不存在",null,null);const l=hO(o,n,"source",a);if(!l)return zn(!1,"SOURCE_PORT_NOT_FOUND",`源节点不存在输出端口 ${wO(n)}`,null,null);const c=hO(i,r,"target",a);if(!c)return zn(!1,"TARGET_PORT_NOT_FOUND",`目标节点不存在输入端口 ${wO(r)}`,l,null);if(l.type!==c.type)return zn(!1,"PORT_TYPE_MISMATCH",`端口类型不匹配:${l.type} 输出不能连接到 ${c.type} 输入`,l,c);const u=fO(t),d=fO(e);if(hw(c.deniedSourceNodeKeys,u))return zn(!1,"SOURCE_NODE_DENIED",`目标输入端口禁止源节点 ${u}`,l,c);if(hw(l.deniedTargetNodeKeys,d))return zn(!1,"TARGET_NODE_DENIED",`源输出端口禁止目标节点 ${d}`,l,c);if(pO(c.allowedSourceNodeKeys,u))return zn(!1,"SOURCE_NODE_NOT_ALLOWED",`源节点 ${u||"(未声明 node key)"} 不在目标输入端口白名单中`,l,c);if(pO(l.allowedTargetNodeKeys,d))return zn(!1,"TARGET_NODE_NOT_ALLOWED",`目标节点 ${d||"(未声明 node key)"} 不在源输出端口白名单中`,l,c);const f=s??[],p=mO(f,t.id,l.name,"source",a);if(gO(l,p))return zn(!1,"SOURCE_MAX_CONNECTIONS_REACHED",`源输出端口 ${l.name} 最多只能连接 ${l.maxConnections} 个节点`,l,c);const m=mO(f,e.id,c.name,"target",a);return gO(c,m)?zn(!1,"TARGET_MAX_CONNECTIONS_REACHED",`目标输入端口 ${c.name} 最多只能连接 ${c.maxConnections} 个节点`,l,c):t.id===e.id?zn(!1,"SELF_CONNECTION_NOT_ALLOWED","节点不能连接到自身",l,c):zn(!0,"VALID","",l,c)},pw=72,mw=6,gw=12,bO=24,gR=16,wR=320,vO="main";function bR(t){const e=Math.max(0,Math.floor(t));if(e<=mw)return{height:pw,compact:!1};if(e<=gw)return{height:pw+(e-mw)*bO,compact:!1};const n=pw+(gw-mw)*bO;return{height:Math.min(n+(e-gw)*gR,wR),compact:!0}}function vR(t){const e=t.inputs??[],n=t.outputs??[],{height:r,compact:o}=bR(Math.max(e.length,n.length));return{inputs:e.map((i,s)=>yO(i,s,e.length,fn.TARGET,o)),outputs:n.map((i,s)=>yO(i,s,n.length,fn.SOURCE,o)),height:r,compact:o}}function yO(t,e,n,r,o){const i=dw(t),s=i.type||vO,a=i.displayName||i.name,l=yR(i.position)??(r===fn.TARGET?ne.Position.Left:ne.Position.Right);return{id:i.name,position:l,type:r,isMain:i.name===vO,label:a?h.jsx(kR,{compact:o,label:a}):void 0,maxConnections:typeof i.maxConnections=="number"?i.maxConnections:void 0,connectionType:s,portSchema:i,style:CR(e,n)}}function yR(t){if(t)switch(t){case"left":return ne.Position.Left;case"top":return ne.Position.Top;case"right":return ne.Position.Right;case"bottom":return ne.Position.Bottom;default:return}}function CR(t,e){return{top:`${(t+1)/(e+1)*100}%`}}function kR({compact:t,label:e}){return h.jsx(D.Tooltip,{title:e,children:h.jsx("span",{"data-nodepackage-port-label":!0,title:e,style:{display:"inline-block",maxWidth:t?72:112,overflow:"hidden",textOverflow:"ellipsis",verticalAlign:"middle",whiteSpace:"nowrap"},children:e})})}function SR({nodeType:t,data:e,legacyInputs:n,legacyOutputs:r,resolvePortSchema:o,overrideNodeKey:i,overrideNodeVersion:s}){var C,k;const a=$t(),l=i??ER(t,e),c=s!==void 0?s:xR(e),u=l?Wi(l,c):null,d=((k=(C=a.nodeSelector)==null?void 0:C.connectable)==null?void 0:k.enabled)===!0&&po(e),f=`${l}@${c??"latest"}`,[p,m]=y.useState(null);y.useEffect(()=>{if(!d||!l)return;if(u){m({identity:f,schema:u,failed:!1});return}let _=!1;return pc(l,c).then(S=>{_||m({identity:f,schema:S,failed:!S})}).catch(()=>{_||m({identity:f,schema:null,failed:!0})}),()=>{_=!0}},[u,f,d,l,c]);const v=(p==null?void 0:p.identity)===f?p.schema:null,b=d?u??v:null,w=y.useMemo(()=>b&&o?o(b):b,[o,b]),g=y.useMemo(()=>w?vR(w):null,[w]);return d?g?{inputs:g.inputs,outputs:g.outputs,height:g.height,status:"ready",isNodePackage:!0,schema:b}:!l||(p==null?void 0:p.identity)===f&&p.failed?{inputs:[],outputs:[],height:72,status:"error",isNodePackage:!0,schema:null}:{inputs:[],outputs:[],height:72,status:"loading",isNodePackage:!0,schema:null}:{inputs:n,outputs:r,status:"legacy",isNodePackage:!1,schema:null}}function ER(t,e){const n=e.nodeKey??e.action_key;return typeof n=="string"?n:""}function xR(t){const e=t.nodeVersion??t.action_ver;if(e==null||e==="")return;const n=Number(e);return Number.isFinite(n)?n:void 0}const ww="MCP_TRIGGER",CO="mcp_trigger",kO=200,DR=10;$e.MCP_SERVER;const Gd="dip.core.trigger.mcp-server";function Rd(t){return t===ne.Position.Left?ne.Position.Top:t===ne.Position.Right?ne.Position.Bottom:t}function SO(t){for(const e of t){const n=typeof e.type=="string"?e.type:"",r=e.data&&typeof e.data.action_key=="string"?e.data.action_key:"";if(n.startsWith(`${Gd}@`)||r===Gd)return!0}return!1}const _R=["action_key","actionKey","nodeKey","node_key"],AR=["action_ver","nodeVersion","node_version"],OR=new Set(["left","top","right","bottom"]);function TR(t){if(!t)return"";for(const e of _R){const n=t[e];if(typeof n=="string"&&n.trim())return n.trim()}return""}function NR(t){if(t)for(const e of AR){const n=t[e];if(n==null||n==="")continue;const r=Number(n);if(Number.isFinite(r)&&r>=0)return r}}function BR(t){if(t)switch(t){case"left":return ne.Position.Left;case"top":return ne.Position.Top;case"right":return ne.Position.Right;case"bottom":return ne.Position.Bottom;default:return OR.has(t),void 0}}function EO(t){return!t||t.length===0?[]:t.map(e=>e.position)}function FR(t){const e=TR(t.data);if(!e)return Ui(t.type)?Wi(t.type):null;const n=NR(t.data);return Wi(e,n)}function MR(t){if(!t)return{sources:[],targets:[]};const e=[];for(const r of t.outputs??[])e.push(xO(r,ne.Position.Right));const n=[];for(const r of t.inputs??[])n.push(xO(r,ne.Position.Left));return{sources:e,targets:n}}function xO(t,e){const n=dw(t);return BR(n.position)??e}function IR(t){try{const e=ji(t.type,t.data??void 0);return{sources:EO(e.outputs),targets:EO(e.inputs)}}catch{return null}}function DO(t,e){return e?{sources:t.sources.map(Rd),targets:t.targets.map(Rd)}:t}function Ns(t,e){if(!t)return{sources:[],targets:[]};const n=t.data,r=po(n??null)||Ui(t.type),o=(e==null?void 0:e.isMcpServerCanvas)===!0;if(r){const s=FR(t),a=MR(s);if(a.sources.length>0||a.targets.length>0)return DO(a,o)}const i=IR(t);return i&&(i.sources.length>0||i.targets.length>0)?DO(i,o):{sources:[],targets:[]}}function Dl(t){return t===ne.Position.Top||t===ne.Position.Bottom}function bw(t){return t===ne.Position.Left||t===ne.Position.Right}function PR(t,e){const n=Ns(t,e);return n.sources.some(Dl)||n.targets.some(Dl)}function LR(t,e){const n=Ns(t,e);return n.sources.some(bw)||n.targets.some(bw)}function $R(t,e,n,r){if(n){const o=Ns(n,r),i=_O(o.targets,t.targetHandle,n,"target",r);if(i)return Dl(i)?"vertical":"horizontal"}if(e){const o=Ns(e,r),i=_O(o.sources,t.sourceHandle,e,"source",r);if(i)return Dl(i)?"vertical":"horizontal"}return null}function _O(t,e,n,r,o){if(!e)return t[0];const s=(r==="source"?zR(n):HR(n)).find(a=>a.id===e);return s?o!=null&&o.isMcpServerCanvas?Rd(s.position):s.position:t[0]}function zR(t){try{return ji(t.type,t.data??void 0).outputs}catch{return[]}}function HR(t){try{return ji(t.type,t.data??void 0).inputs}catch{return[]}}function VR(t,e){return Ns(t,e).sources.includes(ne.Position.Top)}function AO(t){if(SO(t))return"vertical";let n=0,r=0;for(const o of t){const i=Ns(o);i.sources.some(Dl)&&(n+=1),i.sources.some(bw)&&(r+=1)}return n===0&&r===0?"horizontal":n>r?"vertical":"horizontal"}const OO=30,vw=72,TO=2;function NO(t){const e=Rd(t.position);if(e===t.position)return t;const n=t.style;if(!n||typeof n!="object")return{...t,position:e};const r={...n},o=t.position===ne.Position.Left||t.position===ne.Position.Right,i=e===ne.Position.Top||e===ne.Position.Bottom;return o&&i&&r.top!==void 0&&(r.left=r.top,delete r.top),{...t,position:e,style:r}}function jR(t){if(!t||typeof t!="string"||!t.includes("@"))return{baseNodeType:t};const e=t.split("@");if(e.length===2){const[n,r]=e;return r?{baseNodeType:n,nodeKey:r}:{baseNodeType:t}}if(e.length===3){const[n,r,o]=e,i=Number(o);return Number.isFinite(i)?{baseNodeType:n,nodeKey:r,nodeVersion:i}:(console.warn("[workflow:node-types] malformed descriptor version, falling back to base type",{type:t}),{baseNodeType:t})}return console.warn("[workflow:node-types] malformed descriptor key, falling back to base type",{type:t}),{baseNodeType:t}}const BO=y.memo(t=>{const{id:e,data:n,selected:r,type:o}=t,i=n,{isMcpServerCanvas:s}=lc(),a=y.useMemo(()=>jR(o),[o]),l=a.baseNodeType,c=uh(o),u=ne.useInternalNode(e),d=(u==null?void 0:u.data)??n,f=ji(o,d),p=f.inputs,m=c.type===pe.SWITCH?CP(d):f.outputs,v=y.useCallback(()=>A0(d),[d]),b=SR({nodeType:l,data:d,legacyInputs:p,legacyOutputs:m,...a.nodeKey?{overrideNodeKey:a.nodeKey}:{},...a.nodeVersion!==void 0?{overrideNodeVersion:a.nodeVersion}:{},...c.useNodePackagePorts&&c.type===pe.SWITCH?{resolvePortSchema:x=>oh(x,v())}:{}}),w=c.useNodePackagePorts?b.outputs:m,g=c.useNodePackagePorts?b.inputs:p,C=s?w.map(NO):w,k=s?g.map(NO):g,_=c.type===pe.SWITCH?Math.max(b.height??0,C.length>TO?C.length*OO:vw):b.height,S=i.status??me.IDLE,E=i!=null&&i.icon?void 0:c.fallbackIcon;return h.jsx(dO,{id:e,data:n,selected:r,type:l,status:S,className:c.className,iconUri:i.icon,fallbackIcon:E,inputs:k,outputs:C,height:_})});BO.displayName="DeclaredNode";function WR(t){if(t)switch(t){case"left":return ne.Position.Left;case"top":return ne.Position.Top;case"right":return ne.Position.Right;case"bottom":return ne.Position.Bottom;default:return}}function UR(t){return t===ne.Position.Top||t===ne.Position.Bottom}function FO(t,e,n){let r;n?r=e===fn.TARGET?ne.Position.Top:ne.Position.Bottom:r=WR(t)??(e===fn.TARGET?ne.Position.Left:ne.Position.Right);const o=UR(r)?ne.Position.Left:ne.Position.Top;return{position:r,styleAxis:o}}const yw=y.memo(t=>{const{id:e,data:n,selected:r,type:o}=t,{isMcpServerCanvas:i}=lc(),s=n,a=T0(o),l=s.node_type==="SwitchNode",c=l&&a?oh(a,A0(s)):a,u=((c==null?void 0:c.inputs)||[]).length,d=((c==null?void 0:c.inputs)||[]).map((g,C)=>{const{display_name:k,name:_,type:S,max_connections:E}=g,{position:x,styleAxis:O}=FO(g.position,fn.TARGET,i);return{id:_,label:k,position:x,type:fn.TARGET,protocol:S,maxConnections:E,isMain:S==="main",style:{[O]:`${10+80/(u+1)*(C+1)}%`}}}),f=((c==null?void 0:c.outputs)||[]).length,p=((c==null?void 0:c.outputs)||[]).map((g,C)=>{const{display_name:k,name:_,type:S,max_connections:E}=g,{position:x,styleAxis:O}=FO(g.position,fn.SOURCE,i);return{id:_,label:k,position:x,type:fn.SOURCE,protocol:S,maxConnections:E,isMain:S==="main",style:{[O]:`${10+80/(f+1)*(C+1)}%`}}}),m=uh(o),v=s.status??me.IDLE,b=s!=null&&s.icon?void 0:m.fallbackIcon,w=l?Math.max(vw,p.length>TO?p.length*OO:vw):void 0;return h.jsx(dO,{id:e,data:n,selected:r,type:pe.DYNAMIC,status:v,className:m.className,iconUri:s.icon,fallbackIcon:b,inputs:d,outputs:p,height:w})});yw.displayName="NodePackageNode";function MO(t,e){const n=String(t);if(typeof e!="string")throw new TypeError("Expected character");let r=0,o=n.indexOf(e);for(;o!==-1;)r++,o=n.indexOf(e,o+e.length);return r}function Wre(){}const _l=Yd(/[A-Za-z]/),Cw=Yd(/[\dA-Za-z]/);function qR(t){return t!==null&&(t<32||t===127)}function Bs(t){return t!==null&&t<-2}function An(t){return t!==null&&(t<0||t===32)}function oo(t){return t===-2||t===-1||t===32}const Kd=Yd(new RegExp("\\p{P}|\\p{S}","u")),Oi=Yd(/\s/);function Yd(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function GR(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const Xd=(function(t){if(t==null)return XR;if(typeof t=="function")return Jd(t);if(typeof t=="object")return Array.isArray(t)?RR(t):KR(t);if(typeof t=="string")return YR(t);throw new Error("Expected function, string, or object as test")});function RR(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=Xd(t[n]);return Jd(r);function r(...o){let i=-1;for(;++i<e.length;)if(e[i].apply(this,o))return!0;return!1}}function KR(t){const e=t;return Jd(n);function n(r){const o=r;let i;for(i in t)if(o[i]!==e[i])return!1;return!0}}function YR(t){return Jd(e);function e(n){return n&&n.type===t}}function Jd(t){return e;function e(n,r,o){return!!(JR(n)&&t.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function XR(){return!0}function JR(t){return t!==null&&typeof t=="object"&&"type"in t}function Ure(t){return t}const IO=[],QR=!0,kw=!1,ZR="skip";function PO(t,e,n,r){let o;typeof e=="function"&&typeof n!="function"?(r=n,n=e):o=e;const i=Xd(o),s=r?-1:1;a(t,void 0,[])();function a(l,c,u){const d=l&&typeof l=="object"?l:{};if(typeof d.type=="string"){const p=typeof d.tagName=="string"?d.tagName:typeof d.name=="string"?d.name:void 0;Object.defineProperty(f,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return f;function f(){let p=IO,m,v,b;if((!e||i(l,c,u[u.length-1]||void 0))&&(p=eK(n(l,u)),p[0]===kw))return p;if("children"in l&&l.children){const w=l;if(w.children&&p[0]!==ZR)for(v=(r?w.children.length:-1)+s,b=u.concat(w);v>-1&&v<w.children.length;){const g=w.children[v];if(m=a(g,v,b)(),m[0]===kw)return m;v=typeof m[1]=="number"?m[1]:v+s}}return p}}}function eK(t){return Array.isArray(t)?t:typeof t=="number"?[QR,t]:t==null?IO:[t]}function tK(t,e,n){const o=Xd((n||{}).ignore||[]),i=nK(e);let s=-1;for(;++s<i.length;)PO(t,"text",a);function a(c,u){let d=-1,f;for(;++d<u.length;){const p=u[d],m=f?f.children:void 0;if(o(p,m?m.indexOf(p):void 0,f))return;f=p}if(f)return l(c,u)}function l(c,u){const d=u[u.length-1],f=i[s][0],p=i[s][1];let m=0;const b=d.children.indexOf(c);let w=!1,g=[];f.lastIndex=0;let C=f.exec(c.value);for(;C;){const k=C.index,_={index:C.index,input:C.input,stack:[...u,c]};let S=p(...C,_);if(typeof S=="string"&&(S=S.length>0?{type:"text",value:S}:void 0),S===!1?f.lastIndex=k+1:(m!==k&&g.push({type:"text",value:c.value.slice(m,k)}),Array.isArray(S)?g.push(...S):S&&g.push(S),m=k+C[0].length,w=!0),!f.global)break;C=f.exec(c.value)}return w?(m<c.value.length&&g.push({type:"text",value:c.value.slice(m)}),d.children.splice(b,1,...g)):g=[c],b+g.length}}function nK(t){const e=[];if(!Array.isArray(t))throw new TypeError("Expected find and replace tuple or list of tuples");const n=!t[0]||Array.isArray(t[0])?t:[t];let r=-1;for(;++r<n.length;){const o=n[r];e.push([rK(o[0]),oK(o[1])])}return e}function rK(t){return typeof t=="string"?new RegExp(GR(t),"g"):t}function oK(t){return typeof t=="function"?t:function(){return t}}const Sw="phrasing",Ew=["autolink","link","image","label"];function iK(){return{transforms:[fK],enter:{literalAutolink:aK,literalAutolinkEmail:xw,literalAutolinkHttp:xw,literalAutolinkWww:xw},exit:{literalAutolink:dK,literalAutolinkEmail:uK,literalAutolinkHttp:lK,literalAutolinkWww:cK}}}function sK(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Sw,notInConstruct:Ew},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Sw,notInConstruct:Ew},{character:":",before:"[ps]",after:"\\/",inConstruct:Sw,notInConstruct:Ew}]}}function aK(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function xw(t){this.config.enter.autolinkProtocol.call(this,t)}function lK(t){this.config.exit.autolinkProtocol.call(this,t)}function cK(t){this.config.exit.data.call(this,t);const e=this.stack[this.stack.length-1];e.type,e.url="http://"+this.sliceSerialize(t)}function uK(t){this.config.exit.autolinkEmail.call(this,t)}function dK(t){this.exit(t)}function fK(t){tK(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,hK],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),pK]],{ignore:["link","linkReference"]})}function hK(t,e,n,r,o){let i="";if(!LO(o)||(/^w/i.test(e)&&(n=e+n,e="",i="http://"),!mK(n)))return!1;const s=gK(n+r);if(!s[0])return!1;const a={type:"link",title:null,url:i+e+s[0],children:[{type:"text",value:e+s[0]}]};return s[1]?[a,{type:"text",value:s[1]}]:a}function pK(t,e,n,r){return!LO(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+n,children:[{type:"text",value:e+"@"+n}]}}function mK(t){const e=t.split(".");return!(e.length<2||e[e.length-1]&&(/_/.test(e[e.length-1])||!/[a-zA-Z\d]/.test(e[e.length-1]))||e[e.length-2]&&(/_/.test(e[e.length-2])||!/[a-zA-Z\d]/.test(e[e.length-2])))}function gK(t){const e=/[!"&'),.:;<>?\]}]+$/.exec(t);if(!e)return[t,void 0];t=t.slice(0,e.index);let n=e[0],r=n.indexOf(")");const o=MO(t,"(");let i=MO(t,")");for(;r!==-1&&o>i;)t+=n.slice(0,r+1),n=n.slice(r+1),r=n.indexOf(")"),i++;return[t,n]}function LO(t,e){const n=t.input.charCodeAt(t.index-1);return(t.index===0||Oi(n)||Kd(n))&&(!e||n!==47)}function Al(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}$O.peek=xK;function wK(){this.buffer()}function bK(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function vK(){this.buffer()}function yK(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function CK(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Al(this.sliceSerialize(t)).toLowerCase(),n.label=e}function kK(t){this.exit(t)}function SK(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=Al(this.sliceSerialize(t)).toLowerCase(),n.label=e}function EK(t){this.exit(t)}function xK(){return"["}function $O(t,e,n,r){const o=n.createTracker(r);let i=o.move("[^");const s=n.enter("footnoteReference"),a=n.enter("reference");return i+=o.move(n.safe(n.associationId(t),{after:"]",before:i})),a(),s(),i+=o.move("]"),i}function DK(){return{enter:{gfmFootnoteCallString:wK,gfmFootnoteCall:bK,gfmFootnoteDefinitionLabelString:vK,gfmFootnoteDefinition:yK},exit:{gfmFootnoteCallString:CK,gfmFootnoteCall:kK,gfmFootnoteDefinitionLabelString:SK,gfmFootnoteDefinition:EK}}}function _K(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:n,footnoteReference:$O},unsafe:[{character:"[",inConstruct:["label","phrasing","reference"]}]};function n(r,o,i,s){const a=i.createTracker(s);let l=a.move("[^");const c=i.enter("footnoteDefinition"),u=i.enter("label");return l+=a.move(i.safe(i.associationId(r),{before:l,after:"]"})),u(),l+=a.move("]:"),r.children&&r.children.length>0&&(a.shift(4),l+=a.move((e?`
|
|
119
119
|
`:" ")+i.indentLines(i.containerFlow(r,a.current()),e?zO:AK))),c(),l}}function AK(t,e,n){return e===0?t:zO(t,e,n)}function zO(t,e,n){return(n?"":" ")+t}const OK=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];HO.peek=MK;function TK(){return{canContainEols:["delete"],enter:{strikethrough:BK},exit:{strikethrough:FK}}}function NK(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:OK}],handlers:{delete:HO}}}function BK(t){this.enter({type:"delete",children:[]},t)}function FK(t){this.exit(t)}function HO(t,e,n,r){const o=n.createTracker(r),i=n.enter("strikethrough");let s=o.move("~~");return s+=n.containerPhrasing(t,{...o.current(),before:s,after:"~"}),s+=o.move("~~"),i(),s}function MK(){return"~"}function IK(t){return t.length}function PK(t,e){const n=e||{},r=(n.align||[]).concat(),o=n.stringLength||IK,i=[],s=[],a=[],l=[];let c=0,u=-1;for(;++u<t.length;){const v=[],b=[];let w=-1;for(t[u].length>c&&(c=t[u].length);++w<t[u].length;){const g=LK(t[u][w]);if(n.alignDelimiters!==!1){const C=o(g);b[w]=C,(l[w]===void 0||C>l[w])&&(l[w]=C)}v.push(g)}s[u]=v,a[u]=b}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<c;)i[d]=VO(r[d]);else{const v=VO(r);for(;++d<c;)i[d]=v}d=-1;const f=[],p=[];for(;++d<c;){const v=i[d];let b="",w="";v===99?(b=":",w=":"):v===108?b=":":v===114&&(w=":");let g=n.alignDelimiters===!1?1:Math.max(1,l[d]-b.length-w.length);const C=b+"-".repeat(g)+w;n.alignDelimiters!==!1&&(g=b.length+g+w.length,g>l[d]&&(l[d]=g),p[d]=g),f[d]=C}s.splice(1,0,f),a.splice(1,0,p),u=-1;const m=[];for(;++u<s.length;){const v=s[u],b=a[u];d=-1;const w=[];for(;++d<c;){const g=v[d]||"";let C="",k="";if(n.alignDelimiters!==!1){const _=l[d]-(b[d]||0),S=i[d];S===114?C=" ".repeat(_):S===99?_%2?(C=" ".repeat(_/2+.5),k=" ".repeat(_/2-.5)):(C=" ".repeat(_/2),k=C):k=" ".repeat(_)}n.delimiterStart!==!1&&!d&&w.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&g==="")&&(n.delimiterStart!==!1||d)&&w.push(" "),n.alignDelimiters!==!1&&w.push(C),w.push(g),n.alignDelimiters!==!1&&w.push(k),n.padding!==!1&&w.push(" "),(n.delimiterEnd!==!1||d!==c-1)&&w.push("|")}m.push(n.delimiterEnd===!1?w.join("").replace(/ +$/,""):w.join(""))}return m.join(`
|
|
120
120
|
`)}function LK(t){return t==null?"":String(t)}function VO(t){const e=typeof t=="string"?t.codePointAt(0):0;return e===67||e===99?99:e===76||e===108?108:e===82||e===114?114:0}function $K(t,e,n,r){const o=n.enter("blockquote"),i=n.createTracker(r);i.move("> "),i.shift(2);const s=n.indentLines(n.containerFlow(t,i.current()),zK);return o(),s}function zK(t,e,n){return">"+(n?"":" ")+t}function HK(t,e){return jO(t,e.inConstruct,!0)&&!jO(t,e.notInConstruct,!1)}function jO(t,e,n){if(typeof e=="string"&&(e=[e]),!e||e.length===0)return n;let r=-1;for(;++r<e.length;)if(t.includes(e[r]))return!0;return!1}function WO(t,e,n,r){let o=-1;for(;++o<n.unsafe.length;)if(n.unsafe[o].character===`
|