@digitalsee-ai/rcs 1.0.2 → 1.0.3
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 +194 -201
- package/dist/rcs.es.js.map +1 -1
- package/dist/rcs.umd.js +10 -10
- package/dist/rcs.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/rcs.umd.js
CHANGED
|
@@ -7,20 +7,20 @@
|
|
|
7
7
|
Copyright (c) 2018 Jed Watson.
|
|
8
8
|
Licensed under the MIT License (MIT), see
|
|
9
9
|
http://jedwatson.github.io/classnames
|
|
10
|
-
*/var _0;function rB(){return _0||(_0=1,(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var i="",s=0;s<arguments.length;s++){var a=arguments[s];a&&(i=o(i,r(a)))}return i}function r(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return n.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var s="";for(var a in i)e.call(i,a)&&i[a]&&(s=o(s,a));return s}function o(i,s){return s?i?i+" "+s:i+s:i}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(Cf)),Cf.exports}var oB=rB();const kn=Ii(oB),iB=(t,e,n,r)=>(t.edges||[]).some(i=>i?r===je.SOURCE?i.source===e&&(i.sourceHandle===n||!i.sourceHandle&&n==="output"):i.target===e&&(i.targetHandle===n||!i.targetHandle&&n==="input"):!1),sB=[Ie.MEMORY,Ie.TOOLS,Ie.CHAT_MODEL],aB=[Be.AI_MEMORY,Be.AI_TOOL,Be.MCP_SERVER,Be.BUILTIN_MCP,Be.AI_LANGUAGE_MODEL],N0=({type:t,id:e,nodeId:n,position:r=ae.Position.Right,style:o={},isValidConnection:i,onConnect:s,label:a,status:l,nodeStatus:c=me.IDLE,category:u="main",protocol:d,shape:h="rhombus",connectionLimit:p=1/0})=>{const{getHandleConnections:m,handleStatus:w}=FN(),{getNode:v}=ae.useReactFlow(),{getNodes:y}=Fi(),g=y(),k=Ct(),A=Vt(),{openNodeSelector:C,nodeSelectorVisible:E}=Es(),D=L=>L.inProgress,S=ae.useStore(b.useCallback(L=>iB(L,n,e,t),[n,e,t])),O=m(n,e,(L=>L==="source"?sf.OUTPUT:sf.INPUT)(t)),B=S||O.length>0,F=O.length>=p,M=ae.useConnection(D),T=t===je.SOURCE&&(!B||!F)&&!M&&k,P=w(n,e),$=l||P&&P||"default",W=b.useCallback(L=>{var re,ie;const q=g.find(he=>he.id===L.target),J=q==null?void 0:q.data,K=J==null?void 0:J.protocol;if(sB.includes(L.sourceHandle)||aB.includes(K))switch(K){case Be.AI_MEMORY:return L.sourceHandle===Ie.MEMORY;case Be.AI_TOOL:return L.sourceHandle===Ie.TOOLS;case Be.AI_LANGUAGE_MODEL:return L.sourceHandle===Ie.CHAT_MODEL;case Be.BUILTIN_MCP:return L.sourceHandle===Ie.BUILTIN_MCP||((ie=(re=J==null?void 0:J.protocol)==null?void 0:re.toUpperCase)==null?void 0:ie.call(re))==="BUILTIN_MCP";case Be.MCP_SERVER:return L.sourceHandle===Ie.TOOLS;default:return!1}return F||L.source===L.target&&L.sourceHandle!==Ie.LOOP?!1:i?i(L):!0},[F,i,g,k]),V=b.useCallback(()=>{var re,ie;const L=v(n);if(!L)return{x:0,y:0};const q=((re=L.measured)==null?void 0:re.width)||240,J=((ie=L.measured)==null?void 0:ie.height)||240;let K={x:0,y:0};switch(r){case ae.Position.Right:K={x:L.position.x+q+100,y:L.position.y};break;case ae.Position.Left:K={x:L.position.x-100,y:L.position.y};break;case ae.Position.Bottom:K={x:L.position.x,y:L.position.y+J+100};break;case ae.Position.Top:K={x:L.position.x,y:L.position.y-100};break}return K},[n,r,v]),X=L=>{var re;L.stopPropagation();const q=y(),J=(re=A.canvas.limits)==null?void 0:re.maxNodes;if(typeof J=="number"&&q.length>=J){x.message.warning("已达到画布允许的最大节点数");return}const K=V();C({sourceNodeId:n,sourceHandle:e,position:K,protocol:d,refresh:E})},G=Wo.main,te=()=>{switch($){case"connected":return Wo.connected;case"connecting":return Wo.connecting;case"error":return Wo.error;default:return{}}},H=()=>Object.hasOwn(Wo.nodeStatus,c)?Wo.nodeStatus[c]:{},j={...G,...te(),...H(),...o},Y=kn("workflow-handle",`workflow-${t}-handle`,"nodrag nopan",`workflow-handle-${$}`,`workflow-handle-${u}`,{"workflow-handle-with-label":!!a,"workflow-handle-main":u==="main","workflow-handle-full":F,"workflow-handle-success":c===me.SUCCESS||c===me.RUNNABLE,"workflow-handle-running":c===me.RUNNING,"workflow-handle-failed":c===me.FAILED,"workflow-handle-invalid":c===me.INVALID},`workflow-handle-target-${r}`,`workflow-handle-shape-${h}`),se=()=>{let L={position:"absolute",zIndex:5,pointerEvents:"all"},q={...br.line,width:"100%",height:"100%"},J={position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",zIndex:6,...br.button};switch(r){case ae.Position.Right:L={...L,right:"-3px",top:o.top,transform:"translateY(-50%)",width:br.horizontal.width,height:br.horizontal.height},J={...J,right:"-100%",top:"50%",transform:"translate(50%, -50%)"},q={...q,left:61};break;case ae.Position.Left:L={...L,left:"-6px",top:"50%",transform:"translateY(-50%)",width:"36px",height:br.horizontal.height},J={...J,left:"-8px",top:"50%",transform:"translate(-50%, -50%)"},q={...q,left:61};break;case ae.Position.Bottom:L={...L,bottom:"-6px",top:"100%",left:o.left,width:br.vertical.width,height:br.vertical.height},q={...q,left:1},J={...J,bottom:"-8px",left:"calc(50% + 1px)",transform:"translate(-50%, 50%)"};break;case ae.Position.Top:L={...L,top:"-6px",left:"50%",transform:"translateX(-50%)",width:br.vertical.width,height:br.vertical.height},J={...J,top:"-8px",left:"50%",transform:"translate(-50%, -50%)"};break}return{containerStyle:L,extenderStyle:q,btnStyle:J}},Q=()=>{if(!T)return null;const L=se();return f.jsxs("div",{className:"workflow-handle-extender-container nodrag nopan",style:L.containerStyle,children:[f.jsx("div",{className:"workflow-handle-extender",style:L.extenderStyle}),f.jsx("div",{className:"workflow-handle-extender-btn",style:L.btnStyle,onClick:X,children:f.jsx(FT.AiOutlinePlusCircle,{})})]})},le=()=>{if(!a)return null;let L;switch(r){case ae.Position.Left:L={left:-8,textAlign:"right"};break;case ae.Position.Right:L={right:-38,top:-3,position:"absolute",zIndex:1e3,textAlign:"center"};break;case ae.Position.Top:L={position:"absolute",top:-8,textAlign:"center"};break;case ae.Position.Bottom:L={position:"absolute",bottom:-18,left:"-150%",textAlign:"center"};break;default:L={right:-8}}return f.jsx("span",{className:"workflow-handle-label",style:L,children:a})};return f.jsxs("div",{children:[f.jsx(ae.Handle,{type:t,position:r,id:e,isConnectableStart:k,isConnectable:!F,isValidConnection:W,onConnect:s,className:Y,style:j,children:a&&le()}),f.jsx("div",{className:"custom-handle-container",children:t==="source"&&Q()})]})},Xl=b.createContext(null),kf=({children:t,variables:e=[],variablePrefix:n="{{",variableSuffix:r="}}",onValidateVariable:o})=>{const[i,s]=b.useState(null),[a,l]=b.useState(!1),[c,u]=b.useState(e),d=b.useRef(new Map),h=b.useCallback(C=>{d.current.set(C.id,C)},[]),p=b.useCallback(C=>{d.current.delete(C),s(E=>E===C?null:E)},[]),m=b.useCallback(C=>{s(C),l(!0)},[]),w=b.useCallback(()=>{s(null)},[]),v=b.useCallback(C=>C.startsWith(n)&&C.endsWith(r)?C:`${n}${C}${r}`,[n,r]),y=b.useCallback(C=>C.startsWith(n)&&C.endsWith(r)?C.slice(n.length,-r.length):null,[n,r]),g=b.useCallback(C=>{if(o)return o(C);const E=y(C)||C;return c.some(D=>D.path===E)},[o,c,y]),k=b.useCallback((C,E=!0)=>{if(!i)return;const D=d.current.get(i);if(!D)return;const S=E?v(C):C;D.insertVariable(S,E)},[i,v]),A={activeFieldId:i,selectorVisible:a,availableVariables:c,registerField:h,unregisterField:p,activateField:m,deactivateField:w,setSelectorVisible:l,insertVariableToActiveField:k,setAvailableVariables:u,validateVariable:g,formatVariable:v,extractVariable:y};return f.jsx(Xl.Provider,{value:A,children:t})},lB=()=>{const t=b.useContext(Xl);if(!t)throw new Error("useVariableSelector must be used within a VariableSelectorProvider");return t},B0=(t,e,n)=>{const r=b.useContext(Xl),o=mt.useRef(e),i=mt.useRef(n),s=mt.useRef(r);return o.current=e,i.current=n,s.current=r,mt.useEffect(()=>{const a=s.current;if(!a)return;const l={id:t,insertVariable:(c,u)=>o.current(c,u),focus:()=>i.current()};return a.registerField(l),()=>{a.unregisterField(t)}},[t]),{activate:()=>{var a;(a=s.current)==null||a.activateField(t)},deactivate:()=>{var a;return(a=s.current)==null?void 0:a.deactivateField()},isActive:(r==null?void 0:r.activeFieldId)===t}},xf=()=>b.useContext(Xl),Sf={meta:{name:"ant-design-5x-full-theme",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#1677ff",colorInfo:"#1677ff",colorSuccess:"#52c41a",colorWarning:"#faad14",colorError:"#ff4d4f",colorTextBase:"#000000",colorBgBase:"#ffffff",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.5714285714285714,borderRadius:6,borderRadiusSM:4,borderRadiusLG:8,lineWidth:1,lineType:"solid",controlHeight:32,controlHeightSM:24,controlHeightLG:40,sizeUnit:4,sizeStep:4,padding:16,paddingXS:8,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:8,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05)",boxShadowSecondary:"0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05)",boxShadowTertiary:"0 1px 2px 0 rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px 0 rgba(0, 0, 0, 0.02)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:8},Anchor:{linkPaddingInlineStart:16},AutoComplete:{},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:6,borderRadiusSM:4,borderRadiusLG:8,controlHeight:32,controlHeightSM:24,controlHeightLG:40,paddingInline:15,paddingInlineLG:15,paddingInlineSM:7,contentFontSize:14,contentFontSizeLG:16,contentFontSizeSM:14,primaryShadow:"0 2px 0 rgba(5, 145, 255, 0.1)",dangerShadow:"0 2px 0 rgba(255, 38, 5, 0.06)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:4},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:40,controlHeightLG:48,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:32,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:32,controlHeightSM:24,controlHeightLG:40,paddingInline:11,paddingInlineSM:7,paddingInlineLG:11,paddingBlock:4,paddingBlockSM:0,paddingBlockLG:6,borderRadius:6},InputNumber:{controlHeight:32,controlHeightSM:24,controlHeightLG:40},Layout:{headerBg:"#001529",headerHeight:64,headerPadding:"0 50px",bodyBg:"#f5f5f5",siderBg:"#001529",triggerBg:"#002140"},List:{itemPadding:"12px 0"},Mentions:{},Menu:{itemHeight:40,iconSize:14,collapsedIconSize:16,horizontalItemBorderRadius:6,itemBorderRadius:6},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16},Notification:{},Pagination:{itemSize:32,itemSizeSM:24},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{buttonSolidCheckedBg:"#1677ff"},Rate:{},Result:{},Segmented:{controlHeight:32},Select:{controlHeight:32,controlHeightSM:24,controlHeightLG:40,multipleItemHeight:24,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:22,trackMinWidth:44,handleSize:18},Table:{headerBg:"#fafafa",headerSortActiveBg:"#f0f0f0",headerSortHoverBg:"#f5f5f5",rowHoverBg:"#fafafa",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:4,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 16px"},Tag:{borderRadiusSM:4},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:32,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}},cB="df",F0=({children:t,customTheme:e,locale:n=Nw,prefixCls:r=cB})=>{const o=mt.useMemo(()=>({cssVar:{prefix:r},algorithm:x.theme.defaultAlgorithm,token:Sf.token,components:Sf.components,...e}),[r,e]);return f.jsx(x.ConfigProvider,{prefixCls:r,locale:n,theme:o,getPopupContainer:i=>(i==null?void 0:i.parentElement)||document.body,children:t})};function qn(t,e){if(t==null||e==="")return;const n=e.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let r=t;for(const o of n){if(r==null)return;const i=Number(o);!Number.isNaN(i)&&Array.isArray(r)?r=r[i]:r=r[o]}return r}const uB=t=>!t||t.length===0,I0=(t,e)=>t==null?!1:Array.isArray(t)?Array.isArray(e)?e.some(n=>t.includes(n)):t.includes(e):typeof t=="string"?Array.isArray(e)?e.some(n=>t.includes(String(n))):t.includes(String(e)):!1,M0=t=>t==null?!0:typeof t=="string"?t.trim().length===0:Array.isArray(t)?t.length===0:typeof t=="object"?Object.keys(t).length===0:!1,P0=(t,e)=>Array.isArray(e)?e.includes(t):!1,dB=(t,e,n)=>{switch(t){case"EQ":return e===n;case"NOT":return e!==n;case"GT":return Number(e)>Number(n);case"LT":return Number(e)<Number(n);case"GE":return Number(e)>=Number(n);case"LE":return Number(e)<=Number(n);case"ISEVEN":return Number(e)%2===0;case"ISODD":return Math.abs(Number(e))%2===1;case"IC":return I0(e,n);case"NIC":return!I0(e,n);case"IN":return P0(e,n);case"NIN":case"NOT_IN":return!P0(e,n);case"EXISTS":return e!=null;case"EMPTY":return M0(e);case"NOT_EMPTY":return!M0(e);default:return!1}},Go=(t,e)=>{if(!t)return!0;const{AND:n,OR:r,key:o,keyword:i,value:s}=t,a=Array.isArray(n),l=Array.isArray(r);if(a||l){const u=n??[],d=r??[];let h=!0,p=uB(d);for(const m of u){if(!h)break;h=Go(m,e)}for(const m of d){if(p)break;p=Go(m,e)}return h&&p}if(!o||!i)return!0;const c=qn(e,o);return dB(i,c,s)};function fB(t,e){const{eventPayload:n,formValues:r}=e;if(t.startsWith("payload.")){const o=t.slice(8);return qn(n.payload||{},o)}if(t.startsWith("formValues.")){const o=t.slice(11);return qn(r,o)}return t in n?n[t]:n.payload&&t in n.payload?n.payload[t]:qn(r,t)}function hB(t,e){const{form:n}=e,{targets:r}=t;for(const o of r)n.setFieldValue(o,void 0);e.executionDepth===1&&console.log("[ActionExecutor] 清空字段:",r)}function pB(t,e){const{form:n}=e,{target:r,value:o,valueFrom:i}=t;let s;i?s=fB(i,e):s=o,n.setFieldValue(r,s),e.executionDepth===1&&console.log(`[ActionExecutor] 设置字段值: ${r} =`,s)}function mB(t,e){const{target:n,disabled:r}=t;e.executionDepth===1&&(console.log(`[ActionExecutor] 设置字段禁用状态: ${n} = ${r}`),console.warn("[ActionExecutor] setFieldDisabled 需要外部状态管理支持,当前仅记录日志"))}async function gB(t,e){const{form:n}=e,{targets:r}=t;try{r&&r.length>0?await n.validateFields(r):await n.validateFields(),e.executionDepth===1&&console.log("[ActionExecutor] 触发验证:",r||"所有字段")}catch(o){e.executionDepth===1&&console.log("[ActionExecutor] 验证失败:",o)}}async function wB(t,e){const{optionsLoader:n,form:r}=e,{action:o,params:i,resultTo:s}=t;if(!n){console.warn("[ActionExecutor] 未提供 optionsLoader,无法执行 callDataLoader 动作");return}try{const a=await n(o,i||{},{values:e.formValues});s&&(r.setFieldValue(s,a),e.executionDepth===1&&console.log(`[ActionExecutor] 数据加载完成,结果设置到: ${s}`,a))}catch(a){console.error("[ActionExecutor] 数据加载失败:",a)}}async function vB(t,e){const{customHandlers:n}=e,{handler:r,params:o}=t;if(!n||!n[r]){console.warn(`[ActionExecutor] 未找到自定义处理器: ${r}`);return}try{await n[r](e,o),e.executionDepth===1&&console.log(`[ActionExecutor] 执行自定义动作: ${r}`)}catch(i){console.error(`[ActionExecutor] 自定义动作执行失败: ${r}`,i)}}async function yB(t,e){switch(t.type){case"clearFields":hB(t,e);break;case"setFieldValue":pB(t,e);break;case"setFieldDisabled":mB(t,e);break;case"triggerValidation":await gB(t,e);break;case"callDataLoader":await wB(t,e);break;case"custom":await vB(t,e);break;default:console.warn("[ActionExecutor] 未知的动作类型:",t.type)}}async function bB(t,e){for(const n of t)await yB(n,e)}function CB(t){const{events:e,form:n,optionsLoader:r,customHandlers:o,maxExecutionDepth:i=10,debug:s=!1}=t,a=b.useRef(0),l=b.useRef(new Map),c=b.useCallback(async(v,y)=>{if(a.current+=1,a.current>i){console.error(`[EventEngine] 执行深度超过限制 (${i}),可能存在无限循环`,v.id||v.trigger),a.current=0;return}try{const g=n.getFieldsValue();if(v.conditions&&!Go(v.conditions,g)){s&&console.log("[EventEngine] 条件不满足,跳过执行:",v.id);return}const k={form:n,formValues:g,eventPayload:y,optionsLoader:r,customHandlers:o,executionDepth:a.current};await bB(v.actions,k),s&&console.log("[EventEngine] 事件处理完成:",v.id||v.trigger)}finally{a.current-=1}},[n,r,o,i,s]),u=b.useCallback(v=>{const y=e.filter(g=>{const{trigger:k}=g;return k.type!==v.type?!1:(k.type==="fieldChange"||k.type==="fieldBlur"||k.type==="fieldFocus")&&"field"in k?k.field===v.field:k.type==="custom"&&"eventName"in k?k.eventName===v.eventName:k.type==="formMount"});for(const g of y)if(g.debounce&&g.debounce>0){const k=`${g.id||JSON.stringify(g.trigger)}`,A=l.current.get(k);A&&clearTimeout(A);const C=setTimeout(()=>{c(g,v),l.current.delete(k)},g.debounce);l.current.set(k,C)}else c(g,v)},[e,c]),d=b.useCallback((v,y,g)=>{const k={type:"fieldChange",field:v,oldValue:g,newValue:y,timestamp:Date.now()};u(k),s&&console.log("[EventEngine] 字段变化事件:",{fieldPath:v,oldValue:g,newValue:y})},[u,s]),h=b.useCallback(v=>{const y={type:"fieldBlur",field:v,timestamp:Date.now()};u(y),s&&console.log("[EventEngine] 字段失焦事件:",{fieldPath:v})},[u,s]),p=b.useCallback(v=>{const y={type:"fieldFocus",field:v,timestamp:Date.now()};u(y),s&&console.log("[EventEngine] 字段聚焦事件:",{fieldPath:v})},[u,s]);b.useEffect(()=>{const v={type:"formMount",timestamp:Date.now()};u(v)},[]),b.useEffect(()=>()=>{for(const v of l.current.values())clearTimeout(v);l.current.clear()},[]);const m=b.useCallback((v,y)=>{const g={type:"custom",eventName:v,payload:y,timestamp:Date.now()};u(g)},[u]);return{triggerFieldChange:d,fieldEventHandlers:{onBlur:h,onFocus:p,dispatch:m}}}const Ef=b.createContext({}),L0=({value:t,children:e})=>f.jsx(Ef.Provider,{value:t,children:e}),kB=()=>b.useContext(Ef);class Jl{constructor(){it(this,"registry",new Map)}register(e,n,r={}){const{override:o=!1}=r;if(this.registry.has(e)&&!o){console.warn(`[FieldRegistry] 字段类型 "${e}" 已注册。使用 { override: true } 来覆盖。`);return}this.registry.set(e,n)}unregister(e){this.registry.delete(e)}get(e){return this.registry.get(e)}has(e){return this.registry.has(e)}getRegisteredTypes(){return Array.from(this.registry.keys())}clone(){const e=new Jl;return this.registry.forEach((n,r)=>{e.register(r,n)}),e}}const Rl=new Jl;function xB(){return new Jl}const $0=b.createContext(Rl),SB=({registry:t,additionalRegistrations:e,children:n})=>{const r=b.useMemo(()=>{const o=t||Rl.clone();if(e!=null&&e.length)for(const{type:i,definition:s}of e)o.register(i,s,{override:!0});return o},[t,e]);return f.jsx($0.Provider,{value:r,children:n})},Ql=()=>b.useContext($0);var be=(t=>(t.TEXT="TEXT",t.TEXTAREA="TEXTAREA",t.NUMBER="NUMBER",t.PASSWORD="PASSWORD",t.SELECT="SELECT",t.MULTI_SELECT="MULTI_SELECT",t.RADIO="RADIO",t.CHECKBOX="CHECKBOX",t.CHECKBOX_GROUP="CHECKBOX_GROUP",t.SWITCH="SWITCH",t.CASCADER="CASCADER",t.TREE_SELECT="TREE_SELECT",t.DATE="DATE",t.DATE_RANGE="DATE_RANGE",t.TIME="TIME",t.TIME_RANGE="TIME_RANGE",t.DATETIME="DATETIME",t.UPLOAD="UPLOAD",t.RATE="RATE",t.SLIDER="SLIDER",t.COLOR_PICKER="COLOR_PICKER",t.MENTIONS="MENTIONS",t.AUTO_COMPLETE="AUTO_COMPLETE",t.LABEL="LABEL",t.HIDDEN="HIDDEN",t.JSON="JSON",t.DIVIDER="DIVIDER",t.INFO_CARD="INFO_CARD",t.ARRAY="ARRAY",t.OBJECT="OBJECT",t.KEY_VALUE="KEY_VALUE",t.ARRAY_OBJECT="ARRAY_OBJECT",t))(be||{});function EB(t){switch(t){case be.NUMBER:case be.SLIDER:case be.RATE:return"number";case be.CHECKBOX:case be.SWITCH:return"boolean";case be.MULTI_SELECT:case be.CHECKBOX_GROUP:case be.DATE_RANGE:case be.TIME_RANGE:case be.ARRAY:case be.ARRAY_OBJECT:return"array";case be.DATE:case be.DATETIME:case be.TIME:return"object";case be.OBJECT:case be.KEY_VALUE:return"object";default:return}}function Mi(t,e,n){const r=[],o=n?EB(n):void 0;for(const i of t){if(i.type==="when"){Go(i.conditions,e)&&r.push(...Mi(i.rules,e,n));continue}const s=DB(i,o);s&&r.push(s)}return r}function DB(t,e){const n={message:t.message,warningOnly:t.warningOnly};switch(t.type){case"required":return e?{...n,required:!0,type:e}:{...n,required:!0};case"type":return{...n,type:t.value};case"min":return{...n,min:t.value,type:e};case"max":return{...n,max:t.value,type:e};case"len":return{...n,len:t.value};case"pattern":return{...n,pattern:new RegExp(t.value,t.flags)};case"enum":return{...n,enum:t.value};case"whitespace":return{...n,whitespace:!0};default:return null}}const AB=t=>!t||typeof t!="object"?!1:"AND"in t||"OR"in t?!0:"keyword"in t&&"key"in t;function Ys(t,e){return t.visibleWhen&&t.visibleWhen.conditions?Go(t.visibleWhen.conditions,e):!0}function OB(t){var e;return((e=t.visibleWhen)==null?void 0:e.hideStrategy)||"unregister"}function Pi(t,e,n=!1){return typeof t=="boolean"?t:AB(t)?Go(t,e):n}const TB=(t,e)=>{const n=e.split(".");let r=t;for(let i=0;i<n.length-1;i+=1){const s=n[i],a=r==null?void 0:r[s];if(typeof a!="object"||a===null)return;r=a}const o=n[n.length-1];if(Array.isArray(r)){const i=Number(o);Number.isNaN(i)||r.splice(i,1)}else r&&delete r[o]};function _B(t,e,n){const r=structuredClone(e);for(const o of t.fields)n[o.name]===!1&&TB(r,o.name);return r}const Zl="{{$fromAI}}",H0=({value:t,onChange:e,children:n,aiFillable:r=!0,disabled:o=!1})=>{const[i,s]=b.useState(t===Zl),[a,l]=b.useState(void 0);if(b.useEffect(()=>{s(t===Zl)},[t]),!r)return b.cloneElement(n,{value:t,onChange:e});const c=()=>{l(t),s(!0),e==null||e(Zl)},u=()=>{s(!1),e==null||e(a)};return i?f.jsx("div",{className:"ai-field-wrapper ai-mode",children:f.jsxs("div",{className:"ai-field-display",children:[f.jsx(x.Input,{readOnly:!0,value:"由 AI 生成",className:"ai-field-input",prefix:f.jsx(Z.RobotOutlined,{className:"ai-icon"})}),!o&&f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.CloseOutlined,{}),onClick:u,className:"ai-field-close"})]})}):f.jsxs("div",{className:"ai-field-wrapper normal-mode",children:[f.jsx("div",{className:"ai-field-content",children:b.cloneElement(n,{value:t,onChange:e})}),!o&&f.jsx(x.Button,{type:"link",size:"small",icon:f.jsx(Z.RobotOutlined,{}),onClick:c,className:"ai-enable-button",children:"由 AI 生成"})]})},z0=/\{\{(.*?)\}\}/g;function Df(t,e=z0){if(!t||typeof t!="string")return[{type:"paragraph",children:[{text:""}]}];const n=t.split(`
|
|
10
|
+
*/var _0;function rB(){return _0||(_0=1,(function(t){(function(){var e={}.hasOwnProperty;function n(){for(var i="",s=0;s<arguments.length;s++){var a=arguments[s];a&&(i=o(i,r(a)))}return i}function r(i){if(typeof i=="string"||typeof i=="number")return i;if(typeof i!="object")return"";if(Array.isArray(i))return n.apply(null,i);if(i.toString!==Object.prototype.toString&&!i.toString.toString().includes("[native code]"))return i.toString();var s="";for(var a in i)e.call(i,a)&&i[a]&&(s=o(s,a));return s}function o(i,s){return s?i?i+" "+s:i+s:i}t.exports?(n.default=n,t.exports=n):window.classNames=n})()})(Cf)),Cf.exports}var oB=rB();const kn=Ii(oB),iB=(t,e,n,r)=>(t.edges||[]).some(i=>i?r===je.SOURCE?i.source===e&&(i.sourceHandle===n||!i.sourceHandle&&n==="output"):i.target===e&&(i.targetHandle===n||!i.targetHandle&&n==="input"):!1),sB=[Ie.MEMORY,Ie.TOOLS,Ie.CHAT_MODEL],aB=[Be.AI_MEMORY,Be.AI_TOOL,Be.MCP_SERVER,Be.BUILTIN_MCP,Be.AI_LANGUAGE_MODEL],N0=({type:t,id:e,nodeId:n,position:r=ae.Position.Right,style:o={},isValidConnection:i,onConnect:s,label:a,status:l,nodeStatus:c=me.IDLE,category:u="main",protocol:d,shape:h="rhombus",connectionLimit:p=1/0})=>{const{getHandleConnections:m,handleStatus:w}=FN(),{getNode:v}=ae.useReactFlow(),{getNodes:y}=Fi(),g=y(),k=Ct(),A=Vt(),{openNodeSelector:C,nodeSelectorVisible:E}=Es(),D=L=>L.inProgress,S=ae.useStore(b.useCallback(L=>iB(L,n,e,t),[n,e,t])),O=m(n,e,(L=>L==="source"?sf.OUTPUT:sf.INPUT)(t)),B=S||O.length>0,F=O.length>=p,M=ae.useConnection(D),T=t===je.SOURCE&&(!B||!F)&&!M&&k,P=w(n,e),$=l||P&&P||"default",W=b.useCallback(L=>{var re,se;const q=g.find(he=>he.id===L.target),J=q==null?void 0:q.data,K=J==null?void 0:J.protocol;if(sB.includes(L.sourceHandle)||aB.includes(K))switch(K){case Be.AI_MEMORY:return L.sourceHandle===Ie.MEMORY;case Be.AI_TOOL:return L.sourceHandle===Ie.TOOLS;case Be.AI_LANGUAGE_MODEL:return L.sourceHandle===Ie.CHAT_MODEL;case Be.BUILTIN_MCP:return L.sourceHandle===Ie.BUILTIN_MCP||((se=(re=J==null?void 0:J.protocol)==null?void 0:re.toUpperCase)==null?void 0:se.call(re))==="BUILTIN_MCP";case Be.MCP_SERVER:return L.sourceHandle===Ie.TOOLS;default:return!1}return F||L.source===L.target&&L.sourceHandle!==Ie.LOOP?!1:i?i(L):!0},[F,i,g,k]),V=b.useCallback(()=>{var re,se;const L=v(n);if(!L)return{x:0,y:0};const q=((re=L.measured)==null?void 0:re.width)||240,J=((se=L.measured)==null?void 0:se.height)||240;let K={x:0,y:0};switch(r){case ae.Position.Right:K={x:L.position.x+q+100,y:L.position.y};break;case ae.Position.Left:K={x:L.position.x-100,y:L.position.y};break;case ae.Position.Bottom:K={x:L.position.x,y:L.position.y+J+100};break;case ae.Position.Top:K={x:L.position.x,y:L.position.y-100};break}return K},[n,r,v]),X=L=>{var re;L.stopPropagation();const q=y(),J=(re=A.canvas.limits)==null?void 0:re.maxNodes;if(typeof J=="number"&&q.length>=J){x.message.warning("已达到画布允许的最大节点数");return}const K=V();C({sourceNodeId:n,sourceHandle:e,position:K,protocol:d,refresh:E})},G=Wo.main,te=()=>{switch($){case"connected":return Wo.connected;case"connecting":return Wo.connecting;case"error":return Wo.error;default:return{}}},H=()=>Object.hasOwn(Wo.nodeStatus,c)?Wo.nodeStatus[c]:{},j={...G,...te(),...H(),...o},Y=kn("workflow-handle",`workflow-${t}-handle`,"nodrag nopan",`workflow-handle-${$}`,`workflow-handle-${u}`,{"workflow-handle-with-label":!!a,"workflow-handle-main":u==="main","workflow-handle-full":F,"workflow-handle-success":c===me.SUCCESS||c===me.RUNNABLE,"workflow-handle-running":c===me.RUNNING,"workflow-handle-failed":c===me.FAILED,"workflow-handle-invalid":c===me.INVALID},`workflow-handle-target-${r}`,`workflow-handle-shape-${h}`),ie=()=>{let L={position:"absolute",zIndex:5,pointerEvents:"all"},q={...br.line,width:"100%",height:"100%"},J={position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",zIndex:6,...br.button};switch(r){case ae.Position.Right:L={...L,right:"-3px",top:o.top,transform:"translateY(-50%)",width:br.horizontal.width,height:br.horizontal.height},J={...J,right:"-100%",top:"50%",transform:"translate(50%, -50%)"},q={...q,left:61};break;case ae.Position.Left:L={...L,left:"-6px",top:"50%",transform:"translateY(-50%)",width:"36px",height:br.horizontal.height},J={...J,left:"-8px",top:"50%",transform:"translate(-50%, -50%)"},q={...q,left:61};break;case ae.Position.Bottom:L={...L,bottom:"-6px",top:"100%",left:o.left,width:br.vertical.width,height:br.vertical.height},q={...q,left:1},J={...J,bottom:"-8px",left:"calc(50% + 1px)",transform:"translate(-50%, 50%)"};break;case ae.Position.Top:L={...L,top:"-6px",left:"50%",transform:"translateX(-50%)",width:br.vertical.width,height:br.vertical.height},J={...J,top:"-8px",left:"50%",transform:"translate(-50%, -50%)"};break}return{containerStyle:L,extenderStyle:q,btnStyle:J}},Q=()=>{if(!T)return null;const L=ie();return f.jsxs("div",{className:"workflow-handle-extender-container nodrag nopan",style:L.containerStyle,children:[f.jsx("div",{className:"workflow-handle-extender",style:L.extenderStyle}),f.jsx("div",{className:"workflow-handle-extender-btn",style:L.btnStyle,onClick:X,children:f.jsx(FT.AiOutlinePlusCircle,{})})]})},le=()=>{if(!a)return null;let L;switch(r){case ae.Position.Left:L={left:-8,textAlign:"right"};break;case ae.Position.Right:L={right:-38,top:-3,position:"absolute",zIndex:1e3,textAlign:"center"};break;case ae.Position.Top:L={position:"absolute",top:-8,textAlign:"center"};break;case ae.Position.Bottom:L={position:"absolute",bottom:-18,left:"-150%",textAlign:"center"};break;default:L={right:-8}}return f.jsx("span",{className:"workflow-handle-label",style:L,children:a})};return f.jsxs("div",{children:[f.jsx(ae.Handle,{type:t,position:r,id:e,isConnectableStart:k,isConnectable:!F,isValidConnection:W,onConnect:s,className:Y,style:j,children:a&&le()}),f.jsx("div",{className:"custom-handle-container",children:t==="source"&&Q()})]})},Xl=b.createContext(null),kf=({children:t,variables:e=[],variablePrefix:n="{{",variableSuffix:r="}}",onValidateVariable:o})=>{const[i,s]=b.useState(null),[a,l]=b.useState(!1),[c,u]=b.useState(e),d=b.useRef(new Map),h=b.useCallback(C=>{d.current.set(C.id,C)},[]),p=b.useCallback(C=>{d.current.delete(C),s(E=>E===C?null:E)},[]),m=b.useCallback(C=>{s(C),l(!0)},[]),w=b.useCallback(()=>{s(null)},[]),v=b.useCallback(C=>C.startsWith(n)&&C.endsWith(r)?C:`${n}${C}${r}`,[n,r]),y=b.useCallback(C=>C.startsWith(n)&&C.endsWith(r)?C.slice(n.length,-r.length):null,[n,r]),g=b.useCallback(C=>{if(o)return o(C);const E=y(C)||C;return c.some(D=>D.path===E)},[o,c,y]),k=b.useCallback((C,E=!0)=>{if(!i)return;const D=d.current.get(i);if(!D)return;const S=E?v(C):C;D.insertVariable(S,E)},[i,v]),A={activeFieldId:i,selectorVisible:a,availableVariables:c,registerField:h,unregisterField:p,activateField:m,deactivateField:w,setSelectorVisible:l,insertVariableToActiveField:k,setAvailableVariables:u,validateVariable:g,formatVariable:v,extractVariable:y};return f.jsx(Xl.Provider,{value:A,children:t})},lB=()=>{const t=b.useContext(Xl);if(!t)throw new Error("useVariableSelector must be used within a VariableSelectorProvider");return t},B0=(t,e,n)=>{const r=b.useContext(Xl),o=mt.useRef(e),i=mt.useRef(n),s=mt.useRef(r);return o.current=e,i.current=n,s.current=r,mt.useEffect(()=>{const a=s.current;if(!a)return;const l={id:t,insertVariable:(c,u)=>o.current(c,u),focus:()=>i.current()};return a.registerField(l),()=>{a.unregisterField(t)}},[t]),{activate:()=>{var a;(a=s.current)==null||a.activateField(t)},deactivate:()=>{var a;return(a=s.current)==null?void 0:a.deactivateField()},isActive:(r==null?void 0:r.activeFieldId)===t}},xf=()=>b.useContext(Xl),Sf={meta:{name:"ant-design-5x-full-theme",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#1677ff",colorInfo:"#1677ff",colorSuccess:"#52c41a",colorWarning:"#faad14",colorError:"#ff4d4f",colorTextBase:"#000000",colorBgBase:"#ffffff",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.5714285714285714,borderRadius:6,borderRadiusSM:4,borderRadiusLG:8,lineWidth:1,lineType:"solid",controlHeight:32,controlHeightSM:24,controlHeightLG:40,sizeUnit:4,sizeStep:4,padding:16,paddingXS:8,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:8,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05)",boxShadowSecondary:"0 6px 16px 0 rgba(0, 0, 0, 0.08), 0 3px 6px -4px rgba(0, 0, 0, 0.12), 0 9px 28px 8px rgba(0, 0, 0, 0.05)",boxShadowTertiary:"0 1px 2px 0 rgba(0, 0, 0, 0.03), 0 1px 6px -1px rgba(0, 0, 0, 0.02), 0 2px 4px 0 rgba(0, 0, 0, 0.02)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:8},Anchor:{linkPaddingInlineStart:16},AutoComplete:{},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:6,borderRadiusSM:4,borderRadiusLG:8,controlHeight:32,controlHeightSM:24,controlHeightLG:40,paddingInline:15,paddingInlineLG:15,paddingInlineSM:7,contentFontSize:14,contentFontSizeLG:16,contentFontSizeSM:14,primaryShadow:"0 2px 0 rgba(5, 145, 255, 0.1)",dangerShadow:"0 2px 0 rgba(255, 38, 5, 0.06)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:4},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:40,controlHeightLG:48,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:32,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:32,controlHeightSM:24,controlHeightLG:40,paddingInline:11,paddingInlineSM:7,paddingInlineLG:11,paddingBlock:4,paddingBlockSM:0,paddingBlockLG:6,borderRadius:6},InputNumber:{controlHeight:32,controlHeightSM:24,controlHeightLG:40},Layout:{headerBg:"#001529",headerHeight:64,headerPadding:"0 50px",bodyBg:"#f5f5f5",siderBg:"#001529",triggerBg:"#002140"},List:{itemPadding:"12px 0"},Mentions:{},Menu:{itemHeight:40,iconSize:14,collapsedIconSize:16,horizontalItemBorderRadius:6,itemBorderRadius:6},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16},Notification:{},Pagination:{itemSize:32,itemSizeSM:24},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{buttonSolidCheckedBg:"#1677ff"},Rate:{},Result:{},Segmented:{controlHeight:32},Select:{controlHeight:32,controlHeightSM:24,controlHeightLG:40,multipleItemHeight:24,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:22,trackMinWidth:44,handleSize:18},Table:{headerBg:"#fafafa",headerSortActiveBg:"#f0f0f0",headerSortHoverBg:"#f5f5f5",rowHoverBg:"#fafafa",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:4,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 16px"},Tag:{borderRadiusSM:4},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:32,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}},cB="df",F0=({children:t,customTheme:e,locale:n=Nw,prefixCls:r=cB})=>{const o=mt.useMemo(()=>({cssVar:{prefix:r},algorithm:x.theme.defaultAlgorithm,token:Sf.token,components:Sf.components,...e}),[r,e]);return f.jsx(x.ConfigProvider,{prefixCls:r,locale:n,theme:o,getPopupContainer:i=>(i==null?void 0:i.parentElement)||document.body,children:t})};function qn(t,e){if(t==null||e==="")return;const n=e.replace(/\[(\d+)\]/g,".$1").split(".").filter(Boolean);let r=t;for(const o of n){if(r==null)return;const i=Number(o);!Number.isNaN(i)&&Array.isArray(r)?r=r[i]:r=r[o]}return r}const uB=t=>!t||t.length===0,I0=(t,e)=>t==null?!1:Array.isArray(t)?Array.isArray(e)?e.some(n=>t.includes(n)):t.includes(e):typeof t=="string"?Array.isArray(e)?e.some(n=>t.includes(String(n))):t.includes(String(e)):!1,M0=t=>t==null?!0:typeof t=="string"?t.trim().length===0:Array.isArray(t)?t.length===0:typeof t=="object"?Object.keys(t).length===0:!1,P0=(t,e)=>Array.isArray(e)?e.includes(t):!1,dB=(t,e,n)=>{switch(t){case"EQ":return e===n;case"NOT":return e!==n;case"GT":return Number(e)>Number(n);case"LT":return Number(e)<Number(n);case"GE":return Number(e)>=Number(n);case"LE":return Number(e)<=Number(n);case"ISEVEN":return Number(e)%2===0;case"ISODD":return Math.abs(Number(e))%2===1;case"IC":return I0(e,n);case"NIC":return!I0(e,n);case"IN":return P0(e,n);case"NIN":case"NOT_IN":return!P0(e,n);case"EXISTS":return e!=null;case"EMPTY":return M0(e);case"NOT_EMPTY":return!M0(e);default:return!1}},Go=(t,e)=>{if(!t)return!0;const{AND:n,OR:r,key:o,keyword:i,value:s}=t,a=Array.isArray(n),l=Array.isArray(r);if(a||l){const u=n??[],d=r??[];let h=!0,p=uB(d);for(const m of u){if(!h)break;h=Go(m,e)}for(const m of d){if(p)break;p=Go(m,e)}return h&&p}if(!o||!i)return!0;const c=qn(e,o);return dB(i,c,s)};function fB(t,e){const{eventPayload:n,formValues:r}=e;if(t.startsWith("payload.")){const o=t.slice(8);return qn(n.payload||{},o)}if(t.startsWith("formValues.")){const o=t.slice(11);return qn(r,o)}return t in n?n[t]:n.payload&&t in n.payload?n.payload[t]:qn(r,t)}function hB(t,e){const{form:n}=e,{targets:r}=t;for(const o of r)n.setFieldValue(o,void 0);e.executionDepth===1&&console.log("[ActionExecutor] 清空字段:",r)}function pB(t,e){const{form:n}=e,{target:r,value:o,valueFrom:i}=t;let s;i?s=fB(i,e):s=o,n.setFieldValue(r,s),e.executionDepth===1&&console.log(`[ActionExecutor] 设置字段值: ${r} =`,s)}function mB(t,e){const{target:n,disabled:r}=t;e.executionDepth===1&&(console.log(`[ActionExecutor] 设置字段禁用状态: ${n} = ${r}`),console.warn("[ActionExecutor] setFieldDisabled 需要外部状态管理支持,当前仅记录日志"))}async function gB(t,e){const{form:n}=e,{targets:r}=t;try{r&&r.length>0?await n.validateFields(r):await n.validateFields(),e.executionDepth===1&&console.log("[ActionExecutor] 触发验证:",r||"所有字段")}catch(o){e.executionDepth===1&&console.log("[ActionExecutor] 验证失败:",o)}}async function wB(t,e){const{optionsLoader:n,form:r}=e,{action:o,params:i,resultTo:s}=t;if(!n){console.warn("[ActionExecutor] 未提供 optionsLoader,无法执行 callDataLoader 动作");return}try{const a=await n(o,i||{},{values:e.formValues});s&&(r.setFieldValue(s,a),e.executionDepth===1&&console.log(`[ActionExecutor] 数据加载完成,结果设置到: ${s}`,a))}catch(a){console.error("[ActionExecutor] 数据加载失败:",a)}}async function vB(t,e){const{customHandlers:n}=e,{handler:r,params:o}=t;if(!n||!n[r]){console.warn(`[ActionExecutor] 未找到自定义处理器: ${r}`);return}try{await n[r](e,o),e.executionDepth===1&&console.log(`[ActionExecutor] 执行自定义动作: ${r}`)}catch(i){console.error(`[ActionExecutor] 自定义动作执行失败: ${r}`,i)}}async function yB(t,e){switch(t.type){case"clearFields":hB(t,e);break;case"setFieldValue":pB(t,e);break;case"setFieldDisabled":mB(t,e);break;case"triggerValidation":await gB(t,e);break;case"callDataLoader":await wB(t,e);break;case"custom":await vB(t,e);break;default:console.warn("[ActionExecutor] 未知的动作类型:",t.type)}}async function bB(t,e){for(const n of t)await yB(n,e)}function CB(t){const{events:e,form:n,optionsLoader:r,customHandlers:o,maxExecutionDepth:i=10,debug:s=!1}=t,a=b.useRef(0),l=b.useRef(new Map),c=b.useCallback(async(v,y)=>{if(a.current+=1,a.current>i){console.error(`[EventEngine] 执行深度超过限制 (${i}),可能存在无限循环`,v.id||v.trigger),a.current=0;return}try{const g=n.getFieldsValue();if(v.conditions&&!Go(v.conditions,g)){s&&console.log("[EventEngine] 条件不满足,跳过执行:",v.id);return}const k={form:n,formValues:g,eventPayload:y,optionsLoader:r,customHandlers:o,executionDepth:a.current};await bB(v.actions,k),s&&console.log("[EventEngine] 事件处理完成:",v.id||v.trigger)}finally{a.current-=1}},[n,r,o,i,s]),u=b.useCallback(v=>{const y=e.filter(g=>{const{trigger:k}=g;return k.type!==v.type?!1:(k.type==="fieldChange"||k.type==="fieldBlur"||k.type==="fieldFocus")&&"field"in k?k.field===v.field:k.type==="custom"&&"eventName"in k?k.eventName===v.eventName:k.type==="formMount"});for(const g of y)if(g.debounce&&g.debounce>0){const k=`${g.id||JSON.stringify(g.trigger)}`,A=l.current.get(k);A&&clearTimeout(A);const C=setTimeout(()=>{c(g,v),l.current.delete(k)},g.debounce);l.current.set(k,C)}else c(g,v)},[e,c]),d=b.useCallback((v,y,g)=>{const k={type:"fieldChange",field:v,oldValue:g,newValue:y,timestamp:Date.now()};u(k),s&&console.log("[EventEngine] 字段变化事件:",{fieldPath:v,oldValue:g,newValue:y})},[u,s]),h=b.useCallback(v=>{const y={type:"fieldBlur",field:v,timestamp:Date.now()};u(y),s&&console.log("[EventEngine] 字段失焦事件:",{fieldPath:v})},[u,s]),p=b.useCallback(v=>{const y={type:"fieldFocus",field:v,timestamp:Date.now()};u(y),s&&console.log("[EventEngine] 字段聚焦事件:",{fieldPath:v})},[u,s]);b.useEffect(()=>{const v={type:"formMount",timestamp:Date.now()};u(v)},[]),b.useEffect(()=>()=>{for(const v of l.current.values())clearTimeout(v);l.current.clear()},[]);const m=b.useCallback((v,y)=>{const g={type:"custom",eventName:v,payload:y,timestamp:Date.now()};u(g)},[u]);return{triggerFieldChange:d,fieldEventHandlers:{onBlur:h,onFocus:p,dispatch:m}}}const Ef=b.createContext({}),L0=({value:t,children:e})=>f.jsx(Ef.Provider,{value:t,children:e}),kB=()=>b.useContext(Ef);class Jl{constructor(){it(this,"registry",new Map)}register(e,n,r={}){const{override:o=!1}=r;if(this.registry.has(e)&&!o){console.warn(`[FieldRegistry] 字段类型 "${e}" 已注册。使用 { override: true } 来覆盖。`);return}this.registry.set(e,n)}unregister(e){this.registry.delete(e)}get(e){return this.registry.get(e)}has(e){return this.registry.has(e)}getRegisteredTypes(){return Array.from(this.registry.keys())}clone(){const e=new Jl;return this.registry.forEach((n,r)=>{e.register(r,n)}),e}}const Rl=new Jl;function xB(){return new Jl}const $0=b.createContext(Rl),SB=({registry:t,additionalRegistrations:e,children:n})=>{const r=b.useMemo(()=>{const o=t||Rl.clone();if(e!=null&&e.length)for(const{type:i,definition:s}of e)o.register(i,s,{override:!0});return o},[t,e]);return f.jsx($0.Provider,{value:r,children:n})},Ql=()=>b.useContext($0);var be=(t=>(t.TEXT="TEXT",t.TEXTAREA="TEXTAREA",t.NUMBER="NUMBER",t.PASSWORD="PASSWORD",t.SELECT="SELECT",t.MULTI_SELECT="MULTI_SELECT",t.RADIO="RADIO",t.CHECKBOX="CHECKBOX",t.CHECKBOX_GROUP="CHECKBOX_GROUP",t.SWITCH="SWITCH",t.CASCADER="CASCADER",t.TREE_SELECT="TREE_SELECT",t.DATE="DATE",t.DATE_RANGE="DATE_RANGE",t.TIME="TIME",t.TIME_RANGE="TIME_RANGE",t.DATETIME="DATETIME",t.UPLOAD="UPLOAD",t.RATE="RATE",t.SLIDER="SLIDER",t.COLOR_PICKER="COLOR_PICKER",t.MENTIONS="MENTIONS",t.AUTO_COMPLETE="AUTO_COMPLETE",t.LABEL="LABEL",t.HIDDEN="HIDDEN",t.JSON="JSON",t.DIVIDER="DIVIDER",t.INFO_CARD="INFO_CARD",t.ARRAY="ARRAY",t.OBJECT="OBJECT",t.KEY_VALUE="KEY_VALUE",t.ARRAY_OBJECT="ARRAY_OBJECT",t))(be||{});function EB(t){switch(t){case be.NUMBER:case be.SLIDER:case be.RATE:return"number";case be.CHECKBOX:case be.SWITCH:return"boolean";case be.MULTI_SELECT:case be.CHECKBOX_GROUP:case be.DATE_RANGE:case be.TIME_RANGE:case be.ARRAY:case be.ARRAY_OBJECT:return"array";case be.DATE:case be.DATETIME:case be.TIME:return"object";case be.OBJECT:case be.KEY_VALUE:return"object";default:return}}function Mi(t,e,n){const r=[],o=n?EB(n):void 0;for(const i of t){if(i.type==="when"){Go(i.conditions,e)&&r.push(...Mi(i.rules,e,n));continue}const s=DB(i,o);s&&r.push(s)}return r}function DB(t,e){const n={message:t.message,warningOnly:t.warningOnly};switch(t.type){case"required":return e?{...n,required:!0,type:e}:{...n,required:!0};case"type":return{...n,type:t.value};case"min":return{...n,min:t.value,type:e};case"max":return{...n,max:t.value,type:e};case"len":return{...n,len:t.value};case"pattern":return{...n,pattern:new RegExp(t.value,t.flags)};case"enum":return{...n,enum:t.value};case"whitespace":return{...n,whitespace:!0};default:return null}}const AB=t=>!t||typeof t!="object"?!1:"AND"in t||"OR"in t?!0:"keyword"in t&&"key"in t;function Ys(t,e){return t.visibleWhen&&t.visibleWhen.conditions?Go(t.visibleWhen.conditions,e):!0}function OB(t){var e;return((e=t.visibleWhen)==null?void 0:e.hideStrategy)||"unregister"}function Pi(t,e,n=!1){return typeof t=="boolean"?t:AB(t)?Go(t,e):n}const TB=(t,e)=>{const n=e.split(".");let r=t;for(let i=0;i<n.length-1;i+=1){const s=n[i],a=r==null?void 0:r[s];if(typeof a!="object"||a===null)return;r=a}const o=n[n.length-1];if(Array.isArray(r)){const i=Number(o);Number.isNaN(i)||r.splice(i,1)}else r&&delete r[o]};function _B(t,e,n){const r=structuredClone(e);for(const o of t.fields)n[o.name]===!1&&TB(r,o.name);return r}const Zl="{{$fromAI}}",H0=({value:t,onChange:e,children:n,aiFillable:r=!0,disabled:o=!1})=>{const[i,s]=b.useState(t===Zl),[a,l]=b.useState(void 0);if(b.useEffect(()=>{s(t===Zl)},[t]),!r)return b.cloneElement(n,{value:t,onChange:e});const c=()=>{l(t),s(!0),e==null||e(Zl)},u=()=>{s(!1),e==null||e(a)};return i?f.jsx("div",{className:"ai-field-wrapper ai-mode",children:f.jsxs("div",{className:"ai-field-display",children:[f.jsx(x.Input,{readOnly:!0,value:"由 AI 生成",className:"ai-field-input",prefix:f.jsx(Z.RobotOutlined,{className:"ai-icon"})}),!o&&f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.CloseOutlined,{}),onClick:u,className:"ai-field-close"})]})}):f.jsxs("div",{className:"ai-field-wrapper normal-mode",children:[f.jsx("div",{className:"ai-field-content",children:b.cloneElement(n,{value:t,onChange:e})}),!o&&f.jsx(x.Button,{type:"link",size:"small",icon:f.jsx(Z.RobotOutlined,{}),onClick:c,className:"ai-enable-button",children:"由 AI 生成"})]})},z0=/\{\{(.*?)\}\}/g;function Df(t,e=z0){if(!t||typeof t!="string")return[{type:"paragraph",children:[{text:""}]}];const n=t.split(`
|
|
11
11
|
`),r=[];for(const o of n){const i=[];let s=0;const a=new RegExp(e.source,e.flags.includes("g")?e.flags:e.flags+"g");let l;for(;(l=a.exec(o))!==null;){const c=o.slice(s,l.index);(c||i.length===0)&&i.push({text:c}),i.push({type:"variable-tag",value:l[0],children:[{text:""}]}),s=l.index+l[0].length}if(s<o.length)i.push({text:o.slice(s)});else if(i.length>0){const c=i[i.length-1];"type"in c&&c.type==="variable-tag"&&i.push({text:""})}i.length===0&&i.push({text:""}),r.push({type:"paragraph",children:i})}return r.length>0?r:[{type:"paragraph",children:[{text:""}]}]}function Af(t){return t.map(e=>e.type==="paragraph"?e.children.map(n=>"type"in n&&n.type==="variable-tag"?n.value:n.text).join(""):"").join(`
|
|
12
|
-
`)}function Li(t){return t&&t.type==="variable-tag"}var NB={transform(t,e){var{current:n,affinity:r}=t;if(n!=null){var o=U.transform(n,e,{affinity:r});t.current=o,o==null&&t.unref()}}},BB={transform(t,e){var{current:n,affinity:r}=t;if(n!=null){var o=Re.transform(n,e,{affinity:r});t.current=o,o==null&&t.unref()}}},FB={transform(t,e){var{current:n,affinity:r}=t;if(n!=null){var o=oe.transform(n,e,{affinity:r});t.current=o,o==null&&t.unref()}}},ec=new WeakMap,tc=new WeakMap,Xs=new WeakMap,j0=new WeakMap,V0=new WeakMap,W0=new WeakMap,U0=new WeakMap,U={ancestors(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=e,r=U.levels(t,e);return n?r=r.slice(1):r=r.slice(0,-1),r},common(t,e){for(var n=[],r=0;r<t.length&&r<e.length;r++){var o=t[r],i=e[r];if(o!==i)break;n.push(o)}return n},compare(t,e){for(var n=Math.min(t.length,e.length),r=0;r<n;r++){if(t[r]<e[r])return-1;if(t[r]>e[r])return 1}return 0},endsAfter(t,e){var n=t.length-1,r=t.slice(0,n),o=e.slice(0,n),i=t[n],s=e[n];return U.equals(r,o)&&i>s},endsAt(t,e){var n=t.length,r=t.slice(0,n),o=e.slice(0,n);return U.equals(r,o)},endsBefore(t,e){var n=t.length-1,r=t.slice(0,n),o=e.slice(0,n),i=t[n],s=e[n];return U.equals(r,o)&&i<s},equals(t,e){return t.length===e.length&&t.every((n,r)=>n===e[r])},hasPrevious(t){return t[t.length-1]>0},isAfter(t,e){return U.compare(t,e)===1},isAncestor(t,e){return t.length<e.length&&U.compare(t,e)===0},isBefore(t,e){return U.compare(t,e)===-1},isChild(t,e){return t.length===e.length+1&&U.compare(t,e)===0},isCommon(t,e){return t.length<=e.length&&U.compare(t,e)===0},isDescendant(t,e){return t.length>e.length&&U.compare(t,e)===0},isParent(t,e){return t.length+1===e.length&&U.compare(t,e)===0},isPath(t){return Array.isArray(t)&&(t.length===0||typeof t[0]=="number")},isSibling(t,e){if(t.length!==e.length)return!1;var n=t.slice(0,-1),r=e.slice(0,-1),o=t[t.length-1],i=e[e.length-1];return o!==i&&U.equals(n,r)},levels(t){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=e,r=[],o=0;o<=t.length;o++)r.push(t.slice(0,o));return n&&r.reverse(),r},next(t){if(t.length===0)throw new Error("Cannot get the next path of a root path [".concat(t,"], because it has no next index."));var e=t[t.length-1];return t.slice(0,-1).concat(e+1)},operationCanTransformPath(t){switch(t.type){case"insert_node":case"remove_node":case"merge_node":case"split_node":case"move_node":return!0;default:return!1}},parent(t){if(t.length===0)throw new Error("Cannot get the parent path of the root path [".concat(t,"]."));return t.slice(0,-1)},previous(t){if(t.length===0)throw new Error("Cannot get the previous path of a root path [".concat(t,"], because it has no previous index."));var e=t[t.length-1];if(e<=0)throw new Error("Cannot get the previous path of a first child path [".concat(t,"] because it would result in a negative index."));return t.slice(0,-1).concat(e-1)},relative(t,e){if(!U.isAncestor(e,t)&&!U.equals(t,e))throw new Error("Cannot get the relative path of [".concat(t,"] inside ancestor [").concat(e,"], because it is not above or equal to the path."));return t.slice(e.length)},transform(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return null;var r=[...t],{affinity:o="forward"}=n;if(t.length===0)return r;switch(e.type){case"insert_node":{var{path:i}=e;(U.equals(i,r)||U.endsBefore(i,r)||U.isAncestor(i,r))&&(r[i.length-1]+=1);break}case"remove_node":{var{path:s}=e;if(U.equals(s,r)||U.isAncestor(s,r))return null;U.endsBefore(s,r)&&(r[s.length-1]-=1);break}case"merge_node":{var{path:a,position:l}=e;U.equals(a,r)||U.endsBefore(a,r)?r[a.length-1]-=1:U.isAncestor(a,r)&&(r[a.length-1]-=1,r[a.length]+=l);break}case"split_node":{var{path:c,position:u}=e;if(U.equals(c,r)){if(o==="forward")r[r.length-1]+=1;else if(o!=="backward")return null}else U.endsBefore(c,r)?r[c.length-1]+=1:U.isAncestor(c,r)&&t[c.length]>=u&&(r[c.length-1]+=1,r[c.length]-=u);break}case"move_node":{var{path:d,newPath:h}=e;if(U.equals(d,h))return r;if(U.isAncestor(d,r)||U.equals(d,r)){var p=h.slice();return U.endsBefore(d,h)&&d.length<h.length&&(p[d.length-1]-=1),p.concat(r.slice(d.length))}else U.isSibling(d,h)&&(U.isAncestor(h,r)||U.equals(h,r))?U.endsBefore(d,r)?r[d.length-1]-=1:r[d.length-1]+=1:U.endsBefore(h,r)||U.equals(h,r)||U.isAncestor(h,r)?(U.endsBefore(d,r)&&(r[d.length-1]-=1),r[h.length-1]+=1):U.endsBefore(d,r)&&(U.equals(h,r)&&(r[h.length-1]+=1),r[d.length-1]-=1);break}}return r}};function Js(t){"@babel/helpers - typeof";return Js=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Js(t)}function IB(t,e){if(Js(t)!=="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(Js(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function MB(t){var e=IB(t,"string");return Js(e)==="symbol"?e:String(e)}function Yt(t,e,n){return e=MB(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function PB(t,e){if(t==null)return{};var n={},r=Object.keys(t),o,i;for(i=0;i<r.length;i++)o=r[i],!(e.indexOf(o)>=0)&&(n[o]=t[o]);return n}function Kr(t,e){if(t==null)return{};var n=PB(t,e),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)r=i[o],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}var LB=["anchor","focus"];function q0(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function $B(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?q0(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q0(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var oe={edges(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=e,{anchor:r,focus:o}=t;return oe.isBackward(t)===n?[r,o]:[o,r]},end(t){var[,e]=oe.edges(t);return e},equals(t,e){return Re.equals(t.anchor,e.anchor)&&Re.equals(t.focus,e.focus)},surrounds(t,e){var n=oe.intersection(t,e);return n?oe.equals(n,e):!1},includes(t,e){if(oe.isRange(e)){if(oe.includes(t,e.anchor)||oe.includes(t,e.focus))return!0;var[n,r]=oe.edges(t),[o,i]=oe.edges(e);return Re.isBefore(n,o)&&Re.isAfter(r,i)}var[s,a]=oe.edges(t),l=!1,c=!1;return Re.isPoint(e)?(l=Re.compare(e,s)>=0,c=Re.compare(e,a)<=0):(l=U.compare(e,s.path)>=0,c=U.compare(e,a.path)<=0),l&&c},intersection(t,e){var n=Kr(t,LB),[r,o]=oe.edges(t),[i,s]=oe.edges(e),a=Re.isBefore(r,i)?i:r,l=Re.isBefore(o,s)?o:s;return Re.isBefore(l,a)?null:$B({anchor:a,focus:l},n)},isBackward(t){var{anchor:e,focus:n}=t;return Re.isAfter(e,n)},isCollapsed(t){var{anchor:e,focus:n}=t;return Re.equals(e,n)},isExpanded(t){return!oe.isCollapsed(t)},isForward(t){return!oe.isBackward(t)},isRange(t){return nn(t)&&Re.isPoint(t.anchor)&&Re.isPoint(t.focus)},*points(t){yield[t.anchor,"anchor"],yield[t.focus,"focus"]},start(t){var[e]=oe.edges(t);return e},transform(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(t===null)return null;var{affinity:r="inward"}=n,o,i;if(r==="inward"){var s=oe.isCollapsed(t);oe.isForward(t)?(o="forward",i=s?o:"backward"):(o="backward",i=s?o:"forward")}else r==="outward"?oe.isForward(t)?(o="backward",i="forward"):(o="forward",i="backward"):(o=r,i=r);var a=Re.transform(t.anchor,e,{affinity:o}),l=Re.transform(t.focus,e,{affinity:i});return!a||!l?null:{anchor:a,focus:l}}},G0=function(e){var{deep:n=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!nn(e))return!1;var r=typeof e.apply=="function";if(r)return!1;var o=n?ge.isNodeList(e.children):Array.isArray(e.children);return o},Ae={isAncestor(t){var{deep:e=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return nn(t)&&ge.isNodeList(t.children,{deep:e})},isElement:G0,isElementList(t){var{deep:e=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Array.isArray(t)&&t.every(n=>Ae.isElement(n,{deep:e}))},isElementProps(t){return t.children!==void 0},isElementType:function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"type";return G0(e)&&e[r]===n},matches(t,e){for(var n in e)if(n!=="children"&&t[n]!==e[n])return!1;return!0}},HB=["children"],zB=["text"];function K0(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function nc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?K0(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K0(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var ge={ancestor(t,e){var n=ge.get(t,e);if(Oe.isText(n))throw new Error("Cannot get the ancestor node at path [".concat(e,"] because it refers to a text node instead: ").concat($t.stringify(n)));return n},ancestors(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var r of U.ancestors(e,n)){var o=ge.ancestor(t,r),i=[o,r];yield i}})()},child(t,e){if(Oe.isText(t))throw new Error("Cannot get the child of a text node: ".concat($t.stringify(t)));var n=t.children[e];if(n==null)throw new Error("Cannot get child at index `".concat(e,"` in node: ").concat($t.stringify(t)));return n},children(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var{reverse:r=!1}=n,o=ge.ancestor(t,e),{children:i}=o,s=r?i.length-1:0;r?s>=0:s<i.length;){var a=ge.child(o,s),l=e.concat(s);yield[a,l],s=r?s-1:s+1}})()},common(t,e,n){var r=U.common(e,n),o=ge.get(t,r);return[o,r]},descendant(t,e){var n=ge.get(t,e);if(I.isEditor(n))throw new Error("Cannot get the descendant node at path [".concat(e,"] because it refers to the root editor node instead: ").concat($t.stringify(n)));return n},descendants(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of ge.nodes(t,e))r.length!==0&&(yield[n,r])})()},elements(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of ge.nodes(t,e))Ae.isElement(n)&&(yield[n,r])})()},extractProps(t){if(Ae.isAncestor(t)){var e=Kr(t,HB);return e}else{var e=Kr(t,zB);return e}},first(t,e){for(var n=e.slice(),r=ge.get(t,n);r&&!(Oe.isText(r)||r.children.length===0);)r=r.children[0],n.push(0);return[r,n]},fragment(t,e){var n={children:t.children},[r,o]=oe.edges(e),i=ge.nodes(n,{reverse:!0,pass:l=>{var[,c]=l;return!oe.includes(e,c)}}),s=function(){if(!oe.includes(e,a)){var c=a[a.length-1];Ko(n,U.parent(a),u=>Nf(u,c,1))}U.equals(a,o.path)&&oc(n,a,u=>{var d=u.text.slice(0,o.offset);return nc(nc({},u),{},{text:d})}),U.equals(a,r.path)&&oc(n,a,u=>{var d=u.text.slice(r.offset);return nc(nc({},u),{},{text:d})})};for(var[,a]of i)s();return n.children},get(t,e){var n=ge.getIf(t,e);if(n===void 0)throw new Error("Cannot find a descendant at path [".concat(e,"] in node: ").concat($t.stringify(t)));return n},getIf(t,e){for(var n=t,r=0;r<e.length;r++){var o=e[r];if(Oe.isText(n)||!n.children[o])return;n=n.children[o]}return n},has(t,e){for(var n=t,r=0;r<e.length;r++){var o=e[r];if(Oe.isText(n)||!n.children[o])return!1;n=n.children[o]}return!0},isNode(t){var{deep:e=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Oe.isText(t)||Ae.isElement(t,{deep:e})||I.isEditor(t,{deep:e})},isNodeList(t){var{deep:e=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Array.isArray(t)&&t.every(n=>ge.isNode(n,{deep:e}))},last(t,e){for(var n=e.slice(),r=ge.get(t,n);r&&!(Oe.isText(r)||r.children.length===0);){var o=r.children.length-1;r=r.children[o],n.push(o)}return[r,n]},leaf(t,e){var n=ge.get(t,e);if(!Oe.isText(n))throw new Error("Cannot get the leaf node at path [".concat(e,"] because it refers to a non-leaf node: ").concat($t.stringify(n)));return n},levels(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var r of U.levels(e,n)){var o=ge.get(t,r);yield[o,r]}})()},matches(t,e){return Ae.isElement(t)&&Ae.isElementProps(e)&&Ae.matches(t,e)||Oe.isText(t)&&Oe.isTextProps(e)&&Oe.matches(t,e)},nodes(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var{pass:n,reverse:r=!1}=e,{from:o=[],to:i}=e,s=new Set,a=[],l=t;!(i&&(r?U.isBefore(a,i):U.isAfter(a,i)));){if(s.has(l)||(yield[l,a]),!s.has(l)&&!Oe.isText(l)&&l.children.length!==0&&(n==null||n([l,a])===!1)){s.add(l);var c=r?l.children.length-1:0;U.isAncestor(a,o)&&(c=o[a.length]),a=a.concat(c),l=ge.get(t,a);continue}if(a.length===0)break;if(!r){var u=U.next(a);if(ge.has(t,u)){a=u,l=ge.get(t,a);continue}}if(r&&a[a.length-1]!==0){var d=U.previous(a);a=d,l=ge.get(t,a);continue}a=U.parent(a),l=ge.get(t,a),s.add(l)}})()},parent(t,e){var n=U.parent(e),r=ge.get(t,n);if(Oe.isText(r))throw new Error("Cannot get the parent of path [".concat(e,"] because it does not exist in the root."));return r},string(t){return Oe.isText(t)?t.text:t.children.map(ge.string).join("")},texts(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of ge.nodes(t,e))Oe.isText(n)&&(yield[n,r])})()}};function Y0(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function gt(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Y0(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y0(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var uo={isNodeOperation(t){return uo.isOperation(t)&&t.type.endsWith("_node")},isOperation(t){if(!nn(t))return!1;switch(t.type){case"insert_node":return U.isPath(t.path)&&ge.isNode(t.node);case"insert_text":return typeof t.offset=="number"&&typeof t.text=="string"&&U.isPath(t.path);case"merge_node":return typeof t.position=="number"&&U.isPath(t.path)&&nn(t.properties);case"move_node":return U.isPath(t.path)&&U.isPath(t.newPath);case"remove_node":return U.isPath(t.path)&&ge.isNode(t.node);case"remove_text":return typeof t.offset=="number"&&typeof t.text=="string"&&U.isPath(t.path);case"set_node":return U.isPath(t.path)&&nn(t.properties)&&nn(t.newProperties);case"set_selection":return t.properties===null&&oe.isRange(t.newProperties)||t.newProperties===null&&oe.isRange(t.properties)||nn(t.properties)&&nn(t.newProperties);case"split_node":return U.isPath(t.path)&&typeof t.position=="number"&&nn(t.properties);default:return!1}},isOperationList(t){return Array.isArray(t)&&t.every(e=>uo.isOperation(e))},isSelectionOperation(t){return uo.isOperation(t)&&t.type.endsWith("_selection")},isTextOperation(t){return uo.isOperation(t)&&t.type.endsWith("_text")},inverse(t){switch(t.type){case"insert_node":return gt(gt({},t),{},{type:"remove_node"});case"insert_text":return gt(gt({},t),{},{type:"remove_text"});case"merge_node":return gt(gt({},t),{},{type:"split_node",path:U.previous(t.path)});case"move_node":{var{newPath:e,path:n}=t;if(U.equals(e,n))return t;if(U.isSibling(n,e))return gt(gt({},t),{},{path:e,newPath:n});var r=U.transform(n,t),o=U.transform(U.next(n),t);return gt(gt({},t),{},{path:r,newPath:o})}case"remove_node":return gt(gt({},t),{},{type:"insert_node"});case"remove_text":return gt(gt({},t),{},{type:"insert_text"});case"set_node":{var{properties:i,newProperties:s}=t;return gt(gt({},t),{},{properties:s,newProperties:i})}case"set_selection":{var{properties:a,newProperties:l}=t;return a==null?gt(gt({},t),{},{properties:l,newProperties:null}):l==null?gt(gt({},t),{},{properties:null,newProperties:a}):gt(gt({},t),{},{properties:l,newProperties:a})}case"split_node":return gt(gt({},t),{},{type:"merge_node",path:U.next(t.path)})}}},nn=t=>typeof t=="object"&&t!==null,X0=(t,e)=>{for(var n in t){var r=t[n],o=e[n];if(Array.isArray(r)&&Array.isArray(o)){if(r.length!==o.length)return!1;for(var i=0;i<r.length;i++)if(r[i]!==o[i])return!1}else if(nn(r)&&nn(o)){if(!X0(r,o))return!1}else if(r!==o)return!1}for(var s in e)if(t[s]===void 0&&e[s]!==void 0)return!1;return!0},Of=t=>t.selection?t.selection:t.children.length>0?I.end(t,[]):[0],$i=(t,e)=>{var[n]=I.node(t,e);return r=>r===n},Tf=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=!n,o=n?GB(e):e,i=$e.None,s=$e.None,a=0,l=null,c=null;for(var u of o){var d=u.codePointAt(0);if(!d)break;var h=oF(u,d);if([i,s]=r?[s,h]:[h,i],Hi(i,$e.ZWJ)&&Hi(s,$e.ExtPict)&&(r?l=J0(e.substring(0,a)):l=J0(e.substring(0,e.length-a)),!l)||Hi(i,$e.RI)&&Hi(s,$e.RI)&&(c!==null?c=!c:r?c=!0:c=cF(e.substring(0,e.length-a)),!c)||i!==$e.None&&s!==$e.None&&sF(i,s))break;a+=u.length}return a||1},jB=/\s/,VB=/[\u002B\u0021-\u0023\u0025-\u002A\u002C-\u002F\u003A\u003B\u003F\u0040\u005B-\u005D\u005F\u007B\u007D\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E3B\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/,WB=/['\u2018\u2019]/,UB=function(e){for(var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=0,o=!1;e.length>0;){var i=Tf(e,n),[s,a]=_f(e,i,n);if(qB(s,a,n))o=!0,r+=i;else if(!o)r+=i;else break;e=a}return r},_f=(t,e,n)=>{if(n){var r=t.length-e;return[t.slice(r,t.length),t.slice(0,r)]}return[t.slice(0,e),t.slice(e)]},qB=function t(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(jB.test(e))return!1;if(WB.test(e)){var o=Tf(n,r),[i,s]=_f(n,o,r);if(t(i,s,r))return!0}return!VB.test(e)},GB=function*(e){for(var n=e.length-1,r=0;r<e.length;r++){var o=e.charAt(n-r);if(YB(o.charCodeAt(0))){var i=e.charAt(n-r-1);if(KB(i.charCodeAt(0))){yield i+o,r++;continue}}yield o}},KB=t=>t>=55296&&t<=56319,YB=t=>t>=56320&&t<=57343,$e;(function(t){t[t.None=0]="None",t[t.Extend=1]="Extend",t[t.ZWJ=2]="ZWJ",t[t.RI=4]="RI",t[t.Prepend=8]="Prepend",t[t.SpacingMark=16]="SpacingMark",t[t.L=32]="L",t[t.V=64]="V",t[t.T=128]="T",t[t.LV=256]="LV",t[t.LVT=512]="LVT",t[t.ExtPict=1024]="ExtPict",t[t.Any=2048]="Any"})($e||($e={}));var XB=/^(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC2\u0CC6\u0CCC\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732\u1733\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B03\u1B34-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200C\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDEFD-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34\uDE36\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF57\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB5\uDEB7\uDF1D-\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B\uDD3C\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40\uDF42]|\uD80D[\uDC40\uDC47-\uDC55]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65\uDD67-\uDD69\uDD6E-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF])$/,JB=/^(?:[\u0600-\u0605\u06DD\u070F\u0890\u0891\u08E2\u0D4E]|\uD804[\uDCBD\uDCCD\uDDC2\uDDC3]|\uD806[\uDD3F\uDD41\uDE3A\uDE84-\uDE89]|\uD807\uDD46)$/,RB=/^(?:[\u0903\u093B\u093E-\u0940\u0949-\u094C\u094E\u094F\u0982\u0983\u09BF\u09C0\u09C7\u09C8\u09CB\u09CC\u0A03\u0A3E-\u0A40\u0A83\u0ABE-\u0AC0\u0AC9\u0ACB\u0ACC\u0B02\u0B03\u0B40\u0B47\u0B48\u0B4B\u0B4C\u0BBF\u0BC1\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0C01-\u0C03\u0C41-\u0C44\u0C82\u0C83\u0CBE\u0CC0\u0CC1\u0CC3\u0CC4\u0CC7\u0CC8\u0CCA\u0CCB\u0D02\u0D03\u0D3F\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D82\u0D83\u0DD0\u0DD1\u0DD8-\u0DDE\u0DF2\u0DF3\u0E33\u0EB3\u0F3E\u0F3F\u0F7F\u1031\u103B\u103C\u1056\u1057\u1084\u1715\u1734\u17B6\u17BE-\u17C5\u17C7\u17C8\u1923-\u1926\u1929-\u192B\u1930\u1931\u1933-\u1938\u1A19\u1A1A\u1A55\u1A57\u1A6D-\u1A72\u1B04\u1B3B\u1B3D-\u1B41\u1B43\u1B44\u1B82\u1BA1\u1BA6\u1BA7\u1BAA\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2\u1BF3\u1C24-\u1C2B\u1C34\u1C35\u1CE1\u1CF7\uA823\uA824\uA827\uA880\uA881\uA8B4-\uA8C3\uA952\uA953\uA983\uA9B4\uA9B5\uA9BA\uA9BB\uA9BE-\uA9C0\uAA2F\uAA30\uAA33\uAA34\uAA4D\uAAEB\uAAEE\uAAEF\uAAF5\uABE3\uABE4\uABE6\uABE7\uABE9\uABEA\uABEC]|\uD804[\uDC00\uDC02\uDC82\uDCB0-\uDCB2\uDCB7\uDCB8\uDD2C\uDD45\uDD46\uDD82\uDDB3-\uDDB5\uDDBF\uDDC0\uDDCE\uDE2C-\uDE2E\uDE32\uDE33\uDE35\uDEE0-\uDEE2\uDF02\uDF03\uDF3F\uDF41-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF62\uDF63]|\uD805[\uDC35-\uDC37\uDC40\uDC41\uDC45\uDCB1\uDCB2\uDCB9\uDCBB\uDCBC\uDCBE\uDCC1\uDDB0\uDDB1\uDDB8-\uDDBB\uDDBE\uDE30-\uDE32\uDE3B\uDE3C\uDE3E\uDEAC\uDEAE\uDEAF\uDEB6\uDF26]|\uD806[\uDC2C-\uDC2E\uDC38\uDD31-\uDD35\uDD37\uDD38\uDD3D\uDD40\uDD42\uDDD1-\uDDD3\uDDDC-\uDDDF\uDDE4\uDE39\uDE57\uDE58\uDE97]|\uD807[\uDC2F\uDC3E\uDCA9\uDCB1\uDCB4\uDD8A-\uDD8E\uDD93\uDD94\uDD96\uDEF5\uDEF6]|\uD81B[\uDF51-\uDF87\uDFF0\uDFF1]|\uD834[\uDD66\uDD6D])$/,QB=/^[\u1100-\u115F\uA960-\uA97C]$/,ZB=/^[\u1160-\u11A7\uD7B0-\uD7C6]$/,eF=/^[\u11A8-\u11FF\uD7CB-\uD7FB]$/,tF=/^[\uAC00\uAC1C\uAC38\uAC54\uAC70\uAC8C\uACA8\uACC4\uACE0\uACFC\uAD18\uAD34\uAD50\uAD6C\uAD88\uADA4\uADC0\uADDC\uADF8\uAE14\uAE30\uAE4C\uAE68\uAE84\uAEA0\uAEBC\uAED8\uAEF4\uAF10\uAF2C\uAF48\uAF64\uAF80\uAF9C\uAFB8\uAFD4\uAFF0\uB00C\uB028\uB044\uB060\uB07C\uB098\uB0B4\uB0D0\uB0EC\uB108\uB124\uB140\uB15C\uB178\uB194\uB1B0\uB1CC\uB1E8\uB204\uB220\uB23C\uB258\uB274\uB290\uB2AC\uB2C8\uB2E4\uB300\uB31C\uB338\uB354\uB370\uB38C\uB3A8\uB3C4\uB3E0\uB3FC\uB418\uB434\uB450\uB46C\uB488\uB4A4\uB4C0\uB4DC\uB4F8\uB514\uB530\uB54C\uB568\uB584\uB5A0\uB5BC\uB5D8\uB5F4\uB610\uB62C\uB648\uB664\uB680\uB69C\uB6B8\uB6D4\uB6F0\uB70C\uB728\uB744\uB760\uB77C\uB798\uB7B4\uB7D0\uB7EC\uB808\uB824\uB840\uB85C\uB878\uB894\uB8B0\uB8CC\uB8E8\uB904\uB920\uB93C\uB958\uB974\uB990\uB9AC\uB9C8\uB9E4\uBA00\uBA1C\uBA38\uBA54\uBA70\uBA8C\uBAA8\uBAC4\uBAE0\uBAFC\uBB18\uBB34\uBB50\uBB6C\uBB88\uBBA4\uBBC0\uBBDC\uBBF8\uBC14\uBC30\uBC4C\uBC68\uBC84\uBCA0\uBCBC\uBCD8\uBCF4\uBD10\uBD2C\uBD48\uBD64\uBD80\uBD9C\uBDB8\uBDD4\uBDF0\uBE0C\uBE28\uBE44\uBE60\uBE7C\uBE98\uBEB4\uBED0\uBEEC\uBF08\uBF24\uBF40\uBF5C\uBF78\uBF94\uBFB0\uBFCC\uBFE8\uC004\uC020\uC03C\uC058\uC074\uC090\uC0AC\uC0C8\uC0E4\uC100\uC11C\uC138\uC154\uC170\uC18C\uC1A8\uC1C4\uC1E0\uC1FC\uC218\uC234\uC250\uC26C\uC288\uC2A4\uC2C0\uC2DC\uC2F8\uC314\uC330\uC34C\uC368\uC384\uC3A0\uC3BC\uC3D8\uC3F4\uC410\uC42C\uC448\uC464\uC480\uC49C\uC4B8\uC4D4\uC4F0\uC50C\uC528\uC544\uC560\uC57C\uC598\uC5B4\uC5D0\uC5EC\uC608\uC624\uC640\uC65C\uC678\uC694\uC6B0\uC6CC\uC6E8\uC704\uC720\uC73C\uC758\uC774\uC790\uC7AC\uC7C8\uC7E4\uC800\uC81C\uC838\uC854\uC870\uC88C\uC8A8\uC8C4\uC8E0\uC8FC\uC918\uC934\uC950\uC96C\uC988\uC9A4\uC9C0\uC9DC\uC9F8\uCA14\uCA30\uCA4C\uCA68\uCA84\uCAA0\uCABC\uCAD8\uCAF4\uCB10\uCB2C\uCB48\uCB64\uCB80\uCB9C\uCBB8\uCBD4\uCBF0\uCC0C\uCC28\uCC44\uCC60\uCC7C\uCC98\uCCB4\uCCD0\uCCEC\uCD08\uCD24\uCD40\uCD5C\uCD78\uCD94\uCDB0\uCDCC\uCDE8\uCE04\uCE20\uCE3C\uCE58\uCE74\uCE90\uCEAC\uCEC8\uCEE4\uCF00\uCF1C\uCF38\uCF54\uCF70\uCF8C\uCFA8\uCFC4\uCFE0\uCFFC\uD018\uD034\uD050\uD06C\uD088\uD0A4\uD0C0\uD0DC\uD0F8\uD114\uD130\uD14C\uD168\uD184\uD1A0\uD1BC\uD1D8\uD1F4\uD210\uD22C\uD248\uD264\uD280\uD29C\uD2B8\uD2D4\uD2F0\uD30C\uD328\uD344\uD360\uD37C\uD398\uD3B4\uD3D0\uD3EC\uD408\uD424\uD440\uD45C\uD478\uD494\uD4B0\uD4CC\uD4E8\uD504\uD520\uD53C\uD558\uD574\uD590\uD5AC\uD5C8\uD5E4\uD600\uD61C\uD638\uD654\uD670\uD68C\uD6A8\uD6C4\uD6E0\uD6FC\uD718\uD734\uD750\uD76C\uD788]$/,nF=/^[\uAC01-\uAC1B\uAC1D-\uAC37\uAC39-\uAC53\uAC55-\uAC6F\uAC71-\uAC8B\uAC8D-\uACA7\uACA9-\uACC3\uACC5-\uACDF\uACE1-\uACFB\uACFD-\uAD17\uAD19-\uAD33\uAD35-\uAD4F\uAD51-\uAD6B\uAD6D-\uAD87\uAD89-\uADA3\uADA5-\uADBF\uADC1-\uADDB\uADDD-\uADF7\uADF9-\uAE13\uAE15-\uAE2F\uAE31-\uAE4B\uAE4D-\uAE67\uAE69-\uAE83\uAE85-\uAE9F\uAEA1-\uAEBB\uAEBD-\uAED7\uAED9-\uAEF3\uAEF5-\uAF0F\uAF11-\uAF2B\uAF2D-\uAF47\uAF49-\uAF63\uAF65-\uAF7F\uAF81-\uAF9B\uAF9D-\uAFB7\uAFB9-\uAFD3\uAFD5-\uAFEF\uAFF1-\uB00B\uB00D-\uB027\uB029-\uB043\uB045-\uB05F\uB061-\uB07B\uB07D-\uB097\uB099-\uB0B3\uB0B5-\uB0CF\uB0D1-\uB0EB\uB0ED-\uB107\uB109-\uB123\uB125-\uB13F\uB141-\uB15B\uB15D-\uB177\uB179-\uB193\uB195-\uB1AF\uB1B1-\uB1CB\uB1CD-\uB1E7\uB1E9-\uB203\uB205-\uB21F\uB221-\uB23B\uB23D-\uB257\uB259-\uB273\uB275-\uB28F\uB291-\uB2AB\uB2AD-\uB2C7\uB2C9-\uB2E3\uB2E5-\uB2FF\uB301-\uB31B\uB31D-\uB337\uB339-\uB353\uB355-\uB36F\uB371-\uB38B\uB38D-\uB3A7\uB3A9-\uB3C3\uB3C5-\uB3DF\uB3E1-\uB3FB\uB3FD-\uB417\uB419-\uB433\uB435-\uB44F\uB451-\uB46B\uB46D-\uB487\uB489-\uB4A3\uB4A5-\uB4BF\uB4C1-\uB4DB\uB4DD-\uB4F7\uB4F9-\uB513\uB515-\uB52F\uB531-\uB54B\uB54D-\uB567\uB569-\uB583\uB585-\uB59F\uB5A1-\uB5BB\uB5BD-\uB5D7\uB5D9-\uB5F3\uB5F5-\uB60F\uB611-\uB62B\uB62D-\uB647\uB649-\uB663\uB665-\uB67F\uB681-\uB69B\uB69D-\uB6B7\uB6B9-\uB6D3\uB6D5-\uB6EF\uB6F1-\uB70B\uB70D-\uB727\uB729-\uB743\uB745-\uB75F\uB761-\uB77B\uB77D-\uB797\uB799-\uB7B3\uB7B5-\uB7CF\uB7D1-\uB7EB\uB7ED-\uB807\uB809-\uB823\uB825-\uB83F\uB841-\uB85B\uB85D-\uB877\uB879-\uB893\uB895-\uB8AF\uB8B1-\uB8CB\uB8CD-\uB8E7\uB8E9-\uB903\uB905-\uB91F\uB921-\uB93B\uB93D-\uB957\uB959-\uB973\uB975-\uB98F\uB991-\uB9AB\uB9AD-\uB9C7\uB9C9-\uB9E3\uB9E5-\uB9FF\uBA01-\uBA1B\uBA1D-\uBA37\uBA39-\uBA53\uBA55-\uBA6F\uBA71-\uBA8B\uBA8D-\uBAA7\uBAA9-\uBAC3\uBAC5-\uBADF\uBAE1-\uBAFB\uBAFD-\uBB17\uBB19-\uBB33\uBB35-\uBB4F\uBB51-\uBB6B\uBB6D-\uBB87\uBB89-\uBBA3\uBBA5-\uBBBF\uBBC1-\uBBDB\uBBDD-\uBBF7\uBBF9-\uBC13\uBC15-\uBC2F\uBC31-\uBC4B\uBC4D-\uBC67\uBC69-\uBC83\uBC85-\uBC9F\uBCA1-\uBCBB\uBCBD-\uBCD7\uBCD9-\uBCF3\uBCF5-\uBD0F\uBD11-\uBD2B\uBD2D-\uBD47\uBD49-\uBD63\uBD65-\uBD7F\uBD81-\uBD9B\uBD9D-\uBDB7\uBDB9-\uBDD3\uBDD5-\uBDEF\uBDF1-\uBE0B\uBE0D-\uBE27\uBE29-\uBE43\uBE45-\uBE5F\uBE61-\uBE7B\uBE7D-\uBE97\uBE99-\uBEB3\uBEB5-\uBECF\uBED1-\uBEEB\uBEED-\uBF07\uBF09-\uBF23\uBF25-\uBF3F\uBF41-\uBF5B\uBF5D-\uBF77\uBF79-\uBF93\uBF95-\uBFAF\uBFB1-\uBFCB\uBFCD-\uBFE7\uBFE9-\uC003\uC005-\uC01F\uC021-\uC03B\uC03D-\uC057\uC059-\uC073\uC075-\uC08F\uC091-\uC0AB\uC0AD-\uC0C7\uC0C9-\uC0E3\uC0E5-\uC0FF\uC101-\uC11B\uC11D-\uC137\uC139-\uC153\uC155-\uC16F\uC171-\uC18B\uC18D-\uC1A7\uC1A9-\uC1C3\uC1C5-\uC1DF\uC1E1-\uC1FB\uC1FD-\uC217\uC219-\uC233\uC235-\uC24F\uC251-\uC26B\uC26D-\uC287\uC289-\uC2A3\uC2A5-\uC2BF\uC2C1-\uC2DB\uC2DD-\uC2F7\uC2F9-\uC313\uC315-\uC32F\uC331-\uC34B\uC34D-\uC367\uC369-\uC383\uC385-\uC39F\uC3A1-\uC3BB\uC3BD-\uC3D7\uC3D9-\uC3F3\uC3F5-\uC40F\uC411-\uC42B\uC42D-\uC447\uC449-\uC463\uC465-\uC47F\uC481-\uC49B\uC49D-\uC4B7\uC4B9-\uC4D3\uC4D5-\uC4EF\uC4F1-\uC50B\uC50D-\uC527\uC529-\uC543\uC545-\uC55F\uC561-\uC57B\uC57D-\uC597\uC599-\uC5B3\uC5B5-\uC5CF\uC5D1-\uC5EB\uC5ED-\uC607\uC609-\uC623\uC625-\uC63F\uC641-\uC65B\uC65D-\uC677\uC679-\uC693\uC695-\uC6AF\uC6B1-\uC6CB\uC6CD-\uC6E7\uC6E9-\uC703\uC705-\uC71F\uC721-\uC73B\uC73D-\uC757\uC759-\uC773\uC775-\uC78F\uC791-\uC7AB\uC7AD-\uC7C7\uC7C9-\uC7E3\uC7E5-\uC7FF\uC801-\uC81B\uC81D-\uC837\uC839-\uC853\uC855-\uC86F\uC871-\uC88B\uC88D-\uC8A7\uC8A9-\uC8C3\uC8C5-\uC8DF\uC8E1-\uC8FB\uC8FD-\uC917\uC919-\uC933\uC935-\uC94F\uC951-\uC96B\uC96D-\uC987\uC989-\uC9A3\uC9A5-\uC9BF\uC9C1-\uC9DB\uC9DD-\uC9F7\uC9F9-\uCA13\uCA15-\uCA2F\uCA31-\uCA4B\uCA4D-\uCA67\uCA69-\uCA83\uCA85-\uCA9F\uCAA1-\uCABB\uCABD-\uCAD7\uCAD9-\uCAF3\uCAF5-\uCB0F\uCB11-\uCB2B\uCB2D-\uCB47\uCB49-\uCB63\uCB65-\uCB7F\uCB81-\uCB9B\uCB9D-\uCBB7\uCBB9-\uCBD3\uCBD5-\uCBEF\uCBF1-\uCC0B\uCC0D-\uCC27\uCC29-\uCC43\uCC45-\uCC5F\uCC61-\uCC7B\uCC7D-\uCC97\uCC99-\uCCB3\uCCB5-\uCCCF\uCCD1-\uCCEB\uCCED-\uCD07\uCD09-\uCD23\uCD25-\uCD3F\uCD41-\uCD5B\uCD5D-\uCD77\uCD79-\uCD93\uCD95-\uCDAF\uCDB1-\uCDCB\uCDCD-\uCDE7\uCDE9-\uCE03\uCE05-\uCE1F\uCE21-\uCE3B\uCE3D-\uCE57\uCE59-\uCE73\uCE75-\uCE8F\uCE91-\uCEAB\uCEAD-\uCEC7\uCEC9-\uCEE3\uCEE5-\uCEFF\uCF01-\uCF1B\uCF1D-\uCF37\uCF39-\uCF53\uCF55-\uCF6F\uCF71-\uCF8B\uCF8D-\uCFA7\uCFA9-\uCFC3\uCFC5-\uCFDF\uCFE1-\uCFFB\uCFFD-\uD017\uD019-\uD033\uD035-\uD04F\uD051-\uD06B\uD06D-\uD087\uD089-\uD0A3\uD0A5-\uD0BF\uD0C1-\uD0DB\uD0DD-\uD0F7\uD0F9-\uD113\uD115-\uD12F\uD131-\uD14B\uD14D-\uD167\uD169-\uD183\uD185-\uD19F\uD1A1-\uD1BB\uD1BD-\uD1D7\uD1D9-\uD1F3\uD1F5-\uD20F\uD211-\uD22B\uD22D-\uD247\uD249-\uD263\uD265-\uD27F\uD281-\uD29B\uD29D-\uD2B7\uD2B9-\uD2D3\uD2D5-\uD2EF\uD2F1-\uD30B\uD30D-\uD327\uD329-\uD343\uD345-\uD35F\uD361-\uD37B\uD37D-\uD397\uD399-\uD3B3\uD3B5-\uD3CF\uD3D1-\uD3EB\uD3ED-\uD407\uD409-\uD423\uD425-\uD43F\uD441-\uD45B\uD45D-\uD477\uD479-\uD493\uD495-\uD4AF\uD4B1-\uD4CB\uD4CD-\uD4E7\uD4E9-\uD503\uD505-\uD51F\uD521-\uD53B\uD53D-\uD557\uD559-\uD573\uD575-\uD58F\uD591-\uD5AB\uD5AD-\uD5C7\uD5C9-\uD5E3\uD5E5-\uD5FF\uD601-\uD61B\uD61D-\uD637\uD639-\uD653\uD655-\uD66F\uD671-\uD68B\uD68D-\uD6A7\uD6A9-\uD6C3\uD6C5-\uD6DF\uD6E1-\uD6FB\uD6FD-\uD717\uD719-\uD733\uD735-\uD74F\uD751-\uD76B\uD76D-\uD787\uD789-\uD7A3]$/,rF=/^(?:[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u2388\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2605\u2607-\u2612\u2614-\u2685\u2690-\u2705\u2708-\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763-\u2767\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDD0F\uDD2F\uDD6C-\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDAD-\uDDE5\uDE01-\uDE0F\uDE1A\uDE2F\uDE32-\uDE3A\uDE3C-\uDE3F\uDE49-\uDFFA]|\uD83D[\uDC00-\uDD3D\uDD46-\uDE4F\uDE80-\uDEFF\uDF74-\uDF7F\uDFD5-\uDFFF]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE-\uDCFF\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDEFF]|\uD83F[\uDC00-\uDFFD])$/,oF=(t,e)=>{var n=$e.Any;return t.search(XB)!==-1&&(n|=$e.Extend),e===8205&&(n|=$e.ZWJ),e>=127462&&e<=127487&&(n|=$e.RI),t.search(JB)!==-1&&(n|=$e.Prepend),t.search(RB)!==-1&&(n|=$e.SpacingMark),t.search(QB)!==-1&&(n|=$e.L),t.search(ZB)!==-1&&(n|=$e.V),t.search(eF)!==-1&&(n|=$e.T),t.search(tF)!==-1&&(n|=$e.LV),t.search(nF)!==-1&&(n|=$e.LVT),t.search(rF)!==-1&&(n|=$e.ExtPict),n};function Hi(t,e){return(t&e)!==0}var iF=[[$e.L,$e.L|$e.V|$e.LV|$e.LVT],[$e.LV|$e.V,$e.V|$e.T],[$e.LVT|$e.T,$e.T],[$e.Any,$e.Extend|$e.ZWJ],[$e.Any,$e.SpacingMark],[$e.Prepend,$e.Any],[$e.ZWJ,$e.ExtPict],[$e.RI,$e.RI]];function sF(t,e){return iF.findIndex(n=>Hi(t,n[0])&&Hi(e,n[1]))===-1}var aF=/(?:[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u2388\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2605\u2607-\u2612\u2614-\u2685\u2690-\u2705\u2708-\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763-\u2767\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDD0F\uDD2F\uDD6C-\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDAD-\uDDE5\uDE01-\uDE0F\uDE1A\uDE2F\uDE32-\uDE3A\uDE3C-\uDE3F\uDE49-\uDFFA]|\uD83D[\uDC00-\uDD3D\uDD46-\uDE4F\uDE80-\uDEFF\uDF74-\uDF7F\uDFD5-\uDFFF]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE-\uDCFF\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDEFF]|\uD83F[\uDC00-\uDFFD])(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC2\u0CC6\u0CCC\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732\u1733\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B03\u1B34-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200C\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDEFD-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34\uDE36\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF57\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB5\uDEB7\uDF1D-\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B\uDD3C\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40\uDF42]|\uD80D[\uDC40\uDC47-\uDC55]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65\uDD67-\uDD69\uDD6E-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF])*\u200D$/,J0=t=>t.search(aF)!==-1,lF=/(?:\uD83C[\uDDE6-\uDDFF])+$/g,cF=t=>{var e=t.match(lF);if(e===null)return!1;var n=e[0].length/2;return n%2===1},uF=function(e){var{deep:n=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!nn(e))return!1;var r=typeof e.addMark=="function"&&typeof e.apply=="function"&&typeof e.deleteFragment=="function"&&typeof e.insertBreak=="function"&&typeof e.insertSoftBreak=="function"&&typeof e.insertFragment=="function"&&typeof e.insertNode=="function"&&typeof e.insertText=="function"&&typeof e.isElementReadOnly=="function"&&typeof e.isInline=="function"&&typeof e.isSelectable=="function"&&typeof e.isVoid=="function"&&typeof e.normalizeNode=="function"&&typeof e.onChange=="function"&&typeof e.removeMark=="function"&&typeof e.getDirtyPaths=="function"&&(e.marks===null||nn(e.marks))&&(e.selection===null||oe.isRange(e.selection))&&(!n||ge.isNodeList(e.children))&&uo.isOperationList(e.operations);return r},I={above(t,e){return t.above(e)},addMark(t,e,n){t.addMark(e,n)},after(t,e,n){return t.after(e,n)},before(t,e,n){return t.before(e,n)},deleteBackward(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{unit:n="character"}=e;t.deleteBackward(n)},deleteForward(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{unit:n="character"}=e;t.deleteForward(n)},deleteFragment(t,e){t.deleteFragment(e)},edges(t,e){return t.edges(e)},elementReadOnly(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t.elementReadOnly(e)},end(t,e){return t.end(e)},first(t,e){return t.first(e)},fragment(t,e){return t.fragment(e)},hasBlocks(t,e){return t.hasBlocks(e)},hasInlines(t,e){return t.hasInlines(e)},hasPath(t,e){return t.hasPath(e)},hasTexts(t,e){return t.hasTexts(e)},insertBreak(t){t.insertBreak()},insertFragment(t,e,n){t.insertFragment(e,n)},insertNode(t,e){t.insertNode(e)},insertSoftBreak(t){t.insertSoftBreak()},insertText(t,e){t.insertText(e)},isBlock(t,e){return t.isBlock(e)},isEdge(t,e,n){return t.isEdge(e,n)},isEditor(t){return uF(t)},isElementReadOnly(t,e){return t.isElementReadOnly(e)},isEmpty(t,e){return t.isEmpty(e)},isEnd(t,e,n){return t.isEnd(e,n)},isInline(t,e){return t.isInline(e)},isNormalizing(t){return t.isNormalizing()},isSelectable(t,e){return t.isSelectable(e)},isStart(t,e,n){return t.isStart(e,n)},isVoid(t,e){return t.isVoid(e)},last(t,e){return t.last(e)},leaf(t,e,n){return t.leaf(e,n)},levels(t,e){return t.levels(e)},marks(t){return t.getMarks()},next(t,e){return t.next(e)},node(t,e,n){return t.node(e,n)},nodes(t,e){return t.nodes(e)},normalize(t,e){t.normalize(e)},parent(t,e,n){return t.parent(e,n)},path(t,e,n){return t.path(e,n)},pathRef(t,e,n){return t.pathRef(e,n)},pathRefs(t){return t.pathRefs()},point(t,e,n){return t.point(e,n)},pointRef(t,e,n){return t.pointRef(e,n)},pointRefs(t){return t.pointRefs()},positions(t,e){return t.positions(e)},previous(t,e){return t.previous(e)},range(t,e,n){return t.range(e,n)},rangeRef(t,e,n){return t.rangeRef(e,n)},rangeRefs(t){return t.rangeRefs()},removeMark(t,e){t.removeMark(e)},setNormalizing(t,e){t.setNormalizing(e)},start(t,e){return t.start(e)},string(t,e,n){return t.string(e,n)},unhangRange(t,e,n){return t.unhangRange(e,n)},void(t,e){return t.void(e)},withoutNormalizing(t,e){t.withoutNormalizing(e)},shouldMergeNodesRemovePrevNode:(t,e,n)=>t.shouldMergeNodesRemovePrevNode(e,n)},dF={isLocation(t){return U.isPath(t)||Re.isPoint(t)||oe.isRange(t)}},fF={isSpan(t){return Array.isArray(t)&&t.length===2&&t.every(U.isPath)}};function R0(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Q0(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?R0(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R0(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var Re={compare(t,e){var n=U.compare(t.path,e.path);return n===0?t.offset<e.offset?-1:t.offset>e.offset?1:0:n},isAfter(t,e){return Re.compare(t,e)===1},isBefore(t,e){return Re.compare(t,e)===-1},equals(t,e){return t.offset===e.offset&&U.equals(t.path,e.path)},isPoint(t){return nn(t)&&typeof t.offset=="number"&&U.isPath(t.path)},transform(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(t===null)return null;var{affinity:r="forward"}=n,{path:o,offset:i}=t;switch(e.type){case"insert_node":case"move_node":{o=U.transform(o,e,n);break}case"insert_text":{U.equals(e.path,o)&&(e.offset<i||e.offset===i&&r==="forward")&&(i+=e.text.length);break}case"merge_node":{U.equals(e.path,o)&&(i+=e.position),o=U.transform(o,e,n);break}case"remove_text":{U.equals(e.path,o)&&e.offset<=i&&(i-=Math.min(i-e.offset,e.text.length));break}case"remove_node":{if(U.equals(e.path,o)||U.isAncestor(e.path,o))return null;o=U.transform(o,e,n);break}case"split_node":{if(U.equals(e.path,o)){if(e.position===i&&r==null)return null;(e.position<i||e.position===i&&r==="forward")&&(i-=e.position,o=U.transform(o,e,Q0(Q0({},n),{},{affinity:"forward"})))}else o=U.transform(o,e,n);break}default:return t}return{path:o,offset:i}}},Z0=void 0,$t={setScrubber(t){Z0=t},stringify(t){return JSON.stringify(t,Z0)}},hF=["text"],pF=["anchor","focus","merge"];function ey(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Yr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ey(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ey(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var Oe={equals(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{loose:r=!1}=n;function o(i){var s=Kr(i,hF);return s}return X0(r?o(t):t,r?o(e):e)},isText(t){return nn(t)&&typeof t.text=="string"},isTextList(t){return Array.isArray(t)&&t.every(e=>Oe.isText(e))},isTextProps(t){return t.text!==void 0},matches(t,e){for(var n in e)if(n!=="text"&&(!t.hasOwnProperty(n)||t[n]!==e[n]))return!1;return!0},decorations(t,e){var n=[{leaf:Yr({},t)}];for(var r of e){var{anchor:o,focus:i,merge:s}=r,a=Kr(r,pF),[l,c]=oe.edges(r),u=[],d=0,h=l.offset,p=c.offset,m=s??Object.assign;for(var{leaf:w}of n){var{length:v}=w.text,y=d;if(d+=v,h<=y&&d<=p){m(w,a),u.push({leaf:w});continue}if(h!==p&&(h===d||p===y)||h>d||p<y||p===y&&y!==0){u.push({leaf:w});continue}var g=w,k=void 0,A=void 0;if(p<d){var C=p-y;A={leaf:Yr(Yr({},g),{},{text:g.text.slice(C)})},g=Yr(Yr({},g),{},{text:g.text.slice(0,C)})}if(h>y){var E=h-y;k={leaf:Yr(Yr({},g),{},{text:g.text.slice(0,E)})},g=Yr(Yr({},g),{},{text:g.text.slice(E)})}m(g,a),k&&u.push(k),u.push({leaf:g}),A&&u.push(A)}n=u}if(n.length>1){var D=0;for(var[S,_]of n.entries()){var O=D,B=O+_.leaf.text.length,N={start:O,end:B};S===0&&(N.isFirst=!0),S===n.length-1&&(N.isLast=!0),_.position=N,D=B}}return n}};function ty(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function rc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ty(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ty(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var ny=function(e,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return[...e.slice(0,n),...o,...e.slice(n)]},Rs=function(e,n,r){for(var o=arguments.length,i=new Array(o>3?o-3:0),s=3;s<o;s++)i[s-3]=arguments[s];return[...e.slice(0,n),...i,...e.slice(n+r)]},Nf=Rs,Bf=(t,e,n)=>{if(e.length===0)throw new Error("Cannot modify the editor");for(var r=ge.get(t,e),o=e.slice(),i=n(r);o.length>1;){var s=o.pop(),a=ge.get(t,o);i=rc(rc({},a),{},{children:Rs(a.children,s,1,i)})}var l=o.pop();t.children=Rs(t.children,l,1,i)},Ko=(t,e,n)=>{e.length===0?t.children=n(t.children):Bf(t,e,r=>{if(Oe.isText(r))throw new Error("Cannot get the element at path [".concat(e,"] because it refers to a leaf node: ").concat($t.stringify(r)));return rc(rc({},r),{},{children:n(r.children)})})},oc=(t,e,n)=>Bf(t,e,r=>{if(!Oe.isText(r))throw new Error("Cannot get the leaf node at path [".concat(e,"] because it refers to a non-leaf node: ").concat($t.stringify(r)));return n(r)});function ry(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Tt(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ry(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ry(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var mF={transform(t,e){var n=!1;switch(e.type){case"insert_node":{var{path:r,node:o}=e;Ko(t,U.parent(r),q=>{var J=r[r.length-1];if(J>q.length)throw new Error('Cannot apply an "insert_node" operation at path ['.concat(r,"] because the destination is past the end of the node."));return ny(q,J,o)}),n=!0;break}case"insert_text":{var{path:i,offset:s,text:a}=e;if(a.length===0)break;oc(t,i,q=>{var J=q.text.slice(0,s),K=q.text.slice(s);return Tt(Tt({},q),{},{text:J+a+K})}),n=!0;break}case"merge_node":{var{path:l}=e,c=l[l.length-1],u=U.previous(l),d=u[u.length-1];Ko(t,U.parent(l),q=>{var J=q[c],K=q[d],re;if(Oe.isText(J)&&Oe.isText(K))re=Tt(Tt({},K),{},{text:K.text+J.text});else if(!Oe.isText(J)&&!Oe.isText(K))re=Tt(Tt({},K),{},{children:K.children.concat(J.children)});else throw new Error('Cannot apply a "merge_node" operation at path ['.concat(l,"] to nodes of different interfaces: ").concat($t.stringify(J)," ").concat($t.stringify(K)));return Rs(q,d,2,re)}),n=!0;break}case"move_node":{var{path:h,newPath:p}=e,m=h[h.length-1];if(U.isAncestor(h,p))throw new Error("Cannot move a path [".concat(h,"] to new path [").concat(p,"] because the destination is inside itself."));var w=ge.get(t,h);Ko(t,U.parent(h),q=>Nf(q,m,1));var v=U.transform(h,e),y=v[v.length-1];Ko(t,U.parent(v),q=>ny(q,y,w)),n=!0;break}case"remove_node":{var{path:g}=e,k=g[g.length-1];if(Ko(t,U.parent(g),q=>Nf(q,k,1)),t.selection){var A=Tt({},t.selection);for(var[C,E]of oe.points(A)){var D=Re.transform(C,e);if(A!=null&&D!=null)A[E]=D;else{var S=void 0,_=void 0;for(var[O,B]of ge.texts(t))if(U.compare(B,g)===-1)S=[O,B];else{_=[O,B];break}var N=!1;S&&_&&(U.isSibling(S[1],g)?N=!1:U.equals(_[1],g)?N=!0:N=U.common(S[1],g).length<U.common(_[1],g).length),S&&!N?A[E]={path:S[1],offset:S[0].text.length}:_?A[E]={path:_[1],offset:0}:A=null}}(!A||!oe.equals(A,t.selection))&&(t.selection=A)}break}case"remove_text":{var{path:F,offset:M,text:T}=e;if(T.length===0)break;oc(t,F,q=>{var J=q.text.slice(0,M),K=q.text.slice(M+T.length);return Tt(Tt({},q),{},{text:J+K})}),n=!0;break}case"set_node":{var{path:P,properties:$,newProperties:W}=e;if(P.length===0)throw new Error("Cannot set properties on the root node!");Bf(t,P,q=>{var J=Tt({},q);for(var K in W){if(K==="children"||K==="text")throw new Error('Cannot set the "'.concat(K,'" property of nodes!'));var re=W[K];re==null?delete J[K]:J[K]=re}for(var ie in $)W.hasOwnProperty(ie)||delete J[ie];return J});break}case"set_selection":{var{newProperties:V}=e;if(V==null){t.selection=null;break}if(t.selection==null){if(!oe.isRange(V))throw new Error('Cannot apply an incomplete "set_selection" operation properties '.concat($t.stringify(V)," when there is no current selection."));t.selection=Tt({},V);break}var X=Tt({},t.selection);for(var G in V){var te=V[G];if(te==null){if(G==="anchor"||G==="focus")throw new Error('Cannot remove the "'.concat(G,'" selection property'));delete X[G]}else X[G]=te}t.selection=X;break}case"split_node":{var{path:H,position:j,properties:Y}=e,se=H[H.length-1];if(H.length===0)throw new Error('Cannot apply a "split_node" operation at path ['.concat(H,"] because the root node cannot be split."));Ko(t,U.parent(H),q=>{var J=q[se],K,re;if(Oe.isText(J)){var ie=J.text.slice(0,j),he=J.text.slice(j);K=Tt(Tt({},J),{},{text:ie}),re=Tt(Tt({},Y),{},{text:he})}else{var Ce=J.children.slice(0,j),Fe=J.children.slice(j);K=Tt(Tt({},J),{},{children:Ce}),re=Tt(Tt({},Y),{},{children:Fe})}return Rs(q,se,1,K,re)}),n=!0;break}}if(n&&t.selection){var Q=Tt({},t.selection);for(var[le,L]of oe.points(Q))Q[L]=Re.transform(le,e);oe.equals(Q,t.selection)||(t.selection=Q)}}},gF={insertNodes(t,e,n){t.insertNodes(e,n)},liftNodes(t,e){t.liftNodes(e)},mergeNodes(t,e){t.mergeNodes(e)},moveNodes(t,e){t.moveNodes(e)},removeNodes(t,e){t.removeNodes(e)},setNodes(t,e,n){t.setNodes(e,n)},splitNodes(t,e){t.splitNodes(e)},unsetNodes(t,e,n){t.unsetNodes(e,n)},unwrapNodes(t,e){t.unwrapNodes(e)},wrapNodes(t,e,n){t.wrapNodes(e,n)}},wF={collapse(t,e){t.collapse(e)},deselect(t){t.deselect()},move(t,e){t.move(e)},select(t,e){t.select(e)},setPoint(t,e,n){t.setPoint(e,n)},setSelection(t,e){t.setSelection(e)}},vF={delete(t,e){t.delete(e)},insertFragment(t,e,n){t.insertFragment(e,n)},insertText(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};I.withoutNormalizing(t,()=>{var{voids:r=!1}=n,{at:o=Of(t)}=n;if(U.isPath(o)&&(o=I.range(t,o)),oe.isRange(o))if(oe.isCollapsed(o))o=o.anchor;else{var i=oe.end(o);if(!r&&I.void(t,{at:i}))return;var s=oe.start(o),a=I.pointRef(t,s),l=I.pointRef(t,i);ce.delete(t,{at:o,voids:r});var c=a.unref(),u=l.unref();o=c||u,ce.setSelection(t,{anchor:o,focus:o})}if(!(!r&&I.void(t,{at:o})||I.elementReadOnly(t,{at:o}))){var{path:d,offset:h}=o;e.length>0&&t.apply({type:"insert_text",path:d,offset:h,text:e})}})}};function oy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function ic(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?oy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):oy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var ce=ic(ic(ic(ic({},mF),gF),wF),vF),sc=new WeakMap,yF=t=>sc.get(t)||!1,bF=(t,e,n)=>{var r=sc.get(t)||!1;sc.set(t,!0);try{e(),n()}finally{sc.set(t,r)}};function iy(t,e,n){var r=ec.get(t)||[],o=tc.get(t)||new Set,i,s,a=d=>{if(d){var h=d.join(",");s.has(h)||(s.add(h),i.push(d))}};if(n){i=[],s=new Set;for(var l of r){var c=n(l);a(c)}}else i=r,s=o;for(var u of e)a(u);ec.set(t,i),tc.set(t,s)}var CF=(t,e)=>{for(var n of I.pathRefs(t))NB.transform(n,e);for(var r of I.pointRefs(t))BB.transform(r,e);for(var o of I.rangeRefs(t))FB.transform(o,e);if(!yF(t)){var i=U.operationCanTransformPath(e)?s=>U.transform(s,e):void 0;iy(t,t.getDirtyPaths(e),i)}ce.transform(t,e),t.operations.push(e),I.normalize(t,{operation:e}),e.type==="set_selection"&&(t.marks=null),Xs.get(t)||(Xs.set(t,!0),Promise.resolve().then(()=>{Xs.set(t,!1),t.onChange({operation:e}),t.operations=[]}))},kF=(t,e)=>{switch(e.type){case"insert_text":case"remove_text":case"set_node":{var{path:n}=e;return U.levels(n)}case"insert_node":{var{node:r,path:o}=e,i=U.levels(o),s=Oe.isText(r)?[]:Array.from(ge.nodes(r),O=>{var[,B]=O;return o.concat(B)});return[...i,...s]}case"merge_node":{var{path:a}=e,l=U.ancestors(a),c=U.previous(a);return[...l,c]}case"move_node":{var{path:u,newPath:d}=e;if(U.equals(u,d))return[];var h=[],p=[];for(var m of U.ancestors(u)){var w=U.transform(m,e);h.push(w)}for(var v of U.ancestors(d)){var y=U.transform(v,e);p.push(y)}var g=p[p.length-1],k=d[d.length-1],A=g.concat(k);return[...h,...p,A]}case"remove_node":{var{path:C}=e,E=U.ancestors(C);return[...E]}case"split_node":{var{path:D}=e,S=U.levels(D),_=U.next(D);return[...S,_]}default:return[]}},xF=t=>{var{selection:e}=t;return e?ge.fragment(t,e):[]},SF=(t,e,n)=>{var[r,o]=e;if(!Oe.isText(r)){if(Ae.isElement(r)&&r.children.length===0){var i={text:""};ce.insertNodes(t,i,{at:o.concat(0),voids:!0});return}for(var s=I.isEditor(r)?!1:Ae.isElement(r)&&(t.isInline(r)||r.children.length===0||Oe.isText(r.children[0])||t.isInline(r.children[0])),a=0,l=0;l<r.children.length;l++,a++){var c=ge.get(t,o);if(!Oe.isText(c)){var u=c.children[a],d=c.children[a-1],h=l===r.children.length-1,p=Oe.isText(u)||Ae.isElement(u)&&t.isInline(u);if(p!==s)p?n!=null&&n.fallbackElement?ce.wrapNodes(t,n.fallbackElement(),{at:o.concat(a),voids:!0}):ce.removeNodes(t,{at:o.concat(a),voids:!0}):ce.unwrapNodes(t,{at:o.concat(a),voids:!0}),a--;else if(Ae.isElement(u)){if(t.isInline(u)){if(d==null||!Oe.isText(d)){var m={text:""};ce.insertNodes(t,m,{at:o.concat(a),voids:!0}),a++}else if(h){var w={text:""};ce.insertNodes(t,w,{at:o.concat(a+1),voids:!0}),a++}}}else{if(!Oe.isText(u)&&!("children"in u)){var v=u;v.children=[]}d!=null&&Oe.isText(d)&&(Oe.equals(u,d,{loose:!0})?(ce.mergeNodes(t,{at:o.concat(a),voids:!0}),a--):d.text===""?(ce.removeNodes(t,{at:o.concat(a-1),voids:!0}),a--):u.text===""&&(ce.removeNodes(t,{at:o.concat(a),voids:!0}),a--))}}}}},EF=(t,e)=>{var{iteration:n,initialDirtyPathsLength:r}=e,o=r*42;if(n>o)throw new Error("Could not completely normalize the editor after ".concat(o," iterations! This is usually due to incorrect normalization logic that leaves a node in an invalid state."));return!0},DF=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{voids:r=!1,mode:o="lowest",at:i=e.selection,match:s}=n;if(i){var a=I.path(e,i);if(!oe.isRange(i)||U.equals(i.focus.path,i.anchor.path)){if(a.length===0)return;a=U.parent(a)}var l=o==="lowest",[c]=I.levels(e,{at:a,voids:r,match:s,reverse:l});return c}};function sy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function ay(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?sy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var AF=(t,e,n)=>{var{selection:r}=t;if(r){var o=(d,h)=>{if(!Oe.isText(d))return!1;var[p,m]=I.parent(t,h);return!t.isVoid(p)||t.markableVoid(p)},i=oe.isExpanded(r),s=!1;if(!i){var[a,l]=I.node(t,r);if(a&&o(a,l)){var[c]=I.parent(t,l);s=c&&t.markableVoid(c)}}if(i||s)ce.setNodes(t,{[e]:n},{match:o,split:!0,voids:!0});else{var u=ay(ay({},I.marks(t)||{}),{},{[e]:n});t.marks=u,Xs.get(t)||t.onChange()}}};function ly(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function cy(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ly(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ly(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var OF=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=I.point(e,n,{edge:"end"}),i=I.end(e,[]),s={anchor:o,focus:i},{distance:a=1}=r,l=0,c;for(var u of I.positions(e,cy(cy({},r),{},{at:s}))){if(l>a)break;l!==0&&(c=u),l++}return c};function uy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function dy(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?uy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):uy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var TF=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=I.start(e,[]),i=I.point(e,n,{edge:"start"}),s={anchor:o,focus:i},{distance:a=1}=r,l=0,c;for(var u of I.positions(e,dy(dy({},r),{},{at:s,reverse:!0}))){if(l>a)break;l!==0&&(c=u),l++}return c},_F=(t,e)=>{var{selection:n}=t;n&&oe.isCollapsed(n)&&ce.delete(t,{unit:e,reverse:!0})},NF=(t,e)=>{var{selection:n}=t;n&&oe.isCollapsed(n)&&ce.delete(t,{unit:e})},BF=function(e){var{direction:n="forward"}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{selection:r}=e;r&&oe.isExpanded(r)&&ce.delete(e,{reverse:n==="backward"})},FF=(t,e)=>[I.start(t,e),I.end(t,e)];function fy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function hy(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?fy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):fy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var IF=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return I.above(e,hy(hy({},n),{},{match:r=>Ae.isElement(r)&&I.isElementReadOnly(e,r)}))},MF=(t,e)=>I.point(t,e,{edge:"end"}),PF=(t,e)=>{var n=I.path(t,e,{edge:"start"});return I.node(t,n)},LF=(t,e)=>{var n=I.range(t,e);return ge.fragment(t,n)};function py(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function my(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?py(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):py(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var $F=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return I.above(e,my(my({},n),{},{match:r=>Ae.isElement(r)&&I.isVoid(e,r)}))},HF=(t,e)=>e.children.some(n=>Ae.isElement(n)&&I.isBlock(t,n)),zF=(t,e)=>e.children.some(n=>Oe.isText(n)||I.isInline(t,n)),jF=(t,e)=>ge.has(t,e),VF=(t,e)=>e.children.every(n=>Oe.isText(n)),WF=t=>{ce.splitNodes(t,{always:!0})},UF=(t,e,n)=>{ce.insertNodes(t,e,n)},qF=t=>{ce.splitNodes(t,{always:!0})};function gy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function GF(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var KF=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{selection:o,marks:i}=e;if(o){if(i){var s=GF({text:n},i);ce.insertNodes(e,s,{at:r.at,voids:r.voids})}else ce.insertText(e,n,r);e.marks=null}},YF=(t,e)=>!t.isInline(e),XF=(t,e,n)=>I.isStart(t,e,n)||I.isEnd(t,e,n),JF=(t,e)=>{var{children:n}=e,[r]=n;return n.length===0||n.length===1&&Oe.isText(r)&&r.text===""&&!t.isVoid(e)},RF=(t,e,n)=>{var r=I.end(t,n);return Re.equals(e,r)},QF=t=>{var e=j0.get(t);return e===void 0?!0:e},ZF=(t,e,n)=>{if(e.offset!==0)return!1;var r=I.start(t,n);return Re.equals(e,r)},eI=(t,e)=>{var n=I.path(t,e,{edge:"end"});return I.node(t,n)},tI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=I.path(e,n,r),i=ge.leaf(e,o);return[i,o]};function nI(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){var{at:n=t.selection,reverse:r=!1,voids:o=!1}=e,{match:i}=e;if(i==null&&(i=()=>!0),!!n){var s=[],a=I.path(t,n);for(var[l,c]of ge.levels(t,a))if(i(l,c)&&(s.push([l,c]),!o&&Ae.isElement(l)&&I.isVoid(t,l)))break;r&&s.reverse(),yield*s}})()}var rI=["text"],oI=["text"],iI=function(e){var{marks:n,selection:r}=e;if(!r)return null;var{anchor:o,focus:i}=r;if(n)return n;if(oe.isExpanded(r)){var s=oe.isBackward(r);s&&([i,o]=[o,i]);var a=I.isEnd(e,o,o.path);if(a){var l=I.after(e,o);l&&(o=l)}var[c]=I.nodes(e,{match:Oe.isText,at:{anchor:o,focus:i}});if(c){var[u]=c,d=Kr(u,rI);return d}else return{}}var{path:h}=o,[p]=I.leaf(e,h);if(o.offset===0){var m=I.previous(e,{at:h,match:Oe.isText}),w=I.above(e,{match:C=>Ae.isElement(C)&&I.isVoid(e,C)&&e.markableVoid(C)});if(!w){var v=I.above(e,{match:C=>Ae.isElement(C)&&I.isBlock(e,C)});if(m&&v){var[y,g]=m,[,k]=v;U.isAncestor(k,g)&&(p=y)}}}var A=Kr(p,oI);return A},sI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{mode:r="lowest",voids:o=!1}=n,{match:i,at:s=e.selection}=n;if(s){var a=I.after(e,s,{voids:o});if(a){var[,l]=I.last(e,[]),c=[a.path,l];if(U.isPath(s)&&s.length===0)throw new Error("Cannot get the next node from the root node!");if(i==null)if(U.isPath(s)){var[u]=I.parent(e,s);i=h=>u.children.includes(h)}else i=()=>!0;var[d]=I.nodes(e,{at:c,match:i,mode:r,voids:o});return d}}},aI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=I.path(e,n,r),i=ge.get(e,o);return[i,o]};function lI(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){var{at:n=t.selection,mode:r="all",universal:o=!1,reverse:i=!1,voids:s=!1,pass:a}=e,{match:l}=e;if(l||(l=()=>!0),!!n){var c,u;if(fF.isSpan(n))c=n[0],u=n[1];else{var d=I.path(t,n,{edge:"start"}),h=I.path(t,n,{edge:"end"});c=i?h:d,u=i?d:h}var p=ge.nodes(t,{reverse:i,from:c,to:u,pass:A=>{var[C,E]=A;return a&&a([C,E])?!0:Ae.isElement(C)?!!(!s&&(I.isVoid(t,C)||I.isElementReadOnly(t,C))):!1}}),m=[],w;for(var[v,y]of p){var g=w&&U.compare(y,w[1])===0;if(!(r==="highest"&&g)){if(!l(v,y)){if(o&&!g&&Oe.isText(v))return;continue}if(r==="lowest"&&g){w=[v,y];continue}var k=r==="lowest"?w:[v,y];k&&(o?m.push(k):yield k),w=[v,y]}}r==="lowest"&&w&&(o?m.push(w):yield w),o&&(yield*m)}})()}var cI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{force:r=!1,operation:o}=n,i=u=>ec.get(u)||[],s=u=>tc.get(u)||new Set,a=u=>{var d=i(u).pop(),h=d.join(",");return s(u).delete(h),d};if(I.isNormalizing(e)){if(r){var l=Array.from(ge.nodes(e),u=>{var[,d]=u;return d}),c=new Set(l.map(u=>u.join(",")));ec.set(e,l),tc.set(e,c)}i(e).length!==0&&I.withoutNormalizing(e,()=>{for(var u of i(e))if(ge.has(e,u)){var d=I.node(e,u),[h,p]=d;Ae.isElement(h)&&h.children.length===0&&e.normalizeNode(d,{operation:o})}for(var m=i(e),w=m.length,v=0;m.length!==0;){if(!e.shouldNormalize({dirtyPaths:m,iteration:v,initialDirtyPathsLength:w,operation:o}))return;var y=a(e);if(ge.has(e,y)){var g=I.node(e,y);e.normalizeNode(g,{operation:o})}v++,m=i(e)}})}},uI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=I.path(e,n,r),i=U.parent(o),s=I.node(e,i);return s},dI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:o="forward"}=r,i={current:n,affinity:o,unref(){var{current:a}=i,l=I.pathRefs(e);return l.delete(i),i.current=null,a}},s=I.pathRefs(e);return s.add(i),i},fI=t=>{var e=V0.get(t);return e||(e=new Set,V0.set(t,e)),e},hI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{depth:o,edge:i}=r;if(U.isPath(n)){if(i==="start"){var[,s]=ge.first(e,n);n=s}else if(i==="end"){var[,a]=ge.last(e,n);n=a}}return oe.isRange(n)&&(i==="start"?n=oe.start(n):i==="end"?n=oe.end(n):n=U.common(n.anchor.path,n.focus.path)),Re.isPoint(n)&&(n=n.path),o!=null&&(n=n.slice(0,o)),n},pI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:o="forward"}=r,i={current:n,affinity:o,unref(){var{current:a}=i,l=I.pointRefs(e);return l.delete(i),i.current=null,a}},s=I.pointRefs(e);return s.add(i),i},mI=t=>{var e=W0.get(t);return e||(e=new Set,W0.set(t,e)),e},gI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{edge:o="start"}=r;if(U.isPath(n)){var i;if(o==="end"){var[,s]=ge.last(e,n);i=s}else{var[,a]=ge.first(e,n);i=a}var l=ge.get(e,i);if(!Oe.isText(l))throw new Error("Cannot get the ".concat(o," point in the node at path [").concat(n,"] because it has no ").concat(o," text node."));return{path:i,offset:o==="end"?l.text.length:0}}if(oe.isRange(n)){var[c,u]=oe.edges(n);return o==="start"?c:u}return n};function wI(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){var{at:n=t.selection,unit:r="offset",reverse:o=!1,voids:i=!1}=e;if(!n)return;var s=I.range(t,n),[a,l]=oe.edges(s),c=o?l:a,u=!1,d="",h=0,p=0,m=0,w=[],v=function*(E){var D=w.some(F=>U.isAncestor(F,E));function*S(F){D||(yield F)}if(Ae.isElement(g)){if(!t.isSelectable(g)){if(w.push(E),o)return U.hasPrevious(E)&&(yield*S(I.end(t,U.previous(E)))),0;var _=U.next(E);return I.hasPath(t,_)&&(yield*S(I.start(t,_))),0}if(!i&&(t.isVoid(g)||t.isElementReadOnly(g)))return yield*S(I.start(t,E)),0;if(t.isInline(g))return 0;if(I.hasInlines(t,g)){var O=U.isAncestor(E,l.path)?l:I.end(t,E),B=U.isAncestor(E,a.path)?a:I.start(t,E);d=I.string(t,{anchor:B,focus:O},{voids:i}),u=!0}}if(Oe.isText(g)){var N=U.equals(E,c.path);for(N?(p=o?c.offset:g.text.length-c.offset,m=c.offset):(p=g.text.length,m=o?p:0),(N||u||r==="offset")&&(yield*S({path:E,offset:m}),u=!1);;){if(h===0){if(d==="")break;h=A(d,r,o),d=_f(d,h,o)[1]}if(m=o?m-h:m+h,p=p-h,p<0){h=-p;break}h=0,yield*S({path:E,offset:m})}}},y;for(var[g,k]of I.nodes(t,{at:n,reverse:o,voids:i}))y=yield*v(k);function A(C,E,D){return E==="character"?Tf(C,D):E==="word"?UB(C,D):E==="line"||E==="block"?C.length:1}})()}var vI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{mode:r="lowest",voids:o=!1}=n,{match:i,at:s=e.selection}=n;if(s){var a=I.before(e,s,{voids:o});if(a){var[,l]=I.first(e,[]),c=[a.path,l];if(U.isPath(s)&&s.length===0)throw new Error("Cannot get the previous node from the root node!");if(i==null)if(U.isPath(s)){var[u]=I.parent(e,s);i=h=>u.children.includes(h)}else i=()=>!0;var[d]=I.nodes(e,{reverse:!0,at:c,match:i,mode:r,voids:o});return d}}},yI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:o="forward"}=r,i={current:n,affinity:o,unref(){var{current:a}=i,l=I.rangeRefs(e);return l.delete(i),i.current=null,a}},s=I.rangeRefs(e);return s.add(i),i},bI=t=>{var e=U0.get(t);return e||(e=new Set,U0.set(t,e)),e},CI=(t,e,n)=>{if(oe.isRange(e)&&!n)return e;var r=I.start(t,e),o=I.end(t,n||e);return{anchor:r,focus:o}};function wy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function kI(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?wy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var xI=(t,e)=>{var{selection:n}=t;if(n){var r=(u,d)=>{if(!Oe.isText(u))return!1;var[h,p]=I.parent(t,d);return!t.isVoid(h)||t.markableVoid(h)},o=oe.isExpanded(n),i=!1;if(!o){var[s,a]=I.node(t,n);if(s&&r(s,a)){var[l]=I.parent(t,a);i=l&&t.markableVoid(l)}}if(o||i)ce.unsetNodes(t,e,{match:r,split:!0,voids:!0});else{var c=kI({},I.marks(t)||{});delete c[e],t.marks=c,Xs.get(t)||t.onChange()}}},SI=(t,e)=>{j0.set(t,e)},EI=(t,e)=>I.point(t,e,{edge:"start"}),DI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:o=!1}=r,i=I.range(e,n),[s,a]=oe.edges(i),l="";for(var[c,u]of I.nodes(e,{at:i,match:Oe.isText,voids:o})){var d=c.text;U.equals(u,a.path)&&(d=d.slice(0,a.offset)),U.equals(u,s.path)&&(d=d.slice(s.offset)),l+=d}return l},AI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:o=!1}=r,[i,s]=oe.edges(n);if(i.offset!==0||s.offset!==0||oe.isCollapsed(n)||U.hasPrevious(s.path))return n;var a=I.above(e,{at:s,match:m=>Ae.isElement(m)&&I.isBlock(e,m),voids:o}),l=a?a[1]:[],c=I.start(e,i),u={anchor:c,focus:s},d=!0;for(var[h,p]of I.nodes(e,{at:u,match:Oe.isText,reverse:!0,voids:o})){if(d){d=!1;continue}if(h.text!==""||U.isBefore(p,l)){s={path:p,offset:h.text.length};break}}return{anchor:i,focus:s}},OI=(t,e)=>{var n=I.isNormalizing(t);I.setNormalizing(t,!1);try{e()}finally{I.setNormalizing(t,n)}I.normalize(t)},TI=(t,e,n)=>{var[r,o]=e;return Ae.isElement(r)&&I.isEmpty(t,r)||Oe.isText(r)&&r.text===""&&o[o.length-1]!==0},_I=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};I.withoutNormalizing(e,()=>{var r,o,{reverse:i=!1,unit:s="character",distance:a=1,voids:l=!1}=n,{at:c=e.selection,hanging:u=!1}=n;if(c){var d=!1;if(oe.isRange(c)&&oe.isCollapsed(c)&&(d=!0,c=c.anchor),Re.isPoint(c)){var h=I.void(e,{at:c,mode:"highest"});if(!l&&h){var[,p]=h;c=p}else{var m={unit:s,distance:a},w=i?I.before(e,c,m)||I.start(e,[]):I.after(e,c,m)||I.end(e,[]);c={anchor:c,focus:w},u=!0}}if(U.isPath(c)){ce.removeNodes(e,{at:c,voids:l});return}if(!oe.isCollapsed(c)){if(!u){var[,v]=oe.edges(c),y=I.end(e,[]);Re.equals(v,y)||(c=I.unhangRange(e,c,{voids:l}))}var[g,k]=oe.edges(c),A=I.above(e,{match:ie=>Ae.isElement(ie)&&I.isBlock(e,ie),at:g,voids:l}),C=I.above(e,{match:ie=>Ae.isElement(ie)&&I.isBlock(e,ie),at:k,voids:l}),E=A&&C&&!U.equals(A[1],C[1]),D=U.equals(g.path,k.path),S=l?null:(r=I.void(e,{at:g,mode:"highest"}))!==null&&r!==void 0?r:I.elementReadOnly(e,{at:g,mode:"highest"}),_=l?null:(o=I.void(e,{at:k,mode:"highest"}))!==null&&o!==void 0?o:I.elementReadOnly(e,{at:k,mode:"highest"});if(S){var O=I.before(e,g);O&&A&&U.isAncestor(A[1],O.path)&&(g=O)}if(_){var B=I.after(e,k);B&&C&&U.isAncestor(C[1],B.path)&&(k=B)}var N=[],F;for(var M of I.nodes(e,{at:c,voids:l})){var[T,P]=M;F&&U.compare(P,F)===0||(!l&&Ae.isElement(T)&&(I.isVoid(e,T)||I.isElementReadOnly(e,T))||!U.isCommon(P,g.path)&&!U.isCommon(P,k.path))&&(N.push(M),F=P)}var $=Array.from(N,ie=>{var[,he]=ie;return I.pathRef(e,he)}),W=I.pointRef(e,g),V=I.pointRef(e,k),X="";if(!D&&!S){var G=W.current,[te]=I.leaf(e,G),{path:H}=G,{offset:j}=g,Y=te.text.slice(j);Y.length>0&&(e.apply({type:"remove_text",path:H,offset:j,text:Y}),X=Y)}if($.reverse().map(ie=>ie.unref()).filter(ie=>ie!==null).forEach(ie=>ce.removeNodes(e,{at:ie,voids:l})),!_){var se=V.current,[Q]=I.leaf(e,se),{path:le}=se,L=D?g.offset:0,q=Q.text.slice(L,k.offset);q.length>0&&(e.apply({type:"remove_text",path:le,offset:L,text:q}),X=q)}!D&&E&&V.current&&W.current&&ce.mergeNodes(e,{at:V.current,hanging:!0,voids:l}),d&&i&&s==="character"&&X.length>1&&X.match(/[\u0980-\u09FF\u0E00-\u0E7F\u1000-\u109F\u0900-\u097F\u1780-\u17FF\u0D00-\u0D7F\u0B00-\u0B7F\u0A00-\u0A7F\u0B80-\u0BFF\u0C00-\u0C7F]+/)&&ce.insertText(e,X.slice(0,X.length-a));var J=W.unref(),K=V.unref(),re=i?J||K:K||J;n.at==null&&re&&ce.select(e,re)}}})},NI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};I.withoutNormalizing(e,()=>{var{hanging:o=!1,voids:i=!1}=r,{at:s=Of(e),batchDirty:a=!0}=r;if(n.length){if(oe.isRange(s))if(o||(s=I.unhangRange(e,s,{voids:i})),oe.isCollapsed(s))s=s.anchor;else{var[,l]=oe.edges(s);if(!i&&I.void(e,{at:l}))return;var c=I.pointRef(e,l);ce.delete(e,{at:s}),s=c.unref()}else U.isPath(s)&&(s=I.start(e,s));if(!(!i&&I.void(e,{at:s}))){var u=I.above(e,{at:s,match:H=>Ae.isElement(H)&&I.isInline(e,H),mode:"highest",voids:i});if(u){var[,d]=u;if(I.isEnd(e,s,d)){var h=I.after(e,d);s=h}else if(I.isStart(e,s,d)){var p=I.before(e,d);s=p}}var m=I.above(e,{match:H=>Ae.isElement(H)&&I.isBlock(e,H),at:s,voids:i}),[,w]=m,v=I.isStart(e,s,w),y=I.isEnd(e,s,w),g=v&&y,[,k]=ge.first({children:n},[]),[,A]=ge.last({children:n},[]),C=H=>{var[j,Y]=H,se=Y.length===0;return se?!1:g?!0:!(!v&&U.isAncestor(Y,k)&&Ae.isElement(j)&&!e.isVoid(j)&&!e.isInline(j)||!y&&U.isAncestor(Y,A)&&Ae.isElement(j)&&!e.isVoid(j)&&!e.isInline(j))},E=!0,D=[],S=[],_=[];for(var O of ge.nodes({children:n},{pass:C})){var[B,N]=O;E&&Ae.isElement(B)&&!e.isInline(B)&&!U.isAncestor(N,k)&&(E=!1),C(O)&&(Ae.isElement(B)&&!e.isInline(B)?(E=!1,S.push(B)):E?D.push(B):_.push(B))}var[F]=I.nodes(e,{at:s,match:H=>Oe.isText(H)||I.isInline(e,H),mode:"highest",voids:i}),[,M]=F,T=I.isStart(e,s,M),P=I.isEnd(e,s,M),$=I.pathRef(e,y&&!_.length?U.next(w):w),W=I.pathRef(e,P?U.next(M):M),V=_.length>0;ce.splitNodes(e,{at:s,match:H=>V?Ae.isElement(H)&&I.isBlock(e,H):Oe.isText(H)||I.isInline(e,H),mode:V?"lowest":"highest",always:V&&(!v||D.length>0)&&(!y||_.length>0),voids:i});var X=I.pathRef(e,!T||T&&P?U.next(M):M);if(ce.insertNodes(e,D,{at:X.current,match:H=>Oe.isText(H)||I.isInline(e,H),mode:"highest",voids:i,batchDirty:a}),g&&!D.length&&S.length&&!_.length&&ce.delete(e,{at:w,voids:i}),ce.insertNodes(e,S,{at:$.current,match:H=>Ae.isElement(H)&&I.isBlock(e,H),mode:"lowest",voids:i,batchDirty:a}),ce.insertNodes(e,_,{at:W.current,match:H=>Oe.isText(H)||I.isInline(e,H),mode:"highest",voids:i,batchDirty:a}),!r.at){var G;if(_.length>0&&W.current?G=U.previous(W.current):S.length>0&&$.current?G=U.previous($.current):X.current&&(G=U.previous(X.current)),G){var te=I.end(e,G);ce.select(e,te)}}X.unref(),$.unref(),W.unref()}}})},BI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{edge:r="anchor"}=n,{selection:o}=e;if(o){if(r==="anchor")ce.select(e,o.anchor);else if(r==="focus")ce.select(e,o.focus);else if(r==="start"){var[i]=oe.edges(o);ce.select(e,i)}else if(r==="end"){var[,s]=oe.edges(o);ce.select(e,s)}}else return},FI=t=>{var{selection:e}=t;e&&t.apply({type:"set_selection",properties:e,newProperties:null})},II=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{selection:r}=e,{distance:o=1,unit:i="character",reverse:s=!1}=n,{edge:a=null}=n;if(r){a==="start"&&(a=oe.isBackward(r)?"focus":"anchor"),a==="end"&&(a=oe.isBackward(r)?"anchor":"focus");var{anchor:l,focus:c}=r,u={distance:o,unit:i},d={};if(a==null||a==="anchor"){var h=s?I.before(e,l,u):I.after(e,l,u);h&&(d.anchor=h)}if(a==null||a==="focus"){var p=s?I.before(e,c,u):I.after(e,c,u);p&&(d.focus=p)}ce.setSelection(e,d)}},MI=(t,e)=>{var{selection:n}=t;if(e=I.range(t,e),n){ce.setSelection(t,e);return}if(!oe.isRange(e))throw new Error("When setting the selection and the current selection is `null` you must provide at least an `anchor` and `focus`, but you passed: ".concat($t.stringify(e)));t.apply({type:"set_selection",properties:n,newProperties:e})};function vy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function yy(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var PI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{selection:o}=e,{edge:i="both"}=r;if(o){i==="start"&&(i=oe.isBackward(o)?"focus":"anchor"),i==="end"&&(i=oe.isBackward(o)?"anchor":"focus");var{anchor:s,focus:a}=o,l=i==="anchor"?s:a;ce.setSelection(e,{[i==="anchor"?"anchor":"focus"]:yy(yy({},l),n)})}},LI=(t,e)=>{var{selection:n}=t,r={},o={};if(n){for(var i in e)(i==="anchor"&&e.anchor!=null&&!Re.equals(e.anchor,n.anchor)||i==="focus"&&e.focus!=null&&!Re.equals(e.focus,n.focus)||i!=="anchor"&&i!=="focus"&&e[i]!==n[i])&&(r[i]=n[i],o[i]=e[i]);Object.keys(r).length>0&&t.apply({type:"set_selection",properties:r,newProperties:o})}},$I=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};I.withoutNormalizing(e,()=>{var{hanging:o=!1,voids:i=!1,mode:s="lowest",batchDirty:a=!0}=r,{at:l,match:c,select:u}=r;if(ge.isNode(n)&&(n=[n]),n.length!==0){var[d]=n;if(l||(l=Of(e),u!==!1&&(u=!0)),u==null&&(u=!1),oe.isRange(l))if(o||(l=I.unhangRange(e,l,{voids:i})),oe.isCollapsed(l))l=l.anchor;else{var[,h]=oe.edges(l),p=I.pointRef(e,h);ce.delete(e,{at:l}),l=p.unref()}if(Re.isPoint(l)){c==null&&(Oe.isText(d)?c=O=>Oe.isText(O):e.isInline(d)?c=O=>Oe.isText(O)||I.isInline(e,O):c=O=>Ae.isElement(O)&&I.isBlock(e,O));var[m]=I.nodes(e,{at:l.path,match:c,mode:s,voids:i});if(m){var[,w]=m,v=I.pathRef(e,w),y=I.isEnd(e,l,w);ce.splitNodes(e,{at:l,match:c,mode:s,voids:i});var g=v.unref();l=y?U.next(g):g}else return}var k=U.parent(l),A=l[l.length-1];if(!(!i&&I.void(e,{at:k}))){if(a){var C=[],E=U.levels(k);bF(e,()=>{var O=function(){var F=k.concat(A);A++;var M={type:"insert_node",path:F,node:B};e.apply(M),l=U.next(l),C.push(M),Oe.isText(B)?E.push(F):E.push(...Array.from(ge.nodes(B),T=>{var[,P]=T;return F.concat(P)}))};for(var B of n)O()},()=>{iy(e,E,O=>{var B=O;for(var N of C)if(U.operationCanTransformPath(N)&&(B=U.transform(B,N),!B))return null;return B})})}else for(var D of n){var S=k.concat(A);A++,e.apply({type:"insert_node",path:S,node:D}),l=U.next(l)}if(l=U.previous(l),u){var _=I.end(e,l);_&&ce.select(e,_)}}}})},HI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};I.withoutNormalizing(e,()=>{var{at:r=e.selection,mode:o="lowest",voids:i=!1}=n,{match:s}=n;if(s==null&&(s=U.isPath(r)?$i(e,r):A=>Ae.isElement(A)&&I.isBlock(e,A)),!!r){var a=I.nodes(e,{at:r,match:s,mode:o,voids:i}),l=Array.from(a,A=>{var[,C]=A;return I.pathRef(e,C)});for(var c of l){var u=c.unref();if(u.length<2)throw new Error("Cannot lift node at a path [".concat(u,"] because it has a depth of less than `2`."));var d=I.node(e,U.parent(u)),[h,p]=d,m=u[u.length-1],{length:w}=h.children;if(w===1){var v=U.next(p);ce.moveNodes(e,{at:u,to:v,voids:i}),ce.removeNodes(e,{at:p,voids:i})}else if(m===0)ce.moveNodes(e,{at:u,to:p,voids:i});else if(m===w-1){var y=U.next(p);ce.moveNodes(e,{at:u,to:y,voids:i})}else{var g=U.next(u),k=U.next(p);ce.splitNodes(e,{at:g,voids:i}),ce.moveNodes(e,{at:u,to:k,voids:i})}}}})},zI=["text"],jI=["children"],by=(t,e)=>{if(Ae.isElement(e)){var n=e;return I.isVoid(t,e)?!0:n.children.length===1?by(t,n.children[0]):!1}else return!I.isEditor(e)},VI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};I.withoutNormalizing(e,()=>{var{match:r,at:o=e.selection}=n,{hanging:i=!1,voids:s=!1,mode:a="lowest"}=n;if(o){if(r==null)if(U.isPath(o)){var[l]=I.parent(e,o);r=O=>l.children.includes(O)}else r=O=>Ae.isElement(O)&&I.isBlock(e,O);if(!i&&oe.isRange(o)&&(o=I.unhangRange(e,o,{voids:s})),oe.isRange(o))if(oe.isCollapsed(o))o=o.anchor;else{var[,c]=oe.edges(o),u=I.pointRef(e,c);ce.delete(e,{at:o}),o=u.unref(),n.at==null&&ce.select(e,o)}var[d]=I.nodes(e,{at:o,match:r,voids:s,mode:a}),h=I.previous(e,{at:o,match:r,voids:s,mode:a});if(!(!d||!h)){var[p,m]=d,[w,v]=h;if(!(m.length===0||v.length===0)){var y=U.next(v),g=U.common(m,v),k=U.isSibling(m,v),A=Array.from(I.levels(e,{at:m}),O=>{var[B]=O;return B}).slice(g.length).slice(0,-1),C=I.above(e,{at:m,mode:"highest",match:O=>A.includes(O)&&by(e,O)}),E=C&&I.pathRef(e,C[1]),D,S;if(Oe.isText(p)&&Oe.isText(w)){var _=Kr(p,zI);S=w.text.length,D=_}else if(Ae.isElement(p)&&Ae.isElement(w)){var _=Kr(p,jI);S=w.children.length,D=_}else throw new Error("Cannot merge the node at path [".concat(m,"] with the previous sibling because it is not the same kind: ").concat($t.stringify(p)," ").concat($t.stringify(w)));k||ce.moveNodes(e,{at:m,to:y,voids:s}),E&&ce.removeNodes(e,{at:E.current,voids:s}),I.shouldMergeNodesRemovePrevNode(e,h,d)?ce.removeNodes(e,{at:v,voids:s}):e.apply({type:"merge_node",path:y,position:S,properties:D}),E&&E.unref()}}}})},WI=(t,e)=>{I.withoutNormalizing(t,()=>{var{to:n,at:r=t.selection,mode:o="lowest",voids:i=!1}=e,{match:s}=e;if(r){s==null&&(s=U.isPath(r)?$i(t,r):p=>Ae.isElement(p)&&I.isBlock(t,p));var a=I.pathRef(t,n),l=I.nodes(t,{at:r,match:s,mode:o,voids:i}),c=Array.from(l,p=>{var[,m]=p;return I.pathRef(t,m)});for(var u of c){var d=u.unref(),h=a.current;d.length!==0&&t.apply({type:"move_node",path:d,newPath:h}),a.current&&U.isSibling(h,d)&&U.isAfter(h,d)&&(a.current=U.next(a.current))}a.unref()}})},UI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};I.withoutNormalizing(e,()=>{var{hanging:r=!1,voids:o=!1,mode:i="lowest"}=n,{at:s=e.selection,match:a}=n;if(s){a==null&&(a=U.isPath(s)?$i(e,s):p=>Ae.isElement(p)&&I.isBlock(e,p)),!r&&oe.isRange(s)&&(s=I.unhangRange(e,s,{voids:o}));var l=I.nodes(e,{at:s,match:a,mode:i,voids:o}),c=Array.from(l,p=>{var[,m]=p;return I.pathRef(e,m)});for(var u of c){var d=u.unref();if(d){var[h]=I.node(e,d);e.apply({type:"remove_node",path:d,node:h})}}}})},qI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};I.withoutNormalizing(e,()=>{var{match:o,at:i=e.selection,compare:s,merge:a}=r,{hanging:l=!1,mode:c="lowest",split:u=!1,voids:d=!1}=r;if(i){if(o==null&&(o=U.isPath(i)?$i(e,i):S=>Ae.isElement(S)&&I.isBlock(e,S)),!l&&oe.isRange(i)&&(i=I.unhangRange(e,i,{voids:d})),u&&oe.isRange(i)){if(oe.isCollapsed(i)&&I.leaf(e,i.anchor)[0].text.length>0)return;var h=I.rangeRef(e,i,{affinity:"inward"}),[p,m]=oe.edges(i),w=c==="lowest"?"lowest":"highest",v=I.isEnd(e,m,m.path);ce.splitNodes(e,{at:m,match:o,mode:w,voids:d,always:!v});var y=I.isStart(e,p,p.path);ce.splitNodes(e,{at:p,match:o,mode:w,voids:d,always:!y}),i=h.unref(),r.at==null&&ce.select(e,i)}s||(s=(S,_)=>S!==_);for(var[g,k]of I.nodes(e,{at:i,match:o,mode:c,voids:d})){var A={},C={};if(k.length!==0){var E=!1;for(var D in n)D==="children"||D==="text"||s(n[D],g[D])&&(E=!0,g.hasOwnProperty(D)&&(A[D]=g[D]),a?n[D]!=null&&(C[D]=a(g[D],n[D])):n[D]!=null&&(C[D]=n[D]));E&&e.apply({type:"set_node",path:k,properties:A,newProperties:C})}}}})},GI=(t,e)=>{if(oe.isCollapsed(e))return e.anchor;var[,n]=oe.edges(e),r=I.pointRef(t,n);return ce.delete(t,{at:e}),r.unref()},KI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};I.withoutNormalizing(e,()=>{var{mode:r="lowest",voids:o=!1}=n,{match:i,at:s=e.selection,height:a=0,always:l=!1}=n;if(i==null&&(i=V=>Ae.isElement(V)&&I.isBlock(e,V)),oe.isRange(s)&&(s=GI(e,s)),U.isPath(s)){var c=s,u=I.point(e,c),[d]=I.parent(e,c);i=V=>V===d,a=u.path.length-c.length+1,s=u,l=!0}if(s){var h=I.pointRef(e,s,{affinity:"backward"}),p;try{var[m]=I.nodes(e,{at:s,match:i,mode:r,voids:o});if(!m)return;var w=I.void(e,{at:s,mode:"highest"}),v=0;if(!o&&w){var[y,g]=w;if(Ae.isElement(y)&&e.isInline(y)){var k=I.after(e,g);if(!k){var A={text:""},C=U.next(g);ce.insertNodes(e,A,{at:C,voids:o}),k=I.point(e,C)}s=k,l=!0}var E=s.path.length-g.length;a=E+1,l=!0}p=I.pointRef(e,s);var D=s.path.length-a,[,S]=m,_=s.path.slice(0,D),O=a===0?s.offset:s.path[D]+v;for(var[B,N]of I.levels(e,{at:_,reverse:!0,voids:o})){var F=!1;if(N.length<S.length||N.length===0||!o&&Ae.isElement(B)&&I.isVoid(e,B))break;var M=h.current,T=I.isEnd(e,M,N);if(l||!h||!I.isEdge(e,M,N)){F=!0;var P=ge.extractProps(B);e.apply({type:"split_node",path:N,position:O,properties:P})}O=N[N.length-1]+(F||T?1:0)}if(n.at==null){var $=p.current||I.end(e,[]);ce.select(e,$)}}finally{var W;h.unref(),(W=p)===null||W===void 0||W.unref()}}})},YI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Array.isArray(n)||(n=[n]);var o={};for(var i of n)o[i]=null;ce.setNodes(e,o,r)},XI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};I.withoutNormalizing(e,()=>{var{mode:r="lowest",split:o=!1,voids:i=!1}=n,{at:s=e.selection,match:a}=n;if(s){a==null&&(a=U.isPath(s)?$i(e,s):p=>Ae.isElement(p)&&I.isBlock(e,p)),U.isPath(s)&&(s=I.range(e,s));var l=oe.isRange(s)?I.rangeRef(e,s):null,c=I.nodes(e,{at:s,match:a,mode:r,voids:i}),u=Array.from(c,p=>{var[,m]=p;return I.pathRef(e,m)}).reverse(),d=function(){var m=h.unref(),[w]=I.node(e,m),v=I.range(e,m);o&&l&&(v=oe.intersection(l.current,v)),ce.liftNodes(e,{at:v,match:y=>Ae.isAncestor(w)&&w.children.includes(y),voids:i})};for(var h of u)d();l&&l.unref()}})};function Cy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function ky(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Cy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Cy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var JI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};I.withoutNormalizing(e,()=>{var{mode:o="lowest",split:i=!1,voids:s=!1}=r,{match:a,at:l=e.selection}=r;if(l){if(a==null&&(U.isPath(l)?a=$i(e,l):e.isInline(n)?a=y=>Ae.isElement(y)&&I.isInline(e,y)||Oe.isText(y):a=y=>Ae.isElement(y)&&I.isBlock(e,y)),i&&oe.isRange(l)){var[c,u]=oe.edges(l),d=I.rangeRef(e,l,{affinity:"inward"}),h=y=>{var g=I.above(e,{at:y,match:k=>Ae.isElement(k)&&I.isBlock(e,k)});return g&&I.isEdge(e,y,g[1])};ce.splitNodes(e,{at:u,match:a,voids:s,always:!h(u)}),ce.splitNodes(e,{at:c,match:a,voids:s,always:!h(c)}),l=d.unref(),r.at==null&&ce.select(e,l)}var p=Array.from(I.nodes(e,{at:l,match:e.isInline(n)?y=>Ae.isElement(y)&&I.isBlock(e,y):y=>I.isEditor(y),mode:"lowest",voids:s})),m=function(){var g=oe.isRange(l)?oe.intersection(l,I.range(e,v)):l;if(!g)return 0;var k=Array.from(I.nodes(e,{at:g,match:a,mode:o,voids:s}));if(k.length>0){var[A]=k,C=k[k.length-1],[,E]=A,[,D]=C;if(E.length===0&&D.length===0)return 0;var S=U.equals(E,D)?U.parent(E):U.common(E,D),_=I.range(e,E,D),O=I.node(e,S),[B]=O,N=S.length+1,F=U.next(D.slice(0,N)),M=ky(ky({},n),{},{children:[]});ce.insertNodes(e,M,{at:F,voids:s}),ce.moveNodes(e,{at:_,match:T=>Ae.isAncestor(B)&&B.children.includes(T),to:F.concat(0),voids:s})}},w;for(var[,v]of p)w=m()}})},xy=()=>{var t={children:[],operations:[],selection:null,marks:null,isElementReadOnly:()=>!1,isInline:()=>!1,isSelectable:()=>!0,isVoid:()=>!1,markableVoid:()=>!1,onChange:()=>{},apply:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return CF(t,...r)},addMark:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return AF(t,...r)},deleteBackward:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return _F(t,...r)},deleteForward:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return NF(t,...r)},deleteFragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return BF(t,...r)},getFragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return xF(t,...r)},insertBreak:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return WF(t,...r)},insertSoftBreak:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return qF(t,...r)},insertFragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return NI(t,...r)},insertNode:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return UF(t,...r)},insertText:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return KF(t,...r)},normalizeNode:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return SF(t,...r)},removeMark:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return xI(t,...r)},getDirtyPaths:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return kF(t,...r)},shouldNormalize:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return EF(t,...r)},above:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return DF(t,...r)},after:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return OF(t,...r)},before:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return TF(t,...r)},collapse:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return BI(t,...r)},delete:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return _I(t,...r)},deselect:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return FI(t,...r)},edges:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return FF(t,...r)},elementReadOnly:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return IF(t,...r)},end:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return MF(t,...r)},first:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return PF(t,...r)},fragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return LF(t,...r)},getMarks:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return iI(t,...r)},hasBlocks:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return HF(t,...r)},hasInlines:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return zF(t,...r)},hasPath:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return jF(t,...r)},hasTexts:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return VF(t,...r)},insertNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return $I(t,...r)},isBlock:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return YF(t,...r)},isEdge:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return XF(t,...r)},isEmpty:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return JF(t,...r)},isEnd:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return RF(t,...r)},isNormalizing:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return QF(t,...r)},isStart:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return ZF(t,...r)},last:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return eI(t,...r)},leaf:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return tI(t,...r)},levels:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return nI(t,...r)},liftNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return HI(t,...r)},mergeNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return VI(t,...r)},move:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return II(t,...r)},moveNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return WI(t,...r)},next:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return sI(t,...r)},node:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return aI(t,...r)},nodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return lI(t,...r)},normalize:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return cI(t,...r)},parent:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return uI(t,...r)},path:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return hI(t,...r)},pathRef:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return dI(t,...r)},pathRefs:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return fI(t,...r)},point:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return gI(t,...r)},pointRef:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return pI(t,...r)},pointRefs:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return mI(t,...r)},positions:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return wI(t,...r)},previous:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return vI(t,...r)},range:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return CI(t,...r)},rangeRef:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return yI(t,...r)},rangeRefs:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return bI(t,...r)},removeNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return UI(t,...r)},select:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return MI(t,...r)},setNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return qI(t,...r)},setNormalizing:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return SI(t,...r)},setPoint:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return PI(t,...r)},setSelection:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return LI(t,...r)},splitNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return KI(t,...r)},start:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return EI(t,...r)},string:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return DI(t,...r)},unhangRange:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return AI(t,...r)},unsetNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return YI(t,...r)},unwrapNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return XI(t,...r)},void:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return $F(t,...r)},withoutNormalizing:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return OI(t,...r)},wrapNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return JI(t,...r)},shouldMergeNodesRemovePrevNode:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return TI(t,...r)}};return t};/*!
|
|
12
|
+
`)}function Li(t){return t&&t.type==="variable-tag"}var NB={transform(t,e){var{current:n,affinity:r}=t;if(n!=null){var o=U.transform(n,e,{affinity:r});t.current=o,o==null&&t.unref()}}},BB={transform(t,e){var{current:n,affinity:r}=t;if(n!=null){var o=Re.transform(n,e,{affinity:r});t.current=o,o==null&&t.unref()}}},FB={transform(t,e){var{current:n,affinity:r}=t;if(n!=null){var o=oe.transform(n,e,{affinity:r});t.current=o,o==null&&t.unref()}}},ec=new WeakMap,tc=new WeakMap,Xs=new WeakMap,j0=new WeakMap,V0=new WeakMap,W0=new WeakMap,U0=new WeakMap,U={ancestors(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=e,r=U.levels(t,e);return n?r=r.slice(1):r=r.slice(0,-1),r},common(t,e){for(var n=[],r=0;r<t.length&&r<e.length;r++){var o=t[r],i=e[r];if(o!==i)break;n.push(o)}return n},compare(t,e){for(var n=Math.min(t.length,e.length),r=0;r<n;r++){if(t[r]<e[r])return-1;if(t[r]>e[r])return 1}return 0},endsAfter(t,e){var n=t.length-1,r=t.slice(0,n),o=e.slice(0,n),i=t[n],s=e[n];return U.equals(r,o)&&i>s},endsAt(t,e){var n=t.length,r=t.slice(0,n),o=e.slice(0,n);return U.equals(r,o)},endsBefore(t,e){var n=t.length-1,r=t.slice(0,n),o=e.slice(0,n),i=t[n],s=e[n];return U.equals(r,o)&&i<s},equals(t,e){return t.length===e.length&&t.every((n,r)=>n===e[r])},hasPrevious(t){return t[t.length-1]>0},isAfter(t,e){return U.compare(t,e)===1},isAncestor(t,e){return t.length<e.length&&U.compare(t,e)===0},isBefore(t,e){return U.compare(t,e)===-1},isChild(t,e){return t.length===e.length+1&&U.compare(t,e)===0},isCommon(t,e){return t.length<=e.length&&U.compare(t,e)===0},isDescendant(t,e){return t.length>e.length&&U.compare(t,e)===0},isParent(t,e){return t.length+1===e.length&&U.compare(t,e)===0},isPath(t){return Array.isArray(t)&&(t.length===0||typeof t[0]=="number")},isSibling(t,e){if(t.length!==e.length)return!1;var n=t.slice(0,-1),r=e.slice(0,-1),o=t[t.length-1],i=e[e.length-1];return o!==i&&U.equals(n,r)},levels(t){for(var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=e,r=[],o=0;o<=t.length;o++)r.push(t.slice(0,o));return n&&r.reverse(),r},next(t){if(t.length===0)throw new Error("Cannot get the next path of a root path [".concat(t,"], because it has no next index."));var e=t[t.length-1];return t.slice(0,-1).concat(e+1)},operationCanTransformPath(t){switch(t.type){case"insert_node":case"remove_node":case"merge_node":case"split_node":case"move_node":return!0;default:return!1}},parent(t){if(t.length===0)throw new Error("Cannot get the parent path of the root path [".concat(t,"]."));return t.slice(0,-1)},previous(t){if(t.length===0)throw new Error("Cannot get the previous path of a root path [".concat(t,"], because it has no previous index."));var e=t[t.length-1];if(e<=0)throw new Error("Cannot get the previous path of a first child path [".concat(t,"] because it would result in a negative index."));return t.slice(0,-1).concat(e-1)},relative(t,e){if(!U.isAncestor(e,t)&&!U.equals(t,e))throw new Error("Cannot get the relative path of [".concat(t,"] inside ancestor [").concat(e,"], because it is not above or equal to the path."));return t.slice(e.length)},transform(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(!t)return null;var r=[...t],{affinity:o="forward"}=n;if(t.length===0)return r;switch(e.type){case"insert_node":{var{path:i}=e;(U.equals(i,r)||U.endsBefore(i,r)||U.isAncestor(i,r))&&(r[i.length-1]+=1);break}case"remove_node":{var{path:s}=e;if(U.equals(s,r)||U.isAncestor(s,r))return null;U.endsBefore(s,r)&&(r[s.length-1]-=1);break}case"merge_node":{var{path:a,position:l}=e;U.equals(a,r)||U.endsBefore(a,r)?r[a.length-1]-=1:U.isAncestor(a,r)&&(r[a.length-1]-=1,r[a.length]+=l);break}case"split_node":{var{path:c,position:u}=e;if(U.equals(c,r)){if(o==="forward")r[r.length-1]+=1;else if(o!=="backward")return null}else U.endsBefore(c,r)?r[c.length-1]+=1:U.isAncestor(c,r)&&t[c.length]>=u&&(r[c.length-1]+=1,r[c.length]-=u);break}case"move_node":{var{path:d,newPath:h}=e;if(U.equals(d,h))return r;if(U.isAncestor(d,r)||U.equals(d,r)){var p=h.slice();return U.endsBefore(d,h)&&d.length<h.length&&(p[d.length-1]-=1),p.concat(r.slice(d.length))}else U.isSibling(d,h)&&(U.isAncestor(h,r)||U.equals(h,r))?U.endsBefore(d,r)?r[d.length-1]-=1:r[d.length-1]+=1:U.endsBefore(h,r)||U.equals(h,r)||U.isAncestor(h,r)?(U.endsBefore(d,r)&&(r[d.length-1]-=1),r[h.length-1]+=1):U.endsBefore(d,r)&&(U.equals(h,r)&&(r[h.length-1]+=1),r[d.length-1]-=1);break}}return r}};function Js(t){"@babel/helpers - typeof";return Js=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Js(t)}function IB(t,e){if(Js(t)!=="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(Js(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function MB(t){var e=IB(t,"string");return Js(e)==="symbol"?e:String(e)}function Yt(t,e,n){return e=MB(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}function PB(t,e){if(t==null)return{};var n={},r=Object.keys(t),o,i;for(i=0;i<r.length;i++)o=r[i],!(e.indexOf(o)>=0)&&(n[o]=t[o]);return n}function Kr(t,e){if(t==null)return{};var n=PB(t,e),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)r=i[o],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}var LB=["anchor","focus"];function q0(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function $B(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?q0(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):q0(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var oe={edges(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{reverse:n=!1}=e,{anchor:r,focus:o}=t;return oe.isBackward(t)===n?[r,o]:[o,r]},end(t){var[,e]=oe.edges(t);return e},equals(t,e){return Re.equals(t.anchor,e.anchor)&&Re.equals(t.focus,e.focus)},surrounds(t,e){var n=oe.intersection(t,e);return n?oe.equals(n,e):!1},includes(t,e){if(oe.isRange(e)){if(oe.includes(t,e.anchor)||oe.includes(t,e.focus))return!0;var[n,r]=oe.edges(t),[o,i]=oe.edges(e);return Re.isBefore(n,o)&&Re.isAfter(r,i)}var[s,a]=oe.edges(t),l=!1,c=!1;return Re.isPoint(e)?(l=Re.compare(e,s)>=0,c=Re.compare(e,a)<=0):(l=U.compare(e,s.path)>=0,c=U.compare(e,a.path)<=0),l&&c},intersection(t,e){var n=Kr(t,LB),[r,o]=oe.edges(t),[i,s]=oe.edges(e),a=Re.isBefore(r,i)?i:r,l=Re.isBefore(o,s)?o:s;return Re.isBefore(l,a)?null:$B({anchor:a,focus:l},n)},isBackward(t){var{anchor:e,focus:n}=t;return Re.isAfter(e,n)},isCollapsed(t){var{anchor:e,focus:n}=t;return Re.equals(e,n)},isExpanded(t){return!oe.isCollapsed(t)},isForward(t){return!oe.isBackward(t)},isRange(t){return nn(t)&&Re.isPoint(t.anchor)&&Re.isPoint(t.focus)},*points(t){yield[t.anchor,"anchor"],yield[t.focus,"focus"]},start(t){var[e]=oe.edges(t);return e},transform(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(t===null)return null;var{affinity:r="inward"}=n,o,i;if(r==="inward"){var s=oe.isCollapsed(t);oe.isForward(t)?(o="forward",i=s?o:"backward"):(o="backward",i=s?o:"forward")}else r==="outward"?oe.isForward(t)?(o="backward",i="forward"):(o="forward",i="backward"):(o=r,i=r);var a=Re.transform(t.anchor,e,{affinity:o}),l=Re.transform(t.focus,e,{affinity:i});return!a||!l?null:{anchor:a,focus:l}}},G0=function(e){var{deep:n=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!nn(e))return!1;var r=typeof e.apply=="function";if(r)return!1;var o=n?ge.isNodeList(e.children):Array.isArray(e.children);return o},Ae={isAncestor(t){var{deep:e=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return nn(t)&&ge.isNodeList(t.children,{deep:e})},isElement:G0,isElementList(t){var{deep:e=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Array.isArray(t)&&t.every(n=>Ae.isElement(n,{deep:e}))},isElementProps(t){return t.children!==void 0},isElementType:function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:"type";return G0(e)&&e[r]===n},matches(t,e){for(var n in e)if(n!=="children"&&t[n]!==e[n])return!1;return!0}},HB=["children"],zB=["text"];function K0(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function nc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?K0(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):K0(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var ge={ancestor(t,e){var n=ge.get(t,e);if(Oe.isText(n))throw new Error("Cannot get the ancestor node at path [".concat(e,"] because it refers to a text node instead: ").concat($t.stringify(n)));return n},ancestors(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var r of U.ancestors(e,n)){var o=ge.ancestor(t,r),i=[o,r];yield i}})()},child(t,e){if(Oe.isText(t))throw new Error("Cannot get the child of a text node: ".concat($t.stringify(t)));var n=t.children[e];if(n==null)throw new Error("Cannot get child at index `".concat(e,"` in node: ").concat($t.stringify(t)));return n},children(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var{reverse:r=!1}=n,o=ge.ancestor(t,e),{children:i}=o,s=r?i.length-1:0;r?s>=0:s<i.length;){var a=ge.child(o,s),l=e.concat(s);yield[a,l],s=r?s-1:s+1}})()},common(t,e,n){var r=U.common(e,n),o=ge.get(t,r);return[o,r]},descendant(t,e){var n=ge.get(t,e);if(I.isEditor(n))throw new Error("Cannot get the descendant node at path [".concat(e,"] because it refers to the root editor node instead: ").concat($t.stringify(n)));return n},descendants(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of ge.nodes(t,e))r.length!==0&&(yield[n,r])})()},elements(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of ge.nodes(t,e))Ae.isElement(n)&&(yield[n,r])})()},extractProps(t){if(Ae.isAncestor(t)){var e=Kr(t,HB);return e}else{var e=Kr(t,zB);return e}},first(t,e){for(var n=e.slice(),r=ge.get(t,n);r&&!(Oe.isText(r)||r.children.length===0);)r=r.children[0],n.push(0);return[r,n]},fragment(t,e){var n={children:t.children},[r,o]=oe.edges(e),i=ge.nodes(n,{reverse:!0,pass:l=>{var[,c]=l;return!oe.includes(e,c)}}),s=function(){if(!oe.includes(e,a)){var c=a[a.length-1];Ko(n,U.parent(a),u=>Nf(u,c,1))}U.equals(a,o.path)&&oc(n,a,u=>{var d=u.text.slice(0,o.offset);return nc(nc({},u),{},{text:d})}),U.equals(a,r.path)&&oc(n,a,u=>{var d=u.text.slice(r.offset);return nc(nc({},u),{},{text:d})})};for(var[,a]of i)s();return n.children},get(t,e){var n=ge.getIf(t,e);if(n===void 0)throw new Error("Cannot find a descendant at path [".concat(e,"] in node: ").concat($t.stringify(t)));return n},getIf(t,e){for(var n=t,r=0;r<e.length;r++){var o=e[r];if(Oe.isText(n)||!n.children[o])return;n=n.children[o]}return n},has(t,e){for(var n=t,r=0;r<e.length;r++){var o=e[r];if(Oe.isText(n)||!n.children[o])return!1;n=n.children[o]}return!0},isNode(t){var{deep:e=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Oe.isText(t)||Ae.isElement(t,{deep:e})||I.isEditor(t,{deep:e})},isNodeList(t){var{deep:e=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return Array.isArray(t)&&t.every(n=>ge.isNode(n,{deep:e}))},last(t,e){for(var n=e.slice(),r=ge.get(t,n);r&&!(Oe.isText(r)||r.children.length===0);){var o=r.children.length-1;r=r.children[o],n.push(o)}return[r,n]},leaf(t,e){var n=ge.get(t,e);if(!Oe.isText(n))throw new Error("Cannot get the leaf node at path [".concat(e,"] because it refers to a non-leaf node: ").concat($t.stringify(n)));return n},levels(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};return(function*(){for(var r of U.levels(e,n)){var o=ge.get(t,r);yield[o,r]}})()},matches(t,e){return Ae.isElement(t)&&Ae.isElementProps(e)&&Ae.matches(t,e)||Oe.isText(t)&&Oe.isTextProps(e)&&Oe.matches(t,e)},nodes(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var{pass:n,reverse:r=!1}=e,{from:o=[],to:i}=e,s=new Set,a=[],l=t;!(i&&(r?U.isBefore(a,i):U.isAfter(a,i)));){if(s.has(l)||(yield[l,a]),!s.has(l)&&!Oe.isText(l)&&l.children.length!==0&&(n==null||n([l,a])===!1)){s.add(l);var c=r?l.children.length-1:0;U.isAncestor(a,o)&&(c=o[a.length]),a=a.concat(c),l=ge.get(t,a);continue}if(a.length===0)break;if(!r){var u=U.next(a);if(ge.has(t,u)){a=u,l=ge.get(t,a);continue}}if(r&&a[a.length-1]!==0){var d=U.previous(a);a=d,l=ge.get(t,a);continue}a=U.parent(a),l=ge.get(t,a),s.add(l)}})()},parent(t,e){var n=U.parent(e),r=ge.get(t,n);if(Oe.isText(r))throw new Error("Cannot get the parent of path [".concat(e,"] because it does not exist in the root."));return r},string(t){return Oe.isText(t)?t.text:t.children.map(ge.string).join("")},texts(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){for(var[n,r]of ge.nodes(t,e))Oe.isText(n)&&(yield[n,r])})()}};function Y0(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function gt(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Y0(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Y0(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var uo={isNodeOperation(t){return uo.isOperation(t)&&t.type.endsWith("_node")},isOperation(t){if(!nn(t))return!1;switch(t.type){case"insert_node":return U.isPath(t.path)&&ge.isNode(t.node);case"insert_text":return typeof t.offset=="number"&&typeof t.text=="string"&&U.isPath(t.path);case"merge_node":return typeof t.position=="number"&&U.isPath(t.path)&&nn(t.properties);case"move_node":return U.isPath(t.path)&&U.isPath(t.newPath);case"remove_node":return U.isPath(t.path)&&ge.isNode(t.node);case"remove_text":return typeof t.offset=="number"&&typeof t.text=="string"&&U.isPath(t.path);case"set_node":return U.isPath(t.path)&&nn(t.properties)&&nn(t.newProperties);case"set_selection":return t.properties===null&&oe.isRange(t.newProperties)||t.newProperties===null&&oe.isRange(t.properties)||nn(t.properties)&&nn(t.newProperties);case"split_node":return U.isPath(t.path)&&typeof t.position=="number"&&nn(t.properties);default:return!1}},isOperationList(t){return Array.isArray(t)&&t.every(e=>uo.isOperation(e))},isSelectionOperation(t){return uo.isOperation(t)&&t.type.endsWith("_selection")},isTextOperation(t){return uo.isOperation(t)&&t.type.endsWith("_text")},inverse(t){switch(t.type){case"insert_node":return gt(gt({},t),{},{type:"remove_node"});case"insert_text":return gt(gt({},t),{},{type:"remove_text"});case"merge_node":return gt(gt({},t),{},{type:"split_node",path:U.previous(t.path)});case"move_node":{var{newPath:e,path:n}=t;if(U.equals(e,n))return t;if(U.isSibling(n,e))return gt(gt({},t),{},{path:e,newPath:n});var r=U.transform(n,t),o=U.transform(U.next(n),t);return gt(gt({},t),{},{path:r,newPath:o})}case"remove_node":return gt(gt({},t),{},{type:"insert_node"});case"remove_text":return gt(gt({},t),{},{type:"insert_text"});case"set_node":{var{properties:i,newProperties:s}=t;return gt(gt({},t),{},{properties:s,newProperties:i})}case"set_selection":{var{properties:a,newProperties:l}=t;return a==null?gt(gt({},t),{},{properties:l,newProperties:null}):l==null?gt(gt({},t),{},{properties:null,newProperties:a}):gt(gt({},t),{},{properties:l,newProperties:a})}case"split_node":return gt(gt({},t),{},{type:"merge_node",path:U.next(t.path)})}}},nn=t=>typeof t=="object"&&t!==null,X0=(t,e)=>{for(var n in t){var r=t[n],o=e[n];if(Array.isArray(r)&&Array.isArray(o)){if(r.length!==o.length)return!1;for(var i=0;i<r.length;i++)if(r[i]!==o[i])return!1}else if(nn(r)&&nn(o)){if(!X0(r,o))return!1}else if(r!==o)return!1}for(var s in e)if(t[s]===void 0&&e[s]!==void 0)return!1;return!0},Of=t=>t.selection?t.selection:t.children.length>0?I.end(t,[]):[0],$i=(t,e)=>{var[n]=I.node(t,e);return r=>r===n},Tf=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=!n,o=n?GB(e):e,i=$e.None,s=$e.None,a=0,l=null,c=null;for(var u of o){var d=u.codePointAt(0);if(!d)break;var h=oF(u,d);if([i,s]=r?[s,h]:[h,i],Hi(i,$e.ZWJ)&&Hi(s,$e.ExtPict)&&(r?l=J0(e.substring(0,a)):l=J0(e.substring(0,e.length-a)),!l)||Hi(i,$e.RI)&&Hi(s,$e.RI)&&(c!==null?c=!c:r?c=!0:c=cF(e.substring(0,e.length-a)),!c)||i!==$e.None&&s!==$e.None&&sF(i,s))break;a+=u.length}return a||1},jB=/\s/,VB=/[\u002B\u0021-\u0023\u0025-\u002A\u002C-\u002F\u003A\u003B\u003F\u0040\u005B-\u005D\u005F\u007B\u007D\u00A1\u00A7\u00AB\u00B6\u00B7\u00BB\u00BF\u037E\u0387\u055A-\u055F\u0589\u058A\u05BE\u05C0\u05C3\u05C6\u05F3\u05F4\u0609\u060A\u060C\u060D\u061B\u061E\u061F\u066A-\u066D\u06D4\u0700-\u070D\u07F7-\u07F9\u0830-\u083E\u085E\u0964\u0965\u0970\u0AF0\u0DF4\u0E4F\u0E5A\u0E5B\u0F04-\u0F12\u0F14\u0F3A-\u0F3D\u0F85\u0FD0-\u0FD4\u0FD9\u0FDA\u104A-\u104F\u10FB\u1360-\u1368\u1400\u166D\u166E\u169B\u169C\u16EB-\u16ED\u1735\u1736\u17D4-\u17D6\u17D8-\u17DA\u1800-\u180A\u1944\u1945\u1A1E\u1A1F\u1AA0-\u1AA6\u1AA8-\u1AAD\u1B5A-\u1B60\u1BFC-\u1BFF\u1C3B-\u1C3F\u1C7E\u1C7F\u1CC0-\u1CC7\u1CD3\u2010-\u2027\u2030-\u2043\u2045-\u2051\u2053-\u205E\u207D\u207E\u208D\u208E\u2329\u232A\u2768-\u2775\u27C5\u27C6\u27E6-\u27EF\u2983-\u2998\u29D8-\u29DB\u29FC\u29FD\u2CF9-\u2CFC\u2CFE\u2CFF\u2D70\u2E00-\u2E2E\u2E30-\u2E3B\u3001-\u3003\u3008-\u3011\u3014-\u301F\u3030\u303D\u30A0\u30FB\uA4FE\uA4FF\uA60D-\uA60F\uA673\uA67E\uA6F2-\uA6F7\uA874-\uA877\uA8CE\uA8CF\uA8F8-\uA8FA\uA92E\uA92F\uA95F\uA9C1-\uA9CD\uA9DE\uA9DF\uAA5C-\uAA5F\uAADE\uAADF\uAAF0\uAAF1\uABEB\uFD3E\uFD3F\uFE10-\uFE19\uFE30-\uFE52\uFE54-\uFE61\uFE63\uFE68\uFE6A\uFE6B\uFF01-\uFF03\uFF05-\uFF0A\uFF0C-\uFF0F\uFF1A\uFF1B\uFF1F\uFF20\uFF3B-\uFF3D\uFF3F\uFF5B\uFF5D\uFF5F-\uFF65]/,WB=/['\u2018\u2019]/,UB=function(e){for(var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1,r=0,o=!1;e.length>0;){var i=Tf(e,n),[s,a]=_f(e,i,n);if(qB(s,a,n))o=!0,r+=i;else if(!o)r+=i;else break;e=a}return r},_f=(t,e,n)=>{if(n){var r=t.length-e;return[t.slice(r,t.length),t.slice(0,r)]}return[t.slice(0,e),t.slice(e)]},qB=function t(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:!1;if(jB.test(e))return!1;if(WB.test(e)){var o=Tf(n,r),[i,s]=_f(n,o,r);if(t(i,s,r))return!0}return!VB.test(e)},GB=function*(e){for(var n=e.length-1,r=0;r<e.length;r++){var o=e.charAt(n-r);if(YB(o.charCodeAt(0))){var i=e.charAt(n-r-1);if(KB(i.charCodeAt(0))){yield i+o,r++;continue}}yield o}},KB=t=>t>=55296&&t<=56319,YB=t=>t>=56320&&t<=57343,$e;(function(t){t[t.None=0]="None",t[t.Extend=1]="Extend",t[t.ZWJ=2]="ZWJ",t[t.RI=4]="RI",t[t.Prepend=8]="Prepend",t[t.SpacingMark=16]="SpacingMark",t[t.L=32]="L",t[t.V=64]="V",t[t.T=128]="T",t[t.LV=256]="LV",t[t.LVT=512]="LVT",t[t.ExtPict=1024]="ExtPict",t[t.Any=2048]="Any"})($e||($e={}));var XB=/^(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC2\u0CC6\u0CCC\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732\u1733\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B03\u1B34-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200C\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDEFD-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34\uDE36\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF57\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB5\uDEB7\uDF1D-\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B\uDD3C\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40\uDF42]|\uD80D[\uDC40\uDC47-\uDC55]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65\uDD67-\uDD69\uDD6E-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF])$/,JB=/^(?:[\u0600-\u0605\u06DD\u070F\u0890\u0891\u08E2\u0D4E]|\uD804[\uDCBD\uDCCD\uDDC2\uDDC3]|\uD806[\uDD3F\uDD41\uDE3A\uDE84-\uDE89]|\uD807\uDD46)$/,RB=/^(?:[\u0903\u093B\u093E-\u0940\u0949-\u094C\u094E\u094F\u0982\u0983\u09BF\u09C0\u09C7\u09C8\u09CB\u09CC\u0A03\u0A3E-\u0A40\u0A83\u0ABE-\u0AC0\u0AC9\u0ACB\u0ACC\u0B02\u0B03\u0B40\u0B47\u0B48\u0B4B\u0B4C\u0BBF\u0BC1\u0BC2\u0BC6-\u0BC8\u0BCA-\u0BCC\u0C01-\u0C03\u0C41-\u0C44\u0C82\u0C83\u0CBE\u0CC0\u0CC1\u0CC3\u0CC4\u0CC7\u0CC8\u0CCA\u0CCB\u0D02\u0D03\u0D3F\u0D40\u0D46-\u0D48\u0D4A-\u0D4C\u0D82\u0D83\u0DD0\u0DD1\u0DD8-\u0DDE\u0DF2\u0DF3\u0E33\u0EB3\u0F3E\u0F3F\u0F7F\u1031\u103B\u103C\u1056\u1057\u1084\u1715\u1734\u17B6\u17BE-\u17C5\u17C7\u17C8\u1923-\u1926\u1929-\u192B\u1930\u1931\u1933-\u1938\u1A19\u1A1A\u1A55\u1A57\u1A6D-\u1A72\u1B04\u1B3B\u1B3D-\u1B41\u1B43\u1B44\u1B82\u1BA1\u1BA6\u1BA7\u1BAA\u1BE7\u1BEA-\u1BEC\u1BEE\u1BF2\u1BF3\u1C24-\u1C2B\u1C34\u1C35\u1CE1\u1CF7\uA823\uA824\uA827\uA880\uA881\uA8B4-\uA8C3\uA952\uA953\uA983\uA9B4\uA9B5\uA9BA\uA9BB\uA9BE-\uA9C0\uAA2F\uAA30\uAA33\uAA34\uAA4D\uAAEB\uAAEE\uAAEF\uAAF5\uABE3\uABE4\uABE6\uABE7\uABE9\uABEA\uABEC]|\uD804[\uDC00\uDC02\uDC82\uDCB0-\uDCB2\uDCB7\uDCB8\uDD2C\uDD45\uDD46\uDD82\uDDB3-\uDDB5\uDDBF\uDDC0\uDDCE\uDE2C-\uDE2E\uDE32\uDE33\uDE35\uDEE0-\uDEE2\uDF02\uDF03\uDF3F\uDF41-\uDF44\uDF47\uDF48\uDF4B-\uDF4D\uDF62\uDF63]|\uD805[\uDC35-\uDC37\uDC40\uDC41\uDC45\uDCB1\uDCB2\uDCB9\uDCBB\uDCBC\uDCBE\uDCC1\uDDB0\uDDB1\uDDB8-\uDDBB\uDDBE\uDE30-\uDE32\uDE3B\uDE3C\uDE3E\uDEAC\uDEAE\uDEAF\uDEB6\uDF26]|\uD806[\uDC2C-\uDC2E\uDC38\uDD31-\uDD35\uDD37\uDD38\uDD3D\uDD40\uDD42\uDDD1-\uDDD3\uDDDC-\uDDDF\uDDE4\uDE39\uDE57\uDE58\uDE97]|\uD807[\uDC2F\uDC3E\uDCA9\uDCB1\uDCB4\uDD8A-\uDD8E\uDD93\uDD94\uDD96\uDEF5\uDEF6]|\uD81B[\uDF51-\uDF87\uDFF0\uDFF1]|\uD834[\uDD66\uDD6D])$/,QB=/^[\u1100-\u115F\uA960-\uA97C]$/,ZB=/^[\u1160-\u11A7\uD7B0-\uD7C6]$/,eF=/^[\u11A8-\u11FF\uD7CB-\uD7FB]$/,tF=/^[\uAC00\uAC1C\uAC38\uAC54\uAC70\uAC8C\uACA8\uACC4\uACE0\uACFC\uAD18\uAD34\uAD50\uAD6C\uAD88\uADA4\uADC0\uADDC\uADF8\uAE14\uAE30\uAE4C\uAE68\uAE84\uAEA0\uAEBC\uAED8\uAEF4\uAF10\uAF2C\uAF48\uAF64\uAF80\uAF9C\uAFB8\uAFD4\uAFF0\uB00C\uB028\uB044\uB060\uB07C\uB098\uB0B4\uB0D0\uB0EC\uB108\uB124\uB140\uB15C\uB178\uB194\uB1B0\uB1CC\uB1E8\uB204\uB220\uB23C\uB258\uB274\uB290\uB2AC\uB2C8\uB2E4\uB300\uB31C\uB338\uB354\uB370\uB38C\uB3A8\uB3C4\uB3E0\uB3FC\uB418\uB434\uB450\uB46C\uB488\uB4A4\uB4C0\uB4DC\uB4F8\uB514\uB530\uB54C\uB568\uB584\uB5A0\uB5BC\uB5D8\uB5F4\uB610\uB62C\uB648\uB664\uB680\uB69C\uB6B8\uB6D4\uB6F0\uB70C\uB728\uB744\uB760\uB77C\uB798\uB7B4\uB7D0\uB7EC\uB808\uB824\uB840\uB85C\uB878\uB894\uB8B0\uB8CC\uB8E8\uB904\uB920\uB93C\uB958\uB974\uB990\uB9AC\uB9C8\uB9E4\uBA00\uBA1C\uBA38\uBA54\uBA70\uBA8C\uBAA8\uBAC4\uBAE0\uBAFC\uBB18\uBB34\uBB50\uBB6C\uBB88\uBBA4\uBBC0\uBBDC\uBBF8\uBC14\uBC30\uBC4C\uBC68\uBC84\uBCA0\uBCBC\uBCD8\uBCF4\uBD10\uBD2C\uBD48\uBD64\uBD80\uBD9C\uBDB8\uBDD4\uBDF0\uBE0C\uBE28\uBE44\uBE60\uBE7C\uBE98\uBEB4\uBED0\uBEEC\uBF08\uBF24\uBF40\uBF5C\uBF78\uBF94\uBFB0\uBFCC\uBFE8\uC004\uC020\uC03C\uC058\uC074\uC090\uC0AC\uC0C8\uC0E4\uC100\uC11C\uC138\uC154\uC170\uC18C\uC1A8\uC1C4\uC1E0\uC1FC\uC218\uC234\uC250\uC26C\uC288\uC2A4\uC2C0\uC2DC\uC2F8\uC314\uC330\uC34C\uC368\uC384\uC3A0\uC3BC\uC3D8\uC3F4\uC410\uC42C\uC448\uC464\uC480\uC49C\uC4B8\uC4D4\uC4F0\uC50C\uC528\uC544\uC560\uC57C\uC598\uC5B4\uC5D0\uC5EC\uC608\uC624\uC640\uC65C\uC678\uC694\uC6B0\uC6CC\uC6E8\uC704\uC720\uC73C\uC758\uC774\uC790\uC7AC\uC7C8\uC7E4\uC800\uC81C\uC838\uC854\uC870\uC88C\uC8A8\uC8C4\uC8E0\uC8FC\uC918\uC934\uC950\uC96C\uC988\uC9A4\uC9C0\uC9DC\uC9F8\uCA14\uCA30\uCA4C\uCA68\uCA84\uCAA0\uCABC\uCAD8\uCAF4\uCB10\uCB2C\uCB48\uCB64\uCB80\uCB9C\uCBB8\uCBD4\uCBF0\uCC0C\uCC28\uCC44\uCC60\uCC7C\uCC98\uCCB4\uCCD0\uCCEC\uCD08\uCD24\uCD40\uCD5C\uCD78\uCD94\uCDB0\uCDCC\uCDE8\uCE04\uCE20\uCE3C\uCE58\uCE74\uCE90\uCEAC\uCEC8\uCEE4\uCF00\uCF1C\uCF38\uCF54\uCF70\uCF8C\uCFA8\uCFC4\uCFE0\uCFFC\uD018\uD034\uD050\uD06C\uD088\uD0A4\uD0C0\uD0DC\uD0F8\uD114\uD130\uD14C\uD168\uD184\uD1A0\uD1BC\uD1D8\uD1F4\uD210\uD22C\uD248\uD264\uD280\uD29C\uD2B8\uD2D4\uD2F0\uD30C\uD328\uD344\uD360\uD37C\uD398\uD3B4\uD3D0\uD3EC\uD408\uD424\uD440\uD45C\uD478\uD494\uD4B0\uD4CC\uD4E8\uD504\uD520\uD53C\uD558\uD574\uD590\uD5AC\uD5C8\uD5E4\uD600\uD61C\uD638\uD654\uD670\uD68C\uD6A8\uD6C4\uD6E0\uD6FC\uD718\uD734\uD750\uD76C\uD788]$/,nF=/^[\uAC01-\uAC1B\uAC1D-\uAC37\uAC39-\uAC53\uAC55-\uAC6F\uAC71-\uAC8B\uAC8D-\uACA7\uACA9-\uACC3\uACC5-\uACDF\uACE1-\uACFB\uACFD-\uAD17\uAD19-\uAD33\uAD35-\uAD4F\uAD51-\uAD6B\uAD6D-\uAD87\uAD89-\uADA3\uADA5-\uADBF\uADC1-\uADDB\uADDD-\uADF7\uADF9-\uAE13\uAE15-\uAE2F\uAE31-\uAE4B\uAE4D-\uAE67\uAE69-\uAE83\uAE85-\uAE9F\uAEA1-\uAEBB\uAEBD-\uAED7\uAED9-\uAEF3\uAEF5-\uAF0F\uAF11-\uAF2B\uAF2D-\uAF47\uAF49-\uAF63\uAF65-\uAF7F\uAF81-\uAF9B\uAF9D-\uAFB7\uAFB9-\uAFD3\uAFD5-\uAFEF\uAFF1-\uB00B\uB00D-\uB027\uB029-\uB043\uB045-\uB05F\uB061-\uB07B\uB07D-\uB097\uB099-\uB0B3\uB0B5-\uB0CF\uB0D1-\uB0EB\uB0ED-\uB107\uB109-\uB123\uB125-\uB13F\uB141-\uB15B\uB15D-\uB177\uB179-\uB193\uB195-\uB1AF\uB1B1-\uB1CB\uB1CD-\uB1E7\uB1E9-\uB203\uB205-\uB21F\uB221-\uB23B\uB23D-\uB257\uB259-\uB273\uB275-\uB28F\uB291-\uB2AB\uB2AD-\uB2C7\uB2C9-\uB2E3\uB2E5-\uB2FF\uB301-\uB31B\uB31D-\uB337\uB339-\uB353\uB355-\uB36F\uB371-\uB38B\uB38D-\uB3A7\uB3A9-\uB3C3\uB3C5-\uB3DF\uB3E1-\uB3FB\uB3FD-\uB417\uB419-\uB433\uB435-\uB44F\uB451-\uB46B\uB46D-\uB487\uB489-\uB4A3\uB4A5-\uB4BF\uB4C1-\uB4DB\uB4DD-\uB4F7\uB4F9-\uB513\uB515-\uB52F\uB531-\uB54B\uB54D-\uB567\uB569-\uB583\uB585-\uB59F\uB5A1-\uB5BB\uB5BD-\uB5D7\uB5D9-\uB5F3\uB5F5-\uB60F\uB611-\uB62B\uB62D-\uB647\uB649-\uB663\uB665-\uB67F\uB681-\uB69B\uB69D-\uB6B7\uB6B9-\uB6D3\uB6D5-\uB6EF\uB6F1-\uB70B\uB70D-\uB727\uB729-\uB743\uB745-\uB75F\uB761-\uB77B\uB77D-\uB797\uB799-\uB7B3\uB7B5-\uB7CF\uB7D1-\uB7EB\uB7ED-\uB807\uB809-\uB823\uB825-\uB83F\uB841-\uB85B\uB85D-\uB877\uB879-\uB893\uB895-\uB8AF\uB8B1-\uB8CB\uB8CD-\uB8E7\uB8E9-\uB903\uB905-\uB91F\uB921-\uB93B\uB93D-\uB957\uB959-\uB973\uB975-\uB98F\uB991-\uB9AB\uB9AD-\uB9C7\uB9C9-\uB9E3\uB9E5-\uB9FF\uBA01-\uBA1B\uBA1D-\uBA37\uBA39-\uBA53\uBA55-\uBA6F\uBA71-\uBA8B\uBA8D-\uBAA7\uBAA9-\uBAC3\uBAC5-\uBADF\uBAE1-\uBAFB\uBAFD-\uBB17\uBB19-\uBB33\uBB35-\uBB4F\uBB51-\uBB6B\uBB6D-\uBB87\uBB89-\uBBA3\uBBA5-\uBBBF\uBBC1-\uBBDB\uBBDD-\uBBF7\uBBF9-\uBC13\uBC15-\uBC2F\uBC31-\uBC4B\uBC4D-\uBC67\uBC69-\uBC83\uBC85-\uBC9F\uBCA1-\uBCBB\uBCBD-\uBCD7\uBCD9-\uBCF3\uBCF5-\uBD0F\uBD11-\uBD2B\uBD2D-\uBD47\uBD49-\uBD63\uBD65-\uBD7F\uBD81-\uBD9B\uBD9D-\uBDB7\uBDB9-\uBDD3\uBDD5-\uBDEF\uBDF1-\uBE0B\uBE0D-\uBE27\uBE29-\uBE43\uBE45-\uBE5F\uBE61-\uBE7B\uBE7D-\uBE97\uBE99-\uBEB3\uBEB5-\uBECF\uBED1-\uBEEB\uBEED-\uBF07\uBF09-\uBF23\uBF25-\uBF3F\uBF41-\uBF5B\uBF5D-\uBF77\uBF79-\uBF93\uBF95-\uBFAF\uBFB1-\uBFCB\uBFCD-\uBFE7\uBFE9-\uC003\uC005-\uC01F\uC021-\uC03B\uC03D-\uC057\uC059-\uC073\uC075-\uC08F\uC091-\uC0AB\uC0AD-\uC0C7\uC0C9-\uC0E3\uC0E5-\uC0FF\uC101-\uC11B\uC11D-\uC137\uC139-\uC153\uC155-\uC16F\uC171-\uC18B\uC18D-\uC1A7\uC1A9-\uC1C3\uC1C5-\uC1DF\uC1E1-\uC1FB\uC1FD-\uC217\uC219-\uC233\uC235-\uC24F\uC251-\uC26B\uC26D-\uC287\uC289-\uC2A3\uC2A5-\uC2BF\uC2C1-\uC2DB\uC2DD-\uC2F7\uC2F9-\uC313\uC315-\uC32F\uC331-\uC34B\uC34D-\uC367\uC369-\uC383\uC385-\uC39F\uC3A1-\uC3BB\uC3BD-\uC3D7\uC3D9-\uC3F3\uC3F5-\uC40F\uC411-\uC42B\uC42D-\uC447\uC449-\uC463\uC465-\uC47F\uC481-\uC49B\uC49D-\uC4B7\uC4B9-\uC4D3\uC4D5-\uC4EF\uC4F1-\uC50B\uC50D-\uC527\uC529-\uC543\uC545-\uC55F\uC561-\uC57B\uC57D-\uC597\uC599-\uC5B3\uC5B5-\uC5CF\uC5D1-\uC5EB\uC5ED-\uC607\uC609-\uC623\uC625-\uC63F\uC641-\uC65B\uC65D-\uC677\uC679-\uC693\uC695-\uC6AF\uC6B1-\uC6CB\uC6CD-\uC6E7\uC6E9-\uC703\uC705-\uC71F\uC721-\uC73B\uC73D-\uC757\uC759-\uC773\uC775-\uC78F\uC791-\uC7AB\uC7AD-\uC7C7\uC7C9-\uC7E3\uC7E5-\uC7FF\uC801-\uC81B\uC81D-\uC837\uC839-\uC853\uC855-\uC86F\uC871-\uC88B\uC88D-\uC8A7\uC8A9-\uC8C3\uC8C5-\uC8DF\uC8E1-\uC8FB\uC8FD-\uC917\uC919-\uC933\uC935-\uC94F\uC951-\uC96B\uC96D-\uC987\uC989-\uC9A3\uC9A5-\uC9BF\uC9C1-\uC9DB\uC9DD-\uC9F7\uC9F9-\uCA13\uCA15-\uCA2F\uCA31-\uCA4B\uCA4D-\uCA67\uCA69-\uCA83\uCA85-\uCA9F\uCAA1-\uCABB\uCABD-\uCAD7\uCAD9-\uCAF3\uCAF5-\uCB0F\uCB11-\uCB2B\uCB2D-\uCB47\uCB49-\uCB63\uCB65-\uCB7F\uCB81-\uCB9B\uCB9D-\uCBB7\uCBB9-\uCBD3\uCBD5-\uCBEF\uCBF1-\uCC0B\uCC0D-\uCC27\uCC29-\uCC43\uCC45-\uCC5F\uCC61-\uCC7B\uCC7D-\uCC97\uCC99-\uCCB3\uCCB5-\uCCCF\uCCD1-\uCCEB\uCCED-\uCD07\uCD09-\uCD23\uCD25-\uCD3F\uCD41-\uCD5B\uCD5D-\uCD77\uCD79-\uCD93\uCD95-\uCDAF\uCDB1-\uCDCB\uCDCD-\uCDE7\uCDE9-\uCE03\uCE05-\uCE1F\uCE21-\uCE3B\uCE3D-\uCE57\uCE59-\uCE73\uCE75-\uCE8F\uCE91-\uCEAB\uCEAD-\uCEC7\uCEC9-\uCEE3\uCEE5-\uCEFF\uCF01-\uCF1B\uCF1D-\uCF37\uCF39-\uCF53\uCF55-\uCF6F\uCF71-\uCF8B\uCF8D-\uCFA7\uCFA9-\uCFC3\uCFC5-\uCFDF\uCFE1-\uCFFB\uCFFD-\uD017\uD019-\uD033\uD035-\uD04F\uD051-\uD06B\uD06D-\uD087\uD089-\uD0A3\uD0A5-\uD0BF\uD0C1-\uD0DB\uD0DD-\uD0F7\uD0F9-\uD113\uD115-\uD12F\uD131-\uD14B\uD14D-\uD167\uD169-\uD183\uD185-\uD19F\uD1A1-\uD1BB\uD1BD-\uD1D7\uD1D9-\uD1F3\uD1F5-\uD20F\uD211-\uD22B\uD22D-\uD247\uD249-\uD263\uD265-\uD27F\uD281-\uD29B\uD29D-\uD2B7\uD2B9-\uD2D3\uD2D5-\uD2EF\uD2F1-\uD30B\uD30D-\uD327\uD329-\uD343\uD345-\uD35F\uD361-\uD37B\uD37D-\uD397\uD399-\uD3B3\uD3B5-\uD3CF\uD3D1-\uD3EB\uD3ED-\uD407\uD409-\uD423\uD425-\uD43F\uD441-\uD45B\uD45D-\uD477\uD479-\uD493\uD495-\uD4AF\uD4B1-\uD4CB\uD4CD-\uD4E7\uD4E9-\uD503\uD505-\uD51F\uD521-\uD53B\uD53D-\uD557\uD559-\uD573\uD575-\uD58F\uD591-\uD5AB\uD5AD-\uD5C7\uD5C9-\uD5E3\uD5E5-\uD5FF\uD601-\uD61B\uD61D-\uD637\uD639-\uD653\uD655-\uD66F\uD671-\uD68B\uD68D-\uD6A7\uD6A9-\uD6C3\uD6C5-\uD6DF\uD6E1-\uD6FB\uD6FD-\uD717\uD719-\uD733\uD735-\uD74F\uD751-\uD76B\uD76D-\uD787\uD789-\uD7A3]$/,rF=/^(?:[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u2388\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2605\u2607-\u2612\u2614-\u2685\u2690-\u2705\u2708-\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763-\u2767\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDD0F\uDD2F\uDD6C-\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDAD-\uDDE5\uDE01-\uDE0F\uDE1A\uDE2F\uDE32-\uDE3A\uDE3C-\uDE3F\uDE49-\uDFFA]|\uD83D[\uDC00-\uDD3D\uDD46-\uDE4F\uDE80-\uDEFF\uDF74-\uDF7F\uDFD5-\uDFFF]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE-\uDCFF\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDEFF]|\uD83F[\uDC00-\uDFFD])$/,oF=(t,e)=>{var n=$e.Any;return t.search(XB)!==-1&&(n|=$e.Extend),e===8205&&(n|=$e.ZWJ),e>=127462&&e<=127487&&(n|=$e.RI),t.search(JB)!==-1&&(n|=$e.Prepend),t.search(RB)!==-1&&(n|=$e.SpacingMark),t.search(QB)!==-1&&(n|=$e.L),t.search(ZB)!==-1&&(n|=$e.V),t.search(eF)!==-1&&(n|=$e.T),t.search(tF)!==-1&&(n|=$e.LV),t.search(nF)!==-1&&(n|=$e.LVT),t.search(rF)!==-1&&(n|=$e.ExtPict),n};function Hi(t,e){return(t&e)!==0}var iF=[[$e.L,$e.L|$e.V|$e.LV|$e.LVT],[$e.LV|$e.V,$e.V|$e.T],[$e.LVT|$e.T,$e.T],[$e.Any,$e.Extend|$e.ZWJ],[$e.Any,$e.SpacingMark],[$e.Prepend,$e.Any],[$e.ZWJ,$e.ExtPict],[$e.RI,$e.RI]];function sF(t,e){return iF.findIndex(n=>Hi(t,n[0])&&Hi(e,n[1]))===-1}var aF=/(?:[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u2388\u23CF\u23E9-\u23F3\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB-\u25FE\u2600-\u2605\u2607-\u2612\u2614-\u2685\u2690-\u2705\u2708-\u2712\u2714\u2716\u271D\u2721\u2728\u2733\u2734\u2744\u2747\u274C\u274E\u2753-\u2755\u2757\u2763-\u2767\u2795-\u2797\u27A1\u27B0\u27BF\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B50\u2B55\u3030\u303D\u3297\u3299]|\uD83C[\uDC00-\uDCFF\uDD0D-\uDD0F\uDD2F\uDD6C-\uDD71\uDD7E\uDD7F\uDD8E\uDD91-\uDD9A\uDDAD-\uDDE5\uDE01-\uDE0F\uDE1A\uDE2F\uDE32-\uDE3A\uDE3C-\uDE3F\uDE49-\uDFFA]|\uD83D[\uDC00-\uDD3D\uDD46-\uDE4F\uDE80-\uDEFF\uDF74-\uDF7F\uDFD5-\uDFFF]|\uD83E[\uDC0C-\uDC0F\uDC48-\uDC4F\uDC5A-\uDC5F\uDC88-\uDC8F\uDCAE-\uDCFF\uDD0C-\uDD3A\uDD3C-\uDD45\uDD47-\uDEFF]|\uD83F[\uDC00-\uDFFD])(?:[\u0300-\u036F\u0483-\u0489\u0591-\u05BD\u05BF\u05C1\u05C2\u05C4\u05C5\u05C7\u0610-\u061A\u064B-\u065F\u0670\u06D6-\u06DC\u06DF-\u06E4\u06E7\u06E8\u06EA-\u06ED\u0711\u0730-\u074A\u07A6-\u07B0\u07EB-\u07F3\u07FD\u0816-\u0819\u081B-\u0823\u0825-\u0827\u0829-\u082D\u0859-\u085B\u0898-\u089F\u08CA-\u08E1\u08E3-\u0902\u093A\u093C\u0941-\u0948\u094D\u0951-\u0957\u0962\u0963\u0981\u09BC\u09BE\u09C1-\u09C4\u09CD\u09D7\u09E2\u09E3\u09FE\u0A01\u0A02\u0A3C\u0A41\u0A42\u0A47\u0A48\u0A4B-\u0A4D\u0A51\u0A70\u0A71\u0A75\u0A81\u0A82\u0ABC\u0AC1-\u0AC5\u0AC7\u0AC8\u0ACD\u0AE2\u0AE3\u0AFA-\u0AFF\u0B01\u0B3C\u0B3E\u0B3F\u0B41-\u0B44\u0B4D\u0B55-\u0B57\u0B62\u0B63\u0B82\u0BBE\u0BC0\u0BCD\u0BD7\u0C00\u0C04\u0C3C\u0C3E-\u0C40\u0C46-\u0C48\u0C4A-\u0C4D\u0C55\u0C56\u0C62\u0C63\u0C81\u0CBC\u0CBF\u0CC2\u0CC6\u0CCC\u0CCD\u0CD5\u0CD6\u0CE2\u0CE3\u0D00\u0D01\u0D3B\u0D3C\u0D3E\u0D41-\u0D44\u0D4D\u0D57\u0D62\u0D63\u0D81\u0DCA\u0DCF\u0DD2-\u0DD4\u0DD6\u0DDF\u0E31\u0E34-\u0E3A\u0E47-\u0E4E\u0EB1\u0EB4-\u0EBC\u0EC8-\u0ECE\u0F18\u0F19\u0F35\u0F37\u0F39\u0F71-\u0F7E\u0F80-\u0F84\u0F86\u0F87\u0F8D-\u0F97\u0F99-\u0FBC\u0FC6\u102D-\u1030\u1032-\u1037\u1039\u103A\u103D\u103E\u1058\u1059\u105E-\u1060\u1071-\u1074\u1082\u1085\u1086\u108D\u109D\u135D-\u135F\u1712-\u1714\u1732\u1733\u1752\u1753\u1772\u1773\u17B4\u17B5\u17B7-\u17BD\u17C6\u17C9-\u17D3\u17DD\u180B-\u180D\u180F\u1885\u1886\u18A9\u1920-\u1922\u1927\u1928\u1932\u1939-\u193B\u1A17\u1A18\u1A1B\u1A56\u1A58-\u1A5E\u1A60\u1A62\u1A65-\u1A6C\u1A73-\u1A7C\u1A7F\u1AB0-\u1ACE\u1B00-\u1B03\u1B34-\u1B3A\u1B3C\u1B42\u1B6B-\u1B73\u1B80\u1B81\u1BA2-\u1BA5\u1BA8\u1BA9\u1BAB-\u1BAD\u1BE6\u1BE8\u1BE9\u1BED\u1BEF-\u1BF1\u1C2C-\u1C33\u1C36\u1C37\u1CD0-\u1CD2\u1CD4-\u1CE0\u1CE2-\u1CE8\u1CED\u1CF4\u1CF8\u1CF9\u1DC0-\u1DFF\u200C\u20D0-\u20F0\u2CEF-\u2CF1\u2D7F\u2DE0-\u2DFF\u302A-\u302F\u3099\u309A\uA66F-\uA672\uA674-\uA67D\uA69E\uA69F\uA6F0\uA6F1\uA802\uA806\uA80B\uA825\uA826\uA82C\uA8C4\uA8C5\uA8E0-\uA8F1\uA8FF\uA926-\uA92D\uA947-\uA951\uA980-\uA982\uA9B3\uA9B6-\uA9B9\uA9BC\uA9BD\uA9E5\uAA29-\uAA2E\uAA31\uAA32\uAA35\uAA36\uAA43\uAA4C\uAA7C\uAAB0\uAAB2-\uAAB4\uAAB7\uAAB8\uAABE\uAABF\uAAC1\uAAEC\uAAED\uAAF6\uABE5\uABE8\uABED\uFB1E\uFE00-\uFE0F\uFE20-\uFE2F\uFF9E\uFF9F]|\uD800[\uDDFD\uDEE0\uDF76-\uDF7A]|\uD802[\uDE01-\uDE03\uDE05\uDE06\uDE0C-\uDE0F\uDE38-\uDE3A\uDE3F\uDEE5\uDEE6]|\uD803[\uDD24-\uDD27\uDEAB\uDEAC\uDEFD-\uDEFF\uDF46-\uDF50\uDF82-\uDF85]|\uD804[\uDC01\uDC38-\uDC46\uDC70\uDC73\uDC74\uDC7F-\uDC81\uDCB3-\uDCB6\uDCB9\uDCBA\uDCC2\uDD00-\uDD02\uDD27-\uDD2B\uDD2D-\uDD34\uDD73\uDD80\uDD81\uDDB6-\uDDBE\uDDC9-\uDDCC\uDDCF\uDE2F-\uDE31\uDE34\uDE36\uDE37\uDE3E\uDE41\uDEDF\uDEE3-\uDEEA\uDF00\uDF01\uDF3B\uDF3C\uDF3E\uDF40\uDF57\uDF66-\uDF6C\uDF70-\uDF74]|\uD805[\uDC38-\uDC3F\uDC42-\uDC44\uDC46\uDC5E\uDCB0\uDCB3-\uDCB8\uDCBA\uDCBD\uDCBF\uDCC0\uDCC2\uDCC3\uDDAF\uDDB2-\uDDB5\uDDBC\uDDBD\uDDBF\uDDC0\uDDDC\uDDDD\uDE33-\uDE3A\uDE3D\uDE3F\uDE40\uDEAB\uDEAD\uDEB0-\uDEB5\uDEB7\uDF1D-\uDF1F\uDF22-\uDF25\uDF27-\uDF2B]|\uD806[\uDC2F-\uDC37\uDC39\uDC3A\uDD30\uDD3B\uDD3C\uDD3E\uDD43\uDDD4-\uDDD7\uDDDA\uDDDB\uDDE0\uDE01-\uDE0A\uDE33-\uDE38\uDE3B-\uDE3E\uDE47\uDE51-\uDE56\uDE59-\uDE5B\uDE8A-\uDE96\uDE98\uDE99]|\uD807[\uDC30-\uDC36\uDC38-\uDC3D\uDC3F\uDC92-\uDCA7\uDCAA-\uDCB0\uDCB2\uDCB3\uDCB5\uDCB6\uDD31-\uDD36\uDD3A\uDD3C\uDD3D\uDD3F-\uDD45\uDD47\uDD90\uDD91\uDD95\uDD97\uDEF3\uDEF4\uDF00\uDF01\uDF36-\uDF3A\uDF40\uDF42]|\uD80D[\uDC40\uDC47-\uDC55]|\uD81A[\uDEF0-\uDEF4\uDF30-\uDF36]|\uD81B[\uDF4F\uDF8F-\uDF92\uDFE4]|\uD82F[\uDC9D\uDC9E]|\uD833[\uDF00-\uDF2D\uDF30-\uDF46]|\uD834[\uDD65\uDD67-\uDD69\uDD6E-\uDD72\uDD7B-\uDD82\uDD85-\uDD8B\uDDAA-\uDDAD\uDE42-\uDE44]|\uD836[\uDE00-\uDE36\uDE3B-\uDE6C\uDE75\uDE84\uDE9B-\uDE9F\uDEA1-\uDEAF]|\uD838[\uDC00-\uDC06\uDC08-\uDC18\uDC1B-\uDC21\uDC23\uDC24\uDC26-\uDC2A\uDC8F\uDD30-\uDD36\uDEAE\uDEEC-\uDEEF]|\uD839[\uDCEC-\uDCEF]|\uD83A[\uDCD0-\uDCD6\uDD44-\uDD4A]|\uD83C[\uDFFB-\uDFFF]|\uDB40[\uDC20-\uDC7F\uDD00-\uDDEF])*\u200D$/,J0=t=>t.search(aF)!==-1,lF=/(?:\uD83C[\uDDE6-\uDDFF])+$/g,cF=t=>{var e=t.match(lF);if(e===null)return!1;var n=e[0].length/2;return n%2===1},uF=function(e){var{deep:n=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};if(!nn(e))return!1;var r=typeof e.addMark=="function"&&typeof e.apply=="function"&&typeof e.deleteFragment=="function"&&typeof e.insertBreak=="function"&&typeof e.insertSoftBreak=="function"&&typeof e.insertFragment=="function"&&typeof e.insertNode=="function"&&typeof e.insertText=="function"&&typeof e.isElementReadOnly=="function"&&typeof e.isInline=="function"&&typeof e.isSelectable=="function"&&typeof e.isVoid=="function"&&typeof e.normalizeNode=="function"&&typeof e.onChange=="function"&&typeof e.removeMark=="function"&&typeof e.getDirtyPaths=="function"&&(e.marks===null||nn(e.marks))&&(e.selection===null||oe.isRange(e.selection))&&(!n||ge.isNodeList(e.children))&&uo.isOperationList(e.operations);return r},I={above(t,e){return t.above(e)},addMark(t,e,n){t.addMark(e,n)},after(t,e,n){return t.after(e,n)},before(t,e,n){return t.before(e,n)},deleteBackward(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{unit:n="character"}=e;t.deleteBackward(n)},deleteForward(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{unit:n="character"}=e;t.deleteForward(n)},deleteFragment(t,e){t.deleteFragment(e)},edges(t,e){return t.edges(e)},elementReadOnly(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return t.elementReadOnly(e)},end(t,e){return t.end(e)},first(t,e){return t.first(e)},fragment(t,e){return t.fragment(e)},hasBlocks(t,e){return t.hasBlocks(e)},hasInlines(t,e){return t.hasInlines(e)},hasPath(t,e){return t.hasPath(e)},hasTexts(t,e){return t.hasTexts(e)},insertBreak(t){t.insertBreak()},insertFragment(t,e,n){t.insertFragment(e,n)},insertNode(t,e){t.insertNode(e)},insertSoftBreak(t){t.insertSoftBreak()},insertText(t,e){t.insertText(e)},isBlock(t,e){return t.isBlock(e)},isEdge(t,e,n){return t.isEdge(e,n)},isEditor(t){return uF(t)},isElementReadOnly(t,e){return t.isElementReadOnly(e)},isEmpty(t,e){return t.isEmpty(e)},isEnd(t,e,n){return t.isEnd(e,n)},isInline(t,e){return t.isInline(e)},isNormalizing(t){return t.isNormalizing()},isSelectable(t,e){return t.isSelectable(e)},isStart(t,e,n){return t.isStart(e,n)},isVoid(t,e){return t.isVoid(e)},last(t,e){return t.last(e)},leaf(t,e,n){return t.leaf(e,n)},levels(t,e){return t.levels(e)},marks(t){return t.getMarks()},next(t,e){return t.next(e)},node(t,e,n){return t.node(e,n)},nodes(t,e){return t.nodes(e)},normalize(t,e){t.normalize(e)},parent(t,e,n){return t.parent(e,n)},path(t,e,n){return t.path(e,n)},pathRef(t,e,n){return t.pathRef(e,n)},pathRefs(t){return t.pathRefs()},point(t,e,n){return t.point(e,n)},pointRef(t,e,n){return t.pointRef(e,n)},pointRefs(t){return t.pointRefs()},positions(t,e){return t.positions(e)},previous(t,e){return t.previous(e)},range(t,e,n){return t.range(e,n)},rangeRef(t,e,n){return t.rangeRef(e,n)},rangeRefs(t){return t.rangeRefs()},removeMark(t,e){t.removeMark(e)},setNormalizing(t,e){t.setNormalizing(e)},start(t,e){return t.start(e)},string(t,e,n){return t.string(e,n)},unhangRange(t,e,n){return t.unhangRange(e,n)},void(t,e){return t.void(e)},withoutNormalizing(t,e){t.withoutNormalizing(e)},shouldMergeNodesRemovePrevNode:(t,e,n)=>t.shouldMergeNodesRemovePrevNode(e,n)},dF={isLocation(t){return U.isPath(t)||Re.isPoint(t)||oe.isRange(t)}},fF={isSpan(t){return Array.isArray(t)&&t.length===2&&t.every(U.isPath)}};function R0(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Q0(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?R0(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):R0(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var Re={compare(t,e){var n=U.compare(t.path,e.path);return n===0?t.offset<e.offset?-1:t.offset>e.offset?1:0:n},isAfter(t,e){return Re.compare(t,e)===1},isBefore(t,e){return Re.compare(t,e)===-1},equals(t,e){return t.offset===e.offset&&U.equals(t.path,e.path)},isPoint(t){return nn(t)&&typeof t.offset=="number"&&U.isPath(t.path)},transform(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};if(t===null)return null;var{affinity:r="forward"}=n,{path:o,offset:i}=t;switch(e.type){case"insert_node":case"move_node":{o=U.transform(o,e,n);break}case"insert_text":{U.equals(e.path,o)&&(e.offset<i||e.offset===i&&r==="forward")&&(i+=e.text.length);break}case"merge_node":{U.equals(e.path,o)&&(i+=e.position),o=U.transform(o,e,n);break}case"remove_text":{U.equals(e.path,o)&&e.offset<=i&&(i-=Math.min(i-e.offset,e.text.length));break}case"remove_node":{if(U.equals(e.path,o)||U.isAncestor(e.path,o))return null;o=U.transform(o,e,n);break}case"split_node":{if(U.equals(e.path,o)){if(e.position===i&&r==null)return null;(e.position<i||e.position===i&&r==="forward")&&(i-=e.position,o=U.transform(o,e,Q0(Q0({},n),{},{affinity:"forward"})))}else o=U.transform(o,e,n);break}default:return t}return{path:o,offset:i}}},Z0=void 0,$t={setScrubber(t){Z0=t},stringify(t){return JSON.stringify(t,Z0)}},hF=["text"],pF=["anchor","focus","merge"];function ey(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Yr(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ey(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ey(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var Oe={equals(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{loose:r=!1}=n;function o(i){var s=Kr(i,hF);return s}return X0(r?o(t):t,r?o(e):e)},isText(t){return nn(t)&&typeof t.text=="string"},isTextList(t){return Array.isArray(t)&&t.every(e=>Oe.isText(e))},isTextProps(t){return t.text!==void 0},matches(t,e){for(var n in e)if(n!=="text"&&(!t.hasOwnProperty(n)||t[n]!==e[n]))return!1;return!0},decorations(t,e){var n=[{leaf:Yr({},t)}];for(var r of e){var{anchor:o,focus:i,merge:s}=r,a=Kr(r,pF),[l,c]=oe.edges(r),u=[],d=0,h=l.offset,p=c.offset,m=s??Object.assign;for(var{leaf:w}of n){var{length:v}=w.text,y=d;if(d+=v,h<=y&&d<=p){m(w,a),u.push({leaf:w});continue}if(h!==p&&(h===d||p===y)||h>d||p<y||p===y&&y!==0){u.push({leaf:w});continue}var g=w,k=void 0,A=void 0;if(p<d){var C=p-y;A={leaf:Yr(Yr({},g),{},{text:g.text.slice(C)})},g=Yr(Yr({},g),{},{text:g.text.slice(0,C)})}if(h>y){var E=h-y;k={leaf:Yr(Yr({},g),{},{text:g.text.slice(0,E)})},g=Yr(Yr({},g),{},{text:g.text.slice(E)})}m(g,a),k&&u.push(k),u.push({leaf:g}),A&&u.push(A)}n=u}if(n.length>1){var D=0;for(var[S,_]of n.entries()){var O=D,B=O+_.leaf.text.length,N={start:O,end:B};S===0&&(N.isFirst=!0),S===n.length-1&&(N.isLast=!0),_.position=N,D=B}}return n}};function ty(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function rc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ty(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ty(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var ny=function(e,n){for(var r=arguments.length,o=new Array(r>2?r-2:0),i=2;i<r;i++)o[i-2]=arguments[i];return[...e.slice(0,n),...o,...e.slice(n)]},Rs=function(e,n,r){for(var o=arguments.length,i=new Array(o>3?o-3:0),s=3;s<o;s++)i[s-3]=arguments[s];return[...e.slice(0,n),...i,...e.slice(n+r)]},Nf=Rs,Bf=(t,e,n)=>{if(e.length===0)throw new Error("Cannot modify the editor");for(var r=ge.get(t,e),o=e.slice(),i=n(r);o.length>1;){var s=o.pop(),a=ge.get(t,o);i=rc(rc({},a),{},{children:Rs(a.children,s,1,i)})}var l=o.pop();t.children=Rs(t.children,l,1,i)},Ko=(t,e,n)=>{e.length===0?t.children=n(t.children):Bf(t,e,r=>{if(Oe.isText(r))throw new Error("Cannot get the element at path [".concat(e,"] because it refers to a leaf node: ").concat($t.stringify(r)));return rc(rc({},r),{},{children:n(r.children)})})},oc=(t,e,n)=>Bf(t,e,r=>{if(!Oe.isText(r))throw new Error("Cannot get the leaf node at path [".concat(e,"] because it refers to a non-leaf node: ").concat($t.stringify(r)));return n(r)});function ry(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Tt(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ry(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ry(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var mF={transform(t,e){var n=!1;switch(e.type){case"insert_node":{var{path:r,node:o}=e;Ko(t,U.parent(r),q=>{var J=r[r.length-1];if(J>q.length)throw new Error('Cannot apply an "insert_node" operation at path ['.concat(r,"] because the destination is past the end of the node."));return ny(q,J,o)}),n=!0;break}case"insert_text":{var{path:i,offset:s,text:a}=e;if(a.length===0)break;oc(t,i,q=>{var J=q.text.slice(0,s),K=q.text.slice(s);return Tt(Tt({},q),{},{text:J+a+K})}),n=!0;break}case"merge_node":{var{path:l}=e,c=l[l.length-1],u=U.previous(l),d=u[u.length-1];Ko(t,U.parent(l),q=>{var J=q[c],K=q[d],re;if(Oe.isText(J)&&Oe.isText(K))re=Tt(Tt({},K),{},{text:K.text+J.text});else if(!Oe.isText(J)&&!Oe.isText(K))re=Tt(Tt({},K),{},{children:K.children.concat(J.children)});else throw new Error('Cannot apply a "merge_node" operation at path ['.concat(l,"] to nodes of different interfaces: ").concat($t.stringify(J)," ").concat($t.stringify(K)));return Rs(q,d,2,re)}),n=!0;break}case"move_node":{var{path:h,newPath:p}=e,m=h[h.length-1];if(U.isAncestor(h,p))throw new Error("Cannot move a path [".concat(h,"] to new path [").concat(p,"] because the destination is inside itself."));var w=ge.get(t,h);Ko(t,U.parent(h),q=>Nf(q,m,1));var v=U.transform(h,e),y=v[v.length-1];Ko(t,U.parent(v),q=>ny(q,y,w)),n=!0;break}case"remove_node":{var{path:g}=e,k=g[g.length-1];if(Ko(t,U.parent(g),q=>Nf(q,k,1)),t.selection){var A=Tt({},t.selection);for(var[C,E]of oe.points(A)){var D=Re.transform(C,e);if(A!=null&&D!=null)A[E]=D;else{var S=void 0,_=void 0;for(var[O,B]of ge.texts(t))if(U.compare(B,g)===-1)S=[O,B];else{_=[O,B];break}var N=!1;S&&_&&(U.isSibling(S[1],g)?N=!1:U.equals(_[1],g)?N=!0:N=U.common(S[1],g).length<U.common(_[1],g).length),S&&!N?A[E]={path:S[1],offset:S[0].text.length}:_?A[E]={path:_[1],offset:0}:A=null}}(!A||!oe.equals(A,t.selection))&&(t.selection=A)}break}case"remove_text":{var{path:F,offset:M,text:T}=e;if(T.length===0)break;oc(t,F,q=>{var J=q.text.slice(0,M),K=q.text.slice(M+T.length);return Tt(Tt({},q),{},{text:J+K})}),n=!0;break}case"set_node":{var{path:P,properties:$,newProperties:W}=e;if(P.length===0)throw new Error("Cannot set properties on the root node!");Bf(t,P,q=>{var J=Tt({},q);for(var K in W){if(K==="children"||K==="text")throw new Error('Cannot set the "'.concat(K,'" property of nodes!'));var re=W[K];re==null?delete J[K]:J[K]=re}for(var se in $)W.hasOwnProperty(se)||delete J[se];return J});break}case"set_selection":{var{newProperties:V}=e;if(V==null){t.selection=null;break}if(t.selection==null){if(!oe.isRange(V))throw new Error('Cannot apply an incomplete "set_selection" operation properties '.concat($t.stringify(V)," when there is no current selection."));t.selection=Tt({},V);break}var X=Tt({},t.selection);for(var G in V){var te=V[G];if(te==null){if(G==="anchor"||G==="focus")throw new Error('Cannot remove the "'.concat(G,'" selection property'));delete X[G]}else X[G]=te}t.selection=X;break}case"split_node":{var{path:H,position:j,properties:Y}=e,ie=H[H.length-1];if(H.length===0)throw new Error('Cannot apply a "split_node" operation at path ['.concat(H,"] because the root node cannot be split."));Ko(t,U.parent(H),q=>{var J=q[ie],K,re;if(Oe.isText(J)){var se=J.text.slice(0,j),he=J.text.slice(j);K=Tt(Tt({},J),{},{text:se}),re=Tt(Tt({},Y),{},{text:he})}else{var Ce=J.children.slice(0,j),Fe=J.children.slice(j);K=Tt(Tt({},J),{},{children:Ce}),re=Tt(Tt({},Y),{},{children:Fe})}return Rs(q,ie,1,K,re)}),n=!0;break}}if(n&&t.selection){var Q=Tt({},t.selection);for(var[le,L]of oe.points(Q))Q[L]=Re.transform(le,e);oe.equals(Q,t.selection)||(t.selection=Q)}}},gF={insertNodes(t,e,n){t.insertNodes(e,n)},liftNodes(t,e){t.liftNodes(e)},mergeNodes(t,e){t.mergeNodes(e)},moveNodes(t,e){t.moveNodes(e)},removeNodes(t,e){t.removeNodes(e)},setNodes(t,e,n){t.setNodes(e,n)},splitNodes(t,e){t.splitNodes(e)},unsetNodes(t,e,n){t.unsetNodes(e,n)},unwrapNodes(t,e){t.unwrapNodes(e)},wrapNodes(t,e,n){t.wrapNodes(e,n)}},wF={collapse(t,e){t.collapse(e)},deselect(t){t.deselect()},move(t,e){t.move(e)},select(t,e){t.select(e)},setPoint(t,e,n){t.setPoint(e,n)},setSelection(t,e){t.setSelection(e)}},vF={delete(t,e){t.delete(e)},insertFragment(t,e,n){t.insertFragment(e,n)},insertText(t,e){var n=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};I.withoutNormalizing(t,()=>{var{voids:r=!1}=n,{at:o=Of(t)}=n;if(U.isPath(o)&&(o=I.range(t,o)),oe.isRange(o))if(oe.isCollapsed(o))o=o.anchor;else{var i=oe.end(o);if(!r&&I.void(t,{at:i}))return;var s=oe.start(o),a=I.pointRef(t,s),l=I.pointRef(t,i);ce.delete(t,{at:o,voids:r});var c=a.unref(),u=l.unref();o=c||u,ce.setSelection(t,{anchor:o,focus:o})}if(!(!r&&I.void(t,{at:o})||I.elementReadOnly(t,{at:o}))){var{path:d,offset:h}=o;e.length>0&&t.apply({type:"insert_text",path:d,offset:h,text:e})}})}};function oy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function ic(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?oy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):oy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var ce=ic(ic(ic(ic({},mF),gF),wF),vF),sc=new WeakMap,yF=t=>sc.get(t)||!1,bF=(t,e,n)=>{var r=sc.get(t)||!1;sc.set(t,!0);try{e(),n()}finally{sc.set(t,r)}};function iy(t,e,n){var r=ec.get(t)||[],o=tc.get(t)||new Set,i,s,a=d=>{if(d){var h=d.join(",");s.has(h)||(s.add(h),i.push(d))}};if(n){i=[],s=new Set;for(var l of r){var c=n(l);a(c)}}else i=r,s=o;for(var u of e)a(u);ec.set(t,i),tc.set(t,s)}var CF=(t,e)=>{for(var n of I.pathRefs(t))NB.transform(n,e);for(var r of I.pointRefs(t))BB.transform(r,e);for(var o of I.rangeRefs(t))FB.transform(o,e);if(!yF(t)){var i=U.operationCanTransformPath(e)?s=>U.transform(s,e):void 0;iy(t,t.getDirtyPaths(e),i)}ce.transform(t,e),t.operations.push(e),I.normalize(t,{operation:e}),e.type==="set_selection"&&(t.marks=null),Xs.get(t)||(Xs.set(t,!0),Promise.resolve().then(()=>{Xs.set(t,!1),t.onChange({operation:e}),t.operations=[]}))},kF=(t,e)=>{switch(e.type){case"insert_text":case"remove_text":case"set_node":{var{path:n}=e;return U.levels(n)}case"insert_node":{var{node:r,path:o}=e,i=U.levels(o),s=Oe.isText(r)?[]:Array.from(ge.nodes(r),O=>{var[,B]=O;return o.concat(B)});return[...i,...s]}case"merge_node":{var{path:a}=e,l=U.ancestors(a),c=U.previous(a);return[...l,c]}case"move_node":{var{path:u,newPath:d}=e;if(U.equals(u,d))return[];var h=[],p=[];for(var m of U.ancestors(u)){var w=U.transform(m,e);h.push(w)}for(var v of U.ancestors(d)){var y=U.transform(v,e);p.push(y)}var g=p[p.length-1],k=d[d.length-1],A=g.concat(k);return[...h,...p,A]}case"remove_node":{var{path:C}=e,E=U.ancestors(C);return[...E]}case"split_node":{var{path:D}=e,S=U.levels(D),_=U.next(D);return[...S,_]}default:return[]}},xF=t=>{var{selection:e}=t;return e?ge.fragment(t,e):[]},SF=(t,e,n)=>{var[r,o]=e;if(!Oe.isText(r)){if(Ae.isElement(r)&&r.children.length===0){var i={text:""};ce.insertNodes(t,i,{at:o.concat(0),voids:!0});return}for(var s=I.isEditor(r)?!1:Ae.isElement(r)&&(t.isInline(r)||r.children.length===0||Oe.isText(r.children[0])||t.isInline(r.children[0])),a=0,l=0;l<r.children.length;l++,a++){var c=ge.get(t,o);if(!Oe.isText(c)){var u=c.children[a],d=c.children[a-1],h=l===r.children.length-1,p=Oe.isText(u)||Ae.isElement(u)&&t.isInline(u);if(p!==s)p?n!=null&&n.fallbackElement?ce.wrapNodes(t,n.fallbackElement(),{at:o.concat(a),voids:!0}):ce.removeNodes(t,{at:o.concat(a),voids:!0}):ce.unwrapNodes(t,{at:o.concat(a),voids:!0}),a--;else if(Ae.isElement(u)){if(t.isInline(u)){if(d==null||!Oe.isText(d)){var m={text:""};ce.insertNodes(t,m,{at:o.concat(a),voids:!0}),a++}else if(h){var w={text:""};ce.insertNodes(t,w,{at:o.concat(a+1),voids:!0}),a++}}}else{if(!Oe.isText(u)&&!("children"in u)){var v=u;v.children=[]}d!=null&&Oe.isText(d)&&(Oe.equals(u,d,{loose:!0})?(ce.mergeNodes(t,{at:o.concat(a),voids:!0}),a--):d.text===""?(ce.removeNodes(t,{at:o.concat(a-1),voids:!0}),a--):u.text===""&&(ce.removeNodes(t,{at:o.concat(a),voids:!0}),a--))}}}}},EF=(t,e)=>{var{iteration:n,initialDirtyPathsLength:r}=e,o=r*42;if(n>o)throw new Error("Could not completely normalize the editor after ".concat(o," iterations! This is usually due to incorrect normalization logic that leaves a node in an invalid state."));return!0},DF=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{voids:r=!1,mode:o="lowest",at:i=e.selection,match:s}=n;if(i){var a=I.path(e,i);if(!oe.isRange(i)||U.equals(i.focus.path,i.anchor.path)){if(a.length===0)return;a=U.parent(a)}var l=o==="lowest",[c]=I.levels(e,{at:a,voids:r,match:s,reverse:l});return c}};function sy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function ay(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?sy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):sy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var AF=(t,e,n)=>{var{selection:r}=t;if(r){var o=(d,h)=>{if(!Oe.isText(d))return!1;var[p,m]=I.parent(t,h);return!t.isVoid(p)||t.markableVoid(p)},i=oe.isExpanded(r),s=!1;if(!i){var[a,l]=I.node(t,r);if(a&&o(a,l)){var[c]=I.parent(t,l);s=c&&t.markableVoid(c)}}if(i||s)ce.setNodes(t,{[e]:n},{match:o,split:!0,voids:!0});else{var u=ay(ay({},I.marks(t)||{}),{},{[e]:n});t.marks=u,Xs.get(t)||t.onChange()}}};function ly(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function cy(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?ly(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ly(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var OF=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=I.point(e,n,{edge:"end"}),i=I.end(e,[]),s={anchor:o,focus:i},{distance:a=1}=r,l=0,c;for(var u of I.positions(e,cy(cy({},r),{},{at:s}))){if(l>a)break;l!==0&&(c=u),l++}return c};function uy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function dy(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?uy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):uy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var TF=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=I.start(e,[]),i=I.point(e,n,{edge:"start"}),s={anchor:o,focus:i},{distance:a=1}=r,l=0,c;for(var u of I.positions(e,dy(dy({},r),{},{at:s,reverse:!0}))){if(l>a)break;l!==0&&(c=u),l++}return c},_F=(t,e)=>{var{selection:n}=t;n&&oe.isCollapsed(n)&&ce.delete(t,{unit:e,reverse:!0})},NF=(t,e)=>{var{selection:n}=t;n&&oe.isCollapsed(n)&&ce.delete(t,{unit:e})},BF=function(e){var{direction:n="forward"}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{selection:r}=e;r&&oe.isExpanded(r)&&ce.delete(e,{reverse:n==="backward"})},FF=(t,e)=>[I.start(t,e),I.end(t,e)];function fy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function hy(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?fy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):fy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var IF=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return I.above(e,hy(hy({},n),{},{match:r=>Ae.isElement(r)&&I.isElementReadOnly(e,r)}))},MF=(t,e)=>I.point(t,e,{edge:"end"}),PF=(t,e)=>{var n=I.path(t,e,{edge:"start"});return I.node(t,n)},LF=(t,e)=>{var n=I.range(t,e);return ge.fragment(t,n)};function py(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function my(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?py(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):py(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var $F=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return I.above(e,my(my({},n),{},{match:r=>Ae.isElement(r)&&I.isVoid(e,r)}))},HF=(t,e)=>e.children.some(n=>Ae.isElement(n)&&I.isBlock(t,n)),zF=(t,e)=>e.children.some(n=>Oe.isText(n)||I.isInline(t,n)),jF=(t,e)=>ge.has(t,e),VF=(t,e)=>e.children.every(n=>Oe.isText(n)),WF=t=>{ce.splitNodes(t,{always:!0})},UF=(t,e,n)=>{ce.insertNodes(t,e,n)},qF=t=>{ce.splitNodes(t,{always:!0})};function gy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function GF(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var KF=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{selection:o,marks:i}=e;if(o){if(i){var s=GF({text:n},i);ce.insertNodes(e,s,{at:r.at,voids:r.voids})}else ce.insertText(e,n,r);e.marks=null}},YF=(t,e)=>!t.isInline(e),XF=(t,e,n)=>I.isStart(t,e,n)||I.isEnd(t,e,n),JF=(t,e)=>{var{children:n}=e,[r]=n;return n.length===0||n.length===1&&Oe.isText(r)&&r.text===""&&!t.isVoid(e)},RF=(t,e,n)=>{var r=I.end(t,n);return Re.equals(e,r)},QF=t=>{var e=j0.get(t);return e===void 0?!0:e},ZF=(t,e,n)=>{if(e.offset!==0)return!1;var r=I.start(t,n);return Re.equals(e,r)},eI=(t,e)=>{var n=I.path(t,e,{edge:"end"});return I.node(t,n)},tI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=I.path(e,n,r),i=ge.leaf(e,o);return[i,o]};function nI(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){var{at:n=t.selection,reverse:r=!1,voids:o=!1}=e,{match:i}=e;if(i==null&&(i=()=>!0),!!n){var s=[],a=I.path(t,n);for(var[l,c]of ge.levels(t,a))if(i(l,c)&&(s.push([l,c]),!o&&Ae.isElement(l)&&I.isVoid(t,l)))break;r&&s.reverse(),yield*s}})()}var rI=["text"],oI=["text"],iI=function(e){var{marks:n,selection:r}=e;if(!r)return null;var{anchor:o,focus:i}=r;if(n)return n;if(oe.isExpanded(r)){var s=oe.isBackward(r);s&&([i,o]=[o,i]);var a=I.isEnd(e,o,o.path);if(a){var l=I.after(e,o);l&&(o=l)}var[c]=I.nodes(e,{match:Oe.isText,at:{anchor:o,focus:i}});if(c){var[u]=c,d=Kr(u,rI);return d}else return{}}var{path:h}=o,[p]=I.leaf(e,h);if(o.offset===0){var m=I.previous(e,{at:h,match:Oe.isText}),w=I.above(e,{match:C=>Ae.isElement(C)&&I.isVoid(e,C)&&e.markableVoid(C)});if(!w){var v=I.above(e,{match:C=>Ae.isElement(C)&&I.isBlock(e,C)});if(m&&v){var[y,g]=m,[,k]=v;U.isAncestor(k,g)&&(p=y)}}}var A=Kr(p,oI);return A},sI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{mode:r="lowest",voids:o=!1}=n,{match:i,at:s=e.selection}=n;if(s){var a=I.after(e,s,{voids:o});if(a){var[,l]=I.last(e,[]),c=[a.path,l];if(U.isPath(s)&&s.length===0)throw new Error("Cannot get the next node from the root node!");if(i==null)if(U.isPath(s)){var[u]=I.parent(e,s);i=h=>u.children.includes(h)}else i=()=>!0;var[d]=I.nodes(e,{at:c,match:i,mode:r,voids:o});return d}}},aI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=I.path(e,n,r),i=ge.get(e,o);return[i,o]};function lI(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){var{at:n=t.selection,mode:r="all",universal:o=!1,reverse:i=!1,voids:s=!1,pass:a}=e,{match:l}=e;if(l||(l=()=>!0),!!n){var c,u;if(fF.isSpan(n))c=n[0],u=n[1];else{var d=I.path(t,n,{edge:"start"}),h=I.path(t,n,{edge:"end"});c=i?h:d,u=i?d:h}var p=ge.nodes(t,{reverse:i,from:c,to:u,pass:A=>{var[C,E]=A;return a&&a([C,E])?!0:Ae.isElement(C)?!!(!s&&(I.isVoid(t,C)||I.isElementReadOnly(t,C))):!1}}),m=[],w;for(var[v,y]of p){var g=w&&U.compare(y,w[1])===0;if(!(r==="highest"&&g)){if(!l(v,y)){if(o&&!g&&Oe.isText(v))return;continue}if(r==="lowest"&&g){w=[v,y];continue}var k=r==="lowest"?w:[v,y];k&&(o?m.push(k):yield k),w=[v,y]}}r==="lowest"&&w&&(o?m.push(w):yield w),o&&(yield*m)}})()}var cI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{force:r=!1,operation:o}=n,i=u=>ec.get(u)||[],s=u=>tc.get(u)||new Set,a=u=>{var d=i(u).pop(),h=d.join(",");return s(u).delete(h),d};if(I.isNormalizing(e)){if(r){var l=Array.from(ge.nodes(e),u=>{var[,d]=u;return d}),c=new Set(l.map(u=>u.join(",")));ec.set(e,l),tc.set(e,c)}i(e).length!==0&&I.withoutNormalizing(e,()=>{for(var u of i(e))if(ge.has(e,u)){var d=I.node(e,u),[h,p]=d;Ae.isElement(h)&&h.children.length===0&&e.normalizeNode(d,{operation:o})}for(var m=i(e),w=m.length,v=0;m.length!==0;){if(!e.shouldNormalize({dirtyPaths:m,iteration:v,initialDirtyPathsLength:w,operation:o}))return;var y=a(e);if(ge.has(e,y)){var g=I.node(e,y);e.normalizeNode(g,{operation:o})}v++,m=i(e)}})}},uI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=I.path(e,n,r),i=U.parent(o),s=I.node(e,i);return s},dI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:o="forward"}=r,i={current:n,affinity:o,unref(){var{current:a}=i,l=I.pathRefs(e);return l.delete(i),i.current=null,a}},s=I.pathRefs(e);return s.add(i),i},fI=t=>{var e=V0.get(t);return e||(e=new Set,V0.set(t,e)),e},hI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{depth:o,edge:i}=r;if(U.isPath(n)){if(i==="start"){var[,s]=ge.first(e,n);n=s}else if(i==="end"){var[,a]=ge.last(e,n);n=a}}return oe.isRange(n)&&(i==="start"?n=oe.start(n):i==="end"?n=oe.end(n):n=U.common(n.anchor.path,n.focus.path)),Re.isPoint(n)&&(n=n.path),o!=null&&(n=n.slice(0,o)),n},pI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:o="forward"}=r,i={current:n,affinity:o,unref(){var{current:a}=i,l=I.pointRefs(e);return l.delete(i),i.current=null,a}},s=I.pointRefs(e);return s.add(i),i},mI=t=>{var e=W0.get(t);return e||(e=new Set,W0.set(t,e)),e},gI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{edge:o="start"}=r;if(U.isPath(n)){var i;if(o==="end"){var[,s]=ge.last(e,n);i=s}else{var[,a]=ge.first(e,n);i=a}var l=ge.get(e,i);if(!Oe.isText(l))throw new Error("Cannot get the ".concat(o," point in the node at path [").concat(n,"] because it has no ").concat(o," text node."));return{path:i,offset:o==="end"?l.text.length:0}}if(oe.isRange(n)){var[c,u]=oe.edges(n);return o==="start"?c:u}return n};function wI(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};return(function*(){var{at:n=t.selection,unit:r="offset",reverse:o=!1,voids:i=!1}=e;if(!n)return;var s=I.range(t,n),[a,l]=oe.edges(s),c=o?l:a,u=!1,d="",h=0,p=0,m=0,w=[],v=function*(E){var D=w.some(F=>U.isAncestor(F,E));function*S(F){D||(yield F)}if(Ae.isElement(g)){if(!t.isSelectable(g)){if(w.push(E),o)return U.hasPrevious(E)&&(yield*S(I.end(t,U.previous(E)))),0;var _=U.next(E);return I.hasPath(t,_)&&(yield*S(I.start(t,_))),0}if(!i&&(t.isVoid(g)||t.isElementReadOnly(g)))return yield*S(I.start(t,E)),0;if(t.isInline(g))return 0;if(I.hasInlines(t,g)){var O=U.isAncestor(E,l.path)?l:I.end(t,E),B=U.isAncestor(E,a.path)?a:I.start(t,E);d=I.string(t,{anchor:B,focus:O},{voids:i}),u=!0}}if(Oe.isText(g)){var N=U.equals(E,c.path);for(N?(p=o?c.offset:g.text.length-c.offset,m=c.offset):(p=g.text.length,m=o?p:0),(N||u||r==="offset")&&(yield*S({path:E,offset:m}),u=!1);;){if(h===0){if(d==="")break;h=A(d,r,o),d=_f(d,h,o)[1]}if(m=o?m-h:m+h,p=p-h,p<0){h=-p;break}h=0,yield*S({path:E,offset:m})}}},y;for(var[g,k]of I.nodes(t,{at:n,reverse:o,voids:i}))y=yield*v(k);function A(C,E,D){return E==="character"?Tf(C,D):E==="word"?UB(C,D):E==="line"||E==="block"?C.length:1}})()}var vI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{mode:r="lowest",voids:o=!1}=n,{match:i,at:s=e.selection}=n;if(s){var a=I.before(e,s,{voids:o});if(a){var[,l]=I.first(e,[]),c=[a.path,l];if(U.isPath(s)&&s.length===0)throw new Error("Cannot get the previous node from the root node!");if(i==null)if(U.isPath(s)){var[u]=I.parent(e,s);i=h=>u.children.includes(h)}else i=()=>!0;var[d]=I.nodes(e,{reverse:!0,at:c,match:i,mode:r,voids:o});return d}}},yI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{affinity:o="forward"}=r,i={current:n,affinity:o,unref(){var{current:a}=i,l=I.rangeRefs(e);return l.delete(i),i.current=null,a}},s=I.rangeRefs(e);return s.add(i),i},bI=t=>{var e=U0.get(t);return e||(e=new Set,U0.set(t,e)),e},CI=(t,e,n)=>{if(oe.isRange(e)&&!n)return e;var r=I.start(t,e),o=I.end(t,n||e);return{anchor:r,focus:o}};function wy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function kI(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?wy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):wy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var xI=(t,e)=>{var{selection:n}=t;if(n){var r=(u,d)=>{if(!Oe.isText(u))return!1;var[h,p]=I.parent(t,d);return!t.isVoid(h)||t.markableVoid(h)},o=oe.isExpanded(n),i=!1;if(!o){var[s,a]=I.node(t,n);if(s&&r(s,a)){var[l]=I.parent(t,a);i=l&&t.markableVoid(l)}}if(o||i)ce.unsetNodes(t,e,{match:r,split:!0,voids:!0});else{var c=kI({},I.marks(t)||{});delete c[e],t.marks=c,Xs.get(t)||t.onChange()}}},SI=(t,e)=>{j0.set(t,e)},EI=(t,e)=>I.point(t,e,{edge:"start"}),DI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:o=!1}=r,i=I.range(e,n),[s,a]=oe.edges(i),l="";for(var[c,u]of I.nodes(e,{at:i,match:Oe.isText,voids:o})){var d=c.text;U.equals(u,a.path)&&(d=d.slice(0,a.offset)),U.equals(u,s.path)&&(d=d.slice(s.offset)),l+=d}return l},AI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{voids:o=!1}=r,[i,s]=oe.edges(n);if(i.offset!==0||s.offset!==0||oe.isCollapsed(n)||U.hasPrevious(s.path))return n;var a=I.above(e,{at:s,match:m=>Ae.isElement(m)&&I.isBlock(e,m),voids:o}),l=a?a[1]:[],c=I.start(e,i),u={anchor:c,focus:s},d=!0;for(var[h,p]of I.nodes(e,{at:u,match:Oe.isText,reverse:!0,voids:o})){if(d){d=!1;continue}if(h.text!==""||U.isBefore(p,l)){s={path:p,offset:h.text.length};break}}return{anchor:i,focus:s}},OI=(t,e)=>{var n=I.isNormalizing(t);I.setNormalizing(t,!1);try{e()}finally{I.setNormalizing(t,n)}I.normalize(t)},TI=(t,e,n)=>{var[r,o]=e;return Ae.isElement(r)&&I.isEmpty(t,r)||Oe.isText(r)&&r.text===""&&o[o.length-1]!==0},_I=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};I.withoutNormalizing(e,()=>{var r,o,{reverse:i=!1,unit:s="character",distance:a=1,voids:l=!1}=n,{at:c=e.selection,hanging:u=!1}=n;if(c){var d=!1;if(oe.isRange(c)&&oe.isCollapsed(c)&&(d=!0,c=c.anchor),Re.isPoint(c)){var h=I.void(e,{at:c,mode:"highest"});if(!l&&h){var[,p]=h;c=p}else{var m={unit:s,distance:a},w=i?I.before(e,c,m)||I.start(e,[]):I.after(e,c,m)||I.end(e,[]);c={anchor:c,focus:w},u=!0}}if(U.isPath(c)){ce.removeNodes(e,{at:c,voids:l});return}if(!oe.isCollapsed(c)){if(!u){var[,v]=oe.edges(c),y=I.end(e,[]);Re.equals(v,y)||(c=I.unhangRange(e,c,{voids:l}))}var[g,k]=oe.edges(c),A=I.above(e,{match:se=>Ae.isElement(se)&&I.isBlock(e,se),at:g,voids:l}),C=I.above(e,{match:se=>Ae.isElement(se)&&I.isBlock(e,se),at:k,voids:l}),E=A&&C&&!U.equals(A[1],C[1]),D=U.equals(g.path,k.path),S=l?null:(r=I.void(e,{at:g,mode:"highest"}))!==null&&r!==void 0?r:I.elementReadOnly(e,{at:g,mode:"highest"}),_=l?null:(o=I.void(e,{at:k,mode:"highest"}))!==null&&o!==void 0?o:I.elementReadOnly(e,{at:k,mode:"highest"});if(S){var O=I.before(e,g);O&&A&&U.isAncestor(A[1],O.path)&&(g=O)}if(_){var B=I.after(e,k);B&&C&&U.isAncestor(C[1],B.path)&&(k=B)}var N=[],F;for(var M of I.nodes(e,{at:c,voids:l})){var[T,P]=M;F&&U.compare(P,F)===0||(!l&&Ae.isElement(T)&&(I.isVoid(e,T)||I.isElementReadOnly(e,T))||!U.isCommon(P,g.path)&&!U.isCommon(P,k.path))&&(N.push(M),F=P)}var $=Array.from(N,se=>{var[,he]=se;return I.pathRef(e,he)}),W=I.pointRef(e,g),V=I.pointRef(e,k),X="";if(!D&&!S){var G=W.current,[te]=I.leaf(e,G),{path:H}=G,{offset:j}=g,Y=te.text.slice(j);Y.length>0&&(e.apply({type:"remove_text",path:H,offset:j,text:Y}),X=Y)}if($.reverse().map(se=>se.unref()).filter(se=>se!==null).forEach(se=>ce.removeNodes(e,{at:se,voids:l})),!_){var ie=V.current,[Q]=I.leaf(e,ie),{path:le}=ie,L=D?g.offset:0,q=Q.text.slice(L,k.offset);q.length>0&&(e.apply({type:"remove_text",path:le,offset:L,text:q}),X=q)}!D&&E&&V.current&&W.current&&ce.mergeNodes(e,{at:V.current,hanging:!0,voids:l}),d&&i&&s==="character"&&X.length>1&&X.match(/[\u0980-\u09FF\u0E00-\u0E7F\u1000-\u109F\u0900-\u097F\u1780-\u17FF\u0D00-\u0D7F\u0B00-\u0B7F\u0A00-\u0A7F\u0B80-\u0BFF\u0C00-\u0C7F]+/)&&ce.insertText(e,X.slice(0,X.length-a));var J=W.unref(),K=V.unref(),re=i?J||K:K||J;n.at==null&&re&&ce.select(e,re)}}})},NI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};I.withoutNormalizing(e,()=>{var{hanging:o=!1,voids:i=!1}=r,{at:s=Of(e),batchDirty:a=!0}=r;if(n.length){if(oe.isRange(s))if(o||(s=I.unhangRange(e,s,{voids:i})),oe.isCollapsed(s))s=s.anchor;else{var[,l]=oe.edges(s);if(!i&&I.void(e,{at:l}))return;var c=I.pointRef(e,l);ce.delete(e,{at:s}),s=c.unref()}else U.isPath(s)&&(s=I.start(e,s));if(!(!i&&I.void(e,{at:s}))){var u=I.above(e,{at:s,match:H=>Ae.isElement(H)&&I.isInline(e,H),mode:"highest",voids:i});if(u){var[,d]=u;if(I.isEnd(e,s,d)){var h=I.after(e,d);s=h}else if(I.isStart(e,s,d)){var p=I.before(e,d);s=p}}var m=I.above(e,{match:H=>Ae.isElement(H)&&I.isBlock(e,H),at:s,voids:i}),[,w]=m,v=I.isStart(e,s,w),y=I.isEnd(e,s,w),g=v&&y,[,k]=ge.first({children:n},[]),[,A]=ge.last({children:n},[]),C=H=>{var[j,Y]=H,ie=Y.length===0;return ie?!1:g?!0:!(!v&&U.isAncestor(Y,k)&&Ae.isElement(j)&&!e.isVoid(j)&&!e.isInline(j)||!y&&U.isAncestor(Y,A)&&Ae.isElement(j)&&!e.isVoid(j)&&!e.isInline(j))},E=!0,D=[],S=[],_=[];for(var O of ge.nodes({children:n},{pass:C})){var[B,N]=O;E&&Ae.isElement(B)&&!e.isInline(B)&&!U.isAncestor(N,k)&&(E=!1),C(O)&&(Ae.isElement(B)&&!e.isInline(B)?(E=!1,S.push(B)):E?D.push(B):_.push(B))}var[F]=I.nodes(e,{at:s,match:H=>Oe.isText(H)||I.isInline(e,H),mode:"highest",voids:i}),[,M]=F,T=I.isStart(e,s,M),P=I.isEnd(e,s,M),$=I.pathRef(e,y&&!_.length?U.next(w):w),W=I.pathRef(e,P?U.next(M):M),V=_.length>0;ce.splitNodes(e,{at:s,match:H=>V?Ae.isElement(H)&&I.isBlock(e,H):Oe.isText(H)||I.isInline(e,H),mode:V?"lowest":"highest",always:V&&(!v||D.length>0)&&(!y||_.length>0),voids:i});var X=I.pathRef(e,!T||T&&P?U.next(M):M);if(ce.insertNodes(e,D,{at:X.current,match:H=>Oe.isText(H)||I.isInline(e,H),mode:"highest",voids:i,batchDirty:a}),g&&!D.length&&S.length&&!_.length&&ce.delete(e,{at:w,voids:i}),ce.insertNodes(e,S,{at:$.current,match:H=>Ae.isElement(H)&&I.isBlock(e,H),mode:"lowest",voids:i,batchDirty:a}),ce.insertNodes(e,_,{at:W.current,match:H=>Oe.isText(H)||I.isInline(e,H),mode:"highest",voids:i,batchDirty:a}),!r.at){var G;if(_.length>0&&W.current?G=U.previous(W.current):S.length>0&&$.current?G=U.previous($.current):X.current&&(G=U.previous(X.current)),G){var te=I.end(e,G);ce.select(e,te)}}X.unref(),$.unref(),W.unref()}}})},BI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{edge:r="anchor"}=n,{selection:o}=e;if(o){if(r==="anchor")ce.select(e,o.anchor);else if(r==="focus")ce.select(e,o.focus);else if(r==="start"){var[i]=oe.edges(o);ce.select(e,i)}else if(r==="end"){var[,s]=oe.edges(o);ce.select(e,s)}}else return},FI=t=>{var{selection:e}=t;e&&t.apply({type:"set_selection",properties:e,newProperties:null})},II=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},{selection:r}=e,{distance:o=1,unit:i="character",reverse:s=!1}=n,{edge:a=null}=n;if(r){a==="start"&&(a=oe.isBackward(r)?"focus":"anchor"),a==="end"&&(a=oe.isBackward(r)?"anchor":"focus");var{anchor:l,focus:c}=r,u={distance:o,unit:i},d={};if(a==null||a==="anchor"){var h=s?I.before(e,l,u):I.after(e,l,u);h&&(d.anchor=h)}if(a==null||a==="focus"){var p=s?I.before(e,c,u):I.after(e,c,u);p&&(d.focus=p)}ce.setSelection(e,d)}},MI=(t,e)=>{var{selection:n}=t;if(e=I.range(t,e),n){ce.setSelection(t,e);return}if(!oe.isRange(e))throw new Error("When setting the selection and the current selection is `null` you must provide at least an `anchor` and `focus`, but you passed: ".concat($t.stringify(e)));t.apply({type:"set_selection",properties:n,newProperties:e})};function vy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function yy(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?vy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):vy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var PI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{selection:o}=e,{edge:i="both"}=r;if(o){i==="start"&&(i=oe.isBackward(o)?"focus":"anchor"),i==="end"&&(i=oe.isBackward(o)?"anchor":"focus");var{anchor:s,focus:a}=o,l=i==="anchor"?s:a;ce.setSelection(e,{[i==="anchor"?"anchor":"focus"]:yy(yy({},l),n)})}},LI=(t,e)=>{var{selection:n}=t,r={},o={};if(n){for(var i in e)(i==="anchor"&&e.anchor!=null&&!Re.equals(e.anchor,n.anchor)||i==="focus"&&e.focus!=null&&!Re.equals(e.focus,n.focus)||i!=="anchor"&&i!=="focus"&&e[i]!==n[i])&&(r[i]=n[i],o[i]=e[i]);Object.keys(r).length>0&&t.apply({type:"set_selection",properties:r,newProperties:o})}},$I=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};I.withoutNormalizing(e,()=>{var{hanging:o=!1,voids:i=!1,mode:s="lowest",batchDirty:a=!0}=r,{at:l,match:c,select:u}=r;if(ge.isNode(n)&&(n=[n]),n.length!==0){var[d]=n;if(l||(l=Of(e),u!==!1&&(u=!0)),u==null&&(u=!1),oe.isRange(l))if(o||(l=I.unhangRange(e,l,{voids:i})),oe.isCollapsed(l))l=l.anchor;else{var[,h]=oe.edges(l),p=I.pointRef(e,h);ce.delete(e,{at:l}),l=p.unref()}if(Re.isPoint(l)){c==null&&(Oe.isText(d)?c=O=>Oe.isText(O):e.isInline(d)?c=O=>Oe.isText(O)||I.isInline(e,O):c=O=>Ae.isElement(O)&&I.isBlock(e,O));var[m]=I.nodes(e,{at:l.path,match:c,mode:s,voids:i});if(m){var[,w]=m,v=I.pathRef(e,w),y=I.isEnd(e,l,w);ce.splitNodes(e,{at:l,match:c,mode:s,voids:i});var g=v.unref();l=y?U.next(g):g}else return}var k=U.parent(l),A=l[l.length-1];if(!(!i&&I.void(e,{at:k}))){if(a){var C=[],E=U.levels(k);bF(e,()=>{var O=function(){var F=k.concat(A);A++;var M={type:"insert_node",path:F,node:B};e.apply(M),l=U.next(l),C.push(M),Oe.isText(B)?E.push(F):E.push(...Array.from(ge.nodes(B),T=>{var[,P]=T;return F.concat(P)}))};for(var B of n)O()},()=>{iy(e,E,O=>{var B=O;for(var N of C)if(U.operationCanTransformPath(N)&&(B=U.transform(B,N),!B))return null;return B})})}else for(var D of n){var S=k.concat(A);A++,e.apply({type:"insert_node",path:S,node:D}),l=U.next(l)}if(l=U.previous(l),u){var _=I.end(e,l);_&&ce.select(e,_)}}}})},HI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};I.withoutNormalizing(e,()=>{var{at:r=e.selection,mode:o="lowest",voids:i=!1}=n,{match:s}=n;if(s==null&&(s=U.isPath(r)?$i(e,r):A=>Ae.isElement(A)&&I.isBlock(e,A)),!!r){var a=I.nodes(e,{at:r,match:s,mode:o,voids:i}),l=Array.from(a,A=>{var[,C]=A;return I.pathRef(e,C)});for(var c of l){var u=c.unref();if(u.length<2)throw new Error("Cannot lift node at a path [".concat(u,"] because it has a depth of less than `2`."));var d=I.node(e,U.parent(u)),[h,p]=d,m=u[u.length-1],{length:w}=h.children;if(w===1){var v=U.next(p);ce.moveNodes(e,{at:u,to:v,voids:i}),ce.removeNodes(e,{at:p,voids:i})}else if(m===0)ce.moveNodes(e,{at:u,to:p,voids:i});else if(m===w-1){var y=U.next(p);ce.moveNodes(e,{at:u,to:y,voids:i})}else{var g=U.next(u),k=U.next(p);ce.splitNodes(e,{at:g,voids:i}),ce.moveNodes(e,{at:u,to:k,voids:i})}}}})},zI=["text"],jI=["children"],by=(t,e)=>{if(Ae.isElement(e)){var n=e;return I.isVoid(t,e)?!0:n.children.length===1?by(t,n.children[0]):!1}else return!I.isEditor(e)},VI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};I.withoutNormalizing(e,()=>{var{match:r,at:o=e.selection}=n,{hanging:i=!1,voids:s=!1,mode:a="lowest"}=n;if(o){if(r==null)if(U.isPath(o)){var[l]=I.parent(e,o);r=O=>l.children.includes(O)}else r=O=>Ae.isElement(O)&&I.isBlock(e,O);if(!i&&oe.isRange(o)&&(o=I.unhangRange(e,o,{voids:s})),oe.isRange(o))if(oe.isCollapsed(o))o=o.anchor;else{var[,c]=oe.edges(o),u=I.pointRef(e,c);ce.delete(e,{at:o}),o=u.unref(),n.at==null&&ce.select(e,o)}var[d]=I.nodes(e,{at:o,match:r,voids:s,mode:a}),h=I.previous(e,{at:o,match:r,voids:s,mode:a});if(!(!d||!h)){var[p,m]=d,[w,v]=h;if(!(m.length===0||v.length===0)){var y=U.next(v),g=U.common(m,v),k=U.isSibling(m,v),A=Array.from(I.levels(e,{at:m}),O=>{var[B]=O;return B}).slice(g.length).slice(0,-1),C=I.above(e,{at:m,mode:"highest",match:O=>A.includes(O)&&by(e,O)}),E=C&&I.pathRef(e,C[1]),D,S;if(Oe.isText(p)&&Oe.isText(w)){var _=Kr(p,zI);S=w.text.length,D=_}else if(Ae.isElement(p)&&Ae.isElement(w)){var _=Kr(p,jI);S=w.children.length,D=_}else throw new Error("Cannot merge the node at path [".concat(m,"] with the previous sibling because it is not the same kind: ").concat($t.stringify(p)," ").concat($t.stringify(w)));k||ce.moveNodes(e,{at:m,to:y,voids:s}),E&&ce.removeNodes(e,{at:E.current,voids:s}),I.shouldMergeNodesRemovePrevNode(e,h,d)?ce.removeNodes(e,{at:v,voids:s}):e.apply({type:"merge_node",path:y,position:S,properties:D}),E&&E.unref()}}}})},WI=(t,e)=>{I.withoutNormalizing(t,()=>{var{to:n,at:r=t.selection,mode:o="lowest",voids:i=!1}=e,{match:s}=e;if(r){s==null&&(s=U.isPath(r)?$i(t,r):p=>Ae.isElement(p)&&I.isBlock(t,p));var a=I.pathRef(t,n),l=I.nodes(t,{at:r,match:s,mode:o,voids:i}),c=Array.from(l,p=>{var[,m]=p;return I.pathRef(t,m)});for(var u of c){var d=u.unref(),h=a.current;d.length!==0&&t.apply({type:"move_node",path:d,newPath:h}),a.current&&U.isSibling(h,d)&&U.isAfter(h,d)&&(a.current=U.next(a.current))}a.unref()}})},UI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};I.withoutNormalizing(e,()=>{var{hanging:r=!1,voids:o=!1,mode:i="lowest"}=n,{at:s=e.selection,match:a}=n;if(s){a==null&&(a=U.isPath(s)?$i(e,s):p=>Ae.isElement(p)&&I.isBlock(e,p)),!r&&oe.isRange(s)&&(s=I.unhangRange(e,s,{voids:o}));var l=I.nodes(e,{at:s,match:a,mode:i,voids:o}),c=Array.from(l,p=>{var[,m]=p;return I.pathRef(e,m)});for(var u of c){var d=u.unref();if(d){var[h]=I.node(e,d);e.apply({type:"remove_node",path:d,node:h})}}}})},qI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};I.withoutNormalizing(e,()=>{var{match:o,at:i=e.selection,compare:s,merge:a}=r,{hanging:l=!1,mode:c="lowest",split:u=!1,voids:d=!1}=r;if(i){if(o==null&&(o=U.isPath(i)?$i(e,i):S=>Ae.isElement(S)&&I.isBlock(e,S)),!l&&oe.isRange(i)&&(i=I.unhangRange(e,i,{voids:d})),u&&oe.isRange(i)){if(oe.isCollapsed(i)&&I.leaf(e,i.anchor)[0].text.length>0)return;var h=I.rangeRef(e,i,{affinity:"inward"}),[p,m]=oe.edges(i),w=c==="lowest"?"lowest":"highest",v=I.isEnd(e,m,m.path);ce.splitNodes(e,{at:m,match:o,mode:w,voids:d,always:!v});var y=I.isStart(e,p,p.path);ce.splitNodes(e,{at:p,match:o,mode:w,voids:d,always:!y}),i=h.unref(),r.at==null&&ce.select(e,i)}s||(s=(S,_)=>S!==_);for(var[g,k]of I.nodes(e,{at:i,match:o,mode:c,voids:d})){var A={},C={};if(k.length!==0){var E=!1;for(var D in n)D==="children"||D==="text"||s(n[D],g[D])&&(E=!0,g.hasOwnProperty(D)&&(A[D]=g[D]),a?n[D]!=null&&(C[D]=a(g[D],n[D])):n[D]!=null&&(C[D]=n[D]));E&&e.apply({type:"set_node",path:k,properties:A,newProperties:C})}}}})},GI=(t,e)=>{if(oe.isCollapsed(e))return e.anchor;var[,n]=oe.edges(e),r=I.pointRef(t,n);return ce.delete(t,{at:e}),r.unref()},KI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};I.withoutNormalizing(e,()=>{var{mode:r="lowest",voids:o=!1}=n,{match:i,at:s=e.selection,height:a=0,always:l=!1}=n;if(i==null&&(i=V=>Ae.isElement(V)&&I.isBlock(e,V)),oe.isRange(s)&&(s=GI(e,s)),U.isPath(s)){var c=s,u=I.point(e,c),[d]=I.parent(e,c);i=V=>V===d,a=u.path.length-c.length+1,s=u,l=!0}if(s){var h=I.pointRef(e,s,{affinity:"backward"}),p;try{var[m]=I.nodes(e,{at:s,match:i,mode:r,voids:o});if(!m)return;var w=I.void(e,{at:s,mode:"highest"}),v=0;if(!o&&w){var[y,g]=w;if(Ae.isElement(y)&&e.isInline(y)){var k=I.after(e,g);if(!k){var A={text:""},C=U.next(g);ce.insertNodes(e,A,{at:C,voids:o}),k=I.point(e,C)}s=k,l=!0}var E=s.path.length-g.length;a=E+1,l=!0}p=I.pointRef(e,s);var D=s.path.length-a,[,S]=m,_=s.path.slice(0,D),O=a===0?s.offset:s.path[D]+v;for(var[B,N]of I.levels(e,{at:_,reverse:!0,voids:o})){var F=!1;if(N.length<S.length||N.length===0||!o&&Ae.isElement(B)&&I.isVoid(e,B))break;var M=h.current,T=I.isEnd(e,M,N);if(l||!h||!I.isEdge(e,M,N)){F=!0;var P=ge.extractProps(B);e.apply({type:"split_node",path:N,position:O,properties:P})}O=N[N.length-1]+(F||T?1:0)}if(n.at==null){var $=p.current||I.end(e,[]);ce.select(e,$)}}finally{var W;h.unref(),(W=p)===null||W===void 0||W.unref()}}})},YI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};Array.isArray(n)||(n=[n]);var o={};for(var i of n)o[i]=null;ce.setNodes(e,o,r)},XI=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};I.withoutNormalizing(e,()=>{var{mode:r="lowest",split:o=!1,voids:i=!1}=n,{at:s=e.selection,match:a}=n;if(s){a==null&&(a=U.isPath(s)?$i(e,s):p=>Ae.isElement(p)&&I.isBlock(e,p)),U.isPath(s)&&(s=I.range(e,s));var l=oe.isRange(s)?I.rangeRef(e,s):null,c=I.nodes(e,{at:s,match:a,mode:r,voids:i}),u=Array.from(c,p=>{var[,m]=p;return I.pathRef(e,m)}).reverse(),d=function(){var m=h.unref(),[w]=I.node(e,m),v=I.range(e,m);o&&l&&(v=oe.intersection(l.current,v)),ce.liftNodes(e,{at:v,match:y=>Ae.isAncestor(w)&&w.children.includes(y),voids:i})};for(var h of u)d();l&&l.unref()}})};function Cy(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function ky(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Cy(Object(n),!0).forEach(function(r){Yt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Cy(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var JI=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{};I.withoutNormalizing(e,()=>{var{mode:o="lowest",split:i=!1,voids:s=!1}=r,{match:a,at:l=e.selection}=r;if(l){if(a==null&&(U.isPath(l)?a=$i(e,l):e.isInline(n)?a=y=>Ae.isElement(y)&&I.isInline(e,y)||Oe.isText(y):a=y=>Ae.isElement(y)&&I.isBlock(e,y)),i&&oe.isRange(l)){var[c,u]=oe.edges(l),d=I.rangeRef(e,l,{affinity:"inward"}),h=y=>{var g=I.above(e,{at:y,match:k=>Ae.isElement(k)&&I.isBlock(e,k)});return g&&I.isEdge(e,y,g[1])};ce.splitNodes(e,{at:u,match:a,voids:s,always:!h(u)}),ce.splitNodes(e,{at:c,match:a,voids:s,always:!h(c)}),l=d.unref(),r.at==null&&ce.select(e,l)}var p=Array.from(I.nodes(e,{at:l,match:e.isInline(n)?y=>Ae.isElement(y)&&I.isBlock(e,y):y=>I.isEditor(y),mode:"lowest",voids:s})),m=function(){var g=oe.isRange(l)?oe.intersection(l,I.range(e,v)):l;if(!g)return 0;var k=Array.from(I.nodes(e,{at:g,match:a,mode:o,voids:s}));if(k.length>0){var[A]=k,C=k[k.length-1],[,E]=A,[,D]=C;if(E.length===0&&D.length===0)return 0;var S=U.equals(E,D)?U.parent(E):U.common(E,D),_=I.range(e,E,D),O=I.node(e,S),[B]=O,N=S.length+1,F=U.next(D.slice(0,N)),M=ky(ky({},n),{},{children:[]});ce.insertNodes(e,M,{at:F,voids:s}),ce.moveNodes(e,{at:_,match:T=>Ae.isAncestor(B)&&B.children.includes(T),to:F.concat(0),voids:s})}},w;for(var[,v]of p)w=m()}})},xy=()=>{var t={children:[],operations:[],selection:null,marks:null,isElementReadOnly:()=>!1,isInline:()=>!1,isSelectable:()=>!0,isVoid:()=>!1,markableVoid:()=>!1,onChange:()=>{},apply:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return CF(t,...r)},addMark:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return AF(t,...r)},deleteBackward:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return _F(t,...r)},deleteForward:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return NF(t,...r)},deleteFragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return BF(t,...r)},getFragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return xF(t,...r)},insertBreak:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return WF(t,...r)},insertSoftBreak:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return qF(t,...r)},insertFragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return NI(t,...r)},insertNode:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return UF(t,...r)},insertText:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return KF(t,...r)},normalizeNode:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return SF(t,...r)},removeMark:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return xI(t,...r)},getDirtyPaths:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return kF(t,...r)},shouldNormalize:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return EF(t,...r)},above:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return DF(t,...r)},after:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return OF(t,...r)},before:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return TF(t,...r)},collapse:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return BI(t,...r)},delete:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return _I(t,...r)},deselect:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return FI(t,...r)},edges:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return FF(t,...r)},elementReadOnly:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return IF(t,...r)},end:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return MF(t,...r)},first:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return PF(t,...r)},fragment:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return LF(t,...r)},getMarks:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return iI(t,...r)},hasBlocks:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return HF(t,...r)},hasInlines:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return zF(t,...r)},hasPath:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return jF(t,...r)},hasTexts:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return VF(t,...r)},insertNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return $I(t,...r)},isBlock:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return YF(t,...r)},isEdge:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return XF(t,...r)},isEmpty:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return JF(t,...r)},isEnd:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return RF(t,...r)},isNormalizing:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return QF(t,...r)},isStart:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return ZF(t,...r)},last:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return eI(t,...r)},leaf:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return tI(t,...r)},levels:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return nI(t,...r)},liftNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return HI(t,...r)},mergeNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return VI(t,...r)},move:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return II(t,...r)},moveNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return WI(t,...r)},next:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return sI(t,...r)},node:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return aI(t,...r)},nodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return lI(t,...r)},normalize:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return cI(t,...r)},parent:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return uI(t,...r)},path:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return hI(t,...r)},pathRef:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return dI(t,...r)},pathRefs:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return fI(t,...r)},point:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return gI(t,...r)},pointRef:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return pI(t,...r)},pointRefs:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return mI(t,...r)},positions:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return wI(t,...r)},previous:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return vI(t,...r)},range:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return CI(t,...r)},rangeRef:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return yI(t,...r)},rangeRefs:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return bI(t,...r)},removeNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return UI(t,...r)},select:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return MI(t,...r)},setNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return qI(t,...r)},setNormalizing:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return SI(t,...r)},setPoint:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return PI(t,...r)},setSelection:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return LI(t,...r)},splitNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return KI(t,...r)},start:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return EI(t,...r)},string:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return DI(t,...r)},unhangRange:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return AI(t,...r)},unsetNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return YI(t,...r)},unwrapNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return XI(t,...r)},void:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return $F(t,...r)},withoutNormalizing:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return OI(t,...r)},wrapNodes:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return JI(t,...r)},shouldMergeNodesRemovePrevNode:function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return TI(t,...r)}};return t};/*!
|
|
13
13
|
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
14
14
|
*
|
|
15
15
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
16
16
|
* Released under the MIT License.
|
|
17
|
-
*/function Sy(t){return Object.prototype.toString.call(t)==="[object Object]"}function RI(t){var e,n;return Sy(t)===!1?!1:(e=t.constructor,e===void 0?!0:(n=e.prototype,!(Sy(n)===!1||n.hasOwnProperty("isPrototypeOf")===!1)))}var QI={isHistory(t){return RI(t)&&Array.isArray(t.redos)&&Array.isArray(t.undos)&&(t.redos.length===0||uo.isOperationList(t.redos[0].operations))&&(t.undos.length===0||uo.isOperationList(t.undos[0].operations))}},Ff=new WeakMap,Yo=new WeakMap,ac=new WeakMap,kr={isHistoryEditor(t){return QI.isHistory(t.history)&&I.isEditor(t)},isMerging(t){return Yo.get(t)},isSplittingOnce(t){return ac.get(t)},setSplittingOnce(t,e){ac.set(t,e)},isSaving(t){return Ff.get(t)},redo(t){t.redo()},undo(t){t.undo()},withMerging(t,e){var n=kr.isMerging(t);Yo.set(t,!0),e(),Yo.set(t,n)},withNewBatch(t,e){var n=kr.isMerging(t);Yo.set(t,!0),ac.set(t,!0),e(),Yo.set(t,n),ac.delete(t)},withoutMerging(t,e){var n=kr.isMerging(t);Yo.set(t,!1),e(),Yo.set(t,n)},withoutSaving(t,e){var n=kr.isSaving(t);Ff.set(t,!1);try{e()}finally{Ff.set(t,n)}}},ZI=t=>{var e=t,{apply:n}=e;return e.history={undos:[],redos:[]},e.redo=()=>{var{history:r}=e,{redos:o}=r;if(o.length>0){var i=o[o.length-1];i.selectionBefore&&ce.setSelection(e,i.selectionBefore),kr.withoutSaving(e,()=>{I.withoutNormalizing(e,()=>{for(var s of i.operations)e.apply(s)})}),r.redos.pop(),e.writeHistory("undos",i)}},e.undo=()=>{var{history:r}=e,{undos:o}=r;if(o.length>0){var i=o[o.length-1];kr.withoutSaving(e,()=>{I.withoutNormalizing(e,()=>{var s=i.operations.map(uo.inverse).reverse();for(var a of s)e.apply(a);i.selectionBefore&&ce.setSelection(e,i.selectionBefore)})}),e.writeHistory("redos",i),r.undos.pop()}},e.apply=r=>{var{operations:o,history:i}=e,{undos:s}=i,a=s[s.length-1],l=a&&a.operations[a.operations.length-1],c=kr.isSaving(e),u=kr.isMerging(e);if(c==null&&(c=tM(r)),c){if(u==null&&(a==null?u=!1:o.length!==0?u=!0:u=eM(r,l)),kr.isSplittingOnce(e)&&(u=!1,kr.setSplittingOnce(e,void 0)),a&&u)a.operations.push(r);else{var d={operations:[r],selectionBefore:e.selection};e.writeHistory("undos",d)}for(;s.length>100;)s.shift();i.redos=[]}n(r)},e.writeHistory=(r,o)=>{e.history[r].push(o)},e},eM=(t,e)=>!!(e&&t.type==="insert_text"&&e.type==="insert_text"&&t.offset===e.offset+e.text.length&&U.equals(t.path,e.path)||e&&t.type==="remove_text"&&e.type==="remove_text"&&t.offset+t.text.length===e.offset&&U.equals(t.path,e.path)),tM=(t,e)=>t.type!=="set_selection",If,Ey;function nM(){if(Ey)return If;Ey=1,If=o;var t="֑-߿יִ-﷽ﹰ-ﻼ",e="A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--",n=new RegExp("^[^"+e+"]*["+t+"]"),r=new RegExp("^[^"+t+"]*["+e+"]");function o(i){return i=String(i||""),n.test(i)?"rtl":r.test(i)?"ltr":"neutral"}return If}var rM=nM();const Dy=Ii(rM);var Mf,Ay;function Pf(){if(Ay)return Mf;Ay=1;function t(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}return Mf=t,Mf}var Lf,Oy;function oM(){if(Oy)return Lf;Oy=1;var t=typeof Yl=="object"&&Yl&&Yl.Object===Object&&Yl;return Lf=t,Lf}var $f,Ty;function _y(){if(Ty)return $f;Ty=1;var t=oM(),e=typeof self=="object"&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return $f=n,$f}var Hf,Ny;function iM(){if(Ny)return Hf;Ny=1;var t=_y(),e=function(){return t.Date.now()};return Hf=e,Hf}var zf,By;function sM(){if(By)return zf;By=1;var t=/\s/;function e(n){for(var r=n.length;r--&&t.test(n.charAt(r)););return r}return zf=e,zf}var jf,Fy;function aM(){if(Fy)return jf;Fy=1;var t=sM(),e=/^\s+/;function n(r){return r&&r.slice(0,t(r)+1).replace(e,"")}return jf=n,jf}var Vf,Iy;function My(){if(Iy)return Vf;Iy=1;var t=_y(),e=t.Symbol;return Vf=e,Vf}var Wf,Py;function lM(){if(Py)return Wf;Py=1;var t=My(),e=Object.prototype,n=e.hasOwnProperty,r=e.toString,o=t?t.toStringTag:void 0;function i(s){var a=n.call(s,o),l=s[o];try{s[o]=void 0;var c=!0}catch{}var u=r.call(s);return c&&(a?s[o]=l:delete s[o]),u}return Wf=i,Wf}var Uf,Ly;function cM(){if(Ly)return Uf;Ly=1;var t=Object.prototype,e=t.toString;function n(r){return e.call(r)}return Uf=n,Uf}var qf,$y;function uM(){if($y)return qf;$y=1;var t=My(),e=lM(),n=cM(),r="[object Null]",o="[object Undefined]",i=t?t.toStringTag:void 0;function s(a){return a==null?a===void 0?o:r:i&&i in Object(a)?e(a):n(a)}return qf=s,qf}var Gf,Hy;function dM(){if(Hy)return Gf;Hy=1;function t(e){return e!=null&&typeof e=="object"}return Gf=t,Gf}var Kf,zy;function fM(){if(zy)return Kf;zy=1;var t=uM(),e=dM(),n="[object Symbol]";function r(o){return typeof o=="symbol"||e(o)&&t(o)==n}return Kf=r,Kf}var Yf,jy;function hM(){if(jy)return Yf;jy=1;var t=aM(),e=Pf(),n=fM(),r=NaN,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function l(c){if(typeof c=="number")return c;if(n(c))return r;if(e(c)){var u=typeof c.valueOf=="function"?c.valueOf():c;c=e(u)?u+"":u}if(typeof c!="string")return c===0?c:+c;c=t(c);var d=i.test(c);return d||s.test(c)?a(c.slice(2),d?2:8):o.test(c)?r:+c}return Yf=l,Yf}var Xf,Vy;function Wy(){if(Vy)return Xf;Vy=1;var t=Pf(),e=iM(),n=hM(),r="Expected a function",o=Math.max,i=Math.min;function s(a,l,c){var u,d,h,p,m,w,v=0,y=!1,g=!1,k=!0;if(typeof a!="function")throw new TypeError(r);l=n(l)||0,t(c)&&(y=!!c.leading,g="maxWait"in c,h=g?o(n(c.maxWait)||0,l):h,k="trailing"in c?!!c.trailing:k);function A(F){var M=u,T=d;return u=d=void 0,v=F,p=a.apply(T,M),p}function C(F){return v=F,m=setTimeout(S,l),y?A(F):p}function E(F){var M=F-w,T=F-v,P=l-M;return g?i(P,h-T):P}function D(F){var M=F-w,T=F-v;return w===void 0||M>=l||M<0||g&&T>=h}function S(){var F=e();if(D(F))return _(F);m=setTimeout(S,E(F))}function _(F){return m=void 0,k&&u?A(F):(u=d=void 0,p)}function O(){m!==void 0&&clearTimeout(m),v=0,u=w=d=m=void 0}function B(){return m===void 0?p:_(e())}function N(){var F=e(),M=D(F);if(u=arguments,d=this,w=F,M){if(m===void 0)return C(w);if(g)return clearTimeout(m),m=setTimeout(S,l),A(w)}return m===void 0&&(m=setTimeout(S,l)),p}return N.cancel=O,N.flush=B,N}return Xf=s,Xf}var pM=Wy();const mM=Ii(pM);var Jf,Uy;function gM(){if(Uy)return Jf;Uy=1;var t=Wy(),e=Pf(),n="Expected a function";function r(o,i,s){var a=!0,l=!0;if(typeof o!="function")throw new TypeError(n);return e(s)&&(a="leading"in s?!!s.leading:a,l="trailing"in s?!!s.trailing:l),t(o,i,{leading:a,maxWait:i,trailing:l})}return Jf=r,Jf}var wM=gM();const vM=Ii(wM),qy=t=>typeof t=="object"&&t!=null&&t.nodeType===1,Gy=(t,e)=>(!e||t!=="hidden")&&t!=="visible"&&t!=="clip",lc=(t,e)=>{if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){const n=getComputedStyle(t,null);return Gy(n.overflowY,e)||Gy(n.overflowX,e)||(r=>{const o=(i=>{if(!i.ownerDocument||!i.ownerDocument.defaultView)return null;try{return i.ownerDocument.defaultView.frameElement}catch{return null}})(r);return!!o&&(o.clientHeight<r.scrollHeight||o.clientWidth<r.scrollWidth)})(t)}return!1},cc=(t,e,n,r,o,i,s,a)=>i<t&&s>e||i>t&&s<e?0:i<=t&&a<=n||s>=e&&a>=n?i-t-r:s>e&&a<n||i<t&&a>n?s-e+o:0,yM=t=>{const e=t.parentElement;return e??(t.getRootNode().host||null)},Ky=(t,e)=>{var n,r,o,i;if(typeof document>"u")return[];const{scrollMode:s,block:a,inline:l,boundary:c,skipOverflowHiddenElements:u}=e,d=typeof c=="function"?c:P=>P!==c;if(!qy(t))throw new TypeError("Invalid target");const h=document.scrollingElement||document.documentElement,p=[];let m=t;for(;qy(m)&&d(m);){if(m=yM(m),m===h){p.push(m);break}m!=null&&m===document.body&&lc(m)&&!lc(document.documentElement)||m!=null&&lc(m,u)&&p.push(m)}const w=(r=(n=window.visualViewport)==null?void 0:n.width)!=null?r:innerWidth,v=(i=(o=window.visualViewport)==null?void 0:o.height)!=null?i:innerHeight,{scrollX:y,scrollY:g}=window,{height:k,width:A,top:C,right:E,bottom:D,left:S}=t.getBoundingClientRect(),{top:_,right:O,bottom:B,left:N}=(P=>{const $=window.getComputedStyle(P);return{top:parseFloat($.scrollMarginTop)||0,right:parseFloat($.scrollMarginRight)||0,bottom:parseFloat($.scrollMarginBottom)||0,left:parseFloat($.scrollMarginLeft)||0}})(t);let F=a==="start"||a==="nearest"?C-_:a==="end"?D+B:C+k/2-_+B,M=l==="center"?S+A/2-N+O:l==="end"?E+O:S-N;const T=[];for(let P=0;P<p.length;P++){const $=p[P],{height:W,width:V,top:X,right:G,bottom:te,left:H}=$.getBoundingClientRect();if(s==="if-needed"&&C>=0&&S>=0&&D<=v&&E<=w&&($===h&&!lc($)||C>=X&&D<=te&&S>=H&&E<=G))return T;const j=getComputedStyle($),Y=parseInt(j.borderLeftWidth,10),se=parseInt(j.borderTopWidth,10),Q=parseInt(j.borderRightWidth,10),le=parseInt(j.borderBottomWidth,10);let L=0,q=0;const J="offsetWidth"in $?$.offsetWidth-$.clientWidth-Y-Q:0,K="offsetHeight"in $?$.offsetHeight-$.clientHeight-se-le:0,re="offsetWidth"in $?$.offsetWidth===0?0:V/$.offsetWidth:0,ie="offsetHeight"in $?$.offsetHeight===0?0:W/$.offsetHeight:0;if(h===$)L=a==="start"?F:a==="end"?F-v:a==="nearest"?cc(g,g+v,v,se,le,g+F,g+F+k,k):F-v/2,q=l==="start"?M:l==="center"?M-w/2:l==="end"?M-w:cc(y,y+w,w,Y,Q,y+M,y+M+A,A),L=Math.max(0,L+g),q=Math.max(0,q+y);else{L=a==="start"?F-X-se:a==="end"?F-te+le+K:a==="nearest"?cc(X,te,W,se,le+K,F,F+k,k):F-(X+W/2)+K/2,q=l==="start"?M-H-Y:l==="center"?M-(H+V/2)+J/2:l==="end"?M-G+Q+J:cc(H,G,V,Y,Q+J,M,M+A,A);const{scrollLeft:he,scrollTop:Ce}=$;L=ie===0?0:Math.max(0,Math.min(Ce+L/ie,$.scrollHeight-W/ie+K)),q=re===0?0:Math.max(0,Math.min(he+q/re,$.scrollWidth-V/re+J)),F+=Ce-L,M+=he-q}T.push({el:$,top:L,left:q})}return T},bM=t=>t===!1?{block:"end",inline:"nearest"}:(e=>e===Object(e)&&Object.keys(e).length!==0)(t)?t:{block:"start",inline:"nearest"};function CM(t,e){if(!t.isConnected||!(o=>{let i=o;for(;i&&i.parentNode;){if(i.parentNode===document)return!0;i=i.parentNode instanceof ShadowRoot?i.parentNode.host:i.parentNode}return!1})(t))return;const n=(o=>{const i=window.getComputedStyle(o);return{top:parseFloat(i.scrollMarginTop)||0,right:parseFloat(i.scrollMarginRight)||0,bottom:parseFloat(i.scrollMarginBottom)||0,left:parseFloat(i.scrollMarginLeft)||0}})(t);if((o=>typeof o=="object"&&typeof o.behavior=="function")(e))return e.behavior(Ky(t,e));const r=typeof e=="boolean"||e==null?void 0:e.behavior;for(const{el:o,top:i,left:s}of Ky(t,bM(e))){const a=i-n.top+n.bottom,l=s-n.left+n.right;o.scroll({top:a,left:l,behavior:r})}}var sr={},Yy;function kM(){if(Yy)return sr;Yy=1,Object.defineProperty(sr,"__esModule",{value:!0});for(var t=typeof window<"u"&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),e={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},n={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:t?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},r={backspace:8,tab:9,enter:13,shift:16,control:17,alt:18,pause:19,capslock:20,escape:27," ":32,pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,insert:45,delete:46,meta:91,numlock:144,scrolllock:145,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},o=1;o<20;o++)r["f"+o]=111+o;function i(h,p,m){p&&!("byKey"in p)&&(m=p,p=null),Array.isArray(h)||(h=[h]);var w=h.map(function(g){return l(g,p)}),v=function(k){return w.some(function(A){return c(A,k)})},y=m==null?v:v(m);return y}function s(h,p){return i(h,p)}function a(h,p){return i(h,{byKey:!0},p)}function l(h,p){var m=p&&p.byKey,w={};h=h.replace("++","+add");var v=h.split("+"),y=v.length;for(var g in e)w[e[g]]=!1;var k=!0,A=!1,C=void 0;try{for(var E=v[Symbol.iterator](),D;!(k=(D=E.next()).done);k=!0){var S=D.value,_=S.endsWith("?")&&S.length>1;_&&(S=S.slice(0,-1));var O=d(S),B=e[O];if(S.length>1&&!B&&!n[S]&&!r[O])throw new TypeError('Unknown modifier: "'+S+'"');(y===1||!B)&&(m?w.key=O:w.which=u(S)),B&&(w[B]=_?null:!0)}}catch(N){A=!0,C=N}finally{try{!k&&E.return&&E.return()}finally{if(A)throw C}}return w}function c(h,p){for(var m in h){var w=h[m],v=void 0;if(w!=null&&(m==="key"&&p.key!=null?v=p.key.toLowerCase():m==="which"?v=w===91&&p.which===93?91:p.which:v=p[m],!(v==null&&w===!1)&&v!==w))return!1}return!0}function u(h){h=d(h);var p=r[h]||h.toUpperCase().charCodeAt(0);return p}function d(h){return h=h.toLowerCase(),h=n[h]||h,h}return sr.default=i,sr.isHotkey=i,sr.isCodeHotkey=s,sr.isKeyHotkey=a,sr.parseHotkey=l,sr.compareHotkey=c,sr.toKeyCode=u,sr.toKeyName=d,sr}var Rf=kM(),Xy=globalThis.Node,xM=globalThis.Text,Qf=t=>t&&t.ownerDocument&&t.ownerDocument.defaultView||null,SM=t=>fo(t)&&t.nodeType===8,Gn=t=>fo(t)&&t.nodeType===1,fo=t=>{var e=Qf(t);return!!e&&t instanceof e.Node},Zf=t=>{var e=t&&t.anchorNode&&Qf(t.anchorNode);return!!e&&t instanceof e.Selection},Jy=t=>fo(t)&&t.nodeType===3,EM=t=>t.clipboardData&&t.clipboardData.getData("text/plain")!==""&&t.clipboardData.types.length===1,DM=t=>{var[e,n]=t;if(Gn(e)&&e.childNodes.length){var r=n===e.childNodes.length,o=r?n-1:n;for([e,o]=Ry(e,o,r?"backward":"forward"),r=o<n;Gn(e)&&e.childNodes.length;){var i=r?e.childNodes.length-1:0;e=OM(e,i,r?"backward":"forward")}n=r&&e.textContent!=null?e.textContent.length:0}return[e,n]},AM=t=>{for(var e=t&&t.parentNode;e;){if(e.toString()==="[object ShadowRoot]")return!0;e=e.parentNode}return!1},Ry=(t,e,n)=>{for(var{childNodes:r}=t,o=r[e],i=e,s=!1,a=!1;(SM(o)||Gn(o)&&o.childNodes.length===0||Gn(o)&&o.getAttribute("contenteditable")==="false")&&!(s&&a);){if(i>=r.length){s=!0,i=e-1,n="backward";continue}if(i<0){a=!0,i=e+1,n="forward";continue}o=r[i],e=i,i+=n==="forward"?1:-1}return[o,e]},OM=(t,e,n)=>{var[r]=Ry(t,e,n);return r},Qy=t=>{var e="";if(Jy(t)&&t.nodeValue)return t.nodeValue;if(Gn(t)){for(var n of Array.from(t.childNodes))e+=Qy(n);var r=getComputedStyle(t).getPropertyValue("display");(r==="block"||r==="list"||t.tagName==="BR")&&(e+=`
|
|
17
|
+
*/function Sy(t){return Object.prototype.toString.call(t)==="[object Object]"}function RI(t){var e,n;return Sy(t)===!1?!1:(e=t.constructor,e===void 0?!0:(n=e.prototype,!(Sy(n)===!1||n.hasOwnProperty("isPrototypeOf")===!1)))}var QI={isHistory(t){return RI(t)&&Array.isArray(t.redos)&&Array.isArray(t.undos)&&(t.redos.length===0||uo.isOperationList(t.redos[0].operations))&&(t.undos.length===0||uo.isOperationList(t.undos[0].operations))}},Ff=new WeakMap,Yo=new WeakMap,ac=new WeakMap,kr={isHistoryEditor(t){return QI.isHistory(t.history)&&I.isEditor(t)},isMerging(t){return Yo.get(t)},isSplittingOnce(t){return ac.get(t)},setSplittingOnce(t,e){ac.set(t,e)},isSaving(t){return Ff.get(t)},redo(t){t.redo()},undo(t){t.undo()},withMerging(t,e){var n=kr.isMerging(t);Yo.set(t,!0),e(),Yo.set(t,n)},withNewBatch(t,e){var n=kr.isMerging(t);Yo.set(t,!0),ac.set(t,!0),e(),Yo.set(t,n),ac.delete(t)},withoutMerging(t,e){var n=kr.isMerging(t);Yo.set(t,!1),e(),Yo.set(t,n)},withoutSaving(t,e){var n=kr.isSaving(t);Ff.set(t,!1);try{e()}finally{Ff.set(t,n)}}},ZI=t=>{var e=t,{apply:n}=e;return e.history={undos:[],redos:[]},e.redo=()=>{var{history:r}=e,{redos:o}=r;if(o.length>0){var i=o[o.length-1];i.selectionBefore&&ce.setSelection(e,i.selectionBefore),kr.withoutSaving(e,()=>{I.withoutNormalizing(e,()=>{for(var s of i.operations)e.apply(s)})}),r.redos.pop(),e.writeHistory("undos",i)}},e.undo=()=>{var{history:r}=e,{undos:o}=r;if(o.length>0){var i=o[o.length-1];kr.withoutSaving(e,()=>{I.withoutNormalizing(e,()=>{var s=i.operations.map(uo.inverse).reverse();for(var a of s)e.apply(a);i.selectionBefore&&ce.setSelection(e,i.selectionBefore)})}),e.writeHistory("redos",i),r.undos.pop()}},e.apply=r=>{var{operations:o,history:i}=e,{undos:s}=i,a=s[s.length-1],l=a&&a.operations[a.operations.length-1],c=kr.isSaving(e),u=kr.isMerging(e);if(c==null&&(c=tM(r)),c){if(u==null&&(a==null?u=!1:o.length!==0?u=!0:u=eM(r,l)),kr.isSplittingOnce(e)&&(u=!1,kr.setSplittingOnce(e,void 0)),a&&u)a.operations.push(r);else{var d={operations:[r],selectionBefore:e.selection};e.writeHistory("undos",d)}for(;s.length>100;)s.shift();i.redos=[]}n(r)},e.writeHistory=(r,o)=>{e.history[r].push(o)},e},eM=(t,e)=>!!(e&&t.type==="insert_text"&&e.type==="insert_text"&&t.offset===e.offset+e.text.length&&U.equals(t.path,e.path)||e&&t.type==="remove_text"&&e.type==="remove_text"&&t.offset+t.text.length===e.offset&&U.equals(t.path,e.path)),tM=(t,e)=>t.type!=="set_selection",If,Ey;function nM(){if(Ey)return If;Ey=1,If=o;var t="֑-߿יִ-﷽ﹰ-ﻼ",e="A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--",n=new RegExp("^[^"+e+"]*["+t+"]"),r=new RegExp("^[^"+t+"]*["+e+"]");function o(i){return i=String(i||""),n.test(i)?"rtl":r.test(i)?"ltr":"neutral"}return If}var rM=nM();const Dy=Ii(rM);var Mf,Ay;function Pf(){if(Ay)return Mf;Ay=1;function t(e){var n=typeof e;return e!=null&&(n=="object"||n=="function")}return Mf=t,Mf}var Lf,Oy;function oM(){if(Oy)return Lf;Oy=1;var t=typeof Yl=="object"&&Yl&&Yl.Object===Object&&Yl;return Lf=t,Lf}var $f,Ty;function _y(){if(Ty)return $f;Ty=1;var t=oM(),e=typeof self=="object"&&self&&self.Object===Object&&self,n=t||e||Function("return this")();return $f=n,$f}var Hf,Ny;function iM(){if(Ny)return Hf;Ny=1;var t=_y(),e=function(){return t.Date.now()};return Hf=e,Hf}var zf,By;function sM(){if(By)return zf;By=1;var t=/\s/;function e(n){for(var r=n.length;r--&&t.test(n.charAt(r)););return r}return zf=e,zf}var jf,Fy;function aM(){if(Fy)return jf;Fy=1;var t=sM(),e=/^\s+/;function n(r){return r&&r.slice(0,t(r)+1).replace(e,"")}return jf=n,jf}var Vf,Iy;function My(){if(Iy)return Vf;Iy=1;var t=_y(),e=t.Symbol;return Vf=e,Vf}var Wf,Py;function lM(){if(Py)return Wf;Py=1;var t=My(),e=Object.prototype,n=e.hasOwnProperty,r=e.toString,o=t?t.toStringTag:void 0;function i(s){var a=n.call(s,o),l=s[o];try{s[o]=void 0;var c=!0}catch{}var u=r.call(s);return c&&(a?s[o]=l:delete s[o]),u}return Wf=i,Wf}var Uf,Ly;function cM(){if(Ly)return Uf;Ly=1;var t=Object.prototype,e=t.toString;function n(r){return e.call(r)}return Uf=n,Uf}var qf,$y;function uM(){if($y)return qf;$y=1;var t=My(),e=lM(),n=cM(),r="[object Null]",o="[object Undefined]",i=t?t.toStringTag:void 0;function s(a){return a==null?a===void 0?o:r:i&&i in Object(a)?e(a):n(a)}return qf=s,qf}var Gf,Hy;function dM(){if(Hy)return Gf;Hy=1;function t(e){return e!=null&&typeof e=="object"}return Gf=t,Gf}var Kf,zy;function fM(){if(zy)return Kf;zy=1;var t=uM(),e=dM(),n="[object Symbol]";function r(o){return typeof o=="symbol"||e(o)&&t(o)==n}return Kf=r,Kf}var Yf,jy;function hM(){if(jy)return Yf;jy=1;var t=aM(),e=Pf(),n=fM(),r=NaN,o=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,s=/^0o[0-7]+$/i,a=parseInt;function l(c){if(typeof c=="number")return c;if(n(c))return r;if(e(c)){var u=typeof c.valueOf=="function"?c.valueOf():c;c=e(u)?u+"":u}if(typeof c!="string")return c===0?c:+c;c=t(c);var d=i.test(c);return d||s.test(c)?a(c.slice(2),d?2:8):o.test(c)?r:+c}return Yf=l,Yf}var Xf,Vy;function Wy(){if(Vy)return Xf;Vy=1;var t=Pf(),e=iM(),n=hM(),r="Expected a function",o=Math.max,i=Math.min;function s(a,l,c){var u,d,h,p,m,w,v=0,y=!1,g=!1,k=!0;if(typeof a!="function")throw new TypeError(r);l=n(l)||0,t(c)&&(y=!!c.leading,g="maxWait"in c,h=g?o(n(c.maxWait)||0,l):h,k="trailing"in c?!!c.trailing:k);function A(F){var M=u,T=d;return u=d=void 0,v=F,p=a.apply(T,M),p}function C(F){return v=F,m=setTimeout(S,l),y?A(F):p}function E(F){var M=F-w,T=F-v,P=l-M;return g?i(P,h-T):P}function D(F){var M=F-w,T=F-v;return w===void 0||M>=l||M<0||g&&T>=h}function S(){var F=e();if(D(F))return _(F);m=setTimeout(S,E(F))}function _(F){return m=void 0,k&&u?A(F):(u=d=void 0,p)}function O(){m!==void 0&&clearTimeout(m),v=0,u=w=d=m=void 0}function B(){return m===void 0?p:_(e())}function N(){var F=e(),M=D(F);if(u=arguments,d=this,w=F,M){if(m===void 0)return C(w);if(g)return clearTimeout(m),m=setTimeout(S,l),A(w)}return m===void 0&&(m=setTimeout(S,l)),p}return N.cancel=O,N.flush=B,N}return Xf=s,Xf}var pM=Wy();const mM=Ii(pM);var Jf,Uy;function gM(){if(Uy)return Jf;Uy=1;var t=Wy(),e=Pf(),n="Expected a function";function r(o,i,s){var a=!0,l=!0;if(typeof o!="function")throw new TypeError(n);return e(s)&&(a="leading"in s?!!s.leading:a,l="trailing"in s?!!s.trailing:l),t(o,i,{leading:a,maxWait:i,trailing:l})}return Jf=r,Jf}var wM=gM();const vM=Ii(wM),qy=t=>typeof t=="object"&&t!=null&&t.nodeType===1,Gy=(t,e)=>(!e||t!=="hidden")&&t!=="visible"&&t!=="clip",lc=(t,e)=>{if(t.clientHeight<t.scrollHeight||t.clientWidth<t.scrollWidth){const n=getComputedStyle(t,null);return Gy(n.overflowY,e)||Gy(n.overflowX,e)||(r=>{const o=(i=>{if(!i.ownerDocument||!i.ownerDocument.defaultView)return null;try{return i.ownerDocument.defaultView.frameElement}catch{return null}})(r);return!!o&&(o.clientHeight<r.scrollHeight||o.clientWidth<r.scrollWidth)})(t)}return!1},cc=(t,e,n,r,o,i,s,a)=>i<t&&s>e||i>t&&s<e?0:i<=t&&a<=n||s>=e&&a>=n?i-t-r:s>e&&a<n||i<t&&a>n?s-e+o:0,yM=t=>{const e=t.parentElement;return e??(t.getRootNode().host||null)},Ky=(t,e)=>{var n,r,o,i;if(typeof document>"u")return[];const{scrollMode:s,block:a,inline:l,boundary:c,skipOverflowHiddenElements:u}=e,d=typeof c=="function"?c:P=>P!==c;if(!qy(t))throw new TypeError("Invalid target");const h=document.scrollingElement||document.documentElement,p=[];let m=t;for(;qy(m)&&d(m);){if(m=yM(m),m===h){p.push(m);break}m!=null&&m===document.body&&lc(m)&&!lc(document.documentElement)||m!=null&&lc(m,u)&&p.push(m)}const w=(r=(n=window.visualViewport)==null?void 0:n.width)!=null?r:innerWidth,v=(i=(o=window.visualViewport)==null?void 0:o.height)!=null?i:innerHeight,{scrollX:y,scrollY:g}=window,{height:k,width:A,top:C,right:E,bottom:D,left:S}=t.getBoundingClientRect(),{top:_,right:O,bottom:B,left:N}=(P=>{const $=window.getComputedStyle(P);return{top:parseFloat($.scrollMarginTop)||0,right:parseFloat($.scrollMarginRight)||0,bottom:parseFloat($.scrollMarginBottom)||0,left:parseFloat($.scrollMarginLeft)||0}})(t);let F=a==="start"||a==="nearest"?C-_:a==="end"?D+B:C+k/2-_+B,M=l==="center"?S+A/2-N+O:l==="end"?E+O:S-N;const T=[];for(let P=0;P<p.length;P++){const $=p[P],{height:W,width:V,top:X,right:G,bottom:te,left:H}=$.getBoundingClientRect();if(s==="if-needed"&&C>=0&&S>=0&&D<=v&&E<=w&&($===h&&!lc($)||C>=X&&D<=te&&S>=H&&E<=G))return T;const j=getComputedStyle($),Y=parseInt(j.borderLeftWidth,10),ie=parseInt(j.borderTopWidth,10),Q=parseInt(j.borderRightWidth,10),le=parseInt(j.borderBottomWidth,10);let L=0,q=0;const J="offsetWidth"in $?$.offsetWidth-$.clientWidth-Y-Q:0,K="offsetHeight"in $?$.offsetHeight-$.clientHeight-ie-le:0,re="offsetWidth"in $?$.offsetWidth===0?0:V/$.offsetWidth:0,se="offsetHeight"in $?$.offsetHeight===0?0:W/$.offsetHeight:0;if(h===$)L=a==="start"?F:a==="end"?F-v:a==="nearest"?cc(g,g+v,v,ie,le,g+F,g+F+k,k):F-v/2,q=l==="start"?M:l==="center"?M-w/2:l==="end"?M-w:cc(y,y+w,w,Y,Q,y+M,y+M+A,A),L=Math.max(0,L+g),q=Math.max(0,q+y);else{L=a==="start"?F-X-ie:a==="end"?F-te+le+K:a==="nearest"?cc(X,te,W,ie,le+K,F,F+k,k):F-(X+W/2)+K/2,q=l==="start"?M-H-Y:l==="center"?M-(H+V/2)+J/2:l==="end"?M-G+Q+J:cc(H,G,V,Y,Q+J,M,M+A,A);const{scrollLeft:he,scrollTop:Ce}=$;L=se===0?0:Math.max(0,Math.min(Ce+L/se,$.scrollHeight-W/se+K)),q=re===0?0:Math.max(0,Math.min(he+q/re,$.scrollWidth-V/re+J)),F+=Ce-L,M+=he-q}T.push({el:$,top:L,left:q})}return T},bM=t=>t===!1?{block:"end",inline:"nearest"}:(e=>e===Object(e)&&Object.keys(e).length!==0)(t)?t:{block:"start",inline:"nearest"};function CM(t,e){if(!t.isConnected||!(o=>{let i=o;for(;i&&i.parentNode;){if(i.parentNode===document)return!0;i=i.parentNode instanceof ShadowRoot?i.parentNode.host:i.parentNode}return!1})(t))return;const n=(o=>{const i=window.getComputedStyle(o);return{top:parseFloat(i.scrollMarginTop)||0,right:parseFloat(i.scrollMarginRight)||0,bottom:parseFloat(i.scrollMarginBottom)||0,left:parseFloat(i.scrollMarginLeft)||0}})(t);if((o=>typeof o=="object"&&typeof o.behavior=="function")(e))return e.behavior(Ky(t,e));const r=typeof e=="boolean"||e==null?void 0:e.behavior;for(const{el:o,top:i,left:s}of Ky(t,bM(e))){const a=i-n.top+n.bottom,l=s-n.left+n.right;o.scroll({top:a,left:l,behavior:r})}}var sr={},Yy;function kM(){if(Yy)return sr;Yy=1,Object.defineProperty(sr,"__esModule",{value:!0});for(var t=typeof window<"u"&&/Mac|iPod|iPhone|iPad/.test(window.navigator.platform),e={alt:"altKey",control:"ctrlKey",meta:"metaKey",shift:"shiftKey"},n={add:"+",break:"pause",cmd:"meta",command:"meta",ctl:"control",ctrl:"control",del:"delete",down:"arrowdown",esc:"escape",ins:"insert",left:"arrowleft",mod:t?"meta":"control",opt:"alt",option:"alt",return:"enter",right:"arrowright",space:" ",spacebar:" ",up:"arrowup",win:"meta",windows:"meta"},r={backspace:8,tab:9,enter:13,shift:16,control:17,alt:18,pause:19,capslock:20,escape:27," ":32,pageup:33,pagedown:34,end:35,home:36,arrowleft:37,arrowup:38,arrowright:39,arrowdown:40,insert:45,delete:46,meta:91,numlock:144,scrolllock:145,";":186,"=":187,",":188,"-":189,".":190,"/":191,"`":192,"[":219,"\\":220,"]":221,"'":222},o=1;o<20;o++)r["f"+o]=111+o;function i(h,p,m){p&&!("byKey"in p)&&(m=p,p=null),Array.isArray(h)||(h=[h]);var w=h.map(function(g){return l(g,p)}),v=function(k){return w.some(function(A){return c(A,k)})},y=m==null?v:v(m);return y}function s(h,p){return i(h,p)}function a(h,p){return i(h,{byKey:!0},p)}function l(h,p){var m=p&&p.byKey,w={};h=h.replace("++","+add");var v=h.split("+"),y=v.length;for(var g in e)w[e[g]]=!1;var k=!0,A=!1,C=void 0;try{for(var E=v[Symbol.iterator](),D;!(k=(D=E.next()).done);k=!0){var S=D.value,_=S.endsWith("?")&&S.length>1;_&&(S=S.slice(0,-1));var O=d(S),B=e[O];if(S.length>1&&!B&&!n[S]&&!r[O])throw new TypeError('Unknown modifier: "'+S+'"');(y===1||!B)&&(m?w.key=O:w.which=u(S)),B&&(w[B]=_?null:!0)}}catch(N){A=!0,C=N}finally{try{!k&&E.return&&E.return()}finally{if(A)throw C}}return w}function c(h,p){for(var m in h){var w=h[m],v=void 0;if(w!=null&&(m==="key"&&p.key!=null?v=p.key.toLowerCase():m==="which"?v=w===91&&p.which===93?91:p.which:v=p[m],!(v==null&&w===!1)&&v!==w))return!1}return!0}function u(h){h=d(h);var p=r[h]||h.toUpperCase().charCodeAt(0);return p}function d(h){return h=h.toLowerCase(),h=n[h]||h,h}return sr.default=i,sr.isHotkey=i,sr.isCodeHotkey=s,sr.isKeyHotkey=a,sr.parseHotkey=l,sr.compareHotkey=c,sr.toKeyCode=u,sr.toKeyName=d,sr}var Rf=kM(),Xy=globalThis.Node,xM=globalThis.Text,Qf=t=>t&&t.ownerDocument&&t.ownerDocument.defaultView||null,SM=t=>fo(t)&&t.nodeType===8,Gn=t=>fo(t)&&t.nodeType===1,fo=t=>{var e=Qf(t);return!!e&&t instanceof e.Node},Zf=t=>{var e=t&&t.anchorNode&&Qf(t.anchorNode);return!!e&&t instanceof e.Selection},Jy=t=>fo(t)&&t.nodeType===3,EM=t=>t.clipboardData&&t.clipboardData.getData("text/plain")!==""&&t.clipboardData.types.length===1,DM=t=>{var[e,n]=t;if(Gn(e)&&e.childNodes.length){var r=n===e.childNodes.length,o=r?n-1:n;for([e,o]=Ry(e,o,r?"backward":"forward"),r=o<n;Gn(e)&&e.childNodes.length;){var i=r?e.childNodes.length-1:0;e=OM(e,i,r?"backward":"forward")}n=r&&e.textContent!=null?e.textContent.length:0}return[e,n]},AM=t=>{for(var e=t&&t.parentNode;e;){if(e.toString()==="[object ShadowRoot]")return!0;e=e.parentNode}return!1},Ry=(t,e,n)=>{for(var{childNodes:r}=t,o=r[e],i=e,s=!1,a=!1;(SM(o)||Gn(o)&&o.childNodes.length===0||Gn(o)&&o.getAttribute("contenteditable")==="false")&&!(s&&a);){if(i>=r.length){s=!0,i=e-1,n="backward";continue}if(i<0){a=!0,i=e+1,n="forward";continue}o=r[i],e=i,i+=n==="forward"?1:-1}return[o,e]},OM=(t,e,n)=>{var[r]=Ry(t,e,n);return r},Qy=t=>{var e="";if(Jy(t)&&t.nodeValue)return t.nodeValue;if(Gn(t)){for(var n of Array.from(t.childNodes))e+=Qy(n);var r=getComputedStyle(t).getPropertyValue("display");(r==="block"||r==="list"||t.tagName==="BR")&&(e+=`
|
|
18
18
|
`)}return e},TM=/data-slate-fragment="(.+?)"/m,_M=t=>{var e=t.getData("text/html"),[,n]=e.match(TM)||[];return n},Qs=t=>t.getSelection!=null?t.getSelection():document.getSelection(),eh=(t,e,n)=>{var{target:r}=e;if(Gn(r)&&r.matches('[contentEditable="false"]'))return!1;var{document:o}=He.getWindow(t);if(Xo(o,r))return He.hasDOMNode(t,r,{editable:!0});var i=n.find(s=>{var{addedNodes:a,removedNodes:l}=s;for(var c of a)if(c===r||Xo(c,r))return!0;for(var u of l)if(u===r||Xo(u,r))return!0});return!i||i===e?!1:eh(t,i,n)},NM=()=>{for(var t=document.activeElement;(e=t)!==null&&e!==void 0&&e.shadowRoot&&(n=t.shadowRoot)!==null&&n!==void 0&&n.activeElement;){var e,n,r;t=(r=t)===null||r===void 0||(r=r.shadowRoot)===null||r===void 0?void 0:r.activeElement}return t},Zy=(t,e)=>!!(t.compareDocumentPosition(e)&Xy.DOCUMENT_POSITION_PRECEDING),BM=(t,e)=>!!(t.compareDocumentPosition(e)&Xy.DOCUMENT_POSITION_FOLLOWING),eb=(t,e)=>{if(!t)return null;for(var n=t;n;){if(n.matches&&n.matches(e))return n;if(n.parentElement)n=n.parentElement;else if(n.parentNode&&"host"in n.parentNode)n=n.parentNode.host;else return null}return null},Xo=(t,e)=>{if(!t||!e)return!1;if(t.contains(e))return!0;for(var n=e;n;){if(n===t)return!0;if(n.parentNode)"host"in n.parentNode?n=n.parentNode.host:n=n.parentNode;else return!1}return!1},th,nh,FM=typeof navigator<"u"&&typeof window<"u"&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,tb=typeof navigator<"u"&&/Mac OS X/.test(navigator.userAgent),rn=typeof navigator<"u"&&/Android/.test(navigator.userAgent),zi=typeof navigator<"u"&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Jo=typeof navigator<"u"&&/AppleWebKit(?!.*Chrome)/i.test(navigator.userAgent),IM=typeof navigator<"u"&&/Edge?\/(?:[0-6][0-9]|[0-7][0-8])(?:\.)/i.test(navigator.userAgent),rh=typeof navigator<"u"&&/Chrome/i.test(navigator.userAgent),nb=typeof navigator<"u"&&/Chrome?\/(?:[0-7][0-5]|[0-6][0-9])(?:\.)/i.test(navigator.userAgent),MM=rn&&typeof navigator<"u"&&/Chrome?\/(?:[0-5]?\d)(?:\.)/i.test(navigator.userAgent),PM=typeof navigator<"u"&&/^(?!.*Seamonkey)(?=.*Firefox\/(?:[0-7][0-9]|[0-8][0-6])(?:\.)).*/i.test(navigator.userAgent),LM=typeof navigator<"u"&&/.*UCBrowser/.test(navigator.userAgent),$M=typeof navigator<"u"&&/.*Wechat/.test(navigator.userAgent)&&!/.*MacWechat/.test(navigator.userAgent)&&(!rh||nb),uc=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";typeof navigator<"u"&&/Safari/.test(navigator.userAgent)&&/Version\/(\d+)/.test(navigator.userAgent)&&((th=navigator.userAgent.match(/Version\/(\d+)/))!==null&&th!==void 0&&th[1]&&parseInt((nh=navigator.userAgent.match(/Version\/(\d+)/))===null||nh===void 0?void 0:nh[1],10)<17);var ho=(!nb||!MM)&&!IM&&typeof globalThis<"u"&&globalThis.InputEvent&&typeof globalThis.InputEvent.prototype.getTargetRanges=="function";function Zs(t){"@babel/helpers - typeof";return Zs=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Zs(t)}function HM(t,e){if(Zs(t)!=="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(Zs(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function zM(t){var e=HM(t,"string");return Zs(e)==="symbol"?e:String(e)}function oh(t,e,n){return e=zM(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var jM=0;class rb{constructor(){oh(this,"id",void 0),this.id="".concat(jM++)}}var ji=new WeakMap,Vi=new WeakMap,ea=new WeakMap,ob=new WeakMap,ta=new WeakMap,ih=new WeakMap,na=new WeakMap,Ro=new WeakMap,dc=new WeakMap,fc=new WeakMap,sh=new WeakMap,po=new WeakMap,Qo=new WeakMap,ra=new WeakMap,ah=new WeakMap,lh=new WeakMap,ar=new WeakMap,Xr=new WeakMap,xn=new WeakMap,mo=new WeakMap,Jr=new WeakMap,ib=new WeakMap,Wi=Symbol("placeholder"),sb=Symbol("mark-placeholder"),He={androidPendingDiffs:t=>xn.get(t),androidScheduleFlush:t=>{var e;(e=lh.get(t))===null||e===void 0||e()},blur:t=>{var e=He.toDOMNode(t,t),n=He.findDocumentOrShadowRoot(t);po.set(t,!1),n.activeElement===e&&e.blur()},deselect:t=>{var{selection:e}=t,n=He.findDocumentOrShadowRoot(t),r=Qs(n);r&&r.rangeCount>0&&r.removeAllRanges(),e&&ce.deselect(t)},findDocumentOrShadowRoot:t=>{var e=He.toDOMNode(t,t),n=e.getRootNode();return n instanceof Document||n instanceof ShadowRoot?n:e.ownerDocument},findEventRange:(t,e)=>{"nativeEvent"in e&&(e=e.nativeEvent);var{clientX:n,clientY:r,target:o}=e;if(n==null||r==null)throw new Error("Cannot resolve a Slate range from a DOM event: ".concat(e));var i=He.toSlateNode(t,e.target),s=He.findPath(t,i);if(ge.isElement(i)&&I.isVoid(t,i)){var a=o.getBoundingClientRect(),l=t.isInline(i)?n-a.left<a.left+a.width-n:r-a.top<a.top+a.height-r,c=I.point(t,s,{edge:l?"start":"end"}),u=l?I.before(t,c):I.after(t,c);if(u){var d=I.range(t,u);return d}}var h,{document:p}=He.getWindow(t);if(p.caretRangeFromPoint)h=p.caretRangeFromPoint(n,r);else{var m=p.caretPositionFromPoint(n,r);m&&(h=p.createRange(),h.setStart(m.offsetNode,m.offset),h.setEnd(m.offsetNode,m.offset))}if(!h)throw new Error("Cannot resolve a Slate range from a DOM event: ".concat(e));var w=He.toSlateRange(t,h,{exactMatch:!1,suppressThrow:!1});return w},findKey:(t,e)=>{var n=dc.get(e);return n||(n=new rb,dc.set(e,n)),n},findPath:(t,e)=>{for(var n=[],r=e;;){var o=ea.get(r);if(o==null){if(r===t)return n;break}var i=Vi.get(r);if(i==null)break;n.unshift(i),r=o}throw new Error("Unable to find the path for Slate node: ".concat($t.stringify(e)))},focus:function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{retries:5};if(!po.get(e)&&ta.get(e)){if(n.retries<=0)throw new Error("Could not set focus, editor seems stuck with pending operations");if(e.operations.length>0){setTimeout(()=>{He.focus(e,{retries:n.retries-1})},10);return}var r=He.toDOMNode(e,e),o=He.findDocumentOrShadowRoot(e);if(o.activeElement!==r){if(e.selection&&o instanceof Document){var i=Qs(o),s=He.toDOMRange(e,e.selection);i==null||i.removeAllRanges(),i==null||i.addRange(s)}e.selection||ce.select(e,I.start(e,[])),po.set(e,!0),r.focus({preventScroll:!0})}}},getWindow:t=>{var e=ob.get(t);if(!e)throw new Error("Unable to find a host window element for this editor");return e},hasDOMNode:function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},{editable:o=!1}=r,i=He.toDOMNode(e,e),s;try{s=Gn(n)?n:n.parentElement}catch(a){if(a instanceof Error&&!a.message.includes('Permission denied to access property "nodeType"'))throw a}return s?eb(s,"[data-slate-editor]")===i&&(!o||s.isContentEditable?!0:typeof s.isContentEditable=="boolean"&&eb(s,'[contenteditable="false"]')===i||!!s.getAttribute("data-slate-zero-width")):!1},hasEditableTarget:(t,e)=>fo(e)&&He.hasDOMNode(t,e,{editable:!0}),hasRange:(t,e)=>{var{anchor:n,focus:r}=e;return I.hasPath(t,n.path)&&I.hasPath(t,r.path)},hasSelectableTarget:(t,e)=>He.hasEditableTarget(t,e)||He.isTargetInsideNonReadonlyVoid(t,e),hasTarget:(t,e)=>fo(e)&&He.hasDOMNode(t,e),insertData:(t,e)=>{t.insertData(e)},insertFragmentData:(t,e)=>t.insertFragmentData(e),insertTextData:(t,e)=>t.insertTextData(e),isComposing:t=>!!Qo.get(t),isFocused:t=>!!po.get(t),isReadOnly:t=>!!sh.get(t),isTargetInsideNonReadonlyVoid:(t,e)=>{if(sh.get(t)||!He.hasTarget(t,e))return!1;var n=He.toSlateNode(t,e);return ge.isElement(n)&&I.isVoid(t,n)},setFragmentData:(t,e,n)=>t.setFragmentData(e,n),toDOMNode:(t,e)=>{var n,r=e===t?ta.get(t):(n=fc.get(t))===null||n===void 0?void 0:n.get(He.findKey(t,e));if(!r)throw new Error("Cannot resolve a DOM node from Slate node: ".concat($t.stringify(e)));return r},toDOMPoint:(t,e)=>{var[n]=I.node(t,e.path),r=He.toDOMNode(t,n),o;I.void(t,{at:e})&&(e={path:e.path,offset:0});for(var i="[data-slate-string], [data-slate-zero-width]",s=Array.from(r.querySelectorAll(i)),a=0,l=0;l<s.length;l++){var c=s[l],u=c.childNodes[0];if(!(u==null||u.textContent==null)){var{length:d}=u.textContent,h=c.getAttribute("data-slate-length"),p=h==null?d:parseInt(h,10),m=a+p,w=s[l+1];if(e.offset===m&&w!==null&&w!==void 0&&w.hasAttribute("data-slate-mark-placeholder")){var v,y=w.childNodes[0];o=[y instanceof xM?y:w,(v=w.textContent)!==null&&v!==void 0&&v.startsWith("\uFEFF")?1:0];break}if(e.offset<=m){var g=Math.min(d,Math.max(0,e.offset-a));o=[u,g];break}a=m}}if(!o)throw new Error("Cannot resolve a DOM point from Slate point: ".concat($t.stringify(e)));return o},toDOMRange:(t,e)=>{var{anchor:n,focus:r}=e,o=oe.isBackward(e),i=He.toDOMPoint(t,n),s=oe.isCollapsed(e)?i:He.toDOMPoint(t,r),a=He.getWindow(t),l=a.document.createRange(),[c,u]=o?s:i,[d,h]=o?i:s,p=Gn(c)?c:c.parentElement,m=!!p.getAttribute("data-slate-zero-width"),w=Gn(d)?d:d.parentElement,v=!!w.getAttribute("data-slate-zero-width");return l.setStart(c,m?1:u),l.setEnd(d,v?1:h),l},toSlateNode:(t,e)=>{var n=Gn(e)?e:e.parentElement;n&&!n.hasAttribute("data-slate-node")&&(n=n.closest("[data-slate-node]"));var r=n?na.get(n):null;if(!r)throw new Error("Cannot resolve a Slate node from DOM node: ".concat(n));return r},toSlatePoint:(t,e,n)=>{var{exactMatch:r,suppressThrow:o,searchDirection:i}=n,[s,a]=r?e:DM(e),l=s.parentNode,c=null,u=0;if(l){var d,h,p=He.toDOMNode(t,t),m=l.closest('[data-slate-void="true"]'),w=m&&Xo(p,m)?m:null,v=l.closest('[contenteditable="false"]'),y=v&&Xo(p,v)?v:null,g=l.closest("[data-slate-leaf]"),k=null;if(g){if(c=g.closest('[data-slate-node="text"]'),c){var A=He.getWindow(t),C=A.document.createRange();C.setStart(c,0),C.setEnd(s,a);var E=C.cloneContents(),D=[...Array.prototype.slice.call(E.querySelectorAll("[data-slate-zero-width]")),...Array.prototype.slice.call(E.querySelectorAll("[contenteditable=false]"))];D.forEach(H=>{if(rn&&!r&&H.hasAttribute("data-slate-zero-width")&&H.textContent.length>0&&H.textContext!=="\uFEFF"){H.textContent.startsWith("\uFEFF")&&(H.textContent=H.textContent.slice(1));return}H.parentNode.removeChild(H)}),u=E.textContent.length,k=c}}else if(w){for(var S=w.querySelectorAll("[data-slate-leaf]"),_=0;_<S.length;_++){var O=S[_];if(He.hasDOMNode(t,O)){g=O;break}}g?(c=g.closest('[data-slate-node="text"]'),k=g,u=k.textContent.length,k.querySelectorAll("[data-slate-zero-width]").forEach(H=>{u-=H.textContent.length})):u=1}else if(y){var B=H=>H?H.querySelectorAll("[data-slate-leaf]:not(:scope [data-slate-editor] [data-slate-leaf])"):[],N=y.closest('[data-slate-node="element"]');if(i==="backward"||!i){var F,M=[...B(N==null?void 0:N.previousElementSibling),...B(N)];g=(F=M.findLast(H=>Zy(y,H)))!==null&&F!==void 0?F:null}if(i==="forward"||!i){var T,P=[...B(N),...B(N==null?void 0:N.nextElementSibling)];g=(T=P.find(H=>BM(y,H)))!==null&&T!==void 0?T:null}g&&(c=g.closest('[data-slate-node="text"]'),k=g,i==="forward"?u=0:(u=k.textContent.length,k.querySelectorAll("[data-slate-zero-width]").forEach(H=>{u-=H.textContent.length})))}k&&u===k.textContent.length&&rn&&k.getAttribute("data-slate-zero-width")==="z"&&(d=k.textContent)!==null&&d!==void 0&&d.startsWith("\uFEFF")&&(l.hasAttribute("data-slate-zero-width")||zi&&(h=k.textContent)!==null&&h!==void 0&&h.endsWith(`
|
|
19
19
|
|
|
20
20
|
`))&&u--}if(rn&&!c&&!r){var $=l.hasAttribute("data-slate-node")?l:l.closest("[data-slate-node]");if($&&He.hasDOMNode(t,$,{editable:!0})){var W=He.toSlateNode(t,$),{path:V,offset:X}=I.start(t,He.findPath(t,W));return $.querySelector("[data-slate-leaf]")||(X=a),{path:V,offset:X}}}if(!c){if(o)return null;throw new Error("Cannot resolve a Slate point from DOM point: ".concat(e))}var G=He.toSlateNode(t,c),te=He.findPath(t,G);return{path:te,offset:u}},toSlateRange:(t,e,n)=>{var r,{exactMatch:o,suppressThrow:i}=n,s=Zf(e)?e.anchorNode:e.startContainer,a,l,c,u,d;if(s)if(Zf(e)){if(zi&&e.rangeCount>1){c=e.focusNode;var h=e.getRangeAt(0),p=e.getRangeAt(e.rangeCount-1);if(c instanceof HTMLTableRowElement&&h.startContainer instanceof HTMLTableRowElement&&p.startContainer instanceof HTMLTableRowElement){let E=function(D){return D.childElementCount>0?E(D.children[0]):D};var m=h.startContainer,w=p.startContainer,v=E(m.children[h.startOffset]),y=E(w.children[p.startOffset]);u=0,y.childNodes.length>0?a=y.childNodes[0]:a=y,v.childNodes.length>0?c=v.childNodes[0]:c=v,y instanceof HTMLElement?l=y.innerHTML.length:l=0}else h.startContainer===c?(a=p.endContainer,l=p.endOffset,u=h.startOffset):(a=h.startContainer,l=h.endOffset,u=p.startOffset)}else a=e.anchorNode,l=e.anchorOffset,c=e.focusNode,u=e.focusOffset;rh&&AM(a)||zi?d=e.anchorNode===e.focusNode&&e.anchorOffset===e.focusOffset:d=e.isCollapsed}else a=e.startContainer,l=e.startOffset,c=e.endContainer,u=e.endOffset,d=e.collapsed;if(a==null||c==null||l==null||u==null)throw new Error("Cannot resolve a Slate range from DOM range: ".concat(e));zi&&(r=c.textContent)!==null&&r!==void 0&&r.endsWith(`
|
|
21
21
|
|
|
22
22
|
`)&&u===c.textContent.length&&u--;var g=He.toSlatePoint(t,[a,l],{exactMatch:o,suppressThrow:i});if(!g)return null;var k=Zy(a,c)||a===c&&u<l,A=d?g:He.toSlatePoint(t,[c,u],{exactMatch:o,suppressThrow:i,searchDirection:k?"forward":"backward"});if(!A)return null;var C={anchor:g,focus:A};return oe.isExpanded(C)&&oe.isForward(C)&&Gn(c)&&I.void(t,{at:C.focus,mode:"highest"})&&(C=I.unhangRange(t,C,{voids:!0})),C}};function VM(t,e){var{path:n,diff:r}=e;if(!I.hasPath(t,n))return!1;var o=ge.get(t,n);if(!ge.isText(o))return!1;if(r.start!==o.text.length||r.text.length===0)return o.text.slice(r.start,r.start+r.text.length)===r.text;var i=U.next(n);if(!I.hasPath(t,i))return!1;var s=ge.get(t,i);return ge.isText(s)&&s.text.startsWith(r.text)}function ab(t){for(var e=arguments.length,n=new Array(e>1?e-1:0),r=1;r<e;r++)n[r-1]=arguments[r];return n.reduce((o,i)=>o.slice(0,i.start)+i.text+o.slice(i.end),t)}function WM(t,e){for(var n=Math.min(t.length,e.length),r=0;r<n;r++)if(t.charAt(r)!==e.charAt(r))return r;return n}function UM(t,e,n){for(var r=Math.min(t.length,e.length,n),o=0;o<r;o++)if(t.charAt(t.length-o-1)!==e.charAt(e.length-o-1))return o;return r}function lb(t,e){var{start:n,end:r,text:o}=e,i=t.slice(n,r),s=WM(i,o),a=Math.min(i.length-s,o.length-s),l=UM(i,o,a),c={start:n+s,end:r-l,text:o.slice(s,o.length-l)};return c.start===c.end&&c.text.length===0?null:c}function qM(t,e,n){var r=Math.min(e.start,n.start),o=Math.max(0,Math.min(e.start+e.text.length,n.end)-n.start),i=ab(t,e,n),s=Math.max(n.start+n.text.length,e.start+e.text.length+(e.start+e.text.length>n.start?n.text.length:0)-o),a=i.slice(r,s),l=Math.max(e.end,n.end-e.text.length+(e.end-e.start));return lb(t,{start:r,end:l,text:a})}function GM(t){var{path:e,diff:n}=t;return{anchor:{path:e,offset:n.start},focus:{path:e,offset:n.end}}}function ch(t,e){var{path:n,offset:r}=e;if(!I.hasPath(t,n))return null;var o=ge.get(t,n);if(!ge.isText(o))return null;var i=I.above(t,{match:a=>ge.isElement(a)&&I.isBlock(t,a),at:n});if(!i)return null;for(;r>o.text.length;){var s=I.next(t,{at:n,match:ge.isText});if(!s||!U.isDescendant(s[1],i[1]))return null;r-=o.text.length,o=s[0],n=s[1]}return{path:n,offset:r}}function cb(t,e){var n=ch(t,e.anchor);if(!n)return null;if(oe.isCollapsed(e))return{anchor:n,focus:n};var r=ch(t,e.focus);return r?{anchor:n,focus:r}:null}function uh(t,e,n){var r=xn.get(t),o=r==null?void 0:r.find(u=>{var{path:d}=u;return U.equals(d,e.path)});if(!o||e.offset<=o.diff.start)return Re.transform(e,n,{affinity:"backward"});var{diff:i}=o;if(e.offset<=i.start+i.text.length){var s={path:e.path,offset:i.start},a=Re.transform(s,n,{affinity:"backward"});return a?{path:a.path,offset:a.offset+e.offset-i.start}:null}var l={path:e.path,offset:e.offset-i.text.length+i.end-i.start},c=Re.transform(l,n,{affinity:"backward"});return c?n.type==="split_node"&&U.equals(n.path,e.path)&&l.offset<n.position&&i.start<n.position?c:{path:c.path,offset:c.offset+i.text.length-i.end+i.start}:null}function ub(t,e,n){var r=uh(t,e.anchor,n);if(!r)return null;if(oe.isCollapsed(e))return{anchor:r,focus:r};var o=uh(t,e.focus,n);return o?{anchor:r,focus:o}:null}function KM(t,e){var{path:n,diff:r,id:o}=t;switch(e.type){case"insert_text":return!U.equals(e.path,n)||e.offset>=r.end?t:e.offset<=r.start?{diff:{start:e.text.length+r.start,end:e.text.length+r.end,text:r.text},id:o,path:n}:{diff:{start:r.start,end:r.end+e.text.length,text:r.text},id:o,path:n};case"remove_text":return!U.equals(e.path,n)||e.offset>=r.end?t:e.offset+e.text.length<=r.start?{diff:{start:r.start-e.text.length,end:r.end-e.text.length,text:r.text},id:o,path:n}:{diff:{start:r.start,end:r.end-e.text.length,text:r.text},id:o,path:n};case"split_node":return!U.equals(e.path,n)||e.position>=r.end?{diff:r,id:o,path:U.transform(n,e,{affinity:"backward"})}:e.position>r.start?{diff:{start:r.start,end:Math.min(e.position,r.end),text:r.text},id:o,path:n}:{diff:{start:r.start-e.position,end:r.end-e.position,text:r.text},id:o,path:U.transform(n,e,{affinity:"forward"})};case"merge_node":return U.equals(e.path,n)?{diff:{start:r.start+e.position,end:r.end+e.position,text:r.text},id:o,path:U.transform(n,e)}:{diff:r,id:o,path:U.transform(n,e)}}var i=U.transform(n,e);return i?{diff:r,path:i,id:o}:null}var db=(t,e)=>{var n=(e.top+e.bottom)/2;return t.top<=n&&t.bottom>=n},fb=(t,e,n)=>{var r=He.toDOMRange(t,e).getBoundingClientRect(),o=He.toDOMRange(t,n).getBoundingClientRect();return db(r,o)&&db(o,r)},YM=(t,e)=>{var n=I.range(t,oe.end(e)),r=Array.from(I.positions(t,{at:e})),o=0,i=r.length,s=Math.floor(i/2);if(fb(t,I.range(t,r[o]),n))return I.range(t,r[o],n);if(r.length<2)return I.range(t,r[r.length-1],n);for(;s!==r.length&&s!==o;)fb(t,I.range(t,r[s]),n)?i=s:o=s,s=Math.floor((o+i)/2);return I.range(t,r[o],n)};function hb(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function pb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?hb(Object(n),!0).forEach(function(r){oh(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):hb(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var XM=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"x-slate-fragment",r=e,{apply:o,onChange:i,deleteBackward:s,addMark:a,removeMark:l}=r;return fc.set(r,new WeakMap),r.addMark=(c,u)=>{var d,h;(d=lh.get(r))===null||d===void 0||d(),!ar.get(r)&&(h=xn.get(r))!==null&&h!==void 0&&h.length&&ar.set(r,null),Xr.delete(r),a(c,u)},r.removeMark=c=>{var u;!ar.get(r)&&(u=xn.get(r))!==null&&u!==void 0&&u.length&&ar.set(r,null),Xr.delete(r),l(c)},r.deleteBackward=c=>{if(c!=="line")return s(c);if(r.selection&&oe.isCollapsed(r.selection)){var u=I.above(r,{match:m=>ge.isElement(m)&&I.isBlock(r,m),at:r.selection});if(u){var[,d]=u,h=I.range(r,d,r.selection.anchor),p=YM(r,h);oe.isCollapsed(p)||ce.delete(r,{at:p})}}},r.apply=c=>{var u=[],d=[],h=xn.get(r);if(h!=null&&h.length){var p=h.map(M=>KM(M,c)).filter(Boolean);xn.set(r,p)}var m=Jr.get(r);m&&Jr.set(r,ub(r,m,c));var w=mo.get(r);if(w!=null&&w.at){var v=dF.isPoint(w==null?void 0:w.at)?uh(r,w.at,c):ub(r,w.at,c);mo.set(r,v?pb(pb({},w),{},{at:v}):null)}switch(c.type){case"insert_text":case"remove_text":case"set_node":case"split_node":{u.push(...Ui(r,c.path));break}case"set_selection":{var y;(y=ra.get(r))===null||y===void 0||y.unref(),ra.delete(r);break}case"insert_node":case"remove_node":{u.push(...Ui(r,U.parent(c.path)));break}case"merge_node":{var g=U.previous(c.path);u.push(...Ui(r,g));break}case"move_node":{var k=U.common(U.parent(c.path),U.parent(c.newPath));u.push(...Ui(r,k));var A;U.isBefore(c.path,c.newPath)?(u.push(...Ui(r,U.parent(c.path))),A=c.newPath):(u.push(...Ui(r,U.parent(c.newPath))),A=c.path);var C=ge.get(e,U.parent(A)),E=He.findKey(r,C),D=I.pathRef(r,U.parent(A));d.push([D,E]);break}}switch(o(c),c.type){case"insert_node":case"remove_node":case"merge_node":case"move_node":case"split_node":case"insert_text":case"remove_text":case"set_selection":ji.set(r,!0)}for(var[S,_]of u){var[O]=I.node(r,S);dc.set(O,_)}for(var[B,N]of d){if(B.current){var[F]=I.node(r,B.current);dc.set(F,N)}B.unref()}},r.setFragmentData=c=>{var{selection:u}=r;if(u){var[d,h]=oe.edges(u),p=I.void(r,{at:d.path}),m=I.void(r,{at:h.path});if(!(oe.isCollapsed(u)&&!p)){var w=He.toDOMRange(r,u),v=w.cloneContents(),y=v.childNodes[0];if(v.childNodes.forEach(O=>{O.textContent&&O.textContent.trim()!==""&&(y=O)}),m){var[g]=m,k=w.cloneRange(),A=He.toDOMNode(r,g);k.setEndAfter(A),v=k.cloneContents()}if(p&&(y=v.querySelector("[data-slate-spacer]")),Array.from(v.querySelectorAll("[data-slate-zero-width]")).forEach(O=>{var B=O.getAttribute("data-slate-zero-width")==="n";O.textContent=B?`
|
|
23
|
-
`:""}),Jy(y)){var C=y.ownerDocument.createElement("span");C.style.whiteSpace="pre",C.appendChild(y),v.appendChild(C),y=C}var E=r.getFragment(),D=JSON.stringify(E),S=window.btoa(encodeURIComponent(D));y.setAttribute("data-slate-fragment",S),c.setData("application/".concat(n),S);var _=v.ownerDocument.createElement("div");return _.appendChild(v),_.setAttribute("hidden","true"),v.ownerDocument.body.appendChild(_),c.setData("text/html",_.innerHTML),c.setData("text/plain",Qy(_)),v.ownerDocument.body.removeChild(_),c}}},r.insertData=c=>{r.insertFragmentData(c)||r.insertTextData(c)},r.insertFragmentData=c=>{var u=c.getData("application/".concat(n))||_M(c);if(u){var d=decodeURIComponent(window.atob(u)),h=JSON.parse(d);return r.insertFragment(h),!0}return!1},r.insertTextData=c=>{var u=c.getData("text/plain");if(u){var d=u.split(/\r\n|\r|\n/),h=!1;for(var p of d)h&&ce.splitNodes(r,{always:!0}),r.insertText(p),h=!0;return!0}return!1},r.onChange=c=>{var u=ah.get(r);u&&u(c),i(c)},r},Ui=(t,e)=>{var n=[];for(var[r,o]of I.levels(t,{at:e})){var i=He.findKey(t,r);n.push([o,i])}return n},JM=3,RM={bold:"mod+b",compose:["down","left","right","up","backspace","enter"],moveBackward:"left",moveForward:"right",moveWordBackward:"ctrl+left",moveWordForward:"ctrl+right",deleteBackward:"shift?+backspace",deleteForward:"shift?+delete",extendBackward:"shift+left",extendForward:"shift+right",italic:"mod+i",insertSoftBreak:"shift+enter",splitBlock:"enter",undo:"mod+z"},QM={moveLineBackward:"opt+up",moveLineForward:"opt+down",moveWordBackward:"opt+left",moveWordForward:"opt+right",deleteBackward:["ctrl+backspace","ctrl+h"],deleteForward:["ctrl+delete","ctrl+d"],deleteLineBackward:"cmd+shift?+backspace",deleteLineForward:["cmd+shift?+delete","ctrl+k"],deleteWordBackward:"opt+shift?+backspace",deleteWordForward:"opt+shift?+delete",extendLineBackward:"opt+shift+up",extendLineForward:"opt+shift+down",redo:"cmd+shift+z",transposeCharacter:"ctrl+t"},ZM={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},wt=t=>{var e=RM[t],n=QM[t],r=ZM[t],o=e&&Rf.isHotkey(e),i=n&&Rf.isHotkey(n),s=r&&Rf.isHotkey(r);return a=>!!(o&&o(a)||tb&&i&&i(a)||!tb&&s&&s(a))},kt={isBold:wt("bold"),isCompose:wt("compose"),isMoveBackward:wt("moveBackward"),isMoveForward:wt("moveForward"),isDeleteBackward:wt("deleteBackward"),isDeleteForward:wt("deleteForward"),isDeleteLineBackward:wt("deleteLineBackward"),isDeleteLineForward:wt("deleteLineForward"),isDeleteWordBackward:wt("deleteWordBackward"),isDeleteWordForward:wt("deleteWordForward"),isExtendBackward:wt("extendBackward"),isExtendForward:wt("extendForward"),isExtendLineBackward:wt("extendLineBackward"),isExtendLineForward:wt("extendLineForward"),isItalic:wt("italic"),isMoveLineBackward:wt("moveLineBackward"),isMoveLineForward:wt("moveLineForward"),isMoveWordBackward:wt("moveWordBackward"),isMoveWordForward:wt("moveWordForward"),isRedo:wt("redo"),isSoftBreak:wt("insertSoftBreak"),isSplitBlock:wt("splitBlock"),isTransposeCharacter:wt("transposeCharacter"),isUndo:wt("undo")};function eP(t,e){if(t==null)return{};var n={},r=Object.keys(t),o,i;for(i=0;i<r.length;i++)o=r[i],!(e.indexOf(o)>=0)&&(n[o]=t[o]);return n}function mb(t,e){if(t==null)return{};var n=eP(t,e),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)r=i[o],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}var tP=["anchor","focus"],nP=["anchor","focus"];function gb(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function wb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gb(Object(n),!0).forEach(function(r){oh(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gb(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var rP=(t,e)=>Object.keys(t).length===Object.keys(e).length&&Object.keys(t).every(n=>e.hasOwnProperty(n)&&t[n]===e[n]),vb=(t,e)=>{var n=mb(t,tP),r=mb(e,nP);return t[Wi]===e[Wi]&&rP(n,r)},dh=(t,e)=>{if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(var n=0;n<t.length;n++){var r=t[n],o=e[n];if(!oe.equals(r,o)||!vb(r,o))return!1}return!0},yb=(t,e)=>{if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(var n=0;n<t.length;n++){var r=t[n],o=e[n];if(r.anchor.offset!==o.anchor.offset||r.focus.offset!==o.focus.offset||!vb(r,o))return!1}return!0},oP=(t,e,n)=>{var r=Array.from(e.children,()=>[]);if(n.length===0)return r;var o=He.findPath(t,e),i=o.length,s=I.range(t,o),a=new Array(e.children.length),l=k=>{var A=a[k];if(A)return A;var C=I.range(t,[...o,k]);return a[k]=C,C};for(var c of n){var u=oe.intersection(s,c);if(u)for(var[d,h]=oe.edges(u),p=d.path[i],m=h.path[i],w=p;w<=m;w++){var v=r[w];if(v){var y=l(w),g=oe.intersection(y,c);g&&v.push(wb(wb({},c),g))}}}return r},Zo=[],iP=function(){return Zo.some(function(t){return t.activeTargets.length>0})},sP=function(){return Zo.some(function(t){return t.skippedTargets.length>0})},bb="ResizeObserver loop completed with undelivered notifications.",aP=function(){var t;typeof ErrorEvent=="function"?t=new ErrorEvent("error",{message:bb}):(t=document.createEvent("Event"),t.initEvent("error",!1,!1),t.message=bb),window.dispatchEvent(t)},oa;(function(t){t.BORDER_BOX="border-box",t.CONTENT_BOX="content-box",t.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(oa||(oa={}));var ei=function(t){return Object.freeze(t)},lP=(function(){function t(e,n){this.inlineSize=e,this.blockSize=n,ei(this)}return t})(),Cb=(function(){function t(e,n,r,o){return this.x=e,this.y=n,this.width=r,this.height=o,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,ei(this)}return t.prototype.toJSON=function(){var e=this,n=e.x,r=e.y,o=e.top,i=e.right,s=e.bottom,a=e.left,l=e.width,c=e.height;return{x:n,y:r,top:o,right:i,bottom:s,left:a,width:l,height:c}},t.fromRect=function(e){return new t(e.x,e.y,e.width,e.height)},t})(),fh=function(t){return t instanceof SVGElement&&"getBBox"in t},kb=function(t){if(fh(t)){var e=t.getBBox(),n=e.width,r=e.height;return!n&&!r}var o=t,i=o.offsetWidth,s=o.offsetHeight;return!(i||s||t.getClientRects().length)},xb=function(t){var e;if(t instanceof Element)return!0;var n=(e=t==null?void 0:t.ownerDocument)===null||e===void 0?void 0:e.defaultView;return!!(n&&t instanceof n.Element)},cP=function(t){switch(t.tagName){case"INPUT":if(t.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1},ia=typeof window<"u"?window:{},hc=new WeakMap,Sb=/auto|scroll/,uP=/^tb|vertical/,dP=/msie|trident/i.test(ia.navigator&&ia.navigator.userAgent),xr=function(t){return parseFloat(t||"0")},qi=function(t,e,n){return t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=!1),new lP((n?e:t)||0,(n?t:e)||0)},Eb=ei({devicePixelContentBoxSize:qi(),borderBoxSize:qi(),contentBoxSize:qi(),contentRect:new Cb(0,0,0,0)}),Db=function(t,e){if(e===void 0&&(e=!1),hc.has(t)&&!e)return hc.get(t);if(kb(t))return hc.set(t,Eb),Eb;var n=getComputedStyle(t),r=fh(t)&&t.ownerSVGElement&&t.getBBox(),o=!dP&&n.boxSizing==="border-box",i=uP.test(n.writingMode||""),s=!r&&Sb.test(n.overflowY||""),a=!r&&Sb.test(n.overflowX||""),l=r?0:xr(n.paddingTop),c=r?0:xr(n.paddingRight),u=r?0:xr(n.paddingBottom),d=r?0:xr(n.paddingLeft),h=r?0:xr(n.borderTopWidth),p=r?0:xr(n.borderRightWidth),m=r?0:xr(n.borderBottomWidth),w=r?0:xr(n.borderLeftWidth),v=d+c,y=l+u,g=w+p,k=h+m,A=a?t.offsetHeight-k-t.clientHeight:0,C=s?t.offsetWidth-g-t.clientWidth:0,E=o?v+g:0,D=o?y+k:0,S=r?r.width:xr(n.width)-E-C,_=r?r.height:xr(n.height)-D-A,O=S+v+C+g,B=_+y+A+k,N=ei({devicePixelContentBoxSize:qi(Math.round(S*devicePixelRatio),Math.round(_*devicePixelRatio),i),borderBoxSize:qi(O,B,i),contentBoxSize:qi(S,_,i),contentRect:new Cb(d,l,S,_)});return hc.set(t,N),N},Ab=function(t,e,n){var r=Db(t,n),o=r.borderBoxSize,i=r.contentBoxSize,s=r.devicePixelContentBoxSize;switch(e){case oa.DEVICE_PIXEL_CONTENT_BOX:return s;case oa.BORDER_BOX:return o;default:return i}},fP=(function(){function t(e){var n=Db(e);this.target=e,this.contentRect=n.contentRect,this.borderBoxSize=ei([n.borderBoxSize]),this.contentBoxSize=ei([n.contentBoxSize]),this.devicePixelContentBoxSize=ei([n.devicePixelContentBoxSize])}return t})(),Ob=function(t){if(kb(t))return 1/0;for(var e=0,n=t.parentNode;n;)e+=1,n=n.parentNode;return e},hP=function(){var t=1/0,e=[];Zo.forEach(function(s){if(s.activeTargets.length!==0){var a=[];s.activeTargets.forEach(function(c){var u=new fP(c.target),d=Ob(c.target);a.push(u),c.lastReportedSize=Ab(c.target,c.observedBox),d<t&&(t=d)}),e.push(function(){s.callback.call(s.observer,a,s.observer)}),s.activeTargets.splice(0,s.activeTargets.length)}});for(var n=0,r=e;n<r.length;n++){var o=r[n];o()}return t},Tb=function(t){Zo.forEach(function(n){n.activeTargets.splice(0,n.activeTargets.length),n.skippedTargets.splice(0,n.skippedTargets.length),n.observationTargets.forEach(function(o){o.isActive()&&(Ob(o.target)>t?n.activeTargets.push(o):n.skippedTargets.push(o))})})},pP=function(){var t=0;for(Tb(t);iP();)t=hP(),Tb(t);return sP()&&aP(),t>0},hh,_b=[],mP=function(){return _b.splice(0).forEach(function(t){return t()})},gP=function(t){if(!hh){var e=0,n=document.createTextNode(""),r={characterData:!0};new MutationObserver(function(){return mP()}).observe(n,r),hh=function(){n.textContent="".concat(e?e--:e++)}}_b.push(t),hh()},wP=function(t){gP(function(){requestAnimationFrame(t)})},pc=0,vP=function(){return!!pc},yP=250,bP={attributes:!0,characterData:!0,childList:!0,subtree:!0},Nb=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],Bb=function(t){return t===void 0&&(t=0),Date.now()+t},ph=!1,CP=(function(){function t(){var e=this;this.stopped=!0,this.listener=function(){return e.schedule()}}return t.prototype.run=function(e){var n=this;if(e===void 0&&(e=yP),!ph){ph=!0;var r=Bb(e);wP(function(){var o=!1;try{o=pP()}finally{if(ph=!1,e=r-Bb(),!vP())return;o?n.run(1e3):e>0?n.run(e):n.start()}})}},t.prototype.schedule=function(){this.stop(),this.run()},t.prototype.observe=function(){var e=this,n=function(){return e.observer&&e.observer.observe(document.body,bP)};document.body?n():ia.addEventListener("DOMContentLoaded",n)},t.prototype.start=function(){var e=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),Nb.forEach(function(n){return ia.addEventListener(n,e.listener,!0)}))},t.prototype.stop=function(){var e=this;this.stopped||(this.observer&&this.observer.disconnect(),Nb.forEach(function(n){return ia.removeEventListener(n,e.listener,!0)}),this.stopped=!0)},t})(),mh=new CP,Fb=function(t){!pc&&t>0&&mh.start(),pc+=t,!pc&&mh.stop()},kP=function(t){return!fh(t)&&!cP(t)&&getComputedStyle(t).display==="inline"},xP=(function(){function t(e,n){this.target=e,this.observedBox=n||oa.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return t.prototype.isActive=function(){var e=Ab(this.target,this.observedBox,!0);return kP(this.target)&&(this.lastReportedSize=e),this.lastReportedSize.inlineSize!==e.inlineSize||this.lastReportedSize.blockSize!==e.blockSize},t})(),SP=(function(){function t(e,n){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=n}return t})(),mc=new WeakMap,Ib=function(t,e){for(var n=0;n<t.length;n+=1)if(t[n].target===e)return n;return-1},gc=(function(){function t(){}return t.connect=function(e,n){var r=new SP(e,n);mc.set(e,r)},t.observe=function(e,n,r){var o=mc.get(e),i=o.observationTargets.length===0;Ib(o.observationTargets,n)<0&&(i&&Zo.push(o),o.observationTargets.push(new xP(n,r&&r.box)),Fb(1),mh.schedule())},t.unobserve=function(e,n){var r=mc.get(e),o=Ib(r.observationTargets,n),i=r.observationTargets.length===1;o>=0&&(i&&Zo.splice(Zo.indexOf(r),1),r.observationTargets.splice(o,1),Fb(-1))},t.disconnect=function(e){var n=this,r=mc.get(e);r.observationTargets.slice().forEach(function(o){return n.unobserve(e,o.target)}),r.activeTargets.splice(0,r.activeTargets.length)},t})(),EP=(function(){function t(e){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof e!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");gc.connect(this,e)}return t.prototype.observe=function(e,n){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!xb(e))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");gc.observe(this,e,n)},t.prototype.unobserve=function(e){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!xb(e))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");gc.unobserve(this,e)},t.prototype.disconnect=function(){gc.disconnect(this)},t.toString=function(){return"function ResizeObserver () { [polyfill code] }"},t})();function DP(t,e){if(t==null)return{};var n={},r=Object.keys(t),o,i;for(i=0;i<r.length;i++)o=r[i],!(e.indexOf(o)>=0)&&(n[o]=t[o]);return n}function wc(t,e){if(t==null)return{};var n=DP(t,e),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)r=i[o],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}function sa(t){"@babel/helpers - typeof";return sa=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},sa(t)}function AP(t,e){if(sa(t)!=="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(sa(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function OP(t){var e=AP(t,"string");return sa(e)==="symbol"?e:String(e)}function vt(t,e,n){return e=OP(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var gh=b.createContext(null),lr=()=>{var t=b.useContext(gh);if(!t)throw new Error("The `useSlateStatic` hook must be used inside the <Slate> component's context.");return t},pe=He;function Mb(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function vc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Mb(Object(n),!0).forEach(function(r){vt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Mb(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var TP=25,_P=200,NP=function(){},BP=t=>(t==null?void 0:t.constructor.name)==="DataTransfer";function FP(t){var{editor:e,scheduleOnDOMSelectionChange:n,onDOMSelectionChange:r}=t,o=!1,i=null,s=null,a=null,l=0,c=!1,u=()=>{var N=Jr.get(e);if(Jr.delete(e),N){var{selection:F}=e,M=cb(e,N);M&&(!F||!oe.equals(M,F))&&ce.select(e,M)}},d=()=>{var N=mo.get(e);if(mo.delete(e),!!N){if(N.at){var F=Re.isPoint(N.at)?ch(e,N.at):cb(e,N.at);if(!F)return;var M=I.range(e,F);(!e.selection||!oe.equals(e.selection,M))&&ce.select(e,F)}N.run()}},h=()=>{if(s&&(clearTimeout(s),s=null),a&&(clearTimeout(a),a=null),!A()&&!k()){u();return}o||(o=!0,setTimeout(()=>o=!1)),k()&&(o="action");var N=e.selection&&I.rangeRef(e,e.selection,{affinity:"forward"});Xr.set(e,e.marks),NP("flush",mo.get(e),xn.get(e));for(var F=A(),M;M=(T=xn.get(e))===null||T===void 0?void 0:T[0];){var T,P,$=ar.get(e);$!==void 0&&(ar.delete(e),e.marks=$),$&&c===!1&&(c=null);var W=GM(M);(!e.selection||!oe.equals(e.selection,W))&&ce.select(e,W),M.diff.text?I.insertText(e,M.diff.text):I.deleteFragment(e),xn.set(e,(P=xn.get(e))===null||P===void 0?void 0:P.filter(G=>{var{id:te}=G;return te!==M.id})),VM(e,M)||(F=!1,mo.delete(e),Xr.delete(e),o="action",Jr.delete(e),n.cancel(),r.cancel(),N==null||N.unref())}var V=N==null?void 0:N.unref();if(V&&!Jr.get(e)&&(!e.selection||!oe.equals(V,e.selection))&&ce.select(e,V),k()){d();return}F&&n(),n.flush(),r.flush(),u();var X=Xr.get(e);Xr.delete(e),X!==void 0&&(e.marks=X,e.onChange())},p=N=>{i&&clearTimeout(i),i=setTimeout(()=>{Qo.set(e,!1),h()},TP)},m=N=>{Qo.set(e,!0),i&&(clearTimeout(i),i=null)},w=function(){var F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,M=ih.get(e);if(M){if(A()||F){M.style.display="none";return}M.style.removeProperty("display")}},v=(N,F)=>{var M,T=(M=xn.get(e))!==null&&M!==void 0?M:[];xn.set(e,T);var P=ge.leaf(e,N),$=T.findIndex(X=>U.equals(X.path,N));if($<0){var W=lb(P.text,F);W&&T.push({path:N,diff:F,id:l++}),w();return}var V=qM(P.text,T[$].diff,F);if(!V){T.splice($,1),w();return}T[$]=vc(vc({},T[$]),{},{diff:V})},y=function(F){var{at:M}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};c=!1,Jr.delete(e),n.cancel(),r.cancel(),k()&&h(),mo.set(e,{at:M,run:F}),a=setTimeout(h)},g=N=>{var F;if(s&&(clearTimeout(s),s=null),!ji.get(e)){var{inputType:M}=N,T=null,P=N.dataTransfer||N.data||void 0;c!==!1&&M!=="insertText"&&M!=="insertCompositionText"&&(c=!1);var[$]=N.getTargetRanges();$&&(T=pe.toSlateRange(e,$,{exactMatch:!1,suppressThrow:!0}));var W=pe.getWindow(e),V=W.getSelection();if(!T&&V&&($=V,T=pe.toSlateRange(e,V,{exactMatch:!1,suppressThrow:!0})),T=(F=T)!==null&&F!==void 0?F:e.selection,!!T){var X=!0;if(M.startsWith("delete")){var G=M.endsWith("Backward")?"backward":"forward",[te,H]=oe.edges(T),[j,Y]=I.leaf(e,te.path);if(oe.isExpanded(T)&&j.text.length===te.offset&&H.offset===0){var se=I.next(e,{at:te.path,match:Oe.isText});se&&U.equals(se[1],H.path)&&(G==="backward"?(T={anchor:H,focus:H},te=H,[j,Y]=se):(T={anchor:te,focus:te},H=te))}var Q={text:"",start:te.offset,end:H.offset},le=xn.get(e),L=le==null?void 0:le.find(At=>U.equals(At.path,Y)),q=L?[L.diff,Q]:[Q],J=ab(j.text,...q);if(J.length===0&&(X=!1),oe.isExpanded(T)){if(X&&U.equals(T.anchor.path,T.focus.path)){var K={path:T.anchor.path,offset:te.offset},re=I.range(e,K,K);return D(re),v(T.anchor.path,{text:"",end:H.offset,start:te.offset})}return y(()=>I.deleteFragment(e,{direction:G}),{at:T})}}switch(M){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":return y(()=>I.deleteFragment(e),{at:T});case"deleteContent":case"deleteContentForward":{var{anchor:ie}=T;if(X&&oe.isCollapsed(T)){var he=ge.leaf(e,ie.path);if(ie.offset<he.text.length)return v(ie.path,{text:"",start:ie.offset,end:ie.offset+1})}return y(()=>I.deleteForward(e),{at:T})}case"deleteContentBackward":{var Ce,{anchor:Fe}=T,qe=Zf($)?$.isCollapsed:!!((Ce=$)!==null&&Ce!==void 0&&Ce.collapsed);return X&&qe&&oe.isCollapsed(T)&&Fe.offset>0?v(Fe.path,{text:"",start:Fe.offset-1,end:Fe.offset}):y(()=>I.deleteBackward(e),{at:T})}case"deleteEntireSoftLine":return y(()=>{I.deleteBackward(e,{unit:"line"}),I.deleteForward(e,{unit:"line"})},{at:T});case"deleteHardLineBackward":return y(()=>I.deleteBackward(e,{unit:"block"}),{at:T});case"deleteSoftLineBackward":return y(()=>I.deleteBackward(e,{unit:"line"}),{at:T});case"deleteHardLineForward":return y(()=>I.deleteForward(e,{unit:"block"}),{at:T});case"deleteSoftLineForward":return y(()=>I.deleteForward(e,{unit:"line"}),{at:T});case"deleteWordBackward":return y(()=>I.deleteBackward(e,{unit:"word"}),{at:T});case"deleteWordForward":return y(()=>I.deleteForward(e,{unit:"word"}),{at:T});case"insertLineBreak":return y(()=>I.insertSoftBreak(e),{at:T});case"insertParagraph":return y(()=>I.insertBreak(e),{at:T});case"insertCompositionText":case"deleteCompositionText":case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":{if(BP(P))return y(()=>pe.insertData(e,P),{at:T});var Le=P??"";if(ar.get(e)&&(Le=Le.replace("\uFEFF","")),M==="insertText"&&/.*\n.*\n$/.test(Le)&&(Le=Le.slice(0,-1)),Le.includes(`
|
|
23
|
+
`:""}),Jy(y)){var C=y.ownerDocument.createElement("span");C.style.whiteSpace="pre",C.appendChild(y),v.appendChild(C),y=C}var E=r.getFragment(),D=JSON.stringify(E),S=window.btoa(encodeURIComponent(D));y.setAttribute("data-slate-fragment",S),c.setData("application/".concat(n),S);var _=v.ownerDocument.createElement("div");return _.appendChild(v),_.setAttribute("hidden","true"),v.ownerDocument.body.appendChild(_),c.setData("text/html",_.innerHTML),c.setData("text/plain",Qy(_)),v.ownerDocument.body.removeChild(_),c}}},r.insertData=c=>{r.insertFragmentData(c)||r.insertTextData(c)},r.insertFragmentData=c=>{var u=c.getData("application/".concat(n))||_M(c);if(u){var d=decodeURIComponent(window.atob(u)),h=JSON.parse(d);return r.insertFragment(h),!0}return!1},r.insertTextData=c=>{var u=c.getData("text/plain");if(u){var d=u.split(/\r\n|\r|\n/),h=!1;for(var p of d)h&&ce.splitNodes(r,{always:!0}),r.insertText(p),h=!0;return!0}return!1},r.onChange=c=>{var u=ah.get(r);u&&u(c),i(c)},r},Ui=(t,e)=>{var n=[];for(var[r,o]of I.levels(t,{at:e})){var i=He.findKey(t,r);n.push([o,i])}return n},JM=3,RM={bold:"mod+b",compose:["down","left","right","up","backspace","enter"],moveBackward:"left",moveForward:"right",moveWordBackward:"ctrl+left",moveWordForward:"ctrl+right",deleteBackward:"shift?+backspace",deleteForward:"shift?+delete",extendBackward:"shift+left",extendForward:"shift+right",italic:"mod+i",insertSoftBreak:"shift+enter",splitBlock:"enter",undo:"mod+z"},QM={moveLineBackward:"opt+up",moveLineForward:"opt+down",moveWordBackward:"opt+left",moveWordForward:"opt+right",deleteBackward:["ctrl+backspace","ctrl+h"],deleteForward:["ctrl+delete","ctrl+d"],deleteLineBackward:"cmd+shift?+backspace",deleteLineForward:["cmd+shift?+delete","ctrl+k"],deleteWordBackward:"opt+shift?+backspace",deleteWordForward:"opt+shift?+delete",extendLineBackward:"opt+shift+up",extendLineForward:"opt+shift+down",redo:"cmd+shift+z",transposeCharacter:"ctrl+t"},ZM={deleteWordBackward:"ctrl+shift?+backspace",deleteWordForward:"ctrl+shift?+delete",redo:["ctrl+y","ctrl+shift+z"]},wt=t=>{var e=RM[t],n=QM[t],r=ZM[t],o=e&&Rf.isHotkey(e),i=n&&Rf.isHotkey(n),s=r&&Rf.isHotkey(r);return a=>!!(o&&o(a)||tb&&i&&i(a)||!tb&&s&&s(a))},kt={isBold:wt("bold"),isCompose:wt("compose"),isMoveBackward:wt("moveBackward"),isMoveForward:wt("moveForward"),isDeleteBackward:wt("deleteBackward"),isDeleteForward:wt("deleteForward"),isDeleteLineBackward:wt("deleteLineBackward"),isDeleteLineForward:wt("deleteLineForward"),isDeleteWordBackward:wt("deleteWordBackward"),isDeleteWordForward:wt("deleteWordForward"),isExtendBackward:wt("extendBackward"),isExtendForward:wt("extendForward"),isExtendLineBackward:wt("extendLineBackward"),isExtendLineForward:wt("extendLineForward"),isItalic:wt("italic"),isMoveLineBackward:wt("moveLineBackward"),isMoveLineForward:wt("moveLineForward"),isMoveWordBackward:wt("moveWordBackward"),isMoveWordForward:wt("moveWordForward"),isRedo:wt("redo"),isSoftBreak:wt("insertSoftBreak"),isSplitBlock:wt("splitBlock"),isTransposeCharacter:wt("transposeCharacter"),isUndo:wt("undo")};function eP(t,e){if(t==null)return{};var n={},r=Object.keys(t),o,i;for(i=0;i<r.length;i++)o=r[i],!(e.indexOf(o)>=0)&&(n[o]=t[o]);return n}function mb(t,e){if(t==null)return{};var n=eP(t,e),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)r=i[o],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}var tP=["anchor","focus"],nP=["anchor","focus"];function gb(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function wb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?gb(Object(n),!0).forEach(function(r){oh(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):gb(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var rP=(t,e)=>Object.keys(t).length===Object.keys(e).length&&Object.keys(t).every(n=>e.hasOwnProperty(n)&&t[n]===e[n]),vb=(t,e)=>{var n=mb(t,tP),r=mb(e,nP);return t[Wi]===e[Wi]&&rP(n,r)},dh=(t,e)=>{if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(var n=0;n<t.length;n++){var r=t[n],o=e[n];if(!oe.equals(r,o)||!vb(r,o))return!1}return!0},yb=(t,e)=>{if(t===e)return!0;if(!t||!e||t.length!==e.length)return!1;for(var n=0;n<t.length;n++){var r=t[n],o=e[n];if(r.anchor.offset!==o.anchor.offset||r.focus.offset!==o.focus.offset||!vb(r,o))return!1}return!0},oP=(t,e,n)=>{var r=Array.from(e.children,()=>[]);if(n.length===0)return r;var o=He.findPath(t,e),i=o.length,s=I.range(t,o),a=new Array(e.children.length),l=k=>{var A=a[k];if(A)return A;var C=I.range(t,[...o,k]);return a[k]=C,C};for(var c of n){var u=oe.intersection(s,c);if(u)for(var[d,h]=oe.edges(u),p=d.path[i],m=h.path[i],w=p;w<=m;w++){var v=r[w];if(v){var y=l(w),g=oe.intersection(y,c);g&&v.push(wb(wb({},c),g))}}}return r},Zo=[],iP=function(){return Zo.some(function(t){return t.activeTargets.length>0})},sP=function(){return Zo.some(function(t){return t.skippedTargets.length>0})},bb="ResizeObserver loop completed with undelivered notifications.",aP=function(){var t;typeof ErrorEvent=="function"?t=new ErrorEvent("error",{message:bb}):(t=document.createEvent("Event"),t.initEvent("error",!1,!1),t.message=bb),window.dispatchEvent(t)},oa;(function(t){t.BORDER_BOX="border-box",t.CONTENT_BOX="content-box",t.DEVICE_PIXEL_CONTENT_BOX="device-pixel-content-box"})(oa||(oa={}));var ei=function(t){return Object.freeze(t)},lP=(function(){function t(e,n){this.inlineSize=e,this.blockSize=n,ei(this)}return t})(),Cb=(function(){function t(e,n,r,o){return this.x=e,this.y=n,this.width=r,this.height=o,this.top=this.y,this.left=this.x,this.bottom=this.top+this.height,this.right=this.left+this.width,ei(this)}return t.prototype.toJSON=function(){var e=this,n=e.x,r=e.y,o=e.top,i=e.right,s=e.bottom,a=e.left,l=e.width,c=e.height;return{x:n,y:r,top:o,right:i,bottom:s,left:a,width:l,height:c}},t.fromRect=function(e){return new t(e.x,e.y,e.width,e.height)},t})(),fh=function(t){return t instanceof SVGElement&&"getBBox"in t},kb=function(t){if(fh(t)){var e=t.getBBox(),n=e.width,r=e.height;return!n&&!r}var o=t,i=o.offsetWidth,s=o.offsetHeight;return!(i||s||t.getClientRects().length)},xb=function(t){var e;if(t instanceof Element)return!0;var n=(e=t==null?void 0:t.ownerDocument)===null||e===void 0?void 0:e.defaultView;return!!(n&&t instanceof n.Element)},cP=function(t){switch(t.tagName){case"INPUT":if(t.type!=="image")break;case"VIDEO":case"AUDIO":case"EMBED":case"OBJECT":case"CANVAS":case"IFRAME":case"IMG":return!0}return!1},ia=typeof window<"u"?window:{},hc=new WeakMap,Sb=/auto|scroll/,uP=/^tb|vertical/,dP=/msie|trident/i.test(ia.navigator&&ia.navigator.userAgent),xr=function(t){return parseFloat(t||"0")},qi=function(t,e,n){return t===void 0&&(t=0),e===void 0&&(e=0),n===void 0&&(n=!1),new lP((n?e:t)||0,(n?t:e)||0)},Eb=ei({devicePixelContentBoxSize:qi(),borderBoxSize:qi(),contentBoxSize:qi(),contentRect:new Cb(0,0,0,0)}),Db=function(t,e){if(e===void 0&&(e=!1),hc.has(t)&&!e)return hc.get(t);if(kb(t))return hc.set(t,Eb),Eb;var n=getComputedStyle(t),r=fh(t)&&t.ownerSVGElement&&t.getBBox(),o=!dP&&n.boxSizing==="border-box",i=uP.test(n.writingMode||""),s=!r&&Sb.test(n.overflowY||""),a=!r&&Sb.test(n.overflowX||""),l=r?0:xr(n.paddingTop),c=r?0:xr(n.paddingRight),u=r?0:xr(n.paddingBottom),d=r?0:xr(n.paddingLeft),h=r?0:xr(n.borderTopWidth),p=r?0:xr(n.borderRightWidth),m=r?0:xr(n.borderBottomWidth),w=r?0:xr(n.borderLeftWidth),v=d+c,y=l+u,g=w+p,k=h+m,A=a?t.offsetHeight-k-t.clientHeight:0,C=s?t.offsetWidth-g-t.clientWidth:0,E=o?v+g:0,D=o?y+k:0,S=r?r.width:xr(n.width)-E-C,_=r?r.height:xr(n.height)-D-A,O=S+v+C+g,B=_+y+A+k,N=ei({devicePixelContentBoxSize:qi(Math.round(S*devicePixelRatio),Math.round(_*devicePixelRatio),i),borderBoxSize:qi(O,B,i),contentBoxSize:qi(S,_,i),contentRect:new Cb(d,l,S,_)});return hc.set(t,N),N},Ab=function(t,e,n){var r=Db(t,n),o=r.borderBoxSize,i=r.contentBoxSize,s=r.devicePixelContentBoxSize;switch(e){case oa.DEVICE_PIXEL_CONTENT_BOX:return s;case oa.BORDER_BOX:return o;default:return i}},fP=(function(){function t(e){var n=Db(e);this.target=e,this.contentRect=n.contentRect,this.borderBoxSize=ei([n.borderBoxSize]),this.contentBoxSize=ei([n.contentBoxSize]),this.devicePixelContentBoxSize=ei([n.devicePixelContentBoxSize])}return t})(),Ob=function(t){if(kb(t))return 1/0;for(var e=0,n=t.parentNode;n;)e+=1,n=n.parentNode;return e},hP=function(){var t=1/0,e=[];Zo.forEach(function(s){if(s.activeTargets.length!==0){var a=[];s.activeTargets.forEach(function(c){var u=new fP(c.target),d=Ob(c.target);a.push(u),c.lastReportedSize=Ab(c.target,c.observedBox),d<t&&(t=d)}),e.push(function(){s.callback.call(s.observer,a,s.observer)}),s.activeTargets.splice(0,s.activeTargets.length)}});for(var n=0,r=e;n<r.length;n++){var o=r[n];o()}return t},Tb=function(t){Zo.forEach(function(n){n.activeTargets.splice(0,n.activeTargets.length),n.skippedTargets.splice(0,n.skippedTargets.length),n.observationTargets.forEach(function(o){o.isActive()&&(Ob(o.target)>t?n.activeTargets.push(o):n.skippedTargets.push(o))})})},pP=function(){var t=0;for(Tb(t);iP();)t=hP(),Tb(t);return sP()&&aP(),t>0},hh,_b=[],mP=function(){return _b.splice(0).forEach(function(t){return t()})},gP=function(t){if(!hh){var e=0,n=document.createTextNode(""),r={characterData:!0};new MutationObserver(function(){return mP()}).observe(n,r),hh=function(){n.textContent="".concat(e?e--:e++)}}_b.push(t),hh()},wP=function(t){gP(function(){requestAnimationFrame(t)})},pc=0,vP=function(){return!!pc},yP=250,bP={attributes:!0,characterData:!0,childList:!0,subtree:!0},Nb=["resize","load","transitionend","animationend","animationstart","animationiteration","keyup","keydown","mouseup","mousedown","mouseover","mouseout","blur","focus"],Bb=function(t){return t===void 0&&(t=0),Date.now()+t},ph=!1,CP=(function(){function t(){var e=this;this.stopped=!0,this.listener=function(){return e.schedule()}}return t.prototype.run=function(e){var n=this;if(e===void 0&&(e=yP),!ph){ph=!0;var r=Bb(e);wP(function(){var o=!1;try{o=pP()}finally{if(ph=!1,e=r-Bb(),!vP())return;o?n.run(1e3):e>0?n.run(e):n.start()}})}},t.prototype.schedule=function(){this.stop(),this.run()},t.prototype.observe=function(){var e=this,n=function(){return e.observer&&e.observer.observe(document.body,bP)};document.body?n():ia.addEventListener("DOMContentLoaded",n)},t.prototype.start=function(){var e=this;this.stopped&&(this.stopped=!1,this.observer=new MutationObserver(this.listener),this.observe(),Nb.forEach(function(n){return ia.addEventListener(n,e.listener,!0)}))},t.prototype.stop=function(){var e=this;this.stopped||(this.observer&&this.observer.disconnect(),Nb.forEach(function(n){return ia.removeEventListener(n,e.listener,!0)}),this.stopped=!0)},t})(),mh=new CP,Fb=function(t){!pc&&t>0&&mh.start(),pc+=t,!pc&&mh.stop()},kP=function(t){return!fh(t)&&!cP(t)&&getComputedStyle(t).display==="inline"},xP=(function(){function t(e,n){this.target=e,this.observedBox=n||oa.CONTENT_BOX,this.lastReportedSize={inlineSize:0,blockSize:0}}return t.prototype.isActive=function(){var e=Ab(this.target,this.observedBox,!0);return kP(this.target)&&(this.lastReportedSize=e),this.lastReportedSize.inlineSize!==e.inlineSize||this.lastReportedSize.blockSize!==e.blockSize},t})(),SP=(function(){function t(e,n){this.activeTargets=[],this.skippedTargets=[],this.observationTargets=[],this.observer=e,this.callback=n}return t})(),mc=new WeakMap,Ib=function(t,e){for(var n=0;n<t.length;n+=1)if(t[n].target===e)return n;return-1},gc=(function(){function t(){}return t.connect=function(e,n){var r=new SP(e,n);mc.set(e,r)},t.observe=function(e,n,r){var o=mc.get(e),i=o.observationTargets.length===0;Ib(o.observationTargets,n)<0&&(i&&Zo.push(o),o.observationTargets.push(new xP(n,r&&r.box)),Fb(1),mh.schedule())},t.unobserve=function(e,n){var r=mc.get(e),o=Ib(r.observationTargets,n),i=r.observationTargets.length===1;o>=0&&(i&&Zo.splice(Zo.indexOf(r),1),r.observationTargets.splice(o,1),Fb(-1))},t.disconnect=function(e){var n=this,r=mc.get(e);r.observationTargets.slice().forEach(function(o){return n.unobserve(e,o.target)}),r.activeTargets.splice(0,r.activeTargets.length)},t})(),EP=(function(){function t(e){if(arguments.length===0)throw new TypeError("Failed to construct 'ResizeObserver': 1 argument required, but only 0 present.");if(typeof e!="function")throw new TypeError("Failed to construct 'ResizeObserver': The callback provided as parameter 1 is not a function.");gc.connect(this,e)}return t.prototype.observe=function(e,n){if(arguments.length===0)throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!xb(e))throw new TypeError("Failed to execute 'observe' on 'ResizeObserver': parameter 1 is not of type 'Element");gc.observe(this,e,n)},t.prototype.unobserve=function(e){if(arguments.length===0)throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': 1 argument required, but only 0 present.");if(!xb(e))throw new TypeError("Failed to execute 'unobserve' on 'ResizeObserver': parameter 1 is not of type 'Element");gc.unobserve(this,e)},t.prototype.disconnect=function(){gc.disconnect(this)},t.toString=function(){return"function ResizeObserver () { [polyfill code] }"},t})();function DP(t,e){if(t==null)return{};var n={},r=Object.keys(t),o,i;for(i=0;i<r.length;i++)o=r[i],!(e.indexOf(o)>=0)&&(n[o]=t[o]);return n}function wc(t,e){if(t==null)return{};var n=DP(t,e),r,o;if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);for(o=0;o<i.length;o++)r=i[o],!(e.indexOf(r)>=0)&&Object.prototype.propertyIsEnumerable.call(t,r)&&(n[r]=t[r])}return n}function sa(t){"@babel/helpers - typeof";return sa=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},sa(t)}function AP(t,e){if(sa(t)!=="object"||t===null)return t;var n=t[Symbol.toPrimitive];if(n!==void 0){var r=n.call(t,e);if(sa(r)!=="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function OP(t){var e=AP(t,"string");return sa(e)==="symbol"?e:String(e)}function vt(t,e,n){return e=OP(e),e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var gh=b.createContext(null),lr=()=>{var t=b.useContext(gh);if(!t)throw new Error("The `useSlateStatic` hook must be used inside the <Slate> component's context.");return t},pe=He;function Mb(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function vc(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Mb(Object(n),!0).forEach(function(r){vt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Mb(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var TP=25,_P=200,NP=function(){},BP=t=>(t==null?void 0:t.constructor.name)==="DataTransfer";function FP(t){var{editor:e,scheduleOnDOMSelectionChange:n,onDOMSelectionChange:r}=t,o=!1,i=null,s=null,a=null,l=0,c=!1,u=()=>{var N=Jr.get(e);if(Jr.delete(e),N){var{selection:F}=e,M=cb(e,N);M&&(!F||!oe.equals(M,F))&&ce.select(e,M)}},d=()=>{var N=mo.get(e);if(mo.delete(e),!!N){if(N.at){var F=Re.isPoint(N.at)?ch(e,N.at):cb(e,N.at);if(!F)return;var M=I.range(e,F);(!e.selection||!oe.equals(e.selection,M))&&ce.select(e,F)}N.run()}},h=()=>{if(s&&(clearTimeout(s),s=null),a&&(clearTimeout(a),a=null),!A()&&!k()){u();return}o||(o=!0,setTimeout(()=>o=!1)),k()&&(o="action");var N=e.selection&&I.rangeRef(e,e.selection,{affinity:"forward"});Xr.set(e,e.marks),NP("flush",mo.get(e),xn.get(e));for(var F=A(),M;M=(T=xn.get(e))===null||T===void 0?void 0:T[0];){var T,P,$=ar.get(e);$!==void 0&&(ar.delete(e),e.marks=$),$&&c===!1&&(c=null);var W=GM(M);(!e.selection||!oe.equals(e.selection,W))&&ce.select(e,W),M.diff.text?I.insertText(e,M.diff.text):I.deleteFragment(e),xn.set(e,(P=xn.get(e))===null||P===void 0?void 0:P.filter(G=>{var{id:te}=G;return te!==M.id})),VM(e,M)||(F=!1,mo.delete(e),Xr.delete(e),o="action",Jr.delete(e),n.cancel(),r.cancel(),N==null||N.unref())}var V=N==null?void 0:N.unref();if(V&&!Jr.get(e)&&(!e.selection||!oe.equals(V,e.selection))&&ce.select(e,V),k()){d();return}F&&n(),n.flush(),r.flush(),u();var X=Xr.get(e);Xr.delete(e),X!==void 0&&(e.marks=X,e.onChange())},p=N=>{i&&clearTimeout(i),i=setTimeout(()=>{Qo.set(e,!1),h()},TP)},m=N=>{Qo.set(e,!0),i&&(clearTimeout(i),i=null)},w=function(){var F=arguments.length>0&&arguments[0]!==void 0?arguments[0]:!1,M=ih.get(e);if(M){if(A()||F){M.style.display="none";return}M.style.removeProperty("display")}},v=(N,F)=>{var M,T=(M=xn.get(e))!==null&&M!==void 0?M:[];xn.set(e,T);var P=ge.leaf(e,N),$=T.findIndex(X=>U.equals(X.path,N));if($<0){var W=lb(P.text,F);W&&T.push({path:N,diff:F,id:l++}),w();return}var V=qM(P.text,T[$].diff,F);if(!V){T.splice($,1),w();return}T[$]=vc(vc({},T[$]),{},{diff:V})},y=function(F){var{at:M}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};c=!1,Jr.delete(e),n.cancel(),r.cancel(),k()&&h(),mo.set(e,{at:M,run:F}),a=setTimeout(h)},g=N=>{var F;if(s&&(clearTimeout(s),s=null),!ji.get(e)){var{inputType:M}=N,T=null,P=N.dataTransfer||N.data||void 0;c!==!1&&M!=="insertText"&&M!=="insertCompositionText"&&(c=!1);var[$]=N.getTargetRanges();$&&(T=pe.toSlateRange(e,$,{exactMatch:!1,suppressThrow:!0}));var W=pe.getWindow(e),V=W.getSelection();if(!T&&V&&($=V,T=pe.toSlateRange(e,V,{exactMatch:!1,suppressThrow:!0})),T=(F=T)!==null&&F!==void 0?F:e.selection,!!T){var X=!0;if(M.startsWith("delete")){var G=M.endsWith("Backward")?"backward":"forward",[te,H]=oe.edges(T),[j,Y]=I.leaf(e,te.path);if(oe.isExpanded(T)&&j.text.length===te.offset&&H.offset===0){var ie=I.next(e,{at:te.path,match:Oe.isText});ie&&U.equals(ie[1],H.path)&&(G==="backward"?(T={anchor:H,focus:H},te=H,[j,Y]=ie):(T={anchor:te,focus:te},H=te))}var Q={text:"",start:te.offset,end:H.offset},le=xn.get(e),L=le==null?void 0:le.find(At=>U.equals(At.path,Y)),q=L?[L.diff,Q]:[Q],J=ab(j.text,...q);if(J.length===0&&(X=!1),oe.isExpanded(T)){if(X&&U.equals(T.anchor.path,T.focus.path)){var K={path:T.anchor.path,offset:te.offset},re=I.range(e,K,K);return D(re),v(T.anchor.path,{text:"",end:H.offset,start:te.offset})}return y(()=>I.deleteFragment(e,{direction:G}),{at:T})}}switch(M){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":return y(()=>I.deleteFragment(e),{at:T});case"deleteContent":case"deleteContentForward":{var{anchor:se}=T;if(X&&oe.isCollapsed(T)){var he=ge.leaf(e,se.path);if(se.offset<he.text.length)return v(se.path,{text:"",start:se.offset,end:se.offset+1})}return y(()=>I.deleteForward(e),{at:T})}case"deleteContentBackward":{var Ce,{anchor:Fe}=T,qe=Zf($)?$.isCollapsed:!!((Ce=$)!==null&&Ce!==void 0&&Ce.collapsed);return X&&qe&&oe.isCollapsed(T)&&Fe.offset>0?v(Fe.path,{text:"",start:Fe.offset-1,end:Fe.offset}):y(()=>I.deleteBackward(e),{at:T})}case"deleteEntireSoftLine":return y(()=>{I.deleteBackward(e,{unit:"line"}),I.deleteForward(e,{unit:"line"})},{at:T});case"deleteHardLineBackward":return y(()=>I.deleteBackward(e,{unit:"block"}),{at:T});case"deleteSoftLineBackward":return y(()=>I.deleteBackward(e,{unit:"line"}),{at:T});case"deleteHardLineForward":return y(()=>I.deleteForward(e,{unit:"block"}),{at:T});case"deleteSoftLineForward":return y(()=>I.deleteForward(e,{unit:"line"}),{at:T});case"deleteWordBackward":return y(()=>I.deleteBackward(e,{unit:"word"}),{at:T});case"deleteWordForward":return y(()=>I.deleteForward(e,{unit:"word"}),{at:T});case"insertLineBreak":return y(()=>I.insertSoftBreak(e),{at:T});case"insertParagraph":return y(()=>I.insertBreak(e),{at:T});case"insertCompositionText":case"deleteCompositionText":case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":{if(BP(P))return y(()=>pe.insertData(e,P),{at:T});var Le=P??"";if(ar.get(e)&&(Le=Le.replace("\uFEFF","")),M==="insertText"&&/.*\n.*\n$/.test(Le)&&(Le=Le.slice(0,-1)),Le.includes(`
|
|
24
24
|
`))return y(()=>{var At=Le.split(`
|
|
25
25
|
`);At.forEach((ht,ot)=>{ht&&I.insertText(e,ht),ot!==At.length-1&&I.insertSoftBreak(e)})},{at:T});if(U.equals(T.anchor.path,T.focus.path)){var[de,Te]=oe.edges(T),_e={start:de.offset,end:Te.offset,text:Le};if(Le&&c&&M==="insertCompositionText"){var tt=c.start+c.text.search(/\S|$/),cn=_e.start+_e.text.search(/\S|$/);cn===tt+1&&_e.end===c.start+c.text.length?(_e.start-=1,c=null,O()):c=!1}else M==="insertText"?c===null?c=_e:c&&oe.isCollapsed(T)&&c.end+c.text.length===de.offset?c=vc(vc({},c),{},{text:c.text+Le}):c=!1:c=!1;if(X){var Vn=e.selection;if(v(de.path,_e),Vn){var en={path:de.path,offset:de.offset+Le.length};y(()=>{ce.select(e,{anchor:en,focus:en})},{at:en})}return}}return y(()=>I.insertText(e,Le),{at:T})}}}}},k=()=>!!mo.get(e),A=()=>{var N;return!!((N=xn.get(e))!==null&&N!==void 0&&N.length)},C=()=>k()||A(),E=()=>o,D=N=>{Jr.set(e,N),s&&(clearTimeout(s),s=null);var{selection:F}=e;if(N){var M=!F||!U.equals(F.anchor.path,N.anchor.path),T=!F||!U.equals(F.anchor.path.slice(0,-1),N.anchor.path.slice(0,-1));(M&&c||T)&&(c=!1),(M||A())&&(s=setTimeout(h,_P))}},S=()=>{(k()||!A())&&h()},_=N=>{A()||(w(!0),setTimeout(w))},O=()=>{k()||(a=setTimeout(h))},B=N=>{if(!(A()||k())&&N.some(M=>eh(e,M,N))){var F;(F=ib.get(e))===null||F===void 0||F()}};return{flush:h,scheduleFlush:O,hasPendingDiffs:A,hasPendingAction:k,hasPendingChanges:C,isFlushing:E,handleUserSelect:D,handleCompositionEnd:p,handleCompositionStart:m,handleDOMBeforeInput:g,handleKeyDown:_,handleDomMutations:B,handleInput:S}}function IP(){var t=b.useRef(!1);return b.useEffect(()=>(t.current=!0,()=>{t.current=!1}),[]),t.current}var Sr=uc?b.useLayoutEffect:b.useEffect;function MP(t,e,n){var[r]=b.useState(()=>new MutationObserver(e));Sr(()=>{r.takeRecords()}),b.useEffect(()=>{if(!t.current)throw new Error("Failed to attach MutationObserver, `node` is undefined");return r.observe(t.current,n),()=>r.disconnect()},[r,t,n])}var PP=["node"];function Pb(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function LP(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Pb(Object(n),!0).forEach(function(r){vt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Pb(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var $P={subtree:!0,childList:!0,characterData:!0},HP=rn?t=>{var{node:e}=t,n=wc(t,PP);if(!rn)return null;var r=lr(),o=IP(),[i]=b.useState(()=>FP(LP({editor:r},n)));return MP(e,i.handleDomMutations,$P),lh.set(r,i.scheduleFlush),o&&i.flush(),i}:()=>null;function Lb(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function zP(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Lb(Object(n),!0).forEach(function(r){vt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Lb(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var jP=t=>{var{isLast:e,leaf:n,parent:r,text:o}=t,i=lr(),s=pe.findPath(i,o),a=U.parent(s),l=!!n[sb];return i.isVoid(r)?b.createElement(wh,{length:ge.string(r).length}):n.text===""&&r.children[r.children.length-1]===o&&!i.isInline(r)&&I.string(i,a)===""?b.createElement(wh,{isLineBreak:!0,isMarkPlaceholder:l}):n.text===""?b.createElement(wh,{isMarkPlaceholder:l}):e&&n.text.slice(-1)===`
|
|
26
26
|
`?b.createElement($b,{isTrailing:!0,text:n.text}):b.createElement($b,{text:n.text})},$b=t=>{var{text:e,isTrailing:n=!1}=t,r=b.useRef(null),o=()=>"".concat(e??"").concat(n?`
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
The error may be correlated with this previous error:
|
|
29
29
|
`.concat(r.current.stack,`
|
|
30
30
|
|
|
31
|
-
`)),c}o.current=t,i.current=s,r.current=void 0;var l=b.useCallback(()=>{try{var c=o.current();if(e(i.current,c))return;i.current=c}catch(u){u instanceof Error?r.current=u:r.current=new Error(String(u))}n()},[]);return[s,l]}function XP(t){return t instanceof Error}var Wb=b.createContext({}),Ub=(t,e)=>{var n=lr(),{decorate:r,addEventListener:o}=b.useContext(Wb),i=()=>{var c=pe.findPath(n,t);return r([t,c])},s=Oe.isText(t)?yb:dh,[a,l]=Vb(i,s);return Sr(()=>{var c=o(l);return l(),c},[o,l]),b.useMemo(()=>[...a,...e],[a,e])},JP=t=>{var e=b.useRef(new Set),n=b.useRef(t);Sr(()=>{n.current=t,e.current.forEach(i=>i())},[t]);var r=b.useCallback(i=>n.current(i),[]),o=b.useCallback(i=>(e.current.add(i),()=>{e.current.delete(i)}),[]);return b.useMemo(()=>({decorate:r,addEventListener:o}),[r,o])};function qb(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Gb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qb(Object(n),!0).forEach(function(r){vt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qb(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var RP=t=>b.createElement(ZP,Gb({},t)),QP=t=>{for(var{decorations:e,isLast:n,parent:r,renderPlaceholder:o,renderLeaf:i,renderText:s=RP,text:a}=t,l=lr(),c=b.useRef(null),u=Ub(a,e),d=Oe.decorations(a,u),h=pe.findKey(l,a),p=[],m=0;m<d.length;m++){var{leaf:w,position:v}=d[m];p.push(b.createElement(KP,{isLast:n&&m===d.length-1,key:"".concat(h.id,"-").concat(m),renderPlaceholder:o,leaf:w,leafPosition:v,text:a,parent:r,renderLeaf:i}))}var y=b.useCallback(k=>{var A=fc.get(l);k?(A==null||A.set(h,k),Ro.set(a,k),na.set(k,a)):(A==null||A.delete(h),Ro.delete(a),c.current&&na.delete(c.current)),c.current=k},[c,l,h,a]),g={"data-slate-node":"text",ref:y};return s({text:a,children:p,attributes:g})},Kb=b.memo(QP,(t,e)=>e.parent===t.parent&&e.isLast===t.isLast&&e.renderText===t.renderText&&e.renderLeaf===t.renderLeaf&&e.renderPlaceholder===t.renderPlaceholder&&e.text===t.text&&yb(e.decorations,t.decorations)),ZP=t=>{var{attributes:e,children:n}=t;return b.createElement("span",Gb({},e),n)};function Yb(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function vh(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Yb(Object(n),!0).forEach(function(r){vt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Yb(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var e2=t=>b.createElement(r2,vh({},t)),t2=t=>{var{decorations:e,element:n,renderElement:r=e2,renderChunk:o,renderPlaceholder:i,renderLeaf:s,renderText:a}=t,l=lr(),c=h2(),u=l.isInline(n),d=Ub(n,e),h=pe.findKey(l,n),p=b.useCallback(A=>{var C=fc.get(l);A?(C==null||C.set(h,A),Ro.set(n,A),na.set(A,n)):(C==null||C.delete(h),Ro.delete(n))},[l,h,n]),m=eC({decorations:d,node:n,renderElement:r,renderChunk:o,renderPlaceholder:i,renderLeaf:s,renderText:a}),w={"data-slate-node":"element",ref:p};if(u&&(w["data-slate-inline"]=!0),!u&&I.hasInlines(l,n)){var v=ge.string(n),y=Dy(v);y==="rtl"&&(w.dir=y)}if(I.isVoid(l,n)){w["data-slate-void"]=!0,!c&&u&&(w.contentEditable=!1);var g=u?"span":"div",[[k]]=ge.texts(n);m=b.createElement(g,{"data-slate-spacer":!0,style:{height:"0",color:"transparent",outline:"none",position:"absolute"}},b.createElement(Kb,{renderPlaceholder:i,decorations:[],isLast:!1,parent:n,text:k})),Vi.set(k,0),ea.set(k,n)}return r({attributes:w,children:m,element:n})},n2=b.memo(t2,(t,e)=>t.element===e.element&&t.renderElement===e.renderElement&&t.renderChunk===e.renderChunk&&t.renderText===e.renderText&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&dh(t.decorations,e.decorations)),r2=t=>{var{attributes:e,children:n,element:r}=t,o=lr(),i=o.isInline(r)?"span":"div";return b.createElement(i,vh(vh({},e),{},{style:{position:"relative"}}),n)};class o2{constructor(e,n){var{chunkSize:r,debug:o}=n;vt(this,"root",void 0),vt(this,"chunkSize",void 0),vt(this,"debug",void 0),vt(this,"reachedEnd",void 0),vt(this,"pointerChunk",void 0),vt(this,"pointerIndex",void 0),vt(this,"pointerIndexStack",void 0),vt(this,"cachedPointerNode",void 0),this.root=e,this.chunkSize=r,this.debug=o??!1,this.pointerChunk=e,this.pointerIndex=-1,this.pointerIndexStack=[],this.reachedEnd=!1,this.validateState()}readLeaf(){if(this.reachedEnd)return null;for(;;)if(this.pointerIndex+1<this.pointerSiblings.length){this.pointerIndex++,this.cachedPointerNode=void 0;break}else{if(this.pointerChunk.type==="root")return this.reachedEnd=!0,null;this.exitChunk()}return this.validateState(),this.enterChunkUntilLeaf(!1),this.pointerNode}returnToPreviousLeaf(){if(this.reachedEnd){this.reachedEnd=!1,this.enterChunkUntilLeaf(!0);return}for(;;)if(this.pointerIndex>=1){this.pointerIndex--,this.cachedPointerNode=void 0;break}else if(this.pointerChunk.type==="root"){this.pointerIndex=-1;return}else this.exitChunk();this.validateState(),this.enterChunkUntilLeaf(!0)}insertBefore(e){this.returnToPreviousLeaf(),this.insertAfter(e),this.readLeaf()}insertAfter(e){if(e.length!==0){for(var n=0,r=0;this.pointerChunk.type==="chunk"&&this.pointerIndex===this.pointerSiblings.length-1;){var o=this.chunkSize-this.pointerSiblings.length,i=Math.min(o,e.length);if(i>0){var s=e.splice(0,i);this.rawInsertAfter(s,n)}this.exitChunk(),n++}if(e.length!==0){var a=this.savePointer(),l=null;if(this.readLeaf())for(;this.pointerChunk.type==="chunk"&&this.pointerIndex===0;){var c=this.chunkSize-this.pointerSiblings.length,u=Math.min(c,e.length);if(u>0){var d=e.splice(-u,u);this.pointerIndex=-1,this.cachedPointerNode=void 0,this.rawInsertAfter(d,r),l||(l=this.savePointer())}this.exitChunk(),r++}this.restorePointer(a);var h=Math.max(n,r);this.rawInsertAfter(e,h),l&&this.restorePointer(l),this.validateState()}}}remove(){this.pointerSiblings.splice(this.pointerIndex--,1),this.cachedPointerNode=void 0,this.pointerSiblings.length===0&&this.pointerChunk.type==="chunk"?(this.exitChunk(),this.remove()):this.invalidateChunk(),this.validateState()}invalidateChunk(){for(var e=this.pointerChunk;e.type==="chunk";e=e.parent)this.root.modifiedChunks.add(e)}get atStart(){return this.pointerChunk.type==="root"&&this.pointerIndex===-1}get pointerSiblings(){return this.pointerChunk.children}getPointerNode(){return this.reachedEnd||this.pointerIndex===-1?null:this.pointerSiblings[this.pointerIndex]}get pointerNode(){if(this.cachedPointerNode!==void 0)return this.cachedPointerNode;var e=this.getPointerNode();return this.cachedPointerNode=e,e}getChunkPath(e){for(var n=[],r=e;r.type==="chunk";r=r.parent){var o=r.parent.children.indexOf(r);if(o===-1)return null;n.unshift(o)}return n}savePointer(){if(this.atStart)return"start";if(!this.pointerNode)throw new Error("Cannot save pointer when pointerNode is null");return{chunk:this.pointerChunk,node:this.pointerNode}}restorePointer(e){if(e==="start"){this.pointerChunk=this.root,this.pointerIndex=-1,this.pointerIndexStack=[],this.reachedEnd=!1,this.cachedPointerNode=void 0;return}var{chunk:n,node:r}=e,o=n.children.indexOf(r);if(o===-1)throw new Error("Cannot restore point because saved node is no longer in saved chunk");var i=this.getChunkPath(n);if(!i)throw new Error("Cannot restore point because saved chunk is no longer connected to root");this.pointerChunk=n,this.pointerIndex=o,this.pointerIndexStack=i,this.reachedEnd=!1,this.cachedPointerNode=r,this.validateState()}enterChunk(e){var n;if(((n=this.pointerNode)===null||n===void 0?void 0:n.type)!=="chunk")throw new Error("Cannot enter non-chunk");if(this.pointerIndexStack.push(this.pointerIndex),this.pointerChunk=this.pointerNode,this.pointerIndex=e?this.pointerSiblings.length-1:0,this.cachedPointerNode=void 0,this.validateState(),this.pointerChunk.children.length===0)throw new Error("Cannot enter empty chunk")}enterChunkUntilLeaf(e){for(;((n=this.pointerNode)===null||n===void 0?void 0:n.type)==="chunk";){var n;this.enterChunk(e)}}exitChunk(){if(this.pointerChunk.type==="root")throw new Error("Cannot exit root");var e=this.pointerChunk;this.pointerChunk=e.parent,this.pointerIndex=this.pointerIndexStack.pop(),this.cachedPointerNode=void 0,this.validateState()}rawInsertAfter(e,n){if(e.length!==0){for(var r=(u,d,h)=>{if(h===1)return u;for(var p=[],m=0;m<this.chunkSize;m++){var w=u.slice(m*h,(m+1)*h);if(w.length===0)break;var v={type:"chunk",key:new rb,parent:d,children:[]};v.children=r(w,v,h/this.chunkSize),p.push(v)}return p},o=this.pointerSiblings.length+e.length,i=0,s=this.chunkSize;s<o;s*=this.chunkSize)i++;var a=Math.max(i,n),l=Math.pow(this.chunkSize,a),c=r(e,this.pointerChunk,l);this.pointerSiblings.splice(this.pointerIndex+1,0,...c),this.pointerIndex+=c.length,this.cachedPointerNode=void 0,this.invalidateChunk(),this.validateState()}}validateState(){if(this.debug){var e=r=>{if(r.type==="chunk"){var{parent:o,children:i}=r;if(!o.children.includes(r))throw new Error("Debug: Chunk ".concat(r.key.id," has an incorrect parent property"));i.forEach(e)}};if(this.root.children.forEach(e),this.cachedPointerNode!==void 0&&this.cachedPointerNode!==this.getPointerNode())throw new Error("Debug: The cached pointer is incorrect and has not been invalidated");var n=this.getChunkPath(this.pointerChunk);if(!n)throw new Error("Debug: The pointer chunk is not connected to the root");if(!U.equals(this.pointerIndexStack,n))throw new Error("Debug: The cached index stack [".concat(this.pointerIndexStack.join(", "),"] does not match the path of the pointer chunk [").concat(n.join(", "),"]"))}}}class i2{constructor(e,n){vt(this,"editor",void 0),vt(this,"children",void 0),vt(this,"cachedKeys",void 0),vt(this,"pointerIndex",void 0),this.editor=e,this.children=n,this.cachedKeys=new Array(n.length),this.pointerIndex=0}read(e){if(e===1)return[this.children[this.pointerIndex++]];var n=this.remaining(e);return this.pointerIndex+=e,n}remaining(e){return e===void 0?this.children.slice(this.pointerIndex):this.children.slice(this.pointerIndex,this.pointerIndex+e)}get reachedEnd(){return this.pointerIndex>=this.children.length}lookAhead(e,n){var r=this.children.indexOf(e,this.pointerIndex);if(r>-1)return r-this.pointerIndex;for(var o=this.pointerIndex;o<this.children.length;o++){var i=this.children[o],s=this.findKey(i,o);if(s===n)return o-this.pointerIndex}return-1}toChunkLeaves(e,n){return e.map((r,o)=>({type:"leaf",node:r,key:this.findKey(r,n+o),index:n+o}))}findKey(e,n){var r=this.cachedKeys[n];if(r)return r;var o=pe.findKey(this.editor,e);return this.cachedKeys[n]=o,o}}var s2=(t,e)=>{var{chunkTree:n,children:r,chunkSize:o,rerenderChildren:i=[],onInsert:s,onUpdate:a,onIndexChange:l,debug:c}=e;n.modifiedChunks.clear();for(var u=new o2(n,{chunkSize:o,debug:c}),d=new i2(t,r),h,p=function(){var y=d.lookAhead(h.node,h.key),g=y>0&&n.movedNodeKeys.has(h.key);if(y===-1||g)return u.remove(),1;var k=d.pointerIndex,A=d.read(y+1),C=A.pop();if(A.length){var E=d.toChunkLeaves(A,k);u.insertBefore(E),A.forEach((S,_)=>{s==null||s(S,k+_)})}var D=d.pointerIndex-1;h.node!==C&&(h.node=C,u.invalidateChunk(),a==null||a(C,D)),h.index!==D&&(h.index=D,l==null||l(C,D)),i.includes(D)&&u.invalidateChunk()};h=u.readLeaf();)p();if(!d.reachedEnd){var m=d.remaining(),w=d.toChunkLeaves(m,d.pointerIndex);u.returnToPreviousLeaf(),u.insertAfter(w),m.forEach((v,y)=>{s==null||s(v,d.pointerIndex+y)})}n.movedNodeKeys.clear()};function Xb(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function a2(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Xb(Object(n),!0).forEach(function(r){vt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Xb(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var Jb=new WeakMap,Rb=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=pe.findKey(e,n),i=Jb.get(o);return i||(i={type:"root",movedNodeKeys:new Set,modifiedChunks:new Set,children:[]},Jb.set(o,i)),r.reconcile&&s2(e,a2({chunkTree:i,children:n.children},r.reconcile)),i},l2=t=>{var{children:e}=t;return e},Qb=t=>{var{root:e,ancestor:n,renderElement:r,renderChunk:o=l2}=t;return n.children.map(i=>{if(i.type==="chunk"){var s=i.key.id,a=o({highest:n===e,lowest:i.children.some(c=>c.type==="leaf"),attributes:{"data-slate-chunk":!0},children:b.createElement(u2,{root:e,ancestor:i,renderElement:r,renderChunk:o})});return b.createElement(b.Fragment,{key:s},a)}var l=i.node;return r(l,i.index,i.key)})},c2=Qb,u2=b.memo(Qb,(t,e)=>t.root===e.root&&t.renderElement===e.renderElement&&t.renderChunk===e.renderChunk&&!e.root.modifiedChunks.has(e.ancestor)),Zb=b.createContext(null),d2=()=>b.useContext(Zb),eC=t=>{var{decorations:e,node:n,renderElement:r,renderChunk:o,renderPlaceholder:i,renderText:s,renderLeaf:a}=t,l=lr();ji.set(l,!1);var c=I.isEditor(n),u=!c&&Ae.isElement(n)&&!l.isInline(n),d=u&&I.hasInlines(l,n),h=d?null:l.getChunkSize(n),p=!!h,{decorationsByChild:m,childrenToRedecorate:w}=f2(l,n,e);p||n.children.forEach((k,A)=>{Vi.set(k,A),ea.set(k,n)});var v=b.useCallback((k,A,C)=>{var E=C??pe.findKey(l,k);return b.createElement(Zb.Provider,{key:"provider-".concat(E.id),value:k},b.createElement(n2,{decorations:m[A],element:k,key:E.id,renderElement:r,renderChunk:o,renderPlaceholder:i,renderLeaf:a,renderText:s}))},[l,m,r,o,i,a,s]),y=(k,A)=>{var C=pe.findKey(l,k);return b.createElement(Kb,{decorations:m[A],key:C.id,isLast:A===n.children.length-1,parent:n,renderPlaceholder:i,renderLeaf:a,renderText:s,text:k})};if(!p)return n.children.map((k,A)=>Oe.isText(k)?y(k,A):v(k,A));var g=Rb(l,n,{reconcile:{chunkSize:h,rerenderChildren:w,onInsert:(k,A)=>{Vi.set(k,A),ea.set(k,n)},onUpdate:(k,A)=>{Vi.set(k,A),ea.set(k,n)},onIndexChange:(k,A)=>{Vi.set(k,A)}}});return b.createElement(c2,{root:g,ancestor:g,renderElement:v,renderChunk:o})},f2=(t,e,n)=>{var r=oP(t,e,n),o=b.useRef(r).current,i=[];o.length=r.length;for(var s=0;s<r.length;s++){var a,l=r[s],c=(a=o[s])!==null&&a!==void 0?a:null;dh(c,l)||(o[s]=l,i.push(s))}return{decorationsByChild:o,childrenToRedecorate:i}},tC=b.createContext(!1),h2=()=>b.useContext(tC),yc=b.createContext({}),p2=(t,e)=>t===e;function m2(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:p2,{deferred:n}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=b.useContext(yc);if(!r)throw new Error("The `useSlateSelector` hook must be used inside the <Slate> component's context.");var{addEventListener:o}=r,i=lr(),s=b.useCallback(()=>t(i),[i,t]),[a,l]=Vb(s,e);return Sr(()=>{var c=o(l,{deferred:n});return l(),c},[o,l,n]),a}function g2(){var t=b.useRef(new Set),e=b.useRef(new Set),n=b.useCallback(()=>{t.current.forEach(s=>s())},[]),r=b.useCallback(()=>{e.current.forEach(s=>s()),e.current.clear()},[]),o=b.useCallback(function(s){var{deferred:a=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=a?()=>e.current.add(s):s;return t.current.add(l),()=>{t.current.delete(l)}},[]),i=b.useMemo(()=>({addEventListener:o,flushDeferred:r}),[o,r]);return{selectorContext:i,onChange:n}}function w2(){var{flushDeferred:t}=b.useContext(yc);Sr(t)}var v2=()=>{var{addEventListener:t}=b.useContext(yc),[,e]=b.useReducer(n=>n+1,0);if(!t)throw new Error("The `useSlate` hook must be used inside the <Slate> component's context.");return Sr(()=>t(e),[t]),lr()};function y2(){var t=lr(),e=b.useRef(!1),n=b.useRef(0),r=b.useCallback(()=>{if(!e.current){e.current=!0;var o=pe.getWindow(t);o.cancelAnimationFrame(n.current),n.current=o.requestAnimationFrame(()=>{e.current=!1})}},[t]);return b.useEffect(()=>()=>cancelAnimationFrame(n.current),[]),{receivedUserInput:e,onUserInput:r}}var b2=(t,e)=>{var n=[],r=()=>{n=[]},o=s=>{if(e.current){var a=s.filter(l=>eh(t,l,s));n.push(...a)}};function i(){n.length>0&&(n.reverse().forEach(s=>{s.type!=="characterData"&&(s.removedNodes.forEach(a=>{s.target.insertBefore(a,s.nextSibling)}),s.addedNodes.forEach(a=>{s.target.removeChild(a)}))}),r())}return{registerMutations:o,restoreDOM:i,clear:r}},C2={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0};class nC extends b.Component{constructor(){super(...arguments),vt(this,"context",null),vt(this,"manager",null),vt(this,"mutationObserver",null)}observe(){var e,{node:n}=this.props;if(!n.current)throw new Error("Failed to attach MutationObserver, `node` is undefined");(e=this.mutationObserver)===null||e===void 0||e.observe(n.current,C2)}componentDidMount(){var{receivedUserInput:e}=this.props,n=this.context;this.manager=b2(n,e),this.mutationObserver=new MutationObserver(this.manager.registerMutations),this.observe()}getSnapshotBeforeUpdate(){var e,n,r,o=(e=this.mutationObserver)===null||e===void 0?void 0:e.takeRecords();if(o!=null&&o.length){var i;(i=this.manager)===null||i===void 0||i.registerMutations(o)}return(n=this.mutationObserver)===null||n===void 0||n.disconnect(),(r=this.manager)===null||r===void 0||r.restoreDOM(),null}componentDidUpdate(){var e;(e=this.manager)===null||e===void 0||e.clear(),this.observe()}componentWillUnmount(){var e;(e=this.mutationObserver)===null||e===void 0||e.disconnect()}render(){return this.props.children}}vt(nC,"contextType",gh);var k2=rn?nC:t=>{var{children:e}=t;return b.createElement(b.Fragment,null,e)},x2=b.createContext(!1),S2=["autoFocus","decorate","onDOMBeforeInput","placeholder","readOnly","renderElement","renderChunk","renderLeaf","renderText","renderPlaceholder","scrollSelectionIntoView","style","as","disableDefaultStyles"],E2=["text"];function rC(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Er(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?rC(Object(n),!0).forEach(function(r){vt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rC(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var D2=t=>b.createElement(b.Fragment,null,eC(t)),oC=b.forwardRef((t,e)=>{var n=b.useCallback(L=>b.createElement(A2,Er({},L)),[]),{autoFocus:r,decorate:o=O2,onDOMBeforeInput:i,placeholder:s,readOnly:a=!1,renderElement:l,renderChunk:c,renderLeaf:u,renderText:d,renderPlaceholder:h=n,scrollSelectionIntoView:p=T2,style:m={},as:w="div",disableDefaultStyles:v=!1}=t,y=wc(t,S2),g=v2(),[k,A]=b.useState(!1),C=b.useRef(null),E=b.useRef([]),[D,S]=b.useState(),_=b.useRef(!1),{onUserInput:O,receivedUserInput:B}=y2(),[,N]=b.useReducer(L=>L+1,0);ib.set(g,N),sh.set(g,a);var F=b.useMemo(()=>({isDraggingInternally:!1,isUpdatingSelection:!1,latestElement:null,hasMarkPlaceholder:!1}),[]);b.useEffect(()=>{C.current&&r&&C.current.focus()},[r]);var M=b.useRef(),T=b.useMemo(()=>vM(()=>{if(ji.get(g)){T();return}var L=pe.toDOMNode(g,g),q=L.getRootNode();if(!_.current&&Jo&&q instanceof ShadowRoot){_.current=!0;var J=NM();J?document.execCommand("indent"):ce.deselect(g),_.current=!1;return}var K=M.current;if((rn||!pe.isComposing(g))&&(!F.isUpdatingSelection||K!=null&&K.isFlushing())&&!F.isDraggingInternally){var re=pe.findDocumentOrShadowRoot(g),{activeElement:ie}=re,he=pe.toDOMNode(g,g),Ce=Qs(re);if(ie===he?(F.latestElement=ie,po.set(g,!0)):po.delete(g),!Ce)return ce.deselect(g);var{anchorNode:Fe,focusNode:qe}=Ce,Le=pe.hasEditableTarget(g,Fe)||pe.isTargetInsideNonReadonlyVoid(g,Fe),de=pe.hasTarget(g,qe);if(Le&&de){var Te=pe.toSlateRange(g,Ce,{exactMatch:!1,suppressThrow:!0});Te&&(!pe.isComposing(g)&&!(K!=null&&K.hasPendingChanges())&&!(K!=null&&K.isFlushing())?ce.select(g,Te):K==null||K.handleUserSelect(Te))}a&&(!Le||!de)&&ce.deselect(g)}},100),[g,a,F]),P=b.useMemo(()=>mM(T,0),[T]);M.current=HP({node:C,onDOMSelectionChange:T,scheduleOnDOMSelectionChange:P}),Sr(()=>{var L,q,J;C.current&&(J=Qf(C.current))?(ob.set(g,J),ta.set(g,C.current),Ro.set(g,C.current),na.set(C.current,g)):Ro.delete(g);var{selection:K}=g,re=pe.findDocumentOrShadowRoot(g),ie=Qs(re);if(!(!ie||!pe.isFocused(g)||(L=M.current)!==null&&L!==void 0&&L.hasPendingAction())){var he=Le=>{var de=ie.type!=="None";if(!(!K&&!de)){var Te=ie.focusNode,_e;if(zi&&ie.rangeCount>1){var tt=ie.getRangeAt(0),cn=ie.getRangeAt(ie.rangeCount-1);tt.startContainer===Te?_e=cn.endContainer:_e=tt.startContainer}else _e=ie.anchorNode;var Vn=ta.get(g),en=!1;if(Xo(Vn,_e)&&Xo(Vn,Te)&&(en=!0),de&&en&&K&&!Le){var At=pe.toSlateRange(g,ie,{exactMatch:!0,suppressThrow:!0});if(At&&oe.equals(At,K)){var ht;if(!F.hasMarkPlaceholder||(ht=_e)!==null&&ht!==void 0&&(ht=ht.parentElement)!==null&&ht!==void 0&&ht.hasAttribute("data-slate-mark-placeholder"))return}}if(K&&!pe.hasRange(g,K)){g.selection=pe.toSlateRange(g,ie,{exactMatch:!1,suppressThrow:!0});return}F.isUpdatingSelection=!0;var ot=null;try{ot=K&&pe.toDOMRange(g,K)}catch{}return ot?(pe.isComposing(g)&&!rn?ie.collapseToEnd():oe.isBackward(K)?ie.setBaseAndExtent(ot.endContainer,ot.endOffset,ot.startContainer,ot.startOffset):ie.setBaseAndExtent(ot.startContainer,ot.startOffset,ot.endContainer,ot.endOffset),p(g,ot)):ie.removeAllRanges(),ot}};ie.rangeCount<=1&&he();var Ce=((q=M.current)===null||q===void 0?void 0:q.isFlushing())==="action";if(!rn||!Ce){setTimeout(()=>{F.isUpdatingSelection=!1});return}var Fe=null,qe=requestAnimationFrame(()=>{if(Ce){var Le=de=>{try{var Te=pe.toDOMNode(g,g);Te.focus(),he(de)}catch{}};Le(),Fe=setTimeout(()=>{Le(!0),F.isUpdatingSelection=!1})}});return()=>{cancelAnimationFrame(qe),Fe&&clearTimeout(Fe)}}});var $=b.useCallback(L=>{iC(g,L);var q=pe.toDOMNode(g,g),J=q.getRootNode();if(_!=null&&_.current&&Jo&&J instanceof ShadowRoot){var K=L.getTargetRanges(),re=K[0],ie=new window.Range;ie.setStart(re.startContainer,re.startOffset),ie.setEnd(re.endContainer,re.endOffset);var he=pe.toSlateRange(g,ie,{exactMatch:!1,suppressThrow:!1});ce.select(g,he),L.preventDefault(),L.stopImmediatePropagation();return}if(O(),!a&&pe.hasEditableTarget(g,L.target)&&!_2(L,i)){var Ce;if(M.current)return M.current.handleDOMBeforeInput(L);P.flush(),T.flush();var{selection:Fe}=g,{inputType:qe}=L,Le=L.dataTransfer||L.data||void 0,de=qe==="insertCompositionText"||qe==="deleteCompositionText";if(de&&pe.isComposing(g))return;var Te=!1;if(qe==="insertText"&&Fe&&oe.isCollapsed(Fe)&&L.data&&L.data.length===1&&/[a-z ]/i.test(L.data)&&Fe.anchor.offset!==0&&(Te=!0,g.marks&&(Te=!1),!ji.get(g))){var _e,tt,{anchor:cn}=Fe,[Vn,en]=pe.toDOMPoint(g,cn),At=(_e=Vn.parentElement)===null||_e===void 0?void 0:_e.closest("a"),ht=pe.getWindow(g);if(Te&&At&&pe.hasDOMNode(g,At)){var ot,lo=ht==null?void 0:ht.document.createTreeWalker(At,NodeFilter.SHOW_TEXT).lastChild();lo===Vn&&((ot=lo.textContent)===null||ot===void 0?void 0:ot.length)===en&&(Te=!1)}if(Te&&Vn.parentElement&&(ht==null||(tt=ht.getComputedStyle(Vn.parentElement))===null||tt===void 0?void 0:tt.whiteSpace)==="pre"){var Wn=I.above(g,{at:cn.path,match:Ms=>Ae.isElement(Ms)&&I.isBlock(g,Ms)});Wn&&ge.string(Wn[0]).includes(" ")&&(Te=!1)}}if((!qe.startsWith("delete")||qe.startsWith("deleteBy"))&&!ji.get(g)){var[bi]=L.getTargetRanges();if(bi){var Fs=pe.toSlateRange(g,bi,{exactMatch:!1,suppressThrow:!1});if(!Fe||!oe.equals(Fe,Fs)){Te=!1;var Is=!de&&g.selection&&I.rangeRef(g,g.selection);ce.select(g,Fs),Is&&ra.set(g,Is)}}}if(de)return;if(Te||L.preventDefault(),Fe&&oe.isExpanded(Fe)&&qe.startsWith("delete")){var Ci=qe.endsWith("Backward")?"backward":"forward";I.deleteFragment(g,{direction:Ci});return}switch(qe){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":{I.deleteFragment(g);break}case"deleteContent":case"deleteContentForward":{I.deleteForward(g);break}case"deleteContentBackward":{I.deleteBackward(g);break}case"deleteEntireSoftLine":{I.deleteBackward(g,{unit:"line"}),I.deleteForward(g,{unit:"line"});break}case"deleteHardLineBackward":{I.deleteBackward(g,{unit:"block"});break}case"deleteSoftLineBackward":{I.deleteBackward(g,{unit:"line"});break}case"deleteHardLineForward":{I.deleteForward(g,{unit:"block"});break}case"deleteSoftLineForward":{I.deleteForward(g,{unit:"line"});break}case"deleteWordBackward":{I.deleteBackward(g,{unit:"word"});break}case"deleteWordForward":{I.deleteForward(g,{unit:"word"});break}case"insertLineBreak":I.insertSoftBreak(g);break;case"insertParagraph":{I.insertBreak(g);break}case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":{qe==="insertFromComposition"&&pe.isComposing(g)&&(A(!1),Qo.set(g,!1)),(Le==null?void 0:Le.constructor.name)==="DataTransfer"?pe.insertData(g,Le):typeof Le=="string"&&(Te?E.current.push(()=>I.insertText(g,Le)):I.insertText(g,Le));break}}var Wr=(Ce=ra.get(g))===null||Ce===void 0?void 0:Ce.unref();ra.delete(g),Wr&&(!g.selection||!oe.equals(g.selection,Wr))&&ce.select(g,Wr)}},[g,T,O,i,a,P]),W=b.useCallback(L=>{L==null?(T.cancel(),P.cancel(),ta.delete(g),Ro.delete(g),C.current&&ho&&C.current.removeEventListener("beforeinput",$)):ho&&L.addEventListener("beforeinput",$),C.current=L,typeof e=="function"?e(L):e&&(e.current=L)},[T,P,g,$,e]);Sr(()=>{var L=pe.getWindow(g),q=K=>{var{target:re}=K,ie=re instanceof HTMLElement?re:null,he=ie==null?void 0:ie.tagName;he==="INPUT"||he==="TEXTAREA"||P()};L.document.addEventListener("selectionchange",q);var J=()=>{F.isDraggingInternally=!1};return L.document.addEventListener("dragend",J),L.document.addEventListener("drop",J),()=>{L.document.removeEventListener("selectionchange",q),L.document.removeEventListener("dragend",J),L.document.removeEventListener("drop",J)}},[P,F]);var V=o([g,[]]),X=JP(o),G=s&&g.children.length===1&&Array.from(ge.texts(g)).length===1&&ge.string(g)===""&&!k,te=b.useCallback(L=>{if(L&&G){var q;S((q=L.getBoundingClientRect())===null||q===void 0?void 0:q.height)}else S(void 0)},[G]);if(G){var H=I.start(g,[]);V.push({[Wi]:!0,placeholder:s,onPlaceholderResize:te,anchor:H,focus:H})}var{marks:j}=g;if(F.hasMarkPlaceholder=!1,g.selection&&oe.isCollapsed(g.selection)&&j){var{anchor:Y}=g.selection,se=ge.leaf(g,Y.path),Q=wc(se,E2);if(!Oe.equals(se,j,{loose:!0})){F.hasMarkPlaceholder=!0;var le=Object.fromEntries(Object.keys(Q).map(L=>[L,null]));V.push(Er(Er(Er({[sb]:!0},le),j),{},{anchor:Y,focus:Y}))}}return b.useEffect(()=>{setTimeout(()=>{var{selection:L}=g;if(L){var{anchor:q}=L,J=ge.leaf(g,q.path);if(j&&!Oe.equals(J,j,{loose:!0})){ar.set(g,j);return}}ar.delete(g)})}),w2(),b.createElement(tC.Provider,{value:a},b.createElement(x2.Provider,{value:k},b.createElement(Wb.Provider,{value:X},b.createElement(k2,{node:C,receivedUserInput:B},b.createElement(w,Er(Er({role:a?void 0:"textbox","aria-multiline":a?void 0:!0,translate:"no"},y),{},{spellCheck:ho||!uc?y.spellCheck:!1,autoCorrect:ho||!uc?y.autoCorrect:"false",autoCapitalize:ho||!uc?y.autoCapitalize:"false","data-slate-editor":!0,"data-slate-node":"value",contentEditable:!a,zindex:-1,suppressContentEditableWarning:!0,ref:W,style:Er(Er({},v?{}:Er({position:"relative",whiteSpace:"pre-wrap",wordWrap:"break-word"},D?{minHeight:D}:{})),m),onBeforeInput:b.useCallback(L=>{if(!ho&&!a&&!mn(L,y.onBeforeInput)&&pe.hasSelectableTarget(g,L.target)&&(L.preventDefault(),!pe.isComposing(g))){var q=L.data;I.insertText(g,q)}},[y.onBeforeInput,g,a]),onInput:b.useCallback(L=>{if(!mn(L,y.onInput)){if(M.current){M.current.handleInput();return}for(var q of E.current)q();E.current=[],pe.isFocused(g)||iC(g,L.nativeEvent)}},[y.onInput,g]),onBlur:b.useCallback(L=>{if(!(a||F.isUpdatingSelection||!pe.hasSelectableTarget(g,L.target)||mn(L,y.onBlur))){var q=pe.findDocumentOrShadowRoot(g);if(F.latestElement!==q.activeElement){var{relatedTarget:J}=L,K=pe.toDOMNode(g,g);if(J!==K&&!(Gn(J)&&J.hasAttribute("data-slate-spacer"))){if(J!=null&&fo(J)&&pe.hasDOMNode(g,J)){var re=pe.toSlateNode(g,J);if(Ae.isElement(re)&&!g.isVoid(re))return}if(Jo){var ie=Qs(q);ie==null||ie.removeAllRanges()}po.delete(g)}}}},[a,F.isUpdatingSelection,F.latestElement,g,y.onBlur]),onClick:b.useCallback(L=>{if(pe.hasTarget(g,L.target)&&!mn(L,y.onClick)&&fo(L.target)){var q=pe.toSlateNode(g,L.target),J=pe.findPath(g,q);if(!I.hasPath(g,J)||ge.get(g,J)!==q)return;if(L.detail===JM&&J.length>=1){var K=J;if(!(Ae.isElement(q)&&I.isBlock(g,q))){var re,ie=I.above(g,{match:Te=>Ae.isElement(Te)&&I.isBlock(g,Te),at:J});K=(re=ie==null?void 0:ie[1])!==null&&re!==void 0?re:J.slice(0,1)}var he=I.range(g,K);ce.select(g,he);return}if(a)return;var Ce=I.start(g,J),Fe=I.end(g,J),qe=I.void(g,{at:Ce}),Le=I.void(g,{at:Fe});if(qe&&Le&&U.equals(qe[1],Le[1])){var de=I.range(g,Ce);ce.select(g,de)}}},[g,y.onClick,a]),onCompositionEnd:b.useCallback(L=>{if(!aa(L)&&pe.hasSelectableTarget(g,L.target)){var q;if(pe.isComposing(g)&&Promise.resolve().then(()=>{A(!1),Qo.set(g,!1)}),(q=M.current)===null||q===void 0||q.handleCompositionEnd(L),mn(L,y.onCompositionEnd)||rn)return;if(!Jo&&!PM&&!FM&&!$M&&!LM&&L.data){var J=ar.get(g);ar.delete(g),J!==void 0&&(Xr.set(g,g.marks),g.marks=J),I.insertText(g,L.data);var K=Xr.get(g);Xr.delete(g),K!==void 0&&(g.marks=K)}}},[y.onCompositionEnd,g]),onCompositionUpdate:b.useCallback(L=>{pe.hasSelectableTarget(g,L.target)&&!mn(L,y.onCompositionUpdate)&&!aa(L)&&(pe.isComposing(g)||(A(!0),Qo.set(g,!0)))},[y.onCompositionUpdate,g]),onCompositionStart:b.useCallback(L=>{if(!aa(L)&&pe.hasSelectableTarget(g,L.target)){var q;if((q=M.current)===null||q===void 0||q.handleCompositionStart(L),mn(L,y.onCompositionStart)||rn)return;A(!0);var{selection:J}=g;if(J&&oe.isExpanded(J)){I.deleteFragment(g);return}}},[y.onCompositionStart,g]),onCopy:b.useCallback(L=>{pe.hasSelectableTarget(g,L.target)&&!mn(L,y.onCopy)&&!aa(L)&&(L.preventDefault(),pe.setFragmentData(g,L.clipboardData,"copy"))},[y.onCopy,g]),onCut:b.useCallback(L=>{if(!a&&pe.hasSelectableTarget(g,L.target)&&!mn(L,y.onCut)&&!aa(L)){L.preventDefault(),pe.setFragmentData(g,L.clipboardData,"cut");var{selection:q}=g;if(q)if(oe.isExpanded(q))I.deleteFragment(g);else{var J=ge.parent(g,q.anchor.path);I.isVoid(g,J)&&ce.delete(g)}}},[a,g,y.onCut]),onDragOver:b.useCallback(L=>{if(pe.hasTarget(g,L.target)&&!mn(L,y.onDragOver)){var q=pe.toSlateNode(g,L.target);Ae.isElement(q)&&I.isVoid(g,q)&&L.preventDefault()}},[y.onDragOver,g]),onDragStart:b.useCallback(L=>{if(!a&&pe.hasTarget(g,L.target)&&!mn(L,y.onDragStart)){var q=pe.toSlateNode(g,L.target),J=pe.findPath(g,q),K=Ae.isElement(q)&&I.isVoid(g,q)||I.void(g,{at:J,voids:!0});if(K){var re=I.range(g,J);ce.select(g,re)}F.isDraggingInternally=!0,pe.setFragmentData(g,L.dataTransfer,"drag")}},[a,g,y.onDragStart,F]),onDrop:b.useCallback(L=>{if(!a&&pe.hasTarget(g,L.target)&&!mn(L,y.onDrop)){L.preventDefault();var q=g.selection,J=pe.findEventRange(g,L),K=L.dataTransfer;ce.select(g,J),F.isDraggingInternally&&q&&!oe.equals(q,J)&&!I.void(g,{at:J,voids:!0})&&ce.delete(g,{at:q}),pe.insertData(g,K),pe.isFocused(g)||pe.focus(g)}},[a,g,y.onDrop,F]),onDragEnd:b.useCallback(L=>{!a&&F.isDraggingInternally&&y.onDragEnd&&pe.hasTarget(g,L.target)&&y.onDragEnd(L)},[a,F,y,g]),onFocus:b.useCallback(L=>{if(!a&&!F.isUpdatingSelection&&pe.hasEditableTarget(g,L.target)&&!mn(L,y.onFocus)){var q=pe.toDOMNode(g,g),J=pe.findDocumentOrShadowRoot(g);if(F.latestElement=J.activeElement,zi&&L.target!==q){q.focus();return}po.set(g,!0)}},[a,F,g,y.onFocus]),onKeyDown:b.useCallback(L=>{if(!a&&pe.hasEditableTarget(g,L.target)){var q;(q=M.current)===null||q===void 0||q.handleKeyDown(L);var{nativeEvent:J}=L;if(pe.isComposing(g)&&J.isComposing===!1&&(Qo.set(g,!1),A(!1)),mn(L,y.onKeyDown)||pe.isComposing(g))return;var{selection:K}=g,re=g.children[K!==null?K.focus.path[0]:0],ie=Dy(ge.string(re))==="rtl";if(kt.isRedo(J)){L.preventDefault();var he=g;typeof he.redo=="function"&&he.redo();return}if(kt.isUndo(J)){L.preventDefault();var Ce=g;typeof Ce.undo=="function"&&Ce.undo();return}if(kt.isMoveLineBackward(J)){L.preventDefault(),ce.move(g,{unit:"line",reverse:!0});return}if(kt.isMoveLineForward(J)){L.preventDefault(),ce.move(g,{unit:"line"});return}if(kt.isExtendLineBackward(J)){L.preventDefault(),ce.move(g,{unit:"line",edge:"focus",reverse:!0});return}if(kt.isExtendLineForward(J)){L.preventDefault(),ce.move(g,{unit:"line",edge:"focus"});return}if(kt.isMoveBackward(J)){L.preventDefault(),K&&oe.isCollapsed(K)?ce.move(g,{reverse:!ie}):ce.collapse(g,{edge:ie?"end":"start"});return}if(kt.isMoveForward(J)){L.preventDefault(),K&&oe.isCollapsed(K)?ce.move(g,{reverse:ie}):ce.collapse(g,{edge:ie?"start":"end"});return}if(kt.isMoveWordBackward(J)){L.preventDefault(),K&&oe.isExpanded(K)&&ce.collapse(g,{edge:"focus"}),ce.move(g,{unit:"word",reverse:!ie});return}if(kt.isMoveWordForward(J)){L.preventDefault(),K&&oe.isExpanded(K)&&ce.collapse(g,{edge:"focus"}),ce.move(g,{unit:"word",reverse:ie});return}if(ho){if((rh||Jo)&&K&&(kt.isDeleteBackward(J)||kt.isDeleteForward(J))&&oe.isCollapsed(K)){var Fe=ge.parent(g,K.anchor.path);if(Ae.isElement(Fe)&&I.isVoid(g,Fe)&&(I.isInline(g,Fe)||I.isBlock(g,Fe))){L.preventDefault(),I.deleteBackward(g,{unit:"block"});return}}}else{if(kt.isBold(J)||kt.isItalic(J)||kt.isTransposeCharacter(J)){L.preventDefault();return}if(kt.isSoftBreak(J)){L.preventDefault(),I.insertSoftBreak(g);return}if(kt.isSplitBlock(J)){L.preventDefault(),I.insertBreak(g);return}if(kt.isDeleteBackward(J)){L.preventDefault(),K&&oe.isExpanded(K)?I.deleteFragment(g,{direction:"backward"}):I.deleteBackward(g);return}if(kt.isDeleteForward(J)){L.preventDefault(),K&&oe.isExpanded(K)?I.deleteFragment(g,{direction:"forward"}):I.deleteForward(g);return}if(kt.isDeleteLineBackward(J)){L.preventDefault(),K&&oe.isExpanded(K)?I.deleteFragment(g,{direction:"backward"}):I.deleteBackward(g,{unit:"line"});return}if(kt.isDeleteLineForward(J)){L.preventDefault(),K&&oe.isExpanded(K)?I.deleteFragment(g,{direction:"forward"}):I.deleteForward(g,{unit:"line"});return}if(kt.isDeleteWordBackward(J)){L.preventDefault(),K&&oe.isExpanded(K)?I.deleteFragment(g,{direction:"backward"}):I.deleteBackward(g,{unit:"word"});return}if(kt.isDeleteWordForward(J)){L.preventDefault(),K&&oe.isExpanded(K)?I.deleteFragment(g,{direction:"forward"}):I.deleteForward(g,{unit:"word"});return}}}},[a,g,y.onKeyDown]),onPaste:b.useCallback(L=>{!a&&pe.hasEditableTarget(g,L.target)&&!mn(L,y.onPaste)&&(!ho||EM(L.nativeEvent)||Jo)&&(L.preventDefault(),pe.insertData(g,L.clipboardData))},[a,g,y.onPaste])}),b.createElement(D2,{decorations:V,node:g,renderElement:l,renderChunk:c,renderPlaceholder:h,renderLeaf:u,renderText:d}))))))}),A2=t=>{var{attributes:e,children:n}=t;return b.createElement("span",Er({},e),n,rn&&b.createElement("br",null))},O2=()=>[],T2=(t,e)=>{var n=!!t.selection&&oe.isBackward(t.selection),r=e.cloneRange();if(r.collapse(n),r.getBoundingClientRect){var o=r.startContainer.parentElement,i=r.getBoundingClientRect(),s=i.width===0&&i.height===0&&i.x===0&&i.y===0;if(s){var a=o.getBoundingClientRect(),l=a.width>0||a.height>0;if(l)return}o.getBoundingClientRect=r.getBoundingClientRect.bind(r),CM(o,{scrollMode:"if-needed"}),delete o.getBoundingClientRect}},mn=(t,e)=>{if(!e)return!1;var n=e(t);return n??(t.isDefaultPrevented()||t.isPropagationStopped())},aa=t=>fo(t.target)&&(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement),_2=(t,e)=>{if(!e)return!1;var n=e(t);return n??t.defaultPrevented},iC=(t,e)=>{var n=t;if(e.inputType==="historyUndo"&&typeof n.undo=="function"){n.undo();return}if(e.inputType==="historyRedo"&&typeof n.redo=="function"){n.redo();return}},sC=b.createContext(!1),N2=()=>b.useContext(sC),aC=parseInt(b.version.split(".")[0],10),B2=["editor","children","onChange","onSelectionChange","onValueChange","initialValue"],lC=t=>{var{editor:e,children:n,onChange:r,onSelectionChange:o,onValueChange:i,initialValue:s}=t,a=wc(t,B2);b.useState(()=>{if(!ge.isNodeList(s))throw new Error("[Slate] initialValue is invalid! Expected a list of elements but got: ".concat($t.stringify(s)));if(!I.isEditor(e))throw new Error("[Slate] editor is invalid! You passed: ".concat($t.stringify(e)));e.children=s,Object.assign(e,a)});var{selectorContext:l,onChange:c}=g2(),u=b.useCallback(()=>{r&&r(e.children),o&&e.operations.find(p=>p.type==="set_selection")&&o(e.selection),i&&e.operations.find(p=>p.type!=="set_selection")&&i(e.children),c()},[e,c,r,o,i]);b.useEffect(()=>(ah.set(e,u),()=>{ah.set(e,()=>{})}),[e,u]);var[d,h]=b.useState(pe.isFocused(e));return b.useEffect(()=>{h(pe.isFocused(e))},[e]),Sr(()=>{var p=()=>h(pe.isFocused(e));return aC>=17?(document.addEventListener("focusin",p),document.addEventListener("focusout",p),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",p)}):(document.addEventListener("focus",p,!0),document.addEventListener("blur",p,!0),()=>{document.removeEventListener("focus",p,!0),document.removeEventListener("blur",p,!0)})},[]),b.createElement(yc.Provider,{value:l},b.createElement(gh.Provider,{value:e},b.createElement(sC.Provider,{value:d},n)))},F2=()=>{var t=d2();if(!t)return!1;var e=b.useCallback(n=>{if(!n.selection)return!1;var r=pe.findPath(n,t),o=I.range(n,r);return!!oe.intersection(o,n.selection)},[t]);return m2(e,void 0,{deferred:!0})},cC=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"x-slate-fragment",r=e;r=XM(r,n);var{onChange:o,apply:i,insertText:s}=r;return r.getChunkSize=()=>null,rn&&(r.insertText=(a,l)=>(Jr.delete(r),s(a,l))),r.onChange=a=>{var l=aC<18?Lo.unstable_batchedUpdates:c=>c();l(()=>{o(a)})},r.apply=a=>{if(a.type==="move_node"){var l=ge.parent(r,a.path),c=!!r.getChunkSize(l);if(c){var u=ge.get(r,a.path),d=Rb(r,l),h=pe.findKey(r,u);d.movedNodeKeys.add(h)}}i(a)},r};const uC=mt.createContext(null),I2=()=>{const t=mt.useContext(uC);if(!t)throw new Error("useSlateEditor must be used within SlateEditorContext");return t},M2=t=>{const{attributes:e,children:n,element:r,...o}=t;return Li(r)?f.jsx(P2,{attributes:e,element:r,...o,children:n}):f.jsx("p",{...e,children:n})},P2=t=>{const{attributes:e,element:n,children:r,onVariableClick:o,validateVariable:i,renderVariableTag:s,renderVariableTooltip:a,showRemoveButton:l=!0,disabled:c,readOnly:u}=t,[d,h]=mt.useState(!0),p=I2(),m=n.value.replace(/^\{\{|\}\}$/g,"");b.useEffect(()=>{if(i){const k=i(m);k instanceof Promise?k.then(h).catch(()=>h(!1)):h(k)}},[m,i]);const w=k=>{k.preventDefault(),k.stopPropagation(),!(c||u)&&(o==null||o(n.value))},v=k=>{if(k.preventDefault(),k.stopPropagation(),!(c||u))try{const A=pe.findPath(p,n);ce.removeNodes(p,{at:A})}catch{}},y=s?s(n.value,d):m,g=a?a(n.value):n.value;return f.jsxs("span",{...e,children:[f.jsxs("button",{contentEditable:!1,className:`variable-tag ${d?"valid":"invalid"}`,disabled:c||u,onClick:w,style:{userSelect:"none"},type:"button",children:[f.jsx(x.Tooltip,{title:g,children:f.jsx("span",{className:"variable-tag-content",children:y})}),l&&!c&&!u&&f.jsx(Z.CloseCircleFilled,{className:"variable-tag-remove",onClick:v})]}),f.jsx("span",{style:{fontSize:0,lineHeight:0,width:0,height:0,display:"inline-block"},children:r})]})},L2=({attributes:t,children:e})=>f.jsx("span",{...t,children:e}),$2=t=>{const{isInline:e,isVoid:n,deleteBackward:r,deleteForward:o}=t;return t.isInline=i=>Li(i)?!0:e(i),t.isVoid=i=>Li(i)?!0:n(i),t.deleteBackward=i=>{const{selection:s}=t;if(s&&oe.isCollapsed(s)){const[a]=I.nodes(t,{match:l=>!I.isEditor(l)&&Ae.isElement(l)&&Li(l)});if(a){const[,l]=a,c=I.before(t,s);if(c){const[u]=I.node(t,c);if(Ae.isElement(u)&&Li(u)){ce.removeNodes(t,{at:l});return}}}}r(i)},t.deleteForward=i=>{const{selection:s}=t;if(s&&oe.isCollapsed(s)){const a=I.after(t,s);if(a){const[l,c]=I.node(t,a);if(Ae.isElement(l)&&Li(l)){ce.removeNodes(t,{at:c});return}}}o(i)},t},bc=({value:t="",onChange:e,placeholder:n,disabled:r=!1,readOnly:o=!1,multiline:i=!1,minRows:s=1,maxRows:a,className:l,style:c,capturePattern:u=z0,onVariableClick:d,validateVariable:h,renderVariableTag:p,renderVariableTooltip:m,showRemoveButton:w=!0,onFocus:v,onBlur:y})=>{const g=typeof t=="string"?t:"",k=b.useId(),A=b.useRef(null),C=b.useRef(!1),E=b.useRef(g),D=b.useMemo(()=>(A.current||(A.current=$2(ZI(cC(xy())))),A.current),[]),S=b.useMemo(()=>Df(g,u),[]),_=b.useCallback((V,X)=>{const te={type:"variable-tag",value:V.startsWith("{{")?V:`{{${V}}}`,children:[{text:""}]};try{pe.focus(D)}catch{}ce.insertNodes(D,te),ce.move(D,{distance:1,unit:"offset"});const H=Af(D.children);e==null||e(H)},[D,e]),O=b.useCallback(()=>{try{pe.focus(D)}catch{}},[D]),B=B0(k,_,O),N=b.useCallback(V=>{const X=Af(V);X!==E.current&&(E.current=X,e==null||e(X))},[e]),F=b.useCallback(V=>{!i&&V.key==="Enter"&&V.preventDefault()},[i]),M=b.useCallback(()=>{B.activate(),v==null||v()},[B,v]),T=b.useCallback(()=>{y==null||y()},[y]);b.useEffect(()=>{if(!C.current){C.current=!0;return}const V=Af(D.children);if(!(g===V||g===E.current)){E.current=g;try{ce.select(D,{anchor:I.start(D,[]),focus:I.end(D,[])}),ce.delete(D);const X=Df(g,u);ce.insertNodes(D,X,{at:[0]});const G=D.children;if(G.length>1&&G[0].type==="paragraph"){const te=G[0];te.children.length===1&&"text"in te.children[0]&&te.children[0].text===""&&ce.removeNodes(D,{at:[0]})}}catch{D.children=Df(g,u),D.onChange()}}},[g,u,D]);const P=b.useCallback(V=>f.jsx(M2,{...V,onVariableClick:d,validateVariable:h,renderVariableTag:p,renderVariableTooltip:m,showRemoveButton:w,disabled:r,readOnly:o}),[d,h,p,m,w,r,o]),$=b.useCallback(V=>f.jsx(L2,{...V}),[]),W={...c,minHeight:i?`${s*24}px`:void 0,maxHeight:i&&a?`${a*24}px`:void 0,overflowY:i?"auto":void 0};return f.jsx(uC.Provider,{value:D,children:f.jsx("div",{className:`variable-input-wrapper ${r?"disabled":""} ${o?"readonly":""} ${i?"multiline":""} ${l||""}`,style:W,children:f.jsx(lC,{editor:D,initialValue:S,onChange:N,children:f.jsx(oC,{className:"variable-input-editable",renderElement:P,renderLeaf:$,placeholder:n,readOnly:r||o,onKeyDown:F,onFocus:M,onBlur:T})})})})},dC=({rows:t=4,autoSize:e,minRows:n,maxRows:r,...o})=>{const i=typeof e=="object"?e.minRows:n??t,s=typeof e=="object"?e.maxRows:r;return f.jsx(bc,{...o,multiline:!0,minRows:i,maxRows:s})},Cc={normal:{label:"文本",icon:f.jsx(Z.FontSizeOutlined,{}),description:"普通文本输入"},expression:{label:"表达式",icon:f.jsx(Z.FunctionOutlined,{}),description:"支持变量引用的表达式模式"},code:{label:"代码",icon:f.jsx(Z.CodeOutlined,{}),description:"JavaScript 代码模式"}},la=({value:t="",onChange:e,availableModes:n=["normal","expression"],defaultMode:r="normal",mode:o,onModeChange:i,disabled:s=!1,readOnly:a=!1,placeholder:l,multiline:c=!1,rows:u=4,validateVariable:d,renderVariableTag:h,renderVariableTooltip:p,renderNormalMode:m,children:w,hideModeSwitch:v=!1,modeSwitchPosition:y="top-left",compact:g=!1})=>{const k=()=>t&&typeof t=="string"&&/\{\{.*\}\}/.test(t)?"expression":r,[A,C]=b.useState(k),E=o??A;b.useEffect(()=>{o!==void 0&&C(o)},[o]);const D=b.useCallback(N=>{C(N),i==null||i(N)},[i]),S=b.useCallback(N=>{e==null||e(N)},[e]),_=b.useMemo(()=>n.filter(N=>Cc[N]),[n]),O=()=>v||_.length<=1?null:f.jsx("div",{className:`value-mode-switch ${y}`,children:f.jsx(x.Radio.Group,{value:E,onChange:N=>D(N.target.value),size:"small",disabled:s||a,optionType:"button",buttonStyle:"solid",children:_.map(N=>f.jsxs(x.Radio.Button,{value:N,title:Cc[N].description,children:[Cc[N].icon,f.jsx("span",{className:"mode-label",children:Cc[N].label})]},N))})}),B=()=>{switch(E){case"normal":return w?mt.cloneElement(w,{value:t,onChange:S,disabled:s,readOnly:a}):m?m({value:t,onChange:S,disabled:s,readOnly:a,placeholder:l}):c?f.jsx(x.Input.TextArea,{value:t,onChange:N=>S(N.target.value),disabled:s,readOnly:a,placeholder:l,rows:u}):f.jsx(x.Input,{value:t,onChange:N=>S(N.target.value),disabled:s,readOnly:a,placeholder:l});case"expression":return c?f.jsx(dC,{value:t,onChange:S,disabled:s,readOnly:a,placeholder:l||"输入文本或使用 {{变量}}",rows:u,validateVariable:d,renderVariableTag:h,renderVariableTooltip:p}):f.jsx(bc,{value:t,onChange:S,disabled:s,readOnly:a,placeholder:l||"输入文本或使用 {{变量}}",validateVariable:d,renderVariableTag:h,renderVariableTooltip:p});case"code":return f.jsx(x.Input.TextArea,{value:t,onChange:N=>S(N.target.value),disabled:s,readOnly:a,placeholder:l||"// 输入 JavaScript 代码",rows:u,className:"code-mode-textarea",style:{fontFamily:"monospace"}});default:return null}};return f.jsxs("div",{className:`value-mode-wrapper${g?" compact":""}`,children:[O(),f.jsx("div",{className:"value-mode-content",children:B()})]})};function pt(t,e={}){const n={needsFormItemName:!0,supportsVariableInsert:!1,supportsAiFillable:!1,...e};if(n.supportsVariableInsert&&n.supportsAiFillable)return{component:t,meta:n};const r=o=>{const{field:i,disabled:s,readOnly:a,context:l,value:c,onChange:u}=o,d=n.valuePropName?o[n.valuePropName]??c:c;let h=f.jsx(t,{...o,value:d});return i.variableInsert&&!n.supportsVariableInsert&&(h=f.jsx(la,{availableModes:["normal","expression"],defaultMode:"normal",disabled:s,readOnly:a,placeholder:i.placeholder,validateVariable:l.validateVariable,renderVariableTag:l.renderVariableTag,renderVariableTooltip:l.renderVariableTooltip,modeSwitchPosition:"top-right",value:d,onChange:u,children:h})),i.aiFillable&&!n.supportsAiFillable&&(h=f.jsx(H0,{aiFillable:!0,disabled:s,children:h})),h};return r.displayName=`FieldComponent(${t.displayName||t.name||"Anonymous"})`,{component:r,meta:n}}function go(t,e={}){return{component:t,meta:e}}const fC=({children:t})=>f.jsx(x.Button,{disabled:!0,style:{pointerEvents:"none"},children:t}),hC=({field:t,disabled:e,value:n,onChange:r,id:o})=>{const i=t.showThousandsSeparator?l=>`${l}`.replace(/\B(?=(\d{3})+(?!\d))/g,","):void 0,s=t.showThousandsSeparator?l=>l==null?void 0:l.replace(/\$\s?|(,*)/g,""):void 0,a=f.jsx(x.InputNumber,{disabled:e,placeholder:t.placeholder,min:t.min,max:t.max,step:t.step,precision:t.precision,controls:t.controls,formatter:i,parser:s,style:{width:"100%"},value:n,onChange:r,id:o});return!t.addonBefore&&!t.addonAfter?a:f.jsxs(x.Space.Compact,{style:{width:"100%"},children:[t.addonBefore?f.jsx(fC,{children:t.addonBefore}):null,a,t.addonAfter?f.jsx(fC,{children:t.addonAfter}):null]})};hC.displayName="NumberFieldControl";const H2=pt(hC,{needsFormItemName:!0}),pC=({field:t,disabled:e,readOnly:n,value:r,onChange:o,id:i})=>f.jsx(x.Input.Password,{disabled:e,readOnly:n,placeholder:t.placeholder,value:r,onChange:s=>o==null?void 0:o(s.target.value),id:i});pC.displayName="PasswordFieldControl";const z2=pt(pC,{needsFormItemName:!0}),mC=({field:t,disabled:e,readOnly:n,context:r,value:o,onChange:i,id:s})=>{const a=t.autoSize??(t.minRows||t.maxRows?{minRows:t.minRows,maxRows:t.maxRows}:void 0),l=t.minRows||4;if(t.variableInsert)return f.jsx(la,{availableModes:["normal","expression"],defaultMode:"normal",disabled:e,readOnly:n,placeholder:t.placeholder,multiline:!0,rows:l,validateVariable:r.validateVariable,renderVariableTag:r.renderVariableTag,renderVariableTooltip:r.renderVariableTooltip,modeSwitchPosition:"top-right",value:o,onChange:i,children:f.jsx(x.Input.TextArea,{placeholder:t.placeholder,rows:l,autoSize:a,showCount:t.showCount,maxLength:t.maxLength})});const c=()=>{var d;(d=r.eventHandlers)==null||d.onBlur(t.name)},u=()=>{var d;(d=r.eventHandlers)==null||d.onFocus(t.name)};return f.jsx(x.Input.TextArea,{disabled:e,readOnly:n,placeholder:t.placeholder,rows:l,autoSize:a,showCount:t.showCount,maxLength:t.maxLength,value:o,onChange:d=>i==null?void 0:i(d.target.value),onBlur:c,onFocus:u,id:s})};mC.displayName="TextareaFieldControl";const j2=pt(mC,{supportsVariableInsert:!0,needsFormItemName:!0}),gC=({field:t,disabled:e,readOnly:n,value:r,onChange:o,id:i,context:s})=>{const a=()=>{var c;(c=s.eventHandlers)==null||c.onBlur(t.name)},l=()=>{var c;(c=s.eventHandlers)==null||c.onFocus(t.name)};return f.jsx(x.Input,{disabled:e,readOnly:n,placeholder:t.placeholder,value:r,onChange:c=>o==null?void 0:o(c.target.value),onBlur:a,onFocus:l,id:i})};gC.displayName="TextFieldControl";const V2=pt(gC,{supportsVariableInsert:!1,needsFormItemName:!0}),wC=({field:t,disabled:e,context:n})=>{const r=Ql(),{renderVariableTag:o,renderVariableTooltip:i,validateVariable:s,values:a,optionsLoader:l}=n,c=W2(t),u=r.get(t.itemSchema.type),d=u==null?void 0:u.component;return f.jsx(x.Form.List,{name:t.name,rules:c,children:(h,{add:p,remove:m},{errors:w})=>f.jsxs(x.Space,{direction:"vertical",style:{width:"100%"},children:[h.map((v,y)=>f.jsxs(x.Card,{size:"small",title:t.itemLabel||`Item ${y+1}`,children:[f.jsx(x.Form.Item,{name:[v.name,t.itemSchema.name],label:t.itemSchema.label,rules:Mi(t.itemSchema.rules||[],a,t.itemSchema.type),children:d&&f.jsx(d,{field:t.itemSchema,disabled:e,readOnly:!1,context:{values:a,optionsLoader:l,renderVariableTag:o,renderVariableTooltip:i,validateVariable:s}})}),f.jsxs("div",{style:{textAlign:"right"},children:[f.jsx(x.Button,{type:"link",danger:!0,onClick:()=>m(v.name),disabled:e||t.minItems!==void 0&&h.length<=t.minItems,children:"移除"}),t.allowCopy&&f.jsx(x.Button,{type:"link",onClick:()=>{const g=qn(a,`${t.name}.${v.name}`);p(g,y+1)},disabled:e,children:"复制"})]})]},v.key)),f.jsx(x.Button,{type:"dashed",block:!0,onClick:()=>p(t.itemSchema.defaultValue),disabled:e||t.maxItems!==void 0&&h.length>=t.maxItems,children:"添加"}),f.jsx(x.Form.ErrorList,{errors:w})]})})};wC.displayName="ArrayFieldControl";function W2(t){var n;const e=[];if((n=t.rules)!=null&&n.some(r=>r.type==="required")){const r=t.rules.find(o=>o.type==="required");e.push({validator:async(o,i)=>{if(!i||i.length===0)throw new Error((r==null?void 0:r.message)||"此项为必填")}})}return t.minItems!==void 0&&e.push({validator:async(r,o)=>{if(!o||o.length<t.minItems)throw new Error(`至少需要 ${t.minItems} 项`)}}),t.maxItems!==void 0&&e.push({validator:async(r,o)=>{if(o&&o.length>t.maxItems)throw new Error(`最多允许 ${t.maxItems} 项`)}}),e}const U2=go(wC,{isComplexField:!0,needsFormItemName:!1}),vC=({field:t,disabled:e,context:n})=>{const r=Ql(),o=x.Form.useFormInstance(),{renderVariableTag:i,renderVariableTooltip:s,validateVariable:a,values:l,optionsLoader:c}=n,u=t,d=G2(u),h=u.__arrayObjectDepth??0,p=u.__arrayObjectLevelBackgroundColors??t.levelBackgroundColors,m=eL(t,h,p),w=rL(t);return f.jsx(x.Form.List,{name:u.name,rules:w,children:(v,{add:y,remove:g,move:k},{errors:A})=>f.jsxs(x.Space,{direction:"vertical",style:{width:"100%"},children:[v.map((C,E)=>f.jsx(x.Card,{size:"small",style:tL(m),bodyStyle:nL(m),title:f.jsx(yC,{field:t,index:E,titlePath:K2(t,d,C.name),disabled:e}),extra:f.jsxs(x.Space,{children:[t.allowCopy&&f.jsx(x.Tooltip,{title:"复制",children:f.jsx(x.Button,{"aria-label":"复制",type:"text",size:"small",icon:f.jsx(Z.CopyOutlined,{}),onClick:()=>{const D=[...d,C.name],S=o.getFieldValue(D)??CC(l,D);y(S,E+1)},disabled:e||t.maxItems!==void 0&&v.length>=t.maxItems})}),f.jsx(x.Tooltip,{title:"置顶",children:f.jsx(x.Button,{"aria-label":"置顶",type:"text",size:"small",icon:f.jsx(Z.VerticalAlignTopOutlined,{}),disabled:e||E===0,onClick:()=>k(E,0)})}),f.jsx(x.Tooltip,{title:"向上",children:f.jsx(x.Button,{"aria-label":"向上",type:"text",size:"small",icon:f.jsx(Z.ArrowUpOutlined,{}),disabled:e||E===0,onClick:()=>k(E,E-1)})}),f.jsx(x.Tooltip,{title:"向下",children:f.jsx(x.Button,{"aria-label":"向下",type:"text",size:"small",icon:f.jsx(Z.ArrowDownOutlined,{}),disabled:e||E===v.length-1,onClick:()=>k(E,E+1)})}),f.jsx(x.Tooltip,{title:"置底",children:f.jsx(x.Button,{"aria-label":"置底",type:"text",size:"small",icon:f.jsx(Z.VerticalAlignBottomOutlined,{}),disabled:e||E===v.length-1,onClick:()=>k(E,v.length-1)})}),f.jsx(x.Tooltip,{title:"删除",children:f.jsx(x.Button,{"aria-label":"删除",type:"text",size:"small",danger:!0,icon:f.jsx(Z.DeleteOutlined,{}),onClick:()=>g(C.name),disabled:e||t.minItems!==void 0&&v.length<=t.minItems})})]}),children:f.jsx("div",{style:Q2(t),children:t.columns.map(D=>{const S=r.get(D.type),_=S==null?void 0:S.component,O=[C.name,D.name],B=[...d,C.name,D.name];return f.jsx(x.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const N=o.getFieldValue([...d,C.name])??CC(l,[...d,C.name])??{};return Ys(D,N)?S!=null&&S.meta.isComplexField?f.jsx(x.Form.Item,{label:D.label,tooltip:D.tooltip,extra:D.helpText||D.extra||D.description,children:_&&f.jsx(_,{field:q2(D,O,B,h+1,p),disabled:e,readOnly:!1,context:{values:l,optionsLoader:c,renderVariableTag:i,renderVariableTooltip:s,validateVariable:a}})}):f.jsx(x.Form.Item,{name:O,label:D.label,tooltip:D.tooltip,extra:D.helpText||D.extra||D.description,rules:Mi(D.rules||[],N,D.type),preserve:D.visibleWhen?!1:void 0,children:_&&f.jsx(_,{field:D,disabled:e,readOnly:!1,context:{values:l,optionsLoader:c,renderVariableTag:i,renderVariableTooltip:s,validateVariable:a}})}):null}},D.name)})})},C.key)),f.jsx(x.Button,{type:"dashed",block:!0,icon:f.jsx(Z.PlusOutlined,{}),onClick:()=>y(),disabled:e||t.maxItems!==void 0&&v.length>=t.maxItems,children:R2(t)}),f.jsx(x.Form.ErrorList,{errors:A})]})})};vC.displayName="ArrayObjectFieldControl";const yC=({field:t,index:e,titlePath:n,disabled:r})=>{const o=x.Form.useFormInstance(),i=x.Form.useWatch(n,o),[s,a]=mt.useState(!1),[l,c]=mt.useState(""),u=J2(t,e),d=X2(i,u),h=()=>{c(d),a(!0)},p=()=>{c(""),a(!1)},m=()=>{if(n){const w=l.trim()||void 0;o.setFieldValue(n,w)}a(!1),c("")};return n?s?f.jsxs(x.Space,{children:[f.jsx(x.Input,{size:"small",value:l,onChange:w=>c(w.target.value),onPressEnter:m,style:{width:200},placeholder:"请输入标题"}),f.jsx(x.Button,{"aria-label":"保存标题",type:"text",size:"small",icon:f.jsx(Z.CheckOutlined,{style:{color:"#52c41a"}}),onClick:m}),f.jsx(x.Button,{"aria-label":"取消标题编辑",type:"text",size:"small",icon:f.jsx(Z.CloseOutlined,{}),onClick:p})]}):f.jsxs(x.Space,{children:[f.jsx("span",{children:d}),f.jsx(x.Button,{"aria-label":"编辑标题",type:"text",size:"small",icon:f.jsx(Z.EditOutlined,{}),disabled:r,onClick:h})]}):f.jsx("span",{children:d})};yC.displayName="ArrayObjectRowTitle";function q2(t,e,n,r,o){return{...t,name:e,__arrayObjectRootNamePath:n,__arrayObjectDepth:r,__arrayObjectLevelBackgroundColors:o}}function bC(t){return Array.isArray(t)?t:[t]}function G2(t){return t.__arrayObjectRootNamePath??bC(t.name)}function CC(t,e){return qn(t,bC(e).join("."))}function K2(t,e,n){const r=Y2(t);return r?[...e,n,r]:void 0}function Y2(t){return t.titleFieldName?t.titleFieldName:t.titleEditable?"title":void 0}function X2(t,e){return typeof t=="string"&&t.trim()?t:e}function J2(t,e){return t.label?`${t.label} #${e+1}`:`Item ${e+1}`}function R2(t){return t.label?`添加${t.label}`:"添加行"}function Q2(t){return t.columnLayout!=="grid"?{display:"flex",flexDirection:"column",width:"100%",gap:0}:{display:"grid",gridTemplateColumns:`repeat(${Z2(t)}, minmax(0, 1fr))`,columnGap:16,rowGap:0,width:"100%",alignItems:"start"}}function Z2(t){const e=typeof t.columnCount=="number"&&Number.isFinite(t.columnCount)?Math.floor(t.columnCount):3;return Math.max(1,Math.min(e,Math.max(t.columns.length,1)))}function eL(t,e,n){if(t.backgroundColor)return t.backgroundColor;if(n!=null&&n.length)return n[e%n.length]}function tL(t){if(t)return{backgroundColor:t}}function nL(t){if(t)return{backgroundColor:t}}function rL(t){var n;const e=[];if((n=t.rules)!=null&&n.some(r=>r.type==="required")){const r=t.rules.find(o=>o.type==="required");e.push({validator:async(o,i)=>{if(!i||i.length===0)throw new Error((r==null?void 0:r.message)||"此项为必填")}})}return t.minItems!==void 0&&e.push({validator:async(r,o)=>{if(!o||o.length<t.minItems)throw new Error(`至少需要 ${t.minItems} 项`)}}),t.maxItems!==void 0&&e.push({validator:async(r,o)=>{if(o&&o.length>t.maxItems)throw new Error(`最多允许 ${t.maxItems} 项`)}}),e}const oL=go(vC,{isComplexField:!0,needsFormItemName:!1}),iL=/\{\{.*\}\}/;function kC(t){return typeof t=="string"&&iL.test(t)?"expression":"normal"}const xC=({field:t,disabled:e,readOnly:n,context:r})=>{const{renderVariableTag:o,renderVariableTooltip:i,validateVariable:s}=r,a=sL(t),l=t.keyPlaceholder||"Key",c=t.valuePlaceholder||"Value",u=t.variableInsert?32:0;return f.jsx(x.Form.List,{name:t.name,rules:a,children:(d,{add:h,remove:p},{errors:m})=>f.jsxs(x.Space,{direction:"vertical",style:{width:"100%"},children:[d.map(w=>f.jsx(SC,{field:t,listField:w,disabled:e,readOnly:n,canRemove:!(e||t.minItems!==void 0&&d.length<=t.minItems),keyPlaceholder:l,valuePlaceholder:c,valueModeSwitchOffset:u,onRemove:p,validateVariable:s,renderVariableTag:o,renderVariableTooltip:i},w.key)),f.jsx(x.Button,{type:"dashed",block:!0,icon:f.jsx(Z.PlusOutlined,{}),onClick:()=>h(),disabled:e||t.maxItems!==void 0&&d.length>=t.maxItems,children:"添加键值对"}),f.jsx(x.Form.ErrorList,{errors:m})]})})};xC.displayName="KeyValueFieldControl";const SC=({field:t,listField:e,disabled:n,readOnly:r,canRemove:o,keyPlaceholder:i,valuePlaceholder:s,valueModeSwitchOffset:a,onRemove:l,validateVariable:c,renderVariableTag:u,renderVariableTooltip:d})=>{const h=x.Form.useFormInstance(),[p,m]=b.useState(()=>{const w=h.getFieldValue([t.name,e.name]),v=kC(w==null?void 0:w.key);return v==="expression"?v:kC(w==null?void 0:w.value)});return f.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[f.jsx(x.Form.Item,{style:{flex:1,marginBottom:0,marginTop:a},name:[e.name,"key"],rules:[{required:!0,message:"请输入Key"}],children:t.variableInsert?f.jsx(la,{availableModes:["normal","expression"],mode:p,hideModeSwitch:!0,disabled:n,readOnly:r,placeholder:i,validateVariable:c,renderVariableTag:u,renderVariableTooltip:d}):f.jsx(x.Input,{placeholder:i,disabled:n,readOnly:r})}),f.jsx(x.Form.Item,{style:{flex:1,marginBottom:0},name:[e.name,"value"],children:t.variableInsert?f.jsx(la,{availableModes:["normal","expression"],mode:p,onModeChange:m,disabled:n,readOnly:r,placeholder:s,validateVariable:c,renderVariableTag:u,renderVariableTooltip:d,modeSwitchPosition:"top-right",compact:!0}):f.jsx(x.Input,{placeholder:s,disabled:n,readOnly:r})}),f.jsx(x.Button,{type:"text",danger:!0,icon:f.jsx(Z.DeleteOutlined,{}),style:{marginTop:a},onClick:()=>l(e.name),disabled:!o})]})};SC.displayName="KeyValueRow";function sL(t){var n;const e=[];if((n=t.rules)!=null&&n.some(r=>r.type==="required")){const r=t.rules.find(o=>o.type==="required");e.push({validator:async(o,i)=>{if(!i||i.length===0)throw new Error((r==null?void 0:r.message)||"此项为必填")}})}if(t.minItems!==void 0){const r=t.minItems;e.push({validator:async(o,i)=>{if(!i||i.length<r)throw new Error(`至少需要 ${r} 项`)}})}if(t.maxItems!==void 0){const r=t.maxItems;e.push({validator:async(o,i)=>{if(i&&i.length>r)throw new Error(`最多允许 ${r} 项`)}})}return e}const aL=go(xC,{isComplexField:!0,supportsVariableInsert:!0,needsFormItemName:!1});function lL(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.name=="string"&&e.name.trim()!==""&&typeof e.type=="string"}function cL(t){return!t||typeof t!="object"||Array.isArray(t)?[]:Object.values(t).filter(lL)}const EC=({field:t,disabled:e,context:n})=>{const r=x.Form.useFormInstance(),i=uL(t.name),[s,a]=mt.useState(null);mt.useEffect(()=>{Promise.resolve().then(()=>IL).then(v=>{a(()=>v.FieldRenderer)})},[]);const{renderVariableTag:l,renderVariableTooltip:c,validateVariable:u,values:d,optionsLoader:h}=n,p=mt.useMemo(()=>cL(t.properties),[t.properties]),m=r.getFieldValue(i)??qn(d,i.join("."))??{},w=f.jsx(x.Space,{direction:"vertical",style:{width:"100%"},children:p.map(v=>{const y=[...i,v.name];return Ys(v,m)&&s?f.jsx(s,{field:{...v,name:y},values:d,optionsLoader:h,disabled:e,renderVariableTag:l,renderVariableTooltip:c,validateVariable:u},y.join(".")):null})});return t.collapsible?f.jsx(x.Collapse,{defaultActiveKey:t.defaultCollapsed?[]:["main"],items:[{key:"main",label:t.label||t.name,children:w}]}):f.jsx(x.Card,{size:"small",title:t.label,children:w})};EC.displayName="ObjectFieldControl";function uL(t){return Array.isArray(t)?t:[t]}const dL=go(EC,{isComplexField:!0,needsFormItemName:!1}),DC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.DatePicker,{disabled:e,placeholder:t.placeholder,picker:t.picker,format:t.format,style:{width:"100%"},value:n,onChange:r,id:o});DC.displayName="DateFieldControl";const fL=pt(DC,{needsFormItemName:!0}),AC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.DatePicker.RangePicker,{disabled:e,picker:t.picker,showTime:t.showTime,format:t.format,style:{width:"100%"},value:n,onChange:i=>r==null?void 0:r(i),id:o});AC.displayName="DateRangeFieldControl";const hL=pt(AC,{needsFormItemName:!0}),OC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.DatePicker,{disabled:e,placeholder:t.placeholder,showTime:t.showTime??!0,format:t.format||"YYYY-MM-DD HH:mm:ss",style:{width:"100%"},value:n,onChange:r,id:o});OC.displayName="DateTimeFieldControl";const pL=pt(OC,{needsFormItemName:!0}),TC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.TimePicker,{disabled:e,placeholder:t.placeholder,format:t.format,style:{width:"100%"},value:n,onChange:i=>r==null?void 0:r(i),id:o});TC.displayName="TimeFieldControl";const mL=pt(TC,{needsFormItemName:!0}),_C=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.TimePicker.RangePicker,{disabled:e,format:t.format,style:{width:"100%"},value:n,onChange:i=>r==null?void 0:r(i),id:o});_C.displayName="TimeRangeFieldControl";const gL=pt(_C,{needsFormItemName:!0}),NC=({field:t})=>f.jsx(x.Divider,{children:t.label});NC.displayName="DividerFieldControl";const wL=go(NC,{isDisplayOnly:!0,needsFormItemName:!1}),BC=({value:t,onChange:e,id:n})=>f.jsx(x.Input,{type:"hidden",value:t,onChange:r=>e==null?void 0:e(r.target.value),id:n});BC.displayName="HiddenFieldControl";const vL=go(BC,{needsFormItemName:!0,isHidden:!0}),FC=({field:t})=>f.jsx(x.Alert,{message:t.label,description:t.description||t.placeholder,type:t.status||"info",showIcon:t.showIcon,closable:t.closable});FC.displayName="InfoCardFieldControl";const yL=go(FC,{isDisplayOnly:!0,needsFormItemName:!1}),IC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Input.TextArea,{disabled:e,placeholder:t.placeholder,rows:6,value:n,onChange:i=>r==null?void 0:r(i.target.value),id:o});IC.displayName="JsonFieldControl";const bL=pt(IC,{needsFormItemName:!0}),MC=({field:t,value:e})=>f.jsx("span",{children:e||t.placeholder||t.defaultValue});MC.displayName="LabelFieldControl";const CL=pt(MC,{needsFormItemName:!0}),PC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Cascader,{disabled:e,placeholder:t.placeholder,options:t.options,changeOnSelect:t.changeOnSelect,multiple:t.multiple||void 0,showSearch:t.showSearch,value:n,onChange:(i,s)=>r==null?void 0:r(i),id:o});PC.displayName="CascaderFieldControl";const kL=pt(PC,{needsFormItemName:!0}),LC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Checkbox,{disabled:e,checked:n,onChange:i=>r==null?void 0:r(i.target.checked),id:o,children:t.placeholder});LC.displayName="CheckboxFieldControl";const xL=pt(LC,{needsFormItemName:!0,valuePropName:"checked"}),$C=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Checkbox.Group,{disabled:e,options:t.options,value:n,onChange:i=>r==null?void 0:r(i)});$C.displayName="CheckboxGroupFieldControl";const SL=pt($C,{needsFormItemName:!0}),HC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Radio.Group,{disabled:e,options:t.options,optionType:t.optionType,buttonStyle:t.buttonStyle,value:n,onChange:i=>r==null?void 0:r(i.target.value),id:o});HC.displayName="RadioFieldControl";const EL=pt(HC,{needsFormItemName:!0}),zC=({field:t,disabled:e,context:n,value:r,onChange:o,id:i})=>{const{values:s,optionsLoader:a}=n,[l,c]=b.useState(jC(t)),[u,d]=b.useState(!1),h=t.type===be.MULTI_SELECT||t.mode==="multiple",p=y=>!y||y.kind==="static"?[]:y.deps||[],m=b.useMemo(()=>{const g=p(t.optionsSource).map(k=>qn(s,k));return JSON.stringify(g)},[t.optionsSource,s]);b.useEffect(()=>{if(!t.optionsSource||t.optionsSource.kind==="static"){c(jC(t));return}const y=t.optionsSource;if(!a){c(y.fallbackOptions||t.options||[]);return}const k=p(y).reduce((E,D)=>(E[D]=qn(s,D),E),{}),A={...y.params||{},deps:k};d(!0);let C=!1;return a(y.action,A,{values:s}).then(E=>{C||c(E)}).catch(()=>{C||c(y.fallbackOptions||t.options||[])}).finally(()=>{C||d(!1)}),()=>{C=!0}},[m,t.optionsSource,t.options]);const w=()=>{var y;(y=n.eventHandlers)==null||y.onBlur(t.name)},v=()=>{var y;(y=n.eventHandlers)==null||y.onFocus(t.name)};return f.jsx(x.Select,{disabled:e,placeholder:t.placeholder,options:l,mode:h?"multiple":t.mode,showSearch:t.showSearch,allowClear:t.allowClear,maxTagCount:t.maxTagCount,loading:u,value:r,onChange:o,onBlur:w,onFocus:v,id:i})};zC.displayName="SelectFieldControl";function jC(t){var n;if((n=t.options)!=null&&n.length)return t.options;const e=t.optionsSource;return e?e.kind==="static"?e.items||[]:e.fallbackOptions||[]:[]}const VC=pt(zC,{supportsVariableInsert:!1,needsFormItemName:!0}),WC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Switch,{disabled:e,checkedChildren:t.checkedChildren,unCheckedChildren:t.unCheckedChildren,checked:n,onChange:r,id:o});WC.displayName="SwitchFieldControl";const DL=pt(WC,{needsFormItemName:!0,valuePropName:"checked"}),UC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.TreeSelect,{disabled:e,placeholder:t.placeholder,treeData:t.options,multiple:t.multiple,showSearch:t.showSearch,allowClear:t.allowClear,treeCheckable:t.treeCheckable,value:n,onChange:r,id:o});UC.displayName="TreeSelectFieldControl";const AL=pt(UC,{needsFormItemName:!0}),qC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.AutoComplete,{disabled:e,placeholder:t.placeholder,options:t.options,allowClear:t.allowClear,value:n,onChange:r,id:o});qC.displayName="AutoCompleteFieldControl";const OL=pt(qC,{needsFormItemName:!0}),GC=({disabled:t,value:e,onChange:n})=>f.jsx(x.ColorPicker,{disabled:t,value:e,onChange:(r,o)=>n==null?void 0:n(o)});GC.displayName="ColorPickerFieldControl";const TL=pt(GC,{needsFormItemName:!0}),KC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Mentions,{disabled:e,placeholder:t.placeholder,value:n,onChange:r,id:o});KC.displayName="MentionsFieldControl";const _L=pt(KC,{needsFormItemName:!0}),YC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Rate,{disabled:e,count:t.count,allowHalf:t.allowHalf,value:n,onChange:r,id:o});YC.displayName="RateFieldControl";const NL=pt(YC,{needsFormItemName:!0}),XC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Slider,{disabled:e,min:t.min,max:t.max,step:t.step,marks:t.marks,range:t.range,value:n,onChange:i=>r==null?void 0:r(i),id:o});XC.displayName="SliderFieldControl";const BL=pt(XC,{needsFormItemName:!0}),JC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Upload,{disabled:e,accept:t.accept,maxCount:t.maxCount,listType:t.listType||"text",action:t.action,multiple:t.multiple,fileList:n,onChange:r,id:o,children:f.jsx(x.Button,{icon:f.jsx(Z.UploadOutlined,{}),disabled:e,children:"上传文件"})});JC.displayName="UploadFieldControl";const FL=pt(JC,{needsFormItemName:!0});function RC(t=Rl){t.register(be.TEXT,V2),t.register(be.TEXTAREA,j2),t.register(be.NUMBER,H2),t.register(be.PASSWORD,z2),t.register(be.SELECT,VC),t.register(be.MULTI_SELECT,VC),t.register(be.RADIO,EL),t.register(be.CHECKBOX,xL),t.register(be.CHECKBOX_GROUP,SL),t.register(be.SWITCH,DL),t.register(be.CASCADER,kL),t.register(be.TREE_SELECT,AL),t.register(be.DATE,fL),t.register(be.DATETIME,pL),t.register(be.DATE_RANGE,hL),t.register(be.TIME,mL),t.register(be.TIME_RANGE,gL),t.register(be.UPLOAD,FL),t.register(be.RATE,NL),t.register(be.SLIDER,BL),t.register(be.COLOR_PICKER,TL),t.register(be.MENTIONS,_L),t.register(be.AUTO_COMPLETE,OL),t.register(be.LABEL,CL),t.register(be.HIDDEN,vL),t.register(be.JSON,bL),t.register(be.DIVIDER,wL),t.register(be.INFO_CARD,yL),t.register(be.ARRAY,U2),t.register(be.OBJECT,dL),t.register(be.KEY_VALUE,aL),t.register(be.ARRAY_OBJECT,oL)}RC();const yh=({field:t,disabled:e,required:n,readOnly:r,rules:o,values:i,optionsLoader:s,validateVariable:a,renderVariableTag:l,renderVariableTooltip:c,eventHandlers:u})=>{const d=Ql(),h=e??Pi(t.disabled,i,!1),p=n??Pi(t.required,i,!1),m=r??Pi(t.readOnly,i,!1),w=o??Mi(t.rules||[],i,t.type),v={values:i,optionsLoader:s,validateVariable:a,renderVariableTag:l,renderVariableTooltip:c,eventHandlers:u},y=d.get(t.type);if(!y)return f.jsxs("span",{children:["不支持的字段类型: ",t.type]});const{component:g,meta:k}=y;return k.isDisplayOnly?f.jsx(g,{field:t,disabled:h,readOnly:m,context:v}):k.isComplexField?f.jsx(x.Form.Item,{label:t.label,tooltip:t.tooltip,extra:t.helpText||t.extra||t.description,required:p,labelCol:t.labelCol,wrapperCol:t.wrapperCol,colon:t.colon,children:f.jsx(g,{field:t,disabled:h,readOnly:m,context:v})}):k.isHidden?f.jsx(x.Form.Item,{name:k.needsFormItemName!==!1?t.name:void 0,hidden:!0,rules:w,valuePropName:k.valuePropName,validateTrigger:t.validateTrigger,children:f.jsx(g,{field:t,disabled:h,readOnly:m,context:v})}):f.jsx(x.Form.Item,{name:k.needsFormItemName!==!1?t.name:void 0,label:t.label,tooltip:t.tooltip,extra:t.helpText||t.extra||t.description,required:p,rules:w,labelCol:t.labelCol,wrapperCol:t.wrapperCol,colon:t.colon,valuePropName:k.valuePropName,validateTrigger:t.validateTrigger,children:f.jsx(g,{field:t,disabled:h,readOnly:m,context:v})})},IL=Object.freeze(Object.defineProperty({__proto__:null,FieldRenderer:yh},Symbol.toStringTag,{value:"Module"})),ML={meta:{name:"antd-5x-apple-pixel-aligned-full",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#007AFF",colorInfo:"#007AFF",colorSuccess:"#34C759",colorWarning:"#FF9F0A",colorError:"#FF3B30",colorTextBase:"#0B0B0F",colorBgBase:"#FFFFFF",colorBorder:"#D1D1D6",colorBorderSecondary:"#E5E5EA",colorPrimaryBorder:"#007AFF",colorPrimaryBorderHover:"#007AFF",colorPrimaryHover:"#0066D6",colorPrimaryActive:"#0056B3",controlOutlineWidth:2,controlOutline:"rgba(0, 122, 255, 0.25)",fontFamily:'"SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.6,borderRadius:10,borderRadiusSM:8,borderRadiusLG:12,lineWidth:1,lineType:"solid",controlHeight:44,controlHeightSM:36,controlHeightLG:52,sizeUnit:4,sizeStep:4,padding:16,paddingXS:10,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:10,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 10px 24px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08)",boxShadowSecondary:"0 6px 16px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06)",boxShadowTertiary:"0 2px 8px rgba(0,0,0,0.08)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:12},Anchor:{linkPaddingInlineStart:16},AutoComplete:{controlHeight:44,controlHeightSM:36,controlHeightLG:52},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:999,borderRadiusSM:999,borderRadiusLG:999,controlHeight:44,controlHeightSM:36,controlHeightLG:52,paddingInline:18,paddingInlineLG:20,paddingInlineSM:14,contentFontSize:14,contentFontSizeLG:16,contentFontSizeSM:14,primaryShadow:"0 2px 0 rgba(0,122,255,0.14)",dangerShadow:"0 2px 0 rgba(255,59,48,0.12)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24,borderRadiusLG:14},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:6},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:52,activeBorderColor:"#007AFF",activeShadow:"0 0 0 2px rgba(0, 122, 255, 0.25)"},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:44,controlHeightLG:52,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:44,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:44,controlHeightSM:36,controlHeightLG:52,paddingInline:14,paddingInlineSM:12,paddingInlineLG:14,paddingBlock:10,paddingBlockSM:8,paddingBlockLG:12,borderRadius:10,hoverBorderColor:"#C7C7CC",activeBorderColor:"#007AFF",activeShadow:"0 0 0 2px rgba(0, 122, 255, 0.25)"},InputNumber:{controlHeight:44,controlHeightSM:36,controlHeightLG:52},Layout:{headerBg:"#FFFFFF",headerHeight:64,headerPadding:"0 50px",bodyBg:"#F2F2F7",siderBg:"#FFFFFF",triggerBg:"#F2F2F7"},List:{itemPadding:"12px 0"},Mentions:{controlHeight:44,controlHeightSM:36,controlHeightLG:52},Menu:{itemHeight:44,iconSize:16,collapsedIconSize:18,horizontalItemBorderRadius:10,itemBorderRadius:10},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16,borderRadiusLG:14},Notification:{},Pagination:{itemSize:44,itemSizeSM:36},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{buttonSolidCheckedBg:"#007AFF"},Rate:{},Result:{},Segmented:{controlHeight:36},Select:{controlHeight:44,controlHeightSM:36,controlHeightLG:52,multipleItemHeight:28,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:24,trackMinWidth:44,handleSize:20},Table:{headerBg:"#F2F2F7",headerSortActiveBg:"#EDEDF2",headerSortHoverBg:"#F2F2F7",rowHoverBg:"#F2F2F7",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:4,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 16px"},Tag:{borderRadiusSM:8},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:52,activeBorderColor:"#007AFF",activeShadow:"0 0 0 2px rgba(0, 122, 255, 0.25)"},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:36,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}},PL={meta:{name:"antd-5x-google-material3-aligned-full",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#1A73E8",colorInfo:"#1A73E8",colorSuccess:"#34A853",colorWarning:"#FBBC04",colorError:"#EA4335",colorTextBase:"#202124",colorBgBase:"#FFFFFF",colorBorder:"#DADCE0",colorBorderSecondary:"#E0E3E7",colorPrimaryBorder:"#1A73E8",colorPrimaryBorderHover:"#1A73E8",colorPrimaryHover:"#1967D2",colorPrimaryActive:"#174EA6",controlOutlineWidth:2,controlOutline:"rgba(26, 115, 232, 0.24)",fontFamily:'"Google Sans", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.5714285714285714,borderRadius:8,borderRadiusSM:4,borderRadiusLG:12,lineWidth:1,lineType:"solid",controlHeight:56,controlHeightSM:40,controlHeightLG:64,sizeUnit:4,sizeStep:4,padding:16,paddingXS:8,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:8,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 1px 2px rgba(60,64,67,0.16), 0 2px 6px rgba(60,64,67,0.12)",boxShadowSecondary:"0 2px 8px rgba(60,64,67,0.14)",boxShadowTertiary:"0 1px 3px rgba(60,64,67,0.12)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:12},Anchor:{linkPaddingInlineStart:16},AutoComplete:{controlHeight:56,controlHeightSM:40,controlHeightLG:64},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:999,borderRadiusSM:999,borderRadiusLG:999,controlHeight:40,controlHeightSM:32,controlHeightLG:48,paddingInline:24,paddingInlineLG:24,paddingInlineSM:16,contentFontSize:14,contentFontSizeLG:14,contentFontSizeSM:14,primaryShadow:"0 1px 0 rgba(26,115,232,0.20)",dangerShadow:"0 1px 0 rgba(234,67,53,0.18)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24,borderRadiusLG:12},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:4},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:56,controlHeightSM:40,controlHeightLG:64,activeBorderColor:"#1A73E8",activeShadow:"0 0 0 2px rgba(26, 115, 232, 0.24)"},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:40,controlHeightLG:48,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:40,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:56,controlHeightSM:40,controlHeightLG:64,paddingInline:16,paddingInlineSM:12,paddingInlineLG:16,paddingBlock:14,paddingBlockSM:8,paddingBlockLG:16,borderRadius:4,hoverBorderColor:"#BDC1C6",activeBorderColor:"#1A73E8",activeShadow:"0 0 0 2px rgba(26, 115, 232, 0.24)"},InputNumber:{controlHeight:56,controlHeightSM:40,controlHeightLG:64},Layout:{headerBg:"#202124",headerHeight:64,headerPadding:"0 50px",bodyBg:"#F8F9FA",siderBg:"#202124",triggerBg:"#303134"},List:{itemPadding:"12px 0"},Mentions:{controlHeight:56,controlHeightSM:40,controlHeightLG:64},Menu:{itemHeight:40,iconSize:14,collapsedIconSize:16,horizontalItemBorderRadius:12,itemBorderRadius:12},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16,borderRadiusLG:16},Notification:{},Pagination:{itemSize:40,itemSizeSM:32},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{buttonSolidCheckedBg:"#1A73E8"},Rate:{},Result:{},Segmented:{controlHeight:40},Select:{controlHeight:56,controlHeightSM:40,controlHeightLG:64,multipleItemHeight:28,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:24,trackMinWidth:44,handleSize:20},Table:{headerBg:"#F8F9FA",headerSortActiveBg:"#F1F3F4",headerSortHoverBg:"#F3F5F6",rowHoverBg:"#F8F9FA",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:4,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 18px"},Tag:{borderRadiusSM:8},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:56,controlHeightSM:40,controlHeightLG:64,activeBorderColor:"#1A73E8",activeShadow:"0 0 0 2px rgba(26, 115, 232, 0.24)"},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:32,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}},LL={meta:{name:"antd-5x-preline-pixel-aligned-full",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#2563EB",colorInfo:"#2563EB",colorSuccess:"#16A34A",colorWarning:"#F59E0B",colorError:"#EF4444",colorTextBase:"#0F172A",colorBgBase:"#FFFFFF",colorBorder:"#E5E7EB",colorBorderSecondary:"#E5E7EB",colorPrimaryBorder:"#3B82F6",colorPrimaryBorderHover:"#3B82F6",colorPrimaryHover:"#1D4ED8",colorPrimaryActive:"#1E40AF",controlOutlineWidth:1,controlOutline:"rgba(59, 130, 246, 0.45)",fontFamily:'Graphik, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.6,borderRadius:8,borderRadiusSM:6,borderRadiusLG:12,lineWidth:1,lineType:"solid",controlHeight:44,controlHeightSM:36,controlHeightLG:48,sizeUnit:4,sizeStep:4,padding:16,paddingXS:8,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:8,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 1px 2px rgba(15,23,42,0.06), 0 6px 18px rgba(15,23,42,0.08)",boxShadowSecondary:"0 1px 2px rgba(15,23,42,0.05), 0 10px 24px rgba(15,23,42,0.10)",boxShadowTertiary:"0 1px 2px rgba(15,23,42,0.06)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:12},Anchor:{linkPaddingInlineStart:16},AutoComplete:{controlHeight:44,controlHeightSM:36,controlHeightLG:48},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:8,borderRadiusSM:8,borderRadiusLG:10,controlHeight:44,controlHeightSM:36,controlHeightLG:48,paddingInline:16,paddingInlineLG:18,paddingInlineSM:12,contentFontSize:14,contentFontSizeLG:14,contentFontSizeSM:14,primaryShadow:"0 1px 0 rgba(37,99,235,0.18)",dangerShadow:"0 1px 0 rgba(239,68,68,0.16)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24,borderRadiusLG:12},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:6},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:48,activeBorderColor:"#3B82F6",activeShadow:"0 0 0 1px rgba(59, 130, 246, 0.45)"},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:40,controlHeightLG:48,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:36,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:44,controlHeightSM:36,controlHeightLG:48,paddingInline:16,paddingInlineSM:12,paddingInlineLG:16,paddingBlock:10,paddingBlockSM:8,paddingBlockLG:10,borderRadius:8,hoverBorderColor:"#D1D5DB",activeBorderColor:"#3B82F6",activeShadow:"0 0 0 1px rgba(59, 130, 246, 0.45)"},InputNumber:{controlHeight:44,controlHeightSM:36,controlHeightLG:48},Layout:{headerBg:"#0B1220",headerHeight:64,headerPadding:"0 50px",bodyBg:"#F8FAFC",siderBg:"#0B1220",triggerBg:"#0F1A2E"},List:{itemPadding:"12px 0"},Mentions:{controlHeight:44,controlHeightSM:36,controlHeightLG:48},Menu:{itemHeight:40,iconSize:14,collapsedIconSize:16,horizontalItemBorderRadius:8,itemBorderRadius:8},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16,borderRadiusLG:12},Notification:{},Pagination:{itemSize:36,itemSizeSM:32},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{},Rate:{},Result:{},Segmented:{controlHeight:36},Select:{controlHeight:44,controlHeightSM:36,controlHeightLG:48,multipleItemHeight:28,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:22,trackMinWidth:44,handleSize:18},Table:{headerBg:"#F8FAFC",headerSortActiveBg:"#F1F5F9",headerSortHoverBg:"#F3F6FB",rowHoverBg:"#F8FAFC",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:6,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 16px"},Tag:{borderRadiusSM:6},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:48,activeBorderColor:"#3B82F6",activeShadow:"0 0 0 1px rgba(59, 130, 246, 0.45)"},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:32,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}};function $L(t){return"optionsSource"in t&&t.optionsSource&&t.optionsSource.kind!=="static"?t.optionsSource.deps||[]:[]}function HL(t){const e=[];for(const n of t.fields){const r=$L(n);if(r.length>0)for(const o of r)e.push({id:`auto-clear-${n.name}-on-${o}-change`,trigger:{type:"fieldChange",field:o},actions:[{type:"clearFields",targets:[n.name]}]})}return e}function zL(t,e,n=!0){return[...n?HL(t):[],...e||[]]}const jL={default:Sf,apple:ML,google:PL,preline:LL};function Gi({schema:t,initialValues:e,onSubmit:n,onChange:r,submitLabel:o="提交",showReset:i=!1,resetLabel:s="重置",onReset:a,form:l,showSubmit:c=!0,optionsLoader:u,nodeId:d,mcpMode:h,validateVariable:p,renderVariableTag:m,renderVariableTooltip:w,availableVariables:v,theme:y,customTheme:g,locale:k,prefixCls:A,events:C,customHandlers:E,maxExecutionDepth:D,debugEvents:S}){var se;const[_]=x.Form.useForm(),O=l||_,B=mt.useMemo(()=>{const Q={};for(const le of t.fields)le.defaultValue!==void 0&&(Q[le.name]=le.defaultValue);return{...Q,...e||{}}},[t.fields,e]),N=mt.useMemo(()=>{const Q=t.enableAutoEvents!==!1,le=t.events||[],L=C||[];return zL(t,[...le,...L],Q)},[t,C]),F=CB({events:N,form:O,optionsLoader:u,customHandlers:E,maxExecutionDepth:D,debug:S}),M=mt.useRef({}),T=mt.useMemo(()=>{if(g)return g;if(y)return jL[y]},[g,y]),P=x.Form.useWatch([],O),$=mt.useMemo(()=>JSON.stringify({...B||{},...P||{}}),[B,P]),W=mt.useMemo(()=>({...B||{},...P||{}}),[$]),[V,X]=mt.useState({}),G=mt.useRef({});mt.useEffect(()=>{var le;const Q={};for(const L of t.fields){const q=Ys(L,W);if(Q[L.name]=q,G.current[L.name]===!0&&q===!1){const K=OB(L),re=((le=L.visibleWhen)==null?void 0:le.clearOnHide)??!0;K==="unregister"&&O.setFieldValue(L.name,re?void 0:O.getFieldValue(L.name))}}G.current=Q,X(Q)},[t.fields,O,W]);const te=async Q=>{const le=t.pruneInvisibleOnSubmit===!1?Q:_B(t,Q,V);await(n==null?void 0:n(le))},H=(Q,le)=>{if(r==null||r(Q,le),F.triggerFieldChange&&Q){const L=M.current;for(const q in Q){const J=qn(L,q),K=Q[q];F.triggerFieldChange(q,K,J)}}M.current={...le}},j=c||i,Y=mt.useMemo(()=>({nodeId:d,mcpMode:h,validateVariable:p,renderVariableTag:m,renderVariableTooltip:w,availableVariables:v}),[d,h,p,m,w,v]);return f.jsx(F0,{customTheme:T,locale:k,prefixCls:A,children:f.jsx(L0,{value:Y,children:f.jsxs(x.Form,{form:O,layout:t.layout||"vertical",labelCol:t.labelCol,wrapperCol:t.wrapperCol,colon:t.colon,size:t.size,initialValues:B,onFinish:te,onValuesChange:H,children:[t.fields.map(Q=>{if(!Ys(Q,W))return null;const L=Pi(Q.disabled,W,!1),q=Pi(Q.required,W,!1),J=Mi(Q.rules||[],W,Q.type),K=q&&!J.some(re=>"required"in re&&re.required)?[{required:!0,message:`${Q.label||Q.name}为必填项`},...J]:J;return f.jsx(yh,{field:Q,disabled:L,required:q,rules:K,values:W,optionsLoader:u,validateVariable:p,renderVariableTag:m,renderVariableTooltip:w,eventHandlers:F.fieldEventHandlers},Q.name)}),j&&f.jsx(x.Form.Item,{wrapperCol:{offset:((se=t.labelCol)==null?void 0:se.span)||0},children:f.jsxs(x.Space,{children:[i&&f.jsx(x.Button,{onClick:()=>{O.resetFields(),a==null||a()},children:s}),c&&f.jsx(x.Button,{type:"primary",htmlType:"submit",children:o})]})})]})})})}const QC=({formSchema:t,initialValues:e,onCancel:n,onSubmit:r})=>{const[o]=x.Form.useForm();b.useEffect(()=>{o.setFieldsValue(e??{})},[o,e]);const i=async s=>{const a=await o.validateFields();r(a,s)};return f.jsxs("div",{children:[f.jsx(Gi,{schema:t,form:o,initialValues:e,showSubmit:!1,showReset:!1}),f.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:16},children:f.jsxs(x.Space,{children:[f.jsx(x.Button,{onClick:n,children:"取消"}),f.jsx(x.Button,{onClick:()=>i(!0),children:"测试连接"}),f.jsx(x.Button,{type:"primary",onClick:()=>i(!1),children:"保存"})]})})]})},ZC=t=>Array.isArray(t)?t.map(e=>{if(typeof e=="string"){const s=e.trim();return s?{label:s,value:s}:null}const n=(e==null?void 0:e.value)??(e==null?void 0:e.label)??"",r=n==null?"":String(n).trim();if(!r)return null;const o=(e==null?void 0:e.label)??"";return{label:o==null?r:String(o).trim()||r,value:r}}).filter(Boolean):[],e1=b.forwardRef((t,e)=>{const[n,r]=b.useState([]),[o,i]=b.useState("");b.useEffect(()=>{i(t.proxyId)},[t.proxyId]),b.useEffect(()=>{Tv().then(l=>{r(l??[])})},[]);const s=()=>o;b.useImperativeHandle(e,()=>({getProxyId:s}));const a=l=>{i(l)};return f.jsxs("div",{children:[f.jsx("h3",{children:f.jsx(Ee.FormattedMessage,{id:"link.flow.use_proxy_gateway"})}),f.jsxs(x.Select,{className:"proxy_id_select",value:o,dropdownStyle:{zIndex:99999999999},onChange:a,style:{width:"100%"},children:[f.jsx(x.Select.Option,{value:"0",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.do_not_use"})}),n.map(l=>f.jsx(x.Select.Option,{value:l.id,children:l.group_name},l.id))]}),f.jsxs("p",{style:{color:"#ccc",marginTop:20},children:[f.jsx(Ee.FormattedMessage,{id:"link.flow.private_network_deployment"}),f.jsx("a",{style:{margin:"0 2px"},href:"/uc/setting/gateway",target:"_blank",rel:"noopener",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.proxy_gateway"})}),f.jsx(Ee.FormattedMessage,{id:"link.flow.secure_connection"})]})]})});var kc={exports:{}},VL=kc.exports,t1;function WL(){return t1||(t1=1,(function(t,e){(function(n,r){t.exports=r()})(VL,(function(){var n=1e3,r=6e4,o=36e5,i="millisecond",s="second",a="minute",l="hour",c="day",u="week",d="month",h="quarter",p="year",m="date",w="Invalid Date",v=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(M){var T=["th","st","nd","rd"],P=M%100;return"["+M+(T[(P-20)%10]||T[P]||T[0])+"]"}},k=function(M,T,P){var $=String(M);return!$||$.length>=T?M:""+Array(T+1-$.length).join(P)+M},A={s:k,z:function(M){var T=-M.utcOffset(),P=Math.abs(T),$=Math.floor(P/60),W=P%60;return(T<=0?"+":"-")+k($,2,"0")+":"+k(W,2,"0")},m:function M(T,P){if(T.date()<P.date())return-M(P,T);var $=12*(P.year()-T.year())+(P.month()-T.month()),W=T.clone().add($,d),V=P-W<0,X=T.clone().add($+(V?-1:1),d);return+(-($+(P-W)/(V?W-X:X-W))||0)},a:function(M){return M<0?Math.ceil(M)||0:Math.floor(M)},p:function(M){return{M:d,y:p,w:u,d:c,D:m,h:l,m:a,s,ms:i,Q:h}[M]||String(M||"").toLowerCase().replace(/s$/,"")},u:function(M){return M===void 0}},C="en",E={};E[C]=g;var D="$isDayjsObject",S=function(M){return M instanceof N||!(!M||!M[D])},_=function M(T,P,$){var W;if(!T)return C;if(typeof T=="string"){var V=T.toLowerCase();E[V]&&(W=V),P&&(E[V]=P,W=V);var X=T.split("-");if(!W&&X.length>1)return M(X[0])}else{var G=T.name;E[G]=T,W=G}return!$&&W&&(C=W),W||!$&&C},O=function(M,T){if(S(M))return M.clone();var P=typeof T=="object"?T:{};return P.date=M,P.args=arguments,new N(P)},B=A;B.l=_,B.i=S,B.w=function(M,T){return O(M,{locale:T.$L,utc:T.$u,x:T.$x,$offset:T.$offset})};var N=(function(){function M(P){this.$L=_(P.locale,null,!0),this.parse(P),this.$x=this.$x||P.x||{},this[D]=!0}var T=M.prototype;return T.parse=function(P){this.$d=(function($){var W=$.date,V=$.utc;if(W===null)return new Date(NaN);if(B.u(W))return new Date;if(W instanceof Date)return new Date(W);if(typeof W=="string"&&!/Z$/i.test(W)){var X=W.match(v);if(X){var G=X[2]-1||0,te=(X[7]||"0").substring(0,3);return V?new Date(Date.UTC(X[1],G,X[3]||1,X[4]||0,X[5]||0,X[6]||0,te)):new Date(X[1],G,X[3]||1,X[4]||0,X[5]||0,X[6]||0,te)}}return new Date(W)})(P),this.init()},T.init=function(){var P=this.$d;this.$y=P.getFullYear(),this.$M=P.getMonth(),this.$D=P.getDate(),this.$W=P.getDay(),this.$H=P.getHours(),this.$m=P.getMinutes(),this.$s=P.getSeconds(),this.$ms=P.getMilliseconds()},T.$utils=function(){return B},T.isValid=function(){return this.$d.toString()!==w},T.isSame=function(P,$){var W=O(P);return this.startOf($)<=W&&W<=this.endOf($)},T.isAfter=function(P,$){return O(P)<this.startOf($)},T.isBefore=function(P,$){return this.endOf($)<O(P)},T.$g=function(P,$,W){return B.u(P)?this[$]:this.set(W,P)},T.unix=function(){return Math.floor(this.valueOf()/1e3)},T.valueOf=function(){return this.$d.getTime()},T.startOf=function(P,$){var W=this,V=!!B.u($)||$,X=B.p(P),G=function(L,q){var J=B.w(W.$u?Date.UTC(W.$y,q,L):new Date(W.$y,q,L),W);return V?J:J.endOf(c)},te=function(L,q){return B.w(W.toDate()[L].apply(W.toDate("s"),(V?[0,0,0,0]:[23,59,59,999]).slice(q)),W)},H=this.$W,j=this.$M,Y=this.$D,se="set"+(this.$u?"UTC":"");switch(X){case p:return V?G(1,0):G(31,11);case d:return V?G(1,j):G(0,j+1);case u:var Q=this.$locale().weekStart||0,le=(H<Q?H+7:H)-Q;return G(V?Y-le:Y+(6-le),j);case c:case m:return te(se+"Hours",0);case l:return te(se+"Minutes",1);case a:return te(se+"Seconds",2);case s:return te(se+"Milliseconds",3);default:return this.clone()}},T.endOf=function(P){return this.startOf(P,!1)},T.$set=function(P,$){var W,V=B.p(P),X="set"+(this.$u?"UTC":""),G=(W={},W[c]=X+"Date",W[m]=X+"Date",W[d]=X+"Month",W[p]=X+"FullYear",W[l]=X+"Hours",W[a]=X+"Minutes",W[s]=X+"Seconds",W[i]=X+"Milliseconds",W)[V],te=V===c?this.$D+($-this.$W):$;if(V===d||V===p){var H=this.clone().set(m,1);H.$d[G](te),H.init(),this.$d=H.set(m,Math.min(this.$D,H.daysInMonth())).$d}else G&&this.$d[G](te);return this.init(),this},T.set=function(P,$){return this.clone().$set(P,$)},T.get=function(P){return this[B.p(P)]()},T.add=function(P,$){var W,V=this;P=Number(P);var X=B.p($),G=function(j){var Y=O(V);return B.w(Y.date(Y.date()+Math.round(j*P)),V)};if(X===d)return this.set(d,this.$M+P);if(X===p)return this.set(p,this.$y+P);if(X===c)return G(1);if(X===u)return G(7);var te=(W={},W[a]=r,W[l]=o,W[s]=n,W)[X]||1,H=this.$d.getTime()+P*te;return B.w(H,this)},T.subtract=function(P,$){return this.add(-1*P,$)},T.format=function(P){var $=this,W=this.$locale();if(!this.isValid())return W.invalidDate||w;var V=P||"YYYY-MM-DDTHH:mm:ssZ",X=B.z(this),G=this.$H,te=this.$m,H=this.$M,j=W.weekdays,Y=W.months,se=W.meridiem,Q=function(q,J,K,re){return q&&(q[J]||q($,V))||K[J].slice(0,re)},le=function(q){return B.s(G%12||12,q,"0")},L=se||function(q,J,K){var re=q<12?"AM":"PM";return K?re.toLowerCase():re};return V.replace(y,(function(q,J){return J||(function(K){switch(K){case"YY":return String($.$y).slice(-2);case"YYYY":return B.s($.$y,4,"0");case"M":return H+1;case"MM":return B.s(H+1,2,"0");case"MMM":return Q(W.monthsShort,H,Y,3);case"MMMM":return Q(Y,H);case"D":return $.$D;case"DD":return B.s($.$D,2,"0");case"d":return String($.$W);case"dd":return Q(W.weekdaysMin,$.$W,j,2);case"ddd":return Q(W.weekdaysShort,$.$W,j,3);case"dddd":return j[$.$W];case"H":return String(G);case"HH":return B.s(G,2,"0");case"h":return le(1);case"hh":return le(2);case"a":return L(G,te,!0);case"A":return L(G,te,!1);case"m":return String(te);case"mm":return B.s(te,2,"0");case"s":return String($.$s);case"ss":return B.s($.$s,2,"0");case"SSS":return B.s($.$ms,3,"0");case"Z":return X}return null})(q)||X.replace(":","")}))},T.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},T.diff=function(P,$,W){var V,X=this,G=B.p($),te=O(P),H=(te.utcOffset()-this.utcOffset())*r,j=this-te,Y=function(){return B.m(X,te)};switch(G){case p:V=Y()/12;break;case d:V=Y();break;case h:V=Y()/3;break;case u:V=(j-H)/6048e5;break;case c:V=(j-H)/864e5;break;case l:V=j/o;break;case a:V=j/r;break;case s:V=j/n;break;default:V=j}return W?V:B.a(V)},T.daysInMonth=function(){return this.endOf(d).$D},T.$locale=function(){return E[this.$L]},T.locale=function(P,$){if(!P)return this.$L;var W=this.clone(),V=_(P,$,!0);return V&&(W.$L=V),W},T.clone=function(){return B.w(this.$d,this)},T.toDate=function(){return new Date(this.valueOf())},T.toJSON=function(){return this.isValid()?this.toISOString():null},T.toISOString=function(){return this.$d.toISOString()},T.toString=function(){return this.$d.toUTCString()},M})(),F=N.prototype;return O.prototype=F,[["$ms",i],["$s",s],["$m",a],["$H",l],["$W",c],["$M",d],["$y",p],["$D",m]].forEach((function(M){F[M[1]]=function(T){return this.$g(T,M[0],M[1])}})),O.extend=function(M,T){return M.$i||(M(T,N,O),M.$i=!0),O},O.locale=_,O.isDayjs=S,O.unix=function(M){return O(1e3*M)},O.en=E[C],O.Ls=E,O.p={},O}))})(kc)),kc.exports}var UL=WL();const cr=Ii(UL),qL=t=>f.jsx(x.DatePicker,{style:{width:"100%"},picker:"date",value:cr(t.value?t.value:new Date),onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD")))}}),GL=t=>f.jsx(x.DatePicker,{style:{width:"100%"},picker:"date",showTime:!0,value:cr(t.value?t.value:new Date),onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD hh:mm:ss")))}}),KL=({value:t=[],onChange:e,valueType:n})=>{const r=a=>{const l=[...t];l.splice(a,1),e==null||e(l)},o=()=>{e==null||e([...t,{key:"",value:""}])},i=(a,l)=>{e==null||e(t.map((c,u)=>u===a?{...c,key:l}:c))},s=(a,l)=>{e==null||e(t.map((c,u)=>u===a?{...c,value:l}:c))};return f.jsxs("div",{children:[t.map((a,l)=>f.jsxs(x.Space,{size:"small",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[f.jsx(x.Input,{value:a.key,onChange:c=>i(l,c.target.value),placeholder:"Key"}),f.jsx(x.Input,{placeholder:"Value",style:{width:300},value:a.value,onChange:c=>s(l,c.target.value)}),f.jsx(Z.DeleteOutlined,{onClick:()=>{r(l)}})]},l)),f.jsxs(x.Button,{type:"dashed",onClick:o,block:!0,children:[f.jsx(Z.PlusOutlined,{})," ",f.jsx(Ee.FormattedMessage,{id:"app.common.word.add-field"})]})]})},YL=t=>null,n1=1024;let XL=0,bh=class{constructor(e,n){this.from=e,this.to=n}};class Ve{constructor(e={}){this.id=XL++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Sn.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}Ve.closedBy=new Ve({deserialize:t=>t.split(" ")}),Ve.openedBy=new Ve({deserialize:t=>t.split(" ")}),Ve.group=new Ve({deserialize:t=>t.split(" ")}),Ve.isolate=new Ve({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),Ve.contextHash=new Ve({perNode:!0}),Ve.lookAhead=new Ve({perNode:!0}),Ve.mounted=new Ve({perNode:!0});class ca{constructor(e,n,r,o=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=o}static get(e){return e&&e.props&&e.props[Ve.mounted.id]}}const JL=Object.create(null);class Sn{constructor(e,n,r,o=0){this.name=e,this.props=n,this.id=r,this.flags=o}static define(e){let n=e.props&&e.props.length?Object.create(null):JL,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),o=new Sn(e.name||"",n,e.id,r);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(o)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[i[0].id]=i[1]}}return o}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Ve.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let o of r.split(" "))n[o]=e[r];return r=>{for(let o=r.prop(Ve.group),i=-1;i<(o?o.length:0);i++){let s=n[i<0?r.name:o[i]];if(s)return s}}}}Sn.none=new Sn("",Object.create(null),0,8);class Ch{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let r of this.types){let o=null;for(let i of e){let s=i(r);if(s){o||(o=Object.assign({},r.props));let a=s[1],l=s[0];l.combine&&l.id in o&&(a=l.combine(o[l.id],a)),o[l.id]=a}}n.push(o?new Sn(r.name,o,r.id,r.flags):r)}return new Ch(n)}}const xc=new WeakMap,r1=new WeakMap;var Et;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Et||(Et={}));class _t{constructor(e,n,r,o,i){if(this.type=e,this.children=n,this.positions=r,this.length=o,this.props=null,i&&i.length){this.props=Object.create(null);for(let[s,a]of i)this.props[typeof s=="number"?s:s.id]=a}}toString(){let e=ca.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let o=r.toString();o&&(n&&(n+=","),n+=o)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new Sh(this.topNode,e)}cursorAt(e,n=0,r=0){let o=xc.get(this)||this.topNode,i=new Sh(o);return i.moveTo(e,n),xc.set(this,i._tree),i}get topNode(){return new Kn(this,0,0,null)}resolve(e,n=0){let r=ua(xc.get(this)||this.topNode,e,n,!1);return xc.set(this,r),r}resolveInner(e,n=0){let r=ua(r1.get(this)||this.topNode,e,n,!0);return r1.set(this,r),r}resolveStack(e,n=0){return ZL(this,e,n)}iterate(e){let{enter:n,leave:r,from:o=0,to:i=this.length}=e,s=e.mode||0,a=(s&Et.IncludeAnonymous)>0;for(let l=this.cursor(s|Et.IncludeAnonymous);;){let c=!1;if(l.from<=i&&l.to>=o&&(!a&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(a||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Dh(Sn.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,o)=>new _t(this.type,n,r,o,this.propValues),e.makeTree||((n,r,o)=>new _t(Sn.none,n,r,o)))}static build(e){return e3(e)}}_t.empty=new _t(Sn.none,[],[],0);class kh{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new kh(this.buffer,this.index)}}class wo{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return Sn.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],r=this.buffer[e+3],o=this.set.types[n],i=o.name;if(/\W/.test(i)&&!o.isError&&(i=JSON.stringify(i)),e+=4,r==e)return i;let s=[];for(;e<r;)s.push(this.childString(e)),e=this.buffer[e+3];return i+"("+s.join(",")+")"}findChild(e,n,r,o,i){let{buffer:s}=this,a=-1;for(let l=e;l!=n&&!(o1(i,o,s[l+1],s[l+2])&&(a=l,r>0));l=s[l+3]);return a}slice(e,n,r){let o=this.buffer,i=new Uint16Array(n-e),s=0;for(let a=e,l=0;a<n;){i[l++]=o[a++],i[l++]=o[a++]-r;let c=i[l++]=o[a++]-r;i[l++]=o[a++]-e,s=Math.max(s,c)}return new wo(i,s,this.set)}}function o1(t,e,n,r){switch(t){case-2:return n<e;case-1:return r>=e&&n<e;case 0:return n<e&&r>e;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function ua(t,e,n,r){for(var o;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let s=!r&&t instanceof Kn&&t.index<0?null:t.parent;if(!s)return t;t=s}let i=r?0:Et.IgnoreOverlays;if(r)for(let s=t,a=s.parent;a;s=a,a=s.parent)s instanceof Kn&&s.index<0&&((o=a.enter(e,n,i))===null||o===void 0?void 0:o.from)!=s.from&&(t=a);for(;;){let s=t.enter(e,n,i);if(!s)return t;t=s}}class i1{cursor(e=0){return new Sh(this,e)}getChild(e,n=null,r=null){let o=s1(this,e,n,r);return o.length?o[0]:null}getChildren(e,n=null,r=null){return s1(this,e,n,r)}resolve(e,n=0){return ua(this,e,n,!1)}resolveInner(e,n=0){return ua(this,e,n,!0)}matchContext(e){return xh(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),r=this;for(;n;){let o=n.lastChild;if(!o||o.to!=n.to)break;o.type.isError&&o.from==o.to?(r=n,n=o.prevSibling):n=o}return r}get node(){return this}get next(){return this.parent}}class Kn extends i1{constructor(e,n,r,o){super(),this._tree=e,this.from=n,this.index=r,this._parent=o}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,r,o,i=0){var s;for(let a=this;;){for(let{children:l,positions:c}=a._tree,u=n>0?l.length:-1;e!=u;e+=n){let d=l[e],h=c[e]+a.from;if(!(!(i&Et.EnterBracketed&&d instanceof _t&&((s=ca.get(d))===null||s===void 0?void 0:s.overlay)===null&&(h>=r||h+d.length<=r))&&!o1(o,r,h,h+d.length))){if(d instanceof wo){if(i&Et.ExcludeBuffers)continue;let p=d.findChild(0,d.buffer.length,n,r-h,o);if(p>-1)return new vo(new RL(a,d,e,h),null,p)}else if(i&Et.IncludeAnonymous||!d.type.isAnonymous||Eh(d)){let p;if(!(i&Et.IgnoreMounts)&&(p=ca.get(d))&&!p.overlay)return new Kn(p.tree,h,e,a);let m=new Kn(d,h,e,a);return i&Et.IncludeAnonymous||!m.type.isAnonymous?m:m.nextChild(n<0?d.children.length-1:0,n,r,o,i)}}}if(i&Et.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+n:e=n<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let o;if(!(r&Et.IgnoreOverlays)&&(o=ca.get(this._tree))&&o.overlay){let i=e-this.from,s=r&Et.EnterBracketed&&o.bracketed;for(let{from:a,to:l}of o.overlay)if((n>0||s?a<=i:a<i)&&(n<0||s?l>=i:l>i))return new Kn(o.tree,o.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function s1(t,e,n,r){let o=t.cursor(),i=[];if(!o.firstChild())return i;if(n!=null){for(let s=!1;!s;)if(s=o.type.is(n),!o.nextSibling())return i}for(;;){if(r!=null&&o.type.is(r))return i;if(o.type.is(e)&&i.push(o.node),!o.nextSibling())return r==null?i:[]}}function xh(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class RL{constructor(e,n,r,o){this.parent=e,this.buffer=n,this.index=r,this.start=o}}class vo extends i1{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:o}=this.context,i=o.findChild(this.index+4,o.buffer[this.index+3],e,n-this.context.start,r);return i<0?null:new vo(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Et.ExcludeBuffers)return null;let{buffer:o}=this.context,i=o.findChild(this.index+4,o.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return i<0?null:new vo(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new vo(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new vo(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,o=this.index+4,i=r.buffer[this.index+3];if(i>o){let s=r.buffer[this.index+1];e.push(r.slice(o,i,s)),n.push(0)}return new _t(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function a1(t){if(!t.length)return null;let e=0,n=t[0];for(let i=1;i<t.length;i++){let s=t[i];(s.from>n.from||s.to<n.to)&&(n=s,e=i)}let r=n instanceof Kn&&n.index<0?null:n.parent,o=t.slice();return r?o[e]=r:o.splice(e,1),new QL(o,n)}class QL{constructor(e,n){this.heads=e,this.node=n}get next(){return a1(this.heads)}}function ZL(t,e,n){let r=t.resolveInner(e,n),o=null;for(let i=r instanceof Kn?r:r.context.parent;i;i=i.parent)if(i.index<0){let s=i.parent;(o||(o=[r])).push(s.resolve(e,n)),i=s}else{let s=ca.get(i.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let a=new Kn(s.tree,s.overlay[0].from+i.from,-1,i);(o||(o=[r])).push(ua(a,e,n,!1))}}return o?a1(o):r}class Sh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Et.EnterBracketed,e instanceof Kn)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:o}=this.buffer;return this.type=n||o.set.types[o.buffer[e]],this.from=r+o.buffer[e+1],this.to=r+o.buffer[e+2],!0}yield(e){return e?e instanceof Kn?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:o}=this.buffer,i=o.findChild(this.index+4,o.buffer[this.index+3],e,n-this.buffer.start,r);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&Et.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Et.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Et.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let o=r<0?0:this.stack[r]+4;if(this.index!=o)return this.yieldBuf(n.findChild(o,this.index,-1,0,4))}else{let o=n.buffer[this.index+3];if(o<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(o)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:o}=this;if(o){if(e>0){if(this.index<o.buffer.buffer.length)return!1}else for(let i=0;i<this.index;i++)if(o.buffer.buffer[i+3]<this.index)return!1;({index:n,parent:r}=o)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let i=n+e,s=e<0?-1:r._tree.children.length;i!=s;i+=e){let a=r._tree.children[i];if(this.mode&Et.IncludeAnonymous||a instanceof wo||!a.type.isAnonymous||Eh(a))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,r=0;if(e&&e.context==this.buffer)e:for(let o=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==o){if(o==this.index)return s;n=s,r=i+1;break e}o=this.stack[--i]}for(let o=r;o<this.stack.length;o++)n=new vo(this.buffer,n,this.stack[o]);return this.bufferNode=new vo(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let r=0;;){let o=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(o=!0)}for(;;){if(o&&n&&n(this),o=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,o=!0}}}matchContext(e){if(!this.buffer)return xh(this.node.parent,e);let{buffer:n}=this.buffer,{types:r}=n.set;for(let o=e.length-1,i=this.stack.length-1;o>=0;i--){if(i<0)return xh(this._tree,e,o);let s=r[n.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[o]&&e[o]!=s.name)return!1;o--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof wo||!e.type.isAnonymous||Eh(e))}function e3(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:o=n1,reused:i=[],minRepeatType:s=r.types.length}=t,a=Array.isArray(n)?new kh(n,n.length):n,l=r.types,c=0,u=0;function d(C,E,D,S,_,O){let{id:B,start:N,end:F,size:M}=a,T=u,P=c;if(M<0)if(a.next(),M==-1){let G=i[B];D.push(G),S.push(N-C);return}else if(M==-3){c=B;return}else if(M==-4){u=B;return}else throw new RangeError(`Unrecognized record size: ${M}`);let $=l[B],W,V,X=N-C;if(F-N<=o&&(V=v(a.pos-E,_))){let G=new Uint16Array(V.size-V.skip),te=a.pos-V.size,H=G.length;for(;a.pos>te;)H=y(V.start,G,H);W=new wo(G,F-V.start,r),X=V.start-C}else{let G=a.pos-M;a.next();let te=[],H=[],j=B>=s?B:-1,Y=0,se=F;for(;a.pos>G;)j>=0&&a.id==j&&a.size>=0?(a.end<=se-o&&(m(te,H,N,Y,a.end,se,j,T,P),Y=te.length,se=a.end),a.next()):O>2500?h(N,G,te,H):d(N,G,te,H,j,O+1);if(j>=0&&Y>0&&Y<te.length&&m(te,H,N,Y,N,se,j,T,P),te.reverse(),H.reverse(),j>-1&&Y>0){let Q=p($,P);W=Dh($,te,H,0,te.length,0,F-N,Q,Q)}else W=w($,te,H,F-N,T-F,P)}D.push(W),S.push(X)}function h(C,E,D,S){let _=[],O=0,B=-1;for(;a.pos>E;){let{id:N,start:F,end:M,size:T}=a;if(T>4)a.next();else{if(B>-1&&F<B)break;B<0&&(B=M-o),_.push(N,F,M),O++,a.next()}}if(O){let N=new Uint16Array(O*4),F=_[_.length-2];for(let M=_.length-3,T=0;M>=0;M-=3)N[T++]=_[M],N[T++]=_[M+1]-F,N[T++]=_[M+2]-F,N[T++]=T;D.push(new wo(N,_[2]-F,r)),S.push(F-C)}}function p(C,E){return(D,S,_)=>{let O=0,B=D.length-1,N,F;if(B>=0&&(N=D[B])instanceof _t){if(!B&&N.type==C&&N.length==_)return N;(F=N.prop(Ve.lookAhead))&&(O=S[B]+N.length+F)}return w(C,D,S,_,O,E)}}function m(C,E,D,S,_,O,B,N,F){let M=[],T=[];for(;C.length>S;)M.push(C.pop()),T.push(E.pop()+D-_);C.push(w(r.types[B],M,T,O-_,N-O,F)),E.push(_-D)}function w(C,E,D,S,_,O,B){if(O){let N=[Ve.contextHash,O];B=B?[N].concat(B):[N]}if(_>25){let N=[Ve.lookAhead,_];B=B?[N].concat(B):[N]}return new _t(C,E,D,S,B)}function v(C,E){let D=a.fork(),S=0,_=0,O=0,B=D.end-o,N={size:0,start:0,skip:0};e:for(let F=D.pos-C;D.pos>F;){let M=D.size;if(D.id==E&&M>=0){N.size=S,N.start=_,N.skip=O,O+=4,S+=4,D.next();continue}let T=D.pos-M;if(M<0||T<F||D.start<B)break;let P=D.id>=s?4:0,$=D.start;for(D.next();D.pos>T;){if(D.size<0)if(D.size==-3||D.size==-4)P+=4;else break e;else D.id>=s&&(P+=4);D.next()}_=$,S+=M,O+=P}return(E<0||S==C)&&(N.size=S,N.start=_,N.skip=O),N.size>4?N:void 0}function y(C,E,D){let{id:S,start:_,end:O,size:B}=a;if(a.next(),B>=0&&S<s){let N=D;if(B>4){let F=a.pos-(B-4);for(;a.pos>F;)D=y(C,E,D)}E[--D]=N,E[--D]=O-C,E[--D]=_-C,E[--D]=S}else B==-3?c=S:B==-4&&(u=S);return D}let g=[],k=[];for(;a.pos>0;)d(t.start||0,t.bufferStart||0,g,k,-1,0);let A=(e=t.length)!==null&&e!==void 0?e:g.length?k[0]+g[0].length:0;return new _t(l[t.topID],g.reverse(),k.reverse(),A)}const l1=new WeakMap;function Sc(t,e){if(!t.isAnonymous||e instanceof wo||e.type!=t)return 1;let n=l1.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof _t)){n=1;break}n+=Sc(t,r)}l1.set(e,n)}return n}function Dh(t,e,n,r,o,i,s,a,l){let c=0;for(let m=r;m<o;m++)c+=Sc(t,e[m]);let u=Math.ceil(c*1.5/8),d=[],h=[];function p(m,w,v,y,g){for(let k=v;k<y;){let A=k,C=w[k],E=Sc(t,m[k]);for(k++;k<y;k++){let D=Sc(t,m[k]);if(E+D>=u)break;E+=D}if(k==A+1){if(E>u){let D=m[A];p(D.children,D.positions,0,D.children.length,w[A]+g);continue}d.push(m[A])}else{let D=w[k-1]+m[k-1].length-C;d.push(Dh(t,m,w,A,k,C,D,null,l))}h.push(C+g-i)}}return p(e,n,r,o,0),(a||l)(d,h,s)}class ti{constructor(e,n,r,o,i=!1,s=!1){this.from=e,this.to=n,this.tree=r,this.offset=o,this.open=(i?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let o=[new ti(0,e.length,e,0,!1,r)];for(let i of n)i.to>e.length&&o.push(i);return o}static applyChanges(e,n,r=128){if(!n.length)return e;let o=[],i=1,s=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<n.length?n[a]:null,d=u?u.fromA:1e9;if(d-l>=r)for(;s&&s.from<d;){let h=s;if(l>=h.from||d<=h.to||c){let p=Math.max(h.from,l)-c,m=Math.min(h.to,d)-c;h=p>=m?null:new ti(p,m,h.tree,h.offset+c,a>0,!!u)}if(h&&o.push(h),s.to>d)break;s=i<e.length?e[i++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return o}}class c1{startParse(e,n,r){return typeof e=="string"&&(e=new t3(e)),r=r?r.length?r.map(o=>new bh(o.from,o.to)):[new bh(0,0)]:[new bh(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let o=this.startParse(e,n,r);for(;;){let i=o.advance();if(i)return i}}}class t3{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Ve({perNode:!0});class Ec{constructor(e,n,r,o,i,s,a,l,c,u=0,d){this.p=e,this.stack=n,this.state=r,this.reducePos=o,this.pos=i,this.score=s,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=d}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let o=e.parser.context;return new Ec(e,[],n,r,r,0,[],0,o?new u1(o,o.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,o=e&65535,{parser:i}=this.p,s=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=i.dynamicPrecedence(o);if(a&&(this.score+=a),r==0){this.pushState(i.getGoto(this.state,o,!0),this.reducePos),o<i.minRepeatTerm&&this.storeNode(o,this.reducePos,this.reducePos,s?8:4,!0),this.reduceContext(o,this.reducePos);return}let l=this.stack.length-(r-1)*3-(e&262144?6:0),c=l?this.stack[l-2]:this.p.ranges[0].from,u=this.reducePos-c;u>=2e3&&!(!((n=this.p.parser.nodeSet.types[o])===null||n===void 0)&&n.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=u));let d=l?this.stack[l-1]:0,h=this.bufferBase+this.buffer.length-d;if(o<i.minRepeatTerm||e&131072){let p=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(o,c,p,h+4,!0)}if(e&262144)this.state=this.stack[l];else{let p=this.stack[l-3];this.state=i.getGoto(p,o,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(o,c)}storeNode(e,n,r,o=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this,a=this.buffer.length;if(a==0&&s.parent&&(a=s.bufferBase-s.parent.bufferBase,s=s.parent),a>0&&s.buffer[a-4]==0&&s.buffer[a-1]>-1){if(n==r)return;if(s.buffer[a-2]>=n){s.buffer[a-2]=r;return}}}if(!i||this.pos==r)this.buffer.push(e,n,r,o);else{let s=this.buffer.length;if(s>0&&(this.buffer[s-4]!=0||this.buffer[s-1]<0)){let a=!1;for(let l=s;l>0&&this.buffer[l-2]>r;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;s>0&&this.buffer[s-2]>r;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,o>4&&(o-=4)}this.buffer[s]=e,this.buffer[s+1]=n,this.buffer[s+2]=r,this.buffer[s+3]=o}}shift(e,n,r,o){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let i=e,{parser:s}=this.p;this.pos=o,!s.stateFlag(i,1)&&(o>r||n<=s.maxNode)&&(this.reducePos=o),this.pushState(i,Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=s.maxNode&&this.buffer.push(n,r,o,4)}else this.pos=o,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,o,4)}apply(e,n,r,o){e&65536?this.reduce(e):this.shift(e,n,r,o)}useNode(e,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let o=this.pos;this.reducePos=this.pos=o+e.length,this.pushState(n,o),this.buffer.push(r,o,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),o=e.bufferBase+n;for(;e&&o==e.bufferBase;)e=e.parent;return new Ec(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,o,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new n3(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if((r&65536)==0)return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let o=[];for(let i=0,s;i<n.length;i+=2)(s=n[i+1])!=this.state&&this.p.parser.hasAction(s,e)&&o.push(n[i],s);if(this.stack.length<120)for(let i=0;o.length<8&&i<n.length;i+=2){let s=n[i+1];o.some((a,l)=>l&1&&a==s)||o.push(n[i],s)}n=o}let r=[];for(let o=0;o<n.length&&r.length<4;o+=2){let i=n[o+1];if(i==this.state)continue;let s=this.split();s.pushState(i,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(n[o],this.pos),s.reducePos=this.pos,s.score-=200,r.push(s)}return r}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if((n&65536)==0)return!1;if(!e.validAction(this.state,n)){let r=n>>19,o=n&65535,i=this.stack.length-r*3;if(i<0||e.getGoto(this.stack[i],o,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;n=s}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(o,i)=>{if(!n.includes(o))return n.push(o),e.allActions(o,s=>{if(!(s&393216))if(s&65536){let a=(s>>19)-i;if(a>1){let l=s&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=r(s,i+1);if(a!=null)return a}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let n=new u1(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class u1{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class n3{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let o=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=o}}class Dc{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new Dc(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Dc(this.stack,this.pos,this.index)}}function Ac(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,o=0;r<t.length;){let i=0;for(;;){let s=t.charCodeAt(r++),a=!1;if(s==126){i=65535;break}s>=92&&s--,s>=34&&s--;let l=s-32;if(l>=46&&(l-=46,a=!0),i+=l,a)break;i*=46}n?n[o++]=i:n=new e(i)}return n}class Oc{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const d1=new Oc;class r3{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=d1,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,o=this.rangeIndex,i=this.pos+e;for(;i<r.from;){if(!o)return null;let s=this.ranges[--o];i-=r.from-s.to,r=s}for(;n<0?i>r.to:i>=r.to;){if(o==this.ranges.length-1)return null;let s=this.ranges[++o];i+=s.from-r.to,r=s}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,o;if(n>=0&&n<this.chunk.length)r=this.pos+e,o=this.chunk.charCodeAt(n);else{let i=this.resolveOffset(e,1);if(i==null)return-1;if(r=i,r>=this.chunk2Pos&&r<this.chunk2Pos+this.chunk2.length)o=this.chunk2.charCodeAt(r-this.chunk2Pos);else{let s=this.rangeIndex,a=this.range;for(;a.to<=r;)a=this.ranges[++s];this.chunk2=this.input.chunk(this.chunk2Pos=r),r+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-r)),o=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),o}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=r}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=d1,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let o of this.ranges){if(o.from>=n)break;o.to>e&&(r+=this.input.read(Math.max(o.from,e),Math.min(o.to,n)))}return r}}class Ki{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;o3(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}Ki.prototype.contextual=Ki.prototype.fallback=Ki.prototype.extend=!1,Ki.prototype.fallback=Ki.prototype.extend=!1;function o3(t,e,n,r,o,i){let s=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;(a&t[s])!=0;){let c=t[s+1];for(let p=s+3;p<c;p+=2)if((t[p+1]&a)>0){let m=t[p];if(l.allows(m)&&(e.token.value==-1||e.token.value==m||i3(m,e.token.value,o,i))){e.acceptToken(m);break}}let u=e.next,d=0,h=t[s+2];if(e.next<0&&h>d&&t[c+h*3-3]==65535){s=t[c+h*3-1];continue e}for(;d<h;){let p=d+h>>1,m=c+p+(p<<1),w=t[m],v=t[m+1]||65536;if(u<w)h=p;else if(u>=v)d=p+1;else{s=t[m+2],e.advance();continue e}}break}}function f1(t,e,n){for(let r=e,o;(o=t[r])!=65535;r++)if(o==n)return r-e;return-1}function i3(t,e,n,r){let o=f1(n,r,e);return o<0||f1(n,r,t)<o}const Ln=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG);let Ah=null;function h1(t,e,n){let r=t.cursor(Et.IncludeAnonymous);for(r.moveTo(e);;)if(!(n<0?r.childBefore(e):r.childAfter(e)))for(;;){if((n<0?r.to<e:r.from>e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class s3{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?h1(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?h1(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let r=this.trees[n],o=this.index[n];if(o==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=r.children[o],s=this.start[n]+r.positions[o];if(s>e)return this.nextStart=s,null;if(i instanceof _t){if(s==e){if(s<this.safeFrom)return null;let a=s+i.length;if(a<=this.safeTo){let l=i.prop(Ve.lookAhead);if(!l||a+l<this.fragment.to)return i}}this.index[n]++,s+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(s),this.index.push(0))}else this.index[n]++,this.nextStart=s+i.length}}}class a3{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new Oc)}getActions(e){let n=0,r=null,{parser:o}=e.p,{tokenizers:i}=o,s=o.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;c<i.length;c++){if((1<<c&s)==0)continue;let u=i[c],d=this.tokens[c];if(!(r&&!u.fallback)&&((u.contextual||d.start!=e.pos||d.mask!=s||d.context!=a)&&(this.updateCachedToken(d,u,e),d.mask=s,d.context=a),d.lookAhead>d.end+25&&(l=Math.max(d.lookAhead,l)),d.value!=0)){let h=n;if(d.extended>-1&&(n=this.addActions(e,d.extended,d.end,n)),n=this.addActions(e,d.value,d.end,n),!u.extend&&(r=d,n>h))break}}for(;this.actions.length>n;)this.actions.pop();return l&&e.setLookAhead(l),!r&&e.pos==this.stream.end&&(r=new Oc,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new Oc,{pos:r,p:o}=e;return n.start=r,n.end=Math.min(r+1,o.stream.end),n.value=r==o.stream.end?o.parser.eofTerm:0,n}updateCachedToken(e,n,r){let o=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(o,e),r),e.value>-1){let{parser:i}=r.p;for(let s=0;s<i.specialized.length;s++)if(i.specialized[s]==e.value){let a=i.specializers[s](this.stream.read(e.start,e.end),r);if(a>=0&&r.p.parser.dialect.allows(a>>1)){(a&1)==0?e.value=a>>1:e.extended=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(o+1)}putAction(e,n,r,o){for(let i=0;i<o;i+=3)if(this.actions[i]==e)return o;return this.actions[o++]=e,this.actions[o++]=n,this.actions[o++]=r,o}addActions(e,n,r,o){let{state:i}=e,{parser:s}=e.p,{data:a}=s;for(let l=0;l<2;l++)for(let c=s.stateSlot(i,l?2:1);;c+=3){if(a[c]==65535)if(a[c+1]==1)c=Rr(a,c+2);else{o==0&&a[c+1]==2&&(o=this.putAction(Rr(a,c+2),n,r,o));break}a[c]==n&&(o=this.putAction(Rr(a,c+1),n,r,o))}return o}}class l3{constructor(e,n,r,o){this.parser=e,this.input=n,this.ranges=o,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new r3(n,o),this.tokens=new a3(e,this.stream),this.topTerm=e.top[1];let{from:i}=o[0];this.stacks=[Ec.start(this,e.top[0],i)],this.fragments=r.length&&this.stream.end-i>e.bufferLength*4?new s3(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,r=this.stacks=[],o,i;if(this.bigReductionCount>300&&e.length==1){let[s]=e;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<e.length;s++){let a=e[s];for(;;){if(this.tokens.mainToken=null,a.pos>n)r.push(a);else{if(this.advanceStack(a,r,e))continue;{o||(o=[],i=[]),o.push(a);let l=this.tokens.getMainToken(a);i.push(l.value,l.end)}}break}}if(!r.length){let s=o&&u3(o);if(s)return Ln&&console.log("Finish with "+this.stackID(s)),this.stackToTree(s);if(this.parser.strict)throw Ln&&o&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&o){let s=this.stoppedAt!=null&&o[0].pos>this.stoppedAt?o[0]:this.runRecovery(o,i,r);if(s)return Ln&&console.log("Force-finish "+this.stackID(s)),this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(r.length>s)for(r.sort((a,l)=>l.score-a.score);r.length>s;)r.pop();r.some(a=>a.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let s=0;s<r.length-1;s++){let a=r[s];for(let l=s+1;l<r.length;l++){let c=r[l];if(a.sameState(c)||a.buffer.length>500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)r.splice(l--,1);else{r.splice(s--,1);continue e}}}r.length>12&&(r.sort((s,a)=>a.score-s.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let s=1;s<r.length;s++)r[s].pos<this.minStackPos&&(this.minStackPos=r[s].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,r){let o=e.pos,{parser:i}=this,s=Ln?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&o>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let d=this.fragments.nodeAt(o);d;){let h=this.parser.nodeSet.types[d.type.id]==d.type?i.getGoto(e.state,d.type.id):-1;if(h>-1&&d.length&&(!c||(d.prop(Ve.contextHash)||0)==u))return e.useNode(d,h),Ln&&console.log(s+this.stackID(e)+` (via reuse of ${i.getName(d.type.id)})`),!0;if(!(d instanceof _t)||d.children.length==0||d.positions[0]>0)break;let p=d.children[0];if(p instanceof _t&&d.positions[0]==0)d=p;else break}}let a=i.stateSlot(e.state,4);if(a>0)return e.reduce(a),Ln&&console.log(s+this.stackID(e)+` (via always-reduce ${i.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;c<l.length;){let u=l[c++],d=l[c++],h=l[c++],p=c==l.length||!r,m=p?e:e.split(),w=this.tokens.mainToken;if(m.apply(u,d,w?w.start:m.pos,h),Ln&&console.log(s+this.stackID(m)+` (via ${(u&65536)==0?"shift":`reduce of ${i.getName(u&65535)}`} for ${i.getName(d)} @ ${o}${m==e?"":", split"})`),p)return!0;m.pos>o?n.push(m):r.push(m)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return p1(e,n),!0}}runRecovery(e,n,r){let o=null,i=!1;for(let s=0;s<e.length;s++){let a=e[s],l=n[s<<1],c=n[(s<<1)+1],u=Ln?this.stackID(a)+" -> ":"";if(a.deadEnd&&(i||(i=!0,a.restart(),Ln&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,r))))continue;let d=a.split(),h=u;for(let p=0;p<10&&d.forceReduce()&&(Ln&&console.log(h+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,r));p++)Ln&&(h=this.stackID(d)+" -> ");for(let p of a.recoverByInsert(l))Ln&&console.log(u+this.stackID(p)+" (via recover-insert)"),this.advanceFully(p,r);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),Ln&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),p1(a,r)):(!o||o.score<d.score)&&(o=d)}return o}stackToTree(e){return e.close(),_t.build({buffer:Dc.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let n=(Ah||(Ah=new WeakMap)).get(e);return n||Ah.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function p1(t,e){for(let n=0;n<e.length;n++){let r=e[n];if(r.pos==t.pos&&r.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class c3{constructor(e,n,r){this.source=e,this.flags=n,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}}class Tc extends c1{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let a=0;a<e.repeatNodeCount;a++)n.push("");let r=Object.keys(e.topRules).map(a=>e.topRules[a][1]),o=[];for(let a=0;a<n.length;a++)o.push([]);function i(a,l,c){o[a].push([l,l.deserialize(String(c))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=Ve[l]);for(let c=1;c<a.length;){let u=a[c++];if(u>=0)i(u,l,a[c++]);else{let d=a[c+-u];for(let h=-u;h>0;h--)i(a[c++],l,d);c++}}}this.nodeSet=new Ch(n.map((a,l)=>Sn.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:o[l],top:r.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=n1;let s=Ac(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(m1),this.states=Ac(e.states,Uint32Array),this.data=Ac(e.stateData),this.goto=Ac(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Ki(s,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let o=new l3(this,e,n,r);for(let i of this.wrappers)o=i(o,e,n,r);return o}getGoto(e,n,r=!1){let o=this.goto;if(n>=o[0])return-1;for(let i=o[n+1];;){let s=o[i++],a=s&1,l=o[i++];if(a&&r)return l;for(let c=i+(s>>1);i<c;i++)if(o[i]==e)return l;if(a)return-1}}hasAction(e,n){let r=this.data;for(let o=0;o<2;o++)for(let i=this.stateSlot(e,o?2:1),s;;i+=3){if((s=r[i])==65535)if(r[i+1]==1)s=r[i=Rr(r,i+2)];else{if(r[i+1]==2)return Rr(r,i+2);break}if(s==n||s==0)return Rr(r,i+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),o=r?n(r):void 0;for(let i=this.stateSlot(e,1);o==null;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Rr(this.data,i+2);else break;o=n(Rr(this.data,i+1))}return o}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Rr(this.data,r+2);else break;if((this.data[r+2]&1)==0){let o=this.data[r+1];n.some((i,s)=>s&1&&i==o)||n.push(this.data[r],o)}}return n}configure(e){let n=Object.assign(Object.create(Tc.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let o=e.tokenizers.find(i=>i.from==r);return o?o.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,o)=>{let i=e.specializers.find(a=>a.from==r.external);if(!i)return r;let s=Object.assign(Object.assign({},r),{external:i.to});return n.specializers[o]=m1(s),s})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let i of e.split(" ")){let s=n.indexOf(i);s>=0&&(r[s]=!0)}let o=null;for(let i=0;i<n.length;i++)if(!r[i])for(let s=this.dialects[n[i]],a;(a=this.data[s++])!=65535;)(o||(o=new Uint8Array(this.maxTerm+1)))[a]=1;return new c3(e,r,o)}static deserialize(e){return new Tc(e)}}function Rr(t,e){return t[e]|t[e+1]<<16}function u3(t){let e=null;for(let n of t){let r=n.p.stoppedAt;(n.pos==n.p.stream.end||r!=null&&n.pos>r)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function m1(t){if(t.external){let e=t.extend?1:0;return(n,r)=>t.external(n,r)<<1|e}return t.get}let d3=0;class Yn{constructor(e,n,r,o){this.name=e,this.set=n,this.base=r,this.modified=o,this.id=d3++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof Yn&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let o=new Yn(r,[],null,[]);if(o.set.push(o),n)for(let i of n.set)o.set.push(i);return o}static defineModifier(e){let n=new _c(e);return r=>r.modified.indexOf(n)>-1?r:_c.get(r.base||r,r.modified.concat(n).sort((o,i)=>o.id-i.id))}}let f3=0;class _c{constructor(e){this.name=e,this.instances=[],this.id=f3++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(a=>a.base==e&&h3(n,a.modified));if(r)return r;let o=[],i=new Yn(e.name,o,e,n);for(let a of n)a.instances.push(i);let s=p3(n);for(let a of e.set)if(!a.modified.length)for(let l of s)o.push(_c.get(a,l));return i}}function h3(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function p3(t){let e=[[]];for(let n=0;n<t.length;n++)for(let r=0,o=e.length;r<o;r++)e.push(e[r].concat(t[n]));return e.sort((n,r)=>r.length-n.length)}function g1(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let o of n.split(" "))if(o){let i=[],s=2,a=o;for(let d=0;;){if(a=="..."&&d>0&&d+3==o.length){s=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+o);if(i.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),d+=h[0].length,d==o.length)break;let p=o[d++];if(d==o.length&&p=="!"){s=0;break}if(p!="/")throw new RangeError("Invalid path: "+o);a=o.slice(d)}let l=i.length-1,c=i[l];if(!c)throw new RangeError("Invalid path: "+o);let u=new da(r,s,l>0?i.slice(0,l):null);e[c]=u.sort(e[c])}}return w1.add(e)}const w1=new Ve({combine(t,e){let n,r,o;for(;t||e;){if(!t||e&&t.depth>=e.depth?(o=e,e=e.next):(o=t,t=t.next),n&&n.mode==o.mode&&!o.context&&!n.context)continue;let i=new da(o.tags,o.mode,o.context);n?n.next=i:r=i,n=i}return r}});class da{constructor(e,n,r,o){this.tags=e,this.mode=n,this.context=r,this.next=o}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}da.empty=new da([],2,null);function v1(t,e){let n=Object.create(null);for(let i of t)if(!Array.isArray(i.tag))n[i.tag.id]=i.class;else for(let s of i.tag)n[s.id]=i.class;let{scope:r,all:o=null}=e||{};return{style:i=>{let s=o;for(let a of i)for(let l of a.set){let c=n[l.id];if(c){s=s?s+" "+c:c;break}}return s},scope:r}}function m3(t,e){let n=null;for(let r of t){let o=r.style(e);o&&(n=n?n+" "+o:o)}return n}function g3(t,e,n,r=0,o=t.length){let i=new w3(r,Array.isArray(e)?e:[e],n);i.highlightRange(t.cursor(),r,o,"",i.highlighters),i.flush(o)}class w3{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,o,i){let{type:s,from:a,to:l}=e;if(a>=r||l<=n)return;s.isTop&&(i=this.highlighters.filter(p=>!p.scope||p.scope(s)));let c=o,u=v3(e)||da.empty,d=m3(i,u.tags);if(d&&(c&&(c+=" "),c+=d,u.mode==1&&(o+=(o?" ":"")+d)),this.startSpan(Math.max(n,a),c),u.opaque)return;let h=e.tree&&e.tree.prop(Ve.mounted);if(h&&h.overlay){let p=e.node.enter(h.overlay[0].from+a,1),m=this.highlighters.filter(v=>!v.scope||v.scope(h.tree.type)),w=e.firstChild();for(let v=0,y=a;;v++){let g=v<h.overlay.length?h.overlay[v]:null,k=g?g.from+a:l,A=Math.max(n,y),C=Math.min(r,k);if(A<C&&w)for(;e.from<C&&(this.highlightRange(e,A,C,o,i),this.startSpan(Math.min(C,e.to),c),!(e.to>=k||!e.nextSibling())););if(!g||k>r)break;y=g.to+a,y>n&&(this.highlightRange(p.cursor(),Math.max(n,g.from+a),Math.min(r,y),"",m),this.startSpan(Math.min(r,y),c))}w&&e.parent()}else if(e.firstChild()){h&&(o="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,o,i),this.startSpan(Math.min(r,e.to),c)}while(e.nextSibling());e.parent()}}}function v3(t){let e=t.type.prop(w1);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const ye=Yn.define,Nc=ye(),yo=ye(),y1=ye(yo),b1=ye(yo),bo=ye(),Bc=ye(bo),Oh=ye(bo),Dr=ye(),ni=ye(Dr),Ar=ye(),Or=ye(),Th=ye(),fa=ye(Th),Fc=ye(),z={comment:Nc,lineComment:ye(Nc),blockComment:ye(Nc),docComment:ye(Nc),name:yo,variableName:ye(yo),typeName:y1,tagName:ye(y1),propertyName:b1,attributeName:ye(b1),className:ye(yo),labelName:ye(yo),namespace:ye(yo),macroName:ye(yo),literal:bo,string:Bc,docString:ye(Bc),character:ye(Bc),attributeValue:ye(Bc),number:Oh,integer:ye(Oh),float:ye(Oh),bool:ye(bo),regexp:ye(bo),escape:ye(bo),color:ye(bo),url:ye(bo),keyword:Ar,self:ye(Ar),null:ye(Ar),atom:ye(Ar),unit:ye(Ar),modifier:ye(Ar),operatorKeyword:ye(Ar),controlKeyword:ye(Ar),definitionKeyword:ye(Ar),moduleKeyword:ye(Ar),operator:Or,derefOperator:ye(Or),arithmeticOperator:ye(Or),logicOperator:ye(Or),bitwiseOperator:ye(Or),compareOperator:ye(Or),updateOperator:ye(Or),definitionOperator:ye(Or),typeOperator:ye(Or),controlOperator:ye(Or),punctuation:Th,separator:ye(Th),bracket:fa,angleBracket:ye(fa),squareBracket:ye(fa),paren:ye(fa),brace:ye(fa),content:Dr,heading:ni,heading1:ye(ni),heading2:ye(ni),heading3:ye(ni),heading4:ye(ni),heading5:ye(ni),heading6:ye(ni),contentSeparator:ye(Dr),list:ye(Dr),quote:ye(Dr),emphasis:ye(Dr),strong:ye(Dr),link:ye(Dr),monospace:ye(Dr),strikethrough:ye(Dr),inserted:ye(),deleted:ye(),changed:ye(),invalid:ye(),meta:Fc,documentMeta:ye(Fc),annotation:ye(Fc),processingInstruction:ye(Fc),definition:Yn.defineModifier("definition"),constant:Yn.defineModifier("constant"),function:Yn.defineModifier("function"),standard:Yn.defineModifier("standard"),local:Yn.defineModifier("local"),special:Yn.defineModifier("special")};for(let t in z){let e=z[t];e instanceof Yn&&(e.name=t)}v1([{tag:z.link,class:"tok-link"},{tag:z.heading,class:"tok-heading"},{tag:z.emphasis,class:"tok-emphasis"},{tag:z.strong,class:"tok-strong"},{tag:z.keyword,class:"tok-keyword"},{tag:z.atom,class:"tok-atom"},{tag:z.bool,class:"tok-bool"},{tag:z.url,class:"tok-url"},{tag:z.labelName,class:"tok-labelName"},{tag:z.inserted,class:"tok-inserted"},{tag:z.deleted,class:"tok-deleted"},{tag:z.literal,class:"tok-literal"},{tag:z.string,class:"tok-string"},{tag:z.number,class:"tok-number"},{tag:[z.regexp,z.escape,z.special(z.string)],class:"tok-string2"},{tag:z.variableName,class:"tok-variableName"},{tag:z.local(z.variableName),class:"tok-variableName tok-local"},{tag:z.definition(z.variableName),class:"tok-variableName tok-definition"},{tag:z.special(z.variableName),class:"tok-variableName2"},{tag:z.definition(z.propertyName),class:"tok-propertyName tok-definition"},{tag:z.typeName,class:"tok-typeName"},{tag:z.namespace,class:"tok-namespace"},{tag:z.className,class:"tok-className"},{tag:z.macroName,class:"tok-macroName"},{tag:z.propertyName,class:"tok-propertyName"},{tag:z.operator,class:"tok-operator"},{tag:z.comment,class:"tok-comment"},{tag:z.meta,class:"tok-meta"},{tag:z.invalid,class:"tok-invalid"},{tag:z.punctuation,class:"tok-punctuation"}]);const y3=g1({String:z.string,Number:z.number,"True False":z.bool,PropertyName:z.propertyName,Null:z.null,", :":z.separator,"[ ]":z.squareBracket,"{ }":z.brace}),b3=Tc.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[y3],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});let _h=[],C1=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?C1:_h).push(n=n+t[e])})();function C3(t){if(t<768)return!1;for(let e=0,n=_h.length;;){let r=e+n>>1;if(t<_h[r])n=r;else if(t>=C1[r])e=r+1;else return!0;if(e==n)return!1}}function k1(t){return t>=127462&&t<=127487}const x1=8205;function k3(t,e,n=!0,r=!0){return(n?S1:x3)(t,e,r)}function S1(t,e,n){if(e==t.length)return e;e&&E1(t.charCodeAt(e))&&D1(t.charCodeAt(e-1))&&e--;let r=Nh(t,e);for(e+=A1(r);e<t.length;){let o=Nh(t,e);if(r==x1||o==x1||n&&C3(o))e+=A1(o),r=o;else if(k1(o)){let i=0,s=e-2;for(;s>=0&&k1(Nh(t,s));)i++,s-=2;if(i%2==0)break;e+=2}else break}return e}function x3(t,e,n){for(;e>0;){let r=S1(t,e-2,n);if(r<e)return r;e--}return 0}function Nh(t,e){let n=t.charCodeAt(e);if(!D1(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return E1(r)?(n-55296<<10)+(r-56320)+65536:n}function E1(t){return t>=56320&&t<57344}function D1(t){return t>=55296&&t<56320}function A1(t){return t<65536?1:2}let Ze=class BT{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Yi(this,e,n);let o=[];return this.decompose(0,e,o,2),r.length&&r.decompose(0,r.length,o,3),this.decompose(n,this.length,o,1),Tr.from(o,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Yi(this,e,n);let r=[];return this.decompose(e,n,r,0),Tr.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),o=new ha(this),i=new ha(e);for(let s=n,a=n;;){if(o.next(s),i.next(s),s=0,o.lineBreak!=i.lineBreak||o.done!=i.done||o.value!=i.value)return!1;if(a+=o.value.length,o.done||a>=r)return!0}}iter(e=1){return new ha(this,e)}iterRange(e,n=this.length){return new T1(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let o=this.line(e).from;r=this.iterRange(o,Math.max(o,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new _1(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?BT.empty:e.length<=32?new Nt(e):Tr.from(Nt.split(e,[]))}};class Nt extends Ze{constructor(e,n=S3(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,o){for(let i=0;;i++){let s=this.text[i],a=o+s.length;if((n?r:a)>=e)return new E3(o,a,r,s);o=a+1,r++}}decompose(e,n,r,o){let i=e<=0&&n>=this.length?this:new Nt(O1(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(o&1){let s=r.pop(),a=Ic(i.text,s.text.slice(),0,i.length);if(a.length<=32)r.push(new Nt(a,s.length+i.length));else{let l=a.length>>1;r.push(new Nt(a.slice(0,l)),new Nt(a.slice(l)))}}else r.push(i)}replace(e,n,r){if(!(r instanceof Nt))return super.replace(e,n,r);[e,n]=Yi(this,e,n);let o=Ic(this.text,Ic(r.text,O1(this.text,0,e)),n),i=this.length+r.length-(n-e);return o.length<=32?new Nt(o,i):Tr.from(Nt.split(o,[]),i)}sliceString(e,n=this.length,r=`
|
|
31
|
+
`)),c}o.current=t,i.current=s,r.current=void 0;var l=b.useCallback(()=>{try{var c=o.current();if(e(i.current,c))return;i.current=c}catch(u){u instanceof Error?r.current=u:r.current=new Error(String(u))}n()},[]);return[s,l]}function XP(t){return t instanceof Error}var Wb=b.createContext({}),Ub=(t,e)=>{var n=lr(),{decorate:r,addEventListener:o}=b.useContext(Wb),i=()=>{var c=pe.findPath(n,t);return r([t,c])},s=Oe.isText(t)?yb:dh,[a,l]=Vb(i,s);return Sr(()=>{var c=o(l);return l(),c},[o,l]),b.useMemo(()=>[...a,...e],[a,e])},JP=t=>{var e=b.useRef(new Set),n=b.useRef(t);Sr(()=>{n.current=t,e.current.forEach(i=>i())},[t]);var r=b.useCallback(i=>n.current(i),[]),o=b.useCallback(i=>(e.current.add(i),()=>{e.current.delete(i)}),[]);return b.useMemo(()=>({decorate:r,addEventListener:o}),[r,o])};function qb(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Gb(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?qb(Object(n),!0).forEach(function(r){vt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):qb(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var RP=t=>b.createElement(ZP,Gb({},t)),QP=t=>{for(var{decorations:e,isLast:n,parent:r,renderPlaceholder:o,renderLeaf:i,renderText:s=RP,text:a}=t,l=lr(),c=b.useRef(null),u=Ub(a,e),d=Oe.decorations(a,u),h=pe.findKey(l,a),p=[],m=0;m<d.length;m++){var{leaf:w,position:v}=d[m];p.push(b.createElement(KP,{isLast:n&&m===d.length-1,key:"".concat(h.id,"-").concat(m),renderPlaceholder:o,leaf:w,leafPosition:v,text:a,parent:r,renderLeaf:i}))}var y=b.useCallback(k=>{var A=fc.get(l);k?(A==null||A.set(h,k),Ro.set(a,k),na.set(k,a)):(A==null||A.delete(h),Ro.delete(a),c.current&&na.delete(c.current)),c.current=k},[c,l,h,a]),g={"data-slate-node":"text",ref:y};return s({text:a,children:p,attributes:g})},Kb=b.memo(QP,(t,e)=>e.parent===t.parent&&e.isLast===t.isLast&&e.renderText===t.renderText&&e.renderLeaf===t.renderLeaf&&e.renderPlaceholder===t.renderPlaceholder&&e.text===t.text&&yb(e.decorations,t.decorations)),ZP=t=>{var{attributes:e,children:n}=t;return b.createElement("span",Gb({},e),n)};function Yb(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function vh(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Yb(Object(n),!0).forEach(function(r){vt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Yb(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var e2=t=>b.createElement(r2,vh({},t)),t2=t=>{var{decorations:e,element:n,renderElement:r=e2,renderChunk:o,renderPlaceholder:i,renderLeaf:s,renderText:a}=t,l=lr(),c=h2(),u=l.isInline(n),d=Ub(n,e),h=pe.findKey(l,n),p=b.useCallback(A=>{var C=fc.get(l);A?(C==null||C.set(h,A),Ro.set(n,A),na.set(A,n)):(C==null||C.delete(h),Ro.delete(n))},[l,h,n]),m=eC({decorations:d,node:n,renderElement:r,renderChunk:o,renderPlaceholder:i,renderLeaf:s,renderText:a}),w={"data-slate-node":"element",ref:p};if(u&&(w["data-slate-inline"]=!0),!u&&I.hasInlines(l,n)){var v=ge.string(n),y=Dy(v);y==="rtl"&&(w.dir=y)}if(I.isVoid(l,n)){w["data-slate-void"]=!0,!c&&u&&(w.contentEditable=!1);var g=u?"span":"div",[[k]]=ge.texts(n);m=b.createElement(g,{"data-slate-spacer":!0,style:{height:"0",color:"transparent",outline:"none",position:"absolute"}},b.createElement(Kb,{renderPlaceholder:i,decorations:[],isLast:!1,parent:n,text:k})),Vi.set(k,0),ea.set(k,n)}return r({attributes:w,children:m,element:n})},n2=b.memo(t2,(t,e)=>t.element===e.element&&t.renderElement===e.renderElement&&t.renderChunk===e.renderChunk&&t.renderText===e.renderText&&t.renderLeaf===e.renderLeaf&&t.renderPlaceholder===e.renderPlaceholder&&dh(t.decorations,e.decorations)),r2=t=>{var{attributes:e,children:n,element:r}=t,o=lr(),i=o.isInline(r)?"span":"div";return b.createElement(i,vh(vh({},e),{},{style:{position:"relative"}}),n)};class o2{constructor(e,n){var{chunkSize:r,debug:o}=n;vt(this,"root",void 0),vt(this,"chunkSize",void 0),vt(this,"debug",void 0),vt(this,"reachedEnd",void 0),vt(this,"pointerChunk",void 0),vt(this,"pointerIndex",void 0),vt(this,"pointerIndexStack",void 0),vt(this,"cachedPointerNode",void 0),this.root=e,this.chunkSize=r,this.debug=o??!1,this.pointerChunk=e,this.pointerIndex=-1,this.pointerIndexStack=[],this.reachedEnd=!1,this.validateState()}readLeaf(){if(this.reachedEnd)return null;for(;;)if(this.pointerIndex+1<this.pointerSiblings.length){this.pointerIndex++,this.cachedPointerNode=void 0;break}else{if(this.pointerChunk.type==="root")return this.reachedEnd=!0,null;this.exitChunk()}return this.validateState(),this.enterChunkUntilLeaf(!1),this.pointerNode}returnToPreviousLeaf(){if(this.reachedEnd){this.reachedEnd=!1,this.enterChunkUntilLeaf(!0);return}for(;;)if(this.pointerIndex>=1){this.pointerIndex--,this.cachedPointerNode=void 0;break}else if(this.pointerChunk.type==="root"){this.pointerIndex=-1;return}else this.exitChunk();this.validateState(),this.enterChunkUntilLeaf(!0)}insertBefore(e){this.returnToPreviousLeaf(),this.insertAfter(e),this.readLeaf()}insertAfter(e){if(e.length!==0){for(var n=0,r=0;this.pointerChunk.type==="chunk"&&this.pointerIndex===this.pointerSiblings.length-1;){var o=this.chunkSize-this.pointerSiblings.length,i=Math.min(o,e.length);if(i>0){var s=e.splice(0,i);this.rawInsertAfter(s,n)}this.exitChunk(),n++}if(e.length!==0){var a=this.savePointer(),l=null;if(this.readLeaf())for(;this.pointerChunk.type==="chunk"&&this.pointerIndex===0;){var c=this.chunkSize-this.pointerSiblings.length,u=Math.min(c,e.length);if(u>0){var d=e.splice(-u,u);this.pointerIndex=-1,this.cachedPointerNode=void 0,this.rawInsertAfter(d,r),l||(l=this.savePointer())}this.exitChunk(),r++}this.restorePointer(a);var h=Math.max(n,r);this.rawInsertAfter(e,h),l&&this.restorePointer(l),this.validateState()}}}remove(){this.pointerSiblings.splice(this.pointerIndex--,1),this.cachedPointerNode=void 0,this.pointerSiblings.length===0&&this.pointerChunk.type==="chunk"?(this.exitChunk(),this.remove()):this.invalidateChunk(),this.validateState()}invalidateChunk(){for(var e=this.pointerChunk;e.type==="chunk";e=e.parent)this.root.modifiedChunks.add(e)}get atStart(){return this.pointerChunk.type==="root"&&this.pointerIndex===-1}get pointerSiblings(){return this.pointerChunk.children}getPointerNode(){return this.reachedEnd||this.pointerIndex===-1?null:this.pointerSiblings[this.pointerIndex]}get pointerNode(){if(this.cachedPointerNode!==void 0)return this.cachedPointerNode;var e=this.getPointerNode();return this.cachedPointerNode=e,e}getChunkPath(e){for(var n=[],r=e;r.type==="chunk";r=r.parent){var o=r.parent.children.indexOf(r);if(o===-1)return null;n.unshift(o)}return n}savePointer(){if(this.atStart)return"start";if(!this.pointerNode)throw new Error("Cannot save pointer when pointerNode is null");return{chunk:this.pointerChunk,node:this.pointerNode}}restorePointer(e){if(e==="start"){this.pointerChunk=this.root,this.pointerIndex=-1,this.pointerIndexStack=[],this.reachedEnd=!1,this.cachedPointerNode=void 0;return}var{chunk:n,node:r}=e,o=n.children.indexOf(r);if(o===-1)throw new Error("Cannot restore point because saved node is no longer in saved chunk");var i=this.getChunkPath(n);if(!i)throw new Error("Cannot restore point because saved chunk is no longer connected to root");this.pointerChunk=n,this.pointerIndex=o,this.pointerIndexStack=i,this.reachedEnd=!1,this.cachedPointerNode=r,this.validateState()}enterChunk(e){var n;if(((n=this.pointerNode)===null||n===void 0?void 0:n.type)!=="chunk")throw new Error("Cannot enter non-chunk");if(this.pointerIndexStack.push(this.pointerIndex),this.pointerChunk=this.pointerNode,this.pointerIndex=e?this.pointerSiblings.length-1:0,this.cachedPointerNode=void 0,this.validateState(),this.pointerChunk.children.length===0)throw new Error("Cannot enter empty chunk")}enterChunkUntilLeaf(e){for(;((n=this.pointerNode)===null||n===void 0?void 0:n.type)==="chunk";){var n;this.enterChunk(e)}}exitChunk(){if(this.pointerChunk.type==="root")throw new Error("Cannot exit root");var e=this.pointerChunk;this.pointerChunk=e.parent,this.pointerIndex=this.pointerIndexStack.pop(),this.cachedPointerNode=void 0,this.validateState()}rawInsertAfter(e,n){if(e.length!==0){for(var r=(u,d,h)=>{if(h===1)return u;for(var p=[],m=0;m<this.chunkSize;m++){var w=u.slice(m*h,(m+1)*h);if(w.length===0)break;var v={type:"chunk",key:new rb,parent:d,children:[]};v.children=r(w,v,h/this.chunkSize),p.push(v)}return p},o=this.pointerSiblings.length+e.length,i=0,s=this.chunkSize;s<o;s*=this.chunkSize)i++;var a=Math.max(i,n),l=Math.pow(this.chunkSize,a),c=r(e,this.pointerChunk,l);this.pointerSiblings.splice(this.pointerIndex+1,0,...c),this.pointerIndex+=c.length,this.cachedPointerNode=void 0,this.invalidateChunk(),this.validateState()}}validateState(){if(this.debug){var e=r=>{if(r.type==="chunk"){var{parent:o,children:i}=r;if(!o.children.includes(r))throw new Error("Debug: Chunk ".concat(r.key.id," has an incorrect parent property"));i.forEach(e)}};if(this.root.children.forEach(e),this.cachedPointerNode!==void 0&&this.cachedPointerNode!==this.getPointerNode())throw new Error("Debug: The cached pointer is incorrect and has not been invalidated");var n=this.getChunkPath(this.pointerChunk);if(!n)throw new Error("Debug: The pointer chunk is not connected to the root");if(!U.equals(this.pointerIndexStack,n))throw new Error("Debug: The cached index stack [".concat(this.pointerIndexStack.join(", "),"] does not match the path of the pointer chunk [").concat(n.join(", "),"]"))}}}class i2{constructor(e,n){vt(this,"editor",void 0),vt(this,"children",void 0),vt(this,"cachedKeys",void 0),vt(this,"pointerIndex",void 0),this.editor=e,this.children=n,this.cachedKeys=new Array(n.length),this.pointerIndex=0}read(e){if(e===1)return[this.children[this.pointerIndex++]];var n=this.remaining(e);return this.pointerIndex+=e,n}remaining(e){return e===void 0?this.children.slice(this.pointerIndex):this.children.slice(this.pointerIndex,this.pointerIndex+e)}get reachedEnd(){return this.pointerIndex>=this.children.length}lookAhead(e,n){var r=this.children.indexOf(e,this.pointerIndex);if(r>-1)return r-this.pointerIndex;for(var o=this.pointerIndex;o<this.children.length;o++){var i=this.children[o],s=this.findKey(i,o);if(s===n)return o-this.pointerIndex}return-1}toChunkLeaves(e,n){return e.map((r,o)=>({type:"leaf",node:r,key:this.findKey(r,n+o),index:n+o}))}findKey(e,n){var r=this.cachedKeys[n];if(r)return r;var o=pe.findKey(this.editor,e);return this.cachedKeys[n]=o,o}}var s2=(t,e)=>{var{chunkTree:n,children:r,chunkSize:o,rerenderChildren:i=[],onInsert:s,onUpdate:a,onIndexChange:l,debug:c}=e;n.modifiedChunks.clear();for(var u=new o2(n,{chunkSize:o,debug:c}),d=new i2(t,r),h,p=function(){var y=d.lookAhead(h.node,h.key),g=y>0&&n.movedNodeKeys.has(h.key);if(y===-1||g)return u.remove(),1;var k=d.pointerIndex,A=d.read(y+1),C=A.pop();if(A.length){var E=d.toChunkLeaves(A,k);u.insertBefore(E),A.forEach((S,_)=>{s==null||s(S,k+_)})}var D=d.pointerIndex-1;h.node!==C&&(h.node=C,u.invalidateChunk(),a==null||a(C,D)),h.index!==D&&(h.index=D,l==null||l(C,D)),i.includes(D)&&u.invalidateChunk()};h=u.readLeaf();)p();if(!d.reachedEnd){var m=d.remaining(),w=d.toChunkLeaves(m,d.pointerIndex);u.returnToPreviousLeaf(),u.insertAfter(w),m.forEach((v,y)=>{s==null||s(v,d.pointerIndex+y)})}n.movedNodeKeys.clear()};function Xb(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function a2(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Xb(Object(n),!0).forEach(function(r){vt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Xb(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var Jb=new WeakMap,Rb=function(e,n){var r=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},o=pe.findKey(e,n),i=Jb.get(o);return i||(i={type:"root",movedNodeKeys:new Set,modifiedChunks:new Set,children:[]},Jb.set(o,i)),r.reconcile&&s2(e,a2({chunkTree:i,children:n.children},r.reconcile)),i},l2=t=>{var{children:e}=t;return e},Qb=t=>{var{root:e,ancestor:n,renderElement:r,renderChunk:o=l2}=t;return n.children.map(i=>{if(i.type==="chunk"){var s=i.key.id,a=o({highest:n===e,lowest:i.children.some(c=>c.type==="leaf"),attributes:{"data-slate-chunk":!0},children:b.createElement(u2,{root:e,ancestor:i,renderElement:r,renderChunk:o})});return b.createElement(b.Fragment,{key:s},a)}var l=i.node;return r(l,i.index,i.key)})},c2=Qb,u2=b.memo(Qb,(t,e)=>t.root===e.root&&t.renderElement===e.renderElement&&t.renderChunk===e.renderChunk&&!e.root.modifiedChunks.has(e.ancestor)),Zb=b.createContext(null),d2=()=>b.useContext(Zb),eC=t=>{var{decorations:e,node:n,renderElement:r,renderChunk:o,renderPlaceholder:i,renderText:s,renderLeaf:a}=t,l=lr();ji.set(l,!1);var c=I.isEditor(n),u=!c&&Ae.isElement(n)&&!l.isInline(n),d=u&&I.hasInlines(l,n),h=d?null:l.getChunkSize(n),p=!!h,{decorationsByChild:m,childrenToRedecorate:w}=f2(l,n,e);p||n.children.forEach((k,A)=>{Vi.set(k,A),ea.set(k,n)});var v=b.useCallback((k,A,C)=>{var E=C??pe.findKey(l,k);return b.createElement(Zb.Provider,{key:"provider-".concat(E.id),value:k},b.createElement(n2,{decorations:m[A],element:k,key:E.id,renderElement:r,renderChunk:o,renderPlaceholder:i,renderLeaf:a,renderText:s}))},[l,m,r,o,i,a,s]),y=(k,A)=>{var C=pe.findKey(l,k);return b.createElement(Kb,{decorations:m[A],key:C.id,isLast:A===n.children.length-1,parent:n,renderPlaceholder:i,renderLeaf:a,renderText:s,text:k})};if(!p)return n.children.map((k,A)=>Oe.isText(k)?y(k,A):v(k,A));var g=Rb(l,n,{reconcile:{chunkSize:h,rerenderChildren:w,onInsert:(k,A)=>{Vi.set(k,A),ea.set(k,n)},onUpdate:(k,A)=>{Vi.set(k,A),ea.set(k,n)},onIndexChange:(k,A)=>{Vi.set(k,A)}}});return b.createElement(c2,{root:g,ancestor:g,renderElement:v,renderChunk:o})},f2=(t,e,n)=>{var r=oP(t,e,n),o=b.useRef(r).current,i=[];o.length=r.length;for(var s=0;s<r.length;s++){var a,l=r[s],c=(a=o[s])!==null&&a!==void 0?a:null;dh(c,l)||(o[s]=l,i.push(s))}return{decorationsByChild:o,childrenToRedecorate:i}},tC=b.createContext(!1),h2=()=>b.useContext(tC),yc=b.createContext({}),p2=(t,e)=>t===e;function m2(t){var e=arguments.length>1&&arguments[1]!==void 0?arguments[1]:p2,{deferred:n}=arguments.length>2&&arguments[2]!==void 0?arguments[2]:{},r=b.useContext(yc);if(!r)throw new Error("The `useSlateSelector` hook must be used inside the <Slate> component's context.");var{addEventListener:o}=r,i=lr(),s=b.useCallback(()=>t(i),[i,t]),[a,l]=Vb(s,e);return Sr(()=>{var c=o(l,{deferred:n});return l(),c},[o,l,n]),a}function g2(){var t=b.useRef(new Set),e=b.useRef(new Set),n=b.useCallback(()=>{t.current.forEach(s=>s())},[]),r=b.useCallback(()=>{e.current.forEach(s=>s()),e.current.clear()},[]),o=b.useCallback(function(s){var{deferred:a=!1}=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{},l=a?()=>e.current.add(s):s;return t.current.add(l),()=>{t.current.delete(l)}},[]),i=b.useMemo(()=>({addEventListener:o,flushDeferred:r}),[o,r]);return{selectorContext:i,onChange:n}}function w2(){var{flushDeferred:t}=b.useContext(yc);Sr(t)}var v2=()=>{var{addEventListener:t}=b.useContext(yc),[,e]=b.useReducer(n=>n+1,0);if(!t)throw new Error("The `useSlate` hook must be used inside the <Slate> component's context.");return Sr(()=>t(e),[t]),lr()};function y2(){var t=lr(),e=b.useRef(!1),n=b.useRef(0),r=b.useCallback(()=>{if(!e.current){e.current=!0;var o=pe.getWindow(t);o.cancelAnimationFrame(n.current),n.current=o.requestAnimationFrame(()=>{e.current=!1})}},[t]);return b.useEffect(()=>()=>cancelAnimationFrame(n.current),[]),{receivedUserInput:e,onUserInput:r}}var b2=(t,e)=>{var n=[],r=()=>{n=[]},o=s=>{if(e.current){var a=s.filter(l=>eh(t,l,s));n.push(...a)}};function i(){n.length>0&&(n.reverse().forEach(s=>{s.type!=="characterData"&&(s.removedNodes.forEach(a=>{s.target.insertBefore(a,s.nextSibling)}),s.addedNodes.forEach(a=>{s.target.removeChild(a)}))}),r())}return{registerMutations:o,restoreDOM:i,clear:r}},C2={subtree:!0,childList:!0,characterData:!0,characterDataOldValue:!0};class nC extends b.Component{constructor(){super(...arguments),vt(this,"context",null),vt(this,"manager",null),vt(this,"mutationObserver",null)}observe(){var e,{node:n}=this.props;if(!n.current)throw new Error("Failed to attach MutationObserver, `node` is undefined");(e=this.mutationObserver)===null||e===void 0||e.observe(n.current,C2)}componentDidMount(){var{receivedUserInput:e}=this.props,n=this.context;this.manager=b2(n,e),this.mutationObserver=new MutationObserver(this.manager.registerMutations),this.observe()}getSnapshotBeforeUpdate(){var e,n,r,o=(e=this.mutationObserver)===null||e===void 0?void 0:e.takeRecords();if(o!=null&&o.length){var i;(i=this.manager)===null||i===void 0||i.registerMutations(o)}return(n=this.mutationObserver)===null||n===void 0||n.disconnect(),(r=this.manager)===null||r===void 0||r.restoreDOM(),null}componentDidUpdate(){var e;(e=this.manager)===null||e===void 0||e.clear(),this.observe()}componentWillUnmount(){var e;(e=this.mutationObserver)===null||e===void 0||e.disconnect()}render(){return this.props.children}}vt(nC,"contextType",gh);var k2=rn?nC:t=>{var{children:e}=t;return b.createElement(b.Fragment,null,e)},x2=b.createContext(!1),S2=["autoFocus","decorate","onDOMBeforeInput","placeholder","readOnly","renderElement","renderChunk","renderLeaf","renderText","renderPlaceholder","scrollSelectionIntoView","style","as","disableDefaultStyles"],E2=["text"];function rC(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(o){return Object.getOwnPropertyDescriptor(t,o).enumerable})),n.push.apply(n,r)}return n}function Er(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?rC(Object(n),!0).forEach(function(r){vt(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):rC(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}var D2=t=>b.createElement(b.Fragment,null,eC(t)),oC=b.forwardRef((t,e)=>{var n=b.useCallback(L=>b.createElement(A2,Er({},L)),[]),{autoFocus:r,decorate:o=O2,onDOMBeforeInput:i,placeholder:s,readOnly:a=!1,renderElement:l,renderChunk:c,renderLeaf:u,renderText:d,renderPlaceholder:h=n,scrollSelectionIntoView:p=T2,style:m={},as:w="div",disableDefaultStyles:v=!1}=t,y=wc(t,S2),g=v2(),[k,A]=b.useState(!1),C=b.useRef(null),E=b.useRef([]),[D,S]=b.useState(),_=b.useRef(!1),{onUserInput:O,receivedUserInput:B}=y2(),[,N]=b.useReducer(L=>L+1,0);ib.set(g,N),sh.set(g,a);var F=b.useMemo(()=>({isDraggingInternally:!1,isUpdatingSelection:!1,latestElement:null,hasMarkPlaceholder:!1}),[]);b.useEffect(()=>{C.current&&r&&C.current.focus()},[r]);var M=b.useRef(),T=b.useMemo(()=>vM(()=>{if(ji.get(g)){T();return}var L=pe.toDOMNode(g,g),q=L.getRootNode();if(!_.current&&Jo&&q instanceof ShadowRoot){_.current=!0;var J=NM();J?document.execCommand("indent"):ce.deselect(g),_.current=!1;return}var K=M.current;if((rn||!pe.isComposing(g))&&(!F.isUpdatingSelection||K!=null&&K.isFlushing())&&!F.isDraggingInternally){var re=pe.findDocumentOrShadowRoot(g),{activeElement:se}=re,he=pe.toDOMNode(g,g),Ce=Qs(re);if(se===he?(F.latestElement=se,po.set(g,!0)):po.delete(g),!Ce)return ce.deselect(g);var{anchorNode:Fe,focusNode:qe}=Ce,Le=pe.hasEditableTarget(g,Fe)||pe.isTargetInsideNonReadonlyVoid(g,Fe),de=pe.hasTarget(g,qe);if(Le&&de){var Te=pe.toSlateRange(g,Ce,{exactMatch:!1,suppressThrow:!0});Te&&(!pe.isComposing(g)&&!(K!=null&&K.hasPendingChanges())&&!(K!=null&&K.isFlushing())?ce.select(g,Te):K==null||K.handleUserSelect(Te))}a&&(!Le||!de)&&ce.deselect(g)}},100),[g,a,F]),P=b.useMemo(()=>mM(T,0),[T]);M.current=HP({node:C,onDOMSelectionChange:T,scheduleOnDOMSelectionChange:P}),Sr(()=>{var L,q,J;C.current&&(J=Qf(C.current))?(ob.set(g,J),ta.set(g,C.current),Ro.set(g,C.current),na.set(C.current,g)):Ro.delete(g);var{selection:K}=g,re=pe.findDocumentOrShadowRoot(g),se=Qs(re);if(!(!se||!pe.isFocused(g)||(L=M.current)!==null&&L!==void 0&&L.hasPendingAction())){var he=Le=>{var de=se.type!=="None";if(!(!K&&!de)){var Te=se.focusNode,_e;if(zi&&se.rangeCount>1){var tt=se.getRangeAt(0),cn=se.getRangeAt(se.rangeCount-1);tt.startContainer===Te?_e=cn.endContainer:_e=tt.startContainer}else _e=se.anchorNode;var Vn=ta.get(g),en=!1;if(Xo(Vn,_e)&&Xo(Vn,Te)&&(en=!0),de&&en&&K&&!Le){var At=pe.toSlateRange(g,se,{exactMatch:!0,suppressThrow:!0});if(At&&oe.equals(At,K)){var ht;if(!F.hasMarkPlaceholder||(ht=_e)!==null&&ht!==void 0&&(ht=ht.parentElement)!==null&&ht!==void 0&&ht.hasAttribute("data-slate-mark-placeholder"))return}}if(K&&!pe.hasRange(g,K)){g.selection=pe.toSlateRange(g,se,{exactMatch:!1,suppressThrow:!0});return}F.isUpdatingSelection=!0;var ot=null;try{ot=K&&pe.toDOMRange(g,K)}catch{}return ot?(pe.isComposing(g)&&!rn?se.collapseToEnd():oe.isBackward(K)?se.setBaseAndExtent(ot.endContainer,ot.endOffset,ot.startContainer,ot.startOffset):se.setBaseAndExtent(ot.startContainer,ot.startOffset,ot.endContainer,ot.endOffset),p(g,ot)):se.removeAllRanges(),ot}};se.rangeCount<=1&&he();var Ce=((q=M.current)===null||q===void 0?void 0:q.isFlushing())==="action";if(!rn||!Ce){setTimeout(()=>{F.isUpdatingSelection=!1});return}var Fe=null,qe=requestAnimationFrame(()=>{if(Ce){var Le=de=>{try{var Te=pe.toDOMNode(g,g);Te.focus(),he(de)}catch{}};Le(),Fe=setTimeout(()=>{Le(!0),F.isUpdatingSelection=!1})}});return()=>{cancelAnimationFrame(qe),Fe&&clearTimeout(Fe)}}});var $=b.useCallback(L=>{iC(g,L);var q=pe.toDOMNode(g,g),J=q.getRootNode();if(_!=null&&_.current&&Jo&&J instanceof ShadowRoot){var K=L.getTargetRanges(),re=K[0],se=new window.Range;se.setStart(re.startContainer,re.startOffset),se.setEnd(re.endContainer,re.endOffset);var he=pe.toSlateRange(g,se,{exactMatch:!1,suppressThrow:!1});ce.select(g,he),L.preventDefault(),L.stopImmediatePropagation();return}if(O(),!a&&pe.hasEditableTarget(g,L.target)&&!_2(L,i)){var Ce;if(M.current)return M.current.handleDOMBeforeInput(L);P.flush(),T.flush();var{selection:Fe}=g,{inputType:qe}=L,Le=L.dataTransfer||L.data||void 0,de=qe==="insertCompositionText"||qe==="deleteCompositionText";if(de&&pe.isComposing(g))return;var Te=!1;if(qe==="insertText"&&Fe&&oe.isCollapsed(Fe)&&L.data&&L.data.length===1&&/[a-z ]/i.test(L.data)&&Fe.anchor.offset!==0&&(Te=!0,g.marks&&(Te=!1),!ji.get(g))){var _e,tt,{anchor:cn}=Fe,[Vn,en]=pe.toDOMPoint(g,cn),At=(_e=Vn.parentElement)===null||_e===void 0?void 0:_e.closest("a"),ht=pe.getWindow(g);if(Te&&At&&pe.hasDOMNode(g,At)){var ot,lo=ht==null?void 0:ht.document.createTreeWalker(At,NodeFilter.SHOW_TEXT).lastChild();lo===Vn&&((ot=lo.textContent)===null||ot===void 0?void 0:ot.length)===en&&(Te=!1)}if(Te&&Vn.parentElement&&(ht==null||(tt=ht.getComputedStyle(Vn.parentElement))===null||tt===void 0?void 0:tt.whiteSpace)==="pre"){var Wn=I.above(g,{at:cn.path,match:Ms=>Ae.isElement(Ms)&&I.isBlock(g,Ms)});Wn&&ge.string(Wn[0]).includes(" ")&&(Te=!1)}}if((!qe.startsWith("delete")||qe.startsWith("deleteBy"))&&!ji.get(g)){var[bi]=L.getTargetRanges();if(bi){var Fs=pe.toSlateRange(g,bi,{exactMatch:!1,suppressThrow:!1});if(!Fe||!oe.equals(Fe,Fs)){Te=!1;var Is=!de&&g.selection&&I.rangeRef(g,g.selection);ce.select(g,Fs),Is&&ra.set(g,Is)}}}if(de)return;if(Te||L.preventDefault(),Fe&&oe.isExpanded(Fe)&&qe.startsWith("delete")){var Ci=qe.endsWith("Backward")?"backward":"forward";I.deleteFragment(g,{direction:Ci});return}switch(qe){case"deleteByComposition":case"deleteByCut":case"deleteByDrag":{I.deleteFragment(g);break}case"deleteContent":case"deleteContentForward":{I.deleteForward(g);break}case"deleteContentBackward":{I.deleteBackward(g);break}case"deleteEntireSoftLine":{I.deleteBackward(g,{unit:"line"}),I.deleteForward(g,{unit:"line"});break}case"deleteHardLineBackward":{I.deleteBackward(g,{unit:"block"});break}case"deleteSoftLineBackward":{I.deleteBackward(g,{unit:"line"});break}case"deleteHardLineForward":{I.deleteForward(g,{unit:"block"});break}case"deleteSoftLineForward":{I.deleteForward(g,{unit:"line"});break}case"deleteWordBackward":{I.deleteBackward(g,{unit:"word"});break}case"deleteWordForward":{I.deleteForward(g,{unit:"word"});break}case"insertLineBreak":I.insertSoftBreak(g);break;case"insertParagraph":{I.insertBreak(g);break}case"insertFromComposition":case"insertFromDrop":case"insertFromPaste":case"insertFromYank":case"insertReplacementText":case"insertText":{qe==="insertFromComposition"&&pe.isComposing(g)&&(A(!1),Qo.set(g,!1)),(Le==null?void 0:Le.constructor.name)==="DataTransfer"?pe.insertData(g,Le):typeof Le=="string"&&(Te?E.current.push(()=>I.insertText(g,Le)):I.insertText(g,Le));break}}var Wr=(Ce=ra.get(g))===null||Ce===void 0?void 0:Ce.unref();ra.delete(g),Wr&&(!g.selection||!oe.equals(g.selection,Wr))&&ce.select(g,Wr)}},[g,T,O,i,a,P]),W=b.useCallback(L=>{L==null?(T.cancel(),P.cancel(),ta.delete(g),Ro.delete(g),C.current&&ho&&C.current.removeEventListener("beforeinput",$)):ho&&L.addEventListener("beforeinput",$),C.current=L,typeof e=="function"?e(L):e&&(e.current=L)},[T,P,g,$,e]);Sr(()=>{var L=pe.getWindow(g),q=K=>{var{target:re}=K,se=re instanceof HTMLElement?re:null,he=se==null?void 0:se.tagName;he==="INPUT"||he==="TEXTAREA"||P()};L.document.addEventListener("selectionchange",q);var J=()=>{F.isDraggingInternally=!1};return L.document.addEventListener("dragend",J),L.document.addEventListener("drop",J),()=>{L.document.removeEventListener("selectionchange",q),L.document.removeEventListener("dragend",J),L.document.removeEventListener("drop",J)}},[P,F]);var V=o([g,[]]),X=JP(o),G=s&&g.children.length===1&&Array.from(ge.texts(g)).length===1&&ge.string(g)===""&&!k,te=b.useCallback(L=>{if(L&&G){var q;S((q=L.getBoundingClientRect())===null||q===void 0?void 0:q.height)}else S(void 0)},[G]);if(G){var H=I.start(g,[]);V.push({[Wi]:!0,placeholder:s,onPlaceholderResize:te,anchor:H,focus:H})}var{marks:j}=g;if(F.hasMarkPlaceholder=!1,g.selection&&oe.isCollapsed(g.selection)&&j){var{anchor:Y}=g.selection,ie=ge.leaf(g,Y.path),Q=wc(ie,E2);if(!Oe.equals(ie,j,{loose:!0})){F.hasMarkPlaceholder=!0;var le=Object.fromEntries(Object.keys(Q).map(L=>[L,null]));V.push(Er(Er(Er({[sb]:!0},le),j),{},{anchor:Y,focus:Y}))}}return b.useEffect(()=>{setTimeout(()=>{var{selection:L}=g;if(L){var{anchor:q}=L,J=ge.leaf(g,q.path);if(j&&!Oe.equals(J,j,{loose:!0})){ar.set(g,j);return}}ar.delete(g)})}),w2(),b.createElement(tC.Provider,{value:a},b.createElement(x2.Provider,{value:k},b.createElement(Wb.Provider,{value:X},b.createElement(k2,{node:C,receivedUserInput:B},b.createElement(w,Er(Er({role:a?void 0:"textbox","aria-multiline":a?void 0:!0,translate:"no"},y),{},{spellCheck:ho||!uc?y.spellCheck:!1,autoCorrect:ho||!uc?y.autoCorrect:"false",autoCapitalize:ho||!uc?y.autoCapitalize:"false","data-slate-editor":!0,"data-slate-node":"value",contentEditable:!a,zindex:-1,suppressContentEditableWarning:!0,ref:W,style:Er(Er({},v?{}:Er({position:"relative",whiteSpace:"pre-wrap",wordWrap:"break-word"},D?{minHeight:D}:{})),m),onBeforeInput:b.useCallback(L=>{if(!ho&&!a&&!mn(L,y.onBeforeInput)&&pe.hasSelectableTarget(g,L.target)&&(L.preventDefault(),!pe.isComposing(g))){var q=L.data;I.insertText(g,q)}},[y.onBeforeInput,g,a]),onInput:b.useCallback(L=>{if(!mn(L,y.onInput)){if(M.current){M.current.handleInput();return}for(var q of E.current)q();E.current=[],pe.isFocused(g)||iC(g,L.nativeEvent)}},[y.onInput,g]),onBlur:b.useCallback(L=>{if(!(a||F.isUpdatingSelection||!pe.hasSelectableTarget(g,L.target)||mn(L,y.onBlur))){var q=pe.findDocumentOrShadowRoot(g);if(F.latestElement!==q.activeElement){var{relatedTarget:J}=L,K=pe.toDOMNode(g,g);if(J!==K&&!(Gn(J)&&J.hasAttribute("data-slate-spacer"))){if(J!=null&&fo(J)&&pe.hasDOMNode(g,J)){var re=pe.toSlateNode(g,J);if(Ae.isElement(re)&&!g.isVoid(re))return}if(Jo){var se=Qs(q);se==null||se.removeAllRanges()}po.delete(g)}}}},[a,F.isUpdatingSelection,F.latestElement,g,y.onBlur]),onClick:b.useCallback(L=>{if(pe.hasTarget(g,L.target)&&!mn(L,y.onClick)&&fo(L.target)){var q=pe.toSlateNode(g,L.target),J=pe.findPath(g,q);if(!I.hasPath(g,J)||ge.get(g,J)!==q)return;if(L.detail===JM&&J.length>=1){var K=J;if(!(Ae.isElement(q)&&I.isBlock(g,q))){var re,se=I.above(g,{match:Te=>Ae.isElement(Te)&&I.isBlock(g,Te),at:J});K=(re=se==null?void 0:se[1])!==null&&re!==void 0?re:J.slice(0,1)}var he=I.range(g,K);ce.select(g,he);return}if(a)return;var Ce=I.start(g,J),Fe=I.end(g,J),qe=I.void(g,{at:Ce}),Le=I.void(g,{at:Fe});if(qe&&Le&&U.equals(qe[1],Le[1])){var de=I.range(g,Ce);ce.select(g,de)}}},[g,y.onClick,a]),onCompositionEnd:b.useCallback(L=>{if(!aa(L)&&pe.hasSelectableTarget(g,L.target)){var q;if(pe.isComposing(g)&&Promise.resolve().then(()=>{A(!1),Qo.set(g,!1)}),(q=M.current)===null||q===void 0||q.handleCompositionEnd(L),mn(L,y.onCompositionEnd)||rn)return;if(!Jo&&!PM&&!FM&&!$M&&!LM&&L.data){var J=ar.get(g);ar.delete(g),J!==void 0&&(Xr.set(g,g.marks),g.marks=J),I.insertText(g,L.data);var K=Xr.get(g);Xr.delete(g),K!==void 0&&(g.marks=K)}}},[y.onCompositionEnd,g]),onCompositionUpdate:b.useCallback(L=>{pe.hasSelectableTarget(g,L.target)&&!mn(L,y.onCompositionUpdate)&&!aa(L)&&(pe.isComposing(g)||(A(!0),Qo.set(g,!0)))},[y.onCompositionUpdate,g]),onCompositionStart:b.useCallback(L=>{if(!aa(L)&&pe.hasSelectableTarget(g,L.target)){var q;if((q=M.current)===null||q===void 0||q.handleCompositionStart(L),mn(L,y.onCompositionStart)||rn)return;A(!0);var{selection:J}=g;if(J&&oe.isExpanded(J)){I.deleteFragment(g);return}}},[y.onCompositionStart,g]),onCopy:b.useCallback(L=>{pe.hasSelectableTarget(g,L.target)&&!mn(L,y.onCopy)&&!aa(L)&&(L.preventDefault(),pe.setFragmentData(g,L.clipboardData,"copy"))},[y.onCopy,g]),onCut:b.useCallback(L=>{if(!a&&pe.hasSelectableTarget(g,L.target)&&!mn(L,y.onCut)&&!aa(L)){L.preventDefault(),pe.setFragmentData(g,L.clipboardData,"cut");var{selection:q}=g;if(q)if(oe.isExpanded(q))I.deleteFragment(g);else{var J=ge.parent(g,q.anchor.path);I.isVoid(g,J)&&ce.delete(g)}}},[a,g,y.onCut]),onDragOver:b.useCallback(L=>{if(pe.hasTarget(g,L.target)&&!mn(L,y.onDragOver)){var q=pe.toSlateNode(g,L.target);Ae.isElement(q)&&I.isVoid(g,q)&&L.preventDefault()}},[y.onDragOver,g]),onDragStart:b.useCallback(L=>{if(!a&&pe.hasTarget(g,L.target)&&!mn(L,y.onDragStart)){var q=pe.toSlateNode(g,L.target),J=pe.findPath(g,q),K=Ae.isElement(q)&&I.isVoid(g,q)||I.void(g,{at:J,voids:!0});if(K){var re=I.range(g,J);ce.select(g,re)}F.isDraggingInternally=!0,pe.setFragmentData(g,L.dataTransfer,"drag")}},[a,g,y.onDragStart,F]),onDrop:b.useCallback(L=>{if(!a&&pe.hasTarget(g,L.target)&&!mn(L,y.onDrop)){L.preventDefault();var q=g.selection,J=pe.findEventRange(g,L),K=L.dataTransfer;ce.select(g,J),F.isDraggingInternally&&q&&!oe.equals(q,J)&&!I.void(g,{at:J,voids:!0})&&ce.delete(g,{at:q}),pe.insertData(g,K),pe.isFocused(g)||pe.focus(g)}},[a,g,y.onDrop,F]),onDragEnd:b.useCallback(L=>{!a&&F.isDraggingInternally&&y.onDragEnd&&pe.hasTarget(g,L.target)&&y.onDragEnd(L)},[a,F,y,g]),onFocus:b.useCallback(L=>{if(!a&&!F.isUpdatingSelection&&pe.hasEditableTarget(g,L.target)&&!mn(L,y.onFocus)){var q=pe.toDOMNode(g,g),J=pe.findDocumentOrShadowRoot(g);if(F.latestElement=J.activeElement,zi&&L.target!==q){q.focus();return}po.set(g,!0)}},[a,F,g,y.onFocus]),onKeyDown:b.useCallback(L=>{if(!a&&pe.hasEditableTarget(g,L.target)){var q;(q=M.current)===null||q===void 0||q.handleKeyDown(L);var{nativeEvent:J}=L;if(pe.isComposing(g)&&J.isComposing===!1&&(Qo.set(g,!1),A(!1)),mn(L,y.onKeyDown)||pe.isComposing(g))return;var{selection:K}=g,re=g.children[K!==null?K.focus.path[0]:0],se=Dy(ge.string(re))==="rtl";if(kt.isRedo(J)){L.preventDefault();var he=g;typeof he.redo=="function"&&he.redo();return}if(kt.isUndo(J)){L.preventDefault();var Ce=g;typeof Ce.undo=="function"&&Ce.undo();return}if(kt.isMoveLineBackward(J)){L.preventDefault(),ce.move(g,{unit:"line",reverse:!0});return}if(kt.isMoveLineForward(J)){L.preventDefault(),ce.move(g,{unit:"line"});return}if(kt.isExtendLineBackward(J)){L.preventDefault(),ce.move(g,{unit:"line",edge:"focus",reverse:!0});return}if(kt.isExtendLineForward(J)){L.preventDefault(),ce.move(g,{unit:"line",edge:"focus"});return}if(kt.isMoveBackward(J)){L.preventDefault(),K&&oe.isCollapsed(K)?ce.move(g,{reverse:!se}):ce.collapse(g,{edge:se?"end":"start"});return}if(kt.isMoveForward(J)){L.preventDefault(),K&&oe.isCollapsed(K)?ce.move(g,{reverse:se}):ce.collapse(g,{edge:se?"start":"end"});return}if(kt.isMoveWordBackward(J)){L.preventDefault(),K&&oe.isExpanded(K)&&ce.collapse(g,{edge:"focus"}),ce.move(g,{unit:"word",reverse:!se});return}if(kt.isMoveWordForward(J)){L.preventDefault(),K&&oe.isExpanded(K)&&ce.collapse(g,{edge:"focus"}),ce.move(g,{unit:"word",reverse:se});return}if(ho){if((rh||Jo)&&K&&(kt.isDeleteBackward(J)||kt.isDeleteForward(J))&&oe.isCollapsed(K)){var Fe=ge.parent(g,K.anchor.path);if(Ae.isElement(Fe)&&I.isVoid(g,Fe)&&(I.isInline(g,Fe)||I.isBlock(g,Fe))){L.preventDefault(),I.deleteBackward(g,{unit:"block"});return}}}else{if(kt.isBold(J)||kt.isItalic(J)||kt.isTransposeCharacter(J)){L.preventDefault();return}if(kt.isSoftBreak(J)){L.preventDefault(),I.insertSoftBreak(g);return}if(kt.isSplitBlock(J)){L.preventDefault(),I.insertBreak(g);return}if(kt.isDeleteBackward(J)){L.preventDefault(),K&&oe.isExpanded(K)?I.deleteFragment(g,{direction:"backward"}):I.deleteBackward(g);return}if(kt.isDeleteForward(J)){L.preventDefault(),K&&oe.isExpanded(K)?I.deleteFragment(g,{direction:"forward"}):I.deleteForward(g);return}if(kt.isDeleteLineBackward(J)){L.preventDefault(),K&&oe.isExpanded(K)?I.deleteFragment(g,{direction:"backward"}):I.deleteBackward(g,{unit:"line"});return}if(kt.isDeleteLineForward(J)){L.preventDefault(),K&&oe.isExpanded(K)?I.deleteFragment(g,{direction:"forward"}):I.deleteForward(g,{unit:"line"});return}if(kt.isDeleteWordBackward(J)){L.preventDefault(),K&&oe.isExpanded(K)?I.deleteFragment(g,{direction:"backward"}):I.deleteBackward(g,{unit:"word"});return}if(kt.isDeleteWordForward(J)){L.preventDefault(),K&&oe.isExpanded(K)?I.deleteFragment(g,{direction:"forward"}):I.deleteForward(g,{unit:"word"});return}}}},[a,g,y.onKeyDown]),onPaste:b.useCallback(L=>{!a&&pe.hasEditableTarget(g,L.target)&&!mn(L,y.onPaste)&&(!ho||EM(L.nativeEvent)||Jo)&&(L.preventDefault(),pe.insertData(g,L.clipboardData))},[a,g,y.onPaste])}),b.createElement(D2,{decorations:V,node:g,renderElement:l,renderChunk:c,renderPlaceholder:h,renderLeaf:u,renderText:d}))))))}),A2=t=>{var{attributes:e,children:n}=t;return b.createElement("span",Er({},e),n,rn&&b.createElement("br",null))},O2=()=>[],T2=(t,e)=>{var n=!!t.selection&&oe.isBackward(t.selection),r=e.cloneRange();if(r.collapse(n),r.getBoundingClientRect){var o=r.startContainer.parentElement,i=r.getBoundingClientRect(),s=i.width===0&&i.height===0&&i.x===0&&i.y===0;if(s){var a=o.getBoundingClientRect(),l=a.width>0||a.height>0;if(l)return}o.getBoundingClientRect=r.getBoundingClientRect.bind(r),CM(o,{scrollMode:"if-needed"}),delete o.getBoundingClientRect}},mn=(t,e)=>{if(!e)return!1;var n=e(t);return n??(t.isDefaultPrevented()||t.isPropagationStopped())},aa=t=>fo(t.target)&&(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement),_2=(t,e)=>{if(!e)return!1;var n=e(t);return n??t.defaultPrevented},iC=(t,e)=>{var n=t;if(e.inputType==="historyUndo"&&typeof n.undo=="function"){n.undo();return}if(e.inputType==="historyRedo"&&typeof n.redo=="function"){n.redo();return}},sC=b.createContext(!1),N2=()=>b.useContext(sC),aC=parseInt(b.version.split(".")[0],10),B2=["editor","children","onChange","onSelectionChange","onValueChange","initialValue"],lC=t=>{var{editor:e,children:n,onChange:r,onSelectionChange:o,onValueChange:i,initialValue:s}=t,a=wc(t,B2);b.useState(()=>{if(!ge.isNodeList(s))throw new Error("[Slate] initialValue is invalid! Expected a list of elements but got: ".concat($t.stringify(s)));if(!I.isEditor(e))throw new Error("[Slate] editor is invalid! You passed: ".concat($t.stringify(e)));e.children=s,Object.assign(e,a)});var{selectorContext:l,onChange:c}=g2(),u=b.useCallback(()=>{r&&r(e.children),o&&e.operations.find(p=>p.type==="set_selection")&&o(e.selection),i&&e.operations.find(p=>p.type!=="set_selection")&&i(e.children),c()},[e,c,r,o,i]);b.useEffect(()=>(ah.set(e,u),()=>{ah.set(e,()=>{})}),[e,u]);var[d,h]=b.useState(pe.isFocused(e));return b.useEffect(()=>{h(pe.isFocused(e))},[e]),Sr(()=>{var p=()=>h(pe.isFocused(e));return aC>=17?(document.addEventListener("focusin",p),document.addEventListener("focusout",p),()=>{document.removeEventListener("focusin",p),document.removeEventListener("focusout",p)}):(document.addEventListener("focus",p,!0),document.addEventListener("blur",p,!0),()=>{document.removeEventListener("focus",p,!0),document.removeEventListener("blur",p,!0)})},[]),b.createElement(yc.Provider,{value:l},b.createElement(gh.Provider,{value:e},b.createElement(sC.Provider,{value:d},n)))},F2=()=>{var t=d2();if(!t)return!1;var e=b.useCallback(n=>{if(!n.selection)return!1;var r=pe.findPath(n,t),o=I.range(n,r);return!!oe.intersection(o,n.selection)},[t]);return m2(e,void 0,{deferred:!0})},cC=function(e){var n=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"x-slate-fragment",r=e;r=XM(r,n);var{onChange:o,apply:i,insertText:s}=r;return r.getChunkSize=()=>null,rn&&(r.insertText=(a,l)=>(Jr.delete(r),s(a,l))),r.onChange=a=>{var l=aC<18?Lo.unstable_batchedUpdates:c=>c();l(()=>{o(a)})},r.apply=a=>{if(a.type==="move_node"){var l=ge.parent(r,a.path),c=!!r.getChunkSize(l);if(c){var u=ge.get(r,a.path),d=Rb(r,l),h=pe.findKey(r,u);d.movedNodeKeys.add(h)}}i(a)},r};const uC=mt.createContext(null),I2=()=>{const t=mt.useContext(uC);if(!t)throw new Error("useSlateEditor must be used within SlateEditorContext");return t},M2=t=>{const{attributes:e,children:n,element:r,...o}=t;return Li(r)?f.jsx(P2,{attributes:e,element:r,...o,children:n}):f.jsx("p",{...e,children:n})},P2=t=>{const{attributes:e,element:n,children:r,onVariableClick:o,validateVariable:i,renderVariableTag:s,renderVariableTooltip:a,showRemoveButton:l=!0,disabled:c,readOnly:u}=t,[d,h]=mt.useState(!0),p=I2(),m=n.value.replace(/^\{\{|\}\}$/g,"");b.useEffect(()=>{if(i){const k=i(m);k instanceof Promise?k.then(h).catch(()=>h(!1)):h(k)}},[m,i]);const w=k=>{k.preventDefault(),k.stopPropagation(),!(c||u)&&(o==null||o(n.value))},v=k=>{if(k.preventDefault(),k.stopPropagation(),!(c||u))try{const A=pe.findPath(p,n);ce.removeNodes(p,{at:A})}catch{}},y=s?s(n.value,d):m,g=a?a(n.value):n.value;return f.jsxs("span",{...e,children:[f.jsxs("button",{contentEditable:!1,className:`variable-tag ${d?"valid":"invalid"}`,disabled:c||u,onClick:w,style:{userSelect:"none"},type:"button",children:[f.jsx(x.Tooltip,{title:g,children:f.jsx("span",{className:"variable-tag-content",children:y})}),l&&!c&&!u&&f.jsx(Z.CloseCircleFilled,{className:"variable-tag-remove",onClick:v})]}),f.jsx("span",{style:{fontSize:0,lineHeight:0,width:0,height:0,display:"inline-block"},children:r})]})},L2=({attributes:t,children:e})=>f.jsx("span",{...t,children:e}),$2=t=>{const{isInline:e,isVoid:n,deleteBackward:r,deleteForward:o}=t;return t.isInline=i=>Li(i)?!0:e(i),t.isVoid=i=>Li(i)?!0:n(i),t.deleteBackward=i=>{const{selection:s}=t;if(s&&oe.isCollapsed(s)){const[a]=I.nodes(t,{match:l=>!I.isEditor(l)&&Ae.isElement(l)&&Li(l)});if(a){const[,l]=a,c=I.before(t,s);if(c){const[u]=I.node(t,c);if(Ae.isElement(u)&&Li(u)){ce.removeNodes(t,{at:l});return}}}}r(i)},t.deleteForward=i=>{const{selection:s}=t;if(s&&oe.isCollapsed(s)){const a=I.after(t,s);if(a){const[l,c]=I.node(t,a);if(Ae.isElement(l)&&Li(l)){ce.removeNodes(t,{at:c});return}}}o(i)},t},bc=({value:t="",onChange:e,placeholder:n,disabled:r=!1,readOnly:o=!1,multiline:i=!1,minRows:s=1,maxRows:a,className:l,style:c,capturePattern:u=z0,onVariableClick:d,validateVariable:h,renderVariableTag:p,renderVariableTooltip:m,showRemoveButton:w=!0,onFocus:v,onBlur:y})=>{const g=typeof t=="string"?t:"",k=b.useId(),A=b.useRef(null),C=b.useRef(!1),E=b.useRef(g),D=b.useMemo(()=>(A.current||(A.current=$2(ZI(cC(xy())))),A.current),[]),S=b.useMemo(()=>Df(g,u),[]),_=b.useCallback((V,X)=>{const te={type:"variable-tag",value:V.startsWith("{{")?V:`{{${V}}}`,children:[{text:""}]};try{pe.focus(D)}catch{}ce.insertNodes(D,te),ce.move(D,{distance:1,unit:"offset"});const H=Af(D.children);e==null||e(H)},[D,e]),O=b.useCallback(()=>{try{pe.focus(D)}catch{}},[D]),B=B0(k,_,O),N=b.useCallback(V=>{const X=Af(V);X!==E.current&&(E.current=X,e==null||e(X))},[e]),F=b.useCallback(V=>{!i&&V.key==="Enter"&&V.preventDefault()},[i]),M=b.useCallback(()=>{B.activate(),v==null||v()},[B,v]),T=b.useCallback(()=>{y==null||y()},[y]);b.useEffect(()=>{if(!C.current){C.current=!0;return}const V=Af(D.children);if(!(g===V||g===E.current)){E.current=g;try{ce.select(D,{anchor:I.start(D,[]),focus:I.end(D,[])}),ce.delete(D);const X=Df(g,u);ce.insertNodes(D,X,{at:[0]});const G=D.children;if(G.length>1&&G[0].type==="paragraph"){const te=G[0];te.children.length===1&&"text"in te.children[0]&&te.children[0].text===""&&ce.removeNodes(D,{at:[0]})}}catch{D.children=Df(g,u),D.onChange()}}},[g,u,D]);const P=b.useCallback(V=>f.jsx(M2,{...V,onVariableClick:d,validateVariable:h,renderVariableTag:p,renderVariableTooltip:m,showRemoveButton:w,disabled:r,readOnly:o}),[d,h,p,m,w,r,o]),$=b.useCallback(V=>f.jsx(L2,{...V}),[]),W={...c,minHeight:i?`${s*24}px`:void 0,maxHeight:i&&a?`${a*24}px`:void 0,overflowY:i?"auto":void 0};return f.jsx(uC.Provider,{value:D,children:f.jsx("div",{className:`variable-input-wrapper ${r?"disabled":""} ${o?"readonly":""} ${i?"multiline":""} ${l||""}`,style:W,children:f.jsx(lC,{editor:D,initialValue:S,onChange:N,children:f.jsx(oC,{className:"variable-input-editable",renderElement:P,renderLeaf:$,placeholder:n,readOnly:r||o,onKeyDown:F,onFocus:M,onBlur:T})})})})},dC=({rows:t=4,autoSize:e,minRows:n,maxRows:r,...o})=>{const i=typeof e=="object"?e.minRows:n??t,s=typeof e=="object"?e.maxRows:r;return f.jsx(bc,{...o,multiline:!0,minRows:i,maxRows:s})},Cc={normal:{label:"文本",icon:f.jsx(Z.FontSizeOutlined,{}),description:"普通文本输入"},expression:{label:"表达式",icon:f.jsx(Z.FunctionOutlined,{}),description:"支持变量引用的表达式模式"},code:{label:"代码",icon:f.jsx(Z.CodeOutlined,{}),description:"JavaScript 代码模式"}},la=({value:t="",onChange:e,availableModes:n=["normal","expression"],defaultMode:r="normal",mode:o,onModeChange:i,disabled:s=!1,readOnly:a=!1,placeholder:l,multiline:c=!1,rows:u=4,validateVariable:d,renderVariableTag:h,renderVariableTooltip:p,renderNormalMode:m,children:w,hideModeSwitch:v=!1,modeSwitchPosition:y="top-left",compact:g=!1})=>{const k=()=>t&&typeof t=="string"&&/\{\{.*\}\}/.test(t)?"expression":r,[A,C]=b.useState(k),E=o??A;b.useEffect(()=>{o!==void 0&&C(o)},[o]);const D=b.useCallback(N=>{C(N),i==null||i(N)},[i]),S=b.useCallback(N=>{e==null||e(N)},[e]),_=b.useMemo(()=>n.filter(N=>Cc[N]),[n]),O=()=>v||_.length<=1?null:f.jsx("div",{className:`value-mode-switch ${y}`,children:f.jsx(x.Radio.Group,{value:E,onChange:N=>D(N.target.value),size:"small",disabled:s||a,optionType:"button",buttonStyle:"solid",children:_.map(N=>f.jsxs(x.Radio.Button,{value:N,title:Cc[N].description,children:[Cc[N].icon,f.jsx("span",{className:"mode-label",children:Cc[N].label})]},N))})}),B=()=>{switch(E){case"normal":return w?mt.cloneElement(w,{value:t,onChange:S,disabled:s,readOnly:a}):m?m({value:t,onChange:S,disabled:s,readOnly:a,placeholder:l}):c?f.jsx(x.Input.TextArea,{value:t,onChange:N=>S(N.target.value),disabled:s,readOnly:a,placeholder:l,rows:u}):f.jsx(x.Input,{value:t,onChange:N=>S(N.target.value),disabled:s,readOnly:a,placeholder:l});case"expression":return c?f.jsx(dC,{value:t,onChange:S,disabled:s,readOnly:a,placeholder:l||"输入文本或使用 {{变量}}",rows:u,validateVariable:d,renderVariableTag:h,renderVariableTooltip:p}):f.jsx(bc,{value:t,onChange:S,disabled:s,readOnly:a,placeholder:l||"输入文本或使用 {{变量}}",validateVariable:d,renderVariableTag:h,renderVariableTooltip:p});case"code":return f.jsx(x.Input.TextArea,{value:t,onChange:N=>S(N.target.value),disabled:s,readOnly:a,placeholder:l||"// 输入 JavaScript 代码",rows:u,className:"code-mode-textarea",style:{fontFamily:"monospace"}});default:return null}};return f.jsxs("div",{className:`value-mode-wrapper${g?" compact":""}`,children:[O(),f.jsx("div",{className:"value-mode-content",children:B()})]})};function pt(t,e={}){const n={needsFormItemName:!0,supportsVariableInsert:!1,supportsAiFillable:!1,...e};if(n.supportsVariableInsert&&n.supportsAiFillable)return{component:t,meta:n};const r=o=>{const{field:i,disabled:s,readOnly:a,context:l,value:c,onChange:u}=o,d=n.valuePropName?o[n.valuePropName]??c:c;let h=f.jsx(t,{...o,value:d});return i.variableInsert&&!n.supportsVariableInsert&&(h=f.jsx(la,{availableModes:["normal","expression"],defaultMode:"normal",disabled:s,readOnly:a,placeholder:i.placeholder,validateVariable:l.validateVariable,renderVariableTag:l.renderVariableTag,renderVariableTooltip:l.renderVariableTooltip,modeSwitchPosition:"top-right",value:d,onChange:u,children:h})),i.aiFillable&&!n.supportsAiFillable&&(h=f.jsx(H0,{aiFillable:!0,disabled:s,children:h})),h};return r.displayName=`FieldComponent(${t.displayName||t.name||"Anonymous"})`,{component:r,meta:n}}function go(t,e={}){return{component:t,meta:e}}const fC=({children:t})=>f.jsx(x.Button,{disabled:!0,style:{pointerEvents:"none"},children:t}),hC=({field:t,disabled:e,value:n,onChange:r,id:o})=>{const i=t.showThousandsSeparator?l=>`${l}`.replace(/\B(?=(\d{3})+(?!\d))/g,","):void 0,s=t.showThousandsSeparator?l=>l==null?void 0:l.replace(/\$\s?|(,*)/g,""):void 0,a=f.jsx(x.InputNumber,{disabled:e,placeholder:t.placeholder,min:t.min,max:t.max,step:t.step,precision:t.precision,controls:t.controls,formatter:i,parser:s,style:{width:"100%"},value:n,onChange:r,id:o});return!t.addonBefore&&!t.addonAfter?a:f.jsxs(x.Space.Compact,{style:{width:"100%"},children:[t.addonBefore?f.jsx(fC,{children:t.addonBefore}):null,a,t.addonAfter?f.jsx(fC,{children:t.addonAfter}):null]})};hC.displayName="NumberFieldControl";const H2=pt(hC,{needsFormItemName:!0}),pC=({field:t,disabled:e,readOnly:n,value:r,onChange:o,id:i})=>f.jsx(x.Input.Password,{disabled:e,readOnly:n,placeholder:t.placeholder,value:r,onChange:s=>o==null?void 0:o(s.target.value),id:i});pC.displayName="PasswordFieldControl";const z2=pt(pC,{needsFormItemName:!0}),mC=({field:t,disabled:e,readOnly:n,context:r,value:o,onChange:i,id:s})=>{const a=t.autoSize??(t.minRows||t.maxRows?{minRows:t.minRows,maxRows:t.maxRows}:void 0),l=t.minRows||4;if(t.variableInsert)return f.jsx(la,{availableModes:["normal","expression"],defaultMode:"normal",disabled:e,readOnly:n,placeholder:t.placeholder,multiline:!0,rows:l,validateVariable:r.validateVariable,renderVariableTag:r.renderVariableTag,renderVariableTooltip:r.renderVariableTooltip,modeSwitchPosition:"top-right",value:o,onChange:i,children:f.jsx(x.Input.TextArea,{placeholder:t.placeholder,rows:l,autoSize:a,showCount:t.showCount,maxLength:t.maxLength})});const c=()=>{var d;(d=r.eventHandlers)==null||d.onBlur(t.name)},u=()=>{var d;(d=r.eventHandlers)==null||d.onFocus(t.name)};return f.jsx(x.Input.TextArea,{disabled:e,readOnly:n,placeholder:t.placeholder,rows:l,autoSize:a,showCount:t.showCount,maxLength:t.maxLength,value:o,onChange:d=>i==null?void 0:i(d.target.value),onBlur:c,onFocus:u,id:s})};mC.displayName="TextareaFieldControl";const j2=pt(mC,{supportsVariableInsert:!0,needsFormItemName:!0}),gC=({field:t,disabled:e,readOnly:n,value:r,onChange:o,id:i,context:s})=>{const a=()=>{var c;(c=s.eventHandlers)==null||c.onBlur(t.name)},l=()=>{var c;(c=s.eventHandlers)==null||c.onFocus(t.name)};return f.jsx(x.Input,{disabled:e,readOnly:n,placeholder:t.placeholder,value:r,onChange:c=>o==null?void 0:o(c.target.value),onBlur:a,onFocus:l,id:i})};gC.displayName="TextFieldControl";const V2=pt(gC,{supportsVariableInsert:!1,needsFormItemName:!0}),wC=({field:t,disabled:e,context:n})=>{const r=Ql(),{renderVariableTag:o,renderVariableTooltip:i,validateVariable:s,values:a,optionsLoader:l}=n,c=W2(t),u=r.get(t.itemSchema.type),d=u==null?void 0:u.component;return f.jsx(x.Form.List,{name:t.name,rules:c,children:(h,{add:p,remove:m},{errors:w})=>f.jsxs(x.Space,{direction:"vertical",style:{width:"100%"},children:[h.map((v,y)=>f.jsxs(x.Card,{size:"small",title:t.itemLabel||`Item ${y+1}`,children:[f.jsx(x.Form.Item,{name:[v.name,t.itemSchema.name],label:t.itemSchema.label,rules:Mi(t.itemSchema.rules||[],a,t.itemSchema.type),children:d&&f.jsx(d,{field:t.itemSchema,disabled:e,readOnly:!1,context:{values:a,optionsLoader:l,renderVariableTag:o,renderVariableTooltip:i,validateVariable:s}})}),f.jsxs("div",{style:{textAlign:"right"},children:[f.jsx(x.Button,{type:"link",danger:!0,onClick:()=>m(v.name),disabled:e||t.minItems!==void 0&&h.length<=t.minItems,children:"移除"}),t.allowCopy&&f.jsx(x.Button,{type:"link",onClick:()=>{const g=qn(a,`${t.name}.${v.name}`);p(g,y+1)},disabled:e,children:"复制"})]})]},v.key)),f.jsx(x.Button,{type:"dashed",block:!0,onClick:()=>p(t.itemSchema.defaultValue),disabled:e||t.maxItems!==void 0&&h.length>=t.maxItems,children:"添加"}),f.jsx(x.Form.ErrorList,{errors:w})]})})};wC.displayName="ArrayFieldControl";function W2(t){var n;const e=[];if((n=t.rules)!=null&&n.some(r=>r.type==="required")){const r=t.rules.find(o=>o.type==="required");e.push({validator:async(o,i)=>{if(!i||i.length===0)throw new Error((r==null?void 0:r.message)||"此项为必填")}})}return t.minItems!==void 0&&e.push({validator:async(r,o)=>{if(!o||o.length<t.minItems)throw new Error(`至少需要 ${t.minItems} 项`)}}),t.maxItems!==void 0&&e.push({validator:async(r,o)=>{if(o&&o.length>t.maxItems)throw new Error(`最多允许 ${t.maxItems} 项`)}}),e}const U2=go(wC,{isComplexField:!0,needsFormItemName:!1}),vC=({field:t,disabled:e,context:n})=>{const r=Ql(),o=x.Form.useFormInstance(),{renderVariableTag:i,renderVariableTooltip:s,validateVariable:a,values:l,optionsLoader:c}=n,u=t,d=G2(u),h=u.__arrayObjectDepth??0,p=u.__arrayObjectLevelBackgroundColors??t.levelBackgroundColors,m=eL(t,h,p),w=rL(t);return f.jsx(x.Form.List,{name:u.name,rules:w,children:(v,{add:y,remove:g,move:k},{errors:A})=>f.jsxs(x.Space,{direction:"vertical",style:{width:"100%"},children:[v.map((C,E)=>f.jsx(x.Card,{size:"small",style:tL(m),bodyStyle:nL(m),title:f.jsx(yC,{field:t,index:E,titlePath:K2(t,d,C.name),disabled:e}),extra:f.jsxs(x.Space,{children:[t.allowCopy&&f.jsx(x.Tooltip,{title:"复制",children:f.jsx(x.Button,{"aria-label":"复制",type:"text",size:"small",icon:f.jsx(Z.CopyOutlined,{}),onClick:()=>{const D=[...d,C.name],S=o.getFieldValue(D)??CC(l,D);y(S,E+1)},disabled:e||t.maxItems!==void 0&&v.length>=t.maxItems})}),f.jsx(x.Tooltip,{title:"置顶",children:f.jsx(x.Button,{"aria-label":"置顶",type:"text",size:"small",icon:f.jsx(Z.VerticalAlignTopOutlined,{}),disabled:e||E===0,onClick:()=>k(E,0)})}),f.jsx(x.Tooltip,{title:"向上",children:f.jsx(x.Button,{"aria-label":"向上",type:"text",size:"small",icon:f.jsx(Z.ArrowUpOutlined,{}),disabled:e||E===0,onClick:()=>k(E,E-1)})}),f.jsx(x.Tooltip,{title:"向下",children:f.jsx(x.Button,{"aria-label":"向下",type:"text",size:"small",icon:f.jsx(Z.ArrowDownOutlined,{}),disabled:e||E===v.length-1,onClick:()=>k(E,E+1)})}),f.jsx(x.Tooltip,{title:"置底",children:f.jsx(x.Button,{"aria-label":"置底",type:"text",size:"small",icon:f.jsx(Z.VerticalAlignBottomOutlined,{}),disabled:e||E===v.length-1,onClick:()=>k(E,v.length-1)})}),f.jsx(x.Tooltip,{title:"删除",children:f.jsx(x.Button,{"aria-label":"删除",type:"text",size:"small",danger:!0,icon:f.jsx(Z.DeleteOutlined,{}),onClick:()=>g(C.name),disabled:e||t.minItems!==void 0&&v.length<=t.minItems})})]}),children:f.jsx("div",{style:Q2(t),children:t.columns.map(D=>{const S=r.get(D.type),_=S==null?void 0:S.component,O=[C.name,D.name],B=[...d,C.name,D.name];return f.jsx(x.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const N=o.getFieldValue([...d,C.name])??CC(l,[...d,C.name])??{};return Ys(D,N)?S!=null&&S.meta.isComplexField?f.jsx(x.Form.Item,{label:D.label,tooltip:D.tooltip,extra:D.helpText||D.extra||D.description,children:_&&f.jsx(_,{field:q2(D,O,B,h+1,p),disabled:e,readOnly:!1,context:{values:l,optionsLoader:c,renderVariableTag:i,renderVariableTooltip:s,validateVariable:a}})}):f.jsx(x.Form.Item,{name:O,label:D.label,tooltip:D.tooltip,extra:D.helpText||D.extra||D.description,rules:Mi(D.rules||[],N,D.type),preserve:D.visibleWhen?!1:void 0,children:_&&f.jsx(_,{field:D,disabled:e,readOnly:!1,context:{values:l,optionsLoader:c,renderVariableTag:i,renderVariableTooltip:s,validateVariable:a}})}):null}},D.name)})})},C.key)),f.jsx(x.Button,{type:"dashed",block:!0,icon:f.jsx(Z.PlusOutlined,{}),onClick:()=>y(),disabled:e||t.maxItems!==void 0&&v.length>=t.maxItems,children:R2(t)}),f.jsx(x.Form.ErrorList,{errors:A})]})})};vC.displayName="ArrayObjectFieldControl";const yC=({field:t,index:e,titlePath:n,disabled:r})=>{const o=x.Form.useFormInstance(),i=x.Form.useWatch(n,o),[s,a]=mt.useState(!1),[l,c]=mt.useState(""),u=J2(t,e),d=X2(i,u),h=()=>{c(d),a(!0)},p=()=>{c(""),a(!1)},m=()=>{if(n){const w=l.trim()||void 0;o.setFieldValue(n,w)}a(!1),c("")};return n?s?f.jsxs(x.Space,{children:[f.jsx(x.Input,{size:"small",value:l,onChange:w=>c(w.target.value),onPressEnter:m,style:{width:200},placeholder:"请输入标题"}),f.jsx(x.Button,{"aria-label":"保存标题",type:"text",size:"small",icon:f.jsx(Z.CheckOutlined,{style:{color:"#52c41a"}}),onClick:m}),f.jsx(x.Button,{"aria-label":"取消标题编辑",type:"text",size:"small",icon:f.jsx(Z.CloseOutlined,{}),onClick:p})]}):f.jsxs(x.Space,{children:[f.jsx("span",{children:d}),f.jsx(x.Button,{"aria-label":"编辑标题",type:"text",size:"small",icon:f.jsx(Z.EditOutlined,{}),disabled:r,onClick:h})]}):f.jsx("span",{children:d})};yC.displayName="ArrayObjectRowTitle";function q2(t,e,n,r,o){return{...t,name:e,__arrayObjectRootNamePath:n,__arrayObjectDepth:r,__arrayObjectLevelBackgroundColors:o}}function bC(t){return Array.isArray(t)?t:[t]}function G2(t){return t.__arrayObjectRootNamePath??bC(t.name)}function CC(t,e){return qn(t,bC(e).join("."))}function K2(t,e,n){const r=Y2(t);return r?[...e,n,r]:void 0}function Y2(t){return t.titleFieldName?t.titleFieldName:t.titleEditable?"title":void 0}function X2(t,e){return typeof t=="string"&&t.trim()?t:e}function J2(t,e){return t.label?`${t.label} #${e+1}`:`Item ${e+1}`}function R2(t){return t.label?`添加${t.label}`:"添加行"}function Q2(t){return t.columnLayout!=="grid"?{display:"flex",flexDirection:"column",width:"100%",gap:0}:{display:"grid",gridTemplateColumns:`repeat(${Z2(t)}, minmax(0, 1fr))`,columnGap:16,rowGap:0,width:"100%",alignItems:"start"}}function Z2(t){const e=typeof t.columnCount=="number"&&Number.isFinite(t.columnCount)?Math.floor(t.columnCount):3;return Math.max(1,Math.min(e,Math.max(t.columns.length,1)))}function eL(t,e,n){if(t.backgroundColor)return t.backgroundColor;if(n!=null&&n.length)return n[e%n.length]}function tL(t){if(t)return{backgroundColor:t}}function nL(t){if(t)return{backgroundColor:t}}function rL(t){var n;const e=[];if((n=t.rules)!=null&&n.some(r=>r.type==="required")){const r=t.rules.find(o=>o.type==="required");e.push({validator:async(o,i)=>{if(!i||i.length===0)throw new Error((r==null?void 0:r.message)||"此项为必填")}})}return t.minItems!==void 0&&e.push({validator:async(r,o)=>{if(!o||o.length<t.minItems)throw new Error(`至少需要 ${t.minItems} 项`)}}),t.maxItems!==void 0&&e.push({validator:async(r,o)=>{if(o&&o.length>t.maxItems)throw new Error(`最多允许 ${t.maxItems} 项`)}}),e}const oL=go(vC,{isComplexField:!0,needsFormItemName:!1}),iL=/\{\{.*\}\}/;function kC(t){return typeof t=="string"&&iL.test(t)?"expression":"normal"}const xC=({field:t,disabled:e,readOnly:n,context:r})=>{const{renderVariableTag:o,renderVariableTooltip:i,validateVariable:s}=r,a=sL(t),l=t.keyPlaceholder||"Key",c=t.valuePlaceholder||"Value",u=t.variableInsert?32:0;return f.jsx(x.Form.List,{name:t.name,rules:a,children:(d,{add:h,remove:p},{errors:m})=>f.jsxs(x.Space,{direction:"vertical",style:{width:"100%"},children:[d.map(w=>f.jsx(SC,{field:t,listField:w,disabled:e,readOnly:n,canRemove:!(e||t.minItems!==void 0&&d.length<=t.minItems),keyPlaceholder:l,valuePlaceholder:c,valueModeSwitchOffset:u,onRemove:p,validateVariable:s,renderVariableTag:o,renderVariableTooltip:i},w.key)),f.jsx(x.Button,{type:"dashed",block:!0,icon:f.jsx(Z.PlusOutlined,{}),onClick:()=>h(),disabled:e||t.maxItems!==void 0&&d.length>=t.maxItems,children:"添加键值对"}),f.jsx(x.Form.ErrorList,{errors:m})]})})};xC.displayName="KeyValueFieldControl";const SC=({field:t,listField:e,disabled:n,readOnly:r,canRemove:o,keyPlaceholder:i,valuePlaceholder:s,valueModeSwitchOffset:a,onRemove:l,validateVariable:c,renderVariableTag:u,renderVariableTooltip:d})=>{const h=x.Form.useFormInstance(),[p,m]=b.useState(()=>{const w=h.getFieldValue([t.name,e.name]),v=kC(w==null?void 0:w.key);return v==="expression"?v:kC(w==null?void 0:w.value)});return f.jsxs("div",{style:{display:"flex",alignItems:"flex-start",gap:8},children:[f.jsx(x.Form.Item,{style:{flex:1,marginBottom:0,marginTop:a},name:[e.name,"key"],rules:[{required:!0,message:"请输入Key"}],children:t.variableInsert?f.jsx(la,{availableModes:["normal","expression"],mode:p,hideModeSwitch:!0,disabled:n,readOnly:r,placeholder:i,validateVariable:c,renderVariableTag:u,renderVariableTooltip:d}):f.jsx(x.Input,{placeholder:i,disabled:n,readOnly:r})}),f.jsx(x.Form.Item,{style:{flex:1,marginBottom:0},name:[e.name,"value"],children:t.variableInsert?f.jsx(la,{availableModes:["normal","expression"],mode:p,onModeChange:m,disabled:n,readOnly:r,placeholder:s,validateVariable:c,renderVariableTag:u,renderVariableTooltip:d,modeSwitchPosition:"top-right",compact:!0}):f.jsx(x.Input,{placeholder:s,disabled:n,readOnly:r})}),f.jsx(x.Button,{type:"text",danger:!0,icon:f.jsx(Z.DeleteOutlined,{}),style:{marginTop:a},onClick:()=>l(e.name),disabled:!o})]})};SC.displayName="KeyValueRow";function sL(t){var n;const e=[];if((n=t.rules)!=null&&n.some(r=>r.type==="required")){const r=t.rules.find(o=>o.type==="required");e.push({validator:async(o,i)=>{if(!i||i.length===0)throw new Error((r==null?void 0:r.message)||"此项为必填")}})}if(t.minItems!==void 0){const r=t.minItems;e.push({validator:async(o,i)=>{if(!i||i.length<r)throw new Error(`至少需要 ${r} 项`)}})}if(t.maxItems!==void 0){const r=t.maxItems;e.push({validator:async(o,i)=>{if(i&&i.length>r)throw new Error(`最多允许 ${r} 项`)}})}return e}const aL=go(xC,{isComplexField:!0,supportsVariableInsert:!0,needsFormItemName:!1});function lL(t){if(!t||typeof t!="object")return!1;const e=t;return typeof e.name=="string"&&e.name.trim()!==""&&typeof e.type=="string"}function cL(t){return!t||typeof t!="object"||Array.isArray(t)?[]:Object.values(t).filter(lL)}const EC=({field:t,disabled:e,context:n})=>{const r=x.Form.useFormInstance(),i=uL(t.name),[s,a]=mt.useState(null);mt.useEffect(()=>{Promise.resolve().then(()=>IL).then(v=>{a(()=>v.FieldRenderer)})},[]);const{renderVariableTag:l,renderVariableTooltip:c,validateVariable:u,values:d,optionsLoader:h}=n,p=mt.useMemo(()=>cL(t.properties),[t.properties]),m=r.getFieldValue(i)??qn(d,i.join("."))??{},w=f.jsx(x.Space,{direction:"vertical",style:{width:"100%"},children:p.map(v=>{const y=[...i,v.name];return Ys(v,m)&&s?f.jsx(s,{field:{...v,name:y},values:d,optionsLoader:h,disabled:e,renderVariableTag:l,renderVariableTooltip:c,validateVariable:u},y.join(".")):null})});return t.collapsible?f.jsx(x.Collapse,{defaultActiveKey:t.defaultCollapsed?[]:["main"],items:[{key:"main",label:t.label||t.name,children:w}]}):f.jsx(x.Card,{size:"small",title:t.label,children:w})};EC.displayName="ObjectFieldControl";function uL(t){return Array.isArray(t)?t:[t]}const dL=go(EC,{isComplexField:!0,needsFormItemName:!1}),DC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.DatePicker,{disabled:e,placeholder:t.placeholder,picker:t.picker,format:t.format,style:{width:"100%"},value:n,onChange:r,id:o});DC.displayName="DateFieldControl";const fL=pt(DC,{needsFormItemName:!0}),AC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.DatePicker.RangePicker,{disabled:e,picker:t.picker,showTime:t.showTime,format:t.format,style:{width:"100%"},value:n,onChange:i=>r==null?void 0:r(i),id:o});AC.displayName="DateRangeFieldControl";const hL=pt(AC,{needsFormItemName:!0}),OC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.DatePicker,{disabled:e,placeholder:t.placeholder,showTime:t.showTime??!0,format:t.format||"YYYY-MM-DD HH:mm:ss",style:{width:"100%"},value:n,onChange:r,id:o});OC.displayName="DateTimeFieldControl";const pL=pt(OC,{needsFormItemName:!0}),TC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.TimePicker,{disabled:e,placeholder:t.placeholder,format:t.format,style:{width:"100%"},value:n,onChange:i=>r==null?void 0:r(i),id:o});TC.displayName="TimeFieldControl";const mL=pt(TC,{needsFormItemName:!0}),_C=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.TimePicker.RangePicker,{disabled:e,format:t.format,style:{width:"100%"},value:n,onChange:i=>r==null?void 0:r(i),id:o});_C.displayName="TimeRangeFieldControl";const gL=pt(_C,{needsFormItemName:!0}),NC=({field:t})=>f.jsx(x.Divider,{children:t.label});NC.displayName="DividerFieldControl";const wL=go(NC,{isDisplayOnly:!0,needsFormItemName:!1}),BC=({value:t,onChange:e,id:n})=>f.jsx(x.Input,{type:"hidden",value:t,onChange:r=>e==null?void 0:e(r.target.value),id:n});BC.displayName="HiddenFieldControl";const vL=go(BC,{needsFormItemName:!0,isHidden:!0}),FC=({field:t})=>f.jsx(x.Alert,{message:t.label,description:t.description||t.placeholder,type:t.status||"info",showIcon:t.showIcon,closable:t.closable});FC.displayName="InfoCardFieldControl";const yL=go(FC,{isDisplayOnly:!0,needsFormItemName:!1}),IC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Input.TextArea,{disabled:e,placeholder:t.placeholder,rows:6,value:n,onChange:i=>r==null?void 0:r(i.target.value),id:o});IC.displayName="JsonFieldControl";const bL=pt(IC,{needsFormItemName:!0}),MC=({field:t,value:e})=>f.jsx("span",{children:e||t.placeholder||t.defaultValue});MC.displayName="LabelFieldControl";const CL=pt(MC,{needsFormItemName:!0}),PC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Cascader,{disabled:e,placeholder:t.placeholder,options:t.options,changeOnSelect:t.changeOnSelect,multiple:t.multiple||void 0,showSearch:t.showSearch,value:n,onChange:(i,s)=>r==null?void 0:r(i),id:o});PC.displayName="CascaderFieldControl";const kL=pt(PC,{needsFormItemName:!0}),LC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Checkbox,{disabled:e,checked:n,onChange:i=>r==null?void 0:r(i.target.checked),id:o,children:t.placeholder});LC.displayName="CheckboxFieldControl";const xL=pt(LC,{needsFormItemName:!0,valuePropName:"checked"}),$C=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Checkbox.Group,{disabled:e,options:t.options,value:n,onChange:i=>r==null?void 0:r(i)});$C.displayName="CheckboxGroupFieldControl";const SL=pt($C,{needsFormItemName:!0}),HC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Radio.Group,{disabled:e,options:t.options,optionType:t.optionType,buttonStyle:t.buttonStyle,value:n,onChange:i=>r==null?void 0:r(i.target.value),id:o});HC.displayName="RadioFieldControl";const EL=pt(HC,{needsFormItemName:!0}),zC=({field:t,disabled:e,context:n,value:r,onChange:o,id:i})=>{const{values:s,optionsLoader:a}=n,[l,c]=b.useState(jC(t)),[u,d]=b.useState(!1),h=t.type===be.MULTI_SELECT||t.mode==="multiple",p=y=>!y||y.kind==="static"?[]:y.deps||[],m=b.useMemo(()=>{const g=p(t.optionsSource).map(k=>qn(s,k));return JSON.stringify(g)},[t.optionsSource,s]);b.useEffect(()=>{if(!t.optionsSource||t.optionsSource.kind==="static"){c(jC(t));return}const y=t.optionsSource;if(!a){c(y.fallbackOptions||t.options||[]);return}const k=p(y).reduce((E,D)=>(E[D]=qn(s,D),E),{}),A={...y.params||{},deps:k};d(!0);let C=!1;return a(y.action,A,{values:s}).then(E=>{C||c(E)}).catch(()=>{C||c(y.fallbackOptions||t.options||[])}).finally(()=>{C||d(!1)}),()=>{C=!0}},[m,t.optionsSource,t.options]);const w=()=>{var y;(y=n.eventHandlers)==null||y.onBlur(t.name)},v=()=>{var y;(y=n.eventHandlers)==null||y.onFocus(t.name)};return f.jsx(x.Select,{disabled:e,placeholder:t.placeholder,options:l,mode:h?"multiple":t.mode,showSearch:t.showSearch,allowClear:t.allowClear,maxTagCount:t.maxTagCount,loading:u,value:r,onChange:o,onBlur:w,onFocus:v,id:i})};zC.displayName="SelectFieldControl";function jC(t){var n;if((n=t.options)!=null&&n.length)return t.options;const e=t.optionsSource;return e?e.kind==="static"?e.items||[]:e.fallbackOptions||[]:[]}const VC=pt(zC,{supportsVariableInsert:!1,needsFormItemName:!0}),WC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Switch,{disabled:e,checkedChildren:t.checkedChildren,unCheckedChildren:t.unCheckedChildren,checked:n,onChange:r,id:o});WC.displayName="SwitchFieldControl";const DL=pt(WC,{needsFormItemName:!0,valuePropName:"checked"}),UC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.TreeSelect,{disabled:e,placeholder:t.placeholder,treeData:t.options,multiple:t.multiple,showSearch:t.showSearch,allowClear:t.allowClear,treeCheckable:t.treeCheckable,value:n,onChange:r,id:o});UC.displayName="TreeSelectFieldControl";const AL=pt(UC,{needsFormItemName:!0}),qC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.AutoComplete,{disabled:e,placeholder:t.placeholder,options:t.options,allowClear:t.allowClear,value:n,onChange:r,id:o});qC.displayName="AutoCompleteFieldControl";const OL=pt(qC,{needsFormItemName:!0}),GC=({disabled:t,value:e,onChange:n})=>f.jsx(x.ColorPicker,{disabled:t,value:e,onChange:(r,o)=>n==null?void 0:n(o)});GC.displayName="ColorPickerFieldControl";const TL=pt(GC,{needsFormItemName:!0}),KC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Mentions,{disabled:e,placeholder:t.placeholder,value:n,onChange:r,id:o});KC.displayName="MentionsFieldControl";const _L=pt(KC,{needsFormItemName:!0}),YC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Rate,{disabled:e,count:t.count,allowHalf:t.allowHalf,value:n,onChange:r,id:o});YC.displayName="RateFieldControl";const NL=pt(YC,{needsFormItemName:!0}),XC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Slider,{disabled:e,min:t.min,max:t.max,step:t.step,marks:t.marks,range:t.range,value:n,onChange:i=>r==null?void 0:r(i),id:o});XC.displayName="SliderFieldControl";const BL=pt(XC,{needsFormItemName:!0}),JC=({field:t,disabled:e,value:n,onChange:r,id:o})=>f.jsx(x.Upload,{disabled:e,accept:t.accept,maxCount:t.maxCount,listType:t.listType||"text",action:t.action,multiple:t.multiple,fileList:n,onChange:r,id:o,children:f.jsx(x.Button,{icon:f.jsx(Z.UploadOutlined,{}),disabled:e,children:"上传文件"})});JC.displayName="UploadFieldControl";const FL=pt(JC,{needsFormItemName:!0});function RC(t=Rl){t.register(be.TEXT,V2),t.register(be.TEXTAREA,j2),t.register(be.NUMBER,H2),t.register(be.PASSWORD,z2),t.register(be.SELECT,VC),t.register(be.MULTI_SELECT,VC),t.register(be.RADIO,EL),t.register(be.CHECKBOX,xL),t.register(be.CHECKBOX_GROUP,SL),t.register(be.SWITCH,DL),t.register(be.CASCADER,kL),t.register(be.TREE_SELECT,AL),t.register(be.DATE,fL),t.register(be.DATETIME,pL),t.register(be.DATE_RANGE,hL),t.register(be.TIME,mL),t.register(be.TIME_RANGE,gL),t.register(be.UPLOAD,FL),t.register(be.RATE,NL),t.register(be.SLIDER,BL),t.register(be.COLOR_PICKER,TL),t.register(be.MENTIONS,_L),t.register(be.AUTO_COMPLETE,OL),t.register(be.LABEL,CL),t.register(be.HIDDEN,vL),t.register(be.JSON,bL),t.register(be.DIVIDER,wL),t.register(be.INFO_CARD,yL),t.register(be.ARRAY,U2),t.register(be.OBJECT,dL),t.register(be.KEY_VALUE,aL),t.register(be.ARRAY_OBJECT,oL)}RC();const yh=({field:t,disabled:e,required:n,readOnly:r,rules:o,values:i,optionsLoader:s,validateVariable:a,renderVariableTag:l,renderVariableTooltip:c,eventHandlers:u})=>{const d=Ql(),h=e??Pi(t.disabled,i,!1),p=n??Pi(t.required,i,!1),m=r??Pi(t.readOnly,i,!1),w=o??Mi(t.rules||[],i,t.type),v={values:i,optionsLoader:s,validateVariable:a,renderVariableTag:l,renderVariableTooltip:c,eventHandlers:u},y=d.get(t.type);if(!y)return f.jsxs("span",{children:["不支持的字段类型: ",t.type]});const{component:g,meta:k}=y;return k.isDisplayOnly?f.jsx(g,{field:t,disabled:h,readOnly:m,context:v}):k.isComplexField?f.jsx(x.Form.Item,{label:t.label,tooltip:t.tooltip,extra:t.helpText||t.extra||t.description,required:p,labelCol:t.labelCol,wrapperCol:t.wrapperCol,colon:t.colon,children:f.jsx(g,{field:t,disabled:h,readOnly:m,context:v})}):k.isHidden?f.jsx(x.Form.Item,{name:k.needsFormItemName!==!1?t.name:void 0,hidden:!0,rules:w,valuePropName:k.valuePropName,validateTrigger:t.validateTrigger,children:f.jsx(g,{field:t,disabled:h,readOnly:m,context:v})}):f.jsx(x.Form.Item,{name:k.needsFormItemName!==!1?t.name:void 0,label:t.label,tooltip:t.tooltip,extra:t.helpText||t.extra||t.description,required:p,rules:w,labelCol:t.labelCol,wrapperCol:t.wrapperCol,colon:t.colon,valuePropName:k.valuePropName,validateTrigger:t.validateTrigger,children:f.jsx(g,{field:t,disabled:h,readOnly:m,context:v})})},IL=Object.freeze(Object.defineProperty({__proto__:null,FieldRenderer:yh},Symbol.toStringTag,{value:"Module"})),ML={meta:{name:"antd-5x-apple-pixel-aligned-full",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#007AFF",colorInfo:"#007AFF",colorSuccess:"#34C759",colorWarning:"#FF9F0A",colorError:"#FF3B30",colorTextBase:"#0B0B0F",colorBgBase:"#FFFFFF",colorBorder:"#D1D1D6",colorBorderSecondary:"#E5E5EA",colorPrimaryBorder:"#007AFF",colorPrimaryBorderHover:"#007AFF",colorPrimaryHover:"#0066D6",colorPrimaryActive:"#0056B3",controlOutlineWidth:2,controlOutline:"rgba(0, 122, 255, 0.25)",fontFamily:'"SF Pro Text", "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.6,borderRadius:10,borderRadiusSM:8,borderRadiusLG:12,lineWidth:1,lineType:"solid",controlHeight:44,controlHeightSM:36,controlHeightLG:52,sizeUnit:4,sizeStep:4,padding:16,paddingXS:10,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:10,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 10px 24px rgba(0,0,0,0.12), 0 2px 8px rgba(0,0,0,0.08)",boxShadowSecondary:"0 6px 16px rgba(0,0,0,0.10), 0 2px 6px rgba(0,0,0,0.06)",boxShadowTertiary:"0 2px 8px rgba(0,0,0,0.08)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:12},Anchor:{linkPaddingInlineStart:16},AutoComplete:{controlHeight:44,controlHeightSM:36,controlHeightLG:52},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:999,borderRadiusSM:999,borderRadiusLG:999,controlHeight:44,controlHeightSM:36,controlHeightLG:52,paddingInline:18,paddingInlineLG:20,paddingInlineSM:14,contentFontSize:14,contentFontSizeLG:16,contentFontSizeSM:14,primaryShadow:"0 2px 0 rgba(0,122,255,0.14)",dangerShadow:"0 2px 0 rgba(255,59,48,0.12)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24,borderRadiusLG:14},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:6},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:52,activeBorderColor:"#007AFF",activeShadow:"0 0 0 2px rgba(0, 122, 255, 0.25)"},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:44,controlHeightLG:52,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:44,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:44,controlHeightSM:36,controlHeightLG:52,paddingInline:14,paddingInlineSM:12,paddingInlineLG:14,paddingBlock:10,paddingBlockSM:8,paddingBlockLG:12,borderRadius:10,hoverBorderColor:"#C7C7CC",activeBorderColor:"#007AFF",activeShadow:"0 0 0 2px rgba(0, 122, 255, 0.25)"},InputNumber:{controlHeight:44,controlHeightSM:36,controlHeightLG:52},Layout:{headerBg:"#FFFFFF",headerHeight:64,headerPadding:"0 50px",bodyBg:"#F2F2F7",siderBg:"#FFFFFF",triggerBg:"#F2F2F7"},List:{itemPadding:"12px 0"},Mentions:{controlHeight:44,controlHeightSM:36,controlHeightLG:52},Menu:{itemHeight:44,iconSize:16,collapsedIconSize:18,horizontalItemBorderRadius:10,itemBorderRadius:10},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16,borderRadiusLG:14},Notification:{},Pagination:{itemSize:44,itemSizeSM:36},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{buttonSolidCheckedBg:"#007AFF"},Rate:{},Result:{},Segmented:{controlHeight:36},Select:{controlHeight:44,controlHeightSM:36,controlHeightLG:52,multipleItemHeight:28,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:24,trackMinWidth:44,handleSize:20},Table:{headerBg:"#F2F2F7",headerSortActiveBg:"#EDEDF2",headerSortHoverBg:"#F2F2F7",rowHoverBg:"#F2F2F7",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:4,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 16px"},Tag:{borderRadiusSM:8},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:52,activeBorderColor:"#007AFF",activeShadow:"0 0 0 2px rgba(0, 122, 255, 0.25)"},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:36,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}},PL={meta:{name:"antd-5x-google-material3-aligned-full",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#1A73E8",colorInfo:"#1A73E8",colorSuccess:"#34A853",colorWarning:"#FBBC04",colorError:"#EA4335",colorTextBase:"#202124",colorBgBase:"#FFFFFF",colorBorder:"#DADCE0",colorBorderSecondary:"#E0E3E7",colorPrimaryBorder:"#1A73E8",colorPrimaryBorderHover:"#1A73E8",colorPrimaryHover:"#1967D2",colorPrimaryActive:"#174EA6",controlOutlineWidth:2,controlOutline:"rgba(26, 115, 232, 0.24)",fontFamily:'"Google Sans", Roboto, -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.5714285714285714,borderRadius:8,borderRadiusSM:4,borderRadiusLG:12,lineWidth:1,lineType:"solid",controlHeight:56,controlHeightSM:40,controlHeightLG:64,sizeUnit:4,sizeStep:4,padding:16,paddingXS:8,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:8,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 1px 2px rgba(60,64,67,0.16), 0 2px 6px rgba(60,64,67,0.12)",boxShadowSecondary:"0 2px 8px rgba(60,64,67,0.14)",boxShadowTertiary:"0 1px 3px rgba(60,64,67,0.12)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:12},Anchor:{linkPaddingInlineStart:16},AutoComplete:{controlHeight:56,controlHeightSM:40,controlHeightLG:64},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:999,borderRadiusSM:999,borderRadiusLG:999,controlHeight:40,controlHeightSM:32,controlHeightLG:48,paddingInline:24,paddingInlineLG:24,paddingInlineSM:16,contentFontSize:14,contentFontSizeLG:14,contentFontSizeSM:14,primaryShadow:"0 1px 0 rgba(26,115,232,0.20)",dangerShadow:"0 1px 0 rgba(234,67,53,0.18)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24,borderRadiusLG:12},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:4},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:56,controlHeightSM:40,controlHeightLG:64,activeBorderColor:"#1A73E8",activeShadow:"0 0 0 2px rgba(26, 115, 232, 0.24)"},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:40,controlHeightLG:48,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:40,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:56,controlHeightSM:40,controlHeightLG:64,paddingInline:16,paddingInlineSM:12,paddingInlineLG:16,paddingBlock:14,paddingBlockSM:8,paddingBlockLG:16,borderRadius:4,hoverBorderColor:"#BDC1C6",activeBorderColor:"#1A73E8",activeShadow:"0 0 0 2px rgba(26, 115, 232, 0.24)"},InputNumber:{controlHeight:56,controlHeightSM:40,controlHeightLG:64},Layout:{headerBg:"#202124",headerHeight:64,headerPadding:"0 50px",bodyBg:"#F8F9FA",siderBg:"#202124",triggerBg:"#303134"},List:{itemPadding:"12px 0"},Mentions:{controlHeight:56,controlHeightSM:40,controlHeightLG:64},Menu:{itemHeight:40,iconSize:14,collapsedIconSize:16,horizontalItemBorderRadius:12,itemBorderRadius:12},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16,borderRadiusLG:16},Notification:{},Pagination:{itemSize:40,itemSizeSM:32},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{buttonSolidCheckedBg:"#1A73E8"},Rate:{},Result:{},Segmented:{controlHeight:40},Select:{controlHeight:56,controlHeightSM:40,controlHeightLG:64,multipleItemHeight:28,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:24,trackMinWidth:44,handleSize:20},Table:{headerBg:"#F8F9FA",headerSortActiveBg:"#F1F3F4",headerSortHoverBg:"#F3F5F6",rowHoverBg:"#F8F9FA",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:4,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 18px"},Tag:{borderRadiusSM:8},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:56,controlHeightSM:40,controlHeightLG:64,activeBorderColor:"#1A73E8",activeShadow:"0 0 0 2px rgba(26, 115, 232, 0.24)"},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:32,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}},LL={meta:{name:"antd-5x-preline-pixel-aligned-full",algorithm:"defaultAlgorithm"},token:{colorPrimary:"#2563EB",colorInfo:"#2563EB",colorSuccess:"#16A34A",colorWarning:"#F59E0B",colorError:"#EF4444",colorTextBase:"#0F172A",colorBgBase:"#FFFFFF",colorBorder:"#E5E7EB",colorBorderSecondary:"#E5E7EB",colorPrimaryBorder:"#3B82F6",colorPrimaryBorderHover:"#3B82F6",colorPrimaryHover:"#1D4ED8",colorPrimaryActive:"#1E40AF",controlOutlineWidth:1,controlOutline:"rgba(59, 130, 246, 0.45)",fontFamily:'Graphik, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji"',fontSize:14,lineHeight:1.6,borderRadius:8,borderRadiusSM:6,borderRadiusLG:12,lineWidth:1,lineType:"solid",controlHeight:44,controlHeightSM:36,controlHeightLG:48,sizeUnit:4,sizeStep:4,padding:16,paddingXS:8,paddingSM:12,paddingLG:24,paddingXL:32,margin:16,marginXS:8,marginSM:12,marginLG:24,marginXL:32,wireframe:!1,motion:!0,motionUnit:.1,motionBase:0,motionEaseOutCirc:"cubic-bezier(0.08, 0.82, 0.17, 1)",motionEaseInOutCirc:"cubic-bezier(0.78, 0.14, 0.15, 0.86)",motionEaseOutBack:"cubic-bezier(0.12, 0.4, 0.29, 1.46)",motionEaseInBack:"cubic-bezier(0.71, -0.46, 0.88, 0.6)",motionEaseInOutBack:"cubic-bezier(0.71, -0.46, 0.29, 1.46)",opacityImage:1,linkDecoration:"none",linkHoverDecoration:"none",linkFocusDecoration:"none",boxShadow:"0 1px 2px rgba(15,23,42,0.06), 0 6px 18px rgba(15,23,42,0.08)",boxShadowSecondary:"0 1px 2px rgba(15,23,42,0.05), 0 10px 24px rgba(15,23,42,0.10)",boxShadowTertiary:"0 1px 2px rgba(15,23,42,0.06)",screenXS:480,screenXSMin:480,screenXSMax:575,screenSM:576,screenSMMin:576,screenSMMax:767,screenMD:768,screenMDMin:768,screenMDMax:991,screenLG:992,screenLGMin:992,screenLGMax:1199,screenXL:1200,screenXLMin:1200,screenXLMax:1599,screenXXL:1600,screenXXLMin:1600},components:{Alert:{borderRadiusLG:12},Anchor:{linkPaddingInlineStart:16},AutoComplete:{controlHeight:44,controlHeightSM:36,controlHeightLG:48},Avatar:{containerSize:32,containerSizeLG:40,containerSizeSM:24,textFontSize:14,textFontSizeLG:16,textFontSizeSM:12},BackTop:{},Badge:{indicatorHeight:16},Breadcrumb:{separatorMargin:8},Button:{borderRadius:8,borderRadiusSM:8,borderRadiusLG:10,controlHeight:44,controlHeightSM:36,controlHeightLG:48,paddingInline:16,paddingInlineLG:18,paddingInlineSM:12,contentFontSize:14,contentFontSizeLG:14,contentFontSizeSM:14,primaryShadow:"0 1px 0 rgba(37,99,235,0.18)",dangerShadow:"0 1px 0 rgba(239,68,68,0.16)"},Calendar:{fullBg:"#ffffff"},Card:{headerBg:"transparent",headerFontSize:16,headerHeight:56,paddingLG:24,borderRadiusLG:12},Carousel:{},Cascader:{},Checkbox:{borderRadiusSM:6},Collapse:{headerPadding:"12px 16px",contentPadding:"16px 16px"},ColorPicker:{},ConfigProvider:{},DatePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:48,activeBorderColor:"#3B82F6",activeShadow:"0 0 0 1px rgba(59, 130, 246, 0.45)"},Descriptions:{titleMarginBottom:16,itemPaddingBottom:16},Divider:{textPaddingInline:12},Drawer:{paddingLG:24},Dropdown:{},Empty:{},FloatButton:{controlHeight:40,controlHeightLG:48,borderRadius:999},Form:{itemMarginBottom:24,labelHeight:36,labelColonMarginInlineStart:2,labelColonMarginInlineEnd:8},Grid:{},Image:{},Input:{controlHeight:44,controlHeightSM:36,controlHeightLG:48,paddingInline:16,paddingInlineSM:12,paddingInlineLG:16,paddingBlock:10,paddingBlockSM:8,paddingBlockLG:10,borderRadius:8,hoverBorderColor:"#D1D5DB",activeBorderColor:"#3B82F6",activeShadow:"0 0 0 1px rgba(59, 130, 246, 0.45)"},InputNumber:{controlHeight:44,controlHeightSM:36,controlHeightLG:48},Layout:{headerBg:"#0B1220",headerHeight:64,headerPadding:"0 50px",bodyBg:"#F8FAFC",siderBg:"#0B1220",triggerBg:"#0F1A2E"},List:{itemPadding:"12px 0"},Mentions:{controlHeight:44,controlHeightSM:36,controlHeightLG:48},Menu:{itemHeight:40,iconSize:14,collapsedIconSize:16,horizontalItemBorderRadius:8,itemBorderRadius:8},Message:{},Modal:{headerBg:"transparent",titleFontSize:16,paddingMD:20,paddingContentHorizontalLG:24,paddingContentVerticalLG:16,borderRadiusLG:12},Notification:{},Pagination:{itemSize:36,itemSizeSM:32},Popconfirm:{},Popover:{},Progress:{},QRCode:{},Radio:{},Rate:{},Result:{},Segmented:{controlHeight:36},Select:{controlHeight:44,controlHeightSM:36,controlHeightLG:48,multipleItemHeight:28,showArrowPaddingInlineEnd:18},Skeleton:{},Slider:{},Space:{},Spin:{},Statistic:{},Steps:{iconSize:32,iconFontSize:16},Switch:{trackHeight:22,trackMinWidth:44,handleSize:18},Table:{headerBg:"#F8FAFC",headerSortActiveBg:"#F1F5F9",headerSortHoverBg:"#F3F6FB",rowHoverBg:"#F8FAFC",cellPaddingBlock:12,cellPaddingInline:16},Tabs:{cardGutter:6,horizontalMargin:"0 0 16px 0",horizontalItemPadding:"12px 16px"},Tag:{borderRadiusSM:6},Timeline:{},TimePicker:{cellHeight:24,timeColumnWidth:56,controlHeight:44,controlHeightSM:36,controlHeightLG:48,activeBorderColor:"#3B82F6",activeShadow:"0 0 0 1px rgba(59, 130, 246, 0.45)"},Tooltip:{},Tour:{},Transfer:{},Tree:{nodeHeight:32,titleHeight:24},TreeSelect:{},Typography:{titleMarginTop:0,titleMarginBottom:8},Upload:{},Watermark:{}}};function $L(t){return"optionsSource"in t&&t.optionsSource&&t.optionsSource.kind!=="static"?t.optionsSource.deps||[]:[]}function HL(t){const e=[];for(const n of t.fields){const r=$L(n);if(r.length>0)for(const o of r)e.push({id:`auto-clear-${n.name}-on-${o}-change`,trigger:{type:"fieldChange",field:o},actions:[{type:"clearFields",targets:[n.name]}]})}return e}function zL(t,e,n=!0){return[...n?HL(t):[],...e||[]]}const jL={default:Sf,apple:ML,google:PL,preline:LL};function Gi({schema:t,initialValues:e,onSubmit:n,onChange:r,submitLabel:o="提交",showReset:i=!1,resetLabel:s="重置",onReset:a,form:l,showSubmit:c=!0,optionsLoader:u,nodeId:d,mcpMode:h,validateVariable:p,renderVariableTag:m,renderVariableTooltip:w,availableVariables:v,theme:y,customTheme:g,locale:k,prefixCls:A,events:C,customHandlers:E,maxExecutionDepth:D,debugEvents:S}){var ie;const[_]=x.Form.useForm(),O=l||_,B=mt.useMemo(()=>{const Q={};for(const le of t.fields)le.defaultValue!==void 0&&(Q[le.name]=le.defaultValue);return{...Q,...e||{}}},[t.fields,e]),N=mt.useMemo(()=>{const Q=t.enableAutoEvents!==!1,le=t.events||[],L=C||[];return zL(t,[...le,...L],Q)},[t,C]),F=CB({events:N,form:O,optionsLoader:u,customHandlers:E,maxExecutionDepth:D,debug:S}),M=mt.useRef({}),T=mt.useMemo(()=>{if(g)return g;if(y)return jL[y]},[g,y]),P=x.Form.useWatch([],O),$=mt.useMemo(()=>JSON.stringify({...B||{},...P||{}}),[B,P]),W=mt.useMemo(()=>({...B||{},...P||{}}),[$]),[V,X]=mt.useState({}),G=mt.useRef({});mt.useEffect(()=>{var le;const Q={};for(const L of t.fields){const q=Ys(L,W);if(Q[L.name]=q,G.current[L.name]===!0&&q===!1){const K=OB(L),re=((le=L.visibleWhen)==null?void 0:le.clearOnHide)??!0;K==="unregister"&&O.setFieldValue(L.name,re?void 0:O.getFieldValue(L.name))}}G.current=Q,X(Q)},[t.fields,O,W]);const te=async Q=>{const le=t.pruneInvisibleOnSubmit===!1?Q:_B(t,Q,V);await(n==null?void 0:n(le))},H=(Q,le)=>{if(r==null||r(Q,le),F.triggerFieldChange&&Q){const L=M.current;for(const q in Q){const J=qn(L,q),K=Q[q];F.triggerFieldChange(q,K,J)}}M.current={...le}},j=c||i,Y=mt.useMemo(()=>({nodeId:d,mcpMode:h,validateVariable:p,renderVariableTag:m,renderVariableTooltip:w,availableVariables:v}),[d,h,p,m,w,v]);return f.jsx(F0,{customTheme:T,locale:k,prefixCls:A,children:f.jsx(L0,{value:Y,children:f.jsxs(x.Form,{form:O,layout:t.layout||"vertical",labelCol:t.labelCol,wrapperCol:t.wrapperCol,colon:t.colon,size:t.size,initialValues:B,onFinish:te,onValuesChange:H,children:[t.fields.map(Q=>{if(!Ys(Q,W))return null;const L=Pi(Q.disabled,W,!1),q=Pi(Q.required,W,!1),J=Mi(Q.rules||[],W,Q.type),K=q&&!J.some(re=>"required"in re&&re.required)?[{required:!0,message:`${Q.label||Q.name}为必填项`},...J]:J;return f.jsx(yh,{field:Q,disabled:L,required:q,rules:K,values:W,optionsLoader:u,validateVariable:p,renderVariableTag:m,renderVariableTooltip:w,eventHandlers:F.fieldEventHandlers},Q.name)}),j&&f.jsx(x.Form.Item,{wrapperCol:{offset:((ie=t.labelCol)==null?void 0:ie.span)||0},children:f.jsxs(x.Space,{children:[i&&f.jsx(x.Button,{onClick:()=>{O.resetFields(),a==null||a()},children:s}),c&&f.jsx(x.Button,{type:"primary",htmlType:"submit",children:o})]})})]})})})}const QC=({formSchema:t,initialValues:e,onCancel:n,onSubmit:r})=>{const[o]=x.Form.useForm();b.useEffect(()=>{o.setFieldsValue(e??{})},[o,e]);const i=async s=>{const a=await o.validateFields();r(a,s)};return f.jsxs("div",{children:[f.jsx(Gi,{schema:t,form:o,initialValues:e,showSubmit:!1,showReset:!1}),f.jsx("div",{style:{display:"flex",justifyContent:"flex-end",marginTop:16},children:f.jsxs(x.Space,{children:[f.jsx(x.Button,{onClick:n,children:"取消"}),f.jsx(x.Button,{onClick:()=>i(!0),children:"测试连接"}),f.jsx(x.Button,{type:"primary",onClick:()=>i(!1),children:"保存"})]})})]})},ZC=t=>Array.isArray(t)?t.map(e=>{if(typeof e=="string"){const s=e.trim();return s?{label:s,value:s}:null}const n=(e==null?void 0:e.value)??(e==null?void 0:e.label)??"",r=n==null?"":String(n).trim();if(!r)return null;const o=(e==null?void 0:e.label)??"";return{label:o==null?r:String(o).trim()||r,value:r}}).filter(Boolean):[],e1=b.forwardRef((t,e)=>{const[n,r]=b.useState([]),[o,i]=b.useState("");b.useEffect(()=>{i(t.proxyId)},[t.proxyId]),b.useEffect(()=>{Tv().then(l=>{r(l??[])})},[]);const s=()=>o;b.useImperativeHandle(e,()=>({getProxyId:s}));const a=l=>{i(l)};return f.jsxs("div",{children:[f.jsx("h3",{children:f.jsx(Ee.FormattedMessage,{id:"link.flow.use_proxy_gateway"})}),f.jsxs(x.Select,{className:"proxy_id_select",value:o,dropdownStyle:{zIndex:99999999999},onChange:a,style:{width:"100%"},children:[f.jsx(x.Select.Option,{value:"0",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.do_not_use"})}),n.map(l=>f.jsx(x.Select.Option,{value:l.id,children:l.group_name},l.id))]}),f.jsxs("p",{style:{color:"#ccc",marginTop:20},children:[f.jsx(Ee.FormattedMessage,{id:"link.flow.private_network_deployment"}),f.jsx("a",{style:{margin:"0 2px"},href:"/uc/setting/gateway",target:"_blank",rel:"noopener",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.proxy_gateway"})}),f.jsx(Ee.FormattedMessage,{id:"link.flow.secure_connection"})]})]})});var kc={exports:{}},VL=kc.exports,t1;function WL(){return t1||(t1=1,(function(t,e){(function(n,r){t.exports=r()})(VL,(function(){var n=1e3,r=6e4,o=36e5,i="millisecond",s="second",a="minute",l="hour",c="day",u="week",d="month",h="quarter",p="year",m="date",w="Invalid Date",v=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(M){var T=["th","st","nd","rd"],P=M%100;return"["+M+(T[(P-20)%10]||T[P]||T[0])+"]"}},k=function(M,T,P){var $=String(M);return!$||$.length>=T?M:""+Array(T+1-$.length).join(P)+M},A={s:k,z:function(M){var T=-M.utcOffset(),P=Math.abs(T),$=Math.floor(P/60),W=P%60;return(T<=0?"+":"-")+k($,2,"0")+":"+k(W,2,"0")},m:function M(T,P){if(T.date()<P.date())return-M(P,T);var $=12*(P.year()-T.year())+(P.month()-T.month()),W=T.clone().add($,d),V=P-W<0,X=T.clone().add($+(V?-1:1),d);return+(-($+(P-W)/(V?W-X:X-W))||0)},a:function(M){return M<0?Math.ceil(M)||0:Math.floor(M)},p:function(M){return{M:d,y:p,w:u,d:c,D:m,h:l,m:a,s,ms:i,Q:h}[M]||String(M||"").toLowerCase().replace(/s$/,"")},u:function(M){return M===void 0}},C="en",E={};E[C]=g;var D="$isDayjsObject",S=function(M){return M instanceof N||!(!M||!M[D])},_=function M(T,P,$){var W;if(!T)return C;if(typeof T=="string"){var V=T.toLowerCase();E[V]&&(W=V),P&&(E[V]=P,W=V);var X=T.split("-");if(!W&&X.length>1)return M(X[0])}else{var G=T.name;E[G]=T,W=G}return!$&&W&&(C=W),W||!$&&C},O=function(M,T){if(S(M))return M.clone();var P=typeof T=="object"?T:{};return P.date=M,P.args=arguments,new N(P)},B=A;B.l=_,B.i=S,B.w=function(M,T){return O(M,{locale:T.$L,utc:T.$u,x:T.$x,$offset:T.$offset})};var N=(function(){function M(P){this.$L=_(P.locale,null,!0),this.parse(P),this.$x=this.$x||P.x||{},this[D]=!0}var T=M.prototype;return T.parse=function(P){this.$d=(function($){var W=$.date,V=$.utc;if(W===null)return new Date(NaN);if(B.u(W))return new Date;if(W instanceof Date)return new Date(W);if(typeof W=="string"&&!/Z$/i.test(W)){var X=W.match(v);if(X){var G=X[2]-1||0,te=(X[7]||"0").substring(0,3);return V?new Date(Date.UTC(X[1],G,X[3]||1,X[4]||0,X[5]||0,X[6]||0,te)):new Date(X[1],G,X[3]||1,X[4]||0,X[5]||0,X[6]||0,te)}}return new Date(W)})(P),this.init()},T.init=function(){var P=this.$d;this.$y=P.getFullYear(),this.$M=P.getMonth(),this.$D=P.getDate(),this.$W=P.getDay(),this.$H=P.getHours(),this.$m=P.getMinutes(),this.$s=P.getSeconds(),this.$ms=P.getMilliseconds()},T.$utils=function(){return B},T.isValid=function(){return this.$d.toString()!==w},T.isSame=function(P,$){var W=O(P);return this.startOf($)<=W&&W<=this.endOf($)},T.isAfter=function(P,$){return O(P)<this.startOf($)},T.isBefore=function(P,$){return this.endOf($)<O(P)},T.$g=function(P,$,W){return B.u(P)?this[$]:this.set(W,P)},T.unix=function(){return Math.floor(this.valueOf()/1e3)},T.valueOf=function(){return this.$d.getTime()},T.startOf=function(P,$){var W=this,V=!!B.u($)||$,X=B.p(P),G=function(L,q){var J=B.w(W.$u?Date.UTC(W.$y,q,L):new Date(W.$y,q,L),W);return V?J:J.endOf(c)},te=function(L,q){return B.w(W.toDate()[L].apply(W.toDate("s"),(V?[0,0,0,0]:[23,59,59,999]).slice(q)),W)},H=this.$W,j=this.$M,Y=this.$D,ie="set"+(this.$u?"UTC":"");switch(X){case p:return V?G(1,0):G(31,11);case d:return V?G(1,j):G(0,j+1);case u:var Q=this.$locale().weekStart||0,le=(H<Q?H+7:H)-Q;return G(V?Y-le:Y+(6-le),j);case c:case m:return te(ie+"Hours",0);case l:return te(ie+"Minutes",1);case a:return te(ie+"Seconds",2);case s:return te(ie+"Milliseconds",3);default:return this.clone()}},T.endOf=function(P){return this.startOf(P,!1)},T.$set=function(P,$){var W,V=B.p(P),X="set"+(this.$u?"UTC":""),G=(W={},W[c]=X+"Date",W[m]=X+"Date",W[d]=X+"Month",W[p]=X+"FullYear",W[l]=X+"Hours",W[a]=X+"Minutes",W[s]=X+"Seconds",W[i]=X+"Milliseconds",W)[V],te=V===c?this.$D+($-this.$W):$;if(V===d||V===p){var H=this.clone().set(m,1);H.$d[G](te),H.init(),this.$d=H.set(m,Math.min(this.$D,H.daysInMonth())).$d}else G&&this.$d[G](te);return this.init(),this},T.set=function(P,$){return this.clone().$set(P,$)},T.get=function(P){return this[B.p(P)]()},T.add=function(P,$){var W,V=this;P=Number(P);var X=B.p($),G=function(j){var Y=O(V);return B.w(Y.date(Y.date()+Math.round(j*P)),V)};if(X===d)return this.set(d,this.$M+P);if(X===p)return this.set(p,this.$y+P);if(X===c)return G(1);if(X===u)return G(7);var te=(W={},W[a]=r,W[l]=o,W[s]=n,W)[X]||1,H=this.$d.getTime()+P*te;return B.w(H,this)},T.subtract=function(P,$){return this.add(-1*P,$)},T.format=function(P){var $=this,W=this.$locale();if(!this.isValid())return W.invalidDate||w;var V=P||"YYYY-MM-DDTHH:mm:ssZ",X=B.z(this),G=this.$H,te=this.$m,H=this.$M,j=W.weekdays,Y=W.months,ie=W.meridiem,Q=function(q,J,K,re){return q&&(q[J]||q($,V))||K[J].slice(0,re)},le=function(q){return B.s(G%12||12,q,"0")},L=ie||function(q,J,K){var re=q<12?"AM":"PM";return K?re.toLowerCase():re};return V.replace(y,(function(q,J){return J||(function(K){switch(K){case"YY":return String($.$y).slice(-2);case"YYYY":return B.s($.$y,4,"0");case"M":return H+1;case"MM":return B.s(H+1,2,"0");case"MMM":return Q(W.monthsShort,H,Y,3);case"MMMM":return Q(Y,H);case"D":return $.$D;case"DD":return B.s($.$D,2,"0");case"d":return String($.$W);case"dd":return Q(W.weekdaysMin,$.$W,j,2);case"ddd":return Q(W.weekdaysShort,$.$W,j,3);case"dddd":return j[$.$W];case"H":return String(G);case"HH":return B.s(G,2,"0");case"h":return le(1);case"hh":return le(2);case"a":return L(G,te,!0);case"A":return L(G,te,!1);case"m":return String(te);case"mm":return B.s(te,2,"0");case"s":return String($.$s);case"ss":return B.s($.$s,2,"0");case"SSS":return B.s($.$ms,3,"0");case"Z":return X}return null})(q)||X.replace(":","")}))},T.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},T.diff=function(P,$,W){var V,X=this,G=B.p($),te=O(P),H=(te.utcOffset()-this.utcOffset())*r,j=this-te,Y=function(){return B.m(X,te)};switch(G){case p:V=Y()/12;break;case d:V=Y();break;case h:V=Y()/3;break;case u:V=(j-H)/6048e5;break;case c:V=(j-H)/864e5;break;case l:V=j/o;break;case a:V=j/r;break;case s:V=j/n;break;default:V=j}return W?V:B.a(V)},T.daysInMonth=function(){return this.endOf(d).$D},T.$locale=function(){return E[this.$L]},T.locale=function(P,$){if(!P)return this.$L;var W=this.clone(),V=_(P,$,!0);return V&&(W.$L=V),W},T.clone=function(){return B.w(this.$d,this)},T.toDate=function(){return new Date(this.valueOf())},T.toJSON=function(){return this.isValid()?this.toISOString():null},T.toISOString=function(){return this.$d.toISOString()},T.toString=function(){return this.$d.toUTCString()},M})(),F=N.prototype;return O.prototype=F,[["$ms",i],["$s",s],["$m",a],["$H",l],["$W",c],["$M",d],["$y",p],["$D",m]].forEach((function(M){F[M[1]]=function(T){return this.$g(T,M[0],M[1])}})),O.extend=function(M,T){return M.$i||(M(T,N,O),M.$i=!0),O},O.locale=_,O.isDayjs=S,O.unix=function(M){return O(1e3*M)},O.en=E[C],O.Ls=E,O.p={},O}))})(kc)),kc.exports}var UL=WL();const cr=Ii(UL),qL=t=>f.jsx(x.DatePicker,{style:{width:"100%"},picker:"date",value:cr(t.value?t.value:new Date),onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD")))}}),GL=t=>f.jsx(x.DatePicker,{style:{width:"100%"},picker:"date",showTime:!0,value:cr(t.value?t.value:new Date),onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("YYYY-MM-DD hh:mm:ss")))}}),KL=({value:t=[],onChange:e,valueType:n})=>{const r=a=>{const l=[...t];l.splice(a,1),e==null||e(l)},o=()=>{e==null||e([...t,{key:"",value:""}])},i=(a,l)=>{e==null||e(t.map((c,u)=>u===a?{...c,key:l}:c))},s=(a,l)=>{e==null||e(t.map((c,u)=>u===a?{...c,value:l}:c))};return f.jsxs("div",{children:[t.map((a,l)=>f.jsxs(x.Space,{size:"small",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[f.jsx(x.Input,{value:a.key,onChange:c=>i(l,c.target.value),placeholder:"Key"}),f.jsx(x.Input,{placeholder:"Value",style:{width:300},value:a.value,onChange:c=>s(l,c.target.value)}),f.jsx(Z.DeleteOutlined,{onClick:()=>{r(l)}})]},l)),f.jsxs(x.Button,{type:"dashed",onClick:o,block:!0,children:[f.jsx(Z.PlusOutlined,{})," ",f.jsx(Ee.FormattedMessage,{id:"app.common.word.add-field"})]})]})},YL=t=>null,n1=1024;let XL=0,bh=class{constructor(e,n){this.from=e,this.to=n}};class Ve{constructor(e={}){this.id=XL++,this.perNode=!!e.perNode,this.deserialize=e.deserialize||(()=>{throw new Error("This node type doesn't define a deserialize function")}),this.combine=e.combine||null}add(e){if(this.perNode)throw new RangeError("Can't add per-node props to node types");return typeof e!="function"&&(e=Sn.match(e)),n=>{let r=e(n);return r===void 0?null:[this,r]}}}Ve.closedBy=new Ve({deserialize:t=>t.split(" ")}),Ve.openedBy=new Ve({deserialize:t=>t.split(" ")}),Ve.group=new Ve({deserialize:t=>t.split(" ")}),Ve.isolate=new Ve({deserialize:t=>{if(t&&t!="rtl"&&t!="ltr"&&t!="auto")throw new RangeError("Invalid value for isolate: "+t);return t||"auto"}}),Ve.contextHash=new Ve({perNode:!0}),Ve.lookAhead=new Ve({perNode:!0}),Ve.mounted=new Ve({perNode:!0});class ca{constructor(e,n,r,o=!1){this.tree=e,this.overlay=n,this.parser=r,this.bracketed=o}static get(e){return e&&e.props&&e.props[Ve.mounted.id]}}const JL=Object.create(null);class Sn{constructor(e,n,r,o=0){this.name=e,this.props=n,this.id=r,this.flags=o}static define(e){let n=e.props&&e.props.length?Object.create(null):JL,r=(e.top?1:0)|(e.skipped?2:0)|(e.error?4:0)|(e.name==null?8:0),o=new Sn(e.name||"",n,e.id,r);if(e.props){for(let i of e.props)if(Array.isArray(i)||(i=i(o)),i){if(i[0].perNode)throw new RangeError("Can't store a per-node prop on a node type");n[i[0].id]=i[1]}}return o}prop(e){return this.props[e.id]}get isTop(){return(this.flags&1)>0}get isSkipped(){return(this.flags&2)>0}get isError(){return(this.flags&4)>0}get isAnonymous(){return(this.flags&8)>0}is(e){if(typeof e=="string"){if(this.name==e)return!0;let n=this.prop(Ve.group);return n?n.indexOf(e)>-1:!1}return this.id==e}static match(e){let n=Object.create(null);for(let r in e)for(let o of r.split(" "))n[o]=e[r];return r=>{for(let o=r.prop(Ve.group),i=-1;i<(o?o.length:0);i++){let s=n[i<0?r.name:o[i]];if(s)return s}}}}Sn.none=new Sn("",Object.create(null),0,8);class Ch{constructor(e){this.types=e;for(let n=0;n<e.length;n++)if(e[n].id!=n)throw new RangeError("Node type ids should correspond to array positions when creating a node set")}extend(...e){let n=[];for(let r of this.types){let o=null;for(let i of e){let s=i(r);if(s){o||(o=Object.assign({},r.props));let a=s[1],l=s[0];l.combine&&l.id in o&&(a=l.combine(o[l.id],a)),o[l.id]=a}}n.push(o?new Sn(r.name,o,r.id,r.flags):r)}return new Ch(n)}}const xc=new WeakMap,r1=new WeakMap;var Et;(function(t){t[t.ExcludeBuffers=1]="ExcludeBuffers",t[t.IncludeAnonymous=2]="IncludeAnonymous",t[t.IgnoreMounts=4]="IgnoreMounts",t[t.IgnoreOverlays=8]="IgnoreOverlays",t[t.EnterBracketed=16]="EnterBracketed"})(Et||(Et={}));class _t{constructor(e,n,r,o,i){if(this.type=e,this.children=n,this.positions=r,this.length=o,this.props=null,i&&i.length){this.props=Object.create(null);for(let[s,a]of i)this.props[typeof s=="number"?s:s.id]=a}}toString(){let e=ca.get(this);if(e&&!e.overlay)return e.tree.toString();let n="";for(let r of this.children){let o=r.toString();o&&(n&&(n+=","),n+=o)}return this.type.name?(/\W/.test(this.type.name)&&!this.type.isError?JSON.stringify(this.type.name):this.type.name)+(n.length?"("+n+")":""):n}cursor(e=0){return new Sh(this.topNode,e)}cursorAt(e,n=0,r=0){let o=xc.get(this)||this.topNode,i=new Sh(o);return i.moveTo(e,n),xc.set(this,i._tree),i}get topNode(){return new Kn(this,0,0,null)}resolve(e,n=0){let r=ua(xc.get(this)||this.topNode,e,n,!1);return xc.set(this,r),r}resolveInner(e,n=0){let r=ua(r1.get(this)||this.topNode,e,n,!0);return r1.set(this,r),r}resolveStack(e,n=0){return ZL(this,e,n)}iterate(e){let{enter:n,leave:r,from:o=0,to:i=this.length}=e,s=e.mode||0,a=(s&Et.IncludeAnonymous)>0;for(let l=this.cursor(s|Et.IncludeAnonymous);;){let c=!1;if(l.from<=i&&l.to>=o&&(!a&&l.type.isAnonymous||n(l)!==!1)){if(l.firstChild())continue;c=!0}for(;c&&r&&(a||!l.type.isAnonymous)&&r(l),!l.nextSibling();){if(!l.parent())return;c=!0}}}prop(e){return e.perNode?this.props?this.props[e.id]:void 0:this.type.prop(e)}get propValues(){let e=[];if(this.props)for(let n in this.props)e.push([+n,this.props[n]]);return e}balance(e={}){return this.children.length<=8?this:Dh(Sn.none,this.children,this.positions,0,this.children.length,0,this.length,(n,r,o)=>new _t(this.type,n,r,o,this.propValues),e.makeTree||((n,r,o)=>new _t(Sn.none,n,r,o)))}static build(e){return e3(e)}}_t.empty=new _t(Sn.none,[],[],0);class kh{constructor(e,n){this.buffer=e,this.index=n}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}get pos(){return this.index}next(){this.index-=4}fork(){return new kh(this.buffer,this.index)}}class wo{constructor(e,n,r){this.buffer=e,this.length=n,this.set=r}get type(){return Sn.none}toString(){let e=[];for(let n=0;n<this.buffer.length;)e.push(this.childString(n)),n=this.buffer[n+3];return e.join(",")}childString(e){let n=this.buffer[e],r=this.buffer[e+3],o=this.set.types[n],i=o.name;if(/\W/.test(i)&&!o.isError&&(i=JSON.stringify(i)),e+=4,r==e)return i;let s=[];for(;e<r;)s.push(this.childString(e)),e=this.buffer[e+3];return i+"("+s.join(",")+")"}findChild(e,n,r,o,i){let{buffer:s}=this,a=-1;for(let l=e;l!=n&&!(o1(i,o,s[l+1],s[l+2])&&(a=l,r>0));l=s[l+3]);return a}slice(e,n,r){let o=this.buffer,i=new Uint16Array(n-e),s=0;for(let a=e,l=0;a<n;){i[l++]=o[a++],i[l++]=o[a++]-r;let c=i[l++]=o[a++]-r;i[l++]=o[a++]-e,s=Math.max(s,c)}return new wo(i,s,this.set)}}function o1(t,e,n,r){switch(t){case-2:return n<e;case-1:return r>=e&&n<e;case 0:return n<e&&r>e;case 1:return n<=e&&r>e;case 2:return r>e;case 4:return!0}}function ua(t,e,n,r){for(var o;t.from==t.to||(n<1?t.from>=e:t.from>e)||(n>-1?t.to<=e:t.to<e);){let s=!r&&t instanceof Kn&&t.index<0?null:t.parent;if(!s)return t;t=s}let i=r?0:Et.IgnoreOverlays;if(r)for(let s=t,a=s.parent;a;s=a,a=s.parent)s instanceof Kn&&s.index<0&&((o=a.enter(e,n,i))===null||o===void 0?void 0:o.from)!=s.from&&(t=a);for(;;){let s=t.enter(e,n,i);if(!s)return t;t=s}}class i1{cursor(e=0){return new Sh(this,e)}getChild(e,n=null,r=null){let o=s1(this,e,n,r);return o.length?o[0]:null}getChildren(e,n=null,r=null){return s1(this,e,n,r)}resolve(e,n=0){return ua(this,e,n,!1)}resolveInner(e,n=0){return ua(this,e,n,!0)}matchContext(e){return xh(this.parent,e)}enterUnfinishedNodesBefore(e){let n=this.childBefore(e),r=this;for(;n;){let o=n.lastChild;if(!o||o.to!=n.to)break;o.type.isError&&o.from==o.to?(r=n,n=o.prevSibling):n=o}return r}get node(){return this}get next(){return this.parent}}class Kn extends i1{constructor(e,n,r,o){super(),this._tree=e,this.from=n,this.index=r,this._parent=o}get type(){return this._tree.type}get name(){return this._tree.type.name}get to(){return this.from+this._tree.length}nextChild(e,n,r,o,i=0){var s;for(let a=this;;){for(let{children:l,positions:c}=a._tree,u=n>0?l.length:-1;e!=u;e+=n){let d=l[e],h=c[e]+a.from;if(!(!(i&Et.EnterBracketed&&d instanceof _t&&((s=ca.get(d))===null||s===void 0?void 0:s.overlay)===null&&(h>=r||h+d.length<=r))&&!o1(o,r,h,h+d.length))){if(d instanceof wo){if(i&Et.ExcludeBuffers)continue;let p=d.findChild(0,d.buffer.length,n,r-h,o);if(p>-1)return new vo(new RL(a,d,e,h),null,p)}else if(i&Et.IncludeAnonymous||!d.type.isAnonymous||Eh(d)){let p;if(!(i&Et.IgnoreMounts)&&(p=ca.get(d))&&!p.overlay)return new Kn(p.tree,h,e,a);let m=new Kn(d,h,e,a);return i&Et.IncludeAnonymous||!m.type.isAnonymous?m:m.nextChild(n<0?d.children.length-1:0,n,r,o,i)}}}if(i&Et.IncludeAnonymous||!a.type.isAnonymous||(a.index>=0?e=a.index+n:e=n<0?-1:a._parent._tree.children.length,a=a._parent,!a))return null}}get firstChild(){return this.nextChild(0,1,0,4)}get lastChild(){return this.nextChild(this._tree.children.length-1,-1,0,4)}childAfter(e){return this.nextChild(0,1,e,2)}childBefore(e){return this.nextChild(this._tree.children.length-1,-1,e,-2)}prop(e){return this._tree.prop(e)}enter(e,n,r=0){let o;if(!(r&Et.IgnoreOverlays)&&(o=ca.get(this._tree))&&o.overlay){let i=e-this.from,s=r&Et.EnterBracketed&&o.bracketed;for(let{from:a,to:l}of o.overlay)if((n>0||s?a<=i:a<i)&&(n<0||s?l>=i:l>i))return new Kn(o.tree,o.overlay[0].from+this.from,-1,this)}return this.nextChild(0,1,e,n,r)}nextSignificantParent(){let e=this;for(;e.type.isAnonymous&&e._parent;)e=e._parent;return e}get parent(){return this._parent?this._parent.nextSignificantParent():null}get nextSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index+1,1,0,4):null}get prevSibling(){return this._parent&&this.index>=0?this._parent.nextChild(this.index-1,-1,0,4):null}get tree(){return this._tree}toTree(){return this._tree}toString(){return this._tree.toString()}}function s1(t,e,n,r){let o=t.cursor(),i=[];if(!o.firstChild())return i;if(n!=null){for(let s=!1;!s;)if(s=o.type.is(n),!o.nextSibling())return i}for(;;){if(r!=null&&o.type.is(r))return i;if(o.type.is(e)&&i.push(o.node),!o.nextSibling())return r==null?i:[]}}function xh(t,e,n=e.length-1){for(let r=t;n>=0;r=r.parent){if(!r)return!1;if(!r.type.isAnonymous){if(e[n]&&e[n]!=r.name)return!1;n--}}return!0}class RL{constructor(e,n,r,o){this.parent=e,this.buffer=n,this.index=r,this.start=o}}class vo extends i1{get name(){return this.type.name}get from(){return this.context.start+this.context.buffer.buffer[this.index+1]}get to(){return this.context.start+this.context.buffer.buffer[this.index+2]}constructor(e,n,r){super(),this.context=e,this._parent=n,this.index=r,this.type=e.buffer.set.types[e.buffer.buffer[r]]}child(e,n,r){let{buffer:o}=this.context,i=o.findChild(this.index+4,o.buffer[this.index+3],e,n-this.context.start,r);return i<0?null:new vo(this.context,this,i)}get firstChild(){return this.child(1,0,4)}get lastChild(){return this.child(-1,0,4)}childAfter(e){return this.child(1,e,2)}childBefore(e){return this.child(-1,e,-2)}prop(e){return this.type.prop(e)}enter(e,n,r=0){if(r&Et.ExcludeBuffers)return null;let{buffer:o}=this.context,i=o.findChild(this.index+4,o.buffer[this.index+3],n>0?1:-1,e-this.context.start,n);return i<0?null:new vo(this.context,this,i)}get parent(){return this._parent||this.context.parent.nextSignificantParent()}externalSibling(e){return this._parent?null:this.context.parent.nextChild(this.context.index+e,e,0,4)}get nextSibling(){let{buffer:e}=this.context,n=e.buffer[this.index+3];return n<(this._parent?e.buffer[this._parent.index+3]:e.buffer.length)?new vo(this.context,this._parent,n):this.externalSibling(1)}get prevSibling(){let{buffer:e}=this.context,n=this._parent?this._parent.index+4:0;return this.index==n?this.externalSibling(-1):new vo(this.context,this._parent,e.findChild(n,this.index,-1,0,4))}get tree(){return null}toTree(){let e=[],n=[],{buffer:r}=this.context,o=this.index+4,i=r.buffer[this.index+3];if(i>o){let s=r.buffer[this.index+1];e.push(r.slice(o,i,s)),n.push(0)}return new _t(this.type,e,n,this.to-this.from)}toString(){return this.context.buffer.childString(this.index)}}function a1(t){if(!t.length)return null;let e=0,n=t[0];for(let i=1;i<t.length;i++){let s=t[i];(s.from>n.from||s.to<n.to)&&(n=s,e=i)}let r=n instanceof Kn&&n.index<0?null:n.parent,o=t.slice();return r?o[e]=r:o.splice(e,1),new QL(o,n)}class QL{constructor(e,n){this.heads=e,this.node=n}get next(){return a1(this.heads)}}function ZL(t,e,n){let r=t.resolveInner(e,n),o=null;for(let i=r instanceof Kn?r:r.context.parent;i;i=i.parent)if(i.index<0){let s=i.parent;(o||(o=[r])).push(s.resolve(e,n)),i=s}else{let s=ca.get(i.tree);if(s&&s.overlay&&s.overlay[0].from<=e&&s.overlay[s.overlay.length-1].to>=e){let a=new Kn(s.tree,s.overlay[0].from+i.from,-1,i);(o||(o=[r])).push(ua(a,e,n,!1))}}return o?a1(o):r}class Sh{get name(){return this.type.name}constructor(e,n=0){if(this.buffer=null,this.stack=[],this.index=0,this.bufferNode=null,this.mode=n&~Et.EnterBracketed,e instanceof Kn)this.yieldNode(e);else{this._tree=e.context.parent,this.buffer=e.context;for(let r=e._parent;r;r=r._parent)this.stack.unshift(r.index);this.bufferNode=e,this.yieldBuf(e.index)}}yieldNode(e){return e?(this._tree=e,this.type=e.type,this.from=e.from,this.to=e.to,!0):!1}yieldBuf(e,n){this.index=e;let{start:r,buffer:o}=this.buffer;return this.type=n||o.set.types[o.buffer[e]],this.from=r+o.buffer[e+1],this.to=r+o.buffer[e+2],!0}yield(e){return e?e instanceof Kn?(this.buffer=null,this.yieldNode(e)):(this.buffer=e.context,this.yieldBuf(e.index,e.type)):!1}toString(){return this.buffer?this.buffer.buffer.childString(this.index):this._tree.toString()}enterChild(e,n,r){if(!this.buffer)return this.yield(this._tree.nextChild(e<0?this._tree._tree.children.length-1:0,e,n,r,this.mode));let{buffer:o}=this.buffer,i=o.findChild(this.index+4,o.buffer[this.index+3],e,n-this.buffer.start,r);return i<0?!1:(this.stack.push(this.index),this.yieldBuf(i))}firstChild(){return this.enterChild(1,0,4)}lastChild(){return this.enterChild(-1,0,4)}childAfter(e){return this.enterChild(1,e,2)}childBefore(e){return this.enterChild(-1,e,-2)}enter(e,n,r=this.mode){return this.buffer?r&Et.ExcludeBuffers?!1:this.enterChild(1,e,n):this.yield(this._tree.enter(e,n,r))}parent(){if(!this.buffer)return this.yieldNode(this.mode&Et.IncludeAnonymous?this._tree._parent:this._tree.parent);if(this.stack.length)return this.yieldBuf(this.stack.pop());let e=this.mode&Et.IncludeAnonymous?this.buffer.parent:this.buffer.parent.nextSignificantParent();return this.buffer=null,this.yieldNode(e)}sibling(e){if(!this.buffer)return this._tree._parent?this.yield(this._tree.index<0?null:this._tree._parent.nextChild(this._tree.index+e,e,0,4,this.mode)):!1;let{buffer:n}=this.buffer,r=this.stack.length-1;if(e<0){let o=r<0?0:this.stack[r]+4;if(this.index!=o)return this.yieldBuf(n.findChild(o,this.index,-1,0,4))}else{let o=n.buffer[this.index+3];if(o<(r<0?n.buffer.length:n.buffer[this.stack[r]+3]))return this.yieldBuf(o)}return r<0?this.yield(this.buffer.parent.nextChild(this.buffer.index+e,e,0,4,this.mode)):!1}nextSibling(){return this.sibling(1)}prevSibling(){return this.sibling(-1)}atLastNode(e){let n,r,{buffer:o}=this;if(o){if(e>0){if(this.index<o.buffer.buffer.length)return!1}else for(let i=0;i<this.index;i++)if(o.buffer.buffer[i+3]<this.index)return!1;({index:n,parent:r}=o)}else({index:n,_parent:r}=this._tree);for(;r;{index:n,_parent:r}=r)if(n>-1)for(let i=n+e,s=e<0?-1:r._tree.children.length;i!=s;i+=e){let a=r._tree.children[i];if(this.mode&Et.IncludeAnonymous||a instanceof wo||!a.type.isAnonymous||Eh(a))return!1}return!0}move(e,n){if(n&&this.enterChild(e,0,4))return!0;for(;;){if(this.sibling(e))return!0;if(this.atLastNode(e)||!this.parent())return!1}}next(e=!0){return this.move(1,e)}prev(e=!0){return this.move(-1,e)}moveTo(e,n=0){for(;(this.from==this.to||(n<1?this.from>=e:this.from>e)||(n>-1?this.to<=e:this.to<e))&&this.parent(););for(;this.enterChild(1,e,n););return this}get node(){if(!this.buffer)return this._tree;let e=this.bufferNode,n=null,r=0;if(e&&e.context==this.buffer)e:for(let o=this.index,i=this.stack.length;i>=0;){for(let s=e;s;s=s._parent)if(s.index==o){if(o==this.index)return s;n=s,r=i+1;break e}o=this.stack[--i]}for(let o=r;o<this.stack.length;o++)n=new vo(this.buffer,n,this.stack[o]);return this.bufferNode=new vo(this.buffer,n,this.index)}get tree(){return this.buffer?null:this._tree._tree}iterate(e,n){for(let r=0;;){let o=!1;if(this.type.isAnonymous||e(this)!==!1){if(this.firstChild()){r++;continue}this.type.isAnonymous||(o=!0)}for(;;){if(o&&n&&n(this),o=this.type.isAnonymous,!r)return;if(this.nextSibling())break;this.parent(),r--,o=!0}}}matchContext(e){if(!this.buffer)return xh(this.node.parent,e);let{buffer:n}=this.buffer,{types:r}=n.set;for(let o=e.length-1,i=this.stack.length-1;o>=0;i--){if(i<0)return xh(this._tree,e,o);let s=r[n.buffer[this.stack[i]]];if(!s.isAnonymous){if(e[o]&&e[o]!=s.name)return!1;o--}}return!0}}function Eh(t){return t.children.some(e=>e instanceof wo||!e.type.isAnonymous||Eh(e))}function e3(t){var e;let{buffer:n,nodeSet:r,maxBufferLength:o=n1,reused:i=[],minRepeatType:s=r.types.length}=t,a=Array.isArray(n)?new kh(n,n.length):n,l=r.types,c=0,u=0;function d(C,E,D,S,_,O){let{id:B,start:N,end:F,size:M}=a,T=u,P=c;if(M<0)if(a.next(),M==-1){let G=i[B];D.push(G),S.push(N-C);return}else if(M==-3){c=B;return}else if(M==-4){u=B;return}else throw new RangeError(`Unrecognized record size: ${M}`);let $=l[B],W,V,X=N-C;if(F-N<=o&&(V=v(a.pos-E,_))){let G=new Uint16Array(V.size-V.skip),te=a.pos-V.size,H=G.length;for(;a.pos>te;)H=y(V.start,G,H);W=new wo(G,F-V.start,r),X=V.start-C}else{let G=a.pos-M;a.next();let te=[],H=[],j=B>=s?B:-1,Y=0,ie=F;for(;a.pos>G;)j>=0&&a.id==j&&a.size>=0?(a.end<=ie-o&&(m(te,H,N,Y,a.end,ie,j,T,P),Y=te.length,ie=a.end),a.next()):O>2500?h(N,G,te,H):d(N,G,te,H,j,O+1);if(j>=0&&Y>0&&Y<te.length&&m(te,H,N,Y,N,ie,j,T,P),te.reverse(),H.reverse(),j>-1&&Y>0){let Q=p($,P);W=Dh($,te,H,0,te.length,0,F-N,Q,Q)}else W=w($,te,H,F-N,T-F,P)}D.push(W),S.push(X)}function h(C,E,D,S){let _=[],O=0,B=-1;for(;a.pos>E;){let{id:N,start:F,end:M,size:T}=a;if(T>4)a.next();else{if(B>-1&&F<B)break;B<0&&(B=M-o),_.push(N,F,M),O++,a.next()}}if(O){let N=new Uint16Array(O*4),F=_[_.length-2];for(let M=_.length-3,T=0;M>=0;M-=3)N[T++]=_[M],N[T++]=_[M+1]-F,N[T++]=_[M+2]-F,N[T++]=T;D.push(new wo(N,_[2]-F,r)),S.push(F-C)}}function p(C,E){return(D,S,_)=>{let O=0,B=D.length-1,N,F;if(B>=0&&(N=D[B])instanceof _t){if(!B&&N.type==C&&N.length==_)return N;(F=N.prop(Ve.lookAhead))&&(O=S[B]+N.length+F)}return w(C,D,S,_,O,E)}}function m(C,E,D,S,_,O,B,N,F){let M=[],T=[];for(;C.length>S;)M.push(C.pop()),T.push(E.pop()+D-_);C.push(w(r.types[B],M,T,O-_,N-O,F)),E.push(_-D)}function w(C,E,D,S,_,O,B){if(O){let N=[Ve.contextHash,O];B=B?[N].concat(B):[N]}if(_>25){let N=[Ve.lookAhead,_];B=B?[N].concat(B):[N]}return new _t(C,E,D,S,B)}function v(C,E){let D=a.fork(),S=0,_=0,O=0,B=D.end-o,N={size:0,start:0,skip:0};e:for(let F=D.pos-C;D.pos>F;){let M=D.size;if(D.id==E&&M>=0){N.size=S,N.start=_,N.skip=O,O+=4,S+=4,D.next();continue}let T=D.pos-M;if(M<0||T<F||D.start<B)break;let P=D.id>=s?4:0,$=D.start;for(D.next();D.pos>T;){if(D.size<0)if(D.size==-3||D.size==-4)P+=4;else break e;else D.id>=s&&(P+=4);D.next()}_=$,S+=M,O+=P}return(E<0||S==C)&&(N.size=S,N.start=_,N.skip=O),N.size>4?N:void 0}function y(C,E,D){let{id:S,start:_,end:O,size:B}=a;if(a.next(),B>=0&&S<s){let N=D;if(B>4){let F=a.pos-(B-4);for(;a.pos>F;)D=y(C,E,D)}E[--D]=N,E[--D]=O-C,E[--D]=_-C,E[--D]=S}else B==-3?c=S:B==-4&&(u=S);return D}let g=[],k=[];for(;a.pos>0;)d(t.start||0,t.bufferStart||0,g,k,-1,0);let A=(e=t.length)!==null&&e!==void 0?e:g.length?k[0]+g[0].length:0;return new _t(l[t.topID],g.reverse(),k.reverse(),A)}const l1=new WeakMap;function Sc(t,e){if(!t.isAnonymous||e instanceof wo||e.type!=t)return 1;let n=l1.get(e);if(n==null){n=1;for(let r of e.children){if(r.type!=t||!(r instanceof _t)){n=1;break}n+=Sc(t,r)}l1.set(e,n)}return n}function Dh(t,e,n,r,o,i,s,a,l){let c=0;for(let m=r;m<o;m++)c+=Sc(t,e[m]);let u=Math.ceil(c*1.5/8),d=[],h=[];function p(m,w,v,y,g){for(let k=v;k<y;){let A=k,C=w[k],E=Sc(t,m[k]);for(k++;k<y;k++){let D=Sc(t,m[k]);if(E+D>=u)break;E+=D}if(k==A+1){if(E>u){let D=m[A];p(D.children,D.positions,0,D.children.length,w[A]+g);continue}d.push(m[A])}else{let D=w[k-1]+m[k-1].length-C;d.push(Dh(t,m,w,A,k,C,D,null,l))}h.push(C+g-i)}}return p(e,n,r,o,0),(a||l)(d,h,s)}class ti{constructor(e,n,r,o,i=!1,s=!1){this.from=e,this.to=n,this.tree=r,this.offset=o,this.open=(i?1:0)|(s?2:0)}get openStart(){return(this.open&1)>0}get openEnd(){return(this.open&2)>0}static addTree(e,n=[],r=!1){let o=[new ti(0,e.length,e,0,!1,r)];for(let i of n)i.to>e.length&&o.push(i);return o}static applyChanges(e,n,r=128){if(!n.length)return e;let o=[],i=1,s=e.length?e[0]:null;for(let a=0,l=0,c=0;;a++){let u=a<n.length?n[a]:null,d=u?u.fromA:1e9;if(d-l>=r)for(;s&&s.from<d;){let h=s;if(l>=h.from||d<=h.to||c){let p=Math.max(h.from,l)-c,m=Math.min(h.to,d)-c;h=p>=m?null:new ti(p,m,h.tree,h.offset+c,a>0,!!u)}if(h&&o.push(h),s.to>d)break;s=i<e.length?e[i++]:null}if(!u)break;l=u.toA,c=u.toA-u.toB}return o}}class c1{startParse(e,n,r){return typeof e=="string"&&(e=new t3(e)),r=r?r.length?r.map(o=>new bh(o.from,o.to)):[new bh(0,0)]:[new bh(0,e.length)],this.createParse(e,n||[],r)}parse(e,n,r){let o=this.startParse(e,n,r);for(;;){let i=o.advance();if(i)return i}}}class t3{constructor(e){this.string=e}get length(){return this.string.length}chunk(e){return this.string.slice(e)}get lineChunks(){return!1}read(e,n){return this.string.slice(e,n)}}new Ve({perNode:!0});class Ec{constructor(e,n,r,o,i,s,a,l,c,u=0,d){this.p=e,this.stack=n,this.state=r,this.reducePos=o,this.pos=i,this.score=s,this.buffer=a,this.bufferBase=l,this.curContext=c,this.lookAhead=u,this.parent=d}toString(){return`[${this.stack.filter((e,n)=>n%3==0).concat(this.state)}]@${this.pos}${this.score?"!"+this.score:""}`}static start(e,n,r=0){let o=e.parser.context;return new Ec(e,[],n,r,r,0,[],0,o?new u1(o,o.start):null,0,null)}get context(){return this.curContext?this.curContext.context:null}pushState(e,n){this.stack.push(this.state,n,this.bufferBase+this.buffer.length),this.state=e}reduce(e){var n;let r=e>>19,o=e&65535,{parser:i}=this.p,s=this.reducePos<this.pos-25&&this.setLookAhead(this.pos),a=i.dynamicPrecedence(o);if(a&&(this.score+=a),r==0){this.pushState(i.getGoto(this.state,o,!0),this.reducePos),o<i.minRepeatTerm&&this.storeNode(o,this.reducePos,this.reducePos,s?8:4,!0),this.reduceContext(o,this.reducePos);return}let l=this.stack.length-(r-1)*3-(e&262144?6:0),c=l?this.stack[l-2]:this.p.ranges[0].from,u=this.reducePos-c;u>=2e3&&!(!((n=this.p.parser.nodeSet.types[o])===null||n===void 0)&&n.isAnonymous)&&(c==this.p.lastBigReductionStart?(this.p.bigReductionCount++,this.p.lastBigReductionSize=u):this.p.lastBigReductionSize<u&&(this.p.bigReductionCount=1,this.p.lastBigReductionStart=c,this.p.lastBigReductionSize=u));let d=l?this.stack[l-1]:0,h=this.bufferBase+this.buffer.length-d;if(o<i.minRepeatTerm||e&131072){let p=i.stateFlag(this.state,1)?this.pos:this.reducePos;this.storeNode(o,c,p,h+4,!0)}if(e&262144)this.state=this.stack[l];else{let p=this.stack[l-3];this.state=i.getGoto(p,o,!0)}for(;this.stack.length>l;)this.stack.pop();this.reduceContext(o,c)}storeNode(e,n,r,o=4,i=!1){if(e==0&&(!this.stack.length||this.stack[this.stack.length-1]<this.buffer.length+this.bufferBase)){let s=this,a=this.buffer.length;if(a==0&&s.parent&&(a=s.bufferBase-s.parent.bufferBase,s=s.parent),a>0&&s.buffer[a-4]==0&&s.buffer[a-1]>-1){if(n==r)return;if(s.buffer[a-2]>=n){s.buffer[a-2]=r;return}}}if(!i||this.pos==r)this.buffer.push(e,n,r,o);else{let s=this.buffer.length;if(s>0&&(this.buffer[s-4]!=0||this.buffer[s-1]<0)){let a=!1;for(let l=s;l>0&&this.buffer[l-2]>r;l-=4)if(this.buffer[l-1]>=0){a=!0;break}if(a)for(;s>0&&this.buffer[s-2]>r;)this.buffer[s]=this.buffer[s-4],this.buffer[s+1]=this.buffer[s-3],this.buffer[s+2]=this.buffer[s-2],this.buffer[s+3]=this.buffer[s-1],s-=4,o>4&&(o-=4)}this.buffer[s]=e,this.buffer[s+1]=n,this.buffer[s+2]=r,this.buffer[s+3]=o}}shift(e,n,r,o){if(e&131072)this.pushState(e&65535,this.pos);else if((e&262144)==0){let i=e,{parser:s}=this.p;this.pos=o,!s.stateFlag(i,1)&&(o>r||n<=s.maxNode)&&(this.reducePos=o),this.pushState(i,Math.min(r,this.reducePos)),this.shiftContext(n,r),n<=s.maxNode&&this.buffer.push(n,r,o,4)}else this.pos=o,this.shiftContext(n,r),n<=this.p.parser.maxNode&&this.buffer.push(n,r,o,4)}apply(e,n,r,o){e&65536?this.reduce(e):this.shift(e,n,r,o)}useNode(e,n){let r=this.p.reused.length-1;(r<0||this.p.reused[r]!=e)&&(this.p.reused.push(e),r++);let o=this.pos;this.reducePos=this.pos=o+e.length,this.pushState(n,o),this.buffer.push(r,o,this.reducePos,-1),this.curContext&&this.updateContext(this.curContext.tracker.reuse(this.curContext.context,e,this,this.p.stream.reset(this.pos-e.length)))}split(){let e=this,n=e.buffer.length;for(;n>0&&e.buffer[n-2]>e.reducePos;)n-=4;let r=e.buffer.slice(n),o=e.bufferBase+n;for(;e&&o==e.bufferBase;)e=e.parent;return new Ec(this.p,this.stack.slice(),this.state,this.reducePos,this.pos,this.score,r,o,this.curContext,this.lookAhead,e)}recoverByDelete(e,n){let r=e<=this.p.parser.maxNode;r&&this.storeNode(e,this.pos,n,4),this.storeNode(0,this.pos,n,r?8:4),this.pos=this.reducePos=n,this.score-=190}canShift(e){for(let n=new n3(this);;){let r=this.p.parser.stateSlot(n.state,4)||this.p.parser.hasAction(n.state,e);if(r==0)return!1;if((r&65536)==0)return!0;n.reduce(r)}}recoverByInsert(e){if(this.stack.length>=300)return[];let n=this.p.parser.nextStates(this.state);if(n.length>8||this.stack.length>=120){let o=[];for(let i=0,s;i<n.length;i+=2)(s=n[i+1])!=this.state&&this.p.parser.hasAction(s,e)&&o.push(n[i],s);if(this.stack.length<120)for(let i=0;o.length<8&&i<n.length;i+=2){let s=n[i+1];o.some((a,l)=>l&1&&a==s)||o.push(n[i],s)}n=o}let r=[];for(let o=0;o<n.length&&r.length<4;o+=2){let i=n[o+1];if(i==this.state)continue;let s=this.split();s.pushState(i,this.pos),s.storeNode(0,s.pos,s.pos,4,!0),s.shiftContext(n[o],this.pos),s.reducePos=this.pos,s.score-=200,r.push(s)}return r}forceReduce(){let{parser:e}=this.p,n=e.stateSlot(this.state,5);if((n&65536)==0)return!1;if(!e.validAction(this.state,n)){let r=n>>19,o=n&65535,i=this.stack.length-r*3;if(i<0||e.getGoto(this.stack[i],o,!1)<0){let s=this.findForcedReduction();if(s==null)return!1;n=s}this.storeNode(0,this.pos,this.pos,4,!0),this.score-=100}return this.reducePos=this.pos,this.reduce(n),!0}findForcedReduction(){let{parser:e}=this.p,n=[],r=(o,i)=>{if(!n.includes(o))return n.push(o),e.allActions(o,s=>{if(!(s&393216))if(s&65536){let a=(s>>19)-i;if(a>1){let l=s&65535,c=this.stack.length-a*3;if(c>=0&&e.getGoto(this.stack[c],l,!1)>=0)return a<<19|65536|l}}else{let a=r(s,i+1);if(a!=null)return a}})};return r(this.state,0)}forceAll(){for(;!this.p.parser.stateFlag(this.state,2);)if(!this.forceReduce()){this.storeNode(0,this.pos,this.pos,4,!0);break}return this}get deadEnd(){if(this.stack.length!=3)return!1;let{parser:e}=this.p;return e.data[e.stateSlot(this.state,1)]==65535&&!e.stateSlot(this.state,4)}restart(){this.storeNode(0,this.pos,this.pos,4,!0),this.state=this.stack[0],this.stack.length=0}sameState(e){if(this.state!=e.state||this.stack.length!=e.stack.length)return!1;for(let n=0;n<this.stack.length;n+=3)if(this.stack[n]!=e.stack[n])return!1;return!0}get parser(){return this.p.parser}dialectEnabled(e){return this.p.parser.dialect.flags[e]}shiftContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.shift(this.curContext.context,e,this,this.p.stream.reset(n)))}reduceContext(e,n){this.curContext&&this.updateContext(this.curContext.tracker.reduce(this.curContext.context,e,this,this.p.stream.reset(n)))}emitContext(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-3)&&this.buffer.push(this.curContext.hash,this.pos,this.pos,-3)}emitLookAhead(){let e=this.buffer.length-1;(e<0||this.buffer[e]!=-4)&&this.buffer.push(this.lookAhead,this.pos,this.pos,-4)}updateContext(e){if(e!=this.curContext.context){let n=new u1(this.curContext.tracker,e);n.hash!=this.curContext.hash&&this.emitContext(),this.curContext=n}}setLookAhead(e){return e<=this.lookAhead?!1:(this.emitLookAhead(),this.lookAhead=e,!0)}close(){this.curContext&&this.curContext.tracker.strict&&this.emitContext(),this.lookAhead>0&&this.emitLookAhead()}}class u1{constructor(e,n){this.tracker=e,this.context=n,this.hash=e.strict?e.hash(n):0}}class n3{constructor(e){this.start=e,this.state=e.state,this.stack=e.stack,this.base=this.stack.length}reduce(e){let n=e&65535,r=e>>19;r==0?(this.stack==this.start.stack&&(this.stack=this.stack.slice()),this.stack.push(this.state,0,0),this.base+=3):this.base-=(r-1)*3;let o=this.start.p.parser.getGoto(this.stack[this.base-3],n,!0);this.state=o}}class Dc{constructor(e,n,r){this.stack=e,this.pos=n,this.index=r,this.buffer=e.buffer,this.index==0&&this.maybeNext()}static create(e,n=e.bufferBase+e.buffer.length){return new Dc(e,n,n-e.bufferBase)}maybeNext(){let e=this.stack.parent;e!=null&&(this.index=this.stack.bufferBase-e.bufferBase,this.stack=e,this.buffer=e.buffer)}get id(){return this.buffer[this.index-4]}get start(){return this.buffer[this.index-3]}get end(){return this.buffer[this.index-2]}get size(){return this.buffer[this.index-1]}next(){this.index-=4,this.pos-=4,this.index==0&&this.maybeNext()}fork(){return new Dc(this.stack,this.pos,this.index)}}function Ac(t,e=Uint16Array){if(typeof t!="string")return t;let n=null;for(let r=0,o=0;r<t.length;){let i=0;for(;;){let s=t.charCodeAt(r++),a=!1;if(s==126){i=65535;break}s>=92&&s--,s>=34&&s--;let l=s-32;if(l>=46&&(l-=46,a=!0),i+=l,a)break;i*=46}n?n[o++]=i:n=new e(i)}return n}class Oc{constructor(){this.start=-1,this.value=-1,this.end=-1,this.extended=-1,this.lookAhead=0,this.mask=0,this.context=0}}const d1=new Oc;class r3{constructor(e,n){this.input=e,this.ranges=n,this.chunk="",this.chunkOff=0,this.chunk2="",this.chunk2Pos=0,this.next=-1,this.token=d1,this.rangeIndex=0,this.pos=this.chunkPos=n[0].from,this.range=n[0],this.end=n[n.length-1].to,this.readNext()}resolveOffset(e,n){let r=this.range,o=this.rangeIndex,i=this.pos+e;for(;i<r.from;){if(!o)return null;let s=this.ranges[--o];i-=r.from-s.to,r=s}for(;n<0?i>r.to:i>=r.to;){if(o==this.ranges.length-1)return null;let s=this.ranges[++o];i+=s.from-r.to,r=s}return i}clipPos(e){if(e>=this.range.from&&e<this.range.to)return e;for(let n of this.ranges)if(n.to>e)return Math.max(e,n.from);return this.end}peek(e){let n=this.chunkOff+e,r,o;if(n>=0&&n<this.chunk.length)r=this.pos+e,o=this.chunk.charCodeAt(n);else{let i=this.resolveOffset(e,1);if(i==null)return-1;if(r=i,r>=this.chunk2Pos&&r<this.chunk2Pos+this.chunk2.length)o=this.chunk2.charCodeAt(r-this.chunk2Pos);else{let s=this.rangeIndex,a=this.range;for(;a.to<=r;)a=this.ranges[++s];this.chunk2=this.input.chunk(this.chunk2Pos=r),r+this.chunk2.length>a.to&&(this.chunk2=this.chunk2.slice(0,a.to-r)),o=this.chunk2.charCodeAt(0)}}return r>=this.token.lookAhead&&(this.token.lookAhead=r+1),o}acceptToken(e,n=0){let r=n?this.resolveOffset(n,-1):this.pos;if(r==null||r<this.token.start)throw new RangeError("Token end out of bounds");this.token.value=e,this.token.end=r}acceptTokenTo(e,n){this.token.value=e,this.token.end=n}getChunk(){if(this.pos>=this.chunk2Pos&&this.pos<this.chunk2Pos+this.chunk2.length){let{chunk:e,chunkPos:n}=this;this.chunk=this.chunk2,this.chunkPos=this.chunk2Pos,this.chunk2=e,this.chunk2Pos=n,this.chunkOff=this.pos-this.chunkPos}else{this.chunk2=this.chunk,this.chunk2Pos=this.chunkPos;let e=this.input.chunk(this.pos),n=this.pos+e.length;this.chunk=n>this.range.to?e.slice(0,this.range.to-this.pos):e,this.chunkPos=this.pos,this.chunkOff=0}}readNext(){return this.chunkOff>=this.chunk.length&&(this.getChunk(),this.chunkOff==this.chunk.length)?this.next=-1:this.next=this.chunk.charCodeAt(this.chunkOff)}advance(e=1){for(this.chunkOff+=e;this.pos+e>=this.range.to;){if(this.rangeIndex==this.ranges.length-1)return this.setDone();e-=this.range.to-this.pos,this.range=this.ranges[++this.rangeIndex],this.pos=this.range.from}return this.pos+=e,this.pos>=this.token.lookAhead&&(this.token.lookAhead=this.pos+1),this.readNext()}setDone(){return this.pos=this.chunkPos=this.end,this.range=this.ranges[this.rangeIndex=this.ranges.length-1],this.chunk="",this.next=-1}reset(e,n){if(n?(this.token=n,n.start=e,n.lookAhead=e+1,n.value=n.extended=-1):this.token=d1,this.pos!=e){if(this.pos=e,e==this.end)return this.setDone(),this;for(;e<this.range.from;)this.range=this.ranges[--this.rangeIndex];for(;e>=this.range.to;)this.range=this.ranges[++this.rangeIndex];e>=this.chunkPos&&e<this.chunkPos+this.chunk.length?this.chunkOff=e-this.chunkPos:(this.chunk="",this.chunkOff=0),this.readNext()}return this}read(e,n){if(e>=this.chunkPos&&n<=this.chunkPos+this.chunk.length)return this.chunk.slice(e-this.chunkPos,n-this.chunkPos);if(e>=this.chunk2Pos&&n<=this.chunk2Pos+this.chunk2.length)return this.chunk2.slice(e-this.chunk2Pos,n-this.chunk2Pos);if(e>=this.range.from&&n<=this.range.to)return this.input.read(e,n);let r="";for(let o of this.ranges){if(o.from>=n)break;o.to>e&&(r+=this.input.read(Math.max(o.from,e),Math.min(o.to,n)))}return r}}class Ki{constructor(e,n){this.data=e,this.id=n}token(e,n){let{parser:r}=n.p;o3(this.data,e,n,this.id,r.data,r.tokenPrecTable)}}Ki.prototype.contextual=Ki.prototype.fallback=Ki.prototype.extend=!1,Ki.prototype.fallback=Ki.prototype.extend=!1;function o3(t,e,n,r,o,i){let s=0,a=1<<r,{dialect:l}=n.p.parser;e:for(;(a&t[s])!=0;){let c=t[s+1];for(let p=s+3;p<c;p+=2)if((t[p+1]&a)>0){let m=t[p];if(l.allows(m)&&(e.token.value==-1||e.token.value==m||i3(m,e.token.value,o,i))){e.acceptToken(m);break}}let u=e.next,d=0,h=t[s+2];if(e.next<0&&h>d&&t[c+h*3-3]==65535){s=t[c+h*3-1];continue e}for(;d<h;){let p=d+h>>1,m=c+p+(p<<1),w=t[m],v=t[m+1]||65536;if(u<w)h=p;else if(u>=v)d=p+1;else{s=t[m+2],e.advance();continue e}}break}}function f1(t,e,n){for(let r=e,o;(o=t[r])!=65535;r++)if(o==n)return r-e;return-1}function i3(t,e,n,r){let o=f1(n,r,e);return o<0||f1(n,r,t)<o}const Ln=typeof process<"u"&&process.env&&/\bparse\b/.test(process.env.LOG);let Ah=null;function h1(t,e,n){let r=t.cursor(Et.IncludeAnonymous);for(r.moveTo(e);;)if(!(n<0?r.childBefore(e):r.childAfter(e)))for(;;){if((n<0?r.to<e:r.from>e)&&!r.type.isError)return n<0?Math.max(0,Math.min(r.to-1,e-25)):Math.min(t.length,Math.max(r.from+1,e+25));if(n<0?r.prevSibling():r.nextSibling())break;if(!r.parent())return n<0?0:t.length}}class s3{constructor(e,n){this.fragments=e,this.nodeSet=n,this.i=0,this.fragment=null,this.safeFrom=-1,this.safeTo=-1,this.trees=[],this.start=[],this.index=[],this.nextFragment()}nextFragment(){let e=this.fragment=this.i==this.fragments.length?null:this.fragments[this.i++];if(e){for(this.safeFrom=e.openStart?h1(e.tree,e.from+e.offset,1)-e.offset:e.from,this.safeTo=e.openEnd?h1(e.tree,e.to+e.offset,-1)-e.offset:e.to;this.trees.length;)this.trees.pop(),this.start.pop(),this.index.pop();this.trees.push(e.tree),this.start.push(-e.offset),this.index.push(0),this.nextStart=this.safeFrom}else this.nextStart=1e9}nodeAt(e){if(e<this.nextStart)return null;for(;this.fragment&&this.safeTo<=e;)this.nextFragment();if(!this.fragment)return null;for(;;){let n=this.trees.length-1;if(n<0)return this.nextFragment(),null;let r=this.trees[n],o=this.index[n];if(o==r.children.length){this.trees.pop(),this.start.pop(),this.index.pop();continue}let i=r.children[o],s=this.start[n]+r.positions[o];if(s>e)return this.nextStart=s,null;if(i instanceof _t){if(s==e){if(s<this.safeFrom)return null;let a=s+i.length;if(a<=this.safeTo){let l=i.prop(Ve.lookAhead);if(!l||a+l<this.fragment.to)return i}}this.index[n]++,s+i.length>=Math.max(this.safeFrom,e)&&(this.trees.push(i),this.start.push(s),this.index.push(0))}else this.index[n]++,this.nextStart=s+i.length}}}class a3{constructor(e,n){this.stream=n,this.tokens=[],this.mainToken=null,this.actions=[],this.tokens=e.tokenizers.map(r=>new Oc)}getActions(e){let n=0,r=null,{parser:o}=e.p,{tokenizers:i}=o,s=o.stateSlot(e.state,3),a=e.curContext?e.curContext.hash:0,l=0;for(let c=0;c<i.length;c++){if((1<<c&s)==0)continue;let u=i[c],d=this.tokens[c];if(!(r&&!u.fallback)&&((u.contextual||d.start!=e.pos||d.mask!=s||d.context!=a)&&(this.updateCachedToken(d,u,e),d.mask=s,d.context=a),d.lookAhead>d.end+25&&(l=Math.max(d.lookAhead,l)),d.value!=0)){let h=n;if(d.extended>-1&&(n=this.addActions(e,d.extended,d.end,n)),n=this.addActions(e,d.value,d.end,n),!u.extend&&(r=d,n>h))break}}for(;this.actions.length>n;)this.actions.pop();return l&&e.setLookAhead(l),!r&&e.pos==this.stream.end&&(r=new Oc,r.value=e.p.parser.eofTerm,r.start=r.end=e.pos,n=this.addActions(e,r.value,r.end,n)),this.mainToken=r,this.actions}getMainToken(e){if(this.mainToken)return this.mainToken;let n=new Oc,{pos:r,p:o}=e;return n.start=r,n.end=Math.min(r+1,o.stream.end),n.value=r==o.stream.end?o.parser.eofTerm:0,n}updateCachedToken(e,n,r){let o=this.stream.clipPos(r.pos);if(n.token(this.stream.reset(o,e),r),e.value>-1){let{parser:i}=r.p;for(let s=0;s<i.specialized.length;s++)if(i.specialized[s]==e.value){let a=i.specializers[s](this.stream.read(e.start,e.end),r);if(a>=0&&r.p.parser.dialect.allows(a>>1)){(a&1)==0?e.value=a>>1:e.extended=a>>1;break}}}else e.value=0,e.end=this.stream.clipPos(o+1)}putAction(e,n,r,o){for(let i=0;i<o;i+=3)if(this.actions[i]==e)return o;return this.actions[o++]=e,this.actions[o++]=n,this.actions[o++]=r,o}addActions(e,n,r,o){let{state:i}=e,{parser:s}=e.p,{data:a}=s;for(let l=0;l<2;l++)for(let c=s.stateSlot(i,l?2:1);;c+=3){if(a[c]==65535)if(a[c+1]==1)c=Rr(a,c+2);else{o==0&&a[c+1]==2&&(o=this.putAction(Rr(a,c+2),n,r,o));break}a[c]==n&&(o=this.putAction(Rr(a,c+1),n,r,o))}return o}}class l3{constructor(e,n,r,o){this.parser=e,this.input=n,this.ranges=o,this.recovering=0,this.nextStackID=9812,this.minStackPos=0,this.reused=[],this.stoppedAt=null,this.lastBigReductionStart=-1,this.lastBigReductionSize=0,this.bigReductionCount=0,this.stream=new r3(n,o),this.tokens=new a3(e,this.stream),this.topTerm=e.top[1];let{from:i}=o[0];this.stacks=[Ec.start(this,e.top[0],i)],this.fragments=r.length&&this.stream.end-i>e.bufferLength*4?new s3(r,e.nodeSet):null}get parsedPos(){return this.minStackPos}advance(){let e=this.stacks,n=this.minStackPos,r=this.stacks=[],o,i;if(this.bigReductionCount>300&&e.length==1){let[s]=e;for(;s.forceReduce()&&s.stack.length&&s.stack[s.stack.length-2]>=this.lastBigReductionStart;);this.bigReductionCount=this.lastBigReductionSize=0}for(let s=0;s<e.length;s++){let a=e[s];for(;;){if(this.tokens.mainToken=null,a.pos>n)r.push(a);else{if(this.advanceStack(a,r,e))continue;{o||(o=[],i=[]),o.push(a);let l=this.tokens.getMainToken(a);i.push(l.value,l.end)}}break}}if(!r.length){let s=o&&u3(o);if(s)return Ln&&console.log("Finish with "+this.stackID(s)),this.stackToTree(s);if(this.parser.strict)throw Ln&&o&&console.log("Stuck with token "+(this.tokens.mainToken?this.parser.getName(this.tokens.mainToken.value):"none")),new SyntaxError("No parse at "+n);this.recovering||(this.recovering=5)}if(this.recovering&&o){let s=this.stoppedAt!=null&&o[0].pos>this.stoppedAt?o[0]:this.runRecovery(o,i,r);if(s)return Ln&&console.log("Force-finish "+this.stackID(s)),this.stackToTree(s.forceAll())}if(this.recovering){let s=this.recovering==1?1:this.recovering*3;if(r.length>s)for(r.sort((a,l)=>l.score-a.score);r.length>s;)r.pop();r.some(a=>a.reducePos>n)&&this.recovering--}else if(r.length>1){e:for(let s=0;s<r.length-1;s++){let a=r[s];for(let l=s+1;l<r.length;l++){let c=r[l];if(a.sameState(c)||a.buffer.length>500&&c.buffer.length>500)if((a.score-c.score||a.buffer.length-c.buffer.length)>0)r.splice(l--,1);else{r.splice(s--,1);continue e}}}r.length>12&&(r.sort((s,a)=>a.score-s.score),r.splice(12,r.length-12))}this.minStackPos=r[0].pos;for(let s=1;s<r.length;s++)r[s].pos<this.minStackPos&&(this.minStackPos=r[s].pos);return null}stopAt(e){if(this.stoppedAt!=null&&this.stoppedAt<e)throw new RangeError("Can't move stoppedAt forward");this.stoppedAt=e}advanceStack(e,n,r){let o=e.pos,{parser:i}=this,s=Ln?this.stackID(e)+" -> ":"";if(this.stoppedAt!=null&&o>this.stoppedAt)return e.forceReduce()?e:null;if(this.fragments){let c=e.curContext&&e.curContext.tracker.strict,u=c?e.curContext.hash:0;for(let d=this.fragments.nodeAt(o);d;){let h=this.parser.nodeSet.types[d.type.id]==d.type?i.getGoto(e.state,d.type.id):-1;if(h>-1&&d.length&&(!c||(d.prop(Ve.contextHash)||0)==u))return e.useNode(d,h),Ln&&console.log(s+this.stackID(e)+` (via reuse of ${i.getName(d.type.id)})`),!0;if(!(d instanceof _t)||d.children.length==0||d.positions[0]>0)break;let p=d.children[0];if(p instanceof _t&&d.positions[0]==0)d=p;else break}}let a=i.stateSlot(e.state,4);if(a>0)return e.reduce(a),Ln&&console.log(s+this.stackID(e)+` (via always-reduce ${i.getName(a&65535)})`),!0;if(e.stack.length>=8400)for(;e.stack.length>6e3&&e.forceReduce(););let l=this.tokens.getActions(e);for(let c=0;c<l.length;){let u=l[c++],d=l[c++],h=l[c++],p=c==l.length||!r,m=p?e:e.split(),w=this.tokens.mainToken;if(m.apply(u,d,w?w.start:m.pos,h),Ln&&console.log(s+this.stackID(m)+` (via ${(u&65536)==0?"shift":`reduce of ${i.getName(u&65535)}`} for ${i.getName(d)} @ ${o}${m==e?"":", split"})`),p)return!0;m.pos>o?n.push(m):r.push(m)}return!1}advanceFully(e,n){let r=e.pos;for(;;){if(!this.advanceStack(e,null,null))return!1;if(e.pos>r)return p1(e,n),!0}}runRecovery(e,n,r){let o=null,i=!1;for(let s=0;s<e.length;s++){let a=e[s],l=n[s<<1],c=n[(s<<1)+1],u=Ln?this.stackID(a)+" -> ":"";if(a.deadEnd&&(i||(i=!0,a.restart(),Ln&&console.log(u+this.stackID(a)+" (restarted)"),this.advanceFully(a,r))))continue;let d=a.split(),h=u;for(let p=0;p<10&&d.forceReduce()&&(Ln&&console.log(h+this.stackID(d)+" (via force-reduce)"),!this.advanceFully(d,r));p++)Ln&&(h=this.stackID(d)+" -> ");for(let p of a.recoverByInsert(l))Ln&&console.log(u+this.stackID(p)+" (via recover-insert)"),this.advanceFully(p,r);this.stream.end>a.pos?(c==a.pos&&(c++,l=0),a.recoverByDelete(l,c),Ln&&console.log(u+this.stackID(a)+` (via recover-delete ${this.parser.getName(l)})`),p1(a,r)):(!o||o.score<d.score)&&(o=d)}return o}stackToTree(e){return e.close(),_t.build({buffer:Dc.create(e),nodeSet:this.parser.nodeSet,topID:this.topTerm,maxBufferLength:this.parser.bufferLength,reused:this.reused,start:this.ranges[0].from,length:e.pos-this.ranges[0].from,minRepeatType:this.parser.minRepeatTerm})}stackID(e){let n=(Ah||(Ah=new WeakMap)).get(e);return n||Ah.set(e,n=String.fromCodePoint(this.nextStackID++)),n+e}}function p1(t,e){for(let n=0;n<e.length;n++){let r=e[n];if(r.pos==t.pos&&r.sameState(t)){e[n].score<t.score&&(e[n]=t);return}}e.push(t)}class c3{constructor(e,n,r){this.source=e,this.flags=n,this.disabled=r}allows(e){return!this.disabled||this.disabled[e]==0}}class Tc extends c1{constructor(e){if(super(),this.wrappers=[],e.version!=14)throw new RangeError(`Parser version (${e.version}) doesn't match runtime version (14)`);let n=e.nodeNames.split(" ");this.minRepeatTerm=n.length;for(let a=0;a<e.repeatNodeCount;a++)n.push("");let r=Object.keys(e.topRules).map(a=>e.topRules[a][1]),o=[];for(let a=0;a<n.length;a++)o.push([]);function i(a,l,c){o[a].push([l,l.deserialize(String(c))])}if(e.nodeProps)for(let a of e.nodeProps){let l=a[0];typeof l=="string"&&(l=Ve[l]);for(let c=1;c<a.length;){let u=a[c++];if(u>=0)i(u,l,a[c++]);else{let d=a[c+-u];for(let h=-u;h>0;h--)i(a[c++],l,d);c++}}}this.nodeSet=new Ch(n.map((a,l)=>Sn.define({name:l>=this.minRepeatTerm?void 0:a,id:l,props:o[l],top:r.indexOf(l)>-1,error:l==0,skipped:e.skippedNodes&&e.skippedNodes.indexOf(l)>-1}))),e.propSources&&(this.nodeSet=this.nodeSet.extend(...e.propSources)),this.strict=!1,this.bufferLength=n1;let s=Ac(e.tokenData);this.context=e.context,this.specializerSpecs=e.specialized||[],this.specialized=new Uint16Array(this.specializerSpecs.length);for(let a=0;a<this.specializerSpecs.length;a++)this.specialized[a]=this.specializerSpecs[a].term;this.specializers=this.specializerSpecs.map(m1),this.states=Ac(e.states,Uint32Array),this.data=Ac(e.stateData),this.goto=Ac(e.goto),this.maxTerm=e.maxTerm,this.tokenizers=e.tokenizers.map(a=>typeof a=="number"?new Ki(s,a):a),this.topRules=e.topRules,this.dialects=e.dialects||{},this.dynamicPrecedences=e.dynamicPrecedences||null,this.tokenPrecTable=e.tokenPrec,this.termNames=e.termNames||null,this.maxNode=this.nodeSet.types.length-1,this.dialect=this.parseDialect(),this.top=this.topRules[Object.keys(this.topRules)[0]]}createParse(e,n,r){let o=new l3(this,e,n,r);for(let i of this.wrappers)o=i(o,e,n,r);return o}getGoto(e,n,r=!1){let o=this.goto;if(n>=o[0])return-1;for(let i=o[n+1];;){let s=o[i++],a=s&1,l=o[i++];if(a&&r)return l;for(let c=i+(s>>1);i<c;i++)if(o[i]==e)return l;if(a)return-1}}hasAction(e,n){let r=this.data;for(let o=0;o<2;o++)for(let i=this.stateSlot(e,o?2:1),s;;i+=3){if((s=r[i])==65535)if(r[i+1]==1)s=r[i=Rr(r,i+2)];else{if(r[i+1]==2)return Rr(r,i+2);break}if(s==n||s==0)return Rr(r,i+1)}return 0}stateSlot(e,n){return this.states[e*6+n]}stateFlag(e,n){return(this.stateSlot(e,0)&n)>0}validAction(e,n){return!!this.allActions(e,r=>r==n?!0:null)}allActions(e,n){let r=this.stateSlot(e,4),o=r?n(r):void 0;for(let i=this.stateSlot(e,1);o==null;i+=3){if(this.data[i]==65535)if(this.data[i+1]==1)i=Rr(this.data,i+2);else break;o=n(Rr(this.data,i+1))}return o}nextStates(e){let n=[];for(let r=this.stateSlot(e,1);;r+=3){if(this.data[r]==65535)if(this.data[r+1]==1)r=Rr(this.data,r+2);else break;if((this.data[r+2]&1)==0){let o=this.data[r+1];n.some((i,s)=>s&1&&i==o)||n.push(this.data[r],o)}}return n}configure(e){let n=Object.assign(Object.create(Tc.prototype),this);if(e.props&&(n.nodeSet=this.nodeSet.extend(...e.props)),e.top){let r=this.topRules[e.top];if(!r)throw new RangeError(`Invalid top rule name ${e.top}`);n.top=r}return e.tokenizers&&(n.tokenizers=this.tokenizers.map(r=>{let o=e.tokenizers.find(i=>i.from==r);return o?o.to:r})),e.specializers&&(n.specializers=this.specializers.slice(),n.specializerSpecs=this.specializerSpecs.map((r,o)=>{let i=e.specializers.find(a=>a.from==r.external);if(!i)return r;let s=Object.assign(Object.assign({},r),{external:i.to});return n.specializers[o]=m1(s),s})),e.contextTracker&&(n.context=e.contextTracker),e.dialect&&(n.dialect=this.parseDialect(e.dialect)),e.strict!=null&&(n.strict=e.strict),e.wrap&&(n.wrappers=n.wrappers.concat(e.wrap)),e.bufferLength!=null&&(n.bufferLength=e.bufferLength),n}hasWrappers(){return this.wrappers.length>0}getName(e){return this.termNames?this.termNames[e]:String(e<=this.maxNode&&this.nodeSet.types[e].name||e)}get eofTerm(){return this.maxNode+1}get topNode(){return this.nodeSet.types[this.top[1]]}dynamicPrecedence(e){let n=this.dynamicPrecedences;return n==null?0:n[e]||0}parseDialect(e){let n=Object.keys(this.dialects),r=n.map(()=>!1);if(e)for(let i of e.split(" ")){let s=n.indexOf(i);s>=0&&(r[s]=!0)}let o=null;for(let i=0;i<n.length;i++)if(!r[i])for(let s=this.dialects[n[i]],a;(a=this.data[s++])!=65535;)(o||(o=new Uint8Array(this.maxTerm+1)))[a]=1;return new c3(e,r,o)}static deserialize(e){return new Tc(e)}}function Rr(t,e){return t[e]|t[e+1]<<16}function u3(t){let e=null;for(let n of t){let r=n.p.stoppedAt;(n.pos==n.p.stream.end||r!=null&&n.pos>r)&&n.p.parser.stateFlag(n.state,2)&&(!e||e.score<n.score)&&(e=n)}return e}function m1(t){if(t.external){let e=t.extend?1:0;return(n,r)=>t.external(n,r)<<1|e}return t.get}let d3=0;class Yn{constructor(e,n,r,o){this.name=e,this.set=n,this.base=r,this.modified=o,this.id=d3++}toString(){let{name:e}=this;for(let n of this.modified)n.name&&(e=`${n.name}(${e})`);return e}static define(e,n){let r=typeof e=="string"?e:"?";if(e instanceof Yn&&(n=e),n!=null&&n.base)throw new Error("Can not derive from a modified tag");let o=new Yn(r,[],null,[]);if(o.set.push(o),n)for(let i of n.set)o.set.push(i);return o}static defineModifier(e){let n=new _c(e);return r=>r.modified.indexOf(n)>-1?r:_c.get(r.base||r,r.modified.concat(n).sort((o,i)=>o.id-i.id))}}let f3=0;class _c{constructor(e){this.name=e,this.instances=[],this.id=f3++}static get(e,n){if(!n.length)return e;let r=n[0].instances.find(a=>a.base==e&&h3(n,a.modified));if(r)return r;let o=[],i=new Yn(e.name,o,e,n);for(let a of n)a.instances.push(i);let s=p3(n);for(let a of e.set)if(!a.modified.length)for(let l of s)o.push(_c.get(a,l));return i}}function h3(t,e){return t.length==e.length&&t.every((n,r)=>n==e[r])}function p3(t){let e=[[]];for(let n=0;n<t.length;n++)for(let r=0,o=e.length;r<o;r++)e.push(e[r].concat(t[n]));return e.sort((n,r)=>r.length-n.length)}function g1(t){let e=Object.create(null);for(let n in t){let r=t[n];Array.isArray(r)||(r=[r]);for(let o of n.split(" "))if(o){let i=[],s=2,a=o;for(let d=0;;){if(a=="..."&&d>0&&d+3==o.length){s=1;break}let h=/^"(?:[^"\\]|\\.)*?"|[^\/!]+/.exec(a);if(!h)throw new RangeError("Invalid path: "+o);if(i.push(h[0]=="*"?"":h[0][0]=='"'?JSON.parse(h[0]):h[0]),d+=h[0].length,d==o.length)break;let p=o[d++];if(d==o.length&&p=="!"){s=0;break}if(p!="/")throw new RangeError("Invalid path: "+o);a=o.slice(d)}let l=i.length-1,c=i[l];if(!c)throw new RangeError("Invalid path: "+o);let u=new da(r,s,l>0?i.slice(0,l):null);e[c]=u.sort(e[c])}}return w1.add(e)}const w1=new Ve({combine(t,e){let n,r,o;for(;t||e;){if(!t||e&&t.depth>=e.depth?(o=e,e=e.next):(o=t,t=t.next),n&&n.mode==o.mode&&!o.context&&!n.context)continue;let i=new da(o.tags,o.mode,o.context);n?n.next=i:r=i,n=i}return r}});class da{constructor(e,n,r,o){this.tags=e,this.mode=n,this.context=r,this.next=o}get opaque(){return this.mode==0}get inherit(){return this.mode==1}sort(e){return!e||e.depth<this.depth?(this.next=e,this):(e.next=this.sort(e.next),e)}get depth(){return this.context?this.context.length:0}}da.empty=new da([],2,null);function v1(t,e){let n=Object.create(null);for(let i of t)if(!Array.isArray(i.tag))n[i.tag.id]=i.class;else for(let s of i.tag)n[s.id]=i.class;let{scope:r,all:o=null}=e||{};return{style:i=>{let s=o;for(let a of i)for(let l of a.set){let c=n[l.id];if(c){s=s?s+" "+c:c;break}}return s},scope:r}}function m3(t,e){let n=null;for(let r of t){let o=r.style(e);o&&(n=n?n+" "+o:o)}return n}function g3(t,e,n,r=0,o=t.length){let i=new w3(r,Array.isArray(e)?e:[e],n);i.highlightRange(t.cursor(),r,o,"",i.highlighters),i.flush(o)}class w3{constructor(e,n,r){this.at=e,this.highlighters=n,this.span=r,this.class=""}startSpan(e,n){n!=this.class&&(this.flush(e),e>this.at&&(this.at=e),this.class=n)}flush(e){e>this.at&&this.class&&this.span(this.at,e,this.class)}highlightRange(e,n,r,o,i){let{type:s,from:a,to:l}=e;if(a>=r||l<=n)return;s.isTop&&(i=this.highlighters.filter(p=>!p.scope||p.scope(s)));let c=o,u=v3(e)||da.empty,d=m3(i,u.tags);if(d&&(c&&(c+=" "),c+=d,u.mode==1&&(o+=(o?" ":"")+d)),this.startSpan(Math.max(n,a),c),u.opaque)return;let h=e.tree&&e.tree.prop(Ve.mounted);if(h&&h.overlay){let p=e.node.enter(h.overlay[0].from+a,1),m=this.highlighters.filter(v=>!v.scope||v.scope(h.tree.type)),w=e.firstChild();for(let v=0,y=a;;v++){let g=v<h.overlay.length?h.overlay[v]:null,k=g?g.from+a:l,A=Math.max(n,y),C=Math.min(r,k);if(A<C&&w)for(;e.from<C&&(this.highlightRange(e,A,C,o,i),this.startSpan(Math.min(C,e.to),c),!(e.to>=k||!e.nextSibling())););if(!g||k>r)break;y=g.to+a,y>n&&(this.highlightRange(p.cursor(),Math.max(n,g.from+a),Math.min(r,y),"",m),this.startSpan(Math.min(r,y),c))}w&&e.parent()}else if(e.firstChild()){h&&(o="");do if(!(e.to<=n)){if(e.from>=r)break;this.highlightRange(e,n,r,o,i),this.startSpan(Math.min(r,e.to),c)}while(e.nextSibling());e.parent()}}}function v3(t){let e=t.type.prop(w1);for(;e&&e.context&&!t.matchContext(e.context);)e=e.next;return e||null}const ye=Yn.define,Nc=ye(),yo=ye(),y1=ye(yo),b1=ye(yo),bo=ye(),Bc=ye(bo),Oh=ye(bo),Dr=ye(),ni=ye(Dr),Ar=ye(),Or=ye(),Th=ye(),fa=ye(Th),Fc=ye(),z={comment:Nc,lineComment:ye(Nc),blockComment:ye(Nc),docComment:ye(Nc),name:yo,variableName:ye(yo),typeName:y1,tagName:ye(y1),propertyName:b1,attributeName:ye(b1),className:ye(yo),labelName:ye(yo),namespace:ye(yo),macroName:ye(yo),literal:bo,string:Bc,docString:ye(Bc),character:ye(Bc),attributeValue:ye(Bc),number:Oh,integer:ye(Oh),float:ye(Oh),bool:ye(bo),regexp:ye(bo),escape:ye(bo),color:ye(bo),url:ye(bo),keyword:Ar,self:ye(Ar),null:ye(Ar),atom:ye(Ar),unit:ye(Ar),modifier:ye(Ar),operatorKeyword:ye(Ar),controlKeyword:ye(Ar),definitionKeyword:ye(Ar),moduleKeyword:ye(Ar),operator:Or,derefOperator:ye(Or),arithmeticOperator:ye(Or),logicOperator:ye(Or),bitwiseOperator:ye(Or),compareOperator:ye(Or),updateOperator:ye(Or),definitionOperator:ye(Or),typeOperator:ye(Or),controlOperator:ye(Or),punctuation:Th,separator:ye(Th),bracket:fa,angleBracket:ye(fa),squareBracket:ye(fa),paren:ye(fa),brace:ye(fa),content:Dr,heading:ni,heading1:ye(ni),heading2:ye(ni),heading3:ye(ni),heading4:ye(ni),heading5:ye(ni),heading6:ye(ni),contentSeparator:ye(Dr),list:ye(Dr),quote:ye(Dr),emphasis:ye(Dr),strong:ye(Dr),link:ye(Dr),monospace:ye(Dr),strikethrough:ye(Dr),inserted:ye(),deleted:ye(),changed:ye(),invalid:ye(),meta:Fc,documentMeta:ye(Fc),annotation:ye(Fc),processingInstruction:ye(Fc),definition:Yn.defineModifier("definition"),constant:Yn.defineModifier("constant"),function:Yn.defineModifier("function"),standard:Yn.defineModifier("standard"),local:Yn.defineModifier("local"),special:Yn.defineModifier("special")};for(let t in z){let e=z[t];e instanceof Yn&&(e.name=t)}v1([{tag:z.link,class:"tok-link"},{tag:z.heading,class:"tok-heading"},{tag:z.emphasis,class:"tok-emphasis"},{tag:z.strong,class:"tok-strong"},{tag:z.keyword,class:"tok-keyword"},{tag:z.atom,class:"tok-atom"},{tag:z.bool,class:"tok-bool"},{tag:z.url,class:"tok-url"},{tag:z.labelName,class:"tok-labelName"},{tag:z.inserted,class:"tok-inserted"},{tag:z.deleted,class:"tok-deleted"},{tag:z.literal,class:"tok-literal"},{tag:z.string,class:"tok-string"},{tag:z.number,class:"tok-number"},{tag:[z.regexp,z.escape,z.special(z.string)],class:"tok-string2"},{tag:z.variableName,class:"tok-variableName"},{tag:z.local(z.variableName),class:"tok-variableName tok-local"},{tag:z.definition(z.variableName),class:"tok-variableName tok-definition"},{tag:z.special(z.variableName),class:"tok-variableName2"},{tag:z.definition(z.propertyName),class:"tok-propertyName tok-definition"},{tag:z.typeName,class:"tok-typeName"},{tag:z.namespace,class:"tok-namespace"},{tag:z.className,class:"tok-className"},{tag:z.macroName,class:"tok-macroName"},{tag:z.propertyName,class:"tok-propertyName"},{tag:z.operator,class:"tok-operator"},{tag:z.comment,class:"tok-comment"},{tag:z.meta,class:"tok-meta"},{tag:z.invalid,class:"tok-invalid"},{tag:z.punctuation,class:"tok-punctuation"}]);const y3=g1({String:z.string,Number:z.number,"True False":z.bool,PropertyName:z.propertyName,Null:z.null,", :":z.separator,"[ ]":z.squareBracket,"{ }":z.brace}),b3=Tc.deserialize({version:14,states:"$bOVQPOOOOQO'#Cb'#CbOnQPO'#CeOvQPO'#ClOOQO'#Cr'#CrQOQPOOOOQO'#Cg'#CgO}QPO'#CfO!SQPO'#CtOOQO,59P,59PO![QPO,59PO!aQPO'#CuOOQO,59W,59WO!iQPO,59WOVQPO,59QOqQPO'#CmO!nQPO,59`OOQO1G.k1G.kOVQPO'#CnO!vQPO,59aOOQO1G.r1G.rOOQO1G.l1G.lOOQO,59X,59XOOQO-E6k-E6kOOQO,59Y,59YOOQO-E6l-E6l",stateData:"#O~OeOS~OQSORSOSSOTSOWQO_ROgPO~OVXOgUO~O^[O~PVO[^O~O]_OVhX~OVaO~O]bO^iX~O^dO~O]_OVha~O]bO^ia~O",goto:"!kjPPPPPPkPPkqwPPPPk{!RPPP!XP!e!hXSOR^bQWQRf_TVQ_Q`WRg`QcZRicQTOQZRQe^RhbRYQR]R",nodeNames:"⚠ JsonText True False Null Number String } { Object Property PropertyName : , ] [ Array",maxTerm:25,nodeProps:[["isolate",-2,6,11,""],["openedBy",7,"{",14,"["],["closedBy",8,"}",15,"]"]],propSources:[y3],skippedNodes:[0],repeatNodeCount:2,tokenData:"(|~RaXY!WYZ!W]^!Wpq!Wrs!]|}$u}!O$z!Q!R%T!R![&c![!]&t!}#O&y#P#Q'O#Y#Z'T#b#c'r#h#i(Z#o#p(r#q#r(w~!]Oe~~!`Wpq!]qr!]rs!xs#O!]#O#P!}#P;'S!];'S;=`$o<%lO!]~!}Og~~#QXrs!]!P!Q!]#O#P!]#U#V!]#Y#Z!]#b#c!]#f#g!]#h#i!]#i#j#m~#pR!Q![#y!c!i#y#T#Z#y~#|R!Q![$V!c!i$V#T#Z$V~$YR!Q![$c!c!i$c#T#Z$c~$fR!Q![!]!c!i!]#T#Z!]~$rP;=`<%l!]~$zO]~~$}Q!Q!R%T!R![&c~%YRT~!O!P%c!g!h%w#X#Y%w~%fP!Q![%i~%nRT~!Q![%i!g!h%w#X#Y%w~%zR{|&T}!O&T!Q![&Z~&WP!Q![&Z~&`PT~!Q![&Z~&hST~!O!P%c!Q![&c!g!h%w#X#Y%w~&yO[~~'OO_~~'TO^~~'WP#T#U'Z~'^P#`#a'a~'dP#g#h'g~'jP#X#Y'm~'rOR~~'uP#i#j'x~'{P#`#a(O~(RP#`#a(U~(ZOS~~(^P#f#g(a~(dP#i#j(g~(jP#X#Y(m~(rOQ~~(wOW~~(|OV~",tokenizers:[0],topRules:{JsonText:[0,1]},tokenPrec:0});let _h=[],C1=[];(()=>{let t="lc,34,7n,7,7b,19,,,,2,,2,,,20,b,1c,l,g,,2t,7,2,6,2,2,,4,z,,u,r,2j,b,1m,9,9,,o,4,,9,,3,,5,17,3,3b,f,,w,1j,,,,4,8,4,,3,7,a,2,t,,1m,,,,2,4,8,,9,,a,2,q,,2,2,1l,,4,2,4,2,2,3,3,,u,2,3,,b,2,1l,,4,5,,2,4,,k,2,m,6,,,1m,,,2,,4,8,,7,3,a,2,u,,1n,,,,c,,9,,14,,3,,1l,3,5,3,,4,7,2,b,2,t,,1m,,2,,2,,3,,5,2,7,2,b,2,s,2,1l,2,,,2,4,8,,9,,a,2,t,,20,,4,,2,3,,,8,,29,,2,7,c,8,2q,,2,9,b,6,22,2,r,,,,,,1j,e,,5,,2,5,b,,10,9,,2u,4,,6,,2,2,2,p,2,4,3,g,4,d,,2,2,6,,f,,jj,3,qa,3,t,3,t,2,u,2,1s,2,,7,8,,2,b,9,,19,3,3b,2,y,,3a,3,4,2,9,,6,3,63,2,2,,1m,,,7,,,,,2,8,6,a,2,,1c,h,1r,4,1c,7,,,5,,14,9,c,2,w,4,2,2,,3,1k,,,2,3,,,3,1m,8,2,2,48,3,,d,,7,4,,6,,3,2,5i,1m,,5,ek,,5f,x,2da,3,3x,,2o,w,fe,6,2x,2,n9w,4,,a,w,2,28,2,7k,,3,,4,,p,2,5,,47,2,q,i,d,,12,8,p,b,1a,3,1c,,2,4,2,2,13,,1v,6,2,2,2,2,c,,8,,1b,,1f,,,3,2,2,5,2,,,16,2,8,,6m,,2,,4,,fn4,,kh,g,g,g,a6,2,gt,,6a,,45,5,1ae,3,,2,5,4,14,3,4,,4l,2,fx,4,ar,2,49,b,4w,,1i,f,1k,3,1d,4,2,2,1x,3,10,5,,8,1q,,c,2,1g,9,a,4,2,,2n,3,2,,,2,6,,4g,,3,8,l,2,1l,2,,,,,m,,e,7,3,5,5f,8,2,3,,,n,,29,,2,6,,,2,,,2,,2,6j,,2,4,6,2,,2,r,2,2d,8,2,,,2,2y,,,,2,6,,,2t,3,2,4,,5,77,9,,2,6t,,a,2,,,4,,40,4,2,2,4,,w,a,14,6,2,4,8,,9,6,2,3,1a,d,,2,ba,7,,6,,,2a,m,2,7,,2,,2,3e,6,3,,,2,,7,,,20,2,3,,,,9n,2,f0b,5,1n,7,t4,,1r,4,29,,f5k,2,43q,,,3,4,5,8,8,2,7,u,4,44,3,1iz,1j,4,1e,8,,e,,m,5,,f,11s,7,,h,2,7,,2,,5,79,7,c5,4,15s,7,31,7,240,5,gx7k,2o,3k,6o".split(",").map(e=>e?parseInt(e,36):1);for(let e=0,n=0;e<t.length;e++)(e%2?C1:_h).push(n=n+t[e])})();function C3(t){if(t<768)return!1;for(let e=0,n=_h.length;;){let r=e+n>>1;if(t<_h[r])n=r;else if(t>=C1[r])e=r+1;else return!0;if(e==n)return!1}}function k1(t){return t>=127462&&t<=127487}const x1=8205;function k3(t,e,n=!0,r=!0){return(n?S1:x3)(t,e,r)}function S1(t,e,n){if(e==t.length)return e;e&&E1(t.charCodeAt(e))&&D1(t.charCodeAt(e-1))&&e--;let r=Nh(t,e);for(e+=A1(r);e<t.length;){let o=Nh(t,e);if(r==x1||o==x1||n&&C3(o))e+=A1(o),r=o;else if(k1(o)){let i=0,s=e-2;for(;s>=0&&k1(Nh(t,s));)i++,s-=2;if(i%2==0)break;e+=2}else break}return e}function x3(t,e,n){for(;e>0;){let r=S1(t,e-2,n);if(r<e)return r;e--}return 0}function Nh(t,e){let n=t.charCodeAt(e);if(!D1(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return E1(r)?(n-55296<<10)+(r-56320)+65536:n}function E1(t){return t>=56320&&t<57344}function D1(t){return t>=55296&&t<56320}function A1(t){return t<65536?1:2}let Ze=class BT{lineAt(e){if(e<0||e>this.length)throw new RangeError(`Invalid position ${e} in document of length ${this.length}`);return this.lineInner(e,!1,1,0)}line(e){if(e<1||e>this.lines)throw new RangeError(`Invalid line number ${e} in ${this.lines}-line document`);return this.lineInner(e,!0,1,0)}replace(e,n,r){[e,n]=Yi(this,e,n);let o=[];return this.decompose(0,e,o,2),r.length&&r.decompose(0,r.length,o,3),this.decompose(n,this.length,o,1),Tr.from(o,this.length-(n-e)+r.length)}append(e){return this.replace(this.length,this.length,e)}slice(e,n=this.length){[e,n]=Yi(this,e,n);let r=[];return this.decompose(e,n,r,0),Tr.from(r,n-e)}eq(e){if(e==this)return!0;if(e.length!=this.length||e.lines!=this.lines)return!1;let n=this.scanIdentical(e,1),r=this.length-this.scanIdentical(e,-1),o=new ha(this),i=new ha(e);for(let s=n,a=n;;){if(o.next(s),i.next(s),s=0,o.lineBreak!=i.lineBreak||o.done!=i.done||o.value!=i.value)return!1;if(a+=o.value.length,o.done||a>=r)return!0}}iter(e=1){return new ha(this,e)}iterRange(e,n=this.length){return new T1(this,e,n)}iterLines(e,n){let r;if(e==null)r=this.iter();else{n==null&&(n=this.lines+1);let o=this.line(e).from;r=this.iterRange(o,Math.max(o,n==this.lines+1?this.length:n<=1?0:this.line(n-1).to))}return new _1(r)}toString(){return this.sliceString(0)}toJSON(){let e=[];return this.flatten(e),e}constructor(){}static of(e){if(e.length==0)throw new RangeError("A document must have at least one line");return e.length==1&&!e[0]?BT.empty:e.length<=32?new Nt(e):Tr.from(Nt.split(e,[]))}};class Nt extends Ze{constructor(e,n=S3(e)){super(),this.text=e,this.length=n}get lines(){return this.text.length}get children(){return null}lineInner(e,n,r,o){for(let i=0;;i++){let s=this.text[i],a=o+s.length;if((n?r:a)>=e)return new E3(o,a,r,s);o=a+1,r++}}decompose(e,n,r,o){let i=e<=0&&n>=this.length?this:new Nt(O1(this.text,e,n),Math.min(n,this.length)-Math.max(0,e));if(o&1){let s=r.pop(),a=Ic(i.text,s.text.slice(),0,i.length);if(a.length<=32)r.push(new Nt(a,s.length+i.length));else{let l=a.length>>1;r.push(new Nt(a.slice(0,l)),new Nt(a.slice(l)))}}else r.push(i)}replace(e,n,r){if(!(r instanceof Nt))return super.replace(e,n,r);[e,n]=Yi(this,e,n);let o=Ic(this.text,Ic(r.text,O1(this.text,0,e)),n),i=this.length+r.length-(n-e);return o.length<=32?new Nt(o,i):Tr.from(Nt.split(o,[]),i)}sliceString(e,n=this.length,r=`
|
|
32
32
|
`){[e,n]=Yi(this,e,n);let o="";for(let i=0,s=0;i<=n&&s<this.text.length;s++){let a=this.text[s],l=i+a.length;i>e&&s&&(o+=r),e<l&&n>i&&(o+=a.slice(Math.max(0,e-i),n-i)),i=l+1}return o}flatten(e){for(let n of this.text)e.push(n)}scanIdentical(){return 0}static split(e,n){let r=[],o=-1;for(let i of e)r.push(i),o+=i.length+1,r.length==32&&(n.push(new Nt(r,o)),r=[],o=-1);return o>-1&&n.push(new Nt(r,o)),n}}class Tr extends Ze{constructor(e,n){super(),this.children=e,this.length=n,this.lines=0;for(let r of e)this.lines+=r.lines}lineInner(e,n,r,o){for(let i=0;;i++){let s=this.children[i],a=o+s.length,l=r+s.lines-1;if((n?l:a)>=e)return s.lineInner(e,n,r,o);o=a+1,r=l+1}}decompose(e,n,r,o){for(let i=0,s=0;s<=n&&i<this.children.length;i++){let a=this.children[i],l=s+a.length;if(e<=l&&n>=s){let c=o&((s<=e?1:0)|(l>=n?2:0));s>=e&&l<=n&&!c?r.push(a):a.decompose(e-s,n-s,r,c)}s=l+1}}replace(e,n,r){if([e,n]=Yi(this,e,n),r.lines<this.lines)for(let o=0,i=0;o<this.children.length;o++){let s=this.children[o],a=i+s.length;if(e>=i&&n<=a){let l=s.replace(e-i,n-i,r),c=this.lines-s.lines+l.lines;if(l.lines<c>>4&&l.lines>c>>6){let u=this.children.slice();return u[o]=l,new Tr(u,this.length-(n-e)+r.length)}return super.replace(i,a,l)}i=a+1}return super.replace(e,n,r)}sliceString(e,n=this.length,r=`
|
|
33
33
|
`){[e,n]=Yi(this,e,n);let o="";for(let i=0,s=0;i<this.children.length&&s<=n;i++){let a=this.children[i],l=s+a.length;s>e&&i&&(o+=r),e<l&&n>s&&(o+=a.sliceString(e-s,n-s,r)),s=l+1}return o}flatten(e){for(let n of this.children)n.flatten(e)}scanIdentical(e,n){if(!(e instanceof Tr))return 0;let r=0,[o,i,s,a]=n>0?[0,0,this.children.length,e.children.length]:[this.children.length-1,e.children.length-1,-1,-1];for(;;o+=n,i+=n){if(o==s||i==a)return r;let l=this.children[o],c=e.children[i];if(l!=c)return r+l.scanIdentical(c,n);r+=l.length+1}}static from(e,n=e.reduce((r,o)=>r+o.length+1,-1)){let r=0;for(let p of e)r+=p.lines;if(r<32){let p=[];for(let m of e)m.flatten(p);return new Nt(p,n)}let o=Math.max(32,r>>5),i=o<<1,s=o>>1,a=[],l=0,c=-1,u=[];function d(p){let m;if(p.lines>i&&p instanceof Tr)for(let w of p.children)d(w);else p.lines>s&&(l>s||!l)?(h(),a.push(p)):p instanceof Nt&&l&&(m=u[u.length-1])instanceof Nt&&p.lines+m.lines<=32?(l+=p.lines,c+=p.length+1,u[u.length-1]=new Nt(m.text.concat(p.text),m.length+1+p.length)):(l+p.lines>o&&h(),l+=p.lines,c+=p.length+1,u.push(p))}function h(){l!=0&&(a.push(u.length==1?u[0]:Tr.from(u,c)),c=-1,l=u.length=0)}for(let p of e)d(p);return h(),a.length==1?a[0]:new Tr(a,n)}}Ze.empty=new Nt([""],0);function S3(t){let e=-1;for(let n of t)e+=n.length+1;return e}function Ic(t,e,n=0,r=1e9){for(let o=0,i=0,s=!0;i<t.length&&o<=r;i++){let a=t[i],l=o+a.length;l>=n&&(l>r&&(a=a.slice(0,r-o)),o<n&&(a=a.slice(n-o)),s?(e[e.length-1]+=a,s=!1):e.push(a)),o=l+1}return e}function O1(t,e,n){return Ic(t,[""],e,n)}class ha{constructor(e,n=1){this.dir=n,this.done=!1,this.lineBreak=!1,this.value="",this.nodes=[e],this.offsets=[n>0?1:(e instanceof Nt?e.text.length:e.children.length)<<1]}nextInner(e,n){for(this.done=this.lineBreak=!1;;){let r=this.nodes.length-1,o=this.nodes[r],i=this.offsets[r],s=i>>1,a=o instanceof Nt?o.text.length:o.children.length;if(s==(n>0?a:0)){if(r==0)return this.done=!0,this.value="",this;n>0&&this.offsets[r-1]++,this.nodes.pop(),this.offsets.pop()}else if((i&1)==(n>0?0:1)){if(this.offsets[r]+=n,e==0)return this.lineBreak=!0,this.value=`
|
|
34
34
|
`,this;e--}else if(o instanceof Nt){let l=o.text[s+(n<0?-1:0)];if(this.offsets[r]+=n,l.length>Math.max(0,e))return this.value=e==0?l:n>0?l.slice(e):l.slice(0,l.length-e),this;e-=l.length}else{let l=o.children[s+(n<0?-1:0)];e>l.length?(e-=l.length,this.offsets[r]+=n):(n<0&&this.offsets[r]--,this.nodes.push(l),this.offsets.push(n>0?1:(l instanceof Nt?l.text.length:l.children.length)<<1))}}}next(e=0){return e<0&&(this.nextInner(-e,-this.dir),e=this.value.length),this.nextInner(e,this.dir)}}class T1{constructor(e,n,r){this.value="",this.done=!1,this.cursor=new ha(e,n>r?-1:1),this.pos=n>r?e.length:0,this.from=Math.min(n,r),this.to=Math.max(n,r)}nextInner(e,n){if(n<0?this.pos<=this.from:this.pos>=this.to)return this.value="",this.done=!0,this;e+=Math.max(0,n<0?this.pos-this.to:this.from-this.pos);let r=n<0?this.pos-this.from:this.to-this.pos;e>r&&(e=r),r-=e;let{value:o}=this.cursor.next(e);return this.pos+=(o.length+e)*n,this.value=o.length<=r?o:n<0?o.slice(o.length-r):o.slice(0,r),this.done=!this.value,this}next(e=0){return e<0?e=Math.max(e,this.from-this.pos):e>0&&(e=Math.min(e,this.to-this.pos)),this.nextInner(e,this.cursor.dir)}get lineBreak(){return this.cursor.lineBreak&&this.value!=""}}class _1{constructor(e){this.inner=e,this.afterBreak=!0,this.value="",this.done=!1}next(e=0){let{done:n,lineBreak:r,value:o}=this.inner.next(e);return n&&this.afterBreak?(this.value="",this.afterBreak=!1):n?(this.done=!0,this.value=""):r?this.afterBreak?this.value="":(this.afterBreak=!0,this.next()):(this.value=o,this.afterBreak=!1),this}get lineBreak(){return!1}}typeof Symbol<"u"&&(Ze.prototype[Symbol.iterator]=function(){return this.iter()},ha.prototype[Symbol.iterator]=T1.prototype[Symbol.iterator]=_1.prototype[Symbol.iterator]=function(){return this});class E3{constructor(e,n,r,o){this.from=e,this.to=n,this.number=r,this.text=o}get length(){return this.to-this.from}}function Yi(t,e,n){return e=Math.max(0,Math.min(t.length,e)),[e,Math.max(e,Math.min(t.length,n))]}function Ht(t,e,n=!0,r=!0){return k3(t,e,n,r)}function D3(t){return t>=56320&&t<57344}function A3(t){return t>=55296&&t<56320}function En(t,e){let n=t.charCodeAt(e);if(!A3(n)||e+1==t.length)return n;let r=t.charCodeAt(e+1);return D3(r)?(n-55296<<10)+(r-56320)+65536:n}function Bh(t){return t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode((t>>10)+55296,(t&1023)+56320))}function _r(t){return t<65536?1:2}const Fh=/\r\n?|\n/;var Xt=(function(t){return t[t.Simple=0]="Simple",t[t.TrackDel=1]="TrackDel",t[t.TrackBefore=2]="TrackBefore",t[t.TrackAfter=3]="TrackAfter",t})(Xt||(Xt={}));class Nr{constructor(e){this.sections=e}get length(){let e=0;for(let n=0;n<this.sections.length;n+=2)e+=this.sections[n];return e}get newLength(){let e=0;for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n+1];e+=r<0?this.sections[n]:r}return e}get empty(){return this.sections.length==0||this.sections.length==2&&this.sections[1]<0}iterGaps(e){for(let n=0,r=0,o=0;n<this.sections.length;){let i=this.sections[n++],s=this.sections[n++];s<0?(e(r,o,i),o+=i):o+=s,r+=i}}iterChangedRanges(e,n=!1){Ih(this,e,n)}get invertedDesc(){let e=[];for(let n=0;n<this.sections.length;){let r=this.sections[n++],o=this.sections[n++];o<0?e.push(r,o):e.push(o,r)}return new Nr(e)}composeDesc(e){return this.empty?e:e.empty?this:N1(this,e)}mapDesc(e,n=!1){return e.empty?this:Mh(this,e,n)}mapPos(e,n=-1,r=Xt.Simple){let o=0,i=0;for(let s=0;s<this.sections.length;){let a=this.sections[s++],l=this.sections[s++],c=o+a;if(l<0){if(c>e)return i+(e-o);i+=a}else{if(r!=Xt.Simple&&c>=e&&(r==Xt.TrackDel&&o<e&&c>e||r==Xt.TrackBefore&&o<e||r==Xt.TrackAfter&&c>e))return null;if(c>e||c==e&&n<0&&!a)return e==o||n<0?i:i+l;i+=l}o=c}if(e>o)throw new RangeError(`Position ${e} is out of range for changeset of length ${o}`);return i}touchesRange(e,n=e){for(let r=0,o=0;r<this.sections.length&&o<=n;){let i=this.sections[r++],s=this.sections[r++],a=o+i;if(s>=0&&o<=n&&a>=e)return o<e&&a>n?"cover":!0;o=a}return!1}toString(){let e="";for(let n=0;n<this.sections.length;){let r=this.sections[n++],o=this.sections[n++];e+=(e?" ":"")+r+(o>=0?":"+o:"")}return e}toJSON(){return this.sections}static fromJSON(e){if(!Array.isArray(e)||e.length%2||e.some(n=>typeof n!="number"))throw new RangeError("Invalid JSON representation of ChangeDesc");return new Nr(e)}static create(e){return new Nr(e)}}class zt extends Nr{constructor(e,n){super(e),this.inserted=n}apply(e){if(this.length!=e.length)throw new RangeError("Applying change set to a document with the wrong length");return Ih(this,(n,r,o,i,s)=>e=e.replace(o,o+(r-n),s),!1),e}mapDesc(e,n=!1){return Mh(this,e,n,!0)}invert(e){let n=this.sections.slice(),r=[];for(let o=0,i=0;o<n.length;o+=2){let s=n[o],a=n[o+1];if(a>=0){n[o]=a,n[o+1]=s;let l=o>>1;for(;r.length<l;)r.push(Ze.empty);r.push(s?e.slice(i,i+s):Ze.empty)}i+=s}return new zt(n,r)}compose(e){return this.empty?e:e.empty?this:N1(this,e,!0)}map(e,n=!1){return e.empty?this:Mh(this,e,n,!0)}iterChanges(e,n=!1){Ih(this,e,n)}get desc(){return Nr.create(this.sections)}filter(e){let n=[],r=[],o=[],i=new pa(this);e:for(let s=0,a=0;;){let l=s==e.length?1e9:e[s++];for(;a<l||a==l&&i.len==0;){if(i.done)break e;let u=Math.min(i.len,l-a);on(o,u,-1);let d=i.ins==-1?-1:i.off==0?i.ins:0;on(n,u,d),d>0&&Co(r,n,i.text),i.forward(u),a+=u}let c=e[s++];for(;a<c;){if(i.done)break e;let u=Math.min(i.len,c-a);on(n,u,-1),on(o,u,i.ins==-1?-1:i.off==0?i.ins:0),i.forward(u),a+=u}}return{changes:new zt(n,r),filtered:Nr.create(o)}}toJSON(){let e=[];for(let n=0;n<this.sections.length;n+=2){let r=this.sections[n],o=this.sections[n+1];o<0?e.push(r):o==0?e.push([r]):e.push([r].concat(this.inserted[n>>1].toJSON()))}return e}static of(e,n,r){let o=[],i=[],s=0,a=null;function l(u=!1){if(!u&&!o.length)return;s<n&&on(o,n-s,-1);let d=new zt(o,i);a=a?a.compose(d.map(a)):d,o=[],i=[],s=0}function c(u){if(Array.isArray(u))for(let d of u)c(d);else if(u instanceof zt){if(u.length!=n)throw new RangeError(`Mismatched change set length (got ${u.length}, expected ${n})`);l(),a=a?a.compose(u.map(a)):u}else{let{from:d,to:h=d,insert:p}=u;if(d>h||d<0||h>n)throw new RangeError(`Invalid change range ${d} to ${h} (in doc of length ${n})`);let m=p?typeof p=="string"?Ze.of(p.split(r||Fh)):p:Ze.empty,w=m.length;if(d==h&&w==0)return;d<s&&l(),d>s&&on(o,d-s,-1),on(o,h-d,w),Co(i,o,m),s=h}}return c(e),l(!a),a}static empty(e){return new zt(e?[e,-1]:[],[])}static fromJSON(e){if(!Array.isArray(e))throw new RangeError("Invalid JSON representation of ChangeSet");let n=[],r=[];for(let o=0;o<e.length;o++){let i=e[o];if(typeof i=="number")n.push(i,-1);else{if(!Array.isArray(i)||typeof i[0]!="number"||i.some((s,a)=>a&&typeof s!="string"))throw new RangeError("Invalid JSON representation of ChangeSet");if(i.length==1)n.push(i[0],0);else{for(;r.length<o;)r.push(Ze.empty);r[o]=Ze.of(i.slice(1)),n.push(i[0],r[o].length)}}}return new zt(n,r)}static createSet(e,n){return new zt(e,n)}}function on(t,e,n,r=!1){if(e==0&&n<=0)return;let o=t.length-2;o>=0&&n<=0&&n==t[o+1]?t[o]+=e:o>=0&&e==0&&t[o]==0?t[o+1]+=n:r?(t[o]+=e,t[o+1]+=n):t.push(e,n)}function Co(t,e,n){if(n.length==0)return;let r=e.length-2>>1;if(r<t.length)t[t.length-1]=t[t.length-1].append(n);else{for(;t.length<r;)t.push(Ze.empty);t.push(n)}}function Ih(t,e,n){let r=t.inserted;for(let o=0,i=0,s=0;s<t.sections.length;){let a=t.sections[s++],l=t.sections[s++];if(l<0)o+=a,i+=a;else{let c=o,u=i,d=Ze.empty;for(;c+=a,u+=l,l&&r&&(d=d.append(r[s-2>>1])),!(n||s==t.sections.length||t.sections[s+1]<0);)a=t.sections[s++],l=t.sections[s++];e(o,c,i,u,d),o=c,i=u}}}function Mh(t,e,n,r=!1){let o=[],i=r?[]:null,s=new pa(t),a=new pa(e);for(let l=-1;;){if(s.done&&a.len||a.done&&s.len)throw new Error("Mismatched change set lengths");if(s.ins==-1&&a.ins==-1){let c=Math.min(s.len,a.len);on(o,c,-1),s.forward(c),a.forward(c)}else if(a.ins>=0&&(s.ins<0||l==s.i||s.off==0&&(a.len<s.len||a.len==s.len&&!n))){let c=a.len;for(on(o,a.ins,-1);c;){let u=Math.min(s.len,c);s.ins>=0&&l<s.i&&s.len<=u&&(on(o,0,s.ins),i&&Co(i,o,s.text),l=s.i),s.forward(u),c-=u}a.next()}else if(s.ins>=0){let c=0,u=s.len;for(;u;)if(a.ins==-1){let d=Math.min(u,a.len);c+=d,u-=d,a.forward(d)}else if(a.ins==0&&a.len<u)u-=a.len,a.next();else break;on(o,c,l<s.i?s.ins:0),i&&l<s.i&&Co(i,o,s.text),l=s.i,s.forward(s.len-u)}else{if(s.done&&a.done)return i?zt.createSet(o,i):Nr.create(o);throw new Error("Mismatched change set lengths")}}}function N1(t,e,n=!1){let r=[],o=n?[]:null,i=new pa(t),s=new pa(e);for(let a=!1;;){if(i.done&&s.done)return o?zt.createSet(r,o):Nr.create(r);if(i.ins==0)on(r,i.len,0,a),i.next();else if(s.len==0&&!s.done)on(r,0,s.ins,a),o&&Co(o,r,s.text),s.next();else{if(i.done||s.done)throw new Error("Mismatched change set lengths");{let l=Math.min(i.len2,s.len),c=r.length;if(i.ins==-1){let u=s.ins==-1?-1:s.off?0:s.ins;on(r,l,u,a),o&&u&&Co(o,r,s.text)}else s.ins==-1?(on(r,i.off?0:i.len,l,a),o&&Co(o,r,i.textBit(l))):(on(r,i.off?0:i.len,s.off?0:s.ins,a),o&&!s.off&&Co(o,r,s.text));a=(i.ins>l||s.ins>=0&&s.len>l)&&(a||r.length>c),i.forward2(l),s.forward(l)}}}}class pa{constructor(e){this.set=e,this.i=0,this.next()}next(){let{sections:e}=this.set;this.i<e.length?(this.len=e[this.i++],this.ins=e[this.i++]):(this.len=0,this.ins=-2),this.off=0}get done(){return this.ins==-2}get len2(){return this.ins<0?this.len:this.ins}get text(){let{inserted:e}=this.set,n=this.i-2>>1;return n>=e.length?Ze.empty:e[n]}textBit(e){let{inserted:n}=this.set,r=this.i-2>>1;return r>=n.length&&!e?Ze.empty:n[r].slice(this.off,e==null?void 0:this.off+e)}forward(e){e==this.len?this.next():(this.len-=e,this.off+=e)}forward2(e){this.ins==-1?this.forward(e):e==this.ins?this.next():(this.ins-=e,this.off+=e)}}class ri{constructor(e,n,r){this.from=e,this.to=n,this.flags=r}get anchor(){return this.flags&32?this.to:this.from}get head(){return this.flags&32?this.from:this.to}get empty(){return this.from==this.to}get assoc(){return this.flags&8?-1:this.flags&16?1:0}get bidiLevel(){let e=this.flags&7;return e==7?null:e}get goalColumn(){let e=this.flags>>6;return e==16777215?void 0:e}map(e,n=-1){let r,o;return this.empty?r=o=e.mapPos(this.from,n):(r=e.mapPos(this.from,1),o=e.mapPos(this.to,-1)),r==this.from&&o==this.to?this:new ri(r,o,this.flags)}extend(e,n=e){if(e<=this.anchor&&n>=this.anchor)return ue.range(e,n);let r=Math.abs(e-this.anchor)>Math.abs(n-this.anchor)?e:n;return ue.range(this.anchor,r)}eq(e,n=!1){return this.anchor==e.anchor&&this.head==e.head&&this.goalColumn==e.goalColumn&&(!n||!this.empty||this.assoc==e.assoc)}toJSON(){return{anchor:this.anchor,head:this.head}}static fromJSON(e){if(!e||typeof e.anchor!="number"||typeof e.head!="number")throw new RangeError("Invalid JSON representation for SelectionRange");return ue.range(e.anchor,e.head)}static create(e,n,r){return new ri(e,n,r)}}class ue{constructor(e,n){this.ranges=e,this.mainIndex=n}map(e,n=-1){return e.empty?this:ue.create(this.ranges.map(r=>r.map(e,n)),this.mainIndex)}eq(e,n=!1){if(this.ranges.length!=e.ranges.length||this.mainIndex!=e.mainIndex)return!1;for(let r=0;r<this.ranges.length;r++)if(!this.ranges[r].eq(e.ranges[r],n))return!1;return!0}get main(){return this.ranges[this.mainIndex]}asSingle(){return this.ranges.length==1?this:new ue([this.main],0)}addRange(e,n=!0){return ue.create([e].concat(this.ranges),n?0:this.mainIndex+1)}replaceRange(e,n=this.mainIndex){let r=this.ranges.slice();return r[n]=e,ue.create(r,this.mainIndex)}toJSON(){return{ranges:this.ranges.map(e=>e.toJSON()),main:this.mainIndex}}static fromJSON(e){if(!e||!Array.isArray(e.ranges)||typeof e.main!="number"||e.main>=e.ranges.length)throw new RangeError("Invalid JSON representation for EditorSelection");return new ue(e.ranges.map(n=>ri.fromJSON(n)),e.main)}static single(e,n=e){return new ue([ue.range(e,n)],0)}static create(e,n=0){if(e.length==0)throw new RangeError("A selection needs at least one range");for(let r=0,o=0;o<e.length;o++){let i=e[o];if(i.empty?i.from<=r:i.from<r)return ue.normalized(e.slice(),n);r=i.to}return new ue(e,n)}static cursor(e,n=0,r,o){return ri.create(e,e,(n==0?0:n<0?8:16)|(r==null?7:Math.min(6,r))|(o??16777215)<<6)}static range(e,n,r,o){let i=(r??16777215)<<6|(o==null?7:Math.min(6,o));return n<e?ri.create(n,e,48|i):ri.create(e,n,(n>e?8:0)|i)}static normalized(e,n=0){let r=e[n];e.sort((o,i)=>o.from-i.from),n=e.indexOf(r);for(let o=1;o<e.length;o++){let i=e[o],s=e[o-1];if(i.empty?i.from<=s.to:i.from<s.to){let a=s.from,l=Math.max(i.to,s.to);o<=n&&n--,e.splice(--o,2,i.anchor>i.head?ue.range(l,a):ue.range(a,l))}}return new ue(e,n)}}function B1(t,e){for(let n of t.ranges)if(n.to>e)throw new RangeError("Selection points outside of document")}let Ph=0;class ke{constructor(e,n,r,o,i){this.combine=e,this.compareInput=n,this.compare=r,this.isStatic=o,this.id=Ph++,this.default=e([]),this.extensions=typeof i=="function"?i(this):i}get reader(){return this}static define(e={}){return new ke(e.combine||(n=>n),e.compareInput||((n,r)=>n===r),e.compare||(e.combine?(n,r)=>n===r:Lh),!!e.static,e.enables)}of(e){return new Mc([],this,0,e)}compute(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Mc(e,this,1,n)}computeN(e,n){if(this.isStatic)throw new Error("Can't compute a static facet");return new Mc(e,this,2,n)}from(e,n){return n||(n=r=>r),this.compute([e],r=>n(r.field(e)))}}function Lh(t,e){return t==e||t.length==e.length&&t.every((n,r)=>n===e[r])}class Mc{constructor(e,n,r,o){this.dependencies=e,this.facet=n,this.type=r,this.value=o,this.id=Ph++}dynamicSlot(e){var n;let r=this.value,o=this.facet.compareInput,i=this.id,s=e[i]>>1,a=this.type==2,l=!1,c=!1,u=[];for(let d of this.dependencies)d=="doc"?l=!0:d=="selection"?c=!0:(((n=e[d.id])!==null&&n!==void 0?n:1)&1)==0&&u.push(e[d.id]);return{create(d){return d.values[s]=r(d),1},update(d,h){if(l&&h.docChanged||c&&(h.docChanged||h.selection)||$h(d,u)){let p=r(d);if(a?!F1(p,d.values[s],o):!o(p,d.values[s]))return d.values[s]=p,1}return 0},reconfigure:(d,h)=>{let p,m=h.config.address[i];if(m!=null){let w=Hc(h,m);if(this.dependencies.every(v=>v instanceof ke?h.facet(v)===d.facet(v):v instanceof Wt?h.field(v,!1)==d.field(v,!1):!0)||(a?F1(p=r(d),w,o):o(p=r(d),w)))return d.values[s]=w,0}else p=r(d);return d.values[s]=p,1}}}}function F1(t,e,n){if(t.length!=e.length)return!1;for(let r=0;r<t.length;r++)if(!n(t[r],e[r]))return!1;return!0}function $h(t,e){let n=!1;for(let r of e)ga(t,r)&1&&(n=!0);return n}function O3(t,e,n){let r=n.map(l=>t[l.id]),o=n.map(l=>l.type),i=r.filter(l=>!(l&1)),s=t[e.id]>>1;function a(l){let c=[];for(let u=0;u<r.length;u++){let d=Hc(l,r[u]);if(o[u]==2)for(let h of d)c.push(h);else c.push(d)}return e.combine(c)}return{create(l){for(let c of r)ga(l,c);return l.values[s]=a(l),1},update(l,c){if(!$h(l,i))return 0;let u=a(l);return e.compare(u,l.values[s])?0:(l.values[s]=u,1)},reconfigure(l,c){let u=$h(l,r),d=c.config.facets[e.id],h=c.facet(e);if(d&&!u&&Lh(n,d))return l.values[s]=h,0;let p=a(l);return e.compare(p,h)?(l.values[s]=h,0):(l.values[s]=p,1)}}}const Pc=ke.define({static:!0});class Wt{constructor(e,n,r,o,i){this.id=e,this.createF=n,this.updateF=r,this.compareF=o,this.spec=i,this.provides=void 0}static define(e){let n=new Wt(Ph++,e.create,e.update,e.compare||((r,o)=>r===o),e);return e.provide&&(n.provides=e.provide(n)),n}create(e){let n=e.facet(Pc).find(r=>r.field==this);return((n==null?void 0:n.create)||this.createF)(e)}slot(e){let n=e[this.id]>>1;return{create:r=>(r.values[n]=this.create(r),1),update:(r,o)=>{let i=r.values[n],s=this.updateF(i,o);return this.compareF(i,s)?0:(r.values[n]=s,1)},reconfigure:(r,o)=>{let i=r.facet(Pc),s=o.facet(Pc),a;return(a=i.find(l=>l.field==this))&&a!=s.find(l=>l.field==this)?(r.values[n]=a.create(r),1):o.config.address[this.id]!=null?(r.values[n]=o.field(this),0):(r.values[n]=this.create(r),1)}}}init(e){return[this,Pc.of({field:this,create:e})]}get extension(){return this}}const oi={lowest:4,low:3,default:2,high:1,highest:0};function ma(t){return e=>new I1(e,t)}const ko={highest:ma(oi.highest),high:ma(oi.high),default:ma(oi.default),low:ma(oi.low),lowest:ma(oi.lowest)};class I1{constructor(e,n){this.inner=e,this.prec=n}}class Lc{of(e){return new Hh(this,e)}reconfigure(e){return Lc.reconfigure.of({compartment:this,extension:e})}get(e){return e.config.compartments.get(this)}}class Hh{constructor(e,n){this.compartment=e,this.inner=n}}class $c{constructor(e,n,r,o,i,s){for(this.base=e,this.compartments=n,this.dynamicSlots=r,this.address=o,this.staticValues=i,this.facets=s,this.statusTemplate=[];this.statusTemplate.length<r.length;)this.statusTemplate.push(0)}staticFacet(e){let n=this.address[e.id];return n==null?e.default:this.staticValues[n>>1]}static resolve(e,n,r){let o=[],i=Object.create(null),s=new Map;for(let h of T3(e,n,s))h instanceof Wt?o.push(h):(i[h.facet.id]||(i[h.facet.id]=[])).push(h);let a=Object.create(null),l=[],c=[];for(let h of o)a[h.id]=c.length<<1,c.push(p=>h.slot(p));let u=r==null?void 0:r.config.facets;for(let h in i){let p=i[h],m=p[0].facet,w=u&&u[h]||[];if(p.every(v=>v.type==0))if(a[m.id]=l.length<<1|1,Lh(w,p))l.push(r.facet(m));else{let v=m.combine(p.map(y=>y.value));l.push(r&&m.compare(v,r.facet(m))?r.facet(m):v)}else{for(let v of p)v.type==0?(a[v.id]=l.length<<1|1,l.push(v.value)):(a[v.id]=c.length<<1,c.push(y=>v.dynamicSlot(y)));a[m.id]=c.length<<1,c.push(v=>O3(v,m,p))}}let d=c.map(h=>h(a));return new $c(e,s,d,a,l,i)}}function T3(t,e,n){let r=[[],[],[],[],[]],o=new Map;function i(s,a){let l=o.get(s);if(l!=null){if(l<=a)return;let c=r[l].indexOf(s);c>-1&&r[l].splice(c,1),s instanceof Hh&&n.delete(s.compartment)}if(o.set(s,a),Array.isArray(s))for(let c of s)i(c,a);else if(s instanceof Hh){if(n.has(s.compartment))throw new RangeError("Duplicate use of compartment in extensions");let c=e.get(s.compartment)||s.inner;n.set(s.compartment,c),i(c,a)}else if(s instanceof I1)i(s.inner,s.prec);else if(s instanceof Wt)r[a].push(s),s.provides&&i(s.provides,a);else if(s instanceof Mc)r[a].push(s),s.facet.extensions&&i(s.facet.extensions,oi.default);else{let c=s.extension;if(!c)throw new Error(`Unrecognized extension value in extension set (${s}). This sometimes happens because multiple instances of @codemirror/state are loaded, breaking instanceof checks.`);i(c,a)}}return i(t,oi.default),r.reduce((s,a)=>s.concat(a))}function ga(t,e){if(e&1)return 2;let n=e>>1,r=t.status[n];if(r==4)throw new Error("Cyclic dependency between fields and/or facets");if(r&2)return r;t.status[n]=4;let o=t.computeSlot(t,t.config.dynamicSlots[n]);return t.status[n]=2|o}function Hc(t,e){return e&1?t.config.staticValues[e>>1]:t.values[e>>1]}const M1=ke.define(),zh=ke.define({combine:t=>t.some(e=>e),static:!0}),P1=ke.define({combine:t=>t.length?t[0]:void 0,static:!0}),L1=ke.define(),$1=ke.define(),H1=ke.define(),z1=ke.define({combine:t=>t.length?t[0]:!1});class Br{constructor(e,n){this.type=e,this.value=n}static define(){return new _3}}class _3{of(e){return new Br(this,e)}}class N3{constructor(e){this.map=e}of(e){return new Pe(this,e)}}class Pe{constructor(e,n){this.type=e,this.value=n}map(e){let n=this.type.map(this.value,e);return n===void 0?void 0:n==this.value?this:new Pe(this.type,n)}is(e){return this.type==e}static define(e={}){return new N3(e.map||(n=>n))}static mapEffects(e,n){if(!e.length)return e;let r=[];for(let o of e){let i=o.map(n);i&&r.push(i)}return r}}Pe.reconfigure=Pe.define(),Pe.appendConfig=Pe.define();class Ft{constructor(e,n,r,o,i,s){this.startState=e,this.changes=n,this.selection=r,this.effects=o,this.annotations=i,this.scrollIntoView=s,this._doc=null,this._state=null,r&&B1(r,n.newLength),i.some(a=>a.type==Ft.time)||(this.annotations=i.concat(Ft.time.of(Date.now())))}static create(e,n,r,o,i,s){return new Ft(e,n,r,o,i,s)}get newDoc(){return this._doc||(this._doc=this.changes.apply(this.startState.doc))}get newSelection(){return this.selection||this.startState.selection.map(this.changes)}get state(){return this._state||this.startState.applyTransaction(this),this._state}annotation(e){for(let n of this.annotations)if(n.type==e)return n.value}get docChanged(){return!this.changes.empty}get reconfigured(){return this.startState.config!=this.state.config}isUserEvent(e){let n=this.annotation(Ft.userEvent);return!!(n&&(n==e||n.length>e.length&&n.slice(0,e.length)==e&&n[e.length]=="."))}}Ft.time=Br.define(),Ft.userEvent=Br.define(),Ft.addToHistory=Br.define(),Ft.remote=Br.define();function B3(t,e){let n=[];for(let r=0,o=0;;){let i,s;if(r<t.length&&(o==e.length||e[o]>=t[r]))i=t[r++],s=t[r++];else if(o<e.length)i=e[o++],s=e[o++];else return n;!n.length||n[n.length-1]<i?n.push(i,s):n[n.length-1]<s&&(n[n.length-1]=s)}}function j1(t,e,n){var r;let o,i,s;return n?(o=e.changes,i=zt.empty(e.changes.length),s=t.changes.compose(e.changes)):(o=e.changes.map(t.changes),i=t.changes.mapDesc(e.changes,!0),s=t.changes.compose(o)),{changes:s,selection:e.selection?e.selection.map(i):(r=t.selection)===null||r===void 0?void 0:r.map(o),effects:Pe.mapEffects(t.effects,o).concat(Pe.mapEffects(e.effects,i)),annotations:t.annotations.length?t.annotations.concat(e.annotations):e.annotations,scrollIntoView:t.scrollIntoView||e.scrollIntoView}}function jh(t,e,n){let r=e.selection,o=Xi(e.annotations);return e.userEvent&&(o=o.concat(Ft.userEvent.of(e.userEvent))),{changes:e.changes instanceof zt?e.changes:zt.of(e.changes||[],n,t.facet(P1)),selection:r&&(r instanceof ue?r:ue.single(r.anchor,r.head)),effects:Xi(e.effects),annotations:o,scrollIntoView:!!e.scrollIntoView}}function V1(t,e,n){let r=jh(t,e.length?e[0]:{},t.doc.length);e.length&&e[0].filter===!1&&(n=!1);for(let i=1;i<e.length;i++){e[i].filter===!1&&(n=!1);let s=!!e[i].sequential;r=j1(r,jh(t,e[i],s?r.changes.newLength:t.doc.length),s)}let o=Ft.create(t,r.changes,r.selection,r.effects,r.annotations,r.scrollIntoView);return I3(n?F3(o):o)}function F3(t){let e=t.startState,n=!0;for(let o of e.facet(L1)){let i=o(t);if(i===!1){n=!1;break}Array.isArray(i)&&(n=n===!0?i:B3(n,i))}if(n!==!0){let o,i;if(n===!1)i=t.changes.invertedDesc,o=zt.empty(e.doc.length);else{let s=t.changes.filter(n);o=s.changes,i=s.filtered.mapDesc(s.changes).invertedDesc}t=Ft.create(e,o,t.selection&&t.selection.map(i),Pe.mapEffects(t.effects,i),t.annotations,t.scrollIntoView)}let r=e.facet($1);for(let o=r.length-1;o>=0;o--){let i=r[o](t);i instanceof Ft?t=i:Array.isArray(i)&&i.length==1&&i[0]instanceof Ft?t=i[0]:t=V1(e,Xi(i),!1)}return t}function I3(t){let e=t.startState,n=e.facet(H1),r=t;for(let o=n.length-1;o>=0;o--){let i=n[o](t);i&&Object.keys(i).length&&(r=j1(r,jh(e,i,t.changes.newLength),!0))}return r==t?t:Ft.create(e,t.changes,t.selection,r.effects,r.annotations,r.scrollIntoView)}const M3=[];function Xi(t){return t==null?M3:Array.isArray(t)?t:[t]}var yt=(function(t){return t[t.Word=0]="Word",t[t.Space=1]="Space",t[t.Other=2]="Other",t})(yt||(yt={}));const P3=/[\u00df\u0587\u0590-\u05f4\u0600-\u06ff\u3040-\u309f\u30a0-\u30ff\u3400-\u4db5\u4e00-\u9fcc\uac00-\ud7af]/;let Vh;try{Vh=new RegExp("[\\p{Alphabetic}\\p{Number}_]","u")}catch{}function L3(t){if(Vh)return Vh.test(t);for(let e=0;e<t.length;e++){let n=t[e];if(/\w/.test(n)||n>""&&(n.toUpperCase()!=n.toLowerCase()||P3.test(n)))return!0}return!1}function $3(t){return e=>{if(!/\S/.test(e))return yt.Space;if(L3(e))return yt.Word;for(let n=0;n<t.length;n++)if(e.indexOf(t[n])>-1)return yt.Word;return yt.Other}}class Xe{constructor(e,n,r,o,i,s){this.config=e,this.doc=n,this.selection=r,this.values=o,this.status=e.statusTemplate.slice(),this.computeSlot=i,s&&(s._state=this);for(let a=0;a<this.config.dynamicSlots.length;a++)ga(this,a<<1);this.computeSlot=null}field(e,n=!0){let r=this.config.address[e.id];if(r==null){if(n)throw new RangeError("Field is not present in this state");return}return ga(this,r),Hc(this,r)}update(...e){return V1(this,e,!0)}applyTransaction(e){let n=this.config,{base:r,compartments:o}=n;for(let a of e.effects)a.is(Lc.reconfigure)?(n&&(o=new Map,n.compartments.forEach((l,c)=>o.set(c,l)),n=null),o.set(a.value.compartment,a.value.extension)):a.is(Pe.reconfigure)?(n=null,r=a.value):a.is(Pe.appendConfig)&&(n=null,r=Xi(r).concat(a.value));let i;n?i=e.startState.values.slice():(n=$c.resolve(r,o,this),i=new Xe(n,this.doc,this.selection,n.dynamicSlots.map(()=>null),(l,c)=>c.reconfigure(l,this),null).values);let s=e.startState.facet(zh)?e.newSelection:e.newSelection.asSingle();new Xe(n,e.newDoc,s,i,(a,l)=>l.update(a,e),e)}replaceSelection(e){return typeof e=="string"&&(e=this.toText(e)),this.changeByRange(n=>({changes:{from:n.from,to:n.to,insert:e},range:ue.cursor(n.from+e.length)}))}changeByRange(e){let n=this.selection,r=e(n.ranges[0]),o=this.changes(r.changes),i=[r.range],s=Xi(r.effects);for(let a=1;a<n.ranges.length;a++){let l=e(n.ranges[a]),c=this.changes(l.changes),u=c.map(o);for(let h=0;h<a;h++)i[h]=i[h].map(u);let d=o.mapDesc(c,!0);i.push(l.range.map(d)),o=o.compose(u),s=Pe.mapEffects(s,u).concat(Pe.mapEffects(Xi(l.effects),d))}return{changes:o,selection:ue.create(i,n.mainIndex),effects:s}}changes(e=[]){return e instanceof zt?e:zt.of(e,this.doc.length,this.facet(Xe.lineSeparator))}toText(e){return Ze.of(e.split(this.facet(Xe.lineSeparator)||Fh))}sliceDoc(e=0,n=this.doc.length){return this.doc.sliceString(e,n,this.lineBreak)}facet(e){let n=this.config.address[e.id];return n==null?e.default:(ga(this,n),Hc(this,n))}toJSON(e){let n={doc:this.sliceDoc(),selection:this.selection.toJSON()};if(e)for(let r in e){let o=e[r];o instanceof Wt&&this.config.address[o.id]!=null&&(n[r]=o.spec.toJSON(this.field(e[r]),this))}return n}static fromJSON(e,n={},r){if(!e||typeof e.doc!="string")throw new RangeError("Invalid JSON representation for EditorState");let o=[];if(r){for(let i in r)if(Object.prototype.hasOwnProperty.call(e,i)){let s=r[i],a=e[i];o.push(s.init(l=>s.spec.fromJSON(a,l)))}}return Xe.create({doc:e.doc,selection:ue.fromJSON(e.selection),extensions:n.extensions?o.concat([n.extensions]):o})}static create(e={}){let n=$c.resolve(e.extensions||[],new Map),r=e.doc instanceof Ze?e.doc:Ze.of((e.doc||"").split(n.staticFacet(Xe.lineSeparator)||Fh)),o=e.selection?e.selection instanceof ue?e.selection:ue.single(e.selection.anchor,e.selection.head):ue.single(0);return B1(o,r.length),n.staticFacet(zh)||(o=o.asSingle()),new Xe(n,r,o,n.dynamicSlots.map(()=>null),(i,s)=>s.create(i),null)}get tabSize(){return this.facet(Xe.tabSize)}get lineBreak(){return this.facet(Xe.lineSeparator)||`
|
|
@@ -67,7 +67,7 @@ The error may be correlated with this previous error:
|
|
|
67
67
|
user-select: none;
|
|
68
68
|
`,s.textContent=this.text,s}ignoreEvent(){return!0}}const r=new du({regexp:/{{(.*?)}}/g,decoration:o=>De.replace({widget:new n(o[1])})});return bt.fromClass(class{constructor(o){it(this,"placeholders");this.placeholders=r.createDeco(o)}update(o){this.placeholders=r.updateDeco(o,this.placeholders)}},{decorations:o=>o.placeholders,provide:o=>we.atomicRanges.of(i=>{var s;return((s=i.plugin(o))==null?void 0:s.placeholders)||De.none})})},oj=({completions:t,keywords:e,placeholderThemes:n,mode:r,functions:o,keywordsColor:i,keywordsClassName:s,hintPaths:a})=>[e!=null&&e.length?nj(e,i,s):null,Jz,rj(n,r),we.lineWrapping,FE({override:[Rz(t),a!=null&&a.length?Zz(a):null].filter(l=>!!l)}),Qz(o)].filter(l=>!!l),ij=({completions:t,onValueChange:e,keywords:n,handleFocus:r,placeholderThemes:o,mode:i,functions:s,height:a,width:l,keywordsColor:c,keywordsClassName:u,defaultValue:d,hintPaths:h,extensions:p,disabled:m,id:w},v)=>{const y=b.useRef(null),g=b.useCallback((D,S)=>{var N;const{view:_}=y.current;if(!_)return;const{state:O}=_;if(!O)return;const[B]=((N=O==null?void 0:O.selection)==null?void 0:N.ranges)||[];_.focus(),_.dispatch({changes:{from:B.from,to:B.to,insert:D},selection:{anchor:B.from+D.length}})},[]),k=b.useCallback(()=>{const{view:D}=y.current;D.dispatch({changes:{from:0,to:D.state.doc.length,insert:""},selection:{anchor:0}}),D.focus()},[]),A=b.useCallback(D=>{const{view:S}=y.current;S.dispatch({changes:{from:0,to:S.state.doc.length,insert:D},selection:{anchor:D.length}}),S.focus()},[]);b.useImperativeHandle(v,()=>({insertText:g,clearText:k,setText:A,originEditorRef:y}),[g,k,A]);const C=b.useMemo(()=>[...oj({completions:t,keywords:n,placeholderThemes:o,mode:i,functions:s,keywordsColor:c,keywordsClassName:u,hintPaths:h}),...p||[]],[t,n,o,i,s,c,u,h,p]),E=b.useCallback(D=>{e&&e(D)},[e]);return f.jsx(Nm,{id:w,readOnly:m,height:a,width:l,onFocus:r,extensions:C,theme:pS,onChange:E,value:d,ref:y})},sj=b.forwardRef(ij);function aj(t){const e=b.useMemo(()=>er(),[]),n=b.useRef(null),{event$:r}=b.useContext($r),o=Ct();return r.useSubscription(i=>{var s,a;if(i.type==="insert"&&i.currentInputId===e){const l=i.expression;(s=n==null?void 0:n.current)!=null&&s.insertText&&((a=n==null?void 0:n.current)==null||a.insertText(l,!1))}}),f.jsx(sj,{handleFocus:()=>{o&&(r.emit({type:"visible",visible:!0}),r.emit({type:"setCurrentInputId",currentInputId:e}))},id:e,ref:n,mode:"name",onValueChange:i=>{var s,a;(s=t.onChange)==null||s.call(t,i),(a=t.onValueChange)==null||a.call(t,i)},defaultValue:t.value,placeholderThemes:Xz,completions:[],functions:[],height:"200px",width:"100%"})}const lj=/{{(.*?)}}/,cj=(t,e)=>t?t.split(e).map((n,r)=>r%2?{type:"tag",value:n,children:[{text:n}]}:{text:n??""}):[{text:""}],Xu=(t,e)=>((t==null?void 0:t.split(`
|
|
69
69
|
`))??[""]).map(r=>({type:"paragraph",className:"textbox",children:cj(String(r??""),e)})),uj=t=>{const e=ae.useReactFlow();return b.useMemo(()=>{const n=t.split("."),r=n[0],o=`{{${t}}}`;if(r==="global")return{exists:!0,type:"global",tooltip:n.slice(1).join("."),fullPath:o,backgroundColor:"#ECFDF5",borderColor:"#10B981",textColor:"#065F46",iconColor:"#10B981"};if(ut.includes(["sys_tenant_id","response"],r))return{exists:!0,type:"builtin",tooltip:Yu.getBuiltinVariableTips(r),fullPath:o,backgroundColor:"#F3E8FF",borderColor:"#A855F7",textColor:"#6B21A8",iconColor:"#A855F7"};const i=r==null?void 0:r.slice(1),a=e.getNodes().find(h=>h.id===i);if(!a)return{exists:!1,type:"node",tooltip:R("link.flow.cannot_find_variable_output_node"),fullPath:o,backgroundColor:"#FEF2F2",borderColor:"#EF4444",textColor:"#991B1B",iconColor:"#EF4444"};const l=a.data??{},c=String(l.label||l.name||i),u=l.note;return{exists:!0,type:"node",icon:typeof l.icon=="string"?l.icon:Yu.getNodeIcon(i)??void 0,tooltip:c+(u?` (${u})`:""),fullPath:o,backgroundColor:"#EBF5FF",borderColor:"#3B82F6",textColor:"#1E40AF",iconColor:"#3B82F6"}},[t,e])},dj=(t,e)=>{const n=e.exec(t);if(!n)return null;const o=t.slice(-2)==="}}";return{tagContent:n[1].trimStart(),tagLength:n[0].length,tagStartIndex:n.index,isTagLastItem:o}},lD=(t,e,n)=>{const r=[{type:"tag",value:e,children:[{text:e}]},{text:""}];ce.insertNodes(t,r,n)},fj=(t,e)=>[...t.slice(0,-1),t[t.length-1]+e],hj=({attributes:t,element:e,children:n})=>f.jsx("p",{...t,children:n}),pj=({attributes:t,element:e,children:n,removeTagButton:r,transformInputText:o,transformInputElement:i})=>{const s=F2(),a=N2(),l=uj((e==null?void 0:e.value)||""),c=()=>l.type==="global"?f.jsx(Z.GlobalOutlined,{className:"tag-icon",style:{color:l.iconColor}}):l.type==="builtin"?f.jsx(Z.SettingOutlined,{className:"tag-icon",style:{color:l.iconColor}}):l.icon?f.jsx("img",{src:l.icon,alt:"",className:"tag-icon"}):f.jsx("span",{className:"tag-icon default-icon",style:{backgroundColor:l.exists?"#EBF5FF":"#FEF2F2",color:l.iconColor},children:"N"});return f.jsx(x.Tooltip,{defaultOpen:!l.exists,overlayClassName:"variable-tag-tooltip",placement:"top",getPopupContainer:()=>document.querySelector(".nodes-config-content")??document.body,title:f.jsxs("div",{className:"tag-tooltip-content",children:[f.jsx("div",{className:"tag-tooltip-header",children:f.jsxs("span",{className:"tag-tooltip-type",children:[l.type==="node"&&"节点变量",l.type==="global"&&"全局变量",l.type==="builtin"&&"系统变量"]})}),f.jsx("div",{className:"tag-tooltip-name",children:l.tooltip}),f.jsx("div",{className:"tag-tooltip-path",children:l.fullPath}),l.value&&f.jsxs("div",{className:"tag-tooltip-value",children:[f.jsx("span",{className:"tag-tooltip-value-label",children:"当前值:"}),f.jsx("span",{className:"tag-tooltip-value-text",children:l.value})]})]}),arrow:{pointAtCenter:!0},children:f.jsxs("span",{...t,className:`tag-wrapper ${l.exists?"":"tag-invalid"}`,style:{boxShadow:s&&a?`0 0 0 2px ${l.borderColor}40`:"none",borderColor:l.borderColor,backgroundColor:l.backgroundColor},children:[c(),f.jsxs("span",{className:`tag-text ${r?"tag-text-right-padding":""}`,style:{color:l.textColor},children:[n,o?f.jsx("span",{children:o(e==null?void 0:e.value)}):i?i(e==null?void 0:e.value):f.jsx("span",{children:e==null?void 0:e.value})]})]})})},mj=({attributes:t,element:e,children:n})=>f.jsx("p",{...t,children:n}),gj=(t,e)=>{const{isInline:n,isVoid:r,normalizeNode:o}=t;return t.isInline=i=>i.type==="tag"?!0:n(i),t.isVoid=i=>i.type==="tag"?!0:r(i),t.normalizeNode=([i,s])=>{if(!(i!=null&&i.text)){o([i,s]);return}const a=ge.string(i),l=dj(a,e);if(l){const{tagContent:c,tagLength:u,tagStartIndex:d,isTagLastItem:h}=l,p={path:s,offset:d};ce.delete(t,{at:p,distance:u,unit:"character"}),lD(t,c,{at:p}),h&&ce.select(t,{path:fj(s,1),offset:0})}o([i,s])},t},wj=t=>{var n;const e=(n=t==null?void 0:t.children)==null?void 0:n.map(r=>r.type==="tag"?`{{${r.value}}}`:r.text);return Array.isArray(e)?e.join(""):""},vj=t=>(t??[]).map(n=>wj(n)).join(`
|
|
70
|
-
`),yj=b.forwardRef(({onValueChange:t=u=>{},removeTagButton:e=!1,initValue:n,onFocus:r,addImageElement:o,transformInputText:i,transformInputElement:s,textAreaMode:a,capturePattern:l=lj},c)=>{const u=b.useRef(null),d=b.useMemo(()=>gj(cC(xy()),l),[]),[h,p]=b.useState(Xu(n,l));let m=n;const w=b.useCallback(({element:A,children:C,attributes:E})=>{switch(A.type){case"paragraph":return f.jsx(mj,{attributes:E,element:A,children:C});case"tag":return f.jsx(pj,{attributes:E,element:A,removeTagButton:e,addImageElement:o,transformInputText:i,transformInputElement:s,children:C});default:return f.jsx(hj,{attributes:E,element:A,children:C})}},[]);b.useEffect(()=>{p(Xu(n,l))},[n]);const v=b.useCallback(A=>{u.current=d.selection;const C=vj(A);C!==m&&(m=A,p(A),t(C))},[]),y=A=>{ce.delete(d,{at:[0]});const C=Xu(A,l);d.children=Xu("",l),ce.insertNodes(d,C,{at:[0]})},g=A=>{lD(d,A,{at:u.current.focus}),ce.move(d,{distance:h.length-1})};b.useImperativeHandle(c,()=>({insertTag:g,setValueByParent:y}));const k=Ct();return f.jsx(lC,{editor:d,initialValue:h,onChange:v,children:f.jsx(oC,{style:a?{minHeight:60,maxHeight:200}:{maxHeight:150},onFocus:r,value:h,readOnly:!k,spellCheck:!1,className:"ce-tag_input",renderElement:w})})}),cD=t=>f.jsx("div",{style:{display:t.show?"block":"none",height:"100%",width:"100%",...t.style??{}},children:t.children}),tr=t=>{const e=b.useMemo(()=>er(),[]),{event$:n}=b.useContext($r),r=b.useRef(null),[o,i]=b.useState(""),s=dt.useReactive({innerValueType:"",radioType:"",openEditorNumber:0});b.useEffect(()=>{s.radioType=t.valueType},[t.valueType,s]),n.useSubscription(u=>{var d,h,p;if(u.type==="insert"&&u.currentInputId===e){(h=r==null?void 0:(d=r.current).insertTag)==null||h.call(d,u.expression.slice(2,-2));const m=(o??"")+(t.valueType==="FIX_VALUE"?u.expression.slice(2,-2):u.expression);i(m),(p=t.onChange)==null||p.call(t,m)}});const a=b.useMemo(()=>!t.borrow&&["JS_EXP","ADAPTOR"].includes(t.valueType),[t.borrow,t.valueType]);b.useEffect(()=>{i(t.value)},[t.value]);const l=u=>{var d;(d=t.onChange)==null||d.call(t,u)},c=u=>{var d;i(u),(d=t.onChange)==null||d.call(t,u)};return f.jsxs(Yz,{id:e,canEditInEditor:!t.disableIDE,openEditorNumber:s.openEditorNumber,nodeId:t.nodeId,value:t.value,onFinish:u=>{r.current.setValueByParent(u)},children:[a&&f.jsx("div",{style:{textAlign:"right",position:"absolute",top:-34,right:2},children:f.jsxs(x.Radio.Group,{value:s.radioType,onChange:u=>{s.radioType=u.target.value,s.radioType==="ADAPTOR"&&r.current.setValueByParent(o)},size:"small",style:{marginTop:16},children:[f.jsx(x.Radio.Button,{style:{height:18,fontSize:10,display:"inline-flex",alignItems:"center"},value:"ADAPTOR",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.string"})}),f.jsx(x.Radio.Button,{style:{height:18,fontSize:10,display:"inline-flex",alignItems:"center"},value:"JS_EXP",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.script"})})]})}),f.jsx(cD,{show:s.radioType==="ADAPTOR"||!a&&s.radioType!=="PLAIN_CODE",children:f.jsx(yj,{ref:r,disabled:t.disabled,textAreaMode:t.textAreaMode,initValue:t.value,onFocus:()=>{["JS_EXP","FIX_VALUE","ADAPTOR","PLAIN_TEXT","PLAIN_CODE"].includes(t.valueType)&&(n.emit({type:"visible",visible:!0}),n.emit({type:"setCurrentInputId",currentInputId:e}))},removeTagButton:!1,onValueChange:l,addImageElement:u=>{const h=(u==null?void 0:u.split(".")[0]).slice(1),p=Yu.getConfig().icons.get(h);return p?f.jsx("img",{src:p,alt:h,onError:m=>{m.target.src="/uc/images/default_connector.png"}}):f.jsx(Z.ThunderboltOutlined,{})},transformInputText:u=>ut.includes(["sys_tenant_id","response"],u)?u:u.split(".").slice(1).join("."),transformInputElement:u=>f.jsx("span",{style:{color:"blue"},children:u})})}),f.jsxs(cD,{show:(s.radioType==="JS_EXP"||s.radioType==="PLAIN_CODE")&&(s.radioType==="PLAIN_CODE"||a),style:{position:"relative"},children:[f.jsx("div",{children:f.jsx(aj,{...t,onValueChange:c})}),f.jsx("span",{onClick:()=>{s.openEditorNumber++},style:{position:"absolute",right:16,top:4,color:"white",fontSize:16,cursor:"pointer"},children:f.jsx(Z.FullscreenOutlined,{})})]})]})},bj=({value:t=[],onChange:e,valueType:n})=>{const r=u=>{let d=[...o.items];d=d.filter(h=>h.id!==u),e==null||e(d)},o=dt.useReactive({items:[]}),i=u=>{const d=u.which||u.keyCode;(d===37||d===229)&&u.preventDefault()};b.useEffect(()=>{const u=Array.isArray(t)?t:[];o.items=u.map(d=>({...d,id:d.id??er()}))},[t]);const s=()=>{e==null||e([...o.items,{key:"",value:"",id:er()}])},a=(u,d)=>{e==null||e(o.items.map(h=>h.id===u?{...h,key:d}:h))},l=(u,d)=>{e==null||e(o.items.map(h=>h.id===u?{...h,value:d}:h))},c=Ct();return f.jsxs("div",{children:[o.items.length?o.items.map((u,d)=>f.jsxs(x.Space,{size:"small",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[f.jsx(x.Input,{defaultValue:u.key,onKeyDown:i,onChange:h=>{var p;a(u.id,(p=h.target.value)==null?void 0:p.replace(/'/g,""))},placeholder:"Key"}),f.jsx("span",{style:{display:"inline-block",transform:"translateY(2px)",width:300},children:f.jsx(tr,{borrow:!0,disableIDE:!0,placeholder:"Value",style:{width:300},value:u.value,onChange:h=>l(u.id,h),valueType:n,nodeId:""})}),c&&f.jsx(Z.DeleteOutlined,{onClick:()=>{r(u.id)}})]},u.id)):null,f.jsxs(x.Button,{type:"dashed",onClick:s,block:!0,children:[f.jsx(Z.PlusOutlined,{})," ",f.jsx(Ee.FormattedMessage,{id:"app.common.word.add-field"})]})]})},Cj=t=>null,kj=t=>f.jsx(x.TimePicker,{style:{width:"100%"},use12Hours:!1,format:"HH:mm",value:t.value?cr(t.value,"HH:mm"):null,onChange:e=>{const n=cr(e).format("HH:mm:00");t.onChange&&(t==null||t.onChange(n))}}),{Text:xj}=x.Typography,uD=t=>f.jsx("div",{style:{padding:6,paddingRight:0,border:"1px solid #b0b5cb",borderRadius:4},children:f.jsx(x.Tooltip,{title:t.value,color:"cyan",placement:"topLeft",styles:{body:{width:500}},children:f.jsx(xj,{style:{color:"#b0b5cb"},ellipsis:!0,copyable:{text:t.value},children:t.value})})}),Sj=({value:t=[],onChange:e,...n})=>{const[r,o]=b.useState([]);b.useEffect(()=>{const h=Array.isArray(t)?t:[];o(h.map(p=>({...p,id:p.id??er()})))},[t]);const i=Ct(),s=h=>{const p=r.filter(m=>m.id!==h);o(p),e==null||e(p)},a=()=>{const h={field:"",dataType:"string",desc:"",required:!1,id:er()},p=[...r,h];o(p),e(p)},l=(h,p)=>{const m=r.map(w=>w.id===h?{...w,field:p}:w);o(m),e(m)},c=(h,p)=>{const m=r.map(w=>w.id===h?{...w,dataType:p}:w);o(m),e(m)},u=(h,p)=>{const m=r.map(w=>w.id===h?{...w,desc:p}:w);o(m),e(m)},d=(h,p)=>{const m=r.map(w=>w.id===h?{...w,required:p}:w);o(m),e(m)};return f.jsxs("div",{children:[r.length?r.map(h=>f.jsxs(x.Space,{size:"small",style:{display:"flex",marginBottom:8,width:"100%"},align:"start",children:[f.jsx(x.Input,{value:h.field,onChange:p=>l(h.id,p.target.value),placeholder:"字段名称",status:"",style:{width:130},disabled:!i}),f.jsx(x.Select,{value:h.dataType,onChange:p=>c(h.id,p),placeholder:"数据类型",style:{width:100},disabled:!i,options:[{label:"字符串",value:"string"},{label:"数字",value:"number"},{label:"日期",value:"date"},{label:"布尔",value:"boolean"}]}),f.jsx(x.Input,{value:h.desc,onChange:p=>u(h.id,p.target.value),placeholder:"字段描述",status:"",style:{width:200},disabled:!i}),f.jsx(x.Select,{value:h.required,onChange:p=>d(h.id,p),placeholder:"是否必填",style:{width:100},disabled:!i,options:[{label:"是",value:!0},{label:"否",value:!1}]}),i&&f.jsx(Z.DeleteOutlined,{onClick:()=>{s(h.id)},style:{cursor:"pointer",color:"#ff4d4f",marginTop:8}})]},h.id)):null,i&&f.jsx(x.Button,{type:"dashed",onClick:a,block:!0,icon:f.jsx(Z.PlusOutlined,{}),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.add-field"})})]})},Ej=t=>{const e=b.useMemo(()=>er(),[]),{event$:n}=b.useContext($r),[r,o]=b.useState("");n.useSubscription(s=>{var a;if(s.type==="insert"&&s.currentInputId===e){const l=(r??"")+(t.valueType==="FIX_VALUE"?s.expression.slice(2,-2):s.expression);o(l),(a=t.onChange)==null||a.call(t,l)}}),b.useEffect(()=>{o(t.value)},[t.value]);const i=s=>{var a;o(s.target.value),(a=t.onChange)==null||a.call(t,s.target.value)};return f.jsx(x.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:r,addonBefore:R("link.flow.cipherText"),onChange:i})},Dj=t=>{var o;const e=er(),{multiple:n,...r}=t;return f.jsx(x.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=>f.jsx(x.Select.Option,{label:i.label,value:i.value,children:i.label},i.value))})},Aj=t=>f.jsx(x.TimePicker,{style:{width:"100%"},value:t.value?cr(t.value,"HH:mm:ss"):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("HH:mm:ss")))}}),Oj=["sample","test","payload","body"],Tj=["测试","样本","sample","test","payload","body"],dD=t=>{var n,r,o;return[ve.JSON,ve.TEXTAREA,ve.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},fD=(t,e)=>{if(!t)return!1;const n=t.toLowerCase();return e.some(r=>n.includes(r))},_j=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}},Nj=t=>{const{form:e,configList:n=[],disabled:r,...o}=t;af();const[i,s]=b.useState(!1),[a,l]=b.useState(0),c=b.useRef(void 0),u=oo(),d=b.useMemo(()=>{const m=n.find(w=>dD(w)&&(fD(w.name,Oj)||fD(w.display_name,Tj)));return m||n.find(w=>dD(w))},[n]),h=b.useCallback(()=>{c.current&&(clearInterval(c.current),c.current=void 0)},[]);b.useEffect(()=>()=>{h()},[h]);const p=b.useCallback(async()=>{if(!u){x.message.warning("缺少连接流ID,无法监听Webhook");return}if(!(d!=null&&d.name)){x.message.warning("未找到测试数据字段,无法填充监听结果");return}if(!i){s(!0),l(10),c.current=setInterval(()=>{l(m=>m<=1?(h(),0):m-1)},1e3);try{const m=await Bv(u,{timeout_seconds:10}),w=_j(m);w?(e.setFieldsValue({[d.name]:w}),x.message.success("已捕获Webhook推送数据并填充测试样例")):x.message.info("监听结束,暂无新的推送数据")}catch(m){console.error("监听Webhook失败:",m),x.message.error("监听失败,请稍后重试")}finally{h(),s(!1),l(0)}}},[u,e,i,d==null?void 0:d.name,h]);return f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[f.jsx("div",{style:{flex:1},children:f.jsx(uD,{...o})}),f.jsx(x.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)`:""}`:"监听"})]})},Bj={configFormContainer:"_configFormContainer_1frpl_1"};function Fj(t){return lz(t==null?void 0:t.credentials)}const Hm=new Map,Ju=new Map,Ru=new Map,Qu=new Map,vn="[workflow:schema-render]",Ij=1;function zm(t,e){return`${t}@${e??"latest"}`}function hD(t,e,n){var o,i,s;if(!t||!n){console.warn(`${vn} skip preload classic schema cache`,{nodeKey:t,nodeVersion:e,hasSchema:!!n});return}const r=zm(t,e);console.info(`${vn} preload classic schema cache`,{cacheKey:r,nodeKey:t,nodeVersion:e,schemaVersion:n.version,inputFields:((o=n.input_fields)==null?void 0:o.length)??0,outputs:((i=n.outputs)==null?void 0:i.length)??0,credentials:((s=n.credentials)==null?void 0:s.length)??0}),Ru.set(r,n)}async function Mj(t,e){if(!t)return console.warn(`${vn} skip classic ACM schema fetch without nodeKey`,{nodeKey:t,nodeVersion:e,endpoint:"/acm/actions/{nodeKey}/{version}"}),null;const n=e??Ij;e==null&&console.warn(`${vn} fallback classic ACM schema version`,{nodeKey:t,nodeVersion:e,fallbackNodeVersion:n,reason:"node data does not include action_ver/nodeVersion after reload",endpoint:"/acm/actions/{nodeKey}/{version}"});const r=zm(t,n);if(Ru.has(r))return console.info(`${vn} classic schema cache hit`,{cacheKey:r,nodeKey:t,nodeVersion:n}),Ru.get(r);if(Qu.has(r))return console.info(`${vn} classic schema request pending reuse`,{cacheKey:r,nodeKey:t,nodeVersion:n}),Qu.get(r);console.info(`${vn} fetch classic schema from ACM`,{cacheKey:r,nodeKey:t,nodeVersion:n,endpoint:"/acm/actions/{nodeKey}/{version}"});const o=Dv(t,n).then(i=>{var s,a,l;return console.info(`${vn} classic schema fetch success`,{cacheKey:r,nodeKey:t,nodeVersion:n,schemaVersion:i.version,inputFields:((s=i.input_fields)==null?void 0:s.length)??0,outputs:((a=i.outputs)==null?void 0:a.length)??0,credentials:((l=i.credentials)==null?void 0:l.length)??0}),Ru.set(r,i),i}).catch(i=>(console.warn(`${vn} classic schema fetch failed`,{cacheKey:r,nodeKey:t,nodeVersion:n,endpoint:"/acm/actions/{nodeKey}/{version}",err:i}),null)).finally(()=>{Qu.delete(r)});return Qu.set(r,o),o}async function Zu(t,e){if(!t)return console.warn(`${vn} skip schema fetch without nodeKey`,{nodeVersion:e}),null;const n=zm(t,e);if(Hm.has(n))return console.info(`${vn} schema cache hit`,{cacheKey:n,nodeKey:t,nodeVersion:e}),Hm.get(n);if(Ju.has(n))return console.info(`${vn} schema request pending reuse`,{cacheKey:n,nodeKey:t,nodeVersion:e}),Ju.get(n);console.info(`${vn} fetch schema from DIP`,{cacheKey:n,nodeKey:t,nodeVersion:e,endpoint:e?"/dip/api/nodes/{nodeKey}/{version}":"/dip/api/nodes/{nodeKey}"});const r=EN(t,e).then(o=>{var i,s,a;return console.info(`${vn} schema fetch success`,{cacheKey:n,nodeKey:t,nodeVersion:e,inputFields:((i=o.input_fields)==null?void 0:i.length)??0,outputs:((s=o.outputs)==null?void 0:s.length)??0,credentials:((a=o.credentials)==null?void 0:a.length)??0}),Hm.set(n,o),o}).catch(o=>(console.warn(`${vn} schema fetch failed`,{cacheKey:n,nodeKey:t,nodeVersion:e,endpoint:e?"/dip/api/nodes/{nodeKey}/{version}":"/dip/api/nodes/{nodeKey}",err:o}),null)).finally(()=>{Ju.delete(n)});return Ju.set(n,r),r}const Pj=[ve.TEXT,ve.PASSWORD,ve.SELECT,ve.EXTEND_OBJ,ve.DATE,ve.TIME,ve.DATETIME,ve.TEXTAREA,ve.FIXED_OBJ,ve.JSON],ed="[workflow:schema-render]",Lj=/^\{\{([^.{}]+)\.(.+)\}\}$/,$j=t=>{switch(t.page_control){case ve.SELECT:return t.multi_valued?[]:null;case ve.EXTEND_OBJ:return{};case ve.HIDDEN:return"";case ve.TEXT:return"";case ve.PASSWORD:return"";case ve.LABEL:return"";case ve.DATE:return null;case ve.TIME:return null;case ve.DATETIME:return null;case ve.TEXTAREA:return"";case ve.FIXED_OBJ:return{};case ve.MultiRowAIExtractConfig:return[];case ve.JSON:return""}},pD=(t,e,n,r,o)=>{const i=t.display_name,s=()=>{var a,l,c;switch(t.page_control){case ve.SELECT:return f.jsx(Dj,{options:ZC(t.option_value_objects??t.option_values),multiple:t.multi_valued});case ve.EXTEND_OBJ:return f.jsx(bj,{valueType:t.value_type});case ve.HIDDEN:return f.jsx(Cj,{});case ve.TEXT:return f.jsx(tr,{valueType:t.value_type,nodeId:e});case ve.PASSWORD:return f.jsx(Ej,{valueType:t.value_type});case ve.LABEL:return(a=r==null?void 0:r.webhookField)!=null&&a.enabled&&t.name==="hookUrl"&&r.webhookField.form?f.jsx(Nj,{form:r.webhookField.form,configList:r.webhookField.configList,disabled:r.webhookField.disabled}):f.jsx(uD,{});case ve.DATE:return f.jsx(Cz,{});case ve.TIME:return f.jsx(Aj,{});case ve.DATETIME:return f.jsx(kz,{});case ve.TEXTAREA:return f.jsx(tr,{valueType:t.value_type,textAreaMode:!0,nodeId:e});case ve.FIXED_OBJ:return f.jsx(x.Input.TextArea,{});case ve.JSON:return f.jsx(tr,{valueType:t.value_type,nodeId:e});case ve.MultiRowAIExtractConfig:return f.jsx(Sj,{valueType:t.value_type});case ve.MULTI_SELECT_LIST:return f.jsx(Az,{selectType:"KNOWLEDGE_BASE"});case ve.SYNC_HOUR_MINUTE:return f.jsx(kj,{});case ve.AUTH_TOKEN:return f.jsx(pz,{disabled:(l=r==null?void 0:r.webhookField)==null?void 0:l.disabled});case ve.SECRET_KEY:return f.jsx(gz,{});case ve.SELECT_CLIENT:return f.jsx(yz,{});default:{const u=(c=o==null?void 0:o.form)==null?void 0:c.find(d=>d.name===t.page_control);return u?f.jsx(u.component,{}):null}}};return n&&Pj.includes(t.page_control)?f.jsx("div",{children:f.jsx(x.Form.Item,{required:t.required,rules:[{required:t.required,message:t.page_control===ve.SELECT?R("link.flow.please_select")+t.display_name:R("link.flow.please_enter")+t.display_name}],label:i,name:t.name,children:f.jsx(bz,{children:s()})})},t.ui_id):f.jsx(x.Form.Item,{required:t.required,style:t.page_control===ve.HIDDEN?{display:"none"}:{},rules:[{required:t.required,message:t.page_control===ve.SELECT?R("link.flow.please_select")+t.display_name:R("link.flow.please_enter")+t.display_name},{validator(a,l,c){if(t.page_control===ve.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)},Hj=t=>(t.child_conditions??[]).map(e=>e.left).filter(e=>!!e),zj=(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},mD=b.forwardRef((t,e)=>{var le,L,q,J,K;const{action:n,connector:r,nodeId:o,account_id:i,mcpMode:s}=t,a=Vt(),l=ae.useStoreApi(),c=dt.useReactive({proxyId:"0"}),{config_schema:u,proxy_id:d,protocol:h}=n,p=n.action_key||n.nodeKey,m=n.action_ver??n.nodeVersion??((le=n.node_schema)==null?void 0:le.version),w=n.node_schema,v=Array.isArray(u==null?void 0:u.sub_params),y=b.useMemo(()=>v||!p?null:`${p}@${m??"latest"}`,[v,p,m]),g=y?`${o}:${y}`:o,k=n.account_id??i,A=!v&&((L=w==null?void 0:w.input_fields)!=null&&L.length||(q=w==null?void 0:w.credentials)!=null&&q.length)?w:null,[C,E]=b.useState(()=>y&&A?{identity:y,schema:A,loading:!1,finished:!0}:null),D=(C==null?void 0:C.identity)===y?C:null,S=A??(D==null?void 0:D.schema)??null,_=Fj(S),O=Gu((S==null?void 0:S.credentials)??[]),B=!!(!v&&p&&!S&&((D==null?void 0:D.loading)??!(D!=null&&D.finished)));b.useEffect(()=>{var re,ie;!C||C.identity===y||console.info(`${ed} classic renderer ignore stale next schema state`,{nodeId:o,nodeKey:p,nodeVersion:m,currentIdentity:y,staleIdentity:C.identity,staleLoading:C.loading,staleFinished:C.finished,staleInputFields:((ie=(re=C.schema)==null?void 0:re.input_fields)==null?void 0:ie.length)??0})},[y,C,o,p,m]),b.useEffect(()=>{d&&(c.proxyId=d)},[d]);const[N]=x.Form.useForm(),[F,M]=b.useState(k);if(b.useEffect(()=>{M(k)},[g,k]),v){const re=(J=u.sub_params)==null?void 0:J.reduce((ie,he)=>{let Ce=he.value;he.page_control===ve.EXTEND_OBJ&&(Ce=tz(Ce));const Fe=N.getFieldValue(he.name);return ie[he.name]=Fe??Ce??$j(he),ie},{});N.setFieldsValue({...re})}const T=b.useRef(null),P=b.useRef(null);b.useEffect(()=>{if(!y||!p){E(null);return}if(A){E({identity:y,schema:A,loading:!1,finished:!0});return}let re=!1;return E({identity:y,schema:null,loading:!0,finished:!1}),console.info(`${ed} classic renderer load next schema`,{nodeId:o,nodeKey:p,nodeVersion:m}),Mj(p,m).then(ie=>{var he;re||(E({identity:y,schema:ie,loading:!1,finished:!0}),console.info(`${ed} classic renderer next schema loaded`,{nodeId:o,nodeKey:p,nodeVersion:m,inputFields:((he=ie==null?void 0:ie.input_fields)==null?void 0:he.length)??0}))}).catch(ie=>{re||(E({identity:y,schema:null,loading:!1,finished:!0}),console.error(`${ed} classic renderer next schema load failed`,{nodeId:o,nodeKey:p,nodeVersion:m,err:ie}))}),()=>{re=!0}},[A,y,o,p,m]);const $=b.useMemo(()=>{var re;return(re=S==null?void 0:S.input_fields)!=null&&re.length?el(S.input_fields):null},[S]),W=!!(!v&&($||_||S)),V=b.useMemo(()=>n.params?n.params:u&&!v?u:{},[n,u,v]),X=b.useMemo(()=>JSON.stringify(V??{}),[V]);b.useEffect(()=>{v||!W||(N.resetFields(),N.setFieldsValue(V))},[g,N,v,V,X,W]);const G=b.useCallback(re=>{const ie=re.trim().match(Lj);if(!ie)return null;const he=ie[1],Ce=ie[2];if(he==="global")return null;const Fe=he.startsWith("N")?he.slice(1):he,qe=l.getState().nodes.find(Le=>Le.id===Fe);return qe?{fieldPath:Ce,node:qe,variableNodeId:he}:null},[l]),te=b.useCallback(re=>{var ie;return((ie=G(re))==null?void 0:ie.fieldPath)??re.replace(/^\{\{|\}\}$/g,"")},[G]),H=b.useCallback(re=>{var qe;const ie=G(re);if(!ie)return re;const he=(qe=ie.node)==null?void 0:qe.data,Ce=(he==null?void 0:he.label)||(he==null?void 0:he.name)||(he==null?void 0:he.action_name)||ie.variableNodeId,Fe=he!=null&&he.note?` (${he.note})`:"";return`${Ce}${Fe}.${ie.fieldPath}`},[G]),j=(re,ie)=>N.validateFields().then(async he=>{var Fe,qe,Le,de,Te;if(W)return ie&&((qe=(Fe=T==null?void 0:T.current)==null?void 0:Fe.onIgnoreNodeStart)==null||qe.call(Fe)),t.onSubmit({params:he,account_id:F,proxy_id:he==null?void 0:he.proxy_id},re);const Ce=ut.cloneDeep(n.config_schema);return Ce.sub_params.forEach(_e=>{let tt=he[_e.name];_e.page_control===ve.EXTEND_OBJ&&tt!=="{{$fromAI}}"&&(tt=Bm(tt)),_e.value=tt}),ie&&((de=(Le=T==null?void 0:T.current)==null?void 0:Le.onIgnoreNodeStart)==null||de.call(Le)),!i&&h==="HTTP"&&(r==null?void 0:r.deployment_type)!=="SaasApp"&&(Ce.proxy_id=(Te=P.current)==null?void 0:Te.getProxyId()),t.onSubmit(Ce,re)}).catch(he=>(console.log("err",he),x.message.warning(R("link.flow.missing_configuration")),!1));b.useImperativeHandle(e,()=>({saveConfig:re=>j(re,!1)}));const Y=Ct(),se=h==="WEBHOOK"?{webhookField:{enabled:!0,form:N,configList:(u==null?void 0:u.sub_params)??[],disabled:!Y}}:void 0,Q=re=>{const ie=re.page_control!==ve.HIDDEN?f.jsx("div",{style:{minHeight:10},children:f.jsx("p",{style:{color:"#999",fontSize:12,marginTop:-18,whiteSpace:"pre-wrap"},children:re.description})}):null;if(!re.is_child)return f.jsxs("div",{children:[pD(re,o,s,se,a.canvas.registerComponents),ie]},re.ui_id);const he=Hj(re);return f.jsx(x.Form.Item,{noStyle:!0,shouldUpdate:(Ce={},Fe={})=>re.is_child?he.length?he.some(qe=>(Ce==null?void 0:Ce[qe])!==(Fe==null?void 0:Fe[qe])):!0:!1,children:()=>{const Ce=N.getFieldsValue(!0);return zj(re,Ce)?f.jsxs("div",{children:[pD(re,o,s,se,a.canvas.registerComponents),ie]}):null}},re.ui_id)};return!v&&B?f.jsx("div",{style:{textAlign:"center",padding:40},children:f.jsx(x.Spin,{})}):W?f.jsxs("div",{style:{height:"100%",position:"relative"},children:[f.jsxs("div",{style:{height:"calc(100% - 50px)",minHeight:500,overflowY:"auto"},children:[_?f.jsx(Im,{credentialRequirements:O,value:F,onChange:M,linkApp:r,disabled:!Y}):null,$?f.jsx(Gi,{schema:$,form:N,initialValues:V,showSubmit:!1,showReset:!1,nodeId:o,mcpMode:s,renderVariableTag:te,renderVariableTooltip:H},g):f.jsx("div",{style:{padding:16,color:"#999",textAlign:"center"},children:"该节点暂无配置项"})]}),f.jsx("div",{style:{padding:"10px 20px",paddingBottom:10,paddingTop:30,position:"sticky",backgroundColor:"#FFFFFF",bottom:0,width:"100%",textAlign:"center",borderTop:"1px solid #eaeaea"},children:Y&&f.jsx(x.Button,{type:"primary",disabled:!Y,style:{width:180,borderRadius:4},onClick:()=>j(),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.save"})})})]}):f.jsxs("div",{style:{height:"100%",position:"relative"},children:[f.jsxs(x.Form,{form:N,disabled:!Y,style:{height:"calc(100% - 50px)",minHeight:500,overflowY:"auto",paddingRight:24},layout:"vertical",className:Bj.configFormContainer,children:[(r==null?void 0:r.id)&&n.config_schema&&((K=u==null?void 0:u.sub_params)==null?void 0:K.map(re=>Q(re))),!i&&h==="HTTP"&&(r==null?void 0:r.deployment_type)!=="SaasApp"?f.jsx(e1,{proxyId:c.proxyId,ref:P}):null]}),f.jsx("div",{style:{padding:"10px 20px",paddingBottom:10,paddingTop:30,position:"sticky",backgroundColor:"#FFFFFF",bottom:0,width:"100%",textAlign:"center",borderTop:"1px solid #eaeaea"},children:Y&&f.jsx(x.Button,{type:"primary",disabled:!Y,style:{width:180,borderRadius:4},onClick:()=>j(),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.save"})})})]})}),jj=b.memo(b.forwardRef((t,e)=>{var h;const{nodeId:n,data:r}=t,{account_id:o,account_schema_id:i}=r,s=dt.useReactive({account_id:o}),a=b.useRef(null);b.useImperativeHandle(e,()=>({saveConfig:p=>{var m;return(m=a.current)==null?void 0:m.saveConfig(p)}}));const l=b.useMemo(()=>({id:t.data.connector_id,name:t.data.connector_name}),[t.data.connector_id,t.data.connector_name]),c=!!(t.data.action_key||t.data.nodeKey)&&!Array.isArray((h=t.data.config_schema)==null?void 0:h.sub_params),u=(p,m)=>{if(c){const w=(p==null?void 0:p.params)??p??{},y=Object.hasOwn(p??{},"account_id")?p.account_id??null:s.account_id;t.onSubmit({params:w,account_id:y,proxy_id:(p==null?void 0:p.proxy_id)??(w==null?void 0:w.proxy_id)},m);return}t.onSubmit({properties:p,account_id:s.account_id,proxy_id:p.proxy_id},m)},d=b.useCallback(p=>{s.account_id=p??null},[]);return f.jsxs("div",{children:[i&&!c?f.jsx(Im,{onChange:d,actionAccountSchemaId:i,value:s.account_id,linkApp:l}):null,f.jsx(mD,{ref:a,action:t.data,connector:l,account_id:o,nodeId:n,onSubmit:u})]})}),(t,e)=>t.nodeId===e.nodeId&&ut.isEqual(ut.omit(t.data,["isHovered"]),ut.omit(e.data,["isHovered"]))),gD=[{operator:Ye.eq,label:R("common.eq")},{operator:Ye.ne,label:R("common.ne")},{operator:Ye.sw,label:R("common.sw")},{operator:Ye.nsw,label:R("common.nsw")},{operator:Ye.ew,label:R("common.ew")},{operator:Ye.ewn,label:R("common.ewn")},{operator:Ye.gt,label:R("common.gt")},{operator:Ye.ge,label:R("common.ge")},{operator:Ye.lt,label:R("common.lt")},{operator:Ye.le,label:R("common.le")},{operator:Ye.co,label:R("common.co")},{operator:Ye.nco,label:R("common.nco")},{operator:Ye.in,label:R("common.in")},{operator:Ye.nin,label:R("common.nin")},{operator:Ye.is_null,label:R("common.is_null")},{operator:Ye.is_not_null,label:R("common.is_not_null")}];Ye.eq+"",R("common.eq"),Ye.ne+"",R("common.ne"),Ye.sw+"",R("common.sw"),Ye.nsw+"",R("common.nsw"),Ye.ew+"",R("common.ew"),Ye.ewn+"",R("common.ewn"),Ye.gt+"",R("common.gt"),Ye.lt+"",R("common.lt"),Ye.ge+"",R("common.ge"),Ye.co+"",R("common.co"),Ye.nco+"",R("common.nco"),Ye.le+"",R("common.le"),Ye.in+"",R("common.in"),Ye.nin+"",R("common.nin"),Ye.is_null+"",R("common.is_null"),Ye.is_not_null+"",R("common.is_not_null");const jm=t=>t===Ye.is_null||t===Ye.is_not_null,Vj=(t,e="")=>jm(t)?"":e,{Option:Wj}=x.Select,Uj=b.forwardRef((t,e)=>{const{config_schema:n}=t,[r]=x.Form.useForm(),i=(l=>l!=null&&l.or_list?{or_list:l.or_list.map(u=>({and_list:u.and_list.map(d=>({query:d.query||"",operator:d.operator||"",value:d.value||""}))}))}:{or_list:[{and_list:[{query:"",operator:"",value:""}]}]})(n),s=(l,c,u="")=>r.validateFields().then(async d=>t.onSubmit({properties:d},l)).catch(()=>(x.message.warning(R("link.flow.missing_configuration")),!1));b.useImperativeHandle(e,()=>({saveConfig:()=>s(!0)}));const a=Ct();return f.jsxs("div",{style:{height:"100%",position:"relative"},children:[f.jsx("div",{style:{height:"calc(100% - 60px)",minHeight:500,overflowY:"auto",paddingRight:20},className:"grayBeautifyScrollbar",children:f.jsx(x.Form,{disabled:!a,form:r,initialValues:i,layout:"vertical",autoComplete:"off",children:f.jsx(x.Form.List,{name:"or_list",children:(l,{add:c,remove:u})=>f.jsxs(f.Fragment,{children:[l.map((d,h)=>f.jsxs("div",{style:{marginTop:10},children:[f.jsxs("div",{style:{background:"rgb(247, 248, 249)",borderRadius:8,padding:12},children:[h>0&&a&&f.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:f.jsx(x.Button,{type:"link",style:{color:"red"},icon:f.jsx(Z.MinusCircleOutlined,{style:{color:"red"}}),onClick:()=>u(d.name),children:f.jsx(Ee.FormattedMessage,{id:"link.flow.remove"})})}),f.jsx(x.Form.List,{name:[d.name,"and_list"],children:(p,{add:m,remove:w})=>f.jsx(f.Fragment,{children:p.map((v,y)=>f.jsxs(x.Space,{direction:"vertical",children:[f.jsxs(x.Space,{align:"center",children:[f.jsx(x.Form.Item,{style:{minWidth:150},name:[v.name,"query"],label:R("app.common.word.variable-name"),rules:[{required:!0,message:R("link.flow.please_enter_variable_name")}],children:f.jsx(tr,{nodeId:t.nodeId,placeholder:R("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),f.jsx(x.Form.Item,{name:[v.name,"operator"],label:R("app.common.word.condition"),rules:[{required:!0,message:R("link.flow.please_select_condition")}],children:f.jsx(x.Select,{style:{minWidth:140},placeholder:R("link.flow.select_condition"),getPopupContainer:g=>g.parentNode,children:gD.map(g=>f.jsx(Wj,{value:g.operator,children:g.label},g.operator))})}),f.jsx(x.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const g=r.getFieldValue(["or_list",d.name,"and_list",v.name,"operator"]);return jm(g)?null:f.jsx(x.Form.Item,{style:{minWidth:150},name:[v.name,"value"],label:R("app.common.word.value"),rules:[],children:f.jsx(tr,{nodeId:t.nodeId,placeholder:R("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),y===0&&f.jsx("div",{style:{width:30}}),y>0&&f.jsx(x.Button,{type:"link",icon:f.jsx(Z.MinusCircleOutlined,{}),onClick:()=>w(v.name)})]}),y<p.length-1&&f.jsx(x.Divider,{plain:!0,children:f.jsx(x.Tag,{color:"#999999",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.and"})})}),y===p.length-1&&f.jsx(x.Button,{type:"link",disabled:!a,icon:f.jsx(Z.PlusCircleOutlined,{}),onClick:()=>m({query:"",operator:"",value:""}),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.add-new-and"})})]},v.key))})})]}),h<l.length-1&&f.jsxs("div",{className:"test",style:{textAlign:"center"},children:[" ",f.jsx(x.Divider,{style:{color:"orange"},dashed:!0,children:f.jsx(x.Tag,{color:"#1890ff",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.or"})})})]})]},d.key)),f.jsx(x.Form.Item,{children:f.jsx(x.Button,{type:"link",icon:f.jsx(Z.PlusCircleOutlined,{}),disabled:!a,onClick:()=>c({and_list:[{query:"",operator:"",value:""}]}),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.add-or"})})})]})})})}),f.jsx("div",{style:{position:"sticky",padding:"10px 20px",paddingBottom:0,backgroundColor:"#FFFFFF",bottom:0,width:"100%",textAlign:"center",borderTop:"1px solid #eaeaea"},children:a&&f.jsx(x.Button,{type:"primary",disabled:!a,style:{width:180,borderRadius:4},onClick:()=>s(),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.save"})})})]})}),qj={copy:"Copy JSON",copySuccess:"JSON copied to clipboard",download:"Download JSON",invalidJson:"Invalid JSON data"},Gj={copy:"复制JSON",copySuccess:"JSON已复制到剪贴板",download:"下载JSON",invalidJson:"无效的JSON数据"},{Text:Kj}=x.Typography,wD=({data:t,height:e=400,enableCopy:n=!0,theme:r="light",className:o="",locale:i="zh",maxHeight:s})=>{const[a,l]=b.useState(r),c=b.useRef(null),u=i==="zh"?Gj:qj,d=b.useMemo(()=>{if(!t)return null;try{return typeof t=="string"?JSON.parse(t):t}catch(y){return console.error("JSON解析失败:",y),null}},[t]),h=b.useMemo(()=>{if(!d)return[];const y=(g,k=[],A=0)=>{const C=[];if(g===null)return[{key:k.join("."),value:null,type:"null",path:k,level:A}];if(Array.isArray(g)){const E={key:k.join("."),value:g,type:"array",path:k,level:A,children:[]};g.forEach((D,S)=>{const _=[...k,S.toString()],O=y(D,_,A+1);E.children.push(...O)}),C.push(E)}else if(typeof g=="object"){const E={key:k.join("."),value:g,type:"object",path:k,level:A,children:[]};Object.entries(g).forEach(([D,S])=>{const _=[...k,D],O=y(S,_,A+1);E.children.push(...O)}),C.push(E)}else{const E=typeof g;C.push({key:k.join("."),value:g,type:E,path:k,level:A})}return C};return y(d)},[d]),p=b.useCallback(()=>{const y=JSON.stringify(d,null,2);navigator.clipboard.writeText(y).then(()=>{x.message.success(u.copySuccess)})},[d,u]),m=b.useCallback(()=>{const y=JSON.stringify(d,null,2),g=new Blob([y],{type:"application/json"}),k=URL.createObjectURL(g),A=document.createElement("a");A.href=k,A.download="data.json",A.click(),URL.revokeObjectURL(k)},[d]),w=b.useCallback(y=>{switch(y.type){case"string":return f.jsxs("span",{className:"json-string",children:['"',y.value,'"']});case"number":return f.jsx("span",{className:"json-number",children:y.value});case"boolean":return f.jsx("span",{className:"json-boolean",children:String(y.value)});case"null":return f.jsx("span",{className:"json-null",children:"null"});default:return null}},[]),v=b.useCallback((y,g)=>{const k=y.children&&y.children.length>0,A=y.path[y.path.length-1];return y.type==="object"||y.type==="array"?f.jsxs("div",{className:"json-node",children:[f.jsxs("div",{className:"json-line",style:{paddingLeft:`${y.level*16}px`},children:[A&&f.jsxs("span",{className:"json-key",children:['"',A,'": ']}),f.jsx("span",{className:"json-bracket",children:y.type==="array"?"[":"{"}),!k&&f.jsx("span",{className:"json-bracket",children:y.type==="array"?"]":"}"})]}),k&&f.jsxs(f.Fragment,{children:[y.children.map((C,E)=>v(C,g+E+1)),f.jsx("div",{className:"json-line",style:{paddingLeft:`${y.level*16}px`},children:f.jsx("span",{className:"json-bracket",children:y.type==="array"?"]":"}"})})]})]},y.key):f.jsx("div",{className:"json-node",children:f.jsxs("div",{className:"json-line",style:{paddingLeft:`${y.level*16}px`},children:[A&&f.jsxs("span",{className:"json-key",children:['"',A,'": ']}),w(y)]})},y.key)},[w,u]);return b.useCallback(()=>{l(a==="dark"?"light":"dark")},[a]),d?f.jsxs("div",{className:`json-renderer ${a} ${o}`,children:[f.jsx("div",{className:"json-toolbar",children:f.jsxs(x.Space,{children:[n&&f.jsx(x.Tooltip,{title:u.copy,children:f.jsx(x.Button,{icon:f.jsx(Z.CopyOutlined,{}),size:"small",onClick:p})}),f.jsx(x.Tooltip,{title:u.download,children:f.jsx(x.Button,{icon:f.jsx(Z.DownloadOutlined,{}),size:"small",onClick:m})})]})}),f.jsx("div",{ref:c,className:"json-content",style:{height:`${e}px`,maxHeight:s?`${s}px`:void 0},children:h.map((y,g)=>v(y,g))})]}):f.jsx("div",{className:`json-renderer error ${a} ${o}`,children:f.jsx("div",{className:"error-message",children:f.jsx(Kj,{type:"secondary",children:u.invalidJson})})})},Hr=()=>{const t=ae.useStoreApi(),{setNodes:e}=ae.useReactFlow(),n=Vt();return{handleNodeDataUpdate:b.useCallback(({id:o,data:i,sync:s})=>{const{nodes:a}=t.getState(),l=n.engineMode===or.NEXT,c=Pn(a,u=>{const d=u.find(h=>h.id===o);d&&(d.data={...d.data,...i}),s&&!l&&Ol(o,{flow_id:n.flowId,properties:d.data.config_schema})});e(c)},[t])}},{TextArea:Yj}=x.Input,{Title:Xj,Paragraph:Jj}=x.Typography,Rj=b.forwardRef((t,e)=>{var k,A;const{nodeId:n,beforeHook:r}=t,o=Vt(),{handleNodeDataUpdate:i}=Hr(),s=(A=(k=o.nodeConfigPanel)==null?void 0:k.testArea)==null?void 0:A.defaultTestResult,[a,l]=b.useState(()=>{if(s==null)return"";if(typeof s=="string")return s;try{return JSON.stringify(s,null,2)}catch{return String(s)}}),c=ae.useInternalNode(n),u=dt.useReactive({testProgress:0,sampleText:"",isError:!1,editable:!1,showErrorAlert:!1,testing:!1,ignoring:!1,successShown:!1,isIgnoreSuccess:!1}),{refreshFlow:d}=Cr();b.useEffect(()=>{if(c!=null&&c.data.output&&(c.data.status===me.SUCCESS||c.data.status===me.RUNNABLE)){const C=typeof c.data.output=="string"?c.data.output:JSON.stringify(c.data.output,null,2);l(C),u.successShown=!0,u.isError=!1,u.showErrorAlert=!1}else if(c!=null&&c.data.output&&c.data.status===me.FAILED){const C=typeof c.data.output=="string"?c.data.output:JSON.stringify(c.data.output,null,2);l(C),u.isError=!0,u.showErrorAlert=!0,u.successShown=!1}},[c]);const h=b.useCallback(()=>{if(!n){console.error("节点ID不能为空");return}u.testing=!0,u.testProgress=60,u.successShown=!1,u.isError=!1,u.showErrorAlert=!1,u.isIgnoreSuccess=!1,Nv(n).then(C=>{let E="";const D=C;(D==null?void 0:D.result)===!1?u.isError=!0:(u.isError=!1,u.successShown=!0),u.isIgnoreSuccess=!1,u.showErrorAlert=u.isError;try{if(typeof D=="object")E=JSON.stringify(D,null,2);else if(typeof D=="string")try{const S=JSON.parse(D);E=JSON.stringify(S,null,2)}catch{E=D}else E=String(D)}catch(S){console.error("格式化测试结果出错:",S),E="测试结果格式化失败: "+String(S)}u.testProgress=100,l(E),i({id:n,data:{status:me.SUCCESS,output:E}})}).catch(C=>{var S;console.error("测试失败:",C),u.testProgress=0,u.isError=!0,u.showErrorAlert=!0,u.successShown=!1,u.isIgnoreSuccess=!1;let E="测试执行失败";(S=C==null?void 0:C.response)!=null&&S.data?E=JSON.stringify(C.response.data,null,2):C!=null&&C.message&&(E=C.message);const D=JSON.stringify({error:E},null,2);l(D),i({id:n,data:{status:me.FAILED,output:D}})}).finally(()=>{setTimeout(()=>{u.testProgress=0,u.testing=!1,u.ignoring=!1,u.isIgnoreSuccess=!1},500)})},[n]),p=()=>{u.testProgress=0,u.testing=!1,u.ignoring=!1,u.isIgnoreSuccess=!0};b.useImperativeHandle(e,()=>({onTestNode:h,finishNodeTest:p}));const m=()=>{r?r(!0):h()},w=()=>{r&&(u.testing=!0,u.ignoring=!0,u.testProgress=60,r(!0,!0,u.sampleText))},v=()=>{l(""),u.sampleText="",u.editable=!1,u.successShown=!1},y=Ct(),g=b.useMemo(()=>{var D;const C=(D=c==null?void 0:c.data)==null?void 0:D.protocol,E=c==null?void 0:c.type;return!y||C===Be.AI_LANGUAGE_MODEL||C===Be.AI_MEMORY||E===ee.BuiltinMCP||E===ee.MCPServer},[c]);return f.jsxs("div",{className:"node-test-container",children:[f.jsxs("div",{className:"node-test-header",children:[f.jsxs("div",{className:"header-title",children:[f.jsx(Z.RocketOutlined,{className:"title-icon"}),f.jsx(Xj,{level:4,children:"节点测试"})]}),f.jsx(Jj,{type:"secondary",className:"header-description",children:"点击测试按钮,实时检查节点执行效果和结果数据"})]}),f.jsxs("div",{className:"test-content",children:[y&&f.jsxs("div",{className:"action-buttons",children:[f.jsx(x.Button,{type:"primary",disabled:g||u.ignoring,icon:f.jsx(Z.RocketOutlined,{}),onClick:m,loading:u.testing&&!u.ignoring,className:"test-button",children:u.testing&&!u.ignoring?"测试中...":"开始测试"}),f.jsx(x.Button,{type:"primary",disabled:g||u.testing&&!u.ignoring,ghost:!0,onClick:w,loading:u.testing&&u.ignoring,className:"ignore-button",children:"忽略调试"}),a&&f.jsx(x.Button,{icon:f.jsx(Z.ReloadOutlined,{}),onClick:v,className:"reset-button",children:"重置"})]}),u.testProgress>0&&f.jsx(x.Progress,{percent:u.testProgress,status:u.isError?"exception":"active",className:"test-progress"}),u.isError&&u.showErrorAlert&&f.jsx(x.Alert,{className:"error-alert",showIcon:!0,message:"测试未通过",description:"请检查节点配置是否正确",type:"error",onClose:()=>{setTimeout(()=>{u.showErrorAlert=!1},500)},closable:!0}),!u.isError&&u.successShown&&a&&!u.testing&&f.jsx(x.Alert,{className:"success-alert",showIcon:!0,message:u.isIgnoreSuccess?"忽略调试成功":"测试成功",description:u.isIgnoreSuccess?"已将样本数据预设为当前节点输出":"节点运行正常,可以查看下方返回结果",type:"success",closable:y}),u.testing?f.jsx(x.Skeleton,{active:!0,className:"result-skeleton"}):f.jsx(f.Fragment,{children:a?f.jsx(x.Card,{styles:{body:{padding:0}},title:f.jsxs("div",{className:"result-header",children:[f.jsx("div",{className:"result-title",children:u.isError?f.jsxs(f.Fragment,{children:[f.jsx(Z.CloseCircleFilled,{className:"error-icon"})," 错误数据"]}):f.jsxs(f.Fragment,{children:[u.isIgnoreSuccess?f.jsx(Z.ExperimentFilled,{className:"success-icon"}):f.jsx(Z.CheckCircleFilled,{className:"success-icon"}),u.isIgnoreSuccess?"样本数据":"测试结果"]})}),y&&f.jsx(x.Button,{size:"small",type:"link",icon:f.jsx(Z.EditOutlined,{}),onClick:()=>{if(u.editable){u.editable=!1;try{const C=JSON.parse(u.sampleText),E=JSON.stringify(C,null,2);l(E),i({id:n,data:{output:E}})}catch{l(u.sampleText)}}else u.sampleText=a,u.editable=!0},className:"edit-button",children:u.editable?"完成":"编辑"})]}),variant:"borderless",className:`result-card ${u.isError?"error-result":"success-result"}`,children:u.editable?f.jsx(Yj,{rows:10,value:u.sampleText,onChange:C=>u.sampleText=C.target.value,className:"result-editor"}):f.jsx(wD,{data:a,height:300,enableCopy:!0,theme:"light"},a)}):f.jsx(x.Card,{variant:"borderless",className:"empty-result",children:f.jsx(x.Result,{icon:f.jsx(Z.RocketOutlined,{}),title:"等待测试",subTitle:'点击"开始测试"按钮开始节点测试'})})})]})]})}),{Option:Fo}=x.Select,Qj=b.forwardRef(({onSubmit:t,config_schema:e,nodeId:n},r)=>{const[o]=x.Form.useForm(),i=x.Form.useWatch("type",o);dt.useMount(()=>{e&&Object.hasOwn(e,"asc")&&o.setFieldsValue(e)});const s=(l,c,u="")=>o.validateFields().then(async d=>i&&i==="NUMBER"&&d.start>d.end?x.message.warning(R("link.flow.loop_start_end_check")):t({properties:d},l)).catch(()=>(x.message.warning(R("link.flow.missing_configuration")),!1));b.useImperativeHandle(r,()=>({saveConfig:()=>s(!0)}));const a=Ct();return f.jsxs("div",{style:{width:"100%",position:"relative",height:"100%"},children:[f.jsx("div",{style:{height:"calc(100% - 60px)",overflow:"scroll"},className:"grayBeautifyScrollbar",children:f.jsxs(x.Form,{disabled:!a,form:o,layout:"vertical",children:[f.jsx(x.Form.Item,{name:"type",label:R("app.common.word.loop-data-type"),rules:[{required:!0,message:R("link.flow.please_select_data_type")}],children:f.jsxs(x.Select,{children:[f.jsx(Fo,{value:"ARRAY",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.array"})}),f.jsx(Fo,{value:"NUMBER",children:f.jsx(Ee.FormattedMessage,{id:"common.number"})}),f.jsx(Fo,{value:"CONDITION",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.condition_expression"})})]})}),i&&i==="NUMBER"&&f.jsxs(x.Form.Item,{required:!0,label:R("link.flow.loop_start_end"),style:{display:"flex"},children:[f.jsx(x.Form.Item,{name:"start",noStyle:!0,rules:[{required:!0,message:R("link.flow.please_select_data_type")}],children:f.jsx(x.InputNumber,{min:1,style:{marginRight:20}})}),f.jsx(x.Form.Item,{name:"end",noStyle:!0,rules:[{required:!0,message:R("link.flow.please_select_data_type")}],children:f.jsx(x.InputNumber,{min:1})})]}),i&&i!=="NUMBER"&&f.jsx(x.Form.Item,{rules:[{required:!0,message:R("link.flow.please_enter_loop_expression")}],label:R("link.flow.loop_expression"),name:"expression",children:f.jsx(tr,{nodeId:n,borrow:!0,valueType:"JS_EXP",placeholder:R("link.flow.please_enter_loop_expression")})}),f.jsx(x.Form.Item,{name:"asc",label:R("app.common.word.circulation-direction"),rules:[{required:!0,message:R("link.flow.please_select_loop_direction")}],children:f.jsxs(x.Select,{children:[f.jsx(Fo,{value:!0,children:f.jsx(Ee.FormattedMessage,{id:"link.flow.loop_head_to_tail"})}),f.jsx(Fo,{value:!1,children:f.jsx(Ee.FormattedMessage,{id:"link.flow.loop_tail_to_head"})})]})}),f.jsx(x.Form.Item,{name:"errorExec",label:R("link.flow.loop_processing"),rules:[{required:!0,message:R("link.flow.please_select_loop_processing")}],children:f.jsxs(x.Select,{children:[f.jsx(Fo,{value:"END",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.terminate_process"})}),f.jsx(Fo,{value:"CONTINUE",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.continue_loop"})}),f.jsx(Fo,{value:"BREAK",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.break_loop"})})]})})]})}),f.jsx("div",{style:{padding:"10px 20px",marginTop:30,paddingBottom:0,backgroundColor:"#FFFFFF",bottom:0,width:"100%",textAlign:"center",borderTop:"1px solid #eaeaea"},children:a&&f.jsx(x.Button,{type:"primary",disabled:!a,style:{width:180,borderRadius:4},onClick:()=>s(),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.save"})})})]})}),td=()=>`branch_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,{Option:Zj}=x.Select,e7=b.forwardRef((t,e)=>{const{config_schema:n,nodeId:r}=t,[o]=x.Form.useForm(),{handleNodeDataUpdate:i}=Hr(),[s,a]=b.useState(null),[l,c]=b.useState(""),d=(A=>!(A!=null&&A.branches)||A.branches.length===0?{branches:[{id:td(),name:R("link.flow.switch.condition_one"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]},{id:td(),name:R("link.flow.switch.condition_two"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]}]}:{branches:A.branches.map((E,D)=>{var S;return{id:E.id||td(),name:E.name||R("link.flow.switch.condition_n",{n:D+1}),or_list:((S=E.or_list)==null?void 0:S.map(_=>{var O;return{and_list:((O=_.and_list)==null?void 0:O.map(B=>({query:B.query||"",operator:B.operator||"",value:B.value||""})))||[{query:"",operator:"",value:""}]}}))||[{and_list:[{query:"",operator:"",value:""}]}]}})})(n),h=()=>{const A=o.getFieldValue("branches")||[];i({id:r,data:{config_schema:{branches:A}}})},p=(A,C)=>{a(A),c(C)},m=()=>{a(null),c("")},w=A=>{const C=ut.cloneDeep(o.getFieldValue("branches"))||[],E=l.trim();if(!E){x.message.error(R("link.flow.switch.branch_name_cannot_be_empty"));return}if(C.some((S,_)=>_!==A&&S.name===E)){x.message.error(R("link.flow.switch.branch_name_duplicate"));return}C[A].name=E,o.setFieldValue("branches",C),a(null),c(""),h()},v=(A,C)=>{const E=o.getFieldValue("branches")||[];if(C<0||C>=E.length)return;const D=[...E],[S]=D.splice(A,1);D.splice(C,0,S),o.setFieldValue("branches",D),h()},y=A=>o.validateFields().then(async C=>{if(!C.branches.some(S=>S.or_list.some(_=>_.and_list.some(O=>O.query&&O.operator)))){x.message.error(R("link.flow.switch.at_least_one_valid_branch"));return}const D=ut.cloneDeep(C);return D.branches.forEach(S=>{S.or_list.forEach(_=>{_.and_list.forEach(O=>{O.value=Vj(O.operator,O.value)})})}),t.onSubmit({properties:D},A)}).catch(()=>(x.message.warning(R("link.flow.missing_configuration")),!1));b.useImperativeHandle(e,()=>({saveConfig:()=>y(!0)}));const g=Ct(),k=(A,C,E,D)=>{const _=(o.getFieldValue("branches")||[])[C],O=s===C;return f.jsxs(x.Card,{style:{marginBottom:16,borderRadius:8,border:"1px solid #d9d9d9"},bodyStyle:{padding:16},children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:12},children:[f.jsx("div",{style:{display:"flex",alignItems:"center",flex:1},children:O?f.jsxs(x.Space,{children:[f.jsx(x.Input,{value:l,onChange:B=>c(B.target.value),style:{width:200},placeholder:R("link.flow.switch.enter_branch_name"),onPressEnter:()=>w(C)}),f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.CheckOutlined,{style:{color:"#52c41a"}}),onClick:()=>w(C)}),f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.CloseOutlined,{}),onClick:m})]}):f.jsxs(x.Space,{children:[f.jsx("span",{style:{fontSize:16,fontWeight:500},children:(_==null?void 0:_.name)||R("link.flow.switch.condition_n",{n:C+1})}),g&&f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.EditOutlined,{}),onClick:()=>p(C,(_==null?void 0:_.name)||"")})]})}),g&&f.jsxs(x.Space,{children:[f.jsx(x.Tooltip,{title:R("link.flow.switch.move_to_top"),children:f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.VerticalAlignTopOutlined,{}),disabled:C===0,onClick:()=>v(C,0)})}),f.jsx(x.Tooltip,{title:R("link.flow.switch.move_up"),children:f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.ArrowUpOutlined,{}),disabled:C===0,onClick:()=>v(C,C-1)})}),f.jsx(x.Tooltip,{title:R("link.flow.switch.move_down"),children:f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.ArrowDownOutlined,{}),disabled:C===E-1,onClick:()=>v(C,C+1)})}),f.jsx(x.Tooltip,{title:R("link.flow.switch.move_to_bottom"),children:f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.VerticalAlignBottomOutlined,{}),disabled:C===E-1,onClick:()=>v(C,E-1)})}),f.jsx(x.Tooltip,{title:R("common.delete"),children:f.jsx(x.Button,{type:"text",size:"small",danger:!0,icon:f.jsx(Z.DeleteOutlined,{}),disabled:E<=1,onClick:()=>{if(E<=1){x.message.warning(R("link.flow.switch.at_least_one_branch"));return}D(A.name),setTimeout(()=>{h()},0)}})})]})]}),f.jsx(x.Form.Item,{name:[A.name,"name"],hidden:!0,children:f.jsx(x.Input,{})}),f.jsx(x.Form.List,{name:[A.name,"or_list"],children:(B,{add:N,remove:F})=>f.jsxs(f.Fragment,{children:[B.map((M,T)=>f.jsxs("div",{style:{marginTop:T>0?10:0},children:[f.jsxs("div",{style:{background:"rgb(247, 248, 249)",borderRadius:8,padding:12},children:[B.length>1&&g&&f.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:f.jsx(x.Button,{type:"link",style:{color:"red"},icon:f.jsx(Z.MinusCircleOutlined,{style:{color:"red"}}),onClick:()=>F(M.name),children:f.jsx(Ee.FormattedMessage,{id:"link.flow.remove"})})}),f.jsx(x.Form.List,{name:[M.name,"and_list"],children:(P,{add:$,remove:W})=>f.jsx(f.Fragment,{children:P.map((V,X)=>f.jsxs(x.Space,{direction:"vertical",style:{width:"100%"},children:[f.jsxs(x.Space,{align:"center",wrap:!0,children:[f.jsx(x.Form.Item,{style:{minWidth:150,marginBottom:0},name:[V.name,"query"],label:R("app.common.word.variable-name"),rules:[{required:!0,message:R("link.flow.please_enter_variable_name")}],children:f.jsx(tr,{nodeId:t.nodeId,placeholder:R("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),f.jsx(x.Form.Item,{style:{marginBottom:0},name:[V.name,"operator"],label:R("app.common.word.condition"),rules:[{required:!0,message:R("link.flow.please_select_condition")}],children:f.jsx(x.Select,{style:{minWidth:140},placeholder:R("link.flow.select_condition"),getPopupContainer:G=>document.body,children:gD.map(G=>f.jsx(Zj,{value:G.operator,children:G.label},G.operator))})}),f.jsx(x.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const G=o.getFieldValue(["branches",A.name,"or_list",M.name,"and_list",V.name,"operator"]);return jm(G)?null:f.jsx(x.Form.Item,{style:{minWidth:150,marginBottom:0},name:[V.name,"value"],label:R("app.common.word.value"),rules:[],children:f.jsx(tr,{nodeId:t.nodeId,placeholder:R("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),X===0&&f.jsx("div",{style:{width:30}}),X>0&&g&&f.jsx(x.Button,{type:"link",icon:f.jsx(Z.MinusCircleOutlined,{}),onClick:()=>W(V.name)})]}),X<P.length-1&&f.jsx(x.Divider,{plain:!0,style:{margin:"8px 0"},children:f.jsx(x.Tag,{color:"#999999",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.and"})})}),X===P.length-1&&f.jsx(x.Button,{type:"link",disabled:!g,icon:f.jsx(Z.PlusCircleOutlined,{}),onClick:()=>$({query:"",operator:"",value:""}),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.add-new-and"})})]},V.key))})},Math.random())]}),T<B.length-1&&f.jsx("div",{style:{textAlign:"center"},children:f.jsx(x.Divider,{style:{color:"orange"},dashed:!0,children:f.jsx(x.Tag,{color:"#1890ff",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.or"})})})})]},M.key)),f.jsx(x.Form.Item,{style:{marginTop:12,marginBottom:0},children:f.jsx(x.Button,{type:"link",icon:f.jsx(Z.PlusCircleOutlined,{}),disabled:!g,onClick:()=>N({and_list:[{query:"",operator:"",value:""}]}),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.add-or"})})})]})})]},A.key)};return f.jsxs("div",{style:{height:"100%",position:"relative"},children:[f.jsx("div",{style:{height:"calc(100% - 60px)",minHeight:500,overflowY:"auto",paddingRight:20},className:"grayBeautifyScrollbar",children:f.jsx(x.Form,{disabled:!g,form:o,initialValues:d,layout:"vertical",autoComplete:"off",children:f.jsx(x.Form.List,{name:"branches",children:(A,{add:C,remove:E})=>f.jsxs(f.Fragment,{children:[A.map((D,S)=>k(D,S,A.length,E)),A.length<10&&f.jsx(x.Button,{type:"dashed",block:!0,icon:f.jsx(Z.PlusCircleOutlined,{}),disabled:!g,onClick:()=>{const D=A.length+1;C({id:td(),name:R("link.flow.switch.condition_n",{n:D}),or_list:[{and_list:[{query:"",operator:"",value:""}]}]}),setTimeout(()=>{h()},0)},style:{marginBottom:16},children:f.jsx(Ee.FormattedMessage,{id:"link.flow.switch.add_branch"})}),A.length>=10&&f.jsx("div",{style:{textAlign:"center",color:"#999",marginBottom:16},children:f.jsx(Ee.FormattedMessage,{id:"link.flow.switch.max_branches_reached"})})]})})})}),f.jsx("div",{style:{position:"sticky",padding:"10px 20px",paddingBottom:0,backgroundColor:"#FFFFFF",bottom:0,width:"100%",textAlign:"center",borderTop:"1px solid #eaeaea"},children:g&&f.jsx(x.Button,{type:"primary",disabled:!g,style:{width:180,borderRadius:4},onClick:()=>y(),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.save"})})})]})}),t7=({nodeId:t,onSubmit:e,data:n})=>{const[r]=x.Form.useForm(),o=Ct(),{refreshFlow:i}=Cr(),{setNodes:s}=ae.useReactFlow(),a=b.useCallback((c,u)=>{s(d=>d.map(h=>!u&&h.id!==t?h:{...h,data:{...h.data,error_handler:c}}))},[t,s]);b.useEffect(()=>{const c=(n==null?void 0:n.error_handler)||{};r.setFieldsValue({retryEnabled:c.retry||!1,retryCount:c.retry_times||3,retryInterval:c.retry_interval||5,stepFactor:c.step_factor||1.5,maxRetryInterval:c.max_retry_interval||60,alertEnabled:c.warn_type===1,webhookUrl:c.notify_url||"",errorHandling:c.process_type===2?"ignore":"interrupt",applyToAllNodes:!!c.apply_all})},[t,r,n==null?void 0:n.error_handler]);const l=async c=>{try{const u={retry:c.retryEnabled,retry_times:c.retryEnabled?c.retryCount:void 0,retry_interval:c.retryEnabled?c.retryInterval:void 0,step_factor:c.retryEnabled?c.stepFactor:void 0,max_retry_interval:c.retryEnabled?c.maxRetryInterval:void 0,warn_type:c.alertEnabled?1:0,notify_url:c.alertEnabled?c.webhookUrl:void 0,process_type:c.errorHandling==="interrupt"?1:2,apply_all:c.applyToAllNodes};await Ol(t,{error_handler:u}),a(u,c.applyToAllNodes),c.applyToAllNodes&&i(),e()}catch{x.message.error(R("common.save_failed"))}};return f.jsxs("div",{style:{height:"100%",position:"relative"},children:[f.jsx("div",{style:{height:"calc(100% - 60px)",overflowY:"auto",paddingRight:20},children:f.jsxs(Un.ProForm,{form:r,layout:"vertical",disabled:!o,submitter:!1,onFinish:l,children:[f.jsx(Un.ProFormSwitch,{name:"retryEnabled",label:R("app.common.word.enable-retry")}),f.jsx(Un.ProFormDependency,{name:["retryEnabled"],children:({retryEnabled:c})=>c?f.jsxs(f.Fragment,{children:[f.jsx(Un.ProFormDigit,{name:"retryCount",label:R("app.common.word.retry-count"),tooltip:R("app.common.word.retry-count-tooltip"),width:"xl",fieldProps:{min:1,max:10,precision:0,style:{width:"100%"}},rules:[{required:c,message:R("app.common.word.please-enter-retry-count")}]}),f.jsx(Un.ProFormDigit,{name:"retryInterval",label:R("app.common.word.retry-interval"),tooltip:R("app.common.word.retry-interval-tooltip"),fieldProps:{min:1,max:60,precision:0,style:{width:"100%"},addonAfter:"s"},rules:[{required:c,message:R("app.common.word.please-enter-retry-interval")}]}),f.jsx(Un.ProFormDigit,{name:"stepFactor",label:R("app.common.word.step-factor"),tooltip:R("app.common.word.step-factor-tooltip"),width:"xl",fieldProps:{min:1,max:5,precision:1,style:{width:"100%"}},rules:[{required:c,message:R("app.common.word.please-enter-step-factor")}]}),f.jsx(Un.ProFormDigit,{name:"maxRetryInterval",label:R("app.common.word.max-retry-interval"),tooltip:R("app.common.word.max-retry-interval-tooltip"),width:"xl",fieldProps:{min:1,max:300,precision:0,style:{width:"100%"},addonAfter:"s"},rules:[{required:c,message:R("app.common.word.please-enter-max-retry-interval")}]})]}):null}),f.jsx(Un.ProFormSwitch,{name:"alertEnabled",label:R("app.common.word.enable-alert")}),f.jsx(Un.ProFormDependency,{name:["alertEnabled"],children:({alertEnabled:c})=>c?f.jsx(Un.ProFormText,{name:"webhookUrl",label:R("app.common.word.webhook-url"),placeholder:R("app.common.word.enter-webhook-url"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:c,message:R("app.common.word.enter-webhook-url")}]}):null}),f.jsx(Un.ProFormSelect,{name:"errorHandling",label:R("app.common.word.error-handling"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:!0,message:R("app.common.word.select-error-handling")}],options:[{label:R("app.common.word.interrupt-flow"),value:"interrupt"},{label:R("app.common.word.ignore-error"),value:"ignore"}]}),f.jsx(Un.ProFormSwitch,{name:"applyToAllNodes",label:R("app.common.word.apply-to-all-nodes")})]})}),f.jsx("div",{style:{padding:"10px 20px",position:"sticky",paddingBottom:0,backgroundColor:"#FFFFFF",bottom:0,width:"100%",textAlign:"center",borderTop:"1px solid #eaeaea"},children:f.jsx(x.Button,{type:"primary",disabled:!o,onClick:()=>r.submit(),style:{width:180,borderRadius:4},children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.save"})})})]})},n7=b.forwardRef((t,e)=>{const{account_id:n,account_schema_id:r,action_name:o,mcp_tool_description:i,description:s}=t.data,a=t.nodeId,l=dt.useReactive({account_id:n,mcp_tool_description:i||o||s||""}),c=b.useRef(null);b.useImperativeHandle(e,()=>({saveConfig:()=>{var p;return(p=c.current)==null?void 0:p.saveConfig()}}));const u=b.useMemo(()=>({id:t.data.connector_id,name:t.data.connector_name}),[t.data.connector_id,t.data.connector_name]),d=(p,m)=>{t.onSubmit({properties:p,account_id:l.account_id,mcp_tool_description:l.mcp_tool_description},m)},h=b.useCallback(p=>{l.account_id=p??null},[]);return f.jsxs("div",{children:[r?f.jsx(Im,{onChange:h,actionAccountSchemaId:r,value:l.account_id,linkApp:u}):null,f.jsx(x.Form.Item,{layout:"vertical",label:"工具描述",children:f.jsx(x.Input,{value:l.mcp_tool_description,onChange:p=>{l.mcp_tool_description=p.target.value}})}),f.jsx(mD,{ref:c,action:t.data,connector:u,account_id:n,nodeId:a,mcpMode:!0,onSubmit:d})]})}),nd="[workflow:schema-render]",r7=()=>{const{event$:t}=b.useContext($r),e=xf();return t.useSubscription(n=>{n.type==="insert"&&n.expression&&e!=null&&e.activeFieldId&&e.insertVariableToActiveField(n.expression,!1)}),null},o7=t=>f.jsxs("div",{className:"node-config-title",style:{display:"flex",alignItems:"center"},children:[t.icon?f.jsx("img",{src:t.icon,alt:t.name,style:{width:24,height:24}}):null,f.jsx("div",{className:"node-config-title-name",style:{fontSize:16,fontWeight:600,marginLeft:10},children:t.name}),f.jsx("div",{className:"node-config-title-description",style:{fontSize:12,color:"gray",marginLeft:10},children:t.description})]}),i7=b.memo(({visible:t,onClose:e,data:n,nodeType:r=ee.ACTION,nodeId:o=""})=>{var M,T,P,$,W;const i=dt.useEventEmitter();af(),ae.useInternalNode(o);const{setNodeConfigVisible:s,refreshFlow:a}=Cr(),l=b.useRef(null),c=b.useRef(null),u=b.useRef(null),d=b.useRef(null),h=b.useRef(null),p=b.useRef(null),m=b.useRef(null),w=ae.useStoreApi(),v=Vt(),y=((T=(M=v.nodeConfigPanel)==null?void 0:M.testArea)==null?void 0:T.allowManualTest)!==!1,g=dt.useReactive({output:"",ignore:!1}),k=b.useMemo(()=>v.nodeConfigPanel.showSettings&&![ee.TRIGGER,ee.MCP_TOOL,ee.AI_SUB_NODE].includes(r),[r,v.nodeConfigPanel.showSettings]),A=()=>{e()};b.useEffect(()=>{var V;t&&((V=l.current)==null||V.loadVariables())},[t]);const C=(n==null?void 0:n.action_id)||null,E=Array.isArray((P=n==null?void 0:n.config_schema)==null?void 0:P.sub_params),D=!!(n!=null&&n.action_key||n!=null&&n.nodeKey)&&!E,S=(n==null?void 0:n.action_key)||(n==null?void 0:n.nodeKey),_=(n==null?void 0:n.action_ver)??(n==null?void 0:n.nodeVersion)??(($=n==null?void 0:n.node_schema)==null?void 0:$.version),{handleNodeDataUpdate:O}=Hr();b.useEffect(()=>{var V;t&&console.info(`${nd} node config modal opened`,{nodeId:o,nodeType:r,actionId:C,isNextCompatibleNode:D,nextNodeKey:S,nextNodeVersion:_,hasConfigSchema:!!(n!=null&&n.config_schema),hasParams:!!(n!=null&&n.params),actionKey:n==null?void 0:n.action_key,actionVer:n==null?void 0:n.action_ver,dataNodeKey:n==null?void 0:n.nodeKey,dataNodeVersion:n==null?void 0:n.nodeVersion,inlineSchemaVersion:(V=n==null?void 0:n.node_schema)==null?void 0:V.version})},[C,n==null?void 0:n.config_schema,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,(W=n==null?void 0:n.node_schema)==null?void 0:W.version,D,S,_,o,r,t]);const B=b.useCallback(async(V,X)=>{const G=v.flowId;try{const te=w.getState().nodes.find(Y=>Y.id===o),H=D?{flow_id:G,properties:V.params||{},position:te==null?void 0:te.position,action_id:C,account_id:V.account_id??null,proxy_id:V.proxy_id,action_key:S,action_ver:_}:{flow_id:G,...V,position:te==null?void 0:te.position,action_id:C};console.info(`${nd} save node config`,{nodeId:o,nodeType:r,actionId:C,isNextCompatibleNode:D,nextNodeKey:S,nextNodeVersion:_,valueKeys:Object.keys(V||{}),paramsKeys:Object.keys((V==null?void 0:V.params)||{}),propertiesKeys:Object.keys((V==null?void 0:V.properties)||{}),ignoreDebugResult:g.ignore});const j=g.ignore?await Fv(o,"","","",D?V.params:V.properties,g.output):await Ol(o,H);if(j)if(console.info(`${nd} save node config success`,{nodeId:o,nodeType:r,isNextCompatibleNode:D,nextNodeKey:S,nextNodeVersion:_,status:j.status}),g.ignore)m.current.finishNodeTest(),O({id:o,data:{status:me.SUCCESS}}),x.message.success("已忽略调试结果");else{x.message.success("节点配置已保存");const Y=D?{params:V.params,account_id:V.account_id,action_key:S,action_ver:_,nodeKey:S,nodeVersion:_}:{};O({id:o,data:{config_schema:D?V.params:V.properties,account_id:V.account_id,...Y,position:te==null?void 0:te.position,status:j.status}})}X&&!g.ignore&&m.current&&m.current.onTestNode(),g.ignore=!1,g.output=""}catch(te){console.error(`${nd} save node config failed`,{nodeId:o,nodeType:r,isNextCompatibleNode:D,nextNodeKey:S,nextNodeVersion:_,err:te}),g.ignore&&O({id:o,data:{status:me.FAILED}})}},[C,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,O,D,S,_,o,r,g,w]),N=V=>{var X,G,te,H,j;return r===ee.LOOP?(X=h.current)==null?void 0:X.saveConfig(V):r===ee.CONDITION?(G=u.current)==null?void 0:G.saveConfig(V):r===ee.SWITCH?(te=d.current)==null?void 0:te.saveConfig(V):r===ee.MCP_TOOL?(H=p.current)==null?void 0:H.saveConfig(V):(j=c.current)==null?void 0:j.saveConfig(V)},F=async(V,X,G)=>{var te;if(X){g.ignore=!0,g.output=G||"",await N(V)===!1&&((te=m.current)==null||te.finishNodeTest());return}if(V)try{x.message.loading("正在保存节点配置...",0),await N(V),x.message.success("节点配置已保存"),x.message.destroy()}catch(H){x.message.destroy(),console.error("节点配置保存失败:",H),x.message.error("节点配置保存失败,无法执行测试")}};return f.jsx(x.Modal,{open:t,footer:null,closeIcon:null,maskClosable:!0,onCancel:()=>{s(null)},centered:!0,width:"70%",className:"nodes-config-modal",styles:{wrapper:{minWidth:1040},mask:{backgroundColor:"rgba(0, 0, 0, 0.45)"},content:{padding:0,overflow:"hidden"}},children:f.jsx($r.Provider,{value:{event$:i},children:f.jsxs(kf,{children:[f.jsx(r7,{}),f.jsxs("div",{className:"nodes-config-container",children:[f.jsxs("div",{className:"nodes-config-header",children:[f.jsx("div",{className:"header-left",children:f.jsx("span",{className:"header-title",children:" 节点配置"})}),f.jsx("div",{className:"header-right",children:f.jsx(x.Button,{type:"text",icon:f.jsx(Z.ArrowLeftOutlined,{}),onClick:A,className:"back-button",children:"返回画布"})})]}),f.jsx("div",{className:"nodes-config-content",children:f.jsxs(x.Row,{gutter:16,className:"config-row",children:[f.jsx(x.Col,{span:5,className:"left-section",children:f.jsx("div",{className:"variables-section",children:f.jsx(aD,{ref:l,nodeId:o,onInsert:()=>{},open:t})})}),f.jsx(x.Col,{span:12,className:"middle-section",children:f.jsx("div",{className:"form-section",style:{height:"100%"},children:f.jsx(x.Card,{title:f.jsx(o7,{icon:n==null?void 0:n.icon,name:n==null?void 0:n.name,description:n==null?void 0:n.description}),variant:"borderless",styles:{body:{paddingTop:0,paddingBottom:0}},className:"section-card form-card",children:f.jsx(x.Tabs,{style:{height:"100%"},items:[{key:"property",label:"参数配置",children:f.jsxs(f.Fragment,{children:[[ee.CONDITION,ee.SWITCH,ee.LOOP,ee.MCP_TOOL].includes(r)?null:f.jsx(jj,{ref:c,nodeId:o,data:n,onSubmit:B}),r===ee.CONDITION?f.jsx(Uj,{ref:u,nodeId:o,config_schema:n.config_schema,onSubmit:B}):null,r===ee.SWITCH?f.jsx(e7,{ref:d,nodeId:o,config_schema:n.config_schema,onSubmit:B}):null,r===ee.LOOP?f.jsx(Qj,{ref:h,nodeId:o,config_schema:n.config_schema,onSubmit:B}):null,r===ee.MCP_TOOL?f.jsx(n7,{ref:p,nodeId:o,data:n,onSubmit:B}):null]})},{key:"setting",label:"设置",children:f.jsx(t7,{data:n,nodeId:o,onSubmit:()=>{x.message.success("保存成功")}})}].slice(0,k?2:1)})})})}),f.jsx(x.Col,{span:7,className:"right-section",children:y&&f.jsx("div",{className:"test-section",children:f.jsx(x.Card,{variant:"borderless",className:"section-card",children:f.jsx(Rj,{ref:m,nodeId:o,beforeHook:F})})})})]})})]})]})})})},(t,e)=>ut.isEqual(ut.omit(t,["isHovered"]),ut.omit(e,["isHovered"]))),{Text:vD}=x.Typography,{TextArea:s7}=x.Input,a7=({title:t,description:e,note:n,nodeId:r,statusIcon:o,className:i="",onNoteChange:s})=>{const[a,l]=b.useState(!1),[c,u]=b.useState(""),[d,h]=b.useState(!1),p=Ct();if(b.useEffect(()=>{u(n||e||"")},[n,e]),!t&&!e&&!n)return null;const m=g=>{g.stopPropagation(),l(!0)},w=async()=>{if(!r){x.message.error("节点ID不能为空"),l(!1);return}if(c===(n||e||"")){l(!1);return}h(!0);try{await zv(r,c),x.message.success(R("link.flow.remark_modification_success")),s==null||s(c),l(!1)}catch(g){x.message.error("备注保存失败"),console.error("保存备注失败:",g),u(n||e||"")}finally{h(!1)}},v=()=>{u(n||e||""),l(!1)},y=g=>{g.key==="Enter"&&(g.ctrlKey||g.metaKey)?w():g.key==="Escape"&&v()};return f.jsxs("div",{className:`workflow-node-description-container ${i}`,children:[t&&f.jsxs("div",{className:"workflow-node-title-row",children:[f.jsx("span",{className:"workflow-node-title-text",children:t}),o&&f.jsx("span",{className:"workflow-node-status-icon",children:o})]}),f.jsx("div",{className:"workflow-node-description-wrapper",children:a?f.jsx(x.Spin,{spinning:d,children:f.jsx(s7,{value:c,onDoubleClick:g=>g.stopPropagation(),onDragStart:g=>g.stopPropagation(),onDrag:g=>g.stopPropagation(),onChange:g=>u(g.target.value),onBlur:w,onKeyDown:y,placeholder:"请输入备注...",autoSize:{minRows:1,maxRows:4},autoFocus:!0,className:"workflow-node-note-editor nodrag"})}):p?f.jsxs("div",{className:"workflow-node-note-display is-editable",onClick:m,title:"点击编辑备注 (Ctrl+Enter保存, Esc取消)",children:[f.jsx(vD,{className:`workflow-node-description ${c?"":"workflow-node-description-placeholder"}`,children:c||"点击添加备注..."}),f.jsx(Z.EditOutlined,{className:"workflow-node-edit-icon"})]}):f.jsx("div",{className:"workflow-node-note-display",children:f.jsx(vD,{className:"workflow-node-description",children:c})})})]})},{Text:yD}=x.Typography,{TextArea:l7}=x.Input,c7=({title:t,description:e,note:n,statusIcon:r,className:o="",onNoteChange:i})=>{const[s,a]=b.useState(!1),[l,c]=b.useState(""),u=Ct();if(b.useEffect(()=>{c(n||e||"")},[n,e]),!t&&!e&&!n)return null;const d=w=>{w.stopPropagation(),a(!0)},h=()=>{if(l===(n||e||"")){a(!1);return}i==null||i(l),a(!1)},p=()=>{c(n||e||""),a(!1)},m=w=>{w.key==="Enter"&&(w.ctrlKey||w.metaKey)?h():w.key==="Escape"&&p()};return f.jsxs("div",{className:`workflow-node-description-container ${o}`,children:[t&&f.jsxs("div",{className:"workflow-node-title-row",children:[f.jsx("span",{className:"workflow-node-title-text",children:t}),r&&f.jsx("span",{className:"workflow-node-status-icon",children:r})]}),f.jsx("div",{className:"workflow-node-description-wrapper",children:s?f.jsx(l7,{value:l,onDoubleClick:w=>w.stopPropagation(),onDragStart:w=>w.stopPropagation(),onDrag:w=>w.stopPropagation(),onChange:w=>c(w.target.value),onBlur:h,onKeyDown:m,placeholder:"请输入备注...",autoSize:{minRows:1,maxRows:4},autoFocus:!0,className:"workflow-node-note-editor nodrag"}):u?f.jsxs("div",{className:"workflow-node-note-display is-editable",onClick:d,title:"点击编辑备注 (Ctrl+Enter保存, Esc取消)",children:[f.jsx(yD,{className:`workflow-node-description ${l?"":"workflow-node-description-placeholder"}`,children:l||"点击添加备注..."}),f.jsx(Z.EditOutlined,{className:"workflow-node-edit-icon"})]}):f.jsx("div",{className:"workflow-node-note-display",children:f.jsx(yD,{className:"workflow-node-description",children:l})})})]})},u7=t=>({label:t.action_name,description:t.connector_name,config_schema:t.config_schema||t.properties,...Object.entries(t).reduce((e,[n,r])=>(n!=="name"&&(e[n]=r),e),{})}),Vm={color:"#3883f6"},d7=[ee.TRIGGER,ee.AI_SUB_NODE],f7=[ee.TRIGGER,ee.AI_SUB_NODE],h7=({nodeId:t,isDisabled:e=!1,handleViewConfig:n,onDelete:r,className:o,type:i})=>{const{handleNodeDataUpdate:s}=Hr(),{addNodes:a,getNodes:l}=Fi(),c=Vt(),u=ae.useInternalNode(t),d=Ct(),h=b.useMemo(()=>{var O;const E=c.nodeTypes;if(!u)return;const D=E.types[u.type];if(D)return D;const S=(O=u.data)==null?void 0:O.category;return S?Object.values(E.types).find(B=>B.category===S):void 0},[c.nodeTypes,u]),p=b.useMemo(()=>((h==null?void 0:h.operations)||[]).reduce((D,S)=>(D[S.id]=S.enabled,D),{}),[h]),m=b.useMemo(()=>{var S,_;if(!u)return!1;const E=((S=c.canvas.fixedNodes)==null?void 0:S.triggerIds)||[],D=((_=c.nodeTypes.fixed)==null?void 0:_.triggers)||[];return E.includes(u.id)||D.includes(u.type)},[c.canvas.fixedNodes,c.nodeTypes.fixed,u]),w=b.useMemo(()=>{const E=!d7.includes(i),D=p.copy===void 0?!0:p.copy;return E&&D&&d},[i,p,d]),v=b.useMemo(()=>{const E=!f7.includes(i),D=p.disable===void 0?!0:p.disable;return E&&D&&d},[i,p,d]),y=()=>{jv(t,e?"on":"off").then(E=>{s({id:t,data:{closed:E.closed,status:E.status}})})},g=b.useMemo(()=>c.canvas.mode!=="preview"&&!d,[c.canvas.mode,d]);b.useMemo(()=>d&&!m&&c.canvas.allowRemoveTrigger,[d,m,c.canvas.allowRemoveTrigger]);const k=()=>{r&&r(t)},A=async()=>{var D;const E=l();try{const S=E.find(B=>B.id===t);if(!S){x.message.error("获取当前节点信息失败");return}const _=(D=c.canvas.limits)==null?void 0:D.maxNodes;if(typeof _=="number"&&E.length>=_){x.message.warning("已达到画布允许的最大节点数");return}const O=await nf(t);if(O){const B=Bn.createNode(O.node_type,O.id,u7(O),{x:S.position.x,y:S.position.y+100});a([B]),x.message.success("节点复制成功")}}catch(S){x.message.error("节点复制失败"),console.error("复制节点失败:",S)}},C=i===ee.AI_SUB_NODE;return f.jsxs("div",{className:kn("node-operations",o,C?"node-operations-right":""),children:[w&&f.jsx(x.Tooltip,{title:"复制节点",children:f.jsx(x.Button,{type:"text",icon:f.jsx(xi.IoCopyOutline,{style:Vm}),onClick:A,className:kn("operation-button")})}),v&&f.jsx(x.Tooltip,{title:e?"激活节点":"禁用节点",children:f.jsx(x.Button,{type:"text",icon:e?f.jsx(xi.IoPlayOutline,{style:Vm}):f.jsx(xi.IoBanOutline,{style:Vm}),onClick:y,className:kn("operation-button",{disabled:e})})}),d&&f.jsx(x.Popconfirm,{title:"确定要删除此节点吗?",description:"删除后无法恢复,请谨慎操作",onConfirm:k,okText:"确定",cancelText:"取消",placement:"top",children:f.jsx(x.Tooltip,{title:"删除节点",children:f.jsx(x.Button,{type:"text",icon:f.jsx(Bw.RiDeleteBin5Line,{style:{color:"red"}}),className:"operation-button delete-button"})})}),g&&f.jsx(x.Tooltip,{title:"查看配置",children:f.jsx(x.Button,{type:"link",onClick:n,icon:f.jsx(Z.EyeOutlined,{}),className:kn("operation-button")})})]})},bD={type:ee.START,id:"PLACEHOLDER_NODE",position:{x:100,y:250},data:{type:ee.START,name:"开始",nodeId:"PLACEHOLDER_NODE",id:"PLACEHOLDER_NODE",description:"开始节点"}},p7=[ee.AGENT,ee.BROWSER,ee.MCPServer,ee.BuiltinMCP],rd=()=>{const t=ae.useStoreApi(),[e,n]=b.useState(0),o=Vt().engineMode===or.NEXT,i=b.useCallback((u,d)=>{const{nodes:h,setNodes:p}=t.getState(),m=Pn(h,w=>{const v=w.find(y=>y.id===d.id);v.data?v.data.isHovered=!0:v.data={isHovered:!0}});p(m)},[]),s=b.useCallback((u,d)=>{const{nodes:h,setNodes:p}=t.getState(),m=Pn(h,w=>{const v=w.find(y=>y.id===d.id);v.data?v.data.isHovered=!1:v.data={isHovered:!1}});p(m)},[]),a=b.useCallback(u=>{const{nodes:d,setNodes:h}=t.getState(),p=Pn(d,m=>{u.forEach(w=>{w.type==="select"&&(m.find(v=>v.id===w.id).selected=w.selected)})});h(p)},[t]),l=b.useCallback((u,d,h=new Set)=>(d.filter(m=>m.source===u&&m.sourceHandle!==Ie.OUTPUT&&m.sourceHandle!==Ie.DONE&&m.sourceHandle!==Ie.LOOP&&m.sourceHandle!==Ie.TRUE&&m.sourceHandle!==Ie.FALSE).forEach(m=>{const w=m.target;h.has(w)||(h.add(w),l(w,d,h))}),h),[]),c=b.useCallback((u,d)=>{const{nodes:h,edges:p,setNodes:m,setEdges:w}=t.getState(),v=new Set(u);p7.includes(d)&&u.forEach(E=>{l(E,p).forEach(S=>{v.add(S)})});const y=Array.from(v),g=h.filter(E=>!y.includes(E.id)),k=g.map(E=>E.id),C=p.filter(E=>!y.includes(E.source)&&!y.includes(E.target)).filter(E=>k.includes(E.target));if(o)g.length===0&&g.push(bD);else{const E=g.some(D=>D.type===ee.TRIGGER);(g.length===0||!E)&&g.push(bD)}m(g),w(C)},[t,l]);return{autoSaveNum:e,onNodeMouseEnter:i,onNodeMouseLeave:s,handleNodesChange:a,handleNodesDelete:c}},Wm={color:"#3883f6"},m7=[ee.TRIGGER,ee.AI_SUB_NODE],g7=[ee.TRIGGER,ee.AI_SUB_NODE],w7=({nodeId:t,isDisabled:e=!1,handleViewConfig:n,className:r,type:o})=>{const{handleNodeDataUpdate:i}=Hr(),{addNodes:s,getNodes:a}=Fi(),{handleNodesDelete:l}=rd(),c=Vt(),u=ae.useInternalNode(t),d=Ct(),h=b.useMemo(()=>{var _;const E=c.nodeTypes;if(!u)return;const D=E.types[u.type];if(D)return D;const S=(_=u.data)==null?void 0:_.category;if(S)return Object.values(E.types).find(O=>O.category===S)},[c.nodeTypes,u]),p=b.useMemo(()=>((h==null?void 0:h.operations)||[]).reduce((D,S)=>(D[S.id]=S.enabled,D),{}),[h]),m=b.useMemo(()=>{var S,_;if(!u)return!1;const E=((S=c.canvas.fixedNodes)==null?void 0:S.triggerIds)||[],D=((_=c.nodeTypes.fixed)==null?void 0:_.triggers)||[];return E.includes(u.id)||D.includes(u.type)},[c.canvas.fixedNodes,c.nodeTypes.fixed,u]),w=b.useMemo(()=>{const E=!m7.includes(o),D=p.copy===void 0?!0:p.copy;return E&&D&&d},[o,p,d]),v=b.useMemo(()=>{const E=!g7.includes(o),D=p.disable===void 0?!0:p.disable;return E&&D&&d},[o,p,d]),y=b.useMemo(()=>c.canvas.mode!=="preview"&&!d,[c.canvas.mode,d]),g=()=>{i({id:t,data:{closed:e?"0":"1",status:e?"on":"off"}})},k=()=>{if(m){x.message.warning("当前触发节点已被配置为不可删除");return}l([t],o)},A=()=>{var N;const E=a(),D=E.find(F=>F.id===t);if(!D){x.message.error("获取当前节点信息失败");return}const S=(N=c.canvas.limits)==null?void 0:N.maxNodes;if(typeof S=="number"&&E.length>=S){x.message.warning("已达到画布允许的最大节点数");return}const _=crypto.randomUUID(),O=ut.cloneDeep(D.data);O.id=_,O.nodeId=_,O.name&&(O.name=`${O.name} 副本`),O.status=void 0,O.output=void 0;const B=Bn.createNode(D.type,_,O,{x:D.position.x+50,y:D.position.y+100});s([B]),x.message.success("节点复制成功")},C=o===ee.AI_SUB_NODE;return f.jsxs("div",{className:kn("node-operations",r,C?"node-operations-right":""),children:[w&&f.jsx(x.Tooltip,{title:"复制节点",children:f.jsx(x.Button,{type:"text",icon:f.jsx(xi.IoCopyOutline,{style:Wm}),onClick:A,className:"operation-button"})}),v&&f.jsx(x.Tooltip,{title:e?"激活节点":"禁用节点",children:f.jsx(x.Button,{type:"text",icon:e?f.jsx(xi.IoPlayOutline,{style:Wm}):f.jsx(xi.IoBanOutline,{style:Wm}),onClick:g,className:kn("operation-button",{disabled:e})})}),d&&f.jsx(x.Popconfirm,{title:"确定要删除此节点吗?",description:"删除后无法恢复,请谨慎操作",onConfirm:k,okText:"确定",cancelText:"取消",placement:"top",children:f.jsx(x.Tooltip,{title:"删除节点",children:f.jsx(x.Button,{type:"text",icon:f.jsx(Bw.RiDeleteBin5Line,{style:{color:"red"}}),className:"operation-button delete-button"})})}),y&&f.jsx(x.Tooltip,{title:"查看配置",children:f.jsx(x.Button,{type:"link",onClick:n,icon:f.jsx(Z.EyeOutlined,{}),className:"operation-button"})})]})};function v7(t){const{color:e,visible:n}=t;return f.jsx("span",{style:{width:16,height:16,borderRadius:10,backgroundColor:e,display:n?"flex":"none",justifyContent:"center",alignItems:"center",position:"absolute",zIndex:1e3,top:"calc(50% - 8px)",left:-8},children:f.jsx(Z.ThunderboltOutlined,{style:{fontSize:10,color:"white"}})})}const bs={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)"}},_n=({id:t,type:e=ee.ACTION,selected:n=!1,icon:r,inputs:o=[],outputs:i=[],showToolbar:s=!0,width:a,height:l,className:c="",status:u=me.IDLE,onTestNode:d,data:h,contentRender:p,showNodeDescription:m=!0,onToggleNodeDisabled:w})=>{const{currentNodeConfigVisibleId:v,setNodeConfigVisible:y}=Cr(),{handleNodeDataUpdate:g}=Hr(),{handleNodesDelete:k}=rd(),A=Vt(),C=G=>{g({id:t,data:{note:G}})},E=b.useCallback(()=>{y(null)},[]),D=(h==null?void 0:h.isHovered)||!1,S=ae.useNodeConnections({id:t}),_=b.useMemo(()=>e===ee.TRIGGER,[e,S]),O=()=>{y(t)},B=b.useMemo(()=>(h==null?void 0:h.closed)==="1",[h==null?void 0:h.closed]),N=b.useMemo(()=>typeof a=="number"&&a>0?a:300,[a]),F=(G="node")=>{if(B)return`workflow-${G}-disabled`;switch(u){case me.INVALID:return`workflow-${G}-warning`;case me.FAILED:return`workflow-${G}-failed`;case me.SUCCESS:case me.RUNNABLE:return`workflow-${G}-success`;case me.RUNNING:return`workflow-${G}-running`;case me.IDLE:default:return""}},M=()=>{if(B)return bs.disabled;switch(u){case me.INVALID:return bs.warning;case me.FAILED:return bs.error;case me.SUCCESS:case me.RUNNABLE:return bs.success;case me.RUNNING:return bs.info;default:return bs.info}},T=(G="normal")=>M()[G],P=()=>o.map(G=>f.jsx(N0,{nodeId:t,id:G.id,position:G.position,type:je.TARGET,label:G.label,nodeStatus:u,style:G.style},`${t}-${G.id}`)),$=async()=>{var H,j;const G=((H=A.canvas.fixedNodes)==null?void 0:H.triggerIds)||[],te=((j=A.nodeTypes.fixed)==null?void 0:j.triggers)||[];if(G.includes(t)||te.includes(e)){x.message.warning("当前触发节点已被配置为不可删除");return}await Qd(t),k([t],e)},W=b.useMemo(()=>i.map(G=>f.jsx(N0,{nodeId:t,connectionLimit:G.maxConnections,id:G.id,style:G.style,position:G.position,protocol:G.protocol,type:G.type,label:G.label,shape:G.shape,nodeStatus:u},`${t}-${G.id}`)),[u,JSON.stringify(i)]),V=()=>{switch(u){case me.INVALID:return f.jsx("div",{className:"workflow-node-status-icon workflow-node-warning-icon",children:f.jsx(Z.WarningFilled,{style:{color:T(),fontSize:16}})});case me.FAILED:return f.jsx("div",{className:"workflow-node-status-icon workflow-node-failed-icon",children:f.jsx(Z.CloseCircleFilled,{style:{color:T(),fontSize:16}})});case me.SUCCESS:case me.RUNNABLE:return f.jsx("div",{className:"workflow-node-status-icon workflow-node-success-icon",children:f.jsx(Z.CheckCircleFilled,{style:{color:T(),fontSize:16}})});case me.RUNNING:return f.jsx("div",{className:"workflow-node-status-icon workflow-node-running-icon",children:f.jsx(Z.LoadingOutlined,{style:{color:T(),fontSize:16}})});default:return null}},X=()=>f.jsxs(f.Fragment,{children:[r&&f.jsx("div",{className:"workflow-node-icon-wrapper",children:f.jsx("div",{className:"workflow-node-icon",children:r})}),m&&(A.engineMode===or.NEXT?f.jsx(c7,{title:h==null?void 0:h.name,note:(h==null?void 0:h.note)||"",statusIcon:V(),onNoteChange:C,className:"workflow-node-text"}):f.jsx(a7,{title:h==null?void 0:h.connector_name,nodeId:t,note:(h==null?void 0:h.note)||"",statusIcon:V(),onNoteChange:C,description:h.action_name,className:"workflow-node-text"}))]});return f.jsxs(b.Fragment,{children:[f.jsxs("div",{style:{width:N,height:l||"auto"},onDoubleClick:O,className:`${c}
|
|
70
|
+
`),yj=b.forwardRef(({onValueChange:t=u=>{},removeTagButton:e=!1,initValue:n,onFocus:r,addImageElement:o,transformInputText:i,transformInputElement:s,textAreaMode:a,capturePattern:l=lj},c)=>{const u=b.useRef(null),d=b.useMemo(()=>gj(cC(xy()),l),[]),[h,p]=b.useState(Xu(n,l));let m=n;const w=b.useCallback(({element:A,children:C,attributes:E})=>{switch(A.type){case"paragraph":return f.jsx(mj,{attributes:E,element:A,children:C});case"tag":return f.jsx(pj,{attributes:E,element:A,removeTagButton:e,addImageElement:o,transformInputText:i,transformInputElement:s,children:C});default:return f.jsx(hj,{attributes:E,element:A,children:C})}},[]);b.useEffect(()=>{p(Xu(n,l))},[n]);const v=b.useCallback(A=>{u.current=d.selection;const C=vj(A);C!==m&&(m=A,p(A),t(C))},[]),y=A=>{ce.delete(d,{at:[0]});const C=Xu(A,l);d.children=Xu("",l),ce.insertNodes(d,C,{at:[0]})},g=A=>{lD(d,A,{at:u.current.focus}),ce.move(d,{distance:h.length-1})};b.useImperativeHandle(c,()=>({insertTag:g,setValueByParent:y}));const k=Ct();return f.jsx(lC,{editor:d,initialValue:h,onChange:v,children:f.jsx(oC,{style:a?{minHeight:60,maxHeight:200}:{maxHeight:150},onFocus:r,value:h,readOnly:!k,spellCheck:!1,className:"ce-tag_input",renderElement:w})})}),cD=t=>f.jsx("div",{style:{display:t.show?"block":"none",height:"100%",width:"100%",...t.style??{}},children:t.children}),tr=t=>{const e=b.useMemo(()=>er(),[]),{event$:n}=b.useContext($r),r=b.useRef(null),[o,i]=b.useState(""),s=dt.useReactive({innerValueType:"",radioType:"",openEditorNumber:0});b.useEffect(()=>{s.radioType=t.valueType},[t.valueType,s]),n.useSubscription(u=>{var d,h,p;if(u.type==="insert"&&u.currentInputId===e){(h=r==null?void 0:(d=r.current).insertTag)==null||h.call(d,u.expression.slice(2,-2));const m=(o??"")+(t.valueType==="FIX_VALUE"?u.expression.slice(2,-2):u.expression);i(m),(p=t.onChange)==null||p.call(t,m)}});const a=b.useMemo(()=>!t.borrow&&["JS_EXP","ADAPTOR"].includes(t.valueType),[t.borrow,t.valueType]);b.useEffect(()=>{i(t.value)},[t.value]);const l=u=>{var d;(d=t.onChange)==null||d.call(t,u)},c=u=>{var d;i(u),(d=t.onChange)==null||d.call(t,u)};return f.jsxs(Yz,{id:e,canEditInEditor:!t.disableIDE,openEditorNumber:s.openEditorNumber,nodeId:t.nodeId,value:t.value,onFinish:u=>{r.current.setValueByParent(u)},children:[a&&f.jsx("div",{style:{textAlign:"right",position:"absolute",top:-34,right:2},children:f.jsxs(x.Radio.Group,{value:s.radioType,onChange:u=>{s.radioType=u.target.value,s.radioType==="ADAPTOR"&&r.current.setValueByParent(o)},size:"small",style:{marginTop:16},children:[f.jsx(x.Radio.Button,{style:{height:18,fontSize:10,display:"inline-flex",alignItems:"center"},value:"ADAPTOR",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.string"})}),f.jsx(x.Radio.Button,{style:{height:18,fontSize:10,display:"inline-flex",alignItems:"center"},value:"JS_EXP",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.script"})})]})}),f.jsx(cD,{show:s.radioType==="ADAPTOR"||!a&&s.radioType!=="PLAIN_CODE",children:f.jsx(yj,{ref:r,disabled:t.disabled,textAreaMode:t.textAreaMode,initValue:t.value,onFocus:()=>{["JS_EXP","FIX_VALUE","ADAPTOR","PLAIN_TEXT","PLAIN_CODE"].includes(t.valueType)&&(n.emit({type:"visible",visible:!0}),n.emit({type:"setCurrentInputId",currentInputId:e}))},removeTagButton:!1,onValueChange:l,addImageElement:u=>{const h=(u==null?void 0:u.split(".")[0]).slice(1),p=Yu.getConfig().icons.get(h);return p?f.jsx("img",{src:p,alt:h,onError:m=>{m.target.src="/uc/images/default_connector.png"}}):f.jsx(Z.ThunderboltOutlined,{})},transformInputText:u=>ut.includes(["sys_tenant_id","response"],u)?u:u.split(".").slice(1).join("."),transformInputElement:u=>f.jsx("span",{style:{color:"blue"},children:u})})}),f.jsxs(cD,{show:(s.radioType==="JS_EXP"||s.radioType==="PLAIN_CODE")&&(s.radioType==="PLAIN_CODE"||a),style:{position:"relative"},children:[f.jsx("div",{children:f.jsx(aj,{...t,onValueChange:c})}),f.jsx("span",{onClick:()=>{s.openEditorNumber++},style:{position:"absolute",right:16,top:4,color:"white",fontSize:16,cursor:"pointer"},children:f.jsx(Z.FullscreenOutlined,{})})]})]})},bj=({value:t=[],onChange:e,valueType:n})=>{const r=u=>{let d=[...o.items];d=d.filter(h=>h.id!==u),e==null||e(d)},o=dt.useReactive({items:[]}),i=u=>{const d=u.which||u.keyCode;(d===37||d===229)&&u.preventDefault()};b.useEffect(()=>{const u=Array.isArray(t)?t:[];o.items=u.map(d=>({...d,id:d.id??er()}))},[t]);const s=()=>{e==null||e([...o.items,{key:"",value:"",id:er()}])},a=(u,d)=>{e==null||e(o.items.map(h=>h.id===u?{...h,key:d}:h))},l=(u,d)=>{e==null||e(o.items.map(h=>h.id===u?{...h,value:d}:h))},c=Ct();return f.jsxs("div",{children:[o.items.length?o.items.map((u,d)=>f.jsxs(x.Space,{size:"small",style:{display:"flex",marginBottom:8,width:"100%"},align:"center",children:[f.jsx(x.Input,{defaultValue:u.key,onKeyDown:i,onChange:h=>{var p;a(u.id,(p=h.target.value)==null?void 0:p.replace(/'/g,""))},placeholder:"Key"}),f.jsx("span",{style:{display:"inline-block",transform:"translateY(2px)",width:300},children:f.jsx(tr,{borrow:!0,disableIDE:!0,placeholder:"Value",style:{width:300},value:u.value,onChange:h=>l(u.id,h),valueType:n,nodeId:""})}),c&&f.jsx(Z.DeleteOutlined,{onClick:()=>{r(u.id)}})]},u.id)):null,f.jsxs(x.Button,{type:"dashed",onClick:s,block:!0,children:[f.jsx(Z.PlusOutlined,{})," ",f.jsx(Ee.FormattedMessage,{id:"app.common.word.add-field"})]})]})},Cj=t=>null,kj=t=>f.jsx(x.TimePicker,{style:{width:"100%"},use12Hours:!1,format:"HH:mm",value:t.value?cr(t.value,"HH:mm"):null,onChange:e=>{const n=cr(e).format("HH:mm:00");t.onChange&&(t==null||t.onChange(n))}}),{Text:xj}=x.Typography,uD=t=>f.jsx("div",{style:{padding:6,paddingRight:0,border:"1px solid #b0b5cb",borderRadius:4},children:f.jsx(x.Tooltip,{title:t.value,color:"cyan",placement:"topLeft",styles:{body:{width:500}},children:f.jsx(xj,{style:{color:"#b0b5cb"},ellipsis:!0,copyable:{text:t.value},children:t.value})})}),Sj=({value:t=[],onChange:e,...n})=>{const[r,o]=b.useState([]);b.useEffect(()=>{const h=Array.isArray(t)?t:[];o(h.map(p=>({...p,id:p.id??er()})))},[t]);const i=Ct(),s=h=>{const p=r.filter(m=>m.id!==h);o(p),e==null||e(p)},a=()=>{const h={field:"",dataType:"string",desc:"",required:!1,id:er()},p=[...r,h];o(p),e(p)},l=(h,p)=>{const m=r.map(w=>w.id===h?{...w,field:p}:w);o(m),e(m)},c=(h,p)=>{const m=r.map(w=>w.id===h?{...w,dataType:p}:w);o(m),e(m)},u=(h,p)=>{const m=r.map(w=>w.id===h?{...w,desc:p}:w);o(m),e(m)},d=(h,p)=>{const m=r.map(w=>w.id===h?{...w,required:p}:w);o(m),e(m)};return f.jsxs("div",{children:[r.length?r.map(h=>f.jsxs(x.Space,{size:"small",style:{display:"flex",marginBottom:8,width:"100%"},align:"start",children:[f.jsx(x.Input,{value:h.field,onChange:p=>l(h.id,p.target.value),placeholder:"字段名称",status:"",style:{width:130},disabled:!i}),f.jsx(x.Select,{value:h.dataType,onChange:p=>c(h.id,p),placeholder:"数据类型",style:{width:100},disabled:!i,options:[{label:"字符串",value:"string"},{label:"数字",value:"number"},{label:"日期",value:"date"},{label:"布尔",value:"boolean"}]}),f.jsx(x.Input,{value:h.desc,onChange:p=>u(h.id,p.target.value),placeholder:"字段描述",status:"",style:{width:200},disabled:!i}),f.jsx(x.Select,{value:h.required,onChange:p=>d(h.id,p),placeholder:"是否必填",style:{width:100},disabled:!i,options:[{label:"是",value:!0},{label:"否",value:!1}]}),i&&f.jsx(Z.DeleteOutlined,{onClick:()=>{s(h.id)},style:{cursor:"pointer",color:"#ff4d4f",marginTop:8}})]},h.id)):null,i&&f.jsx(x.Button,{type:"dashed",onClick:a,block:!0,icon:f.jsx(Z.PlusOutlined,{}),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.add-field"})})]})},Ej=t=>{const e=b.useMemo(()=>er(),[]),{event$:n}=b.useContext($r),[r,o]=b.useState("");n.useSubscription(s=>{var a;if(s.type==="insert"&&s.currentInputId===e){const l=(r??"")+(t.valueType==="FIX_VALUE"?s.expression.slice(2,-2):s.expression);o(l),(a=t.onChange)==null||a.call(t,l)}}),b.useEffect(()=>{o(t.value)},[t.value]);const i=s=>{var a;o(s.target.value),(a=t.onChange)==null||a.call(t,s.target.value)};return f.jsx(x.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:r,addonBefore:R("link.flow.cipherText"),onChange:i})},Dj=t=>{var o;const e=er(),{multiple:n,...r}=t;return f.jsx(x.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=>f.jsx(x.Select.Option,{label:i.label,value:i.value,children:i.label},i.value))})},Aj=t=>f.jsx(x.TimePicker,{style:{width:"100%"},value:t.value?cr(t.value,"HH:mm:ss"):null,onChange:e=>{t.onChange&&(t==null||t.onChange(e==null?void 0:e.format("HH:mm:ss")))}}),Oj=["sample","test","payload","body"],Tj=["测试","样本","sample","test","payload","body"],dD=t=>{var n,r,o;return[ve.JSON,ve.TEXTAREA,ve.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},fD=(t,e)=>{if(!t)return!1;const n=t.toLowerCase();return e.some(r=>n.includes(r))},_j=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}},Nj=t=>{const{form:e,configList:n=[],disabled:r,...o}=t;af();const[i,s]=b.useState(!1),[a,l]=b.useState(0),c=b.useRef(void 0),u=oo(),d=b.useMemo(()=>{const m=n.find(w=>dD(w)&&(fD(w.name,Oj)||fD(w.display_name,Tj)));return m||n.find(w=>dD(w))},[n]),h=b.useCallback(()=>{c.current&&(clearInterval(c.current),c.current=void 0)},[]);b.useEffect(()=>()=>{h()},[h]);const p=b.useCallback(async()=>{if(!u){x.message.warning("缺少连接流ID,无法监听Webhook");return}if(!(d!=null&&d.name)){x.message.warning("未找到测试数据字段,无法填充监听结果");return}if(!i){s(!0),l(10),c.current=setInterval(()=>{l(m=>m<=1?(h(),0):m-1)},1e3);try{const m=await Bv(u,{timeout_seconds:10}),w=_j(m);w?(e.setFieldsValue({[d.name]:w}),x.message.success("已捕获Webhook推送数据并填充测试样例")):x.message.info("监听结束,暂无新的推送数据")}catch(m){console.error("监听Webhook失败:",m),x.message.error("监听失败,请稍后重试")}finally{h(),s(!1),l(0)}}},[u,e,i,d==null?void 0:d.name,h]);return f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[f.jsx("div",{style:{flex:1},children:f.jsx(uD,{...o})}),f.jsx(x.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)`:""}`:"监听"})]})},Bj={configFormContainer:"_configFormContainer_1frpl_1"};function Fj(t){return lz(t==null?void 0:t.credentials)}const Hm=new Map,Ju=new Map,Ru=new Map,Qu=new Map,vn="[workflow:schema-render]",Ij=1;function zm(t,e){return`${t}@${e??"latest"}`}function hD(t,e,n){var o,i,s;if(!t||!n){console.warn(`${vn} skip preload classic schema cache`,{nodeKey:t,nodeVersion:e,hasSchema:!!n});return}const r=zm(t,e);console.info(`${vn} preload classic schema cache`,{cacheKey:r,nodeKey:t,nodeVersion:e,schemaVersion:n.version,inputFields:((o=n.input_fields)==null?void 0:o.length)??0,outputs:((i=n.outputs)==null?void 0:i.length)??0,credentials:((s=n.credentials)==null?void 0:s.length)??0}),Ru.set(r,n)}async function Mj(t,e){if(!t)return console.warn(`${vn} skip classic ACM schema fetch without nodeKey`,{nodeKey:t,nodeVersion:e,endpoint:"/acm/actions/{nodeKey}/{version}"}),null;const n=e??Ij;e==null&&console.warn(`${vn} fallback classic ACM schema version`,{nodeKey:t,nodeVersion:e,fallbackNodeVersion:n,reason:"node data does not include action_ver/nodeVersion after reload",endpoint:"/acm/actions/{nodeKey}/{version}"});const r=zm(t,n);if(Ru.has(r))return console.info(`${vn} classic schema cache hit`,{cacheKey:r,nodeKey:t,nodeVersion:n}),Ru.get(r);if(Qu.has(r))return console.info(`${vn} classic schema request pending reuse`,{cacheKey:r,nodeKey:t,nodeVersion:n}),Qu.get(r);console.info(`${vn} fetch classic schema from ACM`,{cacheKey:r,nodeKey:t,nodeVersion:n,endpoint:"/acm/actions/{nodeKey}/{version}"});const o=Dv(t,n).then(i=>{var s,a,l;return console.info(`${vn} classic schema fetch success`,{cacheKey:r,nodeKey:t,nodeVersion:n,schemaVersion:i.version,inputFields:((s=i.input_fields)==null?void 0:s.length)??0,outputs:((a=i.outputs)==null?void 0:a.length)??0,credentials:((l=i.credentials)==null?void 0:l.length)??0}),Ru.set(r,i),i}).catch(i=>(console.warn(`${vn} classic schema fetch failed`,{cacheKey:r,nodeKey:t,nodeVersion:n,endpoint:"/acm/actions/{nodeKey}/{version}",err:i}),null)).finally(()=>{Qu.delete(r)});return Qu.set(r,o),o}async function Zu(t,e){if(!t)return console.warn(`${vn} skip schema fetch without nodeKey`,{nodeVersion:e}),null;const n=zm(t,e);if(Hm.has(n))return console.info(`${vn} schema cache hit`,{cacheKey:n,nodeKey:t,nodeVersion:e}),Hm.get(n);if(Ju.has(n))return console.info(`${vn} schema request pending reuse`,{cacheKey:n,nodeKey:t,nodeVersion:e}),Ju.get(n);console.info(`${vn} fetch schema from DIP`,{cacheKey:n,nodeKey:t,nodeVersion:e,endpoint:e?"/dip/api/nodes/{nodeKey}/{version}":"/dip/api/nodes/{nodeKey}"});const r=EN(t,e).then(o=>{var i,s,a;return console.info(`${vn} schema fetch success`,{cacheKey:n,nodeKey:t,nodeVersion:e,inputFields:((i=o.input_fields)==null?void 0:i.length)??0,outputs:((s=o.outputs)==null?void 0:s.length)??0,credentials:((a=o.credentials)==null?void 0:a.length)??0}),Hm.set(n,o),o}).catch(o=>(console.warn(`${vn} schema fetch failed`,{cacheKey:n,nodeKey:t,nodeVersion:e,endpoint:e?"/dip/api/nodes/{nodeKey}/{version}":"/dip/api/nodes/{nodeKey}",err:o}),null)).finally(()=>{Ju.delete(n)});return Ju.set(n,r),r}const Pj=[ve.TEXT,ve.PASSWORD,ve.SELECT,ve.EXTEND_OBJ,ve.DATE,ve.TIME,ve.DATETIME,ve.TEXTAREA,ve.FIXED_OBJ,ve.JSON],ed="[workflow:schema-render]",Lj=/^\{\{([^.{}]+)\.(.+)\}\}$/,$j=t=>{switch(t.page_control){case ve.SELECT:return t.multi_valued?[]:null;case ve.EXTEND_OBJ:return{};case ve.HIDDEN:return"";case ve.TEXT:return"";case ve.PASSWORD:return"";case ve.LABEL:return"";case ve.DATE:return null;case ve.TIME:return null;case ve.DATETIME:return null;case ve.TEXTAREA:return"";case ve.FIXED_OBJ:return{};case ve.MultiRowAIExtractConfig:return[];case ve.JSON:return""}},pD=(t,e,n,r,o)=>{const i=t.display_name,s=()=>{var a,l,c;switch(t.page_control){case ve.SELECT:return f.jsx(Dj,{options:ZC(t.option_value_objects??t.option_values),multiple:t.multi_valued});case ve.EXTEND_OBJ:return f.jsx(bj,{valueType:t.value_type});case ve.HIDDEN:return f.jsx(Cj,{});case ve.TEXT:return f.jsx(tr,{valueType:t.value_type,nodeId:e});case ve.PASSWORD:return f.jsx(Ej,{valueType:t.value_type});case ve.LABEL:return(a=r==null?void 0:r.webhookField)!=null&&a.enabled&&t.name==="hookUrl"&&r.webhookField.form?f.jsx(Nj,{form:r.webhookField.form,configList:r.webhookField.configList,disabled:r.webhookField.disabled}):f.jsx(uD,{});case ve.DATE:return f.jsx(Cz,{});case ve.TIME:return f.jsx(Aj,{});case ve.DATETIME:return f.jsx(kz,{});case ve.TEXTAREA:return f.jsx(tr,{valueType:t.value_type,textAreaMode:!0,nodeId:e});case ve.FIXED_OBJ:return f.jsx(x.Input.TextArea,{});case ve.JSON:return f.jsx(tr,{valueType:t.value_type,nodeId:e});case ve.MultiRowAIExtractConfig:return f.jsx(Sj,{valueType:t.value_type});case ve.MULTI_SELECT_LIST:return f.jsx(Az,{selectType:"KNOWLEDGE_BASE"});case ve.SYNC_HOUR_MINUTE:return f.jsx(kj,{});case ve.AUTH_TOKEN:return f.jsx(pz,{disabled:(l=r==null?void 0:r.webhookField)==null?void 0:l.disabled});case ve.SECRET_KEY:return f.jsx(gz,{});case ve.SELECT_CLIENT:return f.jsx(yz,{});default:{const u=(c=o==null?void 0:o.form)==null?void 0:c.find(d=>d.name===t.page_control);return u?f.jsx(u.component,{}):null}}};return n&&Pj.includes(t.page_control)?f.jsx("div",{children:f.jsx(x.Form.Item,{required:t.required,rules:[{required:t.required,message:t.page_control===ve.SELECT?R("link.flow.please_select")+t.display_name:R("link.flow.please_enter")+t.display_name}],label:i,name:t.name,children:f.jsx(bz,{children:s()})})},t.ui_id):f.jsx(x.Form.Item,{required:t.required,style:t.page_control===ve.HIDDEN?{display:"none"}:{},rules:[{required:t.required,message:t.page_control===ve.SELECT?R("link.flow.please_select")+t.display_name:R("link.flow.please_enter")+t.display_name},{validator(a,l,c){if(t.page_control===ve.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)},Hj=t=>(t.child_conditions??[]).map(e=>e.left).filter(e=>!!e),zj=(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},mD=b.forwardRef((t,e)=>{var le,L,q,J,K;const{action:n,connector:r,nodeId:o,account_id:i,mcpMode:s}=t,a=Vt(),l=ae.useStoreApi(),c=dt.useReactive({proxyId:"0"}),{config_schema:u,proxy_id:d,protocol:h}=n,p=n.action_key||n.nodeKey,m=n.action_ver??n.nodeVersion??((le=n.node_schema)==null?void 0:le.version),w=n.node_schema,v=Array.isArray(u==null?void 0:u.sub_params),y=b.useMemo(()=>v||!p?null:`${p}@${m??"latest"}`,[v,p,m]),g=y?`${o}:${y}`:o,k=n.account_id??i,A=!v&&((L=w==null?void 0:w.input_fields)!=null&&L.length||(q=w==null?void 0:w.credentials)!=null&&q.length)?w:null,[C,E]=b.useState(()=>y&&A?{identity:y,schema:A,loading:!1,finished:!0}:null),D=(C==null?void 0:C.identity)===y?C:null,S=A??(D==null?void 0:D.schema)??null,_=Fj(S),O=Gu((S==null?void 0:S.credentials)??[]),B=!!(!v&&p&&!S&&((D==null?void 0:D.loading)??!(D!=null&&D.finished)));b.useEffect(()=>{var re,se;!C||C.identity===y||console.info(`${ed} classic renderer ignore stale next schema state`,{nodeId:o,nodeKey:p,nodeVersion:m,currentIdentity:y,staleIdentity:C.identity,staleLoading:C.loading,staleFinished:C.finished,staleInputFields:((se=(re=C.schema)==null?void 0:re.input_fields)==null?void 0:se.length)??0})},[y,C,o,p,m]),b.useEffect(()=>{d&&(c.proxyId=d)},[d]);const[N]=x.Form.useForm(),[F,M]=b.useState(k);if(b.useEffect(()=>{M(k)},[g,k]),v){const re=(J=u.sub_params)==null?void 0:J.reduce((se,he)=>{let Ce=he.value;he.page_control===ve.EXTEND_OBJ&&(Ce=tz(Ce));const Fe=N.getFieldValue(he.name);return se[he.name]=Fe??Ce??$j(he),se},{});N.setFieldsValue({...re})}const T=b.useRef(null),P=b.useRef(null);b.useEffect(()=>{if(!y||!p){E(null);return}if(A){E({identity:y,schema:A,loading:!1,finished:!0});return}let re=!1;return E({identity:y,schema:null,loading:!0,finished:!1}),console.info(`${ed} classic renderer load next schema`,{nodeId:o,nodeKey:p,nodeVersion:m}),Mj(p,m).then(se=>{var he;re||(E({identity:y,schema:se,loading:!1,finished:!0}),console.info(`${ed} classic renderer next schema loaded`,{nodeId:o,nodeKey:p,nodeVersion:m,inputFields:((he=se==null?void 0:se.input_fields)==null?void 0:he.length)??0}))}).catch(se=>{re||(E({identity:y,schema:null,loading:!1,finished:!0}),console.error(`${ed} classic renderer next schema load failed`,{nodeId:o,nodeKey:p,nodeVersion:m,err:se}))}),()=>{re=!0}},[A,y,o,p,m]);const $=b.useMemo(()=>{var re;return(re=S==null?void 0:S.input_fields)!=null&&re.length?el(S.input_fields):null},[S]),W=!!(!v&&($||_||S)),V=b.useMemo(()=>n.params?n.params:u&&!v?u:{},[n,u,v]),X=b.useMemo(()=>JSON.stringify(V??{}),[V]);b.useEffect(()=>{v||!W||(N.resetFields(),N.setFieldsValue(V))},[g,N,v,V,X,W]);const G=b.useCallback(re=>{const se=re.trim().match(Lj);if(!se)return null;const he=se[1],Ce=se[2];if(he==="global")return null;const Fe=he.startsWith("N")?he.slice(1):he,qe=l.getState().nodes.find(Le=>Le.id===Fe);return qe?{fieldPath:Ce,node:qe,variableNodeId:he}:null},[l]),te=b.useCallback(re=>{var se;return((se=G(re))==null?void 0:se.fieldPath)??re.replace(/^\{\{|\}\}$/g,"")},[G]),H=b.useCallback(re=>{var qe;const se=G(re);if(!se)return re;const he=(qe=se.node)==null?void 0:qe.data,Ce=(he==null?void 0:he.label)||(he==null?void 0:he.name)||(he==null?void 0:he.action_name)||se.variableNodeId,Fe=he!=null&&he.note?` (${he.note})`:"";return`${Ce}${Fe}.${se.fieldPath}`},[G]),j=(re,se)=>N.validateFields().then(async he=>{var Fe,qe,Le,de,Te;if(W)return se&&((qe=(Fe=T==null?void 0:T.current)==null?void 0:Fe.onIgnoreNodeStart)==null||qe.call(Fe)),t.onSubmit({params:he,account_id:F,proxy_id:he==null?void 0:he.proxy_id},re);const Ce=ut.cloneDeep(n.config_schema);return Ce.sub_params.forEach(_e=>{let tt=he[_e.name];_e.page_control===ve.EXTEND_OBJ&&tt!=="{{$fromAI}}"&&(tt=Bm(tt)),_e.value=tt}),se&&((de=(Le=T==null?void 0:T.current)==null?void 0:Le.onIgnoreNodeStart)==null||de.call(Le)),!i&&h==="HTTP"&&(r==null?void 0:r.deployment_type)!=="SaasApp"&&(Ce.proxy_id=(Te=P.current)==null?void 0:Te.getProxyId()),t.onSubmit(Ce,re)}).catch(he=>(console.log("err",he),x.message.warning(R("link.flow.missing_configuration")),!1));b.useImperativeHandle(e,()=>({saveConfig:re=>j(re,!1)}));const Y=Ct(),ie=h==="WEBHOOK"?{webhookField:{enabled:!0,form:N,configList:(u==null?void 0:u.sub_params)??[],disabled:!Y}}:void 0,Q=re=>{const se=re.page_control!==ve.HIDDEN?f.jsx("div",{style:{minHeight:10},children:f.jsx("p",{style:{color:"#999",fontSize:12,marginTop:-18,whiteSpace:"pre-wrap"},children:re.description})}):null;if(!re.is_child)return f.jsxs("div",{children:[pD(re,o,s,ie,a.canvas.registerComponents),se]},re.ui_id);const he=Hj(re);return f.jsx(x.Form.Item,{noStyle:!0,shouldUpdate:(Ce={},Fe={})=>re.is_child?he.length?he.some(qe=>(Ce==null?void 0:Ce[qe])!==(Fe==null?void 0:Fe[qe])):!0:!1,children:()=>{const Ce=N.getFieldsValue(!0);return zj(re,Ce)?f.jsxs("div",{children:[pD(re,o,s,ie,a.canvas.registerComponents),se]}):null}},re.ui_id)};return!v&&B?f.jsx("div",{style:{textAlign:"center",padding:40},children:f.jsx(x.Spin,{})}):W?f.jsxs("div",{style:{height:"100%",position:"relative"},children:[f.jsxs("div",{style:{height:"calc(100% - 50px)",minHeight:500,overflowY:"auto"},children:[_?f.jsx(Im,{credentialRequirements:O,value:F,onChange:M,linkApp:r,disabled:!Y}):null,$?f.jsx(Gi,{schema:$,form:N,initialValues:V,showSubmit:!1,showReset:!1,nodeId:o,mcpMode:s,renderVariableTag:te,renderVariableTooltip:H},g):f.jsx("div",{style:{padding:16,color:"#999",textAlign:"center"},children:"该节点暂无配置项"})]}),f.jsx("div",{style:{padding:"10px 20px",paddingBottom:10,paddingTop:30,position:"sticky",backgroundColor:"#FFFFFF",bottom:0,width:"100%",textAlign:"center",borderTop:"1px solid #eaeaea"},children:Y&&f.jsx(x.Button,{type:"primary",disabled:!Y,style:{width:180,borderRadius:4},onClick:()=>j(),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.save"})})})]}):f.jsxs("div",{style:{height:"100%",position:"relative"},children:[f.jsxs(x.Form,{form:N,disabled:!Y,style:{height:"calc(100% - 50px)",minHeight:500,overflowY:"auto",paddingRight:24},layout:"vertical",className:Bj.configFormContainer,children:[(r==null?void 0:r.id)&&n.config_schema&&((K=u==null?void 0:u.sub_params)==null?void 0:K.map(re=>Q(re))),!i&&h==="HTTP"&&(r==null?void 0:r.deployment_type)!=="SaasApp"?f.jsx(e1,{proxyId:c.proxyId,ref:P}):null]}),f.jsx("div",{style:{padding:"10px 20px",paddingBottom:10,paddingTop:30,position:"sticky",backgroundColor:"#FFFFFF",bottom:0,width:"100%",textAlign:"center",borderTop:"1px solid #eaeaea"},children:Y&&f.jsx(x.Button,{type:"primary",disabled:!Y,style:{width:180,borderRadius:4},onClick:()=>j(),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.save"})})})]})}),jj=b.memo(b.forwardRef((t,e)=>{var h;const{nodeId:n,data:r}=t,{account_id:o,account_schema_id:i}=r,s=dt.useReactive({account_id:o}),a=b.useRef(null);b.useImperativeHandle(e,()=>({saveConfig:p=>{var m;return(m=a.current)==null?void 0:m.saveConfig(p)}}));const l=b.useMemo(()=>({id:t.data.connector_id,name:t.data.connector_name}),[t.data.connector_id,t.data.connector_name]),c=!!(t.data.action_key||t.data.nodeKey)&&!Array.isArray((h=t.data.config_schema)==null?void 0:h.sub_params),u=(p,m)=>{if(c){const w=(p==null?void 0:p.params)??p??{},y=Object.hasOwn(p??{},"account_id")?p.account_id??null:s.account_id;t.onSubmit({params:w,account_id:y,proxy_id:(p==null?void 0:p.proxy_id)??(w==null?void 0:w.proxy_id)},m);return}t.onSubmit({properties:p,account_id:s.account_id,proxy_id:p.proxy_id},m)},d=b.useCallback(p=>{s.account_id=p??null},[]);return f.jsxs("div",{children:[i&&!c?f.jsx(Im,{onChange:d,actionAccountSchemaId:i,value:s.account_id,linkApp:l}):null,f.jsx(mD,{ref:a,action:t.data,connector:l,account_id:o,nodeId:n,onSubmit:u})]})}),(t,e)=>t.nodeId===e.nodeId&&ut.isEqual(ut.omit(t.data,["isHovered"]),ut.omit(e.data,["isHovered"]))),gD=[{operator:Ye.eq,label:R("common.eq")},{operator:Ye.ne,label:R("common.ne")},{operator:Ye.sw,label:R("common.sw")},{operator:Ye.nsw,label:R("common.nsw")},{operator:Ye.ew,label:R("common.ew")},{operator:Ye.ewn,label:R("common.ewn")},{operator:Ye.gt,label:R("common.gt")},{operator:Ye.ge,label:R("common.ge")},{operator:Ye.lt,label:R("common.lt")},{operator:Ye.le,label:R("common.le")},{operator:Ye.co,label:R("common.co")},{operator:Ye.nco,label:R("common.nco")},{operator:Ye.in,label:R("common.in")},{operator:Ye.nin,label:R("common.nin")},{operator:Ye.is_null,label:R("common.is_null")},{operator:Ye.is_not_null,label:R("common.is_not_null")}];Ye.eq+"",R("common.eq"),Ye.ne+"",R("common.ne"),Ye.sw+"",R("common.sw"),Ye.nsw+"",R("common.nsw"),Ye.ew+"",R("common.ew"),Ye.ewn+"",R("common.ewn"),Ye.gt+"",R("common.gt"),Ye.lt+"",R("common.lt"),Ye.ge+"",R("common.ge"),Ye.co+"",R("common.co"),Ye.nco+"",R("common.nco"),Ye.le+"",R("common.le"),Ye.in+"",R("common.in"),Ye.nin+"",R("common.nin"),Ye.is_null+"",R("common.is_null"),Ye.is_not_null+"",R("common.is_not_null");const jm=t=>t===Ye.is_null||t===Ye.is_not_null,Vj=(t,e="")=>jm(t)?"":e,{Option:Wj}=x.Select,Uj=b.forwardRef((t,e)=>{const{config_schema:n}=t,[r]=x.Form.useForm(),i=(l=>l!=null&&l.or_list?{or_list:l.or_list.map(u=>({and_list:u.and_list.map(d=>({query:d.query||"",operator:d.operator||"",value:d.value||""}))}))}:{or_list:[{and_list:[{query:"",operator:"",value:""}]}]})(n),s=(l,c,u="")=>r.validateFields().then(async d=>t.onSubmit({properties:d},l)).catch(()=>(x.message.warning(R("link.flow.missing_configuration")),!1));b.useImperativeHandle(e,()=>({saveConfig:()=>s(!0)}));const a=Ct();return f.jsxs("div",{style:{height:"100%",position:"relative"},children:[f.jsx("div",{style:{height:"calc(100% - 60px)",minHeight:500,overflowY:"auto",paddingRight:20},className:"grayBeautifyScrollbar",children:f.jsx(x.Form,{disabled:!a,form:r,initialValues:i,layout:"vertical",autoComplete:"off",children:f.jsx(x.Form.List,{name:"or_list",children:(l,{add:c,remove:u})=>f.jsxs(f.Fragment,{children:[l.map((d,h)=>f.jsxs("div",{style:{marginTop:10},children:[f.jsxs("div",{style:{background:"rgb(247, 248, 249)",borderRadius:8,padding:12},children:[h>0&&a&&f.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:f.jsx(x.Button,{type:"link",style:{color:"red"},icon:f.jsx(Z.MinusCircleOutlined,{style:{color:"red"}}),onClick:()=>u(d.name),children:f.jsx(Ee.FormattedMessage,{id:"link.flow.remove"})})}),f.jsx(x.Form.List,{name:[d.name,"and_list"],children:(p,{add:m,remove:w})=>f.jsx(f.Fragment,{children:p.map((v,y)=>f.jsxs(x.Space,{direction:"vertical",children:[f.jsxs(x.Space,{align:"center",children:[f.jsx(x.Form.Item,{style:{minWidth:150},name:[v.name,"query"],label:R("app.common.word.variable-name"),rules:[{required:!0,message:R("link.flow.please_enter_variable_name")}],children:f.jsx(tr,{nodeId:t.nodeId,placeholder:R("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),f.jsx(x.Form.Item,{name:[v.name,"operator"],label:R("app.common.word.condition"),rules:[{required:!0,message:R("link.flow.please_select_condition")}],children:f.jsx(x.Select,{style:{minWidth:140},placeholder:R("link.flow.select_condition"),getPopupContainer:g=>g.parentNode,children:gD.map(g=>f.jsx(Wj,{value:g.operator,children:g.label},g.operator))})}),f.jsx(x.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const g=r.getFieldValue(["or_list",d.name,"and_list",v.name,"operator"]);return jm(g)?null:f.jsx(x.Form.Item,{style:{minWidth:150},name:[v.name,"value"],label:R("app.common.word.value"),rules:[],children:f.jsx(tr,{nodeId:t.nodeId,placeholder:R("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),y===0&&f.jsx("div",{style:{width:30}}),y>0&&f.jsx(x.Button,{type:"link",icon:f.jsx(Z.MinusCircleOutlined,{}),onClick:()=>w(v.name)})]}),y<p.length-1&&f.jsx(x.Divider,{plain:!0,children:f.jsx(x.Tag,{color:"#999999",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.and"})})}),y===p.length-1&&f.jsx(x.Button,{type:"link",disabled:!a,icon:f.jsx(Z.PlusCircleOutlined,{}),onClick:()=>m({query:"",operator:"",value:""}),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.add-new-and"})})]},v.key))})})]}),h<l.length-1&&f.jsxs("div",{className:"test",style:{textAlign:"center"},children:[" ",f.jsx(x.Divider,{style:{color:"orange"},dashed:!0,children:f.jsx(x.Tag,{color:"#1890ff",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.or"})})})]})]},d.key)),f.jsx(x.Form.Item,{children:f.jsx(x.Button,{type:"link",icon:f.jsx(Z.PlusCircleOutlined,{}),disabled:!a,onClick:()=>c({and_list:[{query:"",operator:"",value:""}]}),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.add-or"})})})]})})})}),f.jsx("div",{style:{position:"sticky",padding:"10px 20px",paddingBottom:0,backgroundColor:"#FFFFFF",bottom:0,width:"100%",textAlign:"center",borderTop:"1px solid #eaeaea"},children:a&&f.jsx(x.Button,{type:"primary",disabled:!a,style:{width:180,borderRadius:4},onClick:()=>s(),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.save"})})})]})}),qj={copy:"Copy JSON",copySuccess:"JSON copied to clipboard",download:"Download JSON",invalidJson:"Invalid JSON data"},Gj={copy:"复制JSON",copySuccess:"JSON已复制到剪贴板",download:"下载JSON",invalidJson:"无效的JSON数据"},{Text:Kj}=x.Typography,wD=({data:t,height:e=400,enableCopy:n=!0,theme:r="light",className:o="",locale:i="zh",maxHeight:s})=>{const[a,l]=b.useState(r),c=b.useRef(null),u=i==="zh"?Gj:qj,d=b.useMemo(()=>{if(!t)return null;try{return typeof t=="string"?JSON.parse(t):t}catch(y){return console.error("JSON解析失败:",y),null}},[t]),h=b.useMemo(()=>{if(!d)return[];const y=(g,k=[],A=0)=>{const C=[];if(g===null)return[{key:k.join("."),value:null,type:"null",path:k,level:A}];if(Array.isArray(g)){const E={key:k.join("."),value:g,type:"array",path:k,level:A,children:[]};g.forEach((D,S)=>{const _=[...k,S.toString()],O=y(D,_,A+1);E.children.push(...O)}),C.push(E)}else if(typeof g=="object"){const E={key:k.join("."),value:g,type:"object",path:k,level:A,children:[]};Object.entries(g).forEach(([D,S])=>{const _=[...k,D],O=y(S,_,A+1);E.children.push(...O)}),C.push(E)}else{const E=typeof g;C.push({key:k.join("."),value:g,type:E,path:k,level:A})}return C};return y(d)},[d]),p=b.useCallback(()=>{const y=JSON.stringify(d,null,2);navigator.clipboard.writeText(y).then(()=>{x.message.success(u.copySuccess)})},[d,u]),m=b.useCallback(()=>{const y=JSON.stringify(d,null,2),g=new Blob([y],{type:"application/json"}),k=URL.createObjectURL(g),A=document.createElement("a");A.href=k,A.download="data.json",A.click(),URL.revokeObjectURL(k)},[d]),w=b.useCallback(y=>{switch(y.type){case"string":return f.jsxs("span",{className:"json-string",children:['"',y.value,'"']});case"number":return f.jsx("span",{className:"json-number",children:y.value});case"boolean":return f.jsx("span",{className:"json-boolean",children:String(y.value)});case"null":return f.jsx("span",{className:"json-null",children:"null"});default:return null}},[]),v=b.useCallback((y,g)=>{const k=y.children&&y.children.length>0,A=y.path[y.path.length-1];return y.type==="object"||y.type==="array"?f.jsxs("div",{className:"json-node",children:[f.jsxs("div",{className:"json-line",style:{paddingLeft:`${y.level*16}px`},children:[A&&f.jsxs("span",{className:"json-key",children:['"',A,'": ']}),f.jsx("span",{className:"json-bracket",children:y.type==="array"?"[":"{"}),!k&&f.jsx("span",{className:"json-bracket",children:y.type==="array"?"]":"}"})]}),k&&f.jsxs(f.Fragment,{children:[y.children.map((C,E)=>v(C,g+E+1)),f.jsx("div",{className:"json-line",style:{paddingLeft:`${y.level*16}px`},children:f.jsx("span",{className:"json-bracket",children:y.type==="array"?"]":"}"})})]})]},y.key):f.jsx("div",{className:"json-node",children:f.jsxs("div",{className:"json-line",style:{paddingLeft:`${y.level*16}px`},children:[A&&f.jsxs("span",{className:"json-key",children:['"',A,'": ']}),w(y)]})},y.key)},[w,u]);return b.useCallback(()=>{l(a==="dark"?"light":"dark")},[a]),d?f.jsxs("div",{className:`json-renderer ${a} ${o}`,children:[f.jsx("div",{className:"json-toolbar",children:f.jsxs(x.Space,{children:[n&&f.jsx(x.Tooltip,{title:u.copy,children:f.jsx(x.Button,{icon:f.jsx(Z.CopyOutlined,{}),size:"small",onClick:p})}),f.jsx(x.Tooltip,{title:u.download,children:f.jsx(x.Button,{icon:f.jsx(Z.DownloadOutlined,{}),size:"small",onClick:m})})]})}),f.jsx("div",{ref:c,className:"json-content",style:{height:`${e}px`,maxHeight:s?`${s}px`:void 0},children:h.map((y,g)=>v(y,g))})]}):f.jsx("div",{className:`json-renderer error ${a} ${o}`,children:f.jsx("div",{className:"error-message",children:f.jsx(Kj,{type:"secondary",children:u.invalidJson})})})},Hr=()=>{const t=ae.useStoreApi(),{setNodes:e}=ae.useReactFlow(),n=Vt();return{handleNodeDataUpdate:b.useCallback(({id:o,data:i,sync:s})=>{const{nodes:a}=t.getState(),l=n.engineMode===or.NEXT,c=Pn(a,u=>{const d=u.find(h=>h.id===o);d&&(d.data={...d.data,...i}),s&&!l&&Ol(o,{flow_id:n.flowId,properties:d.data.config_schema})});e(c)},[t])}},{TextArea:Yj}=x.Input,{Title:Xj,Paragraph:Jj}=x.Typography,Rj=b.forwardRef((t,e)=>{var k,A;const{nodeId:n,beforeHook:r}=t,o=Vt(),{handleNodeDataUpdate:i}=Hr(),s=(A=(k=o.nodeConfigPanel)==null?void 0:k.testArea)==null?void 0:A.defaultTestResult,[a,l]=b.useState(()=>{if(s==null)return"";if(typeof s=="string")return s;try{return JSON.stringify(s,null,2)}catch{return String(s)}}),c=ae.useInternalNode(n),u=dt.useReactive({testProgress:0,sampleText:"",isError:!1,editable:!1,showErrorAlert:!1,testing:!1,ignoring:!1,successShown:!1,isIgnoreSuccess:!1}),{refreshFlow:d}=Cr();b.useEffect(()=>{if(c!=null&&c.data.output&&(c.data.status===me.SUCCESS||c.data.status===me.RUNNABLE)){const C=typeof c.data.output=="string"?c.data.output:JSON.stringify(c.data.output,null,2);l(C),u.successShown=!0,u.isError=!1,u.showErrorAlert=!1}else if(c!=null&&c.data.output&&c.data.status===me.FAILED){const C=typeof c.data.output=="string"?c.data.output:JSON.stringify(c.data.output,null,2);l(C),u.isError=!0,u.showErrorAlert=!0,u.successShown=!1}},[c]);const h=b.useCallback(()=>{if(!n){console.error("节点ID不能为空");return}u.testing=!0,u.testProgress=60,u.successShown=!1,u.isError=!1,u.showErrorAlert=!1,u.isIgnoreSuccess=!1,Nv(n).then(C=>{let E="";const D=C;(D==null?void 0:D.result)===!1?u.isError=!0:(u.isError=!1,u.successShown=!0),u.isIgnoreSuccess=!1,u.showErrorAlert=u.isError;try{if(typeof D=="object")E=JSON.stringify(D,null,2);else if(typeof D=="string")try{const S=JSON.parse(D);E=JSON.stringify(S,null,2)}catch{E=D}else E=String(D)}catch(S){console.error("格式化测试结果出错:",S),E="测试结果格式化失败: "+String(S)}u.testProgress=100,l(E),i({id:n,data:{status:me.SUCCESS,output:E}})}).catch(C=>{var S;console.error("测试失败:",C),u.testProgress=0,u.isError=!0,u.showErrorAlert=!0,u.successShown=!1,u.isIgnoreSuccess=!1;let E="测试执行失败";(S=C==null?void 0:C.response)!=null&&S.data?E=JSON.stringify(C.response.data,null,2):C!=null&&C.message&&(E=C.message);const D=JSON.stringify({error:E},null,2);l(D),i({id:n,data:{status:me.FAILED,output:D}})}).finally(()=>{setTimeout(()=>{u.testProgress=0,u.testing=!1,u.ignoring=!1,u.isIgnoreSuccess=!1},500)})},[n]),p=()=>{u.testProgress=0,u.testing=!1,u.ignoring=!1,u.isIgnoreSuccess=!0};b.useImperativeHandle(e,()=>({onTestNode:h,finishNodeTest:p}));const m=()=>{r?r(!0):h()},w=()=>{r&&(u.testing=!0,u.ignoring=!0,u.testProgress=60,r(!0,!0,u.sampleText))},v=()=>{l(""),u.sampleText="",u.editable=!1,u.successShown=!1},y=Ct(),g=b.useMemo(()=>{var D;const C=(D=c==null?void 0:c.data)==null?void 0:D.protocol,E=c==null?void 0:c.type;return!y||C===Be.AI_LANGUAGE_MODEL||C===Be.AI_MEMORY||E===ee.BuiltinMCP||E===ee.MCPServer},[c]);return f.jsxs("div",{className:"node-test-container",children:[f.jsxs("div",{className:"node-test-header",children:[f.jsxs("div",{className:"header-title",children:[f.jsx(Z.RocketOutlined,{className:"title-icon"}),f.jsx(Xj,{level:4,children:"节点测试"})]}),f.jsx(Jj,{type:"secondary",className:"header-description",children:"点击测试按钮,实时检查节点执行效果和结果数据"})]}),f.jsxs("div",{className:"test-content",children:[y&&f.jsxs("div",{className:"action-buttons",children:[f.jsx(x.Button,{type:"primary",disabled:g||u.ignoring,icon:f.jsx(Z.RocketOutlined,{}),onClick:m,loading:u.testing&&!u.ignoring,className:"test-button",children:u.testing&&!u.ignoring?"测试中...":"开始测试"}),f.jsx(x.Button,{type:"primary",disabled:g||u.testing&&!u.ignoring,ghost:!0,onClick:w,loading:u.testing&&u.ignoring,className:"ignore-button",children:"忽略调试"}),a&&f.jsx(x.Button,{icon:f.jsx(Z.ReloadOutlined,{}),onClick:v,className:"reset-button",children:"重置"})]}),u.testProgress>0&&f.jsx(x.Progress,{percent:u.testProgress,status:u.isError?"exception":"active",className:"test-progress"}),u.isError&&u.showErrorAlert&&f.jsx(x.Alert,{className:"error-alert",showIcon:!0,message:"测试未通过",description:"请检查节点配置是否正确",type:"error",onClose:()=>{setTimeout(()=>{u.showErrorAlert=!1},500)},closable:!0}),!u.isError&&u.successShown&&a&&!u.testing&&f.jsx(x.Alert,{className:"success-alert",showIcon:!0,message:u.isIgnoreSuccess?"忽略调试成功":"测试成功",description:u.isIgnoreSuccess?"已将样本数据预设为当前节点输出":"节点运行正常,可以查看下方返回结果",type:"success",closable:y}),u.testing?f.jsx(x.Skeleton,{active:!0,className:"result-skeleton"}):f.jsx(f.Fragment,{children:a?f.jsx(x.Card,{styles:{body:{padding:0}},title:f.jsxs("div",{className:"result-header",children:[f.jsx("div",{className:"result-title",children:u.isError?f.jsxs(f.Fragment,{children:[f.jsx(Z.CloseCircleFilled,{className:"error-icon"})," 错误数据"]}):f.jsxs(f.Fragment,{children:[u.isIgnoreSuccess?f.jsx(Z.ExperimentFilled,{className:"success-icon"}):f.jsx(Z.CheckCircleFilled,{className:"success-icon"}),u.isIgnoreSuccess?"样本数据":"测试结果"]})}),y&&f.jsx(x.Button,{size:"small",type:"link",icon:f.jsx(Z.EditOutlined,{}),onClick:()=>{if(u.editable){u.editable=!1;try{const C=JSON.parse(u.sampleText),E=JSON.stringify(C,null,2);l(E),i({id:n,data:{output:E}})}catch{l(u.sampleText)}}else u.sampleText=a,u.editable=!0},className:"edit-button",children:u.editable?"完成":"编辑"})]}),variant:"borderless",className:`result-card ${u.isError?"error-result":"success-result"}`,children:u.editable?f.jsx(Yj,{rows:10,value:u.sampleText,onChange:C=>u.sampleText=C.target.value,className:"result-editor"}):f.jsx(wD,{data:a,height:300,enableCopy:!0,theme:"light"},a)}):f.jsx(x.Card,{variant:"borderless",className:"empty-result",children:f.jsx(x.Result,{icon:f.jsx(Z.RocketOutlined,{}),title:"等待测试",subTitle:'点击"开始测试"按钮开始节点测试'})})})]})]})}),{Option:Fo}=x.Select,Qj=b.forwardRef(({onSubmit:t,config_schema:e,nodeId:n},r)=>{const[o]=x.Form.useForm(),i=x.Form.useWatch("type",o);dt.useMount(()=>{e&&Object.hasOwn(e,"asc")&&o.setFieldsValue(e)});const s=(l,c,u="")=>o.validateFields().then(async d=>i&&i==="NUMBER"&&d.start>d.end?x.message.warning(R("link.flow.loop_start_end_check")):t({properties:d},l)).catch(()=>(x.message.warning(R("link.flow.missing_configuration")),!1));b.useImperativeHandle(r,()=>({saveConfig:l=>s(l)}));const a=Ct();return f.jsxs("div",{style:{width:"100%",position:"relative",height:"100%"},children:[f.jsx("div",{style:{height:"calc(100% - 60px)",overflow:"scroll"},className:"grayBeautifyScrollbar",children:f.jsxs(x.Form,{disabled:!a,form:o,layout:"vertical",children:[f.jsx(x.Form.Item,{name:"type",label:R("app.common.word.loop-data-type"),rules:[{required:!0,message:R("link.flow.please_select_data_type")}],children:f.jsxs(x.Select,{children:[f.jsx(Fo,{value:"ARRAY",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.array"})}),f.jsx(Fo,{value:"NUMBER",children:f.jsx(Ee.FormattedMessage,{id:"common.number"})}),f.jsx(Fo,{value:"CONDITION",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.condition_expression"})})]})}),i&&i==="NUMBER"&&f.jsxs(x.Form.Item,{required:!0,label:R("link.flow.loop_start_end"),style:{display:"flex"},children:[f.jsx(x.Form.Item,{name:"start",noStyle:!0,rules:[{required:!0,message:R("link.flow.please_select_data_type")}],children:f.jsx(x.InputNumber,{min:1,style:{marginRight:20}})}),f.jsx(x.Form.Item,{name:"end",noStyle:!0,rules:[{required:!0,message:R("link.flow.please_select_data_type")}],children:f.jsx(x.InputNumber,{min:1})})]}),i&&i!=="NUMBER"&&f.jsx(x.Form.Item,{rules:[{required:!0,message:R("link.flow.please_enter_loop_expression")}],label:R("link.flow.loop_expression"),name:"expression",children:f.jsx(tr,{nodeId:n,borrow:!0,valueType:"JS_EXP",placeholder:R("link.flow.please_enter_loop_expression")})}),f.jsx(x.Form.Item,{name:"asc",label:R("app.common.word.circulation-direction"),rules:[{required:!0,message:R("link.flow.please_select_loop_direction")}],children:f.jsxs(x.Select,{children:[f.jsx(Fo,{value:!0,children:f.jsx(Ee.FormattedMessage,{id:"link.flow.loop_head_to_tail"})}),f.jsx(Fo,{value:!1,children:f.jsx(Ee.FormattedMessage,{id:"link.flow.loop_tail_to_head"})})]})}),f.jsx(x.Form.Item,{name:"errorExec",label:R("link.flow.loop_processing"),rules:[{required:!0,message:R("link.flow.please_select_loop_processing")}],children:f.jsxs(x.Select,{children:[f.jsx(Fo,{value:"END",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.terminate_process"})}),f.jsx(Fo,{value:"CONTINUE",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.continue_loop"})}),f.jsx(Fo,{value:"BREAK",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.break_loop"})})]})})]})}),f.jsx("div",{style:{padding:"10px 20px",marginTop:30,paddingBottom:0,backgroundColor:"#FFFFFF",bottom:0,width:"100%",textAlign:"center",borderTop:"1px solid #eaeaea"},children:a&&f.jsx(x.Button,{type:"primary",disabled:!a,style:{width:180,borderRadius:4},onClick:()=>s(),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.save"})})})]})}),td=()=>`branch_${Date.now()}_${Math.random().toString(36).substr(2,9)}`,{Option:Zj}=x.Select,e7=b.forwardRef((t,e)=>{const{config_schema:n,nodeId:r}=t,[o]=x.Form.useForm(),{handleNodeDataUpdate:i}=Hr(),[s,a]=b.useState(null),[l,c]=b.useState(""),d=(A=>!(A!=null&&A.branches)||A.branches.length===0?{branches:[{id:td(),name:R("link.flow.switch.condition_one"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]},{id:td(),name:R("link.flow.switch.condition_two"),or_list:[{and_list:[{query:"",operator:"",value:""}]}]}]}:{branches:A.branches.map((E,D)=>{var S;return{id:E.id||td(),name:E.name||R("link.flow.switch.condition_n",{n:D+1}),or_list:((S=E.or_list)==null?void 0:S.map(_=>{var O;return{and_list:((O=_.and_list)==null?void 0:O.map(B=>({query:B.query||"",operator:B.operator||"",value:B.value||""})))||[{query:"",operator:"",value:""}]}}))||[{and_list:[{query:"",operator:"",value:""}]}]}})})(n),h=()=>{const A=o.getFieldValue("branches")||[];i({id:r,data:{config_schema:{branches:A}}})},p=(A,C)=>{a(A),c(C)},m=()=>{a(null),c("")},w=A=>{const C=ut.cloneDeep(o.getFieldValue("branches"))||[],E=l.trim();if(!E){x.message.error(R("link.flow.switch.branch_name_cannot_be_empty"));return}if(C.some((S,_)=>_!==A&&S.name===E)){x.message.error(R("link.flow.switch.branch_name_duplicate"));return}C[A].name=E,o.setFieldValue("branches",C),a(null),c(""),h()},v=(A,C)=>{const E=o.getFieldValue("branches")||[];if(C<0||C>=E.length)return;const D=[...E],[S]=D.splice(A,1);D.splice(C,0,S),o.setFieldValue("branches",D),h()},y=A=>o.validateFields().then(async C=>{if(!C.branches.some(S=>S.or_list.some(_=>_.and_list.some(O=>O.query&&O.operator)))){x.message.error(R("link.flow.switch.at_least_one_valid_branch"));return}const D=ut.cloneDeep(C);return D.branches.forEach(S=>{S.or_list.forEach(_=>{_.and_list.forEach(O=>{O.value=Vj(O.operator,O.value)})})}),t.onSubmit({properties:D},A)}).catch(()=>(x.message.warning(R("link.flow.missing_configuration")),!1));b.useImperativeHandle(e,()=>({saveConfig:()=>y(!0)}));const g=Ct(),k=(A,C,E,D)=>{const _=(o.getFieldValue("branches")||[])[C],O=s===C;return f.jsxs(x.Card,{style:{marginBottom:16,borderRadius:8,border:"1px solid #d9d9d9"},bodyStyle:{padding:16},children:[f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginBottom:12},children:[f.jsx("div",{style:{display:"flex",alignItems:"center",flex:1},children:O?f.jsxs(x.Space,{children:[f.jsx(x.Input,{value:l,onChange:B=>c(B.target.value),style:{width:200},placeholder:R("link.flow.switch.enter_branch_name"),onPressEnter:()=>w(C)}),f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.CheckOutlined,{style:{color:"#52c41a"}}),onClick:()=>w(C)}),f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.CloseOutlined,{}),onClick:m})]}):f.jsxs(x.Space,{children:[f.jsx("span",{style:{fontSize:16,fontWeight:500},children:(_==null?void 0:_.name)||R("link.flow.switch.condition_n",{n:C+1})}),g&&f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.EditOutlined,{}),onClick:()=>p(C,(_==null?void 0:_.name)||"")})]})}),g&&f.jsxs(x.Space,{children:[f.jsx(x.Tooltip,{title:R("link.flow.switch.move_to_top"),children:f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.VerticalAlignTopOutlined,{}),disabled:C===0,onClick:()=>v(C,0)})}),f.jsx(x.Tooltip,{title:R("link.flow.switch.move_up"),children:f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.ArrowUpOutlined,{}),disabled:C===0,onClick:()=>v(C,C-1)})}),f.jsx(x.Tooltip,{title:R("link.flow.switch.move_down"),children:f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.ArrowDownOutlined,{}),disabled:C===E-1,onClick:()=>v(C,C+1)})}),f.jsx(x.Tooltip,{title:R("link.flow.switch.move_to_bottom"),children:f.jsx(x.Button,{type:"text",size:"small",icon:f.jsx(Z.VerticalAlignBottomOutlined,{}),disabled:C===E-1,onClick:()=>v(C,E-1)})}),f.jsx(x.Tooltip,{title:R("common.delete"),children:f.jsx(x.Button,{type:"text",size:"small",danger:!0,icon:f.jsx(Z.DeleteOutlined,{}),disabled:E<=1,onClick:()=>{if(E<=1){x.message.warning(R("link.flow.switch.at_least_one_branch"));return}D(A.name),setTimeout(()=>{h()},0)}})})]})]}),f.jsx(x.Form.Item,{name:[A.name,"name"],hidden:!0,children:f.jsx(x.Input,{})}),f.jsx(x.Form.List,{name:[A.name,"or_list"],children:(B,{add:N,remove:F})=>f.jsxs(f.Fragment,{children:[B.map((M,T)=>f.jsxs("div",{style:{marginTop:T>0?10:0},children:[f.jsxs("div",{style:{background:"rgb(247, 248, 249)",borderRadius:8,padding:12},children:[B.length>1&&g&&f.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:f.jsx(x.Button,{type:"link",style:{color:"red"},icon:f.jsx(Z.MinusCircleOutlined,{style:{color:"red"}}),onClick:()=>F(M.name),children:f.jsx(Ee.FormattedMessage,{id:"link.flow.remove"})})}),f.jsx(x.Form.List,{name:[M.name,"and_list"],children:(P,{add:$,remove:W})=>f.jsx(f.Fragment,{children:P.map((V,X)=>f.jsxs(x.Space,{direction:"vertical",style:{width:"100%"},children:[f.jsxs(x.Space,{align:"center",wrap:!0,children:[f.jsx(x.Form.Item,{style:{minWidth:150,marginBottom:0},name:[V.name,"query"],label:R("app.common.word.variable-name"),rules:[{required:!0,message:R("link.flow.please_enter_variable_name")}],children:f.jsx(tr,{nodeId:t.nodeId,placeholder:R("link.flow.variable_name"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})}),f.jsx(x.Form.Item,{style:{marginBottom:0},name:[V.name,"operator"],label:R("app.common.word.condition"),rules:[{required:!0,message:R("link.flow.please_select_condition")}],children:f.jsx(x.Select,{style:{minWidth:140},placeholder:R("link.flow.select_condition"),getPopupContainer:G=>document.body,children:gD.map(G=>f.jsx(Zj,{value:G.operator,children:G.label},G.operator))})}),f.jsx(x.Form.Item,{noStyle:!0,shouldUpdate:!0,children:()=>{const G=o.getFieldValue(["branches",A.name,"or_list",M.name,"and_list",V.name,"operator"]);return jm(G)?null:f.jsx(x.Form.Item,{style:{minWidth:150,marginBottom:0},name:[V.name,"value"],label:R("app.common.word.value"),rules:[],children:f.jsx(tr,{nodeId:t.nodeId,placeholder:R("link.flow.value"),borrow:!0,disableIDE:!0,valueType:"JS_EXP"})})}}),X===0&&f.jsx("div",{style:{width:30}}),X>0&&g&&f.jsx(x.Button,{type:"link",icon:f.jsx(Z.MinusCircleOutlined,{}),onClick:()=>W(V.name)})]}),X<P.length-1&&f.jsx(x.Divider,{plain:!0,style:{margin:"8px 0"},children:f.jsx(x.Tag,{color:"#999999",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.and"})})}),X===P.length-1&&f.jsx(x.Button,{type:"link",disabled:!g,icon:f.jsx(Z.PlusCircleOutlined,{}),onClick:()=>$({query:"",operator:"",value:""}),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.add-new-and"})})]},V.key))})},Math.random())]}),T<B.length-1&&f.jsx("div",{style:{textAlign:"center"},children:f.jsx(x.Divider,{style:{color:"orange"},dashed:!0,children:f.jsx(x.Tag,{color:"#1890ff",children:f.jsx(Ee.FormattedMessage,{id:"link.flow.or"})})})})]},M.key)),f.jsx(x.Form.Item,{style:{marginTop:12,marginBottom:0},children:f.jsx(x.Button,{type:"link",icon:f.jsx(Z.PlusCircleOutlined,{}),disabled:!g,onClick:()=>N({and_list:[{query:"",operator:"",value:""}]}),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.add-or"})})})]})})]},A.key)};return f.jsxs("div",{style:{height:"100%",position:"relative"},children:[f.jsx("div",{style:{height:"calc(100% - 60px)",minHeight:500,overflowY:"auto",paddingRight:20},className:"grayBeautifyScrollbar",children:f.jsx(x.Form,{disabled:!g,form:o,initialValues:d,layout:"vertical",autoComplete:"off",children:f.jsx(x.Form.List,{name:"branches",children:(A,{add:C,remove:E})=>f.jsxs(f.Fragment,{children:[A.map((D,S)=>k(D,S,A.length,E)),A.length<10&&f.jsx(x.Button,{type:"dashed",block:!0,icon:f.jsx(Z.PlusCircleOutlined,{}),disabled:!g,onClick:()=>{const D=A.length+1;C({id:td(),name:R("link.flow.switch.condition_n",{n:D}),or_list:[{and_list:[{query:"",operator:"",value:""}]}]}),setTimeout(()=>{h()},0)},style:{marginBottom:16},children:f.jsx(Ee.FormattedMessage,{id:"link.flow.switch.add_branch"})}),A.length>=10&&f.jsx("div",{style:{textAlign:"center",color:"#999",marginBottom:16},children:f.jsx(Ee.FormattedMessage,{id:"link.flow.switch.max_branches_reached"})})]})})})}),f.jsx("div",{style:{position:"sticky",padding:"10px 20px",paddingBottom:0,backgroundColor:"#FFFFFF",bottom:0,width:"100%",textAlign:"center",borderTop:"1px solid #eaeaea"},children:g&&f.jsx(x.Button,{type:"primary",disabled:!g,style:{width:180,borderRadius:4},onClick:()=>y(),children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.save"})})})]})}),t7=({nodeId:t,onSubmit:e,data:n})=>{const[r]=x.Form.useForm(),o=Ct(),{refreshFlow:i}=Cr(),{setNodes:s}=ae.useReactFlow(),a=b.useCallback((c,u)=>{s(d=>d.map(h=>!u&&h.id!==t?h:{...h,data:{...h.data,error_handler:c}}))},[t,s]);b.useEffect(()=>{const c=(n==null?void 0:n.error_handler)||{};r.setFieldsValue({retryEnabled:c.retry||!1,retryCount:c.retry_times||3,retryInterval:c.retry_interval||5,stepFactor:c.step_factor||1.5,maxRetryInterval:c.max_retry_interval||60,alertEnabled:c.warn_type===1,webhookUrl:c.notify_url||"",errorHandling:c.process_type===2?"ignore":"interrupt",applyToAllNodes:!!c.apply_all})},[t,r,n==null?void 0:n.error_handler]);const l=async c=>{try{const u={retry:c.retryEnabled,retry_times:c.retryEnabled?c.retryCount:void 0,retry_interval:c.retryEnabled?c.retryInterval:void 0,step_factor:c.retryEnabled?c.stepFactor:void 0,max_retry_interval:c.retryEnabled?c.maxRetryInterval:void 0,warn_type:c.alertEnabled?1:0,notify_url:c.alertEnabled?c.webhookUrl:void 0,process_type:c.errorHandling==="interrupt"?1:2,apply_all:c.applyToAllNodes};await Ol(t,{error_handler:u}),a(u,c.applyToAllNodes),c.applyToAllNodes&&i(),e()}catch{x.message.error(R("common.save_failed"))}};return f.jsxs("div",{style:{height:"100%",position:"relative"},children:[f.jsx("div",{style:{height:"calc(100% - 60px)",overflowY:"auto",paddingRight:20},children:f.jsxs(Un.ProForm,{form:r,layout:"vertical",disabled:!o,submitter:!1,onFinish:l,children:[f.jsx(Un.ProFormSwitch,{name:"retryEnabled",label:R("app.common.word.enable-retry")}),f.jsx(Un.ProFormDependency,{name:["retryEnabled"],children:({retryEnabled:c})=>c?f.jsxs(f.Fragment,{children:[f.jsx(Un.ProFormDigit,{name:"retryCount",label:R("app.common.word.retry-count"),tooltip:R("app.common.word.retry-count-tooltip"),width:"xl",fieldProps:{min:1,max:10,precision:0,style:{width:"100%"}},rules:[{required:c,message:R("app.common.word.please-enter-retry-count")}]}),f.jsx(Un.ProFormDigit,{name:"retryInterval",label:R("app.common.word.retry-interval"),tooltip:R("app.common.word.retry-interval-tooltip"),fieldProps:{min:1,max:60,precision:0,style:{width:"100%"},addonAfter:"s"},rules:[{required:c,message:R("app.common.word.please-enter-retry-interval")}]}),f.jsx(Un.ProFormDigit,{name:"stepFactor",label:R("app.common.word.step-factor"),tooltip:R("app.common.word.step-factor-tooltip"),width:"xl",fieldProps:{min:1,max:5,precision:1,style:{width:"100%"}},rules:[{required:c,message:R("app.common.word.please-enter-step-factor")}]}),f.jsx(Un.ProFormDigit,{name:"maxRetryInterval",label:R("app.common.word.max-retry-interval"),tooltip:R("app.common.word.max-retry-interval-tooltip"),width:"xl",fieldProps:{min:1,max:300,precision:0,style:{width:"100%"},addonAfter:"s"},rules:[{required:c,message:R("app.common.word.please-enter-max-retry-interval")}]})]}):null}),f.jsx(Un.ProFormSwitch,{name:"alertEnabled",label:R("app.common.word.enable-alert")}),f.jsx(Un.ProFormDependency,{name:["alertEnabled"],children:({alertEnabled:c})=>c?f.jsx(Un.ProFormText,{name:"webhookUrl",label:R("app.common.word.webhook-url"),placeholder:R("app.common.word.enter-webhook-url"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:c,message:R("app.common.word.enter-webhook-url")}]}):null}),f.jsx(Un.ProFormSelect,{name:"errorHandling",label:R("app.common.word.error-handling"),width:"xl",fieldProps:{style:{width:"100%"}},rules:[{required:!0,message:R("app.common.word.select-error-handling")}],options:[{label:R("app.common.word.interrupt-flow"),value:"interrupt"},{label:R("app.common.word.ignore-error"),value:"ignore"}]}),f.jsx(Un.ProFormSwitch,{name:"applyToAllNodes",label:R("app.common.word.apply-to-all-nodes")})]})}),f.jsx("div",{style:{padding:"10px 20px",position:"sticky",paddingBottom:0,backgroundColor:"#FFFFFF",bottom:0,width:"100%",textAlign:"center",borderTop:"1px solid #eaeaea"},children:f.jsx(x.Button,{type:"primary",disabled:!o,onClick:()=>r.submit(),style:{width:180,borderRadius:4},children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.save"})})})]})},n7=b.forwardRef((t,e)=>{const{account_id:n,account_schema_id:r,action_name:o,mcp_tool_description:i,description:s}=t.data,a=t.nodeId,l=dt.useReactive({account_id:n,mcp_tool_description:i||o||s||""}),c=b.useRef(null);b.useImperativeHandle(e,()=>({saveConfig:()=>{var p;return(p=c.current)==null?void 0:p.saveConfig()}}));const u=b.useMemo(()=>({id:t.data.connector_id,name:t.data.connector_name}),[t.data.connector_id,t.data.connector_name]),d=(p,m)=>{t.onSubmit({properties:p,account_id:l.account_id,mcp_tool_description:l.mcp_tool_description},m)},h=b.useCallback(p=>{l.account_id=p??null},[]);return f.jsxs("div",{children:[r?f.jsx(Im,{onChange:h,actionAccountSchemaId:r,value:l.account_id,linkApp:u}):null,f.jsx(x.Form.Item,{layout:"vertical",label:"工具描述",children:f.jsx(x.Input,{value:l.mcp_tool_description,onChange:p=>{l.mcp_tool_description=p.target.value}})}),f.jsx(mD,{ref:c,action:t.data,connector:u,account_id:n,nodeId:a,mcpMode:!0,onSubmit:d})]})}),nd="[workflow:schema-render]",r7=()=>{const{event$:t}=b.useContext($r),e=xf();return t.useSubscription(n=>{n.type==="insert"&&n.expression&&e!=null&&e.activeFieldId&&e.insertVariableToActiveField(n.expression,!1)}),null},o7=t=>f.jsxs("div",{className:"node-config-title",style:{display:"flex",alignItems:"center"},children:[t.icon?f.jsx("img",{src:t.icon,alt:t.name,style:{width:24,height:24}}):null,f.jsx("div",{className:"node-config-title-name",style:{fontSize:16,fontWeight:600,marginLeft:10},children:t.name}),f.jsx("div",{className:"node-config-title-description",style:{fontSize:12,color:"gray",marginLeft:10},children:t.description})]}),i7=b.memo(({visible:t,onClose:e,data:n,nodeType:r=ee.ACTION,nodeId:o=""})=>{var M,T,P,$,W;const i=dt.useEventEmitter();af(),ae.useInternalNode(o);const{setNodeConfigVisible:s,refreshFlow:a}=Cr(),l=b.useRef(null),c=b.useRef(null),u=b.useRef(null),d=b.useRef(null),h=b.useRef(null),p=b.useRef(null),m=b.useRef(null),w=ae.useStoreApi(),v=Vt(),y=((T=(M=v.nodeConfigPanel)==null?void 0:M.testArea)==null?void 0:T.allowManualTest)!==!1,g=dt.useReactive({output:"",ignore:!1}),k=b.useMemo(()=>v.nodeConfigPanel.showSettings&&![ee.TRIGGER,ee.MCP_TOOL,ee.AI_SUB_NODE].includes(r),[r,v.nodeConfigPanel.showSettings]),A=()=>{e()};b.useEffect(()=>{var V;t&&((V=l.current)==null||V.loadVariables())},[t]);const C=(n==null?void 0:n.action_id)||null,E=Array.isArray((P=n==null?void 0:n.config_schema)==null?void 0:P.sub_params),D=r===ee.ACTION&&!!(n!=null&&n.action_key||n!=null&&n.nodeKey)&&!E,S=(n==null?void 0:n.action_key)||(n==null?void 0:n.nodeKey),_=(n==null?void 0:n.action_ver)??(n==null?void 0:n.nodeVersion)??(($=n==null?void 0:n.node_schema)==null?void 0:$.version),{handleNodeDataUpdate:O}=Hr();b.useEffect(()=>{var V;t&&console.info(`${nd} node config modal opened`,{nodeId:o,nodeType:r,actionId:C,isNextCompatibleNode:D,nextNodeKey:S,nextNodeVersion:_,hasConfigSchema:!!(n!=null&&n.config_schema),hasParams:!!(n!=null&&n.params),actionKey:n==null?void 0:n.action_key,actionVer:n==null?void 0:n.action_ver,dataNodeKey:n==null?void 0:n.nodeKey,dataNodeVersion:n==null?void 0:n.nodeVersion,inlineSchemaVersion:(V=n==null?void 0:n.node_schema)==null?void 0:V.version})},[C,n==null?void 0:n.config_schema,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,(W=n==null?void 0:n.node_schema)==null?void 0:W.version,D,S,_,o,r,t]);const B=b.useCallback(async(V,X)=>{const G=v.flowId;try{const te=w.getState().nodes.find(ie=>ie.id===o),H=D?V.params||V.properties||{}:V.properties,j=D?{flow_id:G,properties:H,position:te==null?void 0:te.position,action_id:C,account_id:V.account_id??null,proxy_id:V.proxy_id,action_key:S,action_ver:_}:{flow_id:G,...V,position:te==null?void 0:te.position,action_id:C};console.info(`${nd} save node config`,{nodeId:o,nodeType:r,actionId:C,isNextCompatibleNode:D,nextNodeKey:S,nextNodeVersion:_,valueKeys:Object.keys(V||{}),paramsKeys:Object.keys((V==null?void 0:V.params)||{}),propertiesKeys:Object.keys((V==null?void 0:V.properties)||{}),ignoreDebugResult:g.ignore});const Y=g.ignore?await Fv(o,"","","",H,g.output):await Ol(o,j);if(Y)if(console.info(`${nd} save node config success`,{nodeId:o,nodeType:r,isNextCompatibleNode:D,nextNodeKey:S,nextNodeVersion:_,status:Y.status}),g.ignore)m.current.finishNodeTest(),O({id:o,data:{status:me.SUCCESS}}),x.message.success("已忽略调试结果");else{x.message.success("节点配置已保存");const ie=D?{params:H,account_id:V.account_id,action_key:S,action_ver:_,nodeKey:S,nodeVersion:_}:{};O({id:o,data:{config_schema:H,account_id:V.account_id,...ie,position:te==null?void 0:te.position,status:Y.status}})}X&&!g.ignore&&m.current&&m.current.onTestNode(),g.ignore=!1,g.output=""}catch(te){console.error(`${nd} save node config failed`,{nodeId:o,nodeType:r,isNextCompatibleNode:D,nextNodeKey:S,nextNodeVersion:_,err:te}),g.ignore&&O({id:o,data:{status:me.FAILED}})}},[C,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,O,D,S,_,o,r,g,w]),N=V=>{var X,G,te,H,j;return r===ee.LOOP?(X=h.current)==null?void 0:X.saveConfig(V):r===ee.CONDITION?(G=u.current)==null?void 0:G.saveConfig(V):r===ee.SWITCH?(te=d.current)==null?void 0:te.saveConfig(V):r===ee.MCP_TOOL?(H=p.current)==null?void 0:H.saveConfig(V):(j=c.current)==null?void 0:j.saveConfig(V)},F=async(V,X,G)=>{var te;if(X){g.ignore=!0,g.output=G||"",await N(V)===!1&&((te=m.current)==null||te.finishNodeTest());return}if(V)try{x.message.loading("正在保存节点配置...",0),await N(V),x.message.success("节点配置已保存"),x.message.destroy()}catch(H){x.message.destroy(),console.error("节点配置保存失败:",H),x.message.error("节点配置保存失败,无法执行测试")}};return f.jsx(x.Modal,{open:t,footer:null,closeIcon:null,maskClosable:!0,onCancel:()=>{s(null)},centered:!0,width:"70%",className:"nodes-config-modal",styles:{wrapper:{minWidth:1040},mask:{backgroundColor:"rgba(0, 0, 0, 0.45)"},content:{padding:0,overflow:"hidden"}},children:f.jsx($r.Provider,{value:{event$:i},children:f.jsxs(kf,{children:[f.jsx(r7,{}),f.jsxs("div",{className:"nodes-config-container",children:[f.jsxs("div",{className:"nodes-config-header",children:[f.jsx("div",{className:"header-left",children:f.jsx("span",{className:"header-title",children:" 节点配置"})}),f.jsx("div",{className:"header-right",children:f.jsx(x.Button,{type:"text",icon:f.jsx(Z.ArrowLeftOutlined,{}),onClick:A,className:"back-button",children:"返回画布"})})]}),f.jsx("div",{className:"nodes-config-content",children:f.jsxs(x.Row,{gutter:16,className:"config-row",children:[f.jsx(x.Col,{span:5,className:"left-section",children:f.jsx("div",{className:"variables-section",children:f.jsx(aD,{ref:l,nodeId:o,onInsert:()=>{},open:t})})}),f.jsx(x.Col,{span:12,className:"middle-section",children:f.jsx("div",{className:"form-section",style:{height:"100%"},children:f.jsx(x.Card,{title:f.jsx(o7,{icon:n==null?void 0:n.icon,name:n==null?void 0:n.name,description:n==null?void 0:n.description}),variant:"borderless",styles:{body:{paddingTop:0,paddingBottom:0}},className:"section-card form-card",children:f.jsx(x.Tabs,{style:{height:"100%"},items:[{key:"property",label:"参数配置",children:f.jsxs(f.Fragment,{children:[[ee.CONDITION,ee.SWITCH,ee.LOOP,ee.MCP_TOOL].includes(r)?null:f.jsx(jj,{ref:c,nodeId:o,data:n,onSubmit:B}),r===ee.CONDITION?f.jsx(Uj,{ref:u,nodeId:o,config_schema:n.config_schema,onSubmit:B}):null,r===ee.SWITCH?f.jsx(e7,{ref:d,nodeId:o,config_schema:n.config_schema,onSubmit:B}):null,r===ee.LOOP?f.jsx(Qj,{ref:h,nodeId:o,config_schema:n.config_schema,onSubmit:B}):null,r===ee.MCP_TOOL?f.jsx(n7,{ref:p,nodeId:o,data:n,onSubmit:B}):null]})},{key:"setting",label:"设置",children:f.jsx(t7,{data:n,nodeId:o,onSubmit:()=>{x.message.success("保存成功")}})}].slice(0,k?2:1)})})})}),f.jsx(x.Col,{span:7,className:"right-section",children:y&&f.jsx("div",{className:"test-section",children:f.jsx(x.Card,{variant:"borderless",className:"section-card",children:f.jsx(Rj,{ref:m,nodeId:o,beforeHook:F})})})})]})})]})]})})})},(t,e)=>ut.isEqual(ut.omit(t,["isHovered"]),ut.omit(e,["isHovered"]))),{Text:vD}=x.Typography,{TextArea:s7}=x.Input,a7=({title:t,description:e,note:n,nodeId:r,statusIcon:o,className:i="",onNoteChange:s})=>{const[a,l]=b.useState(!1),[c,u]=b.useState(""),[d,h]=b.useState(!1),p=Ct();if(b.useEffect(()=>{u(n||e||"")},[n,e]),!t&&!e&&!n)return null;const m=g=>{g.stopPropagation(),l(!0)},w=async()=>{if(!r){x.message.error("节点ID不能为空"),l(!1);return}if(c===(n||e||"")){l(!1);return}h(!0);try{await zv(r,c),x.message.success(R("link.flow.remark_modification_success")),s==null||s(c),l(!1)}catch(g){x.message.error("备注保存失败"),console.error("保存备注失败:",g),u(n||e||"")}finally{h(!1)}},v=()=>{u(n||e||""),l(!1)},y=g=>{g.key==="Enter"&&(g.ctrlKey||g.metaKey)?w():g.key==="Escape"&&v()};return f.jsxs("div",{className:`workflow-node-description-container ${i}`,children:[t&&f.jsxs("div",{className:"workflow-node-title-row",children:[f.jsx("span",{className:"workflow-node-title-text",children:t}),o&&f.jsx("span",{className:"workflow-node-status-icon",children:o})]}),f.jsx("div",{className:"workflow-node-description-wrapper",children:a?f.jsx(x.Spin,{spinning:d,children:f.jsx(s7,{value:c,onDoubleClick:g=>g.stopPropagation(),onDragStart:g=>g.stopPropagation(),onDrag:g=>g.stopPropagation(),onChange:g=>u(g.target.value),onBlur:w,onKeyDown:y,placeholder:"请输入备注...",autoSize:{minRows:1,maxRows:4},autoFocus:!0,className:"workflow-node-note-editor nodrag"})}):p?f.jsxs("div",{className:"workflow-node-note-display is-editable",onClick:m,title:"点击编辑备注 (Ctrl+Enter保存, Esc取消)",children:[f.jsx(vD,{className:`workflow-node-description ${c?"":"workflow-node-description-placeholder"}`,children:c||"点击添加备注..."}),f.jsx(Z.EditOutlined,{className:"workflow-node-edit-icon"})]}):f.jsx("div",{className:"workflow-node-note-display",children:f.jsx(vD,{className:"workflow-node-description",children:c})})})]})},{Text:yD}=x.Typography,{TextArea:l7}=x.Input,c7=({title:t,description:e,note:n,statusIcon:r,className:o="",onNoteChange:i})=>{const[s,a]=b.useState(!1),[l,c]=b.useState(""),u=Ct();if(b.useEffect(()=>{c(n||e||"")},[n,e]),!t&&!e&&!n)return null;const d=w=>{w.stopPropagation(),a(!0)},h=()=>{if(l===(n||e||"")){a(!1);return}i==null||i(l),a(!1)},p=()=>{c(n||e||""),a(!1)},m=w=>{w.key==="Enter"&&(w.ctrlKey||w.metaKey)?h():w.key==="Escape"&&p()};return f.jsxs("div",{className:`workflow-node-description-container ${o}`,children:[t&&f.jsxs("div",{className:"workflow-node-title-row",children:[f.jsx("span",{className:"workflow-node-title-text",children:t}),r&&f.jsx("span",{className:"workflow-node-status-icon",children:r})]}),f.jsx("div",{className:"workflow-node-description-wrapper",children:s?f.jsx(l7,{value:l,onDoubleClick:w=>w.stopPropagation(),onDragStart:w=>w.stopPropagation(),onDrag:w=>w.stopPropagation(),onChange:w=>c(w.target.value),onBlur:h,onKeyDown:m,placeholder:"请输入备注...",autoSize:{minRows:1,maxRows:4},autoFocus:!0,className:"workflow-node-note-editor nodrag"}):u?f.jsxs("div",{className:"workflow-node-note-display is-editable",onClick:d,title:"点击编辑备注 (Ctrl+Enter保存, Esc取消)",children:[f.jsx(yD,{className:`workflow-node-description ${l?"":"workflow-node-description-placeholder"}`,children:l||"点击添加备注..."}),f.jsx(Z.EditOutlined,{className:"workflow-node-edit-icon"})]}):f.jsx("div",{className:"workflow-node-note-display",children:f.jsx(yD,{className:"workflow-node-description",children:l})})})]})},u7=t=>({label:t.action_name,description:t.connector_name,config_schema:t.config_schema||t.properties,...Object.entries(t).reduce((e,[n,r])=>(n!=="name"&&(e[n]=r),e),{})}),Vm={color:"#3883f6"},d7=[ee.TRIGGER,ee.AI_SUB_NODE],f7=[ee.TRIGGER,ee.AI_SUB_NODE],h7=({nodeId:t,isDisabled:e=!1,handleViewConfig:n,onDelete:r,className:o,type:i})=>{const{handleNodeDataUpdate:s}=Hr(),{addNodes:a,getNodes:l}=Fi(),c=Vt(),u=ae.useInternalNode(t),d=Ct(),h=b.useMemo(()=>{var O;const E=c.nodeTypes;if(!u)return;const D=E.types[u.type];if(D)return D;const S=(O=u.data)==null?void 0:O.category;return S?Object.values(E.types).find(B=>B.category===S):void 0},[c.nodeTypes,u]),p=b.useMemo(()=>((h==null?void 0:h.operations)||[]).reduce((D,S)=>(D[S.id]=S.enabled,D),{}),[h]),m=b.useMemo(()=>{var S,_;if(!u)return!1;const E=((S=c.canvas.fixedNodes)==null?void 0:S.triggerIds)||[],D=((_=c.nodeTypes.fixed)==null?void 0:_.triggers)||[];return E.includes(u.id)||D.includes(u.type)},[c.canvas.fixedNodes,c.nodeTypes.fixed,u]),w=b.useMemo(()=>{const E=!d7.includes(i),D=p.copy===void 0?!0:p.copy;return E&&D&&d},[i,p,d]),v=b.useMemo(()=>{const E=!f7.includes(i),D=p.disable===void 0?!0:p.disable;return E&&D&&d},[i,p,d]),y=()=>{jv(t,e?"on":"off").then(E=>{s({id:t,data:{closed:E.closed,status:E.status}})})},g=b.useMemo(()=>c.canvas.mode!=="preview"&&!d,[c.canvas.mode,d]);b.useMemo(()=>d&&!m&&c.canvas.allowRemoveTrigger,[d,m,c.canvas.allowRemoveTrigger]);const k=()=>{r&&r(t)},A=async()=>{var D;const E=l();try{const S=E.find(B=>B.id===t);if(!S){x.message.error("获取当前节点信息失败");return}const _=(D=c.canvas.limits)==null?void 0:D.maxNodes;if(typeof _=="number"&&E.length>=_){x.message.warning("已达到画布允许的最大节点数");return}const O=await nf(t);if(O){const B=Bn.createNode(O.node_type,O.id,u7(O),{x:S.position.x,y:S.position.y+100});a([B]),x.message.success("节点复制成功")}}catch(S){x.message.error("节点复制失败"),console.error("复制节点失败:",S)}},C=i===ee.AI_SUB_NODE;return f.jsxs("div",{className:kn("node-operations",o,C?"node-operations-right":""),children:[w&&f.jsx(x.Tooltip,{title:"复制节点",children:f.jsx(x.Button,{type:"text",icon:f.jsx(xi.IoCopyOutline,{style:Vm}),onClick:A,className:kn("operation-button")})}),v&&f.jsx(x.Tooltip,{title:e?"激活节点":"禁用节点",children:f.jsx(x.Button,{type:"text",icon:e?f.jsx(xi.IoPlayOutline,{style:Vm}):f.jsx(xi.IoBanOutline,{style:Vm}),onClick:y,className:kn("operation-button",{disabled:e})})}),d&&f.jsx(x.Popconfirm,{title:"确定要删除此节点吗?",description:"删除后无法恢复,请谨慎操作",onConfirm:k,okText:"确定",cancelText:"取消",placement:"top",children:f.jsx(x.Tooltip,{title:"删除节点",children:f.jsx(x.Button,{type:"text",icon:f.jsx(Bw.RiDeleteBin5Line,{style:{color:"red"}}),className:"operation-button delete-button"})})}),g&&f.jsx(x.Tooltip,{title:"查看配置",children:f.jsx(x.Button,{type:"link",onClick:n,icon:f.jsx(Z.EyeOutlined,{}),className:kn("operation-button")})})]})},bD={type:ee.START,id:"PLACEHOLDER_NODE",position:{x:100,y:250},data:{type:ee.START,name:"开始",nodeId:"PLACEHOLDER_NODE",id:"PLACEHOLDER_NODE",description:"开始节点"}},p7=[ee.AGENT,ee.BROWSER,ee.MCPServer,ee.BuiltinMCP],rd=()=>{const t=ae.useStoreApi(),[e,n]=b.useState(0),o=Vt().engineMode===or.NEXT,i=b.useCallback((u,d)=>{const{nodes:h,setNodes:p}=t.getState(),m=Pn(h,w=>{const v=w.find(y=>y.id===d.id);v.data?v.data.isHovered=!0:v.data={isHovered:!0}});p(m)},[]),s=b.useCallback((u,d)=>{const{nodes:h,setNodes:p}=t.getState(),m=Pn(h,w=>{const v=w.find(y=>y.id===d.id);v.data?v.data.isHovered=!1:v.data={isHovered:!1}});p(m)},[]),a=b.useCallback(u=>{const{nodes:d,setNodes:h}=t.getState(),p=Pn(d,m=>{u.forEach(w=>{w.type==="select"&&(m.find(v=>v.id===w.id).selected=w.selected)})});h(p)},[t]),l=b.useCallback((u,d,h=new Set)=>(d.filter(m=>m.source===u&&m.sourceHandle!==Ie.OUTPUT&&m.sourceHandle!==Ie.DONE&&m.sourceHandle!==Ie.LOOP&&m.sourceHandle!==Ie.TRUE&&m.sourceHandle!==Ie.FALSE).forEach(m=>{const w=m.target;h.has(w)||(h.add(w),l(w,d,h))}),h),[]),c=b.useCallback((u,d)=>{const{nodes:h,edges:p,setNodes:m,setEdges:w}=t.getState(),v=new Set(u);p7.includes(d)&&u.forEach(E=>{l(E,p).forEach(S=>{v.add(S)})});const y=Array.from(v),g=h.filter(E=>!y.includes(E.id)),k=g.map(E=>E.id),C=p.filter(E=>!y.includes(E.source)&&!y.includes(E.target)).filter(E=>k.includes(E.target));if(o)g.length===0&&g.push(bD);else{const E=g.some(D=>D.type===ee.TRIGGER);(g.length===0||!E)&&g.push(bD)}m(g),w(C)},[t,l]);return{autoSaveNum:e,onNodeMouseEnter:i,onNodeMouseLeave:s,handleNodesChange:a,handleNodesDelete:c}},Wm={color:"#3883f6"},m7=[ee.TRIGGER,ee.AI_SUB_NODE],g7=[ee.TRIGGER,ee.AI_SUB_NODE],w7=({nodeId:t,isDisabled:e=!1,handleViewConfig:n,className:r,type:o})=>{const{handleNodeDataUpdate:i}=Hr(),{addNodes:s,getNodes:a}=Fi(),{handleNodesDelete:l}=rd(),c=Vt(),u=ae.useInternalNode(t),d=Ct(),h=b.useMemo(()=>{var _;const E=c.nodeTypes;if(!u)return;const D=E.types[u.type];if(D)return D;const S=(_=u.data)==null?void 0:_.category;if(S)return Object.values(E.types).find(O=>O.category===S)},[c.nodeTypes,u]),p=b.useMemo(()=>((h==null?void 0:h.operations)||[]).reduce((D,S)=>(D[S.id]=S.enabled,D),{}),[h]),m=b.useMemo(()=>{var S,_;if(!u)return!1;const E=((S=c.canvas.fixedNodes)==null?void 0:S.triggerIds)||[],D=((_=c.nodeTypes.fixed)==null?void 0:_.triggers)||[];return E.includes(u.id)||D.includes(u.type)},[c.canvas.fixedNodes,c.nodeTypes.fixed,u]),w=b.useMemo(()=>{const E=!m7.includes(o),D=p.copy===void 0?!0:p.copy;return E&&D&&d},[o,p,d]),v=b.useMemo(()=>{const E=!g7.includes(o),D=p.disable===void 0?!0:p.disable;return E&&D&&d},[o,p,d]),y=b.useMemo(()=>c.canvas.mode!=="preview"&&!d,[c.canvas.mode,d]),g=()=>{i({id:t,data:{closed:e?"0":"1",status:e?"on":"off"}})},k=()=>{if(m){x.message.warning("当前触发节点已被配置为不可删除");return}l([t],o)},A=()=>{var N;const E=a(),D=E.find(F=>F.id===t);if(!D){x.message.error("获取当前节点信息失败");return}const S=(N=c.canvas.limits)==null?void 0:N.maxNodes;if(typeof S=="number"&&E.length>=S){x.message.warning("已达到画布允许的最大节点数");return}const _=crypto.randomUUID(),O=ut.cloneDeep(D.data);O.id=_,O.nodeId=_,O.name&&(O.name=`${O.name} 副本`),O.status=void 0,O.output=void 0;const B=Bn.createNode(D.type,_,O,{x:D.position.x+50,y:D.position.y+100});s([B]),x.message.success("节点复制成功")},C=o===ee.AI_SUB_NODE;return f.jsxs("div",{className:kn("node-operations",r,C?"node-operations-right":""),children:[w&&f.jsx(x.Tooltip,{title:"复制节点",children:f.jsx(x.Button,{type:"text",icon:f.jsx(xi.IoCopyOutline,{style:Wm}),onClick:A,className:"operation-button"})}),v&&f.jsx(x.Tooltip,{title:e?"激活节点":"禁用节点",children:f.jsx(x.Button,{type:"text",icon:e?f.jsx(xi.IoPlayOutline,{style:Wm}):f.jsx(xi.IoBanOutline,{style:Wm}),onClick:g,className:kn("operation-button",{disabled:e})})}),d&&f.jsx(x.Popconfirm,{title:"确定要删除此节点吗?",description:"删除后无法恢复,请谨慎操作",onConfirm:k,okText:"确定",cancelText:"取消",placement:"top",children:f.jsx(x.Tooltip,{title:"删除节点",children:f.jsx(x.Button,{type:"text",icon:f.jsx(Bw.RiDeleteBin5Line,{style:{color:"red"}}),className:"operation-button delete-button"})})}),y&&f.jsx(x.Tooltip,{title:"查看配置",children:f.jsx(x.Button,{type:"link",onClick:n,icon:f.jsx(Z.EyeOutlined,{}),className:"operation-button"})})]})};function v7(t){const{color:e,visible:n}=t;return f.jsx("span",{style:{width:16,height:16,borderRadius:10,backgroundColor:e,display:n?"flex":"none",justifyContent:"center",alignItems:"center",position:"absolute",zIndex:1e3,top:"calc(50% - 8px)",left:-8},children:f.jsx(Z.ThunderboltOutlined,{style:{fontSize:10,color:"white"}})})}const bs={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)"}},_n=({id:t,type:e=ee.ACTION,selected:n=!1,icon:r,inputs:o=[],outputs:i=[],showToolbar:s=!0,width:a,height:l,className:c="",status:u=me.IDLE,onTestNode:d,data:h,contentRender:p,showNodeDescription:m=!0,onToggleNodeDisabled:w})=>{const{currentNodeConfigVisibleId:v,setNodeConfigVisible:y}=Cr(),{handleNodeDataUpdate:g}=Hr(),{handleNodesDelete:k}=rd(),A=Vt(),C=G=>{g({id:t,data:{note:G}})},E=b.useCallback(()=>{y(null)},[]),D=(h==null?void 0:h.isHovered)||!1,S=ae.useNodeConnections({id:t}),_=b.useMemo(()=>e===ee.TRIGGER,[e,S]),O=()=>{y(t)},B=b.useMemo(()=>(h==null?void 0:h.closed)==="1",[h==null?void 0:h.closed]),N=b.useMemo(()=>typeof a=="number"&&a>0?a:300,[a]),F=(G="node")=>{if(B)return`workflow-${G}-disabled`;switch(u){case me.INVALID:return`workflow-${G}-warning`;case me.FAILED:return`workflow-${G}-failed`;case me.SUCCESS:case me.RUNNABLE:return`workflow-${G}-success`;case me.RUNNING:return`workflow-${G}-running`;case me.IDLE:default:return""}},M=()=>{if(B)return bs.disabled;switch(u){case me.INVALID:return bs.warning;case me.FAILED:return bs.error;case me.SUCCESS:case me.RUNNABLE:return bs.success;case me.RUNNING:return bs.info;default:return bs.info}},T=(G="normal")=>M()[G],P=()=>o.map(G=>f.jsx(N0,{nodeId:t,id:G.id,position:G.position,type:je.TARGET,label:G.label,nodeStatus:u,style:G.style},`${t}-${G.id}`)),$=async()=>{var H,j;const G=((H=A.canvas.fixedNodes)==null?void 0:H.triggerIds)||[],te=((j=A.nodeTypes.fixed)==null?void 0:j.triggers)||[];if(G.includes(t)||te.includes(e)){x.message.warning("当前触发节点已被配置为不可删除");return}await Qd(t),k([t],e)},W=b.useMemo(()=>i.map(G=>f.jsx(N0,{nodeId:t,connectionLimit:G.maxConnections,id:G.id,style:G.style,position:G.position,protocol:G.protocol,type:G.type,label:G.label,shape:G.shape,nodeStatus:u},`${t}-${G.id}`)),[u,JSON.stringify(i)]),V=()=>{switch(u){case me.INVALID:return f.jsx("div",{className:"workflow-node-status-icon workflow-node-warning-icon",children:f.jsx(Z.WarningFilled,{style:{color:T(),fontSize:16}})});case me.FAILED:return f.jsx("div",{className:"workflow-node-status-icon workflow-node-failed-icon",children:f.jsx(Z.CloseCircleFilled,{style:{color:T(),fontSize:16}})});case me.SUCCESS:case me.RUNNABLE:return f.jsx("div",{className:"workflow-node-status-icon workflow-node-success-icon",children:f.jsx(Z.CheckCircleFilled,{style:{color:T(),fontSize:16}})});case me.RUNNING:return f.jsx("div",{className:"workflow-node-status-icon workflow-node-running-icon",children:f.jsx(Z.LoadingOutlined,{style:{color:T(),fontSize:16}})});default:return null}},X=()=>f.jsxs(f.Fragment,{children:[r&&f.jsx("div",{className:"workflow-node-icon-wrapper",children:f.jsx("div",{className:"workflow-node-icon",children:r})}),m&&(A.engineMode===or.NEXT?f.jsx(c7,{title:h==null?void 0:h.name,note:(h==null?void 0:h.note)||"",statusIcon:V(),onNoteChange:C,className:"workflow-node-text"}):f.jsx(a7,{title:h==null?void 0:h.connector_name,nodeId:t,note:(h==null?void 0:h.note)||"",statusIcon:V(),onNoteChange:C,description:h.action_name,className:"workflow-node-text"}))]});return f.jsxs(b.Fragment,{children:[f.jsxs("div",{style:{width:N,height:l||"auto"},onDoubleClick:O,className:`${c}
|
|
71
71
|
${F("container")}`,children:[f.jsx(v7,{color:T("lighter"),visible:_}),f.jsxs("div",{className:`workflow-node ${n?"workflow-node-selected":""}`,style:{"--status-color":T(),"--status-color-tint":T("lighter"),...B?{opacity:.4}:{}},children:[B&&f.jsx("div",{className:"workflow-node-deactivated-line"}),f.jsx("div",{className:"workflow-node-toolbar",style:{display:s&&A.canvas.mode!=="preview"&&D?"block":"none"},children:A.engineMode===or.NEXT?f.jsx(w7,{nodeId:t,type:e,isDisabled:B,handleViewConfig:O}):f.jsx(h7,{nodeId:t,type:e,isDisabled:B,handleViewConfig:O,onTest:d,onToggleDisabled:w,onDelete:$})}),p?p(h,V()):f.jsx("div",{className:"workflow-node-content",children:X()}),P(),W]})]}),A.engineMode!==or.NEXT&&f.jsx(i7,{visible:t===v,onClose:E,nodeType:e,data:h,nodeId:t})]})},y7=t=>{var c,u,d,h,p,m,w,v,y,g;const{id:e,data:n,selected:r}=t,o=n.status&&n.status!==me.IDLE?n.status:me.IDLE,i=((c=n==null?void 0:n.backendData)==null?void 0:c.properties)&&Object.keys((u=n==null?void 0:n.backendData)==null?void 0:u.properties).length>0,s=i&&((h=(d=n==null?void 0:n.backendData)==null?void 0:d.properties)!=null&&h.display_name)?(m=(p=n==null?void 0:n.backendData)==null?void 0:p.properties)==null?void 0:m.display_name:n==null?void 0:n.label,a=i&&((v=(w=n==null?void 0:n.backendData)==null?void 0:w.properties)!=null&&v.description)?(g=(y=n==null?void 0:n.backendData)==null?void 0:y.properties)==null?void 0:g.description:n==null?void 0:n.description,l={...n,label:s,description:a};return f.jsx(_n,{id:e,data:l,selected:r,status:o,className:"action-node",icon:n!=null&&n.icon?f.jsx("img",{src:n==null?void 0:n.icon,alt:n.label,style:{width:30,height:30}}):f.jsx(Z.PlayCircleOutlined,{style:{fontSize:24,color:"#007fff"}}),inputs:[{id:Ie.INPUT,position:ae.Position.Left,type:je.TARGET}],outputs:[{id:Ie.OUTPUT,position:ae.Position.Right,maxConnections:1,type:je.SOURCE}]})},CD=t=>{const{data:e}=t,n=e.status?e.status:me.IDLE;return f.jsx(_n,{...t,type:t.type,status:n,className:"agent-node",icon:e!=null&&e.icon?f.jsx("img",{src:e==null?void 0:e.icon,alt:e.label,style:{width:30,height:30}}):f.jsx(Z.PlayCircleOutlined,{style:{fontSize:24,color:"#007fff"}}),inputs:[{id:Ie.INPUT,position:ae.Position.Left,type:je.TARGET,isMain:!0}],outputs:[{id:Ie.CHAT_MODEL,position:ae.Position.Bottom,category:"slave",type:je.SOURCE,isMain:!0,maxConnections:1,label:"Chat Model",protocol:Be.AI_LANGUAGE_MODEL,shape:"rhombus",style:{left:"30%",transform:"translateX(-50%)"}},{id:Ie.MEMORY,position:ae.Position.Bottom,category:"slave",type:je.SOURCE,protocol:Be.AI_MEMORY,isMain:!0,label:"Memory",maxConnections:1,shape:"rhombus",style:{left:"54%",transform:"translateX(-50%)"}},{id:Ie.TOOLS,position:ae.Position.Bottom,category:"slave",protocol:Be.AI_TOOL,type:je.SOURCE,isMain:!0,label:"Tools",shape:"rhombus",style:{left:"72%",transform:"translateX(-50%)"}},{id:Ie.OUTPUT,position:ae.Position.Right,type:je.SOURCE,maxConnections:1,isMain:!0}]})},od=t=>{const{id:e,data:n,selected:r}=t,o=n,i=o.status?o.status:me.IDLE;return f.jsx(_n,{id:e,status:i,data:o,selected:r,type:ee.AI_SUB_NODE,className:"workflow-aisub-node",icon:o!=null&&o.icon?f.jsx("img",{src:o==null?void 0:o.icon,alt:o.label,style:{width:30,height:30}}):f.jsx(Z.PlayCircleOutlined,{style:{fontSize:24,color:"#007fff"}}),inputs:[{id:Ie.INPUT,position:ae.Position.Top,type:je.TARGET,isMain:!0}]})},kD=t=>{const{data:e}=t,n=e.status?e.status:me.IDLE;return f.jsx(_n,{...t,type:t.type,status:n,className:"agent-node",icon:e!=null&&e.icon?f.jsx("img",{src:e==null?void 0:e.icon,alt:e.label,style:{width:30,height:30}}):f.jsx(Z.PlayCircleOutlined,{style:{fontSize:24,color:"#007fff"}}),inputs:[{id:Ie.INPUT,position:ae.Position.Left,type:je.TARGET,isMain:!0}],outputs:[{id:Ie.CHAT_MODEL,position:ae.Position.Bottom,category:"slave",type:je.SOURCE,isMain:!0,maxConnections:1,label:"Chat Model",protocol:Be.AI_LANGUAGE_MODEL,shape:"rhombus",style:{left:"50%",transform:"translateX(-50%)"}},{id:Ie.OUTPUT,position:ae.Position.Right,type:je.SOURCE,maxConnections:1,isMain:!0}]})},xD=t=>{const{id:e,data:n,selected:r}=t,o=n,i=o.status?o.status:me.IDLE;return f.jsx(_n,{id:e,status:i,data:o,selected:r,type:ee.BuiltinMCP,className:"workflow-aisub-node",icon:o!=null&&o.icon?f.jsx("img",{src:o==null?void 0:o.icon,alt:o.label,style:{width:30,height:30}}):f.jsx(Z.PlayCircleOutlined,{style:{fontSize:24,color:"#007fff"}}),inputs:[{id:Ie.INPUT,position:ae.Position.Top,type:je.TARGET,isMain:!0}],outputs:[{id:Ie.BUILTIN_MCP,position:ae.Position.Bottom,protocol:Be.BUILTIN_MCP,type:je.SOURCE,isMain:!0,shape:"rhombus",style:{left:"50%",transform:"translateX(-50%)"}}]})},b7=t=>{const{id:e,data:n,selected:r}=t,o=n;return f.jsx(_n,{id:e,data:o,selected:r,type:ee.CONDITION,status:o==null?void 0:o.status,className:"condition-node",icon:o!=null&&o.icon?f.jsx("img",{src:o==null?void 0:o.icon,alt:o.label,style:{width:30,height:30}}):f.jsx(Z.FilterOutlined,{style:{fontSize:24,color:"#007fff"}}),inputs:[{id:Ie.INPUT,position:ae.Position.Left,type:je.TARGET,maxConnections:1,isMain:!0}],outputs:[{id:Ie.TRUE,position:ae.Position.Right,type:je.SOURCE,maxConnections:1,label:"true",style:{top:"33%"},isMain:!0},{id:Ie.FALSE,position:ae.Position.Right,maxConnections:1,type:je.SOURCE,label:"false",style:{top:"67%"}}]})},SD=b.memo(({data:t,id:e,selected:n})=>{const r=t.isHovered||!1,o={border:n?"2px solid #007fff":r?"2px solid #3395ff":"1px solid #d9d9d9",boxShadow:r?"0 0 8px rgba(0, 127, 255, 0.3)":n?"0 0 5px rgba(0, 127, 255, 0.2)":"none",transition:"all 0.2s ease",background:r?"rgba(0, 127, 255, 0.08)":"#fff"};return f.jsxs("div",{className:"custom-node",style:o,children:[f.jsx(ae.Handle,{type:"target",position:ae.Position.Top,style:{background:"#555"},id:"input"}),f.jsxs("div",{className:"node-content",children:[f.jsx("div",{className:"node-title",children:t.name||"Node"}),t.description&&f.jsx("div",{className:"node-description",children:t.description}),r&&f.jsx("div",{className:"hover-indicator",children:f.jsx("span",{className:"hover-badge",children:"悬停中"})})]}),f.jsx(ae.Handle,{type:"source",position:ae.Position.Bottom,style:{background:"#555"},id:"output"})]})}),{Option:TR}=x.Select,C7=t=>{const{id:e,data:n,selected:r}=t,o=n;return f.jsx(_n,{id:e,data:o,status:o==null?void 0:o.status,type:ee.LOOP,selected:r,icon:o!=null&&o.icon?f.jsx("img",{src:o==null?void 0:o.icon,alt:o.label,style:{width:30,height:30}}):f.jsx(Z.ReloadOutlined,{style:{fontSize:24,color:"#007fff"}}),className:"loop-node",inputs:[{id:Ie.INPUT,position:ae.Position.Left,type:je.TARGET}],outputs:[{type:je.SOURCE,position:ae.Position.Right,id:Ie.DONE,label:"done",maxConnections:1,style:{top:"33%"}},{type:je.SOURCE,position:ae.Position.Right,id:Ie.LOOP,label:"loop",maxConnections:1,style:{top:"67%"}}]})},k7=b.memo(C7),ED=t=>{const{id:e,data:n,selected:r}=t,o=n,i=o.status?o.status:me.IDLE;return f.jsx(_n,{id:e,status:i,data:o,selected:r,type:ee.MCPServer,className:"workflow-aisub-node",icon:o!=null&&o.icon?f.jsx("img",{src:o==null?void 0:o.icon,alt:o.label,style:{width:30,height:30}}):f.jsx(Z.PlayCircleOutlined,{style:{fontSize:24,color:"#007fff"}}),inputs:[{id:Ie.INPUT,position:ae.Position.Top,type:je.TARGET,protocol:Be.MCP_SERVER,isMain:!0}]})},DD=t=>{const{id:e,data:n,selected:r}=t,o=n,i=o.status?o.status:me.IDLE;return f.jsx(_n,{id:e,status:i,data:o,selected:r,type:ee.MCP_TOOL,className:"workflow-mcp-tool-node",icon:o!=null&&o.icon?f.jsx("img",{src:o==null?void 0:o.icon,alt:o.label,style:{width:30,height:30}}):f.jsx(Z.PlayCircleOutlined,{style:{fontSize:24,color:"#007fff"}}),inputs:[{id:Ie.INPUT,position:ae.Position.Top,protocol:Be.BUILTIN_MCP,type:je.TARGET,isMain:!0}]})},x7=({icon:t,label:e})=>{const n=t?f.jsx("img",{src:t,alt:e,style:{width:24,height:24}}):f.jsx(Z.ReloadOutlined,{style:{fontSize:24,color:"#007fff"}});return f.jsx(x.Badge,{offset:[-22,2],count:f.jsx(Z.ReloadOutlined,{style:{fontSize:12,color:"#007fff"}}),children:n})},S7=t=>{const{id:e,data:n,selected:r}=t,o=n;return f.jsx(_n,{id:e,data:o,status:o==null?void 0:o.status,type:ee.SELF_LOOP,selected:r,icon:f.jsx(x7,{icon:o==null?void 0:o.icon,label:o==null?void 0:o.label}),className:"loop-node",inputs:[{id:Ie.INPUT,position:ae.Position.Left,type:je.TARGET}],outputs:[{type:je.SOURCE,position:ae.Position.Right,id:Ie.DONE,label:"done",maxConnections:1,style:{top:"33%"}},{type:je.SOURCE,position:ae.Position.Right,id:Ie.LOOP,label:"loop",maxConnections:1,style:{top:"67%"}}]})},E7=b.memo(S7),AD=()=>{const t=ae.useNodes(),e=Ct(),{openNodeSelector:n}=Es(),r=o=>{o.stopPropagation(),n({trigger:!0})};return t.some(o=>{var i;return(i=o.type)==null?void 0:i.includes(ee.TRIGGER)})||!e?null:f.jsxs("div",{onClick:r,className:"nodrag nopan start-node",children:[f.jsx("div",{className:"start-node-icon",children:f.jsx(Z.PlusCircleOutlined,{})}),f.jsxs("div",{className:"start-node-text",children:[f.jsx("h3",{className:"start-node-text-title",children:"添加触发节点"}),f.jsx("p",{className:"start-node-text-desc",children:"触发时将执行节点后续步骤"})]})]})};function OD(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 _R(){}const tl=sd(/[A-Za-z]/),Um=sd(/[\dA-Za-z]/);function D7(t){return t!==null&&(t<32||t===127)}function Cs(t){return t!==null&&t<-2}function Nn(t){return t!==null&&(t<0||t===32)}function io(t){return t===-2||t===-1||t===32}const id=sd(new RegExp("\\p{P}|\\p{S}","u")),pi=sd(/\s/);function sd(t){return e;function e(n){return n!==null&&n>-1&&t.test(String.fromCharCode(n))}}function A7(t){if(typeof t!="string")throw new TypeError("Expected a string");return t.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const ad=(function(t){if(t==null)return N7;if(typeof t=="function")return ld(t);if(typeof t=="object")return Array.isArray(t)?O7(t):T7(t);if(typeof t=="string")return _7(t);throw new Error("Expected function, string, or object as test")});function O7(t){const e=[];let n=-1;for(;++n<t.length;)e[n]=ad(t[n]);return ld(r);function r(...o){let i=-1;for(;++i<e.length;)if(e[i].apply(this,o))return!0;return!1}}function T7(t){const e=t;return ld(n);function n(r){const o=r;let i;for(i in t)if(o[i]!==e[i])return!1;return!0}}function _7(t){return ld(e);function e(n){return n&&n.type===t}}function ld(t){return e;function e(n,r,o){return!!(B7(n)&&t.call(this,n,typeof r=="number"?r:void 0,o||void 0))}}function N7(){return!0}function B7(t){return t!==null&&typeof t=="object"&&"type"in t}function NR(t){return t}const TD=[],F7=!0,qm=!1,I7="skip";function _D(t,e,n,r){let o;typeof e=="function"&&typeof n!="function"?(r=n,n=e):o=e;const i=ad(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(h,"name",{value:"node ("+(l.type+(p?"<"+p+">":""))+")"})}return h;function h(){let p=TD,m,w,v;if((!e||i(l,c,u[u.length-1]||void 0))&&(p=M7(n(l,u)),p[0]===qm))return p;if("children"in l&&l.children){const y=l;if(y.children&&p[0]!==I7)for(w=(r?y.children.length:-1)+s,v=u.concat(y);w>-1&&w<y.children.length;){const g=y.children[w];if(m=a(g,w,v)(),m[0]===qm)return m;w=typeof m[1]=="number"?m[1]:w+s}}return p}}}function M7(t){return Array.isArray(t)?t:typeof t=="number"?[F7,t]:t==null?TD:[t]}function P7(t,e,n){const o=ad((n||{}).ignore||[]),i=L7(e);let s=-1;for(;++s<i.length;)_D(t,"text",a);function a(c,u){let d=-1,h;for(;++d<u.length;){const p=u[d],m=h?h.children:void 0;if(o(p,m?m.indexOf(p):void 0,h))return;h=p}if(h)return l(c,u)}function l(c,u){const d=u[u.length-1],h=i[s][0],p=i[s][1];let m=0;const v=d.children.indexOf(c);let y=!1,g=[];h.lastIndex=0;let k=h.exec(c.value);for(;k;){const A=k.index,C={index:k.index,input:k.input,stack:[...u,c]};let E=p(...k,C);if(typeof E=="string"&&(E=E.length>0?{type:"text",value:E}:void 0),E===!1?h.lastIndex=A+1:(m!==A&&g.push({type:"text",value:c.value.slice(m,A)}),Array.isArray(E)?g.push(...E):E&&g.push(E),m=A+k[0].length,y=!0),!h.global)break;k=h.exec(c.value)}return y?(m<c.value.length&&g.push({type:"text",value:c.value.slice(m)}),d.children.splice(v,1,...g)):g=[c],v+g.length}}function L7(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([$7(o[0]),H7(o[1])])}return e}function $7(t){return typeof t=="string"?new RegExp(A7(t),"g"):t}function H7(t){return typeof t=="function"?t:function(){return t}}const Gm="phrasing",Km=["autolink","link","image","label"];function z7(){return{transforms:[K7],enter:{literalAutolink:V7,literalAutolinkEmail:Ym,literalAutolinkHttp:Ym,literalAutolinkWww:Ym},exit:{literalAutolink:G7,literalAutolinkEmail:q7,literalAutolinkHttp:W7,literalAutolinkWww:U7}}}function j7(){return{unsafe:[{character:"@",before:"[+\\-.\\w]",after:"[\\-.\\w]",inConstruct:Gm,notInConstruct:Km},{character:".",before:"[Ww]",after:"[\\-.\\w]",inConstruct:Gm,notInConstruct:Km},{character:":",before:"[ps]",after:"\\/",inConstruct:Gm,notInConstruct:Km}]}}function V7(t){this.enter({type:"link",title:null,url:"",children:[]},t)}function Ym(t){this.config.enter.autolinkProtocol.call(this,t)}function W7(t){this.config.exit.autolinkProtocol.call(this,t)}function U7(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 q7(t){this.config.exit.autolinkEmail.call(this,t)}function G7(t){this.exit(t)}function K7(t){P7(t,[[/(https?:\/\/|www(?=\.))([-.\w]+)([^ \t\r\n]*)/gi,Y7],[new RegExp("(?<=^|\\s|\\p{P}|\\p{S})([-.\\w+]+)@([-\\w]+(?:\\.[-\\w]+)+)","gu"),X7]],{ignore:["link","linkReference"]})}function Y7(t,e,n,r,o){let i="";if(!ND(o)||(/^w/i.test(e)&&(n=e+n,e="",i="http://"),!J7(n)))return!1;const s=R7(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 X7(t,e,n,r){return!ND(r,!0)||/[-\d_]$/.test(n)?!1:{type:"link",title:null,url:"mailto:"+e+"@"+n,children:[{type:"text",value:e+"@"+n}]}}function J7(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 R7(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=OD(t,"(");let i=OD(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 ND(t,e){const n=t.input.charCodeAt(t.index-1);return(t.index===0||pi(n)||id(n))&&(!e||n!==47)}function nl(t){return t.replace(/[\t\n\r ]+/g," ").replace(/^ | $/g,"").toLowerCase().toUpperCase()}BD.peek=sV;function Q7(){this.buffer()}function Z7(t){this.enter({type:"footnoteReference",identifier:"",label:""},t)}function eV(){this.buffer()}function tV(t){this.enter({type:"footnoteDefinition",identifier:"",label:"",children:[]},t)}function nV(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=nl(this.sliceSerialize(t)).toLowerCase(),n.label=e}function rV(t){this.exit(t)}function oV(t){const e=this.resume(),n=this.stack[this.stack.length-1];n.type,n.identifier=nl(this.sliceSerialize(t)).toLowerCase(),n.label=e}function iV(t){this.exit(t)}function sV(){return"["}function BD(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 aV(){return{enter:{gfmFootnoteCallString:Q7,gfmFootnoteCall:Z7,gfmFootnoteDefinitionLabelString:eV,gfmFootnoteDefinition:tV},exit:{gfmFootnoteCallString:nV,gfmFootnoteCall:rV,gfmFootnoteDefinitionLabelString:oV,gfmFootnoteDefinition:iV}}}function lV(t){let e=!1;return t&&t.firstLineBlank&&(e=!0),{handlers:{footnoteDefinition:n,footnoteReference:BD},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?`
|
|
72
72
|
`:" ")+i.indentLines(i.containerFlow(r,a.current()),e?FD:cV))),c(),l}}function cV(t,e,n){return e===0?t:FD(t,e,n)}function FD(t,e,n){return(n?"":" ")+t}const uV=["autolink","destinationLiteral","destinationRaw","reference","titleQuote","titleApostrophe"];ID.peek=mV;function dV(){return{canContainEols:["delete"],enter:{strikethrough:hV},exit:{strikethrough:pV}}}function fV(){return{unsafe:[{character:"~",inConstruct:"phrasing",notInConstruct:uV}],handlers:{delete:ID}}}function hV(t){this.enter({type:"delete",children:[]},t)}function pV(t){this.exit(t)}function ID(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 mV(){return"~"}function gV(t){return t.length}function wV(t,e){const n=e||{},r=(n.align||[]).concat(),o=n.stringLength||gV,i=[],s=[],a=[],l=[];let c=0,u=-1;for(;++u<t.length;){const w=[],v=[];let y=-1;for(t[u].length>c&&(c=t[u].length);++y<t[u].length;){const g=vV(t[u][y]);if(n.alignDelimiters!==!1){const k=o(g);v[y]=k,(l[y]===void 0||k>l[y])&&(l[y]=k)}w.push(g)}s[u]=w,a[u]=v}let d=-1;if(typeof r=="object"&&"length"in r)for(;++d<c;)i[d]=MD(r[d]);else{const w=MD(r);for(;++d<c;)i[d]=w}d=-1;const h=[],p=[];for(;++d<c;){const w=i[d];let v="",y="";w===99?(v=":",y=":"):w===108?v=":":w===114&&(y=":");let g=n.alignDelimiters===!1?1:Math.max(1,l[d]-v.length-y.length);const k=v+"-".repeat(g)+y;n.alignDelimiters!==!1&&(g=v.length+g+y.length,g>l[d]&&(l[d]=g),p[d]=g),h[d]=k}s.splice(1,0,h),a.splice(1,0,p),u=-1;const m=[];for(;++u<s.length;){const w=s[u],v=a[u];d=-1;const y=[];for(;++d<c;){const g=w[d]||"";let k="",A="";if(n.alignDelimiters!==!1){const C=l[d]-(v[d]||0),E=i[d];E===114?k=" ".repeat(C):E===99?C%2?(k=" ".repeat(C/2+.5),A=" ".repeat(C/2-.5)):(k=" ".repeat(C/2),A=k):A=" ".repeat(C)}n.delimiterStart!==!1&&!d&&y.push("|"),n.padding!==!1&&!(n.alignDelimiters===!1&&g==="")&&(n.delimiterStart!==!1||d)&&y.push(" "),n.alignDelimiters!==!1&&y.push(k),y.push(g),n.alignDelimiters!==!1&&y.push(A),n.padding!==!1&&y.push(" "),(n.delimiterEnd!==!1||d!==c-1)&&y.push("|")}m.push(n.delimiterEnd===!1?y.join("").replace(/ +$/,""):y.join(""))}return m.join(`
|
|
73
73
|
`)}function vV(t){return t==null?"":String(t)}function MD(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 yV(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()),bV);return o(),s}function bV(t,e,n){return">"+(n?"":" ")+t}function CV(t,e){return PD(t,e.inConstruct,!0)&&!PD(t,e.notInConstruct,!1)}function PD(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 LD(t,e,n,r){let o=-1;for(;++o<n.unsafe.length;)if(n.unsafe[o].character===`
|
|
@@ -88,16 +88,16 @@ The error may be correlated with this previous error:
|
|
|
88
88
|
`,eg={content:dA,color:uA[0]},fA=({id:t,data:e,selected:n,width:r,height:o})=>{const{config_schema:i}=e||{},s=b.useRef(null),a=b.useMemo(()=>{if(i!=null&&i.value)try{const P=JSON.parse(i.value);return{...eg,...P}}catch{return eg}return eg},[i==null?void 0:i.value]),{handleNodeDataUpdate:l}=Hr(),[c,u]=b.useState(!1),[d,h]=b.useState(a.content),[p,m]=b.useState(a.content),[w,v]=b.useState(a.color),{addNodes:y,getNodes:g}=Fi(),{handleNodesDelete:k}=rd(),A=Vt();b.useEffect(()=>{h(a.content),v(a.color)},[a.content,a.color]);const C=P=>({content:d,color:w,width:r,height:o,...P}),E=()=>{if(s.current){const P=s.current.getBoundingClientRect();return{width:Math.round(P.width),height:Math.round(P.height)}}return{width:r,height:o}},D=P=>{var W;const $={config_schema:{value:JSON.stringify(P)}};l({id:t,sync:!0,data:$}),(W=e==null?void 0:e.onChange)==null||W.call(e,t,P)},S=()=>{m(d),u(!0)},_=b.useCallback(()=>{const P=p||dA;h(P);const $=E(),W=C({content:P,color:w,width:$.width,height:$.height});D(W),u(!1)},[p,w,r,o]),O=()=>{u(!1)},B=b.useCallback(()=>{setTimeout(()=>{const P=E(),$=C({width:P.width,height:P.height});D($)},50)},[d,w,r,o]),N=P=>{v(P);const $=E(),W=C({color:P,width:$.width,height:$.height});D(W)},F=A.engineMode===or.NEXT,M=async()=>{try{F||await Qd(t),k([t],ee.STICKY),x.message.success("便签删除成功")}catch(P){x.message.error("便签删除失败"),console.error("删除便签失败:",P)}},T=async()=>{var $;const P=g();try{const W=P.find(X=>X.id===t);if(!W){x.message.error("获取当前节点信息失败");return}const V=($=A.canvas.limits)==null?void 0:$.maxNodes;if(typeof V=="number"&&P.length>=V){x.message.warning("已达到画布允许的最大节点数");return}if(F){const X=crypto.randomUUID(),G=ut.cloneDeep(W.data);G.id=X,G.nodeId=X;const te=Bn.createNode(ee.STICKY,X,G,{x:W.position.x+50,y:W.position.y+100});y([te])}else{const X=await nf(t);X&&y([{id:X.id,type:X.node_type,position:{x:W.position.x,y:W.position.y+100}}])}x.message.success("便签复制成功")}catch(W){x.message.error("便签复制失败"),console.error("复制便签失败:",W)}};return f.jsxs(b.Fragment,{children:[f.jsx(ae.NodeResizer,{lineStyle:{borderColor:"transparent",borderWidth:15},handleStyle:{background:"transparent"},onResizeEnd:B,minWidth:140,minHeight:94}),n&&f.jsx(ae.NodeToolbar,{children:f.jsxs("div",{className:"workflow-sticky-toolbar",children:[f.jsx("div",{className:"sticky-toolbar-button",onClick:S,children:f.jsx(Z.EditOutlined,{})}),f.jsx("div",{className:"sticky-toolbar-button",onClick:T,children:f.jsx(Z.CopyOutlined,{})}),f.jsx("div",{className:"sticky-toolbar-button sticky-toolbar-button-danger",onClick:M,children:f.jsx(Z.DeleteOutlined,{})}),f.jsx("div",{className:"sticky-color-palette",children:uA.map(P=>f.jsx("div",{className:kn("sticky-color-item",{"sticky-color-item-active":P===w}),style:{backgroundColor:P},onClick:()=>N(P)},P))})]})}),f.jsx("div",{ref:s,style:{width:"100%",height:"100%"},children:f.jsx(x.Card,{className:kn("workflow-sticky-note",{"workflow-sticky-note-selected":n}),style:{width:"100%",height:"100%",padding:0,borderColor:eU(w)},styles:{body:{width:"100%",height:"100%",backgroundColor:w,padding:8,overflow:"auto"}},onDoubleClick:S,children:f.jsx("div",{className:"workflow-sticky-md",children:f.jsx(PT,{remarkPlugins:[QW],children:d})})})}),f.jsx(x.Modal,{title:"编辑便签",open:c,onOk:_,onCancel:O,okText:"确定",cancelText:"取消",width:520,children:f.jsx(ZW,{value:p,onChange:P=>m(P.target.value),autoSize:{minRows:6,maxRows:12},placeholder:"支持 Markdown 语法,在此编辑便签内容"})})]})},tU=t=>{var l;const{id:e,data:n,selected:r}=t,o=ae.useUpdateNodeInternals(),i=ae.useInternalNode(e),s=i==null?void 0:i.data,a=b.useMemo(()=>{const u=((s==null?void 0:s.config_schema)||{}).branches||[],d=Math.max(2,Math.min(u.length,10));return setTimeout(()=>{o(e)},1e3),u.map((h,p)=>{const m=h==null?void 0:h.name,w=(p+1)/(d+2)*100;return{id:h==null?void 0:h.id,position:ae.Position.Right,type:je.SOURCE,maxConnections:1,label:m,style:{top:`${w}%`},isMain:!1}}).concat({id:"default-branch",position:ae.Position.Right,type:je.SOURCE,maxConnections:1,label:"default",style:{top:`${(u.length+1)/(d+2)*100}%`},isMain:!1})},[s==null?void 0:s.config_schema,JSON.stringify((l=s==null?void 0:s.config_schema)==null?void 0:l.branches)]);return f.jsx(_n,{id:e,data:s,selected:r,height:a.length>2?a.length*30:72,type:ee.SWITCH,status:s==null?void 0:s.status,className:"switch-node",icon:s!=null&&s.icon?f.jsx("img",{src:s==null?void 0:s.icon,alt:s.name,style:{width:24,height:24}}):f.jsx(Z.FilterOutlined,{style:{fontSize:24,color:"#007fff"}}),inputs:[{id:Ie.INPUT,position:ae.Position.Left,type:je.TARGET,maxConnections:1,isMain:!0}],outputs:a})},nU=t=>{const{id:e,data:n,selected:r}=t,o=n;return f.jsx(_n,{id:e,data:o,selected:r,type:ee.TRIGGER,status:o==null?void 0:o.status,icon:o!=null&&o.icon?f.jsx("img",{src:o==null?void 0:o.icon,alt:o.label,style:{width:30,height:30}}):f.jsx(Fw.PiCursorFill,{style:{color:"#007fff",fontSize:24}}),inputs:[],outputs:[{id:Ie.OUTPUT,position:ae.Position.Right,type:je.SOURCE,isMain:!0,label:"",maxConnections:1}],className:"workflow-trigger-node"})};class Bn{static getNodeTypes(){return{[ee.START]:AD,[ee.TRIGGER]:nU,[ee.ACTION]:y7,[ee.AGENT]:CD,[ee.BROWSER]:kD,[ee.CONDITION]:b7,[ee.LOOP]:k7,[ee.SELF_LOOP]:E7,[ee.AI_SUB_NODE]:od,[ee.VECTOR_STORE]:od,[ee.MCPServer]:ED,[ee.BuiltinMCP]:xD,[ee.MCP_TOOL]:DD,[ee.CUSTOM]:SD,[ee.SWITCH]:tU,[ee.STICKY]:fA}}static mapTypeToBackendType(e){switch(e){case ee.ACTION:return"ActionNode";case ee.CONDITION:return"ConditionNode";case ee.LOOP:return"LoopNode";case ee.SELF_LOOP:return"SelfLoopNode";case ee.AGENT:return"AgentNode";case ee.TRIGGER:return"StartEventNode";case ee.START:return"StartNode";case ee.AI_SUB_NODE:return"AISubNode";case ee.SWITCH:return"SwitchNode";case ee.STICKY:return"StickyNoteNode";default:return"UnknownNode"}}static createNode(e,n,r,o={x:0,y:0}){let i={};switch(e){case ee.CONDITION:r.branches||(r.branches=[{id:"true",label:"是",condition:"value === true"},{id:"false",label:"否",condition:"value === false"}]);break;case ee.LOOP:r.loopType||(r.loopType="for",r.config={initialValue:0,finalValue:10,step:1});break;case ee.TRIGGER:i={};break}return{id:n,type:e,data:r,position:o,...i}}static toBackendFormat(e){const n=e.data.node_type,r=e.data.action_id||e.data.id||"";return{node_type:n,connector_id:e.data.connector_id||"",n_id:e.data.n_id||e.id,action_id:r,account_id:e.data.account_id||null,position:e.position,properties:Bn.extractNodeProperties(e.data)}}static extractNodeProperties(e){if(!e)return{};const n={...e};return["node_type","connector_id","n_id","action_id","account_id","label","description","isHovered","category"].forEach(o=>{o in n&&delete n[o]}),n}}const ol=[],rU={nodes:ol,edges:[],selectedNodes:[],selectedEdges:[],workflowName:"",refreshWorkFlowNum:0,autoSaveWatchNum:0,currentNodeConfigVisibleId:null,isLocked:!0,executionControl:null},hA=Ld.createSlice({name:"workflow",initialState:rU,reducers:{setWorkflowId:(t,e)=>{t.workflowId=e.payload},executeAutoSave:t=>{t.autoSaveWatchNum+=1},setWorkflowName:(t,e)=>{t.workflowName=e.payload},applyNodesChanges:(t,e)=>{const n=ae.applyNodeChanges(e.payload,t.nodes);t.nodes=n.length>0?n:ol},applyEdgesChanges:(t,e)=>{t.edges=ae.applyEdgeChanges(e.payload,t.edges)},refreshFlow:t=>{t.refreshWorkFlowNum+=1},addConnection:(t,e)=>{const n={id:Pm(),source:e.payload.source,type:"main",sourceHandle:e.payload.sourceHandle,target:e.payload.target,targetHandle:e.payload.targetHandle};t.edges.push(n)},addNode:(t,e)=>{const{type:n,position:r,data:o}=e.payload,i=Bn.createNode(n,Pm(),o,r);t.nodes.push(i)},addNodes:(t,e)=>{const n=t.nodes.concat(e.payload);t.nodes=n.length>0?n.filter(r=>r.id!=="PLACEHOLDER_NODE"):ol},addEdges:(t,e)=>{t.edges.push(...e.payload)},resetFlow:t=>{t.nodes=[],t.edges=[],t.workflowName="",t.workflowId="",t.refreshWorkFlowNum=0,t.currentNodeConfigVisibleId=null,t.isLocked=!0,t.executionControl=null},removeNodes:(t,e)=>{const n=e.payload,r=t.nodes.filter(o=>!n.includes(o.id));t.nodes=r.length>0?r:ol,t.edges=t.edges.filter(o=>!n.includes(o.source)&&!n.includes(o.target))},removeEdges:(t,e)=>{const n=e.payload;t.edges=t.edges.filter(r=>!n.includes(r.id))},setSelection:(t,e)=>{t.selectedNodes=e.payload.nodes,t.selectedEdges=e.payload.edges},updateEdge:(t,e)=>{const{oldEdge:n,newConnection:r}=e.payload,o=t.edges.findIndex(i=>i.id===n.id);if(o!==-1){const i={...n,source:r.source,sourceHandle:r.sourceHandle,target:r.target,targetHandle:r.targetHandle};t.edges[o]=i}},setNodes:(t,e)=>{t.nodes=e.payload.length>0?e.payload:ol},setEdges:(t,e)=>{t.edges=e.payload},setFlowOpStatus:(t,e)=>{t.op_status=e.payload},updateNode:(t,e)=>{const{id:n,data:r}=e.payload,o=t.nodes.findIndex(i=>i.id===n);o!==-1&&(t.nodes[o]={...t.nodes[o],data:{...t.nodes[o].data,...r}})},setCurrentNodeConfigVisibleId:(t,e)=>{t.currentNodeConfigVisibleId=e.payload},setLocked:(t,e)=>{t.isLocked=e.payload},setExecutionControl:(t,e)=>{t.executionControl=e.payload}}}),{setWorkflowId:oU,setWorkflowName:gi,applyNodesChanges:iU,applyEdgesChanges:sU,addConnection:aU,addNode:BR,addNodes:lU,addEdges:cU,removeNodes:uU,removeEdges:dU,setSelection:FR,updateEdge:fU,setNodes:hU,setEdges:pU,updateNode:mU,setFlowOpStatus:xs,refreshFlow:pA,setCurrentNodeConfigVisibleId:gU,setLocked:wU,setExecutionControl:mA,resetFlow:hd,executeAutoSave:vU}=hA.actions,yU=hA.reducer,tg=Ld.configureStore({reducer:{workflow:yU,panel:BN},middleware:t=>t({serializableCheck:{ignoredActions:["panel/setNodeAddCallback"],ignoredPaths:["panel.nodeAddCallback"]}})}),Ss=()=>$d.useDispatch(),Io=$d.useSelector;function Es(){const t=Ss(),{nodeSelectorVisible:e,nodeAddInfo:n,nodeAddCallback:r}=Io(c=>c.panel),o=b.useCallback(c=>{t(_N(c))},[t]),i=b.useCallback(()=>{t(t0())},[t]),s=b.useCallback(c=>{r&&n&&r(n,c),t(t0())},[t,n,r]),a=b.useCallback((c,u)=>{r&&c&&r(c,u)},[t,n,r]),l=b.useCallback(c=>{t(NN(c))},[t]);return{nodeSelectorVisible:e,nodeAddInfo:n,openNodeSelector:o,closeNodeSelector:i,handleNodeSelect:s,handleManualAdd:a,setNodeAddCallback:l}}const bU=({node:t,onSelect:e})=>f.jsxs("div",{className:"simple-node-item",onClick:()=>e(t),children:[f.jsx("div",{className:"simple-node-item-icon",children:f.jsx("span",{children:t.name.charAt(0).toUpperCase()})}),f.jsxs("div",{className:"simple-node-item-info",children:[f.jsx("div",{className:"simple-node-item-name",children:t.name}),t.description&&f.jsx("div",{className:"simple-node-item-desc",children:t.description}),f.jsx("div",{className:"simple-node-item-key",children:t.key})]})]});function CU(t){const[e,n]=b.useState([]),[r,o]=b.useState(!1),[i,s]=b.useState("");b.useEffect(()=>{if(!t){s("");return}o(!0),SN().then(c=>{console.log(`[DIP] 节点列表加载完成: ${c.length}个节点`),n(c)}).catch(c=>{console.error("[DIP] 获取节点列表失败:",c),n([])}).finally(()=>o(!1))},[t]);const a=b.useMemo(()=>{if(!i.trim())return e;const c=i.trim().toLowerCase();return e.filter(u=>u.name.toLowerCase().includes(c)||u.key.toLowerCase().includes(c))},[e,i]),l=b.useMemo(()=>{const c=new Map;for(const d of a){const h=d.key.split("."),p=h.length>=2?h[0]:"other";c.has(p)||c.set(p,[]),c.get(p).push(d)}const u=Array.from(c.entries()).map(([d,h])=>({pluginId:d,nodes:h}));return console.log(`[DIP] 过滤后: ${a.length}个节点, ${u.length}个分组`),u},[a]);return{allNodes:e,filteredNodes:a,groupedNodes:l,loading:r,searchText:i,setSearchText:s}}const kU=()=>{const t=b.useRef(null),{nodeSelectorVisible:e,closeNodeSelector:n,handleNodeSelect:r,nodeAddInfo:o}=Es(),{groupedNodes:i,loading:s,searchText:a,setSearchText:l}=CU(e),c=b.useCallback(u=>{console.log(`[DIP] 选中节点: ${u.key} v${u.version}`);const d={id:u.key,type:ee.ACTION,name:u.name,description:u.description||"",category:"DIP",icon:void 0,isAction:!0,nodeVersion:u.version,action_type:ee.ACTION,nodeId:u.key,action_name:u.name,connector_name:"DIP"};r(d)},[r,o]);return dt.useClickAway(()=>{e&&n()},t),e?f.jsxs("div",{className:kn("simple-node-selector",{visible:e}),ref:t,children:[f.jsxs("div",{className:"simple-panel-header",children:[f.jsx("div",{className:"simple-header-title",children:"选择节点"}),f.jsx("div",{className:"simple-header-close",onClick:n,children:f.jsx(Z.CloseOutlined,{})})]}),f.jsx("div",{className:"simple-search-container",children:f.jsx(x.Input,{placeholder:"搜索节点名称或 Key...",prefix:f.jsx(Z.SearchOutlined,{style:{color:"#007aff"}}),allowClear:!0,value:a,onChange:u=>l(u.target.value)})}),f.jsx("div",{className:"simple-panel-content",children:s?f.jsxs("div",{className:"simple-loading-state",children:[f.jsx(x.Spin,{}),f.jsx("span",{className:"simple-loading-text",children:"加载节点中..."})]}):i.length===0?f.jsx("div",{className:"simple-empty-state",children:"暂无可用节点"}):i.map(u=>f.jsxs("div",{className:"simple-node-group",children:[f.jsx("div",{className:"simple-group-title",children:u.pluginId}),u.nodes.map(d=>f.jsx(bU,{node:d,onSelect:c},d.key))]},u.pluginId))})]}):null};var xt=(t=>(t.MAIN="main",t.AI="ai",t))(xt||{});const ng=()=>{const t=ae.useStoreApi(),e=b.useCallback((s,a)=>{const{edges:l,setEdges:c}=t.getState(),u=Pn(l,d=>{const h=d.find(p=>p.id===a.id);h.data?h.data.isHovered=!0:h.data={isHovered:!0}});c(u)},[]),n=b.useCallback((s,a)=>{const{edges:l,setEdges:c}=t.getState(),u=Pn(l,d=>{const h=d.find(p=>p.id===a.id);h.data?h.data.isHovered=!1:h.data={isHovered:!1}});c(u)},[]),r=b.useCallback(s=>{const{edges:a,setEdges:l}=t.getState(),c=Pn(a,u=>{s.forEach(d=>{d.type==="select"&&(u.find(h=>h.id===d.id).selected=d.selected)})});l(c)},[t]),o=b.useCallback(s=>{const{edges:a,setEdges:l}=t.getState(),c=a.filter(u=>!s.includes(u.id));console.log("edges",a),console.log("newEdges",c),l(c)},[t]),i=b.useCallback(s=>{const a=Bt.createEdge(xt.MAIN,`${s.source}-${s.target}-${Date.now()}`,s.source,s.target,{sourceHandle:s.sourceHandle,targetHandle:s.targetHandle}),{edges:l,setEdges:c}=t.getState();c([...l,a])},[t]);return{onEdgeMouseEnter:e,removeEdges:o,onConnect:i,setEdges:t.getState().setEdges,onEdgeMouseLeave:n,handleEdgesChange:r}},xU=t=>{switch(t){case me.INVALID:return"workflow-edge-warning";case me.FAILED:return"workflow-edge-failed";case me.SUCCESS:return"workflow-edge-success";case me.RUNNING:return"workflow-edge-running";case me.IDLE:default:return""}},{EDGE_PADDING_BOTTOM:SU,EDGE_BORDER_RADIUS:gA,HANDLE_SIZE:EU}=i0,{undeletableEdgeTargetTypes:DU,unAddableTargetTypes:AU}=s0,pd=1,OU=({id:t,sourceX:e,sourceY:n,targetX:r,targetY:o,sourcePosition:i,targetPosition:s,data:a,source:l,sourceHandleId:c,target:u,targetHandleId:d,style:h={},animated:p=!1,className:m="workflow-main-edge"})=>{var le,L;const w=oo(),{removeEdges:v}=ng(),{getNodes:y}=Fi(),{openNodeSelector:g}=Es(),k=ae.useInternalNode(l),A=k==null?void 0:k.data,C=(A==null?void 0:A.status)||me.IDLE,E=Ct(),D=ae.useInternalNode(u),S=D==null?void 0:D.data,_=n0.includes((L=(le=S==null?void 0:S.protocol)==null?void 0:le.toUpperCase)==null?void 0:L.call(le))||r0.includes(D==null?void 0:D.type),O=Vt(),B=O.edgeRules,N=b.useMemo(()=>s===ae.Position.Left?r+pd:s===ae.Position.Right?r-pd:r,[r,s]),F=b.useMemo(()=>s===ae.Position.Top?o+pd:s===ae.Position.Bottom?o-pd:o,[o,s]),M=b.useMemo(()=>e-EU>N,[e,N]),T=(a==null?void 0:a.connectionType)||"main",P=(a==null?void 0:a.isLoopEdge)||!1,$=DU.includes(D==null?void 0:D.type),W=AU.includes(D==null?void 0:D.type),{edgePath:V,labelX:X,labelY:G}=b.useMemo(()=>{if(!M||T!=="main"||_){const[q,J,K]=ae.getBezierPath({sourceX:e,sourceY:n,sourcePosition:i,targetX:N,targetY:F,targetPosition:s});return{edgePath:q,labelX:J,labelY:K}}else{const q=(e+N)/2,J=n+SU,[K]=ae.getSmoothStepPath({sourceX:e,sourceY:n,sourcePosition:i,targetX:q,targetY:J,targetPosition:ae.Position.Right,borderRadius:gA}),[re]=ae.getSmoothStepPath({sourceX:q,sourceY:J,sourcePosition:ae.Position.Left,targetX:N,targetY:F,targetPosition:s,borderRadius:gA});return{edgePath:`${K} ${re}`,labelX:q,labelY:J}}},[e,n,N,F,i,s,M,T]),H={..._?Vs.aiProtocol:P?Vs.loop:a!=null&&a.isHovered?Vs.hovered:Vs.default,...h},j=`workflow-edge ${p?"workflow-edge-animated":""}
|
|
89
89
|
${P?"workflow-loop-edge":""}
|
|
90
90
|
${a!=null&&a.isHovered?"edge-hovered":""}
|
|
91
|
-
${xU(C)} ${m}`.replace(/\s+/g," ").trim(),Y=q=>{var he;if(q.stopPropagation(),B&&B.allowAddNodeOnEdge===!1)return;const J=y(),K=(he=O.canvas.limits)==null?void 0:he.maxNodes;if(typeof K=="number"&&J.length>=K){x.message.warning("已达到画布允许的最大节点数");return}const re={x:(e+N)/2,y:(n+F)/2};g({position:re,edge:{id:t,source:l,sourceHandleId:c,target:u,targetHandleId:d,data:a},targetNode:ut.cloneDeep(D),sourceNode:ut.cloneDeep(k)})},se=q=>{q.stopPropagation(),!($||B&&B.allowDeleteEdge===!1)&&(v([t]),Vv(w,[t]))},Q=[f.jsx("path",{id:t,className:j,d:V,style:H,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",markerEnd:"url(#workflow-arrow)"},`${t}-path`),E?f.jsx(ae.EdgeLabelRenderer,{children:f.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${X}px,${G}px)`,padding:"4px",borderRadius:"4px",opacity:a!=null&&a.isHovered?1:0,gap:"8px",zIndex:1e3,pointerEvents:"all"},className:"nodrag nopan workflow-edge-buttons",children:[!W&&(!B||B.allowAddNodeOnEdge!==!1)&&f.jsx("button",{type:"button",onClick:Y,style:{...Ws.default,...Ws.add},className:"workflow-edge-button",title:"添加节点",children:f.jsx(Z.PlusOutlined,{style:{fontSize:"16px"}})}),!$&&(!B||B.allowDeleteEdge!==!1)&&f.jsx("button",{type:"button",onClick:se,style:{...Ws.default,...Ws.delete},className:"workflow-edge-button",title:"删除连线",children:f.jsx(Z.DeleteOutlined,{style:{fontSize:"16px"}})})]})},`${t}-buttons`):null];return a!=null&&a.label&&Q.push(f.jsx(ae.EdgeLabelRenderer,{children:f.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${X}px,${G+(P?20:0)}px)`,...o0.edge},children:a.label})},`${t}-label`)),Q};class Bt{static getEdgeTypes(){return{[xt.MAIN]:OU}}static getEdgeComponent(e){const n=Bt.getEdgeTypes();return n[e]||n[xt.MAIN]}static createEdge(e,n,r,o,i){const s=e===xt.AI?"workflow-ai-edge":"workflow-main-edge",a=e===xt.AI?"green":"#7e8186";let l={},c,u,d;if(i&&typeof i=="object"&&("sourceHandle"in i||"targetHandle"in i||"onAddNode"in i)){const h=i;c=h.sourceHandle,u=h.targetHandle,d=h.onAddNode,l=h.data||{}}return{id:n,type:e,source:r,target:o,sourceHandle:c,targetHandle:u,data:{...l,className:s,onAddNode:d},markerEnd:{type:ae.MarkerType.ArrowClosed,width:20,height:20,color:a},style:{stroke:a,strokeWidth:1},className:s}}static renderEdge(e){const n=Bt.getEdgeComponent(e.type||xt.MAIN);return f.jsx(n,{...e})}}const TU=new Set(Object.values(ee));function _U(t){var n;const e=(n=t.params)==null?void 0:n._uiNodeType;return e&&TU.has(e)?e:ee.ACTION}function NU(t){return t.map(e=>{const{_uiNodeType:n,_configSchema:r,_note:o,_debugOutput:i,_debugStatus:s,...a}=e.params||{};return{id:e.id,type:_U(e),position:e.position,data:{name:e.name,label:e.name,action_name:e.name,nodeKey:e.nodeKey,nodeVersion:e.nodeVersion,params:a,credentialInstanceId:e.credentialInstanceId,settings:e.settings,...r?{config_schema:r}:{},...o?{note:o}:{},...i!==void 0?{output:i}:{},...s!==void 0?{status:s}:{}}}})}function BU(t){return t.map((e,n)=>{const r=`${e.sourceNodeId}-${e.targetNodeId}-${n}`;return Bt.createEdge(xt.MAIN,r,e.sourceNodeId,e.targetNodeId,{sourceHandle:e.sourceOutput||"main",targetHandle:e.targetInput||"main"})}).filter(Boolean)}function FU(t){if(!t)return{workflowId:"",workflowName:"",nodes:[],edges:[],active:!1};const e=NU(t.nodes||[]),n=new Set(e.map(o=>o.id)),r=BU(t.connections||[]).filter(o=>n.has(o.source)&&n.has(o.target));return{workflowId:t.id,workflowName:t.name||"",nodes:e,edges:r,active:t.active??!1}}function IU(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function MU(t){const e=t.data,n={...(e==null?void 0:e.params)||{}};return t.type&&t.type!==ee.ACTION&&(n._uiNodeType=t.type),e!=null&&e.config_schema&&(n._configSchema=e.config_schema),e!=null&&e.note&&(n._note=e.note),(e==null?void 0:e.output)!==void 0&&(e==null?void 0:e.output)!==null&&(e==null?void 0:e.output)!==""&&(n._debugOutput=e.output),(e==null?void 0:e.status)!==void 0&&(e==null?void 0:e.status)!==null&&(n._debugStatus=e.status),{id:t.id,name:(e==null?void 0:e.label)||(e==null?void 0:e.action_name)||"",nodeKey:(e==null?void 0:e.nodeKey)||"",nodeVersion:(e==null?void 0:e.nodeVersion)||1,position:t.position,params:n,credentialInstanceId:e==null?void 0:e.credentialInstanceId,settings:e==null?void 0:e.settings}}function PU(t){return{sourceNodeId:t.source,sourceOutput:t.sourceHandle||"main",targetNodeId:t.target,targetInput:t.targetHandle||"main"}}function LU(t,e,n=""){const r=t.filter(s=>s.type!==ee.START).map(MU),o=new Set(r.map(s=>s.id)),i=e.filter(s=>o.has(s.source)&&o.has(s.target)&&s.source&&s.sourceHandle&&s.targetHandle);return{name:n,nodes:r,connections:i.map(PU)}}const rg={type:ee.START,id:"PLACEHOLDER_NODE",position:{x:100,y:250},data:{type:ee.START,name:"开始",nodeId:"PLACEHOLDER_NODE",id:"PLACEHOLDER_NODE",description:"开始节点"}},wA=t=>({label:t.action_name,description:t.connector_name,...t.action_key?{nodeKey:t.action_key}:{},...t.action_ver!==void 0?{nodeVersion:t.action_ver}:{},...Object.entries(t).reduce((e,[n,r])=>(n!=="name"&&n!=="node_schema"&&(e[n]=r),e),{})}),og=t=>({...wA(t),name:t.name});Bn.getNodeTypes();const $U=Bt.getEdgeTypes(),HU={"--edge-marker-size":"14px","--edge-stroke-width":"1px"},zU={x:0,y:0,zoom:1},jU={x:0,y:0,zoom:.8},VU={type:xt.MAIN,markerEnd:{type:ae.MarkerType.ArrowClosed,width:20,height:20,color:"#7e8186"}},WU="944",UU="core.stickyNote",{Title:qU,Text:ig}=x.Typography,GU=({opStatus:t})=>{const e=oo(),n={[We.UNPUBLISHED]:f.jsx(x.Tag,{bordered:!1,color:"orange",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.not-published"})}),[We.ONLINE]:f.jsx(x.Tag,{bordered:!1,color:"green",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.already-online"})}),[We.OFFLINE]:f.jsx(x.Tag,{bordered:!1,color:"default",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.already-offline"})}),[We.ONLINE_ING]:f.jsx(x.Tag,{bordered:!1,color:"processing",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.going-online"})}),[We.ON_WARN]:f.jsx(Nl,{to:`/link/log?warnId=${e}`,children:f.jsxs(x.Space,{size:[5,5],children:[f.jsx(Z.ExclamationCircleOutlined,{style:{color:"#faad14"}}),f.jsx(Ee.FormattedMessage,{id:"common.warning"})]})}),[We.OFF_WARN]:f.jsx(Nl,{to:`/link/log?warnId=${e}`,children:f.jsxs(x.Space,{size:[5,5],children:[f.jsx(Z.ExclamationCircleOutlined,{style:{color:"#faad14"}}),f.jsx(Ee.FormattedMessage,{id:"common.warning"})]})})};return f.jsx(f.Fragment,{children:n[t]??null})},KU=({onSave:t,readOnly:e=!1,preview:n=!1,autoSaveStatus:r=hn.IDLE,lastSavedTime:o,unSave:i,appFlowMode:s=!1,canvasApi:a})=>{var te,H;const l=Ss(),c=Ct(),u=Io(j=>j.workflow.workflowName),d=Io(j=>j.workflow.op_status),[h,p]=b.useState(!1),[m,w]=b.useState(u),[v,y]=b.useState(!1),[g,k]=b.useState(!1),A=b.useRef(null),{getNodes:C}=ae.useReactFlow(),E=C(),D=Vt(),S=D.toolbar,_=oo(),O=D.history??_i,B=((te=E.filter(j=>j.type!==ee.START))==null?void 0:te.length)>0;b.useEffect(()=>{w(u)},[u]),b.useEffect(()=>{h&&A.current&&A.current.focus()},[h]),dt.useUnmount(()=>{l(hd()),gi("")});const N=()=>{t==null||t()},F=b.useCallback(()=>{if(g)return;const j=u,Y=m.trim()||"未命名工作流";l(gi(Y)),Xv(_,{name:Y}).catch(()=>{l(gi(j))}),p(!1)},[l,m,u,_,g]),M=async()=>{y(!0);try{await kN(_),x.message.success("上线成功"),l(xs(We.ONLINE))}catch{}finally{y(!1)}},T=async()=>{y(!0);try{await xN(_),x.message.success("下线成功"),l(xs(We.OFFLINE))}catch{}finally{y(!1)}},[P,$]=x.Modal.useModal(),W=async j=>{j?await P.confirm({title:"上线提示",content:"确定启用当前流程吗?"})&&M():T()},V=async()=>{var se;const j=d===We.ONLINE||d===We.ON_WARN,Y=()=>{var Q,le;if((Q=S==null?void 0:S.nav)!=null&&Q.onBack){S.nav.onBack();return}if((le=S==null?void 0:S.nav)!=null&&le.backTo){O.push(S.nav.backTo);return}s?O.go(-1):O.push("/link/ai-flow")};if(!j&&((se=S==null?void 0:S.nav)!=null&&se.confirmOnBackWhenOffline)&&i){await P.confirm({title:R("link.flow.operation_title"),content:S.nav.backConfirmMessage||"当前流程未保存,是否确认返回?"})&&Y();return}Y()},X=()=>{if(i)return f.jsx(x.Tooltip,{title:"暂未保存",children:f.jsx(x.Tag,{bordered:!1,color:"warning",children:"未保存"})});switch(r){case hn.SAVING:return f.jsx(x.Tooltip,{children:f.jsx("div",{style:{display:"flex",alignItems:"center"},children:f.jsx(Z.SyncOutlined,{spin:!0,style:{marginRight:8,color:"#1890ff"}})})});case hn.SAVED:return f.jsx(x.Tooltip,{title:`已自动保存 (${o})`,children:f.jsx("div",{style:{display:"flex",alignItems:"center"},children:f.jsxs(x.Tag,{bordered:!1,color:"green",children:["已保存"," ",f.jsx("span",{style:{fontSize:10,marginLeft:4,color:"#999"},children:o})]})})});case hn.ERROR:return f.jsx(x.Tooltip,{title:"自动保存失败",children:f.jsx(x.Badge,{status:"error",text:f.jsx("span",{children:"保存失败"})})});default:return null}},G=()=>{var Y,se,Q,le;const j=[];return((Y=S==null?void 0:S.nav)==null?void 0:Y.showBack)!==!1&&j.push(f.jsx(x.Button,{type:"text",icon:f.jsx(Z.ArrowLeftOutlined,{className:"workflow-back-icon"}),onClick:V,children:R("app.common.word.back")},"back"),f.jsx(x.Divider,{type:"vertical"},"divider-back")),s||(h?j.push(f.jsx(x.Input,{ref:A,value:m,onChange:L=>w(L.target.value),onPressEnter:F,onBlur:F,onCompositionStart:()=>k(!0),onCompositionEnd:()=>k(!1),maxLength:30,className:"workflow-name-input",placeholder:"请输入工作流名称"},"name-input")):j.push(f.jsx("button",{className:"workflow-name",type:"button",onClick:n?void 0:()=>{var L;!e&&((L=S==null?void 0:S.flowName)==null?void 0:L.editable)!==!1&&p(!0)},children:u?f.jsxs(f.Fragment,{children:[f.jsx(qU,{level:4,className:"workflow-name-text",children:u}),!e&&!n&&((se=S==null?void 0:S.flowName)==null?void 0:se.editable)&&f.jsx(Z.FormOutlined,{className:"edit-icon"})]}):f.jsx(x.Skeleton.Input,{active:!0,size:"small"})},"name-display")),j.push(f.jsx(x.Divider,{type:"vertical"},"divider-name"))),n?j.push(f.jsx(ig,{type:"secondary",children:"预览模式"},"preview-text")):j.push(f.jsxs(x.Space,{size:8,children:[D.toolbar.enableOnlineButton&&f.jsxs(b.Fragment,{children:[f.jsx(ig,{children:(S==null?void 0:S.enableFlowText)||"启用流程"}),f.jsx(x.Switch,{disabled:!B,onChange:W,loading:v,checked:d===We.ONLINE||d===We.ON_WARN})]}),f.jsx(x.Divider,{type:"vertical"}),((Q=S==null?void 0:S.flowStatusTag)==null?void 0:Q.enabled)!==!1&&f.jsx("span",{style:(le=S==null?void 0:S.flowStatusTag)==null?void 0:le.style,children:f.jsx(GU,{opStatus:d})})]},"online-area")),j.push(f.jsx(x.Divider,{type:"vertical"},"divider-status")),!c&&!n&&j.push(f.jsx(ig,{type:"secondary",children:"当前流为只读模式,如需编辑,请下线流程"},"readonly-hint")),j};return f.jsxs("div",{className:"workflow-canvas-header",children:[$,f.jsx("div",{className:"workflow-heder-left-area",children:G()}),f.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[c&&!n&&X(),(S==null?void 0:S.helpDocUrl)&&f.jsx(x.Button,{icon:f.jsx(Z.QuestionCircleOutlined,{}),type:"link",onClick:()=>window.open(S.helpDocUrl,"_blank"),children:S.helpDocText||"帮助文档"}),f.jsxs(x.Space,{style:{marginLeft:16},children:[(H=S==null?void 0:S.buttons)==null?void 0:H.map(j=>f.jsx(x.Button,{style:j.style,icon:j.icon,type:j.type??"default",onClick:()=>{var Y;a&&((Y=j.onClick)==null||Y.call(j,a))},children:j.label},j.id)),c&&!n&&f.jsx(x.Tooltip,{title:"保存",children:f.jsx(x.Button,{onClick:N,type:"primary",children:"保存"})})]})]})]})},YU=({onOpenNodeSelector:t,onAddNoteNode:e,onTidyCanvas:n,panelStyle:r={},buttonStyle:o={},dangerButtonStyle:i={},showTidyButton:s=!0,buttons:a})=>{const l=[{key:"add-node",title:"打开节点选择面板",icon:f.jsx(Z.PlusOutlined,{}),onClick:t,visible:!0,danger:!1},{key:"add-note",title:"添加便签",icon:f.jsx(Z.BookOutlined,{}),onClick:e,visible:!0,danger:!1}],c=a||l,u={backgroundColor:"transparent",boxShadow:"none",marginTop:30,marginRight:20,...r},d={width:32,height:32,background:"#FFF",...o},h={...d,...i};return f.jsx(ae.Panel,{position:"top-right",style:u,children:f.jsx(x.Space,{direction:"vertical",children:c.map(p=>p.visible===!1?null:f.jsx(x.Tooltip,{placement:"left",title:p.title,children:f.jsx(x.Button,{onClick:p.onClick,type:"primary",style:p.danger?h:d,danger:p.danger,ghost:!0,icon:p.icon})},p.key))})})},XU=b.memo(({loading:t})=>t?f.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.7)",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1e3,backdropFilter:"blur(2px)"},children:f.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:12},children:[f.jsx(x.Spin,{size:"large"}),f.jsx("span",{style:{color:"#1890ff",fontSize:16},children:"正在加载工作流..."})]})}):null),JU=b.memo(()=>f.jsx("svg",{style:{position:"absolute",width:0,height:0},children:f.jsx("defs",{children:f.jsx("marker",{id:"workflow-arrow",viewBox:"-10 -10 20 20",refX:"3",refY:"0",markerWidth:"12.5",markerHeight:"12.5",markerUnits:"strokeWidth",orient:"auto-start-reverse",children:f.jsx("polyline",{strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4",strokeWidth:"3",stroke:"context-stroke",fill:"context-stroke"})})})})),RU={width:"100%",height:"100%",position:"absolute",zIndex:10,pointerEvents:"none"},QU=t=>({width:t.width,height:t.height,transform:t.transform});function ZU({horizontal:t,vertical:e}){const{width:n,height:r,transform:o}=ae.useStore(QU),i=b.useRef(null);return b.useEffect(()=>{const s=i.current,a=s==null?void 0:s.getContext("2d");if(!a||!s)return;const l=window.devicePixelRatio;s.width=n*l,s.height=r*l,a.scale(l,l),a.clearRect(0,0,n,r),a.strokeStyle="#0041d0",typeof e=="number"&&(a.moveTo(e*o[2]+o[0],0),a.lineTo(e*o[2]+o[0],r),a.stroke()),typeof t=="number"&&(a.moveTo(0,t*o[2]+o[1]),a.lineTo(n,t*o[2]+o[1]),a.stroke())},[n,r,o,t,e]),f.jsx("canvas",{ref:i,className:"react-flow__canvas",style:RU})}const eq=b.memo(ZU);function tq(t){const{workflowId:e,strategy:n,setNodes:r,setEdges:o,fitView:i,setLoading:s,setUnSave:a,dispatch:l,setFlowOpStatusAction:c,refreshWorkFlowNum:u}=t;b.useEffect(()=>{if(!e)return;let d=!1;return s(!0),n.loadFlow(e).then(h=>{if(d)return;l(gi(h.name)),l(mA(h.executionControl??null)),h.opStatus&&c(h.opStatus);const{nodes:p,edges:m}=h;p.length>0?(n.requiresTriggerNode?p.some(v=>v.type===ee.TRIGGER)?r(p):(p.unshift(rg),r([rg,...p])):r(p),n.requiresTriggerNode&&i({minZoom:.3,maxZoom:1})):r([rg]),o(m.length>0?m:[])}).catch(h=>{d||(console.error("[WorkflowCanvas] 加载工作流失败:",h),r([]),o([]))}).finally(()=>{d||(s(!1),setTimeout(()=>{a(!1)},500))}),()=>{d=!0}},[e,n,l,u,i])}const wi="[workflow:schema-render]";async function nq(t,e){var n,r,o,i,s,a,l,c;try{console.info(`${wi} resolve ports from schema`,{nodeKey:t,nodeVersion:e});const u=await Zu(t,e);if(!u)return console.warn(`${wi} cannot resolve ports without schema`,{nodeKey:t,nodeVersion:e}),{firstInputPort:null,firstOutputPort:null,loopPort:null,donePort:null};const d=((r=(n=u.inputs)==null?void 0:n[0])==null?void 0:r.name)||null,h=((i=(o=u.outputs)==null?void 0:o[0])==null?void 0:i.name)||null,p=((a=(s=u.outputs)==null?void 0:s.find(w=>w.name==="loop"))==null?void 0:a.name)||null,m=((c=(l=u.outputs)==null?void 0:l.find(w=>w.name==="done"))==null?void 0:c.name)||null;return console.info(`${wi} resolved ports from schema`,{nodeKey:t,nodeVersion:e,firstInputPort:d,firstOutputPort:h,loopPort:p,donePort:m}),{firstInputPort:d,firstOutputPort:h,loopPort:p,donePort:m}}catch(u){return console.error(`${wi} resolve ports from schema failed`,{nodeKey:t,nodeVersion:e,err:u}),{firstInputPort:null,firstOutputPort:null,loopPort:null,donePort:null}}}function rq(t){const{workflowId:e,strategy:n,store:r,addNodes:o,addEdges:i,removeEdges:s,handleEdgeAddNode:a,setNodeConfigVisible:l,setNodeFitHumanView:c,saveFlow:u}=t;return async(d,h)=>{var B;if(!e)return;let p=null;const{nodes:m}=r.getState(),w=h.nodeKey||h.action_key||h.id,v=h.nodeVersion??h.action_ver;if(console.info(`${wi} add next node`,{workflowId:e,nodeType:h.type,actionId:h.id,nodeSchemaKey:w,nodeSchemaVersion:v,trigger:!!d.trigger,insertOnEdge:!!d.edge}),d.trigger){const{nodeId:N,nodeData:F}=await n.createNode({workflowId:e,nodeType:ee.TRIGGER,actionId:h.id,configSchema:h.config_schema||{},position:{x:100,y:250},isTrigger:!0,icon:h.icon,name:h.name||h.action_name,connectorName:h.connector_name,nodeVersion:h.nodeVersion,existingNodes:m});p=N;const M=Bn.createNode(ee.TRIGGER,N,og({...h,...F}),{x:100,y:250});o([M]),c(N),l(N),window.__AI_FLOW_IN_QUEUE_NODE_ID=p,await u();return}const{nodeId:y,nodeData:g}=await n.createNode({workflowId:e,nodeType:h.action_type,actionId:h.id,configSchema:h.config_schema||{},position:d.position,icon:h.icon,name:h.name||h.action_name,connectorName:h.connector_name,nodeVersion:h.nodeVersion,existingNodes:m});p=y;const k=Bn.createNode(h.type,y,og({...h,...g}),d.position);if(o([k]),c(y),h.type===ee.STICKY){window.__AI_FLOW_IN_QUEUE_NODE_ID=p,await u();return}const{firstInputPort:A,firstOutputPort:C,loopPort:E,donePort:D}=await nq(w,v);if(!A||!C){console.warn(`${wi} skip edge creation because schema ports are incomplete`,{nodeId:y,actionId:h.id,nodeSchemaKey:w,nodeSchemaVersion:v,firstInputPort:A,firstOutputPort:C}),window.__AI_FLOW_IN_QUEUE_NODE_ID=p,await u();return}const S=h.type===ee.LOOP||h.type===ee.SELF_LOOP,_=E??"loop",O=D??"done";if(S&&(!E||!D)&&console.warn(`${wi} loop schema ports missing, fallback to conventional handles`,{nodeId:y,nodeSchemaKey:w,nodeSchemaVersion:v,loopPort:E,donePort:D}),d.edge){const N=Bt.createEdge(xt.MAIN,`${d.edge.source}-${y}-${Date.now()}`,d.edge.source,y,{sourceHandle:d.edge.sourceHandleId,targetHandle:A,onAddNode:a,data:{undeletable:!1}}),F=Bt.createEdge(xt.MAIN,`${y}-${d.edge.target}-${Date.now()}`,y,d.edge.target,{sourceHandle:C,targetHandle:d.edge.targetHandle||d.edge.targetHandleId,onAddNode:a,data:{}});if(S){const M=Bt.createEdge(xt.MAIN,`loop-self-edge-${y}`,y,y,{sourceHandle:_,targetHandle:A}),T=Bt.createEdge(xt.MAIN,`loop-edge-target-${y}`,y,d.edge.target,{sourceHandle:O,targetHandle:d.edge.targetHandle||d.edge.targetHandleId,onAddNode:a,data:{undeletable:!0}});i([M,N,T])}else i([N,F]);s([d.edge.id]),window.__AI_FLOW_IN_QUEUE_NODE_ID=p,await u();return}if(S){const N=Bt.createEdge(xt.MAIN,`loop-self-edge-${y}`,y,y,{sourceHandle:_,targetHandle:A});i([N])}if(d.sourceNodeId&&d.sourceHandle){const N=Bt.createEdge(xt.MAIN,`${d.sourceNodeId}-${y}-${Date.now()}`,d.sourceNodeId,y,{sourceHandle:d.sourceHandle,targetHandle:A,onAddNode:a});if(i([N]),d.sourceNodeId===d.targetNodeId&&d.targetNodeId){const F=Bt.createEdge(xt.MAIN,`loop-back-${y}-${d.targetNodeId}`,y,d.targetNodeId,{sourceHandle:S?_:C,targetHandle:A,onAddNode:a,data:{undeletable:!1}});i([F]),(B=d.edge)!=null&&B.id&&s([d.edge.id])}}window.__AI_FLOW_IN_QUEUE_NODE_ID=p,await u()}}const oq="[workflow:schema-render]";function iq({workflowId:t,strategy:e,store:n,addNodes:r,addEdges:o,removeEdges:i,setNodeAddCallback:s,handleEdgeAddNode:a,setNodeConfigVisible:l,setNodeFitHumanView:c,saveFlow:u,engineMode:d}){const h=b.useCallback(async(w,v)=>{if(!t)return;let y=null;const{nodes:g}=n.getState(),k=e.convertNodeData??wA,A=v.action_key||v.nodeKey,C=v.action_ver??v.nodeVersion,E=!!A;if(console.info(`${oq} add classic node`,{workflowId:t,nodeType:v.type,actionId:v.id,actionKey:A,actionVer:C,isNextCompatibleNode:E,trigger:!!w.trigger,insertOnEdge:!!w.edge}),w.trigger){const{nodeId:D,nodeData:S}=await e.createNode({workflowId:t,nodeType:ee.TRIGGER,actionId:v.id,actionKey:A,actionVer:C,configSchema:v.config_schema||{},position:{x:100,y:250},isTrigger:!0,icon:v.icon,name:v.name||v.action_name,connectorName:v.connector_name,nodeVersion:v.nodeVersion,existingNodes:g});y=D;const _=Bn.createNode(ee.TRIGGER,D,k({...v,...S}),{x:100,y:250});r([_]),c(D),l(D)}else{const{nodeId:D,nodeData:S}=await e.createNode({workflowId:t,nodeType:v.action_type,actionId:v.id,actionKey:A,actionVer:C,configSchema:v.config_schema||{},position:w.position,icon:v.icon,name:v.name||v.action_name,connectorName:v.connector_name,nodeVersion:v.nodeVersion,existingNodes:g});y=D;const _=Bn.createNode(v.type,D,k({...v,...S}),w.position);if(r([_]),c(D),v.type===ee.STICKY)return;if(w.edge){const O=Bt.createEdge(xt.MAIN,`${w.edge.source}-${D}-${Date.now()}`,w.edge.source,D,{sourceHandle:w.edge.sourceHandleId,targetHandle:Ie.INPUT,onAddNode:a,data:{undeletable:!1}}),B=Bt.createEdge(xt.MAIN,`${D}-${w.edge.target}-${Date.now()}`,D,w.edge.target,{sourceHandle:Ie.OUTPUT,targetHandle:w.edge.targetHandle||w.edge.targetHandleId,onAddNode:a,data:{}});if(v.type===ee.LOOP||v.type===ee.SELF_LOOP){const N=Bt.createEdge(xt.MAIN,`loop-self-edge-${D}`,D,D,{sourceHandle:"loop",targetHandle:Ie.INPUT}),F=Bt.createEdge(xt.MAIN,`loop-edge-target-${D}`,D,w.edge.target,{sourceHandle:"done",targetHandle:w.edge.targetHandle||w.edge.targetHandleId,onAddNode:a,data:{undeletable:!0}});o([N,O,F])}else o([O,B]);i([w.edge.id]),window.__AI_FLOW_IN_QUEUE_NODE_ID=y,await u();return}if(v.type===ee.LOOP||v.type===ee.SELF_LOOP){const O=Bt.createEdge(xt.MAIN,`loop-self-edge-${D}`,D,D,{sourceHandle:"loop",targetHandle:Ie.INPUT});o([O])}if(w.sourceNodeId&&w.sourceHandle){const O=Bt.createEdge(xt.MAIN,`${w.sourceNodeId}-${D}-${Date.now()}`,w.sourceNodeId,D,{sourceHandle:w.sourceHandle,targetHandle:Ie.INPUT,onAddNode:a});if(o([O]),w.sourceNodeId===w.targetNodeId&&w.targetNodeId){const B=Bt.createEdge(xt.MAIN,`loop-back-${D}-${w.targetNodeId}`,D,w.targetNodeId,{sourceHandle:v.type===ee.LOOP||v.type===ee.SELF_LOOP?"loop":Ie.OUTPUT,targetHandle:Ie.INPUT,onAddNode:a,data:{undeletable:!1}});o([B]),i([w.edge.id])}}else{window.__AI_FLOW_IN_QUEUE_NODE_ID=y,await u();return}}window.__AI_FLOW_IN_QUEUE_NODE_ID=y,await u()},[o,r,a,i,u,l,c,n,e,t]),p=b.useMemo(()=>rq({workflowId:t,strategy:e,store:n,addNodes:r,addEdges:o,removeEdges:i,handleEdgeAddNode:a,setNodeConfigVisible:l,setNodeFitHumanView:c,saveFlow:u}),[t,e,n,r,o,i,a,l,c,u]),m=d===or.NEXT?p:h;b.useEffect(()=>(s(m),()=>{s(()=>{})}),[m,s])}function sq({dispatch:t,reactFlow:e,setEdges:n,setNodes:r,store:o,setNodeConfigVisible:i,saveFlowRef:s}){const a=b.useRef(new Map);return{canvasApi:b.useMemo(()=>({init(){},destroy(){t(hd()),n([]),r([]),a.current.clear()},refresh(){t(pA())},setFlowOpStatus(c){t(xs(c))},getData(){const{nodes:c,edges:u}=o.getState();return{nodes:c.map(d=>{var h;return{id:d.id,type:d.type||"",position:d.position,data:d.data,disabled:((h=d.data)==null?void 0:h.closed)==="1"}}),edges:u.map(d=>({id:d.id,source:d.source,target:d.target,data:d.data}))}},setData(c){const u=c.nodes.map(h=>({id:h.id,type:h.type,position:h.position,data:h.data})),d=c.edges.map(h=>({id:h.id,source:h.source,target:h.target,data:h.data}));r(u),n(d)},exportJSON(){return JSON.stringify(this.getData())},importJSON(c){try{const u=typeof c=="string"?JSON.parse(c):c;this.setData(u)}catch(u){console.error("导入 JSON 失败",u)}},zoomIn(){e.zoomIn()},zoomOut(){e.zoomOut()},zoomTo(c){e.zoomTo(c)},fitView(){e.fitView()},center(){e.fitView({padding:.2})},addNode(c){const u=c.id||`${Date.now()}`,d={id:u,type:c.type,position:c.position,data:c.data};return r(h=>[...h,d]),u},updateNode(c,u){r(d=>d.map(h=>h.id===c?{...h,...u,position:u.position||h.position,data:u.data?{...h.data,...u.data}:h.data}:h))},deleteNode(c){r(u=>u.filter(d=>d.id!==c)),n(u=>u.filter(d=>d.source!==c&&d.target!==c))},getNode(c){var h;const{nodes:u}=o.getState(),d=u.find(p=>p.id===c);return d?{id:d.id,type:d.type||"",position:d.position,data:d.data,disabled:((h=d.data)==null?void 0:h.closed)==="1"}:null},selectNode(){},clearSelection(){e.setNodes(c=>c.map(u=>({...u,selected:!1})))},moveNode(c,u){this.updateNode(c,{position:u})},enableNode(c){this.updateNode(c,{disabled:!1})},disableNode(c){this.updateNode(c,{disabled:!0})},addEdge(c){const u=c.id||`${c.source}-${c.target}-${Date.now()}`,d={id:u,source:c.source,target:c.target,data:c.data};return n(h=>[...h,d]),u},deleteEdge(c){n(u=>u.filter(d=>d.id!==c))},deleteEdgesBetween(c,u){n(d=>d.filter(h=>h.source!==c||h.target!==u))},openNodePanel(c){i(c)},closeNodePanel(){i(null)},isPanelOpen(){const{currentNodeConfigVisibleId:c}=o.getState();return!!c},async runNodeTest(){return Promise.resolve(null)},async saveFlow(){return s.current()},on(c,u){return a.current.has(c)||a.current.set(c,new Set),a.current.get(c).add(u),()=>{this.off(c,u)}},off(c,u){const d=a.current.get(c);d&&(u?d.delete(u):d.clear(),d.size===0&&a.current.delete(c))},emit(c,u){const d=a.current.get(c);d&&d.forEach(h=>{try{h(u)}catch(p){console.error(`事件 "${c}" 的处理器执行出错:`,p)}})},once(c,u){const d=h=>{u(h),this.off(c,d)};this.on(c,d)}}),[t,e,n,r,o,i]),eventListenersRef:a}}function aq(t,e,n=5){var l,c,u,d;const r={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},o=e.find(h=>h.id===t.id);if(!o||!t.position)return r;const i={left:t.position.x,right:t.position.x+(((l=o.measured)==null?void 0:l.width)??0),top:t.position.y,bottom:t.position.y+(((c=o.measured)==null?void 0:c.height)??0),width:((u=o.measured)==null?void 0:u.width)??0,height:((d=o.measured)==null?void 0:d.height)??0};let s=n,a=n;return e.filter(h=>h.id!==o.id).reduce((h,p)=>{var D,S,_,O;const m={left:p.position.x,right:p.position.x+(((D=p.measured)==null?void 0:D.width)??0),top:p.position.y,bottom:p.position.y+(((S=p.measured)==null?void 0:S.height)??0),width:((_=p.measured)==null?void 0:_.width)??0,height:((O=p.measured)==null?void 0:O.height)??0},w=Math.abs(i.left-m.left);w<a&&(h.snapPosition.x=m.left,h.vertical=m.left,a=w);const v=Math.abs(i.right-m.right);v<a&&(h.snapPosition.x=m.right-i.width,h.vertical=m.right,a=v);const y=Math.abs(i.left-m.right);y<a&&(h.snapPosition.x=m.right,h.vertical=m.right,a=y);const g=Math.abs(i.right-m.left);g<a&&(h.snapPosition.x=m.left-i.width,h.vertical=m.left,a=g);const k=Math.abs(i.top-m.top);k<s&&(h.snapPosition.y=m.top,h.horizontal=m.top,s=k);const A=Math.abs(i.bottom-m.top);A<s&&(h.snapPosition.y=m.top-i.height,h.horizontal=m.top,s=A);const C=Math.abs(i.bottom-m.bottom);C<s&&(h.snapPosition.y=m.bottom-i.height,h.horizontal=m.bottom,s=C);const E=Math.abs(i.top-m.bottom);return E<s&&(h.snapPosition.y=m.bottom,h.horizontal=m.bottom,s=E),h},r)}const lq=({enabled:t=!0,message:e="您有未保存的更改,确定要离开吗?"})=>{b.useEffect(()=>{if(!t)return;let n;return(()=>{n=_i.block(o=>{t?window.confirm(e)&&(n==null||n(),o.retry()):(n==null||n(),o.retry())})})(),()=>{n==null||n()}},[t,e]),b.useEffect(()=>{if(!t)return;const n=r=>{if(t)return r.preventDefault(),r.returnValue=e,e};return window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n)},[t,e])};var sg,vA;function ag(){if(vA)return sg;vA=1;var t="\0",e="\0",n="";class r{constructor(u){it(this,"_isDirected",!0);it(this,"_isMultigraph",!1);it(this,"_isCompound",!1);it(this,"_label");it(this,"_defaultNodeLabelFn",()=>{});it(this,"_defaultEdgeLabelFn",()=>{});it(this,"_nodes",{});it(this,"_in",{});it(this,"_preds",{});it(this,"_out",{});it(this,"_sucs",{});it(this,"_edgeObjs",{});it(this,"_edgeLabels",{});it(this,"_nodeCount",0);it(this,"_edgeCount",0);it(this,"_parent");it(this,"_children");u&&(this._isDirected=Object.hasOwn(u,"directed")?u.directed:!0,this._isMultigraph=Object.hasOwn(u,"multigraph")?u.multigraph:!1,this._isCompound=Object.hasOwn(u,"compound")?u.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[e]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(u){return this._label=u,this}graph(){return this._label}setDefaultNodeLabel(u){return this._defaultNodeLabelFn=u,typeof u!="function"&&(this._defaultNodeLabelFn=()=>u),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var u=this;return this.nodes().filter(d=>Object.keys(u._in[d]).length===0)}sinks(){var u=this;return this.nodes().filter(d=>Object.keys(u._out[d]).length===0)}setNodes(u,d){var h=arguments,p=this;return u.forEach(function(m){h.length>1?p.setNode(m,d):p.setNode(m)}),this}setNode(u,d){return Object.hasOwn(this._nodes,u)?(arguments.length>1&&(this._nodes[u]=d),this):(this._nodes[u]=arguments.length>1?d:this._defaultNodeLabelFn(u),this._isCompound&&(this._parent[u]=e,this._children[u]={},this._children[e][u]=!0),this._in[u]={},this._preds[u]={},this._out[u]={},this._sucs[u]={},++this._nodeCount,this)}node(u){return this._nodes[u]}hasNode(u){return Object.hasOwn(this._nodes,u)}removeNode(u){var d=this;if(Object.hasOwn(this._nodes,u)){var h=p=>d.removeEdge(d._edgeObjs[p]);delete this._nodes[u],this._isCompound&&(this._removeFromParentsChildList(u),delete this._parent[u],this.children(u).forEach(function(p){d.setParent(p)}),delete this._children[u]),Object.keys(this._in[u]).forEach(h),delete this._in[u],delete this._preds[u],Object.keys(this._out[u]).forEach(h),delete this._out[u],delete this._sucs[u],--this._nodeCount}return this}setParent(u,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(d===void 0)d=e;else{d+="";for(var h=d;h!==void 0;h=this.parent(h))if(h===u)throw new Error("Setting "+d+" as parent of "+u+" would create a cycle");this.setNode(d)}return this.setNode(u),this._removeFromParentsChildList(u),this._parent[u]=d,this._children[d][u]=!0,this}_removeFromParentsChildList(u){delete this._children[this._parent[u]][u]}parent(u){if(this._isCompound){var d=this._parent[u];if(d!==e)return d}}children(u=e){if(this._isCompound){var d=this._children[u];if(d)return Object.keys(d)}else{if(u===e)return this.nodes();if(this.hasNode(u))return[]}}predecessors(u){var d=this._preds[u];if(d)return Object.keys(d)}successors(u){var d=this._sucs[u];if(d)return Object.keys(d)}neighbors(u){var d=this.predecessors(u);if(d){const p=new Set(d);for(var h of this.successors(u))p.add(h);return Array.from(p.values())}}isLeaf(u){var d;return this.isDirected()?d=this.successors(u):d=this.neighbors(u),d.length===0}filterNodes(u){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var h=this;Object.entries(this._nodes).forEach(function([w,v]){u(w)&&d.setNode(w,v)}),Object.values(this._edgeObjs).forEach(function(w){d.hasNode(w.v)&&d.hasNode(w.w)&&d.setEdge(w,h.edge(w))});var p={};function m(w){var v=h.parent(w);return v===void 0||d.hasNode(v)?(p[w]=v,v):v in p?p[v]:m(v)}return this._isCompound&&d.nodes().forEach(w=>d.setParent(w,m(w))),d}setDefaultEdgeLabel(u){return this._defaultEdgeLabelFn=u,typeof u!="function"&&(this._defaultEdgeLabelFn=()=>u),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(u,d){var h=this,p=arguments;return u.reduce(function(m,w){return p.length>1?h.setEdge(m,w,d):h.setEdge(m,w),w}),this}setEdge(){var u,d,h,p,m=!1,w=arguments[0];typeof w=="object"&&w!==null&&"v"in w?(u=w.v,d=w.w,h=w.name,arguments.length===2&&(p=arguments[1],m=!0)):(u=w,d=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),u=""+u,d=""+d,h!==void 0&&(h=""+h);var v=s(this._isDirected,u,d,h);if(Object.hasOwn(this._edgeLabels,v))return m&&(this._edgeLabels[v]=p),this;if(h!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(u),this.setNode(d),this._edgeLabels[v]=m?p:this._defaultEdgeLabelFn(u,d,h);var y=a(this._isDirected,u,d,h);return u=y.v,d=y.w,Object.freeze(y),this._edgeObjs[v]=y,o(this._preds[d],u),o(this._sucs[u],d),this._in[d][v]=y,this._out[u][v]=y,this._edgeCount++,this}edge(u,d,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,h);return this._edgeLabels[p]}edgeAsObj(){const u=this.edge(...arguments);return typeof u!="object"?{label:u}:u}hasEdge(u,d,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,h);return Object.hasOwn(this._edgeLabels,p)}removeEdge(u,d,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,h),m=this._edgeObjs[p];return m&&(u=m.v,d=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],i(this._preds[d],u),i(this._sucs[u],d),delete this._in[d][p],delete this._out[u][p],this._edgeCount--),this}inEdges(u,d){var h=this._in[u];if(h){var p=Object.values(h);return d?p.filter(m=>m.v===d):p}}outEdges(u,d){var h=this._out[u];if(h){var p=Object.values(h);return d?p.filter(m=>m.w===d):p}}nodeEdges(u,d){var h=this.inEdges(u,d);if(h)return h.concat(this.outEdges(u,d))}}function o(c,u){c[u]?c[u]++:c[u]=1}function i(c,u){--c[u]||delete c[u]}function s(c,u,d,h){var p=""+u,m=""+d;if(!c&&p>m){var w=p;p=m,m=w}return p+n+m+n+(h===void 0?t:h)}function a(c,u,d,h){var p=""+u,m=""+d;if(!c&&p>m){var w=p;p=m,m=w}var v={v:p,w:m};return h&&(v.name=h),v}function l(c,u){return s(c,u.v,u.w,u.name)}return sg=r,sg}var lg,yA;function cq(){return yA||(yA=1,lg="2.2.4"),lg}var cg,bA;function uq(){return bA||(bA=1,cg={Graph:ag(),version:cq()}),cg}var ug,CA;function dq(){if(CA)return ug;CA=1;var t=ag();ug={write:e,read:o};function e(i){var s={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:n(i),edges:r(i)};return i.graph()!==void 0&&(s.value=structuredClone(i.graph())),s}function n(i){return i.nodes().map(function(s){var a=i.node(s),l=i.parent(s),c={v:s};return a!==void 0&&(c.value=a),l!==void 0&&(c.parent=l),c})}function r(i){return i.edges().map(function(s){var a=i.edge(s),l={v:s.v,w:s.w};return s.name!==void 0&&(l.name=s.name),a!==void 0&&(l.value=a),l})}function o(i){var s=new t(i.options).setGraph(i.value);return i.nodes.forEach(function(a){s.setNode(a.v,a.value),a.parent&&s.setParent(a.v,a.parent)}),i.edges.forEach(function(a){s.setEdge({v:a.v,w:a.w,name:a.name},a.value)}),s}return ug}var dg,kA;function fq(){if(kA)return dg;kA=1,dg=t;function t(e){var n={},r=[],o;function i(s){Object.hasOwn(n,s)||(n[s]=!0,o.push(s),e.successors(s).forEach(i),e.predecessors(s).forEach(i))}return e.nodes().forEach(function(s){o=[],i(s),o.length&&r.push(o)}),r}return dg}var fg,xA;function SA(){if(xA)return fg;xA=1;class t{constructor(){it(this,"_arr",[]);it(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,r){var o=this._keyIndices;if(n=String(n),!Object.hasOwn(o,n)){var i=this._arr,s=i.length;return o[n]=s,i.push({key:n,priority:r}),this._decrease(s),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,r){var o=this._keyIndices[n];if(r>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[o].priority+" New: "+r);this._arr[o].priority=r,this._decrease(o)}_heapify(n){var r=this._arr,o=2*n,i=o+1,s=n;o<r.length&&(s=r[o].priority<r[s].priority?o:s,i<r.length&&(s=r[i].priority<r[s].priority?i:s),s!==n&&(this._swap(n,s),this._heapify(s)))}_decrease(n){for(var r=this._arr,o=r[n].priority,i;n!==0&&(i=n>>1,!(r[i].priority<o));)this._swap(n,i),n=i}_swap(n,r){var o=this._arr,i=this._keyIndices,s=o[n],a=o[r];o[n]=a,o[r]=s,i[a.key]=n,i[s.key]=r}}return fg=t,fg}var hg,EA;function DA(){if(EA)return hg;EA=1;var t=SA();hg=n;var e=()=>1;function n(o,i,s,a){return r(o,String(i),s||e,a||function(l){return o.outEdges(l)})}function r(o,i,s,a){var l={},c=new t,u,d,h=function(p){var m=p.v!==u?p.v:p.w,w=l[m],v=s(p),y=d.distance+v;if(v<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+p+" Weight: "+v);y<w.distance&&(w.distance=y,w.predecessor=u,c.decrease(m,y))};for(o.nodes().forEach(function(p){var m=p===i?0:Number.POSITIVE_INFINITY;l[p]={distance:m},c.add(p,m)});c.size()>0&&(u=c.removeMin(),d=l[u],d.distance!==Number.POSITIVE_INFINITY);)a(u).forEach(h);return l}return hg}var pg,AA;function hq(){if(AA)return pg;AA=1;var t=DA();pg=e;function e(n,r,o){return n.nodes().reduce(function(i,s){return i[s]=t(n,s,r,o),i},{})}return pg}var mg,OA;function TA(){if(OA)return mg;OA=1,mg=t;function t(e){var n=0,r=[],o={},i=[];function s(a){var l=o[a]={onStack:!0,lowlink:n,index:n++};if(r.push(a),e.successors(a).forEach(function(d){Object.hasOwn(o,d)?o[d].onStack&&(l.lowlink=Math.min(l.lowlink,o[d].index)):(s(d),l.lowlink=Math.min(l.lowlink,o[d].lowlink))}),l.lowlink===l.index){var c=[],u;do u=r.pop(),o[u].onStack=!1,c.push(u);while(a!==u);i.push(c)}}return e.nodes().forEach(function(a){Object.hasOwn(o,a)||s(a)}),i}return mg}var gg,_A;function pq(){if(_A)return gg;_A=1;var t=TA();gg=e;function e(n){return t(n).filter(function(r){return r.length>1||r.length===1&&n.hasEdge(r[0],r[0])})}return gg}var wg,NA;function mq(){if(NA)return wg;NA=1,wg=e;var t=()=>1;function e(r,o,i){return n(r,o||t,i||function(s){return r.outEdges(s)})}function n(r,o,i){var s={},a=r.nodes();return a.forEach(function(l){s[l]={},s[l][l]={distance:0},a.forEach(function(c){l!==c&&(s[l][c]={distance:Number.POSITIVE_INFINITY})}),i(l).forEach(function(c){var u=c.v===l?c.w:c.v,d=o(c);s[l][u]={distance:d,predecessor:l}})}),a.forEach(function(l){var c=s[l];a.forEach(function(u){var d=s[u];a.forEach(function(h){var p=d[l],m=c[h],w=d[h],v=p.distance+m.distance;v<w.distance&&(w.distance=v,w.predecessor=m.predecessor)})})}),s}return wg}var vg,BA;function FA(){if(BA)return vg;BA=1;function t(n){var r={},o={},i=[];function s(a){if(Object.hasOwn(o,a))throw new e;Object.hasOwn(r,a)||(o[a]=!0,r[a]=!0,n.predecessors(a).forEach(s),delete o[a],i.push(a))}if(n.sinks().forEach(s),Object.keys(r).length!==n.nodeCount())throw new e;return i}class e extends Error{constructor(){super(...arguments)}}return vg=t,t.CycleException=e,vg}var yg,IA;function gq(){if(IA)return yg;IA=1;var t=FA();yg=e;function e(n){try{t(n)}catch(r){if(r instanceof t.CycleException)return!1;throw r}return!0}return yg}var bg,MA;function PA(){if(MA)return bg;MA=1,bg=t;function t(o,i,s){Array.isArray(i)||(i=[i]);var a=o.isDirected()?d=>o.successors(d):d=>o.neighbors(d),l=s==="post"?e:n,c=[],u={};return i.forEach(d=>{if(!o.hasNode(d))throw new Error("Graph does not have node: "+d);l(d,a,u,c)}),c}function e(o,i,s,a){for(var l=[[o,!1]];l.length>0;){var c=l.pop();c[1]?a.push(c[0]):Object.hasOwn(s,c[0])||(s[c[0]]=!0,l.push([c[0],!0]),r(i(c[0]),u=>l.push([u,!1])))}}function n(o,i,s,a){for(var l=[o];l.length>0;){var c=l.pop();Object.hasOwn(s,c)||(s[c]=!0,a.push(c),r(i(c),u=>l.push(u)))}}function r(o,i){for(var s=o.length;s--;)i(o[s],s,o);return o}return bg}var Cg,LA;function wq(){if(LA)return Cg;LA=1;var t=PA();Cg=e;function e(n,r){return t(n,r,"post")}return Cg}var kg,$A;function vq(){if($A)return kg;$A=1;var t=PA();kg=e;function e(n,r){return t(n,r,"pre")}return kg}var xg,HA;function yq(){if(HA)return xg;HA=1;var t=ag(),e=SA();xg=n;function n(r,o){var i=new t,s={},a=new e,l;function c(d){var h=d.v===l?d.w:d.v,p=a.priority(h);if(p!==void 0){var m=o(d);m<p&&(s[h]=l,a.decrease(h,m))}}if(r.nodeCount()===0)return i;r.nodes().forEach(function(d){a.add(d,Number.POSITIVE_INFINITY),i.setNode(d)}),a.decrease(r.nodes()[0],0);for(var u=!1;a.size()>0;){if(l=a.removeMin(),Object.hasOwn(s,l))i.setEdge(l,s[l]);else{if(u)throw new Error("Input graph is not connected: "+r);u=!0}r.nodeEdges(l).forEach(c)}return i}return xg}var Sg,zA;function bq(){return zA||(zA=1,Sg={components:fq(),dijkstra:DA(),dijkstraAll:hq(),findCycles:pq(),floydWarshall:mq(),isAcyclic:gq(),postorder:wq(),preorder:vq(),prim:yq(),tarjan:TA(),topsort:FA()}),Sg}var Eg,jA;function gr(){if(jA)return Eg;jA=1;var t=uq();return Eg={Graph:t.Graph,json:dq(),alg:bq(),version:t.version},Eg}var Dg,VA;function Cq(){if(VA)return Dg;VA=1;class t{constructor(){let o={};o._next=o._prev=o,this._sentinel=o}dequeue(){let o=this._sentinel,i=o._prev;if(i!==o)return e(i),i}enqueue(o){let i=this._sentinel;o._prev&&o._next&&e(o),o._next=i._next,i._next._prev=o,i._next=o,o._prev=i}toString(){let o=[],i=this._sentinel,s=i._prev;for(;s!==i;)o.push(JSON.stringify(s,n)),s=s._prev;return"["+o.join(", ")+"]"}}function e(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,o){if(r!=="_next"&&r!=="_prev")return o}return Dg=t,Dg}var Ag,WA;function kq(){if(WA)return Ag;WA=1;let t=gr().Graph,e=Cq();Ag=r;let n=()=>1;function r(c,u){if(c.nodeCount()<=1)return[];let d=s(c,u||n);return o(d.graph,d.buckets,d.zeroIdx).flatMap(p=>c.outEdges(p.v,p.w))}function o(c,u,d){let h=[],p=u[u.length-1],m=u[0],w;for(;c.nodeCount();){for(;w=m.dequeue();)i(c,u,d,w);for(;w=p.dequeue();)i(c,u,d,w);if(c.nodeCount()){for(let v=u.length-2;v>0;--v)if(w=u[v].dequeue(),w){h=h.concat(i(c,u,d,w,!0));break}}}return h}function i(c,u,d,h,p){let m=p?[]:void 0;return c.inEdges(h.v).forEach(w=>{let v=c.edge(w),y=c.node(w.v);p&&m.push({v:w.v,w:w.w}),y.out-=v,a(u,d,y)}),c.outEdges(h.v).forEach(w=>{let v=c.edge(w),y=w.w,g=c.node(y);g.in-=v,a(u,d,g)}),c.removeNode(h.v),m}function s(c,u){let d=new t,h=0,p=0;c.nodes().forEach(v=>{d.setNode(v,{v,in:0,out:0})}),c.edges().forEach(v=>{let y=d.edge(v.v,v.w)||0,g=u(v),k=y+g;d.setEdge(v.v,v.w,k),p=Math.max(p,d.node(v.v).out+=g),h=Math.max(h,d.node(v.w).in+=g)});let m=l(p+h+3).map(()=>new e),w=h+1;return d.nodes().forEach(v=>{a(m,w,d.node(v))}),{graph:d,buckets:m,zeroIdx:w}}function a(c,u,d){d.out?d.in?c[d.out-d.in+u].enqueue(d):c[c.length-1].enqueue(d):c[0].enqueue(d)}function l(c){const u=[];for(let d=0;d<c;d++)u.push(d);return u}return Ag}var Og,UA;function Mt(){if(UA)return Og;UA=1;let t=gr().Graph;Og={addBorderNode:u,addDummyNode:e,applyWithChunking:p,asNonCompoundGraph:r,buildLayerMatrix:a,intersectRect:s,mapValues:E,maxRank:m,normalizeRanks:l,notime:y,partition:w,pick:C,predecessorWeights:i,range:A,removeEmptyRanks:c,simplify:n,successorWeights:o,time:v,uniqueId:k,zipObject:D};function e(S,_,O,B){for(var N=B;S.hasNode(N);)N=k(B);return O.dummy=_,S.setNode(N,O),N}function n(S){let _=new t().setGraph(S.graph());return S.nodes().forEach(O=>_.setNode(O,S.node(O))),S.edges().forEach(O=>{let B=_.edge(O.v,O.w)||{weight:0,minlen:1},N=S.edge(O);_.setEdge(O.v,O.w,{weight:B.weight+N.weight,minlen:Math.max(B.minlen,N.minlen)})}),_}function r(S){let _=new t({multigraph:S.isMultigraph()}).setGraph(S.graph());return S.nodes().forEach(O=>{S.children(O).length||_.setNode(O,S.node(O))}),S.edges().forEach(O=>{_.setEdge(O,S.edge(O))}),_}function o(S){let _=S.nodes().map(O=>{let B={};return S.outEdges(O).forEach(N=>{B[N.w]=(B[N.w]||0)+S.edge(N).weight}),B});return D(S.nodes(),_)}function i(S){let _=S.nodes().map(O=>{let B={};return S.inEdges(O).forEach(N=>{B[N.v]=(B[N.v]||0)+S.edge(N).weight}),B});return D(S.nodes(),_)}function s(S,_){let O=S.x,B=S.y,N=_.x-O,F=_.y-B,M=S.width/2,T=S.height/2;if(!N&&!F)throw new Error("Not possible to find intersection inside of the rectangle");let P,$;return Math.abs(F)*M>Math.abs(N)*T?(F<0&&(T=-T),P=T*N/F,$=T):(N<0&&(M=-M),P=M,$=M*F/N),{x:O+P,y:B+$}}function a(S){let _=A(m(S)+1).map(()=>[]);return S.nodes().forEach(O=>{let B=S.node(O),N=B.rank;N!==void 0&&(_[N][B.order]=O)}),_}function l(S){let _=S.nodes().map(B=>{let N=S.node(B).rank;return N===void 0?Number.MAX_VALUE:N}),O=p(Math.min,_);S.nodes().forEach(B=>{let N=S.node(B);Object.hasOwn(N,"rank")&&(N.rank-=O)})}function c(S){let _=S.nodes().map(M=>S.node(M).rank),O=p(Math.min,_),B=[];S.nodes().forEach(M=>{let T=S.node(M).rank-O;B[T]||(B[T]=[]),B[T].push(M)});let N=0,F=S.graph().nodeRankFactor;Array.from(B).forEach((M,T)=>{M===void 0&&T%F!==0?--N:M!==void 0&&N&&M.forEach(P=>S.node(P).rank+=N)})}function u(S,_,O,B){let N={width:0,height:0};return arguments.length>=4&&(N.rank=O,N.order=B),e(S,"border",N,_)}function d(S,_=h){const O=[];for(let B=0;B<S.length;B+=_){const N=S.slice(B,B+_);O.push(N)}return O}const h=65535;function p(S,_){if(_.length>h){const O=d(_);return S.apply(null,O.map(B=>S.apply(null,B)))}else return S.apply(null,_)}function m(S){const O=S.nodes().map(B=>{let N=S.node(B).rank;return N===void 0?Number.MIN_VALUE:N});return p(Math.max,O)}function w(S,_){let O={lhs:[],rhs:[]};return S.forEach(B=>{_(B)?O.lhs.push(B):O.rhs.push(B)}),O}function v(S,_){let O=Date.now();try{return _()}finally{console.log(S+" time: "+(Date.now()-O)+"ms")}}function y(S,_){return _()}let g=0;function k(S){var _=++g;return S+(""+_)}function A(S,_,O=1){_==null&&(_=S,S=0);let B=F=>F<_;O<0&&(B=F=>_<F);const N=[];for(let F=S;B(F);F+=O)N.push(F);return N}function C(S,_){const O={};for(const B of _)S[B]!==void 0&&(O[B]=S[B]);return O}function E(S,_){let O=_;return typeof _=="string"&&(O=B=>B[_]),Object.entries(S).reduce((B,[N,F])=>(B[N]=O(F,N),B),{})}function D(S,_){return S.reduce((O,B,N)=>(O[B]=_[N],O),{})}return Og}var Tg,qA;function xq(){if(qA)return Tg;qA=1;let t=kq(),e=Mt().uniqueId;Tg={run:n,undo:o};function n(i){(i.graph().acyclicer==="greedy"?t(i,a(i)):r(i)).forEach(l=>{let c=i.edge(l);i.removeEdge(l),c.forwardName=l.name,c.reversed=!0,i.setEdge(l.w,l.v,c,e("rev"))});function a(l){return c=>l.edge(c).weight}}function r(i){let s=[],a={},l={};function c(u){Object.hasOwn(l,u)||(l[u]=!0,a[u]=!0,i.outEdges(u).forEach(d=>{Object.hasOwn(a,d.w)?s.push(d):c(d.w)}),delete a[u])}return i.nodes().forEach(c),s}function o(i){i.edges().forEach(s=>{let a=i.edge(s);if(a.reversed){i.removeEdge(s);let l=a.forwardName;delete a.reversed,delete a.forwardName,i.setEdge(s.w,s.v,a,l)}})}return Tg}var _g,GA;function Sq(){if(GA)return _g;GA=1;let t=Mt();_g={run:e,undo:r};function e(o){o.graph().dummyChains=[],o.edges().forEach(i=>n(o,i))}function n(o,i){let s=i.v,a=o.node(s).rank,l=i.w,c=o.node(l).rank,u=i.name,d=o.edge(i),h=d.labelRank;if(c===a+1)return;o.removeEdge(i);let p,m,w;for(w=0,++a;a<c;++w,++a)d.points=[],m={width:0,height:0,edgeLabel:d,edgeObj:i,rank:a},p=t.addDummyNode(o,"edge",m,"_d"),a===h&&(m.width=d.width,m.height=d.height,m.dummy="edge-label",m.labelpos=d.labelpos),o.setEdge(s,p,{weight:d.weight},u),w===0&&o.graph().dummyChains.push(p),s=p;o.setEdge(s,l,{weight:d.weight},u)}function r(o){o.graph().dummyChains.forEach(i=>{let s=o.node(i),a=s.edgeLabel,l;for(o.setEdge(s.edgeObj,a);s.dummy;)l=o.successors(i)[0],o.removeNode(i),a.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(a.x=s.x,a.y=s.y,a.width=s.width,a.height=s.height),i=l,s=o.node(i)})}return _g}var Ng,KA;function md(){if(KA)return Ng;KA=1;const{applyWithChunking:t}=Mt();Ng={longestPath:e,slack:n};function e(r){var o={};function i(s){var a=r.node(s);if(Object.hasOwn(o,s))return a.rank;o[s]=!0;let l=r.outEdges(s).map(u=>u==null?Number.POSITIVE_INFINITY:i(u.w)-r.edge(u).minlen);var c=t(Math.min,l);return c===Number.POSITIVE_INFINITY&&(c=0),a.rank=c}r.sources().forEach(i)}function n(r,o){return r.node(o.w).rank-r.node(o.v).rank-r.edge(o).minlen}return Ng}var Bg,YA;function XA(){if(YA)return Bg;YA=1;var t=gr().Graph,e=md().slack;Bg=n;function n(s){var a=new t({directed:!1}),l=s.nodes()[0],c=s.nodeCount();a.setNode(l,{});for(var u,d;r(a,s)<c;)u=o(a,s),d=a.hasNode(u.v)?e(s,u):-e(s,u),i(a,s,d);return a}function r(s,a){function l(c){a.nodeEdges(c).forEach(u=>{var d=u.v,h=c===d?u.w:d;!s.hasNode(h)&&!e(a,u)&&(s.setNode(h,{}),s.setEdge(c,h,{}),l(h))})}return s.nodes().forEach(l),s.nodeCount()}function o(s,a){return a.edges().reduce((c,u)=>{let d=Number.POSITIVE_INFINITY;return s.hasNode(u.v)!==s.hasNode(u.w)&&(d=e(a,u)),d<c[0]?[d,u]:c},[Number.POSITIVE_INFINITY,null])[1]}function i(s,a,l){s.nodes().forEach(c=>a.node(c).rank+=l)}return Bg}var Fg,JA;function Eq(){if(JA)return Fg;JA=1;var t=XA(),e=md().slack,n=md().longestPath,r=gr().alg.preorder,o=gr().alg.postorder,i=Mt().simplify;Fg=s,s.initLowLimValues=u,s.initCutValues=a,s.calcCutValue=c,s.leaveEdge=h,s.enterEdge=p,s.exchangeEdges=m;function s(g){g=i(g),n(g);var k=t(g);u(k),a(k,g);for(var A,C;A=h(k);)C=p(k,g,A),m(k,g,A,C)}function a(g,k){var A=o(g,g.nodes());A=A.slice(0,A.length-1),A.forEach(C=>l(g,k,C))}function l(g,k,A){var C=g.node(A),E=C.parent;g.edge(A,E).cutvalue=c(g,k,A)}function c(g,k,A){var C=g.node(A),E=C.parent,D=!0,S=k.edge(A,E),_=0;return S||(D=!1,S=k.edge(E,A)),_=S.weight,k.nodeEdges(A).forEach(O=>{var B=O.v===A,N=B?O.w:O.v;if(N!==E){var F=B===D,M=k.edge(O).weight;if(_+=F?M:-M,v(g,A,N)){var T=g.edge(A,N).cutvalue;_+=F?-T:T}}}),_}function u(g,k){arguments.length<2&&(k=g.nodes()[0]),d(g,{},1,k)}function d(g,k,A,C,E){var D=A,S=g.node(C);return k[C]=!0,g.neighbors(C).forEach(_=>{Object.hasOwn(k,_)||(A=d(g,k,A,_,C))}),S.low=D,S.lim=A++,E?S.parent=E:delete S.parent,A}function h(g){return g.edges().find(k=>g.edge(k).cutvalue<0)}function p(g,k,A){var C=A.v,E=A.w;k.hasEdge(C,E)||(C=A.w,E=A.v);var D=g.node(C),S=g.node(E),_=D,O=!1;D.lim>S.lim&&(_=S,O=!0);var B=k.edges().filter(N=>O===y(g,g.node(N.v),_)&&O!==y(g,g.node(N.w),_));return B.reduce((N,F)=>e(k,F)<e(k,N)?F:N)}function m(g,k,A,C){var E=A.v,D=A.w;g.removeEdge(E,D),g.setEdge(C.v,C.w,{}),u(g),a(g,k),w(g,k)}function w(g,k){var A=g.nodes().find(E=>!k.node(E).parent),C=r(g,A);C=C.slice(1),C.forEach(E=>{var D=g.node(E).parent,S=k.edge(E,D),_=!1;S||(S=k.edge(D,E),_=!0),k.node(E).rank=k.node(D).rank+(_?S.minlen:-S.minlen)})}function v(g,k,A){return g.hasEdge(k,A)}function y(g,k,A){return A.low<=k.lim&&k.lim<=A.lim}return Fg}var Ig,RA;function Dq(){if(RA)return Ig;RA=1;var t=md(),e=t.longestPath,n=XA(),r=Eq();Ig=o;function o(l){var c=l.graph().ranker;if(c instanceof Function)return c(l);switch(l.graph().ranker){case"network-simplex":a(l);break;case"tight-tree":s(l);break;case"longest-path":i(l);break;case"none":break;default:a(l)}}var i=e;function s(l){e(l),n(l)}function a(l){r(l)}return Ig}var Mg,QA;function Aq(){if(QA)return Mg;QA=1,Mg=t;function t(r){let o=n(r);r.graph().dummyChains.forEach(i=>{let s=r.node(i),a=s.edgeObj,l=e(r,o,a.v,a.w),c=l.path,u=l.lca,d=0,h=c[d],p=!0;for(;i!==a.w;){if(s=r.node(i),p){for(;(h=c[d])!==u&&r.node(h).maxRank<s.rank;)d++;h===u&&(p=!1)}if(!p){for(;d<c.length-1&&r.node(h=c[d+1]).minRank<=s.rank;)d++;h=c[d]}r.setParent(i,h),i=r.successors(i)[0]}})}function e(r,o,i,s){let a=[],l=[],c=Math.min(o[i].low,o[s].low),u=Math.max(o[i].lim,o[s].lim),d,h;d=i;do d=r.parent(d),a.push(d);while(d&&(o[d].low>c||u>o[d].lim));for(h=d,d=s;(d=r.parent(d))!==h;)l.push(d);return{path:a.concat(l.reverse()),lca:h}}function n(r){let o={},i=0;function s(a){let l=i;r.children(a).forEach(s),o[a]={low:l,lim:i++}}return r.children().forEach(s),o}return Mg}var Pg,ZA;function Oq(){if(ZA)return Pg;ZA=1;let t=Mt();Pg={run:e,cleanup:i};function e(s){let a=t.addDummyNode(s,"root",{},"_root"),l=r(s),c=Object.values(l),u=t.applyWithChunking(Math.max,c)-1,d=2*u+1;s.graph().nestingRoot=a,s.edges().forEach(p=>s.edge(p).minlen*=d);let h=o(s)+1;s.children().forEach(p=>n(s,a,d,h,u,l,p)),s.graph().nodeRankFactor=d}function n(s,a,l,c,u,d,h){let p=s.children(h);if(!p.length){h!==a&&s.setEdge(a,h,{weight:0,minlen:l});return}let m=t.addBorderNode(s,"_bt"),w=t.addBorderNode(s,"_bb"),v=s.node(h);s.setParent(m,h),v.borderTop=m,s.setParent(w,h),v.borderBottom=w,p.forEach(y=>{n(s,a,l,c,u,d,y);let g=s.node(y),k=g.borderTop?g.borderTop:y,A=g.borderBottom?g.borderBottom:y,C=g.borderTop?c:2*c,E=k!==A?1:u-d[h]+1;s.setEdge(m,k,{weight:C,minlen:E,nestingEdge:!0}),s.setEdge(A,w,{weight:C,minlen:E,nestingEdge:!0})}),s.parent(h)||s.setEdge(a,m,{weight:0,minlen:u+d[h]})}function r(s){var a={};function l(c,u){var d=s.children(c);d&&d.length&&d.forEach(h=>l(h,u+1)),a[c]=u}return s.children().forEach(c=>l(c,1)),a}function o(s){return s.edges().reduce((a,l)=>a+s.edge(l).weight,0)}function i(s){var a=s.graph();s.removeNode(a.nestingRoot),delete a.nestingRoot,s.edges().forEach(l=>{var c=s.edge(l);c.nestingEdge&&s.removeEdge(l)})}return Pg}var Lg,eO;function Tq(){if(eO)return Lg;eO=1;let t=Mt();Lg=e;function e(r){function o(i){let s=r.children(i),a=r.node(i);if(s.length&&s.forEach(o),Object.hasOwn(a,"minRank")){a.borderLeft=[],a.borderRight=[];for(let l=a.minRank,c=a.maxRank+1;l<c;++l)n(r,"borderLeft","_bl",i,a,l),n(r,"borderRight","_br",i,a,l)}}r.children().forEach(o)}function n(r,o,i,s,a,l){let c={width:0,height:0,rank:l,borderType:o},u=a[o][l-1],d=t.addDummyNode(r,"border",c,i);a[o][l]=d,r.setParent(d,s),u&&r.setEdge(u,d,{weight:1})}return Lg}var $g,tO;function _q(){if(tO)return $g;tO=1,$g={adjust:t,undo:e};function t(l){let c=l.graph().rankdir.toLowerCase();(c==="lr"||c==="rl")&&n(l)}function e(l){let c=l.graph().rankdir.toLowerCase();(c==="bt"||c==="rl")&&o(l),(c==="lr"||c==="rl")&&(s(l),n(l))}function n(l){l.nodes().forEach(c=>r(l.node(c))),l.edges().forEach(c=>r(l.edge(c)))}function r(l){let c=l.width;l.width=l.height,l.height=c}function o(l){l.nodes().forEach(c=>i(l.node(c))),l.edges().forEach(c=>{let u=l.edge(c);u.points.forEach(i),Object.hasOwn(u,"y")&&i(u)})}function i(l){l.y=-l.y}function s(l){l.nodes().forEach(c=>a(l.node(c))),l.edges().forEach(c=>{let u=l.edge(c);u.points.forEach(a),Object.hasOwn(u,"x")&&a(u)})}function a(l){let c=l.x;l.x=l.y,l.y=c}return $g}var Hg,nO;function Nq(){if(nO)return Hg;nO=1;let t=Mt();Hg=e;function e(n){let r={},o=n.nodes().filter(u=>!n.children(u).length),i=o.map(u=>n.node(u).rank),s=t.applyWithChunking(Math.max,i),a=t.range(s+1).map(()=>[]);function l(u){if(r[u])return;r[u]=!0;let d=n.node(u);a[d.rank].push(u),n.successors(u).forEach(l)}return o.sort((u,d)=>n.node(u).rank-n.node(d).rank).forEach(l),a}return Hg}var zg,rO;function Bq(){if(rO)return zg;rO=1;let t=Mt().zipObject;zg=e;function e(r,o){let i=0;for(let s=1;s<o.length;++s)i+=n(r,o[s-1],o[s]);return i}function n(r,o,i){let s=t(i,i.map((h,p)=>p)),a=o.flatMap(h=>r.outEdges(h).map(p=>({pos:s[p.w],weight:r.edge(p).weight})).sort((p,m)=>p.pos-m.pos)),l=1;for(;l<i.length;)l<<=1;let c=2*l-1;l-=1;let u=new Array(c).fill(0),d=0;return a.forEach(h=>{let p=h.pos+l;u[p]+=h.weight;let m=0;for(;p>0;)p%2&&(m+=u[p+1]),p=p-1>>1,u[p]+=h.weight;d+=h.weight*m}),d}return zg}var jg,oO;function Fq(){if(oO)return jg;oO=1,jg=t;function t(e,n=[]){return n.map(r=>{let o=e.inEdges(r);if(o.length){let i=o.reduce((s,a)=>{let l=e.edge(a),c=e.node(a.v);return{sum:s.sum+l.weight*c.order,weight:s.weight+l.weight}},{sum:0,weight:0});return{v:r,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:r}})}return jg}var Vg,iO;function Iq(){if(iO)return Vg;iO=1;let t=Mt();Vg=e;function e(o,i){let s={};o.forEach((l,c)=>{let u=s[l.v]={indegree:0,in:[],out:[],vs:[l.v],i:c};l.barycenter!==void 0&&(u.barycenter=l.barycenter,u.weight=l.weight)}),i.edges().forEach(l=>{let c=s[l.v],u=s[l.w];c!==void 0&&u!==void 0&&(u.indegree++,c.out.push(s[l.w]))});let a=Object.values(s).filter(l=>!l.indegree);return n(a)}function n(o){let i=[];function s(l){return c=>{c.merged||(c.barycenter===void 0||l.barycenter===void 0||c.barycenter>=l.barycenter)&&r(l,c)}}function a(l){return c=>{c.in.push(l),--c.indegree===0&&o.push(c)}}for(;o.length;){let l=o.pop();i.push(l),l.in.reverse().forEach(s(l)),l.out.forEach(a(l))}return i.filter(l=>!l.merged).map(l=>t.pick(l,["vs","i","barycenter","weight"]))}function r(o,i){let s=0,a=0;o.weight&&(s+=o.barycenter*o.weight,a+=o.weight),i.weight&&(s+=i.barycenter*i.weight,a+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=s/a,o.weight=a,o.i=Math.min(i.i,o.i),i.merged=!0}return Vg}var Wg,sO;function Mq(){if(sO)return Wg;sO=1;let t=Mt();Wg=e;function e(o,i){let s=t.partition(o,m=>Object.hasOwn(m,"barycenter")),a=s.lhs,l=s.rhs.sort((m,w)=>w.i-m.i),c=[],u=0,d=0,h=0;a.sort(r(!!i)),h=n(c,l,h),a.forEach(m=>{h+=m.vs.length,c.push(m.vs),u+=m.barycenter*m.weight,d+=m.weight,h=n(c,l,h)});let p={vs:c.flat(!0)};return d&&(p.barycenter=u/d,p.weight=d),p}function n(o,i,s){let a;for(;i.length&&(a=i[i.length-1]).i<=s;)i.pop(),o.push(a.vs),s++;return s}function r(o){return(i,s)=>i.barycenter<s.barycenter?-1:i.barycenter>s.barycenter?1:o?s.i-i.i:i.i-s.i}return Wg}var Ug,aO;function Pq(){if(aO)return Ug;aO=1;let t=Fq(),e=Iq(),n=Mq();Ug=r;function r(s,a,l,c){let u=s.children(a),d=s.node(a),h=d?d.borderLeft:void 0,p=d?d.borderRight:void 0,m={};h&&(u=u.filter(g=>g!==h&&g!==p));let w=t(s,u);w.forEach(g=>{if(s.children(g.v).length){let k=r(s,g.v,l,c);m[g.v]=k,Object.hasOwn(k,"barycenter")&&i(g,k)}});let v=e(w,l);o(v,m);let y=n(v,c);if(h&&(y.vs=[h,y.vs,p].flat(!0),s.predecessors(h).length)){let g=s.node(s.predecessors(h)[0]),k=s.node(s.predecessors(p)[0]);Object.hasOwn(y,"barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+g.order+k.order)/(y.weight+2),y.weight+=2}return y}function o(s,a){s.forEach(l=>{l.vs=l.vs.flatMap(c=>a[c]?a[c].vs:c)})}function i(s,a){s.barycenter!==void 0?(s.barycenter=(s.barycenter*s.weight+a.barycenter*a.weight)/(s.weight+a.weight),s.weight+=a.weight):(s.barycenter=a.barycenter,s.weight=a.weight)}return Ug}var qg,lO;function Lq(){if(lO)return qg;lO=1;let t=gr().Graph,e=Mt();qg=n;function n(o,i,s,a){a||(a=o.nodes());let l=r(o),c=new t({compound:!0}).setGraph({root:l}).setDefaultNodeLabel(u=>o.node(u));return a.forEach(u=>{let d=o.node(u),h=o.parent(u);(d.rank===i||d.minRank<=i&&i<=d.maxRank)&&(c.setNode(u),c.setParent(u,h||l),o[s](u).forEach(p=>{let m=p.v===u?p.w:p.v,w=c.edge(m,u),v=w!==void 0?w.weight:0;c.setEdge(m,u,{weight:o.edge(p).weight+v})}),Object.hasOwn(d,"minRank")&&c.setNode(u,{borderLeft:d.borderLeft[i],borderRight:d.borderRight[i]}))}),c}function r(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return qg}var Gg,cO;function $q(){if(cO)return Gg;cO=1,Gg=t;function t(e,n,r){let o={},i;r.forEach(s=>{let a=e.parent(s),l,c;for(;a;){if(l=e.parent(a),l?(c=o[l],o[l]=a):(c=i,i=a),c&&c!==a){n.setEdge(c,a);return}a=l}})}return Gg}var Kg,uO;function Hq(){if(uO)return Kg;uO=1;let t=Nq(),e=Bq(),n=Pq(),r=Lq(),o=$q(),i=gr().Graph,s=Mt();Kg=a;function a(d,h){if(h&&typeof h.customOrder=="function"){h.customOrder(d,a);return}let p=s.maxRank(d),m=l(d,s.range(1,p+1),"inEdges"),w=l(d,s.range(p-1,-1,-1),"outEdges"),v=t(d);if(u(d,v),h&&h.disableOptimalOrderHeuristic)return;let y=Number.POSITIVE_INFINITY,g;for(let k=0,A=0;A<4;++k,++A){c(k%2?m:w,k%4>=2),v=s.buildLayerMatrix(d);let C=e(d,v);C<y&&(A=0,g=Object.assign({},v),y=C)}u(d,g)}function l(d,h,p){const m=new Map,w=(v,y)=>{m.has(v)||m.set(v,[]),m.get(v).push(y)};for(const v of d.nodes()){const y=d.node(v);if(typeof y.rank=="number"&&w(y.rank,v),typeof y.minRank=="number"&&typeof y.maxRank=="number")for(let g=y.minRank;g<=y.maxRank;g++)g!==y.rank&&w(g,v)}return h.map(function(v){return r(d,v,p,m.get(v)||[])})}function c(d,h){let p=new i;d.forEach(function(m){let w=m.graph().root,v=n(m,w,p,h);v.vs.forEach((y,g)=>m.node(y).order=g),o(m,p,v.vs)})}function u(d,h){Object.values(h).forEach(p=>p.forEach((m,w)=>d.node(m).order=w))}return Kg}var Yg,dO;function zq(){if(dO)return Yg;dO=1;let t=gr().Graph,e=Mt();Yg={positionX:p,findType1Conflicts:n,findType2Conflicts:r,addConflict:i,hasConflict:s,verticalAlignment:a,horizontalCompaction:l,alignCoordinates:d,findSmallestWidthAlignment:u,balance:h};function n(v,y){let g={};function k(A,C){let E=0,D=0,S=A.length,_=C[C.length-1];return C.forEach((O,B)=>{let N=o(v,O),F=N?v.node(N).order:S;(N||O===_)&&(C.slice(D,B+1).forEach(M=>{v.predecessors(M).forEach(T=>{let P=v.node(T),$=P.order;($<E||F<$)&&!(P.dummy&&v.node(M).dummy)&&i(g,T,M)})}),D=B+1,E=F)}),C}return y.length&&y.reduce(k),g}function r(v,y){let g={};function k(C,E,D,S,_){let O;e.range(E,D).forEach(B=>{O=C[B],v.node(O).dummy&&v.predecessors(O).forEach(N=>{let F=v.node(N);F.dummy&&(F.order<S||F.order>_)&&i(g,N,O)})})}function A(C,E){let D=-1,S,_=0;return E.forEach((O,B)=>{if(v.node(O).dummy==="border"){let N=v.predecessors(O);N.length&&(S=v.node(N[0]).order,k(E,_,B,D,S),_=B,D=S)}k(E,_,E.length,S,C.length)}),E}return y.length&&y.reduce(A),g}function o(v,y){if(v.node(y).dummy)return v.predecessors(y).find(g=>v.node(g).dummy)}function i(v,y,g){if(y>g){let A=y;y=g,g=A}let k=v[y];k||(v[y]=k={}),k[g]=!0}function s(v,y,g){if(y>g){let k=y;y=g,g=k}return!!v[y]&&Object.hasOwn(v[y],g)}function a(v,y,g,k){let A={},C={},E={};return y.forEach(D=>{D.forEach((S,_)=>{A[S]=S,C[S]=S,E[S]=_})}),y.forEach(D=>{let S=-1;D.forEach(_=>{let O=k(_);if(O.length){O=O.sort((N,F)=>E[N]-E[F]);let B=(O.length-1)/2;for(let N=Math.floor(B),F=Math.ceil(B);N<=F;++N){let M=O[N];C[_]===_&&S<E[M]&&!s(g,_,M)&&(C[M]=_,C[_]=A[_]=A[M],S=E[M])}}})}),{root:A,align:C}}function l(v,y,g,k,A){let C={},E=c(v,y,g,A),D=A?"borderLeft":"borderRight";function S(B,N){let F=E.nodes(),M=F.pop(),T={};for(;M;)T[M]?B(M):(T[M]=!0,F.push(M),F=F.concat(N(M))),M=F.pop()}function _(B){C[B]=E.inEdges(B).reduce((N,F)=>Math.max(N,C[F.v]+E.edge(F)),0)}function O(B){let N=E.outEdges(B).reduce((M,T)=>Math.min(M,C[T.w]-E.edge(T)),Number.POSITIVE_INFINITY),F=v.node(B);N!==Number.POSITIVE_INFINITY&&F.borderType!==D&&(C[B]=Math.max(C[B],N))}return S(_,E.predecessors.bind(E)),S(O,E.successors.bind(E)),Object.keys(k).forEach(B=>C[B]=C[g[B]]),C}function c(v,y,g,k){let A=new t,C=v.graph(),E=m(C.nodesep,C.edgesep,k);return y.forEach(D=>{let S;D.forEach(_=>{let O=g[_];if(A.setNode(O),S){var B=g[S],N=A.edge(B,O);A.setEdge(B,O,Math.max(E(v,_,S),N||0))}S=_})}),A}function u(v,y){return Object.values(y).reduce((g,k)=>{let A=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;Object.entries(k).forEach(([D,S])=>{let _=w(v,D)/2;A=Math.max(S+_,A),C=Math.min(S-_,C)});const E=A-C;return E<g[0]&&(g=[E,k]),g},[Number.POSITIVE_INFINITY,null])[1]}function d(v,y){let g=Object.values(y),k=e.applyWithChunking(Math.min,g),A=e.applyWithChunking(Math.max,g);["u","d"].forEach(C=>{["l","r"].forEach(E=>{let D=C+E,S=v[D];if(S===y)return;let _=Object.values(S),O=k-e.applyWithChunking(Math.min,_);E!=="l"&&(O=A-e.applyWithChunking(Math.max,_)),O&&(v[D]=e.mapValues(S,B=>B+O))})})}function h(v,y){return e.mapValues(v.ul,(g,k)=>{if(y)return v[y.toLowerCase()][k];{let A=Object.values(v).map(C=>C[k]).sort((C,E)=>C-E);return(A[1]+A[2])/2}})}function p(v){let y=e.buildLayerMatrix(v),g=Object.assign(n(v,y),r(v,y)),k={},A;["u","d"].forEach(E=>{A=E==="u"?y:Object.values(y).reverse(),["l","r"].forEach(D=>{D==="r"&&(A=A.map(B=>Object.values(B).reverse()));let S=(E==="u"?v.predecessors:v.successors).bind(v),_=a(v,A,g,S),O=l(v,A,_.root,_.align,D==="r");D==="r"&&(O=e.mapValues(O,B=>-B)),k[E+D]=O})});let C=u(v,k);return d(k,C),h(k,v.graph().align)}function m(v,y,g){return(k,A,C)=>{let E=k.node(A),D=k.node(C),S=0,_;if(S+=E.width/2,Object.hasOwn(E,"labelpos"))switch(E.labelpos.toLowerCase()){case"l":_=-E.width/2;break;case"r":_=E.width/2;break}if(_&&(S+=g?_:-_),_=0,S+=(E.dummy?y:v)/2,S+=(D.dummy?y:v)/2,S+=D.width/2,Object.hasOwn(D,"labelpos"))switch(D.labelpos.toLowerCase()){case"l":_=D.width/2;break;case"r":_=-D.width/2;break}return _&&(S+=g?_:-_),_=0,S}}function w(v,y){return v.node(y).width}return Yg}var Xg,fO;function jq(){if(fO)return Xg;fO=1;let t=Mt(),e=zq().positionX;Xg=n;function n(o){o=t.asNonCompoundGraph(o),r(o),Object.entries(e(o)).forEach(([i,s])=>o.node(i).x=s)}function r(o){let i=t.buildLayerMatrix(o),s=o.graph().ranksep,a=0;i.forEach(l=>{const c=l.reduce((u,d)=>{const h=o.node(d).height;return u>h?u:h},0);l.forEach(u=>o.node(u).y=a+c/2),a+=c+s})}return Xg}var Jg,hO;function Vq(){if(hO)return Jg;hO=1;let t=xq(),e=Sq(),n=Dq(),r=Mt().normalizeRanks,o=Aq(),i=Mt().removeEmptyRanks,s=Oq(),a=Tq(),l=_q(),c=Hq(),u=jq(),d=Mt(),h=gr().Graph;Jg=p;function p(H,j){let Y=j&&j.debugTiming?d.time:d.notime;Y("layout",()=>{let se=Y(" buildLayoutGraph",()=>S(H));Y(" runLayout",()=>m(se,Y,j)),Y(" updateInputGraph",()=>w(H,se))})}function m(H,j,Y){j(" makeSpaceForEdgeLabels",()=>_(H)),j(" removeSelfEdges",()=>W(H)),j(" acyclic",()=>t.run(H)),j(" nestingGraph.run",()=>s.run(H)),j(" rank",()=>n(d.asNonCompoundGraph(H))),j(" injectEdgeLabelProxies",()=>O(H)),j(" removeEmptyRanks",()=>i(H)),j(" nestingGraph.cleanup",()=>s.cleanup(H)),j(" normalizeRanks",()=>r(H)),j(" assignRankMinMax",()=>B(H)),j(" removeEdgeLabelProxies",()=>N(H)),j(" normalize.run",()=>e.run(H)),j(" parentDummyChains",()=>o(H)),j(" addBorderSegments",()=>a(H)),j(" order",()=>c(H,Y)),j(" insertSelfEdges",()=>V(H)),j(" adjustCoordinateSystem",()=>l.adjust(H)),j(" position",()=>u(H)),j(" positionSelfEdges",()=>X(H)),j(" removeBorderNodes",()=>$(H)),j(" normalize.undo",()=>e.undo(H)),j(" fixupEdgeLabelCoords",()=>T(H)),j(" undoCoordinateSystem",()=>l.undo(H)),j(" translateGraph",()=>F(H)),j(" assignNodeIntersects",()=>M(H)),j(" reversePoints",()=>P(H)),j(" acyclic.undo",()=>t.undo(H))}function w(H,j){H.nodes().forEach(Y=>{let se=H.node(Y),Q=j.node(Y);se&&(se.x=Q.x,se.y=Q.y,se.rank=Q.rank,j.children(Y).length&&(se.width=Q.width,se.height=Q.height))}),H.edges().forEach(Y=>{let se=H.edge(Y),Q=j.edge(Y);se.points=Q.points,Object.hasOwn(Q,"x")&&(se.x=Q.x,se.y=Q.y)}),H.graph().width=j.graph().width,H.graph().height=j.graph().height}let v=["nodesep","edgesep","ranksep","marginx","marginy"],y={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},g=["acyclicer","ranker","rankdir","align"],k=["width","height","rank"],A={width:0,height:0},C=["minlen","weight","width","height","labeloffset"],E={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},D=["labelpos"];function S(H){let j=new h({multigraph:!0,compound:!0}),Y=te(H.graph());return j.setGraph(Object.assign({},y,G(Y,v),d.pick(Y,g))),H.nodes().forEach(se=>{let Q=te(H.node(se));const le=G(Q,k);Object.keys(A).forEach(L=>{le[L]===void 0&&(le[L]=A[L])}),j.setNode(se,le),j.setParent(se,H.parent(se))}),H.edges().forEach(se=>{let Q=te(H.edge(se));j.setEdge(se,Object.assign({},E,G(Q,C),d.pick(Q,D)))}),j}function _(H){let j=H.graph();j.ranksep/=2,H.edges().forEach(Y=>{let se=H.edge(Y);se.minlen*=2,se.labelpos.toLowerCase()!=="c"&&(j.rankdir==="TB"||j.rankdir==="BT"?se.width+=se.labeloffset:se.height+=se.labeloffset)})}function O(H){H.edges().forEach(j=>{let Y=H.edge(j);if(Y.width&&Y.height){let se=H.node(j.v),le={rank:(H.node(j.w).rank-se.rank)/2+se.rank,e:j};d.addDummyNode(H,"edge-proxy",le,"_ep")}})}function B(H){let j=0;H.nodes().forEach(Y=>{let se=H.node(Y);se.borderTop&&(se.minRank=H.node(se.borderTop).rank,se.maxRank=H.node(se.borderBottom).rank,j=Math.max(j,se.maxRank))}),H.graph().maxRank=j}function N(H){H.nodes().forEach(j=>{let Y=H.node(j);Y.dummy==="edge-proxy"&&(H.edge(Y.e).labelRank=Y.rank,H.removeNode(j))})}function F(H){let j=Number.POSITIVE_INFINITY,Y=0,se=Number.POSITIVE_INFINITY,Q=0,le=H.graph(),L=le.marginx||0,q=le.marginy||0;function J(K){let re=K.x,ie=K.y,he=K.width,Ce=K.height;j=Math.min(j,re-he/2),Y=Math.max(Y,re+he/2),se=Math.min(se,ie-Ce/2),Q=Math.max(Q,ie+Ce/2)}H.nodes().forEach(K=>J(H.node(K))),H.edges().forEach(K=>{let re=H.edge(K);Object.hasOwn(re,"x")&&J(re)}),j-=L,se-=q,H.nodes().forEach(K=>{let re=H.node(K);re.x-=j,re.y-=se}),H.edges().forEach(K=>{let re=H.edge(K);re.points.forEach(ie=>{ie.x-=j,ie.y-=se}),Object.hasOwn(re,"x")&&(re.x-=j),Object.hasOwn(re,"y")&&(re.y-=se)}),le.width=Y-j+L,le.height=Q-se+q}function M(H){H.edges().forEach(j=>{let Y=H.edge(j),se=H.node(j.v),Q=H.node(j.w),le,L;Y.points?(le=Y.points[0],L=Y.points[Y.points.length-1]):(Y.points=[],le=Q,L=se),Y.points.unshift(d.intersectRect(se,le)),Y.points.push(d.intersectRect(Q,L))})}function T(H){H.edges().forEach(j=>{let Y=H.edge(j);if(Object.hasOwn(Y,"x"))switch((Y.labelpos==="l"||Y.labelpos==="r")&&(Y.width-=Y.labeloffset),Y.labelpos){case"l":Y.x-=Y.width/2+Y.labeloffset;break;case"r":Y.x+=Y.width/2+Y.labeloffset;break}})}function P(H){H.edges().forEach(j=>{let Y=H.edge(j);Y.reversed&&Y.points.reverse()})}function $(H){H.nodes().forEach(j=>{if(H.children(j).length){let Y=H.node(j),se=H.node(Y.borderTop),Q=H.node(Y.borderBottom),le=H.node(Y.borderLeft[Y.borderLeft.length-1]),L=H.node(Y.borderRight[Y.borderRight.length-1]);Y.width=Math.abs(L.x-le.x),Y.height=Math.abs(Q.y-se.y),Y.x=le.x+Y.width/2,Y.y=se.y+Y.height/2}}),H.nodes().forEach(j=>{H.node(j).dummy==="border"&&H.removeNode(j)})}function W(H){H.edges().forEach(j=>{if(j.v===j.w){var Y=H.node(j.v);Y.selfEdges||(Y.selfEdges=[]),Y.selfEdges.push({e:j,label:H.edge(j)}),H.removeEdge(j)}})}function V(H){var j=d.buildLayerMatrix(H);j.forEach(Y=>{var se=0;Y.forEach((Q,le)=>{var L=H.node(Q);L.order=le+se,(L.selfEdges||[]).forEach(q=>{d.addDummyNode(H,"selfedge",{width:q.label.width,height:q.label.height,rank:L.rank,order:le+ ++se,e:q.e,label:q.label},"_se")}),delete L.selfEdges})})}function X(H){H.nodes().forEach(j=>{var Y=H.node(j);if(Y.dummy==="selfedge"){var se=H.node(Y.e.v),Q=se.x+se.width/2,le=se.y,L=Y.x-Q,q=se.height/2;H.setEdge(Y.e,Y.label),H.removeNode(j),Y.label.points=[{x:Q+2*L/3,y:le-q},{x:Q+5*L/6,y:le-q},{x:Q+L,y:le},{x:Q+5*L/6,y:le+q},{x:Q+2*L/3,y:le+q}],Y.label.x=Y.x,Y.label.y=Y.y}})}function G(H,j){return d.mapValues(d.pick(H,j),Number)}function te(H){var j={};return H&&Object.entries(H).forEach(([Y,se])=>{typeof Y=="string"&&(Y=Y.toLowerCase()),j[Y]=se}),j}return Jg}var Rg,pO;function Wq(){if(pO)return Rg;pO=1;let t=Mt(),e=gr().Graph;Rg={debugOrdering:n};function n(r){let o=t.buildLayerMatrix(r),i=new e({compound:!0,multigraph:!0}).setGraph({});return r.nodes().forEach(s=>{i.setNode(s,{label:s}),i.setParent(s,"layer"+r.node(s).rank)}),r.edges().forEach(s=>i.setEdge(s.v,s.w,{},s.name)),o.forEach((s,a)=>{let l="layer"+a;i.setNode(l,{rank:"same"}),s.reduce((c,u)=>(i.setEdge(c,u,{style:"invis"}),u))}),i}return Rg}var Qg,mO;function Uq(){return mO||(mO=1,Qg="1.1.8"),Qg}var Zg,gO;function qq(){return gO||(gO=1,Zg={graphlib:gr(),layout:Vq(),debug:Wq(),util:{time:Mt().time,notime:Mt().notime},version:Uq()}),Zg}var Gq=qq();const wO=Ii(Gq),ew=20,Ke=300,Ds=ew*15,tw=ew*10,As=ew*3;function vO(t){return t.type===ee.AGENT||t.type===ee.MCPServer}function yO(t){return t.type===ee.BuiltinMCP}function Kq(t){return t.type===ee.AI_SUB_NODE||t.type===ee.MCP_TOOL}function bO(t,e,n){const r=new Map(n.map(a=>[a.id,a])),i=e.filter(a=>a.source===t).map(a=>r.get(a.target)).filter(a=>a!==void 0);console.log("候选子节点:",i.map(a=>`${a.id}(${a.type})`));const s=i.filter(a=>a!==void 0&&Kq(a));return console.log("符合条件的子节点:",s.map(a=>`${a.id}(${a.type})`)),s}function Yq(t,e){const n=[t,...e],r=Ke,o=Ke,i=n.length*o+(n.length-1)*As,s=r,a=t.position.y,c={x:t.position.x,y:a,width:s,height:i};return{parentId:t.id,childIds:e.map(u=>u.id),boundingBox:c}}function Xq(t,e){const n=Ke,r=Ke,o=Math.max(n,e.length*n+(e.length-1)*Ds),i=r+As+r,s=t.position.y,l={x:t.position.x,y:s,width:o,height:i};return{parentId:t.id,childIds:e.map(c=>c.id),boundingBox:l}}function Jq(t,e,n){if(t.length===0)return{boundingBox:{x:0,y:0,width:0,height:0},nodes:[]};const r=Rq(t),o=[],i=[],s=new Set;t.forEach(C=>{var E,D;if(console.log(`检查节点 ${C.id}:`,{type:C.type,dataType:(E=C.data)==null?void 0:E.type,actionType:(D=C.data)==null?void 0:D.action_type,isVerticalParent:vO(C),isHorizontalParent:yO(C)}),vO(C)&&!s.has(C.id)){const S=bO(C.id,e,t);console.log(`找到Agent/MCPServer节点 ${C.id}, 子节点数量: ${S.length}`,S.map(O=>O.id));const _=Yq(C,S);o.push(_),s.add(C.id),S.forEach(O=>s.add(O.id))}if(yO(C)&&!s.has(C.id)){const S=bO(C.id,e,t);console.log(`找到BuiltinMCP节点 ${C.id}, 子节点数量: ${S.length}`,S.map(O=>O.id));const _=Xq(C,S);i.push(_),s.add(C.id),S.forEach(O=>s.add(O.id))}}),console.log(`总共找到 ${o.length} 个垂直布局组`,o),console.log(`总共找到 ${i.length} 个水平布局组`,i),console.log("所有边的连接:",e.map(C=>`${C.source} -> ${C.target}`));const a=t.filter(C=>!s.has(C.id)),l=new wO.graphlib.Graph;l.setGraph({rankdir:"LR",edgesep:tw,nodesep:tw,ranksep:Ds}),l.setDefaultEdgeLabel(()=>({})),a.forEach(C=>{const E=C.width||Ke,D=C.height||Ke;l.setNode(C.id,{width:E,height:D,x:C.position.x,y:C.position.y})}),o.forEach(C=>{const E=Ke+C.childIds.length*(Ke+As);l.setNode(C.parentId,{width:Ke,height:E})}),i.forEach(C=>{const E=Math.max(Ke,C.childIds.length*Ke+(C.childIds.length-1)*Ds),D=Ke+As+Ke;l.setNode(C.parentId,{width:E,height:D})}),e.forEach(C=>{const E=[...o,...i],D=E.some(F=>F.parentId===C.source||F.childIds.includes(C.source)),S=E.some(F=>F.parentId===C.target||F.childIds.includes(C.target));if(D&&S){const F=E.find(T=>T.parentId===C.source||T.childIds.includes(C.source)),M=E.find(T=>T.parentId===C.target||T.childIds.includes(C.target));if(F===M)return}let _=C.source,O=C.target;const B=E.find(F=>F.childIds.includes(C.source));B&&(_=B.parentId);const N=E.find(F=>F.childIds.includes(C.target));N&&(O=N.parentId),l.hasNode(_)&&l.hasNode(O)&&l.setEdge(_,O)}),wO.layout(l);const c=[],u=[],d=[],h=[];a.forEach(C=>{if(l.hasNode(C.id)){const E=l.node(C.id);if(!E||typeof E.x!="number"||typeof E.y!="number"){console.warn(`Invalid layout data for regular node ${C.id}:`,E);return}const D={x:E.x-(E.width||Ke)/2,y:E.y-(E.height||Ke)/2,width:E.width||Ke,height:E.height||Ke};u.push({id:C.id,boundingBox:D}),d.push(D.y),h.push(D.x),c.push({id:C.id,x:D.x,y:D.y,width:D.width,height:D.height})}}),o.forEach(C=>{var E,D;if(l.hasNode(C.parentId)){const S=l.node(C.parentId);if(!S||typeof S.x!="number"||typeof S.y!="number"){console.warn(`Invalid layout data for vertical group ${C.parentId}:`,S);return}const _=S.x,O=S.y,B=S.width||Ke,N=S.height||Ke,F=t.find(W=>W.id===C.parentId),M=t.filter(W=>C.childIds.includes(W.id));if(!F)return;const T=_-B/2,P=O-N/2,$={x:T,y:P,width:Ke,height:Ke};console.log(`垂直布局父节点 ${C.parentId}: 从 (${(E=F.position)==null?void 0:E.x}, ${(D=F.position)==null?void 0:D.y}) 移动到 (${$.x}, ${$.y})`),u.push({id:C.parentId,boundingBox:$}),d.push($.y),h.push($.x),c.push({id:C.parentId,x:$.x,y:$.y,width:$.width,height:$.height}),M.forEach((W,V)=>{var te,H;const X=$.y+(V+1)*(Ke+As),G={x:$.x,y:X,width:Ke,height:Ke};console.log(`垂直布局子节点 ${W.id}: 从 (${(te=W.position)==null?void 0:te.x}, ${(H=W.position)==null?void 0:H.y}) 移动到 (${G.x}, ${G.y})`),u.push({id:W.id,boundingBox:G}),d.push(G.y),h.push(G.x),c.push({id:W.id,x:G.x,y:G.y,width:G.width,height:G.height})})}}),i.forEach(C=>{var E,D;if(l.hasNode(C.parentId)){const S=l.node(C.parentId);if(!S||typeof S.x!="number"||typeof S.y!="number"){console.warn(`Invalid layout data for horizontal group ${C.parentId}:`,S);return}const _=S.x,O=S.y,B=S.width||Ke,N=S.height||Ke,F=t.find(G=>G.id===C.parentId),M=t.filter(G=>C.childIds.includes(G.id));if(!F)return;const T=_-B/2,P=O-N/2,$={x:T+(B-Ke)/2,y:P,width:Ke,height:Ke};console.log(`水平布局父节点 ${C.parentId}: 从 (${(E=F.position)==null?void 0:E.x}, ${(D=F.position)==null?void 0:D.y}) 移动到 (${$.x}, ${$.y})`),u.push({id:C.parentId,boundingBox:$}),d.push($.y),h.push($.x),c.push({id:C.parentId,x:$.x,y:$.y,width:$.width,height:$.height});const W=$.y+Ke+As,V=M.length*Ke+(M.length-1)*Ds,X=T+(B-V)/2;M.forEach((G,te)=>{var Y,se;const j={x:X+te*(Ke+Ds),y:W,width:Ke,height:Ke};console.log(`水平布局子节点 ${G.id}: 从 (${(Y=G.position)==null?void 0:Y.x}, ${(se=G.position)==null?void 0:se.y}) 移动到 (${j.x}, ${j.y})`),u.push({id:G.id,boundingBox:j}),d.push(j.y),h.push(j.x),c.push({id:G.id,x:j.x,y:j.y,width:j.width,height:j.height})})}});const p=20;function m(C,E){return Math.round(C/E)*E}const w=[...new Set(d.map(C=>m(C,p)))].sort((C,E)=>C-E),v=[...new Set(h.map(C=>m(C,p)))].sort((C,E)=>C-E);console.log("主要Y对齐线:",w),console.log("主要X对齐线:",v);const y=c.map(C=>{const E=o.some(S=>S.childIds.includes(C.id)),D=i.some(S=>S.childIds.includes(C.id));if(E){const S=o.find(O=>O.childIds.includes(C.id)),_=c.find(O=>O.id===(S==null?void 0:S.parentId));if(_)return{...C,x:m(_.x,p),y:m(C.y,p)}}return D?{...C,x:m(C.x,p),y:m(C.y,p)}:{...C,x:m(C.x,p),y:m(C.y,p)}});console.log("对齐前的结果:",c.slice(0,3)),console.log("对齐后的结果:",y.slice(0,3));const g=u.length>0?CO(u.map(C=>C.boundingBox)):{x:0,y:0,width:0,height:0},k={x:g.x-r.x,y:g.y-r.y},A=y.map(C=>({...C,x:C.x-k.x,y:C.y-k.y}));return console.log(`布局完成,锚点偏移: (${k.x}, ${k.y})`),console.log("最终布局结果:",A),{boundingBox:g,nodes:A}}function Rq(t){if(t.length===0)return{x:0,y:0,width:0,height:0};const e=t.map(n=>({x:n.position.x,y:n.position.y,width:n.width||Ke,height:n.height||Ke}));return CO(e)}function CO(t){if(t.length===0)return{x:0,y:0,width:0,height:0};const{minX:e,minY:n,maxX:r,maxY:o}=t.reduce((i,s)=>{const{x:a,y:l,width:c,height:u}=s;return{minX:Math.min(i.minX,a),maxX:Math.max(i.maxX,a+c),minY:Math.min(i.minY,l),maxY:Math.max(i.maxY,l+u)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return{x:e,y:n,width:r-e,height:o-n}}const kO=t=>{const{getNodes:e,getEdges:n,getNode:r,fitView:o,setNodes:i}=ae.useReactFlow(),s=b.useCallback((c=Tl.ALL,u=!1)=>{const d=e(),h=n(),p=c==="selection"?d.filter(w=>w.selected):d;if(p.length===0)return console.log("没有节点需要布局"),{boundingBox:{x:0,y:0,width:0,height:0},nodes:[]};const m=Jq(p,h);return i(d.map(w=>{const v=m.nodes.find(y=>y.id===w.id);return v?{...w,position:{x:v.x,y:v.y}}:w})),u&&setTimeout(()=>{o({padding:.1,includeHiddenNodes:!1,duration:200})},10),m},[e,n,i,o]),a=b.useCallback((c=!1)=>s(Tl.ALL,c),[s]),l=b.useCallback((c=!1)=>s(Tl.SELECTION,c),[s]);return{layout:s,autoLayout:a,layoutSelection:l}},Qq={HORIZONTAL_GAP:Ds+100,VERTICAL_SPACING:tw,INITIAL_X:100,MAIN_NODE_Y:300,X_PROXIMITY_THRESHOLD:50};function xO(t,e=Qq){const n=t.filter(a=>a.type!==ee.AI_SUB_NODE);let r;n.length>0?r=Math.max(...n.map(l=>l.position.x))+e.HORIZONTAL_GAP:r=e.INITIAL_X;const o=e.MAIN_NODE_Y,s=t.filter(a=>Math.abs(a.position.x-r)<e.X_PROXIMITY_THRESHOLD).length*e.VERTICAL_SPACING;return[r,o+s]}const SO=()=>new Date().toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",second:"2-digit"});function Zq(t,e){var un,dn;const{workflowId:n,preview:r=!1,previewId:o,linkMode:i=!1,onInit:s}=t,a=Ss(),{setLocked:l,op_status:c}=Cr(),u=Ct(),[d,h]=b.useState(!1),[p,m]=b.useState(!1),w=Vt(),v=ae.useReactFlow(),{autoLayout:y}=kO(),[g,k]=b.useState(!0),A=!!(r&&o||w.canvas.mode==="preview"),C=c===We.ONLINE||c===We.ON_WARN,E=b.useMemo(()=>!A&&w.canvas.miniMap,[A,w.canvas.miniMap]),D=b.useMemo(()=>!A&&!i&&w.canvas.controls,[A,i,w.canvas.controls]),S=b.useMemo(()=>!A&&!i&&w.canvas.header,[A,i,w.canvas.header]),_=b.useMemo(()=>{var Se;return(Se=w.canvas.grid)==null?void 0:Se.enabled},[(un=w.canvas.grid)==null?void 0:un.enabled]),O=b.useMemo(()=>u&&!A&&w.canvas.fastOperationButtons,[u,A,w.canvas.fastOperationButtons]);lq({enabled:!A&&d&&!C});const B=A||g||!u,N=b.useCallback(Se=>{requestAnimationFrame(()=>{const Ne=v.getNode(Se);Ne&&v.fitView({nodes:[Ne],padding:.4,duration:300,maxZoom:1})})},[v]),[F,M]=b.useState(hn.IDLE),[T,P]=b.useState(""),{setFlowOpStatusAction:$,setNodeConfigVisible:W}=Cr(n),{addNodes:V,addEdges:X}=Fi(),{removeEdges:G,onConnect:te,handleEdgesChange:H}=ng(),j=ae.useStoreApi(),Y=j.getState().edges,se=Io(Se=>Se.workflow.refreshWorkFlowNum),[Q,le]=ae.useNodesState([]),[L,q]=ae.useEdgesState([]),[J,K]=b.useState(void 0),[re,ie]=b.useState(void 0),he=b.useCallback(Se=>{var Pt,In;if(!Se)return!0;const Ne=(Pt=w.canvas)==null?void 0:Pt.selectable;if(!Ne)return!0;const{includeNodeIds:Ge,includeCategories:nt}=Ne;if((!Ge||Ge.length===0)&&(!nt||nt.length===0))return!0;const ct=j.getState().nodes.find(Ur=>Ur.id===Se);if(!ct)return!0;const St=(In=ct.data)==null?void 0:In.category;return!!(Ge&&Ge.includes(Se)||nt&&St&&nt.includes(St))},[(dn=w.canvas)==null?void 0:dn.selectable,j]),Ce=b.useCallback((Se,Ne)=>{if(K(void 0),ie(void 0),Se.length===1&&Se[0].type==="position"&&Se[0].dragging&&Se[0].position){const Ge=aq(Se[0],Ne);Se[0].position.x=Ge.snapPosition.x??Se[0].position.x,Se[0].position.y=Ge.snapPosition.y??Se[0].position.y,K(Ge.horizontal),ie(Ge.vertical)}return Se},[]),Fe=b.useCallback(Se=>{H(Se),Se.forEach(Ne=>{Ne.type!=="select"&&Ne.type!=="replace"&&h(!0)})},[H]),qe=b.useCallback(Se=>{const Ne=j.getState().nodes,Ge=Se.map(lt=>lt.type==="position"&&!he(lt.id)?null:lt.type==="select"&&!he(lt.id)?{...lt,selected:!1}:lt).filter(lt=>lt!==null);Ce(Ge,Ne);const nt=Pn(Ne,lt=>{const ct=ae.applyNodeChanges(Ge,lt);lt.splice(0,ct.length,...ct),lt.splice(ct.length)});le(nt),Ge.forEach(lt=>{lt.type!=="select"&<.type!=="replace"&&h(!0)})},[he,le,j,Ce]),{onEdgeMouseEnter:Le,onEdgeMouseLeave:de}=ng(),{onNodeMouseEnter:Te,onNodeMouseLeave:_e,autoSaveNum:tt}=rd(),cn=b.useCallback((Se,Ne)=>{M(Se),Se===hn.SAVED?(P(SO()),window.__AI_FLOW_IN_QUEUE_NODE_ID&&(W(window.__AI_FLOW_IN_QUEUE_NODE_ID),window.__AI_FLOW_IN_QUEUE_NODE_ID="")):Se===hn.ERROR&&Ne&&console.error("保存失败:",Ne)},[W]),{setNodeAddCallback:Vn,openNodeSelector:en,handleManualAdd:At}=Es();dt.useUnmount(()=>{a(hd()),q([]),le([])});const ht=b.useRef(async()=>{}),ot=b.useCallback(Se=>{var nt;if(Se.defaultPrevented)return;const Ne=Se.target,Ge=(nt=Ne==null?void 0:Ne.tagName)==null?void 0:nt.toLowerCase();Ge==="input"||Ge==="textarea"||Ne!=null&&Ne.isContentEditable||Se.altKey&&Se.shiftKey&&Se.code==="KeyD"&&(Se.preventDefault(),m(lt=>!lt))},[]);b.useEffect(()=>(window.addEventListener("keydown",ot),()=>{window.removeEventListener("keydown",ot)}),[ot]);const lo=b.useCallback(Se=>{var ct;const Ne=((ct=w.edgeRules)==null?void 0:ct.validators)||[];if(!Ne.length)return!0;const{nodes:Ge,edges:nt}=j.getState(),lt={nodes:Ge.reduce((St,Pt)=>{var Ur;const In={id:Pt.id,type:Pt.type||"",position:Pt.position,data:Pt.data,disabled:((Ur=Pt.data)==null?void 0:Ur.closed)==="1"};return St[Pt.id]=In,St},{}),edges:nt.map(St=>({id:St.id,source:St.source,target:St.target,data:St.data}))};try{return Ne.every(St=>St(Se,lt))}catch(St){return console.error("边校验函数执行异常",St),!1}},[w.edgeRules,j]),Wn=b.useCallback(Se=>{if(!Se.source||!Se.target)return;const Ne={source:Se.source,target:Se.target,data:{}};lo(Ne)&&(te(Se),h(!0))},[te,lo]),bi=b.useCallback((Se,Ne)=>{w.edgeRules&&w.edgeRules.allowAddNodeOnEdge===!1||en({position:Se,edge:Ne})},[en,w.edgeRules]),Fs=b.useCallback(Se=>{Se.stopPropagation();const{nodes:Ne}=j.getState();if(Ne.some(nt=>nt.type===ee.TRIGGER)){const nt=xO(Ne);en({position:{x:nt[0],y:nt[1]}})}else en({trigger:!0})},[en,j]),Is=b.useCallback(()=>{const{nodes:Se}=j.getState();let Ne;const Ge=Se.find(nt=>nt.selected&&nt.type!==ee.STICKY);Ge?Ne=[Ge.position.x,Ge.position.y-80]:Ne=xO(Se),At({position:{x:Ne[0],y:Ne[1]}},{action_type:ee.STICKY,type:ee.STICKY,id:e,nodeId:e,name:"便签",action_name:"便签",connector_name:"",description:""})},[At,e,j]),Ci=b.useCallback(()=>{y()},[y]),{canvasApi:Wr}=sq({dispatch:a,reactFlow:v,setEdges:q,setNodes:le,store:j,setNodeConfigVisible:W,saveFlowRef:ht});b.useEffect(()=>{s&&s(Wr)},[s,Wr]);const Ms=w.canvas.nativeProps||{},{onNodeContextMenu:ki,onPaneContextMenu:Ps,...Ow}=Ms,Tw=b.useCallback((Se,Ne)=>{Se.ctrlKey&&Se.preventDefault(),ki==null||ki(Se,Ne)},[ki]),Gt=b.useCallback(Se=>{Se.ctrlKey&&Se.preventDefault(),Ps==null||Ps(Se)},[Ps]);return{nodes:Q,edges:L,setNodes:le,setEdges:q,unSave:d,setUnSave:h,loading:g,setLoading:k,debugVisible:p,setDebugVisible:m,autoSaveStatus:F,lastSavedTime:T,helperLineHorizontal:J,helperLineVertical:re,isPreviewMode:A,isInteractionDisabled:B,isOnline:C,showMiniMap:E,showControls:D,showCanvasHeader:S,showBackground:_,showFastOperationButtons:O,onNodesChange:qe,handleEdgesChange:Fe,handleConnect:Wn,handleEdgeAddNode:bi,handleOpenNodeSelector:Fs,handleAddNoteNode:Is,handleTidy:Ci,onEdgeMouseEnter:Le,onEdgeMouseLeave:de,onNodeMouseEnter:Te,onNodeMouseLeave:_e,onNodeContextMenu:Tw,onPaneContextMenu:Gt,updateSaveStatus:cn,setNodeFitHumanView:N,canvasApi:Wr,reactFlow:v,dispatch:a,store:j,storeEdges:Y,refreshWorkFlowNum:se,addNodes:V,addEdges:X,removeEdges:G,setNodeAddCallback:Vn,setNodeConfigVisible:W,setFlowOpStatusAction:$,autoSaveNum:tt,setLocked:l,openNodeSelector:en,handleManualAdd:At,restNativeProps:Ow,saveFlowRef:ht}}const eG=(t,e="normal")=>{const n=t.data.status;if(t.type===ee.STICKY)return e==="lighter"?"rgba(0,0,0,.5)":"rgb(206, 226, 164)";switch(n){case me.INVALID:return e==="lighter"?"#F2C000":"#FDF6D5";case me.FAILED:return e==="lighter"?"#FA170A":"#FF918B";case me.SUCCESS:case me.RUNNABLE:return e==="lighter"?"#2EC04F":"#8CDF3A";case me.RUNNING:return e==="lighter"?"#007AFF":"#D9EBFF";default:return e==="lighter"?"#51A4F6":"#00c3ff"}};function tG(t){const e=n=>eG(n);return f.jsx(ae.MiniMap,{style:{display:"flex",flexDirection:"row"},nodeStrokeColor:e,nodeStrokeWidth:3,pannable:!0,zoomable:!0,nodeColor:e,nodeBorderRadius:3,...t})}const nG=200,gd=150,il=44,EO=t=>{try{return JSON.stringify(t)}catch(e){return String(e)}},nw=t=>({id:t.id,type:t.type,position:t.position,data:t.data}),rw=t=>({id:t.id,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle,data:t.data}),vi=t=>{if(!t)return"";const e=t.data,n=(e==null?void 0:e.backendData)||void 0,r=(n==null?void 0:n.properties)||void 0;return(r==null?void 0:r.display_name)||(e==null?void 0:e.label)||(e==null?void 0:e.action_name)||(e==null?void 0:e.name)||t.id},rG=t=>t.replace(/[^a-zA-Z0-9_]/g,"_"),oG=(t,e,n,r)=>{const o=new Map;t.forEach((l,c)=>{const u=rG(l.id||`node_${c}`);o.set(l.id,u)});const i=["flowchart LR"];t.forEach(l=>{const c=o.get(l.id);if(!c)return;const u=`${l.id} ${vi(l)}`.replace(/"/g,"'");i.push(` ${c}["${u}"]`)});const s=[];let a=0;return e.forEach(l=>{const c=o.get(l.source),u=o.get(l.target);!c||!u||(i.push(` ${c} --> ${u}`),r.has(l.id)&&s.push(a),a+=1)}),s.forEach(l=>{i.push(` linkStyle ${l} stroke:#cf1322,stroke-width:2px`)}),i.join(`
|
|
91
|
+
${xU(C)} ${m}`.replace(/\s+/g," ").trim(),Y=q=>{var he;if(q.stopPropagation(),B&&B.allowAddNodeOnEdge===!1)return;const J=y(),K=(he=O.canvas.limits)==null?void 0:he.maxNodes;if(typeof K=="number"&&J.length>=K){x.message.warning("已达到画布允许的最大节点数");return}const re={x:(e+N)/2,y:(n+F)/2};g({position:re,edge:{id:t,source:l,sourceHandleId:c,target:u,targetHandleId:d,data:a},targetNode:ut.cloneDeep(D),sourceNode:ut.cloneDeep(k)})},ie=q=>{q.stopPropagation(),!($||B&&B.allowDeleteEdge===!1)&&(v([t]),Vv(w,[t]))},Q=[f.jsx("path",{id:t,className:j,d:V,style:H,fill:"none",strokeLinecap:"round",strokeLinejoin:"round",markerEnd:"url(#workflow-arrow)"},`${t}-path`),E?f.jsx(ae.EdgeLabelRenderer,{children:f.jsxs("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${X}px,${G}px)`,padding:"4px",borderRadius:"4px",opacity:a!=null&&a.isHovered?1:0,gap:"8px",zIndex:1e3,pointerEvents:"all"},className:"nodrag nopan workflow-edge-buttons",children:[!W&&(!B||B.allowAddNodeOnEdge!==!1)&&f.jsx("button",{type:"button",onClick:Y,style:{...Ws.default,...Ws.add},className:"workflow-edge-button",title:"添加节点",children:f.jsx(Z.PlusOutlined,{style:{fontSize:"16px"}})}),!$&&(!B||B.allowDeleteEdge!==!1)&&f.jsx("button",{type:"button",onClick:ie,style:{...Ws.default,...Ws.delete},className:"workflow-edge-button",title:"删除连线",children:f.jsx(Z.DeleteOutlined,{style:{fontSize:"16px"}})})]})},`${t}-buttons`):null];return a!=null&&a.label&&Q.push(f.jsx(ae.EdgeLabelRenderer,{children:f.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${X}px,${G+(P?20:0)}px)`,...o0.edge},children:a.label})},`${t}-label`)),Q};class Bt{static getEdgeTypes(){return{[xt.MAIN]:OU}}static getEdgeComponent(e){const n=Bt.getEdgeTypes();return n[e]||n[xt.MAIN]}static createEdge(e,n,r,o,i){const s=e===xt.AI?"workflow-ai-edge":"workflow-main-edge",a=e===xt.AI?"green":"#7e8186";let l={},c,u,d;if(i&&typeof i=="object"&&("sourceHandle"in i||"targetHandle"in i||"onAddNode"in i)){const h=i;c=h.sourceHandle,u=h.targetHandle,d=h.onAddNode,l=h.data||{}}return{id:n,type:e,source:r,target:o,sourceHandle:c,targetHandle:u,data:{...l,className:s,onAddNode:d},markerEnd:{type:ae.MarkerType.ArrowClosed,width:20,height:20,color:a},style:{stroke:a,strokeWidth:1},className:s}}static renderEdge(e){const n=Bt.getEdgeComponent(e.type||xt.MAIN);return f.jsx(n,{...e})}}const TU=new Set(Object.values(ee));function _U(t){var n;const e=(n=t.params)==null?void 0:n._uiNodeType;return e&&TU.has(e)?e:ee.ACTION}function NU(t){return t.map(e=>{const{_uiNodeType:n,_configSchema:r,_note:o,_debugOutput:i,_debugStatus:s,...a}=e.params||{};return{id:e.id,type:_U(e),position:e.position,data:{name:e.name,label:e.name,action_name:e.name,nodeKey:e.nodeKey,nodeVersion:e.nodeVersion,params:a,credentialInstanceId:e.credentialInstanceId,settings:e.settings,...r?{config_schema:r}:{},...o?{note:o}:{},...i!==void 0?{output:i}:{},...s!==void 0?{status:s}:{}}}})}function BU(t){return t.map((e,n)=>{const r=`${e.sourceNodeId}-${e.targetNodeId}-${n}`;return Bt.createEdge(xt.MAIN,r,e.sourceNodeId,e.targetNodeId,{sourceHandle:e.sourceOutput||"main",targetHandle:e.targetInput||"main"})}).filter(Boolean)}function FU(t){if(!t)return{workflowId:"",workflowName:"",nodes:[],edges:[],active:!1};const e=NU(t.nodes||[]),n=new Set(e.map(o=>o.id)),r=BU(t.connections||[]).filter(o=>n.has(o.source)&&n.has(o.target));return{workflowId:t.id,workflowName:t.name||"",nodes:e,edges:r,active:t.active??!1}}function IU(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function MU(t){const e=t.data,n={...(e==null?void 0:e.params)||{}};return t.type&&t.type!==ee.ACTION&&(n._uiNodeType=t.type),e!=null&&e.config_schema&&(n._configSchema=e.config_schema),e!=null&&e.note&&(n._note=e.note),(e==null?void 0:e.output)!==void 0&&(e==null?void 0:e.output)!==null&&(e==null?void 0:e.output)!==""&&(n._debugOutput=e.output),(e==null?void 0:e.status)!==void 0&&(e==null?void 0:e.status)!==null&&(n._debugStatus=e.status),{id:t.id,name:(e==null?void 0:e.label)||(e==null?void 0:e.action_name)||"",nodeKey:(e==null?void 0:e.nodeKey)||"",nodeVersion:(e==null?void 0:e.nodeVersion)||1,position:t.position,params:n,credentialInstanceId:e==null?void 0:e.credentialInstanceId,settings:e==null?void 0:e.settings}}function PU(t){return{sourceNodeId:t.source,sourceOutput:t.sourceHandle||"main",targetNodeId:t.target,targetInput:t.targetHandle||"main"}}function LU(t,e,n=""){const r=t.filter(s=>s.type!==ee.START).map(MU),o=new Set(r.map(s=>s.id)),i=e.filter(s=>o.has(s.source)&&o.has(s.target)&&s.source&&s.sourceHandle&&s.targetHandle);return{name:n,nodes:r,connections:i.map(PU)}}const rg={type:ee.START,id:"PLACEHOLDER_NODE",position:{x:100,y:250},data:{type:ee.START,name:"开始",nodeId:"PLACEHOLDER_NODE",id:"PLACEHOLDER_NODE",description:"开始节点"}},wA=t=>({label:t.action_name,description:t.connector_name,...t.action_key?{nodeKey:t.action_key}:{},...t.action_ver!==void 0?{nodeVersion:t.action_ver}:{},...Object.entries(t).reduce((e,[n,r])=>(n!=="name"&&n!=="node_schema"&&(e[n]=r),e),{})}),og=t=>({...wA(t),name:t.name});Bn.getNodeTypes();const $U=Bt.getEdgeTypes(),HU={"--edge-marker-size":"14px","--edge-stroke-width":"1px"},zU={x:0,y:0,zoom:1},jU={x:0,y:0,zoom:.8},VU={type:xt.MAIN,markerEnd:{type:ae.MarkerType.ArrowClosed,width:20,height:20,color:"#7e8186"}},WU="944",UU="core.stickyNote",{Title:qU,Text:ig}=x.Typography,GU=({opStatus:t})=>{const e=oo(),n={[We.UNPUBLISHED]:f.jsx(x.Tag,{bordered:!1,color:"orange",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.not-published"})}),[We.ONLINE]:f.jsx(x.Tag,{bordered:!1,color:"green",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.already-online"})}),[We.OFFLINE]:f.jsx(x.Tag,{bordered:!1,color:"default",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.already-offline"})}),[We.ONLINE_ING]:f.jsx(x.Tag,{bordered:!1,color:"processing",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.going-online"})}),[We.ON_WARN]:f.jsx(Nl,{to:`/link/log?warnId=${e}`,children:f.jsxs(x.Space,{size:[5,5],children:[f.jsx(Z.ExclamationCircleOutlined,{style:{color:"#faad14"}}),f.jsx(Ee.FormattedMessage,{id:"common.warning"})]})}),[We.OFF_WARN]:f.jsx(Nl,{to:`/link/log?warnId=${e}`,children:f.jsxs(x.Space,{size:[5,5],children:[f.jsx(Z.ExclamationCircleOutlined,{style:{color:"#faad14"}}),f.jsx(Ee.FormattedMessage,{id:"common.warning"})]})})};return f.jsx(f.Fragment,{children:n[t]??null})},KU=({onSave:t,readOnly:e=!1,preview:n=!1,autoSaveStatus:r=hn.IDLE,lastSavedTime:o,unSave:i,appFlowMode:s=!1,canvasApi:a})=>{var te,H;const l=Ss(),c=Ct(),u=Io(j=>j.workflow.workflowName),d=Io(j=>j.workflow.op_status),[h,p]=b.useState(!1),[m,w]=b.useState(u),[v,y]=b.useState(!1),[g,k]=b.useState(!1),A=b.useRef(null),{getNodes:C}=ae.useReactFlow(),E=C(),D=Vt(),S=D.toolbar,_=oo(),O=D.history??_i,B=((te=E.filter(j=>j.type!==ee.START))==null?void 0:te.length)>0;b.useEffect(()=>{w(u)},[u]),b.useEffect(()=>{h&&A.current&&A.current.focus()},[h]),dt.useUnmount(()=>{l(hd()),gi("")});const N=()=>{t==null||t()},F=b.useCallback(()=>{if(g)return;const j=u,Y=m.trim()||"未命名工作流";l(gi(Y)),Xv(_,{name:Y}).catch(()=>{l(gi(j))}),p(!1)},[l,m,u,_,g]),M=async()=>{y(!0);try{await kN(_),x.message.success("上线成功"),l(xs(We.ONLINE))}catch{}finally{y(!1)}},T=async()=>{y(!0);try{await xN(_),x.message.success("下线成功"),l(xs(We.OFFLINE))}catch{}finally{y(!1)}},[P,$]=x.Modal.useModal(),W=async j=>{j?await P.confirm({title:"上线提示",content:"确定启用当前流程吗?"})&&M():T()},V=async()=>{var ie;const j=d===We.ONLINE||d===We.ON_WARN,Y=()=>{var Q,le;if((Q=S==null?void 0:S.nav)!=null&&Q.onBack){S.nav.onBack();return}if((le=S==null?void 0:S.nav)!=null&&le.backTo){O.push(S.nav.backTo);return}s?O.go(-1):O.push("/link/ai-flow")};if(!j&&((ie=S==null?void 0:S.nav)!=null&&ie.confirmOnBackWhenOffline)&&i){await P.confirm({title:R("link.flow.operation_title"),content:S.nav.backConfirmMessage||"当前流程未保存,是否确认返回?"})&&Y();return}Y()},X=()=>{if(i)return f.jsx(x.Tooltip,{title:"暂未保存",children:f.jsx(x.Tag,{bordered:!1,color:"warning",children:"未保存"})});switch(r){case hn.SAVING:return f.jsx(x.Tooltip,{children:f.jsx("div",{style:{display:"flex",alignItems:"center"},children:f.jsx(Z.SyncOutlined,{spin:!0,style:{marginRight:8,color:"#1890ff"}})})});case hn.SAVED:return f.jsx(x.Tooltip,{title:`已自动保存 (${o})`,children:f.jsx("div",{style:{display:"flex",alignItems:"center"},children:f.jsxs(x.Tag,{bordered:!1,color:"green",children:["已保存"," ",f.jsx("span",{style:{fontSize:10,marginLeft:4,color:"#999"},children:o})]})})});case hn.ERROR:return f.jsx(x.Tooltip,{title:"自动保存失败",children:f.jsx(x.Badge,{status:"error",text:f.jsx("span",{children:"保存失败"})})});default:return null}},G=()=>{var Y,ie,Q,le;const j=[];return((Y=S==null?void 0:S.nav)==null?void 0:Y.showBack)!==!1&&j.push(f.jsx(x.Button,{type:"text",icon:f.jsx(Z.ArrowLeftOutlined,{className:"workflow-back-icon"}),onClick:V,children:R("app.common.word.back")},"back"),f.jsx(x.Divider,{type:"vertical"},"divider-back")),s||(h?j.push(f.jsx(x.Input,{ref:A,value:m,onChange:L=>w(L.target.value),onPressEnter:F,onBlur:F,onCompositionStart:()=>k(!0),onCompositionEnd:()=>k(!1),maxLength:30,className:"workflow-name-input",placeholder:"请输入工作流名称"},"name-input")):j.push(f.jsx("button",{className:"workflow-name",type:"button",onClick:n?void 0:()=>{var L;!e&&((L=S==null?void 0:S.flowName)==null?void 0:L.editable)!==!1&&p(!0)},children:u?f.jsxs(f.Fragment,{children:[f.jsx(qU,{level:4,className:"workflow-name-text",children:u}),!e&&!n&&((ie=S==null?void 0:S.flowName)==null?void 0:ie.editable)&&f.jsx(Z.FormOutlined,{className:"edit-icon"})]}):f.jsx(x.Skeleton.Input,{active:!0,size:"small"})},"name-display")),j.push(f.jsx(x.Divider,{type:"vertical"},"divider-name"))),n?j.push(f.jsx(ig,{type:"secondary",children:"预览模式"},"preview-text")):j.push(f.jsxs(x.Space,{size:8,children:[D.toolbar.enableOnlineButton&&f.jsxs(b.Fragment,{children:[f.jsx(ig,{children:(S==null?void 0:S.enableFlowText)||"启用流程"}),f.jsx(x.Switch,{disabled:!B,onChange:W,loading:v,checked:d===We.ONLINE||d===We.ON_WARN})]}),f.jsx(x.Divider,{type:"vertical"}),((Q=S==null?void 0:S.flowStatusTag)==null?void 0:Q.enabled)!==!1&&f.jsx("span",{style:(le=S==null?void 0:S.flowStatusTag)==null?void 0:le.style,children:f.jsx(GU,{opStatus:d})})]},"online-area")),j.push(f.jsx(x.Divider,{type:"vertical"},"divider-status")),!c&&!n&&j.push(f.jsx(ig,{type:"secondary",children:"当前流为只读模式,如需编辑,请下线流程"},"readonly-hint")),j};return f.jsxs("div",{className:"workflow-canvas-header",children:[$,f.jsx("div",{className:"workflow-heder-left-area",children:G()}),f.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[c&&!n&&X(),(S==null?void 0:S.helpDocUrl)&&f.jsx(x.Button,{icon:f.jsx(Z.QuestionCircleOutlined,{}),type:"link",onClick:()=>window.open(S.helpDocUrl,"_blank"),children:S.helpDocText||"帮助文档"}),f.jsxs(x.Space,{style:{marginLeft:16},children:[(H=S==null?void 0:S.buttons)==null?void 0:H.map(j=>f.jsx(x.Button,{style:j.style,icon:j.icon,type:j.type??"default",onClick:()=>{var Y;a&&((Y=j.onClick)==null||Y.call(j,a))},children:j.label},j.id)),c&&!n&&f.jsx(x.Tooltip,{title:"保存",children:f.jsx(x.Button,{onClick:N,type:"primary",children:"保存"})})]})]})]})},YU=({onOpenNodeSelector:t,onAddNoteNode:e,onTidyCanvas:n,panelStyle:r={},buttonStyle:o={},dangerButtonStyle:i={},showTidyButton:s=!0,buttons:a})=>{const l=[{key:"add-node",title:"打开节点选择面板",icon:f.jsx(Z.PlusOutlined,{}),onClick:t,visible:!0,danger:!1},{key:"add-note",title:"添加便签",icon:f.jsx(Z.BookOutlined,{}),onClick:e,visible:!0,danger:!1}],c=a||l,u={backgroundColor:"transparent",boxShadow:"none",marginTop:30,marginRight:20,...r},d={width:32,height:32,background:"#FFF",...o},h={...d,...i};return f.jsx(ae.Panel,{position:"top-right",style:u,children:f.jsx(x.Space,{direction:"vertical",children:c.map(p=>p.visible===!1?null:f.jsx(x.Tooltip,{placement:"left",title:p.title,children:f.jsx(x.Button,{onClick:p.onClick,type:"primary",style:p.danger?h:d,danger:p.danger,ghost:!0,icon:p.icon})},p.key))})})},XU=b.memo(({loading:t})=>t?f.jsx("div",{style:{position:"absolute",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(255, 255, 255, 0.7)",display:"flex",justifyContent:"center",alignItems:"center",zIndex:1e3,backdropFilter:"blur(2px)"},children:f.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:12},children:[f.jsx(x.Spin,{size:"large"}),f.jsx("span",{style:{color:"#1890ff",fontSize:16},children:"正在加载工作流..."})]})}):null),JU=b.memo(()=>f.jsx("svg",{style:{position:"absolute",width:0,height:0},children:f.jsx("defs",{children:f.jsx("marker",{id:"workflow-arrow",viewBox:"-10 -10 20 20",refX:"3",refY:"0",markerWidth:"12.5",markerHeight:"12.5",markerUnits:"strokeWidth",orient:"auto-start-reverse",children:f.jsx("polyline",{strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4",strokeWidth:"3",stroke:"context-stroke",fill:"context-stroke"})})})})),RU={width:"100%",height:"100%",position:"absolute",zIndex:10,pointerEvents:"none"},QU=t=>({width:t.width,height:t.height,transform:t.transform});function ZU({horizontal:t,vertical:e}){const{width:n,height:r,transform:o}=ae.useStore(QU),i=b.useRef(null);return b.useEffect(()=>{const s=i.current,a=s==null?void 0:s.getContext("2d");if(!a||!s)return;const l=window.devicePixelRatio;s.width=n*l,s.height=r*l,a.scale(l,l),a.clearRect(0,0,n,r),a.strokeStyle="#0041d0",typeof e=="number"&&(a.moveTo(e*o[2]+o[0],0),a.lineTo(e*o[2]+o[0],r),a.stroke()),typeof t=="number"&&(a.moveTo(0,t*o[2]+o[1]),a.lineTo(n,t*o[2]+o[1]),a.stroke())},[n,r,o,t,e]),f.jsx("canvas",{ref:i,className:"react-flow__canvas",style:RU})}const eq=b.memo(ZU);function tq(t){const{workflowId:e,strategy:n,setNodes:r,setEdges:o,fitView:i,setLoading:s,setUnSave:a,dispatch:l,setFlowOpStatusAction:c,refreshWorkFlowNum:u}=t;b.useEffect(()=>{if(!e)return;let d=!1;return s(!0),n.loadFlow(e).then(h=>{if(d)return;l(gi(h.name)),l(mA(h.executionControl??null)),h.opStatus&&c(h.opStatus);const{nodes:p,edges:m}=h;p.length>0?(n.requiresTriggerNode?p.some(v=>v.type===ee.TRIGGER)?r(p):(p.unshift(rg),r([rg,...p])):r(p),n.requiresTriggerNode&&i({minZoom:.3,maxZoom:1})):r([rg]),o(m.length>0?m:[])}).catch(h=>{d||(console.error("[WorkflowCanvas] 加载工作流失败:",h),r([]),o([]))}).finally(()=>{d||(s(!1),setTimeout(()=>{a(!1)},500))}),()=>{d=!0}},[e,n,l,u,i])}const wi="[workflow:schema-render]";async function nq(t,e){var n,r,o,i,s,a,l,c;try{console.info(`${wi} resolve ports from schema`,{nodeKey:t,nodeVersion:e});const u=await Zu(t,e);if(!u)return console.warn(`${wi} cannot resolve ports without schema`,{nodeKey:t,nodeVersion:e}),{firstInputPort:null,firstOutputPort:null,loopPort:null,donePort:null};const d=((r=(n=u.inputs)==null?void 0:n[0])==null?void 0:r.name)||null,h=((i=(o=u.outputs)==null?void 0:o[0])==null?void 0:i.name)||null,p=((a=(s=u.outputs)==null?void 0:s.find(w=>w.name==="loop"))==null?void 0:a.name)||null,m=((c=(l=u.outputs)==null?void 0:l.find(w=>w.name==="done"))==null?void 0:c.name)||null;return console.info(`${wi} resolved ports from schema`,{nodeKey:t,nodeVersion:e,firstInputPort:d,firstOutputPort:h,loopPort:p,donePort:m}),{firstInputPort:d,firstOutputPort:h,loopPort:p,donePort:m}}catch(u){return console.error(`${wi} resolve ports from schema failed`,{nodeKey:t,nodeVersion:e,err:u}),{firstInputPort:null,firstOutputPort:null,loopPort:null,donePort:null}}}function rq(t){const{workflowId:e,strategy:n,store:r,addNodes:o,addEdges:i,removeEdges:s,handleEdgeAddNode:a,setNodeConfigVisible:l,setNodeFitHumanView:c,saveFlow:u}=t;return async(d,h)=>{var B;if(!e)return;let p=null;const{nodes:m}=r.getState(),w=h.nodeKey||h.action_key||h.id,v=h.nodeVersion??h.action_ver;if(console.info(`${wi} add next node`,{workflowId:e,nodeType:h.type,actionId:h.id,nodeSchemaKey:w,nodeSchemaVersion:v,trigger:!!d.trigger,insertOnEdge:!!d.edge}),d.trigger){const{nodeId:N,nodeData:F}=await n.createNode({workflowId:e,nodeType:ee.TRIGGER,actionId:h.id,configSchema:h.config_schema||{},position:{x:100,y:250},isTrigger:!0,icon:h.icon,name:h.name||h.action_name,connectorName:h.connector_name,nodeVersion:h.nodeVersion,existingNodes:m});p=N;const M=Bn.createNode(ee.TRIGGER,N,og({...h,...F}),{x:100,y:250});o([M]),c(N),l(N),window.__AI_FLOW_IN_QUEUE_NODE_ID=p,await u();return}const{nodeId:y,nodeData:g}=await n.createNode({workflowId:e,nodeType:h.action_type,actionId:h.id,configSchema:h.config_schema||{},position:d.position,icon:h.icon,name:h.name||h.action_name,connectorName:h.connector_name,nodeVersion:h.nodeVersion,existingNodes:m});p=y;const k=Bn.createNode(h.type,y,og({...h,...g}),d.position);if(o([k]),c(y),h.type===ee.STICKY){window.__AI_FLOW_IN_QUEUE_NODE_ID=p,await u();return}const{firstInputPort:A,firstOutputPort:C,loopPort:E,donePort:D}=await nq(w,v);if(!A||!C){console.warn(`${wi} skip edge creation because schema ports are incomplete`,{nodeId:y,actionId:h.id,nodeSchemaKey:w,nodeSchemaVersion:v,firstInputPort:A,firstOutputPort:C}),window.__AI_FLOW_IN_QUEUE_NODE_ID=p,await u();return}const S=h.type===ee.LOOP||h.type===ee.SELF_LOOP,_=E??"loop",O=D??"done";if(S&&(!E||!D)&&console.warn(`${wi} loop schema ports missing, fallback to conventional handles`,{nodeId:y,nodeSchemaKey:w,nodeSchemaVersion:v,loopPort:E,donePort:D}),d.edge){const N=Bt.createEdge(xt.MAIN,`${d.edge.source}-${y}-${Date.now()}`,d.edge.source,y,{sourceHandle:d.edge.sourceHandleId,targetHandle:A,onAddNode:a,data:{undeletable:!1}}),F=Bt.createEdge(xt.MAIN,`${y}-${d.edge.target}-${Date.now()}`,y,d.edge.target,{sourceHandle:C,targetHandle:d.edge.targetHandle||d.edge.targetHandleId,onAddNode:a,data:{}});if(S){const M=Bt.createEdge(xt.MAIN,`loop-self-edge-${y}`,y,y,{sourceHandle:_,targetHandle:A}),T=Bt.createEdge(xt.MAIN,`loop-edge-target-${y}`,y,d.edge.target,{sourceHandle:O,targetHandle:d.edge.targetHandle||d.edge.targetHandleId,onAddNode:a,data:{undeletable:!0}});i([M,N,T])}else i([N,F]);s([d.edge.id]),window.__AI_FLOW_IN_QUEUE_NODE_ID=p,await u();return}if(S){const N=Bt.createEdge(xt.MAIN,`loop-self-edge-${y}`,y,y,{sourceHandle:_,targetHandle:A});i([N])}if(d.sourceNodeId&&d.sourceHandle){const N=Bt.createEdge(xt.MAIN,`${d.sourceNodeId}-${y}-${Date.now()}`,d.sourceNodeId,y,{sourceHandle:d.sourceHandle,targetHandle:A,onAddNode:a});if(i([N]),d.sourceNodeId===d.targetNodeId&&d.targetNodeId){const F=Bt.createEdge(xt.MAIN,`loop-back-${y}-${d.targetNodeId}`,y,d.targetNodeId,{sourceHandle:S?_:C,targetHandle:A,onAddNode:a,data:{undeletable:!1}});i([F]),(B=d.edge)!=null&&B.id&&s([d.edge.id])}}window.__AI_FLOW_IN_QUEUE_NODE_ID=p,await u()}}const oq="[workflow:schema-render]";function iq({workflowId:t,strategy:e,store:n,addNodes:r,addEdges:o,removeEdges:i,setNodeAddCallback:s,handleEdgeAddNode:a,setNodeConfigVisible:l,setNodeFitHumanView:c,saveFlow:u,engineMode:d}){const h=b.useCallback(async(w,v)=>{if(!t)return;let y=null;const{nodes:g}=n.getState(),k=e.convertNodeData??wA,A=v.action_key||v.nodeKey,C=v.action_ver??v.nodeVersion,E=!!A;if(console.info(`${oq} add classic node`,{workflowId:t,nodeType:v.type,actionId:v.id,actionKey:A,actionVer:C,isNextCompatibleNode:E,trigger:!!w.trigger,insertOnEdge:!!w.edge}),w.trigger){const{nodeId:D,nodeData:S}=await e.createNode({workflowId:t,nodeType:ee.TRIGGER,actionId:v.id,actionKey:A,actionVer:C,configSchema:v.config_schema||{},position:{x:100,y:250},isTrigger:!0,icon:v.icon,name:v.name||v.action_name,connectorName:v.connector_name,nodeVersion:v.nodeVersion,existingNodes:g});y=D;const _=Bn.createNode(ee.TRIGGER,D,k({...v,...S}),{x:100,y:250});r([_]),c(D),l(D)}else{const{nodeId:D,nodeData:S}=await e.createNode({workflowId:t,nodeType:v.action_type,actionId:v.id,actionKey:A,actionVer:C,configSchema:v.config_schema||{},position:w.position,icon:v.icon,name:v.name||v.action_name,connectorName:v.connector_name,nodeVersion:v.nodeVersion,existingNodes:g});y=D;const _=Bn.createNode(v.type,D,k({...v,...S}),w.position);if(r([_]),c(D),v.type===ee.STICKY)return;if(w.edge){const O=Bt.createEdge(xt.MAIN,`${w.edge.source}-${D}-${Date.now()}`,w.edge.source,D,{sourceHandle:w.edge.sourceHandleId,targetHandle:Ie.INPUT,onAddNode:a,data:{undeletable:!1}}),B=Bt.createEdge(xt.MAIN,`${D}-${w.edge.target}-${Date.now()}`,D,w.edge.target,{sourceHandle:Ie.OUTPUT,targetHandle:w.edge.targetHandle||w.edge.targetHandleId,onAddNode:a,data:{}});if(v.type===ee.LOOP||v.type===ee.SELF_LOOP){const N=Bt.createEdge(xt.MAIN,`loop-self-edge-${D}`,D,D,{sourceHandle:"loop",targetHandle:Ie.INPUT}),F=Bt.createEdge(xt.MAIN,`loop-edge-target-${D}`,D,w.edge.target,{sourceHandle:"done",targetHandle:w.edge.targetHandle||w.edge.targetHandleId,onAddNode:a,data:{undeletable:!0}});o([N,O,F])}else o([O,B]);i([w.edge.id]),window.__AI_FLOW_IN_QUEUE_NODE_ID=y,await u();return}if(v.type===ee.LOOP||v.type===ee.SELF_LOOP){const O=Bt.createEdge(xt.MAIN,`loop-self-edge-${D}`,D,D,{sourceHandle:"loop",targetHandle:Ie.INPUT});o([O])}if(w.sourceNodeId&&w.sourceHandle){const O=Bt.createEdge(xt.MAIN,`${w.sourceNodeId}-${D}-${Date.now()}`,w.sourceNodeId,D,{sourceHandle:w.sourceHandle,targetHandle:Ie.INPUT,onAddNode:a});if(o([O]),w.sourceNodeId===w.targetNodeId&&w.targetNodeId){const B=Bt.createEdge(xt.MAIN,`loop-back-${D}-${w.targetNodeId}`,D,w.targetNodeId,{sourceHandle:v.type===ee.LOOP||v.type===ee.SELF_LOOP?"loop":Ie.OUTPUT,targetHandle:Ie.INPUT,onAddNode:a,data:{undeletable:!1}});o([B]),i([w.edge.id])}}else{window.__AI_FLOW_IN_QUEUE_NODE_ID=y,await u();return}}window.__AI_FLOW_IN_QUEUE_NODE_ID=y,await u()},[o,r,a,i,u,l,c,n,e,t]),p=b.useMemo(()=>rq({workflowId:t,strategy:e,store:n,addNodes:r,addEdges:o,removeEdges:i,handleEdgeAddNode:a,setNodeConfigVisible:l,setNodeFitHumanView:c,saveFlow:u}),[t,e,n,r,o,i,a,l,c,u]),m=d===or.NEXT?p:h;b.useEffect(()=>(s(m),()=>{s(()=>{})}),[m,s])}function sq({dispatch:t,reactFlow:e,setEdges:n,setNodes:r,store:o,setNodeConfigVisible:i,saveFlowRef:s}){const a=b.useRef(new Map);return{canvasApi:b.useMemo(()=>({init(){},destroy(){t(hd()),n([]),r([]),a.current.clear()},refresh(){t(pA())},setFlowOpStatus(c){t(xs(c))},getData(){const{nodes:c,edges:u}=o.getState();return{nodes:c.map(d=>{var h;return{id:d.id,type:d.type||"",position:d.position,data:d.data,disabled:((h=d.data)==null?void 0:h.closed)==="1"}}),edges:u.map(d=>({id:d.id,source:d.source,target:d.target,data:d.data}))}},setData(c){const u=c.nodes.map(h=>({id:h.id,type:h.type,position:h.position,data:h.data})),d=c.edges.map(h=>({id:h.id,source:h.source,target:h.target,data:h.data}));r(u),n(d)},exportJSON(){return JSON.stringify(this.getData())},importJSON(c){try{const u=typeof c=="string"?JSON.parse(c):c;this.setData(u)}catch(u){console.error("导入 JSON 失败",u)}},zoomIn(){e.zoomIn()},zoomOut(){e.zoomOut()},zoomTo(c){e.zoomTo(c)},fitView(){e.fitView()},center(){e.fitView({padding:.2})},addNode(c){const u=c.id||`${Date.now()}`,d={id:u,type:c.type,position:c.position,data:c.data};return r(h=>[...h,d]),u},updateNode(c,u){r(d=>d.map(h=>h.id===c?{...h,...u,position:u.position||h.position,data:u.data?{...h.data,...u.data}:h.data}:h))},deleteNode(c){r(u=>u.filter(d=>d.id!==c)),n(u=>u.filter(d=>d.source!==c&&d.target!==c))},getNode(c){var h;const{nodes:u}=o.getState(),d=u.find(p=>p.id===c);return d?{id:d.id,type:d.type||"",position:d.position,data:d.data,disabled:((h=d.data)==null?void 0:h.closed)==="1"}:null},selectNode(){},clearSelection(){e.setNodes(c=>c.map(u=>({...u,selected:!1})))},moveNode(c,u){this.updateNode(c,{position:u})},enableNode(c){this.updateNode(c,{disabled:!1})},disableNode(c){this.updateNode(c,{disabled:!0})},addEdge(c){const u=c.id||`${c.source}-${c.target}-${Date.now()}`,d={id:u,source:c.source,target:c.target,data:c.data};return n(h=>[...h,d]),u},deleteEdge(c){n(u=>u.filter(d=>d.id!==c))},deleteEdgesBetween(c,u){n(d=>d.filter(h=>h.source!==c||h.target!==u))},openNodePanel(c){i(c)},closeNodePanel(){i(null)},isPanelOpen(){const{currentNodeConfigVisibleId:c}=o.getState();return!!c},async runNodeTest(){return Promise.resolve(null)},async saveFlow(){return s.current()},on(c,u){return a.current.has(c)||a.current.set(c,new Set),a.current.get(c).add(u),()=>{this.off(c,u)}},off(c,u){const d=a.current.get(c);d&&(u?d.delete(u):d.clear(),d.size===0&&a.current.delete(c))},emit(c,u){const d=a.current.get(c);d&&d.forEach(h=>{try{h(u)}catch(p){console.error(`事件 "${c}" 的处理器执行出错:`,p)}})},once(c,u){const d=h=>{u(h),this.off(c,d)};this.on(c,d)}}),[t,e,n,r,o,i]),eventListenersRef:a}}function aq(t,e,n=5){var l,c,u,d;const r={horizontal:void 0,vertical:void 0,snapPosition:{x:void 0,y:void 0}},o=e.find(h=>h.id===t.id);if(!o||!t.position)return r;const i={left:t.position.x,right:t.position.x+(((l=o.measured)==null?void 0:l.width)??0),top:t.position.y,bottom:t.position.y+(((c=o.measured)==null?void 0:c.height)??0),width:((u=o.measured)==null?void 0:u.width)??0,height:((d=o.measured)==null?void 0:d.height)??0};let s=n,a=n;return e.filter(h=>h.id!==o.id).reduce((h,p)=>{var D,S,_,O;const m={left:p.position.x,right:p.position.x+(((D=p.measured)==null?void 0:D.width)??0),top:p.position.y,bottom:p.position.y+(((S=p.measured)==null?void 0:S.height)??0),width:((_=p.measured)==null?void 0:_.width)??0,height:((O=p.measured)==null?void 0:O.height)??0},w=Math.abs(i.left-m.left);w<a&&(h.snapPosition.x=m.left,h.vertical=m.left,a=w);const v=Math.abs(i.right-m.right);v<a&&(h.snapPosition.x=m.right-i.width,h.vertical=m.right,a=v);const y=Math.abs(i.left-m.right);y<a&&(h.snapPosition.x=m.right,h.vertical=m.right,a=y);const g=Math.abs(i.right-m.left);g<a&&(h.snapPosition.x=m.left-i.width,h.vertical=m.left,a=g);const k=Math.abs(i.top-m.top);k<s&&(h.snapPosition.y=m.top,h.horizontal=m.top,s=k);const A=Math.abs(i.bottom-m.top);A<s&&(h.snapPosition.y=m.top-i.height,h.horizontal=m.top,s=A);const C=Math.abs(i.bottom-m.bottom);C<s&&(h.snapPosition.y=m.bottom-i.height,h.horizontal=m.bottom,s=C);const E=Math.abs(i.top-m.bottom);return E<s&&(h.snapPosition.y=m.bottom,h.horizontal=m.bottom,s=E),h},r)}const lq=({enabled:t=!0,message:e="您有未保存的更改,确定要离开吗?"})=>{b.useEffect(()=>{if(!t)return;let n;return(()=>{n=_i.block(o=>{t?window.confirm(e)&&(n==null||n(),o.retry()):(n==null||n(),o.retry())})})(),()=>{n==null||n()}},[t,e]),b.useEffect(()=>{if(!t)return;const n=r=>{if(t)return r.preventDefault(),r.returnValue=e,e};return window.addEventListener("beforeunload",n),()=>window.removeEventListener("beforeunload",n)},[t,e])};var sg,vA;function ag(){if(vA)return sg;vA=1;var t="\0",e="\0",n="";class r{constructor(u){it(this,"_isDirected",!0);it(this,"_isMultigraph",!1);it(this,"_isCompound",!1);it(this,"_label");it(this,"_defaultNodeLabelFn",()=>{});it(this,"_defaultEdgeLabelFn",()=>{});it(this,"_nodes",{});it(this,"_in",{});it(this,"_preds",{});it(this,"_out",{});it(this,"_sucs",{});it(this,"_edgeObjs",{});it(this,"_edgeLabels",{});it(this,"_nodeCount",0);it(this,"_edgeCount",0);it(this,"_parent");it(this,"_children");u&&(this._isDirected=Object.hasOwn(u,"directed")?u.directed:!0,this._isMultigraph=Object.hasOwn(u,"multigraph")?u.multigraph:!1,this._isCompound=Object.hasOwn(u,"compound")?u.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[e]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(u){return this._label=u,this}graph(){return this._label}setDefaultNodeLabel(u){return this._defaultNodeLabelFn=u,typeof u!="function"&&(this._defaultNodeLabelFn=()=>u),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var u=this;return this.nodes().filter(d=>Object.keys(u._in[d]).length===0)}sinks(){var u=this;return this.nodes().filter(d=>Object.keys(u._out[d]).length===0)}setNodes(u,d){var h=arguments,p=this;return u.forEach(function(m){h.length>1?p.setNode(m,d):p.setNode(m)}),this}setNode(u,d){return Object.hasOwn(this._nodes,u)?(arguments.length>1&&(this._nodes[u]=d),this):(this._nodes[u]=arguments.length>1?d:this._defaultNodeLabelFn(u),this._isCompound&&(this._parent[u]=e,this._children[u]={},this._children[e][u]=!0),this._in[u]={},this._preds[u]={},this._out[u]={},this._sucs[u]={},++this._nodeCount,this)}node(u){return this._nodes[u]}hasNode(u){return Object.hasOwn(this._nodes,u)}removeNode(u){var d=this;if(Object.hasOwn(this._nodes,u)){var h=p=>d.removeEdge(d._edgeObjs[p]);delete this._nodes[u],this._isCompound&&(this._removeFromParentsChildList(u),delete this._parent[u],this.children(u).forEach(function(p){d.setParent(p)}),delete this._children[u]),Object.keys(this._in[u]).forEach(h),delete this._in[u],delete this._preds[u],Object.keys(this._out[u]).forEach(h),delete this._out[u],delete this._sucs[u],--this._nodeCount}return this}setParent(u,d){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(d===void 0)d=e;else{d+="";for(var h=d;h!==void 0;h=this.parent(h))if(h===u)throw new Error("Setting "+d+" as parent of "+u+" would create a cycle");this.setNode(d)}return this.setNode(u),this._removeFromParentsChildList(u),this._parent[u]=d,this._children[d][u]=!0,this}_removeFromParentsChildList(u){delete this._children[this._parent[u]][u]}parent(u){if(this._isCompound){var d=this._parent[u];if(d!==e)return d}}children(u=e){if(this._isCompound){var d=this._children[u];if(d)return Object.keys(d)}else{if(u===e)return this.nodes();if(this.hasNode(u))return[]}}predecessors(u){var d=this._preds[u];if(d)return Object.keys(d)}successors(u){var d=this._sucs[u];if(d)return Object.keys(d)}neighbors(u){var d=this.predecessors(u);if(d){const p=new Set(d);for(var h of this.successors(u))p.add(h);return Array.from(p.values())}}isLeaf(u){var d;return this.isDirected()?d=this.successors(u):d=this.neighbors(u),d.length===0}filterNodes(u){var d=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});d.setGraph(this.graph());var h=this;Object.entries(this._nodes).forEach(function([w,v]){u(w)&&d.setNode(w,v)}),Object.values(this._edgeObjs).forEach(function(w){d.hasNode(w.v)&&d.hasNode(w.w)&&d.setEdge(w,h.edge(w))});var p={};function m(w){var v=h.parent(w);return v===void 0||d.hasNode(v)?(p[w]=v,v):v in p?p[v]:m(v)}return this._isCompound&&d.nodes().forEach(w=>d.setParent(w,m(w))),d}setDefaultEdgeLabel(u){return this._defaultEdgeLabelFn=u,typeof u!="function"&&(this._defaultEdgeLabelFn=()=>u),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(u,d){var h=this,p=arguments;return u.reduce(function(m,w){return p.length>1?h.setEdge(m,w,d):h.setEdge(m,w),w}),this}setEdge(){var u,d,h,p,m=!1,w=arguments[0];typeof w=="object"&&w!==null&&"v"in w?(u=w.v,d=w.w,h=w.name,arguments.length===2&&(p=arguments[1],m=!0)):(u=w,d=arguments[1],h=arguments[3],arguments.length>2&&(p=arguments[2],m=!0)),u=""+u,d=""+d,h!==void 0&&(h=""+h);var v=s(this._isDirected,u,d,h);if(Object.hasOwn(this._edgeLabels,v))return m&&(this._edgeLabels[v]=p),this;if(h!==void 0&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(u),this.setNode(d),this._edgeLabels[v]=m?p:this._defaultEdgeLabelFn(u,d,h);var y=a(this._isDirected,u,d,h);return u=y.v,d=y.w,Object.freeze(y),this._edgeObjs[v]=y,o(this._preds[d],u),o(this._sucs[u],d),this._in[d][v]=y,this._out[u][v]=y,this._edgeCount++,this}edge(u,d,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,h);return this._edgeLabels[p]}edgeAsObj(){const u=this.edge(...arguments);return typeof u!="object"?{label:u}:u}hasEdge(u,d,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,h);return Object.hasOwn(this._edgeLabels,p)}removeEdge(u,d,h){var p=arguments.length===1?l(this._isDirected,arguments[0]):s(this._isDirected,u,d,h),m=this._edgeObjs[p];return m&&(u=m.v,d=m.w,delete this._edgeLabels[p],delete this._edgeObjs[p],i(this._preds[d],u),i(this._sucs[u],d),delete this._in[d][p],delete this._out[u][p],this._edgeCount--),this}inEdges(u,d){var h=this._in[u];if(h){var p=Object.values(h);return d?p.filter(m=>m.v===d):p}}outEdges(u,d){var h=this._out[u];if(h){var p=Object.values(h);return d?p.filter(m=>m.w===d):p}}nodeEdges(u,d){var h=this.inEdges(u,d);if(h)return h.concat(this.outEdges(u,d))}}function o(c,u){c[u]?c[u]++:c[u]=1}function i(c,u){--c[u]||delete c[u]}function s(c,u,d,h){var p=""+u,m=""+d;if(!c&&p>m){var w=p;p=m,m=w}return p+n+m+n+(h===void 0?t:h)}function a(c,u,d,h){var p=""+u,m=""+d;if(!c&&p>m){var w=p;p=m,m=w}var v={v:p,w:m};return h&&(v.name=h),v}function l(c,u){return s(c,u.v,u.w,u.name)}return sg=r,sg}var lg,yA;function cq(){return yA||(yA=1,lg="2.2.4"),lg}var cg,bA;function uq(){return bA||(bA=1,cg={Graph:ag(),version:cq()}),cg}var ug,CA;function dq(){if(CA)return ug;CA=1;var t=ag();ug={write:e,read:o};function e(i){var s={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:n(i),edges:r(i)};return i.graph()!==void 0&&(s.value=structuredClone(i.graph())),s}function n(i){return i.nodes().map(function(s){var a=i.node(s),l=i.parent(s),c={v:s};return a!==void 0&&(c.value=a),l!==void 0&&(c.parent=l),c})}function r(i){return i.edges().map(function(s){var a=i.edge(s),l={v:s.v,w:s.w};return s.name!==void 0&&(l.name=s.name),a!==void 0&&(l.value=a),l})}function o(i){var s=new t(i.options).setGraph(i.value);return i.nodes.forEach(function(a){s.setNode(a.v,a.value),a.parent&&s.setParent(a.v,a.parent)}),i.edges.forEach(function(a){s.setEdge({v:a.v,w:a.w,name:a.name},a.value)}),s}return ug}var dg,kA;function fq(){if(kA)return dg;kA=1,dg=t;function t(e){var n={},r=[],o;function i(s){Object.hasOwn(n,s)||(n[s]=!0,o.push(s),e.successors(s).forEach(i),e.predecessors(s).forEach(i))}return e.nodes().forEach(function(s){o=[],i(s),o.length&&r.push(o)}),r}return dg}var fg,xA;function SA(){if(xA)return fg;xA=1;class t{constructor(){it(this,"_arr",[]);it(this,"_keyIndices",{})}size(){return this._arr.length}keys(){return this._arr.map(function(n){return n.key})}has(n){return Object.hasOwn(this._keyIndices,n)}priority(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority}min(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key}add(n,r){var o=this._keyIndices;if(n=String(n),!Object.hasOwn(o,n)){var i=this._arr,s=i.length;return o[n]=s,i.push({key:n,priority:r}),this._decrease(s),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key}decrease(n,r){var o=this._keyIndices[n];if(r>this._arr[o].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[o].priority+" New: "+r);this._arr[o].priority=r,this._decrease(o)}_heapify(n){var r=this._arr,o=2*n,i=o+1,s=n;o<r.length&&(s=r[o].priority<r[s].priority?o:s,i<r.length&&(s=r[i].priority<r[s].priority?i:s),s!==n&&(this._swap(n,s),this._heapify(s)))}_decrease(n){for(var r=this._arr,o=r[n].priority,i;n!==0&&(i=n>>1,!(r[i].priority<o));)this._swap(n,i),n=i}_swap(n,r){var o=this._arr,i=this._keyIndices,s=o[n],a=o[r];o[n]=a,o[r]=s,i[a.key]=n,i[s.key]=r}}return fg=t,fg}var hg,EA;function DA(){if(EA)return hg;EA=1;var t=SA();hg=n;var e=()=>1;function n(o,i,s,a){return r(o,String(i),s||e,a||function(l){return o.outEdges(l)})}function r(o,i,s,a){var l={},c=new t,u,d,h=function(p){var m=p.v!==u?p.v:p.w,w=l[m],v=s(p),y=d.distance+v;if(v<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+p+" Weight: "+v);y<w.distance&&(w.distance=y,w.predecessor=u,c.decrease(m,y))};for(o.nodes().forEach(function(p){var m=p===i?0:Number.POSITIVE_INFINITY;l[p]={distance:m},c.add(p,m)});c.size()>0&&(u=c.removeMin(),d=l[u],d.distance!==Number.POSITIVE_INFINITY);)a(u).forEach(h);return l}return hg}var pg,AA;function hq(){if(AA)return pg;AA=1;var t=DA();pg=e;function e(n,r,o){return n.nodes().reduce(function(i,s){return i[s]=t(n,s,r,o),i},{})}return pg}var mg,OA;function TA(){if(OA)return mg;OA=1,mg=t;function t(e){var n=0,r=[],o={},i=[];function s(a){var l=o[a]={onStack:!0,lowlink:n,index:n++};if(r.push(a),e.successors(a).forEach(function(d){Object.hasOwn(o,d)?o[d].onStack&&(l.lowlink=Math.min(l.lowlink,o[d].index)):(s(d),l.lowlink=Math.min(l.lowlink,o[d].lowlink))}),l.lowlink===l.index){var c=[],u;do u=r.pop(),o[u].onStack=!1,c.push(u);while(a!==u);i.push(c)}}return e.nodes().forEach(function(a){Object.hasOwn(o,a)||s(a)}),i}return mg}var gg,_A;function pq(){if(_A)return gg;_A=1;var t=TA();gg=e;function e(n){return t(n).filter(function(r){return r.length>1||r.length===1&&n.hasEdge(r[0],r[0])})}return gg}var wg,NA;function mq(){if(NA)return wg;NA=1,wg=e;var t=()=>1;function e(r,o,i){return n(r,o||t,i||function(s){return r.outEdges(s)})}function n(r,o,i){var s={},a=r.nodes();return a.forEach(function(l){s[l]={},s[l][l]={distance:0},a.forEach(function(c){l!==c&&(s[l][c]={distance:Number.POSITIVE_INFINITY})}),i(l).forEach(function(c){var u=c.v===l?c.w:c.v,d=o(c);s[l][u]={distance:d,predecessor:l}})}),a.forEach(function(l){var c=s[l];a.forEach(function(u){var d=s[u];a.forEach(function(h){var p=d[l],m=c[h],w=d[h],v=p.distance+m.distance;v<w.distance&&(w.distance=v,w.predecessor=m.predecessor)})})}),s}return wg}var vg,BA;function FA(){if(BA)return vg;BA=1;function t(n){var r={},o={},i=[];function s(a){if(Object.hasOwn(o,a))throw new e;Object.hasOwn(r,a)||(o[a]=!0,r[a]=!0,n.predecessors(a).forEach(s),delete o[a],i.push(a))}if(n.sinks().forEach(s),Object.keys(r).length!==n.nodeCount())throw new e;return i}class e extends Error{constructor(){super(...arguments)}}return vg=t,t.CycleException=e,vg}var yg,IA;function gq(){if(IA)return yg;IA=1;var t=FA();yg=e;function e(n){try{t(n)}catch(r){if(r instanceof t.CycleException)return!1;throw r}return!0}return yg}var bg,MA;function PA(){if(MA)return bg;MA=1,bg=t;function t(o,i,s){Array.isArray(i)||(i=[i]);var a=o.isDirected()?d=>o.successors(d):d=>o.neighbors(d),l=s==="post"?e:n,c=[],u={};return i.forEach(d=>{if(!o.hasNode(d))throw new Error("Graph does not have node: "+d);l(d,a,u,c)}),c}function e(o,i,s,a){for(var l=[[o,!1]];l.length>0;){var c=l.pop();c[1]?a.push(c[0]):Object.hasOwn(s,c[0])||(s[c[0]]=!0,l.push([c[0],!0]),r(i(c[0]),u=>l.push([u,!1])))}}function n(o,i,s,a){for(var l=[o];l.length>0;){var c=l.pop();Object.hasOwn(s,c)||(s[c]=!0,a.push(c),r(i(c),u=>l.push(u)))}}function r(o,i){for(var s=o.length;s--;)i(o[s],s,o);return o}return bg}var Cg,LA;function wq(){if(LA)return Cg;LA=1;var t=PA();Cg=e;function e(n,r){return t(n,r,"post")}return Cg}var kg,$A;function vq(){if($A)return kg;$A=1;var t=PA();kg=e;function e(n,r){return t(n,r,"pre")}return kg}var xg,HA;function yq(){if(HA)return xg;HA=1;var t=ag(),e=SA();xg=n;function n(r,o){var i=new t,s={},a=new e,l;function c(d){var h=d.v===l?d.w:d.v,p=a.priority(h);if(p!==void 0){var m=o(d);m<p&&(s[h]=l,a.decrease(h,m))}}if(r.nodeCount()===0)return i;r.nodes().forEach(function(d){a.add(d,Number.POSITIVE_INFINITY),i.setNode(d)}),a.decrease(r.nodes()[0],0);for(var u=!1;a.size()>0;){if(l=a.removeMin(),Object.hasOwn(s,l))i.setEdge(l,s[l]);else{if(u)throw new Error("Input graph is not connected: "+r);u=!0}r.nodeEdges(l).forEach(c)}return i}return xg}var Sg,zA;function bq(){return zA||(zA=1,Sg={components:fq(),dijkstra:DA(),dijkstraAll:hq(),findCycles:pq(),floydWarshall:mq(),isAcyclic:gq(),postorder:wq(),preorder:vq(),prim:yq(),tarjan:TA(),topsort:FA()}),Sg}var Eg,jA;function gr(){if(jA)return Eg;jA=1;var t=uq();return Eg={Graph:t.Graph,json:dq(),alg:bq(),version:t.version},Eg}var Dg,VA;function Cq(){if(VA)return Dg;VA=1;class t{constructor(){let o={};o._next=o._prev=o,this._sentinel=o}dequeue(){let o=this._sentinel,i=o._prev;if(i!==o)return e(i),i}enqueue(o){let i=this._sentinel;o._prev&&o._next&&e(o),o._next=i._next,i._next._prev=o,i._next=o,o._prev=i}toString(){let o=[],i=this._sentinel,s=i._prev;for(;s!==i;)o.push(JSON.stringify(s,n)),s=s._prev;return"["+o.join(", ")+"]"}}function e(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,o){if(r!=="_next"&&r!=="_prev")return o}return Dg=t,Dg}var Ag,WA;function kq(){if(WA)return Ag;WA=1;let t=gr().Graph,e=Cq();Ag=r;let n=()=>1;function r(c,u){if(c.nodeCount()<=1)return[];let d=s(c,u||n);return o(d.graph,d.buckets,d.zeroIdx).flatMap(p=>c.outEdges(p.v,p.w))}function o(c,u,d){let h=[],p=u[u.length-1],m=u[0],w;for(;c.nodeCount();){for(;w=m.dequeue();)i(c,u,d,w);for(;w=p.dequeue();)i(c,u,d,w);if(c.nodeCount()){for(let v=u.length-2;v>0;--v)if(w=u[v].dequeue(),w){h=h.concat(i(c,u,d,w,!0));break}}}return h}function i(c,u,d,h,p){let m=p?[]:void 0;return c.inEdges(h.v).forEach(w=>{let v=c.edge(w),y=c.node(w.v);p&&m.push({v:w.v,w:w.w}),y.out-=v,a(u,d,y)}),c.outEdges(h.v).forEach(w=>{let v=c.edge(w),y=w.w,g=c.node(y);g.in-=v,a(u,d,g)}),c.removeNode(h.v),m}function s(c,u){let d=new t,h=0,p=0;c.nodes().forEach(v=>{d.setNode(v,{v,in:0,out:0})}),c.edges().forEach(v=>{let y=d.edge(v.v,v.w)||0,g=u(v),k=y+g;d.setEdge(v.v,v.w,k),p=Math.max(p,d.node(v.v).out+=g),h=Math.max(h,d.node(v.w).in+=g)});let m=l(p+h+3).map(()=>new e),w=h+1;return d.nodes().forEach(v=>{a(m,w,d.node(v))}),{graph:d,buckets:m,zeroIdx:w}}function a(c,u,d){d.out?d.in?c[d.out-d.in+u].enqueue(d):c[c.length-1].enqueue(d):c[0].enqueue(d)}function l(c){const u=[];for(let d=0;d<c;d++)u.push(d);return u}return Ag}var Og,UA;function Mt(){if(UA)return Og;UA=1;let t=gr().Graph;Og={addBorderNode:u,addDummyNode:e,applyWithChunking:p,asNonCompoundGraph:r,buildLayerMatrix:a,intersectRect:s,mapValues:E,maxRank:m,normalizeRanks:l,notime:y,partition:w,pick:C,predecessorWeights:i,range:A,removeEmptyRanks:c,simplify:n,successorWeights:o,time:v,uniqueId:k,zipObject:D};function e(S,_,O,B){for(var N=B;S.hasNode(N);)N=k(B);return O.dummy=_,S.setNode(N,O),N}function n(S){let _=new t().setGraph(S.graph());return S.nodes().forEach(O=>_.setNode(O,S.node(O))),S.edges().forEach(O=>{let B=_.edge(O.v,O.w)||{weight:0,minlen:1},N=S.edge(O);_.setEdge(O.v,O.w,{weight:B.weight+N.weight,minlen:Math.max(B.minlen,N.minlen)})}),_}function r(S){let _=new t({multigraph:S.isMultigraph()}).setGraph(S.graph());return S.nodes().forEach(O=>{S.children(O).length||_.setNode(O,S.node(O))}),S.edges().forEach(O=>{_.setEdge(O,S.edge(O))}),_}function o(S){let _=S.nodes().map(O=>{let B={};return S.outEdges(O).forEach(N=>{B[N.w]=(B[N.w]||0)+S.edge(N).weight}),B});return D(S.nodes(),_)}function i(S){let _=S.nodes().map(O=>{let B={};return S.inEdges(O).forEach(N=>{B[N.v]=(B[N.v]||0)+S.edge(N).weight}),B});return D(S.nodes(),_)}function s(S,_){let O=S.x,B=S.y,N=_.x-O,F=_.y-B,M=S.width/2,T=S.height/2;if(!N&&!F)throw new Error("Not possible to find intersection inside of the rectangle");let P,$;return Math.abs(F)*M>Math.abs(N)*T?(F<0&&(T=-T),P=T*N/F,$=T):(N<0&&(M=-M),P=M,$=M*F/N),{x:O+P,y:B+$}}function a(S){let _=A(m(S)+1).map(()=>[]);return S.nodes().forEach(O=>{let B=S.node(O),N=B.rank;N!==void 0&&(_[N][B.order]=O)}),_}function l(S){let _=S.nodes().map(B=>{let N=S.node(B).rank;return N===void 0?Number.MAX_VALUE:N}),O=p(Math.min,_);S.nodes().forEach(B=>{let N=S.node(B);Object.hasOwn(N,"rank")&&(N.rank-=O)})}function c(S){let _=S.nodes().map(M=>S.node(M).rank),O=p(Math.min,_),B=[];S.nodes().forEach(M=>{let T=S.node(M).rank-O;B[T]||(B[T]=[]),B[T].push(M)});let N=0,F=S.graph().nodeRankFactor;Array.from(B).forEach((M,T)=>{M===void 0&&T%F!==0?--N:M!==void 0&&N&&M.forEach(P=>S.node(P).rank+=N)})}function u(S,_,O,B){let N={width:0,height:0};return arguments.length>=4&&(N.rank=O,N.order=B),e(S,"border",N,_)}function d(S,_=h){const O=[];for(let B=0;B<S.length;B+=_){const N=S.slice(B,B+_);O.push(N)}return O}const h=65535;function p(S,_){if(_.length>h){const O=d(_);return S.apply(null,O.map(B=>S.apply(null,B)))}else return S.apply(null,_)}function m(S){const O=S.nodes().map(B=>{let N=S.node(B).rank;return N===void 0?Number.MIN_VALUE:N});return p(Math.max,O)}function w(S,_){let O={lhs:[],rhs:[]};return S.forEach(B=>{_(B)?O.lhs.push(B):O.rhs.push(B)}),O}function v(S,_){let O=Date.now();try{return _()}finally{console.log(S+" time: "+(Date.now()-O)+"ms")}}function y(S,_){return _()}let g=0;function k(S){var _=++g;return S+(""+_)}function A(S,_,O=1){_==null&&(_=S,S=0);let B=F=>F<_;O<0&&(B=F=>_<F);const N=[];for(let F=S;B(F);F+=O)N.push(F);return N}function C(S,_){const O={};for(const B of _)S[B]!==void 0&&(O[B]=S[B]);return O}function E(S,_){let O=_;return typeof _=="string"&&(O=B=>B[_]),Object.entries(S).reduce((B,[N,F])=>(B[N]=O(F,N),B),{})}function D(S,_){return S.reduce((O,B,N)=>(O[B]=_[N],O),{})}return Og}var Tg,qA;function xq(){if(qA)return Tg;qA=1;let t=kq(),e=Mt().uniqueId;Tg={run:n,undo:o};function n(i){(i.graph().acyclicer==="greedy"?t(i,a(i)):r(i)).forEach(l=>{let c=i.edge(l);i.removeEdge(l),c.forwardName=l.name,c.reversed=!0,i.setEdge(l.w,l.v,c,e("rev"))});function a(l){return c=>l.edge(c).weight}}function r(i){let s=[],a={},l={};function c(u){Object.hasOwn(l,u)||(l[u]=!0,a[u]=!0,i.outEdges(u).forEach(d=>{Object.hasOwn(a,d.w)?s.push(d):c(d.w)}),delete a[u])}return i.nodes().forEach(c),s}function o(i){i.edges().forEach(s=>{let a=i.edge(s);if(a.reversed){i.removeEdge(s);let l=a.forwardName;delete a.reversed,delete a.forwardName,i.setEdge(s.w,s.v,a,l)}})}return Tg}var _g,GA;function Sq(){if(GA)return _g;GA=1;let t=Mt();_g={run:e,undo:r};function e(o){o.graph().dummyChains=[],o.edges().forEach(i=>n(o,i))}function n(o,i){let s=i.v,a=o.node(s).rank,l=i.w,c=o.node(l).rank,u=i.name,d=o.edge(i),h=d.labelRank;if(c===a+1)return;o.removeEdge(i);let p,m,w;for(w=0,++a;a<c;++w,++a)d.points=[],m={width:0,height:0,edgeLabel:d,edgeObj:i,rank:a},p=t.addDummyNode(o,"edge",m,"_d"),a===h&&(m.width=d.width,m.height=d.height,m.dummy="edge-label",m.labelpos=d.labelpos),o.setEdge(s,p,{weight:d.weight},u),w===0&&o.graph().dummyChains.push(p),s=p;o.setEdge(s,l,{weight:d.weight},u)}function r(o){o.graph().dummyChains.forEach(i=>{let s=o.node(i),a=s.edgeLabel,l;for(o.setEdge(s.edgeObj,a);s.dummy;)l=o.successors(i)[0],o.removeNode(i),a.points.push({x:s.x,y:s.y}),s.dummy==="edge-label"&&(a.x=s.x,a.y=s.y,a.width=s.width,a.height=s.height),i=l,s=o.node(i)})}return _g}var Ng,KA;function md(){if(KA)return Ng;KA=1;const{applyWithChunking:t}=Mt();Ng={longestPath:e,slack:n};function e(r){var o={};function i(s){var a=r.node(s);if(Object.hasOwn(o,s))return a.rank;o[s]=!0;let l=r.outEdges(s).map(u=>u==null?Number.POSITIVE_INFINITY:i(u.w)-r.edge(u).minlen);var c=t(Math.min,l);return c===Number.POSITIVE_INFINITY&&(c=0),a.rank=c}r.sources().forEach(i)}function n(r,o){return r.node(o.w).rank-r.node(o.v).rank-r.edge(o).minlen}return Ng}var Bg,YA;function XA(){if(YA)return Bg;YA=1;var t=gr().Graph,e=md().slack;Bg=n;function n(s){var a=new t({directed:!1}),l=s.nodes()[0],c=s.nodeCount();a.setNode(l,{});for(var u,d;r(a,s)<c;)u=o(a,s),d=a.hasNode(u.v)?e(s,u):-e(s,u),i(a,s,d);return a}function r(s,a){function l(c){a.nodeEdges(c).forEach(u=>{var d=u.v,h=c===d?u.w:d;!s.hasNode(h)&&!e(a,u)&&(s.setNode(h,{}),s.setEdge(c,h,{}),l(h))})}return s.nodes().forEach(l),s.nodeCount()}function o(s,a){return a.edges().reduce((c,u)=>{let d=Number.POSITIVE_INFINITY;return s.hasNode(u.v)!==s.hasNode(u.w)&&(d=e(a,u)),d<c[0]?[d,u]:c},[Number.POSITIVE_INFINITY,null])[1]}function i(s,a,l){s.nodes().forEach(c=>a.node(c).rank+=l)}return Bg}var Fg,JA;function Eq(){if(JA)return Fg;JA=1;var t=XA(),e=md().slack,n=md().longestPath,r=gr().alg.preorder,o=gr().alg.postorder,i=Mt().simplify;Fg=s,s.initLowLimValues=u,s.initCutValues=a,s.calcCutValue=c,s.leaveEdge=h,s.enterEdge=p,s.exchangeEdges=m;function s(g){g=i(g),n(g);var k=t(g);u(k),a(k,g);for(var A,C;A=h(k);)C=p(k,g,A),m(k,g,A,C)}function a(g,k){var A=o(g,g.nodes());A=A.slice(0,A.length-1),A.forEach(C=>l(g,k,C))}function l(g,k,A){var C=g.node(A),E=C.parent;g.edge(A,E).cutvalue=c(g,k,A)}function c(g,k,A){var C=g.node(A),E=C.parent,D=!0,S=k.edge(A,E),_=0;return S||(D=!1,S=k.edge(E,A)),_=S.weight,k.nodeEdges(A).forEach(O=>{var B=O.v===A,N=B?O.w:O.v;if(N!==E){var F=B===D,M=k.edge(O).weight;if(_+=F?M:-M,v(g,A,N)){var T=g.edge(A,N).cutvalue;_+=F?-T:T}}}),_}function u(g,k){arguments.length<2&&(k=g.nodes()[0]),d(g,{},1,k)}function d(g,k,A,C,E){var D=A,S=g.node(C);return k[C]=!0,g.neighbors(C).forEach(_=>{Object.hasOwn(k,_)||(A=d(g,k,A,_,C))}),S.low=D,S.lim=A++,E?S.parent=E:delete S.parent,A}function h(g){return g.edges().find(k=>g.edge(k).cutvalue<0)}function p(g,k,A){var C=A.v,E=A.w;k.hasEdge(C,E)||(C=A.w,E=A.v);var D=g.node(C),S=g.node(E),_=D,O=!1;D.lim>S.lim&&(_=S,O=!0);var B=k.edges().filter(N=>O===y(g,g.node(N.v),_)&&O!==y(g,g.node(N.w),_));return B.reduce((N,F)=>e(k,F)<e(k,N)?F:N)}function m(g,k,A,C){var E=A.v,D=A.w;g.removeEdge(E,D),g.setEdge(C.v,C.w,{}),u(g),a(g,k),w(g,k)}function w(g,k){var A=g.nodes().find(E=>!k.node(E).parent),C=r(g,A);C=C.slice(1),C.forEach(E=>{var D=g.node(E).parent,S=k.edge(E,D),_=!1;S||(S=k.edge(D,E),_=!0),k.node(E).rank=k.node(D).rank+(_?S.minlen:-S.minlen)})}function v(g,k,A){return g.hasEdge(k,A)}function y(g,k,A){return A.low<=k.lim&&k.lim<=A.lim}return Fg}var Ig,RA;function Dq(){if(RA)return Ig;RA=1;var t=md(),e=t.longestPath,n=XA(),r=Eq();Ig=o;function o(l){var c=l.graph().ranker;if(c instanceof Function)return c(l);switch(l.graph().ranker){case"network-simplex":a(l);break;case"tight-tree":s(l);break;case"longest-path":i(l);break;case"none":break;default:a(l)}}var i=e;function s(l){e(l),n(l)}function a(l){r(l)}return Ig}var Mg,QA;function Aq(){if(QA)return Mg;QA=1,Mg=t;function t(r){let o=n(r);r.graph().dummyChains.forEach(i=>{let s=r.node(i),a=s.edgeObj,l=e(r,o,a.v,a.w),c=l.path,u=l.lca,d=0,h=c[d],p=!0;for(;i!==a.w;){if(s=r.node(i),p){for(;(h=c[d])!==u&&r.node(h).maxRank<s.rank;)d++;h===u&&(p=!1)}if(!p){for(;d<c.length-1&&r.node(h=c[d+1]).minRank<=s.rank;)d++;h=c[d]}r.setParent(i,h),i=r.successors(i)[0]}})}function e(r,o,i,s){let a=[],l=[],c=Math.min(o[i].low,o[s].low),u=Math.max(o[i].lim,o[s].lim),d,h;d=i;do d=r.parent(d),a.push(d);while(d&&(o[d].low>c||u>o[d].lim));for(h=d,d=s;(d=r.parent(d))!==h;)l.push(d);return{path:a.concat(l.reverse()),lca:h}}function n(r){let o={},i=0;function s(a){let l=i;r.children(a).forEach(s),o[a]={low:l,lim:i++}}return r.children().forEach(s),o}return Mg}var Pg,ZA;function Oq(){if(ZA)return Pg;ZA=1;let t=Mt();Pg={run:e,cleanup:i};function e(s){let a=t.addDummyNode(s,"root",{},"_root"),l=r(s),c=Object.values(l),u=t.applyWithChunking(Math.max,c)-1,d=2*u+1;s.graph().nestingRoot=a,s.edges().forEach(p=>s.edge(p).minlen*=d);let h=o(s)+1;s.children().forEach(p=>n(s,a,d,h,u,l,p)),s.graph().nodeRankFactor=d}function n(s,a,l,c,u,d,h){let p=s.children(h);if(!p.length){h!==a&&s.setEdge(a,h,{weight:0,minlen:l});return}let m=t.addBorderNode(s,"_bt"),w=t.addBorderNode(s,"_bb"),v=s.node(h);s.setParent(m,h),v.borderTop=m,s.setParent(w,h),v.borderBottom=w,p.forEach(y=>{n(s,a,l,c,u,d,y);let g=s.node(y),k=g.borderTop?g.borderTop:y,A=g.borderBottom?g.borderBottom:y,C=g.borderTop?c:2*c,E=k!==A?1:u-d[h]+1;s.setEdge(m,k,{weight:C,minlen:E,nestingEdge:!0}),s.setEdge(A,w,{weight:C,minlen:E,nestingEdge:!0})}),s.parent(h)||s.setEdge(a,m,{weight:0,minlen:u+d[h]})}function r(s){var a={};function l(c,u){var d=s.children(c);d&&d.length&&d.forEach(h=>l(h,u+1)),a[c]=u}return s.children().forEach(c=>l(c,1)),a}function o(s){return s.edges().reduce((a,l)=>a+s.edge(l).weight,0)}function i(s){var a=s.graph();s.removeNode(a.nestingRoot),delete a.nestingRoot,s.edges().forEach(l=>{var c=s.edge(l);c.nestingEdge&&s.removeEdge(l)})}return Pg}var Lg,eO;function Tq(){if(eO)return Lg;eO=1;let t=Mt();Lg=e;function e(r){function o(i){let s=r.children(i),a=r.node(i);if(s.length&&s.forEach(o),Object.hasOwn(a,"minRank")){a.borderLeft=[],a.borderRight=[];for(let l=a.minRank,c=a.maxRank+1;l<c;++l)n(r,"borderLeft","_bl",i,a,l),n(r,"borderRight","_br",i,a,l)}}r.children().forEach(o)}function n(r,o,i,s,a,l){let c={width:0,height:0,rank:l,borderType:o},u=a[o][l-1],d=t.addDummyNode(r,"border",c,i);a[o][l]=d,r.setParent(d,s),u&&r.setEdge(u,d,{weight:1})}return Lg}var $g,tO;function _q(){if(tO)return $g;tO=1,$g={adjust:t,undo:e};function t(l){let c=l.graph().rankdir.toLowerCase();(c==="lr"||c==="rl")&&n(l)}function e(l){let c=l.graph().rankdir.toLowerCase();(c==="bt"||c==="rl")&&o(l),(c==="lr"||c==="rl")&&(s(l),n(l))}function n(l){l.nodes().forEach(c=>r(l.node(c))),l.edges().forEach(c=>r(l.edge(c)))}function r(l){let c=l.width;l.width=l.height,l.height=c}function o(l){l.nodes().forEach(c=>i(l.node(c))),l.edges().forEach(c=>{let u=l.edge(c);u.points.forEach(i),Object.hasOwn(u,"y")&&i(u)})}function i(l){l.y=-l.y}function s(l){l.nodes().forEach(c=>a(l.node(c))),l.edges().forEach(c=>{let u=l.edge(c);u.points.forEach(a),Object.hasOwn(u,"x")&&a(u)})}function a(l){let c=l.x;l.x=l.y,l.y=c}return $g}var Hg,nO;function Nq(){if(nO)return Hg;nO=1;let t=Mt();Hg=e;function e(n){let r={},o=n.nodes().filter(u=>!n.children(u).length),i=o.map(u=>n.node(u).rank),s=t.applyWithChunking(Math.max,i),a=t.range(s+1).map(()=>[]);function l(u){if(r[u])return;r[u]=!0;let d=n.node(u);a[d.rank].push(u),n.successors(u).forEach(l)}return o.sort((u,d)=>n.node(u).rank-n.node(d).rank).forEach(l),a}return Hg}var zg,rO;function Bq(){if(rO)return zg;rO=1;let t=Mt().zipObject;zg=e;function e(r,o){let i=0;for(let s=1;s<o.length;++s)i+=n(r,o[s-1],o[s]);return i}function n(r,o,i){let s=t(i,i.map((h,p)=>p)),a=o.flatMap(h=>r.outEdges(h).map(p=>({pos:s[p.w],weight:r.edge(p).weight})).sort((p,m)=>p.pos-m.pos)),l=1;for(;l<i.length;)l<<=1;let c=2*l-1;l-=1;let u=new Array(c).fill(0),d=0;return a.forEach(h=>{let p=h.pos+l;u[p]+=h.weight;let m=0;for(;p>0;)p%2&&(m+=u[p+1]),p=p-1>>1,u[p]+=h.weight;d+=h.weight*m}),d}return zg}var jg,oO;function Fq(){if(oO)return jg;oO=1,jg=t;function t(e,n=[]){return n.map(r=>{let o=e.inEdges(r);if(o.length){let i=o.reduce((s,a)=>{let l=e.edge(a),c=e.node(a.v);return{sum:s.sum+l.weight*c.order,weight:s.weight+l.weight}},{sum:0,weight:0});return{v:r,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:r}})}return jg}var Vg,iO;function Iq(){if(iO)return Vg;iO=1;let t=Mt();Vg=e;function e(o,i){let s={};o.forEach((l,c)=>{let u=s[l.v]={indegree:0,in:[],out:[],vs:[l.v],i:c};l.barycenter!==void 0&&(u.barycenter=l.barycenter,u.weight=l.weight)}),i.edges().forEach(l=>{let c=s[l.v],u=s[l.w];c!==void 0&&u!==void 0&&(u.indegree++,c.out.push(s[l.w]))});let a=Object.values(s).filter(l=>!l.indegree);return n(a)}function n(o){let i=[];function s(l){return c=>{c.merged||(c.barycenter===void 0||l.barycenter===void 0||c.barycenter>=l.barycenter)&&r(l,c)}}function a(l){return c=>{c.in.push(l),--c.indegree===0&&o.push(c)}}for(;o.length;){let l=o.pop();i.push(l),l.in.reverse().forEach(s(l)),l.out.forEach(a(l))}return i.filter(l=>!l.merged).map(l=>t.pick(l,["vs","i","barycenter","weight"]))}function r(o,i){let s=0,a=0;o.weight&&(s+=o.barycenter*o.weight,a+=o.weight),i.weight&&(s+=i.barycenter*i.weight,a+=i.weight),o.vs=i.vs.concat(o.vs),o.barycenter=s/a,o.weight=a,o.i=Math.min(i.i,o.i),i.merged=!0}return Vg}var Wg,sO;function Mq(){if(sO)return Wg;sO=1;let t=Mt();Wg=e;function e(o,i){let s=t.partition(o,m=>Object.hasOwn(m,"barycenter")),a=s.lhs,l=s.rhs.sort((m,w)=>w.i-m.i),c=[],u=0,d=0,h=0;a.sort(r(!!i)),h=n(c,l,h),a.forEach(m=>{h+=m.vs.length,c.push(m.vs),u+=m.barycenter*m.weight,d+=m.weight,h=n(c,l,h)});let p={vs:c.flat(!0)};return d&&(p.barycenter=u/d,p.weight=d),p}function n(o,i,s){let a;for(;i.length&&(a=i[i.length-1]).i<=s;)i.pop(),o.push(a.vs),s++;return s}function r(o){return(i,s)=>i.barycenter<s.barycenter?-1:i.barycenter>s.barycenter?1:o?s.i-i.i:i.i-s.i}return Wg}var Ug,aO;function Pq(){if(aO)return Ug;aO=1;let t=Fq(),e=Iq(),n=Mq();Ug=r;function r(s,a,l,c){let u=s.children(a),d=s.node(a),h=d?d.borderLeft:void 0,p=d?d.borderRight:void 0,m={};h&&(u=u.filter(g=>g!==h&&g!==p));let w=t(s,u);w.forEach(g=>{if(s.children(g.v).length){let k=r(s,g.v,l,c);m[g.v]=k,Object.hasOwn(k,"barycenter")&&i(g,k)}});let v=e(w,l);o(v,m);let y=n(v,c);if(h&&(y.vs=[h,y.vs,p].flat(!0),s.predecessors(h).length)){let g=s.node(s.predecessors(h)[0]),k=s.node(s.predecessors(p)[0]);Object.hasOwn(y,"barycenter")||(y.barycenter=0,y.weight=0),y.barycenter=(y.barycenter*y.weight+g.order+k.order)/(y.weight+2),y.weight+=2}return y}function o(s,a){s.forEach(l=>{l.vs=l.vs.flatMap(c=>a[c]?a[c].vs:c)})}function i(s,a){s.barycenter!==void 0?(s.barycenter=(s.barycenter*s.weight+a.barycenter*a.weight)/(s.weight+a.weight),s.weight+=a.weight):(s.barycenter=a.barycenter,s.weight=a.weight)}return Ug}var qg,lO;function Lq(){if(lO)return qg;lO=1;let t=gr().Graph,e=Mt();qg=n;function n(o,i,s,a){a||(a=o.nodes());let l=r(o),c=new t({compound:!0}).setGraph({root:l}).setDefaultNodeLabel(u=>o.node(u));return a.forEach(u=>{let d=o.node(u),h=o.parent(u);(d.rank===i||d.minRank<=i&&i<=d.maxRank)&&(c.setNode(u),c.setParent(u,h||l),o[s](u).forEach(p=>{let m=p.v===u?p.w:p.v,w=c.edge(m,u),v=w!==void 0?w.weight:0;c.setEdge(m,u,{weight:o.edge(p).weight+v})}),Object.hasOwn(d,"minRank")&&c.setNode(u,{borderLeft:d.borderLeft[i],borderRight:d.borderRight[i]}))}),c}function r(o){for(var i;o.hasNode(i=e.uniqueId("_root")););return i}return qg}var Gg,cO;function $q(){if(cO)return Gg;cO=1,Gg=t;function t(e,n,r){let o={},i;r.forEach(s=>{let a=e.parent(s),l,c;for(;a;){if(l=e.parent(a),l?(c=o[l],o[l]=a):(c=i,i=a),c&&c!==a){n.setEdge(c,a);return}a=l}})}return Gg}var Kg,uO;function Hq(){if(uO)return Kg;uO=1;let t=Nq(),e=Bq(),n=Pq(),r=Lq(),o=$q(),i=gr().Graph,s=Mt();Kg=a;function a(d,h){if(h&&typeof h.customOrder=="function"){h.customOrder(d,a);return}let p=s.maxRank(d),m=l(d,s.range(1,p+1),"inEdges"),w=l(d,s.range(p-1,-1,-1),"outEdges"),v=t(d);if(u(d,v),h&&h.disableOptimalOrderHeuristic)return;let y=Number.POSITIVE_INFINITY,g;for(let k=0,A=0;A<4;++k,++A){c(k%2?m:w,k%4>=2),v=s.buildLayerMatrix(d);let C=e(d,v);C<y&&(A=0,g=Object.assign({},v),y=C)}u(d,g)}function l(d,h,p){const m=new Map,w=(v,y)=>{m.has(v)||m.set(v,[]),m.get(v).push(y)};for(const v of d.nodes()){const y=d.node(v);if(typeof y.rank=="number"&&w(y.rank,v),typeof y.minRank=="number"&&typeof y.maxRank=="number")for(let g=y.minRank;g<=y.maxRank;g++)g!==y.rank&&w(g,v)}return h.map(function(v){return r(d,v,p,m.get(v)||[])})}function c(d,h){let p=new i;d.forEach(function(m){let w=m.graph().root,v=n(m,w,p,h);v.vs.forEach((y,g)=>m.node(y).order=g),o(m,p,v.vs)})}function u(d,h){Object.values(h).forEach(p=>p.forEach((m,w)=>d.node(m).order=w))}return Kg}var Yg,dO;function zq(){if(dO)return Yg;dO=1;let t=gr().Graph,e=Mt();Yg={positionX:p,findType1Conflicts:n,findType2Conflicts:r,addConflict:i,hasConflict:s,verticalAlignment:a,horizontalCompaction:l,alignCoordinates:d,findSmallestWidthAlignment:u,balance:h};function n(v,y){let g={};function k(A,C){let E=0,D=0,S=A.length,_=C[C.length-1];return C.forEach((O,B)=>{let N=o(v,O),F=N?v.node(N).order:S;(N||O===_)&&(C.slice(D,B+1).forEach(M=>{v.predecessors(M).forEach(T=>{let P=v.node(T),$=P.order;($<E||F<$)&&!(P.dummy&&v.node(M).dummy)&&i(g,T,M)})}),D=B+1,E=F)}),C}return y.length&&y.reduce(k),g}function r(v,y){let g={};function k(C,E,D,S,_){let O;e.range(E,D).forEach(B=>{O=C[B],v.node(O).dummy&&v.predecessors(O).forEach(N=>{let F=v.node(N);F.dummy&&(F.order<S||F.order>_)&&i(g,N,O)})})}function A(C,E){let D=-1,S,_=0;return E.forEach((O,B)=>{if(v.node(O).dummy==="border"){let N=v.predecessors(O);N.length&&(S=v.node(N[0]).order,k(E,_,B,D,S),_=B,D=S)}k(E,_,E.length,S,C.length)}),E}return y.length&&y.reduce(A),g}function o(v,y){if(v.node(y).dummy)return v.predecessors(y).find(g=>v.node(g).dummy)}function i(v,y,g){if(y>g){let A=y;y=g,g=A}let k=v[y];k||(v[y]=k={}),k[g]=!0}function s(v,y,g){if(y>g){let k=y;y=g,g=k}return!!v[y]&&Object.hasOwn(v[y],g)}function a(v,y,g,k){let A={},C={},E={};return y.forEach(D=>{D.forEach((S,_)=>{A[S]=S,C[S]=S,E[S]=_})}),y.forEach(D=>{let S=-1;D.forEach(_=>{let O=k(_);if(O.length){O=O.sort((N,F)=>E[N]-E[F]);let B=(O.length-1)/2;for(let N=Math.floor(B),F=Math.ceil(B);N<=F;++N){let M=O[N];C[_]===_&&S<E[M]&&!s(g,_,M)&&(C[M]=_,C[_]=A[_]=A[M],S=E[M])}}})}),{root:A,align:C}}function l(v,y,g,k,A){let C={},E=c(v,y,g,A),D=A?"borderLeft":"borderRight";function S(B,N){let F=E.nodes(),M=F.pop(),T={};for(;M;)T[M]?B(M):(T[M]=!0,F.push(M),F=F.concat(N(M))),M=F.pop()}function _(B){C[B]=E.inEdges(B).reduce((N,F)=>Math.max(N,C[F.v]+E.edge(F)),0)}function O(B){let N=E.outEdges(B).reduce((M,T)=>Math.min(M,C[T.w]-E.edge(T)),Number.POSITIVE_INFINITY),F=v.node(B);N!==Number.POSITIVE_INFINITY&&F.borderType!==D&&(C[B]=Math.max(C[B],N))}return S(_,E.predecessors.bind(E)),S(O,E.successors.bind(E)),Object.keys(k).forEach(B=>C[B]=C[g[B]]),C}function c(v,y,g,k){let A=new t,C=v.graph(),E=m(C.nodesep,C.edgesep,k);return y.forEach(D=>{let S;D.forEach(_=>{let O=g[_];if(A.setNode(O),S){var B=g[S],N=A.edge(B,O);A.setEdge(B,O,Math.max(E(v,_,S),N||0))}S=_})}),A}function u(v,y){return Object.values(y).reduce((g,k)=>{let A=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;Object.entries(k).forEach(([D,S])=>{let _=w(v,D)/2;A=Math.max(S+_,A),C=Math.min(S-_,C)});const E=A-C;return E<g[0]&&(g=[E,k]),g},[Number.POSITIVE_INFINITY,null])[1]}function d(v,y){let g=Object.values(y),k=e.applyWithChunking(Math.min,g),A=e.applyWithChunking(Math.max,g);["u","d"].forEach(C=>{["l","r"].forEach(E=>{let D=C+E,S=v[D];if(S===y)return;let _=Object.values(S),O=k-e.applyWithChunking(Math.min,_);E!=="l"&&(O=A-e.applyWithChunking(Math.max,_)),O&&(v[D]=e.mapValues(S,B=>B+O))})})}function h(v,y){return e.mapValues(v.ul,(g,k)=>{if(y)return v[y.toLowerCase()][k];{let A=Object.values(v).map(C=>C[k]).sort((C,E)=>C-E);return(A[1]+A[2])/2}})}function p(v){let y=e.buildLayerMatrix(v),g=Object.assign(n(v,y),r(v,y)),k={},A;["u","d"].forEach(E=>{A=E==="u"?y:Object.values(y).reverse(),["l","r"].forEach(D=>{D==="r"&&(A=A.map(B=>Object.values(B).reverse()));let S=(E==="u"?v.predecessors:v.successors).bind(v),_=a(v,A,g,S),O=l(v,A,_.root,_.align,D==="r");D==="r"&&(O=e.mapValues(O,B=>-B)),k[E+D]=O})});let C=u(v,k);return d(k,C),h(k,v.graph().align)}function m(v,y,g){return(k,A,C)=>{let E=k.node(A),D=k.node(C),S=0,_;if(S+=E.width/2,Object.hasOwn(E,"labelpos"))switch(E.labelpos.toLowerCase()){case"l":_=-E.width/2;break;case"r":_=E.width/2;break}if(_&&(S+=g?_:-_),_=0,S+=(E.dummy?y:v)/2,S+=(D.dummy?y:v)/2,S+=D.width/2,Object.hasOwn(D,"labelpos"))switch(D.labelpos.toLowerCase()){case"l":_=D.width/2;break;case"r":_=-D.width/2;break}return _&&(S+=g?_:-_),_=0,S}}function w(v,y){return v.node(y).width}return Yg}var Xg,fO;function jq(){if(fO)return Xg;fO=1;let t=Mt(),e=zq().positionX;Xg=n;function n(o){o=t.asNonCompoundGraph(o),r(o),Object.entries(e(o)).forEach(([i,s])=>o.node(i).x=s)}function r(o){let i=t.buildLayerMatrix(o),s=o.graph().ranksep,a=0;i.forEach(l=>{const c=l.reduce((u,d)=>{const h=o.node(d).height;return u>h?u:h},0);l.forEach(u=>o.node(u).y=a+c/2),a+=c+s})}return Xg}var Jg,hO;function Vq(){if(hO)return Jg;hO=1;let t=xq(),e=Sq(),n=Dq(),r=Mt().normalizeRanks,o=Aq(),i=Mt().removeEmptyRanks,s=Oq(),a=Tq(),l=_q(),c=Hq(),u=jq(),d=Mt(),h=gr().Graph;Jg=p;function p(H,j){let Y=j&&j.debugTiming?d.time:d.notime;Y("layout",()=>{let ie=Y(" buildLayoutGraph",()=>S(H));Y(" runLayout",()=>m(ie,Y,j)),Y(" updateInputGraph",()=>w(H,ie))})}function m(H,j,Y){j(" makeSpaceForEdgeLabels",()=>_(H)),j(" removeSelfEdges",()=>W(H)),j(" acyclic",()=>t.run(H)),j(" nestingGraph.run",()=>s.run(H)),j(" rank",()=>n(d.asNonCompoundGraph(H))),j(" injectEdgeLabelProxies",()=>O(H)),j(" removeEmptyRanks",()=>i(H)),j(" nestingGraph.cleanup",()=>s.cleanup(H)),j(" normalizeRanks",()=>r(H)),j(" assignRankMinMax",()=>B(H)),j(" removeEdgeLabelProxies",()=>N(H)),j(" normalize.run",()=>e.run(H)),j(" parentDummyChains",()=>o(H)),j(" addBorderSegments",()=>a(H)),j(" order",()=>c(H,Y)),j(" insertSelfEdges",()=>V(H)),j(" adjustCoordinateSystem",()=>l.adjust(H)),j(" position",()=>u(H)),j(" positionSelfEdges",()=>X(H)),j(" removeBorderNodes",()=>$(H)),j(" normalize.undo",()=>e.undo(H)),j(" fixupEdgeLabelCoords",()=>T(H)),j(" undoCoordinateSystem",()=>l.undo(H)),j(" translateGraph",()=>F(H)),j(" assignNodeIntersects",()=>M(H)),j(" reversePoints",()=>P(H)),j(" acyclic.undo",()=>t.undo(H))}function w(H,j){H.nodes().forEach(Y=>{let ie=H.node(Y),Q=j.node(Y);ie&&(ie.x=Q.x,ie.y=Q.y,ie.rank=Q.rank,j.children(Y).length&&(ie.width=Q.width,ie.height=Q.height))}),H.edges().forEach(Y=>{let ie=H.edge(Y),Q=j.edge(Y);ie.points=Q.points,Object.hasOwn(Q,"x")&&(ie.x=Q.x,ie.y=Q.y)}),H.graph().width=j.graph().width,H.graph().height=j.graph().height}let v=["nodesep","edgesep","ranksep","marginx","marginy"],y={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},g=["acyclicer","ranker","rankdir","align"],k=["width","height","rank"],A={width:0,height:0},C=["minlen","weight","width","height","labeloffset"],E={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},D=["labelpos"];function S(H){let j=new h({multigraph:!0,compound:!0}),Y=te(H.graph());return j.setGraph(Object.assign({},y,G(Y,v),d.pick(Y,g))),H.nodes().forEach(ie=>{let Q=te(H.node(ie));const le=G(Q,k);Object.keys(A).forEach(L=>{le[L]===void 0&&(le[L]=A[L])}),j.setNode(ie,le),j.setParent(ie,H.parent(ie))}),H.edges().forEach(ie=>{let Q=te(H.edge(ie));j.setEdge(ie,Object.assign({},E,G(Q,C),d.pick(Q,D)))}),j}function _(H){let j=H.graph();j.ranksep/=2,H.edges().forEach(Y=>{let ie=H.edge(Y);ie.minlen*=2,ie.labelpos.toLowerCase()!=="c"&&(j.rankdir==="TB"||j.rankdir==="BT"?ie.width+=ie.labeloffset:ie.height+=ie.labeloffset)})}function O(H){H.edges().forEach(j=>{let Y=H.edge(j);if(Y.width&&Y.height){let ie=H.node(j.v),le={rank:(H.node(j.w).rank-ie.rank)/2+ie.rank,e:j};d.addDummyNode(H,"edge-proxy",le,"_ep")}})}function B(H){let j=0;H.nodes().forEach(Y=>{let ie=H.node(Y);ie.borderTop&&(ie.minRank=H.node(ie.borderTop).rank,ie.maxRank=H.node(ie.borderBottom).rank,j=Math.max(j,ie.maxRank))}),H.graph().maxRank=j}function N(H){H.nodes().forEach(j=>{let Y=H.node(j);Y.dummy==="edge-proxy"&&(H.edge(Y.e).labelRank=Y.rank,H.removeNode(j))})}function F(H){let j=Number.POSITIVE_INFINITY,Y=0,ie=Number.POSITIVE_INFINITY,Q=0,le=H.graph(),L=le.marginx||0,q=le.marginy||0;function J(K){let re=K.x,se=K.y,he=K.width,Ce=K.height;j=Math.min(j,re-he/2),Y=Math.max(Y,re+he/2),ie=Math.min(ie,se-Ce/2),Q=Math.max(Q,se+Ce/2)}H.nodes().forEach(K=>J(H.node(K))),H.edges().forEach(K=>{let re=H.edge(K);Object.hasOwn(re,"x")&&J(re)}),j-=L,ie-=q,H.nodes().forEach(K=>{let re=H.node(K);re.x-=j,re.y-=ie}),H.edges().forEach(K=>{let re=H.edge(K);re.points.forEach(se=>{se.x-=j,se.y-=ie}),Object.hasOwn(re,"x")&&(re.x-=j),Object.hasOwn(re,"y")&&(re.y-=ie)}),le.width=Y-j+L,le.height=Q-ie+q}function M(H){H.edges().forEach(j=>{let Y=H.edge(j),ie=H.node(j.v),Q=H.node(j.w),le,L;Y.points?(le=Y.points[0],L=Y.points[Y.points.length-1]):(Y.points=[],le=Q,L=ie),Y.points.unshift(d.intersectRect(ie,le)),Y.points.push(d.intersectRect(Q,L))})}function T(H){H.edges().forEach(j=>{let Y=H.edge(j);if(Object.hasOwn(Y,"x"))switch((Y.labelpos==="l"||Y.labelpos==="r")&&(Y.width-=Y.labeloffset),Y.labelpos){case"l":Y.x-=Y.width/2+Y.labeloffset;break;case"r":Y.x+=Y.width/2+Y.labeloffset;break}})}function P(H){H.edges().forEach(j=>{let Y=H.edge(j);Y.reversed&&Y.points.reverse()})}function $(H){H.nodes().forEach(j=>{if(H.children(j).length){let Y=H.node(j),ie=H.node(Y.borderTop),Q=H.node(Y.borderBottom),le=H.node(Y.borderLeft[Y.borderLeft.length-1]),L=H.node(Y.borderRight[Y.borderRight.length-1]);Y.width=Math.abs(L.x-le.x),Y.height=Math.abs(Q.y-ie.y),Y.x=le.x+Y.width/2,Y.y=ie.y+Y.height/2}}),H.nodes().forEach(j=>{H.node(j).dummy==="border"&&H.removeNode(j)})}function W(H){H.edges().forEach(j=>{if(j.v===j.w){var Y=H.node(j.v);Y.selfEdges||(Y.selfEdges=[]),Y.selfEdges.push({e:j,label:H.edge(j)}),H.removeEdge(j)}})}function V(H){var j=d.buildLayerMatrix(H);j.forEach(Y=>{var ie=0;Y.forEach((Q,le)=>{var L=H.node(Q);L.order=le+ie,(L.selfEdges||[]).forEach(q=>{d.addDummyNode(H,"selfedge",{width:q.label.width,height:q.label.height,rank:L.rank,order:le+ ++ie,e:q.e,label:q.label},"_se")}),delete L.selfEdges})})}function X(H){H.nodes().forEach(j=>{var Y=H.node(j);if(Y.dummy==="selfedge"){var ie=H.node(Y.e.v),Q=ie.x+ie.width/2,le=ie.y,L=Y.x-Q,q=ie.height/2;H.setEdge(Y.e,Y.label),H.removeNode(j),Y.label.points=[{x:Q+2*L/3,y:le-q},{x:Q+5*L/6,y:le-q},{x:Q+L,y:le},{x:Q+5*L/6,y:le+q},{x:Q+2*L/3,y:le+q}],Y.label.x=Y.x,Y.label.y=Y.y}})}function G(H,j){return d.mapValues(d.pick(H,j),Number)}function te(H){var j={};return H&&Object.entries(H).forEach(([Y,ie])=>{typeof Y=="string"&&(Y=Y.toLowerCase()),j[Y]=ie}),j}return Jg}var Rg,pO;function Wq(){if(pO)return Rg;pO=1;let t=Mt(),e=gr().Graph;Rg={debugOrdering:n};function n(r){let o=t.buildLayerMatrix(r),i=new e({compound:!0,multigraph:!0}).setGraph({});return r.nodes().forEach(s=>{i.setNode(s,{label:s}),i.setParent(s,"layer"+r.node(s).rank)}),r.edges().forEach(s=>i.setEdge(s.v,s.w,{},s.name)),o.forEach((s,a)=>{let l="layer"+a;i.setNode(l,{rank:"same"}),s.reduce((c,u)=>(i.setEdge(c,u,{style:"invis"}),u))}),i}return Rg}var Qg,mO;function Uq(){return mO||(mO=1,Qg="1.1.8"),Qg}var Zg,gO;function qq(){return gO||(gO=1,Zg={graphlib:gr(),layout:Vq(),debug:Wq(),util:{time:Mt().time,notime:Mt().notime},version:Uq()}),Zg}var Gq=qq();const wO=Ii(Gq),ew=20,Ke=300,Ds=ew*15,tw=ew*10,As=ew*3;function vO(t){return t.type===ee.AGENT||t.type===ee.MCPServer}function yO(t){return t.type===ee.BuiltinMCP}function Kq(t){return t.type===ee.AI_SUB_NODE||t.type===ee.MCP_TOOL}function bO(t,e,n){const r=new Map(n.map(a=>[a.id,a])),i=e.filter(a=>a.source===t).map(a=>r.get(a.target)).filter(a=>a!==void 0);console.log("候选子节点:",i.map(a=>`${a.id}(${a.type})`));const s=i.filter(a=>a!==void 0&&Kq(a));return console.log("符合条件的子节点:",s.map(a=>`${a.id}(${a.type})`)),s}function Yq(t,e){const n=[t,...e],r=Ke,o=Ke,i=n.length*o+(n.length-1)*As,s=r,a=t.position.y,c={x:t.position.x,y:a,width:s,height:i};return{parentId:t.id,childIds:e.map(u=>u.id),boundingBox:c}}function Xq(t,e){const n=Ke,r=Ke,o=Math.max(n,e.length*n+(e.length-1)*Ds),i=r+As+r,s=t.position.y,l={x:t.position.x,y:s,width:o,height:i};return{parentId:t.id,childIds:e.map(c=>c.id),boundingBox:l}}function Jq(t,e,n){if(t.length===0)return{boundingBox:{x:0,y:0,width:0,height:0},nodes:[]};const r=Rq(t),o=[],i=[],s=new Set;t.forEach(C=>{var E,D;if(console.log(`检查节点 ${C.id}:`,{type:C.type,dataType:(E=C.data)==null?void 0:E.type,actionType:(D=C.data)==null?void 0:D.action_type,isVerticalParent:vO(C),isHorizontalParent:yO(C)}),vO(C)&&!s.has(C.id)){const S=bO(C.id,e,t);console.log(`找到Agent/MCPServer节点 ${C.id}, 子节点数量: ${S.length}`,S.map(O=>O.id));const _=Yq(C,S);o.push(_),s.add(C.id),S.forEach(O=>s.add(O.id))}if(yO(C)&&!s.has(C.id)){const S=bO(C.id,e,t);console.log(`找到BuiltinMCP节点 ${C.id}, 子节点数量: ${S.length}`,S.map(O=>O.id));const _=Xq(C,S);i.push(_),s.add(C.id),S.forEach(O=>s.add(O.id))}}),console.log(`总共找到 ${o.length} 个垂直布局组`,o),console.log(`总共找到 ${i.length} 个水平布局组`,i),console.log("所有边的连接:",e.map(C=>`${C.source} -> ${C.target}`));const a=t.filter(C=>!s.has(C.id)),l=new wO.graphlib.Graph;l.setGraph({rankdir:"LR",edgesep:tw,nodesep:tw,ranksep:Ds}),l.setDefaultEdgeLabel(()=>({})),a.forEach(C=>{const E=C.width||Ke,D=C.height||Ke;l.setNode(C.id,{width:E,height:D,x:C.position.x,y:C.position.y})}),o.forEach(C=>{const E=Ke+C.childIds.length*(Ke+As);l.setNode(C.parentId,{width:Ke,height:E})}),i.forEach(C=>{const E=Math.max(Ke,C.childIds.length*Ke+(C.childIds.length-1)*Ds),D=Ke+As+Ke;l.setNode(C.parentId,{width:E,height:D})}),e.forEach(C=>{const E=[...o,...i],D=E.some(F=>F.parentId===C.source||F.childIds.includes(C.source)),S=E.some(F=>F.parentId===C.target||F.childIds.includes(C.target));if(D&&S){const F=E.find(T=>T.parentId===C.source||T.childIds.includes(C.source)),M=E.find(T=>T.parentId===C.target||T.childIds.includes(C.target));if(F===M)return}let _=C.source,O=C.target;const B=E.find(F=>F.childIds.includes(C.source));B&&(_=B.parentId);const N=E.find(F=>F.childIds.includes(C.target));N&&(O=N.parentId),l.hasNode(_)&&l.hasNode(O)&&l.setEdge(_,O)}),wO.layout(l);const c=[],u=[],d=[],h=[];a.forEach(C=>{if(l.hasNode(C.id)){const E=l.node(C.id);if(!E||typeof E.x!="number"||typeof E.y!="number"){console.warn(`Invalid layout data for regular node ${C.id}:`,E);return}const D={x:E.x-(E.width||Ke)/2,y:E.y-(E.height||Ke)/2,width:E.width||Ke,height:E.height||Ke};u.push({id:C.id,boundingBox:D}),d.push(D.y),h.push(D.x),c.push({id:C.id,x:D.x,y:D.y,width:D.width,height:D.height})}}),o.forEach(C=>{var E,D;if(l.hasNode(C.parentId)){const S=l.node(C.parentId);if(!S||typeof S.x!="number"||typeof S.y!="number"){console.warn(`Invalid layout data for vertical group ${C.parentId}:`,S);return}const _=S.x,O=S.y,B=S.width||Ke,N=S.height||Ke,F=t.find(W=>W.id===C.parentId),M=t.filter(W=>C.childIds.includes(W.id));if(!F)return;const T=_-B/2,P=O-N/2,$={x:T,y:P,width:Ke,height:Ke};console.log(`垂直布局父节点 ${C.parentId}: 从 (${(E=F.position)==null?void 0:E.x}, ${(D=F.position)==null?void 0:D.y}) 移动到 (${$.x}, ${$.y})`),u.push({id:C.parentId,boundingBox:$}),d.push($.y),h.push($.x),c.push({id:C.parentId,x:$.x,y:$.y,width:$.width,height:$.height}),M.forEach((W,V)=>{var te,H;const X=$.y+(V+1)*(Ke+As),G={x:$.x,y:X,width:Ke,height:Ke};console.log(`垂直布局子节点 ${W.id}: 从 (${(te=W.position)==null?void 0:te.x}, ${(H=W.position)==null?void 0:H.y}) 移动到 (${G.x}, ${G.y})`),u.push({id:W.id,boundingBox:G}),d.push(G.y),h.push(G.x),c.push({id:W.id,x:G.x,y:G.y,width:G.width,height:G.height})})}}),i.forEach(C=>{var E,D;if(l.hasNode(C.parentId)){const S=l.node(C.parentId);if(!S||typeof S.x!="number"||typeof S.y!="number"){console.warn(`Invalid layout data for horizontal group ${C.parentId}:`,S);return}const _=S.x,O=S.y,B=S.width||Ke,N=S.height||Ke,F=t.find(G=>G.id===C.parentId),M=t.filter(G=>C.childIds.includes(G.id));if(!F)return;const T=_-B/2,P=O-N/2,$={x:T+(B-Ke)/2,y:P,width:Ke,height:Ke};console.log(`水平布局父节点 ${C.parentId}: 从 (${(E=F.position)==null?void 0:E.x}, ${(D=F.position)==null?void 0:D.y}) 移动到 (${$.x}, ${$.y})`),u.push({id:C.parentId,boundingBox:$}),d.push($.y),h.push($.x),c.push({id:C.parentId,x:$.x,y:$.y,width:$.width,height:$.height});const W=$.y+Ke+As,V=M.length*Ke+(M.length-1)*Ds,X=T+(B-V)/2;M.forEach((G,te)=>{var Y,ie;const j={x:X+te*(Ke+Ds),y:W,width:Ke,height:Ke};console.log(`水平布局子节点 ${G.id}: 从 (${(Y=G.position)==null?void 0:Y.x}, ${(ie=G.position)==null?void 0:ie.y}) 移动到 (${j.x}, ${j.y})`),u.push({id:G.id,boundingBox:j}),d.push(j.y),h.push(j.x),c.push({id:G.id,x:j.x,y:j.y,width:j.width,height:j.height})})}});const p=20;function m(C,E){return Math.round(C/E)*E}const w=[...new Set(d.map(C=>m(C,p)))].sort((C,E)=>C-E),v=[...new Set(h.map(C=>m(C,p)))].sort((C,E)=>C-E);console.log("主要Y对齐线:",w),console.log("主要X对齐线:",v);const y=c.map(C=>{const E=o.some(S=>S.childIds.includes(C.id)),D=i.some(S=>S.childIds.includes(C.id));if(E){const S=o.find(O=>O.childIds.includes(C.id)),_=c.find(O=>O.id===(S==null?void 0:S.parentId));if(_)return{...C,x:m(_.x,p),y:m(C.y,p)}}return D?{...C,x:m(C.x,p),y:m(C.y,p)}:{...C,x:m(C.x,p),y:m(C.y,p)}});console.log("对齐前的结果:",c.slice(0,3)),console.log("对齐后的结果:",y.slice(0,3));const g=u.length>0?CO(u.map(C=>C.boundingBox)):{x:0,y:0,width:0,height:0},k={x:g.x-r.x,y:g.y-r.y},A=y.map(C=>({...C,x:C.x-k.x,y:C.y-k.y}));return console.log(`布局完成,锚点偏移: (${k.x}, ${k.y})`),console.log("最终布局结果:",A),{boundingBox:g,nodes:A}}function Rq(t){if(t.length===0)return{x:0,y:0,width:0,height:0};const e=t.map(n=>({x:n.position.x,y:n.position.y,width:n.width||Ke,height:n.height||Ke}));return CO(e)}function CO(t){if(t.length===0)return{x:0,y:0,width:0,height:0};const{minX:e,minY:n,maxX:r,maxY:o}=t.reduce((i,s)=>{const{x:a,y:l,width:c,height:u}=s;return{minX:Math.min(i.minX,a),maxX:Math.max(i.maxX,a+c),minY:Math.min(i.minY,l),maxY:Math.max(i.maxY,l+u)}},{minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0});return{x:e,y:n,width:r-e,height:o-n}}const kO=t=>{const{getNodes:e,getEdges:n,getNode:r,fitView:o,setNodes:i}=ae.useReactFlow(),s=b.useCallback((c=Tl.ALL,u=!1)=>{const d=e(),h=n(),p=c==="selection"?d.filter(w=>w.selected):d;if(p.length===0)return console.log("没有节点需要布局"),{boundingBox:{x:0,y:0,width:0,height:0},nodes:[]};const m=Jq(p,h);return i(d.map(w=>{const v=m.nodes.find(y=>y.id===w.id);return v?{...w,position:{x:v.x,y:v.y}}:w})),u&&setTimeout(()=>{o({padding:.1,includeHiddenNodes:!1,duration:200})},10),m},[e,n,i,o]),a=b.useCallback((c=!1)=>s(Tl.ALL,c),[s]),l=b.useCallback((c=!1)=>s(Tl.SELECTION,c),[s]);return{layout:s,autoLayout:a,layoutSelection:l}},Qq={HORIZONTAL_GAP:Ds+100,VERTICAL_SPACING:tw,INITIAL_X:100,MAIN_NODE_Y:300,X_PROXIMITY_THRESHOLD:50};function xO(t,e=Qq){const n=t.filter(a=>a.type!==ee.AI_SUB_NODE);let r;n.length>0?r=Math.max(...n.map(l=>l.position.x))+e.HORIZONTAL_GAP:r=e.INITIAL_X;const o=e.MAIN_NODE_Y,s=t.filter(a=>Math.abs(a.position.x-r)<e.X_PROXIMITY_THRESHOLD).length*e.VERTICAL_SPACING;return[r,o+s]}const SO=()=>new Date().toLocaleTimeString("zh-CN",{hour:"2-digit",minute:"2-digit",second:"2-digit"});function Zq(t,e){var un,dn;const{workflowId:n,preview:r=!1,previewId:o,linkMode:i=!1,onInit:s}=t,a=Ss(),{setLocked:l,op_status:c}=Cr(),u=Ct(),[d,h]=b.useState(!1),[p,m]=b.useState(!1),w=Vt(),v=ae.useReactFlow(),{autoLayout:y}=kO(),[g,k]=b.useState(!0),A=!!(r&&o||w.canvas.mode==="preview"),C=c===We.ONLINE||c===We.ON_WARN,E=b.useMemo(()=>!A&&w.canvas.miniMap,[A,w.canvas.miniMap]),D=b.useMemo(()=>!A&&!i&&w.canvas.controls,[A,i,w.canvas.controls]),S=b.useMemo(()=>!A&&!i&&w.canvas.header,[A,i,w.canvas.header]),_=b.useMemo(()=>{var Se;return(Se=w.canvas.grid)==null?void 0:Se.enabled},[(un=w.canvas.grid)==null?void 0:un.enabled]),O=b.useMemo(()=>u&&!A&&w.canvas.fastOperationButtons,[u,A,w.canvas.fastOperationButtons]);lq({enabled:!A&&d&&!C});const B=A||g||!u,N=b.useCallback(Se=>{requestAnimationFrame(()=>{const Ne=v.getNode(Se);Ne&&v.fitView({nodes:[Ne],padding:.4,duration:300,maxZoom:1})})},[v]),[F,M]=b.useState(hn.IDLE),[T,P]=b.useState(""),{setFlowOpStatusAction:$,setNodeConfigVisible:W}=Cr(n),{addNodes:V,addEdges:X}=Fi(),{removeEdges:G,onConnect:te,handleEdgesChange:H}=ng(),j=ae.useStoreApi(),Y=j.getState().edges,ie=Io(Se=>Se.workflow.refreshWorkFlowNum),[Q,le]=ae.useNodesState([]),[L,q]=ae.useEdgesState([]),[J,K]=b.useState(void 0),[re,se]=b.useState(void 0),he=b.useCallback(Se=>{var Pt,In;if(!Se)return!0;const Ne=(Pt=w.canvas)==null?void 0:Pt.selectable;if(!Ne)return!0;const{includeNodeIds:Ge,includeCategories:nt}=Ne;if((!Ge||Ge.length===0)&&(!nt||nt.length===0))return!0;const ct=j.getState().nodes.find(Ur=>Ur.id===Se);if(!ct)return!0;const St=(In=ct.data)==null?void 0:In.category;return!!(Ge&&Ge.includes(Se)||nt&&St&&nt.includes(St))},[(dn=w.canvas)==null?void 0:dn.selectable,j]),Ce=b.useCallback((Se,Ne)=>{if(K(void 0),se(void 0),Se.length===1&&Se[0].type==="position"&&Se[0].dragging&&Se[0].position){const Ge=aq(Se[0],Ne);Se[0].position.x=Ge.snapPosition.x??Se[0].position.x,Se[0].position.y=Ge.snapPosition.y??Se[0].position.y,K(Ge.horizontal),se(Ge.vertical)}return Se},[]),Fe=b.useCallback(Se=>{H(Se),Se.forEach(Ne=>{Ne.type!=="select"&&Ne.type!=="replace"&&h(!0)})},[H]),qe=b.useCallback(Se=>{const Ne=j.getState().nodes,Ge=Se.map(lt=>lt.type==="position"&&!he(lt.id)?null:lt.type==="select"&&!he(lt.id)?{...lt,selected:!1}:lt).filter(lt=>lt!==null);Ce(Ge,Ne);const nt=Pn(Ne,lt=>{const ct=ae.applyNodeChanges(Ge,lt);lt.splice(0,ct.length,...ct),lt.splice(ct.length)});le(nt),Ge.forEach(lt=>{lt.type!=="select"&<.type!=="replace"&&h(!0)})},[he,le,j,Ce]),{onEdgeMouseEnter:Le,onEdgeMouseLeave:de}=ng(),{onNodeMouseEnter:Te,onNodeMouseLeave:_e,autoSaveNum:tt}=rd(),cn=b.useCallback((Se,Ne)=>{M(Se),Se===hn.SAVED?(P(SO()),window.__AI_FLOW_IN_QUEUE_NODE_ID&&(W(window.__AI_FLOW_IN_QUEUE_NODE_ID),window.__AI_FLOW_IN_QUEUE_NODE_ID="")):Se===hn.ERROR&&Ne&&console.error("保存失败:",Ne)},[W]),{setNodeAddCallback:Vn,openNodeSelector:en,handleManualAdd:At}=Es();dt.useUnmount(()=>{a(hd()),q([]),le([])});const ht=b.useRef(async()=>{}),ot=b.useCallback(Se=>{var nt;if(Se.defaultPrevented)return;const Ne=Se.target,Ge=(nt=Ne==null?void 0:Ne.tagName)==null?void 0:nt.toLowerCase();Ge==="input"||Ge==="textarea"||Ne!=null&&Ne.isContentEditable||Se.altKey&&Se.shiftKey&&Se.code==="KeyD"&&(Se.preventDefault(),m(lt=>!lt))},[]);b.useEffect(()=>(window.addEventListener("keydown",ot),()=>{window.removeEventListener("keydown",ot)}),[ot]);const lo=b.useCallback(Se=>{var ct;const Ne=((ct=w.edgeRules)==null?void 0:ct.validators)||[];if(!Ne.length)return!0;const{nodes:Ge,edges:nt}=j.getState(),lt={nodes:Ge.reduce((St,Pt)=>{var Ur;const In={id:Pt.id,type:Pt.type||"",position:Pt.position,data:Pt.data,disabled:((Ur=Pt.data)==null?void 0:Ur.closed)==="1"};return St[Pt.id]=In,St},{}),edges:nt.map(St=>({id:St.id,source:St.source,target:St.target,data:St.data}))};try{return Ne.every(St=>St(Se,lt))}catch(St){return console.error("边校验函数执行异常",St),!1}},[w.edgeRules,j]),Wn=b.useCallback(Se=>{if(!Se.source||!Se.target)return;const Ne={source:Se.source,target:Se.target,data:{}};lo(Ne)&&(te(Se),h(!0))},[te,lo]),bi=b.useCallback((Se,Ne)=>{w.edgeRules&&w.edgeRules.allowAddNodeOnEdge===!1||en({position:Se,edge:Ne})},[en,w.edgeRules]),Fs=b.useCallback(Se=>{Se.stopPropagation();const{nodes:Ne}=j.getState();if(Ne.some(nt=>nt.type===ee.TRIGGER)){const nt=xO(Ne);en({position:{x:nt[0],y:nt[1]}})}else en({trigger:!0})},[en,j]),Is=b.useCallback(()=>{const{nodes:Se}=j.getState();let Ne;const Ge=Se.find(nt=>nt.selected&&nt.type!==ee.STICKY);Ge?Ne=[Ge.position.x,Ge.position.y-80]:Ne=xO(Se),At({position:{x:Ne[0],y:Ne[1]}},{action_type:ee.STICKY,type:ee.STICKY,id:e,nodeId:e,name:"便签",action_name:"便签",connector_name:"",description:""})},[At,e,j]),Ci=b.useCallback(()=>{y()},[y]),{canvasApi:Wr}=sq({dispatch:a,reactFlow:v,setEdges:q,setNodes:le,store:j,setNodeConfigVisible:W,saveFlowRef:ht});b.useEffect(()=>{s&&s(Wr)},[s,Wr]);const Ms=w.canvas.nativeProps||{},{onNodeContextMenu:ki,onPaneContextMenu:Ps,...Ow}=Ms,Tw=b.useCallback((Se,Ne)=>{Se.ctrlKey&&Se.preventDefault(),ki==null||ki(Se,Ne)},[ki]),Gt=b.useCallback(Se=>{Se.ctrlKey&&Se.preventDefault(),Ps==null||Ps(Se)},[Ps]);return{nodes:Q,edges:L,setNodes:le,setEdges:q,unSave:d,setUnSave:h,loading:g,setLoading:k,debugVisible:p,setDebugVisible:m,autoSaveStatus:F,lastSavedTime:T,helperLineHorizontal:J,helperLineVertical:re,isPreviewMode:A,isInteractionDisabled:B,isOnline:C,showMiniMap:E,showControls:D,showCanvasHeader:S,showBackground:_,showFastOperationButtons:O,onNodesChange:qe,handleEdgesChange:Fe,handleConnect:Wn,handleEdgeAddNode:bi,handleOpenNodeSelector:Fs,handleAddNoteNode:Is,handleTidy:Ci,onEdgeMouseEnter:Le,onEdgeMouseLeave:de,onNodeMouseEnter:Te,onNodeMouseLeave:_e,onNodeContextMenu:Tw,onPaneContextMenu:Gt,updateSaveStatus:cn,setNodeFitHumanView:N,canvasApi:Wr,reactFlow:v,dispatch:a,store:j,storeEdges:Y,refreshWorkFlowNum:ie,addNodes:V,addEdges:X,removeEdges:G,setNodeAddCallback:Vn,setNodeConfigVisible:W,setFlowOpStatusAction:$,autoSaveNum:tt,setLocked:l,openNodeSelector:en,handleManualAdd:At,restNativeProps:Ow,saveFlowRef:ht}}const eG=(t,e="normal")=>{const n=t.data.status;if(t.type===ee.STICKY)return e==="lighter"?"rgba(0,0,0,.5)":"rgb(206, 226, 164)";switch(n){case me.INVALID:return e==="lighter"?"#F2C000":"#FDF6D5";case me.FAILED:return e==="lighter"?"#FA170A":"#FF918B";case me.SUCCESS:case me.RUNNABLE:return e==="lighter"?"#2EC04F":"#8CDF3A";case me.RUNNING:return e==="lighter"?"#007AFF":"#D9EBFF";default:return e==="lighter"?"#51A4F6":"#00c3ff"}};function tG(t){const e=n=>eG(n);return f.jsx(ae.MiniMap,{style:{display:"flex",flexDirection:"row"},nodeStrokeColor:e,nodeStrokeWidth:3,pannable:!0,zoomable:!0,nodeColor:e,nodeBorderRadius:3,...t})}const nG=200,gd=150,il=44,EO=t=>{try{return JSON.stringify(t)}catch(e){return String(e)}},nw=t=>({id:t.id,type:t.type,position:t.position,data:t.data}),rw=t=>({id:t.id,source:t.source,target:t.target,sourceHandle:t.sourceHandle,targetHandle:t.targetHandle,data:t.data}),vi=t=>{if(!t)return"";const e=t.data,n=(e==null?void 0:e.backendData)||void 0,r=(n==null?void 0:n.properties)||void 0;return(r==null?void 0:r.display_name)||(e==null?void 0:e.label)||(e==null?void 0:e.action_name)||(e==null?void 0:e.name)||t.id},rG=t=>t.replace(/[^a-zA-Z0-9_]/g,"_"),oG=(t,e,n,r)=>{const o=new Map;t.forEach((l,c)=>{const u=rG(l.id||`node_${c}`);o.set(l.id,u)});const i=["flowchart LR"];t.forEach(l=>{const c=o.get(l.id);if(!c)return;const u=`${l.id} ${vi(l)}`.replace(/"/g,"'");i.push(` ${c}["${u}"]`)});const s=[];let a=0;return e.forEach(l=>{const c=o.get(l.source),u=o.get(l.target);!c||!u||(i.push(` ${c} --> ${u}`),r.has(l.id)&&s.push(a),a+=1)}),s.forEach(l=>{i.push(` linkStyle ${l} stroke:#cf1322,stroke-width:2px`)}),i.join(`
|
|
92
92
|
`)},iG=t=>`${t.source}__${t.target}__${t.sourceHandle||""}__${t.targetHandle||""}`,DO=(t,e)=>t.map(n=>{const r=e.get(n.source)||n.source,o=e.get(n.target)||n.target;return`${n.source}(${r}) -> ${n.target}(${o})`}),AO=(t,e)=>{const n=new Map;t.forEach(o=>{const i=iG(o),s=n.get(i)||[];s.push(o),n.set(i,s)});const r=[];return n.forEach((o,i)=>{if(o.length<=1)return;const s=o[0],a=e.get(s.source)||s.source,l=e.get(s.target)||s.target;r.push({key:i,relation:`${s.source}(${a}) -> ${s.target}(${l})`,edgeIds:o.map(c=>c.id)})}),r},OO=(t,e)=>{if(!t.length)return{levels:[],unvisited:[]};const n=new Map(t.map(h=>[h.id,h])),r=new Map,o=new Map;t.forEach(h=>{r.set(h.id,[]),o.set(h.id,0)}),e.forEach(h=>{var p;!n.has(h.source)||!n.has(h.target)||((p=r.get(h.source))==null||p.push(h.target),o.set(h.target,(o.get(h.target)||0)+1))});const i=t.filter(h=>h.type==="START"||h.type==="TRIGGER"||(o.get(h.id)||0)===0),s=[],a=new Map;if(i.length)i.forEach(h=>{s.push({id:h.id,level:0}),a.set(h.id,0)});else{const h=t[0];s.push({id:h.id,level:0}),a.set(h.id,0)}const l=new Set;for(;s.length;){const h=s.shift();if(!h)break;if(l.has(h.id))continue;l.add(h.id),(r.get(h.id)||[]).forEach(m=>{a.has(m)||a.set(m,h.level+1),s.push({id:m,level:h.level+1})})}const c=new Map;a.forEach((h,p)=>{const m=n.get(p);if(!m)return;const w=c.get(h)||[];w.push(m),c.set(h,w)});const u=Array.from(c.entries()).sort((h,p)=>h[0]-p[0]).map(([h,p])=>({level:h,nodes:p})),d=t.filter(h=>!l.has(h.id));return{levels:u,unvisited:d}},sG=(t,e)=>{const{levels:n,unvisited:r}=OO(t,e),o=gd,i=il,s=200,a=90,l=[],c=e.map(m=>({id:m.id,source:m.source,target:m.target})).filter(m=>t.some(w=>w.id===m.source)&&t.some(w=>w.id===m.target));let u=-1;n.forEach(m=>{m.level>u&&(u=m.level)});const d=[...n];r.length&&d.push({level:u+1,nodes:r}),d.forEach(m=>{const w=m.level*s;m.nodes.forEach((v,y)=>{const g=y*(i+a),k=`${v.id} (${vi(v)})`;l.push({id:v.id,label:k,x:w,y:g})})});const h=Math.max(...l.map(m=>m.x),0),p=Math.max(...l.map(m=>m.y),0);return{nodes:l,edges:c,width:h+o+s,height:p+i+a}},TO=t=>t.length?t.map(e=>{const n=e.detail?JSON.stringify(e.detail,null,2):"";return`[${e.time}] ${e.message}${n?`
|
|
93
93
|
${n}`:""}`}).join(`
|
|
94
94
|
|
|
95
|
-
`):"暂无日志",wd=async t=>{var e;try{if((e=navigator==null?void 0:navigator.clipboard)!=null&&e.writeText)return await navigator.clipboard.writeText(t),!0}catch{}try{const n=document.createElement("textarea");n.value=t,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}},_O=(t,e,n)=>{const r=new Map(t.map(l=>[l.id,l])),o=new Map(e.map(l=>[l.id,l])),i=[],s=[],a=[];return o.forEach((l,c)=>{if(!r.has(c)){i.push(c);return}const u=EO(n(r.get(c))),d=EO(n(l));u!==d&&a.push(c)}),r.forEach((l,c)=>{o.has(c)||s.push(c)}),{added:i,removed:s,changed:a}},aG=({visible:t,nodes:e,edges:n,onClose:r})=>{const[o,i]=b.useState([]),[s,a]=b.useState(!1),[l,c]=b.useState(!1),[u,d]=b.useState(),[h,p]=b.useState(),m=b.useRef({nodes:[],edges:[]});b.useEffect(()=>{const T=m.current;if(m.current={nodes:e,edges:n},!t)return;const P=_O(T.nodes,e,nw),$=_O(T.edges,n,rw),W=P.added.length+P.removed.length+P.changed.length>0,V=$.added.length+$.removed.length+$.changed.length>0;if(!W&&!V)return;const X=new Map(e.map(Q=>[Q.id,vi(Q)])),G=Object.fromEntries(X.entries()),te=DO(n,X),H=AO(n,X),j={nodeDiff:P,edgeDiff:$,nodeCount:{prev:T.nodes.length,next:e.length},edgeCount:{prev:T.edges.length,next:n.length},edgeRelations:te,nodeNameMap:G,duplicateEdges:H},Y=[];W&&Y.push(`节点 +${P.added.length} -${P.removed.length} ~${P.changed.length}`),V&&Y.push(`连线 +${$.added.length} -${$.removed.length} ~${$.changed.length}`);const
|
|
95
|
+
`):"暂无日志",wd=async t=>{var e;try{if((e=navigator==null?void 0:navigator.clipboard)!=null&&e.writeText)return await navigator.clipboard.writeText(t),!0}catch{}try{const n=document.createElement("textarea");n.value=t,n.style.position="fixed",n.style.opacity="0",document.body.appendChild(n),n.focus(),n.select();const r=document.execCommand("copy");return document.body.removeChild(n),r}catch{return!1}},_O=(t,e,n)=>{const r=new Map(t.map(l=>[l.id,l])),o=new Map(e.map(l=>[l.id,l])),i=[],s=[],a=[];return o.forEach((l,c)=>{if(!r.has(c)){i.push(c);return}const u=EO(n(r.get(c))),d=EO(n(l));u!==d&&a.push(c)}),r.forEach((l,c)=>{o.has(c)||s.push(c)}),{added:i,removed:s,changed:a}},aG=({visible:t,nodes:e,edges:n,onClose:r})=>{const[o,i]=b.useState([]),[s,a]=b.useState(!1),[l,c]=b.useState(!1),[u,d]=b.useState(),[h,p]=b.useState(),m=b.useRef({nodes:[],edges:[]});b.useEffect(()=>{const T=m.current;if(m.current={nodes:e,edges:n},!t)return;const P=_O(T.nodes,e,nw),$=_O(T.edges,n,rw),W=P.added.length+P.removed.length+P.changed.length>0,V=$.added.length+$.removed.length+$.changed.length>0;if(!W&&!V)return;const X=new Map(e.map(Q=>[Q.id,vi(Q)])),G=Object.fromEntries(X.entries()),te=DO(n,X),H=AO(n,X),j={nodeDiff:P,edgeDiff:$,nodeCount:{prev:T.nodes.length,next:e.length},edgeCount:{prev:T.edges.length,next:n.length},edgeRelations:te,nodeNameMap:G,duplicateEdges:H},Y=[];W&&Y.push(`节点 +${P.added.length} -${P.removed.length} ~${P.changed.length}`),V&&Y.push(`连线 +${$.added.length} -${$.removed.length} ~${$.changed.length}`);const ie={id:`${Date.now()}-${Math.random()}`,time:SO(),message:Y.join(" | "),nodeSummary:W?{added:P.added.length,removed:P.removed.length,changed:P.changed.length}:void 0,edgeSummary:V?{added:$.added.length,removed:$.removed.length,changed:$.changed.length}:void 0,edgeRelations:te,duplicateEdges:H,detail:j,expanded:!1};i(Q=>[ie,...Q].slice(0,nG)),console.log("[WorkflowDebugPanel]",ie.message,j)},[n,e,t]);const w=b.useMemo(()=>e.map(T=>({label:`${T.id} (${vi(T)})`,value:T.id})),[e]),v=b.useMemo(()=>n.map(T=>({label:`${T.id} (${T.source} -> ${T.target})`,value:T.id})),[n]),y=e.find(T=>T.id===u),g=n.find(T=>T.id===h),k=b.useMemo(()=>{const T=new Map;return e.forEach(P=>{T.set(P.id,vi(P))}),T},[e]),A=b.useMemo(()=>AO(n,k),[n,k]),C=b.useMemo(()=>{const T=new Set;return A==null||A.forEach(P=>{P.edgeIds.forEach($=>T.add($))}),T},[A]),E=b.useMemo(()=>n.map(T=>{const P=k.get(T.source)||T.source,$=k.get(T.target)||T.target;return{id:T.id,text:`${T.source}(${P}) -> ${T.target}(${$})`,isDuplicate:C.has(T.id)}}),[C,n,k]),D=b.useMemo(()=>oG(e,n,k,C),[C,n,k,e]),S=b.useMemo(()=>sG(e,n),[n,e]),_=b.useMemo(()=>new Map(S.nodes.map(T=>[T.id,T])),[S.nodes]),O=Math.max(S.width,400),B=Math.max(S.height,180),N=b.useMemo(()=>{const{levels:T,unvisited:P}=OO(e,n),$=T.map(W=>{const V=W.nodes.map(X=>`${X.id}(${vi(X)})`).join(" | ");return`L${W.level}: ${V}`});return P.length&&$.push(`循环/未连接: ${P.map(W=>`${W.id}(${vi(W)})`).join(" | ")}`),$.length?$.join(`
|
|
96
96
|
`):"暂无结构"},[n,e]),F=b.useMemo(()=>s&&l?o.filter(T=>T.nodeSummary||T.edgeSummary):s?o.filter(T=>T.nodeSummary):l?o.filter(T=>T.edgeSummary):o,[o,l,s]),M=b.useMemo(()=>{const T={nodes:e.map(nw),edges:n.map(rw),edgeRelations:DO(n,k),duplicateEdges:A,mermaidSource:D};return JSON.stringify(T,null,2)},[A,n,D,k,e]);return t?f.jsxs(ae.Panel,{position:"bottom-right",className:"workflow-debug-panel",children:[f.jsxs("div",{className:"workflow-debug-panel__header",children:[f.jsx("span",{children:"画布调试"}),f.jsx(x.Button,{size:"small",onClick:r,children:"关闭"})]}),f.jsxs("div",{className:"workflow-debug-panel__section",children:[f.jsxs("div",{className:"workflow-debug-panel__log-header",children:[f.jsx("span",{children:"变更日志"}),f.jsxs(x.Space,{size:6,children:[f.jsx(x.Button,{size:"small",onClick:async()=>{const T=TO(F);await wd(T)?x.message.success("日志已复制"):x.message.error("复制失败")},children:"复制日志"}),f.jsx(x.Button,{size:"small",onClick:async()=>{const T=F[0],P=T?TO([T]):"暂无日志";await wd(P)?x.message.success("最新日志已复制"):x.message.error("复制失败")},children:"复制最新"}),f.jsx(x.Button,{size:"small",onClick:async()=>{await wd(M)?x.message.success("快照已复制"):x.message.error("复制失败")},children:"复制快照"})]})]}),f.jsx("div",{className:"workflow-debug-panel__toolbar",children:f.jsxs(x.Space,{size:6,wrap:!0,children:[f.jsx(x.Button,{size:"small",onClick:()=>a(T=>!T),children:s?"显示全部":"仅节点"}),f.jsx(x.Button,{size:"small",onClick:()=>c(T=>!T),children:l?"显示全部":"仅连线"}),f.jsx(x.Button,{size:"small",onClick:()=>i(T=>T.map(P=>({...P,expanded:!0}))),children:"全部展开"}),f.jsx(x.Button,{size:"small",onClick:()=>i(T=>T.map(P=>({...P,expanded:!1}))),children:"全部收起"}),f.jsx(x.Button,{size:"small",onClick:()=>i([]),children:"清空"})]})}),f.jsxs("div",{className:"workflow-debug-panel__log-list",children:[F.length===0&&f.jsx("div",{className:"workflow-debug-panel__log-empty",children:"暂无日志"}),F.map(T=>f.jsxs("div",{className:"workflow-debug-panel__log-item",children:[f.jsxs("div",{className:"workflow-debug-panel__log-title",children:[f.jsx("span",{className:"workflow-debug-panel__log-time",children:T.time}),f.jsx("span",{children:T.message})]}),f.jsxs("div",{className:"workflow-debug-panel__log-tags",children:[T.nodeSummary&&f.jsxs("span",{className:"workflow-debug-panel__tag workflow-debug-panel__tag-node",children:["节点 +",T.nodeSummary.added," -",T.nodeSummary.removed," ~",T.nodeSummary.changed]}),T.edgeSummary&&f.jsxs("span",{className:"workflow-debug-panel__tag workflow-debug-panel__tag-edge",children:["连线 +",T.edgeSummary.added," -",T.edgeSummary.removed," ~",T.edgeSummary.changed]})]}),f.jsx("div",{className:"workflow-debug-panel__log-actions",children:f.jsx(x.Button,{size:"small",onClick:()=>i(P=>P.map($=>$.id===T.id?{...$,expanded:!$.expanded}:$)),children:T.expanded?"收起详情":"展开详情"})}),T.expanded&&f.jsxs("div",{className:"workflow-debug-panel__log-detail",children:[T.edgeRelations&&f.jsxs("div",{className:"workflow-debug-panel__log-detail-block",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"连线关系"}),f.jsx("pre",{children:T.edgeRelations.join(`
|
|
97
97
|
`)})]}),T.duplicateEdges&&T.duplicateEdges.length>0&&f.jsxs("div",{className:"workflow-debug-panel__log-detail-block",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"重复连线"}),f.jsx("pre",{children:T.duplicateEdges.map(P=>`${P.relation} [${P.edgeIds.join(", ")}]`).join(`
|
|
98
|
-
`)})]}),T.detail&&f.jsxs("div",{className:"workflow-debug-panel__log-detail-block",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"详细信息"}),f.jsx("pre",{children:JSON.stringify(T.detail,null,2)})]})]})]},T.id))]})]}),f.jsxs("div",{className:"workflow-debug-panel__section",children:[f.jsxs("div",{className:"workflow-debug-panel__summary",children:[f.jsxs("span",{children:["节点数: ",e.length]}),f.jsxs("span",{children:["连线数: ",n.length]})]}),f.jsxs("div",{className:"workflow-debug-panel__detail",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"结构图预览"}),f.jsx("div",{className:"workflow-debug-panel__graph",children:f.jsxs("svg",{className:"workflow-debug-panel__graph-canvas",width:"100%",height:B,viewBox:`0 0 ${O} ${B}`,preserveAspectRatio:"xMinYMin meet",children:[f.jsxs("defs",{children:[f.jsx("marker",{id:"workflow-debug-arrow",markerWidth:"10",markerHeight:"10",refX:"8",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:f.jsx("path",{d:"M0,0 L0,6 L9,3 z",fill:"#8c8c8c"})}),f.jsx("marker",{id:"workflow-debug-arrow-dup",markerWidth:"10",markerHeight:"10",refX:"8",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:f.jsx("path",{d:"M0,0 L0,6 L9,3 z",fill:"#cf1322"})})]}),S.edges.map(T=>{const P=_.get(T.source),$=_.get(T.target);if(!P||!$)return null;const W=C.has(T.id),V=P.x+gd,X=P.y+il/2,G=$.x,te=$.y+il/2;return f.jsx("line",{x1:V,y1:X,x2:G,y2:te,stroke:W?"#cf1322":"#8c8c8c",strokeWidth:W?2.2:1.4,markerEnd:W?"url(#workflow-debug-arrow-dup)":"url(#workflow-debug-arrow)"},T.id)}),S.nodes.map(T=>f.jsxs("g",{transform:`translate(${T.x}, ${T.y})`,children:[f.jsx("rect",{width:gd,height:il,rx:6,fill:"#ffffff",stroke:"#91caff",strokeWidth:1.4}),f.jsx("text",{x:gd/2,y:il/2+4,textAnchor:"middle",fontSize:"11",fill:"#1f1f1f",children:T.label})]},T.id))]})})]}),f.jsxs("div",{className:"workflow-debug-panel__detail",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"Mermaid 图"}),f.jsx("div",{className:"workflow-debug-panel__mermaid-actions",children:f.jsx(x.Button,{size:"small",onClick:async()=>{await wd(D)?x.message.success("Mermaid 已复制"):x.message.error("复制失败")},children:"复制 Mermaid"})}),f.jsx("pre",{children:D})]}),f.jsxs("div",{className:"workflow-debug-panel__detail",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"结构布局"}),f.jsx("pre",{children:N})]}),f.jsxs("div",{className:"workflow-debug-panel__detail",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"连线关系"}),f.jsxs("div",{className:"workflow-debug-panel__edge-list",children:[E.length===0&&f.jsx("div",{className:"workflow-debug-panel__log-empty",children:"暂无连线"}),E.map(T=>f.jsxs("div",{className:`workflow-debug-panel__edge-line${T.isDuplicate?" workflow-debug-panel__edge-line--duplicate":""}`,children:[f.jsx("span",{children:T.text}),T.isDuplicate&&f.jsx("span",{className:"workflow-debug-panel__edge-flag",children:"重复"})]},T.id))]})]}),A&&A.length>0&&f.jsxs("div",{className:"workflow-debug-panel__detail",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"重复连线"}),f.jsx("div",{className:"workflow-debug-panel__edge-list",children:A.map(T=>f.jsxs("div",{className:"workflow-debug-panel__edge-line--duplicate",children:[f.jsx("span",{children:T.relation}),f.jsx("span",{className:"workflow-debug-panel__edge-flag",children:T.edgeIds.join(", ")})]},T.key))})]}),f.jsxs(x.Space,{direction:"vertical",size:8,style:{width:"100%"},children:[f.jsx(x.Select,{value:u,placeholder:"选择节点查看详情",options:w,onChange:T=>d(T),allowClear:!0,size:"small"}),f.jsx(x.Select,{value:h,placeholder:"选择连线查看详情",options:v,onChange:T=>p(T),allowClear:!0,size:"small"})]}),f.jsxs("div",{className:"workflow-debug-panel__detail",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"节点详情"}),f.jsx("pre",{children:y?JSON.stringify(nw(y),null,2):"未选择节点"})]}),f.jsxs("div",{className:"workflow-debug-panel__detail",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"连线详情"}),f.jsx("pre",{children:g?JSON.stringify({...rw(g),sourceName:k.get(g.source),targetName:k.get(g.target),isDuplicate:C.has(g.id)},null,2):"未选择连线"})]})]})]}):null},NO=b.createContext(null),lG=({api:t,children:e})=>f.jsx(NO.Provider,{value:t,children:e}),BO=()=>{const t=b.useContext(NO);if(!t)throw new Error("useCanvasApi must be used within a CanvasApiProvider");return t},FO=t=>{var v;const{workflowId:e,strategy:n,readOnly:r=!1,appFlowMode:o=!1,linkMode:i=!1}=t,s=Vt(),a=Zq(t,n.stickyNodeKey),{setUnSave:l,store:c,updateSaveStatus:u}=a,d=b.useMemo(()=>n.nodeTypes??Bn.getNodeTypes(),[n.nodeTypes]),h=b.useCallback(async()=>{if(e)try{u(hn.SAVING);const{nodes:y,edges:g}=c.getState(),k=y.map(D=>D.id),A=g.filter(D=>k.includes(D.target)&&D.source&&D.sourceHandle&&D.targetHandle),C=tg.getState().workflow.workflowName,E=tg.getState().workflow.executionControl;await n.saveFlow({nodes:y,edges:A,workflowName:C,workflowId:e,executionControl:E}),l(!1),u(hn.SAVED)}catch(y){u(hn.ERROR,y)}},[l,c,n,u,e]);a.saveFlowRef.current=h,tq({workflowId:e,strategy:n,setNodes:a.setNodes,setEdges:a.setEdges,fitView:a.reactFlow.fitView,setLoading:a.setLoading,setUnSave:a.setUnSave,dispatch:a.dispatch,setFlowOpStatusAction:a.setFlowOpStatusAction,refreshWorkFlowNum:a.refreshWorkFlowNum}),iq({workflowId:e,strategy:n,store:a.store,addNodes:a.addNodes,addEdges:a.addEdges,removeEdges:a.removeEdges,setNodeAddCallback:a.setNodeAddCallback,handleEdgeAddNode:a.handleEdgeAddNode,setNodeConfigVisible:a.setNodeConfigVisible,setNodeFitHumanView:a.setNodeFitHumanView,saveFlow:h,engineMode:s.engineMode});const p=n.HeaderComponent,m=n.PanelComponent,w=n.ConfigModalComponent;return f.jsxs(lG,{api:a.canvasApi,children:[f.jsxs("div",{className:a.isPreviewMode?"workflow-canvas-container workflow-canvas-container-preview":"workflow-canvas-container",style:{height:s.canvas.height?`${s.canvas.height}`:i?"calc(100vh - 320px)":void 0},children:[a.showCanvasHeader&&f.jsx(p,{onSave:h,readOnly:r,autoSaveStatus:a.autoSaveStatus,unSave:a.unSave,lastSavedTime:a.lastSavedTime,appFlowMode:o,canvasApi:a.canvasApi}),f.jsxs("div",{className:"workflow-canvas",children:[f.jsx(XU,{loading:a.loading}),f.jsx(JU,{}),f.jsxs(ae.ReactFlow,{nodes:a.nodes,edges:a.edges,onNodesChange:a.onNodesChange,onEdgesChange:a.handleEdgesChange,onConnect:a.handleConnect,multiSelectionKeyCode:null,nodeTypes:d,edgeTypes:$U,connectionLineType:ae.ConnectionLineType.Bezier,connectionMode:ae.ConnectionMode.Loose,onNodeMouseEnter:a.onNodeMouseEnter,onNodeMouseLeave:a.onNodeMouseLeave,onEdgeMouseEnter:a.onEdgeMouseEnter,onEdgeMouseLeave:a.onEdgeMouseLeave,onNodeContextMenu:a.onNodeContextMenu,onPaneContextMenu:a.onPaneContextMenu,defaultEdgeOptions:VU,style:HU,defaultViewport:a.isPreviewMode?jU:zU,minZoom:.1,maxZoom:2,fitView:!1,snapToGrid:!0,snapGrid:[20,20],deleteKeyCode:null,nodesDraggable:!a.isInteractionDisabled,nodesConnectable:!a.isInteractionDisabled,elementsSelectable:!a.isInteractionDisabled,className:"react-flow-canvas-container",...a.restNativeProps,children:[a.showBackground&&f.jsx(ae.Background,{gap:(v=s.canvas.grid)==null?void 0:v.size,color:"#eee",variant:ae.BackgroundVariant.Lines}),a.showFastOperationButtons&&f.jsx(YU,{onOpenNodeSelector:a.handleOpenNodeSelector,onAddNoteNode:a.handleAddNoteNode,onTidyCanvas:a.handleTidy}),a.showControls&&f.jsx(ae.Controls,{onInteractiveChange:y=>{a.setLocked(y)}}),a.showMiniMap&&f.jsx(tG,{}),f.jsx(m,{}),f.jsx(eq,{horizontal:a.helperLineHorizontal,vertical:a.helperLineVertical}),f.jsx(aG,{visible:a.debugVisible,nodes:a.nodes,edges:a.storeEdges,onClose:()=>a.setDebugVisible(!1)})]})]})]}),w&&f.jsx(w,{})]})};var vd=(t=>(t.ONCE="ONCE",t.EACH="EACH",t))(vd||{}),yi=(t=>(t.STOP_WORKFLOW="STOP_WORKFLOW",t.CONTINUE_ERROR_OUTPUT="CONTINUE_ERROR_OUTPUT",t))(yi||{});const yd="error",cG=[{label:"合并执行(ONCE)",value:vd.ONCE},{label:"逐条执行(EACH)",value:vd.EACH}],uG=[{label:"停止工作流(STOP_WORKFLOW)",value:yi.STOP_WORKFLOW},{label:"输出错误并继续(CONTINUE_ERROR_OUTPUT)",value:yi.CONTINUE_ERROR_OUTPUT}],ow=({unit:t,style:e,...n})=>f.jsxs(x.Space.Compact,{style:{width:"100%"},children:[f.jsx(x.InputNumber,{...n,style:{flex:1,...e}}),f.jsx(x.Button,{disabled:!0,style:{pointerEvents:"none"},children:t})]}),dG=({nodeId:t})=>{const[e]=x.Form.useForm(),{getEdges:n,getNode:r,setEdges:o}=ae.useReactFlow(),{handleNodeDataUpdate:i}=Hr();b.useEffect(()=>{var c;const a=r(t),l=((c=a==null?void 0:a.data)==null?void 0:c.settings)??{};e.setFieldsValue({retryCount:l.retryCount??0,retryInterval:l.retryInterval??1e3,timeout:l.timeout??0,onError:l.onError??yi.STOP_WORKFLOW,executeMode:l.executeMode??vd.ONCE})},[t,e,r]);const s=b.useCallback(a=>{const l={retryCount:a.retryCount,retryInterval:a.retryInterval,timeout:a.timeout,onError:a.onError??yi.STOP_WORKFLOW,executeMode:a.executeMode};i({id:t,data:{settings:l}}),l.onError!==yi.CONTINUE_ERROR_OUTPUT&&o(n().filter(c=>!(c.source===t&&(c.sourceHandle||"main")===yd))),x.message.success("节点设置已保存")},[t,i,n,o]);return f.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[f.jsx("div",{style:{flex:1,overflowY:"auto",padding:"16px 16px 0"},children:f.jsxs(x.Form,{form:e,layout:"vertical",onFinish:s,children:[f.jsx(x.Form.Item,{label:"执行模式",name:"executeMode",children:f.jsx(x.Select,{options:cG,style:{width:"100%"}})}),f.jsx(x.Form.Item,{label:"错误处理策略",name:"onError",tooltip:"选择节点执行失败后的处理方式。CONTINUE_ERROR_OUTPUT 会显示 error 输出锚点",children:f.jsx(x.Select,{options:uG,style:{width:"100%"}})}),f.jsx(x.Form.Item,{label:"重试次数",name:"retryCount",tooltip:"失败后自动重试的次数,0 表示不重试",rules:[{type:"number",min:0,max:10,message:"重试次数范围 0–10"}],children:f.jsx(ow,{min:0,max:10,precision:0,unit:"次"})}),f.jsx(x.Form.Item,{noStyle:!0,shouldUpdate:(a,l)=>a.retryCount!==l.retryCount,children:({getFieldValue:a})=>a("retryCount")>0?f.jsx(x.Form.Item,{label:"重试间隔",name:"retryInterval",tooltip:"两次重试之间的等待时间(毫秒)",rules:[{type:"number",min:100,message:"重试间隔至少 100ms"}],children:f.jsx(ow,{min:100,step:500,unit:"ms"})}):null}),f.jsx(x.Form.Item,{label:"执行超时",name:"timeout",tooltip:"节点执行的最大时间(秒),0 表示无限制",rules:[{type:"number",min:0,message:"超时时间不能为负数"}],children:f.jsx(ow,{min:0,step:10,unit:"秒"})})]})}),f.jsx("div",{style:{padding:"12px 16px",borderTop:"1px solid #eaeaea",backgroundColor:"#fff",textAlign:"center"},children:f.jsx(x.Button,{type:"primary",style:{width:180},onClick:()=>e.submit(),children:"保存"})})]})},{TextArea:fG}=x.Input,{Title:hG,Paragraph:pG}=x.Typography;function mG(t,e){var r,o;const n={};for(const i of t){if(i.id===e)continue;const s=(r=i.data)==null?void 0:r.name,a=(o=i.data)==null?void 0:o.output;if(!s||a===void 0||a===null||a==="")continue;let l=a;if(typeof l=="string")try{l=JSON.parse(l)}catch{continue}Array.isArray(l)?n[s]=l:l&&typeof l=="object"&&(Array.isArray(l.default)?n[s]=l.default:n[s]=[l])}return n}const gG=b.forwardRef((t,e)=>{const{nodeId:n,beforeHook:r}=t,{handleNodeDataUpdate:o}=Hr(),i=ae.useInternalNode(n),s=ae.useReactFlow(),a=Ct(),[l,c]=b.useState(""),u=dt.useReactive({testProgress:0,sampleText:"",isError:!1,editable:!1,showErrorAlert:!1,testing:!1,ignoring:!1,successShown:!1,isIgnoreSuccess:!1});b.useEffect(()=>{var g,k;const v=(g=i==null?void 0:i.data)==null?void 0:g.output,y=(k=i==null?void 0:i.data)==null?void 0:k.status;if(u.testProgress=0,u.sampleText="",u.editable=!1,u.testing=!1,u.ignoring=!1,u.showErrorAlert=!1,v!=null&&v!==""){const A=typeof v=="string"?v:JSON.stringify(v,null,2);c(A),y===me.FAILED?(u.isError=!0,u.successShown=!1,u.isIgnoreSuccess=!1):(u.isError=!1,u.successShown=!0,u.isIgnoreSuccess=!1)}else c(""),u.isError=!1,u.successShown=!1,u.isIgnoreSuccess=!1},[n]);const d=b.useCallback(()=>{if(!n)return;u.testing=!0,u.testProgress=60,u.successShown=!1;const v=i==null?void 0:i.data,y=mG(s.getNodes(),n),g={nodeKey:(v==null?void 0:v.nodeKey)??"",nodeVersion:(v==null?void 0:v.nodeVersion)??0,nodeName:(v==null?void 0:v.name)??n,params:(v==null?void 0:v.params)??{},inputData:[],credentialInstanceId:v==null?void 0:v.credentialInstanceId,contextNodes:y,timeoutSeconds:30};DN(g).then(k=>{if(k.success){const A=k.outputData??k.resolvedParams;o({id:n,data:{status:me.SUCCESS,output:A}}),u.isError=!1,u.successShown=!0,u.isIgnoreSuccess=!1,u.showErrorAlert=!1,u.testProgress=100,c(typeof A=="string"?A:JSON.stringify(A,null,2))}else{const A=k.error??"节点执行失败";console.warn("[NextNodeTest] 测试失败:",A),o({id:n,data:{status:me.FAILED}}),u.testProgress=0,u.isError=!0,u.showErrorAlert=!0,c(JSON.stringify({error:A},null,2))}}).catch(k=>{console.error("[NextNodeTest] 请求异常:",k);const A=(k==null?void 0:k.message)??"测试执行失败";o({id:n,data:{status:me.FAILED}}),u.testProgress=0,u.isError=!0,u.showErrorAlert=!0,c(JSON.stringify({error:A},null,2))}).finally(()=>{setTimeout(()=>{u.testProgress=0,u.testing=!1,u.ignoring=!1,u.isIgnoreSuccess=!1},500)})},[n,i,s,o]),h=()=>{u.testProgress=0,u.testing=!1,u.ignoring=!1,u.isIgnoreSuccess=!0};b.useImperativeHandle(e,()=>({onTestNode:d,finishNodeTest:h}));const p=()=>{r?r(!0):d()},m=()=>{const v=u.sampleText||l;if(!v)return;u.testing=!0,u.ignoring=!0,u.testProgress=60;let y;try{y=JSON.parse(v)}catch{y=v}console.log("[NextNodeTest] 忽略调试, 写入样本数据:",y),o({id:n,data:{status:me.SUCCESS,output:y}});const g=typeof y=="string"?y:JSON.stringify(y,null,2);c(g),u.testProgress=100,setTimeout(()=>{u.testProgress=0,u.testing=!1,u.ignoring=!1,u.isIgnoreSuccess=!0,u.isError=!1,u.showErrorAlert=!1,u.successShown=!0},500)},w=()=>{c(""),u.sampleText="",u.editable=!1,u.successShown=!1};return f.jsxs("div",{className:"node-test-container",children:[f.jsxs("div",{className:"node-test-header",children:[f.jsxs("div",{className:"header-title",children:[f.jsx(Z.RocketOutlined,{className:"title-icon"}),f.jsx(hG,{level:4,children:"节点测试"})]}),f.jsx(pG,{type:"secondary",className:"header-description",children:"点击测试按钮,实时检查节点执行效果和结果数据"})]}),f.jsxs("div",{className:"test-content",children:[a&&f.jsxs("div",{className:"action-buttons",children:[f.jsx(x.Button,{type:"primary",disabled:u.ignoring,icon:f.jsx(Z.RocketOutlined,{}),onClick:p,loading:u.testing&&!u.ignoring,className:"test-button",children:u.testing&&!u.ignoring?"测试中...":"开始测试"}),f.jsx(x.Button,{type:"primary",disabled:u.testing&&!u.ignoring||!(u.sampleText||l),ghost:!0,onClick:m,loading:u.testing&&u.ignoring,className:"ignore-button",title:u.sampleText||l?void 0:"请先编辑样本数据",children:"忽略调试"}),l&&f.jsx(x.Button,{icon:f.jsx(Z.ReloadOutlined,{}),onClick:w,className:"reset-button",children:"重置"})]}),u.testProgress>0&&f.jsx(x.Progress,{percent:u.testProgress,status:u.isError?"exception":"active",className:"test-progress"}),u.isError&&u.showErrorAlert&&f.jsx(x.Alert,{className:"error-alert",showIcon:!0,message:"测试未通过",description:"请检查节点配置是否正确",type:"error",onClose:()=>{setTimeout(()=>{u.showErrorAlert=!1},500)},closable:!0}),!u.isError&&u.successShown&&l&&!u.testing&&f.jsx(x.Alert,{className:"success-alert",showIcon:!0,message:u.isIgnoreSuccess?"忽略调试成功":"测试成功",description:u.isIgnoreSuccess?"已将样本数据预设为当前节点输出":"节点运行正常,可以查看下方返回结果",type:"success",closable:a}),u.testing?f.jsx(x.Skeleton,{active:!0,className:"result-skeleton"}):f.jsx(f.Fragment,{children:l?f.jsx(x.Card,{styles:{body:{padding:0}},title:f.jsxs("div",{className:"result-header",children:[f.jsx("div",{className:"result-title",children:u.isError?f.jsxs(f.Fragment,{children:[f.jsx(Z.CloseCircleFilled,{className:"error-icon"})," 错误数据"]}):f.jsxs(f.Fragment,{children:[u.isIgnoreSuccess?f.jsx(Z.ExperimentFilled,{className:"success-icon"}):f.jsx(Z.CheckCircleFilled,{className:"success-icon"}),u.isIgnoreSuccess?"样本数据":"测试结果"]})}),a&&f.jsx(x.Button,{size:"small",type:"link",icon:f.jsx(Z.EditOutlined,{}),onClick:()=>{if(u.editable){u.editable=!1;try{const v=JSON.parse(u.sampleText),y=JSON.stringify(v,null,2);c(y),o({id:n,data:{output:y}})}catch{c(u.sampleText)}}else u.sampleText=l,u.editable=!0},className:"edit-button",children:u.editable?"完成":"编辑"})]}),variant:"borderless",className:`result-card ${u.isError?"error-result":"success-result"}`,children:u.editable?f.jsx(fG,{rows:10,value:u.sampleText,onChange:v=>u.sampleText=v.target.value,className:"result-editor"}):f.jsx(wD,{data:l,height:300,enableCopy:!0,theme:"light"})}):f.jsx(x.Card,{variant:"borderless",className:"empty-result",children:f.jsx(x.Result,{icon:f.jsx(Z.RocketOutlined,{}),title:"等待测试",subTitle:'点击"开始测试"按钮开始节点测试'})})})]})]})}),wG=t=>t.sourceHandle||"main",IO=t=>`${t.node.id}:${t.outputMode}`,vG=t=>{if(t.length===0)return[];if(t.length===1)return t[0];const e=t.slice(1).map(n=>new Set(n.map(IO)));return t[0].filter(n=>e.every(r=>r.has(IO(n))))},yG=(t,e,n)=>{const r=t.filter(o=>o.node.id!==e.id);return r.push({node:e,outputMode:n}),r};function MO(t,e,n,r=new Set){if(r.has(t))return[];const o=n.get(t)??[];if(o.length===0)return[];const i=new Set(r);i.add(t);const s=o.map(a=>{const l=e.get(a.source);if(!l)return[];const c=MO(a.source,e,n,i);return yG(c,l,wG(a)===yd?"error":"normal")});return vG(s)}function bG(t,e,n){const r=new Map(e.map(i=>[i.id,i])),o=new Map;for(const i of n){const s=o.get(i.target)??[];s.push(i),o.set(i.target,s)}return MO(t,r,o)}function bd(t,e){const n=t.trim(),r=n.startsWith("N")?n:`N${n}`,o=e.trim();return o?`{{${r}.${o}}}`:`{{${r}}}`}function CG(t,e){return e.map(n=>({key:`${t}.${n.key}`,title:n.label||n.key,type:n.type,isLeaf:!0,expression:bd(t,n.key)}))}function kG(t){return[{key:`${t}.__error__.errorType`,title:"错误类型",type:"STRING",isLeaf:!0,expression:bd(t,"errorType")},{key:`${t}.__error__.errorDetail`,title:"错误详情",type:"STRING",isLeaf:!0,expression:bd(t,"errorDetail")}]}async function xG(t,e,n){var s,a,l;const r=bG(t,e,n);if(r.length===0)return[];const o=await Promise.all(r.map(async({node:c,outputMode:u})=>{var p,m;const d=(p=c.data)==null?void 0:p.nodeKey;if(!d||u==="error")return{node:c,outputMode:u,schema:null};const h=await Zu(d,(m=c.data)==null?void 0:m.nodeVersion);return{node:c,outputMode:u,schema:h}})),i=[];for(const{node:c,outputMode:u,schema:d}of o){const h=((s=c.data)==null?void 0:s.label)||((a=c.data)==null?void 0:a.action_name)||((l=c.data)==null?void 0:l.nodeKey)||c.id,p=u==="error"?[]:(d==null?void 0:d.output_fields)??[],m=u==="error"?kG(c.id):p.length>0?CG(c.id,p):[{key:`${c.id}.__output__`,title:"output",type:"OBJECT",isLeaf:!0,expression:bd(c.id,"output")}];i.push({key:c.id,title:h,isLeaf:!1,children:m})}return i}const SG={STRING:"orange",NUMBER:"blue",BOOLEAN:"green",OBJECT:"cyan",ARRAY:"purple",EMPTY:"default"},EG={STRING:"Str",NUMBER:"Num",BOOLEAN:"Bool",OBJECT:"Obj",ARRAY:"Arr"},DG=t=>{const e=t.nodes.map(r=>{const o=r.data??{};return[r.id,o.nodeKey??"",o.nodeVersion??"",o.label??"",o.action_name??"",o.name??""].join(":")}).sort().join("|"),n=t.edges.map(r=>[r.id,r.source,r.sourceHandle??"",r.target,r.targetHandle??""].join(":")).sort().join("|");return`${e}||${n}`},AG=b.forwardRef(({nodeId:t,open:e},n)=>{const r=ae.useStoreApi(),o=ae.useStore(DG),{event$:i}=b.useContext($r),s=b.useRef(0),[a,l]=b.useState([]),[c,u]=b.useState(!1),d=b.useCallback(async m=>{if(!t)return;const w=s.current+1;s.current=w,u(!0);try{const{nodes:v,edges:y}=r.getState(),g=await xG(t,v,y);s.current===w&&l(g)}catch(v){console.error("[DIP] 构建变量树失败:",v)}finally{s.current===w&&u(!1)}},[t,r]);b.useImperativeHandle(n,()=>({loadVariables:d})),b.useEffect(()=>{e&&d(o)},[e,o,d]),i.useSubscription(m=>{m.type==="visible"&&m.visible&&d()});const h=b.useCallback((m,w)=>{const v=w.node;!v.isLeaf||!v.expression||i.emit({type:"insert",expression:v.expression})},[i]),p=a.map(m=>{var w;return{key:m.key,title:f.jsxs("span",{style:{fontSize:14,fontWeight:"bold",color:"#777"},children:[f.jsx(Z.UsbOutlined,{style:{color:"#108ee9",marginRight:4,fontSize:16}}),m.title]}),selectable:!1,children:(w=m.children)==null?void 0:w.map(v=>({key:v.key,selectable:v.type!=="EMPTY",isLeaf:v.isLeaf,title:f.jsxs("div",{style:{display:"flex",flexWrap:"nowrap",alignItems:"center"},children:[v.type&&v.type!=="EMPTY"&&f.jsx(x.Tag,{color:SG[v.type]||"gray",style:{textWrap:"nowrap",padding:"0 3px"},children:EG[v.type]||v.type}),f.jsx("span",{style:{fontSize:14,fontWeight:"bold"},children:v.title})]}),...v}))}});return f.jsxs("div",{className:Qe.container,children:[f.jsx("div",{className:Qe.header,children:f.jsxs("div",{style:{display:"flex",alignItems:"center",color:"#999"},children:[f.jsx(Z.RocketOutlined,{style:{fontSize:20,marginRight:10}}),f.jsx("h3",{style:{margin:0,color:"#999"},children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.select-variable"})})]})}),f.jsx("div",{style:{flex:1,overflowY:"auto"},className:"grayBeautifyScrollbar",children:c?f.jsx("div",{style:{textAlign:"center",padding:20},children:f.jsx(x.Spin,{size:"small"})}):p.length>0?f.jsx(x.Tree,{showLine:!0,defaultExpandAll:!0,treeData:p,onSelect:h}):f.jsx(x.Empty,{image:x.Empty.PRESENTED_IMAGE_SIMPLE,description:f.jsx(Ee.FormattedMessage,{id:"common.no-process-variables-yet"})})})]})}),OG=({credentialKey:t,open:e,onCancel:n,onCreated:r})=>{const[o,i]=b.useState(null),[s,a]=b.useState(null),[l,c]=b.useState(!1),[u,d]=b.useState(!1),[h,p]=b.useState(!1),[m]=x.Form.useForm(),[w]=x.Form.useForm();b.useEffect(()=>{!e||!t||(c(!0),Jv(t).then(k=>{var A;i(k),(A=k.fields)!=null&&A.length?a(el(k.fields)):a(null)}).catch(k=>{console.error("获取凭据 Schema 失败:",k),x.message.error("获取凭据配置失败")}).finally(()=>c(!1)))},[e,t]);const v=b.useCallback(()=>{m.resetFields(),w.resetFields(),n()},[m,w,n]),y=b.useCallback(async()=>{try{const k=await w.validateFields(),A=await m.validateFields();d(!0);const C=await Rv({name:k.credentialName,credentialKey:t,credentialVersion:(o==null?void 0:o.version)??1,data:A});x.message.success("凭据创建成功"),m.resetFields(),w.resetFields(),r(C.id)}catch(k){if(k!=null&&k.errorFields)return;console.error("创建凭据失败:",k),x.message.error("创建凭据失败")}finally{d(!1)}},[t,o,m,w,r]),g=b.useCallback(async()=>{try{const k=await w.validateFields(),A=await m.validateFields();p(!0);const C=await Rv({name:k.credentialName,credentialKey:t,credentialVersion:(o==null?void 0:o.version)??1,data:A}),E=await Qv(C.id);E.success?(x.message.success(E.message||"测试连接成功"),m.resetFields(),w.resetFields(),r(C.id)):x.message.error(E.message||"测试连接失败")}catch(k){if(k!=null&&k.errorFields)return;console.error("测试连接失败:",k),x.message.error("测试连接失败")}finally{p(!1)}},[t,o,m,w,r]);return f.jsx(x.Modal,{title:`新建凭据${o!=null&&o.name?` - ${o.name}`:""}`,open:e,onCancel:v,width:560,footer:f.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[f.jsx(x.Button,{onClick:v,children:"取消"}),f.jsx(x.Button,{icon:f.jsx(Z.ApiOutlined,{}),onClick:g,loading:h,children:"测试连接"}),f.jsx(x.Button,{type:"primary",onClick:y,loading:u,children:"确认创建"})]}),destroyOnClose:!0,children:l?f.jsx("div",{style:{textAlign:"center",padding:40},children:f.jsx(x.Spin,{})}):f.jsxs("div",{children:[f.jsx(x.Form,{form:w,layout:"vertical",style:{marginBottom:16},children:f.jsx(x.Form.Item,{label:"凭据名称",name:"credentialName",rules:[{required:!0,message:"请输入凭据名称"}],children:f.jsx(x.Input,{placeholder:"为此凭据起一个名称"})})}),s?f.jsx(Gi,{schema:s,form:m,showSubmit:!1,showReset:!1}):f.jsx("div",{style:{padding:16,color:"#999",textAlign:"center"},children:"该凭据类型暂无配置项"})]})})},TG=({instanceId:t,credentialKey:e,open:n,onCancel:r,onUpdated:o,onDeleted:i})=>{const[s,a]=b.useState(null),[l,c]=b.useState(null),[u,d]=b.useState(!1),[h,p]=b.useState(!1),[m,w]=b.useState(!1),[v,y]=b.useState(!1),[g]=x.Form.useForm(),[k]=x.Form.useForm();b.useEffect(()=>{!n||!t||(d(!0),Promise.all([Jv(e),ON(t)]).then(([S,_])=>{var O;if(a(S),k.setFieldsValue({credentialName:_.name}),(O=S.fields)!=null&&O.length){if(c(el(S.fields)),_.data)try{const B=JSON.parse(_.data);g.setFieldsValue(B)}catch{}}else c(null)}).catch(S=>{console.error("获取凭据信息失败:",S),x.message.error("获取凭据信息失败")}).finally(()=>d(!1)))},[n,t,e,g,k]);const A=b.useCallback(()=>{g.resetFields(),k.resetFields(),r()},[g,k,r]),C=b.useCallback(async()=>{try{const S=await k.validateFields(),_=await g.validateFields();p(!0),await of(t,{name:S.credentialName,data:_}),x.message.success("凭据更新成功"),A(),o()}catch(S){if(S!=null&&S.errorFields)return;console.error("更新凭据失败:",S),x.message.error("更新凭据失败")}finally{p(!1)}},[t,g,k,A,o]),E=b.useCallback(async()=>{try{const S=await k.validateFields(),_=await g.validateFields();w(!0),await of(t,{name:S.credentialName,data:_});const O=await Qv(t);O.success?x.message.success(O.message||"测试连接成功"):x.message.error(O.message||"测试连接失败")}catch(S){if(S!=null&&S.errorFields)return;console.error("测试连接失败:",S),x.message.error("测试连接失败")}finally{w(!1)}},[t,g,k]),D=b.useCallback(async()=>{y(!0);try{await Zv(t),x.message.success("凭据删除成功"),A(),i==null||i()}catch(S){console.error("删除凭据失败:",S),x.message.error("删除凭据失败")}finally{y(!1)}},[t,A,i]);return f.jsx(x.Modal,{title:`编辑凭据${s!=null&&s.name?` - ${s.name}`:""}`,open:n,onCancel:A,width:560,footer:f.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[f.jsx(x.Popconfirm,{title:"确认删除",description:"删除后无法恢复,确定要删除此凭据吗?",onConfirm:D,okText:"删除",cancelText:"取消",okButtonProps:{danger:!0,loading:v},children:f.jsx(x.Button,{danger:!0,icon:f.jsx(Z.DeleteOutlined,{}),loading:v,children:"删除凭据"})}),f.jsxs("div",{style:{display:"flex",gap:8},children:[f.jsx(x.Button,{onClick:A,children:"取消"}),f.jsx(x.Button,{icon:f.jsx(Z.ApiOutlined,{}),onClick:E,loading:m,children:"测试连接"}),f.jsx(x.Button,{type:"primary",onClick:C,loading:h,children:"保存修改"})]})]}),destroyOnClose:!0,children:u?f.jsx("div",{style:{textAlign:"center",padding:40},children:f.jsx(x.Spin,{})}):f.jsxs("div",{children:[f.jsx(x.Form,{form:k,layout:"vertical",style:{marginBottom:16},children:f.jsx(x.Form.Item,{label:"凭据名称",name:"credentialName",rules:[{required:!0,message:"请输入凭据名称"}],children:f.jsx(x.Input,{placeholder:"为此凭据起一个名称"})})}),l?f.jsx(Gi,{schema:l,form:g,showSubmit:!1,showReset:!1}):f.jsx("div",{style:{padding:16,color:"#999",textAlign:"center"},children:"该凭据类型暂无配置项"})]})})},{Text:PO}=x.Typography,_G=({credentialKey:t,label:e="授权配置",required:n=!1,value:r,onChange:o,disabled:i=!1})=>{const[s,a]=b.useState([]),[l,c]=b.useState(!1),[u,d]=b.useState(!1),[h,p]=b.useState(!1),[m,w]=b.useState(null),[v,y]=b.useState(null),[g,k]=b.useState(""),A=b.useRef(null),C=b.useCallback(()=>{t&&(c(!0),AN(t).then(T=>{a(Array.isArray(T)?T:[])}).catch(()=>{a([])}).finally(()=>c(!1)))},[t]);b.useEffect(()=>{C()},[C]),b.useEffect(()=>{v&&A.current&&setTimeout(()=>{var T;(T=A.current)==null||T.focus()},100)},[v]);const E=b.useCallback(T=>{d(!1),C(),o==null||o(T)},[C,o]),D=b.useCallback(T=>{w(T),p(!0)},[]),S=b.useCallback(()=>{p(!1),w(null),C()},[C]),_=b.useCallback(T=>{Zv(T).then(()=>{x.message.success("凭据删除成功"),C(),r===T&&(o==null||o(void 0))}).catch(()=>{x.message.error("删除凭据失败")})},[C,r,o]),O=b.useCallback((T,P,$)=>{T.stopPropagation(),T.preventDefault(),y(P),k($)},[]),B=b.useCallback(()=>{y(null),k("")},[]),N=b.useCallback(()=>{if(!v||!g.trim()){B();return}const T=g.trim(),P=s.find($=>$.id===v);if((P==null?void 0:P.name)===T){B();return}of(v,{name:T}).then(()=>{x.message.success("凭据重命名成功"),C(),B()}).catch(()=>{x.message.error("重命名失败")})},[v,g,s,C,B]),F=b.useCallback(T=>{v&&(T.stopPropagation(),T.preventDefault())},[v]),M=b.useCallback(T=>f.jsxs("div",{children:[T,f.jsx(x.Divider,{style:{margin:"4px 0"}}),f.jsx("div",{style:{padding:"8px",textAlign:"center"},children:f.jsx(x.Button,{icon:f.jsx(Z.PlusOutlined,{}),onClick:()=>d(!0),type:"link",block:!0,disabled:i,children:"新建凭据"})})]}),[i]);return t?f.jsxs("div",{style:{padding:"16px 0"},children:[f.jsxs(PO,{strong:!0,style:{display:"block",marginBottom:8,fontSize:14},children:[e,n?f.jsx("span",{style:{color:"#ff4d4f",marginLeft:4},children:"*"}):null]}),f.jsx(x.Select,{style:{width:"100%"},placeholder:"选择凭据实例",value:r,onChange:T=>o==null?void 0:o(T),loading:l,disabled:i,allowClear:!0,onClear:()=>o==null?void 0:o(void 0),dropdownRender:M,onClick:F,children:s.map(T=>f.jsx(x.Select.Option,{value:T.id,children:f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",padding:"4px 0"},onClick:F,children:[f.jsx("div",{style:{display:"flex",alignItems:"center",maxWidth:"40%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v!==T.id?f.jsxs(b.Fragment,{children:[f.jsx("span",{children:T.name}),f.jsx(Z.EditOutlined,{style:{fontSize:12,color:"#1890ff",marginLeft:6,cursor:"pointer",opacity:.5},onClick:P=>{i||O(P,T.id,T.name)}})]}):f.jsx(x.Input,{ref:A,size:"small",value:g,onChange:P=>k(P.target.value),onPressEnter:N,onBlur:N,onClick:P=>P.stopPropagation(),onMouseDown:P=>P.stopPropagation(),style:{width:120}})}),f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[f.jsx(PO,{type:"secondary",style:{fontSize:12},children:T.updatedAt?cr(T.updatedAt).format("YYYY-MM-DD HH:mm"):T.createdAt?cr(T.createdAt).format("YYYY-MM-DD HH:mm"):""}),f.jsx(x.Button,{type:"link",icon:f.jsx(Z.EditOutlined,{}),size:"small",onClick:P=>{P.stopPropagation(),D(T.id)},disabled:i,children:"编辑"}),f.jsx(x.Popconfirm,{title:"确认删除",description:"删除后无法恢复,确定要删除此凭据吗?",onConfirm:P=>{P==null||P.stopPropagation(),_(T.id)},onCancel:P=>P==null?void 0:P.stopPropagation(),okText:"删除",cancelText:"取消",okButtonProps:{danger:!0},disabled:i,children:f.jsx(x.Button,{type:"link",danger:!0,icon:f.jsx(Z.DeleteOutlined,{}),size:"small",onClick:P=>P.stopPropagation(),disabled:i,children:"删除"})})]})]})},T.id))}),t&&f.jsx(OG,{credentialKey:t,open:u,onCancel:()=>d(!1),onCreated:E}),t&&m&&f.jsx(TG,{instanceId:m,credentialKey:t,open:h,onCancel:()=>{p(!1),w(null)},onUpdated:S,onDeleted:()=>{p(!1),w(null),C(),r===m&&(o==null||o(void 0))}})]}):null},jr="[workflow:schema-render]",NG=/^\{\{([^.{}]+)\.(.+)\}\}$/,BG=b.forwardRef((t,e)=>{const{nodeId:n,data:r,onSubmitted:o,onValuesChange:i,cachedValues:s}=t,[a,l]=b.useState(null),[c,u]=b.useState([]),[d,h]=b.useState(r==null?void 0:r.credentialInstanceId),[p,m]=b.useState(),[w,v]=b.useState(!1),[y,g]=b.useState(!1),[k]=x.Form.useForm(),A=ae.useStoreApi(),C=r==null?void 0:r.nodeKey,E=r==null?void 0:r.nodeVersion;b.useEffect(()=>{if(!C){console.warn(`${jr} open next config without nodeKey`,{nodeId:n,data:r}),g(!0);return}let N=!1;return v(!0),g(!1),console.info(`${jr} open next config`,{nodeId:n,nodeKey:C,nodeVersion:E,hasParams:!!(r!=null&&r.params),credentialInstanceId:r==null?void 0:r.credentialInstanceId}),Zu(C,E).then(F=>{var M,T,P,$,W,V,X;if(N){console.info(`${jr} ignore schema result after unmount`,{nodeId:n,nodeKey:C,nodeVersion:E});return}if(!F){console.warn(`${jr} next config schema empty`,{nodeId:n,nodeKey:C,nodeVersion:E}),l(null),u([]);return}if(console.info(`${jr} next config schema loaded`,{nodeId:n,nodeKey:C,nodeVersion:E,schemaKeys:Object.keys(F),schemaVersion:F.version,inputFields:((M=F.input_fields)==null?void 0:M.length)??0,outputs:((T=F.outputs)==null?void 0:T.length)??0,credentials:((P=F.credentials)==null?void 0:P.length)??0,fieldSummaries:(($=F.input_fields)==null?void 0:$.map(G=>({key:G.key,label:G.label,type:G.type,required:G.required})))??[]}),(W=F.input_fields)!=null&&W.length){const G=el(F.input_fields);console.info(`${jr} next config form schema converted`,{nodeId:n,nodeKey:C,nodeVersion:E,fields:G.fields.length}),l(G)}else console.warn(`${jr} next config schema has no inputFields`,{nodeId:n,nodeKey:C,nodeVersion:E,schemaKeys:Object.keys(F),hasNestedNodeSchema:!!F.node_schema,nestedInputFields:((X=(V=F.node_schema)==null?void 0:V.input_fields)==null?void 0:X.length)??0}),l(null);u(F.credentials??[])}).catch(F=>{console.error(`${jr} next config schema load failed`,{nodeId:n,nodeKey:C,nodeVersion:E,err:F})}).finally(()=>{N||(v(!1),g(!0))}),()=>{N=!0}},[n,C,E]);const D=b.useCallback(N=>{console.info(`${jr} submit next config`,{nodeId:n,nodeKey:C,nodeVersion:E,valueKeys:Object.keys(N),credentialInstanceId:d}),o({params:N,credentialInstanceId:d})},[d,n,C,E,o]),S=b.useCallback(N=>{const F=N.trim().match(NG);if(!F)return null;const M=F[1],T=F[2];if(M==="global")return null;const P=M.startsWith("N")?M.slice(1):M,$=A.getState().nodes.find(W=>W.id===P);return $?{fieldPath:T,node:$,variableNodeId:M}:null},[A]),_=b.useCallback(N=>{var F;return((F=S(N))==null?void 0:F.fieldPath)??N.replace(/^\{\{|\}\}$/g,"")},[S]),O=b.useCallback(N=>{var $;const F=S(N);if(!F)return N;const M=($=F.node)==null?void 0:$.data,T=(M==null?void 0:M.label)||(M==null?void 0:M.name)||(M==null?void 0:M.action_name)||F.variableNodeId,P=M!=null&&M.note?` (${M.note})`:"";return`${T}${P}.${F.fieldPath}`},[S]);b.useImperativeHandle(e,()=>({saveConfig:()=>k.validateFields().then(N=>(D(N),N)).catch(()=>null)}));const B=b.useMemo(()=>Gu(c),[c]);return b.useEffect(()=>{var N;if(!d){m(void 0);return}!p&&((N=B[0])!=null&&N.key)&&m(B[0].key)},[p,d,B]),b.useEffect(()=>{w||!y||a||console.warn(`${jr} render empty config placeholder`,{nodeId:n,nodeKey:C,nodeVersion:E,loading:w})},[a,w,n,C,E,y]),w?f.jsx("div",{style:{textAlign:"center",padding:40},children:f.jsx(x.Spin,{})}):f.jsxs("div",{children:[B.map(N=>f.jsx(_G,{credentialKey:N.key,label:B.length>1?N.label:void 0,required:N.required,value:p===N.key?d:void 0,onChange:F=>{if(F){m(N.key),h(F);return}p===N.key&&(h(void 0),m(void 0))}},N.key)),a?f.jsx(Gi,{schema:a,form:k,initialValues:s??(r==null?void 0:r.params)??{},onSubmit:D,onChange:i?(N,F)=>i(F):void 0,renderVariableTag:_,renderVariableTooltip:O,showSubmit:!1,showReset:!1,nodeId:n}):f.jsx("div",{style:{padding:16,color:"#999",textAlign:"center"},children:C?"该节点暂无配置项":"未知节点类型"}),f.jsx("div",{style:{padding:"12px 0",position:"sticky",backgroundColor:"#FFFFFF",bottom:0,width:"100%",textAlign:"center",borderTop:"1px solid #eaeaea"},children:f.jsx(x.Button,{type:"primary",style:{width:180,borderRadius:4},onClick:()=>{k.validateFields().then(N=>{D(N)}).catch(()=>{})},children:"保存"})})]})}),FG=()=>{const{event$:t}=b.useContext($r),e=xf();return t.useSubscription(n=>{n.type==="insert"&&(console.log("[Bridge] 收到 insert 事件:",{expression:n.expression,hasVarSelector:!!e,activeFieldId:e==null?void 0:e.activeFieldId}),n.expression&&e?e.insertVariableToActiveField(n.expression,!1):e?e.activeFieldId||console.warn("[Bridge] 没有激活的字段(请先点击一个支持变量的表单字段)"):console.warn("[Bridge] VariableSelectorContext 不可用"))}),null},IG=t=>f.jsxs("div",{className:"node-config-title",style:{display:"flex",alignItems:"center"},children:[t.icon?f.jsx("img",{src:t.icon,alt:t.name,style:{width:24,height:24}}):null,f.jsx("div",{className:"node-config-title-name",style:{fontSize:16,fontWeight:600,marginLeft:10},children:t.name}),f.jsx("div",{className:"node-config-title-description",style:{fontSize:12,color:"gray",marginLeft:10},children:t.description})]}),MG=b.memo(({visible:t,onClose:e,data:n,nodeType:r=ee.ACTION,nodeId:o="",cachedValues:i,onValuesChange:s})=>{var A,C,E,D;const a=dt.useEventEmitter(),l=ae.useInternalNode(o),{setNodeConfigVisible:c}=Cr(),u=b.useRef(null),d=b.useRef(null),h=b.useRef(null),p=Vt(),m=((C=(A=p.nodeConfigPanel)==null?void 0:A.testArea)==null?void 0:C.allowManualTest)!==!1,{handleNodeDataUpdate:w}=Hr(),v=b.useRef(ut.debounce((S,_)=>{s==null||s(S,_)},300)).current,y=b.useMemo(()=>p.nodeConfigPanel.showSettings&&![ee.TRIGGER,ee.MCP_TOOL,ee.AI_SUB_NODE].includes(r),[r,p.nodeConfigPanel.showSettings]),g=b.useCallback(async(S,_)=>{try{w({id:o,data:{params:S.params,credentialInstanceId:S.credentialInstanceId}}),x.message.success("节点配置已保存"),s==null||s(o,null),_&&h.current&&h.current.onTestNode()}catch{}},[(E=l==null?void 0:l.position)==null?void 0:E.x,(D=l==null?void 0:l.position)==null?void 0:D.y,o,w,s]),k=async(S,_)=>{var O,B;if(!_&&S)try{x.message.loading("正在保存节点配置...",0),await((O=d.current)==null?void 0:O.saveConfig()),x.message.destroy(),(B=h.current)==null||B.onTestNode()}catch{x.message.destroy(),x.message.error("节点配置保存失败,无法执行测试")}};return f.jsx(x.Modal,{open:t,footer:null,closeIcon:null,maskClosable:!0,onCancel:()=>{c(null)},centered:!0,width:"70%",className:"nodes-config-modal",styles:{wrapper:{minWidth:1040},mask:{backgroundColor:"rgba(0, 0, 0, 0.45)"},content:{padding:0,overflow:"hidden"}},children:f.jsx($r.Provider,{value:{event$:a},children:f.jsxs(kf,{children:[f.jsx(FG,{}),f.jsxs("div",{className:"nodes-config-container",children:[f.jsxs("div",{className:"nodes-config-header",children:[f.jsx("div",{className:"header-left",children:f.jsx("span",{className:"header-title",children:" 节点配置"})}),f.jsx("div",{className:"header-right",children:f.jsx(x.Button,{type:"text",icon:f.jsx(Z.ArrowLeftOutlined,{}),onClick:e,className:"back-button",children:"返回画布"})})]}),f.jsx("div",{className:"nodes-config-content",children:f.jsxs(x.Row,{gutter:16,className:"config-row",children:[f.jsx(x.Col,{span:5,className:"left-section",children:f.jsx("div",{className:"variables-section",children:f.jsx(AG,{ref:u,nodeId:o,open:t})})}),f.jsx(x.Col,{span:12,className:"middle-section",children:f.jsx("div",{className:"form-section",style:{height:"100%"},children:f.jsx(x.Card,{title:f.jsx(IG,{icon:n==null?void 0:n.icon,name:n==null?void 0:n.name,description:n==null?void 0:n.description}),variant:"borderless",styles:{body:{paddingTop:0,paddingBottom:0}},className:"section-card form-card",children:f.jsx(x.Tabs,{style:{height:"100%"},items:[{key:"property",label:"参数配置",children:f.jsx(BG,{ref:d,nodeId:o,data:n,onSubmitted:g,cachedValues:i,onValuesChange:s?S=>v(o,S):void 0})},...y?[{key:"setting",label:"设置",children:f.jsx(dG,{nodeId:o})}]:[]]})})})}),f.jsx(x.Col,{span:7,className:"right-section",children:m&&f.jsx("div",{className:"test-section",children:f.jsx(x.Card,{variant:"borderless",className:"section-card",children:f.jsx(gG,{ref:h,nodeId:o,beforeHook:k})})})})]})})]})]})})})},(t,e)=>ut.isEqual(ut.omit(t,["isHovered"]),ut.omit(e,["isHovered"])));function PG(){const t=b.useRef(new Map),e=b.useCallback(i=>t.current.get(i),[]),n=b.useCallback((i,s)=>{t.current.set(i,s)},[]),r=b.useCallback(i=>{t.current.delete(i)},[]),o=b.useCallback((i,s)=>{s===null?r(i):n(i,s)},[r,n]);return{getCachedValues:e,handleValuesChange:o}}const LG=()=>{const{currentNodeConfigVisibleId:t,setNodeConfigVisible:e}=Cr(),n=ae.useStoreApi(),{getCachedValues:r,handleValuesChange:o}=PG(),i=t?n.getState().nodes.find(s=>s.id===t):void 0;return f.jsx(MG,{visible:!!t,onClose:()=>e(null),nodeType:i==null?void 0:i.type,data:i==null?void 0:i.data,nodeId:t??"",cachedValues:t?r(t):void 0,onValuesChange:o})};function LO(t,e){return e===1?{top:"50%"}:{top:`${(t+1)/(e+1)*100}%`}}const Cd=t=>{const{id:e,data:n,selected:r,minHeight:o=72,maxHeight:i=300,className:s}=t,[a,l]=b.useState(null),[c,u]=b.useState(!0),d=ae.useUpdateNodeInternals(),h=n==null?void 0:n.settings,p=(h==null?void 0:h.onError)===yi.CONTINUE_ERROR_OUTPUT;b.useEffect(()=>{const k=n==null?void 0:n.nodeKey,A=n==null?void 0:n.nodeVersion;if(!k){u(!1);return}let C=!1;return Zu(k,A).then(E=>{!C&&E&&l(E)}).catch(E=>{console.error("[NextBaseNode] 加载 Schema 失败:",E)}).finally(()=>{C||u(!1)}),()=>{C=!0}},[n==null?void 0:n.nodeKey,n==null?void 0:n.nodeVersion]);const m=b.useMemo(()=>!(a!=null&&a.inputs)||a.inputs.length===0?[{id:"main",position:ae.Position.Left,type:je.TARGET}]:a.inputs.map((k,A)=>({id:k.name,position:ae.Position.Left,type:je.TARGET,label:k.displayName,style:LO(A,a.inputs.length)})),[a]),w=b.useMemo(()=>{const k=!(a!=null&&a.outputs)||a.outputs.length===0?[{id:"main",position:ae.Position.Right,type:je.SOURCE,maxConnections:1}]:a.outputs.map(E=>({id:E.name,position:ae.Position.Right,type:je.SOURCE,maxConnections:1,label:E.displayName})),A=k.some(E=>E.id===yd),C=p&&!A?[...k,{id:yd,position:ae.Position.Right,type:je.SOURCE,maxConnections:1,label:"error"}]:k;return C.map((E,D)=>({...E,style:LO(D,C.length)}))},[a,p]),v=b.useMemo(()=>{const k=Math.max(m.length,w.length);return k<=1?o:Math.min(k*40,i)},[m.length,w.length,o,i]),y=m.length+w.length;b.useEffect(()=>{if(c||!a||y===0)return;const k=setTimeout(()=>{d(e)},100);return()=>{clearTimeout(k)}},[c,a,y,e,d]);const g=n;return f.jsx(_n,{id:e,data:g,selected:r,height:v,className:s,icon:g!=null&&g.icon?f.jsx("img",{src:g.icon,alt:g.label,style:{width:30,height:30}}):f.jsx(Z.PlayCircleOutlined,{style:{fontSize:24,color:"#007fff"}}),inputs:m,outputs:w,status:g.status})},$G=t=>f.jsx(Cd,{...t,className:"next-action-node"}),HG=t=>f.jsx(Cd,{...t,className:"next-condition-node"}),zG=t=>f.jsx(Cd,{...t,className:"next-switch-node",maxHeight:400}),$O=t=>f.jsx(Cd,{...t,className:"next-loop-node"}),jG=t=>{const{id:e,data:n,selected:r}=t,o=n,i=[{id:"main",position:ae.Position.Right,type:je.SOURCE,isMain:!0,label:"",maxConnections:1}];return f.jsx(_n,{id:e,data:o,selected:r,type:ee.TRIGGER,status:o==null?void 0:o.status,icon:o!=null&&o.icon?f.jsx("img",{src:o==null?void 0:o.icon,alt:o.label,style:{width:30,height:30}}):f.jsx(Fw.PiCursorFill,{style:{color:"#007fff",fontSize:24}}),inputs:[],outputs:i,className:"workflow-trigger-node"})};class VG{static getNodeTypes(){return{[ee.START]:AD,[ee.TRIGGER]:jG,[ee.ACTION]:$G,[ee.CONDITION]:HG,[ee.SWITCH]:zG,[ee.LOOP]:$O,[ee.SELF_LOOP]:$O,[ee.AGENT]:CD,[ee.BROWSER]:kD,[ee.AI_SUB_NODE]:od,[ee.VECTOR_STORE]:od,[ee.MCPServer]:ED,[ee.BuiltinMCP]:xD,[ee.MCP_TOOL]:DD,[ee.CUSTOM]:SD,[ee.STICKY]:fA}}}function WG(t,e){const n=new Set(e.map(o=>{var i;return((i=o.data)==null?void 0:i.name)||""}));if(!n.has(t))return t;let r=1;for(;n.has(`${t} ${r}`);)r++;return`${t} ${r}`}const UG={async loadFlow(t){const e=await CN(t),{nodes:n,edges:r,workflowName:o}=FU(e);return{nodes:n,edges:r,name:o,opStatus:e.active?We.ONLINE:We.OFFLINE}},async saveFlow({nodes:t,edges:e,workflowName:n,workflowId:r}){await Xv(r,LU(t,e,n))},async createNode({actionId:t,icon:e,name:n,connectorName:r,nodeVersion:o,existingNodes:i}){const s=WG(n||"",i||[]);return{nodeId:IU(),nodeData:{connector_name:r||"",name:s,action_name:s,label:s,status:1,protocol:"",icon:e,nodeKey:t,nodeVersion:o??1}}},stickyNodeKey:UU,nodeTypes:VG.getNodeTypes(),convertNodeData:og,HeaderComponent:KU,PanelComponent:kU,ConfigModalComponent:LG,requiresTriggerNode:!1},qG=t=>f.jsx(FO,{strategy:UG,...t});var wr=(t=>(t.SECOND="second",t.MINUTE="minute",t.HOUR="hour",t))(wr||{});function GG(t){return{[wr.SECOND]:"SECONDS",[wr.MINUTE]:"MINUTES",[wr.HOUR]:"HOURS"}[t]}function KG(t){return{SECONDS:wr.SECOND,MINUTES:wr.MINUTE,HOURS:wr.HOUR}[t]}function YG(){return{enableControl:!1,timeoutValue:30,timeoutUnit:wr.MINUTE,maxNodeExecutions:1e4,webhookUrl:""}}function XG(t){return{enabled:t.enableControl,timeout_value:t.timeoutValue,timeout_unit:GG(t.timeoutUnit),max_node_executions:t.maxNodeExecutions,webhook_url:t.webhookUrl||void 0}}function JG(t){return{enableControl:t.enabled,timeoutValue:t.timeout_value,timeoutUnit:KG(t.timeout_unit),maxNodeExecutions:t.max_node_executions,webhookUrl:t.webhook_url||""}}function RG(t){if(!t)return!0;try{return new URL(t),!0}catch{return!1}}const{Text:iw}=x.Typography,QG=()=>{const[t,e]=b.useState(!1),[n,r]=b.useState(!1),[o]=x.Form.useForm(),i=x.Form.useWatch("enableControl",o),s=Ss(),a=Io(p=>p.workflow.executionControl),l=BO(),c=()=>{e(!0),o.setFieldsValue(a?JG(a):YG())},u=()=>{e(!1)},d=async()=>{try{const p=await o.validateFields();r(!0),s(mA(XG(p))),await l.saveFlow(),x.message.success("保存成功"),e(!1)}catch(p){x.message.error("保存失败"),console.error(p)}finally{r(!1)}},h=(p,m)=>!m||RG(m)?Promise.resolve():Promise.reject(new Error("请输入合法的URL格式"));return f.jsxs(f.Fragment,{children:[f.jsx(x.Tooltip,{title:"流程设置",children:f.jsx(x.Button,{type:"text",icon:f.jsx(Z.SettingOutlined,{}),onClick:c})}),f.jsx(x.Drawer,{title:"流程设置",placement:"right",width:480,open:t,onClose:u,footer:f.jsxs(x.Space,{style:{float:"right"},children:[f.jsx(x.Button,{onClick:u,children:"取消"}),f.jsx(x.Button,{type:"primary",onClick:d,loading:n,children:"保存"})]}),children:f.jsxs(x.Form,{form:o,layout:"vertical",autoComplete:"off",children:[f.jsx(x.Form.Item,{label:"执行管控",name:"enableControl",valuePropName:"checked",children:f.jsx(x.Switch,{})}),i&&f.jsxs(f.Fragment,{children:[f.jsxs(x.Form.Item,{label:"执行超时",required:!0,style:{marginBottom:8},children:[f.jsxs(x.Space.Compact,{style:{width:"100%"},children:[f.jsx(x.Form.Item,{name:"timeoutValue",noStyle:!0,rules:[{required:!0,message:"请输入超时时间"},{type:"number",min:1,message:"必须大于0"}],children:f.jsx(x.InputNumber,{style:{width:"70%"},placeholder:"请输入",min:1})}),f.jsx(x.Form.Item,{name:"timeoutUnit",noStyle:!0,rules:[{required:!0}],children:f.jsxs(x.Select,{style:{width:"30%"},children:[f.jsx(x.Select.Option,{value:wr.SECOND,children:"秒"}),f.jsx(x.Select.Option,{value:wr.MINUTE,children:"分钟"}),f.jsx(x.Select.Option,{value:wr.HOUR,children:"小时"})]})})]}),f.jsx(iw,{type:"secondary",style:{fontSize:12},children:"流程执行超过此时间将自动终止,使用墙钟时间计算"})]}),f.jsx(x.Form.Item,{label:"最大节点执行次数",name:"maxNodeExecutions",rules:[{required:!0,message:"请输入最大节点执行次数"},{type:"number",min:1,message:"必须为正整数"}],children:f.jsx(x.InputNumber,{style:{width:"100%"},placeholder:"请输入",min:1,precision:0})}),f.jsx(iw,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-16,marginBottom:16},children:"流程中所有节点执行的总次数上限,超过后将自动终止"}),f.jsx(x.Form.Item,{label:"错误通知 Webhook",name:"webhookUrl",rules:[{validator:h}],children:f.jsx(x.Input,{placeholder:"请输入 Webhook URL"})}),f.jsx(iw,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-16},children:"流程因超时或超限终止时,将向此地址发送通知"})]})]})})]})},{Title:ZG,Text:sw}=x.Typography,HO="[workflow:online-validation]",eK=({opStatus:t})=>{const e=oo();return{[We.UNPUBLISHED]:f.jsx(x.Tag,{bordered:!1,color:"orange",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.not-published"})}),[We.ONLINE]:f.jsx(x.Tag,{bordered:!1,color:"green",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.already-online"})}),[We.OFFLINE]:f.jsx(x.Tag,{bordered:!1,color:"default",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.already-offline"})}),[We.ONLINE_ING]:f.jsx(x.Tag,{bordered:!1,color:"processing",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.going-online"})}),[We.ON_WARN]:f.jsx(Nl,{to:`/link/log?warnId=${e}`,children:f.jsxs(x.Space,{size:[5,5],children:[f.jsx(Z.ExclamationCircleOutlined,{style:{color:"#faad14"}}),f.jsx(Ee.FormattedMessage,{id:"common.warning"})]})}),[We.OFF_WARN]:f.jsx(Nl,{to:`/link/log?warnId=${e}`,children:f.jsxs(x.Space,{size:[5,5],children:[f.jsx(Z.ExclamationCircleOutlined,{style:{color:"#faad14"}}),f.jsx(Ee.FormattedMessage,{id:"common.warning"})]})})}[t]},tK=({onSave:t,readOnly:e=!1,preview:n=!1,autoSaveStatus:r=hn.IDLE,lastSavedTime:o,unSave:i,appFlowMode:s=!1,canvasApi:a})=>{var Y,se;const l=Ss(),c=Ct(),u=Io(Q=>Q.workflow.workflowName),d=Io(Q=>Q.workflow.op_status),[h,p]=b.useState(!1),[m,w]=b.useState(u),[v,y]=b.useState(!1),g=b.useRef(null),{getNodes:k}=ae.useReactFlow(),A=Vt(),C=A.toolbar,E=oo(),D=((Y=k().filter(Q=>Q.type!==ee.START))==null?void 0:Y.length)>0;b.useEffect(()=>{w(u)},[u]),b.useEffect(()=>{h&&g.current&&g.current.focus()},[h]);const S=b.useCallback(()=>{const L=k().filter(q=>q.type!==ee.START).filter(q=>q.data.status!==me.SUCCESS&&q.data.status!==me.RUNNABLE);return L.length&&console.warn(`${HO} node status check failed`,{unhealthyNodes:L.map(q=>({id:q.id,name:q.data.name,type:q.type,status:q.data.status}))}),L.length===0},[k]),_=b.useCallback(()=>{const Q=k().filter(L=>L.type!==ee.START),le=(L,q,J)=>(console.warn(`${HO} required config check failed`,{node:{id:L.id,name:L.data.name,type:L.type,status:L.data.status},reason:q,details:J,configSchema:L.data.config_schema}),!1);for(const L of Q){const{data:q,type:J}=L,{config_schema:K}=q;if(J===ee.LOOP){if(!(K!=null&&K.asc))return le(L,"loop config is missing asc");const re=Object.keys(K??{});if(re.length===0)return le(L,"loop config schema is empty");if(re.some(ie=>typeof K[ie]>"u"))return le(L,"loop config contains undefined values",{undefinedKeys:re.filter(ie=>typeof K[ie]>"u")})}else if(J===ee.CONDITION){if(!(K!=null&&K.or_list)||!K.or_list.length)return le(L,"condition config is missing or_list");if(!K.or_list.every(ie=>ie.and_list.every(he=>he.query&&he.operator)))return le(L,"condition config contains incomplete rules")}else if(J===ee.SWITCH){if(!(K!=null&&K.branches)||!K.branches.length)return le(L,"switch config is missing branches");if(!K.branches.every(ie=>ie.or_list.every(he=>he.and_list.every(Ce=>Ce.query&&Ce.operator))))return le(L,"switch config contains incomplete branch rules")}else if(J!==ee.STICKY){const re=K==null?void 0:K.sub_params;if(!Array.isArray(re))return le(L,"config_schema.sub_params is missing or invalid");const ie=re.every(Ce=>(console.log("subParams :",re),Ce.required?typeof Ce.value<"u"&&Ce.value!==null:!0));if(!ie)return le(L,"required parameters are missing",{missingParams:re.filter(Ce=>Ce.required&&(typeof Ce.value>"u"||Ce.value===null)).map(Ce=>({key:Ce.key,name:Ce.name,label:Ce.label}))});const he=K!=null&&K.account_schema_id?!!K.account_id:!0;if(!ie||!he)return le(L,"account is required but account_id is missing",{accountSchemaId:K==null?void 0:K.account_schema_id,accountId:K==null?void 0:K.account_id})}}return!0},[k]),O=()=>{if((d===We.ONLINE||d===We.ON_WARN)&&(!_()||!S())){x.message.warning("当前流程节点存在异常,请完成节点测试或下线流程后再尝试保存");return}t==null||t()},B=Q=>{w(Q.target.value)};dt.useUnmount(()=>{l(hd()),gi("")});const N=b.useCallback(()=>{const Q=u,le=m.trim(),L=le||"未命名工作流";l(gi(L)),Rd(E,{name:L}).then(()=>{}).catch(()=>{l(gi(Q))}),p(!1)},[l,m,u]),F=()=>{N()},M=()=>{N()},T=()=>{var Q;!e&&((Q=C==null?void 0:C.flowName)==null?void 0:Q.editable)!==!1&&p(!0)},P=()=>{if(i)return f.jsx(x.Tooltip,{title:"暂未保存",children:f.jsx(x.Tag,{bordered:!1,color:"warning",children:"未保存"})});switch(r){case hn.SAVING:return f.jsx(x.Tooltip,{children:f.jsx("div",{style:{display:"flex",alignItems:"center"},children:f.jsx(Z.SyncOutlined,{spin:!0,style:{marginRight:8,color:"#1890ff"}})})});case hn.SAVED:return f.jsx(x.Tooltip,{title:`已自动保存 (${o})`,children:f.jsx("div",{style:{display:"flex",alignItems:"center"},children:f.jsxs(x.Tag,{bordered:!1,color:"green",children:["已保存"," ",f.jsx("span",{style:{fontSize:10,marginLeft:4,color:"#999"},children:o})]})})});case hn.ERROR:return f.jsx(x.Tooltip,{title:"自动保存失败",children:f.jsx(x.Badge,{status:"error",text:f.jsx("span",{children:"保存失败"})})});default:return null}},[$,W]=x.Modal.useModal(),V=async()=>{var L;const Q=d===We.ONLINE||d===We.ON_WARN,le=()=>{var q,J;if((q=C==null?void 0:C.nav)!=null&&q.onBack){C.nav.onBack();return}if((J=C==null?void 0:C.nav)!=null&&J.backTo){_i.push(C.nav.backTo);return}s?_i.back():_i.push("/link/ai-flow")};if(!Q&&((L=C==null?void 0:C.nav)!=null&&L.confirmOnBackWhenOffline)&&i){await $.confirm({title:R("user.common.operation_title"),content:C.nav.backConfirmMessage||"当前流程未保存,是否确认返回?"})&&le();return}le()},X=async(Q={})=>{if(!E)return;y(!0);const{force:le=!1,customFn:L}=Q;return(le?Uv(E):L?L(E):rf(E,We.ONLINE)).then(()=>(x.message.success(R("link.flow.online_success")),l(xs(We.ONLINE)),{success:!0})).catch(J=>({success:!1,error:J})).finally(()=>{y(!1)})},G=async Q=>{if(!E)return;y(!0),(Q?Q(E):rf(E,We.OFFLINE)).then(()=>{x.message.success(R("link.flow.offline_success")),l(xs(We.OFFLINE))}).catch(()=>{}).finally(()=>{y(!1)})},te=async()=>await $.confirm({icon:f.jsx(f.Fragment,{}),centered:!0,title:R("link.flow.confirm_online"),content:(C==null?void 0:C.enableOnlineConfirmMessage)||R("link.flow.force_online_confirm"),cancelText:R("common.no"),okText:R("common.yes")}),H=async Q=>{if(Q){if(!S()){await te()&&await X({force:!0,customFn:C==null?void 0:C.customOnlineApi});return}const L=await X({force:!1,customFn:C==null?void 0:C.customOnlineApi});L&&!L.success&&await te()&&await X({force:!0,customFn:C==null?void 0:C.customOnlineApi})}else G(C==null?void 0:C.customOfflineApi)},j=()=>{var le,L,q,J;const Q=[];return((le=C==null?void 0:C.nav)==null?void 0:le.showBack)!==!1&&(Q.push(f.jsx(x.Button,{type:"text",icon:f.jsx(Z.ArrowLeftOutlined,{className:"workflow-back-icon"}),onClick:V,children:R("app.common.word.back")},"back")),Q.push(f.jsx(x.Divider,{type:"vertical"},"divider-back"))),s||(h?Q.push(f.jsx(x.Input,{ref:g,value:m,onChange:B,onPressEnter:F,onBlur:M,maxLength:30,className:"workflow-name-input",placeholder:"请输入工作流名称"},"name-input")):Q.push(f.jsx("div",{className:"workflow-name",onClick:n?void 0:T,children:u?f.jsxs(f.Fragment,{children:[f.jsx(ZG,{level:4,className:"workflow-name-text",children:u}),!e&&!n&&((L=C==null?void 0:C.flowName)==null?void 0:L.editable)&&f.jsx(Z.FormOutlined,{className:"edit-icon"})]}):f.jsx(x.Skeleton.Input,{active:!0,size:"small"})},"name-display")),Q.push(f.jsx(x.Divider,{type:"vertical"},"divider-name"))),n?Q.push(f.jsx(sw,{type:"secondary",children:"预览模式"},"preview-text")):Q.push(f.jsxs(x.Space,{size:8,children:[A.toolbar.enableOnlineButton&&f.jsxs(b.Fragment,{children:[f.jsx(sw,{children:(C==null?void 0:C.enableFlowText)||"启用流程"}),f.jsx(x.Switch,{disabled:!D,onChange:H,loading:v,checked:d===We.ONLINE||d===We.ON_WARN})]}),f.jsx(x.Divider,{type:"vertical"}),((q=C==null?void 0:C.flowStatusTag)==null?void 0:q.enabled)===!1?null:f.jsx("span",{style:(J=C==null?void 0:C.flowStatusTag)==null?void 0:J.style,children:f.jsx(eK,{opStatus:d})})]},"online-area")),Q.push(f.jsx(x.Divider,{type:"vertical"},"divider-status")),!c&&!n&&Q.push(f.jsx(sw,{type:"secondary",children:"当前流为只读模式,如需编辑,请下线流程"},"readonly-hint")),Q};return f.jsxs("div",{className:"workflow-canvas-header",children:[W,f.jsx("div",{className:"workflow-heder-left-area",children:j()}),f.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[c&&!n&&P(),f.jsx("span",{children:f.jsx(x.Button,{icon:f.jsx(Z.QuestionCircleOutlined,{}),type:"link",onClick:()=>{const Q=(C==null?void 0:C.helpDocUrl)||"https://1in15q85qd.apifox.cn/8698531m0";window.open(Q,"_blank")},children:(C==null?void 0:C.helpDocText)||"帮助文档"})}),f.jsxs(x.Space,{style:{marginLeft:16},children:[(se=C==null?void 0:C.buttons)==null?void 0:se.map(Q=>f.jsx(x.Button,{style:Q.style,icon:Q.icon,type:Q.type??"default",onClick:()=>{Q.onClick&&a&&Q.onClick(a)},children:Q.label},Q.id)),c&&!n&&f.jsx(QG,{}),c&&!n&&f.jsx(f.Fragment,{children:f.jsx(x.Tooltip,{title:"保存",children:f.jsx(x.Button,{onClick:O,type:"primary",children:"保存"})})})]})]})]})},nK=({categories:t,activeId:e,loading:n,onChange:r})=>n?f.jsx("div",{className:"category-tabs-wrapper loading",children:f.jsxs("div",{className:"category-tabs-loading",children:[f.jsx(x.Spin,{size:"small"}),f.jsx("span",{children:"分类加载中"})]})}):f.jsxs("div",{className:"category-tabs-wrapper",children:[f.jsx("div",{className:"category-tabs",children:t.map(o=>f.jsx("div",{className:kn("category-tab",{active:e===o.id}),onClick:()=>r(o),children:o.name},o.id))}),f.jsx("div",{className:"category-tabs-mask left"}),f.jsx("div",{className:"category-tabs-mask right"})]}),rK=({action:t,parentNode:e,onSelect:n})=>{const r=()=>{n(e,t)};return f.jsxs("div",{className:"action-item",onClick:r,children:[f.jsx("div",{className:"item-icon","data-category":e.category.split("-")[0]||"action",children:t.icon?f.jsx("img",{src:t.icon,alt:t.name,style:{width:32,height:32}}):f.jsx("div",{children:t.name.charAt(0).toUpperCase()})}),f.jsxs("div",{className:"item-content",children:[f.jsx("div",{className:"item-title",children:t.name}),t.description&&f.jsx("div",{className:"item-description",children:t.description})]})]})},oK=({node:t,expanded:e,actions:n,loading:r,hasPartialActions:o,onToggle:i,onActionSelect:s,onLoadAllActions:a})=>{const l=()=>{i(t)},c=u=>{u.stopPropagation(),a==null||a(t)};return f.jsxs("div",{className:kn("node-card",{expanded:e}),children:[f.jsxs("div",{className:"node-card-header",onClick:l,children:[f.jsx("div",{className:"node-card-icon",children:t.icon?f.jsx("img",{src:t.icon,alt:t.name}):f.jsx("span",{children:t.name.charAt(0).toUpperCase()})}),f.jsxs("div",{className:"node-card-info",children:[f.jsx("div",{className:"node-card-title",children:t.name}),t.description&&f.jsx("div",{className:"node-card-desc",children:t.description})]}),f.jsx(Z.CaretDownOutlined,{className:kn("node-card-arrow",{expanded:e})})]}),e&&f.jsxs("div",{className:"node-card-body",children:[r?f.jsx("div",{className:"node-card-state",children:"动作加载中..."}):n.length===0?f.jsx("div",{className:"node-card-state",children:"暂无可用动作"}):f.jsx("div",{className:"node-card-actions",children:n.map(u=>f.jsx("div",{className:"node-card-action-wrapper",onClick:d=>d.stopPropagation(),children:f.jsx(rK,{action:u,parentNode:t,onSelect:s})},u.id))}),o&&!r&&f.jsx("div",{className:"node-card-more",onClick:c,children:"查看该节点全部动作"})]})]})},iK=({currentCategory:t,categoryPath:e,selectedNode:n,onBack:r,onClose:o,title:i,subTitle:s,showBackButton:a})=>{const l=()=>n?n.name:t?t.name:"节点选择器",c=()=>n?"选择动作":e.length>0?e.slice(0,-1).map(p=>p.name).join(" / "):"",u=i||l(),d=s??c(),h=typeof a=="boolean"?a:!!(n||e.length>0);return f.jsxs("div",{className:"panel-header",children:[f.jsxs("div",{className:"header-left",children:[h&&r&&f.jsx("div",{className:"back-button",onClick:r,children:f.jsx(Z.ArrowLeftOutlined,{})}),f.jsxs("div",{className:"title",children:[u,d&&f.jsx("div",{className:"category-path",children:d})]})]}),f.jsx("div",{className:"close-button",onClick:o,children:f.jsx(Z.CloseOutlined,{})})]})},zO=[],jO=Object.freeze(Object.defineProperty({__proto__:null,defaultCategories:zO},Symbol.toStringTag,{value:"Module"})),aw="[workflow:schema-render]",sK=new Set(Object.values(ee)),aK=t=>{if(t)return sK.has(t)?t:void 0},lK=({nodeSelectorVisible:t,nodeAddInfo:e})=>{const[n,r]=b.useState(!1),o=oo();return{isLoadingActions:n,fetchNodeActions:async(s,a)=>{a!=null&&a.suppressLoading||r(!0);try{const l=t&&e&&e.trigger===!0,c={linkId:s.id,flowId:o},u=(e==null?void 0:e.protocol)===Be.BUILTIN_MCP?ee.MCP_TOOL:aK(s.type);u&&(c.actionType=u),l&&(c.trigger=!0);const d=await Ev(c);return d&&d.items&&Array.isArray(d.items)?d.items.map(p=>{var w,v,y,g;const m=p.action_ver??((w=p.node_schema)==null?void 0:w.version);return p.action_key&&((y=(v=p.node_schema)==null?void 0:v.input_fields)!=null&&y.length)?(console.info(`${aw} preload schema from actions list`,{actionId:p.id,nodeKey:p.action_key,actionVer:p.action_ver,schemaVersion:p.node_schema.version,resolvedVersion:m,inputFields:p.node_schema.input_fields.length}),hD(p.action_key,m,p.node_schema)):p.action_key&&p.node_schema?console.info(`${aw} action list inline schema has no inputFields`,{actionId:p.id,nodeKey:p.action_key,actionVer:p.action_ver,schemaVersion:p.node_schema.version,resolvedVersion:m,inputFields:((g=p.node_schema.input_fields)==null?void 0:g.length)??0}):p.action_key&&console.info(`${aw} action list item without inline schema`,{actionId:p.id,nodeKey:p.action_key,resolvedVersion:m}),{...p,id:p.id,action_key:p.action_key,action_ver:m,nodeKey:p.action_key,nodeVersion:m,node_schema:p.node_schema,name:p.name||"未命名动作",description:p.description||"",connector_name:s.name,nodeId:s.id,nodeIcon:s.icon}}):[]}catch(l){return console.error("获取动作列表失败:",l),[]}finally{a!=null&&a.suppressLoading||r(!1)}}}},cK=({onFetchCategories:t,restrictToCategory:e,nodeSelectorVisible:n,nodeAddInfo:r,fallbackCategories:o=[]})=>{const[i,s]=b.useState(o),[a,l]=b.useState(!1);return b.useEffect(()=>{if(!n)return;(async()=>{l(!0);try{let u="action";const d=n&&r&&r.trigger,h=r==null?void 0:r.protocol,p=!!h;d?u="trigger":h===Be.AI_TOOL?u="mcp":h===Be.BUILTIN_MCP?u="tool":h===Be.AI_LANGUAGE_MODEL?u="model":h===Be.AI_MEMORY&&(u="memory");const m=await t(u),w=e?m.filter(y=>y.id===e):d?m:m.filter(y=>y.id!=="TRIGGER"),v=e||p?null:{id:"ALL",name:"全部",description:"全部分类",icon:void 0};s(v?[v,...w]:w)}catch(u){console.error("Failed to fetch categories:",u),s(o)}finally{l(!1)}})()},[t,e,n,r,o]),{categories:i,isLoadingCategories:a,setCategories:s}},uK=({categories:t,initialCategory:e,nodeSelectorVisible:n,nodeAddInfo:r,onFetchNodesByCategory:o,defaultPageSize:i=20,flowId:s})=>{const[a,l]=b.useState(e||"ALL"),[c,u]=b.useState([]),[d,h]=b.useState(!1),[p,m]=b.useState({page:1,size:i,total:0,hasMore:!0}),w=n&&r&&r.trigger===!0,v=n&&r&&r.protocol===Be.AI_TOOL,y=n&&r&&r.protocol===Be.BUILTIN_MCP,g=b.useMemo(()=>{const O=r==null?void 0:r.protocol;if(O){if(O===Be.AI_TOOL)return Be.MCP;if(O===Be.AI_LANGUAGE_MODEL||O===Be.AI_MEMORY)return O}},[r==null?void 0:r.protocol]),k=b.useMemo(()=>{const O=r==null?void 0:r.protocol;if(O===Be.AI_TOOL)return"tool";if(O===Be.AI_LANGUAGE_MODEL)return"model";if(O===Be.AI_MEMORY)return"memory"},[r==null?void 0:r.protocol]),A=b.useMemo(()=>a==="ALL"?null:t.find(O=>O.id===a)||null,[a,t]),C=b.useCallback((O,B=1)=>({app_domain_category:O&&O!=="ALL"?O:void 0,page:B,size:i,trigger:!!w,type:k,protocol:g,flow_id:s}),[i,w,k,g,s]),E=b.useCallback(async(O,B=1,N=!1)=>{if(n){h(!0);try{const F=C(O,B),{nodes:M,total:T,size:P}=await o(F);u($=>N?[...$,...M]:M),m({page:B,size:P,total:T,hasMore:B*P<T})}catch(F){console.error("Failed to fetch category data:",F),N||u([])}finally{h(!1)}}},[C,n,o]),D=b.useCallback(async O=>{l(O),await E(O,1,!1)},[E]),S=b.useCallback(async()=>{d||!p.hasMore||await E(a||"ALL",p.page+1,!0)},[E,d,p,a]),_=b.useCallback(()=>{l(e||"ALL"),u([]),m({page:1,size:i,total:0,hasMore:!0})},[e,i]);return b.useEffect(()=>{var B,N;if(!n){_();return}const O=e&&((B=t.find(F=>F.id===e))==null?void 0:B.id)||((N=t[0])==null?void 0:N.id)||"ALL";l(O),E(O,1,!1)},[n,t,e,E,_]),{categoryNodes:c,currentCategory:A,isLoadingNodes:d,isRealTriggerMode:w,isAIToolMode:v,isBuiltinMCPMode:y,navigateToCategory:D,loadMoreNodes:S,resetNavigation:_,pagination:p,activeCategoryId:a,setActiveCategoryId:l}},dK=({onSearch:t})=>{const[e,n]=b.useState(""),[r,o]=b.useState([]),[i,s]=b.useState(!1),[a,l]=b.useState({total:0,page:1,size:20}),c=b.useCallback(async(d,h={})=>{if(n(d),!d.trim()){o([]),l({total:0,page:1,size:h.size||20});return}s(!0);try{const{nodes:p,total:m,page:w,size:v}=await t({...h,name:d});o(p),l({total:m,page:w,size:v})}catch(p){console.error("Search failed:",p),o([]),l({total:0,page:1,size:h.size||20})}finally{s(!1)}},[t]),u=b.useCallback(()=>{n(""),o([]),l({total:0,page:1,size:20})},[]);return{searchText:e,searchResults:r,isSearching:i,searchMeta:a,handleSearch:c,clearSearch:u,setSearchText:n}},lw="[workflow:schema-render]",fK=(t,e)=>{var o,i,s,a;const n=t.action_type||t.node_struct||ee.ACTION,r=t.action_ver??((o=t.node_schema)==null?void 0:o.version);return t.action_key&&((s=(i=t.node_schema)==null?void 0:i.input_fields)!=null&&s.length)?(console.info(`${lw} preload schema from search result`,{actionId:t.id,nodeKey:t.action_key,actionVer:t.action_ver,schemaVersion:t.node_schema.version,resolvedVersion:r,inputFields:t.node_schema.input_fields.length}),hD(t.action_key,r,t.node_schema)):t.action_key&&t.node_schema?console.info(`${lw} search result inline schema has no inputFields`,{actionId:t.id,nodeKey:t.action_key,actionVer:t.action_ver,schemaVersion:t.node_schema.version,resolvedVersion:r,inputFields:((a=t.node_schema.input_fields)==null?void 0:a.length)??0}):t.action_key&&console.info(`${lw} search result action without inline schema`,{actionId:t.id,nodeKey:t.action_key,resolvedVersion:r}),{...t,id:t.id,type:n,action_type:n,action_key:t.action_key,action_ver:r,nodeKey:t.action_key,nodeVersion:r,node_schema:t.node_schema,action_name:t.name||e.name,name:t.name||e.name,description:t.description||e.description||"",connector_name:e.name,nodeId:e.id,nodeIcon:e.icon}},hK=(t,e)=>{if(typeof e=="boolean")return e;if(!t)return!1;const n=t.toUpperCase();return n==="ACTION_ONLY"||n==="BOTH_MATCHED"},pK=(t,e)=>{const{matchedActions:n,defaultExpanded:r,matchType:o}=e||{};return{id:t.id||t.name,type:t.build_type||ee.ACTION,name:t.name,description:t.description||"",category:t.app_domain_category&&t.app_domain_category[0]||"unknown",icon:t.icon||void 0,app_domain_category:t.app_domain_category||[],actionCategories:t.app_action_category||[],deployment_type:t.deployment_type,build_type:t.build_type,matchedActions:n,defaultExpanded:hK(o,r),matchType:o,connector:t}},VO=async(t={})=>{var e;try{const{apiSearchLinks:n}=await Promise.resolve().then(()=>Yv),r=await n({...t,page:t.page||1,size:t.size||20}),o=((e=r.items)==null?void 0:e.map(({connector:i,matched_actions:s,default_expanded:a,match_type:l})=>{const c=(s||[]).map(u=>fK(u,i));return pK(i,{matchedActions:c,defaultExpanded:a,matchType:l})}))||[];return{nodes:o,total:r.total||o.length,page:r.page||t.page||1,size:r.size||t.size||20,pages:r.pages}}catch(n){return console.error("获取节点列表失败:",n),{nodes:[],total:0,page:t.page||1,size:t.size||20,pages:0}}},mK=async t=>{try{const{apiGetNodeCategory:e}=await Promise.resolve().then(()=>Yv),{defaultCategories:n}=await Promise.resolve().then(()=>jO),r=await e({type:t}),o=i=>({id:i.name,name:i.label,description:i.desc||"",icon:i.icon||void 0,search_action:i.search_action||!1,children:i.next&&i.next.length>0?i.next.map(s=>o(s)):void 0,nodes:[]});return Array.isArray(r)?r.map(i=>o(i)):n}catch(e){console.error("获取分类失败:",e);const{defaultCategories:n}=await Promise.resolve().then(()=>jO);return n}},gK=({availableCategories:t=zO,initialCategory:e,onSearch:n,onFetchCategories:r,onFetchNodesByCategory:o,restrictToCategory:i})=>{const s=b.useRef(null),a=b.useRef(null),[l,c]=b.useState([]),[u,d]=b.useState({}),h=n||VO,p=r||mK,m=o||VO,{nodeSelectorVisible:w,closeNodeSelector:v,handleNodeSelect:y,nodeAddInfo:g}=Es(),k=oo(),{fetchNodeActions:A}=lK({nodeSelectorVisible:w,nodeAddInfo:g}),{categories:C,isLoadingCategories:E}=cK({onFetchCategories:p,restrictToCategory:i,nodeSelectorVisible:w,nodeAddInfo:g,fallbackCategories:t}),{searchText:D,searchResults:S,isSearching:_,handleSearch:O,clearSearch:B,setSearchText:N}=dK({onSearch:h}),F=b.useRef(D),{categoryNodes:M,isLoadingNodes:T,isRealTriggerMode:P,navigateToCategory:$,loadMoreNodes:W,resetNavigation:V,pagination:X,activeCategoryId:G,currentCategory:te}=uK({categories:C,initialCategory:e,nodeSelectorVisible:w,nodeAddInfo:g,onFetchNodesByCategory:m,flowId:k}),H=b.useMemo(()=>D?S:M,[D,S,M]),j=b.useMemo(()=>(g==null?void 0:g.protocol)===Be.AI_LANGUAGE_MODEL?"选择模型":"选择动作",[g==null?void 0:g.protocol]),Y=b.useMemo(()=>(g==null?void 0:g.protocol)===Be.AI_LANGUAGE_MODEL||(g==null?void 0:g.protocol)===Be.AI_MEMORY?"按模型名称搜索":"按节点/动作名称搜索",[g==null?void 0:g.protocol]),se=D,Q=b.useMemo(()=>{const de=g==null?void 0:g.protocol;if(de){if(de===Be.AI_TOOL)return Be.MCP;if(de===Be.AI_LANGUAGE_MODEL||de===Be.AI_MEMORY)return de}},[g==null?void 0:g.protocol]),le=b.useMemo(()=>{const de=g==null?void 0:g.protocol;if(de===Be.AI_TOOL)return"tool";if(de===Be.AI_LANGUAGE_MODEL)return"model";if(de===Be.AI_MEMORY)return"memory"},[g==null?void 0:g.protocol]),L=b.useCallback(()=>({app_domain_category:G&&G!=="ALL"?G:void 0,trigger:!!P,type:le,protocol:Q,flow_id:k}),[G,P,le,Q,k]),{run:q,cancel:J}=dt.useDebounceFn(de=>{const Te=de.trim();if(!Te){B(),c([]);return}O(Te,L())},{wait:300}),K=b.useCallback(async de=>{d(_e=>{var tt,cn;return{..._e,[de.id]:{actions:((tt=_e[de.id])==null?void 0:tt.actions)||[],loading:!0,source:(cn=_e[de.id])==null?void 0:cn.source}}});const Te=await A(de,{suppressLoading:!0});d(_e=>({..._e,[de.id]:{actions:Te,loading:!1,source:"full"}}))},[A]),re=async de=>{if(l.includes(de.id)){c(tt=>tt.filter(cn=>cn!==de.id));return}c(tt=>[...tt,de.id]);const _e=u[de.id];(!_e||_e.actions.length===0||_e.source==="search-partial")&&await K(de)},ie=async de=>{await K(de)},he=(de,Te)=>{const _e={...Te,...g,name:de.name,description:Te.name||"",type:(Te==null?void 0:Te.action_type)??ee.ACTION,connector_name:(de==null?void 0:de.name)||"",category:(de==null?void 0:de.category)||"unknown",icon:de.icon,isAction:!0};y(_e)},Ce=async de=>{c([]),B(),await $(de.id)},Fe=de=>{N(de),q(de)},qe=de=>{if(D||!X.hasMore||T)return;const{scrollTop:Te,scrollHeight:_e,clientHeight:tt}=de.currentTarget;_e-Te-tt<120&&W()};b.useEffect(()=>{if(!w){const de=setTimeout(()=>{B(),V(),c([]),d({})},200);return()=>clearTimeout(de)}return()=>J()},[w,B,V,J]),b.useEffect(()=>{if(F.current=D,D){const de=S.filter(Te=>Te.defaultExpanded).map(Te=>Te.id);c(de)}},[S,D]),b.useEffect(()=>{D||c([])},[G,D]),b.useEffect(()=>{F.current&&O(F.current,L())},[G,L,O]),b.useEffect(()=>{d(de=>{const Te={};return H.forEach(_e=>{_e.matchedActions&&_e.matchedActions.length>0?Te[_e.id]={actions:_e.matchedActions,loading:!1,source:"search-partial"}:de[_e.id]?Te[_e.id]=de[_e.id]:Te[_e.id]={actions:[],loading:!1}}),Te})},[H]),dt.useClickAway(()=>{w&&v()},s);const Le=()=>_?f.jsxs("div",{className:"loading-state",children:[f.jsx(x.Spin,{}),f.jsx("span",{className:"loading-text",children:"搜索中..."})]}):!_&&H.length===0?f.jsx("div",{className:"empty-state",children:f.jsx("div",{className:"empty-text",children:"暂无符合条件的节点"})}):f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"node-card-list",children:H.map(de=>{var Te,_e,tt;return f.jsx(oK,{node:de,expanded:l.includes(de.id),actions:((Te=u[de.id])==null?void 0:Te.actions)||[],loading:((_e=u[de.id])==null?void 0:_e.loading)||!1,hasPartialActions:((tt=u[de.id])==null?void 0:tt.source)==="search-partial",onToggle:re,onActionSelect:he,onLoadAllActions:ie},de.id)})}),!D&&T&&H.length>0&&f.jsxs("div",{className:"list-loading",children:[f.jsx(x.Spin,{size:"small"}),f.jsx("span",{children:"正在加载更多"})]}),!D&&!X.hasMore&&!T&&H.length>0&&f.jsx("div",{className:"list-footer",children:"已加载全部"})]});return w?f.jsxs("div",{className:kn("modern-node-selector",{visible:w}),ref:s,children:[f.jsx(iK,{currentCategory:te,categoryPath:[],selectedNode:null,onClose:v,title:j,showBackButton:!1}),f.jsx("div",{className:"search-container",children:f.jsx(x.Input,{placeholder:Y,prefix:f.jsx(Z.SearchOutlined,{style:{color:"#007aff"}}),allowClear:!0,value:se,onChange:de=>Fe(de.target.value)})}),f.jsx(nK,{categories:C,activeId:G||"ALL",loading:E,onChange:Ce}),f.jsx("div",{className:"panel-content",ref:a,onClick:de=>de.stopPropagation(),onScroll:qe,children:Le()})]}):null};function wK(t){return t.map(e=>{const{node_type:n,id:r,position:o,icon:i,action_name:s,connector_name:a,description:l,action_id:c,connector_id:u,properties:d,account_schema_id:h,account_id:p,action_key:m,action_ver:w,...v}=e;let y,g;if(n===ee.STICKY)try{const A=JSON.parse(d.value);y=A.width,g=A.height}catch{}const k={type:n,id:r,position:o,data:{icon:i,label:s,action_name:s,description:l,connector_name:a,connector_id:u,account_id:p,account_schema_id:h,action_id:c,action_key:m,action_ver:w,nodeKey:m||v.nodeKey,nodeVersion:w??v.nodeVersion,params:v.params||d,config_schema:d,...v}};if(typeof y=="number"||typeof g=="number"){const A=k.style||{};k.style={...A,...typeof y=="number"?{width:y}:{},...typeof g=="number"?{height:g}:{}}}return k})}function vK(t){if(!t)return console.error("API返回数据格式错误: 缺少data字段"),{workflowId:"",workflowName:"",nodes:[],edges:[]};const e=wK(t.nodes||[]),n=e.map(o=>o.id),r=(t.connections||[]).map(o=>({...o,type:o.type||"main"})).filter(o=>n.includes(o.target)&&o.source&&o.sourceHandle&&o.targetHandle);return{workflowId:t.id||"",workflowName:t.name||"",nodes:e,edges:r}}function yK(t,e,n=""){const r=t.filter(o=>o.type!==ee.START).map(o=>{const{config_schema:i,config:s,params:a,node_schema:l,...c}=o.data;return{...c,node_type:o.type,connector_id:o.data.connector_id||"",id:o.id,action_id:o.data.action_id||o.data.id||"",account_id:o.data.account_id||null,position:o.position,properties:i||s||{},action_name:o.data.label||"",description:o.data.description||""}});return{name:n,connections:e,nodes:r}}const bK={async loadFlow(t){const e=await _v(t),{nodes:n,edges:r,workflowName:o}=vK(e);return{nodes:n,edges:r,name:o||e.name||"",opStatus:e.op_status,executionControl:e.execution_control??null}},async saveFlow({nodes:t,edges:e,workflowName:n,workflowId:r,executionControl:o}){const i=yK(t,e,n);o&&(i.execution_control=o),await Rd(r,i)},async createNode({workflowId:t,nodeType:e,actionId:n,actionKey:r,actionVer:o,configSchema:i,position:s}){const a=await Ov({flow_id:t,node_type:e,action_id:n,...r?{action_key:r,action_ver:o}:{},properties:i||{},position:s});return{nodeId:a.id,nodeData:{action_name:a.action_name,connector_name:a.connector_name,status:a.status,icon:a.icon,protocol:a.protocol,...r?{action_key:r,action_ver:o,nodeKey:r,nodeVersion:o}:{}}}},stickyNodeKey:WU,nodeTypes:Bn.getNodeTypes(),HeaderComponent:tK,PanelComponent:gK,requiresTriggerNode:!0},CK=t=>f.jsx(FO,{strategy:bK,...t}),Dt={"configSubflow-container":"_configSubflow-container_xgeh3_1","configSubflow-selectSection":"_configSubflow-selectSection_xgeh3_4","configSubflow-selectWrapper":"_configSubflow-selectWrapper_xgeh3_19","configSubflow-select":"_configSubflow-select_xgeh3_4","configSubflow-optionContent":"_configSubflow-optionContent_xgeh3_28","configSubflow-optionName":"_configSubflow-optionName_xgeh3_34","configSubflow-optionLink":"_configSubflow-optionLink_xgeh3_41","configSubflow-paramsSection":"_configSubflow-paramsSection_xgeh3_60","configSubflow-paramsTitle":"_configSubflow-paramsTitle_xgeh3_65","configSubflow-paramsList":"_configSubflow-paramsList_xgeh3_77","configSubflow-paramItem":"_configSubflow-paramItem_xgeh3_82",hasError:"_hasError_xgeh3_95","configSubflow-paramKey":"_configSubflow-paramKey_xgeh3_99","configSubflow-paramKeyLabel":"_configSubflow-paramKeyLabel_xgeh3_104","configSubflow-paramValue":"_configSubflow-paramValue_xgeh3_124","configSubflow-hintMessage":"_configSubflow-hintMessage_xgeh3_150",warning:"_warning_xgeh3_164",info:"_info_xgeh3_169","configSubflow-errorText":"_configSubflow-errorText_xgeh3_179","configSubflow-loading":"_configSubflow-loading_xgeh3_185"},kK=(t,e={})=>!(t!=null&&t.params)||Object.keys(t.params).length===0?[]:Object.entries(t.params).map(([n,r],o)=>({id:`${n}_${o}`,key:n,value:e[n]!==void 0?e[n]:r,exampleValue:r})),xK=t=>!!(t!=null&&t.params&&Object.keys(t.params).length>0),WO=b.forwardRef(({value:t,onChange:e,disabled:n=!1,nodeId:r=""},o)=>{const[i,s]=b.useState(t==null?void 0:t.flowId),[a,l]=b.useState([]),[c,u]=b.useState([]),d=Ct(),h=n||!d,{data:p=[],loading:m,run:w}=dt.useRequest(Kv,{debounceWait:300}),v=p||[],y=b.useMemo(()=>v.find(F=>F.id===i),[v,i]);b.useEffect(()=>{(t==null?void 0:t.flowId)!==i&&s(t==null?void 0:t.flowId)},[t==null?void 0:t.flowId]),b.useEffect(()=>{if(y){const F=kK(y,t==null?void 0:t.input);l(F)}else l([])},[y,t==null?void 0:t.input]);const g=b.useCallback((F,M)=>{if(!F){e==null||e(void 0);return}e==null||e({flowId:F,input:M})},[e]),k=b.useCallback(F=>{s(F),u([]);const M=v.find(P=>P.id===F),T={};M!=null&&M.params&&Object.entries(M.params).forEach(([P,$])=>{T[P]=$}),g(F,T)},[v,g]),A=b.useCallback((F,M)=>{const T={...(t==null?void 0:t.input)||{}};T[F]=M,g(i,T),u(P=>P.filter($=>!($.type==="param"&&$.paramKey===F)))},[i,t==null?void 0:t.input,g]),C=b.useCallback((F,M)=>{M.stopPropagation(),M.preventDefault(),window.open(`/uc/link/ai-flow/edit?id=${F}`,"_blank")},[]),E=b.useCallback(()=>{const F=[];return i||F.push({type:"flow",message:"请选择子流程"}),y!=null&&y.params&&Object.keys(y.params).forEach(M=>{var P;const T=(P=t==null?void 0:t.input)==null?void 0:P[M];(T==null||T==="")&&F.push({type:"param",paramKey:M,message:`参数 "${M}" 不能为空`})}),u(F),F.length===0},[i,y,t==null?void 0:t.input]),D=b.useCallback(()=>{u([])},[]);b.useImperativeHandle(o,()=>({validate:E,clearErrors:D}),[E,D]);const S=()=>{var F;return(F=c.find(M=>M.type==="flow"))==null?void 0:F.message},_=F=>{var M;return(M=c.find(T=>T.type==="param"&&T.paramKey===F))==null?void 0:M.message},O=F=>f.jsxs("div",{className:Dt["configSubflow-optionContent"],children:[f.jsx("span",{className:Dt["configSubflow-optionName"],children:F.name}),f.jsx(x.Tooltip,{title:"在新标签页中打开子流程",children:f.jsx("span",{className:Dt["configSubflow-optionLink"],onClick:M=>C(F.id,M),children:f.jsx(Z.ExportOutlined,{})})})]}),B=()=>i?m?f.jsxs("div",{className:Dt["configSubflow-loading"],children:[f.jsx(x.Spin,{size:"small"}),f.jsx("span",{style:{marginLeft:8},children:"加载中..."})]}):xK(y)?f.jsx("div",{className:Dt["configSubflow-paramsList"],children:a.map(F=>{const M=_(F.key);return f.jsxs("div",{className:`${Dt["configSubflow-paramItem"]} ${M?Dt.hasError:""}`,children:[f.jsx("div",{className:Dt["configSubflow-paramKey"],children:f.jsx(x.Tooltip,{title:`示例值: ${F.exampleValue}`,children:f.jsx("div",{className:Dt["configSubflow-paramKeyLabel"],children:F.key})})}),f.jsxs("div",{className:Dt["configSubflow-paramValue"],children:[f.jsx(tr,{value:F.value,onChange:T=>A(F.key,T),placeholder:`示例: ${F.exampleValue}`,disabled:h,borrow:!0,nodeId:r,valueType:"ADAPTOR"}),M&&f.jsx("div",{className:Dt["configSubflow-errorText"],children:M})]})]},F.id)})}):f.jsxs("div",{className:`${Dt["configSubflow-hintMessage"]} ${Dt.info}`,children:[f.jsx(Z.InfoCircleOutlined,{}),f.jsx("span",{children:"该流程无需进行参数配置"})]}):f.jsxs("div",{className:`${Dt["configSubflow-hintMessage"]} ${Dt.warning}`,children:[f.jsx(Z.InfoCircleOutlined,{}),f.jsx("span",{children:"请先选择子流程"})]}),N=S();return f.jsxs("div",{className:Dt["configSubflow-container"],children:[f.jsxs("div",{className:Dt["configSubflow-selectSection"],children:[f.jsx("div",{className:Dt["configSubflow-selectWrapper"],children:f.jsx(x.Select,{className:Dt["configSubflow-select"],value:i,onChange:k,placeholder:"请选择子流程",disabled:h,loading:m,showSearch:!0,filterOption:!1,onSearch:w,notFoundContent:m?f.jsx(x.Spin,{size:"small"}):"暂无数据",allowClear:!0,status:N?"error":void 0,options:v.map(F=>({value:F.id,label:O(F)}))})}),N&&f.jsx("div",{className:Dt["configSubflow-errorText"],children:N})]}),f.jsxs("div",{className:Dt["configSubflow-paramsSection"],children:[f.jsxs("div",{className:Dt["configSubflow-paramsTitle"],children:[f.jsx(Z.SettingOutlined,{}),f.jsx("span",{children:"参数配置"})]}),B()]})]})});WO.displayName="ConfigSubflow";function SK(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return b.useMemo(()=>r=>{e.forEach(o=>o(r))},e)}const kd=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Os(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function cw(t){return"nodeType"in t}function Fn(t){var e,n;return t?Os(t)?t:cw(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function uw(t){const{Document:e}=Fn(t);return t instanceof e}function sl(t){return Os(t)?!1:t instanceof Fn(t).HTMLElement}function UO(t){return t instanceof Fn(t).SVGElement}function Ts(t){return t?Os(t)?t.document:cw(t)?uw(t)?t:sl(t)||UO(t)?t.ownerDocument:document:document:document}const Vr=kd?b.useLayoutEffect:b.useEffect;function dw(t){const e=b.useRef(t);return Vr(()=>{e.current=t}),b.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e.current==null?void 0:e.current(...r)},[])}function EK(){const t=b.useRef(null),e=b.useCallback((r,o)=>{t.current=setInterval(r,o)},[]),n=b.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function al(t,e){e===void 0&&(e=[t]);const n=b.useRef(t);return Vr(()=>{n.current!==t&&(n.current=t)},e),n}function ll(t,e){const n=b.useRef();return b.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function xd(t){const e=dw(t),n=b.useRef(null),r=b.useCallback(o=>{o!==n.current&&(e==null||e(o,n.current)),n.current=o},[]);return[n,r]}function fw(t){const e=b.useRef();return b.useEffect(()=>{e.current=t},[t]),e.current}let hw={};function cl(t,e){return b.useMemo(()=>{if(e)return e;const n=hw[t]==null?0:hw[t]+1;return hw[t]=n,t+"-"+n},[t,e])}function qO(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,s)=>{const a=Object.entries(s);for(const[l,c]of a){const u=i[l];u!=null&&(i[l]=u+t*c)}return i},{...e})}}const _s=qO(1),ul=qO(-1);function DK(t){return"clientX"in t&&"clientY"in t}function pw(t){if(!t)return!1;const{KeyboardEvent:e}=Fn(t.target);return e&&t instanceof e}function AK(t){if(!t)return!1;const{TouchEvent:e}=Fn(t.target);return e&&t instanceof e}function mw(t){if(AK(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:n}=t.touches[0];return{x:e,y:n}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:n}=t.changedTouches[0];return{x:e,y:n}}}return DK(t)?{x:t.clientX,y:t.clientY}:null}const dl=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[dl.Translate.toString(t),dl.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),GO="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function OK(t){return t.matches(GO)?t:t.querySelector(GO)}const TK={display:"none"};function _K(t){let{id:e,value:n}=t;return b.createElement("div",{id:e,style:TK},n)}function NK(t){let{id:e,announcement:n,ariaLiveType:r="assertive"}=t;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return b.createElement("div",{id:e,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function BK(){const[t,e]=b.useState("");return{announce:b.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const KO=b.createContext(null);function FK(t){const e=b.useContext(KO);b.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function IK(){const[t]=b.useState(()=>new Set),e=b.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[b.useCallback(r=>{let{type:o,event:i}=r;t.forEach(s=>{var a;return(a=s[o])==null?void 0:a.call(s,i)})},[t]),e]}const MK={draggable:`
|
|
98
|
+
`)})]}),T.detail&&f.jsxs("div",{className:"workflow-debug-panel__log-detail-block",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"详细信息"}),f.jsx("pre",{children:JSON.stringify(T.detail,null,2)})]})]})]},T.id))]})]}),f.jsxs("div",{className:"workflow-debug-panel__section",children:[f.jsxs("div",{className:"workflow-debug-panel__summary",children:[f.jsxs("span",{children:["节点数: ",e.length]}),f.jsxs("span",{children:["连线数: ",n.length]})]}),f.jsxs("div",{className:"workflow-debug-panel__detail",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"结构图预览"}),f.jsx("div",{className:"workflow-debug-panel__graph",children:f.jsxs("svg",{className:"workflow-debug-panel__graph-canvas",width:"100%",height:B,viewBox:`0 0 ${O} ${B}`,preserveAspectRatio:"xMinYMin meet",children:[f.jsxs("defs",{children:[f.jsx("marker",{id:"workflow-debug-arrow",markerWidth:"10",markerHeight:"10",refX:"8",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:f.jsx("path",{d:"M0,0 L0,6 L9,3 z",fill:"#8c8c8c"})}),f.jsx("marker",{id:"workflow-debug-arrow-dup",markerWidth:"10",markerHeight:"10",refX:"8",refY:"3",orient:"auto",markerUnits:"strokeWidth",children:f.jsx("path",{d:"M0,0 L0,6 L9,3 z",fill:"#cf1322"})})]}),S.edges.map(T=>{const P=_.get(T.source),$=_.get(T.target);if(!P||!$)return null;const W=C.has(T.id),V=P.x+gd,X=P.y+il/2,G=$.x,te=$.y+il/2;return f.jsx("line",{x1:V,y1:X,x2:G,y2:te,stroke:W?"#cf1322":"#8c8c8c",strokeWidth:W?2.2:1.4,markerEnd:W?"url(#workflow-debug-arrow-dup)":"url(#workflow-debug-arrow)"},T.id)}),S.nodes.map(T=>f.jsxs("g",{transform:`translate(${T.x}, ${T.y})`,children:[f.jsx("rect",{width:gd,height:il,rx:6,fill:"#ffffff",stroke:"#91caff",strokeWidth:1.4}),f.jsx("text",{x:gd/2,y:il/2+4,textAnchor:"middle",fontSize:"11",fill:"#1f1f1f",children:T.label})]},T.id))]})})]}),f.jsxs("div",{className:"workflow-debug-panel__detail",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"Mermaid 图"}),f.jsx("div",{className:"workflow-debug-panel__mermaid-actions",children:f.jsx(x.Button,{size:"small",onClick:async()=>{await wd(D)?x.message.success("Mermaid 已复制"):x.message.error("复制失败")},children:"复制 Mermaid"})}),f.jsx("pre",{children:D})]}),f.jsxs("div",{className:"workflow-debug-panel__detail",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"结构布局"}),f.jsx("pre",{children:N})]}),f.jsxs("div",{className:"workflow-debug-panel__detail",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"连线关系"}),f.jsxs("div",{className:"workflow-debug-panel__edge-list",children:[E.length===0&&f.jsx("div",{className:"workflow-debug-panel__log-empty",children:"暂无连线"}),E.map(T=>f.jsxs("div",{className:`workflow-debug-panel__edge-line${T.isDuplicate?" workflow-debug-panel__edge-line--duplicate":""}`,children:[f.jsx("span",{children:T.text}),T.isDuplicate&&f.jsx("span",{className:"workflow-debug-panel__edge-flag",children:"重复"})]},T.id))]})]}),A&&A.length>0&&f.jsxs("div",{className:"workflow-debug-panel__detail",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"重复连线"}),f.jsx("div",{className:"workflow-debug-panel__edge-list",children:A.map(T=>f.jsxs("div",{className:"workflow-debug-panel__edge-line--duplicate",children:[f.jsx("span",{children:T.relation}),f.jsx("span",{className:"workflow-debug-panel__edge-flag",children:T.edgeIds.join(", ")})]},T.key))})]}),f.jsxs(x.Space,{direction:"vertical",size:8,style:{width:"100%"},children:[f.jsx(x.Select,{value:u,placeholder:"选择节点查看详情",options:w,onChange:T=>d(T),allowClear:!0,size:"small"}),f.jsx(x.Select,{value:h,placeholder:"选择连线查看详情",options:v,onChange:T=>p(T),allowClear:!0,size:"small"})]}),f.jsxs("div",{className:"workflow-debug-panel__detail",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"节点详情"}),f.jsx("pre",{children:y?JSON.stringify(nw(y),null,2):"未选择节点"})]}),f.jsxs("div",{className:"workflow-debug-panel__detail",children:[f.jsx("div",{className:"workflow-debug-panel__detail-title",children:"连线详情"}),f.jsx("pre",{children:g?JSON.stringify({...rw(g),sourceName:k.get(g.source),targetName:k.get(g.target),isDuplicate:C.has(g.id)},null,2):"未选择连线"})]})]})]}):null},NO=b.createContext(null),lG=({api:t,children:e})=>f.jsx(NO.Provider,{value:t,children:e}),BO=()=>{const t=b.useContext(NO);if(!t)throw new Error("useCanvasApi must be used within a CanvasApiProvider");return t},FO=t=>{var v;const{workflowId:e,strategy:n,readOnly:r=!1,appFlowMode:o=!1,linkMode:i=!1}=t,s=Vt(),a=Zq(t,n.stickyNodeKey),{setUnSave:l,store:c,updateSaveStatus:u}=a,d=b.useMemo(()=>n.nodeTypes??Bn.getNodeTypes(),[n.nodeTypes]),h=b.useCallback(async()=>{if(e)try{u(hn.SAVING);const{nodes:y,edges:g}=c.getState(),k=y.map(D=>D.id),A=g.filter(D=>k.includes(D.target)&&D.source&&D.sourceHandle&&D.targetHandle),C=tg.getState().workflow.workflowName,E=tg.getState().workflow.executionControl;await n.saveFlow({nodes:y,edges:A,workflowName:C,workflowId:e,executionControl:E}),l(!1),u(hn.SAVED)}catch(y){u(hn.ERROR,y)}},[l,c,n,u,e]);a.saveFlowRef.current=h,tq({workflowId:e,strategy:n,setNodes:a.setNodes,setEdges:a.setEdges,fitView:a.reactFlow.fitView,setLoading:a.setLoading,setUnSave:a.setUnSave,dispatch:a.dispatch,setFlowOpStatusAction:a.setFlowOpStatusAction,refreshWorkFlowNum:a.refreshWorkFlowNum}),iq({workflowId:e,strategy:n,store:a.store,addNodes:a.addNodes,addEdges:a.addEdges,removeEdges:a.removeEdges,setNodeAddCallback:a.setNodeAddCallback,handleEdgeAddNode:a.handleEdgeAddNode,setNodeConfigVisible:a.setNodeConfigVisible,setNodeFitHumanView:a.setNodeFitHumanView,saveFlow:h,engineMode:s.engineMode});const p=n.HeaderComponent,m=n.PanelComponent,w=n.ConfigModalComponent;return f.jsxs(lG,{api:a.canvasApi,children:[f.jsxs("div",{className:a.isPreviewMode?"workflow-canvas-container workflow-canvas-container-preview":"workflow-canvas-container",style:{height:s.canvas.height?`${s.canvas.height}`:i?"calc(100vh - 320px)":void 0},children:[a.showCanvasHeader&&f.jsx(p,{onSave:h,readOnly:r,autoSaveStatus:a.autoSaveStatus,unSave:a.unSave,lastSavedTime:a.lastSavedTime,appFlowMode:o,canvasApi:a.canvasApi}),f.jsxs("div",{className:"workflow-canvas",children:[f.jsx(XU,{loading:a.loading}),f.jsx(JU,{}),f.jsxs(ae.ReactFlow,{nodes:a.nodes,edges:a.edges,onNodesChange:a.onNodesChange,onEdgesChange:a.handleEdgesChange,onConnect:a.handleConnect,multiSelectionKeyCode:null,nodeTypes:d,edgeTypes:$U,connectionLineType:ae.ConnectionLineType.Bezier,connectionMode:ae.ConnectionMode.Loose,onNodeMouseEnter:a.onNodeMouseEnter,onNodeMouseLeave:a.onNodeMouseLeave,onEdgeMouseEnter:a.onEdgeMouseEnter,onEdgeMouseLeave:a.onEdgeMouseLeave,onNodeContextMenu:a.onNodeContextMenu,onPaneContextMenu:a.onPaneContextMenu,defaultEdgeOptions:VU,style:HU,defaultViewport:a.isPreviewMode?jU:zU,minZoom:.1,maxZoom:2,fitView:!1,snapToGrid:!0,snapGrid:[20,20],deleteKeyCode:null,nodesDraggable:!a.isInteractionDisabled,nodesConnectable:!a.isInteractionDisabled,elementsSelectable:!a.isInteractionDisabled,className:"react-flow-canvas-container",...a.restNativeProps,children:[a.showBackground&&f.jsx(ae.Background,{gap:(v=s.canvas.grid)==null?void 0:v.size,color:"#eee",variant:ae.BackgroundVariant.Lines}),a.showFastOperationButtons&&f.jsx(YU,{onOpenNodeSelector:a.handleOpenNodeSelector,onAddNoteNode:a.handleAddNoteNode,onTidyCanvas:a.handleTidy}),a.showControls&&f.jsx(ae.Controls,{onInteractiveChange:y=>{a.setLocked(y)}}),a.showMiniMap&&f.jsx(tG,{}),f.jsx(m,{}),f.jsx(eq,{horizontal:a.helperLineHorizontal,vertical:a.helperLineVertical}),f.jsx(aG,{visible:a.debugVisible,nodes:a.nodes,edges:a.storeEdges,onClose:()=>a.setDebugVisible(!1)})]})]})]}),w&&f.jsx(w,{})]})};var vd=(t=>(t.ONCE="ONCE",t.EACH="EACH",t))(vd||{}),yi=(t=>(t.STOP_WORKFLOW="STOP_WORKFLOW",t.CONTINUE_ERROR_OUTPUT="CONTINUE_ERROR_OUTPUT",t))(yi||{});const yd="error",cG=[{label:"合并执行(ONCE)",value:vd.ONCE},{label:"逐条执行(EACH)",value:vd.EACH}],uG=[{label:"停止工作流(STOP_WORKFLOW)",value:yi.STOP_WORKFLOW},{label:"输出错误并继续(CONTINUE_ERROR_OUTPUT)",value:yi.CONTINUE_ERROR_OUTPUT}],ow=({unit:t,style:e,...n})=>f.jsxs(x.Space.Compact,{style:{width:"100%"},children:[f.jsx(x.InputNumber,{...n,style:{flex:1,...e}}),f.jsx(x.Button,{disabled:!0,style:{pointerEvents:"none"},children:t})]}),dG=({nodeId:t})=>{const[e]=x.Form.useForm(),{getEdges:n,getNode:r,setEdges:o}=ae.useReactFlow(),{handleNodeDataUpdate:i}=Hr();b.useEffect(()=>{var c;const a=r(t),l=((c=a==null?void 0:a.data)==null?void 0:c.settings)??{};e.setFieldsValue({retryCount:l.retryCount??0,retryInterval:l.retryInterval??1e3,timeout:l.timeout??0,onError:l.onError??yi.STOP_WORKFLOW,executeMode:l.executeMode??vd.ONCE})},[t,e,r]);const s=b.useCallback(a=>{const l={retryCount:a.retryCount,retryInterval:a.retryInterval,timeout:a.timeout,onError:a.onError??yi.STOP_WORKFLOW,executeMode:a.executeMode};i({id:t,data:{settings:l}}),l.onError!==yi.CONTINUE_ERROR_OUTPUT&&o(n().filter(c=>!(c.source===t&&(c.sourceHandle||"main")===yd))),x.message.success("节点设置已保存")},[t,i,n,o]);return f.jsxs("div",{style:{height:"100%",display:"flex",flexDirection:"column"},children:[f.jsx("div",{style:{flex:1,overflowY:"auto",padding:"16px 16px 0"},children:f.jsxs(x.Form,{form:e,layout:"vertical",onFinish:s,children:[f.jsx(x.Form.Item,{label:"执行模式",name:"executeMode",children:f.jsx(x.Select,{options:cG,style:{width:"100%"}})}),f.jsx(x.Form.Item,{label:"错误处理策略",name:"onError",tooltip:"选择节点执行失败后的处理方式。CONTINUE_ERROR_OUTPUT 会显示 error 输出锚点",children:f.jsx(x.Select,{options:uG,style:{width:"100%"}})}),f.jsx(x.Form.Item,{label:"重试次数",name:"retryCount",tooltip:"失败后自动重试的次数,0 表示不重试",rules:[{type:"number",min:0,max:10,message:"重试次数范围 0–10"}],children:f.jsx(ow,{min:0,max:10,precision:0,unit:"次"})}),f.jsx(x.Form.Item,{noStyle:!0,shouldUpdate:(a,l)=>a.retryCount!==l.retryCount,children:({getFieldValue:a})=>a("retryCount")>0?f.jsx(x.Form.Item,{label:"重试间隔",name:"retryInterval",tooltip:"两次重试之间的等待时间(毫秒)",rules:[{type:"number",min:100,message:"重试间隔至少 100ms"}],children:f.jsx(ow,{min:100,step:500,unit:"ms"})}):null}),f.jsx(x.Form.Item,{label:"执行超时",name:"timeout",tooltip:"节点执行的最大时间(秒),0 表示无限制",rules:[{type:"number",min:0,message:"超时时间不能为负数"}],children:f.jsx(ow,{min:0,step:10,unit:"秒"})})]})}),f.jsx("div",{style:{padding:"12px 16px",borderTop:"1px solid #eaeaea",backgroundColor:"#fff",textAlign:"center"},children:f.jsx(x.Button,{type:"primary",style:{width:180},onClick:()=>e.submit(),children:"保存"})})]})},{TextArea:fG}=x.Input,{Title:hG,Paragraph:pG}=x.Typography;function mG(t,e){var r,o;const n={};for(const i of t){if(i.id===e)continue;const s=(r=i.data)==null?void 0:r.name,a=(o=i.data)==null?void 0:o.output;if(!s||a===void 0||a===null||a==="")continue;let l=a;if(typeof l=="string")try{l=JSON.parse(l)}catch{continue}Array.isArray(l)?n[s]=l:l&&typeof l=="object"&&(Array.isArray(l.default)?n[s]=l.default:n[s]=[l])}return n}const gG=b.forwardRef((t,e)=>{const{nodeId:n,beforeHook:r}=t,{handleNodeDataUpdate:o}=Hr(),i=ae.useInternalNode(n),s=ae.useReactFlow(),a=Ct(),[l,c]=b.useState(""),u=dt.useReactive({testProgress:0,sampleText:"",isError:!1,editable:!1,showErrorAlert:!1,testing:!1,ignoring:!1,successShown:!1,isIgnoreSuccess:!1});b.useEffect(()=>{var g,k;const v=(g=i==null?void 0:i.data)==null?void 0:g.output,y=(k=i==null?void 0:i.data)==null?void 0:k.status;if(u.testProgress=0,u.sampleText="",u.editable=!1,u.testing=!1,u.ignoring=!1,u.showErrorAlert=!1,v!=null&&v!==""){const A=typeof v=="string"?v:JSON.stringify(v,null,2);c(A),y===me.FAILED?(u.isError=!0,u.successShown=!1,u.isIgnoreSuccess=!1):(u.isError=!1,u.successShown=!0,u.isIgnoreSuccess=!1)}else c(""),u.isError=!1,u.successShown=!1,u.isIgnoreSuccess=!1},[n]);const d=b.useCallback(()=>{if(!n)return;u.testing=!0,u.testProgress=60,u.successShown=!1;const v=i==null?void 0:i.data,y=mG(s.getNodes(),n),g={nodeKey:(v==null?void 0:v.nodeKey)??"",nodeVersion:(v==null?void 0:v.nodeVersion)??0,nodeName:(v==null?void 0:v.name)??n,params:(v==null?void 0:v.params)??{},inputData:[],credentialInstanceId:v==null?void 0:v.credentialInstanceId,contextNodes:y,timeoutSeconds:30};DN(g).then(k=>{if(k.success){const A=k.outputData??k.resolvedParams;o({id:n,data:{status:me.SUCCESS,output:A}}),u.isError=!1,u.successShown=!0,u.isIgnoreSuccess=!1,u.showErrorAlert=!1,u.testProgress=100,c(typeof A=="string"?A:JSON.stringify(A,null,2))}else{const A=k.error??"节点执行失败";console.warn("[NextNodeTest] 测试失败:",A),o({id:n,data:{status:me.FAILED}}),u.testProgress=0,u.isError=!0,u.showErrorAlert=!0,c(JSON.stringify({error:A},null,2))}}).catch(k=>{console.error("[NextNodeTest] 请求异常:",k);const A=(k==null?void 0:k.message)??"测试执行失败";o({id:n,data:{status:me.FAILED}}),u.testProgress=0,u.isError=!0,u.showErrorAlert=!0,c(JSON.stringify({error:A},null,2))}).finally(()=>{setTimeout(()=>{u.testProgress=0,u.testing=!1,u.ignoring=!1,u.isIgnoreSuccess=!1},500)})},[n,i,s,o]),h=()=>{u.testProgress=0,u.testing=!1,u.ignoring=!1,u.isIgnoreSuccess=!0};b.useImperativeHandle(e,()=>({onTestNode:d,finishNodeTest:h}));const p=()=>{r?r(!0):d()},m=()=>{const v=u.sampleText||l;if(!v)return;u.testing=!0,u.ignoring=!0,u.testProgress=60;let y;try{y=JSON.parse(v)}catch{y=v}console.log("[NextNodeTest] 忽略调试, 写入样本数据:",y),o({id:n,data:{status:me.SUCCESS,output:y}});const g=typeof y=="string"?y:JSON.stringify(y,null,2);c(g),u.testProgress=100,setTimeout(()=>{u.testProgress=0,u.testing=!1,u.ignoring=!1,u.isIgnoreSuccess=!0,u.isError=!1,u.showErrorAlert=!1,u.successShown=!0},500)},w=()=>{c(""),u.sampleText="",u.editable=!1,u.successShown=!1};return f.jsxs("div",{className:"node-test-container",children:[f.jsxs("div",{className:"node-test-header",children:[f.jsxs("div",{className:"header-title",children:[f.jsx(Z.RocketOutlined,{className:"title-icon"}),f.jsx(hG,{level:4,children:"节点测试"})]}),f.jsx(pG,{type:"secondary",className:"header-description",children:"点击测试按钮,实时检查节点执行效果和结果数据"})]}),f.jsxs("div",{className:"test-content",children:[a&&f.jsxs("div",{className:"action-buttons",children:[f.jsx(x.Button,{type:"primary",disabled:u.ignoring,icon:f.jsx(Z.RocketOutlined,{}),onClick:p,loading:u.testing&&!u.ignoring,className:"test-button",children:u.testing&&!u.ignoring?"测试中...":"开始测试"}),f.jsx(x.Button,{type:"primary",disabled:u.testing&&!u.ignoring||!(u.sampleText||l),ghost:!0,onClick:m,loading:u.testing&&u.ignoring,className:"ignore-button",title:u.sampleText||l?void 0:"请先编辑样本数据",children:"忽略调试"}),l&&f.jsx(x.Button,{icon:f.jsx(Z.ReloadOutlined,{}),onClick:w,className:"reset-button",children:"重置"})]}),u.testProgress>0&&f.jsx(x.Progress,{percent:u.testProgress,status:u.isError?"exception":"active",className:"test-progress"}),u.isError&&u.showErrorAlert&&f.jsx(x.Alert,{className:"error-alert",showIcon:!0,message:"测试未通过",description:"请检查节点配置是否正确",type:"error",onClose:()=>{setTimeout(()=>{u.showErrorAlert=!1},500)},closable:!0}),!u.isError&&u.successShown&&l&&!u.testing&&f.jsx(x.Alert,{className:"success-alert",showIcon:!0,message:u.isIgnoreSuccess?"忽略调试成功":"测试成功",description:u.isIgnoreSuccess?"已将样本数据预设为当前节点输出":"节点运行正常,可以查看下方返回结果",type:"success",closable:a}),u.testing?f.jsx(x.Skeleton,{active:!0,className:"result-skeleton"}):f.jsx(f.Fragment,{children:l?f.jsx(x.Card,{styles:{body:{padding:0}},title:f.jsxs("div",{className:"result-header",children:[f.jsx("div",{className:"result-title",children:u.isError?f.jsxs(f.Fragment,{children:[f.jsx(Z.CloseCircleFilled,{className:"error-icon"})," 错误数据"]}):f.jsxs(f.Fragment,{children:[u.isIgnoreSuccess?f.jsx(Z.ExperimentFilled,{className:"success-icon"}):f.jsx(Z.CheckCircleFilled,{className:"success-icon"}),u.isIgnoreSuccess?"样本数据":"测试结果"]})}),a&&f.jsx(x.Button,{size:"small",type:"link",icon:f.jsx(Z.EditOutlined,{}),onClick:()=>{if(u.editable){u.editable=!1;try{const v=JSON.parse(u.sampleText),y=JSON.stringify(v,null,2);c(y),o({id:n,data:{output:y}})}catch{c(u.sampleText)}}else u.sampleText=l,u.editable=!0},className:"edit-button",children:u.editable?"完成":"编辑"})]}),variant:"borderless",className:`result-card ${u.isError?"error-result":"success-result"}`,children:u.editable?f.jsx(fG,{rows:10,value:u.sampleText,onChange:v=>u.sampleText=v.target.value,className:"result-editor"}):f.jsx(wD,{data:l,height:300,enableCopy:!0,theme:"light"})}):f.jsx(x.Card,{variant:"borderless",className:"empty-result",children:f.jsx(x.Result,{icon:f.jsx(Z.RocketOutlined,{}),title:"等待测试",subTitle:'点击"开始测试"按钮开始节点测试'})})})]})]})}),wG=t=>t.sourceHandle||"main",IO=t=>`${t.node.id}:${t.outputMode}`,vG=t=>{if(t.length===0)return[];if(t.length===1)return t[0];const e=t.slice(1).map(n=>new Set(n.map(IO)));return t[0].filter(n=>e.every(r=>r.has(IO(n))))},yG=(t,e,n)=>{const r=t.filter(o=>o.node.id!==e.id);return r.push({node:e,outputMode:n}),r};function MO(t,e,n,r=new Set){if(r.has(t))return[];const o=n.get(t)??[];if(o.length===0)return[];const i=new Set(r);i.add(t);const s=o.map(a=>{const l=e.get(a.source);if(!l)return[];const c=MO(a.source,e,n,i);return yG(c,l,wG(a)===yd?"error":"normal")});return vG(s)}function bG(t,e,n){const r=new Map(e.map(i=>[i.id,i])),o=new Map;for(const i of n){const s=o.get(i.target)??[];s.push(i),o.set(i.target,s)}return MO(t,r,o)}function bd(t,e){const n=t.trim(),r=n.startsWith("N")?n:`N${n}`,o=e.trim();return o?`{{${r}.${o}}}`:`{{${r}}}`}function CG(t,e){return e.map(n=>({key:`${t}.${n.key}`,title:n.label||n.key,type:n.type,isLeaf:!0,expression:bd(t,n.key)}))}function kG(t){return[{key:`${t}.__error__.errorType`,title:"错误类型",type:"STRING",isLeaf:!0,expression:bd(t,"errorType")},{key:`${t}.__error__.errorDetail`,title:"错误详情",type:"STRING",isLeaf:!0,expression:bd(t,"errorDetail")}]}async function xG(t,e,n){var s,a,l;const r=bG(t,e,n);if(r.length===0)return[];const o=await Promise.all(r.map(async({node:c,outputMode:u})=>{var p,m;const d=(p=c.data)==null?void 0:p.nodeKey;if(!d||u==="error")return{node:c,outputMode:u,schema:null};const h=await Zu(d,(m=c.data)==null?void 0:m.nodeVersion);return{node:c,outputMode:u,schema:h}})),i=[];for(const{node:c,outputMode:u,schema:d}of o){const h=((s=c.data)==null?void 0:s.label)||((a=c.data)==null?void 0:a.action_name)||((l=c.data)==null?void 0:l.nodeKey)||c.id,p=u==="error"?[]:(d==null?void 0:d.output_fields)??[],m=u==="error"?kG(c.id):p.length>0?CG(c.id,p):[{key:`${c.id}.__output__`,title:"output",type:"OBJECT",isLeaf:!0,expression:bd(c.id,"output")}];i.push({key:c.id,title:h,isLeaf:!1,children:m})}return i}const SG={STRING:"orange",NUMBER:"blue",BOOLEAN:"green",OBJECT:"cyan",ARRAY:"purple",EMPTY:"default"},EG={STRING:"Str",NUMBER:"Num",BOOLEAN:"Bool",OBJECT:"Obj",ARRAY:"Arr"},DG=t=>{const e=t.nodes.map(r=>{const o=r.data??{};return[r.id,o.nodeKey??"",o.nodeVersion??"",o.label??"",o.action_name??"",o.name??""].join(":")}).sort().join("|"),n=t.edges.map(r=>[r.id,r.source,r.sourceHandle??"",r.target,r.targetHandle??""].join(":")).sort().join("|");return`${e}||${n}`},AG=b.forwardRef(({nodeId:t,open:e},n)=>{const r=ae.useStoreApi(),o=ae.useStore(DG),{event$:i}=b.useContext($r),s=b.useRef(0),[a,l]=b.useState([]),[c,u]=b.useState(!1),d=b.useCallback(async m=>{if(!t)return;const w=s.current+1;s.current=w,u(!0);try{const{nodes:v,edges:y}=r.getState(),g=await xG(t,v,y);s.current===w&&l(g)}catch(v){console.error("[DIP] 构建变量树失败:",v)}finally{s.current===w&&u(!1)}},[t,r]);b.useImperativeHandle(n,()=>({loadVariables:d})),b.useEffect(()=>{e&&d(o)},[e,o,d]),i.useSubscription(m=>{m.type==="visible"&&m.visible&&d()});const h=b.useCallback((m,w)=>{const v=w.node;!v.isLeaf||!v.expression||i.emit({type:"insert",expression:v.expression})},[i]),p=a.map(m=>{var w;return{key:m.key,title:f.jsxs("span",{style:{fontSize:14,fontWeight:"bold",color:"#777"},children:[f.jsx(Z.UsbOutlined,{style:{color:"#108ee9",marginRight:4,fontSize:16}}),m.title]}),selectable:!1,children:(w=m.children)==null?void 0:w.map(v=>({key:v.key,selectable:v.type!=="EMPTY",isLeaf:v.isLeaf,title:f.jsxs("div",{style:{display:"flex",flexWrap:"nowrap",alignItems:"center"},children:[v.type&&v.type!=="EMPTY"&&f.jsx(x.Tag,{color:SG[v.type]||"gray",style:{textWrap:"nowrap",padding:"0 3px"},children:EG[v.type]||v.type}),f.jsx("span",{style:{fontSize:14,fontWeight:"bold"},children:v.title})]}),...v}))}});return f.jsxs("div",{className:Qe.container,children:[f.jsx("div",{className:Qe.header,children:f.jsxs("div",{style:{display:"flex",alignItems:"center",color:"#999"},children:[f.jsx(Z.RocketOutlined,{style:{fontSize:20,marginRight:10}}),f.jsx("h3",{style:{margin:0,color:"#999"},children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.select-variable"})})]})}),f.jsx("div",{style:{flex:1,overflowY:"auto"},className:"grayBeautifyScrollbar",children:c?f.jsx("div",{style:{textAlign:"center",padding:20},children:f.jsx(x.Spin,{size:"small"})}):p.length>0?f.jsx(x.Tree,{showLine:!0,defaultExpandAll:!0,treeData:p,onSelect:h}):f.jsx(x.Empty,{image:x.Empty.PRESENTED_IMAGE_SIMPLE,description:f.jsx(Ee.FormattedMessage,{id:"common.no-process-variables-yet"})})})]})}),OG=({credentialKey:t,open:e,onCancel:n,onCreated:r})=>{const[o,i]=b.useState(null),[s,a]=b.useState(null),[l,c]=b.useState(!1),[u,d]=b.useState(!1),[h,p]=b.useState(!1),[m]=x.Form.useForm(),[w]=x.Form.useForm();b.useEffect(()=>{!e||!t||(c(!0),Jv(t).then(k=>{var A;i(k),(A=k.fields)!=null&&A.length?a(el(k.fields)):a(null)}).catch(k=>{console.error("获取凭据 Schema 失败:",k),x.message.error("获取凭据配置失败")}).finally(()=>c(!1)))},[e,t]);const v=b.useCallback(()=>{m.resetFields(),w.resetFields(),n()},[m,w,n]),y=b.useCallback(async()=>{try{const k=await w.validateFields(),A=await m.validateFields();d(!0);const C=await Rv({name:k.credentialName,credentialKey:t,credentialVersion:(o==null?void 0:o.version)??1,data:A});x.message.success("凭据创建成功"),m.resetFields(),w.resetFields(),r(C.id)}catch(k){if(k!=null&&k.errorFields)return;console.error("创建凭据失败:",k),x.message.error("创建凭据失败")}finally{d(!1)}},[t,o,m,w,r]),g=b.useCallback(async()=>{try{const k=await w.validateFields(),A=await m.validateFields();p(!0);const C=await Rv({name:k.credentialName,credentialKey:t,credentialVersion:(o==null?void 0:o.version)??1,data:A}),E=await Qv(C.id);E.success?(x.message.success(E.message||"测试连接成功"),m.resetFields(),w.resetFields(),r(C.id)):x.message.error(E.message||"测试连接失败")}catch(k){if(k!=null&&k.errorFields)return;console.error("测试连接失败:",k),x.message.error("测试连接失败")}finally{p(!1)}},[t,o,m,w,r]);return f.jsx(x.Modal,{title:`新建凭据${o!=null&&o.name?` - ${o.name}`:""}`,open:e,onCancel:v,width:560,footer:f.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:8},children:[f.jsx(x.Button,{onClick:v,children:"取消"}),f.jsx(x.Button,{icon:f.jsx(Z.ApiOutlined,{}),onClick:g,loading:h,children:"测试连接"}),f.jsx(x.Button,{type:"primary",onClick:y,loading:u,children:"确认创建"})]}),destroyOnClose:!0,children:l?f.jsx("div",{style:{textAlign:"center",padding:40},children:f.jsx(x.Spin,{})}):f.jsxs("div",{children:[f.jsx(x.Form,{form:w,layout:"vertical",style:{marginBottom:16},children:f.jsx(x.Form.Item,{label:"凭据名称",name:"credentialName",rules:[{required:!0,message:"请输入凭据名称"}],children:f.jsx(x.Input,{placeholder:"为此凭据起一个名称"})})}),s?f.jsx(Gi,{schema:s,form:m,showSubmit:!1,showReset:!1}):f.jsx("div",{style:{padding:16,color:"#999",textAlign:"center"},children:"该凭据类型暂无配置项"})]})})},TG=({instanceId:t,credentialKey:e,open:n,onCancel:r,onUpdated:o,onDeleted:i})=>{const[s,a]=b.useState(null),[l,c]=b.useState(null),[u,d]=b.useState(!1),[h,p]=b.useState(!1),[m,w]=b.useState(!1),[v,y]=b.useState(!1),[g]=x.Form.useForm(),[k]=x.Form.useForm();b.useEffect(()=>{!n||!t||(d(!0),Promise.all([Jv(e),ON(t)]).then(([S,_])=>{var O;if(a(S),k.setFieldsValue({credentialName:_.name}),(O=S.fields)!=null&&O.length){if(c(el(S.fields)),_.data)try{const B=JSON.parse(_.data);g.setFieldsValue(B)}catch{}}else c(null)}).catch(S=>{console.error("获取凭据信息失败:",S),x.message.error("获取凭据信息失败")}).finally(()=>d(!1)))},[n,t,e,g,k]);const A=b.useCallback(()=>{g.resetFields(),k.resetFields(),r()},[g,k,r]),C=b.useCallback(async()=>{try{const S=await k.validateFields(),_=await g.validateFields();p(!0),await of(t,{name:S.credentialName,data:_}),x.message.success("凭据更新成功"),A(),o()}catch(S){if(S!=null&&S.errorFields)return;console.error("更新凭据失败:",S),x.message.error("更新凭据失败")}finally{p(!1)}},[t,g,k,A,o]),E=b.useCallback(async()=>{try{const S=await k.validateFields(),_=await g.validateFields();w(!0),await of(t,{name:S.credentialName,data:_});const O=await Qv(t);O.success?x.message.success(O.message||"测试连接成功"):x.message.error(O.message||"测试连接失败")}catch(S){if(S!=null&&S.errorFields)return;console.error("测试连接失败:",S),x.message.error("测试连接失败")}finally{w(!1)}},[t,g,k]),D=b.useCallback(async()=>{y(!0);try{await Zv(t),x.message.success("凭据删除成功"),A(),i==null||i()}catch(S){console.error("删除凭据失败:",S),x.message.error("删除凭据失败")}finally{y(!1)}},[t,A,i]);return f.jsx(x.Modal,{title:`编辑凭据${s!=null&&s.name?` - ${s.name}`:""}`,open:n,onCancel:A,width:560,footer:f.jsxs("div",{style:{display:"flex",justifyContent:"space-between"},children:[f.jsx(x.Popconfirm,{title:"确认删除",description:"删除后无法恢复,确定要删除此凭据吗?",onConfirm:D,okText:"删除",cancelText:"取消",okButtonProps:{danger:!0,loading:v},children:f.jsx(x.Button,{danger:!0,icon:f.jsx(Z.DeleteOutlined,{}),loading:v,children:"删除凭据"})}),f.jsxs("div",{style:{display:"flex",gap:8},children:[f.jsx(x.Button,{onClick:A,children:"取消"}),f.jsx(x.Button,{icon:f.jsx(Z.ApiOutlined,{}),onClick:E,loading:m,children:"测试连接"}),f.jsx(x.Button,{type:"primary",onClick:C,loading:h,children:"保存修改"})]})]}),destroyOnClose:!0,children:u?f.jsx("div",{style:{textAlign:"center",padding:40},children:f.jsx(x.Spin,{})}):f.jsxs("div",{children:[f.jsx(x.Form,{form:k,layout:"vertical",style:{marginBottom:16},children:f.jsx(x.Form.Item,{label:"凭据名称",name:"credentialName",rules:[{required:!0,message:"请输入凭据名称"}],children:f.jsx(x.Input,{placeholder:"为此凭据起一个名称"})})}),l?f.jsx(Gi,{schema:l,form:g,showSubmit:!1,showReset:!1}):f.jsx("div",{style:{padding:16,color:"#999",textAlign:"center"},children:"该凭据类型暂无配置项"})]})})},{Text:PO}=x.Typography,_G=({credentialKey:t,label:e="授权配置",required:n=!1,value:r,onChange:o,disabled:i=!1})=>{const[s,a]=b.useState([]),[l,c]=b.useState(!1),[u,d]=b.useState(!1),[h,p]=b.useState(!1),[m,w]=b.useState(null),[v,y]=b.useState(null),[g,k]=b.useState(""),A=b.useRef(null),C=b.useCallback(()=>{t&&(c(!0),AN(t).then(T=>{a(Array.isArray(T)?T:[])}).catch(()=>{a([])}).finally(()=>c(!1)))},[t]);b.useEffect(()=>{C()},[C]),b.useEffect(()=>{v&&A.current&&setTimeout(()=>{var T;(T=A.current)==null||T.focus()},100)},[v]);const E=b.useCallback(T=>{d(!1),C(),o==null||o(T)},[C,o]),D=b.useCallback(T=>{w(T),p(!0)},[]),S=b.useCallback(()=>{p(!1),w(null),C()},[C]),_=b.useCallback(T=>{Zv(T).then(()=>{x.message.success("凭据删除成功"),C(),r===T&&(o==null||o(void 0))}).catch(()=>{x.message.error("删除凭据失败")})},[C,r,o]),O=b.useCallback((T,P,$)=>{T.stopPropagation(),T.preventDefault(),y(P),k($)},[]),B=b.useCallback(()=>{y(null),k("")},[]),N=b.useCallback(()=>{if(!v||!g.trim()){B();return}const T=g.trim(),P=s.find($=>$.id===v);if((P==null?void 0:P.name)===T){B();return}of(v,{name:T}).then(()=>{x.message.success("凭据重命名成功"),C(),B()}).catch(()=>{x.message.error("重命名失败")})},[v,g,s,C,B]),F=b.useCallback(T=>{v&&(T.stopPropagation(),T.preventDefault())},[v]),M=b.useCallback(T=>f.jsxs("div",{children:[T,f.jsx(x.Divider,{style:{margin:"4px 0"}}),f.jsx("div",{style:{padding:"8px",textAlign:"center"},children:f.jsx(x.Button,{icon:f.jsx(Z.PlusOutlined,{}),onClick:()=>d(!0),type:"link",block:!0,disabled:i,children:"新建凭据"})})]}),[i]);return t?f.jsxs("div",{style:{padding:"16px 0"},children:[f.jsxs(PO,{strong:!0,style:{display:"block",marginBottom:8,fontSize:14},children:[e,n?f.jsx("span",{style:{color:"#ff4d4f",marginLeft:4},children:"*"}):null]}),f.jsx(x.Select,{style:{width:"100%"},placeholder:"选择凭据实例",value:r,onChange:T=>o==null?void 0:o(T),loading:l,disabled:i,allowClear:!0,onClear:()=>o==null?void 0:o(void 0),dropdownRender:M,onClick:F,children:s.map(T=>f.jsx(x.Select.Option,{value:T.id,children:f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",width:"100%",padding:"4px 0"},onClick:F,children:[f.jsx("div",{style:{display:"flex",alignItems:"center",maxWidth:"40%",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:v!==T.id?f.jsxs(b.Fragment,{children:[f.jsx("span",{children:T.name}),f.jsx(Z.EditOutlined,{style:{fontSize:12,color:"#1890ff",marginLeft:6,cursor:"pointer",opacity:.5},onClick:P=>{i||O(P,T.id,T.name)}})]}):f.jsx(x.Input,{ref:A,size:"small",value:g,onChange:P=>k(P.target.value),onPressEnter:N,onBlur:N,onClick:P=>P.stopPropagation(),onMouseDown:P=>P.stopPropagation(),style:{width:120}})}),f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:8},children:[f.jsx(PO,{type:"secondary",style:{fontSize:12},children:T.updatedAt?cr(T.updatedAt).format("YYYY-MM-DD HH:mm"):T.createdAt?cr(T.createdAt).format("YYYY-MM-DD HH:mm"):""}),f.jsx(x.Button,{type:"link",icon:f.jsx(Z.EditOutlined,{}),size:"small",onClick:P=>{P.stopPropagation(),D(T.id)},disabled:i,children:"编辑"}),f.jsx(x.Popconfirm,{title:"确认删除",description:"删除后无法恢复,确定要删除此凭据吗?",onConfirm:P=>{P==null||P.stopPropagation(),_(T.id)},onCancel:P=>P==null?void 0:P.stopPropagation(),okText:"删除",cancelText:"取消",okButtonProps:{danger:!0},disabled:i,children:f.jsx(x.Button,{type:"link",danger:!0,icon:f.jsx(Z.DeleteOutlined,{}),size:"small",onClick:P=>P.stopPropagation(),disabled:i,children:"删除"})})]})]})},T.id))}),t&&f.jsx(OG,{credentialKey:t,open:u,onCancel:()=>d(!1),onCreated:E}),t&&m&&f.jsx(TG,{instanceId:m,credentialKey:t,open:h,onCancel:()=>{p(!1),w(null)},onUpdated:S,onDeleted:()=>{p(!1),w(null),C(),r===m&&(o==null||o(void 0))}})]}):null},jr="[workflow:schema-render]",NG=/^\{\{([^.{}]+)\.(.+)\}\}$/,BG=b.forwardRef((t,e)=>{const{nodeId:n,data:r,onSubmitted:o,onValuesChange:i,cachedValues:s}=t,[a,l]=b.useState(null),[c,u]=b.useState([]),[d,h]=b.useState(r==null?void 0:r.credentialInstanceId),[p,m]=b.useState(),[w,v]=b.useState(!1),[y,g]=b.useState(!1),[k]=x.Form.useForm(),A=ae.useStoreApi(),C=r==null?void 0:r.nodeKey,E=r==null?void 0:r.nodeVersion;b.useEffect(()=>{if(!C){console.warn(`${jr} open next config without nodeKey`,{nodeId:n,data:r}),g(!0);return}let N=!1;return v(!0),g(!1),console.info(`${jr} open next config`,{nodeId:n,nodeKey:C,nodeVersion:E,hasParams:!!(r!=null&&r.params),credentialInstanceId:r==null?void 0:r.credentialInstanceId}),Zu(C,E).then(F=>{var M,T,P,$,W,V,X;if(N){console.info(`${jr} ignore schema result after unmount`,{nodeId:n,nodeKey:C,nodeVersion:E});return}if(!F){console.warn(`${jr} next config schema empty`,{nodeId:n,nodeKey:C,nodeVersion:E}),l(null),u([]);return}if(console.info(`${jr} next config schema loaded`,{nodeId:n,nodeKey:C,nodeVersion:E,schemaKeys:Object.keys(F),schemaVersion:F.version,inputFields:((M=F.input_fields)==null?void 0:M.length)??0,outputs:((T=F.outputs)==null?void 0:T.length)??0,credentials:((P=F.credentials)==null?void 0:P.length)??0,fieldSummaries:(($=F.input_fields)==null?void 0:$.map(G=>({key:G.key,label:G.label,type:G.type,required:G.required})))??[]}),(W=F.input_fields)!=null&&W.length){const G=el(F.input_fields);console.info(`${jr} next config form schema converted`,{nodeId:n,nodeKey:C,nodeVersion:E,fields:G.fields.length}),l(G)}else console.warn(`${jr} next config schema has no inputFields`,{nodeId:n,nodeKey:C,nodeVersion:E,schemaKeys:Object.keys(F),hasNestedNodeSchema:!!F.node_schema,nestedInputFields:((X=(V=F.node_schema)==null?void 0:V.input_fields)==null?void 0:X.length)??0}),l(null);u(F.credentials??[])}).catch(F=>{console.error(`${jr} next config schema load failed`,{nodeId:n,nodeKey:C,nodeVersion:E,err:F})}).finally(()=>{N||(v(!1),g(!0))}),()=>{N=!0}},[n,C,E]);const D=b.useCallback(N=>{console.info(`${jr} submit next config`,{nodeId:n,nodeKey:C,nodeVersion:E,valueKeys:Object.keys(N),credentialInstanceId:d}),o({params:N,credentialInstanceId:d})},[d,n,C,E,o]),S=b.useCallback(N=>{const F=N.trim().match(NG);if(!F)return null;const M=F[1],T=F[2];if(M==="global")return null;const P=M.startsWith("N")?M.slice(1):M,$=A.getState().nodes.find(W=>W.id===P);return $?{fieldPath:T,node:$,variableNodeId:M}:null},[A]),_=b.useCallback(N=>{var F;return((F=S(N))==null?void 0:F.fieldPath)??N.replace(/^\{\{|\}\}$/g,"")},[S]),O=b.useCallback(N=>{var $;const F=S(N);if(!F)return N;const M=($=F.node)==null?void 0:$.data,T=(M==null?void 0:M.label)||(M==null?void 0:M.name)||(M==null?void 0:M.action_name)||F.variableNodeId,P=M!=null&&M.note?` (${M.note})`:"";return`${T}${P}.${F.fieldPath}`},[S]);b.useImperativeHandle(e,()=>({saveConfig:()=>k.validateFields().then(N=>(D(N),N)).catch(()=>null)}));const B=b.useMemo(()=>Gu(c),[c]);return b.useEffect(()=>{var N;if(!d){m(void 0);return}!p&&((N=B[0])!=null&&N.key)&&m(B[0].key)},[p,d,B]),b.useEffect(()=>{w||!y||a||console.warn(`${jr} render empty config placeholder`,{nodeId:n,nodeKey:C,nodeVersion:E,loading:w})},[a,w,n,C,E,y]),w?f.jsx("div",{style:{textAlign:"center",padding:40},children:f.jsx(x.Spin,{})}):f.jsxs("div",{children:[B.map(N=>f.jsx(_G,{credentialKey:N.key,label:B.length>1?N.label:void 0,required:N.required,value:p===N.key?d:void 0,onChange:F=>{if(F){m(N.key),h(F);return}p===N.key&&(h(void 0),m(void 0))}},N.key)),a?f.jsx(Gi,{schema:a,form:k,initialValues:s??(r==null?void 0:r.params)??{},onSubmit:D,onChange:i?(N,F)=>i(F):void 0,renderVariableTag:_,renderVariableTooltip:O,showSubmit:!1,showReset:!1,nodeId:n}):f.jsx("div",{style:{padding:16,color:"#999",textAlign:"center"},children:C?"该节点暂无配置项":"未知节点类型"}),f.jsx("div",{style:{padding:"12px 0",position:"sticky",backgroundColor:"#FFFFFF",bottom:0,width:"100%",textAlign:"center",borderTop:"1px solid #eaeaea"},children:f.jsx(x.Button,{type:"primary",style:{width:180,borderRadius:4},onClick:()=>{k.validateFields().then(N=>{D(N)}).catch(()=>{})},children:"保存"})})]})}),FG=()=>{const{event$:t}=b.useContext($r),e=xf();return t.useSubscription(n=>{n.type==="insert"&&(console.log("[Bridge] 收到 insert 事件:",{expression:n.expression,hasVarSelector:!!e,activeFieldId:e==null?void 0:e.activeFieldId}),n.expression&&e?e.insertVariableToActiveField(n.expression,!1):e?e.activeFieldId||console.warn("[Bridge] 没有激活的字段(请先点击一个支持变量的表单字段)"):console.warn("[Bridge] VariableSelectorContext 不可用"))}),null},IG=t=>f.jsxs("div",{className:"node-config-title",style:{display:"flex",alignItems:"center"},children:[t.icon?f.jsx("img",{src:t.icon,alt:t.name,style:{width:24,height:24}}):null,f.jsx("div",{className:"node-config-title-name",style:{fontSize:16,fontWeight:600,marginLeft:10},children:t.name}),f.jsx("div",{className:"node-config-title-description",style:{fontSize:12,color:"gray",marginLeft:10},children:t.description})]}),MG=b.memo(({visible:t,onClose:e,data:n,nodeType:r=ee.ACTION,nodeId:o="",cachedValues:i,onValuesChange:s})=>{var A,C,E,D;const a=dt.useEventEmitter(),l=ae.useInternalNode(o),{setNodeConfigVisible:c}=Cr(),u=b.useRef(null),d=b.useRef(null),h=b.useRef(null),p=Vt(),m=((C=(A=p.nodeConfigPanel)==null?void 0:A.testArea)==null?void 0:C.allowManualTest)!==!1,{handleNodeDataUpdate:w}=Hr(),v=b.useRef(ut.debounce((S,_)=>{s==null||s(S,_)},300)).current,y=b.useMemo(()=>p.nodeConfigPanel.showSettings&&![ee.TRIGGER,ee.MCP_TOOL,ee.AI_SUB_NODE].includes(r),[r,p.nodeConfigPanel.showSettings]),g=b.useCallback(async(S,_)=>{try{w({id:o,data:{params:S.params,credentialInstanceId:S.credentialInstanceId}}),x.message.success("节点配置已保存"),s==null||s(o,null),_&&h.current&&h.current.onTestNode()}catch{}},[(E=l==null?void 0:l.position)==null?void 0:E.x,(D=l==null?void 0:l.position)==null?void 0:D.y,o,w,s]),k=async(S,_)=>{var O,B;if(!_&&S)try{x.message.loading("正在保存节点配置...",0),await((O=d.current)==null?void 0:O.saveConfig()),x.message.destroy(),(B=h.current)==null||B.onTestNode()}catch{x.message.destroy(),x.message.error("节点配置保存失败,无法执行测试")}};return f.jsx(x.Modal,{open:t,footer:null,closeIcon:null,maskClosable:!0,onCancel:()=>{c(null)},centered:!0,width:"70%",className:"nodes-config-modal",styles:{wrapper:{minWidth:1040},mask:{backgroundColor:"rgba(0, 0, 0, 0.45)"},content:{padding:0,overflow:"hidden"}},children:f.jsx($r.Provider,{value:{event$:a},children:f.jsxs(kf,{children:[f.jsx(FG,{}),f.jsxs("div",{className:"nodes-config-container",children:[f.jsxs("div",{className:"nodes-config-header",children:[f.jsx("div",{className:"header-left",children:f.jsx("span",{className:"header-title",children:" 节点配置"})}),f.jsx("div",{className:"header-right",children:f.jsx(x.Button,{type:"text",icon:f.jsx(Z.ArrowLeftOutlined,{}),onClick:e,className:"back-button",children:"返回画布"})})]}),f.jsx("div",{className:"nodes-config-content",children:f.jsxs(x.Row,{gutter:16,className:"config-row",children:[f.jsx(x.Col,{span:5,className:"left-section",children:f.jsx("div",{className:"variables-section",children:f.jsx(AG,{ref:u,nodeId:o,open:t})})}),f.jsx(x.Col,{span:12,className:"middle-section",children:f.jsx("div",{className:"form-section",style:{height:"100%"},children:f.jsx(x.Card,{title:f.jsx(IG,{icon:n==null?void 0:n.icon,name:n==null?void 0:n.name,description:n==null?void 0:n.description}),variant:"borderless",styles:{body:{paddingTop:0,paddingBottom:0}},className:"section-card form-card",children:f.jsx(x.Tabs,{style:{height:"100%"},items:[{key:"property",label:"参数配置",children:f.jsx(BG,{ref:d,nodeId:o,data:n,onSubmitted:g,cachedValues:i,onValuesChange:s?S=>v(o,S):void 0})},...y?[{key:"setting",label:"设置",children:f.jsx(dG,{nodeId:o})}]:[]]})})})}),f.jsx(x.Col,{span:7,className:"right-section",children:m&&f.jsx("div",{className:"test-section",children:f.jsx(x.Card,{variant:"borderless",className:"section-card",children:f.jsx(gG,{ref:h,nodeId:o,beforeHook:k})})})})]})})]})]})})})},(t,e)=>ut.isEqual(ut.omit(t,["isHovered"]),ut.omit(e,["isHovered"])));function PG(){const t=b.useRef(new Map),e=b.useCallback(i=>t.current.get(i),[]),n=b.useCallback((i,s)=>{t.current.set(i,s)},[]),r=b.useCallback(i=>{t.current.delete(i)},[]),o=b.useCallback((i,s)=>{s===null?r(i):n(i,s)},[r,n]);return{getCachedValues:e,handleValuesChange:o}}const LG=()=>{const{currentNodeConfigVisibleId:t,setNodeConfigVisible:e}=Cr(),n=ae.useStoreApi(),{getCachedValues:r,handleValuesChange:o}=PG(),i=t?n.getState().nodes.find(s=>s.id===t):void 0;return f.jsx(MG,{visible:!!t,onClose:()=>e(null),nodeType:i==null?void 0:i.type,data:i==null?void 0:i.data,nodeId:t??"",cachedValues:t?r(t):void 0,onValuesChange:o})};function LO(t,e){return e===1?{top:"50%"}:{top:`${(t+1)/(e+1)*100}%`}}const Cd=t=>{const{id:e,data:n,selected:r,minHeight:o=72,maxHeight:i=300,className:s}=t,[a,l]=b.useState(null),[c,u]=b.useState(!0),d=ae.useUpdateNodeInternals(),h=n==null?void 0:n.settings,p=(h==null?void 0:h.onError)===yi.CONTINUE_ERROR_OUTPUT;b.useEffect(()=>{const k=n==null?void 0:n.nodeKey,A=n==null?void 0:n.nodeVersion;if(!k){u(!1);return}let C=!1;return Zu(k,A).then(E=>{!C&&E&&l(E)}).catch(E=>{console.error("[NextBaseNode] 加载 Schema 失败:",E)}).finally(()=>{C||u(!1)}),()=>{C=!0}},[n==null?void 0:n.nodeKey,n==null?void 0:n.nodeVersion]);const m=b.useMemo(()=>!(a!=null&&a.inputs)||a.inputs.length===0?[{id:"main",position:ae.Position.Left,type:je.TARGET}]:a.inputs.map((k,A)=>({id:k.name,position:ae.Position.Left,type:je.TARGET,label:k.displayName,style:LO(A,a.inputs.length)})),[a]),w=b.useMemo(()=>{const k=!(a!=null&&a.outputs)||a.outputs.length===0?[{id:"main",position:ae.Position.Right,type:je.SOURCE,maxConnections:1}]:a.outputs.map(E=>({id:E.name,position:ae.Position.Right,type:je.SOURCE,maxConnections:1,label:E.displayName})),A=k.some(E=>E.id===yd),C=p&&!A?[...k,{id:yd,position:ae.Position.Right,type:je.SOURCE,maxConnections:1,label:"error"}]:k;return C.map((E,D)=>({...E,style:LO(D,C.length)}))},[a,p]),v=b.useMemo(()=>{const k=Math.max(m.length,w.length);return k<=1?o:Math.min(k*40,i)},[m.length,w.length,o,i]),y=m.length+w.length;b.useEffect(()=>{if(c||!a||y===0)return;const k=setTimeout(()=>{d(e)},100);return()=>{clearTimeout(k)}},[c,a,y,e,d]);const g=n;return f.jsx(_n,{id:e,data:g,selected:r,height:v,className:s,icon:g!=null&&g.icon?f.jsx("img",{src:g.icon,alt:g.label,style:{width:30,height:30}}):f.jsx(Z.PlayCircleOutlined,{style:{fontSize:24,color:"#007fff"}}),inputs:m,outputs:w,status:g.status})},$G=t=>f.jsx(Cd,{...t,className:"next-action-node"}),HG=t=>f.jsx(Cd,{...t,className:"next-condition-node"}),zG=t=>f.jsx(Cd,{...t,className:"next-switch-node",maxHeight:400}),$O=t=>f.jsx(Cd,{...t,className:"next-loop-node"}),jG=t=>{const{id:e,data:n,selected:r}=t,o=n,i=[{id:"main",position:ae.Position.Right,type:je.SOURCE,isMain:!0,label:"",maxConnections:1}];return f.jsx(_n,{id:e,data:o,selected:r,type:ee.TRIGGER,status:o==null?void 0:o.status,icon:o!=null&&o.icon?f.jsx("img",{src:o==null?void 0:o.icon,alt:o.label,style:{width:30,height:30}}):f.jsx(Fw.PiCursorFill,{style:{color:"#007fff",fontSize:24}}),inputs:[],outputs:i,className:"workflow-trigger-node"})};class VG{static getNodeTypes(){return{[ee.START]:AD,[ee.TRIGGER]:jG,[ee.ACTION]:$G,[ee.CONDITION]:HG,[ee.SWITCH]:zG,[ee.LOOP]:$O,[ee.SELF_LOOP]:$O,[ee.AGENT]:CD,[ee.BROWSER]:kD,[ee.AI_SUB_NODE]:od,[ee.VECTOR_STORE]:od,[ee.MCPServer]:ED,[ee.BuiltinMCP]:xD,[ee.MCP_TOOL]:DD,[ee.CUSTOM]:SD,[ee.STICKY]:fA}}}function WG(t,e){const n=new Set(e.map(o=>{var i;return((i=o.data)==null?void 0:i.name)||""}));if(!n.has(t))return t;let r=1;for(;n.has(`${t} ${r}`);)r++;return`${t} ${r}`}const UG={async loadFlow(t){const e=await CN(t),{nodes:n,edges:r,workflowName:o}=FU(e);return{nodes:n,edges:r,name:o,opStatus:e.active?We.ONLINE:We.OFFLINE}},async saveFlow({nodes:t,edges:e,workflowName:n,workflowId:r}){await Xv(r,LU(t,e,n))},async createNode({actionId:t,icon:e,name:n,connectorName:r,nodeVersion:o,existingNodes:i}){const s=WG(n||"",i||[]);return{nodeId:IU(),nodeData:{connector_name:r||"",name:s,action_name:s,label:s,status:1,protocol:"",icon:e,nodeKey:t,nodeVersion:o??1}}},stickyNodeKey:UU,nodeTypes:VG.getNodeTypes(),convertNodeData:og,HeaderComponent:KU,PanelComponent:kU,ConfigModalComponent:LG,requiresTriggerNode:!1},qG=t=>f.jsx(FO,{strategy:UG,...t});var wr=(t=>(t.SECOND="second",t.MINUTE="minute",t.HOUR="hour",t))(wr||{});function GG(t){return{[wr.SECOND]:"SECONDS",[wr.MINUTE]:"MINUTES",[wr.HOUR]:"HOURS"}[t]}function KG(t){return{SECONDS:wr.SECOND,MINUTES:wr.MINUTE,HOURS:wr.HOUR}[t]}function YG(){return{enableControl:!1,timeoutValue:30,timeoutUnit:wr.MINUTE,maxNodeExecutions:1e4,webhookUrl:""}}function XG(t){return{enabled:t.enableControl,timeout_value:t.timeoutValue,timeout_unit:GG(t.timeoutUnit),max_node_executions:t.maxNodeExecutions,webhook_url:t.webhookUrl||void 0}}function JG(t){return{enableControl:t.enabled,timeoutValue:t.timeout_value,timeoutUnit:KG(t.timeout_unit),maxNodeExecutions:t.max_node_executions,webhookUrl:t.webhook_url||""}}function RG(t){if(!t)return!0;try{return new URL(t),!0}catch{return!1}}const{Text:iw}=x.Typography,QG=()=>{const[t,e]=b.useState(!1),[n,r]=b.useState(!1),[o]=x.Form.useForm(),i=x.Form.useWatch("enableControl",o),s=Ss(),a=Io(p=>p.workflow.executionControl),l=BO(),c=()=>{e(!0),o.setFieldsValue(a?JG(a):YG())},u=()=>{e(!1)},d=async()=>{try{const p=await o.validateFields();r(!0),s(mA(XG(p))),await l.saveFlow(),x.message.success("保存成功"),e(!1)}catch(p){x.message.error("保存失败"),console.error(p)}finally{r(!1)}},h=(p,m)=>!m||RG(m)?Promise.resolve():Promise.reject(new Error("请输入合法的URL格式"));return f.jsxs(f.Fragment,{children:[f.jsx(x.Tooltip,{title:"流程设置",children:f.jsx(x.Button,{type:"text",icon:f.jsx(Z.SettingOutlined,{}),onClick:c})}),f.jsx(x.Drawer,{title:"流程设置",placement:"right",width:480,open:t,onClose:u,footer:f.jsxs(x.Space,{style:{float:"right"},children:[f.jsx(x.Button,{onClick:u,children:"取消"}),f.jsx(x.Button,{type:"primary",onClick:d,loading:n,children:"保存"})]}),children:f.jsxs(x.Form,{form:o,layout:"vertical",autoComplete:"off",children:[f.jsx(x.Form.Item,{label:"执行管控",name:"enableControl",valuePropName:"checked",children:f.jsx(x.Switch,{})}),i&&f.jsxs(f.Fragment,{children:[f.jsxs(x.Form.Item,{label:"执行超时",required:!0,style:{marginBottom:8},children:[f.jsxs(x.Space.Compact,{style:{width:"100%"},children:[f.jsx(x.Form.Item,{name:"timeoutValue",noStyle:!0,rules:[{required:!0,message:"请输入超时时间"},{type:"number",min:1,message:"必须大于0"}],children:f.jsx(x.InputNumber,{style:{width:"70%"},placeholder:"请输入",min:1})}),f.jsx(x.Form.Item,{name:"timeoutUnit",noStyle:!0,rules:[{required:!0}],children:f.jsxs(x.Select,{style:{width:"30%"},children:[f.jsx(x.Select.Option,{value:wr.SECOND,children:"秒"}),f.jsx(x.Select.Option,{value:wr.MINUTE,children:"分钟"}),f.jsx(x.Select.Option,{value:wr.HOUR,children:"小时"})]})})]}),f.jsx(iw,{type:"secondary",style:{fontSize:12},children:"流程执行超过此时间将自动终止,使用墙钟时间计算"})]}),f.jsx(x.Form.Item,{label:"最大节点执行次数",name:"maxNodeExecutions",rules:[{required:!0,message:"请输入最大节点执行次数"},{type:"number",min:1,message:"必须为正整数"}],children:f.jsx(x.InputNumber,{style:{width:"100%"},placeholder:"请输入",min:1,precision:0})}),f.jsx(iw,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-16,marginBottom:16},children:"流程中所有节点执行的总次数上限,超过后将自动终止"}),f.jsx(x.Form.Item,{label:"错误通知 Webhook",name:"webhookUrl",rules:[{validator:h}],children:f.jsx(x.Input,{placeholder:"请输入 Webhook URL"})}),f.jsx(iw,{type:"secondary",style:{fontSize:12,display:"block",marginTop:-16},children:"流程因超时或超限终止时,将向此地址发送通知"})]})]})})]})},{Title:ZG,Text:sw}=x.Typography,HO="[workflow:online-validation]",eK=({opStatus:t})=>{const e=oo();return{[We.UNPUBLISHED]:f.jsx(x.Tag,{bordered:!1,color:"orange",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.not-published"})}),[We.ONLINE]:f.jsx(x.Tag,{bordered:!1,color:"green",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.already-online"})}),[We.OFFLINE]:f.jsx(x.Tag,{bordered:!1,color:"default",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.already-offline"})}),[We.ONLINE_ING]:f.jsx(x.Tag,{bordered:!1,color:"processing",children:f.jsx(Ee.FormattedMessage,{id:"app.common.word.going-online"})}),[We.ON_WARN]:f.jsx(Nl,{to:`/link/log?warnId=${e}`,children:f.jsxs(x.Space,{size:[5,5],children:[f.jsx(Z.ExclamationCircleOutlined,{style:{color:"#faad14"}}),f.jsx(Ee.FormattedMessage,{id:"common.warning"})]})}),[We.OFF_WARN]:f.jsx(Nl,{to:`/link/log?warnId=${e}`,children:f.jsxs(x.Space,{size:[5,5],children:[f.jsx(Z.ExclamationCircleOutlined,{style:{color:"#faad14"}}),f.jsx(Ee.FormattedMessage,{id:"common.warning"})]})})}[t]},tK=({onSave:t,readOnly:e=!1,preview:n=!1,autoSaveStatus:r=hn.IDLE,lastSavedTime:o,unSave:i,appFlowMode:s=!1,canvasApi:a})=>{var Y,ie;const l=Ss(),c=Ct(),u=Io(Q=>Q.workflow.workflowName),d=Io(Q=>Q.workflow.op_status),[h,p]=b.useState(!1),[m,w]=b.useState(u),[v,y]=b.useState(!1),g=b.useRef(null),{getNodes:k}=ae.useReactFlow(),A=Vt(),C=A.toolbar,E=oo(),D=((Y=k().filter(Q=>Q.type!==ee.START))==null?void 0:Y.length)>0;b.useEffect(()=>{w(u)},[u]),b.useEffect(()=>{h&&g.current&&g.current.focus()},[h]);const S=b.useCallback(()=>{const L=k().filter(q=>q.type!==ee.START).filter(q=>q.data.status!==me.SUCCESS&&q.data.status!==me.RUNNABLE);return L.length&&console.warn(`${HO} node status check failed`,{unhealthyNodes:L.map(q=>({id:q.id,name:q.data.name,type:q.type,status:q.data.status}))}),L.length===0},[k]),_=b.useCallback(()=>{const Q=k().filter(L=>L.type!==ee.START),le=(L,q,J)=>(console.warn(`${HO} required config check failed`,{node:{id:L.id,name:L.data.name,type:L.type,status:L.data.status},reason:q,details:J,configSchema:L.data.config_schema}),!1);for(const L of Q){const{data:q,type:J}=L,{config_schema:K}=q;if(J===ee.LOOP){if(!(K!=null&&K.asc))return le(L,"loop config is missing asc");const re=Object.keys(K??{});if(re.length===0)return le(L,"loop config schema is empty");if(re.some(se=>typeof K[se]>"u"))return le(L,"loop config contains undefined values",{undefinedKeys:re.filter(se=>typeof K[se]>"u")})}else if(J===ee.CONDITION){if(!(K!=null&&K.or_list)||!K.or_list.length)return le(L,"condition config is missing or_list");if(!K.or_list.every(se=>se.and_list.every(he=>he.query&&he.operator)))return le(L,"condition config contains incomplete rules")}else if(J===ee.SWITCH){if(!(K!=null&&K.branches)||!K.branches.length)return le(L,"switch config is missing branches");if(!K.branches.every(se=>se.or_list.every(he=>he.and_list.every(Ce=>Ce.query&&Ce.operator))))return le(L,"switch config contains incomplete branch rules")}else if(J!==ee.STICKY){const re=K==null?void 0:K.sub_params;if(!Array.isArray(re))return le(L,"config_schema.sub_params is missing or invalid");const se=re.every(Ce=>(console.log("subParams :",re),Ce.required?typeof Ce.value<"u"&&Ce.value!==null:!0));if(!se)return le(L,"required parameters are missing",{missingParams:re.filter(Ce=>Ce.required&&(typeof Ce.value>"u"||Ce.value===null)).map(Ce=>({key:Ce.key,name:Ce.name,label:Ce.label}))});const he=K!=null&&K.account_schema_id?!!K.account_id:!0;if(!se||!he)return le(L,"account is required but account_id is missing",{accountSchemaId:K==null?void 0:K.account_schema_id,accountId:K==null?void 0:K.account_id})}}return!0},[k]),O=()=>{if((d===We.ONLINE||d===We.ON_WARN)&&(!_()||!S())){x.message.warning("当前流程节点存在异常,请完成节点测试或下线流程后再尝试保存");return}t==null||t()},B=Q=>{w(Q.target.value)};dt.useUnmount(()=>{l(hd()),gi("")});const N=b.useCallback(()=>{const Q=u,le=m.trim(),L=le||"未命名工作流";l(gi(L)),Rd(E,{name:L}).then(()=>{}).catch(()=>{l(gi(Q))}),p(!1)},[l,m,u]),F=()=>{N()},M=()=>{N()},T=()=>{var Q;!e&&((Q=C==null?void 0:C.flowName)==null?void 0:Q.editable)!==!1&&p(!0)},P=()=>{if(i)return f.jsx(x.Tooltip,{title:"暂未保存",children:f.jsx(x.Tag,{bordered:!1,color:"warning",children:"未保存"})});switch(r){case hn.SAVING:return f.jsx(x.Tooltip,{children:f.jsx("div",{style:{display:"flex",alignItems:"center"},children:f.jsx(Z.SyncOutlined,{spin:!0,style:{marginRight:8,color:"#1890ff"}})})});case hn.SAVED:return f.jsx(x.Tooltip,{title:`已自动保存 (${o})`,children:f.jsx("div",{style:{display:"flex",alignItems:"center"},children:f.jsxs(x.Tag,{bordered:!1,color:"green",children:["已保存"," ",f.jsx("span",{style:{fontSize:10,marginLeft:4,color:"#999"},children:o})]})})});case hn.ERROR:return f.jsx(x.Tooltip,{title:"自动保存失败",children:f.jsx(x.Badge,{status:"error",text:f.jsx("span",{children:"保存失败"})})});default:return null}},[$,W]=x.Modal.useModal(),V=async()=>{var L;const Q=d===We.ONLINE||d===We.ON_WARN,le=()=>{var q,J;if((q=C==null?void 0:C.nav)!=null&&q.onBack){C.nav.onBack();return}if((J=C==null?void 0:C.nav)!=null&&J.backTo){_i.push(C.nav.backTo);return}s?_i.back():_i.push("/link/ai-flow")};if(!Q&&((L=C==null?void 0:C.nav)!=null&&L.confirmOnBackWhenOffline)&&i){await $.confirm({title:R("user.common.operation_title"),content:C.nav.backConfirmMessage||"当前流程未保存,是否确认返回?"})&&le();return}le()},X=async(Q={})=>{if(!E)return;y(!0);const{force:le=!1,customFn:L}=Q;return(le?Uv(E):L?L(E):rf(E,We.ONLINE)).then(()=>(x.message.success(R("link.flow.online_success")),l(xs(We.ONLINE)),{success:!0})).catch(J=>({success:!1,error:J})).finally(()=>{y(!1)})},G=async Q=>{if(!E)return;y(!0),(Q?Q(E):rf(E,We.OFFLINE)).then(()=>{x.message.success(R("link.flow.offline_success")),l(xs(We.OFFLINE))}).catch(()=>{}).finally(()=>{y(!1)})},te=async()=>await $.confirm({icon:f.jsx(f.Fragment,{}),centered:!0,title:R("link.flow.confirm_online"),content:(C==null?void 0:C.enableOnlineConfirmMessage)||R("link.flow.force_online_confirm"),cancelText:R("common.no"),okText:R("common.yes")}),H=async Q=>{if(Q){if(!S()){await te()&&await X({force:!0,customFn:C==null?void 0:C.customOnlineApi});return}const L=await X({force:!1,customFn:C==null?void 0:C.customOnlineApi});L&&!L.success&&await te()&&await X({force:!0,customFn:C==null?void 0:C.customOnlineApi})}else G(C==null?void 0:C.customOfflineApi)},j=()=>{var le,L,q,J;const Q=[];return((le=C==null?void 0:C.nav)==null?void 0:le.showBack)!==!1&&(Q.push(f.jsx(x.Button,{type:"text",icon:f.jsx(Z.ArrowLeftOutlined,{className:"workflow-back-icon"}),onClick:V,children:R("app.common.word.back")},"back")),Q.push(f.jsx(x.Divider,{type:"vertical"},"divider-back"))),s||(h?Q.push(f.jsx(x.Input,{ref:g,value:m,onChange:B,onPressEnter:F,onBlur:M,maxLength:30,className:"workflow-name-input",placeholder:"请输入工作流名称"},"name-input")):Q.push(f.jsx("div",{className:"workflow-name",onClick:n?void 0:T,children:u?f.jsxs(f.Fragment,{children:[f.jsx(ZG,{level:4,className:"workflow-name-text",children:u}),!e&&!n&&((L=C==null?void 0:C.flowName)==null?void 0:L.editable)&&f.jsx(Z.FormOutlined,{className:"edit-icon"})]}):f.jsx(x.Skeleton.Input,{active:!0,size:"small"})},"name-display")),Q.push(f.jsx(x.Divider,{type:"vertical"},"divider-name"))),n?Q.push(f.jsx(sw,{type:"secondary",children:"预览模式"},"preview-text")):Q.push(f.jsxs(x.Space,{size:8,children:[A.toolbar.enableOnlineButton&&f.jsxs(b.Fragment,{children:[f.jsx(sw,{children:(C==null?void 0:C.enableFlowText)||"启用流程"}),f.jsx(x.Switch,{disabled:!D,onChange:H,loading:v,checked:d===We.ONLINE||d===We.ON_WARN})]}),f.jsx(x.Divider,{type:"vertical"}),((q=C==null?void 0:C.flowStatusTag)==null?void 0:q.enabled)===!1?null:f.jsx("span",{style:(J=C==null?void 0:C.flowStatusTag)==null?void 0:J.style,children:f.jsx(eK,{opStatus:d})})]},"online-area")),Q.push(f.jsx(x.Divider,{type:"vertical"},"divider-status")),!c&&!n&&Q.push(f.jsx(sw,{type:"secondary",children:"当前流为只读模式,如需编辑,请下线流程"},"readonly-hint")),Q};return f.jsxs("div",{className:"workflow-canvas-header",children:[W,f.jsx("div",{className:"workflow-heder-left-area",children:j()}),f.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[c&&!n&&P(),f.jsx("span",{children:f.jsx(x.Button,{icon:f.jsx(Z.QuestionCircleOutlined,{}),type:"link",onClick:()=>{const Q=(C==null?void 0:C.helpDocUrl)||"https://1in15q85qd.apifox.cn/8698531m0";window.open(Q,"_blank")},children:(C==null?void 0:C.helpDocText)||"帮助文档"})}),f.jsxs(x.Space,{style:{marginLeft:16},children:[(ie=C==null?void 0:C.buttons)==null?void 0:ie.map(Q=>f.jsx(x.Button,{style:Q.style,icon:Q.icon,type:Q.type??"default",onClick:()=>{Q.onClick&&a&&Q.onClick(a)},children:Q.label},Q.id)),c&&!n&&f.jsx(QG,{}),c&&!n&&f.jsx(f.Fragment,{children:f.jsx(x.Tooltip,{title:"保存",children:f.jsx(x.Button,{onClick:O,type:"primary",children:"保存"})})})]})]})]})},nK=({categories:t,activeId:e,loading:n,onChange:r})=>n?f.jsx("div",{className:"category-tabs-wrapper loading",children:f.jsxs("div",{className:"category-tabs-loading",children:[f.jsx(x.Spin,{size:"small"}),f.jsx("span",{children:"分类加载中"})]})}):f.jsxs("div",{className:"category-tabs-wrapper",children:[f.jsx("div",{className:"category-tabs",children:t.map(o=>f.jsx("div",{className:kn("category-tab",{active:e===o.id}),onClick:()=>r(o),children:o.name},o.id))}),f.jsx("div",{className:"category-tabs-mask left"}),f.jsx("div",{className:"category-tabs-mask right"})]}),rK=({action:t,parentNode:e,onSelect:n})=>{const r=()=>{n(e,t)};return f.jsxs("div",{className:"action-item",onClick:r,children:[f.jsx("div",{className:"item-icon","data-category":e.category.split("-")[0]||"action",children:t.icon?f.jsx("img",{src:t.icon,alt:t.name,style:{width:32,height:32}}):f.jsx("div",{children:t.name.charAt(0).toUpperCase()})}),f.jsxs("div",{className:"item-content",children:[f.jsx("div",{className:"item-title",children:t.name}),t.description&&f.jsx("div",{className:"item-description",children:t.description})]})]})},oK=({node:t,expanded:e,actions:n,loading:r,hasPartialActions:o,onToggle:i,onActionSelect:s,onLoadAllActions:a})=>{const l=()=>{i(t)},c=u=>{u.stopPropagation(),a==null||a(t)};return f.jsxs("div",{className:kn("node-card",{expanded:e}),children:[f.jsxs("div",{className:"node-card-header",onClick:l,children:[f.jsx("div",{className:"node-card-icon",children:t.icon?f.jsx("img",{src:t.icon,alt:t.name}):f.jsx("span",{children:t.name.charAt(0).toUpperCase()})}),f.jsxs("div",{className:"node-card-info",children:[f.jsx("div",{className:"node-card-title",children:t.name}),t.description&&f.jsx("div",{className:"node-card-desc",children:t.description})]}),f.jsx(Z.CaretDownOutlined,{className:kn("node-card-arrow",{expanded:e})})]}),e&&f.jsxs("div",{className:"node-card-body",children:[r?f.jsx("div",{className:"node-card-state",children:"动作加载中..."}):n.length===0?f.jsx("div",{className:"node-card-state",children:"暂无可用动作"}):f.jsx("div",{className:"node-card-actions",children:n.map(u=>f.jsx("div",{className:"node-card-action-wrapper",onClick:d=>d.stopPropagation(),children:f.jsx(rK,{action:u,parentNode:t,onSelect:s})},u.id))}),o&&!r&&f.jsx("div",{className:"node-card-more",onClick:c,children:"查看该节点全部动作"})]})]})},iK=({currentCategory:t,categoryPath:e,selectedNode:n,onBack:r,onClose:o,title:i,subTitle:s,showBackButton:a})=>{const l=()=>n?n.name:t?t.name:"节点选择器",c=()=>n?"选择动作":e.length>0?e.slice(0,-1).map(p=>p.name).join(" / "):"",u=i||l(),d=s??c(),h=typeof a=="boolean"?a:!!(n||e.length>0);return f.jsxs("div",{className:"panel-header",children:[f.jsxs("div",{className:"header-left",children:[h&&r&&f.jsx("div",{className:"back-button",onClick:r,children:f.jsx(Z.ArrowLeftOutlined,{})}),f.jsxs("div",{className:"title",children:[u,d&&f.jsx("div",{className:"category-path",children:d})]})]}),f.jsx("div",{className:"close-button",onClick:o,children:f.jsx(Z.CloseOutlined,{})})]})},zO=[],jO=Object.freeze(Object.defineProperty({__proto__:null,defaultCategories:zO},Symbol.toStringTag,{value:"Module"})),aw="[workflow:schema-render]",sK=new Set(Object.values(ee)),aK=t=>{if(t)return sK.has(t)?t:void 0},lK=({nodeSelectorVisible:t,nodeAddInfo:e})=>{const[n,r]=b.useState(!1),o=oo();return{isLoadingActions:n,fetchNodeActions:async(s,a)=>{a!=null&&a.suppressLoading||r(!0);try{const l=t&&e&&e.trigger===!0,c={linkId:s.id,flowId:o},u=(e==null?void 0:e.protocol)===Be.BUILTIN_MCP?ee.MCP_TOOL:aK(s.type);u&&(c.actionType=u),l&&(c.trigger=!0);const d=await Ev(c);return d&&d.items&&Array.isArray(d.items)?d.items.map(p=>{var w,v,y,g;const m=p.action_ver??((w=p.node_schema)==null?void 0:w.version);return p.action_key&&((y=(v=p.node_schema)==null?void 0:v.input_fields)!=null&&y.length)?(console.info(`${aw} preload schema from actions list`,{actionId:p.id,nodeKey:p.action_key,actionVer:p.action_ver,schemaVersion:p.node_schema.version,resolvedVersion:m,inputFields:p.node_schema.input_fields.length}),hD(p.action_key,m,p.node_schema)):p.action_key&&p.node_schema?console.info(`${aw} action list inline schema has no inputFields`,{actionId:p.id,nodeKey:p.action_key,actionVer:p.action_ver,schemaVersion:p.node_schema.version,resolvedVersion:m,inputFields:((g=p.node_schema.input_fields)==null?void 0:g.length)??0}):p.action_key&&console.info(`${aw} action list item without inline schema`,{actionId:p.id,nodeKey:p.action_key,resolvedVersion:m}),{...p,id:p.id,action_key:p.action_key,action_ver:m,nodeKey:p.action_key,nodeVersion:m,node_schema:p.node_schema,name:p.name||"未命名动作",description:p.description||"",connector_name:s.name,nodeId:s.id,nodeIcon:s.icon}}):[]}catch(l){return console.error("获取动作列表失败:",l),[]}finally{a!=null&&a.suppressLoading||r(!1)}}}},cK=({onFetchCategories:t,restrictToCategory:e,nodeSelectorVisible:n,nodeAddInfo:r,fallbackCategories:o=[]})=>{const[i,s]=b.useState(o),[a,l]=b.useState(!1);return b.useEffect(()=>{if(!n)return;(async()=>{l(!0);try{let u="action";const d=n&&r&&r.trigger,h=r==null?void 0:r.protocol,p=!!h;d?u="trigger":h===Be.AI_TOOL?u="mcp":h===Be.BUILTIN_MCP?u="tool":h===Be.AI_LANGUAGE_MODEL?u="model":h===Be.AI_MEMORY&&(u="memory");const m=await t(u),w=e?m.filter(y=>y.id===e):d?m:m.filter(y=>y.id!=="TRIGGER"),v=e||p?null:{id:"ALL",name:"全部",description:"全部分类",icon:void 0};s(v?[v,...w]:w)}catch(u){console.error("Failed to fetch categories:",u),s(o)}finally{l(!1)}})()},[t,e,n,r,o]),{categories:i,isLoadingCategories:a,setCategories:s}},uK=({categories:t,initialCategory:e,nodeSelectorVisible:n,nodeAddInfo:r,onFetchNodesByCategory:o,defaultPageSize:i=20,flowId:s})=>{const[a,l]=b.useState(e||"ALL"),[c,u]=b.useState([]),[d,h]=b.useState(!1),[p,m]=b.useState({page:1,size:i,total:0,hasMore:!0}),w=n&&r&&r.trigger===!0,v=n&&r&&r.protocol===Be.AI_TOOL,y=n&&r&&r.protocol===Be.BUILTIN_MCP,g=b.useMemo(()=>{const O=r==null?void 0:r.protocol;if(O){if(O===Be.AI_TOOL)return Be.MCP;if(O===Be.AI_LANGUAGE_MODEL||O===Be.AI_MEMORY)return O}},[r==null?void 0:r.protocol]),k=b.useMemo(()=>{const O=r==null?void 0:r.protocol;if(O===Be.AI_TOOL)return"tool";if(O===Be.AI_LANGUAGE_MODEL)return"model";if(O===Be.AI_MEMORY)return"memory"},[r==null?void 0:r.protocol]),A=b.useMemo(()=>a==="ALL"?null:t.find(O=>O.id===a)||null,[a,t]),C=b.useCallback((O,B=1)=>({app_domain_category:O&&O!=="ALL"?O:void 0,page:B,size:i,trigger:!!w,type:k,protocol:g,flow_id:s}),[i,w,k,g,s]),E=b.useCallback(async(O,B=1,N=!1)=>{if(n){h(!0);try{const F=C(O,B),{nodes:M,total:T,size:P}=await o(F);u($=>N?[...$,...M]:M),m({page:B,size:P,total:T,hasMore:B*P<T})}catch(F){console.error("Failed to fetch category data:",F),N||u([])}finally{h(!1)}}},[C,n,o]),D=b.useCallback(async O=>{l(O),await E(O,1,!1)},[E]),S=b.useCallback(async()=>{d||!p.hasMore||await E(a||"ALL",p.page+1,!0)},[E,d,p,a]),_=b.useCallback(()=>{l(e||"ALL"),u([]),m({page:1,size:i,total:0,hasMore:!0})},[e,i]);return b.useEffect(()=>{var B,N;if(!n){_();return}const O=e&&((B=t.find(F=>F.id===e))==null?void 0:B.id)||((N=t[0])==null?void 0:N.id)||"ALL";l(O),E(O,1,!1)},[n,t,e,E,_]),{categoryNodes:c,currentCategory:A,isLoadingNodes:d,isRealTriggerMode:w,isAIToolMode:v,isBuiltinMCPMode:y,navigateToCategory:D,loadMoreNodes:S,resetNavigation:_,pagination:p,activeCategoryId:a,setActiveCategoryId:l}},dK=({onSearch:t})=>{const[e,n]=b.useState(""),[r,o]=b.useState([]),[i,s]=b.useState(!1),[a,l]=b.useState({total:0,page:1,size:20}),c=b.useCallback(async(d,h={})=>{if(n(d),!d.trim()){o([]),l({total:0,page:1,size:h.size||20});return}s(!0);try{const{nodes:p,total:m,page:w,size:v}=await t({...h,name:d});o(p),l({total:m,page:w,size:v})}catch(p){console.error("Search failed:",p),o([]),l({total:0,page:1,size:h.size||20})}finally{s(!1)}},[t]),u=b.useCallback(()=>{n(""),o([]),l({total:0,page:1,size:20})},[]);return{searchText:e,searchResults:r,isSearching:i,searchMeta:a,handleSearch:c,clearSearch:u,setSearchText:n}},lw="[workflow:schema-render]",fK=(t,e)=>{var o,i,s,a;const n=t.action_type||t.node_struct||ee.ACTION,r=t.action_ver??((o=t.node_schema)==null?void 0:o.version);return t.action_key&&((s=(i=t.node_schema)==null?void 0:i.input_fields)!=null&&s.length)?(console.info(`${lw} preload schema from search result`,{actionId:t.id,nodeKey:t.action_key,actionVer:t.action_ver,schemaVersion:t.node_schema.version,resolvedVersion:r,inputFields:t.node_schema.input_fields.length}),hD(t.action_key,r,t.node_schema)):t.action_key&&t.node_schema?console.info(`${lw} search result inline schema has no inputFields`,{actionId:t.id,nodeKey:t.action_key,actionVer:t.action_ver,schemaVersion:t.node_schema.version,resolvedVersion:r,inputFields:((a=t.node_schema.input_fields)==null?void 0:a.length)??0}):t.action_key&&console.info(`${lw} search result action without inline schema`,{actionId:t.id,nodeKey:t.action_key,resolvedVersion:r}),{...t,id:t.id,type:n,action_type:n,action_key:t.action_key,action_ver:r,nodeKey:t.action_key,nodeVersion:r,node_schema:t.node_schema,action_name:t.name||e.name,name:t.name||e.name,description:t.description||e.description||"",connector_name:e.name,nodeId:e.id,nodeIcon:e.icon}},hK=(t,e)=>{if(typeof e=="boolean")return e;if(!t)return!1;const n=t.toUpperCase();return n==="ACTION_ONLY"||n==="BOTH_MATCHED"},pK=(t,e)=>{const{matchedActions:n,defaultExpanded:r,matchType:o}=e||{};return{id:t.id||t.name,type:t.build_type||ee.ACTION,name:t.name,description:t.description||"",category:t.app_domain_category&&t.app_domain_category[0]||"unknown",icon:t.icon||void 0,app_domain_category:t.app_domain_category||[],actionCategories:t.app_action_category||[],deployment_type:t.deployment_type,build_type:t.build_type,matchedActions:n,defaultExpanded:hK(o,r),matchType:o,connector:t}},VO=async(t={})=>{var e;try{const{apiSearchLinks:n}=await Promise.resolve().then(()=>Yv),r=await n({...t,page:t.page||1,size:t.size||20}),o=((e=r.items)==null?void 0:e.map(({connector:i,matched_actions:s,default_expanded:a,match_type:l})=>{const c=(s||[]).map(u=>fK(u,i));return pK(i,{matchedActions:c,defaultExpanded:a,matchType:l})}))||[];return{nodes:o,total:r.total||o.length,page:r.page||t.page||1,size:r.size||t.size||20,pages:r.pages}}catch(n){return console.error("获取节点列表失败:",n),{nodes:[],total:0,page:t.page||1,size:t.size||20,pages:0}}},mK=async t=>{try{const{apiGetNodeCategory:e}=await Promise.resolve().then(()=>Yv),{defaultCategories:n}=await Promise.resolve().then(()=>jO),r=await e({type:t}),o=i=>({id:i.name,name:i.label,description:i.desc||"",icon:i.icon||void 0,search_action:i.search_action||!1,children:i.next&&i.next.length>0?i.next.map(s=>o(s)):void 0,nodes:[]});return Array.isArray(r)?r.map(i=>o(i)):n}catch(e){console.error("获取分类失败:",e);const{defaultCategories:n}=await Promise.resolve().then(()=>jO);return n}},gK=({availableCategories:t=zO,initialCategory:e,onSearch:n,onFetchCategories:r,onFetchNodesByCategory:o,restrictToCategory:i})=>{const s=b.useRef(null),a=b.useRef(null),[l,c]=b.useState([]),[u,d]=b.useState({}),h=n||VO,p=r||mK,m=o||VO,{nodeSelectorVisible:w,closeNodeSelector:v,handleNodeSelect:y,nodeAddInfo:g}=Es(),k=oo(),{fetchNodeActions:A}=lK({nodeSelectorVisible:w,nodeAddInfo:g}),{categories:C,isLoadingCategories:E}=cK({onFetchCategories:p,restrictToCategory:i,nodeSelectorVisible:w,nodeAddInfo:g,fallbackCategories:t}),{searchText:D,searchResults:S,isSearching:_,handleSearch:O,clearSearch:B,setSearchText:N}=dK({onSearch:h}),F=b.useRef(D),{categoryNodes:M,isLoadingNodes:T,isRealTriggerMode:P,navigateToCategory:$,loadMoreNodes:W,resetNavigation:V,pagination:X,activeCategoryId:G,currentCategory:te}=uK({categories:C,initialCategory:e,nodeSelectorVisible:w,nodeAddInfo:g,onFetchNodesByCategory:m,flowId:k}),H=b.useMemo(()=>D?S:M,[D,S,M]),j=b.useMemo(()=>(g==null?void 0:g.protocol)===Be.AI_LANGUAGE_MODEL?"选择模型":"选择动作",[g==null?void 0:g.protocol]),Y=b.useMemo(()=>(g==null?void 0:g.protocol)===Be.AI_LANGUAGE_MODEL||(g==null?void 0:g.protocol)===Be.AI_MEMORY?"按模型名称搜索":"按节点/动作名称搜索",[g==null?void 0:g.protocol]),ie=D,Q=b.useMemo(()=>{const de=g==null?void 0:g.protocol;if(de){if(de===Be.AI_TOOL)return Be.MCP;if(de===Be.AI_LANGUAGE_MODEL||de===Be.AI_MEMORY)return de}},[g==null?void 0:g.protocol]),le=b.useMemo(()=>{const de=g==null?void 0:g.protocol;if(de===Be.AI_TOOL)return"tool";if(de===Be.AI_LANGUAGE_MODEL)return"model";if(de===Be.AI_MEMORY)return"memory"},[g==null?void 0:g.protocol]),L=b.useCallback(()=>({app_domain_category:G&&G!=="ALL"?G:void 0,trigger:!!P,type:le,protocol:Q,flow_id:k}),[G,P,le,Q,k]),{run:q,cancel:J}=dt.useDebounceFn(de=>{const Te=de.trim();if(!Te){B(),c([]);return}O(Te,L())},{wait:300}),K=b.useCallback(async de=>{d(_e=>{var tt,cn;return{..._e,[de.id]:{actions:((tt=_e[de.id])==null?void 0:tt.actions)||[],loading:!0,source:(cn=_e[de.id])==null?void 0:cn.source}}});const Te=await A(de,{suppressLoading:!0});d(_e=>({..._e,[de.id]:{actions:Te,loading:!1,source:"full"}}))},[A]),re=async de=>{if(l.includes(de.id)){c(tt=>tt.filter(cn=>cn!==de.id));return}c(tt=>[...tt,de.id]);const _e=u[de.id];(!_e||_e.actions.length===0||_e.source==="search-partial")&&await K(de)},se=async de=>{await K(de)},he=(de,Te)=>{const _e={...Te,...g,name:de.name,description:Te.name||"",type:(Te==null?void 0:Te.action_type)??ee.ACTION,connector_name:(de==null?void 0:de.name)||"",category:(de==null?void 0:de.category)||"unknown",icon:de.icon,isAction:!0};y(_e)},Ce=async de=>{c([]),B(),await $(de.id)},Fe=de=>{N(de),q(de)},qe=de=>{if(D||!X.hasMore||T)return;const{scrollTop:Te,scrollHeight:_e,clientHeight:tt}=de.currentTarget;_e-Te-tt<120&&W()};b.useEffect(()=>{if(!w){const de=setTimeout(()=>{B(),V(),c([]),d({})},200);return()=>clearTimeout(de)}return()=>J()},[w,B,V,J]),b.useEffect(()=>{if(F.current=D,D){const de=S.filter(Te=>Te.defaultExpanded).map(Te=>Te.id);c(de)}},[S,D]),b.useEffect(()=>{D||c([])},[G,D]),b.useEffect(()=>{F.current&&O(F.current,L())},[G,L,O]),b.useEffect(()=>{d(de=>{const Te={};return H.forEach(_e=>{_e.matchedActions&&_e.matchedActions.length>0?Te[_e.id]={actions:_e.matchedActions,loading:!1,source:"search-partial"}:de[_e.id]?Te[_e.id]=de[_e.id]:Te[_e.id]={actions:[],loading:!1}}),Te})},[H]),dt.useClickAway(()=>{w&&v()},s);const Le=()=>_?f.jsxs("div",{className:"loading-state",children:[f.jsx(x.Spin,{}),f.jsx("span",{className:"loading-text",children:"搜索中..."})]}):!_&&H.length===0?f.jsx("div",{className:"empty-state",children:f.jsx("div",{className:"empty-text",children:"暂无符合条件的节点"})}):f.jsxs(f.Fragment,{children:[f.jsx("div",{className:"node-card-list",children:H.map(de=>{var Te,_e,tt;return f.jsx(oK,{node:de,expanded:l.includes(de.id),actions:((Te=u[de.id])==null?void 0:Te.actions)||[],loading:((_e=u[de.id])==null?void 0:_e.loading)||!1,hasPartialActions:((tt=u[de.id])==null?void 0:tt.source)==="search-partial",onToggle:re,onActionSelect:he,onLoadAllActions:se},de.id)})}),!D&&T&&H.length>0&&f.jsxs("div",{className:"list-loading",children:[f.jsx(x.Spin,{size:"small"}),f.jsx("span",{children:"正在加载更多"})]}),!D&&!X.hasMore&&!T&&H.length>0&&f.jsx("div",{className:"list-footer",children:"已加载全部"})]});return w?f.jsxs("div",{className:kn("modern-node-selector",{visible:w}),ref:s,children:[f.jsx(iK,{currentCategory:te,categoryPath:[],selectedNode:null,onClose:v,title:j,showBackButton:!1}),f.jsx("div",{className:"search-container",children:f.jsx(x.Input,{placeholder:Y,prefix:f.jsx(Z.SearchOutlined,{style:{color:"#007aff"}}),allowClear:!0,value:ie,onChange:de=>Fe(de.target.value)})}),f.jsx(nK,{categories:C,activeId:G||"ALL",loading:E,onChange:Ce}),f.jsx("div",{className:"panel-content",ref:a,onClick:de=>de.stopPropagation(),onScroll:qe,children:Le()})]}):null};function wK(t){return t.map(e=>{const{node_type:n,id:r,position:o,icon:i,action_name:s,connector_name:a,description:l,action_id:c,connector_id:u,properties:d,account_schema_id:h,account_id:p,action_key:m,action_ver:w,...v}=e;let y,g;if(n===ee.STICKY)try{const A=JSON.parse(d.value);y=A.width,g=A.height}catch{}const k={type:n,id:r,position:o,data:{icon:i,label:s,action_name:s,description:l,connector_name:a,connector_id:u,account_id:p,account_schema_id:h,action_id:c,action_key:m,action_ver:w,nodeKey:m||v.nodeKey,nodeVersion:w??v.nodeVersion,params:v.params||d,config_schema:d,...v}};if(typeof y=="number"||typeof g=="number"){const A=k.style||{};k.style={...A,...typeof y=="number"?{width:y}:{},...typeof g=="number"?{height:g}:{}}}return k})}function vK(t){if(!t)return console.error("API返回数据格式错误: 缺少data字段"),{workflowId:"",workflowName:"",nodes:[],edges:[]};const e=wK(t.nodes||[]),n=e.map(o=>o.id),r=(t.connections||[]).map(o=>({...o,type:o.type||"main"})).filter(o=>n.includes(o.target)&&o.source&&o.sourceHandle&&o.targetHandle);return{workflowId:t.id||"",workflowName:t.name||"",nodes:e,edges:r}}function yK(t,e,n=""){const r=t.filter(o=>o.type!==ee.START).map(o=>{const{config_schema:i,config:s,params:a,node_schema:l,...c}=o.data;return{...c,node_type:o.type,connector_id:o.data.connector_id||"",id:o.id,action_id:o.data.action_id||o.data.id||"",account_id:o.data.account_id||null,position:o.position,properties:i||s||{},action_name:o.data.label||"",description:o.data.description||""}});return{name:n,connections:e,nodes:r}}const bK={async loadFlow(t){const e=await _v(t),{nodes:n,edges:r,workflowName:o}=vK(e);return{nodes:n,edges:r,name:o||e.name||"",opStatus:e.op_status,executionControl:e.execution_control??null}},async saveFlow({nodes:t,edges:e,workflowName:n,workflowId:r,executionControl:o}){const i=yK(t,e,n);o&&(i.execution_control=o),await Rd(r,i)},async createNode({workflowId:t,nodeType:e,actionId:n,actionKey:r,actionVer:o,configSchema:i,position:s}){const a=await Ov({flow_id:t,node_type:e,action_id:n,...r?{action_key:r,action_ver:o}:{},properties:i||{},position:s});return{nodeId:a.id,nodeData:{action_name:a.action_name,connector_name:a.connector_name,status:a.status,icon:a.icon,protocol:a.protocol,...r?{action_key:r,action_ver:o,nodeKey:r,nodeVersion:o}:{}}}},stickyNodeKey:WU,nodeTypes:Bn.getNodeTypes(),HeaderComponent:tK,PanelComponent:gK,requiresTriggerNode:!0},CK=t=>f.jsx(FO,{strategy:bK,...t}),Dt={"configSubflow-container":"_configSubflow-container_xgeh3_1","configSubflow-selectSection":"_configSubflow-selectSection_xgeh3_4","configSubflow-selectWrapper":"_configSubflow-selectWrapper_xgeh3_19","configSubflow-select":"_configSubflow-select_xgeh3_4","configSubflow-optionContent":"_configSubflow-optionContent_xgeh3_28","configSubflow-optionName":"_configSubflow-optionName_xgeh3_34","configSubflow-optionLink":"_configSubflow-optionLink_xgeh3_41","configSubflow-paramsSection":"_configSubflow-paramsSection_xgeh3_60","configSubflow-paramsTitle":"_configSubflow-paramsTitle_xgeh3_65","configSubflow-paramsList":"_configSubflow-paramsList_xgeh3_77","configSubflow-paramItem":"_configSubflow-paramItem_xgeh3_82",hasError:"_hasError_xgeh3_95","configSubflow-paramKey":"_configSubflow-paramKey_xgeh3_99","configSubflow-paramKeyLabel":"_configSubflow-paramKeyLabel_xgeh3_104","configSubflow-paramValue":"_configSubflow-paramValue_xgeh3_124","configSubflow-hintMessage":"_configSubflow-hintMessage_xgeh3_150",warning:"_warning_xgeh3_164",info:"_info_xgeh3_169","configSubflow-errorText":"_configSubflow-errorText_xgeh3_179","configSubflow-loading":"_configSubflow-loading_xgeh3_185"},kK=(t,e={})=>!(t!=null&&t.params)||Object.keys(t.params).length===0?[]:Object.entries(t.params).map(([n,r],o)=>({id:`${n}_${o}`,key:n,value:e[n]!==void 0?e[n]:r,exampleValue:r})),xK=t=>!!(t!=null&&t.params&&Object.keys(t.params).length>0),WO=b.forwardRef(({value:t,onChange:e,disabled:n=!1,nodeId:r=""},o)=>{const[i,s]=b.useState(t==null?void 0:t.flowId),[a,l]=b.useState([]),[c,u]=b.useState([]),d=Ct(),h=n||!d,{data:p=[],loading:m,run:w}=dt.useRequest(Kv,{debounceWait:300}),v=p||[],y=b.useMemo(()=>v.find(F=>F.id===i),[v,i]);b.useEffect(()=>{(t==null?void 0:t.flowId)!==i&&s(t==null?void 0:t.flowId)},[t==null?void 0:t.flowId]),b.useEffect(()=>{if(y){const F=kK(y,t==null?void 0:t.input);l(F)}else l([])},[y,t==null?void 0:t.input]);const g=b.useCallback((F,M)=>{if(!F){e==null||e(void 0);return}e==null||e({flowId:F,input:M})},[e]),k=b.useCallback(F=>{s(F),u([]);const M=v.find(P=>P.id===F),T={};M!=null&&M.params&&Object.entries(M.params).forEach(([P,$])=>{T[P]=$}),g(F,T)},[v,g]),A=b.useCallback((F,M)=>{const T={...(t==null?void 0:t.input)||{}};T[F]=M,g(i,T),u(P=>P.filter($=>!($.type==="param"&&$.paramKey===F)))},[i,t==null?void 0:t.input,g]),C=b.useCallback((F,M)=>{M.stopPropagation(),M.preventDefault(),window.open(`/uc/link/ai-flow/edit?id=${F}`,"_blank")},[]),E=b.useCallback(()=>{const F=[];return i||F.push({type:"flow",message:"请选择子流程"}),y!=null&&y.params&&Object.keys(y.params).forEach(M=>{var P;const T=(P=t==null?void 0:t.input)==null?void 0:P[M];(T==null||T==="")&&F.push({type:"param",paramKey:M,message:`参数 "${M}" 不能为空`})}),u(F),F.length===0},[i,y,t==null?void 0:t.input]),D=b.useCallback(()=>{u([])},[]);b.useImperativeHandle(o,()=>({validate:E,clearErrors:D}),[E,D]);const S=()=>{var F;return(F=c.find(M=>M.type==="flow"))==null?void 0:F.message},_=F=>{var M;return(M=c.find(T=>T.type==="param"&&T.paramKey===F))==null?void 0:M.message},O=F=>f.jsxs("div",{className:Dt["configSubflow-optionContent"],children:[f.jsx("span",{className:Dt["configSubflow-optionName"],children:F.name}),f.jsx(x.Tooltip,{title:"在新标签页中打开子流程",children:f.jsx("span",{className:Dt["configSubflow-optionLink"],onClick:M=>C(F.id,M),children:f.jsx(Z.ExportOutlined,{})})})]}),B=()=>i?m?f.jsxs("div",{className:Dt["configSubflow-loading"],children:[f.jsx(x.Spin,{size:"small"}),f.jsx("span",{style:{marginLeft:8},children:"加载中..."})]}):xK(y)?f.jsx("div",{className:Dt["configSubflow-paramsList"],children:a.map(F=>{const M=_(F.key);return f.jsxs("div",{className:`${Dt["configSubflow-paramItem"]} ${M?Dt.hasError:""}`,children:[f.jsx("div",{className:Dt["configSubflow-paramKey"],children:f.jsx(x.Tooltip,{title:`示例值: ${F.exampleValue}`,children:f.jsx("div",{className:Dt["configSubflow-paramKeyLabel"],children:F.key})})}),f.jsxs("div",{className:Dt["configSubflow-paramValue"],children:[f.jsx(tr,{value:F.value,onChange:T=>A(F.key,T),placeholder:`示例: ${F.exampleValue}`,disabled:h,borrow:!0,nodeId:r,valueType:"ADAPTOR"}),M&&f.jsx("div",{className:Dt["configSubflow-errorText"],children:M})]})]},F.id)})}):f.jsxs("div",{className:`${Dt["configSubflow-hintMessage"]} ${Dt.info}`,children:[f.jsx(Z.InfoCircleOutlined,{}),f.jsx("span",{children:"该流程无需进行参数配置"})]}):f.jsxs("div",{className:`${Dt["configSubflow-hintMessage"]} ${Dt.warning}`,children:[f.jsx(Z.InfoCircleOutlined,{}),f.jsx("span",{children:"请先选择子流程"})]}),N=S();return f.jsxs("div",{className:Dt["configSubflow-container"],children:[f.jsxs("div",{className:Dt["configSubflow-selectSection"],children:[f.jsx("div",{className:Dt["configSubflow-selectWrapper"],children:f.jsx(x.Select,{className:Dt["configSubflow-select"],value:i,onChange:k,placeholder:"请选择子流程",disabled:h,loading:m,showSearch:!0,filterOption:!1,onSearch:w,notFoundContent:m?f.jsx(x.Spin,{size:"small"}):"暂无数据",allowClear:!0,status:N?"error":void 0,options:v.map(F=>({value:F.id,label:O(F)}))})}),N&&f.jsx("div",{className:Dt["configSubflow-errorText"],children:N})]}),f.jsxs("div",{className:Dt["configSubflow-paramsSection"],children:[f.jsxs("div",{className:Dt["configSubflow-paramsTitle"],children:[f.jsx(Z.SettingOutlined,{}),f.jsx("span",{children:"参数配置"})]}),B()]})]})});WO.displayName="ConfigSubflow";function SK(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return b.useMemo(()=>r=>{e.forEach(o=>o(r))},e)}const kd=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Os(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function cw(t){return"nodeType"in t}function Fn(t){var e,n;return t?Os(t)?t:cw(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}function uw(t){const{Document:e}=Fn(t);return t instanceof e}function sl(t){return Os(t)?!1:t instanceof Fn(t).HTMLElement}function UO(t){return t instanceof Fn(t).SVGElement}function Ts(t){return t?Os(t)?t.document:cw(t)?uw(t)?t:sl(t)||UO(t)?t.ownerDocument:document:document:document}const Vr=kd?b.useLayoutEffect:b.useEffect;function dw(t){const e=b.useRef(t);return Vr(()=>{e.current=t}),b.useCallback(function(){for(var n=arguments.length,r=new Array(n),o=0;o<n;o++)r[o]=arguments[o];return e.current==null?void 0:e.current(...r)},[])}function EK(){const t=b.useRef(null),e=b.useCallback((r,o)=>{t.current=setInterval(r,o)},[]),n=b.useCallback(()=>{t.current!==null&&(clearInterval(t.current),t.current=null)},[]);return[e,n]}function al(t,e){e===void 0&&(e=[t]);const n=b.useRef(t);return Vr(()=>{n.current!==t&&(n.current=t)},e),n}function ll(t,e){const n=b.useRef();return b.useMemo(()=>{const r=t(n.current);return n.current=r,r},[...e])}function xd(t){const e=dw(t),n=b.useRef(null),r=b.useCallback(o=>{o!==n.current&&(e==null||e(o,n.current)),n.current=o},[]);return[n,r]}function fw(t){const e=b.useRef();return b.useEffect(()=>{e.current=t},[t]),e.current}let hw={};function cl(t,e){return b.useMemo(()=>{if(e)return e;const n=hw[t]==null?0:hw[t]+1;return hw[t]=n,t+"-"+n},[t,e])}function qO(t){return function(e){for(var n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.reduce((i,s)=>{const a=Object.entries(s);for(const[l,c]of a){const u=i[l];u!=null&&(i[l]=u+t*c)}return i},{...e})}}const _s=qO(1),ul=qO(-1);function DK(t){return"clientX"in t&&"clientY"in t}function pw(t){if(!t)return!1;const{KeyboardEvent:e}=Fn(t.target);return e&&t instanceof e}function AK(t){if(!t)return!1;const{TouchEvent:e}=Fn(t.target);return e&&t instanceof e}function mw(t){if(AK(t)){if(t.touches&&t.touches.length){const{clientX:e,clientY:n}=t.touches[0];return{x:e,y:n}}else if(t.changedTouches&&t.changedTouches.length){const{clientX:e,clientY:n}=t.changedTouches[0];return{x:e,y:n}}}return DK(t)?{x:t.clientX,y:t.clientY}:null}const dl=Object.freeze({Translate:{toString(t){if(!t)return;const{x:e,y:n}=t;return"translate3d("+(e?Math.round(e):0)+"px, "+(n?Math.round(n):0)+"px, 0)"}},Scale:{toString(t){if(!t)return;const{scaleX:e,scaleY:n}=t;return"scaleX("+e+") scaleY("+n+")"}},Transform:{toString(t){if(t)return[dl.Translate.toString(t),dl.Scale.toString(t)].join(" ")}},Transition:{toString(t){let{property:e,duration:n,easing:r}=t;return e+" "+n+"ms "+r}}}),GO="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function OK(t){return t.matches(GO)?t:t.querySelector(GO)}const TK={display:"none"};function _K(t){let{id:e,value:n}=t;return b.createElement("div",{id:e,style:TK},n)}function NK(t){let{id:e,announcement:n,ariaLiveType:r="assertive"}=t;const o={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return b.createElement("div",{id:e,style:o,role:"status","aria-live":r,"aria-atomic":!0},n)}function BK(){const[t,e]=b.useState("");return{announce:b.useCallback(r=>{r!=null&&e(r)},[]),announcement:t}}const KO=b.createContext(null);function FK(t){const e=b.useContext(KO);b.useEffect(()=>{if(!e)throw new Error("useDndMonitor must be used within a children of <DndContext>");return e(t)},[t,e])}function IK(){const[t]=b.useState(()=>new Set),e=b.useCallback(r=>(t.add(r),()=>t.delete(r)),[t]);return[b.useCallback(r=>{let{type:o,event:i}=r;t.forEach(s=>{var a;return(a=s[o])==null?void 0:a.call(s,i)})},[t]),e]}const MK={draggable:`
|
|
99
99
|
To pick up a draggable item, press the space bar.
|
|
100
100
|
While dragging, use the arrow keys to move the item.
|
|
101
101
|
Press space again to drop the item in its new position, or press escape to cancel.
|
|
102
|
-
`},PK={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function LK(t){let{announcements:e=PK,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=MK}=t;const{announce:i,announcement:s}=BK(),a=cl("DndLiveRegion"),[l,c]=b.useState(!1);if(b.useEffect(()=>{c(!0)},[]),FK(b.useMemo(()=>({onDragStart(d){let{active:h}=d;i(e.onDragStart({active:h}))},onDragMove(d){let{active:h,over:p}=d;e.onDragMove&&i(e.onDragMove({active:h,over:p}))},onDragOver(d){let{active:h,over:p}=d;i(e.onDragOver({active:h,over:p}))},onDragEnd(d){let{active:h,over:p}=d;i(e.onDragEnd({active:h,over:p}))},onDragCancel(d){let{active:h,over:p}=d;i(e.onDragCancel({active:h,over:p}))}}),[i,e])),!l)return null;const u=b.createElement(b.Fragment,null,b.createElement(_K,{id:r,value:o.draggable}),b.createElement(NK,{id:a,announcement:s}));return n?Lo.createPortal(u,n):u}var jt;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(jt||(jt={}));function Sd(){}function YO(t,e){return b.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function $K(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return b.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const vr=Object.freeze({x:0,y:0});function XO(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function JO(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function HK(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function RO(t){let{left:e,top:n,height:r,width:o}=t;return[{x:e,y:n},{x:e+o,y:n},{x:e,y:n+r},{x:e+o,y:n+r}]}function QO(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function ZO(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+t.width*.5,y:n+t.height*.5}}const zK=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const o=ZO(e,e.left,e.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=XO(ZO(l),o);i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(JO)},jK=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const o=RO(e),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=RO(l),u=o.reduce((h,p,m)=>h+XO(c[m],p),0),d=Number((u/4).toFixed(4));i.push({id:a,data:{droppableContainer:s,value:d}})}}return i.sort(JO)};function VK(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),o=Math.min(e.left+e.width,t.left+t.width),i=Math.min(e.top+e.height,t.top+t.height),s=o-r,a=i-n;if(r<o&&n<i){const l=e.width*e.height,c=t.width*t.height,u=s*a,d=u/(l+c-u);return Number(d.toFixed(4))}return 0}const WK=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const o=[];for(const i of r){const{id:s}=i,a=n.get(s);if(a){const l=VK(a,e);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(HK)};function UK(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function eT(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:vr}function qK(t){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((s,a)=>({...s,top:s.top+t*a.y,bottom:s.bottom+t*a.y,left:s.left+t*a.x,right:s.right+t*a.x}),{...n})}}const GK=qK(1);function KK(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function YK(t,e,n){const r=KK(e);if(!r)return t;const{scaleX:o,scaleY:i,x:s,y:a}=r,l=t.left-s-(1-o)*parseFloat(n),c=t.top-a-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=o?t.width/o:t.width,d=i?t.height/i:t.height;return{width:u,height:d,top:c,right:l+u,bottom:c+d,left:l}}const XK={ignoreTransform:!1};function Ns(t,e){e===void 0&&(e=XK);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:c,transformOrigin:u}=Fn(t).getComputedStyle(t);c&&(n=YK(n,c,u))}const{top:r,left:o,width:i,height:s,bottom:a,right:l}=n;return{top:r,left:o,width:i,height:s,bottom:a,right:l}}function tT(t){return Ns(t,{ignoreTransform:!0})}function JK(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function RK(t,e){return e===void 0&&(e=Fn(t).getComputedStyle(t)),e.position==="fixed"}function QK(t,e){e===void 0&&(e=Fn(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=e[o];return typeof i=="string"?n.test(i):!1})}function Ed(t,e){const n=[];function r(o){if(e!=null&&n.length>=e||!o)return n;if(uw(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!sl(o)||UO(o)||n.includes(o))return n;const i=Fn(t).getComputedStyle(o);return o!==t&&QK(o,i)&&n.push(o),RK(o,i)?n:r(o.parentNode)}return t?r(t):n}function nT(t){const[e]=Ed(t,1);return e??null}function gw(t){return!kd||!t?null:Os(t)?t:cw(t)?uw(t)||t===Ts(t).scrollingElement?window:sl(t)?t:null:null}function rT(t){return Os(t)?t.scrollX:t.scrollLeft}function oT(t){return Os(t)?t.scrollY:t.scrollTop}function ww(t){return{x:rT(t),y:oT(t)}}var qt;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(qt||(qt={}));function iT(t){return!kd||!t?!1:t===document.scrollingElement}function sT(t){const e={x:0,y:0},n=iT(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},o=t.scrollTop<=e.y,i=t.scrollLeft<=e.x,s=t.scrollTop>=r.y,a=t.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:s,isRight:a,maxScroll:r,minScroll:e}}const ZK={x:.2,y:.2};function eY(t,e,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=ZK);const{isTop:c,isBottom:u,isLeft:d,isRight:h}=sT(t),p={x:0,y:0},m={x:0,y:0},w={height:e.height*o.y,width:e.width*o.x};return!c&&i<=e.top+w.height?(p.y=qt.Backward,m.y=r*Math.abs((e.top+w.height-i)/w.height)):!u&&l>=e.bottom-w.height&&(p.y=qt.Forward,m.y=r*Math.abs((e.bottom-w.height-l)/w.height)),!h&&a>=e.right-w.width?(p.x=qt.Forward,m.x=r*Math.abs((e.right-w.width-a)/w.width)):!d&&s<=e.left+w.width&&(p.x=qt.Backward,m.x=r*Math.abs((e.left+w.width-s)/w.width)),{direction:p,speed:m}}function tY(t){if(t===document.scrollingElement){const{innerWidth:i,innerHeight:s}=window;return{top:0,left:0,right:i,bottom:s,width:i,height:s}}const{top:e,left:n,right:r,bottom:o}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:o,width:t.clientWidth,height:t.clientHeight}}function aT(t){return t.reduce((e,n)=>_s(e,ww(n)),vr)}function nY(t){return t.reduce((e,n)=>e+rT(n),0)}function rY(t){return t.reduce((e,n)=>e+oT(n),0)}function oY(t,e){if(e===void 0&&(e=Ns),!t)return;const{top:n,left:r,bottom:o,right:i}=e(t);nT(t)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const iY=[["x",["left","right"],nY],["y",["top","bottom"],rY]];class vw{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=Ed(n),o=aT(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[i,s,a]of iY)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=a(r),u=o[i]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class fl{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var o;(o=this.target)==null||o.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function sY(t){const{EventTarget:e}=Fn(t);return t instanceof e?t:Ts(t)}function yw(t,e){const n=Math.abs(t.x),r=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+r**2)>e:"x"in e&&"y"in e?n>e.x&&r>e.y:"x"in e?n>e.x:"y"in e?r>e.y:!1}var nr;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(nr||(nr={}));function lT(t){t.preventDefault()}function aY(t){t.stopPropagation()}var Je;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Je||(Je={}));const cT={start:[Je.Space,Je.Enter],cancel:[Je.Esc],end:[Je.Space,Je.Enter,Je.Tab]},lY=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Je.Right:return{...n,x:n.x+25};case Je.Left:return{...n,x:n.x-25};case Je.Down:return{...n,y:n.y+25};case Je.Up:return{...n,y:n.y-25}}};class bw{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new fl(Ts(n)),this.windowListeners=new fl(Fn(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(nr.Resize,this.handleCancel),this.windowListeners.add(nr.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(nr.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&oY(r),n(vr)}handleKeyDown(e){if(pw(e)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=cT,coordinateGetter:s=lY,scrollBehavior:a="smooth"}=o,{code:l}=e;if(i.end.includes(l)){this.handleEnd(e);return}if(i.cancel.includes(l)){this.handleCancel(e);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:vr;this.referenceCoordinates||(this.referenceCoordinates=u);const d=s(e,{active:n,context:r.current,currentCoordinates:u});if(d){const h=ul(d,u),p={x:0,y:0},{scrollableAncestors:m}=r.current;for(const w of m){const v=e.code,{isTop:y,isRight:g,isLeft:k,isBottom:A,maxScroll:C,minScroll:E}=sT(w),D=tY(w),S={x:Math.min(v===Je.Right?D.right-D.width/2:D.right,Math.max(v===Je.Right?D.left:D.left+D.width/2,d.x)),y:Math.min(v===Je.Down?D.bottom-D.height/2:D.bottom,Math.max(v===Je.Down?D.top:D.top+D.height/2,d.y))},_=v===Je.Right&&!g||v===Je.Left&&!k,O=v===Je.Down&&!A||v===Je.Up&&!y;if(_&&S.x!==d.x){const B=w.scrollLeft+h.x,N=v===Je.Right&&B<=C.x||v===Je.Left&&B>=E.x;if(N&&!h.y){w.scrollTo({left:B,behavior:a});return}N?p.x=w.scrollLeft-B:p.x=v===Je.Right?w.scrollLeft-C.x:w.scrollLeft-E.x,p.x&&w.scrollBy({left:-p.x,behavior:a});break}else if(O&&S.y!==d.y){const B=w.scrollTop+h.y,N=v===Je.Down&&B<=C.y||v===Je.Up&&B>=E.y;if(N&&!h.x){w.scrollTo({top:B,behavior:a});return}N?p.y=w.scrollTop-B:p.y=v===Je.Down?w.scrollTop-C.y:w.scrollTop-E.y,p.y&&w.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(e,_s(ul(d,this.referenceCoordinates),p))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}bw.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=cT,onActivation:o}=e,{active:i}=n;const{code:s}=t.nativeEvent;if(r.start.includes(s)){const a=i.activatorNode.current;return a&&t.target!==a?!1:(t.preventDefault(),o==null||o({event:t.nativeEvent}),!0)}return!1}}];function uT(t){return!!(t&&"distance"in t)}function dT(t){return!!(t&&"delay"in t)}class Cw{constructor(e,n,r){var o;r===void 0&&(r=sY(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:i}=e,{target:s}=i;this.props=e,this.events=n,this.document=Ts(s),this.documentListeners=new fl(this.document),this.listeners=new fl(r),this.windowListeners=new fl(Fn(s)),this.initialCoordinates=(o=mw(i))!=null?o:vr,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(nr.Resize,this.handleCancel),this.windowListeners.add(nr.DragStart,lT),this.windowListeners.add(nr.VisibilityChange,this.handleCancel),this.windowListeners.add(nr.ContextMenu,lT),this.documentListeners.add(nr.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(dT(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(uT(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:r,onPending:o}=this.props;o(r,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(nr.Click,aY,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(nr.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:s,options:{activationConstraint:a}}=i;if(!o)return;const l=(n=mw(e))!=null?n:vr,c=ul(o,l);if(!r&&a){if(uT(a)){if(a.tolerance!=null&&yw(c,a.tolerance))return this.handleCancel();if(yw(c,a.distance))return this.handleStart()}if(dT(a)&&yw(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}e.cancelable&&e.preventDefault(),s(l)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===Je.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const cY={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class kw extends Cw{constructor(e){const{event:n}=e,r=Ts(n.target);super(e,cY,r)}}kw.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const uY={move:{name:"mousemove"},end:{name:"mouseup"}};var xw;(function(t){t[t.RightClick=2]="RightClick"})(xw||(xw={}));class dY extends Cw{constructor(e){super(e,uY,Ts(e.event.target))}}dY.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===xw.RightClick?!1:(r==null||r({event:n}),!0)}}];const Sw={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class fY extends Cw{constructor(e){super(e,Sw)}static setup(){return window.addEventListener(Sw.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Sw.move.name,e)};function e(){}}}fY.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;const{touches:o}=n;return o.length>1?!1:(r==null||r({event:n}),!0)}}];var hl;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(hl||(hl={}));var Dd;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Dd||(Dd={}));function hY(t){let{acceleration:e,activator:n=hl.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=Dd.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:d,threshold:h}=t;const p=mY({delta:d,disabled:!i}),[m,w]=EK(),v=b.useRef({x:0,y:0}),y=b.useRef({x:0,y:0}),g=b.useMemo(()=>{switch(n){case hl.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case hl.DraggableRect:return o}},[n,o,l]),k=b.useRef(null),A=b.useCallback(()=>{const E=k.current;if(!E)return;const D=v.current.x*y.current.x,S=v.current.y*y.current.y;E.scrollBy(D,S)},[]),C=b.useMemo(()=>a===Dd.TreeOrder?[...c].reverse():c,[a,c]);b.useEffect(()=>{if(!i||!c.length||!g){w();return}for(const E of C){if((r==null?void 0:r(E))===!1)continue;const D=c.indexOf(E),S=u[D];if(!S)continue;const{direction:_,speed:O}=eY(E,S,g,e,h);for(const B of["x","y"])p[B][_[B]]||(O[B]=0,_[B]=0);if(O.x>0||O.y>0){w(),k.current=E,m(A,s),v.current=O,y.current=_;return}}v.current={x:0,y:0},y.current={x:0,y:0},w()},[e,A,r,w,i,s,JSON.stringify(g),JSON.stringify(p),m,c,C,u,JSON.stringify(h)])}const pY={x:{[qt.Backward]:!1,[qt.Forward]:!1},y:{[qt.Backward]:!1,[qt.Forward]:!1}};function mY(t){let{delta:e,disabled:n}=t;const r=fw(e);return ll(o=>{if(n||!r||!o)return pY;const i={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[qt.Backward]:o.x[qt.Backward]||i.x===-1,[qt.Forward]:o.x[qt.Forward]||i.x===1},y:{[qt.Backward]:o.y[qt.Backward]||i.y===-1,[qt.Forward]:o.y[qt.Forward]||i.y===1}}},[n,e,r])}function gY(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return ll(o=>{var i;return e==null?null:(i=r??o)!=null?i:null},[r,e])}function wY(t,e){return b.useMemo(()=>t.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(s=>({eventName:s.eventName,handler:e(s.handler,r)}));return[...n,...i]},[]),[t,e])}var pl;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(pl||(pl={}));var Ew;(function(t){t.Optimized="optimized"})(Ew||(Ew={}));const fT=new Map;function vY(t,e){let{dragging:n,dependencies:r,config:o}=e;const[i,s]=b.useState(null),{frequency:a,measure:l,strategy:c}=o,u=b.useRef(t),d=v(),h=al(d),p=b.useCallback(function(y){y===void 0&&(y=[]),!h.current&&s(g=>g===null?y:g.concat(y.filter(k=>!g.includes(k))))},[h]),m=b.useRef(null),w=ll(y=>{if(d&&!n)return fT;if(!y||y===fT||u.current!==t||i!=null){const g=new Map;for(let k of t){if(!k)continue;if(i&&i.length>0&&!i.includes(k.id)&&k.rect.current){g.set(k.id,k.rect.current);continue}const A=k.node.current,C=A?new vw(l(A),A):null;k.rect.current=C,C&&g.set(k.id,C)}return g}return y},[t,i,n,d,l]);return b.useEffect(()=>{u.current=t},[t]),b.useEffect(()=>{d||p()},[n,d]),b.useEffect(()=>{i&&i.length>0&&s(null)},[JSON.stringify(i)]),b.useEffect(()=>{d||typeof a!="number"||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},a))},[a,d,p,...r]),{droppableRects:w,measureDroppableContainers:p,measuringScheduled:i!=null};function v(){switch(c){case pl.Always:return!1;case pl.BeforeDragging:return n;default:return!n}}}function hT(t,e){return ll(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function yY(t,e){return hT(t,e)}function bY(t){let{callback:e,disabled:n}=t;const r=dw(e),o=b.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return b.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function Ad(t){let{callback:e,disabled:n}=t;const r=dw(e),o=b.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return b.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function CY(t){return new vw(Ns(t),t)}function pT(t,e,n){e===void 0&&(e=CY);const[r,o]=b.useState(null);function i(){o(l=>{if(!t)return null;if(t.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=e(t);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const s=bY({callback(l){if(t)for(const c of l){const{type:u,target:d}=c;if(u==="childList"&&d instanceof HTMLElement&&d.contains(t)){i();break}}}}),a=Ad({callback:i});return Vr(()=>{i(),t?(a==null||a.observe(t),s==null||s.observe(document.body,{childList:!0,subtree:!0})):(a==null||a.disconnect(),s==null||s.disconnect())},[t]),r}function kY(t){const e=hT(t);return eT(t,e)}const mT=[];function xY(t){const e=b.useRef(t),n=ll(r=>t?r&&r!==mT&&t&&e.current&&t.parentNode===e.current.parentNode?r:Ed(t):mT,[t]);return b.useEffect(()=>{e.current=t},[t]),n}function SY(t){const[e,n]=b.useState(null),r=b.useRef(t),o=b.useCallback(i=>{const s=gw(i.target);s&&n(a=>a?(a.set(s,ww(s)),new Map(a)):null)},[]);return b.useEffect(()=>{const i=r.current;if(t!==i){s(i);const a=t.map(l=>{const c=gw(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,ww(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=t}return()=>{s(t),s(i)};function s(a){a.forEach(l=>{const c=gw(l);c==null||c.removeEventListener("scroll",o)})}},[o,t]),b.useMemo(()=>t.length?e?Array.from(e.values()).reduce((i,s)=>_s(i,s),vr):aT(t):vr,[t,e])}function gT(t,e){e===void 0&&(e=[]);const n=b.useRef(null);return b.useEffect(()=>{n.current=null},e),b.useEffect(()=>{const r=t!==vr;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?ul(t,n.current):vr}function EY(t){b.useEffect(()=>{if(!kd)return;const e=t.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of e)n==null||n()}},t.map(e=>{let{sensor:n}=e;return n}))}function DY(t,e){return b.useMemo(()=>t.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=s=>{i(s,e)},n},{}),[t,e])}function wT(t){return b.useMemo(()=>t?JK(t):null,[t])}const vT=[];function AY(t,e){e===void 0&&(e=Ns);const[n]=t,r=wT(n?Fn(n):null),[o,i]=b.useState(vT);function s(){i(()=>t.length?t.map(l=>iT(l)?r:new vw(e(l),l)):vT)}const a=Ad({callback:s});return Vr(()=>{a==null||a.disconnect(),s(),t.forEach(l=>a==null?void 0:a.observe(l))},[t]),o}function OY(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return sl(e)?e:t}function TY(t){let{measure:e}=t;const[n,r]=b.useState(null),o=b.useCallback(c=>{for(const{target:u}of c)if(sl(u)){r(d=>{const h=e(u);return d?{...d,width:h.width,height:h.height}:h});break}},[e]),i=Ad({callback:o}),s=b.useCallback(c=>{const u=OY(c);i==null||i.disconnect(),u&&(i==null||i.observe(u)),r(u?e(u):null)},[e,i]),[a,l]=xd(s);return b.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const _Y=[{sensor:kw,options:{}},{sensor:bw,options:{}}],NY={current:{}},Od={draggable:{measure:tT},droppable:{measure:tT,strategy:pl.WhileDragging,frequency:Ew.Optimized},dragOverlay:{measure:Ns}};class ml extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,r;return(n=(r=this.get(e))==null?void 0:r.node.current)!=null?n:void 0}}const BY={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ml,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Sd},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Od,measureDroppableContainers:Sd,windowRect:null,measuringScheduled:!1},FY={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Sd,draggableNodes:new Map,over:null,measureDroppableContainers:Sd},Td=b.createContext(FY),yT=b.createContext(BY);function IY(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ml}}}function MY(t,e){switch(e.type){case jt.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case jt.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case jt.DragEnd:case jt.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case jt.RegisterDroppable:{const{element:n}=e,{id:r}=n,o=new ml(t.droppable.containers);return o.set(r,n),{...t,droppable:{...t.droppable,containers:o}}}case jt.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new ml(t.droppable.containers);return s.set(n,{...i,disabled:o}),{...t,droppable:{...t.droppable,containers:s}}}case jt.UnregisterDroppable:{const{id:n,key:r}=e,o=t.droppable.containers.get(n);if(!o||r!==o.key)return t;const i=new ml(t.droppable.containers);return i.delete(n),{...t,droppable:{...t.droppable,containers:i}}}default:return t}}function PY(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:o}=b.useContext(Td),i=fw(r),s=fw(n==null?void 0:n.id);return b.useEffect(()=>{if(!e&&!r&&i&&s!=null){if(!pw(i)||document.activeElement===i.target)return;const a=o.get(s);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const d=OK(u);if(d){d.focus();break}}})}},[r,e,o,s,i]),null}function LY(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((o,i)=>i({transform:o,...r}),n):n}function $Y(t){return b.useMemo(()=>({draggable:{...Od.draggable,...t==null?void 0:t.draggable},droppable:{...Od.droppable,...t==null?void 0:t.droppable},dragOverlay:{...Od.dragOverlay,...t==null?void 0:t.dragOverlay}}),[t==null?void 0:t.draggable,t==null?void 0:t.droppable,t==null?void 0:t.dragOverlay])}function HY(t){let{activeNode:e,measure:n,initialRect:r,config:o=!0}=t;const i=b.useRef(!1),{x:s,y:a}=typeof o=="boolean"?{x:o,y:o}:o;Vr(()=>{if(!s&&!a||!e){i.current=!1;return}if(i.current||!r)return;const c=e==null?void 0:e.node.current;if(!c||c.isConnected===!1)return;const u=n(c),d=eT(u,r);if(s||(d.x=0),a||(d.y=0),i.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const h=nT(c);h&&h.scrollBy({top:d.y,left:d.x})}},[e,s,a,r,n])}const bT=b.createContext({...vr,scaleX:1,scaleY:1});var Mo;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Mo||(Mo={}));const zY=b.memo(function(e){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=_Y,collisionDetection:d=WK,measuring:h,modifiers:p,...m}=e;const w=b.useReducer(MY,void 0,IY),[v,y]=w,[g,k]=IK(),[A,C]=b.useState(Mo.Uninitialized),E=A===Mo.Initialized,{draggable:{active:D,nodes:S,translate:_},droppable:{containers:O}}=v,B=D!=null?S.get(D):null,N=b.useRef({initial:null,translated:null}),F=b.useMemo(()=>{var Gt;return D!=null?{id:D,data:(Gt=B==null?void 0:B.data)!=null?Gt:NY,rect:N}:null},[D,B]),M=b.useRef(null),[T,P]=b.useState(null),[$,W]=b.useState(null),V=al(m,Object.values(m)),X=cl("DndDescribedBy",s),G=b.useMemo(()=>O.getEnabled(),[O]),te=$Y(h),{droppableRects:H,measureDroppableContainers:j,measuringScheduled:Y}=vY(G,{dragging:E,dependencies:[_.x,_.y],config:te.droppable}),se=gY(S,D),Q=b.useMemo(()=>$?mw($):null,[$]),le=Tw(),L=yY(se,te.draggable.measure);HY({activeNode:D!=null?S.get(D):null,config:le.layoutShiftCompensation,initialRect:L,measure:te.draggable.measure});const q=pT(se,te.draggable.measure,L),J=pT(se?se.parentElement:null),K=b.useRef({activatorEvent:null,active:null,activeNode:se,collisionRect:null,collisions:null,droppableRects:H,draggableNodes:S,draggingNode:null,draggingNodeRect:null,droppableContainers:O,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),re=O.getNodeFor((n=K.current.over)==null?void 0:n.id),ie=TY({measure:te.dragOverlay.measure}),he=(r=ie.nodeRef.current)!=null?r:se,Ce=E?(o=ie.rect)!=null?o:q:null,Fe=!!(ie.nodeRef.current&&ie.rect),qe=kY(Fe?null:q),Le=wT(he?Fn(he):null),de=xY(E?re??se:null),Te=AY(de),_e=LY(p,{transform:{x:_.x-qe.x,y:_.y-qe.y,scaleX:1,scaleY:1},activatorEvent:$,active:F,activeNodeRect:q,containerNodeRect:J,draggingNodeRect:Ce,over:K.current.over,overlayNodeRect:ie.rect,scrollableAncestors:de,scrollableAncestorRects:Te,windowRect:Le}),tt=Q?_s(Q,_):null,cn=SY(de),Vn=gT(cn),en=gT(cn,[q]),At=_s(_e,Vn),ht=Ce?GK(Ce,_e):null,ot=F&&ht?d({active:F,collisionRect:ht,droppableRects:H,droppableContainers:G,pointerCoordinates:tt}):null,lo=QO(ot,"id"),[Wn,bi]=b.useState(null),Fs=Fe?_e:_s(_e,en),Is=UK(Fs,(i=Wn==null?void 0:Wn.rect)!=null?i:null,q),Ci=b.useRef(null),Wr=b.useCallback((Gt,un)=>{let{sensor:dn,options:Se}=un;if(M.current==null)return;const Ne=S.get(M.current);if(!Ne)return;const Ge=Gt.nativeEvent,nt=new dn({active:M.current,activeNode:Ne,event:Ge,options:Se,context:K,onAbort(ct){if(!S.get(ct))return;const{onDragAbort:Pt}=V.current,In={id:ct};Pt==null||Pt(In),g({type:"onDragAbort",event:In})},onPending(ct,St,Pt,In){if(!S.get(ct))return;const{onDragPending:gl}=V.current,Po={id:ct,constraint:St,initialCoordinates:Pt,offset:In};gl==null||gl(Po),g({type:"onDragPending",event:Po})},onStart(ct){const St=M.current;if(St==null)return;const Pt=S.get(St);if(!Pt)return;const{onDragStart:In}=V.current,Ur={activatorEvent:Ge,active:{id:St,data:Pt.data,rect:N}};Lo.unstable_batchedUpdates(()=>{In==null||In(Ur),C(Mo.Initializing),y({type:jt.DragStart,initialCoordinates:ct,active:St}),g({type:"onDragStart",event:Ur}),P(Ci.current),W(Ge)})},onMove(ct){y({type:jt.DragMove,coordinates:ct})},onEnd:lt(jt.DragEnd),onCancel:lt(jt.DragCancel)});Ci.current=nt;function lt(ct){return async function(){const{active:Pt,collisions:In,over:Ur,scrollAdjustedTranslate:gl}=K.current;let Po=null;if(Pt&&gl){const{cancelDrop:wl}=V.current;Po={activatorEvent:Ge,active:Pt,collisions:In,delta:gl,over:Ur},ct===jt.DragEnd&&typeof wl=="function"&&await Promise.resolve(wl(Po))&&(ct=jt.DragCancel)}M.current=null,Lo.unstable_batchedUpdates(()=>{y({type:ct}),C(Mo.Uninitialized),bi(null),P(null),W(null),Ci.current=null;const wl=ct===jt.DragEnd?"onDragEnd":"onDragCancel";if(Po){const _w=V.current[wl];_w==null||_w(Po),g({type:wl,event:Po})}})}}},[S]),Ms=b.useCallback((Gt,un)=>(dn,Se)=>{const Ne=dn.nativeEvent,Ge=S.get(Se);if(M.current!==null||!Ge||Ne.dndKit||Ne.defaultPrevented)return;const nt={active:Ge};Gt(dn,un.options,nt)===!0&&(Ne.dndKit={capturedBy:un.sensor},M.current=Se,Wr(dn,un))},[S,Wr]),ki=wY(u,Ms);EY(u),Vr(()=>{q&&A===Mo.Initializing&&C(Mo.Initialized)},[q,A]),b.useEffect(()=>{const{onDragMove:Gt}=V.current,{active:un,activatorEvent:dn,collisions:Se,over:Ne}=K.current;if(!un||!dn)return;const Ge={active:un,activatorEvent:dn,collisions:Se,delta:{x:At.x,y:At.y},over:Ne};Lo.unstable_batchedUpdates(()=>{Gt==null||Gt(Ge),g({type:"onDragMove",event:Ge})})},[At.x,At.y]),b.useEffect(()=>{const{active:Gt,activatorEvent:un,collisions:dn,droppableContainers:Se,scrollAdjustedTranslate:Ne}=K.current;if(!Gt||M.current==null||!un||!Ne)return;const{onDragOver:Ge}=V.current,nt=Se.get(lo),lt=nt&&nt.rect.current?{id:nt.id,rect:nt.rect.current,data:nt.data,disabled:nt.disabled}:null,ct={active:Gt,activatorEvent:un,collisions:dn,delta:{x:Ne.x,y:Ne.y},over:lt};Lo.unstable_batchedUpdates(()=>{bi(lt),Ge==null||Ge(ct),g({type:"onDragOver",event:ct})})},[lo]),Vr(()=>{K.current={activatorEvent:$,active:F,activeNode:se,collisionRect:ht,collisions:ot,droppableRects:H,draggableNodes:S,draggingNode:he,draggingNodeRect:Ce,droppableContainers:O,over:Wn,scrollableAncestors:de,scrollAdjustedTranslate:At},N.current={initial:Ce,translated:ht}},[F,se,ot,ht,S,he,Ce,H,O,Wn,de,At]),hY({...le,delta:_,draggingRect:ht,pointerCoordinates:tt,scrollableAncestors:de,scrollableAncestorRects:Te});const Ps=b.useMemo(()=>({active:F,activeNode:se,activeNodeRect:q,activatorEvent:$,collisions:ot,containerNodeRect:J,dragOverlay:ie,draggableNodes:S,droppableContainers:O,droppableRects:H,over:Wn,measureDroppableContainers:j,scrollableAncestors:de,scrollableAncestorRects:Te,measuringConfiguration:te,measuringScheduled:Y,windowRect:Le}),[F,se,q,$,ot,J,ie,S,O,H,Wn,j,de,Te,te,Y,Le]),Ow=b.useMemo(()=>({activatorEvent:$,activators:ki,active:F,activeNodeRect:q,ariaDescribedById:{draggable:X},dispatch:y,draggableNodes:S,over:Wn,measureDroppableContainers:j}),[$,ki,F,q,y,X,S,Wn,j]);return b.createElement(KO.Provider,{value:k},b.createElement(Td.Provider,{value:Ow},b.createElement(yT.Provider,{value:Ps},b.createElement(bT.Provider,{value:Is},c)),b.createElement(PY,{disabled:(a==null?void 0:a.restoreFocus)===!1})),b.createElement(LK,{...a,hiddenTextDescribedById:X}));function Tw(){const Gt=(T==null?void 0:T.autoScrollEnabled)===!1,un=typeof l=="object"?l.enabled===!1:l===!1,dn=E&&!Gt&&!un;return typeof l=="object"?{...l,enabled:dn}:{enabled:dn}}}),jY=b.createContext(null),CT="button",VY="Draggable";function WY(t){let{id:e,data:n,disabled:r=!1,attributes:o}=t;const i=cl(VY),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:d,over:h}=b.useContext(Td),{role:p=CT,roleDescription:m="draggable",tabIndex:w=0}=o??{},v=(l==null?void 0:l.id)===e,y=b.useContext(v?bT:jY),[g,k]=xd(),[A,C]=xd(),E=DY(s,e),D=al(n);Vr(()=>(d.set(e,{id:e,key:i,node:g,activatorNode:A,data:D}),()=>{const _=d.get(e);_&&_.key===i&&d.delete(e)}),[d,e]);const S=b.useMemo(()=>({role:p,tabIndex:w,"aria-disabled":r,"aria-pressed":v&&p===CT?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,w,v,m,u.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:S,isDragging:v,listeners:r?void 0:E,node:g,over:h,setNodeRef:k,setActivatorNodeRef:C,transform:y}}function UY(){return b.useContext(yT)}const qY="Droppable",GY={timeout:25};function KY(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:o}=t;const i=cl(qY),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=b.useContext(Td),u=b.useRef({disabled:n}),d=b.useRef(!1),h=b.useRef(null),p=b.useRef(null),{disabled:m,updateMeasurementsFor:w,timeout:v}={...GY,...o},y=al(w??r),g=b.useCallback(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{c(Array.isArray(y.current)?y.current:[y.current]),p.current=null},v)},[v]),k=Ad({callback:g,disabled:m||!s}),A=b.useCallback((S,_)=>{k&&(_&&(k.unobserve(_),d.current=!1),S&&k.observe(S))},[k]),[C,E]=xd(A),D=al(e);return b.useEffect(()=>{!k||!C.current||(k.disconnect(),d.current=!1,k.observe(C.current))},[C,k]),b.useEffect(()=>(a({type:jt.RegisterDroppable,element:{id:r,key:i,disabled:n,node:C,rect:h,data:D}}),()=>a({type:jt.UnregisterDroppable,key:i,id:r})),[r]),b.useEffect(()=>{n!==u.current.disabled&&(a({type:jt.SetDroppableDisabled,id:r,key:i,disabled:n}),u.current.disabled=n)},[r,i,n,a]),{active:s,rect:h,isOver:(l==null?void 0:l.id)===r,node:C,over:l,setNodeRef:E}}const YY=t=>{let{transform:e}=t;return{...e,x:0}};function Dw(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function XY(t,e){return t.reduce((n,r,o)=>{const i=e.get(r);return i&&(n[o]=i),n},Array(t.length))}function _d(t){return t!==null&&t>=0}function JY(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function RY(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const kT=t=>{let{rects:e,activeIndex:n,overIndex:r,index:o}=t;const i=Dw(e,r,n),s=e[o],a=i[o];return!a||!s?null:{x:a.left-s.left,y:a.top-s.top,scaleX:a.width/s.width,scaleY:a.height/s.height}},Nd={scaleX:1,scaleY:1},QY=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:s}=t;const a=(e=i[n])!=null?e:r;if(!a)return null;if(o===n){const c=i[s];return c?{x:0,y:n<s?c.top+c.height-(a.top+a.height):c.top-a.top,...Nd}:null}const l=ZY(i,o,n);return o>n&&o<=s?{x:0,y:-a.height-l,...Nd}:o<n&&o>=s?{x:0,y:a.height+l,...Nd}:{x:0,y:0,...Nd}};function ZY(t,e,n){const r=t[e],o=t[e-1],i=t[e+1];return r?n<e?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const xT="Sortable",ST=b.createContext({activeIndex:-1,containerId:xT,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:kT,disabled:{draggable:!1,droppable:!1}});function eX(t){let{children:e,id:n,items:r,strategy:o=kT,disabled:i=!1}=t;const{active:s,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=UY(),d=cl(xT,n),h=a.rect!==null,p=b.useMemo(()=>r.map(E=>typeof E=="object"&&"id"in E?E.id:E),[r]),m=s!=null,w=s?p.indexOf(s.id):-1,v=c?p.indexOf(c.id):-1,y=b.useRef(p),g=!JY(p,y.current),k=v!==-1&&w===-1||g,A=RY(i);Vr(()=>{g&&m&&u(p)},[g,p,m,u]),b.useEffect(()=>{y.current=p},[p]);const C=b.useMemo(()=>({activeIndex:w,containerId:d,disabled:A,disableTransforms:k,items:p,overIndex:v,useDragOverlay:h,sortedRects:XY(p,l),strategy:o}),[w,d,A.draggable,A.droppable,k,p,v,l,h,o]);return b.createElement(ST.Provider,{value:C},e)}const tX=t=>{let{id:e,items:n,activeIndex:r,overIndex:o}=t;return Dw(n,r,o).indexOf(e)},nX=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:o,items:i,newIndex:s,previousItems:a,previousContainerId:l,transition:c}=t;return!c||!r||a!==i&&o===s?!1:n?!0:s!==o&&e===l},rX={duration:200,easing:"ease"},ET="transform",oX=dl.Transition.toString({property:ET,duration:0,easing:"linear"}),iX={roleDescription:"sortable"};function sX(t){let{disabled:e,index:n,node:r,rect:o}=t;const[i,s]=b.useState(null),a=b.useRef(n);return Vr(()=>{if(!e&&n!==a.current&&r.current){const l=o.current;if(l){const c=Ns(r.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&s(u)}}n!==a.current&&(a.current=n)},[e,n,r,o]),b.useEffect(()=>{i&&s(null)},[i]),i}function aX(t){let{animateLayoutChanges:e=nX,attributes:n,disabled:r,data:o,getNewIndex:i=tX,id:s,strategy:a,resizeObserverConfig:l,transition:c=rX}=t;const{items:u,containerId:d,activeIndex:h,disabled:p,disableTransforms:m,sortedRects:w,overIndex:v,useDragOverlay:y,strategy:g}=b.useContext(ST),k=lX(r,p),A=u.indexOf(s),C=b.useMemo(()=>({sortable:{containerId:d,index:A,items:u},...o}),[d,o,A,u]),E=b.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:D,node:S,isOver:_,setNodeRef:O}=KY({id:s,data:C,disabled:k.droppable,resizeObserverConfig:{updateMeasurementsFor:E,...l}}),{active:B,activatorEvent:N,activeNodeRect:F,attributes:M,setNodeRef:T,listeners:P,isDragging:$,over:W,setActivatorNodeRef:V,transform:X}=WY({id:s,data:C,attributes:{...iX,...n},disabled:k.draggable}),G=SK(O,T),te=!!B,H=te&&!m&&_d(h)&&_d(v),j=!y&&$,Y=j&&H?X:null,Q=H?Y??(a??g)({rects:w,activeNodeRect:F,activeIndex:h,overIndex:v,index:A}):null,le=_d(h)&&_d(v)?i({id:s,items:u,activeIndex:h,overIndex:v}):A,L=B==null?void 0:B.id,q=b.useRef({activeId:L,items:u,newIndex:le,containerId:d}),J=u!==q.current.items,K=e({active:B,containerId:d,isDragging:$,isSorting:te,id:s,index:A,items:u,newIndex:q.current.newIndex,previousItems:q.current.items,previousContainerId:q.current.containerId,transition:c,wasDragging:q.current.activeId!=null}),re=sX({disabled:!K,index:A,node:S,rect:D});return b.useEffect(()=>{te&&q.current.newIndex!==le&&(q.current.newIndex=le),d!==q.current.containerId&&(q.current.containerId=d),u!==q.current.items&&(q.current.items=u)},[te,le,d,u]),b.useEffect(()=>{if(L===q.current.activeId)return;if(L!=null&&q.current.activeId==null){q.current.activeId=L;return}const he=setTimeout(()=>{q.current.activeId=L},50);return()=>clearTimeout(he)},[L]),{active:B,activeIndex:h,attributes:M,data:C,rect:D,index:A,newIndex:le,items:u,isOver:_,isSorting:te,isDragging:$,listeners:P,node:S,overIndex:v,over:W,setNodeRef:G,setActivatorNodeRef:V,setDroppableNodeRef:O,setDraggableNodeRef:T,transform:re??Q,transition:ie()};function ie(){if(re||J&&q.current.newIndex===A)return oX;if(!(j&&!pw(N)||!c)&&(te||K))return dl.Transition.toString({...c,property:ET})}}function lX(t,e){var n,r;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t==null?void 0:t.draggable)!=null?n:e.draggable,droppable:(r=t==null?void 0:t.droppable)!=null?r:e.droppable}}function Bd(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const cX=[Je.Down,Je.Right,Je.Up,Je.Left],uX=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:s,scrollableAncestors:a}}=e;if(cX.includes(t.code)){if(t.preventDefault(),!n||!r)return;const l=[];i.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const h=o.get(d.id);if(h)switch(t.code){case Je.Down:r.top<h.top&&l.push(d);break;case Je.Up:r.top>h.top&&l.push(d);break;case Je.Left:r.left>h.left&&l.push(d);break;case Je.Right:r.left<h.left&&l.push(d);break}});const c=jK({collisionRect:r,droppableRects:o,droppableContainers:l});let u=QO(c,"id");if(u===(s==null?void 0:s.id)&&c.length>1&&(u=c[1].id),u!=null){const d=i.get(n.id),h=i.get(u),p=h?o.get(h.id):null,m=h==null?void 0:h.node.current;if(m&&p&&d&&h){const v=Ed(m).some((E,D)=>a[D]!==E),y=DT(d,h),g=dX(d,h),k=v||!y?{x:0,y:0}:{x:g?r.width-p.width:0,y:g?r.height-p.height:0},A={x:p.left,y:p.top};return k.x&&k.y?A:ul(A,k)}}}};function DT(t,e){return!Bd(t)||!Bd(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function dX(t,e){return!Bd(t)||!Bd(e)||!DT(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}const Me={"multiRowGuard-container":"_multiRowGuard-container_4gqpc_1","multiRowGuard-ruleCard":"_multiRowGuard-ruleCard_4gqpc_4",isDragging:"_isDragging_4gqpc_17",hasError:"_hasError_4gqpc_23","multiRowGuard-ruleHeader":"_multiRowGuard-ruleHeader_4gqpc_30","multiRowGuard-dragHandle":"_multiRowGuard-dragHandle_4gqpc_38","multiRowGuard-ruleIndex":"_multiRowGuard-ruleIndex_4gqpc_53","multiRowGuard-deleteBtn":"_multiRowGuard-deleteBtn_4gqpc_57","multiRowGuard-ruleBody":"_multiRowGuard-ruleBody_4gqpc_65","multiRowGuard-formRow":"_multiRowGuard-formRow_4gqpc_70","multiRowGuard-formItem":"_multiRowGuard-formItem_4gqpc_75","multiRowGuard-formLabel":"_multiRowGuard-formLabel_4gqpc_82",required:"_required_4gqpc_88","multiRowGuard-extraFields":"_multiRowGuard-extraFields_4gqpc_93","multiRowGuard-rangeInputs":"_multiRowGuard-rangeInputs_4gqpc_98","multiRowGuard-rangeInput":"_multiRowGuard-rangeInput_4gqpc_98","multiRowGuard-rangeSeparator":"_multiRowGuard-rangeSeparator_4gqpc_106","multiRowGuard-addBtn":"_multiRowGuard-addBtn_4gqpc_110","multiRowGuard-emptyState":"_multiRowGuard-emptyState_4gqpc_113","multiRowGuard-emptyState-icon":"_multiRowGuard-emptyState-icon_4gqpc_121","multiRowGuard-emptyState-text":"_multiRowGuard-emptyState-text_4gqpc_126","multiRowGuard-enumTagsContainer":"_multiRowGuard-enumTagsContainer_4gqpc_129","multiRowGuard-errorText":"_multiRowGuard-errorText_4gqpc_133","multiRowGuard-fieldError":"_multiRowGuard-fieldError_4gqpc_139"},fX=[{label:"必填校验",value:Lt.REQUIRED},{label:"数据类型校验",value:Lt.TYPE},{label:"枚举校验",value:Lt.ENUM},{label:"数值范围校验",value:Lt.RANGE}],hX=[{label:"Error - 终止流程",value:_l.ERROR},{label:"Warning - 记录告警",value:_l.WARNING}],pX=[{label:"字符串 (string)",value:Oi.STRING},{label:"数字 (number)",value:Oi.NUMBER},{label:"布尔值 (boolean)",value:Oi.BOOLEAN},{label:"对象 (object)",value:Oi.OBJECT},{label:"数组 (array)",value:Oi.ARRAY}],mX=(t,e)=>{const n=e+1;if(!t.field_path||t.field_path.trim()==="")return`规则 ${n}: 字段路径不能为空`;if(!t.rule_type)return`规则 ${n}: 请选择校验规则类型`;if(!t.severity)return`规则 ${n}: 请选择失败处理方式`;switch(t.rule_type){case Lt.TYPE:if(!t.expected_type)return`规则 ${n}: 请选择期望数据类型`;break;case Lt.ENUM:if(!t.enum_values||t.enum_values.length===0)return`规则 ${n}: 请输入至少一个枚举值`;break;case Lt.RANGE:if(t.min===void 0&&t.max===void 0)return`规则 ${n}: 最小值和最大值至少填写一项`;if(t.min!==void 0&&t.max!==void 0&&t.min>t.max)return`规则 ${n}: 最小值不能大于最大值`;break}return null},gX=(t,e)=>{if(!e||e.length===0)return Promise.resolve();for(let n=0;n<e.length;n++){const r=mX(e[n],n);if(r)return Promise.reject(new Error(r))}return Promise.resolve()},wX=(t,e)=>!e||e.length===0?Promise.reject(new Error("请至少添加一条校验规则")):Promise.resolve(),vX=()=>({id:er(),field_path:"",rule_type:Lt.REQUIRED,severity:_l.ERROR,message:""}),yX=t=>{const e=[];switch((!t.field_path||t.field_path.trim()==="")&&e.push({ruleId:t.id,field:"field_path",message:"字段路径不能为空"}),t.rule_type||e.push({ruleId:t.id,field:"rule_type",message:"请选择校验规则类型"}),t.severity||e.push({ruleId:t.id,field:"severity",message:"请选择失败处理方式"}),t.rule_type){case Lt.TYPE:t.expected_type||e.push({ruleId:t.id,field:"expected_type",message:"请选择期望数据类型"});break;case Lt.ENUM:(!t.enum_values||t.enum_values.length===0)&&e.push({ruleId:t.id,field:"enum_values",message:"请输入至少一个枚举值"});break;case Lt.RANGE:t.min===void 0&&t.max===void 0&&e.push({ruleId:t.id,field:"min",message:"最小值和最大值至少填写一项"}),t.min!==void 0&&t.max!==void 0&&t.min>t.max&&e.push({ruleId:t.id,field:"min",message:"最小值不能大于最大值"});break}return e},Bs=(t,e,n)=>{var r;return(r=t.find(o=>o.ruleId===e&&o.field===n))==null?void 0:r.message},bX=({rule:t,index:e,disabled:n=!1,nodeId:r,errors:o,onUpdate:i,onDelete:s})=>{const{attributes:a,listeners:l,setNodeRef:c,setActivatorNodeRef:u,transform:d,transition:h,isDragging:p}=aX({id:t.id,disabled:n}),m={transform:dl.Transform.toString(d&&{...d,scaleY:1}),transition:h},w=Bs(o,t.id,"field_path"),v=Bs(o,t.id,"rule_type"),y=Bs(o,t.id,"severity"),g=Bs(o,t.id,"expected_type"),k=Bs(o,t.id,"enum_values"),A=Bs(o,t.id,"min"),C=o.some(S=>S.ruleId===t.id),E=S=>{const _=S.map(O=>{const B=Number(O);return!isNaN(B)&&O.trim()!==""?B:O});i(t.id,{enum_values:_})},D=()=>{var S;switch(t.rule_type){case Lt.TYPE:return f.jsxs("div",{className:Me["multiRowGuard-formItem"],children:[f.jsx("span",{className:`${Me["multiRowGuard-formLabel"]} ${Me.required}`,children:"期望数据类型"}),f.jsx(x.Select,{value:t.expected_type,onChange:_=>i(t.id,{expected_type:_}),options:pX,placeholder:"请选择数据类型",style:{width:"100%"},disabled:n,status:g?"error":void 0}),g&&f.jsx("div",{className:Me["multiRowGuard-errorText"],children:g})]});case Lt.ENUM:return f.jsxs("div",{className:Me["multiRowGuard-formItem"],children:[f.jsx("span",{className:`${Me["multiRowGuard-formLabel"]} ${Me.required}`,children:"枚举值列表"}),f.jsx(x.Select,{mode:"tags",value:((S=t.enum_values)==null?void 0:S.map(String))??[],onChange:E,placeholder:"输入枚举值后按回车添加",style:{width:"100%"},disabled:n,className:Me["multiRowGuard-enumTagsContainer"],tokenSeparators:[","],status:k?"error":void 0}),k&&f.jsx("div",{className:Me["multiRowGuard-errorText"],children:k})]});case Lt.RANGE:return f.jsxs("div",{className:Me["multiRowGuard-formItem"],children:[f.jsx("span",{className:Me["multiRowGuard-formLabel"],children:"数值范围"}),f.jsxs("div",{className:Me["multiRowGuard-rangeInputs"],children:[f.jsx(x.InputNumber,{className:Me["multiRowGuard-rangeInput"],value:t.min,onChange:_=>i(t.id,{min:_??void 0}),placeholder:"最小值",disabled:n,status:A?"error":void 0}),f.jsx("span",{className:Me["multiRowGuard-rangeSeparator"],children:"至"}),f.jsx(x.InputNumber,{className:Me["multiRowGuard-rangeInput"],value:t.max,onChange:_=>i(t.id,{max:_??void 0}),placeholder:"最大值",disabled:n,status:A?"error":void 0})]}),A&&f.jsx("div",{className:Me["multiRowGuard-errorText"],children:A})]});default:return null}};return f.jsxs("div",{ref:c,style:m,className:`${Me["multiRowGuard-ruleCard"]} ${p?Me.isDragging:""} ${C?Me.hasError:""}`,children:[f.jsxs("div",{className:Me["multiRowGuard-ruleHeader"],children:[f.jsxs("div",{ref:u,className:Me["multiRowGuard-dragHandle"],...a,...l,children:[f.jsx(Z.HolderOutlined,{}),f.jsxs("span",{className:Me["multiRowGuard-ruleIndex"],children:["规则 ",e+1]})]}),!n&&f.jsx(Z.DeleteOutlined,{className:Me["multiRowGuard-deleteBtn"],onClick:()=>s(t.id)})]}),f.jsxs("div",{className:Me["multiRowGuard-ruleBody"],children:[f.jsxs("div",{className:Me["multiRowGuard-formRow"],children:[f.jsxs("div",{className:Me["multiRowGuard-formItem"],children:[f.jsx("span",{className:`${Me["multiRowGuard-formLabel"]} ${Me.required}`,children:"字段路径"}),f.jsx("div",{className:w?Me["multiRowGuard-fieldError"]:void 0,children:f.jsx(tr,{value:t.field_path,onChange:S=>i(t.id,{field_path:S}),placeholder:"如:data.order_id",disabled:n,nodeId:r,borrow:!0,valueType:"ADAPTOR"})}),w&&f.jsx("div",{className:Me["multiRowGuard-errorText"],children:w})]}),f.jsxs("div",{className:Me["multiRowGuard-formItem"],children:[f.jsx("span",{className:`${Me["multiRowGuard-formLabel"]} ${Me.required}`,children:"校验规则类型"}),f.jsx(x.Select,{value:t.rule_type,onChange:S=>{const _={rule_type:S};S!==Lt.TYPE&&(_.expected_type=void 0),S!==Lt.ENUM&&(_.enum_values=void 0),S!==Lt.RANGE&&(_.min=void 0,_.max=void 0),i(t.id,_)},options:fX,style:{width:"100%"},disabled:n,status:v?"error":void 0}),v&&f.jsx("div",{className:Me["multiRowGuard-errorText"],children:v})]})]}),t.rule_type!==Lt.REQUIRED&&f.jsx("div",{className:Me["multiRowGuard-extraFields"],children:D()}),f.jsxs("div",{className:Me["multiRowGuard-formRow"],children:[f.jsxs("div",{className:Me["multiRowGuard-formItem"],children:[f.jsx("span",{className:`${Me["multiRowGuard-formLabel"]} ${Me.required}`,children:"失败处理方式"}),f.jsx(x.Select,{value:t.severity,onChange:S=>i(t.id,{severity:S}),options:hX,style:{width:"100%"},disabled:n,status:y?"error":void 0}),y&&f.jsx("div",{className:Me["multiRowGuard-errorText"],children:y})]}),f.jsxs("div",{className:Me["multiRowGuard-formItem"],children:[f.jsx("span",{className:Me["multiRowGuard-formLabel"],children:"错误提示"}),f.jsx(tr,{value:t.message,onChange:S=>i(t.id,{message:S}),placeholder:"自定义错误提示信息(可选)",disabled:n,nodeId:r,valueType:"FIX_VALUE",disableIDE:!0})]})]})]})]})},AT=b.forwardRef(({value:t,onChange:e,disabled:n=!1,nodeId:r=""},o)=>{const[i,s]=b.useState([]),[a,l]=b.useState([]),c=$K(YO(kw,{activationConstraint:{distance:8}}),YO(bw,{coordinateGetter:uX}));b.useEffect(()=>{const k=(t??[]).map(A=>({...A,id:A.id??er()}));s(k)},[t]);const u=b.useCallback(()=>{const g=[];return i.forEach(k=>{const A=yX(k);g.push(...A)}),l(g),g.length===0},[i]),d=b.useCallback(()=>a,[a]),h=b.useCallback(()=>{l([])},[]);b.useImperativeHandle(o,()=>({validate:u,getErrors:d,clearErrors:h}),[u,d,h]);const p=b.useCallback(g=>{e==null||e(g)},[e]),m=b.useCallback(()=>{const g=[...i,vX()];s(g),p(g)},[i,p]),w=b.useCallback(g=>{const k=i.filter(A=>A.id!==g);s(k),p(k),l(A=>A.filter(C=>C.ruleId!==g))},[i,p]),v=b.useCallback((g,k)=>{const A=i.map(E=>E.id===g?{...E,...k}:E);s(A),p(A);const C=Object.keys(k);l(E=>E.filter(D=>!(D.ruleId===g&&C.includes(D.field))))},[i,p]),y=b.useCallback(g=>{const{active:k,over:A}=g;if(A&&k.id!==A.id){const C=i.findIndex(S=>S.id===k.id),E=i.findIndex(S=>S.id===A.id),D=Dw(i,C,E);s(D),p(D)}},[i,p]);return f.jsxs("div",{className:Me["multiRowGuard-container"],children:[i.length>0?f.jsx(zY,{sensors:c,collisionDetection:zK,modifiers:[YY],onDragEnd:y,children:f.jsx(eX,{items:i.map(g=>g.id),strategy:QY,children:i.map((g,k)=>f.jsx(bX,{rule:g,index:k,disabled:n,nodeId:r,errors:a,onUpdate:v,onDelete:w},g.id))})}):f.jsxs("div",{className:Me["multiRowGuard-emptyState"],children:[f.jsx(Z.SafetyCertificateOutlined,{className:Me["multiRowGuard-emptyState-icon"]}),f.jsx("div",{className:Me["multiRowGuard-emptyState-text"],children:"暂无校验规则,点击下方按钮添加"})]}),!n&&f.jsx(x.Button,{type:"dashed",onClick:m,block:!0,icon:f.jsx(Z.PlusOutlined,{}),className:Me["multiRowGuard-addBtn"],children:"添加校验规则"})]})});AT.displayName="MultiRowGuard";const CX={nativeProps:{},registerComponents:{form:[{name:"MULTI_ROW_GUARD",component:AT,additionalRules:()=>[{validateTrigger:"blur",validator:gX},{validateTrigger:"blur",validator:wX}]},{name:"CONFIG_SUB_FLOW",component:WO}]},grid:{enabled:!0,size:20},miniMap:!0,header:!0,controls:!0,fastOperationButtons:!0,mode:"edit",allowRemoveTrigger:!0,fixedNodes:{triggerIds:[]},selectable:{includeNodeIds:void 0,includeCategories:void 0},limits:{maxNodes:1/0}},kX={types:{trigger:{id:"trigger",category:"Trigger",style:{colors:{success:"#00C853",warning:"#FFD600",error:"#D50000"},card:{radius:8,padding:12,borderColor:"#e0e0e0"},icon:{size:20,radius:4,url:""}},operations:[{id:"copy",label:"复制",enabled:!0},{id:"delete",label:"删除",enabled:!1}]},action:{id:"action",category:"Action",style:{colors:{success:"#00C853",warning:"#FFD600",error:"#D50000"},card:{radius:8,padding:12,borderColor:"#bdbdbd"},icon:{size:20,radius:4,url:""}},operations:[{id:"copy",label:"复制",enabled:!0},{id:"delete",label:"删除",enabled:!0}]}},fixed:{triggers:[],finalAction:void 0}},xX={buttons:[],flowName:{editable:!0,defaultNameRule:()=>`未命名流程-${Date.now()}`,fixedTitle:void 0},nav:{showBack:!0,showHome:!0,backTo:void 0,confirmOnBackWhenOffline:!0,backConfirmMessage:void 0},enableOnlineButton:!0,enableSaveButton:!0,flowStatusTag:{enabled:!0,style:{}},helpDocUrl:void 0,helpDocText:void 0,enableOnlineConfirmMessage:void 0,enableFlowText:void 0},SX={allowAddNodeOnEdge:!0,allowDeleteEdge:!0,validators:[]},EX={tabs:[],showSettings:!0,testArea:{allowManualTest:!0,defaultTestResult:null}},Fd={flowId:"",engineMode:or.CLASSIC,canvas:CX,nodeTypes:kX,edgeRules:SX,toolbar:xX,nodeConfigPanel:EX},DX={arrayStrategy:"append",mergeByIdKeys:["id"]},Id=t=>t&&typeof t=="object"&&!Array.isArray(t);function AX(t,e,n){var o;const r=n.arrayStrategy||"append";if(r==="override")return[...e];if(r==="append")return[...t,...e];if(r==="mergeById"){const i=((o=n.mergeByIdKeys)==null?void 0:o[0])||"id",s=new Map;return t.forEach(a=>s.set(a[i],{...a})),e.forEach(a=>{const l=a[i];s.has(l)?s.set(l,Aw(s.get(l),a,n)):s.set(l,{...a})}),Array.from(s.values())}return[...t]}function Aw(t,e,n=DX){const r={...t};return!Id(t)||!Id(e)?{...e}:(Object.keys(e).forEach(o=>{const i=e[o],s=t[o];if(i!==void 0){if(Array.isArray(s)&&Array.isArray(i)){r[o]=AX(s,i,n);return}if(Id(s)&&Id(i)){r[o]=Aw(s,i,n);return}r[o]=i}}),r)}function OT(t,e,n){return Aw(t,e,n)}let Md={};const OX=t=>{if(Md={...Md,...t},t.httpClient){const e=t.httpClient;if(typeof e=="function")jo({httpClient:e});else{const n=e;jo({httpClient:async(o,i)=>{var h;const{method:s="GET",params:a,data:l,headers:c}=i||{},u=s.toLowerCase(),d={params:a,headers:c};try{let p;switch(u){case"get":p=await n.get(o,d);break;case"post":p=await n.post(o,l,d);break;case"put":p=await n.put(o,l,d);break;case"patch":p=await n.patch(o,l,d);break;case"delete":p=await n.delete(o,d);break;default:p=await n.request({...d,url:o,method:s,data:l})}return((h=p==null?void 0:p.data)==null?void 0:h.data)!==void 0?p.data.data:(p==null?void 0:p.data)||p}catch(p){throw p}}})}}(t.baseUrl!==void 0||t.token!==void 0)&&jo({...t.baseUrl!==void 0?{baseUrl:t.baseUrl}:{},...t.token!==void 0?{token:t.token}:{}})},TX=()=>({...Md}),_X=()=>{Md={}},TT=({id:t="input",position:e=ae.Position.Left,style:n={},isConnectable:r=!0,isValidConnection:o,onConnect:i})=>f.jsx(ae.Handle,{type:"target",id:t,position:e,style:n,isConnectable:r,isValidConnection:o,onConnect:i,className:"workflow-handle workflow-input-handle"}),_T=({id:t="output",position:e=ae.Position.Right,style:n={},isConnectable:r=!0,isValidConnection:o,onConnect:i})=>f.jsx(ae.Handle,{type:"source",id:t,position:e,style:n,isConnectable:r,isValidConnection:o,onConnect:i,className:"workflow-handle workflow-output-handle"});class NX{static createInputHandle(e,n=ae.Position.Left,r={}){return f.jsx(TT,{id:e,position:n,...r})}static createOutputHandle(e,n=ae.Position.Right,r={}){return f.jsx(_T,{id:e,position:n,...r})}static createInputHandles(e,n=ae.Position.Left,r={}){return Array(e).fill(0).map((o,i)=>f.jsx(TT,{id:`input_${i}`,position:n,style:{top:`${(i+1)*100/(e+1)}%`},...r},`input_${i}`))}static createOutputHandles(e,n=ae.Position.Right,r={}){return Array(e).fill(0).map((o,i)=>f.jsx(_T,{id:`output-${i}`,position:n,style:{top:`${(i+1)*100/(e+1)}%`},...r},`output-${i}`))}}const BX=(t=100)=>{const[e,n]=b.useState([]),[r,o]=b.useState([]),[i,s]=b.useState(!1),{getNodes:a,getEdges:l,setNodes:c,setEdges:u}=ae.useReactFlow();b.useEffect(()=>{if(i)return;const m=setTimeout(()=>{const w={nodes:a(),edges:l()},v=e[0];v&&JSON.stringify(v.nodes)===JSON.stringify(w.nodes)&&JSON.stringify(v.edges)===JSON.stringify(w.edges)||(n(y=>{const g=[w,...y];return g.length>t&&g.pop(),g}),o([]))},500);return()=>clearTimeout(m)},[a,l,e,i,t]);const d=b.useCallback(()=>{const[p,...m]=e;p&&(s(!0),o(w=>[{nodes:a(),edges:l()},...w]),n(m),c(p.nodes),u(p.edges),setTimeout(()=>s(!1),100))},[e,a,l,c,u]),h=b.useCallback(()=>{const[p,...m]=r;p&&(s(!0),n(w=>[{nodes:a(),edges:l()},...w]),o(m),c(p.nodes),u(p.edges),setTimeout(()=>s(!1),100))},[r,a,l,c,u]);return{undo:d,redo:h,canUndo:e.length>0,canRedo:r.length>0,history:e,future:r}},FX=t=>{var v,y,g,k;const{config:e,workflowId:n,locale:r="zh-CN",apiBaseUrl:o,apiToken:i,httpClient:s,history:a,engineMode:l}=t,c=b.useRef(null);n&&(Fd.flowId=n||"");const u=b.useMemo(()=>{const A=e?OT(Fd,e):{...Fd};return l&&(A.engineMode=l),s&&(A.httpClient=s),a&&(A.history=a),A},[e,s,a,l]),d=b.useRef(void 0);u.httpClient&&u.httpClient!==d.current&&(jo({httpClient:u.httpClient}),d.current=u.httpClient),(o!==((v=c.current)==null?void 0:v.baseUrl)||i!==((y=c.current)==null?void 0:y.token))&&(o!==void 0||i!==void 0?jo({...o!==void 0?{baseUrl:o}:{},...i!==void 0?{token:i}:{}}):(((g=c.current)==null?void 0:g.baseUrl)!==void 0||((k=c.current)==null?void 0:k.token)!==void 0)&&jo({baseUrl:"",token:""}),c.current={baseUrl:o,token:i});const p=b.useMemo(()=>Mw(r),[r]),m=r==="zh-TW"?$T:r==="en-US"?LT:Nw,w=u.engineMode===or.NEXT?qG:CK;return f.jsx(x.ConfigProvider,{locale:m,children:f.jsx(Ee.IntlProvider,{messages:p,locale:r,children:f.jsx($d.Provider,{store:tg,children:f.jsx(MN,{value:u,children:f.jsx(ae.ReactFlowProvider,{children:f.jsx(w,{workflowId:n,readOnly:t.readOnly,preview:t.preview,previewId:t.previewId,appFlowMode:t.appFlowMode,linkMode:t.linkMode,onSave:t.onSave,onInit:t.onInit})})})})})})},Pd=t=>typeof t!="string"?!1:/\{\{.*\}\}/.test(t),IX=({value:t,onChange:e,allowExpression:n=!0,defaultValueMode:r="select",valueMode:o,onValueModeChange:i,validateVariable:s,expressionPlaceholder:a="输入表达式,支持 {{变量}}",hideModeSwitch:l=!1,options:c,placeholder:u,disabled:d,...h})=>{const p=b.useMemo(()=>Pd(t)?"expression":r,[]),[m,w]=b.useState(p),v=o??m;b.useEffect(()=>{o!==void 0&&w(o)},[o]),b.useEffect(()=>{Pd(t)&&v!=="expression"&&(w("expression"),i==null||i("expression"))},[t,v,i]);const y=b.useCallback(E=>{w(E),i==null||i(E),E==="select"&&Pd(t)&&(e==null||e(void 0))},[t,e,i]),g=b.useCallback(E=>{e==null||e(E)},[e]),k=b.useCallback(E=>{e==null||e(E)},[e]),A=()=>l||!n?null:f.jsx("div",{className:"select-expression-mode-switch",children:f.jsxs(x.Radio.Group,{value:v,onChange:E=>y(E.target.value),size:"small",disabled:d,optionType:"button",buttonStyle:"solid",children:[f.jsxs(x.Radio.Button,{value:"select",title:"下拉选择模式",children:[f.jsx(Z.FontSizeOutlined,{}),f.jsx("span",{className:"mode-label",children:"选择"})]}),f.jsxs(x.Radio.Button,{value:"expression",title:"表达式模式",children:[f.jsx(Z.FunctionOutlined,{}),f.jsx("span",{className:"mode-label",children:"表达式"})]})]})}),C=()=>v==="expression"?f.jsx(bc,{value:typeof t=="string"?t:"",onChange:k,placeholder:a,disabled:d,validateVariable:s}):f.jsx(x.Select,{...h,value:Pd(t)?void 0:t,onChange:g,options:c,placeholder:u,disabled:d});return f.jsxs("div",{className:"select-with-expression",children:[A(),f.jsx("div",{className:"select-expression-content",children:C()})]})};function MX(t){const{dataSource:e,dataLoader:n,values:r,initialData:o,immediate:i=!0,context:s={},transform:a}=t,[l,c]=b.useState(o),[u,d]=b.useState(!1),[h,p]=b.useState(),m=b.useRef(new Map),w=E=>!E||E.kind==="static"?[]:E.deps||[],v=b.useMemo(()=>e?JSON.stringify(e):"null",[e]),y=b.useMemo(()=>{const D=w(e).map(S=>qn(r,S));return JSON.stringify(D)},[e,r]),g=E=>E.cacheKey?E.cacheKey:`${E.action}:${y}`,k=E=>{if(!E.cache)return;const D=g(E),S=m.current.get(D);if(S){if(E.cacheTTL&&Date.now()-S.timestamp>E.cacheTTL){m.current.delete(D);return}return S.data}},A=(E,D)=>{if(!E.cache)return;const S=g(E);m.current.set(S,{data:D,timestamp:Date.now()})},C=()=>{c(void 0),p(void 0)};return b.useEffect(()=>{if(!i)return;if(!e||e.kind==="static"){const N=e&&"data"in e?e.data:o,F=a&&N!==void 0?a(N):N;c(F);return}const E=e,D=k(E);if(D!==void 0){c(D);return}if(!n){const N=E.fallbackData??o,F=a&&N!==void 0?a(N):N;c(F);return}const _=w(E).reduce((N,F)=>(N[F]=qn(r,F),N),{}),O={...E.params||{},deps:_};d(!0),p(void 0);let B=!1;return n(E.action,O,{values:r,...s}).then(N=>{if(!B){const F=a?a(N):N;c(F),A(E,F)}}).catch(N=>{if(!B){const F=N instanceof Error?N:new Error(String(N));p(F);const M=E.fallbackData??o,T=a&&M!==void 0?a(M):M;c(T)}}).finally(()=>{B||d(!1)}),()=>{B=!0}},[y,v,i]),{data:l,loading:u,error:h,reload:C,setData:c}}fe.AIFieldWrapper=H0,fe.AI_FILL_VALUE=Zl,fe.AI_TOOL_NODE_TYPES=r0,fe.AntdProvider=F0,fe.DigitalseeWorkFlow=FX,fe.DynamicForm=Gi,fe.DynamicFormContext=Ef,fe.DynamicFormField=be,fe.DynamicFormProvider=L0,fe.EdgeFactory=Bt,fe.EngineMode=or,fe.FieldRegistryProvider=SB,fe.FieldRenderer=yh,fe.HandleFactory=NX,fe.NodeFactory=Bn,fe.NodeStatus=me,fe.NodeType=ee,fe.SelectWithExpression=IX,fe.ValueModeWrapper=la,fe.VariableInput=bc,fe.VariableSelectorProvider=kf,fe.VariableTextarea=dC,fe.WorkflowOpStatus=We,fe.aiProtocolTypes=n0,fe.arrowStyles=IN,fe.canvasGeometry=i0,fe.configureWorkflow=OX,fe.connectionRules=s0,fe.createFieldComponent=pt,fe.createFieldRegistry=xB,fe.createSimpleFieldComponent=go,fe.createTranslator=Pw,fe.defaultCanvasEngineConfig=Fd,fe.defaultFieldRegistry=Rl,fe.edgeButtonStyles=Ws,fe.edgeStyles=Vs,fe.evaluateCondition=Go,fe.extenderStyles=br,fe.getGlobalWorkflowConfig=TX,fe.handleStyles=Wo,fe.isFieldVisible=Ys,fe.jsonRulesToAntdRules=Mi,fe.labelStyles=o0,fe.mergeConfig=OT,fe.nodeTypeColors=Kt,fe.registerBuiltinFields=RC,fe.resetGlobalWorkflowConfig=_X,fe.resolveBool=Pi,fe.useCanvasApi=BO,fe.useCanvasConfig=Vt,fe.useCanvasLayout=kO,fe.useDataLoader=MX,fe.useDynamicFormContext=kB,fe.useFieldRegistry=Ql,fe.useRegisterVariableField=B0,fe.useUndo=BX,fe.useVariableSelector=lB,fe.useVariableSelectorOptional=xf,fe.useWorkflow=Cr,Object.defineProperty(fe,Symbol.toStringTag,{value:"Module"})}));
|
|
102
|
+
`},PK={onDragStart(t){let{active:e}=t;return"Picked up draggable item "+e.id+"."},onDragOver(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was moved over droppable area "+n.id+".":"Draggable item "+e.id+" is no longer over a droppable area."},onDragEnd(t){let{active:e,over:n}=t;return n?"Draggable item "+e.id+" was dropped over droppable area "+n.id:"Draggable item "+e.id+" was dropped."},onDragCancel(t){let{active:e}=t;return"Dragging was cancelled. Draggable item "+e.id+" was dropped."}};function LK(t){let{announcements:e=PK,container:n,hiddenTextDescribedById:r,screenReaderInstructions:o=MK}=t;const{announce:i,announcement:s}=BK(),a=cl("DndLiveRegion"),[l,c]=b.useState(!1);if(b.useEffect(()=>{c(!0)},[]),FK(b.useMemo(()=>({onDragStart(d){let{active:h}=d;i(e.onDragStart({active:h}))},onDragMove(d){let{active:h,over:p}=d;e.onDragMove&&i(e.onDragMove({active:h,over:p}))},onDragOver(d){let{active:h,over:p}=d;i(e.onDragOver({active:h,over:p}))},onDragEnd(d){let{active:h,over:p}=d;i(e.onDragEnd({active:h,over:p}))},onDragCancel(d){let{active:h,over:p}=d;i(e.onDragCancel({active:h,over:p}))}}),[i,e])),!l)return null;const u=b.createElement(b.Fragment,null,b.createElement(_K,{id:r,value:o.draggable}),b.createElement(NK,{id:a,announcement:s}));return n?Lo.createPortal(u,n):u}var jt;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(jt||(jt={}));function Sd(){}function YO(t,e){return b.useMemo(()=>({sensor:t,options:e??{}}),[t,e])}function $K(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];return b.useMemo(()=>[...e].filter(r=>r!=null),[...e])}const vr=Object.freeze({x:0,y:0});function XO(t,e){return Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2))}function JO(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return n-r}function HK(t,e){let{data:{value:n}}=t,{data:{value:r}}=e;return r-n}function RO(t){let{left:e,top:n,height:r,width:o}=t;return[{x:e,y:n},{x:e+o,y:n},{x:e,y:n+r},{x:e+o,y:n+r}]}function QO(t,e){if(!t||t.length===0)return null;const[n]=t;return n[e]}function ZO(t,e,n){return e===void 0&&(e=t.left),n===void 0&&(n=t.top),{x:e+t.width*.5,y:n+t.height*.5}}const zK=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const o=ZO(e,e.left,e.top),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=XO(ZO(l),o);i.push({id:a,data:{droppableContainer:s,value:c}})}}return i.sort(JO)},jK=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const o=RO(e),i=[];for(const s of r){const{id:a}=s,l=n.get(a);if(l){const c=RO(l),u=o.reduce((h,p,m)=>h+XO(c[m],p),0),d=Number((u/4).toFixed(4));i.push({id:a,data:{droppableContainer:s,value:d}})}}return i.sort(JO)};function VK(t,e){const n=Math.max(e.top,t.top),r=Math.max(e.left,t.left),o=Math.min(e.left+e.width,t.left+t.width),i=Math.min(e.top+e.height,t.top+t.height),s=o-r,a=i-n;if(r<o&&n<i){const l=e.width*e.height,c=t.width*t.height,u=s*a,d=u/(l+c-u);return Number(d.toFixed(4))}return 0}const WK=t=>{let{collisionRect:e,droppableRects:n,droppableContainers:r}=t;const o=[];for(const i of r){const{id:s}=i,a=n.get(s);if(a){const l=VK(a,e);l>0&&o.push({id:s,data:{droppableContainer:i,value:l}})}}return o.sort(HK)};function UK(t,e,n){return{...t,scaleX:e&&n?e.width/n.width:1,scaleY:e&&n?e.height/n.height:1}}function eT(t,e){return t&&e?{x:t.left-e.left,y:t.top-e.top}:vr}function qK(t){return function(n){for(var r=arguments.length,o=new Array(r>1?r-1:0),i=1;i<r;i++)o[i-1]=arguments[i];return o.reduce((s,a)=>({...s,top:s.top+t*a.y,bottom:s.bottom+t*a.y,left:s.left+t*a.x,right:s.right+t*a.x}),{...n})}}const GK=qK(1);function KK(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function YK(t,e,n){const r=KK(e);if(!r)return t;const{scaleX:o,scaleY:i,x:s,y:a}=r,l=t.left-s-(1-o)*parseFloat(n),c=t.top-a-(1-i)*parseFloat(n.slice(n.indexOf(" ")+1)),u=o?t.width/o:t.width,d=i?t.height/i:t.height;return{width:u,height:d,top:c,right:l+u,bottom:c+d,left:l}}const XK={ignoreTransform:!1};function Ns(t,e){e===void 0&&(e=XK);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:c,transformOrigin:u}=Fn(t).getComputedStyle(t);c&&(n=YK(n,c,u))}const{top:r,left:o,width:i,height:s,bottom:a,right:l}=n;return{top:r,left:o,width:i,height:s,bottom:a,right:l}}function tT(t){return Ns(t,{ignoreTransform:!0})}function JK(t){const e=t.innerWidth,n=t.innerHeight;return{top:0,left:0,right:e,bottom:n,width:e,height:n}}function RK(t,e){return e===void 0&&(e=Fn(t).getComputedStyle(t)),e.position==="fixed"}function QK(t,e){e===void 0&&(e=Fn(t).getComputedStyle(t));const n=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(o=>{const i=e[o];return typeof i=="string"?n.test(i):!1})}function Ed(t,e){const n=[];function r(o){if(e!=null&&n.length>=e||!o)return n;if(uw(o)&&o.scrollingElement!=null&&!n.includes(o.scrollingElement))return n.push(o.scrollingElement),n;if(!sl(o)||UO(o)||n.includes(o))return n;const i=Fn(t).getComputedStyle(o);return o!==t&&QK(o,i)&&n.push(o),RK(o,i)?n:r(o.parentNode)}return t?r(t):n}function nT(t){const[e]=Ed(t,1);return e??null}function gw(t){return!kd||!t?null:Os(t)?t:cw(t)?uw(t)||t===Ts(t).scrollingElement?window:sl(t)?t:null:null}function rT(t){return Os(t)?t.scrollX:t.scrollLeft}function oT(t){return Os(t)?t.scrollY:t.scrollTop}function ww(t){return{x:rT(t),y:oT(t)}}var qt;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(qt||(qt={}));function iT(t){return!kd||!t?!1:t===document.scrollingElement}function sT(t){const e={x:0,y:0},n=iT(t)?{height:window.innerHeight,width:window.innerWidth}:{height:t.clientHeight,width:t.clientWidth},r={x:t.scrollWidth-n.width,y:t.scrollHeight-n.height},o=t.scrollTop<=e.y,i=t.scrollLeft<=e.x,s=t.scrollTop>=r.y,a=t.scrollLeft>=r.x;return{isTop:o,isLeft:i,isBottom:s,isRight:a,maxScroll:r,minScroll:e}}const ZK={x:.2,y:.2};function eY(t,e,n,r,o){let{top:i,left:s,right:a,bottom:l}=n;r===void 0&&(r=10),o===void 0&&(o=ZK);const{isTop:c,isBottom:u,isLeft:d,isRight:h}=sT(t),p={x:0,y:0},m={x:0,y:0},w={height:e.height*o.y,width:e.width*o.x};return!c&&i<=e.top+w.height?(p.y=qt.Backward,m.y=r*Math.abs((e.top+w.height-i)/w.height)):!u&&l>=e.bottom-w.height&&(p.y=qt.Forward,m.y=r*Math.abs((e.bottom-w.height-l)/w.height)),!h&&a>=e.right-w.width?(p.x=qt.Forward,m.x=r*Math.abs((e.right-w.width-a)/w.width)):!d&&s<=e.left+w.width&&(p.x=qt.Backward,m.x=r*Math.abs((e.left+w.width-s)/w.width)),{direction:p,speed:m}}function tY(t){if(t===document.scrollingElement){const{innerWidth:i,innerHeight:s}=window;return{top:0,left:0,right:i,bottom:s,width:i,height:s}}const{top:e,left:n,right:r,bottom:o}=t.getBoundingClientRect();return{top:e,left:n,right:r,bottom:o,width:t.clientWidth,height:t.clientHeight}}function aT(t){return t.reduce((e,n)=>_s(e,ww(n)),vr)}function nY(t){return t.reduce((e,n)=>e+rT(n),0)}function rY(t){return t.reduce((e,n)=>e+oT(n),0)}function oY(t,e){if(e===void 0&&(e=Ns),!t)return;const{top:n,left:r,bottom:o,right:i}=e(t);nT(t)&&(o<=0||i<=0||n>=window.innerHeight||r>=window.innerWidth)&&t.scrollIntoView({block:"center",inline:"center"})}const iY=[["x",["left","right"],nY],["y",["top","bottom"],rY]];class vw{constructor(e,n){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=Ed(n),o=aT(r);this.rect={...e},this.width=e.width,this.height=e.height;for(const[i,s,a]of iY)for(const l of s)Object.defineProperty(this,l,{get:()=>{const c=a(r),u=o[i]-c;return this.rect[l]+u},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class fl{constructor(e){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(n=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...n)})},this.target=e}add(e,n,r){var o;(o=this.target)==null||o.addEventListener(e,n,r),this.listeners.push([e,n,r])}}function sY(t){const{EventTarget:e}=Fn(t);return t instanceof e?t:Ts(t)}function yw(t,e){const n=Math.abs(t.x),r=Math.abs(t.y);return typeof e=="number"?Math.sqrt(n**2+r**2)>e:"x"in e&&"y"in e?n>e.x&&r>e.y:"x"in e?n>e.x:"y"in e?r>e.y:!1}var nr;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(nr||(nr={}));function lT(t){t.preventDefault()}function aY(t){t.stopPropagation()}var Je;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(Je||(Je={}));const cT={start:[Je.Space,Je.Enter],cancel:[Je.Esc],end:[Je.Space,Je.Enter,Je.Tab]},lY=(t,e)=>{let{currentCoordinates:n}=e;switch(t.code){case Je.Right:return{...n,x:n.x+25};case Je.Left:return{...n,x:n.x-25};case Je.Down:return{...n,y:n.y+25};case Je.Up:return{...n,y:n.y-25}}};class bw{constructor(e){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=e;const{event:{target:n}}=e;this.props=e,this.listeners=new fl(Ts(n)),this.windowListeners=new fl(Fn(n)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(nr.Resize,this.handleCancel),this.windowListeners.add(nr.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(nr.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:e,onStart:n}=this.props,r=e.node.current;r&&oY(r),n(vr)}handleKeyDown(e){if(pw(e)){const{active:n,context:r,options:o}=this.props,{keyboardCodes:i=cT,coordinateGetter:s=lY,scrollBehavior:a="smooth"}=o,{code:l}=e;if(i.end.includes(l)){this.handleEnd(e);return}if(i.cancel.includes(l)){this.handleCancel(e);return}const{collisionRect:c}=r.current,u=c?{x:c.left,y:c.top}:vr;this.referenceCoordinates||(this.referenceCoordinates=u);const d=s(e,{active:n,context:r.current,currentCoordinates:u});if(d){const h=ul(d,u),p={x:0,y:0},{scrollableAncestors:m}=r.current;for(const w of m){const v=e.code,{isTop:y,isRight:g,isLeft:k,isBottom:A,maxScroll:C,minScroll:E}=sT(w),D=tY(w),S={x:Math.min(v===Je.Right?D.right-D.width/2:D.right,Math.max(v===Je.Right?D.left:D.left+D.width/2,d.x)),y:Math.min(v===Je.Down?D.bottom-D.height/2:D.bottom,Math.max(v===Je.Down?D.top:D.top+D.height/2,d.y))},_=v===Je.Right&&!g||v===Je.Left&&!k,O=v===Je.Down&&!A||v===Je.Up&&!y;if(_&&S.x!==d.x){const B=w.scrollLeft+h.x,N=v===Je.Right&&B<=C.x||v===Je.Left&&B>=E.x;if(N&&!h.y){w.scrollTo({left:B,behavior:a});return}N?p.x=w.scrollLeft-B:p.x=v===Je.Right?w.scrollLeft-C.x:w.scrollLeft-E.x,p.x&&w.scrollBy({left:-p.x,behavior:a});break}else if(O&&S.y!==d.y){const B=w.scrollTop+h.y,N=v===Je.Down&&B<=C.y||v===Je.Up&&B>=E.y;if(N&&!h.x){w.scrollTo({top:B,behavior:a});return}N?p.y=w.scrollTop-B:p.y=v===Je.Down?w.scrollTop-C.y:w.scrollTop-E.y,p.y&&w.scrollBy({top:-p.y,behavior:a});break}}this.handleMove(e,_s(ul(d,this.referenceCoordinates),p))}}}handleMove(e,n){const{onMove:r}=this.props;e.preventDefault(),r(n)}handleEnd(e){const{onEnd:n}=this.props;e.preventDefault(),this.detach(),n()}handleCancel(e){const{onCancel:n}=this.props;e.preventDefault(),this.detach(),n()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}bw.activators=[{eventName:"onKeyDown",handler:(t,e,n)=>{let{keyboardCodes:r=cT,onActivation:o}=e,{active:i}=n;const{code:s}=t.nativeEvent;if(r.start.includes(s)){const a=i.activatorNode.current;return a&&t.target!==a?!1:(t.preventDefault(),o==null||o({event:t.nativeEvent}),!0)}return!1}}];function uT(t){return!!(t&&"distance"in t)}function dT(t){return!!(t&&"delay"in t)}class Cw{constructor(e,n,r){var o;r===void 0&&(r=sY(e.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=e,this.events=n;const{event:i}=e,{target:s}=i;this.props=e,this.events=n,this.document=Ts(s),this.documentListeners=new fl(this.document),this.listeners=new fl(r),this.windowListeners=new fl(Fn(s)),this.initialCoordinates=(o=mw(i))!=null?o:vr,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:e,props:{options:{activationConstraint:n,bypassActivationConstraint:r}}}=this;if(this.listeners.add(e.move.name,this.handleMove,{passive:!1}),this.listeners.add(e.end.name,this.handleEnd),e.cancel&&this.listeners.add(e.cancel.name,this.handleCancel),this.windowListeners.add(nr.Resize,this.handleCancel),this.windowListeners.add(nr.DragStart,lT),this.windowListeners.add(nr.VisibilityChange,this.handleCancel),this.windowListeners.add(nr.ContextMenu,lT),this.documentListeners.add(nr.Keydown,this.handleKeydown),n){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(dT(n)){this.timeoutId=setTimeout(this.handleStart,n.delay),this.handlePending(n);return}if(uT(n)){this.handlePending(n);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(e,n){const{active:r,onPending:o}=this.props;o(r,e,this.initialCoordinates,n)}handleStart(){const{initialCoordinates:e}=this,{onStart:n}=this.props;e&&(this.activated=!0,this.documentListeners.add(nr.Click,aY,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(nr.SelectionChange,this.removeTextSelection),n(e))}handleMove(e){var n;const{activated:r,initialCoordinates:o,props:i}=this,{onMove:s,options:{activationConstraint:a}}=i;if(!o)return;const l=(n=mw(e))!=null?n:vr,c=ul(o,l);if(!r&&a){if(uT(a)){if(a.tolerance!=null&&yw(c,a.tolerance))return this.handleCancel();if(yw(c,a.distance))return this.handleStart()}if(dT(a)&&yw(c,a.tolerance))return this.handleCancel();this.handlePending(a,c);return}e.cancelable&&e.preventDefault(),s(l)}handleEnd(){const{onAbort:e,onEnd:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleCancel(){const{onAbort:e,onCancel:n}=this.props;this.detach(),this.activated||e(this.props.active),n()}handleKeydown(e){e.code===Je.Esc&&this.handleCancel()}removeTextSelection(){var e;(e=this.document.getSelection())==null||e.removeAllRanges()}}const cY={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class kw extends Cw{constructor(e){const{event:n}=e,r=Ts(n.target);super(e,cY,r)}}kw.activators=[{eventName:"onPointerDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return!n.isPrimary||n.button!==0?!1:(r==null||r({event:n}),!0)}}];const uY={move:{name:"mousemove"},end:{name:"mouseup"}};var xw;(function(t){t[t.RightClick=2]="RightClick"})(xw||(xw={}));class dY extends Cw{constructor(e){super(e,uY,Ts(e.event.target))}}dY.activators=[{eventName:"onMouseDown",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;return n.button===xw.RightClick?!1:(r==null||r({event:n}),!0)}}];const Sw={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class fY extends Cw{constructor(e){super(e,Sw)}static setup(){return window.addEventListener(Sw.move.name,e,{capture:!1,passive:!1}),function(){window.removeEventListener(Sw.move.name,e)};function e(){}}}fY.activators=[{eventName:"onTouchStart",handler:(t,e)=>{let{nativeEvent:n}=t,{onActivation:r}=e;const{touches:o}=n;return o.length>1?!1:(r==null||r({event:n}),!0)}}];var hl;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(hl||(hl={}));var Dd;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(Dd||(Dd={}));function hY(t){let{acceleration:e,activator:n=hl.Pointer,canScroll:r,draggingRect:o,enabled:i,interval:s=5,order:a=Dd.TreeOrder,pointerCoordinates:l,scrollableAncestors:c,scrollableAncestorRects:u,delta:d,threshold:h}=t;const p=mY({delta:d,disabled:!i}),[m,w]=EK(),v=b.useRef({x:0,y:0}),y=b.useRef({x:0,y:0}),g=b.useMemo(()=>{switch(n){case hl.Pointer:return l?{top:l.y,bottom:l.y,left:l.x,right:l.x}:null;case hl.DraggableRect:return o}},[n,o,l]),k=b.useRef(null),A=b.useCallback(()=>{const E=k.current;if(!E)return;const D=v.current.x*y.current.x,S=v.current.y*y.current.y;E.scrollBy(D,S)},[]),C=b.useMemo(()=>a===Dd.TreeOrder?[...c].reverse():c,[a,c]);b.useEffect(()=>{if(!i||!c.length||!g){w();return}for(const E of C){if((r==null?void 0:r(E))===!1)continue;const D=c.indexOf(E),S=u[D];if(!S)continue;const{direction:_,speed:O}=eY(E,S,g,e,h);for(const B of["x","y"])p[B][_[B]]||(O[B]=0,_[B]=0);if(O.x>0||O.y>0){w(),k.current=E,m(A,s),v.current=O,y.current=_;return}}v.current={x:0,y:0},y.current={x:0,y:0},w()},[e,A,r,w,i,s,JSON.stringify(g),JSON.stringify(p),m,c,C,u,JSON.stringify(h)])}const pY={x:{[qt.Backward]:!1,[qt.Forward]:!1},y:{[qt.Backward]:!1,[qt.Forward]:!1}};function mY(t){let{delta:e,disabled:n}=t;const r=fw(e);return ll(o=>{if(n||!r||!o)return pY;const i={x:Math.sign(e.x-r.x),y:Math.sign(e.y-r.y)};return{x:{[qt.Backward]:o.x[qt.Backward]||i.x===-1,[qt.Forward]:o.x[qt.Forward]||i.x===1},y:{[qt.Backward]:o.y[qt.Backward]||i.y===-1,[qt.Forward]:o.y[qt.Forward]||i.y===1}}},[n,e,r])}function gY(t,e){const n=e!=null?t.get(e):void 0,r=n?n.node.current:null;return ll(o=>{var i;return e==null?null:(i=r??o)!=null?i:null},[r,e])}function wY(t,e){return b.useMemo(()=>t.reduce((n,r)=>{const{sensor:o}=r,i=o.activators.map(s=>({eventName:s.eventName,handler:e(s.handler,r)}));return[...n,...i]},[]),[t,e])}var pl;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(pl||(pl={}));var Ew;(function(t){t.Optimized="optimized"})(Ew||(Ew={}));const fT=new Map;function vY(t,e){let{dragging:n,dependencies:r,config:o}=e;const[i,s]=b.useState(null),{frequency:a,measure:l,strategy:c}=o,u=b.useRef(t),d=v(),h=al(d),p=b.useCallback(function(y){y===void 0&&(y=[]),!h.current&&s(g=>g===null?y:g.concat(y.filter(k=>!g.includes(k))))},[h]),m=b.useRef(null),w=ll(y=>{if(d&&!n)return fT;if(!y||y===fT||u.current!==t||i!=null){const g=new Map;for(let k of t){if(!k)continue;if(i&&i.length>0&&!i.includes(k.id)&&k.rect.current){g.set(k.id,k.rect.current);continue}const A=k.node.current,C=A?new vw(l(A),A):null;k.rect.current=C,C&&g.set(k.id,C)}return g}return y},[t,i,n,d,l]);return b.useEffect(()=>{u.current=t},[t]),b.useEffect(()=>{d||p()},[n,d]),b.useEffect(()=>{i&&i.length>0&&s(null)},[JSON.stringify(i)]),b.useEffect(()=>{d||typeof a!="number"||m.current!==null||(m.current=setTimeout(()=>{p(),m.current=null},a))},[a,d,p,...r]),{droppableRects:w,measureDroppableContainers:p,measuringScheduled:i!=null};function v(){switch(c){case pl.Always:return!1;case pl.BeforeDragging:return n;default:return!n}}}function hT(t,e){return ll(n=>t?n||(typeof e=="function"?e(t):t):null,[e,t])}function yY(t,e){return hT(t,e)}function bY(t){let{callback:e,disabled:n}=t;const r=dw(e),o=b.useMemo(()=>{if(n||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:i}=window;return new i(r)},[r,n]);return b.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function Ad(t){let{callback:e,disabled:n}=t;const r=dw(e),o=b.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:i}=window;return new i(r)},[n]);return b.useEffect(()=>()=>o==null?void 0:o.disconnect(),[o]),o}function CY(t){return new vw(Ns(t),t)}function pT(t,e,n){e===void 0&&(e=CY);const[r,o]=b.useState(null);function i(){o(l=>{if(!t)return null;if(t.isConnected===!1){var c;return(c=l??n)!=null?c:null}const u=e(t);return JSON.stringify(l)===JSON.stringify(u)?l:u})}const s=bY({callback(l){if(t)for(const c of l){const{type:u,target:d}=c;if(u==="childList"&&d instanceof HTMLElement&&d.contains(t)){i();break}}}}),a=Ad({callback:i});return Vr(()=>{i(),t?(a==null||a.observe(t),s==null||s.observe(document.body,{childList:!0,subtree:!0})):(a==null||a.disconnect(),s==null||s.disconnect())},[t]),r}function kY(t){const e=hT(t);return eT(t,e)}const mT=[];function xY(t){const e=b.useRef(t),n=ll(r=>t?r&&r!==mT&&t&&e.current&&t.parentNode===e.current.parentNode?r:Ed(t):mT,[t]);return b.useEffect(()=>{e.current=t},[t]),n}function SY(t){const[e,n]=b.useState(null),r=b.useRef(t),o=b.useCallback(i=>{const s=gw(i.target);s&&n(a=>a?(a.set(s,ww(s)),new Map(a)):null)},[]);return b.useEffect(()=>{const i=r.current;if(t!==i){s(i);const a=t.map(l=>{const c=gw(l);return c?(c.addEventListener("scroll",o,{passive:!0}),[c,ww(c)]):null}).filter(l=>l!=null);n(a.length?new Map(a):null),r.current=t}return()=>{s(t),s(i)};function s(a){a.forEach(l=>{const c=gw(l);c==null||c.removeEventListener("scroll",o)})}},[o,t]),b.useMemo(()=>t.length?e?Array.from(e.values()).reduce((i,s)=>_s(i,s),vr):aT(t):vr,[t,e])}function gT(t,e){e===void 0&&(e=[]);const n=b.useRef(null);return b.useEffect(()=>{n.current=null},e),b.useEffect(()=>{const r=t!==vr;r&&!n.current&&(n.current=t),!r&&n.current&&(n.current=null)},[t]),n.current?ul(t,n.current):vr}function EY(t){b.useEffect(()=>{if(!kd)return;const e=t.map(n=>{let{sensor:r}=n;return r.setup==null?void 0:r.setup()});return()=>{for(const n of e)n==null||n()}},t.map(e=>{let{sensor:n}=e;return n}))}function DY(t,e){return b.useMemo(()=>t.reduce((n,r)=>{let{eventName:o,handler:i}=r;return n[o]=s=>{i(s,e)},n},{}),[t,e])}function wT(t){return b.useMemo(()=>t?JK(t):null,[t])}const vT=[];function AY(t,e){e===void 0&&(e=Ns);const[n]=t,r=wT(n?Fn(n):null),[o,i]=b.useState(vT);function s(){i(()=>t.length?t.map(l=>iT(l)?r:new vw(e(l),l)):vT)}const a=Ad({callback:s});return Vr(()=>{a==null||a.disconnect(),s(),t.forEach(l=>a==null?void 0:a.observe(l))},[t]),o}function OY(t){if(!t)return null;if(t.children.length>1)return t;const e=t.children[0];return sl(e)?e:t}function TY(t){let{measure:e}=t;const[n,r]=b.useState(null),o=b.useCallback(c=>{for(const{target:u}of c)if(sl(u)){r(d=>{const h=e(u);return d?{...d,width:h.width,height:h.height}:h});break}},[e]),i=Ad({callback:o}),s=b.useCallback(c=>{const u=OY(c);i==null||i.disconnect(),u&&(i==null||i.observe(u)),r(u?e(u):null)},[e,i]),[a,l]=xd(s);return b.useMemo(()=>({nodeRef:a,rect:n,setRef:l}),[n,a,l])}const _Y=[{sensor:kw,options:{}},{sensor:bw,options:{}}],NY={current:{}},Od={draggable:{measure:tT},droppable:{measure:tT,strategy:pl.WhileDragging,frequency:Ew.Optimized},dragOverlay:{measure:Ns}};class ml extends Map{get(e){var n;return e!=null&&(n=super.get(e))!=null?n:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(e=>{let{disabled:n}=e;return!n})}getNodeFor(e){var n,r;return(n=(r=this.get(e))==null?void 0:r.node.current)!=null?n:void 0}}const BY={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ml,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:Sd},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Od,measureDroppableContainers:Sd,windowRect:null,measuringScheduled:!1},FY={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:Sd,draggableNodes:new Map,over:null,measureDroppableContainers:Sd},Td=b.createContext(FY),yT=b.createContext(BY);function IY(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ml}}}function MY(t,e){switch(e.type){case jt.DragStart:return{...t,draggable:{...t.draggable,initialCoordinates:e.initialCoordinates,active:e.active}};case jt.DragMove:return t.draggable.active==null?t:{...t,draggable:{...t.draggable,translate:{x:e.coordinates.x-t.draggable.initialCoordinates.x,y:e.coordinates.y-t.draggable.initialCoordinates.y}}};case jt.DragEnd:case jt.DragCancel:return{...t,draggable:{...t.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case jt.RegisterDroppable:{const{element:n}=e,{id:r}=n,o=new ml(t.droppable.containers);return o.set(r,n),{...t,droppable:{...t.droppable,containers:o}}}case jt.SetDroppableDisabled:{const{id:n,key:r,disabled:o}=e,i=t.droppable.containers.get(n);if(!i||r!==i.key)return t;const s=new ml(t.droppable.containers);return s.set(n,{...i,disabled:o}),{...t,droppable:{...t.droppable,containers:s}}}case jt.UnregisterDroppable:{const{id:n,key:r}=e,o=t.droppable.containers.get(n);if(!o||r!==o.key)return t;const i=new ml(t.droppable.containers);return i.delete(n),{...t,droppable:{...t.droppable,containers:i}}}default:return t}}function PY(t){let{disabled:e}=t;const{active:n,activatorEvent:r,draggableNodes:o}=b.useContext(Td),i=fw(r),s=fw(n==null?void 0:n.id);return b.useEffect(()=>{if(!e&&!r&&i&&s!=null){if(!pw(i)||document.activeElement===i.target)return;const a=o.get(s);if(!a)return;const{activatorNode:l,node:c}=a;if(!l.current&&!c.current)return;requestAnimationFrame(()=>{for(const u of[l.current,c.current]){if(!u)continue;const d=OK(u);if(d){d.focus();break}}})}},[r,e,o,s,i]),null}function LY(t,e){let{transform:n,...r}=e;return t!=null&&t.length?t.reduce((o,i)=>i({transform:o,...r}),n):n}function $Y(t){return b.useMemo(()=>({draggable:{...Od.draggable,...t==null?void 0:t.draggable},droppable:{...Od.droppable,...t==null?void 0:t.droppable},dragOverlay:{...Od.dragOverlay,...t==null?void 0:t.dragOverlay}}),[t==null?void 0:t.draggable,t==null?void 0:t.droppable,t==null?void 0:t.dragOverlay])}function HY(t){let{activeNode:e,measure:n,initialRect:r,config:o=!0}=t;const i=b.useRef(!1),{x:s,y:a}=typeof o=="boolean"?{x:o,y:o}:o;Vr(()=>{if(!s&&!a||!e){i.current=!1;return}if(i.current||!r)return;const c=e==null?void 0:e.node.current;if(!c||c.isConnected===!1)return;const u=n(c),d=eT(u,r);if(s||(d.x=0),a||(d.y=0),i.current=!0,Math.abs(d.x)>0||Math.abs(d.y)>0){const h=nT(c);h&&h.scrollBy({top:d.y,left:d.x})}},[e,s,a,r,n])}const bT=b.createContext({...vr,scaleX:1,scaleY:1});var Mo;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(Mo||(Mo={}));const zY=b.memo(function(e){var n,r,o,i;let{id:s,accessibility:a,autoScroll:l=!0,children:c,sensors:u=_Y,collisionDetection:d=WK,measuring:h,modifiers:p,...m}=e;const w=b.useReducer(MY,void 0,IY),[v,y]=w,[g,k]=IK(),[A,C]=b.useState(Mo.Uninitialized),E=A===Mo.Initialized,{draggable:{active:D,nodes:S,translate:_},droppable:{containers:O}}=v,B=D!=null?S.get(D):null,N=b.useRef({initial:null,translated:null}),F=b.useMemo(()=>{var Gt;return D!=null?{id:D,data:(Gt=B==null?void 0:B.data)!=null?Gt:NY,rect:N}:null},[D,B]),M=b.useRef(null),[T,P]=b.useState(null),[$,W]=b.useState(null),V=al(m,Object.values(m)),X=cl("DndDescribedBy",s),G=b.useMemo(()=>O.getEnabled(),[O]),te=$Y(h),{droppableRects:H,measureDroppableContainers:j,measuringScheduled:Y}=vY(G,{dragging:E,dependencies:[_.x,_.y],config:te.droppable}),ie=gY(S,D),Q=b.useMemo(()=>$?mw($):null,[$]),le=Tw(),L=yY(ie,te.draggable.measure);HY({activeNode:D!=null?S.get(D):null,config:le.layoutShiftCompensation,initialRect:L,measure:te.draggable.measure});const q=pT(ie,te.draggable.measure,L),J=pT(ie?ie.parentElement:null),K=b.useRef({activatorEvent:null,active:null,activeNode:ie,collisionRect:null,collisions:null,droppableRects:H,draggableNodes:S,draggingNode:null,draggingNodeRect:null,droppableContainers:O,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),re=O.getNodeFor((n=K.current.over)==null?void 0:n.id),se=TY({measure:te.dragOverlay.measure}),he=(r=se.nodeRef.current)!=null?r:ie,Ce=E?(o=se.rect)!=null?o:q:null,Fe=!!(se.nodeRef.current&&se.rect),qe=kY(Fe?null:q),Le=wT(he?Fn(he):null),de=xY(E?re??ie:null),Te=AY(de),_e=LY(p,{transform:{x:_.x-qe.x,y:_.y-qe.y,scaleX:1,scaleY:1},activatorEvent:$,active:F,activeNodeRect:q,containerNodeRect:J,draggingNodeRect:Ce,over:K.current.over,overlayNodeRect:se.rect,scrollableAncestors:de,scrollableAncestorRects:Te,windowRect:Le}),tt=Q?_s(Q,_):null,cn=SY(de),Vn=gT(cn),en=gT(cn,[q]),At=_s(_e,Vn),ht=Ce?GK(Ce,_e):null,ot=F&&ht?d({active:F,collisionRect:ht,droppableRects:H,droppableContainers:G,pointerCoordinates:tt}):null,lo=QO(ot,"id"),[Wn,bi]=b.useState(null),Fs=Fe?_e:_s(_e,en),Is=UK(Fs,(i=Wn==null?void 0:Wn.rect)!=null?i:null,q),Ci=b.useRef(null),Wr=b.useCallback((Gt,un)=>{let{sensor:dn,options:Se}=un;if(M.current==null)return;const Ne=S.get(M.current);if(!Ne)return;const Ge=Gt.nativeEvent,nt=new dn({active:M.current,activeNode:Ne,event:Ge,options:Se,context:K,onAbort(ct){if(!S.get(ct))return;const{onDragAbort:Pt}=V.current,In={id:ct};Pt==null||Pt(In),g({type:"onDragAbort",event:In})},onPending(ct,St,Pt,In){if(!S.get(ct))return;const{onDragPending:gl}=V.current,Po={id:ct,constraint:St,initialCoordinates:Pt,offset:In};gl==null||gl(Po),g({type:"onDragPending",event:Po})},onStart(ct){const St=M.current;if(St==null)return;const Pt=S.get(St);if(!Pt)return;const{onDragStart:In}=V.current,Ur={activatorEvent:Ge,active:{id:St,data:Pt.data,rect:N}};Lo.unstable_batchedUpdates(()=>{In==null||In(Ur),C(Mo.Initializing),y({type:jt.DragStart,initialCoordinates:ct,active:St}),g({type:"onDragStart",event:Ur}),P(Ci.current),W(Ge)})},onMove(ct){y({type:jt.DragMove,coordinates:ct})},onEnd:lt(jt.DragEnd),onCancel:lt(jt.DragCancel)});Ci.current=nt;function lt(ct){return async function(){const{active:Pt,collisions:In,over:Ur,scrollAdjustedTranslate:gl}=K.current;let Po=null;if(Pt&&gl){const{cancelDrop:wl}=V.current;Po={activatorEvent:Ge,active:Pt,collisions:In,delta:gl,over:Ur},ct===jt.DragEnd&&typeof wl=="function"&&await Promise.resolve(wl(Po))&&(ct=jt.DragCancel)}M.current=null,Lo.unstable_batchedUpdates(()=>{y({type:ct}),C(Mo.Uninitialized),bi(null),P(null),W(null),Ci.current=null;const wl=ct===jt.DragEnd?"onDragEnd":"onDragCancel";if(Po){const _w=V.current[wl];_w==null||_w(Po),g({type:wl,event:Po})}})}}},[S]),Ms=b.useCallback((Gt,un)=>(dn,Se)=>{const Ne=dn.nativeEvent,Ge=S.get(Se);if(M.current!==null||!Ge||Ne.dndKit||Ne.defaultPrevented)return;const nt={active:Ge};Gt(dn,un.options,nt)===!0&&(Ne.dndKit={capturedBy:un.sensor},M.current=Se,Wr(dn,un))},[S,Wr]),ki=wY(u,Ms);EY(u),Vr(()=>{q&&A===Mo.Initializing&&C(Mo.Initialized)},[q,A]),b.useEffect(()=>{const{onDragMove:Gt}=V.current,{active:un,activatorEvent:dn,collisions:Se,over:Ne}=K.current;if(!un||!dn)return;const Ge={active:un,activatorEvent:dn,collisions:Se,delta:{x:At.x,y:At.y},over:Ne};Lo.unstable_batchedUpdates(()=>{Gt==null||Gt(Ge),g({type:"onDragMove",event:Ge})})},[At.x,At.y]),b.useEffect(()=>{const{active:Gt,activatorEvent:un,collisions:dn,droppableContainers:Se,scrollAdjustedTranslate:Ne}=K.current;if(!Gt||M.current==null||!un||!Ne)return;const{onDragOver:Ge}=V.current,nt=Se.get(lo),lt=nt&&nt.rect.current?{id:nt.id,rect:nt.rect.current,data:nt.data,disabled:nt.disabled}:null,ct={active:Gt,activatorEvent:un,collisions:dn,delta:{x:Ne.x,y:Ne.y},over:lt};Lo.unstable_batchedUpdates(()=>{bi(lt),Ge==null||Ge(ct),g({type:"onDragOver",event:ct})})},[lo]),Vr(()=>{K.current={activatorEvent:$,active:F,activeNode:ie,collisionRect:ht,collisions:ot,droppableRects:H,draggableNodes:S,draggingNode:he,draggingNodeRect:Ce,droppableContainers:O,over:Wn,scrollableAncestors:de,scrollAdjustedTranslate:At},N.current={initial:Ce,translated:ht}},[F,ie,ot,ht,S,he,Ce,H,O,Wn,de,At]),hY({...le,delta:_,draggingRect:ht,pointerCoordinates:tt,scrollableAncestors:de,scrollableAncestorRects:Te});const Ps=b.useMemo(()=>({active:F,activeNode:ie,activeNodeRect:q,activatorEvent:$,collisions:ot,containerNodeRect:J,dragOverlay:se,draggableNodes:S,droppableContainers:O,droppableRects:H,over:Wn,measureDroppableContainers:j,scrollableAncestors:de,scrollableAncestorRects:Te,measuringConfiguration:te,measuringScheduled:Y,windowRect:Le}),[F,ie,q,$,ot,J,se,S,O,H,Wn,j,de,Te,te,Y,Le]),Ow=b.useMemo(()=>({activatorEvent:$,activators:ki,active:F,activeNodeRect:q,ariaDescribedById:{draggable:X},dispatch:y,draggableNodes:S,over:Wn,measureDroppableContainers:j}),[$,ki,F,q,y,X,S,Wn,j]);return b.createElement(KO.Provider,{value:k},b.createElement(Td.Provider,{value:Ow},b.createElement(yT.Provider,{value:Ps},b.createElement(bT.Provider,{value:Is},c)),b.createElement(PY,{disabled:(a==null?void 0:a.restoreFocus)===!1})),b.createElement(LK,{...a,hiddenTextDescribedById:X}));function Tw(){const Gt=(T==null?void 0:T.autoScrollEnabled)===!1,un=typeof l=="object"?l.enabled===!1:l===!1,dn=E&&!Gt&&!un;return typeof l=="object"?{...l,enabled:dn}:{enabled:dn}}}),jY=b.createContext(null),CT="button",VY="Draggable";function WY(t){let{id:e,data:n,disabled:r=!1,attributes:o}=t;const i=cl(VY),{activators:s,activatorEvent:a,active:l,activeNodeRect:c,ariaDescribedById:u,draggableNodes:d,over:h}=b.useContext(Td),{role:p=CT,roleDescription:m="draggable",tabIndex:w=0}=o??{},v=(l==null?void 0:l.id)===e,y=b.useContext(v?bT:jY),[g,k]=xd(),[A,C]=xd(),E=DY(s,e),D=al(n);Vr(()=>(d.set(e,{id:e,key:i,node:g,activatorNode:A,data:D}),()=>{const _=d.get(e);_&&_.key===i&&d.delete(e)}),[d,e]);const S=b.useMemo(()=>({role:p,tabIndex:w,"aria-disabled":r,"aria-pressed":v&&p===CT?!0:void 0,"aria-roledescription":m,"aria-describedby":u.draggable}),[r,p,w,v,m,u.draggable]);return{active:l,activatorEvent:a,activeNodeRect:c,attributes:S,isDragging:v,listeners:r?void 0:E,node:g,over:h,setNodeRef:k,setActivatorNodeRef:C,transform:y}}function UY(){return b.useContext(yT)}const qY="Droppable",GY={timeout:25};function KY(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:o}=t;const i=cl(qY),{active:s,dispatch:a,over:l,measureDroppableContainers:c}=b.useContext(Td),u=b.useRef({disabled:n}),d=b.useRef(!1),h=b.useRef(null),p=b.useRef(null),{disabled:m,updateMeasurementsFor:w,timeout:v}={...GY,...o},y=al(w??r),g=b.useCallback(()=>{if(!d.current){d.current=!0;return}p.current!=null&&clearTimeout(p.current),p.current=setTimeout(()=>{c(Array.isArray(y.current)?y.current:[y.current]),p.current=null},v)},[v]),k=Ad({callback:g,disabled:m||!s}),A=b.useCallback((S,_)=>{k&&(_&&(k.unobserve(_),d.current=!1),S&&k.observe(S))},[k]),[C,E]=xd(A),D=al(e);return b.useEffect(()=>{!k||!C.current||(k.disconnect(),d.current=!1,k.observe(C.current))},[C,k]),b.useEffect(()=>(a({type:jt.RegisterDroppable,element:{id:r,key:i,disabled:n,node:C,rect:h,data:D}}),()=>a({type:jt.UnregisterDroppable,key:i,id:r})),[r]),b.useEffect(()=>{n!==u.current.disabled&&(a({type:jt.SetDroppableDisabled,id:r,key:i,disabled:n}),u.current.disabled=n)},[r,i,n,a]),{active:s,rect:h,isOver:(l==null?void 0:l.id)===r,node:C,over:l,setNodeRef:E}}const YY=t=>{let{transform:e}=t;return{...e,x:0}};function Dw(t,e,n){const r=t.slice();return r.splice(n<0?r.length+n:n,0,r.splice(e,1)[0]),r}function XY(t,e){return t.reduce((n,r,o)=>{const i=e.get(r);return i&&(n[o]=i),n},Array(t.length))}function _d(t){return t!==null&&t>=0}function JY(t,e){if(t===e)return!0;if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}function RY(t){return typeof t=="boolean"?{draggable:t,droppable:t}:t}const kT=t=>{let{rects:e,activeIndex:n,overIndex:r,index:o}=t;const i=Dw(e,r,n),s=e[o],a=i[o];return!a||!s?null:{x:a.left-s.left,y:a.top-s.top,scaleX:a.width/s.width,scaleY:a.height/s.height}},Nd={scaleX:1,scaleY:1},QY=t=>{var e;let{activeIndex:n,activeNodeRect:r,index:o,rects:i,overIndex:s}=t;const a=(e=i[n])!=null?e:r;if(!a)return null;if(o===n){const c=i[s];return c?{x:0,y:n<s?c.top+c.height-(a.top+a.height):c.top-a.top,...Nd}:null}const l=ZY(i,o,n);return o>n&&o<=s?{x:0,y:-a.height-l,...Nd}:o<n&&o>=s?{x:0,y:a.height+l,...Nd}:{x:0,y:0,...Nd}};function ZY(t,e,n){const r=t[e],o=t[e-1],i=t[e+1];return r?n<e?o?r.top-(o.top+o.height):i?i.top-(r.top+r.height):0:i?i.top-(r.top+r.height):o?r.top-(o.top+o.height):0:0}const xT="Sortable",ST=b.createContext({activeIndex:-1,containerId:xT,disableTransforms:!1,items:[],overIndex:-1,useDragOverlay:!1,sortedRects:[],strategy:kT,disabled:{draggable:!1,droppable:!1}});function eX(t){let{children:e,id:n,items:r,strategy:o=kT,disabled:i=!1}=t;const{active:s,dragOverlay:a,droppableRects:l,over:c,measureDroppableContainers:u}=UY(),d=cl(xT,n),h=a.rect!==null,p=b.useMemo(()=>r.map(E=>typeof E=="object"&&"id"in E?E.id:E),[r]),m=s!=null,w=s?p.indexOf(s.id):-1,v=c?p.indexOf(c.id):-1,y=b.useRef(p),g=!JY(p,y.current),k=v!==-1&&w===-1||g,A=RY(i);Vr(()=>{g&&m&&u(p)},[g,p,m,u]),b.useEffect(()=>{y.current=p},[p]);const C=b.useMemo(()=>({activeIndex:w,containerId:d,disabled:A,disableTransforms:k,items:p,overIndex:v,useDragOverlay:h,sortedRects:XY(p,l),strategy:o}),[w,d,A.draggable,A.droppable,k,p,v,l,h,o]);return b.createElement(ST.Provider,{value:C},e)}const tX=t=>{let{id:e,items:n,activeIndex:r,overIndex:o}=t;return Dw(n,r,o).indexOf(e)},nX=t=>{let{containerId:e,isSorting:n,wasDragging:r,index:o,items:i,newIndex:s,previousItems:a,previousContainerId:l,transition:c}=t;return!c||!r||a!==i&&o===s?!1:n?!0:s!==o&&e===l},rX={duration:200,easing:"ease"},ET="transform",oX=dl.Transition.toString({property:ET,duration:0,easing:"linear"}),iX={roleDescription:"sortable"};function sX(t){let{disabled:e,index:n,node:r,rect:o}=t;const[i,s]=b.useState(null),a=b.useRef(n);return Vr(()=>{if(!e&&n!==a.current&&r.current){const l=o.current;if(l){const c=Ns(r.current,{ignoreTransform:!0}),u={x:l.left-c.left,y:l.top-c.top,scaleX:l.width/c.width,scaleY:l.height/c.height};(u.x||u.y)&&s(u)}}n!==a.current&&(a.current=n)},[e,n,r,o]),b.useEffect(()=>{i&&s(null)},[i]),i}function aX(t){let{animateLayoutChanges:e=nX,attributes:n,disabled:r,data:o,getNewIndex:i=tX,id:s,strategy:a,resizeObserverConfig:l,transition:c=rX}=t;const{items:u,containerId:d,activeIndex:h,disabled:p,disableTransforms:m,sortedRects:w,overIndex:v,useDragOverlay:y,strategy:g}=b.useContext(ST),k=lX(r,p),A=u.indexOf(s),C=b.useMemo(()=>({sortable:{containerId:d,index:A,items:u},...o}),[d,o,A,u]),E=b.useMemo(()=>u.slice(u.indexOf(s)),[u,s]),{rect:D,node:S,isOver:_,setNodeRef:O}=KY({id:s,data:C,disabled:k.droppable,resizeObserverConfig:{updateMeasurementsFor:E,...l}}),{active:B,activatorEvent:N,activeNodeRect:F,attributes:M,setNodeRef:T,listeners:P,isDragging:$,over:W,setActivatorNodeRef:V,transform:X}=WY({id:s,data:C,attributes:{...iX,...n},disabled:k.draggable}),G=SK(O,T),te=!!B,H=te&&!m&&_d(h)&&_d(v),j=!y&&$,Y=j&&H?X:null,Q=H?Y??(a??g)({rects:w,activeNodeRect:F,activeIndex:h,overIndex:v,index:A}):null,le=_d(h)&&_d(v)?i({id:s,items:u,activeIndex:h,overIndex:v}):A,L=B==null?void 0:B.id,q=b.useRef({activeId:L,items:u,newIndex:le,containerId:d}),J=u!==q.current.items,K=e({active:B,containerId:d,isDragging:$,isSorting:te,id:s,index:A,items:u,newIndex:q.current.newIndex,previousItems:q.current.items,previousContainerId:q.current.containerId,transition:c,wasDragging:q.current.activeId!=null}),re=sX({disabled:!K,index:A,node:S,rect:D});return b.useEffect(()=>{te&&q.current.newIndex!==le&&(q.current.newIndex=le),d!==q.current.containerId&&(q.current.containerId=d),u!==q.current.items&&(q.current.items=u)},[te,le,d,u]),b.useEffect(()=>{if(L===q.current.activeId)return;if(L!=null&&q.current.activeId==null){q.current.activeId=L;return}const he=setTimeout(()=>{q.current.activeId=L},50);return()=>clearTimeout(he)},[L]),{active:B,activeIndex:h,attributes:M,data:C,rect:D,index:A,newIndex:le,items:u,isOver:_,isSorting:te,isDragging:$,listeners:P,node:S,overIndex:v,over:W,setNodeRef:G,setActivatorNodeRef:V,setDroppableNodeRef:O,setDraggableNodeRef:T,transform:re??Q,transition:se()};function se(){if(re||J&&q.current.newIndex===A)return oX;if(!(j&&!pw(N)||!c)&&(te||K))return dl.Transition.toString({...c,property:ET})}}function lX(t,e){var n,r;return typeof t=="boolean"?{draggable:t,droppable:!1}:{draggable:(n=t==null?void 0:t.draggable)!=null?n:e.draggable,droppable:(r=t==null?void 0:t.droppable)!=null?r:e.droppable}}function Bd(t){if(!t)return!1;const e=t.data.current;return!!(e&&"sortable"in e&&typeof e.sortable=="object"&&"containerId"in e.sortable&&"items"in e.sortable&&"index"in e.sortable)}const cX=[Je.Down,Je.Right,Je.Up,Je.Left],uX=(t,e)=>{let{context:{active:n,collisionRect:r,droppableRects:o,droppableContainers:i,over:s,scrollableAncestors:a}}=e;if(cX.includes(t.code)){if(t.preventDefault(),!n||!r)return;const l=[];i.getEnabled().forEach(d=>{if(!d||d!=null&&d.disabled)return;const h=o.get(d.id);if(h)switch(t.code){case Je.Down:r.top<h.top&&l.push(d);break;case Je.Up:r.top>h.top&&l.push(d);break;case Je.Left:r.left>h.left&&l.push(d);break;case Je.Right:r.left<h.left&&l.push(d);break}});const c=jK({collisionRect:r,droppableRects:o,droppableContainers:l});let u=QO(c,"id");if(u===(s==null?void 0:s.id)&&c.length>1&&(u=c[1].id),u!=null){const d=i.get(n.id),h=i.get(u),p=h?o.get(h.id):null,m=h==null?void 0:h.node.current;if(m&&p&&d&&h){const v=Ed(m).some((E,D)=>a[D]!==E),y=DT(d,h),g=dX(d,h),k=v||!y?{x:0,y:0}:{x:g?r.width-p.width:0,y:g?r.height-p.height:0},A={x:p.left,y:p.top};return k.x&&k.y?A:ul(A,k)}}}};function DT(t,e){return!Bd(t)||!Bd(e)?!1:t.data.current.sortable.containerId===e.data.current.sortable.containerId}function dX(t,e){return!Bd(t)||!Bd(e)||!DT(t,e)?!1:t.data.current.sortable.index<e.data.current.sortable.index}const Me={"multiRowGuard-container":"_multiRowGuard-container_4gqpc_1","multiRowGuard-ruleCard":"_multiRowGuard-ruleCard_4gqpc_4",isDragging:"_isDragging_4gqpc_17",hasError:"_hasError_4gqpc_23","multiRowGuard-ruleHeader":"_multiRowGuard-ruleHeader_4gqpc_30","multiRowGuard-dragHandle":"_multiRowGuard-dragHandle_4gqpc_38","multiRowGuard-ruleIndex":"_multiRowGuard-ruleIndex_4gqpc_53","multiRowGuard-deleteBtn":"_multiRowGuard-deleteBtn_4gqpc_57","multiRowGuard-ruleBody":"_multiRowGuard-ruleBody_4gqpc_65","multiRowGuard-formRow":"_multiRowGuard-formRow_4gqpc_70","multiRowGuard-formItem":"_multiRowGuard-formItem_4gqpc_75","multiRowGuard-formLabel":"_multiRowGuard-formLabel_4gqpc_82",required:"_required_4gqpc_88","multiRowGuard-extraFields":"_multiRowGuard-extraFields_4gqpc_93","multiRowGuard-rangeInputs":"_multiRowGuard-rangeInputs_4gqpc_98","multiRowGuard-rangeInput":"_multiRowGuard-rangeInput_4gqpc_98","multiRowGuard-rangeSeparator":"_multiRowGuard-rangeSeparator_4gqpc_106","multiRowGuard-addBtn":"_multiRowGuard-addBtn_4gqpc_110","multiRowGuard-emptyState":"_multiRowGuard-emptyState_4gqpc_113","multiRowGuard-emptyState-icon":"_multiRowGuard-emptyState-icon_4gqpc_121","multiRowGuard-emptyState-text":"_multiRowGuard-emptyState-text_4gqpc_126","multiRowGuard-enumTagsContainer":"_multiRowGuard-enumTagsContainer_4gqpc_129","multiRowGuard-errorText":"_multiRowGuard-errorText_4gqpc_133","multiRowGuard-fieldError":"_multiRowGuard-fieldError_4gqpc_139"},fX=[{label:"必填校验",value:Lt.REQUIRED},{label:"数据类型校验",value:Lt.TYPE},{label:"枚举校验",value:Lt.ENUM},{label:"数值范围校验",value:Lt.RANGE}],hX=[{label:"Error - 终止流程",value:_l.ERROR},{label:"Warning - 记录告警",value:_l.WARNING}],pX=[{label:"字符串 (string)",value:Oi.STRING},{label:"数字 (number)",value:Oi.NUMBER},{label:"布尔值 (boolean)",value:Oi.BOOLEAN},{label:"对象 (object)",value:Oi.OBJECT},{label:"数组 (array)",value:Oi.ARRAY}],mX=(t,e)=>{const n=e+1;if(!t.field_path||t.field_path.trim()==="")return`规则 ${n}: 字段路径不能为空`;if(!t.rule_type)return`规则 ${n}: 请选择校验规则类型`;if(!t.severity)return`规则 ${n}: 请选择失败处理方式`;switch(t.rule_type){case Lt.TYPE:if(!t.expected_type)return`规则 ${n}: 请选择期望数据类型`;break;case Lt.ENUM:if(!t.enum_values||t.enum_values.length===0)return`规则 ${n}: 请输入至少一个枚举值`;break;case Lt.RANGE:if(t.min===void 0&&t.max===void 0)return`规则 ${n}: 最小值和最大值至少填写一项`;if(t.min!==void 0&&t.max!==void 0&&t.min>t.max)return`规则 ${n}: 最小值不能大于最大值`;break}return null},gX=(t,e)=>{if(!e||e.length===0)return Promise.resolve();for(let n=0;n<e.length;n++){const r=mX(e[n],n);if(r)return Promise.reject(new Error(r))}return Promise.resolve()},wX=(t,e)=>!e||e.length===0?Promise.reject(new Error("请至少添加一条校验规则")):Promise.resolve(),vX=()=>({id:er(),field_path:"",rule_type:Lt.REQUIRED,severity:_l.ERROR,message:""}),yX=t=>{const e=[];switch((!t.field_path||t.field_path.trim()==="")&&e.push({ruleId:t.id,field:"field_path",message:"字段路径不能为空"}),t.rule_type||e.push({ruleId:t.id,field:"rule_type",message:"请选择校验规则类型"}),t.severity||e.push({ruleId:t.id,field:"severity",message:"请选择失败处理方式"}),t.rule_type){case Lt.TYPE:t.expected_type||e.push({ruleId:t.id,field:"expected_type",message:"请选择期望数据类型"});break;case Lt.ENUM:(!t.enum_values||t.enum_values.length===0)&&e.push({ruleId:t.id,field:"enum_values",message:"请输入至少一个枚举值"});break;case Lt.RANGE:t.min===void 0&&t.max===void 0&&e.push({ruleId:t.id,field:"min",message:"最小值和最大值至少填写一项"}),t.min!==void 0&&t.max!==void 0&&t.min>t.max&&e.push({ruleId:t.id,field:"min",message:"最小值不能大于最大值"});break}return e},Bs=(t,e,n)=>{var r;return(r=t.find(o=>o.ruleId===e&&o.field===n))==null?void 0:r.message},bX=({rule:t,index:e,disabled:n=!1,nodeId:r,errors:o,onUpdate:i,onDelete:s})=>{const{attributes:a,listeners:l,setNodeRef:c,setActivatorNodeRef:u,transform:d,transition:h,isDragging:p}=aX({id:t.id,disabled:n}),m={transform:dl.Transform.toString(d&&{...d,scaleY:1}),transition:h},w=Bs(o,t.id,"field_path"),v=Bs(o,t.id,"rule_type"),y=Bs(o,t.id,"severity"),g=Bs(o,t.id,"expected_type"),k=Bs(o,t.id,"enum_values"),A=Bs(o,t.id,"min"),C=o.some(S=>S.ruleId===t.id),E=S=>{const _=S.map(O=>{const B=Number(O);return!isNaN(B)&&O.trim()!==""?B:O});i(t.id,{enum_values:_})},D=()=>{var S;switch(t.rule_type){case Lt.TYPE:return f.jsxs("div",{className:Me["multiRowGuard-formItem"],children:[f.jsx("span",{className:`${Me["multiRowGuard-formLabel"]} ${Me.required}`,children:"期望数据类型"}),f.jsx(x.Select,{value:t.expected_type,onChange:_=>i(t.id,{expected_type:_}),options:pX,placeholder:"请选择数据类型",style:{width:"100%"},disabled:n,status:g?"error":void 0}),g&&f.jsx("div",{className:Me["multiRowGuard-errorText"],children:g})]});case Lt.ENUM:return f.jsxs("div",{className:Me["multiRowGuard-formItem"],children:[f.jsx("span",{className:`${Me["multiRowGuard-formLabel"]} ${Me.required}`,children:"枚举值列表"}),f.jsx(x.Select,{mode:"tags",value:((S=t.enum_values)==null?void 0:S.map(String))??[],onChange:E,placeholder:"输入枚举值后按回车添加",style:{width:"100%"},disabled:n,className:Me["multiRowGuard-enumTagsContainer"],tokenSeparators:[","],status:k?"error":void 0}),k&&f.jsx("div",{className:Me["multiRowGuard-errorText"],children:k})]});case Lt.RANGE:return f.jsxs("div",{className:Me["multiRowGuard-formItem"],children:[f.jsx("span",{className:Me["multiRowGuard-formLabel"],children:"数值范围"}),f.jsxs("div",{className:Me["multiRowGuard-rangeInputs"],children:[f.jsx(x.InputNumber,{className:Me["multiRowGuard-rangeInput"],value:t.min,onChange:_=>i(t.id,{min:_??void 0}),placeholder:"最小值",disabled:n,status:A?"error":void 0}),f.jsx("span",{className:Me["multiRowGuard-rangeSeparator"],children:"至"}),f.jsx(x.InputNumber,{className:Me["multiRowGuard-rangeInput"],value:t.max,onChange:_=>i(t.id,{max:_??void 0}),placeholder:"最大值",disabled:n,status:A?"error":void 0})]}),A&&f.jsx("div",{className:Me["multiRowGuard-errorText"],children:A})]});default:return null}};return f.jsxs("div",{ref:c,style:m,className:`${Me["multiRowGuard-ruleCard"]} ${p?Me.isDragging:""} ${C?Me.hasError:""}`,children:[f.jsxs("div",{className:Me["multiRowGuard-ruleHeader"],children:[f.jsxs("div",{ref:u,className:Me["multiRowGuard-dragHandle"],...a,...l,children:[f.jsx(Z.HolderOutlined,{}),f.jsxs("span",{className:Me["multiRowGuard-ruleIndex"],children:["规则 ",e+1]})]}),!n&&f.jsx(Z.DeleteOutlined,{className:Me["multiRowGuard-deleteBtn"],onClick:()=>s(t.id)})]}),f.jsxs("div",{className:Me["multiRowGuard-ruleBody"],children:[f.jsxs("div",{className:Me["multiRowGuard-formRow"],children:[f.jsxs("div",{className:Me["multiRowGuard-formItem"],children:[f.jsx("span",{className:`${Me["multiRowGuard-formLabel"]} ${Me.required}`,children:"字段路径"}),f.jsx("div",{className:w?Me["multiRowGuard-fieldError"]:void 0,children:f.jsx(tr,{value:t.field_path,onChange:S=>i(t.id,{field_path:S}),placeholder:"如:data.order_id",disabled:n,nodeId:r,borrow:!0,valueType:"ADAPTOR"})}),w&&f.jsx("div",{className:Me["multiRowGuard-errorText"],children:w})]}),f.jsxs("div",{className:Me["multiRowGuard-formItem"],children:[f.jsx("span",{className:`${Me["multiRowGuard-formLabel"]} ${Me.required}`,children:"校验规则类型"}),f.jsx(x.Select,{value:t.rule_type,onChange:S=>{const _={rule_type:S};S!==Lt.TYPE&&(_.expected_type=void 0),S!==Lt.ENUM&&(_.enum_values=void 0),S!==Lt.RANGE&&(_.min=void 0,_.max=void 0),i(t.id,_)},options:fX,style:{width:"100%"},disabled:n,status:v?"error":void 0}),v&&f.jsx("div",{className:Me["multiRowGuard-errorText"],children:v})]})]}),t.rule_type!==Lt.REQUIRED&&f.jsx("div",{className:Me["multiRowGuard-extraFields"],children:D()}),f.jsxs("div",{className:Me["multiRowGuard-formRow"],children:[f.jsxs("div",{className:Me["multiRowGuard-formItem"],children:[f.jsx("span",{className:`${Me["multiRowGuard-formLabel"]} ${Me.required}`,children:"失败处理方式"}),f.jsx(x.Select,{value:t.severity,onChange:S=>i(t.id,{severity:S}),options:hX,style:{width:"100%"},disabled:n,status:y?"error":void 0}),y&&f.jsx("div",{className:Me["multiRowGuard-errorText"],children:y})]}),f.jsxs("div",{className:Me["multiRowGuard-formItem"],children:[f.jsx("span",{className:Me["multiRowGuard-formLabel"],children:"错误提示"}),f.jsx(tr,{value:t.message,onChange:S=>i(t.id,{message:S}),placeholder:"自定义错误提示信息(可选)",disabled:n,nodeId:r,valueType:"FIX_VALUE",disableIDE:!0})]})]})]})]})},AT=b.forwardRef(({value:t,onChange:e,disabled:n=!1,nodeId:r=""},o)=>{const[i,s]=b.useState([]),[a,l]=b.useState([]),c=$K(YO(kw,{activationConstraint:{distance:8}}),YO(bw,{coordinateGetter:uX}));b.useEffect(()=>{const k=(t??[]).map(A=>({...A,id:A.id??er()}));s(k)},[t]);const u=b.useCallback(()=>{const g=[];return i.forEach(k=>{const A=yX(k);g.push(...A)}),l(g),g.length===0},[i]),d=b.useCallback(()=>a,[a]),h=b.useCallback(()=>{l([])},[]);b.useImperativeHandle(o,()=>({validate:u,getErrors:d,clearErrors:h}),[u,d,h]);const p=b.useCallback(g=>{e==null||e(g)},[e]),m=b.useCallback(()=>{const g=[...i,vX()];s(g),p(g)},[i,p]),w=b.useCallback(g=>{const k=i.filter(A=>A.id!==g);s(k),p(k),l(A=>A.filter(C=>C.ruleId!==g))},[i,p]),v=b.useCallback((g,k)=>{const A=i.map(E=>E.id===g?{...E,...k}:E);s(A),p(A);const C=Object.keys(k);l(E=>E.filter(D=>!(D.ruleId===g&&C.includes(D.field))))},[i,p]),y=b.useCallback(g=>{const{active:k,over:A}=g;if(A&&k.id!==A.id){const C=i.findIndex(S=>S.id===k.id),E=i.findIndex(S=>S.id===A.id),D=Dw(i,C,E);s(D),p(D)}},[i,p]);return f.jsxs("div",{className:Me["multiRowGuard-container"],children:[i.length>0?f.jsx(zY,{sensors:c,collisionDetection:zK,modifiers:[YY],onDragEnd:y,children:f.jsx(eX,{items:i.map(g=>g.id),strategy:QY,children:i.map((g,k)=>f.jsx(bX,{rule:g,index:k,disabled:n,nodeId:r,errors:a,onUpdate:v,onDelete:w},g.id))})}):f.jsxs("div",{className:Me["multiRowGuard-emptyState"],children:[f.jsx(Z.SafetyCertificateOutlined,{className:Me["multiRowGuard-emptyState-icon"]}),f.jsx("div",{className:Me["multiRowGuard-emptyState-text"],children:"暂无校验规则,点击下方按钮添加"})]}),!n&&f.jsx(x.Button,{type:"dashed",onClick:m,block:!0,icon:f.jsx(Z.PlusOutlined,{}),className:Me["multiRowGuard-addBtn"],children:"添加校验规则"})]})});AT.displayName="MultiRowGuard";const CX={nativeProps:{},registerComponents:{form:[{name:"MULTI_ROW_GUARD",component:AT,additionalRules:()=>[{validateTrigger:"blur",validator:gX},{validateTrigger:"blur",validator:wX}]},{name:"CONFIG_SUB_FLOW",component:WO}]},grid:{enabled:!0,size:20},miniMap:!0,header:!0,controls:!0,fastOperationButtons:!0,mode:"edit",allowRemoveTrigger:!0,fixedNodes:{triggerIds:[]},selectable:{includeNodeIds:void 0,includeCategories:void 0},limits:{maxNodes:1/0}},kX={types:{trigger:{id:"trigger",category:"Trigger",style:{colors:{success:"#00C853",warning:"#FFD600",error:"#D50000"},card:{radius:8,padding:12,borderColor:"#e0e0e0"},icon:{size:20,radius:4,url:""}},operations:[{id:"copy",label:"复制",enabled:!0},{id:"delete",label:"删除",enabled:!1}]},action:{id:"action",category:"Action",style:{colors:{success:"#00C853",warning:"#FFD600",error:"#D50000"},card:{radius:8,padding:12,borderColor:"#bdbdbd"},icon:{size:20,radius:4,url:""}},operations:[{id:"copy",label:"复制",enabled:!0},{id:"delete",label:"删除",enabled:!0}]}},fixed:{triggers:[],finalAction:void 0}},xX={buttons:[],flowName:{editable:!0,defaultNameRule:()=>`未命名流程-${Date.now()}`,fixedTitle:void 0},nav:{showBack:!0,showHome:!0,backTo:void 0,confirmOnBackWhenOffline:!0,backConfirmMessage:void 0},enableOnlineButton:!0,enableSaveButton:!0,flowStatusTag:{enabled:!0,style:{}},helpDocUrl:void 0,helpDocText:void 0,enableOnlineConfirmMessage:void 0,enableFlowText:void 0},SX={allowAddNodeOnEdge:!0,allowDeleteEdge:!0,validators:[]},EX={tabs:[],showSettings:!0,testArea:{allowManualTest:!0,defaultTestResult:null}},Fd={flowId:"",engineMode:or.CLASSIC,canvas:CX,nodeTypes:kX,edgeRules:SX,toolbar:xX,nodeConfigPanel:EX},DX={arrayStrategy:"append",mergeByIdKeys:["id"]},Id=t=>t&&typeof t=="object"&&!Array.isArray(t);function AX(t,e,n){var o;const r=n.arrayStrategy||"append";if(r==="override")return[...e];if(r==="append")return[...t,...e];if(r==="mergeById"){const i=((o=n.mergeByIdKeys)==null?void 0:o[0])||"id",s=new Map;return t.forEach(a=>s.set(a[i],{...a})),e.forEach(a=>{const l=a[i];s.has(l)?s.set(l,Aw(s.get(l),a,n)):s.set(l,{...a})}),Array.from(s.values())}return[...t]}function Aw(t,e,n=DX){const r={...t};return!Id(t)||!Id(e)?{...e}:(Object.keys(e).forEach(o=>{const i=e[o],s=t[o];if(i!==void 0){if(Array.isArray(s)&&Array.isArray(i)){r[o]=AX(s,i,n);return}if(Id(s)&&Id(i)){r[o]=Aw(s,i,n);return}r[o]=i}}),r)}function OT(t,e,n){return Aw(t,e,n)}let Md={};const OX=t=>{if(Md={...Md,...t},t.httpClient){const e=t.httpClient;if(typeof e=="function")jo({httpClient:e});else{const n=e;jo({httpClient:async(o,i)=>{var h;const{method:s="GET",params:a,data:l,headers:c}=i||{},u=s.toLowerCase(),d={params:a,headers:c};try{let p;switch(u){case"get":p=await n.get(o,d);break;case"post":p=await n.post(o,l,d);break;case"put":p=await n.put(o,l,d);break;case"patch":p=await n.patch(o,l,d);break;case"delete":p=await n.delete(o,d);break;default:p=await n.request({...d,url:o,method:s,data:l})}return((h=p==null?void 0:p.data)==null?void 0:h.data)!==void 0?p.data.data:(p==null?void 0:p.data)||p}catch(p){throw p}}})}}(t.baseUrl!==void 0||t.token!==void 0)&&jo({...t.baseUrl!==void 0?{baseUrl:t.baseUrl}:{},...t.token!==void 0?{token:t.token}:{}})},TX=()=>({...Md}),_X=()=>{Md={}},TT=({id:t="input",position:e=ae.Position.Left,style:n={},isConnectable:r=!0,isValidConnection:o,onConnect:i})=>f.jsx(ae.Handle,{type:"target",id:t,position:e,style:n,isConnectable:r,isValidConnection:o,onConnect:i,className:"workflow-handle workflow-input-handle"}),_T=({id:t="output",position:e=ae.Position.Right,style:n={},isConnectable:r=!0,isValidConnection:o,onConnect:i})=>f.jsx(ae.Handle,{type:"source",id:t,position:e,style:n,isConnectable:r,isValidConnection:o,onConnect:i,className:"workflow-handle workflow-output-handle"});class NX{static createInputHandle(e,n=ae.Position.Left,r={}){return f.jsx(TT,{id:e,position:n,...r})}static createOutputHandle(e,n=ae.Position.Right,r={}){return f.jsx(_T,{id:e,position:n,...r})}static createInputHandles(e,n=ae.Position.Left,r={}){return Array(e).fill(0).map((o,i)=>f.jsx(TT,{id:`input_${i}`,position:n,style:{top:`${(i+1)*100/(e+1)}%`},...r},`input_${i}`))}static createOutputHandles(e,n=ae.Position.Right,r={}){return Array(e).fill(0).map((o,i)=>f.jsx(_T,{id:`output-${i}`,position:n,style:{top:`${(i+1)*100/(e+1)}%`},...r},`output-${i}`))}}const BX=(t=100)=>{const[e,n]=b.useState([]),[r,o]=b.useState([]),[i,s]=b.useState(!1),{getNodes:a,getEdges:l,setNodes:c,setEdges:u}=ae.useReactFlow();b.useEffect(()=>{if(i)return;const m=setTimeout(()=>{const w={nodes:a(),edges:l()},v=e[0];v&&JSON.stringify(v.nodes)===JSON.stringify(w.nodes)&&JSON.stringify(v.edges)===JSON.stringify(w.edges)||(n(y=>{const g=[w,...y];return g.length>t&&g.pop(),g}),o([]))},500);return()=>clearTimeout(m)},[a,l,e,i,t]);const d=b.useCallback(()=>{const[p,...m]=e;p&&(s(!0),o(w=>[{nodes:a(),edges:l()},...w]),n(m),c(p.nodes),u(p.edges),setTimeout(()=>s(!1),100))},[e,a,l,c,u]),h=b.useCallback(()=>{const[p,...m]=r;p&&(s(!0),n(w=>[{nodes:a(),edges:l()},...w]),o(m),c(p.nodes),u(p.edges),setTimeout(()=>s(!1),100))},[r,a,l,c,u]);return{undo:d,redo:h,canUndo:e.length>0,canRedo:r.length>0,history:e,future:r}},FX=t=>{var v,y,g,k;const{config:e,workflowId:n,locale:r="zh-CN",apiBaseUrl:o,apiToken:i,httpClient:s,history:a,engineMode:l}=t,c=b.useRef(null);n&&(Fd.flowId=n||"");const u=b.useMemo(()=>{const A=e?OT(Fd,e):{...Fd};return l&&(A.engineMode=l),s&&(A.httpClient=s),a&&(A.history=a),A},[e,s,a,l]),d=b.useRef(void 0);u.httpClient&&u.httpClient!==d.current&&(jo({httpClient:u.httpClient}),d.current=u.httpClient),(o!==((v=c.current)==null?void 0:v.baseUrl)||i!==((y=c.current)==null?void 0:y.token))&&(o!==void 0||i!==void 0?jo({...o!==void 0?{baseUrl:o}:{},...i!==void 0?{token:i}:{}}):(((g=c.current)==null?void 0:g.baseUrl)!==void 0||((k=c.current)==null?void 0:k.token)!==void 0)&&jo({baseUrl:"",token:""}),c.current={baseUrl:o,token:i});const p=b.useMemo(()=>Mw(r),[r]),m=r==="zh-TW"?$T:r==="en-US"?LT:Nw,w=u.engineMode===or.NEXT?qG:CK;return f.jsx(x.ConfigProvider,{locale:m,children:f.jsx(Ee.IntlProvider,{messages:p,locale:r,children:f.jsx($d.Provider,{store:tg,children:f.jsx(MN,{value:u,children:f.jsx(ae.ReactFlowProvider,{children:f.jsx(w,{workflowId:n,readOnly:t.readOnly,preview:t.preview,previewId:t.previewId,appFlowMode:t.appFlowMode,linkMode:t.linkMode,onSave:t.onSave,onInit:t.onInit})})})})})})},Pd=t=>typeof t!="string"?!1:/\{\{.*\}\}/.test(t),IX=({value:t,onChange:e,allowExpression:n=!0,defaultValueMode:r="select",valueMode:o,onValueModeChange:i,validateVariable:s,expressionPlaceholder:a="输入表达式,支持 {{变量}}",hideModeSwitch:l=!1,options:c,placeholder:u,disabled:d,...h})=>{const p=b.useMemo(()=>Pd(t)?"expression":r,[]),[m,w]=b.useState(p),v=o??m;b.useEffect(()=>{o!==void 0&&w(o)},[o]),b.useEffect(()=>{Pd(t)&&v!=="expression"&&(w("expression"),i==null||i("expression"))},[t,v,i]);const y=b.useCallback(E=>{w(E),i==null||i(E),E==="select"&&Pd(t)&&(e==null||e(void 0))},[t,e,i]),g=b.useCallback(E=>{e==null||e(E)},[e]),k=b.useCallback(E=>{e==null||e(E)},[e]),A=()=>l||!n?null:f.jsx("div",{className:"select-expression-mode-switch",children:f.jsxs(x.Radio.Group,{value:v,onChange:E=>y(E.target.value),size:"small",disabled:d,optionType:"button",buttonStyle:"solid",children:[f.jsxs(x.Radio.Button,{value:"select",title:"下拉选择模式",children:[f.jsx(Z.FontSizeOutlined,{}),f.jsx("span",{className:"mode-label",children:"选择"})]}),f.jsxs(x.Radio.Button,{value:"expression",title:"表达式模式",children:[f.jsx(Z.FunctionOutlined,{}),f.jsx("span",{className:"mode-label",children:"表达式"})]})]})}),C=()=>v==="expression"?f.jsx(bc,{value:typeof t=="string"?t:"",onChange:k,placeholder:a,disabled:d,validateVariable:s}):f.jsx(x.Select,{...h,value:Pd(t)?void 0:t,onChange:g,options:c,placeholder:u,disabled:d});return f.jsxs("div",{className:"select-with-expression",children:[A(),f.jsx("div",{className:"select-expression-content",children:C()})]})};function MX(t){const{dataSource:e,dataLoader:n,values:r,initialData:o,immediate:i=!0,context:s={},transform:a}=t,[l,c]=b.useState(o),[u,d]=b.useState(!1),[h,p]=b.useState(),m=b.useRef(new Map),w=E=>!E||E.kind==="static"?[]:E.deps||[],v=b.useMemo(()=>e?JSON.stringify(e):"null",[e]),y=b.useMemo(()=>{const D=w(e).map(S=>qn(r,S));return JSON.stringify(D)},[e,r]),g=E=>E.cacheKey?E.cacheKey:`${E.action}:${y}`,k=E=>{if(!E.cache)return;const D=g(E),S=m.current.get(D);if(S){if(E.cacheTTL&&Date.now()-S.timestamp>E.cacheTTL){m.current.delete(D);return}return S.data}},A=(E,D)=>{if(!E.cache)return;const S=g(E);m.current.set(S,{data:D,timestamp:Date.now()})},C=()=>{c(void 0),p(void 0)};return b.useEffect(()=>{if(!i)return;if(!e||e.kind==="static"){const N=e&&"data"in e?e.data:o,F=a&&N!==void 0?a(N):N;c(F);return}const E=e,D=k(E);if(D!==void 0){c(D);return}if(!n){const N=E.fallbackData??o,F=a&&N!==void 0?a(N):N;c(F);return}const _=w(E).reduce((N,F)=>(N[F]=qn(r,F),N),{}),O={...E.params||{},deps:_};d(!0),p(void 0);let B=!1;return n(E.action,O,{values:r,...s}).then(N=>{if(!B){const F=a?a(N):N;c(F),A(E,F)}}).catch(N=>{if(!B){const F=N instanceof Error?N:new Error(String(N));p(F);const M=E.fallbackData??o,T=a&&M!==void 0?a(M):M;c(T)}}).finally(()=>{B||d(!1)}),()=>{B=!0}},[y,v,i]),{data:l,loading:u,error:h,reload:C,setData:c}}fe.AIFieldWrapper=H0,fe.AI_FILL_VALUE=Zl,fe.AI_TOOL_NODE_TYPES=r0,fe.AntdProvider=F0,fe.DigitalseeWorkFlow=FX,fe.DynamicForm=Gi,fe.DynamicFormContext=Ef,fe.DynamicFormField=be,fe.DynamicFormProvider=L0,fe.EdgeFactory=Bt,fe.EngineMode=or,fe.FieldRegistryProvider=SB,fe.FieldRenderer=yh,fe.HandleFactory=NX,fe.NodeFactory=Bn,fe.NodeStatus=me,fe.NodeType=ee,fe.SelectWithExpression=IX,fe.ValueModeWrapper=la,fe.VariableInput=bc,fe.VariableSelectorProvider=kf,fe.VariableTextarea=dC,fe.WorkflowOpStatus=We,fe.aiProtocolTypes=n0,fe.arrowStyles=IN,fe.canvasGeometry=i0,fe.configureWorkflow=OX,fe.connectionRules=s0,fe.createFieldComponent=pt,fe.createFieldRegistry=xB,fe.createSimpleFieldComponent=go,fe.createTranslator=Pw,fe.defaultCanvasEngineConfig=Fd,fe.defaultFieldRegistry=Rl,fe.edgeButtonStyles=Ws,fe.edgeStyles=Vs,fe.evaluateCondition=Go,fe.extenderStyles=br,fe.getGlobalWorkflowConfig=TX,fe.handleStyles=Wo,fe.isFieldVisible=Ys,fe.jsonRulesToAntdRules=Mi,fe.labelStyles=o0,fe.mergeConfig=OT,fe.nodeTypeColors=Kt,fe.registerBuiltinFields=RC,fe.resetGlobalWorkflowConfig=_X,fe.resolveBool=Pi,fe.useCanvasApi=BO,fe.useCanvasConfig=Vt,fe.useCanvasLayout=kO,fe.useDataLoader=MX,fe.useDynamicFormContext=kB,fe.useFieldRegistry=Ql,fe.useRegisterVariableField=B0,fe.useUndo=BX,fe.useVariableSelector=lB,fe.useVariableSelectorOptional=xf,fe.useWorkflow=Cr,Object.defineProperty(fe,Symbol.toStringTag,{value:"Module"})}));
|
|
103
103
|
//# sourceMappingURL=rcs.umd.js.map
|